stitchkit 0.74.0 → 0.75.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 (77) hide show
  1. package/dist/agent-runtime/sqlite-purge.d.ts +3 -3
  2. package/dist/agent-runtime/sqlite-purge.d.ts.map +1 -1
  3. package/dist/agent-runtime/sqlite.d.ts +5 -17
  4. package/dist/agent-runtime/sqlite.d.ts.map +1 -1
  5. package/dist/agent-runtime-coding-tools.js +2 -1
  6. package/dist/agent-runtime-harness.js +5 -4
  7. package/dist/agent-runtime-sqlite-bun.d.ts +1 -1
  8. package/dist/agent-runtime-sqlite-bun.d.ts.map +1 -1
  9. package/dist/agent-runtime-sqlite-node.d.ts +1 -1
  10. package/dist/agent-runtime-sqlite-node.d.ts.map +1 -1
  11. package/dist/agent-runtime.js +8 -7
  12. package/dist/application/diagnostic-journal-lock.d.ts +14 -0
  13. package/dist/application/diagnostic-journal-lock.d.ts.map +1 -1
  14. package/dist/application/keyspace-sqlite.d.ts +31 -0
  15. package/dist/application/keyspace-sqlite.d.ts.map +1 -0
  16. package/dist/application/keyspace.d.ts +142 -0
  17. package/dist/application/keyspace.d.ts.map +1 -0
  18. package/dist/application/watch-hub.d.ts +113 -0
  19. package/dist/application/watch-hub.d.ts.map +1 -0
  20. package/dist/application.d.ts +4 -0
  21. package/dist/application.d.ts.map +1 -1
  22. package/dist/application.js +475 -3
  23. package/dist/cli.js +7 -6
  24. package/dist/contract/index.js +2 -1
  25. package/dist/{index-aczggrty.js → index-28jsdwt1.js} +1 -1
  26. package/dist/index-35z5h2ty.js +594 -0
  27. package/dist/{index-f6n5n7nz.js → index-4kp4fxvp.js} +4 -18
  28. package/dist/{index-118v0z41.js → index-52400rdd.js} +8 -3
  29. package/dist/{index-da1aqnhb.js → index-65kathdm.js} +6 -4
  30. package/dist/{index-jqtsc9mj.js → index-6wr9f6qm.js} +2 -2
  31. package/dist/{index-7qy2ex0m.js → index-885chjxq.js} +1 -1
  32. package/dist/{index-k2zczx1g.js → index-9c5dbr5q.js} +1 -1
  33. package/dist/{index-s2rchahr.js → index-9my2n66s.js} +4 -4
  34. package/dist/{index-nemjkxjp.js → index-e0a57ymn.js} +1 -1
  35. package/dist/{index-vbf2p6me.js → index-endzd8sj.js} +1 -1
  36. package/dist/{index-vj3vvpaa.js → index-hsz2mmk0.js} +1 -17
  37. package/dist/{index-s4c8wy8m.js → index-k68e5jz0.js} +2 -2
  38. package/dist/index-rxfy4cq7.js +17 -0
  39. package/dist/{index-58jzmnn4.js → index-v5dm4bwq.js} +1 -1
  40. package/dist/{index-m668wzyc.js → index-v7xjfy10.js} +1 -1
  41. package/dist/index-vdvmcy7r.js +22 -0
  42. package/dist/{index-ezmn6ac6.js → index-xgahrwdf.js} +3 -3
  43. package/dist/index.js +26 -611
  44. package/dist/internal/sqlite.d.ts +27 -0
  45. package/dist/internal/sqlite.d.ts.map +1 -0
  46. package/dist/internal/stable-digest.d.ts +24 -0
  47. package/dist/internal/stable-digest.d.ts.map +1 -0
  48. package/dist/live/events.d.ts +155 -0
  49. package/dist/live/events.d.ts.map +1 -0
  50. package/dist/live/watch-client.d.ts +66 -0
  51. package/dist/live/watch-client.d.ts.map +1 -0
  52. package/dist/live/watch-contract.d.ts +157 -0
  53. package/dist/live/watch-contract.d.ts.map +1 -0
  54. package/dist/live.d.ts +18 -0
  55. package/dist/live.d.ts.map +1 -0
  56. package/dist/live.js +284 -0
  57. package/dist/node.js +5 -4
  58. package/dist/observability/index.js +4 -3
  59. package/dist/primitives.js +2 -1
  60. package/dist/remote.js +3 -2
  61. package/dist/server/create.d.ts.map +1 -1
  62. package/dist/server/event-bus.d.ts +49 -1
  63. package/dist/server/event-bus.d.ts.map +1 -1
  64. package/dist/server/index.d.ts +2 -1
  65. package/dist/server/index.d.ts.map +1 -1
  66. package/dist/server/index.js +224 -12
  67. package/dist/server/middleware/trust-fence.d.ts +116 -0
  68. package/dist/server/middleware/trust-fence.d.ts.map +1 -0
  69. package/dist/server/types.d.ts +16 -1
  70. package/dist/server/types.d.ts.map +1 -1
  71. package/dist/testing.js +3 -2
  72. package/dist/tool-invoker.js +6 -5
  73. package/dist/tools/mcp-round.d.ts.map +1 -1
  74. package/dist/tools.js +15 -30
  75. package/llms-full.txt +417 -7
  76. package/llms.txt +1 -0
  77. package/package.json +6 -2
