@hasna/todos 0.15.41 → 0.15.47

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 (45) hide show
  1. package/dashboard/dist/assets/index-BNQ4gJua.js +342 -0
  2. package/dashboard/dist/assets/index-DjzvHUWt.css +1 -0
  3. package/dashboard/dist/index.html +2 -2
  4. package/dist/cli/cloud-router.d.ts.map +1 -1
  5. package/dist/cli/components/Dashboard.d.ts +1 -1
  6. package/dist/cli/components/Dashboard.d.ts.map +1 -1
  7. package/dist/cli/components/Header.d.ts +1 -1
  8. package/dist/cli/components/Header.d.ts.map +1 -1
  9. package/dist/cli/components/ProjectList.d.ts +1 -1
  10. package/dist/cli/components/ProjectList.d.ts.map +1 -1
  11. package/dist/cli/components/SearchView.d.ts +1 -1
  12. package/dist/cli/components/SearchView.d.ts.map +1 -1
  13. package/dist/cli/components/TaskDetail.d.ts +1 -1
  14. package/dist/cli/components/TaskDetail.d.ts.map +1 -1
  15. package/dist/cli/components/TaskForm.d.ts +1 -1
  16. package/dist/cli/components/TaskForm.d.ts.map +1 -1
  17. package/dist/cli/components/TaskList.d.ts +1 -1
  18. package/dist/cli/components/TaskList.d.ts.map +1 -1
  19. package/dist/cli/index.js +521 -120
  20. package/dist/contracts.js +346 -83
  21. package/dist/db/task-graph.d.ts.map +1 -1
  22. package/dist/db/task-lifecycle.d.ts.map +1 -1
  23. package/dist/db/webhooks.d.ts.map +1 -1
  24. package/dist/index.js +499 -113
  25. package/dist/lib/instant-compare.d.ts +35 -0
  26. package/dist/lib/instant-compare.d.ts.map +1 -0
  27. package/dist/mcp/index.js +520 -119
  28. package/dist/mcp.js +5 -4
  29. package/dist/pr-groups/postgres.d.ts.map +1 -1
  30. package/dist/project-registration/postgres.d.ts.map +1 -1
  31. package/dist/project-registration.js +466 -100
  32. package/dist/registry.js +346 -83
  33. package/dist/release-provenance.json +5 -5
  34. package/dist/server/cloud.d.ts.map +1 -1
  35. package/dist/server/index.js +1179 -309
  36. package/dist/storage/local-sqlite.d.ts.map +1 -1
  37. package/dist/storage/postgres-adapter.d.ts.map +1 -1
  38. package/dist/storage.js +447 -89
  39. package/dist/task-manifest/postgres.d.ts.map +1 -1
  40. package/dist/task-manifest.js +15 -6
  41. package/dist/task-subtree-transfer/postgres.d.ts.map +1 -1
  42. package/dist/task-subtree-transfer.js +15 -6
  43. package/package.json +5 -4
  44. package/dashboard/dist/assets/index-DJm6m6Yy.css +0 -1
  45. package/dashboard/dist/assets/index-DVotjwab.js +0 -346
