@picassohq/cli 1.0.3 → 1.0.5

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 (64) hide show
  1. package/dist/build-info.json +2 -1
  2. package/dist/index.js +1860 -1316
  3. package/package.json +1 -1
  4. package/runtime/dsh/picasso-ecosystem.cordis.patch.yml +4 -7
  5. package/runtime/dsh/picasso-sdk.patch.yml +47 -0
  6. package/runtime/engine-manifest.json +37 -16
  7. package/runtime/packages/picasso-compaction/cordis.patch.yml +4 -0
  8. package/runtime/packages/picasso-compaction/index.js +875 -0
  9. package/runtime/packages/picasso-compaction/package.json +27 -0
  10. package/runtime/packages/picasso-hooks/cordis.patch.yml +4 -0
  11. package/runtime/packages/picasso-hooks/index.js +302 -0
  12. package/runtime/packages/picasso-hooks/lifecycle-events.js +651 -0
  13. package/runtime/packages/picasso-hooks/package.json +29 -0
  14. package/runtime/packages/picasso-lean-context/argument-repair.js +422 -0
  15. package/runtime/packages/picasso-lean-context/glob-walk.js +518 -0
  16. package/runtime/packages/picasso-lean-context/index.js +159 -11
  17. package/runtime/packages/picasso-memory/index.js +66 -24
  18. package/runtime/packages/picasso-model-router/connections.js +213 -10
  19. package/runtime/packages/picasso-model-router/index.js +128 -1
  20. package/runtime/packages/picasso-model-router/package.json +3 -1
  21. package/runtime/packages/picasso-model-router/thinking-default.js +236 -0
  22. package/runtime/packages/picasso-progress-reports/index.js +128 -18
  23. package/runtime/packages/picasso-sdk-server/command-runs.js +37 -0
  24. package/runtime/packages/picasso-sdk-server/ignore-file.js +5 -1
  25. package/runtime/packages/picasso-sdk-server/index.js +11 -3
  26. package/runtime/packages/picasso-sdk-server/package.json +1 -0
  27. package/runtime/packages/picasso-sdk-server/wave2-hooks.js +26 -6
  28. package/runtime/packages/picasso-web-search/backends.js +245 -195
  29. package/runtime/packages/picasso-web-search/config.js +75 -27
  30. package/runtime/packages/picasso-web-search/cordis.patch.yml +2 -1
  31. package/runtime/packages/picasso-web-search/failure.js +7 -1
  32. package/runtime/packages/picasso-web-search/index.js +7 -5
  33. package/runtime/packages/picasso-web-search/package.json +6 -0
  34. package/runtime/packages/picasso-web-search/requests.js +339 -0
  35. package/runtime/packages/picasso-web-search/router.js +17 -12
  36. package/runtime/packages/picasso-x-reader/settings.js +4 -1
  37. package/runtime/plugins/picasso-auto-approve/index.js +21 -8
  38. package/runtime/plugins/picasso-compaction/index.js +875 -0
  39. package/runtime/plugins/picasso-compaction/package.json +27 -0
  40. package/runtime/plugins/picasso-hooks/index.js +302 -0
  41. package/runtime/plugins/picasso-hooks/lifecycle-events.js +651 -0
  42. package/runtime/plugins/picasso-hooks/package.json +29 -0
  43. package/runtime/plugins/picasso-lean-context/argument-repair.js +422 -0
  44. package/runtime/plugins/picasso-lean-context/glob-walk.js +518 -0
  45. package/runtime/plugins/picasso-lean-context/index.js +159 -11
  46. package/runtime/plugins/picasso-memory/index.js +66 -24
  47. package/runtime/plugins/picasso-model-router/connections.js +213 -10
  48. package/runtime/plugins/picasso-model-router/index.js +128 -1
  49. package/runtime/plugins/picasso-model-router/package.json +3 -1
  50. package/runtime/plugins/picasso-model-router/thinking-default.js +236 -0
  51. package/runtime/plugins/picasso-progress-reports/index.js +128 -18
  52. package/runtime/plugins/picasso-provider-models/index.js +236 -4
  53. package/runtime/plugins/picasso-trackers/index.js +12 -2
  54. package/runtime/plugins/picasso-web-search/backends.js +245 -195
  55. package/runtime/plugins/picasso-web-search/config.js +75 -27
  56. package/runtime/plugins/picasso-web-search/failure.js +7 -1
  57. package/runtime/plugins/picasso-web-search/index.js +7 -5
  58. package/runtime/plugins/picasso-web-search/package.json +6 -0
  59. package/runtime/plugins/picasso-web-search/requests.js +339 -0
  60. package/runtime/plugins/picasso-web-search/router.js +17 -12
  61. package/runtime/plugins/picasso-x-reader/settings.js +4 -1
  62. package/runtime/relay/main.mjs +3877 -1989
  63. package/runtime/relay/model-listing.mjs +337 -26
  64. package/runtime/relay/versions-routes.mjs +86 -20
