@picassohq/cli 0.0.0-stage → 1.0.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 (232) hide show
  1. package/agents/browser_agent.yaml +53 -0
  2. package/agents/code_reviewer.yaml +49 -0
  3. package/agents/codebase_investigator.yaml +70 -0
  4. package/agents/design_auditor.yaml +50 -0
  5. package/agents/devex_auditor.yaml +50 -0
  6. package/agents/doc_writer.yaml +54 -0
  7. package/agents/engineering_architect.yaml +51 -0
  8. package/agents/generalist.yaml +55 -0
  9. package/agents/migration_planner.yaml +51 -0
  10. package/agents/product_reviewer.yaml +48 -0
  11. package/agents/qa_operator.yaml +52 -0
  12. package/agents/release_engineer.yaml +50 -0
  13. package/agents/security_auditor.yaml +62 -0
  14. package/agents/test_writer.yaml +52 -0
  15. package/assets/first-light-lockup.png +0 -0
  16. package/assets/first-light-tagline.png +0 -0
  17. package/assets/house/README.md +26 -0
  18. package/assets/house/auraone-banner.png +0 -0
  19. package/assets/house/auraone-logo.png +0 -0
  20. package/assets/house/kiro-prism-banner.png +0 -0
  21. package/assets/house/kiro-prism-logo.png +0 -0
  22. package/assets/house/picasso-banner.png +0 -0
  23. package/assets/house/picasso-logo.png +0 -0
  24. package/assets/wordmark-app.png +0 -0
  25. package/assets/wordmark-tight.png +0 -0
  26. package/assets/wordmark.png +0 -0
  27. package/design/styles.css +1042 -0
  28. package/dist/build-info.json +37 -0
  29. package/dist/index.js +3062 -0
  30. package/goals/cli-hardening.yaml +40 -0
  31. package/goals/repo-maintenance.yaml +40 -0
  32. package/package.json +49 -4
  33. package/runtime/dsh/picasso-ecosystem.community.amendments.yml +24 -0
  34. package/runtime/dsh/picasso-ecosystem.community.json +185 -0
  35. package/runtime/dsh/picasso-ecosystem.community.patch.yml +40 -0
  36. package/runtime/dsh/picasso-ecosystem.cordis.patch.yml +143 -0
  37. package/runtime/dsh/picasso-isolation.patch.yml +25 -0
  38. package/runtime/dsh/picasso-providers.patch.yml +373 -0
  39. package/runtime/dsh/picasso-runtime.cordis.yml +738 -0
  40. package/runtime/dsh/picasso-sdk.patch.yml +204 -0
  41. package/runtime/engine-manifest.json +215 -0
  42. package/runtime/package.json +6 -0
  43. package/runtime/packages/picasso-cache-probe/cordis.patch.yml +5 -0
  44. package/runtime/packages/picasso-cache-probe/index.js +477 -0
  45. package/runtime/packages/picasso-cache-probe/package.json +38 -0
  46. package/runtime/packages/picasso-commands/cordis.patch.yml +4 -0
  47. package/runtime/packages/picasso-commands/fresh-review.js +573 -0
  48. package/runtime/packages/picasso-commands/index.js +497 -0
  49. package/runtime/packages/picasso-commands/package.json +28 -0
  50. package/runtime/packages/picasso-instructions/conflicts.js +115 -0
  51. package/runtime/packages/picasso-instructions/formats.js +145 -0
  52. package/runtime/packages/picasso-instructions/frontmatter.js +175 -0
  53. package/runtime/packages/picasso-instructions/glob.js +114 -0
  54. package/runtime/packages/picasso-instructions/globals.js +90 -0
  55. package/runtime/packages/picasso-instructions/imports.js +123 -0
  56. package/runtime/packages/picasso-instructions/index.js +326 -0
  57. package/runtime/packages/picasso-instructions/modes.js +64 -0
  58. package/runtime/packages/picasso-instructions/package.json +30 -0
  59. package/runtime/packages/picasso-instructions/parse.js +134 -0
  60. package/runtime/packages/picasso-instructions/report.js +161 -0
  61. package/runtime/packages/picasso-instructions/resolve.js +939 -0
  62. package/runtime/packages/picasso-instructions/scan.js +181 -0
  63. package/runtime/packages/picasso-instructions/settings.js +150 -0
  64. package/runtime/packages/picasso-instructions/skills.js +345 -0
  65. package/runtime/packages/picasso-lean-context/cordis.patch.yml +13 -0
  66. package/runtime/packages/picasso-lean-context/index.js +6280 -0
  67. package/runtime/packages/picasso-lean-context/package.json +26 -0
  68. package/runtime/packages/picasso-lean-context/read-image-recovery.js +306 -0
  69. package/runtime/packages/picasso-lean-context/timeline.js +418 -0
  70. package/runtime/packages/picasso-librarian/classify.js +146 -0
  71. package/runtime/packages/picasso-librarian/cordis.patch.yml +10 -0
  72. package/runtime/packages/picasso-librarian/index.js +878 -0
  73. package/runtime/packages/picasso-librarian/notes.js +159 -0
  74. package/runtime/packages/picasso-librarian/package.json +34 -0
  75. package/runtime/packages/picasso-librarian/state.js +478 -0
  76. package/runtime/packages/picasso-memory/index.js +1184 -0
  77. package/runtime/packages/picasso-memory/package.json +21 -0
  78. package/runtime/packages/picasso-model-router/connections.js +912 -0
  79. package/runtime/packages/picasso-model-router/cordis.patch.yml +17 -0
  80. package/runtime/packages/picasso-model-router/index.js +1083 -0
  81. package/runtime/packages/picasso-model-router/package.json +30 -0
  82. package/runtime/packages/picasso-options/cordis.patch.yml +4 -0
  83. package/runtime/packages/picasso-options/index.js +263 -0
  84. package/runtime/packages/picasso-options/package.json +28 -0
  85. package/runtime/packages/picasso-progress-reports/cordis.patch.yml +10 -0
  86. package/runtime/packages/picasso-progress-reports/index.js +267 -0
  87. package/runtime/packages/picasso-progress-reports/package.json +30 -0
  88. package/runtime/packages/picasso-progress-reports/report.js +235 -0
  89. package/runtime/packages/picasso-sdk-server/aside.js +142 -0
  90. package/runtime/packages/picasso-sdk-server/connections.js +38 -0
  91. package/runtime/packages/picasso-sdk-server/context-timeline.js +27 -0
  92. package/runtime/packages/picasso-sdk-server/egress-gate.js +520 -0
  93. package/runtime/packages/picasso-sdk-server/failure-policy.js +246 -0
  94. package/runtime/packages/picasso-sdk-server/file-input.js +169 -0
  95. package/runtime/packages/picasso-sdk-server/goal.js +131 -0
  96. package/runtime/packages/picasso-sdk-server/ignore-file.js +458 -0
  97. package/runtime/packages/picasso-sdk-server/ignore-plugin.js +12 -0
  98. package/runtime/packages/picasso-sdk-server/ignore-sandbox.js +122 -0
  99. package/runtime/packages/picasso-sdk-server/ignore-snapshot.js +131 -0
  100. package/runtime/packages/picasso-sdk-server/image-input.js +44 -0
  101. package/runtime/packages/picasso-sdk-server/index.js +891 -0
  102. package/runtime/packages/picasso-sdk-server/instructions.js +34 -0
  103. package/runtime/packages/picasso-sdk-server/jobs.js +113 -0
  104. package/runtime/packages/picasso-sdk-server/mcp-gate.js +51 -0
  105. package/runtime/packages/picasso-sdk-server/model-selection.js +162 -0
  106. package/runtime/packages/picasso-sdk-server/package.json +50 -0
  107. package/runtime/packages/picasso-sdk-server/picasso-records.js +50 -0
  108. package/runtime/packages/picasso-sdk-server/provider-reload.js +84 -0
  109. package/runtime/packages/picasso-sdk-server/queue.js +322 -0
  110. package/runtime/packages/picasso-sdk-server/requester.js +43 -0
  111. package/runtime/packages/picasso-sdk-server/rewind.js +108 -0
  112. package/runtime/packages/picasso-sdk-server/schedule.js +187 -0
  113. package/runtime/packages/picasso-sdk-server/session-grants.js +35 -0
  114. package/runtime/packages/picasso-sdk-server/session-state.js +118 -0
  115. package/runtime/packages/picasso-sdk-server/shell-paths.js +869 -0
  116. package/runtime/packages/picasso-sdk-server/stream-deltas.js +211 -0
  117. package/runtime/packages/picasso-sdk-server/team-tasks.js +451 -0
  118. package/runtime/packages/picasso-sdk-server/tool-output.js +128 -0
  119. package/runtime/packages/picasso-sdk-server/tools-list.js +51 -0
  120. package/runtime/packages/picasso-sdk-server/wave2-hooks.js +612 -0
  121. package/runtime/packages/picasso-sdk-server/workspace-archive.js +170 -0
  122. package/runtime/packages/picasso-sdk-server/workspace-restore.js +180 -0
  123. package/runtime/packages/picasso-web-search/backends.js +412 -0
  124. package/runtime/packages/picasso-web-search/config.js +121 -0
  125. package/runtime/packages/picasso-web-search/cordis.patch.yml +7 -0
  126. package/runtime/packages/picasso-web-search/failure.js +116 -0
  127. package/runtime/packages/picasso-web-search/format.js +42 -0
  128. package/runtime/packages/picasso-web-search/index.js +71 -0
  129. package/runtime/packages/picasso-web-search/package.json +38 -0
  130. package/runtime/packages/picasso-web-search/router.js +156 -0
  131. package/runtime/packages/picasso-x-reader/circle.js +324 -0
  132. package/runtime/packages/picasso-x-reader/command.js +169 -0
  133. package/runtime/packages/picasso-x-reader/cordis.patch.yml +8 -0
  134. package/runtime/packages/picasso-x-reader/index.js +170 -0
  135. package/runtime/packages/picasso-x-reader/package.json +39 -0
  136. package/runtime/packages/picasso-x-reader/read.js +370 -0
  137. package/runtime/packages/picasso-x-reader/rewrite.js +38 -0
  138. package/runtime/packages/picasso-x-reader/settings.js +131 -0
  139. package/runtime/packages/picasso-x-reader/urls.js +154 -0
  140. package/runtime/packages/picasso-x-reader/xmd.js +512 -0
  141. package/runtime/plugins/picasso-auth-bridge/index.js +380 -0
  142. package/runtime/plugins/picasso-auth-bridge/package.json +28 -0
  143. package/runtime/plugins/picasso-auto-approve/index.js +1003 -0
  144. package/runtime/plugins/picasso-auto-approve/package.json +28 -0
  145. package/runtime/plugins/picasso-browser/index.js +424 -0
  146. package/runtime/plugins/picasso-browser/package.json +28 -0
  147. package/runtime/plugins/picasso-checkpoints/evidence.js +210 -0
  148. package/runtime/plugins/picasso-checkpoints/index.js +885 -0
  149. package/runtime/plugins/picasso-checkpoints/package.json +29 -0
  150. package/runtime/plugins/picasso-commands/fresh-review.js +573 -0
  151. package/runtime/plugins/picasso-commands/index.js +497 -0
  152. package/runtime/plugins/picasso-commands/package.json +28 -0
  153. package/runtime/plugins/picasso-instructions/conflicts.js +115 -0
  154. package/runtime/plugins/picasso-instructions/formats.js +145 -0
  155. package/runtime/plugins/picasso-instructions/frontmatter.js +175 -0
  156. package/runtime/plugins/picasso-instructions/glob.js +114 -0
  157. package/runtime/plugins/picasso-instructions/globals.js +90 -0
  158. package/runtime/plugins/picasso-instructions/imports.js +123 -0
  159. package/runtime/plugins/picasso-instructions/index.js +326 -0
  160. package/runtime/plugins/picasso-instructions/modes.js +64 -0
  161. package/runtime/plugins/picasso-instructions/package.json +30 -0
  162. package/runtime/plugins/picasso-instructions/parse.js +134 -0
  163. package/runtime/plugins/picasso-instructions/report.js +161 -0
  164. package/runtime/plugins/picasso-instructions/resolve.js +939 -0
  165. package/runtime/plugins/picasso-instructions/scan.js +181 -0
  166. package/runtime/plugins/picasso-instructions/settings.js +150 -0
  167. package/runtime/plugins/picasso-instructions/skills.js +345 -0
  168. package/runtime/plugins/picasso-lean-context/index.js +6280 -0
  169. package/runtime/plugins/picasso-lean-context/package.json +26 -0
  170. package/runtime/plugins/picasso-lean-context/read-image-recovery.js +306 -0
  171. package/runtime/plugins/picasso-lean-context/timeline.js +418 -0
  172. package/runtime/plugins/picasso-librarian/classify.js +146 -0
  173. package/runtime/plugins/picasso-librarian/index.js +878 -0
  174. package/runtime/plugins/picasso-librarian/notes.js +159 -0
  175. package/runtime/plugins/picasso-librarian/package.json +34 -0
  176. package/runtime/plugins/picasso-librarian/state.js +478 -0
  177. package/runtime/plugins/picasso-lifecycle-hooks/index.js +186 -0
  178. package/runtime/plugins/picasso-lifecycle-hooks/package.json +25 -0
  179. package/runtime/plugins/picasso-mail/inbox.js +207 -0
  180. package/runtime/plugins/picasso-mail/index.js +293 -0
  181. package/runtime/plugins/picasso-mail/package.json +22 -0
  182. package/runtime/plugins/picasso-memory/index.js +1184 -0
  183. package/runtime/plugins/picasso-memory/package.json +21 -0
  184. package/runtime/plugins/picasso-model-router/connections.js +912 -0
  185. package/runtime/plugins/picasso-model-router/index.js +1083 -0
  186. package/runtime/plugins/picasso-model-router/package.json +30 -0
  187. package/runtime/plugins/picasso-options/index.js +263 -0
  188. package/runtime/plugins/picasso-options/package.json +28 -0
  189. package/runtime/plugins/picasso-progress-reports/index.js +267 -0
  190. package/runtime/plugins/picasso-progress-reports/package.json +30 -0
  191. package/runtime/plugins/picasso-progress-reports/report.js +235 -0
  192. package/runtime/plugins/picasso-provider-models/index.js +436 -0
  193. package/runtime/plugins/picasso-provider-models/package.json +28 -0
  194. package/runtime/plugins/picasso-repo-index/index.js +1850 -0
  195. package/runtime/plugins/picasso-repo-index/package.json +28 -0
  196. package/runtime/plugins/picasso-schedule-pause/index.js +344 -0
  197. package/runtime/plugins/picasso-schedule-pause/package.json +28 -0
  198. package/runtime/plugins/picasso-session-lifecycle/index.js +796 -0
  199. package/runtime/plugins/picasso-session-lifecycle/package.json +28 -0
  200. package/runtime/plugins/picasso-trackers/index.js +895 -0
  201. package/runtime/plugins/picasso-trackers/package.json +28 -0
  202. package/runtime/plugins/picasso-web-search/backends.js +412 -0
  203. package/runtime/plugins/picasso-web-search/config.js +121 -0
  204. package/runtime/plugins/picasso-web-search/failure.js +116 -0
  205. package/runtime/plugins/picasso-web-search/format.js +42 -0
  206. package/runtime/plugins/picasso-web-search/index.js +71 -0
  207. package/runtime/plugins/picasso-web-search/package.json +38 -0
  208. package/runtime/plugins/picasso-web-search/router.js +156 -0
  209. package/runtime/plugins/picasso-x-reader/circle.js +324 -0
  210. package/runtime/plugins/picasso-x-reader/command.js +169 -0
  211. package/runtime/plugins/picasso-x-reader/index.js +170 -0
  212. package/runtime/plugins/picasso-x-reader/package.json +39 -0
  213. package/runtime/plugins/picasso-x-reader/read.js +370 -0
  214. package/runtime/plugins/picasso-x-reader/rewrite.js +38 -0
  215. package/runtime/plugins/picasso-x-reader/settings.js +131 -0
  216. package/runtime/plugins/picasso-x-reader/urls.js +154 -0
  217. package/runtime/plugins/picasso-x-reader/xmd.js +512 -0
  218. package/runtime/relay/attachment-text.mjs +737 -0
  219. package/runtime/relay/companion/companion.css +126 -0
  220. package/runtime/relay/companion/companion.js +648 -0
  221. package/runtime/relay/companion/icon.svg +5 -0
  222. package/runtime/relay/companion/index.html +25 -0
  223. package/runtime/relay/companion/manifest.json +13 -0
  224. package/runtime/relay/companion/sw.js +41 -0
  225. package/runtime/relay/main.mjs +38580 -0
  226. package/runtime/relay/model-listing.mjs +614 -0
  227. package/runtime/relay/versions-routes.mjs +1400 -0
  228. package/runtime/verify-plugins.mjs +205 -0
  229. package/runtime-lock/package-lock.json +10779 -0
  230. package/runtime-lock/package.json +7 -0
  231. package/scripts/install-runtime.mjs +400 -0
  232. package/README.md +0 -3
