pi-fabric 0.92.33 → 0.92.34
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/dist/actors/types.d.ts +1 -1
- package/dist/actors/types.d.ts.map +1 -1
- package/dist/agents/handoff.d.ts.map +1 -1
- package/dist/agents.js +2 -2
- package/dist/chunks/{chunk-CEXO6ELQ.js → chunk-HYK47EXZ.js} +2 -2
- package/dist/chunks/{chunk-COEKLWQ4.js → chunk-K3PMKWYO.js} +2 -2
- package/dist/chunks/{chunk-R7G4HXVD.js → chunk-OPEOIVF6.js} +1 -1
- package/dist/chunks/{chunk-R7G4HXVD.js.map → chunk-OPEOIVF6.js.map} +2 -2
- package/dist/chunks/{chunk-OTCASLY2.js → chunk-R2V7X3QI.js} +1 -1
- package/dist/chunks/chunk-R2V7X3QI.js.map +7 -0
- package/dist/chunks/{chunk-WJ6OWOVJ.js → chunk-U5PRQ6NL.js} +3 -3
- package/dist/chunks/{chunk-327VLBDU.js → chunk-Z7ZAT43C.js} +2 -2
- package/dist/fabric-runtime-state.js +5 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -5
- package/dist/index.js.map +2 -2
- package/dist/residency/host.js +4 -4
- package/dist/residency/pi-entry.js +4 -4
- package/dist/ui/conversation-native-reader.d.ts.map +1 -1
- package/dist/ui/conversation-native-reader.js.map +2 -2
- package/dist/ui/dashboard.js +1 -1
- package/package.json +4 -4
- package/dist/chunks/chunk-OTCASLY2.js.map +0 -7
- /package/dist/chunks/{chunk-CEXO6ELQ.js.map → chunk-HYK47EXZ.js.map} +0 -0
- /package/dist/chunks/{chunk-COEKLWQ4.js.map → chunk-K3PMKWYO.js.map} +0 -0
- /package/dist/chunks/{chunk-WJ6OWOVJ.js.map → chunk-U5PRQ6NL.js.map} +0 -0
- /package/dist/chunks/{chunk-327VLBDU.js.map → chunk-Z7ZAT43C.js.map} +0 -0
package/dist/actors/types.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ import type { FabricLogLine, AgentRunRecord, AgentUsage } from "../agents/types.
|
|
|
5
5
|
import type { FabricCapabilityRequirement } from "../components/types.js";
|
|
6
6
|
import type { FabricKernel } from "../runtime/kernel.js";
|
|
7
7
|
import type { FabricParticipantResidency } from "../topology/types.js";
|
|
8
|
-
export type FabricActorPiHostEvent = Exclude<ExtensionEvent["type"], "project_trust">;
|
|
8
|
+
export type FabricActorPiHostEvent = Exclude<ExtensionEvent["type"], "project_trust" | "cache_warming_decision">;
|
|
9
9
|
export declare const FABRIC_ACTOR_PI_HOST_EVENTS: readonly ["resources_discover", "session_start", "session_info_changed", "session_before_switch", "session_before_fork", "session_before_compact", "session_compact", "session_compact_failed", "session_shutdown", "session_before_tree", "session_tree", "input", "before_agent_start", "agent_start", "agent_end", "agent_settled", "turn_start", "turn_end", "message_start", "message_update", "message_end", "ui_prompt_start", "ui_prompt_end", "context", "before_provider_headers", "before_provider_request", "after_provider_response", "tool_execution_start", "tool_call", "tool_execution_update", "tool_result", "tool_execution_end", "model_select", "thinking_level_select", "user_bash"];
|
|
10
10
|
export declare const FABRIC_ACTOR_HOST_EVENTS: readonly ["resources_discover", "session_start", "session_info_changed", "session_before_switch", "session_before_fork", "session_before_compact", "session_compact", "session_compact_failed", "session_shutdown", "session_before_tree", "session_tree", "input", "before_agent_start", "agent_start", "agent_end", "agent_settled", "turn_start", "turn_end", "message_start", "message_update", "message_end", "ui_prompt_start", "ui_prompt_end", "context", "before_provider_headers", "before_provider_request", "after_provider_response", "tool_execution_start", "tool_call", "tool_execution_update", "tool_result", "tool_execution_end", "model_select", "thinking_level_select", "user_bash", "tool_error"];
|
|
11
11
|
export type FabricActorHostEvent = (typeof FABRIC_ACTOR_HOST_EVENTS)[number];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/actors/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;A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C,EAAE,QAAQ,GAAG,SAAS,GAAG,MAAM,CAAC;IACvC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,UAAU,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,oBAAoB;IACnC,MAAM,EAAE,QAAQ,GAAG,SAAS,GAAG,MAAM,CAAC;IACtC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB;AAED,MAAM,WAAW,0BAA0B;IACzC,KAAK,EAAE,eAAe,CAAC;IACvB,OAAO,EAAE,kBAAkB,CAAC;IAC5B,QAAQ,EAAE,OAAO,CAAC,mBAAmB,EAAE,SAAS,CAAC,CAAC;IAClD,WAAW,EAAE,OAAO,CAAC;CACtB;AAED;;;;;;;GAOG;AACH,MAAM,WAAW,qBAAsB,SAAQ,kBAAkB;IAC/D,EAAE,EAAE,MAAM,CAAC;IACX,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAKlB,MAAM,EAAE,oBAAoB,EAAE,CAAC;IAC/B,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,QAAQ,EAAE,mBAAmB,CAAC;IAC9B,YAAY,EAAE,uBAAuB,CAAC;IACtC,WAAW,EAAE,OAAO,CAAC;IACrB,QAAQ,EAAE,OAAO,CAAC;IAClB,SAAS,CAAC,EAAE,0BAA0B,CAAC;IACvC,MAAM,EAAE,iBAAiB,CAAC;CAC3B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"handoff.d.ts","sourceRoot":"","sources":["../../src/agents/handoff.ts"],"names":[],"mappings":"AAGA,OAAO,EAGL,KAAK,YAAY,EAElB,MAAM,iCAAiC,CAAC;
|
|
1
|
+
{"version":3,"file":"handoff.d.ts","sourceRoot":"","sources":["../../src/agents/handoff.ts"],"names":[],"mappings":"AAGA,OAAO,EAGL,KAAK,YAAY,EAElB,MAAM,iCAAiC,CAAC;AAOzC,OAAO,KAAK,EACV,gBAAgB,EAChB,sBAAsB,EACtB,wBAAwB,EACzB,MAAM,YAAY,CAAC;AACpB,OAAO,EAKL,KAAK,qBAAqB,EAE3B,MAAM,wBAAwB,CAAC;AAEhC,UAAU,oBAAoB;IAC5B,SAAS,IAAI,YAAY,EAAE,CAAC;IAC5B,QAAQ,CAAC,EAAE,EAAE,MAAM,GAAG,YAAY,GAAG,SAAS,CAAC;IAC/C,SAAS,IAAI,MAAM,GAAG,IAAI,CAAC;IAC3B,cAAc,IAAI,MAAM,GAAG,SAAS,CAAC;IACrC,YAAY,IAAI,MAAM,CAAC;CACxB;AAED,UAAU,YAAY;IACpB,QAAQ,EAAE,MAAM,CAAC;IACjB,EAAE,EAAE,MAAM,CAAC;CACZ;AAwBD,eAAO,MAAM,wBAAwB,GACnC,OAAO,OAAO,KACb,wBAAwB,GAAG,SA4B7B,CAAC;AAwCF,eAAO,MAAM,sBAAsB,GACjC,QAAQ,oBAAoB,EAC5B,cAAc,YAAY,GAAG,SAAS,EACtC,iBAAiB,sBAAsB,EACvC,iBAAiB,MAAM,KACtB,gBAiCF,CAAC;AAqFF,eAAO,MAAM,mBAAmB,GAC9B,MAAM,gBAAgB,EACtB,KAAK,MAAM,EACX,WAAW,MAAM,EACjB,WAAW,qBAAqB,EAChC,aAAa,wBAAwB,KACpC,MA4FF,CAAC"}
|
package/dist/agents.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
AGENTS_ACTION_DESCRIPTORS,
|
|
3
3
|
normalizeAgentRunRequest
|
|
4
|
-
} from "./chunks/chunk-
|
|
4
|
+
} from "./chunks/chunk-Z7ZAT43C.js";
|
|
5
5
|
import {
|
|
6
6
|
validateAgentResult
|
|
7
7
|
} from "./chunks/chunk-3QECYQGA.js";
|
|
@@ -17,7 +17,7 @@ import {
|
|
|
17
17
|
terminalAgentStatuses,
|
|
18
18
|
waitForAgent
|
|
19
19
|
} from "./chunks/chunk-AYBIR4YV.js";
|
|
20
|
-
import "./chunks/chunk-
|
|
20
|
+
import "./chunks/chunk-R2V7X3QI.js";
|
|
21
21
|
import "./chunks/chunk-A4VP7HDF.js";
|
|
22
22
|
import "./chunks/chunk-MGWQOKBV.js";
|
|
23
23
|
import "./chunks/chunk-3H7SDWZI.js";
|
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
buildThinkingDigest,
|
|
11
11
|
snapshotHandoffSession,
|
|
12
12
|
thinkingTransferPolicy
|
|
13
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-OPEOIVF6.js";
|
|
14
14
|
import {
|
|
15
15
|
isFabricThinking
|
|
16
16
|
} from "./chunk-MGWQOKBV.js";
|
|
@@ -2012,4 +2012,4 @@ export {
|
|
|
2012
2012
|
PrewalkController,
|
|
2013
2013
|
PrewalkDriftTracker
|
|
2014
2014
|
};
|
|
2015
|
-
//# sourceMappingURL=chunk-
|
|
2015
|
+
//# sourceMappingURL=chunk-HYK47EXZ.js.map
|
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
agentParticipantRecords,
|
|
10
10
|
loadModelUsage,
|
|
11
11
|
useBudgetLedger
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-U5PRQ6NL.js";
|
|
13
13
|
import {
|
|
14
14
|
RESIDENT_HOST_FORMAT,
|
|
15
15
|
residentDeliveryPrefix,
|
|
@@ -689,4 +689,4 @@ if (isMain) {
|
|
|
689
689
|
export {
|
|
690
690
|
runResidentHostFromConfigPath
|
|
691
691
|
};
|
|
692
|
-
//# sourceMappingURL=chunk-
|
|
692
|
+
//# sourceMappingURL=chunk-K3PMKWYO.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/agents/thinking-transfer.ts", "../../src/agents/handoff.ts", "../../src/topology/peer-settle.ts"],
|
|
4
|
-
"sourcesContent": ["import type {\n SessionEntry,\n SessionMessageEntry,\n} from \"@earendil-works/pi-coding-agent\";\n\n// Cross-model thinking transfer for trajectory handoffs.\n//\n// Pi replays stored thinking blocks verbatim per provider: a Codex Responses\n// reasoning item rides as a provider-shaped `thinkingSignature` blob, and the\n// OpenAI-completions transform (pi-ai) uses that blob as the *request field\n// name* when the history is handed to a different provider \u2014 landing prior\n// deliberation in a junk field while the real `reasoning_content` stays\n// empty. Signature-sensitive families (Anthropic) reject foreign signatures\n// outright. This module applies a family-aware policy to the fabric-owned\n// child session at the handoff boundary, where rewriting is safe because the\n// source session (ground truth) is never touched:\n//\n// preserved \u2014 same provider and api family: native replay already works.\n// re-signed \u2014 openai-completions reasoning targets: thinking text is kept\n// and the signature normalized to \"reasoning_content\" so preserve-thinking\n// servers (Kimi, DeepSeek, \u2026) actually receive prior reasoning.\n// stripped \u2014 everything else: thinking blocks and foreign thought\n// signatures are removed so no bogus field or invalid signature is sent;\n// a bounded, entry-id-cited digest keeps continuity instead.\n\ninterface ThinkingTransferSource {\n provider: string;\n modelId: string;\n /** pi-ai transport api of the source model, when the registry resolves it. */\n api?: string | undefined;\n}\n\ninterface ThinkingTransferTarget {\n provider: string;\n modelId: string;\n api?: string | undefined;\n reasoning?: boolean | undefined;\n /** Model replays thinking as visible text; deliberation must not leak there. */\n requiresThinkingAsText?: boolean | undefined;\n}\n\nexport interface ThinkingTransferInput {\n source?: ThinkingTransferSource;\n target: ThinkingTransferTarget;\n}\n\nexport type ThinkingTransferPolicy = \"preserved\" | \"re-signed\" | \"stripped\";\n\nexport interface ThinkingTransferReport {\n policy: ThinkingTransferPolicy;\n translated: number;\n dropped: number;\n}\n\n// Field name pi-ai emits when a thinking block's signature is exactly this\n// string (the opencode-go \"reasoning\" \u2192 \"reasoning_content\" remap proves the\n// convention): the request then carries real prior reasoning content.\nexport const REASONING_CONTENT_SIGNATURE = \"reasoning_content\";\n\nconst OPENAI_COMPLETIONS_API = \"openai-completions\";\n\nexport const thinkingTransferPolicy = (\n input: ThinkingTransferInput,\n): ThinkingTransferPolicy => {\n const { source, target } = input;\n // Same provider with equal or unknown apis: native replay is provider-shipped\n // and the default experience; only an api-proof mismatch transfers.\n if (\n source &&\n source.provider === target.provider &&\n (source.api === undefined || target.api === undefined || source.api === target.api)\n ) {\n return \"preserved\";\n }\n if (\n target.api === OPENAI_COMPLETIONS_API &&\n target.reasoning === true &&\n target.requiresThinkingAsText !== true\n ) {\n return \"re-signed\";\n }\n return \"stripped\";\n};\n\nconst isRecord = (value: unknown): value is Record<string, unknown> =>\n typeof value === \"object\" && value !== null && !Array.isArray(value);\n\nconst isThinkingPart = (part: unknown): part is Record<string, unknown> =>\n isRecord(part) && part.type === \"thinking\";\n\n// Clone-and-rewrite walk over assistant content parts. Also clears foreign\n// `thoughtSignature` artifacts (Google-style reasoning_details), which are as\n// provider-bound as thinking signatures. Callers own the input; the original\n// entries are never mutated.\nexport const translateThinkingForExecutor = (\n entries: SessionEntry[],\n policy: ThinkingTransferPolicy,\n): { entries: SessionEntry[]; report: ThinkingTransferReport } => {\n if (policy === \"preserved\") {\n return { entries, report: { policy, translated: 0, dropped: 0 } };\n }\n const clone = structuredClone(entries);\n let translated = 0;\n let dropped = 0;\n for (const entry of clone) {\n if (entry.type !== \"message\") continue;\n const message = (entry as SessionMessageEntry).message as {\n role?: unknown;\n content?: unknown;\n };\n if (message.role !== \"assistant\" || !Array.isArray(message.content)) continue;\n const kept: unknown[] = [];\n for (const part of message.content as unknown[]) {\n if (isRecord(part) && part.type === \"toolCall\") {\n delete part.thoughtSignature;\n kept.push(part);\n continue;\n }\n if (!isThinkingPart(part)) {\n kept.push(part);\n continue;\n }\n const text = typeof part.thinking === \"string\" ? part.thinking : \"\";\n if (policy === \"re-signed\" && part.redacted !== true && text.trim().length > 0) {\n part.thinkingSignature = REASONING_CONTENT_SIGNATURE;\n translated += 1;\n kept.push(part);\n continue;\n }\n dropped += 1;\n }\n message.content = kept;\n }\n return { entries: clone, report: { policy, translated, dropped } };\n};\n\nexport const THINKING_DIGEST_CUSTOM_TYPE = \"pi-fabric-handoff-thinking\";\n\nconst MAX_DIGEST_BLOCKS = 8;\nconst MAX_DIGEST_LINE = 80;\nconst MAX_DIGEST_BYTES = 2048;\n\nexport interface ThinkingDigest {\n content: string;\n citedBlocks: number;\n}\n\nconst firstLineOf = (text: string): string => {\n const end = text.indexOf(\"\\n\");\n return end === -1 ? text : text.slice(0, end);\n};\n\nconst truncate = (text: string, max: number): string =>\n text.length > max ? text.slice(0, max) : text;\n\nconst clipUtf8 = (text: string, maxBytes: number): string => {\n if (Buffer.byteLength(text, \"utf8\") <= maxBytes) return text;\n let out = \"\";\n let bytes = 0;\n for (const char of text) {\n const size = Buffer.byteLength(char, \"utf8\");\n if (bytes + size > maxBytes) break;\n out += char;\n bytes += size;\n }\n return out;\n};\n\n// Bounded continuity bridge for executors whose reasoning channel cannot\n// accept prior thinking: the newest few first-lines, cited by stable entry id,\n// explicitly labeled as deliberation so they read as context, not style. The\n// full scratchpad remains addressable in the source session.\nexport const buildThinkingDigest = (\n entries: SessionEntry[],\n input: ThinkingTransferInput,\n): ThinkingDigest | undefined => {\n const blocks: Array<{ entryId: string; line: string }> = [];\n for (const entry of entries) {\n if (entry.type !== \"message\") continue;\n const message = (entry as SessionMessageEntry).message as {\n role?: unknown;\n content?: unknown;\n };\n if (message.role !== \"assistant\" || !Array.isArray(message.content)) continue;\n for (const part of message.content as unknown[]) {\n if (!isThinkingPart(part)) continue;\n const text = typeof part.thinking === \"string\" ? part.thinking : \"\";\n const line = truncate(firstLineOf(text).trim(), MAX_DIGEST_LINE);\n if (line) blocks.push({ entryId: entry.id, line });\n }\n }\n if (blocks.length === 0) return undefined;\n const recent = blocks.slice(-MAX_DIGEST_BLOCKS);\n const omitted = blocks.length - recent.length;\n const sourceId = input.source\n ? `${input.source.provider}/${input.source.modelId}`\n : \"the prior model\";\n const targetId = `${input.target.provider}/${input.target.modelId}`;\n const lines = [\n \"Prewalk handoff continuity digest (deliberation, not commitments).\",\n `Thinking from ${sourceId} was not transferred: ${targetId} cannot replay it (incompatible reasoning channels). Most recent lines:`,\n ...recent.map((block) => `- [entry ${block.entryId}] ${block.line}`),\n ];\n if (omitted > 0) lines.push(`(omitted ${omitted} older thinking blocks)`);\n lines.push(\"Full thinking remains addressable in the source session by entry id.\");\n return {\n content: clipUtf8(lines.join(\"\\n\"), MAX_DIGEST_BYTES),\n citedBlocks: recent.length,\n };\n};\n", "import { randomUUID } from \"node:crypto\";\nimport fs from \"node:fs\";\nimport path from \"node:path\";\nimport {\n CURRENT_SESSION_VERSION,\n SessionManager,\n type SessionEntry,\n type SessionMessageEntry,\n} from \"@earendil-works/pi-coding-agent\";\nimport { compileFabricSummary, rawContextTokens } from \"../compaction/hook.js\";\nimport {\n compactionRequestBoundsError,\n encodeCompactionRequest,\n} from \"../compaction/instructions.js\";\nimport type {\n AgentSessionSeed,\n AgentToolResultMessage,\n HandoffCompactionRequest,\n} from \"./types.js\";\nimport {\n buildThinkingDigest,\n THINKING_DIGEST_CUSTOM_TYPE,\n thinkingTransferPolicy,\n translateThinkingForExecutor,\n type ThinkingTransferInput,\n type ThinkingTransferReport,\n} from \"./thinking-transfer.js\";\n\ninterface HandoffSessionSource {\n getBranch(): SessionEntry[];\n getEntry(id: string): SessionEntry | undefined;\n getLeafId(): string | null;\n getSessionFile(): string | undefined;\n getSessionId(): string;\n}\n\ninterface CurrentModel {\n provider: string;\n id: string;\n}\n\ntype NativeAssistantMessage = Extract<\n SessionMessageEntry[\"message\"],\n { role: \"assistant\" }\n>;\ntype NativeAssistantEntry = SessionMessageEntry & {\n message: NativeAssistantMessage;\n};\n\nconst isRecord = (value: unknown): value is Record<string, unknown> =>\n typeof value === \"object\" && value !== null && !Array.isArray(value);\n\ninterface HandoffCompactionOutcome {\n applied: boolean;\n reason?: string;\n sections?: string[];\n tokensBefore?: number;\n firstKeptEntryId?: string;\n}\n\n// Validate the model-facing agents.handoff `compact` option against the same\n// bounds as compact.request. Called both when the request is scheduled (inside\n// the guest) and when the boundary runner replays it.\nexport const checkedHandoffCompaction = (\n value: unknown,\n): HandoffCompactionRequest | undefined => {\n if (value === undefined || value === false) return undefined;\n const input = value === true ? {} : value;\n if (!isRecord(input)) {\n throw new Error(\n \"Invalid agents.handoff compact arguments: compact must be true or an object with instructions/preserve\",\n );\n }\n if (input.instructions !== undefined && typeof input.instructions !== \"string\") {\n throw new Error(\"Invalid agents.handoff compact arguments: instructions must be a string\");\n }\n if (\n input.preserve !== undefined &&\n (!Array.isArray(input.preserve) || input.preserve.some((item) => typeof item !== \"string\"))\n ) {\n throw new Error(\n \"Invalid agents.handoff compact arguments: preserve must be an array of strings\",\n );\n }\n const request: HandoffCompactionRequest = {\n ...(typeof input.instructions === \"string\" ? { instructions: input.instructions } : {}),\n ...(input.preserve !== undefined ? { preserve: input.preserve as string[] } : {}),\n };\n const boundsError = compactionRequestBoundsError(request);\n if (boundsError) {\n throw new Error(`Invalid agents.handoff compact arguments: ${boundsError.message}`);\n }\n return request;\n};\n\nconst isToolCall = (value: unknown): value is {\n type: \"toolCall\";\n id: string;\n name: string;\n arguments: Record<string, unknown>;\n} =>\n isRecord(value) &&\n value.type === \"toolCall\" &&\n typeof value.id === \"string\" &&\n typeof value.name === \"string\" &&\n isRecord(value.arguments);\n\nconst activeFabricTurn = (\n source: HandoffSessionSource,\n outerToolCallId: string,\n): NativeAssistantEntry => {\n const leafId = source.getLeafId();\n const entry = leafId ? source.getEntry(leafId) : undefined;\n if (entry?.type !== \"message\" || entry.message.role !== \"assistant\") {\n throw new Error(\n \"Trajectory handoff requires the active fabric_exec assistant turn to be the session leaf\",\n );\n }\n const content = Array.isArray(entry.message.content) ? entry.message.content : [];\n const toolCalls = content.filter(isToolCall);\n if (!toolCalls.some((call) => call.id === outerToolCallId)) {\n throw new Error(\n \"Trajectory handoff could not find the active fabric_exec assistant turn in the Pi session\",\n );\n }\n if (toolCalls.length !== 1 || toolCalls[0]?.name !== \"fabric_exec\") {\n throw new Error(\n \"Trajectory handoff requires fabric_exec to be the only top-level tool call in its assistant turn\",\n );\n }\n return entry as NativeAssistantEntry;\n};\n\nexport const snapshotHandoffSession = (\n source: HandoffSessionSource,\n currentModel: CurrentModel | undefined,\n outerToolResult: AgentToolResultMessage,\n outerToolCallId: string,\n): AgentSessionSeed => {\n if (\n outerToolResult.toolCallId !== outerToolCallId ||\n outerToolResult.toolName !== \"fabric_exec\"\n ) {\n throw new Error(\"Trajectory handoff requires the finalized outer fabric_exec result\");\n }\n const active = activeFabricTurn(source, outerToolCallId);\n const sourceSessionFile = source.getSessionFile();\n const branch = source.getBranch();\n let model = currentModel\n ? { provider: currentModel.provider, modelId: currentModel.id }\n : undefined;\n let thinkingLevel: string | undefined;\n for (let index = branch.length - 1; index >= 0; index--) {\n const entry = branch[index];\n if (!thinkingLevel && entry?.type === \"thinking_level_change\") {\n thinkingLevel = entry.thinkingLevel;\n }\n if (!model && entry?.type === \"model_change\") {\n model = { provider: entry.provider, modelId: entry.modelId };\n }\n if (model && thinkingLevel) break;\n }\n return {\n sourceSessionId: source.getSessionId(),\n ...(sourceSessionFile ? { sourceSessionFile } : {}),\n sourceBranchLeafId: active.id,\n ...(!sourceSessionFile ? { sourceBranch: structuredClone(branch) } : {}),\n ...(model ? { sourceModel: model } : {}),\n ...(thinkingLevel ? { sourceThinkingLevel: thinkingLevel } : {}),\n outerToolResult: structuredClone(outerToolResult),\n };\n};\n\nconst materializeBranch = (\n seed: AgentSessionSeed,\n cwd: string,\n directory: string,\n): SessionManager => {\n if (!seed.sourceBranch) {\n throw new Error(\"In-memory trajectory handoff is missing its source branch\");\n }\n const id = randomUUID();\n const sessionFile = path.join(directory, `handoff-${id}.jsonl`);\n const header = {\n type: \"session\" as const,\n version: CURRENT_SESSION_VERSION,\n id,\n timestamp: new Date().toISOString(),\n cwd,\n ...(seed.sourceSessionFile ? { parentSession: seed.sourceSessionFile } : {}),\n };\n fs.writeFileSync(\n sessionFile,\n `${[header, ...seed.sourceBranch].map((entry) => JSON.stringify(entry)).join(\"\\n\")}\\n`,\n { encoding: \"utf8\", mode: 0o600, flag: \"wx\" },\n );\n return SessionManager.open(sessionFile, directory, cwd);\n};\n\nconst forkBranch = (\n seed: AgentSessionSeed,\n cwd: string,\n directory: string,\n): SessionManager => {\n if (!seed.sourceSessionFile) return materializeBranch(seed, cwd, directory);\n const fork = SessionManager.open(seed.sourceSessionFile, directory, cwd);\n if (!fork.getEntry(seed.sourceBranchLeafId)) {\n throw new Error(\n `Trajectory handoff branch point ${seed.sourceBranchLeafId} is missing from the persisted Pi session`,\n );\n }\n const sessionFile = fork.createBranchedSession(seed.sourceBranchLeafId);\n if (!sessionFile) {\n throw new Error(\"Trajectory handoff could not create a persisted Pi session branch\");\n }\n return fork;\n};\n\n// File-backed read of the exact branch prefix, cloned so transfer translation\n// never mutates the source session's live entries. Used instead of\n// forkBranch when the executor's reasoning channel differs: createBranchedSession\n// copies raw lines and cannot rewrite foreign thinking signatures.\nconst persistedBranch = (\n seed: AgentSessionSeed,\n cwd: string,\n directory: string,\n): SessionEntry[] => {\n if (!seed.sourceSessionFile) {\n throw new Error(\"Persisted trajectory handoff is missing its source session file\");\n }\n const source = SessionManager.open(seed.sourceSessionFile, directory, cwd);\n if (!source.getEntry(seed.sourceBranchLeafId)) {\n throw new Error(\n `Trajectory handoff branch point ${seed.sourceBranchLeafId} is missing from the persisted Pi session`,\n );\n }\n return structuredClone(source.getBranch(seed.sourceBranchLeafId));\n};\n\nconst synchronizeSourceSettings = (\n session: SessionManager,\n seed: AgentSessionSeed,\n): void => {\n const context = session.buildSessionContext();\n if (\n seed.sourceModel &&\n (context.model?.provider !== seed.sourceModel.provider ||\n context.model.modelId !== seed.sourceModel.modelId)\n ) {\n session.appendModelChange(seed.sourceModel.provider, seed.sourceModel.modelId);\n }\n if (seed.sourceThinkingLevel && context.thinkingLevel !== seed.sourceThinkingLevel) {\n session.appendThinkingLevelChange(seed.sourceThinkingLevel);\n }\n};\n\nexport const writeHandoffSession = (\n seed: AgentSessionSeed,\n cwd: string,\n directory: string,\n transfer?: ThinkingTransferInput,\n compaction?: HandoffCompactionRequest,\n): string => {\n fs.mkdirSync(directory, { recursive: true, mode: 0o700 });\n const policy = transfer ? thinkingTransferPolicy(transfer) : \"preserved\";\n let session: SessionManager;\n let report: ThinkingTransferReport | undefined;\n let digest: { content: string; citedBlocks: number } | undefined;\n if (!transfer || policy === \"preserved\") {\n session = forkBranch(seed, cwd, directory);\n } else {\n const rawBranch = seed.sourceSessionFile\n ? persistedBranch(seed, cwd, directory)\n : structuredClone(seed.sourceBranch ?? (() => {\n throw new Error(\"Trajectory handoff transfer is missing its source branch\");\n })());\n if (policy === \"stripped\") digest = buildThinkingDigest(rawBranch, transfer);\n const translated = translateThinkingForExecutor(rawBranch, policy);\n report = translated.report;\n session = materializeBranch({ ...seed, sourceBranch: translated.entries }, cwd, directory);\n }\n // Append the compaction entry before settings sync and the outer tool result\n // so the executor's context opens with the deterministic summary, followed\n // by the kept tail, then the boundary artifacts appended afterwards. The\n // file retains the full raw branch, mirroring Pi's append-only compaction.\n let compactionOutcome: HandoffCompactionOutcome | undefined;\n if (compaction) {\n const branchEntries = session.getBranch();\n const customInstructions = compaction.preserve\n ? encodeCompactionRequest({\n ...(compaction.instructions !== undefined\n ? { instructions: compaction.instructions }\n : {}),\n preserve: compaction.preserve,\n })\n : compaction.instructions;\n const tokensBefore = rawContextTokens(branchEntries);\n const compiled = compileFabricSummary(branchEntries, tokensBefore, undefined, customInstructions);\n if (\"cancel\" in compiled) {\n compactionOutcome = { applied: false, reason: compiled.reason };\n } else {\n session.appendCompaction(\n compiled.compaction.summary,\n compiled.compaction.firstKeptEntryId,\n tokensBefore,\n compiled.compaction.details,\n true,\n );\n compactionOutcome = {\n applied: true,\n sections: compiled.compaction.details?.sections ?? [],\n tokensBefore,\n firstKeptEntryId: compiled.compaction.firstKeptEntryId,\n };\n }\n }\n synchronizeSourceSettings(session, seed);\n session.appendMessage(seed.outerToolResult);\n if (digest) {\n session.appendCustomMessageEntry(THINKING_DIGEST_CUSTOM_TYPE, digest.content, false, {\n policy,\n citedBlocks: digest.citedBlocks,\n });\n }\n session.appendCustomEntry(\"pi-fabric-handoff\", {\n sourceSessionId: seed.sourceSessionId,\n boundary: \"fabric_exec_end\",\n ...(compactionOutcome\n ? {\n compaction: compactionOutcome.applied\n ? {\n applied: true,\n sections: compactionOutcome.sections,\n tokensBefore: compactionOutcome.tokensBefore,\n firstKeptEntryId: compactionOutcome.firstKeptEntryId,\n }\n : { applied: false, reason: compactionOutcome.reason },\n }\n : {}),\n ...(transfer && report\n ? {\n thinkingTransfer: {\n policy: report.policy,\n translated: report.translated,\n dropped: report.dropped,\n target: `${transfer.target.provider}/${transfer.target.modelId}`,\n },\n }\n : {}),\n });\n const sessionFile = session.getSessionFile();\n if (!sessionFile) throw new Error(\"Trajectory handoff did not produce a Pi session file\");\n fs.chmodSync(sessionFile, 0o600);\n return sessionFile;\n};\n", "import type { FabricPeerInfo } from \"./types.js\";\n\n/** Quiet window after a peer's last observed activity before it counts as settled. */\nconst DEFAULT_PEER_SETTLED_FOR_MS = 3_000;\nconst PEER_SETTLE_POLL_MS = 500;\n\n/**\n * Derive a Linear-style label prefix from a project path's basename:\n * \"pi-queue-steer\" -> \"PQS\", \"fabric\" -> \"FAB\". Falls back to \"P\".\n */\nexport const peerLabelPrefix = (cwd: string | undefined): string => {\n\tconst base = cwd?.split(/[\\\\/]/).filter(Boolean).at(-1) ?? \"\";\n\tconst words = base.split(/[^A-Za-z0-9]+/).filter(Boolean);\n\tif (words.length === 0) return \"P\";\n\t// Single-word projects borrow the first letters (\"fabric\" -> \"FAB\"),\n\t// multi-word projects take word initials (\"pi-queue-steer\" -> \"PQS\").\n\tif (words.length === 1) return words[0]!.slice(0, 3).toUpperCase();\n\treturn words\n\t\t.slice(0, 4)\n\t\t.map((word) => word[0]!.toUpperCase())\n\t\t.join(\"\");\n};\n\n/** Snapshot of one root peer session for pickers and status lines. */\nexport interface FabricPeerCard {\n\tid: string;\n\tlabel: string;\n\tstatus: \"idle\" | \"running\";\n\tmodel?: string;\n\tcwd?: string;\n\tstartedAt: number;\n\tupdatedAt: number;\n\tpendingMessages: boolean;\n}\n\n/** Labels are chronological, so creation order is simply label minting order. */\nexport const buildPeerCards = (peers: readonly FabricPeerInfo[]): FabricPeerCard[] =>\n\t[...peers]\n\t\t.sort((left, right) => left.startedAt - right.startedAt || left.id.localeCompare(right.id))\n\t\t.map((peer) => ({\n\t\t\tid: peer.id,\n\t\t\tlabel: peer.label ?? peer.name,\n\t\t\tstatus: peer.status,\n\t\t\t...(peer.model ? { model: peer.model } : {}),\n\t\t\t...(peer.cwd ? { cwd: peer.cwd } : {}),\n\t\t\tstartedAt: peer.startedAt,\n\t\t\tupdatedAt: peer.updatedAt,\n\t\t\tpendingMessages: peer.pendingMessages,\n\t\t}));\n\ninterface PeerSettleProgress {\n\twaiting: Array<{ label: string; status: \"idle\" | \"running\" }>;\n}\n\nexport type PeerSettleResult = { ok: true } | { ok: false; error: string };\n\nexport interface AwaitPeerSettleOptions {\n\t/** Fresh peer snapshot source (typically FabricRuntimeState.peerInfos()). */\n\tpoll: () => FabricPeerInfo[];\n\t/** Peer label (case-insensitive) or exact participant id. Omitted means all peers. */\n\tselector?: string;\n\tsettledForMs?: number;\n\tpollMs?: number;\n\tnow?: () => number;\n\tsignal?: AbortSignal;\n\tonUpdate?: (progress: PeerSettleProgress) => void;\n}\n\nconst matchesSelector = (peer: FabricPeerInfo, selector: string): boolean => {\n\tconst target = selector.trim().toLowerCase();\n\tif (!target) return false;\n\treturn (\n\t\tpeer.id.toLowerCase() === target ||\n\t\t(peer.label ?? \"\").toLowerCase() === target ||\n\t\tpeer.name.toLowerCase() === target\n\t);\n};\n\ninterface WatchedPeer {\n\tid: string;\n\tlabel: string;\n\trunning: boolean;\n\t/** Last time the peer was observed running; undefined when quiet since arming. */\n\tlastRunningAt: number | undefined;\n\tsettled: boolean;\n}\n\n/**\n * Wait until every watched peer has settled: only runs that started after\n * arming delay it (an idle-at-arm peer satisfies once the quiet window\n * passes), and a peer vanishing from the mesh counts as settled since it can\n * no longer conflict.\n */\nexport const awaitPeerSettle = (options: AwaitPeerSettleOptions): Promise<PeerSettleResult> => {\n\tconst now = options.now ?? (() => Date.now());\n\tconst settledFor = Math.max(0, options.settledForMs ?? DEFAULT_PEER_SETTLED_FOR_MS);\n\tconst pollMs = Math.max(10, options.pollMs ?? PEER_SETTLE_POLL_MS);\n\tconst armedAt = now();\n\tconst initial = options.poll();\n\tconst targets =\n\t\toptions.selector !== undefined\n\t\t\t? initial.filter((peer) => matchesSelector(peer, options.selector ?? \"\"))\n\t\t\t: [...initial];\n\tif (options.selector !== undefined && targets.length === 0) {\n\t\treturn Promise.resolve({\n\t\t\tok: false,\n\t\t\terror: `No Fabric peer matches \"${options.selector}\" on this project mesh`,\n\t\t});\n\t}\n\tif (targets.length === 0) return Promise.resolve({ ok: true });\n\n\tconst watched = new Map<string, WatchedPeer>();\n\tfor (const peer of targets) {\n\t\twatched.set(peer.id, {\n\t\t\tid: peer.id,\n\t\t\tlabel: peer.label ?? peer.name,\n\t\t\trunning: peer.status === \"running\",\n\t\t\tlastRunningAt: peer.status === \"running\" ? armedAt : undefined,\n\t\t\tsettled: false,\n\t\t});\n\t}\n\n\treturn new Promise<PeerSettleResult>((resolve) => {\n\t\tlet timer: ReturnType<typeof setInterval> | undefined;\n\t\tlet done = false;\n\t\tconst finish = (result: PeerSettleResult): void => {\n\t\t\tif (done) return;\n\t\t\tdone = true;\n\t\t\tif (timer) clearInterval(timer);\n\t\t\toptions.signal?.removeEventListener(\"abort\", onAbort);\n\t\t\tresolve(result);\n\t\t};\n\t\tconst onAbort = (): void => finish({ ok: false, error: \"cancelled\" });\n\t\tconst tick = (): void => {\n\t\t\tconst snapshot = options.poll();\n\t\t\tconst byId = new Map(snapshot.map((peer) => [peer.id, peer] as const));\n\t\t\tconst current = now();\n\t\t\tfor (const entry of watched.values()) {\n\t\t\t\tif (entry.settled) continue;\n\t\t\t\tconst peer = byId.get(entry.id);\n\t\t\t\tif (!peer) {\n\t\t\t\t\tentry.settled = true;\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tentry.label = peer.label ?? peer.name;\n\t\t\t\tconst running = peer.status === \"running\";\n\t\t\t\tif (running) {\n\t\t\t\t\tentry.lastRunningAt = current;\n\t\t\t\t\tentry.running = true;\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tentry.running = false;\n\t\t\t\tconst quietSince = entry.lastRunningAt ?? armedAt;\n\t\t\t\tif (current - quietSince >= settledFor) entry.settled = true;\n\t\t\t}\n\t\t\tconst waiting = [...watched.values()]\n\t\t\t\t.filter((entry) => !entry.settled)\n\t\t\t\t.map((entry) => ({ label: entry.label, status: entry.running ? \"running\" : \"idle\" }) as const);\n\t\t\tif (waiting.length === 0) {\n\t\t\t\toptions.onUpdate?.({ waiting });\n\t\t\t\tfinish({ ok: true });\n\t\t\t\treturn;\n\t\t\t}\n\t\t\toptions.onUpdate?.({ waiting });\n\t\t};\n\t\tif (options.signal) {\n\t\t\tif (options.signal.aborted) {\n\t\t\t\tfinish({ ok: false, error: \"cancelled\" });\n\t\t\t\treturn;\n\t\t\t}\n\t\t\toptions.signal.addEventListener(\"abort\", onAbort, { once: true });\n\t\t}\n\t\ttimer = setInterval(tick, pollMs);\n\t\ttick();\n\t});\n};\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;AAyDO,IAAM,8BAA8B;AAE3C,IAAM,yBAAyB;AAExB,IAAM,yBAAyB,CACpC,UAC2B;AAC3B,QAAM,EAAE,QAAQ,OAAO,IAAI;AAG3B,MACE,UACA,OAAO,aAAa,OAAO,aAC1B,OAAO,QAAQ,UAAa,OAAO,QAAQ,UAAa,OAAO,QAAQ,OAAO,MAC/E;AACA,WAAO;AAAA,EACT;AACA,MACE,OAAO,QAAQ,0BACf,OAAO,cAAc,QAC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BAAgB;AACtB,gBAAM,UAAU;AAChB;AAAA,QACD;AACA,cAAM,UAAU;AAChB,cAAM,aAAa,MAAM,iBAAiB;AAC1C,YAAI,UAAU,cAAc,WAAY,OAAM,UAAU;AAAA,MACzD;AACA,YAAM,UAAU,CAAC,GAAG,QAAQ,OAAO,CAAC,EAClC,OAAO,CAAC,UAAU,CAAC,MAAM,OAAO,EAChC,IAAI,CAAC,WAAW,EAAE,OAAO,MAAM,OAAO,QAAQ,MAAM,UAAU,YAAY,OAAO,EAAW;AAC9F,UAAI,QAAQ,WAAW,GAAG;AACzB,gBAAQ,WAAW,EAAE,QAAQ,CAAC;AAC9B,eAAO,EAAE,IAAI,KAAK,CAAC;AACnB;AAAA,MACD;AACA,cAAQ,WAAW,EAAE,QAAQ,CAAC;AAAA,IAC/B;AACA,QAAI,QAAQ,QAAQ;AACnB,UAAI,QAAQ,OAAO,SAAS;AAC3B,eAAO,EAAE,IAAI,OAAO,OAAO,YAAY,CAAC;AACxC;AAAA,MACD;AACA,cAAQ,OAAO,iBAAiB,SAAS,SAAS,EAAE,MAAM,KAAK,CAAC;AAAA,IACjE;AACA,YAAQ,YAAY,MAAM,MAAM;AAChC,SAAK;AAAA,EACN,CAAC;AACF;",
|
|
4
|
+
"sourcesContent": ["import type {\n SessionEntry,\n SessionMessageEntry,\n} from \"@earendil-works/pi-coding-agent\";\n\n// Cross-model thinking transfer for trajectory handoffs.\n//\n// Pi replays stored thinking blocks verbatim per provider: a Codex Responses\n// reasoning item rides as a provider-shaped `thinkingSignature` blob, and the\n// OpenAI-completions transform (pi-ai) uses that blob as the *request field\n// name* when the history is handed to a different provider \u2014 landing prior\n// deliberation in a junk field while the real `reasoning_content` stays\n// empty. Signature-sensitive families (Anthropic) reject foreign signatures\n// outright. This module applies a family-aware policy to the fabric-owned\n// child session at the handoff boundary, where rewriting is safe because the\n// source session (ground truth) is never touched:\n//\n// preserved \u2014 same provider and api family: native replay already works.\n// re-signed \u2014 openai-completions reasoning targets: thinking text is kept\n// and the signature normalized to \"reasoning_content\" so preserve-thinking\n// servers (Kimi, DeepSeek, \u2026) actually receive prior reasoning.\n// stripped \u2014 everything else: thinking blocks and foreign thought\n// signatures are removed so no bogus field or invalid signature is sent;\n// a bounded, entry-id-cited digest keeps continuity instead.\n\ninterface ThinkingTransferSource {\n provider: string;\n modelId: string;\n /** pi-ai transport api of the source model, when the registry resolves it. */\n api?: string | undefined;\n}\n\ninterface ThinkingTransferTarget {\n provider: string;\n modelId: string;\n api?: string | undefined;\n reasoning?: boolean | undefined;\n /** Model replays thinking as visible text; deliberation must not leak there. */\n requiresThinkingAsText?: boolean | undefined;\n}\n\nexport interface ThinkingTransferInput {\n source?: ThinkingTransferSource;\n target: ThinkingTransferTarget;\n}\n\nexport type ThinkingTransferPolicy = \"preserved\" | \"re-signed\" | \"stripped\";\n\nexport interface ThinkingTransferReport {\n policy: ThinkingTransferPolicy;\n translated: number;\n dropped: number;\n}\n\n// Field name pi-ai emits when a thinking block's signature is exactly this\n// string (the opencode-go \"reasoning\" \u2192 \"reasoning_content\" remap proves the\n// convention): the request then carries real prior reasoning content.\nexport const REASONING_CONTENT_SIGNATURE = \"reasoning_content\";\n\nconst OPENAI_COMPLETIONS_API = \"openai-completions\";\n\nexport const thinkingTransferPolicy = (\n input: ThinkingTransferInput,\n): ThinkingTransferPolicy => {\n const { source, target } = input;\n // Same provider with equal or unknown apis: native replay is provider-shipped\n // and the default experience; only an api-proof mismatch transfers.\n if (\n source &&\n source.provider === target.provider &&\n (source.api === undefined || target.api === undefined || source.api === target.api)\n ) {\n return \"preserved\";\n }\n if (\n target.api === OPENAI_COMPLETIONS_API &&\n target.reasoning === true &&\n target.requiresThinkingAsText !== true\n ) {\n return \"re-signed\";\n }\n return \"stripped\";\n};\n\nconst isRecord = (value: unknown): value is Record<string, unknown> =>\n typeof value === \"object\" && value !== null && !Array.isArray(value);\n\nconst isThinkingPart = (part: unknown): part is Record<string, unknown> =>\n isRecord(part) && part.type === \"thinking\";\n\n// Clone-and-rewrite walk over assistant content parts. Also clears foreign\n// `thoughtSignature` artifacts (Google-style reasoning_details), which are as\n// provider-bound as thinking signatures. Callers own the input; the original\n// entries are never mutated.\nexport const translateThinkingForExecutor = (\n entries: SessionEntry[],\n policy: ThinkingTransferPolicy,\n): { entries: SessionEntry[]; report: ThinkingTransferReport } => {\n if (policy === \"preserved\") {\n return { entries, report: { policy, translated: 0, dropped: 0 } };\n }\n const clone = structuredClone(entries);\n let translated = 0;\n let dropped = 0;\n for (const entry of clone) {\n if (entry.type !== \"message\") continue;\n const message = (entry as SessionMessageEntry).message as {\n role?: unknown;\n content?: unknown;\n };\n if (message.role !== \"assistant\" || !Array.isArray(message.content)) continue;\n const kept: unknown[] = [];\n for (const part of message.content as unknown[]) {\n if (isRecord(part) && part.type === \"toolCall\") {\n delete part.thoughtSignature;\n kept.push(part);\n continue;\n }\n if (!isThinkingPart(part)) {\n kept.push(part);\n continue;\n }\n const text = typeof part.thinking === \"string\" ? part.thinking : \"\";\n if (policy === \"re-signed\" && part.redacted !== true && text.trim().length > 0) {\n part.thinkingSignature = REASONING_CONTENT_SIGNATURE;\n translated += 1;\n kept.push(part);\n continue;\n }\n dropped += 1;\n }\n message.content = kept;\n }\n return { entries: clone, report: { policy, translated, dropped } };\n};\n\nexport const THINKING_DIGEST_CUSTOM_TYPE = \"pi-fabric-handoff-thinking\";\n\nconst MAX_DIGEST_BLOCKS = 8;\nconst MAX_DIGEST_LINE = 80;\nconst MAX_DIGEST_BYTES = 2048;\n\nexport interface ThinkingDigest {\n content: string;\n citedBlocks: number;\n}\n\nconst firstLineOf = (text: string): string => {\n const end = text.indexOf(\"\\n\");\n return end === -1 ? text : text.slice(0, end);\n};\n\nconst truncate = (text: string, max: number): string =>\n text.length > max ? text.slice(0, max) : text;\n\nconst clipUtf8 = (text: string, maxBytes: number): string => {\n if (Buffer.byteLength(text, \"utf8\") <= maxBytes) return text;\n let out = \"\";\n let bytes = 0;\n for (const char of text) {\n const size = Buffer.byteLength(char, \"utf8\");\n if (bytes + size > maxBytes) break;\n out += char;\n bytes += size;\n }\n return out;\n};\n\n// Bounded continuity bridge for executors whose reasoning channel cannot\n// accept prior thinking: the newest few first-lines, cited by stable entry id,\n// explicitly labeled as deliberation so they read as context, not style. The\n// full scratchpad remains addressable in the source session.\nexport const buildThinkingDigest = (\n entries: SessionEntry[],\n input: ThinkingTransferInput,\n): ThinkingDigest | undefined => {\n const blocks: Array<{ entryId: string; line: string }> = [];\n for (const entry of entries) {\n if (entry.type !== \"message\") continue;\n const message = (entry as SessionMessageEntry).message as {\n role?: unknown;\n content?: unknown;\n };\n if (message.role !== \"assistant\" || !Array.isArray(message.content)) continue;\n for (const part of message.content as unknown[]) {\n if (!isThinkingPart(part)) continue;\n const text = typeof part.thinking === \"string\" ? part.thinking : \"\";\n const line = truncate(firstLineOf(text).trim(), MAX_DIGEST_LINE);\n if (line) blocks.push({ entryId: entry.id, line });\n }\n }\n if (blocks.length === 0) return undefined;\n const recent = blocks.slice(-MAX_DIGEST_BLOCKS);\n const omitted = blocks.length - recent.length;\n const sourceId = input.source\n ? `${input.source.provider}/${input.source.modelId}`\n : \"the prior model\";\n const targetId = `${input.target.provider}/${input.target.modelId}`;\n const lines = [\n \"Prewalk handoff continuity digest (deliberation, not commitments).\",\n `Thinking from ${sourceId} was not transferred: ${targetId} cannot replay it (incompatible reasoning channels). Most recent lines:`,\n ...recent.map((block) => `- [entry ${block.entryId}] ${block.line}`),\n ];\n if (omitted > 0) lines.push(`(omitted ${omitted} older thinking blocks)`);\n lines.push(\"Full thinking remains addressable in the source session by entry id.\");\n return {\n content: clipUtf8(lines.join(\"\\n\"), MAX_DIGEST_BYTES),\n citedBlocks: recent.length,\n };\n};\n", "import { randomUUID } from \"node:crypto\";\nimport fs from \"node:fs\";\nimport path from \"node:path\";\nimport {\n CURRENT_SESSION_VERSION,\n SessionManager,\n type SessionEntry,\n type SessionMessageEntry,\n} from \"@earendil-works/pi-coding-agent\";\nimport type { JsonObject } from \"@earendil-works/pi-ai\";\nimport { compileFabricSummary, rawContextTokens } from \"../compaction/hook.js\";\nimport {\n compactionRequestBoundsError,\n encodeCompactionRequest,\n} from \"../compaction/instructions.js\";\nimport type {\n AgentSessionSeed,\n AgentToolResultMessage,\n HandoffCompactionRequest,\n} from \"./types.js\";\nimport {\n buildThinkingDigest,\n THINKING_DIGEST_CUSTOM_TYPE,\n thinkingTransferPolicy,\n translateThinkingForExecutor,\n type ThinkingTransferInput,\n type ThinkingTransferReport,\n} from \"./thinking-transfer.js\";\n\ninterface HandoffSessionSource {\n getBranch(): SessionEntry[];\n getEntry(id: string): SessionEntry | undefined;\n getLeafId(): string | null;\n getSessionFile(): string | undefined;\n getSessionId(): string;\n}\n\ninterface CurrentModel {\n provider: string;\n id: string;\n}\n\ntype NativeAssistantMessage = Extract<\n SessionMessageEntry[\"message\"],\n { role: \"assistant\" }\n>;\ntype NativeAssistantEntry = SessionMessageEntry & {\n message: NativeAssistantMessage;\n};\n\nconst isRecord = (value: unknown): value is Record<string, unknown> =>\n typeof value === \"object\" && value !== null && !Array.isArray(value);\n\ninterface HandoffCompactionOutcome {\n applied: boolean;\n reason?: string;\n sections?: string[];\n tokensBefore?: number;\n firstKeptEntryId?: string;\n}\n\n// Validate the model-facing agents.handoff `compact` option against the same\n// bounds as compact.request. Called both when the request is scheduled (inside\n// the guest) and when the boundary runner replays it.\nexport const checkedHandoffCompaction = (\n value: unknown,\n): HandoffCompactionRequest | undefined => {\n if (value === undefined || value === false) return undefined;\n const input = value === true ? {} : value;\n if (!isRecord(input)) {\n throw new Error(\n \"Invalid agents.handoff compact arguments: compact must be true or an object with instructions/preserve\",\n );\n }\n if (input.instructions !== undefined && typeof input.instructions !== \"string\") {\n throw new Error(\"Invalid agents.handoff compact arguments: instructions must be a string\");\n }\n if (\n input.preserve !== undefined &&\n (!Array.isArray(input.preserve) || input.preserve.some((item) => typeof item !== \"string\"))\n ) {\n throw new Error(\n \"Invalid agents.handoff compact arguments: preserve must be an array of strings\",\n );\n }\n const request: HandoffCompactionRequest = {\n ...(typeof input.instructions === \"string\" ? { instructions: input.instructions } : {}),\n ...(input.preserve !== undefined ? { preserve: input.preserve as string[] } : {}),\n };\n const boundsError = compactionRequestBoundsError(request);\n if (boundsError) {\n throw new Error(`Invalid agents.handoff compact arguments: ${boundsError.message}`);\n }\n return request;\n};\n\nconst isToolCall = (value: unknown): value is {\n type: \"toolCall\";\n id: string;\n name: string;\n arguments: JsonObject;\n} =>\n isRecord(value) &&\n value.type === \"toolCall\" &&\n typeof value.id === \"string\" &&\n typeof value.name === \"string\" &&\n isRecord(value.arguments);\n\nconst activeFabricTurn = (\n source: HandoffSessionSource,\n outerToolCallId: string,\n): NativeAssistantEntry => {\n const leafId = source.getLeafId();\n const entry = leafId ? source.getEntry(leafId) : undefined;\n if (entry?.type !== \"message\" || entry.message.role !== \"assistant\") {\n throw new Error(\n \"Trajectory handoff requires the active fabric_exec assistant turn to be the session leaf\",\n );\n }\n const content = Array.isArray(entry.message.content) ? entry.message.content : [];\n const toolCalls = content.filter(isToolCall);\n if (!toolCalls.some((call) => call.id === outerToolCallId)) {\n throw new Error(\n \"Trajectory handoff could not find the active fabric_exec assistant turn in the Pi session\",\n );\n }\n if (toolCalls.length !== 1 || toolCalls[0]?.name !== \"fabric_exec\") {\n throw new Error(\n \"Trajectory handoff requires fabric_exec to be the only top-level tool call in its assistant turn\",\n );\n }\n return entry as NativeAssistantEntry;\n};\n\nexport const snapshotHandoffSession = (\n source: HandoffSessionSource,\n currentModel: CurrentModel | undefined,\n outerToolResult: AgentToolResultMessage,\n outerToolCallId: string,\n): AgentSessionSeed => {\n if (\n outerToolResult.toolCallId !== outerToolCallId ||\n outerToolResult.toolName !== \"fabric_exec\"\n ) {\n throw new Error(\"Trajectory handoff requires the finalized outer fabric_exec result\");\n }\n const active = activeFabricTurn(source, outerToolCallId);\n const sourceSessionFile = source.getSessionFile();\n const branch = source.getBranch();\n let model = currentModel\n ? { provider: currentModel.provider, modelId: currentModel.id }\n : undefined;\n let thinkingLevel: string | undefined;\n for (let index = branch.length - 1; index >= 0; index--) {\n const entry = branch[index];\n if (!thinkingLevel && entry?.type === \"thinking_level_change\") {\n thinkingLevel = entry.thinkingLevel;\n }\n if (!model && entry?.type === \"model_change\") {\n model = { provider: entry.provider, modelId: entry.modelId };\n }\n if (model && thinkingLevel) break;\n }\n return {\n sourceSessionId: source.getSessionId(),\n ...(sourceSessionFile ? { sourceSessionFile } : {}),\n sourceBranchLeafId: active.id,\n ...(!sourceSessionFile ? { sourceBranch: structuredClone(branch) } : {}),\n ...(model ? { sourceModel: model } : {}),\n ...(thinkingLevel ? { sourceThinkingLevel: thinkingLevel } : {}),\n outerToolResult: structuredClone(outerToolResult),\n };\n};\n\nconst materializeBranch = (\n seed: AgentSessionSeed,\n cwd: string,\n directory: string,\n): SessionManager => {\n if (!seed.sourceBranch) {\n throw new Error(\"In-memory trajectory handoff is missing its source branch\");\n }\n const id = randomUUID();\n const sessionFile = path.join(directory, `handoff-${id}.jsonl`);\n const header = {\n type: \"session\" as const,\n version: CURRENT_SESSION_VERSION,\n id,\n timestamp: new Date().toISOString(),\n cwd,\n ...(seed.sourceSessionFile ? { parentSession: seed.sourceSessionFile } : {}),\n };\n fs.writeFileSync(\n sessionFile,\n `${[header, ...seed.sourceBranch].map((entry) => JSON.stringify(entry)).join(\"\\n\")}\\n`,\n { encoding: \"utf8\", mode: 0o600, flag: \"wx\" },\n );\n return SessionManager.open(sessionFile, directory, cwd);\n};\n\nconst forkBranch = (\n seed: AgentSessionSeed,\n cwd: string,\n directory: string,\n): SessionManager => {\n if (!seed.sourceSessionFile) return materializeBranch(seed, cwd, directory);\n const fork = SessionManager.open(seed.sourceSessionFile, directory, cwd);\n if (!fork.getEntry(seed.sourceBranchLeafId)) {\n throw new Error(\n `Trajectory handoff branch point ${seed.sourceBranchLeafId} is missing from the persisted Pi session`,\n );\n }\n const sessionFile = fork.createBranchedSession(seed.sourceBranchLeafId);\n if (!sessionFile) {\n throw new Error(\"Trajectory handoff could not create a persisted Pi session branch\");\n }\n return fork;\n};\n\n// File-backed read of the exact branch prefix, cloned so transfer translation\n// never mutates the source session's live entries. Used instead of\n// forkBranch when the executor's reasoning channel differs: createBranchedSession\n// copies raw lines and cannot rewrite foreign thinking signatures.\nconst persistedBranch = (\n seed: AgentSessionSeed,\n cwd: string,\n directory: string,\n): SessionEntry[] => {\n if (!seed.sourceSessionFile) {\n throw new Error(\"Persisted trajectory handoff is missing its source session file\");\n }\n const source = SessionManager.open(seed.sourceSessionFile, directory, cwd);\n if (!source.getEntry(seed.sourceBranchLeafId)) {\n throw new Error(\n `Trajectory handoff branch point ${seed.sourceBranchLeafId} is missing from the persisted Pi session`,\n );\n }\n return structuredClone(source.getBranch(seed.sourceBranchLeafId));\n};\n\nconst synchronizeSourceSettings = (\n session: SessionManager,\n seed: AgentSessionSeed,\n): void => {\n const context = session.buildSessionContext();\n if (\n seed.sourceModel &&\n (context.model?.provider !== seed.sourceModel.provider ||\n context.model.modelId !== seed.sourceModel.modelId)\n ) {\n session.appendModelChange(seed.sourceModel.provider, seed.sourceModel.modelId);\n }\n if (seed.sourceThinkingLevel && context.thinkingLevel !== seed.sourceThinkingLevel) {\n session.appendThinkingLevelChange(seed.sourceThinkingLevel);\n }\n};\n\nexport const writeHandoffSession = (\n seed: AgentSessionSeed,\n cwd: string,\n directory: string,\n transfer?: ThinkingTransferInput,\n compaction?: HandoffCompactionRequest,\n): string => {\n fs.mkdirSync(directory, { recursive: true, mode: 0o700 });\n const policy = transfer ? thinkingTransferPolicy(transfer) : \"preserved\";\n let session: SessionManager;\n let report: ThinkingTransferReport | undefined;\n let digest: { content: string; citedBlocks: number } | undefined;\n if (!transfer || policy === \"preserved\") {\n session = forkBranch(seed, cwd, directory);\n } else {\n const rawBranch = seed.sourceSessionFile\n ? persistedBranch(seed, cwd, directory)\n : structuredClone(seed.sourceBranch ?? (() => {\n throw new Error(\"Trajectory handoff transfer is missing its source branch\");\n })());\n if (policy === \"stripped\") digest = buildThinkingDigest(rawBranch, transfer);\n const translated = translateThinkingForExecutor(rawBranch, policy);\n report = translated.report;\n session = materializeBranch({ ...seed, sourceBranch: translated.entries }, cwd, directory);\n }\n // Append the compaction entry before settings sync and the outer tool result\n // so the executor's context opens with the deterministic summary, followed\n // by the kept tail, then the boundary artifacts appended afterwards. The\n // file retains the full raw branch, mirroring Pi's append-only compaction.\n let compactionOutcome: HandoffCompactionOutcome | undefined;\n if (compaction) {\n const branchEntries = session.getBranch();\n const customInstructions = compaction.preserve\n ? encodeCompactionRequest({\n ...(compaction.instructions !== undefined\n ? { instructions: compaction.instructions }\n : {}),\n preserve: compaction.preserve,\n })\n : compaction.instructions;\n const tokensBefore = rawContextTokens(branchEntries);\n const compiled = compileFabricSummary(branchEntries, tokensBefore, undefined, customInstructions);\n if (\"cancel\" in compiled) {\n compactionOutcome = { applied: false, reason: compiled.reason };\n } else {\n session.appendCompaction(\n compiled.compaction.summary,\n compiled.compaction.firstKeptEntryId,\n tokensBefore,\n compiled.compaction.details,\n true,\n );\n compactionOutcome = {\n applied: true,\n sections: compiled.compaction.details?.sections ?? [],\n tokensBefore,\n firstKeptEntryId: compiled.compaction.firstKeptEntryId,\n };\n }\n }\n synchronizeSourceSettings(session, seed);\n session.appendMessage(seed.outerToolResult);\n if (digest) {\n session.appendCustomMessageEntry(THINKING_DIGEST_CUSTOM_TYPE, digest.content, false, {\n policy,\n citedBlocks: digest.citedBlocks,\n });\n }\n session.appendCustomEntry(\"pi-fabric-handoff\", {\n sourceSessionId: seed.sourceSessionId,\n boundary: \"fabric_exec_end\",\n ...(compactionOutcome\n ? {\n compaction: compactionOutcome.applied\n ? {\n applied: true,\n sections: compactionOutcome.sections,\n tokensBefore: compactionOutcome.tokensBefore,\n firstKeptEntryId: compactionOutcome.firstKeptEntryId,\n }\n : { applied: false, reason: compactionOutcome.reason },\n }\n : {}),\n ...(transfer && report\n ? {\n thinkingTransfer: {\n policy: report.policy,\n translated: report.translated,\n dropped: report.dropped,\n target: `${transfer.target.provider}/${transfer.target.modelId}`,\n },\n }\n : {}),\n });\n const sessionFile = session.getSessionFile();\n if (!sessionFile) throw new Error(\"Trajectory handoff did not produce a Pi session file\");\n fs.chmodSync(sessionFile, 0o600);\n return sessionFile;\n};\n", "import type { FabricPeerInfo } from \"./types.js\";\n\n/** Quiet window after a peer's last observed activity before it counts as settled. */\nconst DEFAULT_PEER_SETTLED_FOR_MS = 3_000;\nconst PEER_SETTLE_POLL_MS = 500;\n\n/**\n * Derive a Linear-style label prefix from a project path's basename:\n * \"pi-queue-steer\" -> \"PQS\", \"fabric\" -> \"FAB\". Falls back to \"P\".\n */\nexport const peerLabelPrefix = (cwd: string | undefined): string => {\n\tconst base = cwd?.split(/[\\\\/]/).filter(Boolean).at(-1) ?? \"\";\n\tconst words = base.split(/[^A-Za-z0-9]+/).filter(Boolean);\n\tif (words.length === 0) return \"P\";\n\t// Single-word projects borrow the first letters (\"fabric\" -> \"FAB\"),\n\t// multi-word projects take word initials (\"pi-queue-steer\" -> \"PQS\").\n\tif (words.length === 1) return words[0]!.slice(0, 3).toUpperCase();\n\treturn words\n\t\t.slice(0, 4)\n\t\t.map((word) => word[0]!.toUpperCase())\n\t\t.join(\"\");\n};\n\n/** Snapshot of one root peer session for pickers and status lines. */\nexport interface FabricPeerCard {\n\tid: string;\n\tlabel: string;\n\tstatus: \"idle\" | \"running\";\n\tmodel?: string;\n\tcwd?: string;\n\tstartedAt: number;\n\tupdatedAt: number;\n\tpendingMessages: boolean;\n}\n\n/** Labels are chronological, so creation order is simply label minting order. */\nexport const buildPeerCards = (peers: readonly FabricPeerInfo[]): FabricPeerCard[] =>\n\t[...peers]\n\t\t.sort((left, right) => left.startedAt - right.startedAt || left.id.localeCompare(right.id))\n\t\t.map((peer) => ({\n\t\t\tid: peer.id,\n\t\t\tlabel: peer.label ?? peer.name,\n\t\t\tstatus: peer.status,\n\t\t\t...(peer.model ? { model: peer.model } : {}),\n\t\t\t...(peer.cwd ? { cwd: peer.cwd } : {}),\n\t\t\tstartedAt: peer.startedAt,\n\t\t\tupdatedAt: peer.updatedAt,\n\t\t\tpendingMessages: peer.pendingMessages,\n\t\t}));\n\ninterface PeerSettleProgress {\n\twaiting: Array<{ label: string; status: \"idle\" | \"running\" }>;\n}\n\nexport type PeerSettleResult = { ok: true } | { ok: false; error: string };\n\nexport interface AwaitPeerSettleOptions {\n\t/** Fresh peer snapshot source (typically FabricRuntimeState.peerInfos()). */\n\tpoll: () => FabricPeerInfo[];\n\t/** Peer label (case-insensitive) or exact participant id. Omitted means all peers. */\n\tselector?: string;\n\tsettledForMs?: number;\n\tpollMs?: number;\n\tnow?: () => number;\n\tsignal?: AbortSignal;\n\tonUpdate?: (progress: PeerSettleProgress) => void;\n}\n\nconst matchesSelector = (peer: FabricPeerInfo, selector: string): boolean => {\n\tconst target = selector.trim().toLowerCase();\n\tif (!target) return false;\n\treturn (\n\t\tpeer.id.toLowerCase() === target ||\n\t\t(peer.label ?? \"\").toLowerCase() === target ||\n\t\tpeer.name.toLowerCase() === target\n\t);\n};\n\ninterface WatchedPeer {\n\tid: string;\n\tlabel: string;\n\trunning: boolean;\n\t/** Last time the peer was observed running; undefined when quiet since arming. */\n\tlastRunningAt: number | undefined;\n\tsettled: boolean;\n}\n\n/**\n * Wait until every watched peer has settled: only runs that started after\n * arming delay it (an idle-at-arm peer satisfies once the quiet window\n * passes), and a peer vanishing from the mesh counts as settled since it can\n * no longer conflict.\n */\nexport const awaitPeerSettle = (options: AwaitPeerSettleOptions): Promise<PeerSettleResult> => {\n\tconst now = options.now ?? (() => Date.now());\n\tconst settledFor = Math.max(0, options.settledForMs ?? DEFAULT_PEER_SETTLED_FOR_MS);\n\tconst pollMs = Math.max(10, options.pollMs ?? PEER_SETTLE_POLL_MS);\n\tconst armedAt = now();\n\tconst initial = options.poll();\n\tconst targets =\n\t\toptions.selector !== undefined\n\t\t\t? initial.filter((peer) => matchesSelector(peer, options.selector ?? \"\"))\n\t\t\t: [...initial];\n\tif (options.selector !== undefined && targets.length === 0) {\n\t\treturn Promise.resolve({\n\t\t\tok: false,\n\t\t\terror: `No Fabric peer matches \"${options.selector}\" on this project mesh`,\n\t\t});\n\t}\n\tif (targets.length === 0) return Promise.resolve({ ok: true });\n\n\tconst watched = new Map<string, WatchedPeer>();\n\tfor (const peer of targets) {\n\t\twatched.set(peer.id, {\n\t\t\tid: peer.id,\n\t\t\tlabel: peer.label ?? peer.name,\n\t\t\trunning: peer.status === \"running\",\n\t\t\tlastRunningAt: peer.status === \"running\" ? armedAt : undefined,\n\t\t\tsettled: false,\n\t\t});\n\t}\n\n\treturn new Promise<PeerSettleResult>((resolve) => {\n\t\tlet timer: ReturnType<typeof setInterval> | undefined;\n\t\tlet done = false;\n\t\tconst finish = (result: PeerSettleResult): void => {\n\t\t\tif (done) return;\n\t\t\tdone = true;\n\t\t\tif (timer) clearInterval(timer);\n\t\t\toptions.signal?.removeEventListener(\"abort\", onAbort);\n\t\t\tresolve(result);\n\t\t};\n\t\tconst onAbort = (): void => finish({ ok: false, error: \"cancelled\" });\n\t\tconst tick = (): void => {\n\t\t\tconst snapshot = options.poll();\n\t\t\tconst byId = new Map(snapshot.map((peer) => [peer.id, peer] as const));\n\t\t\tconst current = now();\n\t\t\tfor (const entry of watched.values()) {\n\t\t\t\tif (entry.settled) continue;\n\t\t\t\tconst peer = byId.get(entry.id);\n\t\t\t\tif (!peer) {\n\t\t\t\t\tentry.settled = true;\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tentry.label = peer.label ?? peer.name;\n\t\t\t\tconst running = peer.status === \"running\";\n\t\t\t\tif (running) {\n\t\t\t\t\tentry.lastRunningAt = current;\n\t\t\t\t\tentry.running = true;\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tentry.running = false;\n\t\t\t\tconst quietSince = entry.lastRunningAt ?? armedAt;\n\t\t\t\tif (current - quietSince >= settledFor) entry.settled = true;\n\t\t\t}\n\t\t\tconst waiting = [...watched.values()]\n\t\t\t\t.filter((entry) => !entry.settled)\n\t\t\t\t.map((entry) => ({ label: entry.label, status: entry.running ? \"running\" : \"idle\" }) as const);\n\t\t\tif (waiting.length === 0) {\n\t\t\t\toptions.onUpdate?.({ waiting });\n\t\t\t\tfinish({ ok: true });\n\t\t\t\treturn;\n\t\t\t}\n\t\t\toptions.onUpdate?.({ waiting });\n\t\t};\n\t\tif (options.signal) {\n\t\t\tif (options.signal.aborted) {\n\t\t\t\tfinish({ ok: false, error: \"cancelled\" });\n\t\t\t\treturn;\n\t\t\t}\n\t\t\toptions.signal.addEventListener(\"abort\", onAbort, { once: true });\n\t\t}\n\t\ttimer = setInterval(tick, pollMs);\n\t\ttick();\n\t});\n};\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;AAyDO,IAAM,8BAA8B;AAE3C,IAAM,yBAAyB;AAExB,IAAM,yBAAyB,CACpC,UAC2B;AAC3B,QAAM,EAAE,QAAQ,OAAO,IAAI;AAG3B,MACE,UACA,OAAO,aAAa,OAAO,aAC1B,OAAO,QAAQ,UAAa,OAAO,QAAQ,UAAa,OAAO,QAAQ,OAAO,MAC/E;AACA,WAAO;AAAA,EACT;AACA,MACE,OAAO,QAAQ,0BACf,OAAO,cAAc,QACrB,OAAO,2BAA2B,MAClC;AACA,WAAO;AAAA,EACT;AACA,SAAO;AACT;AAEA,IAAM,WAAW,CAAC,UAChB,OAAO,UAAU,YAAY,UAAU,QAAQ,CAAC,MAAM,QAAQ,KAAK;AAErE,IAAM,iBAAiB,CAAC,SACtB,SAAS,IAAI,KAAK,KAAK,SAAS;AAM3B,IAAM,+BAA+B,CAC1C,SACA,WACgE;AAChE,MAAI,WAAW,aAAa;AAC1B,WAAO,EAAE,SAAS,QAAQ,EAAE,QAAQ,YAAY,GAAG,SAAS,EAAE,EAAE;AAAA,EAClE;AACA,QAAM,QAAQ,gBAAgB,OAAO;AACrC,MAAI,aAAa;AACjB,MAAI,UAAU;AACd,aAAW,SAAS,OAAO;AACzB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,WAAW,EAAE,QAAQ,CAAC;AAAA,IAC/B;AACA,QAAI,QAAQ,QAAQ;AACnB,UAAI,QAAQ,OAAO,SAAS;AAC3B,eAAO,EAAE,IAAI,OAAO,OAAO,YAAY,CAAC;AACxC;AAAA,MACD;AACA,cAAQ,OAAO,iBAAiB,SAAS,SAAS,EAAE,MAAM,KAAK,CAAC;AAAA,IACjE;AACA,YAAQ,YAAY,MAAM,MAAM;AAChC,SAAK;AAAA,EACN,CAAC;AACF;",
|
|
6
6
|
"names": ["isRecord"]
|
|
7
7
|
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/actors/types.ts"],
|
|
4
|
+
"sourcesContent": ["import type { ExtensionEvent } from \"@earendil-works/pi-coding-agent\";\nimport type { FabricAgentRunner, FabricAgentTransport, FabricPythonRuntime } from \"../config.js\";\nimport type { FabricThinking } from \"../thinking.js\";\nimport type { FabricLogLine, AgentRunRecord, AgentUsage } from \"../agents/types.js\";\nimport type { FabricCapabilityRequirement } from \"../components/types.js\";\nimport type { FabricKernel } from \"../runtime/kernel.js\";\nimport type { FabricParticipantResidency } from \"../topology/types.js\";\n\n// Pi's extension event union is closed; every member we want the actor host\n// to observe must appear in FABRIC_ACTOR_PI_HOST_EVENTS below. `project_trust`\n// uses pi's dedicated trust handler, and pi 0.86's `cache_warming_decision` is\n// a host-internal prompt-cache maintenance control event, so neither is an\n// actor observation and both are excluded here.\nexport type FabricActorPiHostEvent = Exclude<\n ExtensionEvent[\"type\"],\n \"project_trust\" | \"cache_warming_decision\"\n>;\n\nconst defineFabricActorPiHostEvents = <\n const Events extends readonly FabricActorPiHostEvent[],\n>(\n events: Exclude<FabricActorPiHostEvent, Events[number]> extends never ? Events : never,\n): Events => events;\n\nexport const FABRIC_ACTOR_PI_HOST_EVENTS = defineFabricActorPiHostEvents([\n \"resources_discover\",\n \"session_start\",\n \"session_info_changed\",\n \"session_before_switch\",\n \"session_before_fork\",\n \"session_before_compact\",\n \"session_compact\",\n \"session_compact_failed\",\n \"session_shutdown\",\n \"session_before_tree\",\n \"session_tree\",\n \"input\",\n \"before_agent_start\",\n \"agent_start\",\n \"agent_end\",\n \"agent_settled\",\n \"turn_start\",\n \"turn_end\",\n \"message_start\",\n \"message_update\",\n \"message_end\",\n \"ui_prompt_start\",\n \"ui_prompt_end\",\n \"context\",\n \"before_provider_headers\",\n \"before_provider_request\",\n \"after_provider_response\",\n \"tool_execution_start\",\n \"tool_call\",\n \"tool_execution_update\",\n \"tool_result\",\n \"tool_execution_end\",\n \"model_select\",\n \"thinking_level_select\",\n \"user_bash\",\n]);\n\nexport const FABRIC_ACTOR_HOST_EVENTS = [\n ...FABRIC_ACTOR_PI_HOST_EVENTS,\n \"tool_error\",\n] as const;\n\nexport type FabricActorHostEvent = (typeof FABRIC_ACTOR_HOST_EVENTS)[number];\n\nconst FABRIC_ACTOR_HOST_EVENT_SET: ReadonlySet<string> = new Set(FABRIC_ACTOR_HOST_EVENTS);\n\nexport const isFabricActorHostEvent = (value: unknown): value is FabricActorHostEvent =>\n typeof value === \"string\" && FABRIC_ACTOR_HOST_EVENT_SET.has(value);\n\nexport type FabricActorDelivery = \"mailbox\" | \"steer\" | \"followUp\" | \"nextTurn\";\nexport type FabricActorResponseMode = \"text\" | \"directive\";\nexport type FabricActorStatus = \"idle\" | \"queued\" | \"running\" | \"stopped\";\nexport type FabricActorBindingScope = \"session\" | \"project\";\nexport type FabricActorStorageScope = \"session\" | \"project\";\n\nexport interface FabricActorRunBinding {\n model?: string;\n thinking?: FabricThinking;\n}\n\ninterface FabricActorBindingView extends FabricActorRunBinding {\n scope: \"session\";\n sessionId: string;\n updatedAt?: number;\n}\n\ninterface FabricActorProjectDefaults extends FabricActorRunBinding {\n scope: \"project\";\n}\n\nexport interface FabricActorValidWhileSource {\n version: 1;\n source: string;\n}\n\nexport interface FabricActorValidityDecision {\n valid: boolean;\n reason?: string;\n}\n\nexport type FabricActorActivation =\n | {\n kind: \"hostEvent\";\n id: string;\n source: string;\n sequence: number;\n createdAt: number;\n event: FabricActorHostEvent;\n mainRevision: number;\n taskRevision: number;\n signal?: unknown;\n }\n | {\n kind: \"direct\";\n id: string;\n source: string;\n sequence: number;\n createdAt: number;\n }\n | {\n kind: \"mesh\";\n id: string;\n source: string;\n sequence: number;\n createdAt: number;\n topic: string;\n };\n\nexport interface FabricActorValidityFacts {\n activation: FabricActorActivation;\n current: {\n latestActivationSequence: number;\n mainRevision: number;\n taskRevision: number;\n idle: boolean;\n now: number;\n };\n}\n\nexport interface FabricActorRequest {\n /** Storage and visibility boundary. Defaults to mesh.actorScope for compatibility. */\n scope?: FabricActorStorageScope;\n name: string;\n instructions: string;\n /** Asynchronous observations of session-bound Pi events plus synthetic tool_error. */\n events?: FabricActorHostEvent[];\n topics?: string[];\n /** Defaults to mailbox. steer/followUp require an explicit triggerTurn choice. */\n delivery?: FabricActorDelivery;\n responseMode?: FabricActorResponseMode;\n /** Required for steer/followUp; must be false or omitted for mailbox/nextTurn. */\n triggerTurn?: boolean;\n coalesce?: boolean;\n /** session actors stop with their Pi host; durable actors transfer to a resident host. */\n residency?: FabricParticipantResidency;\n runner?: FabricAgentRunner;\n /** Omitted/inherit resolves at creation; the actor keeps one language for its session. */\n kernel?: FabricKernel | \"inherit\";\n /** Host-only backend snapshot for persistent/resident sessions; not a provider argument. */\n pythonRuntime?: FabricPythonRuntime;\n model?: string;\n thinking?: FabricThinking;\n tools?: string[];\n transport?: FabricAgentTransport;\n timeoutMs?: number;\n /**\n * Fabric capability for the actor. Defaults to true (today's behavior: a Pi\n * actor is recursively Fabric-equipped with the host-required fabric_exec\n * tool). Set false to disable Fabric for a Pi actor: the activation runs with\n * extensions:false and recursive:false so fabric_exec is not injected and the\n * actor cannot call agents.* or mesh.*; the host still manages its mailbox\n * and delivery (same model as a Claude actor). This does not restrict the\n * actor's ordinary tool allowlist. Fixed at creation.\n */\n extensions?: boolean;\n /** Exact Fabric actions committed before every actor run. Optional entries do not block a run. */\n requires?: readonly (string | FabricCapabilityRequirement)[];\n /** Serialized guest predicate evaluated before work and before delivery. */\n validWhile?: FabricActorValidWhileSource;\n}\n\nexport interface FabricActorInfo {\n id: string;\n scope: FabricActorStorageScope;\n name: string;\n rootId?: string;\n status: FabricActorStatus;\n runner: FabricAgentRunner;\n kernel?: FabricKernel;\n pythonRuntime?: FabricPythonRuntime;\n events: FabricActorHostEvent[];\n topics: string[];\n delivery: FabricActorDelivery;\n responseMode: FabricActorResponseMode;\n triggerTurn: boolean;\n coalesce: boolean;\n residency?: FabricParticipantResidency;\n /** Effective value for this caller after session bindings overlay project defaults. */\n model?: string;\n /** Effective value for this caller after session bindings overlay project defaults. */\n thinking?: FabricThinking;\n binding?: FabricActorBindingView;\n projectDefaults?: FabricActorProjectDefaults;\n tools?: string[];\n timeoutMs?: number;\n extensions?: boolean;\n requirements?: FabricCapabilityRequirement[];\n capabilityDigest?: string;\n missingCapabilities?: string[];\n validWhile?: FabricActorValidWhileSource;\n queued: number;\n messages: number;\n createdAt: number;\n updatedAt: number;\n lastRunId?: string;\n lastError?: string;\n sessionFile?: string;\n logDir?: string;\n}\n\nexport interface FabricActorLog {\n actorId: string;\n actorName: string;\n sessionFile: string;\n logDir: string;\n session: FabricLogLine[];\n sessionHasMore: boolean;\n sessionBefore?: number;\n run?: {\n runId: string;\n eventsFile: string;\n status?: AgentRunRecord;\n events: FabricLogLine[];\n hasMore: boolean;\n before?: number;\n };\n retainedRuns: string[];\n}\n\nexport interface FabricActorMessage {\n id: string;\n actorId: string;\n actorName: string;\n direction: \"in\" | \"out\";\n source: string;\n createdAt: number;\n text?: string;\n data?: unknown;\n action?: \"silent\" | \"message\" | \"stop\";\n runId?: string;\n usage?: AgentUsage;\n error?: string;\n stale?: boolean;\n reason?: string;\n}\n\nexport interface FabricActorDirective {\n action: \"silent\" | \"message\" | \"stop\";\n message?: string;\n data?: unknown;\n}\n\nexport interface FabricActorDeliveryRequest {\n actor: FabricActorInfo;\n message: FabricActorMessage;\n delivery: Exclude<FabricActorDelivery, \"mailbox\">;\n triggerTurn: boolean;\n}\n\n/**\n * A project-independent actor template stored in the global registry\n * (the user's agent dir, not a project mesh). It carries only the actor\n * definition (the same fields as FabricActorRequest) plus identity and\n * timestamps \u2014 never any history (messages, session transcript, or run logs).\n * Global actors are not live: they are stamped into a project via import,\n * which creates a fresh live actor with no inherited history.\n */\nexport interface GlobalActorDefinition extends FabricActorRequest {\n id: string;\n createdAt: number;\n updatedAt: number;\n // Redeclared required: the registry always materializes these (defaults\n // applied on create and load), so they are never undefined on a stored\n // template. Keeping them required avoids undefined creeping into merges and\n // spreads under exactOptionalPropertyTypes.\n events: FabricActorHostEvent[];\n topics: string[];\n delivery: FabricActorDelivery;\n responseMode: FabricActorResponseMode;\n triggerTurn: boolean;\n coalesce: boolean;\n residency?: FabricParticipantResidency;\n runner: FabricAgentRunner;\n}\n"],
|
|
5
|
+
"mappings": ";AAkBA,IAAM,gCAAgC,CAGpC,WACW;AAEN,IAAM,8BAA8B,8BAA8B;AAAA,EACvE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,CAAC;AAEM,IAAM,2BAA2B;AAAA,EACtC,GAAG;AAAA,EACH;AACF;AAIA,IAAM,8BAAmD,IAAI,IAAI,wBAAwB;AAElF,IAAM,yBAAyB,CAAC,UACrC,OAAO,UAAU,YAAY,4BAA4B,IAAI,KAAK;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -18,7 +18,7 @@ import {
|
|
|
18
18
|
import {
|
|
19
19
|
peerLabelPrefix,
|
|
20
20
|
writeHandoffSession
|
|
21
|
-
} from "./chunk-
|
|
21
|
+
} from "./chunk-OPEOIVF6.js";
|
|
22
22
|
import {
|
|
23
23
|
resolveAgentDir
|
|
24
24
|
} from "./chunk-PXAICAUT.js";
|
|
@@ -56,7 +56,7 @@ import {
|
|
|
56
56
|
} from "./chunk-AYBIR4YV.js";
|
|
57
57
|
import {
|
|
58
58
|
FABRIC_ACTOR_HOST_EVENTS
|
|
59
|
-
} from "./chunk-
|
|
59
|
+
} from "./chunk-R2V7X3QI.js";
|
|
60
60
|
import {
|
|
61
61
|
isFabricThinking
|
|
62
62
|
} from "./chunk-MGWQOKBV.js";
|
|
@@ -6962,4 +6962,4 @@ export {
|
|
|
6962
6962
|
agentParticipantRecords,
|
|
6963
6963
|
actorParticipantRecord
|
|
6964
6964
|
};
|
|
6965
|
-
//# sourceMappingURL=chunk-
|
|
6965
|
+
//# sourceMappingURL=chunk-U5PRQ6NL.js.map
|
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
} from "./chunk-AYBIR4YV.js";
|
|
4
4
|
import {
|
|
5
5
|
FABRIC_ACTOR_HOST_EVENTS
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-R2V7X3QI.js";
|
|
7
7
|
import {
|
|
8
8
|
aliasThinking
|
|
9
9
|
} from "./chunk-A4VP7HDF.js";
|
|
@@ -744,4 +744,4 @@ export {
|
|
|
744
744
|
AGENTS_ACTION_DESCRIPTORS,
|
|
745
745
|
normalizeAgentRunRequest
|
|
746
746
|
};
|
|
747
|
-
//# sourceMappingURL=chunk-
|
|
747
|
+
//# sourceMappingURL=chunk-Z7ZAT43C.js.map
|
|
@@ -33,7 +33,7 @@ import {
|
|
|
33
33
|
expandSkillDirMarkersForRead,
|
|
34
34
|
resolveFabricIdentity,
|
|
35
35
|
runFabricHandoffAtBoundary
|
|
36
|
-
} from "./chunks/chunk-
|
|
36
|
+
} from "./chunks/chunk-HYK47EXZ.js";
|
|
37
37
|
import {
|
|
38
38
|
AgentTranscriptReader,
|
|
39
39
|
MAX_WRITE_DIFF_BYTES,
|
|
@@ -67,7 +67,7 @@ import "./chunks/chunk-IGVDD2HT.js";
|
|
|
67
67
|
import {
|
|
68
68
|
AGENTS_ACTION_DESCRIPTORS,
|
|
69
69
|
normalizeAgentRunRequest
|
|
70
|
-
} from "./chunks/chunk-
|
|
70
|
+
} from "./chunks/chunk-Z7ZAT43C.js";
|
|
71
71
|
import {
|
|
72
72
|
actionArgNormalizer,
|
|
73
73
|
uniqueDeclaredKeyForSpelling
|
|
@@ -124,7 +124,7 @@ import {
|
|
|
124
124
|
resolveInheritedSessionPins,
|
|
125
125
|
resolvePiBinary,
|
|
126
126
|
withInheritedSessionPins
|
|
127
|
-
} from "./chunks/chunk-
|
|
127
|
+
} from "./chunks/chunk-U5PRQ6NL.js";
|
|
128
128
|
import {
|
|
129
129
|
executeFile,
|
|
130
130
|
processIsAlive,
|
|
@@ -142,7 +142,7 @@ import {
|
|
|
142
142
|
} from "./chunks/chunk-JNMTTJMQ.js";
|
|
143
143
|
import {
|
|
144
144
|
checkedHandoffCompaction
|
|
145
|
-
} from "./chunks/chunk-
|
|
145
|
+
} from "./chunks/chunk-OPEOIVF6.js";
|
|
146
146
|
import {
|
|
147
147
|
resolveAgentDir
|
|
148
148
|
} from "./chunks/chunk-PXAICAUT.js";
|
|
@@ -180,7 +180,7 @@ import {
|
|
|
180
180
|
import {
|
|
181
181
|
FABRIC_ACTOR_HOST_EVENTS,
|
|
182
182
|
isFabricActorHostEvent
|
|
183
|
-
} from "./chunks/chunk-
|
|
183
|
+
} from "./chunks/chunk-R2V7X3QI.js";
|
|
184
184
|
import {
|
|
185
185
|
FUZZY_RESOLUTION_MARKERS,
|
|
186
186
|
resolveAvailablePiModel,
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,YAAY,EAEb,MAAM,iCAAiC,CAAC;AA2JzC,eAAO,MAAM,2BAA2B,IAAI,CAAC;AAC7C,YAAY,EAAE,wBAAwB,EAAE,MAAM,mBAAmB,CAAC;AAClE,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,mBAAmB,CAAC;AAElE,wBAA8B,QAAQ,CAAC,EAAE,EAAE,YAAY,EAAE,OAAO,GAAE;IAAE,WAAW,CAAC,EAAE,wBAAwB,CAAA;CAAO,GAAG,OAAO,CAAC,IAAI,CAAC,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,YAAY,EAEb,MAAM,iCAAiC,CAAC;AA2JzC,eAAO,MAAM,2BAA2B,IAAI,CAAC;AAC7C,YAAY,EAAE,wBAAwB,EAAE,MAAM,mBAAmB,CAAC;AAClE,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,mBAAmB,CAAC;AAElE,wBAA8B,QAAQ,CAAC,EAAE,EAAE,YAAY,EAAE,OAAO,GAAE;IAAE,WAAW,CAAC,EAAE,wBAAwB,CAAA;CAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CAgwBhI;AAED,cAAc,kBAAkB,CAAC;AACjC,cAAc,oBAAoB,CAAC;AACnC,cAAc,eAAe,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -71,7 +71,7 @@ import {
|
|
|
71
71
|
restoreBorrowedInPlaceMain,
|
|
72
72
|
settleInPlacePrewalk,
|
|
73
73
|
withTrajectoryRearmDirective
|
|
74
|
-
} from "./chunks/chunk-
|
|
74
|
+
} from "./chunks/chunk-HYK47EXZ.js";
|
|
75
75
|
import {
|
|
76
76
|
AgentTranscriptReader,
|
|
77
77
|
countNewlines,
|
|
@@ -202,7 +202,7 @@ import {
|
|
|
202
202
|
import {
|
|
203
203
|
awaitPeerSettle,
|
|
204
204
|
buildPeerCards
|
|
205
|
-
} from "./chunks/chunk-
|
|
205
|
+
} from "./chunks/chunk-OPEOIVF6.js";
|
|
206
206
|
import {
|
|
207
207
|
resolveAgentDir
|
|
208
208
|
} from "./chunks/chunk-PXAICAUT.js";
|
|
@@ -234,7 +234,7 @@ import "./chunks/chunk-KAD7UWT2.js";
|
|
|
234
234
|
import "./chunks/chunk-ZDNGXLEC.js";
|
|
235
235
|
import {
|
|
236
236
|
FABRIC_ACTOR_PI_HOST_EVENTS
|
|
237
|
-
} from "./chunks/chunk-
|
|
237
|
+
} from "./chunks/chunk-R2V7X3QI.js";
|
|
238
238
|
import "./chunks/chunk-A4VP7HDF.js";
|
|
239
239
|
import "./chunks/chunk-MGWQOKBV.js";
|
|
240
240
|
import "./chunks/chunk-3H7SDWZI.js";
|
|
@@ -5830,8 +5830,8 @@ async function piFabric(pi, options = {}) {
|
|
|
5830
5830
|
message: {
|
|
5831
5831
|
...event.message,
|
|
5832
5832
|
content: [{ type: "text", text }],
|
|
5833
|
-
|
|
5834
|
-
|
|
5833
|
+
isError: !boundarySucceeded,
|
|
5834
|
+
...details === void 0 ? {} : { details }
|
|
5835
5835
|
}
|
|
5836
5836
|
};
|
|
5837
5837
|
});
|