@zq-silk/yui 0.13.8 → 0.13.9

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.
Files changed (67) hide show
  1. package/README.md +9 -8
  2. package/dist/cli/commandCatalog.js +21 -2
  3. package/dist/cli.js +42 -13
  4. package/dist/commands/agentCommands.js +1 -1
  5. package/dist/commands/configCommands.js +1 -86
  6. package/dist/commands/executionAuditCommands.js +17 -16
  7. package/dist/commands/globalRoleCommands.js +4 -4
  8. package/dist/commands/sessionCommands.js +2 -6
  9. package/dist/commands/taskActor.js +1 -2
  10. package/dist/commands/taskCommands.js +92 -9
  11. package/dist/commands/taskRoleRuntimeStatus.js +3 -3
  12. package/dist/config/configCatalog.js +1 -6
  13. package/dist/config/yuiConfig.js +0 -79
  14. package/dist/controller/clientRuntime.js +40 -3
  15. package/dist/controller/controller.js +29 -52
  16. package/dist/controller/fileSchedulerStoreAdapter.js +305 -1056
  17. package/dist/controller/runtime.js +12 -5
  18. package/dist/controller/runtimeHookRunFence.js +3 -9
  19. package/dist/controller/runtimeLaunchCoordinator.js +44 -67
  20. package/dist/controller/structuredProviderObservation.js +18 -5
  21. package/dist/coordination/workMailbox.js +4 -4
  22. package/dist/execution/executionHealth.js +1 -1
  23. package/dist/executor/agentExecutor.js +92 -68
  24. package/dist/executor/executorRegistry.js +8 -20
  25. package/dist/executor/fileRoleLaunchPlanner.js +24 -90
  26. package/dist/executor/turnCompletion.js +5 -5
  27. package/dist/lifecycle/exactRunTerminalization.js +1 -1
  28. package/dist/observability/executionAudit.js +40 -94
  29. package/dist/operator/operatorSessionHistory.js +7 -5
  30. package/dist/role/role.js +1 -1
  31. package/dist/run/agentRun.js +4 -54
  32. package/dist/runtime/agentDriver.js +2 -0
  33. package/dist/runtime/agentError.js +114 -0
  34. package/dist/runtime/agentHost.js +55 -82
  35. package/dist/runtime/builtinAgentDrivers.js +21 -9
  36. package/dist/runtime/builtinAgentErrorMappers.js +150 -0
  37. package/dist/runtime/exactControlPlane.js +6 -12
  38. package/dist/runtime/index.js +0 -1
  39. package/dist/runtime/launchBroker.js +5 -19
  40. package/dist/runtime/lifecycleReservation.js +20 -4
  41. package/dist/runtime/providerRuntimeIdentity.js +3 -2
  42. package/dist/runtime/runtimeBinding.js +0 -27
  43. package/dist/runtime/runtimeObservation.js +7 -16
  44. package/dist/runtime/runtimeSessionCandidate.js +3 -10
  45. package/dist/runtime/sessionLaunchRequest.js +1 -2
  46. package/dist/runtime/sessionReconciliation.js +2 -2
  47. package/dist/runtime/structuredProviderHost.js +44 -79
  48. package/dist/runtime/taskRuntimeIsolation.js +0 -7
  49. package/dist/runtime/tmuxAdapters.js +6 -49
  50. package/dist/scheduler/activeRoleRunDelivery.js +218 -168
  51. package/dist/scheduler/leaderWakeupProcessor.js +126 -86
  52. package/dist/scheduler/roleRunLiveness.js +4 -1
  53. package/dist/scheduler/roleRunStall.js +7 -11
  54. package/dist/scheduler/wakeReason.js +4 -0
  55. package/dist/storage/migration/productionRegistry.js +332 -0
  56. package/dist/storage/sqliteSchema.js +54 -2
  57. package/dist/storage/sqliteStore.js +11 -44
  58. package/dist/storage/taskStore.js +7 -35
  59. package/package.json +1 -1
  60. package/skills/yui-leader/SKILL.md +30 -8
  61. package/skills/yui-operator/SKILL.md +14 -6
  62. package/skills/yui-runtime/SKILL.md +6 -4
  63. package/dist/lifecycle/providerErrorClass.js +0 -152
  64. package/dist/run/providerRetry.js +0 -226
  65. package/dist/run/providerRetryConfig.js +0 -27
  66. package/dist/runtime/providerErrorCodes.js +0 -278
  67. package/dist/runtime/providerRecoveryDecision.js +0 -55
