@robota-sdk/agent-product 3.2.3 → 3.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (78) hide show
  1. package/CHANGELOG.md +40 -0
  2. package/README.md +22 -11
  3. package/dist/capability-pack/index.cjs +1 -0
  4. package/dist/capability-pack/index.d.cts +2 -0
  5. package/dist/capability-pack/index.d.ts +2 -0
  6. package/dist/capability-pack/index.js +1 -0
  7. package/dist/capability-pack-D389p-Cv.js +2 -0
  8. package/dist/capability-pack-D389p-Cv.js.map +1 -0
  9. package/dist/capability-pack-Dc6eJ76H.cjs +1 -0
  10. package/dist/coding/index.cjs +1 -0
  11. package/dist/coding/index.d.cts +75 -0
  12. package/dist/coding/index.d.cts.map +1 -0
  13. package/dist/coding/index.d.ts +75 -0
  14. package/dist/coding/index.d.ts.map +1 -0
  15. package/dist/coding/index.js +2 -0
  16. package/dist/coding/index.js.map +1 -0
  17. package/dist/command/index.cjs +1 -0
  18. package/dist/command/index.d.cts +948 -0
  19. package/dist/command/index.d.cts.map +1 -0
  20. package/dist/command/index.d.ts +948 -0
  21. package/dist/command/index.d.ts.map +1 -0
  22. package/dist/command/index.js +1 -0
  23. package/dist/command/node.cjs +1 -0
  24. package/dist/command/node.d.cts +100 -0
  25. package/dist/command/node.d.cts.map +1 -0
  26. package/dist/command/node.d.ts +100 -0
  27. package/dist/command/node.d.ts.map +1 -0
  28. package/dist/command/node.js +1 -0
  29. package/dist/command-DZUsxxG3.cjs +120 -0
  30. package/dist/command-DynprfoA.js +121 -0
  31. package/dist/command-DynprfoA.js.map +1 -0
  32. package/dist/index-BNDTmhmd.d.cts +109 -0
  33. package/dist/index-BNDTmhmd.d.cts.map +1 -0
  34. package/dist/index-BNDTmhmd.d.ts +109 -0
  35. package/dist/index-BNDTmhmd.d.ts.map +1 -0
  36. package/dist/index-Cz8aDRO3.d.cts +156 -0
  37. package/dist/index-Cz8aDRO3.d.cts.map +1 -0
  38. package/dist/index-jksIH551.d.ts +156 -0
  39. package/dist/index-jksIH551.d.ts.map +1 -0
  40. package/dist/index.cjs +1 -1
  41. package/dist/index.d.cts +6 -5
  42. package/dist/index.d.cts.map +1 -1
  43. package/dist/index.d.ts +6 -5
  44. package/dist/index.d.ts.map +1 -1
  45. package/dist/index.js +1 -1
  46. package/dist/index.js.map +1 -1
  47. package/dist/keybindings-command-module-CcA9-Xqi.d.cts +126 -0
  48. package/dist/keybindings-command-module-CcA9-Xqi.d.cts.map +1 -0
  49. package/dist/keybindings-command-module-CcA9-Xqi.d.ts +126 -0
  50. package/dist/keybindings-command-module-CcA9-Xqi.d.ts.map +1 -0
  51. package/dist/load-external-presets-CJeFbxNF.js +5 -0
  52. package/dist/load-external-presets-CJeFbxNF.js.map +1 -0
  53. package/dist/load-external-presets-DCY3HJ8d.d.cts +107 -0
  54. package/dist/load-external-presets-DCY3HJ8d.d.cts.map +1 -0
  55. package/dist/load-external-presets-DCY3HJ8d.d.ts +107 -0
  56. package/dist/load-external-presets-DCY3HJ8d.d.ts.map +1 -0
  57. package/dist/load-external-presets-DyoUUA3V.cjs +4 -0
  58. package/dist/node-BgupUyg0.cjs +1 -0
  59. package/dist/node-Cw2VT1HG.js +2 -0
  60. package/dist/node-Cw2VT1HG.js.map +1 -0
  61. package/dist/preset/index.cjs +1 -0
  62. package/dist/preset/index.d.cts +3 -0
  63. package/dist/preset/index.d.ts +3 -0
  64. package/dist/preset/index.js +1 -0
  65. package/dist/preset/node.cjs +1 -0
  66. package/dist/preset/node.d.cts +13 -0
  67. package/dist/preset/node.d.cts.map +1 -0
  68. package/dist/preset/node.d.ts +13 -0
  69. package/dist/preset/node.d.ts.map +1 -0
  70. package/dist/preset/node.js +2 -0
  71. package/dist/preset/node.js.map +1 -0
  72. package/dist/preset-nuw37AF-.js +4 -0
  73. package/dist/preset-nuw37AF-.js.map +1 -0
  74. package/dist/preset-tH5pgRIC.cjs +3 -0
  75. package/dist/theme-command-module-DYJhjKuI.cjs +2 -0
  76. package/dist/theme-command-module-GyqgVqV9.js +3 -0
  77. package/dist/theme-command-module-GyqgVqV9.js.map +1 -0
  78. package/package.json +78 -8
