@steerable/agent-shell 0.6.15

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 (204) hide show
  1. package/LICENSE +91 -0
  2. package/contracts/tool-contract.json +326 -0
  3. package/dist/attachments.d.ts +41 -0
  4. package/dist/attachments.js +147 -0
  5. package/dist/brand.d.ts +24 -0
  6. package/dist/brand.js +92 -0
  7. package/dist/host/http-routes.d.ts +21 -0
  8. package/dist/host/http-routes.js +55 -0
  9. package/dist/host/ipc.d.ts +11 -0
  10. package/dist/host/ipc.js +20 -0
  11. package/dist/host/pack-assembly.d.ts +86 -0
  12. package/dist/host/pack-assembly.js +32 -0
  13. package/dist/host/runtime.d.ts +69 -0
  14. package/dist/host/runtime.js +207 -0
  15. package/dist/host/visible-terminal-exec.d.ts +21 -0
  16. package/dist/host/visible-terminal-exec.js +151 -0
  17. package/dist/hosted-web-search.d.ts +13 -0
  18. package/dist/hosted-web-search.js +82 -0
  19. package/dist/image-attachment.d.ts +39 -0
  20. package/dist/image-attachment.js +133 -0
  21. package/dist/insights/flush.d.ts +10 -0
  22. package/dist/insights/flush.js +139 -0
  23. package/dist/insights/record.d.ts +17 -0
  24. package/dist/insights/record.js +44 -0
  25. package/dist/json-store.d.ts +9 -0
  26. package/dist/json-store.js +22 -0
  27. package/dist/llm/index.d.ts +23 -0
  28. package/dist/llm/index.js +105 -0
  29. package/dist/llm/ollama.d.ts +23 -0
  30. package/dist/llm/ollama.js +242 -0
  31. package/dist/llm/openai-compat.d.ts +20 -0
  32. package/dist/llm/openai-compat.js +199 -0
  33. package/dist/llm/sidecar-provider.d.ts +37 -0
  34. package/dist/llm/sidecar-provider.js +163 -0
  35. package/dist/llm/tool-choice.d.ts +35 -0
  36. package/dist/llm/tool-choice.js +85 -0
  37. package/dist/llm/types.d.ts +122 -0
  38. package/dist/llm/types.js +1 -0
  39. package/dist/local-backend/agent-capability.d.ts +101 -0
  40. package/dist/local-backend/agent-capability.js +174 -0
  41. package/dist/local-backend/ai-title.d.ts +43 -0
  42. package/dist/local-backend/ai-title.js +173 -0
  43. package/dist/local-backend/auto-continue-helper.d.ts +80 -0
  44. package/dist/local-backend/auto-continue-helper.js +83 -0
  45. package/dist/local-backend/branch-helper.d.ts +24 -0
  46. package/dist/local-backend/branch-helper.js +27 -0
  47. package/dist/local-backend/context-compactor.d.ts +81 -0
  48. package/dist/local-backend/context-compactor.js +213 -0
  49. package/dist/local-backend/coreloop-stream.d.ts +245 -0
  50. package/dist/local-backend/coreloop-stream.js +277 -0
  51. package/dist/local-backend/deferred-detector.d.ts +15 -0
  52. package/dist/local-backend/deferred-detector.js +124 -0
  53. package/dist/local-backend/history-helper.d.ts +30 -0
  54. package/dist/local-backend/history-helper.js +34 -0
  55. package/dist/local-backend/interrupted-helper.d.ts +29 -0
  56. package/dist/local-backend/interrupted-helper.js +25 -0
  57. package/dist/local-backend/live-stream.d.ts +36 -0
  58. package/dist/local-backend/live-stream.js +23 -0
  59. package/dist/local-backend/llm-diagnose.d.ts +37 -0
  60. package/dist/local-backend/llm-diagnose.js +284 -0
  61. package/dist/local-backend/message-triggers.d.ts +27 -0
  62. package/dist/local-backend/message-triggers.js +67 -0
  63. package/dist/local-backend/pack-backend-routes.d.ts +31 -0
  64. package/dist/local-backend/pack-backend-routes.js +62 -0
  65. package/dist/local-backend/pack-turn-hooks.d.ts +37 -0
  66. package/dist/local-backend/pack-turn-hooks.js +67 -0
  67. package/dist/local-backend/prompt-builder.d.ts +101 -0
  68. package/dist/local-backend/prompt-builder.js +246 -0
  69. package/dist/local-backend/regenerate-helper.d.ts +62 -0
  70. package/dist/local-backend/regenerate-helper.js +75 -0
  71. package/dist/local-backend/router.d.ts +175 -0
  72. package/dist/local-backend/router.js +3139 -0
  73. package/dist/local-backend/skill-install.d.ts +19 -0
  74. package/dist/local-backend/skill-install.js +71 -0
  75. package/dist/local-backend/skill-loader.d.ts +92 -0
  76. package/dist/local-backend/skill-loader.js +146 -0
  77. package/dist/local-backend/skills/00-identity/SKILL.md +32 -0
  78. package/dist/local-backend/skills/10-goal/SKILL.md +59 -0
  79. package/dist/local-backend/skills/11-loop/SKILL.md +71 -0
  80. package/dist/local-backend/skills/12-create-skill/SKILL.md +88 -0
  81. package/dist/local-backend/skills/70-plan-mode/SKILL.md +58 -0
  82. package/dist/local-backend/skills/80-tool-usage/SKILL.md +70 -0
  83. package/dist/local-backend/skills/81-anti-deferred/SKILL.md +53 -0
  84. package/dist/local-backend/skills/82-data-grounding/SKILL.md +56 -0
  85. package/dist/local-backend/skills/85-local-exec/SKILL.md +86 -0
  86. package/dist/local-backend/skills/86-proactive-coding/SKILL.md +51 -0
  87. package/dist/local-backend/subagent-profiles.d.ts +30 -0
  88. package/dist/local-backend/subagent-profiles.js +74 -0
  89. package/dist/local-backend/task-process.d.ts +12 -0
  90. package/dist/local-backend/task-process.js +176 -0
  91. package/dist/local-backend/task-service.d.ts +135 -0
  92. package/dist/local-backend/task-service.js +565 -0
  93. package/dist/local-backend/turn-duration.d.ts +2 -0
  94. package/dist/local-backend/turn-duration.js +9 -0
  95. package/dist/local-backend/turn-timeline.d.ts +16 -0
  96. package/dist/local-backend/turn-timeline.js +42 -0
  97. package/dist/local-backend/worktree-service.d.ts +84 -0
  98. package/dist/local-backend/worktree-service.js +243 -0
  99. package/dist/local-edit.d.ts +48 -0
  100. package/dist/local-edit.js +44 -0
  101. package/dist/local-executor.d.ts +255 -0
  102. package/dist/local-executor.js +881 -0
  103. package/dist/local-script-registry.d.ts +28 -0
  104. package/dist/local-script-registry.js +63 -0
  105. package/dist/log.d.ts +13 -0
  106. package/dist/log.js +12 -0
  107. package/dist/main.d.ts +1 -0
  108. package/dist/main.js +855 -0
  109. package/dist/mcp-executor.d.ts +45 -0
  110. package/dist/mcp-executor.js +241 -0
  111. package/dist/mcp-server-registry.d.ts +104 -0
  112. package/dist/mcp-server-registry.js +234 -0
  113. package/dist/preload-default.d.ts +1 -0
  114. package/dist/preload-default.js +9 -0
  115. package/dist/preload.cjs +395 -0
  116. package/dist/preload.d.ts +20 -0
  117. package/dist/preload.js +411 -0
  118. package/dist/product-config.d.ts +43 -0
  119. package/dist/product-config.js +26 -0
  120. package/dist/project-registry.d.ts +55 -0
  121. package/dist/project-registry.js +106 -0
  122. package/dist/project-rules.d.ts +15 -0
  123. package/dist/project-rules.js +102 -0
  124. package/dist/runtime.d.ts +62 -0
  125. package/dist/runtime.js +217 -0
  126. package/dist/scenario/pack.d.ts +8 -0
  127. package/dist/scenario/pack.js +1 -0
  128. package/dist/scenario/registry.d.ts +24 -0
  129. package/dist/scenario/registry.js +31 -0
  130. package/dist/server/http-server.d.ts +39 -0
  131. package/dist/server/http-server.js +361 -0
  132. package/dist/server/index.d.ts +1 -0
  133. package/dist/server/index.js +107 -0
  134. package/dist/server/sse-bus.d.ts +14 -0
  135. package/dist/server/sse-bus.js +31 -0
  136. package/dist/shell-adapt.d.ts +21 -0
  137. package/dist/shell-adapt.js +104 -0
  138. package/dist/sidecar/boot.d.ts +36 -0
  139. package/dist/sidecar/boot.js +343 -0
  140. package/dist/sidecar/egress-hint.d.ts +15 -0
  141. package/dist/sidecar/egress-hint.js +46 -0
  142. package/dist/sidecar/egress-proxy.d.ts +183 -0
  143. package/dist/sidecar/egress-proxy.js +419 -0
  144. package/dist/sidecar/errors.d.ts +22 -0
  145. package/dist/sidecar/errors.js +38 -0
  146. package/dist/sidecar/exec-sandbox.d.ts +48 -0
  147. package/dist/sidecar/exec-sandbox.js +94 -0
  148. package/dist/sidecar/handle.d.ts +32 -0
  149. package/dist/sidecar/handle.js +53 -0
  150. package/dist/sidecar/index.d.ts +14 -0
  151. package/dist/sidecar/index.js +13 -0
  152. package/dist/sidecar/proxy-detect.d.ts +50 -0
  153. package/dist/sidecar/proxy-detect.js +182 -0
  154. package/dist/sidecar/reverse-approval.d.ts +55 -0
  155. package/dist/sidecar/reverse-approval.js +86 -0
  156. package/dist/sidecar/reverse-ask-user.d.ts +34 -0
  157. package/dist/sidecar/reverse-ask-user.js +59 -0
  158. package/dist/sidecar/reverse-spawn.d.ts +19 -0
  159. package/dist/sidecar/reverse-spawn.js +161 -0
  160. package/dist/sidecar/reverse-tools.d.ts +29 -0
  161. package/dist/sidecar/reverse-tools.js +106 -0
  162. package/dist/sidecar/safety-patterns.d.ts +41 -0
  163. package/dist/sidecar/safety-patterns.js +157 -0
  164. package/dist/sidecar/storage-path.d.ts +14 -0
  165. package/dist/sidecar/storage-path.js +35 -0
  166. package/dist/sidecar/supervisor.d.ts +218 -0
  167. package/dist/sidecar/supervisor.js +932 -0
  168. package/dist/sidecar/types.d.ts +601 -0
  169. package/dist/sidecar/types.js +1 -0
  170. package/dist/single-instance.d.ts +11 -0
  171. package/dist/single-instance.js +21 -0
  172. package/dist/storage/empty-chats.d.ts +9 -0
  173. package/dist/storage/empty-chats.js +16 -0
  174. package/dist/storage/index.d.ts +373 -0
  175. package/dist/storage/index.js +1158 -0
  176. package/dist/storage/insights-redact.d.ts +2 -0
  177. package/dist/storage/insights-redact.js +30 -0
  178. package/dist/storage/insights-settings.d.ts +53 -0
  179. package/dist/storage/insights-settings.js +92 -0
  180. package/dist/storage/llm-settings.d.ts +120 -0
  181. package/dist/storage/llm-settings.js +233 -0
  182. package/dist/storage/local-store-singleton.d.ts +28 -0
  183. package/dist/storage/local-store-singleton.js +38 -0
  184. package/dist/storage/message-order.d.ts +25 -0
  185. package/dist/storage/message-order.js +27 -0
  186. package/dist/storage/pack-migrations.d.ts +22 -0
  187. package/dist/storage/pack-migrations.js +24 -0
  188. package/dist/storage/pack-seeds.d.ts +36 -0
  189. package/dist/storage/pack-seeds.js +42 -0
  190. package/dist/storage/telemetry-settings.d.ts +38 -0
  191. package/dist/storage/telemetry-settings.js +59 -0
  192. package/dist/storage/usage-summary.d.ts +55 -0
  193. package/dist/storage/usage-summary.js +38 -0
  194. package/dist/storage/web-search-settings.d.ts +38 -0
  195. package/dist/storage/web-search-settings.js +74 -0
  196. package/dist/storage/write-lease.d.ts +26 -0
  197. package/dist/storage/write-lease.js +74 -0
  198. package/dist/terminal-manager.d.ts +83 -0
  199. package/dist/terminal-manager.js +506 -0
  200. package/dist/tool-router.d.ts +228 -0
  201. package/dist/tool-router.js +930 -0
  202. package/dist/tool-search-rank.d.ts +42 -0
  203. package/dist/tool-search-rank.js +96 -0
  204. package/package.json +67 -0
