@arnilo/prism-hosts 0.13.0 → 0.14.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 +2 -0
- package/a2a/README.md +195 -0
- package/a2a/src/card.ts +208 -0
- package/a2a/src/codec.ts +523 -0
- package/a2a/src/connect.ts +415 -0
- package/a2a/src/errors.ts +87 -0
- package/a2a/src/index.ts +40 -0
- package/a2a/src/limits.ts +43 -0
- package/a2a/src/pending.ts +28 -0
- package/a2a/src/proxy.ts +526 -0
- package/a2a/src/serve.ts +886 -0
- package/acp/README.md +3 -1
- package/acp/src/limits.ts +3 -16
- package/acp/src/mapper.ts +26 -5
- package/acp/src/serve.ts +6 -5
- package/ag-ui/README.md +2 -1
- package/ag-ui/src/a2ui.ts +8 -31
- package/ag-ui/src/ag-ui-mapper.ts +27 -1
- package/ag-ui/src/encrypted-value.ts +3 -3
- package/ag-ui/src/handler.ts +4 -4
- package/ag-ui/src/index.ts +0 -33
- package/ag-ui/src/limits.ts +5 -88
- package/ag-ui/src/projectors.ts +8 -6
- package/ag-ui/src/renderer/bind.ts +2 -1
- package/channels/README.md +61 -5
- package/channels/src/discord-gateway.ts +354 -0
- package/channels/src/discord.ts +873 -0
- package/channels/src/index.ts +4 -2
- package/channels/src/limits.ts +3 -19
- package/channels/src/pairing.ts +1 -2
- package/channels/src/runtime-turn.ts +10 -2
- package/channels/src/signal.ts +11 -19
- package/channels/src/slack.ts +854 -0
- package/channels/src/telegram.ts +22 -44
- package/channels/src/types.ts +5 -2
- package/devtools/README.md +1 -1
- package/driver-process/src/driver.ts +3 -1
- package/driver-process/src/testing.ts +1 -1
- package/driver-process/src/turn.ts +5 -1
- package/evals/README.md +11 -7
- package/evals/src/calibration.ts +5 -13
- package/evals/src/compare-experiments.ts +1 -2
- package/evals/src/comparison.ts +7 -25
- package/evals/src/curate.ts +3 -9
- package/evals/src/dataset.ts +0 -2
- package/evals/src/index.ts +3 -20
- package/evals/src/injection.ts +33 -6
- package/evals/src/judge.ts +9 -13
- package/evals/src/limits.ts +0 -17
- package/evals/src/rubric-judge.ts +5 -10
- package/evals/src/scenario-runner.ts +8 -4
- package/evals/src/scenarios.ts +5 -5
- package/evals/src/score.ts +3 -5
- package/evals/src/stats.ts +0 -2
- package/evals/src/threshold.ts +3 -3
- package/evals/src/toolless-session.ts +7 -3
- package/evals/src/trace.ts +8 -14
- package/evals/src/trajectory.ts +45 -11
- package/evals/src/types.ts +2 -2
- package/evals/src/user-simulator.ts +1 -7
- package/evals/src/util.ts +3 -9
- package/headless/README.md +20 -1
- package/headless/src/authority.ts +14 -1
- package/headless/src/errors.ts +3 -1
- package/headless/src/index.ts +10 -1
- package/headless/src/limits.ts +2 -2
- package/headless/src/pending.ts +4 -3
- package/headless/src/recover.ts +126 -0
- package/headless/src/resume.ts +1 -1
- package/host-builder/data/api.json +1308 -1367
- package/host-builder/data/errors.json +207 -181
- package/host-builder/data/examples/a2a-client.ts +125 -0
- package/host-builder/data/examples/a2a-server.ts +133 -0
- package/host-builder/data/examples/autonomous-coding-loop.ts +1 -1
- package/host-builder/data/examples/build-workflow.ts +2 -2
- package/host-builder/data/examples/caveman-ponytail.ts +1 -1
- package/host-builder/data/examples/channel-discord.ts +176 -0
- package/host-builder/data/examples/channel-slack.ts +146 -0
- package/host-builder/data/examples/continue-after-failure.ts +80 -0
- package/host-builder/data/examples/custom-adapter.ts +1 -1
- package/host-builder/data/examples/decision-models.ts +1 -1
- package/host-builder/data/examples/define-package.ts +1 -1
- package/host-builder/data/examples/delegate.ts +74 -9
- package/host-builder/data/examples/durable-loops-and-approvals.ts +11 -10
- package/host-builder/data/examples/governance-deny.ts +1 -1
- package/host-builder/data/examples/guardrail-content.ts +126 -0
- package/host-builder/data/examples/headless-host.ts +1 -1
- package/host-builder/data/examples/long-running-job.ts +129 -0
- package/host-builder/data/examples/long-term-memory.ts +1 -1
- package/host-builder/data/examples/mcp-oauth.ts +197 -0
- package/host-builder/data/examples/mcp-trust.ts +1 -1
- package/host-builder/data/examples/memory-and-wiki.ts +3 -3
- package/host-builder/data/examples/memory-system.ts +31 -18
- package/host-builder/data/examples/model-router-aggregate-budgets.ts +1 -1
- package/host-builder/data/examples/parallel-tools.ts +70 -0
- package/host-builder/data/examples/remote-agent.ts +1 -1
- package/host-builder/data/examples/serve-tools.ts +1 -1
- package/host-builder/data/examples/session-memory.ts +29 -26
- package/host-builder/data/examples/side-call.ts +9 -5
- package/host-builder/data/examples/sqlite-resume.ts +1 -1
- package/host-builder/data/examples/structured-output.ts +57 -0
- package/host-builder/data/examples.json +15 -5
- package/host-builder/skills/prism-host-builder/SKILL.md +1 -1
- package/host-builder/skills/prism-host-builder/references/choosing.md +14 -10
- package/host-builder/skills/prism-host-builder/references/pitfalls.md +5 -3
- package/host-builder/skills/prism-host-builder/references/recipes.md +5 -5
- package/host-builder/skills/prism-host-builder/references/verification.md +1 -1
- package/host-builder/src/check/runner.ts +2 -3
- package/host-builder/src/server.ts +2 -2
- package/mcp-server/README.md +3 -3
- package/mcp-server/src/bounds.ts +3 -3
- package/mcp-server/src/serve-tools.ts +2 -9
- package/mcp-server/src/serve.ts +2 -4
- package/mcp-server/src/server.ts +10 -20
- package/package.json +12 -6
- package/remote/README.md +7 -4
- package/remote/src/channel.ts +6 -2
- package/remote/src/connect.ts +9 -3
- package/remote/src/errors.ts +3 -1
- package/remote/src/limits.ts +3 -13
- package/remote/src/mirror.ts +2 -1
- package/remote/src/pending.ts +4 -3
- package/remote/src/protocol.ts +3 -0
- package/remote/src/serve.ts +43 -5
- package/remote/src/session-proxy.ts +28 -5
- package/remote/src/testing.ts +3 -1
- package/remote/src/wire.ts +74 -14
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Structured Output Demo (plan 235 Task 3).
|
|
3
|
+
*
|
|
4
|
+
* A run that passes `providerOptions.structuredOutput` gets `RunResult.output` (the parsed, schema-checked
|
|
5
|
+
* value) or `RunResult.outputError` (paths and messages). The mock model here does not declare the
|
|
6
|
+
* `structuredOutput` capability, so `mode: "auto"` uses prompted mode: the schema goes to the model as one
|
|
7
|
+
* instruction block instead of a native response format. The first reply misses a required field, so the
|
|
8
|
+
* kernel sends one repair message listing the violation (`repair` defaults to 1); the second reply is valid.
|
|
9
|
+
*
|
|
10
|
+
* Run: bun examples/structured-output.ts
|
|
11
|
+
*/
|
|
12
|
+
import { createAgent, type ModelProvider, providerDone, providerTextDelta } from "@arnilo/prism";
|
|
13
|
+
import { providerPackage } from "@arnilo/prism/provider-kit";
|
|
14
|
+
|
|
15
|
+
const schema = {
|
|
16
|
+
type: "object",
|
|
17
|
+
properties: { city: { type: "string" }, celsius: { type: "number" } },
|
|
18
|
+
required: ["city", "celsius"],
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
function scriptedModel(): ModelProvider & { readonly prompts: string[] } {
|
|
22
|
+
const prompts: string[] = [];
|
|
23
|
+
let turn = 0;
|
|
24
|
+
return {
|
|
25
|
+
id: "mock",
|
|
26
|
+
prompts,
|
|
27
|
+
async *generate(request) {
|
|
28
|
+
turn += 1;
|
|
29
|
+
const last = request.messages.at(-1);
|
|
30
|
+
prompts.push(last?.content.map((block) => (block.type === "text" ? block.text : "")).join("") ?? "");
|
|
31
|
+
// First reply: a JSON object without the required `celsius`. Second: the corrected object.
|
|
32
|
+
yield providerTextDelta(turn === 1 ? '{"city":"Oslo"}' : '```json\n{"city":"Oslo","celsius":18}\n```');
|
|
33
|
+
yield providerDone();
|
|
34
|
+
},
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
const model = scriptedModel();
|
|
39
|
+
const agent = await createAgent({
|
|
40
|
+
model: { provider: "mock", model: "plain" },
|
|
41
|
+
packages: [providerPackage("structured-output-demo", [model])],
|
|
42
|
+
});
|
|
43
|
+
const session = await agent.session({ id: "structured-output-demo", create: true });
|
|
44
|
+
const result = await session.run("What is the weather in Oslo?", {
|
|
45
|
+
providerOptions: { structuredOutput: { name: "weather", schema, mode: "auto", repair: 1 } },
|
|
46
|
+
});
|
|
47
|
+
await agent.dispose();
|
|
48
|
+
|
|
49
|
+
console.log(
|
|
50
|
+
JSON.stringify({
|
|
51
|
+
status: result.status,
|
|
52
|
+
requests: model.prompts.length,
|
|
53
|
+
repairMessage: model.prompts[1],
|
|
54
|
+
output: result.output,
|
|
55
|
+
outputError: result.outputError ?? null,
|
|
56
|
+
}),
|
|
57
|
+
);
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"schemaVersion": 1,
|
|
3
|
-
"prismVersion": "0.
|
|
4
|
-
"contentHash": "
|
|
3
|
+
"prismVersion": "0.14.0",
|
|
4
|
+
"contentHash": "75fc16968d39788d3d4456f0868c2220580fa4537621501d37e2a473142ee766",
|
|
5
5
|
"examples": [
|
|
6
|
+
{"path":"examples/a2a-client.ts","title":"Bun-only demo (the examples tsconfig is Node-typed): the one Bun global this file uses.","gate":"executed","imports":["@arnilo/prism","@arnilo/prism-hosts/a2a","@arnilo/prism/provider-kit"],"requiresEnv":["DEMO_A2A_TOKEN"],"needsCredentials":true},
|
|
7
|
+
{"path":"examples/a2a-server.ts","title":"A real host verifies a token here. Without `authorize`, every call is refused.","gate":"executed","imports":["@arnilo/prism","@arnilo/prism-hosts/a2a","@arnilo/prism/provider-kit"],"requiresEnv":[],"needsCredentials":false},
|
|
6
8
|
{"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
9
|
{"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
10
|
{"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},
|
|
@@ -17,6 +19,8 @@
|
|
|
17
19
|
{"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
20
|
{"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
21
|
{"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},
|
|
22
|
+
{"path":"examples/channel-discord.ts","title":"Scripted REST API: the Gateway URL, message creation, and interaction callbacks.","gate":"executed","imports":["@arnilo/prism","@arnilo/prism-hosts/channels/discord","@arnilo/prism/provider-kit"],"requiresEnv":["DEMO_DISCORD_BOT_TOKEN"],"needsCredentials":true},
|
|
23
|
+
{"path":"examples/channel-slack.ts","title":"Scripted Slack Web API: every chat.postMessage succeeds and is recorded.","gate":"executed","imports":["@arnilo/prism","@arnilo/prism-hosts/channels/slack","@arnilo/prism/provider-kit"],"requiresEnv":["DEMO_SLACK_BOT_TOKEN","DEMO_SLACK_SIGNING_SECRET"],"needsCredentials":true},
|
|
20
24
|
{"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
25
|
{"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
26
|
{"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},
|
|
@@ -26,6 +30,7 @@
|
|
|
26
30
|
{"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
31
|
{"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
32
|
{"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},
|
|
33
|
+
{"path":"examples/continue-after-failure.ts","title":"Process A: the model calls `lookup`, then the provider fails on the next turn.","gate":"executed","imports":["@arnilo/prism","@arnilo/prism/provider-kit"],"requiresEnv":[],"needsCredentials":false},
|
|
29
34
|
{"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
35
|
{"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
36
|
{"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},
|
|
@@ -34,7 +39,7 @@
|
|
|
34
39
|
{"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
40
|
{"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
41
|
{"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},
|
|
42
|
+
{"path":"examples/delegate.ts","title":"Delegate Demo (plan 160 Task 4, plan 191 Task 5, plan 232 Tasks 4–5).","gate":"executed","imports":["@arnilo/prism","@arnilo/prism-extensions/delegate","@arnilo/prism-tools/coding","@arnilo/prism/provider-kit"],"requiresEnv":[],"needsCredentials":false},
|
|
38
43
|
{"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
44
|
{"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
45
|
{"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},
|
|
@@ -51,6 +56,7 @@
|
|
|
51
56
|
{"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
57
|
{"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
58
|
{"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},
|
|
59
|
+
{"path":"examples/guardrail-content.ts","title":"Guardrail content stages (plan 237 Task 2) — network-free: mock provider, in-memory store.","gate":"executed","imports":["@arnilo/prism","@arnilo/prism-extensions/guardrail-packs","@arnilo/prism/provider-kit"],"requiresEnv":[],"needsCredentials":false},
|
|
54
60
|
{"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
61
|
{"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
62
|
{"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},
|
|
@@ -60,13 +66,15 @@
|
|
|
60
66
|
{"path":"examples/hosted-sandbox.ts","title":"hosted-sandbox","gate":"executed","imports":["@arnilo/prism-tools/coding"],"requiresEnv":[],"needsCredentials":false},
|
|
61
67
|
{"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
68
|
{"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},
|
|
69
|
+
{"path":"examples/long-running-job.ts","title":"Each run calls `record` with its step number, then reports. The step is the count of user messages, so a continued","gate":"executed","imports":["@arnilo/prism","@arnilo/prism-extensions/store-jsonl","@arnilo/prism-extensions/workflows","@arnilo/prism/provider-kit"],"requiresEnv":[],"needsCredentials":false},
|
|
63
70
|
{"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
71
|
{"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},
|
|
72
|
+
{"path":"examples/mcp-oauth.ts","title":"The credentials slot a keyring would provide.","gate":"executed","imports":["@arnilo/prism","@arnilo/prism-extensions/mcp","@arnilo/prism/testing"],"requiresEnv":[],"needsCredentials":false},
|
|
65
73
|
{"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
74
|
{"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
75
|
{"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
76
|
{"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":"
|
|
77
|
+
{"path":"examples/memory-system.ts","title":"Working memory is an experimental opt-in, off unless configured. The example uses the model policy to show the","gate":"executed","imports":["@arnilo/prism","@arnilo/prism-memory-system"],"requiresEnv":[],"needsCredentials":false},
|
|
70
78
|
{"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
79
|
{"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
80
|
{"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},
|
|
@@ -76,6 +84,7 @@
|
|
|
76
84
|
{"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
85
|
{"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
86
|
{"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},
|
|
87
|
+
{"path":"examples/parallel-tools.ts","title":"Default: the four calls overlap.","gate":"executed","imports":["@arnilo/prism","@arnilo/prism/testing"],"requiresEnv":[],"needsCredentials":false},
|
|
79
88
|
{"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
89
|
{"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
90
|
{"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},
|
|
@@ -93,11 +102,12 @@
|
|
|
93
102
|
{"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
103
|
{"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
104
|
{"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":"
|
|
105
|
+
{"path":"examples/side-call.ts","title":"Passing the tool's session runs the call on the hook plane and charges it to this run's limits.","gate":"executed","imports":["@arnilo/prism","@arnilo/prism/testing"],"requiresEnv":[],"needsCredentials":false},
|
|
97
106
|
{"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
107
|
{"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
108
|
{"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
109
|
{"path":"examples/sqlite-resume.ts","title":"sqlite-resume","gate":"executed","imports":["@arnilo/prism","@arnilo/prism-extensions/store-sqlite","@arnilo/prism/testing"],"requiresEnv":[],"needsCredentials":false},
|
|
110
|
+
{"path":"examples/structured-output.ts","title":"Structured Output Demo (plan 235 Task 3).","gate":"executed","imports":["@arnilo/prism","@arnilo/prism/provider-kit"],"requiresEnv":[],"needsCredentials":false},
|
|
101
111
|
{"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
112
|
{"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
113
|
{"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},
|
|
@@ -49,7 +49,7 @@ receives), never guess it.
|
|
|
49
49
|
`definePackage` and list it.
|
|
50
50
|
- No default model or provider exists. A host names one and lists the provider package.
|
|
51
51
|
- Do not run `bun install` to repair a workspace without being asked; it can rewrite the lockfile.
|
|
52
|
-
-
|
|
52
|
+
- Session memory (`@arnilo/prism-memory-system`, `enabled: true`) is the recommended compaction system. Its working memory, long-term memory and `@arnilo/prism-knowledge` are experimental: opt in on purpose (`references/choosing.md`).
|
|
53
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
54
|
|
|
55
55
|
## Mistakes the compiler cannot catch
|
|
@@ -44,24 +44,28 @@ There are four slots: `loop`, `compaction`, `store`, `credentials`. Each holds o
|
|
|
44
44
|
provide one slot with no assignment fail the load (`ERR_PRISM_SLOT_CONFLICT`). Assign the owner by package name in
|
|
45
45
|
`slots`, as `node_modules/@arnilo/prism/docs/slots.md` shows.
|
|
46
46
|
|
|
47
|
-
- Need
|
|
48
|
-
|
|
49
|
-
|
|
47
|
+
- Need long sessions to stay coherent (the default choice): session memory, `@arnilo/prism-memory-system` with
|
|
48
|
+
`enabled: true`. STM records the session and compaction removes only what it recorded; `recall` returns originals.
|
|
49
|
+
It installs off: without `enabled: true` no session uses it. Example: `examples/session-memory.ts`.
|
|
50
|
+
- Need a plain summary instead: `@arnilo/prism-extensions/compaction`, one model call per compaction. It replaces
|
|
51
|
+
session memory. One compaction system runs per agent: listing both fails `createAgent`, unless the memory system
|
|
52
|
+
sets `context: { compaction: false }` (to keep its long-term memory). Example: `examples/compaction.ts`.
|
|
50
53
|
- Need a different loop (workflow, external agent): `slots.loop`, or a package that claims it
|
|
51
54
|
(`@arnilo/prism-extensions/workflows`, `@arnilo/prism-hosts/driver-process`). Example: `examples/custom-loop.ts`.
|
|
52
55
|
|
|
53
|
-
## The experimental memory
|
|
56
|
+
## The experimental memory parts
|
|
54
57
|
|
|
55
|
-
`@arnilo/prism-memory-system
|
|
56
|
-
|
|
57
|
-
|
|
58
|
+
`@arnilo/prism-memory-system` is stable for its session tier (STM, session compaction, `recall`). Its `wm`, `rehearsal`,
|
|
59
|
+
`scope`, `ltm` and `sleep` config are experimental, and `@arnilo/prism-knowledge/wiki` and `/rag` ship on the
|
|
60
|
+
`experimental` dist-tag. Experimental parts may change in any release; a `^0.14.0` range never matches a prerelease, so
|
|
61
|
+
opt in by tag:
|
|
58
62
|
|
|
59
63
|
```bash
|
|
60
|
-
bun add @arnilo/prism-
|
|
64
|
+
bun add @arnilo/prism-knowledge@experimental
|
|
61
65
|
```
|
|
62
66
|
|
|
63
|
-
Say in your report
|
|
64
|
-
|
|
67
|
+
Say in your report when the host depends on an experimental part. Examples: `examples/long-term-memory.ts`,
|
|
68
|
+
`examples/memory-and-wiki.ts`.
|
|
65
69
|
|
|
66
70
|
## Approval and governance
|
|
67
71
|
|
|
@@ -25,7 +25,7 @@ In the tables below the **Code** column holds only codes that exist in `errors.j
|
|
|
25
25
|
| `config_invalid` | A config value breaks the schema (type, range, shape). | Fix the value. |
|
|
26
26
|
| `secret_literal` | A literal was put in a secret field. | Use an `env:NAME` or `keyring:name` ref. |
|
|
27
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:
|
|
28
|
+
| `kernel_api` | `requires.api` is not an API level this kernel supports. | Write the package against `api: 2` for 0.14. |
|
|
29
29
|
| `capability_missing` | The package used a capability it did not declare. | Add it to `capabilities`, only if the package really needs it. |
|
|
30
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
31
|
| `registration_closed` | A tool or contribution was registered after `setup` finished. | Register during `setup`. |
|
|
@@ -38,8 +38,10 @@ In the tables below the **Code** column holds only codes that exist in `errors.j
|
|
|
38
38
|
a project unless asked; edit `package.json` and tell the person to install.
|
|
39
39
|
- **Copying a 0.12 sample.** A `store: "memory"` field, a `loop:` option or a model-invoked workflow no longer exists.
|
|
40
40
|
Read `references/upgrading.md` and copy from `data/examples/`.
|
|
41
|
-
- **Two
|
|
42
|
-
|
|
41
|
+
- **Two compaction systems.** Listing `@arnilo/prism-extensions/compaction` with `@arnilo/prism-memory-system` fails
|
|
42
|
+
`createAgent`, whatever `slots` says. Keep one, or set the memory system's `context: { compaction: false }`.
|
|
43
|
+
- **Session memory that never runs.** `@arnilo/prism-memory-system` installs off: set `enabled: true`, or the kernel's
|
|
44
|
+
deterministic compactor runs.
|
|
43
45
|
- **A tool in `requiresTools` that is off.** The skill disappears from the catalog; it is not an error. Check
|
|
44
46
|
`agent.inspect().skills` before you debug the prompt.
|
|
45
47
|
- **A host answering nothing.** With no `host.ui`, every ask answers `unavailable`. Approval asks then suspend the run
|
|
@@ -29,7 +29,7 @@ Page: `node_modules/@arnilo/prism/docs/tools.md`.
|
|
|
29
29
|
|
|
30
30
|
## Write a package
|
|
31
31
|
|
|
32
|
-
Copy `examples/define-package.ts`. Declare `requires: { api:
|
|
32
|
+
Copy `examples/define-package.ts`. Declare `requires: { api: 2 }`, the capabilities you use, and a config schema
|
|
33
33
|
with `x-prism-secret` for any secret field. Register hooks with `prism.hooks.on(name, handler)`. A handler receives one
|
|
34
34
|
payload: read its fields in `data/api.json` under `members` (a `tool.call` payload is `ToolCallHookPayload`: the tool
|
|
35
35
|
`name`, its `args` object and its `effects`). Test the package with `packageConformance(pkg)` from
|
|
@@ -107,10 +107,10 @@ Pages: `node_modules/@arnilo/prism/docs/drivers.md`, `node_modules/@arnilo/prism
|
|
|
107
107
|
|
|
108
108
|
## Compact long history
|
|
109
109
|
|
|
110
|
-
Copy `examples/
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
110
|
+
Copy `examples/session-memory.ts` (session memory with `enabled: true`), or `examples/compaction.ts`
|
|
111
|
+
for LLM compaction instead. List one compaction system: two fail `createAgent` (`references/choosing.md`). Check
|
|
112
|
+
`agent.inspect().slots`.
|
|
113
|
+
Pages: `node_modules/@arnilo/prism-memory-system/README.md`, `node_modules/@arnilo/prism-extensions/compaction/README.md`.
|
|
114
114
|
|
|
115
115
|
## Drive the host from a manifest
|
|
116
116
|
|
|
@@ -6,8 +6,6 @@ import { redactSecrets } from "@arnilo/prism";
|
|
|
6
6
|
|
|
7
7
|
/** The wall-clock limit of one check when the host sets none, in milliseconds. */
|
|
8
8
|
export const DEFAULT_CHECK_TIMEOUT_MS = 30_000;
|
|
9
|
-
/** The most a host may raise the limit to. */
|
|
10
|
-
export const MAX_CHECK_TIMEOUT_MS = 120_000;
|
|
11
9
|
/** The most bytes of the child's result, and of each of its output streams, that the runner keeps. */
|
|
12
10
|
export const MAX_CHECK_OUTPUT_BYTES = 1024 * 1024;
|
|
13
11
|
|
|
@@ -99,7 +97,8 @@ function tail(text: string, secrets: readonly string[]): string {
|
|
|
99
97
|
* masked with the values of the `--pass-env` variables.
|
|
100
98
|
*/
|
|
101
99
|
export async function runCheck<T>(options: RunCheckOptions): Promise<CheckOutcome<T>> {
|
|
102
|
-
|
|
100
|
+
// Host-set: the host's value is the cap (plan 239 Task 5), never clamped.
|
|
101
|
+
const timeoutMs = options.timeoutMs ?? DEFAULT_CHECK_TIMEOUT_MS;
|
|
103
102
|
const env = childEnv(options.passEnv, options.env);
|
|
104
103
|
const secrets = (options.passEnv ?? [])
|
|
105
104
|
.map((name) => (options.env ?? process.env)[name])
|
|
@@ -5,7 +5,7 @@ import manifest from "../../package.json" with { type: "json" };
|
|
|
5
5
|
import { checkPackage } from "./check/conformance.js";
|
|
6
6
|
import { inspectHost } from "./check/inspect.js";
|
|
7
7
|
import { checkManifest } from "./check/manifest.js";
|
|
8
|
-
import { DEFAULT_CHECK_TIMEOUT_MS
|
|
8
|
+
import { DEFAULT_CHECK_TIMEOUT_MS } from "./check/runner.js";
|
|
9
9
|
import { type CheckTargets, findTarget, resolveCheckTargets } from "./check/targets.js";
|
|
10
10
|
import { HostBuilderError } from "./errors.js";
|
|
11
11
|
import { type LoadHostBuilderIndexOptions, loadHostBuilderIndex } from "./indexes.js";
|
|
@@ -70,7 +70,7 @@ export function createHostBuilderMcpServer(options: HostBuilderMcpOptions): McpS
|
|
|
70
70
|
const targets: CheckTargets = resolveCheckTargets(root, options.entries, options.packages);
|
|
71
71
|
const checkSettings = {
|
|
72
72
|
root,
|
|
73
|
-
timeoutMs:
|
|
73
|
+
timeoutMs: (options.checkTimeoutSeconds ?? DEFAULT_CHECK_TIMEOUT_MS / 1000) * 1000,
|
|
74
74
|
passEnv: options.passEnv ?? [],
|
|
75
75
|
};
|
|
76
76
|
const flagHelp = (flag: string) =>
|
package/mcp-server/README.md
CHANGED
|
@@ -64,7 +64,7 @@ try {
|
|
|
64
64
|
| `origin` | The bridge origin every served call is attributed to. |
|
|
65
65
|
| `prefix` | Prepended to each served tool name in `tools/list` and `tools/call`. |
|
|
66
66
|
| `resources` | Static `{ uri, name, mimeType?, text }` resources, each bounded to 256 KiB. `skillResources` builds the entries for skills that go with the served tools ([below](#lending-skills-with-tools)). |
|
|
67
|
-
| `limits` | `{ maxConcurrentCalls?, resultBytes? }`. Defaults 8 / 1 MiB;
|
|
67
|
+
| `limits` | `{ maxConcurrentCalls?, resultBytes? }`. Defaults 8 / 1 MiB; the host's values are the caps. Caps text, `structuredContent`, and the envelope body alike. |
|
|
68
68
|
| `permissionTool` | `{ name, effects?, rewrite?, codec? }`: also serve a permission-prompt tool backed by `run.ask`. |
|
|
69
69
|
| `relay` | `{ command }`, required for `stdio-relay`. |
|
|
70
70
|
| `headerEnv` | The bearer-token variable name. Default `PRISM_MCP_TOKEN`. |
|
|
@@ -189,8 +189,8 @@ answers `unavailable` (a Phase 14+ gap).
|
|
|
189
189
|
throwing callback denies. `PrismMcpAuthorization.ownership` is passed through unchanged — identity
|
|
190
190
|
enforcement belongs to the agent's own governance hooks.
|
|
191
191
|
- Results and errors are redacted with `options.redactor` (default `agent.config.redactor`) and
|
|
192
|
-
truncated to `maxResultBytes` (default 1 MiB
|
|
193
|
-
(default 64 KiB
|
|
192
|
+
truncated to `maxResultBytes` (default 1 MiB). `maxPromptBytes` bounds one prompt
|
|
193
|
+
(default 64 KiB). The host's values are the caps.
|
|
194
194
|
- `serveTools` results are already redacted by the kernel (`dispatchToolCall` applies the agent's
|
|
195
195
|
redactor) and truncated to `limits.resultBytes` here. Its resource `text` is host-supplied and
|
|
196
196
|
served verbatim, so **never put a secret in a `resources` entry**.
|
package/mcp-server/src/bounds.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { McpBridgeError } from "@arnilo/prism-extensions/mcp";
|
|
2
2
|
|
|
3
3
|
/** Resolves a bounded positive integer option, or throws naming the rule. Shared by `serve`, `server`, and `serve-tools`. */
|
|
4
|
-
|
|
4
|
+
/** A host-set server limit: a positive safe integer. The host's value is the cap (plan 239 Task 5). */
|
|
5
|
+
export function bounded(value: number | undefined, fallback: number, name: string): number {
|
|
5
6
|
const resolved = value ?? fallback;
|
|
6
|
-
if (!Number.isSafeInteger(resolved) || resolved < 1
|
|
7
|
-
throw new McpBridgeError(`${name} must be a positive safe integer <= ${cap}`);
|
|
7
|
+
if (!Number.isSafeInteger(resolved) || resolved < 1) throw new McpBridgeError(`${name} must be a positive safe integer`);
|
|
8
8
|
return resolved;
|
|
9
9
|
}
|
|
10
10
|
|
|
@@ -19,9 +19,7 @@ import type { PermissionDecision, PermissionRequest, PrismMcpWebHandler, ServeTo
|
|
|
19
19
|
|
|
20
20
|
const DEFAULT_HEADER_ENV = "PRISM_MCP_TOKEN";
|
|
21
21
|
const DEFAULT_MAX_CONCURRENT_CALLS = 8;
|
|
22
|
-
const HARD_MAX_CONCURRENT_CALLS = 64;
|
|
23
22
|
const DEFAULT_RESULT_BYTES = 1024 * 1024;
|
|
24
|
-
const HARD_RESULT_BYTES = 8 * 1024 * 1024;
|
|
25
23
|
export const MAX_RESOURCE_BYTES = 256 * 1024;
|
|
26
24
|
const CLOSED_MESSAGE = "served tools are closed";
|
|
27
25
|
const APPROVAL_PENDING_MESSAGE = "approval is pending; the run is suspended until a decision is recorded, so do not retry this call";
|
|
@@ -77,13 +75,8 @@ export async function serveTools(run: RunController, options: ServeToolsOptions)
|
|
|
77
75
|
if (options.allow.length === 0 && options.permissionTool === undefined)
|
|
78
76
|
throw new ServeToolsError("serve_tools_empty", "serveTools needs a non-empty allow list");
|
|
79
77
|
const headerEnv = options.headerEnv ?? DEFAULT_HEADER_ENV;
|
|
80
|
-
const maxConcurrentCalls = bounded(
|
|
81
|
-
|
|
82
|
-
DEFAULT_MAX_CONCURRENT_CALLS,
|
|
83
|
-
HARD_MAX_CONCURRENT_CALLS,
|
|
84
|
-
"maxConcurrentCalls",
|
|
85
|
-
);
|
|
86
|
-
const resultBytes = bounded(options.limits?.resultBytes, DEFAULT_RESULT_BYTES, HARD_RESULT_BYTES, "resultBytes");
|
|
78
|
+
const maxConcurrentCalls = bounded(options.limits?.maxConcurrentCalls, DEFAULT_MAX_CONCURRENT_CALLS, "maxConcurrentCalls");
|
|
79
|
+
const resultBytes = bounded(options.limits?.resultBytes, DEFAULT_RESULT_BYTES, "resultBytes");
|
|
87
80
|
const resources = options.resources ?? [];
|
|
88
81
|
for (const resource of resources) {
|
|
89
82
|
if (Buffer.byteLength(resource.text, "utf8") > MAX_RESOURCE_BYTES)
|
package/mcp-server/src/serve.ts
CHANGED
|
@@ -25,9 +25,7 @@ import type { PrismMcpAuthorization, ServeMcpHandle, ServeMcpOptions } from "./t
|
|
|
25
25
|
|
|
26
26
|
const DEFAULT_TOOL_NAME = "prompt";
|
|
27
27
|
const DEFAULT_MAX_PROMPT_BYTES = 64 * 1024;
|
|
28
|
-
const HARD_MAX_PROMPT_BYTES = 1024 * 1024;
|
|
29
28
|
const DEFAULT_MAX_RESULT_BYTES = 1024 * 1024;
|
|
30
|
-
const HARD_MAX_RESULT_BYTES = 8 * 1024 * 1024;
|
|
31
29
|
const APPROVAL_OUTCOMES: readonly ApprovalOutcome[] = ["allow_once", "allow_for_run", "reject_once", "reject_for_run"];
|
|
32
30
|
const APPROVAL_SCHEMA: ElicitRequestFormParams["requestedSchema"] = {
|
|
33
31
|
type: "object",
|
|
@@ -49,8 +47,8 @@ export function serveMcp(agent: Agent, options: ServeMcpOptions): ServeMcpHandle
|
|
|
49
47
|
if (transports !== 1) throw new McpBridgeError("serveMcp takes exactly one of { stdio: true }, { transport }, or { http }");
|
|
50
48
|
const toolName = options.toolName ?? DEFAULT_TOOL_NAME;
|
|
51
49
|
if (!toolName) throw new McpBridgeError("toolName must be non-empty");
|
|
52
|
-
const maxPromptBytes = bounded(options.maxPromptBytes, DEFAULT_MAX_PROMPT_BYTES,
|
|
53
|
-
const maxResultBytes = bounded(options.maxResultBytes, DEFAULT_MAX_RESULT_BYTES,
|
|
50
|
+
const maxPromptBytes = bounded(options.maxPromptBytes, DEFAULT_MAX_PROMPT_BYTES, "maxPromptBytes");
|
|
51
|
+
const maxResultBytes = bounded(options.maxResultBytes, DEFAULT_MAX_RESULT_BYTES, "maxResultBytes");
|
|
54
52
|
const redactor = options.redactor ?? agent.config.redactor;
|
|
55
53
|
const host = isMcpHost(agent.config.host) ? agent.config.host : undefined;
|
|
56
54
|
const sessions = new Map<string, Session>();
|
package/mcp-server/src/server.ts
CHANGED
|
@@ -19,11 +19,11 @@ import { bounded } from "./bounds.js";
|
|
|
19
19
|
import type { CreatePrismMcpWebHandlerOptions, PrismMcpStdioHandle, PrismMcpWebHandler, ServePrismMcpStdioOptions } from "./types.js";
|
|
20
20
|
|
|
21
21
|
const DEFAULT_MAX_HTTP_REQUEST_BYTES = 1024 * 1024;
|
|
22
|
-
const HARD_MAX_HTTP_REQUEST_BYTES = 8 * 1024 * 1024;
|
|
23
22
|
const DEFAULT_MAX_HTTP_RESPONSE_BYTES = 2 * 1024 * 1024;
|
|
24
|
-
const HARD_MAX_HTTP_RESPONSE_BYTES = 16 * 1024 * 1024;
|
|
25
23
|
const DEFAULT_SERVER_CALL_TIMEOUT_MS = 60_000;
|
|
26
|
-
const
|
|
24
|
+
const DEFAULT_MAX_CONCURRENT_REQUESTS = 32;
|
|
25
|
+
const DEFAULT_MAX_SESSIONS = 32;
|
|
26
|
+
const DEFAULT_MAX_SUBSCRIPTIONS = 1024;
|
|
27
27
|
|
|
28
28
|
/**
|
|
29
29
|
* Dual-era web handler. Modern (2026-07-28) traffic is served by the SDK's
|
|
@@ -42,27 +42,17 @@ export async function createPrismMcpWebHandler(
|
|
|
42
42
|
options: CreatePrismMcpWebHandlerOptions = {},
|
|
43
43
|
): Promise<PrismMcpWebHandler> {
|
|
44
44
|
const createServer: McpServerFactory = typeof server === "function" ? server : () => server;
|
|
45
|
-
const maxRequestBytes = bounded(options.maxRequestBytes, DEFAULT_MAX_HTTP_REQUEST_BYTES,
|
|
46
|
-
const maxResponseBytes = bounded(
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
HARD_MAX_HTTP_RESPONSE_BYTES,
|
|
50
|
-
"maxResponseBytes",
|
|
51
|
-
);
|
|
52
|
-
const maxConcurrentRequests = bounded(options.maxConcurrentRequests, 32, 512, "maxConcurrentRequests");
|
|
53
|
-
const requestTimeoutMs = bounded(
|
|
54
|
-
options.requestTimeoutMs,
|
|
55
|
-
DEFAULT_SERVER_CALL_TIMEOUT_MS,
|
|
56
|
-
HARD_SERVER_CALL_TIMEOUT_MS,
|
|
57
|
-
"requestTimeoutMs",
|
|
58
|
-
);
|
|
45
|
+
const maxRequestBytes = bounded(options.maxRequestBytes, DEFAULT_MAX_HTTP_REQUEST_BYTES, "maxRequestBytes");
|
|
46
|
+
const maxResponseBytes = bounded(options.maxResponseBytes, DEFAULT_MAX_HTTP_RESPONSE_BYTES, "maxResponseBytes");
|
|
47
|
+
const maxConcurrentRequests = bounded(options.maxConcurrentRequests, DEFAULT_MAX_CONCURRENT_REQUESTS, "maxConcurrentRequests");
|
|
48
|
+
const requestTimeoutMs = bounded(options.requestTimeoutMs, DEFAULT_SERVER_CALL_TIMEOUT_MS, "requestTimeoutMs");
|
|
59
49
|
const stateful = options.sessionIdGenerator !== undefined;
|
|
60
50
|
if (stateful && (!options.resolveIdentity || !options.allowedOrigins?.length))
|
|
61
51
|
throw new McpBridgeError("Stateful MCP sessions require resolveIdentity and exact allowedOrigins");
|
|
62
52
|
const protectedResource = options.protectedResource === undefined ? undefined : normalizeProtectedResource(options.protectedResource);
|
|
63
|
-
const maxSessions = bounded(options.maxSessions,
|
|
53
|
+
const maxSessions = bounded(options.maxSessions, DEFAULT_MAX_SESSIONS, "maxSessions");
|
|
64
54
|
const sessions = new Map<string, string>();
|
|
65
|
-
const maxSubscriptions = bounded(options.maxSubscriptions,
|
|
55
|
+
const maxSubscriptions = bounded(options.maxSubscriptions, DEFAULT_MAX_SUBSCRIPTIONS, "maxSubscriptions");
|
|
66
56
|
if (
|
|
67
57
|
options.keepAliveMs !== undefined &&
|
|
68
58
|
(!Number.isSafeInteger(options.keepAliveMs) || options.keepAliveMs < 0 || options.keepAliveMs > 300_000)
|
|
@@ -208,7 +198,7 @@ export function servePrismMcpStdio(server: McpServer | McpServerFactory, options
|
|
|
208
198
|
legacy: options.legacy ?? "serve",
|
|
209
199
|
...(options.transport !== undefined ? { transport: options.transport } : {}),
|
|
210
200
|
...(options.maxSubscriptions !== undefined
|
|
211
|
-
? { maxSubscriptions: bounded(options.maxSubscriptions,
|
|
201
|
+
? { maxSubscriptions: bounded(options.maxSubscriptions, DEFAULT_MAX_SUBSCRIPTIONS, "maxSubscriptions") }
|
|
212
202
|
: {}),
|
|
213
203
|
});
|
|
214
204
|
}
|
package/package.json
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@arnilo/prism-hosts",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.14.0",
|
|
4
4
|
"description": "Prism host libraries, process driver and version-exact host-builder kit. Import each library through its subpath.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
7
|
+
"./a2a": "./a2a/src/index.ts",
|
|
7
8
|
"./mcp-server": "./mcp-server/src/index.ts",
|
|
8
9
|
"./acp": "./acp/src/index.ts",
|
|
9
10
|
"./ag-ui": "./ag-ui/src/index.ts",
|
|
@@ -11,6 +12,8 @@
|
|
|
11
12
|
"./channels": "./channels/src/index.ts",
|
|
12
13
|
"./channels/telegram": "./channels/src/telegram.ts",
|
|
13
14
|
"./channels/signal": "./channels/src/signal.ts",
|
|
15
|
+
"./channels/slack": "./channels/src/slack.ts",
|
|
16
|
+
"./channels/discord": "./channels/src/discord.ts",
|
|
14
17
|
"./evals": "./evals/src/index.ts",
|
|
15
18
|
"./devtools": "./devtools/src/index.ts",
|
|
16
19
|
"./remote": "./remote/src/index.ts",
|
|
@@ -21,6 +24,9 @@
|
|
|
21
24
|
"./driver-process/testing": "./driver-process/src/testing.ts"
|
|
22
25
|
},
|
|
23
26
|
"files": [
|
|
27
|
+
"a2a/src",
|
|
28
|
+
"!a2a/src/**/__tests__",
|
|
29
|
+
"a2a/README.md",
|
|
24
30
|
"mcp-server/src",
|
|
25
31
|
"!mcp-server/src/**/__tests__",
|
|
26
32
|
"mcp-server/README.md",
|
|
@@ -60,13 +66,13 @@
|
|
|
60
66
|
"LICENSE"
|
|
61
67
|
],
|
|
62
68
|
"scripts": {
|
|
63
|
-
"test": "bun ../../scripts/with-build-lock.mjs --shared bun test --parallel=4 --timeout=0 mcp-server/src acp/src ag-ui/src channels/src evals/src devtools/src remote/src headless/src host-builder/src driver-process/src --path-ignore-patterns=channels/src/__tests__/postgres.integration.test.ts",
|
|
69
|
+
"test": "bun ../../scripts/with-build-lock.mjs --shared bun test --parallel=4 --timeout=0 a2a/src mcp-server/src acp/src ag-ui/src channels/src evals/src devtools/src remote/src headless/src host-builder/src driver-process/src --path-ignore-patterns=channels/src/__tests__/postgres.integration.test.ts",
|
|
64
70
|
"typecheck": "tsc -p tsconfig.json --noEmit",
|
|
65
71
|
"test:postgres": "bun ../../scripts/require-postgres-url.mjs && bun ../../scripts/with-build-lock.mjs --shared bun test --timeout=0 channels/src/__tests__/postgres.integration.test.ts",
|
|
66
72
|
"pack:dry-run": "bun pm pack --dry-run"
|
|
67
73
|
},
|
|
68
74
|
"peerDependencies": {
|
|
69
|
-
"@arnilo/prism": "
|
|
75
|
+
"@arnilo/prism": "^0.14.0",
|
|
70
76
|
"@agentclientprotocol/sdk": "1.4.0",
|
|
71
77
|
"@ag-ui/core": "1.0.4",
|
|
72
78
|
"@modelcontextprotocol/server": "^2.3.0",
|
|
@@ -76,8 +82,8 @@
|
|
|
76
82
|
"@modelcontextprotocol/client": "^2.3.0",
|
|
77
83
|
"@types/node": "^22.20.0",
|
|
78
84
|
"typescript": "^7.0.2",
|
|
79
|
-
"@arnilo/prism-extensions": "0.
|
|
80
|
-
"@arnilo/prism-tools": "0.
|
|
85
|
+
"@arnilo/prism-extensions": "0.14.0",
|
|
86
|
+
"@arnilo/prism-tools": "0.14.0",
|
|
81
87
|
"@ag-ui/client": "1.0.4",
|
|
82
88
|
"@types/pg": "^8.23.1",
|
|
83
89
|
"pg": "^8.23.0",
|
|
@@ -113,7 +119,7 @@
|
|
|
113
119
|
"prism-host-builder": "./host-builder/bin/prism-host-builder.ts"
|
|
114
120
|
},
|
|
115
121
|
"dependencies": {
|
|
116
|
-
"@arnilo/prism-extensions": "^0.
|
|
122
|
+
"@arnilo/prism-extensions": "^0.14.0"
|
|
117
123
|
},
|
|
118
124
|
"peerDependenciesMeta": {
|
|
119
125
|
"@agentclientprotocol/sdk": {
|
package/remote/README.md
CHANGED
|
@@ -83,7 +83,7 @@ Network endpoint `token` is the resolved bearer value (for example `served.token
|
|
|
83
83
|
| `maxPendingRequests` | 64 | 1024 | Outstanding outbound requests. |
|
|
84
84
|
| `maxQueuedEvents` | 1000 | 100,000 | Queued transport events. |
|
|
85
85
|
|
|
86
|
-
All limits are positive safe integers
|
|
86
|
+
All limits are positive safe integers, and the host's value is the cap. Slow consumers disconnect rather than grow an unbounded queue.
|
|
87
87
|
|
|
88
88
|
## Protocol
|
|
89
89
|
|
|
@@ -95,6 +95,7 @@ JSON-RPC 2.0 frames negotiate `prism.remote/1` in `initialize`. Unsupported vers
|
|
|
95
95
|
| `sessions.open` | client → server | Create or reopen a session, optionally with parent links. |
|
|
96
96
|
| `sessions.list` | client → server | List sessions with a query. |
|
|
97
97
|
| `sessions.resume` | client → server | Resume pending decisions. |
|
|
98
|
+
| `sessions.continue` | client → server | `Session.continue()`: a run with no new input on a branch that owes a model turn. Rejects with `nothing_to_continue` when nothing is owed; the proxy turns that into `SessionContinueError`. |
|
|
98
99
|
| `sessions.messages` | client → server | Read branch messages. |
|
|
99
100
|
| `run` | client → server | Start a run; returns run id. |
|
|
100
101
|
| `steer` | client → server | Steer an active session. |
|
|
@@ -114,7 +115,7 @@ Every inbound wire payload is validated before reaching the kernel; unknown or o
|
|
|
114
115
|
|
|
115
116
|
| Surface | Allowed fields & bounds | Rejected / stripped |
|
|
116
117
|
| --- | --- | --- |
|
|
117
|
-
| `run.options` / `sessions.resume.options` | `metadata` (object), `limits` (object), `interactive` (boolean) | `principal`, `ownership`, `redactor`, `runLedger`, `signal`, and any unknown key (`invalid_params`). |
|
|
118
|
+
| `run.options` / `sessions.resume.options` / `sessions.continue.options` | `metadata` (object), `limits` (object: run-limit axes that only narrow the agent's resolved limits; `null`, an unknown axis, or a value above the agent's is `invalid_params`), `interactive` (boolean) | `principal`, `ownership`, `redactor`, `runLedger`, `signal`, and any unknown key (`invalid_params`). |
|
|
118
119
|
| `sessions.resume.decisions[]` | `approvalId` (non-empty string ≤ 256), `outcome` (`allow_once` \| `allow_for_run` \| `reject_once` \| `reject_for_run`), `reason` (string ≤ 2 KiB), `elicitation` (JSON object, only for pending `elicitation` decisions), `modifiedArguments` (JSON object, only when `allowModifiedArguments: true`) | `modifiedArguments` when `allowModifiedArguments` is omitted/`false`, `elicitation` on `tool_approval` decisions, and any extra key (`invalid_params`). |
|
|
119
120
|
| `steer.options` | `softInterrupt` (boolean) | Any other key or non-boolean `softInterrupt` (`invalid_params`). |
|
|
120
121
|
| `sessions.list.query` | `cursor` (non-empty string ≤ 512), `limit` (integer `1..100`), `order` (`"asc"` \| `"desc"`), `agentId`, `parentSessionId`, `workflowRunId`, `delegationId`, `actorAgent` (non-empty strings ≤ `MAX_SESSION_LINK_ID_LENGTH`), `actorKind` (`"prism"` \| `"external"`) | Client-supplied `tenantId`, `accountId`, `userId` are stripped (server `ownershipFor` scope applies); any other key or out-of-range value is `invalid_params`. |
|
|
@@ -136,6 +137,8 @@ Mirroring trusts the remote's redaction and stores messages as received, without
|
|
|
136
137
|
|
|
137
138
|
A later client initializes and opens the suspended session; the server reads pending decisions from the remote branch and sends UI requests, then resumes from answers. Unavailable answers leave decisions pending. Explicit `session.resume(decisions)` also works. A disconnected active proxy run rejects with `disconnected`; reconnect and reopen the session to inspect or continue it. Disposing a stdio proxy terminates its owned child, so persistence is needed for later recovery.
|
|
138
139
|
|
|
140
|
+
Events are forwarded unchanged. A provider attempt that ends with `turn.completed { error }` may be retried after it streamed output; a remote client discards that attempt's deltas ([Events](../../../docs/events.md#failed-attempts)).
|
|
141
|
+
|
|
139
142
|
The proxy caches `inspect()` and command descriptors at initialization. Unsupported local operations fail with `remote_unsupported`; there is no local execution fallback. No extra model calls are made by this library.
|
|
140
143
|
|
|
141
144
|
## Network transports
|
|
@@ -164,8 +167,8 @@ Host matching includes the port and is exact, case insensitive. Default allowed
|
|
|
164
167
|
|
|
165
168
|
Every connection opened on a served agent is partitioned by its authenticated `Principal` (`kind` and `id`). Single-principal transports (`stdio`, memory, or loopback bearer authentication where `authenticate` is omitted) share the default single-principal partition, which also acts as operator.
|
|
166
169
|
|
|
167
|
-
- **Session isolation floor:** `ServerState.sessions` is keyed by principal and session id, backed by an $O(1)$ `sessionOwners` map. Independently of `ownershipFor`, any wire call (`sessions.open(id)`, `sessions.messages`, `run`, `steer`, `abort`, `sessions.resume`, or `commands.run` with `sessionId`) for a session owned by another principal rejects with `session_not_found`.
|
|
168
|
-
- **Kernel ownership scope (`ownershipFor`):** When `ownershipFor: (principal) => OwnershipScope` is configured on `serveAgent`, the derived scope is passed into `sessions.open` (`SessionOptions.ownership`), `sessions.list` (stripping any client-supplied ownership keys), `run`, `sessions.resume`, and reconnect pending-decision resume (`RunOptions.ownership`).
|
|
170
|
+
- **Session isolation floor:** `ServerState.sessions` is keyed by principal and session id, backed by an $O(1)$ `sessionOwners` map. Independently of `ownershipFor`, any wire call (`sessions.open(id)`, `sessions.messages`, `run`, `steer`, `abort`, `sessions.resume`, `sessions.continue`, or `commands.run` with `sessionId`) for a session owned by another principal rejects with `session_not_found`.
|
|
171
|
+
- **Kernel ownership scope (`ownershipFor`):** When `ownershipFor: (principal) => OwnershipScope` is configured on `serveAgent`, the derived scope is passed into `sessions.open` (`SessionOptions.ownership`), `sessions.list` (stripping any client-supplied ownership keys), `run`, `sessions.resume`, `sessions.continue`, and reconnect pending-decision resume (`RunOptions.ownership`).
|
|
169
172
|
- **Owner-routed `remoteHostUi` and pending delivery:** Requests carrying `request.sessionId` route in $O(1)$ to a bound connection of that session's owning principal, or return `unavailable` (suspending the run durably) if that principal has no bound connection. On connect, `deliverPending` delivers only the connecting principal's suspended sessions.
|
|
170
173
|
- **Operator-only agent-scoped requests and events (`operator`):** `hostUi` requests without a `sessionId` and `agent.event` notifications without a `sessionId` (or from host-local sessions not owned by a remote principal) route only to connections where `operator(principal) === true` (or single-principal connections). Session-scoped `agent.event` notifications (`session.opened`, `background.*`) reach only that session's owning principal.
|
|
171
174
|
|