@the-open-engine/zeroshot 6.39.2 → 6.40.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (53) hide show
  1. package/README.md +12 -0
  2. package/cli/agent-provider-boundary.js +19 -0
  3. package/cli/agent-provider-boundary.ts +79 -0
  4. package/cli/export-stream.js +94 -0
  5. package/cli/export-stream.ts +118 -0
  6. package/cli/index.js +102 -54
  7. package/cli/json-export.js +2 -38
  8. package/cli/json-export.ts +2 -56
  9. package/cli/semantic-canonical.js +60 -0
  10. package/cli/semantic-canonical.ts +59 -0
  11. package/cli/semantic-contract.js +97 -0
  12. package/cli/semantic-contract.ts +153 -0
  13. package/cli/semantic-events.js +53 -0
  14. package/cli/semantic-events.ts +65 -0
  15. package/cli/semantic-evidence.js +63 -0
  16. package/cli/semantic-evidence.ts +65 -0
  17. package/cli/semantic-export.js +186 -0
  18. package/cli/semantic-export.ts +245 -0
  19. package/cli/semantic-json.js +69 -0
  20. package/cli/semantic-json.ts +69 -0
  21. package/cli/semantic-line-scanner.js +56 -0
  22. package/cli/semantic-line-scanner.ts +54 -0
  23. package/cli/semantic-parser.js +78 -0
  24. package/cli/semantic-parser.ts +95 -0
  25. package/cli/semantic-provider-line.js +91 -0
  26. package/cli/semantic-provider-line.ts +106 -0
  27. package/cli/trace-evidence.js +86 -0
  28. package/cli/trace-evidence.ts +115 -0
  29. package/cli/trace-export.js +120 -0
  30. package/cli/trace-export.ts +164 -0
  31. package/cli/trace-output-record.js +15 -0
  32. package/cli/trace-output-record.ts +18 -0
  33. package/cli/trace-output.js +98 -0
  34. package/cli/trace-output.ts +119 -0
  35. package/lib/agent-cli-provider/log-prefix.d.ts.map +1 -1
  36. package/lib/agent-cli-provider/log-prefix.js +8 -6
  37. package/lib/agent-cli-provider/log-prefix.js.map +1 -1
  38. package/lib/stream-json-parser.js +6 -5
  39. package/npm-shrinkwrap.json +2 -2
  40. package/package.json +6 -4
  41. package/src/agent/agent-task-executor.js +36 -40
  42. package/src/agent/output-extraction-json.js +5 -6
  43. package/src/agent/output-extraction-json.ts +4 -7
  44. package/src/agent-cli-provider/log-prefix.ts +12 -7
  45. package/src/claude-task-runner.js +9 -9
  46. package/src/legacy-lib/stream-json-parser.ts +10 -5
  47. package/src/providers/index.js +1 -19
  48. package/src/task-log-line.d.ts +20 -0
  49. package/src/task-log-line.js +80 -0
  50. package/task-lib/commands/logs.js +5 -8
  51. package/task-lib/sdk-watcher-output.js +31 -0
  52. package/task-lib/sdk-watcher.js +4 -11
  53. package/task-lib/watcher-output-runtime.js +30 -16
@@ -8,6 +8,14 @@ import {
8
8
  supportsProviderStructuredOutputRecovery,
9
9
  } from './provider-helper-runtime.js';
10
10
  import { terminateProcess } from './process-termination.js';
11
+ import { createRequire } from 'module';
12
+
13
+ const require = createRequire(import.meta.url);
14
+ const {
15
+ TASK_LOG_STDOUT_PREFIX,
16
+ formatTaskLogMarker,
17
+ formatTaskLogStdout,
18
+ } = require('../src/task-log-line.js');
11
19
 
12
20
  export const COMMAND_CLEANUP_UNINITIALIZED = Symbol('command-cleanup-uninitialized');
13
21
 