@@ -24,6 +24,10 @@ import {
24
24
  import {
25
25
  createBoundedSinkManager
26
26
  } from "./index-a59da114.js";
27
+ import {
28
+ argumentsDigest,
29
+ stableValue
30
+ } from "./index-vdvmcy7r.js";
27
31
  import {
28
32
  ApplicationAdmissionError,
29
33
  ApplicationShutdownBudgetSchema,
@@ -48,6 +52,7 @@ import {
48
52
  projectApplicationStatus
49
53
  } from "./index-8eywc9zv.js";
50
54
  import"./index-3z73fh2c.js";
55
+ import"./index-rxfy4cq7.js";
51
56
  import"./index-0w9abg87.js";
52
57
  import {
53
58
  isRecord
@@ -604,13 +609,30 @@ function attribute(owner, identity) {
604
609
  }
605
610
  return owner.host === hostname() ? "this-machine" : "unattributable";
606
611
  }
607
- function probeLiveness(owner) {
612
+ async function probeLiveness(owner) {
608
613
  try {
609
614
  process.kill(owner.pid, 0);
610
- return "alive";
611
615
  } catch (error) {
612
616
  return isRecord(error) && error.code === "ESRCH" ? "gone" : "alive";
613
617
  }
618
+ return await isZombieProcess(owner.pid) ? "gone" : "alive";
619
+ }
620
+ async function isZombieProcess(pid, seam = {}) {
621
+ const { procRoot = "/proc", psCommand = "ps" } = seam;
622
+ try {
623
+ const stat = await readFile(`${procRoot}/${pid}/stat`, "utf8");
624
+ return stat.slice(stat.lastIndexOf(")") + 1).trimStart().startsWith("Z");
625
+ } catch {}
626
+ try {
627
+ const { stdout } = await run(psCommand, ["-o", "state=", "-p", String(pid)], {
628
+ timeout: 2000,
629
+ maxBuffer: 1 << 16,
630
+ encoding: "utf8"
631
+ });
632
+ return stdout.trim().startsWith("Z");
633
+ } catch {
634
+ return false;
635
+ }
614
636
  }
615
637
  async function diagnose(owner, declaredIdentity) {
616
638
  if (!owner)
@@ -624,7 +646,7 @@ async function diagnose(owner, declaredIdentity) {
624
646
  };
625
647
  if (attribution !== "this-machine")
626
648
  return { attribution, liveness: "not-probed", owner: record };
627
- return { attribution, liveness: probeLiveness(owner), owner: record };
649
+ return { attribution, liveness: await probeLiveness(owner), owner: record };
628
650
  }
629
651
  async function readLockOwner(lockPath) {
630
652
  let handle;
@@ -1194,6 +1216,138 @@ function createApplicationOperationalHandlers(application, options = {}) {
1194
1216
  })
1195
1217
  };
1196
1218
  }
1219
+ // src/application/keyspace.ts
1220
+ function defineKeyspace(name, declaration) {
1221
+ if (name.trim() === "") {
1222
+ throw new Error("[stitchkit] defineKeyspace: a keyspace needs a name.");
1223
+ }
1224
+ return { name, schema: declaration.schema, key: declaration.key };
1225
+ }
1226
+ function keyspaceResource(declaration, config) {
1227
+ const maxPending = config.maxPendingWrites ?? 1024;
1228
+ const records = new Map;
1229
+ let admitting = true;
1230
+ let pending = 0;
1231
+ let chain = Promise.resolve();
1232
+ function run2(work) {
1233
+ if (!admitting) {
1234
+ return Promise.reject(new Error(`[stitchkit] keyspace "${declaration.name}" is shutting down and is not accepting writes.`));
1235
+ }
1236
+ if (pending >= maxPending) {
1237
+ return Promise.reject(new Error(`[stitchkit] keyspace "${declaration.name}": ${pending} writes are already waiting for the backend (limit ${maxPending}). The backend is not keeping up; queueing this one would trade a visible refusal for an invisible leak.`));
1238
+ }
1239
+ pending += 1;
1240
+ const queued = chain.then(work, work);
1241
+ chain = queued.then(() => {
1242
+ return;
1243
+ }, () => {
1244
+ return;
1245
+ });
1246
+ return queued.finally(() => {
1247
+ pending -= 1;
1248
+ });
1249
+ }
1250
+ const keyspace = {
1251
+ get: (key) => records.get(key),
1252
+ list: () => [...records.values()],
1253
+ get size() {
1254
+ return records.size;
1255
+ },
1256
+ put(value) {
1257
+ const parsed = declaration.schema.parse(value);
1258
+ const key = declaration.key(parsed);
1259
+ return run2(async () => {
1260
+ await config.backend.put(key, parsed);
1261
+ records.set(key, parsed);
1262
+ config.onChanged?.({
1263
+ keyspace: declaration.name,
1264
+ key,
1265
+ value: parsed,
1266
+ change: "put"
1267
+ });
1268
+ });
1269
+ },
1270
+ delete(key) {
1271
+ return run2(async () => {
1272
+ await config.backend.delete(key);
1273
+ records.delete(key);
1274
+ config.onChanged?.({ keyspace: declaration.name, key, change: "delete" });
1275
+ });
1276
+ },
1277
+ pendingWrites: () => pending
1278
+ };
1279
+ function reportUnwritten() {
1280
+ if (pending > 0)
1281
+ config.onUnwritten?.(pending);
1282
+ }
1283
+ return {
1284
+ id: config.id ?? `keyspace:${declaration.name}`,
1285
+ ...config.dependsOn && { dependsOn: config.dependsOn },
1286
+ async start(_context) {
1287
+ for (const stored of await config.backend.load()) {
1288
+ const value = declaration.schema.parse(stored);
1289
+ records.set(declaration.key(value), value);
1290
+ }
1291
+ return { value: keyspace };
1292
+ },
1293
+ stopAdmission() {
1294
+ admitting = false;
1295
+ },
1296
+ async drain() {
1297
+ await chain;
1298
+ },
1299
+ async close() {
1300
+ reportUnwritten();
1301
+ await config.backend.close?.();
1302
+ },
1303
+ force() {
1304
+ reportUnwritten();
1305
+ }
1306
+ };
1307
+ }
1308
+ function memoryKeyspaceBackend() {
1309
+ const stored = new Map;
1310
+ return {
1311
+ load: async () => [...stored.values()],
1312
+ put: async (key, value) => {
1313
+ stored.set(key, value);
1314
+ },
1315
+ delete: async (key) => {
1316
+ stored.delete(key);
1317
+ }
1318
+ };
1319
+ }
1320
+ // src/application/keyspace-sqlite.ts
1321
+ var IDENTIFIER = /^[A-Za-z_][A-Za-z0-9_]*$/;
1322
+ function sqliteKeyspaceBackend(declaration, config) {
1323
+ const table = config.table ?? `stitchkit_keyspace_${declaration.name}`;
1324
+ if (!IDENTIFIER.test(table)) {
1325
+ throw new Error(`[stitchkit] sqliteKeyspaceBackend: "${table}" is not a bare SQL identifier. A table name cannot be a bound parameter, so it is checked here rather than interpolated on trust. Pass \`table\` explicitly when the keyspace name is not identifier-shaped.`);
1326
+ }
1327
+ const database = config.database;
1328
+ if (config.initialize !== false) {
1329
+ database.exec(`CREATE TABLE IF NOT EXISTS ${table} (key TEXT PRIMARY KEY, payload TEXT NOT NULL)`);
1330
+ }
1331
+ return {
1332
+ async load() {
1333
+ const rows = database.prepare(`SELECT payload FROM ${table}`).all();
1334
+ return rows.map((row) => {
1335
+ const payload = Reflect.get(Object(row), "payload");
1336
+ if (typeof payload !== "string") {
1337
+ throw new Error(`[stitchkit] keyspace "${declaration.name}": a row in ${table} has no text payload.`);
1338
+ }
1339
+ return JSON.parse(payload);
1340
+ });
1341
+ },
1342
+ async put(key, value) {
1343
+ database.prepare(`INSERT INTO ${table} (key, payload) VALUES (?, ?)
1344
+ ON CONFLICT(key) DO UPDATE SET payload = excluded.payload`).run(key, JSON.stringify(value));
1345
+ },
1346
+ async delete(key) {
1347
+ database.prepare(`DELETE FROM ${table} WHERE key = ?`).run(key);
1348
+ }
1349
+ };
1350
+ }
1197
1351
  // src/application/server-resource.ts
1198
1352
  function managedServerResource(config) {
1199
1353
  let shutdownPromise;
@@ -1253,12 +1407,330 @@ function managedServerResource(config) {
1253
1407
  }
1254
1408
  });
