@whittlelabs/sifter 0.34.0 → 0.35.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/bin.js +495 -406
- package/bin.js.map +4 -4
- package/package.json +1 -1
package/bin.js
CHANGED
|
@@ -11072,6 +11072,7 @@ var require_claude_code = __commonJS({
|
|
|
11072
11072
|
let finalText = null;
|
|
11073
11073
|
const readPaths = [];
|
|
11074
11074
|
let usage = null;
|
|
11075
|
+
const toolCalls = {};
|
|
11075
11076
|
let resultMeta = null;
|
|
11076
11077
|
let structuredOutput = null;
|
|
11077
11078
|
let sessionId = null;
|
|
@@ -11099,6 +11100,8 @@ var require_claude_code = __commonJS({
|
|
|
11099
11100
|
const b = block;
|
|
11100
11101
|
if (b?.type !== "tool_use")
|
|
11101
11102
|
continue;
|
|
11103
|
+
if (typeof b.name === "string")
|
|
11104
|
+
toolCalls[b.name] = (toolCalls[b.name] ?? 0) + 1;
|
|
11102
11105
|
const fp = b.input?.file_path;
|
|
11103
11106
|
if (b.name === "Read" && typeof fp === "string") {
|
|
11104
11107
|
readPaths.push(fp);
|
|
@@ -11125,13 +11128,19 @@ var require_claude_code = __commonJS({
|
|
|
11125
11128
|
}
|
|
11126
11129
|
const u = event.usage;
|
|
11127
11130
|
const cost = event.total_cost_usd;
|
|
11131
|
+
const turns = event.num_turns;
|
|
11128
11132
|
usage = {
|
|
11129
11133
|
...typeof u?.input_tokens === "number" ? { inputTokens: u.input_tokens } : {},
|
|
11130
11134
|
...typeof u?.output_tokens === "number" ? { outputTokens: u.output_tokens } : {},
|
|
11131
|
-
...typeof
|
|
11135
|
+
...typeof u?.cache_read_input_tokens === "number" ? { cacheReadInputTokens: u.cache_read_input_tokens } : {},
|
|
11136
|
+
...typeof u?.cache_creation_input_tokens === "number" ? { cacheCreationInputTokens: u.cache_creation_input_tokens } : {},
|
|
11137
|
+
...typeof cost === "number" ? { costUsd: cost } : {},
|
|
11138
|
+
...typeof turns === "number" ? { turns } : {}
|
|
11132
11139
|
};
|
|
11133
11140
|
}
|
|
11134
11141
|
}
|
|
11142
|
+
if (usage && Object.keys(toolCalls).length > 0)
|
|
11143
|
+
usage.toolCalls = toolCalls;
|
|
11135
11144
|
return { finalText, readPaths, usage, resultMeta, structuredOutput, sessionId, model, toolInputs };
|
|
11136
11145
|
}
|
|
11137
11146
|
}
|
|
@@ -26124,6 +26133,257 @@ var require_chain = __commonJS({
|
|
|
26124
26133
|
}
|
|
26125
26134
|
});
|
|
26126
26135
|
|
|
26136
|
+
// ../../packages/shuttle/dist/executors/output-gates.js
|
|
26137
|
+
var require_output_gates = __commonJS({
|
|
26138
|
+
"../../packages/shuttle/dist/executors/output-gates.js"(exports2) {
|
|
26139
|
+
"use strict";
|
|
26140
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
26141
|
+
exports2.isSanctionedPaint = isSanctionedPaint;
|
|
26142
|
+
exports2.unsanctionedPaints = unsanctionedPaints;
|
|
26143
|
+
exports2.resolvePath = resolvePath;
|
|
26144
|
+
exports2.evaluateOutputGates = evaluateOutputGates;
|
|
26145
|
+
exports2.renderRepairPrompt = renderRepairPrompt;
|
|
26146
|
+
var INPUT_REF = "input:";
|
|
26147
|
+
var COLOR_BEARING = ["fill", "stroke", "color", "stop-color", "flood-color", "lighting-color"];
|
|
26148
|
+
var INERT = /* @__PURE__ */ new Set(["none", "inherit", "initial", "unset", "transparent", "currentcolor"]);
|
|
26149
|
+
function isSanctionedPaint(raw) {
|
|
26150
|
+
const value = raw.trim().toLowerCase();
|
|
26151
|
+
if (value === "")
|
|
26152
|
+
return true;
|
|
26153
|
+
if (INERT.has(value))
|
|
26154
|
+
return true;
|
|
26155
|
+
if (/^url\(\s*['"]?#[^)'"]+['"]?\s*\)$/.test(value))
|
|
26156
|
+
return true;
|
|
26157
|
+
const varMatch = /^var\(\s*(--[a-z0-9-]+)\s*(?:,([\s\S]*))?\)$/.exec(value);
|
|
26158
|
+
if (!varMatch)
|
|
26159
|
+
return false;
|
|
26160
|
+
const [, name, fallback] = varMatch;
|
|
26161
|
+
if (!name.startsWith("--color-"))
|
|
26162
|
+
return false;
|
|
26163
|
+
return fallback === void 0 || isSanctionedPaint(fallback);
|
|
26164
|
+
}
|
|
26165
|
+
function unsanctionedPaints(source) {
|
|
26166
|
+
const found = [];
|
|
26167
|
+
const attrs = COLOR_BEARING.join("|");
|
|
26168
|
+
const attribute = new RegExp(`\\b(?:${attrs})\\s*=\\s*(['"])([\\s\\S]*?)\\1`, "gi");
|
|
26169
|
+
const declaration = new RegExp(`\\b(?:${attrs})\\s*:\\s*([^;"'}\\n]+)`, "gi");
|
|
26170
|
+
for (const [, , value] of source.matchAll(attribute)) {
|
|
26171
|
+
if (!isSanctionedPaint(value))
|
|
26172
|
+
found.push(value.trim());
|
|
26173
|
+
}
|
|
26174
|
+
for (const [, value] of source.matchAll(declaration)) {
|
|
26175
|
+
if (!isSanctionedPaint(value))
|
|
26176
|
+
found.push(value.trim());
|
|
26177
|
+
}
|
|
26178
|
+
return found;
|
|
26179
|
+
}
|
|
26180
|
+
function resolvePath(root, path) {
|
|
26181
|
+
let ctx = root;
|
|
26182
|
+
for (const seg of path.split(".")) {
|
|
26183
|
+
const project = seg.endsWith("[*]");
|
|
26184
|
+
const key = project ? seg.slice(0, -3) : seg;
|
|
26185
|
+
if (Array.isArray(ctx)) {
|
|
26186
|
+
ctx = ctx.map((el) => key ? el?.[key] : el);
|
|
26187
|
+
} else {
|
|
26188
|
+
ctx = key ? ctx?.[key] : ctx;
|
|
26189
|
+
}
|
|
26190
|
+
if (project && !Array.isArray(ctx)) {
|
|
26191
|
+
ctx = ctx == null ? [] : [ctx];
|
|
26192
|
+
}
|
|
26193
|
+
}
|
|
26194
|
+
return ctx;
|
|
26195
|
+
}
|
|
26196
|
+
function resolveRef(ref, output, inputs) {
|
|
26197
|
+
if (ref.startsWith(INPUT_REF)) {
|
|
26198
|
+
const label = ref.slice(INPUT_REF.length);
|
|
26199
|
+
const row = inputs.find((i) => i.label === label) ?? inputs.find((i) => i.label === "artifacts" && i.payload.label === label);
|
|
26200
|
+
if (!row)
|
|
26201
|
+
return void 0;
|
|
26202
|
+
return Object.prototype.hasOwnProperty.call(row.payload, "value") ? row.payload.value : row.payload;
|
|
26203
|
+
}
|
|
26204
|
+
return resolvePath(output, ref);
|
|
26205
|
+
}
|
|
26206
|
+
function asStrings(value) {
|
|
26207
|
+
if (Array.isArray(value))
|
|
26208
|
+
return value.map((v) => String(v));
|
|
26209
|
+
if (value == null)
|
|
26210
|
+
return [];
|
|
26211
|
+
return [String(value)];
|
|
26212
|
+
}
|
|
26213
|
+
var PRIMITIVES = {
|
|
26214
|
+
/**
|
|
26215
|
+
* `coverage` — the values at `got` must exactly cover the set at `want`:
|
|
26216
|
+
* every wanted value present, nothing invented, none repeated. Params:
|
|
26217
|
+
* `{ got: <output path>, want: <ref>, subject?: <noun> }`.
|
|
26218
|
+
*/
|
|
26219
|
+
coverage(params, output, inputs) {
|
|
26220
|
+
const subject = typeof params.subject === "string" ? params.subject : "item";
|
|
26221
|
+
const got = asStrings(resolveRef(String(params.got), output, inputs));
|
|
26222
|
+
const want = asStrings(resolveRef(String(params.want), output, inputs));
|
|
26223
|
+
const gotSet = new Set(got);
|
|
26224
|
+
const wantSet = new Set(want);
|
|
26225
|
+
const missing = want.filter((v) => !gotSet.has(v));
|
|
26226
|
+
const unknown = [...new Set(got.filter((v) => !wantSet.has(v)))];
|
|
26227
|
+
const seen = /* @__PURE__ */ new Set();
|
|
26228
|
+
const duplicated = [];
|
|
26229
|
+
for (const v of got) {
|
|
26230
|
+
if (seen.has(v))
|
|
26231
|
+
duplicated.push(v);
|
|
26232
|
+
else
|
|
26233
|
+
seen.add(v);
|
|
26234
|
+
}
|
|
26235
|
+
if (missing.length === 0 && unknown.length === 0 && duplicated.length === 0)
|
|
26236
|
+
return [];
|
|
26237
|
+
const parts = [];
|
|
26238
|
+
if (missing.length)
|
|
26239
|
+
parts.push(`missing ${subject}(s): [${missing.join(", ")}]`);
|
|
26240
|
+
if (unknown.length)
|
|
26241
|
+
parts.push(`not a known ${subject}: [${unknown.join(", ")}]`);
|
|
26242
|
+
if (duplicated.length)
|
|
26243
|
+
parts.push(`assessed more than once: [${[...new Set(duplicated)].join(", ")}]`);
|
|
26244
|
+
return [
|
|
26245
|
+
`every ${subject} must be covered exactly once \u2014 ${parts.join("; ")}. Return one entry per ${subject}, using its exact id.`
|
|
26246
|
+
];
|
|
26247
|
+
},
|
|
26248
|
+
/**
|
|
26249
|
+
* `non_empty_when` — the array at `path` must be non-empty, optionally only
|
|
26250
|
+
* when `when.path` equals `when.equals`. Params:
|
|
26251
|
+
* `{ path: <output path>, when?: { path: <output path>, equals: <value> } }`.
|
|
26252
|
+
*/
|
|
26253
|
+
non_empty_when(params, output) {
|
|
26254
|
+
const when = params.when;
|
|
26255
|
+
if (when && typeof when.path === "string") {
|
|
26256
|
+
if (resolvePath(output, when.path) !== when.equals)
|
|
26257
|
+
return [];
|
|
26258
|
+
}
|
|
26259
|
+
const path = String(params.path);
|
|
26260
|
+
const value = resolvePath(output, path);
|
|
26261
|
+
if (Array.isArray(value) && value.length > 0)
|
|
26262
|
+
return [];
|
|
26263
|
+
const cond = when && typeof when.path === "string" ? ` when ${when.path} is ${JSON.stringify(when.equals)}` : "";
|
|
26264
|
+
return [
|
|
26265
|
+
`'${path}' must be a non-empty array${cond}; it was ${Array.isArray(value) ? "empty" : "absent"}.`
|
|
26266
|
+
];
|
|
26267
|
+
},
|
|
26268
|
+
/**
|
|
26269
|
+
* `bounded_palette` — every colour in the sources at `path` must be named
|
|
26270
|
+
* by role rather than written as a value. Params:
|
|
26271
|
+
* `{ path: <output path>, roles?: <role names for the repair turn> }`.
|
|
26272
|
+
*
|
|
26273
|
+
* A drawing the model authors is markup the house did not write, and a
|
|
26274
|
+
* literal in it is a colour outside the consuming palette: unproved
|
|
26275
|
+
* against the colours beside it, unchecked for contrast on the ground it
|
|
26276
|
+
* lands on, and fixed to one theme. The consumer strips such a paint at
|
|
26277
|
+
* render, so an artifact that carries one silently loses it. Catching it
|
|
26278
|
+
* HERE is what makes that a repair the model can make while it still has
|
|
26279
|
+
* the drawing in hand, instead of a defect nobody sees until the picture
|
|
26280
|
+
* comes out plain.
|
|
26281
|
+
*/
|
|
26282
|
+
bounded_palette(params, output) {
|
|
26283
|
+
const path = String(params.path);
|
|
26284
|
+
const value = resolvePath(output, path);
|
|
26285
|
+
const sources = (Array.isArray(value) ? value : [value]).filter((v) => typeof v === "string" && v.length > 0);
|
|
26286
|
+
const offenders = [...new Set(sources.flatMap(unsanctionedPaints))];
|
|
26287
|
+
if (offenders.length === 0)
|
|
26288
|
+
return [];
|
|
26289
|
+
const roles = Array.isArray(params.roles) ? params.roles.map(String) : [];
|
|
26290
|
+
const vocabulary = roles.length > 0 ? ` Use one of: ${roles.join(", ")}.` : "";
|
|
26291
|
+
return [
|
|
26292
|
+
`'${path}' states ${offenders.length} colour value${offenders.length === 1 ? "" : "s"} directly (${offenders.slice(0, 8).join(", ")}${offenders.length > 8 ? ", \u2026" : ""}). Every colour must be named by role \u2014 var(--color-\u2026), currentColor, or none \u2014 never as a hex, rgb(), hsl() or colour name, because a value cannot adapt to the reader's theme and was never checked against the colours beside it.${vocabulary} Redraw with roles and return the whole output again.`
|
|
26293
|
+
];
|
|
26294
|
+
}
|
|
26295
|
+
};
|
|
26296
|
+
function evaluateOutputGates(gates, output, inputs) {
|
|
26297
|
+
const findings = [];
|
|
26298
|
+
for (const gate of gates) {
|
|
26299
|
+
const primitive = PRIMITIVES[gate.primitive];
|
|
26300
|
+
if (!primitive) {
|
|
26301
|
+
findings.push({ gate: gate.name, message: `unknown gate primitive '${gate.primitive}'` });
|
|
26302
|
+
continue;
|
|
26303
|
+
}
|
|
26304
|
+
for (const message of primitive(gate.params, output, inputs)) {
|
|
26305
|
+
findings.push({ gate: gate.name, message });
|
|
26306
|
+
}
|
|
26307
|
+
}
|
|
26308
|
+
return { ok: findings.length === 0, findings };
|
|
26309
|
+
}
|
|
26310
|
+
function renderRepairPrompt(findings) {
|
|
26311
|
+
return [
|
|
26312
|
+
"Your previous answer did not satisfy these output checks. Return the corrected, complete answer that resolves every item below. Produce the same output shape with the problems fixed, and nothing else \u2014 no commentary, no explanation of the changes.",
|
|
26313
|
+
"",
|
|
26314
|
+
...findings.map((f) => `- [${f.gate}] ${f.message}`)
|
|
26315
|
+
].join("\n");
|
|
26316
|
+
}
|
|
26317
|
+
}
|
|
26318
|
+
});
|
|
26319
|
+
|
|
26320
|
+
// ../../packages/shuttle/dist/logging/logger.js
|
|
26321
|
+
var require_logger = __commonJS({
|
|
26322
|
+
"../../packages/shuttle/dist/logging/logger.js"(exports2) {
|
|
26323
|
+
"use strict";
|
|
26324
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
26325
|
+
exports2.createLogger = createLogger;
|
|
26326
|
+
exports2.setGlobalLogger = setGlobalLogger;
|
|
26327
|
+
exports2.getLogger = getLogger;
|
|
26328
|
+
var LEVEL_ORDER = {
|
|
26329
|
+
debug: 0,
|
|
26330
|
+
info: 1,
|
|
26331
|
+
warn: 2,
|
|
26332
|
+
error: 3
|
|
26333
|
+
};
|
|
26334
|
+
function formatContext(context) {
|
|
26335
|
+
return Object.entries(context).map(([k, v]) => `${k}=${typeof v === "string" ? v : JSON.stringify(v)}`).join(" ");
|
|
26336
|
+
}
|
|
26337
|
+
function formatPretty(level, message, context) {
|
|
26338
|
+
const timestamp = (/* @__PURE__ */ new Date()).toISOString();
|
|
26339
|
+
const tag = level.toUpperCase().padEnd(5);
|
|
26340
|
+
const base = `[${timestamp}] ${tag} ${message}`;
|
|
26341
|
+
if (context && Object.keys(context).length > 0) {
|
|
26342
|
+
return `${base} ${formatContext(context)}`;
|
|
26343
|
+
}
|
|
26344
|
+
return base;
|
|
26345
|
+
}
|
|
26346
|
+
function formatJson(level, message, context) {
|
|
26347
|
+
const entry = {
|
|
26348
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
26349
|
+
level,
|
|
26350
|
+
message,
|
|
26351
|
+
...context
|
|
26352
|
+
};
|
|
26353
|
+
return JSON.stringify(entry);
|
|
26354
|
+
}
|
|
26355
|
+
function createLogger(options) {
|
|
26356
|
+
const threshold = LEVEL_ORDER[options.level];
|
|
26357
|
+
const format = options.format === "json" ? formatJson : formatPretty;
|
|
26358
|
+
function emit(level, message, context) {
|
|
26359
|
+
if (LEVEL_ORDER[level] < threshold)
|
|
26360
|
+
return;
|
|
26361
|
+
const line = format(level, message, context);
|
|
26362
|
+
if (level === "error") {
|
|
26363
|
+
console.error(line);
|
|
26364
|
+
} else if (level === "warn") {
|
|
26365
|
+
console.warn(line);
|
|
26366
|
+
} else {
|
|
26367
|
+
console.log(line);
|
|
26368
|
+
}
|
|
26369
|
+
}
|
|
26370
|
+
return {
|
|
26371
|
+
debug: (message, context) => emit("debug", message, context),
|
|
26372
|
+
info: (message, context) => emit("info", message, context),
|
|
26373
|
+
warn: (message, context) => emit("warn", message, context),
|
|
26374
|
+
error: (message, context) => emit("error", message, context)
|
|
26375
|
+
};
|
|
26376
|
+
}
|
|
26377
|
+
var globalLogger = createLogger({ level: "info", format: "pretty" });
|
|
26378
|
+
function setGlobalLogger(logger) {
|
|
26379
|
+
globalLogger = logger;
|
|
26380
|
+
}
|
|
26381
|
+
function getLogger() {
|
|
26382
|
+
return globalLogger;
|
|
26383
|
+
}
|
|
26384
|
+
}
|
|
26385
|
+
});
|
|
26386
|
+
|
|
26127
26387
|
// ../../packages/shuttle/dist/workspace/git.js
|
|
26128
26388
|
var require_git = __commonJS({
|
|
26129
26389
|
"../../packages/shuttle/dist/workspace/git.js"(exports2) {
|
|
@@ -26612,358 +26872,231 @@ var require_workspace = __commonJS({
|
|
|
26612
26872
|
} });
|
|
26613
26873
|
Object.defineProperty(exports2, "registerModifier", { enumerable: true, get: function() {
|
|
26614
26874
|
return materialize_1.registerModifier;
|
|
26615
|
-
} });
|
|
26616
|
-
var git_1 = require_git();
|
|
26617
|
-
Object.defineProperty(exports2, "gitMaterializer", { enumerable: true, get: function() {
|
|
26618
|
-
return git_1.gitMaterializer;
|
|
26619
|
-
} });
|
|
26620
|
-
Object.defineProperty(exports2, "buildGitAuthEnv", { enumerable: true, get: function() {
|
|
26621
|
-
return git_1.buildGitAuthEnv;
|
|
26622
|
-
} });
|
|
26623
|
-
var overlay_1 = require_overlay();
|
|
26624
|
-
Object.defineProperty(exports2, "overlayModifier", { enumerable: true, get: function() {
|
|
26625
|
-
return overlay_1.overlayModifier;
|
|
26626
|
-
} });
|
|
26627
|
-
Object.defineProperty(exports2, "applyOverlay", { enumerable: true, get: function() {
|
|
26628
|
-
return overlay_1.applyOverlay;
|
|
26629
|
-
} });
|
|
26630
|
-
}
|
|
26631
|
-
});
|
|
26632
|
-
|
|
26633
|
-
// ../../packages/shuttle/dist/
|
|
26634
|
-
var
|
|
26635
|
-
"../../packages/shuttle/dist/
|
|
26636
|
-
"use strict";
|
|
26637
|
-
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
26638
|
-
exports2.
|
|
26639
|
-
exports2.
|
|
26640
|
-
|
|
26641
|
-
|
|
26642
|
-
|
|
26643
|
-
|
|
26644
|
-
|
|
26645
|
-
|
|
26646
|
-
|
|
26647
|
-
|
|
26648
|
-
const
|
|
26649
|
-
|
|
26650
|
-
|
|
26651
|
-
|
|
26652
|
-
|
|
26653
|
-
|
|
26654
|
-
|
|
26655
|
-
|
|
26656
|
-
|
|
26657
|
-
|
|
26658
|
-
|
|
26659
|
-
|
|
26660
|
-
|
|
26661
|
-
|
|
26662
|
-
|
|
26663
|
-
|
|
26664
|
-
"../../packages/shuttle/dist/credentials/broker.js"(exports2) {
|
|
26665
|
-
"use strict";
|
|
26666
|
-
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
26667
|
-
exports2.createCredentialBroker = createCredentialBroker;
|
|
26668
|
-
var keep_1 = require_dist2();
|
|
26669
|
-
var env_ref_1 = require_env_ref();
|
|
26670
|
-
var registry_1 = require_registry2();
|
|
26671
|
-
function createCredentialBroker(config, deps = {}) {
|
|
26672
|
-
if (typeof config !== "object" || config === null || config.apiKeyFrom !== "job-metadata") {
|
|
26673
|
-
return null;
|
|
26674
|
-
}
|
|
26675
|
-
const cfg = config;
|
|
26676
|
-
const keepApiUrl = (0, env_ref_1.resolveConfigStringOrEnv)(cfg, "keepApiUrl", "KEEP_API_URL");
|
|
26677
|
-
const clientId = (0, env_ref_1.resolveConfigStringOrEnv)(cfg, "keepClientId", "KEEP_CLIENT_ID");
|
|
26678
|
-
const clientSecret = (0, env_ref_1.resolveConfigStringOrEnv)(cfg, "keepClientSecret", "KEEP_CLIENT_SECRET");
|
|
26679
|
-
const stmFactory = deps.buildServiceTokenManager ?? ((c) => new keep_1.ServiceTokenManager(c));
|
|
26680
|
-
const stm = stmFactory({ keepApiUrl, clientId, clientSecret });
|
|
26681
|
-
const keepFactory = deps.buildKeepClient ?? ((c) => new keep_1.KeepClient(c));
|
|
26682
|
-
return {
|
|
26683
|
-
async reveal({ name, principal }) {
|
|
26684
|
-
const resolver = (0, registry_1.getCredentialResolver)(name);
|
|
26685
|
-
if (!resolver)
|
|
26686
|
-
return null;
|
|
26687
|
-
const serviceToken = await stm.getToken();
|
|
26688
|
-
if (!serviceToken) {
|
|
26689
|
-
throw new Error("credential broker: Keep service-token exchange failed. Check KEEP_CLIENT_ID / KEEP_CLIENT_SECRET.");
|
|
26690
|
-
}
|
|
26691
|
-
const keep = keepFactory({ baseUrl: keepApiUrl, serviceToken });
|
|
26692
|
-
return resolver(keep, principal);
|
|
26693
|
-
}
|
|
26694
|
-
};
|
|
26695
|
-
}
|
|
26696
|
-
}
|
|
26697
|
-
});
|
|
26698
|
-
|
|
26699
|
-
// ../../packages/shuttle/dist/credentials/index.js
|
|
26700
|
-
var require_credentials = __commonJS({
|
|
26701
|
-
"../../packages/shuttle/dist/credentials/index.js"(exports2) {
|
|
26702
|
-
"use strict";
|
|
26703
|
-
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
26704
|
-
exports2.getCredentialResolver = exports2.registerCredentialResolver = exports2.createCredentialBroker = void 0;
|
|
26705
|
-
var broker_1 = require_broker();
|
|
26706
|
-
Object.defineProperty(exports2, "createCredentialBroker", { enumerable: true, get: function() {
|
|
26707
|
-
return broker_1.createCredentialBroker;
|
|
26708
|
-
} });
|
|
26709
|
-
var registry_1 = require_registry2();
|
|
26710
|
-
Object.defineProperty(exports2, "registerCredentialResolver", { enumerable: true, get: function() {
|
|
26711
|
-
return registry_1.registerCredentialResolver;
|
|
26712
|
-
} });
|
|
26713
|
-
Object.defineProperty(exports2, "getCredentialResolver", { enumerable: true, get: function() {
|
|
26714
|
-
return registry_1.getCredentialResolver;
|
|
26715
|
-
} });
|
|
26716
|
-
}
|
|
26717
|
-
});
|
|
26718
|
-
|
|
26719
|
-
// ../../packages/shuttle/dist/executors/output-gates.js
|
|
26720
|
-
var require_output_gates = __commonJS({
|
|
26721
|
-
"../../packages/shuttle/dist/executors/output-gates.js"(exports2) {
|
|
26722
|
-
"use strict";
|
|
26723
|
-
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
26724
|
-
exports2.isSanctionedPaint = isSanctionedPaint;
|
|
26725
|
-
exports2.unsanctionedPaints = unsanctionedPaints;
|
|
26726
|
-
exports2.resolvePath = resolvePath;
|
|
26727
|
-
exports2.evaluateOutputGates = evaluateOutputGates;
|
|
26728
|
-
exports2.renderRepairPrompt = renderRepairPrompt;
|
|
26729
|
-
var INPUT_REF = "input:";
|
|
26730
|
-
var COLOR_BEARING = ["fill", "stroke", "color", "stop-color", "flood-color", "lighting-color"];
|
|
26731
|
-
var INERT = /* @__PURE__ */ new Set(["none", "inherit", "initial", "unset", "transparent", "currentcolor"]);
|
|
26732
|
-
function isSanctionedPaint(raw) {
|
|
26733
|
-
const value = raw.trim().toLowerCase();
|
|
26734
|
-
if (value === "")
|
|
26735
|
-
return true;
|
|
26736
|
-
if (INERT.has(value))
|
|
26737
|
-
return true;
|
|
26738
|
-
if (/^url\(\s*['"]?#[^)'"]+['"]?\s*\)$/.test(value))
|
|
26739
|
-
return true;
|
|
26740
|
-
const varMatch = /^var\(\s*(--[a-z0-9-]+)\s*(?:,([\s\S]*))?\)$/.exec(value);
|
|
26741
|
-
if (!varMatch)
|
|
26742
|
-
return false;
|
|
26743
|
-
const [, name, fallback] = varMatch;
|
|
26744
|
-
if (!name.startsWith("--color-"))
|
|
26745
|
-
return false;
|
|
26746
|
-
return fallback === void 0 || isSanctionedPaint(fallback);
|
|
26747
|
-
}
|
|
26748
|
-
function unsanctionedPaints(source) {
|
|
26749
|
-
const found = [];
|
|
26750
|
-
const attrs = COLOR_BEARING.join("|");
|
|
26751
|
-
const attribute = new RegExp(`\\b(?:${attrs})\\s*=\\s*(['"])([\\s\\S]*?)\\1`, "gi");
|
|
26752
|
-
const declaration = new RegExp(`\\b(?:${attrs})\\s*:\\s*([^;"'}\\n]+)`, "gi");
|
|
26753
|
-
for (const [, , value] of source.matchAll(attribute)) {
|
|
26754
|
-
if (!isSanctionedPaint(value))
|
|
26755
|
-
found.push(value.trim());
|
|
26756
|
-
}
|
|
26757
|
-
for (const [, value] of source.matchAll(declaration)) {
|
|
26758
|
-
if (!isSanctionedPaint(value))
|
|
26759
|
-
found.push(value.trim());
|
|
26760
|
-
}
|
|
26761
|
-
return found;
|
|
26762
|
-
}
|
|
26763
|
-
function resolvePath(root, path) {
|
|
26764
|
-
let ctx = root;
|
|
26765
|
-
for (const seg of path.split(".")) {
|
|
26766
|
-
const project = seg.endsWith("[*]");
|
|
26767
|
-
const key = project ? seg.slice(0, -3) : seg;
|
|
26768
|
-
if (Array.isArray(ctx)) {
|
|
26769
|
-
ctx = ctx.map((el) => key ? el?.[key] : el);
|
|
26770
|
-
} else {
|
|
26771
|
-
ctx = key ? ctx?.[key] : ctx;
|
|
26772
|
-
}
|
|
26773
|
-
if (project && !Array.isArray(ctx)) {
|
|
26774
|
-
ctx = ctx == null ? [] : [ctx];
|
|
26775
|
-
}
|
|
26776
|
-
}
|
|
26777
|
-
return ctx;
|
|
26778
|
-
}
|
|
26779
|
-
function resolveRef(ref, output, inputs) {
|
|
26780
|
-
if (ref.startsWith(INPUT_REF)) {
|
|
26781
|
-
const label = ref.slice(INPUT_REF.length);
|
|
26782
|
-
const row = inputs.find((i) => i.label === label) ?? inputs.find((i) => i.label === "artifacts" && i.payload.label === label);
|
|
26783
|
-
if (!row)
|
|
26784
|
-
return void 0;
|
|
26785
|
-
return Object.prototype.hasOwnProperty.call(row.payload, "value") ? row.payload.value : row.payload;
|
|
26786
|
-
}
|
|
26787
|
-
return resolvePath(output, ref);
|
|
26788
|
-
}
|
|
26789
|
-
function asStrings(value) {
|
|
26790
|
-
if (Array.isArray(value))
|
|
26791
|
-
return value.map((v) => String(v));
|
|
26792
|
-
if (value == null)
|
|
26793
|
-
return [];
|
|
26794
|
-
return [String(value)];
|
|
26795
|
-
}
|
|
26796
|
-
var PRIMITIVES = {
|
|
26797
|
-
/**
|
|
26798
|
-
* `coverage` — the values at `got` must exactly cover the set at `want`:
|
|
26799
|
-
* every wanted value present, nothing invented, none repeated. Params:
|
|
26800
|
-
* `{ got: <output path>, want: <ref>, subject?: <noun> }`.
|
|
26801
|
-
*/
|
|
26802
|
-
coverage(params, output, inputs) {
|
|
26803
|
-
const subject = typeof params.subject === "string" ? params.subject : "item";
|
|
26804
|
-
const got = asStrings(resolveRef(String(params.got), output, inputs));
|
|
26805
|
-
const want = asStrings(resolveRef(String(params.want), output, inputs));
|
|
26806
|
-
const gotSet = new Set(got);
|
|
26807
|
-
const wantSet = new Set(want);
|
|
26808
|
-
const missing = want.filter((v) => !gotSet.has(v));
|
|
26809
|
-
const unknown = [...new Set(got.filter((v) => !wantSet.has(v)))];
|
|
26810
|
-
const seen = /* @__PURE__ */ new Set();
|
|
26811
|
-
const duplicated = [];
|
|
26812
|
-
for (const v of got) {
|
|
26813
|
-
if (seen.has(v))
|
|
26814
|
-
duplicated.push(v);
|
|
26815
|
-
else
|
|
26816
|
-
seen.add(v);
|
|
26817
|
-
}
|
|
26818
|
-
if (missing.length === 0 && unknown.length === 0 && duplicated.length === 0)
|
|
26819
|
-
return [];
|
|
26820
|
-
const parts = [];
|
|
26821
|
-
if (missing.length)
|
|
26822
|
-
parts.push(`missing ${subject}(s): [${missing.join(", ")}]`);
|
|
26823
|
-
if (unknown.length)
|
|
26824
|
-
parts.push(`not a known ${subject}: [${unknown.join(", ")}]`);
|
|
26825
|
-
if (duplicated.length)
|
|
26826
|
-
parts.push(`assessed more than once: [${[...new Set(duplicated)].join(", ")}]`);
|
|
26827
|
-
return [
|
|
26828
|
-
`every ${subject} must be covered exactly once \u2014 ${parts.join("; ")}. Return one entry per ${subject}, using its exact id.`
|
|
26829
|
-
];
|
|
26830
|
-
},
|
|
26831
|
-
/**
|
|
26832
|
-
* `non_empty_when` — the array at `path` must be non-empty, optionally only
|
|
26833
|
-
* when `when.path` equals `when.equals`. Params:
|
|
26834
|
-
* `{ path: <output path>, when?: { path: <output path>, equals: <value> } }`.
|
|
26835
|
-
*/
|
|
26836
|
-
non_empty_when(params, output) {
|
|
26837
|
-
const when = params.when;
|
|
26838
|
-
if (when && typeof when.path === "string") {
|
|
26839
|
-
if (resolvePath(output, when.path) !== when.equals)
|
|
26840
|
-
return [];
|
|
26841
|
-
}
|
|
26842
|
-
const path = String(params.path);
|
|
26843
|
-
const value = resolvePath(output, path);
|
|
26844
|
-
if (Array.isArray(value) && value.length > 0)
|
|
26845
|
-
return [];
|
|
26846
|
-
const cond = when && typeof when.path === "string" ? ` when ${when.path} is ${JSON.stringify(when.equals)}` : "";
|
|
26847
|
-
return [
|
|
26848
|
-
`'${path}' must be a non-empty array${cond}; it was ${Array.isArray(value) ? "empty" : "absent"}.`
|
|
26849
|
-
];
|
|
26850
|
-
},
|
|
26851
|
-
/**
|
|
26852
|
-
* `bounded_palette` — every colour in the sources at `path` must be named
|
|
26853
|
-
* by role rather than written as a value. Params:
|
|
26854
|
-
* `{ path: <output path>, roles?: <role names for the repair turn> }`.
|
|
26855
|
-
*
|
|
26856
|
-
* A drawing the model authors is markup the house did not write, and a
|
|
26857
|
-
* literal in it is a colour outside the consuming palette: unproved
|
|
26858
|
-
* against the colours beside it, unchecked for contrast on the ground it
|
|
26859
|
-
* lands on, and fixed to one theme. The consumer strips such a paint at
|
|
26860
|
-
* render, so an artifact that carries one silently loses it. Catching it
|
|
26861
|
-
* HERE is what makes that a repair the model can make while it still has
|
|
26862
|
-
* the drawing in hand, instead of a defect nobody sees until the picture
|
|
26863
|
-
* comes out plain.
|
|
26864
|
-
*/
|
|
26865
|
-
bounded_palette(params, output) {
|
|
26866
|
-
const path = String(params.path);
|
|
26867
|
-
const value = resolvePath(output, path);
|
|
26868
|
-
const sources = (Array.isArray(value) ? value : [value]).filter((v) => typeof v === "string" && v.length > 0);
|
|
26869
|
-
const offenders = [...new Set(sources.flatMap(unsanctionedPaints))];
|
|
26870
|
-
if (offenders.length === 0)
|
|
26871
|
-
return [];
|
|
26872
|
-
const roles = Array.isArray(params.roles) ? params.roles.map(String) : [];
|
|
26873
|
-
const vocabulary = roles.length > 0 ? ` Use one of: ${roles.join(", ")}.` : "";
|
|
26874
|
-
return [
|
|
26875
|
-
`'${path}' states ${offenders.length} colour value${offenders.length === 1 ? "" : "s"} directly (${offenders.slice(0, 8).join(", ")}${offenders.length > 8 ? ", \u2026" : ""}). Every colour must be named by role \u2014 var(--color-\u2026), currentColor, or none \u2014 never as a hex, rgb(), hsl() or colour name, because a value cannot adapt to the reader's theme and was never checked against the colours beside it.${vocabulary} Redraw with roles and return the whole output again.`
|
|
26876
|
-
];
|
|
26877
|
-
}
|
|
26878
|
-
};
|
|
26879
|
-
function evaluateOutputGates(gates, output, inputs) {
|
|
26880
|
-
const findings = [];
|
|
26881
|
-
for (const gate of gates) {
|
|
26882
|
-
const primitive = PRIMITIVES[gate.primitive];
|
|
26883
|
-
if (!primitive) {
|
|
26884
|
-
findings.push({ gate: gate.name, message: `unknown gate primitive '${gate.primitive}'` });
|
|
26885
|
-
continue;
|
|
26875
|
+
} });
|
|
26876
|
+
var git_1 = require_git();
|
|
26877
|
+
Object.defineProperty(exports2, "gitMaterializer", { enumerable: true, get: function() {
|
|
26878
|
+
return git_1.gitMaterializer;
|
|
26879
|
+
} });
|
|
26880
|
+
Object.defineProperty(exports2, "buildGitAuthEnv", { enumerable: true, get: function() {
|
|
26881
|
+
return git_1.buildGitAuthEnv;
|
|
26882
|
+
} });
|
|
26883
|
+
var overlay_1 = require_overlay();
|
|
26884
|
+
Object.defineProperty(exports2, "overlayModifier", { enumerable: true, get: function() {
|
|
26885
|
+
return overlay_1.overlayModifier;
|
|
26886
|
+
} });
|
|
26887
|
+
Object.defineProperty(exports2, "applyOverlay", { enumerable: true, get: function() {
|
|
26888
|
+
return overlay_1.applyOverlay;
|
|
26889
|
+
} });
|
|
26890
|
+
}
|
|
26891
|
+
});
|
|
26892
|
+
|
|
26893
|
+
// ../../packages/shuttle/dist/core/run-dispatch.js
|
|
26894
|
+
var require_run_dispatch = __commonJS({
|
|
26895
|
+
"../../packages/shuttle/dist/core/run-dispatch.js"(exports2) {
|
|
26896
|
+
"use strict";
|
|
26897
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
26898
|
+
exports2.GATE_REPAIR_BUDGET = void 0;
|
|
26899
|
+
exports2.runDispatch = runDispatch;
|
|
26900
|
+
exports2.runOutputGates = runOutputGates;
|
|
26901
|
+
exports2.mergeRepairedResponse = mergeRepairedResponse;
|
|
26902
|
+
var loom_1 = require_dist();
|
|
26903
|
+
var output_gates_1 = require_output_gates();
|
|
26904
|
+
var logger_1 = require_logger();
|
|
26905
|
+
var workspace_1 = require_workspace();
|
|
26906
|
+
exports2.GATE_REPAIR_BUDGET = 2;
|
|
26907
|
+
async function runDispatch(dispatch, executor, options) {
|
|
26908
|
+
const { credentials, signal } = options;
|
|
26909
|
+
const environment = executor.prepareEnvironment ? await executor.prepareEnvironment(dispatch) : void 0;
|
|
26910
|
+
let workspace = null;
|
|
26911
|
+
if (environment?.workspaceRequest) {
|
|
26912
|
+
try {
|
|
26913
|
+
workspace = await (0, workspace_1.materializeWorkspace)(environment.workspaceRequest, {
|
|
26914
|
+
...environment.materializeOptions ?? {},
|
|
26915
|
+
credentials,
|
|
26916
|
+
signal
|
|
26917
|
+
});
|
|
26918
|
+
} catch (err) {
|
|
26919
|
+
(0, logger_1.getLogger)().warn("workspace materialization failed; running prompt-only", {
|
|
26920
|
+
jobId: dispatch.job.id,
|
|
26921
|
+
error: err instanceof Error ? err.message : String(err)
|
|
26922
|
+
});
|
|
26923
|
+
workspace = null;
|
|
26886
26924
|
}
|
|
26887
|
-
|
|
26888
|
-
|
|
26925
|
+
}
|
|
26926
|
+
const ctx = {
|
|
26927
|
+
...options.reportProgress ? { reportProgress: options.reportProgress } : {},
|
|
26928
|
+
workspace,
|
|
26929
|
+
credentials
|
|
26930
|
+
};
|
|
26931
|
+
let response;
|
|
26932
|
+
try {
|
|
26933
|
+
response = await executor.execute(dispatch, signal, ctx);
|
|
26934
|
+
} catch (error) {
|
|
26935
|
+
return { kind: "executor-failed", error };
|
|
26936
|
+
} finally {
|
|
26937
|
+
if (workspace)
|
|
26938
|
+
await workspace.cleanup();
|
|
26939
|
+
}
|
|
26940
|
+
const gated = await runOutputGates(dispatch, response, executor, signal, ctx);
|
|
26941
|
+
if (!gated.ok)
|
|
26942
|
+
return { kind: "gate-failed", reason: gated.reason };
|
|
26943
|
+
return { kind: "completed", response: gated.response };
|
|
26944
|
+
}
|
|
26945
|
+
async function runOutputGates(dispatch, response, executor, signal, ctx) {
|
|
26946
|
+
let spec;
|
|
26947
|
+
try {
|
|
26948
|
+
spec = (0, loom_1.readPromptExecutionSpec)(dispatch.inputs);
|
|
26949
|
+
} catch {
|
|
26950
|
+
return { ok: true, response };
|
|
26951
|
+
}
|
|
26952
|
+
const gates = spec.gates;
|
|
26953
|
+
if (!gates || gates.length === 0)
|
|
26954
|
+
return { ok: true, response };
|
|
26955
|
+
let current = response;
|
|
26956
|
+
let result = (0, output_gates_1.evaluateOutputGates)(gates, current.parsed ?? {}, dispatch.inputs);
|
|
26957
|
+
let attempts = 0;
|
|
26958
|
+
while (!result.ok && attempts < exports2.GATE_REPAIR_BUDGET && current.continuation !== void 0 && typeof executor.continue === "function") {
|
|
26959
|
+
try {
|
|
26960
|
+
const repaired = await executor.continue(current.continuation, (0, output_gates_1.renderRepairPrompt)(result.findings), signal, ctx);
|
|
26961
|
+
current = mergeRepairedResponse(current, repaired);
|
|
26962
|
+
} catch {
|
|
26963
|
+
break;
|
|
26889
26964
|
}
|
|
26965
|
+
result = (0, output_gates_1.evaluateOutputGates)(gates, current.parsed ?? {}, dispatch.inputs);
|
|
26966
|
+
attempts += 1;
|
|
26890
26967
|
}
|
|
26891
|
-
|
|
26968
|
+
if (result.ok)
|
|
26969
|
+
return { ok: true, response: current };
|
|
26970
|
+
const detail = result.findings.map((f) => `[${f.gate}] ${f.message}`).join(" | ");
|
|
26971
|
+
return {
|
|
26972
|
+
ok: false,
|
|
26973
|
+
reason: `output gate(s) failed${attempts > 0 ? ` after ${attempts} repair attempt(s)` : ""}: ${detail}`
|
|
26974
|
+
};
|
|
26892
26975
|
}
|
|
26893
|
-
function
|
|
26894
|
-
|
|
26895
|
-
|
|
26896
|
-
|
|
26897
|
-
|
|
26898
|
-
|
|
26976
|
+
function mergeRepairedResponse(original, repaired) {
|
|
26977
|
+
const replaced = new Set(repaired.outputs.map((o) => o.label));
|
|
26978
|
+
const outputs = [...original.outputs.filter((o) => !replaced.has(o.label)), ...repaired.outputs];
|
|
26979
|
+
const usage = sumUsage(original.usage, repaired.usage);
|
|
26980
|
+
return {
|
|
26981
|
+
...original,
|
|
26982
|
+
...repaired,
|
|
26983
|
+
outputs,
|
|
26984
|
+
...usage ? { usage } : {}
|
|
26985
|
+
};
|
|
26986
|
+
}
|
|
26987
|
+
var ADDITIVE_USAGE = [
|
|
26988
|
+
"inputTokens",
|
|
26989
|
+
"outputTokens",
|
|
26990
|
+
"cacheReadInputTokens",
|
|
26991
|
+
"cacheCreationInputTokens",
|
|
26992
|
+
"costUsd",
|
|
26993
|
+
"turns"
|
|
26994
|
+
];
|
|
26995
|
+
function sumUsage(a, b) {
|
|
26996
|
+
if (!a)
|
|
26997
|
+
return b;
|
|
26998
|
+
if (!b)
|
|
26999
|
+
return a;
|
|
27000
|
+
const sum = { ...a, ...b };
|
|
27001
|
+
for (const key of ADDITIVE_USAGE) {
|
|
27002
|
+
if (a[key] === void 0 && b[key] === void 0)
|
|
27003
|
+
continue;
|
|
27004
|
+
sum[key] = (a[key] ?? 0) + (b[key] ?? 0);
|
|
27005
|
+
}
|
|
27006
|
+
if (a.toolCalls || b.toolCalls) {
|
|
27007
|
+
const calls = { ...a.toolCalls ?? {} };
|
|
27008
|
+
for (const [name, n] of Object.entries(b.toolCalls ?? {}))
|
|
27009
|
+
calls[name] = (calls[name] ?? 0) + n;
|
|
27010
|
+
sum.toolCalls = calls;
|
|
27011
|
+
}
|
|
27012
|
+
return sum;
|
|
26899
27013
|
}
|
|
26900
27014
|
}
|
|
26901
27015
|
});
|
|
26902
27016
|
|
|
26903
|
-
// ../../packages/shuttle/dist/
|
|
26904
|
-
var
|
|
26905
|
-
"../../packages/shuttle/dist/
|
|
27017
|
+
// ../../packages/shuttle/dist/credentials/registry.js
|
|
27018
|
+
var require_registry2 = __commonJS({
|
|
27019
|
+
"../../packages/shuttle/dist/credentials/registry.js"(exports2) {
|
|
26906
27020
|
"use strict";
|
|
26907
27021
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
26908
|
-
exports2.
|
|
26909
|
-
exports2.
|
|
26910
|
-
|
|
26911
|
-
|
|
26912
|
-
|
|
26913
|
-
info: 1,
|
|
26914
|
-
warn: 2,
|
|
26915
|
-
error: 3
|
|
26916
|
-
};
|
|
26917
|
-
function formatContext(context) {
|
|
26918
|
-
return Object.entries(context).map(([k, v]) => `${k}=${typeof v === "string" ? v : JSON.stringify(v)}`).join(" ");
|
|
26919
|
-
}
|
|
26920
|
-
function formatPretty(level, message, context) {
|
|
26921
|
-
const timestamp = (/* @__PURE__ */ new Date()).toISOString();
|
|
26922
|
-
const tag = level.toUpperCase().padEnd(5);
|
|
26923
|
-
const base = `[${timestamp}] ${tag} ${message}`;
|
|
26924
|
-
if (context && Object.keys(context).length > 0) {
|
|
26925
|
-
return `${base} ${formatContext(context)}`;
|
|
26926
|
-
}
|
|
26927
|
-
return base;
|
|
27022
|
+
exports2.registerCredentialResolver = registerCredentialResolver;
|
|
27023
|
+
exports2.getCredentialResolver = getCredentialResolver;
|
|
27024
|
+
var resolvers = /* @__PURE__ */ new Map();
|
|
27025
|
+
function registerCredentialResolver(name, resolver) {
|
|
27026
|
+
resolvers.set(name, resolver);
|
|
26928
27027
|
}
|
|
26929
|
-
function
|
|
26930
|
-
|
|
26931
|
-
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
26932
|
-
level,
|
|
26933
|
-
message,
|
|
26934
|
-
...context
|
|
26935
|
-
};
|
|
26936
|
-
return JSON.stringify(entry);
|
|
27028
|
+
function getCredentialResolver(name) {
|
|
27029
|
+
return resolvers.get(name);
|
|
26937
27030
|
}
|
|
26938
|
-
|
|
26939
|
-
const
|
|
26940
|
-
|
|
26941
|
-
|
|
26942
|
-
|
|
26943
|
-
|
|
26944
|
-
const
|
|
26945
|
-
|
|
26946
|
-
|
|
26947
|
-
|
|
26948
|
-
|
|
26949
|
-
|
|
26950
|
-
|
|
26951
|
-
|
|
27031
|
+
registerCredentialResolver("managed-model-key", async (keep, principal) => {
|
|
27032
|
+
const reveal = await keep.revealManagedSifterKey(principal);
|
|
27033
|
+
return reveal.apiKey;
|
|
27034
|
+
});
|
|
27035
|
+
registerCredentialResolver("github-user-token", async (keep, principal) => {
|
|
27036
|
+
try {
|
|
27037
|
+
const reveal = await keep.getUserGithubToken(principal);
|
|
27038
|
+
return reveal.access_token;
|
|
27039
|
+
} catch {
|
|
27040
|
+
return null;
|
|
27041
|
+
}
|
|
27042
|
+
});
|
|
27043
|
+
}
|
|
27044
|
+
});
|
|
27045
|
+
|
|
27046
|
+
// ../../packages/shuttle/dist/credentials/broker.js
|
|
27047
|
+
var require_broker = __commonJS({
|
|
27048
|
+
"../../packages/shuttle/dist/credentials/broker.js"(exports2) {
|
|
27049
|
+
"use strict";
|
|
27050
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
27051
|
+
exports2.createCredentialBroker = createCredentialBroker;
|
|
27052
|
+
var keep_1 = require_dist2();
|
|
27053
|
+
var env_ref_1 = require_env_ref();
|
|
27054
|
+
var registry_1 = require_registry2();
|
|
27055
|
+
function createCredentialBroker(config, deps = {}) {
|
|
27056
|
+
if (typeof config !== "object" || config === null || config.apiKeyFrom !== "job-metadata") {
|
|
27057
|
+
return null;
|
|
26952
27058
|
}
|
|
27059
|
+
const cfg = config;
|
|
27060
|
+
const keepApiUrl = (0, env_ref_1.resolveConfigStringOrEnv)(cfg, "keepApiUrl", "KEEP_API_URL");
|
|
27061
|
+
const clientId = (0, env_ref_1.resolveConfigStringOrEnv)(cfg, "keepClientId", "KEEP_CLIENT_ID");
|
|
27062
|
+
const clientSecret = (0, env_ref_1.resolveConfigStringOrEnv)(cfg, "keepClientSecret", "KEEP_CLIENT_SECRET");
|
|
27063
|
+
const stmFactory = deps.buildServiceTokenManager ?? ((c) => new keep_1.ServiceTokenManager(c));
|
|
27064
|
+
const stm = stmFactory({ keepApiUrl, clientId, clientSecret });
|
|
27065
|
+
const keepFactory = deps.buildKeepClient ?? ((c) => new keep_1.KeepClient(c));
|
|
26953
27066
|
return {
|
|
26954
|
-
|
|
26955
|
-
|
|
26956
|
-
|
|
26957
|
-
|
|
27067
|
+
async reveal({ name, principal }) {
|
|
27068
|
+
const resolver = (0, registry_1.getCredentialResolver)(name);
|
|
27069
|
+
if (!resolver)
|
|
27070
|
+
return null;
|
|
27071
|
+
const serviceToken = await stm.getToken();
|
|
27072
|
+
if (!serviceToken) {
|
|
27073
|
+
throw new Error("credential broker: Keep service-token exchange failed. Check KEEP_CLIENT_ID / KEEP_CLIENT_SECRET.");
|
|
27074
|
+
}
|
|
27075
|
+
const keep = keepFactory({ baseUrl: keepApiUrl, serviceToken });
|
|
27076
|
+
return resolver(keep, principal);
|
|
27077
|
+
}
|
|
26958
27078
|
};
|
|
26959
27079
|
}
|
|
26960
|
-
|
|
26961
|
-
|
|
26962
|
-
|
|
26963
|
-
|
|
26964
|
-
|
|
26965
|
-
|
|
26966
|
-
|
|
27080
|
+
}
|
|
27081
|
+
});
|
|
27082
|
+
|
|
27083
|
+
// ../../packages/shuttle/dist/credentials/index.js
|
|
27084
|
+
var require_credentials = __commonJS({
|
|
27085
|
+
"../../packages/shuttle/dist/credentials/index.js"(exports2) {
|
|
27086
|
+
"use strict";
|
|
27087
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
27088
|
+
exports2.getCredentialResolver = exports2.registerCredentialResolver = exports2.createCredentialBroker = void 0;
|
|
27089
|
+
var broker_1 = require_broker();
|
|
27090
|
+
Object.defineProperty(exports2, "createCredentialBroker", { enumerable: true, get: function() {
|
|
27091
|
+
return broker_1.createCredentialBroker;
|
|
27092
|
+
} });
|
|
27093
|
+
var registry_1 = require_registry2();
|
|
27094
|
+
Object.defineProperty(exports2, "registerCredentialResolver", { enumerable: true, get: function() {
|
|
27095
|
+
return registry_1.registerCredentialResolver;
|
|
27096
|
+
} });
|
|
27097
|
+
Object.defineProperty(exports2, "getCredentialResolver", { enumerable: true, get: function() {
|
|
27098
|
+
return registry_1.getCredentialResolver;
|
|
27099
|
+
} });
|
|
26967
27100
|
}
|
|
26968
27101
|
});
|
|
26969
27102
|
|
|
@@ -27527,9 +27660,8 @@ var require_shuttle = __commonJS({
|
|
|
27527
27660
|
var loom_1 = require_dist();
|
|
27528
27661
|
var chain_1 = require_chain();
|
|
27529
27662
|
var types_1 = require_types2();
|
|
27530
|
-
var
|
|
27663
|
+
var run_dispatch_1 = require_run_dispatch();
|
|
27531
27664
|
var credentials_1 = require_credentials();
|
|
27532
|
-
var output_gates_1 = require_output_gates();
|
|
27533
27665
|
var keep_1 = require_dist2();
|
|
27534
27666
|
var apply_1 = require_apply();
|
|
27535
27667
|
var environment_1 = require_environment();
|
|
@@ -27549,7 +27681,6 @@ var require_shuttle = __commonJS({
|
|
|
27549
27681
|
var audit_log_1 = require_audit_log();
|
|
27550
27682
|
var spend_tracker_1 = require_spend_tracker();
|
|
27551
27683
|
var store_1 = require_store();
|
|
27552
|
-
var GATE_REPAIR_BUDGET = 2;
|
|
27553
27684
|
var ENVIRONMENT_HOLD = "executor-environment";
|
|
27554
27685
|
function requiredExecutor(dispatch, strategy) {
|
|
27555
27686
|
if (strategy !== loom_1.PROMPT_EXECUTION_STRATEGY)
|
|
@@ -27616,36 +27747,6 @@ var require_shuttle = __commonJS({
|
|
|
27616
27747
|
function formatInstant(epochMs) {
|
|
27617
27748
|
return new Date(epochMs).toISOString().replace(/\.\d{3}Z$/, "Z");
|
|
27618
27749
|
}
|
|
27619
|
-
async function runOutputGates(dispatch, response, executor, signal, ctx) {
|
|
27620
|
-
let spec;
|
|
27621
|
-
try {
|
|
27622
|
-
spec = (0, loom_1.readPromptExecutionSpec)(dispatch.inputs);
|
|
27623
|
-
} catch {
|
|
27624
|
-
return { ok: true, response };
|
|
27625
|
-
}
|
|
27626
|
-
const gates = spec.gates;
|
|
27627
|
-
if (!gates || gates.length === 0)
|
|
27628
|
-
return { ok: true, response };
|
|
27629
|
-
let current = response;
|
|
27630
|
-
let result = (0, output_gates_1.evaluateOutputGates)(gates, current.parsed ?? {}, dispatch.inputs);
|
|
27631
|
-
let attempts = 0;
|
|
27632
|
-
while (!result.ok && attempts < GATE_REPAIR_BUDGET && current.continuation !== void 0 && typeof executor.continue === "function") {
|
|
27633
|
-
try {
|
|
27634
|
-
current = await executor.continue(current.continuation, (0, output_gates_1.renderRepairPrompt)(result.findings), signal, ctx);
|
|
27635
|
-
} catch {
|
|
27636
|
-
break;
|
|
27637
|
-
}
|
|
27638
|
-
result = (0, output_gates_1.evaluateOutputGates)(gates, current.parsed ?? {}, dispatch.inputs);
|
|
27639
|
-
attempts += 1;
|
|
27640
|
-
}
|
|
27641
|
-
if (result.ok)
|
|
27642
|
-
return { ok: true, response: current };
|
|
27643
|
-
const detail = result.findings.map((f) => `[${f.gate}] ${f.message}`).join(" | ");
|
|
27644
|
-
return {
|
|
27645
|
-
ok: false,
|
|
27646
|
-
reason: `output gate(s) failed${attempts > 0 ? ` after ${attempts} repair attempt(s)` : ""}: ${detail}`
|
|
27647
|
-
};
|
|
27648
|
-
}
|
|
27649
27750
|
var Shuttle = class {
|
|
27650
27751
|
brand;
|
|
27651
27752
|
config;
|
|
@@ -27837,35 +27938,16 @@ var require_shuttle = __commonJS({
|
|
|
27837
27938
|
const runOn = async (executor) => {
|
|
27838
27939
|
await observerChain.notify({ kind: "executor.dispatch.started", jobId, attendanceId, executor: executor.capability.id, strategy }, onObserverError);
|
|
27839
27940
|
const dispatchStartedAt = Date.now();
|
|
27840
|
-
const
|
|
27841
|
-
|
|
27842
|
-
|
|
27843
|
-
try {
|
|
27844
|
-
preparedWorkspace = await (0, workspace_1.materializeWorkspace)(environment.workspaceRequest, {
|
|
27845
|
-
...environment.materializeOptions ?? {},
|
|
27846
|
-
credentials: this.broker,
|
|
27847
|
-
signal
|
|
27848
|
-
});
|
|
27849
|
-
} catch (err) {
|
|
27850
|
-
(0, logger_1.getLogger)().warn("workspace materialization failed; running prompt-only", {
|
|
27851
|
-
jobId,
|
|
27852
|
-
error: err instanceof Error ? err.message : String(err)
|
|
27853
|
-
});
|
|
27854
|
-
preparedWorkspace = null;
|
|
27855
|
-
}
|
|
27856
|
-
}
|
|
27857
|
-
const executionCtx = {
|
|
27941
|
+
const outcome = await (0, run_dispatch_1.runDispatch)(dispatch, executor, {
|
|
27942
|
+
credentials: this.broker,
|
|
27943
|
+
signal,
|
|
27858
27944
|
reportProgress: (channel, frames) => {
|
|
27859
27945
|
void jobsClient.postProgress(jobId, { channel, frames }).then(() => activity.record()).catch(() => {
|
|
27860
27946
|
});
|
|
27861
|
-
}
|
|
27862
|
-
|
|
27863
|
-
|
|
27864
|
-
|
|
27865
|
-
let response;
|
|
27866
|
-
try {
|
|
27867
|
-
response = await executor.execute(dispatch, signal, executionCtx);
|
|
27868
|
-
} catch (err) {
|
|
27947
|
+
}
|
|
27948
|
+
});
|
|
27949
|
+
if (outcome.kind === "executor-failed") {
|
|
27950
|
+
const err = outcome.error;
|
|
27869
27951
|
const reason = `executor failed: ${err instanceof Error ? err.message : String(err)}`;
|
|
27870
27952
|
if (this.broker === null && (0, types_1.isExecutorEnvironmentError)(err)) {
|
|
27871
27953
|
this.markUnwell(executor, err, subscribeLogger);
|
|
@@ -27875,14 +27957,11 @@ var require_shuttle = __commonJS({
|
|
|
27875
27957
|
return { kind: "result", result: { status: "failed", reason, failureCode: types_1.MODEL_UNAVAILABLE } };
|
|
27876
27958
|
}
|
|
27877
27959
|
return { kind: "result", result: { status: "failed", reason } };
|
|
27878
|
-
} finally {
|
|
27879
|
-
if (preparedWorkspace)
|
|
27880
|
-
await preparedWorkspace.cleanup();
|
|
27881
27960
|
}
|
|
27882
|
-
|
|
27883
|
-
|
|
27884
|
-
|
|
27885
|
-
response =
|
|
27961
|
+
if (outcome.kind === "gate-failed") {
|
|
27962
|
+
return { kind: "result", result: { status: "failed", reason: outcome.reason } };
|
|
27963
|
+
}
|
|
27964
|
+
const response = outcome.response;
|
|
27886
27965
|
await observerChain.notify({
|
|
27887
27966
|
kind: "executor.dispatch.completed",
|
|
27888
27967
|
jobId,
|
|
@@ -28823,8 +28902,8 @@ var require_dist5 = __commonJS({
|
|
|
28823
28902
|
"../../packages/shuttle/dist/index.js"(exports2) {
|
|
28824
28903
|
"use strict";
|
|
28825
28904
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
28826
|
-
exports2.
|
|
28827
|
-
exports2.revokePairing = exports2.listPairings = exports2.PairingConfigStore = exports2.pair = exports2.scaffoldedConfigPath = exports2.planScaffold = exports2.DEFAULT_REFUSAL_MESSAGE = exports2.DEFAULT_MONTHLY_PERIOD = exports2.DEFAULT_DAILY_PERIOD = exports2.SUBSTRATE_BRAND = void 0;
|
|
28905
|
+
exports2.renderEnvironmentReport = exports2.isWorthReporting = exports2.hostOf = exports2.executorDefaultsFor = exports2.environmentReportJson = exports2.environmentPolledBy = exports2.applyEnvironment = exports2.renderTemplate = exports2.expandHome = exports2.resolvePaths = exports2.SpendStore = exports2.AuditLogStore = exports2.createSpendTrackerObserver = exports2.createAuditLogObserver = exports2.createLoggerObserver = exports2.SpendCapExceeded = exports2.ObserverChain = exports2.createCustomScriptExecutor = exports2.createWebhookExecutor = exports2.createHttpApiExecutor = exports2.createCopilotExecutor = exports2.createCodexExecutor = exports2.createClaudeCodeExecutor = exports2.MODEL_UNAVAILABLE = exports2.ExecutorModelUnavailableError = exports2.ExecutorEnvironmentError = exports2.ExecutorRegistry = exports2.AgentCredentialRevokedError = exports2.runPreflight = exports2.renderLines = exports2.renderJson = exports2.printReport = exports2.hasFailure = exports2.createProbes = exports2.checksFor = exports2.PREFLIGHT_FLOORS = exports2.PREFLIGHT_EXIT_CODE = exports2.CHECKS = exports2.readResponseLatestVersion = exports2.checkResponseMinVersion = exports2.compareSemver = exports2.UpgradeRequiredError = exports2.LATEST_VERSION_HEADER = exports2.MIN_VERSION_HEADER = exports2.loadConfig = exports2.GATE_REPAIR_BUDGET = exports2.mergeRepairedResponse = exports2.runDispatch = exports2.Shuttle = exports2.createCli = void 0;
|
|
28906
|
+
exports2.revokePairing = exports2.listPairings = exports2.PairingConfigStore = exports2.pair = exports2.scaffoldedConfigPath = exports2.planScaffold = exports2.DEFAULT_REFUSAL_MESSAGE = exports2.DEFAULT_MONTHLY_PERIOD = exports2.DEFAULT_DAILY_PERIOD = exports2.SUBSTRATE_BRAND = exports2.verificationJson = exports2.resolveEnvironment = exports2.renderVerificationLine = void 0;
|
|
28828
28907
|
var cli_1 = require_cli();
|
|
28829
28908
|
Object.defineProperty(exports2, "createCli", { enumerable: true, get: function() {
|
|
28830
28909
|
return cli_1.createCli;
|
|
@@ -28833,6 +28912,16 @@ var require_dist5 = __commonJS({
|
|
|
28833
28912
|
Object.defineProperty(exports2, "Shuttle", { enumerable: true, get: function() {
|
|
28834
28913
|
return shuttle_1.Shuttle;
|
|
28835
28914
|
} });
|
|
28915
|
+
var run_dispatch_1 = require_run_dispatch();
|
|
28916
|
+
Object.defineProperty(exports2, "runDispatch", { enumerable: true, get: function() {
|
|
28917
|
+
return run_dispatch_1.runDispatch;
|
|
28918
|
+
} });
|
|
28919
|
+
Object.defineProperty(exports2, "mergeRepairedResponse", { enumerable: true, get: function() {
|
|
28920
|
+
return run_dispatch_1.mergeRepairedResponse;
|
|
28921
|
+
} });
|
|
28922
|
+
Object.defineProperty(exports2, "GATE_REPAIR_BUDGET", { enumerable: true, get: function() {
|
|
28923
|
+
return run_dispatch_1.GATE_REPAIR_BUDGET;
|
|
28924
|
+
} });
|
|
28836
28925
|
var loader_1 = require_loader();
|
|
28837
28926
|
Object.defineProperty(exports2, "loadConfig", { enumerable: true, get: function() {
|
|
28838
28927
|
return loader_1.loadConfig;
|
|
@@ -29043,7 +29132,7 @@ var import_path = require("path");
|
|
|
29043
29132
|
var import_promises = require("fs/promises");
|
|
29044
29133
|
var import_yaml = __toESM(require_dist3());
|
|
29045
29134
|
var import_shuttle = __toESM(require_dist5());
|
|
29046
|
-
var buildVersion = true ? "0.
|
|
29135
|
+
var buildVersion = true ? "0.35.0" : pkg.version;
|
|
29047
29136
|
var AGENT_EXECUTORS = ["claude-code", "codex", "copilot"];
|
|
29048
29137
|
var sifterBrand = {
|
|
29049
29138
|
product: {
|