@@ -69,7 +77,7 @@ function createCodexOutputPassthrough({ log, captureProviderSession }) {
69
77
  let offset = 0;
70
78
  while (offset < text.length) {
71
79
  if (atLineStart) {
72
- logged.push(`[${timestamp}]`);
80
+ logged.push(`[${timestamp}]${TASK_LOG_STDOUT_PREFIX}`);
73
81
  atLineStart = false;
74
82
  }
75
83
  const newline = text.indexOf('\n', offset);
@@ -128,7 +136,7 @@ function createBoundedLinePassthrough({
128
136
  }
129
137
  if (byteLength > MAX_WATCHER_CONTROL_RECORD_BYTES) {
130
138
  if (deferRawUntilOverflow && log) {
131
- log(`[${lineTimestamp}]${inspectionParts.join('')}${part}`);
139
+ log(`[${lineTimestamp}]${linePrefix}${inspectionParts.join('')}${part}`);
132
140
  rawOverflowStreaming = true;
133
141
  }
134
142
  inspectable = false;
@@ -310,8 +318,10 @@ export function completeWatcherFailure({ error, source, ...completionOptions })
310
318
  * frames, prompt text, or control payloads.
311
319
  */
312
320
  export function createRpcWatcherOutputRuntime({ log }) {
321
+ log(formatTaskLogMarker(Date.now()));
322
+
313
323
  function logEvent(event) {
314
- log(`[${Date.now()}]${JSON.stringify(event)}\n`);
324
+ log(formatTaskLogStdout(Date.now(), JSON.stringify(event)));
315
325
  }
316
326
 
317
327
  function complete(result) {
@@ -350,6 +360,7 @@ export function createWatcherOutputRuntime({
350
360
  let finalResultJson = null;
351
361
  let streamingModeError = null;
352
362
  let fatalError = null;
363
+ log(formatTaskLogMarker(Date.now()));
353
364
  const captureProviderSession = providerSessionCapture?.captureLine || (() => {});
354
365
  const codexOutputPassthrough =
355
366
  providerName === 'codex' ? createCodexOutputPassthrough({ log, captureProviderSession }) : null;
@@ -358,6 +369,7 @@ export function createWatcherOutputRuntime({
358
369
  : createBoundedLinePassthrough({
359
370
  log,
360
371
  deferRawUntilOverflow: silentJsonMode,
372
+ linePrefix: TASK_LOG_STDOUT_PREFIX,
361
373
  handleLine: (line, timestamp, { oversized }) =>
362
374
  handleOutputLine(line, timestamp, {
363
375
  alreadyLogged: !silentJsonMode,
@@ -366,19 +378,20 @@ export function createWatcherOutputRuntime({
366
378
  });
367
379
  const stderrPassthrough = createBoundedLinePassthrough({
368
380
  log,
369
- // Pi reserves stdout for its JSON protocol and deliberately routes ordinary writes to
370
- // stderr. Keep those diagnostics in the task log with explicit provenance so followers can
371
- // exclude them from strict JSON validation.
372
- linePrefix: providerName === 'pi' ? '[ZEROSHOT][PROVIDER_STDERR] ' : '',
373
- handleLine: (line, timestamp) => maybeHandleFatalError(line, timestamp),
381
+ // Stderr must never be mistaken for provider protocol output. Fatal detection still receives
382
+ // the raw line through handleLine; only the persisted task-log representation is tagged.
383
+ linePrefix: '[ZEROSHOT][PROVIDER_STDERR] ',
384
+ handleLine: (line, timestamp) => maybeHandleFatalError(line, timestamp, true),
374
385
  });
375
386
 
376
- function maybeHandleFatalError(line, timestamp) {
387
+ function maybeHandleFatalError(line, timestamp, rawPersisted = false) {
377
388
  if (fatalError) return false;
378
389
  const detected = detectProviderFatalError(providerName, line);
379
390
  if (!detected) return false;
380
391
  fatalError = detected;
381
- if (silentJsonMode) log(`[${timestamp}]${line}\n`);
392
+ if (silentJsonMode && !rawPersisted) {
393
+ log(formatTaskLogStdout(timestamp, line));
394
+ }
382
395
  log(`[${timestamp}][ZEROSHOT][FATAL] ${detected}\n`);
383
396
  stopProvider(timestamp);
384
397
  return true;
@@ -413,12 +426,12 @@ export function createWatcherOutputRuntime({
413
426
  if (silentJsonMode && !line.trim()) return;
414
427
  // Pi reserves stdout for JSON lifecycle events. Error text inside an assistant message may be
415
428
  // followed by an automatic retry, so only Pi stderr can prove a pre-agent startup failure.
416
- if (providerName !== 'pi') maybeHandleFatalError(line, timestamp);
429
+ if (providerName !== 'pi') maybeHandleFatalError(line, timestamp, alreadyLogged);
417
430
  if (captureStreamingError(line, timestamp)) return;
418
431
  if (silentJsonMode) {
419
432
  maybeCaptureStructuredOutput(line);
420
433
  } else if (!alreadyLogged) {
421
- log(`[${timestamp}]${line}\n`);
434
+ log(formatTaskLogStdout(timestamp, line));
422
435
  }
423
436
  }
424
437
 
@@ -444,11 +457,10 @@ export function createWatcherOutputRuntime({
444
457
  if (silentJsonMode) {
445
458
  finalResultJson = recoveredLine;
446
459
  } else {
447
- log(`[${timestamp}]${recoveredLine}\n`);
460
+ log(formatTaskLogStdout(timestamp, recoveredLine));
448
461
  }
449
462
  } else if (streamingModeError.line) {
450
- const prefix = silentJsonMode ? '' : `[${streamingModeError.timestamp}]`;
451
- log(`${prefix}${streamingModeError.line}\n`);
463
+ log(formatTaskLogStdout(streamingModeError.timestamp, streamingModeError.line));
452
464
  }
453
465
  return recovered;
454
466
  }
@@ -463,7 +475,9 @@ export function createWatcherOutputRuntime({
463
475
  if (stderrBuffer !== null) stderrPassthrough.flush();
464
476
  const recovered = attemptRecovery(code, timestamp);
465
477
  const sessionIdentityError = providerSessionCapture?.getCompletionError() || null;
466
- if (silentJsonMode && finalResultJson) log(`${finalResultJson}\n`);
478
+ if (silentJsonMode && finalResultJson) {
479
+ log(formatTaskLogStdout(timestamp, finalResultJson));
480
+ }
467
481
  if (config.outputFormat !== 'json') {
468
482
  log(`\n${'='.repeat(50)}\n`);
469
483
  log(`Finished: ${new Date().toISOString()}\n`);