@amalgm/chat 0.1.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/PURPOSE.md +107 -0
- package/README.md +41 -0
- package/dist/contract/chat-input.d.ts +144 -0
- package/dist/contract/chat-input.d.ts.map +1 -0
- package/dist/contract/chat-input.js +261 -0
- package/dist/contract/chat-input.js.map +1 -0
- package/dist/contract/create.d.ts +191 -0
- package/dist/contract/create.d.ts.map +1 -0
- package/dist/contract/create.js +249 -0
- package/dist/contract/create.js.map +1 -0
- package/dist/contract/freeze.d.ts +85 -0
- package/dist/contract/freeze.d.ts.map +1 -0
- package/dist/contract/freeze.js +151 -0
- package/dist/contract/freeze.js.map +1 -0
- package/dist/contract/harnesses.d.ts +21 -0
- package/dist/contract/harnesses.d.ts.map +1 -0
- package/dist/contract/harnesses.js +39 -0
- package/dist/contract/harnesses.js.map +1 -0
- package/dist/contract/index.d.ts +17 -0
- package/dist/contract/index.d.ts.map +1 -0
- package/dist/contract/index.js +17 -0
- package/dist/contract/index.js.map +1 -0
- package/dist/contract/input.d.ts +45 -0
- package/dist/contract/input.d.ts.map +1 -0
- package/dist/contract/input.js +78 -0
- package/dist/contract/input.js.map +1 -0
- package/dist/contract/models.d.ts +57 -0
- package/dist/contract/models.d.ts.map +1 -0
- package/dist/contract/models.js +380 -0
- package/dist/contract/models.js.map +1 -0
- package/dist/contract/payload-merge.d.ts +76 -0
- package/dist/contract/payload-merge.d.ts.map +1 -0
- package/dist/contract/payload-merge.js +215 -0
- package/dist/contract/payload-merge.js.map +1 -0
- package/dist/events/constructors.d.ts +53 -0
- package/dist/events/constructors.d.ts.map +1 -0
- package/dist/events/constructors.js +217 -0
- package/dist/events/constructors.js.map +1 -0
- package/dist/events/index.d.ts +12 -0
- package/dist/events/index.d.ts.map +1 -0
- package/dist/events/index.js +12 -0
- package/dist/events/index.js.map +1 -0
- package/dist/events/schema.d.ts +455 -0
- package/dist/events/schema.d.ts.map +1 -0
- package/dist/events/schema.js +228 -0
- package/dist/events/schema.js.map +1 -0
- package/dist/events/tool-display.d.ts +22 -0
- package/dist/events/tool-display.d.ts.map +1 -0
- package/dist/events/tool-display.js +60 -0
- package/dist/events/tool-display.js.map +1 -0
- package/dist/events/tool-shape.d.ts +48 -0
- package/dist/events/tool-shape.d.ts.map +1 -0
- package/dist/events/tool-shape.js +225 -0
- package/dist/events/tool-shape.js.map +1 -0
- package/dist/index.d.ts +27 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +26 -0
- package/dist/index.js.map +1 -0
- package/dist/normalizers/claude.d.ts +628 -0
- package/dist/normalizers/claude.d.ts.map +1 -0
- package/dist/normalizers/claude.js +603 -0
- package/dist/normalizers/claude.js.map +1 -0
- package/dist/normalizers/codex.d.ts +352 -0
- package/dist/normalizers/codex.d.ts.map +1 -0
- package/dist/normalizers/codex.js +485 -0
- package/dist/normalizers/codex.js.map +1 -0
- package/dist/normalizers/cursor.d.ts +34 -0
- package/dist/normalizers/cursor.d.ts.map +1 -0
- package/dist/normalizers/cursor.js +197 -0
- package/dist/normalizers/cursor.js.map +1 -0
- package/dist/normalizers/index.d.ts +13 -0
- package/dist/normalizers/index.d.ts.map +1 -0
- package/dist/normalizers/index.js +13 -0
- package/dist/normalizers/index.js.map +1 -0
- package/dist/normalizers/opencode.d.ts +81 -0
- package/dist/normalizers/opencode.d.ts.map +1 -0
- package/dist/normalizers/opencode.js +640 -0
- package/dist/normalizers/opencode.js.map +1 -0
- package/dist/normalizers/pi.d.ts +28 -0
- package/dist/normalizers/pi.d.ts.map +1 -0
- package/dist/normalizers/pi.js +160 -0
- package/dist/normalizers/pi.js.map +1 -0
- package/dist/ports.d.ts +14 -0
- package/dist/ports.d.ts.map +1 -0
- package/dist/ports.js +7 -0
- package/dist/ports.js.map +1 -0
- package/dist/transcript/index.d.ts +14 -0
- package/dist/transcript/index.d.ts.map +1 -0
- package/dist/transcript/index.js +12 -0
- package/dist/transcript/index.js.map +1 -0
- package/dist/transcript/message-reducer.d.ts +167 -0
- package/dist/transcript/message-reducer.d.ts.map +1 -0
- package/dist/transcript/message-reducer.js +400 -0
- package/dist/transcript/message-reducer.js.map +1 -0
- package/dist/transcript/part-accumulator.d.ts +24 -0
- package/dist/transcript/part-accumulator.d.ts.map +1 -0
- package/dist/transcript/part-accumulator.js +30 -0
- package/dist/transcript/part-accumulator.js.map +1 -0
- package/dist/transcript/tool-display.d.ts +14 -0
- package/dist/transcript/tool-display.d.ts.map +1 -0
- package/dist/transcript/tool-display.js +125 -0
- package/dist/transcript/tool-display.js.map +1 -0
- package/dist/transcript/tool-shape.d.ts +34 -0
- package/dist/transcript/tool-shape.d.ts.map +1 -0
- package/dist/transcript/tool-shape.js +216 -0
- package/dist/transcript/tool-shape.js.map +1 -0
- package/dist/turns/index.d.ts +11 -0
- package/dist/turns/index.d.ts.map +1 -0
- package/dist/turns/index.js +11 -0
- package/dist/turns/index.js.map +1 -0
- package/dist/turns/queries.d.ts +36 -0
- package/dist/turns/queries.d.ts.map +1 -0
- package/dist/turns/queries.js +37 -0
- package/dist/turns/queries.js.map +1 -0
- package/dist/turns/replay.d.ts +105 -0
- package/dist/turns/replay.d.ts.map +1 -0
- package/dist/turns/replay.js +163 -0
- package/dist/turns/replay.js.map +1 -0
- package/dist/turns/status.d.ts +49 -0
- package/dist/turns/status.d.ts.map +1 -0
- package/dist/turns/status.js +56 -0
- package/dist/turns/status.js.map +1 -0
- package/dist/turns/turn-store.d.ts +109 -0
- package/dist/turns/turn-store.d.ts.map +1 -0
- package/dist/turns/turn-store.js +169 -0
- package/dist/turns/turn-store.js.map +1 -0
- package/dist/usage/finalize.d.ts +57 -0
- package/dist/usage/finalize.d.ts.map +1 -0
- package/dist/usage/finalize.js +139 -0
- package/dist/usage/finalize.js.map +1 -0
- package/dist/usage/index.d.ts +11 -0
- package/dist/usage/index.d.ts.map +1 -0
- package/dist/usage/index.js +11 -0
- package/dist/usage/index.js.map +1 -0
- package/dist/usage/model-catalog.d.ts +50 -0
- package/dist/usage/model-catalog.d.ts.map +1 -0
- package/dist/usage/model-catalog.js +344 -0
- package/dist/usage/model-catalog.js.map +1 -0
- package/dist/usage/normalize.d.ts +103 -0
- package/dist/usage/normalize.d.ts.map +1 -0
- package/dist/usage/normalize.js +71 -0
- package/dist/usage/normalize.js.map +1 -0
- package/dist/usage/ports.d.ts +141 -0
- package/dist/usage/ports.d.ts.map +1 -0
- package/dist/usage/ports.js +113 -0
- package/dist/usage/ports.js.map +1 -0
- package/dist/usage/tokens.d.ts +79 -0
- package/dist/usage/tokens.d.ts.map +1 -0
- package/dist/usage/tokens.js +98 -0
- package/dist/usage/tokens.js.map +1 -0
- package/dist/warm/client-cache.d.ts +47 -0
- package/dist/warm/client-cache.d.ts.map +1 -0
- package/dist/warm/client-cache.js +48 -0
- package/dist/warm/client-cache.js.map +1 -0
- package/dist/warm/envelope-cache.d.ts +79 -0
- package/dist/warm/envelope-cache.d.ts.map +1 -0
- package/dist/warm/envelope-cache.js +85 -0
- package/dist/warm/envelope-cache.js.map +1 -0
- package/dist/warm/index.d.ts +16 -0
- package/dist/warm/index.d.ts.map +1 -0
- package/dist/warm/index.js +11 -0
- package/dist/warm/index.js.map +1 -0
- package/dist/warm/payload.d.ts +137 -0
- package/dist/warm/payload.d.ts.map +1 -0
- package/dist/warm/payload.js +112 -0
- package/dist/warm/payload.js.map +1 -0
- package/dist/warm/revision.d.ts +70 -0
- package/dist/warm/revision.d.ts.map +1 -0
- package/dist/warm/revision.js +63 -0
- package/dist/warm/revision.js.map +1 -0
- package/dist/warm/store-policy.d.ts +57 -0
- package/dist/warm/store-policy.d.ts.map +1 -0
- package/dist/warm/store-policy.js +89 -0
- package/dist/warm/store-policy.js.map +1 -0
- package/dist/wire/frames.d.ts +208 -0
- package/dist/wire/frames.d.ts.map +1 -0
- package/dist/wire/frames.js +245 -0
- package/dist/wire/frames.js.map +1 -0
- package/dist/wire/index.d.ts +7 -0
- package/dist/wire/index.d.ts.map +1 -0
- package/dist/wire/index.js +7 -0
- package/dist/wire/index.js.map +1 -0
- package/package.json +72 -0
package/PURPOSE.md
ADDED
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
# @amalgm/chat — the conversation SDK
|
|
2
|
+
|
|
3
|
+
Status: extraction in progress · founded 2026-08-06 · source of truth for laws:
|
|
4
|
+
`amalgm-engine/runtime/scripts/chat-core/` (production until cutover)
|
|
5
|
+
|
|
6
|
+
## Purpose
|
|
7
|
+
|
|
8
|
+
Chat is Amalgm's central product surface: every user message, every agent
|
|
9
|
+
turn, every streamed token flows through one pipeline. This repo owns that
|
|
10
|
+
pipeline's **laws** — what a turn is, what events mean, what a transcript
|
|
11
|
+
contains, how a send is prepared and billed — as a standalone SDK any host
|
|
12
|
+
can run: the engine runtime today, the Fly workers, the channels bridge
|
|
13
|
+
(email/Telegram/WhatsApp/Slack), and third-party apps tomorrow.
|
|
14
|
+
|
|
15
|
+
**Membership test:** a rule belongs here if it is a law of the conversation
|
|
16
|
+
itself — independent of any particular host, harness, or UI. If it spawns a
|
|
17
|
+
process, opens a socket, or touches a disk, it is a host adapter behind a
|
|
18
|
+
port, not a law.
|
|
19
|
+
|
|
20
|
+
## The seven jobs
|
|
21
|
+
|
|
22
|
+
1. **The event grammar.** One canonical vocabulary (`text.delta` …
|
|
23
|
+
`usage.final` … `done`) that every harness's native events are translated
|
|
24
|
+
into, schema-validated, and one projection of it onto the wire (the
|
|
25
|
+
ACP-shaped SSE frames). The grammar is the product's spine.
|
|
26
|
+
2. **Normalization.** Per-harness translators (claude, codex, opencode,
|
|
27
|
+
cursor, pi) from native protocol events into the grammar. Pure functions;
|
|
28
|
+
every claim traceable to a recorded fixture.
|
|
29
|
+
3. **Transcript truth.** One message reducer shared by both ends of the
|
|
30
|
+
wire: what the user watched streaming is byte-shape-identical to what
|
|
31
|
+
persists and reloads. Parts (text / reasoning / tool / image /
|
|
32
|
+
compaction) are the transcript's atoms.
|
|
33
|
+
4. **The turn machine.** One active turn per session; the in-memory chunk
|
|
34
|
+
log (TurnStore) that makes reconnect/replay possible; the status
|
|
35
|
+
vocabulary (`streaming → cancelling → complete | cancelled | error |
|
|
36
|
+
save_failed | aborted`); the finalization order that never loses a
|
|
37
|
+
transcript silently.
|
|
38
|
+
5. **The frozen contract.** A session's identity — harness, auth, model,
|
|
39
|
+
cwd, instructions, tool set — resolves once at creation and freezes.
|
|
40
|
+
Model names canonicalize through four deliberate identities (display /
|
|
41
|
+
runtime-CLI / billing / context-profile). Changing frozen fields means a
|
|
42
|
+
new session; that is what makes billing identity trustworthy.
|
|
43
|
+
6. **Warm payloads.** The send path carries ids, not configuration: the full
|
|
44
|
+
launch payload is published to the machine's local store while the user
|
|
45
|
+
types (revision-hashed, 409 on mismatch), and the machine record is the
|
|
46
|
+
authority — client-supplied billing-relevant fields are deleted, never
|
|
47
|
+
trusted.
|
|
48
|
+
7. **The usage law.** Token-list algebra, per-harness exactness rules,
|
|
49
|
+
the ownership fork (amalgm billing → proxy meters via egress; byok /
|
|
50
|
+
provider_auth → local logging), and the cost rules (unknown cost is
|
|
51
|
+
null, never zero).
|
|
52
|
+
|
|
53
|
+
## Axioms
|
|
54
|
+
|
|
55
|
+
1. **The engine copy is production truth until cutover.** Laws here are
|
|
56
|
+
ported byte-exact from `amalgm-engine/runtime/scripts/chat-core/`;
|
|
57
|
+
deliberate deviations carry an `engineParity: false` marker and a reason.
|
|
58
|
+
2. **One reducer, both ends of the wire.** The engine's part accumulation
|
|
59
|
+
and the browser's live rendering are the same algorithm. Divergence is a
|
|
60
|
+
bug by definition.
|
|
61
|
+
3. **The wire grammar is a public contract.** Tasks, subagents, Slack
|
|
62
|
+
inbound, email inbound, and hosted apps already speak `POST /chat` + the
|
|
63
|
+
SSE grammar. Evolution is additive; a removed or reshaped frame is a
|
|
64
|
+
breaking change to systems that never imported this package.
|
|
65
|
+
4. **Send carries ids, not payloads.** The machine payload store is the
|
|
66
|
+
authority; precedence is payload record > chatInput > raw body; the
|
|
67
|
+
browser is never trusted for billing-relevant fields.
|
|
68
|
+
5. **Session identity freezes at creation.** The frozen-contract fingerprint
|
|
69
|
+
decides; a turn whose frozen fields drifted continues the old contract.
|
|
70
|
+
6. **Storage is a choice; the meter is not.** Conversation persistence can
|
|
71
|
+
be declined (`storage: 'none'`); usage logging on amalgm billing cannot.
|
|
72
|
+
7. **The host supplies effects.** Nothing in `src/` imports `node:*`, reads
|
|
73
|
+
`process.env`, or calls `Date.now()`/`Math.random()` directly — clocks,
|
|
74
|
+
crypto, stores, transports arrive as injected ports.
|
|
75
|
+
8. **Contracts are byte-exact.** Error strings, header names, status
|
|
76
|
+
vocabularies, thresholds, and merge precedence match the engine to the
|
|
77
|
+
byte; exams pin them.
|
|
78
|
+
9. **One runtime dependency: zod.** The event grammar's executable form is
|
|
79
|
+
the same validator the engine runs — a hand-rolled clone would make
|
|
80
|
+
parity a fiction. Nothing else gets in.
|
|
81
|
+
10. **Amalgm dogfoods its own SDK.** The end state (spec §10): ChatView's
|
|
82
|
+
data layer imports nothing but `@amalgm/chat`; the engine host mounts
|
|
83
|
+
these laws instead of containing them.
|
|
84
|
+
|
|
85
|
+
## Five surfaces
|
|
86
|
+
|
|
87
|
+
| Surface | Form | Status |
|
|
88
|
+
|---|---|---|
|
|
89
|
+
| SDK | `@amalgm/chat` (this package's `src/`) | porting |
|
|
90
|
+
| API | router factory a host mounts | after SDK |
|
|
91
|
+
| CLI | `amalgm-chat` diagnostic commands | after SDK |
|
|
92
|
+
| MCP | tool definitions + dispatch | after SDK |
|
|
93
|
+
| Skill | `skills/chat/SKILL.md` | after SDK |
|
|
94
|
+
|
|
95
|
+
All doors are thin: one behavior in `src/`, adapters around it.
|
|
96
|
+
|
|
97
|
+
## The prior art this repo unifies
|
|
98
|
+
|
|
99
|
+
- `docs/chat-sdk-spec.md` — the locked public-API spec (2026-07-13).
|
|
100
|
+
- `docs/chat-internals-and-plans.md` — the canonical pipeline map.
|
|
101
|
+
- `amalgm-engine/packages/chat/` — the milestone-1 client prototype.
|
|
102
|
+
- The orphaned 84-exam suite (`amalgm-ui/scripts/chat-core/tests/run.js`) —
|
|
103
|
+
the richest chat test suite ever written for this codebase, currently
|
|
104
|
+
running nowhere. It is revived here.
|
|
105
|
+
|
|
106
|
+
See `docs/responsibilities.md` for every duty, the knife table, the garbage
|
|
107
|
+
ledger, and the known wounds.
|
package/README.md
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# @amalgm/chat
|
|
2
|
+
|
|
3
|
+
The Amalgm conversation SDK: every law of the chat pipeline — the event
|
|
4
|
+
grammar, harness normalization, transcript truth, the turn machine, the
|
|
5
|
+
frozen session contract, warm payloads, and the usage law — extracted from
|
|
6
|
+
the engine as a standalone package, plus a faithful reference host. Start
|
|
7
|
+
with [PURPOSE.md](PURPOSE.md) (the charter, seven jobs, ten axioms) and
|
|
8
|
+
[docs/responsibilities.md](docs/responsibilities.md) (every duty, the
|
|
9
|
+
four-copies ground truth, the garbage ledger, the known wounds).
|
|
10
|
+
|
|
11
|
+
```
|
|
12
|
+
src/events/ the canonical event grammar (constructors + zod schema)
|
|
13
|
+
src/wire/ SSE frame projection (ACP-shaped AgentStreamEvent)
|
|
14
|
+
src/transcript/ message reducer, parts, tool shape/display
|
|
15
|
+
src/turns/ TurnStore, status machine, replay grammar
|
|
16
|
+
src/contract/ harnesses, model identities, freeze algebra, chatInput,
|
|
17
|
+
payload merge, input normalization
|
|
18
|
+
src/warm/ warm-payload laws: revision, fingerprint, cache policies
|
|
19
|
+
src/usage/ token algebra, turn finalization, ownership fork, catalog
|
|
20
|
+
src/normalizers/ claude · codex · opencode · cursor · pi → the grammar
|
|
21
|
+
src/ports.ts the ports a host injects (clock, hash, uuid)
|
|
22
|
+
host/ the reference host: adapters, tooling, orchestration,
|
|
23
|
+
chat-server shell (effectful, imports the laws from dist)
|
|
24
|
+
docs/ the chat corpus: SDK spec, runtime law, normalizer
|
|
25
|
+
contracts + errata, internals map, warm payloads,
|
|
26
|
+
reducer divergences
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
npm install
|
|
31
|
+
npm test # build + every exam
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
Rules of the house: `src/` is pure — one runtime dependency (zod, axiom 9),
|
|
35
|
+
no `node:*`, no env, no ambient clock; hosts inject effects through
|
|
36
|
+
`src/ports.ts`. `host/` is effectful by design but never re-implements a
|
|
37
|
+
law — it imports them. Contracts are byte-exact against the shipped engine
|
|
38
|
+
(`amalgm-engine/runtime/scripts/chat-core/`, production truth until
|
|
39
|
+
cutover — axiom 1); every module was differentially verified against the
|
|
40
|
+
engine's own code. Tests are exams — each states a law, and a mutant must
|
|
41
|
+
be convicted by at least one.
|
|
@@ -0,0 +1,144 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
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;;;;;;;;;;;;;;;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+1,261 @@
|
|
|
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
|
+
const VALID_AUTH_METHODS = ['amalgm', 'byok', 'provider_auth'];
|
|
8
|
+
const ChatInputTextPartSchema = z.object({
|
|
9
|
+
type: z.literal('text'),
|
|
10
|
+
text: z.string().default(''),
|
|
11
|
+
}).passthrough();
|
|
12
|
+
const ChatInputFilePartSchema = z.object({
|
|
13
|
+
type: z.literal('file'),
|
|
14
|
+
filename: z.string().optional(),
|
|
15
|
+
mediaType: z.string().optional(),
|
|
16
|
+
url: z.string().optional(),
|
|
17
|
+
storagePath: z.string().optional(),
|
|
18
|
+
storage_path: z.string().optional(),
|
|
19
|
+
computerPath: z.string().optional(),
|
|
20
|
+
sandboxPath: z.string().optional(),
|
|
21
|
+
assetId: z.string().optional(),
|
|
22
|
+
}).passthrough();
|
|
23
|
+
const ChatInputUnknownPartSchema = z.object({
|
|
24
|
+
type: z.string(),
|
|
25
|
+
}).passthrough();
|
|
26
|
+
export const ChatInputPartSchema = z.union([
|
|
27
|
+
ChatInputTextPartSchema,
|
|
28
|
+
ChatInputFilePartSchema,
|
|
29
|
+
ChatInputUnknownPartSchema,
|
|
30
|
+
]);
|
|
31
|
+
export const WorkspaceTargetSchema = z.discriminatedUnion('kind', [
|
|
32
|
+
z.object({
|
|
33
|
+
kind: z.literal('cwd'),
|
|
34
|
+
cwd: z.string(),
|
|
35
|
+
}),
|
|
36
|
+
z.object({
|
|
37
|
+
kind: z.literal('existing-worktree'),
|
|
38
|
+
path: z.string(),
|
|
39
|
+
}),
|
|
40
|
+
z.object({
|
|
41
|
+
kind: z.literal('managed-worktree'),
|
|
42
|
+
repoPath: z.string(),
|
|
43
|
+
branch: z.string(),
|
|
44
|
+
baseBranch: z.string().nullable().optional(),
|
|
45
|
+
path: z.string().nullable().optional(),
|
|
46
|
+
}),
|
|
47
|
+
]);
|
|
48
|
+
export const ChatInputSchema = z.object({
|
|
49
|
+
parts: z.array(ChatInputPartSchema).default([]),
|
|
50
|
+
agent: z.object({
|
|
51
|
+
harness: z.string().nullable().optional(),
|
|
52
|
+
model: z.string().nullable().optional(),
|
|
53
|
+
authMethod: z.enum(VALID_AUTH_METHODS).nullable().optional(),
|
|
54
|
+
customAgentId: z.string().nullable().optional(),
|
|
55
|
+
systemPrompt: z.string().nullable().optional(),
|
|
56
|
+
}).default({}),
|
|
57
|
+
tools: z.object({
|
|
58
|
+
mcpAppIds: z.array(z.string()).default([]),
|
|
59
|
+
toolIds: z.array(z.string()).default([]),
|
|
60
|
+
// zod 4 `.default()` returns the default WITHOUT parsing, so a missing
|
|
61
|
+
// `tools` key yields bare `{}` (no mcpAppIds/toolIds) — verified against
|
|
62
|
+
// the engine at runtime. The cast preserves that byte-exact behavior.
|
|
63
|
+
}).default({}),
|
|
64
|
+
execution: z.object({
|
|
65
|
+
cwd: z.string().nullable().optional(),
|
|
66
|
+
computerId: z.string().nullable().optional(),
|
|
67
|
+
workspace: WorkspaceTargetSchema.nullable().optional(),
|
|
68
|
+
}).default({}),
|
|
69
|
+
});
|
|
70
|
+
function isObject(value) {
|
|
71
|
+
return !!value && typeof value === 'object' && !Array.isArray(value);
|
|
72
|
+
}
|
|
73
|
+
function cleanString(value) {
|
|
74
|
+
return typeof value === 'string' && value.trim() ? value : null;
|
|
75
|
+
}
|
|
76
|
+
function firstString(...values) {
|
|
77
|
+
for (const value of values) {
|
|
78
|
+
const cleaned = cleanString(value);
|
|
79
|
+
if (cleaned)
|
|
80
|
+
return cleaned;
|
|
81
|
+
}
|
|
82
|
+
return null;
|
|
83
|
+
}
|
|
84
|
+
/** Engine `chatInput.js uniqueStrings`: trimmed, deduped string list. */
|
|
85
|
+
export function uniqueStrings(values) {
|
|
86
|
+
if (!Array.isArray(values))
|
|
87
|
+
return [];
|
|
88
|
+
return [...new Set(values.filter((value) => typeof value === 'string' && value.trim()).map((value) => value.trim()))];
|
|
89
|
+
}
|
|
90
|
+
function normalizeWorkspace(rawWorkspace, fallbackCwd) {
|
|
91
|
+
if (isObject(rawWorkspace) && typeof rawWorkspace.kind === 'string') {
|
|
92
|
+
const parsed = WorkspaceTargetSchema.safeParse(rawWorkspace);
|
|
93
|
+
if (parsed.success)
|
|
94
|
+
return parsed.data;
|
|
95
|
+
}
|
|
96
|
+
const cwd = cleanString(fallbackCwd);
|
|
97
|
+
return cwd ? { kind: 'cwd', cwd } : null;
|
|
98
|
+
}
|
|
99
|
+
/** Engine `getWorkspaceCwd`: the folder a workspace target points at, if any. */
|
|
100
|
+
export function getWorkspaceCwd(workspace) {
|
|
101
|
+
if (!workspace || !isObject(workspace))
|
|
102
|
+
return null;
|
|
103
|
+
if (workspace.kind === 'cwd' && cleanString(workspace.cwd))
|
|
104
|
+
return workspace.cwd.trim();
|
|
105
|
+
if (workspace.kind === 'existing-worktree' && cleanString(workspace.path))
|
|
106
|
+
return workspace.path.trim();
|
|
107
|
+
if (workspace.kind === 'managed-worktree') {
|
|
108
|
+
return firstString(workspace.path, workspace.repoPath);
|
|
109
|
+
}
|
|
110
|
+
return null;
|
|
111
|
+
}
|
|
112
|
+
/** Engine `normalizeChatPart` — pass-through normalization for one part. */
|
|
113
|
+
export function normalizeChatPart(part) {
|
|
114
|
+
if (!isObject(part) || typeof part.type !== 'string')
|
|
115
|
+
return null;
|
|
116
|
+
if (part.type === 'text') {
|
|
117
|
+
return {
|
|
118
|
+
...part,
|
|
119
|
+
type: 'text',
|
|
120
|
+
text: typeof part.text === 'string' ? part.text : '',
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
if (part.type === 'file') {
|
|
124
|
+
const storagePath = firstString(part.storagePath, part.storage_path);
|
|
125
|
+
const computerPath = firstString(part.computerPath, part.sandboxPath);
|
|
126
|
+
return {
|
|
127
|
+
...part,
|
|
128
|
+
type: 'file',
|
|
129
|
+
...(cleanString(part.filename) ? { filename: part.filename.trim() } : {}),
|
|
130
|
+
...(cleanString(part.mediaType) ? { mediaType: part.mediaType.trim() } : {}),
|
|
131
|
+
...(cleanString(part.url) ? { url: part.url.trim() } : {}),
|
|
132
|
+
...(storagePath ? { storagePath, storage_path: storagePath } : {}),
|
|
133
|
+
...(computerPath ? { computerPath, sandboxPath: computerPath } : {}),
|
|
134
|
+
...(cleanString(part.assetId) ? { assetId: part.assetId.trim() } : {}),
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
return { ...part };
|
|
138
|
+
}
|
|
139
|
+
/** Engine `normalizeChatParts` — normalized parts, else a text part from the prompt. */
|
|
140
|
+
export function normalizeChatParts(parts, fallbackPrompt) {
|
|
141
|
+
const normalized = Array.isArray(parts)
|
|
142
|
+
? parts.map(normalizeChatPart).filter((part) => Boolean(part))
|
|
143
|
+
: [];
|
|
144
|
+
if (normalized.length > 0)
|
|
145
|
+
return normalized;
|
|
146
|
+
const prompt = typeof fallbackPrompt === 'string' ? fallbackPrompt : '';
|
|
147
|
+
return prompt.trim() ? [{ type: 'text', text: prompt }] : [];
|
|
148
|
+
}
|
|
149
|
+
/** Engine `getChatInputText` — joined text of all text parts. */
|
|
150
|
+
export function getChatInputText(chatInput, fallbackPrompt) {
|
|
151
|
+
const normalized = normalizeChatInput(chatInput, { prompt: fallbackPrompt });
|
|
152
|
+
return normalized.parts
|
|
153
|
+
.filter((part) => part.type === 'text' && typeof part.text === 'string')
|
|
154
|
+
.map((part) => part.text)
|
|
155
|
+
.join('\n\n')
|
|
156
|
+
.trim();
|
|
157
|
+
}
|
|
158
|
+
/** Engine `getAttachedFilePaths` — local paths of attached file parts. */
|
|
159
|
+
export function getAttachedFilePaths(parts) {
|
|
160
|
+
if (!Array.isArray(parts))
|
|
161
|
+
return [];
|
|
162
|
+
return parts
|
|
163
|
+
.filter((part) => part && part.type === 'file')
|
|
164
|
+
.map((part) => firstString(part.computerPath, part.sandboxPath))
|
|
165
|
+
.filter((value) => Boolean(value));
|
|
166
|
+
}
|
|
167
|
+
/** Engine `buildPromptFromParts` — flat prompt text incl. attached-file prefix. */
|
|
168
|
+
export function buildPromptFromParts(parts, fallbackPrompt) {
|
|
169
|
+
const normalizedParts = normalizeChatParts(parts, fallbackPrompt);
|
|
170
|
+
const text = normalizedParts
|
|
171
|
+
.filter((part) => part.type === 'text' && typeof part.text === 'string')
|
|
172
|
+
.map((part) => part.text)
|
|
173
|
+
.join('\n\n')
|
|
174
|
+
.trim();
|
|
175
|
+
const attachedPaths = getAttachedFilePaths(normalizedParts);
|
|
176
|
+
if (attachedPaths.length === 0) {
|
|
177
|
+
return text || (typeof fallbackPrompt === 'string' ? fallbackPrompt : '');
|
|
178
|
+
}
|
|
179
|
+
const attachedPrefix = `[Attached files: ${attachedPaths.join(', ')}]`;
|
|
180
|
+
return text ? `${attachedPrefix}\n\n${text}` : attachedPrefix;
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
* Engine `normalizeChatInput(chatInput, legacy)` — the canonical structured
|
|
184
|
+
* input, merging the structured object with legacy flat fields.
|
|
185
|
+
*/
|
|
186
|
+
export function normalizeChatInput(chatInput, legacy = {}) {
|
|
187
|
+
const rawInput = isObject(chatInput) ? chatInput : {};
|
|
188
|
+
const rawAgent = isObject(rawInput.agent) ? rawInput.agent : {};
|
|
189
|
+
const rawTools = isObject(rawInput.tools) ? rawInput.tools : {};
|
|
190
|
+
const rawExecution = isObject(rawInput.execution) ? rawInput.execution : {};
|
|
191
|
+
const workspace = normalizeWorkspace(rawExecution.workspace, firstString(rawExecution.cwd, legacy.cwd, legacy.projectPath));
|
|
192
|
+
const resolvedCwd = firstString(rawExecution.cwd, getWorkspaceCwd(workspace), legacy.cwd, legacy.projectPath);
|
|
193
|
+
const normalized = {
|
|
194
|
+
parts: normalizeChatParts(rawInput.parts, Array.isArray(legacy.userParts) && legacy.userParts.length > 0
|
|
195
|
+
? null
|
|
196
|
+
: legacy.prompt),
|
|
197
|
+
agent: {
|
|
198
|
+
harness: firstString(rawAgent.harness, rawAgent.harnessId, legacy.harness),
|
|
199
|
+
model: firstString(rawAgent.model, rawAgent.modelId, legacy.modelId, legacy.model),
|
|
200
|
+
authMethod: firstString(rawAgent.authMethod, legacy.authMethod),
|
|
201
|
+
customAgentId: firstString(rawAgent.customAgentId, (typeof rawAgent.harness === 'string' && rawAgent.harness.startsWith('custom-'))
|
|
202
|
+
? rawAgent.harness
|
|
203
|
+
: null, (typeof legacy.harness === 'string' && legacy.harness.startsWith('custom-'))
|
|
204
|
+
? legacy.harness
|
|
205
|
+
: null),
|
|
206
|
+
systemPrompt: firstString(rawAgent.systemPrompt, legacy.systemPrompt),
|
|
207
|
+
},
|
|
208
|
+
tools: {
|
|
209
|
+
mcpAppIds: uniqueStrings(rawTools.mcpAppIds || legacy.mcpAppIds),
|
|
210
|
+
toolIds: uniqueStrings(rawTools.toolIds
|
|
211
|
+
|| legacy.toolIds),
|
|
212
|
+
},
|
|
213
|
+
execution: {
|
|
214
|
+
cwd: resolvedCwd,
|
|
215
|
+
computerId: firstString(rawExecution.computerId, legacy.computerId),
|
|
216
|
+
workspace,
|
|
217
|
+
},
|
|
218
|
+
};
|
|
219
|
+
return ChatInputSchema.parse(normalized);
|
|
220
|
+
}
|
|
221
|
+
/**
|
|
222
|
+
* Engine `chatInputToLegacyFields` — project the structured input back onto
|
|
223
|
+
* the flat legacy body fields (the shape `applyPayloadRecord` spreads).
|
|
224
|
+
*/
|
|
225
|
+
export function chatInputToLegacyFields(chatInput, fallback = {}) {
|
|
226
|
+
const normalized = normalizeChatInput(chatInput, fallback);
|
|
227
|
+
const prompt = buildPromptFromParts(normalized.parts, fallback.prompt);
|
|
228
|
+
const harness = firstString(normalized.agent.customAgentId, normalized.agent.harness, fallback.harness);
|
|
229
|
+
const modelId = firstString(normalized.agent.model, fallback.modelId, fallback.model);
|
|
230
|
+
const cwd = firstString(normalized.execution.cwd, getWorkspaceCwd(normalized.execution.workspace), fallback.cwd, fallback.projectPath);
|
|
231
|
+
const authMethod = firstString(normalized.agent.authMethod, fallback.authMethod);
|
|
232
|
+
const systemPrompt = firstString(normalized.agent.systemPrompt, fallback.systemPrompt);
|
|
233
|
+
return {
|
|
234
|
+
prompt,
|
|
235
|
+
userParts: normalized.parts,
|
|
236
|
+
harness,
|
|
237
|
+
modelId,
|
|
238
|
+
model: modelId,
|
|
239
|
+
authMethod,
|
|
240
|
+
cwd,
|
|
241
|
+
projectPath: cwd,
|
|
242
|
+
computerId: firstString(normalized.execution.computerId, fallback.computerId),
|
|
243
|
+
mcpAppIds: normalized.tools.mcpAppIds,
|
|
244
|
+
systemPrompt,
|
|
245
|
+
};
|
|
246
|
+
}
|
|
247
|
+
/** Engine `withChatInputText` — rewrite every text part through `updater`. */
|
|
248
|
+
export function withChatInputText(chatInput, updater, legacy = {}) {
|
|
249
|
+
const normalized = normalizeChatInput(chatInput, legacy);
|
|
250
|
+
const parts = normalized.parts.map((part) => {
|
|
251
|
+
if (part.type !== 'text' || typeof part.text !== 'string')
|
|
252
|
+
return part;
|
|
253
|
+
const nextText = updater(part.text, part);
|
|
254
|
+
return {
|
|
255
|
+
...part,
|
|
256
|
+
text: typeof nextText === 'string' ? nextText : part.text,
|
|
257
|
+
};
|
|
258
|
+
});
|
|
259
|
+
return normalizeChatInput({ ...normalized, parts });
|
|
260
|
+
}
|
|
261
|
+
//# sourceMappingURL=chat-input.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chat-input.js","sourceRoot":"","sources":["../../src/contract/chat-input.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,MAAM,kBAAkB,GAAG,CAAC,QAAQ,EAAE,MAAM,EAAE,eAAe,CAAU,CAAC;AAExE,MAAM,uBAAuB,GAAG,CAAC,CAAC,MAAM,CAAC;IACvC,IAAI,EAAE,C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