@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
@@ -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.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"load-external-presets-DCY3HJ8d.d.ts","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"}
@@ -0,0 +1,4 @@
1
+ let e=require("@robota-sdk/agent-framework");const t={id:`default`,title:`Default`,description:`Neutral baseline preset — no overrides; reproduces the standard agent behaviour.`},n={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
+ `)},r={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
+ `)},i={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
+ `)},a={"ask-first":`default`,balanced:`default`,"act-first":`acceptEdits`},o=[t,n,r,i];function s(e){let t=new Set(o.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 c(e){let{id:t,title:n,description:r,...i}=e;return i}function l(e){return Object.fromEntries(Object.entries(e).filter(([,e])=>e!==void 0))}function u(e,t){if(!t)return e;let n={...e,...l(t)};return t.deniedTools!==void 0||e.deniedTools!==void 0?{...n,deniedTools:d(e.deniedTools,t.deniedTools)}:n}function d(e,t){return[...new Set([...e??[],...t??[]])]}function f(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=c(r);return i=u(i,n.cliOverrides),i=u(i,n.explicit),m(i)}function p(e=[]){let t=[...o,...s(e).accepted];return{resolvePreset:(e,n={})=>f(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 m(e){return e.permissionMode===void 0?e.defaultPermissionMode===void 0?e.autonomy===void 0?e:{...e,permissionMode:a[e.autonomy]}:{...e,permissionMode:e.defaultPermissionMode}:e}const h=[`ask-first`,`act-first`,`balanced`],g=e.VALID_PERMISSION_MODES;function _(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function v(e){return Array.isArray(e)&&e.every(e=>typeof e==`string`)}function y(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 b(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 x(t,n){if(t.effort!==void 0){if(typeof t.effort!=`string`)return`effort: expected a string`;try{let r=(0,e.parseModelEffort)(t.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(t.autonomy!==void 0){if(!h.includes(t.autonomy))return`autonomy: expected one of ${h.join(`, `)}`;n.autonomy=t.autonomy}let r=[[`permissionMode`,t.permissionMode,e=>n.permissionMode=e],[`defaultPermissionMode`,t.defaultPermissionMode,e=>n.defaultPermissionMode=e]];for(let[e,t,n]of r)if(t!==void 0){if(!g.includes(t))return`${e}: expected one of ${g.join(`, `)}`;n(t)}}function S(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(!v(t))return`${e}: expected an array of strings`;r(t)}}function C(e){if(!_(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=y(e,n)??b(e,n)??x(e,n)??S(e,n);return r===void 0?{ok:!0,preset:{id:e.id,title:e.title,description:e.description,...n}}:{ok:!1,error:r}}function w(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=C(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}=s(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}}Object.defineProperty(exports,"a",{enumerable:!0,get:function(){return n}}),Object.defineProperty(exports,"i",{enumerable:!0,get:function(){return s}}),Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return C}}),Object.defineProperty(exports,"o",{enumerable:!0,get:function(){return t}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return p}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return w}});
@@ -0,0 +1 @@
1
+ const e=require("./theme-command-module-DYJhjKuI.cjs");let t=require("@robota-sdk/agent-framework"),n=require("node:fs"),r=require("node:path"),i=require("node:os"),a=require("@robota-sdk/agent-core/node"),o=require("node:child_process"),s=require("node:net"),c=require("@robota-sdk/agent-framework/node");function l(){let e=process.env.VISUAL?.trim(),t=process.env.EDITOR?.trim(),n=(e!==void 0&&e.length>0?e:t!==void 0&&t.length>0?t:`vi`).split(/\s+/).filter(e=>e.length>0);return{command:n[0]??`vi`,args:n.slice(1)}}function u(e,t,n){return new Promise((r,a)=>{let s=(0,o.spawn)(e,[...t],{cwd:n,stdio:`inherit`,env:process.env});s.on(`error`,a),s.on(`exit`,(e,t)=>{if(e!==null){r(e);return}if(t){let e=i.constants.signals[t];r(128+(e??0));return}r(0)})})}function d(e){return(0,r.isAbsolute)(e)?(0,a.createProcessScopedDirectory)((0,r.dirname)(e),(0,r.basename)(e)):(0,n.mkdtempSync)((0,r.join)((0,i.tmpdir)(),e))}async function f(e,t,i=`agent-editor-`){if(!e.canHandoffTerminal())return{message:`An editor is unavailable here (no interactive terminal).`,success:!1};let o=l(),s=d(i),c=(0,a.removeDirectoryOnProcessExit)(s),f=(0,r.join)(s,`message.md`);try{(0,n.writeFileSync)(f,t??``,{encoding:`utf8`,mode:384});let r=await e.runWithTerminal(async()=>u(o.command,[...o.args,f],e.getCwd()));if(r!==0)return{message:`Editor exited without saving (code ${r}).`,success:!1,data:{exitCode:r}};let i=(0,n.readFileSync)(f,`utf8`).replace(/\s+$/u,``);return i.length===0?{message:`Editor closed with empty content; nothing composed.`,success:!1}:{message:i,success:!0,data:{content:i}}}finally{(0,n.rmSync)(s,{recursive:!0,force:!0,maxRetries:3,retryDelay:20}),c()}}function p(e,t){let n=l();return u(n.command,[...n.args,e],t)}function m(e){return{name:`editor`,displayName:`Editor`,description:e??"Compose a message in $EDITOR (optionally pre-filled with `/editor <text>`), then return it.",source:`editor`,modelInvocable:!1,runner:`client`,surfaces:[`terminal`]}}function h(e,t){let n=m(t);return{name:n.name,displayName:n.displayName,description:n.description,requiresPermission:!1,userInvocable:!0,modelInvocable:!1,runner:n.runner,surfaces:n.surfaces,lifecycle:`inline`,execute:(n,r)=>t===void 0?f(n,r,e):{message:t,success:!1}}}var g=class{unavailableMessage;name=`editor`;constructor(e){this.unavailableMessage=e}getCommands(){return[m(this.unavailableMessage)]}};function _(e,t){return{name:`agent-command-editor`,commandSources:[new g(t)],systemCommands:[h(e,t)]}}function v(e){let t=(0,a.resolvePlatformShell)({executable:e});return{command:t.command,interactiveArgs:t.interactiveArgs,commandArgs:e=>t.commandArgs(e)}}const y="Drop to an interactive shell (or run `/shell <command>` interactively), then return to the agent.";async function b(e,t,n){if(!e.canHandoffTerminal())return{message:`An interactive shell is unavailable here (no interactive terminal).`,success:!1};let r=v(n),i=e.getCwd(),a=t.trim(),o=await e.runWithTerminal(async()=>a.length>0?u(r.command,r.commandArgs(a),i):u(r.command,r.interactiveArgs,i));return{message:a.length>0?`Command exited (code ${o}).`:`Shell session ended (code ${o}).`,success:o===0,data:{exitCode:o}}}function x(){return{name:`shell`,displayName:`Shell`,description:y,source:`shell`,modelInvocable:!1,runner:`client`,surfaces:[`terminal`]}}function S(e){let t=x();return{name:t.name,displayName:t.displayName,description:t.description,requiresPermission:!0,userInvocable:!0,modelInvocable:!1,runner:t.runner,surfaces:t.surfaces,lifecycle:`inline`,execute:(t,n)=>b(t,n,e)}}var C=class{name=`shell`;getCommands(){return[x()]}};function w(e){return{name:`agent-command-shell`,commandSources:[new C],systemCommands:[S(e)]}}const T=3e3;function E(e,t){return new Promise(n=>{let r=Date.now(),i=(0,s.createConnection)({host:e,port:t}),a=setTimeout(()=>{i.destroy(),n({reachable:!1,error:`timeout (${T/1e3}s)`})},T);i.on(`connect`,()=>{clearTimeout(a),i.destroy(),n({reachable:!0,elapsedMs:Date.now()-r})}),i.on(`error`,e=>{clearTimeout(a),n({reachable:!1,error:e.message})})})}function D(e){if(!(0,n.existsSync)(e))return{exists:!1,isDirectory:!1,writable:!1};let t;try{t=(0,n.statSync)(e)}catch{return{exists:!0,isDirectory:!1,writable:!1}}let r=t.isDirectory(),i=t.mode&511,a=!1;try{(0,n.accessSync)(e,n.constants.W_OK),a=!0}catch{a=!1}return{exists:!0,isDirectory:r,writable:a,mode:i}}function O(e,t=process.env){let i=e.trim().split(/\s+/)[0];if(i===void 0||i.length===0)return!1;if((0,r.isAbsolute)(i)||i.includes(`/`))return(0,n.existsSync)(i);let a=process.platform===`win32`?[``,`.exe`,`.cmd`,`.bat`]:[``];return(t.PATH??``).split(r.delimiter).filter(e=>e.length>0).some(e=>a.some(t=>(0,n.existsSync)((0,r.join)(e,i+t))))}function k(e=process.env){return{probeEndpoint:E,inspectPath:D,resolveCommand:t=>O(t,e),ownerOnlyGuarantee:()=>(0,a.ownerOnlyGuarantee)(),files:new c.NodeFileSystem,ensureOwnerOnlyDirectory:(e,t)=>(0,a.ensureOwnerOnlyDirectory)(e,t),writeSettings:c.writeSettings}}function A(n){let{shellExecutable:r,editorTemporaryDirectoryPrefix:i,editorUnavailableMessage:a,keybindingsFile:o,themeCatalogue:s,enabledCommandModules:c,disabledCommandModules:l}=n,u=[[w(r),(e,t)=>b(e,t,r)],[_(i,a),(e,t)=>a===void 0?f(e,t,i):{message:a,success:!1}],[e.s(o,p),t=>e.c(o,t,p)],[e.r(s),(t,n)=>e.i(s,n)]],d=new Set((0,t.selectCommandModules)(u.map(([e])=>e),c,l));return u.filter(([e])=>d.has(e)).flatMap(([e,t])=>(e.systemCommands??[]).map(e=>({name:e.name,execute:t})))}Object.defineProperty(exports,"_",{enumerable:!0,get:function(){return l}}),Object.defineProperty(exports,"a",{enumerable:!0,get:function(){return x}}),Object.defineProperty(exports,"c",{enumerable:!0,get:function(){return b}}),Object.defineProperty(exports,"d",{enumerable:!0,get:function(){return m}}),Object.defineProperty(exports,"f",{enumerable:!0,get:function(){return _}}),Object.defineProperty(exports,"g",{enumerable:!0,get:function(){return u}}),Object.defineProperty(exports,"h",{enumerable:!0,get:function(){return f}}),Object.defineProperty(exports,"i",{enumerable:!0,get:function(){return C}}),Object.defineProperty(exports,"l",{enumerable:!0,get:function(){return v}}),Object.defineProperty(exports,"m",{enumerable:!0,get:function(){return"Compose a message in $EDITOR (optionally pre-filled with `/editor <text>`), then return it."}}),Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return k}}),Object.defineProperty(exports,"o",{enumerable:!0,get:function(){return w}}),Object.defineProperty(exports,"p",{enumerable:!0,get:function(){return p}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return O}}),Object.defineProperty(exports,"s",{enumerable:!0,get:function(){return y}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return A}}),Object.defineProperty(exports,"u",{enumerable:!0,get:function(){return g}});
@@ -0,0 +1,2 @@
1
+ import{c as e,i as t,r as n,s as r}from"./theme-command-module-GyqgVqV9.js";import{selectCommandModules as i}from"@robota-sdk/agent-framework";import{accessSync as a,constants as o,existsSync as s,mkdtempSync as c,readFileSync as l,rmSync as u,statSync as d,writeFileSync as f}from"node:fs";import{basename as p,delimiter as m,dirname as h,isAbsolute as g,join as _}from"node:path";import{constants as v,tmpdir as y}from"node:os";import{createProcessScopedDirectory as b,ensureOwnerOnlyDirectory as x,ownerOnlyGuarantee as S,removeDirectoryOnProcessExit as C,resolvePlatformShell as w}from"@robota-sdk/agent-core/node";import{spawn as T}from"node:child_process";import{createConnection as E}from"node:net";import{NodeFileSystem as D,writeSettings as O}from"@robota-sdk/agent-framework/node";function k(){let e=process.env.VISUAL?.trim(),t=process.env.EDITOR?.trim(),n=(e!==void 0&&e.length>0?e:t!==void 0&&t.length>0?t:`vi`).split(/\s+/).filter(e=>e.length>0);return{command:n[0]??`vi`,args:n.slice(1)}}function A(e,t,n){return new Promise((r,i)=>{let a=T(e,[...t],{cwd:n,stdio:`inherit`,env:process.env});a.on(`error`,i),a.on(`exit`,(e,t)=>{if(e!==null){r(e);return}if(t){let e=v.signals[t];r(128+(e??0));return}r(0)})})}const j="Compose a message in $EDITOR (optionally pre-filled with `/editor <text>`), then return it.";function M(e){return g(e)?b(h(e),p(e)):c(_(y(),e))}async function N(e,t,n=`agent-editor-`){if(!e.canHandoffTerminal())return{message:`An editor is unavailable here (no interactive terminal).`,success:!1};let r=k(),i=M(n),a=C(i),o=_(i,`message.md`);try{f(o,t??``,{encoding:`utf8`,mode:384});let n=await e.runWithTerminal(async()=>A(r.command,[...r.args,o],e.getCwd()));if(n!==0)return{message:`Editor exited without saving (code ${n}).`,success:!1,data:{exitCode:n}};let i=l(o,`utf8`).replace(/\s+$/u,``);return i.length===0?{message:`Editor closed with empty content; nothing composed.`,success:!1}:{message:i,success:!0,data:{content:i}}}finally{u(i,{recursive:!0,force:!0,maxRetries:3,retryDelay:20}),a()}}function P(e,t){let n=k();return A(n.command,[...n.args,e],t)}function F(e){return{name:`editor`,displayName:`Editor`,description:e??"Compose a message in $EDITOR (optionally pre-filled with `/editor <text>`), then return it.",source:`editor`,modelInvocable:!1,runner:`client`,surfaces:[`terminal`]}}function I(e,t){let n=F(t);return{name:n.name,displayName:n.displayName,description:n.description,requiresPermission:!1,userInvocable:!0,modelInvocable:!1,runner:n.runner,surfaces:n.surfaces,lifecycle:`inline`,execute:(n,r)=>t===void 0?N(n,r,e):{message:t,success:!1}}}var L=class{unavailableMessage;name=`editor`;constructor(e){this.unavailableMessage=e}getCommands(){return[F(this.unavailableMessage)]}};function R(e,t){return{name:`agent-command-editor`,commandSources:[new L(t)],systemCommands:[I(e,t)]}}function z(e){let t=w({executable:e});return{command:t.command,interactiveArgs:t.interactiveArgs,commandArgs:e=>t.commandArgs(e)}}const B="Drop to an interactive shell (or run `/shell <command>` interactively), then return to the agent.";async function V(e,t,n){if(!e.canHandoffTerminal())return{message:`An interactive shell is unavailable here (no interactive terminal).`,success:!1};let r=z(n),i=e.getCwd(),a=t.trim(),o=await e.runWithTerminal(async()=>a.length>0?A(r.command,r.commandArgs(a),i):A(r.command,r.interactiveArgs,i));return{message:a.length>0?`Command exited (code ${o}).`:`Shell session ended (code ${o}).`,success:o===0,data:{exitCode:o}}}function H(){return{name:`shell`,displayName:`Shell`,description:B,source:`shell`,modelInvocable:!1,runner:`client`,surfaces:[`terminal`]}}function U(e){let t=H();return{name:t.name,displayName:t.displayName,description:t.description,requiresPermission:!0,userInvocable:!0,modelInvocable:!1,runner:t.runner,surfaces:t.surfaces,lifecycle:`inline`,execute:(t,n)=>V(t,n,e)}}var W=class{name=`shell`;getCommands(){return[H()]}};function G(e){return{name:`agent-command-shell`,commandSources:[new W],systemCommands:[U(e)]}}const K=3e3;function q(e,t){return new Promise(n=>{let r=Date.now(),i=E({host:e,port:t}),a=setTimeout(()=>{i.destroy(),n({reachable:!1,error:`timeout (${K/1e3}s)`})},K);i.on(`connect`,()=>{clearTimeout(a),i.destroy(),n({reachable:!0,elapsedMs:Date.now()-r})}),i.on(`error`,e=>{clearTimeout(a),n({reachable:!1,error:e.message})})})}function J(e){if(!s(e))return{exists:!1,isDirectory:!1,writable:!1};let t;try{t=d(e)}catch{return{exists:!0,isDirectory:!1,writable:!1}}let n=t.isDirectory(),r=t.mode&511,i=!1;try{a(e,o.W_OK),i=!0}catch{i=!1}return{exists:!0,isDirectory:n,writable:i,mode:r}}function Y(e,t=process.env){let n=e.trim().split(/\s+/)[0];if(n===void 0||n.length===0)return!1;if(g(n)||n.includes(`/`))return s(n);let r=process.platform===`win32`?[``,`.exe`,`.cmd`,`.bat`]:[``];return(t.PATH??``).split(m).filter(e=>e.length>0).some(e=>r.some(t=>s(_(e,n+t))))}function X(e=process.env){return{probeEndpoint:q,inspectPath:J,resolveCommand:t=>Y(t,e),ownerOnlyGuarantee:()=>S(),files:new D,ensureOwnerOnlyDirectory:(e,t)=>x(e,t),writeSettings:O}}function Z(a){let{shellExecutable:o,editorTemporaryDirectoryPrefix:s,editorUnavailableMessage:c,keybindingsFile:l,themeCatalogue:u,enabledCommandModules:d,disabledCommandModules:f}=a,p=[[G(o),(e,t)=>V(e,t,o)],[R(s,c),(e,t)=>c===void 0?N(e,t,s):{message:c,success:!1}],[r(l,P),t=>e(l,t,P)],[n(u),(e,n)=>t(u,n)]],m=new Set(i(p.map(([e])=>e),d,f));return p.filter(([e])=>m.has(e)).flatMap(([e,t])=>(e.systemCommands??[]).map(e=>({name:e.name,execute:t})))}export{k as _,H as a,V as c,F as d,R as f,A as g,N as h,W as i,z as l,j as m,X as n,G as o,P as p,Y as r,B as s,Z as t,L as u};
2
+ //# sourceMappingURL=node-Cw2VT1HG.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"node-Cw2VT1HG.js","names":["constants"],"sources":["../src/command/editor/resolve-editor.ts","../src/command/shell/spawn-inherited.ts","../src/command/editor/editor-command.ts","../src/command/editor/open-in-editor.ts","../src/command/editor/editor-command-module.ts","../src/command/shell/resolve-shell.ts","../src/command/shell/shell-command.ts","../src/command/shell/shell-command-module.ts","../src/command/doctor/doctor-node-deps.ts","../src/command/terminal-client/terminal-client-commands.ts"],"sourcesContent":["/**\n * Editor-selection seam. Resolves `$VISUAL` → `$EDITOR` → `vi` (POSIX-first; a Windows\n * default is a separate concern). Splits on whitespace so `\"code -w\"` / `\"subl -w\"` style values work.\n */\nexport interface IResolvedEditor {\n command: string;\n args: readonly string[];\n}\n\nexport function resolveEditor(): IResolvedEditor {\n const visual = process.env.VISUAL?.trim();\n const editor = process.env.EDITOR?.trim();\n const chosen =\n visual !== undefined && visual.length > 0\n ? visual\n : editor !== undefined && editor.length > 0\n ? editor\n : 'vi';\n const parts = chosen.split(/\\s+/).filter((p) => p.length > 0);\n return { command: parts[0] ?? 'vi', args: parts.slice(1) };\n}\n","/**\n * Pure-Node spawn with the real terminal inherited (interactive input + output). Used inside a\n * terminal-handoff `runWithTerminal(fn)` — the framework/transport own the suspend/restore; this just\n * runs the child attached to the real TTY and resolves with its exit code.\n *\n * The one deliberate exception to children in their own session (`withChildSession` in\n * `@robota-sdk/agent-core/node`): the owner asked for this program to have the terminal, and it runs\n * only while the interface has given the terminal up, so never during a secret prompt.\n */\nimport { spawn } from 'node:child_process';\nimport { constants } from 'node:os';\n\nexport function spawnInherited(\n command: string,\n args: readonly string[],\n cwd: string,\n): Promise<number> {\n return new Promise<number>((resolve, reject) => {\n const child = spawn(command, [...args], { cwd, stdio: 'inherit', env: process.env });\n child.on('error', reject);\n child.on('exit', (code, signal) => {\n // A signal-terminated child reports code=null; resolving 0 there is a false\n // success. Translate to the shell convention 128 + signal number so callers see the failure.\n if (code !== null) {\n resolve(code);\n return;\n }\n if (signal) {\n const signalNumber = constants.signals[signal as keyof typeof constants.signals];\n resolve(128 + (signalNumber ?? 0));\n return;\n }\n resolve(0);\n });\n });\n}\n","/**\n * `/editor` — compose a message/prompt in `$EDITOR` via the terminal-handoff capability,\n * then return the saved text. The temp file is pre-filled with any args and removed afterward.\n *\n * The buffer is the composed message, so it is owner-only: a directory only the owner can enter,\n * holding a `0600` file. A relative prefix puts that directory under the operating-system temporary\n * directory; an absolute prefix names a host-owned location instead (`<directory>/<name prefix>`), which\n * a host that keeps no conversation content in shared directories supplies.\n */\nimport { mkdtempSync, readFileSync, rmSync, writeFileSync } from 'node:fs';\nimport { tmpdir } from 'node:os';\nimport { basename, dirname, isAbsolute, join } from 'node:path';\n\nimport {\n createProcessScopedDirectory,\n removeDirectoryOnProcessExit,\n} from '@robota-sdk/agent-core/node';\n\nimport { resolveEditor } from './resolve-editor.js';\nimport { spawnInherited } from '../shell/spawn-inherited.js';\n\nimport type {\n ICommandHostTerminalHandoff,\n ICommandHostWorkspace,\n} from '@robota-sdk/agent-framework';\nimport type { ICommandResult } from '@robota-sdk/agent-interface/command';\n\nexport const EDITOR_COMMAND_DESCRIPTION =\n 'Compose a message in $EDITOR (optionally pre-filled with `/editor <text>`), then return it.';\nexport const DEFAULT_EDITOR_TEMPORARY_DIRECTORY_PREFIX = 'agent-editor-';\n\nfunction createEditorDirectory(prefix: string): string {\n if (isAbsolute(prefix)) return createProcessScopedDirectory(dirname(prefix), basename(prefix));\n return mkdtempSync(join(tmpdir(), prefix));\n}\n\nexport async function executeEditorCommand(\n context: ICommandHostTerminalHandoff & ICommandHostWorkspace,\n args: string,\n temporaryDirectoryPrefix: string = DEFAULT_EDITOR_TEMPORARY_DIRECTORY_PREFIX,\n): Promise<ICommandResult> {\n if (!context.canHandoffTerminal()) {\n return {\n message: 'An editor is unavailable here (no interactive terminal).',\n success: false,\n };\n }\n\n const editor = resolveEditor();\n const dir = createEditorDirectory(temporaryDirectoryPrefix);\n // A hangup or interrupt while the editor is open ends the process without reaching `finally`.\n const cancelExitRemoval = removeDirectoryOnProcessExit(dir);\n const file = join(dir, 'message.md');\n\n try {\n writeFileSync(file, args ?? '', { encoding: 'utf8', mode: 0o600 });\n const exitCode = await context.runWithTerminal(async () =>\n spawnInherited(editor.command, [...editor.args, file], context.getCwd()),\n );\n if (exitCode !== 0) {\n return {\n message: `Editor exited without saving (code ${exitCode}).`,\n success: false,\n data: { exitCode },\n };\n }\n const content = readFileSync(file, 'utf8').replace(/\\s+$/u, '');\n if (content.length === 0) {\n return { message: 'Editor closed with empty content; nothing composed.', success: false };\n }\n return { message: content, success: true, data: { content } };\n } finally {\n rmSync(dir, { recursive: true, force: true, maxRetries: 3, retryDelay: 20 });\n cancelExitRemoval();\n }\n}\n","/**\n * Opens a file in the user's editor on the real terminal: `$VISUAL`, then `$EDITOR`, then `vi`, spawned\n * with the terminal inherited and resolving with the editor's exit code. The Node host's\n * `TOpenFileInEditor`; `/keybindings` takes it by injection.\n */\nimport { spawnInherited } from '../shell/spawn-inherited.js';\n\nimport { resolveEditor } from './resolve-editor.js';\n\nexport function openFileInEditor(path: string, cwd: string): Promise<number> {\n const editor = resolveEditor();\n return spawnInherited(editor.command, [...editor.args, path], cwd);\n}\n","/**\n * `/editor` command module — a framework-level consumer of the terminal-handoff capability.\n */\nimport { EDITOR_COMMAND_DESCRIPTION, executeEditorCommand } from './editor-command.js';\n\nimport type { ICommandModule, ISystemCommand } from '@robota-sdk/agent-framework';\nimport type { ICommand, ICommandSource } from '@robota-sdk/agent-interface/command';\n\nexport function createEditorCommandEntry(unavailableMessage?: string): ICommand {\n return {\n name: 'editor',\n displayName: 'Editor',\n description: unavailableMessage ?? EDITOR_COMMAND_DESCRIPTION,\n source: 'editor',\n // User-only: opens the user's terminal editor; UI-only.\n modelInvocable: false,\n // It takes over the terminal the user sits at, so that terminal runs it, even when attached.\n runner: 'client',\n surfaces: ['terminal'],\n };\n}\n\nfunction createEditorSystemCommand(\n temporaryDirectoryPrefix?: string,\n unavailableMessage?: string,\n): ISystemCommand {\n const entry = createEditorCommandEntry(unavailableMessage);\n return {\n name: entry.name,\n displayName: entry.displayName,\n description: entry.description,\n requiresPermission: false,\n userInvocable: true,\n modelInvocable: false,\n runner: entry.runner,\n surfaces: entry.surfaces,\n lifecycle: 'inline',\n execute: (context, args) =>\n unavailableMessage === undefined\n ? executeEditorCommand(context, args, temporaryDirectoryPrefix)\n : { message: unavailableMessage, success: false },\n };\n}\n\nexport class EditorCommandSource implements ICommandSource {\n readonly name = 'editor';\n\n constructor(private readonly unavailableMessage?: string) {}\n\n getCommands(): ICommand[] {\n return [createEditorCommandEntry(this.unavailableMessage)];\n }\n}\n\nexport function createEditorCommandModule(\n temporaryDirectoryPrefix?: string,\n unavailableMessage?: string,\n): ICommandModule {\n return {\n name: 'agent-command-editor',\n commandSources: [new EditorCommandSource(unavailableMessage)],\n systemCommands: [createEditorSystemCommand(temporaryDirectoryPrefix, unavailableMessage)],\n };\n}\n","/**\n * Shell-selection seam, now backed by the cross-platform SSOT resolver in agent-core.\n * Keep all shell choice behind this function so the call sites never change; the\n * per-platform logic (POSIX `$SHELL`/`sh`, Windows PowerShell) lives once in `resolvePlatformShell`.\n */\nimport { resolvePlatformShell } from '@robota-sdk/agent-core/node';\n\nexport interface IResolvedShell {\n /** Executable to spawn. */\n command: string;\n /** Args for an interactive shell session (drop-to-shell). */\n interactiveArgs: readonly string[];\n /** Args to run a single command string non-interactively. */\n commandArgs(command: string): readonly string[];\n}\n\n/** Resolve the interactive shell for the current platform via the agent-core SSOT resolver. */\nexport function resolveShell(executable?: string): IResolvedShell {\n const shell = resolvePlatformShell({ executable });\n return {\n command: shell.command,\n interactiveArgs: shell.interactiveArgs,\n commandArgs: (cmd: string) => shell.commandArgs(cmd),\n };\n}\n","/**\n * `/shell` — hand the real terminal to an interactive subshell (or run a single command\n * interactively), then return to the agent session. Uses the framework terminal-handoff capability;\n * the shell choice goes through the `resolveShell()` seam (macOS/Linux first).\n */\nimport { resolveShell } from './resolve-shell.js';\nimport { spawnInherited } from './spawn-inherited.js';\n\nimport type {\n ICommandHostTerminalHandoff,\n ICommandHostWorkspace,\n} from '@robota-sdk/agent-framework';\nimport type { ICommandResult } from '@robota-sdk/agent-interface/command';\n\nexport const SHELL_COMMAND_DESCRIPTION =\n 'Drop to an interactive shell (or run `/shell <command>` interactively), then return to the agent.';\n\nexport async function executeShellCommand(\n context: ICommandHostTerminalHandoff & ICommandHostWorkspace,\n args: string,\n executable?: string,\n): Promise<ICommandResult> {\n if (!context.canHandoffTerminal()) {\n return {\n message: 'An interactive shell is unavailable here (no interactive terminal).',\n success: false,\n };\n }\n\n const shell = resolveShell(executable);\n const cwd = context.getCwd();\n const command = args.trim();\n\n const exitCode = await context.runWithTerminal(async () =>\n command.length > 0\n ? spawnInherited(shell.command, shell.commandArgs(command), cwd)\n : spawnInherited(shell.command, shell.interactiveArgs, cwd),\n );\n\n return {\n message:\n command.length > 0\n ? `Command exited (code ${exitCode}).`\n : `Shell session ended (code ${exitCode}).`,\n success: exitCode === 0,\n data: { exitCode },\n };\n}\n","/**\n * `/shell` command module — a framework-level consumer of the terminal-handoff capability.\n */\nimport { executeShellCommand, SHELL_COMMAND_DESCRIPTION } from './shell-command.js';\n\nimport type { ICommandModule, ISystemCommand } from '@robota-sdk/agent-framework';\nimport type { ICommand, ICommandSource } from '@robota-sdk/agent-interface/command';\n\nexport function createShellCommandEntry(): ICommand {\n return {\n name: 'shell',\n displayName: 'Shell',\n description: SHELL_COMMAND_DESCRIPTION,\n source: 'shell',\n // User-only: the user's own shell passthrough; the model has its permission-gated shell tool.\n modelInvocable: false,\n // It takes over the terminal the user sits at, so that terminal runs it, even when attached.\n runner: 'client',\n surfaces: ['terminal'],\n };\n}\n\nfunction createShellSystemCommand(executable?: string): ISystemCommand {\n const entry = createShellCommandEntry();\n return {\n name: entry.name,\n displayName: entry.displayName,\n description: entry.description,\n requiresPermission: true,\n userInvocable: true,\n modelInvocable: false,\n runner: entry.runner,\n surfaces: entry.surfaces,\n lifecycle: 'inline',\n execute: (context, args) => executeShellCommand(context, args, executable),\n };\n}\n\nexport class ShellCommandSource implements ICommandSource {\n readonly name = 'shell';\n\n getCommands(): ICommand[] {\n return [createShellCommandEntry()];\n }\n}\n\nexport function createShellCommandModule(executable?: string): ICommandModule {\n return {\n name: 'agent-command-shell',\n commandSources: [new ShellCommandSource()],\n systemCommands: [createShellSystemCommand(executable)],\n };\n}\n","/**\n * The Node host's {@link IDoctorDeps}: a TCP connect probe, read-only filesystem facts, `PATH`\n * resolution, and the two writers a confirmed repair uses.\n */\nimport { accessSync, constants, existsSync, statSync, type Stats } from 'node:fs';\nimport { createConnection } from 'node:net';\nimport { delimiter, isAbsolute, join } from 'node:path';\n\nimport { ensureOwnerOnlyDirectory, ownerOnlyGuarantee } from '@robota-sdk/agent-core/node';\nimport { NodeFileSystem, writeSettings } from '@robota-sdk/agent-framework/node';\n\nimport type { IDoctorDeps, IDoctorEndpointProbeResult, IDoctorPathFacts } from './doctor-types.js';\n\nconst NETWORK_CHECK_TIMEOUT_MS = 3000;\nconst MS_PER_SECOND = 1000;\nconst MODE_BITS = 0o777;\n\n/** TCP connect with a bounded timeout; a refusal or a timeout is a result, never a throw. */\nexport function probeEndpointViaSocket(\n host: string,\n port: number,\n): Promise<IDoctorEndpointProbeResult> {\n return new Promise((resolve) => {\n const start = Date.now();\n const socket = createConnection({ host, port });\n const timeout = setTimeout(() => {\n socket.destroy();\n resolve({\n reachable: false,\n error: `timeout (${NETWORK_CHECK_TIMEOUT_MS / MS_PER_SECOND}s)`,\n });\n }, NETWORK_CHECK_TIMEOUT_MS);\n socket.on('connect', () => {\n clearTimeout(timeout);\n socket.destroy();\n resolve({ reachable: true, elapsedMs: Date.now() - start });\n });\n socket.on('error', (error) => {\n clearTimeout(timeout);\n resolve({ reachable: false, error: error.message });\n });\n });\n}\n\n/** Existence, directory-ness, `W_OK` and mode — probed without writing. */\nexport function inspectPathFacts(path: string): IDoctorPathFacts {\n if (!existsSync(path)) return { exists: false, isDirectory: false, writable: false };\n let stat: Stats;\n try {\n stat = statSync(path);\n } catch {\n // allow-fallback: a path that exists but cannot be stat'ed is reported as not a writable directory\n return { exists: true, isDirectory: false, writable: false };\n }\n const isDirectory = stat.isDirectory();\n const mode = stat.mode & MODE_BITS;\n let writable = false;\n try {\n accessSync(path, constants.W_OK);\n writable = true;\n } catch {\n // allow-fallback: W_OK refused IS the fact being reported\n writable = false;\n }\n return { exists: true, isDirectory, writable, mode };\n}\n\n/** A bare command resolves through `PATH`; a path-form command must exist as given. */\nexport function resolveCommandOnPath(\n command: string,\n env: Readonly<Record<string, string | undefined>> = process.env,\n): boolean {\n const executable = command.trim().split(/\\s+/)[0];\n if (executable === undefined || executable.length === 0) return false;\n if (isAbsolute(executable) || executable.includes('/')) return existsSync(executable);\n const extensions = process.platform === 'win32' ? ['', '.exe', '.cmd', '.bat'] : [''];\n return (env.PATH ?? '')\n .split(delimiter)\n .filter((dir) => dir.length > 0)\n .some((dir) => extensions.some((ext) => existsSync(join(dir, executable + ext))));\n}\n\nexport function createNodeDoctorDeps(\n env: Readonly<Record<string, string | undefined>> = process.env,\n): IDoctorDeps {\n return {\n probeEndpoint: probeEndpointViaSocket,\n inspectPath: inspectPathFacts,\n resolveCommand: (command) => resolveCommandOnPath(command, env),\n ownerOnlyGuarantee: () => ownerOnlyGuarantee(),\n files: new NodeFileSystem(),\n ensureOwnerOnlyDirectory: (directory, options) => ensureOwnerOnlyDirectory(directory, options),\n writeSettings,\n };\n}\n","/**\n * The commands that belong to the terminal the user sits at — the ones a product's assembly\n * marks `runner: 'client'`. They start the terminal's own processes, so they are on the Node entry. A terminal attached to a workspace daemon runs these in its own process,\n * on its own terminal and working directory, and sends nothing to the daemon.\n *\n * Each one is the in-process command's own execute function, so an attached terminal answers exactly\n * as a standalone one does; only where it runs changes.\n */\nimport { selectCommandModules } from '@robota-sdk/agent-framework';\n\nimport { createEditorCommandModule } from '../editor/editor-command-module.js';\nimport { executeEditorCommand } from '../editor/editor-command.js';\nimport { openFileInEditor } from '../editor/open-in-editor.js';\nimport {\n createKeybindingsCommandModule,\n executeKeybindingsCommand,\n} from '../keybindings/keybindings-command-module.js';\nimport { createShellCommandModule } from '../shell/shell-command-module.js';\nimport { executeShellCommand } from '../shell/shell-command.js';\nimport { createThemeCommandModule, executeThemeCommand } from '../theme/theme-command-module.js';\n\nimport type { IKeybindingsFilePort } from '../keybindings/keybindings-command-module.js';\nimport type {\n ICommandHostTerminalHandoff,\n ICommandHostWorkspace,\n ICommandModule,\n} from '@robota-sdk/agent-framework';\nimport type { ICommandResult, IThemeCataloguePort } from '@robota-sdk/agent-interface/command';\n\n/** A command the terminal runs itself, with the terminal's own handoff and working directory. */\nexport interface ITerminalClientCommand {\n readonly name: string;\n execute(\n host: ICommandHostTerminalHandoff & ICommandHostWorkspace,\n args: string,\n ): ICommandResult | Promise<ICommandResult>;\n}\n\n/** The terminal's own capabilities — the same ones its in-process command modules are given. */\nexport interface ITerminalClientCommandOptions {\n /** The shell `/shell` runs; absent → the platform shell, as for the in-process command. */\n readonly shellExecutable?: string;\n /** Product-owned prefix for `/editor`'s temporary directory; absent → the command's default. */\n readonly editorTemporaryDirectoryPrefix?: string;\n /** Refusal returned before any editor process or temporary file is created. */\n readonly editorUnavailableMessage?: string;\n /** Absent → `/keybindings` answers where key bindings live, as the in-process command does. */\n readonly keybindingsFile?: IKeybindingsFilePort;\n /** Absent → `/theme` answers where themes live, as the in-process command does. */\n readonly themeCatalogue?: IThemeCataloguePort;\n /**\n * The same module selection the default assembly is given (`agent-command-shell`, …): a module it\n * leaves out is left out here too, so an attached terminal offers no command a standalone one\n * would not. Absent → every client-run module.\n */\n readonly enabledCommandModules?: readonly string[];\n /** Applied after `enabledCommandModules`, as in the default assembly (deny > allow). */\n readonly disabledCommandModules?: readonly string[];\n}\n\ntype TClientExecute = ITerminalClientCommand['execute'];\n\n/**\n * Every client-run command the module selection keeps, whether or not its port is given. The set\n * shrinks only with the selection, never with a missing port: the attached terminal routes by it, so\n * a selected command left out would run on the daemon instead — and without its port the command\n * still answers as its in-process twin does.\n */\nexport function createTerminalClientCommands(\n options: ITerminalClientCommandOptions,\n): readonly ITerminalClientCommand[] {\n const {\n shellExecutable,\n editorTemporaryDirectoryPrefix,\n editorUnavailableMessage,\n keybindingsFile,\n themeCatalogue,\n enabledCommandModules,\n disabledCommandModules,\n } = options;\n // Each client command is paired with its in-process module, so selection matches by the module's\n // own name and the command keeps that module's command name.\n const candidates: ReadonlyArray<readonly [ICommandModule, TClientExecute]> = [\n [\n createShellCommandModule(shellExecutable),\n (host, args) => executeShellCommand(host, args, shellExecutable),\n ],\n [\n createEditorCommandModule(editorTemporaryDirectoryPrefix, editorUnavailableMessage),\n (host, args) =>\n editorUnavailableMessage === undefined\n ? executeEditorCommand(host, args, editorTemporaryDirectoryPrefix)\n : { message: editorUnavailableMessage, success: false },\n ],\n [\n createKeybindingsCommandModule(keybindingsFile, openFileInEditor),\n (host) => executeKeybindingsCommand(keybindingsFile, host, openFileInEditor),\n ],\n [\n createThemeCommandModule(themeCatalogue),\n (_host, args) => executeThemeCommand(themeCatalogue, args),\n ],\n ];\n const selected = new Set(\n selectCommandModules(\n candidates.map(([module]) => module),\n enabledCommandModules,\n disabledCommandModules,\n ),\n );\n return candidates\n .filter(([module]) => selected.has(module))\n .flatMap(([module, execute]) =>\n (module.systemCommands ?? []).map((command) => ({ name: command.name, execute })),\n );\n}\n"],"mappings":"uxBASA,SAAgB,GAAiC,CAC/C,IAAM,EAAS,QAAQ,IAAI,QAAQ,KAAK,EAClC,EAAS,QAAQ,IAAI,QAAQ,KAAK,EAOlC,GALJ,IAAW,IAAA,IAAa,EAAO,OAAS,EACpC,EACA,IAAW,IAAA,IAAa,EAAO,OAAS,EACtC,EACA,KAAA,CACa,MAAM,KAAK,CAAC,CAAC,OAAQ,GAAM,EAAE,OAAS,CAAC,EAC5D,MAAO,CAAE,QAAS,EAAM,IAAM,KAAM,KAAM,EAAM,MAAM,CAAC,CAAE,CAC3D,CCRA,SA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@
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../load-external-presets-DyoUUA3V.cjs"),t=require("../preset-tH5pgRIC.cjs");exports.autonomousBuilderPreset=e.a,exports.builtInOutputStyles=t.i,exports.createOutputStyleRegistry=t.t,exports.createPresetRegistry=e.r,exports.defaultPreset=e.o,exports.loadExternalPresetsFromFiles=e.t,exports.loadOutputStylesFromSources=t.n,exports.parseOutputStyleFile=t.r,exports.partitionExternalPresets=e.i,exports.validateExternalPreset=e.n;
@@ -0,0 +1,3 @@
1
+ import { a as IResolvedPresetOptions, c as TPresetPermissionMode, i as IPreset, n as IExternalPresetLoadResult, o as TPresetAutonomy, r as loadExternalPresetsFromFiles, s as TPresetEffort, t as IExternalPresetFile } from "../load-external-presets-DCY3HJ8d.cjs";
2
+ import { S as TOutputStyleTokenCost, _ as IOutputStyleLoadResult, a as TPresetValidationResult, b as IOutputStyleSummary, c as IPresetRegistry, d as createPresetRegistry, f as partitionExternalPresets, g as IOutputStyleFile, h as IOutputStyle, i as builtInOutputStyles, l as IPresetSummary, m as defaultPreset, n as loadOutputStylesFromSources, o as validateExternalPreset, p as autonomousBuilderPreset, r as parseOutputStyleFile, s as IPresetRegistrationResult, t as createOutputStyleRegistry, u as IResolvePresetContext, v as IOutputStyleRegistry, x as TOutputStyleSource, y as IOutputStyleSource } from "../index-Cz8aDRO3.cjs";
3
+ export { type IExternalPresetFile, type IExternalPresetLoadResult, type IOutputStyle, type IOutputStyleFile, type IOutputStyleLoadResult, type IOutputStyleRegistry, type IOutputStyleSource, type IOutputStyleSummary, type IPreset, type IPresetRegistrationResult, type IPresetRegistry, type IPresetSummary, type IResolvePresetContext, type IResolvedPresetOptions, type TOutputStyleSource, type TOutputStyleTokenCost, type TPresetAutonomy, type TPresetEffort, type TPresetPermissionMode, type TPresetValidationResult, autonomousBuilderPreset, builtInOutputStyles, createOutputStyleRegistry, createPresetRegistry, defaultPreset, loadExternalPresetsFromFiles, loadOutputStylesFromSources, parseOutputStyleFile, partitionExternalPresets, validateExternalPreset };
@@ -0,0 +1,3 @@
1
+ import { a as IResolvedPresetOptions, c as TPresetPermissionMode, i as IPreset, n as IExternalPresetLoadResult, o as TPresetAutonomy, r as loadExternalPresetsFromFiles, s as TPresetEffort, t as IExternalPresetFile } from "../load-external-presets-DCY3HJ8d.js";
2
+ import { S as TOutputStyleTokenCost, _ as IOutputStyleLoadResult, a as TPresetValidationResult, b as IOutputStyleSummary, c as IPresetRegistry, d as createPresetRegistry, f as partitionExternalPresets, g as IOutputStyleFile, h as IOutputStyle, i as builtInOutputStyles, l as IPresetSummary, m as defaultPreset, n as loadOutputStylesFromSources, o as validateExternalPreset, p as autonomousBuilderPreset, r as parseOutputStyleFile, s as IPresetRegistrationResult, t as createOutputStyleRegistry, u as IResolvePresetContext, v as IOutputStyleRegistry, x as TOutputStyleSource, y as IOutputStyleSource } from "../index-jksIH551.js";
3
+ export { type IExternalPresetFile, type IExternalPresetLoadResult, type IOutputStyle, type IOutputStyleFile, type IOutputStyleLoadResult, type IOutputStyleRegistry, type IOutputStyleSource, type IOutputStyleSummary, type IPreset, type IPresetRegistrationResult, type IPresetRegistry, type IPresetSummary, type IResolvePresetContext, type IResolvedPresetOptions, type TOutputStyleSource, type TOutputStyleTokenCost, type TPresetAutonomy, type TPresetEffort, type TPresetPermissionMode, type TPresetValidationResult, autonomousBuilderPreset, builtInOutputStyles, createOutputStyleRegistry, createPresetRegistry, defaultPreset, loadExternalPresetsFromFiles, loadOutputStylesFromSources, parseOutputStyleFile, partitionExternalPresets, validateExternalPreset };
@@ -0,0 +1 @@
1
+ import{a as e,i as t,n,o as r,r as i,t as a}from"../load-external-presets-CJeFbxNF.js";import{i as o,n as s,r as c,t as l}from"../preset-nuw37AF-.js";export{e as autonomousBuilderPreset,o as builtInOutputStyles,l as createOutputStyleRegistry,i as createPresetRegistry,r as defaultPreset,a as loadExternalPresetsFromFiles,s as loadOutputStylesFromSources,c as parseOutputStyleFile,t as partitionExternalPresets,n as validateExternalPreset};
@@ -0,0 +1 @@
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../load-external-presets-DyoUUA3V.cjs");let t=require("node:fs"),n=require("node:path");function r(r){return(0,t.existsSync)(r)?e.t((0,t.readdirSync)(r).map(e=>({fileName:e,read:()=>(0,t.readFileSync)((0,n.join)(r,e),`utf8`)}))):{presets:[],loaded:[],errors:[]}}exports.loadExternalPresetsFromDir=r;
@@ -0,0 +1,13 @@
1
+ import { n as IExternalPresetLoadResult } from "../load-external-presets-DCY3HJ8d.cjs";
2
+ //#region src/preset/node-load-external-presets.d.ts
3
+ /**
4
+ * Load and validate every `*.json` external preset from `dir` on the Node host's file system.
5
+ *
6
+ * A missing directory yields an empty result (no error). Every other rule — per-file errors, the
7
+ * built-in id collision, duplicate ids, registering nothing — is that of
8
+ * {@link loadExternalPresetsFromFiles}, which this lists the directory for.
9
+ */
10
+ declare function loadExternalPresetsFromDir(dir: string): IExternalPresetLoadResult;
11
+ //#endregion
12
+ export { loadExternalPresetsFromDir };
13
+ //# sourceMappingURL=node.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"node.d.cts","names":[],"sources":["../../src/preset/node-load-external-presets.ts"],"mappings":";;;;;;;;;iBAcgB,2BAA2B,cAAc"}
@@ -0,0 +1,13 @@
1
+ import { n as IExternalPresetLoadResult } from "../load-external-presets-DCY3HJ8d.js";
2
+ //#region src/preset/node-load-external-presets.d.ts
3
+ /**
4
+ * Load and validate every `*.json` external preset from `dir` on the Node host's file system.
5
+ *
6
+ * A missing directory yields an empty result (no error). Every other rule — per-file errors, the
7
+ * built-in id collision, duplicate ids, registering nothing — is that of
8
+ * {@link loadExternalPresetsFromFiles}, which this lists the directory for.
9
+ */
10
+ declare function loadExternalPresetsFromDir(dir: string): IExternalPresetLoadResult;
11
+ //#endregion
12
+ export { loadExternalPresetsFromDir };
13
+ //# sourceMappingURL=node.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"node.d.ts","names":[],"sources":["../../src/preset/node-load-external-presets.ts"],"mappings":";;;;;;;;;iBAcgB,2BAA2B,cAAc"}
@@ -0,0 +1,2 @@
1
+ import{t as e}from"../load-external-presets-CJeFbxNF.js";import{existsSync as t,readFileSync as n,readdirSync as r}from"node:fs";import{join as i}from"node:path";function a(a){return t(a)?e(r(a).map(e=>({fileName:e,read:()=>n(i(a,e),`utf8`)}))):{presets:[],loaded:[],errors:[]}}export{a as loadExternalPresetsFromDir};
2
+ //# sourceMappingURL=node.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"node.js","names":[],"sources":["../../src/preset/node-load-external-presets.ts"],"sourcesContent":["import { existsSync, readdirSync, readFileSync } from 'node:fs';\nimport { join } from 'node:path';\n\nimport { loadExternalPresetsFromFiles } from './load-external-presets.js';\n\nimport type { IExternalPresetLoadResult } from './load-external-presets.js';\n\n/**\n * Load and validate every `*.json` external preset from `dir` on the Node host's file system.\n *\n * A missing directory yields an empty result (no error). Every other rule — per-file errors, the\n * built-in id collision, duplicate ids, registering nothing — is that of\n * {@link loadExternalPresetsFromFiles}, which this lists the directory for.\n */\nexport function loadExternalPresetsFromDir(dir: string): IExternalPresetLoadResult {\n if (!existsSync(dir)) {\n return { presets: [], loaded: [], errors: [] };\n }\n return loadExternalPresetsFromFiles(\n readdirSync(dir).map((fileName) => ({\n fileName,\n read: () => readFileSync(join(dir, fileName), 'utf8'),\n })),\n );\n}\n"],"mappings":"kKAcA,SAAgB,EAA2B,EAAwC,CAIjF,OAHK,EAAW,CAAG,EAGZ,EACL,EAAY,CAAG,CAAC,CAAC,IAAK,IAAc,CAClC,WACA,SAAY,EAAa,EAAK,EAAK,CAAQ,EAAG,MAAM,CACtD,EAAE,CACJ,EAPS,CAAE,QAAS,CAAC,EAAG,OAAQ,CAAC,EAAG,OAAQ,CAAC,CAAE,CAQjD"}
@@ -0,0 +1,4 @@
1
+ import"./load-external-presets-CJeFbxNF.js";const e=[{id:`default`,name:`Default`,description:`The ordinary response style.`,instructions:``,keepCodingInstructions:!0,tokenCost:`baseline`,source:`built-in`},{id:`concise`,name:`Concise`,description:`Lead with the result and keep routine responses short.`,instructions:`Lead with the answer and skip routine preamble or tool narration. Keep responses concise while doing the same engineering work. Expand fully when asked for detail. Always keep error reports, security warnings and destructive-action confirmations complete.`,keepCodingInstructions:!0,tokenCost:`low`,source:`built-in`},{id:`proactive`,name:`Proactive`,description:`Take the next reasonable step without pausing on routine choices.`,instructions:`Act on reasonable routine assumptions and take the next useful step. State assumptions when they matter. The active permission mode remains authoritative; this style never grants, changes, or bypasses permission.`,keepCodingInstructions:!0,tokenCost:`medium`,source:`built-in`},{id:`explanatory`,name:`Explanatory`,description:`Teach the reasoning and trade-offs behind the answer.`,instructions:`Explain the reasoning, important trade-offs, and relevant terminology as you work. Keep the explanation connected to the requested outcome and do not omit complete error, security, or destructive-action guidance.`,keepCodingInstructions:!0,tokenCost:`high`,source:`built-in`},{id:`learning`,name:`Learning`,description:`Teach by marking useful gaps for the human to fill.`,instructions:`Teach the requested subject step by step. Mark a small number of useful gaps with [Your turn:] and invite the human to fill them before revealing the explanation. Never turn safety, security, error, or destructive-action guidance into a gap.`,keepCodingInstructions:!0,tokenCost:`high`,source:`built-in`}],t=new Set([`baseline`,`low`,`medium`,`high`,`unspecified`]);function n(e){return e.replace(/^(?:"([\s\S]*)"|'([\s\S]*)')$/,`$1$2`)}function r(e,t){if(t===`true`)return!0;if(t===`false`)return!1;throw Error(`${e}: expected boolean, received "${t}"`)}function i(e,t){let r=t.split(`
2
+ `);if(r[0]?.trim()!==`---`)throw Error(`frontmatter: expected an opening --- marker`);let i={},a=-1;for(let e=1;e<r.length;e+=1){let t=r[e];if(t.trim()===`---`){a=e;break}if(t.trim()===``)continue;let o=/^([a-z][a-z0-9-]*):\s*(\S[^\n\r\u2028\u2029]*)?$/.exec(t);if(!o)throw Error(`frontmatter: invalid entry at line ${e+1}`);let s=o[1];if(i[s]!==void 0)throw Error(`frontmatter.${s}: duplicate field`);i[s]=n((o[2]??``).trim())}if(a<0)throw Error(`frontmatter: expected a closing --- marker`);let o=Object.keys(i).filter(e=>![`name`,`description`,`keep-coding-instructions`,`token-cost`].includes(e));if(o.length>0)throw Error(`frontmatter.${o[0]}: unknown field`);return{values:i,instructions:r.slice(a+1).join(`
3
+ `).trim()}}function a(e){let t=e.slice(Math.max(e.lastIndexOf(`/`),e.lastIndexOf(`\\`))+1),n=t.lastIndexOf(`.`);return n>0?t.slice(0,n):t}function o(e){let t=a(e).trim();if(!/^[a-z0-9][a-z0-9-]*$/i.test(t))throw Error(`id: expected the Markdown filename stem to be a slug, received "${t}"`);return t.toLowerCase()}function s(e,n){if(!e.fileName.endsWith(`.md`))throw Error(`file: expected a .md output-style file`);let s=o(e.fileName),c=i(e.fileName,e.content),l=c.values.name?.trim()||a(e.fileName),u=c.values.description?.trim()||`Custom output style: ${l}`,d=c.values[`keep-coding-instructions`]!==void 0&&r(`frontmatter.keep-coding-instructions`,c.values[`keep-coding-instructions`]),f=c.values[`token-cost`]??`unspecified`;if(!t.has(f))throw Error(`frontmatter.token-cost: expected baseline|low|medium|high|unspecified, received "${f}"`);if(c.instructions.length===0)throw Error(`body: expected non-empty style instructions`);return{id:s,name:l,description:u,instructions:c.instructions,keepCodingInstructions:d,tokenCost:f,source:n}}function c(e){return{id:e.id,name:e.name,description:e.description,tokenCost:e.tokenCost,source:e.source}}function l(t){let n=new Map,r=[];for(let t of e)n.set(t.id,t);let i=[...t].sort((e,t)=>e.precedence-t.precedence);for(let e of i){let t=new Set;for(let i of[...e.files].sort((e,t)=>e.fileName.localeCompare(t.fileName))){let a=`${e.displayName}/${i.fileName}`,o;try{o=s(i,e.scope)}catch(e){r.push({file:a,error:e instanceof Error?e.message:String(e)});continue}if(t.has(o.id)){r.push({file:a,error:`duplicate style id "${o.id}" in source`});continue}if(t.add(o.id),n.get(o.id)?.source===`built-in`){r.push({file:a,error:`style id "${o.id}" collides with a built-in`});continue}n.set(o.id,o)}}return{styles:[...n.values()],loaded:[...n.values()].filter(e=>e.source!==`built-in`).map(e=>e.id),errors:r}}function u(e=[]){let t=l(e),n=new Map(t.styles.map(e=>[e.id,e]));return{listOutputStyles:()=>t.styles.map(c),getOutputStyle:e=>n.get(e)}}export{e as i,l as n,s as r,u as t};
4
+ //# sourceMappingURL=preset-nuw37AF-.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"preset-nuw37AF-.js","names":[],"sources":["../src/preset/output-styles.ts","../src/preset/output-style-registry.ts"],"sourcesContent":["import type { IOutputStyle } from './output-style-types.js';\n\nconst DEFAULT_INSTRUCTIONS = '';\n\nexport const builtInOutputStyles: readonly IOutputStyle[] = [\n {\n id: 'default',\n name: 'Default',\n description: 'The ordinary response style.',\n instructions: DEFAULT_INSTRUCTIONS,\n keepCodingInstructions: true,\n tokenCost: 'baseline',\n source: 'built-in',\n },\n {\n id: 'concise',\n name: 'Concise',\n description: 'Lead with the result and keep routine responses short.',\n instructions:\n 'Lead with the answer and skip routine preamble or tool narration. Keep responses concise while doing the same engineering work. Expand fully when asked for detail. Always keep error reports, security warnings and destructive-action confirmations complete.',\n keepCodingInstructions: true,\n tokenCost: 'low',\n source: 'built-in',\n },\n {\n id: 'proactive',\n name: 'Proactive',\n description: 'Take the next reasonable step without pausing on routine choices.',\n instructions:\n 'Act on reasonable routine assumptions and take the next useful step. State assumptions when they matter. The active permission mode remains authoritative; this style never grants, changes, or bypasses permission.',\n keepCodingInstructions: true,\n tokenCost: 'medium',\n source: 'built-in',\n },\n {\n id: 'explanatory',\n name: 'Explanatory',\n description: 'Teach the reasoning and trade-offs behind the answer.',\n instructions:\n 'Explain the reasoning, important trade-offs, and relevant terminology as you work. Keep the explanation connected to the requested outcome and do not omit complete error, security, or destructive-action guidance.',\n keepCodingInstructions: true,\n tokenCost: 'high',\n source: 'built-in',\n },\n {\n id: 'learning',\n name: 'Learning',\n description: 'Teach by marking useful gaps for the human to fill.',\n instructions:\n 'Teach the requested subject step by step. Mark a small number of useful gaps with [Your turn:] and invite the human to fill them before revealing the explanation. Never turn safety, security, error, or destructive-action guidance into a gap.',\n keepCodingInstructions: true,\n tokenCost: 'high',\n source: 'built-in',\n },\n];\n","import { builtInOutputStyles } from './output-styles.js';\n\nimport type {\n IOutputStyle,\n IOutputStyleFile,\n IOutputStyleLoadResult,\n IOutputStyleRegistry,\n IOutputStyleSource,\n IOutputStyleSummary,\n TOutputStyleSource,\n TOutputStyleTokenCost,\n} from './output-style-types.js';\n\nexport { builtInOutputStyles } from './output-styles.js';\n\nconst TOKEN_COSTS = new Set<TOutputStyleTokenCost>([\n 'baseline',\n 'low',\n 'medium',\n 'high',\n 'unspecified',\n]);\n\nfunction stripScalarQuotes(value: string): string {\n return value.replace(/^(?:\"([\\s\\S]*)\"|'([\\s\\S]*)')$/, '$1$2');\n}\n\nfunction parseBoolean(field: string, raw: string): boolean {\n if (raw === 'true') return true;\n if (raw === 'false') return false;\n throw new Error(`${field}: expected boolean, received \"${raw}\"`);\n}\n\nfunction parseFrontmatter(\n fileName: string,\n content: string,\n): { values: Record<string, string>; instructions: string } {\n const lines = content.split('\\n');\n if (lines[0]?.trim() !== '---') {\n throw new Error('frontmatter: expected an opening --- marker');\n }\n const values: Record<string, string> = {};\n let end = -1;\n for (let index = 1; index < lines.length; index += 1) {\n const line = lines[index]!;\n if (line.trim() === '---') {\n end = index;\n break;\n }\n if (line.trim() === '') continue;\n // The value starts at its first non-space character, so the space before it is never split\n // two ways between `\\s*` and the value — that ambiguity made a rejected line quadratic.\n const match = /^([a-z][a-z0-9-]*):\\s*(\\S[^\\n\\r\\u2028\\u2029]*)?$/.exec(line);\n if (!match) throw new Error(`frontmatter: invalid entry at line ${index + 1}`);\n const key = match[1]!;\n if (values[key] !== undefined) throw new Error(`frontmatter.${key}: duplicate field`);\n values[key] = stripScalarQuotes((match[2] ?? '').trim());\n }\n if (end < 0) throw new Error('frontmatter: expected a closing --- marker');\n const unknown = Object.keys(values).filter(\n (key) => !['name', 'description', 'keep-coding-instructions', 'token-cost'].includes(key),\n );\n if (unknown.length > 0) {\n throw new Error(`frontmatter.${unknown[0]}: unknown field`);\n }\n return {\n values,\n instructions: lines\n .slice(end + 1)\n .join('\\n')\n .trim(),\n };\n}\n\n/**\n * The file's name without its final extension. Either separator ends a directory part, since a host\n * that joined the name to a directory may have used either; a name that is only an extension\n * (`.md`) keeps it, as `path.basename` does.\n */\nfunction fileStem(fileName: string): string {\n const name = fileName.slice(Math.max(fileName.lastIndexOf('/'), fileName.lastIndexOf('\\\\')) + 1);\n const dot = name.lastIndexOf('.');\n return dot > 0 ? name.slice(0, dot) : name;\n}\n\nfunction fileId(fileName: string): string {\n const id = fileStem(fileName).trim();\n if (!/^[a-z0-9][a-z0-9-]*$/i.test(id)) {\n throw new Error(`id: expected the Markdown filename stem to be a slug, received \"${id}\"`);\n }\n return id.toLowerCase();\n}\n\nexport function parseOutputStyleFile(\n file: IOutputStyleFile,\n source: TOutputStyleSource,\n): IOutputStyle {\n if (!file.fileName.endsWith('.md')) {\n throw new Error('file: expected a .md output-style file');\n }\n const id = fileId(file.fileName);\n const parsed = parseFrontmatter(file.fileName, file.content);\n const name = parsed.values.name?.trim() || fileStem(file.fileName);\n const description = parsed.values.description?.trim() || `Custom output style: ${name}`;\n const keepCodingInstructions =\n parsed.values['keep-coding-instructions'] === undefined\n ? false\n : parseBoolean(\n 'frontmatter.keep-coding-instructions',\n parsed.values['keep-coding-instructions'],\n );\n const tokenCost = parsed.values['token-cost'] ?? 'unspecified';\n if (!TOKEN_COSTS.has(tokenCost as TOutputStyleTokenCost)) {\n throw new Error(\n `frontmatter.token-cost: expected baseline|low|medium|high|unspecified, received \"${tokenCost}\"`,\n );\n }\n if (parsed.instructions.length === 0) {\n throw new Error('body: expected non-empty style instructions');\n }\n return {\n id,\n name,\n description,\n instructions: parsed.instructions,\n keepCodingInstructions,\n tokenCost: tokenCost as TOutputStyleTokenCost,\n source,\n };\n}\n\nfunction summarize(style: IOutputStyle): IOutputStyleSummary {\n return {\n id: style.id,\n name: style.name,\n description: style.description,\n tokenCost: style.tokenCost,\n source: style.source,\n };\n}\n\nexport function loadOutputStylesFromSources(\n sources: readonly IOutputStyleSource[],\n): IOutputStyleLoadResult {\n const styles = new Map<string, IOutputStyle>();\n const errors: { file: string; error: string }[] = [];\n for (const style of builtInOutputStyles) styles.set(style.id, style);\n\n const orderedSources = [...sources].sort((a, b) => a.precedence - b.precedence);\n for (const source of orderedSources) {\n const seenInSource = new Set<string>();\n for (const file of [...source.files].sort((a, b) => a.fileName.localeCompare(b.fileName))) {\n const displayFile = `${source.displayName}/${file.fileName}`;\n let style: IOutputStyle;\n try {\n style = parseOutputStyleFile(file, source.scope);\n } catch (error) {\n errors.push({\n file: displayFile,\n error: error instanceof Error ? error.message : String(error),\n });\n continue;\n }\n if (seenInSource.has(style.id)) {\n errors.push({ file: displayFile, error: `duplicate style id \"${style.id}\" in source` });\n continue;\n }\n seenInSource.add(style.id);\n if (styles.get(style.id)?.source === 'built-in') {\n errors.push({\n file: displayFile,\n error: `style id \"${style.id}\" collides with a built-in`,\n });\n continue;\n }\n styles.set(style.id, style);\n }\n }\n return {\n styles: [...styles.values()],\n loaded: [...styles.values()]\n .filter((style) => style.source !== 'built-in')\n .map((style) => style.id),\n errors,\n };\n}\n\nexport function createOutputStyleRegistry(\n sources: readonly IOutputStyleSource[] = [],\n): IOutputStyleRegistry {\n const loaded = loadOutputStylesFromSources(sources);\n const byId = new Map(loaded.styles.map((style) => [style.id, style]));\n return {\n listOutputStyles: () => loaded.styles.map(summarize),\n getOutputStyle: (id: string) => byId.get(id),\n };\n}\n"],"mappings":"4CAEA,MAEa,EAA+C,CAC1D,CACE,GAAI,UACJ,KAAM,UACN,YAAa,+BACb,aAAc,GACd,uBAAwB,GACxB,UAAW,WACX,OAAQ,UACV,EACA,CACE,GAAI,UACJ,KAAM,UACN,YAAa,yDACb,aACE,kQACF,uBAAwB,GACxB,UAAW,MACX,OAAQ,UACV,EACA,CACE,GAAI,YACJ,KAAM,YACN,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OAAO,CAAC,CAAC,CACzB,OAAQ,GAAU,EAAM,SAAW,UAAU,CAAC,CAC9C,IAAK,GAAU,EAAM,EAAE,EAC1B,QACF,CACF,CAEA,SAAgB,EACd,EAAyC,CAAC,EACpB,CACtB,IAAM,EAAS,EAA4B,CAAO,EAC5C,EAAO,IAAI,IAAI,EAAO,OAAO,IAAK,GAAU,CAAC,EAAM,GAAI,CAAK,CAAC,CAAC,EACpE,MAAO,CACL,qBAAwB,EAAO,OAAO,IAAI,CAAS,EACnD,eAAiB,GAAe,EAAK,IAAI,CAAE,CAC7C,CACF"}
@@ -0,0 +1,3 @@
1
+ require("./load-external-presets-DyoUUA3V.cjs");const e=[{id:`default`,name:`Default`,description:`The ordinary response style.`,instructions:``,keepCodingInstructions:!0,tokenCost:`baseline`,source:`built-in`},{id:`concise`,name:`Concise`,description:`Lead with the result and keep routine responses short.`,instructions:`Lead with the answer and skip routine preamble or tool narration. Keep responses concise while doing the same engineering work. Expand fully when asked for detail. Always keep error reports, security warnings and destructive-action confirmations complete.`,keepCodingInstructions:!0,tokenCost:`low`,source:`built-in`},{id:`proactive`,name:`Proactive`,description:`Take the next reasonable step without pausing on routine choices.`,instructions:`Act on reasonable routine assumptions and take the next useful step. State assumptions when they matter. The active permission mode remains authoritative; this style never grants, changes, or bypasses permission.`,keepCodingInstructions:!0,tokenCost:`medium`,source:`built-in`},{id:`explanatory`,name:`Explanatory`,description:`Teach the reasoning and trade-offs behind the answer.`,instructions:`Explain the reasoning, important trade-offs, and relevant terminology as you work. Keep the explanation connected to the requested outcome and do not omit complete error, security, or destructive-action guidance.`,keepCodingInstructions:!0,tokenCost:`high`,source:`built-in`},{id:`learning`,name:`Learning`,description:`Teach by marking useful gaps for the human to fill.`,instructions:`Teach the requested subject step by step. Mark a small number of useful gaps with [Your turn:] and invite the human to fill them before revealing the explanation. Never turn safety, security, error, or destructive-action guidance into a gap.`,keepCodingInstructions:!0,tokenCost:`high`,source:`built-in`}],t=new Set([`baseline`,`low`,`medium`,`high`,`unspecified`]);function n(e){return e.replace(/^(?:"([\s\S]*)"|'([\s\S]*)')$/,`$1$2`)}function r(e,t){if(t===`true`)return!0;if(t===`false`)return!1;throw Error(`${e}: expected boolean, received "${t}"`)}function i(e,t){let r=t.split(`
2
+ `);if(r[0]?.trim()!==`---`)throw Error(`frontmatter: expected an opening --- marker`);let i={},a=-1;for(let e=1;e<r.length;e+=1){let t=r[e];if(t.trim()===`---`){a=e;break}if(t.trim()===``)continue;let o=/^([a-z][a-z0-9-]*):\s*(\S[^\n\r\u2028\u2029]*)?$/.exec(t);if(!o)throw Error(`frontmatter: invalid entry at line ${e+1}`);let s=o[1];if(i[s]!==void 0)throw Error(`frontmatter.${s}: duplicate field`);i[s]=n((o[2]??``).trim())}if(a<0)throw Error(`frontmatter: expected a closing --- marker`);let o=Object.keys(i).filter(e=>![`name`,`description`,`keep-coding-instructions`,`token-cost`].includes(e));if(o.length>0)throw Error(`frontmatter.${o[0]}: unknown field`);return{values:i,instructions:r.slice(a+1).join(`
3
+ `).trim()}}function a(e){let t=e.slice(Math.max(e.lastIndexOf(`/`),e.lastIndexOf(`\\`))+1),n=t.lastIndexOf(`.`);return n>0?t.slice(0,n):t}function o(e){let t=a(e).trim();if(!/^[a-z0-9][a-z0-9-]*$/i.test(t))throw Error(`id: expected the Markdown filename stem to be a slug, received "${t}"`);return t.toLowerCase()}function s(e,n){if(!e.fileName.endsWith(`.md`))throw Error(`file: expected a .md output-style file`);let s=o(e.fileName),c=i(e.fileName,e.content),l=c.values.name?.trim()||a(e.fileName),u=c.values.description?.trim()||`Custom output style: ${l}`,d=c.values[`keep-coding-instructions`]!==void 0&&r(`frontmatter.keep-coding-instructions`,c.values[`keep-coding-instructions`]),f=c.values[`token-cost`]??`unspecified`;if(!t.has(f))throw Error(`frontmatter.token-cost: expected baseline|low|medium|high|unspecified, received "${f}"`);if(c.instructions.length===0)throw Error(`body: expected non-empty style instructions`);return{id:s,name:l,description:u,instructions:c.instructions,keepCodingInstructions:d,tokenCost:f,source:n}}function c(e){return{id:e.id,name:e.name,description:e.description,tokenCost:e.tokenCost,source:e.source}}function l(t){let n=new Map,r=[];for(let t of e)n.set(t.id,t);let i=[...t].sort((e,t)=>e.precedence-t.precedence);for(let e of i){let t=new Set;for(let i of[...e.files].sort((e,t)=>e.fileName.localeCompare(t.fileName))){let a=`${e.displayName}/${i.fileName}`,o;try{o=s(i,e.scope)}catch(e){r.push({file:a,error:e instanceof Error?e.message:String(e)});continue}if(t.has(o.id)){r.push({file:a,error:`duplicate style id "${o.id}" in source`});continue}if(t.add(o.id),n.get(o.id)?.source===`built-in`){r.push({file:a,error:`style id "${o.id}" collides with a built-in`});continue}n.set(o.id,o)}}return{styles:[...n.values()],loaded:[...n.values()].filter(e=>e.source!==`built-in`).map(e=>e.id),errors:r}}function u(e=[]){let t=l(e),n=new Map(t.styles.map(e=>[e.id,e]));return{listOutputStyles:()=>t.styles.map(c),getOutputStyle:e=>n.get(e)}}Object.defineProperty(exports,"i",{enumerable:!0,get:function(){return e}}),Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return l}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return s}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return u}});
@@ -0,0 +1,2 @@
1
+ function e(){return{name:`keybindings`,displayName:`Keybindings`,description:`Open the contextual terminal keybindings file in $EDITOR`,source:`keybindings`,modelInvocable:!1,runner:`client`,surfaces:[`terminal`]}}async function t(e,t,n){if(!e)return{success:!1,message:`Key bindings are available in an interactive terminal. Run /keybindings there.`};if(!t.canHandoffTerminal()||n===void 0)return{success:!1,message:`Keybindings editor is unavailable here.`};let r=await e.ensureFile(),i=await t.runWithTerminal(()=>n(r,t.getCwd()));return i===0?{success:!0,message:`Opened keybindings: ${r}`,data:{path:r}}:{success:!1,message:`Keybindings editor exited with code ${i}.`,data:{path:r,exitCode:i}}}var n=class{name=`keybindings`;getCommands(){return[e()]}};function r(r,i){let a=e(),o={name:a.name,displayName:a.displayName,description:a.description,requiresPermission:!1,userInvocable:!0,modelInvocable:!1,runner:a.runner,surfaces:a.surfaces,lifecycle:`inline`,execute:e=>t(r,e,i)};return{name:`agent-command-keybindings`,commandSources:[new n],systemCommands:[o]}}const i=`list | <theme-id> | syntax on|off | motion on|off`;function a(e){return e?`on`:`off`}function o(e){let{settings:t,reducedMotionPin:n}=e.getAppearance(),r=e.listThemes().map(e=>`${e.id===t.theme?`* `:` `}${e.id} — ${e.name} (${e.appearance}, ${e.source})`),i=n?`${a(n.reducedMotion)} for this run (pinned by ${n.tier}; saved ${a(t.reducedMotion)})`:a(t.reducedMotion);return[`Available themes:`,...r,``,`syntax highlighting: ${a(t.syntaxHighlighting)}`,`reduced motion: ${i}`].join(`
2
+ `)}function s(e){return{success:!0,message:o(e),data:{themes:e.listThemes().map(e=>({...e})),appearance:{...e.getAppearance().settings}}}}function c(e,t){return{success:!1,message:`Unknown theme "${e}". Available: ${t.listThemes().map(e=>e.id).join(`, `)||`(none)`}`}}function l(e){if(e===`on`)return!0;if(e===`off`)return!1}function u(e){let t={},n=0,r;for(e[0]!==`syntax`&&e[0]!==`motion`&&(r=e[0],n=1);n<e.length;){let r=e[n],a=l(e[n+1]);if(r!==`syntax`&&r!==`motion`||a===void 0)return{error:`Usage: /theme ${i}`};r===`syntax`?t.syntaxHighlighting=a:t.reducedMotion=!a,n+=2}return{patch:t,...r===void 0?{}:{themeId:r}}}function d(e,t,n){let r=[];t&&r.push(`theme ${t.name}`),e.syntaxHighlighting!==void 0&&r.push(`syntax highlighting ${a(e.syntaxHighlighting)}`),e.reducedMotion!==void 0&&r.push(`motion ${a(!e.reducedMotion)}`);let i=r.length>0?`Applied: ${r.join(`, `)}.`:`Nothing to change.`;return e.reducedMotion!==void 0&&n.reducedMotionPin?`${i} Saved, but this run keeps reduced motion pinned by ${n.reducedMotionPin.tier}.`:i}function f(e,t){if(!e)return{success:!1,message:`Themes are available in an interactive terminal. Run /theme there.`};let n=t.trim().split(/\s+/u).filter(Boolean);if(n.length===0)return{success:!0,message:`Opening the theme picker...`,uiIntents:[{type:`show-theme-picker`}]};if(n.length===1&&n[0]===`list`)return s(e);let r=u(n);if(r.error!==void 0||!r.patch)return{success:!1,message:r.error??`Usage: /theme ${i}`};let a={...r.patch},o;if(r.themeId!==void 0){if(o=e.getTheme(r.themeId),!o)return c(r.themeId,e);a.theme=o.id}return{success:!0,message:d(a,o,e.getAppearance()),data:{appearance:{...a}},hostActions:[{type:`appearance-settings-patch`,patch:a}]}}function p(){return{name:`theme`,displayName:`Theme`,description:`List, preview or switch the terminal colour theme, and toggle syntax highlighting and motion`,argumentHint:i,source:`theme`,userInvocable:!0,modelInvocable:!1,runner:`client`,surfaces:[`terminal`]}}var m=class{name=`theme`;getCommands(){return[p()]}};function h(e){let t=p(),n={name:t.name,displayName:t.displayName,description:t.description,argumentHint:t.argumentHint,requiresPermission:!1,userInvocable:!0,modelInvocable:!1,runner:t.runner,surfaces:t.surfaces,lifecycle:`inline`,execute:(t,n)=>f(e,n)};return{name:`agent-command-theme`,commandSources:[new m],systemCommands:[n]}}Object.defineProperty(exports,"a",{enumerable:!0,get:function(){return n}}),Object.defineProperty(exports,"c",{enumerable:!0,get:function(){return t}}),Object.defineProperty(exports,"i",{enumerable:!0,get:function(){return f}}),Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return p}}),Object.defineProperty(exports,"o",{enumerable:!0,get:function(){return e}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return h}}),Object.defineProperty(exports,"s",{enumerable:!0,get:function(){return r}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return m}});
@@ -0,0 +1,3 @@
1
+ function e(){return{name:`keybindings`,displayName:`Keybindings`,description:`Open the contextual terminal keybindings file in $EDITOR`,source:`keybindings`,modelInvocable:!1,runner:`client`,surfaces:[`terminal`]}}async function t(e,t,n){if(!e)return{success:!1,message:`Key bindings are available in an interactive terminal. Run /keybindings there.`};if(!t.canHandoffTerminal()||n===void 0)return{success:!1,message:`Keybindings editor is unavailable here.`};let r=await e.ensureFile(),i=await t.runWithTerminal(()=>n(r,t.getCwd()));return i===0?{success:!0,message:`Opened keybindings: ${r}`,data:{path:r}}:{success:!1,message:`Keybindings editor exited with code ${i}.`,data:{path:r,exitCode:i}}}var n=class{name=`keybindings`;getCommands(){return[e()]}};function r(r,i){let a=e(),o={name:a.name,displayName:a.displayName,description:a.description,requiresPermission:!1,userInvocable:!0,modelInvocable:!1,runner:a.runner,surfaces:a.surfaces,lifecycle:`inline`,execute:e=>t(r,e,i)};return{name:`agent-command-keybindings`,commandSources:[new n],systemCommands:[o]}}const i=`list | <theme-id> | syntax on|off | motion on|off`;function a(e){return e?`on`:`off`}function o(e){let{settings:t,reducedMotionPin:n}=e.getAppearance(),r=e.listThemes().map(e=>`${e.id===t.theme?`* `:` `}${e.id} — ${e.name} (${e.appearance}, ${e.source})`),i=n?`${a(n.reducedMotion)} for this run (pinned by ${n.tier}; saved ${a(t.reducedMotion)})`:a(t.reducedMotion);return[`Available themes:`,...r,``,`syntax highlighting: ${a(t.syntaxHighlighting)}`,`reduced motion: ${i}`].join(`
2
+ `)}function s(e){return{success:!0,message:o(e),data:{themes:e.listThemes().map(e=>({...e})),appearance:{...e.getAppearance().settings}}}}function c(e,t){return{success:!1,message:`Unknown theme "${e}". Available: ${t.listThemes().map(e=>e.id).join(`, `)||`(none)`}`}}function l(e){if(e===`on`)return!0;if(e===`off`)return!1}function u(e){let t={},n=0,r;for(e[0]!==`syntax`&&e[0]!==`motion`&&(r=e[0],n=1);n<e.length;){let r=e[n],a=l(e[n+1]);if(r!==`syntax`&&r!==`motion`||a===void 0)return{error:`Usage: /theme ${i}`};r===`syntax`?t.syntaxHighlighting=a:t.reducedMotion=!a,n+=2}return{patch:t,...r===void 0?{}:{themeId:r}}}function d(e,t,n){let r=[];t&&r.push(`theme ${t.name}`),e.syntaxHighlighting!==void 0&&r.push(`syntax highlighting ${a(e.syntaxHighlighting)}`),e.reducedMotion!==void 0&&r.push(`motion ${a(!e.reducedMotion)}`);let i=r.length>0?`Applied: ${r.join(`, `)}.`:`Nothing to change.`;return e.reducedMotion!==void 0&&n.reducedMotionPin?`${i} Saved, but this run keeps reduced motion pinned by ${n.reducedMotionPin.tier}.`:i}function f(e,t){if(!e)return{success:!1,message:`Themes are available in an interactive terminal. Run /theme there.`};let n=t.trim().split(/\s+/u).filter(Boolean);if(n.length===0)return{success:!0,message:`Opening the theme picker...`,uiIntents:[{type:`show-theme-picker`}]};if(n.length===1&&n[0]===`list`)return s(e);let r=u(n);if(r.error!==void 0||!r.patch)return{success:!1,message:r.error??`Usage: /theme ${i}`};let a={...r.patch},o;if(r.themeId!==void 0){if(o=e.getTheme(r.themeId),!o)return c(r.themeId,e);a.theme=o.id}return{success:!0,message:d(a,o,e.getAppearance()),data:{appearance:{...a}},hostActions:[{type:`appearance-settings-patch`,patch:a}]}}function p(){return{name:`theme`,displayName:`Theme`,description:`List, preview or switch the terminal colour theme, and toggle syntax highlighting and motion`,argumentHint:i,source:`theme`,userInvocable:!0,modelInvocable:!1,runner:`client`,surfaces:[`terminal`]}}var m=class{name=`theme`;getCommands(){return[p()]}};function h(e){let t=p(),n={name:t.name,displayName:t.displayName,description:t.description,argumentHint:t.argumentHint,requiresPermission:!1,userInvocable:!0,modelInvocable:!1,runner:t.runner,surfaces:t.surfaces,lifecycle:`inline`,execute:(t,n)=>f(e,n)};return{name:`agent-command-theme`,commandSources:[new m],systemCommands:[n]}}export{n as a,t as c,f as i,p as n,e as o,h as r,r as s,m as t};
3
+ //# sourceMappingURL=theme-command-module-GyqgVqV9.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"theme-command-module-GyqgVqV9.js","names":[],"sources":["../src/command/keybindings/keybindings-command-module.ts","../src/command/theme/theme-command-module.ts"],"sourcesContent":["import type {\n ICommandHostTerminalHandoff,\n ICommandHostWorkspace,\n ICommandModule,\n ISystemCommand,\n} from '@robota-sdk/agent-framework';\nimport type { ICommand, ICommandResult, ICommandSource } from '@robota-sdk/agent-interface/command';\n\nexport interface IKeybindingsFilePort {\n ensureFile(): Promise<string>;\n}\n\n/**\n * Opens `path` in the user's editor on the terminal the command holds, and resolves with the editor's\n * exit code. Starting a process is the host's, so a Node host passes `openFileInEditor` from\n * `@robota-sdk/agent-product/command/node`; without one the command says it cannot open an editor here.\n */\nexport type TOpenFileInEditor = (path: string, cwd: string) => Promise<number>;\n\nexport function createKeybindingsCommandEntry(): ICommand {\n return {\n name: 'keybindings',\n displayName: 'Keybindings',\n description: 'Open the contextual terminal keybindings file in $EDITOR',\n source: 'keybindings',\n // User-only: UI preference.\n modelInvocable: false,\n // Key bindings belong to the terminal the user sits at, so that terminal runs it, even when\n // attached.\n runner: 'client',\n surfaces: ['terminal'],\n };\n}\n\n// A host without a terminal (the desktop app's sidecar) still answers, so the command is never\n// \"unknown\" there — it says where key bindings live instead.\nconst KEYBINDINGS_UNAVAILABLE =\n 'Key bindings are available in an interactive terminal. Run /keybindings there.';\n\nexport async function executeKeybindingsCommand(\n file: IKeybindingsFilePort | undefined,\n context: ICommandHostTerminalHandoff & ICommandHostWorkspace,\n openInEditor: TOpenFileInEditor | undefined,\n): Promise<ICommandResult> {\n if (!file) return { success: false, message: KEYBINDINGS_UNAVAILABLE };\n if (!context.canHandoffTerminal() || openInEditor === undefined) {\n return { success: false, message: 'Keybindings editor is unavailable here.' };\n }\n const path = await file.ensureFile();\n const exitCode = await context.runWithTerminal(() => openInEditor(path, context.getCwd()));\n if (exitCode !== 0) {\n return {\n success: false,\n message: `Keybindings editor exited with code ${exitCode}.`,\n data: { path, exitCode },\n };\n }\n return { success: true, message: `Opened keybindings: ${path}`, data: { path } };\n}\n\nexport class KeybindingsCommandSource implements ICommandSource {\n readonly name = 'keybindings';\n\n getCommands(): ICommand[] {\n return [createKeybindingsCommandEntry()];\n }\n}\n\nexport function createKeybindingsCommandModule(\n file: IKeybindingsFilePort | undefined,\n openInEditor?: TOpenFileInEditor,\n): ICommandModule {\n const entry = createKeybindingsCommandEntry();\n const command: ISystemCommand = {\n name: entry.name,\n displayName: entry.displayName,\n description: entry.description,\n requiresPermission: false,\n userInvocable: true,\n modelInvocable: false,\n runner: entry.runner,\n surfaces: entry.surfaces,\n lifecycle: 'inline',\n execute: (context) => executeKeybindingsCommand(file, context, openInEditor),\n };\n return {\n name: 'agent-command-keybindings',\n commandSources: [new KeybindingsCommandSource()],\n systemCommands: [command],\n };\n}\n","import type {\n ICommandModule,\n ISystemCommand,\n TAppearanceSettingsPatch,\n} from '@robota-sdk/agent-framework';\nimport type {\n ICommand,\n ICommandResult,\n ICommandSource,\n IThemeAppearanceState,\n IThemeCatalogueEntry,\n IThemeCataloguePort,\n} from '@robota-sdk/agent-interface/command';\n\nconst THEME_DESCRIPTION =\n 'List, preview or switch the terminal colour theme, and toggle syntax highlighting and motion';\nconst THEME_ARGUMENT_HINT = 'list | <theme-id> | syntax on|off | motion on|off';\n\n// A host without a terminal (the desktop app's sidecar) still answers, so the command is never\n// \"unknown\" there — it says where themes live instead.\nconst THEME_UNAVAILABLE =\n 'Themes are available in an interactive terminal. Run /theme there.';\n\nfunction formatToggle(value: boolean): string {\n return value ? 'on' : 'off';\n}\n\nfunction formatCatalogue(catalogue: IThemeCataloguePort): string {\n const { settings, reducedMotionPin } = catalogue.getAppearance();\n const rows = catalogue.listThemes().map((theme) => {\n const marker = theme.id === settings.theme ? '* ' : ' ';\n return `${marker}${theme.id} — ${theme.name} (${theme.appearance}, ${theme.source})`;\n });\n // Two facts, never one: what this run does, and what is saved. Reporting the SAVED value beside\n // the tier reads as a contradiction on a `--no-reduced-motion` run over a `true` setting, and as\n // an outright wrong answer to \"is motion reduced right now\".\n const motion = reducedMotionPin\n ? `${formatToggle(reducedMotionPin.reducedMotion)} for this run (pinned by ${reducedMotionPin.tier}; saved ${formatToggle(settings.reducedMotion)})`\n : formatToggle(settings.reducedMotion);\n return [\n 'Available themes:',\n ...rows,\n '',\n `syntax highlighting: ${formatToggle(settings.syntaxHighlighting)}`,\n `reduced motion: ${motion}`,\n ].join('\\n');\n}\n\nfunction listResult(catalogue: IThemeCataloguePort): ICommandResult {\n return {\n success: true,\n message: formatCatalogue(catalogue),\n data: {\n themes: catalogue.listThemes().map((theme) => ({ ...theme })),\n appearance: { ...catalogue.getAppearance().settings },\n },\n };\n}\n\nfunction unknownThemeResult(id: string, catalogue: IThemeCataloguePort): ICommandResult {\n const known = catalogue\n .listThemes()\n .map((theme) => theme.id)\n .join(', ');\n return {\n success: false,\n message: `Unknown theme \"${id}\". Available: ${known || '(none)'}`,\n };\n}\n\n/** `on` / `off`, and nothing else — a typo must not read as its opposite. */\nfunction parseToggle(word: string | undefined): boolean | undefined {\n if (word === 'on') return true;\n if (word === 'off') return false;\n return undefined;\n}\n\ninterface IParsedThemeArgs {\n readonly patch?: TAppearanceSettingsPatch;\n readonly themeId?: string;\n readonly error?: string;\n}\n\n/**\n * `/theme <id> [syntax on|off] [motion on|off]`, or a bare `syntax`/`motion` toggle. The theme id is\n * NOT resolved here — parsing answers what was asked for, and the caller decides whether the\n * catalogue holds it, so an unknown id is reported with the catalogue rather than as a parse error.\n */\nfunction parseThemeArgs(tokens: readonly string[]): IParsedThemeArgs {\n const patch: TAppearanceSettingsPatch = {};\n let index = 0;\n let themeId: string | undefined;\n if (tokens[0] !== 'syntax' && tokens[0] !== 'motion') {\n themeId = tokens[0];\n index = 1;\n }\n while (index < tokens.length) {\n const key = tokens[index];\n const value = parseToggle(tokens[index + 1]);\n if ((key !== 'syntax' && key !== 'motion') || value === undefined) {\n return { error: `Usage: /theme ${THEME_ARGUMENT_HINT}` };\n }\n if (key === 'syntax') patch.syntaxHighlighting = value;\n else patch.reducedMotion = !value;\n index += 2;\n }\n return { patch, ...(themeId === undefined ? {} : { themeId }) };\n}\n\n/**\n * `motion on` means \"animate\", which is `reducedMotion: false`. The inversion lives in one place\n * precisely because reading it backwards is the easy mistake — a user asking for motion and getting\n * stillness would look like the command doing nothing.\n */\nfunction describeChange(\n patch: TAppearanceSettingsPatch,\n theme: IThemeCatalogueEntry | undefined,\n state: IThemeAppearanceState,\n): string {\n const parts: string[] = [];\n if (theme) parts.push(`theme ${theme.name}`);\n if (patch.syntaxHighlighting !== undefined) {\n parts.push(`syntax highlighting ${formatToggle(patch.syntaxHighlighting)}`);\n }\n if (patch.reducedMotion !== undefined) {\n parts.push(`motion ${formatToggle(!patch.reducedMotion)}`);\n }\n const applied = parts.length > 0 ? `Applied: ${parts.join(', ')}.` : 'Nothing to change.';\n // The pin is reported, never silently obeyed or silently overridden: the setting IS persisted and\n // takes effect next run, while this run keeps what pinned it.\n if (patch.reducedMotion !== undefined && state.reducedMotionPin) {\n return `${applied} Saved, but this run keeps reduced motion pinned by ${state.reducedMotionPin.tier}.`;\n }\n return applied;\n}\n\nexport function executeThemeCommand(\n catalogue: IThemeCataloguePort | undefined,\n args: string,\n): ICommandResult {\n if (!catalogue) return { success: false, message: THEME_UNAVAILABLE };\n\n const tokens = args.trim().split(/\\s+/u).filter(Boolean);\n if (tokens.length === 0) {\n return {\n success: true,\n message: 'Opening the theme picker...',\n uiIntents: [{ type: 'show-theme-picker' }],\n };\n }\n if (tokens.length === 1 && tokens[0] === 'list') return listResult(catalogue);\n\n const parsed = parseThemeArgs(tokens);\n if (parsed.error !== undefined || !parsed.patch) {\n return { success: false, message: parsed.error ?? `Usage: /theme ${THEME_ARGUMENT_HINT}` };\n }\n\n const patch = { ...parsed.patch };\n let theme: IThemeCatalogueEntry | undefined;\n if (parsed.themeId !== undefined) {\n theme = catalogue.getTheme(parsed.themeId);\n // An unknown id writes NOTHING — not the theme, and not the toggles submitted beside it.\n if (!theme) return unknownThemeResult(parsed.themeId, catalogue);\n patch.theme = theme.id;\n }\n\n return {\n success: true,\n message: describeChange(patch, theme, catalogue.getAppearance()),\n data: { appearance: { ...patch } },\n hostActions: [{ type: 'appearance-settings-patch', patch }],\n };\n}\n\nexport function createThemeCommandEntry(): ICommand {\n return {\n name: 'theme',\n displayName: 'Theme',\n description: THEME_DESCRIPTION,\n argumentHint: THEME_ARGUMENT_HINT,\n source: 'theme',\n userInvocable: true,\n // User-only: UI preference.\n modelInvocable: false,\n // Themes belong to the terminal the user sits at, so that terminal runs it, even when attached.\n runner: 'client',\n surfaces: ['terminal'],\n };\n}\n\nexport class ThemeCommandSource implements ICommandSource {\n readonly name = 'theme';\n\n getCommands(): ICommand[] {\n return [createThemeCommandEntry()];\n }\n}\n\nexport function createThemeCommandModule(\n catalogue: IThemeCataloguePort | undefined,\n): ICommandModule {\n const entry = createThemeCommandEntry();\n const command: ISystemCommand = {\n name: entry.name,\n displayName: entry.displayName,\n description: entry.description,\n argumentHint: entry.argumentHint,\n requiresPermission: false,\n userInvocable: true,\n modelInvocable: false,\n runner: entry.runner,\n surfaces: entry.surfaces,\n lifecycle: 'inline',\n execute: (_context, args) => executeThemeCommand(catalogue, args),\n };\n return {\n name: 'agent-command-theme',\n commandSources: [new ThemeCommandSource()],\n systemCommands: [command],\n };\n}\n"],"mappings":"AAmBA,SAAgB,GAA0C,CACxD,MAAO,CACL,KAAM,cACN,YAAa,cACb,YAAa,2DACb,OAAQ,cAER,eAAgB,GAGhB,OAAQ,SACR,SAAU,CAAC,UAAU,CACvB,CACF,CAOA,eAAsB,EACpB,EACA,EACA,EACyB,CACzB,GAAI,CAAC,EAAM,MAAO,CAAE,QAAS,GAAO,QAAS,gFAAwB,EACrE,GAAI,CAAC,EAAQ,mBAAmB,GAAK,IAAiB,IAAA,GACpD,MAAO,CAAE,QAAS,GAAO,QAAS,yCAA0C,EAE9E,IAAM,EAAO,MAAM,EAAK,WAAW,EAC7B,EAAW,MAAM,EAAQ,oBAAsB,EAAa,EAAM,EAAQ,OAAO,CAAC,CAAC,EAQzF,OAPI,IAAa,EAOV,CAAE,QAAS,GAAM,QAAS,uBAAuB,IAAQ,KAAM,CAAE,MAAK,CAAE,EANtE,CACL,QAAS,GACT,QAAS,uCAAuC,EAAS,GACzD,KAAM,CAAE,OAAM,UAAS,CACzB,CAGJ,CAEA,IAAa,E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Ac,EAAM,aACpB,mBAAoB,GACpB,cAAe,GACf,eAAgB,GAChB,OAAQ,EAAM,OACd,SAAU,EAAM,SAChB,UAAW,SACX,SAAU,EAAU,IAAS,EAAoB,EAAW,CAAI,CAClE,EACA,MAAO,CACL,KAAM,sBACN,eAAgB,CAAC,IAAI,CAAoB,EACzC,eAAgB,CAAC,CAAO,CAC1B,CACF"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@robota-sdk/agent-product",
3
- "version": "3.2.3",
4
- "description": "The product-assembly kernel for the Robota SDK: assembleProduct — a pure, IO-free fold over IProductProfile that delegates runtime construction to agent-framework",
3
+ "version": "3.3.2",
4
+ "description": "Product assembly for the Robota SDK: assembleProduct over IProductProfile, plus one subpath each for the capability-pack contract, presets, slash-command modules and the coding capability pack",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",
@@ -17,6 +17,75 @@
17
17
  "default": "./dist/index.cjs"
