@robota-sdk/agent-product 3.8.0 → 3.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +5 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
# @robota-sdk/agent-product
|
|
2
2
|
|
|
3
|
+
## 3.9.0
|
|
4
|
+
### Minor Changes
|
|
5
|
+
|
|
6
|
+
- ae94749: `assembleProduct` now passes a managed-run provider through to the session options instead of refusing it, since the session admits a managed turn only through the durable execution journal. It still refuses when the session options supply a different provider than the managed one the profile resolved, so a managed provider is never silently replaced, and for a pre-built session, whose options carry only a model-step provider.
|
|
7
|
+
|
|
3
8
|
## 3.8.0
|
|
4
9
|
### Minor Changes
|
|
5
10
|
|
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./capability-pack-Dc6eJ76H.cjs"),t=require("./load-external-presets-DyoUUA3V.cjs");require("./preset-tH5pgRIC.cjs");let n=require("@robota-sdk/agent-core"),r=require("@robota-sdk/agent-framework");function i(e,t){if(t.provider&&(0,n.isManagedRunProvider)(t.provider))throw new n.ManagedRunUnavailableError(t.provider.name
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./capability-pack-Dc6eJ76H.cjs"),t=require("./load-external-presets-DyoUUA3V.cjs");require("./preset-tH5pgRIC.cjs");let n=require("@robota-sdk/agent-core"),r=require("@robota-sdk/agent-framework");function i(e,t){let r=e.provider??t.provider;if(t.provider!==void 0&&(0,n.isManagedRunProvider)(t.provider)&&r!==t.provider)throw new n.ManagedRunUnavailableError(t.provider.name,`the session options supply a different provider`);let i=e.providerErrorGuidance??t.providerErrorGuidance,a=e.promptFileReferenceTag??t.promptFileReferenceTag,o=e.modelCommandToolPrefix??t.modelCommandToolPrefix,s=e.subagentHookEnvironmentNames??t.subagentHookEnvironmentNames,c=e.observerFailureWarningCode??t.observerFailureWarningCode,l=e.permissionMode===void 0&&t.defaultPermissionMode!==void 0?{permissionMode:t.defaultPermissionMode}:{},u=e.commandModules??t.commandModules,d={...e.commandHostAdapters,presetRegistry:t.presetRegistry};if(`session`in e){if(r!==void 0&&(0,n.isManagedRunProvider)(r))throw new n.ManagedRunUnavailableError(r.name,`a pre-built session's options carry only a model-step provider`);return{...e,provider:r,...i===void 0?{}:{providerErrorGuidance:i},...a===void 0?{}:{promptFileReferenceTag:a},...o===void 0?{}:{modelCommandToolPrefix:o},...s===void 0?{}:{subagentHookEnvironmentNames:s},...c===void 0?{}:{observerFailureWarningCode:c},commandModules:u,commandHostAdapters:d,...l}}if(r===void 0)throw Error("assembleProduct: no provider available — the profile carried neither `providerSettings` nor an injected `provider`, and the session options supplied none.");return{...e,provider:r,...i===void 0?{}:{providerErrorGuidance:i},...a===void 0?{}:{promptFileReferenceTag:a},...o===void 0?{}:{modelCommandToolPrefix:o},...s===void 0?{}:{subagentHookEnvironmentNames:s},...c===void 0?{}:{observerFailureWarningCode:c},commandModules:u,commandHostAdapters:d,additionalTools:[...e.additionalTools??[],...t.tools],...t.subagents.length>0?{agentDefinitions:t.subagents}:{},...l}}function a(a){let o=a.presetRegistry??t.r(a.presets??[]),s=a.defaultPresetId===void 0?void 0:o.resolvePreset(a.defaultPresetId,a.presetContext),{merged:c,acceptedPacks:l,rejected:u,rejectedPacks:d}=e.t(a.baseCommandModules??[],a.packs??[]),f=a.provider??(a.providerSettings===void 0?void 0:(0,n.createProviderFromConfig)(a.providerSettings,a.providerDefinitions)),p=e=>i(e.session,{provider:f,providerErrorGuidance:a.providerErrorGuidance,promptFileReferenceTag:a.promptFileReferenceTag,modelCommandToolPrefix:a.modelCommandToolPrefix,subagentHookEnvironmentNames:a.subagentHookEnvironmentNames,observerFailureWarningCode:a.observerFailureWarningCode,commandModules:c.commandModules,tools:c.tools,subagents:c.subagents,defaultPermissionMode:s?.permissionMode,presetRegistry:o});return{id:a.id,...a.agentName===void 0?{}:{agentName:a.agentName},...a.version===void 0?{}:{version:a.version},...f===void 0?{}:{provider:f},providerDefinitions:a.providerDefinitions,commandModules:c.commandModules,tools:c.tools,subagents:c.subagents,acceptedPacks:l,rejectedCapabilities:u,rejectedPacks:d,presets:o,resolvePreset:(e,t)=>o.resolvePreset(e,t),...a.defaultPresetId===void 0?{}:{defaultPresetId:a.defaultPresetId},...s===void 0?{}:{defaultPreset:s},backgroundTaskRunners:a.backgroundTaskRunners??[],...a.subagentRunnerFactory===void 0?{}:{subagentRunnerFactory:a.subagentRunnerFactory},...a.transports===void 0?{}:{transports:typeof a.transports==`function`?a.transports():a.transports},buildRuntimeOptions:p,buildRuntime:e=>(0,r.buildRuntimeSession)(p(e))}}exports.assembleProduct=a;
|
package/dist/index.d.cts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.cts","names":[],"sources":["../src/product-profile.ts","../src/assemble-product.ts"],"mappings":";;;;;;;;;;;;;;;;;UAyCiB,gBAAgB,UAAU,qBAAqB;;EAG9D;;EAEA;;EAEA;;;;;;EAQA,8BAA8B,oBAAoB;;;;;;;;;;;EAWlD,mBAAmB;;;;;;EAMnB,WAAW;;EAEX,wBAAwB;;EAExB;;EAEA;;EAEA,+BAA+B;;EAE/B,6BAA6B;;;;;EAM7B,mBAAmB;;;;;;;;;;;;EAYnB,iBAAiB;;EAEjB;;;;;;EAMA,gBAAgB;;EAIhB,iBAAiB;;EAEjB,8BAA8B;;EAI9B,iCAAiC;;EAEjC,wBAAwB;;EAExB,aAAa,gCAAgC;;;;;;;UAQ9B;;;;;;EAMf,SAAS;;;;;;UAOM,kBAAkB,UAAU,qBAAqB;;EAEhE;EACA;EACA;;;;;;EAOA,WAAW;;EAEX,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;;;;;;;;;;iBAiIhB,gBACd,UAAU,sBAAsB,qBAChC,UAAU,qBAAqB,WAAW,sBAE1C,SAAS,KAAK,gBAAgB;EAC5B,8BAA8B;EAC9B,WAAW;IAEZ,yBAAyB,GAAG"}
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{t as e}from"./capability-pack-D389p-Cv.js";import{r as t}from"./load-external-presets-CJeFbxNF.js";import"./preset-nuw37AF-.js";import{ManagedRunUnavailableError as n,createProviderFromConfig as r,isManagedRunProvider as i}from"@robota-sdk/agent-core";import{buildRuntimeSession as a}from"@robota-sdk/agent-framework";function o(e,t){if(t.provider&&i(t.provider))throw new n(t.provider.name
|
|
1
|
+
import{t as e}from"./capability-pack-D389p-Cv.js";import{r as t}from"./load-external-presets-CJeFbxNF.js";import"./preset-nuw37AF-.js";import{ManagedRunUnavailableError as n,createProviderFromConfig as r,isManagedRunProvider as i}from"@robota-sdk/agent-core";import{buildRuntimeSession as a}from"@robota-sdk/agent-framework";function o(e,t){let r=e.provider??t.provider;if(t.provider!==void 0&&i(t.provider)&&r!==t.provider)throw new n(t.provider.name,`the session options supply a different provider`);let a=e.providerErrorGuidance??t.providerErrorGuidance,o=e.promptFileReferenceTag??t.promptFileReferenceTag,s=e.modelCommandToolPrefix??t.modelCommandToolPrefix,c=e.subagentHookEnvironmentNames??t.subagentHookEnvironmentNames,l=e.observerFailureWarningCode??t.observerFailureWarningCode,u=e.permissionMode===void 0&&t.defaultPermissionMode!==void 0?{permissionMode:t.defaultPermissionMode}:{},d=e.commandModules??t.commandModules,f={...e.commandHostAdapters,presetRegistry:t.presetRegistry};if(`session`in e){if(r!==void 0&&i(r))throw new n(r.name,`a pre-built session's options carry only a model-step provider`);return{...e,provider:r,...a===void 0?{}:{providerErrorGuidance:a},...o===void 0?{}:{promptFileReferenceTag:o},...s===void 0?{}:{modelCommandToolPrefix:s},...c===void 0?{}:{subagentHookEnvironmentNames:c},...l===void 0?{}:{observerFailureWarningCode:l},commandModules:d,commandHostAdapters:f,...u}}if(r===void 0)throw Error("assembleProduct: no provider available — the profile carried neither `providerSettings` nor an injected `provider`, and the session options supplied none.");return{...e,provider:r,...a===void 0?{}:{providerErrorGuidance:a},...o===void 0?{}:{promptFileReferenceTag:o},...s===void 0?{}:{modelCommandToolPrefix:s},...c===void 0?{}:{subagentHookEnvironmentNames:c},...l===void 0?{}:{observerFailureWarningCode:l},commandModules:d,commandHostAdapters:f,additionalTools:[...e.additionalTools??[],...t.tools],...t.subagents.length>0?{agentDefinitions:t.subagents}:{},...u}}function s(n){let i=n.presetRegistry??t(n.presets??[]),s=n.defaultPresetId===void 0?void 0:i.resolvePreset(n.defaultPresetId,n.presetContext),{merged:c,acceptedPacks:l,rejected:u,rejectedPacks:d}=e(n.baseCommandModules??[],n.packs??[]),f=n.provider??(n.providerSettings===void 0?void 0:r(n.providerSettings,n.providerDefinitions)),p=e=>o(e.session,{provider:f,providerErrorGuidance:n.providerErrorGuidance,promptFileReferenceTag:n.promptFileReferenceTag,modelCommandToolPrefix:n.modelCommandToolPrefix,subagentHookEnvironmentNames:n.subagentHookEnvironmentNames,observerFailureWarningCode:n.observerFailureWarningCode,commandModules:c.commandModules,tools:c.tools,subagents:c.subagents,defaultPermissionMode:s?.permissionMode,presetRegistry:i});return{id:n.id,...n.agentName===void 0?{}:{agentName:n.agentName},...n.version===void 0?{}:{version:n.version},...f===void 0?{}:{provider:f},providerDefinitions:n.providerDefinitions,commandModules:c.commandModules,tools:c.tools,subagents:c.subagents,acceptedPacks:l,rejectedCapabilities:u,rejectedPacks:d,presets:i,resolvePreset:(e,t)=>i.resolvePreset(e,t),...n.defaultPresetId===void 0?{}:{defaultPresetId:n.defaultPresetId},...s===void 0?{}:{defaultPreset:s},backgroundTaskRunners:n.backgroundTaskRunners??[],...n.subagentRunnerFactory===void 0?{}:{subagentRunnerFactory:n.subagentRunnerFactory},...n.transports===void 0?{}:{transports:typeof n.transports==`function`?n.transports():n.transports},buildRuntimeOptions:p,buildRuntime:e=>a(p(e))}}export{s as assembleProduct};
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../src/assemble-product.ts"],"sourcesContent":["import { mergeCapabilityPacks } from './capability-pack/index.js';\nimport {\n createProviderFromConfig,\n isManagedRunProvider,\n ManagedRunUnavailableError,\n} from '@robota-sdk/agent-core';\nimport { buildRuntimeSession } from '@robota-sdk/agent-framework';\nimport { createPresetRegistry } from './preset/index.js';\n\nimport type { IAssembledProduct, IBuildRuntimeInput, IProductProfile } from './product-profile.js';\nimport type { TCompositionFieldPolicy } from './capability-pack/index.js';\nimport type {\n FunctionTool,\n IProviderDefinition,\n TProviderDefinition,\n TExecutionProvider,\n IToolWithEventService,\n TPermissionMode,\n} from '@robota-sdk/agent-core';\nimport type {\n IAgentDefinition,\n ICommandHostAdapters,\n ICommandModule,\n TInteractiveSessionOptions,\n} from '@robota-sdk/agent-framework';\nimport type { IPresetRegistry, IResolvedPresetOptions } from './preset/index.js';\n\nexport const PRODUCT_PROFILE_FIELD_POLICIES = {\n id: 'surfaced',\n agentName: 'surfaced',\n version: 'surfaced',\n providerDefinitions: 'consumed-and-surfaced',\n providerSettings: 'consumed',\n provider: 'consumed-and-surfaced',\n providerErrorGuidance: 'consumed',\n promptFileReferenceTag: 'consumed',\n modelCommandToolPrefix: 'consumed',\n subagentHookEnvironmentNames: 'consumed',\n observerFailureWarningCode: 'consumed',\n presets: 'consumed',\n presetRegistry: 'consumed-and-surfaced',\n defaultPresetId: 'consumed-and-surfaced',\n presetContext: 'consumed',\n packs: 'consumed',\n baseCommandModules: 'consumed',\n backgroundTaskRunners: 'surfaced',\n subagentRunnerFactory: 'surfaced',\n transports: 'consumed-and-surfaced',\n} as const satisfies Record<keyof IProductProfile, TCompositionFieldPolicy>;\n\n/** The product-owned materials the assembler overlays onto the shell-supplied session options. */\ninterface IOverlayMaterials {\n provider: TExecutionProvider | undefined;\n providerErrorGuidance: IProductProfile['providerErrorGuidance'];\n promptFileReferenceTag: IProductProfile['promptFileReferenceTag'];\n modelCommandToolPrefix: IProductProfile['modelCommandToolPrefix'];\n subagentHookEnvironmentNames: IProductProfile['subagentHookEnvironmentNames'];\n observerFailureWarningCode: IProductProfile['observerFailureWarningCode'];\n commandModules: readonly ICommandModule[];\n tools: readonly FunctionTool[];\n subagents: readonly IAgentDefinition[];\n defaultPermissionMode: TPermissionMode | undefined;\n /** The instance preset registry, so `/preset` discovers this product's presets. */\n presetRegistry: IPresetRegistry;\n}\n\ntype TAssembledForDefinitions<D extends TProviderDefinition, P extends TExecutionProvider> = Omit<\n IAssembledProduct<TExecutionProvider>,\n 'provider' | 'providerDefinitions'\n> & {\n provider?: ReturnType<D['createProvider']> | P;\n providerDefinitions: readonly D[];\n};\n\n/**\n * Overlay the assembled command modules, pack tools, and pack subagents onto the shell's session options.\n * The injected pre-built-session path gets command modules only (its session already owns its tools); the\n * standard construction path also receives the additive pack tools and — via the framework's\n * `agentDefinitions` injection seam (owner Decision 2) — the merged pack subagents, so a\n * pack's subagents actually reach the runtime instead of being inert material. `agentDefinitions` is left\n * UNSET when no pack contributes one, so the framework's own built-ins + discovery are unchanged.\n *\n * The default preset's `permissionMode` is applied only when the shell left it unset.\n */\nfunction overlaySessionOptions(\n base: TInteractiveSessionOptions,\n materials: IOverlayMaterials,\n): TInteractiveSessionOptions {\n if (materials.provider && isManagedRunProvider(materials.provider)) {\n throw new ManagedRunUnavailableError(materials.provider.name);\n }\n const provider = base.provider ?? materials.provider;\n if (provider && isManagedRunProvider(provider))\n throw new ManagedRunUnavailableError(provider.name);\n const providerErrorGuidance = base.providerErrorGuidance ?? materials.providerErrorGuidance;\n const promptFileReferenceTag = base.promptFileReferenceTag ?? materials.promptFileReferenceTag;\n const modelCommandToolPrefix = base.modelCommandToolPrefix ?? materials.modelCommandToolPrefix;\n const subagentHookEnvironmentNames =\n base.subagentHookEnvironmentNames ?? materials.subagentHookEnvironmentNames;\n const observerFailureWarningCode =\n base.observerFailureWarningCode ?? materials.observerFailureWarningCode;\n const permissionModeOverlay =\n base.permissionMode === undefined && materials.defaultPermissionMode !== undefined\n ? { permissionMode: materials.defaultPermissionMode }\n : {};\n // The shell may hand in a selection it has ALREADY narrowed — the configured shell applies its preset's\n // enabled/disabledCommandModules delta to the merged `base ⊕ packs` superset before calling the seam\n // (the spec's composition order: the merge widens, the preset delta narrows). Overwriting it here would\n // silently undo that narrowing, so the assembled set is overlaid only when the caller left it unset —\n // the same \"only when the shell left it unset\" rule `permissionMode` already follows.\n const commandModules = base.commandModules ?? materials.commandModules;\n // MERGED into the shell's bag, never substituted for it. The shell wires its own adapters\n // there (remote control, process, settings) and the registry stands beside them; replacing the bag\n // would silently drop capabilities this assembler knows nothing about. Both arms get it — an\n // injected session is exactly the embedded-host case the item is about.\n const commandHostAdapters: ICommandHostAdapters = {\n ...base.commandHostAdapters,\n presetRegistry: materials.presetRegistry,\n };\n\n if ('session' in base) {\n return {\n ...base,\n provider,\n ...(providerErrorGuidance !== undefined ? { providerErrorGuidance } : {}),\n ...(promptFileReferenceTag !== undefined ? { promptFileReferenceTag } : {}),\n ...(modelCommandToolPrefix !== undefined ? { modelCommandToolPrefix } : {}),\n ...(subagentHookEnvironmentNames !== undefined ? { subagentHookEnvironmentNames } : {}),\n ...(observerFailureWarningCode !== undefined ? { observerFailureWarningCode } : {}),\n commandModules,\n commandHostAdapters,\n ...permissionModeOverlay,\n };\n }\n\n if (provider === undefined) {\n throw new Error(\n 'assembleProduct: no provider available — the profile carried neither `providerSettings` nor an injected `provider`, and the session options supplied none.',\n );\n }\n\n return {\n ...base,\n provider,\n ...(providerErrorGuidance !== undefined ? { providerErrorGuidance } : {}),\n ...(promptFileReferenceTag !== undefined ? { promptFileReferenceTag } : {}),\n ...(modelCommandToolPrefix !== undefined ? { modelCommandToolPrefix } : {}),\n ...(subagentHookEnvironmentNames !== undefined ? { subagentHookEnvironmentNames } : {}),\n ...(observerFailureWarningCode !== undefined ? { observerFailureWarningCode } : {}),\n commandModules,\n commandHostAdapters,\n additionalTools: [\n ...(base.additionalTools ?? []),\n ...(materials.tools as readonly IToolWithEventService[]),\n ],\n ...(materials.subagents.length > 0 ? { agentDefinitions: materials.subagents } : {}),\n ...permissionModeOverlay,\n };\n}\n\n/**\n * The single product-composition function — a PURE, deterministic, IO-free fold over `IProductProfile`.\n *\n * `assembleProduct` is a **peer** of the repo's already-blessed pure folds (`resolvePreset`,\n * `mergeSettings`, `mergeCapabilityPacks`): it reads only its argument, calls only pure sub-folds and the\n * framework's runtime-construction seam, and hard-codes **no** product's choices — there is ZERO\n * product-specific branching (no `if (profile.id === '…')` ever). Everything product-specific arrives as\n * `profile` DATA. This property is what makes the `agent-product` carve-out from the \"no shared\n * product factory\" rule safe; its three parts (dependency-graph neutrality, purity/no-IO, no\n * product-name conditionals) are stated in this package's SPEC.md, \"The pure-fold property\".\n *\n * What it does:\n * 1. Builds a PER-CALL instance-scoped preset registry over `profile.presets` — or adopts the\n * instance the caller already built and handed in as `profile.presetRegistry`. Either way it\n * never mutates the `preset` subpath's module-level `externalPresets` global, so two products in one process do\n * not share one registry and repeat calls do not accumulate. `defaultPresetId` is resolved over that\n * registry with `profile.presetContext`, so the product's `defaultPreset` is the caller's resolution.\n * 2. Merges the additive capability packs onto `profile.baseCommandModules` via `mergeCapabilityPacks`\n * (base ⊕ packs, with a rejection channel — never a silent override).\n * 3. Constructs the provider from `profile.providerDefinitions` + the shell's already-resolved\n * `profile.providerSettings` (owner Decision 1) via agent-core's pure `createProviderFromConfig`; an\n * injected `profile.provider` overrides it.\n * 4. Produces `buildRuntimeOptions`/`buildRuntime`, which DELEGATE runtime construction to\n * `agent-framework`'s `buildRuntimeSession` seam (the SSOT for runtime assembly) — never re-implementing runtime\n * assembly — overlaying the assembled modules, pack tools, and pack subagents (`agentDefinitions`).\n *\n * Settings/args/env resolution and concrete transports/presentation stay in the shell; `assembleProduct`\n * receives already-resolved data and returns neutral materials the shell binds its own transport over.\n */\nexport function assembleProduct<\n D extends TProviderDefinition = IProviderDefinition,\n P extends TExecutionProvider = ReturnType<D['createProvider']>,\n>(\n profile: Omit<IProductProfile<TExecutionProvider>, 'providerDefinitions' | 'provider'> & {\n providerDefinitions: readonly D[];\n provider?: P;\n },\n): TAssembledForDefinitions<D, P> {\n // (1) Per-call instance-scoped preset registry — pure w.r.t. process state. A caller that had to\n // resolve a preset BEFORE it could build this profile (a preset can carry the `model`/`agentName` the\n // profile is constructed from) hands its own instance in as `presetRegistry`; the assembler then uses\n // THAT one rather than building a second, equivalent registry, so there is exactly one resolution path.\n // Either way the registry is instance-scoped — no module-level state is read or mutated.\n const presets = profile.presetRegistry ?? createPresetRegistry(profile.presets ?? []);\n const defaultPreset: IResolvedPresetOptions | undefined =\n profile.defaultPresetId !== undefined\n ? presets.resolvePreset(profile.defaultPresetId, profile.presetContext)\n : undefined;\n\n // (2) Additive capability merge — base ⊕ packs, deterministic, with a rejection channel.\n const { merged, acceptedPacks, rejected, rejectedPacks } = mergeCapabilityPacks(\n profile.baseCommandModules ?? [],\n profile.packs ?? [],\n );\n\n // (3) Provider construction — IN-KERNEL, from the profile's definitions + the shell's ALREADY-RESOLVED\n // settings (owner Decision 1). `createProviderFromConfig` is a pure `config → IAIProvider` factory that\n // lives in `@robota-sdk/agent-core`, an ALLOWED dependency layer,\n // so this reads no fs/env and the fold stays pure. An injected `profile.provider` wins (advanced/test\n // override, e.g. `--session-log` replay); with neither, no provider is constructed and the consumer\n // supplies one in the `buildRuntime` session options (the Mode A shape).\n const provider =\n profile.provider ??\n (profile.providerSettings !== undefined\n ? createProviderFromConfig(profile.providerSettings, profile.providerDefinitions)\n : undefined);\n\n // (4) The runtime-construction delegate — DELEGATES to the framework seam, never re-implements.\n const buildRuntimeOptions = (input: IBuildRuntimeInput): TInteractiveSessionOptions =>\n overlaySessionOptions(input.session, {\n provider,\n providerErrorGuidance: profile.providerErrorGuidance,\n promptFileReferenceTag: profile.promptFileReferenceTag,\n modelCommandToolPrefix: profile.modelCommandToolPrefix,\n subagentHookEnvironmentNames: profile.subagentHookEnvironmentNames,\n observerFailureWarningCode: profile.observerFailureWarningCode,\n commandModules: merged.commandModules,\n tools: merged.tools,\n subagents: merged.subagents,\n defaultPermissionMode: defaultPreset?.permissionMode,\n // The instance registry reaches the SESSION through the host-adapter bag, so\n // `/preset` discovers through the same presets this product resolved with. It was already\n // assembled here and surfaced on the product; what was missing was the last hop, which is why\n // `/preset` read a module global and why two products in one process shared one mutable list.\n presetRegistry: presets,\n });\n\n return {\n id: profile.id,\n ...(profile.agentName !== undefined ? { agentName: profile.agentName } : {}),\n ...(profile.version !== undefined ? { version: profile.version } : {}),\n ...(provider !== undefined ? { provider } : {}),\n providerDefinitions: profile.providerDefinitions,\n commandModules: merged.commandModules,\n tools: merged.tools,\n subagents: merged.subagents,\n acceptedPacks,\n rejectedCapabilities: rejected,\n rejectedPacks,\n presets,\n resolvePreset: (id, context) => presets.resolvePreset(id, context),\n ...(profile.defaultPresetId !== undefined ? { defaultPresetId: profile.defaultPresetId } : {}),\n ...(defaultPreset !== undefined ? { defaultPreset } : {}),\n backgroundTaskRunners: profile.backgroundTaskRunners ?? [],\n ...(profile.subagentRunnerFactory !== undefined\n ? { subagentRunnerFactory: profile.subagentRunnerFactory }\n : {}),\n ...(profile.transports !== undefined\n ? {\n transports:\n typeof profile.transports === 'function' ? profile.transports() : profile.transports,\n }\n : {}),\n buildRuntimeOptions,\n buildRuntime: (input) => buildRuntimeSession(buildRuntimeOptions(input)),\n };\n}\n"],"mappings":"qUAoFA,SAAS,EACP,EACA,EAC4B,CAC5B,GAAI,EAAU,UAAY,EAAqB,EAAU,QAAQ,EAC/D,MAAM,IAAI,EAA2B,EAAU,SAAS,IAAI,EAE9D,IAAM,EAAW,EAAK,UAAY,EAAU,SAC5C,GAAI,GAAY,EAAqB,CAAQ,EAC3C,MAAM,IAAI,EAA2B,EAAS,IAAI,EACpD,I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,CAAC,EAArB,CAAE,eAAc,EAClD,sBAAuB,EAAQ,uBAAyB,CAAC,EACzD,GAAI,EAAQ,wBAA0B,IAAA,GAElC,CAAC,EADD,CAAE,sBAAuB,EAAQ,qBAAsB,EAE3D,GAAI,EAAQ,aAAe,IAAA,GAKvB,CAAC,EAJD,CACE,WACE,OAAO,EAAQ,YAAe,WAAa,EAAQ,WAAW,EAAI,EAAQ,UAC9E,EAEJ,sBACA,aAAe,GAAU,EAAoB,EAAoB,CAAK,CAAC,CACzE,CACF"}
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../src/assemble-product.ts"],"sourcesContent":["import { mergeCapabilityPacks } from './capability-pack/index.js';\nimport {\n createProviderFromConfig,\n isManagedRunProvider,\n ManagedRunUnavailableError,\n} from '@robota-sdk/agent-core';\nimport { buildRuntimeSession } from '@robota-sdk/agent-framework';\nimport { createPresetRegistry } from './preset/index.js';\n\nimport type { IAssembledProduct, IBuildRuntimeInput, IProductProfile } from './product-profile.js';\nimport type { TCompositionFieldPolicy } from './capability-pack/index.js';\nimport type {\n FunctionTool,\n IProviderDefinition,\n TProviderDefinition,\n TExecutionProvider,\n IToolWithEventService,\n TPermissionMode,\n} from '@robota-sdk/agent-core';\nimport type {\n IAgentDefinition,\n ICommandHostAdapters,\n ICommandModule,\n TInteractiveSessionOptions,\n} from '@robota-sdk/agent-framework';\nimport type { IPresetRegistry, IResolvedPresetOptions } from './preset/index.js';\n\nexport const PRODUCT_PROFILE_FIELD_POLICIES = {\n id: 'surfaced',\n agentName: 'surfaced',\n version: 'surfaced',\n providerDefinitions: 'consumed-and-surfaced',\n providerSettings: 'consumed',\n provider: 'consumed-and-surfaced',\n providerErrorGuidance: 'consumed',\n promptFileReferenceTag: 'consumed',\n modelCommandToolPrefix: 'consumed',\n subagentHookEnvironmentNames: 'consumed',\n observerFailureWarningCode: 'consumed',\n presets: 'consumed',\n presetRegistry: 'consumed-and-surfaced',\n defaultPresetId: 'consumed-and-surfaced',\n presetContext: 'consumed',\n packs: 'consumed',\n baseCommandModules: 'consumed',\n backgroundTaskRunners: 'surfaced',\n subagentRunnerFactory: 'surfaced',\n transports: 'consumed-and-surfaced',\n} as const satisfies Record<keyof IProductProfile, TCompositionFieldPolicy>;\n\n/** The product-owned materials the assembler overlays onto the shell-supplied session options. */\ninterface IOverlayMaterials {\n provider: TExecutionProvider | undefined;\n providerErrorGuidance: IProductProfile['providerErrorGuidance'];\n promptFileReferenceTag: IProductProfile['promptFileReferenceTag'];\n modelCommandToolPrefix: IProductProfile['modelCommandToolPrefix'];\n subagentHookEnvironmentNames: IProductProfile['subagentHookEnvironmentNames'];\n observerFailureWarningCode: IProductProfile['observerFailureWarningCode'];\n commandModules: readonly ICommandModule[];\n tools: readonly FunctionTool[];\n subagents: readonly IAgentDefinition[];\n defaultPermissionMode: TPermissionMode | undefined;\n /** The instance preset registry, so `/preset` discovers this product's presets. */\n presetRegistry: IPresetRegistry;\n}\n\ntype TAssembledForDefinitions<D extends TProviderDefinition, P extends TExecutionProvider> = Omit<\n IAssembledProduct<TExecutionProvider>,\n 'provider' | 'providerDefinitions'\n> & {\n provider?: ReturnType<D['createProvider']> | P;\n providerDefinitions: readonly D[];\n};\n\n/**\n * Overlay the assembled command modules, pack tools, and pack subagents onto the shell's session options.\n * The injected pre-built-session path gets command modules only (its session already owns its tools); the\n * standard construction path also receives the additive pack tools and — via the framework's\n * `agentDefinitions` injection seam (owner Decision 2) — the merged pack subagents, so a\n * pack's subagents actually reach the runtime instead of being inert material. `agentDefinitions` is left\n * UNSET when no pack contributes one, so the framework's own built-ins + discovery are unchanged.\n *\n * The default preset's `permissionMode` is applied only when the shell left it unset.\n */\nfunction overlaySessionOptions(\n base: TInteractiveSessionOptions,\n materials: IOverlayMaterials,\n): TInteractiveSessionOptions {\n const provider = base.provider ?? materials.provider;\n // A managed provider passes through: the session admits its turns only through the durable journal.\n // What it must not do is lose its turns, unnoticed, to a different provider the shell supplied.\n if (\n materials.provider !== undefined &&\n isManagedRunProvider(materials.provider) &&\n provider !== materials.provider\n )\n throw new ManagedRunUnavailableError(\n materials.provider.name,\n 'the session options supply a different provider',\n );\n const providerErrorGuidance = base.providerErrorGuidance ?? materials.providerErrorGuidance;\n const promptFileReferenceTag = base.promptFileReferenceTag ?? materials.promptFileReferenceTag;\n const modelCommandToolPrefix = base.modelCommandToolPrefix ?? materials.modelCommandToolPrefix;\n const subagentHookEnvironmentNames =\n base.subagentHookEnvironmentNames ?? materials.subagentHookEnvironmentNames;\n const observerFailureWarningCode =\n base.observerFailureWarningCode ?? materials.observerFailureWarningCode;\n const permissionModeOverlay =\n base.permissionMode === undefined && materials.defaultPermissionMode !== undefined\n ? { permissionMode: materials.defaultPermissionMode }\n : {};\n // The shell may hand in a selection it has ALREADY narrowed — the configured shell applies its preset's\n // enabled/disabledCommandModules delta to the merged `base ⊕ packs` superset before calling the seam\n // (the spec's composition order: the merge widens, the preset delta narrows). Overwriting it here would\n // silently undo that narrowing, so the assembled set is overlaid only when the caller left it unset —\n // the same \"only when the shell left it unset\" rule `permissionMode` already follows.\n const commandModules = base.commandModules ?? materials.commandModules;\n // MERGED into the shell's bag, never substituted for it. The shell wires its own adapters\n // there (remote control, process, settings) and the registry stands beside them; replacing the bag\n // would silently drop capabilities this assembler knows nothing about. Both arms get it — an\n // injected session is exactly the embedded-host case the item is about.\n const commandHostAdapters: ICommandHostAdapters = {\n ...base.commandHostAdapters,\n presetRegistry: materials.presetRegistry,\n };\n\n if ('session' in base) {\n if (provider !== undefined && isManagedRunProvider(provider))\n throw new ManagedRunUnavailableError(\n provider.name,\n \"a pre-built session's options carry only a model-step provider\",\n );\n return {\n ...base,\n provider,\n ...(providerErrorGuidance !== undefined ? { providerErrorGuidance } : {}),\n ...(promptFileReferenceTag !== undefined ? { promptFileReferenceTag } : {}),\n ...(modelCommandToolPrefix !== undefined ? { modelCommandToolPrefix } : {}),\n ...(subagentHookEnvironmentNames !== undefined ? { subagentHookEnvironmentNames } : {}),\n ...(observerFailureWarningCode !== undefined ? { observerFailureWarningCode } : {}),\n commandModules,\n commandHostAdapters,\n ...permissionModeOverlay,\n };\n }\n\n if (provider === undefined) {\n throw new Error(\n 'assembleProduct: no provider available — the profile carried neither `providerSettings` nor an injected `provider`, and the session options supplied none.',\n );\n }\n\n return {\n ...base,\n provider,\n ...(providerErrorGuidance !== undefined ? { providerErrorGuidance } : {}),\n ...(promptFileReferenceTag !== undefined ? { promptFileReferenceTag } : {}),\n ...(modelCommandToolPrefix !== undefined ? { modelCommandToolPrefix } : {}),\n ...(subagentHookEnvironmentNames !== undefined ? { subagentHookEnvironmentNames } : {}),\n ...(observerFailureWarningCode !== undefined ? { observerFailureWarningCode } : {}),\n commandModules,\n commandHostAdapters,\n additionalTools: [\n ...(base.additionalTools ?? []),\n ...(materials.tools as readonly IToolWithEventService[]),\n ],\n ...(materials.subagents.length > 0 ? { agentDefinitions: materials.subagents } : {}),\n ...permissionModeOverlay,\n };\n}\n\n/**\n * The single product-composition function — a PURE, deterministic, IO-free fold over `IProductProfile`.\n *\n * `assembleProduct` is a **peer** of the repo's already-blessed pure folds (`resolvePreset`,\n * `mergeSettings`, `mergeCapabilityPacks`): it reads only its argument, calls only pure sub-folds and the\n * framework's runtime-construction seam, and hard-codes **no** product's choices — there is ZERO\n * product-specific branching (no `if (profile.id === '…')` ever). Everything product-specific arrives as\n * `profile` DATA. This property is what makes the `agent-product` carve-out from the \"no shared\n * product factory\" rule safe; its three parts (dependency-graph neutrality, purity/no-IO, no\n * product-name conditionals) are stated in this package's SPEC.md, \"The pure-fold property\".\n *\n * What it does:\n * 1. Builds a PER-CALL instance-scoped preset registry over `profile.presets` — or adopts the\n * instance the caller already built and handed in as `profile.presetRegistry`. Either way it\n * never mutates the `preset` subpath's module-level `externalPresets` global, so two products in one process do\n * not share one registry and repeat calls do not accumulate. `defaultPresetId` is resolved over that\n * registry with `profile.presetContext`, so the product's `defaultPreset` is the caller's resolution.\n * 2. Merges the additive capability packs onto `profile.baseCommandModules` via `mergeCapabilityPacks`\n * (base ⊕ packs, with a rejection channel — never a silent override).\n * 3. Constructs the provider from `profile.providerDefinitions` + the shell's already-resolved\n * `profile.providerSettings` (owner Decision 1) via agent-core's pure `createProviderFromConfig`; an\n * injected `profile.provider` overrides it.\n * 4. Produces `buildRuntimeOptions`/`buildRuntime`, which DELEGATE runtime construction to\n * `agent-framework`'s `buildRuntimeSession` seam (the SSOT for runtime assembly) — never re-implementing runtime\n * assembly — overlaying the assembled modules, pack tools, and pack subagents (`agentDefinitions`).\n *\n * Settings/args/env resolution and concrete transports/presentation stay in the shell; `assembleProduct`\n * receives already-resolved data and returns neutral materials the shell binds its own transport over.\n */\nexport function assembleProduct<\n D extends TProviderDefinition = IProviderDefinition,\n P extends TExecutionProvider = ReturnType<D['createProvider']>,\n>(\n profile: Omit<IProductProfile<TExecutionProvider>, 'providerDefinitions' | 'provider'> & {\n providerDefinitions: readonly D[];\n provider?: P;\n },\n): TAssembledForDefinitions<D, P> {\n // (1) Per-call instance-scoped preset registry — pure w.r.t. process state. A caller that had to\n // resolve a preset BEFORE it could build this profile (a preset can carry the `model`/`agentName` the\n // profile is constructed from) hands its own instance in as `presetRegistry`; the assembler then uses\n // THAT one rather than building a second, equivalent registry, so there is exactly one resolution path.\n // Either way the registry is instance-scoped — no module-level state is read or mutated.\n const presets = profile.presetRegistry ?? createPresetRegistry(profile.presets ?? []);\n const defaultPreset: IResolvedPresetOptions | undefined =\n profile.defaultPresetId !== undefined\n ? presets.resolvePreset(profile.defaultPresetId, profile.presetContext)\n : undefined;\n\n // (2) Additive capability merge — base ⊕ packs, deterministic, with a rejection channel.\n const { merged, acceptedPacks, rejected, rejectedPacks } = mergeCapabilityPacks(\n profile.baseCommandModules ?? [],\n profile.packs ?? [],\n );\n\n // (3) Provider construction — IN-KERNEL, from the profile's definitions + the shell's ALREADY-RESOLVED\n // settings (owner Decision 1). `createProviderFromConfig` is a pure `config → IAIProvider` factory that\n // lives in `@robota-sdk/agent-core`, an ALLOWED dependency layer,\n // so this reads no fs/env and the fold stays pure. An injected `profile.provider` wins (advanced/test\n // override, e.g. `--session-log` replay); with neither, no provider is constructed and the consumer\n // supplies one in the `buildRuntime` session options (the Mode A shape).\n const provider =\n profile.provider ??\n (profile.providerSettings !== undefined\n ? createProviderFromConfig(profile.providerSettings, profile.providerDefinitions)\n : undefined);\n\n // (4) The runtime-construction delegate — DELEGATES to the framework seam, never re-implements.\n const buildRuntimeOptions = (input: IBuildRuntimeInput): TInteractiveSessionOptions =>\n overlaySessionOptions(input.session, {\n provider,\n providerErrorGuidance: profile.providerErrorGuidance,\n promptFileReferenceTag: profile.promptFileReferenceTag,\n modelCommandToolPrefix: profile.modelCommandToolPrefix,\n subagentHookEnvironmentNames: profile.subagentHookEnvironmentNames,\n observerFailureWarningCode: profile.observerFailureWarningCode,\n commandModules: merged.commandModules,\n tools: merged.tools,\n subagents: merged.subagents,\n defaultPermissionMode: defaultPreset?.permissionMode,\n // The instance registry reaches the SESSION through the host-adapter bag, so\n // `/preset` discovers through the same presets this product resolved with. It was already\n // assembled here and surfaced on the product; what was missing was the last hop, which is why\n // `/preset` read a module global and why two products in one process shared one mutable list.\n presetRegistry: presets,\n });\n\n return {\n id: profile.id,\n ...(profile.agentName !== undefined ? { agentName: profile.agentName } : {}),\n ...(profile.version !== undefined ? { version: profile.version } : {}),\n ...(provider !== undefined ? { provider } : {}),\n providerDefinitions: profile.providerDefinitions,\n commandModules: merged.commandModules,\n tools: merged.tools,\n subagents: merged.subagents,\n acceptedPacks,\n rejectedCapabilities: rejected,\n rejectedPacks,\n presets,\n resolvePreset: (id, context) => presets.resolvePreset(id, context),\n ...(profile.defaultPresetId !== undefined ? { defaultPresetId: profile.defaultPresetId } : {}),\n ...(defaultPreset !== undefined ? { defaultPreset } : {}),\n backgroundTaskRunners: profile.backgroundTaskRunners ?? [],\n ...(profile.subagentRunnerFactory !== undefined\n ? { subagentRunnerFactory: profile.subagentRunnerFactory }\n : {}),\n ...(profile.transports !== undefined\n ? {\n transports:\n typeof profile.transports === 'function' ? profile.transports() : profile.transports,\n }\n : {}),\n buildRuntimeOptions,\n buildRuntime: (input) => buildRuntimeSession(buildRuntimeOptions(input)),\n };\n}\n"],"mappings":"qUAoFA,SAAS,EACP,EACA,EAC4B,CAC5B,IAAM,EAAW,EAAK,UAAY,EAAU,SAG5C,GACE,EAAU,WAAa,IAAA,IACvB,EAAqB,EAAU,QAAQ,GACvC,IAAa,EAAU,SAEvB,MAAM,IAAI,EACR,EAAU,SAAS,KACnB,iDACF,EACF,IAAM,EAAwB,EAAK,uBAAyB,EAAU,sBAChE,EAAyB,EAAK,wBAA0B,EAAU,uBAClE,EAAyB,EAAK,wBAA0B,EAAU,uBAClE,EACJ,EAAK,8BAAgC,EAAU,6BAC3C,EACJ,EAAK,4BAA8B,EAAU,2BACzC,EACJ,EAAK,iBAAmB,IAAA,IAAa,EAAU,wBAA0B,IAAA,GACrE,CAAE,eAAgB,EAAU,qBAAsB,EAClD,CAAC,EAMD,EAAiB,EAAK,gBAAkB,EAAU,eAKlD,EAA4C,CAChD,GAAG,EAAK,oBACR,eAAgB,EAAU,cAC5B,EAEA,GAAI,YAAa,EAAM,CACrB,GAAI,IAAa,IAAA,IAAa,EAAqB,CAAQ,EACzD,MAAM,IAAI,EACR,EAAS,KACT,gEACF,EACF,MAAO,CACL,GAAG,EACH,WACA,GAAI,IAA0B,IAAA,GAAwC,CAAC,EAA7B,CAAE,uBAAsB,EAClE,GAAI,IAA2B,IAAA,GAAyC,CAAC,EAA9B,CAAE,wBAAuB,EACpE,GAAI,IAA2B,IAAA,GAAyC,CAAC,EAA9B,CAAE,wBAAuB,EACpE,GAAI,IAAiC,IAAA,GAA+C,CAAC,EAApC,CAAE,8BAA6B,EAChF,GAAI,IAA+B,IAAA,GAA6C,CAAC,EAAlC,CAAE,4BAA2B,EAC5E,iBACA,sBACA,GAAG,CACL,CACF,CAEA,GAAI,IAAa,IAAA,GACf,MAAU,MACR,4JACF,EAGF,MAAO,CACL,GAA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EAAQ,SAAU,EACrE,GAAI,EAAQ,UAAY,IAAA,GAA2C,CAAC,EAAhC,CAAE,QAAS,EAAQ,OAAQ,EAC/D,GAAI,IAAa,IAAA,GAA2B,CAAC,EAAhB,CAAE,UAAS,EACxC,oBAAqB,EAAQ,oBAC7B,eAAgB,EAAO,eACvB,MAAO,EAAO,MACd,UAAW,EAAO,UAClB,gBACA,qBAAsB,EACtB,gBACA,UACA,eAAgB,EAAI,IAAY,EAAQ,cAAc,EAAI,CAAO,EACjE,GAAI,EAAQ,kBAAoB,IAAA,GAA2D,CAAC,EAAhD,CAAE,gBAAiB,EAAQ,eAAgB,EACvF,GAAI,IAAkB,IAAA,GAAgC,CAAC,EAArB,CAAE,eAAc,EAClD,sBAAuB,EAAQ,uBAAyB,CAAC,EACzD,GAAI,EAAQ,wBAA0B,IAAA,GAElC,CAAC,EADD,CAAE,sBAAuB,EAAQ,qBAAsB,EAE3D,GAAI,EAAQ,aAAe,IAAA,GAKvB,CAAC,EAJD,CACE,WACE,OAAO,EAAQ,YAAe,WAAa,EAAQ,WAAW,EAAI,EAAQ,UAC9E,EAEJ,sBACA,aAAe,GAAU,EAAoB,EAAoB,CAAK,CAAC,CACzE,CACF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@robota-sdk/agent-product",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.9.0",
|
|
4
4
|
"description": "Product assembly for the Robota SDK: assembleProduct over IProductProfile, plus one subpath each for the capability-pack contract, presets, slash-command modules and the coding capability pack",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -109,10 +109,10 @@
|
|
|
109
109
|
],
|
|
110
110
|
"dependencies": {
|
|
111
111
|
"zod": "^4.6.7",
|
|
112
|
-
"@robota-sdk/agent-core": "^3.3.4",
|
|
113
112
|
"@robota-sdk/agent-framework": "^3.3.7",
|
|
113
|
+
"@robota-sdk/agent-tools": "^3.3.3",
|
|
114
114
|
"@robota-sdk/agent-interface": "^3.3.3",
|
|
115
|
-
"@robota-sdk/agent-
|
|
115
|
+
"@robota-sdk/agent-core": "^3.3.4"
|
|
116
116
|
},
|
|
117
117
|
"devDependencies": {
|
|
118
118
|
"@types/node": "^22.19.21",
|