@grackle-ai/common 0.132.0 → 0.132.2

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.
@@ -0,0 +1,129 @@
1
+ /**
2
+ * AgentEvent → AHP SessionAction mapper (AHP HR1b / RFC #1292).
3
+ *
4
+ * Stateless function that translates a single PowerLine `AgentEvent` (or any
5
+ * structurally-compatible value — see {@link AgentEventFields}) into one or
6
+ * more AHP `SessionAction` payloads. The mapper requires a {@link MapperContext}
7
+ * from the caller to track turn state and tool-call pairing.
8
+ *
9
+ * Lives in `@grackle-ai/common` because the live gRPC transport
10
+ * (`GrpcHostTransport` in `@grackle-ai/adapter-sdk`) consumes it, and
11
+ * HR8d's PowerLine-side AHP wire emits AHP actions by running this mapper
12
+ * forward against the runtime's `AgentEvent` stream. Decoupling from
13
+ * `powerline.AgentEvent` lets HR8d remove the gRPC path entirely without
14
+ * touching the mapper.
15
+ *
16
+ * @module ahp-mapper
17
+ */
18
+ import { type StateAction } from "@grackle-ai/ahp";
19
+ /**
20
+ * Structural subset of `powerline.AgentEvent` that the mapper plus its
21
+ * downstream consumers actually read.
22
+ *
23
+ * Any object with these fields can be passed to `mapAgentEvent` —
24
+ * proto-generated `AgentEvent` messages from the live gRPC stream and plain
25
+ * objects reconstructed from `session_actions` rows during replay both qualify.
26
+ *
27
+ * The fields the mapper itself reads are `type`, `content`, `toolCallId`,
28
+ * `turnId`, and `diagnostic`. `timestamp` and `raw` are not consulted by the
29
+ * mapper but are included here so downstream consumers (e.g. `event-processor`
30
+ * in `@grackle-ai/core`) can convert envelopes back into `grackle.SessionEvent`
31
+ * proto messages without re-importing the powerline types.
32
+ */
33
+ export interface AgentEventFields {
34
+ /** Event type discriminator (e.g. `"turn_started"`, `"tool_use"`). */
35
+ type: string;
36
+ /** Event payload (string, often JSON). Empty/missing maps to `""`. */
37
+ content?: string;
38
+ /** First-class tool call ID for `tool_use` / `tool_result` pairing (HR3). */
39
+ toolCallId?: string;
40
+ /** Turn ID this event belongs to (overrides the active context turn). */
41
+ turnId?: string;
42
+ /** `true` for diagnostic system events that route to OTLP telemetry (HR7). */
43
+ diagnostic?: boolean;
44
+ /** ISO-8601 timestamp string (passed through from the runtime). */
45
+ timestamp?: string;
46
+ /** Raw event body — opaque to the mapper, used by JSONL persistence. */
47
+ raw?: string;
48
+ }
49
+ /**
50
+ * Disposition of a single AgentEvent after mapping.
51
+ */
52
+ export type Disposition = "mapped" | "carried" | "dropped";
53
+ /**
54
+ * Metadata describing how an AgentEvent was handled.
55
+ */
56
+ export interface MappingNote {
57
+ /** Index of the AgentEvent in the stream (0-based). */
58
+ index: number;
59
+ /** The original AgentEvent type string. */
60
+ type: string;
61
+ /** Whether the event was mapped to AHP actions, carried as metadata, or dropped. */
62
+ disposition: Disposition;
63
+ /** Human-readable detail about the mapping decision. */
64
+ detail: string;
65
+ }
66
+ /**
67
+ * Context maintained by the caller across a stream of events.
68
+ * Tracks turn state and tool-call pairing.
69
+ */
70
+ export interface MapperContext {
71
+ /** ID of the currently active turn, or `undefined` if no turn has started. */
72
+ turnId?: string;
73
+ /**
74
+ * Stack of open tool call IDs (LIFO). Used for pairing `tool_result` events
75
+ * with their corresponding `tool_use` when `toolCallId` is not available.
76
+ */
77
+ openToolCalls: string[];
78
+ /**
79
+ * Monotonically increasing counter for generating unique part IDs within
80
+ * the current session.
81
+ */
82
+ partCounter: number;
83
+ /**
84
+ * Monotonically increasing event index. Stored in snapshots so delta replay
85
+ * can seed the starting index and generate consistent synthetic turn/tool IDs
86
+ * (e.g. `turn-${index}`) for events that lack explicit IDs.
87
+ */
88
+ eventIndex: number;
89
+ /**
90
+ * Accumulated `_meta` fields carried across events. The mapper merges
91
+ * cost and runtimeSessionId into this object.
92
+ */
93
+ metaAccumulator: {
94
+ /** Accumulated cost in millicents (AHP-upstream gap; rides on `_meta`). */
95
+ costMillicents?: number;
96
+ /** Runtime-provided session ID from the `runtime_session_id` event. */
97
+ runtimeSessionId?: string;
98
+ };
99
+ }
100
+ /** Result of mapping a single AgentEvent. */
101
+ export interface MapResult {
102
+ /** AHP StateAction[] produced from this event (all session-specific). */
103
+ actions: StateAction[];
104
+ /** Mapping disposition for this event (always zero or one). */
105
+ note?: MappingNote;
106
+ }
107
+ /**
108
+ * Map a PowerLine `AgentEvent` into AHP `SessionAction` payloads.
109
+ *
110
+ * | AgentEvent type | AHP action(s) | Disposition |
111
+ * |-----------------|---------------|-------------|
112
+ * | `turn_started` | `SessionTurnStarted` | mapped |
113
+ * | `turn_complete` | `SessionTurnComplete` | mapped |
114
+ * | `input_needed` | advisory only | dropped |
115
+ * | `text` | `SessionResponsePart(markdown)` | mapped |
116
+ * | `tool_use` | `SessionToolCallStart` + `SessionToolCallReady` | mapped |
117
+ * | `tool_result` | `SessionToolCallComplete` | mapped |
118
+ * | `usage` | (none — cost accumulated in `_meta`) | carried |
119
+ * | `error` (in-turn) | `SessionError` | mapped |
120
+ * | `error` (pre-turn) | `SessionCreationFailed` | mapped |
121
+ * | `status: failed` | `SessionError` or `SessionCreationFailed` | mapped |
122
+ * | `status: killed/terminated` | `SessionError` (abandoned turn) | conditional |
123
+ * | `status: completed/waiting_input/running` | dropped | dropped |
124
+ * | `system` (diagnostic) | dropped (OTLP telemetry) | carried |
125
+ * | `system` (non-diagnostic) | `SessionResponsePart(systemNotification)` | mapped |
126
+ * | `runtime_session_id` | `_meta.runtimeSessionId` | carried |
127
+ */
128
+ export declare function mapAgentEvent(event: AgentEventFields, index: number, context: MapperContext): MapResult;
129
+ //# sourceMappingURL=ahp-mapper.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ahp-mapper.d.ts","sourceRoot":"","sources":["../src/ahp-mapper.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EAML,KAAK,WAAW,EAEjB,MAAM,iBAAiB,CAAC;AAEzB;;;;;;;;;;;;;GAaG;AACH,MAAM,WAAW,gBAAgB;IAC/B,sEAAsE;IACtE,I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E,gBAAgB,EACvB,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,aAAa,GACrB,SAAS,CA4cX"}
@@ -0,0 +1,504 @@
1
+ /**
2
+ * AgentEvent → AHP SessionAction mapper (AHP HR1b / RFC #1292).
3
+ *
4
+ * Stateless function that translates a single PowerLine `AgentEvent` (or any
5
+ * structurally-compatible value — see {@link AgentEventFields}) into one or
6
+ * more AHP `SessionAction` payloads. The mapper requires a {@link MapperContext}
7
+ * from the caller to track turn state and tool-call pairing.
8
+ *
9
+ * Lives in `@grackle-ai/common` because the live gRPC transport
10
+ * (`GrpcHostTransport` in `@grackle-ai/adapter-sdk`) consumes it, and
11
+ * HR8d's PowerLine-side AHP wire emits AHP actions by running this mapper
12
+ * forward against the runtime's `AgentEvent` stream. Decoupling from
13
+ * `powerline.AgentEvent` lets HR8d remove the gRPC path entirely without
14
+ * touching the mapper.
15
+ *
16
+ * @module ahp-mapper
17
+ */
18
+ import { ActionType, ToolCallConfirmationReason, ToolResultContentType, ResponsePartKind, } from "@grackle-ai/ahp";
19
+ /** Safely parse an event's content JSON, returning a record or undefined on failure. */
20
+ function safeParseContent(content) {
21
+ if (!content)
22
+ return undefined;
23
+ try {
24
+ return JSON.parse(content);
25
+ }
26
+ catch {
27
+ return undefined;
28
+ }
29
+ }
30
+ /** Build an ErrorInfo from a message string. */
31
+ function makeErrorInfo(message) {
32
+ return { message, errorType: "unknown" };
33
+ }
34
+ /** Build a ToolResultContent from a string. */
35
+ function makeTextResult(text) {
36
+ return { type: ToolResultContentType.Text, text };
37
+ }
38
+ /** Check whether a system event is a diagnostic (HR7) that routes to OTLP. */
39
+ function isDiagnosticEvent(event) {
40
+ if (event.diagnostic)
41
+ return true;
42
+ const parsed = safeParseContent(event.content);
43
+ if (parsed) {
44
+ const keys = Object.keys(parsed);
45
+ if ((keys.includes("span") || keys.includes("trace") || keys.includes("level")) &&
46
+ !keys.some((k) => k === "text" || k === "content" || k === "tool_name")) {
47
+ return true;
48
+ }
49
+ }
50
+ return false;
51
+ }
52
+ /**
53
+ * Get a string field from parsed JSON content with fallbacks.
54
+ * @param parsed - The parsed JSON object to look up.
55
+ * @param fields - Field names to try (in order).
56
+ * @param fallback - Literal fallback value if no field is found.
57
+ * @returns The first found field value as a string, or the fallback.
58
+ */
59
+ function str(parsed, fields, fallback) {
60
+ for (const field of fields) {
61
+ const val = parsed[field];
62
+ if (val !== undefined)
63
+ return String(val);
64
+ }
65
+ return fallback;
66
+ }
67
+ /**
68
+ * Map a PowerLine `AgentEvent` into AHP `SessionAction` payloads.
69
+ *
70
+ * | AgentEvent type | AHP action(s) | Disposition |
71
+ * |-----------------|---------------|-------------|
72
+ * | `turn_started` | `SessionTurnStarted` | mapped |
73
+ * | `turn_complete` | `SessionTurnComplete` | mapped |
74
+ * | `input_needed` | advisory only | dropped |
75
+ * | `text` | `SessionResponsePart(markdown)` | mapped |
76
+ * | `tool_use` | `SessionToolCallStart` + `SessionToolCallReady` | mapped |
77
+ * | `tool_result` | `SessionToolCallComplete` | mapped |
78
+ * | `usage` | (none — cost accumulated in `_meta`) | carried |
79
+ * | `error` (in-turn) | `SessionError` | mapped |
80
+ * | `error` (pre-turn) | `SessionCreationFailed` | mapped |
81
+ * | `status: failed` | `SessionError` or `SessionCreationFailed` | mapped |
82
+ * | `status: killed/terminated` | `SessionError` (abandoned turn) | conditional |
83
+ * | `status: completed/waiting_input/running` | dropped | dropped |
84
+ * | `system` (diagnostic) | dropped (OTLP telemetry) | carried |
85
+ * | `system` (non-diagnostic) | `SessionResponsePart(systemNotification)` | mapped |
86
+ * | `runtime_session_id` | `_meta.runtimeSessionId` | carried |
87
+ */
88
+ export function mapAgentEvent(event, index, context) {
89
+ const actions = [];
90
+ let note;
91
+ const { type, content, toolCallId, turnId } = event;
92
+ // Proto string fields default to "", treat empty as undefined
93
+ const eventTurnId = turnId || undefined;
94
+ const parsed = safeParseContent(content);
95
+ const hasParsed = parsed !== undefined;
96
+ switch (type) {
97
+ // ─── Turn lifecycle ────────────────────────────────────────────
98
+ case "turn_started": {
99
+ const userMessage = hasParsed ? str(parsed, ["user_message"], content || "") : content || "";
100
+ // Always derive a fresh turnId when eventTurnId is absent — don't inherit stale context.turnId
101
+ const derivedTurnId = eventTurnId || `turn-${index}`;
102
+ actions.push({
103
+ type: ActionType.SessionTurnStarted,
104
+ turnId: derivedTurnId,
105
+ userMessage: { text: userMessage },
106
+ });
107
+ context.turnId = derivedTurnId;
108
+ context.openToolCalls = [];
109
+ // partCounter is NOT reset here — it increments across turns so part IDs
110
+ // are globally unique within a session (part-0, part-1, … across all turns).
111
+ note = {
112
+ index,
113
+ type: "turn_started",
114
+ disposition: "mapped",
115
+ detail: `Mapped to SessionTurnStarted (turnId=${context.turnId})`,
116
+ };
117
+ break;
118
+ }
119
+ case "turn_complete": {
120
+ const turnId = eventTurnId || context.turnId;
121
+ if (turnId) {
122
+ actions.push({
123
+ type: ActionType.SessionTurnComplete,
124
+ turnId,
125
+ });
126
+ context.turnId = undefined;
127
+ context.openToolCalls = [];
128
+ note = {
129
+ index,
130
+ type: "turn_complete",
131
+ disposition: "mapped",
132
+ detail: `Mapped to SessionTurnComplete (turnId=${turnId})`,
133
+ };
134
+ }
135
+ else {
136
+ note = {
137
+ index,
138
+ type: "turn_complete",
139
+ disposition: "dropped",
140
+ detail: "No active turn to complete",
141
+ };
142
+ }
143
+ break;
144
+ }
145
+ // ─── Dropped: advisory only ────────────────────────────────────
146
+ case "input_needed": {
147
+ note = {
148
+ index,
149
+ type: "input_needed",
150
+ disposition: "dropped",
151
+ detail: "Advisory event — no structured elicitation content yet",
152
+ };
153
+ break;
154
+ }
155
+ // ─── Response parts ────────────────────────────────────────────
156
+ case "text": {
157
+ const turnId = eventTurnId || context.turnId;
158
+ if (!turnId) {
159
+ note = {
160
+ index,
161
+ type: "text",
162
+ disposition: "dropped",
163
+ detail: "No active turn for text part",
164
+ };
165
+ break;
166
+ }
167
+ const partId = `part-${context.partCounter++}`;
168
+ actions.push({
169
+ type: ActionType.SessionResponsePart,
170
+ turnId,
171
+ part: {
172
+ kind: ResponsePartKind.Markdown,
173
+ id: partId,
174
+ content: content || "",
175
+ },
176
+ });
177
+ note = {
178
+ index,
179
+ type: "text",
180
+ disposition: "mapped",
181
+ detail: `Mapped to SessionResponsePart (partId=${partId})`,
182
+ };
183
+ break;
184
+ }
185
+ // ─── Tool calls ────────────────────────────────────────────────
186
+ case "tool_use": {
187
+ const turnId = eventTurnId || context.turnId;
188
+ if (!turnId) {
189
+ note = {
190
+ index,
191
+ type: "tool_use",
192
+ disposition: "dropped",
193
+ detail: "No active turn for tool_use",
194
+ };
195
+ break;
196
+ }
197
+ const toolCallIdValue = toolCallId || `tc-${context.partCounter++}`;
198
+ const toolName = hasParsed
199
+ ? str(parsed, ["tool_name", "name"], "unknown_tool")
200
+ : "unknown_tool";
201
+ const displayName = hasParsed ? str(parsed, ["display_name"], toolName) : toolName;
202
+ const invocationMessage = hasParsed
203
+ ? str(parsed, ["invocation_message"], `Running ${toolName}`)
204
+ : `Running ${toolName}`;
205
+ // SessionToolCallStart
206
+ actions.push({
207
+ type: ActionType.SessionToolCallStart,
208
+ turnId,
209
+ toolCallId: toolCallIdValue,
210
+ toolName,
211
+ displayName,
212
+ });
213
+ // SessionToolCallReady with auto-confirmation
214
+ actions.push({
215
+ type: ActionType.SessionToolCallReady,
216
+ turnId,
217
+ toolCallId: toolCallIdValue,
218
+ invocationMessage,
219
+ confirmed: ToolCallConfirmationReason.NotNeeded,
220
+ });
221
+ context.openToolCalls.push(toolCallIdValue);
222
+ note = {
223
+ index,
224
+ type: "tool_use",
225
+ disposition: "mapped",
226
+ detail: `Mapped to SessionToolCallStart + SessionToolCallReady (toolCallId=${toolCallIdValue})`,
227
+ };
228
+ break;
229
+ }
230
+ case "tool_result": {
231
+ const turnId = eventTurnId || context.turnId;
232
+ if (!turnId) {
233
+ note = {
234
+ index,
235
+ type: "tool_result",
236
+ disposition: "dropped",
237
+ detail: "No active turn for tool_result",
238
+ };
239
+ break;
240
+ }
241
+ // Pair by first-class toolCallId (HR3), with LIFO stack fallback
242
+ const pairedToolCallId = toolCallId || context.openToolCalls.pop() || "";
243
+ // Remove matched id from stack when first-class toolCallId is provided
244
+ if (toolCallId) {
245
+ const idx = context.openToolCalls.indexOf(toolCallId);
246
+ if (idx !== -1) {
247
+ context.openToolCalls.splice(idx, 1);
248
+ }
249
+ }
250
+ if (!pairedToolCallId) {
251
+ note = {
252
+ index,
253
+ type: "tool_result",
254
+ disposition: "dropped",
255
+ detail: "No matching tool call for result",
256
+ };
257
+ break;
258
+ }
259
+ const isOk = hasParsed
260
+ ? "is_ok" in parsed
261
+ ? parsed.is_ok === true
262
+ : "success" in parsed
263
+ ? parsed.success === true
264
+ : true
265
+ : true;
266
+ const pastTenseMessage = hasParsed
267
+ ? str(parsed, ["past_tense_message"], content || "")
268
+ : content || "";
269
+ const resultText = hasParsed ? str(parsed, ["content"], content || "") : content || "";
270
+ actions.push({
271
+ type: ActionType.SessionToolCallComplete,
272
+ turnId,
273
+ toolCallId: pairedToolCallId,
274
+ result: {
275
+ success: isOk,
276
+ pastTenseMessage,
277
+ content: isOk ? [makeTextResult(resultText)] : undefined,
278
+ error: isOk ? undefined : { message: pastTenseMessage },
279
+ },
280
+ });
281
+ // System notification for successful result
282
+ if (isOk && content) {
283
+ const displayText = resultText.length > 200 ? resultText.slice(0, 200) + "..." : resultText;
284
+ actions.push({
285
+ type: ActionType.SessionResponsePart,
286
+ turnId,
287
+ part: {
288
+ kind: ResponsePartKind.SystemNotification,
289
+ content: displayText,
290
+ },
291
+ });
292
+ }
293
+ note = {
294
+ index,
295
+ type: "tool_result",
296
+ disposition: "mapped",
297
+ detail: `Mapped to SessionToolCallComplete (toolCallId=${pairedToolCallId})`,
298
+ };
299
+ break;
300
+ }
301
+ // ─── Usage (carried via _meta) ─────────────────────────────────
302
+ case "usage": {
303
+ const rawCost = hasParsed ? parsed.cost_millicents : undefined;
304
+ // eslint-disable-next-line eqeqeq -- `!= null` checks both null and undefined in one expression
305
+ if (rawCost != null && Number.isFinite(Number(rawCost))) {
306
+ const prevCost = context.metaAccumulator.costMillicents ?? 0;
307
+ const cost = Number(rawCost);
308
+ context.metaAccumulator.costMillicents = Math.max(0, prevCost + Math.trunc(cost));
309
+ }
310
+ note = {
311
+ index,
312
+ type: "usage",
313
+ disposition: "carried",
314
+ detail: `Usage tracked — costMillicents now ${context.metaAccumulator.costMillicents ?? 0}`,
315
+ };
316
+ break;
317
+ }
318
+ // ─── Errors ────────────────────────────────────────────────────
319
+ case "error": {
320
+ const turnId = eventTurnId || context.turnId;
321
+ const errorDetail = content || "Unknown error";
322
+ if (turnId) {
323
+ actions.push({
324
+ type: ActionType.SessionError,
325
+ turnId,
326
+ error: makeErrorInfo(errorDetail),
327
+ });
328
+ note = {
329
+ index,
330
+ type: "error",
331
+ disposition: "mapped",
332
+ detail: `Mapped to SessionError (turnId=${turnId})`,
333
+ };
334
+ context.turnId = undefined;
335
+ }
336
+ else {
337
+ actions.push({
338
+ type: ActionType.SessionCreationFailed,
339
+ error: makeErrorInfo(errorDetail),
340
+ });
341
+ note = {
342
+ index,
343
+ type: "error",
344
+ disposition: "mapped",
345
+ detail: "Mapped to SessionCreationFailed (no active turn)",
346
+ };
347
+ }
348
+ break;
349
+ }
350
+ // ─── Status events ─────────────────────────────────────────────
351
+ case "status": {
352
+ const statusContent = content || "";
353
+ const turnId = eventTurnId || context.turnId;
354
+ switch (statusContent) {
355
+ case "failed": {
356
+ if (turnId) {
357
+ actions.push({
358
+ type: ActionType.SessionError,
359
+ turnId,
360
+ error: makeErrorInfo("Session failed during turn"),
361
+ });
362
+ context.turnId = undefined;
363
+ note = {
364
+ index,
365
+ type: "status",
366
+ disposition: "mapped",
367
+ detail: `Mapped to SessionError (status=failed, turnId=${turnId})`,
368
+ };
369
+ }
370
+ else {
371
+ actions.push({
372
+ type: ActionType.SessionCreationFailed,
373
+ error: makeErrorInfo("Session creation failed"),
374
+ });
375
+ note = {
376
+ index,
377
+ type: "status",
378
+ disposition: "mapped",
379
+ detail: "Mapped to SessionCreationFailed (status=failed)",
380
+ };
381
+ }
382
+ break;
383
+ }
384
+ case "killed":
385
+ case "terminated": {
386
+ if (turnId) {
387
+ actions.push({
388
+ type: ActionType.SessionError,
389
+ turnId,
390
+ error: makeErrorInfo(`Session ${statusContent} during turn`),
391
+ });
392
+ context.turnId = undefined;
393
+ context.openToolCalls = [];
394
+ note = {
395
+ index,
396
+ type: "status",
397
+ disposition: "mapped",
398
+ detail: `Mapped to SessionError (status=${statusContent})`,
399
+ };
400
+ }
401
+ else {
402
+ note = {
403
+ index,
404
+ type: "status",
405
+ disposition: "dropped",
406
+ detail: `No active turn for status=${statusContent}`,
407
+ };
408
+ }
409
+ break;
410
+ }
411
+ case "completed":
412
+ case "waiting_input":
413
+ case "running": {
414
+ note = {
415
+ index,
416
+ type: "status",
417
+ disposition: "dropped",
418
+ detail: `Dropped — redundant with turn_* events (status=${statusContent})`,
419
+ };
420
+ break;
421
+ }
422
+ default: {
423
+ note = {
424
+ index,
425
+ type: "status",
426
+ disposition: "dropped",
427
+ detail: `Dropped — unrecognized status (${statusContent})`,
428
+ };
429
+ }
430
+ }
431
+ break;
432
+ }
433
+ // ─── System events ─────────────────────────────────────────────
434
+ case "system": {
435
+ const turnId = eventTurnId || context.turnId;
436
+ if (isDiagnosticEvent(event)) {
437
+ note = {
438
+ index,
439
+ type: "system",
440
+ disposition: "carried",
441
+ detail: "Dropped — diagnostic event routes to ahp-otlp telemetry",
442
+ };
443
+ break;
444
+ }
445
+ if (turnId) {
446
+ actions.push({
447
+ type: ActionType.SessionResponsePart,
448
+ turnId,
449
+ part: {
450
+ kind: ResponsePartKind.SystemNotification,
451
+ content: content || "",
452
+ },
453
+ });
454
+ note = {
455
+ index,
456
+ type: "system",
457
+ disposition: "mapped",
458
+ detail: "Mapped to SessionResponsePart(systemNotification)",
459
+ };
460
+ }
461
+ else {
462
+ note = {
463
+ index,
464
+ type: "system",
465
+ disposition: "dropped",
466
+ detail: "No active turn for system event",
467
+ };
468
+ }
469
+ break;
470
+ }
471
+ // ─── Internal control events ───────────────────────────────────
472
+ case "runtime_session_id": {
473
+ if (content) {
474
+ context.metaAccumulator.runtimeSessionId = content;
475
+ note = {
476
+ index,
477
+ type: "runtime_session_id",
478
+ disposition: "carried",
479
+ detail: "Carried as _meta.runtimeSessionId",
480
+ };
481
+ }
482
+ else {
483
+ note = {
484
+ index,
485
+ type: "runtime_session_id",
486
+ disposition: "dropped",
487
+ detail: "No content to carry",
488
+ };
489
+ }
490
+ break;
491
+ }
492
+ // ─── Unknown event types ───────────────────────────────────────
493
+ default: {
494
+ note = {
495
+ index,
496
+ type,
497
+ disposition: "dropped",
498
+ detail: `Unrecognized event type: ${type}`,
499
+ };
500
+ }
501
+ }
502
+ return { actions, note };
503
+ }
504
+ //# sourceMappingURL=ahp-mapper.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ahp-mapper.js","sourceRoot":"","sources":["../src/ahp-mapper.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EACL,UAAU,EACV,0BAA0B,EAC1B,qBAAqB,EACrB,gBAAgB,GAIjB,MAAM,iBAAiB,CAAC;AAiCzB,wFAAwF;AACxF,SAAS,gBAAgB,CAAC,OAAgB;IACxC,IAAI,CAAC,OAAO;QAAE,OAAO,SAAS,CAAC;IAC/B,IAAI,CAAC;QACH,OAAO,IAAI,CAAC,KAAK,CAAC,OAAO,CAA4B,CAAC;IACxD,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,SAAS,CAAC;IACnB,CAAC;AACH,CAAC;AAgED,gDAAgD;AAChD,SAAS,aAAa,CAAC,OAAe;IACpC,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,SAAS,EAAe,CAAC;AACxD,CAAC;AAED,+CAA+C;AAC/C,SAAS,cAAc,CAAC,IAAY;IAClC,OAAO,EAAE,IAAI,EAAE,qBAAqB,CAAC,IAAI,EAAE,IAAI,EAAu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ACtB,MAAM,EAAE,qBAAqB;iBAC9B,CAAC;YACJ,CAAC;YACD,MAAM;QACR,CAAC;QAED,kEAAkE;QAElE,OAAO,CAAC,CAAC,CAAC;YACR,IAAI,GAAG;gBACL,KAAK;gBACL,IAAI;gBACJ,WAAW,EAAE,SAAS;gBACtB,MAAM,EAAE,4BAA4B,IAAI,EAAE;aAC3C,CAAC;QACJ,CAAC;IACH,CAAC;IAED,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;AAC3B,CAAC"}
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Tests for `mapAgentEvent` — AgentEvent → AHP SessionAction mapping.
3
+ *
4
+ * Each test covers one AgentEvent type and verifies:
5
+ * 1. Correct AHP action(s) are produced
6
+ * 2. Mapper context is updated correctly
7
+ * 3. Mapping notes have the right disposition
8
+ */
9
+ export {};
10
+ //# sourceMappingURL=ahp-mapper.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ahp-mapper.test.d.ts","sourceRoot":"","sources":["../src/ahp-mapper.test.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG"}