@amalgm/chat 0.2.8 → 0.2.9-main.34746990150
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 +94 -41
- package/README.md +17 -4
- package/dist/acp/projection.d.ts +8 -0
- package/dist/acp/projection.d.ts.map +1 -1
- package/dist/acp/projection.js +10 -3
- 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 +38 -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 +5 -4
- package/dist/conversations/transcript.d.ts.map +1 -1
- package/dist/conversations/transcript.js +43 -143
- package/dist/conversations/transcript.js.map +1 -1
- package/dist/conversations/types.d.ts +19 -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 +72 -72
- package/dist/events/schema.js +16 -16
- package/dist/events/schema.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 +142 -142
- package/dist/normalizers/claude.d.ts.map +1 -1
- package/dist/normalizers/claude.js +23 -37
- package/dist/normalizers/claude.js.map +1 -1
- package/dist/normalizers/codex.d.ts +71 -71
- package/dist/normalizers/codex.d.ts.map +1 -1
- package/dist/normalizers/codex.js +12 -24
- 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.map +1 -1
- package/dist/normalizers/opencode.js +9 -6
- package/dist/normalizers/opencode.js.map +1 -1
- package/dist/normalizers/pi.d.ts.map +1 -1
- package/dist/normalizers/pi.js +27 -14
- package/dist/normalizers/pi.js.map +1 -1
- package/dist/sessions/chat.d.ts +5 -5
- package/dist/sessions/chat.d.ts.map +1 -1
- package/dist/sessions/chat.js +51 -19
- 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 +8 -9
- package/dist/usage/normalize.d.ts.map +1 -1
- package/dist/usage/normalize.js +20 -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/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/host/adapters/acp-prompt.js +36 -0
- package/host/adapters/acp.js +50 -71
- package/host/adapters/attachments.js +37 -0
- package/host/adapters/claude.js +9 -2
- package/host/adapters/codex.js +36 -18
- package/host/adapters/cursor.js +72 -99
- package/host/adapters/opencode.js +39 -25
- package/host/adapters/pi.js +24 -19
- package/host/adapters/prompt.js +13 -21
- package/host/adapters/provider-url.js +8 -0
- package/host/auth.js +10 -9
- package/host/http.js +3 -2
- package/host/model-resolution.js +7 -0
- package/host/native-contract.js +4 -3
- package/host/native-runtime.js +25 -11
- package/host/sqlite/index.d.ts +2 -0
- package/host/sqlite/index.js +48 -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/package.json +26 -2
- 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
|
|
@@ -105,6 +112,8 @@ automations, and third-party apps must all use the same public SDK.
|
|
|
105
112
|
28. The official ACP `McpServer` union is the one prepared tool-injection
|
|
106
113
|
shape. Toolbox selections resolve to `McpServer[]`; native adapters only
|
|
107
114
|
project that exact list into provider configuration.
|
|
115
|
+
Native connected apps, plugins, and ambient MCP configuration cannot add
|
|
116
|
+
unselected servers to a prepared execution.
|
|
108
117
|
29. Amalgm products exposed to agents are ordinary selected MCP servers. Tools,
|
|
109
118
|
Agents, Chat, and future platform capabilities receive no ambient or
|
|
110
119
|
provider-specific injection path.
|
|
@@ -112,10 +121,14 @@ automations, and third-party apps must all use the same public SDK.
|
|
|
112
121
|
instruction bundle. Adapters consume that prepared bundle through a native
|
|
113
122
|
system/developer-instruction channel; they never reread instruction sources
|
|
114
123
|
or prepend instructions to ACP user prompt content.
|
|
115
|
-
|
|
124
|
+
Machine instructions come from the host-selected Amalgm root; unreadable
|
|
125
|
+
instruction sources fail preparation rather than silently removing guidance.
|
|
126
|
+
31. Stable ACP has no client-supplied system-instruction field. A generic ACP agent
|
|
116
127
|
receives prepared instructions only through a namespaced `_meta` extension
|
|
117
128
|
it advertised during initialization; otherwise non-empty instructions are
|
|
118
129
|
rejected as unsupported.
|
|
130
|
+
The native Cursor adapter uses an immutable managed rules directory for
|
|
131
|
+
instructions and ACP's session cwd for the execution workspace.
|
|
119
132
|
32. A tool selection revision is the exact immutable deployment-head digest
|
|
120
133
|
supplied by Tools, not a machine-local database counter. Preparation must
|
|
121
134
|
resolve that digest or fail; once prepared, the resulting official ACP
|
|
@@ -145,6 +158,30 @@ automations, and third-party apps must all use the same public SDK.
|
|
|
145
158
|
admitted message creates that exact conversation; every later message
|
|
146
159
|
resumes it, and the provider message id is the stable turn id. Chat never
|
|
147
160
|
infers a thread from a subject or chooses a recipient.
|
|
161
|
+
39. Provider failure is a turn outcome, never an ACP transcript part and never
|
|
162
|
+
successful end-of-stream. Committed output survives a later provider failure.
|
|
163
|
+
40. One conversation admits one provider session and one turn at a time, including
|
|
164
|
+
while asynchronous creation or input persistence is pending.
|
|
165
|
+
41. An execution change cannot erase conversation context. Without a proven native
|
|
166
|
+
checkpoint, the host supplies committed history as an explicit ACP resource.
|
|
167
|
+
42. Transcript activity has one text, reasoning, or tool shape and one state
|
|
168
|
+
vocabulary: pending, active, complete, error. A tool id identifies one part
|
|
169
|
+
throughout a turn; later detail cannot erase its identity, result, or terminal
|
|
170
|
+
state. Titles and optional timing are presentation facts, not tool identity.
|
|
171
|
+
Usage and compaction are session telemetry, not transcript content.
|
|
172
|
+
43. Attachment bytes belong to the accepted ACP prompt. A native adapter that
|
|
173
|
+
needs a filesystem path receives a host materialization of those bytes;
|
|
174
|
+
that derived file is never the durable source of truth.
|
|
175
|
+
44. A managed provider home belongs to one installation and one auth authority.
|
|
176
|
+
Child environments contain standard process and network settings plus
|
|
177
|
+
explicitly prepared credentials; they never inherit host service secrets.
|
|
178
|
+
Native adapters project the configured provider base onto their SDK's API
|
|
179
|
+
path; an SDK's appended path cannot change the selected authority.
|
|
180
|
+
Subscription, platform, and distinct BYOK credentials cannot share persisted
|
|
181
|
+
provider configuration or login material.
|
|
182
|
+
45. A caller-supplied conversation id is an idempotency key within its owner
|
|
183
|
+
and installation. Retrying start rejoins that conversation, including after
|
|
184
|
+
a provider launch failed; it never replaces accepted history.
|
|
148
185
|
|
|
149
186
|
## North-star proof
|
|
150
187
|
|
|
@@ -164,41 +201,57 @@ require a new event grammar, transcript reducer, or UI data model.
|
|
|
164
201
|
|
|
165
202
|
## Current truth
|
|
166
203
|
|
|
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
|
-
not
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
204
|
+
The public SDK has one high-level `Chat` capability, official ACP prompt
|
|
205
|
+
content, immutable prepared executions, and durable official ACP updates. The
|
|
206
|
+
Node host composes one owner-scoped SQLite journal and one HTTP/SSE protocol.
|
|
207
|
+
Input commits before provider invocation, output and usage commit before fanout,
|
|
208
|
+
and reconnect reads the same journal. Disconnect leaves the runtime pump alive;
|
|
209
|
+
uncertain work after restart becomes interrupted. Structured provider failures
|
|
210
|
+
retain partial output and remain failed in the stream and saved history.
|
|
211
|
+
|
|
212
|
+
Claude Code, Codex, Cursor, OpenCode, Pi, and a generic OpenCode ACP process have
|
|
213
|
+
passed real text, image, file, and selected MCP-tool turns through the local
|
|
214
|
+
Shell. The paired UI uses the same public client and transcript reducer. Saved
|
|
215
|
+
execution choices survive reload, and continuation survives auth changes through
|
|
216
|
+
explicit committed-history delivery when a native checkpoint cannot be reused.
|
|
217
|
+
The dated evidence and account-specific limits are recorded in
|
|
218
|
+
`docs/chat-roadmap.md`.
|
|
219
|
+
|
|
220
|
+
All five native harnesses receive the same selected seven-product MCP loadout
|
|
221
|
+
and recover prepared machine instructions in real turns. Cursor's current ACP
|
|
222
|
+
implementation omits MCP names, inputs and result bodies from tool updates and
|
|
223
|
+
sometimes reports an upstream error as ordinary agent text plus `end_turn`.
|
|
224
|
+
Those omissions remain explicit upstream parity gaps; Chat neither invents
|
|
225
|
+
tool identity nor classifies arbitrary agent prose as a structured failure.
|
|
226
|
+
|
|
227
|
+
Native usage observations and optional ACP prompt usage persist with their raw
|
|
228
|
+
source. Turn totals, cache and reasoning buckets, reported cost, and current
|
|
229
|
+
context remain separate facts; unknown values remain null. Providers that do
|
|
230
|
+
not expose model-step identity cannot populate an exact per-step ledger.
|
|
231
|
+
|
|
232
|
+
The remote gateway/Live authority does not yet expose the conversation catalog
|
|
233
|
+
and change stream; Live/R2 synchronization is not connected. Durable queued
|
|
234
|
+
turns, identity-targeted abort, and application-stream permission interaction
|
|
235
|
+
remain separate work described in the acceptance plan. Every attachment form
|
|
236
|
+
has not been exercised against every provider. Generic ACP admission uses an
|
|
237
|
+
immutable launch descriptor, and non-empty system instructions require the
|
|
238
|
+
agent to advertise the Amalgm session-instructions extension. The machine/project
|
|
239
|
+
instruction-source revision is not yet represented in control-plane execution
|
|
240
|
+
selection. Amp, Gemini CLI, and Kiro were not installed for individual acceptance.
|
|
203
241
|
|
|
204
242
|
The public contracts live in `docs/contracts/` and the shipped Chat skill.
|
|
243
|
+
|
|
244
|
+
## Managed package delivery
|
|
245
|
+
|
|
246
|
+
Managed package delivery starts from a clean, exact main or preview source
|
|
247
|
+
commit. The workflow occurrence supplies only its generated version and source
|
|
248
|
+
record; tests run against those candidate inputs before packing. Every native
|
|
249
|
+
gate and publication use that same tarball and integrity. A candidate tag makes
|
|
250
|
+
bytes available to release assembly; it never promotes an installed runtime.
|
|
251
|
+
Release tooling remains available inside each owner repository so a developer
|
|
252
|
+
or CI job never needs access to another private product repository.
|
|
253
|
+
Registry credentials are available only to the final protected publication job,
|
|
254
|
+
after every native examination proves the exact candidate bytes.
|
|
255
|
+
Native consumers install the archive as a dependency, so SDK development
|
|
256
|
+
dependencies never become an end-user installation requirement.
|
|
257
|
+
Each admitted owner gate proves its actual checkout equals the managed source.
|
package/README.md
CHANGED
|
@@ -14,6 +14,9 @@ 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
|
+
This chat's completed work, acceptance evidence and remaining priorities are
|
|
18
|
+
tracked in [docs/chat-roadmap.md](docs/chat-roadmap.md).
|
|
19
|
+
|
|
17
20
|
```ts
|
|
18
21
|
import { Chat } from "@amalgm/chat";
|
|
19
22
|
import {
|
|
@@ -103,7 +106,17 @@ npm test
|
|
|
103
106
|
npm pack --dry-run
|
|
104
107
|
```
|
|
105
108
|
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
109
|
+
Managed npm delivery uses `.github/workflows/publish-package.yml` after the
|
|
110
|
+
exact main/preview owner checks pass. The occurrence generates a unique
|
|
111
|
+
prerelease version and records its source SHA; it reruns the owner suite, packs
|
|
112
|
+
once, and installs that tarball on Linux, macOS and Windows before publication.
|
|
113
|
+
The `candidate-main`/`candidate-preview` tags are release-assembly inputs and
|
|
114
|
+
never select installed runtimes. `package.json` declares this owner's gates,
|
|
115
|
+
CLI probes, peer-only exports and lifecycle permissions. The standalone runner
|
|
116
|
+
under `scripts/release/` is intentionally copied across owners to preserve
|
|
117
|
+
private repository access boundaries. The final publish step uses the `NPM_TOKEN`
|
|
118
|
+
secret in the `npm-release` environment. Where npm trusted publishing is
|
|
119
|
+
configured for this repository's `publish-package.yml` and that environment,
|
|
120
|
+
the token can be omitted. Authentication does not replace native certification,
|
|
121
|
+
exact source records or artifact integrity; private source repositories do not
|
|
122
|
+
receive npm's public-source provenance.
|
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,CAAC;IACxB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,aAAa;IAC5B,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE;QACN,IAAI,EAAE,MAAM,CAAC;QACb,WAAW,EAAE,MAAM,CAAC;QACpB,GAAG,CAAC,EAAE,OAAO,CAAC;KACf,CA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,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,9 +132,6 @@ 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
|
}
|
|
@@ -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,MA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,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,38 @@
|
|
|
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 type TranscriptPart = TranscriptTextPart | TranscriptToolPart | (Exclude<ContentBlock, {
|
|
34
|
+
type: 'text';
|
|
35
|
+
}> & {
|
|
36
|
+
state: TranscriptPartState;
|
|
37
|
+
});
|
|
38
|
+
//# 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,GA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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,CAA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EAAE,CAAC;QACpE,GAAG,CAAC,MAAM,CAAC,SAAS,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,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,14 @@
|
|
|
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>;
|
|
7
8
|
}
|
|
8
9
|
export declare function createAcpTranscriptState(): AcpTranscriptState;
|
|
9
|
-
/**
|
|
10
|
-
export declare function applyAcpTranscriptUpdate(state: AcpTranscriptState,
|
|
11
|
-
export declare function finalizeAcpTranscript(state: AcpTranscriptState, failed?: boolean): readonly
|
|
10
|
+
/** The same provider-independent ACP projection serves live, replay, and storage. */
|
|
11
|
+
export declare function applyAcpTranscriptUpdate(state: AcpTranscriptState, update: SessionUpdate): void;
|
|
12
|
+
export declare function finalizeAcpTranscript(state: AcpTranscriptState, failed?: boolean): readonly TranscriptPart[];
|
|
12
13
|
export declare function promptContentPlain(parts: readonly unknown[]): string | null;
|
|
13
14
|
//# 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,EAA0C,MAAM,uBAAuB,CAAC;AAGpG,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;CACxC;AAED,wBAAgB,wBAAwB,IAAI,kBAAkB,CAE7D;AA2BD,qFAAqF;AACrF,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,kBAAkB,EAAE,MAAM,EAAE,aAAa,GAAG,IAAI,CAwB/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"}
|