hiveagents-runtime 0.0.0-stage → 0.1.0-beta.1
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/LICENSE +202 -0
- package/README.md +85 -2
- package/dist/adapter-kit.d.ts +37 -0
- package/dist/adapter-kit.js +33 -0
- package/dist/adapter-kit.js.map +1 -0
- package/dist/agent-D0HS38G3.d.ts +169 -0
- package/dist/agent-OLSXNGNN.js +23 -0
- package/dist/agent-OLSXNGNN.js.map +1 -0
- package/dist/agent-readiness-V36OJME4.js +19 -0
- package/dist/agent-readiness-V36OJME4.js.map +1 -0
- package/dist/capture-runtime-GP6NZ2ee.d.ts +54 -0
- package/dist/chunk-2RUEC63U.js +1217 -0
- package/dist/chunk-2RUEC63U.js.map +1 -0
- package/dist/chunk-3B3JW4U3.js +291 -0
- package/dist/chunk-3B3JW4U3.js.map +1 -0
- package/dist/chunk-3TIYA3K5.js +55 -0
- package/dist/chunk-3TIYA3K5.js.map +1 -0
- package/dist/chunk-6XIJW65Q.js +52 -0
- package/dist/chunk-6XIJW65Q.js.map +1 -0
- package/dist/chunk-7LDQKJKI.js +248 -0
- package/dist/chunk-7LDQKJKI.js.map +1 -0
- package/dist/chunk-ALLOMOUN.js +810 -0
- package/dist/chunk-ALLOMOUN.js.map +1 -0
- package/dist/chunk-C2DN6KL4.js +853 -0
- package/dist/chunk-C2DN6KL4.js.map +1 -0
- package/dist/chunk-COKYQUTK.js +581 -0
- package/dist/chunk-COKYQUTK.js.map +1 -0
- package/dist/chunk-CPN4DOXH.js +115 -0
- package/dist/chunk-CPN4DOXH.js.map +1 -0
- package/dist/chunk-DBFXFWQZ.js +385 -0
- package/dist/chunk-DBFXFWQZ.js.map +1 -0
- package/dist/chunk-DZFFGUIA.js +81 -0
- package/dist/chunk-DZFFGUIA.js.map +1 -0
- package/dist/chunk-EEUYQFCP.js +106 -0
- package/dist/chunk-EEUYQFCP.js.map +1 -0
- package/dist/chunk-GFVYNPLS.js +118 -0
- package/dist/chunk-GFVYNPLS.js.map +1 -0
- package/dist/chunk-GJ4FTDBJ.js +2910 -0
- package/dist/chunk-GJ4FTDBJ.js.map +1 -0
- package/dist/chunk-GS5U3KUN.js +201 -0
- package/dist/chunk-GS5U3KUN.js.map +1 -0
- package/dist/chunk-HB7FBSH2.js +960 -0
- package/dist/chunk-HB7FBSH2.js.map +1 -0
- package/dist/chunk-HZFZX5A3.js +21 -0
- package/dist/chunk-HZFZX5A3.js.map +1 -0
- package/dist/chunk-J7VAYJKM.js +595 -0
- package/dist/chunk-J7VAYJKM.js.map +1 -0
- package/dist/chunk-NCNSHOF7.js +52 -0
- package/dist/chunk-NCNSHOF7.js.map +1 -0
- package/dist/chunk-RXU2Q2HF.js +49 -0
- package/dist/chunk-RXU2Q2HF.js.map +1 -0
- package/dist/chunk-SRJUZJKV.js +521 -0
- package/dist/chunk-SRJUZJKV.js.map +1 -0
- package/dist/chunk-TG7NTMTR.js +208 -0
- package/dist/chunk-TG7NTMTR.js.map +1 -0
- package/dist/chunk-TIZKGD4R.js +202 -0
- package/dist/chunk-TIZKGD4R.js.map +1 -0
- package/dist/chunk-WMKO5XOE.js +601 -0
- package/dist/chunk-WMKO5XOE.js.map +1 -0
- package/dist/chunk-WOQBVJH5.js +175 -0
- package/dist/chunk-WOQBVJH5.js.map +1 -0
- package/dist/cli.d.ts +1 -0
- package/dist/cli.js +25 -0
- package/dist/cli.js.map +1 -0
- package/dist/errors-DgehLwqI.d.ts +98 -0
- package/dist/execution-halt-CW0Oi9s9.d.ts +12 -0
- package/dist/execution-types-UJ6gAF48.d.ts +239 -0
- package/dist/host-ledger-VPRWVVOS.js +25 -0
- package/dist/host-ledger-VPRWVVOS.js.map +1 -0
- package/dist/hosted-runtime.d.ts +168 -0
- package/dist/hosted-runtime.js +857 -0
- package/dist/hosted-runtime.js.map +1 -0
- package/dist/index-B86C6VAD.d.ts +41 -0
- package/dist/index.d.ts +327 -0
- package/dist/index.js +8818 -0
- package/dist/index.js.map +1 -0
- package/dist/memory-items-BSTC0_R0.d.ts +28 -0
- package/dist/memory-tools.d.ts +222 -0
- package/dist/memory-tools.js +923 -0
- package/dist/memory-tools.js.map +1 -0
- package/dist/orchestration/dynamic.d.ts +854 -0
- package/dist/orchestration/dynamic.js +3150 -0
- package/dist/orchestration/dynamic.js.map +1 -0
- package/dist/orchestration/graph.d.ts +11 -0
- package/dist/orchestration/graph.js +9 -0
- package/dist/orchestration/graph.js.map +1 -0
- package/dist/orchestration/index.d.ts +2385 -0
- package/dist/orchestration/index.js +6403 -0
- package/dist/orchestration/index.js.map +1 -0
- package/dist/orchestration/log.d.ts +301 -0
- package/dist/orchestration/log.js +3058 -0
- package/dist/orchestration/log.js.map +1 -0
- package/dist/orchestration/memory.d.ts +711 -0
- package/dist/orchestration/memory.js +27 -0
- package/dist/orchestration/memory.js.map +1 -0
- package/dist/provider-XCpWjJ6a.d.ts +151 -0
- package/dist/routing/index.d.ts +29 -0
- package/dist/routing/index.js +385 -0
- package/dist/routing/index.js.map +1 -0
- package/dist/routing/learning/index.d.ts +433 -0
- package/dist/routing/learning/index.js +2501 -0
- package/dist/routing/learning/index.js.map +1 -0
- package/dist/runtime-C6Cu2fvw.d.ts +283 -0
- package/dist/runtime-Y72XJFFO.js +18 -0
- package/dist/runtime-Y72XJFFO.js.map +1 -0
- package/dist/store-types-2YdceOMy.d.ts +78 -0
- package/dist/types-BB7KqceP.d.ts +52 -0
- package/dist/types-BBRKjIc7.d.ts +86 -0
- package/dist/types-DTFc1qO6.d.ts +1065 -0
- package/dist/types-DYex3p7_.d.ts +88 -0
- package/docs/licenses/ruflo-memory-MIT.txt +21 -0
- package/docs/releases/0.1.0-beta.1.md +13 -0
- package/package.json +114 -4
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/public/agent-readiness.ts","../src/core/capabilities.ts","../src/core/subscription-exec.ts","../src/session/negotiation.ts","../src/session/exec-capabilities.ts","../src/session/mcp-envelope.ts"],"sourcesContent":["import { types } from 'node:util';\nimport { realpath } from 'node:fs/promises';\nimport type { ExecAdapter, ExecProbeTurn } from '../adapters/provider.js';\nimport type { CliCompatibilityAssessment } from '../compatibility/manifest.js';\nimport { OperationScope } from '../control/operation-scope.js';\nimport { validateSettlementOption } from '../control/exec-settlement.js';\nimport { validateTimeoutMs } from '../process/run-process.js';\nimport { selectTransport } from '../core/capabilities.js';\nimport { freeze } from '../shared/json.js';\nimport { buildEnvironment } from '../core/environment.js';\nimport { assertRespondCompatibility, assertRespondAuth } from '../core/respond-policy.js';\nimport { createExecutablePin, experimentalGates, PinnedExecAdapter, type ExecReprobe } from '../core/registry.js';\nimport type { Runtime } from '../core/runtime.js';\nimport { SubscriptionExecAdapter } from '../core/subscription-exec.js';\nimport { authenticationState, hasConfirmedSubscription, isAuthenticationConfirmed } from '../core/auth-evidence.js';\nimport { buildSafetyEnvelope, negotiateCapabilities, controlFeatures } from '../session/negotiation.js';\nimport { buildExecFeatures } from '../session/exec-capabilities.js';\nimport { envelopeMcpServers } from '../session/mcp-envelope.js';\nimport { CliNotInstalledError, NotAuthenticatedError, UnexpectedAuthSourceError, UnsupportedCliVersionError, UnsupportedCapabilityError } from './errors.js';\nimport type { AgentOptions, AgentReadiness, AgentReadinessOptions, CapabilityReport, CapabilityStatus, ModelInfo, NegotiatedPlan, PermissionIntent, RuntimeWarning, SessionPersistence } from './types.js';\n\nexport interface PreparedAgent {\n readonly readiness: AgentReadiness;\n readonly launchPlan: NegotiatedPlan;\n cwd: string;\n permissions: PermissionIntent;\n sessionAdapter: ExecAdapter;\n}\n\n/** Preparation has no session side effects; callers choose whether to retain its result. */\nexport async function prepareAgent(\n options: Readonly<AgentOptions>, runtime: Runtime, model: ModelInfo,\n persistence: SessionPersistence = 'provider', scope?: OperationScope,\n): Promise<PreparedAgent> {\n const probe = async <T>(work: () => Promise<T> | T): Promise<T> => scope ? scope.race(work) : work();\n let sessionAdapter: ExecAdapter;\n const transport = agentTransport(options, runtime, model.provider, persistence);\n runtime.registration(model.provider).validateOptions(options, transport);\n const cwd = await probe(() => realpath(options.cwd ?? process.cwd()));\n const requestedPermissions = options.permissions ?? { mode: 'analyze' };\n const directories = requestedPermissions.additionalDirectories;\n const additionalDirectories = directories\n ? await Promise.all(directories.map((directory) => probe(() => realpath(directory))))\n : undefined;\n const permissionsIntent: PermissionIntent = {\n ...requestedPermissions,\n ...(additionalDirectories === undefined ? {} : { additionalDirectories }),\n };\n const adapter = runtime.adapter(model.provider);\n const env = agentEnvironment(options);\n const installation = await probe(() => adapter.detect(env, scope));\n if (!installation.installed) {\n throw new CliNotInstalledError(model.provider, { retryable: false });\n }\n const providerOptions = model.provider === 'claude' ? options.providerOptions?.claude\n : model.provider === 'codex' ? options.providerOptions?.codex : options.providerOptions?.external?.[model.provider];\n const authTurn: ExecProbeTurn | undefined = options.requireAuth === 'subscription'\n ? { cwd, contextArgs: runtime.registration(model.provider).translateContext(options.context).args,\n ...(providerOptions === undefined ? {} : { providerOptions }) }\n : undefined;\n const auth = await probe(() => adapter.auth(env, scope, authTurn));\n if (!isAuthenticationConfirmed(auth)\n && !(authenticationState(auth) === 'unknown' && options.requireAuth !== 'subscription')) {\n throw new NotAuthenticatedError(model.provider, {\n retryable: false,\n ...(installation.version === undefined ? {} : { cliVersion: installation.version }),\n });\n }\n const compatibility: CliCompatibilityAssessment | undefined = installation.version\n ? await probe(() => adapter.compatibility?.(env, installation.version!, scope))\n : undefined;\n if (transport === 'exec' && installation.version && compatibility?.features.turns === 'unsupported') {\n throw new UnsupportedCliVersionError(model.provider, installation.version, {\n provider: model.provider,\n transport: 'exec',\n cliVersion: installation.version,\n retryable: false,\n sanitizedDiagnostics: { missingFlags: compatibility.missingFlags },\n });\n }\n if (options.requireAuth === 'subscription' && !hasConfirmedSubscription(auth)) {\n throw new UnexpectedAuthSourceError(model.provider, {\n retryable: false,\n sanitizedDiagnostics: { detectedSource: auth.source },\n });\n }\n if (options.effort && model.supportedEffort\n && !model.supportedEffort.includes(options.effort)) {\n throw new UnsupportedCapabilityError(\n { provider: model.provider, transport: 'exec', retryable: false },\n `Effort \"${options.effort}\" is not supported by ${model.id}`,\n );\n }\n const context = runtime.registration(model.provider).translateContext(options.context);\n const permissions = runtime.registration(model.provider).translatePermissions(\n permissionsIntent,\n transport,\n );\n assertRespondCompatibility(options, compatibility);\n const unsupported = [...context.unsupported, ...permissions.report.unsupported];\n if (options.permissions?.strict !== false && unsupported.length > 0) {\n throw new UnsupportedCapabilityError(\n { provider: model.provider, transport, retryable: false },\n `Requested policy cannot be enforced: ${unsupported.join(', ')}`,\n );\n }\n const compatibilityWarnings: RuntimeWarning[] = compatibility === undefined\n ? [{ code: 'COMPATIBILITY_NOT_PROBED', message: 'CLI help capabilities were not probed' }]\n : compatibility.evidence === 'live-contract'\n ? []\n : [{\n code: compatibility.missingFlags.length > 0 ? 'CLI_FLAGS_MISSING' : 'HELP_PROBED_ONLY',\n message: compatibility.missingFlags.length > 0\n ? `Installed CLI is missing flags: ${compatibility.missingFlags.join(', ')}`\n : `${model.provider} ${installation.version ?? 'unknown'} is help-probed but not live-contract verified`,\n }];\n const capabilities: CapabilityReport = {\n provider: model.provider,\n transport,\n features: buildExecFeatures(compatibility?.features, model.provider, !!adapter.stream),\n unsupported,\n warnings: [\n ...(auth.state === 'unknown' ? [{ code: 'AUTH_UNVERIFIED', message: 'Authentication is unverified; the requested turn will confirm it' }] : []),\n ...context.warnings.map((message) => ({ code: 'CONTEXT_PARTIAL', message })),\n ...compatibilityWarnings,\n ],\n contextSources: context.report,\n enforcement: permissions.report,\n };\n const executableRealpath = installation.realpath ?? installation.path ?? '';\n const fingerprint = `${model.provider}:${installation.version ?? 'unknown'}:${executableRealpath}`;\n const controlRegistration = runtime.controlRegistration(model.provider);\n if (transport === 'control' && controlRegistration) capabilities.features = controlFeatures(controlRegistration);\n const negotiatedCapabilities = negotiateCapabilities({\n transport,\n registration: controlRegistration,\n features: capabilities.features,\n fingerprint,\n });\n assertRequiredCapabilities(options, model, negotiatedCapabilities, transport);\n const requireSubscription = (exec: ExecAdapter) => transport === 'exec' && options.requireAuth === 'subscription'\n ? new SubscriptionExecAdapter(exec) : exec;\n const pin = await probe(() => createExecutablePin(installation.launchTarget?.command ?? executableRealpath, installation.version, { target: installation.launchTarget, identityFiles: installation.identityFiles }));\n if (pin) {\n const pinnedBase = runtime.adapterWithTarget(model.provider, pin.launchTarget ?? { command: pin.realpath, argsPrefix: [] });\n const reprobe: ExecReprobe = async (probeEnv, previous, context) => {\n const probed = await pinnedBase.detect(probeEnv, context);\n if (!probed.installed) {\n throw new CliNotInstalledError(model.provider, { retryable: false });\n }\n {\n const version = probed.version ?? previous.cliVersion ?? 'unknown';\n const reassessed = await pinnedBase.compatibility?.(probeEnv, version, context);\n assertRespondCompatibility(options, reassessed);\n assertRequiredCapabilities(options, model, negotiateCapabilities({\n transport,\n registration: controlRegistration,\n features: buildExecFeatures(reassessed?.features, model.provider, !!pinnedBase.stream),\n fingerprint,\n }), transport);\n if (options.permissions?.mode === 'respond') assertRespondAuth(options, await pinnedBase.auth(probeEnv, context, authTurn));\n if (reassessed?.features.turns === 'unsupported') {\n throw new UnsupportedCliVersionError(model.provider, version, {\n provider: model.provider,\n transport: 'exec',\n cliVersion: version,\n retryable: false,\n sanitizedDiagnostics: { missingFlags: reassessed.missingFlags },\n });\n }\n }\n const next = await createExecutablePin(\n probed.launchTarget?.command ?? probed.realpath ?? probed.path ?? previous.realpath,\n probed.version ?? previous.cliVersion,\n { target: probed.launchTarget ?? previous.launchTarget, identityFiles: probed.identityFiles ?? previous.identityFiles?.map((file) => file.realpath) },\n );\n if (!next) throw new CliNotInstalledError(model.provider, { retryable: false });\n return next;\n };\n sessionAdapter = new PinnedExecAdapter(requireSubscription(pinnedBase), pin, reprobe);\n } else {\n sessionAdapter = requireSubscription(adapter);\n }\n const envelope = buildSafetyEnvelope({\n tools: [...(permissionsIntent.mode === 'respond' ? options.providerOptions?.claude?.tools ?? [] : []),\n ...(options.tools ?? []).map(tool => tool.name)],\n mcpServers: envelopeMcpServers({\n provider: model.provider, transport, cwd, providerOptions,\n contextArgs: context.args, permissionArgs: permissions.args, applicationTools: options.tools?.length ?? 0,\n }),\n cwd,\n permissions: permissionsIntent,\n environmentVariables: Object.keys(env),\n executableRealpath,\n modelId: model.id,\n enforcedBy: permissions.report.effective.enforcedBy,\n });\n const readiness: AgentReadiness = {\n ready: true,\n provider: model.provider,\n model,\n installation,\n auth,\n capabilities,\n plan: {\n provider: model.provider,\n transport,\n fingerprint: {\n adapterVersion: transport === 'control' && controlRegistration\n ? controlRegistration.adapterVersion\n : runtime.registration(model.provider).exec.adapterVersion,\n cliVersion: installation.version ?? 'unknown',\n executableRealpath: pin?.realpath ?? executableRealpath,\n ...(pin === undefined ? {} : { executableDigest: pin.digest }),\n ...(pin?.launchIdentityDigest === undefined ? {} : { launchIdentityDigest: pin.launchIdentityDigest }),\n ...(transport === 'control' && controlRegistration?.protocolVersion !== undefined\n ? { protocolVersion: controlRegistration.protocolVersion }\n : {}),\n ...(transport === 'control' && controlRegistration?.sdkVersion !== undefined\n ? { sdkVersion: controlRegistration.sdkVersion }\n : {}),\n },\n capabilities: negotiatedCapabilities,\n envelope,\n warnings: capabilities.warnings,\n },\n };\n const launchPlan = freeze(structuredClone(readiness.plan));\n return { cwd, permissions: permissionsIntent, sessionAdapter, launchPlan, readiness: freeze(structuredClone(readiness)) };\n}\n\nfunction assertRequiredCapabilities(\n options: Readonly<AgentOptions>, model: ModelInfo,\n negotiated: Record<string, CapabilityStatus>,\n transport: 'exec' | 'control',\n): void {\n for (const [name, value] of Object.entries(options.capabilities ?? {})) {\n if (value !== true && value !== 'required') continue;\n const key = name === 'tokenDeltas' ? 'messageDeltas' : name;\n const support = negotiated[key]?.support ?? 'unknown';\n if (support === 'unknown' || support === 'none') {\n throw new UnsupportedCapabilityError(\n { provider: model.provider, transport, retryable: false },\n `Required capability ${name} is ${support} on the ${transport} transport; unknown evidence does not satisfy a required capability`,\n );\n }\n }\n}\n\nexport function agentEnvironment(options: Readonly<AgentOptions>): NodeJS.ProcessEnv {\n const profile = options.context?.profile ?? 'native';\n return buildEnvironment(options.environment ?? { mode: profile === 'native' ? 'inherit' : 'minimal' });\n}\n\nexport function agentTransport(\n options: Readonly<AgentOptions>, runtime: Runtime, provider: string, persistence: SessionPersistence = 'provider',\n) {\n const controlRegistered = runtime.controlRegistration(provider) !== undefined;\n const preference = options.transport ?? 'auto';\n return selectTransport({\n provider,\n preference: options.pinned && preference === 'auto' ? 'exec' : preference,\n requirements: options.capabilities ?? {},\n persistence,\n controlRegistered,\n controlAvailable: controlRegistered && experimentalGates(options.providerOptions).control,\n execCapabilities: runtime.registration(provider).execCapabilities,\n });\n}\n\n/** Snapshot and validate before starting any asynchronous preparation. */\nexport async function freshAgentReadiness(\n options: Readonly<AgentOptions>, runtime: Runtime, model: ModelInfo,\n readinessOptions: AgentReadinessOptions,\n): Promise<AgentReadiness> {\n if (!readinessOptions || typeof readinessOptions !== 'object' || types.isProxy(readinessOptions)\n || ![Object.prototype, null].includes(Object.getPrototypeOf(readinessOptions))) {\n throw new TypeError('Readiness options must be a plain object');\n }\n const snapshot: Record<string, unknown> = Object.create(null);\n for (const key of Reflect.ownKeys(readinessOptions)) {\n const descriptor = Object.getOwnPropertyDescriptor(readinessOptions, key)!;\n if (typeof key !== 'string' || !['signal', 'timeoutMs', 'awaitSettlement'].includes(key)\n || !Object.hasOwn(descriptor, 'value')) throw new TypeError('Invalid readiness option');\n snapshot[key] = descriptor.value;\n }\n const { signal, timeoutMs, awaitSettlement } = snapshot;\n if (signal !== undefined && !(signal instanceof AbortSignal)) throw new TypeError('signal must be an AbortSignal');\n if (timeoutMs !== undefined && typeof timeoutMs !== 'number') throw new TypeError('timeoutMs must be a number');\n validateSettlementOption(awaitSettlement);\n const scope = new OperationScope(Object.assign(Object.create(null), {\n timeoutMs: validateTimeoutMs(timeoutMs), ...(signal === undefined ? {} : { signal }),\n context: { provider: model.provider, retryable: true },\n }));\n try {\n return (await scope.race(() => prepareAgent(options, runtime, model, 'provider', scope))).readiness;\n } finally {\n try {\n if (awaitSettlement) { await scope.drain(); scope.rethrowExecutionHalt(); }\n } finally { scope.dispose(); }\n }\n}\n","import {\n RequiredTransportUnavailableError,\n UnsupportedCapabilityError,\n} from '../public/errors.js';\nimport { controlUnavailableMessage } from './registry.js';\nimport type {\n CapabilityRequirements,\n CapabilitySupport,\n ProviderId,\n SessionPersistence,\n TransportKind,\n TransportPreference,\n} from '../public/types.js';\n\nconst CONTROL_ONLY: ReadonlyArray<keyof CapabilityRequirements> = [\n 'interactiveApprovals',\n 'userInputDuringTurn',\n 'steering',\n 'inProcessTools',\n 'dynamicPermissions',\n 'sessionInspection',\n 'checkpointOrRollback',\n // Ningún exec CLI confirma un fork sin prompt; exigirlo debe rutear a control\n // en vez de elegir exec y fallar cerrado después.\n 'forkWithoutPrompt',\n];\n\nexport interface TransportSelectionInput {\n provider: ProviderId;\n execCapabilities?: Readonly<Record<string, CapabilitySupport>> | undefined;\n preference: TransportPreference;\n requirements: CapabilityRequirements;\n persistence: SessionPersistence;\n controlAvailable: boolean;\n /** A control adapter is registered but the experimentalControl gate is off. */\n controlRegistered?: boolean;\n}\n\nfunction controlUnavailable(input: TransportSelectionInput, detail: string): never {\n if (input.controlRegistered ?? false) {\n throw new UnsupportedCapabilityError(\n { provider: input.provider, transport: 'control', retryable: false },\n `${detail}; the ${input.provider} control adapter is registered but requires the explicit experimentalControl opt-in`,\n );\n }\n throw new RequiredTransportUnavailableError(\n { provider: input.provider, transport: 'control', retryable: false },\n `${detail}; ${controlUnavailableMessage(input.provider)}`,\n );\n}\n\nfunction requiredControlCapabilities(input: TransportSelectionInput): string[] {\n const required = CONTROL_ONLY.filter((name) => {\n const value = input.requirements[name];\n return value === true || value === 'required';\n });\n const processPersistence = input.requirements.processPersistence;\n if (input.persistence === 'process' || processPersistence === true || processPersistence === 'required') {\n required.push('processPersistence');\n }\n const deltas = input.requirements.messageDeltas ?? input.requirements.tokenDeltas;\n if ((input.execCapabilities?.messageDeltas === 'unsupported' || input.execCapabilities?.tokenDeltas === 'unsupported' || input.provider === 'codex') && (deltas === true || deltas === 'required')) {\n required.push('messageDeltas');\n }\n return [...new Set(required)];\n}\n\nexport function selectTransport(input: TransportSelectionInput): TransportKind {\n const requiresControl = requiredControlCapabilities(input);\n\n if (input.preference === 'exec' && requiresControl.length > 0) {\n throw new UnsupportedCapabilityError(\n { provider: input.provider, transport: 'exec', retryable: false },\n `Exec transport cannot provide: ${requiresControl.join(', ')}`,\n );\n }\n\n if (input.preference === 'control') {\n if (!input.controlAvailable) {\n controlUnavailable(input, 'Control transport was explicitly requested');\n }\n return 'control';\n }\n\n if (requiresControl.length > 0) {\n if (!input.controlAvailable) {\n controlUnavailable(input, `Capabilities require control transport: ${requiresControl.join(', ')}`);\n }\n return 'control';\n }\n\n return 'exec';\n}\n","import { settleExecScope } from '../control/exec-settlement.js';\nimport { raceExecWork, resultUsage, streamStepUsage } from '../control/exec-usage.js';\nimport type { AdapterStreamItem, ExecAdapter, ExecProbeContext, ExecProbeTurn, ExecTurnRequest } from '../adapters/provider.js';\nimport { OperationScope } from '../control/operation-scope.js';\nimport { isAuthenticationConfirmed } from './auth-evidence.js';\nimport { NotAuthenticatedError, UnexpectedAuthSourceError } from '../public/errors.js';\n\n/** A CLI login can change while a session remains open, independently of its binary. */\nexport class SubscriptionExecAdapter implements ExecAdapter {\n readonly id: ExecAdapter['id'];\n stream?: NonNullable<ExecAdapter['stream']>;\n\n constructor(readonly inner: ExecAdapter) {\n this.id = inner.id;\n const stream = inner.stream?.bind(inner);\n if (stream) {\n const check = this.#check.bind(this);\n this.stream = async function* (request) {\n const scope = new OperationScope({ timeoutMs: request.timeoutMs, ...(request.signal ? { signal: request.signal } : {}), context: { provider: inner.id, transport: 'exec', retryable: true } });\n let iterator: AsyncIterator<AdapterStreamItem> | undefined, exhausted = false;\n try {\n await scope.race(() => check(request, scope));\n iterator = stream({ ...request, requireSubscription: true, timeoutMs: scope.remainingMs(), signal: scope.signal })[Symbol.asyncIterator]();\n for (;;) {\n const step = await raceExecWork(scope, () => iterator!.next(), request.awaitSettlement, streamStepUsage);\n if (step.done) { exhausted = true; return; }\n yield step.value;\n }\n } finally { await settleExecScope(scope, request.awaitSettlement, iterator, exhausted); }\n };\n }\n }\n\n detect(env: NodeJS.ProcessEnv, context?: ExecProbeContext) { return this.inner.detect(env, context); }\n auth(env: NodeJS.ProcessEnv, context?: ExecProbeContext, turn?: ExecProbeTurn) { return this.inner.auth(env, context, turn); }\n models() { return this.inner.models(); }\n async compatibility(env: NodeJS.ProcessEnv, version: string, context?: ExecProbeContext) {\n return this.inner.compatibility?.(env, version, context);\n }\n\n async execute(request: ExecTurnRequest) {\n const scope = new OperationScope({ timeoutMs: request.timeoutMs, ...(request.signal ? { signal: request.signal } : {}), context: { provider: this.id, transport: 'exec', retryable: true } });\n try {\n await scope.race(() => this.#check(request, scope));\n return await raceExecWork(scope, () => this.inner.execute({ ...request, requireSubscription: true, timeoutMs: scope.remainingMs(), signal: scope.signal }), request.awaitSettlement, resultUsage);\n } finally { if (request.awaitSettlement) await scope.drain(); scope.dispose(); }\n }\n\n async #check(request: ExecTurnRequest, scope: ExecProbeContext): Promise<void> {\n const context = { provider: this.id, transport: 'exec' as const, retryable: false };\n const auth = await this.inner.auth(request.env, scope, {\n cwd: request.cwd, contextArgs: request.contextArgs,\n ...(request.providerOptions === undefined ? {} : { providerOptions: request.providerOptions }),\n });\n if (!isAuthenticationConfirmed(auth)) throw new NotAuthenticatedError(this.id, context);\n if (auth.source !== 'subscription') {\n throw new UnexpectedAuthSourceError(this.id, {\n ...context, sanitizedDiagnostics: { detectedSource: auth.source },\n });\n }\n }\n}\n","import type { ControlAdapterRegistration } from '../core/registry.js';\nimport type {\n CapabilityStatus,\n CapabilitySupport,\n EnforcementReport,\n PermissionIntent,\n PermissionModeCeiling,\n SafetyEnvelope,\n TransportKind,\n} from '../public/types.js';\n\n/**\n * Compiles what a `Session` will actually be opened under: the negotiated\n * capability verdicts and the immutable SafetyEnvelope. Both are derived from\n * evidence gathered during readiness, never from adapter internals.\n */\n\nconst PERMISSION_MODE_CEILINGS: Record<PermissionIntent['mode'], PermissionModeCeiling> = {\n analyze: 'plan',\n respond: 'default',\n edit: 'acceptEdits',\n unrestricted: 'bypassPermissions',\n};\n\n/** Keep the public legacy report scoped to the selected transport too. */\nexport function controlFeatures(registration: ControlAdapterRegistration): Record<string, CapabilitySupport> {\n const features = Object.fromEntries(Object.entries(registration.capabilityVerdicts).map(([name, support]) => [\n name, support === 'full' ? 'supported' : support === 'none' ? 'unsupported'\n : support === 'unknown' ? 'unverified' : 'partial',\n ])) as Record<string, CapabilitySupport>;\n features.tokenDeltas = features.messageDeltas ?? 'unverified';\n return features;\n}\n\nfunction statusFromLegacy(support: CapabilitySupport, fingerprint: string): CapabilityStatus {\n const normalized = support === 'supported'\n ? 'full'\n : support === 'unsupported' ? 'none' : support === 'unverified' ? 'unknown' : 'partial';\n return {\n support: normalized,\n evidence: [{ source: 'compatibility-manifest', fingerprint }],\n };\n}\n\nexport function negotiateCapabilities(input: {\n transport: TransportKind;\n registration: ControlAdapterRegistration | undefined;\n features: Record<string, CapabilitySupport>;\n fingerprint: string;\n}): Record<string, CapabilityStatus> {\n const { registration } = input;\n const negotiated: Record<string, CapabilityStatus> = input.transport === 'control' && registration\n ? Object.fromEntries(\n Object.entries(registration.capabilityVerdicts).map(([name, support]) => [\n name,\n {\n support,\n evidence: [{ source: registration.evidenceSource, fingerprint: input.fingerprint }],\n } satisfies CapabilityStatus,\n ]),\n )\n : Object.fromEntries(\n Object.entries(input.features).map(([name, support]) => [\n name,\n statusFromLegacy(support, input.fingerprint),\n ]),\n );\n // Exec token deltas are the runtime's message-delta channel; expose the\n // portable name so requirements negotiate against one vocabulary.\n if (negotiated.tokenDeltas && !negotiated.messageDeltas) {\n negotiated.messageDeltas = negotiated.tokenDeltas;\n }\n return negotiated;\n}\n\nexport function buildSafetyEnvelope(input: {\n cwd: string;\n permissions: PermissionIntent;\n environmentVariables: string[];\n executableRealpath: string;\n modelId: string;\n enforcedBy: EnforcementReport['effective']['enforcedBy'];\n tools?: string[];\n /** MCP server names and config-layer markers (see `mcp-envelope.ts`); absent means none. */\n mcpServers?: string[];\n}): SafetyEnvelope {\n const { permissions } = input;\n return {\n authorityEpoch: crypto.randomUUID(),\n filesystem: {\n readonlyRoots: [input.cwd, ...(permissions.additionalDirectories ?? [])],\n writableRoots: permissions.mode === 'analyze' || permissions.mode === 'respond'\n ? []\n : [input.cwd, ...(permissions.additionalDirectories ?? [])],\n },\n network: permissions.network === 'allow' ? [{ protocol: 'https', host: '*' }] : [],\n tools: [...(input.tools ?? [])],\n executables: input.executableRealpath ? [input.executableRealpath] : [],\n mcpServers: [...(input.mcpServers ?? [])],\n environmentVariables: input.environmentVariables,\n settingsPersistence: 'none',\n enforcedBy: input.enforcedBy,\n permissionModeCeiling: PERMISSION_MODE_CEILINGS[permissions.mode],\n modelAllowlist: [input.modelId],\n };\n}\n","import type { CapabilitySupport, ProviderId } from '../public/types.js';\n\n/** Provider evidence cannot advertise channels the exec host cannot transport. */\nexport function buildExecFeatures(\n reported: Record<string, CapabilitySupport> = {},\n provider: ProviderId,\n streaming: boolean,\n): Record<string, CapabilitySupport> {\n const deltas = streaming\n ? reported.messageDeltas ?? reported.tokenDeltas ?? (provider === 'codex' ? 'unsupported' : 'unverified')\n : 'unsupported';\n return {\n turns: 'unverified',\n resume: 'unverified',\n forkWithPrompt: 'unverified',\n structuredOutput: 'unverified',\n ...reported,\n tokenDeltas: deltas,\n messageDeltas: deltas,\n forkWithoutPrompt: 'unsupported',\n images: 'unsupported',\n files: 'unsupported',\n interactiveApprovals: 'unsupported',\n userInputDuringTurn: 'unsupported',\n steering: 'unsupported',\n inProcessTools: 'unsupported',\n dynamicPermissions: 'unsupported',\n sessionInspection: 'unsupported',\n checkpointOrRollback: 'unsupported',\n processPersistence: 'unsupported',\n };\n}\n","import { resolve } from 'node:path';\n\n/**\n * What `SafetyEnvelope.mcpServers` records: the MCP servers a launch can reach,\n * by name where the SDK hands them over, and by marker where a configuration\n * layer the SDK does not read can add more.\n *\n * Claude exec (`providerOptions.claude.mcpConfigs`, `--mcp-config`):\n * - An inline JSON config contributes its server names.\n * - A path contributes `config:<absolute path>`, resolved against the agent's\n * cwd as the CLI resolves it. Readiness does not read the file: the CLI reads\n * it again on every turn, so names read now would describe a snapshot the\n * turn may no longer use. The marker records the authority that is actually\n * granted, \"whatever this file defines when the turn starts\".\n * - Inline text that is not a `{\"mcpServers\":{...}}` object contributes\n * `config:inline`, so its presence stays visible.\n * - Unless the launch passes `--strict-mcp-config` (`strictMcpConfig: true`,\n * or the `respond` intent) or `--safe-mode` (the `clean` profile), the CLI\n * also loads the servers of its own settings, project `.mcp.json` and\n * plugins: `config:claude-settings`.\n *\n * Codex exec (`providerOptions.codex.config`, `--config key=TOML`):\n * - `mcp_servers: { <name>: {...} }` and dotted keys `mcp_servers.<name>[.…]`\n * contribute `<name>`; an `mcp_servers` value that is not a table contributes\n * `config:inline`.\n * - Unless the launch passes `--ignore-user-config` (`ignoreUserConfig: true`,\n * or the `project`/`clean` profiles), `$CODEX_HOME/config.toml` loads with\n * its `mcp_servers`, and so does `<cwd>/.codex/config.toml` when that user\n * config marks the project as trusted: `config:codex-user` stands for both\n * layers. Codex control always loads them (it accepts only the native\n * profile), so it carries the marker too.\n *\n * Claude control registers the in-process `oar_application` server when the\n * agent has application tools. Codex control hands application tools over as\n * dynamic tools, not MCP, so they appear in `tools` only. Whatever the Claude\n * Agent SDK loads from settings by itself is not reflected.\n */\nexport const INLINE_MCP_CONFIG_MARKER = 'config:inline';\nexport const CLAUDE_SETTINGS_MCP_MARKER = 'config:claude-settings';\nexport const CODEX_USER_CONFIG_MARKER = 'config:codex-user';\n/** Mirrors `APPLICATION_TOOL_SERVER` in the Claude control adapter; a test keeps them equal. */\nexport const CLAUDE_APPLICATION_TOOL_SERVER = 'oar_application';\n\nexport interface EnvelopeMcpInput {\n provider: string;\n transport: 'exec' | 'control';\n cwd: string;\n /** The provider's own options object (`providerOptions.claude`, `.codex`). */\n providerOptions: Readonly<Record<string, unknown>> | undefined;\n contextArgs: readonly string[];\n permissionArgs: readonly string[];\n applicationTools: number;\n}\n\nexport function envelopeMcpServers(input: EnvelopeMcpInput): string[] {\n const options = input.providerOptions;\n if (input.provider === 'claude' && input.transport === 'exec') {\n const servers = mcpServersFromClaudeConfigs(options?.mcpConfigs, input.cwd);\n const strict = options?.strictMcpConfig === true || input.permissionArgs.includes('--strict-mcp-config');\n if (!strict && !input.contextArgs.includes('--safe-mode')) servers.push(CLAUDE_SETTINGS_MCP_MARKER);\n return servers;\n }\n if (input.provider === 'claude') return input.applicationTools > 0 ? [CLAUDE_APPLICATION_TOOL_SERVER] : [];\n if (input.provider === 'codex') {\n // Codex control refuses `mcp_servers` keys in its config, so only exec reads them.\n const servers = input.transport === 'exec' ? mcpServersFromCodexConfig(options?.config) : [];\n const ignored = input.contextArgs.includes('--ignore-user-config')\n || (input.transport === 'exec' && options?.ignoreUserConfig === true);\n if (!ignored) servers.push(CODEX_USER_CONFIG_MARKER);\n return servers;\n }\n return [];\n}\n\nexport function mcpServersFromClaudeConfigs(configs: unknown, cwd: string): string[] {\n if (!Array.isArray(configs)) return [];\n const servers = new Set<string>();\n for (const config of configs) {\n // Malformed entries are refused by the exec adapter before any turn runs.\n if (typeof config !== 'string' || config.trim() === '') continue;\n if (!config.trimStart().startsWith('{')) {\n servers.add(`config:${resolve(cwd, config)}`);\n continue;\n }\n const names = inlineServerNames(config);\n if (names === undefined) servers.add(INLINE_MCP_CONFIG_MARKER);\n else for (const name of names) servers.add(name);\n }\n return [...servers];\n}\n\n/** Server names in a Codex `--config` object, as the exec adapter turns each key into `key=TOML`. */\nexport function mcpServersFromCodexConfig(config: unknown): string[] {\n if (!isTable(config)) return [];\n const servers = new Set<string>();\n for (const [key, value] of Object.entries(config)) {\n if (key === 'mcp_servers') {\n if (isTable(value)) for (const name of Object.keys(value)) servers.add(name);\n else servers.add(INLINE_MCP_CONFIG_MARKER);\n } else if (key.startsWith('mcp_servers.')) {\n // The adapter accepts only dotted bare keys, so the second segment is the server name.\n servers.add(key.split('.')[1]!);\n }\n }\n return [...servers];\n}\n\nfunction isTable(value: unknown): value is Record<string, unknown> {\n return value !== null && typeof value === 'object' && !Array.isArray(value);\n}\n\nfunction inlineServerNames(config: string): string[] | undefined {\n try {\n const parsed = JSON.parse(config) as unknown;\n const map = isTable(parsed) ? parsed.mcpServers : undefined;\n return isTable(map) ? Object.keys(map) : undefined;\n } catch {\n return undefined;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,SAAS,aAAa;AACtB,SAAS,gBAAgB;;;ACazB,IAAM,eAA4D;AAAA,EAChE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA;AAAA;AAAA,EAGA;AACF;AAaA,SAAS,mBAAmB,OAAgC,QAAuB;AACjF,MAAI,MAAM,qBAAqB,OAAO;AACpC,UAAM,IAAI;AAAA,MACR,EAAE,UAAU,MAAM,UAAU,WAAW,WAAW,WAAW,MAAM;AAAA,MACnE,GAAG,MAAM,SAAS,MAAM,QAAQ;AAAA,IAClC;AAAA,EACF;AACA,QAAM,IAAI;AAAA,IACR,EAAE,UAAU,MAAM,UAAU,WAAW,WAAW,WAAW,MAAM;AAAA,IACnE,GAAG,MAAM,KAAK,0BAA0B,MAAM,QAAQ,CAAC;AAAA,EACzD;AACF;AAEA,SAAS,4BAA4B,OAA0C;AAC7E,QAAM,WAAW,aAAa,OAAO,CAAC,SAAS;AAC7C,UAAM,QAAQ,MAAM,aAAa,IAAI;AACrC,WAAO,UAAU,QAAQ,UAAU;AAAA,EACrC,CAAC;AACD,QAAM,qBAAqB,MAAM,aAAa;AAC9C,MAAI,MAAM,gBAAgB,aAAa,uBAAuB,QAAQ,uBAAuB,YAAY;AACvG,aAAS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","names":["context"]}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import {
|
|
2
|
+
checksum
|
|
3
|
+
} from "./chunk-EEUYQFCP.js";
|
|
4
|
+
|
|
5
|
+
// src/orchestration/workflow/checkpoint.ts
|
|
6
|
+
function nonempty(value, field) {
|
|
7
|
+
if (typeof value !== "string" || !value.trim()) throw new Error(`${field} must be a nonempty string`);
|
|
8
|
+
}
|
|
9
|
+
function jsonClone(value) {
|
|
10
|
+
const seen = /* @__PURE__ */ new Set();
|
|
11
|
+
const visit = (item) => {
|
|
12
|
+
if (item === null || typeof item === "string" || typeof item === "boolean") return;
|
|
13
|
+
if (typeof item === "number" && Number.isFinite(item)) return;
|
|
14
|
+
if (typeof item !== "object" || item === null) throw new Error("Workflow output must be JSON-compatible");
|
|
15
|
+
if (seen.has(item)) throw new Error("Workflow output must be JSON-compatible (cycle)");
|
|
16
|
+
const prototype = Object.getPrototypeOf(item);
|
|
17
|
+
if (Array.isArray(item) ? prototype !== Array.prototype : prototype !== Object.prototype && prototype !== null) {
|
|
18
|
+
throw new Error("Workflow output must be JSON-compatible (plain objects only)");
|
|
19
|
+
}
|
|
20
|
+
if (Object.getOwnPropertySymbols(item).length) throw new Error("Workflow output must be JSON-compatible");
|
|
21
|
+
for (const [key, descriptor] of Object.entries(Object.getOwnPropertyDescriptors(item))) {
|
|
22
|
+
if (Array.isArray(item) && key === "length") continue;
|
|
23
|
+
if (!Object.hasOwn(descriptor, "value") || !descriptor.enumerable) {
|
|
24
|
+
throw new Error("Workflow output must be JSON-compatible (enumerable data properties only)");
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
seen.add(item);
|
|
28
|
+
if (Array.isArray(item)) {
|
|
29
|
+
if (Object.keys(item).length !== item.length) throw new Error("Workflow output must be JSON-compatible (array holes/properties)");
|
|
30
|
+
for (let index = 0; index < item.length; index++) {
|
|
31
|
+
if (!Object.hasOwn(item, index)) throw new Error("Workflow output must be JSON-compatible (array hole)");
|
|
32
|
+
visit(item[index]);
|
|
33
|
+
}
|
|
34
|
+
} else {
|
|
35
|
+
for (const child of Object.values(item)) visit(child);
|
|
36
|
+
}
|
|
37
|
+
seen.delete(item);
|
|
38
|
+
};
|
|
39
|
+
visit(value);
|
|
40
|
+
return JSON.parse(JSON.stringify(value));
|
|
41
|
+
}
|
|
42
|
+
function identity(definition) {
|
|
43
|
+
nonempty(definition.id, "Workflow id");
|
|
44
|
+
nonempty(definition.version, "Workflow version");
|
|
45
|
+
for (const step of definition.steps) {
|
|
46
|
+
const attempts = step.maxAttempts ?? 1;
|
|
47
|
+
if (!Number.isSafeInteger(attempts) || attempts < 1) throw new Error(`Invalid maxAttempts for ${step.id}`);
|
|
48
|
+
if (step.replaySafe !== void 0 && typeof step.replaySafe !== "boolean") throw new Error(`Invalid replaySafe for ${step.id}`);
|
|
49
|
+
if (typeof step.execute !== "function") throw new Error(`Missing execute callback for ${step.id}`);
|
|
50
|
+
}
|
|
51
|
+
return {
|
|
52
|
+
id: definition.id,
|
|
53
|
+
version: definition.version,
|
|
54
|
+
fingerprint: checksum(JSON.stringify({
|
|
55
|
+
id: definition.id,
|
|
56
|
+
version: definition.version,
|
|
57
|
+
steps: definition.steps.map((step) => ({
|
|
58
|
+
id: step.id,
|
|
59
|
+
dependencies: [...step.dependencies ?? []].sort(),
|
|
60
|
+
maxAttempts: step.maxAttempts ?? 1,
|
|
61
|
+
replaySafe: step.replaySafe ?? false
|
|
62
|
+
}))
|
|
63
|
+
}))
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
function object(value) {
|
|
67
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
68
|
+
}
|
|
69
|
+
function validateCheckpoint(value, definition, runId) {
|
|
70
|
+
const fail = () => {
|
|
71
|
+
throw new Error("Corrupt workflow checkpoint");
|
|
72
|
+
};
|
|
73
|
+
if (!object(value) || value.format !== 1 || value.runId !== runId || !object(value.workflow)) return fail();
|
|
74
|
+
const wanted = identity(definition);
|
|
75
|
+
if (value.workflow.id !== wanted.id || value.workflow.version !== wanted.version || value.workflow.fingerprint !== wanted.fingerprint) throw new Error("Workflow definition does not match checkpoint");
|
|
76
|
+
if (typeof value.status !== "string" || !["running", "completed", "failed", "cancelled", "halted"].includes(value.status) || !object(value.steps)) return fail();
|
|
77
|
+
if (Object.keys(value.steps).length !== definition.steps.length) return fail();
|
|
78
|
+
for (const step of definition.steps) {
|
|
79
|
+
if (!Object.hasOwn(value.steps, step.id)) return fail();
|
|
80
|
+
const state = value.steps[step.id];
|
|
81
|
+
if (!object(state) || !Number.isSafeInteger(state.attempts)) return fail();
|
|
82
|
+
const attempts = state.attempts;
|
|
83
|
+
const max = step.maxAttempts ?? 1;
|
|
84
|
+
if (attempts < 0 || attempts > max) return fail();
|
|
85
|
+
if (typeof state.status !== "string" || !["pending", "running", "completed", "failed", "interrupted", "blocked"].includes(state.status)) return fail();
|
|
86
|
+
if (state.status === "pending" && attempts >= max) return fail();
|
|
87
|
+
if (state.status === "blocked" ? attempts !== 0 : state.status !== "pending" && attempts === 0) return fail();
|
|
88
|
+
if (state.status === "failed" && attempts !== max) return fail();
|
|
89
|
+
if (state.error !== void 0 && typeof state.error !== "string") return fail();
|
|
90
|
+
if (state.status === "completed" !== Object.hasOwn(state, "output")) return fail();
|
|
91
|
+
if (state.status === "completed") jsonClone(state.output);
|
|
92
|
+
if (attempts > 0) {
|
|
93
|
+
for (const dependency of step.dependencies ?? []) {
|
|
94
|
+
const parent = value.steps[dependency];
|
|
95
|
+
if (!object(parent) || parent.status !== "completed") return fail();
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
const states = Object.values(value.steps);
|
|
100
|
+
if (value.status === "completed" && !states.every((state) => state.status === "completed")) return fail();
|
|
101
|
+
if (value.status === "failed" && (states.some((state) => ["pending", "running", "interrupted"].includes(state.status)) || !states.some((state) => state.status === "failed"))) return fail();
|
|
102
|
+
return jsonClone(value);
|
|
103
|
+
}
|
|
104
|
+
function cloneSteps(steps) {
|
|
105
|
+
return steps.map((step) => ({ ...step, ...step.dependencies === void 0 ? {} : { dependencies: [...step.dependencies] } }));
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
export {
|
|
109
|
+
nonempty,
|
|
110
|
+
jsonClone,
|
|
111
|
+
identity,
|
|
112
|
+
validateCheckpoint,
|
|
113
|
+
cloneSteps
|
|
114
|
+
};
|
|
115
|
+
//# sourceMappingURL=chunk-CPN4DOXH.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/orchestration/workflow/checkpoint.ts"],"sourcesContent":["import { checksum } from '../../shared/json.js';\nimport type { JsonValue, WorkflowCheckpoint, WorkflowDefinition, WorkflowStep } from './types.js';\n\nexport { checksum };\n\nexport function nonempty(value: unknown, field: string): asserts value is string {\n if (typeof value !== 'string' || !value.trim()) throw new Error(`${field} must be a nonempty string`);\n}\n\n/** Validates rather than silently dropping undefined, Infinity, holes, cycles or toJSON objects. */\nexport function jsonClone<T>(value: T): T {\n const seen = new Set<object>();\n const visit = (item: unknown): void => {\n if (item === null || typeof item === 'string' || typeof item === 'boolean') return;\n if (typeof item === 'number' && Number.isFinite(item)) return;\n if (typeof item !== 'object' || item === null) throw new Error('Workflow output must be JSON-compatible');\n if (seen.has(item)) throw new Error('Workflow output must be JSON-compatible (cycle)');\n const prototype = Object.getPrototypeOf(item);\n if (Array.isArray(item) ? prototype !== Array.prototype : prototype !== Object.prototype && prototype !== null) {\n throw new Error('Workflow output must be JSON-compatible (plain objects only)');\n }\n if (Object.getOwnPropertySymbols(item).length) throw new Error('Workflow output must be JSON-compatible');\n for (const [key, descriptor] of Object.entries(Object.getOwnPropertyDescriptors(item))) {\n if (Array.isArray(item) && key === 'length') continue;\n if (!Object.hasOwn(descriptor, 'value') || !descriptor.enumerable) {\n throw new Error('Workflow output must be JSON-compatible (enumerable data properties only)');\n }\n }\n seen.add(item);\n if (Array.isArray(item)) {\n if (Object.keys(item).length !== item.length) throw new Error('Workflow output must be JSON-compatible (array holes/properties)');\n for (let index = 0; index < item.length; index++) {\n if (!Object.hasOwn(item, index)) throw new Error('Workflow output must be JSON-compatible (array hole)');\n visit(item[index]);\n }\n } else {\n for (const child of Object.values(item)) visit(child);\n }\n seen.delete(item);\n };\n visit(value);\n return JSON.parse(JSON.stringify(value)) as T;\n}\n\nexport function identity(definition: WorkflowDefinition): WorkflowCheckpoint['workflow'] {\n nonempty(definition.id, 'Workflow id'); nonempty(definition.version, 'Workflow version');\n for (const step of definition.steps) {\n const attempts = step.maxAttempts ?? 1;\n if (!Number.isSafeInteger(attempts) || attempts < 1) throw new Error(`Invalid maxAttempts for ${step.id}`);\n if (step.replaySafe !== undefined && typeof step.replaySafe !== 'boolean') throw new Error(`Invalid replaySafe for ${step.id}`);\n if (typeof step.execute !== 'function') throw new Error(`Missing execute callback for ${step.id}`);\n }\n return {\n id: definition.id, version: definition.version,\n fingerprint: checksum(JSON.stringify({\n id: definition.id, version: definition.version,\n steps: definition.steps.map(step => ({\n id: step.id, dependencies: [...(step.dependencies ?? [])].sort(),\n maxAttempts: step.maxAttempts ?? 1, replaySafe: step.replaySafe ?? false,\n })),\n })),\n };\n}\n\nfunction object(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null && !Array.isArray(value);\n}\n\nexport function validateCheckpoint(\n value: unknown, definition: WorkflowDefinition, runId: string,\n): WorkflowCheckpoint {\n const fail = (): never => { throw new Error('Corrupt workflow checkpoint'); };\n if (!object(value) || value.format !== 1 || value.runId !== runId || !object(value.workflow)) return fail();\n const wanted = identity(definition);\n if (value.workflow.id !== wanted.id || value.workflow.version !== wanted.version\n || value.workflow.fingerprint !== wanted.fingerprint) throw new Error('Workflow definition does not match checkpoint');\n if (typeof value.status !== 'string' || !['running', 'completed', 'failed', 'cancelled', 'halted'].includes(value.status) || !object(value.steps)) return fail();\n if (Object.keys(value.steps).length !== definition.steps.length) return fail();\n for (const step of definition.steps) {\n if (!Object.hasOwn(value.steps, step.id)) return fail();\n const state = value.steps[step.id];\n if (!object(state) || !Number.isSafeInteger(state.attempts)) return fail();\n const attempts = state.attempts as number; const max = step.maxAttempts ?? 1;\n if (attempts < 0 || attempts > max) return fail();\n if (typeof state.status !== 'string' || !['pending', 'running', 'completed', 'failed', 'interrupted', 'blocked'].includes(state.status)) return fail();\n if (state.status === 'pending' && attempts >= max) return fail();\n if (state.status === 'blocked' ? attempts !== 0 : state.status !== 'pending' && attempts === 0) return fail();\n if (state.status === 'failed' && attempts !== max) return fail();\n if (state.error !== undefined && typeof state.error !== 'string') return fail();\n if ((state.status === 'completed') !== Object.hasOwn(state, 'output')) return fail();\n if (state.status === 'completed') jsonClone(state.output as JsonValue);\n if (attempts > 0) {\n for (const dependency of step.dependencies ?? []) {\n const parent = value.steps[dependency];\n if (!object(parent) || parent.status !== 'completed') return fail();\n }\n }\n }\n const states = Object.values(value.steps) as unknown as WorkflowCheckpoint['steps'][string][];\n if (value.status === 'completed' && !states.every(state => state.status === 'completed')) return fail();\n if (value.status === 'failed' && (states.some(state => ['pending', 'running', 'interrupted'].includes(state.status))\n || !states.some(state => state.status === 'failed'))) return fail();\n return jsonClone(value) as unknown as WorkflowCheckpoint;\n}\n\nexport function cloneSteps(steps: readonly WorkflowStep[]): WorkflowStep[] {\n return steps.map(step => ({ ...step, ...(step.dependencies === undefined ? {} : { dependencies: [...step.dependencies] }) }));\n}\n"],"mappings":";;;;;AAKO,SAAS,SAAS,OAAgB,OAAwC;AAC/E,MAAI,OAAO,UAAU,YAAY,CAAC,MAAM,KAAK,EAAG,OAAM,IAAI,MAAM,GAAG,KAAK,4BAA4B;AACtG;AAGO,SAAS,UAAa,OAAa;AACxC,QAAM,OAAO,oBAAI,IAAY;AAC7B,QAAM,QAAQ,CAAC,SAAwB;AACrC,QAAI,SAAS,QAAQ,OAAO,SAAS,YAAY,OAAO,SAAS,UAAW;AAC5E,QAAI,OAAO,SAAS,YAAY,OAAO,SAAS,IAAI,EAAG;AACvD,QAAI,OAAO,SAAS,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;AAAA,IACF;AAAA,EACF;AACA,QAAM,SAAS,OAAO,OAAO,MAAM,KAAK;AACxC,MAAI,MAAM,WAAW,eAAe,CAAC,OAAO,MAAM,WAAS,MAAM,WAAW,WAAW,EAAG,QAAO,KAAK;AACtG,MAAI,MAAM,WAAW,aAAa,OAAO,KAAK,WAAS,CAAC,WAAW,WAAW,aAAa,EAAE,SAAS,MAAM,MAAM,CAAC,KAC9G,CAAC,OAAO,KAAK,WAAS,MAAM,WAAW,QAAQ,GAAI,QAAO,KAAK;AACpE,SAAO,UAAU,KAAK;AACxB;AAEO,SAAS,WAAW,OAAgD;AACzE,SAAO,MAAM,IAAI,WAAS,EAAE,GAAG,MAAM,GAAI,KAAK,iBAAiB,SAAY,CAAC,IAAI,EAAE,cAAc,CAAC,GAAG,KAAK,YAAY,EAAE,EAAG,EAAE;AAC9H;","names":[]}
|
|
@@ -0,0 +1,385 @@
|
|
|
1
|
+
import {
|
|
2
|
+
rethrowExecutionHalt
|
|
3
|
+
} from "./chunk-NCNSHOF7.js";
|
|
4
|
+
import {
|
|
5
|
+
OutputLimitError
|
|
6
|
+
} from "./chunk-TG7NTMTR.js";
|
|
7
|
+
|
|
8
|
+
// src/adapters/provider-limits.ts
|
|
9
|
+
import { types } from "node:util";
|
|
10
|
+
var names = [
|
|
11
|
+
"primary",
|
|
12
|
+
"secondary",
|
|
13
|
+
"error",
|
|
14
|
+
"five_hour",
|
|
15
|
+
"seven_day",
|
|
16
|
+
"seven_day_opus",
|
|
17
|
+
"seven_day_sonnet",
|
|
18
|
+
"seven_day_oauth_apps",
|
|
19
|
+
"seven_day_overage_included",
|
|
20
|
+
"overage",
|
|
21
|
+
"unrecognized"
|
|
22
|
+
];
|
|
23
|
+
var statuses = ["allowed", "allowed_warning", "rejected"];
|
|
24
|
+
var sources = ["claude-rate-limit-event", "codex-token-count", "codex-account-rate-limits", "codex-usage-error"];
|
|
25
|
+
var object = (v) => v !== null && typeof v === "object" && !types.isProxy(v) && !Array.isArray(v);
|
|
26
|
+
function own(v, key) {
|
|
27
|
+
if (!object(v)) return void 0;
|
|
28
|
+
const descriptor = Object.getOwnPropertyDescriptor(v, key);
|
|
29
|
+
return descriptor && "value" in descriptor ? descriptor.value : void 0;
|
|
30
|
+
}
|
|
31
|
+
var integer = (v) => Number.isSafeInteger(v) && v >= 0;
|
|
32
|
+
var ratio = (v) => typeof v === "number" && Number.isFinite(v) && v >= 0 && v <= 1e3;
|
|
33
|
+
var name = (v) => typeof v === "string" && names.includes(v) ? v : "unrecognized";
|
|
34
|
+
var status = (v) => typeof v === "string" && statuses.includes(v) ? v : "unrecognized";
|
|
35
|
+
function window(raw, label, camel = false) {
|
|
36
|
+
if (!object(raw)) return void 0;
|
|
37
|
+
const used = own(raw, camel ? "usedPercent" : "used_percent");
|
|
38
|
+
const minutes = own(raw, camel ? "windowDurationMins" : "window_minutes");
|
|
39
|
+
const reset = own(raw, camel ? "resetsAt" : "resets_at");
|
|
40
|
+
return Object.freeze({
|
|
41
|
+
name: label,
|
|
42
|
+
...ratio(used) ? { usedPercent: used } : {},
|
|
43
|
+
...integer(minutes) && minutes <= 525600 ? { windowMinutes: minutes } : {},
|
|
44
|
+
...integer(reset) ? { reset: Object.freeze({ value: reset, unit: "unverified" }) } : {}
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
function readProviderRateLimits(provider, raw, receivedAt = Date.now()) {
|
|
48
|
+
if (!integer(receivedAt)) return void 0;
|
|
49
|
+
const timestamp = own(raw, "timestamp");
|
|
50
|
+
const eventAt = typeof timestamp === "string" && /^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d(?:\.\d{1,9})?Z$/.test(timestamp) ? Date.parse(timestamp) : NaN;
|
|
51
|
+
const observedAt = Object.freeze({
|
|
52
|
+
value: Number.isFinite(eventAt) ? eventAt : receivedAt,
|
|
53
|
+
source: Number.isFinite(eventAt) ? "event-timestamp" : "sdk-receive-clock"
|
|
54
|
+
});
|
|
55
|
+
const info = own(raw, "rate_limit_info");
|
|
56
|
+
if (provider === "claude" && own(raw, "type") === "rate_limit_event" && object(info)) {
|
|
57
|
+
const reset = own(info, "resetsAt"), utilization = own(info, "utilization");
|
|
58
|
+
return Object.freeze({
|
|
59
|
+
type: "rate-limit.observed",
|
|
60
|
+
provider,
|
|
61
|
+
source: "claude-rate-limit-event",
|
|
62
|
+
status: status(own(info, "status")),
|
|
63
|
+
observedAt,
|
|
64
|
+
windows: Object.freeze([Object.freeze({
|
|
65
|
+
name: name(own(info, "rateLimitType")),
|
|
66
|
+
...ratio(utilization) ? { utilization } : {},
|
|
67
|
+
...integer(reset) ? { reset: Object.freeze({ value: reset, unit: "unverified" }) } : {}
|
|
68
|
+
})]),
|
|
69
|
+
...own(info, "errorCode") === "credits_required" ? { code: "credits_required" } : {}
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
if (provider !== "codex") return void 0;
|
|
73
|
+
const payload = own(raw, "payload"), type = own(raw, "type");
|
|
74
|
+
let limits, source = "codex-token-count", camel = false;
|
|
75
|
+
if (type === "event_msg" && own(payload, "type") === "token_count") limits = own(payload, "rate_limits");
|
|
76
|
+
else if (type === "token_count") limits = own(raw, "rate_limits");
|
|
77
|
+
else if (own(raw, "method") === "account/rateLimits/updated") {
|
|
78
|
+
limits = own(own(raw, "params"), "rateLimits");
|
|
79
|
+
camel = true;
|
|
80
|
+
source = "codex-account-rate-limits";
|
|
81
|
+
}
|
|
82
|
+
if (object(limits)) return Object.freeze({
|
|
83
|
+
type: "rate-limit.observed",
|
|
84
|
+
provider,
|
|
85
|
+
source,
|
|
86
|
+
observedAt,
|
|
87
|
+
windows: Object.freeze(["primary", "secondary"].flatMap((label) => {
|
|
88
|
+
const item2 = window(own(limits, label), label, camel);
|
|
89
|
+
return item2 ? [item2] : [];
|
|
90
|
+
}))
|
|
91
|
+
});
|
|
92
|
+
const error = type === "error" ? own(raw, "error") : own(payload, "type") === "error" ? own(payload, "error") : void 0;
|
|
93
|
+
if (own(error, "type") !== "usage_limit_reached" && own(error, "code") !== "usage_limit_reached") return void 0;
|
|
94
|
+
const item = window(error, "error");
|
|
95
|
+
return Object.freeze({
|
|
96
|
+
type: "rate-limit.observed",
|
|
97
|
+
provider,
|
|
98
|
+
source: "codex-usage-error",
|
|
99
|
+
status: "rejected",
|
|
100
|
+
observedAt,
|
|
101
|
+
windows: Object.freeze(item ? [item] : [])
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
function captureProviderRateLimits(value) {
|
|
105
|
+
const provider = own(value, "provider"), source = own(value, "source"), rawWindows = own(value, "windows"), rawClock = own(value, "observedAt"), clock = own(rawClock, "value"), clockSource = own(rawClock, "source");
|
|
106
|
+
if (own(value, "type") !== "rate-limit.observed" || !["claude", "codex"].includes(provider) || !sources.includes(source) || !integer(clock) || !["event-timestamp", "sdk-receive-clock"].includes(clockSource) || !Array.isArray(rawWindows) || types.isProxy(rawWindows) || rawWindows.length > 2) return void 0;
|
|
107
|
+
const windows = [];
|
|
108
|
+
for (let i = 0; i < rawWindows.length; i++) {
|
|
109
|
+
const descriptor = Object.getOwnPropertyDescriptor(rawWindows, String(i));
|
|
110
|
+
if (!descriptor || !("value" in descriptor) || !object(descriptor.value)) return void 0;
|
|
111
|
+
const raw = descriptor.value, reset = own(own(raw, "reset"), "value"), used = own(raw, "usedPercent"), utilization = own(raw, "utilization"), minutes = own(raw, "windowMinutes");
|
|
112
|
+
windows.push(Object.freeze({
|
|
113
|
+
name: name(own(raw, "name")),
|
|
114
|
+
...ratio(used) ? { usedPercent: used } : {},
|
|
115
|
+
...ratio(utilization) ? { utilization } : {},
|
|
116
|
+
...integer(minutes) && minutes <= 525600 ? { windowMinutes: minutes } : {},
|
|
117
|
+
...integer(reset) ? { reset: Object.freeze({ value: reset, unit: "unverified" }) } : {}
|
|
118
|
+
}));
|
|
119
|
+
}
|
|
120
|
+
if (new Set(windows.map((w) => w.name)).size !== windows.length) return void 0;
|
|
121
|
+
if (provider === "claude" !== (source === "claude-rate-limit-event")) return void 0;
|
|
122
|
+
return Object.freeze({
|
|
123
|
+
type: "rate-limit.observed",
|
|
124
|
+
provider,
|
|
125
|
+
source,
|
|
126
|
+
observedAt: Object.freeze({
|
|
127
|
+
value: clock,
|
|
128
|
+
source: clockSource
|
|
129
|
+
}),
|
|
130
|
+
windows: Object.freeze(windows),
|
|
131
|
+
...own(value, "status") === void 0 ? {} : { status: status(own(value, "status")) },
|
|
132
|
+
...own(value, "code") === "credits_required" ? { code: "credits_required" } : {}
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
function resolveProviderRateLimits(input) {
|
|
136
|
+
const value = captureProviderRateLimits(input);
|
|
137
|
+
if (!value) return void 0;
|
|
138
|
+
return Object.freeze({ ...value, windows: Object.freeze(value.windows.map((w) => {
|
|
139
|
+
if (!w.reset) return w;
|
|
140
|
+
const atMs = w.reset.value * 1e3, elapsed = atMs - value.observedAt.value;
|
|
141
|
+
const minutes = w.windowMinutes && w.windowMinutes > 0 ? w.windowMinutes : w.name === "five_hour" ? 300 : w.name.startsWith("seven_day") ? 10080 : void 0;
|
|
142
|
+
if (!Number.isSafeInteger(atMs) || !Number.isFinite(new Date(atMs).getTime()) || elapsed <= 0 || minutes !== void 0 && elapsed > minutes * 6e4) return w;
|
|
143
|
+
return Object.freeze({ ...w, reset: Object.freeze({ value: w.reset.value, unit: "unix-seconds", atMs }) });
|
|
144
|
+
})) });
|
|
145
|
+
}
|
|
146
|
+
function providerUsageRetryAt(input) {
|
|
147
|
+
const value = resolveProviderRateLimits(input);
|
|
148
|
+
if (!value || value.status !== "rejected" || value.code === "credits_required" || value.windows.length !== 1) return void 0;
|
|
149
|
+
const w = value.windows[0];
|
|
150
|
+
if (value.source === "claude-rate-limit-event" && ![
|
|
151
|
+
"five_hour",
|
|
152
|
+
"seven_day",
|
|
153
|
+
"seven_day_opus",
|
|
154
|
+
"seven_day_sonnet",
|
|
155
|
+
"seven_day_oauth_apps",
|
|
156
|
+
"seven_day_overage_included"
|
|
157
|
+
].includes(w.name)) return void 0;
|
|
158
|
+
if (value.source !== "claude-rate-limit-event" && value.source !== "codex-usage-error") return void 0;
|
|
159
|
+
const at = w.reset?.atMs;
|
|
160
|
+
return at !== void 0 && at > Date.now() ? at : void 0;
|
|
161
|
+
}
|
|
162
|
+
function confirmedUsageRetryAt(events) {
|
|
163
|
+
const latest = /* @__PURE__ */ new Map();
|
|
164
|
+
for (const event of events) if (event.type === "provider.event") {
|
|
165
|
+
const value = captureProviderRateLimits(event.event);
|
|
166
|
+
if (value && value.provider === event.provider) for (const w of value.windows)
|
|
167
|
+
latest.set(`${value.provider}:${value.source}:${w.name}`, value);
|
|
168
|
+
}
|
|
169
|
+
const candidates = [...latest.values()].filter((v) => v.status === "rejected");
|
|
170
|
+
if (candidates.length !== 1) return void 0;
|
|
171
|
+
return providerUsageRetryAt(candidates[0]);
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
// src/process/jsonl-frames.ts
|
|
175
|
+
var DEFAULT_MAX_FRAME_BYTES = 1024 * 1024;
|
|
176
|
+
function assertJsonlFrame(frame, limit = DEFAULT_MAX_FRAME_BYTES) {
|
|
177
|
+
if (Buffer.byteLength(frame, "utf8") <= limit) return;
|
|
178
|
+
throw new OutputLimitError(
|
|
179
|
+
{ retryable: false, sanitizedDiagnostics: { maxFrameBytes: limit } },
|
|
180
|
+
`JSONL frame exceeded ${limit} buffered bytes`
|
|
181
|
+
);
|
|
182
|
+
}
|
|
183
|
+
function* jsonlFrames(raw) {
|
|
184
|
+
for (const line of raw.split(/\r?\n/)) {
|
|
185
|
+
assertJsonlFrame(line);
|
|
186
|
+
yield line;
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
// src/process/json-lines.ts
|
|
191
|
+
var IncrementalLineDecoder = class {
|
|
192
|
+
#decoder = new TextDecoder();
|
|
193
|
+
#maxBufferedBytes;
|
|
194
|
+
#buffer = "";
|
|
195
|
+
#failure;
|
|
196
|
+
constructor(options = {}) {
|
|
197
|
+
this.#maxBufferedBytes = options.maxBufferedBytes ?? DEFAULT_MAX_FRAME_BYTES;
|
|
198
|
+
}
|
|
199
|
+
#checkFrame(frame) {
|
|
200
|
+
try {
|
|
201
|
+
assertJsonlFrame(frame, this.#maxBufferedBytes);
|
|
202
|
+
} catch (error) {
|
|
203
|
+
this.#buffer = "";
|
|
204
|
+
this.#failure = error;
|
|
205
|
+
throw error;
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
/**
|
|
209
|
+
* A frame over the limit is terminal: the partial frame is discarded, the
|
|
210
|
+
* same error is rethrown for every later chunk, and the frame is never
|
|
211
|
+
* delivered when its newline finally arrives. Throwing once per chunk while
|
|
212
|
+
* keeping the buffer used to surface as one uncaught exception per chunk in
|
|
213
|
+
* the host and then hand the oversized frame to the consumer anyway.
|
|
214
|
+
*/
|
|
215
|
+
push(chunk) {
|
|
216
|
+
if (this.#failure) throw this.#failure;
|
|
217
|
+
this.#buffer += this.#decoder.decode(chunk, { stream: true });
|
|
218
|
+
const lines = this.#buffer.split(/\r?\n/);
|
|
219
|
+
this.#buffer = lines.pop() ?? "";
|
|
220
|
+
for (const line of lines) this.#checkFrame(line);
|
|
221
|
+
this.#checkFrame(this.#buffer.endsWith("\r") ? this.#buffer.slice(0, -1) : this.#buffer);
|
|
222
|
+
return lines;
|
|
223
|
+
}
|
|
224
|
+
assertHealthy() {
|
|
225
|
+
if (this.#failure) throw this.#failure;
|
|
226
|
+
}
|
|
227
|
+
finish() {
|
|
228
|
+
if (this.#failure) return [];
|
|
229
|
+
this.#buffer += this.#decoder.decode();
|
|
230
|
+
this.#checkFrame(this.#buffer);
|
|
231
|
+
if (this.#buffer.length === 0) return [];
|
|
232
|
+
const line = this.#buffer;
|
|
233
|
+
this.#buffer = "";
|
|
234
|
+
return [line];
|
|
235
|
+
}
|
|
236
|
+
};
|
|
237
|
+
async function guardJsonlFrames(work) {
|
|
238
|
+
const frames = new IncrementalLineDecoder();
|
|
239
|
+
try {
|
|
240
|
+
const result = await work((chunk) => {
|
|
241
|
+
frames.push(chunk);
|
|
242
|
+
});
|
|
243
|
+
frames.finish();
|
|
244
|
+
return result;
|
|
245
|
+
} finally {
|
|
246
|
+
frames.assertHealthy();
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
var ProtocolResultAccumulator = class {
|
|
250
|
+
#events = [];
|
|
251
|
+
#nativeEvents = [];
|
|
252
|
+
#verdictLines = [];
|
|
253
|
+
#sessionId;
|
|
254
|
+
#turnId;
|
|
255
|
+
#text = "";
|
|
256
|
+
observe(line, parsed) {
|
|
257
|
+
if (parsed.sessionId !== void 0) this.#sessionId = parsed.sessionId;
|
|
258
|
+
if (parsed.turnId !== void 0) this.#turnId = parsed.turnId;
|
|
259
|
+
for (const event of parsed.events) {
|
|
260
|
+
if (event.type === "message.completed") this.#text = event.text;
|
|
261
|
+
}
|
|
262
|
+
this.#events.push(...parsed.events);
|
|
263
|
+
this.#nativeEvents.push(...parsed.nativeEvents);
|
|
264
|
+
if (parsed.terminalEvent !== void 0 || parsed.failure !== void 0 && parsed.failure.kind !== "protocol") {
|
|
265
|
+
this.#verdictLines.push(line);
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
finish(parse) {
|
|
269
|
+
const verdict = parse(this.#verdictLines.join("\n"));
|
|
270
|
+
const retryAt = confirmedUsageRetryAt(this.#events);
|
|
271
|
+
const terminal = verdict.terminalEvent;
|
|
272
|
+
const failure = verdict.failure && terminal?.type === "result" && terminal.api_error_status === 429 && retryAt !== void 0 ? { kind: "usage-limit", message: "Provider usage limit reached" } : verdict.failure;
|
|
273
|
+
return {
|
|
274
|
+
...verdict,
|
|
275
|
+
...failure?.kind === "usage-limit" && retryAt !== void 0 ? { failure: { ...failure, retryAt } } : {},
|
|
276
|
+
...this.#sessionId === void 0 ? {} : { sessionId: this.#sessionId },
|
|
277
|
+
...this.#turnId === void 0 ? {} : { turnId: this.#turnId },
|
|
278
|
+
text: this.#text,
|
|
279
|
+
events: this.#events,
|
|
280
|
+
nativeEvents: this.#nativeEvents
|
|
281
|
+
};
|
|
282
|
+
}
|
|
283
|
+
};
|
|
284
|
+
|
|
285
|
+
// src/process/resolve-binary.ts
|
|
286
|
+
import { execFileSync } from "node:child_process";
|
|
287
|
+
import { accessSync, constants, existsSync, realpathSync } from "node:fs";
|
|
288
|
+
import { delimiter, extname, join } from "node:path";
|
|
289
|
+
function resolveBinary(name2, options = {}) {
|
|
290
|
+
return resolveBinaryCandidates(name2, options)[0];
|
|
291
|
+
}
|
|
292
|
+
function resolveBinaryCandidates(name2, options = {}) {
|
|
293
|
+
const platform = options.platform ?? process.platform;
|
|
294
|
+
const env = options.env ?? process.env;
|
|
295
|
+
if (platform !== "win32") {
|
|
296
|
+
const candidates = name2.includes("/") ? [name2] : (env.PATH ?? "").split(delimiter).filter(Boolean).map((directory) => join(directory, name2));
|
|
297
|
+
const targets = /* @__PURE__ */ new Map();
|
|
298
|
+
for (const candidate of candidates) {
|
|
299
|
+
try {
|
|
300
|
+
accessSync(candidate, constants.X_OK);
|
|
301
|
+
const command = realpathSync(candidate);
|
|
302
|
+
targets.set(command, { command, argsPrefix: [] });
|
|
303
|
+
} catch {
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
return [...targets.values()];
|
|
307
|
+
}
|
|
308
|
+
let paths;
|
|
309
|
+
try {
|
|
310
|
+
const output = execFileSync("where.exe", [name2], {
|
|
311
|
+
encoding: "utf8",
|
|
312
|
+
env,
|
|
313
|
+
stdio: ["ignore", "pipe", "ignore"]
|
|
314
|
+
});
|
|
315
|
+
paths = output.split(/\r?\n/).map((value) => value.trim()).filter(Boolean);
|
|
316
|
+
} catch {
|
|
317
|
+
return [];
|
|
318
|
+
}
|
|
319
|
+
const executables = paths.filter(
|
|
320
|
+
(path) => extname(path).toLowerCase() === ".exe" && existsSync(path)
|
|
321
|
+
);
|
|
322
|
+
return [...new Set(executables.map((path) => realpathSync(path)))].map((command) => ({ command, argsPrefix: [] }));
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
// src/process/exec-discovery.ts
|
|
326
|
+
import { realpath } from "node:fs/promises";
|
|
327
|
+
import { isAbsolute } from "node:path";
|
|
328
|
+
var ExecDiscovery = class {
|
|
329
|
+
constructor(name2, runner, configured) {
|
|
330
|
+
this.name = name2;
|
|
331
|
+
this.runner = runner;
|
|
332
|
+
this.configured = configured;
|
|
333
|
+
}
|
|
334
|
+
name;
|
|
335
|
+
runner;
|
|
336
|
+
configured;
|
|
337
|
+
#selected = /* @__PURE__ */ new WeakMap();
|
|
338
|
+
target(env) {
|
|
339
|
+
return this.configured ?? this.#selected.get(env) ?? resolveBinary(this.name, { env });
|
|
340
|
+
}
|
|
341
|
+
async detect(env, context) {
|
|
342
|
+
this.#selected.delete(env);
|
|
343
|
+
const candidates = this.configured ? [this.configured] : resolveBinaryCandidates(this.name, { env });
|
|
344
|
+
for (const target of candidates) {
|
|
345
|
+
if (context?.signal.aborted) throw context.signal.reason;
|
|
346
|
+
try {
|
|
347
|
+
const result = await this.runner({
|
|
348
|
+
command: target.command,
|
|
349
|
+
args: [...target.argsPrefix, "--version"],
|
|
350
|
+
cwd: process.cwd(),
|
|
351
|
+
env,
|
|
352
|
+
stdin: "",
|
|
353
|
+
timeoutMs: Math.min(15e3, context?.remainingMs() ?? 15e3),
|
|
354
|
+
maxOutputBytes: 16384,
|
|
355
|
+
...context ? { signal: context.signal } : {}
|
|
356
|
+
});
|
|
357
|
+
if (result.code !== 0) continue;
|
|
358
|
+
const version = result.stdout.match(/\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?/)?.[0];
|
|
359
|
+
this.#selected.set(env, target);
|
|
360
|
+
const command = await realpath(target.command).catch(() => target.command);
|
|
361
|
+
const identityFiles = await Promise.all(target.argsPrefix.filter((arg) => isAbsolute(arg)).map((file) => realpath(file)));
|
|
362
|
+
const launchTarget = { command, argsPrefix: [...target.argsPrefix] };
|
|
363
|
+
return { installed: true, path: command, launchTarget, ...identityFiles.length ? { identityFiles } : {}, ...version ? { version } : {} };
|
|
364
|
+
} catch (error) {
|
|
365
|
+
rethrowExecutionHalt(error);
|
|
366
|
+
if (context?.signal.aborted) throw context.signal.reason ?? error;
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
return { installed: false };
|
|
370
|
+
}
|
|
371
|
+
};
|
|
372
|
+
|
|
373
|
+
export {
|
|
374
|
+
jsonlFrames,
|
|
375
|
+
readProviderRateLimits,
|
|
376
|
+
resolveProviderRateLimits,
|
|
377
|
+
confirmedUsageRetryAt,
|
|
378
|
+
IncrementalLineDecoder,
|
|
379
|
+
guardJsonlFrames,
|
|
380
|
+
ProtocolResultAccumulator,
|
|
381
|
+
resolveBinary,
|
|
382
|
+
resolveBinaryCandidates,
|
|
383
|
+
ExecDiscovery
|
|
384
|
+
};
|
|
385
|
+
//# sourceMappingURL=chunk-DBFXFWQZ.js.map
|