@arnilo/prism-hosts 0.0.0-stage → 0.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +394 -0
- package/LICENSE +21 -0
- package/README.md +34 -2
- package/acp/README.md +87 -0
- package/acp/src/capabilities.ts +184 -0
- package/acp/src/errors.ts +24 -0
- package/acp/src/host.ts +36 -0
- package/acp/src/index.ts +25 -0
- package/acp/src/limits.ts +49 -0
- package/acp/src/mapper.ts +419 -0
- package/acp/src/permission.ts +37 -0
- package/acp/src/projection.ts +39 -0
- package/acp/src/prompt.ts +170 -0
- package/acp/src/serve.ts +345 -0
- package/acp/src/session-map.ts +49 -0
- package/ag-ui/README.md +56 -0
- package/ag-ui/src/a2ui.ts +570 -0
- package/ag-ui/src/ag-ui-mapper.ts +507 -0
- package/ag-ui/src/encrypted-value.ts +40 -0
- package/ag-ui/src/errors.ts +29 -0
- package/ag-ui/src/handler.ts +642 -0
- package/ag-ui/src/index.ts +177 -0
- package/ag-ui/src/input.ts +190 -0
- package/ag-ui/src/limits.ts +279 -0
- package/ag-ui/src/mcp-apps.ts +256 -0
- package/ag-ui/src/mcp.ts +94 -0
- package/ag-ui/src/projection.ts +201 -0
- package/ag-ui/src/projectors.ts +272 -0
- package/ag-ui/src/renderer/bind.ts +152 -0
- package/ag-ui/src/renderer/core.ts +270 -0
- package/ag-ui/src/renderer/index.ts +165 -0
- package/ag-ui/src/replay.ts +189 -0
- package/ag-ui/src/types.ts +66 -0
- package/channels/README.md +139 -0
- package/channels/src/admission.ts +8 -0
- package/channels/src/approvals.ts +262 -0
- package/channels/src/checkpoint-contract.ts +97 -0
- package/channels/src/delivery.ts +116 -0
- package/channels/src/host-ui.ts +356 -0
- package/channels/src/identity.ts +46 -0
- package/channels/src/index.ts +82 -0
- package/channels/src/limits.ts +49 -0
- package/channels/src/memory-stores.ts +112 -0
- package/channels/src/pairing.ts +178 -0
- package/channels/src/runtime-admit.ts +389 -0
- package/channels/src/runtime-core.ts +621 -0
- package/channels/src/runtime-reconcile.ts +299 -0
- package/channels/src/runtime-turn.ts +664 -0
- package/channels/src/runtime-types.ts +95 -0
- package/channels/src/runtime.ts +86 -0
- package/channels/src/secret-ref.ts +42 -0
- package/channels/src/signal.ts +790 -0
- package/channels/src/state.ts +355 -0
- package/channels/src/telegram.ts +1317 -0
- package/channels/src/types.ts +442 -0
- package/devtools/README.md +92 -0
- package/devtools/bin/prism-devtools.ts +63 -0
- package/devtools/src/args.ts +71 -0
- package/devtools/src/bun.d.ts +27 -0
- package/devtools/src/compare.ts +190 -0
- package/devtools/src/errors.ts +15 -0
- package/devtools/src/index.ts +25 -0
- package/devtools/src/replay.ts +36 -0
- package/devtools/src/security.ts +80 -0
- package/devtools/src/serve.ts +259 -0
- package/devtools/src/ui/assets.ts +108 -0
- package/devtools/src/ui/inspector.ts +182 -0
- package/driver-process/README.md +197 -0
- package/driver-process/src/abort.ts +74 -0
- package/driver-process/src/adapter.ts +211 -0
- package/driver-process/src/driver.ts +303 -0
- package/driver-process/src/errors.ts +17 -0
- package/driver-process/src/extend.ts +72 -0
- package/driver-process/src/index.ts +5 -0
- package/driver-process/src/inspect.ts +33 -0
- package/driver-process/src/session.ts +72 -0
- package/driver-process/src/testing.ts +394 -0
- package/driver-process/src/transports/json-rpc.ts +147 -0
- package/driver-process/src/transports/jsonl-stream.ts +12 -0
- package/driver-process/src/transports/types.ts +11 -0
- package/driver-process/src/turn.ts +106 -0
- package/evals/README.md +843 -0
- package/evals/src/calibration.ts +179 -0
- package/evals/src/citation-integrity.ts +98 -0
- package/evals/src/citations.ts +45 -0
- package/evals/src/compare-experiments.ts +153 -0
- package/evals/src/comparison.ts +230 -0
- package/evals/src/curate.ts +257 -0
- package/evals/src/dataset.ts +81 -0
- package/evals/src/erp-invariants.ts +163 -0
- package/evals/src/errors.ts +23 -0
- package/evals/src/experiment.ts +537 -0
- package/evals/src/failure-injection.ts +77 -0
- package/evals/src/feedback.ts +53 -0
- package/evals/src/index.ts +198 -0
- package/evals/src/injection.ts +247 -0
- package/evals/src/judge-panel.ts +109 -0
- package/evals/src/judge.ts +89 -0
- package/evals/src/limits.ts +50 -0
- package/evals/src/report-record.ts +47 -0
- package/evals/src/rubric-judge.ts +334 -0
- package/evals/src/scenario-runner.ts +317 -0
- package/evals/src/scenarios.ts +81 -0
- package/evals/src/score.ts +328 -0
- package/evals/src/scorer.ts +21 -0
- package/evals/src/state-match.ts +130 -0
- package/evals/src/stats.ts +635 -0
- package/evals/src/threshold.ts +117 -0
- package/evals/src/timeline.ts +38 -0
- package/evals/src/toolless-session.ts +33 -0
- package/evals/src/trace.ts +80 -0
- package/evals/src/trajectory.ts +623 -0
- package/evals/src/types.ts +672 -0
- package/evals/src/user-simulator.ts +101 -0
- package/evals/src/util.ts +207 -0
- package/headless/README.md +172 -0
- package/headless/src/answers.ts +91 -0
- package/headless/src/authority.ts +32 -0
- package/headless/src/errors.ts +36 -0
- package/headless/src/index.ts +17 -0
- package/headless/src/limits.ts +11 -0
- package/headless/src/pending.ts +16 -0
- package/headless/src/policy.ts +36 -0
- package/headless/src/resume.ts +103 -0
- package/headless/src/route.ts +153 -0
- package/headless/src/scheduler/clock.ts +22 -0
- package/headless/src/scheduler/cron.ts +19 -0
- package/headless/src/scheduler/firing.ts +58 -0
- package/headless/src/scheduler/index.ts +399 -0
- package/headless/src/scheduler/lease.ts +38 -0
- package/headless/src/scheduler/missed.ts +12 -0
- package/headless/src/scheduler/state.ts +132 -0
- package/host-builder/README.md +251 -0
- package/host-builder/bin/prism-host-builder.ts +169 -0
- package/host-builder/data/api.json +6167 -0
- package/host-builder/data/errors.json +546 -0
- package/host-builder/data/examples/acp.ts +63 -0
- package/host-builder/data/examples/adapters/conformance.ts +34 -0
- package/host-builder/data/examples/adapters/fixtures/rpc-server.json +26 -0
- package/host-builder/data/examples/adapters/fixtures/stream-cli.json +27 -0
- package/host-builder/data/examples/adapters/fixtures/workspace-config.json +28 -0
- package/host-builder/data/examples/adapters/rpc-server.dialect.ts +218 -0
- package/host-builder/data/examples/adapters/rpc-server.ts +309 -0
- package/host-builder/data/examples/adapters/stream-cli.dialect.ts +165 -0
- package/host-builder/data/examples/adapters/stream-cli.ts +256 -0
- package/host-builder/data/examples/adapters/workspace-config.dialect.ts +172 -0
- package/host-builder/data/examples/adapters/workspace-config.ts +251 -0
- package/host-builder/data/examples/advisor.ts +94 -0
- package/host-builder/data/examples/ag-ui-a2ui.ts +80 -0
- package/host-builder/data/examples/ag-ui-mcp-apps.ts +44 -0
- package/host-builder/data/examples/ag-ui-server.ts +118 -0
- package/host-builder/data/examples/agent-durable-approval.ts +43 -0
- package/host-builder/data/examples/api-key-auth.ts +23 -0
- package/host-builder/data/examples/approval.ts +92 -0
- package/host-builder/data/examples/attention-compiler.ts +81 -0
- package/host-builder/data/examples/autonomous-coding-loop.ts +343 -0
- package/host-builder/data/examples/behavior-evaluation.ts +303 -0
- package/host-builder/data/examples/build-workflow.ts +334 -0
- package/host-builder/data/examples/cache-aware-prompt-assembly.ts +139 -0
- package/host-builder/data/examples/caveman-ponytail.ts +197 -0
- package/host-builder/data/examples/cli.ts +31 -0
- package/host-builder/data/examples/coding-approval.ts +115 -0
- package/host-builder/data/examples/coding-browser-evaluation.ts +208 -0
- package/host-builder/data/examples/coding-compaction.ts +30 -0
- package/host-builder/data/examples/coding-goal-verify.ts +121 -0
- package/host-builder/data/examples/coding-tools-capability-gaps.ts +75 -0
- package/host-builder/data/examples/compaction.ts +36 -0
- package/host-builder/data/examples/connected-slack-mcp.ts +67 -0
- package/host-builder/data/examples/context.ts +29 -0
- package/host-builder/data/examples/custom-adapter.ts +256 -0
- package/host-builder/data/examples/custom-builders.ts +66 -0
- package/host-builder/data/examples/custom-loop.ts +89 -0
- package/host-builder/data/examples/custom-provider.ts +70 -0
- package/host-builder/data/examples/custom-session-store.ts +72 -0
- package/host-builder/data/examples/custom-tools-skills-context.ts +97 -0
- package/host-builder/data/examples/decision-models.ts +98 -0
- package/host-builder/data/examples/define-package.ts +188 -0
- package/host-builder/data/examples/delegate.ts +200 -0
- package/host-builder/data/examples/discover-skills.ts +65 -0
- package/host-builder/data/examples/drive-rag-sync.ts +44 -0
- package/host-builder/data/examples/durable-approval.ts +139 -0
- package/host-builder/data/examples/durable-investigation.ts +93 -0
- package/host-builder/data/examples/durable-loops-and-approvals.ts +94 -0
- package/host-builder/data/examples/enterprise-identity.ts +21 -0
- package/host-builder/data/examples/enterprise-policy-audit.ts +50 -0
- package/host-builder/data/examples/enterprise-work-connectors.ts +103 -0
- package/host-builder/data/examples/eval-injection.ts +73 -0
- package/host-builder/data/examples/eval-judges.ts +145 -0
- package/host-builder/data/examples/evals.ts +86 -0
- package/host-builder/data/examples/evaluation-gate.ts +40 -0
- package/host-builder/data/examples/execution-timeline.ts +173 -0
- package/host-builder/data/examples/external-agent.ts +541 -0
- package/host-builder/data/examples/external-app-db-backed.ts +344 -0
- package/host-builder/data/examples/governance-deny.ts +122 -0
- package/host-builder/data/examples/guardrail-packs.ts +240 -0
- package/host-builder/data/examples/headless-host.ts +245 -0
- package/host-builder/data/examples/hooks-audit-command.mjs +31 -0
- package/host-builder/data/examples/hooks-json.ts +87 -0
- package/host-builder/data/examples/host-builder-agent.ts +150 -0
- package/host-builder/data/examples/host-hooks.ts +71 -0
- package/host-builder/data/examples/host-step-loop-timeline.ts +212 -0
- package/host-builder/data/examples/hosted-sandbox.ts +48 -0
- package/host-builder/data/examples/instruction-injection.ts +127 -0
- package/host-builder/data/examples/jsonl-stores-branching.ts +49 -0
- package/host-builder/data/examples/long-term-memory.ts +158 -0
- package/host-builder/data/examples/manifest.ts +112 -0
- package/host-builder/data/examples/mcp-server.ts +48 -0
- package/host-builder/data/examples/mcp-trust.ts +173 -0
- package/host-builder/data/examples/memory-and-wiki.ts +315 -0
- package/host-builder/data/examples/memory-lifecycle.ts +302 -0
- package/host-builder/data/examples/memory-system.ts +252 -0
- package/host-builder/data/examples/messaging-agent.ts +70 -0
- package/host-builder/data/examples/minimal-host-app.ts +41 -0
- package/host-builder/data/examples/model-router-aggregate-budgets.ts +364 -0
- package/host-builder/data/examples/model-router.ts +106 -0
- package/host-builder/data/examples/obscura.ts +48 -0
- package/host-builder/data/examples/observability.ts +116 -0
- package/host-builder/data/examples/open-connector-sidecar.ts +105 -0
- package/host-builder/data/examples/openai-compatible.ts +70 -0
- package/host-builder/data/examples/package-skills.ts +85 -0
- package/host-builder/data/examples/phase9-coding-intelligence.ts +221 -0
- package/host-builder/data/examples/provider-registration.ts +29 -0
- package/host-builder/data/examples/provider-resolver.ts +39 -0
- package/host-builder/data/examples/rag.ts +40 -0
- package/host-builder/data/examples/remote-agent-server.ts +45 -0
- package/host-builder/data/examples/remote-agent.ts +124 -0
- package/host-builder/data/examples/research-ledger.ts +79 -0
- package/host-builder/data/examples/revocation-propagation.ts +287 -0
- package/host-builder/data/examples/run-feedback.ts +93 -0
- package/host-builder/data/examples/scanned-document-rag.ts +48 -0
- package/host-builder/data/examples/sdk-basics.ts +21 -0
- package/host-builder/data/examples/secure-agent.ts +55 -0
- package/host-builder/data/examples/semantic-memory.ts +52 -0
- package/host-builder/data/examples/serve-tools.ts +495 -0
- package/host-builder/data/examples/session-memory.ts +317 -0
- package/host-builder/data/examples/session-search.ts +131 -0
- package/host-builder/data/examples/session.ts +52 -0
- package/host-builder/data/examples/side-call.ts +64 -0
- package/host-builder/data/examples/signal-agent.ts +9 -0
- package/host-builder/data/examples/skills-progressive-disclosure.ts +88 -0
- package/host-builder/data/examples/skills.ts +19 -0
- package/host-builder/data/examples/sqlite-resume.ts +147 -0
- package/host-builder/data/examples/system-project-prompts.ts +74 -0
- package/host-builder/data/examples/system-prompts.ts +19 -0
- package/host-builder/data/examples/telegram-agent.ts +30 -0
- package/host-builder/data/examples/tool-narrowing-planes.ts +99 -0
- package/host-builder/data/examples/tools.ts +29 -0
- package/host-builder/data/examples/validator.ts +67 -0
- package/host-builder/data/examples/web-no-key.ts +85 -0
- package/host-builder/data/examples/web-research.ts +35 -0
- package/host-builder/data/examples/workflow-event-sink.ts +114 -0
- package/host-builder/data/examples/workflow-loop.ts +93 -0
- package/host-builder/data/examples/workflow-multimodal-document.ts +94 -0
- package/host-builder/data/examples/workflow-parallel-research.ts +111 -0
- package/host-builder/data/examples/workflow-postgres-resume.ts +75 -0
- package/host-builder/data/examples/workflow-research-and-review.ts +98 -0
- package/host-builder/data/examples/workflow-sqlite-resume.ts +163 -0
- package/host-builder/data/examples.json +130 -0
- package/host-builder/skills/prism-host-builder/SKILL.md +85 -0
- package/host-builder/skills/prism-host-builder/references/choosing.md +101 -0
- package/host-builder/skills/prism-host-builder/references/layout.md +52 -0
- package/host-builder/skills/prism-host-builder/references/pitfalls.md +50 -0
- package/host-builder/skills/prism-host-builder/references/recipes.md +129 -0
- package/host-builder/skills/prism-host-builder/references/security.md +52 -0
- package/host-builder/skills/prism-host-builder/references/upgrading.md +67 -0
- package/host-builder/skills/prism-host-builder/references/verification.md +108 -0
- package/host-builder/src/check/child.ts +108 -0
- package/host-builder/src/check/conformance.ts +13 -0
- package/host-builder/src/check/inspect.ts +20 -0
- package/host-builder/src/check/manifest.ts +23 -0
- package/host-builder/src/check/runner.ts +181 -0
- package/host-builder/src/check/targets.ts +65 -0
- package/host-builder/src/errors.ts +35 -0
- package/host-builder/src/index.ts +25 -0
- package/host-builder/src/indexes.ts +145 -0
- package/host-builder/src/install/install.ts +400 -0
- package/host-builder/src/install/targets.ts +50 -0
- package/host-builder/src/lookup/api.ts +127 -0
- package/host-builder/src/lookup/bound.ts +38 -0
- package/host-builder/src/lookup/docs.ts +238 -0
- package/host-builder/src/lookup/errors.ts +92 -0
- package/host-builder/src/lookup/examples.ts +117 -0
- package/host-builder/src/lookup/text.ts +60 -0
- package/host-builder/src/server.ts +300 -0
- package/host-builder/src/version.ts +38 -0
- package/mcp-server/README.md +219 -0
- package/mcp-server/src/bounds.ts +23 -0
- package/mcp-server/src/host.ts +31 -0
- package/mcp-server/src/index.ts +27 -0
- package/mcp-server/src/serve-tools.ts +408 -0
- package/mcp-server/src/serve.ts +329 -0
- package/mcp-server/src/server.ts +331 -0
- package/mcp-server/src/session-map.ts +47 -0
- package/mcp-server/src/skill-resources.ts +85 -0
- package/mcp-server/src/types.ts +215 -0
- package/package.json +130 -4
- package/remote/README.md +244 -0
- package/remote/src/attribution.ts +22 -0
- package/remote/src/auth.ts +30 -0
- package/remote/src/bun-module.d.ts +34 -0
- package/remote/src/channel.ts +86 -0
- package/remote/src/connect.ts +212 -0
- package/remote/src/dispatcher.ts +282 -0
- package/remote/src/errors.ts +59 -0
- package/remote/src/host-ui.ts +152 -0
- package/remote/src/http-gate.ts +43 -0
- package/remote/src/index.ts +53 -0
- package/remote/src/jsonl.ts +69 -0
- package/remote/src/limits.ts +43 -0
- package/remote/src/mirror.ts +90 -0
- package/remote/src/pending.ts +22 -0
- package/remote/src/protocol.ts +107 -0
- package/remote/src/serve.ts +560 -0
- package/remote/src/session-proxy.ts +219 -0
- package/remote/src/sse.ts +38 -0
- package/remote/src/stdio-client.ts +41 -0
- package/remote/src/testing-fixtures/serve-stdio.ts +32 -0
- package/remote/src/testing.ts +230 -0
- package/remote/src/transport.ts +139 -0
- package/remote/src/transports/client.ts +126 -0
- package/remote/src/transports/network.ts +268 -0
- package/remote/src/wire.ts +244 -0
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
export {
|
|
2
|
+
A2UI_ACTIVITY_TYPE,
|
|
3
|
+
A2UI_ERROR_EVENT,
|
|
4
|
+
A2UI_OPERATIONS_KEY,
|
|
5
|
+
A2UI_VERSION,
|
|
6
|
+
type AgUiA2UiAction,
|
|
7
|
+
type AgUiA2UiLimitOptions,
|
|
8
|
+
type AgUiA2UiOptions,
|
|
9
|
+
type AgUiA2UiPainter,
|
|
10
|
+
createAgUiA2UiPainter,
|
|
11
|
+
DEFAULT_MAX_A2UI_COMPONENT_DEPTH,
|
|
12
|
+
DEFAULT_MAX_A2UI_OPERATION_BYTES,
|
|
13
|
+
DEFAULT_MAX_A2UI_OPS_PER_MESSAGE,
|
|
14
|
+
DEFAULT_MAX_A2UI_SURFACES_PER_RUN,
|
|
15
|
+
extractAgUiA2UiActions,
|
|
16
|
+
HARD_MAX_A2UI_COMPONENT_DEPTH,
|
|
17
|
+
HARD_MAX_A2UI_OPERATION_BYTES,
|
|
18
|
+
HARD_MAX_A2UI_OPS_PER_MESSAGE,
|
|
19
|
+
HARD_MAX_A2UI_SURFACES_PER_RUN,
|
|
20
|
+
type ResolvedAgUiA2UiLimits,
|
|
21
|
+
resolveAgUiA2UiLimits,
|
|
22
|
+
} from "./a2ui.js";
|
|
23
|
+
export { type AgUiEventMapper, type AgUiEventMapperOptions, createAgUiEventMapper } from "./ag-ui-mapper.js";
|
|
24
|
+
export {
|
|
25
|
+
type CreateReasoningEncryptedValueOptions,
|
|
26
|
+
createReasoningEncryptedValue,
|
|
27
|
+
} from "./encrypted-value.js";
|
|
28
|
+
export { AgUiError, type AgUiErrorCode } from "./errors.js";
|
|
29
|
+
export {
|
|
30
|
+
type AgUiAuthorizationInput,
|
|
31
|
+
type AgUiFrontendToolHandoff,
|
|
32
|
+
type AgUiFrontendToolPolicyInput,
|
|
33
|
+
type AgUiHandler,
|
|
34
|
+
type AgUiInputOptions,
|
|
35
|
+
type AgUiInputPolicyOptions,
|
|
36
|
+
type AgUiInputProjection,
|
|
37
|
+
type AgUiInputProjectorInput,
|
|
38
|
+
type AgUiPreparedInput,
|
|
39
|
+
type CreateAgUiHandlerOptions,
|
|
40
|
+
createAgUiHandler,
|
|
41
|
+
resolveAgUiCapabilities,
|
|
42
|
+
} from "./handler.js";
|
|
43
|
+
export {
|
|
44
|
+
type AgUiLimitOptions,
|
|
45
|
+
DEFAULT_AG_UI_LIMITS,
|
|
46
|
+
DEFAULT_MAX_ACTIVITY_BYTES,
|
|
47
|
+
DEFAULT_MAX_CURSOR_BYTES,
|
|
48
|
+
DEFAULT_MAX_ERROR_BYTES,
|
|
49
|
+
DEFAULT_MAX_EVENT_BYTES,
|
|
50
|
+
DEFAULT_MAX_INPUT_CONTEXT_BYTES,
|
|
51
|
+
DEFAULT_MAX_INPUT_CONTEXTS,
|
|
52
|
+
DEFAULT_MAX_INPUT_INTERRUPTS,
|
|
53
|
+
DEFAULT_MAX_INPUT_MEDIA_BYTES,
|
|
54
|
+
DEFAULT_MAX_INPUT_MEDIA_PARTS,
|
|
55
|
+
DEFAULT_MAX_INPUT_MESSAGES,
|
|
56
|
+
DEFAULT_MAX_INPUT_TEXT_BYTES,
|
|
57
|
+
DEFAULT_MAX_INPUT_TOOL_BYTES,
|
|
58
|
+
DEFAULT_MAX_INPUT_TOOLS,
|
|
59
|
+
DEFAULT_MAX_JSON_ARRAY_ITEMS,
|
|
60
|
+
DEFAULT_MAX_JSON_DEPTH,
|
|
61
|
+
DEFAULT_MAX_JSON_PROPERTIES,
|
|
62
|
+
DEFAULT_MAX_PATCH_OPERATIONS,
|
|
63
|
+
DEFAULT_MAX_QUEUED_EVENTS,
|
|
64
|
+
DEFAULT_MAX_RAW_EVENT_BYTES,
|
|
65
|
+
DEFAULT_MAX_REASONING_BYTES,
|
|
66
|
+
DEFAULT_MAX_REPLAY_EVENTS,
|
|
67
|
+
DEFAULT_MAX_REQUEST_BYTES,
|
|
68
|
+
DEFAULT_MAX_STATE_BYTES,
|
|
69
|
+
DEFAULT_MAX_STREAM_BYTES,
|
|
70
|
+
DEFAULT_MAX_STREAM_EVENTS,
|
|
71
|
+
DEFAULT_MAX_TEXT_BYTES,
|
|
72
|
+
DEFAULT_REQUEST_TIMEOUT_MS,
|
|
73
|
+
HARD_AG_UI_LIMITS,
|
|
74
|
+
HARD_MAX_ACTIVITY_BYTES,
|
|
75
|
+
HARD_MAX_CURSOR_BYTES,
|
|
76
|
+
HARD_MAX_ERROR_BYTES,
|
|
77
|
+
HARD_MAX_EVENT_BYTES,
|
|
78
|
+
HARD_MAX_INPUT_CONTEXT_BYTES,
|
|
79
|
+
HARD_MAX_INPUT_CONTEXTS,
|
|
80
|
+
HARD_MAX_INPUT_INTERRUPTS,
|
|
81
|
+
HARD_MAX_INPUT_MEDIA_BYTES,
|
|
82
|
+
HARD_MAX_INPUT_MEDIA_PARTS,
|
|
83
|
+
HARD_MAX_INPUT_MESSAGES,
|
|
84
|
+
HARD_MAX_INPUT_TEXT_BYTES,
|
|
85
|
+
HARD_MAX_INPUT_TOOL_BYTES,
|
|
86
|
+
HARD_MAX_INPUT_TOOLS,
|
|
87
|
+
HARD_MAX_JSON_ARRAY_ITEMS,
|
|
88
|
+
HARD_MAX_JSON_DEPTH,
|
|
89
|
+
HARD_MAX_JSON_PROPERTIES,
|
|
90
|
+
HARD_MAX_PATCH_OPERATIONS,
|
|
91
|
+
HARD_MAX_QUEUED_EVENTS,
|
|
92
|
+
HARD_MAX_RAW_EVENT_BYTES,
|
|
93
|
+
HARD_MAX_REASONING_BYTES,
|
|
94
|
+
HARD_MAX_REPLAY_EVENTS,
|
|
95
|
+
HARD_MAX_REQUEST_BYTES,
|
|
96
|
+
HARD_MAX_STATE_BYTES,
|
|
97
|
+
HARD_MAX_STREAM_BYTES,
|
|
98
|
+
HARD_MAX_STREAM_EVENTS,
|
|
99
|
+
HARD_MAX_TEXT_BYTES,
|
|
100
|
+
HARD_REQUEST_TIMEOUT_MS,
|
|
101
|
+
type ResolvedAgUiLimits,
|
|
102
|
+
resolveAgUiLimits,
|
|
103
|
+
} from "./limits.js";
|
|
104
|
+
export {
|
|
105
|
+
type AgUiMcpAdapter,
|
|
106
|
+
type AgUiMcpPrepareInput,
|
|
107
|
+
type AgUiMcpToolSelectionInput,
|
|
108
|
+
type CreateAgUiMcpAdapterOptions,
|
|
109
|
+
createAgUiMcpAdapter,
|
|
110
|
+
} from "./mcp.js";
|
|
111
|
+
export {
|
|
112
|
+
type AgUiMcpAppAuthorizationInput,
|
|
113
|
+
type AgUiMcpAppCallContext,
|
|
114
|
+
type AgUiMcpAppSandbox,
|
|
115
|
+
type CreateAgUiMcpAppHandlerOptions,
|
|
116
|
+
createAgUiMcpAppHandler,
|
|
117
|
+
createAgUiMcpAppSandbox,
|
|
118
|
+
} from "./mcp-apps.js";
|
|
119
|
+
export type {
|
|
120
|
+
AgUiActivityDelta,
|
|
121
|
+
AgUiActivitySnapshot,
|
|
122
|
+
AgUiCustomProjection,
|
|
123
|
+
AgUiProjectedImage,
|
|
124
|
+
AgUiProjectedToolResult,
|
|
125
|
+
AgUiProjection,
|
|
126
|
+
AgUiRawProjection,
|
|
127
|
+
AgUiReasoningProjection,
|
|
128
|
+
Awaitable,
|
|
129
|
+
} from "./projection.js";
|
|
130
|
+
export { type CoWorkProjectionOptions, projectAgUiJson, projectAgUiPatch, projectCoWorkEvent } from "./projection.js";
|
|
131
|
+
export {
|
|
132
|
+
type AgUiStateStore,
|
|
133
|
+
type CreateActivityFromToolProgressProjectionOptions,
|
|
134
|
+
type CreateMessagesFromSessionProjectionOptions,
|
|
135
|
+
type CreateStateFromStoreProjectionOptions,
|
|
136
|
+
composeAgUiProjections,
|
|
137
|
+
createActivityFromToolProgressProjection,
|
|
138
|
+
createMessagesFromSessionProjection,
|
|
139
|
+
createStateFromStoreProjection,
|
|
140
|
+
DEFAULT_MAX_PROJECTOR_MESSAGES,
|
|
141
|
+
HARD_MAX_PROJECTOR_MESSAGES,
|
|
142
|
+
jsonDiff,
|
|
143
|
+
} from "./projectors.js";
|
|
144
|
+
// Task 14: reference renderer subpath (@arnilo/prism-hosts/ag-ui/renderer).
|
|
145
|
+
// Type-only re-exports; runtime DOM code stays behind the subpath so the main
|
|
146
|
+
// entry remains runtime-agnostic.
|
|
147
|
+
export type {
|
|
148
|
+
A2UiCatalog,
|
|
149
|
+
A2UiComponentModel,
|
|
150
|
+
A2UiComponentRenderer,
|
|
151
|
+
A2UiRenderContext,
|
|
152
|
+
A2UiRenderError,
|
|
153
|
+
A2UiRenderer,
|
|
154
|
+
A2UiSurfaceModel,
|
|
155
|
+
CreateA2UiRendererOptions,
|
|
156
|
+
Dom,
|
|
157
|
+
DomNode,
|
|
158
|
+
} from "./renderer/index.js";
|
|
159
|
+
export {
|
|
160
|
+
type AgentEventSourceAgUiReplayOptions,
|
|
161
|
+
type AgUiReplay,
|
|
162
|
+
type AgUiReplayEvent,
|
|
163
|
+
type AgUiReplayPage,
|
|
164
|
+
type AgUiReplayRequest,
|
|
165
|
+
type CoWorkReplay,
|
|
166
|
+
type CoWorkReplayOptions,
|
|
167
|
+
type CoWorkReplayPage,
|
|
168
|
+
type CoWorkReplayRequest,
|
|
169
|
+
type CoWorkSource,
|
|
170
|
+
createAgentEventSourceAgUiReplay,
|
|
171
|
+
createCoWorkReplay,
|
|
172
|
+
createPersistenceAgUiReplay,
|
|
173
|
+
type PersistenceAgUiReplayOptions,
|
|
174
|
+
} from "./replay.js";
|
|
175
|
+
export type { AgUiAuthorization, AgUiRunReference, CoWorkContext, CoWorkEvent, CoWorkKind } from "./types.js";
|
|
176
|
+
|
|
177
|
+
export const packageName = "@arnilo/prism-hosts/ag-ui";
|
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
import { type Message as AgUiMessage, type Context, type ResumeEntry, type RunAgentInput, type Tool } from "@ag-ui/core";
|
|
2
|
+
import { RunAgentInputSchema } from "@ag-ui/core/schemas";
|
|
3
|
+
import { AgUiError } from "./errors.js";
|
|
4
|
+
import type { ResolvedAgUiLimits } from "./limits.js";
|
|
5
|
+
|
|
6
|
+
/** Fully schema-validated, byte-bounded AG-UI request. Values remain untrusted until a host projector accepts them. */
|
|
7
|
+
export interface ParsedAgUiInput {
|
|
8
|
+
readonly request: RunAgentInput;
|
|
9
|
+
readonly threadId: string;
|
|
10
|
+
readonly runId: string;
|
|
11
|
+
readonly parentRunId?: string;
|
|
12
|
+
readonly messages: readonly AgUiMessage[];
|
|
13
|
+
readonly tools: readonly Tool[];
|
|
14
|
+
readonly context: readonly Context[];
|
|
15
|
+
readonly state: unknown;
|
|
16
|
+
readonly forwardedProps: unknown;
|
|
17
|
+
readonly resume: readonly ResumeEntry[];
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/** Parses complete official input without granting client fields runtime authority. */
|
|
21
|
+
export function parseAgUiInput(value: unknown, limits: ResolvedAgUiLimits): ParsedAgUiInput {
|
|
22
|
+
const result = RunAgentInputSchema.safeParse(value);
|
|
23
|
+
if (!result.success) throw new AgUiError("ERR_PRISM_AG_UI_INPUT", "Invalid AG-UI run input");
|
|
24
|
+
const input = result.data;
|
|
25
|
+
assertId(input.threadId, "threadId");
|
|
26
|
+
assertId(input.runId, "runId");
|
|
27
|
+
if (input.parentRunId !== undefined) assertId(input.parentRunId, "parentRunId");
|
|
28
|
+
if (input.messages.length > limits.maxInputMessages) throw new AgUiError("ERR_PRISM_AG_UI_LIMIT", "Too many input messages");
|
|
29
|
+
if (input.tools.length > limits.maxInputTools) throw new AgUiError("ERR_PRISM_AG_UI_LIMIT", "Too many frontend tools");
|
|
30
|
+
if (input.context.length > limits.maxInputContexts) throw new AgUiError("ERR_PRISM_AG_UI_LIMIT", "Too many input contexts");
|
|
31
|
+
if ((input.resume?.length ?? 0) > limits.maxInputInterrupts) throw new AgUiError("ERR_PRISM_AG_UI_LIMIT", "Too many resume entries");
|
|
32
|
+
|
|
33
|
+
assertBoundedJson(input.state, limits.maxStateBytes, limits, "state");
|
|
34
|
+
assertBoundedJson(input.forwardedProps, limits.maxStateBytes, limits, "forwardedProps");
|
|
35
|
+
assertBoundedJson(input.messages, limits.maxInputTextBytes, limits, "messages");
|
|
36
|
+
assertBoundedJson(input.tools, limits.maxInputToolBytes, limits, "tools");
|
|
37
|
+
assertBoundedJson(input.context, limits.maxInputContextBytes, limits, "context");
|
|
38
|
+
assertBoundedJson(input.resume ?? [], limits.maxStateBytes, limits, "resume");
|
|
39
|
+
assertMessageIds(input.messages);
|
|
40
|
+
assertToolIds(input.tools);
|
|
41
|
+
assertResumeIds(input.resume ?? []);
|
|
42
|
+
assertMediaBounds(input.messages, limits);
|
|
43
|
+
|
|
44
|
+
return {
|
|
45
|
+
request: input,
|
|
46
|
+
threadId: input.threadId,
|
|
47
|
+
runId: input.runId,
|
|
48
|
+
parentRunId: input.parentRunId,
|
|
49
|
+
messages: input.messages,
|
|
50
|
+
tools: input.tools,
|
|
51
|
+
context: input.context,
|
|
52
|
+
state: input.state,
|
|
53
|
+
forwardedProps: input.forwardedProps,
|
|
54
|
+
resume: input.resume ?? [],
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/** Legacy secure default: only final text user input may reach a Prism session. */
|
|
59
|
+
export function defaultAgUiInput(input: ParsedAgUiInput, limits: ResolvedAgUiLimits): string {
|
|
60
|
+
if (input.tools.length !== 0 || !emptyState(input.state)) {
|
|
61
|
+
throw new AgUiError("ERR_PRISM_AG_UI_INPUT", "Frontend tools and state are not supported without input.project");
|
|
62
|
+
}
|
|
63
|
+
const message = [...input.messages].reverse().find((item) => item.role === "user");
|
|
64
|
+
if (!message) throw new AgUiError("ERR_PRISM_AG_UI_INPUT", "A user message is required");
|
|
65
|
+
const userText = textContent(message.content);
|
|
66
|
+
if (Buffer.byteLength(userText, "utf8") > limits.maxInputTextBytes) {
|
|
67
|
+
throw new AgUiError("ERR_PRISM_AG_UI_LIMIT", "User message exceeds maxInputTextBytes");
|
|
68
|
+
}
|
|
69
|
+
return userText;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/** Bounded JSON check shared by untrusted input and host output projectors. */
|
|
73
|
+
export function assertBoundedJson(
|
|
74
|
+
value: unknown,
|
|
75
|
+
maxBytes: number,
|
|
76
|
+
limits: Pick<ResolvedAgUiLimits, "maxJsonDepth" | "maxJsonProperties" | "maxJsonArrayItems">,
|
|
77
|
+
name: string,
|
|
78
|
+
): void {
|
|
79
|
+
let properties = 0;
|
|
80
|
+
const visit = (current: unknown, depth: number): void => {
|
|
81
|
+
if (depth > limits.maxJsonDepth) throw new AgUiError("ERR_PRISM_AG_UI_LIMIT", `${name} exceeds maxJsonDepth`);
|
|
82
|
+
if (current === null || typeof current === "string" || typeof current === "boolean") return;
|
|
83
|
+
if (typeof current === "number") {
|
|
84
|
+
if (!Number.isFinite(current)) throw new AgUiError("ERR_PRISM_AG_UI_INPUT", `${name} must be JSON-serializable`);
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
if (Array.isArray(current)) {
|
|
88
|
+
if (current.length > limits.maxJsonArrayItems) throw new AgUiError("ERR_PRISM_AG_UI_LIMIT", `${name} exceeds maxJsonArrayItems`);
|
|
89
|
+
for (const item of current) visit(item, depth + 1);
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
if (
|
|
93
|
+
!current ||
|
|
94
|
+
typeof current !== "object" ||
|
|
95
|
+
(Object.getPrototypeOf(current) !== Object.prototype && Object.getPrototypeOf(current) !== null)
|
|
96
|
+
) {
|
|
97
|
+
throw new AgUiError("ERR_PRISM_AG_UI_INPUT", `${name} must be JSON-serializable`);
|
|
98
|
+
}
|
|
99
|
+
for (const [key, item] of Object.entries(current)) {
|
|
100
|
+
if (key === "__proto__" || key === "prototype" || key === "constructor") {
|
|
101
|
+
throw new AgUiError("ERR_PRISM_AG_UI_INPUT", `${name} contains a forbidden key`);
|
|
102
|
+
}
|
|
103
|
+
properties += 1;
|
|
104
|
+
if (properties > limits.maxJsonProperties) throw new AgUiError("ERR_PRISM_AG_UI_LIMIT", `${name} exceeds maxJsonProperties`);
|
|
105
|
+
visit(item, depth + 1);
|
|
106
|
+
}
|
|
107
|
+
};
|
|
108
|
+
visit(value, 0);
|
|
109
|
+
let serialized: string | undefined;
|
|
110
|
+
try {
|
|
111
|
+
serialized = JSON.stringify(value);
|
|
112
|
+
} catch {
|
|
113
|
+
throw new AgUiError("ERR_PRISM_AG_UI_INPUT", `${name} must be JSON-serializable`);
|
|
114
|
+
}
|
|
115
|
+
if (serialized === undefined) throw new AgUiError("ERR_PRISM_AG_UI_INPUT", `${name} must be JSON-serializable`);
|
|
116
|
+
if (Buffer.byteLength(serialized, "utf8") > maxBytes) throw new AgUiError("ERR_PRISM_AG_UI_LIMIT", `${name} exceeds byte limit`);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
function textContent(content: unknown): string {
|
|
120
|
+
if (typeof content === "string") return content;
|
|
121
|
+
if (
|
|
122
|
+
!Array.isArray(content) ||
|
|
123
|
+
content.some(
|
|
124
|
+
(part) =>
|
|
125
|
+
!part ||
|
|
126
|
+
typeof part !== "object" ||
|
|
127
|
+
(part as { type?: unknown }).type !== "text" ||
|
|
128
|
+
typeof (part as { text?: unknown }).text !== "string",
|
|
129
|
+
)
|
|
130
|
+
) {
|
|
131
|
+
throw new AgUiError("ERR_PRISM_AG_UI_INPUT", "Only text user content is supported without input.project");
|
|
132
|
+
}
|
|
133
|
+
return content.map((part) => (part as { text: string }).text).join("");
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
function emptyState(value: unknown): boolean {
|
|
137
|
+
return value === undefined || value === null || (typeof value === "object" && !Array.isArray(value) && Object.keys(value).length === 0);
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
function assertMessageIds(messages: readonly AgUiMessage[]): void {
|
|
141
|
+
for (const message of messages) {
|
|
142
|
+
assertId(message.id, "message id");
|
|
143
|
+
if (message.role === "assistant") {
|
|
144
|
+
for (const call of message.toolCalls ?? []) {
|
|
145
|
+
assertId(call.id, "tool call id");
|
|
146
|
+
if (Buffer.byteLength(call.function.name, "utf8") > 512) throw new AgUiError("ERR_PRISM_AG_UI_LIMIT", "Tool call name is too long");
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
if (message.role === "tool") assertId(message.toolCallId, "tool result id");
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
function assertToolIds(tools: readonly Tool[]): void {
|
|
154
|
+
for (const tool of tools) {
|
|
155
|
+
if (Buffer.byteLength(tool.name, "utf8") > 512 || Buffer.byteLength(tool.description, "utf8") > 8 * 1024) {
|
|
156
|
+
throw new AgUiError("ERR_PRISM_AG_UI_LIMIT", "Frontend tool is too large");
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
function assertResumeIds(entries: readonly ResumeEntry[]): void {
|
|
162
|
+
for (const entry of entries) assertId(entry.interruptId, "interruptId");
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
function assertMediaBounds(messages: readonly AgUiMessage[], limits: ResolvedAgUiLimits): void {
|
|
166
|
+
let parts = 0;
|
|
167
|
+
let bytes = 0;
|
|
168
|
+
for (const message of messages) {
|
|
169
|
+
if (message.role !== "user" || !Array.isArray(message.content)) continue;
|
|
170
|
+
for (const part of message.content) {
|
|
171
|
+
if (part.type !== "image" && part.type !== "audio" && part.type !== "video" && part.type !== "document") continue;
|
|
172
|
+
parts += 1;
|
|
173
|
+
if (parts > limits.maxInputMediaParts) throw new AgUiError("ERR_PRISM_AG_UI_LIMIT", "Too many input media parts");
|
|
174
|
+
const data = part.source.type === "data" ? part.source.value : undefined;
|
|
175
|
+
if (data) bytes += estimateBase64DecodedBytes(data);
|
|
176
|
+
if (bytes > limits.maxInputMediaBytes) throw new AgUiError("ERR_PRISM_AG_UI_LIMIT", "Input media exceeds maxInputMediaBytes");
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
function estimateBase64DecodedBytes(value: string): number {
|
|
182
|
+
const padding = value.endsWith("==") ? 2 : value.endsWith("=") ? 1 : 0;
|
|
183
|
+
return Math.max(0, Math.floor((value.length * 3) / 4) - padding);
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
function assertId(value: string, name: string): void {
|
|
187
|
+
if (value.length > 128 || !/^[A-Za-z0-9][A-Za-z0-9._:-]*$/.test(value)) {
|
|
188
|
+
throw new AgUiError("ERR_PRISM_AG_UI_INPUT", `${name} is invalid`);
|
|
189
|
+
}
|
|
190
|
+
}
|
|
@@ -0,0 +1,279 @@
|
|
|
1
|
+
import { AgUiError } from "./errors.js";
|
|
2
|
+
|
|
3
|
+
/** Phase 7 frozen baseline transport caps. */
|
|
4
|
+
export const DEFAULT_MAX_EVENT_BYTES = 64 * 1024;
|
|
5
|
+
export const HARD_MAX_EVENT_BYTES = 1024 * 1024;
|
|
6
|
+
export const DEFAULT_MAX_TEXT_BYTES = 64 * 1024;
|
|
7
|
+
export const HARD_MAX_TEXT_BYTES = 1024 * 1024;
|
|
8
|
+
export const DEFAULT_MAX_ERROR_BYTES = 8 * 1024;
|
|
9
|
+
export const HARD_MAX_ERROR_BYTES = 64 * 1024;
|
|
10
|
+
export const DEFAULT_MAX_REQUEST_BYTES = 64 * 1024;
|
|
11
|
+
export const HARD_MAX_REQUEST_BYTES = 1024 * 1024;
|
|
12
|
+
export const DEFAULT_MAX_INPUT_MESSAGES = 128;
|
|
13
|
+
export const HARD_MAX_INPUT_MESSAGES = 1024;
|
|
14
|
+
export const DEFAULT_MAX_INPUT_TEXT_BYTES = 64 * 1024;
|
|
15
|
+
export const HARD_MAX_INPUT_TEXT_BYTES = 1024 * 1024;
|
|
16
|
+
export const DEFAULT_MAX_CURSOR_BYTES = 4 * 1024;
|
|
17
|
+
export const HARD_MAX_CURSOR_BYTES = 16 * 1024;
|
|
18
|
+
export const DEFAULT_MAX_REPLAY_EVENTS = 100;
|
|
19
|
+
export const HARD_MAX_REPLAY_EVENTS = 500;
|
|
20
|
+
export const DEFAULT_MAX_STREAM_EVENTS = 10_000;
|
|
21
|
+
export const HARD_MAX_STREAM_EVENTS = 100_000;
|
|
22
|
+
export const DEFAULT_MAX_STREAM_BYTES = 10 * 1024 * 1024;
|
|
23
|
+
export const HARD_MAX_STREAM_BYTES = 64 * 1024 * 1024;
|
|
24
|
+
export const DEFAULT_MAX_QUEUED_EVENTS = 128;
|
|
25
|
+
export const HARD_MAX_QUEUED_EVENTS = 4096;
|
|
26
|
+
export const DEFAULT_REQUEST_TIMEOUT_MS = 120_000;
|
|
27
|
+
export const HARD_REQUEST_TIMEOUT_MS = 30 * 60_000;
|
|
28
|
+
|
|
29
|
+
/** Full AG-UI request/projection caps. They can narrow but never exceed these hard limits. */
|
|
30
|
+
export const DEFAULT_MAX_INPUT_TOOLS = 32;
|
|
31
|
+
export const HARD_MAX_INPUT_TOOLS = 256;
|
|
32
|
+
export const DEFAULT_MAX_INPUT_CONTEXTS = 32;
|
|
33
|
+
export const HARD_MAX_INPUT_CONTEXTS = 256;
|
|
34
|
+
export const DEFAULT_MAX_INPUT_INTERRUPTS = 8;
|
|
35
|
+
export const HARD_MAX_INPUT_INTERRUPTS = 64;
|
|
36
|
+
export const DEFAULT_MAX_INPUT_MEDIA_PARTS = 16;
|
|
37
|
+
export const HARD_MAX_INPUT_MEDIA_PARTS = 64;
|
|
38
|
+
export const DEFAULT_MAX_INPUT_MEDIA_BYTES = 64 * 1024;
|
|
39
|
+
export const HARD_MAX_INPUT_MEDIA_BYTES = 1024 * 1024;
|
|
40
|
+
export const DEFAULT_MAX_INPUT_TOOL_BYTES = 16 * 1024;
|
|
41
|
+
export const HARD_MAX_INPUT_TOOL_BYTES = 256 * 1024;
|
|
42
|
+
export const DEFAULT_MAX_INPUT_CONTEXT_BYTES = 16 * 1024;
|
|
43
|
+
export const HARD_MAX_INPUT_CONTEXT_BYTES = 256 * 1024;
|
|
44
|
+
export const DEFAULT_MAX_STATE_BYTES = 64 * 1024;
|
|
45
|
+
export const HARD_MAX_STATE_BYTES = 1024 * 1024;
|
|
46
|
+
export const DEFAULT_MAX_PATCH_OPERATIONS = 128;
|
|
47
|
+
export const HARD_MAX_PATCH_OPERATIONS = 4096;
|
|
48
|
+
export const DEFAULT_MAX_ACTIVITY_BYTES = 64 * 1024;
|
|
49
|
+
export const HARD_MAX_ACTIVITY_BYTES = 1024 * 1024;
|
|
50
|
+
export const DEFAULT_MAX_REASONING_BYTES = 64 * 1024;
|
|
51
|
+
export const HARD_MAX_REASONING_BYTES = 1024 * 1024;
|
|
52
|
+
export const DEFAULT_MAX_RAW_EVENT_BYTES = 64 * 1024;
|
|
53
|
+
export const HARD_MAX_RAW_EVENT_BYTES = 1024 * 1024;
|
|
54
|
+
export const DEFAULT_MAX_JSON_DEPTH = 16;
|
|
55
|
+
export const HARD_MAX_JSON_DEPTH = 64;
|
|
56
|
+
export const DEFAULT_MAX_JSON_PROPERTIES = 128;
|
|
57
|
+
export const HARD_MAX_JSON_PROPERTIES = 4096;
|
|
58
|
+
export const DEFAULT_MAX_JSON_ARRAY_ITEMS = 512;
|
|
59
|
+
export const HARD_MAX_JSON_ARRAY_ITEMS = 8192;
|
|
60
|
+
|
|
61
|
+
/** Phase 10 frozen ACP session-lifecycle caps (scripts/phase10-freeze-manifest.json caps.acp). */
|
|
62
|
+
export const DEFAULT_MAX_ACP_SESSIONS = 32;
|
|
63
|
+
export const HARD_MAX_ACP_SESSIONS = 128;
|
|
64
|
+
export const DEFAULT_MAX_ACP_ADDITIONAL_DIRECTORIES = 8;
|
|
65
|
+
export const HARD_MAX_ACP_ADDITIONAL_DIRECTORIES = 32;
|
|
66
|
+
export const DEFAULT_MAX_ACP_ADDITIONAL_DIRECTORY_PATH_BYTES = 4 * 1024;
|
|
67
|
+
export const HARD_MAX_ACP_ADDITIONAL_DIRECTORY_PATH_BYTES = 16 * 1024;
|
|
68
|
+
export const DEFAULT_MAX_ACP_MCP_SERVERS_PER_SESSION = 8;
|
|
69
|
+
export const HARD_MAX_ACP_MCP_SERVERS_PER_SESSION = 32;
|
|
70
|
+
export const DEFAULT_MAX_ACP_MCP_SERVER_CONFIG_BYTES = 16 * 1024;
|
|
71
|
+
export const HARD_MAX_ACP_MCP_SERVER_CONFIG_BYTES = 256 * 1024;
|
|
72
|
+
export const DEFAULT_MAX_ACP_MCP_HEADER_VALUE_BYTES = 4 * 1024;
|
|
73
|
+
export const HARD_MAX_ACP_MCP_HEADER_VALUE_BYTES = 64 * 1024;
|
|
74
|
+
export const DEFAULT_MAX_ACP_SESSION_LIST_PAGE = 20;
|
|
75
|
+
export const HARD_MAX_ACP_SESSION_LIST_PAGE = 100;
|
|
76
|
+
export const DEFAULT_MAX_ACP_MODES_PER_SESSION = 16;
|
|
77
|
+
export const HARD_MAX_ACP_MODES_PER_SESSION = 64;
|
|
78
|
+
export const DEFAULT_MAX_ACP_CONFIG_OPTIONS = 16;
|
|
79
|
+
export const HARD_MAX_ACP_CONFIG_OPTIONS = 64;
|
|
80
|
+
export const DEFAULT_MAX_ACP_DIFF_BYTES = 64 * 1024;
|
|
81
|
+
export const HARD_MAX_ACP_DIFF_BYTES = 1024 * 1024;
|
|
82
|
+
export const DEFAULT_MAX_ACP_LOCATIONS_PER_UPDATE = 32;
|
|
83
|
+
export const HARD_MAX_ACP_LOCATIONS_PER_UPDATE = 128;
|
|
84
|
+
export const DEFAULT_MAX_ACP_IMAGE_BYTES = 256 * 1024;
|
|
85
|
+
export const HARD_MAX_ACP_IMAGE_BYTES = 1024 * 1024;
|
|
86
|
+
export const DEFAULT_MAX_ACP_COMMANDS_PER_UPDATE = 32;
|
|
87
|
+
export const HARD_MAX_ACP_COMMANDS_PER_UPDATE = 128;
|
|
88
|
+
|
|
89
|
+
export interface AgUiLimitOptions {
|
|
90
|
+
readonly maxEventBytes?: number;
|
|
91
|
+
readonly maxTextBytes?: number;
|
|
92
|
+
readonly maxErrorBytes?: number;
|
|
93
|
+
readonly maxRequestBytes?: number;
|
|
94
|
+
readonly maxInputMessages?: number;
|
|
95
|
+
readonly maxInputTextBytes?: number;
|
|
96
|
+
readonly maxCursorBytes?: number;
|
|
97
|
+
readonly maxReplayEvents?: number;
|
|
98
|
+
readonly maxStreamEvents?: number;
|
|
99
|
+
readonly maxStreamBytes?: number;
|
|
100
|
+
readonly maxQueuedEvents?: number;
|
|
101
|
+
readonly requestTimeoutMs?: number;
|
|
102
|
+
readonly maxInputTools?: number;
|
|
103
|
+
readonly maxInputContexts?: number;
|
|
104
|
+
readonly maxInputInterrupts?: number;
|
|
105
|
+
readonly maxInputMediaParts?: number;
|
|
106
|
+
readonly maxInputMediaBytes?: number;
|
|
107
|
+
readonly maxInputToolBytes?: number;
|
|
108
|
+
readonly maxInputContextBytes?: number;
|
|
109
|
+
readonly maxStateBytes?: number;
|
|
110
|
+
readonly maxPatchOperations?: number;
|
|
111
|
+
readonly maxActivityBytes?: number;
|
|
112
|
+
readonly maxReasoningBytes?: number;
|
|
113
|
+
readonly maxRawEventBytes?: number;
|
|
114
|
+
readonly maxJsonDepth?: number;
|
|
115
|
+
readonly maxJsonProperties?: number;
|
|
116
|
+
readonly maxJsonArrayItems?: number;
|
|
117
|
+
/** ACP in-memory session registry bound (acp.sessions). */
|
|
118
|
+
readonly acpSessions?: number;
|
|
119
|
+
readonly acpAdditionalDirectories?: number;
|
|
120
|
+
readonly acpAdditionalDirectoryPathBytes?: number;
|
|
121
|
+
readonly acpMcpServersPerSession?: number;
|
|
122
|
+
readonly acpMcpServerConfigBytes?: number;
|
|
123
|
+
readonly acpMcpHeaderValueBytes?: number;
|
|
124
|
+
readonly acpSessionListPage?: number;
|
|
125
|
+
readonly acpModesPerSession?: number;
|
|
126
|
+
readonly acpConfigOptions?: number;
|
|
127
|
+
readonly acpDiffBytes?: number;
|
|
128
|
+
readonly acpLocationsPerUpdate?: number;
|
|
129
|
+
readonly acpImageBytes?: number;
|
|
130
|
+
readonly acpCommandsPerUpdate?: number;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
export interface ResolvedAgUiLimits {
|
|
134
|
+
readonly maxEventBytes: number;
|
|
135
|
+
readonly maxTextBytes: number;
|
|
136
|
+
readonly maxErrorBytes: number;
|
|
137
|
+
readonly maxRequestBytes: number;
|
|
138
|
+
readonly maxInputMessages: number;
|
|
139
|
+
readonly maxInputTextBytes: number;
|
|
140
|
+
readonly maxCursorBytes: number;
|
|
141
|
+
readonly maxReplayEvents: number;
|
|
142
|
+
readonly maxStreamEvents: number;
|
|
143
|
+
readonly maxStreamBytes: number;
|
|
144
|
+
readonly maxQueuedEvents: number;
|
|
145
|
+
readonly requestTimeoutMs: number;
|
|
146
|
+
readonly maxInputTools: number;
|
|
147
|
+
readonly maxInputContexts: number;
|
|
148
|
+
readonly maxInputInterrupts: number;
|
|
149
|
+
readonly maxInputMediaParts: number;
|
|
150
|
+
readonly maxInputMediaBytes: number;
|
|
151
|
+
readonly maxInputToolBytes: number;
|
|
152
|
+
readonly maxInputContextBytes: number;
|
|
153
|
+
readonly maxStateBytes: number;
|
|
154
|
+
readonly maxPatchOperations: number;
|
|
155
|
+
readonly maxActivityBytes: number;
|
|
156
|
+
readonly maxReasoningBytes: number;
|
|
157
|
+
readonly maxRawEventBytes: number;
|
|
158
|
+
readonly maxJsonDepth: number;
|
|
159
|
+
readonly maxJsonProperties: number;
|
|
160
|
+
readonly maxJsonArrayItems: number;
|
|
161
|
+
readonly acpSessions: number;
|
|
162
|
+
readonly acpAdditionalDirectories: number;
|
|
163
|
+
readonly acpAdditionalDirectoryPathBytes: number;
|
|
164
|
+
readonly acpMcpServersPerSession: number;
|
|
165
|
+
readonly acpMcpServerConfigBytes: number;
|
|
166
|
+
readonly acpMcpHeaderValueBytes: number;
|
|
167
|
+
readonly acpSessionListPage: number;
|
|
168
|
+
readonly acpModesPerSession: number;
|
|
169
|
+
readonly acpConfigOptions: number;
|
|
170
|
+
readonly acpDiffBytes: number;
|
|
171
|
+
readonly acpLocationsPerUpdate: number;
|
|
172
|
+
readonly acpImageBytes: number;
|
|
173
|
+
readonly acpCommandsPerUpdate: number;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
export const DEFAULT_AG_UI_LIMITS: ResolvedAgUiLimits = {
|
|
177
|
+
maxEventBytes: DEFAULT_MAX_EVENT_BYTES,
|
|
178
|
+
maxTextBytes: DEFAULT_MAX_TEXT_BYTES,
|
|
179
|
+
maxErrorBytes: DEFAULT_MAX_ERROR_BYTES,
|
|
180
|
+
maxRequestBytes: DEFAULT_MAX_REQUEST_BYTES,
|
|
181
|
+
maxInputMessages: DEFAULT_MAX_INPUT_MESSAGES,
|
|
182
|
+
maxInputTextBytes: DEFAULT_MAX_INPUT_TEXT_BYTES,
|
|
183
|
+
maxCursorBytes: DEFAULT_MAX_CURSOR_BYTES,
|
|
184
|
+
maxReplayEvents: DEFAULT_MAX_REPLAY_EVENTS,
|
|
185
|
+
maxStreamEvents: DEFAULT_MAX_STREAM_EVENTS,
|
|
186
|
+
maxStreamBytes: DEFAULT_MAX_STREAM_BYTES,
|
|
187
|
+
maxQueuedEvents: DEFAULT_MAX_QUEUED_EVENTS,
|
|
188
|
+
requestTimeoutMs: DEFAULT_REQUEST_TIMEOUT_MS,
|
|
189
|
+
maxInputTools: DEFAULT_MAX_INPUT_TOOLS,
|
|
190
|
+
maxInputContexts: DEFAULT_MAX_INPUT_CONTEXTS,
|
|
191
|
+
maxInputInterrupts: DEFAULT_MAX_INPUT_INTERRUPTS,
|
|
192
|
+
maxInputMediaParts: DEFAULT_MAX_INPUT_MEDIA_PARTS,
|
|
193
|
+
maxInputMediaBytes: DEFAULT_MAX_INPUT_MEDIA_BYTES,
|
|
194
|
+
maxInputToolBytes: DEFAULT_MAX_INPUT_TOOL_BYTES,
|
|
195
|
+
maxInputContextBytes: DEFAULT_MAX_INPUT_CONTEXT_BYTES,
|
|
196
|
+
maxStateBytes: DEFAULT_MAX_STATE_BYTES,
|
|
197
|
+
maxPatchOperations: DEFAULT_MAX_PATCH_OPERATIONS,
|
|
198
|
+
maxActivityBytes: DEFAULT_MAX_ACTIVITY_BYTES,
|
|
199
|
+
maxReasoningBytes: DEFAULT_MAX_REASONING_BYTES,
|
|
200
|
+
maxRawEventBytes: DEFAULT_MAX_RAW_EVENT_BYTES,
|
|
201
|
+
maxJsonDepth: DEFAULT_MAX_JSON_DEPTH,
|
|
202
|
+
maxJsonProperties: DEFAULT_MAX_JSON_PROPERTIES,
|
|
203
|
+
maxJsonArrayItems: DEFAULT_MAX_JSON_ARRAY_ITEMS,
|
|
204
|
+
acpSessions: DEFAULT_MAX_ACP_SESSIONS,
|
|
205
|
+
acpAdditionalDirectories: DEFAULT_MAX_ACP_ADDITIONAL_DIRECTORIES,
|
|
206
|
+
acpAdditionalDirectoryPathBytes: DEFAULT_MAX_ACP_ADDITIONAL_DIRECTORY_PATH_BYTES,
|
|
207
|
+
acpMcpServersPerSession: DEFAULT_MAX_ACP_MCP_SERVERS_PER_SESSION,
|
|
208
|
+
acpMcpServerConfigBytes: DEFAULT_MAX_ACP_MCP_SERVER_CONFIG_BYTES,
|
|
209
|
+
acpMcpHeaderValueBytes: DEFAULT_MAX_ACP_MCP_HEADER_VALUE_BYTES,
|
|
210
|
+
acpSessionListPage: DEFAULT_MAX_ACP_SESSION_LIST_PAGE,
|
|
211
|
+
acpModesPerSession: DEFAULT_MAX_ACP_MODES_PER_SESSION,
|
|
212
|
+
acpConfigOptions: DEFAULT_MAX_ACP_CONFIG_OPTIONS,
|
|
213
|
+
acpDiffBytes: DEFAULT_MAX_ACP_DIFF_BYTES,
|
|
214
|
+
acpLocationsPerUpdate: DEFAULT_MAX_ACP_LOCATIONS_PER_UPDATE,
|
|
215
|
+
acpImageBytes: DEFAULT_MAX_ACP_IMAGE_BYTES,
|
|
216
|
+
acpCommandsPerUpdate: DEFAULT_MAX_ACP_COMMANDS_PER_UPDATE,
|
|
217
|
+
};
|
|
218
|
+
|
|
219
|
+
export const HARD_AG_UI_LIMITS: ResolvedAgUiLimits = {
|
|
220
|
+
maxEventBytes: HARD_MAX_EVENT_BYTES,
|
|
221
|
+
maxTextBytes: HARD_MAX_TEXT_BYTES,
|
|
222
|
+
maxErrorBytes: HARD_MAX_ERROR_BYTES,
|
|
223
|
+
maxRequestBytes: HARD_MAX_REQUEST_BYTES,
|
|
224
|
+
maxInputMessages: HARD_MAX_INPUT_MESSAGES,
|
|
225
|
+
maxInputTextBytes: HARD_MAX_INPUT_TEXT_BYTES,
|
|
226
|
+
maxCursorBytes: HARD_MAX_CURSOR_BYTES,
|
|
227
|
+
maxReplayEvents: HARD_MAX_REPLAY_EVENTS,
|
|
228
|
+
maxStreamEvents: HARD_MAX_STREAM_EVENTS,
|
|
229
|
+
maxStreamBytes: HARD_MAX_STREAM_BYTES,
|
|
230
|
+
maxQueuedEvents: HARD_MAX_QUEUED_EVENTS,
|
|
231
|
+
requestTimeoutMs: HARD_REQUEST_TIMEOUT_MS,
|
|
232
|
+
maxInputTools: HARD_MAX_INPUT_TOOLS,
|
|
233
|
+
maxInputContexts: HARD_MAX_INPUT_CONTEXTS,
|
|
234
|
+
maxInputInterrupts: HARD_MAX_INPUT_INTERRUPTS,
|
|
235
|
+
maxInputMediaParts: HARD_MAX_INPUT_MEDIA_PARTS,
|
|
236
|
+
maxInputMediaBytes: HARD_MAX_INPUT_MEDIA_BYTES,
|
|
237
|
+
maxInputToolBytes: HARD_MAX_INPUT_TOOL_BYTES,
|
|
238
|
+
maxInputContextBytes: HARD_MAX_INPUT_CONTEXT_BYTES,
|
|
239
|
+
maxStateBytes: HARD_MAX_STATE_BYTES,
|
|
240
|
+
maxPatchOperations: HARD_MAX_PATCH_OPERATIONS,
|
|
241
|
+
maxActivityBytes: HARD_MAX_ACTIVITY_BYTES,
|
|
242
|
+
maxReasoningBytes: HARD_MAX_REASONING_BYTES,
|
|
243
|
+
maxRawEventBytes: HARD_MAX_RAW_EVENT_BYTES,
|
|
244
|
+
maxJsonDepth: HARD_MAX_JSON_DEPTH,
|
|
245
|
+
maxJsonProperties: HARD_MAX_JSON_PROPERTIES,
|
|
246
|
+
maxJsonArrayItems: HARD_MAX_JSON_ARRAY_ITEMS,
|
|
247
|
+
acpSessions: HARD_MAX_ACP_SESSIONS,
|
|
248
|
+
acpAdditionalDirectories: HARD_MAX_ACP_ADDITIONAL_DIRECTORIES,
|
|
249
|
+
acpAdditionalDirectoryPathBytes: HARD_MAX_ACP_ADDITIONAL_DIRECTORY_PATH_BYTES,
|
|
250
|
+
acpMcpServersPerSession: HARD_MAX_ACP_MCP_SERVERS_PER_SESSION,
|
|
251
|
+
acpMcpServerConfigBytes: HARD_MAX_ACP_MCP_SERVER_CONFIG_BYTES,
|
|
252
|
+
acpMcpHeaderValueBytes: HARD_MAX_ACP_MCP_HEADER_VALUE_BYTES,
|
|
253
|
+
acpSessionListPage: HARD_MAX_ACP_SESSION_LIST_PAGE,
|
|
254
|
+
acpModesPerSession: HARD_MAX_ACP_MODES_PER_SESSION,
|
|
255
|
+
acpConfigOptions: HARD_MAX_ACP_CONFIG_OPTIONS,
|
|
256
|
+
acpDiffBytes: HARD_MAX_ACP_DIFF_BYTES,
|
|
257
|
+
acpLocationsPerUpdate: HARD_MAX_ACP_LOCATIONS_PER_UPDATE,
|
|
258
|
+
acpImageBytes: HARD_MAX_ACP_IMAGE_BYTES,
|
|
259
|
+
acpCommandsPerUpdate: HARD_MAX_ACP_COMMANDS_PER_UPDATE,
|
|
260
|
+
};
|
|
261
|
+
|
|
262
|
+
export function resolveAgUiLimits(options: AgUiLimitOptions = {}): ResolvedAgUiLimits {
|
|
263
|
+
return Object.fromEntries(
|
|
264
|
+
Object.entries(DEFAULT_AG_UI_LIMITS).map(([name, defaultValue]) => [
|
|
265
|
+
name,
|
|
266
|
+
validate(name as keyof ResolvedAgUiLimits, options[name as keyof AgUiLimitOptions] ?? defaultValue),
|
|
267
|
+
]),
|
|
268
|
+
) as unknown as ResolvedAgUiLimits;
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
function validate(name: keyof ResolvedAgUiLimits, value: number): number {
|
|
272
|
+
const hard = HARD_AG_UI_LIMITS[name];
|
|
273
|
+
const minimum =
|
|
274
|
+
name.endsWith("Bytes") || name === "requestTimeoutMs" ? (name === "maxTextBytes" || name === "maxErrorBytes" ? 16 : 1_024) : 1;
|
|
275
|
+
if (!Number.isSafeInteger(value) || value < minimum || value > hard) {
|
|
276
|
+
throw new AgUiError("ERR_PRISM_AG_UI_LIMIT", `${name} must be a safe integer from ${minimum} through ${hard}`);
|
|
277
|
+
}
|
|
278
|
+
return value;
|
|
279
|
+
}
|