@@ -0,0 +1,42 @@
1
+ /**
2
+ * `tool_search` 的 BM25 排序,与 steerable-framework
3
+ * `packages/agent-runtime/py/src/steerable_agent_runtime/tool_search.py`
4
+ * 同一算法与同一常量:同名工具在两侧必须给出同样的名次与同样的默认上限,
5
+ * 否则「桌面的 tool_search」和「框架的 tool_search」是两个契约不同的工具。
6
+ */
7
+ /** 每次调用默认返回条数;与框架 `DEFAULT_MAX_RESULTS` 一致(codex 的 tool_discovery 上限)。 */
8
+ export declare const TOOL_SEARCH_DEFAULT_MAX_RESULTS = 8;
9
+ /** 每次调用硬上限:每条匹配都带完整 schema,无界结果就是无界上下文注入。 */
10
+ export declare const TOOL_SEARCH_MAX_RESULTS_CEILING = 20;
11
+ /** 排序输入:只需要参与打分的两个字段。 */
12
+ export interface RankableTool {
13
+ name: string;
14
+ description: string;
15
+ }
16
+ /**
17
+ * 按 BM25 给 `inventory` 打分并排序,最佳在前。
18
+ *
19
+ * 排序而非过滤,但下限仍是过滤:不含任何查询词的文档得 0 分被丢弃——
20
+ * 对词表外的查询返回空,胜过返回一串不相关的工具。
21
+ *
22
+ * 分数本身是导出的,因为与框架实现的等价性要按分数比对:只比名次会漏掉
23
+ * 常量漂移(k1/b/name 权重变了而名次恰好不变)。
24
+ *
25
+ * @param inventory 待打分的工具名录。
26
+ * @param query 模型给出的查询串。
27
+ * @returns 命中的工具及其分数,按分数降序、同分按 name 升序。
28
+ */
29
+ export declare function scoreTools<T extends RankableTool>(inventory: readonly T[], query: string): Array<{
30
+ tool: T;
31
+ score: number;
32
+ }>;
33
+ /**
34
+ * `scoreTools` 的名次部分。
35
+ *
36
+ * @param inventory 待排序的工具名录。
37
+ * @param query 模型给出的查询串。
38
+ * @returns 命中的工具,按分数降序、同分按 name 升序。
39
+ */
40
+ export declare function rankTools<T extends RankableTool>(inventory: readonly T[], query: string): T[];
41
+ /** 把请求的条数收进 [1, 封顶] 区间;缺省用框架的默认值。 */
42
+ export declare function resolveMaxResults(requested: unknown): number;
@@ -0,0 +1,96 @@
1
+ /**
2
+ * `tool_search` 的 BM25 排序,与 steerable-framework
3
+ * `packages/agent-runtime/py/src/steerable_agent_runtime/tool_search.py`
4
+ * 同一算法与同一常量:同名工具在两侧必须给出同样的名次与同样的默认上限,
5
+ * 否则「桌面的 tool_search」和「框架的 tool_search」是两个契约不同的工具。
6
+ */
7
+ /** 每次调用默认返回条数;与框架 `DEFAULT_MAX_RESULTS` 一致(codex 的 tool_discovery 上限)。 */
8
+ export const TOOL_SEARCH_DEFAULT_MAX_RESULTS = 8;
9
+ /** 每次调用硬上限:每条匹配都带完整 schema,无界结果就是无界上下文注入。 */
10
+ export const TOOL_SEARCH_MAX_RESULTS_CEILING = 20;
11
+ /** BM25 饱和度/长度归一常量——Lucene 默认值,与框架一致,不重调。 */
12
+ const BM25_K1 = 1.2;
13
+ const BM25_B = 0.75;
14
+ /** name 分词计两次:命中工具自己的名字比命中描述更能说明意图。 */
15
+ const NAME_WEIGHT = 2;
16
+ /**
17
+ * 小写字母数字连续段。`mcp__github__create_issue` 会切成限定词与动词部分,
18
+ * 这正是模型提问时的用词方式。
19
+ */
20
+ function tokenize(text) {
21
+ return text.toLowerCase().match(/[a-z0-9]+/g) ?? [];
22
+ }
23
+ function counter(tokens) {
24
+ const counts = new Map();
25
+ for (const token of tokens)
26
+ counts.set(token, (counts.get(token) ?? 0) + 1);
27
+ return counts;
28
+ }
29
+ /**
30
+ * 按 BM25 给 `inventory` 打分并排序,最佳在前。
31
+ *
32
+ * 排序而非过滤,但下限仍是过滤:不含任何查询词的文档得 0 分被丢弃——
33
+ * 对词表外的查询返回空,胜过返回一串不相关的工具。
34
+ *
35
+ * 分数本身是导出的,因为与框架实现的等价性要按分数比对:只比名次会漏掉
36
+ * 常量漂移(k1/b/name 权重变了而名次恰好不变)。
37
+ *
38
+ * @param inventory 待打分的工具名录。
39
+ * @param query 模型给出的查询串。
40
+ * @returns 命中的工具及其分数,按分数降序、同分按 name 升序。
41
+ */
42
+ export function scoreTools(inventory, query) {
43
+ const documents = inventory.map(tool => ({
44
+ tool,
45
+ tokens: [
46
+ ...Array.from({ length: NAME_WEIGHT }, () => tokenize(tool.name)).flat(),
47
+ ...tokenize(tool.description),
48
+ ],
49
+ }));
50
+ if (documents.length === 0)
51
+ return [];
52
+ const docFreq = new Map();
53
+ for (const { tokens } of documents) {
54
+ for (const term of new Set(tokens))
55
+ docFreq.set(term, (docFreq.get(term) ?? 0) + 1);
56
+ }
57
+ const nDocs = documents.length;
58
+ const avgLen = documents.reduce((sum, { tokens }) => sum + tokens.length, 0) / nDocs;
59
+ const queryTerms = new Set(tokenize(query));
60
+ const scored = [];
61
+ for (const { tool, tokens } of documents) {
62
+ const termFreq = counter(tokens);
63
+ let score = 0;
64
+ for (const term of queryTerms) {
65
+ const freq = termFreq.get(term) ?? 0;
66
+ if (freq === 0)
67
+ continue;
68
+ const n = docFreq.get(term) ?? 0;
69
+ const idf = Math.log(1 + (nDocs - n + 0.5) / (n + 0.5));
70
+ score +=
71
+ (idf * (freq * (BM25_K1 + 1))) /
72
+ (freq + BM25_K1 * (1 - BM25_B + (BM25_B * tokens.length) / avgLen));
73
+ }
74
+ if (score > 0)
75
+ scored.push({ score, tool });
76
+ }
77
+ scored.sort((a, b) => b.score - a.score || a.tool.name.localeCompare(b.tool.name));
78
+ return scored;
79
+ }
80
+ /**
81
+ * `scoreTools` 的名次部分。
82
+ *
83
+ * @param inventory 待排序的工具名录。
84
+ * @param query 模型给出的查询串。
85
+ * @returns 命中的工具,按分数降序、同分按 name 升序。
86
+ */
87
+ export function rankTools(inventory, query) {
88
+ return scoreTools(inventory, query).map(({ tool }) => tool);
89
+ }
90
+ /** 把请求的条数收进 [1, 封顶] 区间;缺省用框架的默认值。 */
91
+ export function resolveMaxResults(requested) {
92
+ const asked = typeof requested === 'number' && Number.isFinite(requested)
93
+ ? Math.trunc(requested)
94
+ : TOOL_SEARCH_DEFAULT_MAX_RESULTS;
95
+ return Math.max(1, Math.min(asked, TOOL_SEARCH_MAX_RESULTS_CEILING));
96
+ }
package/package.json ADDED
@@ -0,0 +1,67 @@
1
+ {
2
+ "name": "@steerable/agent-shell",
3
+ "version": "0.6.15",
4
+ "description": "Steerable framework — product-neutral desktop/headless agent host (Tier 5). Electron main + preload + headless HTTP server (BS) sharing one storage/sidecar/tooling core; scenario packs extend it through the @steerable/pack-sdk contract and are composed at build time by the consuming product.",
5
+ "license": "Apache-2.0",
6
+ "homepage": "https://steerableframework.com/",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "git+https://github.com/pathlyapp/steerable-framework.git",
10
+ "directory": "packages/agent-shell/ts"
11
+ },
12
+ "bugs": {
13
+ "url": "https://github.com/pathlyapp/steerable-framework/issues"
14
+ },
15
+ "type": "module",
16
+ "main": "dist/runtime.js",
17
+ "exports": {
18
+ "./*": {
19
+ "types": "./dist/*.d.ts",
20
+ "default": "./dist/*.js"
21
+ }
22
+ },
23
+ "files": [
24
+ "dist",
25
+ "contracts",
26
+ "README.md"
27
+ ],
28
+ "publishConfig": {
29
+ "access": "public",
30
+ "provenance": true
31
+ },
32
+ "engines": {
33
+ "node": ">=20"
34
+ },
35
+ "dependencies": {
36
+ "@modelcontextprotocol/sdk": "^1.29.0",
37
+ "better-sqlite3": "^11.9.1",
38
+ "conf": "10.2.0",
39
+ "dotenv": "^17.4.2",
40
+ "electron-log": "^5.4.3",
41
+ "electron-store": "^8.1.0",
42
+ "he": "^1.2.0",
43
+ "node-pty": "^1.1.0",
44
+ "@steerable/agent-harness": "0.6.15",
45
+ "@steerable/pack-sdk": "0.6.15",
46
+ "@steerable/agent-protocol": "0.6.15"
47
+ },
48
+ "devDependencies": {
49
+ "@types/better-sqlite3": "^7.6.13",
50
+ "@types/he": "^1.2.3",
51
+ "@types/node": "^22.10.5",
52
+ "electron": "^28.3.3",
53
+ "typescript": "^5.8.3",
54
+ "vitest": "^3.2.4",
55
+ "esbuild": "^0.25.0"
56
+ },
57
+ "scripts": {
58
+ "gen": "echo agent-shell-ts",
59
+ "build": "tsc -p tsconfig.json && node copy-skills.mjs && node scripts/build-preload.mjs",
60
+ "test": "vitest run",
61
+ "lint": "tsc -p tsconfig.json --noEmit && node scripts/check-shell-neutral.mjs",
62
+ "check:drift": "echo ok",
63
+ "shell:neutral": "node scripts/check-shell-neutral.mjs",
64
+ "web": "ELECTRON_RUN_AS_NODE=1 DEEPPATH_WEB_DIST=${DEEPPATH_WEB_DIST:-../web/app/dist} node node_modules/electron/cli.js dist/server/index.js",
65
+ "client": "DEEPPATH_FORCE_BUNDLED_WEB=1 DEEPPATH_WEB_DIST=${DEEPPATH_WEB_DIST:-../web/app/dist} node node_modules/electron/cli.js dist/main.js"
66
+ }
67
+ }