@amalgm/chat 0.1.1 → 0.2.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/AGENTS.md +98 -0
- package/PURPOSE.md +143 -104
- package/README.md +82 -54
- package/dist/acp/index.d.ts +7 -0
- package/dist/acp/index.d.ts.map +1 -0
- package/dist/acp/index.js +7 -0
- package/dist/acp/index.js.map +1 -0
- package/dist/acp/projection.d.ts +30 -0
- package/dist/acp/projection.d.ts.map +1 -0
- package/dist/acp/projection.js +147 -0
- package/dist/acp/projection.js.map +1 -0
- package/dist/api/conversations.d.ts +66 -0
- package/dist/api/conversations.d.ts.map +1 -0
- package/dist/api/conversations.js +202 -0
- package/dist/api/conversations.js.map +1 -0
- package/dist/api/index.d.ts +3 -3
- package/dist/api/index.d.ts.map +1 -1
- package/dist/api/index.js +1 -2
- package/dist/api/index.js.map +1 -1
- package/dist/conversations/index.d.ts +3 -0
- package/dist/conversations/index.d.ts.map +1 -0
- package/dist/conversations/index.js +3 -0
- package/dist/conversations/index.js.map +1 -0
- package/dist/conversations/transcript.d.ts +13 -0
- package/dist/conversations/transcript.d.ts.map +1 -0
- package/dist/conversations/transcript.js +171 -0
- package/dist/conversations/transcript.js.map +1 -0
- package/dist/conversations/types.d.ts +147 -0
- package/dist/conversations/types.d.ts.map +1 -0
- package/dist/conversations/types.js +9 -0
- package/dist/conversations/types.js.map +1 -0
- package/dist/events/constructors.d.ts +9 -15
- package/dist/events/constructors.d.ts.map +1 -1
- package/dist/events/constructors.js +6 -12
- package/dist/events/constructors.js.map +1 -1
- package/dist/events/index.d.ts +2 -3
- package/dist/events/index.d.ts.map +1 -1
- package/dist/events/index.js +2 -3
- package/dist/events/index.js.map +1 -1
- package/dist/events/schema.d.ts +2 -5
- package/dist/events/schema.d.ts.map +1 -1
- package/dist/events/schema.js +2 -5
- package/dist/events/schema.js.map +1 -1
- package/dist/execution/contract.d.ts +51 -0
- package/dist/execution/contract.d.ts.map +1 -0
- package/dist/execution/contract.js +127 -0
- package/dist/execution/contract.js.map +1 -0
- package/dist/execution/index.d.ts +6 -0
- package/dist/execution/index.d.ts.map +1 -0
- package/dist/execution/index.js +4 -0
- package/dist/execution/index.js.map +1 -0
- package/dist/execution/revision.d.ts +5 -0
- package/dist/execution/revision.d.ts.map +1 -0
- package/dist/execution/revision.js +17 -0
- package/dist/execution/revision.js.map +1 -0
- package/dist/execution/store.d.ts +26 -0
- package/dist/execution/store.d.ts.map +1 -0
- package/dist/execution/store.js +38 -0
- package/dist/execution/store.js.map +1 -0
- package/dist/index.d.ts +8 -23
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +7 -23
- package/dist/index.js.map +1 -1
- package/dist/input/index.d.ts +3 -0
- package/dist/input/index.d.ts.map +1 -0
- package/dist/input/index.js +2 -0
- package/dist/input/index.js.map +1 -0
- package/dist/input/prompt.d.ts +17 -0
- package/dist/input/prompt.d.ts.map +1 -0
- package/dist/input/prompt.js +104 -0
- package/dist/input/prompt.js.map +1 -0
- package/dist/normalizers/claude.d.ts +6 -9
- package/dist/normalizers/claude.d.ts.map +1 -1
- package/dist/normalizers/claude.js +5 -8
- package/dist/normalizers/claude.js.map +1 -1
- package/dist/normalizers/codex.d.ts +5 -8
- package/dist/normalizers/codex.d.ts.map +1 -1
- package/dist/normalizers/codex.js +4 -7
- package/dist/normalizers/codex.js.map +1 -1
- package/dist/normalizers/cursor.d.ts +1 -2
- package/dist/normalizers/cursor.d.ts.map +1 -1
- package/dist/normalizers/cursor.js +2 -3
- package/dist/normalizers/cursor.js.map +1 -1
- package/dist/normalizers/index.d.ts +3 -5
- package/dist/normalizers/index.d.ts.map +1 -1
- package/dist/normalizers/index.js +3 -5
- package/dist/normalizers/index.js.map +1 -1
- package/dist/normalizers/opencode.d.ts +2 -4
- package/dist/normalizers/opencode.d.ts.map +1 -1
- package/dist/normalizers/opencode.js +2 -4
- package/dist/normalizers/opencode.js.map +1 -1
- package/dist/normalizers/pi.d.ts +3 -4
- package/dist/normalizers/pi.d.ts.map +1 -1
- package/dist/normalizers/pi.js +3 -4
- package/dist/normalizers/pi.js.map +1 -1
- package/dist/sessions/chat.d.ts +176 -0
- package/dist/sessions/chat.d.ts.map +1 -0
- package/dist/sessions/chat.js +701 -0
- package/dist/sessions/chat.js.map +1 -0
- package/dist/sessions/index.d.ts +3 -0
- package/dist/sessions/index.d.ts.map +1 -0
- package/dist/sessions/index.js +2 -0
- package/dist/sessions/index.js.map +1 -0
- package/dist/transcript/index.d.ts +1 -1
- package/dist/transcript/index.js +1 -1
- package/dist/transcript/message-reducer.d.ts +1 -1
- package/dist/transcript/message-reducer.js +1 -1
- package/dist/transcript/part-accumulator.d.ts +1 -1
- package/dist/transcript/part-accumulator.js +1 -1
- package/dist/transcript/tool-display.d.ts +1 -1
- package/dist/transcript/tool-display.js +1 -1
- package/dist/transcript/tool-shape.d.ts +1 -1
- package/dist/transcript/tool-shape.js +1 -1
- package/dist/usage/finalize.d.ts +7 -9
- package/dist/usage/finalize.d.ts.map +1 -1
- package/dist/usage/finalize.js +11 -13
- package/dist/usage/finalize.js.map +1 -1
- package/dist/usage/index.d.ts +2 -3
- package/dist/usage/index.d.ts.map +1 -1
- package/dist/usage/index.js +2 -3
- package/dist/usage/index.js.map +1 -1
- package/dist/usage/model-catalog.d.ts +2 -3
- package/dist/usage/model-catalog.d.ts.map +1 -1
- package/dist/usage/model-catalog.js +10 -3
- package/dist/usage/model-catalog.js.map +1 -1
- package/dist/usage/normalize.d.ts +5 -7
- package/dist/usage/normalize.d.ts.map +1 -1
- package/dist/usage/normalize.js +3 -5
- package/dist/usage/normalize.js.map +1 -1
- package/dist/usage/ports.d.ts +14 -24
- package/dist/usage/ports.d.ts.map +1 -1
- package/dist/usage/ports.js +9 -17
- package/dist/usage/ports.js.map +1 -1
- package/dist/usage/steps.d.ts +70 -0
- package/dist/usage/steps.d.ts.map +1 -0
- package/dist/usage/steps.js +152 -0
- package/dist/usage/steps.js.map +1 -0
- package/dist/usage/tokens.d.ts +4 -7
- package/dist/usage/tokens.d.ts.map +1 -1
- package/dist/usage/tokens.js +4 -7
- package/dist/usage/tokens.js.map +1 -1
- package/docs/contracts/acp-and-step-usage.md +51 -0
- package/docs/contracts/conversation-persistence.md +47 -0
- package/docs/contracts/input-and-execution.md +177 -0
- package/docs/contracts/platform-authorization.md +17 -0
- package/host/adapters/acp-capabilities.js +30 -0
- package/host/adapters/acp-client.js +156 -0
- package/host/adapters/acp.js +284 -0
- package/host/adapters/claude.js +235 -0
- package/host/adapters/codex.js +733 -0
- package/host/adapters/cursor.js +347 -0
- package/host/adapters/input-capabilities.js +89 -0
- package/host/adapters/opencode.js +486 -0
- package/host/adapters/pi.js +519 -0
- package/host/adapters/prompt.js +212 -0
- package/host/auth.js +257 -0
- package/host/credentials/store.js +209 -0
- package/host/http.d.ts +32 -0
- package/host/http.js +238 -0
- package/host/index.d.ts +84 -0
- package/host/index.js +59 -0
- package/host/lib/runtime-paths.js +44 -0
- package/host/model-resolution.js +313 -0
- package/host/native-contract.js +185 -0
- package/host/native-runtime.js +194 -0
- package/host/permissions.js +27 -0
- package/host/platform-egress.js +114 -0
- package/host/recorder.js +61 -0
- package/host/sqlite/index.d.ts +69 -0
- package/host/sqlite/index.js +704 -0
- package/host/tooling/mcp-bundle.js +214 -0
- package/host/tooling/mcp-relay.js +83 -0
- package/host/tooling/native-binaries.js +667 -0
- package/host/tooling/native-config.js +460 -0
- package/host/tooling/package-import.js +111 -0
- package/host/tooling/runtime-home.js +26 -0
- package/host/tooling/system-instructions.js +69 -0
- package/host/tooling/system-prompt.js +35 -0
- package/package.json +45 -21
- package/skills/chat/SKILL.md +97 -0
- package/skills/chat/agents/openai.yaml +4 -0
- package/skills/chat/references/contracts.md +131 -0
- package/dist/api/chat-payloads.d.ts +0 -10
- package/dist/api/chat-payloads.d.ts.map +0 -1
- package/dist/api/chat-payloads.js +0 -57
- package/dist/api/chat-payloads.js.map +0 -1
- package/dist/contract/chat-input.d.ts +0 -144
- package/dist/contract/chat-input.d.ts.map +0 -1
- package/dist/contract/chat-input.js +0 -261
- package/dist/contract/chat-input.js.map +0 -1
- package/dist/contract/create.d.ts +0 -191
- package/dist/contract/create.d.ts.map +0 -1
- package/dist/contract/create.js +0 -249
- package/dist/contract/create.js.map +0 -1
- package/dist/contract/freeze.d.ts +0 -85
- package/dist/contract/freeze.d.ts.map +0 -1
- package/dist/contract/freeze.js +0 -151
- package/dist/contract/freeze.js.map +0 -1
- package/dist/contract/harnesses.d.ts +0 -21
- package/dist/contract/harnesses.d.ts.map +0 -1
- package/dist/contract/harnesses.js +0 -39
- package/dist/contract/harnesses.js.map +0 -1
- package/dist/contract/index.d.ts +0 -17
- package/dist/contract/index.d.ts.map +0 -1
- package/dist/contract/index.js +0 -17
- package/dist/contract/index.js.map +0 -1
- package/dist/contract/input.d.ts +0 -45
- package/dist/contract/input.d.ts.map +0 -1
- package/dist/contract/input.js +0 -78
- package/dist/contract/input.js.map +0 -1
- package/dist/contract/models.d.ts +0 -57
- package/dist/contract/models.d.ts.map +0 -1
- package/dist/contract/models.js +0 -380
- package/dist/contract/models.js.map +0 -1
- package/dist/contract/payload-merge.d.ts +0 -76
- package/dist/contract/payload-merge.d.ts.map +0 -1
- package/dist/contract/payload-merge.js +0 -215
- package/dist/contract/payload-merge.js.map +0 -1
- package/dist/events/tool-display.d.ts +0 -22
- package/dist/events/tool-display.d.ts.map +0 -1
- package/dist/events/tool-display.js +0 -60
- package/dist/events/tool-display.js.map +0 -1
- package/dist/events/tool-shape.d.ts +0 -48
- package/dist/events/tool-shape.d.ts.map +0 -1
- package/dist/events/tool-shape.js +0 -225
- package/dist/events/tool-shape.js.map +0 -1
- package/dist/turns/index.d.ts +0 -11
- package/dist/turns/index.d.ts.map +0 -1
- package/dist/turns/index.js +0 -11
- package/dist/turns/index.js.map +0 -1
- package/dist/turns/queries.d.ts +0 -36
- package/dist/turns/queries.d.ts.map +0 -1
- package/dist/turns/queries.js +0 -37
- package/dist/turns/queries.js.map +0 -1
- package/dist/turns/replay.d.ts +0 -105
- package/dist/turns/replay.d.ts.map +0 -1
- package/dist/turns/replay.js +0 -163
- package/dist/turns/replay.js.map +0 -1
- package/dist/turns/status.d.ts +0 -49
- package/dist/turns/status.d.ts.map +0 -1
- package/dist/turns/status.js +0 -56
- package/dist/turns/status.js.map +0 -1
- package/dist/turns/turn-store.d.ts +0 -109
- package/dist/turns/turn-store.d.ts.map +0 -1
- package/dist/turns/turn-store.js +0 -169
- package/dist/turns/turn-store.js.map +0 -1
- package/dist/warm/client-cache.d.ts +0 -47
- package/dist/warm/client-cache.d.ts.map +0 -1
- package/dist/warm/client-cache.js +0 -48
- package/dist/warm/client-cache.js.map +0 -1
- package/dist/warm/envelope-cache.d.ts +0 -79
- package/dist/warm/envelope-cache.d.ts.map +0 -1
- package/dist/warm/envelope-cache.js +0 -85
- package/dist/warm/envelope-cache.js.map +0 -1
- package/dist/warm/index.d.ts +0 -18
- package/dist/warm/index.d.ts.map +0 -1
- package/dist/warm/index.js +0 -12
- package/dist/warm/index.js.map +0 -1
- package/dist/warm/payload.d.ts +0 -137
- package/dist/warm/payload.d.ts.map +0 -1
- package/dist/warm/payload.js +0 -112
- package/dist/warm/payload.js.map +0 -1
- package/dist/warm/revision.d.ts +0 -70
- package/dist/warm/revision.d.ts.map +0 -1
- package/dist/warm/revision.js +0 -63
- package/dist/warm/revision.js.map +0 -1
- package/dist/warm/store-policy.d.ts +0 -57
- package/dist/warm/store-policy.d.ts.map +0 -1
- package/dist/warm/store-policy.js +0 -89
- package/dist/warm/store-policy.js.map +0 -1
- package/dist/warm/store.d.ts +0 -42
- package/dist/warm/store.d.ts.map +0 -1
- package/dist/warm/store.js +0 -69
- package/dist/warm/store.js.map +0 -1
- package/dist/wire/frames.d.ts +0 -208
- package/dist/wire/frames.d.ts.map +0 -1
- package/dist/wire/frames.js +0 -245
- package/dist/wire/frames.js.map +0 -1
- package/dist/wire/index.d.ts +0 -7
- package/dist/wire/index.d.ts.map +0 -1
- package/dist/wire/index.js +0 -7
- package/dist/wire/index.js.map +0 -1
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@amalgm/chat",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "0.2.0",
|
|
4
|
+
"description": "A provider-agnostic agent chat SDK with ACP content, prepared execution, normalized streams, and usage.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "UNLICENSED",
|
|
7
7
|
"repository": {
|
|
@@ -20,26 +20,10 @@
|
|
|
20
20
|
"types": "./dist/events/index.d.ts",
|
|
21
21
|
"default": "./dist/events/index.js"
|
|
22
22
|
},
|
|
23
|
-
"./wire": {
|
|
24
|
-
"types": "./dist/wire/index.d.ts",
|
|
25
|
-
"default": "./dist/wire/index.js"
|
|
26
|
-
},
|
|
27
23
|
"./transcript": {
|
|
28
24
|
"types": "./dist/transcript/index.d.ts",
|
|
29
25
|
"default": "./dist/transcript/index.js"
|
|
30
26
|
},
|
|
31
|
-
"./turns": {
|
|
32
|
-
"types": "./dist/turns/index.d.ts",
|
|
33
|
-
"default": "./dist/turns/index.js"
|
|
34
|
-
},
|
|
35
|
-
"./contract": {
|
|
36
|
-
"types": "./dist/contract/index.d.ts",
|
|
37
|
-
"default": "./dist/contract/index.js"
|
|
38
|
-
},
|
|
39
|
-
"./warm": {
|
|
40
|
-
"types": "./dist/warm/index.d.ts",
|
|
41
|
-
"default": "./dist/warm/index.js"
|
|
42
|
-
},
|
|
43
27
|
"./usage": {
|
|
44
28
|
"types": "./dist/usage/index.d.ts",
|
|
45
29
|
"default": "./dist/usage/index.js"
|
|
@@ -51,26 +35,66 @@
|
|
|
51
35
|
"./api": {
|
|
52
36
|
"types": "./dist/api/index.d.ts",
|
|
53
37
|
"default": "./dist/api/index.js"
|
|
38
|
+
},
|
|
39
|
+
"./acp": {
|
|
40
|
+
"types": "./dist/acp/index.d.ts",
|
|
41
|
+
"default": "./dist/acp/index.js"
|
|
42
|
+
},
|
|
43
|
+
"./input": {
|
|
44
|
+
"types": "./dist/input/index.d.ts",
|
|
45
|
+
"default": "./dist/input/index.js"
|
|
46
|
+
},
|
|
47
|
+
"./execution": {
|
|
48
|
+
"types": "./dist/execution/index.d.ts",
|
|
49
|
+
"default": "./dist/execution/index.js"
|
|
50
|
+
},
|
|
51
|
+
"./sessions": {
|
|
52
|
+
"types": "./dist/sessions/index.d.ts",
|
|
53
|
+
"default": "./dist/sessions/index.js"
|
|
54
|
+
},
|
|
55
|
+
"./conversations": {
|
|
56
|
+
"types": "./dist/conversations/index.d.ts",
|
|
57
|
+
"default": "./dist/conversations/index.js"
|
|
58
|
+
},
|
|
59
|
+
"./sqlite": {
|
|
60
|
+
"types": "./host/sqlite/index.d.ts",
|
|
61
|
+
"default": "./host/sqlite/index.js"
|
|
62
|
+
},
|
|
63
|
+
"./host": {
|
|
64
|
+
"types": "./host/index.d.ts",
|
|
65
|
+
"default": "./host/index.js"
|
|
54
66
|
}
|
|
55
67
|
},
|
|
56
68
|
"files": [
|
|
57
69
|
"dist",
|
|
58
|
-
"
|
|
70
|
+
"AGENTS.md",
|
|
71
|
+
"PURPOSE.md",
|
|
72
|
+
"docs/contracts/acp-and-step-usage.md",
|
|
73
|
+
"docs/contracts/input-and-execution.md",
|
|
74
|
+
"docs/contracts/conversation-persistence.md",
|
|
75
|
+
"docs/contracts/platform-authorization.md",
|
|
76
|
+
"host",
|
|
77
|
+
"skills"
|
|
59
78
|
],
|
|
60
79
|
"engines": {
|
|
61
|
-
"node": ">=
|
|
80
|
+
"node": ">=20"
|
|
62
81
|
},
|
|
63
82
|
"scripts": {
|
|
64
|
-
"build": "tsc -p tsconfig.json",
|
|
83
|
+
"build": "node scripts/clean-dist.mjs && tsc -p tsconfig.json",
|
|
65
84
|
"test": "npm run build && node --test tests/",
|
|
66
85
|
"test:parity": "npm run build && node --test tests/parity/"
|
|
67
86
|
},
|
|
68
87
|
"dependencies": {
|
|
88
|
+
"@agentclientprotocol/sdk": "^1.4.0",
|
|
69
89
|
"@anthropic-ai/claude-agent-sdk": "^0.3.206",
|
|
90
|
+
"@modelcontextprotocol/sdk": "^1.30.0",
|
|
91
|
+
"@openai/codex": "0.150.0",
|
|
70
92
|
"@opencode-ai/sdk": "^1.17.6",
|
|
93
|
+
"better-sqlite3": "^12.11.1",
|
|
71
94
|
"zod": "^4.4.3"
|
|
72
95
|
},
|
|
73
96
|
"devDependencies": {
|
|
97
|
+
"@types/better-sqlite3": "^7.6.13",
|
|
74
98
|
"typescript": "^5.7.3"
|
|
75
99
|
}
|
|
76
100
|
}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: chat
|
|
3
|
+
description: Build and verify provider-agnostic agent chat with the Amalgm Chat SDK. Use for chat interfaces, ACP prompt and update shapes, prepared execution, SQLite conversations, durable streams, Claude Code, Codex, Cursor, OpenCode, Pi, MCP tools, permissions, model-step usage, reconnect, or adapter conformance.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Build with Amalgm Chat
|
|
7
|
+
|
|
8
|
+
Keep application code on the public SDK. Keep native behavior in host adapters.
|
|
9
|
+
|
|
10
|
+
## Establish the contract
|
|
11
|
+
|
|
12
|
+
Read [references/contracts.md](references/contracts.md) before changing input,
|
|
13
|
+
execution preparation, sessions, adapters, or usage. In a source checkout, also
|
|
14
|
+
read the repository `AGENTS.md`; it contains current architecture and known gaps.
|
|
15
|
+
|
|
16
|
+
Use these package doors:
|
|
17
|
+
|
|
18
|
+
- `@amalgm/chat` or `/sessions` for `Chat`, start, resume, and send;
|
|
19
|
+
- `/input` for ordered ACP prompt content;
|
|
20
|
+
- `/execution` for prepared execution contracts and handles;
|
|
21
|
+
- `/acp` for official ACP types and session updates;
|
|
22
|
+
- `/usage` for model-step usage and turn aggregation.
|
|
23
|
+
- `/conversations` for owner-scoped records and UI projections;
|
|
24
|
+
- `/sqlite` for the WAL-backed reference conversation store.
|
|
25
|
+
|
|
26
|
+
Do not copy ACP types into application code.
|
|
27
|
+
|
|
28
|
+
## Follow the user path
|
|
29
|
+
|
|
30
|
+
1. Prepare while the user composes. Resolve the exact agent revision, provider-
|
|
31
|
+
scoped model, model settings, auth binding, tool revision, cwd, permission
|
|
32
|
+
mode, and computer.
|
|
33
|
+
2. Start or resume with the returned `{ id, revision }` handle.
|
|
34
|
+
3. Send an ordered ACP prompt with that handle.
|
|
35
|
+
4. Render official ACP updates without provider branches.
|
|
36
|
+
5. Treat `send()` as one background runtime pump and its returned iterable as
|
|
37
|
+
a subscriber. Reconnect by turn id and committed sequence.
|
|
38
|
+
|
|
39
|
+
Never fetch models, credentials, tools, preferences, agent configuration, or a
|
|
40
|
+
workspace because the user pressed Enter. A missing or stale prepared revision
|
|
41
|
+
must fail explicitly.
|
|
42
|
+
|
|
43
|
+
## Preserve semantics
|
|
44
|
+
|
|
45
|
+
- Pass text and attachments as ACP content blocks. Never flatten or discard an
|
|
46
|
+
attachment. Translate it natively or return a typed unsupported-capability
|
|
47
|
+
result.
|
|
48
|
+
- Treat model identity as `(agent revision, provider, model)`.
|
|
49
|
+
- Treat auth and computer as per-turn selections. Never silently fall back to a
|
|
50
|
+
different auth mode.
|
|
51
|
+
- Expose ordinary tools and MCP tools through one MCP-shaped capability model.
|
|
52
|
+
The resolved selection is complete; never add an ambient MCP server.
|
|
53
|
+
- Use the five native adapters for Claude Code, Codex, Cursor, OpenCode, and Pi.
|
|
54
|
+
Register every other compliant agent through the generic `acp` adapter and
|
|
55
|
+
an immutable launch descriptor; do not add product-name branches for Amp,
|
|
56
|
+
Gemini CLI, Kiro, or later ACP agents.
|
|
57
|
+
- Require every adapter to apply an input exactly or throw a typed unsupported
|
|
58
|
+
error before prompting. Capability negotiation is validation, not fallback.
|
|
59
|
+
- Render `agent_message_chunk`, `agent_thought_chunk`, `tool_call`, and
|
|
60
|
+
`tool_call_update`. Use ACP tool states.
|
|
61
|
+
- Use `@amalgm/stream` for rendering only; it is not the durable journal.
|
|
62
|
+
- Persist accepted input before provider invocation. Commit every update before
|
|
63
|
+
fanout, seal terminal state once, and recover uncertain running turns as
|
|
64
|
+
interrupted after restart.
|
|
65
|
+
- Use bounded SQLite batches for content deltas. Tool, terminal, permission,
|
|
66
|
+
warning, and other control updates flush immediately.
|
|
67
|
+
- Never sync a live SQLite file. Live synchronizes logical conversation rows,
|
|
68
|
+
sealed turns, update batches, messages, and provider checkpoints.
|
|
69
|
+
|
|
70
|
+
## Normalize usage honestly
|
|
71
|
+
|
|
72
|
+
Create one finalized usage record per provider model invocation. Keep input,
|
|
73
|
+
output, cache-read, and cache-write tokens nullable. Derive turn usage from its
|
|
74
|
+
steps. Preserve the raw provider record. Never use ACP context fullness as a
|
|
75
|
+
billing ledger or turn missing values into zero.
|
|
76
|
+
|
|
77
|
+
## Verify through real sessions
|
|
78
|
+
|
|
79
|
+
Test laws with fixtures, then start a real session through `Chat`; do not stop at
|
|
80
|
+
calling an adapter helper. For every claimed adapter, verify start/resume, text
|
|
81
|
+
and supported attachments, tools, permissions, normalized updates, terminal
|
|
82
|
+
state, and usage. Record unsupported capabilities literally.
|
|
83
|
+
|
|
84
|
+
Use the adapter capability matrix and generic ACP launch shape in
|
|
85
|
+
[references/contracts.md](references/contracts.md). A generic ACP conformance
|
|
86
|
+
run does not prove that every named ACP product is installed or authenticated;
|
|
87
|
+
record each product acceptance separately.
|
|
88
|
+
|
|
89
|
+
Run:
|
|
90
|
+
|
|
91
|
+
```bash
|
|
92
|
+
npm test
|
|
93
|
+
npm pack --dry-run
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
Do not claim parity from one successful provider. Record current limitations in
|
|
97
|
+
`PURPOSE.md` or the owning contract document.
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
# Chat SDK contract
|
|
2
|
+
|
|
3
|
+
Load this reference when building a chat surface or changing a provider adapter.
|
|
4
|
+
|
|
5
|
+
## Prompt
|
|
6
|
+
|
|
7
|
+
```ts
|
|
8
|
+
type PromptInput = {
|
|
9
|
+
parts: ContentBlock[]; // official ACP ContentBlock
|
|
10
|
+
};
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
The list is non-empty and ordered. Attachments are ACP `image`, `audio`,
|
|
14
|
+
`resource`, or `resource_link` blocks. The host must prepare bytes or references
|
|
15
|
+
before send.
|
|
16
|
+
|
|
17
|
+
## Prepared execution
|
|
18
|
+
|
|
19
|
+
```ts
|
|
20
|
+
type ExecutionContract = {
|
|
21
|
+
agent: { adapterId: string; installationId: string; revisionId: string };
|
|
22
|
+
model: {
|
|
23
|
+
providerId: string;
|
|
24
|
+
modelId: string;
|
|
25
|
+
settings: SetSessionConfigOptionRequest[];
|
|
26
|
+
};
|
|
27
|
+
auth: { mode: "platform" | "subscription" | "byok"; bindingId: string };
|
|
28
|
+
tools: { revisionId: string | null; toolIds: string[] };
|
|
29
|
+
cwd: {
|
|
30
|
+
path: string;
|
|
31
|
+
workspaceId: string | null;
|
|
32
|
+
materializationRevision: string | null;
|
|
33
|
+
};
|
|
34
|
+
permissionMode: "ask" | "full_access";
|
|
35
|
+
computerId: string;
|
|
36
|
+
};
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
Preparation resolves this to an opaque host binding and returns an
|
|
40
|
+
`ExecutionHandle` containing only `id` and `revision`. Any changed field creates
|
|
41
|
+
a new revision. Start and send consume a prepared handle; they never prepare.
|
|
42
|
+
|
|
43
|
+
## Session path
|
|
44
|
+
|
|
45
|
+
```ts
|
|
46
|
+
const execution = await chat.prepareExecution("composer", contract);
|
|
47
|
+
const session = await chat.startSession({ execution });
|
|
48
|
+
|
|
49
|
+
for await (const update of await session.send({
|
|
50
|
+
execution,
|
|
51
|
+
prompt: { parts: [{ type: "text", text: "Hello" }] },
|
|
52
|
+
})) {
|
|
53
|
+
render(update);
|
|
54
|
+
}
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
Construct `Chat` with the authenticated `ownerUserId`, a
|
|
58
|
+
`ConversationStorePort`, and a host clock. Production hosts should use
|
|
59
|
+
`SqliteConversationStore` from `@amalgm/chat/sqlite` plus
|
|
60
|
+
`createSqliteJournalBatchPolicy()`.
|
|
61
|
+
|
|
62
|
+
`send()` begins one background provider pump after the input transaction
|
|
63
|
+
commits. Iterating its result subscribes to the durable turn; it does not own
|
|
64
|
+
provider execution. Reconnect with `session.reconnect(turnId, {
|
|
65
|
+
afterSequence })`. Every yielded update carries
|
|
66
|
+
`_meta.amalgm.{conversationId,turnId,sequence}`.
|
|
67
|
+
|
|
68
|
+
On startup call `chat.recoverInterruptedTurns()` before admitting new work.
|
|
69
|
+
Committed updates remain replayable. Running turns become `interrupted` unless
|
|
70
|
+
an adapter later supplies a proven reattachment path.
|
|
71
|
+
|
|
72
|
+
Use `chat.resumeSession({ sessionId, execution })` for an existing conversation.
|
|
73
|
+
The conversation identity survives an explicit auth or computer change between
|
|
74
|
+
turns. The adapter may need a different native provider session.
|
|
75
|
+
|
|
76
|
+
## Adapter admission and exact inputs
|
|
77
|
+
|
|
78
|
+
The adapter ids are `claude_code`, `codex`, `cursor`, `opencode`, `pi`, and
|
|
79
|
+
`acp`. The first five are native adapters. The final path admits any
|
|
80
|
+
compliant ACP agent from its resolved immutable revision:
|
|
81
|
+
|
|
82
|
+
```ts
|
|
83
|
+
acpLaunch: {
|
|
84
|
+
command: string;
|
|
85
|
+
args: string[];
|
|
86
|
+
supportedAuthModes: AuthMode[];
|
|
87
|
+
env?: Record<string, string>;
|
|
88
|
+
auth?: {
|
|
89
|
+
platform?: { tokenEnv: string; baseUrlEnv?: string };
|
|
90
|
+
byok?: { tokenEnv: string; baseUrlEnv?: string };
|
|
91
|
+
};
|
|
92
|
+
authMethodIds?: Partial<Record<AuthMode, string>>;
|
|
93
|
+
modelConfiguredAtLaunch?: boolean;
|
|
94
|
+
}
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
| Adapter | Auth | Settings |
|
|
98
|
+
| --- | --- | --- |
|
|
99
|
+
| Claude Code | platform, subscription, BYOK | reasoning, speed |
|
|
100
|
+
| Codex | platform, subscription, BYOK | reasoning, speed |
|
|
101
|
+
| Cursor | subscription, BYOK Cursor API key | advertised model's exact reasoning/speed parameters |
|
|
102
|
+
| OpenCode | platform, subscription, BYOK | exact model-catalog `variant` |
|
|
103
|
+
| Pi | platform, subscription, BYOK | reasoning only |
|
|
104
|
+
| ACP | revision-declared modes | negotiated ACP config options |
|
|
105
|
+
|
|
106
|
+
Every path takes the complete selected tool set (no ambient MCP server), an
|
|
107
|
+
absolute prepared cwd, `ask` or `full_access`,
|
|
108
|
+
an immutable agent revision, a provider-scoped model, and an execution
|
|
109
|
+
computer. Optional prompt/MCP/config capabilities are negotiated for ACP.
|
|
110
|
+
Anything that cannot be applied throws `UNSUPPORTED_EXECUTION_INPUT` or
|
|
111
|
+
`UNSUPPORTED_PROMPT_PART`; no selected input disappears.
|
|
112
|
+
|
|
113
|
+
## Output
|
|
114
|
+
|
|
115
|
+
ACP is the public update grammar:
|
|
116
|
+
|
|
117
|
+
- `agent_message_chunk`: text;
|
|
118
|
+
- `agent_thought_chunk`: reasoning;
|
|
119
|
+
- `tool_call`: tool identity, input, and initial state;
|
|
120
|
+
- `tool_call_update`: input/result deltas and state;
|
|
121
|
+
- ACP permission requests and stop reasons.
|
|
122
|
+
|
|
123
|
+
Amalgm extensions retain durable ids/cursors, raw events, ownership, and richer
|
|
124
|
+
usage without changing the ACP meaning.
|
|
125
|
+
|
|
126
|
+
## Usage
|
|
127
|
+
|
|
128
|
+
One turn can contain many model steps. Each step reports nullable
|
|
129
|
+
`inputTokens`, `outputTokens`, `cacheReadTokens`, and `cacheWriteTokens`, plus
|
|
130
|
+
source, exactness, model identity, and raw evidence. Aggregate the turn from
|
|
131
|
+
steps only. A bucket remains `null` when any contributing step is unknown.
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Fetch API adapter for engine
|
|
3
|
-
* `runtime/scripts/amalgm-mcp/server/routes/chat-payloads.js`.
|
|
4
|
-
* Route matching and response shapes are byte-for-byte laws; persistence and
|
|
5
|
-
* clocks are already behind `ChatPayloadStore` ports.
|
|
6
|
-
*/
|
|
7
|
-
import type { ChatPayloadStore } from '../warm/store.js';
|
|
8
|
-
export type ChatPayloadApi = (request: Request) => Promise<Response>;
|
|
9
|
-
export declare function createChatPayloadApi(store: ChatPayloadStore): ChatPayloadApi;
|
|
10
|
-
//# sourceMappingURL=chat-payloads.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"chat-payloads.d.ts","sourceRoot":"","sources":["../../src/api/chat-payloads.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAEzD,MAAM,MAAM,cAAc,GAAG,CAAC,OAAO,EAAE,OAAO,KAAK,OAAO,CAAC,QAAQ,CAAC,CAAC;AAErE,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,gBAAgB,GAAG,cAAc,CAoC5E"}
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Fetch API adapter for engine
|
|
3
|
-
* `runtime/scripts/amalgm-mcp/server/routes/chat-payloads.js`.
|
|
4
|
-
* Route matching and response shapes are byte-for-byte laws; persistence and
|
|
5
|
-
* clocks are already behind `ChatPayloadStore` ports.
|
|
6
|
-
*/
|
|
7
|
-
export function createChatPayloadApi(store) {
|
|
8
|
-
return async (request) => {
|
|
9
|
-
try {
|
|
10
|
-
const url = new URL(request.url);
|
|
11
|
-
const method = request.method.toUpperCase();
|
|
12
|
-
if (url.pathname === '/chat-payloads' && method === 'GET') {
|
|
13
|
-
const id = url.searchParams.get('id');
|
|
14
|
-
const payload = id ? store.get(id) : null;
|
|
15
|
-
return json(payload ? 200 : (id ? 404 : 200), {
|
|
16
|
-
...(id && payload ? { payload } : {}),
|
|
17
|
-
payloads: store.list(),
|
|
18
|
-
...(id && !payload ? { error: 'Chat payload not found' } : {}),
|
|
19
|
-
});
|
|
20
|
-
}
|
|
21
|
-
if (url.pathname === '/chat-payloads/get' && method === 'POST') {
|
|
22
|
-
const body = await jsonBody(request);
|
|
23
|
-
const payload = store.get(value(body, 'id') || value(body, 'payloadId'));
|
|
24
|
-
if (!payload)
|
|
25
|
-
return json(404, { error: 'Chat payload not found' });
|
|
26
|
-
return json(200, { payload });
|
|
27
|
-
}
|
|
28
|
-
if (url.pathname === '/chat-payloads' && (method === 'PUT' || method === 'POST')) {
|
|
29
|
-
const payload = store.write(await jsonBody(request));
|
|
30
|
-
return json(200, { success: true, payload });
|
|
31
|
-
}
|
|
32
|
-
return new Response('Not found', {
|
|
33
|
-
status: 404,
|
|
34
|
-
headers: { 'content-type': 'text/plain' },
|
|
35
|
-
});
|
|
36
|
-
}
|
|
37
|
-
catch {
|
|
38
|
-
return json(500, { error: 'Internal server error' });
|
|
39
|
-
}
|
|
40
|
-
};
|
|
41
|
-
}
|
|
42
|
-
async function jsonBody(request) {
|
|
43
|
-
const raw = await request.text();
|
|
44
|
-
return raw ? JSON.parse(raw) : {};
|
|
45
|
-
}
|
|
46
|
-
function value(input, key) {
|
|
47
|
-
return input && typeof input === 'object' && !Array.isArray(input)
|
|
48
|
-
? input[key]
|
|
49
|
-
: undefined;
|
|
50
|
-
}
|
|
51
|
-
function json(status, body) {
|
|
52
|
-
return new Response(JSON.stringify(body), {
|
|
53
|
-
status,
|
|
54
|
-
headers: { 'content-type': 'application/json' },
|
|
55
|
-
});
|
|
56
|
-
}
|
|
57
|
-
//# sourceMappingURL=chat-payloads.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"chat-payloads.js","sourceRoot":"","sources":["../../src/api/chat-payloads.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAMH,MAAM,UAAU,oBAAoB,CAAC,KAAuB;IAC1D,OAAO,KAAK,EAAE,OAAO,EAAE,EAAE;QACvB,IAAI,CAAC;YACH,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,OAAO,CAAC,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AAE,cAAc,EAAE,kBAAkB,EAAE;KAChD,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -1,144 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Structured chat input — engine `runtime/lib/chatInput.js` (311 lines),
|
|
3
|
-
* ported byte-exact. Both sides run zod ^4.4.3, so the schemas carry over
|
|
4
|
-
* verbatim (`.passthrough()`, `.default()` semantics identical).
|
|
5
|
-
*/
|
|
6
|
-
import { z } from 'zod';
|
|
7
|
-
export declare const ChatInputPartSchema: z.ZodUnion<readonly [z.ZodObject<{
|
|
8
|
-
type: z.ZodLiteral<"text">;
|
|
9
|
-
text: z.ZodDefault<z.ZodString>;
|
|
10
|
-
}, z.core.$loose>, z.ZodObject<{
|
|
11
|
-
type: z.ZodLiteral<"file">;
|
|
12
|
-
filename: z.ZodOptional<z.ZodString>;
|
|
13
|
-
mediaType: z.ZodOptional<z.ZodString>;
|
|
14
|
-
url: z.ZodOptional<z.ZodString>;
|
|
15
|
-
storagePath: z.ZodOptional<z.ZodString>;
|
|
16
|
-
storage_path: z.ZodOptional<z.ZodString>;
|
|
17
|
-
computerPath: z.ZodOptional<z.ZodString>;
|
|
18
|
-
sandboxPath: z.ZodOptional<z.ZodString>;
|
|
19
|
-
assetId: z.ZodOptional<z.ZodString>;
|
|
20
|
-
}, z.core.$loose>, z.ZodObject<{
|
|
21
|
-
type: z.ZodString;
|
|
22
|
-
}, z.core.$loose>]>;
|
|
23
|
-
export declare const WorkspaceTargetSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
24
|
-
kind: z.ZodLiteral<"cwd">;
|
|
25
|
-
cwd: z.ZodString;
|
|
26
|
-
}, z.core.$strip>, z.ZodObject<{
|
|
27
|
-
kind: z.ZodLiteral<"existing-worktree">;
|
|
28
|
-
path: z.ZodString;
|
|
29
|
-
}, z.core.$strip>, z.ZodObject<{
|
|
30
|
-
kind: z.ZodLiteral<"managed-worktree">;
|
|
31
|
-
repoPath: z.ZodString;
|
|
32
|
-
branch: z.ZodString;
|
|
33
|
-
baseBranch: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
34
|
-
path: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
35
|
-
}, z.core.$strip>], "kind">;
|
|
36
|
-
export declare const ChatInputSchema: z.ZodObject<{
|
|
37
|
-
parts: z.ZodDefault<z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
|
|
38
|
-
type: z.ZodLiteral<"text">;
|
|
39
|
-
text: z.ZodDefault<z.ZodString>;
|
|
40
|
-
}, z.core.$loose>, z.ZodObject<{
|
|
41
|
-
type: z.ZodLiteral<"file">;
|
|
42
|
-
filename: z.ZodOptional<z.ZodString>;
|
|
43
|
-
mediaType: z.ZodOptional<z.ZodString>;
|
|
44
|
-
url: z.ZodOptional<z.ZodString>;
|
|
45
|
-
storagePath: z.ZodOptional<z.ZodString>;
|
|
46
|
-
storage_path: z.ZodOptional<z.ZodString>;
|
|
47
|
-
computerPath: z.ZodOptional<z.ZodString>;
|
|
48
|
-
sandboxPath: z.ZodOptional<z.ZodString>;
|
|
49
|
-
assetId: z.ZodOptional<z.ZodString>;
|
|
50
|
-
}, z.core.$loose>, z.ZodObject<{
|
|
51
|
-
type: z.ZodString;
|
|
52
|
-
}, z.core.$loose>]>>>;
|
|
53
|
-
agent: z.ZodDefault<z.ZodObject<{
|
|
54
|
-
harness: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
55
|
-
model: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
56
|
-
authMethod: z.ZodOptional<z.ZodNullable<z.ZodEnum<{
|
|
57
|
-
amalgm: "amalgm";
|
|
58
|
-
byok: "byok";
|
|
59
|
-
provider_auth: "provider_auth";
|
|
60
|
-
}>>>;
|
|
61
|
-
customAgentId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
62
|
-
systemPrompt: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
63
|
-
}, z.core.$strip>>;
|
|
64
|
-
tools: z.ZodDefault<z.ZodObject<{
|
|
65
|
-
mcpAppIds: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
66
|
-
toolIds: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
67
|
-
}, z.core.$strip>>;
|
|
68
|
-
execution: z.ZodDefault<z.ZodObject<{
|
|
69
|
-
cwd: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
70
|
-
computerId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
71
|
-
workspace: z.ZodOptional<z.ZodNullable<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
72
|
-
kind: z.ZodLiteral<"cwd">;
|
|
73
|
-
cwd: z.ZodString;
|
|
74
|
-
}, z.core.$strip>, z.ZodObject<{
|
|
75
|
-
kind: z.ZodLiteral<"existing-worktree">;
|
|
76
|
-
path: z.ZodString;
|
|
77
|
-
}, z.core.$strip>, z.ZodObject<{
|
|
78
|
-
kind: z.ZodLiteral<"managed-worktree">;
|
|
79
|
-
repoPath: z.ZodString;
|
|
80
|
-
branch: z.ZodString;
|
|
81
|
-
baseBranch: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
82
|
-
path: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
83
|
-
}, z.core.$strip>], "kind">>>;
|
|
84
|
-
}, z.core.$strip>>;
|
|
85
|
-
}, z.core.$strip>;
|
|
86
|
-
export type ChatInputPart = z.infer<typeof ChatInputPartSchema>;
|
|
87
|
-
export type WorkspaceTarget = z.infer<typeof WorkspaceTargetSchema>;
|
|
88
|
-
export type ChatInput = z.infer<typeof ChatInputSchema>;
|
|
89
|
-
/** The legacy flat fields `normalizeChatInput` accepts as fallbacks. */
|
|
90
|
-
export interface ChatInputLegacyFallback {
|
|
91
|
-
prompt?: unknown;
|
|
92
|
-
userParts?: unknown;
|
|
93
|
-
harness?: unknown;
|
|
94
|
-
modelId?: unknown;
|
|
95
|
-
model?: unknown;
|
|
96
|
-
authMethod?: unknown;
|
|
97
|
-
cwd?: unknown;
|
|
98
|
-
projectPath?: unknown;
|
|
99
|
-
computerId?: unknown;
|
|
100
|
-
mcpAppIds?: unknown;
|
|
101
|
-
toolIds?: unknown;
|
|
102
|
-
systemPrompt?: unknown;
|
|
103
|
-
[key: string]: unknown;
|
|
104
|
-
}
|
|
105
|
-
/** Engine `chatInput.js uniqueStrings`: trimmed, deduped string list. */
|
|
106
|
-
export declare function uniqueStrings(values: unknown): string[];
|
|
107
|
-
/** Engine `getWorkspaceCwd`: the folder a workspace target points at, if any. */
|
|
108
|
-
export declare function getWorkspaceCwd(workspace: unknown): string | null;
|
|
109
|
-
/** Engine `normalizeChatPart` — pass-through normalization for one part. */
|
|
110
|
-
export declare function normalizeChatPart(part: unknown): Record<string, any> | null;
|
|
111
|
-
/** Engine `normalizeChatParts` — normalized parts, else a text part from the prompt. */
|
|
112
|
-
export declare function normalizeChatParts(parts: unknown, fallbackPrompt: unknown): Record<string, any>[];
|
|
113
|
-
/** Engine `getChatInputText` — joined text of all text parts. */
|
|
114
|
-
export declare function getChatInputText(chatInput: unknown, fallbackPrompt?: unknown): string;
|
|
115
|
-
/** Engine `getAttachedFilePaths` — local paths of attached file parts. */
|
|
116
|
-
export declare function getAttachedFilePaths(parts: unknown): string[];
|
|
117
|
-
/** Engine `buildPromptFromParts` — flat prompt text incl. attached-file prefix. */
|
|
118
|
-
export declare function buildPromptFromParts(parts: unknown, fallbackPrompt: unknown): string;
|
|
119
|
-
/**
|
|
120
|
-
* Engine `normalizeChatInput(chatInput, legacy)` — the canonical structured
|
|
121
|
-
* input, merging the structured object with legacy flat fields.
|
|
122
|
-
*/
|
|
123
|
-
export declare function normalizeChatInput(chatInput: unknown, legacy?: ChatInputLegacyFallback): ChatInput;
|
|
124
|
-
export interface ChatInputLegacyFields {
|
|
125
|
-
prompt: string;
|
|
126
|
-
userParts: ChatInput['parts'];
|
|
127
|
-
harness: string | null;
|
|
128
|
-
modelId: string | null;
|
|
129
|
-
model: string | null;
|
|
130
|
-
authMethod: string | null;
|
|
131
|
-
cwd: string | null;
|
|
132
|
-
projectPath: string | null;
|
|
133
|
-
computerId: string | null;
|
|
134
|
-
mcpAppIds: string[];
|
|
135
|
-
systemPrompt: string | null;
|
|
136
|
-
}
|
|
137
|
-
/**
|
|
138
|
-
* Engine `chatInputToLegacyFields` — project the structured input back onto
|
|
139
|
-
* the flat legacy body fields (the shape `applyPayloadRecord` spreads).
|
|
140
|
-
*/
|
|
141
|
-
export declare function chatInputToLegacyFields(chatInput: unknown, fallback?: ChatInputLegacyFallback): ChatInputLegacyFields;
|
|
142
|
-
/** Engine `withChatInputText` — rewrite every text part through `updater`. */
|
|
143
|
-
export declare function withChatInputText(chatInput: unknown, updater: (text: string, part: ChatInputPart) => string, legacy?: ChatInputLegacyFallback): ChatInput;
|
|
144
|
-
//# sourceMappingURL=chat-input.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"chat-input.d.ts","sourceRoot":"","sources":["../../src/contract/chat-input.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAyBxB,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;mBAI9B,CAAC;AAEH,eAAO,MAAM,qBAAqB;;;;;;;;;;;;2BAgBhC,CAAC;AAEH,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAqB1B,CAAC;AAEH,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAC;AAChE,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,qBAAqB,CAAC,CAAC;AACpE,MAAM,MAAM,SAAS,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,eAAe,CAAC,CAAC;AAExD,wEAAwE;AACxE,MAAM,WAAW,uBAAuB;IACtC,MAAM,CAAC,EAAE,OAAO,CA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