@tangle-network/agent-runtime 0.348.1 → 0.350.2

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 (130) hide show
  1. package/dist/{activation-BEGalhOL.js → activation-CfJMyzEs.js} +12 -14
  2. package/dist/{activation-BEGalhOL.js.map → activation-CfJMyzEs.js.map} +1 -1
  3. package/dist/{activation-NQZP_mdI.d.ts → activation-DyiHrTlS.d.ts} +2 -24
  4. package/dist/agent.d.ts +8 -12
  5. package/dist/agent.js +9 -12
  6. package/dist/agent.js.map +1 -1
  7. package/dist/{analyst-loop-DZw5QWT9.js → analyst-loop-BZvXCDKy.js} +2 -3
  8. package/dist/{analyst-loop-DZw5QWT9.js.map → analyst-loop-BZvXCDKy.js.map} +1 -1
  9. package/dist/analyst-loop.d.ts +3 -5
  10. package/dist/analyst-loop.js +1 -2
  11. package/dist/{bundle-DKQtOO9d.js → bundle-Ze8pd07a.js} +3 -4
  12. package/dist/{bundle-DKQtOO9d.js.map → bundle-Ze8pd07a.js.map} +1 -1
  13. package/dist/candidate-execution/index.d.ts +13 -33
  14. package/dist/candidate-execution/index.js +16 -18
  15. package/dist/candidate-execution/index.js.map +1 -1
  16. package/dist/{coordination-manager-Bm6leXc6.js → coordination-manager-BkVfWlMz.js} +101 -132
  17. package/dist/coordination-manager-BkVfWlMz.js.map +1 -0
  18. package/dist/{delegate-Cp5-PsaX.js → delegate-DgEie4ad.js} +19 -21
  19. package/dist/delegate-DgEie4ad.js.map +1 -0
  20. package/dist/durable.d.ts +13 -23
  21. package/dist/durable.js +48 -43
  22. package/dist/durable.js.map +1 -1
  23. package/dist/{errors-DodWX-cb.js → errors-wuhGvpE3.js} +2 -3
  24. package/dist/{errors-DodWX-cb.js.map → errors-wuhGvpE3.js.map} +1 -1
  25. package/dist/{graph-CE_pzU31.js → graph-Cx0FhKSE.js} +192 -15
  26. package/dist/graph-Cx0FhKSE.js.map +1 -0
  27. package/dist/{improve-wT11zteg.js → improve-i0HU1-aa.js} +35 -53
  28. package/dist/{improve-wT11zteg.js.map → improve-i0HU1-aa.js.map} +1 -1
  29. package/dist/{improvement-adapter-sIthWkcN.d.ts → improvement-adapter-D5GRU1eY.d.ts} +2 -6
  30. package/dist/index.d.ts +41 -89
  31. package/dist/index.js +43 -61
  32. package/dist/index.js.map +1 -1
  33. package/dist/intelligence.d.ts +39 -59
  34. package/dist/intelligence.js +23 -33
  35. package/dist/intelligence.js.map +1 -1
  36. package/dist/kernel.d.ts +5 -5
  37. package/dist/kernel.js +11 -11
  38. package/dist/{loop-runner-CZzeeJTG.js → loop-runner-BwN9MhdP.js} +5 -6
  39. package/dist/{loop-runner-CZzeeJTG.js.map → loop-runner-BwN9MhdP.js.map} +1 -1
  40. package/dist/{loop-runner-CY5HHhtR.d.ts → loop-runner-DvfOXVx9.d.ts} +3 -5
  41. package/dist/loop-runner-bin.d.ts +5 -8
  42. package/dist/loop-runner-bin.js +2 -3
  43. package/dist/mcp/bin.js +6 -8
  44. package/dist/mcp/bin.js.map +1 -1
  45. package/dist/mcp/index.d.ts +8 -18
  46. package/dist/mcp/index.js +17 -25
  47. package/dist/mcp/index.js.map +1 -1
  48. package/dist/mcp/memory-bin.js +4 -6
  49. package/dist/mcp/memory-bin.js.map +1 -1
  50. package/dist/{model-policy-CyCUwHed.js → model-policy-GSxWwP-b.js} +11 -13
  51. package/dist/model-policy-GSxWwP-b.js.map +1 -0
  52. package/dist/placement.d.ts +12 -14
  53. package/dist/placement.js +1 -2
  54. package/dist/platform.d.ts +7 -13
  55. package/dist/platform.js +3 -6
  56. package/dist/platform.js.map +1 -1
  57. package/dist/{prepare-TEEHSJwq.js → prepare-DE8TQnLu.js} +49 -69
  58. package/dist/{prepare-TEEHSJwq.js.map → prepare-DE8TQnLu.js.map} +1 -1
  59. package/dist/{profile-6OLpbjvV.js → profile-CAhZDW2T.js} +58 -92
  60. package/dist/profile-CAhZDW2T.js.map +1 -0
  61. package/dist/{profile-materialization-bPm0gGLO.d.ts → profile-materialization-BRY22Oh8.d.ts} +1 -3
  62. package/dist/profiles.d.ts +25 -12
  63. package/dist/profiles.js +52 -11
  64. package/dist/profiles.js.map +1 -1
  65. package/dist/{protected-model-port-DVVh-hEk.d.ts → protected-model-port-IKqhTypD.d.ts} +2 -14
  66. package/dist/{protected-redaction-DFCeo4vg.js → protected-redaction-DilFZch5.js} +2 -3
  67. package/dist/{protected-redaction-DFCeo4vg.js.map → protected-redaction-DilFZch5.js.map} +1 -1
  68. package/dist/{provision-supervisor-CC0HdOHo.js → provision-supervisor-Bde_FF0R.js} +11 -15
  69. package/dist/{provision-supervisor-CC0HdOHo.js.map → provision-supervisor-Bde_FF0R.js.map} +1 -1
  70. package/dist/{record-events-D93DkpAx.js → record-events-B2GUgYdz.js} +12 -14
  71. package/dist/{record-events-D93DkpAx.js.map → record-events-B2GUgYdz.js.map} +1 -1
  72. package/dist/{run-cancellation-CzFhQGMa.js → run-cancellation-BLy_Zz-w.js} +6 -7
  73. package/dist/{run-cancellation-CzFhQGMa.js.map → run-cancellation-BLy_Zz-w.js.map} +1 -1
  74. package/dist/{runtime-B_40dXlF.js → runtime-6Ec9sHRe.js} +833 -215
  75. package/dist/runtime-6Ec9sHRe.js.map +1 -0
  76. package/dist/{runtime-hooks-tXpAarhW.js → runtime-hooks-CsW2pfFk.js} +2 -3
  77. package/dist/{runtime-hooks-tXpAarhW.js.map → runtime-hooks-CsW2pfFk.js.map} +1 -1
  78. package/dist/{runtime-hooks-nsqxSUFL.d.ts → runtime-hooks-ZQqPw-0g.d.ts} +1 -3
  79. package/dist/{sandbox-profile-compat-_fEtHPCj.js → sandbox-profile-compat-BxMQ1VXv.js} +62 -44
  80. package/dist/sandbox-profile-compat-BxMQ1VXv.js.map +1 -0
  81. package/dist/{search-executor-COd2F2wp.js → search-executor-B7g_5Wjl.js} +12 -17
  82. package/dist/search-executor-B7g_5Wjl.js.map +1 -0
  83. package/dist/{server-BGB4R4wQ.js → server-fvEMwGMQ.js} +19 -30
  84. package/dist/{server-BGB4R4wQ.js.map → server-fvEMwGMQ.js.map} +1 -1
  85. package/dist/{structural-rollout-Wl_rCuzM.js → structural-rollout-B86bSixU.js} +69 -70
  86. package/dist/structural-rollout-B86bSixU.js.map +1 -0
  87. package/dist/{substrate-CGDFTSRh.js → substrate-Db2pp6y3.js} +2 -3
  88. package/dist/{substrate-CGDFTSRh.js.map → substrate-Db2pp6y3.js.map} +1 -1
  89. package/dist/{supervise-BUOeThuB.js → supervise-CaeZcgAW.js} +615 -203
  90. package/dist/supervise-CaeZcgAW.js.map +1 -0
  91. package/dist/{supervisor-DDy0aEtR.js → supervisor-C1OePYE-.js} +526 -642
  92. package/dist/supervisor-C1OePYE-.js.map +1 -0
  93. package/dist/{task-queue-0fKkoweu.d.ts → task-queue-kefGy79U.d.ts} +1 -3
  94. package/dist/task-queue.d.ts +1 -1
  95. package/dist/task-queue.js +1 -2
  96. package/dist/testing.d.ts +8 -16
  97. package/dist/testing.js +241 -244
  98. package/dist/testing.js.map +1 -1
  99. package/dist/tool-loop.d.ts +16 -19
  100. package/dist/tool-loop.js +2 -3
  101. package/dist/{tool-server-XV4aJwoQ.js → tool-server-CwuYeW_Z.js} +3 -4
  102. package/dist/{tool-server-XV4aJwoQ.js.map → tool-server-CwuYeW_Z.js.map} +1 -1
  103. package/dist/{top-snapshot-CflmaDgk.js → top-snapshot-ChwpTr7A.js} +4 -5
  104. package/dist/{top-snapshot-CflmaDgk.js.map → top-snapshot-ChwpTr7A.js.map} +1 -1
  105. package/dist/tui/bin.js +7 -9
  106. package/dist/tui/bin.js.map +1 -1
  107. package/dist/tui/index.d.ts +3 -5
  108. package/dist/tui/index.js +2 -2
  109. package/dist/{types-hc4cmSc7.d.ts → types-Fowuwdz2.d.ts} +555 -503
  110. package/dist/{types-Cwrea-bU.d.ts → types-qsqfyQoY.d.ts} +1 -3
  111. package/dist/workspace-store/index.d.ts +12 -22
  112. package/dist/workspace-store/index.js +4 -7
  113. package/dist/workspace-store/index.js.map +1 -1
  114. package/dist/{workspace-streams-BiS4ABah.d.ts → workspace-streams-Dq2Fzk3c.d.ts} +1 -11
  115. package/package.json +25 -25
  116. package/skills/agent-graphs/SKILL.md +19 -4
  117. package/skills/be-ambitious/SKILL.md +46 -0
  118. package/skills/graph-designer/SKILL.md +15 -2
  119. package/skills/profile-authoring/SKILL.md +1 -1
  120. package/dist/coordination-manager-Bm6leXc6.js.map +0 -1
  121. package/dist/delegate-Cp5-PsaX.js.map +0 -1
  122. package/dist/graph-CE_pzU31.js.map +0 -1
  123. package/dist/model-policy-CyCUwHed.js.map +0 -1
  124. package/dist/profile-6OLpbjvV.js.map +0 -1
  125. package/dist/runtime-B_40dXlF.js.map +0 -1
  126. package/dist/sandbox-profile-compat-_fEtHPCj.js.map +0 -1
  127. package/dist/search-executor-COd2F2wp.js.map +0 -1
  128. package/dist/structural-rollout-Wl_rCuzM.js.map +0 -1
  129. package/dist/supervise-BUOeThuB.js.map +0 -1
  130. package/dist/supervisor-DDy0aEtR.js.map +0 -1
