@the-open-engine/zeroshot 6.39.1 → 6.39.2
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/README.md +33 -1
- package/cli/index.js +30 -7
- package/cluster-templates/conductor-bootstrap.json +1 -1
- package/lib/agent-cli-provider/adapters/claude.js +1 -1
- package/lib/agent-cli-provider/adapters/claude.js.map +1 -1
- package/lib/agent-cli-provider/adapters/codex.d.ts.map +1 -1
- package/lib/agent-cli-provider/adapters/codex.js +26 -1
- package/lib/agent-cli-provider/adapters/codex.js.map +1 -1
- package/lib/agent-cli-provider/adapters/omp.d.ts.map +1 -1
- package/lib/agent-cli-provider/adapters/omp.js +1 -1
- package/lib/agent-cli-provider/adapters/omp.js.map +1 -1
- package/lib/agent-cli-provider/omp/sdk-environment-policy.d.ts +4 -0
- package/lib/agent-cli-provider/omp/sdk-environment-policy.d.ts.map +1 -0
- package/lib/agent-cli-provider/omp/sdk-environment-policy.js +37 -0
- package/lib/agent-cli-provider/omp/sdk-environment-policy.js.map +1 -0
- package/lib/agent-cli-provider/omp/sdk-process-private-runtime.d.ts.map +1 -1
- package/lib/agent-cli-provider/omp/sdk-process-private-runtime.js +4 -15
- package/lib/agent-cli-provider/omp/sdk-process-private-runtime.js.map +1 -1
- package/lib/agent-cli-provider/omp/sdk-process-result.d.ts +2 -0
- package/lib/agent-cli-provider/omp/sdk-process-result.d.ts.map +1 -1
- package/lib/agent-cli-provider/omp/sdk-process-result.js +2 -2
- package/lib/agent-cli-provider/omp/sdk-process-result.js.map +1 -1
- package/lib/agent-cli-provider/omp/sdk-process-runner.d.ts.map +1 -1
- package/lib/agent-cli-provider/omp/sdk-process-runner.js +6 -1
- package/lib/agent-cli-provider/omp/sdk-process-runner.js.map +1 -1
- package/lib/agent-cli-provider/provider-registry.d.ts +3 -1
- package/lib/agent-cli-provider/provider-registry.d.ts.map +1 -1
- package/lib/agent-cli-provider/provider-registry.js +9 -2
- package/lib/agent-cli-provider/provider-registry.js.map +1 -1
- package/lib/agent-cli-provider/single-agent-runtime.d.ts +4 -1
- package/lib/agent-cli-provider/single-agent-runtime.d.ts.map +1 -1
- package/lib/agent-cli-provider/single-agent-runtime.js +18 -15
- 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-common.js +18 -0
- package/lib/cluster-worker/engine-adapter.js +2 -1
- package/lib/git-remote-utils.js +22 -5
- package/npm-shrinkwrap.json +2 -2
- package/package.json +2 -1
- package/scripts/omp/runtime-identities.js +31 -18
- package/scripts/omp/runtime.js +2 -0
- package/src/agent/agent-lifecycle.js +17 -1
- package/src/agent/output-extraction-failures.js +73 -0
- package/src/agent/output-extraction-failures.ts +100 -0
- package/src/agent/output-extraction-types.ts +5 -0
- package/src/agent/provider-terminal-failure.js +2 -2
- package/src/agent/provider-terminal-failure.ts +4 -2
- package/src/agent-cli-provider/adapters/claude.ts +1 -1
- package/src/agent-cli-provider/adapters/codex.ts +36 -1
- package/src/agent-cli-provider/adapters/omp.ts +2 -1
- package/src/agent-cli-provider/omp/sdk-environment-policy.ts +38 -0
- package/src/agent-cli-provider/omp/sdk-process-private-runtime.ts +4 -16
- package/src/agent-cli-provider/omp/sdk-process-result.ts +4 -2
- package/src/agent-cli-provider/omp/sdk-process-runner.ts +7 -1
- package/src/agent-cli-provider/provider-registry.ts +10 -2
- package/src/agent-cli-provider/single-agent-runtime.ts +24 -15
- package/src/agent-cli-provider/types.ts +3 -0
- package/src/agents/git-pusher-template.js +61 -71
- package/src/attach/socket-paths.js +1 -1
- package/src/attach/socket-paths.ts +1 -1
- package/src/foreground-benchmark-run.js +24 -12
- package/src/legacy-lib/git-remote-utils.ts +23 -5
- package/src/omp-session-verifier.js +8 -5
- package/src/orchestrator.js +42 -0
- package/src/preflight.js +31 -6
- package/src/providers/index.js +3 -3
- package/src/task-execution-context.js +22 -0
- package/src/watcher-prompt-channel.js +1 -1
- package/src/worktree-claude-config.js +25 -0
- package/src/worktree-claude-config.ts +28 -0
- package/task-lib/runner.js +57 -22
|
@@ -19,6 +19,7 @@ import type {
|
|
|
19
19
|
PreparedProviderInvoke,
|
|
20
20
|
} from '../types';
|
|
21
21
|
import type { ProcessResult, ProcessRunnerOptions } from '../process-runner';
|
|
22
|
+
import { isOmpSdkEnvironmentName } from './sdk-environment-policy';
|
|
22
23
|
import { OmpSdkProcessRunnerError } from './sdk-process-error';
|
|
23
24
|
|
|
24
25
|
export { credentialPayload, redactDiagnostic } from './sdk-process-credentials';
|
|
@@ -33,19 +34,6 @@ const PRIVATE_ENV_NAMES = new Set([
|
|
|
33
34
|
'XDG_STATE_HOME',
|
|
34
35
|
'PI_CODING_AGENT_DIR',
|
|
35
36
|
]);
|
|
36
|
-
const MINIMAL_ENV_NAMES = new Set([
|
|
37
|
-
'ALL_PROXY',
|
|
38
|
-
'HTTP_PROXY',
|
|
39
|
-
'HTTPS_PROXY',
|
|
40
|
-
'LANG',
|
|
41
|
-
'LC_ALL',
|
|
42
|
-
'NO_PROXY',
|
|
43
|
-
'PATH',
|
|
44
|
-
'SSL_CERT_DIR',
|
|
45
|
-
'SSL_CERT_FILE',
|
|
46
|
-
'TZ',
|
|
47
|
-
]);
|
|
48
|
-
|
|
49
37
|
export interface OmpSdkPreparedInvocation extends PreparedSingleAgentProviderCommand {
|
|
50
38
|
readonly invoke: PreparedProviderInvoke & {
|
|
51
39
|
readonly lane: 'spawn';
|
|
@@ -119,13 +107,13 @@ export function assertPrepared(
|
|
|
119
107
|
}
|
|
120
108
|
export function assertHostContainment(requirement: OmpSdkContainmentRequirement): void {
|
|
121
109
|
if (
|
|
122
|
-
requirement.mode !== 'host-process-tree' ||
|
|
110
|
+
(requirement.mode !== 'host-process-tree' && requirement.mode !== 'container') ||
|
|
123
111
|
process.platform !== 'linux' ||
|
|
124
112
|
(process.arch !== 'x64' && process.arch !== 'arm64')
|
|
125
113
|
) {
|
|
126
114
|
throw new OmpSdkProcessRunnerError(
|
|
127
115
|
'containment-error',
|
|
128
|
-
'OMP SDK
|
|
116
|
+
'OMP SDK spawn requires the packaged Linux subreaper/pidfd supervisor.'
|
|
129
117
|
);
|
|
130
118
|
}
|
|
131
119
|
}
|
|
@@ -228,7 +216,7 @@ export function childEnvironment(
|
|
|
228
216
|
for (const [name, value] of Object.entries(policy.values)) {
|
|
229
217
|
const normalized = name.toUpperCase();
|
|
230
218
|
if (
|
|
231
|
-
!
|
|
219
|
+
!isOmpSdkEnvironmentName(normalized) ||
|
|
232
220
|
PRIVATE_ENV_NAMES.has(normalized) ||
|
|
233
221
|
/(?:^|_)(?:AUTH|CREDENTIAL|KEY|PASSWORD|SECRET|TOKEN)(?:_|$)/i.test(name)
|
|
234
222
|
) {
|
|
@@ -4,7 +4,7 @@ import type {
|
|
|
4
4
|
OmpSdkProtocolCollector,
|
|
5
5
|
OmpSdkSidecarRequest,
|
|
6
6
|
} from './sdk-protocol';
|
|
7
|
-
import type { OmpSdkCleanupAttestation } from '../types';
|
|
7
|
+
import type { OmpSdkCleanupAttestation, OmpSdkContainmentRequirement } from '../types';
|
|
8
8
|
import { cancelledTerminal, type ChildOutcome } from './sdk-process-io';
|
|
9
9
|
import {
|
|
10
10
|
OmpSdkProcessRunnerError,
|
|
@@ -35,6 +35,7 @@ interface OmpSdkResultContext {
|
|
|
35
35
|
readonly secretValues: readonly string[];
|
|
36
36
|
readonly startedAt: number;
|
|
37
37
|
readonly externalAbort: () => void;
|
|
38
|
+
readonly containmentMode: OmpSdkContainmentRequirement['mode'];
|
|
38
39
|
}
|
|
39
40
|
|
|
40
41
|
export async function collectOmpSdkProcessResult(
|
|
@@ -52,6 +53,7 @@ export async function collectOmpSdkProcessResult(
|
|
|
52
53
|
secretValues,
|
|
53
54
|
startedAt,
|
|
54
55
|
externalAbort,
|
|
56
|
+
containmentMode,
|
|
55
57
|
} = context;
|
|
56
58
|
let rootRemoved = false;
|
|
57
59
|
try {
|
|
@@ -113,7 +115,7 @@ export async function collectOmpSdkProcessResult(
|
|
|
113
115
|
await removePrivateRoot(privateRuntime);
|
|
114
116
|
rootRemoved = true;
|
|
115
117
|
const cleanupAttestation: OmpSdkCleanupAttestation = {
|
|
116
|
-
mode:
|
|
118
|
+
mode: containmentMode,
|
|
117
119
|
terminalBuffered: true,
|
|
118
120
|
descendantsReaped: true,
|
|
119
121
|
clean: true,
|
|
@@ -60,6 +60,10 @@ export async function spawnOmpSdkProcess(
|
|
|
60
60
|
const environment = childEnvironment(prepared.environmentPolicy, privateRuntime);
|
|
61
61
|
const { payload, secretValues } = credentialPayload(prepared.credentialNames, process.env);
|
|
62
62
|
const requestProvider = request.modelSelector.slice(0, request.modelSelector.indexOf('/'));
|
|
63
|
+
const requestContainmentMode =
|
|
64
|
+
request.executionContext === 'docker' || request.executionContext === 'benchmark'
|
|
65
|
+
? 'container'
|
|
66
|
+
: 'host-process-tree';
|
|
63
67
|
const sidecarPath = prepared.commandSpec.args[0] ?? '';
|
|
64
68
|
if (
|
|
65
69
|
!isAbsolute(prepared.commandSpec.binary) ||
|
|
@@ -70,7 +74,8 @@ export async function spawnOmpSdkProcess(
|
|
|
70
74
|
Object.keys(prepared.commandSpec.env).length !== 0 ||
|
|
71
75
|
prepared.semanticIdentity.requestedModelSelector !== request.modelSelector ||
|
|
72
76
|
prepared.semanticIdentity.reasoningEffort !== request.reasoningEffort ||
|
|
73
|
-
prepared.semanticIdentity.provider !== requestProvider
|
|
77
|
+
prepared.semanticIdentity.provider !== requestProvider ||
|
|
78
|
+
prepared.containmentRequirement.mode !== requestContainmentMode
|
|
74
79
|
) {
|
|
75
80
|
payload.fill(0);
|
|
76
81
|
throw new OmpSdkProcessRunnerError(
|
|
@@ -258,6 +263,7 @@ export async function spawnOmpSdkProcess(
|
|
|
258
263
|
secretValues,
|
|
259
264
|
startedAt,
|
|
260
265
|
externalAbort,
|
|
266
|
+
containmentMode: prepared.containmentRequirement.mode,
|
|
261
267
|
});
|
|
262
268
|
|
|
263
269
|
return {
|
|
@@ -128,6 +128,7 @@ interface ProviderRegistryEntryBase {
|
|
|
128
128
|
readonly authInstructions: string;
|
|
129
129
|
readonly credentialPaths: readonly string[];
|
|
130
130
|
readonly credentialEnvKeys: readonly string[];
|
|
131
|
+
readonly configurationEnvKeys?: readonly string[];
|
|
131
132
|
readonly settingsFields: readonly string[];
|
|
132
133
|
readonly settingsDefaults?: Readonly<Record<string, unknown>>;
|
|
133
134
|
readonly settingsValidator?: (
|
|
@@ -185,6 +186,12 @@ const STANDARD_CAPABILITIES: Readonly<
|
|
|
185
186
|
|
|
186
187
|
const CLAUDE_DOCKER_ENV_PASSTHROUGH = [
|
|
187
188
|
'ANTHROPIC_API_KEY',
|
|
189
|
+
'ANTHROPIC_AUTH_TOKEN',
|
|
190
|
+
'ANTHROPIC_BASE_URL',
|
|
191
|
+
'ANTHROPIC_DEFAULT_OPUS_MODEL',
|
|
192
|
+
'ANTHROPIC_DEFAULT_SONNET_MODEL',
|
|
193
|
+
'ANTHROPIC_DEFAULT_HAIKU_MODEL',
|
|
194
|
+
'CLAUDE_CODE_SUBAGENT_MODEL',
|
|
188
195
|
'AWS_BEARER_TOKEN_BEDROCK',
|
|
189
196
|
'AWS_REGION',
|
|
190
197
|
'CLAUDE_CODE_USE_BEDROCK',
|
|
@@ -198,7 +205,7 @@ const PI_EXPLICIT_DOCKER_CREDENTIALS = new Set([
|
|
|
198
205
|
'GOOGLE_APPLICATION_CREDENTIALS',
|
|
199
206
|
]);
|
|
200
207
|
|
|
201
|
-
const
|
|
208
|
+
const PI_AGENT_CONFIGURATION_ENV = [
|
|
202
209
|
'AWS_BEDROCK_FORCE_CACHE',
|
|
203
210
|
'AWS_BEDROCK_FORCE_HTTP1',
|
|
204
211
|
'AWS_BEDROCK_SKIP_AUTH',
|
|
@@ -504,7 +511,7 @@ export const providerRegistry = [
|
|
|
504
511
|
configRoots: ['$HOME/.pi/agent'],
|
|
505
512
|
envPassthrough: [
|
|
506
513
|
...piAdapter.credentialEnvKeys.filter((name) => !PI_EXPLICIT_DOCKER_CREDENTIALS.has(name)),
|
|
507
|
-
...
|
|
514
|
+
...PI_AGENT_CONFIGURATION_ENV,
|
|
508
515
|
],
|
|
509
516
|
},
|
|
510
517
|
defaultLevels: {
|
|
@@ -527,6 +534,7 @@ export const providerRegistry = [
|
|
|
527
534
|
'Manually edit providerSettings.omp in ZEROSHOT_SETTINGS_FILE or $HOME/.zeroshot/settings.json (file 0600, parent directory 0700). Use declared environment or broker variables, an explicit host-only OMP agent directory containing agent.db, or keyless mode; Zeroshot never logs in or stores credential values.',
|
|
528
535
|
credentialPaths: ['~/.omp'],
|
|
529
536
|
credentialEnvKeys: ompAdapter.credentialEnvKeys,
|
|
537
|
+
configurationEnvKeys: PI_AGENT_CONFIGURATION_ENV,
|
|
530
538
|
settingsFields: [
|
|
531
539
|
'transport',
|
|
532
540
|
'minLevel',
|
|
@@ -4,6 +4,7 @@ import * as os from 'node:os';
|
|
|
4
4
|
import * as path from 'node:path';
|
|
5
5
|
|
|
6
6
|
import { getProviderAdapter } from './adapters';
|
|
7
|
+
import { providerCredentialEnv } from './contract-env';
|
|
7
8
|
import { UnsupportedProviderCapabilityError } from './errors';
|
|
8
9
|
import { normalizeGatewayBuildOptions, resolveGatewayConfiguration } from './gateway-tools';
|
|
9
10
|
import { isRecord } from './json';
|
|
@@ -21,6 +22,7 @@ import {
|
|
|
21
22
|
parseExactOmpModelSelector,
|
|
22
23
|
resolveOmpSdkSettings,
|
|
23
24
|
} from './omp/sdk-settings';
|
|
25
|
+
import { ompSdkEnvironmentPolicy } from './omp/sdk-environment-policy';
|
|
24
26
|
import type { ConfiguredOmpSdkSettings } from './omp/sdk-settings';
|
|
25
27
|
import {
|
|
26
28
|
getDefaultProviderId,
|
|
@@ -124,6 +126,10 @@ const commandExistsFn = moduleFunction(providerDetectionModule, 'commandExists')
|
|
|
124
126
|
const getHelpOutputFn = moduleFunction(providerDetectionModule, 'getHelpOutput');
|
|
125
127
|
const getVersionOutputFn = moduleFunction(providerDetectionModule, 'getVersionOutput');
|
|
126
128
|
const resolveOmpSdkRuntimeFn = moduleFunction(ompSdkRuntimeModule, 'resolveOmpSdkRuntime');
|
|
129
|
+
const resolveOmpSdkContainerRuntimeFn = moduleFunction(
|
|
130
|
+
ompSdkRuntimeModule,
|
|
131
|
+
'resolveOmpSdkContainerRuntime'
|
|
132
|
+
);
|
|
127
133
|
|
|
128
134
|
export const resolveOmpTransport = (runtimeSettings?: Record<string, unknown>): 'sdk' | 'rpc' => {
|
|
129
135
|
const settings = runtimeSettings ?? loadRuntimeSettings();
|
|
@@ -325,14 +331,7 @@ function prepareOmpProviderCommand(
|
|
|
325
331
|
}
|
|
326
332
|
|
|
327
333
|
const usesContainerRuntime = executionContext === 'docker' || executionContext === 'benchmark';
|
|
328
|
-
const runtime = usesContainerRuntime
|
|
329
|
-
? {
|
|
330
|
-
bunExecutable: '/opt/zeroshot/node_modules/bun/bin/bun.exe',
|
|
331
|
-
bunVersion: OMP_SDK_BUN_VERSION,
|
|
332
|
-
ompVersion: OMP_SDK_BACKEND_VERSION,
|
|
333
|
-
sidecarPath: '/opt/zeroshot/scripts/omp/sidecar.ts',
|
|
334
|
-
}
|
|
335
|
-
: ompSdkRuntimeAssets();
|
|
334
|
+
const runtime = usesContainerRuntime ? ompSdkContainerRuntimeAssets() : ompSdkRuntimeAssets();
|
|
336
335
|
let privateRoot: string | undefined;
|
|
337
336
|
try {
|
|
338
337
|
privateRoot = fs.mkdtempSync(path.join(os.tmpdir(), 'zeroshot-omp-sdk-request-'));
|
|
@@ -356,10 +355,7 @@ function prepareOmpProviderCommand(
|
|
|
356
355
|
webSearch: { requested: false, effective: false },
|
|
357
356
|
},
|
|
358
357
|
invoke,
|
|
359
|
-
environmentPolicy:
|
|
360
|
-
inherit: 'minimal',
|
|
361
|
-
values: Object.freeze({}),
|
|
362
|
-
},
|
|
358
|
+
environmentPolicy: ompSdkEnvironmentPolicy(),
|
|
363
359
|
credentialNames,
|
|
364
360
|
privateArtifacts: {
|
|
365
361
|
root: privateRoot,
|
|
@@ -483,7 +479,14 @@ function requiredStringValue(value: unknown, field: string): string {
|
|
|
483
479
|
}
|
|
484
480
|
|
|
485
481
|
function ompSdkRuntimeAssets(): OmpSdkRuntimeAssets {
|
|
486
|
-
|
|
482
|
+
return validatedOmpSdkRuntime(resolveOmpSdkRuntimeFn());
|
|
483
|
+
}
|
|
484
|
+
|
|
485
|
+
function ompSdkContainerRuntimeAssets(): OmpSdkRuntimeAssets {
|
|
486
|
+
return validatedOmpSdkRuntime(resolveOmpSdkContainerRuntimeFn());
|
|
487
|
+
}
|
|
488
|
+
|
|
489
|
+
function validatedOmpSdkRuntime(value: unknown): OmpSdkRuntimeAssets {
|
|
487
490
|
if (!isRecord(value))
|
|
488
491
|
throw new Error('Pinned OMP SDK runtime resolver returned invalid evidence.');
|
|
489
492
|
const runtime = {
|
|
@@ -640,7 +643,8 @@ function mergeAcpFailClosedCliFeatures(
|
|
|
640
643
|
export function probeRuntimeProviderCli(
|
|
641
644
|
provider: string,
|
|
642
645
|
evidence?: RuntimeProbeEvidence,
|
|
643
|
-
runtimeSettings?: Record<string, unknown
|
|
646
|
+
runtimeSettings?: Record<string, unknown>,
|
|
647
|
+
context: { readonly executionContext?: OmpSdkExecutionContext } = {}
|
|
644
648
|
): RuntimeProviderProbe {
|
|
645
649
|
const adapter = getProviderAdapter(provider);
|
|
646
650
|
if (adapter.id === 'gateway') {
|
|
@@ -651,7 +655,11 @@ export function probeRuntimeProviderCli(
|
|
|
651
655
|
if (adapter.id === 'omp' && resolveOmpTransport(settings) === 'sdk') {
|
|
652
656
|
const capabilities = adapter.detectCliFeatures('', '');
|
|
653
657
|
try {
|
|
654
|
-
const
|
|
658
|
+
const executionContext = ompExecutionContext(context.executionContext);
|
|
659
|
+
const runtime =
|
|
660
|
+
executionContext === 'docker' || executionContext === 'benchmark'
|
|
661
|
+
? ompSdkContainerRuntimeAssets()
|
|
662
|
+
: ompSdkRuntimeAssets();
|
|
655
663
|
return {
|
|
656
664
|
available: true,
|
|
657
665
|
helpText: 'Pinned bundled OMP SDK sidecar',
|
|
@@ -881,6 +889,7 @@ function resolveRuntimeAuthEnv(
|
|
|
881
889
|
provider: ProviderId,
|
|
882
890
|
settings: Record<string, unknown>
|
|
883
891
|
): Readonly<Record<string, string>> {
|
|
892
|
+
if (provider === 'codex') return providerCredentialEnv(provider);
|
|
884
893
|
if (provider !== 'claude') return {};
|
|
885
894
|
const claudeAuthModule: unknown = require('../../lib/settings/claude-auth');
|
|
886
895
|
const resolveClaudeAuth = moduleFunction(claudeAuthModule, 'resolveClaudeAuth');
|
|
@@ -131,6 +131,7 @@ export interface CodexCliFeatures extends BaseCliFeatures {
|
|
|
131
131
|
readonly supportsIgnoreUserConfig: boolean;
|
|
132
132
|
readonly supportsIgnoreRules: boolean;
|
|
133
133
|
readonly supportsStrictConfig: boolean;
|
|
134
|
+
readonly supportsAddDir: boolean;
|
|
134
135
|
}
|
|
135
136
|
|
|
136
137
|
export interface GeminiCliFeatures extends BaseCliFeatures {
|
|
@@ -447,6 +448,8 @@ export interface BuildProviderCommandOptions {
|
|
|
447
448
|
readonly outputFormat?: OutputFormat;
|
|
448
449
|
readonly jsonSchema?: unknown;
|
|
449
450
|
readonly cwd?: string;
|
|
451
|
+
/** Host paths Codex must be able to write in addition to cwd during normal unattended runs. */
|
|
452
|
+
readonly additionalWritableDirectories?: readonly string[];
|
|
450
453
|
readonly agentName?: string;
|
|
451
454
|
readonly autoApprove?: boolean;
|
|
452
455
|
readonly resumeSessionId?: string;
|
|
@@ -457,18 +457,27 @@ for i in $(seq 1 90); do if timeout 30 gh pr view --json mergedAt --jq .mergedAt
|
|
|
457
457
|
*/
|
|
458
458
|
const SUPPORTED_PLATFORMS = ['github', 'gitlab', 'azure-devops'];
|
|
459
459
|
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
460
|
+
function buildPushCommand(config, gitRemoteArgument) {
|
|
461
|
+
if (config.prName !== 'PR' || !config.createCmd.startsWith('gh pr create')) {
|
|
462
|
+
return `git push -u -- ${gitRemoteArgument} HEAD`;
|
|
463
|
+
}
|
|
464
|
+
|
|
465
|
+
const gitConfig = [
|
|
466
|
+
'url.https://github.com/.insteadOf=git@github.com:',
|
|
467
|
+
'url.https://github.com/.insteadOf=ssh://git@github.com/',
|
|
468
|
+
'credential.helper=',
|
|
469
|
+
'credential.helper=!gh auth git-credential',
|
|
470
|
+
]
|
|
471
|
+
.map((value) => `-c ${quoteShellArgument(value)}`)
|
|
472
|
+
.join(' ');
|
|
473
|
+
return `git ${gitConfig} push -u -- ${gitRemoteArgument} HEAD`;
|
|
474
|
+
}
|
|
475
|
+
|
|
476
|
+
function generateDeliverySteps(config, createNote = '') {
|
|
467
477
|
const {
|
|
468
478
|
prName,
|
|
469
479
|
prNameLower,
|
|
470
480
|
createCmd,
|
|
471
|
-
prUrlExample,
|
|
472
481
|
outputFields,
|
|
473
482
|
requiresPrIdExtraction,
|
|
474
483
|
gitRemote,
|
|
@@ -478,28 +487,13 @@ function generateReviewModePrompt(config) {
|
|
|
478
487
|
const commitMessageArgument = quoteShellArgument(
|
|
479
488
|
`feat: implement #${issueContext.issueNumber} - ${issueContext.issueTitle}`
|
|
480
489
|
);
|
|
490
|
+
const pushCommand = buildPushCommand(config, gitRemoteArgument);
|
|
491
|
+
const createCommandName = createCmd.split(' ').slice(0, 3).join(' ');
|
|
492
|
+
const prUrlInstruction = requiresPrIdExtraction
|
|
493
|
+
? ''
|
|
494
|
+
: ` Save the actual ${prName} URL from the output.`;
|
|
481
495
|
|
|
482
|
-
return
|
|
483
|
-
|
|
484
|
-
Your job is to preserve validator ownership: stage, commit, push, and create the ${prName} for HUMAN REVIEW.
|
|
485
|
-
|
|
486
|
-
Do NOT edit source files, tests, configs, generated artifacts, or lockfiles.
|
|
487
|
-
Do NOT inspect CI logs to debug product code.
|
|
488
|
-
Do NOT resolve merge conflicts or rebase conflicts.
|
|
489
|
-
Do NOT run implementation/debugging workflows after validators hand off.
|
|
490
|
-
Do NOT merge the ${prName} - it is left OPEN for human review.
|
|
491
|
-
Do NOT close the linked issue - it stays open until a human merges the ${prName}.
|
|
492
|
-
|
|
493
|
-
Allowed after validation:
|
|
494
|
-
- git add/status/commit/push
|
|
495
|
-
- ${createCmd.split(' ').slice(0, 3).join(' ')}
|
|
496
|
-
- status-only commands such as ${prName === 'PR' ? 'gh pr view/gh pr checks' : 'the platform PR/MR status command'}
|
|
497
|
-
|
|
498
|
-
If commit hooks, push, ${prName} creation, or conflict handling requires code changes, STOP and report the blocked state in JSON. The implementation and validator agents must fix code and rerun quality gates.
|
|
499
|
-
|
|
500
|
-
## MANDATORY STEPS - EXECUTE EACH ONE IN ORDER - DO NOT SKIP ANY STEP
|
|
501
|
-
|
|
502
|
-
### STEP 1: Stage ALL changes (MANDATORY)
|
|
496
|
+
return `### STEP 1: Stage ALL changes (MANDATORY)
|
|
503
497
|
\`\`\`bash
|
|
504
498
|
git add -A
|
|
505
499
|
\`\`\`
|
|
@@ -519,7 +513,7 @@ Run this command. Do not skip it.
|
|
|
519
513
|
|
|
520
514
|
### STEP 4: Push to ${gitRemote} (MANDATORY)
|
|
521
515
|
\`\`\`bash
|
|
522
|
-
|
|
516
|
+
${pushCommand}
|
|
523
517
|
\`\`\`
|
|
524
518
|
Run this. If it fails, do not edit files, rebase, or resolve conflicts. Output blocked JSON with the failure summary.
|
|
525
519
|
|
|
@@ -529,9 +523,42 @@ Run this. If it fails, do not edit files, rebase, or resolve conflicts. Output b
|
|
|
529
523
|
\`\`\`bash
|
|
530
524
|
${createCmd}
|
|
531
525
|
\`\`\`
|
|
532
|
-
🚨 YOU MUST RUN \`${
|
|
526
|
+
🚨 YOU MUST RUN \`${createCommandName}\`! Outputting a link is NOT creating a ${prName}! 🚨
|
|
533
527
|
The push output shows a "Create a ${prNameLower}" link - IGNORE IT.
|
|
534
|
-
You MUST run the \`${
|
|
528
|
+
You MUST run the \`${createCommandName}\` command above.${prUrlInstruction}${createNote}`;
|
|
529
|
+
}
|
|
530
|
+
|
|
531
|
+
/**
|
|
532
|
+
* Generate the review-mode prompt (--pr without --ship): create the PR/MR and STOP.
|
|
533
|
+
* No merge step, no issue-closing - the PR is left open for human review.
|
|
534
|
+
* @param {Object} config - Platform configuration from PLATFORM_CONFIGS
|
|
535
|
+
* @returns {string} The complete review-mode prompt
|
|
536
|
+
*/
|
|
537
|
+
function generateReviewModePrompt(config) {
|
|
538
|
+
const { prName, createCmd, prUrlExample, outputFields } = config;
|
|
539
|
+
const deliverySteps = generateDeliverySteps(config);
|
|
540
|
+
|
|
541
|
+
return `CRITICAL: ALL VALIDATORS APPROVED. YOU ARE A TRANSPORT-ONLY GIT PUSHER.
|
|
542
|
+
|
|
543
|
+
Your job is to preserve validator ownership: stage, commit, push, and create the ${prName} for HUMAN REVIEW.
|
|
544
|
+
|
|
545
|
+
Do NOT edit source files, tests, configs, generated artifacts, or lockfiles.
|
|
546
|
+
Do NOT inspect CI logs to debug product code.
|
|
547
|
+
Do NOT resolve merge conflicts or rebase conflicts.
|
|
548
|
+
Do NOT run implementation/debugging workflows after validators hand off.
|
|
549
|
+
Do NOT merge the ${prName} - it is left OPEN for human review.
|
|
550
|
+
Do NOT close the linked issue - it stays open until a human merges the ${prName}.
|
|
551
|
+
|
|
552
|
+
Allowed after validation:
|
|
553
|
+
- git add/status/commit/push
|
|
554
|
+
- ${createCmd.split(' ').slice(0, 3).join(' ')}
|
|
555
|
+
- status-only commands such as ${prName === 'PR' ? 'gh pr view/gh pr checks' : 'the platform PR/MR status command'}
|
|
556
|
+
|
|
557
|
+
If commit hooks, push, ${prName} creation, or conflict handling requires code changes, STOP and report the blocked state in JSON. The implementation and validator agents must fix code and rerun quality gates.
|
|
558
|
+
|
|
559
|
+
## MANDATORY STEPS - EXECUTE EACH ONE IN ORDER - DO NOT SKIP ANY STEP
|
|
560
|
+
|
|
561
|
+
${deliverySteps}
|
|
535
562
|
|
|
536
563
|
⚠️ AFTER THE ${prName} IS CREATED, YOU ARE DONE. DO NOT MERGE. DO NOT CLOSE THE ISSUE. ⚠️
|
|
537
564
|
|
|
@@ -578,7 +605,6 @@ If blocked before creating a ${prName}, output:
|
|
|
578
605
|
function generatePrompt(config) {
|
|
579
606
|
const {
|
|
580
607
|
prName,
|
|
581
|
-
prNameLower,
|
|
582
608
|
createCmd,
|
|
583
609
|
mergeCmd,
|
|
584
610
|
mergeFallbackCmd,
|
|
@@ -589,14 +615,9 @@ function generatePrompt(config) {
|
|
|
589
615
|
usesMergeQueue,
|
|
590
616
|
closeIssueMode,
|
|
591
617
|
autoMerge,
|
|
592
|
-
gitRemote,
|
|
593
618
|
issueContext,
|
|
594
619
|
} = config;
|
|
595
|
-
const gitRemoteArgument = quoteShellArgument(gitRemote);
|
|
596
620
|
const issueNumberArgument = quoteShellArgument(issueContext.issueNumber);
|
|
597
|
-
const commitMessageArgument = quoteShellArgument(
|
|
598
|
-
`feat: implement #${issueContext.issueNumber} - ${issueContext.issueTitle}`
|
|
599
|
-
);
|
|
600
621
|
|
|
601
622
|
if (!autoMerge) {
|
|
602
623
|
return generateReviewModePrompt(config);
|
|
@@ -608,6 +629,7 @@ function generatePrompt(config) {
|
|
|
608
629
|
Look for output like: "Created PR 123" or parse the URL for the PR number.
|
|
609
630
|
Save the PR ID to a variable for step 6.`
|
|
610
631
|
: '';
|
|
632
|
+
const deliverySteps = generateDeliverySteps(config, azurePrIdNote);
|
|
611
633
|
|
|
612
634
|
// Azure uses different merge terminology
|
|
613
635
|
const mergeDescription = requiresPrIdExtraction
|
|
@@ -666,39 +688,7 @@ If commit hooks, push, ${prName} creation, merge, CI, or conflict handling requi
|
|
|
666
688
|
|
|
667
689
|
## MANDATORY STEPS - EXECUTE EACH ONE IN ORDER - DO NOT SKIP ANY STEP
|
|
668
690
|
|
|
669
|
-
|
|
670
|
-
\`\`\`bash
|
|
671
|
-
git add -A
|
|
672
|
-
\`\`\`
|
|
673
|
-
Run this command. Do not skip it. If commit fails because hooks/checks fail, do not edit files. Output blocked JSON with the failure summary.
|
|
674
|
-
|
|
675
|
-
### STEP 2: Check what's staged
|
|
676
|
-
\`\`\`bash
|
|
677
|
-
git status
|
|
678
|
-
\`\`\`
|
|
679
|
-
Run this. If nothing to commit, output JSON with ${outputFields.urlField}: null and stop.
|
|
680
|
-
|
|
681
|
-
### STEP 3: Commit the changes (MANDATORY if there are changes)
|
|
682
|
-
\`\`\`bash
|
|
683
|
-
git commit -m ${commitMessageArgument}
|
|
684
|
-
\`\`\`
|
|
685
|
-
Run this command. Do not skip it.
|
|
686
|
-
|
|
687
|
-
### STEP 4: Push to ${gitRemote} (MANDATORY)
|
|
688
|
-
\`\`\`bash
|
|
689
|
-
git push -u -- ${gitRemoteArgument} HEAD
|
|
690
|
-
\`\`\`
|
|
691
|
-
Run this. If it fails, do not edit files, rebase, or resolve conflicts. Output blocked JSON with the failure summary.
|
|
692
|
-
|
|
693
|
-
⚠️ AFTER PUSH YOU ARE NOT DONE! CONTINUE TO STEP 5! ⚠️
|
|
694
|
-
|
|
695
|
-
### STEP 5: CREATE THE ${prName.toUpperCase()} (MANDATORY - YOU MUST RUN THIS COMMAND)
|
|
696
|
-
\`\`\`bash
|
|
697
|
-
${createCmd}
|
|
698
|
-
\`\`\`
|
|
699
|
-
🚨 YOU MUST RUN \`${createCmd.split(' ').slice(0, 3).join(' ')}\`! Outputting a link is NOT creating a ${prName}! 🚨
|
|
700
|
-
The push output shows a "Create a ${prNameLower}" link - IGNORE IT.
|
|
701
|
-
You MUST run the \`${createCmd.split(' ').slice(0, 3).join(' ')}\` command above.${requiresPrIdExtraction ? '' : ` Save the actual ${prName} URL from the output.`}${azurePrIdNote}
|
|
691
|
+
${deliverySteps}
|
|
702
692
|
|
|
703
693
|
⚠️ AFTER ${prName} CREATION YOU ARE NOT DONE! CONTINUE TO STEP 6! ⚠️
|
|
704
694
|
|
|
@@ -3,7 +3,7 @@ const crypto = require("crypto");
|
|
|
3
3
|
const fs = require("fs");
|
|
4
4
|
const os = require("os");
|
|
5
5
|
const path = require("path");
|
|
6
|
-
const SOCKET_ROOT = process.platform === 'win32' ? null :
|
|
6
|
+
const SOCKET_ROOT = process.platform === 'win32' ? null : path.resolve(os.tmpdir());
|
|
7
7
|
const SOCKET_DIR_MODE = 0o700;
|
|
8
8
|
function shortHash(value) {
|
|
9
9
|
return crypto.createHash('sha256').update(value).digest('hex').slice(0, 16);
|
|
@@ -3,7 +3,7 @@ import fs = require('fs');
|
|
|
3
3
|
import os = require('os');
|
|
4
4
|
import path = require('path');
|
|
5
5
|
|
|
6
|
-
const SOCKET_ROOT = process.platform === 'win32' ? null :
|
|
6
|
+
const SOCKET_ROOT = process.platform === 'win32' ? null : path.resolve(os.tmpdir());
|
|
7
7
|
const SOCKET_DIR_MODE = 0o700;
|
|
8
8
|
|
|
9
9
|
function shortHash(value: string): string {
|
|
@@ -4,6 +4,7 @@ const { writeBenchmarkResultBundle } = require('./foreground-benchmark-files');
|
|
|
4
4
|
const TERMINAL_TOPICS = ['CLUSTER_COMPLETE', 'CLUSTER_FAILED'];
|
|
5
5
|
const VERIFIER_ELIGIBLE = new Set(['completed', 'task_failure']);
|
|
6
6
|
const EXIT_CODES = Object.freeze({
|
|
7
|
+
task_failure: 23,
|
|
7
8
|
provider_failure: 20,
|
|
8
9
|
engine_failure: 21,
|
|
9
10
|
cancelled: 22,
|
|
@@ -40,20 +41,24 @@ function requireSettledStatus(orchestrator, clusterId) {
|
|
|
40
41
|
return status;
|
|
41
42
|
}
|
|
42
43
|
|
|
43
|
-
function
|
|
44
|
-
const
|
|
45
|
-
const
|
|
46
|
-
|
|
44
|
+
function buildForegroundResult({ orchestrator, cluster, clusterId, cancelled }) {
|
|
45
|
+
const finalRun = orchestrator.getFinalRun?.(clusterId);
|
|
46
|
+
const status = finalRun?.status || requireSettledStatus(orchestrator, clusterId);
|
|
47
|
+
const terminals = finalRun?.terminalMessages || terminalMessages(cluster, clusterId);
|
|
47
48
|
if (cancelled && terminals.length === 0) {
|
|
48
|
-
|
|
49
|
-
} else {
|
|
50
|
-
result = buildBenchmarkResult({
|
|
51
|
-
runId: clusterId,
|
|
52
|
-
terminalMessages: terminals,
|
|
53
|
-
agents: status.agents,
|
|
54
|
-
});
|
|
49
|
+
return buildCancelledResult({ runId: clusterId, agents: status.agents });
|
|
55
50
|
}
|
|
56
|
-
|
|
51
|
+
return buildBenchmarkResult({
|
|
52
|
+
runId: clusterId,
|
|
53
|
+
terminalMessages: terminals,
|
|
54
|
+
agents: status.agents,
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
function writeForegroundResult({ orchestrator, cluster, clusterId, resultPath, cancelled }) {
|
|
59
|
+
const result = buildForegroundResult({ orchestrator, cluster, clusterId, cancelled });
|
|
60
|
+
const snapshot =
|
|
61
|
+
orchestrator.getFinalRun?.(clusterId)?.snapshot || cluster.messageBus.readSnapshot(clusterId);
|
|
57
62
|
return writeBenchmarkResultBundle(resultPath, result, snapshot);
|
|
58
63
|
}
|
|
59
64
|
|
|
@@ -64,8 +69,15 @@ function exitCodeForResult(result) {
|
|
|
64
69
|
return exitCode;
|
|
65
70
|
}
|
|
66
71
|
|
|
72
|
+
function exitCodeForForegroundResult(result) {
|
|
73
|
+
if (result.outcome === 'completed') return 0;
|
|
74
|
+
return EXIT_CODES[result.outcome] ?? exitCodeForResult(result);
|
|
75
|
+
}
|
|
76
|
+
|
|
67
77
|
module.exports = {
|
|
78
|
+
buildForegroundResult,
|
|
68
79
|
exitCodeForResult,
|
|
80
|
+
exitCodeForForegroundResult,
|
|
69
81
|
isForegroundStatusSettled,
|
|
70
82
|
terminalMessages,
|
|
71
83
|
writeForegroundResult,
|
|
@@ -181,6 +181,25 @@ function parseGitRemoteUrl(remoteUrl: unknown): GitContext | null {
|
|
|
181
181
|
return null;
|
|
182
182
|
}
|
|
183
183
|
|
|
184
|
+
function parseFetchRemoteLine(line: string): readonly [string, string] | null {
|
|
185
|
+
// Partial clones append their filter after the fetch marker, for example
|
|
186
|
+
// `origin https://github.com/org/repo.git (fetch) [blob:none]`.
|
|
187
|
+
const fetchMarker = ' (fetch)';
|
|
188
|
+
const fetchMarkerIndex = line.lastIndexOf(fetchMarker);
|
|
189
|
+
if (fetchMarkerIndex < 1) return null;
|
|
190
|
+
const suffix = line.slice(fetchMarkerIndex + fetchMarker.length);
|
|
191
|
+
if (suffix.length > 0 && !(suffix.startsWith(' [') && suffix.endsWith(']'))) return null;
|
|
192
|
+
|
|
193
|
+
const remoteLine = line.slice(0, fetchMarkerIndex);
|
|
194
|
+
const separatorIndex = remoteLine.search(/\s/);
|
|
195
|
+
if (separatorIndex < 1) {
|
|
196
|
+
return null;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
const remoteUrl = remoteLine.slice(separatorIndex).trim();
|
|
200
|
+
return remoteUrl.length > 0 ? [remoteLine.slice(0, separatorIndex), remoteUrl] : null;
|
|
201
|
+
}
|
|
202
|
+
|
|
184
203
|
/**
|
|
185
204
|
* Detect git repository context from current working directory.
|
|
186
205
|
* Returns provider context extracted from git remote URL.
|
|
@@ -205,15 +224,14 @@ function detectGitContext(cwd = process.cwd()): GitContextWithRemote | null {
|
|
|
205
224
|
|
|
206
225
|
const supportedRemotes = new Map<string, GitContextWithRemote>();
|
|
207
226
|
for (const line of remoteOutput.split(/\r?\n/)) {
|
|
208
|
-
const
|
|
209
|
-
if (!
|
|
227
|
+
const remoteParts = parseFetchRemoteLine(line);
|
|
228
|
+
if (!remoteParts) {
|
|
210
229
|
continue;
|
|
211
230
|
}
|
|
212
231
|
|
|
213
|
-
const remoteCandidate =
|
|
214
|
-
const remoteUrl = match[2];
|
|
232
|
+
const [remoteCandidate, remoteUrl] = remoteParts;
|
|
215
233
|
const remote = normalizeGitRemoteName(remoteCandidate);
|
|
216
|
-
if (!remote
|
|
234
|
+
if (!remote) {
|
|
217
235
|
continue;
|
|
218
236
|
}
|
|
219
237
|
const context = parseGitRemoteUrl(remoteUrl);
|
|
@@ -399,7 +399,10 @@ function streamSessionJsonl(fd, describePath, limits) {
|
|
|
399
399
|
`${describePath} record ${records} is not valid JSON: ${error.message}`
|
|
400
400
|
);
|
|
401
401
|
}
|
|
402
|
-
|
|
402
|
+
// OMP 17.2.1 may reserve its first JSONL record for mutable title metadata before writing the
|
|
403
|
+
// authoritative session record. Accept exactly that one known preamble position; every other
|
|
404
|
+
// ordering still fails closed in parseSessionHeader below.
|
|
405
|
+
if (header === null && !(records === 1 && parsed?.type === 'title')) header = parsed;
|
|
403
406
|
collectCanonicalBlobRefs(parsed, blobRefs, limits);
|
|
404
407
|
}
|
|
405
408
|
|
|
@@ -430,9 +433,9 @@ function streamSessionJsonl(fd, describePath, limits) {
|
|
|
430
433
|
};
|
|
431
434
|
}
|
|
432
435
|
|
|
433
|
-
/** The session
|
|
434
|
-
*
|
|
435
|
-
* to disk and its `cwd` is the workspace the session belongs to. */
|
|
436
|
+
/** The session header (`{type:"session", version, id, cwd, ...}`) is either the first record or
|
|
437
|
+
* follows OMP 17.2.1's single leading title-metadata record. Its `id` is the authoritative session
|
|
438
|
+
* identity written to disk and its `cwd` is the workspace the session belongs to. */
|
|
436
439
|
function parseSessionHeader(header, describePath) {
|
|
437
440
|
if (!header || typeof header !== 'object' || Array.isArray(header)) {
|
|
438
441
|
fail('session-header-missing', `${describePath} has no session header record.`);
|
|
@@ -440,7 +443,7 @@ function parseSessionHeader(header, describePath) {
|
|
|
440
443
|
if (header.type !== 'session') {
|
|
441
444
|
fail(
|
|
442
445
|
'session-header-invalid',
|
|
443
|
-
`${describePath} first record is type ${JSON.stringify(header.type)}, not "session".`
|
|
446
|
+
`${describePath} first non-title-preamble record is type ${JSON.stringify(header.type)}, not "session".`
|
|
444
447
|
);
|
|
445
448
|
}
|
|
446
449
|
if (typeof header.id !== 'string' || header.id.length === 0) {
|