18
18
  }
19
19
  },
20
+ "./capability-pack": {
21
+ "source": "./src/capability-pack/index.ts",
22
+ "import": {
23
+ "types": "./dist/capability-pack/index.d.ts",
24
+ "default": "./dist/capability-pack/index.js"
25
+ },
26
+ "require": {
27
+ "types": "./dist/capability-pack/index.d.cts",
28
+ "default": "./dist/capability-pack/index.cjs"
29
+ }
30
+ },
31
+ "./preset": {
32
+ "source": "./src/preset/index.ts",
33
+ "import": {
34
+ "types": "./dist/preset/index.d.ts",
35
+ "default": "./dist/preset/index.js"
36
+ },
37
+ "require": {
38
+ "types": "./dist/preset/index.d.cts",
39
+ "default": "./dist/preset/index.cjs"
40
+ }
41
+ },
42
+ "./preset/node": {
43
+ "source": "./src/preset/node.ts",
44
+ "browser": null,
45
+ "import": {
46
+ "types": "./dist/preset/node.d.ts",
47
+ "default": "./dist/preset/node.js"
48
+ },
49
+ "require": {
50
+ "types": "./dist/preset/node.d.cts",
51
+ "default": "./dist/preset/node.cjs"
52
+ }
53
+ },
54
+ "./command": {
55
+ "source": "./src/command/index.ts",
56
+ "import": {
57
+ "types": "./dist/command/index.d.ts",
58
+ "default": "./dist/command/index.js"
59
+ },
60
+ "require": {
61
+ "types": "./dist/command/index.d.cts",
62
+ "default": "./dist/command/index.cjs"
63
+ }
64
+ },
65
+ "./command/node": {
66
+ "source": "./src/command/node.ts",
67
+ "browser": null,
68
+ "import": {
69
+ "types": "./dist/command/node.d.ts",
70
+ "default": "./dist/command/node.js"
71
+ },
72
+ "require": {
73
+ "types": "./dist/command/node.d.cts",
74
+ "default": "./dist/command/node.cjs"
75
+ }
76
+ },
77
+ "./coding": {
78
+ "source": "./src/coding/index.ts",
79
+ "browser": null,
80
+ "import": {
81
+ "types": "./dist/coding/index.d.ts",
82
+ "default": "./dist/coding/index.js"
83
+ },
84
+ "require": {
85
+ "types": "./dist/coding/index.d.cts",
86
+ "default": "./dist/coding/index.cjs"
87
+ }
88
+ },
20
89
  "./package.json": "./package.json"
