stitchkit 0.76.1 → 0.77.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.
Files changed (59) hide show
  1. package/dist/agent-runtime-coding-tools.js +1 -2
  2. package/dist/agent-runtime-harness.js +4 -5
  3. package/dist/agent-runtime.js +7 -8
  4. package/dist/application/decisions.d.ts +86 -0
  5. package/dist/application/decisions.d.ts.map +1 -0
  6. package/dist/application/kernel.d.ts +33 -1
  7. package/dist/application/kernel.d.ts.map +1 -1
  8. package/dist/application/watch-hub.d.ts +1 -1
  9. package/dist/application/watch-hub.d.ts.map +1 -1
  10. package/dist/application-schemas.d.ts +15 -0
  11. package/dist/application-schemas.d.ts.map +1 -0
  12. package/dist/application-schemas.js +111 -0
  13. package/dist/application.d.ts +3 -2
  14. package/dist/application.d.ts.map +1 -1
  15. package/dist/application.js +184 -114
  16. package/dist/cli.js +6 -7
  17. package/dist/contract/index.js +1 -2
  18. package/dist/{index-v5dm4bwq.js → index-58jzmnn4.js} +1 -1
  19. package/dist/{index-885chjxq.js → index-7qy2ex0m.js} +1 -1
  20. package/dist/index-a916km3r.js +45 -0
  21. package/dist/{index-28jsdwt1.js → index-aczggrty.js} +1 -1
  22. package/dist/{index-65kathdm.js → index-da1aqnhb.js} +4 -6
  23. package/dist/{index-xgahrwdf.js → index-ezmn6ac6.js} +3 -3
  24. package/dist/{index-4kp4fxvp.js → index-f6n5n7nz.js} +18 -4
  25. package/dist/{index-6wr9f6qm.js → index-jqtsc9mj.js} +2 -2
  26. package/dist/{index-9c5dbr5q.js → index-k2zczx1g.js} +1 -1
  27. package/dist/{index-v7xjfy10.js → index-m668wzyc.js} +1 -1
  28. package/dist/{index-e0a57ymn.js → index-nemjkxjp.js} +1 -1
  29. package/dist/{index-9my2n66s.js → index-s2rchahr.js} +4 -4
  30. package/dist/{index-k68e5jz0.js → index-s4c8wy8m.js} +2 -2
  31. package/dist/{index-52400rdd.js → index-t8qyvrvg.js} +3 -3
  32. package/dist/{index-endzd8sj.js → index-vbf2p6me.js} +1 -1
  33. package/dist/{index-hvftzz91.js → index-vc1b0b1b.js} +221 -117
  34. package/dist/{index-hsz2mmk0.js → index-vj3vvpaa.js} +17 -1
  35. package/dist/index.js +1 -2
  36. package/dist/internal/decision.d.ts +31 -0
  37. package/dist/internal/decision.d.ts.map +1 -0
  38. package/dist/internal/stable-digest.d.ts +40 -6
  39. package/dist/internal/stable-digest.d.ts.map +1 -1
  40. package/dist/live/events.d.ts +8 -13
  41. package/dist/live/events.d.ts.map +1 -1
  42. package/dist/live/watch-client.d.ts.map +1 -1
  43. package/dist/live.d.ts +1 -1
  44. package/dist/live.d.ts.map +1 -1
  45. package/dist/live.js +40 -57
  46. package/dist/node.js +4 -5
  47. package/dist/observability/index.js +3 -4
  48. package/dist/primitives.js +1 -2
  49. package/dist/remote.js +2 -3
  50. package/dist/server/event-bus.d.ts +3 -2
  51. package/dist/server/event-bus.d.ts.map +1 -1
  52. package/dist/server/index.js +5 -6
  53. package/dist/testing.js +3 -4
  54. package/dist/tool-invoker.js +5 -6
  55. package/dist/tools.js +13 -14
  56. package/llms-full.txt +184 -4
  57. package/package.json +6 -2
  58. package/dist/index-rxfy4cq7.js +0 -17
  59. package/dist/index-vdvmcy7r.js +0 -22