@@ -1,278 +0,0 @@
1
- /**
2
- * Provider-neutral structured error taxonomy.
3
- *
4
- * Each Agent Driver parses its own Provider's raw failure text into one of
5
- * these codes at the driver boundary. The retry classifier then maps codes to
6
- * Yui error classes by lookup — no Provider-specific regex lives in the
7
- * classifier. Text matching remains only as a fallback for drivers that
8
- * cannot yet produce a structured code.
9
- */
10
- /**
11
- * Maps each structured code to its Yui error class. This is the single
12
- * authoritative lookup that replaces regex matching in the classifier.
13
- */
14
- export const PROVIDER_ERROR_CODE_CLASS = Object.freeze({
15
- // Stream/transport → transport-uncertain (delivery may have happened)
16
- "stream-internal-error": "transport-uncertain",
17
- "stream-protocol-error": "transport-uncertain",
18
- "stream-error": "transport-uncertain",
19
- "connection-reset": "transport-uncertain",
20
- "connection-lost": "transport-uncertain",
21
- timeout: "transport-uncertain",
22
- // HTTP 5xx / capacity → transient-provider
23
- "http-5xx": "transient-provider",
24
- overloaded: "transient-provider",
25
- "server-error": "transient-provider",
26
- // HTTP 429 → transient-provider (retryable with backoff)
27
- "http-429": "transient-provider",
28
- // HTTP 4xx → invalid-request (non-retryable)
29
- "http-4xx": "invalid-request",
30
- // Policy
31
- "policy-denied": "policy-denied",
32
- // Session
33
- "session-not-found": "session-dead",
34
- "session-expired": "session-dead",
35
- "session-ended": "session-dead",
36
- "process-exited": "session-dead",
37
- // Request
38
- "invalid-request": "invalid-request",
39
- unknown: "unclassified"
40
- });
41
- /** Whether a structured code is retryable in place. */
42
- export function isRetryableErrorCode(code) {
43
- const cls = PROVIDER_ERROR_CODE_CLASS[code];
44
- return cls === "transient-provider" || cls === "transport-uncertain";
45
- }
46
- // ── Claude Code driver ──────────────────────────────────────────────────
47
- /**
48
- * Parses a Claude Code StopFailure `error` string into a structured code.
49
- *
50
- * Claude sends structured API error codes (server_error, overloaded_error,
51
- * rate_limit_error, etc.) as the `error` field, and raw transport text
52
- * ("stream error: stream ID …; INTERNAL_ERROR") in error_details or the
53
- * CLI's own output. This function handles both.
54
- */
55
- export function parseClaudeError(error, details) {
56
- const text = [error, details]
57
- .filter((v) => typeof v === "string" && v.length > 0)
58
- .join("\n");
59
- // ── Structured Claude API error codes ──────────────────────────────
60
- // Claude's StopFailure hook sends these as the `error` field.
61
- if (/^server_error$/iu.test(text)) {
62
- return { code: "server-error", raw: error };
63
- }
64
- if (/^overloaded_error$/iu.test(text)) {
65
- return { code: "overloaded", raw: error };
66
- }
67
- if (/^rate_limit_error$/iu.test(text)) {
68
- return { code: "http-429", raw: error };
69
- }
70
- if (/^invalid_request_error$/iu.test(text)) {
71
- return { code: "invalid-request", raw: error };
72
- }
73
- if (/^(authentication_error|permission_error)$/iu.test(text)) {
74
- return { code: "policy-denied", raw: error };
75
- }
76
- if (/^not_found_error$/iu.test(text)) {
77
- return { code: "session-not-found", raw: error };
78
- }
79
- if (/^api_error$/iu.test(text)) {
80
- return { code: "server-error", raw: error };
81
- }
82
- // Claude CLI structured error codes (e.g. "[claude-code:unrecognized_model]")
83
- if (/\[claude-code:(unrecognized_model|invalid_model|model_not_found)\]/iu.test(text)) {
84
- return { code: "invalid-request", raw: error };
85
- }
86
- // HTTP/2 RST_STREAM (the Task-27 failure mode)
87
- if (/stream error:.*INTERNAL_ERROR/iu.test(text)) {
88
- return { code: "stream-internal-error", raw: error };
89
- }
90
- if (/stream error:.*PROTOCOL_ERROR/iu.test(text)) {
91
- return { code: "stream-protocol-error", raw: error };
92
- }
93
- if (/stream error/iu.test(text)) {
94
- return { code: "stream-error", raw: error };
95
- }
96
- // "Server error mid-response" and similar
97
- if (/server[\s_-]?error/iu.test(text)) {
98
- return { code: "server-error", raw: error };
99
- }
100
- // HTTP status codes
101
- if (/\b429\b/u.test(text))
102
- return { code: "http-429", raw: error };
103
- if (/\b40[0-9]\b/u.test(text))
104
- return { code: "http-4xx", raw: error };
105
- if (/\b50[024]\b/u.test(text))
106
- return { code: "http-5xx", raw: error };
107
- // Connection
108
- if (/connection[\s_-]?reset/iu.test(text))
109
- return { code: "connection-reset", raw: error };
110
- if (/connection[\s_-]?lost/iu.test(text))
111
- return { code: "connection-lost", raw: error };
112
- if (/econnreset/iu.test(text))
113
- return { code: "connection-reset", raw: error };
114
- if (/socket hang up/iu.test(text))
115
- return { code: "connection-reset", raw: error };
116
- // Timeout
117
- if (/timed?[ -]?out/iu.test(text))
118
- return { code: "timeout", raw: error };
119
- if (/etimedout/iu.test(text))
120
- return { code: "timeout", raw: error };
121
- // Capacity
122
- if (/overloaded/iu.test(text))
123
- return { code: "overloaded", raw: error };
124
- if (/rate[\s_-]?limit/iu.test(text))
125
- return { code: "http-429", raw: error };
126
- // Policy
127
- if (/cyber[_-]?policy/iu.test(text))
128
- return { code: "policy-denied", raw: error };
129
- if (/policy[\s_-]?violation/iu.test(text))
130
- return { code: "policy-denied", raw: error };
131
- if (/usage[\s_-]?policy/iu.test(text))
132
- return { code: "policy-denied", raw: error };
133
- if (/content[\s_-]?policy/iu.test(text))
134
- return { code: "policy-denied", raw: error };
135
- if (/safety[\s_-]?policy/iu.test(text))
136
- return { code: "policy-denied", raw: error };
137
- // Session lifecycle
138
- if (/session[\s_-]?not[\s_-]?found/iu.test(text))
139
- return { code: "session-not-found", raw: error };
140
- if (/no[\s_-]?such[\s_-]?(session|thread)/iu.test(text))
141
- return { code: "session-not-found", raw: error };
142
- if (/thread[\s_-]?not[\s_-]?found/iu.test(text))
143
- return { code: "session-not-found", raw: error };
144
- if (/session[\s_-]?(has[\s_-]?)?expired/iu.test(text))
145
- return { code: "session-expired", raw: error };
146
- if (/session[\s_-]?(has[\s_-]?)?ended/iu.test(text))
147
- return { code: "session-ended", raw: error };
148
- if (/process[\s_-]?exited/iu.test(text))
149
- return { code: "process-exited", raw: error };
150
- // Request validity
151
- if (/invalid[\s_-]?request/iu.test(text))
152
- return { code: "invalid-request", raw: error };
153
- if (/validation[\s_-]?error/iu.test(text))
154
- return { code: "invalid-request", raw: error };
155
- if (/bad[\s_-]?request/iu.test(text))
156
- return { code: "http-4xx", raw: error };
157
- if (/unknown[\s_-]?(flag|tool|argument)/iu.test(text))
158
- return { code: "invalid-request", raw: error };
159
- return { code: "unknown", raw: error };
160
- }
161
- // ── Codex driver ────────────────────────────────────────────────────────
162
- /**
163
- * Parses a Codex CLI failure into a structured code.
164
- *
165
- * Codex surfaces errors through process exit, transcript messages, and
166
- * stream-level failures. Its error formats overlap with Claude's (HTTP/2
167
- * stream errors, API status codes) but also include Codex-specific patterns.
168
- */
169
- export function parseCodexError(error, details) {
170
- const text = [error, details]
171
- .filter((v) => typeof v === "string" && v.length > 0)
172
- .join("\n");
173
- // ── Structured API error codes ────────────────────────────────────
174
- if (/^server_error$/iu.test(text)) {
175
- return { code: "server-error", raw: error };
176
- }
177
- if (/^overloaded_error$/iu.test(text)) {
178
- return { code: "overloaded", raw: error };
179
- }
180
- if (/^rate_limit_error$/iu.test(text)) {
181
- return { code: "http-429", raw: error };
182
- }
183
- if (/^invalid_request_error$/iu.test(text)) {
184
- return { code: "invalid-request", raw: error };
185
- }
186
- if (/^(authentication_error|permission_error)$/iu.test(text)) {
187
- return { code: "policy-denied", raw: error };
188
- }
189
- // Codex CLI structured error codes
190
- if (/\[codex:(unrecognized_model|invalid_model|model_not_found)\]/iu.test(text)) {
191
- return { code: "invalid-request", raw: error };
192
- }
193
- // Model not supported / invalid model (non-retryable)
194
- if (/model.*not supported|invalid.*model|model.*not found/iu.test(text)) {
195
- return { code: "invalid-request", raw: error };
196
- }
197
- // Stream disconnected (retryable transport)
198
- if (/stream disconnected/iu.test(text)) {
199
- return { code: "stream-error", raw: error };
200
- }
201
- // ── Stream / transport ────────────────────────────────────────────
202
- if (/stream error:.*INTERNAL_ERROR/iu.test(text)) {
203
- return { code: "stream-internal-error", raw: error };
204
- }
205
- if (/stream error:.*PROTOCOL_ERROR/iu.test(text)) {
206
- return { code: "stream-protocol-error", raw: error };
207
- }
208
- if (/stream error/iu.test(text)) {
209
- return { code: "stream-error", raw: error };
210
- }
211
- // ── HTTP status codes ─────────────────────────────────────────────
212
- if (/\b429\b/u.test(text))
213
- return { code: "http-429", raw: error };
214
- if (/\b40[0-9]\b/u.test(text))
215
- return { code: "http-4xx", raw: error };
216
- if (/\b50[024]\b/u.test(text))
217
- return { code: "http-5xx", raw: error };
218
- // ── Server / capacity ─────────────────────────────────────────────
219
- if (/server[\s_-]?error/iu.test(text)) {
220
- return { code: "server-error", raw: error };
221
- }
222
- if (/overloaded/iu.test(text))
223
- return { code: "overloaded", raw: error };
224
- if (/rate[\s_-]?limit/iu.test(text))
225
- return { code: "http-429", raw: error };
226
- if (/bad gateway/iu.test(text))
227
- return { code: "http-5xx", raw: error };
228
- if (/gateway timeout/iu.test(text))
229
- return { code: "timeout", raw: error };
230
- if (/service unavailable/iu.test(text))
231
- return { code: "http-5xx", raw: error };
232
- if (/temporarily unavailable/iu.test(text))
233
- return { code: "http-5xx", raw: error };
234
- // ── Connection ────────────────────────────────────────────────────
235
- if (/connection[\s_-]?reset/iu.test(text))
236
- return { code: "connection-reset", raw: error };
237
- if (/connection[\s_-]?lost/iu.test(text))
238
- return { code: "connection-lost", raw: error };
239
- if (/econnreset/iu.test(text))
240
- return { code: "connection-reset", raw: error };
241
- if (/socket hang up/iu.test(text))
242
- return { code: "connection-reset", raw: error };
243
- // ── Timeout ───────────────────────────────────────────────────────
244
- if (/timed?[ -]?out/iu.test(text))
245
- return { code: "timeout", raw: error };
246
- if (/etimedout/iu.test(text))
247
- return { code: "timeout", raw: error };
248
- // ── Policy ────────────────────────────────────────────────────────
249
- if (/cyber[_-]?policy/iu.test(text))
250
- return { code: "policy-denied", raw: error };
251
- if (/policy[\s_-]?violation/iu.test(text))
252
- return { code: "policy-denied", raw: error };
253
- if (/usage[\s_-]?policy/iu.test(text))
254
- return { code: "policy-denied", raw: error };
255
- if (/content[\s_-]?policy/iu.test(text))
256
- return { code: "policy-denied", raw: error };
257
- // ── Session ───────────────────────────────────────────────────────
258
- if (/session[\s_-]?not[\s_-]?found/iu.test(text))
259
- return { code: "session-not-found", raw: error };
260
- if (/no[\s_-]?such[\s_-]?(session|thread)/iu.test(text))
261
- return { code: "session-not-found", raw: error };
262
- if (/session[\s_-]?(has[\s_-]?)?expired/iu.test(text))
263
- return { code: "session-expired", raw: error };
264
- if (/session[\s_-]?(has[\s_-]?)?ended/iu.test(text))
265
- return { code: "session-ended", raw: error };
266
- if (/process[\s_-]?exited/iu.test(text))
267
- return { code: "process-exited", raw: error };
268
- // ── Request validity ──────────────────────────────────────────────
269
- if (/invalid[\s_-]?request/iu.test(text))
270
- return { code: "invalid-request", raw: error };
271
- if (/validation[\s_-]?error/iu.test(text))
272
- return { code: "invalid-request", raw: error };
273
- if (/bad[\s_-]?request/iu.test(text))
274
- return { code: "http-4xx", raw: error };
275
- if (/unknown[\s_-]?(flag|tool|argument)/iu.test(text))
276
- return { code: "invalid-request", raw: error };
277
- return { code: "unknown", raw: error };
278
- }
@@ -1,55 +0,0 @@
1
- import { currentProviderActivation, currentProviderConversation, validateProviderRuntimeBinding } from "./providerRuntimeIdentity.js";
2
- /**
3
- * Exact tri-state recovery policy. Unknown is a terminal decision for the
4
- * automatic recovery attempt, not permission to create another Conversation.
5
- */
6
- export function decideProviderRecovery(input) {
7
- const binding = validateProviderRuntimeBinding(input.binding);
8
- const conversation = currentProviderConversation(binding);
9
- if (input.probe.conversationId !== conversation.conversationId) {
10
- throw new Error("Provider recovery probe targets a different Conversation.");
11
- }
12
- if (input.probe.state === "unknown") {
13
- return {
14
- action: "attention",
15
- conversationId: conversation.conversationId,
16
- reason: "Provider Conversation existence is unknown; replacement is fenced."
17
- };
18
- }
19
- if (input.probe.state === "exists") {
20
- if (input.probe.activeTurnId !== undefined) {
21
- return {
22
- action: "observe-active-turn",
23
- conversationId: conversation.conversationId,
24
- turnId: input.probe.activeTurnId
25
- };
26
- }
27
- if (input.unsettledInputDelivery || providerTurnIsUnsettled(binding)) {
28
- return {
29
- action: "attention",
30
- conversationId: conversation.conversationId,
31
- reason: "Provider Conversation exists but prior input delivery is still unsettled."
32
- };
33
- }
34
- return { action: "resume", conversationId: conversation.conversationId };
35
- }
36
- if (input.unsettledInputDelivery || providerTurnIsUnsettled(binding)) {
37
- return {
38
- action: "attention",
39
- conversationId: conversation.conversationId,
40
- reason: "Provider Conversation is missing but input delivery remains unsettled."
41
- };
42
- }
43
- if (currentProviderActivation(binding) !== null || binding.authority.owner !== "none") {
44
- return {
45
- action: "attention",
46
- conversationId: conversation.conversationId,
47
- reason: "Provider Conversation is missing but its Activation writer has not ended."
48
- };
49
- }
50
- return { action: "restart-run", conversationId: conversation.conversationId };
51
- }
52
- function providerTurnIsUnsettled(binding) {
53
- return binding.turn !== null
54
- && ["submitting", "accepted", "running", "delivery-unknown"].includes(binding.turn.status);
55
- }