@felspar/sdk 0.3.0 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -292,13 +292,13 @@ var contentPartsLimits = Object.freeze({
292
292
  maxLogicalDepth: canonicalJsonLimits.maxDepth
293
293
  });
294
294
  var encoder = new TextEncoder();
295
- function utf8(text7) {
296
- if (text7.length >= 64) {
297
- return encoder.encode(text7).byteLength;
295
+ function utf8(text8) {
296
+ if (text8.length >= 64) {
297
+ return encoder.encode(text8).byteLength;
298
298
  }
299
299
  let bytes = 0;
300
- for (let index = 0; index < text7.length; index += 1) {
301
- const code = text7.codePointAt(index) ?? 0;
300
+ for (let index = 0; index < text8.length; index += 1) {
301
+ const code = text8.codePointAt(index) ?? 0;
302
302
  if (code < 128) {
303
303
  bytes += 1;
304
304
  } else if (code < 2048) {
@@ -312,8 +312,8 @@ function utf8(text7) {
312
312
  }
313
313
  return bytes;
314
314
  }
315
- async function sha256(text7) {
316
- const hash = new Uint8Array(await crypto.subtle.digest("SHA-256", encoder.encode(text7)));
315
+ async function sha256(text8) {
316
+ const hash = new Uint8Array(await crypto.subtle.digest("SHA-256", encoder.encode(text8)));
317
317
  return `sha256:${Array.from(hash, (byte) => byte.toString(16).padStart(2, "0")).join("")}`;
318
318
  }
319
319
  function reference(digest28) {
@@ -491,12 +491,12 @@ async function packContentParts(value) {
491
491
  }
492
492
  parts.sort(byDigest);
493
493
  const head = canonicalizeJson({ schema: draftContentPartsFormat, root: root.value, parts });
494
- const text7 = [head, ...parts.map((part) => state.parts.get(part) ?? "")].join("\n");
495
- const storedBytes = utf8(text7);
494
+ const text8 = [head, ...parts.map((part) => state.parts.get(part) ?? "")].join("\n");
495
+ const storedBytes = utf8(text8);
496
496
  admitStored(parts.length, storedBytes);
497
497
  return {
498
498
  digest: digest28,
499
- text: text7,
499
+ text: text8,
500
500
  parts: parts.length,
501
501
  storedBytes,
502
502
  logicalBytes: root.logical.bytes,
@@ -1273,6 +1273,21 @@ function clauseIdentity(clause) {
1273
1273
  function isSameClause(left, right) {
1274
1274
  return clauseIdentity(left) === clauseIdentity(right);
1275
1275
  }
1276
+ function choiceValues(clause) {
1277
+ if ("equals" in clause) {
1278
+ return [clause.equals];
1279
+ }
1280
+ return "oneOf" in clause ? clause.oneOf : [];
1281
+ }
1282
+ function isGuardImplied(guard, clause) {
1283
+ if (isSameClause(guard, clause)) {
1284
+ return true;
1285
+ }
1286
+ const allowed = choiceValues(guard);
1287
+ const values = choiceValues(clause);
1288
+ const isSameKey = clause.key === guard.key;
1289
+ return isSameKey && values.length > 0 && values.every((value) => allowed.includes(value));
1290
+ }
1276
1291
  function isPolicyValid(proposal, context3) {
1277
1292
  const clauses2 = [
1278
1293
  ...proposal.rules.flatMap((rule3) => rule3.when),
@@ -1330,11 +1345,11 @@ function inspectRuleGuards(proposal, context3) {
1330
1345
  for (const [index, rule3] of proposal.rules.entries()) {
1331
1346
  for (const clause of rule3.when) {
1332
1347
  const gates = isRelational ? conditionKeys(clause).flatMap((key3) => activationGuards(key3, requirements3)) : requirements3.get(clause.key)?.requiredWhen ?? [];
1333
- if (gates.some((gate) => rule3.when.every((candidate2) => !isSameClause(gate, candidate2)))) {
1348
+ if (gates.some((gate) => rule3.when.every((candidate2) => !isGuardImplied(gate, candidate2)))) {
1334
1349
  context3.addIssue({
1335
1350
  code: "custom",
1336
1351
  path: ["rules", index],
1337
- message: "Conditional rule must include every exact activation predicate"
1352
+ message: "Conditional rule must include every activation predicate, or an answer condition on its key within its answers"
1338
1353
  });
1339
1354
  }
1340
1355
  }
@@ -1438,7 +1453,7 @@ import { z as z14 } from "zod";
1438
1453
 
1439
1454
  // ../schemas/src/draft-scoring-references.ts
1440
1455
  function hasClause(clauses2, expected2) {
1441
- return clauses2.some((clause) => JSON.stringify(clause) === JSON.stringify(expected2));
1456
+ return clauses2.some((clause) => isGuardImplied(expected2, clause));
1442
1457
  }
1443
1458
  function mayOverlap(left, right, definitions) {
1444
1459
  for (const clause of left) {
@@ -1461,7 +1476,7 @@ function clauseIssues(clause, scope2) {
1461
1476
  }
1462
1477
  for (const key3 of conditionKeys(clause)) {
1463
1478
  if (activationGuards(key3, byKey).some((guard) => !hasClause(active, guard))) {
1464
- issues.push("Scoring applicability must include every exact requirement activation guard");
1479
+ issues.push("Scoring applicability must include every requirement activation guard, or an answer condition on its key within its answers");
1465
1480
  }
1466
1481
  }
1467
1482
  return issues;
@@ -1469,8 +1484,8 @@ function clauseIssues(clause, scope2) {
1469
1484
  function inspectScoringReferences(scoring, requirements3, context3) {
1470
1485
  const definitions = new Map(requirements3.map((row2) => [row2.definition.key, row2.definition]));
1471
1486
  const byKey = new Map(requirements3.map((row2) => [row2.definition.key, row2]));
1472
- for (const [index, criterion2] of scoring.criteria.entries()) {
1473
- const active = criterion2.activeWhen ?? [];
1487
+ for (const [index, criterion3] of scoring.criteria.entries()) {
1488
+ const active = criterion3.activeWhen ?? [];
1474
1489
  const fail = (message) => {
1475
1490
  context3.addIssue({ code: "custom", path: ["criteria", index], message });
1476
1491
  };
@@ -1479,15 +1494,15 @@ function inspectScoringReferences(scoring, requirements3, context3) {
1479
1494
  fail("Scoring applicability requires unconditional requirements");
1480
1495
  }
1481
1496
  }
1482
- const all = [...active, ...criterion2.cases.flatMap((item) => item.when)];
1497
+ const all = [...active, ...criterion3.cases.flatMap((item) => item.when)];
1483
1498
  for (const clause of all) {
1484
1499
  const messages = clauseIssues(clause, { active, definitions, byKey });
1485
1500
  for (const message of messages) {
1486
1501
  fail(message);
1487
1502
  }
1488
1503
  }
1489
- for (const [caseIndex, item] of criterion2.cases.entries()) {
1490
- if (criterion2.cases.slice(caseIndex + 1).some((other) => mayOverlap(item.when, other.when, definitions))) {
1504
+ for (const [caseIndex, item] of criterion3.cases.entries()) {
1505
+ if (criterion3.cases.slice(caseIndex + 1).some((other) => mayOverlap(item.when, other.when, definitions))) {
1491
1506
  fail("Scoring contribution cases must be provably disjoint");
1492
1507
  }
1493
1508
  }
@@ -1519,7 +1534,7 @@ function inspectScoredPolicy(proposal, context3) {
1519
1534
  }
1520
1535
  inspectScoringReferences(scoring, proposal.requirements, context3);
1521
1536
  const ids3 = new Set(rules2.map((rule3) => rule3.id));
1522
- if (gates.some((id12) => !ids3.has(id12))) {
1537
+ if (gates.some((id13) => !ids3.has(id13))) {
1523
1538
  fail("Unknown mandatory gate rule");
1524
1539
  }
1525
1540
  if (rules2.every((rule3) => gates.includes(rule3.id))) {
@@ -1532,7 +1547,7 @@ function inspectScoredPolicy(proposal, context3) {
1532
1547
  if (isGate ? hasRange || rule3.when.length === 0 : !hasRange) {
1533
1548
  fail("Mandatory gates require fact predicates only; other rules require score ranges");
1534
1549
  }
1535
- if (rule3.overrides.some((id12) => gates.includes(id12) !== isGate)) {
1550
+ if (rule3.overrides.some((id13) => gates.includes(id13) !== isGate)) {
1536
1551
  fail("Explicit overrides cannot cross mandatory-gate and score-band classes");
1537
1552
  }
1538
1553
  const range2 = rule3.scoreRange;
@@ -1620,19 +1635,19 @@ function hasCycle(rules2) {
1620
1635
  const graph = new Map(rules2.map((item) => [item.id, item.overrides]));
1621
1636
  const visiting = /* @__PURE__ */ new Set();
1622
1637
  const visited = /* @__PURE__ */ new Set();
1623
- const hasPathCycle = (id12) => {
1624
- if (visiting.has(id12)) {
1638
+ const hasPathCycle = (id13) => {
1639
+ if (visiting.has(id13)) {
1625
1640
  return true;
1626
1641
  }
1627
- if (visited.has(id12)) {
1642
+ if (visited.has(id13)) {
1628
1643
  return false;
1629
1644
  }
1630
- visiting.add(id12);
1631
- if ((graph.get(id12) ?? []).some(hasPathCycle)) {
1645
+ visiting.add(id13);
1646
+ if ((graph.get(id13) ?? []).some(hasPathCycle)) {
1632
1647
  return true;
1633
1648
  }
1634
- visiting.delete(id12);
1635
- visited.add(id12);
1649
+ visiting.delete(id13);
1650
+ visited.add(id13);
1636
1651
  return false;
1637
1652
  };
1638
1653
  return rules2.some((item) => hasPathCycle(item.id));
@@ -1661,11 +1676,11 @@ function inspectRules(proposal, context3) {
1661
1676
  fail("Undeclared condition key or value");
1662
1677
  }
1663
1678
  }
1664
- if (item.overrides.some((id12) => id12 === item.id || !ids3.has(id12))) {
1679
+ if (item.overrides.some((id13) => id13 === item.id || !ids3.has(id13))) {
1665
1680
  fail("Unknown or self override");
1666
1681
  }
1667
- if (item.overrides.some((id12) => {
1668
- const target = byId.get(id12);
1682
+ if (item.overrides.some((id13) => {
1683
+ const target = byId.get(id13);
1669
1684
  return target !== void 0 && draftRulePriority(target) > draftRulePriority(item);
1670
1685
  })) {
1671
1686
  fail("Override points to a higher priority tier");
@@ -1838,8 +1853,8 @@ function checkExpected(candidate2, context3) {
1838
1853
  }
1839
1854
  unique2(result.observationIds, context3, ["expected", "observationIds"]);
1840
1855
  const observationIds = new Set(candidate2.observations.map((entry2) => entry2.id));
1841
- for (const [index, id12] of result.observationIds.entries()) {
1842
- requireBinding2(observationIds.has(id12), context3, {
1856
+ for (const [index, id13] of result.observationIds.entries()) {
1857
+ requireBinding2(observationIds.has(id13), context3, {
1843
1858
  path: ["expected", "observationIds", index],
1844
1859
  message: "Unknown observation"
1845
1860
  });
@@ -2131,7 +2146,7 @@ var bundleNodeLimit = 65536;
2131
2146
  function boundedDraftInput(limits2) {
2132
2147
  return z21.unknown().transform((input, context3) => {
2133
2148
  let nodes = 0;
2134
- let text7 = 0;
2149
+ let text8 = 0;
2135
2150
  const budgetError = new Error("Draft input budget exceeded or non-data input");
2136
2151
  function copy(value, depth) {
2137
2152
  nodes += 1;
@@ -2139,8 +2154,8 @@ function boundedDraftInput(limits2) {
2139
2154
  throw budgetError;
2140
2155
  }
2141
2156
  if (typeof value === "string") {
2142
- text7 += value.length;
2143
- if (value.length > limits2.stringLength || text7 > limits2.totalText) {
2157
+ text8 += value.length;
2158
+ if (value.length > limits2.stringLength || text8 > limits2.totalText) {
2144
2159
  throw budgetError;
2145
2160
  }
2146
2161
  return value;
@@ -2192,7 +2207,7 @@ function boundedDraftInput(limits2) {
2192
2207
  });
2193
2208
  }
2194
2209
  var isUnicodeText = (value) => !/[\uD800-\uDFFF]/u.test(value);
2195
- var isSplitCharacter = (text7, offset) => offset > 0 && offset < text7.length && /[\uDC00-\uDFFF]/u.test(text7.charAt(offset));
2210
+ var isSplitCharacter = (text8, offset) => offset > 0 && offset < text8.length && /[\uDC00-\uDFFF]/u.test(text8.charAt(offset));
2196
2211
  var sourceText = DraftSourceReferenceSchema.omit({ contentDigest: true }).extend({
2197
2212
  text: z21.string().min(1).max(1048576).refine(isUnicodeText, "Lone Unicode surrogate"),
2198
2213
  offsetUnit: z21.literal("utf16_code_units"),
@@ -3023,13 +3038,13 @@ function areSubjectsValid(subjects, isIsolated) {
3023
3038
  function areEscalationsValid(escalations, context3) {
3024
3039
  const { isIsolated, outcomes } = context3;
3025
3040
  const ids3 = new Set(escalations.routes.map((row2) => row2.id));
3026
- const named = [escalations.unresolved, escalations.attemptLimit].filter((id12) => id12 !== null);
3041
+ const named = [escalations.unresolved, escalations.attemptLimit].filter((id13) => id13 !== null);
3027
3042
  return [
3028
3043
  ids3.size === escalations.routes.length,
3029
3044
  escalations.routes.every((row2) => isIsolated(row2.entryId, "routing_jobs")),
3030
3045
  hasUniqueValues(escalations.outcomes.map((row2) => row2.outcome)),
3031
3046
  escalations.outcomes.every((row2) => ids3.has(row2.escalation) && outcomes.has(row2.outcome)),
3032
- named.every((id12) => ids3.has(id12))
3047
+ named.every((id13) => ids3.has(id13))
3033
3048
  ].every(Boolean);
3034
3049
  }
3035
3050
  function isGuideValid(guide, isIsolated) {
@@ -3119,7 +3134,7 @@ var DraftContextSelectionPlanSchema = z31.strictObject({
3119
3134
  if (candidateIds.length > 64 || !hasUniqueIds(candidateIds) || !hasUniqueIds(plan.groups.map((item) => item.id)) || !hasUniqueIds(plan.entries.map((item) => item.id))) {
3120
3135
  context3.addIssue({ code: "custom", message: "Duplicate identities or too many candidates" });
3121
3136
  }
3122
- if (plan.requiredIds.some((id12) => candidateIds.includes(id12))) {
3137
+ if (plan.requiredIds.some((id13) => candidateIds.includes(id13))) {
3123
3138
  context3.addIssue({ code: "custom", message: "Global required root cannot be a candidate" });
3124
3139
  }
3125
3140
  const guidanceId = plan.unresolvedGuidanceEntryId;
@@ -3710,7 +3725,7 @@ var DraftApplicationReleaseSchema = z43.strictObject({
3710
3725
  });
3711
3726
 
3712
3727
  // ../schemas/src/draft-hosted-application.ts
3713
- import { z as z50 } from "zod";
3728
+ import { z as z53 } from "zod";
3714
3729
 
3715
3730
  // ../schemas/src/draft-source-instant.ts
3716
3731
  var localPattern = /^(\d{4})-(\d{2})-(\d{2})[Tt](\d{2}):(\d{2})(?::(\d{2})(?:\.(\d{1,9}))?)?([^.\d].*)$/u;
@@ -4368,60 +4383,244 @@ var HostedOutputChecksSchema = z49.strictObject({
4368
4383
  }
4369
4384
  });
4370
4385
 
4386
+ // ../schemas/src/draft-pack-revision.ts
4387
+ import { z as z52 } from "zod";
4388
+
4389
+ // ../schemas/src/draft-pack-draft-outputs.ts
4390
+ import { z as z50 } from "zod";
4391
+ var identifier21 = z50.string().min(1).max(64).regex(/^[a-z0-9][a-z0-9_-]*$/u, "Use lowercase letters, digits, - and _");
4392
+ var quote = z50.string().min(1).max(4e3);
4393
+ var wording = z50.string().min(1).max(artifactLintLimits.maxLiteralUnits).regex(/\S/u, "Wording needs a visible character").refine(isWellFormedText, "Wording has a broken character");
4394
+ var packDraftOutputLimits = {
4395
+ maxOutputs: 8,
4396
+ maxChecks: 16,
4397
+ maxQuestions: 24,
4398
+ maxContext: 8,
4399
+ defaultCharacters: 8e3,
4400
+ maxCharacters: artifactLintLimits.maxSectionUnits
4401
+ };
4402
+ var wordingCheck = (max) => z50.strictObject({ id: identifier21, quote, wording: z50.array(wording).min(1).max(max) });
4403
+ var PackDraftOutputSchema = z50.strictObject({
4404
+ id: identifier21,
4405
+ what: quote,
4406
+ outcomes: z50.array(identifier21).min(1).max(64).refine(hasUniqueValues, "Duplicate outcome"),
4407
+ maxCharacters: z50.number().int().min(1).max(packDraftOutputLimits.maxCharacters).optional(),
4408
+ context: z50.array(z50.strictObject({ id: identifier21, quote })).min(1).max(packDraftOutputLimits.maxContext).refine((rows) => hasUniqueValues(rows.map((row2) => row2.id)), "Duplicate context id").optional(),
4409
+ require: z50.array(wordingCheck(artifactLintLimits.maxAlternatives)).max(packDraftOutputLimits.maxChecks).optional(),
4410
+ prohibit: z50.array(wordingCheck(artifactLintLimits.maxLiterals)).max(packDraftOutputLimits.maxChecks).optional(),
4411
+ ask: z50.array(z50.strictObject({
4412
+ id: identifier21,
4413
+ quote,
4414
+ kind: z50.enum(["require", "prohibit"]),
4415
+ question: z50.string().min(1).max(2e3).regex(/\S/u)
4416
+ })).max(packDraftOutputLimits.maxQuestions).optional(),
4417
+ states: z50.array(z50.strictObject({
4418
+ id: identifier21,
4419
+ quote,
4420
+ question: identifier21,
4421
+ wording: z50.record(identifier21, z50.array(wording).min(1).max(8)).optional()
4422
+ })).max(packDraftOutputLimits.maxQuestions).optional()
4423
+ }).refine((output) => {
4424
+ const ids3 = [
4425
+ ...output.require ?? [],
4426
+ ...output.prohibit ?? [],
4427
+ ...output.ask ?? [],
4428
+ ...output.states ?? []
4429
+ ];
4430
+ return hasUniqueValues(ids3.map((row2) => row2.id));
4431
+ }, "Duplicate check id").refine((output) => {
4432
+ return (output.ask?.length ?? 0) + (output.states?.length ?? 0) <= packDraftOutputLimits.maxQuestions;
4433
+ }, `At most ${packDraftOutputLimits.maxQuestions} asked questions and stated answers together`).refine((output) => {
4434
+ return (output.require?.length ?? 0) + (output.prohibit?.length ?? 0) + (output.ask?.length ?? 0) + (output.states?.length ?? 0) > 0;
4435
+ }, "An output needs at least one check");
4436
+ var PackDraftOutputsSchema = z50.array(PackDraftOutputSchema).min(1).max(packDraftOutputLimits.maxOutputs).refine((rows) => hasUniqueValues(rows.map((row2) => row2.id)), "Duplicate output");
4437
+
4438
+ // ../schemas/src/draft-pack-draft-scoring.ts
4439
+ import { z as z51 } from "zod";
4440
+ var points = z51.number().min(0).max(1e6);
4441
+ var PackDraftScoreSchema = z51.strictObject({
4442
+ lt: points.optional(),
4443
+ lte: points.optional(),
4444
+ gt: points.optional(),
4445
+ gte: points.optional(),
4446
+ eq: points.optional(),
4447
+ quote: draftQuote
4448
+ }).superRefine((value, context3) => {
4449
+ const lower = Number(value.gt !== void 0) + Number(value.gte !== void 0);
4450
+ const upper = Number(value.lt !== void 0) + Number(value.lte !== void 0);
4451
+ const hasEquality = value.eq !== void 0;
4452
+ if (lower + upper + Number(hasEquality) === 0) {
4453
+ context3.addIssue({ code: "custom", message: "Give a bound: lt, lte, gt, gte or eq" });
4454
+ } else if (lower > 1 || upper > 1) {
4455
+ context3.addIssue({ code: "custom", message: "At most one lower and one upper bound" });
4456
+ } else if (hasEquality && lower + upper > 0) {
4457
+ context3.addIssue({ code: "custom", message: "eq stands alone" });
4458
+ }
4459
+ });
4460
+ var contribution2 = z51.strictObject({
4461
+ id: draftIdentifier,
4462
+ points,
4463
+ quote: draftQuote,
4464
+ when: PackDraftConditionsSchema
4465
+ });
4466
+ var criterion2 = z51.strictObject({
4467
+ id: draftIdentifier,
4468
+ meaning: draftQuote,
4469
+ activeWhen: PackDraftConditionsSchema.optional(),
4470
+ points: z51.array(contribution2).min(1).max(16).refine((rows) => hasUniqueValues(rows.map((row2) => row2.id)), "Duplicate points id"),
4471
+ otherwise: z51.strictObject({ points, quote: draftQuote }).optional()
4472
+ });
4473
+ var PackDraftScoringSchema = z51.strictObject({
4474
+ scale: z51.union([z51.literal(1), z51.literal(100)]).optional(),
4475
+ criteria: z51.array(criterion2).min(1).max(16).refine((rows) => hasUniqueValues(rows.map((row2) => row2.id)), "Duplicate criterion")
4476
+ });
4477
+ var packDraftScoreExpectation = {
4478
+ score: z51.number().min(0).optional(),
4479
+ points: z51.record(draftIdentifier, z51.number().min(0).nullable()).optional()
4480
+ };
4481
+
4482
+ // ../schemas/src/draft-pack-revision.ts
4483
+ var KeptPackDraftSchema = z52.looseObject({
4484
+ schema: z52.string().regex(/^felspar\.pack-draft\/v\d{1,3}$/u),
4485
+ job: z52.string().min(1).max(200)
4486
+ });
4487
+ var id6 = z52.string().min(1).max(200);
4488
+ var text7 = z52.string().min(1).max(262144);
4489
+ var texts = z52.array(z52.string()).max(8);
4490
+ var when = PackDraftConditionsSchema;
4491
+ var conventions = packConventionFields;
4492
+ var PackOutlineSchema = z52.strictObject({
4493
+ schema: z52.literal("felspar.pack-outline/v0"),
4494
+ job: id6,
4495
+ purpose: text7.nullable(),
4496
+ useWhen: texts,
4497
+ notFor: texts,
4498
+ owner: text7.nullable(),
4499
+ evidenceKinds: z52.array(id6).max(8),
4500
+ maxEvidenceAgeDays: z52.number().int().min(1).nullable(),
4501
+ numberStyle: z52.enum(numberStyles).nullable(),
4502
+ dateOrder: conventions.dateOrder.unwrap().nullable(),
4503
+ timeZone: z52.string().min(1).max(64).nullable(),
4504
+ subject: id6.nullable(),
4505
+ subjects: z52.array(z52.strictObject({
4506
+ id: id6,
4507
+ definition: text7,
4508
+ identifier: z52.string().nullable(),
4509
+ example: z52.string().nullable(),
4510
+ match: z52.string(),
4511
+ relationships: z52.array(z52.strictObject({
4512
+ name: id6,
4513
+ subject: id6,
4514
+ cardinality: z52.enum(["one", "many"]),
4515
+ required: z52.boolean(),
4516
+ definition: text7
4517
+ })).max(16),
4518
+ identity: PackDraftIdentitySchema.nullable()
4519
+ })).max(16),
4520
+ escalations: z52.array(z52.strictObject({ id: id6, quote: text7 })).max(16),
4521
+ questions: z52.array(z52.strictObject({
4522
+ key: id6,
4523
+ type: z52.enum(["enum", "boolean", "number", "date"]),
4524
+ meaning: text7,
4525
+ about: id6.nullable(),
4526
+ askOnlyWhen: z52.string().nullable(),
4527
+ when: when.nullable(),
4528
+ unit: z52.string().nullable(),
4529
+ unitWords: z52.array(z52.string()).max(16).nullable(),
4530
+ integer: z52.boolean().nullable(),
4531
+ minimum: z52.number().nullable(),
4532
+ maximum: z52.number().nullable(),
4533
+ answers: z52.array(z52.strictObject({
4534
+ value: id6,
4535
+ meaning: z52.string().nullable(),
4536
+ inclusions: texts,
4537
+ exclusions: texts,
4538
+ examples: texts,
4539
+ edgeCases: texts
4540
+ })).max(64),
4541
+ whereToLook: texts
4542
+ })).max(64),
4543
+ outcomes: z52.array(z52.strictObject({ id: id6, nextStep: text7.nullable(), escalate: id6.nullable() })).max(64),
4544
+ whenUnresolved: z52.strictObject({ quote: text7, escalate: id6.nullable() }).nullable(),
4545
+ attempts: z52.strictObject({ max: z52.number().int(), escalate: id6.nullable() }).nullable(),
4546
+ rules: z52.array(z52.strictObject({
4547
+ id: id6,
4548
+ meaning: text7,
4549
+ outcome: id6,
4550
+ when: when.nullable(),
4551
+ conditions: z52.string().nullable(),
4552
+ scoreRange: z52.record(z52.string(), z52.unknown()).nullable(),
4553
+ score: PackDraftScoreSchema.nullable(),
4554
+ gate: z52.boolean()
4555
+ })).max(256),
4556
+ scoring: PackDraftScoringSchema.nullable(),
4557
+ cases: z52.array(z52.strictObject({
4558
+ id: id6,
4559
+ why: z52.string().nullable(),
4560
+ facts: z52.record(id6, caseFactSchema),
4561
+ decisionDate: CalendarDateSchema.nullable(),
4562
+ subject: z52.strictObject({ id: id6 }).nullable(),
4563
+ expect: z52.strictObject({ outcome: id6, rule: id6, score: z52.number().nullable() })
4564
+ })).max(200),
4565
+ outputChecks: PackDraftOutputsSchema.nullable(),
4566
+ notKept: z52.array(z52.strictObject({ path: z52.string().min(1), reason: z52.string().min(1) })).max(64)
4567
+ });
4568
+
4371
4569
  // ../schemas/src/draft-hosted-application.ts
4372
- var id6 = z50.string().min(1).max(200).regex(/^[a-zA-Z0-9][a-zA-Z0-9._:@-]*$/u);
4570
+ var id7 = z53.string().min(1).max(200).regex(/^[a-zA-Z0-9][a-zA-Z0-9._:@-]*$/u);
4373
4571
  var digest23 = DraftApplicationReleaseSchema.shape.releaseDigest;
4374
- var HostedSourceInputSchema = z50.strictObject({
4375
- sourceId: id6,
4376
- revision: id6,
4377
- title: z50.string().min(1).max(200),
4378
- text: z50.string().min(1).max(1048576)
4379
- });
4380
- var HostedProposalInputV0Schema = z50.strictObject({
4381
- sourceObjectId: id6,
4572
+ var HostedSourceInputSchema = z53.strictObject({
4573
+ sourceId: id7,
4574
+ revision: id7,
4575
+ title: z53.string().min(1).max(200),
4576
+ text: z53.string().min(1).max(1048576)
4577
+ });
4578
+ var HostedProposalInputV0Schema = z53.strictObject({
4579
+ sourceObjectId: id7,
4382
4580
  expectedSourceDigest: digest23,
4383
4581
  material: DraftApplicationJobMaterialSchema,
4384
4582
  compilation: DraftCompilationSchema
4385
4583
  });
4386
- var HostedProposalInputV2Schema = z50.strictObject({
4387
- schema: z50.literal("felspar.hosted-proposal.draft/v2"),
4388
- sourceObjectId: id6,
4584
+ var HostedProposalInputV2Schema = z53.strictObject({
4585
+ schema: z53.literal("felspar.hosted-proposal.draft/v2"),
4586
+ sourceObjectId: id7,
4389
4587
  expectedSourceDigest: digest23,
4390
4588
  material: DraftApplicationJobMaterialV2Schema,
4391
- outputChecks: HostedOutputChecksSchema.optional()
4589
+ outputChecks: HostedOutputChecksSchema.optional(),
4590
+ draft: KeptPackDraftSchema.optional()
4392
4591
  });
4393
- var HostedProposalInputSchema = z50.union([
4592
+ var HostedProposalInputSchema = z53.union([
4394
4593
  HostedProposalInputV2Schema,
4395
4594
  HostedProposalInputV0Schema
4396
4595
  ]);
4397
- var HostedApprovalInputSchema = z50.strictObject({
4596
+ var HostedApprovalInputSchema = z53.strictObject({
4398
4597
  expectedProposalDigest: digest23,
4399
- reviewedMeaning: z50.literal(true),
4400
- reviewedFixtures: z50.literal(true),
4401
- reviewNote: z50.string().min(1).max(2e3)
4598
+ reviewedMeaning: z53.literal(true),
4599
+ reviewedFixtures: z53.literal(true),
4600
+ reviewNote: z53.string().min(1).max(2e3)
4402
4601
  });
4403
- var HostedReleaseInputSchema = z50.strictObject({ expectedApprovalDigest: digest23 });
4404
- var HostedReleaseBundleSchema = z50.strictObject({
4602
+ var HostedReleaseInputSchema = z53.strictObject({ expectedApprovalDigest: digest23 });
4603
+ var HostedReleaseBundleSchema = z53.strictObject({
4405
4604
  release: DraftApplicationReleaseSchema,
4406
4605
  material: DraftAnyApplicationJobMaterialSchema,
4407
- approvalObjectId: id6,
4606
+ approvalObjectId: id7,
4408
4607
  approvalDigest: digest23,
4409
4608
  proposalDigest: digest23,
4410
4609
  sourceDigest: digest23,
4411
4610
  verifiedCompilation: DraftVerifiedCompilationSchema.optional()
4412
4611
  });
4413
- var HostedJobInputSchema = z50.strictObject({
4414
- executionId: id6,
4612
+ var HostedJobInputSchema = z53.strictObject({
4613
+ executionId: id7,
4415
4614
  expectedReleaseDigest: digest23,
4416
4615
  material: DraftAnyApplicationJobMaterialSchema
4417
4616
  });
4418
- var HostedSuppliedJobInputSchema = z50.strictObject({
4419
- mode: z50.literal("supplied"),
4420
- executionId: id6,
4617
+ var HostedSuppliedJobInputSchema = z53.strictObject({
4618
+ mode: z53.literal("supplied"),
4619
+ executionId: id7,
4421
4620
  expectedReleaseDigest: digest23,
4422
4621
  expectedAuthorityDigest: digest23,
4423
- jobId: id6,
4424
- entityId: id6,
4622
+ jobId: id7,
4623
+ entityId: id7,
4425
4624
  evidence: DraftRequiredDecisionSchema.shape.evidence,
4426
4625
  passages: DraftLayeredEvaluationSchema.shape.passages.max(256)
4427
4626
  });
@@ -4431,97 +4630,97 @@ var hostedFactsLimits = {
4431
4630
  maxFactsBytes: 524288,
4432
4631
  maxQuestions: 64
4433
4632
  };
4434
- var factSourceId = z50.string().refine(isDraftSourceId, "source_id_invalid").describe(`The source's own ID or address, such as its page URL with any query: RFC 3986 characters, starting with a letter or digit, at most ${draftSourceIdLimit} characters.`);
4435
- var observedAt = z50.string().refine((value) => normalizedSourceInstant(value) !== null, "observed_at_invalid").transform((value) => normalizedSourceInstant(value) ?? value).describe(`When the source was read: an RFC 3339 date and time with Z or an offset, such as 2026-10-21T10:00:00Z or 2026-10-21T12:00+02:00, at most ${sourceInstantMaxLength} characters. Stored in UTC.`);
4436
- var factSource = z50.strictObject({
4437
- class: id6,
4633
+ var factSourceId = z53.string().refine(isDraftSourceId, "source_id_invalid").describe(`The source's own ID or address, such as its page URL with any query: RFC 3986 characters, starting with a letter or digit, at most ${draftSourceIdLimit} characters.`);
4634
+ var observedAt = z53.string().refine((value) => normalizedSourceInstant(value) !== null, "observed_at_invalid").transform((value) => normalizedSourceInstant(value) ?? value).describe(`When the source was read: an RFC 3339 date and time with Z or an offset, such as 2026-10-21T10:00:00Z or 2026-10-21T12:00+02:00, at most ${sourceInstantMaxLength} characters. Stored in UTC.`);
4635
+ var factSource = z53.strictObject({
4636
+ class: id7,
4438
4637
  id: factSourceId,
4439
- revision: id6.optional(),
4440
- locator: z50.string().min(1).max(4096).optional(),
4638
+ revision: id7.optional(),
4639
+ locator: z53.string().min(1).max(4096).optional(),
4441
4640
  observedAt,
4442
- sensitivity: id6.optional()
4641
+ sensitivity: id7.optional()
4443
4642
  });
4444
- var excerptText = z50.string().min(1).refine((text7) => text7.length <= hostedFactsLimits.maxExcerptCharacters, "text_too_long");
4445
- var about = z50.string().min(1).max(200).optional();
4446
- var HostedExcerptSchema = z50.strictObject({ text: excerptText, source: factSource, about });
4447
- var HostedValueFactSchema = z50.strictObject({
4448
- value: z50.union([z50.string().min(1).max(200), z50.number(), z50.boolean()]),
4643
+ var excerptText = z53.string().min(1).refine((text8) => text8.length <= hostedFactsLimits.maxExcerptCharacters, "text_too_long");
4644
+ var about = z53.string().min(1).max(200).optional();
4645
+ var HostedExcerptSchema = z53.strictObject({ text: excerptText, source: factSource, about });
4646
+ var HostedValueFactSchema = z53.strictObject({
4647
+ value: z53.union([z53.string().min(1).max(200), z53.number(), z53.boolean()]),
4449
4648
  source: factSource.extend({ excerpt: excerptText.optional() }),
4450
4649
  about
4451
4650
  });
4452
- var HostedFactSchema = z50.union([
4651
+ var HostedFactSchema = z53.union([
4453
4652
  HostedValueFactSchema,
4454
4653
  HostedExcerptSchema,
4455
- z50.array(HostedExcerptSchema).min(1).refine((excerpts2) => excerpts2.length <= hostedFactsLimits.maxExcerptsPerQuestion, "too_many_excerpts")
4654
+ z53.array(HostedExcerptSchema).min(1).refine((excerpts2) => excerpts2.length <= hostedFactsLimits.maxExcerptsPerQuestion, "too_many_excerpts")
4456
4655
  ]);
4457
4656
  function factsBytes(facts) {
4458
4657
  const encoder2 = new TextEncoder();
4459
4658
  return encoder2.encode(JSON.stringify(facts)).length;
4460
4659
  }
4461
- var HostedFactsJobInputSchema = z50.strictObject({
4462
- mode: z50.literal("facts"),
4463
- executionId: id6,
4660
+ var HostedFactsJobInputSchema = z53.strictObject({
4661
+ mode: z53.literal("facts"),
4662
+ executionId: id7,
4464
4663
  expectedReleaseDigest: digest23,
4465
- jobId: id6,
4466
- entityId: id6,
4664
+ jobId: id7,
4665
+ entityId: id7,
4467
4666
  related: HostedRelatedSubjectsSchema.optional(),
4468
- identity: z50.record(z50.string().min(1).max(128), z50.string().min(1).max(200)).optional(),
4469
- facts: z50.record(id6, HostedFactSchema).refine((facts) => Object.keys(facts).length <= hostedFactsLimits.maxQuestions, "too_many_questions").refine((facts) => factsBytes(facts) <= hostedFactsLimits.maxFactsBytes, "request_too_large")
4667
+ identity: z53.record(z53.string().min(1).max(128), z53.string().min(1).max(200)).optional(),
4668
+ facts: z53.record(id7, HostedFactSchema).refine((facts) => Object.keys(facts).length <= hostedFactsLimits.maxQuestions, "too_many_questions").refine((facts) => factsBytes(facts) <= hostedFactsLimits.maxFactsBytes, "request_too_large")
4470
4669
  });
4471
4670
  var HostedFactsRequestSchema = HostedFactsJobInputSchema.extend({
4472
- entityId: id6.optional()
4671
+ entityId: id7.optional()
4473
4672
  });
4474
- var HostedJobRequestSchema = z50.union([
4673
+ var HostedJobRequestSchema = z53.union([
4475
4674
  HostedJobInputSchema,
4476
4675
  HostedSuppliedJobInputSchema,
4477
4676
  HostedFactsJobInputSchema
4478
4677
  ]);
4479
- var HostedClassificationResultSchema = z50.strictObject({
4480
- key: id6,
4481
- observationId: id6,
4678
+ var HostedClassificationResultSchema = z53.strictObject({
4679
+ key: id7,
4680
+ observationId: id7,
4482
4681
  record: DraftNormalizedEvidenceSchema.shape.normalizations.element,
4483
- reason: z50.string().regex(/^[a-z][a-z_]{2,63}$/u).nullable(),
4484
- cached: z50.boolean()
4682
+ reason: z53.string().regex(/^[a-z][a-z_]{2,63}$/u).nullable(),
4683
+ cached: z53.boolean()
4485
4684
  });
4486
4685
  function retainsFactsExactly(record) {
4487
4686
  const hasFacts = record.facts !== void 0 && record.judgments !== void 0 && record.judgmentsDigest !== void 0;
4488
4687
  return record.schema === "felspar.hosted-supplied-execution/v3" === hasFacts;
4489
4688
  }
4490
- var HostedSuppliedExecutionRecordSchema = z50.strictObject({
4491
- schema: z50.enum([
4689
+ var HostedSuppliedExecutionRecordSchema = z53.strictObject({
4690
+ schema: z53.enum([
4492
4691
  "felspar.hosted-supplied-execution/v1",
4493
4692
  "felspar.hosted-supplied-execution/v2",
4494
4693
  "felspar.hosted-supplied-execution/v3"
4495
4694
  ]),
4496
- release: z50.strictObject({ releaseId: id6, releaseDigest: digest23, materialDigest: digest23 }),
4497
- evaluationTime: z50.iso.datetime(),
4695
+ release: z53.strictObject({ releaseId: id7, releaseDigest: digest23, materialDigest: digest23 }),
4696
+ evaluationTime: z53.iso.datetime(),
4498
4697
  input: HostedSuppliedJobInputSchema,
4499
4698
  facts: HostedFactsJobInputSchema.optional(),
4500
- judgments: z50.array(HostedClassificationResultSchema).max(192).optional(),
4699
+ judgments: z53.array(HostedClassificationResultSchema).max(192).optional(),
4501
4700
  judgmentsDigest: digest23.optional(),
4502
- expansion: z50.literal("agreeing-excerpts").optional(),
4503
- job: z50.record(z50.string(), z50.unknown())
4701
+ expansion: z53.literal("agreeing-excerpts").optional(),
4702
+ job: z53.record(z53.string(), z53.unknown())
4504
4703
  }).refine(retainsFactsExactly, "Version 3 records, and only they, retain facts with their judgments");
4505
- var HostedObjectSchema = z50.strictObject({
4506
- id: id6,
4507
- kind: z50.enum(["source", "proposal", "approval", "release", "evidence", "result", "execution"]),
4704
+ var HostedObjectSchema = z53.strictObject({
4705
+ id: id7,
4706
+ kind: z53.enum(["source", "proposal", "approval", "release", "evidence", "result", "execution"]),
4508
4707
  payloadDigest: digest23,
4509
- objectKey: z50.string().min(1).max(1e3),
4510
- parentId: id6.nullable(),
4511
- status: z50.enum(["active", "released", "revoked"]),
4512
- metadata: z50.record(z50.string(), z50.unknown())
4513
- });
4514
- var HostedJobResultSchema = z50.object({
4515
- status: z50.string(),
4516
- reason: z50.string().nullable(),
4517
- result: z50.object({
4518
- executionId: z50.string(),
4519
- releaseId: id6,
4708
+ objectKey: z53.string().min(1).max(1e3),
4709
+ parentId: id7.nullable(),
4710
+ status: z53.enum(["active", "released", "revoked"]),
4711
+ metadata: z53.record(z53.string(), z53.unknown())
4712
+ });
4713
+ var HostedJobResultSchema = z53.object({
4714
+ status: z53.string(),
4715
+ reason: z53.string().nullable(),
4716
+ result: z53.object({
4717
+ executionId: z53.string(),
4718
+ releaseId: id7,
4520
4719
  releaseDigest: digest23,
4521
- outcome: z50.string().nullable(),
4522
- scoring: z50.unknown(),
4523
- context: z50.unknown(),
4524
- receipt: z50.unknown()
4720
+ outcome: z53.string().nullable(),
4721
+ scoring: z53.unknown(),
4722
+ context: z53.unknown(),
4723
+ receipt: z53.unknown()
4525
4724
  }).loose().nullable()
4526
4725
  });
4527
4726
 
@@ -4530,12 +4729,12 @@ var limits = hostedFactsLimits;
4530
4729
  var formatFix = "The request does not match the facts request format at this path; follow input.example from get_job_requirements (input.jsonSchema in the REST brief).";
4531
4730
  var fixes = {
4532
4731
  observed_at_invalid: "Send observedAt as the date and time the source was read, with Z or an offset: for example 2026-10-21T10:00:00Z or 2026-10-21T12:00+02:00. A date alone, a time with no offset or words such as yesterday are not accepted.",
4533
- source_id_invalid: `Send source.id as the source's own ID or address, such as the page URL with its query: at most ${draftSourceIdLimit} characters, starting with a letter or digit, using URL characters only (percent-encode spaces and non-ASCII characters).`,
4732
+ source_id_invalid: `Send source.id as the source's own ID or address, such as a ticket number or a document URL with its query: at most ${draftSourceIdLimit} characters, starting with a letter or digit, using URL characters only (percent-encode spaces and non-ASCII characters).`,
4534
4733
  unknown_question: "This question is not in the released job. Use the question keys from describe.",
4535
4734
  source_class_not_accepted: "This question does not accept this source class. Send an excerpt from a source class the question's evidence policy in describe lists.",
4536
4735
  value_not_in_excerpt: "The quoted words do not state this value. Quote the exact words that state it, or send the text without a typed value.",
4537
4736
  duplicate_excerpt: "The same words from the same source were sent twice for this question. Send each excerpt once.",
4538
- duplicate_source_locator: "Another excerpt in this request names the same source and locator with different words. Give each passage its own locator (for example the page URL with the section heading after #); the same words may answer several questions.",
4737
+ duplicate_source_locator: "Another excerpt in this request names the same source and locator with different words. Give each passage its own locator (for example the document URL with the section heading after #, or the message ID); the same words may answer several questions.",
4539
4738
  label_needs_mapping: "Felspar decides answer choices and yes/no questions from source text. Send the words the source says, not a label.",
4540
4739
  value_not_allowed: "A typed value must be a finite number for a number question or a YYYY-MM-DD date for a date question.",
4541
4740
  answer_choice_needs_excerpt: "Send this question in a facts request with the source text; Felspar classifies answer choices itself.",
@@ -4545,6 +4744,7 @@ var fixes = {
4545
4744
  request_too_large: `The facts in one request are at most ${limits.maxFactsBytes} bytes. Send shorter excerpts.`,
4546
4745
  release_changed: "The release changed. Describe the job again and resend with the current release digest.",
4547
4746
  job_mismatch: "This release serves a different job. Use the job and release from describe.",
4747
+ job_retired: "The workspace owner retired this job. Don't call it again: use the job named in replacement (check it with list_jobs), or, if replacement is null, tell the person the job is retired and stop.",
4548
4748
  attempt_limit_reached: "This case has used its decision attempts. Don't ask again: escalate it with the escalation this refusal names (report its id exactly), or with the next step from your last result.",
4549
4749
  subject_id_invalid: "Send the case's ID as the job's subject describes it (its identifier and example in the job requirements): letters, digits and . _ : @ - only.",
4550
4750
  unknown_relationship: "This job's subject has no relationship of this name. Use a relationship listed under subject.related in the job requirements, or leave related out.",
@@ -4566,14 +4766,45 @@ var fixes = {
4566
4766
  invalid_body: "The body must be JSON or content parts within the size limit.",
4567
4767
  context_graph_invalid: "Felspar would block every decision of this pack because of the context issues listed. Build the pack again from its draft with check_pack until it is clean, then propose it again; a pack with these issues can't be proposed, approved or released.",
4568
4768
  forbidden: "This caller may not run this job on this release, or the release is not available. Check the release ID and the caller's access.",
4769
+ access_denied: "This caller may not do this, or what it names is not available to it. Use a job list_jobs shows; if it should be there, ask a workspace owner to add the job to this agent on the Felspar web page.",
4770
+ unauthenticated: "No credential was sent. Send the agent key as a Bearer token, or sign in.",
4771
+ invalid_arguments: "The tool's arguments don't match its input schema. Correct the field at each issue's path and call the tool again.",
4772
+ not_found: "No Felspar route matches this path and method. Check the URL against the REST reference.",
4773
+ check_not_found: "No output check by this caller with this ID on this job. Send the checkId from your own check_output result.",
4774
+ history_not_found: "No case history matches. Check the case ID.",
4775
+ history_unavailable: "Case history could not be read or changed just now. Try again later.",
4776
+ no_current_release: "The job has no current release to compare with. Release a first version, then backtest later changes.",
4777
+ source_access_required: "Your own connection can't read a document behind this object. Connect or reconnect it on the Felspar Sources page, or ask the document's owner to share it.",
4778
+ operation_unavailable: "Felspar could not complete this request. Try again later with the same request; if it keeps failing, tell a person.",
4569
4779
  source_read_failed: "Felspar couldn't read the document's current version with your own connection. If access is not_connected or reconnect, connect or reconnect Google Drive on the Felspar Sources page; if no_access, ask the document's owner to share it with you; otherwise try again later.",
4570
4780
  source_text_not_allowed: "An MCP client can't submit text as a source. To use a document's newest text, call add_current_version with its sourceObjectId from list_sources.",
4571
4781
  source_not_connected: "This source was not added from a connected document. Use a sourceObjectId from list_sources.",
4782
+ pack_not_found: "No released version or proposal of this job matches. Call list_jobs for the workspace's jobs, their current release and open proposals; for a job not yet released, pass a proposalId it lists.",
4783
+ proposal_out_of_date: "A newer version of this job was released after this proposal was made, so it can't be approved or released. Update it: read_pack for the live pack, apply the change again, preview_change, then propose_pack, which replaces your earlier proposal.",
4784
+ proposal_closed: "This proposal was released, rejected, withdrawn or replaced by a newer proposal, so nothing more can be done with it. Call list_jobs for the job's open proposals.",
4785
+ not_proposer: "Only the person who made a proposal may withdraw it; an approver may reject it.",
4786
+ not_job_approver: "Only this job's owner and named approvers, or a workspace owner, may approve, release or reject its proposals. details.owners names who may; ask one of them to review it on the Felspar web page.",
4787
+ withdraw_on_web_page: "Withdraw a proposal on the Felspar web page, or propose the job again, which replaces your earlier proposal.",
4788
+ change_request_needs_release: "This job has no release yet, so there is no document version to propose changes on. Draft its first pack with check_pack and propose_pack.",
4789
+ change_request_quote_invalid: "Each change must quote a passage exactly as it is in the release's version of the document (read_source on the source list_jobs names), found exactly once, with changes that don't overlap and a replacement that differs. details.problems names each change by its index: quote_not_found, quote_not_unique (quote more of the passage), edits_overlap or edit_unchanged.",
4790
+ change_request_definition_reason_required: "Give a reason for each definition the revised pack adds or changes: add { id, reason } under definitions for every id details.definitions lists.",
4791
+ change_request_definition_unknown: "A definition under definitions is not one the revised pack adds or changes. Use the question key or question/answer IDs from the revised pack's diff, or drop it.",
4792
+ change_request_too_large: "This change request is too large to store. Split it into smaller change requests.",
4793
+ change_request_not_found: "No change request with this ID. Call list_change_requests for the job's change requests.",
4794
+ change_request_edit_not_found: "The change request has no change at this index. Use an index from its changes, or leave edit out to comment on the whole request.",
4795
+ change_request_comment_limit: "This change request has as many comments as it can hold. Continue the discussion on the Felspar web page.",
4796
+ change_request_closed: "This change request is already closed.",
4797
+ change_request_close_on_web_page: "Withdraw or reject a change request on the Felspar web page; opening the job's change request again replaces your earlier one.",
4798
+ proposal_draft_invalid: "A proposal's draft must be a valid felspar.pack-draft for the proposal's own job. Propose with propose_pack, which keeps the draft it checked.",
4799
+ preview_too_large: "This draft changes more than one preview can show (2,048 item changes or 64 breaking changes). Preview a smaller revision, or split the pack.",
4800
+ preview_reinterpret_blocked: "Fix the draft's blocking findings (check_pack lists them) before previewing with reinterpret: true. A preview without reinterpret still runs.",
4801
+ pack_job_mismatch: "That release or proposal belongs to another job. Pass the jobId list_jobs shows with it.",
4572
4802
  decision_not_found: "Check the output against a decision this caller made: send the executionId from your get_job_decision result for this job.",
4573
4803
  decision_not_decided: "This decision has no outcome, so nothing is written for it. Follow its next step instead.",
4574
4804
  no_output_checks: "This job's release declares no output checks. Use the decision's next step; nothing is checked before sending.",
4575
4805
  output_not_required: "The decided outcome does not require this output. Send one of the outputs listed in required, or none when it is empty.",
4576
4806
  output_too_large: "The text is longer than this output allows. Shorten it and check again.",
4807
+ invalid_input: "The request does not match the format. Correct each issue at its path: follow input.example from get_job_requirements (input.jsonSchema in the REST brief).",
4577
4808
  invalid_type: formatFix,
4578
4809
  invalid_union: formatFix,
4579
4810
  invalid_value: formatFix,
@@ -4582,231 +4813,252 @@ var fixes = {
4582
4813
  too_big: formatFix,
4583
4814
  too_small: formatFix
4584
4815
  };
4816
+ var hostedRefusalCodes = Object.freeze(Object.keys(fixes));
4585
4817
  function hostedRefusalFix(code) {
4586
4818
  return Object.hasOwn(fixes, code) ? fixes[code] ?? null : null;
4587
4819
  }
4820
+ var retried = /* @__PURE__ */ new Set(["rate_limited", "history_unavailable", "operation_unavailable"]);
4821
+ var escalated = /* @__PURE__ */ new Set([
4822
+ "unauthenticated",
4823
+ "forbidden",
4824
+ "access_denied",
4825
+ "job_retired",
4826
+ "attempt_limit_reached",
4827
+ "source_access_required",
4828
+ "source_read_failed",
4829
+ "no_current_release"
4830
+ ]);
4831
+ function hostedRefusalRecovery(code) {
4832
+ if (!Object.hasOwn(fixes, code)) {
4833
+ return null;
4834
+ }
4835
+ if (retried.has(code)) {
4836
+ return "retry";
4837
+ }
4838
+ return escalated.has(code) ? "escalate" : "fix_input";
4839
+ }
4588
4840
 
4589
4841
  // ../schemas/src/draft-hosted-job-description.ts
4590
- import { z as z52 } from "zod";
4842
+ import { z as z55 } from "zod";
4591
4843
 
4592
4844
  // ../schemas/src/draft-hosted-output-guides.ts
4593
- import { z as z51 } from "zod";
4594
- var id7 = z51.string().min(1).max(200);
4595
- var located = z51.strictObject({
4596
- text: z51.string().min(1).max(262144),
4597
- locator: z51.string().min(1).max(4096)
4845
+ import { z as z54 } from "zod";
4846
+ var id8 = z54.string().min(1).max(200);
4847
+ var located = z54.strictObject({
4848
+ text: z54.string().min(1).max(262144),
4849
+ locator: z54.string().min(1).max(4096)
4598
4850
  });
4599
4851
  var hostedOutputGuideLimits = { maxOutputs: 8, maxContext: 8, maxChecks: 64 };
4600
- var HostedOutputGuideSchema = z51.strictObject({
4601
- id: id7,
4852
+ var HostedOutputGuideSchema = z54.strictObject({
4853
+ id: id8,
4602
4854
  what: located,
4603
- maxCharacters: z51.number().int().min(1),
4604
- context: z51.array(located.extend({ id: id7 })).max(hostedOutputGuideLimits.maxContext).optional(),
4605
- checks: z51.array(z51.strictObject({
4606
- check: id7,
4607
- rule: z51.string().nullable(),
4608
- must: z51.string().min(1).max(8e3)
4855
+ maxCharacters: z54.number().int().min(1),
4856
+ context: z54.array(located.extend({ id: id8 })).max(hostedOutputGuideLimits.maxContext).optional(),
4857
+ checks: z54.array(z54.strictObject({
4858
+ check: id8,
4859
+ rule: z54.string().nullable(),
4860
+ must: z54.string().min(1).max(8e3)
4609
4861
  })).max(hostedOutputGuideLimits.maxChecks)
4610
4862
  });
4611
- var HostedOutputGuidesSchema = z51.array(HostedOutputGuideSchema).max(hostedOutputGuideLimits.maxOutputs);
4863
+ var HostedOutputGuidesSchema = z54.array(HostedOutputGuideSchema).max(hostedOutputGuideLimits.maxOutputs);
4612
4864
 
4613
4865
  // ../schemas/src/draft-hosted-job-description.ts
4614
- var id8 = z52.string().min(1).max(200);
4866
+ var id9 = z55.string().min(1).max(200);
4615
4867
  var digest24 = DraftApplicationReleaseSchema.shape.releaseDigest;
4616
4868
  var { requirements, rules } = DraftRequiredProposalSchema.shape;
4617
- var quotedText = z52.strictObject({
4618
- text: z52.string().min(1).max(262144),
4869
+ var quotedText = z55.strictObject({
4870
+ text: z55.string().min(1).max(262144),
4619
4871
  source: DraftSourceReferenceSchema.omit({ contentDigest: true }).extend({
4620
- locator: z52.string().min(1).max(4096),
4872
+ locator: z55.string().min(1).max(4096),
4621
4873
  contentDigest: digest24
4622
4874
  }),
4623
- parts: z52.array(z52.strictObject({ locator: z52.string().min(1).max(4096), text: z52.string() })).max(16)
4875
+ parts: z55.array(z55.strictObject({ locator: z55.string().min(1).max(4096), text: z55.string() })).max(16)
4624
4876
  });
4625
4877
  var subjectShape = {
4626
- identifier: z52.string().min(1).max(200),
4627
- example: z52.string().min(1).max(200),
4628
- match: z52.enum(subjectMatchRules)
4878
+ identifier: z55.string().min(1).max(200),
4879
+ example: z55.string().min(1).max(200),
4880
+ match: z55.enum(subjectMatchRules)
4629
4881
  };
4630
- var HostedJobSubjectSchema = z52.strictObject({
4631
- type: id8,
4882
+ var HostedJobSubjectSchema = z55.strictObject({
4883
+ type: id9,
4632
4884
  definition: quotedText,
4633
4885
  identifier: subjectShape.identifier.optional(),
4634
4886
  example: subjectShape.example.optional(),
4635
4887
  match: subjectShape.match,
4636
- related: z52.array(z52.strictObject({
4637
- relationship: id8,
4888
+ related: z55.array(z55.strictObject({
4889
+ relationship: id9,
4638
4890
  meaning: quotedText,
4639
- cardinality: z52.enum(relationshipCardinalities),
4640
- required: z52.boolean(),
4641
- subject: id8,
4891
+ cardinality: z55.enum(relationshipCardinalities),
4892
+ required: z55.boolean(),
4893
+ subject: id9,
4642
4894
  definition: quotedText,
4643
4895
  ...subjectShape
4644
4896
  })).max(16),
4645
- send: z52.string().min(1).max(2e4)
4897
+ send: z55.string().min(1).max(2e4)
4646
4898
  });
4647
- var HostedJobEscalationsSchema = z52.strictObject({
4648
- routes: z52.array(z52.strictObject({ id: id8, quote: quotedText })).min(1).max(16),
4649
- unresolved: id8.nullable(),
4650
- attemptLimit: id8.nullable(),
4651
- rule: z52.string().min(1).max(1e3)
4899
+ var HostedJobEscalationsSchema = z55.strictObject({
4900
+ routes: z55.array(z55.strictObject({ id: id9, quote: quotedText })).min(1).max(16),
4901
+ unresolved: id9.nullable(),
4902
+ attemptLimit: id9.nullable(),
4903
+ rule: z55.string().min(1).max(1e3)
4652
4904
  });
4653
- var HostedEscalationSchema = z52.strictObject({
4654
- id: id8,
4655
- trigger: z52.enum(escalationTriggers),
4905
+ var HostedEscalationSchema = z55.strictObject({
4906
+ id: id9,
4907
+ trigger: z55.enum(escalationTriggers),
4656
4908
  why: quotedText
4657
4909
  });
4658
- var HostedJobDescriptionSchema = z52.strictObject({
4659
- schema: z52.literal("felspar.hosted-job-description.draft/v0"),
4660
- job: id8,
4910
+ var HostedJobDescriptionSchema = z55.strictObject({
4911
+ schema: z55.literal("felspar.hosted-job-description.draft/v0"),
4912
+ job: id9,
4661
4913
  purpose: quotedText.optional(),
4662
- useWhen: z52.array(quotedText).max(8).optional(),
4663
- notFor: z52.array(quotedText).max(8).optional(),
4914
+ useWhen: z55.array(quotedText).max(8).optional(),
4915
+ notFor: z55.array(quotedText).max(8).optional(),
4664
4916
  owner: quotedText.optional(),
4665
4917
  subject: HostedJobSubjectSchema.optional(),
4666
- identity: z52.strictObject({
4667
- mode: z52.enum(identityModes),
4668
- send: z52.string().min(1).max(4e3),
4669
- fields: z52.array(z52.strictObject({ name: id8, ...subjectShape })).max(8).optional(),
4670
- question: id8.optional()
4918
+ identity: z55.strictObject({
4919
+ mode: z55.enum(identityModes),
4920
+ send: z55.string().min(1).max(4e3),
4921
+ fields: z55.array(z55.strictObject({ name: id9, ...subjectShape })).max(8).optional(),
4922
+ question: id9.optional()
4671
4923
  }).optional(),
4672
- trustDomain: id8,
4673
- release: z52.strictObject({
4674
- releaseId: id8,
4924
+ trustDomain: id9,
4925
+ release: z55.strictObject({
4926
+ releaseId: id9,
4675
4927
  releaseDigest: digest24,
4676
4928
  materialDigest: digest24,
4677
4929
  expectedAuthorityDigest: digest24
4678
4930
  }),
4679
4931
  resolutionPolicy: DraftRequiredProposalSchema.shape.resolutionPolicy,
4680
- questions: z52.array(requirements.element.extend({
4681
- key: id8,
4682
- type: z52.enum(["enum", "boolean", "number", "date"]),
4932
+ questions: z55.array(requirements.element.extend({
4933
+ key: id9,
4934
+ type: z55.enum(["enum", "boolean", "number", "date"]),
4683
4935
  meaning: quotedText,
4684
- answer: z52.strictObject({
4685
- send: z52.enum(["text", "text_or_value"]),
4686
- valueFormat: z52.enum(["number", "calendar-date"]).nullable(),
4687
- interpretation: z52.enum(["classified", "exact_read", "unsupported"]),
4688
- threshold: z52.number().gt(0).max(1).nullable(),
4689
- applies: z52.enum(["always", "conditional"]),
4690
- dependsOn: z52.array(id8).max(32),
4691
- appliesWhen: z52.string().min(1).max(2e3).nullable(),
4936
+ answer: z55.strictObject({
4937
+ send: z55.enum(["text", "text_or_value"]),
4938
+ valueFormat: z55.enum(["number", "calendar-date"]).nullable(),
4939
+ interpretation: z55.enum(["classified", "exact_read", "unsupported"]),
4940
+ threshold: z55.number().gt(0).max(1).nullable(),
4941
+ applies: z55.enum(["always", "conditional"]),
4942
+ dependsOn: z55.array(id9).max(32),
4943
+ appliesWhen: z55.string().min(1).max(2e3).nullable(),
4692
4944
  reading: ExactReaderSchema.optional()
4693
4945
  }),
4694
- answers: z52.array(z52.strictObject({
4695
- value: id8,
4696
- meaning: z52.string().nullable(),
4697
- inclusions: z52.array(z52.string()).max(8),
4698
- exclusions: z52.array(z52.string()).max(8),
4699
- examples: z52.array(z52.string()).max(8),
4700
- edgeCases: z52.array(z52.string()).max(8)
4946
+ answers: z55.array(z55.strictObject({
4947
+ value: id9,
4948
+ meaning: z55.string().nullable(),
4949
+ inclusions: z55.array(z55.string()).max(8),
4950
+ exclusions: z55.array(z55.string()).max(8),
4951
+ examples: z55.array(z55.string()).max(8),
4952
+ edgeCases: z55.array(z55.string()).max(8)
4701
4953
  })).max(64).optional(),
4702
- whereToLook: z52.array(quotedText).max(8).optional(),
4703
- about: z52.strictObject({ relationship: id8, subject: id8 }).optional()
4954
+ whereToLook: z55.array(quotedText).max(8).optional(),
4955
+ about: z55.strictObject({ relationship: id9, subject: id9 }).optional()
4704
4956
  })).max(64),
4705
- rules: z52.array(rules.element.extend({ text: quotedText })).max(256),
4706
- outcomes: z52.array(z52.strictObject({
4707
- id: id8,
4957
+ rules: z55.array(rules.element.extend({ text: quotedText })).max(256),
4958
+ outcomes: z55.array(z55.strictObject({
4959
+ id: id9,
4708
4960
  meaning: quotedText.nullable(),
4709
4961
  nextStep: quotedText.nullable().optional(),
4710
4962
  outputs: HostedOutputGuidesSchema.optional(),
4711
- escalate: id8.optional()
4963
+ escalate: id9.optional()
4712
4964
  })).max(64),
4713
4965
  escalations: HostedJobEscalationsSchema.optional(),
4714
4966
  whenUnresolved: quotedText.nullable().optional(),
4715
- attempts: z52.strictObject({
4716
- max: z52.number().int().min(1).max(10),
4717
- withProgress: z52.number().int().min(1).max(10),
4718
- rule: z52.string().min(1).max(1e3)
4967
+ attempts: z55.strictObject({
4968
+ max: z55.number().int().min(1).max(10),
4969
+ withProgress: z55.number().int().min(1).max(10),
4970
+ rule: z55.string().min(1).max(1e3)
4719
4971
  }).optional(),
4720
- guidance: z52.strictObject({ gather: z52.string().min(1).max(2e3) }),
4721
- input: z52.strictObject({
4722
- jsonSchema: z52.record(z52.string(), z52.unknown()),
4972
+ guidance: z55.strictObject({ gather: z55.string().min(1).max(2e3) }),
4973
+ input: z55.strictObject({
4974
+ jsonSchema: z55.record(z55.string(), z55.unknown()),
4723
4975
  example: HostedFactsJobInputSchema.nullable(),
4724
- exampleNote: z52.string().max(1e3)
4976
+ exampleNote: z55.string().max(1e3)
4725
4977
  }),
4726
- limits: z52.strictObject({
4727
- maxEvidenceItems: z52.number().int().positive(),
4728
- maxPassages: z52.number().int().positive(),
4729
- facts: z52.strictObject({
4730
- maxExcerptCharacters: z52.literal(hostedFactsLimits.maxExcerptCharacters),
4731
- maxExcerptsPerQuestion: z52.literal(hostedFactsLimits.maxExcerptsPerQuestion),
4732
- maxFactsBytes: z52.literal(hostedFactsLimits.maxFactsBytes),
4733
- maxQuestions: z52.literal(hostedFactsLimits.maxQuestions)
4978
+ limits: z55.strictObject({
4979
+ maxEvidenceItems: z55.number().int().positive(),
4980
+ maxPassages: z55.number().int().positive(),
4981
+ facts: z55.strictObject({
4982
+ maxExcerptCharacters: z55.literal(hostedFactsLimits.maxExcerptCharacters),
4983
+ maxExcerptsPerQuestion: z55.literal(hostedFactsLimits.maxExcerptsPerQuestion),
4984
+ maxFactsBytes: z55.literal(hostedFactsLimits.maxFactsBytes),
4985
+ maxQuestions: z55.literal(hostedFactsLimits.maxQuestions)
4734
4986
  })
4735
4987
  })
4736
4988
  });
4737
- var interpretedExcerpt = z52.strictObject({
4738
- id: id8,
4739
- method: z52.enum(["value", "exact_read", "classified"]),
4740
- status: z52.enum(["accepted", "needs_evidence", "not_needed"]),
4741
- value: z52.union([z52.string(), z52.number(), z52.boolean()]).optional(),
4742
- reasons: z52.array(z52.string()),
4743
- classification: z52.strictObject({
4744
- candidate: z52.string().nullable(),
4745
- probability: z52.number().min(0).max(1).nullable(),
4746
- abstention: z52.number().min(0).max(1).nullable(),
4747
- threshold: z52.number().min(0).max(1),
4748
- alternatives: z52.array(z52.strictObject({ value: z52.string(), probability: z52.number() }))
4989
+ var interpretedExcerpt = z55.strictObject({
4990
+ id: id9,
4991
+ method: z55.enum(["value", "exact_read", "classified"]),
4992
+ status: z55.enum(["accepted", "needs_evidence", "not_needed"]),
4993
+ value: z55.union([z55.string(), z55.number(), z55.boolean()]).optional(),
4994
+ reasons: z55.array(z55.string()),
4995
+ classification: z55.strictObject({
4996
+ candidate: z55.string().nullable(),
4997
+ probability: z55.number().min(0).max(1).nullable(),
4998
+ abstention: z55.number().min(0).max(1).nullable(),
4999
+ threshold: z55.number().min(0).max(1),
5000
+ alternatives: z55.array(z55.strictObject({ value: z55.string(), probability: z55.number() }))
4749
5001
  }).optional()
4750
5002
  });
4751
- var ruleSummary = z52.strictObject({ id: id8, outcome: id8, text: quotedText });
4752
- var HostedJobExplanationSchema = z52.strictObject({
4753
- schema: z52.literal("felspar.hosted-job-explanation.draft/v0"),
4754
- decision: z52.strictObject({ status: z52.string().nullable(), reasons: z52.array(z52.string()) }),
4755
- needs: z52.array(z52.strictObject({
4756
- key: id8,
4757
- status: z52.string(),
4758
- reasons: z52.array(z52.string()),
4759
- acceptedSourceClasses: z52.array(z52.string()),
4760
- maxAgeMs: z52.number().int().nonnegative(),
5003
+ var ruleSummary = z55.strictObject({ id: id9, outcome: id9, text: quotedText });
5004
+ var HostedJobExplanationSchema = z55.strictObject({
5005
+ schema: z55.literal("felspar.hosted-job-explanation.draft/v0"),
5006
+ decision: z55.strictObject({ status: z55.string().nullable(), reasons: z55.array(z55.string()) }),
5007
+ needs: z55.array(z55.strictObject({
5008
+ key: id9,
5009
+ status: z55.string(),
5010
+ reasons: z55.array(z55.string()),
5011
+ acceptedSourceClasses: z55.array(z55.string()),
5012
+ maxAgeMs: z55.number().int().nonnegative(),
4761
5013
  requiredWhen: HostedJobDescriptionSchema.shape.questions.element.shape.requiredWhen,
4762
- excerpts: z52.array(interpretedExcerpt).optional()
5014
+ excerpts: z55.array(interpretedExcerpt).optional()
4763
5015
  })),
4764
- why: z52.strictObject({
4765
- rules: z52.array(ruleSummary),
4766
- overrides: z52.array(z52.strictObject({ by: id8, target: id8 })),
4767
- suppressedRuleIds: z52.array(id8),
4768
- evidence: z52.array(z52.record(z52.string(), z52.unknown()))
5016
+ why: z55.strictObject({
5017
+ rules: z55.array(ruleSummary),
5018
+ overrides: z55.array(z55.strictObject({ by: id9, target: id9 })),
5019
+ suppressedRuleIds: z55.array(id9),
5020
+ evidence: z55.array(z55.record(z55.string(), z55.unknown()))
4769
5021
  }).nullable(),
4770
- context: z52.strictObject({ status: z52.string(), reason: z52.string().nullable() }).nullable(),
4771
- reviewNeeds: z52.array(z52.string()),
4772
- evidenceFreshUntil: z52.iso.datetime().nullable()
5022
+ context: z55.strictObject({ status: z55.string(), reason: z55.string().nullable() }).nullable(),
5023
+ reviewNeeds: z55.array(z55.string()),
5024
+ evidenceFreshUntil: z55.iso.datetime().nullable()
4773
5025
  });
4774
- var HostedReceiptVerificationInputSchema = z52.strictObject({
5026
+ var HostedReceiptVerificationInputSchema = z55.strictObject({
4775
5027
  receipt: DraftJobReceiptSchema,
4776
5028
  expectedReceiptDigest: digest24,
4777
5029
  deliveredCapsule: DraftContextVerificationOptionsSchema.shape.deliveredCapsule
4778
5030
  });
4779
- var HostedReceiptVerificationSchema = z52.strictObject({
4780
- authority: z52.literal("unapproved"),
4781
- status: z52.enum(["reproduced", "mismatch"]),
4782
- mismatches: z52.array(z52.string()),
4783
- decided: z52.strictObject({
4784
- jobId: id8,
4785
- entityId: id8,
4786
- releaseId: id8,
4787
- outcome: id8.nullable(),
4788
- case: z52.strictObject({ id: id8, mode: z52.enum(identityModes) }).optional(),
4789
- subject: z52.strictObject({
4790
- type: id8,
4791
- related: z52.array(z52.strictObject({ relationship: id8, subject: id8, id: id8, questions: z52.array(id8).max(64) })).max(256)
5031
+ var HostedReceiptVerificationSchema = z55.strictObject({
5032
+ authority: z55.literal("unapproved"),
5033
+ status: z55.enum(["reproduced", "mismatch"]),
5034
+ mismatches: z55.array(z55.string()),
5035
+ decided: z55.strictObject({
5036
+ jobId: id9,
5037
+ entityId: id9,
5038
+ releaseId: id9,
5039
+ outcome: id9.nullable(),
5040
+ case: z55.strictObject({ id: id9, mode: z55.enum(identityModes) }).optional(),
5041
+ subject: z55.strictObject({
5042
+ type: id9,
5043
+ related: z55.array(z55.strictObject({ relationship: id9, subject: id9, id: id9, questions: z55.array(id9).max(64) })).max(256)
4792
5044
  }).optional(),
4793
5045
  escalation: HostedEscalationSchema.omit({ why: true }).optional()
4794
5046
  }).optional()
4795
5047
  });
4796
5048
 
4797
5049
  // ../schemas/src/draft-hosted-output-check-record.ts
4798
- import { z as z55 } from "zod";
5050
+ import { z as z58 } from "zod";
4799
5051
 
4800
5052
  // ../schemas/src/draft-artifact-lint.ts
4801
- import { z as z54 } from "zod";
5053
+ import { z as z57 } from "zod";
4802
5054
 
4803
5055
  // ../schemas/src/draft-job-obligations.ts
4804
- import { z as z53 } from "zod";
4805
- var id9 = DraftApplicationScopeSchema.shape.authorityId;
5056
+ import { z as z56 } from "zod";
5057
+ var id10 = DraftApplicationScopeSchema.shape.authorityId;
4806
5058
  var digest25 = DraftJobReceiptSchema.shape.receiptDigest;
4807
5059
  var outcome2 = DraftJobObligationsOutcomeSchema;
4808
5060
  var DraftApplicationJobMaterialV3Schema = DraftApplicationJobMaterialV2Schema.extend({
4809
- schema: z53.literal("felspar.application-job-material.draft/v3"),
5061
+ schema: z56.literal("felspar.application-job-material.draft/v3"),
4810
5062
  obligations: DraftJobObligationsSchema
4811
5063
  }).superRefine((value, context3) => {
4812
5064
  if (context3.issues.length > 0) {
@@ -4834,57 +5086,57 @@ var DraftApplicationJobMaterialV3Schema = DraftApplicationJobMaterialV2Schema.ex
4834
5086
  }
4835
5087
  });
4836
5088
  var HostedProposalInputV3Schema = HostedProposalInputV2Schema.extend({
4837
- schema: z53.literal("felspar.hosted-proposal.draft/v3"),
5089
+ schema: z56.literal("felspar.hosted-proposal.draft/v3"),
4838
5090
  material: DraftApplicationJobMaterialV3Schema
4839
5091
  });
4840
5092
  var jobObligationsReplayRoutes = ["supplied", "evaluated"];
4841
5093
  var replayRoutes = new Set(jobObligationsReplayRoutes);
4842
5094
  var DraftJobObligationsExecutionSchema = DraftAnyJobExecutionSchema.refine((execution) => replayRoutes.has(execution.invocation.route), "Obligations assessments support supplied and evaluated native executions");
4843
- var DraftJobObligationsNativeResultSchema = z53.strictObject({
4844
- authority: z53.literal("unapproved"),
4845
- discovery: z53.record(z53.string(), z53.unknown()),
4846
- executed: z53.record(z53.string(), z53.unknown()),
5095
+ var DraftJobObligationsNativeResultSchema = z56.strictObject({
5096
+ authority: z56.literal("unapproved"),
5097
+ discovery: z56.record(z56.string(), z56.unknown()),
5098
+ executed: z56.record(z56.string(), z56.unknown()),
4847
5099
  receipt: DraftJobReceiptSchema
4848
5100
  });
4849
- var DraftJobObligationsInputSchema = z53.strictObject({
5101
+ var DraftJobObligationsInputSchema = z56.strictObject({
4850
5102
  release: DraftApplicationReleaseSchema,
4851
- material: z53.union([DraftApplicationJobMaterialV3Schema, DraftAnyApplicationJobMaterialSchema]),
5103
+ material: z56.union([DraftApplicationJobMaterialV3Schema, DraftAnyApplicationJobMaterialSchema]),
4852
5104
  execution: DraftJobObligationsExecutionSchema,
4853
5105
  expectedReceiptDigest: digest25,
4854
5106
  job: DraftJobObligationsNativeResultSchema,
4855
5107
  explanation: HostedJobExplanationSchema,
4856
- invocation: DraftJobObligationsScopeSchema.extend({ caseId: id9 })
5108
+ invocation: DraftJobObligationsScopeSchema.extend({ caseId: id10 })
4857
5109
  });
4858
- var requirements2 = z53.strictObject({
4859
- status: z53.enum(["established", "unresolved"]),
5110
+ var requirements2 = z56.strictObject({
5111
+ status: z56.enum(["established", "unresolved"]),
4860
5112
  scope: DraftJobObligationsScopeSchema,
4861
5113
  artifacts: outcome2.shape.artifacts,
4862
5114
  approvals: outcome2.shape.approvals,
4863
- unresolved: z53.array(z53.strictObject({ scopeRef: id9, reasonCodes: z53.array(id9).min(1).max(64) })).max(64)
5115
+ unresolved: z56.array(z56.strictObject({ scopeRef: id10, reasonCodes: z56.array(id10).min(1).max(64) })).max(64)
4864
5116
  });
4865
- var nextReference = z53.discriminatedUnion("kind", [
4866
- z53.strictObject({ kind: z53.literal("evidence_need"), id: id9 }),
4867
- z53.strictObject({ kind: z53.literal("artifact_requirement"), id: id9 }),
4868
- z53.strictObject({ kind: z53.literal("approval_requirement"), id: id9 }),
4869
- z53.strictObject({ kind: z53.literal("unresolved_scope"), scopeRef: id9 })
5117
+ var nextReference = z56.discriminatedUnion("kind", [
5118
+ z56.strictObject({ kind: z56.literal("evidence_need"), id: id10 }),
5119
+ z56.strictObject({ kind: z56.literal("artifact_requirement"), id: id10 }),
5120
+ z56.strictObject({ kind: z56.literal("approval_requirement"), id: id10 }),
5121
+ z56.strictObject({ kind: z56.literal("unresolved_scope"), scopeRef: id10 })
4870
5122
  ]);
4871
- var DraftJobObligationsAssessmentBodySchema = z53.strictObject({
4872
- schema: z53.literal("felspar.job-obligations-assessment.draft/v0"),
4873
- binding: z53.strictObject({
5123
+ var DraftJobObligationsAssessmentBodySchema = z56.strictObject({
5124
+ schema: z56.literal("felspar.job-obligations-assessment.draft/v0"),
5125
+ binding: z56.strictObject({
4874
5126
  releaseDigest: digest25,
4875
5127
  materialDigest: digest25,
4876
5128
  nativeReceiptDigest: digest25,
4877
- jobId: id9,
5129
+ jobId: id10,
4878
5130
  applicationScope: DraftApplicationScopeSchema,
4879
- caseId: id9,
4880
- entityId: id9,
4881
- evaluationTime: z53.iso.datetime({ offset: true }),
4882
- purposeRef: id9,
4883
- useRef: id9.nullable()
5131
+ caseId: id10,
5132
+ entityId: id10,
5133
+ evaluationTime: z56.iso.datetime({ offset: true }),
5134
+ purposeRef: id10,
5135
+ useRef: id10.nullable()
4884
5136
  }),
4885
5137
  requirements: requirements2,
4886
- next: z53.strictObject({
4887
- kind: z53.enum([
5138
+ next: z56.strictObject({
5139
+ kind: z56.enum([
4888
5140
  "stop",
4889
5141
  "review_required",
4890
5142
  "gather_evidence",
@@ -4892,8 +5144,8 @@ var DraftJobObligationsAssessmentBodySchema = z53.strictObject({
4892
5144
  "verify_before_action",
4893
5145
  "return_result"
4894
5146
  ]),
4895
- reasonCodes: z53.array(id9).max(64),
4896
- refs: z53.array(nextReference).max(64)
5147
+ reasonCodes: z56.array(id10).max(64),
5148
+ refs: z56.array(nextReference).max(64)
4897
5149
  })
4898
5150
  });
4899
5151
  function isNextRefDeclared(ref, required) {
@@ -4930,48 +5182,48 @@ var DraftJobObligationsAssessmentSchema = DraftJobObligationsAssessmentBodySchem
4930
5182
  });
4931
5183
 
4932
5184
  // ../schemas/src/draft-artifact-lint.ts
4933
- var id10 = DraftApplicationScopeSchema.shape.authorityId;
5185
+ var id11 = DraftApplicationScopeSchema.shape.authorityId;
4934
5186
  var digest26 = DraftJobReceiptSchema.shape.receiptDigest;
4935
5187
  var passage3 = ArtifactSpecificationSchema;
4936
- var plainArtifact = z54.strictObject({
4937
- id: id10,
4938
- revision: id10,
4939
- mediaType: z54.literal("text/plain"),
4940
- exportProfile: id10.nullable(),
4941
- content: z54.string().max(artifactLintLimits.maxTotalBytes),
5188
+ var plainArtifact = z57.strictObject({
5189
+ id: id11,
5190
+ revision: id11,
5191
+ mediaType: z57.literal("text/plain"),
5192
+ exportProfile: id11.nullable(),
5193
+ content: z57.string().max(artifactLintLimits.maxTotalBytes),
4942
5194
  expectedContentDigest: digest26
4943
5195
  });
4944
- var structuredArtifact = z54.strictObject({
4945
- id: id10,
4946
- revision: id10,
4947
- mediaType: z54.literal("application/vnd.felspar.structured-output+json"),
4948
- exportProfile: id10.nullable(),
5196
+ var structuredArtifact = z57.strictObject({
5197
+ id: id11,
5198
+ revision: id11,
5199
+ mediaType: z57.literal("application/vnd.felspar.structured-output+json"),
5200
+ exportProfile: id11.nullable(),
4949
5201
  content: DraftStructuredOutputSchema,
4950
5202
  expectedContentDigest: digest26
4951
5203
  });
4952
- var ArtifactLintArtifactSchema = z54.discriminatedUnion("mediaType", [
5204
+ var ArtifactLintArtifactSchema = z57.discriminatedUnion("mediaType", [
4953
5205
  plainArtifact,
4954
5206
  structuredArtifact
4955
5207
  ]);
4956
- var ArtifactLintDecisionSchema = z54.strictObject({
5208
+ var ArtifactLintDecisionSchema = z57.strictObject({
4957
5209
  inputs: DraftJobObligationsInputSchema,
4958
5210
  assessment: DraftJobObligationsAssessmentSchema,
4959
5211
  expectedAssessmentDigest: digest26
4960
5212
  });
4961
- var ArtifactLintInputSchema = z54.strictObject({
4962
- schema: z54.literal("felspar.lint.draft/v1"),
4963
- requestId: id10,
5213
+ var ArtifactLintInputSchema = z57.strictObject({
5214
+ schema: z57.literal("felspar.lint.draft/v1"),
5215
+ requestId: id11,
4964
5216
  release: DraftApplicationReleaseSchema,
4965
5217
  material: DraftApplicationJobMaterialV3Schema,
4966
5218
  manifest: ArtifactCheckManifestSchema,
4967
5219
  expectedManifestDigest: digest26,
4968
- attachedObligations: z54.strictObject({ expectedObligationsDigest: digest26 }).optional(),
4969
- attachedCase: z54.strictObject({
5220
+ attachedObligations: z57.strictObject({ expectedObligationsDigest: digest26 }).optional(),
5221
+ attachedCase: z57.strictObject({
4970
5222
  decisionReceiptDigest: digest26,
4971
- answers: z54.array(z54.strictObject({ key: id10, value: z54.union([z54.string().min(1).max(200), z54.null()]) })).max(256)
5223
+ answers: z57.array(z57.strictObject({ key: id11, value: z57.union([z57.string().min(1).max(200), z57.null()]) })).max(256)
4972
5224
  }).optional(),
4973
- case: z54.strictObject({ caseId: id10, purposeRef: id10, useRef: id10.nullable() }),
4974
- artifactRequirementId: id10.nullable(),
5225
+ case: z57.strictObject({ caseId: id11, purposeRef: id11, useRef: id11.nullable() }),
5226
+ artifactRequirementId: id11.nullable(),
4975
5227
  decision: ArtifactLintDecisionSchema.nullable(),
4976
5228
  artifact: ArtifactLintArtifactSchema
4977
5229
  });
@@ -4984,11 +5236,11 @@ var artifactCheckStatuses = [
4984
5236
  "not_applicable",
4985
5237
  "skipped"
4986
5238
  ];
4987
- var range = z54.strictObject({
4988
- sectionId: id10,
4989
- start: z54.number().int().min(0).max(artifactLintLimits.maxSectionUnits),
4990
- end: z54.number().int().min(1).max(artifactLintLimits.maxSectionUnits),
4991
- offsetUnit: z54.literal("utf16_code_units")
5239
+ var range = z57.strictObject({
5240
+ sectionId: id11,
5241
+ start: z57.number().int().min(0).max(artifactLintLimits.maxSectionUnits),
5242
+ end: z57.number().int().min(1).max(artifactLintLimits.maxSectionUnits),
5243
+ offsetUnit: z57.literal("utf16_code_units")
4992
5244
  });
4993
5245
  var findingCodes = [
4994
5246
  "section_missing",
@@ -5016,148 +5268,148 @@ var findingCodes = [
5016
5268
  "evaluation_budget_exceeded",
5017
5269
  "evaluation_skipped"
5018
5270
  ];
5019
- var ArtifactFindingSchema = z54.strictObject({
5020
- code: z54.enum(findingCodes),
5021
- checkId: id10.nullable(),
5022
- severity: z54.enum(["error", "warning"]),
5271
+ var ArtifactFindingSchema = z57.strictObject({
5272
+ code: z57.enum(findingCodes),
5273
+ checkId: id11.nullable(),
5274
+ severity: z57.enum(["error", "warning"]),
5023
5275
  specification: passage3.nullable(),
5024
5276
  location: range.nullable(),
5025
- insertionAnchor: z54.strictObject({ sectionId: id10.nullable(), at: z54.number().int().min(0) }).nullable(),
5026
- literalIndex: z54.number().int().min(0).max(artifactLintLimits.maxLiterals).nullable()
5027
- });
5028
- var ArtifactCheckObservationSchema = z54.strictObject({
5029
- checkId: id10,
5030
- kind: z54.enum(artifactCheckKinds),
5031
- required: z54.boolean(),
5032
- method: z54.enum(["deterministic", "semantic"]),
5033
- status: z54.enum(artifactCheckStatuses),
5034
- occurrences: z54.number().int().min(0),
5035
- parsedValue: z54.number().nullable(),
5036
- caseValue: z54.number().nullable()
5037
- });
5038
- var ArtifactLintRecordBodySchema = z54.strictObject({
5039
- schema: z54.literal("felspar.lint-record.draft/v1"),
5040
- requestId: id10,
5041
- status: z54.enum(["pass", "revise", "unavailable", "review_required"]),
5042
- caseContext: z54.enum(["bound", "not_required"]),
5043
- binding: z54.strictObject({
5277
+ insertionAnchor: z57.strictObject({ sectionId: id11.nullable(), at: z57.number().int().min(0) }).nullable(),
5278
+ literalIndex: z57.number().int().min(0).max(artifactLintLimits.maxLiterals).nullable()
5279
+ });
5280
+ var ArtifactCheckObservationSchema = z57.strictObject({
5281
+ checkId: id11,
5282
+ kind: z57.enum(artifactCheckKinds),
5283
+ required: z57.boolean(),
5284
+ method: z57.enum(["deterministic", "semantic"]),
5285
+ status: z57.enum(artifactCheckStatuses),
5286
+ occurrences: z57.number().int().min(0),
5287
+ parsedValue: z57.number().nullable(),
5288
+ caseValue: z57.number().nullable()
5289
+ });
5290
+ var ArtifactLintRecordBodySchema = z57.strictObject({
5291
+ schema: z57.literal("felspar.lint-record.draft/v1"),
5292
+ requestId: id11,
5293
+ status: z57.enum(["pass", "revise", "unavailable", "review_required"]),
5294
+ caseContext: z57.enum(["bound", "not_required"]),
5295
+ binding: z57.strictObject({
5044
5296
  scope: DraftApplicationScopeSchema,
5045
- releaseId: id10,
5297
+ releaseId: id11,
5046
5298
  releaseDigest: digest26,
5047
5299
  materialDigest: digest26,
5048
5300
  obligationsDigest: digest26.optional(),
5049
5301
  caseFactsDigest: digest26.optional(),
5050
- jobId: id10,
5051
- manifestId: id10,
5302
+ jobId: id11,
5303
+ manifestId: id11,
5052
5304
  manifestDigest: digest26,
5053
- contract: z54.strictObject({ id: id10, digest: digest26 }),
5054
- caseId: id10,
5055
- purposeRef: id10,
5056
- useRef: id10.nullable(),
5057
- artifactRequirementId: id10.nullable(),
5305
+ contract: z57.strictObject({ id: id11, digest: digest26 }),
5306
+ caseId: id11,
5307
+ purposeRef: id11,
5308
+ useRef: id11.nullable(),
5309
+ artifactRequirementId: id11.nullable(),
5058
5310
  decisionReceiptDigest: digest26.nullable(),
5059
5311
  obligationsAssessmentDigest: digest26.nullable()
5060
5312
  }),
5061
- artifact: z54.strictObject({
5062
- id: id10,
5063
- revision: id10,
5064
- mediaType: z54.enum(artifactLintMediaTypes),
5065
- exportProfile: id10.nullable(),
5313
+ artifact: z57.strictObject({
5314
+ id: id11,
5315
+ revision: id11,
5316
+ mediaType: z57.enum(artifactLintMediaTypes),
5317
+ exportProfile: id11.nullable(),
5066
5318
  contentDigest: digest26,
5067
- sections: z54.array(z54.strictObject({
5068
- id: id10,
5069
- units: z54.number().int().min(0),
5319
+ sections: z57.array(z57.strictObject({
5320
+ id: id11,
5321
+ units: z57.number().int().min(0),
5070
5322
  contentDigest: digest26.nullable()
5071
5323
  })).max(artifactLintLimits.maxSections)
5072
5324
  }),
5073
- checks: z54.array(ArtifactCheckObservationSchema).max(artifactLintLimits.maxChecks),
5074
- findings: z54.array(ArtifactFindingSchema).max(2048),
5325
+ checks: z57.array(ArtifactCheckObservationSchema).max(artifactLintLimits.maxChecks),
5326
+ findings: z57.array(ArtifactFindingSchema).max(2048),
5075
5327
  semantic: ArtifactSemanticRecordSchema.nullable(),
5076
- coverage: z54.strictObject({
5077
- scope: z54.literal("declared_checks_only"),
5078
- declared: z54.number().int().min(0),
5079
- applicable: z54.number().int().min(0),
5080
- completed: z54.number().int().min(0),
5081
- required: z54.number().int().min(0),
5082
- requiredCompleted: z54.number().int().min(0),
5083
- textAssigned: z54.enum(["complete", "incomplete"]),
5084
- semantic: z54.enum(["not_declared", "complete", "incomplete"]),
5085
- nativeDocumentLayout: z54.literal("not_checked")
5328
+ coverage: z57.strictObject({
5329
+ scope: z57.literal("declared_checks_only"),
5330
+ declared: z57.number().int().min(0),
5331
+ applicable: z57.number().int().min(0),
5332
+ completed: z57.number().int().min(0),
5333
+ required: z57.number().int().min(0),
5334
+ requiredCompleted: z57.number().int().min(0),
5335
+ textAssigned: z57.enum(["complete", "incomplete"]),
5336
+ semantic: z57.enum(["not_declared", "complete", "incomplete"]),
5337
+ nativeDocumentLayout: z57.literal("not_checked")
5086
5338
  }),
5087
- actionAuthorized: z54.literal(false)
5339
+ actionAuthorized: z57.literal(false)
5088
5340
  });
5089
5341
  var ArtifactLintRecordSchema = ArtifactLintRecordBodySchema.extend({
5090
5342
  recordDigest: digest26
5091
5343
  });
5092
- var ArtifactLintReceiptSchema = z54.strictObject({
5093
- schema: z54.literal("felspar.lint-receipt.draft/v1"),
5344
+ var ArtifactLintReceiptSchema = z57.strictObject({
5345
+ schema: z57.literal("felspar.lint-receipt.draft/v1"),
5094
5346
  recordDigest: digest26,
5095
5347
  releaseDigest: digest26,
5096
5348
  manifestDigest: digest26,
5097
5349
  contractDigest: digest26,
5098
- caseId: id10,
5099
- caseContext: z54.enum(["bound", "not_required"]),
5350
+ caseId: id11,
5351
+ caseContext: z57.enum(["bound", "not_required"]),
5100
5352
  decisionReceiptDigest: digest26.nullable(),
5101
5353
  obligationsAssessmentDigest: digest26.nullable(),
5102
- artifactId: id10,
5103
- artifactRevision: id10,
5354
+ artifactId: id11,
5355
+ artifactRevision: id11,
5104
5356
  artifactDigest: digest26,
5105
- actionAuthorized: z54.literal(false),
5357
+ actionAuthorized: z57.literal(false),
5106
5358
  receiptDigest: digest26
5107
5359
  });
5108
5360
 
5109
5361
  // ../schemas/src/draft-hosted-output-check-record.ts
5110
- var id11 = DraftApplicationScopeSchema.shape.authorityId;
5362
+ var id12 = DraftApplicationScopeSchema.shape.authorityId;
5111
5363
  var digest27 = DraftJobReceiptSchema.shape.receiptDigest;
5112
- var HostedOutputCheckInputSchema = z55.strictObject({
5113
- executionId: id11,
5114
- output: id11.optional(),
5115
- text: z55.string().min(1).max(artifactLintLimits.maxTotalBytes).refine(isWellFormedText, "text_not_well_formed"),
5116
- revision: id11.optional()
5117
- });
5118
- var HostedOutputCheckRecordSchema = z55.strictObject({
5119
- schema: z55.literal("felspar.hosted-output-check/v0"),
5120
- checkId: id11,
5121
- jobId: id11,
5122
- output: id11,
5123
- decision: z55.strictObject({ executionId: id11, outcome: id11, receiptDigest: digest27 }),
5124
- release: z55.strictObject({ releaseId: id11, releaseDigest: digest27 }),
5364
+ var HostedOutputCheckInputSchema = z58.strictObject({
5365
+ executionId: id12,
5366
+ output: id12.optional(),
5367
+ text: z58.string().min(1).max(artifactLintLimits.maxTotalBytes).refine(isWellFormedText, "text_not_well_formed"),
5368
+ revision: id12.optional()
5369
+ });
5370
+ var HostedOutputCheckRecordSchema = z58.strictObject({
5371
+ schema: z58.literal("felspar.hosted-output-check/v0"),
5372
+ checkId: id12,
5373
+ jobId: id12,
5374
+ output: id12,
5375
+ decision: z58.strictObject({ executionId: id12, outcome: id12, receiptDigest: digest27 }),
5376
+ release: z58.strictObject({ releaseId: id12, releaseDigest: digest27 }),
5125
5377
  record: ArtifactLintRecordSchema,
5126
5378
  receipt: ArtifactLintReceiptSchema.nullable(),
5127
- evaluation: z55.strictObject({
5128
- modelCalls: z55.number().int().min(0),
5129
- reason: z55.string().regex(/^[a-z][a-z_]{2,63}$/u).nullable()
5379
+ evaluation: z58.strictObject({
5380
+ modelCalls: z58.number().int().min(0),
5381
+ reason: z58.string().regex(/^[a-z][a-z_]{2,63}$/u).nullable()
5130
5382
  })
5131
5383
  });
5132
5384
 
5133
5385
  // src/draft-hosted-client.ts
5134
- import { z as z56 } from "zod";
5135
- var digestText = z56.string().regex(/^sha256:[a-f0-9]{64}$/u);
5136
- var HostedOutputCheckReplySchema = z56.object({
5137
- status: z56.enum(["pass", "revise", "review_required", "unavailable"]),
5138
- checkId: z56.string(),
5139
- output: z56.string(),
5140
- findings: z56.array(z56.record(z56.string(), z56.unknown())),
5141
- receipt: z56.object({ receiptDigest: digestText, artifactDigest: digestText }).loose().nullable(),
5142
- decision: z56.object({ executionId: z56.string(), receiptDigest: digestText }),
5143
- actionAuthorized: z56.literal(false)
5386
+ import { z as z59 } from "zod";
5387
+ var digestText = z59.string().regex(/^sha256:[a-f0-9]{64}$/u);
5388
+ var HostedOutputCheckReplySchema = z59.object({
5389
+ status: z59.enum(["pass", "revise", "review_required", "unavailable"]),
5390
+ checkId: z59.string(),
5391
+ output: z59.string(),
5392
+ findings: z59.array(z59.record(z59.string(), z59.unknown())),
5393
+ receipt: z59.object({ receiptDigest: digestText, artifactDigest: digestText }).loose().nullable(),
5394
+ decision: z59.object({ executionId: z59.string(), receiptDigest: digestText }),
5395
+ actionAuthorized: z59.literal(false)
5144
5396
  }).loose();
5145
- var quotedWords = z56.object({ text: z56.string() }).loose();
5146
- var FelsparCaseSchema = z56.object({ id: z56.string().min(1).max(200), mode: z56.enum(identityModes) });
5147
- var FelsparRelatedSchema = z56.object({
5148
- relationship: z56.string(),
5149
- subject: z56.string(),
5150
- id: z56.string(),
5151
- questions: z56.array(z56.string())
5152
- });
5153
- var FelsparResultSubjectSchema = z56.object({
5154
- type: z56.string(),
5155
- id: z56.string(),
5156
- related: z56.array(FelsparRelatedSchema)
5157
- });
5158
- var FelsparEscalationSchema = z56.object({
5159
- id: z56.string().min(1).max(200),
5160
- trigger: z56.enum(escalationTriggers),
5397
+ var quotedWords = z59.object({ text: z59.string() }).loose();
5398
+ var FelsparCaseSchema = z59.object({ id: z59.string().min(1).max(200), mode: z59.enum(identityModes) });
5399
+ var FelsparRelatedSchema = z59.object({
5400
+ relationship: z59.string(),
5401
+ subject: z59.string(),
5402
+ id: z59.string(),
5403
+ questions: z59.array(z59.string())
5404
+ });
5405
+ var FelsparResultSubjectSchema = z59.object({
5406
+ type: z59.string(),
5407
+ id: z59.string(),
5408
+ related: z59.array(FelsparRelatedSchema)
5409
+ });
5410
+ var FelsparEscalationSchema = z59.object({
5411
+ id: z59.string().min(1).max(200),
5412
+ trigger: z59.enum(escalationTriggers),
5161
5413
  why: quotedWords
5162
5414
  });
5163
5415
  var FelsparJobResultSchema = HostedJobResultSchema.extend({
@@ -5165,11 +5417,11 @@ var FelsparJobResultSchema = HostedJobResultSchema.extend({
5165
5417
  case: FelsparCaseSchema.optional(),
5166
5418
  subject: FelsparResultSubjectSchema.optional(),
5167
5419
  escalation: FelsparEscalationSchema.optional(),
5168
- missing: z56.array(z56.string()).optional()
5420
+ missing: z59.array(z59.string()).optional()
5169
5421
  }).nullable()
5170
5422
  });
5171
- var FelsparJobListSchema = z56.object({
5172
- jobs: z56.array(z56.object({ id: z56.string().min(1).max(200) })).max(256)
5423
+ var FelsparJobListSchema = z59.object({
5424
+ jobs: z59.array(z59.object({ id: z59.string().min(1).max(200) })).max(256)
5173
5425
  });
5174
5426
  var hostedPartsContentType = "application/x.felspar-content-parts";
5175
5427
  async function partsBody(value) {
@@ -5221,27 +5473,29 @@ ${jobId}`;
5221
5473
  return result;
5222
5474
  };
5223
5475
  }
5224
- var refusalCode = z56.string().regex(/^[a-z][a-z_]{2,63}$/u);
5225
- var fieldPath = z56.array(z56.string().max(256)).max(32);
5226
- var refusalEscalationSchema = z56.object({
5227
- id: z56.string().regex(/^[a-zA-Z0-9][a-zA-Z0-9._:/@-]{0,199}$/u),
5228
- trigger: z56.enum(escalationTriggers),
5229
- why: z56.object({ text: z56.string().max(2e4) })
5476
+ var refusalCode = z59.string().regex(/^[a-z][a-z_]{2,63}$/u);
5477
+ var fieldPath = z59.array(z59.string().max(256)).max(32);
5478
+ var refusalEscalationSchema = z59.object({
5479
+ id: z59.string().regex(/^[a-zA-Z0-9][a-zA-Z0-9._:/@-]{0,199}$/u),
5480
+ trigger: z59.enum(escalationTriggers),
5481
+ why: z59.object({ text: z59.string().max(2e4) })
5230
5482
  });
5231
- var refusalSchema = z56.object({
5483
+ var refusalSchema = z59.object({
5232
5484
  error: refusalCode,
5233
5485
  path: fieldPath.optional(),
5234
- currentReleaseDigest: z56.string().regex(/^sha256:[a-f0-9]{64}$/u).optional(),
5235
- retryAfterSeconds: z56.number().int().min(1).max(3600).optional(),
5236
- escalation: z56.unknown().optional(),
5237
- issues: z56.array(z56.object({ code: refusalCode, path: fieldPath })).max(64).optional()
5486
+ currentReleaseDigest: z59.string().regex(/^sha256:[a-f0-9]{64}$/u).optional(),
5487
+ retryAfterSeconds: z59.number().int().min(1).max(3600).optional(),
5488
+ escalation: z59.unknown().optional(),
5489
+ issues: z59.array(z59.object({ code: refusalCode, path: fieldPath })).max(64).optional()
5238
5490
  }).transform(({ escalation: named, ...value }) => {
5239
5491
  const fix = hostedRefusalFix(value.error);
5492
+ const recovery = hostedRefusalRecovery(value.error);
5240
5493
  const escalation = refusalEscalationSchema.safeParse(named).data;
5241
5494
  return {
5242
5495
  ...value,
5243
5496
  ...escalation !== void 0 && { escalation },
5244
5497
  ...fix !== null && { fix },
5498
+ ...recovery !== null && { recovery },
5245
5499
  ...value.issues && {
5246
5500
  issues: value.issues.map((issue) => {
5247
5501
  const issueFix = hostedRefusalFix(issue.code);
@@ -5262,8 +5516,8 @@ var FelsparRequestError = class extends Error {
5262
5516
  }
5263
5517
  };
5264
5518
  async function refusalOf(response) {
5265
- const text7 = await response.text();
5266
- const parsed = refusalSchema.safeParse(text7.length <= 65536 ? JSON.parse(text7) : null);
5519
+ const text8 = await response.text();
5520
+ const parsed = refusalSchema.safeParse(text8.length <= 65536 ? JSON.parse(text8) : null);
5267
5521
  return parsed.success ? parsed.data : null;
5268
5522
  }
5269
5523
  async function requestError(response) {
@@ -5295,9 +5549,10 @@ function agentCalls(call) {
5295
5549
  const objectId = HostedObjectSchema.shape.id;
5296
5550
  return {
5297
5551
  listJobs: async () => await call("/v0/jobs", FelsparJobListSchema),
5298
- resolveJob: async (id12, value) => {
5552
+ describeCurrentJob: async (job) => await call(`/v0/jobs/${encodeURIComponent(objectId.parse(job))}/brief`, HostedJobDescriptionSchema),
5553
+ resolveJob: async (id13, value) => {
5299
5554
  const input = HostedSuppliedJobInputSchema.parse(value);
5300
- const releaseId = objectId.parse(id12);
5555
+ const releaseId = objectId.parse(id13);
5301
5556
  const path3 = `/v0/releases/${encodeURIComponent(releaseId)}/jobs`;
5302
5557
  return pinnedResult(await call(path3, FelsparJobResultSchema, input), releaseId, input);
5303
5558
  }
@@ -5342,16 +5597,16 @@ function createHostedFelsparClient(configuration) {
5342
5597
  return {
5343
5598
  submitSource: async (value) => await call("/v0/sources", HostedObjectSchema, HostedSourceInputSchema.parse(value)),
5344
5599
  submitProposal: async (value) => await call("/v0/proposals", HostedObjectSchema, HostedProposalInputSchema.parse(value)),
5345
- approveProposal: async (id12, value) => await call(`/v0/proposals/${encodeURIComponent(objectId.parse(id12))}/approve`, HostedObjectSchema, HostedApprovalInputSchema.parse(value)),
5346
- releasePack: async (id12, value) => await call(`/v0/approvals/${encodeURIComponent(objectId.parse(id12))}/release`, DraftApplicationReleaseSchema, HostedReleaseInputSchema.parse(value)),
5347
- loadRelease: async (id12) => await call(`/v0/releases/${encodeURIComponent(objectId.parse(id12))}`, HostedReleaseBundleSchema),
5348
- describeJob: async (id12, job) => await describe(objectId.parse(id12), objectId.parse(job)),
5600
+ approveProposal: async (id13, value) => await call(`/v0/proposals/${encodeURIComponent(objectId.parse(id13))}/approve`, HostedObjectSchema, HostedApprovalInputSchema.parse(value)),
5601
+ releasePack: async (id13, value) => await call(`/v0/approvals/${encodeURIComponent(objectId.parse(id13))}/release`, DraftApplicationReleaseSchema, HostedReleaseInputSchema.parse(value)),
5602
+ loadRelease: async (id13) => await call(`/v0/releases/${encodeURIComponent(objectId.parse(id13))}`, HostedReleaseBundleSchema),
5603
+ describeJob: async (id13, job) => await describe(objectId.parse(id13), objectId.parse(job)),
5349
5604
  verifyReceipt: async (executionObjectId, value) => await call(`/v0/executions/${encodeURIComponent(objectId.parse(executionObjectId))}/verify`, HostedReceiptVerificationSchema, HostedReceiptVerificationInputSchema.parse(value)),
5350
5605
  ...outputCheckCalls(call),
5351
- executeJob: async (id12, value) => await call(`/v0/releases/${encodeURIComponent(objectId.parse(id12))}/jobs`, HostedJobResultSchema, HostedJobInputSchema.parse(value)),
5606
+ executeJob: async (id13, value) => await call(`/v0/releases/${encodeURIComponent(objectId.parse(id13))}/jobs`, HostedJobResultSchema, HostedJobInputSchema.parse(value)),
5352
5607
  ...agentCalls(call),
5353
- resolveFacts: async (id12, value) => {
5354
- const releaseId = objectId.parse(id12);
5608
+ resolveFacts: async (id13, value) => {
5609
+ const releaseId = objectId.parse(id13);
5355
5610
  const input = await factsRequest(value, async (jobId) => await describe(releaseId, jobId));
5356
5611
  const path3 = `/v0/releases/${encodeURIComponent(releaseId)}/jobs`;
5357
5612
  return pinnedResult(await call(path3, FelsparJobResultSchema, input), releaseId, input);