@@ -1,15 +1,18 @@
1
1
  // One search, in a fixed order:
2
2
  //
3
- // 1. NATIVE the route the thread runs on (NATIVE_ROUTES), with that route's own credentials. A route with no
3
+ // 1. NATIVE the route the thread runs on (nativeBackendFor: NATIVE_ROUTES, minimax-* routes and Picasso's managed
4
+ // route), with that route's own credentials. A route with no
4
5
  // native search (a gateway, an OpenAI-compatible host, ...) has no first step.
5
- // 2. FALLBACKS the configured list, in order (config.js). A fallback whose endpoint or key is absent is left out
6
- // silently, so a Mac without the owner's Prism service never sees it.
6
+ // 2. FALLBACKS the list, in order (config.js): the one written in the settings or the environment, else the
7
+ // search-capable providers already connected (AUTO_FALLBACKS). A fallback whose endpoint or key is
8
+ // absent is left out silently, so a Mac without the owner's Prism service never sees it. A fallback
9
+ // that would borrow a disconnected route's key (FALLBACK_ROUTES) is never tried.
7
10
  // 3. FAILURE every backend failed: one structured error naming each backend and why, telling the model web search
8
11
  // is unavailable and not to substitute scraping from the shell (zero fallback: a failure is reported).
9
12
  //
10
13
  // Billing and authorisation errors (402/401/403 and "insufficient balance" bodies) mark the backend dead for the rest of
11
14
  // the session; 429/5xx get one bounded retry that honours Retry-After; everything else is tried once.
12
- import { NATIVE_ROUTES } from './backends.js';
15
+ import { fallbackDisconnected, nativeBackendFor } from './backends.js';
13
16
  import { BackendFailure } from './failure.js';
14
17
  import { formatBackendMarker, formatUnavailable } from './format.js';
15
18
 
