@arnilo/prism-hosts 0.0.0-stage → 0.13.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 (322) hide show
  1. package/CHANGELOG.md +394 -0
  2. package/LICENSE +21 -0
  3. package/README.md +34 -2
  4. package/acp/README.md +87 -0
  5. package/acp/src/capabilities.ts +184 -0
  6. package/acp/src/errors.ts +24 -0
  7. package/acp/src/host.ts +36 -0
  8. package/acp/src/index.ts +25 -0
  9. package/acp/src/limits.ts +49 -0
  10. package/acp/src/mapper.ts +419 -0
  11. package/acp/src/permission.ts +37 -0
  12. package/acp/src/projection.ts +39 -0
  13. package/acp/src/prompt.ts +170 -0
  14. package/acp/src/serve.ts +345 -0
  15. package/acp/src/session-map.ts +49 -0
  16. package/ag-ui/README.md +56 -0
  17. package/ag-ui/src/a2ui.ts +570 -0
  18. package/ag-ui/src/ag-ui-mapper.ts +507 -0
  19. package/ag-ui/src/encrypted-value.ts +40 -0
  20. package/ag-ui/src/errors.ts +29 -0
  21. package/ag-ui/src/handler.ts +642 -0
  22. package/ag-ui/src/index.ts +177 -0
  23. package/ag-ui/src/input.ts +190 -0
  24. package/ag-ui/src/limits.ts +279 -0
  25. package/ag-ui/src/mcp-apps.ts +256 -0
  26. package/ag-ui/src/mcp.ts +94 -0
  27. package/ag-ui/src/projection.ts +201 -0
  28. package/ag-ui/src/projectors.ts +272 -0
  29. package/ag-ui/src/renderer/bind.ts +152 -0
  30. package/ag-ui/src/renderer/core.ts +270 -0
  31. package/ag-ui/src/renderer/index.ts +165 -0
  32. package/ag-ui/src/replay.ts +189 -0
  33. package/ag-ui/src/types.ts +66 -0
  34. package/channels/README.md +139 -0
  35. package/channels/src/admission.ts +8 -0
  36. package/channels/src/approvals.ts +262 -0
  37. package/channels/src/checkpoint-contract.ts +97 -0
  38. package/channels/src/delivery.ts +116 -0
  39. package/channels/src/host-ui.ts +356 -0
  40. package/channels/src/identity.ts +46 -0
  41. package/channels/src/index.ts +82 -0
  42. package/channels/src/limits.ts +49 -0
  43. package/channels/src/memory-stores.ts +112 -0
  44. package/channels/src/pairing.ts +178 -0
  45. package/channels/src/runtime-admit.ts +389 -0
  46. package/channels/src/runtime-core.ts +621 -0
  47. package/channels/src/runtime-reconcile.ts +299 -0
  48. package/channels/src/runtime-turn.ts +664 -0
  49. package/channels/src/runtime-types.ts +95 -0
  50. package/channels/src/runtime.ts +86 -0
  51. package/channels/src/secret-ref.ts +42 -0
  52. package/channels/src/signal.ts +790 -0
  53. package/channels/src/state.ts +355 -0
  54. package/channels/src/telegram.ts +1317 -0
  55. package/channels/src/types.ts +442 -0
  56. package/devtools/README.md +92 -0
  57. package/devtools/bin/prism-devtools.ts +63 -0
  58. package/devtools/src/args.ts +71 -0
  59. package/devtools/src/bun.d.ts +27 -0
  60. package/devtools/src/compare.ts +190 -0
  61. package/devtools/src/errors.ts +15 -0
  62. package/devtools/src/index.ts +25 -0
  63. package/devtools/src/replay.ts +36 -0
  64. package/devtools/src/security.ts +80 -0
  65. package/devtools/src/serve.ts +259 -0
  66. package/devtools/src/ui/assets.ts +108 -0
  67. package/devtools/src/ui/inspector.ts +182 -0
  68. package/driver-process/README.md +197 -0
  69. package/driver-process/src/abort.ts +74 -0
  70. package/driver-process/src/adapter.ts +211 -0
  71. package/driver-process/src/driver.ts +303 -0
  72. package/driver-process/src/errors.ts +17 -0
  73. package/driver-process/src/extend.ts +72 -0
  74. package/driver-process/src/index.ts +5 -0
  75. package/driver-process/src/inspect.ts +33 -0
  76. package/driver-process/src/session.ts +72 -0
  77. package/driver-process/src/testing.ts +394 -0
  78. package/driver-process/src/transports/json-rpc.ts +147 -0
  79. package/driver-process/src/transports/jsonl-stream.ts +12 -0
  80. package/driver-process/src/transports/types.ts +11 -0
  81. package/driver-process/src/turn.ts +106 -0
  82. package/evals/README.md +843 -0
  83. package/evals/src/calibration.ts +179 -0
  84. package/evals/src/citation-integrity.ts +98 -0
  85. package/evals/src/citations.ts +45 -0
  86. package/evals/src/compare-experiments.ts +153 -0
  87. package/evals/src/comparison.ts +230 -0
  88. package/evals/src/curate.ts +257 -0
  89. package/evals/src/dataset.ts +81 -0
  90. package/evals/src/erp-invariants.ts +163 -0
  91. package/evals/src/errors.ts +23 -0
  92. package/evals/src/experiment.ts +537 -0
  93. package/evals/src/failure-injection.ts +77 -0
  94. package/evals/src/feedback.ts +53 -0
  95. package/evals/src/index.ts +198 -0
  96. package/evals/src/injection.ts +247 -0
  97. package/evals/src/judge-panel.ts +109 -0
  98. package/evals/src/judge.ts +89 -0
  99. package/evals/src/limits.ts +50 -0
  100. package/evals/src/report-record.ts +47 -0
  101. package/evals/src/rubric-judge.ts +334 -0
  102. package/evals/src/scenario-runner.ts +317 -0
  103. package/evals/src/scenarios.ts +81 -0
  104. package/evals/src/score.ts +328 -0
  105. package/evals/src/scorer.ts +21 -0
  106. package/evals/src/state-match.ts +130 -0
  107. package/evals/src/stats.ts +635 -0
  108. package/evals/src/threshold.ts +117 -0
  109. package/evals/src/timeline.ts +38 -0
  110. package/evals/src/toolless-session.ts +33 -0
  111. package/evals/src/trace.ts +80 -0
  112. package/evals/src/trajectory.ts +623 -0
  113. package/evals/src/types.ts +672 -0
  114. package/evals/src/user-simulator.ts +101 -0
  115. package/evals/src/util.ts +207 -0
  116. package/headless/README.md +172 -0
  117. package/headless/src/answers.ts +91 -0
  118. package/headless/src/authority.ts +32 -0
  119. package/headless/src/errors.ts +36 -0
  120. package/headless/src/index.ts +17 -0
  121. package/headless/src/limits.ts +11 -0
  122. package/headless/src/pending.ts +16 -0
  123. package/headless/src/policy.ts +36 -0
  124. package/headless/src/resume.ts +103 -0
  125. package/headless/src/route.ts +153 -0
  126. package/headless/src/scheduler/clock.ts +22 -0
  127. package/headless/src/scheduler/cron.ts +19 -0
  128. package/headless/src/scheduler/firing.ts +58 -0
  129. package/headless/src/scheduler/index.ts +399 -0
  130. package/headless/src/scheduler/lease.ts +38 -0
  131. package/headless/src/scheduler/missed.ts +12 -0
  132. package/headless/src/scheduler/state.ts +132 -0
  133. package/host-builder/README.md +251 -0
  134. package/host-builder/bin/prism-host-builder.ts +169 -0
  135. package/host-builder/data/api.json +6167 -0
  136. package/host-builder/data/errors.json +546 -0
  137. package/host-builder/data/examples/acp.ts +63 -0
  138. package/host-builder/data/examples/adapters/conformance.ts +34 -0
  139. package/host-builder/data/examples/adapters/fixtures/rpc-server.json +26 -0
  140. package/host-builder/data/examples/adapters/fixtures/stream-cli.json +27 -0
  141. package/host-builder/data/examples/adapters/fixtures/workspace-config.json +28 -0
  142. package/host-builder/data/examples/adapters/rpc-server.dialect.ts +218 -0
  143. package/host-builder/data/examples/adapters/rpc-server.ts +309 -0
  144. package/host-builder/data/examples/adapters/stream-cli.dialect.ts +165 -0
  145. package/host-builder/data/examples/adapters/stream-cli.ts +256 -0
  146. package/host-builder/data/examples/adapters/workspace-config.dialect.ts +172 -0
  147. package/host-builder/data/examples/adapters/workspace-config.ts +251 -0
  148. package/host-builder/data/examples/advisor.ts +94 -0
  149. package/host-builder/data/examples/ag-ui-a2ui.ts +80 -0
  150. package/host-builder/data/examples/ag-ui-mcp-apps.ts +44 -0
  151. package/host-builder/data/examples/ag-ui-server.ts +118 -0
  152. package/host-builder/data/examples/agent-durable-approval.ts +43 -0
  153. package/host-builder/data/examples/api-key-auth.ts +23 -0
  154. package/host-builder/data/examples/approval.ts +92 -0
  155. package/host-builder/data/examples/attention-compiler.ts +81 -0
  156. package/host-builder/data/examples/autonomous-coding-loop.ts +343 -0
  157. package/host-builder/data/examples/behavior-evaluation.ts +303 -0
  158. package/host-builder/data/examples/build-workflow.ts +334 -0
  159. package/host-builder/data/examples/cache-aware-prompt-assembly.ts +139 -0
  160. package/host-builder/data/examples/caveman-ponytail.ts +197 -0
  161. package/host-builder/data/examples/cli.ts +31 -0
  162. package/host-builder/data/examples/coding-approval.ts +115 -0
  163. package/host-builder/data/examples/coding-browser-evaluation.ts +208 -0
  164. package/host-builder/data/examples/coding-compaction.ts +30 -0
  165. package/host-builder/data/examples/coding-goal-verify.ts +121 -0
  166. package/host-builder/data/examples/coding-tools-capability-gaps.ts +75 -0
  167. package/host-builder/data/examples/compaction.ts +36 -0
  168. package/host-builder/data/examples/connected-slack-mcp.ts +67 -0
  169. package/host-builder/data/examples/context.ts +29 -0
  170. package/host-builder/data/examples/custom-adapter.ts +256 -0
  171. package/host-builder/data/examples/custom-builders.ts +66 -0
  172. package/host-builder/data/examples/custom-loop.ts +89 -0
  173. package/host-builder/data/examples/custom-provider.ts +70 -0
  174. package/host-builder/data/examples/custom-session-store.ts +72 -0
  175. package/host-builder/data/examples/custom-tools-skills-context.ts +97 -0
  176. package/host-builder/data/examples/decision-models.ts +98 -0
  177. package/host-builder/data/examples/define-package.ts +188 -0
  178. package/host-builder/data/examples/delegate.ts +200 -0
  179. package/host-builder/data/examples/discover-skills.ts +65 -0
  180. package/host-builder/data/examples/drive-rag-sync.ts +44 -0
  181. package/host-builder/data/examples/durable-approval.ts +139 -0
  182. package/host-builder/data/examples/durable-investigation.ts +93 -0
  183. package/host-builder/data/examples/durable-loops-and-approvals.ts +94 -0
  184. package/host-builder/data/examples/enterprise-identity.ts +21 -0
  185. package/host-builder/data/examples/enterprise-policy-audit.ts +50 -0
  186. package/host-builder/data/examples/enterprise-work-connectors.ts +103 -0
  187. package/host-builder/data/examples/eval-injection.ts +73 -0
  188. package/host-builder/data/examples/eval-judges.ts +145 -0
  189. package/host-builder/data/examples/evals.ts +86 -0
  190. package/host-builder/data/examples/evaluation-gate.ts +40 -0
  191. package/host-builder/data/examples/execution-timeline.ts +173 -0
  192. package/host-builder/data/examples/external-agent.ts +541 -0
  193. package/host-builder/data/examples/external-app-db-backed.ts +344 -0
  194. package/host-builder/data/examples/governance-deny.ts +122 -0
  195. package/host-builder/data/examples/guardrail-packs.ts +240 -0
  196. package/host-builder/data/examples/headless-host.ts +245 -0
  197. package/host-builder/data/examples/hooks-audit-command.mjs +31 -0
  198. package/host-builder/data/examples/hooks-json.ts +87 -0
  199. package/host-builder/data/examples/host-builder-agent.ts +150 -0
  200. package/host-builder/data/examples/host-hooks.ts +71 -0
  201. package/host-builder/data/examples/host-step-loop-timeline.ts +212 -0
  202. package/host-builder/data/examples/hosted-sandbox.ts +48 -0
  203. package/host-builder/data/examples/instruction-injection.ts +127 -0
  204. package/host-builder/data/examples/jsonl-stores-branching.ts +49 -0
  205. package/host-builder/data/examples/long-term-memory.ts +158 -0
  206. package/host-builder/data/examples/manifest.ts +112 -0
  207. package/host-builder/data/examples/mcp-server.ts +48 -0
  208. package/host-builder/data/examples/mcp-trust.ts +173 -0
  209. package/host-builder/data/examples/memory-and-wiki.ts +315 -0
  210. package/host-builder/data/examples/memory-lifecycle.ts +302 -0
  211. package/host-builder/data/examples/memory-system.ts +252 -0
  212. package/host-builder/data/examples/messaging-agent.ts +70 -0
  213. package/host-builder/data/examples/minimal-host-app.ts +41 -0
  214. package/host-builder/data/examples/model-router-aggregate-budgets.ts +364 -0
  215. package/host-builder/data/examples/model-router.ts +106 -0
  216. package/host-builder/data/examples/obscura.ts +48 -0
  217. package/host-builder/data/examples/observability.ts +116 -0
  218. package/host-builder/data/examples/open-connector-sidecar.ts +105 -0
  219. package/host-builder/data/examples/openai-compatible.ts +70 -0
  220. package/host-builder/data/examples/package-skills.ts +85 -0
  221. package/host-builder/data/examples/phase9-coding-intelligence.ts +221 -0
  222. package/host-builder/data/examples/provider-registration.ts +29 -0
  223. package/host-builder/data/examples/provider-resolver.ts +39 -0
  224. package/host-builder/data/examples/rag.ts +40 -0
  225. package/host-builder/data/examples/remote-agent-server.ts +45 -0
  226. package/host-builder/data/examples/remote-agent.ts +124 -0
  227. package/host-builder/data/examples/research-ledger.ts +79 -0
  228. package/host-builder/data/examples/revocation-propagation.ts +287 -0
  229. package/host-builder/data/examples/run-feedback.ts +93 -0
  230. package/host-builder/data/examples/scanned-document-rag.ts +48 -0
  231. package/host-builder/data/examples/sdk-basics.ts +21 -0
  232. package/host-builder/data/examples/secure-agent.ts +55 -0
  233. package/host-builder/data/examples/semantic-memory.ts +52 -0
  234. package/host-builder/data/examples/serve-tools.ts +495 -0
  235. package/host-builder/data/examples/session-memory.ts +317 -0
  236. package/host-builder/data/examples/session-search.ts +131 -0
  237. package/host-builder/data/examples/session.ts +52 -0
  238. package/host-builder/data/examples/side-call.ts +64 -0
  239. package/host-builder/data/examples/signal-agent.ts +9 -0
  240. package/host-builder/data/examples/skills-progressive-disclosure.ts +88 -0
  241. package/host-builder/data/examples/skills.ts +19 -0
  242. package/host-builder/data/examples/sqlite-resume.ts +147 -0
  243. package/host-builder/data/examples/system-project-prompts.ts +74 -0
  244. package/host-builder/data/examples/system-prompts.ts +19 -0
  245. package/host-builder/data/examples/telegram-agent.ts +30 -0
  246. package/host-builder/data/examples/tool-narrowing-planes.ts +99 -0
  247. package/host-builder/data/examples/tools.ts +29 -0
  248. package/host-builder/data/examples/validator.ts +67 -0
  249. package/host-builder/data/examples/web-no-key.ts +85 -0
  250. package/host-builder/data/examples/web-research.ts +35 -0
  251. package/host-builder/data/examples/workflow-event-sink.ts +114 -0
  252. package/host-builder/data/examples/workflow-loop.ts +93 -0
  253. package/host-builder/data/examples/workflow-multimodal-document.ts +94 -0
  254. package/host-builder/data/examples/workflow-parallel-research.ts +111 -0
  255. package/host-builder/data/examples/workflow-postgres-resume.ts +75 -0
  256. package/host-builder/data/examples/workflow-research-and-review.ts +98 -0
  257. package/host-builder/data/examples/workflow-sqlite-resume.ts +163 -0
  258. package/host-builder/data/examples.json +130 -0
  259. package/host-builder/skills/prism-host-builder/SKILL.md +85 -0
  260. package/host-builder/skills/prism-host-builder/references/choosing.md +101 -0
  261. package/host-builder/skills/prism-host-builder/references/layout.md +52 -0
  262. package/host-builder/skills/prism-host-builder/references/pitfalls.md +50 -0
  263. package/host-builder/skills/prism-host-builder/references/recipes.md +129 -0
  264. package/host-builder/skills/prism-host-builder/references/security.md +52 -0
  265. package/host-builder/skills/prism-host-builder/references/upgrading.md +67 -0
  266. package/host-builder/skills/prism-host-builder/references/verification.md +108 -0
  267. package/host-builder/src/check/child.ts +108 -0
  268. package/host-builder/src/check/conformance.ts +13 -0
  269. package/host-builder/src/check/inspect.ts +20 -0
  270. package/host-builder/src/check/manifest.ts +23 -0
  271. package/host-builder/src/check/runner.ts +181 -0
  272. package/host-builder/src/check/targets.ts +65 -0
  273. package/host-builder/src/errors.ts +35 -0
  274. package/host-builder/src/index.ts +25 -0
  275. package/host-builder/src/indexes.ts +145 -0
  276. package/host-builder/src/install/install.ts +400 -0
  277. package/host-builder/src/install/targets.ts +50 -0
  278. package/host-builder/src/lookup/api.ts +127 -0
  279. package/host-builder/src/lookup/bound.ts +38 -0
  280. package/host-builder/src/lookup/docs.ts +238 -0
  281. package/host-builder/src/lookup/errors.ts +92 -0
  282. package/host-builder/src/lookup/examples.ts +117 -0
  283. package/host-builder/src/lookup/text.ts +60 -0
  284. package/host-builder/src/server.ts +300 -0
  285. package/host-builder/src/version.ts +38 -0
  286. package/mcp-server/README.md +219 -0
  287. package/mcp-server/src/bounds.ts +23 -0
  288. package/mcp-server/src/host.ts +31 -0
  289. package/mcp-server/src/index.ts +27 -0
  290. package/mcp-server/src/serve-tools.ts +408 -0
  291. package/mcp-server/src/serve.ts +329 -0
  292. package/mcp-server/src/server.ts +331 -0
  293. package/mcp-server/src/session-map.ts +47 -0
  294. package/mcp-server/src/skill-resources.ts +85 -0
  295. package/mcp-server/src/types.ts +215 -0
  296. package/package.json +130 -4
  297. package/remote/README.md +244 -0
  298. package/remote/src/attribution.ts +22 -0
  299. package/remote/src/auth.ts +30 -0
  300. package/remote/src/bun-module.d.ts +34 -0
  301. package/remote/src/channel.ts +86 -0
  302. package/remote/src/connect.ts +212 -0
  303. package/remote/src/dispatcher.ts +282 -0
  304. package/remote/src/errors.ts +59 -0
  305. package/remote/src/host-ui.ts +152 -0
  306. package/remote/src/http-gate.ts +43 -0
  307. package/remote/src/index.ts +53 -0
  308. package/remote/src/jsonl.ts +69 -0
  309. package/remote/src/limits.ts +43 -0
  310. package/remote/src/mirror.ts +90 -0
  311. package/remote/src/pending.ts +22 -0
  312. package/remote/src/protocol.ts +107 -0
  313. package/remote/src/serve.ts +560 -0
  314. package/remote/src/session-proxy.ts +219 -0
  315. package/remote/src/sse.ts +38 -0
  316. package/remote/src/stdio-client.ts +41 -0
  317. package/remote/src/testing-fixtures/serve-stdio.ts +32 -0
  318. package/remote/src/testing.ts +230 -0
  319. package/remote/src/transport.ts +139 -0
  320. package/remote/src/transports/client.ts +126 -0
  321. package/remote/src/transports/network.ts +268 -0
  322. package/remote/src/wire.ts +244 -0
@@ -0,0 +1,163 @@
1
+ import { createWorkflowTransitionChannel, type WorkflowEvent } from "@arnilo/prism-extensions/workflows";
2
+ import { unlinkSync } from "node:fs";
3
+ import { createAgent, createSecretRedactor, providerDone, providerTextDelta, providerUsage } from "@arnilo/prism";
4
+ import { createMockProvider } from "@arnilo/prism/testing";
5
+ import {
6
+ agentNode,
7
+ createWorkflowCheckpoints,
8
+ defineWorkflow,
9
+ functionNode,
10
+ resumeWorkflow,
11
+ runWorkflow,
12
+ type WorkflowRunResult,
13
+ } from "@arnilo/prism-extensions/workflows";
14
+ import { createSqlitePersistence } from "@arnilo/prism-extensions/store-sqlite";
15
+ import { providerPackage } from "@arnilo/prism/provider-kit";
16
+
17
+ // SQLite durable checkpoint, abort, and resume. A two-node workflow writes
18
+ // to a temp SQLite database; checkpoint survives the function node then
19
+ // resumes from the checkpoint after a "crash". Uses mock providers — no network.
20
+
21
+ const DB_PATH = ".workflow-resume-demo.db";
22
+
23
+ const provider = createMockProvider([
24
+ providerTextDelta("Hello from agent."),
25
+ providerUsage({ inputTokens: 4, outputTokens: 2, totalTokens: 6 }),
26
+ providerDone(),
27
+ ]);
28
+
29
+ const agent = await createAgent({
30
+ model: { provider: "mock", model: "demo" },
31
+ packages: [providerPackage("test-provider", [provider])],
32
+ });
33
+
34
+ const echoNode = functionNode({
35
+ execute: async (ctx) => {
36
+ // Simulate work that takes long enough for a checkpoint to land.
37
+ await new Promise((r) => setTimeout(r, 20));
38
+ return { echoed: ctx.workflowInput };
39
+ },
40
+ });
41
+
42
+ const agentNodeDef = agentNode({
43
+ agent,
44
+ input: (ctx) => ctx.upstream.echo,
45
+ });
46
+
47
+ const workflow = defineWorkflow({
48
+ revision: "1",
49
+ id: "durable-demo",
50
+ nodes: { echo: echoNode, agent: agentNodeDef },
51
+ edges: [["echo", "agent"]],
52
+ limits: { maxConcurrency: 1, maxNodes: 32 },
53
+ });
54
+
55
+ async function runFresh(): Promise<WorkflowRunResult> {
56
+ const persistence = createSqlitePersistence({ filename: DB_PATH });
57
+ const redactor = createSecretRedactor([]);
58
+ const checkpoints = createWorkflowCheckpoints({ store: persistence.checkpoints, redactor });
59
+ const events: WorkflowEvent[] = [];
60
+
61
+ const result = await runWorkflow(
62
+ workflow,
63
+ { input: "hello" },
64
+ {
65
+ checkpoints,
66
+ redactor,
67
+ ownership: { tenantId: "demo" },
68
+ signal: AbortSignal.timeout(30_000),
69
+ transitions: workflowEvents((e) => events.push(e)),
70
+ },
71
+ );
72
+
73
+ persistence.close();
74
+ return result;
75
+ }
76
+
77
+ async function resumeRun(runId: string): Promise<WorkflowRunResult> {
78
+ const persistence = createSqlitePersistence({ filename: DB_PATH });
79
+ const redactor = createSecretRedactor([]);
80
+ const checkpoints = createWorkflowCheckpoints({ store: persistence.checkpoints, redactor });
81
+ const events: WorkflowEvent[] = [];
82
+
83
+ const result = await resumeWorkflow(
84
+ workflow,
85
+ { runId },
86
+ {
87
+ checkpoints,
88
+ redactor,
89
+ ownership: { tenantId: "demo" },
90
+ signal: AbortSignal.timeout(30_000),
91
+ transitions: workflowEvents((e) => events.push(e)),
92
+ },
93
+ );
94
+
95
+ persistence.close();
96
+ return result;
97
+ }
98
+
99
+ export async function demo() {
100
+ // Clean up from previous runs
101
+ try {
102
+ unlinkSync(DB_PATH);
103
+ } catch {
104
+ /* ok */
105
+ }
106
+ try {
107
+ unlinkSync(`${DB_PATH}-wal`);
108
+ } catch {
109
+ /* ok */
110
+ }
111
+ try {
112
+ unlinkSync(`${DB_PATH}-shm`);
113
+ } catch {
114
+ /* ok */
115
+ }
116
+
117
+ // 1. Fresh run — should succeed
118
+ const fresh = await runFresh();
119
+
120
+ // 2. Resume the same runId — already succeeded, should return immediately
121
+ const resumed = await resumeRun(fresh.runId);
122
+
123
+ // Cleanup
124
+ try {
125
+ unlinkSync(DB_PATH);
126
+ } catch {
127
+ /* ok */
128
+ }
129
+ try {
130
+ unlinkSync(`${DB_PATH}-wal`);
131
+ } catch {
132
+ /* ok */
133
+ }
134
+ try {
135
+ unlinkSync(`${DB_PATH}-shm`);
136
+ } catch {
137
+ /* ok */
138
+ }
139
+
140
+ return {
141
+ freshStatus: fresh.status,
142
+ freshOutputs: Object.keys(fresh.outputs),
143
+ resumedStatus: resumed.status,
144
+ sameRunId: fresh.runId === resumed.runId,
145
+ durable: resumed.status === "succeeded",
146
+ };
147
+ }
148
+
149
+ export async function main() {
150
+ console.log(JSON.stringify(await demo()));
151
+ }
152
+
153
+ if (import.meta.url === `file://${process.argv[1]}`) {
154
+ await main();
155
+ }
156
+
157
+ function workflowEvents(consume: (event: WorkflowEvent) => void) {
158
+ const channel = createWorkflowTransitionChannel({ workflowId: "events", runId: "events" });
159
+ void (async () => {
160
+ for await (const event of channel.subscribe()) consume(event);
161
+ })();
162
+ return channel;
163
+ }
@@ -0,0 +1,130 @@
1
+ {
2
+ "schemaVersion": 1,
3
+ "prismVersion": "0.13.0",
4
+ "contentHash": "fbfb2db980043952efe5f334532e72096e866d8b64a66af591fd659685af17f7",
5
+ "examples": [
6
+ {"path":"examples/acp.ts","title":"acp","gate":"executed","imports":["@arnilo/prism","@arnilo/prism-extensions/approval","@arnilo/prism-hosts/acp","@arnilo/prism/testing"],"requiresEnv":[],"needsCredentials":false},
7
+ {"path":"examples/advisor.ts","title":"Advisor Demo (plan 191 Task 8).","gate":"executed","imports":["@arnilo/prism","@arnilo/prism-extensions/advisor","@arnilo/prism/provider-kit"],"requiresEnv":[],"needsCredentials":false},
8
+ {"path":"examples/ag-ui-a2ui.ts","title":"ag-ui-a2ui","gate":"executed","imports":["@arnilo/prism","@arnilo/prism-hosts/ag-ui","@arnilo/prism/provider-kit"],"requiresEnv":[],"needsCredentials":false},
9
+ {"path":"examples/ag-ui-mcp-apps.ts","title":"ag-ui-mcp-apps","gate":"executed","imports":["@arnilo/prism-extensions/mcp","@arnilo/prism-hosts/ag-ui"],"requiresEnv":[],"needsCredentials":false},
10
+ {"path":"examples/ag-ui-server.ts","title":"1. Initial run: the agent asks to call a tool and the run suspends as an AG-UI interrupt.","gate":"executed","imports":["@arnilo/prism","@arnilo/prism-hosts/ag-ui","@arnilo/prism/provider-kit"],"requiresEnv":[],"needsCredentials":false},
11
+ {"path":"examples/agent-durable-approval.ts","title":"Network-free durable approval: no tool side effect occurs before resume approval. The suspension","gate":"executed","imports":["@arnilo/prism","@arnilo/prism/provider-kit"],"requiresEnv":[],"needsCredentials":false},
12
+ {"path":"examples/api-key-auth.ts","title":"Compose an explicit API-key resolver order through the credentials slot. Prism","gate":"executed","imports":["@arnilo/prism"],"requiresEnv":[],"needsCredentials":false},
13
+ {"path":"examples/approval.ts","title":"The host gate: every `delete_file` call needs a person's yes.","gate":"executed","imports":["@arnilo/prism","@arnilo/prism/testing"],"requiresEnv":[],"needsCredentials":false},
14
+ {"path":"examples/attention-compiler.ts","title":"Attention compiler, no credentials and no network: one pass stays byte-identical because the","gate":"executed","imports":["@arnilo/prism","@arnilo/prism-extensions/context-engineering"],"requiresEnv":[],"needsCredentials":false},
15
+ {"path":"examples/autonomous-coding-loop.ts","title":"Each child is a bounded one-shot agent (limits only narrow); `@arnilo/prism-extensions/delegate` is the model-facing form.","gate":"executed","imports":["@arnilo/prism","@arnilo/prism-extensions/workflows","@arnilo/prism-memory-system","@arnilo/prism-tools/coding","@arnilo/prism/provider-kit","@arnilo/prism/testing"],"requiresEnv":[],"needsCredentials":false},
16
+ {"path":"examples/behavior-evaluation.ts","title":"The host gate: `write_record` needs a person's yes, answered inline (the kernel sends a `confirm`).","gate":"executed","imports":["@arnilo/prism","@arnilo/prism-extensions/governance","@arnilo/prism-hosts/evals","@arnilo/prism-tools/work/connectors","@arnilo/prism/provider-kit","@arnilo/prism/testing"],"requiresEnv":[],"needsCredentials":false},
17
+ {"path":"examples/build-workflow.ts","title":"Every agent gets the one workspace service, so a worktree the workflow creates is the one a driver resolves.","gate":"executed","imports":["@arnilo/prism","@arnilo/prism-extensions/store-sqlite","@arnilo/prism-extensions/workflows","@arnilo/prism-hosts/driver-process","@arnilo/prism-tools/coding","@arnilo/prism/driver-kit","@arnilo/prism/testing"],"requiresEnv":[],"needsCredentials":false},
18
+ {"path":"examples/cache-aware-prompt-assembly.ts","title":"Host context is a `context.build` handler now, so this assembler call sees only what the","gate":"executed","imports":["@arnilo/prism","@arnilo/prism-ai/hyper","@arnilo/prism-ai/opencode-go","@arnilo/prism/provider-kit"],"requiresEnv":[],"needsCredentials":false},
19
+ {"path":"examples/caveman-ponytail.ts","title":"Host-owned persona packages: upstream skills loaded from disk, progressive catalog,","gate":"executed","imports":["@arnilo/prism","@arnilo/prism/node/contribution-discovery","@arnilo/prism/testing"],"requiresEnv":[],"needsCredentials":false},
20
+ {"path":"examples/cli.ts","title":"CLI public surface is the `prism` bin (print/json/rpc), an adapter over the","gate":"executed","imports":[],"requiresEnv":[],"needsCredentials":false},
21
+ {"path":"examples/coding-approval.ts","title":"1. `ask` mode: the edit asks, the scripted host answers, the file changes.","gate":"executed","imports":["@arnilo/prism","@arnilo/prism-extensions/approval","@arnilo/prism-extensions/context-files","@arnilo/prism-tools/coding","@arnilo/prism/testing"],"requiresEnv":[],"needsCredentials":false},
22
+ {"path":"examples/coding-browser-evaluation.ts","title":"Network-free coding + browser adversarial evaluation example for 0.0.9.","gate":"executed","imports":["@arnilo/prism","@arnilo/prism-hosts/evals","@arnilo/prism-tools/browser","@arnilo/prism-tools/coding","@arnilo/prism/provider-kit"],"requiresEnv":[],"needsCredentials":false},
23
+ {"path":"examples/coding-compaction.ts","title":"Coding-focused LLM compaction stays normal bounded compaction: raw history","gate":"executed","imports":["@arnilo/prism","@arnilo/prism-extensions/compaction","@arnilo/prism/testing"],"requiresEnv":[],"needsCredentials":false},
24
+ {"path":"examples/coding-goal-verify.ts","title":"coding-goal-verify","gate":"executed","imports":["@arnilo/prism","@arnilo/prism-extensions/workflows","@arnilo/prism-tools/coding"],"requiresEnv":[],"needsCredentials":false},
25
+ {"path":"examples/coding-tools-capability-gaps.ts","title":"coding-tools-capability-gaps","gate":"executed","imports":["@arnilo/prism","@arnilo/prism-tools/coding"],"requiresEnv":[],"needsCredentials":false},
26
+ {"path":"examples/compaction.ts","title":"LLM compaction as a package: it claims the `compaction` slot and summarizes the","gate":"executed","imports":["@arnilo/prism","@arnilo/prism-extensions/compaction","@arnilo/prism/testing"],"requiresEnv":[],"needsCredentials":false},
27
+ {"path":"examples/connected-slack-mcp.ts","title":"Production hosts select the exact Slack MCP command/origin, then inject tokens through stdio env or MCP OAuth — never model context.","gate":"executed","imports":["@arnilo/prism","@arnilo/prism-extensions/governance","@arnilo/prism-extensions/mcp"],"requiresEnv":[],"needsCredentials":false},
28
+ {"path":"examples/context.ts","title":"Ordered context blocks as a `context.build` handler (roadmap §2.4). The draft is the provider","gate":"executed","imports":["@arnilo/prism","@arnilo/prism/testing"],"requiresEnv":[],"needsCredentials":false},
29
+ {"path":"examples/custom-adapter.ts","title":"Phase 15 Part B: a host extends a reference adapter instead of writing one from scratch.","gate":"executed","imports":["@arnilo/prism","@arnilo/prism-extensions/approval","@arnilo/prism-hosts/driver-process","@arnilo/prism-tools/coding","@arnilo/prism/driver-kit","@arnilo/prism/testing"],"requiresEnv":[],"needsCredentials":false},
30
+ {"path":"examples/custom-builders.ts","title":"A host-owned prompt composition plus a `run.input` hook: both interception","gate":"executed","imports":["@arnilo/prism","@arnilo/prism/testing"],"requiresEnv":[],"needsCredentials":false},
31
+ {"path":"examples/custom-loop.ts","title":"The denied call reached the model as an ordinary tool result on the next turn.","gate":"executed","imports":["@arnilo/prism","@arnilo/prism/provider-kit"],"requiresEnv":[],"needsCredentials":false},
32
+ {"path":"examples/custom-provider.ts","title":"custom-provider","gate":"executed","imports":["@arnilo/prism","@arnilo/prism/provider-kit"],"requiresEnv":[],"needsCredentials":false},
33
+ {"path":"examples/custom-session-store.ts","title":"Custom session store: a host implements the `SessionStore` contract","gate":"executed","imports":["@arnilo/prism","@arnilo/prism/testing"],"requiresEnv":[],"needsCredentials":false},
34
+ {"path":"examples/custom-tools-skills-context.ts","title":"Custom tools + skills + context in one host app: register a host-owned","gate":"executed","imports":["@arnilo/prism","@arnilo/prism/testing"],"requiresEnv":[],"needsCredentials":false},
35
+ {"path":"examples/decision-models.ts","title":"Raw probabilities are the product of a decision call; print them, never parse prose.","gate":"executed","imports":["@arnilo/prism","@arnilo/prism/testing"],"requiresEnv":[],"needsCredentials":false},
36
+ {"path":"examples/define-package.ts","title":"A package declares the kernel API level it was written against; the kernel loads it unchanged on","gate":"executed","imports":["@arnilo/prism","@arnilo/prism/provider-kit"],"requiresEnv":["DEMO_COUNTER_KEY"],"needsCredentials":true},
37
+ {"path":"examples/delegate.ts","title":"Delegate Demo (plan 160 Task 4, plan 191 Task 5).","gate":"executed","imports":["@arnilo/prism","@arnilo/prism-extensions/delegate","@arnilo/prism-tools/coding","@arnilo/prism/provider-kit"],"requiresEnv":[],"needsCredentials":false},
38
+ {"path":"examples/discover-skills.ts","title":"Workspace skill discovery through `@arnilo/prism-extensions/context-files`, end-to-end with the mock","gate":"executed","imports":["@arnilo/prism","@arnilo/prism-extensions/context-files","@arnilo/prism/provider-kit","@arnilo/prism/testing"],"requiresEnv":[],"needsCredentials":false},
39
+ {"path":"examples/drive-rag-sync.ts","title":"drive-rag-sync","gate":"executed","imports":["@arnilo/prism-extensions/workflows","@arnilo/prism-knowledge/rag","@arnilo/prism-memory-system/core"],"requiresEnv":[],"needsCredentials":false},
40
+ {"path":"examples/durable-approval.ts","title":"The host gate: every `delete_file` call needs a person's yes. Without a `host.ui` the run suspends.","gate":"executed","imports":["@arnilo/prism","@arnilo/prism-extensions/store-sqlite","@arnilo/prism/testing"],"requiresEnv":[],"needsCredentials":false},
41
+ {"path":"examples/durable-investigation.ts","title":"The `ask` gate makes the first tool call a suspension instead of a side effect.","gate":"executed","imports":["@arnilo/prism","@arnilo/prism/provider-kit"],"requiresEnv":[],"needsCredentials":false},
42
+ {"path":"examples/durable-loops-and-approvals.ts","title":"Round-gate collects all gated calls into one suspension (Task 2).","gate":"executed","imports":["@arnilo/prism","@arnilo/prism/provider-kit"],"requiresEnv":[],"needsCredentials":false},
43
+ {"path":"examples/enterprise-identity.ts","title":"enterprise-identity","gate":"executed","imports":["@arnilo/prism-extensions/governance"],"requiresEnv":[],"needsCredentials":false},
44
+ {"path":"examples/enterprise-policy-audit.ts","title":"enterprise-policy-audit","gate":"executed","imports":["@arnilo/prism-extensions/governance"],"requiresEnv":[],"needsCredentials":false},
45
+ {"path":"examples/enterprise-work-connectors.ts","title":"Shared durable checkpoint store survives process restart","gate":"executed","imports":["@arnilo/prism-extensions/governance","@arnilo/prism-extensions/workflows","@arnilo/prism-tools/work/connectors"],"requiresEnv":[],"needsCredentials":false},
46
+ {"path":"examples/eval-injection.ts","title":"This scripted model falls for exactly the ignore_previous attack.","gate":"executed","imports":["@arnilo/prism","@arnilo/prism-hosts/evals","@arnilo/prism/provider-kit"],"requiresEnv":[],"needsCredentials":false},
47
+ {"path":"examples/eval-judges.ts","title":"Scripted verdicts demonstrate the API; they do not measure a real judge's quality.","gate":"executed","imports":["@arnilo/prism","@arnilo/prism-hosts/evals","@arnilo/prism/testing"],"requiresEnv":[],"needsCredentials":false},
48
+ {"path":"examples/evals.ts","title":"evals","gate":"executed","imports":["@arnilo/prism","@arnilo/prism-extensions/store-codecs","@arnilo/prism-hosts/evals","@arnilo/prism/testing"],"requiresEnv":[],"needsCredentials":false},
49
+ {"path":"examples/evaluation-gate.ts","title":"evaluation-gate","gate":"executed","imports":["@arnilo/prism","@arnilo/prism-hosts/evals","@arnilo/prism/testing"],"requiresEnv":[],"needsCredentials":false},
50
+ {"path":"examples/execution-timeline.ts","title":"============================================================================","gate":"executed","imports":["@arnilo/prism","@arnilo/prism-extensions/observability","@arnilo/prism-extensions/workflows","@arnilo/prism/provider-kit","@arnilo/prism/testing"],"requiresEnv":[],"needsCredentials":false},
51
+ {"path":"examples/external-agent.ts","title":"Phase 13 end to end, offline: an external agent driven through `@arnilo/prism/driver-kit`.","gate":"executed","imports":["@arnilo/prism","@arnilo/prism/driver-kit","@arnilo/prism/testing"],"requiresEnv":[],"needsCredentials":false},
52
+ {"path":"examples/external-app-db-backed.ts","title":"Phase 41 — End-to-end external-app example with a DB-backed adapter","gate":"executed","imports":["@arnilo/prism","@arnilo/prism/provider-kit","@arnilo/prism/testing"],"requiresEnv":[],"needsCredentials":false},
53
+ {"path":"examples/governance-deny.ts","title":"Governance deny-by-default (plan 159 Task 6; Done criterion 2) — network-free: mock provider,","gate":"executed","imports":["@arnilo/prism","@arnilo/prism-extensions/governance","@arnilo/prism/provider-kit"],"requiresEnv":[],"needsCredentials":false},
54
+ {"path":"examples/guardrail-packs.ts","title":"Guardrail packs end to end (plan 104 Task 7; moved onto `@arnilo/prism-extensions/guardrail-packs` in plan 159 Task 5) —","gate":"executed","imports":["@arnilo/prism","@arnilo/prism-extensions/guardrail-packs","@arnilo/prism-hosts/evals","@arnilo/prism/provider-kit"],"requiresEnv":[],"needsCredentials":false},
55
+ {"path":"examples/headless-host.ts","title":"Keep Bun transport declarations out of the examples compiler, as in remote-agent.ts.","gate":"executed","imports":["@arnilo/prism","@arnilo/prism-extensions/approval","@arnilo/prism-extensions/store-sqlite","@arnilo/prism-extensions/workflows","@arnilo/prism-hosts/channels","@arnilo/prism-hosts/headless","@arnilo/prism/testing"],"requiresEnv":["HEADLESS_DEMO_TOKEN"],"needsCredentials":true},
56
+ {"path":"examples/hooks-json.ts","title":"hooks.json package: config is the file. SessionStart is session.opened. PreToolUse is tool.call.","gate":"executed","imports":["@arnilo/prism","@arnilo/prism-extensions/hooks-json","@arnilo/prism/provider-kit"],"requiresEnv":[],"needsCredentials":false},
57
+ {"path":"examples/host-builder-agent.ts","title":"A Prism agent as the builder of a host: it works on a host project the way a coding agent does, using the","gate":"executed","imports":["@arnilo/prism","@arnilo/prism-extensions/context-files","@arnilo/prism-extensions/mcp","@arnilo/prism-tools/coding","@arnilo/prism/testing"],"requiresEnv":[],"needsCredentials":false},
58
+ {"path":"examples/host-hooks.ts","title":"Turn 1: the model calls the network tool and a local read. Turn 2 would answer, but the budget stops the run first.","gate":"executed","imports":["@arnilo/prism","@arnilo/prism/testing"],"requiresEnv":[],"needsCredentials":false},
59
+ {"path":"examples/host-step-loop-timeline.ts","title":"Host step-loop timeline correlation composition (plan 122 Task 5).","gate":"executed","imports":["@arnilo/prism","@arnilo/prism-extensions/observability","@arnilo/prism/provider-kit"],"requiresEnv":[],"needsCredentials":false},
60
+ {"path":"examples/hosted-sandbox.ts","title":"hosted-sandbox","gate":"executed","imports":["@arnilo/prism-tools/coding"],"requiresEnv":[],"needsCredentials":false},
61
+ {"path":"examples/instruction-injection.ts","title":"Instruction injection, end-to-end with the mock provider.","gate":"executed","imports":["@arnilo/prism","@arnilo/prism-extensions/context-files","@arnilo/prism/node/contribution-discovery","@arnilo/prism/provider-kit","@arnilo/prism/testing"],"requiresEnv":[],"needsCredentials":false},
62
+ {"path":"examples/jsonl-stores-branching.ts","title":"In-memory store + branching; JSONL persistence via the Node subpath.","gate":"executed","imports":["@arnilo/prism","@arnilo/prism-extensions/store-jsonl"],"requiresEnv":[],"needsCredentials":false},
63
+ {"path":"examples/long-term-memory.ts","title":"Network-free: session one consolidates an explicit statement into a typed project note through","gate":"executed","imports":["@arnilo/prism","@arnilo/prism-memory-system","@arnilo/prism-memory-system/core","@arnilo/prism-memory-system/core/fabric","@arnilo/prism/testing"],"requiresEnv":[],"needsCredentials":false},
64
+ {"path":"examples/manifest.ts","title":"1. Install into the project scope.","gate":"executed","imports":["@arnilo/prism","@arnilo/prism/manifest","@arnilo/prism/testing"],"requiresEnv":[],"needsCredentials":false},
65
+ {"path":"examples/mcp-server.ts","title":"One agent, one tool: `serveMcp` exposes the agent as a single `prompt` tool and","gate":"executed","imports":["@arnilo/prism","@arnilo/prism-hosts/mcp-server","@arnilo/prism/testing"],"requiresEnv":[],"needsCredentials":false},
66
+ {"path":"examples/mcp-trust.ts","title":"Approve the two URL servers, deny the stdio server.","gate":"executed","imports":["@arnilo/prism","@arnilo/prism-extensions/mcp","@arnilo/prism/testing"],"requiresEnv":["DOCS_MCP_TOKEN"],"needsCredentials":true},
67
+ {"path":"examples/memory-and-wiki.ts","title":"One memory system. Session memory is inert until a session turns `memory:session` on; `triggerTokens: 1` makes the","gate":"executed","imports":["@arnilo/prism","@arnilo/prism-knowledge/wiki","@arnilo/prism-memory-system"],"requiresEnv":[],"needsCredentials":false},
68
+ {"path":"examples/memory-lifecycle.ts","title":"Memory lifecycle demo: one note's whole life, from a candidate to verified, shadowed, archived and revived.","gate":"executed","imports":["@arnilo/prism","@arnilo/prism-memory-system","@arnilo/prism-memory-system/core","@arnilo/prism/testing"],"requiresEnv":[],"needsCredentials":false},
69
+ {"path":"examples/memory-system.ts","title":"The session tiers are gated per session: this one turns them on.","gate":"executed","imports":["@arnilo/prism","@arnilo/prism-memory-system"],"requiresEnv":[],"needsCredentials":false},
70
+ {"path":"examples/messaging-agent.ts","title":"Plan 079 Task 8: network-free host composition — sqlite journal, mock agent, drain/stop.","gate":"executed","imports":["@arnilo/prism","@arnilo/prism-extensions/governance","@arnilo/prism-extensions/store-sqlite","@arnilo/prism-hosts/channels","@arnilo/prism/testing"],"requiresEnv":[],"needsCredentials":false},
71
+ {"path":"examples/minimal-host-app.ts","title":"Minimal host-app embed: create an agent + session, stream events while a","gate":"executed","imports":["@arnilo/prism","@arnilo/prism/testing"],"requiresEnv":[],"needsCredentials":false},
72
+ {"path":"examples/model-router-aggregate-budgets.ts","title":"Fixed-model aggregate budget composition across host step loops (plan 122 Task 4).","gate":"executed","imports":["@arnilo/prism","@arnilo/prism-extensions/governance","@arnilo/prism-extensions/model-router","@arnilo/prism/provider-kit"],"requiresEnv":[],"needsCredentials":false},
73
+ {"path":"examples/model-router.ts","title":"Model Router Failover Demo (plan 160 Task 2).","gate":"executed","imports":["@arnilo/prism","@arnilo/prism-extensions/model-router","@arnilo/prism/provider-kit"],"requiresEnv":[],"needsCredentials":false},
74
+ {"path":"examples/obscura.ts","title":"Obscura composition example (plan 039): one host-installed binary, three generic","gate":"executed","imports":["@arnilo/prism","@arnilo/prism-tools/browser","@arnilo/prism-tools/web","@arnilo/prism/testing"],"requiresEnv":[],"needsCredentials":false},
75
+ {"path":"examples/observability.ts","title":"Observability Demo (plan 160 Task 3).","gate":"executed","imports":["@arnilo/prism","@arnilo/prism-extensions/observability","@arnilo/prism/provider-kit"],"requiresEnv":[],"needsCredentials":false},
76
+ {"path":"examples/open-connector-sidecar.ts","title":"Loopback plaintext dev escape hatch; the runtime token stays host-supplied.","gate":"executed","imports":["@arnilo/prism","@arnilo/prism-extensions/governance","@arnilo/prism-extensions/mcp"],"requiresEnv":["OOMOL_CONNECT_RUNTIME_TOKEN"],"needsCredentials":true},
77
+ {"path":"examples/openai-compatible.ts","title":"Bun-only demo (the examples tsconfig is Node-typed): the one Bun global this file uses.","gate":"executed","imports":["@arnilo/prism"],"requiresEnv":["EXAMPLE_LOCAL_KEY"],"needsCredentials":true},
78
+ {"path":"examples/package-skills.ts","title":"`searxng` registers `web_search` and `web_fetch` with no key and no request at setup.","gate":"executed","imports":["@arnilo/prism","@arnilo/prism-tools/coding","@arnilo/prism-tools/web","@arnilo/prism/testing"],"requiresEnv":[],"needsCredentials":false},
79
+ {"path":"examples/phase9-coding-intelligence.ts","title":"1. Git-aware enumeration: tracked files listed, ignored file excluded.","gate":"executed","imports":["@arnilo/prism","@arnilo/prism-tools/coding"],"requiresEnv":[],"needsCredentials":false},
80
+ {"path":"examples/provider-registration.ts","title":"Load a provider package, then resolve a host-owned mock from host registries.","gate":"executed","imports":["@arnilo/prism","@arnilo/prism-ai/hyper","@arnilo/prism/testing"],"requiresEnv":[],"needsCredentials":false},
81
+ {"path":"examples/provider-resolver.ts","title":"A loaded provider package resolves `model.provider`. A host-owned provider is one more package","gate":"executed","imports":["@arnilo/prism","@arnilo/prism-ai/hyper","@arnilo/prism/provider-kit","@arnilo/prism/testing"],"requiresEnv":[],"needsCredentials":false},
82
+ {"path":"examples/rag.ts","title":"RAG retrieval rides the `context.build` hook (roadmap §2.4): the retrieved blocks join this","gate":"executed","imports":["@arnilo/prism","@arnilo/prism-knowledge/rag","@arnilo/prism-memory-system/core","@arnilo/prism/testing"],"requiresEnv":[],"needsCredentials":false},
83
+ {"path":"examples/remote-agent-server.ts","title":"Keep Bun transport declarations out of the examples compiler.","gate":"executed","imports":["@arnilo/prism","@arnilo/prism-extensions/approval","@arnilo/prism/testing"],"requiresEnv":[],"needsCredentials":false},
84
+ {"path":"examples/remote-agent.ts","title":"Keep Bun transport declarations out of the examples compiler (see the conformance fixture).","gate":"executed","imports":["@arnilo/prism","@arnilo/prism-extensions/store-sqlite","@arnilo/prism-extensions/workflows","@arnilo/prism/testing"],"requiresEnv":[],"needsCredentials":false},
85
+ {"path":"examples/research-ledger.ts","title":"Offline: bun examples/research-ledger.ts","gate":"executed","imports":["@arnilo/prism","@arnilo/prism-tools/research","@arnilo/prism/testing"],"requiresEnv":[],"needsCredentials":false},
86
+ {"path":"examples/revocation-propagation.ts","title":"Cross-layer revocation composition (plan 122 Task 7).","gate":"executed","imports":["@arnilo/prism","@arnilo/prism-knowledge/rag","@arnilo/prism-memory-system","@arnilo/prism-memory-system/core","@arnilo/prism/testing"],"requiresEnv":[],"needsCredentials":false},
87
+ {"path":"examples/run-feedback.ts","title":"One mock label demonstrates the API; a CI gate needs a representative human-labeled sample.","gate":"executed","imports":["@arnilo/prism","@arnilo/prism-extensions/observability","@arnilo/prism-extensions/store-codecs","@arnilo/prism-hosts/evals","@arnilo/prism/testing"],"requiresEnv":[],"needsCredentials":false},
88
+ {"path":"examples/scanned-document-rag.ts","title":"scanned-document-rag","gate":"executed","imports":["@arnilo/prism-knowledge/rag","@arnilo/prism-memory-system/core","@arnilo/prism-tools/work/document-reader"],"requiresEnv":[],"needsCredentials":false},
89
+ {"path":"examples/sdk-basics.ts","title":"SDK basics: create an agent + session, subscribe to events, run a prompt.","gate":"executed","imports":["@arnilo/prism","@arnilo/prism/testing"],"requiresEnv":[],"needsCredentials":false},
90
+ {"path":"examples/secure-agent.ts","title":"Network-free secure baseline (plan 159 Task 7). `createSecureAgent` is gone; the same guarantees","gate":"executed","imports":["@arnilo/prism","@arnilo/prism-extensions/governance","@arnilo/prism/testing"],"requiresEnv":[],"needsCredentials":false},
91
+ {"path":"examples/semantic-memory.ts","title":"Semantic memory with a hash embedder: remember, recall with adjacent entries, and context injection.","gate":"executed","imports":["@arnilo/prism","@arnilo/prism-memory-system","@arnilo/prism-memory-system/core","@arnilo/prism/testing"],"requiresEnv":[],"needsCredentials":false},
92
+ {"path":"examples/serve-tools.ts","title":"Phase 14 end to end, offline: serving a run's tools to an external agent's own loop.","gate":"executed","imports":["@arnilo/prism","@arnilo/prism-extensions/approval","@arnilo/prism-hosts/mcp-server","@arnilo/prism-tools/coding","@arnilo/prism/driver-kit","@arnilo/prism/testing"],"requiresEnv":[],"needsCredentials":false},
93
+ {"path":"examples/session-memory.ts","title":"Names its source entry, so each turn's pass records its own event (an identical one would habituate).","gate":"executed","imports":["@arnilo/prism","@arnilo/prism-extensions/compaction","@arnilo/prism-extensions/store-sqlite","@arnilo/prism-memory-system"],"requiresEnv":[],"needsCredentials":false},
94
+ {"path":"examples/session-search.ts","title":"Workspace session search over stored sessions (plan 095). One query API covers the indexed","gate":"executed","imports":["@arnilo/prism","@arnilo/prism-extensions/store-jsonl","@arnilo/prism-extensions/store-sqlite"],"requiresEnv":[],"needsCredentials":false},
95
+ {"path":"examples/session.ts","title":"A second turn through `run` returns the RunResult.","gate":"executed","imports":["@arnilo/prism","@arnilo/prism/testing"],"requiresEnv":[],"needsCredentials":false},
96
+ {"path":"examples/side-call.ts","title":"side-call","gate":"executed","imports":["@arnilo/prism","@arnilo/prism/testing"],"requiresEnv":[],"needsCredentials":false},
97
+ {"path":"examples/signal-agent.ts","title":"Explicit, externally supervised signal-cli composition.","gate":"executed","imports":["@arnilo/prism","@arnilo/prism-hosts/channels/signal"],"requiresEnv":[],"needsCredentials":false},
98
+ {"path":"examples/skills-progressive-disclosure.ts","title":"Many-skill catalog under budget, then load one body on demand (no live provider).","gate":"executed","imports":["@arnilo/prism"],"requiresEnv":[],"needsCredentials":false},
99
+ {"path":"examples/skills.ts","title":"Skill registry with progressive disclosure: skills activate by name and may","gate":"executed","imports":["@arnilo/prism"],"requiresEnv":[],"needsCredentials":false},
100
+ {"path":"examples/sqlite-resume.ts","title":"sqlite-resume","gate":"executed","imports":["@arnilo/prism","@arnilo/prism-extensions/store-sqlite","@arnilo/prism/testing"],"requiresEnv":[],"needsCredentials":false},
101
+ {"path":"examples/system-project-prompts.ts","title":"Context files: AGENTS.md (workspace, source: app) and SYSTEM.md (source: user) load as","gate":"executed","imports":["@arnilo/prism","@arnilo/prism-extensions/context-files","@arnilo/prism/provider-kit","@arnilo/prism/testing"],"requiresEnv":[],"needsCredentials":false},
102
+ {"path":"examples/system-prompts.ts","title":"Layered system prompt composition: user, package, app, then run order (Phase 31: user is the global base).","gate":"executed","imports":["@arnilo/prism"],"requiresEnv":[],"needsCredentials":false},
103
+ {"path":"examples/telegram-agent.ts","title":"Explicit host composition for Phase 10 Channels. Calling this function (not importing it)","gate":"executed","imports":["@arnilo/prism","@arnilo/prism-hosts/channels/telegram"],"requiresEnv":[],"needsCredentials":false},
104
+ {"path":"examples/tool-narrowing-planes.ts","title":"Plane-switched tool narrowing on one continuing session, as a `context.build`","gate":"executed","imports":["@arnilo/prism","@arnilo/prism/provider-kit"],"requiresEnv":[],"needsCredentials":false},
105
+ {"path":"examples/tools.ts","title":"Host-owned tool registry: allow/deny filtering and dispatch. Unregistered","gate":"executed","imports":["@arnilo/prism"],"requiresEnv":[],"needsCredentials":false},
106
+ {"path":"examples/validator.ts","title":"Validator Demo (plan 191 Task 8).","gate":"executed","imports":["@arnilo/prism","@arnilo/prism-extensions/advisor","@arnilo/prism/provider-kit"],"requiresEnv":[],"needsCredentials":false},
107
+ {"path":"examples/web-no-key.ts","title":"web-no-key","gate":"executed","imports":["@arnilo/prism","@arnilo/prism-tools/coding","@arnilo/prism-tools/web","@arnilo/prism/testing"],"requiresEnv":[],"needsCredentials":false},
108
+ {"path":"examples/web-research.ts","title":"web-research","gate":"executed","imports":["@arnilo/prism","@arnilo/prism-tools/web"],"requiresEnv":[],"needsCredentials":false},
109
+ {"path":"examples/workflow-event-sink.ts","title":"Observability / event sink: a workflow with a conditional path produces","gate":"executed","imports":["@arnilo/prism","@arnilo/prism-extensions/workflows","@arnilo/prism/provider-kit","@arnilo/prism/testing"],"requiresEnv":[],"needsCredentials":false},
110
+ {"path":"examples/workflow-loop.ts","title":"workflow-loop","gate":"executed","imports":["@arnilo/prism","@arnilo/prism-extensions/approval","@arnilo/prism-extensions/workflows","@arnilo/prism/provider-kit","@arnilo/prism/testing"],"requiresEnv":[],"needsCredentials":false},
111
+ {"path":"examples/workflow-multimodal-document.ts","title":"Offline multimodal document workflow. Host constructs a bounded inline PDF","gate":"executed","imports":["@arnilo/prism","@arnilo/prism-extensions/workflows","@arnilo/prism/provider-kit","@arnilo/prism/testing"],"requiresEnv":[],"needsCredentials":false},
112
+ {"path":"examples/workflow-parallel-research.ts","title":"True parallel research DAG: fan-out normalizes bounded topics, join exposes","gate":"executed","imports":["@arnilo/prism","@arnilo/prism-extensions/workflows","@arnilo/prism/provider-kit","@arnilo/prism/testing"],"requiresEnv":[],"needsCredentials":false},
113
+ {"path":"examples/workflow-postgres-resume.ts","title":"Opt-in PostgreSQL restart/resume example. Default execution is network-free","gate":"executed","imports":["@arnilo/prism-extensions/store-postgres","@arnilo/prism-extensions/workflows"],"requiresEnv":["PRISM_TEST_POSTGRES_URL"],"needsCredentials":false},
114
+ {"path":"examples/workflow-research-and-review.ts","title":"Sequential research → draft → review pipeline with in-memory checkpoints.","gate":"executed","imports":["@arnilo/prism","@arnilo/prism-extensions/workflows","@arnilo/prism/provider-kit","@arnilo/prism/testing"],"requiresEnv":[],"needsCredentials":false},
115
+ {"path":"examples/workflow-sqlite-resume.ts","title":"SQLite durable checkpoint, abort, and resume. A two-node workflow writes","gate":"executed","imports":["@arnilo/prism","@arnilo/prism-extensions/store-sqlite","@arnilo/prism-extensions/workflows","@arnilo/prism/provider-kit","@arnilo/prism/testing"],"requiresEnv":[],"needsCredentials":false}
116
+ ],
117
+ "support": [
118
+ "examples/adapters/conformance.ts",
119
+ "examples/adapters/fixtures/rpc-server.json",
120
+ "examples/adapters/fixtures/stream-cli.json",
121
+ "examples/adapters/fixtures/workspace-config.json",
122
+ "examples/adapters/rpc-server.dialect.ts",
123
+ "examples/adapters/rpc-server.ts",
124
+ "examples/adapters/stream-cli.dialect.ts",
125
+ "examples/adapters/stream-cli.ts",
126
+ "examples/adapters/workspace-config.dialect.ts",
127
+ "examples/adapters/workspace-config.ts",
128
+ "examples/hooks-audit-command.mjs"
129
+ ]
130
+ }
@@ -0,0 +1,85 @@
1
+ ---
2
+ name: prism-host-builder
3
+ description: Use when building, changing, upgrading, or debugging a host or package on the Prism agent SDK (@arnilo/prism): choosing packages, wiring createAgent, serving it, and verifying it.
4
+ ---
5
+
6
+ # Building a Prism host
7
+
8
+ Prism 0.13 is a small kernel plus native packages. A host is code that calls `await createAgent({ model, packages })`
9
+ and serves the agent. Your memory of Prism 0.12 is wrong for this version: read the installed docs, never recall.
10
+
11
+ ## Where the facts are
12
+
13
+ All paths are relative to the project root and describe the installed version.
14
+
15
+ - Docs index: `node_modules/@arnilo/prism/docs/index.md`. Kernel pages sit beside it. Each package has
16
+ `node_modules/@arnilo/<package>/README.md`.
17
+ - Version-exact indexes: `node_modules/@arnilo/prism-hosts/host-builder/data/api.json` (every public name, its signature,
18
+ the docs that mention it), `errors.json` (every error code and what it means) and `examples.json`.
19
+ - Tested example sources: `node_modules/@arnilo/prism-hosts/host-builder/data/examples/<name>.ts`. Copy one; do not retype it.
20
+ - If an MCP server named `prism-host-builder` is connected, its lookup tools read the same indexes. They are an
21
+ accelerator. Every step below also works with a file read.
22
+
23
+ An export that is not in `api.json` does not exist in this version. Check before you import. Every interface and
24
+ class lists its fields under `members`: read a field or method name there (for example the payload a hook handler
25
+ receives), never guess it.
26
+
27
+ ## Workflow
28
+
29
+ 1. **Orient.** Read the project's `package.json`, its `createAgent` call and its lockfile. Note the Prism version,
30
+ which packages are listed, which slots have an owner, and whether the host uses a manifest. Read
31
+ `docs/migrate-to-0.13.md` if any code looks like 0.12 (see `references/upgrading.md`).
32
+ 2. **Choose.** Decide with `references/choosing.md`: host library, store, compaction owner, approval, provider.
33
+ Place each new thing with `references/layout.md`: kernel, package, or host. A capability any host could want is
34
+ a package; an opinion about one product stays in the host.
35
+ 3. **Build.** Read `references/recipes.md` before you write code: find the recipe, open the example it names and
36
+ the docs page it links, and change the smallest thing. List a package to turn it on; nothing is active unless
37
+ it is listed.
38
+ 4. **Verify.** Run `references/verification.md`: typecheck, `agent.inspect()`, and the conformance helpers.
39
+ Read `references/pitfalls.md` when a load or run fails: match the error code before you guess.
40
+ 5. **Report.** Say what changed, which checks ran and what you could not check.
41
+
42
+ ## Rules that do not bend
43
+
44
+ - Secrets are named references the credentials slot resolves, never literals, in config, the manifest, logs and
45
+ tests. A literal fails closed. Read `references/security.md` before you touch credentials, approval, trust or a
46
+ server.
47
+ - Fail closed. Do not weaken a validator, approval mode, trust check or limit to make something pass. Fix the cause.
48
+ - Installed means listed means active. Do not edit the kernel to add a capability. Write a package with
49
+ `definePackage` and list it.
50
+ - No default model or provider exists. A host names one and lists the provider package.
51
+ - Do not run `bun install` to repair a workspace without being asked; it can rewrite the lockfile.
52
+ - Memory packages other than `memory-compaction` are experimental. Opt in on purpose (`references/choosing.md`).
53
+ - Do not copy a code sample from memory, a blog or a 0.12 page. Copy from `data/examples/` or the installed docs.
54
+
55
+ ## Mistakes the compiler cannot catch
56
+
57
+ - **A host that runs tools needs a principal.** Tools with durable effects (`shell`, `write`, `edit`, git commits in
58
+ `@arnilo/prism-tools/coding`) fail closed at run time unless `createAgent` gets `principal: { kind, id }` (and the
59
+ `ownership` scope the host serves). A type check passes without it. A host that runs as a local user sets both.
60
+ - **Deleting a retired field is not an upgrade.** `identity` is gone: it became `principal`. Look every removed field
61
+ up in `references/upgrading.md` and move what it did; do not just delete it.
62
+ - **Types are not behavior.** After the typecheck, drive the host once with scripted mock turns that call its tools
63
+ (`references/verification.md`) and read the tool results.
64
+ - **Two packages for one slot.** Before you list a package that provides `compaction`, `store`, `loop` or `credentials`,
65
+ check what already provides it (`agent.inspect().slots`) and assign the owner in `slots`.
66
+ - **Leave no scratch files.** Delete the files you made only to try something; the whole project must typecheck.
67
+
68
+ ## References
69
+
70
+ Read `recipes.md` before you build; read the others when their row applies. Each is short.
71
+
72
+ | File | Read it when |
73
+ | --- | --- |
74
+ | `references/choosing.md` | picking a host library, store, compaction owner, approval, governance or provider |
75
+ | `references/layout.md` | deciding whether code belongs in the kernel, a package or the host; what is public |
76
+ | `references/recipes.md` | doing a common change: add a tool, a skill, a store, serve over ACP, add approval |
77
+ | `references/pitfalls.md` | a load or run failed, or before you list two packages that touch one slot |
78
+ | `references/security.md` | secrets, approval, trust, multi-user hosts, a network listener |
79
+ | `references/verification.md` | proving a change works without a live model |
80
+ | `references/upgrading.md` | the code or the lockfile is from 0.12, or a name does not exist |
81
+
82
+ ## When you are unsure
83
+
84
+ Prefer the smaller change and say what you assumed. If a docs page and the `api.json` entry disagree, the index
85
+ wins, because it is generated from the installed code. If neither answers, say so; do not invent an option.
@@ -0,0 +1,101 @@
1
+ # Choosing what to use
2
+
3
+ Each section is a decision. Pick the first branch that fits, then read the README it names. Package names, config and
4
+ defaults live in the README, not here: they change, and the README is version-exact.
5
+
6
+ ## Which host library
7
+
8
+ A host library serves or drives an agent from outside. It is imported by host code and is never listed in `packages`.
9
+ The index is `node_modules/@arnilo/prism/docs/index.md` under "Host libraries".
10
+
11
+ - No UI, jobs, cron, or answers arrive from chat or another process: `@arnilo/prism-hosts/headless` routes `HostUi`
12
+ requests and schedules agent or workflow runs. Example: `examples/headless-host.ts`.
13
+ - An editor speaks the Agent Client Protocol: `@arnilo/prism-hosts/acp` (`serveAcp`). Example: `examples/acp.ts`.
14
+ - A browser UI speaks AG-UI over SSE: `@arnilo/prism-hosts/ag-ui`. Example: `examples/ag-ui-server.ts`.
15
+ - An MCP client should call the agent: `@arnilo/prism-hosts/mcp-server` (`serveMcp`). Example: `examples/mcp-server.ts`.
16
+ To hand a vendor agent your tools instead, use `serveTools`; example: `examples/serve-tools.ts`.
17
+ - People talk to it in Telegram or Signal: `@arnilo/prism-hosts/channels`. Examples: `examples/telegram-agent.ts`,
18
+ `examples/signal-agent.ts`.
19
+ - Another process or machine calls it: `@arnilo/prism-hosts/remote` serves and connects (`prism.remote/1`). Examples:
20
+ `examples/remote-agent-server.ts`, `examples/remote-agent.ts`.
21
+ - You want to see events and state while developing: `@arnilo/prism-hosts/devtools` (a loopback inspector; do not expose it).
22
+ - You are scoring behavior: `@arnilo/prism-hosts/evals`. Example: `examples/evals.ts`.
23
+
24
+ Several can serve the same agent. Each needs the host to answer approvals, so settle the approval route first
25
+ (see "Approval" below).
26
+
27
+ ## Which store
28
+
29
+ The `store` slot holds sessions. The kernel default is in memory and lost on exit.
30
+
31
+ - Single process, a file is enough: `@arnilo/prism-extensions/store-jsonl`.
32
+ - Single machine, queries, durable approvals and resume: `@arnilo/prism-extensions/store-sqlite`. Example:
33
+ `examples/sqlite-resume.ts`.
34
+ - Several processes or machines, backups, enterprise state: `@arnilo/prism-extensions/store-postgres`. Read
35
+ `node_modules/@arnilo/prism/docs/operations.md` before you rely on it.
36
+ - A product database of your own: implement `SessionStore` and run `storeConformance`. Example:
37
+ `examples/custom-session-store.ts`. Details in `node_modules/@arnilo/prism/docs/slots.md`.
38
+
39
+ `@arnilo/prism-extensions/store-codecs` is a shared library, not a store. Do not list it.
40
+
41
+ ## Slot owners and compaction
42
+
43
+ There are four slots: `loop`, `compaction`, `store`, `credentials`. Each holds one implementation. Two packages that
44
+ provide one slot with no assignment fail the load (`ERR_PRISM_SLOT_CONFLICT`). Assign the owner by package name in
45
+ `slots`, as `node_modules/@arnilo/prism/docs/slots.md` shows.
46
+
47
+ - Need summarised history: `@arnilo/prism-extensions/compaction` (stable). Example: `examples/compaction.ts`.
48
+ - Need observational memory too: `@arnilo/prism-memory-system` also claims `compaction`. List both and
49
+ assign the owner you want. Example: `examples/session-memory.ts`.
50
+ - Need a different loop (workflow, external agent): `slots.loop`, or a package that claims it
51
+ (`@arnilo/prism-extensions/workflows`, `@arnilo/prism-hosts/driver-process`). Example: `examples/custom-loop.ts`.
52
+
53
+ ## The experimental memory line
54
+
55
+ `@arnilo/prism-memory-system/core` and `-system`, `@arnilo/prism-knowledge/wiki` and `@arnilo/prism-knowledge/rag` ship as `0.13.0-experimental.N` on the npm
56
+ dist-tag `experimental`. They sit outside the compatibility promise: API, config and defaults may change in any release.
57
+ A `^0.13.0` range never matches a prerelease, so opt in by tag and keep the host able to run without them:
58
+
59
+ ```bash
60
+ bun add @arnilo/prism-memory-system@experimental
61
+ ```
62
+
63
+ Say in your report that the host depends on an experimental package. Use `@arnilo/prism-extensions/compaction` unless
64
+ the product needs more. Examples: `examples/long-term-memory.ts`, `examples/memory-and-wiki.ts`.
65
+
66
+ ## Approval and governance
67
+
68
+ - Ask a person before a write, a shell command or a delete: `@arnilo/prism-extensions/approval`, with a `mode` (`deny`, `ask`,
69
+ `edits`, `auto`). Examples: `examples/approval.ts`, `examples/coding-approval.ts`. With no `host.ui`, an ask
70
+ suspends the run durably instead of running the tool: `examples/durable-approval.ts`.
71
+ - Per-user policy, identity, an audit ledger: `@arnilo/prism-extensions/governance`. Examples: `examples/governance-deny.ts`,
72
+ `examples/enterprise-policy-audit.ts`.
73
+ - Prompt-injection and PII checks on inputs, tool results and model output: `@arnilo/prism-extensions/guardrail-packs`.
74
+ Example: `examples/guardrail-packs.ts`.
75
+ - Cost caps and failover across models: `@arnilo/prism-extensions/model-router`. Example: `examples/model-router.ts`.
76
+
77
+ Approval gates a call; it does not sandbox a tool. Isolation is the host's job (`references/security.md`).
78
+
79
+ ## Which provider
80
+
81
+ There is no default. List exactly one provider package per vendor you call and name the model as
82
+ `provider/model` or a `ModelSpec`. Read the provider's README for credentials: they are `env:` or `keyring:` refs,
83
+ or a login flow that stores them for you through the `credentials` slot.
84
+
85
+ - A vendor package exists under "Providers" in `docs/index.md`: use it.
86
+ - It does not: write a provider on `@arnilo/prism/provider-kit`. Example: `examples/custom-provider.ts`.
87
+ - A gateway you operate (LiteLLM, OpenRouter, Kilo): use that gateway's package, and let the gateway pick the vendor.
88
+ - Offline tests: `mockProvider` from `@arnilo/prism/testing`.
89
+
90
+ ```ts
91
+ import { createAgent, providerDone, providerTextDelta } from "@arnilo/prism";
92
+ import { mockProvider } from "@arnilo/prism/testing";
93
+
94
+ const agent = await createAgent({
95
+ model: { provider: "mock", model: "demo" },
96
+ packages: [mockProvider([[providerTextDelta("ok"), providerDone()]])],
97
+ });
98
+ const listed = agent.inspect();
99
+ await agent.dispose();
100
+ export { listed };
101
+ ```
@@ -0,0 +1,52 @@
1
+ # Where things go
2
+
3
+ Three layers each own a different kind of decision. The reference host's README states the rule:
4
+ `node_modules/@arnilo/prism/docs/host.md` covers the host port, and the reference host walkthrough is in the Prism
5
+ repository (`apps/prism-agent/README.md`, "Where things go"). The walkthrough is not in an npm tarball, so this file
6
+ carries the rule.
7
+
8
+ | Layer | Holds | Put a thing here when |
9
+ | --- | --- | --- |
10
+ | Kernel `@arnilo/prism` | the loop, hooks, slots, sessions, store contract, events, host port, driver kit, the package system | the default loop or the package system cannot work without it |
11
+ | Native packages and host libraries | tools, memory, stores, providers, approval, governance, workflows, ACP, remote, channels | any harness or host could want it, whatever the product |
12
+ | The host | which agents exist, their package lists, prompts, routing, vendor adapters, deployment | it is an opinion about one product |
13
+
14
+ Nothing sits between the host and the SDK. The host imports `@arnilo/prism`, its public subpaths, and published
15
+ packages. It never imports a path inside a package (`@arnilo/prism-tools/coding/src/x`), and it never reaches into
16
+ `node_modules`.
17
+
18
+ ## Decide where new code goes
19
+
20
+ 1. Does the kernel fail to work without it? Almost never. Do not edit the kernel to add a capability. If a package
21
+ cannot do the job because a hook or slot is missing, report that as a gap with the hook you needed.
22
+ 2. Could another host want it? Write a package with `definePackage` (`node_modules/@arnilo/prism/docs/packages.md`),
23
+ declare the capabilities it uses, and list it in `packages`. Example: `examples/define-package.ts`.
24
+ 3. Is it one product's opinion (a prompt, a workflow graph, a routing table)? Keep it in the host's own files.
25
+
26
+ The kernel never imports or names a package. A host that needs "if package X is loaded" asks `agent.inspect()`.
27
+
28
+ ## What a package can contribute
29
+
30
+ Through `PackageAPI` a package registers tools, hooks, skills, commands, providers, services and slot
31
+ implementations, and keeps session state. It cannot patch the loop or another package. Gates sit in primitives, not
32
+ in the loop: tools always run through the same executor that fires `tool.call`, so a custom loop cannot skip approval.
33
+ Read `node_modules/@arnilo/prism/docs/hooks.md` for the hook catalog and ordering.
34
+
35
+ ## The public-surface rule
36
+
37
+ Public means: exported from the package entry or a documented subpath, and present in `data/api.json`. Everything
38
+ else is internal and can change without notice.
39
+
40
+ - Import from `@arnilo/prism`, `@arnilo/prism/provider-kit`, `@arnilo/prism/driver-kit`, `@arnilo/prism/manifest`
41
+ and `@arnilo/prism/testing`, as `api.json` lists them per subpath.
42
+ - A name the docs show but `api.json` does not list is stale or experimental. Prefer the index.
43
+ - Types cast with `as unknown as` at a package seam are a smell. Fix the type at the source or import the exported
44
+ type; a cast hides a contract change until runtime.
45
+ - A host never relies on an experimental package's shape staying put (`references/choosing.md`).
46
+
47
+ ## Layout of a host repository
48
+
49
+ A small host is a few files: one `createAgent` call per agent in its own module, a config module that reads `env:`
50
+ refs, and the serving entry. Keep each agent's package list in one place so `inspect()` explains the whole agent.
51
+ Do not split one agent's wiring across modules that mutate it after creation. Look at `examples/minimal-host-app.ts`
52
+ and `examples/headless-host.ts`.