@@ -70,7 +70,7 @@ var package_default;
70
70
  var init_package = __esm(() => {
71
71
  package_default = {
72
72
  name: "@hasna/todos",
73
- version: "0.15.41",
73
+ version: "0.15.47",
74
74
  description: "Universal task management for AI coding agents - CLI + MCP server + interactive TUI",
75
75
  type: "module",
76
76
  main: "dist/index.js",
@@ -188,18 +188,19 @@ var init_package = __esm(() => {
188
188
  author: "Andrei Hasna <andrei@hasna.com>",
189
189
  license: "Apache-2.0",
190
190
  dependencies: {
191
- "@hasna/contracts": "0.13.3",
191
+ "@hasna/contracts": "0.13.4",
192
192
  "@hasna/events": "^0.1.11",
193
193
  "@modelcontextprotocol/sdk": "^1.12.1",
194
194
  chalk: "^5.4.1",
195
195
  commander: "^13.1.0",
196
196
  ink: "^5.2.0",
197
197
  react: "^18.3.1",
198
- zod: "^3.24.2"
198
+ zod: "3.25.76"
199
199
  },
200
200
  overrides: {
201
201
  ajv: "8.20.0",
202
- "fast-uri": "3.1.2"
202
+ "fast-uri": "3.1.2",
203
+ zod: "3.25.76"
203
204
  },
204
205
  devDependencies: {
205
206
  "@types/bun": "^1.2.4",
@@ -223,7 +224,7 @@ var init_package_version = __esm(() => {
223
224
  init_package();
224
225
  });
225
226
 
226
- // node_modules/.bun/@hasna+contracts@0.13.3+86f0f4a9d69523e0/node_modules/@hasna/contracts/dist/auth/index.js
227
+ // node_modules/.bun/@hasna+contracts@0.13.4+ad7b1171e6eea7eb/node_modules/@hasna/contracts/dist/auth/index.js
227
228
  import { createHash, createHmac, randomBytes, timingSafeEqual } from "crypto";
228
229
  function isValidTenantId(value) {
229
230
  return typeof value === "string" && TENANT_ID_PATTERN.test(value);
@@ -1385,6 +1386,60 @@ var init_creator_identity = __esm(() => {
1385
1386
  init_sync_utils();
1386
1387
  });
1387
1388
 
1389
+ // src/lib/instant-compare.ts
1390
+ function isLeapYear(year) {
1391
+ return year % 4 === 0 && year % 100 !== 0 || year % 400 === 0;
1392
+ }
1393
+ function sqliteJulianDay(value) {
1394
+ const m = SQLITE_STAMP.exec(value);
1395
+ if (!m)
1396
+ return null;
1397
+ const year = Number(m[1]);
1398
+ const month = Number(m[2]);
1399
+ const day = Number(m[3]);
1400
+ const hour = m[4] === undefined ? 0 : Number(m[4]);
1401
+ const minute = m[5] === undefined ? 0 : Number(m[5]);
1402
+ const second = m[6] === undefined ? 0 : Number(m[6]);
1403
+ const frac = m[7];
1404
+ const sign = m[8];
1405
+ const offsetHour = m[9];
1406
+ const offsetMinute = m[10];
1407
+ if (month < 1 || month > 12)
1408
+ return null;
1409
+ if (hour > 23 || minute > 59 || second > 59)
1410
+ return null;
1411
+ const maxDay = (DAYS_IN_MONTH[month - 1] ?? 0) + (month === 2 && isLeapYear(year) ? 1 : 0);
1412
+ if (day < 1 || day > maxDay)
1413
+ return null;
1414
+ let offsetMinutes = 0;
1415
+ if (sign !== undefined) {
1416
+ const oh = Number(offsetHour ?? "0");
1417
+ const om = Number(offsetMinute ?? "0");
1418
+ if (oh > 23 || om > 59)
1419
+ return null;
1420
+ offsetMinutes = oh * 60 + om;
1421
+ if (sign === "-")
1422
+ offsetMinutes = -offsetMinutes;
1423
+ }
1424
+ const micros = frac === undefined ? 0 : Number((frac + "000000").slice(0, 6));
1425
+ const ms = Date.UTC(year, month - 1, day, hour, minute, second);
1426
+ return (ms + micros / 1000) / 86400000 + 2440587.5 - offsetMinutes / 1440;
1427
+ }
1428
+ function changedSinceStampNewer(stamp, since) {
1429
+ const stampJd = sqliteJulianDay(stamp);
1430
+ if (stampJd === null)
1431
+ return true;
1432
+ const sinceJd = sqliteJulianDay(since);
1433
+ if (sinceJd === null)
1434
+ return false;
1435
+ return stampJd > sinceJd;
1436
+ }
1437
+ var SQLITE_STAMP, DAYS_IN_MONTH;
1438
+ var init_instant_compare = __esm(() => {
1439
+ SQLITE_STAMP = /^(\d{4})-(\d{2})-(\d{2})(?:[ T](\d{2}):(\d{2})(?::(\d{2})(?:\.(\d+))?)?(?:Z|([+-])(\d{2}):(\d{2}))?)?$/;
1440
+ DAYS_IN_MONTH = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
1441
+ });
1442
+
1388
1443
  // src/lib/plan-project-link-contract.ts
1389
1444
  import { createHash as createHash2 } from "crypto";
1390
1445
  function canonicalPlanProjectLinkJson(value) {
@@ -2898,11 +2953,18 @@ class PostgresJsonRecordStore {
2898
2953
  return context?.requestId ?? this.sourceMachineId ?? null;
2899
2954
  }
2900
2955
  async ensureSchema() {
2901
- this.schemaReady ??= (async () => {
2902
- for (const sql of postgresTodosSyncSchemaSql(this.tableName, this.cursorTableName)) {
2903
- await this.options.client.query(sql);
2904
- }
2905
- })();
2956
+ if (!this.schemaReady) {
2957
+ this.schemaReady = (async () => {
2958
+ await retryOnTransientPostgresError(async () => {
2959
+ for (const sql of postgresTodosSyncSchemaSql(this.tableName, this.cursorTableName)) {
2960
+ await this.options.client.query(sql);
2961
+ }
2962
+ });
2963
+ })().catch((error) => {
2964
+ this.schemaReady = null;
2965
+ throw error;
2966
+ });
2967
+ }
2906
2968
  await this.schemaReady;
2907
2969
  }
2908
2970
  async get(type, id) {
@@ -3311,13 +3373,14 @@ class PostgresJsonRecordStore {
3311
3373
  throw new Error(divergentAuditHistoryReplayError(value.id));
3312
3374
  }
3313
3375
  async withTaskParentIntegrityTransaction(fn) {
3314
- if (typeof this.options.client.transaction !== "function") {
3376
+ const transaction = this.options.client.transaction;
3377
+ if (typeof transaction !== "function") {
3315
3378
  throw new Error("TASK_PARENT_ATOMICITY_UNAVAILABLE: PostgreSQL parent writes and task deletion require transaction(callback)");
3316
3379
  }
3317
- return this.options.client.transaction(async (client) => {
3380
+ return retryOnTransientPostgresError(() => transaction(async (client) => {
3318
3381
  await client.query("/* todos:task-parent-integrity-lock */ SELECT pg_advisory_xact_lock(hashtextextended($1 || ':task-parent-integrity', 0))", [this.service]);
3319
3382
  return fn(client);
3320
- });
3383
+ }));
3321
3384
  }
3322
3385
  async upsertTaskWithPlanMembershipGuard(value, guardedPlanIds, explicitProject, context = {}, parentGuard, queryClient) {
3323
3386
  const planIds = [...new Set(guardedPlanIds.filter(Boolean))].sort();
@@ -4664,7 +4727,7 @@ async function getActiveWork(filters, store) {
4664
4727
  }));
4665
4728
  }
4666
4729
  async function getChangedSince(since, filters, store) {
4667
- return (await listTasks(filters ?? {}, store)).filter((task) => task.updated_at > since);
4730
+ return (await listTasks(filters ?? {}, store)).filter((task) => changedSinceStampNewer(task.updated_at ?? "", since));
4668
4731
  }
4669
4732
  async function createProject(input, store, context) {
4670
4733
  const timestamp = new Date().toISOString();
@@ -5200,6 +5263,35 @@ function compareClock(left, right) {
5200
5263
  function numberValue2(value) {
5201
5264
  return typeof value === "number" && Number.isSafeInteger(value) ? value : null;
5202
5265
  }
5266
+ function isTransientPostgresError(error) {
5267
+ if (typeof error !== "object" || error === null)
5268
+ return false;
5269
+ const candidate = error;
5270
+ const states = [candidate.code, candidate.errno, candidate.sqlState, candidate.sqlstate];
5271
+ if (typeof candidate.cause === "object" && candidate.cause !== null) {
5272
+ const cause = candidate.cause;
5273
+ states.push(cause.code, cause.errno, cause.sqlState, cause.sqlstate);
5274
+ }
5275
+ if (states.some((state) => typeof state === "string" && TRANSIENT_POSTGRES_SQLSTATES.has(state))) {
5276
+ return true;
5277
+ }
5278
+ const message = typeof candidate.message === "string" ? candidate.message : candidate.cause?.message;
5279
+ return typeof message === "string" && TRANSIENT_POSTGRES_MESSAGE_MARKERS.some((marker) => message.includes(marker));
5280
+ }
5281
+ async function retryOnTransientPostgresError(fn, attempts = 2, delayMs = 150) {
5282
+ let lastError;
5283
+ for (let attempt = 1;attempt <= attempts; attempt += 1) {
5284
+ try {
5285
+ return await fn();
5286
+ } catch (error) {
5287
+ lastError = error;
5288
+ if (!isTransientPostgresError(error) || attempt === attempts)
5289
+ throw error;
5290
+ await new Promise((resolve) => setTimeout(resolve, delayMs * attempt));
5291
+ }
5292
+ }
5293
+ throw lastError;
5294
+ }
5203
5295
  function isPostgresUniqueViolation(error) {
5204
5296
  if (typeof error !== "object" || error === null)
5205
5297
  return false;
@@ -5219,10 +5311,11 @@ function postgresConstraintName(error) {
5219
5311
  const constraint = candidate.constraint ?? candidate.constraint_name ?? cause?.constraint ?? cause?.constraint_name;
5220
5312
  return typeof constraint === "string" ? constraint : "";
5221
5313
  }
5222
- var CLOUD_LOCK_EXPIRY_MINUTES = 30, TASK_ORDER_TIEBREAK = "CASE payload->>'priority' WHEN 'critical' THEN 0 WHEN 'high' THEN 1 WHEN 'medium' THEN 2 WHEN 'low' THEN 3 ELSE 4 END ASC, payload->>'created_at' ASC, payload->>'id' ASC", TASK_ORDER_BY;
5314
+ var CLOUD_LOCK_EXPIRY_MINUTES = 30, TASK_ORDER_TIEBREAK = "CASE payload->>'priority' WHEN 'critical' THEN 0 WHEN 'high' THEN 1 WHEN 'medium' THEN 2 WHEN 'low' THEN 3 ELSE 4 END ASC, payload->>'created_at' ASC, payload->>'id' ASC", TASK_ORDER_BY, TRANSIENT_POSTGRES_SQLSTATES, TRANSIENT_POSTGRES_MESSAGE_MARKERS;
5223
5315
  var init_postgres_adapter = __esm(() => {
5224
5316
  init_types();
5225
5317
  init_creator_identity();
5318
+ init_instant_compare();
5226
5319
  init_plan_project_link_contract();
5227
5320
  init_stale_lock_handoff();
5228
5321
  init_postgres_sync();
@@ -5232,6 +5325,12 @@ var init_postgres_adapter = __esm(() => {
5232
5325
  init_audit_history_import();
5233
5326
  init_canonical();
5234
5327
  TASK_ORDER_BY = `ORDER BY ${TASK_ORDER_TIEBREAK}`;
5328
+ TRANSIENT_POSTGRES_SQLSTATES = new Set(["55P03", "40P01", "40001"]);
5329
+ TRANSIENT_POSTGRES_MESSAGE_MARKERS = [
5330
+ "canceling statement due to lock timeout",
5331
+ "deadlock detected",
5332
+ "could not serialize access"
5333
+ ];
5235
5334
  });
5236
5335
 
5237
5336
  // src/pr-groups/types.ts
@@ -7054,10 +7153,19 @@ class PostgresPrGroupLedgerPersistence {
7054
7153
  this.client = client;
7055
7154
  }
7056
7155
  async ensureSchema() {
7057
- this.schemaReady ??= (async () => {
7058
- for (const statement of postgresPrGroupSchemaSql())
7059
- await this.client.query(statement);
7060
- })();
7156
+ if (this.schemaReady === null) {
7157
+ const attempt = (async () => {
7158
+ for (const statement of postgresPrGroupSchemaSql())
7159
+ await this.client.query(statement);
7160
+ })();
7161
+ this.schemaReady = attempt;
7162
+ try {
7163
+ await attempt;
7164
+ } catch (error) {
7165
+ this.schemaReady = null;
7166
+ throw error;
7167
+ }
7168
+ }
7061
7169
  return this.schemaReady;
7062
7170
  }
7063
7171
  async transaction(fn) {
@@ -7702,14 +7810,23 @@ class PostgresTodosProjectRegistrationBackend {
7702
7810
  this.cursorTableName = safeIdentifier(options.cursorTableName ?? "todos_sync_cursors", "cursorTableName");
7703
7811
  }
7704
7812
  async ensureSchema() {
7705
- this.schemaReady ??= (async () => {
7706
- for (const statement of postgresTodosSyncSchemaSql(this.tableName, this.cursorTableName)) {
7707
- await this.client.query(statement);
7708
- }
7709
- for (const statement of postgresTodosProjectRegistrationSchemaSql()) {
7710
- await this.client.query(statement);
7813
+ if (this.schemaReady === null) {
7814
+ const attempt = (async () => {
7815
+ for (const statement of postgresTodosSyncSchemaSql(this.tableName, this.cursorTableName)) {
7816
+ await this.client.query(statement);
7817
+ }
7818
+ for (const statement of postgresTodosProjectRegistrationSchemaSql()) {
7819
+ await this.client.query(statement);
7820
+ }
7821
+ })();
7822
+ this.schemaReady = attempt;
7823
+ try {
7824
+ await attempt;
7825
+ } catch (error) {
7826
+ this.schemaReady = null;
7827
+ throw error;
7711
7828
  }
7712
- })();
7829
+ }
7713
7830
  await this.schemaReady;
7714
7831
  }
7715
7832
  async transaction(fn) {
@@ -13167,8 +13284,9 @@ var init_event_hooks = __esm(() => {
13167
13284
  VALID_TARGETS = new Set(["stdout", "file", "socket", "script"]);
13168
13285
  });
13169
13286
 
13170
- // node_modules/.bun/@hasna+events@0.1.11/node_modules/@hasna/events/dist/index.js
13287
+ // node_modules/.bun/@hasna+events@0.1.16/node_modules/@hasna/events/dist/index.js
13171
13288
  import { chmod, mkdir, readFile, rename, writeFile } from "fs/promises";
13289
+ import { Buffer as Buffer2 } from "buffer";
13172
13290
  import { existsSync as existsSync6 } from "fs";
13173
13291
  import { homedir as homedir2 } from "os";
13174
13292
  import { join as join5 } from "path";
@@ -13277,11 +13395,13 @@ function getEventsDataDir(override) {
13277
13395
 
13278
13396
  class JsonEventsStore {
13279
13397
  dataDir;
13398
+ runtime;
13280
13399
  channelsPath;
13281
13400
  eventsPath;
13282
13401
  deliveriesPath;
13283
13402
  constructor(dataDir = getEventsDataDir()) {
13284
13403
  this.dataDir = dataDir;
13404
+ this.runtime = localJsonRuntime(dataDir);
13285
13405
  this.channelsPath = join5(dataDir, "channels.json");
13286
13406
  this.eventsPath = join5(dataDir, "events.json");
13287
13407
  this.deliveriesPath = join5(dataDir, "deliveries.json");
@@ -13329,13 +13449,58 @@ class JsonEventsStore {
13329
13449
  await this.writeJson(this.eventsPath, events);
13330
13450
  return event;
13331
13451
  }
13332
- async listEvents() {
13452
+ async appendEventOnce(event, options = {}) {
13453
+ await this.init();
13454
+ const events = await this.readJson(this.eventsPath, []);
13455
+ const dedupe = options.dedupe !== false;
13456
+ if (dedupe) {
13457
+ const existing = findEventByIdentity(events, { id: event.id, dedupeKey: event.dedupeKey });
13458
+ if (existing) {
13459
+ return {
13460
+ event: existing,
13461
+ stored: false,
13462
+ deduped: true,
13463
+ identity: { id: existing.id, dedupeKey: existing.dedupeKey }
13464
+ };
13465
+ }
13466
+ }
13467
+ events.push(event);
13468
+ await this.writeJson(this.eventsPath, events);
13469
+ return {
13470
+ event,
13471
+ stored: true,
13472
+ deduped: false,
13473
+ identity: { id: event.id, dedupeKey: event.dedupeKey }
13474
+ };
13475
+ }
13476
+ async listEvents(options = {}) {
13333
13477
  await this.init();
13334
- return this.readJson(this.eventsPath, []);
13478
+ const events = await this.readJson(this.eventsPath, []);
13479
+ return queryEvents(events, options);
13480
+ }
13481
+ async listEventsPage(options = {}) {
13482
+ await this.init();
13483
+ const events = await this.readJson(this.eventsPath, []);
13484
+ const queried = queryEvents(events, {
13485
+ eventId: options.eventId,
13486
+ source: options.source,
13487
+ type: options.type
13488
+ });
13489
+ const offset = decodeLocalJsonEventCursor(options.cursor, options);
13490
+ const limit = normalizeEventPageLimit(options.limit);
13491
+ const pageEvents = queried.slice(offset, offset + limit);
13492
+ const nextOffset = offset + pageEvents.length;
13493
+ const hasMore = nextOffset < queried.length;
13494
+ return {
13495
+ events: pageEvents,
13496
+ cursor: options.cursor,
13497
+ nextCursor: hasMore ? encodeLocalJsonEventCursor(nextOffset, options) : undefined,
13498
+ hasMore
13499
+ };
13335
13500
  }
13336
13501
  async findEventByIdentity(identity) {
13337
13502
  const events = await this.listEvents();
13338
- return events.find((event) => identity.id !== undefined && event.id === identity.id || identity.dedupeKey !== undefined && event.dedupeKey === identity.dedupeKey);
13503
+ return findEventByIdentity(events, identity);
13339
13504
  }
13340
13505
  async appendDelivery(result) {
13341
13506
  await this.init();
@@ -13386,6 +13551,83 @@ class JsonEventsStore {
13386
13551
  });
13387
13552
  }
13388
13553
  }
13554
+ function localJsonRuntime(dataDir = getEventsDataDir()) {
13555
+ return {
13556
+ mode: "local-files",
13557
+ name: "json-events-store",
13558
+ remote: false,
13559
+ localFiles: true,
13560
+ localSqlite: false,
13561
+ postgres: false,
13562
+ s3: false,
13563
+ aws: false,
13564
+ durable: true,
13565
+ idempotency: "best-effort-local",
13566
+ replayCursors: true,
13567
+ description: `Local JSON files in ${dataDir}; no SQLite, Postgres, S3, or AWS runtime is configured by this store.`
13568
+ };
13569
+ }
13570
+ function encodeLocalJsonEventCursor(offset, options = {}) {
13571
+ if (!Number.isInteger(offset) || offset < 0)
13572
+ throw new Error(`Invalid event cursor offset: ${offset}`);
13573
+ const payload = {
13574
+ offset,
13575
+ eventId: options.eventId,
13576
+ source: options.source,
13577
+ type: options.type
13578
+ };
13579
+ return `${LOCAL_JSON_EVENT_CURSOR_PREFIX}${Buffer2.from(JSON.stringify(payload), "utf-8").toString("base64url")}`;
13580
+ }
13581
+ function decodeLocalJsonEventCursor(cursor, options = {}) {
13582
+ if (!cursor)
13583
+ return 0;
13584
+ if (!cursor.startsWith(LOCAL_JSON_EVENT_CURSOR_PREFIX))
13585
+ throw new Error(`Invalid local JSON event cursor: ${cursor}`);
13586
+ const rawPayload = cursor.slice(LOCAL_JSON_EVENT_CURSOR_PREFIX.length);
13587
+ let payload;
13588
+ try {
13589
+ payload = JSON.parse(Buffer2.from(rawPayload, "base64url").toString("utf-8"));
13590
+ } catch {
13591
+ throw new Error(`Invalid local JSON event cursor: ${cursor}`);
13592
+ }
13593
+ const offset = payload.offset;
13594
+ if (!Number.isInteger(offset) || offset < 0)
13595
+ throw new Error(`Invalid local JSON event cursor: ${cursor}`);
13596
+ assertCursorFilter("eventId", payload.eventId, options.eventId);
13597
+ assertCursorFilter("source", payload.source, options.source);
13598
+ assertCursorFilter("type", payload.type, options.type);
13599
+ return offset;
13600
+ }
13601
+ function normalizeEventPageLimit(limit) {
13602
+ if (limit === undefined)
13603
+ return DEFAULT_EVENT_PAGE_LIMIT;
13604
+ if (!Number.isInteger(limit) || limit < 1)
13605
+ throw new Error(`Event page limit must be a positive integer, got ${limit}`);
13606
+ return Math.min(limit, MAX_EVENT_PAGE_LIMIT);
13607
+ }
13608
+ function queryEvents(events, options) {
13609
+ let rows = events;
13610
+ if (options.eventId)
13611
+ rows = rows.filter((event) => event.id === options.eventId);
13612
+ if (options.source)
13613
+ rows = rows.filter((event) => event.source === options.source);
13614
+ if (options.type)
13615
+ rows = rows.filter((event) => event.type === options.type);
13616
+ if (options.cursor) {
13617
+ const offset = decodeLocalJsonEventCursor(options.cursor, options);
13618
+ rows = rows.slice(offset);
13619
+ }
13620
+ if (options.limit !== undefined)
13621
+ rows = rows.slice(0, normalizeEventPageLimit(options.limit));
13622
+ return rows;
13623
+ }
13624
+ function assertCursorFilter(name, cursorValue, optionValue) {
13625
+ if (cursorValue !== optionValue)
13626
+ throw new Error(`Local JSON event cursor ${name} filter mismatch`);
13627
+ }
13628
+ function findEventByIdentity(events, identity) {
13629
+ return events.find((event) => identity.id !== undefined && event.id === identity.id || identity.dedupeKey !== undefined && event.dedupeKey === identity.dedupeKey);
13630
+ }
13389
13631
  function buildSignatureBase(timestamp2, body) {
13390
13632
  return `${timestamp2}.${body}`;
13391
13633
  }
@@ -13399,21 +13641,27 @@ function now2() {
13399
13641
  function truncate(value, max = 4096) {
13400
13642
  return value.length > max ? `${value.slice(0, max)}...` : value;
13401
13643
  }
13402
- function buildWebhookRequest(event, channel) {
13644
+ function buildWebhookRequest(event, channel, options = {}) {
13403
13645
  if (!channel.webhook)
13404
13646
  throw new Error(`Channel ${channel.id} has no webhook config`);
13647
+ for (const name of Object.keys(channel.webhook.headers ?? {})) {
13648
+ if (/^x-hasna-/i.test(name)) {
13649
+ throw new Error(`Webhook header ${name} is reserved for signed delivery metadata`);
13650
+ }
13651
+ }
13405
13652
  const body = JSON.stringify(event);
13406
- const timestamp2 = event.time;
13653
+ const timestamp2 = options.timestamp ?? new Date().toISOString();
13407
13654
  const headers = {
13408
13655
  "Content-Type": "application/json",
13409
13656
  "User-Agent": "@hasna/events",
13410
13657
  "X-Hasna-Event-Id": event.id,
13411
13658
  "X-Hasna-Event-Type": event.type,
13412
- "X-Hasna-Timestamp": timestamp2,
13413
- ...channel.webhook.headers
13659
+ ...channel.webhook.headers,
13660
+ "X-Hasna-Timestamp": timestamp2
13414
13661
  };
13415
- if (channel.webhook.secret) {
13416
- headers["X-Hasna-Signature"] = signPayload(channel.webhook.secret, timestamp2, body);
13662
+ const secret = options.secret ?? channel.webhook.secret;
13663
+ if (secret) {
13664
+ headers["X-Hasna-Signature"] = signPayload(secret, timestamp2, body);
13417
13665
  }
13418
13666
  return { body, headers };
13419
13667
  }
@@ -13421,7 +13669,21 @@ async function dispatchWebhook(event, channel, options = {}) {
13421
13669
  if (!channel.webhook)
13422
13670
  throw new Error(`Channel ${channel.id} has no webhook config`);
13423
13671
  const startedAt = now2();
13424
- const { body, headers } = buildWebhookRequest(event, channel);
13672
+ let secret = channel.webhook.secret;
13673
+ if (channel.webhook.secretRef) {
13674
+ if (!options.secretResolver) {
13675
+ return failedAttempt(startedAt, "Webhook secret reference has no runtime resolver");
13676
+ }
13677
+ try {
13678
+ secret = await options.secretResolver(channel.webhook.secretRef);
13679
+ } catch {
13680
+ return failedAttempt(startedAt, "Webhook secret reference could not be resolved");
13681
+ }
13682
+ if (!secret)
13683
+ return failedAttempt(startedAt, "Webhook secret reference could not be resolved");
13684
+ }
13685
+ const timestamp2 = (options.now?.() ?? new Date).toISOString();
13686
+ const { body, headers } = buildWebhookRequest(event, channel, { secret, timestamp: timestamp2 });
13425
13687
  const controller = new AbortController;
13426
13688
  const timeout = setTimeout(() => controller.abort(), channel.webhook.timeoutMs ?? 15000);
13427
13689
  try {
@@ -13453,6 +13715,15 @@ async function dispatchWebhook(event, channel, options = {}) {
13453
13715
  clearTimeout(timeout);
13454
13716
  }
13455
13717
  }
13718
+ function failedAttempt(startedAt, error) {
13719
+ return {
13720
+ attempt: 1,
13721
+ status: "failed",
13722
+ startedAt,
13723
+ completedAt: now2(),
13724
+ error
13725
+ };
13726
+ }
13456
13727
  async function dispatchCommand(event, channel) {
13457
13728
  if (!channel.command)
13458
13729
  throw new Error(`Channel ${channel.id} has no command config`);
@@ -13541,6 +13812,76 @@ function createDeliveryResult(event, channel, attempts) {
13541
13812
  completedAt: attempts.at(-1)?.completedAt ?? now2()
13542
13813
  };
13543
13814
  }
13815
+
13816
+ class EventTypeCatalog {
13817
+ definitions = new Map;
13818
+ register(definition) {
13819
+ this.definitions.set(definition.type, definition);
13820
+ return this;
13821
+ }
13822
+ unregister(type) {
13823
+ return this.definitions.delete(type);
13824
+ }
13825
+ has(type) {
13826
+ return this.definitions.has(type);
13827
+ }
13828
+ get(type) {
13829
+ return this.definitions.get(type);
13830
+ }
13831
+ list() {
13832
+ return [...this.definitions.values()];
13833
+ }
13834
+ validateEvent(event) {
13835
+ const definition = this.definitions.get(event.type);
13836
+ if (!definition)
13837
+ return { ok: true };
13838
+ return definition.validate(event.data, event);
13839
+ }
13840
+ assertEventValid(event) {
13841
+ const result = this.validateEvent(event);
13842
+ if (!result.ok) {
13843
+ throw new EventValidationError(event.type, result.issues);
13844
+ }
13845
+ }
13846
+ }
13847
+ function redactPaths(event, paths, replacement = "[REDACTED]") {
13848
+ if (paths.length === 0)
13849
+ return event;
13850
+ const copy = structuredClone(event);
13851
+ for (const path of paths) {
13852
+ setPath(copy, path, replacement);
13853
+ }
13854
+ return copy;
13855
+ }
13856
+ function redactSensitiveKeys(event, replacement = "[REDACTED]") {
13857
+ return redactValue2(event, replacement);
13858
+ }
13859
+ function shouldRedactKey(key) {
13860
+ return /secret|token|password|api[_-]?key|authorization/i.test(key);
13861
+ }
13862
+ function redactValue2(value, replacement) {
13863
+ if (Array.isArray(value))
13864
+ return value.map((item) => redactValue2(item, replacement));
13865
+ if (!value || typeof value !== "object")
13866
+ return value;
13867
+ return Object.fromEntries(Object.entries(value).map(([key, item]) => [
13868
+ key,
13869
+ shouldRedactKey(key) ? replacement : redactValue2(item, replacement)
13870
+ ]));
13871
+ }
13872
+ function setPath(input, path, replacement) {
13873
+ const parts = path.split(".");
13874
+ let cursor = input;
13875
+ for (const part of parts.slice(0, -1)) {
13876
+ const next = cursor[part];
13877
+ if (!next || typeof next !== "object")
13878
+ return;
13879
+ cursor = next;
13880
+ }
13881
+ const last = parts.at(-1);
13882
+ if (last && last in cursor)
13883
+ cursor[last] = replacement;
13884
+ }
13544
13885
  function createEvent(input) {
13545
13886
  return {
13546
13887
  id: input.id ?? randomUUID22(),
@@ -13561,10 +13902,18 @@ class EventsClient {
13561
13902
  store;
13562
13903
  redactors;
13563
13904
  transportOptions;
13905
+ catalog;
13906
+ validateCatalogTypes;
13564
13907
  constructor(options = {}) {
13565
13908
  this.store = options.store ?? new JsonEventsStore(options.dataDir);
13566
13909
  this.redactors = options.redactors ?? [];
13567
- this.transportOptions = { fetchImpl: options.fetchImpl };
13910
+ this.transportOptions = {
13911
+ fetchImpl: options.fetchImpl,
13912
+ secretResolver: options.secretResolver,
13913
+ now: options.now
13914
+ };
13915
+ this.catalog = options.catalog ?? defaultEventTypeCatalog;
13916
+ this.validateCatalogTypes = options.validateCatalogTypes ?? false;
13568
13917
  }
13569
13918
  async addChannel(input) {
13570
13919
  const timestamp2 = new Date().toISOString();
@@ -13582,18 +13931,40 @@ class EventsClient {
13582
13931
  }
13583
13932
  async emit(input, options = {}) {
13584
13933
  const event = options.redactSensitiveData === false ? createEvent(input) : redactSensitiveKeys(createEvent(input));
13585
- if (options.dedupe !== false) {
13586
- const existing = await this.store.findEventByIdentity({ id: input.id, dedupeKey: event.dedupeKey });
13587
- if (existing) {
13588
- return { event: existing, deliveries: [], deduped: true };
13589
- }
13590
- }
13591
- await this.store.appendEvent(event);
13592
- const deliveries = options.deliver === false ? [] : await this.deliver(event);
13593
- return { event, deliveries, deduped: false };
13594
- }
13595
- async listEvents() {
13596
- return this.store.listEvents();
13934
+ if (options.validate ?? this.validateCatalogTypes) {
13935
+ this.catalog.assertEventValid(event);
13936
+ }
13937
+ const append = await this.appendEvent(event, { dedupe: options.dedupe !== false });
13938
+ if (append.deduped) {
13939
+ return { event: append.event, deliveries: [], deduped: true };
13940
+ }
13941
+ const deliveries = options.deliver === false ? [] : await this.deliver(append.event);
13942
+ return { event: append.event, deliveries, deduped: false };
13943
+ }
13944
+ async listEvents(options = {}) {
13945
+ if (Object.keys(options).length === 0)
13946
+ return this.store.listEvents();
13947
+ return queryClientEvents(await this.store.listEvents(), options);
13948
+ }
13949
+ async listEventsPage(options = {}) {
13950
+ if (this.store.listEventsPage)
13951
+ return this.store.listEventsPage(options);
13952
+ const events = queryClientEvents(await this.store.listEvents(), {
13953
+ eventId: options.eventId,
13954
+ source: options.source,
13955
+ type: options.type
13956
+ });
13957
+ const offset = decodeLocalJsonEventCursor(options.cursor, options);
13958
+ const limit = normalizeEventPageLimit(options.limit);
13959
+ const pageEvents = events.slice(offset, offset + limit);
13960
+ const nextOffset = offset + pageEvents.length;
13961
+ const hasMore = nextOffset < events.length;
13962
+ return {
13963
+ events: pageEvents,
13964
+ cursor: options.cursor,
13965
+ nextCursor: hasMore ? encodeLocalJsonEventCursor(nextOffset, options) : undefined,
13966
+ hasMore
13967
+ };
13597
13968
  }
13598
13969
  async listDeliveries() {
13599
13970
  return this.store.listDeliveries();
@@ -13661,22 +14032,37 @@ class EventsClient {
13661
14032
  return result;
13662
14033
  }
13663
14034
  async replay(options = {}) {
13664
- const events = (await this.store.listEvents()).filter((event) => {
13665
- if (options.eventId && event.id !== options.eventId)
13666
- return false;
13667
- if (options.source && event.source !== options.source)
13668
- return false;
13669
- if (options.type && event.type !== options.type)
13670
- return false;
13671
- return true;
13672
- });
14035
+ const page = options.cursor || options.limit !== undefined ? await this.listEventsPage(options) : { events: await this.listEvents(options), hasMore: false };
13673
14036
  if (options.dryRun)
13674
- return { events, deliveries: [] };
14037
+ return { events: page.events, deliveries: [], cursor: page.cursor, nextCursor: page.nextCursor, hasMore: page.hasMore };
13675
14038
  const deliveries = [];
13676
- for (const event of events) {
14039
+ for (const event of page.events) {
13677
14040
  deliveries.push(...await this.deliver(event));
13678
14041
  }
13679
- return { events, deliveries };
14042
+ return { events: page.events, deliveries, cursor: page.cursor, nextCursor: page.nextCursor, hasMore: page.hasMore };
14043
+ }
14044
+ async appendEvent(event, options) {
14045
+ if (this.store.appendEventOnce) {
14046
+ return this.store.appendEventOnce(event, { dedupe: options.dedupe });
14047
+ }
14048
+ if (options.dedupe) {
14049
+ const existing = await this.store.findEventByIdentity({ id: event.id, dedupeKey: event.dedupeKey });
14050
+ if (existing) {
14051
+ return {
14052
+ event: existing,
14053
+ stored: false,
14054
+ deduped: true,
14055
+ identity: { id: existing.id, dedupeKey: existing.dedupeKey }
14056
+ };
14057
+ }
14058
+ }
14059
+ const stored = await this.store.appendEvent(event);
14060
+ return {
14061
+ event: stored,
14062
+ stored: true,
14063
+ deduped: false,
14064
+ identity: { id: stored.id, dedupeKey: stored.dedupeKey }
14065
+ };
13680
14066
  }
13681
14067
  async applyRedaction(event, channel) {
13682
14068
  let next = redactPaths(event, channel.redact?.paths ?? [], channel.redact?.replacement ?? "[REDACTED]");
@@ -13703,43 +14089,19 @@ class EventsClient {
13703
14089
  return createDeliveryResult(event, channel, attempts);
13704
14090
  }
13705
14091
  }
13706
- function redactPaths(event, paths, replacement = "[REDACTED]") {
13707
- if (paths.length === 0)
13708
- return event;
13709
- const copy = structuredClone(event);
13710
- for (const path of paths) {
13711
- setPath(copy, path, replacement);
13712
- }
13713
- return copy;
13714
- }
13715
- function redactSensitiveKeys(event, replacement = "[REDACTED]") {
13716
- return redactValue2(event, replacement);
13717
- }
13718
- function shouldRedactKey(key) {
13719
- return /secret|token|password|api[_-]?key|authorization/i.test(key);
13720
- }
13721
- function redactValue2(value, replacement) {
13722
- if (Array.isArray(value))
13723
- return value.map((item) => redactValue2(item, replacement));
13724
- if (!value || typeof value !== "object")
13725
- return value;
13726
- return Object.fromEntries(Object.entries(value).map(([key, item]) => [
13727
- key,
13728
- shouldRedactKey(key) ? replacement : redactValue2(item, replacement)
13729
- ]));
13730
- }
13731
- function setPath(input, path, replacement) {
13732
- const parts = path.split(".");
13733
- let cursor = input;
13734
- for (const part of parts.slice(0, -1)) {
13735
- const next = cursor[part];
13736
- if (!next || typeof next !== "object")
13737
- return;
13738
- cursor = next;
13739
- }
13740
- const last = parts.at(-1);
13741
- if (last && last in cursor)
13742
- cursor[last] = replacement;
14092
+ function queryClientEvents(events, options) {
14093
+ let rows = events;
14094
+ if (options.eventId)
14095
+ rows = rows.filter((event) => event.id === options.eventId);
14096
+ if (options.source)
14097
+ rows = rows.filter((event) => event.source === options.source);
14098
+ if (options.type)
14099
+ rows = rows.filter((event) => event.type === options.type);
14100
+ if (options.cursor)
14101
+ rows = rows.slice(decodeLocalJsonEventCursor(options.cursor, options));
14102
+ if (options.limit !== undefined)
14103
+ rows = rows.slice(0, normalizeEventPageLimit(options.limit));
14104
+ return rows;
13743
14105
  }
13744
14106
  function normalizeTime(value) {
13745
14107
  if (!value)
@@ -13753,9 +14115,22 @@ function normalizeRetryPolicy(policy) {
13753
14115
  multiplier: Math.max(1, policy?.multiplier ?? 2)
13754
14116
  };
13755
14117
  }
13756
- var HASNA_EVENTS_DIR_ENV = "HASNA_EVENTS_DIR", HASNA_EVENTS_HOME_ENV = "HASNA_EVENTS_HOME", DEFAULT_SIGNATURE_TOLERANCE_MS;
14118
+ var HASNA_EVENTS_DIR_ENV = "HASNA_EVENTS_DIR", HASNA_EVENTS_HOME_ENV = "HASNA_EVENTS_HOME", LOCAL_JSON_EVENT_CURSOR_PREFIX = "local-json-v1:", DEFAULT_EVENT_PAGE_LIMIT = 100, MAX_EVENT_PAGE_LIMIT = 1000, DEFAULT_SIGNATURE_TOLERANCE_MS, EventValidationError, defaultEventTypeCatalog, APP_EVENT_V1_MAX_DATA_BYTES;
13757
14119
  var init_dist = __esm(() => {
13758
14120
  DEFAULT_SIGNATURE_TOLERANCE_MS = 5 * 60 * 1000;
14121
+ EventValidationError = class EventValidationError extends Error {
14122
+ eventType;
14123
+ issues;
14124
+ constructor(eventType, issues) {
14125
+ const detail = issues.map((issue) => `${issue.path || "<root>"}: ${issue.message}`).join("; ");
14126
+ super(`Event validation failed for type "${eventType}": ${detail}`);
14127
+ this.name = "EventValidationError";
14128
+ this.eventType = eventType;
14129
+ this.issues = issues;
14130
+ }
14131
+ };
14132
+ defaultEventTypeCatalog = new EventTypeCatalog;
14133
+ APP_EVENT_V1_MAX_DATA_BYTES = 32 * 1024;
13759
14134
  });
13760
14135
 
13761
14136
  // src/db/task-lists.ts
@@ -14594,8 +14969,12 @@ async function deliverWebhook(wh, event, body, attempt, db) {
14594
14969
  const sig = await crypto.subtle.sign("HMAC", key, encoder.encode(body));
14595
14970
  headers["X-Webhook-Signature"] = Array.from(new Uint8Array(sig)).map((b) => b.toString(16).padStart(2, "0")).join("");
14596
14971
  }
14597
- const resp = await fetch(wh.url, { method: "POST", headers, body });
14972
+ const resp = await fetch(wh.url, { method: "POST", headers, body, redirect: "manual" });
14598
14973
  const respText = await resp.text().catch(() => "");
14974
+ if (resp.status >= 300 && resp.status < 400) {
14975
+ logDelivery(db, wh.id, event, body, resp.status, "Blocked: webhook URL returned a 3xx redirect; redirects are never followed (SSRF prevention)", attempt);
14976
+ return;
14977
+ }
14599
14978
  logDelivery(db, wh.id, event, body, resp.status, respText.slice(0, 1000), attempt);
14600
14979
  if (resp.status >= 400 && attempt < MAX_RETRY_ATTEMPTS) {
14601
14980
  const delay = RETRY_BASE_DELAY_MS * Math.pow(2, attempt - 1);
@@ -15288,7 +15667,7 @@ function getTaskGraph(taskId, direction = "both", db) {
15288
15667
  const deps = getTaskDependencies(t.id, d);
15289
15668
  const hasUnfinishedDeps = deps.some((dep) => {
15290
15669
  const depTask = getTask(dep.depends_on, d);
15291
- return depTask && depTask.status !== "completed";
15670
+ return depTask && isBlockingDependencyStatus(depTask.status);
15292
15671
  });
15293
15672
  return { id: t.id, short_id: t.short_id, title: t.title, status: t.status, priority: t.priority, is_blocked: hasUnfinishedDeps };
15294
15673
  }
@@ -15412,7 +15791,7 @@ function getBlockingDeps(id, db) {
15412
15791
  const blocking = [];
15413
15792
  for (const dep of deps) {
15414
15793
  const task = getTask(dep.depends_on, d);
15415
- if (task && task.status !== "completed")
15794
+ if (task && isBlockingDependencyStatus(task.status))
15416
15795
  blocking.push(task);
15417
15796
  }
15418
15797
  return blocking;
@@ -15736,7 +16115,7 @@ function getNextTask2(agentId, filters, db) {
15736
16115
  conditions.push(`id IN (SELECT task_id FROM task_tags WHERE tag IN (${placeholders}))`);
15737
16116
  params.push(...filters.tags);
15738
16117
  }
15739
- conditions.push("id NOT IN (SELECT td.task_id FROM task_dependencies td JOIN tasks dep ON dep.id = td.depends_on WHERE dep.status != 'completed')");
16118
+ conditions.push("id NOT IN (SELECT td.task_id FROM task_dependencies td JOIN tasks dep ON dep.id = td.depends_on WHERE dep.status NOT IN ('completed', 'cancelled'))");
15740
16119
  const where = conditions.join(" AND ");
15741
16120
  let recentProjectIds = [];
15742
16121
  const assignedAliasParams = [];
@@ -15780,7 +16159,7 @@ function getActiveWork2(filters, db) {
15780
16159
  }
15781
16160
  function getTasksChangedSince(since, filters, db) {
15782
16161
  const d = db || getDatabase();
15783
- const conditions = ["updated_at > ?"];
16162
+ const conditions = ["(julianday(updated_at) IS NULL OR julianday(updated_at) > julianday(?))"];
15784
16163
  const params = [since];
15785
16164
  if (filters?.project_id) {
15786
16165
  conditions.push("project_id = ?");
@@ -21078,7 +21457,7 @@ function matchesExtraFilters(task, filter) {
21078
21457
  }
21079
21458
  if (filter.tags?.length) {
21080
21459
  const taskTags = new Set(task.tags ?? []);
21081
- if (!filter.tags.every((tag) => taskTags.has(tag)))
21460
+ if (!filter.tags.some((tag) => taskTags.has(tag)))
21082
21461
  return false;
21083
21462
  }
21084
21463
  if (filter.include_subtasks !== true && filter.parent_id === undefined && task.parent_id)
@@ -27812,12 +28191,21 @@ class PostgresTodosTaskManifestBackend {
27812
28191
  this.tenantId = options.tenantId ?? "default";
27813
28192
  }
27814
28193
  async ensureSchema() {
27815
- this.schemaReady ??= (async () => {
27816
- for (const sql of postgresTodosSyncSchemaSql(this.tableName))
27817
- await this.client.query(sql);
27818
- for (const sql of postgresTodosTaskManifestSchemaSql(this.tenantId))
27819
- await this.client.query(sql);
27820
- })();
28194
+ if (this.schemaReady === null) {
28195
+ const attempt = (async () => {
28196
+ for (const sql of postgresTodosSyncSchemaSql(this.tableName))
28197
+ await this.client.query(sql);
28198
+ for (const sql of postgresTodosTaskManifestSchemaSql(this.tenantId))
28199
+ await this.client.query(sql);
28200
+ })();
28201
+ this.schemaReady = attempt;
28202
+ try {
28203
+ await attempt;
28204
+ } catch (error) {
28205
+ this.schemaReady = null;
28206
+ throw error;
28207
+ }
28208
+ }
27821
28209
  await this.schemaReady;
27822
28210
  }
27823
28211
  async insertSync(tx, objectType2, objectId, payload, now3) {
@@ -29117,12 +29505,21 @@ class PostgresTodosTaskSubtreeTransferBackend {
29117
29505
  this.tenantId = options.tenantId ?? "default";
29118
29506
  }
29119
29507
  async ensureSchema() {
29120
- this.schemaReady ??= (async () => {
29121
- for (const sql of postgresTodosSyncSchemaSql(this.tableName))
29122
- await this.client.query(sql);
29123
- for (const sql of postgresTodosTaskSubtreeTransferSchemaSql())
29124
- await this.client.query(sql);
29125
- })();
29508
+ if (this.schemaReady === null) {
29509
+ const attempt = (async () => {
29510
+ for (const sql of postgresTodosSyncSchemaSql(this.tableName))
29511
+ await this.client.query(sql);
29512
+ for (const sql of postgresTodosTaskSubtreeTransferSchemaSql())
29513
+ await this.client.query(sql);
29514
+ })();
29515
+ this.schemaReady = attempt;
29516
+ try {
29517
+ await attempt;
29518
+ } catch (error) {
29519
+ this.schemaReady = null;
29520
+ throw error;
29521
+ }
29522
+ }
29126
29523
  await this.schemaReady;
29127
29524
  }
29128
29525
  async snapshot(client, input, forUpdate = false) {
@@ -30221,7 +30618,10 @@ async function ensureCloudSchema() {
30221
30618
  await client.query(sql);
30222
30619
  }
30223
30620
  await getApiKeyStore().ensureSchema();
30224
- })();
30621
+ })().catch((error) => {
30622
+ schemaEnsured = null;
30623
+ throw error;
30624
+ });
30225
30625
  return schemaEnsured;
30226
30626
  }
30227
30627
  async function ensureCloudCommentCursorIndex() {
@@ -38081,6 +38481,152 @@ var init_v1 = __esm(() => {
38081
38481
  RFC3339_DATE_TIME = /^(\d{4})-(\d{2})-(\d{2})[Tt]\d{2}:\d{2}:\d{2}(\.\d+)?([Zz]|[+-]\d{2}:\d{2})$/;
38082
38482
  });
38083
38483
 
38484
+ // node_modules/.bun/content-type@1.0.5/node_modules/content-type/index.js
38485
+ var require_content_type = __commonJS((exports) => {
38486
+ /*!
38487
+ * content-type
38488
+ * Copyright(c) 2015 Douglas Christopher Wilson
38489
+ * MIT Licensed
38490
+ */
38491
+ var PARAM_REGEXP = /; *([!#$%&'*+.^_`|~0-9A-Za-z-]+) *= *("(?:[\u000b\u0020\u0021\u0023-\u005b\u005d-\u007e\u0080-\u00ff]|\\[\u000b\u0020-\u00ff])*"|[!#$%&'*+.^_`|~0-9A-Za-z-]+) */g;
38492
+ var TEXT_REGEXP = /^[\u000b\u0020-\u007e\u0080-\u00ff]+$/;
38493
+ var TOKEN_REGEXP = /^[!#$%&'*+.^_`|~0-9A-Za-z-]+$/;
38494
+ var QESC_REGEXP = /\\([\u000b\u0020-\u00ff])/g;
38495
+ var QUOTE_REGEXP = /([\\"])/g;
38496
+ var TYPE_REGEXP = /^[!#$%&'*+.^_`|~0-9A-Za-z-]+\/[!#$%&'*+.^_`|~0-9A-Za-z-]+$/;
38497
+ exports.format = format;
38498
+ exports.parse = parse;
38499
+ function format(obj) {
38500
+ if (!obj || typeof obj !== "object") {
38501
+ throw new TypeError("argument obj is required");
38502
+ }
38503
+ var parameters = obj.parameters;
38504
+ var type = obj.type;
38505
+ if (!type || !TYPE_REGEXP.test(type)) {
38506
+ throw new TypeError("invalid type");
38507
+ }
38508
+ var string = type;
38509
+ if (parameters && typeof parameters === "object") {
38510
+ var param;
38511
+ var params = Object.keys(parameters).sort();
38512
+ for (var i = 0;i < params.length; i++) {
38513
+ param = params[i];
38514
+ if (!TOKEN_REGEXP.test(param)) {
38515
+ throw new TypeError("invalid parameter name");
38516
+ }
38517
+ string += "; " + param + "=" + qstring(parameters[param]);
38518
+ }
38519
+ }
38520
+ return string;
38521
+ }
38522
+ function parse(string) {
38523
+ if (!string) {
38524
+ throw new TypeError("argument string is required");
38525
+ }
38526
+ var header = typeof string === "object" ? getcontenttype(string) : string;
38527
+ if (typeof header !== "string") {
38528
+ throw new TypeError("argument string is required to be a string");
38529
+ }
38530
+ var index = header.indexOf(";");
38531
+ var type = index !== -1 ? header.slice(0, index).trim() : header.trim();
38532
+ if (!TYPE_REGEXP.test(type)) {
38533
+ throw new TypeError("invalid media type");
38534
+ }
38535
+ var obj = new ContentType(type.toLowerCase());
38536
+ if (index !== -1) {
38537
+ var key2;
38538
+ var match;
38539
+ var value;
38540
+ PARAM_REGEXP.lastIndex = index;
38541
+ while (match = PARAM_REGEXP.exec(header)) {
38542
+ if (match.index !== index) {
38543
+ throw new TypeError("invalid parameter format");
38544
+ }
38545
+ index += match[0].length;
38546
+ key2 = match[1].toLowerCase();
38547
+ value = match[2];
38548
+ if (value.charCodeAt(0) === 34) {
38549
+ value = value.slice(1, -1);
38550
+ if (value.indexOf("\\") !== -1) {
38551
+ value = value.replace(QESC_REGEXP, "$1");
38552
+ }
38553
+ }
38554
+ obj.parameters[key2] = value;
38555
+ }
38556
+ if (index !== header.length) {
38557
+ throw new TypeError("invalid parameter format");
38558
+ }
38559
+ }
38560
+ return obj;
38561
+ }
38562
+ function getcontenttype(obj) {
38563
+ var header;
38564
+ if (typeof obj.getHeader === "function") {
38565
+ header = obj.getHeader("content-type");
38566
+ } else if (typeof obj.headers === "object") {
38567
+ header = obj.headers && obj.headers["content-type"];
38568
+ }
38569
+ if (typeof header !== "string") {
38570
+ throw new TypeError("content-type header is missing from object");
38571
+ }
38572
+ return header;
38573
+ }
38574
+ function qstring(val) {
38575
+ var str = String(val);
38576
+ if (TOKEN_REGEXP.test(str)) {
38577
+ return str;
38578
+ }
38579
+ if (str.length > 0 && !TEXT_REGEXP.test(str)) {
38580
+ throw new TypeError("invalid parameter value");
38581
+ }
38582
+ return '"' + str.replace(QUOTE_REGEXP, "\\$1") + '"';
38583
+ }
38584
+ function ContentType(type) {
38585
+ this.parameters = Object.create(null);
38586
+ this.type = type;
38587
+ }
38588
+ });
38589
+
38590
+ // node_modules/.bun/@modelcontextprotocol+sdk@1.30.0/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/mediaType.js
38591
+ function mediaTypeEssence(header) {
38592
+ if (!header) {
38593
+ return;
38594
+ }
38595
+ try {
38596
+ return import_content_type.default.parse(header).type;
38597
+ } catch {
38598
+ const essence = (header.split(";", 1)[0] ?? "").trim().toLowerCase();
38599
+ if (essence === "" || header.slice(essence.length).includes(",")) {
38600
+ return;
38601
+ }
38602
+ return essence;
38603
+ }
38604
+ }
38605
+ function isJsonContentType(header) {
38606
+ if (header === "application/json") {
38607
+ return true;
38608
+ }
38609
+ return mediaTypeEssence(header) === "application/json";
38610
+ }
38611
+ var import_content_type;
38612
+ var init_mediaType = __esm(() => {
38613
+ import_content_type = __toESM(require_content_type(), 1);
38614
+ });
38615
+
38616
+ // node_modules/.bun/@modelcontextprotocol+sdk@1.30.0/node_modules/@modelcontextprotocol/sdk/dist/esm/server/sseKeepAlive.js
38617
+ function armSseKeepAlive(intervalMs, onTick) {
38618
+ if (!Number.isFinite(intervalMs) || intervalMs < 1) {
38619
+ return;
38620
+ }
38621
+ const timer = setInterval(onTick, Math.min(intervalMs, MAX_TIMER_DELAY_MS));
38622
+ timer.unref?.();
38623
+ return timer;
38624
+ }
38625
+ var DEFAULT_SSE_KEEP_ALIVE_MS = 15000, MAX_TIMER_DELAY_MS;
38626
+ var init_sseKeepAlive = __esm(() => {
38627
+ MAX_TIMER_DELAY_MS = 2 ** 31 - 1;
38628
+ });
38629
+
38084
38630
  // node_modules/.bun/zod@3.25.76/node_modules/zod/v4/core/core.js
38085
38631
  function $constructor(name, initializer, params) {
38086
38632
  function init(inst, def) {
@@ -42667,7 +43213,7 @@ var init_v4 = __esm(() => {
42667
43213
  init_classic();
42668
43214
  });
42669
43215
 
42670
- // node_modules/.bun/@modelcontextprotocol+sdk@1.26.0/node_modules/@modelcontextprotocol/sdk/dist/esm/types.js
43216
+ // node_modules/.bun/@modelcontextprotocol+sdk@1.30.0/node_modules/@modelcontextprotocol/sdk/dist/esm/types.js
42671
43217
  function assertCompleteRequestPrompt(request) {
42672
43218
  if (request.params.ref.type !== "ref/prompt") {
42673
43219
  throw new TypeError(`Expected CompleteRequestPrompt, but got ${request.params.ref.type}`);
@@ -42686,7 +43232,7 @@ var init_types7 = __esm(() => {
42686
43232
  ProgressTokenSchema = union([string2(), number2().int()]);
42687
43233
  CursorSchema = string2();
42688
43234
  TaskCreationParamsSchema = looseObject({
42689
- ttl: union([number2(), _null3()]).optional(),
43235
+ ttl: number2().optional(),
42690
43236
  pollInterval: number2().optional()
42691
43237
  });
42692
43238
  TaskMetadataSchema = object({
@@ -42834,7 +43380,8 @@ var init_types7 = __esm(() => {
42834
43380
  roots: object({
42835
43381
  listChanged: boolean2().optional()
42836
43382
  }).optional(),
42837
- tasks: ClientTasksCapabilitySchema.optional()
43383
+ tasks: ClientTasksCapabilitySchema.optional(),
43384
+ extensions: record(string2(), AssertObjectSchema).optional()
42838
43385
  });
42839
43386
  InitializeRequestParamsSchema = BaseRequestParamsSchema.extend({
42840
43387
  protocolVersion: string2(),
@@ -42859,7 +43406,8 @@ var init_types7 = __esm(() => {
42859
43406
  tools: object({
42860
43407
  listChanged: boolean2().optional()
42861
43408
  }).optional(),
42862
- tasks: ServerTasksCapabilitySchema.optional()
43409
+ tasks: ServerTasksCapabilitySchema.optional(),
43410
+ extensions: record(string2(), AssertObjectSchema).optional()
42863
43411
  });
42864
43412
  InitializeResultSchema = ResultSchema.extend({
42865
43413
  protocolVersion: string2(),
@@ -42974,6 +43522,7 @@ var init_types7 = __esm(() => {
42974
43522
  uri: string2(),
42975
43523
  description: optional(string2()),
42976
43524
  mimeType: optional(string2()),
43525
+ size: optional(number2()),
42977
43526
  annotations: AnnotationsSchema.optional(),
42978
43527
  _meta: optional(looseObject({}))
42979
43528
  });
@@ -43502,17 +44051,19 @@ var init_types7 = __esm(() => {
43502
44051
  };
43503
44052
  });
43504
44053
 
43505
- // node_modules/.bun/@modelcontextprotocol+sdk@1.26.0/node_modules/@modelcontextprotocol/sdk/dist/esm/server/webStandardStreamableHttp.js
44054
+ // node_modules/.bun/@modelcontextprotocol+sdk@1.30.0/node_modules/@modelcontextprotocol/sdk/dist/esm/server/webStandardStreamableHttp.js
43506
44055
  class WebStandardStreamableHTTPServerTransport {
43507
44056
  constructor(options = {}) {
43508
44057
  this._started = false;
43509
44058
  this._hasHandledRequest = false;
43510
44059
  this._streamMapping = new Map;
43511
44060
  this._requestToStreamMapping = new Map;
44061
+ this._resumableStreams = new Set;
43512
44062
  this._requestResponseMap = new Map;
43513
44063
  this._initialized = false;
43514
44064
  this._enableJsonResponse = false;
43515
44065
  this._standaloneSseStreamId = "_GET_stream";
44066
+ this._closed = false;
43516
44067
  this.sessionIdGenerator = options.sessionIdGenerator;
43517
44068
  this._enableJsonResponse = options.enableJsonResponse ?? false;
43518
44069
  this._eventStore = options.eventStore;
@@ -43522,6 +44073,22 @@ class WebStandardStreamableHTTPServerTransport {
43522
44073
  this._allowedOrigins = options.allowedOrigins;
43523
44074
  this._enableDnsRebindingProtection = options.enableDnsRebindingProtection ?? false;
43524
44075
  this._retryInterval = options.retryInterval;
44076
+ this._keepAliveMs = options.keepAliveMs ?? DEFAULT_SSE_KEEP_ALIVE_MS;
44077
+ }
44078
+ startKeepAlive(controller, encoder) {
44079
+ if (this._closed)
44080
+ return;
44081
+ const timer = armSseKeepAlive(this._keepAliveMs, () => {
44082
+ try {
44083
+ controller.enqueue(encoder.encode(`: keepalive
44084
+
44085
+ `));
44086
+ } catch {
44087
+ if (timer !== undefined)
44088
+ clearInterval(timer);
44089
+ }
44090
+ });
44091
+ return timer;
43525
44092
  }
43526
44093
  async start() {
43527
44094
  if (this._started) {
@@ -43569,6 +44136,9 @@ class WebStandardStreamableHTTPServerTransport {
43569
44136
  return;
43570
44137
  }
43571
44138
  async handleRequest(req, options) {
44139
+ if (this._closed) {
44140
+ return this.createJsonErrorResponse(404, -32001, "Session not found");
44141
+ }
43572
44142
  if (!this.sessionIdGenerator && this._hasHandledRequest) {
43573
44143
  throw new Error("Stateless transport cannot be reused across requests. Create a new transport per request.");
43574
44144
  }
@@ -43608,10 +44178,12 @@ data:
43608
44178
  `;
43609
44179
  }
43610
44180
  controller.enqueue(encoder.encode(primingEvent));
44181
+ this._resumableStreams.add(streamId);
43611
44182
  }
43612
44183
  async handleGetRequest(req) {
43613
44184
  const acceptHeader = req.headers.get("accept");
43614
44185
  if (!acceptHeader?.includes("text/event-stream")) {
44186
+ this.onerror?.(new Error("Not Acceptable: Client must accept text/event-stream"));
43615
44187
  return this.createJsonErrorResponse(406, -32000, "Not Acceptable: Client must accept text/event-stream");
43616
44188
  }
43617
44189
  const sessionError = this.validateSession(req);
@@ -43629,22 +44201,30 @@ data:
43629
44201
  }
43630
44202
  }
43631
44203
  if (this._streamMapping.get(this._standaloneSseStreamId) !== undefined) {
44204
+ this.onerror?.(new Error("Conflict: Only one SSE stream is allowed per session"));
43632
44205
  return this.createJsonErrorResponse(409, -32000, "Conflict: Only one SSE stream is allowed per session");
43633
44206
  }
43634
44207
  const encoder = new TextEncoder;
43635
44208
  let streamController;
44209
+ let keepAliveTimer = undefined;
43636
44210
  const readable = new ReadableStream({
43637
44211
  start: (controller) => {
43638
44212
  streamController = controller;
43639
44213
  },
43640
44214
  cancel: () => {
43641
- this._streamMapping.delete(this._standaloneSseStreamId);
44215
+ if (keepAliveTimer !== undefined) {
44216
+ clearInterval(keepAliveTimer);
44217
+ }
44218
+ if (this._streamMapping.get(this._standaloneSseStreamId)?.controller === streamController) {
44219
+ this._streamMapping.delete(this._standaloneSseStreamId);
44220
+ }
43642
44221
  }
43643
44222
  });
43644
44223
  const headers = {
43645
44224
  "Content-Type": "text/event-stream",
43646
44225
  "Cache-Control": "no-cache, no-transform",
43647
- Connection: "keep-alive"
44226
+ Connection: "keep-alive",
44227
+ "X-Accel-Buffering": "no"
43648
44228
  };
43649
44229
  if (this.sessionId !== undefined) {
43650
44230
  headers["mcp-session-id"] = this.sessionId;
@@ -43653,16 +44233,21 @@ data:
43653
44233
  controller: streamController,
43654
44234
  encoder,
43655
44235
  cleanup: () => {
44236
+ if (keepAliveTimer !== undefined) {
44237
+ clearInterval(keepAliveTimer);
44238
+ }
43656
44239
  this._streamMapping.delete(this._standaloneSseStreamId);
43657
44240
  try {
43658
44241
  streamController.close();
43659
44242
  } catch {}
43660
44243
  }
43661
44244
  });
44245
+ keepAliveTimer = this.startKeepAlive(streamController, encoder);
43662
44246
  return new Response(readable, { headers });
43663
44247
  }
43664
44248
  async replayEvents(lastEventId) {
43665
44249
  if (!this._eventStore) {
44250
+ this.onerror?.(new Error("Event store not configured"));
43666
44251
  return this.createJsonErrorResponse(400, -32000, "Event store not configured");
43667
44252
  }
43668
44253
  try {
@@ -43670,29 +44255,44 @@ data:
43670
44255
  if (this._eventStore.getStreamIdForEventId) {
43671
44256
  streamId = await this._eventStore.getStreamIdForEventId(lastEventId);
43672
44257
  if (!streamId) {
44258
+ this.onerror?.(new Error("Invalid event ID format"));
43673
44259
  return this.createJsonErrorResponse(400, -32000, "Invalid event ID format");
43674
44260
  }
43675
44261
  if (this._streamMapping.get(streamId) !== undefined) {
44262
+ this.onerror?.(new Error("Conflict: Stream already has an active connection"));
43676
44263
  return this.createJsonErrorResponse(409, -32000, "Conflict: Stream already has an active connection");
43677
44264
  }
43678
44265
  }
43679
44266
  const headers = {
43680
44267
  "Content-Type": "text/event-stream",
43681
44268
  "Cache-Control": "no-cache, no-transform",
43682
- Connection: "keep-alive"
44269
+ Connection: "keep-alive",
44270
+ "X-Accel-Buffering": "no"
43683
44271
  };
43684
44272
  if (this.sessionId !== undefined) {
43685
44273
  headers["mcp-session-id"] = this.sessionId;
43686
44274
  }
43687
44275
  const encoder = new TextEncoder;
43688
44276
  let streamController;
44277
+ let keepAliveTimer = undefined;
44278
+ let replayedStreamId = undefined;
44279
+ let cancelled = false;
43689
44280
  const readable = new ReadableStream({
43690
44281
  start: (controller) => {
43691
44282
  streamController = controller;
43692
44283
  },
43693
- cancel: () => {}
44284
+ cancel: () => {
44285
+ cancelled = true;
44286
+ if (keepAliveTimer !== undefined) {
44287
+ clearInterval(keepAliveTimer);
44288
+ }
44289
+ if (replayedStreamId !== undefined && this._streamMapping.get(replayedStreamId)?.controller === streamController) {
44290
+ this._streamMapping.delete(replayedStreamId);
44291
+ }
44292
+ }
43694
44293
  });
43695
- const replayedStreamId = await this._eventStore.replayEventsAfter(lastEventId, {
44294
+ const replayedEventIds = new Set;
44295
+ replayedStreamId = await this._eventStore.replayEventsAfter(lastEventId, {
43696
44296
  send: async (eventId, message) => {
43697
44297
  const success = this.writeSSEEvent(streamController, encoder, message, eventId);
43698
44298
  if (!success) {
@@ -43700,19 +44300,34 @@ data:
43700
44300
  try {
43701
44301
  streamController.close();
43702
44302
  } catch {}
44303
+ } else {
44304
+ replayedEventIds.add(eventId);
43703
44305
  }
43704
44306
  }
43705
44307
  });
44308
+ if (this._closed || cancelled) {
44309
+ try {
44310
+ streamController.close();
44311
+ } catch {}
44312
+ return this.createJsonErrorResponse(404, -32001, "Session not found");
44313
+ }
44314
+ this._streamMapping.get(replayedStreamId)?.cleanup();
43706
44315
  this._streamMapping.set(replayedStreamId, {
43707
44316
  controller: streamController,
43708
44317
  encoder,
44318
+ replayedEventIds,
43709
44319
  cleanup: () => {
44320
+ if (keepAliveTimer !== undefined) {
44321
+ clearInterval(keepAliveTimer);
44322
+ }
43710
44323
  this._streamMapping.delete(replayedStreamId);
43711
44324
  try {
43712
44325
  streamController.close();
43713
44326
  } catch {}
43714
44327
  }
43715
44328
  });
44329
+ this._resumableStreams.add(replayedStreamId);
44330
+ keepAliveTimer = this.startKeepAlive(streamController, encoder);
43716
44331
  return new Response(readable, { headers });
43717
44332
  } catch (error3) {
43718
44333
  this.onerror?.(error3);
@@ -43732,11 +44347,13 @@ data:
43732
44347
  `;
43733
44348
  controller.enqueue(encoder.encode(eventData));
43734
44349
  return true;
43735
- } catch {
44350
+ } catch (error3) {
44351
+ this.onerror?.(error3);
43736
44352
  return false;
43737
44353
  }
43738
44354
  }
43739
44355
  handleUnsupportedRequest() {
44356
+ this.onerror?.(new Error("Method not allowed."));
43740
44357
  return new Response(JSON.stringify({
43741
44358
  jsonrpc: "2.0",
43742
44359
  error: {
@@ -43756,14 +44373,17 @@ data:
43756
44373
  try {
43757
44374
  const acceptHeader = req.headers.get("accept");
43758
44375
  if (!acceptHeader?.includes("application/json") || !acceptHeader.includes("text/event-stream")) {
44376
+ this.onerror?.(new Error("Not Acceptable: Client must accept both application/json and text/event-stream"));
43759
44377
  return this.createJsonErrorResponse(406, -32000, "Not Acceptable: Client must accept both application/json and text/event-stream");
43760
44378
  }
43761
44379
  const ct = req.headers.get("content-type");
43762
- if (!ct || !ct.includes("application/json")) {
44380
+ if (!isJsonContentType(ct)) {
44381
+ this.onerror?.(new Error("Unsupported Media Type: Content-Type must be application/json"));
43763
44382
  return this.createJsonErrorResponse(415, -32000, "Unsupported Media Type: Content-Type must be application/json");
43764
44383
  }
43765
44384
  const requestInfo = {
43766
- headers: Object.fromEntries(req.headers.entries())
44385
+ headers: Object.fromEntries(req.headers.entries()),
44386
+ url: new URL(req.url)
43767
44387
  };
43768
44388
  let rawMessage;
43769
44389
  if (options?.parsedBody !== undefined) {
@@ -43772,6 +44392,7 @@ data:
43772
44392
  try {
43773
44393
  rawMessage = await req.json();
43774
44394
  } catch {
44395
+ this.onerror?.(new Error("Parse error: Invalid JSON"));
43775
44396
  return this.createJsonErrorResponse(400, -32700, "Parse error: Invalid JSON");
43776
44397
  }
43777
44398
  }
@@ -43783,14 +44404,20 @@ data:
43783
44404
  messages = [JSONRPCMessageSchema.parse(rawMessage)];
43784
44405
  }
43785
44406
  } catch {
44407
+ this.onerror?.(new Error("Parse error: Invalid JSON-RPC message"));
43786
44408
  return this.createJsonErrorResponse(400, -32700, "Parse error: Invalid JSON-RPC message");
43787
44409
  }
44410
+ if (this._closed) {
44411
+ return this.createJsonErrorResponse(404, -32001, "Session not found");
44412
+ }
43788
44413
  const isInitializationRequest = messages.some(isInitializeRequest);
43789
44414
  if (isInitializationRequest) {
43790
44415
  if (this._initialized && this.sessionId !== undefined) {
44416
+ this.onerror?.(new Error("Invalid Request: Server already initialized"));
43791
44417
  return this.createJsonErrorResponse(400, -32600, "Invalid Request: Server already initialized");
43792
44418
  }
43793
44419
  if (messages.length > 1) {
44420
+ this.onerror?.(new Error("Invalid Request: Only one initialization request is allowed"));
43794
44421
  return this.createJsonErrorResponse(400, -32600, "Invalid Request: Only one initialization request is allowed");
43795
44422
  }
43796
44423
  this.sessionId = this.sessionIdGenerator?.();
@@ -43809,6 +44436,9 @@ data:
43809
44436
  return protocolError;
43810
44437
  }
43811
44438
  }
44439
+ if (this._closed) {
44440
+ return this.createJsonErrorResponse(404, -32001, "Session not found");
44441
+ }
43812
44442
  const hasRequests = messages.some(isJSONRPCRequest);
43813
44443
  if (!hasRequests) {
43814
44444
  for (const message of messages) {
@@ -43839,18 +44469,25 @@ data:
43839
44469
  }
43840
44470
  const encoder = new TextEncoder;
43841
44471
  let streamController;
44472
+ let keepAliveTimer = undefined;
43842
44473
  const readable = new ReadableStream({
43843
44474
  start: (controller) => {
43844
44475
  streamController = controller;
43845
44476
  },
43846
44477
  cancel: () => {
43847
- this._streamMapping.delete(streamId);
44478
+ if (keepAliveTimer !== undefined) {
44479
+ clearInterval(keepAliveTimer);
44480
+ }
44481
+ if (this._streamMapping.get(streamId)?.controller === streamController) {
44482
+ this._streamMapping.delete(streamId);
44483
+ }
43848
44484
  }
43849
44485
  });
43850
44486
  const headers = {
43851
44487
  "Content-Type": "text/event-stream",
43852
- "Cache-Control": "no-cache",
43853
- Connection: "keep-alive"
44488
+ "Cache-Control": "no-cache, no-transform",
44489
+ Connection: "keep-alive",
44490
+ "X-Accel-Buffering": "no"
43854
44491
  };
43855
44492
  if (this.sessionId !== undefined) {
43856
44493
  headers["mcp-session-id"] = this.sessionId;
@@ -43861,6 +44498,9 @@ data:
43861
44498
  controller: streamController,
43862
44499
  encoder,
43863
44500
  cleanup: () => {
44501
+ if (keepAliveTimer !== undefined) {
44502
+ clearInterval(keepAliveTimer);
44503
+ }
43864
44504
  this._streamMapping.delete(streamId);
43865
44505
  try {
43866
44506
  streamController.close();
@@ -43870,19 +44510,33 @@ data:
43870
44510
  this._requestToStreamMapping.set(message.id, streamId);
43871
44511
  }
43872
44512
  }
43873
- await this.writePrimingEvent(streamController, encoder, streamId, clientProtocolVersion);
43874
- for (const message of messages) {
43875
- let closeSSEStream;
43876
- let closeStandaloneSSEStream;
43877
- if (isJSONRPCRequest(message) && this._eventStore && clientProtocolVersion >= "2025-11-25") {
43878
- closeSSEStream = () => {
43879
- this.closeSSEStream(message.id);
43880
- };
43881
- closeStandaloneSSEStream = () => {
43882
- this.closeStandaloneSSEStream();
43883
- };
44513
+ try {
44514
+ await this.writePrimingEvent(streamController, encoder, streamId, clientProtocolVersion);
44515
+ for (const message of messages) {
44516
+ let closeSSEStream;
44517
+ let closeStandaloneSSEStream;
44518
+ if (isJSONRPCRequest(message) && this._eventStore && clientProtocolVersion >= "2025-11-25") {
44519
+ closeSSEStream = () => {
44520
+ this.closeSSEStream(message.id);
44521
+ };
44522
+ closeStandaloneSSEStream = () => {
44523
+ this.closeStandaloneSSEStream();
44524
+ };
44525
+ }
44526
+ this.onmessage?.(message, { authInfo: options?.authInfo, requestInfo, closeSSEStream, closeStandaloneSSEStream });
43884
44527
  }
43885
- this.onmessage?.(message, { authInfo: options?.authInfo, requestInfo, closeSSEStream, closeStandaloneSSEStream });
44528
+ } catch (error3) {
44529
+ this._streamMapping.get(streamId)?.cleanup();
44530
+ this._resumableStreams.delete(streamId);
44531
+ for (const message of messages) {
44532
+ if (isJSONRPCRequest(message)) {
44533
+ this._requestToStreamMapping.delete(message.id);
44534
+ }
44535
+ }
44536
+ throw error3;
44537
+ }
44538
+ if (this._streamMapping.get(streamId)?.controller === streamController) {
44539
+ keepAliveTimer = this.startKeepAlive(streamController, encoder);
43886
44540
  }
43887
44541
  return new Response(readable, { status: 200, headers });
43888
44542
  } catch (error3) {
@@ -43899,22 +44553,28 @@ data:
43899
44553
  if (protocolError) {
43900
44554
  return protocolError;
43901
44555
  }
43902
- await Promise.resolve(this._onsessionclosed?.(this.sessionId));
43903
- await this.close();
43904
- return new Response(null, { status: 200 });
44556
+ try {
44557
+ await Promise.resolve(this._onsessionclosed?.(this.sessionId));
44558
+ return new Response(null, { status: 200 });
44559
+ } finally {
44560
+ await this.close();
44561
+ }
43905
44562
  }
43906
44563
  validateSession(req) {
43907
44564
  if (this.sessionIdGenerator === undefined) {
43908
44565
  return;
43909
44566
  }
43910
44567
  if (!this._initialized) {
44568
+ this.onerror?.(new Error("Bad Request: Server not initialized"));
43911
44569
  return this.createJsonErrorResponse(400, -32000, "Bad Request: Server not initialized");
43912
44570
  }
43913
44571
  const sessionId = req.headers.get("mcp-session-id");
43914
44572
  if (!sessionId) {
44573
+ this.onerror?.(new Error("Bad Request: Mcp-Session-Id header is required"));
43915
44574
  return this.createJsonErrorResponse(400, -32000, "Bad Request: Mcp-Session-Id header is required");
43916
44575
  }
43917
44576
  if (sessionId !== this.sessionId) {
44577
+ this.onerror?.(new Error("Session not found"));
43918
44578
  return this.createJsonErrorResponse(404, -32001, "Session not found");
43919
44579
  }
43920
44580
  return;
@@ -43922,16 +44582,22 @@ data:
43922
44582
  validateProtocolVersion(req) {
43923
44583
  const protocolVersion = req.headers.get("mcp-protocol-version");
43924
44584
  if (protocolVersion !== null && !SUPPORTED_PROTOCOL_VERSIONS.includes(protocolVersion)) {
44585
+ this.onerror?.(new Error(`Bad Request: Unsupported protocol version: ${protocolVersion}` + ` (supported versions: ${SUPPORTED_PROTOCOL_VERSIONS.join(", ")})`));
43925
44586
  return this.createJsonErrorResponse(400, -32000, `Bad Request: Unsupported protocol version: ${protocolVersion} (supported versions: ${SUPPORTED_PROTOCOL_VERSIONS.join(", ")})`);
43926
44587
  }
43927
44588
  return;
43928
44589
  }
43929
44590
  async close() {
44591
+ if (this._closed) {
44592
+ return;
44593
+ }
44594
+ this._closed = true;
43930
44595
  this._streamMapping.forEach(({ cleanup }) => {
43931
44596
  cleanup();
43932
44597
  });
43933
44598
  this._streamMapping.clear();
43934
44599
  this._requestResponseMap.clear();
44600
+ this._resumableStreams.clear();
43935
44601
  this.onclose?.();
43936
44602
  }
43937
44603
  closeSSEStream(requestId) {
@@ -43966,7 +44632,7 @@ data:
43966
44632
  if (standaloneSse === undefined) {
43967
44633
  return;
43968
44634
  }
43969
- if (standaloneSse.controller && standaloneSse.encoder) {
44635
+ if (standaloneSse.controller && standaloneSse.encoder && (eventId === undefined || !standaloneSse.replayedEventIds?.has(eventId))) {
43970
44636
  this.writeSSEEvent(standaloneSse.controller, standaloneSse.encoder, message, eventId);
43971
44637
  }
43972
44638
  return;
@@ -43975,13 +44641,19 @@ data:
43975
44641
  if (!streamId) {
43976
44642
  throw new Error(`No connection established for request ID: ${String(requestId)}`);
43977
44643
  }
43978
- const stream = this._streamMapping.get(streamId);
43979
- if (!this._enableJsonResponse && stream?.controller && stream?.encoder) {
44644
+ let stream = this._streamMapping.get(streamId);
44645
+ if (!this._enableJsonResponse) {
43980
44646
  let eventId;
43981
44647
  if (this._eventStore) {
43982
44648
  eventId = await this._eventStore.storeEvent(streamId, message);
44649
+ stream = this._streamMapping.get(streamId);
44650
+ }
44651
+ if (stream?.controller && stream?.encoder && (eventId === undefined || !stream.replayedEventIds?.has(eventId))) {
44652
+ const written = this.writeSSEEvent(stream.controller, stream.encoder, message, eventId);
44653
+ if (written && eventId !== undefined) {
44654
+ this._resumableStreams.add(streamId);
44655
+ }
43983
44656
  }
43984
- this.writeSSEEvent(stream.controller, stream.encoder, message, eventId);
43985
44657
  }
43986
44658
  if (isJSONRPCResultResponse(message) || isJSONRPCErrorResponse(message)) {
43987
44659
  this._requestResponseMap.set(requestId, message);
@@ -43989,6 +44661,25 @@ data:
43989
44661
  const allResponsesReady = relatedIds.every((id) => this._requestResponseMap.has(id));
43990
44662
  if (allResponsesReady) {
43991
44663
  if (!stream) {
44664
+ if (this._closed) {
44665
+ for (const id of relatedIds) {
44666
+ this._requestResponseMap.delete(id);
44667
+ this._requestToStreamMapping.delete(id);
44668
+ }
44669
+ return;
44670
+ }
44671
+ if (!this._enableJsonResponse && this._eventStore && this._resumableStreams.has(streamId)) {
44672
+ for (const id of relatedIds) {
44673
+ this._requestResponseMap.delete(id);
44674
+ this._requestToStreamMapping.delete(id);
44675
+ }
44676
+ this._resumableStreams.delete(streamId);
44677
+ return;
44678
+ }
44679
+ for (const id of relatedIds) {
44680
+ this._requestResponseMap.delete(id);
44681
+ this._requestToStreamMapping.delete(id);
44682
+ }
43992
44683
  throw new Error(`No connection established for request ID: ${String(requestId)}`);
43993
44684
  }
43994
44685
  if (this._enableJsonResponse && stream.resolveJson) {
@@ -44011,11 +44702,14 @@ data:
44011
44702
  this._requestResponseMap.delete(id);
44012
44703
  this._requestToStreamMapping.delete(id);
44013
44704
  }
44705
+ this._resumableStreams.delete(streamId);
44014
44706
  }
44015
44707
  }
44016
44708
  }
44017
44709
  }
44018
44710
  var init_webStandardStreamableHttp = __esm(() => {
44711
+ init_mediaType();
44712
+ init_sseKeepAlive();
44019
44713
  init_types7();
44020
44714
  });
44021
44715
 
@@ -44109,7 +44803,7 @@ var init_v4_mini = __esm(() => {
44109
44803
  init_mini();
44110
44804
  });
44111
44805
 
44112
- // node_modules/.bun/@modelcontextprotocol+sdk@1.26.0/node_modules/@modelcontextprotocol/sdk/dist/esm/server/zod-compat.js
44806
+ // node_modules/.bun/@modelcontextprotocol+sdk@1.30.0/node_modules/@modelcontextprotocol/sdk/dist/esm/server/zod-compat.js
44113
44807
  function isZ4Schema(s) {
44114
44808
  const schema2 = s;
44115
44809
  return !!schema2._zod;
@@ -44193,17 +44887,34 @@ function normalizeObjectSchema(schema2) {
44193
44887
  }
44194
44888
  return;
44195
44889
  }
44890
+ function getDotPath(path) {
44891
+ if (path.length === 0) {
44892
+ return "object root";
44893
+ }
44894
+ return path.reduce((acc, seg, index) => {
44895
+ if (index === 0) {
44896
+ return String(seg);
44897
+ }
44898
+ if (typeof seg === "number") {
44899
+ return `${acc}[${seg}]`;
44900
+ }
44901
+ return `${acc}.${seg}`;
44902
+ }, "");
44903
+ }
44196
44904
  function getParseErrorMessage(error3) {
44197
44905
  if (error3 && typeof error3 === "object") {
44906
+ if ("issues" in error3 && Array.isArray(error3.issues) && error3.issues.length > 0) {
44907
+ return error3.issues.map((i) => {
44908
+ if (!i.path?.length) {
44909
+ return i.message;
44910
+ }
44911
+ return `${i.message} at ${getDotPath(i.path)}`;
44912
+ }).join(`
44913
+ `);
44914
+ }
44198
44915
  if ("message" in error3 && typeof error3.message === "string") {
44199
44916
  return error3.message;
44200
44917
  }
44201
- if ("issues" in error3 && Array.isArray(error3.issues) && error3.issues.length > 0) {
44202
- const firstIssue = error3.issues[0];
44203
- if (firstIssue && typeof firstIssue === "object" && "message" in firstIssue) {
44204
- return String(firstIssue.message);
44205
- }
44206
- }
44207
44918
  try {
44208
44919
  return JSON.stringify(error3);
44209
44920
  } catch {
@@ -44257,12 +44968,12 @@ var init_zod_compat = __esm(() => {
44257
44968
  init_v4_mini();
44258
44969
  });
44259
44970
 
44260
- // node_modules/.bun/@modelcontextprotocol+sdk@1.26.0/node_modules/@modelcontextprotocol/sdk/dist/esm/experimental/tasks/interfaces.js
44971
+ // node_modules/.bun/@modelcontextprotocol+sdk@1.30.0/node_modules/@modelcontextprotocol/sdk/dist/esm/experimental/tasks/interfaces.js
44261
44972
  function isTerminal(status3) {
44262
44973
  return status3 === "completed" || status3 === "failed" || status3 === "cancelled";
44263
44974
  }
44264
44975
 
44265
- // node_modules/.bun/zod-to-json-schema@3.25.1+27912429049419a2/node_modules/zod-to-json-schema/dist/esm/Options.js
44976
+ // node_modules/.bun/zod-to-json-schema@3.25.2+27912429049419a2/node_modules/zod-to-json-schema/dist/esm/Options.js
44266
44977
  var ignoreOverride, defaultOptions, getDefaultOptions = (options) => typeof options === "string" ? {
44267
44978
  ...defaultOptions,
44268
44979
  name: options
@@ -44298,7 +45009,7 @@ var init_Options = __esm(() => {
44298
45009
  };
44299
45010
  });
44300
45011
 
44301
- // node_modules/.bun/zod-to-json-schema@3.25.1+27912429049419a2/node_modules/zod-to-json-schema/dist/esm/Refs.js
45012
+ // node_modules/.bun/zod-to-json-schema@3.25.2+27912429049419a2/node_modules/zod-to-json-schema/dist/esm/Refs.js
44302
45013
  var getRefs = (options) => {
44303
45014
  const _options = getDefaultOptions(options);
44304
45015
  const currentPath = _options.name !== undefined ? [..._options.basePath, _options.definitionPath, _options.name] : _options.basePath;
@@ -44321,7 +45032,7 @@ var init_Refs = __esm(() => {
44321
45032
  init_Options();
44322
45033
  });
44323
45034
 
44324
- // node_modules/.bun/zod-to-json-schema@3.25.1+27912429049419a2/node_modules/zod-to-json-schema/dist/esm/errorMessages.js
45035
+ // node_modules/.bun/zod-to-json-schema@3.25.2+27912429049419a2/node_modules/zod-to-json-schema/dist/esm/errorMessages.js
44325
45036
  function addErrorMessage(res, key2, errorMessage, refs) {
44326
45037
  if (!refs?.errorMessages)
44327
45038
  return;
@@ -44337,7 +45048,7 @@ function setResponseValueAndErrors(res, key2, value, errorMessage, refs) {
44337
45048
  addErrorMessage(res, key2, errorMessage, refs);
44338
45049
  }
44339
45050
 
44340
- // node_modules/.bun/zod-to-json-schema@3.25.1+27912429049419a2/node_modules/zod-to-json-schema/dist/esm/getRelativePath.js
45051
+ // node_modules/.bun/zod-to-json-schema@3.25.2+27912429049419a2/node_modules/zod-to-json-schema/dist/esm/getRelativePath.js
44341
45052
  var getRelativePath = (pathA, pathB) => {
44342
45053
  let i = 0;
44343
45054
  for (;i < pathA.length && i < pathB.length; i++) {
@@ -44347,7 +45058,7 @@ var getRelativePath = (pathA, pathB) => {
44347
45058
  return [(pathA.length - i).toString(), ...pathB.slice(i)].join("/");
44348
45059
  };
44349
45060
 
44350
- // node_modules/.bun/zod-to-json-schema@3.25.1+27912429049419a2/node_modules/zod-to-json-schema/dist/esm/parsers/any.js
45061
+ // node_modules/.bun/zod-to-json-schema@3.25.2+27912429049419a2/node_modules/zod-to-json-schema/dist/esm/parsers/any.js
44351
45062
  function parseAnyDef(refs) {
44352
45063
  if (refs.target !== "openAi") {
44353
45064
  return {};
@@ -44364,7 +45075,7 @@ function parseAnyDef(refs) {
44364
45075
  }
44365
45076
  var init_any = () => {};
44366
45077
 
44367
- // node_modules/.bun/zod-to-json-schema@3.25.1+27912429049419a2/node_modules/zod-to-json-schema/dist/esm/parsers/array.js
45078
+ // node_modules/.bun/zod-to-json-schema@3.25.2+27912429049419a2/node_modules/zod-to-json-schema/dist/esm/parsers/array.js
44368
45079
  function parseArrayDef(def, refs) {
44369
45080
  const res = {
44370
45081
  type: "array"
@@ -44392,7 +45103,7 @@ var init_array = __esm(() => {
44392
45103
  init_parseDef();
44393
45104
  });
44394
45105
 
44395
- // node_modules/.bun/zod-to-json-schema@3.25.1+27912429049419a2/node_modules/zod-to-json-schema/dist/esm/parsers/bigint.js
45106
+ // node_modules/.bun/zod-to-json-schema@3.25.2+27912429049419a2/node_modules/zod-to-json-schema/dist/esm/parsers/bigint.js
44396
45107
  function parseBigintDef(def, refs) {
44397
45108
  const res = {
44398
45109
  type: "integer",
@@ -44439,14 +45150,14 @@ function parseBigintDef(def, refs) {
44439
45150
  }
44440
45151
  var init_bigint = () => {};
44441
45152
 
44442
- // node_modules/.bun/zod-to-json-schema@3.25.1+27912429049419a2/node_modules/zod-to-json-schema/dist/esm/parsers/boolean.js
45153
+ // node_modules/.bun/zod-to-json-schema@3.25.2+27912429049419a2/node_modules/zod-to-json-schema/dist/esm/parsers/boolean.js
44443
45154
  function parseBooleanDef() {
44444
45155
  return {
44445
45156
  type: "boolean"
44446
45157
  };
44447
45158
  }
44448
45159
 
44449
- // node_modules/.bun/zod-to-json-schema@3.25.1+27912429049419a2/node_modules/zod-to-json-schema/dist/esm/parsers/branded.js
45160
+ // node_modules/.bun/zod-to-json-schema@3.25.2+27912429049419a2/node_modules/zod-to-json-schema/dist/esm/parsers/branded.js
44450
45161
  function parseBrandedDef(_def, refs) {
44451
45162
  return parseDef(_def.type._def, refs);
44452
45163
  }
@@ -44454,7 +45165,7 @@ var init_branded = __esm(() => {
44454
45165
  init_parseDef();
44455
45166
  });
44456
45167
 
44457
- // node_modules/.bun/zod-to-json-schema@3.25.1+27912429049419a2/node_modules/zod-to-json-schema/dist/esm/parsers/catch.js
45168
+ // node_modules/.bun/zod-to-json-schema@3.25.2+27912429049419a2/node_modules/zod-to-json-schema/dist/esm/parsers/catch.js
44458
45169
  var parseCatchDef = (def, refs) => {
44459
45170
  return parseDef(def.innerType._def, refs);
44460
45171
  };
@@ -44462,7 +45173,7 @@ var init_catch = __esm(() => {
44462
45173
  init_parseDef();
44463
45174
  });
44464
45175
 
44465
- // node_modules/.bun/zod-to-json-schema@3.25.1+27912429049419a2/node_modules/zod-to-json-schema/dist/esm/parsers/date.js
45176
+ // node_modules/.bun/zod-to-json-schema@3.25.2+27912429049419a2/node_modules/zod-to-json-schema/dist/esm/parsers/date.js
44466
45177
  function parseDateDef(def, refs, overrideDateStrategy) {
44467
45178
  const strategy = overrideDateStrategy ?? refs.dateStrategy;
44468
45179
  if (Array.isArray(strategy)) {
@@ -44508,7 +45219,7 @@ var integerDateParser = (def, refs) => {
44508
45219
  };
44509
45220
  var init_date = () => {};
44510
45221
 
44511
- // node_modules/.bun/zod-to-json-schema@3.25.1+27912429049419a2/node_modules/zod-to-json-schema/dist/esm/parsers/default.js
45222
+ // node_modules/.bun/zod-to-json-schema@3.25.2+27912429049419a2/node_modules/zod-to-json-schema/dist/esm/parsers/default.js
44512
45223
  function parseDefaultDef(_def, refs) {
44513
45224
  return {
44514
45225
  ...parseDef(_def.innerType._def, refs),
@@ -44519,7 +45230,7 @@ var init_default = __esm(() => {
44519
45230
  init_parseDef();
44520
45231
  });
44521
45232
 
44522
- // node_modules/.bun/zod-to-json-schema@3.25.1+27912429049419a2/node_modules/zod-to-json-schema/dist/esm/parsers/effects.js
45233
+ // node_modules/.bun/zod-to-json-schema@3.25.2+27912429049419a2/node_modules/zod-to-json-schema/dist/esm/parsers/effects.js
44523
45234
  function parseEffectsDef(_def, refs) {
44524
45235
  return refs.effectStrategy === "input" ? parseDef(_def.schema._def, refs) : parseAnyDef(refs);
44525
45236
  }
@@ -44528,7 +45239,7 @@ var init_effects = __esm(() => {
44528
45239
  init_any();
44529
45240
  });
44530
45241
 
44531
- // node_modules/.bun/zod-to-json-schema@3.25.1+27912429049419a2/node_modules/zod-to-json-schema/dist/esm/parsers/enum.js
45242
+ // node_modules/.bun/zod-to-json-schema@3.25.2+27912429049419a2/node_modules/zod-to-json-schema/dist/esm/parsers/enum.js
44532
45243
  function parseEnumDef(def) {
44533
45244
  return {
44534
45245
  type: "string",
@@ -44536,7 +45247,7 @@ function parseEnumDef(def) {
44536
45247
  };
44537
45248
  }
44538
45249
 
44539
- // node_modules/.bun/zod-to-json-schema@3.25.1+27912429049419a2/node_modules/zod-to-json-schema/dist/esm/parsers/intersection.js
45250
+ // node_modules/.bun/zod-to-json-schema@3.25.2+27912429049419a2/node_modules/zod-to-json-schema/dist/esm/parsers/intersection.js
44540
45251
  function parseIntersectionDef(def, refs) {
44541
45252
  const allOf = [
44542
45253
  parseDef(def.left._def, {
@@ -44581,7 +45292,7 @@ var init_intersection = __esm(() => {
44581
45292
  init_parseDef();
44582
45293
  });
44583
45294
 
44584
- // node_modules/.bun/zod-to-json-schema@3.25.1+27912429049419a2/node_modules/zod-to-json-schema/dist/esm/parsers/literal.js
45295
+ // node_modules/.bun/zod-to-json-schema@3.25.2+27912429049419a2/node_modules/zod-to-json-schema/dist/esm/parsers/literal.js
44585
45296
  function parseLiteralDef(def, refs) {
44586
45297
  const parsedType2 = typeof def.value;
44587
45298
  if (parsedType2 !== "bigint" && parsedType2 !== "number" && parsedType2 !== "boolean" && parsedType2 !== "string") {
@@ -44601,7 +45312,7 @@ function parseLiteralDef(def, refs) {
44601
45312
  };
44602
45313
  }
44603
45314
 
44604
- // node_modules/.bun/zod-to-json-schema@3.25.1+27912429049419a2/node_modules/zod-to-json-schema/dist/esm/parsers/string.js
45315
+ // node_modules/.bun/zod-to-json-schema@3.25.2+27912429049419a2/node_modules/zod-to-json-schema/dist/esm/parsers/string.js
44605
45316
  function parseStringDef(def, refs) {
44606
45317
  const res = {
44607
45318
  type: "string"
@@ -44900,7 +45611,7 @@ var init_string = __esm(() => {
44900
45611
  ALPHA_NUMERIC = new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");
44901
45612
  });
44902
45613
 
44903
- // node_modules/.bun/zod-to-json-schema@3.25.1+27912429049419a2/node_modules/zod-to-json-schema/dist/esm/parsers/record.js
45614
+ // node_modules/.bun/zod-to-json-schema@3.25.2+27912429049419a2/node_modules/zod-to-json-schema/dist/esm/parsers/record.js
44904
45615
  function parseRecordDef(def, refs) {
44905
45616
  if (refs.target === "openAi") {
44906
45617
  console.warn("Warning: OpenAI may not support records in schemas! Try an array of key-value pairs instead.");
@@ -44959,7 +45670,7 @@ var init_record = __esm(() => {
44959
45670
  init_any();
44960
45671
  });
44961
45672
 
44962
- // node_modules/.bun/zod-to-json-schema@3.25.1+27912429049419a2/node_modules/zod-to-json-schema/dist/esm/parsers/map.js
45673
+ // node_modules/.bun/zod-to-json-schema@3.25.2+27912429049419a2/node_modules/zod-to-json-schema/dist/esm/parsers/map.js
44963
45674
  function parseMapDef(def, refs) {
44964
45675
  if (refs.mapStrategy === "record") {
44965
45676
  return parseRecordDef(def, refs);
@@ -44989,7 +45700,7 @@ var init_map = __esm(() => {
44989
45700
  init_any();
44990
45701
  });
44991
45702
 
44992
- // node_modules/.bun/zod-to-json-schema@3.25.1+27912429049419a2/node_modules/zod-to-json-schema/dist/esm/parsers/nativeEnum.js
45703
+ // node_modules/.bun/zod-to-json-schema@3.25.2+27912429049419a2/node_modules/zod-to-json-schema/dist/esm/parsers/nativeEnum.js
44993
45704
  function parseNativeEnumDef(def) {
44994
45705
  const object3 = def.values;
44995
45706
  const actualKeys = Object.keys(def.values).filter((key2) => {
@@ -45003,7 +45714,7 @@ function parseNativeEnumDef(def) {
45003
45714
  };
45004
45715
  }
45005
45716
 
45006
- // node_modules/.bun/zod-to-json-schema@3.25.1+27912429049419a2/node_modules/zod-to-json-schema/dist/esm/parsers/never.js
45717
+ // node_modules/.bun/zod-to-json-schema@3.25.2+27912429049419a2/node_modules/zod-to-json-schema/dist/esm/parsers/never.js
45007
45718
  function parseNeverDef(refs) {
45008
45719
  return refs.target === "openAi" ? undefined : {
45009
45720
  not: parseAnyDef({
@@ -45016,7 +45727,7 @@ var init_never = __esm(() => {
45016
45727
  init_any();
45017
45728
  });
45018
45729
 
45019
- // node_modules/.bun/zod-to-json-schema@3.25.1+27912429049419a2/node_modules/zod-to-json-schema/dist/esm/parsers/null.js
45730
+ // node_modules/.bun/zod-to-json-schema@3.25.2+27912429049419a2/node_modules/zod-to-json-schema/dist/esm/parsers/null.js
45020
45731
  function parseNullDef(refs) {
45021
45732
  return refs.target === "openApi3" ? {
45022
45733
  enum: ["null"],
@@ -45026,7 +45737,7 @@ function parseNullDef(refs) {
45026
45737
  };
45027
45738
  }
45028
45739
 
45029
- // node_modules/.bun/zod-to-json-schema@3.25.1+27912429049419a2/node_modules/zod-to-json-schema/dist/esm/parsers/union.js
45740
+ // node_modules/.bun/zod-to-json-schema@3.25.2+27912429049419a2/node_modules/zod-to-json-schema/dist/esm/parsers/union.js
45030
45741
  function parseUnionDef(def, refs) {
45031
45742
  if (refs.target === "openApi3")
45032
45743
  return asAnyOf(def, refs);
@@ -45097,7 +45808,7 @@ var init_union = __esm(() => {
45097
45808
  };
45098
45809
  });
45099
45810
 
45100
- // node_modules/.bun/zod-to-json-schema@3.25.1+27912429049419a2/node_modules/zod-to-json-schema/dist/esm/parsers/nullable.js
45811
+ // node_modules/.bun/zod-to-json-schema@3.25.2+27912429049419a2/node_modules/zod-to-json-schema/dist/esm/parsers/nullable.js
45101
45812
  function parseNullableDef(def, refs) {
45102
45813
  if (["ZodString", "ZodNumber", "ZodBigInt", "ZodBoolean", "ZodNull"].includes(def.innerType._def.typeName) && (!def.innerType._def.checks || !def.innerType._def.checks.length)) {
45103
45814
  if (refs.target === "openApi3") {
@@ -45133,7 +45844,7 @@ var init_nullable = __esm(() => {
45133
45844
  init_union();
45134
45845
  });
45135
45846
 
45136
- // node_modules/.bun/zod-to-json-schema@3.25.1+27912429049419a2/node_modules/zod-to-json-schema/dist/esm/parsers/number.js
45847
+ // node_modules/.bun/zod-to-json-schema@3.25.2+27912429049419a2/node_modules/zod-to-json-schema/dist/esm/parsers/number.js
45137
45848
  function parseNumberDef(def, refs) {
45138
45849
  const res = {
45139
45850
  type: "number"
@@ -45183,7 +45894,7 @@ function parseNumberDef(def, refs) {
45183
45894
  }
45184
45895
  var init_number = () => {};
45185
45896
 
45186
- // node_modules/.bun/zod-to-json-schema@3.25.1+27912429049419a2/node_modules/zod-to-json-schema/dist/esm/parsers/object.js
45897
+ // node_modules/.bun/zod-to-json-schema@3.25.2+27912429049419a2/node_modules/zod-to-json-schema/dist/esm/parsers/object.js
45187
45898
  function parseObjectDef(def, refs) {
45188
45899
  const forceOptionalIntoNullable = refs.target === "openAi";
45189
45900
  const result = {
@@ -45256,7 +45967,7 @@ var init_object = __esm(() => {
45256
45967
  init_parseDef();
45257
45968
  });
45258
45969
 
45259
- // node_modules/.bun/zod-to-json-schema@3.25.1+27912429049419a2/node_modules/zod-to-json-schema/dist/esm/parsers/optional.js
45970
+ // node_modules/.bun/zod-to-json-schema@3.25.2+27912429049419a2/node_modules/zod-to-json-schema/dist/esm/parsers/optional.js
45260
45971
  var parseOptionalDef = (def, refs) => {
45261
45972
  if (refs.currentPath.toString() === refs.propertyPath?.toString()) {
45262
45973
  return parseDef(def.innerType._def, refs);
@@ -45279,7 +45990,7 @@ var init_optional = __esm(() => {
45279
45990
  init_any();
45280
45991
  });
45281
45992
 
45282
- // node_modules/.bun/zod-to-json-schema@3.25.1+27912429049419a2/node_modules/zod-to-json-schema/dist/esm/parsers/pipeline.js
45993
+ // node_modules/.bun/zod-to-json-schema@3.25.2+27912429049419a2/node_modules/zod-to-json-schema/dist/esm/parsers/pipeline.js
45283
45994
  var parsePipelineDef = (def, refs) => {
45284
45995
  if (refs.pipeStrategy === "input") {
45285
45996
  return parseDef(def.in._def, refs);
@@ -45302,7 +46013,7 @@ var init_pipeline = __esm(() => {
45302
46013
  init_parseDef();
45303
46014
  });
45304
46015
 
45305
- // node_modules/.bun/zod-to-json-schema@3.25.1+27912429049419a2/node_modules/zod-to-json-schema/dist/esm/parsers/promise.js
46016
+ // node_modules/.bun/zod-to-json-schema@3.25.2+27912429049419a2/node_modules/zod-to-json-schema/dist/esm/parsers/promise.js
45306
46017
  function parsePromiseDef(def, refs) {
45307
46018
  return parseDef(def.type._def, refs);
45308
46019
  }
@@ -45310,7 +46021,7 @@ var init_promise = __esm(() => {
45310
46021
  init_parseDef();
45311
46022
  });
45312
46023
 
45313
- // node_modules/.bun/zod-to-json-schema@3.25.1+27912429049419a2/node_modules/zod-to-json-schema/dist/esm/parsers/set.js
46024
+ // node_modules/.bun/zod-to-json-schema@3.25.2+27912429049419a2/node_modules/zod-to-json-schema/dist/esm/parsers/set.js
45314
46025
  function parseSetDef(def, refs) {
45315
46026
  const items = parseDef(def.valueType._def, {
45316
46027
  ...refs,
@@ -45333,7 +46044,7 @@ var init_set = __esm(() => {
45333
46044
  init_parseDef();
45334
46045
  });
45335
46046
 
45336
- // node_modules/.bun/zod-to-json-schema@3.25.1+27912429049419a2/node_modules/zod-to-json-schema/dist/esm/parsers/tuple.js
46047
+ // node_modules/.bun/zod-to-json-schema@3.25.2+27912429049419a2/node_modules/zod-to-json-schema/dist/esm/parsers/tuple.js
45337
46048
  function parseTupleDef(def, refs) {
45338
46049
  if (def.rest) {
45339
46050
  return {
@@ -45364,7 +46075,7 @@ var init_tuple = __esm(() => {
45364
46075
  init_parseDef();
45365
46076
  });
45366
46077
 
45367
- // node_modules/.bun/zod-to-json-schema@3.25.1+27912429049419a2/node_modules/zod-to-json-schema/dist/esm/parsers/undefined.js
46078
+ // node_modules/.bun/zod-to-json-schema@3.25.2+27912429049419a2/node_modules/zod-to-json-schema/dist/esm/parsers/undefined.js
45368
46079
  function parseUndefinedDef(refs) {
45369
46080
  return {
45370
46081
  not: parseAnyDef(refs)
@@ -45374,7 +46085,7 @@ var init_undefined = __esm(() => {
45374
46085
  init_any();
45375
46086
  });
45376
46087
 
45377
- // node_modules/.bun/zod-to-json-schema@3.25.1+27912429049419a2/node_modules/zod-to-json-schema/dist/esm/parsers/unknown.js
46088
+ // node_modules/.bun/zod-to-json-schema@3.25.2+27912429049419a2/node_modules/zod-to-json-schema/dist/esm/parsers/unknown.js
45378
46089
  function parseUnknownDef(refs) {
45379
46090
  return parseAnyDef(refs);
45380
46091
  }
@@ -45382,7 +46093,7 @@ var init_unknown = __esm(() => {
45382
46093
  init_any();
45383
46094
  });
45384
46095
 
45385
- // node_modules/.bun/zod-to-json-schema@3.25.1+27912429049419a2/node_modules/zod-to-json-schema/dist/esm/parsers/readonly.js
46096
+ // node_modules/.bun/zod-to-json-schema@3.25.2+27912429049419a2/node_modules/zod-to-json-schema/dist/esm/parsers/readonly.js
45386
46097
  var parseReadonlyDef = (def, refs) => {
45387
46098
  return parseDef(def.innerType._def, refs);
45388
46099
  };
@@ -45390,7 +46101,7 @@ var init_readonly = __esm(() => {
45390
46101
  init_parseDef();
45391
46102
  });
45392
46103
 
45393
- // node_modules/.bun/zod-to-json-schema@3.25.1+27912429049419a2/node_modules/zod-to-json-schema/dist/esm/selectParser.js
46104
+ // node_modules/.bun/zod-to-json-schema@3.25.2+27912429049419a2/node_modules/zod-to-json-schema/dist/esm/selectParser.js
45394
46105
  var selectParser = (def, typeName, refs) => {
45395
46106
  switch (typeName) {
45396
46107
  case ZodFirstPartyTypeKind.ZodString:
@@ -45496,7 +46207,7 @@ var init_selectParser = __esm(() => {
45496
46207
  init_readonly();
45497
46208
  });
45498
46209
 
45499
- // node_modules/.bun/zod-to-json-schema@3.25.1+27912429049419a2/node_modules/zod-to-json-schema/dist/esm/parseDef.js
46210
+ // node_modules/.bun/zod-to-json-schema@3.25.2+27912429049419a2/node_modules/zod-to-json-schema/dist/esm/parseDef.js
45500
46211
  function parseDef(def, refs, forceResolution = false) {
45501
46212
  const seenItem = refs.seen.get(def);
45502
46213
  if (refs.override) {
@@ -45556,10 +46267,10 @@ var init_parseDef = __esm(() => {
45556
46267
  init_any();
45557
46268
  });
45558
46269
 
45559
- // node_modules/.bun/zod-to-json-schema@3.25.1+27912429049419a2/node_modules/zod-to-json-schema/dist/esm/parseTypes.js
46270
+ // node_modules/.bun/zod-to-json-schema@3.25.2+27912429049419a2/node_modules/zod-to-json-schema/dist/esm/parseTypes.js
45560
46271
  var init_parseTypes = () => {};
45561
46272
 
45562
- // node_modules/.bun/zod-to-json-schema@3.25.1+27912429049419a2/node_modules/zod-to-json-schema/dist/esm/zodToJsonSchema.js
46273
+ // node_modules/.bun/zod-to-json-schema@3.25.2+27912429049419a2/node_modules/zod-to-json-schema/dist/esm/zodToJsonSchema.js
45563
46274
  var zodToJsonSchema = (schema2, options) => {
45564
46275
  const refs = getRefs(options);
45565
46276
  let definitions = typeof options === "object" && options.definitions ? Object.entries(options.definitions).reduce((acc, [name2, schema3]) => ({
@@ -45625,7 +46336,7 @@ var init_zodToJsonSchema = __esm(() => {
45625
46336
  init_any();
45626
46337
  });
45627
46338
 
45628
- // node_modules/.bun/zod-to-json-schema@3.25.1+27912429049419a2/node_modules/zod-to-json-schema/dist/esm/index.js
46339
+ // node_modules/.bun/zod-to-json-schema@3.25.2+27912429049419a2/node_modules/zod-to-json-schema/dist/esm/index.js
45629
46340
  var init_esm = __esm(() => {
45630
46341
  init_zodToJsonSchema();
45631
46342
  init_Options();
@@ -45661,7 +46372,7 @@ var init_esm = __esm(() => {
45661
46372
  init_zodToJsonSchema();
45662
46373
  });
45663
46374
 
45664
- // node_modules/.bun/@modelcontextprotocol+sdk@1.26.0/node_modules/@modelcontextprotocol/sdk/dist/esm/server/zod-json-schema-compat.js
46375
+ // node_modules/.bun/@modelcontextprotocol+sdk@1.30.0/node_modules/@modelcontextprotocol/sdk/dist/esm/server/zod-json-schema-compat.js
45665
46376
  function mapMiniTarget(t) {
45666
46377
  if (!t)
45667
46378
  return "draft-7";
@@ -45708,7 +46419,7 @@ var init_zod_json_schema_compat = __esm(() => {
45708
46419
  init_esm();
45709
46420
  });
45710
46421
 
45711
- // node_modules/.bun/@modelcontextprotocol+sdk@1.26.0/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/protocol.js
46422
+ // node_modules/.bun/@modelcontextprotocol+sdk@1.30.0/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/protocol.js
45712
46423
  class Protocol {
45713
46424
  constructor(_options) {
45714
46425
  this._options = _options;
@@ -45910,6 +46621,10 @@ class Protocol {
45910
46621
  this._progressHandlers.clear();
45911
46622
  this._taskProgressTokens.clear();
45912
46623
  this._pendingDebouncedNotifications.clear();
46624
+ for (const info of this._timeoutInfo.values()) {
46625
+ clearTimeout(info.timeoutId);
46626
+ }
46627
+ this._timeoutInfo.clear();
45913
46628
  for (const controller of this._requestHandlerAbortControllers.values()) {
45914
46629
  controller.abort();
45915
46630
  }
@@ -46040,7 +46755,9 @@ class Protocol {
46040
46755
  await capturedTransport?.send(errorResponse);
46041
46756
  }
46042
46757
  }).catch((error3) => this._onerror(new Error(`Failed to send response: ${error3}`))).finally(() => {
46043
- this._requestHandlerAbortControllers.delete(request.id);
46758
+ if (this._requestHandlerAbortControllers.get(request.id) === abortController) {
46759
+ this._requestHandlerAbortControllers.delete(request.id);
46760
+ }
46044
46761
  });
46045
46762
  }
46046
46763
  _onprogress(notification) {
@@ -52868,7 +53585,7 @@ var require_formats = __commonJS((exports) => {
52868
53585
  email: /^[a-z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?)*$/i
52869
53586
  };
52870
53587
  exports.formatNames = Object.keys(exports.fullFormats);
52871
- function isLeapYear(year) {
53588
+ function isLeapYear2(year) {
52872
53589
  return year % 4 === 0 && (year % 100 !== 0 || year % 400 === 0);
52873
53590
  }
52874
53591
  var DATE = /^(\d\d\d\d)-(\d\d)-(\d\d)$/;
@@ -52880,7 +53597,7 @@ var require_formats = __commonJS((exports) => {
52880
53597
  const year = +matches[1];
52881
53598
  const month = +matches[2];
52882
53599
  const day = +matches[3];
52883
- return month >= 1 && month <= 12 && day >= 1 && day <= (month === 2 && isLeapYear(year) ? 29 : DAYS[month]);
53600
+ return month >= 1 && month <= 12 && day >= 1 && day <= (month === 2 && isLeapYear2(year) ? 29 : DAYS[month]);
52884
53601
  }
52885
53602
  function compareDate(d1, d2) {
52886
53603
  if (!(d1 && d2))
@@ -53106,7 +53823,7 @@ var require_dist = __commonJS((exports, module) => {
53106
53823
  exports.default = formatsPlugin;
53107
53824
  });
53108
53825
 
53109
- // node_modules/.bun/@modelcontextprotocol+sdk@1.26.0/node_modules/@modelcontextprotocol/sdk/dist/esm/validation/ajv-provider.js
53826
+ // node_modules/.bun/@modelcontextprotocol+sdk@1.30.0/node_modules/@modelcontextprotocol/sdk/dist/esm/validation/ajv-provider.js
53110
53827
  function createDefaultAjvInstance() {
53111
53828
  const ajv = new import_ajv.default({
53112
53829
  strict: false,
@@ -53149,7 +53866,7 @@ var init_ajv_provider = __esm(() => {
53149
53866
  import_ajv_formats = __toESM(require_dist(), 1);
53150
53867
  });
53151
53868
 
53152
- // node_modules/.bun/@modelcontextprotocol+sdk@1.26.0/node_modules/@modelcontextprotocol/sdk/dist/esm/experimental/tasks/server.js
53869
+ // node_modules/.bun/@modelcontextprotocol+sdk@1.30.0/node_modules/@modelcontextprotocol/sdk/dist/esm/experimental/tasks/server.js
53153
53870
  class ExperimentalServerTasks {
53154
53871
  constructor(_server) {
53155
53872
  this._server = _server;
@@ -53157,6 +53874,62 @@ class ExperimentalServerTasks {
53157
53874
  requestStream(request, resultSchema, options) {
53158
53875
  return this._server.requestStream(request, resultSchema, options);
53159
53876
  }
53877
+ createMessageStream(params, options) {
53878
+ const clientCapabilities = this._server.getClientCapabilities();
53879
+ if ((params.tools || params.toolChoice) && !clientCapabilities?.sampling?.tools) {
53880
+ throw new Error("Client does not support sampling tools capability.");
53881
+ }
53882
+ if (params.messages.length > 0) {
53883
+ const lastMessage = params.messages[params.messages.length - 1];
53884
+ const lastContent = Array.isArray(lastMessage.content) ? lastMessage.content : [lastMessage.content];
53885
+ const hasToolResults = lastContent.some((c) => c.type === "tool_result");
53886
+ const previousMessage = params.messages.length > 1 ? params.messages[params.messages.length - 2] : undefined;
53887
+ const previousContent = previousMessage ? Array.isArray(previousMessage.content) ? previousMessage.content : [previousMessage.content] : [];
53888
+ const hasPreviousToolUse = previousContent.some((c) => c.type === "tool_use");
53889
+ if (hasToolResults) {
53890
+ if (lastContent.some((c) => c.type !== "tool_result")) {
53891
+ throw new Error("The last message must contain only tool_result content if any is present");
53892
+ }
53893
+ if (!hasPreviousToolUse) {
53894
+ throw new Error("tool_result blocks are not matching any tool_use from the previous message");
53895
+ }
53896
+ }
53897
+ if (hasPreviousToolUse) {
53898
+ const toolUseIds = new Set(previousContent.filter((c) => c.type === "tool_use").map((c) => c.id));
53899
+ const toolResultIds = new Set(lastContent.filter((c) => c.type === "tool_result").map((c) => c.toolUseId));
53900
+ if (toolUseIds.size !== toolResultIds.size || ![...toolUseIds].every((id) => toolResultIds.has(id))) {
53901
+ throw new Error("ids of tool_result blocks and tool_use blocks from previous message do not match");
53902
+ }
53903
+ }
53904
+ }
53905
+ return this.requestStream({
53906
+ method: "sampling/createMessage",
53907
+ params
53908
+ }, CreateMessageResultSchema, options);
53909
+ }
53910
+ elicitInputStream(params, options) {
53911
+ const clientCapabilities = this._server.getClientCapabilities();
53912
+ const mode = params.mode ?? "form";
53913
+ switch (mode) {
53914
+ case "url": {
53915
+ if (!clientCapabilities?.elicitation?.url) {
53916
+ throw new Error("Client does not support url elicitation.");
53917
+ }
53918
+ break;
53919
+ }
53920
+ case "form": {
53921
+ if (!clientCapabilities?.elicitation?.form) {
53922
+ throw new Error("Client does not support form elicitation.");
53923
+ }
53924
+ break;
53925
+ }
53926
+ }
53927
+ const normalizedParams = mode === "form" && params.mode === undefined ? { ...params, mode: "form" } : params;
53928
+ return this.requestStream({
53929
+ method: "elicitation/create",
53930
+ params: normalizedParams
53931
+ }, ElicitResultSchema, options);
53932
+ }
53160
53933
  async getTask(taskId, options) {
53161
53934
  return this._server.getTask({ taskId }, options);
53162
53935
  }
@@ -53170,8 +53943,11 @@ class ExperimentalServerTasks {
53170
53943
  return this._server.cancelTask({ taskId }, options);
53171
53944
  }
53172
53945
  }
53946
+ var init_server = __esm(() => {
53947
+ init_types7();
53948
+ });
53173
53949
 
53174
- // node_modules/.bun/@modelcontextprotocol+sdk@1.26.0/node_modules/@modelcontextprotocol/sdk/dist/esm/experimental/tasks/helpers.js
53950
+ // node_modules/.bun/@modelcontextprotocol+sdk@1.30.0/node_modules/@modelcontextprotocol/sdk/dist/esm/experimental/tasks/helpers.js
53175
53951
  function assertToolsCallTaskCapability(requests, method, entityName) {
53176
53952
  if (!requests) {
53177
53953
  throw new Error(`${entityName} does not support task creation (required for ${method})`);
@@ -53206,13 +53982,14 @@ function assertClientRequestTaskCapability(requests, method, entityName) {
53206
53982
  }
53207
53983
  }
53208
53984
 
53209
- // node_modules/.bun/@modelcontextprotocol+sdk@1.26.0/node_modules/@modelcontextprotocol/sdk/dist/esm/server/index.js
53985
+ // node_modules/.bun/@modelcontextprotocol+sdk@1.30.0/node_modules/@modelcontextprotocol/sdk/dist/esm/server/index.js
53210
53986
  var Server;
53211
- var init_server = __esm(() => {
53987
+ var init_server2 = __esm(() => {
53212
53988
  init_protocol();
53213
53989
  init_types7();
53214
53990
  init_ajv_provider();
53215
53991
  init_zod_compat();
53992
+ init_server();
53216
53993
  Server = class Server extends Protocol {
53217
53994
  constructor(_serverInfo, options) {
53218
53995
  super(options);
@@ -53260,16 +54037,7 @@ var init_server = __esm(() => {
53260
54037
  if (!methodSchema) {
53261
54038
  throw new Error("Schema is missing a method literal");
53262
54039
  }
53263
- let methodValue;
53264
- if (isZ4Schema(methodSchema)) {
53265
- const v4Schema = methodSchema;
53266
- const v4Def = v4Schema._zod?.def;
53267
- methodValue = v4Def?.value ?? v4Schema.value;
53268
- } else {
53269
- const v3Schema = methodSchema;
53270
- const legacyDef = v3Schema._def;
53271
- methodValue = legacyDef?.value ?? v3Schema.value;
53272
- }
54040
+ const methodValue = getLiteralValue(methodSchema);
53273
54041
  if (typeof methodValue !== "string") {
53274
54042
  throw new Error("Schema method literal must be a string");
53275
54043
  }
@@ -53546,7 +54314,7 @@ var init_server = __esm(() => {
53546
54314
  };
53547
54315
  });
53548
54316
 
53549
- // node_modules/.bun/@modelcontextprotocol+sdk@1.26.0/node_modules/@modelcontextprotocol/sdk/dist/esm/server/completable.js
54317
+ // node_modules/.bun/@modelcontextprotocol+sdk@1.30.0/node_modules/@modelcontextprotocol/sdk/dist/esm/server/completable.js
53550
54318
  function isCompletable(schema2) {
53551
54319
  return !!schema2 && typeof schema2 === "object" && COMPLETABLE_SYMBOL in schema2;
53552
54320
  }
@@ -53561,7 +54329,7 @@ var init_completable = __esm(() => {
53561
54329
  McpZodTypeKind2["Completable"] = "McpCompletable";
53562
54330
  })(McpZodTypeKind || (McpZodTypeKind = {}));
53563
54331
  });
53564
- // node_modules/.bun/@modelcontextprotocol+sdk@1.26.0/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/toolNameValidation.js
54332
+ // node_modules/.bun/@modelcontextprotocol+sdk@1.30.0/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/toolNameValidation.js
53565
54333
  function validateToolName(name) {
53566
54334
  const warnings = [];
53567
54335
  if (name.length === 0) {
@@ -53622,7 +54390,7 @@ var init_toolNameValidation = __esm(() => {
53622
54390
  TOOL_NAME_REGEX = /^[A-Za-z0-9._-]{1,128}$/;
53623
54391
  });
53624
54392
 
53625
- // node_modules/.bun/@modelcontextprotocol+sdk@1.26.0/node_modules/@modelcontextprotocol/sdk/dist/esm/experimental/tasks/mcp-server.js
54393
+ // node_modules/.bun/@modelcontextprotocol+sdk@1.30.0/node_modules/@modelcontextprotocol/sdk/dist/esm/experimental/tasks/mcp-server.js
53626
54394
  class ExperimentalMcpServerTasks {
53627
54395
  constructor(_mcpServer) {
53628
54396
  this._mcpServer = _mcpServer;
@@ -53637,7 +54405,7 @@ class ExperimentalMcpServerTasks {
53637
54405
  }
53638
54406
  }
53639
54407
 
53640
- // node_modules/.bun/@modelcontextprotocol+sdk@1.26.0/node_modules/@modelcontextprotocol/sdk/dist/esm/server/mcp.js
54408
+ // node_modules/.bun/@modelcontextprotocol+sdk@1.30.0/node_modules/@modelcontextprotocol/sdk/dist/esm/server/mcp.js
53641
54409
  class McpServer {
53642
54410
  constructor(serverInfo, options) {
53643
54411
  this._registeredResources = {};
@@ -54221,6 +54989,9 @@ class McpServer {
54221
54989
  annotations = rest.shift();
54222
54990
  }
54223
54991
  } else if (typeof firstArg === "object" && firstArg !== null) {
54992
+ if (Object.values(firstArg).some((v) => typeof v === "object" && v !== null)) {
54993
+ throw new Error(`Tool ${name} expected a Zod schema or ToolAnnotations, but received an unrecognized object`);
54994
+ }
54224
54995
  annotations = rest.shift();
54225
54996
  }
54226
54997
  }
@@ -54309,6 +55080,9 @@ function getZodSchemaObject(schema2) {
54309
55080
  if (isZodRawShapeCompat(schema2)) {
54310
55081
  return objectFromShape(schema2);
54311
55082
  }
55083
+ if (!isZodSchemaInstance(schema2)) {
55084
+ throw new Error("inputSchema must be a Zod schema or raw shape, received an unrecognized object");
55085
+ }
54312
55086
  return schema2;
54313
55087
  }
54314
55088
  function promptArgumentsFromSchema(schema2) {
@@ -54348,7 +55122,7 @@ function createCompletionResult(suggestions) {
54348
55122
  }
54349
55123
  var EMPTY_OBJECT_JSON_SCHEMA, EMPTY_COMPLETION_RESULT;
54350
55124
  var init_mcp = __esm(() => {
54351
- init_server();
55125
+ init_server2();
54352
55126
  init_zod_compat();
54353
55127
  init_zod_json_schema_compat();
54354
55128
  init_types7();
@@ -54367,9 +55141,17 @@ var init_mcp = __esm(() => {
54367
55141
  };
54368
55142
  });
54369
55143
 
54370
- // node_modules/.bun/@modelcontextprotocol+sdk@1.26.0/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/stdio.js
55144
+ // node_modules/.bun/@modelcontextprotocol+sdk@1.30.0/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/stdio.js
54371
55145
  class ReadBuffer {
55146
+ constructor(options) {
55147
+ this._maxBufferSize = options?.maxBufferSize ?? STDIO_DEFAULT_MAX_BUFFER_SIZE;
55148
+ }
54372
55149
  append(chunk) {
55150
+ const newSize = (this._buffer?.length ?? 0) + chunk.length;
55151
+ if (newSize > this._maxBufferSize) {
55152
+ this.clear();
55153
+ throw new Error(`ReadBuffer exceeded maximum size of ${this._maxBufferSize} bytes`);
55154
+ }
54373
55155
  this._buffer = this._buffer ? Buffer.concat([this._buffer, chunk]) : chunk;
54374
55156
  }
54375
55157
  readMessage() {
@@ -54396,26 +55178,33 @@ function serializeMessage(message) {
54396
55178
  return JSON.stringify(message) + `
54397
55179
  `;
54398
55180
  }
55181
+ var STDIO_DEFAULT_MAX_BUFFER_SIZE;
54399
55182
  var init_stdio = __esm(() => {
54400
55183
  init_types7();
55184
+ STDIO_DEFAULT_MAX_BUFFER_SIZE = 10 * 1024 * 1024;
54401
55185
  });
54402
55186
 
54403
- // node_modules/.bun/@modelcontextprotocol+sdk@1.26.0/node_modules/@modelcontextprotocol/sdk/dist/esm/server/stdio.js
55187
+ // node_modules/.bun/@modelcontextprotocol+sdk@1.30.0/node_modules/@modelcontextprotocol/sdk/dist/esm/server/stdio.js
54404
55188
  import process2 from "process";
54405
55189
 
54406
55190
  class StdioServerTransport {
54407
- constructor(_stdin = process2.stdin, _stdout = process2.stdout) {
55191
+ constructor(_stdin = process2.stdin, _stdout = process2.stdout, options) {
54408
55192
  this._stdin = _stdin;
54409
55193
  this._stdout = _stdout;
54410
- this._readBuffer = new ReadBuffer;
54411
55194
  this._started = false;
54412
55195
  this._ondata = (chunk) => {
54413
- this._readBuffer.append(chunk);
54414
- this.processReadBuffer();
55196
+ try {
55197
+ this._readBuffer.append(chunk);
55198
+ this.processReadBuffer();
55199
+ } catch (error3) {
55200
+ this.onerror?.(error3);
55201
+ this.close().catch(() => {});
55202
+ }
54415
55203
  };
54416
55204
  this._onerror = (error3) => {
54417
55205
  this.onerror?.(error3);
54418
55206
  };
55207
+ this._readBuffer = new ReadBuffer({ maxBufferSize: options?.maxBufferSize });
54419
55208
  }
54420
55209
  async start() {
54421
55210
  if (this._started) {
@@ -55696,7 +56485,7 @@ var init_assignee_context = __esm(() => {
55696
56485
  init_assignee_validation();
55697
56486
  });
55698
56487
 
55699
- // node_modules/.bun/@hasna+contracts@0.13.3+86f0f4a9d69523e0/node_modules/@hasna/contracts/dist/client/storage.js
56488
+ // node_modules/.bun/@hasna+contracts@0.13.4+ad7b1171e6eea7eb/node_modules/@hasna/contracts/dist/client/storage.js
55700
56489
  import { isIP } from "net";
55701
56490
  import { readFileSync as readFileSync5, statSync as statSync4 } from "fs";
55702
56491
  import { join as join10 } from "path";
@@ -58156,6 +58945,7 @@ var init_cloud_router = __esm(() => {
58156
58945
  init_storage();
58157
58946
  init_types();
58158
58947
  init_redaction();
58948
+ init_instant_compare();
58159
58949
  init_plan_project_link_contract();
58160
58950
  init_http_client();
58161
58951
  init_adoption_validation();
@@ -85310,7 +86100,7 @@ var require_v4_mini = __commonJS((exports) => {
85310
86100
  __exportStar(require_mini(), exports);
85311
86101
  });
85312
86102
 
85313
- // node_modules/.bun/@modelcontextprotocol+sdk@1.26.0/node_modules/@modelcontextprotocol/sdk/dist/cjs/server/zod-compat.js
86103
+ // node_modules/.bun/@modelcontextprotocol+sdk@1.30.0/node_modules/@modelcontextprotocol/sdk/dist/cjs/server/zod-compat.js
85314
86104
  var require_zod_compat = __commonJS((exports) => {
85315
86105
  var __createBinding = exports && exports.__createBinding || (Object.create ? function(o, m, k, k2) {
85316
86106
  if (k2 === undefined)
@@ -85440,17 +86230,34 @@ var require_zod_compat = __commonJS((exports) => {
85440
86230
  }
85441
86231
  return;
85442
86232
  }
86233
+ function getDotPath2(path) {
86234
+ if (path.length === 0) {
86235
+ return "object root";
86236
+ }
86237
+ return path.reduce((acc, seg, index) => {
86238
+ if (index === 0) {
86239
+ return String(seg);
86240
+ }
86241
+ if (typeof seg === "number") {
86242
+ return `${acc}[${seg}]`;
86243
+ }
86244
+ return `${acc}.${seg}`;
86245
+ }, "");
86246
+ }
85443
86247
  function getParseErrorMessage2(error3) {
85444
86248
  if (error3 && typeof error3 === "object") {
86249
+ if ("issues" in error3 && Array.isArray(error3.issues) && error3.issues.length > 0) {
86250
+ return error3.issues.map((i) => {
86251
+ if (!i.path?.length) {
86252
+ return i.message;
86253
+ }
86254
+ return `${i.message} at ${getDotPath2(i.path)}`;
86255
+ }).join(`
86256
+ `);
86257
+ }
85445
86258
  if ("message" in error3 && typeof error3.message === "string") {
85446
86259
  return error3.message;
85447
86260
  }
85448
- if ("issues" in error3 && Array.isArray(error3.issues) && error3.issues.length > 0) {
85449
- const firstIssue = error3.issues[0];
85450
- if (firstIssue && typeof firstIssue === "object" && "message" in firstIssue) {
85451
- return String(firstIssue.message);
85452
- }
85453
- }
85454
86261
  try {
85455
86262
  return JSON.stringify(error3);
85456
86263
  } catch {
@@ -87157,7 +87964,7 @@ var require_v4 = __commonJS((exports) => {
87157
87964
  exports.default = index_js_1.default;
87158
87965
  });
87159
87966
 
87160
- // node_modules/.bun/@modelcontextprotocol+sdk@1.26.0/node_modules/@modelcontextprotocol/sdk/dist/cjs/types.js
87967
+ // node_modules/.bun/@modelcontextprotocol+sdk@1.30.0/node_modules/@modelcontextprotocol/sdk/dist/cjs/types.js
87161
87968
  var require_types3 = __commonJS((exports) => {
87162
87969
  var __createBinding = exports && exports.__createBinding || (Object.create ? function(o, m, k, k2) {
87163
87970
  if (k2 === undefined)
@@ -87208,7 +88015,7 @@ var require_types3 = __commonJS((exports) => {
87208
88015
  exports.ProgressTokenSchema = z.union([z.string(), z.number().int()]);
87209
88016
  exports.CursorSchema = z.string();
87210
88017
  exports.TaskCreationParamsSchema = z.looseObject({
87211
- ttl: z.union([z.number(), z.null()]).optional(),
88018
+ ttl: z.number().optional(),
87212
88019
  pollInterval: z.number().optional()
87213
88020
  });
87214
88021
  exports.TaskMetadataSchema = z.object({
@@ -87370,7 +88177,8 @@ var require_types3 = __commonJS((exports) => {
87370
88177
  roots: z.object({
87371
88178
  listChanged: z.boolean().optional()
87372
88179
  }).optional(),
87373
- tasks: exports.ClientTasksCapabilitySchema.optional()
88180
+ tasks: exports.ClientTasksCapabilitySchema.optional(),
88181
+ extensions: z.record(z.string(), AssertObjectSchema2).optional()
87374
88182
  });
87375
88183
  exports.InitializeRequestParamsSchema = BaseRequestParamsSchema2.extend({
87376
88184
  protocolVersion: z.string(),
@@ -87397,7 +88205,8 @@ var require_types3 = __commonJS((exports) => {
87397
88205
  tools: z.object({
87398
88206
  listChanged: z.boolean().optional()
87399
88207
  }).optional(),
87400
- tasks: exports.ServerTasksCapabilitySchema.optional()
88208
+ tasks: exports.ServerTasksCapabilitySchema.optional(),
88209
+ extensions: z.record(z.string(), AssertObjectSchema2).optional()
87401
88210
  });
87402
88211
  exports.InitializeResultSchema = exports.ResultSchema.extend({
87403
88212
  protocolVersion: z.string(),
@@ -87514,6 +88323,7 @@ var require_types3 = __commonJS((exports) => {
87514
88323
  uri: z.string(),
87515
88324
  description: z.optional(z.string()),
87516
88325
  mimeType: z.optional(z.string()),
88326
+ size: z.optional(z.number()),
87517
88327
  annotations: exports.AnnotationsSchema.optional(),
87518
88328
  _meta: z.optional(z.looseObject({}))
87519
88329
  });
@@ -88057,7 +88867,7 @@ var require_types3 = __commonJS((exports) => {
88057
88867
  exports.UrlElicitationRequiredError = UrlElicitationRequiredError2;
88058
88868
  });
88059
88869
 
88060
- // node_modules/.bun/@modelcontextprotocol+sdk@1.26.0/node_modules/@modelcontextprotocol/sdk/dist/cjs/experimental/tasks/interfaces.js
88870
+ // node_modules/.bun/@modelcontextprotocol+sdk@1.30.0/node_modules/@modelcontextprotocol/sdk/dist/cjs/experimental/tasks/interfaces.js
88061
88871
  var require_interfaces = __commonJS((exports) => {
88062
88872
  Object.defineProperty(exports, "__esModule", { value: true });
88063
88873
  exports.isTerminal = isTerminal2;
@@ -88066,7 +88876,7 @@ var require_interfaces = __commonJS((exports) => {
88066
88876
  }
88067
88877
  });
88068
88878
 
88069
- // node_modules/.bun/zod-to-json-schema@3.25.1+27912429049419a2/node_modules/zod-to-json-schema/dist/cjs/Options.js
88879
+ // node_modules/.bun/zod-to-json-schema@3.25.2+27912429049419a2/node_modules/zod-to-json-schema/dist/cjs/Options.js
88070
88880
  var require_Options = __commonJS((exports) => {
88071
88881
  Object.defineProperty(exports, "__esModule", { value: true });
88072
88882
  exports.getDefaultOptions = exports.defaultOptions = exports.jsonDescription = exports.ignoreOverride = undefined;
@@ -88117,7 +88927,7 @@ var require_Options = __commonJS((exports) => {
88117
88927
  exports.getDefaultOptions = getDefaultOptions2;
88118
88928
  });
88119
88929
 
88120
- // node_modules/.bun/zod-to-json-schema@3.25.1+27912429049419a2/node_modules/zod-to-json-schema/dist/cjs/Refs.js
88930
+ // node_modules/.bun/zod-to-json-schema@3.25.2+27912429049419a2/node_modules/zod-to-json-schema/dist/cjs/Refs.js
88121
88931
  var require_Refs = __commonJS((exports) => {
88122
88932
  Object.defineProperty(exports, "__esModule", { value: true });
88123
88933
  exports.getRefs = undefined;
@@ -88143,7 +88953,7 @@ var require_Refs = __commonJS((exports) => {
88143
88953
  exports.getRefs = getRefs2;
88144
88954
  });
88145
88955
 
88146
- // node_modules/.bun/zod-to-json-schema@3.25.1+27912429049419a2/node_modules/zod-to-json-schema/dist/cjs/errorMessages.js
88956
+ // node_modules/.bun/zod-to-json-schema@3.25.2+27912429049419a2/node_modules/zod-to-json-schema/dist/cjs/errorMessages.js
88147
88957
  var require_errorMessages = __commonJS((exports) => {
88148
88958
  Object.defineProperty(exports, "__esModule", { value: true });
88149
88959
  exports.setResponseValueAndErrors = exports.addErrorMessage = undefined;
@@ -88165,7 +88975,7 @@ var require_errorMessages = __commonJS((exports) => {
88165
88975
  exports.setResponseValueAndErrors = setResponseValueAndErrors2;
88166
88976
  });
88167
88977
 
88168
- // node_modules/.bun/zod-to-json-schema@3.25.1+27912429049419a2/node_modules/zod-to-json-schema/dist/cjs/getRelativePath.js
88978
+ // node_modules/.bun/zod-to-json-schema@3.25.2+27912429049419a2/node_modules/zod-to-json-schema/dist/cjs/getRelativePath.js
88169
88979
  var require_getRelativePath = __commonJS((exports) => {
88170
88980
  Object.defineProperty(exports, "__esModule", { value: true });
88171
88981
  exports.getRelativePath = undefined;
@@ -88180,7 +88990,7 @@ var require_getRelativePath = __commonJS((exports) => {
88180
88990
  exports.getRelativePath = getRelativePath3;
88181
88991
  });
88182
88992
 
88183
- // node_modules/.bun/zod-to-json-schema@3.25.1+27912429049419a2/node_modules/zod-to-json-schema/dist/cjs/parsers/any.js
88993
+ // node_modules/.bun/zod-to-json-schema@3.25.2+27912429049419a2/node_modules/zod-to-json-schema/dist/cjs/parsers/any.js
88184
88994
  var require_any = __commonJS((exports) => {
88185
88995
  Object.defineProperty(exports, "__esModule", { value: true });
88186
88996
  exports.parseAnyDef = undefined;
@@ -88202,7 +89012,7 @@ var require_any = __commonJS((exports) => {
88202
89012
  exports.parseAnyDef = parseAnyDef2;
88203
89013
  });
88204
89014
 
88205
- // node_modules/.bun/zod-to-json-schema@3.25.1+27912429049419a2/node_modules/zod-to-json-schema/dist/cjs/parsers/array.js
89015
+ // node_modules/.bun/zod-to-json-schema@3.25.2+27912429049419a2/node_modules/zod-to-json-schema/dist/cjs/parsers/array.js
88206
89016
  var require_array = __commonJS((exports) => {
88207
89017
  Object.defineProperty(exports, "__esModule", { value: true });
88208
89018
  exports.parseArrayDef = undefined;
@@ -88234,7 +89044,7 @@ var require_array = __commonJS((exports) => {
88234
89044
  exports.parseArrayDef = parseArrayDef2;
88235
89045
  });
88236
89046
 
88237
- // node_modules/.bun/zod-to-json-schema@3.25.1+27912429049419a2/node_modules/zod-to-json-schema/dist/cjs/parsers/bigint.js
89047
+ // node_modules/.bun/zod-to-json-schema@3.25.2+27912429049419a2/node_modules/zod-to-json-schema/dist/cjs/parsers/bigint.js
88238
89048
  var require_bigint = __commonJS((exports) => {
88239
89049
  Object.defineProperty(exports, "__esModule", { value: true });
88240
89050
  exports.parseBigintDef = undefined;
@@ -88286,7 +89096,7 @@ var require_bigint = __commonJS((exports) => {
88286
89096
  exports.parseBigintDef = parseBigintDef2;
88287
89097
  });
88288
89098
 
88289
- // node_modules/.bun/zod-to-json-schema@3.25.1+27912429049419a2/node_modules/zod-to-json-schema/dist/cjs/parsers/boolean.js
89099
+ // node_modules/.bun/zod-to-json-schema@3.25.2+27912429049419a2/node_modules/zod-to-json-schema/dist/cjs/parsers/boolean.js
88290
89100
  var require_boolean = __commonJS((exports) => {
88291
89101
  Object.defineProperty(exports, "__esModule", { value: true });
88292
89102
  exports.parseBooleanDef = undefined;
@@ -88298,7 +89108,7 @@ var require_boolean = __commonJS((exports) => {
88298
89108
  exports.parseBooleanDef = parseBooleanDef2;
88299
89109
  });
88300
89110
 
88301
- // node_modules/.bun/zod-to-json-schema@3.25.1+27912429049419a2/node_modules/zod-to-json-schema/dist/cjs/parsers/branded.js
89111
+ // node_modules/.bun/zod-to-json-schema@3.25.2+27912429049419a2/node_modules/zod-to-json-schema/dist/cjs/parsers/branded.js
88302
89112
  var require_branded = __commonJS((exports) => {
88303
89113
  Object.defineProperty(exports, "__esModule", { value: true });
88304
89114
  exports.parseBrandedDef = undefined;
@@ -88309,7 +89119,7 @@ var require_branded = __commonJS((exports) => {
88309
89119
  exports.parseBrandedDef = parseBrandedDef2;
88310
89120
  });
88311
89121
 
88312
- // node_modules/.bun/zod-to-json-schema@3.25.1+27912429049419a2/node_modules/zod-to-json-schema/dist/cjs/parsers/catch.js
89122
+ // node_modules/.bun/zod-to-json-schema@3.25.2+27912429049419a2/node_modules/zod-to-json-schema/dist/cjs/parsers/catch.js
88313
89123
  var require_catch = __commonJS((exports) => {
88314
89124
  Object.defineProperty(exports, "__esModule", { value: true });
88315
89125
  exports.parseCatchDef = undefined;
@@ -88320,7 +89130,7 @@ var require_catch = __commonJS((exports) => {
88320
89130
  exports.parseCatchDef = parseCatchDef2;
88321
89131
  });
88322
89132
 
88323
- // node_modules/.bun/zod-to-json-schema@3.25.1+27912429049419a2/node_modules/zod-to-json-schema/dist/cjs/parsers/date.js
89133
+ // node_modules/.bun/zod-to-json-schema@3.25.2+27912429049419a2/node_modules/zod-to-json-schema/dist/cjs/parsers/date.js
88324
89134
  var require_date = __commonJS((exports) => {
88325
89135
  Object.defineProperty(exports, "__esModule", { value: true });
88326
89136
  exports.parseDateDef = undefined;
@@ -88371,7 +89181,7 @@ var require_date = __commonJS((exports) => {
88371
89181
  };
88372
89182
  });
88373
89183
 
88374
- // node_modules/.bun/zod-to-json-schema@3.25.1+27912429049419a2/node_modules/zod-to-json-schema/dist/cjs/parsers/default.js
89184
+ // node_modules/.bun/zod-to-json-schema@3.25.2+27912429049419a2/node_modules/zod-to-json-schema/dist/cjs/parsers/default.js
88375
89185
  var require_default = __commonJS((exports) => {
88376
89186
  Object.defineProperty(exports, "__esModule", { value: true });
88377
89187
  exports.parseDefaultDef = undefined;
@@ -88385,7 +89195,7 @@ var require_default = __commonJS((exports) => {
88385
89195
  exports.parseDefaultDef = parseDefaultDef2;
88386
89196
  });
88387
89197
 
88388
- // node_modules/.bun/zod-to-json-schema@3.25.1+27912429049419a2/node_modules/zod-to-json-schema/dist/cjs/parsers/effects.js
89198
+ // node_modules/.bun/zod-to-json-schema@3.25.2+27912429049419a2/node_modules/zod-to-json-schema/dist/cjs/parsers/effects.js
88389
89199
  var require_effects = __commonJS((exports) => {
88390
89200
  Object.defineProperty(exports, "__esModule", { value: true });
88391
89201
  exports.parseEffectsDef = undefined;
@@ -88397,7 +89207,7 @@ var require_effects = __commonJS((exports) => {
88397
89207
  exports.parseEffectsDef = parseEffectsDef2;
88398
89208
  });
88399
89209
 
88400
- // node_modules/.bun/zod-to-json-schema@3.25.1+27912429049419a2/node_modules/zod-to-json-schema/dist/cjs/parsers/enum.js
89210
+ // node_modules/.bun/zod-to-json-schema@3.25.2+27912429049419a2/node_modules/zod-to-json-schema/dist/cjs/parsers/enum.js
88401
89211
  var require_enum2 = __commonJS((exports) => {
88402
89212
  Object.defineProperty(exports, "__esModule", { value: true });
88403
89213
  exports.parseEnumDef = undefined;
@@ -88410,7 +89220,7 @@ var require_enum2 = __commonJS((exports) => {
88410
89220
  exports.parseEnumDef = parseEnumDef2;
88411
89221
  });
88412
89222
 
88413
- // node_modules/.bun/zod-to-json-schema@3.25.1+27912429049419a2/node_modules/zod-to-json-schema/dist/cjs/parsers/intersection.js
89223
+ // node_modules/.bun/zod-to-json-schema@3.25.2+27912429049419a2/node_modules/zod-to-json-schema/dist/cjs/parsers/intersection.js
88414
89224
  var require_intersection = __commonJS((exports) => {
88415
89225
  Object.defineProperty(exports, "__esModule", { value: true });
88416
89226
  exports.parseIntersectionDef = undefined;
@@ -88458,7 +89268,7 @@ var require_intersection = __commonJS((exports) => {
88458
89268
  exports.parseIntersectionDef = parseIntersectionDef2;
88459
89269
  });
88460
89270
 
88461
- // node_modules/.bun/zod-to-json-schema@3.25.1+27912429049419a2/node_modules/zod-to-json-schema/dist/cjs/parsers/literal.js
89271
+ // node_modules/.bun/zod-to-json-schema@3.25.2+27912429049419a2/node_modules/zod-to-json-schema/dist/cjs/parsers/literal.js
88462
89272
  var require_literal = __commonJS((exports) => {
88463
89273
  Object.defineProperty(exports, "__esModule", { value: true });
88464
89274
  exports.parseLiteralDef = undefined;
@@ -88483,7 +89293,7 @@ var require_literal = __commonJS((exports) => {
88483
89293
  exports.parseLiteralDef = parseLiteralDef2;
88484
89294
  });
88485
89295
 
88486
- // node_modules/.bun/zod-to-json-schema@3.25.1+27912429049419a2/node_modules/zod-to-json-schema/dist/cjs/parsers/string.js
89296
+ // node_modules/.bun/zod-to-json-schema@3.25.2+27912429049419a2/node_modules/zod-to-json-schema/dist/cjs/parsers/string.js
88487
89297
  var require_string = __commonJS((exports) => {
88488
89298
  Object.defineProperty(exports, "__esModule", { value: true });
88489
89299
  exports.parseStringDef = exports.zodPatterns = undefined;
@@ -88786,7 +89596,7 @@ var require_string = __commonJS((exports) => {
88786
89596
  }
88787
89597
  });
88788
89598
 
88789
- // node_modules/.bun/zod-to-json-schema@3.25.1+27912429049419a2/node_modules/zod-to-json-schema/dist/cjs/parsers/record.js
89599
+ // node_modules/.bun/zod-to-json-schema@3.25.2+27912429049419a2/node_modules/zod-to-json-schema/dist/cjs/parsers/record.js
88790
89600
  var require_record = __commonJS((exports) => {
88791
89601
  Object.defineProperty(exports, "__esModule", { value: true });
88792
89602
  exports.parseRecordDef = undefined;
@@ -88848,7 +89658,7 @@ var require_record = __commonJS((exports) => {
88848
89658
  exports.parseRecordDef = parseRecordDef2;
88849
89659
  });
88850
89660
 
88851
- // node_modules/.bun/zod-to-json-schema@3.25.1+27912429049419a2/node_modules/zod-to-json-schema/dist/cjs/parsers/map.js
89661
+ // node_modules/.bun/zod-to-json-schema@3.25.2+27912429049419a2/node_modules/zod-to-json-schema/dist/cjs/parsers/map.js
88852
89662
  var require_map = __commonJS((exports) => {
88853
89663
  Object.defineProperty(exports, "__esModule", { value: true });
88854
89664
  exports.parseMapDef = undefined;
@@ -88881,7 +89691,7 @@ var require_map = __commonJS((exports) => {
88881
89691
  exports.parseMapDef = parseMapDef2;
88882
89692
  });
88883
89693
 
88884
- // node_modules/.bun/zod-to-json-schema@3.25.1+27912429049419a2/node_modules/zod-to-json-schema/dist/cjs/parsers/nativeEnum.js
89694
+ // node_modules/.bun/zod-to-json-schema@3.25.2+27912429049419a2/node_modules/zod-to-json-schema/dist/cjs/parsers/nativeEnum.js
88885
89695
  var require_nativeEnum = __commonJS((exports) => {
88886
89696
  Object.defineProperty(exports, "__esModule", { value: true });
88887
89697
  exports.parseNativeEnumDef = undefined;
@@ -88900,7 +89710,7 @@ var require_nativeEnum = __commonJS((exports) => {
88900
89710
  exports.parseNativeEnumDef = parseNativeEnumDef2;
88901
89711
  });
88902
89712
 
88903
- // node_modules/.bun/zod-to-json-schema@3.25.1+27912429049419a2/node_modules/zod-to-json-schema/dist/cjs/parsers/never.js
89713
+ // node_modules/.bun/zod-to-json-schema@3.25.2+27912429049419a2/node_modules/zod-to-json-schema/dist/cjs/parsers/never.js
88904
89714
  var require_never = __commonJS((exports) => {
88905
89715
  Object.defineProperty(exports, "__esModule", { value: true });
88906
89716
  exports.parseNeverDef = undefined;
@@ -88916,7 +89726,7 @@ var require_never = __commonJS((exports) => {
88916
89726
  exports.parseNeverDef = parseNeverDef2;
88917
89727
  });
88918
89728
 
88919
- // node_modules/.bun/zod-to-json-schema@3.25.1+27912429049419a2/node_modules/zod-to-json-schema/dist/cjs/parsers/null.js
89729
+ // node_modules/.bun/zod-to-json-schema@3.25.2+27912429049419a2/node_modules/zod-to-json-schema/dist/cjs/parsers/null.js
88920
89730
  var require_null = __commonJS((exports) => {
88921
89731
  Object.defineProperty(exports, "__esModule", { value: true });
88922
89732
  exports.parseNullDef = undefined;
@@ -88931,7 +89741,7 @@ var require_null = __commonJS((exports) => {
88931
89741
  exports.parseNullDef = parseNullDef2;
88932
89742
  });
88933
89743
 
88934
- // node_modules/.bun/zod-to-json-schema@3.25.1+27912429049419a2/node_modules/zod-to-json-schema/dist/cjs/parsers/union.js
89744
+ // node_modules/.bun/zod-to-json-schema@3.25.2+27912429049419a2/node_modules/zod-to-json-schema/dist/cjs/parsers/union.js
88935
89745
  var require_union = __commonJS((exports) => {
88936
89746
  Object.defineProperty(exports, "__esModule", { value: true });
88937
89747
  exports.parseUnionDef = exports.primitiveMappings = undefined;
@@ -89005,7 +89815,7 @@ var require_union = __commonJS((exports) => {
89005
89815
  };
89006
89816
  });
89007
89817
 
89008
- // node_modules/.bun/zod-to-json-schema@3.25.1+27912429049419a2/node_modules/zod-to-json-schema/dist/cjs/parsers/nullable.js
89818
+ // node_modules/.bun/zod-to-json-schema@3.25.2+27912429049419a2/node_modules/zod-to-json-schema/dist/cjs/parsers/nullable.js
89009
89819
  var require_nullable = __commonJS((exports) => {
89010
89820
  Object.defineProperty(exports, "__esModule", { value: true });
89011
89821
  exports.parseNullableDef = undefined;
@@ -89044,7 +89854,7 @@ var require_nullable = __commonJS((exports) => {
89044
89854
  exports.parseNullableDef = parseNullableDef2;
89045
89855
  });
89046
89856
 
89047
- // node_modules/.bun/zod-to-json-schema@3.25.1+27912429049419a2/node_modules/zod-to-json-schema/dist/cjs/parsers/number.js
89857
+ // node_modules/.bun/zod-to-json-schema@3.25.2+27912429049419a2/node_modules/zod-to-json-schema/dist/cjs/parsers/number.js
89048
89858
  var require_number = __commonJS((exports) => {
89049
89859
  Object.defineProperty(exports, "__esModule", { value: true });
89050
89860
  exports.parseNumberDef = undefined;
@@ -89099,7 +89909,7 @@ var require_number = __commonJS((exports) => {
89099
89909
  exports.parseNumberDef = parseNumberDef2;
89100
89910
  });
89101
89911
 
89102
- // node_modules/.bun/zod-to-json-schema@3.25.1+27912429049419a2/node_modules/zod-to-json-schema/dist/cjs/parsers/object.js
89912
+ // node_modules/.bun/zod-to-json-schema@3.25.2+27912429049419a2/node_modules/zod-to-json-schema/dist/cjs/parsers/object.js
89103
89913
  var require_object = __commonJS((exports) => {
89104
89914
  Object.defineProperty(exports, "__esModule", { value: true });
89105
89915
  exports.parseObjectDef = undefined;
@@ -89175,7 +89985,7 @@ var require_object = __commonJS((exports) => {
89175
89985
  }
89176
89986
  });
89177
89987
 
89178
- // node_modules/.bun/zod-to-json-schema@3.25.1+27912429049419a2/node_modules/zod-to-json-schema/dist/cjs/parsers/optional.js
89988
+ // node_modules/.bun/zod-to-json-schema@3.25.2+27912429049419a2/node_modules/zod-to-json-schema/dist/cjs/parsers/optional.js
89179
89989
  var require_optional = __commonJS((exports) => {
89180
89990
  Object.defineProperty(exports, "__esModule", { value: true });
89181
89991
  exports.parseOptionalDef = undefined;
@@ -89201,7 +90011,7 @@ var require_optional = __commonJS((exports) => {
89201
90011
  exports.parseOptionalDef = parseOptionalDef2;
89202
90012
  });
89203
90013
 
89204
- // node_modules/.bun/zod-to-json-schema@3.25.1+27912429049419a2/node_modules/zod-to-json-schema/dist/cjs/parsers/pipeline.js
90014
+ // node_modules/.bun/zod-to-json-schema@3.25.2+27912429049419a2/node_modules/zod-to-json-schema/dist/cjs/parsers/pipeline.js
89205
90015
  var require_pipeline = __commonJS((exports) => {
89206
90016
  Object.defineProperty(exports, "__esModule", { value: true });
89207
90017
  exports.parsePipelineDef = undefined;
@@ -89227,7 +90037,7 @@ var require_pipeline = __commonJS((exports) => {
89227
90037
  exports.parsePipelineDef = parsePipelineDef2;
89228
90038
  });
89229
90039
 
89230
- // node_modules/.bun/zod-to-json-schema@3.25.1+27912429049419a2/node_modules/zod-to-json-schema/dist/cjs/parsers/promise.js
90040
+ // node_modules/.bun/zod-to-json-schema@3.25.2+27912429049419a2/node_modules/zod-to-json-schema/dist/cjs/parsers/promise.js
89231
90041
  var require_promise = __commonJS((exports) => {
89232
90042
  Object.defineProperty(exports, "__esModule", { value: true });
89233
90043
  exports.parsePromiseDef = undefined;
@@ -89238,7 +90048,7 @@ var require_promise = __commonJS((exports) => {
89238
90048
  exports.parsePromiseDef = parsePromiseDef2;
89239
90049
  });
89240
90050
 
89241
- // node_modules/.bun/zod-to-json-schema@3.25.1+27912429049419a2/node_modules/zod-to-json-schema/dist/cjs/parsers/set.js
90051
+ // node_modules/.bun/zod-to-json-schema@3.25.2+27912429049419a2/node_modules/zod-to-json-schema/dist/cjs/parsers/set.js
89242
90052
  var require_set = __commonJS((exports) => {
89243
90053
  Object.defineProperty(exports, "__esModule", { value: true });
89244
90054
  exports.parseSetDef = undefined;
@@ -89265,7 +90075,7 @@ var require_set = __commonJS((exports) => {
89265
90075
  exports.parseSetDef = parseSetDef2;
89266
90076
  });
89267
90077
 
89268
- // node_modules/.bun/zod-to-json-schema@3.25.1+27912429049419a2/node_modules/zod-to-json-schema/dist/cjs/parsers/tuple.js
90078
+ // node_modules/.bun/zod-to-json-schema@3.25.2+27912429049419a2/node_modules/zod-to-json-schema/dist/cjs/parsers/tuple.js
89269
90079
  var require_tuple = __commonJS((exports) => {
89270
90080
  Object.defineProperty(exports, "__esModule", { value: true });
89271
90081
  exports.parseTupleDef = undefined;
@@ -89299,7 +90109,7 @@ var require_tuple = __commonJS((exports) => {
89299
90109
  exports.parseTupleDef = parseTupleDef2;
89300
90110
  });
89301
90111
 
89302
- // node_modules/.bun/zod-to-json-schema@3.25.1+27912429049419a2/node_modules/zod-to-json-schema/dist/cjs/parsers/undefined.js
90112
+ // node_modules/.bun/zod-to-json-schema@3.25.2+27912429049419a2/node_modules/zod-to-json-schema/dist/cjs/parsers/undefined.js
89303
90113
  var require_undefined = __commonJS((exports) => {
89304
90114
  Object.defineProperty(exports, "__esModule", { value: true });
89305
90115
  exports.parseUndefinedDef = undefined;
@@ -89312,7 +90122,7 @@ var require_undefined = __commonJS((exports) => {
89312
90122
  exports.parseUndefinedDef = parseUndefinedDef2;
89313
90123
  });
89314
90124
 
89315
- // node_modules/.bun/zod-to-json-schema@3.25.1+27912429049419a2/node_modules/zod-to-json-schema/dist/cjs/parsers/unknown.js
90125
+ // node_modules/.bun/zod-to-json-schema@3.25.2+27912429049419a2/node_modules/zod-to-json-schema/dist/cjs/parsers/unknown.js
89316
90126
  var require_unknown = __commonJS((exports) => {
89317
90127
  Object.defineProperty(exports, "__esModule", { value: true });
89318
90128
  exports.parseUnknownDef = undefined;
@@ -89323,7 +90133,7 @@ var require_unknown = __commonJS((exports) => {
89323
90133
  exports.parseUnknownDef = parseUnknownDef2;
89324
90134
  });
89325
90135
 
89326
- // node_modules/.bun/zod-to-json-schema@3.25.1+27912429049419a2/node_modules/zod-to-json-schema/dist/cjs/parsers/readonly.js
90136
+ // node_modules/.bun/zod-to-json-schema@3.25.2+27912429049419a2/node_modules/zod-to-json-schema/dist/cjs/parsers/readonly.js
89327
90137
  var require_readonly = __commonJS((exports) => {
89328
90138
  Object.defineProperty(exports, "__esModule", { value: true });
89329
90139
  exports.parseReadonlyDef = undefined;
@@ -89334,7 +90144,7 @@ var require_readonly = __commonJS((exports) => {
89334
90144
  exports.parseReadonlyDef = parseReadonlyDef2;
89335
90145
  });
89336
90146
 
89337
- // node_modules/.bun/zod-to-json-schema@3.25.1+27912429049419a2/node_modules/zod-to-json-schema/dist/cjs/selectParser.js
90147
+ // node_modules/.bun/zod-to-json-schema@3.25.2+27912429049419a2/node_modules/zod-to-json-schema/dist/cjs/selectParser.js
89338
90148
  var require_selectParser = __commonJS((exports) => {
89339
90149
  Object.defineProperty(exports, "__esModule", { value: true });
89340
90150
  exports.selectParser = undefined;
@@ -89448,7 +90258,7 @@ var require_selectParser = __commonJS((exports) => {
89448
90258
  exports.selectParser = selectParser3;
89449
90259
  });
89450
90260
 
89451
- // node_modules/.bun/zod-to-json-schema@3.25.1+27912429049419a2/node_modules/zod-to-json-schema/dist/cjs/parseDef.js
90261
+ // node_modules/.bun/zod-to-json-schema@3.25.2+27912429049419a2/node_modules/zod-to-json-schema/dist/cjs/parseDef.js
89452
90262
  var require_parseDef = __commonJS((exports) => {
89453
90263
  Object.defineProperty(exports, "__esModule", { value: true });
89454
90264
  exports.parseDef = undefined;
@@ -89513,12 +90323,12 @@ var require_parseDef = __commonJS((exports) => {
89513
90323
  };
89514
90324
  });
89515
90325
 
89516
- // node_modules/.bun/zod-to-json-schema@3.25.1+27912429049419a2/node_modules/zod-to-json-schema/dist/cjs/parseTypes.js
90326
+ // node_modules/.bun/zod-to-json-schema@3.25.2+27912429049419a2/node_modules/zod-to-json-schema/dist/cjs/parseTypes.js
89517
90327
  var require_parseTypes = __commonJS((exports) => {
89518
90328
  Object.defineProperty(exports, "__esModule", { value: true });
89519
90329
  });
89520
90330
 
89521
- // node_modules/.bun/zod-to-json-schema@3.25.1+27912429049419a2/node_modules/zod-to-json-schema/dist/cjs/zodToJsonSchema.js
90331
+ // node_modules/.bun/zod-to-json-schema@3.25.2+27912429049419a2/node_modules/zod-to-json-schema/dist/cjs/zodToJsonSchema.js
89522
90332
  var require_zodToJsonSchema = __commonJS((exports) => {
89523
90333
  Object.defineProperty(exports, "__esModule", { value: true });
89524
90334
  exports.zodToJsonSchema = undefined;
@@ -89587,7 +90397,7 @@ var require_zodToJsonSchema = __commonJS((exports) => {
89587
90397
  exports.zodToJsonSchema = zodToJsonSchema3;
89588
90398
  });
89589
90399
 
89590
- // node_modules/.bun/zod-to-json-schema@3.25.1+27912429049419a2/node_modules/zod-to-json-schema/dist/cjs/index.js
90400
+ // node_modules/.bun/zod-to-json-schema@3.25.2+27912429049419a2/node_modules/zod-to-json-schema/dist/cjs/index.js
89591
90401
  var require_cjs = __commonJS((exports) => {
89592
90402
  var __createBinding = exports && exports.__createBinding || (Object.create ? function(o, m, k, k2) {
89593
90403
  if (k2 === undefined)
@@ -89652,7 +90462,7 @@ var require_cjs = __commonJS((exports) => {
89652
90462
  exports.default = zodToJsonSchema_js_1.zodToJsonSchema;
89653
90463
  });
89654
90464
 
89655
- // node_modules/.bun/@modelcontextprotocol+sdk@1.26.0/node_modules/@modelcontextprotocol/sdk/dist/cjs/server/zod-json-schema-compat.js
90465
+ // node_modules/.bun/@modelcontextprotocol+sdk@1.30.0/node_modules/@modelcontextprotocol/sdk/dist/cjs/server/zod-json-schema-compat.js
89656
90466
  var require_zod_json_schema_compat = __commonJS((exports) => {
89657
90467
  var __createBinding = exports && exports.__createBinding || (Object.create ? function(o, m, k, k2) {
89658
90468
  if (k2 === undefined)
@@ -89735,7 +90545,7 @@ var require_zod_json_schema_compat = __commonJS((exports) => {
89735
90545
  }
89736
90546
  });
89737
90547
 
89738
- // node_modules/.bun/@modelcontextprotocol+sdk@1.26.0/node_modules/@modelcontextprotocol/sdk/dist/cjs/shared/protocol.js
90548
+ // node_modules/.bun/@modelcontextprotocol+sdk@1.30.0/node_modules/@modelcontextprotocol/sdk/dist/cjs/shared/protocol.js
89739
90549
  var require_protocol = __commonJS((exports) => {
89740
90550
  Object.defineProperty(exports, "__esModule", { value: true });
89741
90551
  exports.Protocol = exports.DEFAULT_REQUEST_TIMEOUT_MSEC = undefined;
@@ -89947,6 +90757,10 @@ var require_protocol = __commonJS((exports) => {
89947
90757
  this._progressHandlers.clear();
89948
90758
  this._taskProgressTokens.clear();
89949
90759
  this._pendingDebouncedNotifications.clear();
90760
+ for (const info of this._timeoutInfo.values()) {
90761
+ clearTimeout(info.timeoutId);
90762
+ }
90763
+ this._timeoutInfo.clear();
89950
90764
  for (const controller of this._requestHandlerAbortControllers.values()) {
89951
90765
  controller.abort();
89952
90766
  }
@@ -90077,7 +90891,9 @@ var require_protocol = __commonJS((exports) => {
90077
90891
  await capturedTransport?.send(errorResponse);
90078
90892
  }
90079
90893
  }).catch((error3) => this._onerror(new Error(`Failed to send response: ${error3}`))).finally(() => {
90080
- this._requestHandlerAbortControllers.delete(request.id);
90894
+ if (this._requestHandlerAbortControllers.get(request.id) === abortController) {
90895
+ this._requestHandlerAbortControllers.delete(request.id);
90896
+ }
90081
90897
  });
90082
90898
  }
90083
90899
  _onprogress(notification) {
@@ -90580,7 +91396,7 @@ var require_protocol = __commonJS((exports) => {
90580
91396
  }
90581
91397
  });
90582
91398
 
90583
- // node_modules/.bun/@modelcontextprotocol+sdk@1.26.0/node_modules/@modelcontextprotocol/sdk/dist/cjs/validation/ajv-provider.js
91399
+ // node_modules/.bun/@modelcontextprotocol+sdk@1.30.0/node_modules/@modelcontextprotocol/sdk/dist/cjs/validation/ajv-provider.js
90584
91400
  var require_ajv_provider = __commonJS((exports) => {
90585
91401
  var __importDefault = exports && exports.__importDefault || function(mod) {
90586
91402
  return mod && mod.__esModule ? mod : { default: mod };
@@ -90628,10 +91444,11 @@ var require_ajv_provider = __commonJS((exports) => {
90628
91444
  exports.AjvJsonSchemaValidator = AjvJsonSchemaValidator2;
90629
91445
  });
90630
91446
 
90631
- // node_modules/.bun/@modelcontextprotocol+sdk@1.26.0/node_modules/@modelcontextprotocol/sdk/dist/cjs/experimental/tasks/server.js
91447
+ // node_modules/.bun/@modelcontextprotocol+sdk@1.30.0/node_modules/@modelcontextprotocol/sdk/dist/cjs/experimental/tasks/server.js
90632
91448
  var require_server = __commonJS((exports) => {
90633
91449
  Object.defineProperty(exports, "__esModule", { value: true });
90634
91450
  exports.ExperimentalServerTasks = undefined;
91451
+ var types_js_1 = require_types3();
90635
91452
 
90636
91453
  class ExperimentalServerTasks2 {
90637
91454
  constructor(_server) {
@@ -90640,6 +91457,62 @@ var require_server = __commonJS((exports) => {
90640
91457
  requestStream(request, resultSchema, options) {
90641
91458
  return this._server.requestStream(request, resultSchema, options);
90642
91459
  }
91460
+ createMessageStream(params, options) {
91461
+ const clientCapabilities = this._server.getClientCapabilities();
91462
+ if ((params.tools || params.toolChoice) && !clientCapabilities?.sampling?.tools) {
91463
+ throw new Error("Client does not support sampling tools capability.");
91464
+ }
91465
+ if (params.messages.length > 0) {
91466
+ const lastMessage = params.messages[params.messages.length - 1];
91467
+ const lastContent = Array.isArray(lastMessage.content) ? lastMessage.content : [lastMessage.content];
91468
+ const hasToolResults = lastContent.some((c) => c.type === "tool_result");
91469
+ const previousMessage = params.messages.length > 1 ? params.messages[params.messages.length - 2] : undefined;
91470
+ const previousContent = previousMessage ? Array.isArray(previousMessage.content) ? previousMessage.content : [previousMessage.content] : [];
91471
+ const hasPreviousToolUse = previousContent.some((c) => c.type === "tool_use");
91472
+ if (hasToolResults) {
91473
+ if (lastContent.some((c) => c.type !== "tool_result")) {
91474
+ throw new Error("The last message must contain only tool_result content if any is present");
91475
+ }
91476
+ if (!hasPreviousToolUse) {
91477
+ throw new Error("tool_result blocks are not matching any tool_use from the previous message");
91478
+ }
91479
+ }
91480
+ if (hasPreviousToolUse) {
91481
+ const toolUseIds = new Set(previousContent.filter((c) => c.type === "tool_use").map((c) => c.id));
91482
+ const toolResultIds = new Set(lastContent.filter((c) => c.type === "tool_result").map((c) => c.toolUseId));
91483
+ if (toolUseIds.size !== toolResultIds.size || ![...toolUseIds].every((id) => toolResultIds.has(id))) {
91484
+ throw new Error("ids of tool_result blocks and tool_use blocks from previous message do not match");
91485
+ }
91486
+ }
91487
+ }
91488
+ return this.requestStream({
91489
+ method: "sampling/createMessage",
91490
+ params
91491
+ }, types_js_1.CreateMessageResultSchema, options);
91492
+ }
91493
+ elicitInputStream(params, options) {
91494
+ const clientCapabilities = this._server.getClientCapabilities();
91495
+ const mode = params.mode ?? "form";
91496
+ switch (mode) {
91497
+ case "url": {
91498
+ if (!clientCapabilities?.elicitation?.url) {
91499
+ throw new Error("Client does not support url elicitation.");
91500
+ }
91501
+ break;
91502
+ }
91503
+ case "form": {
91504
+ if (!clientCapabilities?.elicitation?.form) {
91505
+ throw new Error("Client does not support form elicitation.");
91506
+ }
91507
+ break;
91508
+ }
91509
+ }
91510
+ const normalizedParams = mode === "form" && params.mode === undefined ? { ...params, mode: "form" } : params;
91511
+ return this.requestStream({
91512
+ method: "elicitation/create",
91513
+ params: normalizedParams
91514
+ }, types_js_1.ElicitResultSchema, options);
91515
+ }
90643
91516
  async getTask(taskId, options) {
90644
91517
  return this._server.getTask({ taskId }, options);
90645
91518
  }
@@ -90656,7 +91529,7 @@ var require_server = __commonJS((exports) => {
90656
91529
  exports.ExperimentalServerTasks = ExperimentalServerTasks2;
90657
91530
  });
90658
91531
 
90659
- // node_modules/.bun/@modelcontextprotocol+sdk@1.26.0/node_modules/@modelcontextprotocol/sdk/dist/cjs/experimental/tasks/helpers.js
91532
+ // node_modules/.bun/@modelcontextprotocol+sdk@1.30.0/node_modules/@modelcontextprotocol/sdk/dist/cjs/experimental/tasks/helpers.js
90660
91533
  var require_helpers = __commonJS((exports) => {
90661
91534
  Object.defineProperty(exports, "__esModule", { value: true });
90662
91535
  exports.assertToolsCallTaskCapability = assertToolsCallTaskCapability2;
@@ -90696,7 +91569,7 @@ var require_helpers = __commonJS((exports) => {
90696
91569
  }
90697
91570
  });
90698
91571
 
90699
- // node_modules/.bun/@modelcontextprotocol+sdk@1.26.0/node_modules/@modelcontextprotocol/sdk/dist/cjs/server/index.js
91572
+ // node_modules/.bun/@modelcontextprotocol+sdk@1.30.0/node_modules/@modelcontextprotocol/sdk/dist/cjs/server/index.js
90700
91573
  var require_server2 = __commonJS((exports) => {
90701
91574
  Object.defineProperty(exports, "__esModule", { value: true });
90702
91575
  exports.Server = undefined;
@@ -90754,16 +91627,7 @@ var require_server2 = __commonJS((exports) => {
90754
91627
  if (!methodSchema) {
90755
91628
  throw new Error("Schema is missing a method literal");
90756
91629
  }
90757
- let methodValue;
90758
- if ((0, zod_compat_js_1.isZ4Schema)(methodSchema)) {
90759
- const v4Schema = methodSchema;
90760
- const v4Def = v4Schema._zod?.def;
90761
- methodValue = v4Def?.value ?? v4Schema.value;
90762
- } else {
90763
- const v3Schema = methodSchema;
90764
- const legacyDef = v3Schema._def;
90765
- methodValue = legacyDef?.value ?? v3Schema.value;
90766
- }
91630
+ const methodValue = (0, zod_compat_js_1.getLiteralValue)(methodSchema);
90767
91631
  if (typeof methodValue !== "string") {
90768
91632
  throw new Error("Schema method literal must be a string");
90769
91633
  }
@@ -91041,7 +91905,7 @@ var require_server2 = __commonJS((exports) => {
91041
91905
  exports.Server = Server2;
91042
91906
  });
91043
91907
 
91044
- // node_modules/.bun/@modelcontextprotocol+sdk@1.26.0/node_modules/@modelcontextprotocol/sdk/dist/cjs/server/completable.js
91908
+ // node_modules/.bun/@modelcontextprotocol+sdk@1.30.0/node_modules/@modelcontextprotocol/sdk/dist/cjs/server/completable.js
91045
91909
  var require_completable = __commonJS((exports) => {
91046
91910
  Object.defineProperty(exports, "__esModule", { value: true });
91047
91911
  exports.McpZodTypeKind = exports.COMPLETABLE_SYMBOL = undefined;
@@ -91075,7 +91939,7 @@ var require_completable = __commonJS((exports) => {
91075
91939
  })(McpZodTypeKind2 || (exports.McpZodTypeKind = McpZodTypeKind2 = {}));
91076
91940
  });
91077
91941
 
91078
- // node_modules/.bun/@modelcontextprotocol+sdk@1.26.0/node_modules/@modelcontextprotocol/sdk/dist/cjs/shared/uriTemplate.js
91942
+ // node_modules/.bun/@modelcontextprotocol+sdk@1.30.0/node_modules/@modelcontextprotocol/sdk/dist/cjs/shared/uriTemplate.js
91079
91943
  var require_uriTemplate = __commonJS((exports) => {
91080
91944
  Object.defineProperty(exports, "__esModule", { value: true });
91081
91945
  exports.UriTemplate = undefined;
@@ -91298,7 +92162,7 @@ var require_uriTemplate = __commonJS((exports) => {
91298
92162
  exports.UriTemplate = UriTemplate2;
91299
92163
  });
91300
92164
 
91301
- // node_modules/.bun/@modelcontextprotocol+sdk@1.26.0/node_modules/@modelcontextprotocol/sdk/dist/cjs/shared/toolNameValidation.js
92165
+ // node_modules/.bun/@modelcontextprotocol+sdk@1.30.0/node_modules/@modelcontextprotocol/sdk/dist/cjs/shared/toolNameValidation.js
91302
92166
  var require_toolNameValidation = __commonJS((exports) => {
91303
92167
  Object.defineProperty(exports, "__esModule", { value: true });
91304
92168
  exports.validateToolName = validateToolName2;
@@ -91362,7 +92226,7 @@ var require_toolNameValidation = __commonJS((exports) => {
91362
92226
  }
91363
92227
  });
91364
92228
 
91365
- // node_modules/.bun/@modelcontextprotocol+sdk@1.26.0/node_modules/@modelcontextprotocol/sdk/dist/cjs/experimental/tasks/mcp-server.js
92229
+ // node_modules/.bun/@modelcontextprotocol+sdk@1.30.0/node_modules/@modelcontextprotocol/sdk/dist/cjs/experimental/tasks/mcp-server.js
91366
92230
  var require_mcp_server = __commonJS((exports) => {
91367
92231
  Object.defineProperty(exports, "__esModule", { value: true });
91368
92232
  exports.ExperimentalMcpServerTasks = undefined;
@@ -91430,7 +92294,7 @@ var require_zod = __commonJS((exports) => {
91430
92294
  exports.default = z;
91431
92295
  });
91432
92296
 
91433
- // node_modules/.bun/@modelcontextprotocol+sdk@1.26.0/node_modules/@modelcontextprotocol/sdk/dist/cjs/server/mcp.js
92297
+ // node_modules/.bun/@modelcontextprotocol+sdk@1.30.0/node_modules/@modelcontextprotocol/sdk/dist/cjs/server/mcp.js
91434
92298
  var require_mcp = __commonJS((exports) => {
91435
92299
  Object.defineProperty(exports, "__esModule", { value: true });
91436
92300
  exports.ResourceTemplate = exports.McpServer = undefined;
@@ -92027,6 +92891,9 @@ var require_mcp = __commonJS((exports) => {
92027
92891
  annotations = rest.shift();
92028
92892
  }
92029
92893
  } else if (typeof firstArg === "object" && firstArg !== null) {
92894
+ if (Object.values(firstArg).some((v) => typeof v === "object" && v !== null)) {
92895
+ throw new Error(`Tool ${name} expected a Zod schema or ToolAnnotations, but received an unrecognized object`);
92896
+ }
92030
92897
  annotations = rest.shift();
92031
92898
  }
92032
92899
  }
@@ -92137,6 +93004,9 @@ var require_mcp = __commonJS((exports) => {
92137
93004
  if (isZodRawShapeCompat2(schema2)) {
92138
93005
  return (0, zod_compat_js_1.objectFromShape)(schema2);
92139
93006
  }
93007
+ if (!isZodSchemaInstance2(schema2)) {
93008
+ throw new Error("inputSchema must be a Zod schema or raw shape, received an unrecognized object");
93009
+ }
92140
93010
  return schema2;
92141
93011
  }
92142
93012
  function promptArgumentsFromSchema2(schema2) {
@@ -93943,7 +94813,7 @@ function scoreHealth(scope, scopeId, db) {
93943
94813
  const blockers = d.query(`SELECT dep.id, dep.short_id, dep.title, dep.status
93944
94814
  FROM task_dependencies td
93945
94815
  JOIN tasks dep ON dep.id = td.depends_on
93946
- WHERE td.task_id = ? AND dep.status != 'completed'`).all(task2.id);
94816
+ WHERE td.task_id = ? AND dep.status NOT IN ('completed', 'cancelled')`).all(task2.id);
93947
94817
  return { id: task2.id, short_id: task2.short_id, title: redactEvidenceText(task2.title), blockers };
93948
94818
  }).filter((entry2) => entry2.blockers.length > 0);
93949
94819
  const overdue = tasks.filter((task2) => activeTaskIds.has(task2.id) && Boolean(task2.due_at && task2.due_at < generatedAt)).map((task2) => ({ id: task2.id, short_id: task2.short_id, title: redactEvidenceText(task2.title), due_at: task2.due_at }));
@@ -105097,10 +105967,10 @@ function serveStaticFile(filePath) {
105097
105967
  if (!existsSync16(filePath))
105098
105968
  return null;
105099
105969
  const ext = extname(filePath);
105100
- const contentType = MIME_TYPES[ext] || "application/octet-stream";
105970
+ const contentType2 = MIME_TYPES[ext] || "application/octet-stream";
105101
105971
  return new Response(Bun.file(filePath), {
105102
105972
  headers: {
105103
- "Content-Type": contentType,
105973
+ "Content-Type": contentType2,
105104
105974
  ...SECURITY_HEADERS
105105
105975
  }
105106
105976
  });