@zelari/core 2.55.0 → 2.56.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/README.md +1 -1
- package/dist/core/hooks/lifecycleHookRunner.d.ts +30 -1
- package/dist/core/hooks/lifecycleHookRunner.d.ts.map +1 -1
- package/dist/core/hooks/lifecycleHookRunner.js +54 -0
- package/dist/core/hooks/lifecycleHookRunner.js.map +1 -1
- package/dist/core/hooks/types.d.ts +143 -5
- package/dist/core/hooks/types.d.ts.map +1 -1
- package/dist/core/hooks/types.js +63 -5
- package/dist/core/hooks/types.js.map +1 -1
- package/dist/core/tools/registry.d.ts +17 -0
- package/dist/core/tools/registry.d.ts.map +1 -1
- package/dist/core/tools/registry.js +5 -0
- package/dist/core/tools/registry.js.map +1 -1
- package/dist/session/decisionEvents.d.ts +167 -0
- package/dist/session/decisionEvents.d.ts.map +1 -0
- package/dist/session/decisionEvents.js +206 -0
- package/dist/session/decisionEvents.js.map +1 -0
- package/dist/session/index.d.ts +2 -0
- package/dist/session/index.d.ts.map +1 -1
- package/dist/session/index.js +2 -0
- package/dist/session/index.js.map +1 -1
- package/dist/session/replay.d.ts +33 -0
- package/dist/session/replay.d.ts.map +1 -1
- package/dist/session/replay.js +58 -1
- package/dist/session/replay.js.map +1 -1
- package/dist/session/types.d.ts +7 -1
- package/dist/session/types.d.ts.map +1 -1
- package/dist/session/types.js +20 -0
- package/dist/session/types.js.map +1 -1
- package/dist/session/verifyDebt.d.ts +41 -0
- package/dist/session/verifyDebt.d.ts.map +1 -0
- package/dist/session/verifyDebt.js +40 -0
- package/dist/session/verifyDebt.js.map +1 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* session/decisionEvents.ts — WS7 slice 2: the DECISION-POINT vocabulary.
|
|
3
|
+
*
|
|
4
|
+
* A replay of a spine can already answer "what did the agent DO" (tool.call /
|
|
5
|
+
* tool.result, file.*, verification.run, verify.debt_*). What it could not
|
|
6
|
+
* answer — the whole point of `zelari-code replay` — is "what did the HARNESS
|
|
7
|
+
* decide on the way": whether the operator was asked, whether an approval was
|
|
8
|
+
* auto-granted, whether the OS jail blocked the spawn, whether the model
|
|
9
|
+
* stopped to ask the user, whether a verify was requested at all.
|
|
10
|
+
*
|
|
11
|
+
* Those five kinds are declared in `types.ts` (SESSION_EVENT_KINDS) and their
|
|
12
|
+
* payload contracts live HERE, in one place, mirrored from the emitters that
|
|
13
|
+
* already exist so a future writer does not invent a second spelling:
|
|
14
|
+
*
|
|
15
|
+
* permission.asked ← PermissionRequestPayload (safety/permissionGate.ts,
|
|
16
|
+
* WS5): {tool, categories?, effect?, matchedRuleId?,
|
|
17
|
+
* source?, reason?, argsSummary?}
|
|
18
|
+
* auto_approve.granted← the same decision block, effect resolved to allow
|
|
19
|
+
* (category default / allow rule / `--permissions yolo`)
|
|
20
|
+
* jail.blocked ← JailSpawnDecision deny branch (safety/osJail.ts):
|
|
21
|
+
* {backend, mode, reason, tool?}
|
|
22
|
+
* ask_user.fired ← the ask_user tool args (question/choices/context)
|
|
23
|
+
* verify.requested ← the K1.5/F5 obligation side: a verify was ASKED for
|
|
24
|
+
* (`verification.run` records that it actually ran)
|
|
25
|
+
*
|
|
26
|
+
* ALL FIVE ARE STATE-ONLY (P1): they record a decision, they never feed the
|
|
27
|
+
* model loop, so `deriveMessages()` ignores them and MODEL_SURFACE_KINDS must
|
|
28
|
+
* never gain them (pinned by decisionEvents.test.ts).
|
|
29
|
+
*
|
|
30
|
+
* Replay discipline (same as `parsePermissionDenial`): every reader here is
|
|
31
|
+
* DEFENSIVE. A hand-edited or half-written line must yield empty strings, never
|
|
32
|
+
* a throw — the tolerant reader owns "this line is broken" reporting.
|
|
33
|
+
*/
|
|
34
|
+
import { z } from 'zod';
|
|
35
|
+
import type { SessionEventEnvelope } from './types.js';
|
|
36
|
+
/**
|
|
37
|
+
* The five kinds this slice ADDED to the spine vocabulary (see SESSION_EVENT_KINDS).
|
|
38
|
+
* Order is the reading order of a session, not the declaration order in types.ts.
|
|
39
|
+
*/
|
|
40
|
+
export declare const DECISION_EVENT_KINDS: readonly ["permission.asked", "auto_approve.granted", "jail.blocked", "ask_user.fired", "verify.requested"];
|
|
41
|
+
export type DecisionEventKind = (typeof DECISION_EVENT_KINDS)[number];
|
|
42
|
+
/**
|
|
43
|
+
* What the `decisionEvents` projection aggregates: the five kinds above PLUS
|
|
44
|
+
* the WS1 `permission.denied` — same question ("what did the harness decide
|
|
45
|
+
* about this call?"), so a shadow replay must not have to merge two lists.
|
|
46
|
+
* `permission.denied` keeps its own dedicated `permissionDenials` field too;
|
|
47
|
+
* that field is untouched by this slice.
|
|
48
|
+
*/
|
|
49
|
+
export declare const DECISION_PROJECTION_KINDS: readonly ["permission.asked", "auto_approve.granted", "jail.blocked", "ask_user.fired", "verify.requested", "permission.denied"];
|
|
50
|
+
export type DecisionProjectionKind = (typeof DECISION_PROJECTION_KINDS)[number];
|
|
51
|
+
/** True for every kind the `decisionEvents` projection collects. */
|
|
52
|
+
export declare function isDecisionProjectionKind(kind: string): kind is DecisionProjectionKind;
|
|
53
|
+
/** `permission.asked` — the gate resolved a dispatch to a PROMPT. */
|
|
54
|
+
export declare const PermissionAskedPayloadSchema: z.ZodObject<{
|
|
55
|
+
tool: z.ZodString;
|
|
56
|
+
categories: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
57
|
+
effect: z.ZodOptional<z.ZodLiteral<"ask">>;
|
|
58
|
+
matchedRuleId: z.ZodOptional<z.ZodString>;
|
|
59
|
+
source: z.ZodOptional<z.ZodString>;
|
|
60
|
+
reason: z.ZodOptional<z.ZodString>;
|
|
61
|
+
argsSummary: z.ZodOptional<z.ZodString>;
|
|
62
|
+
}, z.core.$strip>;
|
|
63
|
+
/** `auto_approve.granted` — the same decision, resolved to ALLOW without a prompt. */
|
|
64
|
+
export declare const AutoApproveGrantedPayloadSchema: z.ZodObject<{
|
|
65
|
+
tool: z.ZodString;
|
|
66
|
+
categories: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
67
|
+
source: z.ZodOptional<z.ZodString>;
|
|
68
|
+
matchedRuleId: z.ZodOptional<z.ZodString>;
|
|
69
|
+
reason: z.ZodOptional<z.ZodString>;
|
|
70
|
+
}, z.core.$strip>;
|
|
71
|
+
/** `jail.blocked` — the OS jail refused the spawn (typed `[jail]` error). */
|
|
72
|
+
export declare const JailBlockedPayloadSchema: z.ZodObject<{
|
|
73
|
+
tool: z.ZodOptional<z.ZodString>;
|
|
74
|
+
backend: z.ZodString;
|
|
75
|
+
mode: z.ZodEnum<{
|
|
76
|
+
required: "required";
|
|
77
|
+
off: "off";
|
|
78
|
+
advisory: "advisory";
|
|
79
|
+
}>;
|
|
80
|
+
reason: z.ZodString;
|
|
81
|
+
}, z.core.$strip>;
|
|
82
|
+
/** `ask_user.fired` — the model stopped the loop to ask the operator. */
|
|
83
|
+
export declare const AskUserFiredPayloadSchema: z.ZodObject<{
|
|
84
|
+
question: z.ZodString;
|
|
85
|
+
callId: z.ZodOptional<z.ZodString>;
|
|
86
|
+
choices: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
87
|
+
context: z.ZodOptional<z.ZodString>;
|
|
88
|
+
}, z.core.$strip>;
|
|
89
|
+
/** `verify.requested` — a verify was ASKED for (it may never run). */
|
|
90
|
+
export declare const VerifyRequestedPayloadSchema: z.ZodObject<{
|
|
91
|
+
taskId: z.ZodOptional<z.ZodString>;
|
|
92
|
+
criterionIds: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
93
|
+
source: z.ZodOptional<z.ZodString>;
|
|
94
|
+
reason: z.ZodOptional<z.ZodString>;
|
|
95
|
+
}, z.core.$strip>;
|
|
96
|
+
/** One schema per DECISION_EVENT_KIND — the payload contract table. */
|
|
97
|
+
export declare const DECISION_EVENT_PAYLOAD_SCHEMAS: {
|
|
98
|
+
readonly 'permission.asked': z.ZodObject<{
|
|
99
|
+
tool: z.ZodString;
|
|
100
|
+
categories: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
101
|
+
effect: z.ZodOptional<z.ZodLiteral<"ask">>;
|
|
102
|
+
matchedRuleId: z.ZodOptional<z.ZodString>;
|
|
103
|
+
source: z.ZodOptional<z.ZodString>;
|
|
104
|
+
reason: z.ZodOptional<z.ZodString>;
|
|
105
|
+
argsSummary: z.ZodOptional<z.ZodString>;
|
|
106
|
+
}, z.core.$strip>;
|
|
107
|
+
readonly 'auto_approve.granted': z.ZodObject<{
|
|
108
|
+
tool: z.ZodString;
|
|
109
|
+
categories: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
110
|
+
source: z.ZodOptional<z.ZodString>;
|
|
111
|
+
matchedRuleId: z.ZodOptional<z.ZodString>;
|
|
112
|
+
reason: z.ZodOptional<z.ZodString>;
|
|
113
|
+
}, z.core.$strip>;
|
|
114
|
+
readonly 'jail.blocked': z.ZodObject<{
|
|
115
|
+
tool: z.ZodOptional<z.ZodString>;
|
|
116
|
+
backend: z.ZodString;
|
|
117
|
+
mode: z.ZodEnum<{
|
|
118
|
+
required: "required";
|
|
119
|
+
off: "off";
|
|
120
|
+
advisory: "advisory";
|
|
121
|
+
}>;
|
|
122
|
+
reason: z.ZodString;
|
|
123
|
+
}, z.core.$strip>;
|
|
124
|
+
readonly 'ask_user.fired': z.ZodObject<{
|
|
125
|
+
question: z.ZodString;
|
|
126
|
+
callId: z.ZodOptional<z.ZodString>;
|
|
127
|
+
choices: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
128
|
+
context: z.ZodOptional<z.ZodString>;
|
|
129
|
+
}, z.core.$strip>;
|
|
130
|
+
readonly 'verify.requested': z.ZodObject<{
|
|
131
|
+
taskId: z.ZodOptional<z.ZodString>;
|
|
132
|
+
criterionIds: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
133
|
+
source: z.ZodOptional<z.ZodString>;
|
|
134
|
+
reason: z.ZodOptional<z.ZodString>;
|
|
135
|
+
}, z.core.$strip>;
|
|
136
|
+
};
|
|
137
|
+
/**
|
|
138
|
+
* Validate a payload against its kind's contract. Returns `null` when the
|
|
139
|
+
* payload satisfies it, else a one-line reason (the FIRST zod issue, prefixed
|
|
140
|
+
* with the field path) ready for stderr. Never throws.
|
|
141
|
+
*/
|
|
142
|
+
export declare function decisionPayloadError(kind: DecisionEventKind, data: unknown): string | null;
|
|
143
|
+
/**
|
|
144
|
+
* One decision point, flattened for replay rendering. `seq`/`at` come from the
|
|
145
|
+
* ENVELOPE (never from a `timestamp` field inside the payload): an event's ts
|
|
146
|
+
* is writer-assigned, and replay must read the same clock the rest of the
|
|
147
|
+
* projection reads.
|
|
148
|
+
*/
|
|
149
|
+
export interface DecisionEventSummary {
|
|
150
|
+
seq: number;
|
|
151
|
+
at: number;
|
|
152
|
+
kind: DecisionProjectionKind;
|
|
153
|
+
/** Tool the decision was about (`''` when the kind carries none). */
|
|
154
|
+
tool: string;
|
|
155
|
+
/** Rule/layer that drove it (`''` when none did). */
|
|
156
|
+
source: string;
|
|
157
|
+
/** Human reason, verbatim from the payload (`''` when absent). */
|
|
158
|
+
reason: string;
|
|
159
|
+
/** Bounded, kind-specific one-liner (question, backend+mode, criteria…). */
|
|
160
|
+
detail: string;
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* Flatten one decision event. Pure and defensive: a payload missing every
|
|
164
|
+
* field still yields a summary with empty strings (the KIND is the datum).
|
|
165
|
+
*/
|
|
166
|
+
export declare function parseDecisionEvent(e: SessionEventEnvelope): DecisionEventSummary;
|
|
167
|
+
//# sourceMappingURL=decisionEvents.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"decisionEvents.d.ts","sourceRoot":"","sources":["../../src/session/decisionEvents.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;A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AA4E;IAC5E,MAAM,EAAE,MAAM,CAAC;CAChB;AA4DD;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,CAAC,EAAE,oBAAoB,GAAG,oBAAoB,CAWhF"}
|
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* session/decisionEvents.ts — WS7 slice 2: the DECISION-POINT vocabulary.
|
|
3
|
+
*
|
|
4
|
+
* A replay of a spine can already answer "what did the agent DO" (tool.call /
|
|
5
|
+
* tool.result, file.*, verification.run, verify.debt_*). What it could not
|
|
6
|
+
* answer — the whole point of `zelari-code replay` — is "what did the HARNESS
|
|
7
|
+
* decide on the way": whether the operator was asked, whether an approval was
|
|
8
|
+
* auto-granted, whether the OS jail blocked the spawn, whether the model
|
|
9
|
+
* stopped to ask the user, whether a verify was requested at all.
|
|
10
|
+
*
|
|
11
|
+
* Those five kinds are declared in `types.ts` (SESSION_EVENT_KINDS) and their
|
|
12
|
+
* payload contracts live HERE, in one place, mirrored from the emitters that
|
|
13
|
+
* already exist so a future writer does not invent a second spelling:
|
|
14
|
+
*
|
|
15
|
+
* permission.asked ← PermissionRequestPayload (safety/permissionGate.ts,
|
|
16
|
+
* WS5): {tool, categories?, effect?, matchedRuleId?,
|
|
17
|
+
* source?, reason?, argsSummary?}
|
|
18
|
+
* auto_approve.granted← the same decision block, effect resolved to allow
|
|
19
|
+
* (category default / allow rule / `--permissions yolo`)
|
|
20
|
+
* jail.blocked ← JailSpawnDecision deny branch (safety/osJail.ts):
|
|
21
|
+
* {backend, mode, reason, tool?}
|
|
22
|
+
* ask_user.fired ← the ask_user tool args (question/choices/context)
|
|
23
|
+
* verify.requested ← the K1.5/F5 obligation side: a verify was ASKED for
|
|
24
|
+
* (`verification.run` records that it actually ran)
|
|
25
|
+
*
|
|
26
|
+
* ALL FIVE ARE STATE-ONLY (P1): they record a decision, they never feed the
|
|
27
|
+
* model loop, so `deriveMessages()` ignores them and MODEL_SURFACE_KINDS must
|
|
28
|
+
* never gain them (pinned by decisionEvents.test.ts).
|
|
29
|
+
*
|
|
30
|
+
* Replay discipline (same as `parsePermissionDenial`): every reader here is
|
|
31
|
+
* DEFENSIVE. A hand-edited or half-written line must yield empty strings, never
|
|
32
|
+
* a throw — the tolerant reader owns "this line is broken" reporting.
|
|
33
|
+
*/
|
|
34
|
+
import { z } from 'zod';
|
|
35
|
+
/**
|
|
36
|
+
* The five kinds this slice ADDED to the spine vocabulary (see SESSION_EVENT_KINDS).
|
|
37
|
+
* Order is the reading order of a session, not the declaration order in types.ts.
|
|
38
|
+
*/
|
|
39
|
+
export const DECISION_EVENT_KINDS = [
|
|
40
|
+
'permission.asked',
|
|
41
|
+
'auto_approve.granted',
|
|
42
|
+
'jail.blocked',
|
|
43
|
+
'ask_user.fired',
|
|
44
|
+
'verify.requested',
|
|
45
|
+
];
|
|
46
|
+
/**
|
|
47
|
+
* What the `decisionEvents` projection aggregates: the five kinds above PLUS
|
|
48
|
+
* the WS1 `permission.denied` — same question ("what did the harness decide
|
|
49
|
+
* about this call?"), so a shadow replay must not have to merge two lists.
|
|
50
|
+
* `permission.denied` keeps its own dedicated `permissionDenials` field too;
|
|
51
|
+
* that field is untouched by this slice.
|
|
52
|
+
*/
|
|
53
|
+
export const DECISION_PROJECTION_KINDS = [...DECISION_EVENT_KINDS, 'permission.denied'];
|
|
54
|
+
/** True for every kind the `decisionEvents` projection collects. */
|
|
55
|
+
export function isDecisionProjectionKind(kind) {
|
|
56
|
+
return DECISION_PROJECTION_KINDS.includes(kind);
|
|
57
|
+
}
|
|
58
|
+
// ── Payload contracts (zod) ────────────────────────────────────────────────
|
|
59
|
+
//
|
|
60
|
+
// NOT `.strict()`: the envelope's `data` is an open record and emitters grow
|
|
61
|
+
// fields (an `argsSummary`, a `durationMs`, a future `callId`). These schemas
|
|
62
|
+
// exist to pin what a payload MUST carry (and to be the single place a writer
|
|
63
|
+
// looks up the spelling) — not to reject forward-compatible additions.
|
|
64
|
+
// Unknown/missing REQUIRED fields are reported by `decisionPayloadError`.
|
|
65
|
+
const nonEmpty = z.string().min(1);
|
|
66
|
+
const toolName = z.object({ tool: nonEmpty });
|
|
67
|
+
/** `permission.asked` — the gate resolved a dispatch to a PROMPT. */
|
|
68
|
+
export const PermissionAskedPayloadSchema = toolName.extend({
|
|
69
|
+
/** Declared permission categories of the call (`read`, `write`, …). */
|
|
70
|
+
categories: z.array(z.string()).optional(),
|
|
71
|
+
/** Always `ask` when present — a deny is `permission.denied` (WS1). */
|
|
72
|
+
effect: z.literal('ask').optional(),
|
|
73
|
+
matchedRuleId: nonEmpty.optional(),
|
|
74
|
+
source: nonEmpty.optional(),
|
|
75
|
+
reason: z.string().optional(),
|
|
76
|
+
argsSummary: z.string().optional(),
|
|
77
|
+
});
|
|
78
|
+
/** `auto_approve.granted` — the same decision, resolved to ALLOW without a prompt. */
|
|
79
|
+
export const AutoApproveGrantedPayloadSchema = toolName.extend({
|
|
80
|
+
categories: z.array(z.string()).optional(),
|
|
81
|
+
/** Where the approval came from (`default` / `project` / `session` / `preset`). */
|
|
82
|
+
source: nonEmpty.optional(),
|
|
83
|
+
matchedRuleId: nonEmpty.optional(),
|
|
84
|
+
reason: z.string().optional(),
|
|
85
|
+
});
|
|
86
|
+
/** `jail.blocked` — the OS jail refused the spawn (typed `[jail]` error). */
|
|
87
|
+
export const JailBlockedPayloadSchema = z.object({
|
|
88
|
+
/** Exec tool whose spawn was refused, when one call owned the spawn. */
|
|
89
|
+
tool: nonEmpty.optional(),
|
|
90
|
+
/** Backend id that failed it (`seatbelt` / `bwrap` / `win32-restricted-token`). */
|
|
91
|
+
backend: nonEmpty,
|
|
92
|
+
/** Wire mirror of `safety/osJail.ts` JailMode (core cannot import the CLI). */
|
|
93
|
+
mode: z.enum(['off', 'advisory', 'required']),
|
|
94
|
+
reason: nonEmpty,
|
|
95
|
+
});
|
|
96
|
+
/** `ask_user.fired` — the model stopped the loop to ask the operator. */
|
|
97
|
+
export const AskUserFiredPayloadSchema = z.object({
|
|
98
|
+
question: nonEmpty,
|
|
99
|
+
/** `tool.call` id this question belongs to, when the emitter knows it. */
|
|
100
|
+
callId: nonEmpty.optional(),
|
|
101
|
+
choices: z.array(z.string()).optional(),
|
|
102
|
+
context: z.string().optional(),
|
|
103
|
+
});
|
|
104
|
+
/** `verify.requested` — a verify was ASKED for (it may never run). */
|
|
105
|
+
export const VerifyRequestedPayloadSchema = z.object({
|
|
106
|
+
/** K1.5/F5 debt slot the request belongs to, when one exists. */
|
|
107
|
+
taskId: nonEmpty.optional(),
|
|
108
|
+
/** Criterion ids the request targets (`verification.run` reports outcomes). */
|
|
109
|
+
criterionIds: z.array(z.string()).optional(),
|
|
110
|
+
source: nonEmpty.optional(),
|
|
111
|
+
reason: z.string().optional(),
|
|
112
|
+
});
|
|
113
|
+
/** One schema per DECISION_EVENT_KIND — the payload contract table. */
|
|
114
|
+
export const DECISION_EVENT_PAYLOAD_SCHEMAS = {
|
|
115
|
+
'permission.asked': PermissionAskedPayloadSchema,
|
|
116
|
+
'auto_approve.granted': AutoApproveGrantedPayloadSchema,
|
|
117
|
+
'jail.blocked': JailBlockedPayloadSchema,
|
|
118
|
+
'ask_user.fired': AskUserFiredPayloadSchema,
|
|
119
|
+
'verify.requested': VerifyRequestedPayloadSchema,
|
|
120
|
+
};
|
|
121
|
+
/**
|
|
122
|
+
* Validate a payload against its kind's contract. Returns `null` when the
|
|
123
|
+
* payload satisfies it, else a one-line reason (the FIRST zod issue, prefixed
|
|
124
|
+
* with the field path) ready for stderr. Never throws.
|
|
125
|
+
*/
|
|
126
|
+
export function decisionPayloadError(kind, data) {
|
|
127
|
+
const schema = DECISION_EVENT_PAYLOAD_SCHEMAS[kind];
|
|
128
|
+
const result = schema.safeParse(data);
|
|
129
|
+
if (result.success)
|
|
130
|
+
return null;
|
|
131
|
+
const issue = result.error.issues[0];
|
|
132
|
+
const where = issue?.path.length ? `${issue.path.join('.')}: ` : '';
|
|
133
|
+
return `${where}${issue?.message ?? 'payload does not match the contract'}`;
|
|
134
|
+
}
|
|
135
|
+
/** Primitive-only string read: exotic values degrade to `''`, never `[object Object]`. */
|
|
136
|
+
function str(value) {
|
|
137
|
+
if (typeof value === 'string')
|
|
138
|
+
return value;
|
|
139
|
+
if (typeof value === 'number' || typeof value === 'boolean')
|
|
140
|
+
return String(value);
|
|
141
|
+
return '';
|
|
142
|
+
}
|
|
143
|
+
/** `str` + collapse + bound, so a multi-line question cannot break the report. */
|
|
144
|
+
function oneLine(value, max = 120) {
|
|
145
|
+
const text = str(value).replace(/\s+/g, ' ').trim();
|
|
146
|
+
return text.length > max ? `${text.slice(0, Math.max(0, max - 1))}…` : text;
|
|
147
|
+
}
|
|
148
|
+
/** `a, b, c` for a bounded list, `''` when there is nothing to join. */
|
|
149
|
+
function joinList(value, max = 6) {
|
|
150
|
+
if (!Array.isArray(value))
|
|
151
|
+
return '';
|
|
152
|
+
return value
|
|
153
|
+
.map((v) => oneLine(v, 40))
|
|
154
|
+
.filter((v) => v.length > 0)
|
|
155
|
+
.slice(0, max)
|
|
156
|
+
.join(', ');
|
|
157
|
+
}
|
|
158
|
+
/** `ruleId @source` / `ruleId` / `source` — whatever the payload carried. */
|
|
159
|
+
function describeOrigin(data) {
|
|
160
|
+
const rule = oneLine(data.matchedRuleId, 60);
|
|
161
|
+
const source = oneLine(data.source, 60);
|
|
162
|
+
if (rule && source)
|
|
163
|
+
return `${rule} @${source}`;
|
|
164
|
+
return rule || source;
|
|
165
|
+
}
|
|
166
|
+
function describeDetail(kind, data) {
|
|
167
|
+
switch (kind) {
|
|
168
|
+
case 'permission.asked':
|
|
169
|
+
return (oneLine(data.reason) ||
|
|
170
|
+
oneLine(data.argsSummary) ||
|
|
171
|
+
(describeOrigin(data) ? `rule ${describeOrigin(data)}` : 'prompt awaited'));
|
|
172
|
+
case 'auto_approve.granted': {
|
|
173
|
+
const origin = describeOrigin(data);
|
|
174
|
+
return origin ? `auto-approved (${origin})` : 'auto-approved';
|
|
175
|
+
}
|
|
176
|
+
case 'jail.blocked':
|
|
177
|
+
return `${oneLine(data.backend, 40) || 'jail'} ${oneLine(data.mode, 20) || '?'}: ${oneLine(data.reason)}`;
|
|
178
|
+
case 'ask_user.fired': {
|
|
179
|
+
const choices = joinList(data.choices);
|
|
180
|
+
return oneLine(data.question) + (choices ? ` [choices: ${choices}]` : '');
|
|
181
|
+
}
|
|
182
|
+
case 'verify.requested': {
|
|
183
|
+
const criteria = joinList(data.criterionIds, 4);
|
|
184
|
+
return oneLine(data.reason) || (criteria ? `criteria: ${criteria}` : '');
|
|
185
|
+
}
|
|
186
|
+
case 'permission.denied':
|
|
187
|
+
return oneLine(data.reason) || `denied by ${describeOrigin(data) || 'a permission rule'}`;
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
/**
|
|
191
|
+
* Flatten one decision event. Pure and defensive: a payload missing every
|
|
192
|
+
* field still yields a summary with empty strings (the KIND is the datum).
|
|
193
|
+
*/
|
|
194
|
+
export function parseDecisionEvent(e) {
|
|
195
|
+
const data = e.data;
|
|
196
|
+
return {
|
|
197
|
+
seq: e.seq,
|
|
198
|
+
at: e.ts,
|
|
199
|
+
kind: e.kind,
|
|
200
|
+
tool: oneLine(data.tool, 60),
|
|
201
|
+
source: oneLine(data.source, 60),
|
|
202
|
+
reason: oneLine(data.reason),
|
|
203
|
+
detail: describeDetail(e.kind, data),
|
|
204
|
+
};
|
|
205
|
+
}
|
|
206
|
+
//# sourceMappingURL=decisionEvents.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"decisionEvents.js","sourceRoot":"","sources":["../../src/session/decisionEvents.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB;;;GAGG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG;IAClC,kBAAkB;IAClB,sBAAsB;IACtB,cAAc;IACd,gBAAgB;IAChB,kBAAkB;CACV,CAAC;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C,CAAC,GAAG;QACV,EAAE,EAAE,CAAC,CAAC,EAAE;QACR,IAAI,EAAE,CAAC,CAAC,IAA8B;QACtC,IAAI,EAAE,OAAO,CAAC,IAAI,CAAC,IAAI,EAAE,EAAE,CAAC;QAC5B,MAAM,EAAE,OAAO,CAAC,IAAI,CAAC,MAAM,EAAE,EAAE,CAAC;QAChC,MAAM,EAAE,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC;QAC5B,MAAM,EAAE,cAAc,CAAC,CAAC,CAAC,IAA8B,EAAE,IAAI,CAAC;KAC/D,CAAC;AACJ,CAAC"}
|
package/dist/session/index.d.ts
CHANGED
|
@@ -12,6 +12,8 @@ export * from './agentAdapter.js';
|
|
|
12
12
|
export * from './writer.js';
|
|
13
13
|
export * from './replay.js';
|
|
14
14
|
export * from './replayCache.js';
|
|
15
|
+
export * from './decisionEvents.js';
|
|
16
|
+
export * from './verifyDebt.js';
|
|
15
17
|
export * from './store.js';
|
|
16
18
|
export * from './lineage.js';
|
|
17
19
|
export * from './exportSession.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/session/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,cAAc,YAAY,CAAC;AAC3B,cAAc,mBAAmB,CAAC;AAClC,cAAc,iBAAiB,CAAC;AAChC,cAAc,mBAAmB,CAAC;AAClC,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,kBAAkB,CAAC;AACjC,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC;AAC7B,cAAc,oBAAoB,CAAC;AACnC,cAAc,iBAAiB,CAAC;AAChC,cAAc,eAAe,CAAC;AAC9B,cAAc,mBAAmB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/session/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,cAAc,YAAY,CAAC;AAC3B,cAAc,mBAAmB,CAAC;AAClC,cAAc,iBAAiB,CAAC;AAChC,cAAc,mBAAmB,CAAC;AAClC,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,kBAAkB,CAAC;AACjC,cAAc,qBAAqB,CAAC;AACpC,cAAc,iBAAiB,CAAC;AAChC,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC;AAC7B,cAAc,oBAAoB,CAAC;AACnC,cAAc,iBAAiB,CAAC;AAChC,cAAc,eAAe,CAAC;AAC9B,cAAc,mBAAmB,CAAC"}
|
package/dist/session/index.js
CHANGED
|
@@ -12,6 +12,8 @@ export * from './agentAdapter.js';
|
|
|
12
12
|
export * from './writer.js';
|
|
13
13
|
export * from './replay.js';
|
|
14
14
|
export * from './replayCache.js';
|
|
15
|
+
export * from './decisionEvents.js';
|
|
16
|
+
export * from './verifyDebt.js';
|
|
15
17
|
export * from './store.js';
|
|
16
18
|
export * from './lineage.js';
|
|
17
19
|
export * from './exportSession.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/session/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,cAAc,YAAY,CAAC;AAC3B,cAAc,mBAAmB,CAAC;AAClC,cAAc,iBAAiB,CAAC;AAChC,cAAc,mBAAmB,CAAC;AAClC,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,kBAAkB,CAAC;AACjC,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC;AAC7B,cAAc,oBAAoB,CAAC;AACnC,cAAc,iBAAiB,CAAC;AAChC,cAAc,eAAe,CAAC;AAC9B,cAAc,mBAAmB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/session/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,cAAc,YAAY,CAAC;AAC3B,cAAc,mBAAmB,CAAC;AAClC,cAAc,iBAAiB,CAAC;AAChC,cAAc,mBAAmB,CAAC;AAClC,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,kBAAkB,CAAC;AACjC,cAAc,qBAAqB,CAAC;AACpC,cAAc,iBAAiB,CAAC;AAChC,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC;AAC7B,cAAc,oBAAoB,CAAC;AACnC,cAAc,iBAAiB,CAAC;AAChC,cAAc,eAAe,CAAC;AAC9B,cAAc,mBAAmB,CAAC"}
|
package/dist/session/replay.d.ts
CHANGED
|
@@ -8,6 +8,8 @@
|
|
|
8
8
|
import { type SessionEventEnvelope } from './types.js';
|
|
9
9
|
import { type DerivedMessage } from './modelSurface.js';
|
|
10
10
|
import { type ToolInterrupted } from './recovery.js';
|
|
11
|
+
import { type DecisionEventSummary } from './decisionEvents.js';
|
|
12
|
+
import { type VerifyDebtSummary } from './verifyDebt.js';
|
|
11
13
|
export type ReplayIssueType = 'corrupt-line' | 'schema-mismatch' | 'seq-duplicate' | 'seq-gap' | 'seq-nonmonotonic';
|
|
12
14
|
export interface ReplayIssue {
|
|
13
15
|
type: ReplayIssueType;
|
|
@@ -82,6 +84,37 @@ export interface SessionProjection {
|
|
|
82
84
|
issues: ReplayIssue[];
|
|
83
85
|
/** Dangling tool.call events classified for crash recovery (2.x B). */
|
|
84
86
|
interruptedTools: ToolInterrupted[];
|
|
87
|
+
/** WS1 (t133): pre-dispatch permission denials, in log order. */
|
|
88
|
+
permissionDenials: PermissionDenialSummary[];
|
|
89
|
+
/**
|
|
90
|
+
* WS7 slice 2 (t140): every decision point on this spine, in log order —
|
|
91
|
+
* the five new decision kinds plus `permission.denied` (see
|
|
92
|
+
* decisionEvents.ts for why the two lists are one aggregate).
|
|
93
|
+
*/
|
|
94
|
+
decisionEvents: DecisionEventSummary[];
|
|
95
|
+
/** K1.5/F5 (t78): verify-debt slots, open + cleared, in first-open order. */
|
|
96
|
+
verifyDebts: VerifyDebtSummary[];
|
|
97
|
+
/** Per-tool tally over `tool.call` / `tool.result` (row order = first call). */
|
|
98
|
+
toolCallBreakdown: ToolCallTally[];
|
|
99
|
+
}
|
|
100
|
+
/** One tool's call/result counters, as replay shows them. */
|
|
101
|
+
export interface ToolCallTally {
|
|
102
|
+
tool: string;
|
|
103
|
+
calls: number;
|
|
104
|
+
results: number;
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* WS1 (t133): a `permission.denied` event, replayed. Defensive reads: an
|
|
108
|
+
* older writer (or a hand-edited log) with a missing field yields '' rather
|
|
109
|
+
* than throwing — replay must never die on telemetry.
|
|
110
|
+
*/
|
|
111
|
+
export interface PermissionDenialSummary {
|
|
112
|
+
seq: number;
|
|
113
|
+
at: number;
|
|
114
|
+
tool: string;
|
|
115
|
+
matchedRuleId: string;
|
|
116
|
+
source: string;
|
|
117
|
+
reason: string;
|
|
85
118
|
}
|
|
86
119
|
/** Build the materialized view of a session from its (valid) events. */
|
|
87
120
|
export declare function buildProjection(events: readonly SessionEventEnvelope[], issues?: ReplayIssue[]): SessionProjection;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"replay.d.ts","sourceRoot":"","sources":["../../src/session/replay.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,EAEL,KAAK,oBAAoB,EAC1B,MAAM,YAAY,CAAC;AACpB,OAAO,
|
|
1
|
+
{"version":3,"file":"replay.d.ts","sourceRoot":"","sources":["../../src/session/replay.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,EAEL,KAAK,oBAAoB,EAC1B,MAAM,YAAY,CAAC;AACpB,OAAO,EAAiC,KAAK,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACvF,OAAO,EAA4B,KAAK,eAAe,EAAE,MAAM,eAAe,CAAC;AAC/E,OAAO,EAAsB,KAAK,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AACpF,OAAO,EAAsB,KAAK,iBAAiB,EAAE,MAAM,iBAAiB,C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AM,WAAW,uBAAuB;IACtC,GAAG,EAAE,MAAM,CAAC;IACZ,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,aAAa,EAAE,MAAM,CAAC;IACtB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;CAChB;AA8BD,wEAAwE;AACxE,wBAAgB,eAAe,CAAC,MAAM,EAAE,SAAS,oBAAoB,EAAE,EAAE,MAAM,GAAE,WAAW,EAAO,GAAG,iBAAiB,CA+EtH"}
|
package/dist/session/replay.js
CHANGED
|
@@ -7,8 +7,10 @@
|
|
|
7
7
|
*/
|
|
8
8
|
import { promises as fs } from 'node:fs';
|
|
9
9
|
import { SessionEventEnvelopeSchema, } from './types.js';
|
|
10
|
-
import { deriveMessages } from './modelSurface.js';
|
|
10
|
+
import { deriveMessages, pairToolCalls } from './modelSurface.js';
|
|
11
11
|
import { classifyInterruptedTools } from './recovery.js';
|
|
12
|
+
import { parseDecisionEvent } from './decisionEvents.js';
|
|
13
|
+
import { projectVerifyDebts } from './verifyDebt.js';
|
|
12
14
|
export async function readSessionLog(filePath) {
|
|
13
15
|
let content;
|
|
14
16
|
try {
|
|
@@ -82,6 +84,42 @@ export function parseSessionLogLines(lines, opts = {}) {
|
|
|
82
84
|
}
|
|
83
85
|
return { events, issues, expected, linesConsumed: base + lines.length };
|
|
84
86
|
}
|
|
87
|
+
/**
|
|
88
|
+
* Per-tool tally. A `tool.result` on a REAL spine carries only
|
|
89
|
+
* `{callId, output, ok, durationMs}` — NOT the tool name (verified on a live
|
|
90
|
+
* 938-event session log) — so results are attributed through `pairToolCalls`
|
|
91
|
+
* (the same callId rule the model surface and recovery use). A result whose
|
|
92
|
+
* call is not on this spine (a resumed log can start mid-turn) cannot be
|
|
93
|
+
* attributed and is not counted here; the aggregate `toolCalls`/`toolResults`
|
|
94
|
+
* counters still count it. Rows are ordered by calls desc, then name.
|
|
95
|
+
*/
|
|
96
|
+
function tallyToolCalls(events) {
|
|
97
|
+
const byTool = new Map();
|
|
98
|
+
const slot = (tool) => {
|
|
99
|
+
const found = byTool.get(tool) ?? { tool, calls: 0, results: 0 };
|
|
100
|
+
byTool.set(tool, found);
|
|
101
|
+
return found;
|
|
102
|
+
};
|
|
103
|
+
for (const pair of pairToolCalls(events)) {
|
|
104
|
+
const tool = typeof pair.call.data.tool === 'string' ? pair.call.data.tool : '';
|
|
105
|
+
if (tool.length === 0)
|
|
106
|
+
continue;
|
|
107
|
+
slot(tool).calls += 1;
|
|
108
|
+
if (pair.result !== undefined)
|
|
109
|
+
slot(tool).results += 1;
|
|
110
|
+
}
|
|
111
|
+
return [...byTool.values()].sort((a, b) => b.calls - a.calls || a.tool.localeCompare(b.tool));
|
|
112
|
+
}
|
|
113
|
+
function parsePermissionDenial(e) {
|
|
114
|
+
return {
|
|
115
|
+
seq: e.seq,
|
|
116
|
+
at: e.ts,
|
|
117
|
+
tool: String(e.data.tool ?? ''),
|
|
118
|
+
matchedRuleId: String(e.data.matchedRuleId ?? ''),
|
|
119
|
+
source: String(e.data.source ?? ''),
|
|
120
|
+
reason: String(e.data.reason ?? ''),
|
|
121
|
+
};
|
|
122
|
+
}
|
|
85
123
|
function parseVerification(e) {
|
|
86
124
|
const raw = Array.isArray(e.data.results) ? e.data.results : [];
|
|
87
125
|
const results = raw
|
|
@@ -115,6 +153,10 @@ export function buildProjection(events, issues = []) {
|
|
|
115
153
|
replans: 0,
|
|
116
154
|
issues,
|
|
117
155
|
interruptedTools: classifyInterruptedTools(events),
|
|
156
|
+
permissionDenials: [],
|
|
157
|
+
decisionEvents: [],
|
|
158
|
+
verifyDebts: projectVerifyDebts(events),
|
|
159
|
+
toolCallBreakdown: tallyToolCalls(events),
|
|
118
160
|
};
|
|
119
161
|
for (const e of events) {
|
|
120
162
|
switch (e.kind) {
|
|
@@ -155,6 +197,21 @@ export function buildProjection(events, issues = []) {
|
|
|
155
197
|
rationale: String(e.data.rationale ?? ''),
|
|
156
198
|
});
|
|
157
199
|
break;
|
|
200
|
+
case 'permission.denied':
|
|
201
|
+
projection.permissionDenials.push(parsePermissionDenial(e));
|
|
202
|
+
// …and it IS a decision point: the WS1 denial joins the aggregate too
|
|
203
|
+
// (its dedicated field stays for back-compat consumers — see
|
|
204
|
+
// DECISION_PROJECTION_KINDS).
|
|
205
|
+
projection.decisionEvents.push(parseDecisionEvent(e));
|
|
206
|
+
break;
|
|
207
|
+
// WS7 slice 2 (t140): decision points. Listed explicitly (not a `default`
|
|
208
|
+
// guard) so "who replays ask_user.fired?" answers itself by grep.
|
|
209
|
+
case 'permission.asked':
|
|
210
|
+
case 'auto_approve.granted':
|
|
211
|
+
case 'jail.blocked':
|
|
212
|
+
case 'ask_user.fired':
|
|
213
|
+
case 'verify.requested':
|
|
214
|
+
projection.decisionEvents.push(parseDecisionEvent(e));
|
|
158
215
|
break;
|
|
159
216
|
}
|
|
160
217
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"replay.js","sourceRoot":"","sources":["../../src/session/replay.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,QAAQ,IAAI,EAAE,EAAE,MAAM,SAAS,CAAC;AACzC,OAAO,EACL,0BAA0B,GAE3B,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,cAAc,EAAuB,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"replay.js","sourceRoot":"","sources":["../../src/session/replay.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,QAAQ,IAAI,EAAE,EAAE,MAAM,SAAS,CAAC;AACzC,OAAO,EACL,0BAA0B,GAE3B,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,cAAc,EAAE,aAAa,EAAuB,MAAM,mBAAmB,CAAC;AACvF,OAAO,EAAE,wBAAwB,EAAwB,MAAM,eAAe,CAAC;AAC/E,OAAO,EAAE,kBAAkB,EAA6B,MAAM,qBAAqB,CAAC;AACpF,OAAO,EAAE,k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EAAE,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,IAAI,EAAE,CAAC;iBAC1C,CAAC,CAAC;gBACH,MAAM;YACR,KAAK,mBAAmB;gBACtB,UAAU,CAAC,iBAAiB,CAAC,IAAI,CAAC,qBAAqB,CAAC,CAAC,CAAC,CAAC,CAAC;gBAC5D,sEAAsE;gBACtE,6DAA6D;gBAC7D,8BAA8B;gBAC9B,UAAU,CAAC,cAAc,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAC,CAAC,CAAC,CAAC;gBACtD,MAAM;YACR,0EAA0E;YAC1E,kEAAkE;YAClE,KAAK,kBAAkB,CAAC;YACxB,KAAK,sBAAsB,CAAC;YAC5B,KAAK,cAAc,CAAC;YACpB,KAAK,gBAAgB,CAAC;YACtB,KAAK,kBAAkB;gBACrB,UAAU,CAAC,cAAc,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAC,CAAC,CAAC,CAAC;gBACtD,MAAM;QACV,CAAC;IACH,CAAC;IACD,OAAO,UAAU,CAAC;AACpB,CAAC"}
|
package/dist/session/types.d.ts
CHANGED
|
@@ -36,7 +36,7 @@ export type SessionActor = z.infer<typeof SessionActorSchema>;
|
|
|
36
36
|
* replay: the tolerant reader (replay.ts) reports unknown kinds as
|
|
37
37
|
* `schema-mismatch` issues and skips those lines.
|
|
38
38
|
*/
|
|
39
|
-
export declare const SESSION_EVENT_KINDS: readonly ["session.started", "session.resumed", "session.ended", "session.forked", "session.harness_manifest", "user.message", "assistant.message", "tool.call", "tool.result", "tool.interrupted", "session.compacted", "task.created", "task.updated", "task.contract", "task.contract_updated", "council.member", "mission.phase", "mission.replan", "mission.progress", "verification.run", "verification.evidence", "resource.epoch_started", "resource.snapshot", "resource.limit_reached", "resource.reserve_entered", "resource.overrun", "graph.node_started", "graph.node_ended", "file.read", "file.applied", "file.rejected", "strict.waived", "verify.debt_open", "verify.debt_cleared", "note"];
|
|
39
|
+
export declare const SESSION_EVENT_KINDS: readonly ["session.started", "session.resumed", "session.ended", "session.forked", "session.harness_manifest", "user.message", "assistant.message", "tool.call", "tool.result", "tool.interrupted", "session.compacted", "task.created", "task.updated", "task.contract", "task.contract_updated", "council.member", "mission.phase", "mission.replan", "mission.progress", "verification.run", "verification.evidence", "resource.epoch_started", "resource.snapshot", "resource.limit_reached", "resource.reserve_entered", "resource.overrun", "graph.node_started", "graph.node_ended", "file.read", "file.applied", "file.rejected", "strict.waived", "verify.debt_open", "verify.debt_cleared", "permission.denied", "permission.asked", "auto_approve.granted", "jail.blocked", "ask_user.fired", "verify.requested", "note"];
|
|
40
40
|
export type SessionEventKind = (typeof SESSION_EVENT_KINDS)[number];
|
|
41
41
|
export declare const SessionEventEnvelopeSchema: z.ZodObject<{
|
|
42
42
|
schemaVersion: z.ZodLiteral<1>;
|
|
@@ -78,6 +78,12 @@ export declare const SessionEventEnvelopeSchema: z.ZodObject<{
|
|
|
78
78
|
"strict.waived": "strict.waived";
|
|
79
79
|
"verify.debt_open": "verify.debt_open";
|
|
80
80
|
"verify.debt_cleared": "verify.debt_cleared";
|
|
81
|
+
"permission.denied": "permission.denied";
|
|
82
|
+
"permission.asked": "permission.asked";
|
|
83
|
+
"auto_approve.granted": "auto_approve.granted";
|
|
84
|
+
"jail.blocked": "jail.blocked";
|
|
85
|
+
"ask_user.fired": "ask_user.fired";
|
|
86
|
+
"verify.requested": "verify.requested";
|
|
81
87
|
note: "note";
|
|
82
88
|
}>;
|
|
83
89
|
actor: z.ZodObject<{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/session/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,sFAAsF;AACtF,eAAO,MAAM,sBAAsB,IAAI,CAAC;AAExC,eAAO,MAAM,kBAAkB;;;;;;;;;;iBAK7B,CAAC;AACH,MAAM,MAAM,YAAY,GAAG,CAAC,CAAC,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