@bastani/atomic 0.9.26-alpha.5 → 0.9.26
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/CHANGELOG.md +68 -0
- package/dist/builtin/intercom/CHANGELOG.md +6 -0
- package/dist/builtin/intercom/package.json +2 -2
- package/dist/builtin/mcp/package.json +1 -1
- package/dist/builtin/subagents/package.json +3 -3
- package/dist/builtin/web-access/package.json +2 -2
- package/dist/builtin/workflows/CHANGELOG.md +21 -0
- package/dist/builtin/workflows/builtin/{chunk-613yaa53.js → chunk-9bhs02gm.js} +195 -10
- package/dist/builtin/workflows/builtin/{chunk-6kqrk0pf.js → chunk-gts8wgjr.js} +1 -1
- package/dist/builtin/workflows/builtin/{chunk-ea6nrbn3.js → chunk-gw7rghda.js} +1 -1
- package/dist/builtin/workflows/builtin/goal.js +2 -2
- package/dist/builtin/workflows/builtin/index.js +3 -3
- package/dist/builtin/workflows/builtin/ralph.js +2 -2
- package/dist/builtin/workflows/package.json +2 -2
- package/dist/builtin/workflows/src/extension/index.bundle.mjs +1082 -220
- package/dist/builtin/workflows/src/index.js +967 -186
- package/dist/core/extensions/workflow-run-control.d.ts +3 -0
- package/dist/core/extensions/workflow-run-control.d.ts.map +1 -1
- package/dist/core/extensions/workflow-run-control.js.map +1 -1
- package/dist/core/fast-model-routing.d.ts.map +1 -1
- package/dist/core/fast-model-routing.js +1 -5
- package/dist/core/fast-model-routing.js.map +1 -1
- package/dist/core/model-config.d.ts +36 -0
- package/dist/core/model-config.d.ts.map +1 -1
- package/dist/core/model-config.js +14 -2
- package/dist/core/model-config.js.map +1 -1
- package/dist/core/provider-composer-internal.d.ts +2 -1
- package/dist/core/provider-composer-internal.d.ts.map +1 -1
- package/dist/core/provider-composer-internal.js +13 -0
- package/dist/core/provider-composer-internal.js.map +1 -1
- package/docs/models/reference.md +28 -1
- package/docs/models.md +4 -0
- package/docs/sdk.md +26 -2
- package/docs/workflows/operations.md +15 -1
- package/npm-shrinkwrap.json +67 -67
- package/package.json +8 -8
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"provider-composer-internal.js","sourceRoot":"","sources":["../../src/core/provider-composer-internal.ts"],"names":[],"mappings":"AAuBA,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAE7C,OAAO,EACN,qBAAqB,EACrB,yBAAyB,EACzB,oBAAoB,EACpB,yBAAyB,EACzB,qBAAqB,GACrB,MAAM,2BAA2B,CAAC;AAmFnC,MAAM,CAAC,MAAM,gBAAgB,GAAG,qBAAqB,CAAC;AAEtD,SAAS,WAAW,CACnB,IAA0B,EAC1B,QAAkE;IAElE,IAAI,CAAC,QAAQ;QAAE,OAAO,IAAI,CAAC;IAC3B,MAAM,MAAM,GAAG,EAAE,GAAG,IAAI,EAAE,GAAG,QAAQ,EAAuC,CAAC;IAC7E,MAAM,UAAU,GAAG,IAA2C,CAAC;IAC/D,MAAM,cAAc,GAAG,QAAmC,CAAC;IAC3D,MAAM,YAAY,GAAG,MAAiC,CAAC;IACvD,KAAK,MAAM,GAAG,IAAI,CAAC,mBAAmB,EAAE,sBAAsB,EAAE,oBAAoB,EAAE,kBAAkB,CAAU,EAAE,CAAC;QACpH,MAAM,SAAS,GAAG,UAAU,EAAE,CAAC,GAAG,CAAC,CAAC;QACpC,MAAM,aAAa,GAAG,cAAc,CAAC,GAAG,CAAC,CAAC;QAC1C,IACC,CAAC,OAAO,SAAS,KAAK,QAAQ,IAAI,SAAS,KAAK,IAAI,CAAC;YACrD,CAAC,OAAO,aAAa,KAAK,QAAQ,IAAI,aAAa,KAAK,IAAI,CAAC,EAC5D,CAAC;YACF,YAAY,CAAC,GAAG,CAAC,GAAG,EAAE,GAAI,SAAgC,EAAE,GAAI,aAAoC,EAAE,CAAC;QACxG,CAAC;IACF,CAAC;IACD,OAAO,MAAM,CAAC;AACf,CAAC;AAED,SAAS,gBAAgB,CACxB,IAA+B,EAC/B,QAAgD;IAEhD,IAAI,CAAC,Q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CAAC;KACD,CAAC;AACH,CAAC;AAED,MAAM,UAAU,eAAe,CAC9B,KAAe,EACf,MAAsC,EACtC,SAA0C;IAE1C,MAAM,UAAU,GAAG,WAAW,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,EAAE,KAAK,KAAK,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;IACnH,MAAM,cAAc,GAAG,SAAS,EAAE,MAAM,EAAE,IAAI,CAC7C,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,IAAI,IAAI,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,IAAI,MAAM,CAAC,IAAI,KAAK,CAAC,EAAE,KAAK,KAAK,CAAC,EAAE,CACrF,CAAC;IACF,MAAM,OAAO,GAAG;QACf,GAAG,CAAC,WAAW,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,EAAE,cAAc,EAAE,CAAC,KAAK,CAAC,EAAE,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC,SAAS,CAAC;QACzF,GAAG,UAAU,EAAE,OAAO;QACtB,GAAG,cAAc,EAAE,OAAO;KAC1B,CAAC;IACF,OAAO,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS,CAAC;AAC9D,CAAC","sourcesContent":["import type {\n\tAnyModel,\n\tApi,\n\tApiKeyAuth,\n\tAssistantMessageEventStream,\n\tAuthContext,\n\tAuthResult,\n\tClassifierApi,\n\tImageApi,\n\tModel,\n\tModelAuth,\n\tOAuthAuth,\n\tOAuthCredentials,\n\tOAuthLoginCallbacks,\n\tProvider,\n\tProviderAuthInteraction,\n\tProviderClassifier,\n\tProviderHeaders,\n\tProviderImages,\n\tRefreshModelsContext,\n\tSimpleStreamOptions,\n\tTranscriptContext,\n} from \"@bastani/pi-ai\";\nimport { isModelType } from \"@bastani/pi-ai\";\nimport type { ModelsJsonModel, ModelsJsonModelOverride, ModelsJsonProvider } from \"./model-config.ts\";\nimport {\n\tclearConfigValueCache,\n\tgetConfigValueEnvVarNames,\n\tisCommandConfigValue,\n\tresolveConfigValueOrThrow,\n\tresolveHeadersOrThrow,\n} from \"./resolve-config-value.ts\";\n\nexport interface ExtensionOAuthConfig {\n\tname: string;\n\tloginLabel?: string;\n\tusesCallbackServer?: boolean;\n\tlogin(callbacks: OAuthLoginCallbacks, signal: AbortSignal): Promise<OAuthCredentials>;\n\t/**\n\t * Refresh expired credentials. `signal` is the caller's cancellation signal,\n\t * forwarded by pi through `oauth.refresh(credential, signal)`; honor it by\n\t * passing it into whatever performs the network call. It is a required\n\t * parameter rather than an optional one so the contract cannot be satisfied\n\t * by ignoring cancellation.\n\t */\n\trefreshToken(credentials: OAuthCredentials, signal: AbortSignal): Promise<OAuthCredentials>;\n\tgetApiKey(credentials: OAuthCredentials): string;\n\tmodifyModels?(models: Model<Api>[], credentials: OAuthCredentials): Model<Api>[];\n}\n\ninterface ProviderModelConfigBase {\n\tid: string;\n\tname: string;\n\tapi?: string;\n\tbaseUrl?: string;\n\tinput: AnyModel[\"input\"];\n\tinputLimits?: AnyModel[\"inputLimits\"];\n\tcost: AnyModel[\"cost\"];\n\theaders?: Record<string, string>;\n}\n\nexport interface ProviderChatModelConfig extends ProviderModelConfigBase {\n\ttype?: \"chat\";\n\tapi?: Api;\n\treasoning: boolean;\n\tthinkingLevelMap?: Model<Api>[\"thinkingLevelMap\"];\n\tpromptCache?: Model<Api>[\"promptCache\"];\n\tcontextWindow: number;\n\tmaxTokens: number;\n\tsamplingParams?: Record<string, unknown>;\n\tcompat?: Model<Api>[\"compat\"];\n}\n\nexport interface ProviderImageModelConfig extends ProviderModelConfigBase {\n\ttype: \"image\";\n\tapi?: ImageApi;\n\toutput: (\"text\" | \"image\")[];\n}\n\nexport interface ProviderClassifierModelConfig extends ProviderModelConfigBase {\n\ttype: \"classifier\";\n\tapi?: ClassifierApi;\n\tcontextWindow: number;\n}\n\nexport type ProviderModelConfig = ProviderChatModelConfig | ProviderImageModelConfig | ProviderClassifierModelConfig;\n\n/** Input type for the extension registerProvider API. */\nexport interface ProviderConfigInput {\n\tname?: string;\n\taliasOf?: string;\n\tbaseUrl?: string;\n\tapiKey?: string;\n\tapi?: Api;\n\tstreamSimple?: (\n\t\tmodel: Model<Api>,\n\t\tcontext: TranscriptContext,\n\t\toptions?: SimpleStreamOptions,\n\t) => AssistantMessageEventStream;\n\timages?: Partial<Record<ImageApi, ProviderImages>>;\n\tclassifiers?: Partial<Record<ClassifierApi, ProviderClassifier>>;\n\theaders?: Record<string, string>;\n\tauthHeader?: boolean;\n\toauth?: ExtensionOAuthConfig;\n\tmodels?: ProviderModelConfig[];\n\trefreshModels?(context: RefreshModelsContext): Promise<NonNullable<ProviderConfigInput[\"models\"]>>;\n}\n\nexport type AuthStatus = {\n\tconfigured: boolean;\n\tsource?: \"stored\" | \"runtime\" | \"environment\" | \"fallback\" | \"models_json_key\" | \"models_json_command\";\n\tlabel?: string;\n};\n\nexport const clearApiKeyCache = clearConfigValueCache;\n\nfunction mergeCompat(\n\tbase: Model<Api>[\"compat\"],\n\toverride: Model<Api>[\"compat\"] | ModelsJsonModelOverride[\"compat\"],\n): Model<Api>[\"compat\"] {\n\tif (!override) return base;\n\tconst merged = { ...base, ...override } as NonNullable<Model<Api>[\"compat\"]>;\n\tconst baseNested = base as Record<string, unknown> | undefined;\n\tconst overrideNested = override as Record<string, unknown>;\n\tconst mergedNested = merged as Record<string, unknown>;\n\tfor (const key of [\"openRouterRouting\", \"vercelGatewayRouting\", \"chatTemplateKwargs\", \"chatTemplateArgs\"] as const) {\n\t\tconst baseValue = baseNested?.[key];\n\t\tconst overrideValue = overrideNested[key];\n\t\tif (\n\t\t\t(typeof baseValue === \"object\" && baseValue !== null) ||\n\t\t\t(typeof overrideValue === \"object\" && overrideValue !== null)\n\t\t) {\n\t\t\tmergedNested[key] = { ...(baseValue as object | undefined), ...(overrideValue as object | undefined) };\n\t\t}\n\t}\n\treturn merged;\n}\n\nfunction mergeInputLimits(\n\tbase: Model<Api>[\"inputLimits\"],\n\toverride: ModelsJsonModelOverride[\"inputLimits\"],\n): Model<Api>[\"inputLimits\"] {\n\tif (!override) return base;\n\treturn {\n\t\t...base,\n\t\t...override,\n\t\timages: override.images\n\t\t\t? {\n\t\t\t\t\t...base?.images,\n\t\t\t\t\t...override.images,\n\t\t\t\t\tresize: override.images.resize\n\t\t\t\t\t\t? { ...base?.images?.resize, ...override.images.resize }\n\t\t\t\t\t\t: base?.images?.resize,\n\t\t\t\t}\n\t\t\t: base?.images,\n\t};\n}\n\nexport function applyModelOverride(model: Model<Api>, override: ModelsJsonModelOverride): Model<Api> {\n\treturn {\n\t\t...model,\n\t\tpromptCache: override.promptCache ? { ...model.promptCache, ...override.promptCache } : model.promptCache,\n\t\tname: override.name ?? model.name,\n\t\treasoning: override.reasoning ?? model.reasoning,\n\t\tthinkingLevelMap: override.thinkingLevelMap\n\t\t\t? { ...model.thinkingLevelMap, ...override.thinkingLevelMap }\n\t\t\t: model.thinkingLevelMap,\n\t\tinput: (override.input as Model<Api>[\"input\"] | undefined) ?? model.input,\n\t\tinputLimits: mergeInputLimits(model.inputLimits, override.inputLimits),\n\t\tcost: override.cost\n\t\t\t? {\n\t\t\t\t\tinput: override.cost.input ?? model.cost.input,\n\t\t\t\t\toutput: override.cost.output ?? model.cost.output,\n\t\t\t\t\tcacheRead: override.cost.cacheRead ?? model.cost.cacheRead,\n\t\t\t\t\tcacheWrite: override.cost.cacheWrite ?? model.cost.cacheWrite,\n\t\t\t\t\ttiers: override.cost.tiers ?? model.cost.tiers,\n\t\t\t\t}\n\t\t\t: model.cost,\n\t\tcontextWindow: override.contextWindow ?? model.contextWindow,\n\t\tmaxTokens: override.maxTokens ?? model.maxTokens,\n\t\tsamplingParams: override.samplingParams\n\t\t\t? { ...model.samplingParams, ...override.samplingParams }\n\t\t\t: model.samplingParams,\n\t\tcompat: mergeCompat(model.compat, override.compat),\n\t};\n}\n\nfunction modelFromJson(\n\tproviderId: string,\n\tdefinition: ModelsJsonModel,\n\tproviderConfig: ModelsJsonProvider,\n\tdefaults: Model<Api> | undefined,\n): Model<Api> {\n\tconst api = definition.api ?? providerConfig.api ?? defaults?.api;\n\tif (!api) {\n\t\tthrow new Error(\n\t\t\t`Provider ${providerId}, model ${definition.id}: no \"api\" specified. Set at provider or model level.`,\n\t\t);\n\t}\n\tconst baseUrl = definition.baseUrl ?? providerConfig.baseUrl ?? defaults?.baseUrl;\n\tif (!baseUrl) throw new Error(`Provider ${providerId}: \"baseUrl\" is required when defining custom models.`);\n\tif (definition.contextWindow !== undefined && definition.contextWindow <= 0) {\n\t\tthrow new Error(`Provider ${providerId}, model ${definition.id}: invalid contextWindow`);\n\t}\n\tif (definition.maxTokens !== undefined && definition.maxTokens <= 0) {\n\t\tthrow new Error(`Provider ${providerId}, model ${definition.id}: invalid maxTokens`);\n\t}\n\treturn {\n\t\tid: definition.id,\n\t\tname: definition.name ?? definition.id,\n\t\tapi: api as Api,\n\t\tprovider: providerId,\n\t\tbaseUrl,\n\t\treasoning: definition.reasoning ?? false,\n\t\tthinkingLevelMap: definition.thinkingLevelMap,\n\t\tinput: (definition.input ?? [\"text\"]) as Model<Api>[\"input\"],\n\t\tinputLimits: definition.inputLimits,\n\t\tcost: definition.cost ?? { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 },\n\t\tpromptCache: definition.promptCache,\n\t\tcontextWindow: definition.contextWindow ?? 128000,\n\t\tmaxTokens: definition.maxTokens ?? 16384,\n\t\tsamplingParams: definition.samplingParams,\n\t\theaders: undefined,\n\t\tcompat: mergeCompat(providerConfig.compat, definition.compat),\n\t};\n}\n\nfunction findModelDefaults(models: readonly Model<Api>[], modelId: string, api?: Api): Model<Api> | undefined {\n\treturn (\n\t\tmodels.find((model) => model.id === modelId) ??\n\t\t(api ? models.find((model) => model.api === api) : undefined) ??\n\t\tmodels.find((model) => model.api === \"openai-completions\") ??\n\t\tmodels[0]\n\t);\n}\n\nexport function applyModelsJson(\n\tproviderId: string,\n\tbaseModels: readonly AnyModel[],\n\tconfig: ModelsJsonProvider | undefined,\n): AnyModel[] {\n\tif (!config) return [...baseModels];\n\tif (config.oauth && !config.baseUrl) {\n\t\tthrow new Error(`Provider ${providerId}: \"baseUrl\" is required when \"oauth\" is set.`);\n\t}\n\tconst hasOverrides = config.modelOverrides && Object.keys(config.modelOverrides).length > 0;\n\tif (\n\t\t!config.models?.length &&\n\t\t!config.baseUrl &&\n\t\t!config.headers &&\n\t\t!config.compat &&\n\t\t!hasOverrides &&\n\t\t!config.apiKey &&\n\t\t!config.oauth &&\n\t\tconfig.authHeader === undefined\n\t) {\n\t\tthrow new Error(\n\t\t\t`Provider ${providerId}: must specify \"baseUrl\", \"headers\", \"compat\", \"modelOverrides\", or \"models\".`,\n\t\t);\n\t}\n\n\tconst models: AnyModel[] = baseModels.map((model) =>\n\t\tisModelType(model, \"chat\")\n\t\t\t? {\n\t\t\t\t\t...model,\n\t\t\t\t\tbaseUrl: config.oauth === \"radius\" ? model.baseUrl : (config.baseUrl ?? model.baseUrl),\n\t\t\t\t\tcompat: mergeCompat(model.compat, config.compat),\n\t\t\t\t}\n\t\t\t: { ...model, baseUrl: config.oauth === \"radius\" ? model.baseUrl : (config.baseUrl ?? model.baseUrl) },\n\t);\n\tfor (const definition of config.models ?? []) {\n\t\tconst existingIndex = models.findIndex((model) => isModelType(model, \"chat\") && model.id === definition.id);\n\t\tconst defaults = findModelDefaults(\n\t\t\tmodels.filter((model) => isModelType(model, \"chat\")),\n\t\t\tdefinition.id,\n\t\t\tdefinition.api ?? config.api,\n\t\t);\n\t\tconst model = modelFromJson(providerId, definition, config, defaults);\n\t\tif (existingIndex >= 0) models[existingIndex] = model;\n\t\telse models.push(model);\n\t}\n\treturn models;\n}\n\nexport function applyExtension(\n\tproviderId: string,\n\tmodels: readonly AnyModel[],\n\tconfig: ProviderConfigInput | undefined,\n): AnyModel[] {\n\tif (!config) return [...models];\n\tif (!config.models) {\n\t\treturn config.baseUrl ? models.map((model) => ({ ...model, baseUrl: config.baseUrl! })) : [...models];\n\t}\n\treturn config.models.map((definition) => {\n\t\tconst type = definition.type ?? \"chat\";\n\t\tconst candidates = models.filter((model) => isModelType(model, type));\n\t\tconst defaults =\n\t\t\tcandidates.find((model) => model.id === definition.id) ??\n\t\t\t(definition.api ? candidates.find((model) => model.api === definition.api) : undefined) ??\n\t\t\t(type === \"chat\" ? candidates.find((model) => model.api === \"openai-completions\") : undefined) ??\n\t\t\tcandidates[0];\n\t\tconst api = definition.api ?? (type === \"chat\" ? config.api : undefined) ?? defaults?.api;\n\t\tif (!api) {\n\t\t\tthrow new Error(\n\t\t\t\t`Provider ${providerId}, model ${definition.id}: no \"api\" specified. Set it at model level${type === \"chat\" ? \" or provider level\" : \"\"}.`,\n\t\t\t);\n\t\t}\n\t\tconst baseUrl = definition.baseUrl ?? config.baseUrl ?? defaults?.baseUrl;\n\t\tif (!baseUrl) throw new Error(`Provider ${providerId}: \"baseUrl\" is required when defining custom models.`);\n\t\treturn { ...definition, api, provider: providerId, baseUrl, headers: undefined } as AnyModel;\n\t});\n}\n\nfunction adaptOAuth(config: ExtensionOAuthConfig): OAuthAuth {\n\treturn {\n\t\tname: config.name,\n\t\tlogin: async (callbacks) => {\n\t\t\tconst legacyCallbacks: OAuthLoginCallbacks & {\n\t\t\t\tonInfo(message: string, links: readonly { label?: string; url: string }[]): void;\n\t\t\t} = {\n\t\t\t\tonAuth: (info) => callbacks.notify({ type: \"auth_url\", ...info }),\n\t\t\t\tonDeviceCode: (info) => callbacks.notify({ type: \"device_code\", ...info }),\n\t\t\t\tonPrompt: (prompt) => callbacks.prompt({ type: \"text\", ...prompt }),\n\t\t\t\tonProgress: (message) => callbacks.notify({ type: \"progress\", message }),\n\t\t\t\tonInfo: (message, links) => callbacks.notify({ type: \"info\", message, links }),\n\t\t\t\tonManualCodeInput: () => callbacks.prompt({ type: \"manual_code\", message: \"Paste the authorization code\" }),\n\t\t\t\tonSelect: (prompt) => callbacks.prompt({ type: \"select\", ...prompt }),\n\t\t\t\tsignal: callbacks.signal,\n\t\t\t};\n\t\t\tconst credential = await config.login(legacyCallbacks, callbacks.signal);\n\t\t\treturn { ...credential, type: \"oauth\" };\n\t\t},\n\t\trefresh: async (credential, signal) => ({ ...(await config.refreshToken(credential, signal)), type: \"oauth\" }),\n\t\ttoAuth: async (credential) => ({ apiKey: config.getApiKey(credential) }),\n\t};\n}\n\nfunction withConfiguredAuth(\n\tauth: ModelAuth,\n\theaders: Record<string, string> | undefined,\n\tauthHeader: boolean,\n): ModelAuth {\n\tlet mergedHeaders: ProviderHeaders | undefined =\n\t\tauth.headers || headers ? { ...auth.headers, ...headers } : undefined;\n\tif (authHeader) {\n\t\tif (!auth.apiKey) throw new Error(\"authHeader requires a resolved API key\");\n\t\tmergedHeaders = { ...mergedHeaders, Authorization: `Bearer ${auth.apiKey}` };\n\t}\n\treturn { ...auth, headers: mergedHeaders };\n}\n\nexport function configuredApiKey(\n\tconfig: ModelsJsonProvider | undefined,\n\textension: ProviderConfigInput | undefined,\n): string | undefined {\n\treturn extension?.apiKey ?? config?.apiKey;\n}\n\nexport function configuredHeaders(\n\tconfig: ModelsJsonProvider | undefined,\n\textension: ProviderConfigInput | undefined,\n): Record<string, string> | undefined {\n\tif (!config?.headers && !extension?.headers) return undefined;\n\treturn { ...config?.headers, ...extension?.headers };\n}\n\nasync function configContextEnv(\n\tvalues: readonly string[],\n\tctx: AuthContext,\n\texplicit?: Record<string, string>,\n): Promise<Record<string, string> | undefined> {\n\tconst env = { ...explicit };\n\tfor (const name of new Set(values.flatMap(getConfigValueEnvVarNames))) {\n\t\tif (env[name] !== undefined) continue;\n\t\tconst value = await ctx.env(name);\n\t\tif (value !== undefined) env[name] = value;\n\t}\n\treturn Object.keys(env).length > 0 ? env : undefined;\n}\n\nexport function composeApiKeyAuth(\n\tproviderId: string,\n\tbase: Provider | undefined,\n\tconfig: ModelsJsonProvider | undefined,\n\textension: ProviderConfigInput | undefined,\n): ApiKeyAuth | undefined {\n\tconst inherited = base?.auth.apiKey;\n\tconst rawKey = configuredApiKey(config, extension);\n\tconst oauth = extension?.oauth ?? base?.auth.oauth;\n\t// OAuth-only providers get no fabricated API-key login method.\n\tif (!inherited && rawKey === undefined && oauth) return undefined;\n\tconst rawHeaders = configuredHeaders(config, extension);\n\tconst authHeader = extension?.authHeader ?? config?.authHeader ?? false;\n\treturn {\n\t\tname: inherited?.name ?? \"API key\",\n\t\tlogin:\n\t\t\tinherited?.login ??\n\t\t\t(async (interaction: ProviderAuthInteraction) => ({\n\t\t\t\ttype: \"api_key\",\n\t\t\t\tkey: await interaction.prompt({ type: \"secret\", message: \"Enter API key\" }),\n\t\t\t})),\n\t\tcheck: async (input) => {\n\t\t\tif (input.credential) {\n\t\t\t\tif (inherited?.check) return inherited.check(input);\n\t\t\t\tif (input.credential.key) return { type: \"api_key\", source: \"stored credential\" };\n\t\t\t\tconst resolved = await inherited?.resolve(input);\n\t\t\t\treturn resolved ? { type: \"api_key\", source: resolved.source } : undefined;\n\t\t\t}\n\t\t\tif (rawKey !== undefined) {\n\t\t\t\tif (isCommandConfigValue(rawKey)) return { type: \"api_key\", source: \"configured API key\" };\n\t\t\t\tconst envNames = getConfigValueEnvVarNames(rawKey);\n\t\t\t\tfor (const name of envNames) {\n\t\t\t\t\tif ((await input.ctx.env(name)) === undefined) return undefined;\n\t\t\t\t}\n\t\t\t\treturn { type: \"api_key\", source: \"configured API key\" };\n\t\t\t}\n\t\t\tif (inherited?.check) return inherited.check(input);\n\t\t\tconst resolved = await inherited?.resolve(input);\n\t\t\treturn resolved ? { type: \"api_key\", source: resolved.source } : undefined;\n\t\t},\n\t\tresolve: async (input) => {\n\t\t\tlet result: AuthResult | undefined;\n\t\t\tif (input.credential) {\n\t\t\t\tresult = inherited\n\t\t\t\t\t? await inherited.resolve(input)\n\t\t\t\t\t: input.credential.key\n\t\t\t\t\t\t? { auth: { apiKey: input.credential.key }, env: input.credential.env, source: \"stored credential\" }\n\t\t\t\t\t\t: undefined;\n\t\t\t} else if (rawKey !== undefined) {\n\t\t\t\tconst env = await configContextEnv([rawKey], input.ctx);\n\t\t\t\tconst key = resolveConfigValueOrThrow(rawKey, `API key for provider \"${providerId}\"`, env);\n\t\t\t\tresult = inherited\n\t\t\t\t\t? await inherited.resolve({ ...input, credential: { type: \"api_key\", key } })\n\t\t\t\t\t: { auth: { apiKey: key }, source: \"configured API key\" };\n\t\t\t} else {\n\t\t\t\tresult = await inherited?.resolve(input);\n\t\t\t}\n\t\t\tif (!result) return undefined;\n\t\t\tconst explicitEnv = { ...(input.credential?.env ?? {}), ...(result.env ?? {}) };\n\t\t\tconst headerEnv = await configContextEnv(Object.values(rawHeaders ?? {}), input.ctx, explicitEnv);\n\t\t\tconst headers = resolveHeadersOrThrow(rawHeaders, `provider \"${providerId}\"`, headerEnv);\n\t\t\treturn { ...result, auth: withConfiguredAuth(result.auth, headers, authHeader) };\n\t\t},\n\t};\n}\n\nexport function composeOAuthAuth(\n\tproviderId: string,\n\tbase: Provider | undefined,\n\tconfig: ModelsJsonProvider | undefined,\n\textension: ProviderConfigInput | undefined,\n): OAuthAuth | undefined {\n\tconst oauth = extension?.oauth ? adaptOAuth(extension.oauth) : base?.auth.oauth;\n\tif (!oauth) return undefined;\n\tconst rawHeaders = configuredHeaders(config, extension);\n\tconst authHeader = extension?.authHeader ?? config?.authHeader ?? false;\n\treturn {\n\t\t...oauth,\n\t\ttoAuth: async (credential) => {\n\t\t\tconst auth = await oauth.toAuth(credential);\n\t\t\tconst env = credential.env;\n\t\t\tconst headers = resolveHeadersOrThrow(\n\t\t\t\trawHeaders,\n\t\t\t\t`provider \"${providerId}\"`,\n\t\t\t\ttypeof env === \"object\" && env !== null ? (env as Record<string, string>) : undefined,\n\t\t\t);\n\t\t\treturn withConfiguredAuth(auth, headers, authHeader);\n\t\t},\n\t};\n}\n\nexport function rawModelHeaders(\n\tmodel: AnyModel,\n\tconfig: ModelsJsonProvider | undefined,\n\textension: ProviderConfigInput | undefined,\n): Record<string, string> | undefined {\n\tconst definition = isModelType(model, \"chat\") ? config?.models?.find((entry) => entry.id === model.id) : undefined;\n\tconst extensionModel = extension?.models?.find(\n\t\t(entry) => (entry.type ?? \"chat\") === (model.type ?? \"chat\") && entry.id === model.id,\n\t);\n\tconst headers = {\n\t\t...(isModelType(model, \"chat\") ? config?.modelOverrides?.[model.id]?.headers : undefined),\n\t\t...definition?.headers,\n\t\t...extensionModel?.headers,\n\t};\n\treturn Object.keys(headers).length > 0 ? headers : undefined;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"provider-composer-internal.js","sourceRoot":"","sources":["../../src/core/provider-composer-internal.ts"],"names":[],"mappings":"AAuBA,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAE7C,OAAO,EACN,qBAAqB,EACrB,yBAAyB,EACzB,oBAAoB,EACpB,yBAAyB,EACzB,qBAAqB,GACrB,MAAM,2BAA2B,CAAC;AAoFnC,MAAM,CAAC,MAAM,gBAAgB,GAAG,qBAAqB,CAAC;AAEtD,SAAS,WAAW,CACnB,IAA0B,EAC1B,QAAkE;IAElE,IAAI,CAAC,QAAQ;QAAE,OAAO,IAAI,CAAC;IAC3B,MAAM,MAAM,GAAG,EAAE,GAAG,IAAI,EAAE,GAAG,QAAQ,EAAuC,CAAC;IAC7E,MAAM,UAAU,GAAG,IAA2C,CAAC;IAC/D,MAAM,cAAc,GAAG,QAAmC,CAAC;IAC3D,MAAM,YAAY,GAAG,MAAiC,CAAC;IACvD,KAAK,MAAM,GAAG,IAAI,CAAC,mBAAmB,EAAE,sBAAsB,EAAE,oBAAoB,EAAE,kBAAkB,CAAU,EAAE,CAAC;QACpH,MAAM,SAAS,GAAG,UAAU,EAAE,CAAC,GAAG,CAAC,CAAC;Q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AAM,EAAE,MAAM,EAAE,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,EAAE,KAAK,KAAK,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;IACnH,MAAM,cAAc,GAAG,SAAS,EAAE,MAAM,EAAE,IAAI,CAC7C,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,IAAI,IAAI,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,IAAI,MAAM,CAAC,IAAI,KAAK,CAAC,EAAE,KAAK,KAAK,CAAC,EAAE,CACrF,CAAC;IACF,MAAM,OAAO,GAAG;QACf,GAAG,CAAC,WAAW,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,EAAE,cAAc,EAAE,CAAC,KAAK,CAAC,EAAE,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC,SAAS,CAAC;QACzF,GAAG,UAAU,EAAE,OAAO;QACtB,GAAG,cAAc,EAAE,OAAO;KAC1B,CAAC;IACF,OAAO,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS,CAAC;AAC9D,CAAC","sourcesContent":["import type {\n\tAnyModel,\n\tApi,\n\tApiKeyAuth,\n\tAssistantMessageEventStream,\n\tAuthContext,\n\tAuthResult,\n\tClassifierApi,\n\tImageApi,\n\tModel,\n\tModelAuth,\n\tOAuthAuth,\n\tOAuthCredentials,\n\tOAuthLoginCallbacks,\n\tProvider,\n\tProviderAuthInteraction,\n\tProviderClassifier,\n\tProviderHeaders,\n\tProviderImages,\n\tRefreshModelsContext,\n\tSimpleStreamOptions,\n\tTranscriptContext,\n} from \"@bastani/pi-ai\";\nimport { isModelType } from \"@bastani/pi-ai\";\nimport type { ModelsJsonModel, ModelsJsonModelOverride, ModelsJsonProvider } from \"./model-config.ts\";\nimport {\n\tclearConfigValueCache,\n\tgetConfigValueEnvVarNames,\n\tisCommandConfigValue,\n\tresolveConfigValueOrThrow,\n\tresolveHeadersOrThrow,\n} from \"./resolve-config-value.ts\";\n\nexport interface ExtensionOAuthConfig {\n\tname: string;\n\tloginLabel?: string;\n\tusesCallbackServer?: boolean;\n\tlogin(callbacks: OAuthLoginCallbacks, signal: AbortSignal): Promise<OAuthCredentials>;\n\t/**\n\t * Refresh expired credentials. `signal` is the caller's cancellation signal,\n\t * forwarded by pi through `oauth.refresh(credential, signal)`; honor it by\n\t * passing it into whatever performs the network call. It is a required\n\t * parameter rather than an optional one so the contract cannot be satisfied\n\t * by ignoring cancellation.\n\t */\n\trefreshToken(credentials: OAuthCredentials, signal: AbortSignal): Promise<OAuthCredentials>;\n\tgetApiKey(credentials: OAuthCredentials): string;\n\tmodifyModels?(models: Model<Api>[], credentials: OAuthCredentials): Model<Api>[];\n}\n\ninterface ProviderModelConfigBase {\n\tid: string;\n\tname: string;\n\tapi?: string;\n\tbaseUrl?: string;\n\tinput: AnyModel[\"input\"];\n\tinputLimits?: AnyModel[\"inputLimits\"];\n\tcost: AnyModel[\"cost\"];\n\theaders?: Record<string, string>;\n}\n\nexport interface ProviderChatModelConfig extends ProviderModelConfigBase {\n\ttype?: \"chat\";\n\tapi?: Api;\n\treasoning: boolean;\n\tthinkingLevelMap?: Model<Api>[\"thinkingLevelMap\"];\n\tpromptCache?: Model<Api>[\"promptCache\"];\n\tcontextWindow: number;\n\tmaxTokens: number;\n\tsamplingParams?: Model<Api>[\"samplingParams\"];\n\tsamplingParamsByThinkingLevel?: Model<Api>[\"samplingParamsByThinkingLevel\"];\n\tcompat?: Model<Api>[\"compat\"];\n}\n\nexport interface ProviderImageModelConfig extends ProviderModelConfigBase {\n\ttype: \"image\";\n\tapi?: ImageApi;\n\toutput: (\"text\" | \"image\")[];\n}\n\nexport interface ProviderClassifierModelConfig extends ProviderModelConfigBase {\n\ttype: \"classifier\";\n\tapi?: ClassifierApi;\n\tcontextWindow: number;\n}\n\nexport type ProviderModelConfig = ProviderChatModelConfig | ProviderImageModelConfig | ProviderClassifierModelConfig;\n\n/** Input type for the extension registerProvider API. */\nexport interface ProviderConfigInput {\n\tname?: string;\n\taliasOf?: string;\n\tbaseUrl?: string;\n\tapiKey?: string;\n\tapi?: Api;\n\tstreamSimple?: (\n\t\tmodel: Model<Api>,\n\t\tcontext: TranscriptContext,\n\t\toptions?: SimpleStreamOptions,\n\t) => AssistantMessageEventStream;\n\timages?: Partial<Record<ImageApi, ProviderImages>>;\n\tclassifiers?: Partial<Record<ClassifierApi, ProviderClassifier>>;\n\theaders?: Record<string, string>;\n\tauthHeader?: boolean;\n\toauth?: ExtensionOAuthConfig;\n\tmodels?: ProviderModelConfig[];\n\trefreshModels?(context: RefreshModelsContext): Promise<NonNullable<ProviderConfigInput[\"models\"]>>;\n}\n\nexport type AuthStatus = {\n\tconfigured: boolean;\n\tsource?: \"stored\" | \"runtime\" | \"environment\" | \"fallback\" | \"models_json_key\" | \"models_json_command\";\n\tlabel?: string;\n};\n\nexport const clearApiKeyCache = clearConfigValueCache;\n\nfunction mergeCompat(\n\tbase: Model<Api>[\"compat\"],\n\toverride: Model<Api>[\"compat\"] | ModelsJsonModelOverride[\"compat\"],\n): Model<Api>[\"compat\"] {\n\tif (!override) return base;\n\tconst merged = { ...base, ...override } as NonNullable<Model<Api>[\"compat\"]>;\n\tconst baseNested = base as Record<string, unknown> | undefined;\n\tconst overrideNested = override as Record<string, unknown>;\n\tconst mergedNested = merged as Record<string, unknown>;\n\tfor (const key of [\"openRouterRouting\", \"vercelGatewayRouting\", \"chatTemplateKwargs\", \"chatTemplateArgs\"] as const) {\n\t\tconst baseValue = baseNested?.[key];\n\t\tconst overrideValue = overrideNested[key];\n\t\tif (\n\t\t\t(typeof baseValue === \"object\" && baseValue !== null) ||\n\t\t\t(typeof overrideValue === \"object\" && overrideValue !== null)\n\t\t) {\n\t\t\tmergedNested[key] = { ...(baseValue as object | undefined), ...(overrideValue as object | undefined) };\n\t\t}\n\t}\n\treturn merged;\n}\n\nfunction mergeInputLimits(\n\tbase: Model<Api>[\"inputLimits\"],\n\toverride: ModelsJsonModelOverride[\"inputLimits\"],\n): Model<Api>[\"inputLimits\"] {\n\tif (!override) return base;\n\treturn {\n\t\t...base,\n\t\t...override,\n\t\timages: override.images\n\t\t\t? {\n\t\t\t\t\t...base?.images,\n\t\t\t\t\t...override.images,\n\t\t\t\t\tresize: override.images.resize\n\t\t\t\t\t\t? { ...base?.images?.resize, ...override.images.resize }\n\t\t\t\t\t\t: base?.images?.resize,\n\t\t\t\t}\n\t\t\t: base?.images,\n\t};\n}\n\nfunction mergeSamplingParamsByThinkingLevel(\n\tbase: Model<Api>[\"samplingParamsByThinkingLevel\"],\n\toverride: Model<Api>[\"samplingParamsByThinkingLevel\"],\n): Model<Api>[\"samplingParamsByThinkingLevel\"] {\n\tif (!override) return base;\n\tconst merged = { ...base };\n\tfor (const level of [\"off\", \"minimal\", \"low\", \"medium\", \"high\", \"xhigh\", \"max\"] as const) {\n\t\tconst params = override[level];\n\t\tif (params) merged[level] = { ...base?.[level], ...params };\n\t}\n\treturn merged;\n}\n\nexport function applyModelOverride(model: Model<Api>, override: ModelsJsonModelOverride): Model<Api> {\n\treturn {\n\t\t...model,\n\t\tpromptCache: override.promptCache ? { ...model.promptCache, ...override.promptCache } : model.promptCache,\n\t\tname: override.name ?? model.name,\n\t\treasoning: override.reasoning ?? model.reasoning,\n\t\tthinkingLevelMap: override.thinkingLevelMap\n\t\t\t? { ...model.thinkingLevelMap, ...override.thinkingLevelMap }\n\t\t\t: model.thinkingLevelMap,\n\t\tinput: (override.input as Model<Api>[\"input\"] | undefined) ?? model.input,\n\t\tinputLimits: mergeInputLimits(model.inputLimits, override.inputLimits),\n\t\tcost: override.cost\n\t\t\t? {\n\t\t\t\t\tinput: override.cost.input ?? model.cost.input,\n\t\t\t\t\toutput: override.cost.output ?? model.cost.output,\n\t\t\t\t\tcacheRead: override.cost.cacheRead ?? model.cost.cacheRead,\n\t\t\t\t\tcacheWrite: override.cost.cacheWrite ?? model.cost.cacheWrite,\n\t\t\t\t\ttiers: override.cost.tiers ?? model.cost.tiers,\n\t\t\t\t}\n\t\t\t: model.cost,\n\t\tcontextWindow: override.contextWindow ?? model.contextWindow,\n\t\tmaxTokens: override.maxTokens ?? model.maxTokens,\n\t\tsamplingParams: override.samplingParams\n\t\t\t? { ...model.samplingParams, ...override.samplingParams }\n\t\t\t: model.samplingParams,\n\t\tsamplingParamsByThinkingLevel: mergeSamplingParamsByThinkingLevel(\n\t\t\tmodel.samplingParamsByThinkingLevel,\n\t\t\toverride.samplingParamsByThinkingLevel,\n\t\t),\n\t\tcompat: mergeCompat(model.compat, override.compat),\n\t};\n}\n\nfunction modelFromJson(\n\tproviderId: string,\n\tdefinition: ModelsJsonModel,\n\tproviderConfig: ModelsJsonProvider,\n\tdefaults: Model<Api> | undefined,\n): Model<Api> {\n\tconst api = definition.api ?? providerConfig.api ?? defaults?.api;\n\tif (!api) {\n\t\tthrow new Error(\n\t\t\t`Provider ${providerId}, model ${definition.id}: no \"api\" specified. Set at provider or model level.`,\n\t\t);\n\t}\n\tconst baseUrl = definition.baseUrl ?? providerConfig.baseUrl ?? defaults?.baseUrl;\n\tif (!baseUrl) throw new Error(`Provider ${providerId}: \"baseUrl\" is required when defining custom models.`);\n\tif (definition.contextWindow !== undefined && definition.contextWindow <= 0) {\n\t\tthrow new Error(`Provider ${providerId}, model ${definition.id}: invalid contextWindow`);\n\t}\n\tif (definition.maxTokens !== undefined && definition.maxTokens <= 0) {\n\t\tthrow new Error(`Provider ${providerId}, model ${definition.id}: invalid maxTokens`);\n\t}\n\treturn {\n\t\tid: definition.id,\n\t\tname: definition.name ?? definition.id,\n\t\tapi: api as Api,\n\t\tprovider: providerId,\n\t\tbaseUrl,\n\t\treasoning: definition.reasoning ?? false,\n\t\tthinkingLevelMap: definition.thinkingLevelMap,\n\t\tinput: (definition.input ?? [\"text\"]) as Model<Api>[\"input\"],\n\t\tinputLimits: definition.inputLimits,\n\t\tcost: definition.cost ?? { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 },\n\t\tpromptCache: definition.promptCache,\n\t\tcontextWindow: definition.contextWindow ?? 128000,\n\t\tmaxTokens: definition.maxTokens ?? 16384,\n\t\tsamplingParams: definition.samplingParams,\n\t\tsamplingParamsByThinkingLevel: definition.samplingParamsByThinkingLevel,\n\t\theaders: undefined,\n\t\tcompat: mergeCompat(providerConfig.compat, definition.compat),\n\t};\n}\n\nfunction findModelDefaults(models: readonly Model<Api>[], modelId: string, api?: Api): Model<Api> | undefined {\n\treturn (\n\t\tmodels.find((model) => model.id === modelId) ??\n\t\t(api ? models.find((model) => model.api === api) : undefined) ??\n\t\tmodels.find((model) => model.api === \"openai-completions\") ??\n\t\tmodels[0]\n\t);\n}\n\nexport function applyModelsJson(\n\tproviderId: string,\n\tbaseModels: readonly AnyModel[],\n\tconfig: ModelsJsonProvider | undefined,\n): AnyModel[] {\n\tif (!config) return [...baseModels];\n\tif (config.oauth && !config.baseUrl) {\n\t\tthrow new Error(`Provider ${providerId}: \"baseUrl\" is required when \"oauth\" is set.`);\n\t}\n\tconst hasOverrides = config.modelOverrides && Object.keys(config.modelOverrides).length > 0;\n\tif (\n\t\t!config.models?.length &&\n\t\t!config.baseUrl &&\n\t\t!config.headers &&\n\t\t!config.compat &&\n\t\t!hasOverrides &&\n\t\t!config.apiKey &&\n\t\t!config.oauth &&\n\t\tconfig.authHeader === undefined\n\t) {\n\t\tthrow new Error(\n\t\t\t`Provider ${providerId}: must specify \"baseUrl\", \"headers\", \"compat\", \"modelOverrides\", or \"models\".`,\n\t\t);\n\t}\n\n\tconst models: AnyModel[] = baseModels.map((model) =>\n\t\tisModelType(model, \"chat\")\n\t\t\t? {\n\t\t\t\t\t...model,\n\t\t\t\t\tbaseUrl: config.oauth === \"radius\" ? model.baseUrl : (config.baseUrl ?? model.baseUrl),\n\t\t\t\t\tcompat: mergeCompat(model.compat, config.compat),\n\t\t\t\t}\n\t\t\t: { ...model, baseUrl: config.oauth === \"radius\" ? model.baseUrl : (config.baseUrl ?? model.baseUrl) },\n\t);\n\tfor (const definition of config.models ?? []) {\n\t\tconst existingIndex = models.findIndex((model) => isModelType(model, \"chat\") && model.id === definition.id);\n\t\tconst defaults = findModelDefaults(\n\t\t\tmodels.filter((model) => isModelType(model, \"chat\")),\n\t\t\tdefinition.id,\n\t\t\tdefinition.api ?? config.api,\n\t\t);\n\t\tconst model = modelFromJson(providerId, definition, config, defaults);\n\t\tif (existingIndex >= 0) models[existingIndex] = model;\n\t\telse models.push(model);\n\t}\n\treturn models;\n}\n\nexport function applyExtension(\n\tproviderId: string,\n\tmodels: readonly AnyModel[],\n\tconfig: ProviderConfigInput | undefined,\n): AnyModel[] {\n\tif (!config) return [...models];\n\tif (!config.models) {\n\t\treturn config.baseUrl ? models.map((model) => ({ ...model, baseUrl: config.baseUrl! })) : [...models];\n\t}\n\treturn config.models.map((definition) => {\n\t\tconst type = definition.type ?? \"chat\";\n\t\tconst candidates = models.filter((model) => isModelType(model, type));\n\t\tconst defaults =\n\t\t\tcandidates.find((model) => model.id === definition.id) ??\n\t\t\t(definition.api ? candidates.find((model) => model.api === definition.api) : undefined) ??\n\t\t\t(type === \"chat\" ? candidates.find((model) => model.api === \"openai-completions\") : undefined) ??\n\t\t\tcandidates[0];\n\t\tconst api = definition.api ?? (type === \"chat\" ? config.api : undefined) ?? defaults?.api;\n\t\tif (!api) {\n\t\t\tthrow new Error(\n\t\t\t\t`Provider ${providerId}, model ${definition.id}: no \"api\" specified. Set it at model level${type === \"chat\" ? \" or provider level\" : \"\"}.`,\n\t\t\t);\n\t\t}\n\t\tconst baseUrl = definition.baseUrl ?? config.baseUrl ?? defaults?.baseUrl;\n\t\tif (!baseUrl) throw new Error(`Provider ${providerId}: \"baseUrl\" is required when defining custom models.`);\n\t\treturn { ...definition, api, provider: providerId, baseUrl, headers: undefined } as AnyModel;\n\t});\n}\n\nfunction adaptOAuth(config: ExtensionOAuthConfig): OAuthAuth {\n\treturn {\n\t\tname: config.name,\n\t\tlogin: async (callbacks) => {\n\t\t\tconst legacyCallbacks: OAuthLoginCallbacks & {\n\t\t\t\tonInfo(message: string, links: readonly { label?: string; url: string }[]): void;\n\t\t\t} = {\n\t\t\t\tonAuth: (info) => callbacks.notify({ type: \"auth_url\", ...info }),\n\t\t\t\tonDeviceCode: (info) => callbacks.notify({ type: \"device_code\", ...info }),\n\t\t\t\tonPrompt: (prompt) => callbacks.prompt({ type: \"text\", ...prompt }),\n\t\t\t\tonProgress: (message) => callbacks.notify({ type: \"progress\", message }),\n\t\t\t\tonInfo: (message, links) => callbacks.notify({ type: \"info\", message, links }),\n\t\t\t\tonManualCodeInput: () => callbacks.prompt({ type: \"manual_code\", message: \"Paste the authorization code\" }),\n\t\t\t\tonSelect: (prompt) => callbacks.prompt({ type: \"select\", ...prompt }),\n\t\t\t\tsignal: callbacks.signal,\n\t\t\t};\n\t\t\tconst credential = await config.login(legacyCallbacks, callbacks.signal);\n\t\t\treturn { ...credential, type: \"oauth\" };\n\t\t},\n\t\trefresh: async (credential, signal) => ({ ...(await config.refreshToken(credential, signal)), type: \"oauth\" }),\n\t\ttoAuth: async (credential) => ({ apiKey: config.getApiKey(credential) }),\n\t};\n}\n\nfunction withConfiguredAuth(\n\tauth: ModelAuth,\n\theaders: Record<string, string> | undefined,\n\tauthHeader: boolean,\n): ModelAuth {\n\tlet mergedHeaders: ProviderHeaders | undefined =\n\t\tauth.headers || headers ? { ...auth.headers, ...headers } : undefined;\n\tif (authHeader) {\n\t\tif (!auth.apiKey) throw new Error(\"authHeader requires a resolved API key\");\n\t\tmergedHeaders = { ...mergedHeaders, Authorization: `Bearer ${auth.apiKey}` };\n\t}\n\treturn { ...auth, headers: mergedHeaders };\n}\n\nexport function configuredApiKey(\n\tconfig: ModelsJsonProvider | undefined,\n\textension: ProviderConfigInput | undefined,\n): string | undefined {\n\treturn extension?.apiKey ?? config?.apiKey;\n}\n\nexport function configuredHeaders(\n\tconfig: ModelsJsonProvider | undefined,\n\textension: ProviderConfigInput | undefined,\n): Record<string, string> | undefined {\n\tif (!config?.headers && !extension?.headers) return undefined;\n\treturn { ...config?.headers, ...extension?.headers };\n}\n\nasync function configContextEnv(\n\tvalues: readonly string[],\n\tctx: AuthContext,\n\texplicit?: Record<string, string>,\n): Promise<Record<string, string> | undefined> {\n\tconst env = { ...explicit };\n\tfor (const name of new Set(values.flatMap(getConfigValueEnvVarNames))) {\n\t\tif (env[name] !== undefined) continue;\n\t\tconst value = await ctx.env(name);\n\t\tif (value !== undefined) env[name] = value;\n\t}\n\treturn Object.keys(env).length > 0 ? env : undefined;\n}\n\nexport function composeApiKeyAuth(\n\tproviderId: string,\n\tbase: Provider | undefined,\n\tconfig: ModelsJsonProvider | undefined,\n\textension: ProviderConfigInput | undefined,\n): ApiKeyAuth | undefined {\n\tconst inherited = base?.auth.apiKey;\n\tconst rawKey = configuredApiKey(config, extension);\n\tconst oauth = extension?.oauth ?? base?.auth.oauth;\n\t// OAuth-only providers get no fabricated API-key login method.\n\tif (!inherited && rawKey === undefined && oauth) return undefined;\n\tconst rawHeaders = configuredHeaders(config, extension);\n\tconst authHeader = extension?.authHeader ?? config?.authHeader ?? false;\n\treturn {\n\t\tname: inherited?.name ?? \"API key\",\n\t\tlogin:\n\t\t\tinherited?.login ??\n\t\t\t(async (interaction: ProviderAuthInteraction) => ({\n\t\t\t\ttype: \"api_key\",\n\t\t\t\tkey: await interaction.prompt({ type: \"secret\", message: \"Enter API key\" }),\n\t\t\t})),\n\t\tcheck: async (input) => {\n\t\t\tif (input.credential) {\n\t\t\t\tif (inherited?.check) return inherited.check(input);\n\t\t\t\tif (input.credential.key) return { type: \"api_key\", source: \"stored credential\" };\n\t\t\t\tconst resolved = await inherited?.resolve(input);\n\t\t\t\treturn resolved ? { type: \"api_key\", source: resolved.source } : undefined;\n\t\t\t}\n\t\t\tif (rawKey !== undefined) {\n\t\t\t\tif (isCommandConfigValue(rawKey)) return { type: \"api_key\", source: \"configured API key\" };\n\t\t\t\tconst envNames = getConfigValueEnvVarNames(rawKey);\n\t\t\t\tfor (const name of envNames) {\n\t\t\t\t\tif ((await input.ctx.env(name)) === undefined) return undefined;\n\t\t\t\t}\n\t\t\t\treturn { type: \"api_key\", source: \"configured API key\" };\n\t\t\t}\n\t\t\tif (inherited?.check) return inherited.check(input);\n\t\t\tconst resolved = await inherited?.resolve(input);\n\t\t\treturn resolved ? { type: \"api_key\", source: resolved.source } : undefined;\n\t\t},\n\t\tresolve: async (input) => {\n\t\t\tlet result: AuthResult | undefined;\n\t\t\tif (input.credential) {\n\t\t\t\tresult = inherited\n\t\t\t\t\t? await inherited.resolve(input)\n\t\t\t\t\t: input.credential.key\n\t\t\t\t\t\t? { auth: { apiKey: input.credential.key }, env: input.credential.env, source: \"stored credential\" }\n\t\t\t\t\t\t: undefined;\n\t\t\t} else if (rawKey !== undefined) {\n\t\t\t\tconst env = await configContextEnv([rawKey], input.ctx);\n\t\t\t\tconst key = resolveConfigValueOrThrow(rawKey, `API key for provider \"${providerId}\"`, env);\n\t\t\t\tresult = inherited\n\t\t\t\t\t? await inherited.resolve({ ...input, credential: { type: \"api_key\", key } })\n\t\t\t\t\t: { auth: { apiKey: key }, source: \"configured API key\" };\n\t\t\t} else {\n\t\t\t\tresult = await inherited?.resolve(input);\n\t\t\t}\n\t\t\tif (!result) return undefined;\n\t\t\tconst explicitEnv = { ...(input.credential?.env ?? {}), ...(result.env ?? {}) };\n\t\t\tconst headerEnv = await configContextEnv(Object.values(rawHeaders ?? {}), input.ctx, explicitEnv);\n\t\t\tconst headers = resolveHeadersOrThrow(rawHeaders, `provider \"${providerId}\"`, headerEnv);\n\t\t\treturn { ...result, auth: withConfiguredAuth(result.auth, headers, authHeader) };\n\t\t},\n\t};\n}\n\nexport function composeOAuthAuth(\n\tproviderId: string,\n\tbase: Provider | undefined,\n\tconfig: ModelsJsonProvider | undefined,\n\textension: ProviderConfigInput | undefined,\n): OAuthAuth | undefined {\n\tconst oauth = extension?.oauth ? adaptOAuth(extension.oauth) : base?.auth.oauth;\n\tif (!oauth) return undefined;\n\tconst rawHeaders = configuredHeaders(config, extension);\n\tconst authHeader = extension?.authHeader ?? config?.authHeader ?? false;\n\treturn {\n\t\t...oauth,\n\t\ttoAuth: async (credential) => {\n\t\t\tconst auth = await oauth.toAuth(credential);\n\t\t\tconst env = credential.env;\n\t\t\tconst headers = resolveHeadersOrThrow(\n\t\t\t\trawHeaders,\n\t\t\t\t`provider \"${providerId}\"`,\n\t\t\t\ttypeof env === \"object\" && env !== null ? (env as Record<string, string>) : undefined,\n\t\t\t);\n\t\t\treturn withConfiguredAuth(auth, headers, authHeader);\n\t\t},\n\t};\n}\n\nexport function rawModelHeaders(\n\tmodel: AnyModel,\n\tconfig: ModelsJsonProvider | undefined,\n\textension: ProviderConfigInput | undefined,\n): Record<string, string> | undefined {\n\tconst definition = isModelType(model, \"chat\") ? config?.models?.find((entry) => entry.id === model.id) : undefined;\n\tconst extensionModel = extension?.models?.find(\n\t\t(entry) => (entry.type ?? \"chat\") === (model.type ?? \"chat\") && entry.id === model.id,\n\t);\n\tconst headers = {\n\t\t...(isModelType(model, \"chat\") ? config?.modelOverrides?.[model.id]?.headers : undefined),\n\t\t...definition?.headers,\n\t\t...extensionModel?.headers,\n\t};\n\treturn Object.keys(headers).length > 0 ? headers : undefined;\n}\n"]}
|
package/docs/models/reference.md
CHANGED
|
@@ -95,6 +95,7 @@ In `models.json`, `headers` values must be strings. A `null` suppression marker
|
|
|
95
95
|
| `contextWindow` | No | `128000` | Default/effective context window size in tokens |
|
|
96
96
|
| `maxTokens` | No | `16384` | Maximum output tokens |
|
|
97
97
|
| `samplingParams` | No | omitted | Sampling parameters merged verbatim into every request body for OpenAI-compatible APIs (see below) |
|
|
98
|
+
| `samplingParamsByThinkingLevel` | No | omitted | Sampling parameter overrides keyed by Atomic thinking level for OpenAI-compatible APIs (see [Sampling by Thinking Level](#sampling-by-thinking-level)) |
|
|
98
99
|
| `cost` | No | all zeros | Complete base rates per million tokens plus optional request-wide `tiers` (see below) |
|
|
99
100
|
| `compat` | No | provider `compat` | Provider compatibility overrides. Merged with provider-level `compat` when both are set. |
|
|
100
101
|
| `compat.supportsMidConvoSystemMessages` | No | model default | Accept system/developer messages after the conversation starts |
|
|
@@ -207,6 +208,32 @@ The catalog can also record `inputLimits.maxRequestBytes`, `images.maxPerMessage
|
|
|
207
208
|
|
|
208
209
|
Only OpenAI-compatible APIs apply these values (`openai-completions`, `openai-responses`, and `azure-openai-responses`); other APIs ignore them. Per-request keys override model defaults and named request fields. In `modelOverrides`, `samplingParams` merges per key with the base model's values. Keys are provider-defined and remain unchanged; malformed `samplingParams` values are rejected while loading `models.json`.
|
|
209
210
|
|
|
211
|
+
### Sampling by Thinking Level
|
|
212
|
+
|
|
213
|
+
`samplingParamsByThinkingLevel` sets sampling parameters per thinking level on top of the model's `samplingParams`. Its keys are Atomic thinking levels (`off`, `minimal`, `low`, `medium`, `high`, `xhigh`, and `max`), not the provider values from `thinkingLevelMap`:
|
|
214
|
+
|
|
215
|
+
```json
|
|
216
|
+
{
|
|
217
|
+
"id": "qwen-thinking-model",
|
|
218
|
+
"reasoning": true,
|
|
219
|
+
"samplingParams": {
|
|
220
|
+
"temperature": 1.0,
|
|
221
|
+
"top_p": 0.95
|
|
222
|
+
},
|
|
223
|
+
"samplingParamsByThinkingLevel": {
|
|
224
|
+
"off": {
|
|
225
|
+
"temperature": 0.7,
|
|
226
|
+
"top_p": 0.8
|
|
227
|
+
},
|
|
228
|
+
"high": {
|
|
229
|
+
"top_k": 20
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
```
|
|
234
|
+
|
|
235
|
+
Atomic first clamps an unsupported thinking level to the nearest supported one, then merges the model's `samplingParams`, the effective level's override, and request-level `samplingParams` in that order. Later values win per key, and a level without an entry keeps the model defaults. In `modelOverrides`, each level's entry merges per key with the base model's entry for the same level. These fields apply only to `openai-completions`, `openai-responses`, and `azure-openai-responses`; other APIs ignore them. For `openai-completions` models with `compat.supportsTemperature: false`, the restricted keys are still removed from the final request, including keys that come from a level's override.
|
|
236
|
+
|
|
210
237
|
For vLLM OpenAI-compatible models that share the reasoning and answer budgets, set `compat.supportsThinkingTokenBudget` to `true`. Atomic sends the opt-in `thinking_token_budget` value for an enabled thinking level and always leaves 1024 tokens for the final answer. Pi's defaults are 1024, 2048, 8192, and 16384 tokens for `minimal`, `low`, `medium`, and `high`; the `thinkingBudgets` settings override them. `xhigh` and `max` use the `high` budget, and Atomic omits the field when no positive budget remains after reserving answer space.
|
|
211
238
|
|
|
212
239
|
Model references resolve the complete, unmodified ID before Atomic interprets thinking suffixes or glob syntax. For example, if the catalog contains the literal ID `provider/literal[free]:high`, that complete model wins and `:high` remains part of its ID; it does not become a thinking-level suffix and `[free]` is not treated as a character class. Only when the complete ID is absent does Atomic parse a valid thinking suffix, try the stripped exact ID, then apply glob/fuzzy matching. This preserves literal provider IDs without changing ordinary `*`, `?`, bracket-glob, ambiguity, ordering, or deduplication behavior.
|
|
@@ -413,7 +440,7 @@ Use `modelOverrides` to customize specific models without replacing the provider
|
|
|
413
440
|
}
|
|
414
441
|
```
|
|
415
442
|
|
|
416
|
-
`modelOverrides` supports these fields per model: `name`, `reasoning`, `thinkingLevelMap`, `input`, `inputLimits` (deep-merged), `cost` (partial scalar rates plus optional full tier-array replacement), `contextWindow`, `maxTokens`, `samplingParams` (merged per key), `headers`, `compat`.
|
|
443
|
+
`modelOverrides` supports these fields per model: `name`, `reasoning`, `thinkingLevelMap`, `input`, `inputLimits` (deep-merged), `cost` (partial scalar rates plus optional full tier-array replacement), `contextWindow`, `maxTokens`, `samplingParams` (merged per key), `samplingParamsByThinkingLevel` (merged per level, then per key), `headers`, `compat`.
|
|
417
444
|
|
|
418
445
|
Atomic reads one `models.json` from the active agent directory. It does not layer model overrides from `.pi` and `.atomic` files.
|
|
419
446
|
|
package/docs/models.md
CHANGED
|
@@ -165,6 +165,10 @@ Moved to [Model configuration reference](/models/reference#model-configuration).
|
|
|
165
165
|
|
|
166
166
|
Moved to [Model configuration reference](/models/reference#sampling-parameters).
|
|
167
167
|
|
|
168
|
+
### Sampling by Thinking Level
|
|
169
|
+
|
|
170
|
+
Moved to [Model configuration reference](/models/reference#sampling-by-thinking-level).
|
|
171
|
+
|
|
168
172
|
### Request-wide Cost Tiers
|
|
169
173
|
|
|
170
174
|
Moved to [Model configuration reference](/models/reference#request-wide-cost-tiers).
|
package/docs/sdk.md
CHANGED
|
@@ -228,7 +228,7 @@ Web provider configuration caches are session-local. Configuration discovery and
|
|
|
228
228
|
|
|
229
229
|
### Workflow run control
|
|
230
230
|
|
|
231
|
-
`session.workflows`
|
|
231
|
+
`session.workflows` controls this session's workflow runs without slash commands or the model-facing `workflow` tool. A fresh session can also inspect a durable root from another session by its full UUID, within the same working directory and configured workflow database. Inspection stays read-only and does not add the run to `listRuns()`.
|
|
232
232
|
|
|
233
233
|
```typescript
|
|
234
234
|
interface SessionWorkflows {
|
|
@@ -244,6 +244,30 @@ interface SessionWorkflows {
|
|
|
244
244
|
|
|
245
245
|
`listRuns()` returns the same per-run data as `workflow status`: id, workflow name, status, active stages, and unanswered prompts (`awaitingInput`). Run IDs accept the full UUID or a unique 8-character prefix. `getRun()`, `getStages()`, `pause()` and `quit()` resolve a prefix against the runs this session holds and reject it at once when none matches, so pass the full UUID for a run recorded by an earlier process. `pause`, `quit` and `resume` resolve with the tool's acknowledged outcome: `action`, `runId` (`--all` for a batch), a `status` of `ok`, `running`, `paused`, `partial`, `noop` or `cancelled`, and a human-readable `message`. A `noop` means the request was understood and found nothing to change, such as pausing a run that already ended. A `partial` outcome means part of the request took effect. For `pause({ all: true })` and `quit({ all: true })`, `partial` means this call stopped at least one run and others are still active: `failedRuns` lists each run that is still active with its `runId`, a `reason` (for example `pause_failed` or `no_active_stages`) and a `message`, so check `outcome.status === "partial"` before treating a batch stop as complete. If active runs could not be stopped and this call stopped none, the call rejects with `WorkflowRunControlError` (`WORKFLOW_RUN_CONTROL_FAILED`) whose `failedRuns` carries the same list, even when other runs were already paused. Runs that are already paused or already ended are not failures, and a batch with no active run left to stop resolves as a `noop`. Call `getRun()` before retrying.
|
|
246
246
|
|
|
247
|
+
After an owning process crashes, create a new authorized SDK session with the original `cwd` and workflow database configuration. Keep the workflow definition available, then call `getRun(runId)` with the saved full UUID. Once its progress has been stale for about two minutes and its database ownership connection is gone, status reports `crashed`. `resume(runId)` claims the durable run only after the database excludes the previous owner and any unfinished database writes. It continues under the same UUID and replays completed checkpoints. This works with `SessionManager.inMemory()` and does not require reopening a session file. Concurrent recovery attempts admit only one executor; inspect again if another caller won the claim.
|
|
248
|
+
|
|
249
|
+
A healthy connected foreign owner remains read-only, even while a long-running tool has not refreshed workflow progress or a VM clone cannot see its PID. `pause()` and `quit()` still require its owning session, and `resume()` cannot adopt another session's live, paused, or terminal run. Missing ownership metadata, a different working directory, or unavailable database ownership verification prevents adoption. Older runs without database-fenced ownership remain inspectable but cannot use this distributed recovery path. Recovery from a crashed foreign process requires the full UUID, not a prefix. A host using only the non-durable in-memory workflow backend cannot recover after process loss.
|
|
250
|
+
|
|
251
|
+
Live-cloned SDK hosts must share one authoritative PostgreSQL server and database. Configure a shared database endpoint for those hosts. Copying the managed PostgreSQL directory into another VM creates an independent database, even if both use the same `localhost` URL; separate databases cannot enforce cross-VM ownership exclusion.
|
|
252
|
+
|
|
253
|
+
Use a direct PostgreSQL connection or a proxy that preserves each client's database session. Ownership locks and write authorization depend on session affinity. Transaction-mode and statement-mode pooling, including those PgBouncer modes, are unsupported for the workflow database.
|
|
254
|
+
|
|
255
|
+
Database fencing protects ownership and durable checkpoints, not arbitrary external effects. If an owner loses its database connection, recovery may overlap an unfinished callback in that still-running process. The old owner cannot save new checkpoints, but an interrupted `ctx.tool` callback can be retried before the old callback stops. Make external effects idempotent, for example by passing a stable run/node operation key to an API that deduplicates requests. Completed checkpoints are replayed without rerunning their callbacks; unfinished callbacks do not have exactly-once execution guarantees.
|
|
256
|
+
|
|
257
|
+
An execution that loses its ownership connection cannot silently regain write authority. Restore database availability, inspect the retained run, and resume explicitly. Recovery uses a fresh execution generation while the disconnected generation stays fenced. Keep the database and completed checkpoints; deleting them is not a recovery step.
|
|
258
|
+
|
|
259
|
+
For an older run without database-fenced ownership, stop every older Atomic worker connected to its workflow database before enrollment. Upgrade the recovery host, retain the original database and workflow definition, and create an authorized SDK session with the original `cwd`. Inspect the full UUID, then explicitly confirm the stopped-worker prerequisite:
|
|
260
|
+
|
|
261
|
+
```ts
|
|
262
|
+
await session.workflows.resume(runId, {
|
|
263
|
+
legacyRecovery: { olderWorkersStopped: true },
|
|
264
|
+
});
|
|
265
|
+
```
|
|
266
|
+
|
|
267
|
+
This enrolls an eligible legacy root in database fencing and resumes it under the same UUID, preserving completed checkpoints. The option is an operator assertion, not a mechanism that stops workers. Never pass it while an older worker may still be executing. It does not permit recovery in another working directory, stage-only enrollment, or overriding a healthy fenced owner. Ordinary `resume(runId)` does not automatically adopt an unfenced legacy owner; inspection and existing owner-scoped controls remain available.
|
|
268
|
+
|
|
269
|
+
If the recovery host crashes after enrollment but before execution starts, inspect the full UUID and retry the same explicit option from a fresh session. Retry is permitted only for an interrupted enrollment whose database owner is no longer live. It does not allow takeover of another session's generally paused or blocked fenced run.
|
|
270
|
+
|
|
247
271
|
Pausing a run doesn't park a stage that is waiting on a prompt, including an `ask_user_question` delivered through `HostInput.questionnaire`. If no other work is active, `pause(runId)` and `pause({ all: true })` mark the run `paused` without cancelling its question. Questions not yet shown wait until the run resumes. A later pause counts it as already paused. If your host then answers an already-open prompt, the stage can continue its turn before you call `resume`. To keep a paused run fully stopped, hold prompt answers until you resume it.
|
|
248
272
|
|
|
249
273
|
Requests that cannot be carried out reject with a subclass of `WorkflowRunControlError`. Branch on `code` or use `instanceof`:
|
|
@@ -251,7 +275,7 @@ Requests that cannot be carried out reject with a subclass of `WorkflowRunContro
|
|
|
251
275
|
| Class | `code` | Meaning |
|
|
252
276
|
| --- | --- | --- |
|
|
253
277
|
| `WorkflowRunNotFoundError` | `WORKFLOW_RUN_NOT_FOUND` | The run ID is unknown or malformed, or a prefix is ambiguous or matches no run in this session. |
|
|
254
|
-
| `WorkflowRunOwnershipError` | `WORKFLOW_RUN_OWNED_ELSEWHERE` |
|
|
278
|
+
| `WorkflowRunOwnershipError` | `WORKFLOW_RUN_OWNED_ELSEWHERE` | Mutation requires another session's ownership, the run is still live, or the durable run is outside this host's recovery scope. Inspect it read-only when in scope; control live work from its owner. |
|
|
255
279
|
| `WorkflowRunNotResumableError` | `WORKFLOW_RUN_NOT_RESUMABLE` | The run completed, was killed, or has no durable progress to resume. |
|
|
256
280
|
| `WorkflowStageNotFoundError` | `WORKFLOW_STAGE_NOT_FOUND` | `stageId` matches no stage of the run, or the stage has no control to pause. |
|
|
257
281
|
| `WorkflowStageAmbiguousError` | `WORKFLOW_STAGE_AMBIGUOUS` | `stageId` matches more than one stage; pass a more specific identifier. |
|
|
@@ -548,7 +548,21 @@ New Docker fallback containers publish PostgreSQL on `127.0.0.1` at `PGPORT`, or
|
|
|
548
548
|
|
|
549
549
|
Fallback starts only after failed DBOS initialization has been cleaned up. If Atomic reports `Workflow backend cleanup failed`, workflow startup stops rather than starting another backend alongside an unconfirmed executor. Correct the reported shutdown problem and restart Atomic; do not delete database data to bypass it.
|
|
550
550
|
|
|
551
|
-
**Multiple concurrent Atomic sessions.** A workflow
|
|
551
|
+
**Multiple concurrent Atomic sessions.** A workflow with a healthy connected owner is not a resume target. Fresh progress and database ownership are checked independently, so a quiet long-running tool stays protected. After the owning connection is lost and progress becomes stale in about two minutes, inspection reports `crashed`. Concurrent attempts to resume the same run admit one executor; a stale request reports that the run changed.
|
|
552
|
+
|
|
553
|
+
For SDK crash recovery, save the full run UUID and create a fresh authorized session with the original working directory and workflow database configuration. `session.workflows.getRun(runId)` and `getStages(runId)` inspect its durable state without taking ownership. Once `getRun()` reports `crashed`, `session.workflows.resume(runId)` can adopt the root after the database excludes its previous owner and unfinished database writes. A healthy connected owner stays protected despite stale tool progress or copied VM boot/PID identity. This works with `SessionManager.inMemory()` without reopening a session file. Competing adopters cannot both claim the same generation. Missing ownership metadata, another working directory, or unavailable ownership verification keeps the run read-only; older unfenced runs cannot use distributed adoption.
|
|
554
|
+
|
|
555
|
+
For live-cloned SDK hosts, configure one shared authoritative PostgreSQL server/database. A copied managed PostgreSQL directory in another VM is a separate coordinator, not a shared database, even when its `localhost` connection URL is identical. Independent database copies cannot coordinate ownership across VMs.
|
|
556
|
+
|
|
557
|
+
The workflow database endpoint must preserve database sessions. Use direct PostgreSQL connections or session-mode pooling, not transaction-mode or statement-mode pooling. Ownership locks and write authorization depend on that session affinity.
|
|
558
|
+
|
|
559
|
+
Ownership fencing prevents a disconnected executor from saving later checkpoints or workflow metadata. It does not stop arbitrary external code already running in that executor. After connection loss, the replacement may retry an unfinished `ctx.tool` while the old callback is still active. Use idempotent external effects and stable operation keys; do not assume exactly-once callback execution. Completed durable checkpoints still replay without executing those callbacks again.
|
|
560
|
+
|
|
561
|
+
If Atomic reports that its database ownership connection was lost, restore database availability, inspect the retained run UUID, and resume explicitly. Recovery uses a fresh execution generation; it does not restore the disconnected executor's mutation authority. Preserve the workflow database and completed checkpoints.
|
|
562
|
+
|
|
563
|
+
Older unfenced runs require controlled enrollment rather than automatic foreign-owner adoption. Stop all older Atomic workers using that workflow database, upgrade the recovery host, and keep the original database and workflow definition. In an authorized SDK session with the original working directory, use the full UUID with `session.workflows.resume(runId, { legacyRecovery: { olderWorkersStopped: true } })`. This explicit assertion enrolls the legacy root and preserves its completed checkpoints; it does not stop workers itself. Do not use it while an older worker may still be running. Reads and existing owner-scoped controls do not require enrollment. See [SDK run control](/sdk#workflow-run-control) for the recovery example.
|
|
564
|
+
|
|
565
|
+
If the recovery host crashes between enrollment and execution, inspect the full UUID and retry that explicit SDK option from a fresh session after its database ownership connection is gone. Only an interrupted enrollment is eligible for this retry; healthy owners and other fenced paused or blocked runs remain protected.
|
|
552
566
|
|
|
553
567
|
Independent root workflows persist independently. Nested workflows share their root's ordering.
|
|
554
568
|
|
package/npm-shrinkwrap.json
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bastani/atomic",
|
|
3
|
-
"version": "0.9.26
|
|
3
|
+
"version": "0.9.26",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "@bastani/atomic",
|
|
9
|
-
"version": "0.9.26
|
|
9
|
+
"version": "0.9.26",
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"dependencies": {
|
|
12
|
-
"@bastani/atomic-natives": "0.9.26
|
|
13
|
-
"@bastani/pi-ai": "0.9.26
|
|
12
|
+
"@bastani/atomic-natives": "0.9.26",
|
|
13
|
+
"@bastani/pi-ai": "0.9.26",
|
|
14
14
|
"@dbos-inc/dbos-sdk": "4.25.14",
|
|
15
|
-
"@earendil-works/pi-agent-core": "1.0.
|
|
16
|
-
"@earendil-works/pi-client": "1.0.
|
|
17
|
-
"@earendil-works/pi-codemode": "1.0.
|
|
18
|
-
"@earendil-works/pi-protocol": "1.0.
|
|
19
|
-
"@earendil-works/pi-tui": "1.0.
|
|
15
|
+
"@earendil-works/pi-agent-core": "1.0.2",
|
|
16
|
+
"@earendil-works/pi-client": "1.0.2",
|
|
17
|
+
"@earendil-works/pi-codemode": "1.0.2",
|
|
18
|
+
"@earendil-works/pi-protocol": "1.0.2",
|
|
19
|
+
"@earendil-works/pi-tui": "1.0.2",
|
|
20
20
|
"@modelcontextprotocol/ext-apps": "^1.7.5",
|
|
21
21
|
"@modelcontextprotocol/sdk": "1.30.0",
|
|
22
22
|
"@mozilla/readability": "^0.6.0",
|
|
@@ -432,18 +432,18 @@
|
|
|
432
432
|
}
|
|
433
433
|
},
|
|
434
434
|
"node_modules/@bastani/atomic-natives": {
|
|
435
|
-
"version": "0.9.26
|
|
436
|
-
"resolved": "https://registry.npmjs.org/@bastani/atomic-natives/-/atomic-natives-0.9.26
|
|
435
|
+
"version": "0.9.26",
|
|
436
|
+
"resolved": "https://registry.npmjs.org/@bastani/atomic-natives/-/atomic-natives-0.9.26.tgz",
|
|
437
437
|
"license": "MIT",
|
|
438
438
|
"optionalDependencies": {
|
|
439
|
-
"@bastani/atomic-natives-darwin-arm64": "0.9.26
|
|
440
|
-
"@bastani/atomic-natives-darwin-x64": "0.9.26
|
|
441
|
-
"@bastani/atomic-natives-linux-arm64-gnu": "0.9.26
|
|
442
|
-
"@bastani/atomic-natives-linux-arm64-musl": "0.9.26
|
|
443
|
-
"@bastani/atomic-natives-linux-x64-gnu": "0.9.26
|
|
444
|
-
"@bastani/atomic-natives-linux-x64-musl": "0.9.26
|
|
445
|
-
"@bastani/atomic-natives-win32-arm64-msvc": "0.9.26
|
|
446
|
-
"@bastani/atomic-natives-win32-x64-msvc": "0.9.26
|
|
439
|
+
"@bastani/atomic-natives-darwin-arm64": "0.9.26",
|
|
440
|
+
"@bastani/atomic-natives-darwin-x64": "0.9.26",
|
|
441
|
+
"@bastani/atomic-natives-linux-arm64-gnu": "0.9.26",
|
|
442
|
+
"@bastani/atomic-natives-linux-arm64-musl": "0.9.26",
|
|
443
|
+
"@bastani/atomic-natives-linux-x64-gnu": "0.9.26",
|
|
444
|
+
"@bastani/atomic-natives-linux-x64-musl": "0.9.26",
|
|
445
|
+
"@bastani/atomic-natives-win32-arm64-msvc": "0.9.26",
|
|
446
|
+
"@bastani/atomic-natives-win32-x64-msvc": "0.9.26"
|
|
447
447
|
},
|
|
448
448
|
"engines": {
|
|
449
449
|
"bun": ">=1.4.2",
|
|
@@ -451,8 +451,8 @@
|
|
|
451
451
|
}
|
|
452
452
|
},
|
|
453
453
|
"node_modules/@bastani/atomic-natives-darwin-arm64": {
|
|
454
|
-
"version": "0.9.26
|
|
455
|
-
"resolved": "https://registry.npmjs.org/@bastani/atomic-natives-darwin-arm64/-/atomic-natives-darwin-arm64-0.9.26
|
|
454
|
+
"version": "0.9.26",
|
|
455
|
+
"resolved": "https://registry.npmjs.org/@bastani/atomic-natives-darwin-arm64/-/atomic-natives-darwin-arm64-0.9.26.tgz",
|
|
456
456
|
"license": "MIT",
|
|
457
457
|
"os": [
|
|
458
458
|
"darwin"
|
|
@@ -463,8 +463,8 @@
|
|
|
463
463
|
"optional": true
|
|
464
464
|
},
|
|
465
465
|
"node_modules/@bastani/atomic-natives-darwin-x64": {
|
|
466
|
-
"version": "0.9.26
|
|
467
|
-
"resolved": "https://registry.npmjs.org/@bastani/atomic-natives-darwin-x64/-/atomic-natives-darwin-x64-0.9.26
|
|
466
|
+
"version": "0.9.26",
|
|
467
|
+
"resolved": "https://registry.npmjs.org/@bastani/atomic-natives-darwin-x64/-/atomic-natives-darwin-x64-0.9.26.tgz",
|
|
468
468
|
"license": "MIT",
|
|
469
469
|
"os": [
|
|
470
470
|
"darwin"
|
|
@@ -475,8 +475,8 @@
|
|
|
475
475
|
"optional": true
|
|
476
476
|
},
|
|
477
477
|
"node_modules/@bastani/atomic-natives-linux-arm64-gnu": {
|
|
478
|
-
"version": "0.9.26
|
|
479
|
-
"resolved": "https://registry.npmjs.org/@bastani/atomic-natives-linux-arm64-gnu/-/atomic-natives-linux-arm64-gnu-0.9.26
|
|
478
|
+
"version": "0.9.26",
|
|
479
|
+
"resolved": "https://registry.npmjs.org/@bastani/atomic-natives-linux-arm64-gnu/-/atomic-natives-linux-arm64-gnu-0.9.26.tgz",
|
|
480
480
|
"license": "MIT",
|
|
481
481
|
"os": [
|
|
482
482
|
"linux"
|
|
@@ -490,8 +490,8 @@
|
|
|
490
490
|
"optional": true
|
|
491
491
|
},
|
|
492
492
|
"node_modules/@bastani/atomic-natives-linux-arm64-musl": {
|
|
493
|
-
"version": "0.9.26
|
|
494
|
-
"resolved": "https://registry.npmjs.org/@bastani/atomic-natives-linux-arm64-musl/-/atomic-natives-linux-arm64-musl-0.9.26
|
|
493
|
+
"version": "0.9.26",
|
|
494
|
+
"resolved": "https://registry.npmjs.org/@bastani/atomic-natives-linux-arm64-musl/-/atomic-natives-linux-arm64-musl-0.9.26.tgz",
|
|
495
495
|
"license": "MIT",
|
|
496
496
|
"os": [
|
|
497
497
|
"linux"
|
|
@@ -505,8 +505,8 @@
|
|
|
505
505
|
"optional": true
|
|
506
506
|
},
|
|
507
507
|
"node_modules/@bastani/atomic-natives-linux-x64-gnu": {
|
|
508
|
-
"version": "0.9.26
|
|
509
|
-
"resolved": "https://registry.npmjs.org/@bastani/atomic-natives-linux-x64-gnu/-/atomic-natives-linux-x64-gnu-0.9.26
|
|
508
|
+
"version": "0.9.26",
|
|
509
|
+
"resolved": "https://registry.npmjs.org/@bastani/atomic-natives-linux-x64-gnu/-/atomic-natives-linux-x64-gnu-0.9.26.tgz",
|
|
510
510
|
"license": "MIT",
|
|
511
511
|
"os": [
|
|
512
512
|
"linux"
|
|
@@ -520,8 +520,8 @@
|
|
|
520
520
|
"optional": true
|
|
521
521
|
},
|
|
522
522
|
"node_modules/@bastani/atomic-natives-linux-x64-musl": {
|
|
523
|
-
"version": "0.9.26
|
|
524
|
-
"resolved": "https://registry.npmjs.org/@bastani/atomic-natives-linux-x64-musl/-/atomic-natives-linux-x64-musl-0.9.26
|
|
523
|
+
"version": "0.9.26",
|
|
524
|
+
"resolved": "https://registry.npmjs.org/@bastani/atomic-natives-linux-x64-musl/-/atomic-natives-linux-x64-musl-0.9.26.tgz",
|
|
525
525
|
"license": "MIT",
|
|
526
526
|
"os": [
|
|
527
527
|
"linux"
|
|
@@ -535,8 +535,8 @@
|
|
|
535
535
|
"optional": true
|
|
536
536
|
},
|
|
537
537
|
"node_modules/@bastani/atomic-natives-win32-arm64-msvc": {
|
|
538
|
-
"version": "0.9.26
|
|
539
|
-
"resolved": "https://registry.npmjs.org/@bastani/atomic-natives-win32-arm64-msvc/-/atomic-natives-win32-arm64-msvc-0.9.26
|
|
538
|
+
"version": "0.9.26",
|
|
539
|
+
"resolved": "https://registry.npmjs.org/@bastani/atomic-natives-win32-arm64-msvc/-/atomic-natives-win32-arm64-msvc-0.9.26.tgz",
|
|
540
540
|
"license": "MIT",
|
|
541
541
|
"os": [
|
|
542
542
|
"win32"
|
|
@@ -547,8 +547,8 @@
|
|
|
547
547
|
"optional": true
|
|
548
548
|
},
|
|
549
549
|
"node_modules/@bastani/atomic-natives-win32-x64-msvc": {
|
|
550
|
-
"version": "0.9.26
|
|
551
|
-
"resolved": "https://registry.npmjs.org/@bastani/atomic-natives-win32-x64-msvc/-/atomic-natives-win32-x64-msvc-0.9.26
|
|
550
|
+
"version": "0.9.26",
|
|
551
|
+
"resolved": "https://registry.npmjs.org/@bastani/atomic-natives-win32-x64-msvc/-/atomic-natives-win32-x64-msvc-0.9.26.tgz",
|
|
552
552
|
"license": "MIT",
|
|
553
553
|
"os": [
|
|
554
554
|
"win32"
|
|
@@ -559,13 +559,13 @@
|
|
|
559
559
|
"optional": true
|
|
560
560
|
},
|
|
561
561
|
"node_modules/@bastani/pi-ai": {
|
|
562
|
-
"version": "0.9.26
|
|
563
|
-
"resolved": "https://registry.npmjs.org/@bastani/pi-ai/-/pi-ai-0.9.26
|
|
562
|
+
"version": "0.9.26",
|
|
563
|
+
"resolved": "https://registry.npmjs.org/@bastani/pi-ai/-/pi-ai-0.9.26.tgz",
|
|
564
564
|
"license": "MIT",
|
|
565
565
|
"dependencies": {
|
|
566
566
|
"@anthropic-ai/sdk": "0.129.0",
|
|
567
567
|
"@aws-sdk/client-bedrock-runtime": "3.1127.0",
|
|
568
|
-
"@earendil-works/pi-telemetry": "1.0.
|
|
568
|
+
"@earendil-works/pi-telemetry": "1.0.2",
|
|
569
569
|
"@google/genai": "2.21.0",
|
|
570
570
|
"@smithy/node-http-handler": "4.12.1",
|
|
571
571
|
"http-proxy-agent": "9.1.0",
|
|
@@ -666,9 +666,9 @@
|
|
|
666
666
|
}
|
|
667
667
|
},
|
|
668
668
|
"node_modules/@earendil-works/chord": {
|
|
669
|
-
"version": "1.0.
|
|
670
|
-
"resolved": "https://registry.npmjs.org/@earendil-works/chord/-/chord-1.0.
|
|
671
|
-
"integrity": "sha512-
|
|
669
|
+
"version": "1.0.2",
|
|
670
|
+
"resolved": "https://registry.npmjs.org/@earendil-works/chord/-/chord-1.0.2.tgz",
|
|
671
|
+
"integrity": "sha512-eUXGZjigyEQsFiT/oBJUOaCrzYZRmqf8AgLrlbyuS4u02hjSVhLYRi3xqk1o4UERCgRfjRegqwj/oucawIR7YQ==",
|
|
672
672
|
"license": "MIT",
|
|
673
673
|
"dependencies": {
|
|
674
674
|
"esbuild": "0.28.2"
|
|
@@ -678,12 +678,12 @@
|
|
|
678
678
|
}
|
|
679
679
|
},
|
|
680
680
|
"node_modules/@earendil-works/pi-agent-core": {
|
|
681
|
-
"version": "1.0.
|
|
682
|
-
"resolved": "https://registry.npmjs.org/@earendil-works/pi-agent-core/-/pi-agent-core-1.0.
|
|
683
|
-
"integrity": "sha512-
|
|
681
|
+
"version": "1.0.2",
|
|
682
|
+
"resolved": "https://registry.npmjs.org/@earendil-works/pi-agent-core/-/pi-agent-core-1.0.2.tgz",
|
|
683
|
+
"integrity": "sha512-VRfewY1R5mbedJzlm01PxdCmqU8QrSXjXXhV50bp6rvVuT8YYQv1inTXRY4YzssmGAYpkC2rXipJKP5BpBFXew==",
|
|
684
684
|
"license": "MIT",
|
|
685
685
|
"dependencies": {
|
|
686
|
-
"@earendil-works/pi-ai": "^1.0.
|
|
686
|
+
"@earendil-works/pi-ai": "^1.0.2",
|
|
687
687
|
"typebox": "1.3.27"
|
|
688
688
|
},
|
|
689
689
|
"engines": {
|
|
@@ -691,14 +691,14 @@
|
|
|
691
691
|
}
|
|
692
692
|
},
|
|
693
693
|
"node_modules/@earendil-works/pi-ai": {
|
|
694
|
-
"version": "1.0.
|
|
695
|
-
"resolved": "https://registry.npmjs.org/@earendil-works/pi-ai/-/pi-ai-1.0.
|
|
696
|
-
"integrity": "sha512-
|
|
694
|
+
"version": "1.0.2",
|
|
695
|
+
"resolved": "https://registry.npmjs.org/@earendil-works/pi-ai/-/pi-ai-1.0.2.tgz",
|
|
696
|
+
"integrity": "sha512-JP59xGlSAQ/HhQ6EHN5qmneBlWfDyu6FPPryAvAaSo8A38ubAsEpS9YisCM5Jbbns0srrDffLZonE0OXorHI5A==",
|
|
697
697
|
"license": "MIT",
|
|
698
698
|
"dependencies": {
|
|
699
699
|
"@anthropic-ai/sdk": "0.129.0",
|
|
700
700
|
"@aws-sdk/client-bedrock-runtime": "3.1127.0",
|
|
701
|
-
"@earendil-works/pi-telemetry": "^1.0.
|
|
701
|
+
"@earendil-works/pi-telemetry": "^1.0.2",
|
|
702
702
|
"@google/genai": "2.21.0",
|
|
703
703
|
"@smithy/node-http-handler": "4.12.1",
|
|
704
704
|
"http-proxy-agent": "9.1.0",
|
|
@@ -738,22 +738,22 @@
|
|
|
738
738
|
}
|
|
739
739
|
},
|
|
740
740
|
"node_modules/@earendil-works/pi-client": {
|
|
741
|
-
"version": "1.0.
|
|
742
|
-
"resolved": "https://registry.npmjs.org/@earendil-works/pi-client/-/pi-client-1.0.
|
|
743
|
-
"integrity": "sha512-
|
|
741
|
+
"version": "1.0.2",
|
|
742
|
+
"resolved": "https://registry.npmjs.org/@earendil-works/pi-client/-/pi-client-1.0.2.tgz",
|
|
743
|
+
"integrity": "sha512-KwznnEx24irb2pBIMeha6iIVyoYtrfpbtKkgw31xVn2Q/yzCbTtMe81a5Ep0BAN001iLn5D+aALjQ9vQDpSnGw==",
|
|
744
744
|
"license": "MIT",
|
|
745
745
|
"dependencies": {
|
|
746
|
-
"@earendil-works/chord": "^1.0.
|
|
747
|
-
"@earendil-works/pi-protocol": "^1.0.
|
|
746
|
+
"@earendil-works/chord": "^1.0.2",
|
|
747
|
+
"@earendil-works/pi-protocol": "^1.0.2"
|
|
748
748
|
},
|
|
749
749
|
"engines": {
|
|
750
750
|
"node": ">=22.19.0"
|
|
751
751
|
}
|
|
752
752
|
},
|
|
753
753
|
"node_modules/@earendil-works/pi-codemode": {
|
|
754
|
-
"version": "1.0.
|
|
755
|
-
"resolved": "https://registry.npmjs.org/@earendil-works/pi-codemode/-/pi-codemode-1.0.
|
|
756
|
-
"integrity": "sha512-
|
|
754
|
+
"version": "1.0.2",
|
|
755
|
+
"resolved": "https://registry.npmjs.org/@earendil-works/pi-codemode/-/pi-codemode-1.0.2.tgz",
|
|
756
|
+
"integrity": "sha512-tvfDSVz984ra/4y/hIFmYGpP5ojC+C6/ey+DNbjTzfJvbXviW4JYTXwVcm33KAceI0xcOuE+P1yRGLtQgis0/w==",
|
|
757
757
|
"license": "MIT",
|
|
758
758
|
"dependencies": {
|
|
759
759
|
"quickjs-wasi": "3.6.2"
|
|
@@ -763,12 +763,12 @@
|
|
|
763
763
|
}
|
|
764
764
|
},
|
|
765
765
|
"node_modules/@earendil-works/pi-protocol": {
|
|
766
|
-
"version": "1.0.
|
|
767
|
-
"resolved": "https://registry.npmjs.org/@earendil-works/pi-protocol/-/pi-protocol-1.0.
|
|
768
|
-
"integrity": "sha512-
|
|
766
|
+
"version": "1.0.2",
|
|
767
|
+
"resolved": "https://registry.npmjs.org/@earendil-works/pi-protocol/-/pi-protocol-1.0.2.tgz",
|
|
768
|
+
"integrity": "sha512-VT3/ha2XDDP6mesDVbsv2W7AQDnJFbNSdmCezmpaod6Jcq8KnV/2EPzDPtQ7qYntPq2Esx67M/4/c1YbhmkPag==",
|
|
769
769
|
"license": "MIT",
|
|
770
770
|
"dependencies": {
|
|
771
|
-
"@earendil-works/chord": "^1.0.
|
|
771
|
+
"@earendil-works/chord": "^1.0.2",
|
|
772
772
|
"typebox": "1.3.27"
|
|
773
773
|
},
|
|
774
774
|
"engines": {
|
|
@@ -776,18 +776,18 @@
|
|
|
776
776
|
}
|
|
777
777
|
},
|
|
778
778
|
"node_modules/@earendil-works/pi-telemetry": {
|
|
779
|
-
"version": "1.0.
|
|
780
|
-
"resolved": "https://registry.npmjs.org/@earendil-works/pi-telemetry/-/pi-telemetry-1.0.
|
|
781
|
-
"integrity": "sha512-
|
|
779
|
+
"version": "1.0.2",
|
|
780
|
+
"resolved": "https://registry.npmjs.org/@earendil-works/pi-telemetry/-/pi-telemetry-1.0.2.tgz",
|
|
781
|
+
"integrity": "sha512-Ev5h9TE8nEXHCfRKhWj0qpUFhQgVqNteS95vsM2KNGRGm533vOO2ruDPaEwImBKPMBKXy4omz3D6V2cm41gLOQ==",
|
|
782
782
|
"license": "MIT",
|
|
783
783
|
"engines": {
|
|
784
784
|
"node": ">=22.19.0"
|
|
785
785
|
}
|
|
786
786
|
},
|
|
787
787
|
"node_modules/@earendil-works/pi-tui": {
|
|
788
|
-
"version": "1.0.
|
|
789
|
-
"resolved": "https://registry.npmjs.org/@earendil-works/pi-tui/-/pi-tui-1.0.
|
|
790
|
-
"integrity": "sha512-
|
|
788
|
+
"version": "1.0.2",
|
|
789
|
+
"resolved": "https://registry.npmjs.org/@earendil-works/pi-tui/-/pi-tui-1.0.2.tgz",
|
|
790
|
+
"integrity": "sha512-ElfzjnckohEjzHK5Q5iOpqLpQ1YbM/c/XmjBdPVR5k4uoorQPnny5BtT+rvC0cAjVVCUOHWAWppust7FAaEsOQ==",
|
|
791
791
|
"license": "MIT",
|
|
792
792
|
"dependencies": {
|
|
793
793
|
"get-east-asian-width": "1.6.0",
|