@marcoscale98/pi-extensible-workflows 5.17.0-fork.1 → 5.19.1-fork.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +68 -0
- package/dist/src/agent-execution.js +81 -39
- package/dist/src/background-widget.d.ts +5 -0
- package/dist/src/background-widget.js +1 -1
- package/dist/src/decoders.js +26 -0
- package/dist/src/execution.d.ts +4 -2
- package/dist/src/execution.js +43 -2
- package/dist/src/host-delivery.js +1 -0
- package/dist/src/host-recovery.d.ts +5 -2
- package/dist/src/host-recovery.js +3 -3
- package/dist/src/host-view.d.ts +5 -0
- package/dist/src/host-view.js +29 -5
- package/dist/src/host.d.ts +2 -2
- package/dist/src/host.js +190 -37
- package/dist/src/index.js +495 -93
- package/dist/src/index.js.map +3 -3
- package/dist/src/paths.d.ts +2 -0
- package/dist/src/paths.js +2 -0
- package/dist/src/registry.js +1 -1
- package/dist/src/roles.js +4 -3
- package/dist/src/script-tools.d.ts +27 -0
- package/dist/src/script-tools.js +87 -0
- package/dist/src/settings.d.ts +13 -0
- package/dist/src/settings.js +27 -3
- package/dist/src/trajectory.d.ts +12 -2
- package/dist/src/trajectory.js +30 -8
- package/dist/src/types.d.ts +30 -2
- package/dist/src/types.js +1 -1
- package/dist/src/utils.d.ts +19 -0
- package/dist/src/utils.js +30 -0
- package/dist/src/validation.d.ts +6 -1
- package/dist/src/validation.js +21 -1
- package/dist/starter/index.js +0 -2
- package/dist/starter/index.js.map +1 -1
- package/dist/starter/review-loop.d.ts +0 -13
- package/dist/starter/review-loop.js +0 -2
- package/dist/subagents/index.js +267 -159
- package/dist/subagents/index.js.map +2 -2
- package/dist/subagents/src/contracts.d.ts +45 -29
- package/dist/subagents/src/contracts.js +18 -7
- package/dist/subagents/src/index.d.ts +1 -1
- package/dist/subagents/src/index.js +13 -6
- package/dist/subagents/src/manager.js +3 -3
- package/dist/subagents/src/view.d.ts +1 -0
- package/dist/subagents/src/view.js +13 -52
- package/dist/trajectory/assets/index.html +27 -5
- package/dist/trajectory/index.js +76 -28
- package/dist/trajectory/index.js.map +2 -2
- package/dist/trajectory/src/assets/index.html +27 -5
- package/dist/trajectory/src/index.js +8 -18
- package/dist/trajectory/src/server.js +4 -2
- package/dist/trajectory/src/server.js.map +2 -2
- package/package.json +6 -6
- package/skills/pi-extensible-workflows/SKILL.md +2 -0
- package/src/agent-execution.ts +77 -41
- package/src/background-widget.ts +1 -1
- package/src/decoders.ts +20 -0
- package/src/execution.ts +41 -4
- package/src/host-delivery.ts +1 -0
- package/src/host-recovery.ts +8 -7
- package/src/host-view.ts +23 -5
- package/src/host.ts +173 -35
- package/src/paths.ts +3 -0
- package/src/registry.ts +1 -1
- package/src/roles.ts +4 -3
- package/src/script-tools.ts +76 -0
- package/src/settings.ts +22 -4
- package/src/trajectory.ts +30 -11
- package/src/types.ts +11 -4
- package/src/utils.ts +28 -0
- package/src/validation.ts +19 -1
- package/starter/review-loop.ts +0 -2
- package/subagents/README.md +2 -2
- package/subagents/src/contracts.ts +18 -7
- package/subagents/src/index.ts +16 -6
- package/subagents/src/manager.ts +3 -3
- package/subagents/src/view.ts +13 -50
- package/trajectory/src/assets/index.html +27 -5
- package/trajectory/src/index.ts +6 -9
- package/trajectory/src/server.ts +2 -2
package/dist/trajectory/index.js
CHANGED
|
@@ -47,6 +47,7 @@ var ERROR_CODES = [
|
|
|
47
47
|
"AGENT_FAILED",
|
|
48
48
|
"AGENT_RESULT_COLLECTED",
|
|
49
49
|
"RESULT_INVALID",
|
|
50
|
+
"TOOL_FAILED",
|
|
50
51
|
"CANCELLED",
|
|
51
52
|
"WORKER_UNRESPONSIVE",
|
|
52
53
|
"WORKTREE_FAILED",
|
|
@@ -684,6 +685,22 @@ function decodeRunEvent(value) {
|
|
|
684
685
|
if (timestamp === INVALID_PERSISTED_VALUE) return void 0;
|
|
685
686
|
return { type: value.type, message: value.message, ...timestamp === void 0 ? {} : { timestamp } };
|
|
686
687
|
}
|
|
688
|
+
function decodeScriptCall(value) {
|
|
689
|
+
if (!object(value) || value.kind !== "shell" && value.kind !== "tool" || typeof value.name !== "string" || typeof value.path !== "string" || !finiteNumber(value.startedAt)) return void 0;
|
|
690
|
+
const shell = value.kind === "shell";
|
|
691
|
+
if (shell && !jsonValue(value.input)) return void 0;
|
|
692
|
+
const inputBytes = shell ? optionalNumber(value.inputBytes) : void 0;
|
|
693
|
+
const phase = optionalString(value.phase);
|
|
694
|
+
const finishedAt = optionalNumber(value.finishedAt);
|
|
695
|
+
let error;
|
|
696
|
+
if (value.error !== void 0) {
|
|
697
|
+
if (shell) error = decodeWorkflowError(value.error);
|
|
698
|
+
else if (object(value.error) && typeof value.error.code === "string") error = { code: isWorkflowErrorCode(value.error.code) ? value.error.code : "INTERNAL_ERROR" };
|
|
699
|
+
if (!error) return void 0;
|
|
700
|
+
}
|
|
701
|
+
if (inputBytes === INVALID_PERSISTED_VALUE || phase === INVALID_PERSISTED_VALUE || finishedAt === INVALID_PERSISTED_VALUE) return void 0;
|
|
702
|
+
return { kind: value.kind, name: value.name, path: value.path, ...shell && jsonValue(value.input) ? { input: value.input } : {}, ...inputBytes === void 0 ? {} : { inputBytes }, ...phase === void 0 ? {} : { phase }, startedAt: value.startedAt, ...finishedAt === void 0 ? {} : { finishedAt }, ...error === void 0 ? {} : { error } };
|
|
703
|
+
}
|
|
687
704
|
function decodeDelivery(value) {
|
|
688
705
|
if (!object(value)) return void 0;
|
|
689
706
|
const mode = value.mode;
|
|
@@ -713,6 +730,8 @@ function decodePersistedRun(value, allowLegacyAgentSessions = false) {
|
|
|
713
730
|
const budgetEvents = value.budgetEvents === void 0 ? void 0 : decodeArray(value.budgetEvents, decodeBudgetEvent);
|
|
714
731
|
const events = value.events === void 0 ? void 0 : decodeArray(value.events, decodeRunEvent);
|
|
715
732
|
const delivery = value.delivery === void 0 ? void 0 : decodeDelivery(value.delivery);
|
|
733
|
+
const scriptCalls = value.scriptCalls === void 0 ? void 0 : decodeArray(value.scriptCalls, decodeScriptCall);
|
|
734
|
+
if (value.scriptCalls !== void 0 && !scriptCalls) return void 0;
|
|
716
735
|
if (!agentSessions || !agents || parentRunId === INVALID_PERSISTED_VALUE || value.retry !== void 0 && !retry || phase === INVALID_PERSISTED_VALUE || value.phaseHistory !== void 0 && !phaseHistory || phaseHistoryIndex === INVALID_PERSISTED_VALUE || activeShells === INVALID_PERSISTED_VALUE || activeShellStartedAt === INVALID_PERSISTED_VALUE || value.activeShellsByPhase !== void 0 && !activeShellsByPhase || value.error !== void 0 && !error || failedAt === INVALID_PERSISTED_VALUE || value.budget !== void 0 && !budget || budgetVersion === INVALID_PERSISTED_VALUE || value.budgetVersion !== void 0 && !integer(budgetVersion) || value.usage !== void 0 && !usage || value.budgetEvents !== void 0 && !budgetEvents || value.events !== void 0 && !events || value.delivery !== void 0 && !delivery) return void 0;
|
|
717
736
|
if (value.agentSessions === void 0 && !allowLegacyAgentSessions) return void 0;
|
|
718
737
|
return {
|
|
@@ -731,6 +750,7 @@ function decodePersistedRun(value, allowLegacyAgentSessions = false) {
|
|
|
731
750
|
...activeShells === void 0 ? {} : { activeShells },
|
|
732
751
|
...activeShellStartedAt === void 0 ? {} : { activeShellStartedAt },
|
|
733
752
|
...activeShellsByPhase === void 0 ? {} : { activeShellsByPhase },
|
|
753
|
+
...scriptCalls === void 0 ? {} : { scriptCalls },
|
|
734
754
|
...error === void 0 ? {} : { error },
|
|
735
755
|
...failedAt === void 0 ? {} : { failedAt },
|
|
736
756
|
...budget === void 0 ? {} : { budget },
|
|
@@ -1921,7 +1941,7 @@ function workflowSettingsPath(agentDir = getAgentDir()) {
|
|
|
1921
1941
|
return join4(agentDir, ROLE_DIRECTORY, "settings.json");
|
|
1922
1942
|
}
|
|
1923
1943
|
function normalizedResourcePath(value, settingsPath) {
|
|
1924
|
-
if (value === "*") return value;
|
|
1944
|
+
if (value === "*" || value.startsWith("builtin:")) return value;
|
|
1925
1945
|
let expanded = value === "~" ? homedir4() : value.startsWith("~/") || value.startsWith("~\\") ? join4(homedir4(), value.slice(2)) : value;
|
|
1926
1946
|
if (expanded.startsWith("file://")) expanded = fileURLToPath(expanded);
|
|
1927
1947
|
const resolved = resolve3(dirname2(settingsPath), expanded);
|
|
@@ -2028,7 +2048,7 @@ function parseSettings(path, partial) {
|
|
|
2028
2048
|
fail("CONFIG_ERROR", `Invalid workflow settings JSON at ${path}: ${errorText(error)}`);
|
|
2029
2049
|
}
|
|
2030
2050
|
if (!object(parsed)) fail("INVALID_SETTINGS", `Workflow settings at ${path} must be an object`);
|
|
2031
|
-
const allowed = /* @__PURE__ */ new Set(["concurrency", "modelAliases", "skills", "extensions", "extensionSettings", "tools", "retention", "worktreePostCreateCommand", ...partial ? [] : ["backgroundWidget"]]);
|
|
2051
|
+
const allowed = /* @__PURE__ */ new Set(["concurrency", "modelAliases", "skills", "extensions", "extensionSettings", "tools", "retention", "worktreePostCreateCommand", ...partial ? [] : ["backgroundWidget", "codemodeTools"]]);
|
|
2032
2052
|
const unknown = Object.keys(parsed).find((key) => !allowed.has(key));
|
|
2033
2053
|
if (Object.prototype.hasOwnProperty.call(parsed, "disabledAgentResources")) fail("INVALID_SETTINGS", `disabledAgentResources is no longer supported; use skills, extensions, and tools selectors (settings: ${path})`);
|
|
2034
2054
|
if (unknown) fail("INVALID_SETTINGS", `Unknown workflow setting at ${path}: ${unknown}`);
|
|
@@ -2036,6 +2056,8 @@ function parseSettings(path, partial) {
|
|
|
2036
2056
|
if (concurrency !== void 0 && (!positiveInteger(concurrency) || concurrency > 16)) fail("INVALID_SETTINGS", `${path}.concurrency must be an integer from 1 to 16`);
|
|
2037
2057
|
const backgroundWidget = parsed.backgroundWidget === void 0 ? partial ? void 0 : DEFAULT_SETTINGS.backgroundWidget : parsed.backgroundWidget;
|
|
2038
2058
|
if (backgroundWidget !== void 0 && typeof backgroundWidget !== "boolean") fail("INVALID_SETTINGS", `${path}.backgroundWidget must be a boolean`);
|
|
2059
|
+
const codemodeTools = parsed.codemodeTools;
|
|
2060
|
+
if (codemodeTools !== void 0 && codemodeTools !== "all" && codemodeTools !== "read-only" && codemodeTools !== "none") fail("INVALID_SETTINGS", `${path}.codemodeTools must be "all", "read-only", or "none"`);
|
|
2039
2061
|
const modelAliases = parsed.modelAliases === void 0 ? void 0 : validateModelAliases(parsed.modelAliases, path);
|
|
2040
2062
|
const skills = validateSelectorList(parsed.skills, path, "skills");
|
|
2041
2063
|
const tools = validateSelectorList(parsed.tools, path, "tools");
|
|
@@ -2046,6 +2068,7 @@ function parseSettings(path, partial) {
|
|
|
2046
2068
|
return Object.freeze({
|
|
2047
2069
|
...concurrency === void 0 ? {} : { concurrency },
|
|
2048
2070
|
...backgroundWidget === void 0 ? {} : { backgroundWidget },
|
|
2071
|
+
...codemodeTools === void 0 ? {} : { codemodeTools },
|
|
2049
2072
|
...modelAliases === void 0 ? {} : { modelAliases },
|
|
2050
2073
|
...skills === void 0 ? {} : { skills },
|
|
2051
2074
|
...extensions === void 0 ? {} : { extensions },
|
|
@@ -2109,7 +2132,7 @@ function isCorePackageName(value) {
|
|
|
2109
2132
|
}
|
|
2110
2133
|
|
|
2111
2134
|
// src/registry.ts
|
|
2112
|
-
var RESERVED_GLOBALS = /* @__PURE__ */ new Set(["agent", "shell", "prompt", "checkpoint", "parallel", "pipeline", "phase", "withWorktree", "log", "args", "Promise", "JSON", "Math", "Date", "eval", "Function", "WebAssembly", "process", "require", "module", "exports", "console", "fetch", "XMLHttpRequest", "WebSocket", "performance", "crypto", "setTimeout", "setInterval", "setImmediate", "queueMicrotask", "Intl", "SharedArrayBuffer", "Atomics", "globalThis", "global", "undefined", "NaN", "Infinity", "extensions", "workflow_catalog"]);
|
|
2135
|
+
var RESERVED_GLOBALS = /* @__PURE__ */ new Set(["agent", "shell", "tools", "prompt", "checkpoint", "parallel", "pipeline", "phase", "withWorktree", "log", "args", "Promise", "JSON", "Math", "Date", "eval", "Function", "WebAssembly", "process", "require", "module", "exports", "console", "fetch", "XMLHttpRequest", "WebSocket", "performance", "crypto", "setTimeout", "setInterval", "setImmediate", "queueMicrotask", "Intl", "SharedArrayBuffer", "Atomics", "globalThis", "global", "undefined", "NaN", "Infinity", "extensions", "workflow_catalog"]);
|
|
2113
2136
|
var IDENTIFIER = /^[A-Za-z_$][\w$]*$/;
|
|
2114
2137
|
var SEMVER = /^\d+\.\d+\.\d+(?:-[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?(?:\+[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?$/;
|
|
2115
2138
|
var PACKAGE_NAME = /^(?:@[a-z0-9][a-z0-9._-]*\/)?[a-z0-9][a-z0-9._-]*$/;
|
|
@@ -2433,7 +2456,8 @@ var SUBAGENTS_RUN_PARAMETERS = Type.Object({
|
|
|
2433
2456
|
timeoutMs: Type.Optional(Type.Union([Type.Integer({ minimum: 1, description: "Optional execution timeout in milliseconds" }), Type.Null()]))
|
|
2434
2457
|
}, { additionalProperties: false });
|
|
2435
2458
|
var SUBAGENTS_INSPECT_PARAMETERS = Type.Object({
|
|
2436
|
-
id: Type.Optional(Type.String({ description: "Subagent ID; omit to list ordered run summaries" }))
|
|
2459
|
+
id: Type.Optional(Type.String({ description: "Subagent ID; omit to list ordered run summaries" })),
|
|
2460
|
+
scope: Type.Optional(Type.Union([Type.Literal("session"), Type.Literal("all")], { description: "List scope when id is omitted: session (default) lists runs from the current Pi session; all lists every stored run" }))
|
|
2437
2461
|
}, { additionalProperties: false });
|
|
2438
2462
|
var SUBAGENTS_ID_PARAMETERS = Type.Object({
|
|
2439
2463
|
id: Type.String({ description: "Subagent ID" })
|
|
@@ -2448,6 +2472,24 @@ var SUBAGENTS_STOP_PARAMETERS = Type.Object({
|
|
|
2448
2472
|
var SUBAGENTS_RETRY_PARAMETERS = Type.Object({
|
|
2449
2473
|
id: Type.String({ description: "Failed or stopped subagent ID to retry" })
|
|
2450
2474
|
}, { additionalProperties: false });
|
|
2475
|
+
var SUBAGENT_STATUS_OUTPUT = Type.Object({
|
|
2476
|
+
id: Type.String(),
|
|
2477
|
+
state: Type.String(),
|
|
2478
|
+
sessionId: Type.Optional(Type.String()),
|
|
2479
|
+
startedAt: Type.Optional(Type.Number()),
|
|
2480
|
+
finishedAt: Type.Optional(Type.Number()),
|
|
2481
|
+
attempts: Type.Optional(Type.Number()),
|
|
2482
|
+
attemptDetails: Type.Optional(Type.Array(Type.Unknown())),
|
|
2483
|
+
worktree: Type.Optional(Type.Object({ path: Type.String(), branch: Type.String() })),
|
|
2484
|
+
error: Type.Optional(Type.Object({ code: Type.String(), message: Type.String() })),
|
|
2485
|
+
progress: Type.Optional(Type.Unknown()),
|
|
2486
|
+
value: Type.Optional(Type.Unknown())
|
|
2487
|
+
});
|
|
2488
|
+
var SUBAGENTS_INSPECT_OUTPUT = Type.Union([SUBAGENT_STATUS_OUTPUT, Type.Array(Type.Object({ id: Type.String(), state: Type.String() }))]);
|
|
2489
|
+
var SUBAGENTS_STEER_OUTPUT = Type.Object({ id: Type.String(), accepted: Type.Boolean() });
|
|
2490
|
+
|
|
2491
|
+
// src/tool-timing.ts
|
|
2492
|
+
var TOOL_TIMING_ENTRY_TYPE = "pi-workflows:tool-timing";
|
|
2451
2493
|
|
|
2452
2494
|
// src/trajectory-contracts.ts
|
|
2453
2495
|
var TRAJECTORY_ACTIONS = ["checkpoint-approve", "checkpoint-reject", "pause", "resume", "steer", "stop", "retry", "share"];
|
|
@@ -2480,7 +2522,7 @@ function transcriptToolCallId(value) {
|
|
|
2480
2522
|
return void 0;
|
|
2481
2523
|
}
|
|
2482
2524
|
function isTimingTranscriptEntry(value) {
|
|
2483
|
-
return object(value) && value.type === "custom" && value.customType ===
|
|
2525
|
+
return object(value) && value.type === "custom" && value.customType === TOOL_TIMING_ENTRY_TYPE;
|
|
2484
2526
|
}
|
|
2485
2527
|
function timingToolCallId(value) {
|
|
2486
2528
|
if (!object(value) || !isTimingTranscriptEntry(value) || !object(value.data)) return void 0;
|
|
@@ -2601,7 +2643,7 @@ function withPiToolDescriptions(run) {
|
|
|
2601
2643
|
function canonicalExtensionSelector(selector, base) {
|
|
2602
2644
|
const negated = selector.startsWith("!");
|
|
2603
2645
|
const body = negated ? selector.slice(1) : selector;
|
|
2604
|
-
if (body === "*" || body === "**" || body.startsWith("**/")) return selector;
|
|
2646
|
+
if (body === "*" || body === "**" || body.startsWith("**/") || body.startsWith("builtin:")) return selector;
|
|
2605
2647
|
const resolved = resolve4(base, body);
|
|
2606
2648
|
if (resourcePatternHasMagic(body)) return `${negated ? "!" : ""}${resolved}`;
|
|
2607
2649
|
return `${negated ? "!" : ""}${canonicalPath(resolved)}`;
|
|
@@ -2671,11 +2713,17 @@ function failedAgentOutput(agent) {
|
|
|
2671
2713
|
const status = agent.state === "cancelled" ? "cancelled" : "failed";
|
|
2672
2714
|
return { status, code: error?.code ?? (status === "cancelled" ? "CANCELLED" : "AGENT_FAILED"), message: error?.message ?? `Agent ${agent.state}` };
|
|
2673
2715
|
}
|
|
2716
|
+
function operationOutput(operation) {
|
|
2717
|
+
const bytes = serializedJsonBytes(operation.value);
|
|
2718
|
+
return bytes > DEFAULT_MAX_BYTES ? { status: "truncated", kind: "result", bytes } : { status: "available", value: operation.value, bytes };
|
|
2719
|
+
}
|
|
2720
|
+
function outputForCall(call, operation) {
|
|
2721
|
+
if (operation !== void 0) return call.kind === "tool" ? { status: "completed" } : operationOutput(operation);
|
|
2722
|
+
if (call.error) return { status: call.error.code === "CANCELLED" ? "cancelled" : "failed", code: call.error.code, ...call.kind === "shell" ? { message: call.error.message ?? "Shell failed" } : {} };
|
|
2723
|
+
return call.finishedAt === void 0 ? { status: "pending" } : { status: "unavailable" };
|
|
2724
|
+
}
|
|
2674
2725
|
function outputForAgent(agent, operation) {
|
|
2675
|
-
if (operation !== void 0)
|
|
2676
|
-
const bytes = serializedJsonBytes(operation.value);
|
|
2677
|
-
return bytes > DEFAULT_MAX_BYTES ? { status: "truncated", kind: "result", bytes } : { status: "available", value: operation.value, bytes };
|
|
2678
|
-
}
|
|
2726
|
+
if (operation !== void 0) return operationOutput(operation);
|
|
2679
2727
|
if (agent.state === "failed" || agent.state === "cancelled") return failedAgentOutput(agent);
|
|
2680
2728
|
if (agent.state === "completed") return { status: "unavailable" };
|
|
2681
2729
|
return { status: "pending" };
|
|
@@ -2683,7 +2731,17 @@ function outputForAgent(agent, operation) {
|
|
|
2683
2731
|
function applyTrajectoryAgentOutputs(run, operations) {
|
|
2684
2732
|
const byPath = new Map(operations.map((operation) => [operation.path, operation]));
|
|
2685
2733
|
const agents = run.agents.map((agent) => ({ ...agent, output: outputForAgent(agent, agent.resultPath === void 0 ? void 0 : byPath.get(agent.resultPath)) }));
|
|
2686
|
-
|
|
2734
|
+
const scriptCalls = run.scriptCalls?.map((call) => {
|
|
2735
|
+
const recorded = { ...call, output: outputForCall(call, byPath.get(call.path)) };
|
|
2736
|
+
if (call.kind === "tool") {
|
|
2737
|
+
delete recorded.input;
|
|
2738
|
+
delete recorded.inputBytes;
|
|
2739
|
+
if (call.error) recorded.error = { code: call.error.code };
|
|
2740
|
+
}
|
|
2741
|
+
return recorded;
|
|
2742
|
+
});
|
|
2743
|
+
const rest = run;
|
|
2744
|
+
return { ...rest, agents, ...scriptCalls === void 0 ? {} : { scriptCalls } };
|
|
2687
2745
|
}
|
|
2688
2746
|
function overlayTrajectoryRun(run, overlay) {
|
|
2689
2747
|
const overlaid = overlay(run);
|
|
@@ -2693,7 +2751,7 @@ function overlayTrajectoryRun(run, overlay) {
|
|
|
2693
2751
|
const output = previous?.status === "available" || previous?.status === "truncated" ? previous : outputForAgent(agent, void 0);
|
|
2694
2752
|
return { ...agent, output };
|
|
2695
2753
|
});
|
|
2696
|
-
return { ...overlaid, agents };
|
|
2754
|
+
return { ...overlaid, agents, ...run.scriptCalls === void 0 ? {} : { scriptCalls: run.scriptCalls } };
|
|
2697
2755
|
}
|
|
2698
2756
|
async function loadTrajectoryRun(store, includeTranscripts = true) {
|
|
2699
2757
|
const value = await store.load();
|
|
@@ -2962,9 +3020,6 @@ var ACTIVE_POLL_MS = 1e3;
|
|
|
2962
3020
|
var IDLE_POLL_MS = 1e4;
|
|
2963
3021
|
var RECONNECT_INITIAL_DELAY_MS = 100;
|
|
2964
3022
|
var RECONNECT_MAX_DELAY_MS = 5e3;
|
|
2965
|
-
function isTimingEntry(value) {
|
|
2966
|
-
return object(value) && value.type === "custom" && value.customType === "pi-workflows:tool-timing";
|
|
2967
|
-
}
|
|
2968
3023
|
function boundedString(value, maxLength = 1024) {
|
|
2969
3024
|
if (typeof value !== "string") return value;
|
|
2970
3025
|
const bytes = Buffer.from(value);
|
|
@@ -2974,7 +3029,7 @@ var MAX_LIVE_STRING_BYTES = 64 * 1024;
|
|
|
2974
3029
|
var MAX_LIVE_ARRAY_ENTRIES = 256;
|
|
2975
3030
|
var MAX_LIVE_OBJECT_KEYS = 64;
|
|
2976
3031
|
var LIVE_METADATA_ARRAY_KEYS = /* @__PURE__ */ new Set(["agents", "runs", "subagents"]);
|
|
2977
|
-
var LIVE_TRUNCATABLE_ARRAY_KEYS = /* @__PURE__ */ new Set(["events", "phaseHistory"]);
|
|
3032
|
+
var LIVE_TRUNCATABLE_ARRAY_KEYS = /* @__PURE__ */ new Set(["events", "phaseHistory", "scriptCalls"]);
|
|
2978
3033
|
var LIVE_METADATA_OBJECT_KEYS = /* @__PURE__ */ new Set(["transcripts"]);
|
|
2979
3034
|
function liveValueWillBeBounded(value, key = "", depth = 0) {
|
|
2980
3035
|
if (typeof value === "string") return Buffer.byteLength(value) > MAX_LIVE_STRING_BYTES;
|
|
@@ -2992,7 +3047,7 @@ function liveValueWillBeBounded(value, key = "", depth = 0) {
|
|
|
2992
3047
|
}
|
|
2993
3048
|
var MAX_LIVE_TIMING_BYTES = 64 * 1024;
|
|
2994
3049
|
function boundedTiming(value) {
|
|
2995
|
-
const entries = Array.isArray(value) ? value.filter(
|
|
3050
|
+
const entries = Array.isArray(value) ? value.filter(isTimingTranscriptEntry) : [];
|
|
2996
3051
|
const retained = [];
|
|
2997
3052
|
let bytes = 2;
|
|
2998
3053
|
for (let index = entries.length - 1; index >= 0; index -= 1) {
|
|
@@ -3241,22 +3296,15 @@ function createTrajectoryController(agentDir) {
|
|
|
3241
3296
|
}
|
|
3242
3297
|
};
|
|
3243
3298
|
const transcriptFromFallback = async (input, request) => {
|
|
3244
|
-
const
|
|
3245
|
-
try {
|
|
3246
|
-
if (result.status === "available" && Buffer.byteLength(JSON.stringify(result.entries)) > TRAJECTORY_MAX_TRANSCRIPT_BYTES) return { status: "oversized", revision: result.revision, entries: [], error: "Transcript is too large" };
|
|
3247
|
-
} catch {
|
|
3248
|
-
return { status: "failed", revision: result.revision, entries: [], error: "Transcript failed" };
|
|
3249
|
-
}
|
|
3250
|
-
return result;
|
|
3251
|
-
};
|
|
3252
|
-
const boundedResult = (entries, revision) => {
|
|
3299
|
+
const oversized = (entries, revision) => {
|
|
3253
3300
|
try {
|
|
3254
|
-
|
|
3301
|
+
return Buffer.byteLength(JSON.stringify(entries)) > TRAJECTORY_MAX_TRANSCRIPT_BYTES ? { status: "oversized", revision, entries: [], error: "Transcript is too large" } : void 0;
|
|
3255
3302
|
} catch {
|
|
3256
3303
|
return { status: "failed", revision, entries: [], error: "Transcript failed" };
|
|
3257
3304
|
}
|
|
3258
|
-
return { status: entries.length ? "available" : "empty", revision, entries };
|
|
3259
3305
|
};
|
|
3306
|
+
const boundedTranscriptResult = (result) => (result.status === "available" ? oversized(result.entries, result.revision) : void 0) ?? result;
|
|
3307
|
+
const boundedResult = (entries, revision) => oversized(entries, revision) ?? { status: entries.length ? "available" : "empty", revision, entries };
|
|
3260
3308
|
if (input.loadTranscript) {
|
|
3261
3309
|
const result = await input.loadTranscript(request);
|
|
3262
3310
|
const revisionChanged = request.revision !== void 0 && result.revision !== request.revision && result.status !== "missing" && result.status !== "failed" && result.status !== "oversized" && result.status !== "disconnected";
|