@a5c-ai/babysitter-sdk 0.0.169 → 0.0.170-staging.00aac85c

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 (76) hide show
  1. package/dist/cli/commands/configure.d.ts +124 -0
  2. package/dist/cli/commands/configure.d.ts.map +1 -0
  3. package/dist/cli/commands/configure.js +514 -0
  4. package/dist/cli/commands/health.d.ts +89 -0
  5. package/dist/cli/commands/health.d.ts.map +1 -0
  6. package/dist/cli/commands/health.js +579 -0
  7. package/dist/cli/commands/hookLog.d.ts +15 -0
  8. package/dist/cli/commands/hookLog.d.ts.map +1 -0
  9. package/dist/cli/commands/hookLog.js +286 -0
  10. package/dist/cli/commands/hookRun.d.ts +20 -0
  11. package/dist/cli/commands/hookRun.d.ts.map +1 -0
  12. package/dist/cli/commands/hookRun.js +544 -0
  13. package/dist/cli/commands/runExecuteTasks.d.ts +42 -0
  14. package/dist/cli/commands/runExecuteTasks.d.ts.map +1 -0
  15. package/dist/cli/commands/runExecuteTasks.js +377 -0
  16. package/dist/cli/commands/runIterate.d.ts +5 -1
  17. package/dist/cli/commands/runIterate.d.ts.map +1 -1
  18. package/dist/cli/commands/runIterate.js +75 -6
  19. package/dist/cli/commands/session.d.ts +97 -0
  20. package/dist/cli/commands/session.d.ts.map +1 -0
  21. package/dist/cli/commands/session.js +922 -0
  22. package/dist/cli/commands/skill.d.ts +87 -0
  23. package/dist/cli/commands/skill.d.ts.map +1 -0
  24. package/dist/cli/commands/skill.js +869 -0
  25. package/dist/cli/completionProof.d.ts +4 -0
  26. package/dist/cli/completionProof.d.ts.map +1 -0
  27. package/dist/cli/{completionSecret.js → completionProof.js} +7 -7
  28. package/dist/cli/main.d.ts +14 -0
  29. package/dist/cli/main.d.ts.map +1 -1
  30. package/dist/cli/main.js +649 -16
  31. package/dist/config/defaults.d.ts +165 -0
  32. package/dist/config/defaults.d.ts.map +1 -0
  33. package/dist/config/defaults.js +281 -0
  34. package/dist/config/index.d.ts +25 -0
  35. package/dist/config/index.d.ts.map +1 -0
  36. package/dist/config/index.js +35 -0
  37. package/dist/hooks/dispatcher.d.ts.map +1 -1
  38. package/dist/hooks/dispatcher.js +2 -1
  39. package/dist/index.d.ts +1 -0
  40. package/dist/index.d.ts.map +1 -1
  41. package/dist/index.js +1 -0
  42. package/dist/runtime/constants.d.ts +1 -1
  43. package/dist/runtime/constants.d.ts.map +1 -1
  44. package/dist/runtime/createRun.d.ts.map +1 -1
  45. package/dist/runtime/createRun.js +7 -3
  46. package/dist/runtime/exceptions.d.ts +186 -3
  47. package/dist/runtime/exceptions.d.ts.map +1 -1
  48. package/dist/runtime/exceptions.js +416 -15
  49. package/dist/runtime/types.d.ts +1 -0
  50. package/dist/runtime/types.d.ts.map +1 -1
  51. package/dist/session/index.d.ts +9 -0
  52. package/dist/session/index.d.ts.map +1 -0
  53. package/dist/session/index.js +30 -0
  54. package/dist/session/parse.d.ts +45 -0
  55. package/dist/session/parse.d.ts.map +1 -0
  56. package/dist/session/parse.js +159 -0
  57. package/dist/session/types.d.ts +194 -0
  58. package/dist/session/types.d.ts.map +1 -0
  59. package/dist/session/types.js +45 -0
  60. package/dist/session/write.d.ts +50 -0
  61. package/dist/session/write.d.ts.map +1 -0
  62. package/dist/session/write.js +196 -0
  63. package/dist/storage/createRunDir.d.ts.map +1 -1
  64. package/dist/storage/createRunDir.js +1 -0
  65. package/dist/storage/paths.d.ts +5 -1
  66. package/dist/storage/paths.d.ts.map +1 -1
  67. package/dist/storage/paths.js +6 -1
  68. package/dist/storage/types.d.ts +3 -1
  69. package/dist/storage/types.d.ts.map +1 -1
  70. package/dist/tasks/kinds/index.d.ts.map +1 -1
  71. package/dist/tasks/kinds/index.js +6 -1
  72. package/dist/testing/runHarness.d.ts.map +1 -1
  73. package/dist/testing/runHarness.js +5 -1
  74. package/package.json +1 -2
  75. package/dist/cli/completionSecret.d.ts +0 -4
  76. package/dist/cli/completionSecret.d.ts.map +0 -1
