@tangle-network/agent-runtime 0.323.0 → 0.324.0

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.
Files changed (85) hide show
  1. package/dist/{activation-D4hHi27J.d.ts → activation-CB2npL7F.d.ts} +2 -2
  2. package/dist/{activation-DpipXGti.js → activation-CmWGOW1x.js} +3 -3
  3. package/dist/{activation-DpipXGti.js.map → activation-CmWGOW1x.js.map} +1 -1
  4. package/dist/agent.d.ts +2 -2
  5. package/dist/agent.js +2 -2
  6. package/dist/{bundle-Cw-QdGmH.js → bundle-BJJmfEsw.js} +2 -2
  7. package/dist/{bundle-Cw-QdGmH.js.map → bundle-BJJmfEsw.js.map} +1 -1
  8. package/dist/candidate-execution/index.js +5 -5
  9. package/dist/{coordination-driver-COSL19sL.js → coordination-driver-CNEeqMoh.js} +31 -19
  10. package/dist/coordination-driver-CNEeqMoh.js.map +1 -0
  11. package/dist/{delegate-silSKPSB.js → delegate-C6oOTFB6.js} +2 -2
  12. package/dist/{delegate-silSKPSB.js.map → delegate-C6oOTFB6.js.map} +1 -1
  13. package/dist/{durable-file-DWQA4ooo.js → durable-file-B_eJr6Mb.js} +40 -8
  14. package/dist/durable-file-B_eJr6Mb.js.map +1 -0
  15. package/dist/durable.d.ts +1 -1
  16. package/dist/durable.js +12 -21
  17. package/dist/durable.js.map +1 -1
  18. package/dist/{graph-DbQ-BXKr.js → graph-BKmo7d42.js} +5 -5
  19. package/dist/{graph-DbQ-BXKr.js.map → graph-BKmo7d42.js.map} +1 -1
  20. package/dist/{graph-registry-BuJbzTzF.js → graph-registry-DAI6KNXB.js} +19 -34
  21. package/dist/graph-registry-DAI6KNXB.js.map +1 -0
  22. package/dist/{improvement-cycle-BeN9wahG.js → improvement-cycle-U74a-YKi.js} +10 -10
  23. package/dist/{improvement-cycle-BeN9wahG.js.map → improvement-cycle-U74a-YKi.js.map} +1 -1
  24. package/dist/index.d.ts +7 -7
  25. package/dist/index.js +18 -15
  26. package/dist/index.js.map +1 -1
  27. package/dist/intelligence.d.ts +3 -3
  28. package/dist/intelligence.js +7 -7
  29. package/dist/jsonl-file-DBv31uPi.js +206 -0
  30. package/dist/jsonl-file-DBv31uPi.js.map +1 -0
  31. package/dist/kernel.d.ts +2 -2
  32. package/dist/kernel.js +13 -13
  33. package/dist/{loop-runner-bin-DkhIbFBp.js → loop-runner-bin-BfcTX4-n.js} +3 -3
  34. package/dist/{loop-runner-bin-DkhIbFBp.js.map → loop-runner-bin-BfcTX4-n.js.map} +1 -1
  35. package/dist/{loop-runner-bin-Bsux_MGx.d.ts → loop-runner-bin-CkchKbaB.d.ts} +2 -2
  36. package/dist/loop-runner-bin.d.ts +1 -1
  37. package/dist/loop-runner-bin.js +1 -1
  38. package/dist/mcp/bin.js +3 -3
  39. package/dist/mcp/index.d.ts +3 -3
  40. package/dist/mcp/index.js +6 -6
  41. package/dist/{model-policy-CNe257pB.js → model-policy-CyCUwHed.js} +2 -2
  42. package/dist/model-policy-CyCUwHed.js.map +1 -0
  43. package/dist/{openai-tools-e02ABKl0.d.ts → openai-tools-BR3rRmmC.d.ts} +2 -2
  44. package/dist/{prepare-CFQLx9e3.js → prepare-DpavgJT8.js} +4 -4
  45. package/dist/{prepare-CFQLx9e3.js.map → prepare-DpavgJT8.js.map} +1 -1
  46. package/dist/{profile-BTbpdL9h.js → profile-ZS7_KLwK.js} +2 -2
  47. package/dist/{profile-BTbpdL9h.js.map → profile-ZS7_KLwK.js.map} +1 -1
  48. package/dist/profiles.d.ts +1 -1
  49. package/dist/profiles.js +1 -1
  50. package/dist/{protected-model-port-f1N2f0Uq.js → protected-model-port-BLyyfL3l.js} +4 -4
  51. package/dist/{protected-model-port-f1N2f0Uq.js.map → protected-model-port-BLyyfL3l.js.map} +1 -1
  52. package/dist/{protected-redaction-DylCC_ot.js → protected-redaction-DFCeo4vg.js} +2 -2
  53. package/dist/{protected-redaction-DylCC_ot.js.map → protected-redaction-DFCeo4vg.js.map} +1 -1
  54. package/dist/{provision-supervisor-DdWu6mqu.js → provision-supervisor-DhPJqazM.js} +7 -7
  55. package/dist/{provision-supervisor-DdWu6mqu.js.map → provision-supervisor-DhPJqazM.js.map} +1 -1
  56. package/dist/{run-layout-DSCWdbX2.js → run-layout-Cu8H7aeh.js} +2 -2
  57. package/dist/{run-layout-DSCWdbX2.js.map → run-layout-Cu8H7aeh.js.map} +1 -1
  58. package/dist/{runtime-DhPIc7XV.js → runtime-B9-ZiYFa.js} +84 -80
  59. package/dist/runtime-B9-ZiYFa.js.map +1 -0
  60. package/dist/{search-executor-BS-WJpti.js → search-executor-CtNb_lIB.js} +13 -5
  61. package/dist/search-executor-CtNb_lIB.js.map +1 -0
  62. package/dist/{server-CEDOUOdz.js → server-BLYiq6fK.js} +4 -4
  63. package/dist/{server-CEDOUOdz.js.map → server-BLYiq6fK.js.map} +1 -1
  64. package/dist/{supervise-CwWI7kIk.js → supervise-FOCAUADN.js} +8 -7
  65. package/dist/{supervise-CwWI7kIk.js.map → supervise-FOCAUADN.js.map} +1 -1
  66. package/dist/{supervisor-CSKkm-e1.js → supervisor-DnKhkhKc.js} +10908 -10772
  67. package/dist/supervisor-DnKhkhKc.js.map +1 -0
  68. package/dist/testing.d.ts +1 -1
  69. package/dist/testing.js +14 -14
  70. package/dist/{top-app-DaiR4LXM.js → top-app-BaMw1W2z.js} +2 -2
  71. package/dist/{top-app-DaiR4LXM.js.map → top-app-BaMw1W2z.js.map} +1 -1
  72. package/dist/tui/bin.js +1 -1
  73. package/dist/tui/index.d.ts +1 -1
  74. package/dist/tui/index.js +2 -2
  75. package/dist/{index-7h7-L6Tk.d.ts → types-ytkoP4VV.d.ts} +17362 -17273
  76. package/dist/{workspace-streams-DFAhW7hF.js → workspace-streams-CcoARX4v.js} +2 -2
  77. package/dist/{workspace-streams-DFAhW7hF.js.map → workspace-streams-CcoARX4v.js.map} +1 -1
  78. package/package.json +3 -3
  79. package/dist/coordination-driver-COSL19sL.js.map +0 -1
  80. package/dist/durable-file-DWQA4ooo.js.map +0 -1
  81. package/dist/graph-registry-BuJbzTzF.js.map +0 -1
  82. package/dist/model-policy-CNe257pB.js.map +0 -1
  83. package/dist/runtime-DhPIc7XV.js.map +0 -1
  84. package/dist/search-executor-BS-WJpti.js.map +0 -1
  85. package/dist/supervisor-CSKkm-e1.js.map +0 -1
@@ -1,5 +1,5 @@
1
1
  import { m as ValidationError } from "./errors-DodWX-cb.js";
2
- import { I as embeddedCandidateArtifact, L as immutableCandidateValue, M as canonicalCandidateBytes$1, N as canonicalCandidateDigest$1, P as canonicalCandidateDocument, R as omitTopLevelDigest, z as sha256Bytes$1 } from "./workspace-streams-DFAhW7hF.js";
2
+ import { I as embeddedCandidateArtifact, L as immutableCandidateValue, M as canonicalCandidateBytes$1, N as canonicalCandidateDigest$1, P as canonicalCandidateDocument, R as omitTopLevelDigest, z as sha256Bytes$1 } from "./workspace-streams-CcoARX4v.js";
3
3
  import { agentCandidateProfileActivationSchema, agentCandidateProfileSchema, agentProfileDiffSchema, agentProfileSchema, applyAgentProfileDiff } from "@tangle-network/agent-interface";
4
4
  import { posix } from "node:path";
5
5
  import { isMaterializerHarness, materializeCandidateProfile, resolvePiRuntimePaths } from "@tangle-network/agent-profile-materialize";
