@deepstrike/wasm 0.2.77 → 0.2.79
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/dist/agent.d.ts +6 -2
- package/dist/agent.js +59 -19
- package/dist/index.d.ts +7 -9
- package/dist/index.js +3 -5
- package/dist/memory/attestation.d.ts +38 -0
- package/dist/memory/attestation.js +43 -0
- package/dist/memory/authority.d.ts +2 -0
- package/dist/memory/authority.js +3 -1
- package/dist/memory/candidate-sink.d.ts +66 -0
- package/dist/memory/candidate-sink.js +82 -0
- package/dist/memory/durable.d.ts +4 -2
- package/dist/memory/durable.js +2 -0
- package/dist/memory/index.d.ts +9 -1
- package/dist/memory/index.js +5 -0
- package/dist/memory/lifecycle.d.ts +82 -0
- package/dist/memory/lifecycle.js +46 -0
- package/dist/memory/recall-projection.d.ts +5 -0
- package/dist/memory/recall-projection.js +18 -0
- package/dist/memory/runtime-policy.d.ts +15 -0
- package/dist/memory/runtime-policy.js +26 -0
- package/dist/memory/writer.d.ts +22 -0
- package/dist/memory/writer.js +41 -0
- package/dist/providers/anthropic-compaction.d.ts +84 -0
- package/dist/providers/anthropic-compaction.js +222 -0
- package/dist/providers/anthropic.d.ts +41 -1
- package/dist/providers/anthropic.js +187 -18
- package/dist/providers/base.js +11 -1
- package/dist/runtime/canonical-kernel-step.d.ts +1 -2
- package/dist/runtime/canonical-kernel-step.js +74 -8
- package/dist/runtime/execution-plane.js +1 -1
- package/dist/runtime/index.d.ts +0 -2
- package/dist/runtime/index.js +0 -1
- package/dist/runtime/kernel-event-log.d.ts +8 -0
- package/dist/runtime/kernel-event-log.js +63 -1
- package/dist/runtime/kernel-step.d.ts +15 -2
- package/dist/runtime/os-snapshot.js +1 -0
- package/dist/runtime/runner.d.ts +44 -26
- package/dist/runtime/runner.js +206 -240
- package/dist/runtime/session-event-registry.generated.d.ts +212 -0
- package/dist/runtime/session-event-registry.generated.js +112 -0
- package/dist/runtime/session-log.d.ts +83 -16
- package/dist/runtime/session-log.js +10 -58
- package/dist/runtime/session-repair.d.ts +0 -3
- package/dist/runtime/session-repair.js +0 -3
- package/dist/runtime/sub-agent-orchestrator.d.ts +5 -1
- package/dist/runtime/sub-agent-orchestrator.js +4 -0
- package/dist/runtime/types/agent.d.ts +18 -52
- package/dist/runtime/types/agent.js +8 -45
- package/dist/types.d.ts +10 -5
- package/package.json +3 -3
- package/dist/memory/extraction.d.ts +0 -4
- package/dist/memory/extraction.js +0 -48
- package/dist/runtime/context.d.ts +0 -28
- package/dist/runtime/context.js +0 -16
- package/dist/runtime/evolution.d.ts +0 -189
- package/dist/runtime/evolution.js +0 -25
- package/dist/runtime/reducers.d.ts +0 -15
- package/dist/runtime/reducers.js +0 -57
- package/dist/runtime/verifiable-report.d.ts +0 -59
- package/dist/runtime/verifiable-report.js +0 -64
- package/dist/runtime/workflow-control-flow.d.ts +0 -21
- package/dist/runtime/workflow-control-flow.js +0 -83
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
export declare const SESSION_EVENT_REGISTRY: {
|
|
2
|
+
readonly run_started: {
|
|
3
|
+
readonly required: readonly ["criteria", "goal", "run_id"];
|
|
4
|
+
readonly optional: readonly ["agent_id", "attachments", "metadata", "route", "system_prompt"];
|
|
5
|
+
};
|
|
6
|
+
readonly llm_completed: {
|
|
7
|
+
readonly required: readonly ["content", "tool_calls", "turn"];
|
|
8
|
+
readonly optional: readonly ["effect_id", "invocation_id", "token_count", "wire_evidence"];
|
|
9
|
+
};
|
|
10
|
+
readonly prompt_measured: {
|
|
11
|
+
readonly required: readonly ["measurement", "turn"];
|
|
12
|
+
readonly optional: readonly ["effect_id"];
|
|
13
|
+
};
|
|
14
|
+
readonly provider_attempt: {
|
|
15
|
+
readonly required: readonly ["attempt_seq", "effect_id", "finished_at_ms", "request_fingerprint", "route", "started_at_ms", "status", "transport_rungs"];
|
|
16
|
+
readonly optional: readonly ["accounting_policy_id", "last_error_class", "usage", "wire_evidence"];
|
|
17
|
+
};
|
|
18
|
+
readonly tool_requested: {
|
|
19
|
+
readonly required: readonly ["calls", "turn"];
|
|
20
|
+
readonly optional: readonly [];
|
|
21
|
+
};
|
|
22
|
+
readonly tool_completed: {
|
|
23
|
+
readonly required: readonly ["results", "turn"];
|
|
24
|
+
readonly optional: readonly ["effect_id"];
|
|
25
|
+
};
|
|
26
|
+
readonly tool_argument_repaired: {
|
|
27
|
+
readonly required: readonly ["original_arguments", "repaired_arguments", "tool", "turn"];
|
|
28
|
+
readonly optional: readonly [];
|
|
29
|
+
};
|
|
30
|
+
readonly tool_denied: {
|
|
31
|
+
readonly required: readonly ["call_id", "reason", "tool_name", "turn"];
|
|
32
|
+
readonly optional: readonly [];
|
|
33
|
+
};
|
|
34
|
+
readonly permission_requested: {
|
|
35
|
+
readonly required: readonly ["arguments", "tool", "turn"];
|
|
36
|
+
readonly optional: readonly ["reason"];
|
|
37
|
+
};
|
|
38
|
+
readonly permission_resolved: {
|
|
39
|
+
readonly required: readonly ["approved", "responder", "turn"];
|
|
40
|
+
readonly optional: readonly [];
|
|
41
|
+
};
|
|
42
|
+
readonly compressed: {
|
|
43
|
+
readonly required: readonly ["archived_seq_range", "turn"];
|
|
44
|
+
readonly optional: readonly ["action", "preserved_refs", "summary", "summary_tokens"];
|
|
45
|
+
};
|
|
46
|
+
readonly page_out: {
|
|
47
|
+
readonly required: readonly ["turn"];
|
|
48
|
+
readonly optional: readonly ["action", "archive_ref", "message_count", "summary", "tier_hint"];
|
|
49
|
+
};
|
|
50
|
+
readonly semantic_archive_pending: {
|
|
51
|
+
readonly required: readonly ["effect_id"];
|
|
52
|
+
readonly optional: readonly ["action"];
|
|
53
|
+
};
|
|
54
|
+
readonly semantic_archive_completed: {
|
|
55
|
+
readonly required: readonly ["effect_id", "record_id"];
|
|
56
|
+
readonly optional: readonly [];
|
|
57
|
+
};
|
|
58
|
+
readonly semantic_archive_failed: {
|
|
59
|
+
readonly required: readonly ["effect_id", "error"];
|
|
60
|
+
readonly optional: readonly [];
|
|
61
|
+
};
|
|
62
|
+
readonly page_in: {
|
|
63
|
+
readonly required: readonly ["entry_count", "turn"];
|
|
64
|
+
readonly optional: readonly [];
|
|
65
|
+
};
|
|
66
|
+
readonly rollbacked: {
|
|
67
|
+
readonly required: readonly ["checkpoint_history_len", "turn"];
|
|
68
|
+
readonly optional: readonly ["reason"];
|
|
69
|
+
};
|
|
70
|
+
readonly capability_changed: {
|
|
71
|
+
readonly required: readonly ["added", "removed", "turn"];
|
|
72
|
+
readonly optional: readonly ["capability_id", "change_kind", "mount_reason", "mounted_by", "version"];
|
|
73
|
+
};
|
|
74
|
+
readonly context_renewed: {
|
|
75
|
+
readonly required: readonly ["handoff_ref", "sprint", "turn"];
|
|
76
|
+
readonly optional: readonly [];
|
|
77
|
+
};
|
|
78
|
+
readonly context_lifecycle_reported: {
|
|
79
|
+
readonly required: readonly ["cache_loss_tokens", "knowledge_entries", "knowledge_referenced", "recall_expanded", "recalled", "regret", "turn", "waste_tokens"];
|
|
80
|
+
readonly optional: readonly ["history", "history_items", "history_items_omitted", "items"];
|
|
81
|
+
};
|
|
82
|
+
readonly suspended: {
|
|
83
|
+
readonly required: readonly ["reason", "turn"];
|
|
84
|
+
readonly optional: readonly ["pending_calls"];
|
|
85
|
+
};
|
|
86
|
+
readonly resumed: {
|
|
87
|
+
readonly required: readonly ["turn"];
|
|
88
|
+
readonly optional: readonly ["approved", "denied"];
|
|
89
|
+
};
|
|
90
|
+
readonly tool_gated: {
|
|
91
|
+
readonly required: readonly ["call_id", "reason", "tool", "turn"];
|
|
92
|
+
readonly optional: readonly [];
|
|
93
|
+
};
|
|
94
|
+
readonly signal_delivery_disposed: {
|
|
95
|
+
readonly required: readonly ["attempt", "delivery_id", "disposition", "operation_id", "queue_depth", "signal_id", "turn"];
|
|
96
|
+
readonly optional: readonly [];
|
|
97
|
+
};
|
|
98
|
+
readonly budget_exceeded: {
|
|
99
|
+
readonly required: readonly ["budget", "operation_id", "turn"];
|
|
100
|
+
readonly optional: readonly ["reservation_id"];
|
|
101
|
+
};
|
|
102
|
+
readonly budget_usage_reported: {
|
|
103
|
+
readonly required: readonly ["operation_id", "reservation_id", "rounds", "subagents", "tokens", "turn"];
|
|
104
|
+
readonly optional: readonly [];
|
|
105
|
+
};
|
|
106
|
+
readonly operation_cancelled: {
|
|
107
|
+
readonly required: readonly ["operation_id", "pending_call_ids", "reason", "turn"];
|
|
108
|
+
readonly optional: readonly [];
|
|
109
|
+
};
|
|
110
|
+
readonly milestone_advanced: {
|
|
111
|
+
readonly required: readonly ["capabilities_unlocked", "phase_id", "turn"];
|
|
112
|
+
readonly optional: readonly [];
|
|
113
|
+
};
|
|
114
|
+
readonly milestone_blocked: {
|
|
115
|
+
readonly required: readonly ["phase_id", "reason", "turn"];
|
|
116
|
+
readonly optional: readonly [];
|
|
117
|
+
};
|
|
118
|
+
readonly checkpoint_taken: {
|
|
119
|
+
readonly required: readonly ["history_len", "turn"];
|
|
120
|
+
readonly optional: readonly [];
|
|
121
|
+
};
|
|
122
|
+
readonly entropy_sample: {
|
|
123
|
+
readonly required: readonly ["failure_rate", "repeat_pressure", "rho", "rollbacks_in_window", "score", "turn", "window_turns"];
|
|
124
|
+
readonly optional: readonly [];
|
|
125
|
+
};
|
|
126
|
+
readonly entropy_alert: {
|
|
127
|
+
readonly required: readonly ["score", "threshold", "turn"];
|
|
128
|
+
readonly optional: readonly [];
|
|
129
|
+
};
|
|
130
|
+
readonly agent_process_changed: {
|
|
131
|
+
readonly required: readonly ["agent_id", "context_inheritance", "isolation", "permitted_capability_ids", "role", "turn"];
|
|
132
|
+
readonly optional: readonly ["parent_session_id", "parent_task_id", "result_termination", "state"];
|
|
133
|
+
};
|
|
134
|
+
readonly memory_written: {
|
|
135
|
+
readonly required: readonly ["memory_kind", "name", "record_id", "scope", "size_bytes", "turn"];
|
|
136
|
+
readonly optional: readonly [];
|
|
137
|
+
};
|
|
138
|
+
readonly memory_queried: {
|
|
139
|
+
readonly required: readonly ["query", "requested_k", "requires_async_response", "scope", "turn"];
|
|
140
|
+
readonly optional: readonly [];
|
|
141
|
+
};
|
|
142
|
+
readonly memory_validation_failed: {
|
|
143
|
+
readonly required: readonly ["error", "record_id", "turn"];
|
|
144
|
+
readonly optional: readonly [];
|
|
145
|
+
};
|
|
146
|
+
readonly memory_write_failed: {
|
|
147
|
+
readonly required: readonly ["error", "record_id", "turn"];
|
|
148
|
+
readonly optional: readonly [];
|
|
149
|
+
};
|
|
150
|
+
readonly memory_candidate_pending: {
|
|
151
|
+
readonly required: readonly ["candidate_id", "name", "source", "turn"];
|
|
152
|
+
readonly optional: readonly ["receipt_id"];
|
|
153
|
+
};
|
|
154
|
+
readonly memory_candidate_rejected: {
|
|
155
|
+
readonly required: readonly ["candidate_id", "name", "reason_code", "receipt_id", "source", "turn"];
|
|
156
|
+
readonly optional: readonly [];
|
|
157
|
+
};
|
|
158
|
+
readonly memory_query_failed: {
|
|
159
|
+
readonly required: readonly ["error", "query", "scope", "turn"];
|
|
160
|
+
readonly optional: readonly [];
|
|
161
|
+
};
|
|
162
|
+
readonly memory_retrieval_result: {
|
|
163
|
+
readonly required: readonly ["hits"];
|
|
164
|
+
readonly optional: readonly [];
|
|
165
|
+
};
|
|
166
|
+
readonly workflow_node_completed: {
|
|
167
|
+
readonly required: readonly ["agent_id", "status", "termination", "turn"];
|
|
168
|
+
readonly optional: readonly ["output"];
|
|
169
|
+
};
|
|
170
|
+
readonly workflow_nodes_submitted: {
|
|
171
|
+
readonly required: readonly ["nodes", "turn"];
|
|
172
|
+
readonly optional: readonly ["base_index", "submitter_agent_id"];
|
|
173
|
+
};
|
|
174
|
+
readonly workflow_batch_spawned: {
|
|
175
|
+
readonly required: readonly ["node_count", "node_ids", "turn"];
|
|
176
|
+
readonly optional: readonly [];
|
|
177
|
+
};
|
|
178
|
+
readonly workflow_completed: {
|
|
179
|
+
readonly required: readonly ["node_outcomes", "total_nodes", "turn"];
|
|
180
|
+
readonly optional: readonly [];
|
|
181
|
+
};
|
|
182
|
+
readonly kernel_observation: {
|
|
183
|
+
readonly required: readonly ["observation_kind", "raw", "turn"];
|
|
184
|
+
readonly optional: readonly [];
|
|
185
|
+
};
|
|
186
|
+
readonly run_terminal: {
|
|
187
|
+
readonly required: readonly ["reason", "total_tokens", "turns_used"];
|
|
188
|
+
readonly optional: readonly [];
|
|
189
|
+
};
|
|
190
|
+
readonly summary_upgraded: {
|
|
191
|
+
readonly required: readonly ["compressed_seq", "summary"];
|
|
192
|
+
readonly optional: readonly [];
|
|
193
|
+
};
|
|
194
|
+
readonly group_member_joined: {
|
|
195
|
+
readonly required: readonly ["session_id"];
|
|
196
|
+
readonly optional: readonly ["member_kind", "role"];
|
|
197
|
+
};
|
|
198
|
+
readonly group_budget_charged: {
|
|
199
|
+
readonly required: readonly ["subagents", "tokens"];
|
|
200
|
+
readonly optional: readonly ["rounds"];
|
|
201
|
+
};
|
|
202
|
+
readonly round_started: {
|
|
203
|
+
readonly required: readonly ["goal", "round"];
|
|
204
|
+
readonly optional: readonly [];
|
|
205
|
+
};
|
|
206
|
+
readonly round_paced: {
|
|
207
|
+
readonly required: readonly ["action", "reason", "round"];
|
|
208
|
+
readonly optional: readonly ["coerced_from", "delay_ms", "wake_at_ms"];
|
|
209
|
+
};
|
|
210
|
+
};
|
|
211
|
+
/** Registered kinds in registry order. */
|
|
212
|
+
export declare const SESSION_EVENT_KINDS: readonly ["run_started", "llm_completed", "prompt_measured", "provider_attempt", "tool_requested", "tool_completed", "tool_argument_repaired", "tool_denied", "permission_requested", "permission_resolved", "compressed", "page_out", "semantic_archive_pending", "semantic_archive_completed", "semantic_archive_failed", "page_in", "rollbacked", "capability_changed", "context_renewed", "context_lifecycle_reported", "suspended", "resumed", "tool_gated", "signal_delivery_disposed", "budget_exceeded", "budget_usage_reported", "operation_cancelled", "milestone_advanced", "milestone_blocked", "checkpoint_taken", "entropy_sample", "entropy_alert", "agent_process_changed", "memory_written", "memory_queried", "memory_validation_failed", "memory_write_failed", "memory_candidate_pending", "memory_candidate_rejected", "memory_query_failed", "memory_retrieval_result", "workflow_node_completed", "workflow_nodes_submitted", "workflow_batch_spawned", "workflow_completed", "kernel_observation", "run_terminal", "summary_upgraded", "group_member_joined", "group_budget_charged", "round_started", "round_paced"];
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
// GENERATED by scripts/gen-session-event-registry.mjs from contracts/session-events.json.
|
|
2
|
+
// Do not edit: change the registry and regenerate. `session-log.ts` asserts at compile time
|
|
3
|
+
// that the SessionEvent union matches these kinds and fields exactly.
|
|
4
|
+
export const SESSION_EVENT_REGISTRY = {
|
|
5
|
+
run_started: { required: ["criteria", "goal", "run_id"], optional: ["agent_id", "attachments", "metadata", "route", "system_prompt"] },
|
|
6
|
+
llm_completed: { required: ["content", "tool_calls", "turn"], optional: ["effect_id", "invocation_id", "token_count", "wire_evidence"] },
|
|
7
|
+
prompt_measured: { required: ["measurement", "turn"], optional: ["effect_id"] },
|
|
8
|
+
provider_attempt: { required: ["attempt_seq", "effect_id", "finished_at_ms", "request_fingerprint", "route", "started_at_ms", "status", "transport_rungs"], optional: ["accounting_policy_id", "last_error_class", "usage", "wire_evidence"] },
|
|
9
|
+
tool_requested: { required: ["calls", "turn"], optional: [] },
|
|
10
|
+
tool_completed: { required: ["results", "turn"], optional: ["effect_id"] },
|
|
11
|
+
tool_argument_repaired: { required: ["original_arguments", "repaired_arguments", "tool", "turn"], optional: [] },
|
|
12
|
+
tool_denied: { required: ["call_id", "reason", "tool_name", "turn"], optional: [] },
|
|
13
|
+
permission_requested: { required: ["arguments", "tool", "turn"], optional: ["reason"] },
|
|
14
|
+
permission_resolved: { required: ["approved", "responder", "turn"], optional: [] },
|
|
15
|
+
compressed: { required: ["archived_seq_range", "turn"], optional: ["action", "preserved_refs", "summary", "summary_tokens"] },
|
|
16
|
+
page_out: { required: ["turn"], optional: ["action", "archive_ref", "message_count", "summary", "tier_hint"] },
|
|
17
|
+
semantic_archive_pending: { required: ["effect_id"], optional: ["action"] },
|
|
18
|
+
semantic_archive_completed: { required: ["effect_id", "record_id"], optional: [] },
|
|
19
|
+
semantic_archive_failed: { required: ["effect_id", "error"], optional: [] },
|
|
20
|
+
page_in: { required: ["entry_count", "turn"], optional: [] },
|
|
21
|
+
rollbacked: { required: ["checkpoint_history_len", "turn"], optional: ["reason"] },
|
|
22
|
+
capability_changed: { required: ["added", "removed", "turn"], optional: ["capability_id", "change_kind", "mount_reason", "mounted_by", "version"] },
|
|
23
|
+
context_renewed: { required: ["handoff_ref", "sprint", "turn"], optional: [] },
|
|
24
|
+
context_lifecycle_reported: { required: ["cache_loss_tokens", "knowledge_entries", "knowledge_referenced", "recall_expanded", "recalled", "regret", "turn", "waste_tokens"], optional: ["history", "history_items", "history_items_omitted", "items"] },
|
|
25
|
+
suspended: { required: ["reason", "turn"], optional: ["pending_calls"] },
|
|
26
|
+
resumed: { required: ["turn"], optional: ["approved", "denied"] },
|
|
27
|
+
tool_gated: { required: ["call_id", "reason", "tool", "turn"], optional: [] },
|
|
28
|
+
signal_delivery_disposed: { required: ["attempt", "delivery_id", "disposition", "operation_id", "queue_depth", "signal_id", "turn"], optional: [] },
|
|
29
|
+
budget_exceeded: { required: ["budget", "operation_id", "turn"], optional: ["reservation_id"] },
|
|
30
|
+
budget_usage_reported: { required: ["operation_id", "reservation_id", "rounds", "subagents", "tokens", "turn"], optional: [] },
|
|
31
|
+
operation_cancelled: { required: ["operation_id", "pending_call_ids", "reason", "turn"], optional: [] },
|
|
32
|
+
milestone_advanced: { required: ["capabilities_unlocked", "phase_id", "turn"], optional: [] },
|
|
33
|
+
milestone_blocked: { required: ["phase_id", "reason", "turn"], optional: [] },
|
|
34
|
+
checkpoint_taken: { required: ["history_len", "turn"], optional: [] },
|
|
35
|
+
entropy_sample: { required: ["failure_rate", "repeat_pressure", "rho", "rollbacks_in_window", "score", "turn", "window_turns"], optional: [] },
|
|
36
|
+
entropy_alert: { required: ["score", "threshold", "turn"], optional: [] },
|
|
37
|
+
agent_process_changed: { required: ["agent_id", "context_inheritance", "isolation", "permitted_capability_ids", "role", "turn"], optional: ["parent_session_id", "parent_task_id", "result_termination", "state"] },
|
|
38
|
+
memory_written: { required: ["memory_kind", "name", "record_id", "scope", "size_bytes", "turn"], optional: [] },
|
|
39
|
+
memory_queried: { required: ["query", "requested_k", "requires_async_response", "scope", "turn"], optional: [] },
|
|
40
|
+
memory_validation_failed: { required: ["error", "record_id", "turn"], optional: [] },
|
|
41
|
+
memory_write_failed: { required: ["error", "record_id", "turn"], optional: [] },
|
|
42
|
+
memory_candidate_pending: { required: ["candidate_id", "name", "source", "turn"], optional: ["receipt_id"] },
|
|
43
|
+
memory_candidate_rejected: { required: ["candidate_id", "name", "reason_code", "receipt_id", "source", "turn"], optional: [] },
|
|
44
|
+
memory_query_failed: { required: ["error", "query", "scope", "turn"], optional: [] },
|
|
45
|
+
memory_retrieval_result: { required: ["hits"], optional: [] },
|
|
46
|
+
workflow_node_completed: { required: ["agent_id", "status", "termination", "turn"], optional: ["output"] },
|
|
47
|
+
workflow_nodes_submitted: { required: ["nodes", "turn"], optional: ["base_index", "submitter_agent_id"] },
|
|
48
|
+
workflow_batch_spawned: { required: ["node_count", "node_ids", "turn"], optional: [] },
|
|
49
|
+
workflow_completed: { required: ["node_outcomes", "total_nodes", "turn"], optional: [] },
|
|
50
|
+
kernel_observation: { required: ["observation_kind", "raw", "turn"], optional: [] },
|
|
51
|
+
run_terminal: { required: ["reason", "total_tokens", "turns_used"], optional: [] },
|
|
52
|
+
summary_upgraded: { required: ["compressed_seq", "summary"], optional: [] },
|
|
53
|
+
group_member_joined: { required: ["session_id"], optional: ["member_kind", "role"] },
|
|
54
|
+
group_budget_charged: { required: ["subagents", "tokens"], optional: ["rounds"] },
|
|
55
|
+
round_started: { required: ["goal", "round"], optional: [] },
|
|
56
|
+
round_paced: { required: ["action", "reason", "round"], optional: ["coerced_from", "delay_ms", "wake_at_ms"] },
|
|
57
|
+
};
|
|
58
|
+
/** Registered kinds in registry order. */
|
|
59
|
+
export const SESSION_EVENT_KINDS = [
|
|
60
|
+
"run_started",
|
|
61
|
+
"llm_completed",
|
|
62
|
+
"prompt_measured",
|
|
63
|
+
"provider_attempt",
|
|
64
|
+
"tool_requested",
|
|
65
|
+
"tool_completed",
|
|
66
|
+
"tool_argument_repaired",
|
|
67
|
+
"tool_denied",
|
|
68
|
+
"permission_requested",
|
|
69
|
+
"permission_resolved",
|
|
70
|
+
"compressed",
|
|
71
|
+
"page_out",
|
|
72
|
+
"semantic_archive_pending",
|
|
73
|
+
"semantic_archive_completed",
|
|
74
|
+
"semantic_archive_failed",
|
|
75
|
+
"page_in",
|
|
76
|
+
"rollbacked",
|
|
77
|
+
"capability_changed",
|
|
78
|
+
"context_renewed",
|
|
79
|
+
"context_lifecycle_reported",
|
|
80
|
+
"suspended",
|
|
81
|
+
"resumed",
|
|
82
|
+
"tool_gated",
|
|
83
|
+
"signal_delivery_disposed",
|
|
84
|
+
"budget_exceeded",
|
|
85
|
+
"budget_usage_reported",
|
|
86
|
+
"operation_cancelled",
|
|
87
|
+
"milestone_advanced",
|
|
88
|
+
"milestone_blocked",
|
|
89
|
+
"checkpoint_taken",
|
|
90
|
+
"entropy_sample",
|
|
91
|
+
"entropy_alert",
|
|
92
|
+
"agent_process_changed",
|
|
93
|
+
"memory_written",
|
|
94
|
+
"memory_queried",
|
|
95
|
+
"memory_validation_failed",
|
|
96
|
+
"memory_write_failed",
|
|
97
|
+
"memory_candidate_pending",
|
|
98
|
+
"memory_candidate_rejected",
|
|
99
|
+
"memory_query_failed",
|
|
100
|
+
"memory_retrieval_result",
|
|
101
|
+
"workflow_node_completed",
|
|
102
|
+
"workflow_nodes_submitted",
|
|
103
|
+
"workflow_batch_spawned",
|
|
104
|
+
"workflow_completed",
|
|
105
|
+
"kernel_observation",
|
|
106
|
+
"run_terminal",
|
|
107
|
+
"summary_upgraded",
|
|
108
|
+
"group_member_joined",
|
|
109
|
+
"group_budget_charged",
|
|
110
|
+
"round_started",
|
|
111
|
+
"round_paced",
|
|
112
|
+
];
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { SESSION_EVENT_REGISTRY } from "./session-event-registry.generated.js";
|
|
2
2
|
import type { ProviderWireEvidence, ToolCall, ToolErrorKind } from "../types.js";
|
|
3
3
|
import type { MemoryRecall, MemoryScope } from "../memory/index.js";
|
|
4
4
|
import type { KernelPrimitive } from "./kernel-event-log.js";
|
|
@@ -42,6 +42,42 @@ export interface ProviderAttemptRecord {
|
|
|
42
42
|
wire_evidence?: ProviderWireEvidence;
|
|
43
43
|
accounting_policy_id?: string;
|
|
44
44
|
}
|
|
45
|
+
/** History items of one origin in a `context_lifecycle_reported` event (plan task 4.1). */
|
|
46
|
+
export interface ContextOriginTally {
|
|
47
|
+
origin: ContextItemRecord["origin"];
|
|
48
|
+
items: number;
|
|
49
|
+
tokens: number;
|
|
50
|
+
resident_items?: number;
|
|
51
|
+
resident_tokens?: number;
|
|
52
|
+
read_back?: number;
|
|
53
|
+
}
|
|
54
|
+
/** One knowledge item's lifecycle in a `context_lifecycle_reported` event (plan task 4.1). */
|
|
55
|
+
export interface ContextItemRecord {
|
|
56
|
+
key?: string;
|
|
57
|
+
origin: "system" | "skill" | "memory_recall" | "reference" | "tool_result" | "dependency_output" | "user" | "assistant" | "task_state" | "signal" | "provider_summary";
|
|
58
|
+
tokens: number;
|
|
59
|
+
value: {
|
|
60
|
+
injected_turn: number;
|
|
61
|
+
ref_count: number;
|
|
62
|
+
last_referenced_step?: number;
|
|
63
|
+
last_referenced_turn?: number;
|
|
64
|
+
expanded?: boolean;
|
|
65
|
+
paged_in_after_evict?: boolean;
|
|
66
|
+
};
|
|
67
|
+
/** Why it left; absent while resident. */
|
|
68
|
+
end?: "evicted" | "expired" | "removed" | "compacted" | "renewed";
|
|
69
|
+
}
|
|
70
|
+
/** One history item's lifecycle in a `context_lifecycle_reported` event (plan task 4.1). */
|
|
71
|
+
export interface ContextHistoryItemRecord {
|
|
72
|
+
id: number;
|
|
73
|
+
origin: ContextItemRecord["origin"];
|
|
74
|
+
tokens: number;
|
|
75
|
+
injected_turn: number;
|
|
76
|
+
/** What it rendered when it left, or renders now; absent = full. */
|
|
77
|
+
fidelity?: "structured" | "excerpt" | "handle";
|
|
78
|
+
/** Why it left; absent while still in history. */
|
|
79
|
+
end?: "removed" | "compacted" | "renewed";
|
|
80
|
+
}
|
|
45
81
|
export type SessionEvent = {
|
|
46
82
|
kind: "run_started";
|
|
47
83
|
run_id: string;
|
|
@@ -51,6 +87,7 @@ export type SessionEvent = {
|
|
|
51
87
|
system_prompt?: string;
|
|
52
88
|
attachments?: import("../types.js").ContentPart[];
|
|
53
89
|
route?: ResolvedProviderRoute;
|
|
90
|
+
metadata?: Record<string, unknown>;
|
|
54
91
|
} | {
|
|
55
92
|
kind: "llm_completed";
|
|
56
93
|
turn: number;
|
|
@@ -60,11 +97,6 @@ export type SessionEvent = {
|
|
|
60
97
|
effect_id?: string;
|
|
61
98
|
invocation_id?: string;
|
|
62
99
|
wire_evidence?: ProviderWireEvidence;
|
|
63
|
-
} | {
|
|
64
|
-
kind: "context_prepared";
|
|
65
|
-
turn: number;
|
|
66
|
-
effect_id: string;
|
|
67
|
-
preparation: ContextPrepared;
|
|
68
100
|
} | {
|
|
69
101
|
kind: "prompt_measured";
|
|
70
102
|
turn: number;
|
|
@@ -166,6 +198,24 @@ export type SessionEvent = {
|
|
|
166
198
|
turn: number;
|
|
167
199
|
sprint: number;
|
|
168
200
|
handoff_ref: string;
|
|
201
|
+
} | {
|
|
202
|
+
kind: "context_lifecycle_reported";
|
|
203
|
+
turn: number;
|
|
204
|
+
knowledge_entries: number;
|
|
205
|
+
knowledge_referenced: number;
|
|
206
|
+
regret: number;
|
|
207
|
+
waste_tokens: number;
|
|
208
|
+
cache_loss_tokens: number;
|
|
209
|
+
/** Memory records the kernel recalled, and how many the model read with `memory(record_id)`. */
|
|
210
|
+
recalled: number;
|
|
211
|
+
recall_expanded: number;
|
|
212
|
+
/** Every knowledge item of the run. Absent when the run had none. */
|
|
213
|
+
items?: ContextItemRecord[];
|
|
214
|
+
/** History items by origin: admitted, still in history at the end, read back with `read_result`. */
|
|
215
|
+
history?: ContextOriginTally[];
|
|
216
|
+
/** The latest history items one by one (at most 128); older ones are only counted. */
|
|
217
|
+
history_items?: ContextHistoryItemRecord[];
|
|
218
|
+
history_items_omitted?: number;
|
|
169
219
|
} | {
|
|
170
220
|
kind: "suspended";
|
|
171
221
|
turn: number;
|
|
@@ -277,6 +327,26 @@ export type SessionEvent = {
|
|
|
277
327
|
turn: number;
|
|
278
328
|
record_id: string;
|
|
279
329
|
error: string;
|
|
330
|
+
}
|
|
331
|
+
/** M2 · a write handed to the candidate sink and held for review: nothing is remembered yet.
|
|
332
|
+
* `receipt_id` is absent when the fact comes from the kernel's own observation. */
|
|
333
|
+
| {
|
|
334
|
+
kind: "memory_candidate_pending";
|
|
335
|
+
turn: number;
|
|
336
|
+
candidate_id: string;
|
|
337
|
+
source: string;
|
|
338
|
+
name: string;
|
|
339
|
+
receipt_id?: string;
|
|
340
|
+
}
|
|
341
|
+
/** M2 · the candidate sink refused the write. */
|
|
342
|
+
| {
|
|
343
|
+
kind: "memory_candidate_rejected";
|
|
344
|
+
turn: number;
|
|
345
|
+
candidate_id: string;
|
|
346
|
+
source: string;
|
|
347
|
+
name: string;
|
|
348
|
+
receipt_id: string;
|
|
349
|
+
reason_code: string;
|
|
280
350
|
} | {
|
|
281
351
|
kind: "memory_query_failed";
|
|
282
352
|
turn: number;
|
|
@@ -292,11 +362,6 @@ export type SessionEvent = {
|
|
|
292
362
|
agent_id: string;
|
|
293
363
|
status: import("./types/agent.js").WorkflowNodeStatus;
|
|
294
364
|
termination: string;
|
|
295
|
-
/** W-1: result-borne control signals, persisted so resume replays control flow faithfully —
|
|
296
|
-
* a classifier re-prunes its rejected branches, a recorded loop stop is honored. */
|
|
297
|
-
classify_branch?: string;
|
|
298
|
-
tournament_winner?: string;
|
|
299
|
-
loop_continue?: boolean;
|
|
300
365
|
output?: import("../types.js").ModelMessage;
|
|
301
366
|
} | {
|
|
302
367
|
kind: "workflow_nodes_submitted";
|
|
@@ -360,12 +425,14 @@ export type SessionEvent = {
|
|
|
360
425
|
};
|
|
361
426
|
export type SessionEventKind = SessionEvent["kind"];
|
|
362
427
|
/**
|
|
363
|
-
* The registered session-event vocabulary (F9 / S3, P7-S4).
|
|
364
|
-
* `
|
|
365
|
-
* `
|
|
366
|
-
*
|
|
428
|
+
* The registered session-event vocabulary (F9 / S3, P7-S4). The authority is
|
|
429
|
+
* `contracts/session-events.json`; `session-event-registry.generated.ts` is generated from it
|
|
430
|
+
* (`node scripts/gen-session-event-registry.mjs`). The assertions below fail compilation when the
|
|
431
|
+
* `SessionEvent` union and the registry disagree on a kind or on any kind's required/optional
|
|
432
|
+
* top-level fields, so a new event cannot ship without its registry entry.
|
|
367
433
|
*/
|
|
368
|
-
export declare const SESSION_EVENT_KINDS: readonly ["run_started", "llm_completed", "prompt_measured", "
|
|
434
|
+
export declare const SESSION_EVENT_KINDS: readonly ["run_started", "llm_completed", "prompt_measured", "provider_attempt", "tool_requested", "tool_completed", "tool_argument_repaired", "tool_denied", "permission_requested", "permission_resolved", "compressed", "page_out", "semantic_archive_pending", "semantic_archive_completed", "semantic_archive_failed", "page_in", "rollbacked", "capability_changed", "context_renewed", "context_lifecycle_reported", "suspended", "resumed", "tool_gated", "signal_delivery_disposed", "budget_exceeded", "budget_usage_reported", "operation_cancelled", "milestone_advanced", "milestone_blocked", "checkpoint_taken", "entropy_sample", "entropy_alert", "agent_process_changed", "memory_written", "memory_queried", "memory_validation_failed", "memory_write_failed", "memory_candidate_pending", "memory_candidate_rejected", "memory_query_failed", "memory_retrieval_result", "workflow_node_completed", "workflow_nodes_submitted", "workflow_batch_spawned", "workflow_completed", "kernel_observation", "run_terminal", "summary_upgraded", "group_member_joined", "group_budget_charged", "round_started", "round_paced"];
|
|
435
|
+
export { SESSION_EVENT_REGISTRY };
|
|
369
436
|
/**
|
|
370
437
|
* The business-projection log (spec §9.2): run started/terminal, stream events, observations,
|
|
371
438
|
* provider/tool presentation, and audit metadata. Canonical durable records live exclusively in
|
|
@@ -1,65 +1,17 @@
|
|
|
1
|
+
import { SESSION_EVENT_KINDS as REGISTERED_SESSION_EVENT_KINDS, SESSION_EVENT_REGISTRY } from "./session-event-registry.generated.js";
|
|
1
2
|
import { primitiveForKind } from "./kernel-event-log.js";
|
|
2
3
|
import { InMemoryKernelJournal } from "./kernel-journal.js";
|
|
3
4
|
/**
|
|
4
|
-
* The registered session-event vocabulary (F9 / S3, P7-S4).
|
|
5
|
-
* `
|
|
6
|
-
* `
|
|
7
|
-
*
|
|
5
|
+
* The registered session-event vocabulary (F9 / S3, P7-S4). The authority is
|
|
6
|
+
* `contracts/session-events.json`; `session-event-registry.generated.ts` is generated from it
|
|
7
|
+
* (`node scripts/gen-session-event-registry.mjs`). The assertions below fail compilation when the
|
|
8
|
+
* `SessionEvent` union and the registry disagree on a kind or on any kind's required/optional
|
|
9
|
+
* top-level fields, so a new event cannot ship without its registry entry.
|
|
8
10
|
*/
|
|
9
|
-
export const SESSION_EVENT_KINDS =
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
"context_prepared",
|
|
14
|
-
"provider_attempt",
|
|
15
|
-
"tool_requested",
|
|
16
|
-
"tool_completed",
|
|
17
|
-
"tool_argument_repaired",
|
|
18
|
-
"tool_denied",
|
|
19
|
-
"permission_requested",
|
|
20
|
-
"permission_resolved",
|
|
21
|
-
"compressed",
|
|
22
|
-
"page_out",
|
|
23
|
-
"semantic_archive_pending",
|
|
24
|
-
"semantic_archive_completed",
|
|
25
|
-
"semantic_archive_failed",
|
|
26
|
-
"page_in",
|
|
27
|
-
"rollbacked",
|
|
28
|
-
"capability_changed",
|
|
29
|
-
"context_renewed",
|
|
30
|
-
"suspended",
|
|
31
|
-
"resumed",
|
|
32
|
-
"tool_gated",
|
|
33
|
-
"signal_delivery_disposed",
|
|
34
|
-
"budget_exceeded",
|
|
35
|
-
"budget_usage_reported",
|
|
36
|
-
"operation_cancelled",
|
|
37
|
-
"milestone_advanced",
|
|
38
|
-
"milestone_blocked",
|
|
39
|
-
"checkpoint_taken",
|
|
40
|
-
"entropy_sample",
|
|
41
|
-
"entropy_alert",
|
|
42
|
-
"agent_process_changed",
|
|
43
|
-
"memory_written",
|
|
44
|
-
"memory_queried",
|
|
45
|
-
"memory_validation_failed",
|
|
46
|
-
"memory_write_failed",
|
|
47
|
-
"memory_query_failed",
|
|
48
|
-
"memory_retrieval_result",
|
|
49
|
-
"workflow_node_completed",
|
|
50
|
-
"workflow_nodes_submitted",
|
|
51
|
-
"workflow_batch_spawned",
|
|
52
|
-
"workflow_completed",
|
|
53
|
-
"kernel_observation",
|
|
54
|
-
"run_terminal",
|
|
55
|
-
"summary_upgraded",
|
|
56
|
-
"group_member_joined",
|
|
57
|
-
"group_budget_charged",
|
|
58
|
-
"round_started",
|
|
59
|
-
"round_paced",
|
|
60
|
-
];
|
|
61
|
-
const _vocabularyCoversUnion = true;
|
|
62
|
-
void _vocabularyCoversUnion;
|
|
11
|
+
export const SESSION_EVENT_KINDS = REGISTERED_SESSION_EVENT_KINDS;
|
|
12
|
+
export { SESSION_EVENT_REGISTRY };
|
|
13
|
+
const _sessionEventRegistryInLockstep = true;
|
|
14
|
+
void _sessionEventRegistryInLockstep;
|
|
63
15
|
/**
|
|
64
16
|
* **Single-isolate dev/test implementation** of both capabilities (spec §9.4: one class may
|
|
65
17
|
* implement several capabilities; the *interfaces* stay separate). Its `KernelJournal` half is
|
|
@@ -45,9 +45,6 @@ export declare function buildWorkflowNodeCompletedEvent(input: {
|
|
|
45
45
|
agentId: string;
|
|
46
46
|
status: WorkflowNodeStatus;
|
|
47
47
|
termination: string;
|
|
48
|
-
classifyBranch?: string;
|
|
49
|
-
tournamentWinner?: string;
|
|
50
|
-
loopContinue?: boolean;
|
|
51
48
|
output?: ModelMessage;
|
|
52
49
|
}): Extract<SessionEvent, {
|
|
53
50
|
kind: "workflow_node_completed";
|
|
@@ -58,9 +58,6 @@ export function buildWorkflowNodeCompletedEvent(input) {
|
|
|
58
58
|
agent_id: input.agentId,
|
|
59
59
|
status: input.status,
|
|
60
60
|
termination: input.termination,
|
|
61
|
-
...(input.classifyBranch !== undefined ? { classify_branch: input.classifyBranch } : {}),
|
|
62
|
-
...(input.tournamentWinner !== undefined ? { tournament_winner: input.tournamentWinner } : {}),
|
|
63
|
-
...(input.loopContinue !== undefined ? { loop_continue: input.loopContinue } : {}),
|
|
64
61
|
...(input.output ? { output: input.output } : {}),
|
|
65
62
|
};
|
|
66
63
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { AgentRunSpec, AgentProcessChangedObservation, SubAgentResult } from "./types/agent.js";
|
|
1
|
+
import type { AgentRunSpec, AgentProcessChangedObservation, SubAgentResult, InheritedKnowledge } from "./types/agent.js";
|
|
2
2
|
import type { RuntimeOptions } from "./runner.js";
|
|
3
3
|
import type { SessionLog } from "./session-log.js";
|
|
4
4
|
export interface SubAgentRunContext {
|
|
@@ -20,6 +20,10 @@ export interface SubAgentRunContext {
|
|
|
20
20
|
/** #2-B-ii: parent-controlled abort — when the kernel preempts this node (`AgentPreempted`), the
|
|
21
21
|
* orchestrator interrupts the child runner, cancelling its in-flight LLM call. */
|
|
22
22
|
abortSignal?: AbortSignal;
|
|
23
|
+
/** Plan task 3.1 · the outputs of the workflow nodes this child depends on, by agent id. */
|
|
24
|
+
dependencyOutputs?: Record<string, string>;
|
|
25
|
+
/** Plan task 1.1 · the parent knowledge the kernel lets this child inherit. */
|
|
26
|
+
inheritedKnowledge?: InheritedKnowledge[];
|
|
23
27
|
}
|
|
24
28
|
/** M1/G3 intelligence routing: resolve the provider for a sub-agent from its spec's `modelHint`.
|
|
25
29
|
* Falls back to the parent provider when there is no hint or no `providerFor` hook resolves it. */
|
|
@@ -126,6 +126,10 @@ export class SubAgentOrchestrator {
|
|
|
126
126
|
runSpec: ctx.spec.loopRound
|
|
127
127
|
? { identity: ctx.spec.identity, role: ctx.spec.role, goal: ctx.spec.goal, loopRound: ctx.spec.loopRound }
|
|
128
128
|
: undefined,
|
|
129
|
+
// A child reads only its own dependencies, never ones inherited from the parent's options.
|
|
130
|
+
dependencyOutputs: ctx.dependencyOutputs,
|
|
131
|
+
// Likewise only the knowledge the kernel chose for this child, never the parent's own.
|
|
132
|
+
inheritedKnowledge: ctx.inheritedKnowledge,
|
|
129
133
|
});
|
|
130
134
|
// #2-B-ii: parent preempt → interrupt the child (cancels its in-flight LLM call).
|
|
131
135
|
linkAbort(ctx.abortSignal, childRunner);
|