@@ -1,29 +1,324 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.InvalidSleepTargetError = exports.InvalidTaskDefinitionError = exports.MissingProcessContextError = exports.RunFailedError = exports.InvocationCollisionError = exports.ParallelPendingError = exports.EffectPendingError = exports.EffectRequestedError = exports.BabysitterIntrinsicError = exports.BabysitterRuntimeError = void 0;
3
+ exports.InvalidSleepTargetError = exports.InvalidTaskDefinitionError = exports.MissingProcessContextError = exports.RunFailedError = exports.InvocationCollisionError = exports.ParallelPendingError = exports.EffectPendingError = exports.EffectRequestedError = exports.BabysitterIntrinsicError = exports.BabysitterRuntimeError = exports.ERROR_TEMPLATES = exports.ERROR_CATEGORY_DESCRIPTIONS = exports.ErrorCategory = void 0;
4
+ exports.interpolateTemplate = interpolateTemplate;
5
+ exports.createErrorMessage = createErrorMessage;
6
+ exports.suggestCommand = suggestCommand;
7
+ exports.suggestFlag = suggestFlag;
8
+ exports.suggestFix = suggestFix;
9
+ exports.formatErrorWithContext = formatErrorWithContext;
10
+ exports.formatNextSteps = formatNextSteps;
11
+ exports.toStructuredError = toStructuredError;
4
12
  exports.isIntrinsicError = isIntrinsicError;
13
+ exports.isBabysitterError = isBabysitterError;
5
14
  exports.rehydrateSerializedError = rehydrateSerializedError;
6
15
  const batching_1 = require("../tasks/batching");