@@ -93,12 +96,12 @@ export function createRouter({ ctx, readConfig, backends, sleep = defaultSleep,
93
96
  }
94
97
 
95
98
  async function plan(config, route, model) {
96
- const nativeId = NATIVE_ROUTES[route];
99
+ const nativeId = nativeBackendFor(route);
97
100
  const base = { config, route, model };
98
101
  const steps = [];
99
102
  if (nativeId !== undefined) steps.push({ id: nativeId, role: 'native' });
100
103
  for (const id of config.fallbacks) {
101
- if (id === nativeId) continue;
104
+ if (id === nativeId || fallbackDisconnected(id, config.disconnected)) continue;
102
105
  if (backends[id] !== undefined && (await backends[id].configured({ ...base, role: 'fallback' }))) steps.push({ id, role: 'fallback' });
103
106
  }
104
107
  return steps;
@@ -121,8 +124,9 @@ export function createRouter({ ctx, readConfig, backends, sleep = defaultSleep,
121
124
  continue;
122
125
  }
123
126
  if (step.role === 'native' && !(await backend.configured(call))) {
124
- const ref = await backend.keyRef?.(call);
125
- attempts.push({ name: backend.name, reason: new BackendFailure('credentials', { ref }).reason });
127
+ const unconfigured = backend.unconfigured?.(call);
128
+ const ref = unconfigured === undefined ? await backend.keyRef?.(call) : undefined;
129
+ attempts.push({ name: backend.name, reason: (unconfigured ?? new BackendFailure('credentials', { ref })).reason });
126
130
  continue;
127
131
  }
128
132
  try {
@@ -139,16 +143,17 @@ export function createRouter({ ctx, readConfig, backends, sleep = defaultSleep,
139
143
  },
140
144
 
141
145
  /**
142
- * Whether a search on `route` has anything to try: the route's native search has credentials, or a configured
143
- * fallback is active. Configuration only (no network, no per-session state). The seam's `ready` does NOT use this
146
+ * Whether a search on `route` has anything to try: the route's native search has credentials, or a fallback (listed
147
+ * or automatic) is active. Configuration only (no network, no per-session state). The seam's `ready` does NOT use this
144
148
  * (see index.js): the tool stays offered so a route with nothing configured gets the structured failure.
145
149
  */
146
150
  async configured(route) {
147
151
  const config = readConfig();
148
- const nativeId = NATIVE_ROUTES[route];
152
+ const nativeId = nativeBackendFor(route);
149
153
  if (nativeId !== undefined && (await backends[nativeId].configured({ config, route, role: 'native' }))) return true;
150
154
  for (const id of config.fallbacks) {
151
- if (id !== nativeId && backends[id] !== undefined && (await backends[id].configured({ config, route, role: 'fallback' }))) return true;
155
+ if (id === nativeId || fallbackDisconnected(id, config.disconnected)) continue;
156
+ if (backends[id] !== undefined && (await backends[id].configured({ config, route, role: 'fallback' }))) return true;
152
157
  }
153
158
  return false;
154
159
  },
@@ -89,7 +89,10 @@ function run(cmd, args) {
89
89
  }
90
90
 
91
91
  /** Read the stored key from the system keychain; `undefined` when there is none. */
92
- export async function readKeychainApiKey({ platform = process.platform, runner = run } = {}) {
92
+ export async function readKeychainApiKey({ platform = process.platform, runner } = {}) {
93
+ // Test-only hermetic mode (`PICASSO_TEST_HERMETIC=1`): no key in the login Keychain, unless a test passes a runner.
94
+ if (runner === undefined && process.env.PICASSO_TEST_HERMETIC?.trim() === '1') return undefined;
95
+ runner ??= run;
93
96
  if (platform === 'darwin') {
94
97
  const result = await runner('/usr/bin/security', ['find-generic-password', '-s', X_READER_KEYCHAIN_SERVICE, '-a', X_READER_KEYCHAIN_ACCOUNT, '-w']);
95
98
  const key = result.ok ? result.stdout.trim() : '';
@@ -322,26 +322,36 @@ const leafExcerpt = (leaf) => (leaf.length > SCAN_EXCERPT_MAX ? `${leaf.slice(0,
322
322
  * (objects and arrays recursed, cycles and depth > 24 pruned). Caps are generous — 256 leaves, 1 MiB of text —
323
323
  * and what fits is still scanned whole when the caps cut collection short.
324
324
  */
325
+ /**
326
+ * Argument keys whose string is the text of a file being written or edited, not a command or a path: a README that
327
+ * mentions `.env`, a script that documents `curl … | sh`, code that loads `credentials.json`. The built-in rules do
328
+ * not fire on these (owner 2026-11-17: ordinary edits were refused for naming a file); a rule the person added still
329
+ * scans everything, and the same text run as a command is still caught.
330
+ */
331
+ const CONTENT_KEYS = new Set(['content', 'contents', 'new_string', 'old_string', 'new_str', 'old_str', 'file_text', 'text', 'patch', 'diff', 'body', 'edits']);
332
+
333
+ /** String leaves to scan, each `{text, content}`; `content` marks text under a CONTENT_KEYS argument. */
325
334
  function collectScanLeaves(args, command) {
326
335
  const leaves = [];
327
336
  const budget = { bytes: SCAN_MAX_BYTES };
328
- const push = (value) => {
337
+ const push = (value, content) => {
329
338
  if (leaves.length >= SCAN_MAX_LEAVES || budget.bytes <= 0 || value === '') return;
330
339
  const piece = value.length > budget.bytes ? value.slice(0, budget.bytes) : value;
331
340
  budget.bytes -= piece.length;
332
- leaves.push(piece);
341
+ leaves.push({ text: piece, content });
333
342
  };
334
- if (typeof command === 'string') push(command);
343
+ if (typeof command === 'string') push(command, false);
335
344
  const seen = new Set();
336
- const walk = (value, depth) => {
345
+ const walk = (value, depth, content) => {
337
346
  if (depth > SCAN_MAX_DEPTH || leaves.length >= SCAN_MAX_LEAVES || budget.bytes <= 0) return;
338
- if (typeof value === 'string') return push(value);
347
+ if (typeof value === 'string') return push(value, content);
339
348
  if (!isRecord(value) && !Array.isArray(value)) return;
340
349
  if (seen.has(value)) return;
341
350
  seen.add(value);
342
- for (const item of Array.isArray(value) ? value : Object.values(value)) walk(item, depth + 1);
351
+ if (Array.isArray(value)) for (const item of value) walk(item, depth + 1, content);
352
+ else for (const [key, item] of Object.entries(value)) walk(item, depth + 1, content || CONTENT_KEYS.has(key));
343
353
  };
344
- walk(args, 0);
354
+ walk(args, 0, false);
345
355
  return leaves;
346
356
  }
347
357
 
@@ -464,8 +474,11 @@ export class ContentGuard {
464
474
  */
465
475
  scan(leaves, toolName) {
466
476
  for (const rule of this.policy) {
477
+ const builtin = this.ruleSources?.get(rule.id) === 'builtin';
467
478
  for (const leaf of leaves) {
468
- if (rule.regex.test(leaf)) return { rule: { id: rule.id, pattern: rule.pattern, description: rule.description }, leaf: leafExcerpt(leaf), toolName };
479
+ const text = typeof leaf === 'string' ? leaf : leaf.text;
480
+ if (builtin && typeof leaf !== 'string' && leaf.content) continue;
481
+ if (rule.regex.test(text)) return { rule: { id: rule.id, pattern: rule.pattern, description: rule.description }, leaf: leafExcerpt(text), toolName };
469
482
  }
470
483
  }
471
484
  return undefined;