@amalgm/chat 0.1.1 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AGENTS.md +98 -0
- package/PURPOSE.md +143 -104
- package/README.md +82 -54
- package/dist/acp/index.d.ts +7 -0
- package/dist/acp/index.d.ts.map +1 -0
- package/dist/acp/index.js +7 -0
- package/dist/acp/index.js.map +1 -0
- package/dist/acp/projection.d.ts +30 -0
- package/dist/acp/projection.d.ts.map +1 -0
- package/dist/acp/projection.js +147 -0
- package/dist/acp/projection.js.map +1 -0
- package/dist/api/conversations.d.ts +66 -0
- package/dist/api/conversations.d.ts.map +1 -0
- package/dist/api/conversations.js +202 -0
- package/dist/api/conversations.js.map +1 -0
- package/dist/api/index.d.ts +3 -3
- package/dist/api/index.d.ts.map +1 -1
- package/dist/api/index.js +1 -2
- package/dist/api/index.js.map +1 -1
- package/dist/conversations/index.d.ts +3 -0
- package/dist/conversations/index.d.ts.map +1 -0
- package/dist/conversations/index.js +3 -0
- package/dist/conversations/index.js.map +1 -0
- package/dist/conversations/transcript.d.ts +13 -0
- package/dist/conversations/transcript.d.ts.map +1 -0
- package/dist/conversations/transcript.js +171 -0
- package/dist/conversations/transcript.js.map +1 -0
- package/dist/conversations/types.d.ts +147 -0
- package/dist/conversations/types.d.ts.map +1 -0
- package/dist/conversations/types.js +9 -0
- package/dist/conversations/types.js.map +1 -0
- package/dist/events/constructors.d.ts +9 -15
- package/dist/events/constructors.d.ts.map +1 -1
- package/dist/events/constructors.js +6 -12
- package/dist/events/constructors.js.map +1 -1
- package/dist/events/index.d.ts +2 -3
- package/dist/events/index.d.ts.map +1 -1
- package/dist/events/index.js +2 -3
- package/dist/events/index.js.map +1 -1
- package/dist/events/schema.d.ts +2 -5
- package/dist/events/schema.d.ts.map +1 -1
- package/dist/events/schema.js +2 -5
- package/dist/events/schema.js.map +1 -1
- package/dist/execution/contract.d.ts +51 -0
- package/dist/execution/contract.d.ts.map +1 -0
- package/dist/execution/contract.js +127 -0
- package/dist/execution/contract.js.map +1 -0
- package/dist/execution/index.d.ts +6 -0
- package/dist/execution/index.d.ts.map +1 -0
- package/dist/execution/index.js +4 -0
- package/dist/execution/index.js.map +1 -0
- package/dist/execution/revision.d.ts +5 -0
- package/dist/execution/revision.d.ts.map +1 -0
- package/dist/execution/revision.js +17 -0
- package/dist/execution/revision.js.map +1 -0
- package/dist/execution/store.d.ts +26 -0
- package/dist/execution/store.d.ts.map +1 -0
- package/dist/execution/store.js +38 -0
- package/dist/execution/store.js.map +1 -0
- package/dist/index.d.ts +8 -23
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +7 -23
- package/dist/index.js.map +1 -1
- package/dist/input/index.d.ts +3 -0
- package/dist/input/index.d.ts.map +1 -0
- package/dist/input/index.js +2 -0
- package/dist/input/index.js.map +1 -0
- package/dist/input/prompt.d.ts +17 -0
- package/dist/input/prompt.d.ts.map +1 -0
- package/dist/input/prompt.js +104 -0
- package/dist/input/prompt.js.map +1 -0
- package/dist/normalizers/claude.d.ts +6 -9
- package/dist/normalizers/claude.d.ts.map +1 -1
- package/dist/normalizers/claude.js +5 -8
- package/dist/normalizers/claude.js.map +1 -1
- package/dist/normalizers/codex.d.ts +5 -8
- package/dist/normalizers/codex.d.ts.map +1 -1
- package/dist/normalizers/codex.js +4 -7
- package/dist/normalizers/codex.js.map +1 -1
- package/dist/normalizers/cursor.d.ts +1 -2
- package/dist/normalizers/cursor.d.ts.map +1 -1
- package/dist/normalizers/cursor.js +2 -3
- package/dist/normalizers/cursor.js.map +1 -1
- package/dist/normalizers/index.d.ts +3 -5
- package/dist/normalizers/index.d.ts.map +1 -1
- package/dist/normalizers/index.js +3 -5
- package/dist/normalizers/index.js.map +1 -1
- package/dist/normalizers/opencode.d.ts +2 -4
- package/dist/normalizers/opencode.d.ts.map +1 -1
- package/dist/normalizers/opencode.js +2 -4
- package/dist/normalizers/opencode.js.map +1 -1
- package/dist/normalizers/pi.d.ts +3 -4
- package/dist/normalizers/pi.d.ts.map +1 -1
- package/dist/normalizers/pi.js +3 -4
- package/dist/normalizers/pi.js.map +1 -1
- package/dist/sessions/chat.d.ts +176 -0
- package/dist/sessions/chat.d.ts.map +1 -0
- package/dist/sessions/chat.js +701 -0
- package/dist/sessions/chat.js.map +1 -0
- package/dist/sessions/index.d.ts +3 -0
- package/dist/sessions/index.d.ts.map +1 -0
- package/dist/sessions/index.js +2 -0
- package/dist/sessions/index.js.map +1 -0
- package/dist/transcript/index.d.ts +1 -1
- package/dist/transcript/index.js +1 -1
- package/dist/transcript/message-reducer.d.ts +1 -1
- package/dist/transcript/message-reducer.js +1 -1
- package/dist/transcript/part-accumulator.d.ts +1 -1
- package/dist/transcript/part-accumulator.js +1 -1
- package/dist/transcript/tool-display.d.ts +1 -1
- package/dist/transcript/tool-display.js +1 -1
- package/dist/transcript/tool-shape.d.ts +1 -1
- package/dist/transcript/tool-shape.js +1 -1
- package/dist/usage/finalize.d.ts +7 -9
- package/dist/usage/finalize.d.ts.map +1 -1
- package/dist/usage/finalize.js +11 -13
- package/dist/usage/finalize.js.map +1 -1
- package/dist/usage/index.d.ts +2 -3
- package/dist/usage/index.d.ts.map +1 -1
- package/dist/usage/index.js +2 -3
- package/dist/usage/index.js.map +1 -1
- package/dist/usage/model-catalog.d.ts +2 -3
- package/dist/usage/model-catalog.d.ts.map +1 -1
- package/dist/usage/model-catalog.js +10 -3
- package/dist/usage/model-catalog.js.map +1 -1
- package/dist/usage/normalize.d.ts +5 -7
- package/dist/usage/normalize.d.ts.map +1 -1
- package/dist/usage/normalize.js +3 -5
- package/dist/usage/normalize.js.map +1 -1
- package/dist/usage/ports.d.ts +14 -24
- package/dist/usage/ports.d.ts.map +1 -1
- package/dist/usage/ports.js +9 -17
- package/dist/usage/ports.js.map +1 -1
- package/dist/usage/steps.d.ts +70 -0
- package/dist/usage/steps.d.ts.map +1 -0
- package/dist/usage/steps.js +152 -0
- package/dist/usage/steps.js.map +1 -0
- package/dist/usage/tokens.d.ts +4 -7
- package/dist/usage/tokens.d.ts.map +1 -1
- package/dist/usage/tokens.js +4 -7
- package/dist/usage/tokens.js.map +1 -1
- package/docs/contracts/acp-and-step-usage.md +51 -0
- package/docs/contracts/conversation-persistence.md +47 -0
- package/docs/contracts/input-and-execution.md +177 -0
- package/docs/contracts/platform-authorization.md +17 -0
- package/host/adapters/acp-capabilities.js +30 -0
- package/host/adapters/acp-client.js +156 -0
- package/host/adapters/acp.js +284 -0
- package/host/adapters/claude.js +235 -0
- package/host/adapters/codex.js +733 -0
- package/host/adapters/cursor.js +347 -0
- package/host/adapters/input-capabilities.js +89 -0
- package/host/adapters/opencode.js +486 -0
- package/host/adapters/pi.js +519 -0
- package/host/adapters/prompt.js +212 -0
- package/host/auth.js +257 -0
- package/host/credentials/store.js +209 -0
- package/host/http.d.ts +32 -0
- package/host/http.js +238 -0
- package/host/index.d.ts +84 -0
- package/host/index.js +59 -0
- package/host/lib/runtime-paths.js +44 -0
- package/host/model-resolution.js +313 -0
- package/host/native-contract.js +185 -0
- package/host/native-runtime.js +194 -0
- package/host/permissions.js +27 -0
- package/host/platform-egress.js +114 -0
- package/host/recorder.js +61 -0
- package/host/sqlite/index.d.ts +69 -0
- package/host/sqlite/index.js +704 -0
- package/host/tooling/mcp-bundle.js +214 -0
- package/host/tooling/mcp-relay.js +83 -0
- package/host/tooling/native-binaries.js +667 -0
- package/host/tooling/native-config.js +460 -0
- package/host/tooling/package-import.js +111 -0
- package/host/tooling/runtime-home.js +26 -0
- package/host/tooling/system-instructions.js +69 -0
- package/host/tooling/system-prompt.js +35 -0
- package/package.json +45 -21
- package/skills/chat/SKILL.md +97 -0
- package/skills/chat/agents/openai.yaml +4 -0
- package/skills/chat/references/contracts.md +131 -0
- package/dist/api/chat-payloads.d.ts +0 -10
- package/dist/api/chat-payloads.d.ts.map +0 -1
- package/dist/api/chat-payloads.js +0 -57
- package/dist/api/chat-payloads.js.map +0 -1
- package/dist/contract/chat-input.d.ts +0 -144
- package/dist/contract/chat-input.d.ts.map +0 -1
- package/dist/contract/chat-input.js +0 -261
- package/dist/contract/chat-input.js.map +0 -1
- package/dist/contract/create.d.ts +0 -191
- package/dist/contract/create.d.ts.map +0 -1
- package/dist/contract/create.js +0 -249
- package/dist/contract/create.js.map +0 -1
- package/dist/contract/freeze.d.ts +0 -85
- package/dist/contract/freeze.d.ts.map +0 -1
- package/dist/contract/freeze.js +0 -151
- package/dist/contract/freeze.js.map +0 -1
- package/dist/contract/harnesses.d.ts +0 -21
- package/dist/contract/harnesses.d.ts.map +0 -1
- package/dist/contract/harnesses.js +0 -39
- package/dist/contract/harnesses.js.map +0 -1
- package/dist/contract/index.d.ts +0 -17
- package/dist/contract/index.d.ts.map +0 -1
- package/dist/contract/index.js +0 -17
- package/dist/contract/index.js.map +0 -1
- package/dist/contract/input.d.ts +0 -45
- package/dist/contract/input.d.ts.map +0 -1
- package/dist/contract/input.js +0 -78
- package/dist/contract/input.js.map +0 -1
- package/dist/contract/models.d.ts +0 -57
- package/dist/contract/models.d.ts.map +0 -1
- package/dist/contract/models.js +0 -380
- package/dist/contract/models.js.map +0 -1
- package/dist/contract/payload-merge.d.ts +0 -76
- package/dist/contract/payload-merge.d.ts.map +0 -1
- package/dist/contract/payload-merge.js +0 -215
- package/dist/contract/payload-merge.js.map +0 -1
- package/dist/events/tool-display.d.ts +0 -22
- package/dist/events/tool-display.d.ts.map +0 -1
- package/dist/events/tool-display.js +0 -60
- package/dist/events/tool-display.js.map +0 -1
- package/dist/events/tool-shape.d.ts +0 -48
- package/dist/events/tool-shape.d.ts.map +0 -1
- package/dist/events/tool-shape.js +0 -225
- package/dist/events/tool-shape.js.map +0 -1
- package/dist/turns/index.d.ts +0 -11
- package/dist/turns/index.d.ts.map +0 -1
- package/dist/turns/index.js +0 -11
- package/dist/turns/index.js.map +0 -1
- package/dist/turns/queries.d.ts +0 -36
- package/dist/turns/queries.d.ts.map +0 -1
- package/dist/turns/queries.js +0 -37
- package/dist/turns/queries.js.map +0 -1
- package/dist/turns/replay.d.ts +0 -105
- package/dist/turns/replay.d.ts.map +0 -1
- package/dist/turns/replay.js +0 -163
- package/dist/turns/replay.js.map +0 -1
- package/dist/turns/status.d.ts +0 -49
- package/dist/turns/status.d.ts.map +0 -1
- package/dist/turns/status.js +0 -56
- package/dist/turns/status.js.map +0 -1
- package/dist/turns/turn-store.d.ts +0 -109
- package/dist/turns/turn-store.d.ts.map +0 -1
- package/dist/turns/turn-store.js +0 -169
- package/dist/turns/turn-store.js.map +0 -1
- package/dist/warm/client-cache.d.ts +0 -47
- package/dist/warm/client-cache.d.ts.map +0 -1
- package/dist/warm/client-cache.js +0 -48
- package/dist/warm/client-cache.js.map +0 -1
- package/dist/warm/envelope-cache.d.ts +0 -79
- package/dist/warm/envelope-cache.d.ts.map +0 -1
- package/dist/warm/envelope-cache.js +0 -85
- package/dist/warm/envelope-cache.js.map +0 -1
- package/dist/warm/index.d.ts +0 -18
- package/dist/warm/index.d.ts.map +0 -1
- package/dist/warm/index.js +0 -12
- package/dist/warm/index.js.map +0 -1
- package/dist/warm/payload.d.ts +0 -137
- package/dist/warm/payload.d.ts.map +0 -1
- package/dist/warm/payload.js +0 -112
- package/dist/warm/payload.js.map +0 -1
- package/dist/warm/revision.d.ts +0 -70
- package/dist/warm/revision.d.ts.map +0 -1
- package/dist/warm/revision.js +0 -63
- package/dist/warm/revision.js.map +0 -1
- package/dist/warm/store-policy.d.ts +0 -57
- package/dist/warm/store-policy.d.ts.map +0 -1
- package/dist/warm/store-policy.js +0 -89
- package/dist/warm/store-policy.js.map +0 -1
- package/dist/warm/store.d.ts +0 -42
- package/dist/warm/store.d.ts.map +0 -1
- package/dist/warm/store.js +0 -69
- package/dist/warm/store.js.map +0 -1
- package/dist/wire/frames.d.ts +0 -208
- package/dist/wire/frames.d.ts.map +0 -1
- package/dist/wire/frames.js +0 -245
- package/dist/wire/frames.js.map +0 -1
- package/dist/wire/index.d.ts +0 -7
- package/dist/wire/index.d.ts.map +0 -1
- package/dist/wire/index.js +0 -7
- package/dist/wire/index.js.map +0 -1
package/dist/turns/status.d.ts
DELETED
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Turn status vocabulary and predicates — the turn machine's state alphabet,
|
|
3
|
-
* extracted from engine `chat-core`. Every value is anchored to the engine
|
|
4
|
-
* line that produces it; nothing here is invented.
|
|
5
|
-
*/
|
|
6
|
-
/**
|
|
7
|
-
* Every status a stored turn can hold:
|
|
8
|
-
* - `streaming` — set at start (stores.js:19)
|
|
9
|
-
* - `cancelling` — stop path (engine.js:124); still counted active (stores.js:40)
|
|
10
|
-
* - `complete` — terminal, clean end (engine.js:302)
|
|
11
|
-
* - `error` — terminal (engine.js:302, safety net engine.js:337)
|
|
12
|
-
* - `cancelled` — terminal (engine.js:302)
|
|
13
|
-
* - `aborted` — prior turn of the same session displaced by a new start (stores.js:13)
|
|
14
|
-
* - `save_failed` — persistence failed after the raw stream completed (engine.js:327)
|
|
15
|
-
*/
|
|
16
|
-
export declare const TURN_STATUSES: readonly ["streaming", "cancelling", "complete", "error", "cancelled", "aborted", "save_failed"];
|
|
17
|
-
export type TurnStatus = (typeof TURN_STATUSES)[number];
|
|
18
|
-
/**
|
|
19
|
-
* Synthesized status reported by `GET /active` when a session has no active
|
|
20
|
-
* turn entry (engine.js:107 `entry?.status || 'idle'`). Never stored on a turn.
|
|
21
|
-
*/
|
|
22
|
-
export declare const IDLE_STATUS: "idle";
|
|
23
|
-
/** A queried status: a real turn status, or the synthesized 'idle'. */
|
|
24
|
-
export type QueryStatus = TurnStatus | typeof IDLE_STATUS;
|
|
25
|
-
/**
|
|
26
|
-
* Statuses that hold a tempstore slot / count as active. Engine repeats the
|
|
27
|
-
* literal array at stores.js:40 (activeCount), stores.js:55 (addChunk guard)
|
|
28
|
-
* and engine.js:104, engine.js:336.
|
|
29
|
-
*/
|
|
30
|
-
export declare const ACTIVE_STATUSES: readonly ["streaming", "cancelling"];
|
|
31
|
-
export type ActiveStatus = (typeof ACTIVE_STATUSES)[number];
|
|
32
|
-
/** The active predicate — `['streaming', 'cancelling'].includes(status)`. */
|
|
33
|
-
export declare function isActiveStatus(status: string): status is ActiveStatus;
|
|
34
|
-
/**
|
|
35
|
-
* Terminal predicate as the replay law states it (streams.js:54-56):
|
|
36
|
-
* anything that is not streaming and not cancelling is terminal. Note this
|
|
37
|
-
* includes `save_failed`, which is terminal but does NOT close a frame-format
|
|
38
|
-
* tail (streams.js:90-94).
|
|
39
|
-
*/
|
|
40
|
-
export declare function isTerminalStatus(status: string): boolean;
|
|
41
|
-
/**
|
|
42
|
-
* Stop-reason vocabulary carried on the `complete` frame:
|
|
43
|
-
* - `end_turn` — default (engine.js:251)
|
|
44
|
-
* - `error` — stream error path (engine.js:289; streams.js:151)
|
|
45
|
-
* - `cancelled` — cancelling turn finished without its own done (engine.js:285)
|
|
46
|
-
*/
|
|
47
|
-
export declare const STOP_REASONS: readonly ["end_turn", "error", "cancelled"];
|
|
48
|
-
export type StopReason = (typeof STOP_REASONS)[number];
|
|
49
|
-
//# sourceMappingURL=status.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"status.d.ts","sourceRoot":"","sources":["../../src/turns/status.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;;;;;;;;GASG;AACH,eAAO,MAAM,aAAa,kGAQhB,CAAC;AAEX,MAAM,MAAM,UAAU,GAAG,CAAC,OAAO,aAAa,CAAC,CAAC,MAAM,CAAC,CAAC;AAExD;;;GAGG;AACH,eAAO,MAAM,WAAW,EAAG,MAAe,CAAC;AAE3C,uEAAuE;AACvE,MAAM,MAAM,WAAW,GAAG,UAAU,GAAG,OAAO,WAAW,CAAC;AAE1D;;;;GAIG;AACH,eAAO,MAAM,eAAe,sCAAuC,CAAC;AAEpE,MAAM,MAAM,YAAY,GAAG,CAAC,OAAO,eAAe,CAAC,CAAC,MAAM,CAAC,CAAC;AAE5D,6EAA6E;AAC7E,wBAAgB,cAAc,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,IAAI,YAAY,CAErE;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAExD;AAED;;;;;GAKG;AACH,eAAO,MAAM,YAAY,6CAA8C,CAAC;AAExE,MAAM,MAAM,UAAU,GAAG,CAAC,OAAO,YAAY,CAAC,CAAC,MAAM,CAAC,CAAC"}
|
package/dist/turns/status.js
DELETED
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Turn status vocabulary and predicates — the turn machine's state alphabet,
|
|
3
|
-
* extracted from engine `chat-core`. Every value is anchored to the engine
|
|
4
|
-
* line that produces it; nothing here is invented.
|
|
5
|
-
*/
|
|
6
|
-
/**
|
|
7
|
-
* Every status a stored turn can hold:
|
|
8
|
-
* - `streaming` — set at start (stores.js:19)
|
|
9
|
-
* - `cancelling` — stop path (engine.js:124); still counted active (stores.js:40)
|
|
10
|
-
* - `complete` — terminal, clean end (engine.js:302)
|
|
11
|
-
* - `error` — terminal (engine.js:302, safety net engine.js:337)
|
|
12
|
-
* - `cancelled` — terminal (engine.js:302)
|
|
13
|
-
* - `aborted` — prior turn of the same session displaced by a new start (stores.js:13)
|
|
14
|
-
* - `save_failed` — persistence failed after the raw stream completed (engine.js:327)
|
|
15
|
-
*/
|
|
16
|
-
export const TURN_STATUSES = [
|
|
17
|
-
'streaming',
|
|
18
|
-
'cancelling',
|
|
19
|
-
'complete',
|
|
20
|
-
'error',
|
|
21
|
-
'cancelled',
|
|
22
|
-
'aborted',
|
|
23
|
-
'save_failed',
|
|
24
|
-
];
|
|
25
|
-
/**
|
|
26
|
-
* Synthesized status reported by `GET /active` when a session has no active
|
|
27
|
-
* turn entry (engine.js:107 `entry?.status || 'idle'`). Never stored on a turn.
|
|
28
|
-
*/
|
|
29
|
-
export const IDLE_STATUS = 'idle';
|
|
30
|
-
/**
|
|
31
|
-
* Statuses that hold a tempstore slot / count as active. Engine repeats the
|
|
32
|
-
* literal array at stores.js:40 (activeCount), stores.js:55 (addChunk guard)
|
|
33
|
-
* and engine.js:104, engine.js:336.
|
|
34
|
-
*/
|
|
35
|
-
export const ACTIVE_STATUSES = ['streaming', 'cancelling'];
|
|
36
|
-
/** The active predicate — `['streaming', 'cancelling'].includes(status)`. */
|
|
37
|
-
export function isActiveStatus(status) {
|
|
38
|
-
return ACTIVE_STATUSES.includes(status);
|
|
39
|
-
}
|
|
40
|
-
/**
|
|
41
|
-
* Terminal predicate as the replay law states it (streams.js:54-56):
|
|
42
|
-
* anything that is not streaming and not cancelling is terminal. Note this
|
|
43
|
-
* includes `save_failed`, which is terminal but does NOT close a frame-format
|
|
44
|
-
* tail (streams.js:90-94).
|
|
45
|
-
*/
|
|
46
|
-
export function isTerminalStatus(status) {
|
|
47
|
-
return status !== 'streaming' && status !== 'cancelling';
|
|
48
|
-
}
|
|
49
|
-
/**
|
|
50
|
-
* Stop-reason vocabulary carried on the `complete` frame:
|
|
51
|
-
* - `end_turn` — default (engine.js:251)
|
|
52
|
-
* - `error` — stream error path (engine.js:289; streams.js:151)
|
|
53
|
-
* - `cancelled` — cancelling turn finished without its own done (engine.js:285)
|
|
54
|
-
*/
|
|
55
|
-
export const STOP_REASONS = ['end_turn', 'error', 'cancelled'];
|
|
56
|
-
//# sourceMappingURL=status.js.map
|
package/dist/turns/status.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"status.js","sourceRoot":"","sources":["../../src/turns/status.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG;IAC3B,WAAW;IACX,YAAY;IACZ,UAAU;IACV,OAAO;IACP,WAAW;IACX,SAAS;IACT,aAAa;CACL,CAAC;AAIX;;;GAGG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,MAAe,CAAC;AAK3C;;;;GAIG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,WAAW,EAAE,YAAY,CAAU,CAAC;AAIpE,6EAA6E;AAC7E,MAAM,UAAU,cAAc,CAAC,MAAc;IAC3C,OAAQ,eAAqC,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;AACjE,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,gBAAgB,CAAC,MAAc;IAC7C,OAAO,MAAM,KAAK,WAAW,IAAI,MAAM,KAAK,YAAY,CAAC;AAC3D,CAAC;AAED;;;;;GAKG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,UAAU,EAAE,OAAO,EAAE,WAAW,CAAU,CAAC"}
|
|
@@ -1,109 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* TurnStore — engine `chat-core/stores.js` (113 lines), ported in full.
|
|
3
|
-
* The in-memory raw-stream tempstore: one entry per turn, indexed chunks,
|
|
4
|
-
* seal-on-done, per-turn pub-sub, and the active/latest session maps.
|
|
5
|
-
*
|
|
6
|
-
* `Date.now()` is replaced by an injected {@link ClockMsPort} (constructor
|
|
7
|
-
* argument); everything else is byte-parity with the engine working tree.
|
|
8
|
-
*/
|
|
9
|
-
import type { ClockMsPort } from '../ports.js';
|
|
10
|
-
import { type TurnStatus } from './status.js';
|
|
11
|
-
/** One indexed raw-stream chunk (stores.js:59). */
|
|
12
|
-
export interface TurnChunk {
|
|
13
|
-
index: number;
|
|
14
|
-
/** The SSE frame bytes, written verbatim to frame-format tails. */
|
|
15
|
-
data: string;
|
|
16
|
-
timestamp: number;
|
|
17
|
-
}
|
|
18
|
-
/** A stored turn (stores.js:14-24). Hosts may attach extra bookkeeping. */
|
|
19
|
-
export interface TurnEntry {
|
|
20
|
-
sessionId: string;
|
|
21
|
-
turnId: string;
|
|
22
|
-
assistantMessageId: string | null;
|
|
23
|
-
userMessageId: string | null;
|
|
24
|
-
status: TurnStatus;
|
|
25
|
-
chunks: TurnChunk[];
|
|
26
|
-
parts: unknown[];
|
|
27
|
-
createdAt: number;
|
|
28
|
-
updatedAt: number;
|
|
29
|
-
/** Set when a chunk was added with `{ seal: true }` (stores.js:61). */
|
|
30
|
-
sealedIndex?: number;
|
|
31
|
-
/**
|
|
32
|
-
* Engine-side augmentation slots (engine.js:230-235, engine.js:311-314).
|
|
33
|
-
* The store never reads these; they ride along on the entry object.
|
|
34
|
-
*/
|
|
35
|
-
[extra: string]: unknown;
|
|
36
|
-
}
|
|
37
|
-
export interface StartTurnInput {
|
|
38
|
-
sessionId: string;
|
|
39
|
-
turnId: string;
|
|
40
|
-
assistantMessageId: string | null;
|
|
41
|
-
userMessageId: string | null;
|
|
42
|
-
}
|
|
43
|
-
/** A frame, or a frame factory receiving the assigned index (stores.js:58). */
|
|
44
|
-
export type ChunkFrame = string | ((index: number) => string);
|
|
45
|
-
export interface AddChunkOptions {
|
|
46
|
-
/** `true` seals the log at this chunk's index (stores.js:61). */
|
|
47
|
-
seal?: boolean;
|
|
48
|
-
}
|
|
49
|
-
export type TurnListener = (chunk: TurnChunk | null, entry: TurnEntry) => void;
|
|
50
|
-
export declare class TurnStore {
|
|
51
|
-
readonly turns: Map<string, TurnEntry>;
|
|
52
|
-
readonly activeBySession: Map<string, string>;
|
|
53
|
-
readonly latestBySession: Map<string, string>;
|
|
54
|
-
readonly listeners: Map<string, Set<TurnListener>>;
|
|
55
|
-
private readonly clockMs;
|
|
56
|
-
constructor(clockMs: ClockMsPort);
|
|
57
|
-
/**
|
|
58
|
-
* Open a new turn. A different active turn on the same session is marked
|
|
59
|
-
* `aborted` first — the abort-on-restart law (stores.js:12-13).
|
|
60
|
-
*/
|
|
61
|
-
start({ sessionId, turnId, assistantMessageId, userMessageId }: StartTurnInput): TurnEntry;
|
|
62
|
-
/** The session's active turn entry, if any (stores.js:31-34). */
|
|
63
|
-
active(sessionId: string): TurnEntry | null;
|
|
64
|
-
/**
|
|
65
|
-
* Number of turns still holding a tempstore slot — status in
|
|
66
|
-
* `['streaming', 'cancelling']` (stores.js:36-43).
|
|
67
|
-
*/
|
|
68
|
-
activeCount(): number;
|
|
69
|
-
/**
|
|
70
|
-
* Selection law (stores.js:45-47): the session's active turn wins; else the
|
|
71
|
-
* most recently started turn for the session, even after it went terminal.
|
|
72
|
-
*/
|
|
73
|
-
latest(sessionId: string): TurnEntry | null;
|
|
74
|
-
get(turnId: string | undefined): TurnEntry | null;
|
|
75
|
-
/**
|
|
76
|
-
* Append a chunk (stores.js:53-65). Returns `null` — a rejected write —
|
|
77
|
-
* when the turn is missing, no longer active, or already sealed. The engine
|
|
78
|
-
* converts that `null` into the thrown "Raw stream write failed before
|
|
79
|
-
* event application" (engine.js:262); see {@link addChunkOrThrow}.
|
|
80
|
-
*/
|
|
81
|
-
addChunk(turnId: string, frame: ChunkFrame, options?: AddChunkOptions): TurnChunk | null;
|
|
82
|
-
setParts(turnId: string, parts: unknown[]): void;
|
|
83
|
-
/**
|
|
84
|
-
* Set a turn's status (stores.js:72-79). Any status other than
|
|
85
|
-
* `cancelling` releases the session's active slot; listeners get a
|
|
86
|
-
* `(null, entry)` status notification.
|
|
87
|
-
*/
|
|
88
|
-
mark(turnId: string, status: TurnStatus): void;
|
|
89
|
-
/** Drop the turn and its listeners; release both session maps (stores.js:81-87). */
|
|
90
|
-
clear(turnId: string): void;
|
|
91
|
-
/** Chunks strictly after the cursor (stores.js:89-92); `[]` for unknown turns. */
|
|
92
|
-
chunksAfter(turnId: string, afterIndex?: number): TurnChunk[];
|
|
93
|
-
/** Subscribe to a turn's chunk/status emissions; returns unsubscribe (stores.js:94-102). */
|
|
94
|
-
subscribe(turnId: string, callback: TurnListener): () => void;
|
|
95
|
-
/** Fan out to listeners; listener errors are swallowed (stores.js:104-110). */
|
|
96
|
-
emit(turnId: string, chunk: TurnChunk | null, entry: TurnEntry): void;
|
|
97
|
-
}
|
|
98
|
-
/**
|
|
99
|
-
* The sealed/rejected-write error, byte-exact from engine.js:262. Thrown by
|
|
100
|
-
* the engine's `append()` whenever `addChunk` returns `null` (turn missing,
|
|
101
|
-
* terminal, or sealed).
|
|
102
|
-
*/
|
|
103
|
-
export declare const RAW_STREAM_WRITE_FAILED_MESSAGE = "Raw stream write failed before event application";
|
|
104
|
-
/**
|
|
105
|
-
* The engine's write law as a helper: append, and convert a rejected write
|
|
106
|
-
* into the exact engine throw (engine.js:261-262).
|
|
107
|
-
*/
|
|
108
|
-
export declare function addChunkOrThrow(store: TurnStore, turnId: string, frame: ChunkFrame, options?: AddChunkOptions): TurnChunk;
|
|
109
|
-
//# sourceMappingURL=turn-store.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"turn-store.d.ts","sourceRoot":"","sources":["../../src/turns/turn-store.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAE,KAAK,UAAU,EAAkB,MAAM,aAAa,CAAC;AAE9D,mDAAmD;AACnD,MAAM,WAAW,SAAS;IACxB,KAAK,EAAE,MAAM,CAAC;IACd,mEAAmE;IACnE,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,2EAA2E;AAC3E,MAAM,WAAW,SAAS;IACxB,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;IACf,kBAAkB,EAAE,MAAM,GAAG,IAAI,CAAC;IAClC,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,MAAM,EAAE,UAAU,CAAC;IACnB,MAAM,EAAE,SAAS,EAAE,CAAC;IACpB,KAAK,EAAE,OAAO,EAAE,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,uEAAuE;IACvE,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;;OAGG;IACH,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC;CAC1B;AAED,MAAM,WAAW,cAAc;IAC7B,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,M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IACH,IAAI,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,GAAG,IAAI;IAS9C,oFAAoF;IACpF,KAAK,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI;IAQ3B,kFAAkF;IAClF,WAAW,CAAC,MAAM,EAAE,MAAM,EAAE,UAAU,SAAK,GAAG,SAAS,EAAE;IAKzD,4FAA4F;IAC5F,SAAS,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,YAAY,GAAG,MAAM,IAAI;IAU7D,+EAA+E;IAC/E,IAAI,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,SAAS,GAAG,IAAI,EAAE,KAAK,EAAE,SAAS,GAAG,IAAI;CAOtE;AAED;;;;GAIG;AACH,eAAO,MAAM,+BAA+B,qDAAqD,CAAC;AAElG;;;GAGG;AACH,wBAAgB,eAAe,CAC7B,KAAK,EAAE,SAAS,EAChB,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,UAAU,EACjB,OAAO,GAAE,eAAoB,GAC5B,SAAS,CAIX"}
|
package/dist/turns/turn-store.js
DELETED
|
@@ -1,169 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* TurnStore — engine `chat-core/stores.js` (113 lines), ported in full.
|
|
3
|
-
* The in-memory raw-stream tempstore: one entry per turn, indexed chunks,
|
|
4
|
-
* seal-on-done, per-turn pub-sub, and the active/latest session maps.
|
|
5
|
-
*
|
|
6
|
-
* `Date.now()` is replaced by an injected {@link ClockMsPort} (constructor
|
|
7
|
-
* argument); everything else is byte-parity with the engine working tree.
|
|
8
|
-
*/
|
|
9
|
-
import { isActiveStatus } from './status.js';
|
|
10
|
-
export class TurnStore {
|
|
11
|
-
turns = new Map();
|
|
12
|
-
activeBySession = new Map();
|
|
13
|
-
latestBySession = new Map();
|
|
14
|
-
listeners = new Map();
|
|
15
|
-
clockMs;
|
|
16
|
-
constructor(clockMs) {
|
|
17
|
-
this.clockMs = clockMs;
|
|
18
|
-
}
|
|
19
|
-
/**
|
|
20
|
-
* Open a new turn. A different active turn on the same session is marked
|
|
21
|
-
* `aborted` first — the abort-on-restart law (stores.js:12-13).
|
|
22
|
-
*/
|
|
23
|
-
start({ sessionId, turnId, assistantMessageId, userMessageId }) {
|
|
24
|
-
const previous = this.activeBySession.get(sessionId);
|
|
25
|
-
if (previous && previous !== turnId)
|
|
26
|
-
this.mark(previous, 'aborted');
|
|
27
|
-
const entry = {
|
|
28
|
-
sessionId,
|
|
29
|
-
turnId,
|
|
30
|
-
assistantMessageId,
|
|
31
|
-
userMessageId,
|
|
32
|
-
status: 'streaming',
|
|
33
|
-
chunks: [],
|
|
34
|
-
parts: [],
|
|
35
|
-
createdAt: this.clockMs(),
|
|
36
|
-
updatedAt: this.clockMs(),
|
|
37
|
-
};
|
|
38
|
-
this.turns.set(turnId, entry);
|
|
39
|
-
this.activeBySession.set(sessionId, turnId);
|
|
40
|
-
this.latestBySession.set(sessionId, turnId);
|
|
41
|
-
return entry;
|
|
42
|
-
}
|
|
43
|
-
/** The session's active turn entry, if any (stores.js:31-34). */
|
|
44
|
-
active(sessionId) {
|
|
45
|
-
const turnId = this.activeBySession.get(sessionId);
|
|
46
|
-
return turnId ? this.turns.get(turnId) || null : null;
|
|
47
|
-
}
|
|
48
|
-
/**
|
|
49
|
-
* Number of turns still holding a tempstore slot — status in
|
|
50
|
-
* `['streaming', 'cancelling']` (stores.js:36-43).
|
|
51
|
-
*/
|
|
52
|
-
activeCount() {
|
|
53
|
-
let count = 0;
|
|
54
|
-
for (const turnId of this.activeBySession.values()) {
|
|
55
|
-
const entry = this.turns.get(turnId);
|
|
56
|
-
if (entry && isActiveStatus(entry.status))
|
|
57
|
-
count += 1;
|
|
58
|
-
}
|
|
59
|
-
return count;
|
|
60
|
-
}
|
|
61
|
-
/**
|
|
62
|
-
* Selection law (stores.js:45-47): the session's active turn wins; else the
|
|
63
|
-
* most recently started turn for the session, even after it went terminal.
|
|
64
|
-
*/
|
|
65
|
-
latest(sessionId) {
|
|
66
|
-
return this.active(sessionId) || this.get(this.latestBySession.get(sessionId));
|
|
67
|
-
}
|
|
68
|
-
get(turnId) {
|
|
69
|
-
return (turnId === undefined ? null : this.turns.get(turnId)) || null;
|
|
70
|
-
}
|
|
71
|
-
/**
|
|
72
|
-
* Append a chunk (stores.js:53-65). Returns `null` — a rejected write —
|
|
73
|
-
* when the turn is missing, no longer active, or already sealed. The engine
|
|
74
|
-
* converts that `null` into the thrown "Raw stream write failed before
|
|
75
|
-
* event application" (engine.js:262); see {@link addChunkOrThrow}.
|
|
76
|
-
*/
|
|
77
|
-
addChunk(turnId, frame, options = {}) {
|
|
78
|
-
const entry = this.turns.get(turnId);
|
|
79
|
-
if (!entry || !isActiveStatus(entry.status))
|
|
80
|
-
return null;
|
|
81
|
-
if (Number.isInteger(entry.sealedIndex))
|
|
82
|
-
return null;
|
|
83
|
-
const index = entry.chunks.length;
|
|
84
|
-
const data = typeof frame === 'function' ? frame(index) : frame;
|
|
85
|
-
const chunk = { index, data, timestamp: this.clockMs() };
|
|
86
|
-
entry.chunks.push(chunk);
|
|
87
|
-
if (options.seal === true)
|
|
88
|
-
entry.sealedIndex = index;
|
|
89
|
-
entry.updatedAt = this.clockMs();
|
|
90
|
-
this.emit(turnId, chunk, entry);
|
|
91
|
-
return chunk;
|
|
92
|
-
}
|
|
93
|
-
setParts(turnId, parts) {
|
|
94
|
-
const entry = this.turns.get(turnId);
|
|
95
|
-
if (entry)
|
|
96
|
-
entry.parts = parts;
|
|
97
|
-
}
|
|
98
|
-
/**
|
|
99
|
-
* Set a turn's status (stores.js:72-79). Any status other than
|
|
100
|
-
* `cancelling` releases the session's active slot; listeners get a
|
|
101
|
-
* `(null, entry)` status notification.
|
|
102
|
-
*/
|
|
103
|
-
mark(turnId, status) {
|
|
104
|
-
const entry = this.turns.get(turnId);
|
|
105
|
-
if (!entry)
|
|
106
|
-
return;
|
|
107
|
-
entry.status = status;
|
|
108
|
-
entry.updatedAt = this.clockMs();
|
|
109
|
-
if (status !== 'cancelling' && this.activeBySession.get(entry.sessionId) === turnId)
|
|
110
|
-
this.activeBySession.delete(entry.sessionId);
|
|
111
|
-
this.emit(turnId, null, entry);
|
|
112
|
-
}
|
|
113
|
-
/** Drop the turn and its listeners; release both session maps (stores.js:81-87). */
|
|
114
|
-
clear(turnId) {
|
|
115
|
-
const entry = this.turns.get(turnId);
|
|
116
|
-
if (entry && this.activeBySession.get(entry.sessionId) === turnId)
|
|
117
|
-
this.activeBySession.delete(entry.sessionId);
|
|
118
|
-
if (entry && this.latestBySession.get(entry.sessionId) === turnId)
|
|
119
|
-
this.latestBySession.delete(entry.sessionId);
|
|
120
|
-
this.turns.delete(turnId);
|
|
121
|
-
this.listeners.delete(turnId);
|
|
122
|
-
}
|
|
123
|
-
/** Chunks strictly after the cursor (stores.js:89-92); `[]` for unknown turns. */
|
|
124
|
-
chunksAfter(turnId, afterIndex = -1) {
|
|
125
|
-
const entry = this.turns.get(turnId);
|
|
126
|
-
return entry ? entry.chunks.filter((chunk) => chunk.index > afterIndex) : [];
|
|
127
|
-
}
|
|
128
|
-
/** Subscribe to a turn's chunk/status emissions; returns unsubscribe (stores.js:94-102). */
|
|
129
|
-
subscribe(turnId, callback) {
|
|
130
|
-
if (!this.listeners.has(turnId))
|
|
131
|
-
this.listeners.set(turnId, new Set());
|
|
132
|
-
const set = this.listeners.get(turnId);
|
|
133
|
-
set.add(callback);
|
|
134
|
-
return () => {
|
|
135
|
-
set.delete(callback);
|
|
136
|
-
if (set.size === 0)
|
|
137
|
-
this.listeners.delete(turnId);
|
|
138
|
-
};
|
|
139
|
-
}
|
|
140
|
-
/** Fan out to listeners; listener errors are swallowed (stores.js:104-110). */
|
|
141
|
-
emit(turnId, chunk, entry) {
|
|
142
|
-
const set = this.listeners.get(turnId);
|
|
143
|
-
if (!set)
|
|
144
|
-
return;
|
|
145
|
-
for (const callback of set) {
|
|
146
|
-
try {
|
|
147
|
-
callback(chunk, entry);
|
|
148
|
-
}
|
|
149
|
-
catch { }
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
/**
|
|
154
|
-
* The sealed/rejected-write error, byte-exact from engine.js:262. Thrown by
|
|
155
|
-
* the engine's `append()` whenever `addChunk` returns `null` (turn missing,
|
|
156
|
-
* terminal, or sealed).
|
|
157
|
-
*/
|
|
158
|
-
export const RAW_STREAM_WRITE_FAILED_MESSAGE = 'Raw stream write failed before event application';
|
|
159
|
-
/**
|
|
160
|
-
* The engine's write law as a helper: append, and convert a rejected write
|
|
161
|
-
* into the exact engine throw (engine.js:261-262).
|
|
162
|
-
*/
|
|
163
|
-
export function addChunkOrThrow(store, turnId, frame, options = {}) {
|
|
164
|
-
const chunk = store.addChunk(turnId, frame, options);
|
|
165
|
-
if (!chunk)
|
|
166
|
-
throw new Error(RAW_STREAM_WRITE_FAILED_MESSAGE);
|
|
167
|
-
return chunk;
|
|
168
|
-
}
|
|
169
|
-
//# sourceMappingURL=turn-store.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"turn-store.js","sourceRoot":"","sources":["../../src/turns/turn-store.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,EAAmB,cAAc,EAAE,MAAM,aAAa,CAAC;AA+C9D,MAAM,OAAO,SAAS;IACX,KAAK,GAAG,IAAI,GAAG,EAAqB,CAAC;IACrC,eAAe,GAAG,IAAI,GAAG,EAAkB,CAAC;IAC5C,eAAe,GAAG,IAAI,GAAG,EAAkB,CAAC;IAC5C,SAAS,GAAG,IAAI,GAAG,EAA6B,CAAC;IACzC,OAAO,CAAc;IAEtC,YAAY,OAAoB;QAC9B,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACzB,CAAC;IAED;;;OAGG;IACH,KAAK,CAAC,EAAE,SAAS,EAAE,MAAM,EAAE,kBAAkB,EAAE,aAAa,EAAkB;QAC5E,MAAM,QAAQ,GAAG,IAAI,CAAC,eAAe,CAAC,GAAG,CAAC,SAAS,CA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,CAAC;gBAAC,QAAQ,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;YAAC,CAAC;YAAC,MAAM,CAAC,CAAA,CAAC;QAC1C,CAAC;IACH,CAAC;CACF;AAED;;;;GAIG;AACH,MAAM,CAAC,MAAM,+BAA+B,GAAG,kDAAkD,CAAC;AAElG;;;GAGG;AACH,MAAM,UAAU,eAAe,CAC7B,KAAgB,EAChB,MAAc,EACd,KAAiB,EACjB,UAA2B,EAAE;IAE7B,MAAM,KAAK,GAAG,KAAK,CAAC,QAAQ,CAAC,MAAM,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC;IACrD,IAAI,CAAC,KAAK;QAAE,MAAM,IAAI,KAAK,CAAC,+BAA+B,CAAC,CAAC;IAC7D,OAAO,KAAK,CAAC;AACf,CAAC"}
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Client-side warm-envelope cache — the pure helpers of
|
|
3
|
-
* `amalgm-ui/lib/chat/launchEnvelopeClientCache.ts`. The React hook, the
|
|
4
|
-
* module-level Maps, the debounce timer, and the warm POST are host; this
|
|
5
|
-
* module owns the key law, the usability check, the debounce constant, and
|
|
6
|
-
* the payload-key law.
|
|
7
|
-
*
|
|
8
|
-
* DEAD-LAYER WOUND (docs/warm-payloads.md, "Layer B ... currently dead"):
|
|
9
|
-
* in ChatView today `chatPayloadId` is always present on the request, so
|
|
10
|
-
* the guard `request && !request.chatPayloadId`
|
|
11
|
-
* (`launchEnvelopeClientCache.ts:48-50`) makes `payloadKey` ALWAYS null —
|
|
12
|
-
* no warm POST is ever issued and every send logs `launchEnvelope: "miss"`.
|
|
13
|
-
* Whether that is deliberate (machine payload made authoritative in
|
|
14
|
-
* `0f778ba`) or a regression is an open product question. The guard is
|
|
15
|
-
* ported faithfully anyway (engineParity with the UI source).
|
|
16
|
-
*/
|
|
17
|
-
import type { LaunchEnvelopeRequest } from './payload.js';
|
|
18
|
-
/** Client cache-entry shape — `launchEnvelopeClientCache.ts:7-16`. */
|
|
19
|
-
export type LaunchEnvelopeCacheEntry = {
|
|
20
|
-
id: string;
|
|
21
|
-
fingerprint: string;
|
|
22
|
-
key: string;
|
|
23
|
-
cacheKey: string;
|
|
24
|
-
machineId: string | null;
|
|
25
|
-
expiresAt: number;
|
|
26
|
-
prepareMs: number;
|
|
27
|
-
fetchedMs: number;
|
|
28
|
-
};
|
|
29
|
-
/** `launchEnvelopeClientCache.ts:18` — warm 100 ms after any selection change. */
|
|
30
|
-
export declare const CACHE_WARM_DELAY_MS = 100;
|
|
31
|
-
/** Machine half of the cache key — `launchEnvelopeClientCache.ts:23-25`. */
|
|
32
|
-
export declare function machineKey(machineId: string | null | undefined): string;
|
|
33
|
-
/** Cache-key law — `launchEnvelopeClientCache.ts:27-32`: `machineKey\0payloadKey`. */
|
|
34
|
-
export declare function launchEnvelopeCacheKey(machineId: string | null | undefined, payloadKey: string): string;
|
|
35
|
-
/**
|
|
36
|
-
* Payload-key law — `launchEnvelopeClientCache.ts:48-51`: the warm body is
|
|
37
|
-
* the stable JSON of the request, but only when the request exists AND has
|
|
38
|
-
* no `chatPayloadId` (see the dead-layer wound above — in practice this is
|
|
39
|
-
* always null today).
|
|
40
|
-
*/
|
|
41
|
-
export declare function launchEnvelopePayloadKey(request: LaunchEnvelopeRequest | null): string | null;
|
|
42
|
-
/**
|
|
43
|
-
* Usability check — `launchEnvelopeClientCache.ts:34-38`: an entry is
|
|
44
|
-
* usable while `expiresAt > now`; the UI reads `Date.now()`, injected here.
|
|
45
|
-
*/
|
|
46
|
-
export declare function usableEntry(entry: LaunchEnvelopeCacheEntry | undefined, nowMs: number): LaunchEnvelopeCacheEntry | null;
|
|
47
|
-
//# sourceMappingURL=client-cache.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"client-cache.d.ts","sourceRoot":"","sources":["../../src/warm/client-cache.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAC;AAG1D,sEAAsE;AACtE,MAAM,MAAM,wBAAwB,GAAG;IACrC,EAAE,EAAE,MAAM,CAAC;IACX,WAAW,EAAE,MAAM,CAAC;IACpB,GAAG,EAAE,MAAM,CAAC;IACZ,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF,kFAAkF;AAClF,eAAO,MAAM,mBAAmB,MAAM,CAAC;AAEvC,4EAA4E;AAC5E,wBAAgB,UAAU,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,MAAM,CAEvE;AAED,sFAAsF;AACtF,wBAAgB,sBAAsB,CACpC,SAAS,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,EACpC,UAAU,EAAE,MAAM,GACjB,MAAM,CAER;AAED;;;;;GAKG;AACH,wBAAgB,wBAAwB,CACtC,OAAO,EAAE,qBAAqB,GAAG,IAAI,GACpC,MAAM,GAAG,IAAI,CAEf;AAED;;;GAGG;AACH,wBAAgB,WAAW,CACzB,KAAK,EAAE,wBAAwB,GAAG,SAAS,EAC3C,KAAK,EAAE,MAAM,GACZ,wBAAwB,GAAG,IAAI,CAIjC"}
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Client-side warm-envelope cache — the pure helpers of
|
|
3
|
-
* `amalgm-ui/lib/chat/launchEnvelopeClientCache.ts`. The React hook, the
|
|
4
|
-
* module-level Maps, the debounce timer, and the warm POST are host; this
|
|
5
|
-
* module owns the key law, the usability check, the debounce constant, and
|
|
6
|
-
* the payload-key law.
|
|
7
|
-
*
|
|
8
|
-
* DEAD-LAYER WOUND (docs/warm-payloads.md, "Layer B ... currently dead"):
|
|
9
|
-
* in ChatView today `chatPayloadId` is always present on the request, so
|
|
10
|
-
* the guard `request && !request.chatPayloadId`
|
|
11
|
-
* (`launchEnvelopeClientCache.ts:48-50`) makes `payloadKey` ALWAYS null —
|
|
12
|
-
* no warm POST is ever issued and every send logs `launchEnvelope: "miss"`.
|
|
13
|
-
* Whether that is deliberate (machine payload made authoritative in
|
|
14
|
-
* `0f778ba`) or a regression is an open product question. The guard is
|
|
15
|
-
* ported faithfully anyway (engineParity with the UI source).
|
|
16
|
-
*/
|
|
17
|
-
import { stableJson } from './payload.js';
|
|
18
|
-
/** `launchEnvelopeClientCache.ts:18` — warm 100 ms after any selection change. */
|
|
19
|
-
export const CACHE_WARM_DELAY_MS = 100;
|
|
20
|
-
/** Machine half of the cache key — `launchEnvelopeClientCache.ts:23-25`. */
|
|
21
|
-
export function machineKey(machineId) {
|
|
22
|
-
return machineId?.trim() || 'local';
|
|
23
|
-
}
|
|
24
|
-
/** Cache-key law — `launchEnvelopeClientCache.ts:27-32`: `machineKey\0payloadKey`. */
|
|
25
|
-
export function launchEnvelopeCacheKey(machineId, payloadKey) {
|
|
26
|
-
return `${machineKey(machineId)}\0${payloadKey}`;
|
|
27
|
-
}
|
|
28
|
-
/**
|
|
29
|
-
* Payload-key law — `launchEnvelopeClientCache.ts:48-51`: the warm body is
|
|
30
|
-
* the stable JSON of the request, but only when the request exists AND has
|
|
31
|
-
* no `chatPayloadId` (see the dead-layer wound above — in practice this is
|
|
32
|
-
* always null today).
|
|
33
|
-
*/
|
|
34
|
-
export function launchEnvelopePayloadKey(request) {
|
|
35
|
-
return request && !request.chatPayloadId ? stableJson(request) : null;
|
|
36
|
-
}
|
|
37
|
-
/**
|
|
38
|
-
* Usability check — `launchEnvelopeClientCache.ts:34-38`: an entry is
|
|
39
|
-
* usable while `expiresAt > now`; the UI reads `Date.now()`, injected here.
|
|
40
|
-
*/
|
|
41
|
-
export function usableEntry(entry, nowMs) {
|
|
42
|
-
if (!entry)
|
|
43
|
-
return null;
|
|
44
|
-
if (entry.expiresAt <= nowMs)
|
|
45
|
-
return null;
|
|
46
|
-
return entry;
|
|
47
|
-
}
|
|
48
|
-
//# sourceMappingURL=client-cache.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"client-cache.js","sourceRoot":"","sources":["../../src/warm/client-cache.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAGH,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAc1C,kFAAkF;AAClF,MAAM,CAAC,MAAM,mBAAmB,GAAG,GAAG,CAAC;AAEvC,4EAA4E;AAC5E,MAAM,UAAU,UAAU,CAAC,SAAoC;IAC7D,OAAO,SAAS,EAAE,IAAI,EAAE,IAAI,OAAO,CAAC;AACtC,CAAC;AAED,sFAAsF;AACtF,MAAM,UAAU,sBAAsB,CACpC,SAAoC,EACpC,UAAkB;IAElB,OAAO,GAAG,UAAU,CAAC,SAAS,CAAC,KAAK,UAAU,EAAE,CAAC;AACnD,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,wBAAwB,CACtC,OAAqC;IAErC,OAAO,OAAO,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;AACxE,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,WAAW,CACzB,KAA2C,EAC3C,KAAa;IAEb,IAAI,CAAC,KAAK;QAAE,OAAO,IAAI,CAAC;IACxB,IAAI,KAAK,CAAC,SAAS,IAAI,KAAK;QAAE,OAAO,IAAI,CAAC;IAC1C,OAAO,KAAK,CAAC;AACf,CAAC"}
|
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Server-side launch-envelope cache policy — the pure laws of
|
|
3
|
-
* `amalgm-ui/lib/server/agentLaunchEnvelopeCache.ts` (Layer B in
|
|
4
|
-
* docs/warm-payloads.md).
|
|
5
|
-
*
|
|
6
|
-
* The `globalThis` Map itself, `crypto.randomUUID` id minting, and the
|
|
7
|
-
* store/get functions are host effects — this module exports the
|
|
8
|
-
* fingerprint law (sha256 injected via Sha256HexPort), the stable-sort
|
|
9
|
-
* law, the TTL/cap constants, and the prune decision as a pure function
|
|
10
|
-
* over an entries array + a clock reading.
|
|
11
|
-
*/
|
|
12
|
-
import type { Sha256HexPort } from '../ports.js';
|
|
13
|
-
/** `agentLaunchEnvelopeCache.ts:4` — a warmed envelope lives 10 minutes. */
|
|
14
|
-
export declare const ENVELOPE_TTL_MS: number;
|
|
15
|
-
/** `agentLaunchEnvelopeCache.ts:5` — at most 200 envelopes; overflow evicts oldest-prepared. */
|
|
16
|
-
export declare const MAX_ENVELOPES = 200;
|
|
17
|
-
/**
|
|
18
|
-
* Cached-entry shape — `agentLaunchEnvelopeCache.ts:7-15`. The UI types
|
|
19
|
-
* `envelope` as `PreparedLaunchEnvelope` (a Next-server type); the SDK
|
|
20
|
-
* carries it opaquely.
|
|
21
|
-
*/
|
|
22
|
-
export type CachedAgentLaunchEnvelope = {
|
|
23
|
-
id: string;
|
|
24
|
-
userId: string;
|
|
25
|
-
fingerprint: string;
|
|
26
|
-
preparedAt: number;
|
|
27
|
-
expiresAt: number;
|
|
28
|
-
prepareMs: number;
|
|
29
|
-
envelope: unknown;
|
|
30
|
-
};
|
|
31
|
-
/**
|
|
32
|
-
* The subset of the raw `/api/agent-stream` body the fingerprint reads —
|
|
33
|
-
* field types as in `prepareAgentStreamPayload.ts:81-114`
|
|
34
|
-
* (`RawAgentStreamBody`); only the fingerprinted fields are mirrored.
|
|
35
|
-
*/
|
|
36
|
-
export type LaunchEnvelopeFingerprintInput = {
|
|
37
|
-
chatInput?: unknown;
|
|
38
|
-
modelId?: string;
|
|
39
|
-
harness?: string;
|
|
40
|
-
authMethod?: string;
|
|
41
|
-
mcpAppIds?: string[];
|
|
42
|
-
systemPrompt?: string;
|
|
43
|
-
modelSettings?: unknown;
|
|
44
|
-
chatPayloadId?: string;
|
|
45
|
-
chatPayloadRevision?: string;
|
|
46
|
-
chatPayloadComputerId?: string;
|
|
47
|
-
cloudWorkspaceRef?: unknown;
|
|
48
|
-
};
|
|
49
|
-
/**
|
|
50
|
-
* Stable-sort law — `agentLaunchEnvelopeCache.ts:28-37`. Recursively
|
|
51
|
-
* rebuilds objects with sorted keys so `JSON.stringify` is deterministic.
|
|
52
|
-
* (Unlike `stableJson` in payload.ts this keeps `undefined` values as
|
|
53
|
-
* object entries — the fingerprint input `?? null`s every field first, so
|
|
54
|
-
* the difference never surfaces there.)
|
|
55
|
-
*/
|
|
56
|
-
export declare function stableValue(value: unknown): unknown;
|
|
57
|
-
/**
|
|
58
|
-
* Fingerprint law — `agentLaunchEnvelopeCache.ts:52-72`: sha256 hex over
|
|
59
|
-
* the JSON of the stable-sorted `(userId, chatInput, modelId, harness,
|
|
60
|
-
* authMethod, mcpAppIds, systemPrompt, modelSettings, chatPayloadId,
|
|
61
|
-
* chatPayloadRevision, chatPayloadComputerId, cloudWorkspaceRef)` tuple,
|
|
62
|
-
* every absent field coerced to null. The UI calls
|
|
63
|
-
* `crypto.createHash('sha256')...digest('hex')`; the host injects the
|
|
64
|
-
* equivalent as `sha256Hex`.
|
|
65
|
-
*/
|
|
66
|
-
export declare function fingerprintLaunchEnvelopeInput(userId: string, body: LaunchEnvelopeFingerprintInput, sha256Hex: Sha256HexPort): string;
|
|
67
|
-
/** Expiry law — `agentLaunchEnvelopeCache.ts:88`: expiresAt = preparedAt + TTL. */
|
|
68
|
-
export declare function envelopeExpiresAt(preparedAtMs: number): number;
|
|
69
|
-
/**
|
|
70
|
-
* Prune law — `agentLaunchEnvelopeCache.ts:39-50`, as a pure function:
|
|
71
|
-
* drop every entry with `expiresAt <= now`; then, if still over the cap,
|
|
72
|
-
* evict the oldest by `preparedAt` until exactly `MAX_ENVELOPES` remain.
|
|
73
|
-
* Returns the ids to delete; the host applies them to its Map.
|
|
74
|
-
*/
|
|
75
|
-
export declare function pruneAgentLaunchEnvelopes(entries: readonly CachedAgentLaunchEnvelope[], nowMs: number): {
|
|
76
|
-
expiredIds: string[];
|
|
77
|
-
overflowIds: string[];
|
|
78
|
-
};
|
|
79
|
-
//# sourceMappingURL=envelope-cache.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"envelope-cache.d.ts","sourceRoot":"","sources":["../../src/warm/envelope-cache.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAEjD,4EAA4E;AAC5E,eAAO,MAAM,eAAe,QAAiB,CAAC;AAC9C,gGAAgG;AAChG,eAAO,MAAM,aAAa,MAAM,CAAC;AAEjC;;;;GAIG;AACH,MAAM,MAAM,yBAAyB,GAAG;IACtC,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,OAAO,CAAC;CACnB,CAAC;AAEF;;;;GAIG;AACH,MAAM,MAAM,8BAA8B,GAAG;IAC3C,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;IACrB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,qBAAqB,CAAC,EAAE,MAAM,CAAC;IAC/B,iBAAiB,CAAC,EAAE,OAAO,CAAC;CAC7B,CAAC;AAEF;;;;;;GAMG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CASnD;AAED;;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