@the-open-engine/zeroshot 6.36.0 → 6.38.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.
- package/cli/index.js +99 -29
- package/cli/lib/setup-scanner-worker.js +2 -9
- package/lib/agent-cli-provider/adapters/claude-recovery.d.ts.map +1 -1
- package/lib/agent-cli-provider/adapters/claude-recovery.js +17 -3
- package/lib/agent-cli-provider/adapters/claude-recovery.js.map +1 -1
- package/lib/agent-cli-provider/adapters/index.d.ts.map +1 -1
- package/lib/agent-cli-provider/adapters/index.js +7 -0
- package/lib/agent-cli-provider/adapters/index.js.map +1 -1
- package/lib/agent-cli-provider/adapters/pi.d.ts.map +1 -1
- package/lib/agent-cli-provider/adapters/pi.js +86 -97
- package/lib/agent-cli-provider/adapters/pi.js.map +1 -1
- package/lib/agent-cli-provider/contract-parse.d.ts.map +1 -1
- package/lib/agent-cli-provider/contract-parse.js +5 -1
- package/lib/agent-cli-provider/contract-parse.js.map +1 -1
- package/lib/agent-cli-provider/invoke-evidence.d.ts.map +1 -1
- package/lib/agent-cli-provider/invoke-evidence.js +8 -1
- package/lib/agent-cli-provider/invoke-evidence.js.map +1 -1
- package/lib/agent-cli-provider/pi/credentials.d.ts +2 -0
- package/lib/agent-cli-provider/pi/credentials.d.ts.map +1 -0
- package/lib/agent-cli-provider/pi/credentials.js +51 -0
- package/lib/agent-cli-provider/pi/credentials.js.map +1 -0
- package/lib/agent-cli-provider/pi/events.d.ts +5 -0
- package/lib/agent-cli-provider/pi/events.d.ts.map +1 -0
- package/lib/agent-cli-provider/pi/events.js +124 -0
- package/lib/agent-cli-provider/pi/events.js.map +1 -0
- package/lib/agent-cli-provider/pi/protocol-state.d.ts +6 -0
- package/lib/agent-cli-provider/pi/protocol-state.d.ts.map +1 -0
- package/lib/agent-cli-provider/pi/protocol-state.js +138 -0
- package/lib/agent-cli-provider/pi/protocol-state.js.map +1 -0
- package/lib/agent-cli-provider/pi/release.d.ts +4 -0
- package/lib/agent-cli-provider/pi/release.d.ts.map +1 -0
- package/lib/agent-cli-provider/pi/release.js +7 -0
- package/lib/agent-cli-provider/pi/release.js.map +1 -0
- package/lib/agent-cli-provider/probe-availability.d.ts +5 -0
- package/lib/agent-cli-provider/probe-availability.d.ts.map +1 -0
- package/lib/agent-cli-provider/probe-availability.js +11 -0
- package/lib/agent-cli-provider/probe-availability.js.map +1 -0
- package/lib/agent-cli-provider/provider-registry.d.ts +13 -9
- package/lib/agent-cli-provider/provider-registry.d.ts.map +1 -1
- package/lib/agent-cli-provider/provider-registry.js +42 -8
- package/lib/agent-cli-provider/provider-registry.js.map +1 -1
- package/lib/agent-cli-provider/single-agent-runtime.d.ts.map +1 -1
- package/lib/agent-cli-provider/single-agent-runtime.js +15 -5
- package/lib/agent-cli-provider/single-agent-runtime.js.map +1 -1
- package/lib/agent-cli-provider/types.d.ts +3 -0
- package/lib/agent-cli-provider/types.d.ts.map +1 -1
- package/lib/agent-cli-provider/types.js.map +1 -1
- package/lib/cluster-worker/engine-adapter.js +9 -1
- package/lib/docker-config.js +6 -1
- package/lib/provider-credential-path.js +36 -0
- package/lib/start-cluster.js +8 -0
- package/npm-shrinkwrap.json +2 -2
- package/package.json +1 -1
- package/src/agent/agent-lifecycle.js +25 -76
- package/src/agent/agent-liveness-poll.js +93 -0
- package/src/agent/agent-task-executor.js +98 -23
- package/src/agent/output-extraction.js +115 -0
- package/src/agent/pi-terminal-lifecycle.js +242 -0
- package/src/agent/provider-control-plane.js +26 -0
- package/src/agent/provider-terminal-failure.js +49 -24
- package/src/agent-cli-provider/adapters/claude-recovery.ts +15 -2
- package/src/agent-cli-provider/adapters/index.ts +6 -0
- package/src/agent-cli-provider/adapters/pi.ts +105 -125
- package/src/agent-cli-provider/contract-parse.ts +8 -1
- package/src/agent-cli-provider/invoke-evidence.ts +11 -1
- package/src/agent-cli-provider/pi/credentials.ts +47 -0
- package/src/agent-cli-provider/pi/events.ts +148 -0
- package/src/agent-cli-provider/pi/protocol-state.ts +163 -0
- package/src/agent-cli-provider/pi/release.ts +4 -0
- package/src/agent-cli-provider/probe-availability.ts +19 -0
- package/src/agent-cli-provider/provider-registry.ts +48 -9
- package/src/agent-cli-provider/single-agent-runtime.ts +27 -6
- package/src/agent-cli-provider/types.ts +3 -0
- package/src/config-validator.js +1 -3
- package/src/foreground-benchmark-files.js +81 -0
- package/src/foreground-benchmark-result.js +233 -0
- package/src/foreground-benchmark-run.js +72 -0
- package/src/isolation-manager.js +43 -29
- package/src/orchestrator.js +33 -1
- package/task-lib/runner.js +7 -0
- package/task-lib/watcher-output-runtime.js +16 -5
package/cli/index.js
CHANGED
|
@@ -73,6 +73,11 @@ const {
|
|
|
73
73
|
resolveEffectiveRunPlan,
|
|
74
74
|
} = require('../lib/start-cluster');
|
|
75
75
|
const { requirePreflight } = require('../src/preflight');
|
|
76
|
+
const {
|
|
77
|
+
exitCodeForResult,
|
|
78
|
+
isForegroundStatusSettled,
|
|
79
|
+
writeForegroundResult,
|
|
80
|
+
} = require('../src/foreground-benchmark-run');
|
|
76
81
|
const {
|
|
77
82
|
createUnsupportedProviderCapabilityError,
|
|
78
83
|
serializeTaskStartupError,
|
|
@@ -251,6 +256,17 @@ function shouldRunDetached(options) {
|
|
|
251
256
|
return options.detach && !process.env.ZEROSHOT_DAEMON;
|
|
252
257
|
}
|
|
253
258
|
|
|
259
|
+
function requireForegroundResultMode(options) {
|
|
260
|
+
if (!options.resultFile) return;
|
|
261
|
+
if (shouldRunDetached(options) || process.env.ZEROSHOT_DAEMON) {
|
|
262
|
+
throw new Error('--result-file requires foreground execution without --detach');
|
|
263
|
+
}
|
|
264
|
+
if (options.pr || options.ship) {
|
|
265
|
+
throw new Error('--result-file is incompatible with --pr and --ship delivery');
|
|
266
|
+
}
|
|
267
|
+
process.env.ZEROSHOT_TASK_EXECUTION_CONTEXT = 'benchmark';
|
|
268
|
+
}
|
|
269
|
+
|
|
254
270
|
function printDetachedClusterStart(plan, clusterId, logPath) {
|
|
255
271
|
const runMode = runModeFromPlan(plan);
|
|
256
272
|
console.log(runMode ? `Started ${clusterId} (${runMode})` : `Started ${clusterId}`);
|
|
@@ -605,65 +621,83 @@ function createForegroundCleanup({
|
|
|
605
621
|
return { stop, stopWithFlush };
|
|
606
622
|
}
|
|
607
623
|
|
|
608
|
-
function
|
|
609
|
-
|
|
624
|
+
function setupForegroundSignalHandler({ orchestrator, clusterId, cleanup, settle, handleSigterm }) {
|
|
625
|
+
let handling = false;
|
|
626
|
+
const handler = async (signal) => {
|
|
627
|
+
if (handling) return;
|
|
628
|
+
handling = true;
|
|
610
629
|
cleanup.stop();
|
|
611
|
-
|
|
612
|
-
console.log(chalk.dim('\n\n--- Interrupted ---'));
|
|
630
|
+
console.log(chalk.dim(`\n\n--- Interrupted (${signal}) ---`));
|
|
613
631
|
|
|
614
632
|
try {
|
|
615
633
|
console.log(chalk.dim(`Stopping cluster ${clusterId}...`));
|
|
616
634
|
await orchestrator.stop(clusterId);
|
|
617
635
|
console.log(chalk.dim(`Cluster ${clusterId} stopped.`));
|
|
636
|
+
settle({ cancelled: true });
|
|
618
637
|
} catch (stopErr) {
|
|
619
|
-
|
|
638
|
+
settle(null, stopErr);
|
|
620
639
|
}
|
|
621
|
-
|
|
622
|
-
process.exit(0);
|
|
623
640
|
};
|
|
624
641
|
|
|
625
|
-
|
|
642
|
+
const onSigint = () => handler('SIGINT');
|
|
643
|
+
const onSigterm = () => handler('SIGTERM');
|
|
644
|
+
process.on('SIGINT', onSigint);
|
|
645
|
+
if (handleSigterm) process.on('SIGTERM', onSigterm);
|
|
626
646
|
return () => {
|
|
627
|
-
process.off('SIGINT',
|
|
647
|
+
process.off('SIGINT', onSigint);
|
|
648
|
+
if (handleSigterm) process.off('SIGTERM', onSigterm);
|
|
628
649
|
};
|
|
629
650
|
}
|
|
630
651
|
|
|
631
|
-
function waitForClusterCompletion(orchestrator, clusterId, cleanup) {
|
|
632
|
-
return new Promise((resolve) => {
|
|
652
|
+
function waitForClusterCompletion(orchestrator, clusterId, cleanup, handleSigterm) {
|
|
653
|
+
return new Promise((resolve, reject) => {
|
|
633
654
|
let checkInterval;
|
|
655
|
+
let settled = false;
|
|
656
|
+
let terminalObservedAt = null;
|
|
657
|
+
let removeSignals = () => {};
|
|
634
658
|
const stopChecking = () => {
|
|
635
659
|
if (checkInterval) {
|
|
636
660
|
clearInterval(checkInterval);
|
|
637
661
|
}
|
|
638
662
|
};
|
|
639
|
-
const
|
|
663
|
+
const settle = (result, error) => {
|
|
664
|
+
if (settled) return;
|
|
665
|
+
settled = true;
|
|
666
|
+
stopChecking();
|
|
667
|
+
removeSignals();
|
|
668
|
+
if (error) reject(error);
|
|
669
|
+
else resolve(result);
|
|
670
|
+
};
|
|
671
|
+
removeSignals = setupForegroundSignalHandler({
|
|
640
672
|
orchestrator,
|
|
641
673
|
clusterId,
|
|
642
674
|
cleanup,
|
|
643
|
-
|
|
675
|
+
settle,
|
|
676
|
+
handleSigterm,
|
|
644
677
|
});
|
|
645
678
|
|
|
646
|
-
const finish = (finalizer) => {
|
|
647
|
-
stopChecking();
|
|
648
|
-
removeSigint();
|
|
649
|
-
finalizer();
|
|
650
|
-
resolve();
|
|
651
|
-
};
|
|
652
|
-
|
|
653
679
|
checkInterval = setInterval(() => {
|
|
654
680
|
try {
|
|
655
681
|
const status = orchestrator.getStatus(clusterId);
|
|
656
|
-
if (status
|
|
657
|
-
|
|
682
|
+
if (isForegroundStatusSettled(status)) {
|
|
683
|
+
cleanup.stopWithFlush();
|
|
684
|
+
settle({ cancelled: false });
|
|
685
|
+
} else if (['stopped', 'killed'].includes(status.state)) {
|
|
686
|
+
terminalObservedAt ??= Date.now();
|
|
687
|
+
if (Date.now() - terminalObservedAt > 30_000) {
|
|
688
|
+
cleanup.stop();
|
|
689
|
+
settle(null, new Error('foreground agent processes did not settle after terminal'));
|
|
690
|
+
}
|
|
658
691
|
}
|
|
659
|
-
} catch {
|
|
660
|
-
|
|
692
|
+
} catch (error) {
|
|
693
|
+
cleanup.stop();
|
|
694
|
+
settle(null, error);
|
|
661
695
|
}
|
|
662
696
|
}, 500);
|
|
663
697
|
});
|
|
664
698
|
}
|
|
665
699
|
|
|
666
|
-
async function streamClusterInForeground(cluster, orchestrator, clusterId, plan) {
|
|
700
|
+
async function streamClusterInForeground(cluster, orchestrator, clusterId, plan, handleSigterm) {
|
|
667
701
|
const sendersWithOutput = new Set();
|
|
668
702
|
const processedMessageIds = new Set();
|
|
669
703
|
|
|
@@ -696,8 +730,34 @@ async function streamClusterInForeground(cluster, orchestrator, clusterId, plan)
|
|
|
696
730
|
sendersWithOutput,
|
|
697
731
|
});
|
|
698
732
|
|
|
699
|
-
await waitForClusterCompletion(orchestrator, clusterId, cleanup);
|
|
700
|
-
|
|
733
|
+
const result = await waitForClusterCompletion(orchestrator, clusterId, cleanup, handleSigterm);
|
|
734
|
+
const label = result.cancelled ? 'cancelled' : 'finished';
|
|
735
|
+
console.log(chalk.dim(`\nCluster ${clusterId} ${label}.`));
|
|
736
|
+
return result;
|
|
737
|
+
}
|
|
738
|
+
|
|
739
|
+
async function finishForegroundRun({ cluster, orchestrator, clusterId, plan, resultPath }) {
|
|
740
|
+
try {
|
|
741
|
+
const foreground = await streamClusterInForeground(
|
|
742
|
+
cluster,
|
|
743
|
+
orchestrator,
|
|
744
|
+
clusterId,
|
|
745
|
+
plan,
|
|
746
|
+
Boolean(resultPath)
|
|
747
|
+
);
|
|
748
|
+
if (!resultPath) return;
|
|
749
|
+
const receipt = writeForegroundResult({
|
|
750
|
+
orchestrator,
|
|
751
|
+
cluster,
|
|
752
|
+
clusterId,
|
|
753
|
+
resultPath,
|
|
754
|
+
cancelled: foreground.cancelled,
|
|
755
|
+
});
|
|
756
|
+
process.exitCode = exitCodeForResult(receipt);
|
|
757
|
+
console.log(chalk.dim(`Result ${receipt.outcome} committed to ${resultPath}`));
|
|
758
|
+
} finally {
|
|
759
|
+
orchestrator.close();
|
|
760
|
+
}
|
|
701
761
|
}
|
|
702
762
|
|
|
703
763
|
function setupDaemonCleanup(orchestrator, clusterId) {
|
|
@@ -2662,6 +2722,10 @@ program
|
|
|
2662
2722
|
'fast'
|
|
2663
2723
|
)
|
|
2664
2724
|
.option('-d, --detach', 'Run in background (default: attach to first agent)')
|
|
2725
|
+
.option(
|
|
2726
|
+
'--result-file <path>',
|
|
2727
|
+
'Atomically write a closed foreground result receipt (incompatible with --detach)'
|
|
2728
|
+
)
|
|
2665
2729
|
.addHelpText(
|
|
2666
2730
|
'after',
|
|
2667
2731
|
`
|
|
@@ -2768,6 +2832,7 @@ Force provider flags: -G (GitHub), -L (GitLab), -J (Jira), -D (DevOps), -N (Line
|
|
|
2768
2832
|
}
|
|
2769
2833
|
|
|
2770
2834
|
const { generateName } = require('../src/name-generator');
|
|
2835
|
+
requireForegroundResultMode(effectiveOptions);
|
|
2771
2836
|
if (shouldRunDetached(effectiveOptions)) {
|
|
2772
2837
|
const clusterId = generateName('cluster');
|
|
2773
2838
|
await spawnDetachedCluster(effectiveOptions, effectiveRunPlan, clusterId, stdinText);
|
|
@@ -2811,8 +2876,13 @@ Force provider flags: -G (GitHub), -L (GitLab), -J (Jira), -D (DevOps), -N (Line
|
|
|
2811
2876
|
}
|
|
2812
2877
|
|
|
2813
2878
|
if (!process.env.ZEROSHOT_DAEMON) {
|
|
2814
|
-
await
|
|
2815
|
-
|
|
2879
|
+
await finishForegroundRun({
|
|
2880
|
+
cluster,
|
|
2881
|
+
orchestrator,
|
|
2882
|
+
clusterId,
|
|
2883
|
+
plan: effectiveRunPlan,
|
|
2884
|
+
resultPath: effectiveOptions.resultFile,
|
|
2885
|
+
});
|
|
2816
2886
|
}
|
|
2817
2887
|
setupDaemonCleanup(orchestrator, clusterId);
|
|
2818
2888
|
} catch (error) {
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
const fs = require('fs');
|
|
2
|
-
const os = require('os');
|
|
3
|
-
const path = require('path');
|
|
4
2
|
const { parentPort, workerData } = require('worker_threads');
|
|
5
3
|
|
|
6
4
|
const { commandExists, getCommandPath } = require('../../lib/provider-detection');
|
|
5
|
+
const { resolveProviderCredentialPaths } = require('../../lib/provider-credential-path');
|
|
7
6
|
const { getProviderMetadata, resolveProviderCommand } = require('../../lib/provider-names');
|
|
8
7
|
const { execSync } = require('../../src/lib/safe-exec');
|
|
9
8
|
|
|
@@ -41,19 +40,13 @@ function probeIssue() {
|
|
|
41
40
|
return checkGhAuth();
|
|
42
41
|
}
|
|
43
42
|
|
|
44
|
-
function expandCredentialPath(value) {
|
|
45
|
-
if (value === '~') return os.homedir();
|
|
46
|
-
if (value.startsWith('~/')) return path.join(os.homedir(), value.slice(2));
|
|
47
|
-
return value;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
43
|
function hasCredentialEvidence(metadata) {
|
|
51
44
|
const hasEnvironment = metadata.credentialEnvKeys.some((key) => {
|
|
52
45
|
const value = process.env[key];
|
|
53
46
|
return typeof value === 'string' && value.trim().length > 0;
|
|
54
47
|
});
|
|
55
48
|
if (hasEnvironment) return true;
|
|
56
|
-
return metadata.
|
|
49
|
+
return resolveProviderCredentialPaths(metadata).some((item) => fs.existsSync(item));
|
|
57
50
|
}
|
|
58
51
|
|
|
59
52
|
function providerAuthStatus(id, metadata, available) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"claude-recovery.d.ts","sourceRoot":"","sources":["../../../src/agent-cli-provider/adapters/claude-recovery.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,oBAAoB,yDAAyD,CAAC;AAC3F,eAAO,MAAM,oBAAoB,yBAAyB,CAAC;AAE3D,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,WAAW,wBAAwB;IACvC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC1C,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;CAC7B;AAED,wBAAgB,gCAAgC,CAC9C,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,OAAO,GACZ,kBAAkB,GAAG,IAAI,CAG3B;AAED,wBAAgB,wBAAwB,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,GAAG,MAAM,GAAG,IAAI,
|
|
1
|
+
{"version":3,"file":"claude-recovery.d.ts","sourceRoot":"","sources":["../../../src/agent-cli-provider/adapters/claude-recovery.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,oBAAoB,yDAAyD,CAAC;AAC3F,eAAO,MAAM,oBAAoB,yBAAyB,CAAC;AAE3D,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,WAAW,wBAAwB;IACvC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC1C,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;CAC7B;AAED,wBAAgB,gCAAgC,CAC9C,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,OAAO,GACZ,kBAAkB,GAAG,IAAI,CAG3B;AAED,wBAAgB,wBAAwB,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,GAAG,MAAM,GAAG,IAAI,CAIvF;AAED,wBAAgB,+BAA+B,CAC7C,QAAQ,EAAE,MAAM,EAChB,SAAS,EAAE,MAAM,GAChB,wBAAwB,GAAG,IAAI,CAGjC;AAED,wBAAgB,wCAAwC,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAElF"}
|
|
@@ -17,9 +17,11 @@ function detectProviderStreamingModeError(provider, line) {
|
|
|
17
17
|
return detectClaudeStreamingModeError(line);
|
|
18
18
|
}
|
|
19
19
|
function detectProviderFatalError(provider, line) {
|
|
20
|
-
if (
|
|
21
|
-
return
|
|
22
|
-
|
|
20
|
+
if (isClaudeProvider(provider))
|
|
21
|
+
return detectClaudeFatalError(line);
|
|
22
|
+
if (provider.toLowerCase() === 'pi')
|
|
23
|
+
return detectPiFatalError(line);
|
|
24
|
+
return null;
|
|
23
25
|
}
|
|
24
26
|
function recoverProviderStructuredOutput(provider, sessionId) {
|
|
25
27
|
if (!isClaudeProvider(provider))
|
|
@@ -65,6 +67,18 @@ function detectClaudeFatalError(line) {
|
|
|
65
67
|
}
|
|
66
68
|
return null;
|
|
67
69
|
}
|
|
70
|
+
function detectPiFatalError(line) {
|
|
71
|
+
if (typeof line !== 'string')
|
|
72
|
+
return null;
|
|
73
|
+
const message = line.trim();
|
|
74
|
+
if (/\bno api key found\b/i.test(message)) {
|
|
75
|
+
return 'Pi authentication required: run /login';
|
|
76
|
+
}
|
|
77
|
+
if (/\bmodel\b.*\bnot found\b/i.test(message)) {
|
|
78
|
+
return 'Pi model not found: run pi --list-models';
|
|
79
|
+
}
|
|
80
|
+
return null;
|
|
81
|
+
}
|
|
68
82
|
function findSessionJsonlPath(sessionId) {
|
|
69
83
|
const claudeDir = process.env.CLAUDE_CONFIG_DIR || (0, node_path_1.join)((0, node_os_1.homedir)(), '.claude');
|
|
70
84
|
const projectsDir = (0, node_path_1.join)(claudeDir, 'projects');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"claude-recovery.js","sourceRoot":"","sources":["../../../src/agent-cli-provider/adapters/claude-recovery.ts"],"names":[],"mappings":";;;AAkBA,4EAMC;AAED,
|
|
1
|
+
{"version":3,"file":"claude-recovery.js","sourceRoot":"","sources":["../../../src/agent-cli-provider/adapters/claude-recovery.ts"],"names":[],"mappings":";;;AAkBA,4EAMC;AAED,4DAIC;AAED,0EAMC;AAED,4FAEC;AA1CD,qCAAgE;AAChE,qCAAkC;AAClC,yCAAiC;AACjC,kCAA4D;AAE/C,QAAA,oBAAoB,GAAG,sDAAsD,CAAC;AAC9E,QAAA,oBAAoB,GAAG,sBAAsB,CAAC;AAY3D,S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AC,CAAC,EAAE,KAAK,EAAE,CAAC;KACrC,CAAC;AACJ,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/agent-cli-provider/adapters/index.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EACV,2BAA2B,EAC3B,WAAW,EACX,mBAAmB,EACnB,iBAAiB,EACjB,cAAc,EACd,UAAU,EACV,WAAW,EACX,eAAe,EACf,UAAU,EACV,iBAAiB,EAClB,MAAM,UAAU,CAAC;AAClB,OAAO,EACL,oBAAoB,EACpB,oBAAoB,EACpB,wBAAwB,EACxB,gCAAgC,EAChC,+BAA+B,EAC/B,wCAAwC,EACxC,KAAK,kBAAkB,EACvB,KAAK,wBAAwB,GAC9B,MAAM,mBAAmB,CAAC;AAgB3B,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,iBAAiB,GAAG,MAAM,GAAG,eAAe,CAIpF;AAED,wBAAgB,oBAAoB,IAAI,SAAS,UAAU,EAAE,CAE5D;AAED,wBAAgB,oBAAoB,CAClC,YAAY,EAAE,iBAAiB,GAAG,MAAM,EACxC,OAAO,EAAE,MAAM,EACf,OAAO,CAAC,EAAE,2BAA2B,GACpC,WAAW,CAUb;AAED,wBAAgB,kBAAkB,CAChC,YAAY,EAAE,iBAAiB,GAAG,MAAM,EACxC,KAAK,EAAE,MAAM,GACZ,SAAS,WAAW,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/agent-cli-provider/adapters/index.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EACV,2BAA2B,EAC3B,WAAW,EACX,mBAAmB,EACnB,iBAAiB,EACjB,cAAc,EACd,UAAU,EACV,WAAW,EACX,eAAe,EACf,UAAU,EACV,iBAAiB,EAClB,MAAM,UAAU,CAAC;AAClB,OAAO,EACL,oBAAoB,EACpB,oBAAoB,EACpB,wBAAwB,EACxB,gCAAgC,EAChC,+BAA+B,EAC/B,wCAAwC,EACxC,KAAK,kBAAkB,EACvB,KAAK,wBAAwB,GAC9B,MAAM,mBAAmB,CAAC;AAgB3B,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,iBAAiB,GAAG,MAAM,GAAG,eAAe,CAIpF;AAED,wBAAgB,oBAAoB,IAAI,SAAS,UAAU,EAAE,CAE5D;AAED,wBAAgB,oBAAoB,CAClC,YAAY,EAAE,iBAAiB,GAAG,MAAM,EACxC,OAAO,EAAE,MAAM,EACf,OAAO,CAAC,EAAE,2BAA2B,GACpC,WAAW,CAUb;AAED,wBAAgB,kBAAkB,CAChC,YAAY,EAAE,iBAAiB,GAAG,MAAM,EACxC,KAAK,EAAE,MAAM,GACZ,SAAS,WAAW,EAAE,CAyBxB;AAED,wBAAgB,wBAAwB,CACtC,YAAY,EAAE,iBAAiB,GAAG,MAAM,EACxC,IAAI,EAAE,MAAM,GACX,MAAM,GAAG,IAAI,CAKf;AAED,wBAAgB,gBAAgB,CAC9B,YAAY,EAAE,iBAAiB,GAAG,MAAM,EACxC,KAAK,EAAE,UAAU,EACjB,SAAS,CAAC,EAAE,cAAc,GACzB,iBAAiB,CAEnB;AAED,wBAAgB,qBAAqB,CACnC,YAAY,EAAE,iBAAiB,GAAG,MAAM,EACxC,KAAK,EAAE,OAAO,GACb,mBAAmB,CAErB"}
|
|
@@ -62,6 +62,13 @@ function parseProviderChunk(providerName, chunk) {
|
|
|
62
62
|
events.push(event);
|
|
63
63
|
}
|
|
64
64
|
}
|
|
65
|
+
const finalEvent = adapter.finishParsing?.(state);
|
|
66
|
+
if (finalEvent) {
|
|
67
|
+
if (isOutputEventArray(finalEvent))
|
|
68
|
+
events.push(...finalEvent);
|
|
69
|
+
else
|
|
70
|
+
events.push(finalEvent);
|
|
71
|
+
}
|
|
65
72
|
return events;
|
|
66
73
|
}
|
|
67
74
|
function extractProviderSessionId(providerName, line) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/agent-cli-provider/adapters/index.ts"],"names":[],"mappings":";;;AA6CA,gDAIC;AAED,oDAEC;AAED,oDAcC;AAED,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/agent-cli-provider/adapters/index.ts"],"names":[],"mappings":";;;AA6CA,gDAIC;AAED,oDAEC;AAED,oDAcC;AAED,gDA4BC;AAED,4DAQC;AAED,4CAMC;AAED,sDAKC;AA5HD,8CAAqD;AACrD,sCAA+D;AAC/D,4DAK8B;AAa9B,qDAS2B;AARzB,uHAAA,oBAAoB,OAAA;AACpB,uHAAA,oBAAoB,OAAA;AACpB,2HAAA,wBAAwB,OAAA;AACxB,mIAAA,gCAAgC,OAAA;AAChC,kIAAA,+BAA+B,OAAA;AAC/B,2IAAA,wCAAwC,OAAA;AAK1C,SAAS,kBAAkB,CACzB,KAA2C;IAE3C,OAAO,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;AAC9B,CAAC;AAED,SAAS,oBAAoB,CAAC,QAAoB;IAChD,OAAO,IAAA,4CAAwB,EAAC,QAAQ,CAAC,CAAC,OAAO,CAAC;AACpD,CAAC;AAED,SAAS,YAAY,CAAC,IAAY;IAChC,OAAQ,+BAAiC,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;AAC3D,CAAC;AAED,SAAgB,kBAAkB,CAAC,IAAgC;IACjE,MAAM,UAAU,GAAG,IAAA,yCAAqB,EAAC,IAAI,IAAI,EAAE,CAAC,CAAC;IACrD,IAAI,YAAY,CAAC,UAAU,CAAC;QAAE,OAAO,oBAAoB,CAAC,UAAU,CAAC,CAAC;IACtE,MAAM,IAAI,KAAK,CAAC,qBAAqB,IAAI,YAAY,+BAAW,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;AACjF,CAAC;AAED,SAAgB,oBAAoB;IAClC,OAAO,+BAAW,CAAC;AACrB,CAAC;AAED,SAAgB,oBAAoB,CAClC,YAAwC,EACxC,OAAe,EACf,OAAqC;IAErC,MAA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B,CAAC,UAAU,CAAC;YAAE,MAAM,CAAC,IAAI,CAAC,GAAG,UAAU,CAAC,CAAC;;YAC1D,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;IAC/B,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,SAAgB,wBAAwB,CACtC,YAAwC,EACxC,IAAY;IAEZ,MAAM,OAAO,GAAG,kBAAkB,CAAC,YAAY,IAAI,QAAQ,CAAC,CAAC;IAC7D,MAAM,OAAO,GAAG,IAAA,iCAAoB,EAAC,IAAI,CAAC,CAAC;IAC3C,IAAI,CAAC,OAAO,IAAI,CAAC,OAAO,CAAC,gBAAgB;QAAE,OAAO,IAAI,CAAC;IACvD,OAAO,OAAO,CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAC;AAC3C,CAAC;AAED,SAAgB,gBAAgB,CAC9B,YAAwC,EACxC,KAAiB,EACjB,SAA0B;IAE1B,OAAO,kBAAkB,CAAC,YAAY,CAAC,CAAC,gBAAgB,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC;AAC7E,CAAC;AAED,SAAgB,qBAAqB,CACnC,YAAwC,EACxC,KAAc;IAEd,OAAO,kBAAkB,CAAC,YAAY,CAAC,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;AAC/D,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pi.d.ts","sourceRoot":"","sources":["../../../src/agent-cli-provider/adapters/pi.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"pi.d.ts","sourceRoot":"","sources":["../../../src/agent-cli-provider/adapters/pi.ts"],"names":[],"mappings":"AAMA,OAAO,EASL,KAAK,eAAe,EAGrB,MAAM,UAAU,CAAC;AA8NlB,eAAO,MAAM,SAAS,EAAE,eAmBvB,CAAC"}
|
|
@@ -3,50 +3,93 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.piAdapter = void 0;
|
|
4
4
|
const schema_1 = require("../schema");
|
|
5
5
|
const contract_errors_1 = require("../contract-errors");
|
|
6
|
-
const assistant_stream_1 = require("../assistant-stream");
|
|
7
6
|
const json_1 = require("../json");
|
|
7
|
+
const credentials_1 = require("../pi/credentials");
|
|
8
|
+
const events_1 = require("../pi/events");
|
|
9
|
+
const release_1 = require("../pi/release");
|
|
8
10
|
const common_1 = require("./common");
|
|
9
11
|
const MODEL_CATALOG = {};
|
|
10
12
|
const LEVEL_MAPPING = {
|
|
11
|
-
level1: { rank: 1, model: null },
|
|
12
|
-
level2: { rank: 2, model: null },
|
|
13
|
-
level3: { rank: 3, model: null },
|
|
13
|
+
level1: { rank: 1, model: null, reasoningEffort: 'low' },
|
|
14
|
+
level2: { rank: 2, model: null, reasoningEffort: 'medium' },
|
|
15
|
+
level3: { rank: 3, model: null, reasoningEffort: 'high' },
|
|
14
16
|
};
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
'turn_start',
|
|
20
|
-
'queue_update',
|
|
21
|
-
'compaction_start',
|
|
22
|
-
'compaction_end',
|
|
23
|
-
'auto_retry_start',
|
|
24
|
-
'auto_retry_end',
|
|
25
|
-
]);
|
|
26
|
-
function detectCliFeatures(helpText) {
|
|
17
|
+
function supportsFlag(help, assumeCurrent, versionMatches, pattern) {
|
|
18
|
+
return versionMatches && (assumeCurrent || pattern.test(help));
|
|
19
|
+
}
|
|
20
|
+
function detectCliFeatures(helpText, versionText) {
|
|
27
21
|
const help = helpText ?? '';
|
|
28
|
-
const
|
|
22
|
+
const versionMatches = (0, common_1.isCliVersionAtLeast)(versionText, release_1.PI_SUPPORTED_VERSION);
|
|
23
|
+
const assumeCurrent = !help && versionMatches;
|
|
29
24
|
return {
|
|
30
25
|
provider: 'pi',
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
26
|
+
versionMatches,
|
|
27
|
+
supportsJsonMode: supportsFlag(help, assumeCurrent, versionMatches, /--mode\b/) &&
|
|
28
|
+
(assumeCurrent || /\bjson\b/.test(help)),
|
|
29
|
+
supportsModel: supportsFlag(help, assumeCurrent, versionMatches, /--model\b/),
|
|
30
|
+
supportsThinking: supportsFlag(help, assumeCurrent, versionMatches, /--thinking\b/),
|
|
31
|
+
supportsNoSession: supportsFlag(help, assumeCurrent, versionMatches, /--no-session\b/),
|
|
32
|
+
supportsNoExtensions: supportsFlag(help, assumeCurrent, versionMatches, /--no-extensions\b/),
|
|
33
|
+
supportsNoSkills: supportsFlag(help, assumeCurrent, versionMatches, /--no-skills\b/),
|
|
34
|
+
supportsNoPromptTemplates: supportsFlag(help, assumeCurrent, versionMatches, /--no-prompt-templates\b/),
|
|
35
|
+
supportsNoContextFiles: supportsFlag(help, assumeCurrent, versionMatches, /--no-context-files\b/),
|
|
36
|
+
supportsNoApprove: supportsFlag(help, assumeCurrent, versionMatches, /--no-approve\b/),
|
|
37
|
+
unknown: !help || !(versionText ?? '').trim(),
|
|
40
38
|
};
|
|
41
39
|
}
|
|
40
|
+
function assertRequiredControls(options) {
|
|
41
|
+
const features = (0, common_1.optionFeatures)(options);
|
|
42
|
+
if (features.versionMatches !== true) {
|
|
43
|
+
throw (0, contract_errors_1.contractError)({
|
|
44
|
+
code: 'invalid-field',
|
|
45
|
+
field: 'options.cliFeatures.versionMatches',
|
|
46
|
+
exitCode: 2,
|
|
47
|
+
message: `Pi ${release_1.PI_SUPPORTED_VERSION} or newer is required for the agent_settled JSON protocol. ` +
|
|
48
|
+
`Upgrade with: npm install -g --ignore-scripts ` +
|
|
49
|
+
`@earendil-works/pi-coding-agent@${release_1.PI_SUPPORTED_VERSION}`,
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
const required = [
|
|
53
|
+
['supportsJsonMode', '--mode json'],
|
|
54
|
+
['supportsNoSession', '--no-session'],
|
|
55
|
+
['supportsNoSkills', '--no-skills'],
|
|
56
|
+
['supportsNoPromptTemplates', '--no-prompt-templates'],
|
|
57
|
+
['supportsNoContextFiles', '--no-context-files'],
|
|
58
|
+
['supportsNoApprove', '--no-approve'],
|
|
59
|
+
];
|
|
60
|
+
for (const [field, flag] of required) {
|
|
61
|
+
if (features[field] !== false)
|
|
62
|
+
continue;
|
|
63
|
+
throw (0, contract_errors_1.contractError)({
|
|
64
|
+
code: 'invalid-field',
|
|
65
|
+
field: `options.cliFeatures.${field}`,
|
|
66
|
+
exitCode: 2,
|
|
67
|
+
message: `Pi ${release_1.PI_SUPPORTED_VERSION}+ support for ${flag} is required for Zeroshot execution.`,
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
if (options.modelSpec?.model && features.supportsModel === false) {
|
|
71
|
+
throw (0, contract_errors_1.contractError)({
|
|
72
|
+
code: 'invalid-field',
|
|
73
|
+
field: 'options.cliFeatures.supportsModel',
|
|
74
|
+
exitCode: 2,
|
|
75
|
+
message: `Pi ${release_1.PI_SUPPORTED_VERSION}+ support for --model is required for explicit model selection.`,
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
if (options.modelSpec?.reasoningEffort && features.supportsThinking === false) {
|
|
79
|
+
throw (0, contract_errors_1.contractError)({
|
|
80
|
+
code: 'invalid-field',
|
|
81
|
+
field: 'options.cliFeatures.supportsThinking',
|
|
82
|
+
exitCode: 2,
|
|
83
|
+
message: `Pi ${release_1.PI_SUPPORTED_VERSION}+ support for --thinking is required for reasoning effort.`,
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
}
|
|
42
87
|
function addRequiredArgs(args, options) {
|
|
43
88
|
const features = (0, common_1.optionFeatures)(options);
|
|
44
89
|
if (features.supportsJsonMode !== false)
|
|
45
90
|
args.push('--mode', 'json');
|
|
46
91
|
if (features.supportsNoSession !== false)
|
|
47
92
|
args.push('--no-session');
|
|
48
|
-
if (features.supportsNoExtensions !== false)
|
|
49
|
-
args.push('--no-extensions');
|
|
50
93
|
if (features.supportsNoSkills !== false)
|
|
51
94
|
args.push('--no-skills');
|
|
52
95
|
if (features.supportsNoPromptTemplates !== false)
|
|
@@ -61,6 +104,9 @@ function addOptionalArgs(args, options) {
|
|
|
61
104
|
if (options.modelSpec?.model && features.supportsModel !== false) {
|
|
62
105
|
args.push('--model', options.modelSpec.model);
|
|
63
106
|
}
|
|
107
|
+
if (options.modelSpec?.reasoningEffort && features.supportsThinking !== false) {
|
|
108
|
+
args.push('--thinking', options.modelSpec.reasoningEffort);
|
|
109
|
+
}
|
|
64
110
|
}
|
|
65
111
|
function failClosedUnsupportedSessionControl(options) {
|
|
66
112
|
const hasResumeSessionId = options.resumeSessionId !== undefined;
|
|
@@ -71,29 +117,28 @@ function failClosedUnsupportedSessionControl(options) {
|
|
|
71
117
|
code: 'invalid-field',
|
|
72
118
|
field,
|
|
73
119
|
exitCode: 2,
|
|
74
|
-
message: 'Pi CLI does not support resume/continue session control
|
|
120
|
+
message: 'Pi CLI does not support resume/continue session control with a task-owned identity boundary.',
|
|
75
121
|
});
|
|
76
122
|
}
|
|
77
123
|
function collectWarnings(options) {
|
|
78
|
-
const features = (0, common_1.optionFeatures)(options);
|
|
79
124
|
const warnings = [];
|
|
80
125
|
if (options.jsonSchema) {
|
|
81
126
|
warnings.push((0, common_1.warning)('pi', 'pi-jsonschema', 'Pi CLI does not support provider-native JSON schema; appending schema instructions to the prompt.'));
|
|
82
127
|
}
|
|
83
|
-
if (features.supportsJsonMode === false) {
|
|
84
|
-
warnings.push((0, common_1.warning)('pi', 'pi-json-mode', 'Pi CLI does not advertise --mode json; continuing anyway.'));
|
|
85
|
-
}
|
|
86
128
|
return warnings;
|
|
87
129
|
}
|
|
88
130
|
function buildCommand(context, options = {}) {
|
|
89
131
|
failClosedUnsupportedSessionControl(options);
|
|
132
|
+
assertRequiredControls(options);
|
|
90
133
|
const finalContext = options.jsonSchema
|
|
91
134
|
? (0, schema_1.appendJsonSchemaPrompt)(context, options.jsonSchema)
|
|
92
135
|
: context;
|
|
93
136
|
const args = [];
|
|
94
137
|
addRequiredArgs(args, options);
|
|
95
138
|
addOptionalArgs(args, options);
|
|
96
|
-
|
|
139
|
+
// Pi has no `--` end-of-options sentinel and interprets leading `-`/`@` positional values as
|
|
140
|
+
// flags or file arguments. A leading space keeps arbitrary Zeroshot context in prompt mode.
|
|
141
|
+
args.push(` ${finalContext}`);
|
|
97
142
|
return (0, common_1.commandSpec)({
|
|
98
143
|
binary: 'pi',
|
|
99
144
|
args,
|
|
@@ -102,65 +147,6 @@ function buildCommand(context, options = {}) {
|
|
|
102
147
|
warnings: collectWarnings(options),
|
|
103
148
|
});
|
|
104
149
|
}
|
|
105
|
-
function createPiState() {
|
|
106
|
-
return {
|
|
107
|
-
...(0, common_1.createParserState)('pi'),
|
|
108
|
-
lastAssistantText: '',
|
|
109
|
-
lastAssistantThinking: '',
|
|
110
|
-
};
|
|
111
|
-
}
|
|
112
|
-
function parsePiTurnEnd(event, state) {
|
|
113
|
-
const message = (0, json_1.getRecord)(event, 'message');
|
|
114
|
-
const events = message === null ? [] : [...(0, assistant_stream_1.emitAssistantSnapshot)(message, state)];
|
|
115
|
-
events.push((0, assistant_stream_1.parseTurnEndResult)(event, { failureMessage: 'Pi turn failed' }));
|
|
116
|
-
return events;
|
|
117
|
-
}
|
|
118
|
-
function parseMessageEvent(type, event, state) {
|
|
119
|
-
if (type === 'message_start') {
|
|
120
|
-
(0, assistant_stream_1.resetAssistantSnapshot)((0, json_1.getRecord)(event, 'message'), state);
|
|
121
|
-
return null;
|
|
122
|
-
}
|
|
123
|
-
if (type === 'message_update') {
|
|
124
|
-
const assistantMessageEvent = (0, json_1.getRecord)(event, 'assistantMessageEvent');
|
|
125
|
-
if (assistantMessageEvent !== null) {
|
|
126
|
-
const assistantEvent = (0, assistant_stream_1.parseAssistantDelta)(assistantMessageEvent, state);
|
|
127
|
-
if (assistantEvent !== null)
|
|
128
|
-
return assistantEvent;
|
|
129
|
-
}
|
|
130
|
-
const message = (0, json_1.getRecord)(event, 'message');
|
|
131
|
-
return message === null ? null : (0, assistant_stream_1.emitAssistantSnapshot)(message, state);
|
|
132
|
-
}
|
|
133
|
-
if (type !== 'message_end')
|
|
134
|
-
return undefined;
|
|
135
|
-
const message = (0, json_1.getRecord)(event, 'message');
|
|
136
|
-
return message === null ? null : (0, assistant_stream_1.emitAssistantSnapshot)(message, state);
|
|
137
|
-
}
|
|
138
|
-
function parseToolEvent(type, event, state) {
|
|
139
|
-
if (type === 'tool_execution_start')
|
|
140
|
-
return (0, assistant_stream_1.parseToolExecutionStart)(event, state);
|
|
141
|
-
if (type === 'tool_execution_update')
|
|
142
|
-
return (0, assistant_stream_1.parseToolExecutionUpdate)(event, state);
|
|
143
|
-
if (type === 'tool_execution_end')
|
|
144
|
-
return (0, assistant_stream_1.parseToolExecutionEnd)(event, state);
|
|
145
|
-
return undefined;
|
|
146
|
-
}
|
|
147
|
-
function parseEvent(line, state) {
|
|
148
|
-
const parsed = (0, json_1.tryParseJson)(line);
|
|
149
|
-
if (!(0, json_1.isRecord)(parsed))
|
|
150
|
-
return null;
|
|
151
|
-
const type = (0, json_1.getString)(parsed, 'type');
|
|
152
|
-
if (type === null || IGNORED_EVENT_TYPES.has(type))
|
|
153
|
-
return null;
|
|
154
|
-
const messageEvent = parseMessageEvent(type, parsed, state);
|
|
155
|
-
if (messageEvent !== undefined)
|
|
156
|
-
return messageEvent;
|
|
157
|
-
const toolEvent = parseToolEvent(type, parsed, state);
|
|
158
|
-
if (toolEvent !== undefined)
|
|
159
|
-
return toolEvent;
|
|
160
|
-
if (type === 'turn_end')
|
|
161
|
-
return parsePiTurnEnd(parsed, state);
|
|
162
|
-
return null;
|
|
163
|
-
}
|
|
164
150
|
function resolveModelSpec(level, overrides) {
|
|
165
151
|
return (0, common_1.resolveModelSpecWithConfig)({
|
|
166
152
|
mapping: LEVEL_MAPPING,
|
|
@@ -190,7 +176,9 @@ function classifyError(error) {
|
|
|
190
176
|
/\b(cancelled|canceled|aborted|interrupted)\b/i,
|
|
191
177
|
/\brun\s*\/login\b/i,
|
|
192
178
|
/\bmissing api key\b/i,
|
|
179
|
+
/\bno api key found\b/i,
|
|
193
180
|
/\bno valid authentication\b/i,
|
|
181
|
+
/\bmodel\b.*\bnot found\b/i,
|
|
194
182
|
/\bunknown option\b/i,
|
|
195
183
|
/\bfailed to load\b/i,
|
|
196
184
|
/\bcannot find module\b/i,
|
|
@@ -201,8 +189,8 @@ exports.piAdapter = {
|
|
|
201
189
|
id: 'pi',
|
|
202
190
|
displayName: 'Pi',
|
|
203
191
|
binary: 'pi',
|
|
204
|
-
adapterVersion: '
|
|
205
|
-
credentialEnvKeys:
|
|
192
|
+
adapterVersion: '2',
|
|
193
|
+
credentialEnvKeys: credentials_1.PI_CREDENTIAL_ENV_KEYS,
|
|
206
194
|
modelCatalog: MODEL_CATALOG,
|
|
207
195
|
levelMapping: LEVEL_MAPPING,
|
|
208
196
|
defaultLevel: 'level2',
|
|
@@ -210,8 +198,9 @@ exports.piAdapter = {
|
|
|
210
198
|
defaultMinLevel: 'level1',
|
|
211
199
|
detectCliFeatures,
|
|
212
200
|
buildCommand,
|
|
213
|
-
parseEvent,
|
|
214
|
-
|
|
201
|
+
parseEvent: events_1.parsePiEvent,
|
|
202
|
+
finishParsing: events_1.finishPiParsing,
|
|
203
|
+
createParserState: events_1.createPiParserState,
|
|
215
204
|
resolveModelSpec,
|
|
216
205
|
validateModelId,
|
|
217
206
|
classifyError,
|