@@ -0,0 +1,34 @@
1
+ // `session/instructions { sessionId, cwd? }` -> what instructions the session follows, where they came from and why
2
+ // (`@picasso/instructions`' `instructions` service). `session/instructions/activate { sessionId, name }` loads a
3
+ // manual, model-selected or scoped rule into the session as a Tier-2 reminder on its next step. The TUI's
4
+ // /instructions and the /context section read these; the Mac reads the same service through Host Remote
5
+ // (`instructions/describe`, `instructions/activate`).
6
+
7
+ export const INSTRUCTIONS_METHOD = 'session/instructions';
8
+ export const INSTRUCTIONS_ACTIVATE_METHOD = 'session/instructions/activate';
9
+ export const INSTRUCTIONS_METHODS = Object.freeze([INSTRUCTIONS_METHOD, INSTRUCTIONS_ACTIVATE_METHOD]);
10
+
11
+ /**
12
+ * @param {{ instructions: () => { describe(params: object): Promise<unknown>, activate(params: object): Promise<unknown> } | undefined }} deps
13
+ */
14
+ export function createInstructions({ instructions }) {
15
+ const service = () => {
16
+ const found = instructions();
17
+ // C1: without the plugin there is nothing to describe; say so instead of answering an empty list.
18
+ if (found === undefined || found === null || typeof found.describe !== 'function') {
19
+ throw new Error('instruction discovery is not available (the instructions plugin is not loaded)');
20
+ }
21
+ return found;
22
+ };
23
+ return {
24
+ methods: {
25
+ async [INSTRUCTIONS_METHOD](params) {
26
+ return service().describe({ sessionId: params?.sessionId, cwd: params?.cwd });
27
+ },
28
+ async [INSTRUCTIONS_ACTIVATE_METHOD](params) {
29
+ if (typeof params?.name !== 'string' || params.name.trim() === '') throw new TypeError('a rule name is required');
30
+ return service().activate({ sessionId: params?.sessionId, name: params.name });
31
+ },
32
+ },
33
+ };
34
+ }
@@ -0,0 +1,113 @@
1
+ // Client-invokable job control over the mounted job registry (`ctx.jobs`,
2
+ // @deepseek-ai/dsh-jobs JobRegistry — in this runtime `dsh-jobs-local`):
3
+ //
4
+ // job/list { sessionId } -> { jobs: [JobView-ish] }
5
+ // job/kill { sessionId, jobId, reason? } -> { status: 'requested' | 'already-finished' }
6
+ //
7
+ // The registry fences every lookup by the owner SessionId: `caller` is the
8
+ // request's `sessionId`, so a client can only see and stop the jobs its own
9
+ // session owns (plus unowned jobs, which every session sees). The session
10
+ // must be a live attached one first (`session/not-found` otherwise, matching
11
+ // queue.js); unknown or foreign ids then refuse with `job/not-found`, the
12
+ // Remote API's (`dsh-api-job-controller`) code, and `job/unavailable` reports
13
+ // a runtime without the registry mounted.
14
+ //
15
+ // Rows mirror the `job/registered` / `job/settled` vocabulary the projected
16
+ // events already speak: the registry's `id` becomes `jobId`, its `label`
17
+ // becomes `title`, and the lifecycle status rides flat (running | stopping |
18
+ // completed | killed | failed), so the /tasks merge needs no second shape.
19
+ // `job/follow`'s observation stream stays out of scope — `session.delta`
20
+ // `tool-output` chunks already carry live job output to the client.
21
+
22
+ export const JOB_METHODS = Object.freeze(['job/list', 'job/kill']);
23
+
24
+ /** An honest JSON-RPC refusal; `code` prefixes the message (queue.js's convention) and `data` carries structured context. */
25
+ export class JobError extends Error {
26
+ constructor(code, message, data = {}) {
27
+ super(`${code}: ${message}`);
28
+ this.name = 'JobError';
29
+ this.code = code;
30
+ this.data = data;
31
+ }
32
+ }
33
+
34
+ /** The wire row for one registry `JobView` (dsh-jobs `view.d.ts`). */
35
+ export function jobRow(view) {
36
+ return {
37
+ jobId: String(view.id),
38
+ kind: String(view.kind ?? ''),
39
+ title: String(view.label ?? ''),
40
+ ...(view.owner === undefined ? {} : { owner: String(view.owner) }),
41
+ status: view.status,
42
+ ...(view.progress === undefined ? {} : { progress: String(view.progress) }),
43
+ ...(view.detail === undefined ? {} : { detail: String(view.detail) }),
44
+ startedAt: view.startedAt,
45
+ ...(view.finishedAt === undefined ? {} : { finishedAt: view.finishedAt }),
46
+ ...(view.output === undefined
47
+ ? {}
48
+ : {
49
+ output: {
50
+ total: view.output.total,
51
+ earliest: view.output.earliest,
52
+ ...(view.output.spillPaths === undefined ? {} : { spillPaths: [...view.output.spillPaths] }),
53
+ },
54
+ }),
55
+ };
56
+ }
57
+
58
+ /**
59
+ * @param {object} deps
60
+ * @param {() => any} deps.jobs - resolves the mounted JobRegistry (or undefined).
61
+ * Resolved per call so this plugin boots before the registry and reports
62
+ * `job/unavailable` instead of failing construction.
63
+ * @param {(sessionId: string) => any} deps.agentFor - the live-session lookup
64
+ * (index.js's `agentFor`); the session must be attached for either verb.
65
+ */
66
+ export function createJobs({ jobs, agentFor }) {
67
+ const registry = () => {
68
+ const service = jobs();
69
+ if (service === undefined || typeof service.list !== 'function' || typeof service.kill !== 'function') {
70
+ throw new JobError('job/unavailable', 'Background jobs are not available in this runtime.');
71
+ }
72
+ return service;
73
+ };
74
+ const requireSession = (params, method) => {
75
+ if (typeof params?.sessionId !== 'string' || params.sessionId.length === 0) {
76
+ throw new JobError('gateway/bad-request', `${method} requires a non-empty sessionId`);
77
+ }
78
+ if (agentFor(params.sessionId) === undefined) {
79
+ throw new JobError('session/not-found', `session "${params.sessionId}" not found (not attached)`, { sessionId: params.sessionId });
80
+ }
81
+ return params.sessionId;
82
+ };
83
+ /** Registry refusals (unknown or foreign id) collapse to the Remote API's job/not-found. */
84
+ const fenced = (run, sessionId, jobId) => {
85
+ try {
86
+ return run();
87
+ } catch (error) {
88
+ if (error instanceof JobError) throw error;
89
+ throw new JobError('job/not-found', `no job "${jobId}" in session "${sessionId}"'s visible jobs`, {
90
+ sessionId,
91
+ jobId,
92
+ ...(error instanceof Error && error.message.length > 0 ? { detail: error.message } : {}),
93
+ });
94
+ }
95
+ };
96
+ const methods = {
97
+ async 'job/list'(params) {
98
+ const sessionId = requireSession(params, 'job/list');
99
+ const views = fenced(() => registry().list(sessionId), sessionId, '*');
100
+ return { jobs: views.map(jobRow) };
101
+ },
102
+ async 'job/kill'(params) {
103
+ const sessionId = requireSession(params, 'job/kill');
104
+ if (typeof params?.jobId !== 'string' || params.jobId.length === 0) {
105
+ throw new JobError('gateway/bad-request', 'job/kill requires a non-empty jobId');
106
+ }
107
+ const reason = typeof params.reason === 'string' && params.reason.length > 0 ? params.reason : undefined;
108
+ const status = fenced(() => registry().kill(params.jobId, sessionId, reason), sessionId, params.jobId);
109
+ return { status };
110
+ },
111
+ };
112
+ return { methods };
113
+ }
@@ -0,0 +1,51 @@
1
+ // Per-call approval gate for MCP connector tools (docs/mcp-connector-review.md
2
+ // condition 1 — the review admitted `@deepseek-ai/dsh-mcp-client` only on the
3
+ // condition that `mcp__*` calls never run ungated).
4
+ //
5
+ // The connector's tools register on `ctx.tools` so every call rides the shared
6
+ // `tools/pre-execute` waterfall, but the shipped dsh composition emits no
7
+ // ask/deny for them — the waterfall's default is allow. This listener is that
8
+ // gate: any tool name in the MCP vocabulary returns an `ask` decision, which
9
+ // the dsh-tools dispatcher resolves through `ctx.approval` (fail-closed — no
10
+ // answerer means `unavailable`, which is a deny). The TUI already renders
11
+ // `mcp__` asks (apps/cli/src/approval-details.ts).
12
+ //
13
+ // mcp__<server>__<tool> third-party server tool calls
14
+ // list_mcp_resources shared resource discovery
15
+ // list_mcp_resource_templates shared template discovery
16
+ // read_mcp_resource shared resource reads
17
+ //
18
+ // User override stays possible in both waterfall orders: if a
19
+ // `dsh-permission-rules` rule (`.dsh/rules.yaml`) matches first it can allow
20
+ // or deny before we run; if we run first the ask still reaches the user, who
21
+ // can write a narrower allow rule for a server they trust.
22
+ //
23
+ // The gate is unconditional — there is no config to widen it. Condition 1 is
24
+ // an admission requirement, not a preference; a session that wants a quieter
25
+ // path narrows it with an explicit rules file the user can audit, never with
26
+ // a flag here.
27
+ //
28
+ // No JSON-RPC methods are added; the module exists only for its listener.
29
+
30
+ const MCP_SHARED_TOOLS = Object.freeze(
31
+ new Set(['list_mcp_resources', 'list_mcp_resource_templates', 'read_mcp_resource']),
32
+ );
33
+
34
+ /** `mcp__<server>__<tool>` — the connector's normalization keeps the double underscores. */
35
+ function isMcpToolName(name) {
36
+ return typeof name === 'string' && (name.startsWith('mcp__') || MCP_SHARED_TOOLS.has(name));
37
+ }
38
+
39
+ export function createMcpGate() {
40
+ const install = (ctx) =>
41
+ ctx.on('tools/pre-execute', async (exec, next) => {
42
+ const name = exec?.name;
43
+ if (!isMcpToolName(name)) return next();
44
+ return {
45
+ kind: 'ask',
46
+ reason: `MCP tool "${name}" — third-party MCP server call requires per-call approval (admission condition, docs/mcp-connector-review.md).`,
47
+ };
48
+ });
49
+
50
+ return { install };
51
+ }
@@ -0,0 +1,162 @@
1
+ // Live model switch for a running session, the SDK twin of dsh's web
2
+ // controller `selectModel` (dsh-api-session-controller):
3
+ //
4
+ // session/model/set { sessionId, provider, model, reasoningEffort? }
5
+ // -> { selected: { provider, model, reasoningEffort? } }
6
+ // The exact model must be advertised by `ctx.llm` (`listProviders` +
7
+ // `listModels`, dsh's `modelAvailable`), then `resolveCallConfig`
8
+ // normalizes it. The selection is recorded as dsh's own durable
9
+ // `model/selection` event (the `modelSelection` projection / Picasso's
10
+ // `model-selected`) and installed with dsh-agent's `installModelSelection`,
11
+ // so the next model request (a later step of a running turn, or the next
12
+ // turn) uses it: prompt variables, request provider/model/effort and the
13
+ // model-change notice all follow dsh's own coupling.
14
+ // session/model/get { sessionId }
15
+ // -> { provider, model, reasoningEffort?, source: 'selected' | 'request' | 'default' }
16
+ // session/model/catalog { models: [{ provider, model }] }
17
+ // -> { models: [{ provider, model, reasoning?: { efforts: [{ id, name }], defaultEffort? } } | { provider, model, error }] }
18
+ // The reasoning levels each exact route accepts, read from the adapter that
19
+ // owns it (`ctx.llm.resolveModelInfo`, the same metadata dsh's
20
+ // `session/modelCatalog` serves and `resolveCallConfig` validates against).
21
+ // No `reasoning` means the model takes no effort control. One route's
22
+ // failure is reported on its entry and never fails the others.
23
+ //
24
+ // Errors carry dsh's codes as a `code: message` prefix: session/not-found,
25
+ // session/model-unavailable, gateway/bad-request.
26
+
27
+ export const MODEL_METHODS = Object.freeze(['session/model/set', 'session/model/get', 'session/model/catalog']);
28
+
29
+ /** Most routes one `session/model/catalog` call resolves. */
30
+ const CATALOG_MAX_MODELS = 400;
31
+
32
+ export class ModelSelectionError extends Error {
33
+ constructor(code, message, data = {}) {
34
+ super(`${code}: ${message}`);
35
+ this.name = 'ModelSelectionError';
36
+ this.code = code;
37
+ this.data = data;
38
+ }
39
+ }
40
+
41
+ const nonEmpty = (value) => typeof value === 'string' && value.length > 0;
42
+
43
+ function normalized(selection) {
44
+ return {
45
+ provider: selection.provider,
46
+ model: selection.model,
47
+ ...(selection.reasoningEffort === undefined ? {} : { reasoningEffort: String(selection.reasoningEffort) }),
48
+ };
49
+ }
50
+
51
+ /**
52
+ * @param {object} deps
53
+ * @param {(sessionId: string) => any} deps.agentFor - the live agent (undefined when not attached).
54
+ * @param {() => any} deps.llm - dsh's LLM registry (`ctx.llm`).
55
+ * @param {(agentCtx: any, selection: any) => () => void} deps.install - dsh-agent's `installModelSelection`.
56
+ * @param {() => { provider: string, model: string, reasoningEffort?: string }} deps.defaults - the initialized SDK route.
57
+ */
58
+ export function createModelSelection({ agentFor, llm, install, defaults }) {
59
+ /** Per-agent mutable selection consumed by dsh's prompt assembly and request routing. */
60
+ const selections = new WeakMap();
61
+
62
+ const requireAgent = (params) => {
63
+ if (!nonEmpty(params?.sessionId)) throw new ModelSelectionError('gateway/bad-request', 'a non-empty sessionId is required');
64
+ const agent = agentFor(params.sessionId);
65
+ if (agent === undefined) throw new ModelSelectionError('session/not-found', `session "${params.sessionId}" not found (not attached)`, { sessionId: params.sessionId });
66
+ return agent;
67
+ };
68
+
69
+ const selectionFor = (agent) => {
70
+ let selection = selections.get(agent);
71
+ if (selection !== undefined) return selection;
72
+ let picked;
73
+ selection = {
74
+ get current() {
75
+ return picked;
76
+ },
77
+ set current(next) {
78
+ picked = next;
79
+ },
80
+ assembled: undefined,
81
+ };
82
+ install(agent.ctx, selection);
83
+ selections.set(agent, selection);
84
+ return selection;
85
+ };
86
+
87
+ const available = async (registry, provider, model) => {
88
+ if (!registry.listProviders().some((entry) => entry.id === provider)) return false;
89
+ let models;
90
+ try {
91
+ models = await registry.listModels(provider);
92
+ } catch (error) {
93
+ throw new ModelSelectionError('session/model-unavailable', error instanceof Error ? error.message : String(error), { provider, model });
94
+ }
95
+ return models.some((entry) => entry.id === model);
96
+ };
97
+
98
+ const methods = {
99
+ async 'session/model/set'(params) {
100
+ const agent = requireAgent(params);
101
+ const { provider, model, reasoningEffort } = params;
102
+ if (!nonEmpty(provider) || !nonEmpty(model)) throw new ModelSelectionError('gateway/bad-request', 'session/model/set requires non-empty provider and model');
103
+ if (reasoningEffort !== undefined && !nonEmpty(reasoningEffort)) throw new ModelSelectionError('gateway/bad-request', 'reasoningEffort must be a non-empty string');
104
+ const registry = llm();
105
+ if (registry === undefined) throw new ModelSelectionError('session/model-unavailable', 'the LLM registry is not mounted', { provider, model });
106
+ if (!await available(registry, provider, model)) {
107
+ throw new ModelSelectionError('session/model-unavailable', `model "${model}" is not available from provider "${provider}"`, { provider, model });
108
+ }
109
+ let selected;
110
+ try {
111
+ selected = normalized(await registry.resolveCallConfig({ provider, model, ...(reasoningEffort === undefined ? {} : { reasoningEffort }) }));
112
+ } catch (error) {
113
+ throw new ModelSelectionError('session/model-unavailable', error instanceof Error ? error.message : String(error), { provider, model });
114
+ }
115
+ if (agentFor(params.sessionId) !== agent) throw new ModelSelectionError('session/not-found', `session "${params.sessionId}" was disposed during model selection`, { sessionId: params.sessionId });
116
+ const selection = selectionFor(agent);
117
+ agent.session.append('model/selection', selected);
118
+ selection.current = selected;
119
+ return { selected: { ...selected } };
120
+ },
121
+ async 'session/model/get'(params) {
122
+ const agent = requireAgent(params);
123
+ const picked = selections.get(agent)?.current;
124
+ if (picked !== undefined) return { ...normalized(picked), source: 'selected' };
125
+ const config = agent.session?.requestHeader?.()?.config;
126
+ if (nonEmpty(config?.provider) && nonEmpty(config?.model)) return { ...normalized(config), source: 'request' };
127
+ return { ...normalized(defaults()), source: 'default' };
128
+ },
129
+ async 'session/model/catalog'(params) {
130
+ const requested = Array.isArray(params?.models) ? params.models : undefined;
131
+ if (requested === undefined) throw new ModelSelectionError('gateway/bad-request', 'session/model/catalog requires a models array');
132
+ const registry = llm();
133
+ if (registry === undefined) throw new ModelSelectionError('session/model-unavailable', 'the LLM registry is not mounted');
134
+ const pairs = requested
135
+ .filter((entry) => nonEmpty(entry?.provider) && nonEmpty(entry?.model))
136
+ .slice(0, CATALOG_MAX_MODELS);
137
+ const models = await Promise.all(pairs.map(async ({ provider, model }) => {
138
+ try {
139
+ const info = await registry.resolveModelInfo(provider, model);
140
+ const efforts = Array.isArray(info?.reasoning?.efforts)
141
+ ? info.reasoning.efforts.filter((effort) => nonEmpty(effort?.id)).map((effort) => ({ id: effort.id, name: nonEmpty(effort.name) ? effort.name : effort.id }))
142
+ : [];
143
+ if (efforts.length === 0) return { provider, model };
144
+ const defaultEffort = info.reasoning.defaultEffort;
145
+ return {
146
+ provider,
147
+ model,
148
+ reasoning: { efforts, ...(nonEmpty(defaultEffort) && efforts.some((effort) => effort.id === defaultEffort) ? { defaultEffort } : {}) },
149
+ };
150
+ } catch (error) {
151
+ return { provider, model, error: error instanceof Error ? error.message : String(error) };
152
+ }
153
+ }));
154
+ return { models };
155
+ },
156
+ };
157
+
158
+ /** The live selection of an agent, without installing one. */
159
+ const selectedFor = (agent) => selections.get(agent)?.current;
160
+
161
+ return { methods, selectionFor, selectedFor };
162
+ }
@@ -0,0 +1,50 @@
1
+ {
2
+ "name": "@picasso/sdk-server",
3
+ "version": "0.1.0",
4
+ "private": true,
5
+ "description": "dsh cordis plugin: the stock SDK JSON-RPC server plus Picasso's approval/question responder, cancel, command run and workspace change/restore methods.",
6
+ "type": "module",
7
+ "main": "index.js",
8
+ "exports": {
9
+ ".": "./index.js",
10
+ "./package.json": "./package.json"
11
+ },
12
+ "files": [
13
+ "index.js",
14
+ "aside.js",
15
+ "context-timeline.js",
16
+ "instructions.js",
17
+ "egress-gate.js",
18
+ "failure-policy.js",
19
+ "file-input.js",
20
+ "ignore-file.js",
21
+ "ignore-plugin.js",
22
+ "ignore-sandbox.js",
23
+ "ignore-snapshot.js",
24
+ "image-input.js",
25
+ "jobs.js",
26
+ "mcp-gate.js",
27
+ "model-selection.js",
28
+ "connections.js",
29
+ "picasso-records.js",
30
+ "provider-reload.js",
31
+ "queue.js",
32
+ "requester.js",
33
+ "rewind.js",
34
+ "schedule.js",
35
+ "session-grants.js",
36
+ "tools-list.js",
37
+ "session-state.js",
38
+ "shell-paths.js",
39
+ "stream-deltas.js",
40
+ "team-tasks.js",
41
+ "tool-output.js",
42
+ "wave2-hooks.js",
43
+ "workspace-archive.js",
44
+ "workspace-restore.js"
45
+ ],
46
+ "scripts": {
47
+ "test": "node --import ../../test/setup/hermetic-preload.mjs --test test/*.test.js"
48
+ },
49
+ "license": "UNLICENSED"
50
+ }
@@ -0,0 +1,50 @@
1
+ // Picasso-owned session events in dsh's own log.
2
+ //
3
+ // session/picasso/record { sessionId, records: [{ kind, event }] }
4
+ // -> { appended, seqs }
5
+ //
6
+ // Memory, goal, cache-probe, pricing, plan and permission events are Picasso's,
7
+ // not dsh's, but they belong to the conversation: they must survive resume and
8
+ // fork with it. Each one is appended to the live session as an ignorable dsh
9
+ // plugin record (`plugin:picasso/<kind>`, dsh-session `appendPluginRecord`):
10
+ // dsh keeps the record in its durable log, carries it through fork and resume
11
+ // and never shows it to the model. Readers unwrap the records again
12
+ // (@picasso/sessions dsh-log.ts `dshSessionEvents`), so Picasso keeps no second
13
+ // journal beside dsh's log.
14
+
15
+ export const RECORD_METHODS = Object.freeze(['session/picasso/record']);
16
+ export const PICASSO_RECORD_PREFIX = 'plugin:picasso/';
17
+ const KIND = /^[a-z0-9][a-z0-9._-]*$/u;
18
+ const MAX_RECORDS = 256;
19
+
20
+ /** The record kind for a Picasso session event type (`cache-usage` → `cache-usage`, `Odd Type!` → `event`). */
21
+ export function recordKind(kind) {
22
+ const normalized = String(kind ?? '').toLowerCase();
23
+ return KIND.test(normalized) ? normalized : 'event';
24
+ }
25
+
26
+ /**
27
+ * @param {object} deps
28
+ * @param {(sessionId: string) => any} deps.sessionFor - the live dsh Session (throws when not attached).
29
+ * @param {(session: any, type: string, data: unknown) => number} deps.appendPluginRecord - dsh-session's appender.
30
+ */
31
+ export function createPicassoRecords({ sessionFor, appendPluginRecord }) {
32
+ const methods = {
33
+ async 'session/picasso/record'(params) {
34
+ if (typeof params?.sessionId !== 'string' || params.sessionId.length === 0) throw new TypeError('a non-empty sessionId is required');
35
+ if (!Array.isArray(params.records)) throw new TypeError('records must be an array');
36
+ if (params.records.length > MAX_RECORDS) throw new RangeError(`at most ${MAX_RECORDS} records per call`);
37
+ const session = sessionFor(params.sessionId);
38
+ if (session === undefined) throw new Error(`session ${params.sessionId} is not attached`);
39
+ const prepared = params.records.map((record, index) => {
40
+ if (record === null || typeof record !== 'object' || record.event === null || typeof record.event !== 'object' || Array.isArray(record.event)) {
41
+ throw new TypeError(`records[${index}].event must be an object`);
42
+ }
43
+ return { type: `${PICASSO_RECORD_PREFIX}${recordKind(record.kind ?? record.event.type)}`, data: { event: JSON.parse(JSON.stringify(record.event)) } };
44
+ });
45
+ const seqs = prepared.map(({ type, data }) => appendPluginRecord(session, type, data));
46
+ return { appended: seqs.length, seqs };
47
+ },
48
+ };
49
+ return { methods };
50
+ }
@@ -0,0 +1,84 @@
1
+ // Live provider routes for a running CLI/TUI engine (the shared provider store changed: the Mac app or another
2
+ // terminal added, edited or removed a route, or a key-backed built-in joined it).
3
+ //
4
+ // providers/reload { patch, previous } -> { added, changed, removed }
5
+ //
6
+ // `patch` is the providers overlay the CLI composed again (packages/core runtime-session.ts `currentProviderOverlay`:
7
+ // the bundled catalogue + the home's layers, the shared store highest); `previous` is the overlay this engine runs
8
+ // (launched with, or last applied). Both are parsed the way the launcher parses an overlay (`loadOverlayPatches`).
9
+ // The new overlay's `llm-pi-ai` routes replace the running entry's, with their `!!js` values evaluated the way the
10
+ // loader evaluated them at launch (`interpolate` against the entry's context: the loader's volatile commit resolves a
11
+ // candidate on the plugin's inner fiber, where no `!!js` is evaluated, so a raw expression would be refused there).
12
+ // The adapter's `providers` setting is volatile, so the loader commits it in place and the adapter re-registers its
13
+ // routes (`loader/volatile-update`): no plugin restart, no tool or prompt change, so the tools -> system -> Tier 1
14
+ // prefix stays byte-identical. Nothing is persisted: the next launch composes the same overlay from the files.
15
+ //
16
+ // A change this cannot apply exactly answers an error and leaves the engine as it was (the caller offers a restart):
17
+ // a change to the row's settings beyond its routes, or an engine whose loader did not take the routes.
18
+ //
19
+ // C1: a runtime without the loader or the entry answers an error; nothing is synthesized.
20
+
21
+ export const PROVIDER_RELOAD_METHODS = Object.freeze(['providers/reload']);
22
+
23
+ const PROVIDERS_ENTRY = 'llm-pi-ai';
24
+ const PROVIDERS_ENTRY_NAME = '@deepseek-ai/dsh-llm-pi-ai';
25
+
26
+ const isRecord = (value) => value !== null && typeof value === 'object' && !Array.isArray(value);
27
+ const same = (left, right) => JSON.stringify(left) === JSON.stringify(right);
28
+
29
+ /** The overlay's `llm-pi-ai` row config (the last plain row naming it), split into its routes and the rest. */
30
+ function providerRow(rows) {
31
+ const row = (Array.isArray(rows) ? rows : [])
32
+ .filter((candidate) => isRecord(candidate) && (candidate.id === PROVIDERS_ENTRY || candidate.name === PROVIDERS_ENTRY_NAME) && candidate.insert === undefined)
33
+ .at(-1);
34
+ if (row === undefined || !isRecord(row.config)) throw new Error('providers/reload: the overlay has no provider routes row');
35
+ const { providers, ...rest } = row.config;
36
+ return { providers: isRecord(providers) ? providers : {}, rest };
37
+ }
38
+
39
+ /**
40
+ * @param {object} deps
41
+ * @param {() => any} deps.loader - the running loader (`ctx.get('loader')`).
42
+ * @param {(file: string) => Promise<unknown[]>} deps.loadOverlay - parses an overlay file the way the engine's launcher
43
+ * does (`loadOverlayPatches` of the engine's app boot).
44
+ * @param {() => Promise<(ctx: any, value: unknown) => unknown>} deps.interpolate - the loader's own `!!js` evaluation.
45
+ */
46
+ export function createProviderReload({ loader, loadOverlay, interpolate }) {
47
+ return {
48
+ methods: {
49
+ async 'providers/reload'(params) {
50
+ const file = params?.patch;
51
+ const previousFile = params?.previous;
52
+ if (typeof file !== 'string' || file.length === 0 || typeof previousFile !== 'string' || previousFile.length === 0) {
53
+ throw new TypeError('providers/reload requires patch (the composed providers overlay) and previous (the one this engine runs)');
54
+ }
55
+ const next = providerRow(await loadOverlay(file));
56
+ const previous = providerRow(await loadOverlay(previousFile));
57
+ if (!same(next.rest, previous.rest)) throw new Error('providers/reload: the provider settings beyond the routes changed; restart to apply them');
58
+ const added = Object.keys(next.providers).filter((id) => !(id in previous.providers));
59
+ const removed = Object.keys(previous.providers).filter((id) => !(id in next.providers));
60
+ const changed = Object.keys(next.providers).filter((id) => id in previous.providers && !same(previous.providers[id], next.providers[id]));
61
+ if (added.length + changed.length + removed.length === 0) return { added, changed, removed };
62
+ const tree = loader();
63
+ if (tree === undefined || typeof tree.entries !== 'function') throw new Error('providers/reload: this runtime has no loader');
64
+ const entry = [...tree.entries()].find((candidate) => candidate?.options?.id === PROVIDERS_ENTRY);
65
+ if (entry === undefined || typeof entry.update !== 'function' || !isRecord(entry.options?.config) || entry.fiber?.ctx === undefined) {
66
+ throw new Error('providers/reload: this runtime has no provider routes entry');
67
+ }
68
+ const evaluate = await interpolate();
69
+ const providers = evaluate(entry.fiber.ctx, next.providers);
70
+ // Only `config.providers` changes; the entry's other options (name, group, disabled) stay as launched.
71
+ const launched = entry.options.config;
72
+ await entry.update({ config: { ...launched, providers } });
73
+ // The loader logs (never throws) a candidate it could not commit: check the routes are served as written.
74
+ const effective = entry.fiber?.ctx?.fiber?.effectiveConfig?.providers;
75
+ const served = typeof effective?.get === 'function' ? effective.get() : undefined;
76
+ if (!isRecord(served) || added.some((id) => !(id in served)) || removed.some((id) => id in served)) {
77
+ await entry.update({ config: launched }).catch(() => undefined);
78
+ throw new Error('providers/reload: the engine did not take the new routes; restart to apply them');
79
+ }
80
+ return { added, changed, removed };
81
+ },
82
+ },
83
+ };
84
+ }