@picassohq/cli 1.0.3 → 1.0.4

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 (40) hide show
  1. package/dist/build-info.json +1 -1
  2. package/dist/index.js +1591 -1251
  3. package/package.json +1 -1
  4. package/runtime/engine-manifest.json +22 -11
  5. package/runtime/packages/picasso-compaction/cordis.patch.yml +4 -0
  6. package/runtime/packages/picasso-compaction/index.js +623 -0
  7. package/runtime/packages/picasso-compaction/package.json +27 -0
  8. package/runtime/packages/picasso-lean-context/argument-repair.js +422 -0
  9. package/runtime/packages/picasso-lean-context/index.js +23 -2
  10. package/runtime/packages/picasso-model-router/connections.js +49 -3
  11. package/runtime/packages/picasso-model-router/index.js +32 -1
  12. package/runtime/packages/picasso-model-router/package.json +3 -1
  13. package/runtime/packages/picasso-model-router/thinking-default.js +212 -0
  14. package/runtime/packages/picasso-web-search/backends.js +245 -195
  15. package/runtime/packages/picasso-web-search/config.js +75 -27
  16. package/runtime/packages/picasso-web-search/cordis.patch.yml +2 -1
  17. package/runtime/packages/picasso-web-search/failure.js +7 -1
  18. package/runtime/packages/picasso-web-search/index.js +7 -5
  19. package/runtime/packages/picasso-web-search/package.json +6 -0
  20. package/runtime/packages/picasso-web-search/requests.js +339 -0
  21. package/runtime/packages/picasso-web-search/router.js +17 -12
  22. package/runtime/plugins/picasso-compaction/index.js +623 -0
  23. package/runtime/plugins/picasso-compaction/package.json +27 -0
  24. package/runtime/plugins/picasso-lean-context/argument-repair.js +422 -0
  25. package/runtime/plugins/picasso-lean-context/index.js +23 -2
  26. package/runtime/plugins/picasso-model-router/connections.js +49 -3
  27. package/runtime/plugins/picasso-model-router/index.js +32 -1
  28. package/runtime/plugins/picasso-model-router/package.json +3 -1
  29. package/runtime/plugins/picasso-model-router/thinking-default.js +212 -0
  30. package/runtime/plugins/picasso-provider-models/index.js +236 -4
  31. package/runtime/plugins/picasso-web-search/backends.js +245 -195
  32. package/runtime/plugins/picasso-web-search/config.js +75 -27
  33. package/runtime/plugins/picasso-web-search/failure.js +7 -1
  34. package/runtime/plugins/picasso-web-search/index.js +7 -5
  35. package/runtime/plugins/picasso-web-search/package.json +6 -0
  36. package/runtime/plugins/picasso-web-search/requests.js +339 -0
  37. package/runtime/plugins/picasso-web-search/router.js +17 -12
  38. package/runtime/relay/main.mjs +2776 -1494
  39. package/runtime/relay/model-listing.mjs +337 -26
  40. package/runtime/relay/versions-routes.mjs +65 -3
@@ -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
  },