@wildo-ai/wildo-cli 1.1.12 → 1.1.13
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/src/commands/config/sync.command.d.ts.map +1 -1
- package/dist/src/commands/config/sync.command.js +1 -0
- package/dist/src/commands/config/sync.command.js.map +1 -1
- package/dist/src/commands/context/journey.command.d.ts.map +1 -1
- package/dist/src/commands/context/journey.command.js +8 -0
- package/dist/src/commands/context/journey.command.js.map +1 -1
- package/dist/src/commands/creation/drive.command.d.ts.map +1 -1
- package/dist/src/commands/creation/drive.command.js +2 -0
- package/dist/src/commands/creation/drive.command.js.map +1 -1
- package/dist/src/commands/fwk/publish-all.command.d.ts.map +1 -1
- package/dist/src/commands/fwk/publish-all.command.js +8 -0
- package/dist/src/commands/fwk/publish-all.command.js.map +1 -1
- package/dist/src/commands/local/dev.command.d.ts +68 -0
- package/dist/src/commands/local/dev.command.d.ts.map +1 -1
- package/dist/src/commands/local/dev.command.js +216 -8
- package/dist/src/commands/local/dev.command.js.map +1 -1
- package/dist/src/commands/local/doctor.command.d.ts +22 -9
- package/dist/src/commands/local/doctor.command.d.ts.map +1 -1
- package/dist/src/commands/local/doctor.command.js +45 -42
- package/dist/src/commands/local/doctor.command.js.map +1 -1
- package/dist/src/commands/providers/connect.command.d.ts.map +1 -1
- package/dist/src/commands/providers/connect.command.js +11 -1
- package/dist/src/commands/providers/connect.command.js.map +1 -1
- package/dist/src/commands/seal/currency.command.d.ts +13 -0
- package/dist/src/commands/seal/currency.command.d.ts.map +1 -0
- package/dist/src/commands/seal/currency.command.js +52 -0
- package/dist/src/commands/seal/currency.command.js.map +1 -0
- package/dist/src/commands/seal/seal-admin-door.utils.d.ts.map +1 -1
- package/dist/src/commands/seal/seal-admin-door.utils.js +2 -0
- package/dist/src/commands/seal/seal-admin-door.utils.js.map +1 -1
- package/dist/src/commands/seal/verify.command.d.ts +5 -0
- package/dist/src/commands/seal/verify.command.d.ts.map +1 -1
- package/dist/src/commands/seal/verify.command.js +26 -2
- package/dist/src/commands/seal/verify.command.js.map +1 -1
- package/dist/src/services/application/content-guardrail-classifier.service.d.ts +19 -0
- package/dist/src/services/application/content-guardrail-classifier.service.d.ts.map +1 -1
- package/dist/src/services/application/content-guardrail-classifier.service.js +75 -11
- package/dist/src/services/application/content-guardrail-classifier.service.js.map +1 -1
- package/dist/src/services/application/local-provider-doubles.service.d.ts +98 -0
- package/dist/src/services/application/local-provider-doubles.service.d.ts.map +1 -0
- package/dist/src/services/application/local-provider-doubles.service.js +214 -0
- package/dist/src/services/application/local-provider-doubles.service.js.map +1 -0
- package/dist/src/services/application/system-of-record-simulators.service.d.ts +21 -2
- package/dist/src/services/application/system-of-record-simulators.service.d.ts.map +1 -1
- package/dist/src/services/application/system-of-record-simulators.service.js +21 -12
- package/dist/src/services/application/system-of-record-simulators.service.js.map +1 -1
- package/dist/src/services/companion/creation-drive.service.d.ts +32 -2
- package/dist/src/services/companion/creation-drive.service.d.ts.map +1 -1
- package/dist/src/services/companion/creation-drive.service.js +61 -4
- package/dist/src/services/companion/creation-drive.service.js.map +1 -1
- package/dist/src/services/credentials/credentials.schemas.d.ts +6 -0
- package/dist/src/services/credentials/credentials.schemas.d.ts.map +1 -1
- package/dist/src/services/credentials/credentials.schemas.js +7 -1
- package/dist/src/services/credentials/credentials.schemas.js.map +1 -1
- package/dist/src/services/credentials/provider-env-vars.utils.d.ts.map +1 -1
- package/dist/src/services/credentials/provider-env-vars.utils.js +11 -3
- package/dist/src/services/credentials/provider-env-vars.utils.js.map +1 -1
- package/dist/src/services/data-services/data-services.schemas.d.ts +9 -0
- package/dist/src/services/data-services/data-services.schemas.d.ts.map +1 -1
- package/dist/src/services/data-services/data-services.schemas.js +9 -0
- package/dist/src/services/data-services/data-services.schemas.js.map +1 -1
- package/dist/src/services/deployment/docker/docker-compose-generator.service.d.ts.map +1 -1
- package/dist/src/services/deployment/docker/docker-compose-generator.service.js +7 -2
- package/dist/src/services/deployment/docker/docker-compose-generator.service.js.map +1 -1
- package/dist/src/services/deployment/local-dev-session-lease.service.d.ts.map +1 -1
- package/dist/src/services/deployment/local-dev-session-lease.service.js +22 -1
- package/dist/src/services/deployment/local-dev-session-lease.service.js.map +1 -1
- package/dist/src/services/environment/authored-infra-config.utils.d.ts.map +1 -1
- package/dist/src/services/environment/authored-infra-config.utils.js +1 -0
- package/dist/src/services/environment/authored-infra-config.utils.js.map +1 -1
- package/dist/src/services/environment/authored-infra-member-authority.d.ts.map +1 -1
- package/dist/src/services/environment/authored-infra-member-authority.js +5 -0
- package/dist/src/services/environment/authored-infra-member-authority.js.map +1 -1
- package/dist/src/services/environment/env-configuration-generator.service.d.ts.map +1 -1
- package/dist/src/services/environment/env-configuration-generator.service.js +6 -3
- package/dist/src/services/environment/env-configuration-generator.service.js.map +1 -1
- package/dist/src/services/environment/env-vars-builder.service.d.ts +6 -0
- package/dist/src/services/environment/env-vars-builder.service.d.ts.map +1 -1
- package/dist/src/services/environment/env-vars-builder.service.js +24 -1
- package/dist/src/services/environment/env-vars-builder.service.js.map +1 -1
- package/dist/src/services/environment/environment-hydration.utils.d.ts.map +1 -1
- package/dist/src/services/environment/environment-hydration.utils.js +1 -0
- package/dist/src/services/environment/environment-hydration.utils.js.map +1 -1
- package/dist/src/services/environment/environment.schemas.d.ts +7 -1
- package/dist/src/services/environment/environment.schemas.d.ts.map +1 -1
- package/dist/src/services/environment/environment.schemas.js.map +1 -1
- package/dist/src/services/environment/runtime-bootstrap.service.d.ts +2 -0
- package/dist/src/services/environment/runtime-bootstrap.service.d.ts.map +1 -1
- package/dist/src/services/environment/runtime-bootstrap.service.js +4 -0
- package/dist/src/services/environment/runtime-bootstrap.service.js.map +1 -1
- package/dist/src/services/framework/framework-docker-publish.service.d.ts +13 -0
- package/dist/src/services/framework/framework-docker-publish.service.d.ts.map +1 -1
- package/dist/src/services/framework/framework-docker-publish.service.js +24 -7
- package/dist/src/services/framework/framework-docker-publish.service.js.map +1 -1
- package/dist/src/services/registry/provider-connect.service.d.ts +57 -1
- package/dist/src/services/registry/provider-connect.service.d.ts.map +1 -1
- package/dist/src/services/registry/provider-connect.service.js +63 -2
- package/dist/src/services/registry/provider-connect.service.js.map +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +18 -18
- package/scripts/app-dependency-alignment/propagated-engine-overrides.json +1 -1
- package/wildo-framework.info.json +1 -1
|
@@ -18,6 +18,10 @@
|
|
|
18
18
|
* limit holds until its stated reset, the connectivity hold waits on the network, or the companion is down;
|
|
19
19
|
* - **stop**, naming the rule that fired and what it waits for.
|
|
20
20
|
*
|
|
21
|
+
* The loop's model choosing to stop is not the goal reached: the drive then asks where the application stands against its
|
|
22
|
+
* own requirements (`GET /creation/requirements/standing`, #3701), and calls the goal reached only when no requirement
|
|
23
|
+
* carries an open item.
|
|
24
|
+
*
|
|
21
25
|
* After every loop, it accepts what the autonomy posture says the SYSTEM accepts (`POST /creation/drive/accept`, never
|
|
22
26
|
* inside a live coding run), and stops when the posture leaves acceptance to a person: a marked critical gate, armed.
|
|
23
27
|
*
|
|
@@ -49,8 +53,23 @@ export var CreationDriveUntil;
|
|
|
49
53
|
/** Why the driver stopped. Every exit is one of these, and the report names it with what it waits for. */
|
|
50
54
|
export var CreationDriveStopRule;
|
|
51
55
|
(function (CreationDriveStopRule) {
|
|
52
|
-
/**
|
|
56
|
+
/**
|
|
57
|
+
* The loop's selector chose to stop with nothing running and nothing asked, AND the application's requirements carry no
|
|
58
|
+
* open item (#3701): the goal is reached by measurement, never by the model's judgement alone.
|
|
59
|
+
*/
|
|
53
60
|
CreationDriveStopRule["GOAL_REACHED"] = "goal-reached";
|
|
61
|
+
/**
|
|
62
|
+
* The loop's selector chose to stop, and the application's own requirements still carry open items (#3701): a reported
|
|
63
|
+
* gap, a configuration that does not meet one, one nothing addresses or with no build work landed. The model judged the
|
|
64
|
+
* creation done and the measurement says it is not, so the drive stops and names them: each is closed by the task named
|
|
65
|
+
* beside it, or by a person who starts refinement or decides the requirement is out of scope.
|
|
66
|
+
*/
|
|
67
|
+
CreationDriveStopRule["REQUIREMENTS_OPEN"] = "requirements-open";
|
|
68
|
+
/**
|
|
69
|
+
* The loop's selector chose to stop, and where the application stands against its requirements could not be read
|
|
70
|
+
* (#3701): whether the goal is reached is unknown, so the drive says that rather than claim it.
|
|
71
|
+
*/
|
|
72
|
+
CreationDriveStopRule["GOAL_UNMEASURED"] = "goal-unmeasured";
|
|
54
73
|
/** Nothing is eligible to run, nothing runs, nothing is asked. */
|
|
55
74
|
CreationDriveStopRule["NOTHING_LEFT"] = "nothing-left";
|
|
56
75
|
/**
|
|
@@ -229,9 +248,8 @@ export function decideCreationDriveStep(observation) {
|
|
|
229
248
|
const last = observation.lastLoop;
|
|
230
249
|
if (last !== undefined && !last.waitedSince) {
|
|
231
250
|
// The loop chose to stop, or found nothing eligible, and nothing ran or lifted since: asking again is the same answer.
|
|
232
|
-
if (last.stoppedBecause === LOOP_CHOSE_TO_STOP)
|
|
233
|
-
return
|
|
234
|
-
}
|
|
251
|
+
if (last.stoppedBecause === LOOP_CHOSE_TO_STOP)
|
|
252
|
+
return judgeChosenStop(last.stopRationale ?? 'the loop chose to stop', observation.requirements);
|
|
235
253
|
if (last.stoppedBecause === LOOP_NOTHING_ELIGIBLE)
|
|
236
254
|
return stop(CreationDriveStopRule.NOTHING_LEFT, 'nothing is eligible to run');
|
|
237
255
|
}
|
|
@@ -242,6 +260,29 @@ const LOOP_CHOSE_TO_STOP = 'CHOSE_TO_STOP';
|
|
|
242
260
|
const LOOP_NOTHING_ELIGIBLE = 'NOTHING_ELIGIBLE';
|
|
243
261
|
const LOOP_ALL_LANES_FAILED = 'ALL_LANES_FAILED';
|
|
244
262
|
const LOOP_INTERRUPTED_BY_ENVIRONMENT = 'INTERRUPTED_BY_ENVIRONMENT';
|
|
263
|
+
/** How many open items a stop names in words; the rest are counted. */
|
|
264
|
+
const OPEN_ITEMS_NAMED = 5;
|
|
265
|
+
/**
|
|
266
|
+
* The loop chose to stop: whether the goal is reached is the REQUIREMENTS' answer, not the model's (#3701). Goal reached
|
|
267
|
+
* only when the standing was read and carries no open item; open items stop the drive on a rule that names them;
|
|
268
|
+
* an unread standing is said to be unread. Run 42886943490 stopped "goal-reached" with 16 of 24 requirements partly met.
|
|
269
|
+
*/
|
|
270
|
+
function judgeChosenStop(rationale, requirements) {
|
|
271
|
+
const standing = requirements !== undefined && 'standing' in requirements ? requirements.standing : undefined;
|
|
272
|
+
if (standing === undefined) {
|
|
273
|
+
const why = requirements !== undefined && 'unreadBecause' in requirements ? requirements.unreadBecause : 'it was not read';
|
|
274
|
+
return stop(CreationDriveStopRule.GOAL_UNMEASURED, `${rationale} — but where the application stands against its requirements could not be read (${why}): wildo creation drive again, or wildo context journey`);
|
|
275
|
+
}
|
|
276
|
+
if (standing.openItems.length === 0) {
|
|
277
|
+
return stop(CreationDriveStopRule.GOAL_REACHED, `${rationale} Every one of the ${standing.requirementCount} requirement(s) is met by what the reading measures (stage ${standing.stage}).`);
|
|
278
|
+
}
|
|
279
|
+
const requirementsWithItems = new Set(standing.openItems.map((item) => item.requirementRef)).size;
|
|
280
|
+
const named = standing.openItems.slice(0, OPEN_ITEMS_NAMED)
|
|
281
|
+
.map((item) => `${item.requirementRef}: ${item.detail}${item.closedByTaskRef === null ? '' : ` (closed by ${item.closedByTaskRef})`}`);
|
|
282
|
+
const rest = standing.openItems.length - named.length;
|
|
283
|
+
return stop(CreationDriveStopRule.REQUIREMENTS_OPEN, `the loop chose to stop (${rationale}) while ${requirementsWithItems} of ${standing.requirementCount} requirement(s) carry ${standing.openItems.length} open item(s): `
|
|
284
|
+
+ `${named.join('; ')}${rest > 0 ? `; and ${rest} more` : ''}. Start refinement on them, or decide they are out of scope: wildo creation feed`);
|
|
285
|
+
}
|
|
245
286
|
function stop(rule, waitingFor) {
|
|
246
287
|
return { action: CreationDriveAction.STOP, rule, waitingFor };
|
|
247
288
|
}
|
|
@@ -279,6 +320,8 @@ export async function runCreationDrive(port, options) {
|
|
|
279
320
|
let spentUsd;
|
|
280
321
|
let lastLoop;
|
|
281
322
|
let networkWaitSinceMs;
|
|
323
|
+
/** The standing read for the last loop's chosen stop (#3701); cleared when a loop runs, so a stale one never judges. */
|
|
324
|
+
let requirements;
|
|
282
325
|
const finish = (rule, waitingFor, providerAccountRefusal) => {
|
|
283
326
|
port.progress(`Stopped: ${rule} — ${waitingFor}`);
|
|
284
327
|
return {
|
|
@@ -352,9 +395,22 @@ export async function runCreationDrive(port, options) {
|
|
|
352
395
|
port.progress(`The companion restarted (now since ${status.companionStartedAt}); re-reading its state`);
|
|
353
396
|
}
|
|
354
397
|
companionStartedAt = status.companionStartedAt;
|
|
398
|
+
/*
|
|
399
|
+
* The goal is the requirements' to call (#3701): once the last loop chose to stop with nothing since, read where the
|
|
400
|
+
* application stands, once for that loop. It derives the reading, so it is never read on a poll.
|
|
401
|
+
*/
|
|
402
|
+
if (requirements === undefined && lastLoop?.stoppedBecause === LOOP_CHOSE_TO_STOP && !lastLoop.waitedSince) {
|
|
403
|
+
try {
|
|
404
|
+
requirements = { standing: await port.readRequirementsStanding() };
|
|
405
|
+
}
|
|
406
|
+
catch (error) {
|
|
407
|
+
requirements = { unreadBecause: describeCaughtError(error) };
|
|
408
|
+
}
|
|
409
|
+
}
|
|
355
410
|
const decide = () => decideCreationDriveStep({
|
|
356
411
|
feed, status, elapsedMs: port.now() - startedAt, maximumMs: options.maximumMs, spentUsd, maximumUsd: options.maximumUsd,
|
|
357
412
|
nowMs: port.now(), ...(networkWaitSinceMs === undefined ? {} : { networkWaitSinceMs }), ...(lastLoop ? { lastLoop } : {}),
|
|
413
|
+
...(requirements === undefined ? {} : { requirements }),
|
|
358
414
|
});
|
|
359
415
|
let decision = decide();
|
|
360
416
|
/*
|
|
@@ -387,6 +443,7 @@ export async function runCreationDrive(port, options) {
|
|
|
387
443
|
}
|
|
388
444
|
networkWaitSinceMs = undefined;
|
|
389
445
|
loops += 1;
|
|
446
|
+
requirements = undefined;
|
|
390
447
|
port.progress(`Loop ${loops}: up to ${CREATION_DRIVE_ROUNDS_PER_LOOP} rounds toward the goal`);
|
|
391
448
|
let result;
|
|
392
449
|
try {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"creation-drive.service.js","sourceRoot":"","sources":["../../../../src/services/companion/creation-drive.service.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AACH,OAAO,EACL,8BAA8B,EAC9B,6BAA6B,EAC7B,4BAA4B,GAI7B,MAAM,gCAAgC,CAAC;AACxC,OAAO,EAAE,mCAAmC,EAAoC,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAInI,mGAAmG;AACnG,MAAM,CAAN,IAAY,kBAEX;AAFD,WAAY,kBAAkB;IAC5B,qCAAe,CAAA;AACjB,CAAC,EAFW,kBAAkB,KAAlB,kBAAkB,QAE7B;AAED,0GAA0G;AAC1G,MAAM,CAAN,IAAY,qBAmDX;AAnDD,WAAY,qBAAqB;IAC/B,wGAAwG;IACxG,sDAA6B,CAAA;IAC7B,kEAAkE;IAClE,sDAA6B,CAAA;IAC7B;;;OAGG;IACH,kEAAyC,CAAA;IACzC,0HAA0H;IAC1H,sDAA6B,CAAA;IAC7B,oFAAoF;IACpF,4EAAmD,CAAA;IACnD,6FAA6F;IAC7F,kDAAyB,CAAA;IACzB,6GAA6G;IAC7G,sDAA6B,CAAA;IAC7B,yGAAyG;IACzG,sDAA6B,CAAA;IAC7B,2FAA2F;IAC3F,kFAAyD,CAAA;IACzD,oFAAoF;IACpF,8DAAqC,CAAA;IACrC,uCAAuC;IACvC,kEAAyC,CAAA;IACzC,kCAAkC;IAClC,wDAA+B,CAAA;IAC/B,yGAAyG;IACzG,4EAAmD,CAAA;IACnD,uFAAuF;IACvF,wEAA+C,CAAA;IAC/C;;;OAGG;IACH,sDAA6B,CAAA;IAC7B;;;;;OAKG;IACH,8EAAqD,CAAA;IACrD;;;;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M,CAAC,YAAY,CAAC,sBAAsB,CAAC,CAAC;QAC9E,CAAC;QACD,IAAI,MAAM,aAAa,EAAE;YAAE,OAAO,MAAM,CAAC,qBAAqB,CAAC,0BAA0B,EAAE,mBAAmB,CAAC,CAAC;QAChH,IAAI,MAAM,CAAC,cAAc,KAAK,qBAAqB,EAAE,CAAC;YACpD,MAAM,QAAQ,GAAG,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,GAAG,IAAI,CAAC,WAAW,KAAK,IAAI,CAAC,OAAO,EAAE,CAAC,IAAI,EAAE,CAAC;YACvI,OAAO,MAAM,CAAC,qBAAqB,CAAC,YAAY,EAAE,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,qCAAqC,CAAC,CAAC;QAClH,CAAC;QACD,IAAI,MAAM,CAAC,cAAc,KAAK,+BAA+B,EAAE,CAAC;YAC9D,wBAAwB,IAAI,CAAC,CAAC;YAC9B,IAAI,wBAAwB,IAAI,gDAAgD,EAAE,CAAC;gBACjF,OAAO,MAAM,CAAC,qBAAqB,CAAC,uBAAuB,EAAE,MAAM,CAAC,YAAY,EAAE,OAAO,IAAI,kCAAkC,CAAC,CAAC;YACnI,CAAC;YACD,QAAQ,GAAG,EAAE,GAAG,QAAQ,EAAE,WAAW,EAAE,IAAI,EAAE,CAAC;QAChD,CAAC;aAAM,CAAC;YACN,wBAAwB,GAAG,CAAC,CAAC;QAC/B,CAAC;IACH,CAAC;AACH,CAAC","sourcesContent":["/**\n * # `wildo creation drive --until stuck` — the unattended creation driver (#2233)\n *\n * A full creation still needed a person, or a hand-written script, to move it from one round to the next: in run 004\n * (`app-creation-test-004`) the driving session ran the umbrella or a build wave, accepted what landed, restarted the\n * companion when it fell over, and stopped on the first real blocker. That loop is the shape of \"run a creation\", and\n * it lived outside the framework. `wildo creation loop` covered one piece of it (a model chooses each round) and none of\n * the rest: it stopped at 20 rounds, never accepted, died with the companion and stopped only when the model did.\n *\n * ## The shape\n *\n * Each step reads the companion's durable state (the creation FEED: what Home shows, holds included; and the drive\n * STATUS: what still runs), decides ONE of three things with {@link decideCreationDriveStep}, and does it:\n *\n * - **run** a bounded `wildo creation loop` (up to its 20-round ceiling): the companion gates, a model chooses, the\n * chosen lanes run, the build lane among them;\n * - **wait**: something still runs (a loop, a wave, a lane the usage-limit resume relaunched), the coding agent's usage\n * limit holds until its stated reset, the connectivity hold waits on the network, or the companion is down;\n * - **stop**, naming the rule that fired and what it waits for.\n *\n * After every loop, it accepts what the autonomy posture says the SYSTEM accepts (`POST /creation/drive/accept`, never\n * inside a live coding run), and stops when the posture leaves acceptance to a person: a marked critical gate, armed.\n *\n * ## Why in the CLI and not in the companion\n *\n * A companion restart ends every request it holds and every in-process timer. The driver lives in another process, so a\n * restart is a WAIT: it polls until the companion answers again and reads the same durable rows (the loop's state is\n * the working tree; the run records survive). The restart itself is on the intervention ledger when the companion\n * booted with runs in flight (#2231), and the driver also counts the restarts it saw, from the companion's start time.\n *\n * ## Holds it respects\n *\n * - a person's `wildo build stop` (#3206) is a STOP: a stopped build is never resumed unattended;\n * - the coding agent's usage limit (#2388) is a WAIT until it lifts; the companion's own resume relaunches what it\n * paused (#2463), and the driver waits for that run to drain before choosing again;\n * - the connectivity hold (#3236, #3262) is a WAIT until the agent's API answers.\n *\n * Ceilings are the person's, like `loop`'s iteration ceiling: a wall clock and a spend in US dollars, both required.\n * The spend is the run report's measured total since the drive began (#2231, #2232), a floor wherever a run reported no\n * cost.\n */\nimport {\n CreationDriveAcceptDisposition,\n WorkbenchCreationHomeLineKind,\n WorkbenchCreationHomeSection,\n type CreationConsole_Feed,\n type CreationDrive_AcceptOutcome,\n type CreationDrive_Status,\n} from '@wildo-ai/platform-core-shared';\nimport { describeModelProviderAccountRefusal, type ModelProviderAccountRefusal, describeCaughtError } from '@wildo-ai/saas-models';\n\nimport type { ConsoleLoopResult } from './creation-console.service';\n\n/** The only drive mode: run until a stop rule fires. Named so `--until` is a closed vocabulary. */\nexport enum CreationDriveUntil {\n STUCK = 'stuck',\n}\n\n/** Why the driver stopped. Every exit is one of these, and the report names it with what it waits for. */\nexport enum CreationDriveStopRule {\n /** The loop's selector chose to stop with nothing running and nothing asked: it judged the goal met. */\n GOAL_REACHED = 'goal-reached',\n /** Nothing is eligible to run, nothing runs, nothing is asked. */\n NOTHING_LEFT = 'nothing-left',\n /**\n * A question only the creator can answer: a playbook's clarification, a coding run parked on a question, or an interview\n * whose answer would date work the next round could run (#3361).\n */\n WAITING_ON_CREATOR = 'waiting-on-creator',\n /** The build plan can run nothing until the creator unblocks it (a task that cannot land, retired after its attempts). */\n PLAN_BLOCKED = 'plan-blocked',\n /** A person's `wildo build stop` holds the build; only a person starts it again. */\n BUILD_STOPPED_BY_PERSON = 'build-stopped-by-person',\n /** The build lane holds dispatch because a backend does not run the current tree (#3215). */\n BUILD_HELD = 'build-held',\n /** Every lane of a loop round failed: choosing again over the same state would spend without progressing. */\n LANES_FAILED = 'lanes-failed',\n /** The companion refused to run the loop (a preflight failure, a refusal whose remedy is a decision). */\n LOOP_REFUSED = 'loop-refused',\n /** The autonomy posture leaves acceptance to a person: a marked critical gate is armed. */\n ACCEPTANCE_HELD_FOR_PERSON = 'acceptance-held-for-person',\n /** The creation preflight found what would stop the run, before the first round. */\n PREFLIGHT_FAILED = 'preflight-failed',\n /** The person's wall-clock ceiling. */\n WALL_CLOCK_CEILING = 'wall-clock-ceiling',\n /** The person's spend ceiling. */\n SPEND_CEILING = 'spend-ceiling',\n /** The environment stopped the loop on consecutive rounds, past the loop's own recovery wait (#3235). */\n ENVIRONMENT_INTERRUPTED = 'environment-interrupted',\n /** The companion did not answer for {@link CREATION_DRIVE_COMPANION_DOWN_LIMIT_MS}. */\n COMPANION_UNREACHABLE = 'companion-unreachable',\n /**\n * The coding agent's API has not answered along its route for {@link CREATION_DRIVE_NETWORK_WAIT_LIMIT_MS}: nothing\n * can be built, and the wait has outlived what a network blip is. The person checks the network, or ends the hold.\n */\n NETWORK_LOST = 'network-lost',\n /**\n * A model provider's ACCOUNT refused the companion's or the coding agent's call (#3204): no credits left, a spend or\n * usage limit, billing. The ENVIRONMENT's condition, never the application's: nothing the creation did caused it, and\n * nothing it can do lifts it. A person adds credits or raises the limit in that provider's console, then runs the drive\n * again. Stopped on at once, never after consecutive loops: a loop run again is refused identically.\n */\n PROVIDER_ACCOUNT_REFUSED = 'provider-account-refused',\n /**\n * A verification check cannot be asked for a host cause (#3423, #3432): `wildo` is not on the companion's PATH, or the\n * installed one lacks the verb a check asks, or one check failed the same way on two tasks. Every build task's check\n * would fail the same way, so the companion admits no coding turn. The host's condition: a person repairs it (the next\n * admission asks first), then runs the drive again.\n */\n VERIFICATION_TOOL_UNAVAILABLE = 'verification-tool-unavailable',\n}\n\n/** What the driver waits for when it waits. */\nexport enum CreationDriveWaitReason {\n /** A loop or a detached run (a wave, a lane, a usage-limit resume) still runs in the companion. */\n RUNS_IN_FLIGHT = 'runs-in-flight',\n /** The coding agent's account usage limit holds the build until its stated reset (#2388). */\n CODING_AGENT_USAGE_LIMIT = 'coding-agent-usage-limit',\n /** A coding run lost the network; no coding turn starts until the agent's API answers (#3236, #3262). */\n CODING_AGENT_CONNECTIVITY = 'coding-agent-connectivity',\n /** The companion does not answer (a restart, a crash). */\n COMPANION_DOWN = 'companion-down',\n}\n\n/** How long one wait lasts before the driver reads the state again. */\nexport const CREATION_DRIVE_POLL_INTERVAL_MS = 30_000;\n/** How long the companion may stay unreachable before the drive stops. A restart takes seconds to a few minutes. */\nexport const CREATION_DRIVE_COMPANION_DOWN_LIMIT_MS = 15 * 60 * 1000;\n/**\n * How long the drive waits on the coding agent's network before it stops {@link CreationDriveStopRule.NETWORK_LOST}: three\n * times the coding admission's own twenty-minute bound, so an outage of an hour (app-creation-test-007 measured 35 min)\n * is waited through, and a five-hour one is the person's to see.\n */\nexport const CREATION_DRIVE_NETWORK_WAIT_LIMIT_MS = 60 * 60 * 1000;\n/** The loop's own ceiling per request (`POST /playbooks/loop` caps it at 20). */\nexport const CREATION_DRIVE_ROUNDS_PER_LOOP = 20;\n/** Consecutive loops the environment interrupted before the drive stops (each already waited up to 10 minutes, #3235). */\nexport const CREATION_DRIVE_MAXIMUM_CONSECUTIVE_INTERRUPTIONS = 3;\n/** The ASKED kinds that stop a run until the creator acts. A governance document's fact does not: it blocks no run. */\nconst ASKED_KINDS_THAT_STOP: ReadonlyMap<WorkbenchCreationHomeLineKind, CreationDriveStopRule> = new Map([\n [WorkbenchCreationHomeLineKind.CLARIFICATION, CreationDriveStopRule.WAITING_ON_CREATOR],\n [WorkbenchCreationHomeLineKind.PARKED_QUESTION, CreationDriveStopRule.WAITING_ON_CREATOR],\n /*\n * An interview whose answer would date work the next round could run (#3361). The round withholds that work, so the\n * drive stops and names the interview, as for a clarification, rather than run on without it.\n */\n [WorkbenchCreationHomeLineKind.INTERVIEW_DATES_NEXT_WORK, CreationDriveStopRule.WAITING_ON_CREATOR],\n [WorkbenchCreationHomeLineKind.SPECIFICATION_FAULT_HOLDS_THE_PLAN, CreationDriveStopRule.PLAN_BLOCKED],\n [WorkbenchCreationHomeLineKind.UNBLOCK_THE_PLAN, CreationDriveStopRule.PLAN_BLOCKED],\n]);\n\n/** What the driver knows when it decides its next step. */\nexport interface CreationDriveObservation {\n readonly feed: CreationConsole_Feed;\n readonly status: CreationDrive_Status;\n readonly elapsedMs: number;\n readonly maximumMs: number;\n /** Measured spend since the drive began, USD; undefined when the report could not be read. */\n readonly spentUsd: number | undefined;\n readonly maximumUsd: number;\n /** How the last loop ended, and whether the driver waited on anything since (which makes running again worth it). */\n readonly lastLoop?: { readonly stoppedBecause: string; readonly stopRationale?: string; readonly waitedSince: boolean };\n /** Since when the drive has waited on the coding agent's network without a break (ms on the drive's clock). */\n readonly networkWaitSinceMs?: number;\n readonly nowMs?: number;\n}\n\nexport type CreationDriveDecision =\n | { readonly action: CreationDriveAction.RUN_LOOP }\n | { readonly action: CreationDriveAction.WAIT; readonly reason: CreationDriveWaitReason; readonly detail: string }\n | { readonly action: CreationDriveAction.STOP; readonly rule: CreationDriveStopRule; readonly waitingFor: string; readonly providerAccountRefusal?: ModelProviderAccountRefusal };\n\nexport enum CreationDriveAction {\n RUN_LOOP = 'run-loop',\n WAIT = 'wait',\n STOP = 'stop',\n}\n\n/**\n * The next step, from what the companion's durable rows say now. Order is the rule:\n * a person's stop first (it is theirs); the person's ceilings; anything still running (never start a loop over a\n * running one); what waits on the creator; a backend that does not boot; the holds only a person lifts (a refused\n * provider account, a build check's command missing from PATH); the holds that lift on their own; then the last loop's\n * own verdict when nothing happened since; else run.\n */\nexport function decideCreationDriveStep(observation: CreationDriveObservation): CreationDriveDecision {\n const { feed, status } = observation;\n // Read live from the status first: the feed may be an earlier snapshot, and a stop asked a moment ago holds now.\n const stoppedSince = status.buildStoppedSince ?? feed.buildPreparation?.heldByStopSince ?? null;\n if (stoppedSince !== null) {\n return stop(CreationDriveStopRule.BUILD_STOPPED_BY_PERSON, `a person stopped the build at ${stoppedSince}; start it again with: wildo build run`);\n }\n if (observation.elapsedMs >= observation.maximumMs) {\n return stop(CreationDriveStopRule.WALL_CLOCK_CEILING, `the drive's wall-clock ceiling (${formatHours(observation.maximumMs)}); run it again to continue`);\n }\n if (observation.spentUsd !== undefined && observation.spentUsd >= observation.maximumUsd) {\n return stop(CreationDriveStopRule.SPEND_CEILING, `the drive's spend ceiling (USD ${observation.maximumUsd}; measured USD ${observation.spentUsd.toFixed(2)})`);\n }\n if (status.loopsInFlight > 0 || status.detachedRunsInFlight > 0 || (status.executionsInFlight ?? 0) > 0) {\n return wait(CreationDriveWaitReason.RUNS_IN_FLIGHT, `${status.loopsInFlight} loop(s), ${status.detachedRunsInFlight} detached run(s) and ${status.executionsInFlight ?? 0} playbook execution(s) still running`);\n }\n for (const line of feed.lines) {\n if (line.section !== WorkbenchCreationHomeSection.ASKED) continue;\n const rule = ASKED_KINDS_THAT_STOP.get(line.kind);\n if (rule !== undefined) return stop(rule, describeAskedLine(line.kind, line.taskRef ?? line.playbookRef ?? line.subject ?? line.targetResourceId, line.subject));\n }\n const bootFailures = feed.buildHold?.bootFailures ?? [];\n /*\n * Not while the build lane still owes the repair of a start the application's own code refused (#3204): the lane runs\n * it, bounded per round, and only once it is spent does the hold need a person. Reference run 42696531261 stopped here\n * on two refusals a build task's code caused, with nothing having tried to repair them.\n */\n if (bootFailures.length > 0 && feed.buildHold?.startupRepairOwed !== true) {\n return stop(CreationDriveStopRule.BUILD_HELD, bootFailures.map((failure) => `${failure.serviceIdentifier} does not start: ${failure.remedy}`).join('; '));\n }\n /*\n * The coding agent's provider ACCOUNT refused its turn (#3204). The companion holds the build and re-asks the account\n * every thirty minutes, so a person who adds credits loses nothing; but nothing ever lifts it on its own, so an\n * unattended drive stops here rather than wait for a \"resume\" that only re-asks. Read from the live status first (a\n * pending resume beside it is that re-ask, never a reset), else from the feed's own line.\n */\n const accountRefusal = status.codingAgentAccountRefusal;\n const refusedLine = feed.lines.find((line) => line.kind === WorkbenchCreationHomeLineKind.CODING_AGENT_ACCOUNT_REFUSED);\n if (accountRefusal !== undefined || refusedLine !== undefined) {\n const sentence = accountRefusal !== undefined ? describeModelProviderAccountRefusal(accountRefusal) : refusedLine?.subject ?? 'the coding agent\\'s provider account refused to work';\n return {\n action: CreationDriveAction.STOP,\n rule: CreationDriveStopRule.PROVIDER_ACCOUNT_REFUSED,\n waitingFor: `the coding agent's provider account: ${sentence} The build re-asks it every 30 minutes; run the drive again once it is fixed.`,\n ...(accountRefusal !== undefined ? { providerAccountRefusal: accountRefusal } : {}),\n };\n }\n /*\n * A build check cannot be asked for a host cause (#3423, #3432): a command not on PATH, one lacking the verb, the same\n * failure on two tasks. Nothing the drive does lifts it, so it stops; the line's subject is the cause and its remedy.\n */\n const toolUnavailable = feed.lines.find((line) => line.kind === WorkbenchCreationHomeLineKind.VERIFICATION_TOOL_UNAVAILABLE);\n if (toolUnavailable !== undefined) {\n return stop(CreationDriveStopRule.VERIFICATION_TOOL_UNAVAILABLE,\n `the build's checks, which cannot run (met by build task ${toolUnavailable.taskRef ?? toolUnavailable.targetResourceId}), so no coding turn starts: `\n + `${toolUnavailable.subject ?? 'a command the checks run is unavailable.'} Then run the drive again.`);\n }\n const usageLimit = feed.lines.find((line) => line.kind === WorkbenchCreationHomeLineKind.CODING_AGENT_USAGE_LIMITED);\n if (usageLimit !== undefined || status.pendingBuildResume !== undefined) {\n const resumesAt = status.pendingBuildResume?.resumesAt ?? usageLimit?.subject ?? 'its reset';\n return wait(CreationDriveWaitReason.CODING_AGENT_USAGE_LIMIT, `the coding agent's usage limit; the build resumes on its own at ${resumesAt}`);\n }\n /*\n * Waited on only when the hold has a ROUTE: its background probe ends it when the network returns. A hold with no route\n * (an agent with no known API host, a proxy it cannot use) is ended only by the next coding admission, so waiting on it\n * would wait forever; the loop runs, and its build's next turn is the check (review of 6fe527ed3).\n */\n const connectivity = feed.lines.find((line) => line.kind === WorkbenchCreationHomeLineKind.CODING_AGENT_CONNECTIVITY_LOST && line.subject !== null);\n if (connectivity !== undefined) {\n if (observation.networkWaitSinceMs !== undefined && observation.nowMs !== undefined && observation.nowMs - observation.networkWaitSinceMs >= CREATION_DRIVE_NETWORK_WAIT_LIMIT_MS) {\n return stop(CreationDriveStopRule.NETWORK_LOST, `the coding agent's API (${connectivity.subject}) has not answered for ${formatHours(CREATION_DRIVE_NETWORK_WAIT_LIMIT_MS)}; once the network is back: wildo build rearm ${connectivity.taskRef ?? '<task>'} --reason environment`);\n }\n return wait(CreationDriveWaitReason.CODING_AGENT_CONNECTIVITY, `the coding agent's network; waiting for ${connectivity.subject} to answer`);\n }\n const last = observation.lastLoop;\n if (last !== undefined && !last.waitedSince) {\n // The loop chose to stop, or found nothing eligible, and nothing ran or lifted since: asking again is the same answer.\n if (last.stoppedBecause === LOOP_CHOSE_TO_STOP) {\n return stop(CreationDriveStopRule.GOAL_REACHED, last.stopRationale ?? 'the loop chose to stop');\n }\n if (last.stoppedBecause === LOOP_NOTHING_ELIGIBLE) return stop(CreationDriveStopRule.NOTHING_LEFT, 'nothing is eligible to run');\n }\n return { action: CreationDriveAction.RUN_LOOP };\n}\n\n// semantic-literal-boundary: `PlaybookLoopStopReason` values as the companion's loop document carries them; the CLI reads them as wire values.\nconst LOOP_CHOSE_TO_STOP = 'CHOSE_TO_STOP';\nconst LOOP_NOTHING_ELIGIBLE = 'NOTHING_ELIGIBLE';\nconst LOOP_ALL_LANES_FAILED = 'ALL_LANES_FAILED';\nconst LOOP_INTERRUPTED_BY_ENVIRONMENT = 'INTERRUPTED_BY_ENVIRONMENT';\n\nfunction stop(rule: CreationDriveStopRule, waitingFor: string): CreationDriveDecision {\n return { action: CreationDriveAction.STOP, rule, waitingFor };\n}\n\nfunction wait(reason: CreationDriveWaitReason, detail: string): CreationDriveDecision {\n return { action: CreationDriveAction.WAIT, reason, detail };\n}\n\nfunction formatHours(ms: number): string {\n return `${Math.round((ms / 3_600_000) * 10) / 10} h`;\n}\n\nfunction describeAskedLine(kind: WorkbenchCreationHomeLineKind, subject: string, lineSubject?: string | null): string {\n switch (kind) {\n case WorkbenchCreationHomeLineKind.CLARIFICATION: return `playbook ${subject} asks a question only you can answer: wildo creation questions`;\n case WorkbenchCreationHomeLineKind.PARKED_QUESTION: return `the coding run for ${subject} is parked on a question: wildo creation questions`;\n // #3361: the line's own subject names the steps held until the interview is answered.\n case WorkbenchCreationHomeLineKind.INTERVIEW_DATES_NEXT_WORK:\n return `playbook ${subject}'s interview: ${lineSubject ?? 'the next steps'} read its answer, so they wait for it rather than be derived twice: wildo creation questions`;\n case WorkbenchCreationHomeLineKind.SPECIFICATION_FAULT_HOLDS_THE_PLAN: return `specifications module ${subject} does not evaluate, so the plan has nothing to run and is not finished: wildo creation feed`;\n default: return `the build plan cannot run ${subject} until you act: wildo build dispatches`;\n }\n}\n\n/** What the drive talks to: the companion's routes, the clock, and where its progress goes. A port, so it is testable. */\nexport interface CreationDrivePort {\n readonly readFeed: () => Promise<CreationConsole_Feed>;\n readonly readStatus: () => Promise<CreationDrive_Status>;\n /** The run report's measured total, USD; undefined when it reports none or cannot be read. */\n readonly readSpentUsd: () => Promise<number | undefined>;\n readonly runLoop: (request: { readonly goal: string; readonly maximumIterations: number; readonly fanOut?: number; readonly skipPreflight?: boolean }) => Promise<ConsoleLoopResult & {\n readonly interruption?: { readonly failure: string; readonly providerAccountRefusal?: ModelProviderAccountRefusal };\n }>;\n readonly accept: () => Promise<CreationDrive_AcceptOutcome>;\n /** Did this error mean the companion is not answering (as opposed to answering no)? */\n readonly isCompanionUnreachable: (error: unknown) => boolean;\n /** Did the CLIENT stop waiting while the companion goes on (the loop continues there), or a read is not ready yet? */\n readonly isClientTimeout: (error: unknown) => boolean;\n /** The companion answered \"not now\" (503: a derivation still in progress, as after a restart). A wait, never an error. */\n readonly isNotReadyYet: (error: unknown) => boolean;\n /** The companion refused because a loop or composite already runs (409). */\n readonly isAlreadyRunning: (error: unknown) => boolean;\n /** The provider account's refusal (#3204) the companion ANSWERED with (a model call outside the loop's own steps), or `undefined`. */\n readonly readProviderAccountRefusal: (error: unknown) => ModelProviderAccountRefusal | undefined;\n readonly now: () => number;\n readonly sleep: (ms: number) => Promise<void>;\n readonly progress: (line: string) => void;\n}\n\nexport interface CreationDriveResult {\n readonly stoppedBy: CreationDriveStopRule;\n readonly waitingFor: string;\n readonly loops: number;\n readonly rounds: number;\n readonly accepted: number;\n /** Companion restarts the drive saw: a changed start time, or an outage it waited through. */\n readonly companionRestarts: number;\n readonly elapsedMs: number;\n readonly spentUsd: number | undefined;\n /**\n * False when the spend ceiling could not be applied: the run report could not be read, or reported no USD figure.\n * The ceiling is then not enforced, and the result says so rather than implying it held.\n */\n readonly spendMeasured: boolean;\n /** Present exactly when the drive stopped {@link CreationDriveStopRule.PROVIDER_ACCOUNT_REFUSED}: which account, why, and its own words. */\n readonly providerAccountRefusal?: ModelProviderAccountRefusal;\n}\n\n/**\n * Drive the creation until a stop rule fires (#2233). The preflight is the command's, run before this; everything here\n * talks to the companion through `port`.\n */\nexport async function runCreationDrive(port: CreationDrivePort, options: {\n readonly goal: string;\n readonly maximumMs: number;\n readonly maximumUsd: number;\n readonly fanOut?: number;\n readonly skipPreflight?: boolean;\n}): Promise<CreationDriveResult> {\n const startedAt = port.now();\n let loops = 0;\n let rounds = 0;\n let accepted = 0;\n let companionRestarts = 0;\n let consecutiveInterruptions = 0;\n let companionStartedAt: string | undefined;\n let unreachableSince: number | undefined;\n let spentAtStart: number | undefined;\n let spentUsd: number | undefined;\n let lastLoop: CreationDriveObservation['lastLoop'];\n let networkWaitSinceMs: number | undefined;\n const finish = (rule: CreationDriveStopRule, waitingFor: string, providerAccountRefusal?: ModelProviderAccountRefusal): CreationDriveResult => {\n port.progress(`Stopped: ${rule} — ${waitingFor}`);\n return {\n stoppedBy: rule, waitingFor, loops, rounds, accepted, companionRestarts, elapsedMs: port.now() - startedAt, spentUsd, spendMeasured: spentUsd !== undefined,\n ...(providerAccountRefusal !== undefined ? { providerAccountRefusal } : {}),\n };\n };\n /** The account refusal's stop (#3204): the provider, what is wrong, where to fix it, in its own words. */\n const refusedByProviderAccount = (refusal: ModelProviderAccountRefusal): CreationDriveResult =>\n finish(CreationDriveStopRule.PROVIDER_ACCOUNT_REFUSED, `${describeModelProviderAccountRefusal(refusal)} Then run the drive again.`, refusal);\n const ACCEPTANCE_IS_YOURS = 'the autonomy posture leaves acceptance to you: wildo creation writes, then wildo creation accept <run>';\n /**\n * The posture's accept. `true` when the posture leaves acceptance to a person (a marked critical gate, armed). A live\n * coding run defers it to the next baseline; a failed or timed-out accept is reported and left to the next loop's, never\n * the drive's end (review of 6fe527ed3): the pending runs stay pending, which is what they were.\n */\n const acceptPending = async (): Promise<boolean> => {\n let outcome: CreationDrive_AcceptOutcome;\n try {\n outcome = await port.accept();\n } catch (error) {\n port.progress(`Could not accept the pending playbook runs now (${describeCaughtError(error)}); the next loop asks again`);\n return false;\n }\n if (outcome.disposition === CreationDriveAcceptDisposition.HELD_FOR_PERSON) return true;\n if (outcome.disposition === CreationDriveAcceptDisposition.ACCEPTED) {\n accepted += outcome.accepted ?? 0;\n if ((outcome.accepted ?? 0) > 0) port.progress(`Accepted ${outcome.accepted} playbook run(s) under the autonomy posture`);\n }\n return false;\n };\n /** Wait one poll interval, marking that the drive waited since its last loop. */\n const pause = async (): Promise<void> => {\n if (lastLoop) lastLoop = { ...lastLoop, waitedSince: true };\n await port.sleep(CREATION_DRIVE_POLL_INTERVAL_MS);\n };\n\n for (;;) {\n let feed: CreationConsole_Feed;\n let status: CreationDrive_Status;\n try {\n [feed, status] = await Promise.all([port.readFeed(), port.readStatus()]);\n } catch (error) {\n /*\n * A companion that does not answer, answers \"not yet\" (503: after a restart its first feed derivation is still\n * running), or answers late is a WAIT, bounded; anything else is a defect worth surfacing (review of 6fe527ed3).\n */\n if (!port.isCompanionUnreachable(error) && !port.isNotReadyYet(error) && !port.isClientTimeout(error)) throw error;\n unreachableSince ??= port.now();\n if (port.now() - unreachableSince >= CREATION_DRIVE_COMPANION_DOWN_LIMIT_MS) {\n return finish(CreationDriveStopRule.COMPANION_UNREACHABLE, `the companion has not answered since ${new Date(unreachableSince).toISOString()}: wildo local dev`);\n }\n port.progress(`Waiting: ${CreationDriveWaitReason.COMPANION_DOWN} — the companion does not answer yet; asking again`);\n await pause();\n continue;\n }\n if (unreachableSince !== undefined) {\n unreachableSince = undefined;\n // A restart only when the companion's start time moved: a slow answer or a cold derivation is no restart.\n if (companionStartedAt !== undefined && status.companionStartedAt !== companionStartedAt) {\n companionRestarts += 1;\n port.progress(`The companion restarted (now since ${status.companionStartedAt}); re-reading its state`);\n }\n } else if (companionStartedAt !== undefined && status.companionStartedAt !== companionStartedAt) {\n companionRestarts += 1;\n port.progress(`The companion restarted (now since ${status.companionStartedAt}); re-reading its state`);\n }\n companionStartedAt = status.companionStartedAt;\n const decide = () => decideCreationDriveStep({\n feed, status, elapsedMs: port.now() - startedAt, maximumMs: options.maximumMs, spentUsd, maximumUsd: options.maximumUsd,\n nowMs: port.now(), ...(networkWaitSinceMs === undefined ? {} : { networkWaitSinceMs }), ...(lastLoop ? { lastLoop } : {}),\n });\n let decision = decide();\n /*\n * The spend is read from the run report, which derives from every row and the git history: read before a loop would\n * start (where the ceiling decides) and at the first step (the baseline), never on every poll of a long wait. The\n * ceilings are checked BETWEEN loops: a loop in flight is not cut, so one loop may overshoot them. A spend the report\n * cannot state (unreadable, or no USD figure) leaves the ceiling unenforced, and the result says so (`spendMeasured`).\n */\n if (spentAtStart === undefined || decision.action === CreationDriveAction.RUN_LOOP) {\n const total = await port.readSpentUsd().catch(() => undefined);\n spentAtStart ??= total;\n spentUsd = total === undefined || spentAtStart === undefined ? spentUsd : total - spentAtStart;\n decision = decide();\n }\n if (decision.action === CreationDriveAction.STOP) {\n /*\n * Whatever the system may accept is accepted before the drive stops, so a stop never leaves its work uncommitted.\n * The rule that fired stays the stop's; a posture that leaves acceptance to the person adds to what it waits for.\n */\n if (status.loopsInFlight === 0 && status.detachedRunsInFlight === 0 && (status.executionsInFlight ?? 0) === 0 && await acceptPending()) {\n return finish(decision.rule, `${decision.waitingFor}; and ${ACCEPTANCE_IS_YOURS}`, decision.providerAccountRefusal);\n }\n return finish(decision.rule, decision.waitingFor, decision.providerAccountRefusal);\n }\n if (decision.action === CreationDriveAction.WAIT) {\n networkWaitSinceMs = decision.reason === CreationDriveWaitReason.CODING_AGENT_CONNECTIVITY ? (networkWaitSinceMs ?? port.now()) : undefined;\n port.progress(`Waiting: ${decision.reason} — ${decision.detail}`);\n await pause();\n continue;\n }\n networkWaitSinceMs = undefined;\n\n loops += 1;\n port.progress(`Loop ${loops}: up to ${CREATION_DRIVE_ROUNDS_PER_LOOP} rounds toward the goal`);\n let result: Awaited<ReturnType<CreationDrivePort['runLoop']>>;\n try {\n result = await port.runLoop({\n goal: options.goal,\n maximumIterations: CREATION_DRIVE_ROUNDS_PER_LOOP,\n ...(options.fanOut !== undefined ? { fanOut: options.fanOut } : {}),\n ...(options.skipPreflight === true ? { skipPreflight: true } : {}),\n });\n } catch (error) {\n // The companion went away under the loop, the client stopped waiting while it goes on, or another loop holds the\n // subject: the next read decides (a restart is a wait, a running loop is a wait). Anything else is its refusal.\n if (port.isCompanionUnreachable(error) || port.isClientTimeout(error) || port.isAlreadyRunning(error) || port.isNotReadyYet(error)) {\n lastLoop = undefined;\n // Never straight back: a loop another process holds answers 409 at once, and asking again at once would spin.\n await port.sleep(CREATION_DRIVE_POLL_INTERVAL_MS);\n continue;\n }\n // A provider account's refusal answered as an error (a model call outside the loop's steps, #3204): the environment's, not a refusal of the loop.\n const accountRefusal = port.readProviderAccountRefusal(error);\n if (accountRefusal !== undefined) return refusedByProviderAccount(accountRefusal);\n return finish(CreationDriveStopRule.LOOP_REFUSED, describeCaughtError(error));\n }\n rounds += result.steps.length;\n lastLoop = { stoppedBecause: result.stoppedBecause, waitedSince: false, ...(result.steps.at(-1)?.stopRationale ? { stopRationale: result.steps.at(-1)!.stopRationale! } : {}) };\n port.progress(`Loop ${loops} ran ${result.steps.length} round(s) and stopped: ${result.stoppedBecause}`);\n // A provider account's refusal (#3204) keeps its own rule even where the posture leaves acceptance to a person: it is stopped on at once, since the next loop is refused identically.\n if (result.stoppedBecause === LOOP_INTERRUPTED_BY_ENVIRONMENT && result.interruption?.providerAccountRefusal !== undefined) {\n if (await acceptPending()) return finish(CreationDriveStopRule.PROVIDER_ACCOUNT_REFUSED, `${describeModelProviderAccountRefusal(result.interruption.providerAccountRefusal)} Then run the drive again; and ${ACCEPTANCE_IS_YOURS}`, result.interruption.providerAccountRefusal);\n return refusedByProviderAccount(result.interruption.providerAccountRefusal);\n }\n if (await acceptPending()) return finish(CreationDriveStopRule.ACCEPTANCE_HELD_FOR_PERSON, ACCEPTANCE_IS_YOURS);\n if (result.stoppedBecause === LOOP_ALL_LANES_FAILED) {\n const failures = result.steps.at(-1)?.lanes.filter((lane) => lane.failure).map((lane) => `${lane.playbookRef}: ${lane.failure}`) ?? [];\n return finish(CreationDriveStopRule.LANES_FAILED, failures.join('; ') || 'every lane of the last round failed');\n }\n if (result.stoppedBecause === LOOP_INTERRUPTED_BY_ENVIRONMENT) {\n consecutiveInterruptions += 1;\n if (consecutiveInterruptions >= CREATION_DRIVE_MAXIMUM_CONSECUTIVE_INTERRUPTIONS) {\n return finish(CreationDriveStopRule.ENVIRONMENT_INTERRUPTED, result.interruption?.failure ?? 'the environment stopped the loop');\n }\n lastLoop = { ...lastLoop, waitedSince: true };\n } else {\n consecutiveInterruptions = 0;\n }\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"creation-drive.service.js","sourceRoot":"","sources":["../../../../src/services/companion/creation-drive.service.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4CG;AACH,OAAO,EACL,8BAA8B,EAC9B,6BAA6B,EAC7B,4BAA4B,GAK7B,MAAM,gCAAgC,CAAC;AACxC,OAAO,EAAE,mCAAmC,EAAoC,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAInI,mGAAmG;AACnG,MAAM,CAAN,IAAY,kBAEX;AAFD,WAAY,kBAAkB;IAC5B,qCAAe,CAAA;AACjB,CAAC,EAFW,kBAAkB,KAAlB,kBAAkB,QAE7B;AAED,0GAA0G;AAC1G,MAAM,CAAN,IAAY,qBAkEX;AAlED,WAAY,qBAAqB;IAC/B;;;OAGG;IACH,sDAA6B,CAAA;IAC7B;;;;;OAKG;IACH,gEAAuC,CAAA;IACvC;;;OAGG;IACH,4DAAmC,CAAA;IACnC,kEAAkE;IAClE,sDAA6B,CAAA;IAC7B;;;OAGG;IACH,kEAAyC,CAAA;IACzC,0HAA0H;IAC1H,sDAA6B,CAAA;IAC7B,oFAAoF;IACpF,4EAAmD,CAAA;IACnD,6FAA6F;IAC7F,kDAAyB,CAAA;IACzB,6GA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AAC,CAAC;YAChR,OAAO,wBAAwB,CAAC,MAAM,CAAC,YAAY,CAAC,sBAAsB,CAAC,CAAC;QAC9E,CAAC;QACD,IAAI,MAAM,aAAa,EAAE;YAAE,OAAO,MAAM,CAAC,qBAAqB,CAAC,0BAA0B,EAAE,mBAAmB,CAAC,CAAC;QAChH,IAAI,MAAM,CAAC,cAAc,KAAK,qBAAqB,EAAE,CAAC;YACpD,MAAM,QAAQ,GAAG,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,GAAG,IAAI,CAAC,WAAW,KAAK,IAAI,CAAC,OAAO,EAAE,CAAC,IAAI,EAAE,CAAC;YACvI,OAAO,MAAM,CAAC,qBAAqB,CAAC,YAAY,EAAE,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,qCAAqC,CAAC,CAAC;QAClH,CAAC;QACD,IAAI,MAAM,CAAC,cAAc,KAAK,+BAA+B,EAAE,CAAC;YAC9D,wBAAwB,IAAI,CAAC,CAAC;YAC9B,IAAI,wBAAwB,IAAI,gDAAgD,EAAE,CAAC;gBACjF,OAAO,MAAM,CAAC,qBAAqB,CAAC,uBAAuB,EAAE,MAAM,CAAC,YAAY,EAAE,OAAO,IAAI,kCAAkC,CAAC,CAAC;YACnI,CAAC;YACD,QAAQ,GAAG,EAAE,GAAG,QAAQ,EAAE,WAAW,EAAE,IAAI,EAAE,CAAC;QAChD,CAAC;aAAM,CAAC;YACN,wBAAwB,GAAG,CAAC,CAAC;QAC/B,CAAC;IACH,CAAC;AACH,CAAC","sourcesContent":["/**\n * # `wildo creation drive --until stuck` — the unattended creation driver (#2233)\n *\n * A full creation still needed a person, or a hand-written script, to move it from one round to the next: in run 004\n * (`app-creation-test-004`) the driving session ran the umbrella or a build wave, accepted what landed, restarted the\n * companion when it fell over, and stopped on the first real blocker. That loop is the shape of \"run a creation\", and\n * it lived outside the framework. `wildo creation loop` covered one piece of it (a model chooses each round) and none of\n * the rest: it stopped at 20 rounds, never accepted, died with the companion and stopped only when the model did.\n *\n * ## The shape\n *\n * Each step reads the companion's durable state (the creation FEED: what Home shows, holds included; and the drive\n * STATUS: what still runs), decides ONE of three things with {@link decideCreationDriveStep}, and does it:\n *\n * - **run** a bounded `wildo creation loop` (up to its 20-round ceiling): the companion gates, a model chooses, the\n * chosen lanes run, the build lane among them;\n * - **wait**: something still runs (a loop, a wave, a lane the usage-limit resume relaunched), the coding agent's usage\n * limit holds until its stated reset, the connectivity hold waits on the network, or the companion is down;\n * - **stop**, naming the rule that fired and what it waits for.\n *\n * The loop's model choosing to stop is not the goal reached: the drive then asks where the application stands against its\n * own requirements (`GET /creation/requirements/standing`, #3701), and calls the goal reached only when no requirement\n * carries an open item.\n *\n * After every loop, it accepts what the autonomy posture says the SYSTEM accepts (`POST /creation/drive/accept`, never\n * inside a live coding run), and stops when the posture leaves acceptance to a person: a marked critical gate, armed.\n *\n * ## Why in the CLI and not in the companion\n *\n * A companion restart ends every request it holds and every in-process timer. The driver lives in another process, so a\n * restart is a WAIT: it polls until the companion answers again and reads the same durable rows (the loop's state is\n * the working tree; the run records survive). The restart itself is on the intervention ledger when the companion\n * booted with runs in flight (#2231), and the driver also counts the restarts it saw, from the companion's start time.\n *\n * ## Holds it respects\n *\n * - a person's `wildo build stop` (#3206) is a STOP: a stopped build is never resumed unattended;\n * - the coding agent's usage limit (#2388) is a WAIT until it lifts; the companion's own resume relaunches what it\n * paused (#2463), and the driver waits for that run to drain before choosing again;\n * - the connectivity hold (#3236, #3262) is a WAIT until the agent's API answers.\n *\n * Ceilings are the person's, like `loop`'s iteration ceiling: a wall clock and a spend in US dollars, both required.\n * The spend is the run report's measured total since the drive began (#2231, #2232), a floor wherever a run reported no\n * cost.\n */\nimport {\n CreationDriveAcceptDisposition,\n WorkbenchCreationHomeLineKind,\n WorkbenchCreationHomeSection,\n type CreationConsole_Feed,\n type CreationDrive_AcceptOutcome,\n type CreationDrive_RequirementsStanding,\n type CreationDrive_Status,\n} from '@wildo-ai/platform-core-shared';\nimport { describeModelProviderAccountRefusal, type ModelProviderAccountRefusal, describeCaughtError } from '@wildo-ai/saas-models';\n\nimport type { ConsoleLoopResult } from './creation-console.service';\n\n/** The only drive mode: run until a stop rule fires. Named so `--until` is a closed vocabulary. */\nexport enum CreationDriveUntil {\n STUCK = 'stuck',\n}\n\n/** Why the driver stopped. Every exit is one of these, and the report names it with what it waits for. */\nexport enum CreationDriveStopRule {\n /**\n * The loop's selector chose to stop with nothing running and nothing asked, AND the application's requirements carry no\n * open item (#3701): the goal is reached by measurement, never by the model's judgement alone.\n */\n GOAL_REACHED = 'goal-reached',\n /**\n * The loop's selector chose to stop, and the application's own requirements still carry open items (#3701): a reported\n * gap, a configuration that does not meet one, one nothing addresses or with no build work landed. The model judged the\n * creation done and the measurement says it is not, so the drive stops and names them: each is closed by the task named\n * beside it, or by a person who starts refinement or decides the requirement is out of scope.\n */\n REQUIREMENTS_OPEN = 'requirements-open',\n /**\n * The loop's selector chose to stop, and where the application stands against its requirements could not be read\n * (#3701): whether the goal is reached is unknown, so the drive says that rather than claim it.\n */\n GOAL_UNMEASURED = 'goal-unmeasured',\n /** Nothing is eligible to run, nothing runs, nothing is asked. */\n NOTHING_LEFT = 'nothing-left',\n /**\n * A question only the creator can answer: a playbook's clarification, a coding run parked on a question, or an interview\n * whose answer would date work the next round could run (#3361).\n */\n WAITING_ON_CREATOR = 'waiting-on-creator',\n /** The build plan can run nothing until the creator unblocks it (a task that cannot land, retired after its attempts). */\n PLAN_BLOCKED = 'plan-blocked',\n /** A person's `wildo build stop` holds the build; only a person starts it again. */\n BUILD_STOPPED_BY_PERSON = 'build-stopped-by-person',\n /** The build lane holds dispatch because a backend does not run the current tree (#3215). */\n BUILD_HELD = 'build-held',\n /** Every lane of a loop round failed: choosing again over the same state would spend without progressing. */\n LANES_FAILED = 'lanes-failed',\n /** The companion refused to run the loop (a preflight failure, a refusal whose remedy is a decision). */\n LOOP_REFUSED = 'loop-refused',\n /** The autonomy posture leaves acceptance to a person: a marked critical gate is armed. */\n ACCEPTANCE_HELD_FOR_PERSON = 'acceptance-held-for-person',\n /** The creation preflight found what would stop the run, before the first round. */\n PREFLIGHT_FAILED = 'preflight-failed',\n /** The person's wall-clock ceiling. */\n WALL_CLOCK_CEILING = 'wall-clock-ceiling',\n /** The person's spend ceiling. */\n SPEND_CEILING = 'spend-ceiling',\n /** The environment stopped the loop on consecutive rounds, past the loop's own recovery wait (#3235). */\n ENVIRONMENT_INTERRUPTED = 'environment-interrupted',\n /** The companion did not answer for {@link CREATION_DRIVE_COMPANION_DOWN_LIMIT_MS}. */\n COMPANION_UNREACHABLE = 'companion-unreachable',\n /**\n * The coding agent's API has not answered along its route for {@link CREATION_DRIVE_NETWORK_WAIT_LIMIT_MS}: nothing\n * can be built, and the wait has outlived what a network blip is. The person checks the network, or ends the hold.\n */\n NETWORK_LOST = 'network-lost',\n /**\n * A model provider's ACCOUNT refused the companion's or the coding agent's call (#3204): no credits left, a spend or\n * usage limit, billing. The ENVIRONMENT's condition, never the application's: nothing the creation did caused it, and\n * nothing it can do lifts it. A person adds credits or raises the limit in that provider's console, then runs the drive\n * again. Stopped on at once, never after consecutive loops: a loop run again is refused identically.\n */\n PROVIDER_ACCOUNT_REFUSED = 'provider-account-refused',\n /**\n * A verification check cannot be asked for a host cause (#3423, #3432): `wildo` is not on the companion's PATH, or the\n * installed one lacks the verb a check asks, or one check failed the same way on two tasks. Every build task's check\n * would fail the same way, so the companion admits no coding turn. The host's condition: a person repairs it (the next\n * admission asks first), then runs the drive again.\n */\n VERIFICATION_TOOL_UNAVAILABLE = 'verification-tool-unavailable',\n}\n\n/** What the driver waits for when it waits. */\nexport enum CreationDriveWaitReason {\n /** A loop or a detached run (a wave, a lane, a usage-limit resume) still runs in the companion. */\n RUNS_IN_FLIGHT = 'runs-in-flight',\n /** The coding agent's account usage limit holds the build until its stated reset (#2388). */\n CODING_AGENT_USAGE_LIMIT = 'coding-agent-usage-limit',\n /** A coding run lost the network; no coding turn starts until the agent's API answers (#3236, #3262). */\n CODING_AGENT_CONNECTIVITY = 'coding-agent-connectivity',\n /** The companion does not answer (a restart, a crash). */\n COMPANION_DOWN = 'companion-down',\n}\n\n/** How long one wait lasts before the driver reads the state again. */\nexport const CREATION_DRIVE_POLL_INTERVAL_MS = 30_000;\n/** How long the companion may stay unreachable before the drive stops. A restart takes seconds to a few minutes. */\nexport const CREATION_DRIVE_COMPANION_DOWN_LIMIT_MS = 15 * 60 * 1000;\n/**\n * How long the drive waits on the coding agent's network before it stops {@link CreationDriveStopRule.NETWORK_LOST}: three\n * times the coding admission's own twenty-minute bound, so an outage of an hour (app-creation-test-007 measured 35 min)\n * is waited through, and a five-hour one is the person's to see.\n */\nexport const CREATION_DRIVE_NETWORK_WAIT_LIMIT_MS = 60 * 60 * 1000;\n/** The loop's own ceiling per request (`POST /playbooks/loop` caps it at 20). */\nexport const CREATION_DRIVE_ROUNDS_PER_LOOP = 20;\n/** Consecutive loops the environment interrupted before the drive stops (each already waited up to 10 minutes, #3235). */\nexport const CREATION_DRIVE_MAXIMUM_CONSECUTIVE_INTERRUPTIONS = 3;\n/** The ASKED kinds that stop a run until the creator acts. A governance document's fact does not: it blocks no run. */\nconst ASKED_KINDS_THAT_STOP: ReadonlyMap<WorkbenchCreationHomeLineKind, CreationDriveStopRule> = new Map([\n [WorkbenchCreationHomeLineKind.CLARIFICATION, CreationDriveStopRule.WAITING_ON_CREATOR],\n [WorkbenchCreationHomeLineKind.PARKED_QUESTION, CreationDriveStopRule.WAITING_ON_CREATOR],\n /*\n * An interview whose answer would date work the next round could run (#3361). The round withholds that work, so the\n * drive stops and names the interview, as for a clarification, rather than run on without it.\n */\n [WorkbenchCreationHomeLineKind.INTERVIEW_DATES_NEXT_WORK, CreationDriveStopRule.WAITING_ON_CREATOR],\n [WorkbenchCreationHomeLineKind.SPECIFICATION_FAULT_HOLDS_THE_PLAN, CreationDriveStopRule.PLAN_BLOCKED],\n [WorkbenchCreationHomeLineKind.UNBLOCK_THE_PLAN, CreationDriveStopRule.PLAN_BLOCKED],\n]);\n\n/** What the driver knows when it decides its next step. */\nexport interface CreationDriveObservation {\n readonly feed: CreationConsole_Feed;\n readonly status: CreationDrive_Status;\n readonly elapsedMs: number;\n readonly maximumMs: number;\n /** Measured spend since the drive began, USD; undefined when the report could not be read. */\n readonly spentUsd: number | undefined;\n readonly maximumUsd: number;\n /** How the last loop ended, and whether the driver waited on anything since (which makes running again worth it). */\n readonly lastLoop?: { readonly stoppedBecause: string; readonly stopRationale?: string; readonly waitedSince: boolean };\n /**\n * Where the application stands against its own requirements (#3701), read once the last loop chose to stop: the\n * `standing`, or why it could not be read. Absent when it was not asked.\n */\n readonly requirements?: { readonly standing: CreationDrive_RequirementsStanding } | { readonly unreadBecause: string };\n /** Since when the drive has waited on the coding agent's network without a break (ms on the drive's clock). */\n readonly networkWaitSinceMs?: number;\n readonly nowMs?: number;\n}\n\nexport type CreationDriveDecision =\n | { readonly action: CreationDriveAction.RUN_LOOP }\n | { readonly action: CreationDriveAction.WAIT; readonly reason: CreationDriveWaitReason; readonly detail: string }\n | { readonly action: CreationDriveAction.STOP; readonly rule: CreationDriveStopRule; readonly waitingFor: string; readonly providerAccountRefusal?: ModelProviderAccountRefusal };\n\nexport enum CreationDriveAction {\n RUN_LOOP = 'run-loop',\n WAIT = 'wait',\n STOP = 'stop',\n}\n\n/**\n * The next step, from what the companion's durable rows say now. Order is the rule:\n * a person's stop first (it is theirs); the person's ceilings; anything still running (never start a loop over a\n * running one); what waits on the creator; a backend that does not boot; the holds only a person lifts (a refused\n * provider account, a build check's command missing from PATH); the holds that lift on their own; then the last loop's\n * own verdict when nothing happened since; else run.\n */\nexport function decideCreationDriveStep(observation: CreationDriveObservation): CreationDriveDecision {\n const { feed, status } = observation;\n // Read live from the status first: the feed may be an earlier snapshot, and a stop asked a moment ago holds now.\n const stoppedSince = status.buildStoppedSince ?? feed.buildPreparation?.heldByStopSince ?? null;\n if (stoppedSince !== null) {\n return stop(CreationDriveStopRule.BUILD_STOPPED_BY_PERSON, `a person stopped the build at ${stoppedSince}; start it again with: wildo build run`);\n }\n if (observation.elapsedMs >= observation.maximumMs) {\n return stop(CreationDriveStopRule.WALL_CLOCK_CEILING, `the drive's wall-clock ceiling (${formatHours(observation.maximumMs)}); run it again to continue`);\n }\n if (observation.spentUsd !== undefined && observation.spentUsd >= observation.maximumUsd) {\n return stop(CreationDriveStopRule.SPEND_CEILING, `the drive's spend ceiling (USD ${observation.maximumUsd}; measured USD ${observation.spentUsd.toFixed(2)})`);\n }\n if (status.loopsInFlight > 0 || status.detachedRunsInFlight > 0 || (status.executionsInFlight ?? 0) > 0) {\n return wait(CreationDriveWaitReason.RUNS_IN_FLIGHT, `${status.loopsInFlight} loop(s), ${status.detachedRunsInFlight} detached run(s) and ${status.executionsInFlight ?? 0} playbook execution(s) still running`);\n }\n for (const line of feed.lines) {\n if (line.section !== WorkbenchCreationHomeSection.ASKED) continue;\n const rule = ASKED_KINDS_THAT_STOP.get(line.kind);\n if (rule !== undefined) return stop(rule, describeAskedLine(line.kind, line.taskRef ?? line.playbookRef ?? line.subject ?? line.targetResourceId, line.subject));\n }\n const bootFailures = feed.buildHold?.bootFailures ?? [];\n /*\n * Not while the build lane still owes the repair of a start the application's own code refused (#3204): the lane runs\n * it, bounded per round, and only once it is spent does the hold need a person. Reference run 42696531261 stopped here\n * on two refusals a build task's code caused, with nothing having tried to repair them.\n */\n if (bootFailures.length > 0 && feed.buildHold?.startupRepairOwed !== true) {\n return stop(CreationDriveStopRule.BUILD_HELD, bootFailures.map((failure) => `${failure.serviceIdentifier} does not start: ${failure.remedy}`).join('; '));\n }\n /*\n * The coding agent's provider ACCOUNT refused its turn (#3204). The companion holds the build and re-asks the account\n * every thirty minutes, so a person who adds credits loses nothing; but nothing ever lifts it on its own, so an\n * unattended drive stops here rather than wait for a \"resume\" that only re-asks. Read from the live status first (a\n * pending resume beside it is that re-ask, never a reset), else from the feed's own line.\n */\n const accountRefusal = status.codingAgentAccountRefusal;\n const refusedLine = feed.lines.find((line) => line.kind === WorkbenchCreationHomeLineKind.CODING_AGENT_ACCOUNT_REFUSED);\n if (accountRefusal !== undefined || refusedLine !== undefined) {\n const sentence = accountRefusal !== undefined ? describeModelProviderAccountRefusal(accountRefusal) : refusedLine?.subject ?? 'the coding agent\\'s provider account refused to work';\n return {\n action: CreationDriveAction.STOP,\n rule: CreationDriveStopRule.PROVIDER_ACCOUNT_REFUSED,\n waitingFor: `the coding agent's provider account: ${sentence} The build re-asks it every 30 minutes; run the drive again once it is fixed.`,\n ...(accountRefusal !== undefined ? { providerAccountRefusal: accountRefusal } : {}),\n };\n }\n /*\n * A build check cannot be asked for a host cause (#3423, #3432): a command not on PATH, one lacking the verb, the same\n * failure on two tasks. Nothing the drive does lifts it, so it stops; the line's subject is the cause and its remedy.\n */\n const toolUnavailable = feed.lines.find((line) => line.kind === WorkbenchCreationHomeLineKind.VERIFICATION_TOOL_UNAVAILABLE);\n if (toolUnavailable !== undefined) {\n return stop(CreationDriveStopRule.VERIFICATION_TOOL_UNAVAILABLE,\n `the build's checks, which cannot run (met by build task ${toolUnavailable.taskRef ?? toolUnavailable.targetResourceId}), so no coding turn starts: `\n + `${toolUnavailable.subject ?? 'a command the checks run is unavailable.'} Then run the drive again.`);\n }\n const usageLimit = feed.lines.find((line) => line.kind === WorkbenchCreationHomeLineKind.CODING_AGENT_USAGE_LIMITED);\n if (usageLimit !== undefined || status.pendingBuildResume !== undefined) {\n const resumesAt = status.pendingBuildResume?.resumesAt ?? usageLimit?.subject ?? 'its reset';\n return wait(CreationDriveWaitReason.CODING_AGENT_USAGE_LIMIT, `the coding agent's usage limit; the build resumes on its own at ${resumesAt}`);\n }\n /*\n * Waited on only when the hold has a ROUTE: its background probe ends it when the network returns. A hold with no route\n * (an agent with no known API host, a proxy it cannot use) is ended only by the next coding admission, so waiting on it\n * would wait forever; the loop runs, and its build's next turn is the check (review of 6fe527ed3).\n */\n const connectivity = feed.lines.find((line) => line.kind === WorkbenchCreationHomeLineKind.CODING_AGENT_CONNECTIVITY_LOST && line.subject !== null);\n if (connectivity !== undefined) {\n if (observation.networkWaitSinceMs !== undefined && observation.nowMs !== undefined && observation.nowMs - observation.networkWaitSinceMs >= CREATION_DRIVE_NETWORK_WAIT_LIMIT_MS) {\n return stop(CreationDriveStopRule.NETWORK_LOST, `the coding agent's API (${connectivity.subject}) has not answered for ${formatHours(CREATION_DRIVE_NETWORK_WAIT_LIMIT_MS)}; once the network is back: wildo build rearm ${connectivity.taskRef ?? '<task>'} --reason environment`);\n }\n return wait(CreationDriveWaitReason.CODING_AGENT_CONNECTIVITY, `the coding agent's network; waiting for ${connectivity.subject} to answer`);\n }\n const last = observation.lastLoop;\n if (last !== undefined && !last.waitedSince) {\n // The loop chose to stop, or found nothing eligible, and nothing ran or lifted since: asking again is the same answer.\n if (last.stoppedBecause === LOOP_CHOSE_TO_STOP) return judgeChosenStop(last.stopRationale ?? 'the loop chose to stop', observation.requirements);\n if (last.stoppedBecause === LOOP_NOTHING_ELIGIBLE) return stop(CreationDriveStopRule.NOTHING_LEFT, 'nothing is eligible to run');\n }\n return { action: CreationDriveAction.RUN_LOOP };\n}\n\n// semantic-literal-boundary: `PlaybookLoopStopReason` values as the companion's loop document carries them; the CLI reads them as wire values.\nconst LOOP_CHOSE_TO_STOP = 'CHOSE_TO_STOP';\nconst LOOP_NOTHING_ELIGIBLE = 'NOTHING_ELIGIBLE';\nconst LOOP_ALL_LANES_FAILED = 'ALL_LANES_FAILED';\nconst LOOP_INTERRUPTED_BY_ENVIRONMENT = 'INTERRUPTED_BY_ENVIRONMENT';\n\n/** How many open items a stop names in words; the rest are counted. */\nconst OPEN_ITEMS_NAMED = 5;\n\n/**\n * The loop chose to stop: whether the goal is reached is the REQUIREMENTS' answer, not the model's (#3701). Goal reached\n * only when the standing was read and carries no open item; open items stop the drive on a rule that names them;\n * an unread standing is said to be unread. Run 42886943490 stopped \"goal-reached\" with 16 of 24 requirements partly met.\n */\nfunction judgeChosenStop(rationale: string, requirements: CreationDriveObservation['requirements']): CreationDriveDecision {\n const standing = requirements !== undefined && 'standing' in requirements ? requirements.standing : undefined;\n if (standing === undefined) {\n const why = requirements !== undefined && 'unreadBecause' in requirements ? requirements.unreadBecause : 'it was not read';\n return stop(CreationDriveStopRule.GOAL_UNMEASURED, `${rationale} — but where the application stands against its requirements could not be read (${why}): wildo creation drive again, or wildo context journey`);\n }\n if (standing.openItems.length === 0) {\n return stop(CreationDriveStopRule.GOAL_REACHED, `${rationale} Every one of the ${standing.requirementCount} requirement(s) is met by what the reading measures (stage ${standing.stage}).`);\n }\n const requirementsWithItems = new Set(standing.openItems.map((item) => item.requirementRef)).size;\n const named = standing.openItems.slice(0, OPEN_ITEMS_NAMED)\n .map((item) => `${item.requirementRef}: ${item.detail}${item.closedByTaskRef === null ? '' : ` (closed by ${item.closedByTaskRef})`}`);\n const rest = standing.openItems.length - named.length;\n return stop(CreationDriveStopRule.REQUIREMENTS_OPEN,\n `the loop chose to stop (${rationale}) while ${requirementsWithItems} of ${standing.requirementCount} requirement(s) carry ${standing.openItems.length} open item(s): `\n + `${named.join('; ')}${rest > 0 ? `; and ${rest} more` : ''}. Start refinement on them, or decide they are out of scope: wildo creation feed`);\n}\n\nfunction stop(rule: CreationDriveStopRule, waitingFor: string): CreationDriveDecision {\n return { action: CreationDriveAction.STOP, rule, waitingFor };\n}\n\nfunction wait(reason: CreationDriveWaitReason, detail: string): CreationDriveDecision {\n return { action: CreationDriveAction.WAIT, reason, detail };\n}\n\nfunction formatHours(ms: number): string {\n return `${Math.round((ms / 3_600_000) * 10) / 10} h`;\n}\n\nfunction describeAskedLine(kind: WorkbenchCreationHomeLineKind, subject: string, lineSubject?: string | null): string {\n switch (kind) {\n case WorkbenchCreationHomeLineKind.CLARIFICATION: return `playbook ${subject} asks a question only you can answer: wildo creation questions`;\n case WorkbenchCreationHomeLineKind.PARKED_QUESTION: return `the coding run for ${subject} is parked on a question: wildo creation questions`;\n // #3361: the line's own subject names the steps held until the interview is answered.\n case WorkbenchCreationHomeLineKind.INTERVIEW_DATES_NEXT_WORK:\n return `playbook ${subject}'s interview: ${lineSubject ?? 'the next steps'} read its answer, so they wait for it rather than be derived twice: wildo creation questions`;\n case WorkbenchCreationHomeLineKind.SPECIFICATION_FAULT_HOLDS_THE_PLAN: return `specifications module ${subject} does not evaluate, so the plan has nothing to run and is not finished: wildo creation feed`;\n default: return `the build plan cannot run ${subject} until you act: wildo build dispatches`;\n }\n}\n\n/** What the drive talks to: the companion's routes, the clock, and where its progress goes. A port, so it is testable. */\nexport interface CreationDrivePort {\n readonly readFeed: () => Promise<CreationConsole_Feed>;\n readonly readStatus: () => Promise<CreationDrive_Status>;\n /** Where the application stands against its requirements, derived live (#3701). Asked only once a loop chose to stop. */\n readonly readRequirementsStanding: () => Promise<CreationDrive_RequirementsStanding>;\n /** The run report's measured total, USD; undefined when it reports none or cannot be read. */\n readonly readSpentUsd: () => Promise<number | undefined>;\n readonly runLoop: (request: { readonly goal: string; readonly maximumIterations: number; readonly fanOut?: number; readonly skipPreflight?: boolean }) => Promise<ConsoleLoopResult & {\n readonly interruption?: { readonly failure: string; readonly providerAccountRefusal?: ModelProviderAccountRefusal };\n }>;\n readonly accept: () => Promise<CreationDrive_AcceptOutcome>;\n /** Did this error mean the companion is not answering (as opposed to answering no)? */\n readonly isCompanionUnreachable: (error: unknown) => boolean;\n /** Did the CLIENT stop waiting while the companion goes on (the loop continues there), or a read is not ready yet? */\n readonly isClientTimeout: (error: unknown) => boolean;\n /** The companion answered \"not now\" (503: a derivation still in progress, as after a restart). A wait, never an error. */\n readonly isNotReadyYet: (error: unknown) => boolean;\n /** The companion refused because a loop or composite already runs (409). */\n readonly isAlreadyRunning: (error: unknown) => boolean;\n /** The provider account's refusal (#3204) the companion ANSWERED with (a model call outside the loop's own steps), or `undefined`. */\n readonly readProviderAccountRefusal: (error: unknown) => ModelProviderAccountRefusal | undefined;\n readonly now: () => number;\n readonly sleep: (ms: number) => Promise<void>;\n readonly progress: (line: string) => void;\n}\n\nexport interface CreationDriveResult {\n readonly stoppedBy: CreationDriveStopRule;\n readonly waitingFor: string;\n readonly loops: number;\n readonly rounds: number;\n readonly accepted: number;\n /** Companion restarts the drive saw: a changed start time, or an outage it waited through. */\n readonly companionRestarts: number;\n readonly elapsedMs: number;\n readonly spentUsd: number | undefined;\n /**\n * False when the spend ceiling could not be applied: the run report could not be read, or reported no USD figure.\n * The ceiling is then not enforced, and the result says so rather than implying it held.\n */\n readonly spendMeasured: boolean;\n /** Present exactly when the drive stopped {@link CreationDriveStopRule.PROVIDER_ACCOUNT_REFUSED}: which account, why, and its own words. */\n readonly providerAccountRefusal?: ModelProviderAccountRefusal;\n}\n\n/**\n * Drive the creation until a stop rule fires (#2233). The preflight is the command's, run before this; everything here\n * talks to the companion through `port`.\n */\nexport async function runCreationDrive(port: CreationDrivePort, options: {\n readonly goal: string;\n readonly maximumMs: number;\n readonly maximumUsd: number;\n readonly fanOut?: number;\n readonly skipPreflight?: boolean;\n}): Promise<CreationDriveResult> {\n const startedAt = port.now();\n let loops = 0;\n let rounds = 0;\n let accepted = 0;\n let companionRestarts = 0;\n let consecutiveInterruptions = 0;\n let companionStartedAt: string | undefined;\n let unreachableSince: number | undefined;\n let spentAtStart: number | undefined;\n let spentUsd: number | undefined;\n let lastLoop: CreationDriveObservation['lastLoop'];\n let networkWaitSinceMs: number | undefined;\n /** The standing read for the last loop's chosen stop (#3701); cleared when a loop runs, so a stale one never judges. */\n let requirements: CreationDriveObservation['requirements'];\n const finish = (rule: CreationDriveStopRule, waitingFor: string, providerAccountRefusal?: ModelProviderAccountRefusal): CreationDriveResult => {\n port.progress(`Stopped: ${rule} — ${waitingFor}`);\n return {\n stoppedBy: rule, waitingFor, loops, rounds, accepted, companionRestarts, elapsedMs: port.now() - startedAt, spentUsd, spendMeasured: spentUsd !== undefined,\n ...(providerAccountRefusal !== undefined ? { providerAccountRefusal } : {}),\n };\n };\n /** The account refusal's stop (#3204): the provider, what is wrong, where to fix it, in its own words. */\n const refusedByProviderAccount = (refusal: ModelProviderAccountRefusal): CreationDriveResult =>\n finish(CreationDriveStopRule.PROVIDER_ACCOUNT_REFUSED, `${describeModelProviderAccountRefusal(refusal)} Then run the drive again.`, refusal);\n const ACCEPTANCE_IS_YOURS = 'the autonomy posture leaves acceptance to you: wildo creation writes, then wildo creation accept <run>';\n /**\n * The posture's accept. `true` when the posture leaves acceptance to a person (a marked critical gate, armed). A live\n * coding run defers it to the next baseline; a failed or timed-out accept is reported and left to the next loop's, never\n * the drive's end (review of 6fe527ed3): the pending runs stay pending, which is what they were.\n */\n const acceptPending = async (): Promise<boolean> => {\n let outcome: CreationDrive_AcceptOutcome;\n try {\n outcome = await port.accept();\n } catch (error) {\n port.progress(`Could not accept the pending playbook runs now (${describeCaughtError(error)}); the next loop asks again`);\n return false;\n }\n if (outcome.disposition === CreationDriveAcceptDisposition.HELD_FOR_PERSON) return true;\n if (outcome.disposition === CreationDriveAcceptDisposition.ACCEPTED) {\n accepted += outcome.accepted ?? 0;\n if ((outcome.accepted ?? 0) > 0) port.progress(`Accepted ${outcome.accepted} playbook run(s) under the autonomy posture`);\n }\n return false;\n };\n /** Wait one poll interval, marking that the drive waited since its last loop. */\n const pause = async (): Promise<void> => {\n if (lastLoop) lastLoop = { ...lastLoop, waitedSince: true };\n await port.sleep(CREATION_DRIVE_POLL_INTERVAL_MS);\n };\n\n for (;;) {\n let feed: CreationConsole_Feed;\n let status: CreationDrive_Status;\n try {\n [feed, status] = await Promise.all([port.readFeed(), port.readStatus()]);\n } catch (error) {\n /*\n * A companion that does not answer, answers \"not yet\" (503: after a restart its first feed derivation is still\n * running), or answers late is a WAIT, bounded; anything else is a defect worth surfacing (review of 6fe527ed3).\n */\n if (!port.isCompanionUnreachable(error) && !port.isNotReadyYet(error) && !port.isClientTimeout(error)) throw error;\n unreachableSince ??= port.now();\n if (port.now() - unreachableSince >= CREATION_DRIVE_COMPANION_DOWN_LIMIT_MS) {\n return finish(CreationDriveStopRule.COMPANION_UNREACHABLE, `the companion has not answered since ${new Date(unreachableSince).toISOString()}: wildo local dev`);\n }\n port.progress(`Waiting: ${CreationDriveWaitReason.COMPANION_DOWN} — the companion does not answer yet; asking again`);\n await pause();\n continue;\n }\n if (unreachableSince !== undefined) {\n unreachableSince = undefined;\n // A restart only when the companion's start time moved: a slow answer or a cold derivation is no restart.\n if (companionStartedAt !== undefined && status.companionStartedAt !== companionStartedAt) {\n companionRestarts += 1;\n port.progress(`The companion restarted (now since ${status.companionStartedAt}); re-reading its state`);\n }\n } else if (companionStartedAt !== undefined && status.companionStartedAt !== companionStartedAt) {\n companionRestarts += 1;\n port.progress(`The companion restarted (now since ${status.companionStartedAt}); re-reading its state`);\n }\n companionStartedAt = status.companionStartedAt;\n /*\n * The goal is the requirements' to call (#3701): once the last loop chose to stop with nothing since, read where the\n * application stands, once for that loop. It derives the reading, so it is never read on a poll.\n */\n if (requirements === undefined && lastLoop?.stoppedBecause === LOOP_CHOSE_TO_STOP && !lastLoop.waitedSince) {\n try {\n requirements = { standing: await port.readRequirementsStanding() };\n } catch (error) {\n requirements = { unreadBecause: describeCaughtError(error) };\n }\n }\n const decide = () => decideCreationDriveStep({\n feed, status, elapsedMs: port.now() - startedAt, maximumMs: options.maximumMs, spentUsd, maximumUsd: options.maximumUsd,\n nowMs: port.now(), ...(networkWaitSinceMs === undefined ? {} : { networkWaitSinceMs }), ...(lastLoop ? { lastLoop } : {}),\n ...(requirements === undefined ? {} : { requirements }),\n });\n let decision = decide();\n /*\n * The spend is read from the run report, which derives from every row and the git history: read before a loop would\n * start (where the ceiling decides) and at the first step (the baseline), never on every poll of a long wait. The\n * ceilings are checked BETWEEN loops: a loop in flight is not cut, so one loop may overshoot them. A spend the report\n * cannot state (unreadable, or no USD figure) leaves the ceiling unenforced, and the result says so (`spendMeasured`).\n */\n if (spentAtStart === undefined || decision.action === CreationDriveAction.RUN_LOOP) {\n const total = await port.readSpentUsd().catch(() => undefined);\n spentAtStart ??= total;\n spentUsd = total === undefined || spentAtStart === undefined ? spentUsd : total - spentAtStart;\n decision = decide();\n }\n if (decision.action === CreationDriveAction.STOP) {\n /*\n * Whatever the system may accept is accepted before the drive stops, so a stop never leaves its work uncommitted.\n * The rule that fired stays the stop's; a posture that leaves acceptance to the person adds to what it waits for.\n */\n if (status.loopsInFlight === 0 && status.detachedRunsInFlight === 0 && (status.executionsInFlight ?? 0) === 0 && await acceptPending()) {\n return finish(decision.rule, `${decision.waitingFor}; and ${ACCEPTANCE_IS_YOURS}`, decision.providerAccountRefusal);\n }\n return finish(decision.rule, decision.waitingFor, decision.providerAccountRefusal);\n }\n if (decision.action === CreationDriveAction.WAIT) {\n networkWaitSinceMs = decision.reason === CreationDriveWaitReason.CODING_AGENT_CONNECTIVITY ? (networkWaitSinceMs ?? port.now()) : undefined;\n port.progress(`Waiting: ${decision.reason} — ${decision.detail}`);\n await pause();\n continue;\n }\n networkWaitSinceMs = undefined;\n\n loops += 1;\n requirements = undefined;\n port.progress(`Loop ${loops}: up to ${CREATION_DRIVE_ROUNDS_PER_LOOP} rounds toward the goal`);\n let result: Awaited<ReturnType<CreationDrivePort['runLoop']>>;\n try {\n result = await port.runLoop({\n goal: options.goal,\n maximumIterations: CREATION_DRIVE_ROUNDS_PER_LOOP,\n ...(options.fanOut !== undefined ? { fanOut: options.fanOut } : {}),\n ...(options.skipPreflight === true ? { skipPreflight: true } : {}),\n });\n } catch (error) {\n // The companion went away under the loop, the client stopped waiting while it goes on, or another loop holds the\n // subject: the next read decides (a restart is a wait, a running loop is a wait). Anything else is its refusal.\n if (port.isCompanionUnreachable(error) || port.isClientTimeout(error) || port.isAlreadyRunning(error) || port.isNotReadyYet(error)) {\n lastLoop = undefined;\n // Never straight back: a loop another process holds answers 409 at once, and asking again at once would spin.\n await port.sleep(CREATION_DRIVE_POLL_INTERVAL_MS);\n continue;\n }\n // A provider account's refusal answered as an error (a model call outside the loop's steps, #3204): the environment's, not a refusal of the loop.\n const accountRefusal = port.readProviderAccountRefusal(error);\n if (accountRefusal !== undefined) return refusedByProviderAccount(accountRefusal);\n return finish(CreationDriveStopRule.LOOP_REFUSED, describeCaughtError(error));\n }\n rounds += result.steps.length;\n lastLoop = { stoppedBecause: result.stoppedBecause, waitedSince: false, ...(result.steps.at(-1)?.stopRationale ? { stopRationale: result.steps.at(-1)!.stopRationale! } : {}) };\n port.progress(`Loop ${loops} ran ${result.steps.length} round(s) and stopped: ${result.stoppedBecause}`);\n // A provider account's refusal (#3204) keeps its own rule even where the posture leaves acceptance to a person: it is stopped on at once, since the next loop is refused identically.\n if (result.stoppedBecause === LOOP_INTERRUPTED_BY_ENVIRONMENT && result.interruption?.providerAccountRefusal !== undefined) {\n if (await acceptPending()) return finish(CreationDriveStopRule.PROVIDER_ACCOUNT_REFUSED, `${describeModelProviderAccountRefusal(result.interruption.providerAccountRefusal)} Then run the drive again; and ${ACCEPTANCE_IS_YOURS}`, result.interruption.providerAccountRefusal);\n return refusedByProviderAccount(result.interruption.providerAccountRefusal);\n }\n if (await acceptPending()) return finish(CreationDriveStopRule.ACCEPTANCE_HELD_FOR_PERSON, ACCEPTANCE_IS_YOURS);\n if (result.stoppedBecause === LOOP_ALL_LANES_FAILED) {\n const failures = result.steps.at(-1)?.lanes.filter((lane) => lane.failure).map((lane) => `${lane.playbookRef}: ${lane.failure}`) ?? [];\n return finish(CreationDriveStopRule.LANES_FAILED, failures.join('; ') || 'every lane of the last round failed');\n }\n if (result.stoppedBecause === LOOP_INTERRUPTED_BY_ENVIRONMENT) {\n consecutiveInterruptions += 1;\n if (consecutiveInterruptions >= CREATION_DRIVE_MAXIMUM_CONSECUTIVE_INTERRUPTIONS) {\n return finish(CreationDriveStopRule.ENVIRONMENT_INTERRUPTED, result.interruption?.failure ?? 'the environment stopped the loop');\n }\n lastLoop = { ...lastLoop, waitedSince: true };\n } else {\n consecutiveInterruptions = 0;\n }\n }\n}\n"]}
|
|
@@ -361,6 +361,12 @@ export declare const PlatformEnvConfigJson_Schema: z.ZodObject<{
|
|
|
361
361
|
sharedDomain: z.ZodOptional<z.ZodString>;
|
|
362
362
|
}, z.core.$strict>>;
|
|
363
363
|
}, z.core.$strict>>;
|
|
364
|
+
agentContentGuardrails: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
365
|
+
withoutClassifier: z.ZodLiteral<import("@wildo-ai/saas-models").AgentContentGuardrailsWithoutClassifier.REFUSE>;
|
|
366
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
367
|
+
withoutClassifier: z.ZodLiteral<import("@wildo-ai/saas-models").AgentContentGuardrailsWithoutClassifier.RUN_UNGUARDED>;
|
|
368
|
+
reason: z.ZodString;
|
|
369
|
+
}, z.core.$strict>], "withoutClassifier">>;
|
|
364
370
|
ownershipDnsStandIn: z.ZodOptional<z.ZodObject<{
|
|
365
371
|
baseUrl: z.ZodURL;
|
|
366
372
|
}, z.core.$strict>>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"credentials.schemas.d.ts","sourceRoot":"","sources":["../../../../src/services/credentials/credentials.schemas.ts"],"names":[],"mappings":"AAEA,OAAO,CAAC,MAAM,KAAK,CAAC;AACpB,OAAO,EAIL,oBAAoB,EAKpB,cAAc,EAGd,sBAAsB,EAEtB,iBAAiB,EACjB,qBAAqB,EACrB,yBAAyB,EAO1B,MAAM,+BAA+B,CAAC;AACvC,OAAO,
|
|
1
|
+
{"version":3,"file":"credentials.schemas.d.ts","sourceRoot":"","sources":["../../../../src/services/credentials/credentials.schemas.ts"],"names":[],"mappings":"AAEA,OAAO,CAAC,MAAM,KAAK,CAAC;AACpB,OAAO,EAIL,oBAAoB,EAKpB,cAAc,EAGd,sBAAsB,EAEtB,iBAAiB,EACjB,qBAAqB,EACrB,yBAAyB,EAO1B,MAAM,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AGG;IACH,WAAW,gBAAgB;CAC5B;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,yBAAyB,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,sBAAsB,EAAE,WAAW,CAAC,CA0BjG,CAAC;AAEF;;;GAGG;AACH,wBAAgB,8BAA8B,CAAC,OAAO,EAAE,OAAO,CAAC,sBAAsB,CAAC,GAAG,OAAO,CAAC,sBAAsB,CAAC,CASxH;AAaD;;;;GAIG;AACH,eAAO,MAAM,2BAA2B;;;;iBAItC,CAAC;AACH,MAAM,MAAM,2BAA2B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,2BAA2B,CAAC,CAAC;AAEtF;;;;;;;;;GASG;AACH,eAAO,MAAM,4BAA4B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kBAkRvC,CAAC;AACH,MAAM,MAAM,qBAAqB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,4BAA4B,CAAC,CAAC;AAEjF;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,qCAAqC;;kBAGjD,CAAC;AACF,MAAM,MAAM,8BAA8B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,qCAAqC,CAAC,CAAC"}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// against domain enums. This import direction (validation → domain types) is intentional.
|
|
3
3
|
import z from "zod";
|
|
4
4
|
import { APPLICATION_BACKEND_SENSITIVE_ENV_KEYS, ApplicationCreationVerificationConfigSchema, BackingServicesEnvConfigSchema, BackingServiceSource, WildoCdnConfigSchema, WildoSystemsOfRecordEnvConfigSchema, WildoPlatformStorageConfigSchema, WildoPlatformKeyManagementConfigSchema, DatabaseEngine, PLATFORM_RUNTIME_SENSITIVE_ENV_KEYS, WildoAuthConfigSchema, WildoDeploymentRuntime, WildoKubernetesConfigSchema, WildoLocationType, WildoLocalDataStorage, EnvironmentServiceProfile, WildoLoggingConfigSchema, WildoObservabilityConfigSchema, WildoProviderSelectionOverridesSchema, WildoInfraEmailConfigSchema, WildoOwnershipDnsStandInConfigSchema, WildoRemoteProviderSchema, } from '@wildo-ai/platform-config-lib';
|
|
5
|
-
import { RuntimeEnvironment } from '@wildo-ai/saas-models';
|
|
5
|
+
import { EnvironmentAgentContentGuardrailsSchema, RuntimeEnvironment } from '@wildo-ai/saas-models';
|
|
6
6
|
import { PROVIDER_SENSITIVE_ENV_KEYS } from '../../services/credentials/provider-env-vars.utils.js';
|
|
7
7
|
import { LiveEnvKeySet, memoiseOverCatalogue } from '../../services/credentials/composed-provider-catalogue.js';
|
|
8
8
|
/**
|
|
@@ -612,6 +612,12 @@ export const PlatformEnvConfigJson_Schema = z.strictObject({
|
|
|
612
612
|
* the backend configuration's `email.inbound.sharedDomain` applies unchanged.
|
|
613
613
|
*/
|
|
614
614
|
email: WildoInfraEmailConfigSchema.optional(),
|
|
615
|
+
/**
|
|
616
|
+
* What this environment does with the agents' classifier-backed content guardrails where no classifier offers them,
|
|
617
|
+
* mirrored from `wildo.infra.<env>.config.ts`. Persisted so `env-vars-builder` can project
|
|
618
|
+
* `WILDO_AGENT_CONTENT_GUARDRAILS` across a `wildo config sync` cycle. Missing => such an agent refuses every turn.
|
|
619
|
+
*/
|
|
620
|
+
agentContentGuardrails: EnvironmentAgentContentGuardrailsSchema.optional(),
|
|
615
621
|
/**
|
|
616
622
|
* LOCAL-ONLY ownership-DNS stand-in mirrored from `wildo.infra.local.config.ts` (#2519). Persisted so
|
|
617
623
|
* `env-vars-builder` can project `WILDO_OWNERSHIP_DNS_STAND_IN_URL` across a `wildo config sync` cycle. Missing =>
|