@felspar/sdk 0.2.1 → 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,
@@ -535,8 +535,14 @@ function calendarDay(value) {
535
535
  // ../schemas/src/draft-evidence-scope.ts
536
536
  import { z as z3 } from "zod";
537
537
  var identifier = z3.string().min(1).max(256).regex(/^[a-zA-Z0-9][a-zA-Z0-9._:/@-]*$/u);
538
+ var draftSourceIdLimit = 2048;
539
+ var draftSourceIdPattern = /^[a-zA-Z0-9](?:[a-zA-Z0-9\-._~:/?#[\]@!$&'()*+,;=]|%[0-9a-fA-F]{2})*$/u;
540
+ function isDraftSourceId(value) {
541
+ return value.length <= draftSourceIdLimit && draftSourceIdPattern.test(value);
542
+ }
543
+ var sourceId = z3.string().min(1).max(draftSourceIdLimit).regex(draftSourceIdPattern);
538
544
  var reference2 = z3.strictObject({
539
- sourceId: identifier,
545
+ sourceId,
540
546
  revision: identifier,
541
547
  locator: z3.string().min(1).max(4096).regex(/\S/u),
542
548
  contentDigest: z3.string().regex(/^sha256:[a-f0-9]{64}$/u)
@@ -1267,6 +1273,21 @@ function clauseIdentity(clause) {
1267
1273
  function isSameClause(left, right) {
1268
1274
  return clauseIdentity(left) === clauseIdentity(right);
1269
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
+ }
1270
1291
  function isPolicyValid(proposal, context3) {
1271
1292
  const clauses2 = [
1272
1293
  ...proposal.rules.flatMap((rule3) => rule3.when),
@@ -1324,11 +1345,11 @@ function inspectRuleGuards(proposal, context3) {
1324
1345
  for (const [index, rule3] of proposal.rules.entries()) {
1325
1346
  for (const clause of rule3.when) {
1326
1347
  const gates = isRelational ? conditionKeys(clause).flatMap((key3) => activationGuards(key3, requirements3)) : requirements3.get(clause.key)?.requiredWhen ?? [];
1327
- if (gates.some((gate) => rule3.when.every((candidate2) => !isSameClause(gate, candidate2)))) {
1348
+ if (gates.some((gate) => rule3.when.every((candidate2) => !isGuardImplied(gate, candidate2)))) {
1328
1349
  context3.addIssue({
1329
1350
  code: "custom",
1330
1351
  path: ["rules", index],
1331
- 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"
1332
1353
  });
1333
1354
  }
1334
1355
  }
@@ -1432,7 +1453,7 @@ import { z as z14 } from "zod";
1432
1453
 
1433
1454
  // ../schemas/src/draft-scoring-references.ts
1434
1455
  function hasClause(clauses2, expected2) {
1435
- return clauses2.some((clause) => JSON.stringify(clause) === JSON.stringify(expected2));
1456
+ return clauses2.some((clause) => isGuardImplied(expected2, clause));
1436
1457
  }
1437
1458
  function mayOverlap(left, right, definitions) {
1438
1459
  for (const clause of left) {
@@ -1455,7 +1476,7 @@ function clauseIssues(clause, scope2) {
1455
1476
  }
1456
1477
  for (const key3 of conditionKeys(clause)) {
1457
1478
  if (activationGuards(key3, byKey).some((guard) => !hasClause(active, guard))) {
1458
- 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");
1459
1480
  }
1460
1481
  }
1461
1482
  return issues;
@@ -1463,8 +1484,8 @@ function clauseIssues(clause, scope2) {
1463
1484
  function inspectScoringReferences(scoring, requirements3, context3) {
1464
1485
  const definitions = new Map(requirements3.map((row2) => [row2.definition.key, row2.definition]));
1465
1486
  const byKey = new Map(requirements3.map((row2) => [row2.definition.key, row2]));
1466
- for (const [index, criterion2] of scoring.criteria.entries()) {
1467
- const active = criterion2.activeWhen ?? [];
1487
+ for (const [index, criterion3] of scoring.criteria.entries()) {
1488
+ const active = criterion3.activeWhen ?? [];
1468
1489
  const fail = (message) => {
1469
1490
  context3.addIssue({ code: "custom", path: ["criteria", index], message });
1470
1491
  };
@@ -1473,15 +1494,15 @@ function inspectScoringReferences(scoring, requirements3, context3) {
1473
1494
  fail("Scoring applicability requires unconditional requirements");
1474
1495
  }
1475
1496
  }
1476
- const all = [...active, ...criterion2.cases.flatMap((item) => item.when)];
1497
+ const all = [...active, ...criterion3.cases.flatMap((item) => item.when)];
1477
1498
  for (const clause of all) {
1478
1499
  const messages = clauseIssues(clause, { active, definitions, byKey });
1479
1500
  for (const message of messages) {
1480
1501
  fail(message);
1481
1502
  }
1482
1503
  }
1483
- for (const [caseIndex, item] of criterion2.cases.entries()) {
1484
- 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))) {
1485
1506
  fail("Scoring contribution cases must be provably disjoint");
1486
1507
  }
1487
1508
  }
@@ -1513,7 +1534,7 @@ function inspectScoredPolicy(proposal, context3) {
1513
1534
  }
1514
1535
  inspectScoringReferences(scoring, proposal.requirements, context3);
1515
1536
  const ids3 = new Set(rules2.map((rule3) => rule3.id));
1516
- if (gates.some((id12) => !ids3.has(id12))) {
1537
+ if (gates.some((id13) => !ids3.has(id13))) {
1517
1538
  fail("Unknown mandatory gate rule");
1518
1539
  }
1519
1540
  if (rules2.every((rule3) => gates.includes(rule3.id))) {
@@ -1526,7 +1547,7 @@ function inspectScoredPolicy(proposal, context3) {
1526
1547
  if (isGate ? hasRange || rule3.when.length === 0 : !hasRange) {
1527
1548
  fail("Mandatory gates require fact predicates only; other rules require score ranges");
1528
1549
  }
1529
- if (rule3.overrides.some((id12) => gates.includes(id12) !== isGate)) {
1550
+ if (rule3.overrides.some((id13) => gates.includes(id13) !== isGate)) {
1530
1551
  fail("Explicit overrides cannot cross mandatory-gate and score-band classes");
1531
1552
  }
1532
1553
  const range2 = rule3.scoreRange;
@@ -1614,19 +1635,19 @@ function hasCycle(rules2) {
1614
1635
  const graph = new Map(rules2.map((item) => [item.id, item.overrides]));
1615
1636
  const visiting = /* @__PURE__ */ new Set();
1616
1637
  const visited = /* @__PURE__ */ new Set();
1617
- const hasPathCycle = (id12) => {
1618
- if (visiting.has(id12)) {
1638
+ const hasPathCycle = (id13) => {
1639
+ if (visiting.has(id13)) {
1619
1640
  return true;
1620
1641
  }
1621
- if (visited.has(id12)) {
1642
+ if (visited.has(id13)) {
1622
1643
  return false;
1623
1644
  }
1624
- visiting.add(id12);
1625
- if ((graph.get(id12) ?? []).some(hasPathCycle)) {
1645
+ visiting.add(id13);
1646
+ if ((graph.get(id13) ?? []).some(hasPathCycle)) {
1626
1647
  return true;
1627
1648
  }
1628
- visiting.delete(id12);
1629
- visited.add(id12);
1649
+ visiting.delete(id13);
1650
+ visited.add(id13);
1630
1651
  return false;
1631
1652
  };
1632
1653
  return rules2.some((item) => hasPathCycle(item.id));
@@ -1655,11 +1676,11 @@ function inspectRules(proposal, context3) {
1655
1676
  fail("Undeclared condition key or value");
1656
1677
  }
1657
1678
  }
1658
- if (item.overrides.some((id12) => id12 === item.id || !ids3.has(id12))) {
1679
+ if (item.overrides.some((id13) => id13 === item.id || !ids3.has(id13))) {
1659
1680
  fail("Unknown or self override");
1660
1681
  }
1661
- if (item.overrides.some((id12) => {
1662
- const target = byId.get(id12);
1682
+ if (item.overrides.some((id13) => {
1683
+ const target = byId.get(id13);
1663
1684
  return target !== void 0 && draftRulePriority(target) > draftRulePriority(item);
1664
1685
  })) {
1665
1686
  fail("Override points to a higher priority tier");
@@ -1832,8 +1853,8 @@ function checkExpected(candidate2, context3) {
1832
1853
  }
1833
1854
  unique2(result.observationIds, context3, ["expected", "observationIds"]);
1834
1855
  const observationIds = new Set(candidate2.observations.map((entry2) => entry2.id));
1835
- for (const [index, id12] of result.observationIds.entries()) {
1836
- requireBinding2(observationIds.has(id12), context3, {
1856
+ for (const [index, id13] of result.observationIds.entries()) {
1857
+ requireBinding2(observationIds.has(id13), context3, {
1837
1858
  path: ["expected", "observationIds", index],
1838
1859
  message: "Unknown observation"
1839
1860
  });
@@ -2125,7 +2146,7 @@ var bundleNodeLimit = 65536;
2125
2146
  function boundedDraftInput(limits2) {
2126
2147
  return z21.unknown().transform((input, context3) => {
2127
2148
  let nodes = 0;
2128
- let text7 = 0;
2149
+ let text8 = 0;
2129
2150
  const budgetError = new Error("Draft input budget exceeded or non-data input");
2130
2151
  function copy(value, depth) {
2131
2152
  nodes += 1;
@@ -2133,8 +2154,8 @@ function boundedDraftInput(limits2) {
2133
2154
  throw budgetError;
2134
2155
  }
2135
2156
  if (typeof value === "string") {
2136
- text7 += value.length;
2137
- if (value.length > limits2.stringLength || text7 > limits2.totalText) {
2157
+ text8 += value.length;
2158
+ if (value.length > limits2.stringLength || text8 > limits2.totalText) {
2138
2159
  throw budgetError;
2139
2160
  }
2140
2161
  return value;
@@ -2186,7 +2207,7 @@ function boundedDraftInput(limits2) {
2186
2207
  });
2187
2208
  }
2188
2209
  var isUnicodeText = (value) => !/[\uD800-\uDFFF]/u.test(value);
2189
- 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));
2190
2211
  var sourceText = DraftSourceReferenceSchema.omit({ contentDigest: true }).extend({
2191
2212
  text: z21.string().min(1).max(1048576).refine(isUnicodeText, "Lone Unicode surrogate"),
2192
2213
  offsetUnit: z21.literal("utf16_code_units"),
@@ -2357,7 +2378,7 @@ var DraftEvaluatorContractSchema = z24.strictObject({
2357
2378
  evaluator,
2358
2379
  calibration: z24.strictObject({ id: identifier13, version: identifier13, contentDigest: digest9 }),
2359
2380
  minimumSelectedProbability: z24.number().gt(0).max(1),
2360
- inputContextContract: z24.literal("job-entity-time/v1").optional(),
2381
+ inputContextContract: z24.enum(["job-entity-time/v1", "job-only/v2"]).optional(),
2361
2382
  probabilityContract: z24.enum([
2362
2383
  "closed-distribution-unique-maximum/v1",
2363
2384
  "closed-distribution-with-abstention/v1"
@@ -2367,6 +2388,7 @@ var judgment = z24.discriminatedUnion("status", [
2367
2388
  z24.strictObject({
2368
2389
  status: z24.literal("evaluated"),
2369
2390
  abstentionProbability: z24.number().min(0).max(1).optional(),
2391
+ promptInjectionProbability: z24.number().min(0).max(1).optional(),
2370
2392
  probabilities: z24.array(z24.strictObject({
2371
2393
  value: z24.string().min(1).max(200),
2372
2394
  probability: z24.number().min(0).max(1)
@@ -2403,11 +2425,14 @@ var DraftNormalizedEvidenceSchema = z24.strictObject({
2403
2425
  evaluatorContractDigest: digest9,
2404
2426
  evaluator,
2405
2427
  calibrationDigest: digest9,
2406
- inputScope: z24.strictObject({
2407
- job: DraftEvidenceValidationSchema.shape.job,
2408
- entityId: identifier13,
2409
- evaluationTime: DraftEvidenceValidationSchema.shape.observationChecks.shape.evaluationTime
2410
- }).optional(),
2428
+ inputScope: z24.union([
2429
+ z24.strictObject({
2430
+ job: DraftEvidenceValidationSchema.shape.job,
2431
+ entityId: identifier13,
2432
+ evaluationTime: DraftEvidenceValidationSchema.shape.observationChecks.shape.evaluationTime
2433
+ }),
2434
+ z24.strictObject({ job: DraftEvidenceValidationSchema.shape.job })
2435
+ ]).optional(),
2411
2436
  judgment
2412
2437
  })).max(64)
2413
2438
  });
@@ -2590,11 +2615,11 @@ function readObservation(input, ref) {
2590
2615
  if (ref.kind === "interpreter") {
2591
2616
  return { path: `${path3}.interpretation`, value: observation2.interpretation };
2592
2617
  }
2593
- const { sourceId, revision, locator: locator2 } = observation2.evidence;
2618
+ const { sourceId: sourceId2, revision, locator: locator2 } = observation2.evidence;
2594
2619
  return {
2595
2620
  path: ref.kind === "evidence" ? `${path3}.evidence` : path3,
2596
2621
  value: ref.kind === "evidence" ? observation2.evidence : observation2,
2597
- source: { sourceId, revision, locator: locator2 }
2622
+ source: { sourceId: sourceId2, revision, locator: locator2 }
2598
2623
  };
2599
2624
  }
2600
2625
  function readReference(input, ref) {
@@ -3013,13 +3038,13 @@ function areSubjectsValid(subjects, isIsolated) {
3013
3038
  function areEscalationsValid(escalations, context3) {
3014
3039
  const { isIsolated, outcomes } = context3;
3015
3040
  const ids3 = new Set(escalations.routes.map((row2) => row2.id));
3016
- const named = [escalations.unresolved, escalations.attemptLimit].filter((id12) => id12 !== null);
3041
+ const named = [escalations.unresolved, escalations.attemptLimit].filter((id13) => id13 !== null);
3017
3042
  return [
3018
3043
  ids3.size === escalations.routes.length,
3019
3044
  escalations.routes.every((row2) => isIsolated(row2.entryId, "routing_jobs")),
3020
3045
  hasUniqueValues(escalations.outcomes.map((row2) => row2.outcome)),
3021
3046
  escalations.outcomes.every((row2) => ids3.has(row2.escalation) && outcomes.has(row2.outcome)),
3022
- named.every((id12) => ids3.has(id12))
3047
+ named.every((id13) => ids3.has(id13))
3023
3048
  ].every(Boolean);
3024
3049
  }
3025
3050
  function isGuideValid(guide, isIsolated) {
@@ -3109,7 +3134,7 @@ var DraftContextSelectionPlanSchema = z31.strictObject({
3109
3134
  if (candidateIds.length > 64 || !hasUniqueIds(candidateIds) || !hasUniqueIds(plan.groups.map((item) => item.id)) || !hasUniqueIds(plan.entries.map((item) => item.id))) {
3110
3135
  context3.addIssue({ code: "custom", message: "Duplicate identities or too many candidates" });
3111
3136
  }
3112
- if (plan.requiredIds.some((id12) => candidateIds.includes(id12))) {
3137
+ if (plan.requiredIds.some((id13) => candidateIds.includes(id13))) {
3113
3138
  context3.addIssue({ code: "custom", message: "Global required root cannot be a candidate" });
3114
3139
  }
3115
3140
  const guidanceId = plan.unresolvedGuidanceEntryId;
@@ -3700,7 +3725,74 @@ var DraftApplicationReleaseSchema = z43.strictObject({
3700
3725
  });
3701
3726
 
3702
3727
  // ../schemas/src/draft-hosted-application.ts
3703
- import { z as z50 } from "zod";
3728
+ import { z as z53 } from "zod";
3729
+
3730
+ // ../schemas/src/draft-source-instant.ts
3731
+ var localPattern = /^(\d{4})-(\d{2})-(\d{2})[Tt](\d{2}):(\d{2})(?::(\d{2})(?:\.(\d{1,9}))?)?([^.\d].*)$/u;
3732
+ var offsetPattern = /^(?:[Zz]|([+-])(\d{2}):?(\d{2}))$/u;
3733
+ var utcYear = /^\d{4}-/u;
3734
+ var sourceInstantMaxLength = 64;
3735
+ function daysIn(year, month) {
3736
+ const date = /* @__PURE__ */ new Date(0);
3737
+ date.setUTCFullYear(year, month, 0);
3738
+ return date.getUTCDate();
3739
+ }
3740
+ function isCalendarValue(local) {
3741
+ const { year, month, day } = local;
3742
+ const isDate = month >= 1 && month <= 12 && day >= 1 && day <= daysIn(year, month);
3743
+ return isDate && local.hour <= 23 && local.minute <= 59 && local.second <= 59;
3744
+ }
3745
+ function offsetMinutes(suffix) {
3746
+ const match = offsetPattern.exec(suffix);
3747
+ if (match === null) {
3748
+ return null;
3749
+ }
3750
+ const [, sign, hours, minutes] = match;
3751
+ if (sign === void 0) {
3752
+ return 0;
3753
+ }
3754
+ const h = Number(hours);
3755
+ const m = Number(minutes);
3756
+ if (h > 23 || m > 59) {
3757
+ return null;
3758
+ }
3759
+ return (sign === "-" ? -1 : 1) * (h * 60 + m);
3760
+ }
3761
+ function utcOf(local, offset) {
3762
+ const date = /* @__PURE__ */ new Date(0);
3763
+ date.setUTCFullYear(local.year, local.month - 1, local.day);
3764
+ date.setUTCHours(local.hour, local.minute - offset, local.second, 0);
3765
+ const utc = date.toISOString();
3766
+ return utcYear.test(utc) ? utc.slice(0, 19) : null;
3767
+ }
3768
+ function normalizedSourceInstant(value) {
3769
+ if (value.length > sourceInstantMaxLength) {
3770
+ return null;
3771
+ }
3772
+ const match = localPattern.exec(value);
3773
+ if (match === null) {
3774
+ return null;
3775
+ }
3776
+ const [, year, month, day, hour, minute, second, fraction, suffix] = match;
3777
+ const local = {
3778
+ year: Number(year),
3779
+ month: Number(month),
3780
+ day: Number(day),
3781
+ hour: Number(hour),
3782
+ minute: Number(minute),
3783
+ second: Number(second ?? "0")
3784
+ };
3785
+ const offset = offsetMinutes(suffix ?? "");
3786
+ if (offset === null || !isCalendarValue(local)) {
3787
+ return null;
3788
+ }
3789
+ const utc = utcOf(local, offset);
3790
+ if (utc === null) {
3791
+ return null;
3792
+ }
3793
+ const digits = fraction === void 0 ? "" : `.${fraction.slice(0, 3)}`;
3794
+ return `${utc}${digits}Z`;
3795
+ }
3704
3796
 
3705
3797
  // ../schemas/src/draft-hosted-output-checks.ts
3706
3798
  import { z as z49 } from "zod";
@@ -3852,11 +3944,11 @@ var recipe = DraftClaimEvaluationRecipeSchema.shape;
3852
3944
  var recipeQuestion = recipe.questions.element.shape;
3853
3945
  var { judgment: judgment4 } = DraftNormalizedEvidenceSchema.shape.normalizations.element.shape;
3854
3946
  var artifactSemanticLimits = {
3855
- maxQuestions: 8,
3947
+ maxQuestions: 24,
3856
3948
  maxUnits: 64,
3857
- maxEvaluations: 128,
3949
+ maxEvaluations: 24 * 64,
3858
3950
  maxRequestBytes: 32768,
3859
- maxTotalBytes: 1048576
3951
+ maxTotalBytes: 16777216
3860
3952
  };
3861
3953
  var ArtifactSemanticQuestionSchema = z46.strictObject({
3862
3954
  id: id3,
@@ -4291,60 +4383,244 @@ var HostedOutputChecksSchema = z49.strictObject({
4291
4383
  }
4292
4384
  });
4293
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
+
4294
4569
  // ../schemas/src/draft-hosted-application.ts
4295
- 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);
4296
4571
  var digest23 = DraftApplicationReleaseSchema.shape.releaseDigest;
4297
- var HostedSourceInputSchema = z50.strictObject({
4298
- sourceId: id6,
4299
- revision: id6,
4300
- title: z50.string().min(1).max(200),
4301
- text: z50.string().min(1).max(1048576)
4302
- });
4303
- var HostedProposalInputV0Schema = z50.strictObject({
4304
- 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,
4305
4580
  expectedSourceDigest: digest23,
4306
4581
  material: DraftApplicationJobMaterialSchema,
4307
4582
  compilation: DraftCompilationSchema
4308
4583
  });
4309
- var HostedProposalInputV2Schema = z50.strictObject({
4310
- schema: z50.literal("felspar.hosted-proposal.draft/v2"),
4311
- sourceObjectId: id6,
4584
+ var HostedProposalInputV2Schema = z53.strictObject({
4585
+ schema: z53.literal("felspar.hosted-proposal.draft/v2"),
4586
+ sourceObjectId: id7,
4312
4587
  expectedSourceDigest: digest23,
4313
4588
  material: DraftApplicationJobMaterialV2Schema,
4314
- outputChecks: HostedOutputChecksSchema.optional()
4589
+ outputChecks: HostedOutputChecksSchema.optional(),
4590
+ draft: KeptPackDraftSchema.optional()
4315
4591
  });
4316
- var HostedProposalInputSchema = z50.union([
4592
+ var HostedProposalInputSchema = z53.union([
4317
4593
  HostedProposalInputV2Schema,
4318
4594
  HostedProposalInputV0Schema
4319
4595
  ]);
4320
- var HostedApprovalInputSchema = z50.strictObject({
4596
+ var HostedApprovalInputSchema = z53.strictObject({
4321
4597
  expectedProposalDigest: digest23,
4322
- reviewedMeaning: z50.literal(true),
4323
- reviewedFixtures: z50.literal(true),
4324
- 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)
4325
4601
  });
4326
- var HostedReleaseInputSchema = z50.strictObject({ expectedApprovalDigest: digest23 });
4327
- var HostedReleaseBundleSchema = z50.strictObject({
4602
+ var HostedReleaseInputSchema = z53.strictObject({ expectedApprovalDigest: digest23 });
4603
+ var HostedReleaseBundleSchema = z53.strictObject({
4328
4604
  release: DraftApplicationReleaseSchema,
4329
4605
  material: DraftAnyApplicationJobMaterialSchema,
4330
- approvalObjectId: id6,
4606
+ approvalObjectId: id7,
4331
4607
  approvalDigest: digest23,
4332
4608
  proposalDigest: digest23,
4333
4609
  sourceDigest: digest23,
4334
4610
  verifiedCompilation: DraftVerifiedCompilationSchema.optional()
4335
4611
  });
4336
- var HostedJobInputSchema = z50.strictObject({
4337
- executionId: id6,
4612
+ var HostedJobInputSchema = z53.strictObject({
4613
+ executionId: id7,
4338
4614
  expectedReleaseDigest: digest23,
4339
4615
  material: DraftAnyApplicationJobMaterialSchema
4340
4616
  });
4341
- var HostedSuppliedJobInputSchema = z50.strictObject({
4342
- mode: z50.literal("supplied"),
4343
- executionId: id6,
4617
+ var HostedSuppliedJobInputSchema = z53.strictObject({
4618
+ mode: z53.literal("supplied"),
4619
+ executionId: id7,
4344
4620
  expectedReleaseDigest: digest23,
4345
4621
  expectedAuthorityDigest: digest23,
4346
- jobId: id6,
4347
- entityId: id6,
4622
+ jobId: id7,
4623
+ entityId: id7,
4348
4624
  evidence: DraftRequiredDecisionSchema.shape.evidence,
4349
4625
  passages: DraftLayeredEvaluationSchema.shape.passages.max(256)
4350
4626
  });
@@ -4354,107 +4630,111 @@ var hostedFactsLimits = {
4354
4630
  maxFactsBytes: 524288,
4355
4631
  maxQuestions: 64
4356
4632
  };
4357
- var factSource = z50.strictObject({
4358
- class: id6,
4359
- id: DraftSourceReferenceSchema.shape.sourceId,
4360
- revision: id6.optional(),
4361
- locator: z50.string().min(1).max(4096).optional(),
4362
- observedAt: DraftObservationChecksSchema.shape.evaluationTime,
4363
- sensitivity: id6.optional()
4364
- });
4365
- var excerptText = z50.string().min(1).refine((text7) => text7.length <= hostedFactsLimits.maxExcerptCharacters, "text_too_long");
4366
- var about = z50.string().min(1).max(200).optional();
4367
- var HostedExcerptSchema = z50.strictObject({ text: excerptText, source: factSource, about });
4368
- var HostedValueFactSchema = z50.strictObject({
4369
- value: z50.union([z50.string().min(1).max(200), z50.number(), z50.boolean()]),
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,
4637
+ id: factSourceId,
4638
+ revision: id7.optional(),
4639
+ locator: z53.string().min(1).max(4096).optional(),
4640
+ observedAt,
4641
+ sensitivity: id7.optional()
4642
+ });
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()]),
4370
4648
  source: factSource.extend({ excerpt: excerptText.optional() }),
4371
4649
  about
4372
4650
  });
4373
- var HostedFactSchema = z50.union([
4651
+ var HostedFactSchema = z53.union([
4374
4652
  HostedValueFactSchema,
4375
4653
  HostedExcerptSchema,
4376
- 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")
4377
4655
  ]);
4378
4656
  function factsBytes(facts) {
4379
4657
  const encoder2 = new TextEncoder();
4380
4658
  return encoder2.encode(JSON.stringify(facts)).length;
4381
4659
  }
4382
- var HostedFactsJobInputSchema = z50.strictObject({
4383
- mode: z50.literal("facts"),
4384
- executionId: id6,
4660
+ var HostedFactsJobInputSchema = z53.strictObject({
4661
+ mode: z53.literal("facts"),
4662
+ executionId: id7,
4385
4663
  expectedReleaseDigest: digest23,
4386
- jobId: id6,
4387
- entityId: id6,
4664
+ jobId: id7,
4665
+ entityId: id7,
4388
4666
  related: HostedRelatedSubjectsSchema.optional(),
4389
- identity: z50.record(z50.string().min(1).max(128), z50.string().min(1).max(200)).optional(),
4390
- 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")
4391
4669
  });
4392
4670
  var HostedFactsRequestSchema = HostedFactsJobInputSchema.extend({
4393
- entityId: id6.optional()
4671
+ entityId: id7.optional()
4394
4672
  });
4395
- var HostedJobRequestSchema = z50.union([
4673
+ var HostedJobRequestSchema = z53.union([
4396
4674
  HostedJobInputSchema,
4397
4675
  HostedSuppliedJobInputSchema,
4398
4676
  HostedFactsJobInputSchema
4399
4677
  ]);
4400
- var HostedClassificationResultSchema = z50.strictObject({
4401
- key: id6,
4402
- observationId: id6,
4678
+ var HostedClassificationResultSchema = z53.strictObject({
4679
+ key: id7,
4680
+ observationId: id7,
4403
4681
  record: DraftNormalizedEvidenceSchema.shape.normalizations.element,
4404
- reason: z50.string().regex(/^[a-z][a-z_]{2,63}$/u).nullable(),
4405
- cached: z50.boolean()
4682
+ reason: z53.string().regex(/^[a-z][a-z_]{2,63}$/u).nullable(),
4683
+ cached: z53.boolean()
4406
4684
  });
4407
4685
  function retainsFactsExactly(record) {
4408
4686
  const hasFacts = record.facts !== void 0 && record.judgments !== void 0 && record.judgmentsDigest !== void 0;
4409
4687
  return record.schema === "felspar.hosted-supplied-execution/v3" === hasFacts;
4410
4688
  }
4411
- var HostedSuppliedExecutionRecordSchema = z50.strictObject({
4412
- schema: z50.enum([
4689
+ var HostedSuppliedExecutionRecordSchema = z53.strictObject({
4690
+ schema: z53.enum([
4413
4691
  "felspar.hosted-supplied-execution/v1",
4414
4692
  "felspar.hosted-supplied-execution/v2",
4415
4693
  "felspar.hosted-supplied-execution/v3"
4416
4694
  ]),
4417
- release: z50.strictObject({ releaseId: id6, releaseDigest: digest23, materialDigest: digest23 }),
4418
- evaluationTime: z50.iso.datetime(),
4695
+ release: z53.strictObject({ releaseId: id7, releaseDigest: digest23, materialDigest: digest23 }),
4696
+ evaluationTime: z53.iso.datetime(),
4419
4697
  input: HostedSuppliedJobInputSchema,
4420
4698
  facts: HostedFactsJobInputSchema.optional(),
4421
- judgments: z50.array(HostedClassificationResultSchema).max(192).optional(),
4699
+ judgments: z53.array(HostedClassificationResultSchema).max(192).optional(),
4422
4700
  judgmentsDigest: digest23.optional(),
4423
- expansion: z50.literal("agreeing-excerpts").optional(),
4424
- job: z50.record(z50.string(), z50.unknown())
4701
+ expansion: z53.literal("agreeing-excerpts").optional(),
4702
+ job: z53.record(z53.string(), z53.unknown())
4425
4703
  }).refine(retainsFactsExactly, "Version 3 records, and only they, retain facts with their judgments");
4426
- var HostedObjectSchema = z50.strictObject({
4427
- id: id6,
4428
- 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"]),
4429
4707
  payloadDigest: digest23,
4430
- objectKey: z50.string().min(1).max(1e3),
4431
- parentId: id6.nullable(),
4432
- status: z50.enum(["active", "released", "revoked"]),
4433
- metadata: z50.record(z50.string(), z50.unknown())
4434
- });
4435
- var HostedJobResultSchema = z50.object({
4436
- status: z50.string(),
4437
- reason: z50.string().nullable(),
4438
- result: z50.object({
4439
- executionId: z50.string(),
4440
- 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,
4441
4719
  releaseDigest: digest23,
4442
- outcome: z50.string().nullable(),
4443
- scoring: z50.unknown(),
4444
- context: z50.unknown(),
4445
- receipt: z50.unknown()
4720
+ outcome: z53.string().nullable(),
4721
+ scoring: z53.unknown(),
4722
+ context: z53.unknown(),
4723
+ receipt: z53.unknown()
4446
4724
  }).loose().nullable()
4447
4725
  });
4448
4726
 
4449
4727
  // ../schemas/src/draft-hosted-refusals.ts
4450
4728
  var limits = hostedFactsLimits;
4451
- var formatFix = "The request does not match the facts request format at this path; follow input.jsonSchema from describe.";
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).";
4452
4730
  var fixes = {
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.",
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).`,
4453
4733
  unknown_question: "This question is not in the released job. Use the question keys from describe.",
4454
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.",
4455
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.",
4456
4736
  duplicate_excerpt: "The same words from the same source were sent twice for this question. Send each excerpt once.",
4457
- 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.",
4458
4738
  label_needs_mapping: "Felspar decides answer choices and yes/no questions from source text. Send the words the source says, not a label.",
4459
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.",
4460
4740
  answer_choice_needs_excerpt: "Send this question in a facts request with the source text; Felspar classifies answer choices itself.",
@@ -4464,6 +4744,7 @@ var fixes = {
4464
4744
  request_too_large: `The facts in one request are at most ${limits.maxFactsBytes} bytes. Send shorter excerpts.`,
4465
4745
  release_changed: "The release changed. Describe the job again and resend with the current release digest.",
4466
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.",
4467
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.",
4468
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.",
4469
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.",
@@ -4483,15 +4764,47 @@ var fixes = {
4483
4764
  rate_limited: "This caller or workspace sent more decision requests in the last minute than its plan allows. Wait retryAfterSeconds, then resend the same request with the same execution ID. Send every question you have evidence for in one facts request per entity instead of one request per question, and spread a large run over time; for runs of thousands of entities, ask Felspar about batch scoring.",
4484
4765
  execution_id_reused: "This execution ID was already used for a different request. Use a new execution ID, or resend the original request unchanged.",
4485
4766
  invalid_body: "The body must be JSON or content parts within the size limit.",
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.",
4486
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.",
4487
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.",
4488
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.",
4489
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.",
4490
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.",
4491
4803
  decision_not_decided: "This decision has no outcome, so nothing is written for it. Follow its next step instead.",
4492
4804
  no_output_checks: "This job's release declares no output checks. Use the decision's next step; nothing is checked before sending.",
4493
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.",
4494
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).",
4495
4808
  invalid_type: formatFix,
4496
4809
  invalid_union: formatFix,
4497
4810
  invalid_value: formatFix,
@@ -4500,231 +4813,252 @@ var fixes = {
4500
4813
  too_big: formatFix,
4501
4814
  too_small: formatFix
4502
4815
  };
4816
+ var hostedRefusalCodes = Object.freeze(Object.keys(fixes));
4503
4817
  function hostedRefusalFix(code) {
4504
4818
  return Object.hasOwn(fixes, code) ? fixes[code] ?? null : null;
4505
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
+ }
4506
4840
 
4507
4841
  // ../schemas/src/draft-hosted-job-description.ts
4508
- import { z as z52 } from "zod";
4842
+ import { z as z55 } from "zod";
4509
4843
 
4510
4844
  // ../schemas/src/draft-hosted-output-guides.ts
4511
- import { z as z51 } from "zod";
4512
- var id7 = z51.string().min(1).max(200);
4513
- var located = z51.strictObject({
4514
- text: z51.string().min(1).max(262144),
4515
- 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)
4516
4850
  });
4517
4851
  var hostedOutputGuideLimits = { maxOutputs: 8, maxContext: 8, maxChecks: 64 };
4518
- var HostedOutputGuideSchema = z51.strictObject({
4519
- id: id7,
4852
+ var HostedOutputGuideSchema = z54.strictObject({
4853
+ id: id8,
4520
4854
  what: located,
4521
- maxCharacters: z51.number().int().min(1),
4522
- context: z51.array(located.extend({ id: id7 })).max(hostedOutputGuideLimits.maxContext).optional(),
4523
- checks: z51.array(z51.strictObject({
4524
- check: id7,
4525
- rule: z51.string().nullable(),
4526
- 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)
4527
4861
  })).max(hostedOutputGuideLimits.maxChecks)
4528
4862
  });
4529
- var HostedOutputGuidesSchema = z51.array(HostedOutputGuideSchema).max(hostedOutputGuideLimits.maxOutputs);
4863
+ var HostedOutputGuidesSchema = z54.array(HostedOutputGuideSchema).max(hostedOutputGuideLimits.maxOutputs);
4530
4864
 
4531
4865
  // ../schemas/src/draft-hosted-job-description.ts
4532
- var id8 = z52.string().min(1).max(200);
4866
+ var id9 = z55.string().min(1).max(200);
4533
4867
  var digest24 = DraftApplicationReleaseSchema.shape.releaseDigest;
4534
4868
  var { requirements, rules } = DraftRequiredProposalSchema.shape;
4535
- var quotedText = z52.strictObject({
4536
- text: z52.string().min(1).max(262144),
4869
+ var quotedText = z55.strictObject({
4870
+ text: z55.string().min(1).max(262144),
4537
4871
  source: DraftSourceReferenceSchema.omit({ contentDigest: true }).extend({
4538
- locator: z52.string().min(1).max(4096),
4872
+ locator: z55.string().min(1).max(4096),
4539
4873
  contentDigest: digest24
4540
4874
  }),
4541
- 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)
4542
4876
  });
4543
4877
  var subjectShape = {
4544
- identifier: z52.string().min(1).max(200),
4545
- example: z52.string().min(1).max(200),
4546
- 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)
4547
4881
  };
4548
- var HostedJobSubjectSchema = z52.strictObject({
4549
- type: id8,
4882
+ var HostedJobSubjectSchema = z55.strictObject({
4883
+ type: id9,
4550
4884
  definition: quotedText,
4551
4885
  identifier: subjectShape.identifier.optional(),
4552
4886
  example: subjectShape.example.optional(),
4553
4887
  match: subjectShape.match,
4554
- related: z52.array(z52.strictObject({
4555
- relationship: id8,
4888
+ related: z55.array(z55.strictObject({
4889
+ relationship: id9,
4556
4890
  meaning: quotedText,
4557
- cardinality: z52.enum(relationshipCardinalities),
4558
- required: z52.boolean(),
4559
- subject: id8,
4891
+ cardinality: z55.enum(relationshipCardinalities),
4892
+ required: z55.boolean(),
4893
+ subject: id9,
4560
4894
  definition: quotedText,
4561
4895
  ...subjectShape
4562
4896
  })).max(16),
4563
- send: z52.string().min(1).max(2e4)
4897
+ send: z55.string().min(1).max(2e4)
4564
4898
  });
4565
- var HostedJobEscalationsSchema = z52.strictObject({
4566
- routes: z52.array(z52.strictObject({ id: id8, quote: quotedText })).min(1).max(16),
4567
- unresolved: id8.nullable(),
4568
- attemptLimit: id8.nullable(),
4569
- 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)
4570
4904
  });
4571
- var HostedEscalationSchema = z52.strictObject({
4572
- id: id8,
4573
- trigger: z52.enum(escalationTriggers),
4905
+ var HostedEscalationSchema = z55.strictObject({
4906
+ id: id9,
4907
+ trigger: z55.enum(escalationTriggers),
4574
4908
  why: quotedText
4575
4909
  });
4576
- var HostedJobDescriptionSchema = z52.strictObject({
4577
- schema: z52.literal("felspar.hosted-job-description.draft/v0"),
4578
- job: id8,
4910
+ var HostedJobDescriptionSchema = z55.strictObject({
4911
+ schema: z55.literal("felspar.hosted-job-description.draft/v0"),
4912
+ job: id9,
4579
4913
  purpose: quotedText.optional(),
4580
- useWhen: z52.array(quotedText).max(8).optional(),
4581
- notFor: z52.array(quotedText).max(8).optional(),
4914
+ useWhen: z55.array(quotedText).max(8).optional(),
4915
+ notFor: z55.array(quotedText).max(8).optional(),
4582
4916
  owner: quotedText.optional(),
4583
4917
  subject: HostedJobSubjectSchema.optional(),
4584
- identity: z52.strictObject({
4585
- mode: z52.enum(identityModes),
4586
- send: z52.string().min(1).max(4e3),
4587
- fields: z52.array(z52.strictObject({ name: id8, ...subjectShape })).max(8).optional(),
4588
- 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()
4589
4923
  }).optional(),
4590
- trustDomain: id8,
4591
- release: z52.strictObject({
4592
- releaseId: id8,
4924
+ trustDomain: id9,
4925
+ release: z55.strictObject({
4926
+ releaseId: id9,
4593
4927
  releaseDigest: digest24,
4594
4928
  materialDigest: digest24,
4595
4929
  expectedAuthorityDigest: digest24
4596
4930
  }),
4597
4931
  resolutionPolicy: DraftRequiredProposalSchema.shape.resolutionPolicy,
4598
- questions: z52.array(requirements.element.extend({
4599
- key: id8,
4600
- 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"]),
4601
4935
  meaning: quotedText,
4602
- answer: z52.strictObject({
4603
- send: z52.enum(["text", "text_or_value"]),
4604
- valueFormat: z52.enum(["number", "calendar-date"]).nullable(),
4605
- interpretation: z52.enum(["classified", "exact_read", "unsupported"]),
4606
- threshold: z52.number().gt(0).max(1).nullable(),
4607
- applies: z52.enum(["always", "conditional"]),
4608
- dependsOn: z52.array(id8).max(32),
4609
- 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(),
4610
4944
  reading: ExactReaderSchema.optional()
4611
4945
  }),
4612
- answers: z52.array(z52.strictObject({
4613
- value: id8,
4614
- meaning: z52.string().nullable(),
4615
- inclusions: z52.array(z52.string()).max(8),
4616
- exclusions: z52.array(z52.string()).max(8),
4617
- examples: z52.array(z52.string()).max(8),
4618
- 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)
4619
4953
  })).max(64).optional(),
4620
- whereToLook: z52.array(quotedText).max(8).optional(),
4621
- 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()
4622
4956
  })).max(64),
4623
- rules: z52.array(rules.element.extend({ text: quotedText })).max(256),
4624
- outcomes: z52.array(z52.strictObject({
4625
- id: id8,
4957
+ rules: z55.array(rules.element.extend({ text: quotedText })).max(256),
4958
+ outcomes: z55.array(z55.strictObject({
4959
+ id: id9,
4626
4960
  meaning: quotedText.nullable(),
4627
4961
  nextStep: quotedText.nullable().optional(),
4628
4962
  outputs: HostedOutputGuidesSchema.optional(),
4629
- escalate: id8.optional()
4963
+ escalate: id9.optional()
4630
4964
  })).max(64),
4631
4965
  escalations: HostedJobEscalationsSchema.optional(),
4632
4966
  whenUnresolved: quotedText.nullable().optional(),
4633
- attempts: z52.strictObject({
4634
- max: z52.number().int().min(1).max(10),
4635
- withProgress: z52.number().int().min(1).max(10),
4636
- 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)
4637
4971
  }).optional(),
4638
- guidance: z52.strictObject({ gather: z52.string().min(1).max(2e3) }),
4639
- input: z52.strictObject({
4640
- 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()),
4641
4975
  example: HostedFactsJobInputSchema.nullable(),
4642
- exampleNote: z52.string().max(1e3)
4976
+ exampleNote: z55.string().max(1e3)
4643
4977
  }),
4644
- limits: z52.strictObject({
4645
- maxEvidenceItems: z52.number().int().positive(),
4646
- maxPassages: z52.number().int().positive(),
4647
- facts: z52.strictObject({
4648
- maxExcerptCharacters: z52.literal(hostedFactsLimits.maxExcerptCharacters),
4649
- maxExcerptsPerQuestion: z52.literal(hostedFactsLimits.maxExcerptsPerQuestion),
4650
- maxFactsBytes: z52.literal(hostedFactsLimits.maxFactsBytes),
4651
- 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)
4652
4986
  })
4653
4987
  })
4654
4988
  });
4655
- var interpretedExcerpt = z52.strictObject({
4656
- id: id8,
4657
- method: z52.enum(["value", "exact_read", "classified"]),
4658
- status: z52.enum(["accepted", "needs_evidence", "not_needed"]),
4659
- value: z52.union([z52.string(), z52.number(), z52.boolean()]).optional(),
4660
- reasons: z52.array(z52.string()),
4661
- classification: z52.strictObject({
4662
- candidate: z52.string().nullable(),
4663
- probability: z52.number().min(0).max(1).nullable(),
4664
- abstention: z52.number().min(0).max(1).nullable(),
4665
- threshold: z52.number().min(0).max(1),
4666
- 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() }))
4667
5001
  }).optional()
4668
5002
  });
4669
- var ruleSummary = z52.strictObject({ id: id8, outcome: id8, text: quotedText });
4670
- var HostedJobExplanationSchema = z52.strictObject({
4671
- schema: z52.literal("felspar.hosted-job-explanation.draft/v0"),
4672
- decision: z52.strictObject({ status: z52.string().nullable(), reasons: z52.array(z52.string()) }),
4673
- needs: z52.array(z52.strictObject({
4674
- key: id8,
4675
- status: z52.string(),
4676
- reasons: z52.array(z52.string()),
4677
- acceptedSourceClasses: z52.array(z52.string()),
4678
- 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(),
4679
5013
  requiredWhen: HostedJobDescriptionSchema.shape.questions.element.shape.requiredWhen,
4680
- excerpts: z52.array(interpretedExcerpt).optional()
5014
+ excerpts: z55.array(interpretedExcerpt).optional()
4681
5015
  })),
4682
- why: z52.strictObject({
4683
- rules: z52.array(ruleSummary),
4684
- overrides: z52.array(z52.strictObject({ by: id8, target: id8 })),
4685
- suppressedRuleIds: z52.array(id8),
4686
- 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()))
4687
5021
  }).nullable(),
4688
- context: z52.strictObject({ status: z52.string(), reason: z52.string().nullable() }).nullable(),
4689
- reviewNeeds: z52.array(z52.string()),
4690
- 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()
4691
5025
  });
4692
- var HostedReceiptVerificationInputSchema = z52.strictObject({
5026
+ var HostedReceiptVerificationInputSchema = z55.strictObject({
4693
5027
  receipt: DraftJobReceiptSchema,
4694
5028
  expectedReceiptDigest: digest24,
4695
5029
  deliveredCapsule: DraftContextVerificationOptionsSchema.shape.deliveredCapsule
4696
5030
  });
4697
- var HostedReceiptVerificationSchema = z52.strictObject({
4698
- authority: z52.literal("unapproved"),
4699
- status: z52.enum(["reproduced", "mismatch"]),
4700
- mismatches: z52.array(z52.string()),
4701
- decided: z52.strictObject({
4702
- jobId: id8,
4703
- entityId: id8,
4704
- releaseId: id8,
4705
- outcome: id8.nullable(),
4706
- case: z52.strictObject({ id: id8, mode: z52.enum(identityModes) }).optional(),
4707
- subject: z52.strictObject({
4708
- type: id8,
4709
- 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)
4710
5044
  }).optional(),
4711
5045
  escalation: HostedEscalationSchema.omit({ why: true }).optional()
4712
5046
  }).optional()
4713
5047
  });
4714
5048
 
4715
5049
  // ../schemas/src/draft-hosted-output-check-record.ts
4716
- import { z as z55 } from "zod";
5050
+ import { z as z58 } from "zod";
4717
5051
 
4718
5052
  // ../schemas/src/draft-artifact-lint.ts
4719
- import { z as z54 } from "zod";
5053
+ import { z as z57 } from "zod";
4720
5054
 
4721
5055
  // ../schemas/src/draft-job-obligations.ts
4722
- import { z as z53 } from "zod";
4723
- var id9 = DraftApplicationScopeSchema.shape.authorityId;
5056
+ import { z as z56 } from "zod";
5057
+ var id10 = DraftApplicationScopeSchema.shape.authorityId;
4724
5058
  var digest25 = DraftJobReceiptSchema.shape.receiptDigest;
4725
5059
  var outcome2 = DraftJobObligationsOutcomeSchema;
4726
5060
  var DraftApplicationJobMaterialV3Schema = DraftApplicationJobMaterialV2Schema.extend({
4727
- schema: z53.literal("felspar.application-job-material.draft/v3"),
5061
+ schema: z56.literal("felspar.application-job-material.draft/v3"),
4728
5062
  obligations: DraftJobObligationsSchema
4729
5063
  }).superRefine((value, context3) => {
4730
5064
  if (context3.issues.length > 0) {
@@ -4752,57 +5086,57 @@ var DraftApplicationJobMaterialV3Schema = DraftApplicationJobMaterialV2Schema.ex
4752
5086
  }
4753
5087
  });
4754
5088
  var HostedProposalInputV3Schema = HostedProposalInputV2Schema.extend({
4755
- schema: z53.literal("felspar.hosted-proposal.draft/v3"),
5089
+ schema: z56.literal("felspar.hosted-proposal.draft/v3"),
4756
5090
  material: DraftApplicationJobMaterialV3Schema
4757
5091
  });
4758
5092
  var jobObligationsReplayRoutes = ["supplied", "evaluated"];
4759
5093
  var replayRoutes = new Set(jobObligationsReplayRoutes);
4760
5094
  var DraftJobObligationsExecutionSchema = DraftAnyJobExecutionSchema.refine((execution) => replayRoutes.has(execution.invocation.route), "Obligations assessments support supplied and evaluated native executions");
4761
- var DraftJobObligationsNativeResultSchema = z53.strictObject({
4762
- authority: z53.literal("unapproved"),
4763
- discovery: z53.record(z53.string(), z53.unknown()),
4764
- 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()),
4765
5099
  receipt: DraftJobReceiptSchema
4766
5100
  });
4767
- var DraftJobObligationsInputSchema = z53.strictObject({
5101
+ var DraftJobObligationsInputSchema = z56.strictObject({
4768
5102
  release: DraftApplicationReleaseSchema,
4769
- material: z53.union([DraftApplicationJobMaterialV3Schema, DraftAnyApplicationJobMaterialSchema]),
5103
+ material: z56.union([DraftApplicationJobMaterialV3Schema, DraftAnyApplicationJobMaterialSchema]),
4770
5104
  execution: DraftJobObligationsExecutionSchema,
4771
5105
  expectedReceiptDigest: digest25,
4772
5106
  job: DraftJobObligationsNativeResultSchema,
4773
5107
  explanation: HostedJobExplanationSchema,
4774
- invocation: DraftJobObligationsScopeSchema.extend({ caseId: id9 })
5108
+ invocation: DraftJobObligationsScopeSchema.extend({ caseId: id10 })
4775
5109
  });
4776
- var requirements2 = z53.strictObject({
4777
- status: z53.enum(["established", "unresolved"]),
5110
+ var requirements2 = z56.strictObject({
5111
+ status: z56.enum(["established", "unresolved"]),
4778
5112
  scope: DraftJobObligationsScopeSchema,
4779
5113
  artifacts: outcome2.shape.artifacts,
4780
5114
  approvals: outcome2.shape.approvals,
4781
- 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)
4782
5116
  });
4783
- var nextReference = z53.discriminatedUnion("kind", [
4784
- z53.strictObject({ kind: z53.literal("evidence_need"), id: id9 }),
4785
- z53.strictObject({ kind: z53.literal("artifact_requirement"), id: id9 }),
4786
- z53.strictObject({ kind: z53.literal("approval_requirement"), id: id9 }),
4787
- 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 })
4788
5122
  ]);
4789
- var DraftJobObligationsAssessmentBodySchema = z53.strictObject({
4790
- schema: z53.literal("felspar.job-obligations-assessment.draft/v0"),
4791
- binding: z53.strictObject({
5123
+ var DraftJobObligationsAssessmentBodySchema = z56.strictObject({
5124
+ schema: z56.literal("felspar.job-obligations-assessment.draft/v0"),
5125
+ binding: z56.strictObject({
4792
5126
  releaseDigest: digest25,
4793
5127
  materialDigest: digest25,
4794
5128
  nativeReceiptDigest: digest25,
4795
- jobId: id9,
5129
+ jobId: id10,
4796
5130
  applicationScope: DraftApplicationScopeSchema,
4797
- caseId: id9,
4798
- entityId: id9,
4799
- evaluationTime: z53.iso.datetime({ offset: true }),
4800
- purposeRef: id9,
4801
- useRef: id9.nullable()
5131
+ caseId: id10,
5132
+ entityId: id10,
5133
+ evaluationTime: z56.iso.datetime({ offset: true }),
5134
+ purposeRef: id10,
5135
+ useRef: id10.nullable()
4802
5136
  }),
4803
5137
  requirements: requirements2,
4804
- next: z53.strictObject({
4805
- kind: z53.enum([
5138
+ next: z56.strictObject({
5139
+ kind: z56.enum([
4806
5140
  "stop",
4807
5141
  "review_required",
4808
5142
  "gather_evidence",
@@ -4810,8 +5144,8 @@ var DraftJobObligationsAssessmentBodySchema = z53.strictObject({
4810
5144
  "verify_before_action",
4811
5145
  "return_result"
4812
5146
  ]),
4813
- reasonCodes: z53.array(id9).max(64),
4814
- refs: z53.array(nextReference).max(64)
5147
+ reasonCodes: z56.array(id10).max(64),
5148
+ refs: z56.array(nextReference).max(64)
4815
5149
  })
4816
5150
  });
4817
5151
  function isNextRefDeclared(ref, required) {
@@ -4848,48 +5182,48 @@ var DraftJobObligationsAssessmentSchema = DraftJobObligationsAssessmentBodySchem
4848
5182
  });
4849
5183
 
4850
5184
  // ../schemas/src/draft-artifact-lint.ts
4851
- var id10 = DraftApplicationScopeSchema.shape.authorityId;
5185
+ var id11 = DraftApplicationScopeSchema.shape.authorityId;
4852
5186
  var digest26 = DraftJobReceiptSchema.shape.receiptDigest;
4853
5187
  var passage3 = ArtifactSpecificationSchema;
4854
- var plainArtifact = z54.strictObject({
4855
- id: id10,
4856
- revision: id10,
4857
- mediaType: z54.literal("text/plain"),
4858
- exportProfile: id10.nullable(),
4859
- 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),
4860
5194
  expectedContentDigest: digest26
4861
5195
  });
4862
- var structuredArtifact = z54.strictObject({
4863
- id: id10,
4864
- revision: id10,
4865
- mediaType: z54.literal("application/vnd.felspar.structured-output+json"),
4866
- 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(),
4867
5201
  content: DraftStructuredOutputSchema,
4868
5202
  expectedContentDigest: digest26
4869
5203
  });
4870
- var ArtifactLintArtifactSchema = z54.discriminatedUnion("mediaType", [
5204
+ var ArtifactLintArtifactSchema = z57.discriminatedUnion("mediaType", [
4871
5205
  plainArtifact,
4872
5206
  structuredArtifact
4873
5207
  ]);
4874
- var ArtifactLintDecisionSchema = z54.strictObject({
5208
+ var ArtifactLintDecisionSchema = z57.strictObject({
4875
5209
  inputs: DraftJobObligationsInputSchema,
4876
5210
  assessment: DraftJobObligationsAssessmentSchema,
4877
5211
  expectedAssessmentDigest: digest26
4878
5212
  });
4879
- var ArtifactLintInputSchema = z54.strictObject({
4880
- schema: z54.literal("felspar.lint.draft/v1"),
4881
- requestId: id10,
5213
+ var ArtifactLintInputSchema = z57.strictObject({
5214
+ schema: z57.literal("felspar.lint.draft/v1"),
5215
+ requestId: id11,
4882
5216
  release: DraftApplicationReleaseSchema,
4883
5217
  material: DraftApplicationJobMaterialV3Schema,
4884
5218
  manifest: ArtifactCheckManifestSchema,
4885
5219
  expectedManifestDigest: digest26,
4886
- attachedObligations: z54.strictObject({ expectedObligationsDigest: digest26 }).optional(),
4887
- attachedCase: z54.strictObject({
5220
+ attachedObligations: z57.strictObject({ expectedObligationsDigest: digest26 }).optional(),
5221
+ attachedCase: z57.strictObject({
4888
5222
  decisionReceiptDigest: digest26,
4889
- 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)
4890
5224
  }).optional(),
4891
- case: z54.strictObject({ caseId: id10, purposeRef: id10, useRef: id10.nullable() }),
4892
- artifactRequirementId: id10.nullable(),
5225
+ case: z57.strictObject({ caseId: id11, purposeRef: id11, useRef: id11.nullable() }),
5226
+ artifactRequirementId: id11.nullable(),
4893
5227
  decision: ArtifactLintDecisionSchema.nullable(),
4894
5228
  artifact: ArtifactLintArtifactSchema
4895
5229
  });
@@ -4902,11 +5236,11 @@ var artifactCheckStatuses = [
4902
5236
  "not_applicable",
4903
5237
  "skipped"
4904
5238
  ];
4905
- var range = z54.strictObject({
4906
- sectionId: id10,
4907
- start: z54.number().int().min(0).max(artifactLintLimits.maxSectionUnits),
4908
- end: z54.number().int().min(1).max(artifactLintLimits.maxSectionUnits),
4909
- 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")
4910
5244
  });
4911
5245
  var findingCodes = [
4912
5246
  "section_missing",
@@ -4934,148 +5268,148 @@ var findingCodes = [
4934
5268
  "evaluation_budget_exceeded",
4935
5269
  "evaluation_skipped"
4936
5270
  ];
4937
- var ArtifactFindingSchema = z54.strictObject({
4938
- code: z54.enum(findingCodes),
4939
- checkId: id10.nullable(),
4940
- 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"]),
4941
5275
  specification: passage3.nullable(),
4942
5276
  location: range.nullable(),
4943
- insertionAnchor: z54.strictObject({ sectionId: id10.nullable(), at: z54.number().int().min(0) }).nullable(),
4944
- literalIndex: z54.number().int().min(0).max(artifactLintLimits.maxLiterals).nullable()
4945
- });
4946
- var ArtifactCheckObservationSchema = z54.strictObject({
4947
- checkId: id10,
4948
- kind: z54.enum(artifactCheckKinds),
4949
- required: z54.boolean(),
4950
- method: z54.enum(["deterministic", "semantic"]),
4951
- status: z54.enum(artifactCheckStatuses),
4952
- occurrences: z54.number().int().min(0),
4953
- parsedValue: z54.number().nullable(),
4954
- caseValue: z54.number().nullable()
4955
- });
4956
- var ArtifactLintRecordBodySchema = z54.strictObject({
4957
- schema: z54.literal("felspar.lint-record.draft/v1"),
4958
- requestId: id10,
4959
- status: z54.enum(["pass", "revise", "unavailable", "review_required"]),
4960
- caseContext: z54.enum(["bound", "not_required"]),
4961
- 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({
4962
5296
  scope: DraftApplicationScopeSchema,
4963
- releaseId: id10,
5297
+ releaseId: id11,
4964
5298
  releaseDigest: digest26,
4965
5299
  materialDigest: digest26,
4966
5300
  obligationsDigest: digest26.optional(),
4967
5301
  caseFactsDigest: digest26.optional(),
4968
- jobId: id10,
4969
- manifestId: id10,
5302
+ jobId: id11,
5303
+ manifestId: id11,
4970
5304
  manifestDigest: digest26,
4971
- contract: z54.strictObject({ id: id10, digest: digest26 }),
4972
- caseId: id10,
4973
- purposeRef: id10,
4974
- useRef: id10.nullable(),
4975
- 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(),
4976
5310
  decisionReceiptDigest: digest26.nullable(),
4977
5311
  obligationsAssessmentDigest: digest26.nullable()
4978
5312
  }),
4979
- artifact: z54.strictObject({
4980
- id: id10,
4981
- revision: id10,
4982
- mediaType: z54.enum(artifactLintMediaTypes),
4983
- exportProfile: id10.nullable(),
5313
+ artifact: z57.strictObject({
5314
+ id: id11,
5315
+ revision: id11,
5316
+ mediaType: z57.enum(artifactLintMediaTypes),
5317
+ exportProfile: id11.nullable(),
4984
5318
  contentDigest: digest26,
4985
- sections: z54.array(z54.strictObject({
4986
- id: id10,
4987
- units: z54.number().int().min(0),
5319
+ sections: z57.array(z57.strictObject({
5320
+ id: id11,
5321
+ units: z57.number().int().min(0),
4988
5322
  contentDigest: digest26.nullable()
4989
5323
  })).max(artifactLintLimits.maxSections)
4990
5324
  }),
4991
- checks: z54.array(ArtifactCheckObservationSchema).max(artifactLintLimits.maxChecks),
4992
- findings: z54.array(ArtifactFindingSchema).max(2048),
5325
+ checks: z57.array(ArtifactCheckObservationSchema).max(artifactLintLimits.maxChecks),
5326
+ findings: z57.array(ArtifactFindingSchema).max(2048),
4993
5327
  semantic: ArtifactSemanticRecordSchema.nullable(),
4994
- coverage: z54.strictObject({
4995
- scope: z54.literal("declared_checks_only"),
4996
- declared: z54.number().int().min(0),
4997
- applicable: z54.number().int().min(0),
4998
- completed: z54.number().int().min(0),
4999
- required: z54.number().int().min(0),
5000
- requiredCompleted: z54.number().int().min(0),
5001
- textAssigned: z54.enum(["complete", "incomplete"]),
5002
- semantic: z54.enum(["not_declared", "complete", "incomplete"]),
5003
- 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")
5004
5338
  }),
5005
- actionAuthorized: z54.literal(false)
5339
+ actionAuthorized: z57.literal(false)
5006
5340
  });
5007
5341
  var ArtifactLintRecordSchema = ArtifactLintRecordBodySchema.extend({
5008
5342
  recordDigest: digest26
5009
5343
  });
5010
- var ArtifactLintReceiptSchema = z54.strictObject({
5011
- schema: z54.literal("felspar.lint-receipt.draft/v1"),
5344
+ var ArtifactLintReceiptSchema = z57.strictObject({
5345
+ schema: z57.literal("felspar.lint-receipt.draft/v1"),
5012
5346
  recordDigest: digest26,
5013
5347
  releaseDigest: digest26,
5014
5348
  manifestDigest: digest26,
5015
5349
  contractDigest: digest26,
5016
- caseId: id10,
5017
- caseContext: z54.enum(["bound", "not_required"]),
5350
+ caseId: id11,
5351
+ caseContext: z57.enum(["bound", "not_required"]),
5018
5352
  decisionReceiptDigest: digest26.nullable(),
5019
5353
  obligationsAssessmentDigest: digest26.nullable(),
5020
- artifactId: id10,
5021
- artifactRevision: id10,
5354
+ artifactId: id11,
5355
+ artifactRevision: id11,
5022
5356
  artifactDigest: digest26,
5023
- actionAuthorized: z54.literal(false),
5357
+ actionAuthorized: z57.literal(false),
5024
5358
  receiptDigest: digest26
5025
5359
  });
5026
5360
 
5027
5361
  // ../schemas/src/draft-hosted-output-check-record.ts
5028
- var id11 = DraftApplicationScopeSchema.shape.authorityId;
5362
+ var id12 = DraftApplicationScopeSchema.shape.authorityId;
5029
5363
  var digest27 = DraftJobReceiptSchema.shape.receiptDigest;
5030
- var HostedOutputCheckInputSchema = z55.strictObject({
5031
- executionId: id11,
5032
- output: id11.optional(),
5033
- text: z55.string().min(1).max(artifactLintLimits.maxTotalBytes).refine(isWellFormedText, "text_not_well_formed"),
5034
- revision: id11.optional()
5035
- });
5036
- var HostedOutputCheckRecordSchema = z55.strictObject({
5037
- schema: z55.literal("felspar.hosted-output-check/v0"),
5038
- checkId: id11,
5039
- jobId: id11,
5040
- output: id11,
5041
- decision: z55.strictObject({ executionId: id11, outcome: id11, receiptDigest: digest27 }),
5042
- 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 }),
5043
5377
  record: ArtifactLintRecordSchema,
5044
5378
  receipt: ArtifactLintReceiptSchema.nullable(),
5045
- evaluation: z55.strictObject({
5046
- modelCalls: z55.number().int().min(0),
5047
- 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()
5048
5382
  })
5049
5383
  });
5050
5384
 
5051
5385
  // src/draft-hosted-client.ts
5052
- import { z as z56 } from "zod";
5053
- var digestText = z56.string().regex(/^sha256:[a-f0-9]{64}$/u);
5054
- var HostedOutputCheckReplySchema = z56.object({
5055
- status: z56.enum(["pass", "revise", "review_required", "unavailable"]),
5056
- checkId: z56.string(),
5057
- output: z56.string(),
5058
- findings: z56.array(z56.record(z56.string(), z56.unknown())),
5059
- receipt: z56.object({ receiptDigest: digestText, artifactDigest: digestText }).loose().nullable(),
5060
- decision: z56.object({ executionId: z56.string(), receiptDigest: digestText }),
5061
- 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)
5062
5396
  }).loose();
5063
- var quotedWords = z56.object({ text: z56.string() }).loose();
5064
- var FelsparCaseSchema = z56.object({ id: z56.string().min(1).max(200), mode: z56.enum(identityModes) });
5065
- var FelsparRelatedSchema = z56.object({
5066
- relationship: z56.string(),
5067
- subject: z56.string(),
5068
- id: z56.string(),
5069
- questions: z56.array(z56.string())
5070
- });
5071
- var FelsparResultSubjectSchema = z56.object({
5072
- type: z56.string(),
5073
- id: z56.string(),
5074
- related: z56.array(FelsparRelatedSchema)
5075
- });
5076
- var FelsparEscalationSchema = z56.object({
5077
- id: z56.string().min(1).max(200),
5078
- 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),
5079
5413
  why: quotedWords
5080
5414
  });
5081
5415
  var FelsparJobResultSchema = HostedJobResultSchema.extend({
@@ -5083,11 +5417,11 @@ var FelsparJobResultSchema = HostedJobResultSchema.extend({
5083
5417
  case: FelsparCaseSchema.optional(),
5084
5418
  subject: FelsparResultSubjectSchema.optional(),
5085
5419
  escalation: FelsparEscalationSchema.optional(),
5086
- missing: z56.array(z56.string()).optional()
5420
+ missing: z59.array(z59.string()).optional()
5087
5421
  }).nullable()
5088
5422
  });
5089
- var FelsparJobListSchema = z56.object({
5090
- 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)
5091
5425
  });
5092
5426
  var hostedPartsContentType = "application/x.felspar-content-parts";
5093
5427
  async function partsBody(value) {
@@ -5139,27 +5473,29 @@ ${jobId}`;
5139
5473
  return result;
5140
5474
  };
5141
5475
  }
5142
- var refusalCode = z56.string().regex(/^[a-z][a-z_]{2,63}$/u);
5143
- var fieldPath = z56.array(z56.string().max(256)).max(32);
5144
- var refusalEscalationSchema = z56.object({
5145
- id: z56.string().regex(/^[a-zA-Z0-9][a-zA-Z0-9._:/@-]{0,199}$/u),
5146
- trigger: z56.enum(escalationTriggers),
5147
- 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) })
5148
5482
  });
5149
- var refusalSchema = z56.object({
5483
+ var refusalSchema = z59.object({
5150
5484
  error: refusalCode,
5151
5485
  path: fieldPath.optional(),
5152
- currentReleaseDigest: z56.string().regex(/^sha256:[a-f0-9]{64}$/u).optional(),
5153
- retryAfterSeconds: z56.number().int().min(1).max(3600).optional(),
5154
- escalation: z56.unknown().optional(),
5155
- 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()
5156
5490
  }).transform(({ escalation: named, ...value }) => {
5157
5491
  const fix = hostedRefusalFix(value.error);
5492
+ const recovery = hostedRefusalRecovery(value.error);
5158
5493
  const escalation = refusalEscalationSchema.safeParse(named).data;
5159
5494
  return {
5160
5495
  ...value,
5161
5496
  ...escalation !== void 0 && { escalation },
5162
5497
  ...fix !== null && { fix },
5498
+ ...recovery !== null && { recovery },
5163
5499
  ...value.issues && {
5164
5500
  issues: value.issues.map((issue) => {
5165
5501
  const issueFix = hostedRefusalFix(issue.code);
@@ -5180,8 +5516,8 @@ var FelsparRequestError = class extends Error {
5180
5516
  }
5181
5517
  };
5182
5518
  async function refusalOf(response) {
5183
- const text7 = await response.text();
5184
- 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);
5185
5521
  return parsed.success ? parsed.data : null;
5186
5522
  }
5187
5523
  async function requestError(response) {
@@ -5213,9 +5549,10 @@ function agentCalls(call) {
5213
5549
  const objectId = HostedObjectSchema.shape.id;
5214
5550
  return {
5215
5551
  listJobs: async () => await call("/v0/jobs", FelsparJobListSchema),
5216
- resolveJob: async (id12, value) => {
5552
+ describeCurrentJob: async (job) => await call(`/v0/jobs/${encodeURIComponent(objectId.parse(job))}/brief`, HostedJobDescriptionSchema),
5553
+ resolveJob: async (id13, value) => {
5217
5554
  const input = HostedSuppliedJobInputSchema.parse(value);
5218
- const releaseId = objectId.parse(id12);
5555
+ const releaseId = objectId.parse(id13);
5219
5556
  const path3 = `/v0/releases/${encodeURIComponent(releaseId)}/jobs`;
5220
5557
  return pinnedResult(await call(path3, FelsparJobResultSchema, input), releaseId, input);
5221
5558
  }
@@ -5260,16 +5597,16 @@ function createHostedFelsparClient(configuration) {
5260
5597
  return {
5261
5598
  submitSource: async (value) => await call("/v0/sources", HostedObjectSchema, HostedSourceInputSchema.parse(value)),
5262
5599
  submitProposal: async (value) => await call("/v0/proposals", HostedObjectSchema, HostedProposalInputSchema.parse(value)),
5263
- approveProposal: async (id12, value) => await call(`/v0/proposals/${encodeURIComponent(objectId.parse(id12))}/approve`, HostedObjectSchema, HostedApprovalInputSchema.parse(value)),
5264
- releasePack: async (id12, value) => await call(`/v0/approvals/${encodeURIComponent(objectId.parse(id12))}/release`, DraftApplicationReleaseSchema, HostedReleaseInputSchema.parse(value)),
5265
- loadRelease: async (id12) => await call(`/v0/releases/${encodeURIComponent(objectId.parse(id12))}`, HostedReleaseBundleSchema),
5266
- 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)),
5267
5604
  verifyReceipt: async (executionObjectId, value) => await call(`/v0/executions/${encodeURIComponent(objectId.parse(executionObjectId))}/verify`, HostedReceiptVerificationSchema, HostedReceiptVerificationInputSchema.parse(value)),
5268
5605
  ...outputCheckCalls(call),
5269
- 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)),
5270
5607
  ...agentCalls(call),
5271
- resolveFacts: async (id12, value) => {
5272
- const releaseId = objectId.parse(id12);
5608
+ resolveFacts: async (id13, value) => {
5609
+ const releaseId = objectId.parse(id13);
5273
5610
  const input = await factsRequest(value, async (jobId) => await describe(releaseId, jobId));
5274
5611
  const path3 = `/v0/releases/${encodeURIComponent(releaseId)}/jobs`;
5275
5612
  return pinnedResult(await call(path3, FelsparJobResultSchema, input), releaseId, input);