mirror of
https://github.com/harivansh-afk/clanker-agent.git
synced 2026-04-15 07:04:45 +00:00
fix(companion-os): address grind mode review feedback
Restore the bedrock provider import through an explicit workspace path mapping, align pi-grind package metadata with the existing package manifests, remove the unused controller-failure state path, and parse bare ISO dates in local time. Co-authored-by: Codex <noreply@openai.com>
This commit is contained in:
parent
8c92f479d6
commit
48fa514e7e
7 changed files with 38 additions and 19 deletions
|
|
@ -7,9 +7,9 @@
|
|||
*/
|
||||
process.title = "pi";
|
||||
|
||||
import { bedrockProviderModule } from "@mariozechner/pi-ai/bedrock-provider";
|
||||
import { setBedrockProviderModule } from "@mariozechner/pi-ai";
|
||||
import { EnvHttpProxyAgent, setGlobalDispatcher } from "undici";
|
||||
import { bedrockProviderModule } from "../../ai/src/bedrock-provider.js";
|
||||
import { main } from "./main.js";
|
||||
|
||||
setGlobalDispatcher(new EnvHttpProxyAgent());
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@
|
|||
"pi-package"
|
||||
],
|
||||
"license": "MIT",
|
||||
"author": "OpenAI",
|
||||
"author": "Mario Zechner",
|
||||
"main": "./src/index.ts",
|
||||
"files": [
|
||||
"src",
|
||||
|
|
|
|||
|
|
@ -52,7 +52,6 @@ export function createRunState(input: {
|
|||
lastNextAction: null,
|
||||
pendingRepair: false,
|
||||
consecutiveParseFailures: 0,
|
||||
consecutiveControllerFailures: 0,
|
||||
updatedAt: now,
|
||||
};
|
||||
}
|
||||
|
|
@ -75,7 +74,6 @@ export function isValidRunState(value: unknown): value is GrindRunState {
|
|||
isNullableString(value.lastNextAction) &&
|
||||
typeof value.pendingRepair === "boolean" &&
|
||||
typeof value.consecutiveParseFailures === "number" &&
|
||||
typeof value.consecutiveControllerFailures === "number" &&
|
||||
typeof value.updatedAt === "string"
|
||||
);
|
||||
}
|
||||
|
|
@ -114,19 +112,6 @@ export function withLoopStatus(state: GrindRunState, payload: GrindStatusPayload
|
|||
lastNextAction: payload.nextAction ?? null,
|
||||
pendingRepair: false,
|
||||
consecutiveParseFailures: 0,
|
||||
consecutiveControllerFailures: 0,
|
||||
updatedAt: new Date().toISOString(),
|
||||
};
|
||||
}
|
||||
|
||||
export function withControllerFailure(state: GrindRunState, note: string): GrindRunState {
|
||||
return {
|
||||
...state,
|
||||
status: "blocked",
|
||||
lastCheckpoint: note,
|
||||
lastNextAction: null,
|
||||
pendingRepair: false,
|
||||
consecutiveControllerFailures: state.consecutiveControllerFailures + 1,
|
||||
updatedAt: new Date().toISOString(),
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -47,6 +47,27 @@ function stripTrailingContinuation(text: string): string {
|
|||
.trim();
|
||||
}
|
||||
|
||||
function parseLocalDateOnly(candidate: string): Date | null {
|
||||
const match = candidate.match(/^(\d{4})-(\d{2})-(\d{2})$/);
|
||||
if (!match) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const year = Number(match[1]);
|
||||
const month = Number(match[2]);
|
||||
const day = Number(match[3]);
|
||||
const local = new Date(year, month - 1, day, 0, 0, 0, 0);
|
||||
if (
|
||||
local.getFullYear() !== year ||
|
||||
local.getMonth() !== month - 1 ||
|
||||
local.getDate() !== day
|
||||
) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return local;
|
||||
}
|
||||
|
||||
export function parseDeadline(raw: string, now: Date = new Date()): Date | null {
|
||||
const candidate = raw.trim();
|
||||
if (!candidate) {
|
||||
|
|
@ -85,6 +106,10 @@ export function parseDeadline(raw: string, now: Date = new Date()): Date | null
|
|||
|
||||
const time = parseClockValue(stripTrailingContinuation(normalized));
|
||||
if (!time) {
|
||||
const localDateOnly = parseLocalDateOnly(candidate);
|
||||
if (localDateOnly) {
|
||||
return localDateOnly;
|
||||
}
|
||||
const direct = new Date(candidate);
|
||||
if (!Number.isNaN(direct.getTime())) {
|
||||
return direct;
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ export interface ParsedStopCondition {
|
|||
}
|
||||
|
||||
export interface ParsedAutoActivation {
|
||||
matchedCue: string | null;
|
||||
matchedCue: string;
|
||||
stopCondition: ParsedStopCondition;
|
||||
}
|
||||
|
||||
|
|
@ -48,6 +48,5 @@ export interface GrindRunState {
|
|||
lastNextAction: string | null;
|
||||
pendingRepair: boolean;
|
||||
consecutiveParseFailures: number;
|
||||
consecutiveControllerFailures: number;
|
||||
updatedAt: string;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,6 +30,13 @@ describe("pi-grind parser", () => {
|
|||
expect(result?.stopCondition.deadlineAt).toBe(new Date(2026, 2, 10, 17, 30, 0).toISOString());
|
||||
});
|
||||
|
||||
it("parses bare ISO dates in local time instead of UTC midnight", () => {
|
||||
const result = parseStopCondition("keep going until 2026-03-10", now);
|
||||
|
||||
expect(result.deadlineAt).toBe(new Date(2026, 2, 10, 0, 0, 0).toISOString());
|
||||
expect(result.completionCriterion).toBeNull();
|
||||
});
|
||||
|
||||
it("parses grind status trailers", () => {
|
||||
const payload = parseGrindStatus(
|
||||
'Work done.\n<grind_status>{"state":"continue","summary":"half done","nextAction":"finish tests"}</grind_status>',
|
||||
|
|
|
|||
|
|
@ -5,6 +5,9 @@
|
|||
"paths": {
|
||||
"*": ["./*"],
|
||||
"@mariozechner/pi-ai": ["./packages/ai/src/index.ts"],
|
||||
"@mariozechner/pi-ai/bedrock-provider": [
|
||||
"./packages/ai/src/bedrock-provider.ts"
|
||||
],
|
||||
"@mariozechner/pi-ai/oauth": ["./packages/ai/src/oauth.ts"],
|
||||
"@mariozechner/pi-ai/*": ["./packages/ai/src/*"],
|
||||
"@mariozechner/pi-ai/dist/*": ["./packages/ai/src/*"],
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue