@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.
- package/CHANGELOG.md +394 -0
- package/LICENSE +21 -0
- package/README.md +34 -2
- package/acp/README.md +87 -0
- package/acp/src/capabilities.ts +184 -0
- package/acp/src/errors.ts +24 -0
- package/acp/src/host.ts +36 -0
- package/acp/src/index.ts +25 -0
- package/acp/src/limits.ts +49 -0
- package/acp/src/mapper.ts +419 -0
- package/acp/src/permission.ts +37 -0
- package/acp/src/projection.ts +39 -0
- package/acp/src/prompt.ts +170 -0
- package/acp/src/serve.ts +345 -0
- package/acp/src/session-map.ts +49 -0
- package/ag-ui/README.md +56 -0
- package/ag-ui/src/a2ui.ts +570 -0
- package/ag-ui/src/ag-ui-mapper.ts +507 -0
- package/ag-ui/src/encrypted-value.ts +40 -0
- package/ag-ui/src/errors.ts +29 -0
- package/ag-ui/src/handler.ts +642 -0
- package/ag-ui/src/index.ts +177 -0
- package/ag-ui/src/input.ts +190 -0
- package/ag-ui/src/limits.ts +279 -0
- package/ag-ui/src/mcp-apps.ts +256 -0
- package/ag-ui/src/mcp.ts +94 -0
- package/ag-ui/src/projection.ts +201 -0
- package/ag-ui/src/projectors.ts +272 -0
- package/ag-ui/src/renderer/bind.ts +152 -0
- package/ag-ui/src/renderer/core.ts +270 -0
- package/ag-ui/src/renderer/index.ts +165 -0
- package/ag-ui/src/replay.ts +189 -0
- package/ag-ui/src/types.ts +66 -0
- package/channels/README.md +139 -0
- package/channels/src/admission.ts +8 -0
- package/channels/src/approvals.ts +262 -0
- package/channels/src/checkpoint-contract.ts +97 -0
- package/channels/src/delivery.ts +116 -0
- package/channels/src/host-ui.ts +356 -0
- package/channels/src/identity.ts +46 -0
- package/channels/src/index.ts +82 -0
- package/channels/src/limits.ts +49 -0
- package/channels/src/memory-stores.ts +112 -0
- package/channels/src/pairing.ts +178 -0
- package/channels/src/runtime-admit.ts +389 -0
- package/channels/src/runtime-core.ts +621 -0
- package/channels/src/runtime-reconcile.ts +299 -0
- package/channels/src/runtime-turn.ts +664 -0
- package/channels/src/runtime-types.ts +95 -0
- package/channels/src/runtime.ts +86 -0
- package/channels/src/secret-ref.ts +42 -0
- package/channels/src/signal.ts +790 -0
- package/channels/src/state.ts +355 -0
- package/channels/src/telegram.ts +1317 -0
- package/channels/src/types.ts +442 -0
- package/devtools/README.md +92 -0
- package/devtools/bin/prism-devtools.ts +63 -0
- package/devtools/src/args.ts +71 -0
- package/devtools/src/bun.d.ts +27 -0
- package/devtools/src/compare.ts +190 -0
- package/devtools/src/errors.ts +15 -0
- package/devtools/src/index.ts +25 -0
- package/devtools/src/replay.ts +36 -0
- package/devtools/src/security.ts +80 -0
- package/devtools/src/serve.ts +259 -0
- package/devtools/src/ui/assets.ts +108 -0
- package/devtools/src/ui/inspector.ts +182 -0
- package/driver-process/README.md +197 -0
- package/driver-process/src/abort.ts +74 -0
- package/driver-process/src/adapter.ts +211 -0
- package/driver-process/src/driver.ts +303 -0
- package/driver-process/src/errors.ts +17 -0
- package/driver-process/src/extend.ts +72 -0
- package/driver-process/src/index.ts +5 -0
- package/driver-process/src/inspect.ts +33 -0
- package/driver-process/src/session.ts +72 -0
- package/driver-process/src/testing.ts +394 -0
- package/driver-process/src/transports/json-rpc.ts +147 -0
- package/driver-process/src/transports/jsonl-stream.ts +12 -0
- package/driver-process/src/transports/types.ts +11 -0
- package/driver-process/src/turn.ts +106 -0
- package/evals/README.md +843 -0
- package/evals/src/calibration.ts +179 -0
- package/evals/src/citation-integrity.ts +98 -0
- package/evals/src/citations.ts +45 -0
- package/evals/src/compare-experiments.ts +153 -0
- package/evals/src/comparison.ts +230 -0
- package/evals/src/curate.ts +257 -0
- package/evals/src/dataset.ts +81 -0
- package/evals/src/erp-invariants.ts +163 -0
- package/evals/src/errors.ts +23 -0
- package/evals/src/experiment.ts +537 -0
- package/evals/src/failure-injection.ts +77 -0
- package/evals/src/feedback.ts +53 -0
- package/evals/src/index.ts +198 -0
- package/evals/src/injection.ts +247 -0
- package/evals/src/judge-panel.ts +109 -0
- package/evals/src/judge.ts +89 -0
- package/evals/src/limits.ts +50 -0
- package/evals/src/report-record.ts +47 -0
- package/evals/src/rubric-judge.ts +334 -0
- package/evals/src/scenario-runner.ts +317 -0
- package/evals/src/scenarios.ts +81 -0
- package/evals/src/score.ts +328 -0
- package/evals/src/scorer.ts +21 -0
- package/evals/src/state-match.ts +130 -0
- package/evals/src/stats.ts +635 -0
- package/evals/src/threshold.ts +117 -0
- package/evals/src/timeline.ts +38 -0
- package/evals/src/toolless-session.ts +33 -0
- package/evals/src/trace.ts +80 -0
- package/evals/src/trajectory.ts +623 -0
- package/evals/src/types.ts +672 -0
- package/evals/src/user-simulator.ts +101 -0
- package/evals/src/util.ts +207 -0
- package/headless/README.md +172 -0
- package/headless/src/answers.ts +91 -0
- package/headless/src/authority.ts +32 -0
- package/headless/src/errors.ts +36 -0
- package/headless/src/index.ts +17 -0
- package/headless/src/limits.ts +11 -0
- package/headless/src/pending.ts +16 -0
- package/headless/src/policy.ts +36 -0
- package/headless/src/resume.ts +103 -0
- package/headless/src/route.ts +153 -0
- package/headless/src/scheduler/clock.ts +22 -0
- package/headless/src/scheduler/cron.ts +19 -0
- package/headless/src/scheduler/firing.ts +58 -0
- package/headless/src/scheduler/index.ts +399 -0
- package/headless/src/scheduler/lease.ts +38 -0
- package/headless/src/scheduler/missed.ts +12 -0
- package/headless/src/scheduler/state.ts +132 -0
- package/host-builder/README.md +251 -0
- package/host-builder/bin/prism-host-builder.ts +169 -0
- package/host-builder/data/api.json +6167 -0
- package/host-builder/data/errors.json +546 -0
- package/host-builder/data/examples/acp.ts +63 -0
- package/host-builder/data/examples/adapters/conformance.ts +34 -0
- package/host-builder/data/examples/adapters/fixtures/rpc-server.json +26 -0
- package/host-builder/data/examples/adapters/fixtures/stream-cli.json +27 -0
- package/host-builder/data/examples/adapters/fixtures/workspace-config.json +28 -0
- package/host-builder/data/examples/adapters/rpc-server.dialect.ts +218 -0
- package/host-builder/data/examples/adapters/rpc-server.ts +309 -0
- package/host-builder/data/examples/adapters/stream-cli.dialect.ts +165 -0
- package/host-builder/data/examples/adapters/stream-cli.ts +256 -0
- package/host-builder/data/examples/adapters/workspace-config.dialect.ts +172 -0
- package/host-builder/data/examples/adapters/workspace-config.ts +251 -0
- package/host-builder/data/examples/advisor.ts +94 -0
- package/host-builder/data/examples/ag-ui-a2ui.ts +80 -0
- package/host-builder/data/examples/ag-ui-mcp-apps.ts +44 -0
- package/host-builder/data/examples/ag-ui-server.ts +118 -0
- package/host-builder/data/examples/agent-durable-approval.ts +43 -0
- package/host-builder/data/examples/api-key-auth.ts +23 -0
- package/host-builder/data/examples/approval.ts +92 -0
- package/host-builder/data/examples/attention-compiler.ts +81 -0
- package/host-builder/data/examples/autonomous-coding-loop.ts +343 -0
- package/host-builder/data/examples/behavior-evaluation.ts +303 -0
- package/host-builder/data/examples/build-workflow.ts +334 -0
- package/host-builder/data/examples/cache-aware-prompt-assembly.ts +139 -0
- package/host-builder/data/examples/caveman-ponytail.ts +197 -0
- package/host-builder/data/examples/cli.ts +31 -0
- package/host-builder/data/examples/coding-approval.ts +115 -0
- package/host-builder/data/examples/coding-browser-evaluation.ts +208 -0
- package/host-builder/data/examples/coding-compaction.ts +30 -0
- package/host-builder/data/examples/coding-goal-verify.ts +121 -0
- package/host-builder/data/examples/coding-tools-capability-gaps.ts +75 -0
- package/host-builder/data/examples/compaction.ts +36 -0
- package/host-builder/data/examples/connected-slack-mcp.ts +67 -0
- package/host-builder/data/examples/context.ts +29 -0
- package/host-builder/data/examples/custom-adapter.ts +256 -0
- package/host-builder/data/examples/custom-builders.ts +66 -0
- package/host-builder/data/examples/custom-loop.ts +89 -0
- package/host-builder/data/examples/custom-provider.ts +70 -0
- package/host-builder/data/examples/custom-session-store.ts +72 -0
- package/host-builder/data/examples/custom-tools-skills-context.ts +97 -0
- package/host-builder/data/examples/decision-models.ts +98 -0
- package/host-builder/data/examples/define-package.ts +188 -0
- package/host-builder/data/examples/delegate.ts +200 -0
- package/host-builder/data/examples/discover-skills.ts +65 -0
- package/host-builder/data/examples/drive-rag-sync.ts +44 -0
- package/host-builder/data/examples/durable-approval.ts +139 -0
- package/host-builder/data/examples/durable-investigation.ts +93 -0
- package/host-builder/data/examples/durable-loops-and-approvals.ts +94 -0
- package/host-builder/data/examples/enterprise-identity.ts +21 -0
- package/host-builder/data/examples/enterprise-policy-audit.ts +50 -0
- package/host-builder/data/examples/enterprise-work-connectors.ts +103 -0
- package/host-builder/data/examples/eval-injection.ts +73 -0
- package/host-builder/data/examples/eval-judges.ts +145 -0
- package/host-builder/data/examples/evals.ts +86 -0
- package/host-builder/data/examples/evaluation-gate.ts +40 -0
- package/host-builder/data/examples/execution-timeline.ts +173 -0
- package/host-builder/data/examples/external-agent.ts +541 -0
- package/host-builder/data/examples/external-app-db-backed.ts +344 -0
- package/host-builder/data/examples/governance-deny.ts +122 -0
- package/host-builder/data/examples/guardrail-packs.ts +240 -0
- package/host-builder/data/examples/headless-host.ts +245 -0
- package/host-builder/data/examples/hooks-audit-command.mjs +31 -0
- package/host-builder/data/examples/hooks-json.ts +87 -0
- package/host-builder/data/examples/host-builder-agent.ts +150 -0
- package/host-builder/data/examples/host-hooks.ts +71 -0
- package/host-builder/data/examples/host-step-loop-timeline.ts +212 -0
- package/host-builder/data/examples/hosted-sandbox.ts +48 -0
- package/host-builder/data/examples/instruction-injection.ts +127 -0
- package/host-builder/data/examples/jsonl-stores-branching.ts +49 -0
- package/host-builder/data/examples/long-term-memory.ts +158 -0
- package/host-builder/data/examples/manifest.ts +112 -0
- package/host-builder/data/examples/mcp-server.ts +48 -0
- package/host-builder/data/examples/mcp-trust.ts +173 -0
- package/host-builder/data/examples/memory-and-wiki.ts +315 -0
- package/host-builder/data/examples/memory-lifecycle.ts +302 -0
- package/host-builder/data/examples/memory-system.ts +252 -0
- package/host-builder/data/examples/messaging-agent.ts +70 -0
- package/host-builder/data/examples/minimal-host-app.ts +41 -0
- package/host-builder/data/examples/model-router-aggregate-budgets.ts +364 -0
- package/host-builder/data/examples/model-router.ts +106 -0
- package/host-builder/data/examples/obscura.ts +48 -0
- package/host-builder/data/examples/observability.ts +116 -0
- package/host-builder/data/examples/open-connector-sidecar.ts +105 -0
- package/host-builder/data/examples/openai-compatible.ts +70 -0
- package/host-builder/data/examples/package-skills.ts +85 -0
- package/host-builder/data/examples/phase9-coding-intelligence.ts +221 -0
- package/host-builder/data/examples/provider-registration.ts +29 -0
- package/host-builder/data/examples/provider-resolver.ts +39 -0
- package/host-builder/data/examples/rag.ts +40 -0
- package/host-builder/data/examples/remote-agent-server.ts +45 -0
- package/host-builder/data/examples/remote-agent.ts +124 -0
- package/host-builder/data/examples/research-ledger.ts +79 -0
- package/host-builder/data/examples/revocation-propagation.ts +287 -0
- package/host-builder/data/examples/run-feedback.ts +93 -0
- package/host-builder/data/examples/scanned-document-rag.ts +48 -0
- package/host-builder/data/examples/sdk-basics.ts +21 -0
- package/host-builder/data/examples/secure-agent.ts +55 -0
- package/host-builder/data/examples/semantic-memory.ts +52 -0
- package/host-builder/data/examples/serve-tools.ts +495 -0
- package/host-builder/data/examples/session-memory.ts +317 -0
- package/host-builder/data/examples/session-search.ts +131 -0
- package/host-builder/data/examples/session.ts +52 -0
- package/host-builder/data/examples/side-call.ts +64 -0
- package/host-builder/data/examples/signal-agent.ts +9 -0
- package/host-builder/data/examples/skills-progressive-disclosure.ts +88 -0
- package/host-builder/data/examples/skills.ts +19 -0
- package/host-builder/data/examples/sqlite-resume.ts +147 -0
- package/host-builder/data/examples/system-project-prompts.ts +74 -0
- package/host-builder/data/examples/system-prompts.ts +19 -0
- package/host-builder/data/examples/telegram-agent.ts +30 -0
- package/host-builder/data/examples/tool-narrowing-planes.ts +99 -0
- package/host-builder/data/examples/tools.ts +29 -0
- package/host-builder/data/examples/validator.ts +67 -0
- package/host-builder/data/examples/web-no-key.ts +85 -0
- package/host-builder/data/examples/web-research.ts +35 -0
- package/host-builder/data/examples/workflow-event-sink.ts +114 -0
- package/host-builder/data/examples/workflow-loop.ts +93 -0
- package/host-builder/data/examples/workflow-multimodal-document.ts +94 -0
- package/host-builder/data/examples/workflow-parallel-research.ts +111 -0
- package/host-builder/data/examples/workflow-postgres-resume.ts +75 -0
- package/host-builder/data/examples/workflow-research-and-review.ts +98 -0
- package/host-builder/data/examples/workflow-sqlite-resume.ts +163 -0
- package/host-builder/data/examples.json +130 -0
- package/host-builder/skills/prism-host-builder/SKILL.md +85 -0
- package/host-builder/skills/prism-host-builder/references/choosing.md +101 -0
- package/host-builder/skills/prism-host-builder/references/layout.md +52 -0
- package/host-builder/skills/prism-host-builder/references/pitfalls.md +50 -0
- package/host-builder/skills/prism-host-builder/references/recipes.md +129 -0
- package/host-builder/skills/prism-host-builder/references/security.md +52 -0
- package/host-builder/skills/prism-host-builder/references/upgrading.md +67 -0
- package/host-builder/skills/prism-host-builder/references/verification.md +108 -0
- package/host-builder/src/check/child.ts +108 -0
- package/host-builder/src/check/conformance.ts +13 -0
- package/host-builder/src/check/inspect.ts +20 -0
- package/host-builder/src/check/manifest.ts +23 -0
- package/host-builder/src/check/runner.ts +181 -0
- package/host-builder/src/check/targets.ts +65 -0
- package/host-builder/src/errors.ts +35 -0
- package/host-builder/src/index.ts +25 -0
- package/host-builder/src/indexes.ts +145 -0
- package/host-builder/src/install/install.ts +400 -0
- package/host-builder/src/install/targets.ts +50 -0
- package/host-builder/src/lookup/api.ts +127 -0
- package/host-builder/src/lookup/bound.ts +38 -0
- package/host-builder/src/lookup/docs.ts +238 -0
- package/host-builder/src/lookup/errors.ts +92 -0
- package/host-builder/src/lookup/examples.ts +117 -0
- package/host-builder/src/lookup/text.ts +60 -0
- package/host-builder/src/server.ts +300 -0
- package/host-builder/src/version.ts +38 -0
- package/mcp-server/README.md +219 -0
- package/mcp-server/src/bounds.ts +23 -0
- package/mcp-server/src/host.ts +31 -0
- package/mcp-server/src/index.ts +27 -0
- package/mcp-server/src/serve-tools.ts +408 -0
- package/mcp-server/src/serve.ts +329 -0
- package/mcp-server/src/server.ts +331 -0
- package/mcp-server/src/session-map.ts +47 -0
- package/mcp-server/src/skill-resources.ts +85 -0
- package/mcp-server/src/types.ts +215 -0
- package/package.json +130 -4
- package/remote/README.md +244 -0
- package/remote/src/attribution.ts +22 -0
- package/remote/src/auth.ts +30 -0
- package/remote/src/bun-module.d.ts +34 -0
- package/remote/src/channel.ts +86 -0
- package/remote/src/connect.ts +212 -0
- package/remote/src/dispatcher.ts +282 -0
- package/remote/src/errors.ts +59 -0
- package/remote/src/host-ui.ts +152 -0
- package/remote/src/http-gate.ts +43 -0
- package/remote/src/index.ts +53 -0
- package/remote/src/jsonl.ts +69 -0
- package/remote/src/limits.ts +43 -0
- package/remote/src/mirror.ts +90 -0
- package/remote/src/pending.ts +22 -0
- package/remote/src/protocol.ts +107 -0
- package/remote/src/serve.ts +560 -0
- package/remote/src/session-proxy.ts +219 -0
- package/remote/src/sse.ts +38 -0
- package/remote/src/stdio-client.ts +41 -0
- package/remote/src/testing-fixtures/serve-stdio.ts +32 -0
- package/remote/src/testing.ts +230 -0
- package/remote/src/transport.ts +139 -0
- package/remote/src/transports/client.ts +126 -0
- package/remote/src/transports/network.ts +268 -0
- package/remote/src/wire.ts +244 -0
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
# Pitfalls
|
|
2
|
+
|
|
3
|
+
Match the error code first. `node_modules/@arnilo/prism-hosts/host-builder/data/errors.json` gives each code's owning package,
|
|
4
|
+
file and meaning. A package load error carries a short code; a `createAgent` that fails to load rejects before any run.
|
|
5
|
+
|
|
6
|
+
In the tables below the **Code** column holds only codes that exist in `errors.json`.
|
|
7
|
+
|
|
8
|
+
## Load failures
|
|
9
|
+
|
|
10
|
+
| Code | What happened | Fix |
|
|
11
|
+
| --- | --- | --- |
|
|
12
|
+
| `model_required` | `createAgent` got no `model` and the loop needs one. There is no default provider. | Pass `model: "provider/model"` or a `ModelSpec`, and list the provider package. A model-less loop is the only exception. |
|
|
13
|
+
| `ERR_PRISM_SLOT_CONFLICT` | Two packages provide one slot (usually `compaction`) and `slots` does not choose. | Add `slots: { compaction: "<package name>" }` to the `createAgent` config. This is the SDK's resolution, not a workaround. |
|
|
14
|
+
| `ERR_PRISM_CODING_PRINCIPAL_REQUIRED` | A tool with a durable effect (`shell`, `write`, `edit`, git commit) ran on an agent with no `principal`. | Pass `principal: { kind, id }` to `createAgent`. Do not add the tool to an allow list to get past it. |
|
|
15
|
+
| `ERR_PRISM_UNKNOWN_SLOT_OWNER` | A `slots` assignment names a package that did not provide that slot. | Check the exact package name and that the package is listed and provides the slot. |
|
|
16
|
+
| `manifest_slot_owner` | A manifest `slots` owner is not a listed, enabled entry. | Enable or add the entry, or change the owner. |
|
|
17
|
+
| `missing_service` | A package needs a service no loaded package provides (for example `work.sandbox` for `work_exec`). | List the package that provides it, or provide it from the host. Do not stub the service to silence the error. |
|
|
18
|
+
| `missing_package` | A required package is not listed, or its version is outside the required range. | List it with a version that satisfies the range in its `requires`. |
|
|
19
|
+
| `service_conflict` | Two packages provide one service name. | Drop one, or disable the duplicate with `disable`. |
|
|
20
|
+
| `duplicate_package` | The same package name is listed twice. | List it once. Change per-package options through `packageConfig`. |
|
|
21
|
+
| `tool_conflict` | A tool name is taken by another package, the host's tools or a reserved kernel name. | Rename the tool in your package. Never rely on a later registration shadowing an earlier one. |
|
|
22
|
+
| `skill_conflict` | A skill name is taken by another package or the host's skills. | Rename the skill; names are `domain-job` and unique across packages. |
|
|
23
|
+
| `skill_too_large` | A skill body is over the hard instruction cap. | Move detail into `references/` next to the `SKILL.md`. |
|
|
24
|
+
| `config_unknown_key` | Config has a key the package's schema does not declare. | Read the package README for its keys. Unknown config fails closed; do not add the key to the schema to pass. |
|
|
25
|
+
| `config_invalid` | A config value breaks the schema (type, range, shape). | Fix the value. |
|
|
26
|
+
| `secret_literal` | A literal was put in a secret field. | Use an `env:NAME` or `keyring:name` ref. |
|
|
27
|
+
| `kernel_range` | The kernel version does not satisfy the package's `requires.prism`. | Align versions; all `@arnilo/*` packages are lockstep with the kernel. |
|
|
28
|
+
| `kernel_api` | `requires.api` is not an API level this kernel supports. | Write the package against `api: 1` for 0.13. |
|
|
29
|
+
| `capability_missing` | The package used a capability it did not declare. | Add it to `capabilities`, only if the package really needs it. |
|
|
30
|
+
| `setup_failed` | `setup` threw, or a listed package failed to load. | Read the error cause; fix the package. Do not wrap `setup` in a try/catch that hides it. |
|
|
31
|
+
| `registration_closed` | A tool or contribution was registered after `setup` finished. | Register during `setup`. |
|
|
32
|
+
| `unknown_disable_id` | `disable` names an id no tool, hook, command or skill carries. | Copy the id from `agent.inspect()`. |
|
|
33
|
+
| `state_not_ready` | Session state was read before the session loaded its branch. | Read state inside a hook or tool, not at package setup. |
|
|
34
|
+
|
|
35
|
+
## Failures that carry no code
|
|
36
|
+
|
|
37
|
+
- **`bun install` rewrites the lockfile.** In a workspace it has produced duplicate lock keys. Do not run it to repair
|
|
38
|
+
a project unless asked; edit `package.json` and tell the person to install.
|
|
39
|
+
- **Copying a 0.12 sample.** A `store: "memory"` field, a `loop:` option or a model-invoked workflow no longer exists.
|
|
40
|
+
Read `references/upgrading.md` and copy from `data/examples/`.
|
|
41
|
+
- **Two memory packages and no `slots`.** Listing `@arnilo/prism-extensions/compaction` with
|
|
42
|
+
`@arnilo/prism-memory-system` is valid only with a `compaction` owner assigned.
|
|
43
|
+
- **A tool in `requiresTools` that is off.** The skill disappears from the catalog; it is not an error. Check
|
|
44
|
+
`agent.inspect().skills` before you debug the prompt.
|
|
45
|
+
- **A host answering nothing.** With no `host.ui`, every ask answers `unavailable`. Approval asks then suspend the run
|
|
46
|
+
and resume only when an answer arrives. A run that stops "for no reason" often waits for one.
|
|
47
|
+
- **Importing a package path.** `@arnilo/prism-tools/coding/src/x` is not public and is not in the tarball layout you
|
|
48
|
+
expect. Import the entry or a documented subpath listed in `api.json`.
|
|
49
|
+
- **Experimental memory shape.** A `^0.13.0` range cannot install an experimental package. Install it by tag and
|
|
50
|
+
expect the API to move.
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
# Recipes
|
|
2
|
+
|
|
3
|
+
One entry per common change. Each names a CI-tested example to copy (`node_modules/@arnilo/prism-hosts/host-builder/data/examples/<file>`)
|
|
4
|
+
and the page that explains it. The example is the code; this file never restates it, so it cannot drift.
|
|
5
|
+
`data/examples.json` says whether an example needs credentials.
|
|
6
|
+
|
|
7
|
+
After you copy an example, change the model to the host's, swap the mock provider for the real provider package, and
|
|
8
|
+
keep the rest.
|
|
9
|
+
|
|
10
|
+
## Create an agent and run it
|
|
11
|
+
|
|
12
|
+
Copy `examples/sdk-basics.ts`, then `examples/minimal-host-app.ts` for streaming events.
|
|
13
|
+
Page: `node_modules/@arnilo/prism/docs/agent.md`.
|
|
14
|
+
|
|
15
|
+
## Give an agent coding tools in a project
|
|
16
|
+
|
|
17
|
+
Copy `examples/coding-approval.ts` and drop the approval parts you do not need. List `toolsCoding({ root })` for
|
|
18
|
+
`read`, `write`, `edit`, `glob`, `grep` and `shell`, and `contextFiles({ root })` so `AGENTS.md` and project skills under
|
|
19
|
+
`root` reach the agent. Pass `principal: { kind: "user", id }` and `ownership` to `createAgent`: `shell` and the other
|
|
20
|
+
durable tools refuse to run without a principal. Add approval before you give the agent to anyone else
|
|
21
|
+
(`references/security.md`).
|
|
22
|
+
Pages: `node_modules/@arnilo/prism-tools/coding/README.md`, `node_modules/@arnilo/prism-extensions/context-files/README.md`.
|
|
23
|
+
|
|
24
|
+
## Add a tool the host owns
|
|
25
|
+
|
|
26
|
+
Copy `examples/tools.ts` for the registry and `examples/custom-tools-skills-context.ts` for a tool, a skill and a
|
|
27
|
+
context source in one agent. Declare the tool's `effects` so approval and governance can classify it.
|
|
28
|
+
Page: `node_modules/@arnilo/prism/docs/tools.md`.
|
|
29
|
+
|
|
30
|
+
## Write a package
|
|
31
|
+
|
|
32
|
+
Copy `examples/define-package.ts`. Declare `requires: { api: 1 }`, the capabilities you use, and a config schema
|
|
33
|
+
with `x-prism-secret` for any secret field. Register hooks with `prism.hooks.on(name, handler)`. A handler receives one
|
|
34
|
+
payload: read its fields in `data/api.json` under `members` (a `tool.call` payload is `ToolCallHookPayload`: the tool
|
|
35
|
+
`name`, its `args` object and its `effects`). Test the package with `packageConformance(pkg)` from
|
|
36
|
+
`@arnilo/prism/testing`, then test its behavior through an agent with scripted mock turns (`references/verification.md`).
|
|
37
|
+
`assertToolDispatchConforms` is for a tool, not a package.
|
|
38
|
+
Page: `node_modules/@arnilo/prism/docs/packages.md`.
|
|
39
|
+
|
|
40
|
+
## Ship a skill with a package
|
|
41
|
+
|
|
42
|
+
Copy `examples/package-skills.ts` and `examples/skills.ts`. Register the directory in `setup` with `prism.skills.addDir`
|
|
43
|
+
and list the directory in `package.json` `files`. Keep the description at 300 bytes or less and declare `requiresTools`
|
|
44
|
+
for tools that are always present.
|
|
45
|
+
Page: `node_modules/@arnilo/prism/docs/packages.md` ("Writing a package skill").
|
|
46
|
+
|
|
47
|
+
## Add a hook (gate, transform, observe)
|
|
48
|
+
|
|
49
|
+
Copy `examples/host-hooks.ts` for a budget gate and `examples/custom-builders.ts` for a `run.input` hook. Use a hook,
|
|
50
|
+
not a wrapper around the loop. A deny must return a reason; a throwing gate fails closed.
|
|
51
|
+
Page: `node_modules/@arnilo/prism/docs/hooks.md`.
|
|
52
|
+
|
|
53
|
+
## Load AGENTS.md, SYSTEM.md and workspace skills
|
|
54
|
+
|
|
55
|
+
Copy `examples/system-project-prompts.ts` and `examples/discover-skills.ts`. Context files are trust-gated.
|
|
56
|
+
Page: `node_modules/@arnilo/prism-extensions/context-files/README.md`.
|
|
57
|
+
|
|
58
|
+
## Make runs durable and resumable
|
|
59
|
+
|
|
60
|
+
Copy `examples/sqlite-resume.ts`, then `examples/durable-approval.ts` for a run that suspends on an approval and
|
|
61
|
+
resumes after a restart.
|
|
62
|
+
Page: `node_modules/@arnilo/prism/docs/slots.md`.
|
|
63
|
+
|
|
64
|
+
## Gate tool calls with approval
|
|
65
|
+
|
|
66
|
+
Copy `examples/approval.ts`, then `examples/coding-approval.ts` for a coding agent.
|
|
67
|
+
Page: `node_modules/@arnilo/prism-extensions/approval/README.md`.
|
|
68
|
+
|
|
69
|
+
## Add a model provider
|
|
70
|
+
|
|
71
|
+
Copy `examples/custom-provider.ts`, then run the provider conformance helpers.
|
|
72
|
+
Page: `node_modules/@arnilo/prism/docs/provider-kit.md`.
|
|
73
|
+
|
|
74
|
+
## Resolve a model by name from registered providers
|
|
75
|
+
|
|
76
|
+
Copy `examples/provider-resolver.ts`.
|
|
77
|
+
Page: `node_modules/@arnilo/prism/docs/models.md`.
|
|
78
|
+
|
|
79
|
+
## Serve an agent
|
|
80
|
+
|
|
81
|
+
- ACP (editors): `examples/acp.ts`. Page: `node_modules/@arnilo/prism-hosts/acp/README.md`.
|
|
82
|
+
- AG-UI (browser): `examples/ag-ui-server.ts`. Page: `node_modules/@arnilo/prism-hosts/ag-ui/README.md`.
|
|
83
|
+
- MCP: `examples/mcp-server.ts`. Page: `node_modules/@arnilo/prism-hosts/mcp-server/README.md`.
|
|
84
|
+
- Remote: `examples/remote-agent-server.ts` and `examples/remote-agent.ts`.
|
|
85
|
+
Page: `node_modules/@arnilo/prism-hosts/remote/README.md`.
|
|
86
|
+
- Chat: `examples/telegram-agent.ts`. Page: `node_modules/@arnilo/prism-hosts/channels/README.md`.
|
|
87
|
+
|
|
88
|
+
Every server needs authentication and an ownership mapping before it listens beyond loopback: read
|
|
89
|
+
`references/security.md` first.
|
|
90
|
+
|
|
91
|
+
## Use MCP servers as tools
|
|
92
|
+
|
|
93
|
+
Copy `examples/mcp-trust.ts` for the trust decision and `examples/connected-slack-mcp.ts` for a hosted server with
|
|
94
|
+
tokens kept out of model context.
|
|
95
|
+
Page: `node_modules/@arnilo/prism-extensions/mcp/README.md`.
|
|
96
|
+
|
|
97
|
+
## Orchestrate several agents
|
|
98
|
+
|
|
99
|
+
Copy `examples/workflow-research-and-review.ts`, then `examples/workflow-sqlite-resume.ts` for durable checkpoints.
|
|
100
|
+
For a model-facing sub-agent tool, copy `examples/delegate.ts`.
|
|
101
|
+
Pages: `node_modules/@arnilo/prism-extensions/workflows/README.md`, `node_modules/@arnilo/prism-extensions/delegate/README.md`.
|
|
102
|
+
|
|
103
|
+
## Drive a vendor coding agent
|
|
104
|
+
|
|
105
|
+
Copy `examples/external-agent.ts`, then `examples/custom-adapter.ts`.
|
|
106
|
+
Pages: `node_modules/@arnilo/prism/docs/drivers.md`, `node_modules/@arnilo/prism/docs/agent-adapters.md`.
|
|
107
|
+
|
|
108
|
+
## Compact long history
|
|
109
|
+
|
|
110
|
+
Copy `examples/compaction.ts`. If any other package you list also provides `compaction` (observational memory, or a
|
|
111
|
+
package the project already has), assign the owner in `slots` and check `agent.inspect().slots`
|
|
112
|
+
(`references/choosing.md`).
|
|
113
|
+
Page: `node_modules/@arnilo/prism-extensions/compaction/README.md`.
|
|
114
|
+
|
|
115
|
+
## Drive the host from a manifest
|
|
116
|
+
|
|
117
|
+
Copy `examples/manifest.ts`. The manifest records packages, ranges, integrity and capabilities; `prism add` installs
|
|
118
|
+
and `prism verify` re-checks.
|
|
119
|
+
Page: `node_modules/@arnilo/prism/docs/manifest.md`.
|
|
120
|
+
|
|
121
|
+
## Route across models with a budget
|
|
122
|
+
|
|
123
|
+
Copy `examples/model-router.ts`, then `examples/model-router-aggregate-budgets.ts`.
|
|
124
|
+
Page: `node_modules/@arnilo/prism-extensions/model-router/README.md`.
|
|
125
|
+
|
|
126
|
+
## Observe and evaluate
|
|
127
|
+
|
|
128
|
+
Copy `examples/observability.ts` for OpenTelemetry and `examples/evals.ts` for a dataset and scorers.
|
|
129
|
+
Pages: `node_modules/@arnilo/prism-extensions/observability/README.md`, `node_modules/@arnilo/prism-hosts/evals/README.md`.
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
# Security
|
|
2
|
+
|
|
3
|
+
A short checklist. The full guide is `node_modules/@arnilo/prism/docs/host-security.md`; read it before you expose an
|
|
4
|
+
agent to users, third-party packages, durable storage or real credentials. Nothing here relaxes a fail-closed rule.
|
|
5
|
+
If a check blocks you, fix the input, not the check.
|
|
6
|
+
|
|
7
|
+
## Secrets
|
|
8
|
+
|
|
9
|
+
- Config, the manifest and tests hold refs: `env:NAME` or `keyring:name`. A literal in a secret field fails with
|
|
10
|
+
`secret_literal`. Credentials resolve through the `credentials` slot; the kernel default reads `env:NAME` only.
|
|
11
|
+
- A secret never appears in argv, logs, events, `inspect()` output, error messages or fixtures. Use a fake ref and a
|
|
12
|
+
fake value in tests. Do not print a resolved value to prove it worked.
|
|
13
|
+
- Never put a key in a prompt, a skill, a recipe or a commit. If you see one in the project, tell the person and stop;
|
|
14
|
+
do not copy it.
|
|
15
|
+
- Subscription logins (a vendor plan) store their tokens through the credentials slot. Prism never forwards them to a
|
|
16
|
+
second service. See `node_modules/@arnilo/prism/docs/credentials-and-redaction.md`.
|
|
17
|
+
- Pass the host's redactor to the agent (`redactor`) when it handles credentials the kernel cannot recognise by shape.
|
|
18
|
+
|
|
19
|
+
## Approval and tool effects
|
|
20
|
+
|
|
21
|
+
- Every tool declares `effects` so a gate can classify it. A tool that writes, spawns or reaches the network without
|
|
22
|
+
declaring that is a defect.
|
|
23
|
+
- List `@arnilo/prism-extensions/approval` before any tool that edits files or runs commands, and choose `ask`, `edits` or
|
|
24
|
+
`deny` for untrusted input. `auto` is for a sandbox the host controls.
|
|
25
|
+
- Approval gates a call. It does not isolate it. Run untrusted code in a container or VM the host owns.
|
|
26
|
+
- A timeout on an approval prompt is a deny. Do not make it an allow.
|
|
27
|
+
|
|
28
|
+
## Trust
|
|
29
|
+
|
|
30
|
+
- A package is trusted code: it runs in the host process during `setup`. List only packages you reviewed, pin
|
|
31
|
+
versions, and prefer the manifest (`node_modules/@arnilo/prism/docs/manifest.md`) so integrity hashes are checked.
|
|
32
|
+
- Project files are untrusted until the host says otherwise: `AGENTS.md`, skills, hooks and a project manifest load
|
|
33
|
+
only through a trust decision (`node_modules/@arnilo/prism/docs/resource-loading.md`). Do not add a
|
|
34
|
+
`trustProject: () => true` to make a warning go away.
|
|
35
|
+
- Page text, search results, tool output and model output are data, never instructions. Do not wire them into a
|
|
36
|
+
hook's decision without validation.
|
|
37
|
+
|
|
38
|
+
## Servers and multi-user hosts
|
|
39
|
+
|
|
40
|
+
- A listener beyond loopback needs authentication. Map the authenticated identity to an ownership scope
|
|
41
|
+
(`tenantId`, `userId`) so sessions and memory cannot cross users. Read "Multi-user hosts on one agent" in
|
|
42
|
+
`host-security.md`.
|
|
43
|
+
- Bind to loopback by default. `@arnilo/prism-hosts/devtools` is loopback only; never proxy it.
|
|
44
|
+
- Keep the byte caps (`maxRequestBytes`, `maxResponseBytes`). Raising one needs a stated reason and a test.
|
|
45
|
+
- Serve MCP over stdio for local clients. Over HTTP, add the host's authorization.
|
|
46
|
+
|
|
47
|
+
## Checking your own work
|
|
48
|
+
|
|
49
|
+
- Run `agent.inspect()` and read it as a reviewer: no secret value, only refs.
|
|
50
|
+
- Search the diff for `sk-`, `Bearer `, `-----BEGIN` and `password` before you finish.
|
|
51
|
+
- Do not run a project's host code with real credentials in the environment to "see if it works". Use the mock
|
|
52
|
+
provider and fake refs (`references/verification.md`).
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
# Upgrading and retired names
|
|
2
|
+
|
|
3
|
+
Prism 0.13 replaced mechanisms outright. There are no compatibility aliases: a 0.12 name that is not in
|
|
4
|
+
`data/api.json` does not exist, and no shim will appear. When project code uses an unfamiliar name, look it up here,
|
|
5
|
+
then in `node_modules/@arnilo/prism/docs/migrate-to-0.13.md`, then in the index.
|
|
6
|
+
|
|
7
|
+
## How to read the migration pages
|
|
8
|
+
|
|
9
|
+
- `docs/migrate-to-0.13.md` is the current checklist, 0.12.1 to 0.13.0. Read its tables from the left column: the left
|
|
10
|
+
is the old name, the right is where it went. The retired-name map below is a condensed copy; the page wins.
|
|
11
|
+
- `docs/migration.md` is the era index of older notes. `docs/migrate-to-0.5.md` to `0.11.md` describe retired contracts
|
|
12
|
+
and ship in the tarball only as history. Do not follow them for 0.13.
|
|
13
|
+
- `node_modules/@arnilo/prism/docs/history/` also ships and describes 0.12. Do not read it for how to build a 0.13
|
|
14
|
+
host, and do not copy a snippet from it. If code matches a 0.12 contract, assume it is wrong.
|
|
15
|
+
|
|
16
|
+
## Upgrade steps
|
|
17
|
+
|
|
18
|
+
1. Record the installed version of `@arnilo/prism` and each `@arnilo/*` package. They move in lockstep: align them all.
|
|
19
|
+
2. Replace every 0.12 family dependency with its native package (map below), in `package.json` and imports.
|
|
20
|
+
3. Rewrite `createAgent` to `await createAgent({ model, packages })`. Construction is async.
|
|
21
|
+
4. Move each removed config field to the hook or package that owns it (map below).
|
|
22
|
+
5. Typecheck. Each missing export is a retired name; fix it from the map, not with a cast.
|
|
23
|
+
6. Run `references/verification.md`. Then search for the left-column names below to confirm none remain.
|
|
24
|
+
|
|
25
|
+
## Retired-name map
|
|
26
|
+
|
|
27
|
+
Left column is the retired name. Everything in it is gone.
|
|
28
|
+
|
|
29
|
+
| Retired | Use instead |
|
|
30
|
+
| --- | --- |
|
|
31
|
+
| `createAgentSession`, `createExtensionKernel` | `await agent.session()` and a package listed in `packages` |
|
|
32
|
+
| `extensions: [...]` | `packages: [...]`; installed is listed is active |
|
|
33
|
+
| `provider: "x"`, `model: "y"` (two fields) | `model: { provider: "x", model: "y" }` plus the provider package in `packages` |
|
|
34
|
+
| `tools: { use: ["coding"] }` | `packages: [toolsCoding({ root })]`; a package instance, not a name |
|
|
35
|
+
| `identity: { profile }` | `principal: { kind, id }`, with `ownership` for the scope the host serves. Tools with durable effects fail closed without a principal |
|
|
36
|
+
| `store: "memory"` | the store slot default; list a store package for anything durable |
|
|
37
|
+
| `activateKernel` | list the package; installed is listed is active |
|
|
38
|
+
| `defineAgent` | `createAgent` |
|
|
39
|
+
| `@arnilo/prism-agent-sdk` | `@arnilo/prism` plus the native packages |
|
|
40
|
+
| `@arnilo/prism-providers` | `@arnilo/prism-ai/<vendor>` subpaths |
|
|
41
|
+
| `@arnilo/prism-core` | the kernel `@arnilo/prism` plus native packages |
|
|
42
|
+
| `@arnilo/prism-coding-tools` | `@arnilo/prism-tools/coding`, `-tools-openapi`, `-tools-computer-use`, `@arnilo/prism-extensions/approval` |
|
|
43
|
+
| `@arnilo/prism-web-tools` | `@arnilo/prism-tools/web`, `@arnilo/prism-tools/browser` |
|
|
44
|
+
| `@arnilo/prism-work` | `@arnilo/prism-tools/work` |
|
|
45
|
+
| `@arnilo/prism-hooks` | `@arnilo/prism-extensions/hooks-json` |
|
|
46
|
+
| `@arnilo/prism-acp-agent` | `@arnilo/prism-hosts/acp` (`serveAcp`) |
|
|
47
|
+
| `@arnilo/prism-code` | the private reference host; copy its patterns, never depend on it |
|
|
48
|
+
| `@arnilo/prism-all` | list the packages you need |
|
|
49
|
+
| `stopHooks` | a `run.end` hook |
|
|
50
|
+
| `turnPolicy` | a `turn.before` hook, cost policy |
|
|
51
|
+
| `providerRequestPolicies` | a `model.request` hook |
|
|
52
|
+
| `instructionInjectors`, `promptBuilder`, `inputBuilder` | a `context.build` hook (`@arnilo/prism-extensions/context-files`, `@arnilo/prism-extensions/context-engineering`) |
|
|
53
|
+
| `toolNarrowing` | `RunOptions.tools.only` |
|
|
54
|
+
| `beforeProviderTurn` | the `model.call` around hook |
|
|
55
|
+
| `forwardAgentEvents` | an `observe` hook |
|
|
56
|
+
| `createSecureAgent` | `createAgent` with `@arnilo/prism-extensions/governance` and `@arnilo/prism-extensions/approval` listed |
|
|
57
|
+
| `wiki_search`, `wiki_read_page`, `wiki_record_insight` | `wiki.search` and `wiki.read` (`@arnilo/prism-knowledge/wiki`), `memory.insert` |
|
|
58
|
+
|
|
59
|
+
Plain words that are still valid config names (`loop`, `context`, `permission`, `middleware` when used as a
|
|
60
|
+
hook concept) are not listed: judge them by whether `api.json` or the docs define them in 0.13. `middleware` and
|
|
61
|
+
`guardrails` as config fields moved to the matching hooks (`model.request`, `tool.call`, `tool.result`) and to
|
|
62
|
+
`@arnilo/prism-extensions/guardrail-packs`.
|
|
63
|
+
|
|
64
|
+
## Fabric rename
|
|
65
|
+
|
|
66
|
+
The memory fabric's pinned core is now standing rules (`rules`, per-scope `rules.md`, editable). That package is
|
|
67
|
+
experimental and may change again; read its README, not this table.
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
# Verification
|
|
2
|
+
|
|
3
|
+
Prove a change without a live model, a network or a real credential. Run these in order and stop at the first failure.
|
|
4
|
+
Report what ran and what you could not run.
|
|
5
|
+
|
|
6
|
+
## 1. Typecheck
|
|
7
|
+
|
|
8
|
+
Run the project's own check (`bun run typecheck`, or `bunx tsc --noEmit -p .`). Prism ships TypeScript source and the
|
|
9
|
+
workspace typechecks against it, so an import of a name that is not in `data/api.json` fails here. A new `as unknown
|
|
10
|
+
as` cast is a signal that you used the wrong type.
|
|
11
|
+
|
|
12
|
+
## 2. Load the agent on the mock provider and read `inspect()`
|
|
13
|
+
|
|
14
|
+
Build the agent exactly as the host does, with the real package list, and replace only the provider with
|
|
15
|
+
`mockProvider` from `@arnilo/prism/testing`. Then read `agent.inspect()`: it lists loaded packages, tools, skills,
|
|
16
|
+
commands, hooks in execution order, slot owners, disabled ids and status notes, with no I/O. Check that every package you
|
|
17
|
+
meant to list is `loaded`, that each slot has the owner you expect, and that no secret value appears (refs only).
|
|
18
|
+
Page: `node_modules/@arnilo/prism/docs/packages.md` ("Inspecting an agent").
|
|
19
|
+
|
|
20
|
+
## 3. Conformance helpers
|
|
21
|
+
|
|
22
|
+
Page: `node_modules/@arnilo/prism/docs/testing.md`. The first three come from `@arnilo/prism/testing`; check
|
|
23
|
+
`data/api.json` for the subpath before you import any other.
|
|
24
|
+
|
|
25
|
+
- `packageConformance(input, { config?, mockProvider? })` for a package you wrote. It checks setup and dispose
|
|
26
|
+
idempotence, no leaks after dispose, a valid config schema, capabilities that cover usage, no secret in `inspect()`,
|
|
27
|
+
and that an unavailable host fails closed.
|
|
28
|
+
- `loopConformance(strategy)` for a custom loop.
|
|
29
|
+
- `storeConformance(factory, { reopen })` for a custom session store; the `reopen` leg proves a restart.
|
|
30
|
+
- `assertGateIntegrity` (subpath `@arnilo/prism/testing/tool-conformance`) for a gate that must not be bypassed by a loop.
|
|
31
|
+
|
|
32
|
+
```ts
|
|
33
|
+
import { definePackage } from "@arnilo/prism";
|
|
34
|
+
import { packageConformance } from "@arnilo/prism/testing";
|
|
35
|
+
|
|
36
|
+
const audit = definePackage({
|
|
37
|
+
name: "@acme/audit",
|
|
38
|
+
version: "1.0.0",
|
|
39
|
+
requires: { api: 1 },
|
|
40
|
+
setup(prism) {
|
|
41
|
+
prism.hooks.on("tool.result", () => {});
|
|
42
|
+
},
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
const report = await packageConformance(audit);
|
|
46
|
+
if (!report.ok) {
|
|
47
|
+
throw new Error(report.checks.filter((check) => !check.ok).map((check) => check.message).join("\n"));
|
|
48
|
+
}
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
## 4. Run the host's own tests
|
|
52
|
+
|
|
53
|
+
The typecheck proves types, not behavior. Drive the host with scripted mock turns that call its tools and read the
|
|
54
|
+
tool results: a missing principal, a gate that never fires or a package that never loads shows up there, not in `tsc`.
|
|
55
|
+
|
|
56
|
+
Answer approvals with `createScriptedHostUi` instead of a person; a test that answers `yes` to everything proves
|
|
57
|
+
nothing, so also test a `no`. Use the mock provider's scripted turns to drive a tool call and assert the result.
|
|
58
|
+
Look at `examples/approval.ts` and `examples/tools.ts`.
|
|
59
|
+
|
|
60
|
+
## 5. Examples as the oracle
|
|
61
|
+
|
|
62
|
+
The shipped examples run offline in CI. When a recipe says to copy an example, run your adaptation the same way the
|
|
63
|
+
example runs. If it needs credentials, `data/examples.json` says so; skip it and say so.
|
|
64
|
+
|
|
65
|
+
## 6. Verify installed packages
|
|
66
|
+
|
|
67
|
+
For a manifest host, `prism verify` re-hashes the installed packages and imports enabled ones. It imports project code
|
|
68
|
+
only with `--trust-project`; do not pass that flag on a project you have not reviewed. The MCP tool
|
|
69
|
+
`prism_check_manifest` runs the same check and imports project code only when the server was started with
|
|
70
|
+
`--trust-project`; it never takes that choice from a tool call.
|
|
71
|
+
|
|
72
|
+
## 7. The MCP tools
|
|
73
|
+
|
|
74
|
+
If the `prism-host-builder` MCP server is connected (`prism-host-builder mcp`), use its read-only tools to confirm a
|
|
75
|
+
name, a signature or an error code before you rely on it. They read the same `data/` files, so a file read gives the
|
|
76
|
+
same answer.
|
|
77
|
+
|
|
78
|
+
- `prism_api` with `symbol` (exact export name) or `query` (words), optionally `package`: signature, package, import
|
|
79
|
+
specifier, docs and examples.
|
|
80
|
+
- `prism_errors` with `code`: meaning, owner, declaring file and line, docs, and the fix `pitfalls.md` lists.
|
|
81
|
+
- `prism_examples` with `query` or `package`, or `path` to read one example's source.
|
|
82
|
+
- `prism_docs` with `query`: heading-anchored excerpts from the docs installed in this project.
|
|
83
|
+
|
|
84
|
+
Each call checks the installed `@arnilo/prism` against the version the indexes describe. A mismatch is an
|
|
85
|
+
`ERR_PRISM_HOST_BUILDER_VERSION` tool error naming both versions and the fix; do not work around it, install the
|
|
86
|
+
matching `@arnilo/prism-hosts/host-builder`. An unknown name returns the nearest names, not an error. The server also serves
|
|
87
|
+
the installed docs as `prism-docs://` resources and three prompts: `build-host`, `add-capability` and `upgrade-host`.
|
|
88
|
+
|
|
89
|
+
Three more tools check the host's own code. They are not read-only: each runs that code in a child process, and only
|
|
90
|
+
for targets the user named when the server was started (`--entry <file>#<export>`, `--package <file>#<export>`). Ask the
|
|
91
|
+
user to restart the server with the flag when a tool says none is configured; never try to pass a path.
|
|
92
|
+
|
|
93
|
+
- `prism_inspect_host` with `entry`: builds the agent with the configured factory, returns `agent.inspect()` (packages,
|
|
94
|
+
tools, skills with `requiresTools`, hooks, slot owners, status notes) and disposes it. The factory must build the agent
|
|
95
|
+
on `mockProvider` from `@arnilo/prism/testing` and run nothing: a factory that runs a session or makes an outbound
|
|
96
|
+
request fails with `ERR_PRISM_HOST_BUILDER_CHECK_MODEL_CALL`. The child sees only `PATH`, `HOME`, `TMPDIR`,
|
|
97
|
+
`PRISM_HOME` and the `--pass-env` names, plus `PRISM_HOST_BUILDER_CHECK=1`, so a missing credential fails closed.
|
|
98
|
+
- `prism_check_manifest`: what `prism verify` does, honouring `--trust-project`.
|
|
99
|
+
- `prism_check_package` with `package`: `packageConformance` on the configured package, one result per check.
|
|
100
|
+
|
|
101
|
+
A result is `{ ok, result | error, timedOut, truncated }`. `ok: true` means the check ran; a package that fails
|
|
102
|
+
conformance is `ok: true` with `result.ok: false` and the failing checks listed.
|
|
103
|
+
|
|
104
|
+
## What not to do
|
|
105
|
+
|
|
106
|
+
- Do not call a live provider "to see if it works". Use the mock provider and fake refs.
|
|
107
|
+
- Do not mark a check passed that you did not run. Name it as unchecked.
|
|
108
|
+
- Do not delete or loosen a failing test, approval mode or validator. Fix the cause.
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The check child: `bun child.ts <inspect|manifest|conformance> <resultFile> [<file> <export>] [--trust-project]`.
|
|
3
|
+
* It runs inside the host project (the runner sets the cwd and a filtered environment), imports the host's own
|
|
4
|
+
* code, and writes `{ ok, value | code, message }` to `resultFile`. Nothing here is imported by the server.
|
|
5
|
+
*/
|
|
6
|
+
import { writeFileSync } from "node:fs";
|
|
7
|
+
import { createRequire } from "node:module";
|
|
8
|
+
import { join } from "node:path";
|
|
9
|
+
import { pathToFileURL } from "node:url";
|
|
10
|
+
import { HostBuilderError } from "../errors.js";
|
|
11
|
+
|
|
12
|
+
type Reported = { ok: true; value: unknown } | { ok: false; code?: string; message: string; value?: unknown };
|
|
13
|
+
|
|
14
|
+
function report(resultFile: string, value: Reported): void {
|
|
15
|
+
writeFileSync(resultFile, JSON.stringify(value));
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/** Resolves a kernel subpath from the host project, not from this package, so the check uses the host's install. */
|
|
19
|
+
async function kernel<T>(subpath: string): Promise<T> {
|
|
20
|
+
return (await import(createRequire(join(process.cwd(), "noop.js")).resolve(`@arnilo/prism/${subpath}`))) as T;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
async function exported(file: string, name: string): Promise<unknown> {
|
|
24
|
+
const module = (await import(pathToFileURL(file).href)) as Record<string, unknown>;
|
|
25
|
+
if (!(name in module)) throw new HostBuilderError("ERR_PRISM_HOST_BUILDER_ENTRY", `${file} has no export named "${name}".`);
|
|
26
|
+
return module[name];
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/** Outbound `fetch` during a check is a model call or its stand-in: refuse it and remember it. */
|
|
30
|
+
function guardFetch(): string[] {
|
|
31
|
+
const calls: string[] = [];
|
|
32
|
+
globalThis.fetch = (async (input: unknown) => {
|
|
33
|
+
const url = input instanceof Request ? input.url : String(input);
|
|
34
|
+
calls.push(url.replace(/[?#].*$/, ""));
|
|
35
|
+
throw new Error("Outbound requests are refused while a host-builder check runs.");
|
|
36
|
+
}) as typeof fetch;
|
|
37
|
+
return calls;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
async function inspect(file: string, name: string): Promise<unknown> {
|
|
41
|
+
const calls = guardFetch();
|
|
42
|
+
const factory = await exported(file, name);
|
|
43
|
+
if (typeof factory !== "function") throw new HostBuilderError("ERR_PRISM_HOST_BUILDER_ENTRY", `${name} in ${file} is not a function.`);
|
|
44
|
+
const agent = (await factory()) as {
|
|
45
|
+
inspect?: () => unknown;
|
|
46
|
+
dispose?: () => Promise<void>;
|
|
47
|
+
sessions?: { list?: () => Promise<{ items?: unknown[] }> };
|
|
48
|
+
};
|
|
49
|
+
if (typeof agent?.inspect !== "function" || typeof agent.dispose !== "function")
|
|
50
|
+
throw new HostBuilderError("ERR_PRISM_HOST_BUILDER_ENTRY", `${name} in ${file} did not return an Agent (no inspect() or dispose()).`);
|
|
51
|
+
try {
|
|
52
|
+
const inspection = agent.inspect();
|
|
53
|
+
let sessions = 0;
|
|
54
|
+
try {
|
|
55
|
+
sessions = (await agent.sessions?.list?.())?.items?.length ?? 0;
|
|
56
|
+
} catch {
|
|
57
|
+
// A store without `listSessions` cannot tell; the fetch guard still covers a real provider.
|
|
58
|
+
}
|
|
59
|
+
if (calls.length > 0 || sessions > 0)
|
|
60
|
+
throw new HostBuilderError(
|
|
61
|
+
"ERR_PRISM_HOST_BUILDER_CHECK_MODEL_CALL",
|
|
62
|
+
calls.length > 0
|
|
63
|
+
? `The factory made an outbound request (${calls[0]}). An inspection factory must build the agent on the mock provider and run nothing.`
|
|
64
|
+
: `The factory ran ${sessions} session(s). An inspection factory must build the agent on the mock provider and run nothing.`,
|
|
65
|
+
);
|
|
66
|
+
return inspection;
|
|
67
|
+
} finally {
|
|
68
|
+
await agent.dispose();
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
async function conformance(file: string, name: string): Promise<unknown> {
|
|
73
|
+
const input = await exported(file, name);
|
|
74
|
+
if (input === undefined || input === null || (typeof input !== "function" && typeof input !== "object"))
|
|
75
|
+
throw new HostBuilderError("ERR_PRISM_HOST_BUILDER_ENTRY", `${name} in ${file} is not a package definition or instance.`);
|
|
76
|
+
const testing = await kernel<{ packageConformance: (input: unknown) => Promise<{ ok: boolean }> }>("testing");
|
|
77
|
+
return await testing.packageConformance(input);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
async function manifest(trustProject: boolean): Promise<unknown> {
|
|
81
|
+
const { verify } = await kernel<{ verify: (options: unknown) => Promise<Array<{ ok: boolean }>> }>("manifest");
|
|
82
|
+
const results = await verify({ root: process.cwd(), trustProject: () => trustProject });
|
|
83
|
+
return { ok: results.every((entry) => entry.ok), packages: results };
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
async function main(argv: string[]): Promise<void> {
|
|
87
|
+
const [kind, resultFile, file, name] = argv;
|
|
88
|
+
if (resultFile === undefined) throw new Error("child: missing result file");
|
|
89
|
+
try {
|
|
90
|
+
let value: unknown;
|
|
91
|
+
if (kind === "inspect") value = await inspect(file as string, name as string);
|
|
92
|
+
else if (kind === "conformance") value = await conformance(file as string, name as string);
|
|
93
|
+
else if (kind === "manifest") value = await manifest(argv.includes("--trust-project"));
|
|
94
|
+
else throw new Error(`child: unknown check "${kind}"`);
|
|
95
|
+
report(resultFile, { ok: true, value });
|
|
96
|
+
} catch (error) {
|
|
97
|
+
const code = (error as { code?: unknown })?.code;
|
|
98
|
+
report(resultFile, {
|
|
99
|
+
ok: false,
|
|
100
|
+
...(typeof code === "string" ? { code } : {}),
|
|
101
|
+
message: error instanceof Error ? error.message : String(error),
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
await main(process.argv.slice(2));
|
|
107
|
+
// Host code can leave handles open (timers, sockets); the result is written, so end the process here.
|
|
108
|
+
process.exit(0);
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { CheckSettings } from "./inspect.js";
|
|
2
|
+
import { type CheckOutcome, runCheck } from "./runner.js";
|
|
3
|
+
import type { CheckTarget } from "./targets.js";
|
|
4
|
+
|
|
5
|
+
export interface ConformanceReport {
|
|
6
|
+
readonly ok: boolean;
|
|
7
|
+
readonly checks: readonly { readonly name: string; readonly ok: boolean; readonly message?: string }[];
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
/** Runs `packageConformance` from the host's installed `@arnilo/prism/testing` on the configured package. */
|
|
11
|
+
export function checkPackage(settings: CheckSettings, target: CheckTarget): Promise<CheckOutcome<ConformanceReport>> {
|
|
12
|
+
return runCheck<ConformanceReport>({ ...settings, kind: "conformance", file: target.file, exportName: target.exportName });
|
|
13
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { type CheckOutcome, type RunCheckOptions, runCheck } from "./runner.js";
|
|
2
|
+
import type { CheckTarget } from "./targets.js";
|
|
3
|
+
|
|
4
|
+
/** `agent.inspect()` of the agent an inspection factory builds. Typed loosely: the host's installed kernel owns the shape. */
|
|
5
|
+
export interface InspectedHost {
|
|
6
|
+
readonly packages: readonly unknown[];
|
|
7
|
+
readonly tools: readonly unknown[];
|
|
8
|
+
readonly skills: readonly unknown[];
|
|
9
|
+
readonly hooks: Readonly<Record<string, readonly unknown[]>>;
|
|
10
|
+
readonly slots: Readonly<Record<string, string>>;
|
|
11
|
+
readonly notes?: readonly unknown[];
|
|
12
|
+
readonly [key: string]: unknown;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export type CheckSettings = Pick<RunCheckOptions, "root" | "timeoutMs" | "passEnv" | "env">;
|
|
16
|
+
|
|
17
|
+
/** Builds the host's agent in a child process, reads `agent.inspect()`, disposes the agent. */
|
|
18
|
+
export function inspectHost(settings: CheckSettings, target: CheckTarget): Promise<CheckOutcome<InspectedHost>> {
|
|
19
|
+
return runCheck<InspectedHost>({ ...settings, kind: "inspect", file: target.file, exportName: target.exportName });
|
|
20
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { CheckSettings } from "./inspect.js";
|
|
2
|
+
import { type CheckOutcome, runCheck } from "./runner.js";
|
|
3
|
+
|
|
4
|
+
export interface ManifestReport {
|
|
5
|
+
readonly ok: boolean;
|
|
6
|
+
readonly packages: readonly {
|
|
7
|
+
readonly name: string;
|
|
8
|
+
readonly scope: string;
|
|
9
|
+
readonly enabled: boolean;
|
|
10
|
+
readonly ok: boolean;
|
|
11
|
+
readonly issues: readonly { readonly code: string; readonly message: string }[];
|
|
12
|
+
/** `false` when the entry's code was not imported (disabled, or a project entry the host did not trust). */
|
|
13
|
+
readonly configChecked: boolean;
|
|
14
|
+
}[];
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* What `prism verify` does: re-hash every install and re-check config against the package's schema. A project
|
|
19
|
+
* package is imported only with `trustProject`; without it that entry gets the integrity check alone.
|
|
20
|
+
*/
|
|
21
|
+
export function checkManifest(settings: CheckSettings, trustProject: boolean): Promise<CheckOutcome<ManifestReport>> {
|
|
22
|
+
return runCheck<ManifestReport>({ ...settings, kind: "manifest", trustProject });
|
|
23
|
+
}
|