16
+ // ============================================================================
17
+ // Error Categories
18
+ // ============================================================================
19
+ /**
20
+ * Error category enum for classifying errors by their source and type.
21
+ * This helps users understand the nature of errors and how to address them.
22
+ */
23
+ var ErrorCategory;
24
+ (function (ErrorCategory) {
25
+ /** Configuration errors - issues with settings, environment, or setup */
26
+ ErrorCategory["Configuration"] = "CONFIGURATION";
27
+ /** Validation errors - input data or parameter validation failures */
28
+ ErrorCategory["Validation"] = "VALIDATION";
29
+ /** Runtime errors - errors during execution of processes or tasks */
30
+ ErrorCategory["Runtime"] = "RUNTIME";
31
+ /** External errors - failures from external services, APIs, or dependencies */
32
+ ErrorCategory["External"] = "EXTERNAL";
33
+ /** Internal errors - unexpected internal failures, bugs, or invariant violations */
34
+ ErrorCategory["Internal"] = "INTERNAL";
35
+ })(ErrorCategory || (exports.ErrorCategory = ErrorCategory = {}));
36
+ /**
37
+ * Human-readable descriptions for each error category
38
+ */
39
+ exports.ERROR_CATEGORY_DESCRIPTIONS = {
40
+ [ErrorCategory.Configuration]: "Configuration or setup issue",
41
+ [ErrorCategory.Validation]: "Input validation failure",
42
+ [ErrorCategory.Runtime]: "Runtime execution error",
43
+ [ErrorCategory.External]: "External service or dependency failure",
44
+ [ErrorCategory.Internal]: "Internal error (please report as a bug)",
45
+ };
46
+ /**
47
+ * Built-in error templates for common error scenarios
48
+ */
49
+ exports.ERROR_TEMPLATES = {
50
+ MISSING_REQUIRED_FLAG: {
51
+ pattern: "Missing required flag: {{flag}}",
52
+ category: ErrorCategory.Validation,
53
+ defaultNextSteps: ["Add the missing flag to your command", "Run with --help to see all available options"],
54
+ },
55
+ INVALID_FLAG_VALUE: {
56
+ pattern: "Invalid value for {{flag}}: {{value}}. Expected {{expected}}",
57
+ category: ErrorCategory.Validation,
58
+ defaultNextSteps: ["Check the expected format for this flag", "Run with --help for usage information"],
59
+ },
60
+ FILE_NOT_FOUND: {
61
+ pattern: "File not found: {{path}}",
62
+ category: ErrorCategory.Configuration,
63
+ defaultNextSteps: ["Verify the file path is correct", "Check that the file exists and is readable"],
64
+ },
65
+ PROCESS_NOT_FOUND: {
66
+ pattern: "Process entry file not found: {{path}}",
67
+ category: ErrorCategory.Configuration,
68
+ defaultNextSteps: [
69
+ "Ensure the path is correct and points to a valid JS/TS module",
70
+ "Check that the file has been compiled if using TypeScript",
71
+ ],
72
+ },
73
+ EXPORT_NOT_FOUND: {
74
+ pattern: "Process module {{path}} does not export '{{exportName}}'",
75
+ category: ErrorCategory.Configuration,
76
+ defaultNextSteps: [
77
+ "Check available exports in your module",
78
+ "Use --entry {{path}}#default for default export",
79
+ ],
80
+ defaultSuggestions: ["Did you mean to use a different export name?"],
81
+ },
82
+ EFFECT_NOT_FOUND: {
83
+ pattern: "Effect {{effectId}} not found at {{runDir}}",
84
+ category: ErrorCategory.Validation,
85
+ defaultNextSteps: ["Verify the effect ID is correct", "Run task:list to see available effects"],
86
+ },
87
+ EFFECT_WRONG_STATUS: {
88
+ pattern: "Effect {{effectId}} is not {{expectedStatus}} (current status={{actualStatus}})",
89
+ category: ErrorCategory.Validation,
90
+ defaultNextSteps: ["Check the current effect status with task:show", "Ensure you're operating on the correct effect"],
91
+ },
92
+ RUN_NOT_FOUND: {
93
+ pattern: "Run directory not found: {{runDir}}",
94
+ category: ErrorCategory.Configuration,
95
+ defaultNextSteps: ["Verify the run directory path", "Ensure the run has been created with run:create"],
96
+ },
97
+ JSON_PARSE_ERROR: {
98
+ pattern: "Failed to parse {{file}} as JSON: {{error}}",
99
+ category: ErrorCategory.Validation,
100
+ defaultNextSteps: ["Check that the file contains valid JSON", "Validate JSON syntax with a linter"],
101
+ },
102
+ MISSING_PROCESS_CONTEXT: {
103
+ pattern: "No active process context found on the current async call stack",
104
+ category: ErrorCategory.Runtime,
105
+ defaultNextSteps: [
106
+ "Ensure you are calling this from within a babysitter process function",
107
+ "Check that async context is properly maintained",
108
+ ],
109
+ },
110
+ INVOCATION_COLLISION: {
111
+ pattern: "Invocation key {{invocationKey}} is already in use within this run",
112
+ category: ErrorCategory.Runtime,
113
+ defaultNextSteps: [
114
+ "Ensure unique invocation keys for each task invocation",
115
+ "Check for duplicate task calls in your process",
116
+ ],
117
+ },
118
+ };
119
+ /**
120
+ * Interpolates context variables into a template pattern
121
+ */
122
+ function interpolateTemplate(pattern, context) {
123
+ return pattern.replace(/\{\{(\w+)\}\}/g, (match, key) => {
124
+ const value = context[key];
125
+ if (value === undefined || value === null) {
126
+ return match; // Keep placeholder if no value provided
127
+ }
128
+ return String(value);
129
+ });
130
+ }
131
+ /**
132
+ * Creates an error message from a template and context
133
+ */
134
+ function createErrorMessage(templateKey, context) {
135
+ const template = exports.ERROR_TEMPLATES[templateKey];
136
+ return interpolateTemplate(template.pattern, context);
137
+ }
138
+ // ============================================================================
139
+ // "Did You Mean?" Suggestions
140
+ // ============================================================================
141
+ /**
142
+ * Common typos and their corrections for CLI commands
143
+ */
144
+ const COMMAND_TYPOS = {
145
+ "run:create": ["run:creat", "run:craete", "runcreate", "create:run", "run-create"],
146
+ "run:status": ["run:stat", "run:staus", "runstatus", "status:run", "run-status"],
147
+ "run:iterate": ["run:iter", "run:itterate", "runiterate", "iterate:run", "run-iterate"],
148
+ "run:events": ["run:event", "runevents", "events:run", "run-events"],
149
+ "run:rebuild-state": ["run:rebuild", "run:rebuildstate", "rebuild-state", "run-rebuild-state"],
150
+ "run:repair-journal": ["run:repair", "run:repairjournal", "repair-journal", "run-repair-journal"],
151
+ "task:post": ["task:pst", "taskpost", "post:task", "task-post"],
152
+ "task:list": ["task:lst", "tasklist", "list:task", "task-list", "tasks:list"],
153
+ "task:show": ["task:shw", "taskshow", "show:task", "task-show"],
154
+ };
155
+ /**
156
+ * Common typos and their corrections for CLI flags
157
+ */
158
+ const FLAG_TYPOS = {
159
+ "--runs-dir": ["--runsdir", "--run-dir", "--rundir", "-runs-dir"],
160
+ "--process-id": ["--processid", "--process_id", "-process-id"],
161
+ "--entry": ["--enrty", "--entyr", "-entry"],
162
+ "--inputs": ["--input", "--inpust", "-inputs"],
163
+ "--json": ["--JSON", "-json", "--jsn"],
164
+ "--dry-run": ["--dryrun", "--dry_run", "-dry-run"],
165
+ "--verbose": ["--verbos", "-verbose", "--vebrose"],
166
+ "--status": ["--staus", "--stats", "-status"],
167
+ "--pending": ["--peding", "-pending"],
168
+ };
169
+ /**
170
+ * Computes Levenshtein distance between two strings
171
+ */
172
+ function levenshteinDistance(a, b) {
173
+ const matrix = [];
174
+ for (let i = 0; i <= b.length; i++) {
175
+ matrix[i] = [i];
176
+ }
177
+ for (let j = 0; j <= a.length; j++) {
178
+ matrix[0][j] = j;
179
+ }
180
+ for (let i = 1; i <= b.length; i++) {
181
+ for (let j = 1; j <= a.length; j++) {
182
+ if (b.charAt(i - 1) === a.charAt(j - 1)) {
183
+ matrix[i][j] = matrix[i - 1][j - 1];
184
+ }
185
+ else {
186
+ matrix[i][j] = Math.min(matrix[i - 1][j - 1] + 1, matrix[i][j - 1] + 1, matrix[i - 1][j] + 1);
187
+ }
188
+ }
189
+ }
190
+ return matrix[b.length][a.length];
191
+ }
192
+ /**
193
+ * Suggests corrections for a potentially misspelled command
194
+ */
195
+ function suggestCommand(input) {
196
+ const normalizedInput = input.toLowerCase().trim();
197
+ // Check direct typo mappings first
198
+ for (const [correct, typos] of Object.entries(COMMAND_TYPOS)) {
199
+ if (typos.includes(normalizedInput)) {
200
+ return correct;
201
+ }
202
+ }
203
+ // Fall back to Levenshtein distance
204
+ const commands = Object.keys(COMMAND_TYPOS);
205
+ let bestMatch;
206
+ let bestDistance = Infinity;
207
+ for (const command of commands) {
208
+ const distance = levenshteinDistance(normalizedInput, command);
209
+ if (distance < bestDistance && distance <= 3) {
210
+ bestDistance = distance;
211
+ bestMatch = command;
212
+ }
213
+ }
214
+ return bestMatch;
215
+ }
216
+ /**
217
+ * Suggests corrections for a potentially misspelled flag
218
+ */
219
+ function suggestFlag(input) {
220
+ const normalizedInput = input.toLowerCase().trim();
221
+ // Check direct typo mappings first
222
+ for (const [correct, typos] of Object.entries(FLAG_TYPOS)) {
223
+ if (typos.includes(normalizedInput)) {
224
+ return correct;
225
+ }
226
+ }
227
+ // Fall back to Levenshtein distance
228
+ const flags = Object.keys(FLAG_TYPOS);
229
+ let bestMatch;
230
+ let bestDistance = Infinity;
231
+ for (const flag of flags) {
232
+ const distance = levenshteinDistance(normalizedInput, flag);
233
+ if (distance < bestDistance && distance <= 3) {
234
+ bestDistance = distance;
235
+ bestMatch = flag;
236
+ }
237
+ }
238
+ return bestMatch;
239
+ }
240
+ /**
241
+ * Generic suggestion helper that finds the closest match from a list
242
+ */
243
+ function suggestFix(input, validOptions, maxDistance = 3) {
244
+ const normalizedInput = input.toLowerCase().trim();
245
+ let bestMatch;
246
+ let bestDistance = Infinity;
247
+ for (const option of validOptions) {
248
+ const distance = levenshteinDistance(normalizedInput, option.toLowerCase());
249
+ if (distance < bestDistance && distance <= maxDistance) {
250
+ bestDistance = distance;
251
+ bestMatch = option;
252
+ }
253
+ }
254
+ return bestMatch;
255
+ }
256
+ // ============================================================================
257
+ // Core Error Classes
258
+ // ============================================================================
7
259
  class BabysitterRuntimeError extends Error {
8
260
  details;
9
- constructor(name, message, details) {
261
+ category;
262
+ suggestions;
263
+ nextSteps;
264
+ constructor(name, message, options) {
10
265
  super(message);
11
266
  this.name = name;
12
- this.details = details;
267
+ // Handle backward compatibility: if options looks like old-style details object
268
+ if (options && !isErrorOptions(options)) {
269
+ this.details = options;
270
+ this.category = ErrorCategory.Runtime;
271
+ this.suggestions = [];
272
+ this.nextSteps = [];
273
+ }
274
+ else {
275
+ const opts = options;
276
+ this.details = opts?.details;
277
+ this.category = opts?.category ?? ErrorCategory.Runtime;
278
+ this.suggestions = opts?.suggestions ?? [];
279
+ this.nextSteps = opts?.nextSteps ?? [];
280
+ if (opts?.cause) {
281
+ this.cause = opts.cause;
282
+ }
283
+ }
284
+ }
285
+ /**
286
+ * Creates an error from a template
287
+ */
288
+ static fromTemplate(name, templateKey, context, additionalOptions) {
289
+ const template = exports.ERROR_TEMPLATES[templateKey];
290
+ const message = interpolateTemplate(template.pattern, context);
291
+ return new BabysitterRuntimeError(name, message, {
292
+ category: additionalOptions?.category ?? template.category,
293
+ suggestions: additionalOptions?.suggestions ?? template.defaultSuggestions ?? [],
294
+ nextSteps: additionalOptions?.nextSteps ?? template.defaultNextSteps ?? [],
295
+ details: { ...context, ...(additionalOptions?.details ?? {}) },
296
+ cause: additionalOptions?.cause,
297
+ });
13
298
  }
14
299
  }
15
300
  exports.BabysitterRuntimeError = BabysitterRuntimeError;
301
+ /**
302
+ * Type guard to check if an object is BabysitterErrorOptions vs legacy details
303
+ */
304
+ function isErrorOptions(obj) {
305
+ if (!obj || typeof obj !== "object")
306
+ return false;
307
+ const keys = Object.keys(obj);
308
+ const optionKeys = ["category", "suggestions", "nextSteps", "details", "cause"];
309
+ return keys.some((key) => optionKeys.includes(key));
310
+ }
16
311
  class BabysitterIntrinsicError extends BabysitterRuntimeError {
17
312
  isIntrinsic = true;
18
- constructor(name, message, details) {
19
- super(name, message, details);
313
+ constructor(name, message, options) {
314
+ super(name, message, options);
20
315
  }
21
316
  }
22
317
  exports.BabysitterIntrinsicError = BabysitterIntrinsicError;
23
318
  class EffectRequestedError extends BabysitterIntrinsicError {
24
319
  action;
25
320
  constructor(action) {
26
- super("EffectRequestedError", `Effect ${action.effectId} requested`, { action });
321
+ super("EffectRequestedError", `Effect ${action.effectId} requested`, { details: { action } });
27
322
  this.action = action;
28
323
  }
29
324
  }
@@ -31,7 +326,7 @@ exports.EffectRequestedError = EffectRequestedError;
31
326
  class EffectPendingError extends BabysitterIntrinsicError {
32
327
  action;
33
328
  constructor(action) {
34
- super("EffectPendingError", `Effect ${action.effectId} pending`, { action });
329
+ super("EffectPendingError", `Effect ${action.effectId} pending`, { details: { action } });
35
330
  this.action = action;
36
331
  }
37
332
  }
@@ -41,8 +336,10 @@ class ParallelPendingError extends BabysitterIntrinsicError {
41
336
  effects;
42
337
  constructor(batch) {
43
338
  super("ParallelPendingError", "One or more parallel invocations are pending", {
44
- payload: (0, batching_1.toParallelPendingPayload)(batch),
45
- effects: batch.actions,
339
+ details: {
340
+ payload: (0, batching_1.toParallelPendingPayload)(batch),
341
+ effects: batch.actions,
342
+ },
46
343
  });
47
344
  this.batch = batch;
48
345
  this.effects = batch.actions;
@@ -52,38 +349,142 @@ exports.ParallelPendingError = ParallelPendingError;
52
349
  class InvocationCollisionError extends BabysitterRuntimeError {
53
350
  invocationKey;
54
351
  constructor(invocationKey) {
55
- super("InvocationCollisionError", `Invocation key ${invocationKey} is already in use within this run`, { invocationKey });
352
+ super("InvocationCollisionError", `Invocation key ${invocationKey} is already in use within this run`, {
353
+ category: ErrorCategory.Runtime,
354
+ details: { invocationKey },
355
+ nextSteps: [
356
+ "Ensure unique invocation keys for each task invocation",
357
+ "Check for duplicate task calls in your process",
358
+ ],
359
+ });
56
360
  this.invocationKey = invocationKey;
57
361
  }
58
362
  }
59
363
  exports.InvocationCollisionError = InvocationCollisionError;
60
364
  class RunFailedError extends BabysitterRuntimeError {
61
- constructor(message, details) {
62
- super("RunFailedError", message, details);
365
+ constructor(message, options) {
366
+ super("RunFailedError", message, options);
63
367
  }
64
368
  }
65
369
  exports.RunFailedError = RunFailedError;
66
370
  class MissingProcessContextError extends BabysitterRuntimeError {
67
371
  constructor() {
68
- super("MissingProcessContextError", "No active process context found on the current async call stack");
372
+ super("MissingProcessContextError", "No active process context found on the current async call stack", {
373
+ category: ErrorCategory.Runtime,
374
+ nextSteps: [
375
+ "Ensure you are calling this from within a babysitter process function",
376
+ "Check that async context is properly maintained",
377
+ ],
378
+ });
69
379
  }
70
380
  }
71
381
  exports.MissingProcessContextError = MissingProcessContextError;
72
382
  class InvalidTaskDefinitionError extends BabysitterRuntimeError {
73
383
  constructor(reason) {
74
- super("InvalidTaskDefinitionError", reason);
384
+ super("InvalidTaskDefinitionError", reason, {
385
+ category: ErrorCategory.Validation,
386
+ nextSteps: ["Review the task definition requirements", "Check the task schema documentation"],
387
+ });
75
388
  }
76
389
  }
77
390
  exports.InvalidTaskDefinitionError = InvalidTaskDefinitionError;
78
391
  class InvalidSleepTargetError extends BabysitterRuntimeError {
79
392
  constructor(value) {
80
- super("InvalidSleepTargetError", `Invalid sleep target: ${value}`);
393
+ super("InvalidSleepTargetError", `Invalid sleep target: ${value}`, {
394
+ category: ErrorCategory.Validation,
395
+ nextSteps: [
396
+ "Provide a valid duration (positive number of milliseconds)",
397
+ "Or provide a valid Date object or ISO 8601 date string",
398
+ ],
399
+ });
81
400
  }
82
401
  }
83
402
  exports.InvalidSleepTargetError = InvalidSleepTargetError;
403
+ /**
404
+ * Formats an error with full context including category, suggestions, and next steps
405
+ */
406
+ function formatErrorWithContext(error, options = {}) {
407
+ const { colors = false, includeStack = false, prefix = "" } = options;
408
+ const lines = [];
409
+ // Color helpers (no-op if colors disabled)
410
+ const red = colors ? (s) => `\x1b[31m${s}\x1b[0m` : (s) => s;
411
+ const yellow = colors ? (s) => `\x1b[33m${s}\x1b[0m` : (s) => s;
412
+ const cyan = colors ? (s) => `\x1b[36m${s}\x1b[0m` : (s) => s;
413
+ const dim = colors ? (s) => `\x1b[2m${s}\x1b[0m` : (s) => s;
414
+ const bold = colors ? (s) => `\x1b[1m${s}\x1b[0m` : (s) => s;
415
+ // Main error line
416
+ const isBabysitterError = error instanceof BabysitterRuntimeError;
417
+ const category = isBabysitterError ? error.category : ErrorCategory.Internal;
418
+ const categoryLabel = exports.ERROR_CATEGORY_DESCRIPTIONS[category];
419
+ lines.push(`${prefix}${red(bold("Error:"))} ${error.message}`);
420
+ lines.push(`${prefix}${dim(`[${error.name}] Category: ${categoryLabel}`)}`);
421
+ // Suggestions ("Did you mean?")
422
+ if (isBabysitterError && error.suggestions.length > 0) {
423
+ lines.push("");
424
+ lines.push(`${prefix}${yellow("Did you mean?")}`);
425
+ for (const suggestion of error.suggestions) {
426
+ lines.push(`${prefix} - ${suggestion}`);
427
+ }
428
+ }
429
+ // Next steps
430
+ if (isBabysitterError && error.nextSteps.length > 0) {
431
+ lines.push("");
432
+ lines.push(`${prefix}${cyan("Next Steps:")}`);
433
+ for (const step of error.nextSteps) {
434
+ lines.push(`${prefix} - ${step}`);
435
+ }
436
+ }
437
+ // Stack trace
438
+ if (includeStack && error.stack) {
439
+ lines.push("");
440
+ lines.push(`${prefix}${dim("Stack trace:")}`);
441
+ const stackLines = error.stack.split("\n").slice(1); // Skip the error message line
442
+ for (const stackLine of stackLines) {
443
+ lines.push(`${prefix}${dim(stackLine)}`);
444
+ }
445
+ }
446
+ return lines.join("\n");
447
+ }
448
+ /**
449
+ * Formats next steps as a bulleted list
450
+ */
451
+ function formatNextSteps(nextSteps, options = {}) {
452
+ const { prefix = "", colors = false } = options;
453
+ const cyan = colors ? (s) => `\x1b[36m${s}\x1b[0m` : (s) => s;
454
+ if (nextSteps.length === 0) {
455
+ return "";
456
+ }
457
+ const lines = [`${prefix}${cyan("Next Steps:")}`];
458
+ for (const step of nextSteps) {
459
+ lines.push(`${prefix} - ${step}`);
460
+ }
461
+ return lines.join("\n");
462
+ }
463
+ /**
464
+ * Converts an error to a structured JSON-serializable format
465
+ */
466
+ function toStructuredError(error, includeStack = false) {
467
+ const isBabysitterError = error instanceof BabysitterRuntimeError;
468
+ return {
469
+ name: error.name,
470
+ message: error.message,
471
+ category: isBabysitterError ? error.category : ErrorCategory.Internal,
472
+ categoryDescription: exports.ERROR_CATEGORY_DESCRIPTIONS[isBabysitterError ? error.category : ErrorCategory.Internal],
473
+ suggestions: isBabysitterError ? error.suggestions : [],
474
+ nextSteps: isBabysitterError ? error.nextSteps : [],
475
+ details: isBabysitterError ? error.details : undefined,
476
+ stack: includeStack ? error.stack : undefined,
477
+ };
478
+ }
479
+ // ============================================================================
480
+ // Utility Functions
481
+ // ============================================================================
84
482
  function isIntrinsicError(error) {
85
483
  return Boolean(error && typeof error === "object" && error.isIntrinsic);
86
484
  }
485
+ function isBabysitterError(error) {
486
+ return error instanceof BabysitterRuntimeError;
487
+ }
87
488
  function rehydrateSerializedError(data) {
88
489
  const name = data?.name ?? "TaskError";
89
490
  const message = data?.message ?? "Task failed";
@@ -58,6 +58,7 @@ export interface CreateRunOptions {
58
58
  exportName?: string;
59
59
  };
60
60
  request?: string;
61
+ prompt?: string;
61
62
  inputs?: unknown;
62
63
  processRevision?: string;
63
64
  layoutVersion?: string;
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/runtime/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAChE,OAAO,KAAK,EAAE,WAAW,EAAE,OAAO,EAAE,iBAAiB,EAAE,MAAM,g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SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,QAAQ,CAAC,EAAE,UAAU,CAAC;KACvB,CAAC;CACH;AAED,MAAM,WAAW,2BAA2B;IAC1C,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB"}
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Session state management module.
3
+ * Provides utilities for managing babysitter orchestration session state.
4
+ */
5
+ export type { SessionState, SessionFile, SessionInitOptions, SessionAssociateOptions, SessionResumeOptions, SessionStateOptions, SessionUpdateOptions, SessionInitResult, SessionAssociateResult, SessionResumeResult, SessionStateResult, SessionUpdateResult, } from './types';
6
+ export { SessionError, SessionErrorCode } from './types';
7
+ export { DEFAULT_SESSION_STATE, parseYamlFrontmatter, parseSessionState, readSessionFile, sessionFileExists, validateSessionState, getSessionFilePath, } from './parse';
8
+ export { serializeSessionState, createSessionFileContent, writeSessionFile, updateSessionState, deleteSessionFile, getCurrentTimestamp, isoToEpochSeconds, updateIterationTimes, isIterationTooFast, } from './write';
9
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/session/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,YAAY,EACV,YAAY,EACZ,WAAW,EACX,kBAAkB,EAClB,uBAAuB,EACvB,oBAAoB,EACpB,mBAAmB,EACnB,oBAAoB,EACpB,iBAAiB,EACjB,sBAAsB,EACtB,mBAAmB,EACnB,kBAAkB,EAClB,mBAAmB,GACpB,MAAM,SAAS,CAAC;AAEjB,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAGzD,OAAO,EACL,qBAAqB,EACrB,oBAAoB,EACpB,iBAAiB,EACjB,eAAe,EACf,iBAAiB,EACjB,oBAAoB,EACpB,kBAAkB,GACnB,MAAM,SAAS,CAAC;AAGjB,OAAO,EACL,qBAAqB,EACrB,wBAAwB,EACxB,gBAAgB,EAChB,kBAAkB,EAClB,iBAAiB,EACjB,mBAAmB,EACnB,iBAAiB,EACjB,oBAAoB,EACpB,kBAAkB,GACnB,MAAM,SAAS,CAAC"}
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ /**
3
+ * Session state management module.
4
+ * Provides utilities for managing babysitter orchestration session state.
5
+ */
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.isIterationTooFast = exports.updateIterationTimes = exports.isoToEpochSeconds = exports.getCurrentTimestamp = exports.deleteSessionFile = exports.updateSessionState = exports.writeSessionFile = exports.createSessionFileContent = exports.serializeSessionState = exports.getSessionFilePath = exports.validateSessionState = exports.sessionFileExists = exports.readSessionFile = exports.parseSessionState = exports.parseYamlFrontmatter = exports.DEFAULT_SESSION_STATE = exports.SessionErrorCode = exports.SessionError = void 0;
8
+ var types_1 = require("./types");
9
+ Object.defineProperty(exports, "SessionError", { enumerable: true, get: function () { return types_1.SessionError; } });
10
+ Object.defineProperty(exports, "SessionErrorCode", { enumerable: true, get: function () { return types_1.SessionErrorCode; } });
11
+ // Parsing utilities
12
+ var parse_1 = require("./parse");
13
+ Object.defineProperty(exports, "DEFAULT_SESSION_STATE", { enumerable: true, get: function () { return parse_1.DEFAULT_SESSION_STATE; } });
14
+ Object.defineProperty(exports, "parseYamlFrontmatter", { enumerable: true, get: function () { return parse_1.parseYamlFrontmatter; } });
15
+ Object.defineProperty(exports, "parseSessionState", { enumerable: true, get: function () { return parse_1.parseSessionState; } });
16
+ Object.defineProperty(exports, "readSessionFile", { enumerable: true, get: function () { return parse_1.readSessionFile; } });
17
+ Object.defineProperty(exports, "sessionFileExists", { enumerable: true, get: function () { return parse_1.sessionFileExists; } });
18
+ Object.defineProperty(exports, "validateSessionState", { enumerable: true, get: function () { return parse_1.validateSessionState; } });
19
+ Object.defineProperty(exports, "getSessionFilePath", { enumerable: true, get: function () { return parse_1.getSessionFilePath; } });
20
+ // Writing utilities
21
+ var write_1 = require("./write");
22
+ Object.defineProperty(exports, "serializeSessionState", { enumerable: true, get: function () { return write_1.serializeSessionState; } });
23
+ Object.defineProperty(exports, "createSessionFileContent", { enumerable: true, get: function () { return write_1.createSessionFileContent; } });
24
+ Object.defineProperty(exports, "writeSessionFile", { enumerable: true, get: function () { return write_1.writeSessionFile; } });
25
+ Object.defineProperty(exports, "updateSessionState", { enumerable: true, get: function () { return write_1.updateSessionState; } });
26
+ Object.defineProperty(exports, "deleteSessionFile", { enumerable: true, get: function () { return write_1.deleteSessionFile; } });
27
+ Object.defineProperty(exports, "getCurrentTimestamp", { enumerable: true, get: function () { return write_1.getCurrentTimestamp; } });
28
+ Object.defineProperty(exports, "isoToEpochSeconds", { enumerable: true, get: function () { return write_1.isoToEpochSeconds; } });
29
+ Object.defineProperty(exports, "updateIterationTimes", { enumerable: true, get: function () { return write_1.updateIterationTimes; } });
30
+ Object.defineProperty(exports, "isIterationTooFast", { enumerable: true, get: function () { return write_1.isIterationTooFast; } });
@@ -0,0 +1,45 @@
1
+ /**
2
+ * Session state file parsing utilities.
3
+ * Parses markdown files with YAML frontmatter for session state.
4
+ */
5
+ import type { SessionState, SessionFile } from './types';
6
+ /**
7
+ * Default session state values.
8
+ */
9
+ export declare const DEFAULT_SESSION_STATE: SessionState;
10
+ /**
11
+ * Parse YAML frontmatter from a string.
12
+ * Expects format:
13
+ * ```
14
+ * ---
15
+ * key: value
16
+ * ---
17
+ * content
18
+ * ```
19
+ */
20
+ export declare function parseYamlFrontmatter(content: string): {
21
+ frontmatter: Record<string, string>;
22
+ body: string;
23
+ };
24
+ /**
25
+ * Parse session state from YAML frontmatter values.
26
+ */
27
+ export declare function parseSessionState(frontmatter: Record<string, string>): SessionState;
28
+ /**
29
+ * Read and parse a session state file.
30
+ */
31
+ export declare function readSessionFile(filePath: string): Promise<SessionFile>;
32
+ /**
33
+ * Check if a session state file exists.
34
+ */
35
+ export declare function sessionFileExists(filePath: string): Promise<boolean>;
36
+ /**
37
+ * Validate session state values.
38
+ * Throws SessionError if validation fails.
39
+ */
40
+ export declare function validateSessionState(state: SessionState): void;
41
+ /**
42
+ * Get the state file path for a session.
43
+ */
44
+ export declare function getSessionFilePath(stateDir: string, sessionId: string): string;
45
+ //# sourceMappingURL=parse.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parse.d.ts","sourceRoot":"","sources":["../../src/session/parse.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAGzD;;GAEG;AACH,eAAO,MAAM,qBAAqB,EAAE,YAQnC,CAAC;AAEF;;;;;;;;;GASG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,MAAM,GAAG;IAAE,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAuC3G;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,YAAY,CA6BnF;AAED;;GAEG;AACH,wBAAsB,eAAe,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC,CA4B5E;AAED;;GAEG;AACH,wBAAsB,iBAAiB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAO1E;AAED;;;GAGG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,YAAY,GAAG,IAAI,CAgB9D;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM,CAE9E"}