@amalgm/chat 0.2.9-preview.34176088664 → 0.2.9-preview.34938476986
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/PURPOSE.md +122 -41
- package/README.md +16 -0
- package/dist/acp/projection.d.ts +8 -0
- package/dist/acp/projection.d.ts.map +1 -1
- package/dist/acp/projection.js +24 -4
- package/dist/acp/projection.js.map +1 -1
- package/dist/conversations/index.d.ts +1 -0
- package/dist/conversations/index.d.ts.map +1 -1
- package/dist/conversations/index.js +1 -0
- package/dist/conversations/index.js.map +1 -1
- package/dist/conversations/transcript-parts.d.ts +49 -0
- package/dist/conversations/transcript-parts.d.ts.map +1 -0
- package/dist/conversations/transcript-parts.js +2 -0
- package/dist/conversations/transcript-parts.js.map +1 -0
- package/dist/conversations/transcript-tools.d.ts +11 -0
- package/dist/conversations/transcript-tools.d.ts.map +1 -0
- package/dist/conversations/transcript-tools.js +47 -0
- package/dist/conversations/transcript-tools.js.map +1 -0
- package/dist/conversations/transcript.d.ts +6 -4
- package/dist/conversations/transcript.d.ts.map +1 -1
- package/dist/conversations/transcript.js +66 -142
- package/dist/conversations/transcript.js.map +1 -1
- package/dist/conversations/types.d.ts +22 -0
- package/dist/conversations/types.d.ts.map +1 -1
- package/dist/conversations/types.js.map +1 -1
- package/dist/events/constructors.d.ts.map +1 -1
- package/dist/events/constructors.js +2 -52
- package/dist/events/constructors.js.map +1 -1
- package/dist/events/schema.d.ts +78 -72
- package/dist/events/schema.d.ts.map +1 -1
- package/dist/events/schema.js +18 -16
- package/dist/events/schema.js.map +1 -1
- package/dist/execution/contract.d.ts +3 -0
- package/dist/execution/contract.d.ts.map +1 -1
- package/dist/execution/contract.js +12 -1
- package/dist/execution/contract.js.map +1 -1
- package/dist/execution/controls.d.ts +56 -0
- package/dist/execution/controls.d.ts.map +1 -0
- package/dist/execution/controls.js +24 -0
- package/dist/execution/controls.js.map +1 -0
- package/dist/execution/index.d.ts +3 -1
- package/dist/execution/index.d.ts.map +1 -1
- package/dist/execution/index.js +1 -0
- package/dist/execution/index.js.map +1 -1
- package/dist/execution/store.d.ts +9 -0
- package/dist/execution/store.d.ts.map +1 -1
- package/dist/execution/store.js +15 -3
- package/dist/execution/store.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/input/prompt.js +1 -1
- package/dist/input/prompt.js.map +1 -1
- package/dist/mcp/server.js +13 -13
- package/dist/mcp/server.js.map +1 -1
- package/dist/normalizers/claude.d.ts +104 -96
- package/dist/normalizers/claude.d.ts.map +1 -1
- package/dist/normalizers/claude.js +30 -39
- package/dist/normalizers/claude.js.map +1 -1
- package/dist/normalizers/codex.d.ts +55 -57
- package/dist/normalizers/codex.d.ts.map +1 -1
- package/dist/normalizers/codex.js +33 -77
- package/dist/normalizers/codex.js.map +1 -1
- package/dist/normalizers/index.d.ts +0 -1
- package/dist/normalizers/index.d.ts.map +1 -1
- package/dist/normalizers/index.js +0 -1
- package/dist/normalizers/index.js.map +1 -1
- package/dist/normalizers/opencode.d.ts +5 -2
- package/dist/normalizers/opencode.d.ts.map +1 -1
- package/dist/normalizers/opencode.js +48 -17
- package/dist/normalizers/opencode.js.map +1 -1
- package/dist/normalizers/pi.d.ts +2 -0
- package/dist/normalizers/pi.d.ts.map +1 -1
- package/dist/normalizers/pi.js +47 -20
- package/dist/normalizers/pi.js.map +1 -1
- package/dist/sessions/chat.d.ts +8 -6
- package/dist/sessions/chat.d.ts.map +1 -1
- package/dist/sessions/chat.js +55 -20
- package/dist/sessions/chat.js.map +1 -1
- package/dist/sessions/index.d.ts +1 -1
- package/dist/sessions/index.d.ts.map +1 -1
- package/dist/sessions/index.js +1 -1
- package/dist/sessions/index.js.map +1 -1
- package/dist/usage/acp.d.ts +4 -0
- package/dist/usage/acp.d.ts.map +1 -0
- package/dist/usage/acp.js +20 -0
- package/dist/usage/acp.js.map +1 -0
- package/dist/usage/finalize.d.ts +1 -11
- package/dist/usage/finalize.d.ts.map +1 -1
- package/dist/usage/finalize.js +29 -47
- package/dist/usage/finalize.js.map +1 -1
- package/dist/usage/index.d.ts +2 -1
- package/dist/usage/index.d.ts.map +1 -1
- package/dist/usage/index.js +2 -1
- package/dist/usage/index.js.map +1 -1
- package/dist/usage/normalize.d.ts +12 -9
- package/dist/usage/normalize.d.ts.map +1 -1
- package/dist/usage/normalize.js +22 -20
- package/dist/usage/normalize.js.map +1 -1
- package/dist/usage/ports.d.ts +4 -4
- package/dist/usage/ports.d.ts.map +1 -1
- package/dist/usage/ports.js +5 -5
- package/dist/usage/ports.js.map +1 -1
- package/dist/usage/steps.d.ts +3 -1
- package/dist/usage/steps.d.ts.map +1 -1
- package/dist/usage/steps.js +2 -0
- package/dist/usage/steps.js.map +1 -1
- package/dist/usage/tokens.d.ts +13 -38
- package/dist/usage/tokens.d.ts.map +1 -1
- package/dist/usage/tokens.js +39 -72
- package/dist/usage/tokens.js.map +1 -1
- package/docs/contracts/acp-and-step-usage.md +226 -3
- package/docs/contracts/capabilities-and-instructions.md +32 -0
- package/host/adapters/acp-prompt.js +36 -0
- package/host/adapters/acp.js +67 -136
- package/host/adapters/attachments.js +37 -0
- package/host/adapters/claude-usage.js +53 -0
- package/host/adapters/claude.js +40 -9
- package/host/adapters/codex-usage.js +61 -0
- package/host/adapters/codex.js +116 -39
- package/host/adapters/controls/acp-config.js +85 -0
- package/host/adapters/controls/acp.js +48 -0
- package/host/adapters/controls/catalog.js +49 -0
- package/host/adapters/controls/claude.js +66 -0
- package/host/adapters/controls/codex.js +86 -0
- package/host/adapters/controls/commands.js +22 -0
- package/host/adapters/controls/discovery.js +67 -0
- package/host/adapters/controls/home.js +23 -0
- package/host/adapters/controls/opencode.js +35 -0
- package/host/adapters/controls/pi.js +73 -0
- package/host/adapters/controls/probe.js +40 -0
- package/host/adapters/controls/resume.js +12 -0
- package/host/adapters/controls/settings.js +82 -0
- package/host/adapters/cursor.js +93 -102
- package/host/adapters/input-capabilities.js +22 -3
- package/host/adapters/opencode.js +243 -157
- package/host/adapters/pi-usage-extension.js +54 -0
- package/host/adapters/pi.js +86 -32
- package/host/adapters/prompt.js +13 -21
- package/host/adapters/provider-url.js +8 -0
- package/host/adapters/usage-collector.js +37 -0
- package/host/auth.js +10 -9
- package/host/http.js +3 -2
- package/host/index.js +5 -1
- package/host/model-resolution.js +7 -0
- package/host/native-contract.js +5 -3
- package/host/native-runtime.js +93 -19
- package/host/platform-egress.js +5 -0
- package/host/sqlite/index.d.ts +7 -0
- package/host/sqlite/index.js +96 -4
- package/host/tooling/runtime-home.js +1 -1
- package/host/tooling/system-instructions.js +7 -6
- package/host/tooling/system-prompt.js +12 -18
- package/host/usage-delivery.js +56 -0
- package/package.json +5 -5
- package/dist/normalizers/cursor.d.ts +0 -33
- package/dist/normalizers/cursor.d.ts.map +0 -1
- package/dist/normalizers/cursor.js +0 -196
- package/dist/normalizers/cursor.js.map +0 -1
package/PURPOSE.md
CHANGED
|
@@ -21,7 +21,8 @@ automations, and third-party apps must all use the same public SDK.
|
|
|
21
21
|
- A **session update** is the official ACP output shape.
|
|
22
22
|
- A **step usage record** is Amalgm's immutable usage extension for one model
|
|
23
23
|
step.
|
|
24
|
-
- A **turn usage record** is
|
|
24
|
+
- A **turn usage record** is a provider-reported turn aggregate or a derivation
|
|
25
|
+
from proven steps or cumulative meter baselines.
|
|
25
26
|
- A **raw record** is the native provider evidence retained beside a normalized
|
|
26
27
|
projection.
|
|
27
28
|
- A **prompt** is an ordered list of official ACP content blocks.
|
|
@@ -50,16 +51,22 @@ automations, and third-party apps must all use the same public SDK.
|
|
|
50
51
|
and `tool_call_update` with `pending`, `in_progress`, `completed`, or
|
|
51
52
|
`failed` state.
|
|
52
53
|
5. MCP describes remote tools and their transport. In-process tools may skip
|
|
53
|
-
|
|
54
|
+
MCP transport, but they expose the same content and result semantics.
|
|
55
|
+
Every structured tool result is an object; list results have a named array
|
|
56
|
+
field and pass the official MCP result schema.
|
|
54
57
|
6. A model step has one stable id and at most one finalized usage record.
|
|
55
58
|
Replay, reconnect, and additional subscribers cannot add usage.
|
|
56
59
|
7. Unknown token counts are `null`, never zero. Zero means the provider
|
|
57
60
|
explicitly measured zero.
|
|
58
|
-
|
|
59
|
-
|
|
61
|
+
A provider SDK's initialized counters on a rejected invocation are not a
|
|
62
|
+
measurement; their raw values remain evidence, not billable zero usage.
|
|
63
|
+
8. A provider turn aggregate is authoritative for that turn; otherwise usage
|
|
64
|
+
is the sum of proven steps only where every step reports the bucket.
|
|
60
65
|
9. A cumulative provider counter becomes a step delta only against a proven
|
|
61
66
|
prior baseline. A missing baseline or counter reset remains unknown.
|
|
62
67
|
10. Raw provider usage and its provenance survive normalization.
|
|
68
|
+
Usage observations commit to the turn before provider iteration advances;
|
|
69
|
+
context telemetry remains independent of billable token totals.
|
|
63
70
|
11. Every surface consumes official ACP session updates; Chat has no second
|
|
64
71
|
event grammar.
|
|
65
72
|
12. Provider-specific behavior stays in adapters. Surfaces do not branch on
|
|
@@ -69,6 +76,10 @@ automations, and third-party apps must all use the same public SDK.
|
|
|
69
76
|
payload.
|
|
70
77
|
14. Preparing may discover and resolve. Starting and sending may only consume
|
|
71
78
|
an already-prepared binding.
|
|
79
|
+
UI callers prepare execution selections and attachment content before
|
|
80
|
+
Send; accepting a draft never initiates configuration discovery or file
|
|
81
|
+
preparation. Required durable admission and provider authorization remain
|
|
82
|
+
execution effects, not configuration resolution.
|
|
72
83
|
15. Auth and computer are selected per turn, not frozen to a conversation. A
|
|
73
84
|
running provider operation retains the execution facts it actually used.
|
|
74
85
|
16. A conversation store commits accepted input and every streamed update
|
|
@@ -102,9 +113,13 @@ automations, and third-party apps must all use the same public SDK.
|
|
|
102
113
|
at most the first 500 characters of one message, run independently of the
|
|
103
114
|
turn pump through a host-supplied inference effect, and cannot delay,
|
|
104
115
|
cancel, or change the outcome of the turn they describe.
|
|
116
|
+
Adapters disable native automatic titling where supported; a second title
|
|
117
|
+
generator cannot create model work outside Chat's accounting boundary.
|
|
105
118
|
28. The official ACP `McpServer` union is the one prepared tool-injection
|
|
106
119
|
shape. Toolbox selections resolve to `McpServer[]`; native adapters only
|
|
107
120
|
project that exact list into provider configuration.
|
|
121
|
+
Native connected apps, plugins, and ambient MCP configuration cannot add
|
|
122
|
+
unselected servers to a prepared execution.
|
|
108
123
|
29. Amalgm products exposed to agents are ordinary selected MCP servers. Tools,
|
|
109
124
|
Agents, Chat, and future platform capabilities receive no ambient or
|
|
110
125
|
provider-specific injection path.
|
|
@@ -112,10 +127,14 @@ automations, and third-party apps must all use the same public SDK.
|
|
|
112
127
|
instruction bundle. Adapters consume that prepared bundle through a native
|
|
113
128
|
system/developer-instruction channel; they never reread instruction sources
|
|
114
129
|
or prepend instructions to ACP user prompt content.
|
|
115
|
-
|
|
130
|
+
Machine instructions come from the host-selected Amalgm root; unreadable
|
|
131
|
+
instruction sources fail preparation rather than silently removing guidance.
|
|
132
|
+
31. Stable ACP has no client-supplied system-instruction field. A generic ACP agent
|
|
116
133
|
receives prepared instructions only through a namespaced `_meta` extension
|
|
117
134
|
it advertised during initialization; otherwise non-empty instructions are
|
|
118
135
|
rejected as unsupported.
|
|
136
|
+
The native Cursor adapter uses an immutable managed rules directory for
|
|
137
|
+
instructions and ACP's session cwd for the execution workspace.
|
|
119
138
|
32. A tool selection revision is the exact immutable deployment-head digest
|
|
120
139
|
supplied by Tools, not a machine-local database counter. Preparation must
|
|
121
140
|
resolve that digest or fail; once prepared, the resulting official ACP
|
|
@@ -145,6 +164,64 @@ automations, and third-party apps must all use the same public SDK.
|
|
|
145
164
|
admitted message creates that exact conversation; every later message
|
|
146
165
|
resumes it, and the provider message id is the stable turn id. Chat never
|
|
147
166
|
infers a thread from a subject or chooses a recipient.
|
|
167
|
+
39. Provider failure is a turn outcome, never an ACP transcript part and never
|
|
168
|
+
successful end-of-stream. Committed output survives a later provider failure.
|
|
169
|
+
40. One conversation admits one provider session and one turn at a time, including
|
|
170
|
+
while asynchronous creation or input persistence is pending.
|
|
171
|
+
41. An execution change cannot erase conversation context. Without a proven native
|
|
172
|
+
checkpoint, the host supplies committed history as an explicit ACP resource.
|
|
173
|
+
42. Transcript activity has one text, reasoning, tool, or compaction shape and one state
|
|
174
|
+
vocabulary: pending, active, complete, error. A tool id identifies one part
|
|
175
|
+
throughout a turn; later detail cannot erase its identity, result, or terminal
|
|
176
|
+
state. Titles and optional timing are presentation facts, not tool identity.
|
|
177
|
+
Compaction activity projects namespaced official ACP session metadata;
|
|
178
|
+
it never becomes synthetic assistant text. Its lifecycle survives replay.
|
|
179
|
+
Usage remains a separate measurement, including compaction model steps.
|
|
180
|
+
43. Attachment bytes belong to the accepted ACP prompt. A native adapter that
|
|
181
|
+
needs a filesystem path receives a host materialization of those bytes;
|
|
182
|
+
that derived file is never the durable source of truth.
|
|
183
|
+
44. A managed provider home belongs to one installation and one auth authority.
|
|
184
|
+
Child environments contain standard process and network settings plus
|
|
185
|
+
explicitly prepared credentials; they never inherit host service secrets.
|
|
186
|
+
Native adapters project the configured provider base onto their SDK's API
|
|
187
|
+
path; an SDK's appended path cannot change the selected authority.
|
|
188
|
+
Subscription, platform, and distinct BYOK credentials cannot share persisted
|
|
189
|
+
provider configuration or login material.
|
|
190
|
+
45. A caller-supplied conversation id is an idempotency key within its owner
|
|
191
|
+
and installation. Retrying start rejoins that conversation, including after
|
|
192
|
+
a provider launch failed; it never replaces accepted history.
|
|
193
|
+
46. Preparation carries the selected action exposure without widening the
|
|
194
|
+
resolved agent loadout. Tools enforces direct, search, and hidden boundaries
|
|
195
|
+
through one scoped MCP server; Chat adapters only consume its ACP descriptor.
|
|
196
|
+
Adapters disable provider-side automatic deferral that would move a directly
|
|
197
|
+
exposed action behind another search surface.
|
|
198
|
+
47. Every proven model invocation, including compaction, records its four token
|
|
199
|
+
buckets and model identity once. Provider message ids or invocation order
|
|
200
|
+
identify steps; equal token counts do not identify equal invocations.
|
|
201
|
+
Codex 0.154 or newer supplies exact response-completion measurements in
|
|
202
|
+
native events and its journal; both name the same response. Its cumulative
|
|
203
|
+
context snapshots cannot create model steps.
|
|
204
|
+
The journal assigns immutable ordinals in finalization order, including
|
|
205
|
+
when concurrent provider invocations finish in a different start order.
|
|
206
|
+
A known unfinished invocation remains a partial step; an interrupted
|
|
207
|
+
invocation's initialized counters cannot make a turn look fully measured.
|
|
208
|
+
Provider cancellation and its final usage settle before the turn seals.
|
|
209
|
+
48. Non-platform step usage is delivered from the committed journal with a stable
|
|
210
|
+
idempotency key and retried until acknowledged. Platform usage is metered and
|
|
211
|
+
persisted by the API proxy for each upstream invocation; local observations
|
|
212
|
+
cannot create a second charge. The authenticated host supplies ownership.
|
|
213
|
+
49. Only commands with an explicit Amalgm normalization may be advertised or
|
|
214
|
+
executed. Native discovery is evidence, never execution permission. The only
|
|
215
|
+
enabled command is `/compact`, on adapters with a proven compaction mapping;
|
|
216
|
+
it uses the existing durable turn, compaction activity, and usage journal.
|
|
217
|
+
Unknown slash commands fail before provider invocation, including requests
|
|
218
|
+
carrying attachments; they never fall through as native prompt commands.
|
|
219
|
+
A command's ACP input descriptor declares optional arguments; adapters preserve
|
|
220
|
+
those arguments and reject unsupported input. Surfaces use this same policy.
|
|
221
|
+
The broader native command, mode, and settings menus are deferred. Preparation
|
|
222
|
+
does not run their metadata probes. Existing prepared model settings retain
|
|
223
|
+
their explicit adapter mappings and never change reported model capacity.
|
|
224
|
+
Control-only checkpoint reuse still requires all other prepared facts to match.
|
|
148
225
|
|
|
149
226
|
## North-star proof
|
|
150
227
|
|
|
@@ -164,42 +241,46 @@ require a new event grammar, transcript reducer, or UI data model.
|
|
|
164
241
|
|
|
165
242
|
## Current truth
|
|
166
243
|
|
|
167
|
-
The public SDK
|
|
168
|
-
content,
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
244
|
+
The public SDK has one high-level `Chat` capability, official ACP prompt
|
|
245
|
+
content, immutable prepared executions, and durable official ACP updates. The
|
|
246
|
+
Node host composes one owner-scoped SQLite journal and one HTTP/SSE protocol.
|
|
247
|
+
Input commits before provider invocation, output and usage commit before fanout,
|
|
248
|
+
and reconnect reads the same journal. Disconnect leaves the runtime pump alive;
|
|
249
|
+
uncertain work after restart becomes interrupted. Structured provider failures
|
|
250
|
+
retain partial output and remain failed in the stream and saved history.
|
|
251
|
+
|
|
252
|
+
Claude Code, Codex, Cursor, OpenCode, Pi, and a generic OpenCode ACP process have
|
|
253
|
+
passed real text, image, file, and selected MCP-tool turns through the local
|
|
254
|
+
Shell. The paired UI uses the same public client and transcript reducer. Saved
|
|
255
|
+
execution choices survive reload, and continuation survives auth changes through
|
|
256
|
+
explicit committed-history delivery when a native checkpoint cannot be reused.
|
|
257
|
+
The dated evidence and account-specific limits are recorded in
|
|
258
|
+
`docs/chat-roadmap.md`.
|
|
259
|
+
|
|
260
|
+
All five native harnesses receive the same selected seven-product MCP loadout
|
|
261
|
+
and recover prepared machine instructions in real turns. Cursor's current ACP
|
|
262
|
+
implementation omits MCP names, inputs and result bodies from tool updates and
|
|
263
|
+
sometimes reports an upstream error as ordinary agent text plus `end_turn`.
|
|
264
|
+
Those omissions remain explicit upstream parity gaps; Chat neither invents
|
|
265
|
+
tool identity nor classifies arbitrary agent prose as a structured failure.
|
|
266
|
+
|
|
267
|
+
Native model-step usage and optional ACP context usage persist with their raw
|
|
268
|
+
source. Claude Code, Codex, OpenCode and Pi have returned exact input, output,
|
|
269
|
+
cache-read and cache-write records for ordinary steps and compaction in real
|
|
270
|
+
local turns. Cursor remains unknown. Non-platform records retry from SQLite
|
|
271
|
+
until the authenticated API proxy acknowledges their Supabase row; platform
|
|
272
|
+
requests are metered and persisted by that proxy without a second local upload.
|
|
273
|
+
Turn totals, reasoning, reported cost and context occupancy remain separate.
|
|
274
|
+
|
|
275
|
+
The remote gateway/Live authority does not yet expose the conversation catalog
|
|
276
|
+
and change stream; Live/R2 synchronization is not connected. Durable queued
|
|
277
|
+
turns, identity-targeted abort, and application-stream permission interaction
|
|
278
|
+
remain separate work described in the acceptance plan. Every attachment form
|
|
279
|
+
has not been exercised against every provider. Generic ACP admission uses an
|
|
280
|
+
immutable launch descriptor, and non-empty system instructions require the
|
|
281
|
+
agent to advertise the Amalgm session-instructions extension. The machine/project
|
|
282
|
+
instruction-source revision is not yet represented in control-plane execution
|
|
283
|
+
selection. Amp, Gemini CLI, and Kiro were not installed for individual acceptance.
|
|
203
284
|
|
|
204
285
|
The public contracts live in `docs/contracts/` and the shipped Chat skill.
|
|
205
286
|
|
package/README.md
CHANGED
|
@@ -14,6 +14,13 @@ for ACP-native tool injection and prepared instructions, and
|
|
|
14
14
|
[docs/contracts/conversation-persistence.md](docs/contracts/conversation-persistence.md)
|
|
15
15
|
for local conversations and durable turns.
|
|
16
16
|
|
|
17
|
+
[The step-usage contract](docs/contracts/acp-and-step-usage.md) explains native
|
|
18
|
+
per-invocation measurement, compaction, all four token buckets, durable Supabase
|
|
19
|
+
delivery, and API Proxy v2's ownership of platform metering and charges.
|
|
20
|
+
|
|
21
|
+
This chat's completed work, acceptance evidence and remaining priorities are
|
|
22
|
+
tracked in [docs/chat-roadmap.md](docs/chat-roadmap.md).
|
|
23
|
+
|
|
17
24
|
```ts
|
|
18
25
|
import { Chat } from "@amalgm/chat";
|
|
19
26
|
import {
|
|
@@ -74,6 +81,15 @@ for await (const update of session.reconnect(updates.turnId, { afterSequence: 42
|
|
|
74
81
|
revision, provider/model, cwd, permissions, and placement there. Start and send
|
|
75
82
|
consume the prepared revision; send does not discover configuration.
|
|
76
83
|
|
|
84
|
+
The handle's optional `capabilities` advertises only commands with an explicit
|
|
85
|
+
Amalgm normalization, using official ACP descriptors. Currently this is
|
|
86
|
+
`/compact` on verified adapters; native mode and settings menus are deferred.
|
|
87
|
+
Commands with `input` accept arguments; commands without it run directly.
|
|
88
|
+
Unsupported commands are rejected before provider invocation. `/compact` uses
|
|
89
|
+
the same durable turn and usage path. Reading capabilities never starts a
|
|
90
|
+
session. See the
|
|
91
|
+
[control support table](docs/contracts/capabilities-and-instructions.md#composer-controls).
|
|
92
|
+
|
|
77
93
|
Tool injection uses the official ACP `McpServer[]` lifecycle input. Amalgm
|
|
78
94
|
Tools, Agents, and Chat are platform tools because the authenticated host
|
|
79
95
|
selects their MCP servers, not because adapters contain product-specific
|
package/dist/acp/projection.d.ts
CHANGED
|
@@ -11,6 +11,14 @@ export interface AmalgmAcpMeta {
|
|
|
11
11
|
conversationId?: string;
|
|
12
12
|
turnId?: string;
|
|
13
13
|
sequence?: number;
|
|
14
|
+
tool?: {
|
|
15
|
+
name?: string;
|
|
16
|
+
kind?: string;
|
|
17
|
+
timing?: unknown;
|
|
18
|
+
metadata?: unknown;
|
|
19
|
+
detail?: string;
|
|
20
|
+
error?: unknown;
|
|
21
|
+
};
|
|
14
22
|
native: {
|
|
15
23
|
type: string;
|
|
16
24
|
timestampMs: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"projection.d.ts","sourceRoot":"","sources":["../../src/acp/projection.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,mBAAmB,EACnB,aAAa,EAEb,QAAQ,EACT,MAAM,0BAA0B,CAAC;AAElC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAEvD,eAAO,MAAM,mBAAmB,WAAW,CAAC;AAE5C,MAAM,WAAW,oBAAoB;IACnC,cAAc,CAAC,EAAE,MAAM,C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AI,EAAE,MAAM,CAAC;QACb,WAAW,EAAE,MAAM,CAAC;QACpB,GAAG,CAAC,EAAE,OAAO,CAAC;KACf,CAAC;CACH;AA8BD,0EAA0E;AAC1E,wBAAgB,aAAa,CAAC,IAAI,EAAE,OAAO,GAAG,QAAQ,CA6BrD;AAgBD;;;;GAIG;AACH,wBAAgB,kBAAkB,CAChC,KAAK,EAAE,WAAW,EAClB,OAAO,GAAE,oBAAyB,GACjC,aAAa,GAAG,IAAI,CAsFtB;AAED,4EAA4E;AAC5E,wBAAgB,wBAAwB,CACtC,SAAS,EAAE,MAAM,EACjB,KAAK,EAAE,WAAW,EAClB,OAAO,GAAE,oBAAyB,GACjC,mBAAmB,GAAG,IAAI,CAI5B"}
|
package/dist/acp/projection.js
CHANGED
|
@@ -9,6 +9,16 @@ function projectionMeta(event, context) {
|
|
|
9
9
|
...(context.turnId === undefined ? {} : { turnId: context.turnId }),
|
|
10
10
|
...(context.sequence === undefined ? {} : { sequence: context.sequence }),
|
|
11
11
|
};
|
|
12
|
+
if (event.type === 'tool.started' || event.type === 'tool.updated' || event.type === 'tool.completed') {
|
|
13
|
+
amalgm.tool = {
|
|
14
|
+
...(event.toolName === undefined ? {} : { name: event.toolName }),
|
|
15
|
+
...(event.kind === undefined ? {} : { kind: event.kind }),
|
|
16
|
+
...(event.timing === undefined ? {} : { timing: event.timing }),
|
|
17
|
+
...(event.metadata === undefined ? {} : { metadata: event.metadata }),
|
|
18
|
+
...(event.detail === undefined ? {} : { detail: event.detail }),
|
|
19
|
+
...('error' in event && event.error !== undefined ? { error: event.error } : {}),
|
|
20
|
+
};
|
|
21
|
+
}
|
|
12
22
|
return { [AMALGM_ACP_META_KEY]: amalgm };
|
|
13
23
|
}
|
|
14
24
|
/** Map the richer native tool vocabulary into ACP's stable categories. */
|
|
@@ -122,15 +132,25 @@ export function toAcpSessionUpdate(event, context = {}) {
|
|
|
122
132
|
sessionUpdate: 'usage_update',
|
|
123
133
|
used,
|
|
124
134
|
size,
|
|
125
|
-
...(event.usage.costUsd === null
|
|
126
|
-
? {}
|
|
127
|
-
: { cost: { amount: event.usage.costUsd, currency: 'USD' } }),
|
|
128
135
|
_meta,
|
|
129
136
|
};
|
|
130
137
|
}
|
|
131
138
|
case 'text.boundary':
|
|
139
|
+
return null;
|
|
132
140
|
case 'compaction.started':
|
|
133
|
-
case 'compaction.finished':
|
|
141
|
+
case 'compaction.finished': {
|
|
142
|
+
return {
|
|
143
|
+
sessionUpdate: 'session_info_update',
|
|
144
|
+
_meta: { ..._meta, amalgm: { ..._meta['amalgm'], compaction: {
|
|
145
|
+
phase: event.type === 'compaction.started' ? 'started' : 'finished',
|
|
146
|
+
trigger: event.trigger,
|
|
147
|
+
timestampMs: event.ts,
|
|
148
|
+
...('preTokens' in event ? { preTokens: event.preTokens } : {}),
|
|
149
|
+
...('postTokens' in event ? { postTokens: event.postTokens } : {}),
|
|
150
|
+
...('durationMs' in event ? { durationMs: event.durationMs } : {}),
|
|
151
|
+
} } },
|
|
152
|
+
};
|
|
153
|
+
}
|
|
134
154
|
case 'warning':
|
|
135
155
|
case 'error':
|
|
136
156
|
case 'done':
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"projection.js","sourceRoot":"","sources":["../../src/acp/projection.ts"],"names":[],"mappings":"AASA,MAAM,CAAC,MAAM,mBAAmB,GAAG,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"file":"projection.js","sourceRoot":"","sources":["../../src/acp/projection.ts"],"names":[],"mappings":"AASA,MAAM,CAAC,MAAM,mBAAmB,GAAG,QAAQ,CAAC;AAqB5C,SAAS,cAAc,CACrB,KAAkB,EAClB,OAA6B;IAE7B,MAAM,MAAM,GAA4B,KAAK,CAAC,GAAG,KAAK,SAAS;QAC7D,CAAC,CAAC,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,EAAE,WAAW,EAAE,KAAK,CAAC,EAAE,EAAE;QAC7C,CAAC,CAAC,EAAE,IAAI,EAAE,KAAK,CAAC,IAA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;4BACtB,WAAW,EAAE,KAAK,CAAC,EAAE;4BACrB,GAAG,CAAC,WAAW,IAAI,KAAK,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,KAAK,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;4BAC/D,GAAG,CAAC,YAAY,IAAI,KAAK,CAAC,CAAC,CAAC,EAAE,UAAU,EAAE,KAAK,CAAC,UAAU,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;4BAClE,GAAG,CAAC,YAAY,IAAI,KAAK,CAAC,CAAC,CAAC,EAAE,UAAU,EAAE,KAAK,CAAC,UAAU,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;yBACnE,EAAE,EAAE;aACN,CAAC;QACJ,CAAC;QACD,KAAK,SAAS,CAAC;QACf,KAAK,OAAO,CAAC;QACb,KAAK,MAAM;YACT,OAAO,IAAI,CAAC;IAChB,CAAC;AACH,CAAC;AAED,4EAA4E;AAC5E,MAAM,UAAU,wBAAwB,CACtC,SAAiB,EACjB,KAAkB,EAClB,UAAgC,EAAE;IAElC,MAAM,MAAM,GAAG,kBAAkB,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;IAClD,IAAI,MAAM,KAAK,IAAI;QAAE,OAAO,IAAI,CAAC;IACjC,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,CAAC;AAC/B,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/conversations/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,iBAAiB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/conversations/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,iBAAiB,CAAC;AAChC,cAAc,uBAAuB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/conversations/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,iBAAiB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/conversations/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,iBAAiB,CAAC;AAChC,cAAc,uBAAuB,CAAC"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import type { ContentBlock, ToolCallContent, ToolCallLocation, ToolCallStatus, ToolKind } from '@agentclientprotocol/sdk';
|
|
2
|
+
export type TranscriptPartState = 'pending' | 'active' | 'complete' | 'error';
|
|
3
|
+
export interface TranscriptTiming {
|
|
4
|
+
startedAt?: string | number;
|
|
5
|
+
completedAt?: string | number;
|
|
6
|
+
elapsedMs?: number;
|
|
7
|
+
}
|
|
8
|
+
export interface TranscriptTextPart {
|
|
9
|
+
type: 'text' | 'reasoning';
|
|
10
|
+
text: string;
|
|
11
|
+
state: TranscriptPartState;
|
|
12
|
+
messageId?: string;
|
|
13
|
+
timing?: TranscriptTiming;
|
|
14
|
+
}
|
|
15
|
+
export interface TranscriptToolPart {
|
|
16
|
+
type: 'tool';
|
|
17
|
+
toolCallId: string;
|
|
18
|
+
/** ACP titles may change; a native tool name is separate and may be unknown. */
|
|
19
|
+
toolName: string | null;
|
|
20
|
+
title: string;
|
|
21
|
+
kind?: ToolKind;
|
|
22
|
+
status: ToolCallStatus;
|
|
23
|
+
state: TranscriptPartState;
|
|
24
|
+
input?: unknown;
|
|
25
|
+
output?: unknown;
|
|
26
|
+
content?: ToolCallContent[];
|
|
27
|
+
locations?: ToolCallLocation[];
|
|
28
|
+
timing?: TranscriptTiming;
|
|
29
|
+
_meta?: Record<string, unknown>;
|
|
30
|
+
/** The turn ended before the provider reported a terminal tool result. */
|
|
31
|
+
incomplete?: boolean;
|
|
32
|
+
}
|
|
33
|
+
export interface TranscriptCompactionPart {
|
|
34
|
+
type: 'compaction';
|
|
35
|
+
state: TranscriptPartState;
|
|
36
|
+
phase: 'started' | 'finished';
|
|
37
|
+
trigger?: string;
|
|
38
|
+
preTokens?: number;
|
|
39
|
+
postTokens?: number;
|
|
40
|
+
durationMs?: number;
|
|
41
|
+
timing?: TranscriptTiming;
|
|
42
|
+
incomplete?: boolean;
|
|
43
|
+
}
|
|
44
|
+
export type TranscriptPart = TranscriptTextPart | TranscriptToolPart | TranscriptCompactionPart | (Exclude<ContentBlock, {
|
|
45
|
+
type: 'text';
|
|
46
|
+
}> & {
|
|
47
|
+
state: TranscriptPartState;
|
|
48
|
+
});
|
|
49
|
+
//# sourceMappingURL=transcript-parts.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transcript-parts.d.ts","sourceRoot":"","sources":["../../src/conversations/transcript-parts.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,eAAe,EAAE,gBAAgB,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AAE1H,MAAM,MAAM,mBAAmB,GAAG,SAAS,GAAG,QAAQ,GAAG,UAAU,GAAG,OAAO,CAAC;AAC9E,MAAM,WAAW,gBAAgB;IAC/B,SAAS,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IAC5B,WAAW,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IAC9B,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AACD,MAAM,WAAW,kBAAkB;IACjC,IAAI,EAAE,MAAM,GAAG,WAAW,CAAC;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,mBAAmB,CAAC;IAC3B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,gBAAgB,CAAC;CAC3B;AACD,MAAM,WAAW,kBAAkB;IACjC,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,MAAM,CAAC;IACnB,gFAAgF;IAChF,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,QAAQ,CAAC;IAChB,MAAM,EAAE,cAAc,CAAC;IACvB,KAAK,EAAE,mBAAmB,CAAC;IAC3B,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,OAAO,CAAC,EAAE,eAAe,EAAE,CAAC;IAC5B,SAAS,CAAC,EAAE,gBAAgB,EAAE,CAAC;IAC/B,MAAM,CAAC,EAAE,gBAAgB,CAAC;IAC1B,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAChC,0EAA0E;IAC1E,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB;AACD,MAAM,WAAW,wBAAwB;IACvC,IAAI,EAAE,YAAY,CAAC;IACnB,KAAK,EAAE,mBAAmB,CAAC;IAC3B,KAAK,EAAE,SAAS,GAAG,UAAU,CAAC;IAC9B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,MAAM,CAAC,EAAE,gBAAgB,CAAC;IAC1B,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB;AACD,MAAM,MAAM,cAAc,GAAG,kBAAkB,GAAG,kBAAkB,GAAG,wBAAwB,GAAG,CAAC,OAAO,CAAC,YAAY,EAAE;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC,GAAG;IAAE,KAAK,EAAE,mBAAmB,CAAA;CAAE,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transcript-parts.js","sourceRoot":"","sources":["../../src/conversations/transcript-parts.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { ToolCall, ToolCallUpdate } from '@agentclientprotocol/sdk';
|
|
2
|
+
import type { TranscriptTiming, TranscriptToolPart } from './transcript-parts.js';
|
|
3
|
+
type AnyRecord = Record<string, unknown>;
|
|
4
|
+
export declare function record(value: unknown): AnyRecord;
|
|
5
|
+
export declare function updateTiming(update: {
|
|
6
|
+
_meta?: unknown;
|
|
7
|
+
}): TranscriptTiming | undefined;
|
|
8
|
+
/** ACP tool updates are patches, including updates received before a start. */
|
|
9
|
+
export declare function reduceTranscriptTool(current: TranscriptToolPart | undefined, update: ToolCall | ToolCallUpdate): TranscriptToolPart;
|
|
10
|
+
export {};
|
|
11
|
+
//# sourceMappingURL=transcript-tools.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transcript-tools.d.ts","sourceRoot":"","sources":["../../src/conversations/transcript-tools.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AACzE,OAAO,KAAK,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAElF,KAAK,SAAS,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AACzC,wBAAgB,MAAM,CAAC,KAAK,EAAE,OAAO,GAAG,SAAS,CAEhD;AACD,wBAAgB,YAAY,CAAC,MAAM,EAAE;IAAE,KAAK,CAAC,EAAE,OAAO,CAAA;CAAE,GAAG,gBAAgB,GAAG,SAAS,CAStF;AAKD,+EAA+E;AAC/E,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,kBAAkB,GAAG,SAAS,EAAE,MAAM,EAAE,QAAQ,GAAG,cAAc,GAAG,kBAAkB,CAwBnI"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
export function record(value) {
|
|
2
|
+
return value && typeof value === 'object' && !Array.isArray(value) ? value : {};
|
|
3
|
+
}
|
|
4
|
+
export function updateTiming(update) {
|
|
5
|
+
const amalgm = record(record(update._meta)['amalgm']);
|
|
6
|
+
const tool = record(amalgm['tool']);
|
|
7
|
+
const native = record(amalgm['native']);
|
|
8
|
+
if (Object.keys(record(tool['timing'])).length)
|
|
9
|
+
return tool['timing'];
|
|
10
|
+
const ts = native['timestampMs'];
|
|
11
|
+
if (typeof ts !== 'number' || !Number.isFinite(ts))
|
|
12
|
+
return undefined;
|
|
13
|
+
const terminal = native['type'] === 'tool.completed';
|
|
14
|
+
return terminal ? { completedAt: new Date(ts).toISOString() } : { startedAt: new Date(ts).toISOString() };
|
|
15
|
+
}
|
|
16
|
+
function terminal(status) {
|
|
17
|
+
return status === 'completed' || status === 'failed';
|
|
18
|
+
}
|
|
19
|
+
/** ACP tool updates are patches, including updates received before a start. */
|
|
20
|
+
export function reduceTranscriptTool(current, update) {
|
|
21
|
+
const meta = { ...current?._meta, ...record(update._meta) };
|
|
22
|
+
const priorAmalgm = record(current?._meta?.['amalgm']);
|
|
23
|
+
const amalgm = record(record(update._meta)['amalgm']);
|
|
24
|
+
const tool = { ...record(priorAmalgm['tool']), ...record(amalgm['tool']) };
|
|
25
|
+
if (Object.keys(priorAmalgm).length || Object.keys(amalgm).length)
|
|
26
|
+
meta['amalgm'] = { ...priorAmalgm, ...amalgm, tool };
|
|
27
|
+
const toolName = typeof tool['name'] === 'string' && tool['name'] ? tool['name'] : current?.toolName ?? null;
|
|
28
|
+
const status = current && terminal(current.status) ? current.status : update.status ?? current?.status ?? 'pending';
|
|
29
|
+
const timing = { ...current?.timing, ...updateTiming(update) };
|
|
30
|
+
if (current?.timing?.startedAt !== undefined)
|
|
31
|
+
timing.startedAt = current.timing.startedAt;
|
|
32
|
+
return {
|
|
33
|
+
...current,
|
|
34
|
+
type: 'tool', toolCallId: update.toolCallId, toolName,
|
|
35
|
+
title: update.title || current?.title || toolName || 'Tool',
|
|
36
|
+
...(update.kind == null ? {} : { kind: update.kind }),
|
|
37
|
+
status,
|
|
38
|
+
state: status === 'completed' ? 'complete' : status === 'failed' ? 'error' : status === 'pending' ? 'pending' : 'active',
|
|
39
|
+
...(update.rawInput === undefined ? {} : { input: update.rawInput }),
|
|
40
|
+
...(update.rawOutput === undefined ? {} : { output: update.rawOutput }),
|
|
41
|
+
...(update.content == null ? {} : { content: update.content }),
|
|
42
|
+
...(update.locations == null ? {} : { locations: update.locations }),
|
|
43
|
+
...(Object.keys(timing).length ? { timing } : {}),
|
|
44
|
+
...(Object.keys(meta).length ? { _meta: meta } : {}),
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
//# sourceMappingURL=transcript-tools.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transcript-tools.js","sourceRoot":"","sources":["../../src/conversations/transcript-tools.ts"],"names":[],"mappings":"AAIA,MAAM,UAAU,MAAM,CAAC,KAAc;IACnC,OAAO,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAkB,CAAC,CAAC,CAAC,EAAE,CAAC;AAC/F,CAAC;AACD,MAAM,UAAU,YAAY,CAAC,MAA2B;IACtD,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC;IACtD,MAAM,IAAI,GAAG,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC;IACpC,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC;IACxC,IAAI,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,MAAM;QAAE,OAAO,IAAI,CAAC,QAAQ,CAAqB,CAAC;IAC1F,MAAM,EAAE,GAAG,MAAM,CAAC,aAAa,CAAC,CAAC;IACjC,IAAI,OAAO,EAAE,KAAK,QAAQ,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC;QAAE,OAAO,SAAS,CAAC;IACrE,MAAM,QAAQ,GAAG,MAAM,CAAC,MAAM,C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CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,SAAS,EAAE,CAAC;QACvE,GAAG,CAAC,MAAM,CAAC,OAAO,IAAI,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,MAAM,CAAC,OAAO,EAAE,CAAC;QAC9D,GAAG,CAAC,MAAM,CAAC,SAAS,IAAI,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,MAAM,CAAC,SAAS,EAAE,CAAC;QACpE,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QACjD,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KACrD,CAAC;AACJ,CAAC"}
|
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
import type { SessionUpdate } from '@agentclientprotocol/sdk';
|
|
2
|
+
import type { TranscriptPart } from './transcript-parts.js';
|
|
2
3
|
export interface AcpTranscriptState {
|
|
3
|
-
parts:
|
|
4
|
+
parts: TranscriptPart[];
|
|
4
5
|
textPartIndex: number | null;
|
|
5
6
|
reasoningPartIndex: number | null;
|
|
6
7
|
toolPartIndexById: Map<string, number>;
|
|
8
|
+
compactionPartIndex: number | null;
|
|
7
9
|
}
|
|
8
10
|
export declare function createAcpTranscriptState(): AcpTranscriptState;
|
|
9
|
-
/**
|
|
10
|
-
export declare function applyAcpTranscriptUpdate(state: AcpTranscriptState,
|
|
11
|
-
export declare function finalizeAcpTranscript(state: AcpTranscriptState, failed?: boolean): readonly
|
|
11
|
+
/** The same provider-independent ACP projection serves live, replay, and storage. */
|
|
12
|
+
export declare function applyAcpTranscriptUpdate(state: AcpTranscriptState, update: SessionUpdate): void;
|
|
13
|
+
export declare function finalizeAcpTranscript(state: AcpTranscriptState, failed?: boolean): readonly TranscriptPart[];
|
|
12
14
|
export declare function promptContentPlain(parts: readonly unknown[]): string | null;
|
|
13
15
|
//# sourceMappingURL=transcript.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transcript.d.ts","sourceRoot":"","sources":["../../src/conversations/transcript.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;
|
|
1
|
+
{"version":3,"file":"transcript.d.ts","sourceRoot":"","sources":["../../src/conversations/transcript.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAC9D,OAAO,KAAK,EAAE,cAAc,EAAoE,MAAM,uBAAuB,CAAC;AAG9H,MAAM,WAAW,kBAAkB;IACjC,KAAK,EAAE,cAAc,EAAE,CAAC;IACxB,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,kBAAkB,EAAE,MAAM,GAAG,IAAI,CAAC;IAClC,iBAAiB,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACvC,mBAAmB,EAAE,MAAM,GAAG,IAAI,CAAC;CACpC;AAED,wBAAgB,wBAAwB,IAAI,kBAAkB,CAE7D;AA2BD,qFAAqF;AACrF,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,kBAAkB,EAAE,MAAM,EAAE,aAAa,GAAG,IAAI,CA6C/F;AAED,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,kBAAkB,EAAE,MAAM,UAAQ,GAAG,SAAS,cAAc,EAAE,CAK1G;AAED,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,SAAS,OAAO,EAAE,GAAG,MAAM,GAAG,IAAI,CAI3E"}
|