@@ -1,18 +1,15 @@
1
- import { m as ValidationError } from "./errors-DodWX-cb.js";
2
- import { B as sha256Bytes$1, F as canonicalCandidateDocument, L as embeddedCandidateArtifact, N as canonicalCandidateBytes$1, P as canonicalCandidateDigest$1, R as immutableCandidateValue, n as refuseSandboxProfileField, t as assertSandboxProfileCompatibility, z as omitTopLevelDigest } from "./sandbox-profile-compat-_fEtHPCj.js";
1
+ import { m as ValidationError } from "./errors-wuhGvpE3.js";
2
+ import { B as sha256Bytes$1, F as canonicalCandidateDocument, L as embeddedCandidateArtifact, N as canonicalCandidateBytes$1, P as canonicalCandidateDigest$1, R as immutableCandidateValue, U as nativeSystemPrompt, n as refuseSandboxProfileField, t as assertSandboxProfileCompatibility, z as omitTopLevelDigest } from "./sandbox-profile-compat-BxMQ1VXv.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";
6
- //#region src/candidate-execution/public-config.ts
6
+ // src/candidate-execution/public-config.ts
7
7
  /** Candidate execution has no private secret resolver; never lower a reference to argv or env. */
8
8
  function requirePublicCandidateConfigValue(value, path) {
9
9
  if (value.kind !== "public") throw new ValidationError(`candidate ${path} requires a public value; secret references are unsupported`);
10
10
  return value.value;
11
11
  }
12
- //#endregion
13
- //#region src/candidate-execution/system-prompt.ts
14
- const SYSTEM_PROMPT_FILE = ".tangle/system-prompt.md";
15
- const APPEND_SYSTEM_PROMPT_FILE = ".tangle/append-system-prompt.md";
12
+ // src/candidate-execution/system-prompt.ts
16
13
  const SYSTEM_PROMPT_FLAGS = ["--system-prompt", "--system-prompt-file"];
17
14
  const APPEND_SYSTEM_PROMPT_FLAGS = ["--append-system-prompt", "--append-system-prompt-file"];