@@ -478,4 +478,4 @@ function unsupportedProfileField(path) {
478
478
  //#endregion
479
479
  export { assertCandidateProfileBinding as a, createAgentCandidateProfileActivation as c, omitUndefinedObjectFields as d, parseAgentCandidateProfileActivation as f, parseExactCandidateProfile as h, applyExactAgentProfileDiff as i, freezeGenericAgentCandidateProfile as l, parseExactAgentProfileDiff as m, PI_CANDIDATE_SESSION_DIR_ENV as n, assertCandidateProfileExecutionSupport as o, parseExactAgentProfile as p, agentCandidateProfileAsAgentProfile as r, candidateProfileAgentPaths as s, PI_CANDIDATE_AGENT_DIR_ENV as t, materializeAgentCandidateProfilePlan as u };
480
480
 
481
- //# sourceMappingURL=profile-BTbpdL9h.js.map
481
+ //# sourceMappingURL=profile-ZS7_KLwK.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"profile-BTbpdL9h.js","names":["publicValue","canonicalCandidateBytes","sha256Bytes","canonicalCandidateDigest"],"sources":["../src/candidate-execution/system-prompt.ts","../src/candidate-execution/profile.ts"],"sourcesContent":["import { posix } from 'node:path'\n\nimport type {\n AgentCandidateConfigValue,\n AgentCandidateLaunch,\n} from '@tangle-network/agent-interface'\nimport type {\n AgentCandidateWorkspacePlan,\n HarnessId,\n} from '@tangle-network/agent-profile-materialize'\n\nconst SYSTEM_PROMPT_FILE = '.tangle/system-prompt.md'\nconst APPEND_SYSTEM_PROMPT_FILE = '.tangle/append-system-prompt.md'\n\n/**\n * One row describes the native process control for each prompt intent this adapter owns.\n * A row with no executor projection means the shared materializer already lowered the intent into\n * the signed workspace plan; this adapter still proves that the launch reaches the native binary.\n */\ninterface HarnessSystemPrompt {\n /** The native binary the launch must run for this projection to be provable. */\n readonly executable: string\n /** Apply a replacement prompt to the harness's own control. */\n readonly project: (\n plan: AgentCandidateWorkspacePlan,\n systemPrompt: string,\n systemPromptFilePath: string,\n ) => AgentCandidateWorkspacePlan\n /** Apply an addition without replacing the harness's own prompt. */\n readonly projectAppend?: (\n plan: AgentCandidateWorkspacePlan,\n appendSystemPrompt: string,\n appendSystemPromptFilePath: string,\n ) => AgentCandidateWorkspacePlan\n /** The materializer already projected replacement text into native plan files and flags. */\n readonly retainsProjectedSystemPrompt?: boolean\n /** Does caller argv already set a replacement control this projection would shadow? */\n readonly conflictsWithArgs: (values: readonly string[]) => boolean\n /** Does caller argv already set an additive control this projection would shadow? */\n readonly conflictsWithAppendArgs: (values: readonly string[]) => boolean\n}\n\nconst SYSTEM_PROMPT_FLAGS = ['--system-prompt', '--system-prompt-file'] as const\nconst APPEND_SYSTEM_PROMPT_FLAGS = [\n '--append-system-prompt',\n '--append-system-prompt-file',\n] as const\n\nfunction argsSetSystemPromptFlag(values: readonly string[]): boolean {\n return values.some((value) =>\n SYSTEM_PROMPT_FLAGS.some((flag) => value === flag || value.startsWith(`${flag}=`)),\n )\n}\n\nfunction argsSetAppendSystemPromptFlag(values: readonly string[]): boolean {\n return values.some((value) =>\n APPEND_SYSTEM_PROMPT_FLAGS.some((flag) => value === flag || value.startsWith(`${flag}=`)),\n )\n}\n\n/** Codex keys that can replace or contaminate the materializer's sealed instructions file. */\nconst CODEX_INSTRUCTION_KEYS = ['model_instructions_file', 'developer_instructions'] as const\n\nfunction argsSetCodexInstructionOverride(values: readonly string[]): boolean {\n for (let index = 0; index < values.length; index++) {\n const value = values[index]!\n const config =\n value === '-c' || value === '--config'\n ? values[index + 1]\n : value.startsWith('--config=')\n ? value.slice('--config='.length)\n : undefined\n if (\n config !== undefined &&\n CODEX_INSTRUCTION_KEYS.some((key) => config.trimStart().startsWith(`${key}=`))\n ) {\n return true\n }\n }\n return false\n}\n\nconst HARNESS_SYSTEM_PROMPTS = {\n 'claude-code': {\n executable: 'claude',\n project: (plan, systemPrompt, path) =>\n appendFlags(\n addPromptFile(plan, SYSTEM_PROMPT_FILE, systemPrompt),\n '--system-prompt-file',\n path,\n ),\n projectAppend: (plan, appendSystemPrompt, path) =>\n appendFlags(\n addPromptFile(plan, APPEND_SYSTEM_PROMPT_FILE, appendSystemPrompt),\n '--append-system-prompt-file',\n path,\n ),\n conflictsWithArgs: argsSetSystemPromptFlag,\n conflictsWithAppendArgs: argsSetAppendSystemPromptFlag,\n },\n /** OpenCode's bound primary agent is already selected by the materializer's --agent flag. */\n opencode: {\n executable: 'opencode',\n project: (plan) => plan,\n retainsProjectedSystemPrompt: true,\n conflictsWithArgs: (values) =>\n values.some((value) => value === '--agent' || value.startsWith('--agent=')),\n conflictsWithAppendArgs: argsSetAppendSystemPromptFlag,\n },\n pi: {\n executable: 'pi',\n project: (plan, systemPrompt, path) =>\n appendFlags(addPromptFile(plan, SYSTEM_PROMPT_FILE, systemPrompt), '--system-prompt', path),\n projectAppend: (plan, appendSystemPrompt, path) =>\n appendFlags(\n addPromptFile(plan, APPEND_SYSTEM_PROMPT_FILE, appendSystemPrompt),\n '--append-system-prompt',\n path,\n ),\n conflictsWithArgs: argsSetSystemPromptFlag,\n conflictsWithAppendArgs: argsSetAppendSystemPromptFlag,\n },\n prime: {\n executable: 'prime-agent',\n project: (plan, systemPrompt, path) =>\n appendFlags(addPromptFile(plan, SYSTEM_PROMPT_FILE, systemPrompt), '--system-prompt', path),\n projectAppend: (plan, appendSystemPrompt, path) =>\n appendFlags(\n addPromptFile(plan, APPEND_SYSTEM_PROMPT_FILE, appendSystemPrompt),\n '--append-system-prompt',\n path,\n ),\n conflictsWithArgs: argsSetSystemPromptFlag,\n conflictsWithAppendArgs: argsSetAppendSystemPromptFlag,\n },\n /** Gemini's file and env lowering is materializer-owned; this row supplies the launch proof. */\n gemini: {\n executable: 'gemini',\n project: (plan) => plan,\n conflictsWithArgs: argsSetSystemPromptFlag,\n conflictsWithAppendArgs: argsSetAppendSystemPromptFlag,\n },\n} as const satisfies Partial<Record<HarnessId, HarnessSystemPrompt>>\n\ninterface MaterializedPromptDelivery {\n readonly executable: string\n readonly delivered: (plan: AgentCandidateWorkspacePlan) => boolean\n readonly conflictsWithArgs: (values: readonly string[]) => boolean\n}\n\n/**\n * These controls are lowered by agent-profile-materialize into files plus launch inputs. The\n * candidate adapter does not own the spawn, so it must reject an arbitrary entrypoint even when\n * the plan has the right bytes: only the native binary can make those inputs effective.\n */\nconst MATERIALIZED_PROMPT_DELIVERIES = {\n codex: {\n executable: 'codex',\n delivered: (plan) =>\n plan.files.some((file) => file.relPath === '.codex/system-prompt.md') &&\n plan.flags.some((flag) => flag.value === 'model_instructions_file=.codex/system-prompt.md'),\n conflictsWithArgs: argsSetCodexInstructionOverride,\n },\n gemini: {\n executable: 'gemini',\n delivered: (plan) =>\n plan.files.some((file) => file.relPath === '.gemini/system.md') &&\n plan.env.GEMINI_SYSTEM_MD?.value === '1',\n conflictsWithArgs: argsSetSystemPromptFlag,\n },\n} as const satisfies Partial<Record<HarnessId, MaterializedPromptDelivery>>\n\n/** Project both prompt intents onto their distinct native process controls. */\nexport function projectCandidatePromptIntents(\n plan: AgentCandidateWorkspacePlan,\n launch: AgentCandidateLaunch,\n systemPromptFilePath: string,\n requestedSystemPrompt: string | undefined = plan.systemPrompt?.value,\n requestedAppendSystemPrompt: string | undefined = plan.appendSystemPrompt?.value,\n): AgentCandidateWorkspacePlan {\n const systemPrompt = plan.systemPrompt\n const appendSystemPrompt = plan.appendSystemPrompt\n const delivery = MATERIALIZED_PROMPT_DELIVERIES[\n plan.harness as keyof typeof MATERIALIZED_PROMPT_DELIVERIES\n ] as MaterializedPromptDelivery | undefined\n\n if (systemPrompt === undefined && delivery?.delivered(plan)) {\n assertProvableNativeLaunch(plan.harness, delivery.executable, launch, 'replacement')\n assertNoShadowingArgs(plan.harness, delivery.conflictsWithArgs, launch, 'replacement')\n if (requestedSystemPrompt === undefined) return plan\n return plan\n }\n\n if (requestedSystemPrompt === undefined && requestedAppendSystemPrompt === undefined) {\n return plan\n }\n\n const projection = HARNESS_SYSTEM_PROMPTS[plan.harness as keyof typeof HARNESS_SYSTEM_PROMPTS] as\n | HarnessSystemPrompt\n | undefined\n if (!projection) {\n throw new Error(`candidate system prompt has no native launch projection for ${plan.harness}`)\n }\n\n const requestedReplacement = requestedSystemPrompt !== undefined\n if (requestedReplacement && systemPrompt === undefined) {\n throw new Error(\n `profile materializer did not deliver the candidate system prompt for ${plan.harness}`,\n )\n }\n if (systemPrompt !== undefined && requestedSystemPrompt === undefined) {\n throw new Error(\n `profile materializer added an unexpected candidate system prompt for ${plan.harness}`,\n )\n }\n if (systemPrompt !== undefined && systemPrompt.value !== requestedSystemPrompt) {\n throw new Error('profile materializer changed the candidate system prompt')\n }\n if (\n appendSystemPrompt !== undefined &&\n appendSystemPrompt.value !== requestedAppendSystemPrompt\n ) {\n throw new Error('profile materializer changed the candidate append system prompt')\n }\n\n const intent = requestedReplacement ? 'replacement' : 'addition'\n assertProvableNativeLaunch(plan.harness, projection.executable, launch, intent)\n const launchArgs = (launch.args ?? []).map((value) => value.value)\n if (requestedReplacement && projection.conflictsWithArgs(launchArgs)) {\n throw new Error(\n `${plan.harness} launch arguments conflict with the candidate profile system prompt`,\n )\n }\n if (requestedAppendSystemPrompt !== undefined && projection.conflictsWithAppendArgs(launchArgs)) {\n throw new Error(\n `${plan.harness} launch arguments conflict with the candidate profile append system prompt`,\n )\n }\n\n let projected = plan\n if (systemPrompt !== undefined) {\n projected = projection.project(\n projection.retainsProjectedSystemPrompt\n ? projected\n : omitPromptIntent(projected, 'systemPrompt'),\n systemPrompt.value,\n systemPromptFilePath,\n )\n }\n if (appendSystemPrompt !== undefined) {\n if (!projection.projectAppend) {\n throw new Error(\n `candidate append system prompt has no native launch projection for ${plan.harness}`,\n )\n }\n projected = projection.projectAppend(\n omitPromptIntent(projected, 'appendSystemPrompt'),\n appendSystemPrompt.value,\n posix.join(posix.dirname(systemPromptFilePath), 'append-system-prompt.md'),\n )\n }\n // The source-profile digest binds authored values. Remove executor handoff fields only after\n // converting them into native controls; materializer-owned controls remain visible in the plan.\n return projected\n}\n\nfunction assertProvableNativeLaunch(\n harness: string,\n expectedExecutable: string,\n launch: AgentCandidateLaunch,\n intent: 'replacement' | 'addition',\n): asserts launch is AgentCandidateLaunch & { kind: 'container-command' } {\n if (launch.kind !== 'container-command') {\n throw new Error(`candidate-entrypoint launch cannot prove ${harness} system-prompt ${intent}`)\n }\n if (\n launch.executable !== expectedExecutable &&\n !(\n posix.isAbsolute(launch.executable) &&\n posix.basename(launch.executable) === expectedExecutable\n )\n ) {\n throw new Error(\n `${harness} system-prompt ${intent} requires the native ${expectedExecutable} executable`,\n )\n }\n}\n\nfunction assertNoShadowingArgs(\n harness: string,\n conflictsWithArgs: (values: readonly string[]) => boolean,\n launch: Extract<AgentCandidateLaunch, { kind: 'container-command' }>,\n intent: 'replacement' | 'addition',\n): void {\n if (conflictsWithArgs((launch.args ?? []).map((value) => value.value))) {\n throw new Error(\n `${harness} launch arguments conflict with the candidate profile ${intent === 'replacement' ? 'system' : 'append system'} prompt`,\n )\n }\n}\n\nfunction omitPromptIntent(\n plan: AgentCandidateWorkspacePlan,\n intent: 'systemPrompt' | 'appendSystemPrompt',\n): AgentCandidateWorkspacePlan {\n const projected = { ...plan }\n delete projected[intent]\n return projected\n}\n\nfunction appendFlags(\n plan: AgentCandidateWorkspacePlan,\n ...values: string[]\n): AgentCandidateWorkspacePlan {\n return {\n ...plan,\n flags: [...plan.flags, ...values.map(publicValue)],\n }\n}\n\nfunction publicValue(value: string): AgentCandidateConfigValue {\n return { kind: 'public', value }\n}\n\nfunction addPromptFile(\n plan: AgentCandidateWorkspacePlan,\n relPath: string,\n prompt: string,\n): AgentCandidateWorkspacePlan {\n // Candidate argv rejects control characters. Native prompt-file loading preserves multiline\n // bytes without weakening the shared process schema.\n if (plan.files.some((file) => file.relPath === relPath)) {\n throw new Error(`candidate profile conflicts with reserved ${relPath}`)\n }\n return {\n ...plan,\n files: [\n ...plan.files,\n {\n relPath,\n content: prompt,\n source: 'generated',\n },\n ],\n }\n}\n","import { posix } from 'node:path'\n\nimport type {\n AgentCandidateConfigValue,\n AgentCandidateLaunch,\n AgentCandidateProfile,\n AgentCandidateProfileActivation,\n AgentCandidateProfilePlanEvidence,\n AgentCandidateResourceRef,\n AgentProfile,\n AgentProfileConfigValue,\n AgentProfileDiff,\n AgentProfileMcpServer,\n AgentProfileResourceRef,\n HarnessType,\n Sha256Digest,\n} from '@tangle-network/agent-interface'\nimport {\n agentCandidateProfileActivationSchema,\n agentCandidateProfileSchema,\n agentProfileDiffSchema,\n agentProfileSchema,\n applyAgentProfileDiff,\n} from '@tangle-network/agent-interface'\nimport type {\n AgentCandidateWorkspacePlan,\n HarnessId,\n} from '@tangle-network/agent-profile-materialize'\nimport {\n isMaterializerHarness,\n materializeCandidateProfile,\n resolvePiRuntimePaths,\n} from '@tangle-network/agent-profile-materialize'\n\nimport { ValidationError } from '../errors'\nimport {\n canonicalCandidateBytes,\n canonicalCandidateDigest,\n canonicalCandidateDocument,\n embeddedCandidateArtifact,\n immutableCandidateValue,\n omitTopLevelDigest,\n sha256Bytes,\n} from './digest'\nimport { projectCandidatePromptIntents } from './system-prompt'\n\nexport function candidateMaterializerHarness(harness: HarnessType): HarnessId {\n if (!isMaterializerHarness(harness)) {\n throw new Error(\n `sealed candidate profile materialization is unsupported for harness ${harness}`,\n )\n }\n return harness\n}\n\n/** Runtime applies the materializer's launch flags to the candidate process. */\nexport const CANDIDATE_PROFILE_MATERIALIZER_BINDS = ['systemPrompt'] as const\nexport const PI_CANDIDATE_AGENT_DIR_ENV = 'PI_CODING_AGENT_DIR'\nexport const PI_CANDIDATE_SESSION_DIR_ENV = 'PI_CODING_AGENT_SESSION_DIR'\n\ninterface MaterializeAgentCandidateProfilePlanOptions {\n profile: AgentCandidateProfile\n harness: HarnessType\n launch: AgentCandidateLaunch\n workspace: 'task' | 'candidate'\n workspaces: {\n taskRoot: string\n candidateRoot?: string\n }\n resolvedResources?: ReadonlyMap<Sha256Digest, string>\n}\n\n/** Derive the exact native profile plan used by preparation and later evidence checks. */\nexport function materializeAgentCandidateProfilePlan(\n options: MaterializeAgentCandidateProfilePlanOptions,\n): AgentCandidateWorkspacePlan {\n const root =\n options.workspace === 'task' ? options.workspaces.taskRoot : options.workspaces.candidateRoot\n if (!root) throw new Error('candidate profile target is missing its execution workspace root')\n const plan = materializeCandidateProfile(\n options.profile,\n candidateMaterializerHarness(options.harness),\n {\n binds: CANDIDATE_PROFILE_MATERIALIZER_BINDS,\n resolvedResources: options.resolvedResources,\n },\n )\n return projectCandidatePromptIntents(\n plan,\n options.launch,\n posix.join(root, '.tangle/system-prompt.md'),\n options.profile.prompt?.systemPrompt,\n options.profile.prompt?.appendSystemPrompt,\n )\n}\n\n/** Resolve the private Pi roots needed by an agent-root profile plan. */\nexport function candidateProfileAgentPaths(\n plan: {\n harness: HarnessType\n files: ReadonlyArray<{ root?: 'agent' | 'workspace' }>\n },\n runtimeHome: string | undefined,\n): { agentDir: string; sessionDir: string } | undefined {\n if (!plan.files.some((file) => file.root === 'agent')) return undefined\n if (plan.harness !== 'pi') {\n throw new Error(`candidate profile agent-root files are unsupported for ${plan.harness}`)\n }\n if (runtimeHome === undefined) {\n throw new Error('candidate profile agent-root files require executionRoots.profileRoot')\n }\n return resolvePiRuntimePaths(runtimeHome)\n}\n\n/** Bind exact native profile text to the canonical plan captured during preparation. */\nexport function createAgentCandidateProfileActivation(\n plan: AgentCandidateWorkspacePlan,\n profilePlan: AgentCandidateProfilePlanEvidence,\n): AgentCandidateProfileActivation {\n const sourceByIdentity = new Map(\n plan.files.map((file) => [profileFileIdentity(file.root, file.relPath), file]),\n )\n if (sourceByIdentity.size !== plan.files.length) {\n throw new Error('candidate profile activation contains duplicate rooted native file paths')\n }\n const files = profilePlan.material.files.map((expected) => {\n const source = sourceByIdentity.get(profileFileIdentity(expected.root, expected.relPath))\n if (!source) {\n throw new Error(\n `candidate profile activation is missing ${profileFileLabel(expected.root, expected.relPath)}`,\n )\n }\n const mode = source.mode ?? 0o644\n if (!Number.isSafeInteger(mode) || mode < 0 || mode > 0o777) {\n throw new Error(\n `candidate profile activation has invalid mode for ${profileFileLabel(expected.root, expected.relPath)}`,\n )\n }\n return { path: expected.relPath, mode, content: source.content }\n })\n if (files.length !== plan.files.length) {\n throw new Error('candidate profile activation contains unplanned native files')\n }\n return parseAgentCandidateProfileActivation(\n canonicalCandidateDocument<AgentCandidateProfileActivation>({\n kind: 'agent-candidate-profile-activation',\n profilePlan,\n files,\n }).value,\n profilePlan.digest,\n )\n}\n\nfunction profileFileIdentity(root: 'agent' | 'workspace' | undefined, relPath: string): string {\n return `${root ?? 'workspace'}\\0${relPath}`\n}\n\nfunction profileFileLabel(root: 'agent' | 'workspace' | undefined, relPath: string): string {\n return root === 'agent' ? `agent:${relPath}` : relPath\n}\n\n/** Parse and check every native file hash plus both canonical document digests. */\nexport function parseAgentCandidateProfileActivation(\n input: unknown,\n expectedProfilePlanDigest?: AgentCandidateProfilePlanEvidence['digest'],\n): AgentCandidateProfileActivation {\n const activation = agentCandidateProfileActivationSchema.parse(input)\n const planBytes = canonicalCandidateBytes(activation.profilePlan.material)\n const profilePlanArtifact = activation.profilePlan.artifact\n if (\n sha256Bytes(planBytes) !== activation.profilePlan.digest ||\n profilePlanArtifact.sha256 !== activation.profilePlan.digest ||\n profilePlanArtifact.byteLength !== planBytes.byteLength ||\n ('content' in profilePlanArtifact &&\n !Buffer.from(profilePlanArtifact.content, 'base64').equals(Buffer.from(planBytes))) ||\n (expectedProfilePlanDigest !== undefined &&\n activation.profilePlan.digest !== expectedProfilePlanDigest)\n ) {\n throw new Error('candidate profile activation has an invalid canonical profile plan')\n }\n if (canonicalCandidateDigest(omitTopLevelDigest(activation)) !== activation.digest) {\n throw new Error('candidate profile activation digest does not match')\n }\n return immutableCandidateValue(activation)\n}\n\nconst CANDIDATE_PROFILE_DIRECT_FIELDS = [\n 'name',\n 'description',\n 'version',\n 'tags',\n 'prompt',\n 'harness',\n 'permissions',\n 'tools',\n 'confidential',\n] as const\n\n/** Convert only behavior-preserving generic profile fields into the closed candidate contract. */\nexport function freezeGenericAgentCandidateProfile(input: AgentProfile): AgentCandidateProfile {\n refuseFieldsSandboxCannotCarry(input)\n const profile = parseExactAgentProfile(input, 'profile')\n return candidateProfileFromGenericProfile(profile)\n}\n\n/**\n * Keep every generic-profile-to-candidate conversion in one place.\n * Callers use this both when sealing a new bundle and when proving a measured\n * profile is exactly the profile in an existing candidate.\n */\nfunction candidateProfileFromGenericProfile(profile: AgentProfile): AgentCandidateProfile {\n assertResolvedKnowledgeResources(profile.resources)\n if (profile.connections !== undefined) unsupportedProfileField('connections')\n if (profile.metadata !== undefined) unsupportedProfileField('metadata')\n if (profile.extensions !== undefined) unsupportedProfileField('extensions')\n if (profile.model?.metadata !== undefined) unsupportedProfileField('model.metadata')\n\n const candidate: Record<string, unknown> = {}\n copyDirectProfileFields(candidate, profile as Record<string, unknown>)\n if (profile.model) {\n const { metadata: _metadata, ...model } = profile.model\n candidate.model = model\n }\n if (profile.mcp) candidate.mcp = freezeMcpServers(profile.mcp)\n if (profile.subagents) {\n candidate.subagents = Object.fromEntries(\n Object.entries(profile.subagents).map(([name, subagent]) => {\n if (subagent.metadata !== undefined) unsupportedProfileField(`subagents.${name}.metadata`)\n const { metadata: _metadata, ...value } = subagent\n return [name, value]\n }),\n )\n }\n if (profile.resources) candidate.resources = freezeResources(profile.resources)\n if (profile.hooks && Object.values(profile.hooks).some((commands) => commands.length > 0)) {\n throw new Error(\n 'generic AgentProfile hooks cannot be safely tokenized; use a candidate-profile source with executable/args',\n )\n }\n if (profile.hooks) candidate.hooks = profile.hooks\n if (profile.modes) {\n candidate.modes = Object.fromEntries(\n Object.entries(profile.modes).map(([name, mode]) => {\n if (mode.metadata !== undefined) unsupportedProfileField(`modes.${name}.metadata`)\n const { metadata: _metadata, ...value } = mode\n return [name, value]\n }),\n )\n }\n const parsed = parseExactCandidateProfile(candidate)\n return parsed\n}\n\n/** Prove the measured generic profile and sealed candidate profile describe the same behavior. */\nexport function assertCandidateProfileBinding(\n measuredInput: unknown,\n bundled: AgentCandidateProfile,\n): void {\n refuseFieldsSandboxCannotCarry(measuredInput)\n const measured = parseExactAgentProfile(measuredInput, 'measured agent profile')\n const expected = candidateProfileFromGenericProfile(measured)\n if (canonicalCandidateDigest(expected) !== canonicalCandidateDigest(bundled)) {\n throw new Error('measured agent profile does not match sealed candidate profile')\n }\n}\n\n/** Parse a complete profile without silently discarding unsupported fields. */\nexport function parseExactAgentProfile(input: unknown, label: string): AgentProfile {\n let parsed: AgentProfile\n try {\n parsed = agentProfileSchema.parse(input) as AgentProfile\n } catch (cause) {\n throw new Error(`${label} contains unsupported or non-canonical fields`, { cause })\n }\n assertCanonicalParse(input, parsed, label)\n return parsed\n}\n\n/** Parse a profile diff without silently discarding unsupported fields. */\nexport function parseExactAgentProfileDiff(input: unknown, label: string): AgentProfileDiff {\n let parsed: AgentProfileDiff\n try {\n parsed = agentProfileDiffSchema.parse(input) as AgentProfileDiff\n } catch (cause) {\n throw new Error(`${label} contains unsupported or non-canonical fields`, { cause })\n }\n assertCanonicalParse(input, parsed, label)\n return parsed\n}\n\n/** Apply one exact diff and reject any value that cannot be preserved canonically. */\nexport function applyExactAgentProfileDiff(\n baseInput: unknown,\n diffInput: unknown,\n label: string,\n): AgentProfile {\n const base = parseExactAgentProfile(baseInput, `${label} base profile`)\n const diff = parseExactAgentProfileDiff(diffInput, `${label} diff`)\n const applied = omitUndefinedObjectFields(applyAgentProfileDiff(base, diff), label)\n return parseExactAgentProfile(applied, `${label} result`)\n}\n\n/** Parse a candidate profile without silently discarding unsupported or non-canonical fields. */\nexport function parseExactCandidateProfile(input: unknown): AgentCandidateProfile {\n const parsed = agentCandidateProfileSchema.parse(input)\n assertCanonicalParse(input, parsed, 'candidate profile')\n return parsed\n}\n\n/** Reject profile fields whose behavioral effect is not yet proven by candidate executors. */\nexport function assertCandidateProfileExecutionSupport(profile: AgentCandidateProfile): void {\n assertResolvedKnowledgeResources(profile.resources)\n refuseFieldsSandboxCannotCarry(profile)\n const fields = ['tools', 'permissions', 'modes', 'confidential'] as const\n const unsupported = fields.filter((field) => hasEntries(profile[field]))\n if (unsupported.length > 0) {\n throw new Error(\n `candidate execution cannot prove in-session effects for non-empty AgentProfile fields: ${unsupported.join(', ')}`,\n )\n }\n}\n\n/** Convert the candidate profile contract into the portable interface profile it represents. */\nexport function agentCandidateProfileAsAgentProfile(\n candidate: AgentCandidateProfile,\n): AgentProfile {\n assertResolvedKnowledgeResources(candidate.resources)\n refuseFieldsSandboxCannotCarry(candidate)\n const output: Record<string, unknown> = {}\n copyDirectProfileFields(output, candidate as unknown as Record<string, unknown>)\n if (candidate.model) output.model = { ...candidate.model }\n if (candidate.mcp) {\n output.mcp = Object.fromEntries(\n Object.entries(candidate.mcp).map(([name, server]) => [\n name,\n {\n ...server,\n // Candidate config values ({kind:'public', value}) are already valid\n // AgentProfileConfigValue entries under interface >=0.40 — clone them\n // rather than unwrapping to plain strings, which the 0.40 profile\n // schema rejects.\n ...(server.args ? { args: server.args.map((value) => ({ ...value })) } : {}),\n ...(server.env ? { env: cloneRecord(server.env) } : {}),\n },\n ]),\n )\n }\n if (candidate.subagents) output.subagents = cloneRecord(candidate.subagents)\n if (candidate.modes) output.modes = cloneRecord(candidate.modes)\n if (candidate.hooks) {\n output.hooks = Object.fromEntries(\n Object.entries(candidate.hooks).map(([event, hooks]) => [\n event,\n hooks.map(({ executable, args, env, ...hook }) => ({\n ...hook,\n command: [executable, ...(args ?? []).map(publicValue)].map(shellQuote).join(' '),\n // Hook env stays in config-value form: the 0.40 profile hook contract\n // types env as Record<string, AgentProfileConfigValue>.\n ...(env ? { env: cloneRecord(env) } : {}),\n })),\n ]),\n )\n }\n if (candidate.resources) {\n if (candidate.resources.failOnError !== true) {\n throw new Error('sealed candidate profile contains fields unsupported by generic profiles')\n }\n output.resources = {\n failOnError: true,\n ...(candidate.resources.files\n ? {\n files: candidate.resources.files.map((file) => ({\n ...file,\n resource: publicResource(file.resource),\n })),\n }\n : {}),\n ...(candidate.resources.tools\n ? { tools: candidate.resources.tools.map(publicResource) }\n : {}),\n ...(candidate.resources.skills\n ? { skills: candidate.resources.skills.map(publicResource) }\n : {}),\n ...(candidate.resources.agents\n ? { agents: candidate.resources.agents.map(publicResource) }\n : {}),\n ...(candidate.resources.commands\n ? { commands: candidate.resources.commands.map(publicResource) }\n : {}),\n ...(candidate.resources.instructions !== undefined\n ? {\n instructions:\n typeof candidate.resources.instructions === 'string'\n ? candidate.resources.instructions\n : publicResource(candidate.resources.instructions),\n }\n : {}),\n }\n }\n return output as AgentProfile\n}\n\n/** Recursively remove undefined object fields while refusing undefined array entries. */\nexport function omitUndefinedObjectFields(value: unknown, path: string): unknown {\n if (Array.isArray(value)) {\n return value.map((entry, index) => {\n if (entry === undefined) {\n throw new Error(`${path} produced an undefined array entry at ${index}`)\n }\n return omitUndefinedObjectFields(entry, `${path}[${index}]`)\n })\n }\n if (value === null || typeof value !== 'object') return value\n return Object.fromEntries(\n Object.entries(value as Record<string, unknown>)\n .filter(([, entry]) => entry !== undefined)\n .map(([key, entry]) => [key, omitUndefinedObjectFields(entry, `${path}.${key}`)]),\n )\n}\n\nfunction freezeMcpServers(servers: Record<string, AgentProfileMcpServer>): Record<string, unknown> {\n return Object.fromEntries(\n Object.entries(servers).map(([name, server]) => {\n if (server.transport !== undefined && server.transport !== 'stdio') {\n unsupportedProfileField(`mcp.${name}.transport=${server.transport}`)\n }\n if (server.url !== undefined) unsupportedProfileField(`mcp.${name}.url`)\n if (server.headers !== undefined) unsupportedProfileField(`mcp.${name}.headers`)\n if (server.metadata !== undefined) unsupportedProfileField(`mcp.${name}.metadata`)\n return [\n name,\n {\n ...(server.transport ? { transport: server.transport } : {}),\n ...(server.command ? { command: server.command } : {}),\n ...(server.args\n ? {\n args: server.args.map((value, index) =>\n candidatePublicValue(value, `mcp.${name}.args[${index}]`),\n ),\n }\n : {}),\n ...(server.env ? { env: mapCandidatePublicValues(server.env, `mcp.${name}.env`) } : {}),\n ...(server.cwd ? { cwd: server.cwd } : {}),\n ...(server.enabled === undefined ? {} : { enabled: server.enabled }),\n },\n ]\n }),\n )\n}\n\n/** A newer peer may admit knowledge pins that these candidate conversions cannot preserve. */\nfunction assertResolvedKnowledgeResources(resources: unknown): void {\n if (\n resources !== null &&\n typeof resources === 'object' &&\n 'knowledge' in resources &&\n resources.knowledge !== undefined\n ) {\n throw new Error(\n 'candidate profile resources.knowledge must be owner-authorized and resolved before candidate conversion or execution',\n )\n }\n}\n\n/**\n * Interface 5.3 admits profile `proxySecrets` and candidate secret-ref config values, but\n * Sandbox still ships its own Interface 4.0.0, which carries neither. Refuse them by name\n * rather than drop them; remove this once Sandbox adopts Interface 5.3.\n */\nfunction refuseFieldsSandboxCannotCarry(profile: unknown): void {\n if (!isRecord(profile)) return\n if (profile.proxySecrets !== undefined) refuseFieldSandboxCannotCarry('proxySecrets')\n if (isRecord(profile.mcp)) {\n for (const [name, server] of Object.entries(profile.mcp)) {\n if (!isRecord(server)) continue\n refuseNonPublicConfigValues(server.args, `mcp.${name}.args`)\n refuseNonPublicConfigValues(server.env, `mcp.${name}.env`)\n }\n }\n if (isRecord(profile.hooks)) {\n for (const [event, hooks] of Object.entries(profile.hooks)) {\n if (!Array.isArray(hooks)) continue\n for (const [index, hook] of hooks.entries()) {\n if (!isRecord(hook)) continue\n refuseNonPublicConfigValues(hook.args, `hooks.${event}[${index}].args`)\n refuseNonPublicConfigValues(hook.env, `hooks.${event}[${index}].env`)\n }\n }\n }\n}\n\nfunction refuseNonPublicConfigValues(values: unknown, path: string): void {\n const entries = Array.isArray(values)\n ? values.map((value, index) => [`${path}[${index}]`, value] as const)\n : isRecord(values)\n ? Object.entries(values).map(([name, value]) => [`${path}.${name}`, value] as const)\n : []\n for (const [field, value] of entries) {\n if (isRecord(value) && value.kind !== 'public') {\n refuseFieldSandboxCannotCarry(`${field} (${String(value.kind)})`)\n }\n }\n}\n\nfunction refuseFieldSandboxCannotCarry(field: string): never {\n throw new ValidationError(\n `candidate profile field ${field} is refused: Sandbox's Interface 4.0.0 cannot carry it yet, and Runtime does not drop it`,\n )\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return value !== null && typeof value === 'object' && !Array.isArray(value)\n}\n\nfunction freezeResources(resources: NonNullable<AgentProfile['resources']>): unknown {\n if (resources.failOnError !== true) {\n throw new Error('candidate profile resources require failOnError: true')\n }\n return {\n failOnError: true,\n ...(resources.files\n ? {\n files: resources.files.map((file) => ({\n ...file,\n resource: freezeResource(file.resource),\n })),\n }\n : {}),\n ...(resources.tools ? { tools: resources.tools.map(freezeResource) } : {}),\n ...(resources.skills ? { skills: resources.skills.map(freezeResource) } : {}),\n ...(resources.agents ? { agents: resources.agents.map(freezeResource) } : {}),\n ...(resources.commands ? { commands: resources.commands.map(freezeResource) } : {}),\n ...(resources.instructions === undefined\n ? {}\n : {\n instructions:\n typeof resources.instructions === 'string'\n ? resources.instructions\n : freezeResource(resources.instructions),\n }),\n }\n}\n\nfunction freezeResource(resource: AgentProfileResourceRef): AgentCandidateResourceRef {\n if (resource.kind === 'github') {\n throw new Error(\n 'generic GitHub profile resources do not carry byte identity; use a candidate-profile source with a pinned commit, digest, and byte length',\n )\n }\n const bytes = Buffer.from(resource.content, 'utf8')\n return {\n ...resource,\n sha256: embeddedCandidateArtifact(bytes).sha256,\n byteLength: bytes.byteLength,\n }\n}\n\nfunction copyDirectProfileFields(\n target: Record<string, unknown>,\n source: Record<string, unknown>,\n): void {\n for (const key of CANDIDATE_PROFILE_DIRECT_FIELDS) {\n if (source[key] !== undefined) target[key] = source[key]\n }\n}\n\nfunction assertCanonicalParse(input: unknown, parsed: unknown, label: string): void {\n if (!Buffer.from(canonicalCandidateBytes(input)).equals(canonicalCandidateBytes(parsed))) {\n throw new Error(`${label} contains unsupported or non-canonical fields`)\n }\n}\n\nfunction publicResource(resource: AgentCandidateResourceRef): unknown {\n if (resource.kind === 'inline') {\n return { kind: 'inline', name: resource.name, content: resource.content }\n }\n return {\n kind: 'github',\n repository: `${resource.repository.owner}/${resource.repository.repo}`,\n path: resource.path,\n ref: resource.commit,\n ...(resource.name ? { name: resource.name } : {}),\n }\n}\n\n/** Freeze one profile config value into the candidate's PUBLIC-only config\n * shape. A secret-ref is refused, never silently dropped or unwrapped. */\nfunction candidatePublicValue(\n value: AgentProfileConfigValue,\n path: string,\n): { kind: 'public'; value: string } {\n if (value.kind !== 'public') refuseFieldSandboxCannotCarry(`${path} (${value.kind})`)\n return { kind: 'public', value: value.value }\n}\n\nfunction mapCandidatePublicValues(\n values: Record<string, AgentProfileConfigValue>,\n pathPrefix: string,\n): Record<string, { kind: 'public'; value: string }> {\n return Object.fromEntries(\n Object.entries(values).map(([name, value]) => [\n name,\n candidatePublicValue(value, `${pathPrefix}.${name}`),\n ]),\n )\n}\n\nfunction publicValue(value: AgentCandidateConfigValue): string {\n return value.value\n}\n\nfunction cloneRecord<T>(values: Record<string, T>): Record<string, T> {\n return Object.fromEntries(\n Object.entries(values).map(([key, value]) => [key, { ...value }]),\n ) as Record<string, T>\n}\n\nfunction hasEntries(value: unknown): boolean {\n return value !== undefined && value !== null && typeof value === 'object'\n ? Object.keys(value).length > 0\n : false\n}\n\nfunction shellQuote(value: string): string {\n return /^[A-Za-z0-9_./:@%+=,-]+$/.test(value) ? value : `'${value.replaceAll(\"'\", `'\"'\"'`)}'`\n}\n\nfunction unsupportedProfileField(path: string): never {\n throw new Error(\n `generic AgentProfile field ${path} is not representable in a sealed candidate profile`,\n )\n}\n"],"mappings":";;;;;;AAWA,MAAM,qBAAqB;AAC3B,MAAM,4BAA4B;AA8BlC,MAAM,sBAAsB,CAAC,mBAAmB,sBAAsB;AACtE,MAAM,6BAA6B,CACjC,0BACA,6BACF;AAEA,SAAS,wBAAwB,QAAoC;CACnE,OAAO,OAAO,MAAM,UAClB,oBAAoB,MAAM,SAAS,UAAU,QAAQ,MAAM,WAAW,GAAG,KAAK,EAAE,CAAC,CACnF;AACF;AAEA,SAAS,8BAA8B,QAAoC;CACzE,OAAO,OAAO,MAAM,UAClB,2BAA2B,MAAM,SAAS,UAAU,QAAQ,MAAM,WAAW,GAAG,KAAK,EAAE,CAAC,CAC1F;AACF;;AAGA,MAAM,yBAAyB,CAAC,2BAA2B,wBAAwB;AAEnF,SAAS,gCAAgC,QAAoC;CAC3E,KAAK,IAAI,QAAQ,GAAG,QAAQ,OAAO,QAAQ,SAAS;EAClD,MAAM,QAAQ,OAAO;EACrB,MAAM,SACJ,UAAU,QAAQ,UAAU,aACxB,OAAO,QAAQ,KACf,MAAM,WAAW,WAAW,IAC1B,MAAM,MAAM,CAAkB,IAC9B,KAAA;EACR,IACE,WAAW,KAAA,KACX,uBAAuB,MAAM,QAAQ,OAAO,UAAU,CAAC,CAAC,WAAW,GAAG,IAAI,EAAE,CAAC,GAE7E,OAAO;CAEX;CACA,OAAO;AACT;AAEA,MAAM,yBAAyB;CAC7B,eAAe;EACb,YAAY;EACZ,UAAU,MAAM,c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R,8BAA8B,KAAK,oDACrC;AACF"}
1
+ {"version":3,"file":"profile-ZS7_KLwK.js","names":["publicValue","canonicalCandidateBytes","sha256Bytes","canonicalCandidateDigest"],"sources":["../src/candidate-execution/system-prompt.ts","../src/candidate-execution/profile.ts"],"sourcesContent":["import { posix } from 'node:path'\n\nimport type {\n AgentCandidateConfigValue,\n AgentCandidateLaunch,\n} from '@tangle-network/agent-interface'\nimport type {\n AgentCandidateWorkspacePlan,\n HarnessId,\n} from '@tangle-network/agent-profile-materialize'\n\nconst SYSTEM_PROMPT_FILE = '.tangle/system-prompt.md'\nconst APPEND_SYSTEM_PROMPT_FILE = '.tangle/append-system-prompt.md'\n\n/**\n * One row describes the native process control for each prompt intent this adapter owns.\n * A row with no executor projection means the shared materializer already lowered the intent into\n * the signed workspace plan; this adapter still proves that the launch reaches the native binary.\n */\ninterface HarnessSystemPrompt {\n /** The native binary the launch must run for this projection to be provable. */\n readonly executable: string\n /** Apply a replacement prompt to the harness's own control. */\n readonly project: (\n plan: AgentCandidateWorkspacePlan,\n systemPrompt: string,\n systemPromptFilePath: string,\n ) => AgentCandidateWorkspacePlan\n /** Apply an addition without replacing the harness's own prompt. */\n readonly projectAppend?: (\n plan: AgentCandidateWorkspacePlan,\n appendSystemPrompt: string,\n appendSystemPromptFilePath: string,\n ) => AgentCandidateWorkspacePlan\n /** The materializer already projected replacement text into native plan files and flags. */\n readonly retainsProjectedSystemPrompt?: boolean\n /** Does caller argv already set a replacement control this projection would shadow? */\n readonly conflictsWithArgs: (values: readonly string[]) => boolean\n /** Does caller argv already set an additive control this projection would shadow? */\n readonly conflictsWithAppendArgs: (values: readonly string[]) => boolean\n}\n\nconst SYSTEM_PROMPT_FLAGS = ['--system-prompt', '--system-prompt-file'] as const\nconst APPEND_SYSTEM_PROMPT_FLAGS = [\n '--append-system-prompt',\n '--append-system-prompt-file',\n] as const\n\nfunction argsSetSystemPromptFlag(values: readonly string[]): boolean {\n return values.some((value) =>\n SYSTEM_PROMPT_FLAGS.some((flag) => value === flag || value.startsWith(`${flag}=`)),\n )\n}\n\nfunction argsSetAppendSystemPromptFlag(values: readonly string[]): boolean {\n return values.some((value) =>\n APPEND_SYSTEM_PROMPT_FLAGS.some((flag) => value === flag || value.startsWith(`${flag}=`)),\n )\n}\n\n/** Codex keys that can replace or contaminate the materializer's sealed instructions file. */\nconst CODEX_INSTRUCTION_KEYS = ['model_instructions_file', 'developer_instructions'] as const\n\nfunction argsSetCodexInstructionOverride(values: readonly string[]): boolean {\n for (let index = 0; index < values.length; index++) {\n const value = values[index]!\n const config =\n value === '-c' || value === '--config'\n ? values[index + 1]\n : value.startsWith('--config=')\n ? value.slice('--config='.length)\n : undefined\n if (\n config !== undefined &&\n CODEX_INSTRUCTION_KEYS.some((key) => config.trimStart().startsWith(`${key}=`))\n ) {\n return true\n }\n }\n return false\n}\n\nconst HARNESS_SYSTEM_PROMPTS = {\n 'claude-code': {\n executable: 'claude',\n project: (plan, systemPrompt, path) =>\n appendFlags(\n addPromptFile(plan, SYSTEM_PROMPT_FILE, systemPrompt),\n '--system-prompt-file',\n path,\n ),\n projectAppend: (plan, appendSystemPrompt, path) =>\n appendFlags(\n addPromptFile(plan, APPEND_SYSTEM_PROMPT_FILE, appendSystemPrompt),\n '--append-system-prompt-file',\n path,\n ),\n conflictsWithArgs: argsSetSystemPromptFlag,\n conflictsWithAppendArgs: argsSetAppendSystemPromptFlag,\n },\n /** OpenCode's bound primary agent is already selected by the materializer's --agent flag. */\n opencode: {\n executable: 'opencode',\n project: (plan) => plan,\n retainsProjectedSystemPrompt: true,\n conflictsWithArgs: (values) =>\n values.some((value) => value === '--agent' || value.startsWith('--agent=')),\n conflictsWithAppendArgs: argsSetAppendSystemPromptFlag,\n },\n pi: {\n executable: 'pi',\n project: (plan, systemPrompt, path) =>\n appendFlags(addPromptFile(plan, SYSTEM_PROMPT_FILE, systemPrompt), '--system-prompt', path),\n projectAppend: (plan, appendSystemPrompt, path) =>\n appendFlags(\n addPromptFile(plan, APPEND_SYSTEM_PROMPT_FILE, appendSystemPrompt),\n '--append-system-prompt',\n path,\n ),\n conflictsWithArgs: argsSetSystemPromptFlag,\n conflictsWithAppendArgs: argsSetAppendSystemPromptFlag,\n },\n prime: {\n executable: 'prime-agent',\n project: (plan, systemPrompt, path) =>\n appendFlags(addPromptFile(plan, SYSTEM_PROMPT_FILE, systemPrompt), '--system-prompt', path),\n projectAppend: (plan, appendSystemPrompt, path) =>\n appendFlags(\n addPromptFile(plan, APPEND_SYSTEM_PROMPT_FILE, appendSystemPrompt),\n '--append-system-prompt',\n path,\n ),\n conflictsWithArgs: argsSetSystemPromptFlag,\n conflictsWithAppendArgs: argsSetAppendSystemPromptFlag,\n },\n /** Gemini's file and env lowering is materializer-owned; this row supplies the launch proof. */\n gemini: {\n executable: 'gemini',\n project: (plan) => plan,\n conflictsWithArgs: argsSetSystemPromptFlag,\n conflictsWithAppendArgs: argsSetAppendSystemPromptFlag,\n },\n} as const satisfies Partial<Record<HarnessId, HarnessSystemPrompt>>\n\ninterface MaterializedPromptDelivery {\n readonly executable: string\n readonly delivered: (plan: AgentCandidateWorkspacePlan) => boolean\n readonly conflictsWithArgs: (values: readonly string[]) => boolean\n}\n\n/**\n * These controls are lowered by agent-profile-materialize into files plus launch inputs. The\n * candidate adapter does not own the spawn, so it must reject an arbitrary entrypoint even when\n * the plan has the right bytes: only the native binary can make those inputs effective.\n */\nconst MATERIALIZED_PROMPT_DELIVERIES = {\n codex: {\n executable: 'codex',\n delivered: (plan) =>\n plan.files.some((file) => file.relPath === '.codex/system-prompt.md') &&\n plan.flags.some((flag) => flag.value === 'model_instructions_file=.codex/system-prompt.md'),\n conflictsWithArgs: argsSetCodexInstructionOverride,\n },\n gemini: {\n executable: 'gemini',\n delivered: (plan) =>\n plan.files.some((file) => file.relPath === '.gemini/system.md') &&\n plan.env.GEMINI_SYSTEM_MD?.value === '1',\n conflictsWithArgs: argsSetSystemPromptFlag,\n },\n} as const satisfies Partial<Record<HarnessId, MaterializedPromptDelivery>>\n\n/** Project both prompt intents onto their distinct native process controls. */\nexport function projectCandidatePromptIntents(\n plan: AgentCandidateWorkspacePlan,\n launch: AgentCandidateLaunch,\n systemPromptFilePath: string,\n requestedSystemPrompt: string | undefined = plan.systemPrompt?.value,\n requestedAppendSystemPrompt: string | undefined = plan.appendSystemPrompt?.value,\n): AgentCandidateWorkspacePlan {\n const systemPrompt = plan.systemPrompt\n const appendSystemPrompt = plan.appendSystemPrompt\n const delivery = MATERIALIZED_PROMPT_DELIVERIES[\n plan.harness as keyof typeof MATERIALIZED_PROMPT_DELIVERIES\n ] as MaterializedPromptDelivery | undefined\n\n if (systemPrompt === undefined && delivery?.delivered(plan)) {\n assertProvableNativeLaunch(plan.harness, delivery.executable, launch, 'replacement')\n assertNoShadowingArgs(plan.harness, delivery.conflictsWithArgs, launch, 'replacement')\n if (requestedSystemPrompt === undefined) return plan\n return plan\n }\n\n if (requestedSystemPrompt === undefined && requestedAppendSystemPrompt === undefined) {\n return plan\n }\n\n const projection = HARNESS_SYSTEM_PROMPTS[plan.harness as keyof typeof HARNESS_SYSTEM_PROMPTS] as\n | HarnessSystemPrompt\n | undefined\n if (!projection) {\n throw new Error(`candidate system prompt has no native launch projection for ${plan.harness}`)\n }\n\n const requestedReplacement = requestedSystemPrompt !== undefined\n if (requestedReplacement && systemPrompt === undefined) {\n throw new Error(\n `profile materializer did not deliver the candidate system prompt for ${plan.harness}`,\n )\n }\n if (systemPrompt !== undefined && requestedSystemPrompt === undefined) {\n throw new Error(\n `profile materializer added an unexpected candidate system prompt for ${plan.harness}`,\n )\n }\n if (systemPrompt !== undefined && systemPrompt.value !== requestedSystemPrompt) {\n throw new Error('profile materializer changed the candidate system prompt')\n }\n if (\n appendSystemPrompt !== undefined &&\n appendSystemPrompt.value !== requestedAppendSystemPrompt\n ) {\n throw new Error('profile materializer changed the candidate append system prompt')\n }\n\n const intent = requestedReplacement ? 'replacement' : 'addition'\n assertProvableNativeLaunch(plan.harness, projection.executable, launch, intent)\n const launchArgs = (launch.args ?? []).map((value) => value.value)\n if (requestedReplacement && projection.conflictsWithArgs(launchArgs)) {\n throw new Error(\n `${plan.harness} launch arguments conflict with the candidate profile system prompt`,\n )\n }\n if (requestedAppendSystemPrompt !== undefined && projection.conflictsWithAppendArgs(launchArgs)) {\n throw new Error(\n `${plan.harness} launch arguments conflict with the candidate profile append system prompt`,\n )\n }\n\n let projected = plan\n if (systemPrompt !== undefined) {\n projected = projection.project(\n projection.retainsProjectedSystemPrompt\n ? projected\n : omitPromptIntent(projected, 'systemPrompt'),\n systemPrompt.value,\n systemPromptFilePath,\n )\n }\n if (appendSystemPrompt !== undefined) {\n if (!projection.projectAppend) {\n throw new Error(\n `candidate append system prompt has no native launch projection for ${plan.harness}`,\n )\n }\n projected = projection.projectAppend(\n omitPromptIntent(projected, 'appendSystemPrompt'),\n appendSystemPrompt.value,\n posix.join(posix.dirname(systemPromptFilePath), 'append-system-prompt.md'),\n )\n }\n // The source-profile digest binds authored values. Remove executor handoff fields only after\n // converting them into native controls; materializer-owned controls remain visible in the plan.\n return projected\n}\n\nfunction assertProvableNativeLaunch(\n harness: string,\n expectedExecutable: string,\n launch: AgentCandidateLaunch,\n intent: 'replacement' | 'addition',\n): asserts launch is AgentCandidateLaunch & { kind: 'container-command' } {\n if (launch.kind !== 'container-command') {\n throw new Error(`candidate-entrypoint launch cannot prove ${harness} system-prompt ${intent}`)\n }\n if (\n launch.executable !== expectedExecutable &&\n !(\n posix.isAbsolute(launch.executable) &&\n posix.basename(launch.executable) === expectedExecutable\n )\n ) {\n throw new Error(\n `${harness} system-prompt ${intent} requires the native ${expectedExecutable} executable`,\n )\n }\n}\n\nfunction assertNoShadowingArgs(\n harness: string,\n conflictsWithArgs: (values: readonly string[]) => boolean,\n launch: Extract<AgentCandidateLaunch, { kind: 'container-command' }>,\n intent: 'replacement' | 'addition',\n): void {\n if (conflictsWithArgs((launch.args ?? []).map((value) => value.value))) {\n throw new Error(\n `${harness} launch arguments conflict with the candidate profile ${intent === 'replacement' ? 'system' : 'append system'} prompt`,\n )\n }\n}\n\nfunction omitPromptIntent(\n plan: AgentCandidateWorkspacePlan,\n intent: 'systemPrompt' | 'appendSystemPrompt',\n): AgentCandidateWorkspacePlan {\n const projected = { ...plan }\n delete projected[intent]\n return projected\n}\n\nfunction appendFlags(\n plan: AgentCandidateWorkspacePlan,\n ...values: string[]\n): AgentCandidateWorkspacePlan {\n return {\n ...plan,\n flags: [...plan.flags, ...values.map(publicValue)],\n }\n}\n\nfunction publicValue(value: string): AgentCandidateConfigValue {\n return { kind: 'public', value }\n}\n\nfunction addPromptFile(\n plan: AgentCandidateWorkspacePlan,\n relPath: string,\n prompt: string,\n): AgentCandidateWorkspacePlan {\n // Candidate argv rejects control characters. Native prompt-file loading preserves multiline\n // bytes without weakening the shared process schema.\n if (plan.files.some((file) => file.relPath === relPath)) {\n throw new Error(`candidate profile conflicts with reserved ${relPath}`)\n }\n return {\n ...plan,\n files: [\n ...plan.files,\n {\n relPath,\n content: prompt,\n source: 'generated',\n },\n ],\n }\n}\n","import { posix } from 'node:path'\n\nimport type {\n AgentCandidateConfigValue,\n AgentCandidateLaunch,\n AgentCandidateProfile,\n AgentCandidateProfileActivation,\n AgentCandidateProfilePlanEvidence,\n AgentCandidateResourceRef,\n AgentProfile,\n AgentProfileConfigValue,\n AgentProfileDiff,\n AgentProfileMcpServer,\n AgentProfileResourceRef,\n HarnessType,\n Sha256Digest,\n} from '@tangle-network/agent-interface'\nimport {\n agentCandidateProfileActivationSchema,\n agentCandidateProfileSchema,\n agentProfileDiffSchema,\n agentProfileSchema,\n applyAgentProfileDiff,\n} from '@tangle-network/agent-interface'\nimport type {\n AgentCandidateWorkspacePlan,\n HarnessId,\n} from '@tangle-network/agent-profile-materialize'\nimport {\n isMaterializerHarness,\n materializeCandidateProfile,\n resolvePiRuntimePaths,\n} from '@tangle-network/agent-profile-materialize'\n\nimport { ValidationError } from '../errors'\nimport {\n canonicalCandidateBytes,\n canonicalCandidateDigest,\n canonicalCandidateDocument,\n embeddedCandidateArtifact,\n immutableCandidateValue,\n omitTopLevelDigest,\n sha256Bytes,\n} from './digest'\nimport { projectCandidatePromptIntents } from './system-prompt'\n\nexport function candidateMaterializerHarness(harness: HarnessType): HarnessId {\n if (!isMaterializerHarness(harness)) {\n throw new Error(\n `sealed candidate profile materialization is unsupported for harness ${harness}`,\n )\n }\n return harness\n}\n\n/** Runtime applies the materializer's launch flags to the candidate process. */\nexport const CANDIDATE_PROFILE_MATERIALIZER_BINDS = ['systemPrompt'] as const\nexport const PI_CANDIDATE_AGENT_DIR_ENV = 'PI_CODING_AGENT_DIR'\nexport const PI_CANDIDATE_SESSION_DIR_ENV = 'PI_CODING_AGENT_SESSION_DIR'\n\ninterface MaterializeAgentCandidateProfilePlanOptions {\n profile: AgentCandidateProfile\n harness: HarnessType\n launch: AgentCandidateLaunch\n workspace: 'task' | 'candidate'\n workspaces: {\n taskRoot: string\n candidateRoot?: string\n }\n resolvedResources?: ReadonlyMap<Sha256Digest, string>\n}\n\n/** Derive the exact native profile plan used by preparation and later evidence checks. */\nexport function materializeAgentCandidateProfilePlan(\n options: MaterializeAgentCandidateProfilePlanOptions,\n): AgentCandidateWorkspacePlan {\n const root =\n options.workspace === 'task' ? options.workspaces.taskRoot : options.workspaces.candidateRoot\n if (!root) throw new Error('candidate profile target is missing its execution workspace root')\n const plan = materializeCandidateProfile(\n options.profile,\n candidateMaterializerHarness(options.harness),\n {\n binds: CANDIDATE_PROFILE_MATERIALIZER_BINDS,\n resolvedResources: options.resolvedResources,\n },\n )\n return projectCandidatePromptIntents(\n plan,\n options.launch,\n posix.join(root, '.tangle/system-prompt.md'),\n options.profile.prompt?.systemPrompt,\n options.profile.prompt?.appendSystemPrompt,\n )\n}\n\n/** Resolve the private Pi roots needed by an agent-root profile plan. */\nexport function candidateProfileAgentPaths(\n plan: {\n harness: HarnessType\n files: ReadonlyArray<{ root?: 'agent' | 'workspace' }>\n },\n runtimeHome: string | undefined,\n): { agentDir: string; sessionDir: string } | undefined {\n if (!plan.files.some((file) => file.root === 'agent')) return undefined\n if (plan.harness !== 'pi') {\n throw new Error(`candidate profile agent-root files are unsupported for ${plan.harness}`)\n }\n if (runtimeHome === undefined) {\n throw new Error('candidate profile agent-root files require executionRoots.profileRoot')\n }\n return resolvePiRuntimePaths(runtimeHome)\n}\n\n/** Bind exact native profile text to the canonical plan captured during preparation. */\nexport function createAgentCandidateProfileActivation(\n plan: AgentCandidateWorkspacePlan,\n profilePlan: AgentCandidateProfilePlanEvidence,\n): AgentCandidateProfileActivation {\n const sourceByIdentity = new Map(\n plan.files.map((file) => [profileFileIdentity(file.root, file.relPath), file]),\n )\n if (sourceByIdentity.size !== plan.files.length) {\n throw new Error('candidate profile activation contains duplicate rooted native file paths')\n }\n const files = profilePlan.material.files.map((expected) => {\n const source = sourceByIdentity.get(profileFileIdentity(expected.root, expected.relPath))\n if (!source) {\n throw new Error(\n `candidate profile activation is missing ${profileFileLabel(expected.root, expected.relPath)}`,\n )\n }\n const mode = source.mode ?? 0o644\n if (!Number.isSafeInteger(mode) || mode < 0 || mode > 0o777) {\n throw new Error(\n `candidate profile activation has invalid mode for ${profileFileLabel(expected.root, expected.relPath)}`,\n )\n }\n return { path: expected.relPath, mode, content: source.content }\n })\n if (files.length !== plan.files.length) {\n throw new Error('candidate profile activation contains unplanned native files')\n }\n return parseAgentCandidateProfileActivation(\n canonicalCandidateDocument<AgentCandidateProfileActivation>({\n kind: 'agent-candidate-profile-activation',\n profilePlan,\n files,\n }).value,\n profilePlan.digest,\n )\n}\n\nfunction profileFileIdentity(root: 'agent' | 'workspace' | undefined, relPath: string): string {\n return `${root ?? 'workspace'}\\0${relPath}`\n}\n\nfunction profileFileLabel(root: 'agent' | 'workspace' | undefined, relPath: string): string {\n return root === 'agent' ? `agent:${relPath}` : relPath\n}\n\n/** Parse and check every native file hash plus both canonical document digests. */\nexport function parseAgentCandidateProfileActivation(\n input: unknown,\n expectedProfilePlanDigest?: AgentCandidateProfilePlanEvidence['digest'],\n): AgentCandidateProfileActivation {\n const activation = agentCandidateProfileActivationSchema.parse(input)\n const planBytes = canonicalCandidateBytes(activation.profilePlan.material)\n const profilePlanArtifact = activation.profilePlan.artifact\n if (\n sha256Bytes(planBytes) !== activation.profilePlan.digest ||\n profilePlanArtifact.sha256 !== activation.profilePlan.digest ||\n profilePlanArtifact.byteLength !== planBytes.byteLength ||\n ('content' in profilePlanArtifact &&\n !Buffer.from(profilePlanArtifact.content, 'base64').equals(Buffer.from(planBytes))) ||\n (expectedProfilePlanDigest !== undefined &&\n activation.profilePlan.digest !== expectedProfilePlanDigest)\n ) {\n throw new Error('candidate profile activation has an invalid canonical profile plan')\n }\n if (canonicalCandidateDigest(omitTopLevelDigest(activation)) !== activation.digest) {\n throw new Error('candidate profile activation digest does not match')\n }\n return immutableCandidateValue(activation)\n}\n\nconst CANDIDATE_PROFILE_DIRECT_FIELDS = [\n 'name',\n 'description',\n 'version',\n 'tags',\n 'prompt',\n 'harness',\n 'permissions',\n 'tools',\n 'confidential',\n] as const\n\n/** Convert only behavior-preserving generic profile fields into the closed candidate contract. */\nexport function freezeGenericAgentCandidateProfile(input: AgentProfile): AgentCandidateProfile {\n refuseFieldsSandboxCannotCarry(input)\n const profile = parseExactAgentProfile(input, 'profile')\n return candidateProfileFromGenericProfile(profile)\n}\n\n/**\n * Keep every generic-profile-to-candidate conversion in one place.\n * Callers use this both when sealing a new bundle and when proving a measured\n * profile is exactly the profile in an existing candidate.\n */\nfunction candidateProfileFromGenericProfile(profile: AgentProfile): AgentCandidateProfile {\n assertResolvedKnowledgeResources(profile.resources)\n if (profile.connections !== undefined) unsupportedProfileField('connections')\n if (profile.metadata !== undefined) unsupportedProfileField('metadata')\n if (profile.extensions !== undefined) unsupportedProfileField('extensions')\n if (profile.model?.metadata !== undefined) unsupportedProfileField('model.metadata')\n\n const candidate: Record<string, unknown> = {}\n copyDirectProfileFields(candidate, profile as Record<string, unknown>)\n if (profile.model) {\n const { metadata: _metadata, ...model } = profile.model\n candidate.model = model\n }\n if (profile.mcp) candidate.mcp = freezeMcpServers(profile.mcp)\n if (profile.subagents) {\n candidate.subagents = Object.fromEntries(\n Object.entries(profile.subagents).map(([name, subagent]) => {\n if (subagent.metadata !== undefined) unsupportedProfileField(`subagents.${name}.metadata`)\n const { metadata: _metadata, ...value } = subagent\n return [name, value]\n }),\n )\n }\n if (profile.resources) candidate.resources = freezeResources(profile.resources)\n if (profile.hooks && Object.values(profile.hooks).some((commands) => commands.length > 0)) {\n throw new Error(\n 'generic AgentProfile hooks cannot be safely tokenized; use a candidate-profile source with executable/args',\n )\n }\n if (profile.hooks) candidate.hooks = profile.hooks\n if (profile.modes) {\n candidate.modes = Object.fromEntries(\n Object.entries(profile.modes).map(([name, mode]) => {\n if (mode.metadata !== undefined) unsupportedProfileField(`modes.${name}.metadata`)\n const { metadata: _metadata, ...value } = mode\n return [name, value]\n }),\n )\n }\n const parsed = parseExactCandidateProfile(candidate)\n return parsed\n}\n\n/** Prove the measured generic profile and sealed candidate profile describe the same behavior. */\nexport function assertCandidateProfileBinding(\n measuredInput: unknown,\n bundled: AgentCandidateProfile,\n): void {\n refuseFieldsSandboxCannotCarry(measuredInput)\n const measured = parseExactAgentProfile(measuredInput, 'measured agent profile')\n const expected = candidateProfileFromGenericProfile(measured)\n if (canonicalCandidateDigest(expected) !== canonicalCandidateDigest(bundled)) {\n throw new Error('measured agent profile does not match sealed candidate profile')\n }\n}\n\n/** Parse a complete profile without silently discarding unsupported fields. */\nexport function parseExactAgentProfile(input: unknown, label: string): AgentProfile {\n let parsed: AgentProfile\n try {\n parsed = agentProfileSchema.parse(input) as AgentProfile\n } catch (cause) {\n throw new Error(`${label} contains unsupported or non-canonical fields`, { cause })\n }\n assertCanonicalParse(input, parsed, label)\n return parsed\n}\n\n/** Parse a profile diff without silently discarding unsupported fields. */\nexport function parseExactAgentProfileDiff(input: unknown, label: string): AgentProfileDiff {\n let parsed: AgentProfileDiff\n try {\n parsed = agentProfileDiffSchema.parse(input) as AgentProfileDiff\n } catch (cause) {\n throw new Error(`${label} contains unsupported or non-canonical fields`, { cause })\n }\n assertCanonicalParse(input, parsed, label)\n return parsed\n}\n\n/** Apply one exact diff and reject any value that cannot be preserved canonically. */\nexport function applyExactAgentProfileDiff(\n baseInput: unknown,\n diffInput: unknown,\n label: string,\n): AgentProfile {\n const base = parseExactAgentProfile(baseInput, `${label} base profile`)\n const diff = parseExactAgentProfileDiff(diffInput, `${label} diff`)\n const applied = omitUndefinedObjectFields(applyAgentProfileDiff(base, diff), label)\n return parseExactAgentProfile(applied, `${label} result`)\n}\n\n/** Parse a candidate profile without silently discarding unsupported or non-canonical fields. */\nexport function parseExactCandidateProfile(input: unknown): AgentCandidateProfile {\n const parsed = agentCandidateProfileSchema.parse(input)\n assertCanonicalParse(input, parsed, 'candidate profile')\n return parsed\n}\n\n/** Reject profile fields whose behavioral effect is not yet proven by candidate executors. */\nexport function assertCandidateProfileExecutionSupport(profile: AgentCandidateProfile): void {\n assertResolvedKnowledgeResources(profile.resources)\n refuseFieldsSandboxCannotCarry(profile)\n const fields = ['tools', 'permissions', 'modes', 'confidential'] as const\n const unsupported = fields.filter((field) => hasEntries(profile[field]))\n if (unsupported.length > 0) {\n throw new Error(\n `candidate execution cannot prove in-session effects for non-empty AgentProfile fields: ${unsupported.join(', ')}`,\n )\n }\n}\n\n/** Convert the candidate profile contract into the portable interface profile it represents. */\nexport function agentCandidateProfileAsAgentProfile(\n candidate: AgentCandidateProfile,\n): AgentProfile {\n assertResolvedKnowledgeResources(candidate.resources)\n refuseFieldsSandboxCannotCarry(candidate)\n const output: Record<string, unknown> = {}\n copyDirectProfileFields(output, candidate as unknown as Record<string, unknown>)\n if (candidate.model) output.model = { ...candidate.model }\n if (candidate.mcp) {\n output.mcp = Object.fromEntries(\n Object.entries(candidate.mcp).map(([name, server]) => [\n name,\n {\n ...server,\n // Candidate config values ({kind:'public', value}) are already valid\n // AgentProfileConfigValue entries under interface >=0.40 — clone them\n // rather than unwrapping to plain strings, which the 0.40 profile\n // schema rejects.\n ...(server.args ? { args: server.args.map((value) => ({ ...value })) } : {}),\n ...(server.env ? { env: cloneRecord(server.env) } : {}),\n },\n ]),\n )\n }\n if (candidate.subagents) output.subagents = cloneRecord(candidate.subagents)\n if (candidate.modes) output.modes = cloneRecord(candidate.modes)\n if (candidate.hooks) {\n output.hooks = Object.fromEntries(\n Object.entries(candidate.hooks).map(([event, hooks]) => [\n event,\n hooks.map(({ executable, args, env, ...hook }) => ({\n ...hook,\n command: [executable, ...(args ?? []).map(publicValue)].map(shellQuote).join(' '),\n // Hook env stays in config-value form: the 0.40 profile hook contract\n // types env as Record<string, AgentProfileConfigValue>.\n ...(env ? { env: cloneRecord(env) } : {}),\n })),\n ]),\n )\n }\n if (candidate.resources) {\n if (candidate.resources.failOnError !== true) {\n throw new Error('sealed candidate profile contains fields unsupported by generic profiles')\n }\n output.resources = {\n failOnError: true,\n ...(candidate.resources.files\n ? {\n files: candidate.resources.files.map((file) => ({\n ...file,\n resource: publicResource(file.resource),\n })),\n }\n : {}),\n ...(candidate.resources.tools\n ? { tools: candidate.resources.tools.map(publicResource) }\n : {}),\n ...(candidate.resources.skills\n ? { skills: candidate.resources.skills.map(publicResource) }\n : {}),\n ...(candidate.resources.agents\n ? { agents: candidate.resources.agents.map(publicResource) }\n : {}),\n ...(candidate.resources.commands\n ? { commands: candidate.resources.commands.map(publicResource) }\n : {}),\n ...(candidate.resources.instructions !== undefined\n ? {\n instructions:\n typeof candidate.resources.instructions === 'string'\n ? candidate.resources.instructions\n : publicResource(candidate.resources.instructions),\n }\n : {}),\n }\n }\n return output as AgentProfile\n}\n\n/** Recursively remove undefined object fields while refusing undefined array entries. */\nexport function omitUndefinedObjectFields(value: unknown, path: string): unknown {\n if (Array.isArray(value)) {\n return value.map((entry, index) => {\n if (entry === undefined) {\n throw new Error(`${path} produced an undefined array entry at ${index}`)\n }\n return omitUndefinedObjectFields(entry, `${path}[${index}]`)\n })\n }\n if (value === null || typeof value !== 'object') return value\n return Object.fromEntries(\n Object.entries(value as Record<string, unknown>)\n .filter(([, entry]) => entry !== undefined)\n .map(([key, entry]) => [key, omitUndefinedObjectFields(entry, `${path}.${key}`)]),\n )\n}\n\nfunction freezeMcpServers(servers: Record<string, AgentProfileMcpServer>): Record<string, unknown> {\n return Object.fromEntries(\n Object.entries(servers).map(([name, server]) => {\n if (server.transport !== undefined && server.transport !== 'stdio') {\n unsupportedProfileField(`mcp.${name}.transport=${server.transport}`)\n }\n if (server.url !== undefined) unsupportedProfileField(`mcp.${name}.url`)\n if (server.headers !== undefined) unsupportedProfileField(`mcp.${name}.headers`)\n if (server.metadata !== undefined) unsupportedProfileField(`mcp.${name}.metadata`)\n return [\n name,\n {\n ...(server.transport ? { transport: server.transport } : {}),\n ...(server.command ? { command: server.command } : {}),\n ...(server.args\n ? {\n args: server.args.map((value, index) =>\n candidatePublicValue(value, `mcp.${name}.args[${index}]`),\n ),\n }\n : {}),\n ...(server.env ? { env: mapCandidatePublicValues(server.env, `mcp.${name}.env`) } : {}),\n ...(server.cwd ? { cwd: server.cwd } : {}),\n ...(server.enabled === undefined ? {} : { enabled: server.enabled }),\n },\n ]\n }),\n )\n}\n\n/** A newer peer may admit knowledge pins that these candidate conversions cannot preserve. */\nfunction assertResolvedKnowledgeResources(resources: unknown): void {\n if (\n resources !== null &&\n typeof resources === 'object' &&\n 'knowledge' in resources &&\n resources.knowledge !== undefined\n ) {\n throw new Error(\n 'candidate profile resources.knowledge must be owner-authorized and resolved before candidate conversion or execution',\n )\n }\n}\n\n/**\n * Interface 5.3 admits profile `proxySecrets` and candidate secret-ref config values, but\n * Sandbox still ships its own Interface 4.0.0, which carries neither. Refuse them by name\n * rather than drop them; remove this once Sandbox adopts Interface 5.3.\n */\nfunction refuseFieldsSandboxCannotCarry(profile: unknown): void {\n if (!isRecord(profile)) return\n if (profile.proxySecrets !== undefined) refuseFieldSandboxCannotCarry('proxySecrets')\n if (isRecord(profile.mcp)) {\n for (const [name, server] of Object.entries(profile.mcp)) {\n if (!isRecord(server)) continue\n refuseNonPublicConfigValues(server.args, `mcp.${name}.args`)\n refuseNonPublicConfigValues(server.env, `mcp.${name}.env`)\n }\n }\n if (isRecord(profile.hooks)) {\n for (const [event, hooks] of Object.entries(profile.hooks)) {\n if (!Array.isArray(hooks)) continue\n for (const [index, hook] of hooks.entries()) {\n if (!isRecord(hook)) continue\n refuseNonPublicConfigValues(hook.args, `hooks.${event}[${index}].args`)\n refuseNonPublicConfigValues(hook.env, `hooks.${event}[${index}].env`)\n }\n }\n }\n}\n\nfunction refuseNonPublicConfigValues(values: unknown, path: string): void {\n const entries = Array.isArray(values)\n ? values.map((value, index) => [`${path}[${index}]`, value] as const)\n : isRecord(values)\n ? Object.entries(values).map(([name, value]) => [`${path}.${name}`, value] as const)\n : []\n for (const [field, value] of entries) {\n if (isRecord(value) && value.kind !== 'public') {\n refuseFieldSandboxCannotCarry(`${field} (${String(value.kind)})`)\n }\n }\n}\n\nfunction refuseFieldSandboxCannotCarry(field: string): never {\n throw new ValidationError(\n `candidate profile field ${field} is refused: Sandbox's Interface 4.0.0 cannot carry it yet, and Runtime does not drop it`,\n )\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return value !== null && typeof value === 'object' && !Array.isArray(value)\n}\n\nfunction freezeResources(resources: NonNullable<AgentProfile['resources']>): unknown {\n if (resources.failOnError !== true) {\n throw new Error('candidate profile resources require failOnError: true')\n }\n return {\n failOnError: true,\n ...(resources.files\n ? {\n files: resources.files.map((file) => ({\n ...file,\n resource: freezeResource(file.resource),\n })),\n }\n : {}),\n ...(resources.tools ? { tools: resources.tools.map(freezeResource) } : {}),\n ...(resources.skills ? { skills: resources.skills.map(freezeResource) } : {}),\n ...(resources.agents ? { agents: resources.agents.map(freezeResource) } : {}),\n ...(resources.commands ? { commands: resources.commands.map(freezeResource) } : {}),\n ...(resources.instructions === undefined\n ? {}\n : {\n instructions:\n typeof resources.instructions === 'string'\n ? resources.instructions\n : freezeResource(resources.instructions),\n }),\n }\n}\n\nfunction freezeResource(resource: AgentProfileResourceRef): AgentCandidateResourceRef {\n if (resource.kind === 'github') {\n throw new Error(\n 'generic GitHub profile resources do not carry byte identity; use a candidate-profile source with a pinned commit, digest, and byte length',\n )\n }\n const bytes = Buffer.from(resource.content, 'utf8')\n return {\n ...resource,\n sha256: embeddedCandidateArtifact(bytes).sha256,\n byteLength: bytes.byteLength,\n }\n}\n\nfunction copyDirectProfileFields(\n target: Record<string, unknown>,\n source: Record<string, unknown>,\n): void {\n for (const key of CANDIDATE_PROFILE_DIRECT_FIELDS) {\n if (source[key] !== undefined) target[key] = source[key]\n }\n}\n\nfunction assertCanonicalParse(input: unknown, parsed: unknown, label: string): void {\n if (!Buffer.from(canonicalCandidateBytes(input)).equals(canonicalCandidateBytes(parsed))) {\n throw new Error(`${label} contains unsupported or non-canonical fields`)\n }\n}\n\nfunction publicResource(resource: AgentCandidateResourceRef): unknown {\n if (resource.kind === 'inline') {\n return { kind: 'inline', name: resource.name, content: resource.content }\n }\n return {\n kind: 'github',\n repository: `${resource.repository.owner}/${resource.repository.repo}`,\n path: resource.path,\n ref: resource.commit,\n ...(resource.name ? { name: resource.name } : {}),\n }\n}\n\n/** Freeze one profile config value into the candidate's PUBLIC-only config\n * shape. A secret-ref is refused, never silently dropped or unwrapped. */\nfunction candidatePublicValue(\n value: AgentProfileConfigValue,\n path: string,\n): { kind: 'public'; value: string } {\n if (value.kind !== 'public') refuseFieldSandboxCannotCarry(`${path} (${value.kind})`)\n return { kind: 'public', value: value.value }\n}\n\nfunction mapCandidatePublicValues(\n values: Record<string, AgentProfileConfigValue>,\n pathPrefix: string,\n): Record<string, { kind: 'public'; value: string }> {\n return Object.fromEntries(\n Object.entries(values).map(([name, value]) => [\n name,\n candidatePublicValue(value, `${pathPrefix}.${name}`),\n ]),\n )\n}\n\nfunction publicValue(value: AgentCandidateConfigValue): string {\n return value.value\n}\n\nfunction cloneRecord<T>(values: Record<string, T>): Record<string, T> {\n return Object.fromEntries(\n Object.entries(values).map(([key, value]) => [key, { ...value }]),\n ) as Record<string, T>\n}\n\nfunction hasEntries(value: unknown): boolean {\n return value !== undefined && value !== null && typeof value === 'object'\n ? Object.keys(value).length > 0\n : false\n}\n\nfunction shellQuote(value: string): string {\n return /^[A-Za-z0-9_./:@%+=,-]+$/.test(value) ? value : `'${value.replaceAll(\"'\", `'\"'\"'`)}'`\n}\n\nfunction unsupportedProfileField(path: string): never {\n throw new Error(\n `generic AgentProfile field ${path} is not representable in a sealed candidate profile`,\n )\n}\n"],"mappings":";;;;;;AAWA,MAAM,qBAAqB;AAC3B,MAAM,4BAA4B;AA8BlC,MAAM,sBAAsB,CAAC,mBAAmB,sBAAsB;AACtE,MAAM,6BAA6B,CACjC,0BACA,6BACF;AAEA,SAAS,wBAAwB,QAAoC;CACnE,OAAO,OAAO,MAAM,UAClB,oBAAoB,MAAM,SAAS,UAAU,QAAQ,MAAM,WAAW,GAAG,KAAK,EAAE,CAAC,CACnF;AACF;AAEA,SAAS,8BAA8B,QAAoC;CACzE,OAAO,OAAO,MAAM,UAClB,2BAA2B,MAAM,SAAS,UAAU,QAAQ,MAAM,WAAW,GAAG,KAAK,EAAE,CAAC,CAC1F;AACF;;AAGA,MAAM,yBAAyB,CAAC,2BAA2B,wBAAwB;AAEnF,SAAS,gCAAgC,QAAoC;CAC3E,KAAK,IAAI,QAAQ,GAAG,QAAQ,OAAO,QAAQ,SAAS;EAClD,MAAM,QAAQ,OAAO;EACrB,MAAM,SACJ,UAAU,QAAQ,UAAU,aACxB,OAAO,QAAQ,KACf,MAAM,WAAW,WAAW,IAC1B,MAAM,MAAM,CAAkB,IAC9B,KAAA;EACR,IACE,WAAW,KAAA,KACX,uBAAuB,MAAM,QAAQ,OAAO,UAAU,CAAC,CAAC,WAAW,GAAG,IAAI,EAAE,CAAC,GAE7E,OAAO;CAEX;CACA,OAAO;AACT;AAEA,MAAM,yBAAyB;CAC7B,eAAe;EACb,YAAY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CACpD,MAAM,IAAI,MACR,8BAA8B,KAAK,oDACrC;AACF"}
@@ -1,4 +1,4 @@
1
- import { _S as CoderTask, _x as createResearcherValidator, ax as UI_LENSES, cx as UiFindingSeverity, dx as KnowledgeUpdate, fx as MultiHarnessResearcherFanoutOptions, gx as ResearcherProfileOptions, hx as ResearchTask, ix as UI_FINDING_SEVERITIES, lx as UiLens, mx as ResearchSource, ox as UiFinding, px as ResearchOutput, sx as UiFindingScreenshot, ux as KnowledgeItem, vS as coderTaskToPrompt, vx as multiHarnessResearcherFanout, yx as researcherProfile } from "./index-7h7-L6Tk.js";
1
+ import { $y as createResearcherValidator, By as UI_FINDING_SEVERITIES, Gy as UiLens, Hy as UiFinding, Jy as MultiHarnessResearcherFanoutOptions, Ky as KnowledgeItem, Qy as ResearcherProfileOptions, Tb as coderTaskToPrompt, Uy as UiFindingScreenshot, Vy as UI_LENSES, Wy as UiFindingSeverity, Xy as ResearchSource, Yy as ResearchOutput, Zy as ResearchTask, eb as multiHarnessResearcherFanout, qy as KnowledgeUpdate, tb as researcherProfile, wb as CoderTask } from "./types-ytkoP4VV.js";
2
2
  import { SandboxEvent } from "@tangle-network/sandbox";
3
3
  //#region src/profiles/ui-auditor/lens-prompts.d.ts
4
4
  /** Cross-lens rules injected into every UI audit iteration: finding quality standards and scope limits. @experimental */
package/dist/profiles.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { i as ConfigError } from "./errors-DodWX-cb.js";
2
- import { t as assertExecutableAgentProfile } from "./model-policy-CNe257pB.js";
2
+ import { t as assertExecutableAgentProfile } from "./model-policy-CyCUwHed.js";
3
3
  import { t as coderTaskToPrompt } from "./coder-yhVWbdWc.js";
4
4
  import { n as UI_LENSES, t as UI_FINDING_SEVERITIES } from "./substrate-B0TYNrXn.js";
5
5
  import { agentProfileSchema } from "@tangle-network/agent-interface";
@@ -1,6 +1,6 @@
1
- import { L as immutableCandidateValue, M as canonicalCandidateBytes, N as canonicalCandidateDigest, _ as assertExactObjectKeys, z as sha256Bytes } from "./workspace-streams-DFAhW7hF.js";
2
- import { b as assertAgentCandidateExecutionRoots, d as sealAgentCandidateModelSettlement, f as usdToNanos, i as candidateKnowledgeExecutionPaths } from "./prepare-CFQLx9e3.js";
3
- import { s as candidateProfileAgentPaths } from "./profile-BTbpdL9h.js";
1
+ import { L as immutableCandidateValue, M as canonicalCandidateBytes, N as canonicalCandidateDigest, _ as assertExactObjectKeys, z as sha256Bytes } from "./workspace-streams-CcoARX4v.js";
2
+ import { b as assertAgentCandidateExecutionRoots, d as sealAgentCandidateModelSettlement, f as usdToNanos, i as candidateKnowledgeExecutionPaths } from "./prepare-DpavgJT8.js";
3
+ import { s as candidateProfileAgentPaths } from "./profile-ZS7_KLwK.js";
4
4
  import { posix } from "node:path";
5
5
  import { isDeepStrictEqual } from "node:util";
6
6
  //#region src/candidate-execution/exact-process-executor.ts
@@ -763,4 +763,4 @@ function record(value, label) {
763
763
  //#endregion
764
764
  export { exactProcessProviderAsCandidateExecutor as n, createProtectedAgentCandidateModelPort as t };
765
765
 
766
- //# sourceMappingURL=protected-model-port-f1N2f0Uq.js.map
766
+ //# sourceMappingURL=protected-model-port-BLyyfL3l.js.map