21
90
  },
22
91
  "engines": {
@@ -27,13 +96,13 @@
27
96
  "CHANGELOG.md"
28
97
  ],
29
98
  "dependencies": {
30
- "@robota-sdk/agent-core": "^3.2.2",
31
- "@robota-sdk/agent-capability-pack": "^3.2.3",
32
- "@robota-sdk/agent-framework": "^3.2.3",
33
- "@robota-sdk/agent-interface-transport": "^3.2.3",
34
- "@robota-sdk/agent-preset": "^3.2.3"
99
+ "@robota-sdk/agent-core": "^3.3.1",
100
+ "@robota-sdk/agent-framework": "^3.3.1",
101
+ "@robota-sdk/agent-interface": "^3.3.1",
102
+ "@robota-sdk/agent-tools": "^3.3.2"
35
103
  },
36
104
  "devDependencies": {
105
+ "@types/node": "^22.19.21",
37
106
  "rimraf": "^5.0.10",
38
107
  "tsdown": "^0.22.14",
39
108
  "typescript": "^6.0.3",
@@ -60,8 +129,9 @@
60
129
  "build:types": "pnpm run build",
61
130
  "test": "vitest run --passWithNoTests",
62
131
  "test:coverage": "vitest run --coverage --passWithNoTests",
63
- "scenario:verify": "pnpm scenario:verify:composition-contract",
132
+ "scenario:verify": "pnpm scenario:verify:composition-contract && pnpm scenario:verify:semantic-command-roles",
64
133
  "scenario:verify:composition-contract": "pnpm exec tsx --conditions=source examples/verify-composition-contract.ts",
134
+ "scenario:verify:semantic-command-roles": "pnpm exec tsx --conditions=source examples/verify-semantic-command-roles.ts",
65
135
  "typecheck": "tsgo --noEmit && tsgo -p tsconfig.examples.json --noEmit",
66
136
  "lint": "eslint src/ --ext .ts",
67
137
  "clean": "rimraf dist"