@edgehero/pi-dispatch 3.0.0 → 4.0.0
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/.env.example +34 -0
- package/package.json +6 -2
- package/src/backend-local.mjs +69 -0
- package/src/backend-podman.mjs +44 -13
- package/src/config.mjs +39 -1
- package/src/container-spec.mjs +70 -7
- package/src/cpu-reserve.mjs +344 -0
- package/src/daemon-facts.mjs +58 -0
- package/src/docker-run.mjs +83 -6
- package/src/doctor.mjs +631 -21
- package/src/env-allowlist.mjs +23 -5
- package/src/host-budget.mjs +736 -0
- package/src/host-pi.mjs +1 -1
- package/src/index.mjs +237 -65
- package/src/job-size.mjs +286 -0
- package/src/job-user.mjs +66 -5
- package/src/live-probes.mjs +150 -25
- package/src/model-catalog.mjs +1 -1
- package/src/model-endpoints.mjs +22 -0
- package/src/models-json.mjs +10 -4
- package/src/output-cap.mjs +3 -3
- package/src/prepare.mjs +7 -3
- package/src/processor.mjs +91 -14
- package/src/reserved-env.mjs +3 -2
- package/src/run-container.mjs +62 -8
- package/src/run-history.mjs +204 -117
- package/src/sandbox-store.mjs +5 -1
- package/src/sandbox.mjs +48 -7
- package/src/scoped-limits.mjs +94 -10
- package/src/size-records.mjs +80 -0
- package/src/size-suggest.mjs +441 -0
- package/src/start.mjs +133 -9
- package/src/triggers.mjs +8 -5
package/src/env-allowlist.mjs
CHANGED
|
@@ -33,7 +33,7 @@ import { egressEnv } from "./egress.mjs";
|
|
|
33
33
|
import { forgeSpec } from "./forges.mjs";
|
|
34
34
|
import { apiKeyVariable } from "./provider-key.mjs";
|
|
35
35
|
import { isDeterminateFsCode } from "./transient.mjs";
|
|
36
|
-
import { KEYLESS_HOW, keylessVerdict } from "./model-endpoints.mjs";
|
|
36
|
+
import { KEYLESS_HOW, keylessVerdict, providerRenameHint, readOverlayModels, RENAMED_PROVIDERS } from "./model-endpoints.mjs";
|
|
37
37
|
import { KEYLESS_ENV_NAME } from "./reserved-env.mjs";
|
|
38
38
|
|
|
39
39
|
function configError(message) {
|
|
@@ -161,7 +161,7 @@ export function resolveProviderCredential({ provider, hostEnv, authFromPi = fals
|
|
|
161
161
|
error.code = unreadable.code;
|
|
162
162
|
throw error;
|
|
163
163
|
}
|
|
164
|
-
throw configError(unknownProviderMessage(provider));
|
|
164
|
+
throw configError(unknownProviderMessage(provider, hintOverlay(provider, modelEndpoints, hostEnv)));
|
|
165
165
|
}
|
|
166
166
|
const held = candidates
|
|
167
167
|
.map((name) => [name, hostEnv[name]])
|
|
@@ -209,8 +209,24 @@ export function keylessEndpointsFor(provider, modelEndpoints) {
|
|
|
209
209
|
return verdict.keyless ? verdict.endpoints : null;
|
|
210
210
|
}
|
|
211
211
|
|
|
212
|
-
function unknownProviderMessage(provider) {
|
|
213
|
-
return `pi has no provider "${provider}", so there is no key variable to give it a key
|
|
212
|
+
function unknownProviderMessage(provider, overlay = {}) {
|
|
213
|
+
return `pi has no provider "${provider}", so there is no key variable to give it a key.${providerRenameHint(provider, { ...overlay, piProviders: piProviders() })} Use one of pi's provider ids with its key in the worker environment or in pi's auth.json, or, ${KEYLESS_HOW}.`;
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
/**
|
|
217
|
+
* The overlay models.json the rename hint is judged on (issue #587's review): the pickup's snapshot when it read one, else
|
|
218
|
+
* the overlay itself, read here, only for an id pi renamed. The snapshot reads the overlay only when an endpoint is
|
|
219
|
+
* declared, so a full custom provider under the old id, with no endpoint, was told "did you mean". A read that fails
|
|
220
|
+
* is `overlayUnread`: no guess.
|
|
221
|
+
*/
|
|
222
|
+
function hintOverlay(provider, modelEndpoints, hostEnv) {
|
|
223
|
+
if (modelEndpoints?.models) return { models: modelEndpoints.models };
|
|
224
|
+
if (!Object.hasOwn(RENAMED_PROVIDERS, provider)) return {};
|
|
225
|
+
try {
|
|
226
|
+
return { models: readOverlayModels(hostEnv?.PI_GLOBAL_PI_DIR) };
|
|
227
|
+
} catch {
|
|
228
|
+
return { overlayUnread: true };
|
|
229
|
+
}
|
|
214
230
|
}
|
|
215
231
|
|
|
216
232
|
function defaultAgentDir(hostEnv) {
|
|
@@ -524,13 +540,15 @@ export function buildContainerEnv({ provider, model, maxTurns, maxTokens, maxCos
|
|
|
524
540
|
if (exitAuth === true) env.PI_EXIT_AUTH = "stdin";
|
|
525
541
|
else delete env.PI_EXIT_AUTH;
|
|
526
542
|
|
|
527
|
-
// Issue #500: the runner sets these
|
|
543
|
+
// Issue #500: the runner sets these in its own environment, for its child processes, and no value from outside
|
|
528
544
|
// may arrive first. Both lists refuse them upstream (config.mjs for PI_FORWARD_ENV, the triggers loader for
|
|
529
545
|
// run.secrets, through RUNNER_ENV_NAMES); this is the line that holds if either refusal is ever bypassed.
|
|
530
546
|
// env-internal PI_DISPATCH_CHILD_LEDGER: set by the runner inside the container, never by the worker, so removed here.
|
|
531
547
|
delete env.PI_DISPATCH_CHILD_LEDGER;
|
|
532
548
|
// env-internal PI_DISPATCH_RUNNER_PID: set by the runner inside the container, never by the worker, so removed here.
|
|
533
549
|
delete env.PI_DISPATCH_RUNNER_PID;
|
|
550
|
+
// env-internal PI_DISPATCH_PRICE_TABLE: set by the runner inside the container, never by the worker, so removed here.
|
|
551
|
+
delete env.PI_DISPATCH_PRICE_TABLE;
|
|
534
552
|
|
|
535
553
|
// Forge-backed jobs, and local cron jobs that opted in via run.github. Other local-folder jobs have
|
|
536
554
|
// no token (CONST-TOKEN-SCOPED-PER-JOB). The mint goes into BOTH of its forge's variables because
|