@@ -27,13 +27,16 @@ import {
27
27
  import {
28
28
  argumentsDigest,
29
29
  stableValue
30
- } from "./index-vdvmcy7r.js";
30
+ } from "./index-a916km3r.js";
31
31
  import {
32
32
  ApplicationAdmissionError,
33
+ ApplicationRestartInputSchema,
34
+ ApplicationRestartOutcomeSchema,
35
+ ApplicationRestartResultSchema,
33
36
  ApplicationShutdownBudgetSchema,
34
37
  ApplicationShutdownOptionsSchema,
35
38
  createApplication
36
- } from "./index-hvftzz91.js";
39
+ } from "./index-vc1b0b1b.js";
37
40
  import {
38
41
  defineManagedResource,
39
42
  managedResourceDependencyId
@@ -52,7 +55,6 @@ import {
52
55
  projectApplicationStatus
53
56
  } from "./index-8eywc9zv.js";
54
57
  import"./index-3z73fh2c.js";
55
- import"./index-rxfy4cq7.js";
56
58
  import"./index-0w9abg87.js";
57
59
  import {
58
60
  isRecord
@@ -431,23 +433,84 @@ function createBoundedAdmission(config) {
431
433
  getSnapshot
432
434
  };
433
435
  }
436
+ // src/internal/decision.ts
437
+ import { z as z2 } from "zod";
438
+ var PolicyDecisionSchema = z2.discriminatedUnion("outcome", [
439
+ z2.object({ outcome: z2.literal("allow") }).strict(),
440
+ z2.object({ outcome: z2.literal("deny"), reason: z2.string().min(1) }).strict(),
441
+ z2.object({ outcome: z2.literal("defer") }).strict()
442
+ ]);
443
+
444
+ // src/application/decisions.ts
445
+ class DecisionUndecidedError extends Error {
446
+ trace;
447
+ constructor(trace) {
448
+ const ran = trace.length === 0 ? "no policy ran" : trace.map((e) => e.id).join(" → ");
449
+ super(`Decision pipeline reached its end with no terminal verdict (${ran}). A pipeline needs a policy that answers allow or deny.`);
450
+ this.name = "DecisionUndecidedError";
451
+ this.trace = trace;
452
+ }
453
+ }
454
+
455
+ class DecisionPolicyError extends Error {
456
+ policyId;
457
+ constructor(policyId, detail) {
458
+ super(`Policy "${policyId}" did not return a decision (${detail}). A policy returns { outcome: "allow" | "deny" | "defer" }, and a deny carries a reason.`);
459
+ this.name = "DecisionPolicyError";
460
+ this.policyId = policyId;
461
+ }
462
+ }
463
+ function createDecisionPipeline(policies) {
464
+ const seen = new Set;
465
+ for (const policy of policies) {
466
+ if (policy.id.trim() === "") {
467
+ throw new Error("[stitchkit] decision pipeline: a policy needs a non-empty id.");
468
+ }
469
+ if (seen.has(policy.id)) {
470
+ throw new Error(`[stitchkit] decision pipeline: two policies share the id "${policy.id}". The trace names policies by id, and a duplicate makes it ambiguous exactly when it is read to explain a refusal.`);
471
+ }
472
+ seen.add(policy.id);
473
+ }
474
+ return {
475
+ policyIds: policies.map((policy) => policy.id),
476
+ async decide(input) {
477
+ const trace = [];
478
+ for (const policy of policies) {
479
+ const answer = await policy.decide(input);
480
+ const parsed = PolicyDecisionSchema.safeParse(answer);
481
+ if (!parsed.success) {
482
+ throw new DecisionPolicyError(policy.id, parsed.error.issues[0]?.message ?? "invalid");
483
+ }
484
+ const decision = parsed.data;
485
+ trace.push(decision.outcome === "deny" ? { id: policy.id, outcome: "deny", reason: decision.reason } : { id: policy.id, outcome: decision.outcome });
486
+ if (decision.outcome === "deny") {
487
+ return { outcome: "deny", reason: decision.reason, trace };
488
+ }
489
+ if (decision.outcome === "allow") {
490
+ return { outcome: "allow", trace };
491
+ }
492
+ }
493
+ throw new DecisionUndecidedError(trace);
494
+ }
495
+ };
496
+ }
434
497
  // src/application/diagnostic-journal.ts
435
498
  import { randomUUID } from "node:crypto";
436
499
 
437
500
  // src/application/diagnostic-journal-contract.ts
438
- import { z as z2 } from "zod";
439
- var PositiveSafeIntegerSchema2 = z2.number().int().positive().safe();
440
- var FileModeSchema = z2.number().int().min(0).max(511);
441
- var DiagnosticJournalLimitsSchema = z2.object({
501
+ import { z as z3 } from "zod";
502
+ var PositiveSafeIntegerSchema2 = z3.number().int().positive().safe();
503
+ var FileModeSchema = z3.number().int().min(0).max(511);
504
+ var DiagnosticJournalLimitsSchema = z3.object({
442
505
  maxEventBytes: PositiveSafeIntegerSchema2,
443
506
  maxPendingItems: PositiveSafeIntegerSchema2,
444
507
  maxPendingBytes: PositiveSafeIntegerSchema2,
445
508
  maxFileBytes: PositiveSafeIntegerSchema2,
446
509
  maxFiles: PositiveSafeIntegerSchema2
447
510
  }).strict().readonly();
448
- var DiagnosticJournalLockPolicySchema = z2.enum(["refuse", "reclaim-stale"]);
449
- var DiagnosticJournalStateSchema = z2.enum(["open", "draining", "closed", "failed"]);
450
- var DiagnosticJournalRefusalReasonSchema = z2.enum([
511
+ var DiagnosticJournalLockPolicySchema = z3.enum(["refuse", "reclaim-stale"]);
512
+ var DiagnosticJournalStateSchema = z3.enum(["open", "draining", "closed", "failed"]);
513
+ var DiagnosticJournalRefusalReasonSchema = z3.enum([
451
514
  "closed",
452
515
  "failed",
453
516
  "invalid",
@@ -455,72 +518,72 @@ var DiagnosticJournalRefusalReasonSchema = z2.enum([
455
518
  "item-capacity",
456
519
  "byte-capacity"
457
520
  ]);
458
- var DiagnosticJournalRefusalCountersSchema = z2.object({
459
- closed: z2.number().int().nonnegative(),
460
- failed: z2.number().int().nonnegative(),
461
- invalid: z2.number().int().nonnegative(),
462
- oversized: z2.number().int().nonnegative(),
463
- "item-capacity": z2.number().int().nonnegative(),
464
- "byte-capacity": z2.number().int().nonnegative()
521
+ var DiagnosticJournalRefusalCountersSchema = z3.object({
522
+ closed: z3.number().int().nonnegative(),
523
+ failed: z3.number().int().nonnegative(),
524
+ invalid: z3.number().int().nonnegative(),
525
+ oversized: z3.number().int().nonnegative(),
526
+ "item-capacity": z3.number().int().nonnegative(),
527
+ "byte-capacity": z3.number().int().nonnegative()
465
528
  }).strict().readonly();
466
- var DiagnosticJournalFailurePhaseSchema = z2.enum(["write", "rotation", "close"]);
467
- var DiagnosticJournalStatusSchema = z2.object({
529
+ var DiagnosticJournalFailurePhaseSchema = z3.enum(["write", "rotation", "close"]);
530
+ var DiagnosticJournalStatusSchema = z3.object({
468
531
  state: DiagnosticJournalStateSchema,
469
- epoch: z2.uuid(),
532
+ epoch: z3.uuid(),
470
533
  limits: DiagnosticJournalLimitsSchema,
471
- lock: z2.object({
534
+ lock: z3.object({
472
535
  policy: DiagnosticJournalLockPolicySchema,
473
- reclaimedStale: z2.boolean()
536
+ reclaimedStale: z3.boolean()
474
537
  }).strict().readonly(),
475
- received: z2.number().int().nonnegative(),
476
- accepted: z2.number().int().nonnegative(),
477
- refused: z2.number().int().nonnegative(),
538
+ received: z3.number().int().nonnegative(),
539
+ accepted: z3.number().int().nonnegative(),
540
+ refused: z3.number().int().nonnegative(),
478
541
  refusals: DiagnosticJournalRefusalCountersSchema,
479
- written: z2.number().int().nonnegative(),
480
- failedRecords: z2.number().int().nonnegative(),
481
- pendingItems: z2.number().int().nonnegative(),
482
- pendingBytes: z2.number().int().nonnegative(),
483
- inFlight: z2.boolean(),
484
- rotations: z2.number().int().nonnegative(),
485
- rotationFailures: z2.number().int().nonnegative(),
486
- partialTails: z2.number().int().nonnegative(),
487
- currentFileBytes: z2.number().int().nonnegative(),
488
- retainedFiles: z2.number().int().nonnegative(),
489
- lastAcceptedSequence: z2.number().int().positive().optional(),
490
- lastWrittenSequence: z2.number().int().positive().optional(),
491
- lastSettledSequence: z2.number().int().positive().optional(),
492
- lastFailure: z2.object({
542
+ written: z3.number().int().nonnegative(),
543
+ failedRecords: z3.number().int().nonnegative(),
544
+ pendingItems: z3.number().int().nonnegative(),
545
+ pendingBytes: z3.number().int().nonnegative(),
546
+ inFlight: z3.boolean(),
547
+ rotations: z3.number().int().nonnegative(),
548
+ rotationFailures: z3.number().int().nonnegative(),
549
+ partialTails: z3.number().int().nonnegative(),
550
+ currentFileBytes: z3.number().int().nonnegative(),
551
+ retainedFiles: z3.number().int().nonnegative(),
552
+ lastAcceptedSequence: z3.number().int().positive().optional(),
553
+ lastWrittenSequence: z3.number().int().positive().optional(),
554
+ lastSettledSequence: z3.number().int().positive().optional(),
555
+ lastFailure: z3.object({
493
556
  phase: DiagnosticJournalFailurePhaseSchema,
494
- sequence: z2.number().int().positive().optional()
557
+ sequence: z3.number().int().positive().optional()
495
558
  }).strict().readonly().optional()
496
559
  }).strict().readonly();
497
- var DiagnosticJournalSubmitResultSchema = z2.discriminatedUnion("outcome", [
498
- z2.object({
499
- outcome: z2.literal("accepted"),
500
- epoch: z2.uuid(),
501
- sequence: z2.number().int().positive()
560
+ var DiagnosticJournalSubmitResultSchema = z3.discriminatedUnion("outcome", [
561
+ z3.object({
562
+ outcome: z3.literal("accepted"),
563
+ epoch: z3.uuid(),
564
+ sequence: z3.number().int().positive()
502
565
  }).strict().readonly(),
503
- z2.object({
504
- outcome: z2.literal("refused"),
566
+ z3.object({
567
+ outcome: z3.literal("refused"),
505
568
  reason: DiagnosticJournalRefusalReasonSchema
506
569
  }).strict().readonly()
507
570
  ]);
508
- var DiagnosticJournalWaitResultSchema = z2.object({
509
- outcome: z2.enum(["settled", "timed-out", "cancelled"]),
571
+ var DiagnosticJournalWaitResultSchema = z3.object({
572
+ outcome: z3.enum(["settled", "timed-out", "cancelled"]),
510
573
  state: DiagnosticJournalStateSchema,
511
- throughSequence: z2.number().int().nonnegative(),
512
- settledSequence: z2.number().int().nonnegative()
574
+ throughSequence: z3.number().int().nonnegative(),
575
+ settledSequence: z3.number().int().nonnegative()
513
576
  }).strict().readonly();
514
- var DiagnosticJournalCloseResultSchema = z2.object({
515
- outcome: z2.enum(["closed", "timed-out", "cancelled"]),
577
+ var DiagnosticJournalCloseResultSchema = z3.object({
578
+ outcome: z3.enum(["closed", "timed-out", "cancelled"]),
516
579
  state: DiagnosticJournalStateSchema,
517
- pendingItems: z2.number().int().nonnegative()
580
+ pendingItems: z3.number().int().nonnegative()
518
581
  }).strict().readonly();
519
- var DiagnosticJournalFrameSchema = z2.object({
520
- schemaVersion: z2.literal(1),
521
- epoch: z2.uuid(),
522
- sequence: z2.number().int().positive(),
523
- event: z2.json()
582
+ var DiagnosticJournalFrameSchema = z3.object({
583
+ schemaVersion: z3.literal(1),
584
+ epoch: z3.uuid(),
585
+ sequence: z3.number().int().positive(),
586
+ event: z3.json()
524
587
  }).strict().readonly();
525
588
  function parseDiagnosticJournalMode(mode) {
526
589
  return FileModeSchema.parse(mode ?? 384);
@@ -533,7 +596,7 @@ function readDiagnosticJournalLockDiagnosis(error) {
533
596
  }
534
597
 
535
598
  // src/application/diagnostic-journal-manager.ts
536
- import { z as z3 } from "zod";
599
+ import { z as z4 } from "zod";
537
600
 
538
601
  // src/application/diagnostic-journal-storage.ts
539
602
  import { constants as constants2 } from "node:fs";
@@ -1059,7 +1122,7 @@ function createDiagnosticJournalManager(config, storage) {
1059
1122
  const parsed = config.eventSchema.safeParse(event);
1060
1123
  if (!parsed.success)
1061
1124
  return refuse("invalid");
1062
- const json = z3.json().safeParse(parsed.data);
1125
+ const json = z4.json().safeParse(parsed.data);
1063
1126
  if (!json.success)
1064
1127
  return refuse("invalid");
1065
1128
  const payload = encoder.encode(JSON.stringify(json.data));
@@ -1142,17 +1205,17 @@ async function createDiagnosticJournal(config) {
1142
1205
  }, storage);
1143
1206
  }
1144
1207
  // src/application/events.ts
1145
- import { z as z4 } from "zod";
1146
- var ApplicationLifecycleEventSchema = z4.object({
1147
- type: z4.literal("application-state"),
1208
+ import { z as z5 } from "zod";
1209
+ var ApplicationLifecycleEventSchema = z5.object({
1210
+ type: z5.literal("application-state"),
1148
1211
  applicationId: ApplicationIdSchema,
1149
- epoch: z4.string().uuid(),
1150
- revision: z4.number().int().nonnegative(),
1212
+ epoch: z5.string().uuid(),
1213
+ revision: z5.number().int().nonnegative(),
1151
1214
  lifecycle: ApplicationLifecycleSchema,
1152
1215
  health: ApplicationHealthSchema,
1153
- ready: z4.boolean(),
1154
- capturedAt: z4.string().datetime({ offset: true }),
1155
- resources: z4.array(ManagedResourceSnapshotSchema).readonly()
1216
+ ready: z5.boolean(),
1217
+ capturedAt: z5.string().datetime({ offset: true }),
1218
+ resources: z5.array(ManagedResourceSnapshotSchema).readonly()
1156
1219
  }).strict().readonly();
1157
1220
  function applicationLifecycleEvent(snapshot) {
1158
1221
  return ApplicationLifecycleEventSchema.parse({
@@ -1183,13 +1246,13 @@ function createApplicationEventSink(config) {
1183
1246
  };
1184
1247
  }
1185
1248
  // src/application/health.ts
1186
- import { z as z5 } from "zod";
1187
- var ApplicationHealthHandlerOptionsSchema = z5.object({
1188
- kind: z5.enum(["liveness", "readiness"]),
1189
- retryAfterSeconds: z5.number().int().nonnegative().default(5)
1249
+ import { z as z6 } from "zod";
1250
+ var ApplicationHealthHandlerOptionsSchema = z6.object({
1251
+ kind: z6.enum(["liveness", "readiness"]),
1252
+ retryAfterSeconds: z6.number().int().nonnegative().default(5)
1190
1253
  });
1191
- var ApplicationOperationalHandlersOptionsSchema = z5.object({
1192
- retryAfterSeconds: z5.number().int().nonnegative().default(5)
1254
+ var ApplicationOperationalHandlersOptionsSchema = z6.object({
1255
+ retryAfterSeconds: z6.number().int().nonnegative().default(5)
1193
1256
  });
1194
1257
  function createApplicationHealthHandler(application, options) {
1195
1258
  const parsed = ApplicationHealthHandlerOptionsSchema.parse(options);
@@ -1431,12 +1494,12 @@ function managedServerResource(config) {
1431
1494
  });
1432
1495
  }
1433
1496
  // src/browser/resumable.ts
1434
- import { z as z6 } from "zod";
1435
- var PositiveSafeIntegerSchema3 = z6.number().int().positive().safe();
1436
- var BackoffPolicySchema = z6.object({
1497
+ import { z as z7 } from "zod";
1498
+ var PositiveSafeIntegerSchema3 = z7.number().int().positive().safe();
1499
+ var BackoffPolicySchema = z7.object({
1437
1500
  minDelayMs: PositiveSafeIntegerSchema3,
1438
1501
  maxDelayMs: PositiveSafeIntegerSchema3,
1439
- jitter: z6.number().min(0).max(1)
1502
+ jitter: z7.number().min(0).max(1)
1440
1503
  }).strict().readonly().refine((policy) => policy.maxDelayMs >= policy.minDelayMs, {
1441
1504
  message: "maxDelayMs must be at least minDelayMs"
1442
1505
  });
@@ -1457,12 +1520,12 @@ function createBackoff(policy, random = Math.random) {
1457
1520
  }
1458
1521
 
1459
1522
  // src/live/watch-contract.ts
1460
- import { z as z8 } from "zod";
1523
+ import { z as z9 } from "zod";
1461
1524
 
1462
1525
  // src/browser/live-state.ts
1463
- import { z as z7 } from "zod";
1464
- var PositiveSafeIntegerSchema4 = z7.number().int().positive().safe();
1465
- var LiveStatePhaseSchema = z7.enum([
1526
+ import { z as z8 } from "zod";
1527
+ var PositiveSafeIntegerSchema4 = z8.number().int().positive().safe();
1528
+ var LiveStatePhaseSchema = z8.enum([
1466
1529
  "idle",
1467
1530
  "opening",
1468
1531
  "live",
@@ -1470,7 +1533,7 @@ var LiveStatePhaseSchema = z7.enum([
1470
1533
  "unavailable",
1471
1534
  "closed"
1472
1535
  ]);
1473
- var LiveStateStopReasonSchema = z7.enum([
1536
+ var LiveStateStopReasonSchema = z8.enum([
1474
1537
  "gap",
1475
1538
  "buffer-overflow",
1476
1539
  "source-unavailable",
@@ -1478,42 +1541,42 @@ var LiveStateStopReasonSchema = z7.enum([
1478
1541
  "controller-error",
1479
1542
  "controller-capacity"
1480
1543
  ]);
1481
- var LiveStateControllerStatusSchema = z7.object({
1544
+ var LiveStateControllerStatusSchema = z8.object({
1482
1545
  phase: LiveStatePhaseSchema,
1483
- generation: z7.number().int().nonnegative(),
1484
- hasValue: z7.boolean(),
1485
- bufferedEvents: z7.number().int().nonnegative(),
1486
- bufferedBytes: z7.number().int().nonnegative(),
1487
- receivedEvents: z7.number().int().nonnegative(),
1488
- appliedEvents: z7.number().int().nonnegative(),
1489
- duplicateEvents: z7.number().int().nonnegative(),
1490
- gapEvents: z7.number().int().nonnegative(),
1491
- refusedEvents: z7.number().int().nonnegative(),
1546
+ generation: z8.number().int().nonnegative(),
1547
+ hasValue: z8.boolean(),
1548
+ bufferedEvents: z8.number().int().nonnegative(),
1549
+ bufferedBytes: z8.number().int().nonnegative(),
1550
+ receivedEvents: z8.number().int().nonnegative(),
1551
+ appliedEvents: z8.number().int().nonnegative(),
1552
+ duplicateEvents: z8.number().int().nonnegative(),
1553
+ gapEvents: z8.number().int().nonnegative(),
1554
+ refusedEvents: z8.number().int().nonnegative(),
1492
1555
  reason: LiveStateStopReasonSchema.optional()
1493
1556
  }).strict().readonly();
1494
1557
 
1495
1558
  // src/live/watch-contract.ts
1496
- var WatchKeySchema = z8.object({
1497
- service: z8.string().min(1),
1498
- action: z8.string().min(1),
1499
- digest: z8.string().min(1)
1559
+ var WatchKeySchema = z9.object({
1560
+ service: z9.string().min(1),
1561
+ action: z9.string().min(1),
1562
+ digest: z9.string().min(1)
1500
1563
  }).strict().readonly();
1501
- var WatchOpenSchema = z8.object({ key: WatchKeySchema, args: z8.unknown() }).readonly();
1502
- var WatchAcceptedSchema = z8.object({
1503
- accepted: z8.boolean(),
1504
- reason: z8.string().optional()
1564
+ var WatchOpenSchema = z9.object({ key: WatchKeySchema, args: z9.unknown() }).readonly();
1565
+ var WatchAcceptedSchema = z9.object({
1566
+ accepted: z9.boolean(),
1567
+ reason: z9.string().optional()
1505
1568
  }).strict().readonly();
1506
- var WatchValueSchema = z8.object({
1569
+ var WatchValueSchema = z9.object({
1507
1570
  key: WatchKeySchema,
1508
- revision: z8.number().int().nonnegative(),
1509
- value: z8.unknown()
1571
+ revision: z9.number().int().nonnegative(),
1572
+ value: z9.unknown()
1510
1573
  }).readonly();
1511
- var WatchStateSchema = z8.object({
1574
+ var WatchStateSchema = z9.object({
1512
1575
  key: WatchKeySchema,
1513
1576
  phase: LiveStatePhaseSchema,
1514
1577
  reason: LiveStateStopReasonSchema.optional(),
1515
- code: z8.string().optional(),
1516
- message: z8.string().optional()
1578
+ code: z9.string().optional(),
1579
+ message: z9.string().optional()
1517
1580
  }).readonly();
1518
1581
  var WATCH_OPEN = "stitchkit.watch.open";
1519
1582
  var WATCH_CLOSE = "stitchkit.watch.close";
@@ -1521,12 +1584,12 @@ var WATCH_VALUE = "stitchkit.watch.value";
1521
1584
  var WATCH_STATE = "stitchkit.watch.state";
1522
1585
  var watchContract = {
1523
1586
  serverToClient: {
1524
- [WATCH_VALUE]: { args: z8.tuple([WatchValueSchema]) },
1525
- [WATCH_STATE]: { args: z8.tuple([WatchStateSchema]) }
1587
+ [WATCH_VALUE]: { args: z9.tuple([WatchValueSchema]) },
1588
+ [WATCH_STATE]: { args: z9.tuple([WatchStateSchema]) }
1526
1589
  },
1527
1590
  clientToServer: {
1528
- [WATCH_OPEN]: { args: z8.tuple([WatchOpenSchema]), ack: WatchAcceptedSchema },
1529
- [WATCH_CLOSE]: { args: z8.tuple([z8.object({ key: WatchKeySchema }).readonly()]) }
1591
+ [WATCH_OPEN]: { args: z9.tuple([WatchOpenSchema]), ack: WatchAcceptedSchema },
1592
+ [WATCH_CLOSE]: { args: z9.tuple([z9.object({ key: WatchKeySchema }).readonly()]) }
1530
1593
  }
1531
1594
  };
1532
1595
  function watchKeyString(key) {
@@ -1535,12 +1598,12 @@ function watchKeyString(key) {
1535
1598
 
1536
1599
  // src/application/watch-hub.ts
1537
1600
  var DEFAULT_BACKOFF = { minDelayMs: 250, maxDelayMs: 30000, jitter: 0.2 };
1538
- async function watchKey(operation, args) {
1601
+ function watchKey(operation, args) {
1539
1602
  const record = typeof args === "object" && args !== null && !Array.isArray(args) ? args : { value: args };
1540
1603
  return {
1541
1604
  service: operation.service,
1542
1605
  action: operation.action,
1543
- digest: await argumentsDigest(record)
1606
+ digest: argumentsDigest(record)
1544
1607
  };
1545
1608
  }
1546
1609
  function createWatchHub(config) {
@@ -1757,6 +1820,7 @@ export {
1757
1820
  createWatchHub,
1758
1821
  createManagedSchedule,
1759
1822
  createDiagnosticJournal,
1823
+ createDecisionPipeline,
1760
1824
  createCreditWindow,
1761
1825
  createBoundedChannel,
1762
1826
  createBoundedAdmission,
@@ -1767,6 +1831,7 @@ export {
1767
1831
  createApplication,
1768
1832
  createActivityProjection,
1769
1833
  applicationLifecycleEvent,
1834
+ PolicyDecisionSchema,
1770
1835
  ManagedScheduleStatusSchema,
1771
1836
  ManagedScheduleOverlapSchema,
1772
1837
  ManagedScheduleErrorPolicySchema,
@@ -1783,6 +1848,8 @@ export {
1783
1848
  DiagnosticJournalFrameSchema,
1784
1849
  DiagnosticJournalFailurePhaseSchema,
1785
1850
  DiagnosticJournalCloseResultSchema,
1851
+ DecisionUndecidedError,
1852
+ DecisionPolicyError,
1786
1853
  CreditWindowSnapshotSchema,
1787
1854
  BoundedRateBudgetSchema,
1788
1855
  BoundedOperationWaitError,
@@ -1802,6 +1869,9 @@ export {
1802
1869
  ApplicationShutdownResultSchema,
1803
1870
  ApplicationShutdownOptionsSchema,
1804
1871
  ApplicationShutdownBudgetSchema,
1872
+ ApplicationRestartResultSchema,
1873
+ ApplicationRestartOutcomeSchema,
1874
+ ApplicationRestartInputSchema,
1805
1875
  ApplicationResourceShutdownSchema,
1806
1876
  ApplicationOperationalHandlersOptionsSchema,
1807
1877
  ApplicationLifecycleSchema,
package/dist/cli.js CHANGED
@@ -5,18 +5,17 @@ import {
5
5
  emitResult,
6
6
  parseCliArgs,
7
7
  pollUntilDone
8
- } from "./index-9my2n66s.js";
9
- import"./index-9c5dbr5q.js";
8
+ } from "./index-s2rchahr.js";
9
+ import"./index-k2zczx1g.js";
10
10
  import"./index-wwst0td5.js";
11
- import"./index-885chjxq.js";
12
- import"./index-k68e5jz0.js";
13
- import"./index-e0a57ymn.js";
11
+ import"./index-7qy2ex0m.js";
12
+ import"./index-s4c8wy8m.js";
13
+ import"./index-nemjkxjp.js";
14
14
  import"./index-sbdmyz75.js";
15
15
  import"./index-22by16v6.js";
16
16
  import"./index-cby4ar3v.js";
17
17
  import"./index-nt1mp8km.js";
18
- import"./index-hsz2mmk0.js";
19
- import"./index-rxfy4cq7.js";
18
+ import"./index-vj3vvpaa.js";
20
19
  import"./index-0w9abg87.js";
21
20
  import"./index-qyrqwr4c.js";
22
21
  import"./index-6k1937bx.js";
@@ -20,8 +20,7 @@ import {
20
20
  paginatedSchema,
21
21
  rateLimited,
22
22
  unauthorized
23
- } from "../index-4kp4fxvp.js";
24
- import"../index-rxfy4cq7.js";
23
+ } from "../index-f6n5n7nz.js";
25
24
  import"../index-ksp6e2ye.js";
26
25
  export {
27
26
  unauthorized,
@@ -8,7 +8,7 @@ import {
8
8
  ContractStreamFrameSchema,
9
9
  DEFAULT_CONTRACT_STREAM_FRAME_BYTES,
10
10
  parseTrailingWildcard
11
- } from "./index-hsz2mmk0.js";
11
+ } from "./index-vj3vvpaa.js";
12
12
  import {
13
13
  isRecord,
14
14
  mapObject,
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  executeToolMethod
3
- } from "./index-k68e5jz0.js";
3
+ } from "./index-s4c8wy8m.js";
4
4
  import {
5
5
  assertToolExtensionCompatible,
6
6
  mergeSchemas,
@@ -0,0 +1,45 @@
1
+ // src/internal/stable-digest.ts
2
+ function stableValue(value) {
3
+ if (Array.isArray(value))
4
+ return value.map(stableValue);
5
+ if (value === null || typeof value !== "object")
6
+ return value;
7
+ const result = {};
8
+ for (const key of Object.keys(value).sort()) {
9
+ result[key] = stableValue(Reflect.get(value, key));
10
+ }
11
+ return result;
12
+ }
13
+ function mix128(input) {
14
+ let a = 2654435769;
15
+ let b = 2246822507;
16
+ let c = 3266489909;
17
+ let d = 668265263;
18
+ for (let index = 0;index < input.length; index += 1) {
19
+ const code = input.charCodeAt(index);
20
+ a = Math.imul(a ^ code, 2246822519);
21
+ b = Math.imul(b ^ code, 3266489917);
22
+ c = Math.imul(c ^ code, 668265263);
23
+ d = Math.imul(d ^ code, 374761393);
24
+ a = a << 13 | a >>> 19;
25
+ b = b << 17 | b >>> 15;
26
+ c = c << 7 | c >>> 25;
27
+ d = d << 11 | d >>> 21;
28
+ }
29
+ a ^= b >>> 15;
30
+ b ^= c >>> 13;
31
+ c ^= d >>> 11;
32
+ d ^= a >>> 9;
33
+ return [
34
+ Math.imul(a ^ a >>> 16, 575075507) >>> 0,
35
+ Math.imul(b ^ b >>> 13, 2654435761) >>> 0,
36
+ Math.imul(c ^ c >>> 16, 2246822507) >>> 0,
37
+ Math.imul(d ^ d >>> 15, 3266489909) >>> 0
38
+ ];
39
+ }
40
+ function argumentsDigest(args) {
41
+ const lanes = mix128(JSON.stringify(stableValue(args)) ?? "undefined");
42
+ return lanes.map((lane) => lane.toString(16).padStart(8, "0")).join("");
43
+ }
44
+
45
+ export { stableValue, argumentsDigest };
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  isUnsafeKey
3
- } from "./index-hsz2mmk0.js";
3
+ } from "./index-vj3vvpaa.js";
4
4
  import {
5
5
  isRecord
6
6
  } from "./index-qyrqwr4c.js";
@@ -2,15 +2,13 @@ import {
2
2
  contextContributionDelta,
3
3
  mergeContextContribution,
4
4
  prepareContextContribution
5
- } from "./index-endzd8sj.js";
5
+ } from "./index-vbf2p6me.js";
6
6
  import {
7
+ base64UrlToBytes,
8
+ bytesToBase64Url,
7
9
  isUnsafeKey,
8
10
  safeJsonParse
9
- } from "./index-hsz2mmk0.js";
10
- import {
11
- base64UrlToBytes,
12
- bytesToBase64Url
13
- } from "./index-rxfy4cq7.js";
11
+ } from "./index-vj3vvpaa.js";
14
12
  import {
15
13
  forbidden,
16
14
  unauthorized
@@ -3,15 +3,15 @@ import {
3
3
  } from "./index-3xnq72rz.js";
4
4
  import {
5
5
  collectToolSurface
6
- } from "./index-9c5dbr5q.js";
6
+ } from "./index-k2zczx1g.js";
7
7
  import {
8
8
  createToolRunner,
9
9
  formatToolError
10
- } from "./index-885chjxq.js";
10
+ } from "./index-7qy2ex0m.js";
11
11
  import {
12
12
  isToolExecutionControlError,
13
13
  toolResultFromError
14
- } from "./index-k68e5jz0.js";
14
+ } from "./index-s4c8wy8m.js";
15
15
  import {
16
16
  isRecord
17
17
  } from "./index-qyrqwr4c.js";
@@ -1,7 +1,3 @@
1
- import {
2
- base64UrlToBytes,
3
- bytesToBase64Url
4
- } from "./index-rxfy4cq7.js";
5
1
  import {
6
2
  mapObjectTypeBoundary
7
3
  } from "./index-ksp6e2ye.js";
@@ -435,6 +431,24 @@ var ManagedFileRefSchema = z3.object({
435
431
  });
436
432
  // src/contract/pagination.ts
437
433
  import { z as z4 } from "zod";
434
+
435
+ // src/internal/base64url.ts
436
+ function bytesToBase64Url(bytes) {
437
+ let binary = "";
438
+ for (const byte of bytes)
439
+ binary += String.fromCharCode(byte);
440
+ return btoa(binary).replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "");
441
+ }
442
+ function base64UrlToBytes(segment) {
443
+ if (!/^[A-Za-z0-9_-]*$/.test(segment) || segment.length % 4 === 1) {
444
+ throw new Error("invalid base64url segment");
445
+ }
446
+ const b64 = segment.replace(/-/g, "+").replace(/_/g, "/");
447
+ const padded = b64.padEnd(Math.ceil(b64.length / 4) * 4, "=");
448
+ return Uint8Array.from(atob(padded), (c) => c.charCodeAt(0));
449
+ }
450
+
451
+ // src/contract/pagination.ts
438
452
  function paginatedSchema(itemSchema) {
439
453
  return z4.object({
440
454
  items: z4.array(itemSchema),