1255
1409
  }
1410
+ // src/browser/resumable.ts
1411
+ import { z as z6 } from "zod";
1412
+ var PositiveSafeIntegerSchema3 = z6.number().int().positive().safe();
1413
+ var BackoffPolicySchema = z6.object({
1414
+ minDelayMs: PositiveSafeIntegerSchema3,
1415
+ maxDelayMs: PositiveSafeIntegerSchema3,
1416
+ jitter: z6.number().min(0).max(1)
1417
+ }).strict().readonly().refine((policy) => policy.maxDelayMs >= policy.minDelayMs, {
1418
+ message: "maxDelayMs must be at least minDelayMs"
1419
+ });
1420
+ function createBackoff(policy, random = Math.random) {
1421
+ const { minDelayMs, maxDelayMs, jitter } = BackoffPolicySchema.parse(policy);
1422
+ let attempt = 0;
1423
+ return {
1424
+ next() {
1425
+ const exponential = Math.min(maxDelayMs, minDelayMs * 2 ** attempt);
1426
+ attempt += 1;
1427
+ const spread = exponential * jitter * random();
1428
+ return Math.max(1, Math.round(exponential - spread));
1429
+ },
1430
+ reset() {
1431
+ attempt = 0;
1432
+ }
1433
+ };
1434
+ }
1435
+
1436
+ // src/live/watch-contract.ts
1437
+ import { z as z8 } from "zod";
1438
+
1439
+ // src/browser/live-state.ts
1440
+ import { z as z7 } from "zod";
1441
+ var PositiveSafeIntegerSchema4 = z7.number().int().positive().safe();
1442
+ var LiveStatePhaseSchema = z7.enum([
1443
+ "idle",
1444
+ "opening",
1445
+ "live",
1446
+ "resync-required",
1447
+ "unavailable",
1448
+ "closed"
1449
+ ]);
1450
+ var LiveStateStopReasonSchema = z7.enum([
1451
+ "gap",
1452
+ "buffer-overflow",
1453
+ "source-unavailable",
1454
+ "source-error",
1455
+ "controller-error",
1456
+ "controller-capacity"
1457
+ ]);
1458
+ var LiveStateControllerStatusSchema = z7.object({
1459
+ phase: LiveStatePhaseSchema,
1460
+ generation: z7.number().int().nonnegative(),
1461
+ hasValue: z7.boolean(),
1462
+ bufferedEvents: z7.number().int().nonnegative(),
1463
+ bufferedBytes: z7.number().int().nonnegative(),
1464
+ receivedEvents: z7.number().int().nonnegative(),
1465
+ appliedEvents: z7.number().int().nonnegative(),
1466
+ duplicateEvents: z7.number().int().nonnegative(),
1467
+ gapEvents: z7.number().int().nonnegative(),
1468
+ refusedEvents: z7.number().int().nonnegative(),
1469
+ reason: LiveStateStopReasonSchema.optional()
1470
+ }).strict().readonly();
1471
+
1472
+ // src/live/watch-contract.ts
1473
+ var WatchKeySchema = z8.object({
1474
+ service: z8.string().min(1),
1475
+ action: z8.string().min(1),
1476
+ digest: z8.string().min(1)
1477
+ }).strict().readonly();
1478
+ var WatchOpenSchema = z8.object({ key: WatchKeySchema, args: z8.unknown() }).readonly();
1479
+ var WatchAcceptedSchema = z8.object({
1480
+ accepted: z8.boolean(),
1481
+ reason: z8.string().optional()
1482
+ }).strict().readonly();
1483
+ var WatchValueSchema = z8.object({
1484
+ key: WatchKeySchema,
1485
+ revision: z8.number().int().nonnegative(),
1486
+ value: z8.unknown()
1487
+ }).readonly();
1488
+ var WatchStateSchema = z8.object({
1489
+ key: WatchKeySchema,
1490
+ phase: LiveStatePhaseSchema,
1491
+ reason: LiveStateStopReasonSchema.optional(),
1492
+ code: z8.string().optional(),
1493
+ message: z8.string().optional()
1494
+ }).readonly();
1495
+ var WATCH_OPEN = "stitchkit.watch.open";
1496
+ var WATCH_CLOSE = "stitchkit.watch.close";
1497
+ var WATCH_VALUE = "stitchkit.watch.value";
1498
+ var WATCH_STATE = "stitchkit.watch.state";
1499
+ var watchContract = {
1500
+ serverToClient: {
1501
+ [WATCH_VALUE]: { args: z8.tuple([WatchValueSchema]) },
1502
+ [WATCH_STATE]: { args: z8.tuple([WatchStateSchema]) }
1503
+ },
1504
+ clientToServer: {
1505
+ [WATCH_OPEN]: { args: z8.tuple([WatchOpenSchema]), ack: WatchAcceptedSchema },
1506
+ [WATCH_CLOSE]: { args: z8.tuple([z8.object({ key: WatchKeySchema }).readonly()]) }
1507
+ }
1508
+ };
1509
+ function watchKeyString(key) {
1510
+ return `${key.service}/${key.action}/${key.digest}`;
1511
+ }
1512
+
1513
+ // src/application/watch-hub.ts
1514
+ var DEFAULT_BACKOFF = { minDelayMs: 250, maxDelayMs: 30000, jitter: 0.2 };
1515
+ async function watchKey(operation, args) {
1516
+ const record = typeof args === "object" && args !== null && !Array.isArray(args) ? args : { value: args };
1517
+ return {
1518
+ service: operation.service,
1519
+ action: operation.action,
1520
+ digest: await argumentsDigest(record)
1521
+ };
1522
+ }
1523
+ function createWatchHub(config) {
1524
+ const sources = new Map;
1525
+ const held = new Map;
1526
+ const maxWatches = config.maxWatchesPerSubscriber ?? 64;
1527
+ const holdMs = config.holdMs ?? 0;
1528
+ const same = config.same ?? ((previous, next) => JSON.stringify(stableValue(previous)) === JSON.stringify(stableValue(next)));
1529
+ let reads = 0;
1530
+ let closed = false;
1531
+ function announceState(source, state) {
1532
+ source.state = state;
1533
+ for (const subscriber of source.subscribers)
1534
+ subscriber.state(state);
1535
+ }
1536
+ function publish(source, value) {
1537
+ source.revision += 1;
1538
+ source.value = value;
1539
+ const frame = { key: source.key, revision: source.revision, value };
1540
+ for (const subscriber of source.subscribers)
1541
+ subscriber.value(frame);
1542
+ }
1543
+ async function pump(source) {
1544
+ if (source.reading || closed)
1545
+ return;
1546
+ source.reading = true;
1547
+ try {
1548
+ while (source.dirty && !closed) {
1549
+ source.dirty = false;
1550
+ reads += 1;
1551
+ try {
1552
+ const value = await config.read(source.operation, source.args);
1553
+ source.backoff.reset();
1554
+ const signature = JSON.stringify(stableValue(value));
1555
+ const unchanged = source.signature !== undefined && same(source.value, value);
1556
+ source.signature = signature;
1557
+ if (!unchanged)
1558
+ publish(source, value);
1559
+ if (source.state.phase !== "live") {
1560
+ announceState(source, { key: source.key, phase: "live" });
1561
+ }
1562
+ } catch (error) {
1563
+ const code = readErrorCode(error);
1564
+ announceState(source, {
1565
+ key: source.key,
1566
+ phase: "unavailable",
1567
+ reason: "source-error",
1568
+ ...code !== undefined && { code },
1569
+ message: error instanceof Error ? error.message : String(error)
1570
+ });
1571
+ config.logger?.warn?.("[stitchkit] watched read failed", {
1572
+ key: watchKeyString(source.key),
1573
+ error
1574
+ });
1575
+ scheduleRetry(source);
1576
+ return;
1577
+ }
1578
+ }
1579
+ } finally {
1580
+ source.reading = false;
1581
+ }
1582
+ }
1583
+ function scheduleRetry(source) {
1584
+ if (closed || source.subscribers.size === 0)
1585
+ return;
1586
+ clearTimeout(source.retry);
1587
+ source.retry = setTimeout(() => {
1588
+ source.dirty = true;
1589
+ pump(source);
1590
+ }, source.backoff.next());
1591
+ source.retry.unref?.();
1592
+ }
1593
+ function acquire(operation, key, args) {
1594
+ const id = watchKeyString(key);
1595
+ const existing = sources.get(id);
1596
+ if (existing) {
1597
+ clearTimeout(existing.release);
1598
+ existing.release = undefined;
1599
+ return existing;
1600
+ }
1601
+ const source = {
1602
+ key,
1603
+ operation,
1604
+ args,
1605
+ subscribers: new Set,
1606
+ unsubscribes: [],
1607
+ revision: 0,
1608
+ reading: false,
1609
+ dirty: true,
1610
+ state: { key, phase: "opening" },
1611
+ backoff: createBackoff(config.backoff ?? DEFAULT_BACKOFF)
1612
+ };
1613
+ for (const topic of config.invalidatedBy(operation)) {
1614
+ source.unsubscribes.push(config.subscribe(topic, () => {
1615
+ source.dirty = true;
1616
+ pump(source);
1617
+ }));
1618
+ }
1619
+ sources.set(id, source);
1620
+ return source;
1621
+ }
1622
+ function release(source) {
1623
+ if (source.subscribers.size > 0)
1624
+ return;
1625
+ clearTimeout(source.retry);
1626
+ source.retry = undefined;
1627
+ const drop = () => {
1628
+ if (source.reading) {
1629
+ source.release = setTimeout(drop, 10);
1630
+ source.release.unref?.();
1631
+ return;
1632
+ }
1633
+ for (const unsubscribe of source.unsubscribes)
1634
+ unsubscribe();
1635
+ sources.delete(watchKeyString(source.key));
1636
+ };
1637
+ if (holdMs === 0) {
1638
+ drop();
1639
+ return;
1640
+ }
1641
+ source.release = setTimeout(drop, holdMs);
1642
+ source.release.unref?.();
1643
+ }
1644
+ return {
1645
+ attach(subscriber) {
1646
+ const keys = new Set;
1647
+ held.set(subscriber, keys);
1648
+ return {
1649
+ open(key, args) {
1650
+ if (closed)
1651
+ return { accepted: false, reason: "the watch hub is closed" };
1652
+ const operation = { service: key.service, action: key.action };
1653
+ if (!config.watchable(operation)) {
1654
+ return {
1655
+ accepted: false,
1656
+ reason: `${key.service}.${key.action} is not watchable`
1657
+ };
1658
+ }
1659
+ const id = watchKeyString(key);
1660
+ if (keys.has(id))
1661
+ return { accepted: true };
1662
+ if (keys.size >= maxWatches) {
1663
+ return {
1664
+ accepted: false,
1665
+ reason: `this connection is already watching ${keys.size} reads (limit ${maxWatches})`
1666
+ };
1667
+ }
1668
+ const source = acquire(operation, key, args);
1669
+ source.subscribers.add(subscriber);
1670
+ keys.add(id);
1671
+ if (source.signature !== undefined) {
1672
+ subscriber.value({ key, revision: source.revision, value: source.value });
1673
+ }
1674
+ subscriber.state(source.state);
1675
+ pump(source);
1676
+ return { accepted: true };
1677
+ },
1678
+ close(key) {
1679
+ const id = watchKeyString(key);
1680
+ if (!keys.delete(id))
1681
+ return;
1682
+ const source = sources.get(id);
1683
+ if (!source)
1684
+ return;
1685
+ source.subscribers.delete(subscriber);
1686
+ release(source);
1687
+ },
1688
+ detach() {
1689
+ for (const id of keys) {
1690
+ const source = sources.get(id);
1691
+ if (!source)
1692
+ continue;
1693
+ source.subscribers.delete(subscriber);
1694
+ release(source);
1695
+ }
1696
+ keys.clear();
1697
+ held.delete(subscriber);
1698
+ }
1699
+ };
1700
+ },
1701
+ readCount: () => reads,
1702
+ size: () => sources.size,
1703
+ close() {
1704
+ closed = true;
1705
+ for (const source of sources.values()) {
1706
+ clearTimeout(source.retry);
1707
+ clearTimeout(source.release);
1708
+ for (const unsubscribe of source.unsubscribes)
1709
+ unsubscribe();
1710
+ }
1711
+ sources.clear();
1712
+ held.clear();
1713
+ }
1714
+ };
1715
+ }
1716
+ function readErrorCode(error) {
1717
+ if (typeof error !== "object" || error === null)
1718
+ return;
1719
+ const code = Reflect.get(error, "code");
1720
+ return typeof code === "string" ? code : undefined;
1721
+ }
1256
1722
  export {
1723
+ watchKey,
1724
+ sqliteKeyspaceBackend,
1257
1725
  readDiagnosticJournalLockDiagnosis,
1258
1726
  projectApplicationStatus,
1727
+ memoryKeyspaceBackend,
1259
1728
  managedServerResource,
1260
1729
  managedResourceDependencyId,
1730
+ keyspaceResource,
1261
1731
  defineManagedResource,
1732
+ defineKeyspace,
1733
+ createWatchHub,
1262
1734
  createManagedSchedule,
1263
1735
  createDiagnosticJournal,
1264
1736
  createCreditWindow,
package/dist/cli.js CHANGED
@@ -5,17 +5,18 @@ import {
5
5
  emitResult,
6
6
  parseCliArgs,
7
7
  pollUntilDone
8
- } from "./index-s2rchahr.js";
9
- import"./index-k2zczx1g.js";
8
+ } from "./index-9my2n66s.js";
9
+ import"./index-9c5dbr5q.js";
10
10
  import"./index-wwst0td5.js";
11
- import"./index-7qy2ex0m.js";
12
- import"./index-s4c8wy8m.js";
13
- import"./index-nemjkxjp.js";
11
+ import"./index-885chjxq.js";
12
+ import"./index-k68e5jz0.js";
13
+ import"./index-e0a57ymn.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-vj3vvpaa.js";
18
+ import"./index-hsz2mmk0.js";
19
+ import"./index-rxfy4cq7.js";
19
20
  import"./index-0w9abg87.js";
20
21
  import"./index-qyrqwr4c.js";
21
22
  import"./index-6k1937bx.js";
@@ -20,7 +20,8 @@ import {
20
20
  paginatedSchema,
21
21
  rateLimited,
22
22
  unauthorized
23
- } from "../index-f6n5n7nz.js";
23
+ } from "../index-4kp4fxvp.js";
24
+ import"../index-rxfy4cq7.js";
24
25
  import"../index-ksp6e2ye.js";
25
26
  export {
26
27
  unauthorized,
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  isUnsafeKey
3
- } from "./index-vj3vvpaa.js";
3
+ } from "./index-hsz2mmk0.js";
4
4
  import {
5
5
  isRecord
6
6
  } from "./index-qyrqwr4c.js";