@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.
- package/dist/build-info.json +1 -1
- package/dist/index.js +1591 -1251
- package/package.json +1 -1
- package/runtime/engine-manifest.json +22 -11
- package/runtime/packages/picasso-compaction/cordis.patch.yml +4 -0
- package/runtime/packages/picasso-compaction/index.js +623 -0
- package/runtime/packages/picasso-compaction/package.json +27 -0
- package/runtime/packages/picasso-lean-context/argument-repair.js +422 -0
- package/runtime/packages/picasso-lean-context/index.js +23 -2
- package/runtime/packages/picasso-model-router/connections.js +49 -3
- package/runtime/packages/picasso-model-router/index.js +32 -1
- package/runtime/packages/picasso-model-router/package.json +3 -1
- package/runtime/packages/picasso-model-router/thinking-default.js +212 -0
- package/runtime/packages/picasso-web-search/backends.js +245 -195
- package/runtime/packages/picasso-web-search/config.js +75 -27
- package/runtime/packages/picasso-web-search/cordis.patch.yml +2 -1
- package/runtime/packages/picasso-web-search/failure.js +7 -1
- package/runtime/packages/picasso-web-search/index.js +7 -5
- package/runtime/packages/picasso-web-search/package.json +6 -0
- package/runtime/packages/picasso-web-search/requests.js +339 -0
- package/runtime/packages/picasso-web-search/router.js +17 -12
- package/runtime/plugins/picasso-compaction/index.js +623 -0
- package/runtime/plugins/picasso-compaction/package.json +27 -0
- package/runtime/plugins/picasso-lean-context/argument-repair.js +422 -0
- package/runtime/plugins/picasso-lean-context/index.js +23 -2
- package/runtime/plugins/picasso-model-router/connections.js +49 -3
- package/runtime/plugins/picasso-model-router/index.js +32 -1
- package/runtime/plugins/picasso-model-router/package.json +3 -1
- package/runtime/plugins/picasso-model-router/thinking-default.js +212 -0
- package/runtime/plugins/picasso-provider-models/index.js +236 -4
- package/runtime/plugins/picasso-web-search/backends.js +245 -195
- package/runtime/plugins/picasso-web-search/config.js +75 -27
- package/runtime/plugins/picasso-web-search/failure.js +7 -1
- package/runtime/plugins/picasso-web-search/index.js +7 -5
- package/runtime/plugins/picasso-web-search/package.json +6 -0
- package/runtime/plugins/picasso-web-search/requests.js +339 -0
- package/runtime/plugins/picasso-web-search/router.js +17 -12
- package/runtime/relay/main.mjs +2776 -1494
- package/runtime/relay/model-listing.mjs +337 -26
- 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
|
|
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
|
|
6
|
-
//
|
|
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 {
|
|
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 =
|
|
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
|
|
125
|
-
|
|
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
|
|
143
|
-
*
|
|
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 =
|
|
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
|
|
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
|
},
|