@picassohq/cli 1.0.4 → 1.0.5
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/build-info.json +2 -1
- package/dist/index.js +1557 -1353
- package/package.json +1 -1
- package/runtime/dsh/picasso-ecosystem.cordis.patch.yml +4 -7
- package/runtime/dsh/picasso-sdk.patch.yml +47 -0
- package/runtime/engine-manifest.json +20 -10
- package/runtime/packages/picasso-compaction/index.js +257 -5
- package/runtime/packages/picasso-hooks/cordis.patch.yml +4 -0
- package/runtime/packages/picasso-hooks/index.js +302 -0
- package/runtime/packages/picasso-hooks/lifecycle-events.js +651 -0
- package/runtime/packages/picasso-hooks/package.json +29 -0
- package/runtime/packages/picasso-lean-context/glob-walk.js +518 -0
- package/runtime/packages/picasso-lean-context/index.js +136 -9
- package/runtime/packages/picasso-memory/index.js +66 -24
- package/runtime/packages/picasso-model-router/connections.js +164 -7
- package/runtime/packages/picasso-model-router/index.js +97 -1
- package/runtime/packages/picasso-model-router/thinking-default.js +29 -5
- package/runtime/packages/picasso-progress-reports/index.js +128 -18
- package/runtime/packages/picasso-sdk-server/command-runs.js +37 -0
- package/runtime/packages/picasso-sdk-server/ignore-file.js +5 -1
- package/runtime/packages/picasso-sdk-server/index.js +11 -3
- package/runtime/packages/picasso-sdk-server/package.json +1 -0
- package/runtime/packages/picasso-sdk-server/wave2-hooks.js +26 -6
- package/runtime/packages/picasso-x-reader/settings.js +4 -1
- package/runtime/plugins/picasso-auto-approve/index.js +21 -8
- package/runtime/plugins/picasso-compaction/index.js +257 -5
- package/runtime/plugins/picasso-hooks/index.js +302 -0
- package/runtime/plugins/picasso-hooks/lifecycle-events.js +651 -0
- package/runtime/plugins/picasso-hooks/package.json +29 -0
- package/runtime/plugins/picasso-lean-context/glob-walk.js +518 -0
- package/runtime/plugins/picasso-lean-context/index.js +136 -9
- package/runtime/plugins/picasso-memory/index.js +66 -24
- package/runtime/plugins/picasso-model-router/connections.js +164 -7
- package/runtime/plugins/picasso-model-router/index.js +97 -1
- package/runtime/plugins/picasso-model-router/thinking-default.js +29 -5
- package/runtime/plugins/picasso-progress-reports/index.js +128 -18
- package/runtime/plugins/picasso-trackers/index.js +12 -2
- package/runtime/plugins/picasso-x-reader/settings.js +4 -1
- package/runtime/relay/main.mjs +2254 -1648
- package/runtime/relay/versions-routes.mjs +24 -20
|
@@ -0,0 +1,651 @@
|
|
|
1
|
+
// The dsh runtime lifecycle vocabulary for @picasso/picasso-hooks-bridge.
|
|
2
|
+
//
|
|
3
|
+
// Every entry below names an event the pinned runtime (dsh 0.2.1-rc.5,
|
|
4
|
+
// contract DSH_CONTRACT_VERSION 2026-10-21.1) actually dispatches through the
|
|
5
|
+
// cordis event bus or commits to the session log. Verified against
|
|
6
|
+
// `node_modules/@deepseek-ai/dsh/node_modules/@deepseek-ai/dsh-*/lib/index.js`
|
|
7
|
+
// dispatch sites — never invent a name that nothing emits.
|
|
8
|
+
//
|
|
9
|
+
// `dispatch` is how the runtime delivers the event, which decides what a hook
|
|
10
|
+
// may reply:
|
|
11
|
+
//
|
|
12
|
+
// waterfall — listeners get (…args, next); not calling `next()` vetoes
|
|
13
|
+
// the chain (including the built-in). The listener's return
|
|
14
|
+
// value IS the pipeline's decision, so allow|deny|modify|steer
|
|
15
|
+
// all apply. THE interceptable kind.
|
|
16
|
+
// serial — listeners run in order and are awaited; no `next`, and the
|
|
17
|
+
// return value only bails later listeners. A hook reply can
|
|
18
|
+
// `steer` (the payload carries the live agent) but cannot
|
|
19
|
+
// deny or modify.
|
|
20
|
+
// parallel — listeners run concurrently and are awaited; no decision.
|
|
21
|
+
// Observe-only (the reply channel is ignored).
|
|
22
|
+
// emit — fire-and-forget broadcast. Observe-only.
|
|
23
|
+
// session-event — a session-log event type, observed through `session/event`.
|
|
24
|
+
// Observe-only.
|
|
25
|
+
//
|
|
26
|
+
// `decisions` lists which replies the bridge honors at that point; a reply a
|
|
27
|
+
// point does not support is warned and treated as allow. See HOOKS.md.
|
|
28
|
+
|
|
29
|
+
export const HOOK_DECISIONS = ['allow', 'deny', 'modify', 'steer'];
|
|
30
|
+
|
|
31
|
+
const GATE = ['allow', 'deny', 'modify', 'steer'];
|
|
32
|
+
const OBSERVE = [];
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Every ctx.on-addressable point the runtime dispatches, grouped by subsystem.
|
|
36
|
+
* `internal: true` marks cordis plumbing that exists but is not agent
|
|
37
|
+
* lifecycle; `hot: true` marks events that fire per-token/per-event (a shell
|
|
38
|
+
* hook there runs per occurrence — expensive).
|
|
39
|
+
*/
|
|
40
|
+
export const LIFECYCLE_EVENTS = [
|
|
41
|
+
// ── tools — the call pipeline (dsh-tools) ────────────────────────────────
|
|
42
|
+
{
|
|
43
|
+
name: 'tools/pre-execute', category: 'tools', dispatch: 'waterfall',
|
|
44
|
+
interceptable: true, decisions: GATE,
|
|
45
|
+
fires: 'Before a tool call is dispatched; the gate decision {kind:"allow"|"deny"|"ask"|"cancel"} decides whether it runs.',
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
name: 'tools/execute', category: 'tools', dispatch: 'waterfall',
|
|
49
|
+
interceptable: true, decisions: GATE,
|
|
50
|
+
fires: 'Around the tool body itself; the returned value becomes the tool result (skipping next replaces the dispatch).',
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
name: 'tools/post-execute', category: 'tools', dispatch: 'waterfall',
|
|
54
|
+
interceptable: true, decisions: GATE,
|
|
55
|
+
fires: 'After a tool result is produced; "accept" may replace content/value, "block" turns it into a corrective isError.',
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
name: 'tools/ptc-dispatch-log', category: 'tools', dispatch: 'waterfall',
|
|
59
|
+
interceptable: true, decisions: GATE,
|
|
60
|
+
fires: 'When a PTC workflow dispatch logs; the returned value becomes the logged content.',
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
name: 'tools/result', category: 'tools', dispatch: 'emit',
|
|
64
|
+
interceptable: false, decisions: OBSERVE,
|
|
65
|
+
fires: 'Once per committed tool result (exec is frozen); the canonical post-call observation point.',
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
name: 'tools/change', category: 'tools', dispatch: 'emit',
|
|
69
|
+
interceptable: false, decisions: OBSERVE,
|
|
70
|
+
fires: "When the session's tool catalog changes (a tool layer is added or removed).",
|
|
71
|
+
},
|
|
72
|
+
|
|
73
|
+
// ── agent — the running turn (dsh-agent / dsh-agent-loop) ────────────────
|
|
74
|
+
{
|
|
75
|
+
name: 'agent/pre-step', category: 'agent', dispatch: 'waterfall',
|
|
76
|
+
interceptable: true, decisions: GATE,
|
|
77
|
+
fires: 'Before each model step; {kind:"enter",messages} runs it, {kind:"reject"} blocks the turn as "blocked". Payload carries agent.',
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
name: 'agent/request', category: 'agent', dispatch: 'waterfall',
|
|
81
|
+
interceptable: true, decisions: GATE,
|
|
82
|
+
fires: 'When the per-step request config is proposed; the return replaces {provider,model,reasoningEffort?,maxTokens?}.',
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
name: 'agent/request-error', category: 'agent', dispatch: 'waterfall',
|
|
86
|
+
interceptable: true, decisions: ['allow', 'modify', 'steer'],
|
|
87
|
+
fires: 'When a model request finishes in error; reply {kind:"retry"} (via modify) to retry, otherwise the error propagates.',
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
name: 'agent/turn-stopping', category: 'agent', dispatch: 'serial',
|
|
91
|
+
interceptable: false, decisions: ['steer'],
|
|
92
|
+
fires: 'When a turn is about to stop with an empty next-step inbox; a steer reply injects a message and keeps the turn alive.',
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
name: 'agent/created', category: 'agent', dispatch: 'serial',
|
|
96
|
+
interceptable: false, decisions: ['steer'],
|
|
97
|
+
fires: 'After an agent is constructed and registered, before its first turn.',
|
|
98
|
+
},
|
|
99
|
+
{
|
|
100
|
+
name: 'agent/disposed', category: 'agent', dispatch: 'emit',
|
|
101
|
+
interceptable: false, decisions: OBSERVE,
|
|
102
|
+
fires: 'When an agent is disposed (session end, cancel cleanup, owner unload).',
|
|
103
|
+
},
|
|
104
|
+
{
|
|
105
|
+
name: 'agent/status', category: 'agent', dispatch: 'emit',
|
|
106
|
+
interceptable: false, decisions: OBSERVE,
|
|
107
|
+
fires: 'When the agent\'s running/idle status flips. Payload: {agent,status}.',
|
|
108
|
+
},
|
|
109
|
+
{
|
|
110
|
+
name: 'agent/error', category: 'agent', dispatch: 'emit',
|
|
111
|
+
interceptable: false, decisions: OBSERVE,
|
|
112
|
+
fires: 'When the agent loop records a failure. Payload: {agent,error}.',
|
|
113
|
+
},
|
|
114
|
+
{
|
|
115
|
+
name: 'agent/assistant-stream', category: 'agent', dispatch: 'emit', hot: true,
|
|
116
|
+
interceptable: false, decisions: OBSERVE,
|
|
117
|
+
fires: 'Per assistant stream frame — extremely frequent. Payload: {agent,frame}.',
|
|
118
|
+
},
|
|
119
|
+
{
|
|
120
|
+
name: 'agent/inbox/claimed', category: 'agent', dispatch: 'emit', hot: true,
|
|
121
|
+
interceptable: false, decisions: OBSERVE,
|
|
122
|
+
fires: 'When pending input is claimed into a step.',
|
|
123
|
+
},
|
|
124
|
+
{
|
|
125
|
+
name: 'agent/inbox/inserted', category: 'agent', dispatch: 'emit', hot: true,
|
|
126
|
+
interceptable: false, decisions: OBSERVE,
|
|
127
|
+
fires: 'When a message is spliced into the agent inbox.',
|
|
128
|
+
},
|
|
129
|
+
{
|
|
130
|
+
name: 'agent/inbox/discarded', category: 'agent', dispatch: 'emit', hot: true,
|
|
131
|
+
interceptable: false, decisions: OBSERVE,
|
|
132
|
+
fires: 'When a queued inbox message is discarded.',
|
|
133
|
+
},
|
|
134
|
+
|
|
135
|
+
// ── session — attach/log/teardown (dsh-session) ──────────────────────────
|
|
136
|
+
{
|
|
137
|
+
name: 'session/created', category: 'session', dispatch: 'emit',
|
|
138
|
+
interceptable: false, decisions: OBSERVE,
|
|
139
|
+
fires: 'Exactly once when a session is announced after attach (the real session-start signal).',
|
|
140
|
+
},
|
|
141
|
+
{
|
|
142
|
+
name: 'session/event', category: 'session', dispatch: 'emit', hot: true,
|
|
143
|
+
interceptable: false, decisions: OBSERVE,
|
|
144
|
+
fires: 'Every event committed to the session log, as (session, event) — the umbrella over all session-log types below.',
|
|
145
|
+
},
|
|
146
|
+
{
|
|
147
|
+
name: 'session/disposed', category: 'session', dispatch: 'emit',
|
|
148
|
+
interceptable: false, decisions: OBSERVE,
|
|
149
|
+
fires: 'When a session is torn down (the real session-end signal).',
|
|
150
|
+
},
|
|
151
|
+
{
|
|
152
|
+
name: 'session/flush', category: 'session', dispatch: 'parallel',
|
|
153
|
+
interceptable: false, decisions: OBSERVE,
|
|
154
|
+
fires: 'The awaited durability checkpoint — persistence plugins drain here.',
|
|
155
|
+
},
|
|
156
|
+
|
|
157
|
+
// ── llm — model stream (dsh-llm) ─────────────────────────────────────────
|
|
158
|
+
{
|
|
159
|
+
name: 'llm/stream', category: 'llm', dispatch: 'waterfall',
|
|
160
|
+
interceptable: true, decisions: GATE,
|
|
161
|
+
fires: 'Around every model stream call; the return replaces (or wraps) the adapter stream.',
|
|
162
|
+
},
|
|
163
|
+
|
|
164
|
+
// ── system prompt (dsh-system-prompt) ────────────────────────────────────
|
|
165
|
+
{
|
|
166
|
+
name: 'system-prompt/assemble', category: 'llm', dispatch: 'waterfall',
|
|
167
|
+
interceptable: true, decisions: GATE,
|
|
168
|
+
fires: 'After the system prompt assembly is built, before it is used; the return replaces the assembly.',
|
|
169
|
+
},
|
|
170
|
+
{
|
|
171
|
+
name: 'system-prompt/change', category: 'llm', dispatch: 'emit',
|
|
172
|
+
interceptable: false, decisions: OBSERVE,
|
|
173
|
+
fires: 'When the effective system prompt changes between steps.',
|
|
174
|
+
},
|
|
175
|
+
|
|
176
|
+
// ── filesystem intents (dsh-tool-fs / str-replace-editor) ────────────────
|
|
177
|
+
{
|
|
178
|
+
name: 'fs/write-intent', category: 'fs', dispatch: 'waterfall',
|
|
179
|
+
interceptable: true, decisions: GATE,
|
|
180
|
+
fires: 'Before a write tool touches the file; the return sets the write intent (e.g. createIfAbsent).',
|
|
181
|
+
},
|
|
182
|
+
{
|
|
183
|
+
name: 'fs/edit-intent', category: 'fs', dispatch: 'waterfall',
|
|
184
|
+
interceptable: true, decisions: GATE,
|
|
185
|
+
fires: 'Before an edit tool touches the file; the return sets the edit intent.',
|
|
186
|
+
},
|
|
187
|
+
{
|
|
188
|
+
name: 'fs/observed', category: 'fs', dispatch: 'emit', hot: true,
|
|
189
|
+
interceptable: false, decisions: OBSERVE,
|
|
190
|
+
fires: 'When a filesystem observation (read/write) is recorded, as (target, observation).',
|
|
191
|
+
},
|
|
192
|
+
|
|
193
|
+
// ── compaction (dsh-compaction-basic) ────────────────────────────────────
|
|
194
|
+
{
|
|
195
|
+
name: 'compaction/summary-error', category: 'compaction', dispatch: 'waterfall',
|
|
196
|
+
interceptable: true, decisions: ['allow', 'deny', 'modify'],
|
|
197
|
+
fires: 'When compaction summarization throws; the return is the recovery decision (default false = no recovery).',
|
|
198
|
+
},
|
|
199
|
+
|
|
200
|
+
// ── approvals and questions (dsh-user-approval / dsh-user-questions) ─────
|
|
201
|
+
{
|
|
202
|
+
name: 'approval/request', category: 'approval', dispatch: 'waterfall',
|
|
203
|
+
interceptable: true, decisions: GATE,
|
|
204
|
+
fires: 'When a tool call needs an approval decision; the return is "allowed-once"|"rejected"|"cancelled"|"unavailable".',
|
|
205
|
+
},
|
|
206
|
+
{
|
|
207
|
+
name: 'user-questions/request', category: 'approval', dispatch: 'waterfall',
|
|
208
|
+
interceptable: true, decisions: GATE,
|
|
209
|
+
fires: 'When the ask-user tool needs answers; the return supplies them.',
|
|
210
|
+
},
|
|
211
|
+
|
|
212
|
+
// ── workspace (dsh-workspace / dsh-workspace-changes) ────────────────────
|
|
213
|
+
{
|
|
214
|
+
name: 'workspace/session-activity', category: 'workspace', dispatch: 'waterfall',
|
|
215
|
+
interceptable: true, decisions: ['allow', 'deny', 'modify'],
|
|
216
|
+
fires: 'When the workspace registry asks what a session is doing; the return extends the activity list.',
|
|
217
|
+
},
|
|
218
|
+
{
|
|
219
|
+
name: 'workspace/session-stop', category: 'workspace', dispatch: 'parallel',
|
|
220
|
+
interceptable: false, decisions: OBSERVE,
|
|
221
|
+
fires: 'When a session stops using a workspace; awaited fan-out.',
|
|
222
|
+
},
|
|
223
|
+
{
|
|
224
|
+
name: 'domain/changed', category: 'workspace', dispatch: 'emit',
|
|
225
|
+
interceptable: false, decisions: OBSERVE,
|
|
226
|
+
fires: 'When a workspace domain changes.',
|
|
227
|
+
},
|
|
228
|
+
|
|
229
|
+
// ── telemetry (dsh-session-telemetry) ────────────────────────────────────
|
|
230
|
+
{
|
|
231
|
+
name: 'session-telemetry/record', category: 'platform', dispatch: 'waterfall',
|
|
232
|
+
interceptable: true, decisions: ['allow', 'deny', 'modify'],
|
|
233
|
+
fires: 'When a telemetry record is about to be stored; the return replaces the record.',
|
|
234
|
+
},
|
|
235
|
+
|
|
236
|
+
// ── web ingress (dsh-client-connection) ──────────────────────────────────
|
|
237
|
+
{
|
|
238
|
+
name: 'connection/request', category: 'platform', dispatch: 'waterfall',
|
|
239
|
+
interceptable: true, decisions: ['allow', 'deny', 'modify'],
|
|
240
|
+
fires: 'Around each inbound HTTP request to the web server; skipping next vetoes the built-in handler.',
|
|
241
|
+
},
|
|
242
|
+
{
|
|
243
|
+
name: 'connection/reset', category: 'platform', dispatch: 'emit',
|
|
244
|
+
interceptable: false, decisions: OBSERVE,
|
|
245
|
+
fires: 'When the API gateway connection resets.',
|
|
246
|
+
},
|
|
247
|
+
|
|
248
|
+
// ── workflows (dsh-workflow-ptc — explicitly observe-only upstream) ──────
|
|
249
|
+
{
|
|
250
|
+
name: 'workflow/start', category: 'workflow', dispatch: 'emit',
|
|
251
|
+
interceptable: false, decisions: OBSERVE,
|
|
252
|
+
fires: 'When a PTC workflow run starts.',
|
|
253
|
+
},
|
|
254
|
+
{
|
|
255
|
+
name: 'workflow/end', category: 'workflow', dispatch: 'emit',
|
|
256
|
+
interceptable: false, decisions: OBSERVE,
|
|
257
|
+
fires: 'When a PTC workflow run settles (stopReason, error?, agentsStarted).',
|
|
258
|
+
},
|
|
259
|
+
{
|
|
260
|
+
name: 'workflow/phase', category: 'workflow', dispatch: 'emit',
|
|
261
|
+
interceptable: false, decisions: OBSERVE,
|
|
262
|
+
fires: 'When a workflow run enters a named phase.',
|
|
263
|
+
},
|
|
264
|
+
{
|
|
265
|
+
name: 'workflow/log', category: 'workflow', dispatch: 'emit', hot: true,
|
|
266
|
+
interceptable: false, decisions: OBSERVE,
|
|
267
|
+
fires: 'Per workflow log line.',
|
|
268
|
+
},
|
|
269
|
+
{
|
|
270
|
+
name: 'workflow/agent-start', category: 'workflow', dispatch: 'emit',
|
|
271
|
+
interceptable: false, decisions: OBSERVE,
|
|
272
|
+
fires: 'When a workflow spawns a sub-agent run.',
|
|
273
|
+
},
|
|
274
|
+
{
|
|
275
|
+
name: 'workflow/agent-end', category: 'workflow', dispatch: 'emit',
|
|
276
|
+
interceptable: false, decisions: OBSERVE,
|
|
277
|
+
fires: 'When a workflow sub-agent run finishes.',
|
|
278
|
+
},
|
|
279
|
+
|
|
280
|
+
// ── goals / subagents / presets / schedule ───────────────────────────────
|
|
281
|
+
{
|
|
282
|
+
name: 'goal/changed', category: 'goal', dispatch: 'emit',
|
|
283
|
+
interceptable: false, decisions: OBSERVE,
|
|
284
|
+
fires: 'When a session\'s goal state changes (scoped to the agent\'s context).',
|
|
285
|
+
},
|
|
286
|
+
{
|
|
287
|
+
name: 'goal/activation-changed', category: 'goal', dispatch: 'emit',
|
|
288
|
+
interceptable: false, decisions: OBSERVE,
|
|
289
|
+
fires: 'When a goal is armed/disarmed on a session.',
|
|
290
|
+
},
|
|
291
|
+
{
|
|
292
|
+
name: 'subagent/provider-added', category: 'subagent', dispatch: 'emit',
|
|
293
|
+
interceptable: false, decisions: OBSERVE,
|
|
294
|
+
fires: 'When a subagent spawn provider registers.',
|
|
295
|
+
},
|
|
296
|
+
{
|
|
297
|
+
name: 'agent-preset/selected', category: 'agent', dispatch: 'emit',
|
|
298
|
+
interceptable: false, decisions: OBSERVE,
|
|
299
|
+
fires: 'When an agent preset is selected for a session, as (sessionId, preset).',
|
|
300
|
+
},
|
|
301
|
+
{
|
|
302
|
+
name: 'schedule/changed', category: 'platform', dispatch: 'emit',
|
|
303
|
+
interceptable: false, decisions: OBSERVE,
|
|
304
|
+
fires: 'When the schedule registry changes.',
|
|
305
|
+
},
|
|
306
|
+
{
|
|
307
|
+
name: 'feedback/committed', category: 'session', dispatch: 'parallel',
|
|
308
|
+
interceptable: false, decisions: OBSERVE,
|
|
309
|
+
fires: 'When session feedback is committed; awaited fan-out.',
|
|
310
|
+
},
|
|
311
|
+
|
|
312
|
+
// ── platform plumbing (exist, but not agent lifecycle) ───────────────────
|
|
313
|
+
{
|
|
314
|
+
name: 'api-session/added', category: 'platform', dispatch: 'emit',
|
|
315
|
+
interceptable: false, decisions: OBSERVE,
|
|
316
|
+
fires: 'When the API session controller publishes a session to clients.',
|
|
317
|
+
},
|
|
318
|
+
{
|
|
319
|
+
name: 'api-session/removed', category: 'platform', dispatch: 'emit',
|
|
320
|
+
interceptable: false, decisions: OBSERVE,
|
|
321
|
+
fires: 'When the API session controller removes a published session.',
|
|
322
|
+
},
|
|
323
|
+
{
|
|
324
|
+
name: 'api-session/status', category: 'platform', dispatch: 'emit', hot: true,
|
|
325
|
+
interceptable: false, decisions: OBSERVE,
|
|
326
|
+
fires: 'When a published session\'s running status flips.',
|
|
327
|
+
},
|
|
328
|
+
{
|
|
329
|
+
name: 'api-session/error', category: 'platform', dispatch: 'emit',
|
|
330
|
+
interceptable: false, decisions: OBSERVE,
|
|
331
|
+
fires: 'When a published session reports an error to clients.',
|
|
332
|
+
},
|
|
333
|
+
{
|
|
334
|
+
name: 'api-session/activity', category: 'platform', dispatch: 'emit', hot: true,
|
|
335
|
+
interceptable: false, decisions: OBSERVE,
|
|
336
|
+
fires: 'Per session event time reported to clients.',
|
|
337
|
+
},
|
|
338
|
+
{
|
|
339
|
+
name: 'settings/document-updated', category: 'platform', dispatch: 'emit',
|
|
340
|
+
interceptable: false, decisions: OBSERVE,
|
|
341
|
+
fires: 'When a settings document changes.',
|
|
342
|
+
},
|
|
343
|
+
{
|
|
344
|
+
name: 'app-boot/config-reload', category: 'platform', dispatch: 'emit',
|
|
345
|
+
interceptable: false, decisions: OBSERVE,
|
|
346
|
+
fires: 'When the boot config reloads.',
|
|
347
|
+
},
|
|
348
|
+
{
|
|
349
|
+
name: 'credentials/record-updated', category: 'platform', dispatch: 'emit',
|
|
350
|
+
interceptable: false, decisions: OBSERVE,
|
|
351
|
+
fires: 'When a credential record is updated.',
|
|
352
|
+
},
|
|
353
|
+
{
|
|
354
|
+
name: 'deepseek-account/session-expired', category: 'platform', dispatch: 'emit',
|
|
355
|
+
interceptable: false, decisions: OBSERVE,
|
|
356
|
+
fires: 'When the DeepSeek account session expires.',
|
|
357
|
+
},
|
|
358
|
+
{
|
|
359
|
+
name: 'deepseek-account/signed-out', category: 'platform', dispatch: 'emit',
|
|
360
|
+
interceptable: false, decisions: OBSERVE,
|
|
361
|
+
fires: 'When the DeepSeek account signs out.',
|
|
362
|
+
},
|
|
363
|
+
{
|
|
364
|
+
name: 'deepseek-account/model-sign-in-required', category: 'platform', dispatch: 'emit',
|
|
365
|
+
interceptable: false, decisions: OBSERVE,
|
|
366
|
+
fires: 'When a model route requires sign-in.',
|
|
367
|
+
},
|
|
368
|
+
{
|
|
369
|
+
name: 'loader/volatile-update', category: 'platform', dispatch: 'emit',
|
|
370
|
+
interceptable: false, decisions: OBSERVE,
|
|
371
|
+
fires: 'When the plugin loader reports a volatile (in-memory) plugin change.',
|
|
372
|
+
},
|
|
373
|
+
{
|
|
374
|
+
name: 'loader/config-update', category: 'platform', dispatch: 'emit',
|
|
375
|
+
interceptable: false, decisions: OBSERVE,
|
|
376
|
+
fires: 'When the plugin loader reports a config update.',
|
|
377
|
+
},
|
|
378
|
+
{
|
|
379
|
+
name: 'loader/patch-context', category: 'platform', dispatch: 'waterfall',
|
|
380
|
+
interceptable: true, decisions: ['allow', 'deny', 'modify'],
|
|
381
|
+
fires: 'Around plugin context patching at load time (plugin-loader internal).',
|
|
382
|
+
},
|
|
383
|
+
{
|
|
384
|
+
name: 'plugin-manager/install-state', category: 'platform', dispatch: 'emit',
|
|
385
|
+
interceptable: false, decisions: OBSERVE,
|
|
386
|
+
fires: 'Per install-request phase transition in the plugin manager.',
|
|
387
|
+
},
|
|
388
|
+
{
|
|
389
|
+
name: 'plugin-manager/install-log', category: 'platform', dispatch: 'emit', hot: true,
|
|
390
|
+
interceptable: false, decisions: OBSERVE,
|
|
391
|
+
fires: 'Per install log line in the plugin manager.',
|
|
392
|
+
},
|
|
393
|
+
{
|
|
394
|
+
name: 'plugin-manager/changed', category: 'platform', dispatch: 'emit',
|
|
395
|
+
interceptable: false, decisions: OBSERVE,
|
|
396
|
+
fires: 'When the installed plugin set changes.',
|
|
397
|
+
},
|
|
398
|
+
{
|
|
399
|
+
name: 'plugin-market/changed', category: 'platform', dispatch: 'emit',
|
|
400
|
+
interceptable: false, decisions: OBSERVE,
|
|
401
|
+
fires: 'When the plugin market index changes.',
|
|
402
|
+
},
|
|
403
|
+
{
|
|
404
|
+
name: 'theme/change', category: 'platform', dispatch: 'emit',
|
|
405
|
+
interceptable: false, decisions: OBSERVE,
|
|
406
|
+
fires: 'When the client theme changes.',
|
|
407
|
+
},
|
|
408
|
+
{
|
|
409
|
+
name: 'locale/change', category: 'platform', dispatch: 'emit',
|
|
410
|
+
interceptable: false, decisions: OBSERVE,
|
|
411
|
+
fires: 'When the client locale changes.',
|
|
412
|
+
},
|
|
413
|
+
{
|
|
414
|
+
name: 'hmr/change', category: 'platform', dispatch: 'emit',
|
|
415
|
+
interceptable: false, decisions: OBSERVE,
|
|
416
|
+
fires: 'When a hot-reloadable module changes.',
|
|
417
|
+
},
|
|
418
|
+
{
|
|
419
|
+
name: 'hmr/reload', category: 'platform', dispatch: 'emit',
|
|
420
|
+
interceptable: false, decisions: OBSERVE,
|
|
421
|
+
fires: 'When a hot reload executes.',
|
|
422
|
+
},
|
|
423
|
+
{
|
|
424
|
+
name: 'slots/changed', category: 'platform', dispatch: 'emit',
|
|
425
|
+
interceptable: false, decisions: OBSERVE,
|
|
426
|
+
fires: 'When UI slot assignments change.',
|
|
427
|
+
},
|
|
428
|
+
{
|
|
429
|
+
name: 'webserver/index-inject', category: 'platform', dispatch: 'emit',
|
|
430
|
+
interceptable: false, decisions: OBSERVE,
|
|
431
|
+
fires: 'When the web server builds its index-injection table.',
|
|
432
|
+
},
|
|
433
|
+
{
|
|
434
|
+
name: 'cordis/request-run', category: 'internal', dispatch: 'emit', internal: true,
|
|
435
|
+
interceptable: false, decisions: OBSERVE,
|
|
436
|
+
fires: 'When the cordis host runner accepts a request run.',
|
|
437
|
+
},
|
|
438
|
+
{
|
|
439
|
+
name: 'cordis/request-run-resolved', category: 'internal', dispatch: 'emit', internal: true,
|
|
440
|
+
interceptable: false, decisions: OBSERVE,
|
|
441
|
+
fires: 'When a host-runner request run resolves.',
|
|
442
|
+
},
|
|
443
|
+
{
|
|
444
|
+
name: 'cordis/inspect-query', category: 'internal', dispatch: 'emit', internal: true,
|
|
445
|
+
interceptable: false, decisions: OBSERVE,
|
|
446
|
+
fires: 'When the host inspector receives a query.',
|
|
447
|
+
},
|
|
448
|
+
{
|
|
449
|
+
name: 'cordis/inspect-query-resolved', category: 'internal', dispatch: 'emit', internal: true,
|
|
450
|
+
interceptable: false, decisions: OBSERVE,
|
|
451
|
+
fires: 'When a host inspector query resolves.',
|
|
452
|
+
},
|
|
453
|
+
{
|
|
454
|
+
name: 'cordis/dynamic-package', category: 'internal', dispatch: 'emit', internal: true,
|
|
455
|
+
interceptable: false, decisions: OBSERVE,
|
|
456
|
+
fires: 'When the host runner registers a dynamic package.',
|
|
457
|
+
},
|
|
458
|
+
{
|
|
459
|
+
name: 'cordis/dynamic-retract', category: 'internal', dispatch: 'emit', internal: true,
|
|
460
|
+
interceptable: false, decisions: OBSERVE,
|
|
461
|
+
fires: 'When the host runner retracts a dynamic package.',
|
|
462
|
+
},
|
|
463
|
+
|
|
464
|
+
// ── cordis internals — the plugin framework's own plumbing ───────────────
|
|
465
|
+
{
|
|
466
|
+
name: 'internal/get', category: 'internal', dispatch: 'waterfall', internal: true,
|
|
467
|
+
interceptable: true, decisions: ['allow', 'deny', 'modify'],
|
|
468
|
+
fires: 'Around every service property access on a context (cordis service proxy).',
|
|
469
|
+
},
|
|
470
|
+
{
|
|
471
|
+
name: 'internal/set', category: 'internal', dispatch: 'waterfall', internal: true,
|
|
472
|
+
interceptable: true, decisions: ['allow', 'deny', 'modify'],
|
|
473
|
+
fires: 'Around every service property assignment on a context.',
|
|
474
|
+
},
|
|
475
|
+
{
|
|
476
|
+
name: 'internal/config', category: 'internal', dispatch: 'waterfall', internal: true,
|
|
477
|
+
interceptable: true, decisions: ['allow', 'deny', 'modify'],
|
|
478
|
+
fires: 'When a plugin\'s config resolves at load time.',
|
|
479
|
+
},
|
|
480
|
+
{
|
|
481
|
+
name: 'internal/update', category: 'internal', dispatch: 'waterfall', internal: true,
|
|
482
|
+
interceptable: true, decisions: ['allow', 'deny', 'modify'],
|
|
483
|
+
fires: 'Before a plugin config update applies (and its reload).',
|
|
484
|
+
},
|
|
485
|
+
{
|
|
486
|
+
name: 'internal/listener', category: 'internal', dispatch: 'bail', internal: true,
|
|
487
|
+
interceptable: false, decisions: OBSERVE,
|
|
488
|
+
fires: 'Whenever a listener registers on any event.',
|
|
489
|
+
},
|
|
490
|
+
{
|
|
491
|
+
name: 'internal/dispatch', category: 'internal', dispatch: 'emit', internal: true, hot: true,
|
|
492
|
+
interceptable: false, decisions: OBSERVE,
|
|
493
|
+
fires: 'On every non-internal event dispatch — the hottest event in the runtime.',
|
|
494
|
+
},
|
|
495
|
+
{
|
|
496
|
+
name: 'internal/plugin', category: 'internal', dispatch: 'emit', internal: true,
|
|
497
|
+
interceptable: false, decisions: OBSERVE,
|
|
498
|
+
fires: 'When a plugin fiber starts.',
|
|
499
|
+
},
|
|
500
|
+
{
|
|
501
|
+
name: 'internal/service', category: 'internal', dispatch: 'emit', internal: true,
|
|
502
|
+
interceptable: false, decisions: OBSERVE,
|
|
503
|
+
fires: 'When a service registers on the root context.',
|
|
504
|
+
},
|
|
505
|
+
{
|
|
506
|
+
name: 'internal/status', category: 'internal', dispatch: 'emit', internal: true, hot: true,
|
|
507
|
+
interceptable: false, decisions: OBSERVE,
|
|
508
|
+
fires: 'When a fiber\'s lifecycle state transitions.',
|
|
509
|
+
},
|
|
510
|
+
];
|
|
511
|
+
|
|
512
|
+
/**
|
|
513
|
+
* Session-log event types the runtime commits (mirror of
|
|
514
|
+
* `KNOWN_SESSION_EVENT_TYPES` + the picasso-plugin types from
|
|
515
|
+
* packages/core/src/dsh/contract.ts). A hook may bind a bare type name — the
|
|
516
|
+
* bridge observes `session/event` and fires only when `event.type` matches.
|
|
517
|
+
* All observe-only: a committed log entry cannot be vetoed.
|
|
518
|
+
*/
|
|
519
|
+
export const SESSION_EVENT_TYPES = [
|
|
520
|
+
{ name: 'turn/start', fires: 'A turn begins; data.turn is the 1-based turn number.' },
|
|
521
|
+
{ name: 'turn/end', fires: 'A turn ends; data.reason is completed|aborted|blocked|error|max-tokens|interrupted|forked.' },
|
|
522
|
+
{ name: 'step/start', fires: 'A model step begins inside a turn.' },
|
|
523
|
+
{ name: 'step/end', fires: 'A model step ends.' },
|
|
524
|
+
{ name: 'tool/call', fires: 'A tool call is admitted; data carries callId, name, arguments.' },
|
|
525
|
+
{ name: 'tool/result', fires: 'A tool result is committed; data carries the tool message and error info.' },
|
|
526
|
+
{ name: 'tool/ptc-dispatch', fires: 'A PTC workflow dispatch is committed.' },
|
|
527
|
+
{ name: 'tool/ptc-dispatch-start', fires: 'A PTC workflow dispatch starts.' },
|
|
528
|
+
{ name: 'tool-workflow/run-start', fires: 'A workflow tool run starts.' },
|
|
529
|
+
{ name: 'tool-workflow/run-end', fires: 'A workflow tool run ends.' },
|
|
530
|
+
{ name: 'tool-workflow/agent-start', fires: 'A workflow tool sub-agent starts.' },
|
|
531
|
+
{ name: 'tool-workflow/agent-end', fires: 'A workflow tool sub-agent ends.' },
|
|
532
|
+
{ name: 'user/message', fires: 'A user message is committed.' },
|
|
533
|
+
{ name: 'assistant/message', fires: 'An assistant message is committed; data carries message, usage.' },
|
|
534
|
+
{ name: 'assistant/attempt', fires: 'An assistant attempt failed; data.stream holds the partial stream.' },
|
|
535
|
+
{ name: 'developer/message', fires: 'A developer message is committed.' },
|
|
536
|
+
{ name: 'system/message', fires: 'A system message is committed.' },
|
|
537
|
+
{ name: 'agent/inbox/spliced', fires: 'Durable record of an inbox splice.' },
|
|
538
|
+
{ name: 'agent-preset/selected', fires: 'The session selected an agent preset.' },
|
|
539
|
+
{ name: 'approval/asked', fires: 'A tool call asked for approval.' },
|
|
540
|
+
{ name: 'approval/decided', fires: 'An approval was decided (allowed-once|rejected|cancelled|unavailable).' },
|
|
541
|
+
{ name: 'approval/policy', fires: 'The approval policy changed (ask|never).' },
|
|
542
|
+
{ name: 'command/run', fires: 'A slash/native command was invoked.' },
|
|
543
|
+
{ name: 'command/done', fires: 'A slash/native command finished.' },
|
|
544
|
+
{ name: 'compaction/start', fires: 'A compaction run begins.' },
|
|
545
|
+
{ name: 'compaction/end', fires: 'A compaction run ends.' },
|
|
546
|
+
{ name: 'compaction/prune', fires: 'Entries are shadowed by a compaction.' },
|
|
547
|
+
{ name: 'compaction/summary', fires: 'A compaction summary is committed.' },
|
|
548
|
+
{ name: 'deliverables/presented', fires: 'Files were presented as deliverables.' },
|
|
549
|
+
{ name: 'feedback/record', fires: 'A feedback record is committed.' },
|
|
550
|
+
{ name: 'feedback/message-put', fires: 'A feedback annotation is attached to a message.' },
|
|
551
|
+
{ name: 'feedback/message-delete', fires: 'A feedback annotation is removed.' },
|
|
552
|
+
{ name: 'goal/change', fires: 'The session goal is created/changed/disarmed.' },
|
|
553
|
+
{ name: 'hook/invoked', fires: 'A hook ran (reserved upstream hook dialect: point, handlerId, dialect).' },
|
|
554
|
+
{ name: 'hook/result', fires: 'A hook produced a decision (point, handlerId, decision, exitCode, durationMs).' },
|
|
555
|
+
{ name: 'image/offload', fires: 'Image payloads were offloaded from context.' },
|
|
556
|
+
{ name: 'job/registered', fires: 'A background job registered.' },
|
|
557
|
+
{ name: 'job/settled', fires: 'A background job finished (completed|killed|failed).' },
|
|
558
|
+
{ name: 'llm/retry', fires: 'An LLM retry happened; data carries retryId, provider, retry, delayMs, error.' },
|
|
559
|
+
{ name: 'llm/retry-started', fires: 'An LLM retry window opened.' },
|
|
560
|
+
{ name: 'model/selection', fires: 'The session model selection changed.' },
|
|
561
|
+
{ name: 'permission/preset', fires: 'The permission preset changed.' },
|
|
562
|
+
{ name: 'plan/mode', fires: 'Plan mode toggled; data.active.' },
|
|
563
|
+
{ name: 'request/context', fires: 'The request context window was recorded.' },
|
|
564
|
+
{ name: 'request/header', fires: 'The request header (provider/model/tools) was committed.' },
|
|
565
|
+
{ name: 'sandbox/mode', fires: 'The sandbox mode changed.' },
|
|
566
|
+
{ name: 'schedule/change', fires: 'A schedule entry changed.' },
|
|
567
|
+
{ name: 'session-log-deepseek/delivery-accepted', fires: 'The DeepSeek session-log upload was accepted.' },
|
|
568
|
+
{ name: 'session/end-seed', fires: 'The session end seed was written.' },
|
|
569
|
+
{ name: 'session/title', fires: 'The session title changed.' },
|
|
570
|
+
{ name: 'session/title-llm-request', fires: 'A title-generation LLM request ran.' },
|
|
571
|
+
{ name: 'subagent/catalog', fires: 'The subagent catalog snapshot.' },
|
|
572
|
+
{ name: 'subagent/descriptor', fires: 'A subagent descriptor was registered.' },
|
|
573
|
+
{ name: 'subagent/model-selection-policy', fires: 'The subagent model allowlist.' },
|
|
574
|
+
{ name: 'team/member', fires: 'A team member record changed.' },
|
|
575
|
+
{ name: 'team/message/queued', fires: 'A team message was queued.' },
|
|
576
|
+
{ name: 'team/message/delivered', fires: 'A team message was delivered.' },
|
|
577
|
+
{ name: 'team/mode', fires: 'Agent Teams were switched on or off for the session; data.enabled.' },
|
|
578
|
+
{ name: 'team/task', fires: 'A team task record changed.' },
|
|
579
|
+
{ name: 'todo/write', fires: 'The todo list was rewritten.' },
|
|
580
|
+
{ name: 'web/deepseek-search-llm-request', fires: 'A DeepSeek web-search LLM request ran.' },
|
|
581
|
+
{ name: 'working-directory/change', fires: 'The session working directory changed.' },
|
|
582
|
+
{ name: 'workspace/changes', fires: 'A workspace-changes summary was committed for a turn.' },
|
|
583
|
+
// Picasso plugin events (also flow through session/event).
|
|
584
|
+
{ name: 'memory/recalled', fires: 'Picasso memory recall ran for a prompt.', plugin: 'picasso' },
|
|
585
|
+
{ name: 'memory/written', fires: 'Picasso memory write completed.', plugin: 'picasso' },
|
|
586
|
+
{ name: 'goal/started', fires: 'A Picasso goal run started.', plugin: 'picasso' },
|
|
587
|
+
{ name: 'goal/progress', fires: 'A Picasso goal reported a round of progress.', plugin: 'picasso' },
|
|
588
|
+
{ name: 'goal/finished', fires: 'A Picasso goal finished (met|stopped|failed|budget).', plugin: 'picasso' },
|
|
589
|
+
{ name: 'sponsor/slot', fires: 'A sponsor slot was rendered.', plugin: 'picasso' },
|
|
590
|
+
{ name: 'approval/request', fires: 'Picasso surfaced an approval request to a client.', plugin: 'picasso' },
|
|
591
|
+
{ name: 'approval/respond', fires: 'A client answered an approval request.', plugin: 'picasso' },
|
|
592
|
+
{ name: 'question/request', fires: 'Picasso surfaced a question request to a client.', plugin: 'picasso' },
|
|
593
|
+
{ name: 'upstream/update-available', fires: 'A newer dsh runtime was detected.', plugin: 'picasso' },
|
|
594
|
+
];
|
|
595
|
+
|
|
596
|
+
/**
|
|
597
|
+
* Friendly picasso names that predate the raw vocabulary. Values are the real
|
|
598
|
+
* dsh points; aliases keep working so existing hooks.json entries keep firing.
|
|
599
|
+
* `pre-session`/`post-session` were re-pointed at session/created+disposed —
|
|
600
|
+
* `agent/session-start` does not exist in the runtime (nothing emitted it) and
|
|
601
|
+
* `agent/turn-stopping` fires per turn, not per session.
|
|
602
|
+
*
|
|
603
|
+
* `pre-plan` and `on-error` are not aliases: they are loop events (index.js
|
|
604
|
+
* LOOP_HOOK_EVENTS) with the loop's once-per-turn semantics on both surfaces,
|
|
605
|
+
* so an engine alias would fire them a second time (per step / per request
|
|
606
|
+
* error). The raw `agent/pre-step` and `agent/request-error` stay available.
|
|
607
|
+
*/
|
|
608
|
+
export const PICASSO_EVENT_ALIASES = {
|
|
609
|
+
'pre-tool': 'tools/pre-execute',
|
|
610
|
+
'post-tool': 'tools/post-execute',
|
|
611
|
+
'pre-session': 'session/created',
|
|
612
|
+
'post-session': 'session/disposed',
|
|
613
|
+
};
|
|
614
|
+
|
|
615
|
+
const lifecycleByName = new Map(LIFECYCLE_EVENTS.map((entry) => [entry.name, entry]));
|
|
616
|
+
const sessionEventByName = new Map(
|
|
617
|
+
SESSION_EVENT_TYPES.map((entry) => [
|
|
618
|
+
entry.name,
|
|
619
|
+
{ ...entry, category: 'session-event', dispatch: 'session-event', interceptable: false, decisions: [] },
|
|
620
|
+
]),
|
|
621
|
+
);
|
|
622
|
+
|
|
623
|
+
/**
|
|
624
|
+
* Resolve a hooks.json `event` name to its lifecycle entry (alias-aware).
|
|
625
|
+
* A name that is both an interception point and a session-log type — e.g.
|
|
626
|
+
* `approval/request` — resolves to the interception point: it fires for the
|
|
627
|
+
* same moment and the hook can additionally reply a decision there.
|
|
628
|
+
*/
|
|
629
|
+
export function lifecycleEvent(name) {
|
|
630
|
+
const aliased = PICASSO_EVENT_ALIASES[name] ?? name;
|
|
631
|
+
return lifecycleByName.get(aliased) ?? sessionEventByName.get(aliased);
|
|
632
|
+
}
|
|
633
|
+
|
|
634
|
+
/** Whether `name` is a hooks.json event the bridge can wire to a real dispatch. */
|
|
635
|
+
export function isLifecycleEvent(name) {
|
|
636
|
+
return lifecycleEvent(name) !== undefined;
|
|
637
|
+
}
|
|
638
|
+
|
|
639
|
+
/**
|
|
640
|
+
* Resolve a configured event name to the dsh point the bridge subscribes to.
|
|
641
|
+
* Session-log types resolve to 'session/event' with `sessionType` filter.
|
|
642
|
+
*/
|
|
643
|
+
export function resolveHookPoint(name) {
|
|
644
|
+
const aliased = PICASSO_EVENT_ALIASES[name] ?? name;
|
|
645
|
+
const direct = lifecycleByName.get(aliased);
|
|
646
|
+
if (direct !== undefined) return { point: aliased, entry: direct, sessionType: undefined };
|
|
647
|
+
if (sessionEventByName.has(aliased)) {
|
|
648
|
+
return { point: 'session/event', entry: sessionEventByName.get(aliased), sessionType: aliased };
|
|
649
|
+
}
|
|
650
|
+
return undefined;
|
|
651
|
+
}
|