Files
Genarrative/apps/ai-game-creator-shell/scripts/agent-runtime-real-e2e/runtime-state.mjs
T
k88936 5b2318acf3 删除AGC退役后零引用的真实E2E harness 导出与函数
- runtime-state.mjs 删除只被已删套件使用的 4 个 schema 常量(runProfileBinding / autonomousCompletionContract / autonomousPlaytestReceipt / autonomousGameBuildRunProfile)
- assertions/runtime.mjs 删除 runtimePublicStatusMessageId
- harness/project.mjs 删除 productionDefaultGameIndexHtml
- collaboration-policy.mjs 删除 validateSupervisorSwarmIsolatedSpawnInput 及其专属的静态隔离校验函数族
- persistence.mjs 删除 5 个 supervisorSwarmIsolated*Identity 函数
- 移除随之失去用途的 import(hashJsonValue、isolatedJoinDeliveryTarget、supervisorSwarmIsolatedReviews)
2026-09-23 12:07:51 +08:00

991 lines
31 KiB
JavaScript

import { fileURLToPath, path, randomUUID } from './dependencies.mjs';
export const appRoot = path.resolve(
fileURLToPath(new URL('../..', import.meta.url)),
);
export const repoRoot = path.resolve(appRoot, '../..');
export const manifestPath = path.join(appRoot, 'src-tauri/Cargo.toml');
export const configFileName = 'game-creator.config.json';
export const localConfigFileName = 'game-creator.config.local.json';
export const runnerEndpointFileName = 'agent-runner.endpoint.json';
export const sentinelFileName = '.agent-runtime-real-e2e-disposable.json';
export const sentinelSchema =
'genarrative-agent-runtime-real-e2e-disposable.v1';
export const goalAppDataSentinelFileName =
'.agent-runtime-real-e2e-goal-appdata.json';
export const goalAppDataSentinelSchema =
'genarrative-agent-runtime-real-e2e-goal-appdata.v1';
export const responseStreamAppDataSentinelFileName =
'.agent-runtime-real-e2e-response-stream-appdata.json';
export const responseStreamAppDataSentinelSchema =
'genarrative-agent-runtime-real-e2e-response-stream-appdata.v1';
export const webSearchAppDataSentinelFileName =
'.agent-runtime-real-e2e-web-search-appdata.json';
export const webSearchAppDataSentinelSchema =
'genarrative-agent-runtime-real-e2e-web-search-appdata.v1';
export const contextCompactionAppDataSentinelFileName =
'.agent-runtime-real-e2e-context-compaction-appdata.json';
export const contextCompactionAppDataSentinelSchema =
'genarrative-agent-runtime-real-e2e-context-compaction-appdata.v1';
export const scopedAgentsAppDataSentinelFileName =
'.agent-runtime-real-e2e-scoped-agents-appdata.json';
export const scopedAgentsAppDataSentinelSchema =
'genarrative-agent-runtime-real-e2e-scoped-agents-appdata.v1';
export const projectSkillAppDataSentinelFileName =
'.agent-runtime-real-e2e-project-skill-appdata.json';
export const projectSkillAppDataSentinelSchema =
'genarrative-agent-runtime-real-e2e-project-skill-appdata.v1';
export const steerRunnerKillAppDataSentinelFileName =
'.agent-runtime-real-e2e-steer-runner-kill-appdata.json';
export const steerRunnerKillAppDataSentinelSchema =
'genarrative-agent-runtime-real-e2e-steer-runner-kill-appdata.v1';
export const parallelReadAppDataSentinelFileName =
'.agent-runtime-real-e2e-parallel-read-appdata.json';
export const parallelReadAppDataSentinelSchema =
'genarrative-agent-runtime-real-e2e-parallel-read-appdata.v1';
export const supervisorSwarmAppDataSentinelFileName =
'.agent-runtime-real-e2e-supervisor-swarm-appdata.json';
export const supervisorSwarmAppDataSentinelSchema =
'genarrative-agent-runtime-real-e2e-supervisor-swarm-appdata.v1';
export const supervisorSwarmTransientRetryAppDataSentinelFileName =
'.agent-runtime-real-e2e-supervisor-swarm-transient-retry-appdata.json';
export const supervisorSwarmTransientRetryAppDataSentinelSchema =
'genarrative-agent-runtime-real-e2e-supervisor-swarm-transient-retry-appdata.v1';
export const supervisorSwarmFinalReplyTransientRetryAppDataSentinelFileName =
'.agent-runtime-real-e2e-supervisor-swarm-final-reply-transient-retry-appdata.json';
export const supervisorSwarmFinalReplyTransientRetryAppDataSentinelSchema =
'genarrative-agent-runtime-real-e2e-supervisor-swarm-final-reply-transient-retry-appdata.v1';
export const supervisorSwarmToolPlanHandoffRunnerKillAppDataSentinelFileName =
'.agent-runtime-real-e2e-supervisor-swarm-tool-plan-handoff-runner-kill-appdata.json';
export const supervisorSwarmToolPlanHandoffRunnerKillAppDataSentinelSchema =
'genarrative-agent-runtime-real-e2e-supervisor-swarm-tool-plan-handoff-runner-kill-appdata.v1';
export const supervisorSwarmToolPlanHandoffCheckpointFileName =
'.agent-runtime-real-e2e-tool-plan-handoff-checkpoint.json';
export const supervisorSwarmToolPlanHandoffCheckpointSchema =
'game-creator-tool-plan-handoff-runner-kill-checkpoint.v1';
export const supervisorSwarmToolPlanHandoffCheckpointReachedFileName =
'.agent-runtime-real-e2e-tool-plan-handoff-checkpoint-reached.json';
export const supervisorSwarmToolPlanHandoffCheckpointReachedSchema =
'game-creator-tool-plan-handoff-runner-kill-checkpoint-reached.v1';
export const mainAgentId = 'code-prototype';
export const projectSupervisorAgentId = 'project-supervisor';
export const requestedRunId = `real-e2e-${Date.now()}-${randomUUID().slice(0, 8)}`;
export const visibleText = 'GENARRATIVE_REAL_E2E_VISIBLE';
export const patchedText = 'REAL_E2E_PATCHED';
export const patchsetCreatedPath = 'game/e2e-patchset.txt';
export const patchsetCreatedMarker = 'GENARRATIVE_REAL_E2E_PATCHSET_CREATED';
export const patchsetCreatedContent = `${patchsetCreatedMarker}\n`;
export const goalDeliveryPath = 'game/goal-delivery.txt';
export const gitSensitivePath = 'data/local.sqlite';
export const gitCommitReflogMessage =
'project.git_commit: controlled local commit';
export const editorAssetPrompt =
'real e2e amber arcade token, transparent background';
export const verificationCommand = 'node verify-e2e.mjs';
export const commandFailureMarker = 'real-e2e-command=failed';
export const commandPassedMarker = 'real-e2e-command=passed';
export const commandRootErrorMarker = `real-e2e-root-${randomUUID().replaceAll('-', '')}`;
export const commandRootErrorLine = 170;
export const commandDiagnosticLineCount = 240;
export const goalRuntimeSuite = 'goal-runtime';
export const responseStreamSuite = 'response-stream';
export const webSearchSuite = 'web-search';
export const contextCompactionSuite = 'context-compaction';
export const scopedAgentsSuite = 'scoped-agents';
export const projectSkillSuite = 'project-skill';
export const steerRunnerKillSuite = 'steer-runner-kill';
export const parallelReadSuite = 'parallel-read';
export const supervisorSwarmSuite = 'supervisor-swarm';
export const supervisorSwarmTransientRetrySuite =
'supervisor-swarm-transient-retry';
export const supervisorSwarmFinalReplyTransientRetrySuite =
'supervisor-swarm-final-reply-transient-retry';
export const supervisorSwarmToolPlanHandoffRunnerKillSuite =
'supervisor-swarm-tool-plan-handoff-runner-kill';
export const supervisorSwarmToolPlanHandoffRequestSlot = 'loop-1-repair-0';
export const supervisorSwarmToolPlanHandoffAckTimeoutMs = 360_000;
export const toolPlanHandoffSchemaVersion = 'game-creator-tool-plan-handoff.v1';
export const supervisorSwarmTransientRetryTargetAgentId =
projectSupervisorAgentId;
export const supervisorSwarmTransientRetryBackoffMs = 30_000;
export const supervisorSwarmTransientRetryPreDueGuardMs = 1_500;
export const runtimeContextBundleSchemaVersion =
'game-creator-runtime-context-bundle.v5';
export const providerRequestLifecycleSchemaVersion =
'game-creator-provider-request-lifecycle.v2';
export const providerActionBatchSchemaVersion =
'game-creator-provider-action-batch.v2';
export const supervisorCollaborationPolicySchemaVersion =
'game-creator-supervisor-collaboration-policy.v1';
export const supervisorCollaborationContractSchemaVersion =
'game-creator-supervisor-collaboration-contract.v1';
export const supervisorCollaborationPolicySnapshotSchemaVersion =
'game-creator-supervisor-collaboration-policy-snapshot.v1';
export const supervisorCollaborationPolicySnapshotBindingSchemaVersion =
'game-creator-supervisor-collaboration-policy-snapshot-binding.v1';
export const supervisorCollaborationPolicySnapshotInitialBatchBinding =
'initial-collaboration-batch';
export const staticDelegateDeliverySchemaVersion =
'game-creator-static-delegate-delivery.v1';
export const staticDelegateClaimSchemaVersion =
'game-creator-static-delegate-claim.v1';
export const isolatedAgentGroupSchemaVersion =
'game-creator-isolated-agent-group.v1';
export const isolatedAgentInstanceSchemaVersion =
'game-creator-isolated-agent-instance.v1';
export const isolatedAgentResultSchemaVersion =
'game-creator-isolated-agent-result.v1';
export const isolatedAgentJoinDeliverySchemaVersion =
'game-creator-isolated-agent-join-delivery.v1';
export const isolatedAgentJoinClaimSchemaVersion =
'game-creator-isolated-agent-join-claim.v1';
export const contextCompactionRoundCount = 30;
export const contextCompactionTriggerTurns = new Set([4, 8]);
export const contextCompactionConstraintCanary = `GENARRATIVE_CONTEXT_CONSTRAINT_${randomUUID().replaceAll('-', '').slice(0, 20)}`;
export const scopedAgentsRootCanary = `GENARRATIVE_SCOPE_ROOT_${randomUUID()
.replaceAll('-', '')
.slice(0, 20)}`;
export const scopedAgentsGameCanary = `GENARRATIVE_SCOPE_GAME_${randomUUID()
.replaceAll('-', '')
.slice(0, 20)}`;
export const scopedAgentsAlphaCanary = `GENARRATIVE_SCOPE_ALPHA_${randomUUID()
.replaceAll('-', '')
.slice(0, 20)}`;
export const scopedAgentsBetaCanary = `GENARRATIVE_SCOPE_BETA_${randomUUID()
.replaceAll('-', '')
.slice(0, 20)}`;
export const scopedAgentsAlphaPath = 'game/alpha/delivery.txt';
export const scopedAgentsBetaPath = 'game/beta/delivery.txt';
export const scopedAgentsVerificationScriptPath = 'verify-scoped-agents.mjs';
export const scopedAgentsVerificationCommand = `node ${scopedAgentsVerificationScriptPath}`;
export const projectSkillBodyCanary = `GENARRATIVE_PROJECT_SKILL_${randomUUID()
.replaceAll('-', '')
.slice(0, 20)}`;
export const projectSkillIrrelevantCanary = `GENARRATIVE_IRRELEVANT_SKILL_${randomUUID()
.replaceAll('-', '')
.slice(0, 20)}`;
export const projectSkillEntryPath = '.codex/skills/release-capsule/SKILL.md';
export const projectSkillIrrelevantEntryPath =
'.codex/skills/unrelated-art/SKILL.md';
export const projectSkillTargetPath = 'game/release-capsule.txt';
export const projectSkillVerificationScriptPath = 'verify-project-skill.mjs';
export const projectSkillVerificationCommand = `node ${projectSkillVerificationScriptPath}`;
export const parallelReadCorpusPath = 'game/parallel-read-corpus';
export const parallelReadAlphaQuery = `PARALLEL_READ_ALPHA_${randomUUID()
.replaceAll('-', '')
.slice(0, 20)}`;
export const parallelReadBetaQuery = `PARALLEL_READ_BETA_${randomUUID()
.replaceAll('-', '')
.slice(0, 20)}`;
export const parallelReadCorpusFileCount = 420;
export const supervisorSwarmDesignAgentId = 'design-director';
export const supervisorSwarmQualityAgentId = 'quality-review';
export const supervisorSwarmRequiredAgentIds = [
projectSupervisorAgentId,
supervisorSwarmDesignAgentId,
supervisorSwarmQualityAgentId,
];
export const supervisorSwarmSessionId = `agent-session-${projectSupervisorAgentId}`;
export const supervisorSwarmDesignPath = 'game/supervisor-swarm-design.txt';
export const supervisorSwarmQualityPath = 'game/supervisor-swarm-quality.txt';
export const supervisorSwarmDesignMarker = `SUPERVISOR_SWARM_DESIGN_${randomUUID()
.replaceAll('-', '')
.slice(0, 20)}`;
export const supervisorSwarmQualityMarker = `SUPERVISOR_SWARM_QUALITY_${randomUUID()
.replaceAll('-', '')
.slice(0, 20)}`;
export const supervisorSwarmDesignContent = `DESIGN_STATUS=ready\nDESIGN_MARKER=${supervisorSwarmDesignMarker}\n`;
export const supervisorSwarmWeakQualityContent =
'QUALITY_STATUS=weak\nQUALITY_MARKER=missing\n';
export const supervisorSwarmQualityContent = `QUALITY_STATUS=ready\nQUALITY_MARKER=${supervisorSwarmQualityMarker}\n`;
export const supervisorSwarmProviderRetryAuditGraceSeconds = 10;
export const supervisorSwarmDeniedMutationTools = [
'command.exec',
'file.delete',
'file.write',
'project.patchset',
'project.restore',
];
export const supervisorSwarmProjectMutationTools = new Set([
'asset.register',
'asset.upload',
'canvas.asset_generate',
'canvas.asset_import',
'canvas.export_import',
'canvas.project_open',
'canvas.project_sync',
'command.exec',
'command.run_limited',
'command.start',
'command.stdin',
'command.terminate',
'file.delete',
'file.patch',
'file.write',
'game.generate_draft',
'game.run_local',
'project.create',
'project.export_package',
'project.git_commit',
'project.patchset',
'project.restore',
]);
export const supervisorSwarmPolicyConfirmCommands = [
'agent.kill',
'agent.resume',
'agent.retry',
'agent.schedule_ready',
'agent.spawn_isolated',
'asset.register',
'asset.upload',
'canvas.asset_generate',
'canvas.asset_import',
'canvas.export_import',
'canvas.project_open',
'canvas.project_sync',
'command.exec',
'command.run_limited',
'command.start',
'command.stdin',
'command.terminate',
'file.delete',
'file.write',
'game.generate_draft',
'game.run_local',
'memory.delete',
'memory.write',
'preview.open',
'preview.start',
'project.checkpoint',
'project.create',
'project.export_package',
'project.git_commit',
'project.patchset',
'project.policy_write',
'project.restore',
'project.verify',
'task.create',
'task.update',
];
export const supervisorSwarmConfirmedTools = [
'command.run_limited',
'file.patch',
'file.write',
'project.checkpoint',
'project.patchset',
'project.verify',
];
export const supervisorSwarmIsolatedReviews = [
{
path: 'e2e/isolated-a/evidence.txt',
scope: 'e2e/isolated-a/**',
content: 'isolated-a seeded evidence\n',
boundaryTerms: ['onboarding', 'first-experience'],
requirement:
'player onboarding readiness and whether the evidence gives a clear first-experience signal',
},
{
path: 'e2e/isolated-b/evidence.txt',
scope: 'e2e/isolated-b/**',
content: 'isolated-b seeded evidence\n',
boundaryTerms: ['release risk', 'safe player handoff'],
requirement:
'release risk readiness and whether the evidence supports a safe player handoff',
},
{
path: 'e2e/isolated-c/evidence.txt',
scope: 'e2e/isolated-c/**',
content: 'isolated-c seeded evidence\n',
boundaryTerms: ['observability', 'follow-up'],
requirement:
'post-handoff observability and whether the evidence supports follow-up decisions',
},
];
export const webSearchBaselineApiUrl =
'https://api.github.com/repos/nodejs/node/releases/latest';
export const goalSessionId = `agent-session-${mainAgentId}`;
export const responseStreamThinkingCanary = `GENARRATIVE_RESPONSE_STREAM_THINKING_${randomUUID().replaceAll('-', '')}`;
export const responseStreamThinkingMarkers = [
'<think>',
'</think>',
responseStreamThinkingCanary,
];
export const goalInitialMarker = `GENARRATIVE_GOAL_REVISION_ONE_${randomUUID()
.replaceAll('-', '')
.slice(0, 16)}`;
export const goalFinalMarker = `GENARRATIVE_GOAL_REVISION_TWO_${randomUUID()
.replaceAll('-', '')
.slice(0, 16)}`;
export const goalFailureEvidenceCanary = `GENARRATIVE_GOAL_FAILURE_EVIDENCE_${randomUUID()
.replaceAll('-', '')
.slice(0, 16)}`;
export const goalInitialPayload = {
outcome: `在当前 disposable 项目的 ${goalDeliveryPath} 中交付一份新的变更证据,文件完整内容必须是唯一标记“${goalInitialMarker}”和一个结尾换行。基于仓库真实状态维护计划、完成变更并审阅实际结果,证据不足时不要结束。`,
constraints: [
'保留全部既有受跟踪内容,只新增完成本目标所需的一份安全证据。',
'不得读取、提交或转述敏感诱饵、配置密钥、Runtime 私有正文或项目绝对路径。',
],
verification: [
`项目交付内容包含且只包含一次标记“${goalInitialMarker}”。`,
'实际变更已经过仓库事实和内容差异审阅。',
],
};
export const goalEditedPayload = {
outcome: `前一版目标已经废止,项目交付文件不得保留标记“${goalInitialMarker}”。改为修复当前 disposable 项目唯一的真实验收失败,让项目声明的验收通过,并让 ${goalDeliveryPath} 的完整内容只包含唯一标记“${goalFinalMarker}”和一个结尾换行。基于真实运行反馈维护计划并审阅完整结果,证据不足时不要结束。`,
constraints: [
'保留既有可见内容、非空动画画布和仓库安全边界,只落地完成当前目标所需的原子变更。',
`失败证据门禁 ${goalFailureEvidenceCanary}:任何修复动作前必须先运行项目清单声明的原始验收并观察到真实非零退出;只读源码或验收脚本得出的推断不能替代失败证据。`,
'不得读取、提交或转述敏感诱饵、配置密钥、Runtime 私有正文或项目绝对路径。',
`任何项目交付文件都不得出现已废止标记“${goalInitialMarker}”。`,
],
verification: [
'项目清单声明的原始验收真实通过。',
`新增交付证据精确包含唯一标记“${goalFinalMarker}”。`,
`Runtime 控制面之外不存在已废止标记“${goalInitialMarker}”。`,
],
};
export const steerInstruction =
'继续完成原任务,并依据恢复后的真实进展重审、重排尚未完成的安排,确保最终交付完整。';
export const processFixtureScriptPath = 'fixtures/process-session-service.mjs';
export const processReadyPrefix = 'GENARRATIVE_PROCESS_READY';
export const processEchoPrefix = 'GENARRATIVE_PROCESS_ECHO';
export const processStoppedMarker = 'GENARRATIVE_PROCESS_STOPPED';
export const pollIntervalMs = 750;
export const runTimeoutMs = 30 * 60 * 1000;
export const supervisorSwarmTerminalSidecarCleanupTimeoutMs = 10_000;
export const processRunnerKillStartTimeoutMs = 5 * 60 * 1000;
export const commandOutputLimit = 4 * 1024 * 1024;
export const supportedToolPlanProtocols = new Set([
'native_runtime_tools',
'native_function',
'text_json',
]);
export const toolPlanProtocolErrorKinds = [
'response-shape',
'call-identity',
'unknown-function',
'arguments-json',
'arguments-schema',
'batch-constraint',
'plan-semantics',
'catalog-binding',
];
export const toolPlanProtocolErrorKindSet = new Set(toolPlanProtocolErrorKinds);
export const toolPlanNormalizationKinds = new Set([
'complete-think-block',
'planner-commentary',
]);
export const toolPlanAuditCommonSafeFields =
'schemaVersion updatedAt recordType agentId taskId sessionId runId source loopIteration repairAttempt requestSlot responseFingerprint providerRequestIdSha256 protocol'.split(
' ',
);
export const toolPlanProtocolAuditSafeFields = new Set([
...toolPlanAuditCommonSafeFields,
...'functionCallCount callIdSha256s functionNames responseIdSha256 responseIdChars normalizationKinds normalizationCount normalizedTextChars normalizedTextSha256'.split(
' ',
),
]);
export const toolPlanRepairAuditSafeFields = new Set([
...toolPlanAuditCommonSafeFields,
...'attempt maxAttempts protocolErrorKind protocolErrorSha256 protocolErrorChars responsePreviewSha256 responsePreviewChars callIdSha256 functionNameSha256'.split(
' ',
),
]);
export const processSessionSuites = new Set([
'process-session',
'process-session-runner-kill',
]);
export const goalProjectWriteTools = new Set([
'command.exec',
'command.run_limited',
'file.delete',
'file.patch',
'file.write',
'project.git_commit',
'project.patchset',
]);
export const idempotentObservationTools = new Set([
'project.index',
'project.search',
'project.diff',
'git.inspect',
'file.list',
'file.read',
'command.output_read',
'command.poll',
'agent.action_history',
'agent.run_status',
]);
export const pngSignature = Buffer.from([
0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a,
]);
export const linuxPidfdHelperSource = String.raw`
import os
import select
import signal
import sys
if not hasattr(os, "pidfd_open") or not hasattr(signal, "pidfd_send_signal"):
raise SystemExit(70)
pidfd = os.pidfd_open(int(sys.argv[1]), 0)
try:
sys.stdout.write("PIDFD_READY\n")
sys.stdout.flush()
command = sys.stdin.buffer.readline()
if command == b"CLOSE\n":
raise SystemExit(0)
if command != b"KILL\n":
raise SystemExit(71)
signal.pidfd_send_signal(pidfd, signal.SIGKILL, None, 0)
poller = select.poll()
poller.register(pidfd, select.POLLIN)
if not poller.poll(10000):
raise SystemExit(72)
sys.stdout.write("PIDFD_EXITED\n")
sys.stdout.flush()
finally:
os.close(pidfd)
`;
export const windowsProcessHandleHelperSource = String.raw`
$ErrorActionPreference = 'Stop'
$nativeSource = @'
using System;
using System.Runtime.InteropServices;
public static class GenarrativeOwnedProcessHandle
{
[DllImport("kernel32.dll", SetLastError = true)]
public static extern IntPtr OpenProcess(
uint desiredAccess,
[MarshalAs(UnmanagedType.Bool)] bool inheritHandle,
uint processId);
[DllImport("kernel32.dll", SetLastError = true)]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool TerminateProcess(IntPtr process, uint exitCode);
[DllImport("kernel32.dll", SetLastError = true)]
public static extern uint WaitForSingleObject(IntPtr handle, uint milliseconds);
[DllImport("kernel32.dll", SetLastError = true)]
public static extern uint GetProcessId(IntPtr process);
[DllImport("kernel32.dll", SetLastError = true)]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool CloseHandle(IntPtr handle);
}
'@
[void](Add-Type -TypeDefinition $nativeSource -ErrorAction Stop)
$targetPidText = [Environment]::GetEnvironmentVariable(
'AGC_OWNED_RUNNER_PID',
[EnvironmentVariableTarget]::Process)
if ([String]::IsNullOrWhiteSpace($targetPidText)) { exit 70 }
$targetPid = [UInt32]::Parse($targetPidText)
$desiredAccess = [UInt32](0x0001 -bor 0x00100000 -bor 0x1000)
$handle = [GenarrativeOwnedProcessHandle]::OpenProcess(
$desiredAccess,
$false,
$targetPid)
if ($handle -eq [IntPtr]::Zero) { exit 71 }
try {
if ([GenarrativeOwnedProcessHandle]::GetProcessId($handle) -ne $targetPid) {
exit 72
}
[Console]::Out.WriteLine('HANDLE_READY')
[Console]::Out.Flush()
$command = [Console]::In.ReadLine()
if ($command -eq 'CLOSE') { exit 0 }
if ($command -ne 'KILL') { exit 73 }
if (-not [GenarrativeOwnedProcessHandle]::TerminateProcess($handle, 137)) {
exit 74
}
if ([GenarrativeOwnedProcessHandle]::WaitForSingleObject($handle, 10000) -ne 0) {
exit 75
}
[Console]::Out.WriteLine('HANDLE_EXITED')
[Console]::Out.Flush()
} finally {
[void][GenarrativeOwnedProcessHandle]::CloseHandle($handle)
}
`;
export const activeCommandChildren = new Set();
export const shutdownWaiters = new Set();
export class StreamingSecretScanner {
constructor(secrets) {
this.secrets = [];
this.secretKeys = new Set();
this.tails = new Map();
this.count = 0;
this.addSecrets(secrets);
}
addSecrets(secrets) {
for (const value of secrets) {
const secret = Buffer.isBuffer(value) ? value : Buffer.from(value);
if (secret.length === 0) continue;
const key = secret.toString('base64');
if (this.secretKeys.has(key)) continue;
this.secretKeys.add(key);
this.secrets.push(secret);
}
}
scan(source, chunk) {
const bytes = Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk);
for (const secret of this.secrets) {
const key = `${source}\0${secret.toString('base64')}`;
const tail = this.tails.get(key) ?? Buffer.alloc(0);
const combined = Buffer.concat([tail, bytes]);
let offset = 0;
while (offset <= combined.length - secret.length) {
const index = combined.indexOf(secret, offset);
if (index < 0) break;
if (index + secret.length > tail.length) this.count += 1;
offset = index + Math.max(1, secret.length);
}
this.tails.set(
key,
combined.subarray(
Math.max(0, combined.length - Math.max(0, secret.length - 1)),
),
);
}
}
}
export class BlockedError extends Error {
constructor(components) {
super('prerequisite blocked');
this.code = 'prerequisite-blocked';
this.components = components;
}
}
export const isolatedRunnerState = {
appDataDir: null,
ownerToken: null,
createdAt: 0,
current: null,
configLinks: [],
launchAttempted: false,
pidfdClaimCount: 0,
pidfdSignalCount: 0,
stopped: false,
cleanupPerformed: false,
streamOverrideCreated: false,
webSearchOverrideCreated: false,
configOverlayCreated: false,
sourceConfigCliCallCount: 0,
sourceAppDataDirectoryWatcher: null,
sourceAppDataDirectoryViolationCount: 0,
sourceAppDataDirectoryUntouched: false,
sourceEndpointSnapshot: null,
sourceRunnerEndpointUnchanged: false,
sourceConfigLinksVerified: false,
};
export const state = {
shutdownSignal: null,
linuxPidfdPythonPath: null,
windowsProcessHandlePowerShellPath: null,
cleanupInProgress: false,
status: 'FAIL',
suite: null,
options: null,
config: {
llmConfigured: false,
chromeAvailable: false,
editorApiConfigured: false,
},
blocked: [],
errors: [],
secrets: [],
transcriptOnlySecrets: [],
transcriptLeakCount: 0,
projectLeakCount: 0,
reportLeakCount: 0,
lureLeakCount: null,
commandOutputMarkerSeenInContext: false,
commandOutputContextPages: new Set(),
commandMarkerReportLeakCount: 0,
steerInstructionReportLeakCount: 0,
goalBodyReportLeakCount: 0,
projectPathTranscriptLeakCount: 0,
projectPathReportLeakCount: 0,
formalConfigPathTranscriptLeakCount: 0,
formalConfigPathReportLeakCount: 0,
transcriptScanner: null,
projectPathTranscriptScanner: null,
formalConfigPathTranscriptScanner: null,
projectRoot: null,
sentinelToken: null,
cliBinary: null,
runtimeConfigDir: null,
isolatedRunner: isolatedRunnerState,
runnerKilled: false,
resumed: false,
identityStable: false,
initialRunId: null,
initialSessionId: null,
initialTask: null,
planRecovery: null,
steer: null,
steerRunnerKill: {
oldRunnerBootId: null,
newRunnerBootId: null,
effectiveModel: null,
effectiveApiKind: null,
killedSnapshot: null,
},
goal: {
goalId: null,
initialRevision: 0,
editedRevision: 0,
editProviderInterrupted: false,
pauseProviderInterrupted: false,
initialPending: null,
editedPending: null,
initialCompletedStepHashes: [],
editedEvidenceAbsentBeforeEdit: false,
pauseSnapshot: null,
oldRunnerBootId: null,
newRunnerBootId: null,
revisionOneFixtureIsolated: false,
revisionTwoFixtureInjected: false,
revisionTwoHostFailureObserved: false,
revisionTwoFailureObserved: false,
revisionTwoFailureExitCode: null,
revisionTwoFailureFingerprint: null,
revisionTwoEditAgentDbBoundary: 0,
revisionTwoAgentDbBoundary: 0,
initialGoalSnapshotFingerprint: null,
editedGoalSnapshotFingerprint: null,
initialMarkerAbsenceCheckCount: 0,
monitoredWriteActionIds: new Set(),
preFailureDeliveryActionIds: new Set(),
runner: isolatedRunnerState,
},
responseStream: {
effectiveStreamEnabled: false,
confirmedProjectVerifyCount: 0,
pollCount: 0,
observedSnapshots: [],
lastSnapshot: null,
firstTerminalPoll: null,
finalText: null,
finalRequestSlot: null,
finalResponseRevision: null,
publicLeakCount: 0,
reportLeakCount: 0,
},
webSearch: {
baseline: null,
effectiveEnabled: false,
pollCount: 0,
finalText: null,
gatewayDiagnosis: 'not-run',
reportLeakCount: 0,
},
contextCompaction: {
turnRunIds: [],
turnsCompleted: 0,
compactionRevisions: [],
compactionSourceFingerprints: [],
compactionSummaryFingerprints: [],
privateSummaries: [],
maxEstimatedInputTokens: 0,
autoCompactTokenLimit: 0,
oldRunnerBootId: null,
newRunnerBootId: null,
finalReplyFingerprint: null,
reportLeakCount: 0,
},
scopedAgents: {
effectiveModel: null,
effectiveApiKind: null,
confirmedActionCount: 0,
privateValues: [],
reportLeakCount: 0,
},
projectSkill: {
effectiveModel: null,
effectiveApiKind: null,
initialVerificationFailed: false,
confirmedActionCount: 0,
privateValues: [],
reportLeakCount: 0,
},
parallelRead: {
effectiveModel: null,
effectiveApiKind: null,
privateValues: [],
reportLeakCount: 0,
},
supervisorSwarm: {
effectiveModel: null,
effectiveApiKind: null,
effectiveReasoningEffort: null,
effectiveRequestTimeoutMs: null,
effectiveMaxRetries: null,
effectiveRetryBackoffMs: null,
effectiveDefaultPolicy: null,
effectiveAgentPolicies: {},
privateValues: [],
userTask: null,
reportLeakCount: 0,
policyReleased: false,
initialProviderBatch: null,
initialProviderRequestIds: [],
initialDeliveries: [],
weakDeliveryId: null,
repairDeliveryId: null,
repairTargetAgentId: null,
repairTargetSessionId: null,
repairTargetRunId: null,
repairProviderRequestId: null,
initialProviderOverlapObserved: false,
repairPendingActionId: null,
repairPendingIdentity: null,
repairPendingTool: null,
preKillProviderStartedCount: 0,
preKillProviderStartedIdentities: [],
preKillDeliveryIdentities: [],
preKillClaimIdentities: [],
preKillTaskIdentities: [],
confirmedActionCount: 0,
failedRepairActionCount: 0,
targetedContractReadCount: 0,
repairSearchStartLoop: null,
runnerKillBoundaryObserved: false,
hostVerificationPassed: false,
oldRunnerBootId: null,
newRunnerBootId: null,
transientFaultProxy: null,
transientFaultCheckpoint: null,
transientFaultSelection: null,
transientFaultSelectorError: false,
transientFaultRequestSequence: 0,
transientFaultPreFaultHostVerificationPassed: false,
transientFaultPreFaultHostVerificationCompletedAtMs: 0,
transientRetryPreKillSidecar: null,
transientRetryPostRestartSidecar: null,
transientRetryPreKillRunnerBootId: null,
transientRetryPostRestartRunnerBootId: null,
transientRetryRunnerKilledAtMs: 0,
transientRetryRequestCountBeforeKill: 0,
transientRetryRequestCountAfterRestart: 0,
transientRetryRequestCountBeforeDue: 0,
transientRetryEarlyRequestCount: 0,
transientRetrySidecarIdentityStable: false,
transientRetryAttemptStable: false,
transientRetryAtStable: false,
transientRetryRuntimeIdentityStable: false,
transientRetryAcceptedAtOrAfterDue: false,
transientRetryIncidentalProviderFailureCount: 0,
transientRetryIncidentalProviderRetryCount: 0,
transientRetryRecoveredFromPreviousBoot: false,
transientRetryToolPlanCountAtFault: 0,
transientRetryToolPlanCountAfterRecovery: 0,
transientRetryFinalReplyStreamCommitted: false,
toolPlanHandoffProxy: null,
toolPlanHandoffCheckpointControl: null,
toolPlanHandoffCheckpoint: null,
toolPlanHandoffOldRunnerBootId: null,
toolPlanHandoffNewRunnerBootId: null,
toolPlanHandoffRequestCountBeforeKill: 0,
toolPlanHandoffRequestCountAfterRestart: 0,
toolPlanHandoffNetworkReplayCount: 0,
toolPlanHandoffRuntimeIdentityStable: false,
toolPlanHandoffRequestIdentityStable: false,
toolPlanHandoffRecoveredFromPreviousBoot: false,
toolPlanHandoffControlRemovedBeforeResume: false,
toolPlanHandoffLifecycleClosedExactlyOnce: false,
toolPlanHandoffAuditIdempotent: false,
toolPlanHandoffRecoveredPlanFingerprintMatched: false,
collaborationPolicyWritten: false,
},
confirmedActionIds: new Set(),
cleanupPerformed: false,
process: {
challenge: null,
readyLine: null,
echoLine: null,
contextPolls: new Map(),
challengeSeenInContext: false,
readinessSeenInContext: false,
echoSeenInContext: false,
stoppedSeenInContext: false,
oldRunnerBootId: null,
newRunnerBootId: null,
processOwnerBootId: null,
projectCwdProcessSeen: false,
projectCwdProcessCleanupConfirmed: false,
reportLeakCount: 0,
},
evidence: {},
};