18
15
  function argsSetSystemPromptFlag(values) {
@@ -34,77 +31,46 @@ function argsSetCodexInstructionOverride(values) {
34
31
  const HARNESS_SYSTEM_PROMPTS = {
35
32
  "claude-code": {
36
33
  executable: "claude",
37
- project: (plan, systemPrompt, path) => appendFlags(addPromptFile(plan, SYSTEM_PROMPT_FILE, systemPrompt), "--system-prompt-file", path),
38
- projectAppend: (plan, appendSystemPrompt, path) => appendFlags(addPromptFile(plan, APPEND_SYSTEM_PROMPT_FILE, appendSystemPrompt), "--append-system-prompt-file", path),
39
34
  conflictsWithArgs: argsSetSystemPromptFlag,
40
35
  conflictsWithAppendArgs: argsSetAppendSystemPromptFlag
41
36
  },
42
- /** OpenCode's bound primary agent is already selected by the materializer's --agent flag. */
37
+ codex: {
38
+ executable: "codex",
39
+ conflictsWithArgs: argsSetCodexInstructionOverride,
40
+ conflictsWithAppendArgs: argsSetCodexInstructionOverride
41
+ },
43
42
  opencode: {
44
43
  executable: "opencode",
45
- project: (plan) => plan,
46
- retainsProjectedSystemPrompt: true,
47
44
  conflictsWithArgs: (values) => values.some((value) => value === "--agent" || value.startsWith("--agent=")),
48
45
  conflictsWithAppendArgs: argsSetAppendSystemPromptFlag
49
46
  },
50
47
  pi: {
51
48
  executable: "pi",
52
- project: (plan, systemPrompt, path) => appendFlags(addPromptFile(plan, SYSTEM_PROMPT_FILE, systemPrompt), "--system-prompt", path),
53
- projectAppend: (plan, appendSystemPrompt, path) => appendFlags(addPromptFile(plan, APPEND_SYSTEM_PROMPT_FILE, appendSystemPrompt), "--append-system-prompt", path),
54
49
  conflictsWithArgs: argsSetSystemPromptFlag,
55
50
  conflictsWithAppendArgs: argsSetAppendSystemPromptFlag
56
51
  },
57
52
  prime: {
58
53
  executable: "prime-agent",
59
- project: (plan, systemPrompt, path) => appendFlags(addPromptFile(plan, SYSTEM_PROMPT_FILE, systemPrompt), "--system-prompt", path),
60
- projectAppend: (plan, appendSystemPrompt, path) => appendFlags(addPromptFile(plan, APPEND_SYSTEM_PROMPT_FILE, appendSystemPrompt), "--append-system-prompt", path),
61
54
  conflictsWithArgs: argsSetSystemPromptFlag,
62
55
  conflictsWithAppendArgs: argsSetAppendSystemPromptFlag
63
56
  },
64
- /** Gemini's file and env lowering is materializer-owned; this row supplies the launch proof. */
65
57
  gemini: {
66
58
  executable: "gemini",
67
- project: (plan) => plan,
68
59
  conflictsWithArgs: argsSetSystemPromptFlag,
69
60
  conflictsWithAppendArgs: argsSetAppendSystemPromptFlag
70
61
  }
71
62
  };
72
- /**
73
- * These controls are lowered by agent-profile-materialize into files plus launch inputs. The
74
- * candidate adapter does not own the spawn, so it must reject an arbitrary entrypoint even when
75
- * the plan has the right bytes: only the native binary can make those inputs effective.
76
- */
77
- const MATERIALIZED_PROMPT_DELIVERIES = {
78
- codex: {
79
- executable: "codex",
80
- delivered: (plan) => plan.files.some((file) => file.relPath === ".codex/system-prompt.md") && plan.flags.some((flag) => requirePublicCandidateConfigValue(flag, "profile.flags") === "model_instructions_file=.codex/system-prompt.md"),
81
- conflictsWithArgs: argsSetCodexInstructionOverride
82
- },
83
- gemini: {
84
- executable: "gemini",
85
- delivered: (plan) => {
86
- const env = plan.env.GEMINI_SYSTEM_MD;
87
- return plan.files.some((file) => file.relPath === ".gemini/system.md") && env !== void 0 && requirePublicCandidateConfigValue(env, "profile.env.GEMINI_SYSTEM_MD") === "1";
88
- },
89
- conflictsWithArgs: argsSetSystemPromptFlag
90
- }
91
- };
92
63
  /** Project both prompt intents onto their distinct native process controls. */
93
64
  function projectCandidatePromptIntents(plan, launch, systemPromptFilePath, requestedSystemPrompt = plan.systemPrompt === void 0 ? void 0 : requirePublicCandidateConfigValue(plan.systemPrompt, "profile.systemPrompt"), requestedAppendSystemPrompt = plan.appendSystemPrompt === void 0 ? void 0 : requirePublicCandidateConfigValue(plan.appendSystemPrompt, "profile.appendSystemPrompt")) {
94
65
  const systemPrompt = plan.systemPrompt;
95
66
  const appendSystemPrompt = plan.appendSystemPrompt;
96
- const delivery = MATERIALIZED_PROMPT_DELIVERIES[plan.harness];
97
- if (systemPrompt === void 0 && delivery?.delivered(plan)) {
98
- assertProvableNativeLaunch(plan.harness, delivery.executable, launch, "replacement");
99
- assertNoShadowingArgs(plan.harness, delivery.conflictsWithArgs, launch, "replacement");
100
- if (requestedSystemPrompt === void 0) return plan;
101
- return plan;
102
- }
67
+ const geminiSystem = plan.files.find((file) => file.relPath === ".gemini/system.md");
68
+ const delivered = plan.harness === "gemini" && geminiSystem?.content === requestedSystemPrompt && plan.env.GEMINI_SYSTEM_MD !== void 0 && requirePublicCandidateConfigValue(plan.env.GEMINI_SYSTEM_MD, "profile.env.GEMINI_SYSTEM_MD") === "1";
103
69
  if (requestedSystemPrompt === void 0 && requestedAppendSystemPrompt === void 0) return plan;
104
70
  const projection = HARNESS_SYSTEM_PROMPTS[plan.harness];
105
71
  if (!projection) throw new Error(`candidate system prompt has no native launch projection for ${plan.harness}`);
106
72
  const requestedReplacement = requestedSystemPrompt !== void 0;
107
- if (requestedReplacement && systemPrompt === void 0) throw new Error(`profile materializer did not deliver the candidate system prompt for ${plan.harness}`);
73
+ if (requestedReplacement && systemPrompt === void 0 && !delivered) throw new Error(`profile materializer did not deliver the candidate system prompt for ${plan.harness}`);
108
74
  if (systemPrompt !== void 0 && requestedSystemPrompt === void 0) throw new Error(`profile materializer added an unexpected candidate system prompt for ${plan.harness}`);
109
75
  if (systemPrompt !== void 0 && requirePublicCandidateConfigValue(systemPrompt, "profile.systemPrompt") !== requestedSystemPrompt) throw new Error("profile materializer changed the candidate system prompt");
110
76
  if (appendSystemPrompt !== void 0 && requirePublicCandidateConfigValue(appendSystemPrompt, "profile.appendSystemPrompt") !== requestedAppendSystemPrompt) throw new Error("profile materializer changed the candidate append system prompt");
@@ -113,51 +79,27 @@ function projectCandidatePromptIntents(plan, launch, systemPromptFilePath, reque
113
79
  const launchArgs = (launch.args ?? []).map((value, index) => requirePublicCandidateConfigValue(value, `launch.args[${index}]`));
114
80
  if (requestedReplacement && projection.conflictsWithArgs(launchArgs)) throw new Error(`${plan.harness} launch arguments conflict with the candidate profile system prompt`);
115
81
  if (requestedAppendSystemPrompt !== void 0 && projection.conflictsWithAppendArgs(launchArgs)) throw new Error(`${plan.harness} launch arguments conflict with the candidate profile append system prompt`);
116
- let projected = plan;
117
- if (systemPrompt !== void 0) projected = projection.project(projection.retainsProjectedSystemPrompt ? projected : omitPromptIntent(projected, "systemPrompt"), requirePublicCandidateConfigValue(systemPrompt, "profile.systemPrompt"), systemPromptFilePath);
118
- if (appendSystemPrompt !== void 0) {
119
- if (!projection.projectAppend) throw new Error(`candidate append system prompt has no native launch projection for ${plan.harness}`);
120
- projected = projection.projectAppend(omitPromptIntent(projected, "appendSystemPrompt"), requirePublicCandidateConfigValue(appendSystemPrompt, "profile.appendSystemPrompt"), posix.join(posix.dirname(systemPromptFilePath), "append-system-prompt.md"));
121
- }
122
- return projected;
82
+ if (plan.harness === "opencode" || plan.harness === "gemini") return plan;
83
+ const native = nativeSystemPrompt(plan.harness, {
84
+ ...systemPrompt === void 0 ? {} : { systemPrompt: requestedSystemPrompt },
85
+ appendSystemPrompt: requestedAppendSystemPrompt
86
+ }, systemPromptFilePath);
87
+ for (const file of native.files) if (plan.files.some((existing) => existing.relPath === file.relPath)) throw new Error(`candidate profile conflicts with reserved ${file.relPath}`);
88
+ const { systemPrompt: _system, appendSystemPrompt: _append, ...projected } = plan;
89
+ return {
90
+ ...projected,
91
+ files: [...plan.files, ...native.files],
92
+ flags: [...plan.flags, ...native.flags.map((value) => ({
93
+ kind: "public",
94
+ value
95
+ }))]
96
+ };
123
97
  }
124
98
  function assertProvableNativeLaunch(harness, expectedExecutable, launch, intent) {
125
99
  if (launch.kind !== "container-command") throw new Error(`candidate-entrypoint launch cannot prove ${harness} system-prompt ${intent}`);
126
100
  if (launch.executable !== expectedExecutable && !(posix.isAbsolute(launch.executable) && posix.basename(launch.executable) === expectedExecutable)) throw new Error(`${harness} system-prompt ${intent} requires the native ${expectedExecutable} executable`);
127
101
  }
128
- function assertNoShadowingArgs(harness, conflictsWithArgs, launch, intent) {
129
- if (conflictsWithArgs((launch.args ?? []).map((value, index) => requirePublicCandidateConfigValue(value, `launch.args[${index}]`)))) throw new Error(`${harness} launch arguments conflict with the candidate profile ${intent === "replacement" ? "system" : "append system"} prompt`);
130
- }
131
- function omitPromptIntent(plan, intent) {
132
- const projected = { ...plan };
133
- delete projected[intent];
134
- return projected;
135
- }
136
- function appendFlags(plan, ...values) {
137
- return {
138
- ...plan,
139
- flags: [...plan.flags, ...values.map(publicValue)]
140
- };
141
- }
142
- function publicValue(value) {
143
- return {
144
- kind: "public",
145
- value
146
- };
147
- }
148
- function addPromptFile(plan, relPath, prompt) {
149
- if (plan.files.some((file) => file.relPath === relPath)) throw new Error(`candidate profile conflicts with reserved ${relPath}`);
150
- return {
151
- ...plan,
152
- files: [...plan.files, {
153
- relPath,
154
- content: prompt,
155
- source: "generated"
156
- }]
157
- };
158
- }
159
- //#endregion
160
- //#region src/candidate-execution/profile.ts
102
+ // src/candidate-execution/profile.ts
161
103
  function candidateMaterializerHarness(harness) {
162
104
  if (!isMaterializerHarness(harness)) throw new Error(`sealed candidate profile materialization is unsupported for harness ${harness}`);
163
105
  return harness;
@@ -170,10 +112,32 @@ const PI_CANDIDATE_SESSION_DIR_ENV = "PI_CODING_AGENT_SESSION_DIR";
170
112
  function materializeAgentCandidateProfilePlan(options) {
171
113
  const root = options.workspace === "task" ? options.workspaces.taskRoot : options.workspaces.candidateRoot;
172
114
  if (!root) throw new Error("candidate profile target is missing its execution workspace root");
173
- return projectCandidatePromptIntents(materializeCandidateProfile(options.profile, candidateMaterializerHarness(options.harness), {
115
+ const nativePrompt = [
116
+ "claude-code",
117
+ "codex",
118
+ "pi",
119
+ "prime"
120
+ ].includes(options.harness) ? options.profile.prompt : void 0;
121
+ const { systemPrompt, appendSystemPrompt, ...structuralPrompt } = nativePrompt ?? {};
122
+ const plan = materializeCandidateProfile(nativePrompt === void 0 ? options.profile : {
123
+ ...options.profile,
124
+ prompt: structuralPrompt
125
+ }, candidateMaterializerHarness(options.harness), {
174
126
  binds: CANDIDATE_PROFILE_MATERIALIZER_BINDS,
175
127
  resolvedResources: options.resolvedResources
176
- }), options.launch, posix.join(root, ".tangle/system-prompt.md"), options.profile.prompt?.systemPrompt, options.profile.prompt?.appendSystemPrompt);
128
+ });
129
+ return projectCandidatePromptIntents(nativePrompt === void 0 ? plan : {
130
+ ...plan,
131
+ sourceProfileDigest: canonicalCandidateDigest$1(options.profile),
132
+ ...systemPrompt === void 0 ? {} : { systemPrompt: {
133
+ kind: "public",
134
+ value: systemPrompt
135
+ } },
136
+ ...appendSystemPrompt === void 0 ? {} : { appendSystemPrompt: {
137
+ kind: "public",
138
+ value: appendSystemPrompt
139
+ } }
140
+ }, options.launch, posix.join(root, ".tangle/system-prompt.md"), options.profile.prompt?.systemPrompt, options.profile.prompt?.appendSystemPrompt);
177
141
  }
178
142
  /** Resolve the private Pi roots needed by an agent-root profile plan. */
179
143
  function candidateProfileAgentPaths(plan, runtimeHome) {
@@ -271,7 +235,8 @@ function candidateProfileFromGenericProfile(profile) {
271
235
  /** Prove the measured generic profile and sealed candidate profile describe the same behavior. */
272
236
  function assertCandidateProfileBinding(measuredInput, bundled) {
273
237
  assertSandboxProfileCompatibility(measuredInput);
274
- if (canonicalCandidateDigest$1(candidateProfileFromGenericProfile(parseExactAgentProfile(measuredInput, "measured agent profile"))) !== canonicalCandidateDigest$1(bundled)) throw new Error("measured agent profile does not match sealed candidate profile");
238
+ const expected = candidateProfileFromGenericProfile(parseExactAgentProfile(measuredInput, "measured agent profile"));
239
+ if (canonicalCandidateDigest$1(expected) !== canonicalCandidateDigest$1(bundled)) throw new Error("measured agent profile does not match sealed candidate profile");
275
240
  }
276
241
  /** Parse a complete profile without silently discarding unsupported fields. */
277
242
  function parseExactAgentProfile(input, label) {
@@ -297,7 +262,9 @@ function parseExactAgentProfileDiff(input, label) {
297
262
  }
298
263
  /** Apply one exact diff and reject any value that cannot be preserved canonically. */
299
264
  function applyExactAgentProfileDiff(baseInput, diffInput, label) {
300
- return parseExactAgentProfile(omitUndefinedObjectFields(applyAgentProfileDiff(parseExactAgentProfile(baseInput, `${label} base profile`), parseExactAgentProfileDiff(diffInput, `${label} diff`)), label), `${label} result`);
265
+ const base = parseExactAgentProfile(baseInput, `${label} base profile`);
266
+ const diff = parseExactAgentProfileDiff(diffInput, `${label} diff`);
267
+ return parseExactAgentProfile(omitUndefinedObjectFields(applyAgentProfileDiff(base, diff), label), `${label} result`);
301
268
  }
302
269
  /** Parse a candidate profile without silently discarding unsupported or non-canonical fields. */
303
270
  function parseExactCandidateProfile(input) {
@@ -536,7 +503,6 @@ function exactProfileExecutorFiles(sourceFiles, expectedFiles) {
536
503
  };
537
504
  });
538
505
  }
539
- //#endregion
540
506
  export { parseAgentCandidateProfileActivation as _, applyExactAgentProfileDiff as a, parseExactCandidateProfile as b, buildLaunch as c, createAgentCandidateProfileActivation as d, exactProfileExecutorFiles as f, omitUndefinedObjectFields as g, modelRoutes as h, agentCandidateProfileAsAgentProfile as i, candidateEntrypointReceipt as l, materializeAgentCandidateProfilePlan as m, PI_CANDIDATE_SESSION_DIR_ENV as n, assertCandidateProfileBinding as o, freezeGenericAgentCandidateProfile as p, absoluteExecutionCwd as r, assertCandidateProfileExecutionSupport as s, PI_CANDIDATE_AGENT_DIR_ENV as t, candidateProfileAgentPaths as u, parseExactAgentProfile as v, requirePublicCandidateConfigValue as x, parseExactAgentProfileDiff as y };
541
507
 
542
- //# sourceMappingURL=profile-6OLpbjvV.js.map
508
+ //# sourceMappingURL=profile-CAhZDW2T.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"profile-CAhZDW2T.js","names":["canonicalCandidateDigest","canonicalCandidateBytes","sha256Bytes"],"sources":["../src/candidate-execution/public-config.ts","../src/candidate-execution/system-prompt.ts","../src/candidate-execution/profile.ts"],"sourcesContent":["import type { AgentCandidateConfigValue } from '@tangle-network/agent-interface'\nimport { ValidationError } from '../errors'\n\n/** Candidate execution has no private secret resolver; never lower a reference to argv or env. */\nexport function requirePublicCandidateConfigValue(\n value: AgentCandidateConfigValue,\n path: string,\n): string {\n if (value.kind !== 'public') {\n throw new ValidationError(\n `candidate ${path} requires a public value; secret references are unsupported`,\n )\n }\n return value.value\n}\n","import { posix } from 'node:path'\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'\nimport { nativeSystemPrompt } from '../agent/native-system-prompt'\nimport { requirePublicCandidateConfigValue } from './public-config'\n\ninterface HarnessSystemPrompt {\n readonly executable: string\n readonly conflictsWithArgs: (values: readonly string[]) => boolean\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 conflictsWithArgs: argsSetSystemPromptFlag,\n conflictsWithAppendArgs: argsSetAppendSystemPromptFlag,\n },\n codex: {\n executable: 'codex',\n conflictsWithArgs: argsSetCodexInstructionOverride,\n conflictsWithAppendArgs: argsSetCodexInstructionOverride,\n },\n opencode: {\n executable: 'opencode',\n conflictsWithArgs: (values: readonly string[]) =>\n values.some((value) => value === '--agent' || value.startsWith('--agent=')),\n conflictsWithAppendArgs: argsSetAppendSystemPromptFlag,\n },\n pi: {\n executable: 'pi',\n conflictsWithArgs: argsSetSystemPromptFlag,\n conflictsWithAppendArgs: argsSetAppendSystemPromptFlag,\n },\n prime: {\n executable: 'prime-agent',\n conflictsWithArgs: argsSetSystemPromptFlag,\n conflictsWithAppendArgs: argsSetAppendSystemPromptFlag,\n },\n gemini: {\n executable: 'gemini',\n conflictsWithArgs: argsSetSystemPromptFlag,\n conflictsWithAppendArgs: argsSetAppendSystemPromptFlag,\n },\n} satisfies Partial<Record<HarnessId, HarnessSystemPrompt>>\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 === undefined\n ? undefined\n : requirePublicCandidateConfigValue(plan.systemPrompt, 'profile.systemPrompt'),\n requestedAppendSystemPrompt: string | undefined = plan.appendSystemPrompt === undefined\n ? undefined\n : requirePublicCandidateConfigValue(plan.appendSystemPrompt, 'profile.appendSystemPrompt'),\n): AgentCandidateWorkspacePlan {\n const systemPrompt = plan.systemPrompt\n const appendSystemPrompt = plan.appendSystemPrompt\n const geminiSystem = plan.files.find((file) => file.relPath === '.gemini/system.md')\n const delivered =\n plan.harness === 'gemini' &&\n geminiSystem?.content === requestedSystemPrompt &&\n plan.env.GEMINI_SYSTEM_MD !== undefined &&\n requirePublicCandidateConfigValue(plan.env.GEMINI_SYSTEM_MD, 'profile.env.GEMINI_SYSTEM_MD') ===\n '1'\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 && !delivered) {\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 (\n systemPrompt !== undefined &&\n requirePublicCandidateConfigValue(systemPrompt, 'profile.systemPrompt') !==\n requestedSystemPrompt\n ) {\n throw new Error('profile materializer changed the candidate system prompt')\n }\n if (\n appendSystemPrompt !== undefined &&\n requirePublicCandidateConfigValue(appendSystemPrompt, 'profile.appendSystemPrompt') !==\n 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, index) =>\n requirePublicCandidateConfigValue(value, `launch.args[${index}]`),\n )\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 // These harnesses already have native file/config delivery owned by the materializer.\n if (plan.harness === 'opencode' || plan.harness === 'gemini') return plan\n const native = nativeSystemPrompt(\n plan.harness,\n {\n ...(systemPrompt === undefined ? {} : { systemPrompt: requestedSystemPrompt }),\n appendSystemPrompt: requestedAppendSystemPrompt,\n },\n systemPromptFilePath,\n )\n for (const file of native.files) {\n if (plan.files.some((existing) => existing.relPath === file.relPath)) {\n throw new Error(`candidate profile conflicts with reserved ${file.relPath}`)\n }\n }\n const { systemPrompt: _system, appendSystemPrompt: _append, ...projected } = plan\n return {\n ...projected,\n files: [...plan.files, ...native.files],\n flags: [\n ...plan.flags,\n ...native.flags.map((value): AgentCandidateConfigValue => ({ kind: 'public', value })),\n ],\n }\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","import { posix } from 'node:path'\nimport type {\n AgentCandidateConfigValue,\n AgentCandidateExecutionPlanMaterial,\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'\nimport {\n assertSandboxProfileCompatibility,\n refuseSandboxProfileField,\n} from '../runtime/sandbox-profile-compat'\nimport {\n canonicalCandidateBytes,\n canonicalCandidateDigest,\n canonicalCandidateDocument,\n embeddedCandidateArtifact,\n immutableCandidateValue,\n omitTopLevelDigest,\n sha256Bytes,\n} from './digest'\nimport { requirePublicCandidateConfigValue } from './public-config'\nimport { projectCandidatePromptIntents } from './system-prompt'\nimport type { AgentCandidateTaskExecution, VerifiedAgentCandidate } from './types'\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. */\nconst 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 nativePrompt = ['claude-code', 'codex', 'pi', 'prime'].includes(options.harness)\n ? options.profile.prompt\n : undefined\n const { systemPrompt, appendSystemPrompt, ...structuralPrompt } = nativePrompt ?? {}\n const plan = materializeCandidateProfile(\n nativePrompt === undefined\n ? options.profile\n : {\n ...options.profile,\n prompt: structuralPrompt,\n },\n candidateMaterializerHarness(options.harness),\n {\n binds: CANDIDATE_PROFILE_MATERIALIZER_BINDS,\n resolvedResources: options.resolvedResources,\n },\n )\n return projectCandidatePromptIntents(\n nativePrompt === undefined\n ? plan\n : {\n ...plan,\n sourceProfileDigest: canonicalCandidateDigest(options.profile),\n ...(systemPrompt === undefined\n ? {}\n : { systemPrompt: { kind: 'public', value: systemPrompt } }),\n ...(appendSystemPrompt === undefined\n ? {}\n : { appendSystemPrompt: { kind: 'public', value: appendSystemPrompt } }),\n },\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 assertSandboxProfileCompatibility(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 assertSandboxProfileCompatibility(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 assertSandboxProfileCompatibility(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 assertSandboxProfileCompatibility(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: [\n executable,\n ...(args ?? []).map((value, index) =>\n requirePublicCandidateConfigValue(value, `hooks.${event}.args[${index}]`),\n ),\n ]\n .map(shellQuote)\n .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\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') refuseSandboxProfileField(`${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 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\nexport function buildLaunch(\n candidate: VerifiedAgentCandidate,\n task: AgentCandidateTaskExecution,\n profileFlags: AgentCandidateConfigValue[],\n): { executable: string; args: AgentCandidateConfigValue[] } {\n const launch = candidate.bundle.execution.launch\n if (launch.kind === 'container-command') {\n return { executable: launch.executable, args: [...(launch.args ?? []), ...profileFlags] }\n }\n const candidateRoot = task.executionRoots.candidateRoot\n if (!candidateRoot) throw new Error('candidate entrypoint requires a container candidate root')\n const entrypoint = posix.join(candidateRoot, launch.entrypoint)\n const candidateArgs = launch.args ?? []\n if (launch.interpreter) {\n return {\n executable: launch.interpreter,\n args: [{ kind: 'public', value: entrypoint }, ...candidateArgs, ...profileFlags],\n }\n }\n return { executable: entrypoint, args: [...candidateArgs, ...profileFlags] }\n}\n\nexport function modelRoutes(\n profile: VerifiedAgentCandidate['bundle']['profile'],\n requested: string,\n): AgentCandidateExecutionPlanMaterial['model']['routes'] {\n const routes: AgentCandidateExecutionPlanMaterial['model']['routes'] = [\n { kind: 'primary', requested },\n ]\n if (profile.model?.small) routes.push({ kind: 'small', requested })\n for (const name of Object.keys(profile.modes ?? {}).sort()) {\n if (profile.modes?.[name]?.model) routes.push({ kind: 'mode', name, requested })\n }\n for (const name of Object.keys(profile.subagents ?? {}).sort()) {\n if (profile.subagents?.[name]?.model) routes.push({ kind: 'subagent', name, requested })\n }\n return routes\n}\n\nexport function candidateEntrypointReceipt(\n candidate: VerifiedAgentCandidate,\n): { path: string; sha256: `sha256:${string}`; byteLength: number } | undefined {\n const launch = candidate.bundle.execution.launch\n const workspace = candidate.bundle.execution.workspace\n if (launch.kind !== 'candidate-entrypoint' || !workspace) return undefined\n const file = workspace.material.files.find((entry) => entry.path === launch.entrypoint)\n if (!file) throw new Error('candidate entrypoint is absent from the verified workspace')\n return { path: file.path, sha256: file.sha256, byteLength: file.byteLength }\n}\n\nexport function absoluteExecutionCwd(\n cwd: VerifiedAgentCandidate['bundle']['execution']['cwd'],\n roots: AgentCandidateTaskExecution['executionRoots'],\n): string {\n const root = workspaceExecutionRoot(cwd.workspace, roots)\n const absolute = cwd.path === '.' ? root : posix.join(root, cwd.path)\n if (absolute !== root && !absolute.startsWith(`${root}/`)) {\n throw new Error('candidate cwd escapes its execution workspace')\n }\n return absolute\n}\n\nfunction workspaceExecutionRoot(\n workspace: 'task' | 'candidate',\n roots: AgentCandidateTaskExecution['executionRoots'],\n): string {\n const root = workspace === 'task' ? roots.taskRoot : roots.candidateRoot\n if (!root) throw new Error(`candidate ${workspace} workspace root is missing`)\n return root\n}\n\nexport function exactProfileExecutorFiles(\n sourceFiles: ReadonlyArray<{\n relPath: string\n content: string\n mode?: number\n root?: 'agent' | 'workspace'\n }>,\n expectedFiles: ReadonlyArray<{\n relPath: string\n mode: number\n contentSha256: string\n root?: 'agent'\n }>,\n): Array<{ path: string; mode: number; root?: 'agent'; bytes: Uint8Array }> {\n const byIdentity = new Map(\n sourceFiles.map((file) => [profileFileIdentity(file.root, file.relPath), file]),\n )\n if (byIdentity.size !== sourceFiles.length || sourceFiles.length !== expectedFiles.length) {\n throw new Error('profile source files do not match the signed profile plan')\n }\n return expectedFiles.map((expected) => {\n const source = byIdentity.get(profileFileIdentity(expected.root, expected.relPath))\n const mode = source?.mode ?? 0o644\n const bytes = Buffer.from(source?.content ?? '', 'utf8')\n if (\n !source ||\n !Number.isInteger(mode) ||\n mode < 0 ||\n mode > 0o777 ||\n mode !== expected.mode ||\n sha256Bytes(bytes) !== expected.contentSha256\n ) {\n throw new Error('profile source files do not match the signed profile plan')\n }\n return {\n path: expected.relPath,\n mode,\n ...(expected.root === 'agent' ? { root: 'agent' as const } : {}),\n bytes: Uint8Array.from(bytes),\n }\n })\n}\n"],"mappings":";;;;;;;AAIA,SAAgB,kCACd,OACA,MACQ;CACR,IAAI,MAAM,SAAS,UACjB,MAAM,IAAI,gBACR,aAAa,KAAK,4DACpB;CAEF,OAAO,MAAM;AACf;;ACIA,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,mBAAmB;EACnB,yBAAyB;CAC3B;CACA,OAAO;EACL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G,IAAI,CAAC,CAChF;CACA,IAAI,WAAW,SAAS,YAAY,UAAU,YAAY,WAAW,cAAc,QACjF,MAAM,IAAI,MAAM,2DAA2D;CAE7E,OAAO,cAAc,KAAK,aAAa;EACrC,MAAM,SAAS,WAAW,IAAI,oBAAoB,SAAS,MAAM,SAAS,OAAO,CAAC;EAClF,MAAM,OAAO,QAAQ,QAAQ;EAC7B,MAAM,QAAQ,OAAO,KAAK,QAAQ,WAAW,IAAI,MAAM;EACvD,IACE,CAAC,UACD,CAAC,OAAO,UAAU,IAAI,KACtB,OAAO,KACP,OAAO,OACP,SAAS,SAAS,QAClBC,cAAY,KAAK,MAAM,SAAS,eAEhC,MAAM,IAAI,MAAM,2DAA2D;EAE7E,OAAO;GACL,MAAM,SAAS;GACf;GACA,GAAI,SAAS,SAAS,UAAU,EAAE,MAAM,QAAiB,IAAI,CAAC;GAC9D,OAAO,WAAW,KAAK,KAAK;EAC9B;CACF,CAAC;AACH"}
@@ -1,6 +1,5 @@
1
1
  import { AgentProfile, CanonicalAgentProfileMaterializationAxis } from "@tangle-network/agent-interface";
2
2
  import { HarnessId, SkippableDimension, WorkspacePlan } from "@tangle-network/agent-profile-materialize";
3
- //#region src/agent/profile-materialization.d.ts
4
3
  type KnownAgentProfileMaterializationAxis = CanonicalAgentProfileMaterializationAxis;
5
4
  /** AgentProfile axis name, with `custom:<name>` reserved for caller-owned extensions. */
6
5
  type AgentProfileMaterializationAxis = KnownAgentProfileMaterializationAxis | `custom:${string}`;
@@ -44,6 +43,5 @@ interface AssertProfileMaterializationOptions extends ValidateProfileMaterializa
44
43
  * not the plan's to lower.
45
44
  */
46
45
  declare function assertProfileMaterializes(profile: AgentProfile, harness: HarnessId, context: string, skip?: readonly SkippableDimension[]): WorkspacePlan;
47
- //#endregion
48
46
  export { ProfileMaterializationContract as a, assertProfileMaterializes as c, KnownAgentProfileMaterializationAxis as i, AssertProfileMaterializationOptions as n, ProfileMaterializationIssue as o, DefineProfileMaterializationContractOptions as r, ValidateProfileMaterializationOptions as s, AgentProfileMaterializationAxis as t };
49
- //# sourceMappingURL=profile-materialization-bPm0gGLO.d.ts.map
47
+ //# sourceMappingURL=profile-materialization-BRY22Oh8.d.ts.map
@@ -1,18 +1,34 @@
1
- import { $h as UiFindingScreenshot, Qh as UiFinding, ag as ResearchSource, cg as researcherProfile, eg as UiFindingSeverity, ig as ResearchOutput, ng as KnowledgeItem, og as ResearchTask, rg as KnowledgeUpdate, sg as ResearcherProfileOptions, tg as UiLens } from "./types-hc4cmSc7.js";
1
+ import { Ag as ResearchOutput, Dg as UiLens, Eg as UiFindingSeverity, Mg as ResearchTask, Ng as ResearcherProfileOptions, Og as KnowledgeItem, Pg as researcherProfile, Tg as UiFindingScreenshot, jg as ResearchSource, kg as KnowledgeUpdate, wg as UiFinding } from "./types-Fowuwdz2.js";
2
+ import { AgentProfile } from "@tangle-network/agent-interface";
2
3
  import { SandboxEvent } from "@tangle-network/sandbox";
3
- //#region src/profiles/ui-auditor/lens-prompts.d.ts
4
+ /** Canonical owners of the separately bundled designer capabilities. */
5
+ export declare const graphDesignerSkillSources: Readonly<{
6
+ 'graph-designer': "https://github.com/tangle-network/agent-runtime/blob/main/skills/graph-designer/SKILL.md";
7
+ 'agent-graphs': "https://github.com/tangle-network/agent-runtime/blob/main/skills/agent-graphs/SKILL.md";
8
+ 'be-ambitious': "https://github.com/drewstone/dotfiles/blob/main/claude/skills/be-ambitious/SKILL.md";
9
+ }>;
10
+ type SkillResource = NonNullable<NonNullable<AgentProfile['resources']>['skills']>[number];
11
+ /** Read this installation's bundled skills without depending on a user's skill installation.
12
+ * Self-resolution follows the public profiles entry in source checkouts and packed installs. */
13
+ export declare function graphDesignerSkills(): SkillResource[];
14
+ interface GraphDesignerProfileOptions {
15
+ /** Caller-owned exact harness/model, tools, permissions, connections and other capabilities. */
16
+ readonly profile: AgentProfile;
17
+ readonly name?: string;
18
+ }
19
+ /** Compose graph design capabilities onto a complete execution profile; the skills remain
20
+ * distinct resources carried through the normal profile materializer. */
21
+ export declare function graphDesignerProfile(options: GraphDesignerProfileOptions): AgentProfile;
4
22
  /** Cross-lens rules injected into every UI audit iteration: finding quality standards and scope limits. @experimental */
5
- declare const SHARED_AUDITOR_RULES: string;
23
+ export declare const SHARED_AUDITOR_RULES: string;
6
24
  /** Per-lens auditor briefs: concrete signals to look for and cross-lens distinctions to respect. @experimental */
7
- declare const LENS_BRIEFS: Record<UiLens, string>;
25
+ export declare const LENS_BRIEFS: Record<UiLens, string>;
8
26
  /**
9
27
  * Build a system prompt for a single auditor iteration.
10
28
  *
11
29
  * @experimental
12
30
  */
13
- declare function buildAuditorSystemPrompt(lens: UiLens): string;
14
- //#endregion
15
- //#region src/profiles/ui-auditor/task.d.ts
31
+ export declare function buildAuditorSystemPrompt(lens: UiLens): string;
16
32
  /** @experimental */
17
33
  interface UiAuditViewport {
18
34
  width: number;
@@ -94,10 +110,7 @@ interface UiAuditOutput {
94
110
  /** Optional judge commentary (debug / triage aid). */
95
111
  notes?: string;
96
112
  }
97
- //#endregion
98
- //#region src/profiles/ui-auditor/output-adapter.d.ts
99
113
  /** Parse raw `SandboxEvent` emissions from an audit iteration into structured `UiAuditOutput`. @experimental */
100
- declare function parseAuditorEvents(events: SandboxEvent[]): UiAuditOutput;
101
- //#endregion
102
- export { type KnowledgeItem, type KnowledgeUpdate, LENS_BRIEFS, type ResearchOutput, type ResearchSource, type ResearchTask, type ResearcherProfileOptions, SHARED_AUDITOR_RULES, type UiAuditCapture, type UiAuditCaptureRequest, type UiAuditOutput, type UiAuditTask, type UiAuditViewport, type UiFinding, type UiFindingScreenshot, type UiFindingSeverity, type UiLens, buildAuditorSystemPrompt, parseAuditorEvents, researcherProfile };
114
+ export declare function parseAuditorEvents(events: SandboxEvent[]): UiAuditOutput;
115
+ export { type GraphDesignerProfileOptions, type KnowledgeItem, type KnowledgeUpdate, type ResearchOutput, type ResearchSource, type ResearchTask, type ResearcherProfileOptions, type UiAuditCapture, type UiAuditCaptureRequest, type UiAuditOutput, type UiAuditTask, type UiAuditViewport, type UiFinding, type UiFindingScreenshot, type UiFindingSeverity, type UiLens, researcherProfile };
103
116
  //# sourceMappingURL=profiles.d.ts.map
package/dist/profiles.js CHANGED
@@ -1,9 +1,54 @@
1
- import "./errors-DodWX-cb.js";
2
- import { t as assertExecutableAgentProfile } from "./model-policy-CyCUwHed.js";
3
- import { t as UI_LENSES } from "./substrate-CGDFTSRh.js";
1
+ import { m as ValidationError } from "./errors-wuhGvpE3.js";
2
+ import { t as assertExecutableAgentProfile } from "./model-policy-GSxWwP-b.js";
3
+ import { t as UI_LENSES } from "./substrate-Db2pp6y3.js";
4
4
  import { agentProfileSchema } from "@tangle-network/agent-interface";
5
5
  import { isRecord } from "@tangle-network/agent-core";
6
- //#region src/profiles/researcher.ts
6
+ import { readFileSync } from "node:fs";
7
+ // src/profiles/graph-designer.ts
8
+ /** Canonical owners of the separately bundled designer capabilities. */
9
+ const graphDesignerSkillSources = Object.freeze({
10
+ "graph-designer": "https://github.com/tangle-network/agent-runtime/blob/main/skills/graph-designer/SKILL.md",
11
+ "agent-graphs": "https://github.com/tangle-network/agent-runtime/blob/main/skills/agent-graphs/SKILL.md",
12
+ "be-ambitious": "https://github.com/drewstone/dotfiles/blob/main/claude/skills/be-ambitious/SKILL.md"
13
+ });
14
+ /** Read this installation's bundled skills without depending on a user's skill installation.
15
+ * Self-resolution follows the public profiles entry in source checkouts and packed installs. */
16
+ function graphDesignerSkills() {
17
+ const directory = new URL("../skills/", import.meta.resolve("@tangle-network/agent-runtime/profiles"));
18
+ return Object.keys(graphDesignerSkillSources).map((name) => ({
19
+ kind: "inline",
20
+ name,
21
+ content: readFileSync(new URL(`${name}/SKILL.md`, directory), "utf8")
22
+ }));
23
+ }
24
+ /** Compose graph design capabilities onto a complete execution profile; the skills remain
25
+ * distinct resources carried through the normal profile materializer. */
26
+ function graphDesignerProfile(options) {
27
+ const base = agentProfileSchema.parse(options.profile);
28
+ assertExecutableAgentProfile(base, "graphDesignerProfile");
29
+ const skills = [...base.resources?.skills ?? []];
30
+ for (const skill of graphDesignerSkills()) {
31
+ const existing = skills.find((resource) => resource.name === skill.name);
32
+ if (existing) {
33
+ if (JSON.stringify(existing) !== JSON.stringify(skill)) throw new ValidationError(`graphDesignerProfile: conflicting skill resource ${skill.name}`);
34
+ } else skills.push(skill);
35
+ }
36
+ return agentProfileSchema.parse({
37
+ ...base,
38
+ name: options.name ?? base.name,
39
+ description: base.description ?? "Design, replay and improve checked Runtime graphs.",
40
+ prompt: {
41
+ ...base.prompt,
42
+ instructions: [...base.prompt?.instructions ?? [], "You design or replay the graph requested by the task. Apply the bundled graph-designer, agent-graphs and be-ambitious skills; keep the task acceptance and granted authority fixed. Return the canonical graph file and its actual qualification evidence."]
43
+ },
44
+ resources: {
45
+ ...base.resources,
46
+ skills,
47
+ failOnError: true
48
+ }
49
+ });
50
+ }
51
+ // src/profiles/researcher.ts
7
52
  /**
8
53
  * Opinionated preset for source-grounded research
9
54
  * tasks. The agent is told to:
@@ -414,8 +459,7 @@ function clamp01(value) {
414
459
  if (value > 1) return 1;
415
460
  return value;
416
461
  }
417
- //#endregion
418
- //#region src/profiles/ui-auditor/lens-prompts.ts
462
+ // src/profiles/ui-auditor/lens-prompts.ts
419
463
  /** Cross-lens rules injected into every UI audit iteration: finding quality standards and scope limits. @experimental */
420
464
  const SHARED_AUDITOR_RULES = `
421
465
  You are auditing a UI for a specific class of problems. Stay strictly in your assigned lens — do not file issues that belong to another lens (a separate iteration will catch those).
@@ -530,8 +574,7 @@ function buildAuditorSystemPrompt(lens) {
530
574
  const brief = LENS_BRIEFS[lens];
531
575
  return `${SHARED_AUDITOR_RULES}\n\n${brief}`;
532
576
  }
533
- //#endregion
534
- //#region src/profiles/ui-auditor/output-adapter.ts
577
+ // src/profiles/ui-auditor/output-adapter.ts
535
578
  const KNOWN_LENS_VALUES = new Set(UI_LENSES);
536
579
  function isUiLens(v) {
537
580
  return typeof v === "string" && KNOWN_LENS_VALUES.has(v);
@@ -585,7 +628,6 @@ function parseAuditorEvents(events) {
585
628
  if (typeof n === "string" && n.trim().length > 0) notes = n;
586
629
  break;
587
630
  }
588
- default: break;
589
631
  }
590
632
  }
591
633
  const out = {
@@ -596,7 +638,6 @@ function parseAuditorEvents(events) {
596
638
  if (notes) out.notes = notes;
597
639
  return out;
598
640
  }
599
- //#endregion
600
- export { LENS_BRIEFS, SHARED_AUDITOR_RULES, buildAuditorSystemPrompt, parseAuditorEvents, researcherProfile };
641
+ export { LENS_BRIEFS, SHARED_AUDITOR_RULES, buildAuditorSystemPrompt, graphDesignerProfile, graphDesignerSkillSources, graphDesignerSkills, parseAuditorEvents, researcherProfile };
601
642
 
602
643
  //# sourceMappingURL=profiles.js.map