package/dist/index.js CHANGED
@@ -1,2 +1,2 @@
1
- import{mergeCapabilityPacks as e}from"@robota-sdk/agent-capability-pack";import{createProviderFromConfig as t}from"@robota-sdk/agent-core";import{buildRuntimeSession as n}from"@robota-sdk/agent-framework";import{createPresetRegistry as r}from"@robota-sdk/agent-preset";function i(e,t){let n=e.provider??t.provider,r=e.providerErrorGuidance??t.providerErrorGuidance,i=e.promptFileReferenceTag??t.promptFileReferenceTag,a=e.modelCommandToolPrefix??t.modelCommandToolPrefix,o=e.subagentHookEnvironmentNames??t.subagentHookEnvironmentNames,s=e.observerFailureWarningCode??t.observerFailureWarningCode,c=e.permissionMode===void 0&&t.defaultPermissionMode!==void 0?{permissionMode:t.defaultPermissionMode}:{},l=e.commandModules??t.commandModules,u={...e.commandHostAdapters,presetRegistry:t.presetRegistry};if(`session`in e)return{...e,provider:n,...r===void 0?{}:{providerErrorGuidance:r},...i===void 0?{}:{promptFileReferenceTag:i},...a===void 0?{}:{modelCommandToolPrefix:a},...o===void 0?{}:{subagentHookEnvironmentNames:o},...s===void 0?{}:{observerFailureWarningCode:s},commandModules:l,commandHostAdapters:u,...c};if(n===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:n,...r===void 0?{}:{providerErrorGuidance:r},...i===void 0?{}:{promptFileReferenceTag:i},...a===void 0?{}:{modelCommandToolPrefix:a},...o===void 0?{}:{subagentHookEnvironmentNames:o},...s===void 0?{}:{observerFailureWarningCode:s},commandModules:l,commandHostAdapters:u,additionalTools:[...e.additionalTools??[],...t.tools],...t.subagents.length>0?{agentDefinitions:t.subagents}:{},...c}}function a(a){let o=a.presetRegistry??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(a.baseCommandModules??[],a.packs??[]),f=a.provider??(a.providerSettings===void 0?void 0:t(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=>n(p(e))}}export{a as assembleProduct};
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{createProviderFromConfig as n}from"@robota-sdk/agent-core";import{buildRuntimeSession as r}from"@robota-sdk/agent-framework";function i(e,t){let n=e.provider??t.provider,r=e.providerErrorGuidance??t.providerErrorGuidance,i=e.promptFileReferenceTag??t.promptFileReferenceTag,a=e.modelCommandToolPrefix??t.modelCommandToolPrefix,o=e.subagentHookEnvironmentNames??t.subagentHookEnvironmentNames,s=e.observerFailureWarningCode??t.observerFailureWarningCode,c=e.permissionMode===void 0&&t.defaultPermissionMode!==void 0?{permissionMode:t.defaultPermissionMode}:{},l=e.commandModules??t.commandModules,u={...e.commandHostAdapters,presetRegistry:t.presetRegistry};if(`session`in e)return{...e,provider:n,...r===void 0?{}:{providerErrorGuidance:r},...i===void 0?{}:{promptFileReferenceTag:i},...a===void 0?{}:{modelCommandToolPrefix:a},...o===void 0?{}:{subagentHookEnvironmentNames:o},...s===void 0?{}:{observerFailureWarningCode:s},commandModules:l,commandHostAdapters:u,...c};if(n===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:n,...r===void 0?{}:{providerErrorGuidance:r},...i===void 0?{}:{promptFileReferenceTag:i},...a===void 0?{}:{modelCommandToolPrefix:a},...o===void 0?{}:{subagentHookEnvironmentNames:o},...s===void 0?{}:{observerFailureWarningCode:s},commandModules:l,commandHostAdapters:u,additionalTools:[...e.additionalTools??[],...t.tools],...t.subagents.length>0?{agentDefinitions:t.subagents}:{},...c}}function a(a){let o=a.presetRegistry??t(a.presets??[]),s=a.defaultPresetId===void 0?void 0:o.resolvePreset(a.defaultPresetId,a.presetContext),{merged:c,acceptedPacks:l,rejected:u,rejectedPacks:d}=e(a.baseCommandModules??[],a.packs??[]),f=a.provider??(a.providerSettings===void 0?void 0:n(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=>r(p(e))}}export{a 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 '@robota-sdk/agent-capability-pack';\nimport { createProviderFromConfig } from '@robota-sdk/agent-core';\nimport { buildRuntimeSession } from '@robota-sdk/agent-framework';\nimport { createPresetRegistry } from '@robota-sdk/agent-preset';\n\nimport type { IAssembledProduct, IBuildRuntimeInput, IProductProfile } from './product-profile.js';\nimport type { TCompositionFieldPolicy } from '@robota-sdk/agent-capability-pack';\nimport type {\n FunctionTool,\n IAIProvider,\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 '@robota-sdk/agent-preset';\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: IAIProvider | 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\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 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 safe under the amended\n * project-structure L129 rule, and it is enforced by the three composition-neutrality guards\n * (dependency-graph neutrality, purity/no-IO, no product-name conditionals).\n *\n * What it does:\n * 1. Builds a PER-CALL instance-scoped preset registry over `profile.presets` (R8) — or adopts the\n * instance the caller already built and handed in as `profile.presetRegistry`. Either way it\n * never mutates agent-preset'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(profile: IProductProfile): IAssembledProduct {\n // (1) Per-call instance-scoped preset registry — pure w.r.t. process state (R8). 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":"6QAsEA,SAAS,EACP,EACA,EAC4B,CAC5B,IAAM,EAAW,EAAK,UAAY,EAAU,SACtC,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,EACf,MAAO,CACL,GAAG,EACH,WACA,GAAI,IAA0B,IAAA,GAAwC,CAAC,EAA7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GAI9E,EAAuB,GAC3B,EAAsB,EAAM,QAAS,CACnC,WACA,sBAAuB,EAAQ,sBAC/B,uBAAwB,EAAQ,uBAChC,uBAAwB,EAAQ,uBAChC,6BAA8B,EAAQ,6BACtC,2BAA4B,EAAQ,2BACpC,eAAgB,EAAO,eACvB,MAAO,EAAO,MACd,UAAW,EAAO,UAClB,sBAAuB,GAAe,eAKtC,eAAgB,CAClB,CAAC,EAEH,MAAO,CACL,GAAI,EAAQ,GACZ,GAAI,EAAQ,YAAc,IAAA,GAA+C,CAAC,EAApC,CAAE,UAAW,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"}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../src/assemble-product.ts"],"sourcesContent":["import { mergeCapabilityPacks } from './capability-pack/index.js';\nimport { createProviderFromConfig } 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 IAIProvider,\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: IAIProvider | 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\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 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 safe under the amended\n * project-structure L129 rule, and it is enforced by the three composition-neutrality guards\n * (dependency-graph neutrality, purity/no-IO, no product-name conditionals).\n *\n * What it does:\n * 1. Builds a PER-CALL instance-scoped preset registry over `profile.presets` (R8) — 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(profile: IProductProfile): IAssembledProduct {\n // (1) Per-call instance-scoped preset registry — pure w.r.t. process state (R8). 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":"2QAsEA,SAAS,EACP,EACA,EAC4B,CAC5B,IAAM,EAAW,EAAK,UAAY,EAAU,SACtC,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,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,EAGF,GAAI,IAAa,IAAA,GACf,MAAU,MACR,4JACF,EAGF,MAAO,CACL,GAAG,EACH,WACA,GAAI,IAA0B,IAAA,GAAwC,CAAC,EAA7B,CAAE,uBAAsB,EAClE,GAAI,IAA2B,IAAA,GAAyC,CAAC,EAA9B,CAAE,wBAA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2B,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"}
@@ -0,0 +1,126 @@
1
+ import { IFileSystem, IProviderDefinition } from "@robota-sdk/agent-core";
2
+ import { ICommandHostTerminalHandoff, ICommandHostWorkspace, ICommandMCPActivationAdapter, ICommandModule, IContributionSource, ISkillRootDescriptor, TSettingsData, TSettingsSource, TWorkspaceProjectAccess } from "@robota-sdk/agent-framework";
3
+ import { ICommand, ICommandResult, ICommandSource } from "@robota-sdk/agent-interface/command";
4
+ //#region src/command/doctor/doctor-types.d.ts
5
+ type TDoctorCheckStatus = 'ok' | 'warn' | 'fail' | 'not-configured' | 'not-probed';
6
+ /** The enumerated probes the read-only doctor does not run. Adding one is a spec change. */
7
+ type TDoctorNotProbed = 'mcp-connection' | 'hook-execution' | 'owner-only-mode';
8
+ interface IDoctorCheck {
9
+ /** Stable, user-typeable id (`settings.<scope>.<family>`, `storage.user`, `mcp.plugin.<id>.<server>`). */
10
+ readonly id: string;
11
+ readonly label: string;
12
+ readonly status: TDoctorCheckStatus;
13
+ /** The exact file or directory the finding is about, when there is one. */
14
+ readonly path?: string;
15
+ /** The specific cause, as the owner reported it — a state word, an issue path, an errno; never a secret. */
16
+ readonly cause?: string;
17
+ /** Free-text detail lines rendered under the check. */
18
+ readonly detail?: readonly string[];
19
+ /** Present when this run can repair the finding; names the allowlisted repair id (equal to `id`). */
20
+ readonly repair?: string;
21
+ }
22
+ interface IDoctorReport {
23
+ readonly checks: readonly IDoctorCheck[];
24
+ readonly failCount: number;
25
+ readonly warnCount: number;
26
+ /** Ids of checks whose `repair` is set in THIS run. */
27
+ readonly repairable: readonly string[];
28
+ /** Exit-code contract: `0` when `failCount === 0`, else `1`. */
29
+ readonly exitCode: 0 | 1;
30
+ }
31
+ /** One TCP reachability result; the probe is injected so tests never touch the network. */
32
+ interface IDoctorEndpointProbeResult {
33
+ readonly reachable: boolean;
34
+ readonly elapsedMs?: number;
35
+ readonly error?: string;
36
+ }
37
+ /** What the host knows and the runner does not: the composition the shell built, and its facts. */
38
+ interface IDoctorInputs {
39
+ readonly cwd: string;
40
+ readonly userHome: string;
41
+ /**
42
+ * The product's own user settings file — the only settings layer the repair allowlist may rewrite.
43
+ * The host names it; this library knows no product layout.
44
+ */
45
+ readonly userSettingsPath: string;
46
+ /** The product's user store root and its sessions directory, as the host lays them out. */
47
+ readonly userStorage: {
48
+ readonly root: string;
49
+ readonly sessions: string;
50
+ };
51
+ /** The project state root under a trusted workspace, when the host has one. */
52
+ readonly projectStorageRoot?: string;
53
+ /** Every settings source the runtime merge chain reads, in precedence order. */
54
+ readonly settingsSources: readonly TSettingsSource[];
55
+ readonly projectAccess: TWorkspaceProjectAccess;
56
+ readonly providerDefinitions: readonly IProviderDefinition[];
57
+ /** Optional host wording for remediation; omitted values use product-neutral guidance. */
58
+ readonly diagnosticGuidance?: {
59
+ readonly providerResolution?: string;
60
+ readonly projectTrust?: string;
61
+ };
62
+ /** The environment the credential and `PATH` checks read: the host's own snapshot. */
63
+ readonly env: Readonly<Record<string, string | undefined>>;
64
+ readonly contributionSources: readonly IContributionSource[];
65
+ readonly skillRoots: readonly ISkillRootDescriptor[];
66
+ /** Plugin scope directories, most specific first — the same list the session loader reads. */
67
+ readonly pluginsDirs: readonly string[];
68
+ /** Host-composed MCP activation adapter; absent means the CLI has no MCP host. */
69
+ readonly mcpActivation?: ICommandMCPActivationAdapter;
70
+ /** Checks only the host can make (Node version, terminal, CLI version); rendered first. */
71
+ readonly hostChecks: readonly IDoctorCheck[];
72
+ /** A workspace-composition failure the host converted into a check rather than a crash. */
73
+ readonly compositionFailure?: IDoctorCheck;
74
+ }
75
+ /** Storage facts about one path, probed without writing. */
76
+ interface IDoctorPathFacts {
77
+ readonly exists: boolean;
78
+ readonly isDirectory: boolean;
79
+ readonly writable: boolean;
80
+ /** POSIX mode bits, or `undefined` when the platform does not assert them. */
81
+ readonly mode?: number;
82
+ }
83
+ /**
84
+ * Every side effect the runner and a repair need. The package has no host default: a Node host passes
85
+ * `createNodeDoctorDeps` from `@robota-sdk/agent-product/command/node`, and a host that cannot supply these
86
+ * passes none, so `/doctor` says it is unavailable there.
87
+ */
88
+ interface IDoctorDeps {
89
+ readonly probeEndpoint: (host: string, port: number) => Promise<IDoctorEndpointProbeResult>;
90
+ readonly inspectPath: (path: string) => IDoctorPathFacts;
91
+ /** `true` when a bare command name resolves on `PATH`, or a path-form command exists. */
92
+ readonly resolveCommand: (command: string) => boolean;
93
+ /** The platform's owner-only guarantee for the stores the host keeps. */
94
+ readonly ownerOnlyGuarantee: () => 'posix-mode' | 'windows-acl';
95
+ /** The files the plugin, skill and hook probes read installed extensions through. */
96
+ readonly files: IFileSystem;
97
+ /**
98
+ * Create `directory` and every directory between `options.withinRoot` and it as owner-only
99
+ * directories. The `storage.user` repair is the only caller.
100
+ */
101
+ readonly ensureOwnerOnlyDirectory: (directory: string, options: {
102
+ readonly withinRoot: string;
103
+ }) => void;
104
+ /** Write the settings document at `path`. The `settings.user.*` repair, which writes `{}`, is the only caller. */
105
+ readonly writeSettings: (path: string, settings: TSettingsData) => void;
106
+ }
107
+ //#endregion
108
+ //#region src/command/keybindings/keybindings-command-module.d.ts
109
+ interface IKeybindingsFilePort {
110
+ ensureFile(): Promise<string>;
111
+ }
112
+ /**
113
+ * Opens `path` in the user's editor on the terminal the command holds, and resolves with the editor's
114
+ * exit code. Starting a process is the host's, so a Node host passes `openFileInEditor` from
115
+ * `@robota-sdk/agent-product/command/node`; without one the command says it cannot open an editor here.
116
+ */
117
+ type TOpenFileInEditor = (path: string, cwd: string) => Promise<number>;
118
+ declare function createKeybindingsCommandEntry(): ICommand;
119
+ declare class KeybindingsCommandSource implements ICommandSource {
120
+ readonly name = "keybindings";
121
+ getCommands(): ICommand[];
122
+ }
123
+ declare function createKeybindingsCommandModule(file: IKeybindingsFilePort | undefined, openInEditor?: TOpenFileInEditor): ICommandModule;
124
+ //#endregion
125
+ export { createKeybindingsCommandModule as a, IDoctorEndpointProbeResult as c, IDoctorReport as d, TDoctorCheckStatus as f, createKeybindingsCommandEntry as i, IDoctorInputs as l, KeybindingsCommandSource as n, IDoctorCheck as o, TDoctorNotProbed as p, TOpenFileInEditor as r, IDoctorDeps as s, IKeybindingsFilePort as t, IDoctorPathFacts as u };
126
+ //# sourceMappingURL=keybindings-command-module-CcA9-Xqi.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"keybindings-command-module-CcA9-Xqi.d.cts","names":[],"sources":["../src/command/doctor/doctor-types.ts","../src/command/keybindings/keybindings-command-module.ts"],"mappings":";;;;KAmBY;;KAGA;UAEK;;WAEN;WACA;WACA,QAAQ;;WAER;;WAEA;;WAEA;;WAEA;;UAGM;WACN,iBAAiB;WACjB;WACA;;WAEA;;WAEA;;;UAIM;WACN;WACA;WACA;;;UAIM;WACN;WACA;;;;;WAKA;;WAEA;aAAwB;aAAuB;;;WAE/C;;WAEA,0BAA0B;WAC1B,eAAe;WACf,8BAA8B;;WAE9B;aACE;aACA;;;WAGF,KAAK,SAAS;WACd,8BAA8B;WAC9B,qBAAqB;;WAErB;;WAEA,gBAAgB;;WAEhB,qBAAqB;;WAErB,qBAAqB;;;UAIf;WACN;WACA;WACA;;WAEA;;;;;;;UAQM;WACN,gBAAgB,cAAc,iBAAiB,QAAQ;WACvD,cAAc,iBAAiB;;WAE/B,iBAAiB;;WAEjB;;WAEA,OAAO;;;;;WAKP,2BACP,mBACA;aAAoB;;;WAGb,gBAAgB,cAAc,UAAU;;;;UCpHlC;EACf,cAAc;;;;;;;KAQJ,qBAAqB,cAAc,gBAAgB;iBAE/C,iCAAiC;cAyCpC,oCAAoC;WACtC;EAET,eAAe;;iBAKD,+BACd,MAAM,kCACN,eAAe,oBACd"}
@@ -0,0 +1,126 @@
1
+ import { IFileSystem, IProviderDefinition } from "@robota-sdk/agent-core";
2
+ import { ICommandHostTerminalHandoff, ICommandHostWorkspace, ICommandMCPActivationAdapter, ICommandModule, IContributionSource, ISkillRootDescriptor, TSettingsData, TSettingsSource, TWorkspaceProjectAccess } from "@robota-sdk/agent-framework";
3
+ import { ICommand, ICommandResult, ICommandSource } from "@robota-sdk/agent-interface/command";
4
+ //#region src/command/doctor/doctor-types.d.ts
5
+ type TDoctorCheckStatus = 'ok' | 'warn' | 'fail' | 'not-configured' | 'not-probed';
6
+ /** The enumerated probes the read-only doctor does not run. Adding one is a spec change. */
7
+ type TDoctorNotProbed = 'mcp-connection' | 'hook-execution' | 'owner-only-mode';
8
+ interface IDoctorCheck {
9
+ /** Stable, user-typeable id (`settings.<scope>.<family>`, `storage.user`, `mcp.plugin.<id>.<server>`). */
10
+ readonly id: string;
11
+ readonly label: string;
12
+ readonly status: TDoctorCheckStatus;
13
+ /** The exact file or directory the finding is about, when there is one. */
14
+ readonly path?: string;
15
+ /** The specific cause, as the owner reported it — a state word, an issue path, an errno; never a secret. */
16
+ readonly cause?: string;
17
+ /** Free-text detail lines rendered under the check. */
18
+ readonly detail?: readonly string[];
19
+ /** Present when this run can repair the finding; names the allowlisted repair id (equal to `id`). */
20
+ readonly repair?: string;
21
+ }
22
+ interface IDoctorReport {
23
+ readonly checks: readonly IDoctorCheck[];
24
+ readonly failCount: number;
25
+ readonly warnCount: number;
26
+ /** Ids of checks whose `repair` is set in THIS run. */
27
+ readonly repairable: readonly string[];
28
+ /** Exit-code contract: `0` when `failCount === 0`, else `1`. */
29
+ readonly exitCode: 0 | 1;
30
+ }
31
+ /** One TCP reachability result; the probe is injected so tests never touch the network. */
32
+ interface IDoctorEndpointProbeResult {
33
+ readonly reachable: boolean;
34
+ readonly elapsedMs?: number;
35
+ readonly error?: string;
36
+ }
37
+ /** What the host knows and the runner does not: the composition the shell built, and its facts. */
38
+ interface IDoctorInputs {
39
+ readonly cwd: string;
40
+ readonly userHome: string;
41
+ /**
42
+ * The product's own user settings file — the only settings layer the repair allowlist may rewrite.
43
+ * The host names it; this library knows no product layout.
44
+ */
45
+ readonly userSettingsPath: string;
46
+ /** The product's user store root and its sessions directory, as the host lays them out. */
47
+ readonly userStorage: {
48
+ readonly root: string;
49
+ readonly sessions: string;
50
+ };
51
+ /** The project state root under a trusted workspace, when the host has one. */
52
+ readonly projectStorageRoot?: string;
53
+ /** Every settings source the runtime merge chain reads, in precedence order. */
54
+ readonly settingsSources: readonly TSettingsSource[];
55
+ readonly projectAccess: TWorkspaceProjectAccess;
56
+ readonly providerDefinitions: readonly IProviderDefinition[];
57
+ /** Optional host wording for remediation; omitted values use product-neutral guidance. */
58
+ readonly diagnosticGuidance?: {
59
+ readonly providerResolution?: string;
60
+ readonly projectTrust?: string;
61
+ };
62
+ /** The environment the credential and `PATH` checks read: the host's own snapshot. */
63
+ readonly env: Readonly<Record<string, string | undefined>>;
64
+ readonly contributionSources: readonly IContributionSource[];
65
+ readonly skillRoots: readonly ISkillRootDescriptor[];
66
+ /** Plugin scope directories, most specific first — the same list the session loader reads. */
67
+ readonly pluginsDirs: readonly string[];
68
+ /** Host-composed MCP activation adapter; absent means the CLI has no MCP host. */
69
+ readonly mcpActivation?: ICommandMCPActivationAdapter;
70
+ /** Checks only the host can make (Node version, terminal, CLI version); rendered first. */
71
+ readonly hostChecks: readonly IDoctorCheck[];
72
+ /** A workspace-composition failure the host converted into a check rather than a crash. */
73
+ readonly compositionFailure?: IDoctorCheck;
74
+ }
75
+ /** Storage facts about one path, probed without writing. */
76
+ interface IDoctorPathFacts {
77
+ readonly exists: boolean;
78
+ readonly isDirectory: boolean;
79
+ readonly writable: boolean;
80
+ /** POSIX mode bits, or `undefined` when the platform does not assert them. */
81
+ readonly mode?: number;
82
+ }
83
+ /**
84
+ * Every side effect the runner and a repair need. The package has no host default: a Node host passes
85
+ * `createNodeDoctorDeps` from `@robota-sdk/agent-product/command/node`, and a host that cannot supply these
86
+ * passes none, so `/doctor` says it is unavailable there.
87
+ */
88
+ interface IDoctorDeps {
89
+ readonly probeEndpoint: (host: string, port: number) => Promise<IDoctorEndpointProbeResult>;
90
+ readonly inspectPath: (path: string) => IDoctorPathFacts;
91
+ /** `true` when a bare command name resolves on `PATH`, or a path-form command exists. */
92
+ readonly resolveCommand: (command: string) => boolean;
93
+ /** The platform's owner-only guarantee for the stores the host keeps. */
94
+ readonly ownerOnlyGuarantee: () => 'posix-mode' | 'windows-acl';
95
+ /** The files the plugin, skill and hook probes read installed extensions through. */
96
+ readonly files: IFileSystem;
97
+ /**
98
+ * Create `directory` and every directory between `options.withinRoot` and it as owner-only
99
+ * directories. The `storage.user` repair is the only caller.
100
+ */
101
+ readonly ensureOwnerOnlyDirectory: (directory: string, options: {
102
+ readonly withinRoot: string;
103
+ }) => void;
104
+ /** Write the settings document at `path`. The `settings.user.*` repair, which writes `{}`, is the only caller. */
105
+ readonly writeSettings: (path: string, settings: TSettingsData) => void;
106
+ }
107
+ //#endregion
108
+ //#region src/command/keybindings/keybindings-command-module.d.ts
109
+ interface IKeybindingsFilePort {
110
+ ensureFile(): Promise<string>;
111
+ }
112
+ /**
113
+ * Opens `path` in the user's editor on the terminal the command holds, and resolves with the editor's
114
+ * exit code. Starting a process is the host's, so a Node host passes `openFileInEditor` from
115
+ * `@robota-sdk/agent-product/command/node`; without one the command says it cannot open an editor here.
116
+ */
117
+ type TOpenFileInEditor = (path: string, cwd: string) => Promise<number>;
118
+ declare function createKeybindingsCommandEntry(): ICommand;
119
+ declare class KeybindingsCommandSource implements ICommandSource {
120
+ readonly name = "keybindings";
121
+ getCommands(): ICommand[];
122
+ }
123
+ declare function createKeybindingsCommandModule(file: IKeybindingsFilePort | undefined, openInEditor?: TOpenFileInEditor): ICommandModule;
124
+ //#endregion
125
+ export { createKeybindingsCommandModule as a, IDoctorEndpointProbeResult as c, IDoctorReport as d, TDoctorCheckStatus as f, createKeybindingsCommandEntry as i, IDoctorInputs as l, KeybindingsCommandSource as n, IDoctorCheck as o, TDoctorNotProbed as p, TOpenFileInEditor as r, IDoctorDeps as s, IKeybindingsFilePort as t, IDoctorPathFacts as u };
126
+ //# sourceMappingURL=keybindings-command-module-CcA9-Xqi.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"keybindings-command-module-CcA9-Xqi.d.ts","names":[],"sources":["../src/command/doctor/doctor-types.ts","../src/command/keybindings/keybindings-command-module.ts"],"mappings":";;;;KAmBY;;KAGA;UAEK;;WAEN;WACA;WACA,QAAQ;;WAER;;WAEA;;WAEA;;WAEA;;UAGM;WACN,iBAAiB;WACjB;WACA;;WAEA;;WAEA;;;UAIM;WACN;WACA;WACA;;;UAIM;WACN;WACA;;;;;WAKA;;WAEA;aAAwB;aAAuB;;;WAE/C;;WAEA,0BAA0B;WAC1B,eAAe;WACf,8BAA8B;;WAE9B;aACE;aACA;;;WAGF,KAAK,SAAS;WACd,8BAA8B;WAC9B,qBAAqB;;WAErB;;WAEA,gBAAgB;;WAEhB,qBAAqB;;WAErB,qBAAqB;;;UAIf;WACN;WACA;WACA;;WAEA;;;;;;;UAQM;WACN,gBAAgB,cAAc,iBAAiB,QAAQ;WACvD,cAAc,iBAAiB;;WAE/B,iBAAiB;;WAEjB;;WAEA,OAAO;;;;;WAKP,2BACP,mBACA;aAAoB;;;WAGb,gBAAgB,cAAc,UAAU;;;;UCpHlC;EACf,cAAc;;;;;;;KAQJ,qBAAqB,cAAc,gBAAgB;iBAE/C,iCAAiC;cAyCpC,oCAAoC;WACtC;EAET,eAAe;;iBAKD,+BACd,MAAM,kCACN,eAAe,oBACd"}
@@ -0,0 +1,5 @@
1
+ import{VALID_PERMISSION_MODES as e,parseModelEffort as t}from"@robota-sdk/agent-framework";const n={id:`default`,title:`Default`,description:`Neutral baseline preset — no overrides; reproduces the standard agent behaviour.`},r={id:`autonomous-builder`,title:`Autonomous Builder`,description:`Proactive, self-verifying builder posture — high effort, acts first, dispatches parallel subagents (proactive autonomous-builder persona; original English wording).`,effort:`high`,autonomy:`act-first`,enableParallelSubagents:!0,selfVerification:!0,persona:[`You are a proactive, high-autonomy builder. When you have enough to proceed, proceed and`,`complete the task — act rather than stop to ask. Keep going through the points where a more`,`hesitant assistant would pause for confirmation, and only check in when something is genuinely`,`ambiguous or risky.`,``,`Stay inside the scope of the task. Do the simplest thing that works; do not refactor, add`,`abstractions, or expand scope beyond what was asked. Handle the adjacent detail that the task`,`plainly needs, but resist turning a focused change into a sweeping one.`,``,`After making changes, verify your own work — run the tests, re-read the goal, and confirm the`,`result actually matches what was requested before you call it done.`,``,`Ground your claims in evidence. Before reporting progress, check each claim against an actual`,`tool result from this session; if something is not yet verified, say so plainly rather than`,`implying it is finished.`,``,`Be warm and honest without being sycophantic — tell people what is useful, not just what they`,`want to hear. Stay even-handed and let your conclusions follow from the evidence. When you get`,`something wrong, own it directly, correct it, and move on.`,``,`Lead with the outcome. Report results plainly instead of narrating each step, keep formatting`,`light, and stay concise.`].join(`
2
+ `)},i={id:`careful-reviewer`,title:`Careful Reviewer`,description:`Conservative, ask-first reviewing posture — reads and plans before changing, prompts on write/exec, self-verifies, runs focused (no parallel subagents) at high effort.`,effort:`high`,autonomy:`ask-first`,enableParallelSubagents:!1,selfVerification:!0,persona:[`You are a careful, review-oriented assistant. Read and analyse before you change anything —`,`understand the surrounding code and context first, then lay out a short plan for the change and`,`wait for confirmation before you write or run things that have side effects.`,``,`When you propose a change, explain why — the reasoning behind it and the trade-offs against the`,`alternatives you considered, so the choice can be reviewed rather than taken on trust.`,``,`Stay conservative in scope. Make the change that was asked for and the detail it plainly needs;`,`do not widen the blast radius with unrequested refactors or rewrites.`,``,`Ground your claims in evidence. Before reporting progress or completion, check each claim against`,`an actual tool result from this session; if something is not yet verified, say so plainly rather`,`than implying it is done.`,``,`Be warm and honest without being sycophantic — tell people what is useful, not just what they`,`want to hear. Stay even-handed and let your conclusions follow from the evidence. When you get`,`something wrong, own it directly, correct it, and move on.`].join(`
3
+ `)},a={id:`neutral-executor`,title:`Neutral Executor`,description:`Thin, steerable executor — follows instructions literally, minimal editorialising, strict scope, terse output; balanced autonomy, no parallel subagents, no self-verification, medium effort for predictable scripted use (neutral-alignment work-style; original English wording).`,effort:`medium`,autonomy:`balanced`,enableParallelSubagents:!1,selfVerification:!1,persona:[`Follow the system and user instructions literally. Do what was asked, the way it was asked, and`,`defer to the given instructions over your own preferences.`,``,`Editorialise as little as possible. Skip unrequested commentary, caveats, and asides — give the`,`result, not a narration of it.`,``,`Stay strictly in scope. Make only the change that was requested and the detail it plainly needs;`,`do not add adjacent refactors, comments, or features that were not asked for.`,``,`Keep output terse. Prefer the shortest response that fully answers, so the result is predictable`,`and easy to consume in a script or pipeline.`].join(`
4
+ `)},o={"ask-first":`default`,balanced:`default`,"act-first":`acceptEdits`},s=[n,r,i,a];function c(e){let t=new Set(s.map(e=>e.id)),n=[],r=[];for(let i of e){if(t.has(i.id)){r.push({id:i.id,reason:`collides with built-in preset`});continue}if(n.some(e=>e.id===i.id)){r.push({id:i.id,reason:`duplicate preset id`});continue}n.push(i)}return{accepted:n,rejected:r}}function l(e){let{id:t,title:n,description:r,...i}=e;return i}function u(e){return Object.fromEntries(Object.entries(e).filter(([,e])=>e!==void 0))}function d(e,t){if(!t)return e;let n={...e,...u(t)};return t.deniedTools!==void 0||e.deniedTools!==void 0?{...n,deniedTools:f(e.deniedTools,t.deniedTools)}:n}function f(e,t){return[...new Set([...e??[],...t??[]])]}function p(e,t,n={}){let r=e.find(e=>e.id===t);if(!r){let n=e.map(e=>e.id).join(`, `);throw Error(`Unknown preset: "${t}". Available presets: ${n}.`)}let i=l(r);return i=d(i,n.cliOverrides),i=d(i,n.explicit),h(i)}function m(e=[]){let t=[...s,...c(e).accepted];return{resolvePreset:(e,n={})=>p(t,e,n),getPreset:e=>t.find(t=>t.id===e),listPresets:()=>t.map(({id:e,title:t,description:n})=>({id:e,title:t,description:n}))}}function h(e){return e.permissionMode===void 0?e.defaultPermissionMode===void 0?e.autonomy===void 0?e:{...e,permissionMode:o[e.autonomy]}:{...e,permissionMode:e.defaultPermissionMode}:e}const g=[`ask-first`,`act-first`,`balanced`],_=e;function v(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function y(e){return Array.isArray(e)&&e.every(e=>typeof e==`string`)}function b(e,t){let n=[[`persona`,e.persona,e=>t.persona=e],[`systemPrompt`,e.systemPrompt,e=>t.systemPrompt=e],[`appendSystemPrompt`,e.appendSystemPrompt,e=>t.appendSystemPrompt=e],[`agentName`,e.agentName,e=>t.agentName=e],[`model`,e.model,e=>t.model=e],[`language`,e.language,e=>t.language=e]];for(let[e,t,r]of n)if(t!==void 0){if(typeof t!=`string`)return`${e}: expected a string`;r(t)}}function x(e,t){let n=[[`temperature`,e.temperature,e=>t.temperature=e],[`maxOutputTokens`,e.maxOutputTokens,e=>t.maxOutputTokens=e]];for(let[e,t,r]of n)if(t!==void 0){if(typeof t!=`number`||Number.isNaN(t))return`${e}: expected a number`;r(t)}let r=[[`enableParallelSubagents`,e.enableParallelSubagents,e=>t.enableParallelSubagents=e],[`selfVerification`,e.selfVerification,e=>t.selfVerification=e]];for(let[e,t,n]of r)if(t!==void 0){if(typeof t!=`boolean`)return`${e}: expected a boolean`;n(t)}}function S(e,n){if(e.effort!==void 0){if(typeof e.effort!=`string`)return`effort: expected a string`;try{let r=t(e.effort,`effort`);if(r===void 0)return`effort: expected a Core-owned effort selection`;n.effort=r}catch(e){return`effort: ${e instanceof Error?e.message:String(e)}`}}if(e.autonomy!==void 0){if(!g.includes(e.autonomy))return`autonomy: expected one of ${g.join(`, `)}`;n.autonomy=e.autonomy}let r=[[`permissionMode`,e.permissionMode,e=>n.permissionMode=e],[`defaultPermissionMode`,e.defaultPermissionMode,e=>n.defaultPermissionMode=e]];for(let[e,t,n]of r)if(t!==void 0){if(!_.includes(t))return`${e}: expected one of ${_.join(`, `)}`;n(t)}}function C(e,t){let n=[[`allowedTools`,e.allowedTools,e=>t.allowedTools=e],[`deniedTools`,e.deniedTools,e=>t.deniedTools=e],[`enabledCommandModules`,e.enabledCommandModules,e=>t.enabledCommandModules=e],[`disabledCommandModules`,e.disabledCommandModules,e=>t.disabledCommandModules=e]];for(let[e,t,r]of n)if(t!==void 0){if(!y(t))return`${e}: expected an array of strings`;r(t)}}function w(e){if(!v(e))return{ok:!1,error:`preset: expected a non-null object`};let t=[[`id`,e.id],[`title`,e.title],[`description`,e.description]];for(let[e,n]of t)if(typeof n!=`string`||n.length===0)return{ok:!1,error:`${e}: expected a non-empty string`};let n={},r=b(e,n)??x(e,n)??S(e,n)??C(e,n);return r===void 0?{ok:!0,preset:{id:e.id,title:e.title,description:e.description,...n}}:{ok:!1,error:r}}function T(e){let t=[],n=[],r=new Map;for(let i of e.filter(({fileName:e})=>e.endsWith(`.json`))){let e=i.fileName,a;try{a=JSON.parse(i.read())}catch(n){t.push({file:e,error:n instanceof Error?n.message:String(n)});continue}let o=w(a);if(!o.ok){t.push({file:e,error:o.error});continue}n.push(o.preset),r.set(o.preset.id,e)}let{accepted:i,rejected:a}=c(n);for(let e of a)t.push({file:r.get(e.id)??e.id,error:e.reason});return{presets:i,loaded:i.map(e=>e.id),errors:t}}export{r as a,c as i,w as n,n as o,m as r,T as t};
5
+ //# sourceMappingURL=load-external-presets-CJeFbxNF.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"load-external-presets-CJeFbxNF.js","names":[],"sources":["../src/preset/presets/default.ts","../src/preset/presets/autonomous-builder.ts","../src/preset/presets/careful-reviewer.ts","../src/preset/presets/neutral-executor.ts","../src/preset/resolve-preset.ts","../src/preset/preset-validation.ts","../src/preset/load-external-presets.ts"],"sourcesContent":["import type { IPreset } from '../preset-types.js';\n\n/**\n * The neutral baseline preset. It carries NO option overrides so that resolving it is a\n * pure no-op — applying `default` reproduces the standard agent behaviour exactly (no regression).\n * The default agent identity is chosen by the product shell, not here,\n * so that this preset stays a true identity element under merging.\n */\nexport const defaultPreset: IPreset = {\n id: 'default',\n title: 'Default',\n description: 'Neutral baseline preset — no overrides; reproduces the standard agent behaviour.',\n};\n","import type { IPreset } from '../preset-types.js';\n\n/**\n * Portable behavioural principles for the autonomous-builder persona.\n *\n * Authored in our own English wording (paraphrase, not a verbatim copy of any external prompt)\n * and scoped to the PERSONA layer only. It carries no runtime/environment content — working\n * directory, tool schemas, product identity, dates, and permission text remain the framework\n * RUNTIME layer's responsibility (composed after this block by `buildSystemPrompt`).\n */\nconst AUTONOMOUS_BUILDER_PERSONA = [\n 'You are a proactive, high-autonomy builder. When you have enough to proceed, proceed and',\n 'complete the task — act rather than stop to ask. Keep going through the points where a more',\n 'hesitant assistant would pause for confirmation, and only check in when something is genuinely',\n 'ambiguous or risky.',\n '',\n 'Stay inside the scope of the task. Do the simplest thing that works; do not refactor, add',\n 'abstractions, or expand scope beyond what was asked. Handle the adjacent detail that the task',\n 'plainly needs, but resist turning a focused change into a sweeping one.',\n '',\n 'After making changes, verify your own work — run the tests, re-read the goal, and confirm the',\n 'result actually matches what was requested before you call it done.',\n '',\n 'Ground your claims in evidence. Before reporting progress, check each claim against an actual',\n 'tool result from this session; if something is not yet verified, say so plainly rather than',\n 'implying it is finished.',\n '',\n 'Be warm and honest without being sycophantic — tell people what is useful, not just what they',\n 'want to hear. Stay even-handed and let your conclusions follow from the evidence. When you get',\n 'something wrong, own it directly, correct it, and move on.',\n '',\n 'Lead with the outcome. Report results plainly instead of narrating each step, keep formatting',\n 'light, and stay concise.',\n].join('\\n');\n\n/**\n * The first opinionated built-in preset: an autonomous, self-verifying builder posture.\n *\n * It both ships a portable persona block AND sets the framework/executor mechanism flags\n * (`effort`, `autonomy`, `enableParallelSubagents`, `selfVerification`) so the style is backed\n * by real, observable behaviour rather than persona text alone. The identifier is generic; the\n * sourcing footnote in `description` is the only place a work-style attribution appears.\n *\n * For long-running tasks the effort dial may be raised to a higher tier; `'high'` is the\n * neutral default carried here.\n */\nexport const autonomousBuilderPreset: IPreset = {\n id: 'autonomous-builder',\n title: 'Autonomous Builder',\n description:\n 'Proactive, self-verifying builder posture — high effort, acts first, dispatches parallel ' +\n 'subagents (proactive autonomous-builder persona; original English wording).',\n effort: 'high',\n autonomy: 'act-first',\n enableParallelSubagents: true,\n selfVerification: true,\n persona: AUTONOMOUS_BUILDER_PERSONA,\n};\n","import type { IPreset } from '../preset-types.js';\n\n/**\n * Portable behavioural principles for the careful-reviewer persona.\n *\n * Authored in our own English wording (paraphrase, not a verbatim copy of any external prompt)\n * and scoped to the PERSONA layer only. It carries no runtime/environment content — working\n * directory, tool schemas, product identity, dates, and permission text remain the framework\n * RUNTIME layer's responsibility (composed after this block by `buildSystemPrompt`).\n *\n * The block stays light: a few oriented traits plus a guiding posture, with no stacked emphasis\n * words and no instruction to surface raw reasoning.\n */\nconst CAREFUL_REVIEWER_PERSONA = [\n 'You are a careful, review-oriented assistant. Read and analyse before you change anything —',\n 'understand the surrounding code and context first, then lay out a short plan for the change and',\n 'wait for confirmation before you write or run things that have side effects.',\n '',\n 'When you propose a change, explain why — the reasoning behind it and the trade-offs against the',\n 'alternatives you considered, so the choice can be reviewed rather than taken on trust.',\n '',\n 'Stay conservative in scope. Make the change that was asked for and the detail it plainly needs;',\n 'do not widen the blast radius with unrequested refactors or rewrites.',\n '',\n 'Ground your claims in evidence. Before reporting progress or completion, check each claim against',\n 'an actual tool result from this session; if something is not yet verified, say so plainly rather',\n 'than implying it is done.',\n '',\n 'Be warm and honest without being sycophantic — tell people what is useful, not just what they',\n 'want to hear. Stay even-handed and let your conclusions follow from the evidence. When you get',\n 'something wrong, own it directly, correct it, and move on.',\n].join('\\n');\n\n/**\n * An opinionated built-in preset: a conservative, ask-first reviewing posture.\n *\n * It is the deliberate counterpart to `autonomous-builder` on the autonomy axis. It both ships a\n * portable persona block AND sets the framework/executor mechanism flags so the review style is\n * backed by real, observable behaviour rather than persona text alone:\n *\n * - `autonomy: 'ask-first'` → the resolver maps this onto the ask-on-write permission posture, so\n * writes/exec are prompted rather than auto-accepted.\n * - `selfVerification: true` → the framework/executor verifier loop runs before changes settle.\n * - `enableParallelSubagents: false` → focused analysis, not fan-out.\n * - `effort: 'high'` → deep reading/analysis of code and context before acting.\n *\n * The identifier is generic; no work-style attribution appears in the source.\n */\nexport const carefulReviewerPreset: IPreset = {\n id: 'careful-reviewer',\n title: 'Careful Reviewer',\n description:\n 'Conservative, ask-first reviewing posture — reads and plans before changing, prompts on ' +\n 'write/exec, self-verifies, runs focused (no parallel subagents) at high effort.',\n effort: 'high',\n autonomy: 'ask-first',\n enableParallelSubagents: false,\n selfVerification: true,\n persona: CAREFUL_REVIEWER_PERSONA,\n};\n","import type { IPreset } from '../preset-types.js';\n\n/**\n * Portable behavioural principles for the neutral-executor persona — a thin, steerable posture.\n *\n * Authored in our own English wording (paraphrase, not a verbatim copy of any external prompt)\n * and scoped to the PERSONA layer only. It carries no runtime/environment content — working\n * directory, tool schemas, product identity, dates, and permission text remain the framework\n * RUNTIME layer's responsibility (composed after this block by `buildSystemPrompt`).\n *\n * The block is intentionally minimal: follow instructions literally, editorialise little, stay in\n * scope, output tersely. No stacked emphasis words; no instruction to surface raw reasoning.\n */\nconst NEUTRAL_EXECUTOR_PERSONA = [\n 'Follow the system and user instructions literally. Do what was asked, the way it was asked, and',\n 'defer to the given instructions over your own preferences.',\n '',\n 'Editorialise as little as possible. Skip unrequested commentary, caveats, and asides — give the',\n 'result, not a narration of it.',\n '',\n 'Stay strictly in scope. Make only the change that was requested and the detail it plainly needs;',\n 'do not add adjacent refactors, comments, or features that were not asked for.',\n '',\n 'Keep output terse. Prefer the shortest response that fully answers, so the result is predictable',\n 'and easy to consume in a script or pipeline.',\n].join('\\n');\n\n/**\n * A thin, steerable built-in preset: a minimal-opinion executor that follows instructions\n * literally and keeps output predictable for automation/scripting.\n *\n * Unlike `default` (which pins behaviour in no direction), this preset actively pins a terse,\n * literal posture, AND it sets framework/executor mechanism flags so the thinness is observable\n * rather than persona text alone:\n *\n * - `autonomy: 'balanced'` → neither prompts on every write nor acts aggressively (the resolver\n * maps it onto the standard permission posture).\n * - `enableParallelSubagents: false` and `selfVerification: false` → minimal machinery, predictable.\n * - `effort: 'medium'` → predictable, reproducible output for scripted use.\n *\n * The identifier is generic; any work-style attribution is confined to `description`.\n */\nexport const neutralExecutorPreset: IPreset = {\n id: 'neutral-executor',\n title: 'Neutral Executor',\n description:\n 'Thin, steerable executor — follows instructions literally, minimal editorialising, strict ' +\n 'scope, terse output; balanced autonomy, no parallel subagents, no self-verification, medium ' +\n 'effort for predictable scripted use (neutral-alignment work-style; original English wording).',\n effort: 'medium',\n autonomy: 'balanced',\n enableParallelSubagents: false,\n selfVerification: false,\n persona: NEUTRAL_EXECUTOR_PERSONA,\n};\n","import { autonomousBuilderPreset } from './presets/autonomous-builder.js';\nimport { carefulReviewerPreset } from './presets/careful-reviewer.js';\nimport { defaultPreset } from './presets/default.js';\nimport { neutralExecutorPreset } from './presets/neutral-executor.js';\n\nimport type {\n IPreset,\n TPresetAutonomy,\n TPresetPermissionMode,\n IResolvedPresetOptions,\n} from './preset-types.js';\n\n/**\n * Map a behavioural {@link TPresetAutonomy} posture onto a concrete permission mode.\n *\n * `act-first` opts into `acceptEdits` (writes are not prompted every time);\n * `ask-first` and `balanced` stay on `default` (the standard ask-on-write posture).\n * Only consulted when the resolved options set `autonomy` but no explicit\n * `permissionMode`/`defaultPermissionMode`.\n */\nconst AUTONOMY_TO_PERMISSION_MODE: Record<TPresetAutonomy, TPresetPermissionMode> = {\n 'ask-first': 'default',\n balanced: 'default',\n 'act-first': 'acceptEdits',\n};\n\n/** Registry of built-in presets. Built-ins always win on id conflict and cannot be overridden. */\nconst BUILT_IN_PRESETS: readonly IPreset[] = [\n defaultPreset,\n autonomousBuilderPreset,\n carefulReviewerPreset,\n neutralExecutorPreset,\n];\n\n/** Lightweight `{ id, title, description }` view of a preset for discovery/UX. */\nexport interface IPresetSummary {\n id: string;\n title: string;\n description: string;\n}\n\n/** Outcome of {@link partitionExternalPresets}: which presets were accepted and which rejected. */\nexport interface IPresetRegistrationResult {\n accepted: readonly IPreset[];\n rejected: readonly { id: string; reason: string }[];\n}\n\n/**\n * Apply the external-preset conflict policy to one list, reading and mutating NOTHING outside it.\n *\n * Conflict policy: an external preset whose id matches a BUILT-IN preset is rejected\n * (`'collides with built-in preset'`) — built-ins always win. An external preset whose id matches an\n * earlier ACCEPTED external preset is rejected (`'duplicate preset id'`) — first one wins.\n *\n * The policy is not the process's to hold, only the list it is applied to is. Both callers —\n * {@link createPresetRegistry} and the external-preset loader — now pass their own list, so two\n * products in one process cannot see each other's presets, and a repeated load cannot accumulate.\n */\nexport function partitionExternalPresets(presets: readonly IPreset[]): IPresetRegistrationResult {\n const builtInIds = new Set(BUILT_IN_PRESETS.map((preset) => preset.id));\n const accepted: IPreset[] = [];\n const rejected: { id: string; reason: string }[] = [];\n\n for (const preset of presets) {\n if (builtInIds.has(preset.id)) {\n rejected.push({ id: preset.id, reason: 'collides with built-in preset' });\n continue;\n }\n if (accepted.some((existing) => existing.id === preset.id)) {\n rejected.push({ id: preset.id, reason: 'duplicate preset id' });\n continue;\n }\n accepted.push(preset);\n }\n\n return { accepted, rejected };\n}\n\n/**\n * Override layers for {@link resolvePreset}, in increasing precedence.\n * `cliOverrides` model CLI flags; `explicit` models programmatic/SDK options.\n */\nexport interface IResolvePresetContext {\n cliOverrides?: IResolvedPresetOptions;\n explicit?: IResolvedPresetOptions;\n}\n\n/** Strip the identity triple from a preset, leaving only resolvable option overrides. */\nfunction toPresetOptions(preset: IPreset): IResolvedPresetOptions {\n const { id: _id, title: _title, description: _description, ...options } = preset;\n return options;\n}\n\n/** Keep only the entries of `source` whose value is defined. */\nfunction definedEntries(source: IResolvedPresetOptions): Partial<IResolvedPresetOptions> {\n return Object.fromEntries(Object.entries(source).filter(([, value]) => value !== undefined));\n}\n\n/**\n * Merge `source` onto `target`, skipping `undefined` values so later layers only override set keys.\n *\n * The two tool lists combine differently, and the difference is the\n * decision rather than an implementation detail.\n *\n * - **`allowedTools` REPLACES.** An allowlist is a statement of the COMPLETE permitted set, so a\n * later, more specific layer stating one supersedes the earlier answer. Intersecting would let an\n * earlier layer veto a tool the operator just named, and unioning would let it smuggle one in.\n * - **`deniedTools` UNIONS.** A denial is not weakened by a later layer that forgot to repeat it —\n * forgetting is the common case, and the cost of the two mistakes is not symmetric.\n *\n * This lives HERE, in the resolver, because precedence is the resolver's job: a union applied by one\n * of three shells is a rule the other two disagree with, which is how precedence rules drift apart.\n */\nfunction mergeDefined(\n target: IResolvedPresetOptions,\n source: IResolvedPresetOptions | undefined,\n): IResolvedPresetOptions {\n if (!source) {\n return target;\n }\n const merged = { ...target, ...definedEntries(source) };\n return source.deniedTools !== undefined || target.deniedTools !== undefined\n ? { ...merged, deniedTools: unionTools(target.deniedTools, source.deniedTools) }\n : merged;\n}\n\n/** Every denial either layer stated, order preserved and duplicates dropped. */\nfunction unionTools(\n earlier: readonly string[] | undefined,\n later: readonly string[] | undefined,\n): string[] {\n return [...new Set([...(earlier ?? []), ...(later ?? [])])];\n}\n\n/**\n * Pure resolve over an explicit preset list — the core every {@link createPresetRegistry} instance\n * resolves through. Reads only its arguments; performs the precedence merge + permission-mode\n * derivation.\n *\n * Precedence LOW → HIGH: preset options < `context.cliOverrides` < `context.explicit` (later layers\n * win; `undefined` values are skipped). For the no-op `'default'` preset the result equals the\n * merged overrides.\n *\n * @throws Error when `id` does not match a preset in `presets`.\n */\nfunction resolvePresetFrom(\n presets: readonly IPreset[],\n id: string,\n context: IResolvePresetContext = {},\n): IResolvedPresetOptions {\n const preset = presets.find((p) => p.id === id);\n if (!preset) {\n const available = presets.map((p) => p.id).join(', ');\n throw new Error(`Unknown preset: \"${id}\". Available presets: ${available}.`);\n }\n\n let resolved = toPresetOptions(preset);\n resolved = mergeDefined(resolved, context.cliOverrides);\n resolved = mergeDefined(resolved, context.explicit);\n return derivePermissionMode(resolved);\n}\n\n/**\n * A per-call, instance-scoped preset registry — the ONLY one there is.\n *\n * A registry holds its own merged list `[built-ins, ...accepted externals]`, so two products in one\n * process do not share one and repeat construction does not accumulate. The\n * `@robota-sdk/agent-product` assembler builds one per `assembleProduct` call and surfaces it on the\n * command-host context, which is how `/preset` inside a live session reaches THIS product's presets\n * rather than the process's.\n */\nexport interface IPresetRegistry {\n /** Resolve a preset id against this registry's presets. */\n resolvePreset(id: string, context?: IResolvePresetContext): IResolvedPresetOptions;\n /** Look up a preset by id within this registry, or `undefined`. */\n getPreset(id: string): IPreset | undefined;\n /** `{ id, title, description }` summaries of every preset in this registry. */\n listPresets(): readonly IPresetSummary[];\n}\n\n/**\n * Build an instance-scoped {@link IPresetRegistry} over `[built-ins, ...externalPresets]`.\n *\n * The conflict policy is {@link partitionExternalPresets}, applied to the argument list only: built-ins\n * always win, and among the external presets the first one wins. No module-level state is read or\n * mutated — this is a pure factory, and there is no module-level state to read.\n *\n * Called with no argument it is the BUILT-INS, which is the registry a host that supplies none gets.\n */\nexport function createPresetRegistry(externalPresets: readonly IPreset[] = []): IPresetRegistry {\n const merged: readonly IPreset[] = [\n ...BUILT_IN_PRESETS,\n ...partitionExternalPresets(externalPresets).accepted,\n ];\n\n return {\n resolvePreset: (id, context = {}) => resolvePresetFrom(merged, id, context),\n getPreset: (id) => merged.find((preset) => preset.id === id),\n listPresets: () => merged.map(({ id, title, description }) => ({ id, title, description })),\n };\n}\n\n/**\n * Fill the framework `permissionMode` seam from the preset's posture fields when it\n * is not already set. Precedence: explicit `permissionMode` (untouched) >\n * `defaultPermissionMode` > `autonomy` mapping. A no-op preset (no posture fields)\n * leaves the object unchanged — keeping `resolvePreset('default')` a no-op.\n */\nfunction derivePermissionMode(resolved: IResolvedPresetOptions): IResolvedPresetOptions {\n if (resolved.permissionMode !== undefined) {\n return resolved;\n }\n if (resolved.defaultPermissionMode !== undefined) {\n return { ...resolved, permissionMode: resolved.defaultPermissionMode };\n }\n if (resolved.autonomy !== undefined) {\n return { ...resolved, permissionMode: AUTONOMY_TO_PERMISSION_MODE[resolved.autonomy] };\n }\n return resolved;\n}\n","import { VALID_PERMISSION_MODES, parseModelEffort } from '@robota-sdk/agent-framework';\n\nimport type {\n IPreset,\n TPresetAutonomy,\n TPresetPermissionMode,\n IResolvedPresetOptions,\n} from './preset-types.js';\n\n/** Result of {@link validateExternalPreset}: the validated preset, or a single error message. */\nexport type TPresetValidationResult = { ok: true; preset: IPreset } | { ok: false; error: string };\n\n/** Runtime membership list for {@link TPresetAutonomy}. */\nconst AUTONOMY_VALUES: readonly TPresetAutonomy[] = ['ask-first', 'act-first', 'balanced'];\n\n/** Runtime membership list for {@link TPresetPermissionMode}: every mode a session accepts. */\nconst PERMISSION_MODE_VALUES: readonly TPresetPermissionMode[] = VALID_PERMISSION_MODES;\n\n/** Narrowing guard: `value` is a non-null, non-array object. */\nfunction isPlainObject(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null && !Array.isArray(value);\n}\n\n/** Narrowing guard: `value` is an array whose every element is a string. */\nfunction isStringArray(value: unknown): value is string[] {\n return Array.isArray(value) && value.every((item) => typeof item === 'string');\n}\n\n/** Validate the string-typed optional fields onto `options`; return the first error, if any. */\nfunction validateStringFields(\n value: Record<string, unknown>,\n options: IResolvedPresetOptions,\n): string | undefined {\n const fields: readonly [string, unknown, (v: string) => void][] = [\n ['persona', value.persona, (v) => (options.persona = v)],\n ['systemPrompt', value.systemPrompt, (v) => (options.systemPrompt = v)],\n ['appendSystemPrompt', value.appendSystemPrompt, (v) => (options.appendSystemPrompt = v)],\n ['agentName', value.agentName, (v) => (options.agentName = v)],\n ['model', value.model, (v) => (options.model = v)],\n ['language', value.language, (v) => (options.language = v)],\n ];\n for (const [field, raw, assign] of fields) {\n if (raw === undefined) {\n continue;\n }\n if (typeof raw !== 'string') {\n return `${field}: expected a string`;\n }\n assign(raw);\n }\n return undefined;\n}\n\n/** Validate the number- and boolean-typed optional fields onto `options`; return the first error. */\nfunction validateScalarFields(\n value: Record<string, unknown>,\n options: IResolvedPresetOptions,\n): string | undefined {\n const numbers: readonly [string, unknown, (v: number) => void][] = [\n ['temperature', value.temperature, (v) => (options.temperature = v)],\n ['maxOutputTokens', value.maxOutputTokens, (v) => (options.maxOutputTokens = v)],\n ];\n for (const [field, raw, assign] of numbers) {\n if (raw === undefined) {\n continue;\n }\n if (typeof raw !== 'number' || Number.isNaN(raw)) {\n return `${field}: expected a number`;\n }\n assign(raw);\n }\n\n const booleans: readonly [string, unknown, (v: boolean) => void][] = [\n [\n 'enableParallelSubagents',\n value.enableParallelSubagents,\n (v) => (options.enableParallelSubagents = v),\n ],\n ['selfVerification', value.selfVerification, (v) => (options.selfVerification = v)],\n ];\n for (const [field, raw, assign] of booleans) {\n if (raw === undefined) {\n continue;\n }\n if (typeof raw !== 'boolean') {\n return `${field}: expected a boolean`;\n }\n assign(raw);\n }\n return undefined;\n}\n\n/** Validate the enum-typed optional fields onto `options`; return the first error, if any. */\nfunction validateEnumFields(\n value: Record<string, unknown>,\n options: IResolvedPresetOptions,\n): string | undefined {\n if (value.effort !== undefined) {\n if (typeof value.effort !== 'string') {\n return 'effort: expected a string';\n }\n try {\n const effort = parseModelEffort(value.effort, 'effort');\n if (effort === undefined) {\n return 'effort: expected a Core-owned effort selection';\n }\n options.effort = effort;\n } catch (error) {\n return `effort: ${error instanceof Error ? error.message : String(error)}`;\n }\n }\n\n if (value.autonomy !== undefined) {\n if (!AUTONOMY_VALUES.includes(value.autonomy as TPresetAutonomy)) {\n return `autonomy: expected one of ${AUTONOMY_VALUES.join(', ')}`;\n }\n options.autonomy = value.autonomy as TPresetAutonomy;\n }\n\n const modes: readonly [string, unknown, (v: TPresetPermissionMode) => void][] = [\n ['permissionMode', value.permissionMode, (v) => (options.permissionMode = v)],\n [\n 'defaultPermissionMode',\n value.defaultPermissionMode,\n (v) => (options.defaultPermissionMode = v),\n ],\n ];\n for (const [field, raw, assign] of modes) {\n if (raw === undefined) {\n continue;\n }\n if (!PERMISSION_MODE_VALUES.includes(raw as TPresetPermissionMode)) {\n return `${field}: expected one of ${PERMISSION_MODE_VALUES.join(', ')}`;\n }\n assign(raw as TPresetPermissionMode);\n }\n\n return undefined;\n}\n\n/** Validate the string-array optional fields onto `options`; return the first error, if any. */\nfunction validateArrayFields(\n value: Record<string, unknown>,\n options: IResolvedPresetOptions,\n): string | undefined {\n const arrays: readonly [string, unknown, (v: readonly string[]) => void][] = [\n ['allowedTools', value.allowedTools, (v) => (options.allowedTools = v)],\n ['deniedTools', value.deniedTools, (v) => (options.deniedTools = v)],\n [\n 'enabledCommandModules',\n value.enabledCommandModules,\n (v) => (options.enabledCommandModules = v),\n ],\n [\n 'disabledCommandModules',\n value.disabledCommandModules,\n (v) => (options.disabledCommandModules = v),\n ],\n ];\n for (const [field, raw, assign] of arrays) {\n if (raw === undefined) {\n continue;\n }\n if (!isStringArray(raw)) {\n return `${field}: expected an array of strings`;\n }\n assign(raw);\n }\n return undefined;\n}\n\n/**\n * Manually validate an unknown value as an {@link IPreset} (no schema library).\n *\n * Required fields: non-empty `id`, `title`, `description` strings. Every other field is\n * optional and is validated only when present; an unrecognised field is dropped (the built\n * preset carries the recognised fields only, never unknown keys). On the first failed check\n * returns `{ ok: false, error: '<field>: <reason>' }`.\n */\nexport function validateExternalPreset(value: unknown): TPresetValidationResult {\n if (!isPlainObject(value)) {\n return { ok: false, error: 'preset: expected a non-null object' };\n }\n\n const requiredStrings: readonly ['id' | 'title' | 'description', unknown][] = [\n ['id', value.id],\n ['title', value.title],\n ['description', value.description],\n ];\n for (const [field, raw] of requiredStrings) {\n if (typeof raw !== 'string' || raw.length === 0) {\n return { ok: false, error: `${field}: expected a non-empty string` };\n }\n }\n\n // Accumulate recognised optional fields here, then spread onto the identity triple so the\n // built preset never carries unknown keys.\n const options: IResolvedPresetOptions = {};\n const error =\n validateStringFields(value, options) ??\n validateScalarFields(value, options) ??\n validateEnumFields(value, options) ??\n validateArrayFields(value, options);\n if (error !== undefined) {\n return { ok: false, error };\n }\n\n const preset: IPreset = {\n id: value.id as string,\n title: value.title as string,\n description: value.description as string,\n ...options,\n };\n return { ok: true, preset };\n}\n","import { validateExternalPreset } from './preset-validation.js';\nimport { partitionExternalPresets } from './resolve-preset.js';\n\nimport type { IPreset } from './preset-types.js';\n\n/**\n * Outcome of an external-preset load: the presets themselves, their ids, and per-file errors.\n *\n * `presets` carries the loaded values, so the caller builds its own registry over them and\n * nothing has to be looked up by id from process state.\n */\nexport interface IExternalPresetLoadResult {\n presets: readonly IPreset[];\n loaded: readonly string[];\n errors: readonly { file: string; error: string }[];\n}\n\n/** One candidate preset file, however the host found it: a directory entry, an upload, a fixture. */\nexport interface IExternalPresetFile {\n /** The file's name, as it is reported in an error (`reviewer.json`). Only `*.json` names are read. */\n readonly fileName: string;\n /** The file's text. A throw is that file's error, so a host reads lazily and a failed read is not fatal. */\n readonly read: () => string;\n}\n\n/**\n * Load and validate every `*.json` external preset among `files`.\n *\n * A name that does not end in `.json` is skipped without an error. Each file is read, JSON-parsed and\n * validated; a read, parse or validation failure is recorded as a per-file error and skipped — the\n * remaining files still load. The surviving presets go through {@link partitionExternalPresets}, whose\n * rejections (built-in id collision or duplicate id) are folded into `errors` against their file.\n *\n * Loading REGISTERS NOTHING. The result is a value the caller owns. The package reads no file itself:\n * `loadExternalPresetsFromDir` in `@robota-sdk/agent-product/preset/node` lists a directory on a Node host.\n */\nexport function loadExternalPresetsFromFiles(\n files: readonly IExternalPresetFile[],\n): IExternalPresetLoadResult {\n const errors: { file: string; error: string }[] = [];\n const validPresets: IPreset[] = [];\n // Track which file each validated preset id came from so registry rejections map back to a file.\n const fileById = new Map<string, string>();\n\n for (const file of files.filter(({ fileName }) => fileName.endsWith('.json'))) {\n const name = file.fileName;\n let parsed: unknown;\n try {\n parsed = JSON.parse(file.read());\n } catch (error) {\n // allow-fallback: a malformed file is reported per-file and skipped, not silently swallowed\n errors.push({ file: name, error: error instanceof Error ? error.message : String(error) });\n continue;\n }\n\n const result = validateExternalPreset(parsed);\n if (!result.ok) {\n errors.push({ file: name, error: result.error });\n continue;\n }\n\n validPresets.push(result.preset);\n fileById.set(result.preset.id, name);\n }\n\n const { accepted, rejected } = partitionExternalPresets(validPresets);\n for (const rejection of rejected) {\n errors.push({ file: fileById.get(rejection.id) ?? rejection.id, error: rejection.reason });\n }\n\n return { presets: accepted, loaded: accepted.map((preset) => preset.id), errors };\n}\n"],"mappings":"2FAQA,MAAa,EAAyB,CACpC,GAAI,UACJ,MAAO,UACP,YAAa,kFACf,ECkCa,EAAmC,CAC9C,GAAI,qBACJ,MAAO,qBACP,YACE,uKAEF,OAAQ,OACR,SAAU,YACV,wBAAyB,GACzB,iBAAkB,GAClB,QA9CiC,CACjC,2FACA,8FACA,iGACA,sBACA,GACA,4FACA,gGACA,0EACA,GACA,gGACA,sEACA,GACA,gGACA,8FACA,2BACA,GACA,gGACA,iGACA,6DACA,GACA,gGACA,0BACF,CAAC,CAAC,KAAK;CAuBI,CACX,ECTa,EAAiC,CAC5C,GAAI,mBACJ,MAAO,mBACP,YACE,0KAEF,OAAQ,OACR,SAAU,YACV,wBAAyB,GACzB,iBAAkB,GAClB,QA7C+B,CAC/B,8FACA,kGACA,+EACA,GACA,kGACA,yFACA,GACA,kGACA,wEACA,GACA,oGACA,mGACA,4BACA,GACA,gGACA,iGACA,4DACF,CAAC,CAAC,KAAK;CA2BI,CACX,ECjBa,EAAiC,CAC5C,GAAI,mBACJ,MAAO,mBACP,YACE,sRAGF,OA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C,QACF,CAEA,EAAa,KAAK,EAAO,MAAM,EAC/B,EAAS,IAAI,EAAO,OAAO,GAAI,CAAI,CACrC,CAEA,GAAM,CAAE,WAAU,YAAa,EAAyB,CAAY,EACpE,IAAK,IAAM,KAAa,EACtB,EAAO,KAAK,CAAE,KAAM,EAAS,IAAI,EAAU,EAAE,GAAK,EAAU,GAAI,MAAO,EAAU,MAAO,CAAC,EAG3F,MAAO,CAAE,QAAS,EAAU,OAAQ,EAAS,IAAK,GAAW,EAAO,EAAE,EAAG,QAAO,CAClF"}
@@ -0,0 +1,107 @@
1
+ import { ICreateSessionOptions } from "@robota-sdk/agent-framework";
2
+ //#region src/preset/preset-types.d.ts
3
+ /**
4
+ * Effort dial passed through to the model invocation (mechanism, not persona text).
5
+ * `'xhigh'` corresponds to the long-running ("ultra") tier; `'high'` is the neutral default.
6
+ *
7
+ * Reuses the framework's `ICreateSessionOptions['effort']` channel (which is the
8
+ * `agent-core` `TModelEffort` SSOT) so a resolved preset effort threads straight to the
9
+ * provider invocation seam without introducing a parallel union.
10
+ */
11
+ type TPresetEffort = NonNullable<ICreateSessionOptions['effort']>;
12
+ /**
13
+ * Behavioural autonomy posture. Drives the permission posture (`permissionMode`) — it is a mechanism
14
+ * mapping, not a display label.
15
+ */
16
+ type TPresetAutonomy = 'ask-first' | 'balanced' | 'act-first';
17
+ /**
18
+ * Permission mode reused from the framework option SSOT (`ICreateSessionOptions`).
19
+ * Reusing the indexed access keeps a single source of truth for the permission-mode union.
20
+ */
21
+ type TPresetPermissionMode = ICreateSessionOptions['permissionMode'];
22
+ /**
23
+ * The framework-facing option subset a preset resolves into. Every field maps to an
24
+ * existing `agent-framework` session/assembly seam; presets never introduce new option types.
25
+ */
26
+ interface IResolvedPresetOptions {
27
+ /**
28
+ * Portable persona/behaviour block (tone, refusal philosophy, output style, proactivity).
29
+ * Composed by the framework as a `source: 'persona'` system-prompt section (priority 5) —
30
+ * never runtime/tool/product-identity text. Empty/undefined adds no section (no regression).
31
+ */
32
+ persona?: string;
33
+ systemPrompt?: string;
34
+ appendSystemPrompt?: string;
35
+ agentName?: string;
36
+ model?: string;
37
+ language?: string;
38
+ effort?: TPresetEffort;
39
+ temperature?: number;
40
+ maxOutputTokens?: number;
41
+ /**
42
+ * Resolved framework permission-mode seam. The end value the assembly applies.
43
+ * Populated either directly, from `defaultPermissionMode`, or from the
44
+ * `autonomy` mapping (precedence: explicit `permissionMode` > `defaultPermissionMode`
45
+ * > `autonomy` mapping).
46
+ */
47
+ permissionMode?: TPresetPermissionMode;
48
+ /**
49
+ * Coarse permission posture declared by a preset. When set (and no explicit
50
+ * `permissionMode`), {@link resolvePreset} promotes it to `permissionMode`.
51
+ */
52
+ defaultPermissionMode?: TPresetPermissionMode;
53
+ allowedTools?: readonly string[];
54
+ deniedTools?: readonly string[];
55
+ enabledCommandModules?: readonly string[];
56
+ disabledCommandModules?: readonly string[];
57
+ enableParallelSubagents?: boolean;
58
+ selfVerification?: boolean;
59
+ autonomy?: TPresetAutonomy;
60
+ }
61
+ /**
62
+ * A named, pre-tuned bundle of framework option overrides plus display identity.
63
+ * Extends `IResolvedPresetOptions` (type SSOT) and adds the identity triple.
64
+ */
65
+ interface IPreset extends IResolvedPresetOptions {
66
+ id: string;
67
+ title: string;
68
+ description: string;
69
+ }
70
+ //#endregion
71
+ //#region src/preset/load-external-presets.d.ts
72
+ /**
73
+ * Outcome of an external-preset load: the presets themselves, their ids, and per-file errors.
74
+ *
75
+ * `presets` carries the loaded values, so the caller builds its own registry over them and
76
+ * nothing has to be looked up by id from process state.
77
+ */
78
+ interface IExternalPresetLoadResult {
79
+ presets: readonly IPreset[];
80
+ loaded: readonly string[];
81
+ errors: readonly {
82
+ file: string;
83
+ error: string;
84
+ }[];
85
+ }
86
+ /** One candidate preset file, however the host found it: a directory entry, an upload, a fixture. */
87
+ interface IExternalPresetFile {
88
+ /** The file's name, as it is reported in an error (`reviewer.json`). Only `*.json` names are read. */
89
+ readonly fileName: string;
90
+ /** The file's text. A throw is that file's error, so a host reads lazily and a failed read is not fatal. */
91
+ readonly read: () => string;
92
+ }
93
+ /**
94
+ * Load and validate every `*.json` external preset among `files`.
95
+ *
96
+ * A name that does not end in `.json` is skipped without an error. Each file is read, JSON-parsed and
97
+ * validated; a read, parse or validation failure is recorded as a per-file error and skipped — the
98
+ * remaining files still load. The surviving presets go through {@link partitionExternalPresets}, whose
99
+ * rejections (built-in id collision or duplicate id) are folded into `errors` against their file.
100
+ *
101
+ * Loading REGISTERS NOTHING. The result is a value the caller owns. The package reads no file itself:
102
+ * `loadExternalPresetsFromDir` in `@robota-sdk/agent-product/preset/node` lists a directory on a Node host.
103
+ */
104
+ declare function loadExternalPresetsFromFiles(files: readonly IExternalPresetFile[]): IExternalPresetLoadResult;
105
+ //#endregion
106
+ export { IResolvedPresetOptions as a, TPresetPermissionMode as c, IPreset as i, IExternalPresetLoadResult as n, TPresetAutonomy as o, loadExternalPresetsFromFiles as r, TPresetEffort as s, IExternalPresetFile as t };
107
+ //# sourceMappingURL=load-external-presets-DCY3HJ8d.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"load-external-presets-DCY3HJ8d.d.cts","names":[],"sources":["../src/preset/preset-types.ts","../src/preset/load-external-presets.ts"],"mappings":";;;;;;;;;;KAUY,gBAAgB,YAAY;;;;;KAM5B;;;;;KAMA,wBAAwB;;;;;UAMnB;;;;;;EAOf;EACA;EACA;EACA;EAGA;EACA;EACA,SAAS;EACT;EACA;;;;;;;EASA,iBAAiB;;;;;EAKjB,wBAAwB;EACxB;EACA;EAGA;EACA;EAGA;EACA;EAGA,WAAW;;;;;;UAOI,gBAAgB;EAC/B;EACA;EACA;;;;;;;;;;UCvEe;EACf,kBAAkB;EAClB;EACA;IAAmB;IAAc;;;;UAIlB;;WAEN;;WAEA;;;;;;;;;;;;;iBAcK,6BACd,gBAAgB,wBACf"}