@arnilo/prism-hosts 0.0.0-stage → 0.13.1
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 +6197 -0
- package/host-builder/data/errors.json +558 -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 +255 -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 +318 -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 +68 -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,63 @@
|
|
|
1
|
+
import { ClientSideConnection, ndJsonStream, PROTOCOL_VERSION } from "@agentclientprotocol/sdk";
|
|
2
|
+
import { createAgent } from "@arnilo/prism";
|
|
3
|
+
import { mockProvider, providerDone, providerTextDelta, providerToolCall, toolCallContent } from "@arnilo/prism/testing";
|
|
4
|
+
import { acpHost, serveAcp } from "@arnilo/prism-hosts/acp";
|
|
5
|
+
import approval from "@arnilo/prism-extensions/approval";
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* One agent, approval in ask mode, served over ACP on in-memory streams.
|
|
9
|
+
* The client answers `session/request_permission` with `allow_once`. The tool runs once.
|
|
10
|
+
* Run: npm run build:core && node examples/acp.ts
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
const MODEL = { provider: "mock", model: "demo" } as const;
|
|
14
|
+
const executed: string[] = [];
|
|
15
|
+
|
|
16
|
+
const agent = await createAgent({
|
|
17
|
+
id: "acp-demo",
|
|
18
|
+
model: MODEL,
|
|
19
|
+
host: acpHost(),
|
|
20
|
+
packages: [
|
|
21
|
+
approval({ mode: "ask" }),
|
|
22
|
+
mockProvider([
|
|
23
|
+
[providerToolCall(toolCallContent("call-1", "delete_file", { path: "tmp/scratch.txt" })), providerDone()],
|
|
24
|
+
[providerTextDelta("Deleted."), providerDone()],
|
|
25
|
+
]),
|
|
26
|
+
],
|
|
27
|
+
tools: {
|
|
28
|
+
add: [
|
|
29
|
+
{
|
|
30
|
+
name: "delete_file",
|
|
31
|
+
description: "Deletes a file",
|
|
32
|
+
parameters: { type: "object", properties: { path: { type: "string" } } },
|
|
33
|
+
effects: ["write"],
|
|
34
|
+
execute: (args) => {
|
|
35
|
+
executed.push(String(args.path));
|
|
36
|
+
return { toolCallId: "call-1", name: "delete_file", value: "deleted" };
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
],
|
|
40
|
+
},
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
const clientToAgent = new TransformStream<Uint8Array, Uint8Array>();
|
|
44
|
+
const agentToClient = new TransformStream<Uint8Array, Uint8Array>();
|
|
45
|
+
const server = serveAcp(agent, { stream: ndJsonStream(agentToClient.writable, clientToAgent.readable) });
|
|
46
|
+
const client = new ClientSideConnection(
|
|
47
|
+
() => ({
|
|
48
|
+
sessionUpdate: async () => undefined,
|
|
49
|
+
requestPermission: async () => ({ outcome: { outcome: "selected", optionId: "allow_once" } }),
|
|
50
|
+
}),
|
|
51
|
+
ndJsonStream(clientToAgent.writable, agentToClient.readable),
|
|
52
|
+
);
|
|
53
|
+
|
|
54
|
+
const initialized = await client.initialize({ protocolVersion: PROTOCOL_VERSION });
|
|
55
|
+
const created = await client.newSession({ cwd: "/tmp", mcpServers: [] });
|
|
56
|
+
const prompt = await client.prompt({ sessionId: created.sessionId, prompt: [{ type: "text", text: "Delete tmp/scratch.txt" }] });
|
|
57
|
+
await server.close();
|
|
58
|
+
await agent.dispose();
|
|
59
|
+
|
|
60
|
+
if (executed.length !== 1 || prompt.stopReason !== "end_turn" || initialized.agentCapabilities?.loadSession !== true) {
|
|
61
|
+
throw new Error(`ACP demo failed: ${JSON.stringify({ executed, stopReason: prompt.stopReason })}`);
|
|
62
|
+
}
|
|
63
|
+
console.log({ executed: executed.length, stopReason: prompt.stopReason, loadSession: true });
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/** Runs `adapterConformance` for every reference adapter and prints one JSON summary per adapter. */
|
|
2
|
+
import { adapterConformance } from "@arnilo/prism-hosts/driver-process/testing";
|
|
3
|
+
import { rpcServerDialect, rpcServerFixtures } from "./rpc-server.dialect.js";
|
|
4
|
+
import { rpcServer } from "./rpc-server.js";
|
|
5
|
+
import { streamCliDialect, streamCliFixtures } from "./stream-cli.dialect.js";
|
|
6
|
+
import { streamCli } from "./stream-cli.js";
|
|
7
|
+
import { workspaceConfigDialect, workspaceConfigFixtures } from "./workspace-config.dialect.js";
|
|
8
|
+
import { workspaceConfig } from "./workspace-config.js";
|
|
9
|
+
|
|
10
|
+
const references = [
|
|
11
|
+
{ name: "stream-cli", adapter: streamCli, dialect: streamCliDialect, fixtures: streamCliFixtures },
|
|
12
|
+
{ name: "rpc-server", adapter: rpcServer, dialect: rpcServerDialect, fixtures: rpcServerFixtures },
|
|
13
|
+
{ name: "workspace-config", adapter: workspaceConfig, dialect: workspaceConfigDialect, fixtures: workspaceConfigFixtures },
|
|
14
|
+
];
|
|
15
|
+
|
|
16
|
+
let failed = false;
|
|
17
|
+
|
|
18
|
+
for (const reference of references) {
|
|
19
|
+
try {
|
|
20
|
+
const result = await adapterConformance(reference.adapter, { dialect: reference.dialect, fixtures: reference.fixtures });
|
|
21
|
+
console.log(JSON.stringify({ adapter: reference.name, legs: result.legs }));
|
|
22
|
+
for (const leg of result.legs)
|
|
23
|
+
if (leg.status !== "passed" && leg.status !== "skipped") {
|
|
24
|
+
failed = true;
|
|
25
|
+
console.error(`${reference.name}: leg ${leg.name} is ${leg.status}`);
|
|
26
|
+
}
|
|
27
|
+
} catch (error) {
|
|
28
|
+
failed = true;
|
|
29
|
+
console.error(`${reference.name}: ${error instanceof Error ? error.message : String(error)}`);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
// Plan 174 Task 11: the release gate reads this exit code, so a failed or hung leg must not exit 0.
|
|
34
|
+
if (failed) process.exitCode = 1;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 1,
|
|
3
|
+
"turns": [
|
|
4
|
+
{
|
|
5
|
+
"input": [
|
|
6
|
+
"{\"jsonrpc\":\"2.0\",\"id\":0,\"method\":\"turn/start\",\"params\":{\"text\":\"Review the file\"}}"
|
|
7
|
+
],
|
|
8
|
+
"output": [
|
|
9
|
+
"{\"jsonrpc\":\"2.0\",\"method\":\"item/agentMessage/delta\",\"params\":{\"threadId\":\"recorded-thread\",\"turnId\":\"recorded-turn\",\"delta\":\"Checking.\"}}",
|
|
10
|
+
"{\"jsonrpc\":\"2.0\",\"method\":\"item/reasoning/delta\",\"params\":{\"threadId\":\"recorded-thread\",\"turnId\":\"recorded-turn\",\"delta\":\"Read first.\"}}",
|
|
11
|
+
"{\"jsonrpc\":\"2.0\",\"method\":\"item/started\",\"params\":{\"threadId\":\"recorded-thread\",\"turnId\":\"recorded-turn\",\"item\":{\"type\":\"toolCall\",\"id\":\"read-1\",\"name\":\"read\",\"args\":{\"path\":\"README.md\"}}}}",
|
|
12
|
+
"{\"jsonrpc\":\"2.0\",\"method\":\"item/toolCall/progress\",\"params\":{\"threadId\":\"recorded-thread\",\"turnId\":\"recorded-turn\",\"toolCallId\":\"read-1\",\"progress\":{\"percent\":50}}}",
|
|
13
|
+
"{\"jsonrpc\":\"2.0\",\"method\":\"item/completed\",\"params\":{\"threadId\":\"recorded-thread\",\"turnId\":\"recorded-turn\",\"item\":{\"type\":\"toolResult\",\"id\":\"read-1\",\"status\":\"finished\",\"result\":\"contents\"}}}",
|
|
14
|
+
"{\"jsonrpc\":\"2.0\",\"method\":\"item/completed\",\"params\":{\"threadId\":\"recorded-thread\",\"turnId\":\"recorded-turn\",\"item\":{\"type\":\"agentMessage\",\"text\":\"Done.\"}}}",
|
|
15
|
+
"{\"jsonrpc\":\"2.0\",\"method\":\"item/completed\",\"params\":{\"threadId\":\"recorded-thread\",\"turnId\":\"recorded-turn\",\"item\":{\"type\":\"skill\",\"name\":\"review\",\"source\":\"explicit\",\"resolved\":true}}}",
|
|
16
|
+
"{\"jsonrpc\":\"2.0\",\"method\":\"item/fileChange\",\"params\":{\"threadId\":\"recorded-thread\",\"turnId\":\"recorded-turn\",\"path\":\"note.md\",\"change\":\"modified\",\"source\":\"agent\",\"diff\":\"+reviewed\"}}",
|
|
17
|
+
"{\"jsonrpc\":\"2.0\",\"method\":\"turn/plan/updated\",\"params\":{\"threadId\":\"recorded-thread\",\"turnId\":\"recorded-turn\",\"entries\":[{\"title\":\"review\",\"status\":\"complete\"}]}}",
|
|
18
|
+
"{\"jsonrpc\":\"2.0\",\"method\":\"item/subagent\",\"params\":{\"threadId\":\"recorded-thread\",\"turnId\":\"recorded-turn\",\"phase\":\"started\",\"id\":\"sub-1\",\"name\":\"review\"}}",
|
|
19
|
+
"{\"jsonrpc\":\"2.0\",\"method\":\"thread/compacted\",\"params\":{\"threadId\":\"recorded-thread\",\"turnId\":\"recorded-turn\",\"phase\":\"completed\",\"summary\":\"reviewed\"}}",
|
|
20
|
+
"{\"jsonrpc\":\"2.0\",\"method\":\"notice\",\"params\":{\"threadId\":\"recorded-thread\",\"turnId\":\"recorded-turn\",\"level\":\"warn\",\"code\":\"retry\",\"message\":\"retrying\"}}",
|
|
21
|
+
"{\"jsonrpc\":\"2.0\",\"method\":\"thread/tokenUsage/updated\",\"params\":{\"threadId\":\"recorded-thread\",\"turnId\":\"recorded-turn\",\"usage\":{\"inputTokens\":10,\"outputTokens\":5}}}",
|
|
22
|
+
"{\"jsonrpc\":\"2.0\",\"method\":\"turn/completed\",\"params\":{\"threadId\":\"recorded-thread\",\"turnId\":\"recorded-turn\"}}"
|
|
23
|
+
]
|
|
24
|
+
}
|
|
25
|
+
]
|
|
26
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 1,
|
|
3
|
+
"turns": [
|
|
4
|
+
{
|
|
5
|
+
"input": [
|
|
6
|
+
"{\"type\":\"user\",\"text\":\"Review the file\"}"
|
|
7
|
+
],
|
|
8
|
+
"output": [
|
|
9
|
+
"{\"type\":\"init\",\"sessionId\":\"recorded-session\"}",
|
|
10
|
+
"{\"type\":\"assistant\",\"blocks\":[{\"type\":\"text\",\"text\":\"Checking.\"},{\"type\":\"thinking\",\"text\":\"Read first.\"}]}",
|
|
11
|
+
"{\"type\":\"delta\",\"block\":\"text\",\"text\":\"Done.\"}",
|
|
12
|
+
"{\"type\":\"delta\",\"block\":\"thinking\",\"text\":\"Verified.\"}",
|
|
13
|
+
"{\"type\":\"tool_use\",\"id\":\"read-1\",\"name\":\"read\",\"input\":{\"path\":\"README.md\"}}",
|
|
14
|
+
"{\"type\":\"tool_result\",\"id\":\"read-1\",\"status\":\"finished\",\"result\":\"contents\"}",
|
|
15
|
+
"{\"type\":\"retry\",\"category\":\"transient\",\"message\":\"retrying\"}",
|
|
16
|
+
"{\"type\":\"permission_denied\",\"message\":\"shell declined\"}",
|
|
17
|
+
"{\"type\":\"subagent\",\"parentToolId\":\"parent\",\"phase\":\"started\",\"name\":\"review\"}",
|
|
18
|
+
"{\"type\":\"file\",\"payload\":{\"path\":\"note.md\",\"change\":\"modified\",\"source\":\"agent\",\"diff\":\"+reviewed\"}}",
|
|
19
|
+
"{\"type\":\"subagent\",\"parentToolId\":\"parent\",\"phase\":\"completed\"}",
|
|
20
|
+
"{\"type\":\"skill\",\"payload\":{\"name\":\"review\",\"source\":\"native\",\"resolved\":true}}",
|
|
21
|
+
"{\"type\":\"plan\",\"payload\":{\"entries\":[{\"title\":\"review\",\"status\":\"complete\"}]}}",
|
|
22
|
+
"{\"type\":\"compaction\",\"payload\":{\"phase\":\"completed\",\"summary\":\"reviewed\"}}",
|
|
23
|
+
"{\"type\":\"result\",\"sessionId\":\"recorded-session\",\"usage\":{\"inputTokens\":10,\"outputTokens\":5,\"cost\":0.001}}"
|
|
24
|
+
]
|
|
25
|
+
}
|
|
26
|
+
]
|
|
27
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 1,
|
|
3
|
+
"turns": [
|
|
4
|
+
{
|
|
5
|
+
"input": [
|
|
6
|
+
"{\"type\":\"prompt\",\"text\":\"Review the file\"}"
|
|
7
|
+
],
|
|
8
|
+
"output": [
|
|
9
|
+
"{\"type\":\"init\",\"conversationId\":\"recorded-conversation\"}",
|
|
10
|
+
"{\"type\":\"text_delta\",\"text\":\"Checking.\"}",
|
|
11
|
+
"{\"type\":\"message\",\"role\":\"assistant\",\"blocks\":[{\"type\":\"text\",\"text\":\"Done.\"}]}",
|
|
12
|
+
"{\"type\":\"tool_start\",\"id\":\"read-1\",\"name\":\"read\",\"parameters\":{\"path\":\"README.md\"}}",
|
|
13
|
+
"{\"type\":\"tool_progress\",\"id\":\"read-1\",\"progress\":{\"percent\":50}}",
|
|
14
|
+
"{\"type\":\"tool_end\",\"id\":\"read-1\",\"status\":\"finished\",\"output\":\"contents\"}",
|
|
15
|
+
"{\"type\":\"skill_read\",\"name\":\"review\",\"source\":\"tool\",\"resolved\":true}",
|
|
16
|
+
"{\"type\":\"file_change\",\"path\":\"note.md\",\"change\":\"modified\",\"source\":\"diff\",\"diff\":\"+reviewed\"}",
|
|
17
|
+
"{\"type\":\"plan_update\",\"entries\":[{\"title\":\"read\",\"status\":\"done\"}]}",
|
|
18
|
+
"{\"type\":\"subagent_info\",\"phase\":\"started\",\"id\":\"parent\",\"name\":\"review\"}",
|
|
19
|
+
"{\"type\":\"subagent_info\",\"phase\":\"completed\",\"id\":\"parent\",\"result\":\"done\"}",
|
|
20
|
+
"{\"type\":\"checkpoint\",\"phase\":\"completed\",\"summary\":\"compacted\"}",
|
|
21
|
+
"{\"type\":\"notice\",\"level\":\"warn\",\"code\":\"seen\",\"message\":\"notice\"}",
|
|
22
|
+
"{\"type\":\"usage\",\"usage\":{\"inputTokens\":2,\"outputTokens\":3,\"thinkingTokens\":7}}",
|
|
23
|
+
"{\"type\":\"raw\",\"payload\":{\"vendor\":\"workspace-config\",\"type\":\"custom\",\"data\":{\"ok\":true}}}",
|
|
24
|
+
"{\"type\":\"result\",\"conversationId\":\"recorded-conversation\",\"status\":\"done\",\"usage\":{\"inputTokens\":2,\"outputTokens\":3,\"thinkingTokens\":7}}"
|
|
25
|
+
]
|
|
26
|
+
}
|
|
27
|
+
]
|
|
28
|
+
}
|
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
/** Offline wire companion for worked mapping B in docs/agent-adapters.md. */
|
|
2
|
+
|
|
3
|
+
import { fileURLToPath } from "node:url";
|
|
4
|
+
import type { ExternalActivity, JsonValue, Usage } from "@arnilo/prism";
|
|
5
|
+
import { defineScriptedDialect } from "@arnilo/prism/testing";
|
|
6
|
+
import type { AdapterConformanceFixtures } from "@arnilo/prism-hosts/driver-process/testing";
|
|
7
|
+
|
|
8
|
+
export const rpcServerDialect = defineScriptedDialect({
|
|
9
|
+
name: "rpc-server",
|
|
10
|
+
locate: ({ argv, env, readFile }) => {
|
|
11
|
+
const loaded: string[] = [];
|
|
12
|
+
const load = (path: string | undefined) => {
|
|
13
|
+
if (!path) return undefined;
|
|
14
|
+
const content = readFile(path);
|
|
15
|
+
if (content === undefined) return undefined;
|
|
16
|
+
loaded.push(path);
|
|
17
|
+
return JSON.parse(content);
|
|
18
|
+
};
|
|
19
|
+
const flag = (name: string) => {
|
|
20
|
+
const i = argv.indexOf(name);
|
|
21
|
+
return i < 0 ? undefined : argv[i + 1];
|
|
22
|
+
};
|
|
23
|
+
const config = load(flag("--config"));
|
|
24
|
+
if (config?.instructions?.file && readFile(config.instructions.file) !== undefined) loaded.push(config.instructions.file);
|
|
25
|
+
const mcp = load(flag("--mcp-config"));
|
|
26
|
+
if (!argv.includes("--no-user-config")) {
|
|
27
|
+
const home = env.RPC_HOME ?? env.HOME;
|
|
28
|
+
for (const rel of [".rpc-server/config.json", ".rpc-server/skills/planted/SKILL.md", ".rpc-server/mcp.json"]) {
|
|
29
|
+
const path = `${home}/${rel}`;
|
|
30
|
+
if (readFile(path) !== undefined) loaded.push(path);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
return { endpoint: mcp?.servers?.prism, loaded };
|
|
34
|
+
},
|
|
35
|
+
encodeInput: (input) => {
|
|
36
|
+
if (input.kind === "answer")
|
|
37
|
+
return JSON.stringify({ jsonrpc: "2.0", id: input.id, result: { decision: input.allow ? "allow" : "deny" } });
|
|
38
|
+
const method = input.kind === "user" ? "turn/start" : input.kind === "steer" ? "turn/steer" : "turn/interrupt";
|
|
39
|
+
return JSON.stringify({ jsonrpc: "2.0", id: 0, method, params: input.kind === "interrupt" ? {} : { text: input.text } });
|
|
40
|
+
},
|
|
41
|
+
decodeInput: (line) => {
|
|
42
|
+
let message: { method?: unknown; id?: unknown; params?: { text?: unknown }; result?: { decision?: unknown } } | null;
|
|
43
|
+
try {
|
|
44
|
+
message = JSON.parse(line);
|
|
45
|
+
} catch {
|
|
46
|
+
return undefined;
|
|
47
|
+
}
|
|
48
|
+
if (typeof message !== "object" || message === null) return undefined;
|
|
49
|
+
if (message.method === undefined) {
|
|
50
|
+
if (message.id === undefined) return undefined;
|
|
51
|
+
return { kind: "answer", id: String(message.id), allow: message.result?.decision === "allow" };
|
|
52
|
+
}
|
|
53
|
+
const text = typeof message.params?.text === "string" ? message.params.text : "";
|
|
54
|
+
if (message.method === "turn/start") return { kind: "user", text };
|
|
55
|
+
if (message.method === "turn/steer") return { kind: "steer", text };
|
|
56
|
+
if (message.method === "turn/interrupt") return { kind: "interrupt" };
|
|
57
|
+
return undefined;
|
|
58
|
+
},
|
|
59
|
+
frames: (frame) => {
|
|
60
|
+
const ids = { threadId: "thread-1", turnId: "turn-1" };
|
|
61
|
+
const wrap = (method: string, params: Record<string, unknown>) =>
|
|
62
|
+
JSON.stringify({ jsonrpc: "2.0", method, params: { ...ids, ...params } });
|
|
63
|
+
if (!("kind" in frame)) return wrap("turn/completed", {});
|
|
64
|
+
switch (frame.kind) {
|
|
65
|
+
case "message.delta":
|
|
66
|
+
return frame.content.type === "thinking"
|
|
67
|
+
? wrap("item/reasoning/delta", { delta: frame.content.text })
|
|
68
|
+
: wrap("item/agentMessage/delta", { delta: frame.content.text });
|
|
69
|
+
case "message":
|
|
70
|
+
return wrap("item/completed", {
|
|
71
|
+
item: {
|
|
72
|
+
type: "agentMessage",
|
|
73
|
+
text: frame.message.content
|
|
74
|
+
.filter((part) => part.type === "text")
|
|
75
|
+
.map((part) => part.text)
|
|
76
|
+
.join("\n"),
|
|
77
|
+
},
|
|
78
|
+
});
|
|
79
|
+
case "tool.started":
|
|
80
|
+
return wrap("item/started", { item: { type: "toolCall", id: frame.call.id, name: frame.call.name, args: frame.call.args } });
|
|
81
|
+
case "tool.progress":
|
|
82
|
+
return wrap("item/toolCall/progress", { toolCallId: frame.toolCallId, progress: frame.progress });
|
|
83
|
+
case "tool.completed":
|
|
84
|
+
return wrap("item/completed", {
|
|
85
|
+
item: { type: "toolResult", id: frame.toolCallId, status: frame.status, result: frame.result, error: frame.error },
|
|
86
|
+
});
|
|
87
|
+
case "skill":
|
|
88
|
+
return wrap("item/completed", { item: { type: "skill", name: frame.name, source: frame.source, resolved: frame.resolved } });
|
|
89
|
+
case "file":
|
|
90
|
+
return wrap("item/fileChange", { path: frame.path, change: frame.change, source: frame.source, diff: frame.diff });
|
|
91
|
+
case "plan":
|
|
92
|
+
return wrap("turn/plan/updated", { entries: frame.entries });
|
|
93
|
+
case "subagent":
|
|
94
|
+
return wrap("item/subagent", { phase: frame.phase, id: frame.id, name: frame.name, result: frame.result });
|
|
95
|
+
case "compaction":
|
|
96
|
+
return wrap("thread/compacted", { phase: frame.phase, summary: frame.summary });
|
|
97
|
+
case "notice":
|
|
98
|
+
return wrap("notice", { level: frame.level, code: frame.code, message: frame.message });
|
|
99
|
+
case "usage":
|
|
100
|
+
return wrap("thread/tokenUsage/updated", { usage: frame.usage });
|
|
101
|
+
case "raw":
|
|
102
|
+
return wrap("item/raw", { vendor: frame.vendor, type: frame.type, data: frame.data });
|
|
103
|
+
default:
|
|
104
|
+
return wrap("item/unknown", {});
|
|
105
|
+
}
|
|
106
|
+
},
|
|
107
|
+
parseFrame: (line) => {
|
|
108
|
+
let message: { method?: unknown; id?: unknown; params?: Record<string, unknown> } | null;
|
|
109
|
+
try {
|
|
110
|
+
message = JSON.parse(line);
|
|
111
|
+
} catch {
|
|
112
|
+
return undefined;
|
|
113
|
+
}
|
|
114
|
+
if (typeof message !== "object" || message === null) return undefined;
|
|
115
|
+
if (message.method === "turn/completed") return { kind: "frame", frame: { type: "turn.done" } };
|
|
116
|
+
const params = message.params ?? {};
|
|
117
|
+
if (message.method === "item/approval" && message.id !== undefined) {
|
|
118
|
+
return {
|
|
119
|
+
kind: "hook",
|
|
120
|
+
call: { id: String(message.id), tool: String(params.name ?? ""), args: (params.args ?? {}) as JsonValue },
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
const item = (params.item ?? {}) as Record<string, unknown>;
|
|
124
|
+
let activity: ExternalActivity;
|
|
125
|
+
switch (message.method) {
|
|
126
|
+
case "item/agentMessage/delta":
|
|
127
|
+
activity = { kind: "message.delta", content: { type: "text", text: String(params.delta) } };
|
|
128
|
+
break;
|
|
129
|
+
case "item/reasoning/delta":
|
|
130
|
+
activity = { kind: "message.delta", content: { type: "thinking", text: String(params.delta) } };
|
|
131
|
+
break;
|
|
132
|
+
case "item/started":
|
|
133
|
+
activity = {
|
|
134
|
+
kind: "tool.started",
|
|
135
|
+
call: { id: String(item.id), name: String(item.name), args: item.args as JsonValue },
|
|
136
|
+
};
|
|
137
|
+
break;
|
|
138
|
+
case "item/completed":
|
|
139
|
+
if (item.type === "toolResult") {
|
|
140
|
+
activity = { kind: "tool.completed", toolCallId: String(item.id), status: item.status as "finished" | "error" | "blocked" };
|
|
141
|
+
break;
|
|
142
|
+
}
|
|
143
|
+
if (item.type === "skill") {
|
|
144
|
+
activity = {
|
|
145
|
+
kind: "skill",
|
|
146
|
+
name: String(item.name),
|
|
147
|
+
source: (item.source ?? "explicit") as "native" | "tool" | "explicit" | "path",
|
|
148
|
+
resolved: item.resolved === true,
|
|
149
|
+
};
|
|
150
|
+
break;
|
|
151
|
+
}
|
|
152
|
+
activity = {
|
|
153
|
+
kind: "message",
|
|
154
|
+
message: { role: "assistant", content: [{ type: "text", text: String(item.text) }] },
|
|
155
|
+
};
|
|
156
|
+
break;
|
|
157
|
+
case "item/toolCall/progress":
|
|
158
|
+
activity = { kind: "tool.progress", toolCallId: String(params.toolCallId), progress: params.progress as JsonValue };
|
|
159
|
+
break;
|
|
160
|
+
case "item/fileChange":
|
|
161
|
+
activity = {
|
|
162
|
+
kind: "file",
|
|
163
|
+
path: String(params.path),
|
|
164
|
+
change: params.change as "created" | "modified" | "deleted" | "moved",
|
|
165
|
+
source: params.source as "agent" | "diff",
|
|
166
|
+
...(typeof params.diff === "string" ? { diff: params.diff } : {}),
|
|
167
|
+
};
|
|
168
|
+
break;
|
|
169
|
+
case "turn/plan/updated":
|
|
170
|
+
activity = { kind: "plan", entries: params.entries as { title: string; status: string }[] };
|
|
171
|
+
break;
|
|
172
|
+
case "item/subagent":
|
|
173
|
+
activity = { kind: "subagent", phase: params.phase as "started" | "completed", id: String(params.id) };
|
|
174
|
+
break;
|
|
175
|
+
case "thread/compacted":
|
|
176
|
+
activity = { kind: "compaction", phase: params.phase as "started" | "completed" };
|
|
177
|
+
break;
|
|
178
|
+
case "notice":
|
|
179
|
+
activity = {
|
|
180
|
+
kind: "notice",
|
|
181
|
+
level: params.level as "info" | "warn" | "error",
|
|
182
|
+
code: String(params.code),
|
|
183
|
+
message: String(params.message),
|
|
184
|
+
};
|
|
185
|
+
break;
|
|
186
|
+
case "thread/tokenUsage/updated":
|
|
187
|
+
activity = { kind: "usage", usage: params.usage as Usage };
|
|
188
|
+
break;
|
|
189
|
+
case "item/raw":
|
|
190
|
+
activity = { kind: "raw", vendor: String(params.vendor), type: String(params.type), data: params.data as JsonValue };
|
|
191
|
+
break;
|
|
192
|
+
default:
|
|
193
|
+
return undefined;
|
|
194
|
+
}
|
|
195
|
+
return { kind: "frame", frame: activity };
|
|
196
|
+
},
|
|
197
|
+
hook: {
|
|
198
|
+
via: "client",
|
|
199
|
+
request: (call) =>
|
|
200
|
+
JSON.stringify({
|
|
201
|
+
jsonrpc: "2.0",
|
|
202
|
+
id: call.id,
|
|
203
|
+
method: "item/approval",
|
|
204
|
+
params: { toolCallId: call.id, name: call.tool, args: call.args },
|
|
205
|
+
}),
|
|
206
|
+
},
|
|
207
|
+
});
|
|
208
|
+
|
|
209
|
+
export const rpcServerFixtures: AdapterConformanceFixtures = {
|
|
210
|
+
mode: "key",
|
|
211
|
+
home: {
|
|
212
|
+
hook: { path: ".rpc-server/config.json", content: '{"model":"planted-model"}' },
|
|
213
|
+
skill: { path: ".rpc-server/skills/planted/SKILL.md", content: "planted skill" },
|
|
214
|
+
mcp: { path: ".rpc-server/mcp.json", content: '{"servers":{"planted":{"command":"planted-server"}}}' },
|
|
215
|
+
},
|
|
216
|
+
config: (cli) => ({ binary: cli.command[0]!, args: cli.command.slice(1) }),
|
|
217
|
+
recorded: fileURLToPath(new URL("./fixtures/rpc-server.json", import.meta.url)),
|
|
218
|
+
};
|