@kontextmind/kxm 0.7.72 → 0.7.73

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.
@@ -417,47 +417,78 @@ var HubClient = class {
417
417
  await this.register();
418
418
  }
419
419
  async request(path, init = {}, includeIdentity = true) {
420
- const requestTimeoutMs = this.options.requestTimeoutMs ?? 15e3;
421
- const timeoutSignal = AbortSignal.timeout(requestTimeoutMs);
422
- const signal = init.signal ? AbortSignal.any([init.signal, timeoutSignal]) : timeoutSignal;
423
- let response;
420
+ return await hubJsonRequest(this.options, path, init, this.headers(includeIdentity));
421
+ }
422
+ };
423
+ async function hubJsonRequest(options, path, init, headers) {
424
+ const requestTimeoutMs = options.requestTimeoutMs ?? 15e3;
425
+ const timeoutSignal = AbortSignal.timeout(requestTimeoutMs);
426
+ const signal = init.signal ? AbortSignal.any([init.signal, timeoutSignal]) : timeoutSignal;
427
+ let response;
428
+ try {
429
+ response = await (options.fetchImpl ?? fetch)(`${options.serverUrl.replace(/\/$/, "")}${path}`, {
430
+ ...init,
431
+ signal,
432
+ headers: { ...headers, ...init.headers ?? {} }
433
+ });
434
+ } catch (error) {
435
+ if (timeoutSignal.aborted) throw new Error(`request timed out after ${requestTimeoutMs}ms`);
436
+ throw error;
437
+ }
438
+ const text = await response.text();
439
+ let body = {};
440
+ if (text) {
424
441
  try {
425
- response = await (this.options.fetchImpl ?? fetch)(`${this.options.serverUrl.replace(/\/$/, "")}${path}`, {
426
- ...init,
427
- signal,
428
- headers: { ...this.headers(includeIdentity), ...init.headers ?? {} }
429
- });
430
- } catch (error) {
431
- if (timeoutSignal.aborted) throw new Error(`request timed out after ${requestTimeoutMs}ms`);
432
- throw error;
433
- }
434
- const text = await response.text();
435
- let body = {};
436
- if (text) {
437
- try {
438
- body = JSON.parse(text);
439
- } catch {
440
- throw new Error(`hub returned invalid JSON with HTTP ${response.status}`);
441
- }
442
+ body = JSON.parse(text);
443
+ } catch {
444
+ throw new Error(`hub returned invalid JSON with HTTP ${response.status}`);
442
445
  }
443
- if (!response.ok) {
444
- const extras = {};
445
- for (const key of ["operation", "nextAction", "assignedCoordinatorName"]) {
446
- if (typeof body[key] === "string") extras[key] = body[key];
447
- }
448
- if (body.lease && typeof body.lease === "object") extras.lease = body.lease;
449
- throw new HubHttpError(
450
- response.status,
451
- String(body.error ?? `HTTP ${response.status}`),
452
- typeof body.code === "string" ? body.code : void 0,
453
- response.headers.get("x-request-id") ?? void 0,
454
- Object.keys(extras).length > 0 ? extras : void 0
455
- );
446
+ }
447
+ if (!response.ok) {
448
+ const extras = {};
449
+ for (const key of ["operation", "nextAction", "assignedCoordinatorName"]) {
450
+ if (typeof body[key] === "string") extras[key] = body[key];
456
451
  }
457
- return body;
452
+ if (body.lease && typeof body.lease === "object") extras.lease = body.lease;
453
+ throw new HubHttpError(
454
+ response.status,
455
+ String(body.error ?? `HTTP ${response.status}`),
456
+ typeof body.code === "string" ? body.code : void 0,
457
+ response.headers.get("x-request-id") ?? void 0,
458
+ Object.keys(extras).length > 0 ? extras : void 0
459
+ );
460
+ }
461
+ return body;
462
+ }
463
+ var RuntimeHubClient = class {
464
+ options;
465
+ constructor(options) {
466
+ this.options = options;
467
+ }
468
+ async heartbeat() {
469
+ const result = await this.request("/v1/runtime/presence", {
470
+ project: this.options.project,
471
+ runtimeId: this.options.runtimeId,
472
+ host: this.options.host ?? defaultHostLabel()
473
+ });
474
+ return result.presence;
475
+ }
476
+ /** Push already-derived `kxm.sync-event.v1` objects, in outbox order. */
477
+ async pushSyncEvents(events) {
478
+ return await this.request("/v1/sync/events", {
479
+ project: this.options.project,
480
+ runtimeId: this.options.runtimeId,
481
+ events
482
+ });
483
+ }
484
+ async request(path, body) {
485
+ const headers = { "content-type": "application/json" };
486
+ if (this.options.authToken) headers.authorization = `Bearer ${this.options.authToken}`;
487
+ return await hubJsonRequest(this.options, path, { method: "POST", body: JSON.stringify(body) }, headers);
458
488
  }
459
489
  };
460
490
  export {
461
491
  HubClient,
462
- HubHttpError
492
+ HubHttpError,
493
+ RuntimeHubClient
463
494
  };
@@ -27,6 +27,7 @@ function agentPresenceView(agent, staleAfterMs = DEFAULT_STALE_AFTER_MS, now = D
27
27
  function toAgentRecord(agent, staleAfterMs, now) {
28
28
  return { ...agent, ...agentPresenceView(agent, staleAfterMs, now) };
29
29
  }
30
+ var MAX_SYNC_BATCH_EVENTS = 100;
30
31
  var ProtocolError = class extends Error {
31
32
  statusCode;
32
33
  code;
@@ -2041,6 +2042,7 @@ export {
2041
2042
  MAX_MESSAGE_TTL_MS,
2042
2043
  MAX_PROVIDER_METADATA_FIELDS,
2043
2044
  MAX_SKILL_REFS,
2045
+ MAX_SYNC_BATCH_EVENTS,
2044
2046
  MIN_LEASE_TTL_MS,
2045
2047
  MIN_MESSAGE_RETENTION_MS,
2046
2048
  MIN_MESSAGE_TTL_MS,
@@ -14952,46 +14952,49 @@ var HubClient = class {
14952
14952
  await this.register();
14953
14953
  }
14954
14954
  async request(path, init = {}, includeIdentity = true) {
14955
- const requestTimeoutMs = this.options.requestTimeoutMs ?? 15e3;
14956
- const timeoutSignal = AbortSignal.timeout(requestTimeoutMs);
14957
- const signal = init.signal ? AbortSignal.any([init.signal, timeoutSignal]) : timeoutSignal;
14958
- let response;
14955
+ return await hubJsonRequest(this.options, path, init, this.headers(includeIdentity));
14956
+ }
14957
+ };
14958
+ async function hubJsonRequest(options, path, init, headers) {
14959
+ const requestTimeoutMs = options.requestTimeoutMs ?? 15e3;
14960
+ const timeoutSignal = AbortSignal.timeout(requestTimeoutMs);
14961
+ const signal = init.signal ? AbortSignal.any([init.signal, timeoutSignal]) : timeoutSignal;
14962
+ let response;
14963
+ try {
14964
+ response = await (options.fetchImpl ?? fetch)(`${options.serverUrl.replace(/\/$/, "")}${path}`, {
14965
+ ...init,
14966
+ signal,
14967
+ headers: { ...headers, ...init.headers ?? {} }
14968
+ });
14969
+ } catch (error2) {
14970
+ if (timeoutSignal.aborted) throw new Error(`request timed out after ${requestTimeoutMs}ms`);
14971
+ throw error2;
14972
+ }
14973
+ const text = await response.text();
14974
+ let body = {};
14975
+ if (text) {
14959
14976
  try {
14960
- response = await (this.options.fetchImpl ?? fetch)(`${this.options.serverUrl.replace(/\/$/, "")}${path}`, {
14961
- ...init,
14962
- signal,
14963
- headers: { ...this.headers(includeIdentity), ...init.headers ?? {} }
14964
- });
14965
- } catch (error2) {
14966
- if (timeoutSignal.aborted) throw new Error(`request timed out after ${requestTimeoutMs}ms`);
14967
- throw error2;
14968
- }
14969
- const text = await response.text();
14970
- let body = {};
14971
- if (text) {
14972
- try {
14973
- body = JSON.parse(text);
14974
- } catch {
14975
- throw new Error(`hub returned invalid JSON with HTTP ${response.status}`);
14976
- }
14977
- }
14978
- if (!response.ok) {
14979
- const extras = {};
14980
- for (const key of ["operation", "nextAction", "assignedCoordinatorName"]) {
14981
- if (typeof body[key] === "string") extras[key] = body[key];
14982
- }
14983
- if (body.lease && typeof body.lease === "object") extras.lease = body.lease;
14984
- throw new HubHttpError(
14985
- response.status,
14986
- String(body.error ?? `HTTP ${response.status}`),
14987
- typeof body.code === "string" ? body.code : void 0,
14988
- response.headers.get("x-request-id") ?? void 0,
14989
- Object.keys(extras).length > 0 ? extras : void 0
14990
- );
14977
+ body = JSON.parse(text);
14978
+ } catch {
14979
+ throw new Error(`hub returned invalid JSON with HTTP ${response.status}`);
14991
14980
  }
14992
- return body;
14993
14981
  }
14994
- };
14982
+ if (!response.ok) {
14983
+ const extras = {};
14984
+ for (const key of ["operation", "nextAction", "assignedCoordinatorName"]) {
14985
+ if (typeof body[key] === "string") extras[key] = body[key];
14986
+ }
14987
+ if (body.lease && typeof body.lease === "object") extras.lease = body.lease;
14988
+ throw new HubHttpError(
14989
+ response.status,
14990
+ String(body.error ?? `HTTP ${response.status}`),
14991
+ typeof body.code === "string" ? body.code : void 0,
14992
+ response.headers.get("x-request-id") ?? void 0,
14993
+ Object.keys(extras).length > 0 ? extras : void 0
14994
+ );
14995
+ }
14996
+ return body;
14997
+ }
14995
14998
 
14996
14999
  // plugins/kxm/src/commands.ts
14997
15000
  function requiredString(value, name) {
@@ -16172,46 +16172,49 @@ var HubClient = class {
16172
16172
  await this.register();
16173
16173
  }
16174
16174
  async request(path, init = {}, includeIdentity = true) {
16175
- const requestTimeoutMs = this.options.requestTimeoutMs ?? 15e3;
16176
- const timeoutSignal = AbortSignal.timeout(requestTimeoutMs);
16177
- const signal = init.signal ? AbortSignal.any([init.signal, timeoutSignal]) : timeoutSignal;
16178
- let response;
16175
+ return await hubJsonRequest(this.options, path, init, this.headers(includeIdentity));
16176
+ }
16177
+ };
16178
+ async function hubJsonRequest(options, path, init, headers) {
16179
+ const requestTimeoutMs = options.requestTimeoutMs ?? 15e3;
16180
+ const timeoutSignal = AbortSignal.timeout(requestTimeoutMs);
16181
+ const signal = init.signal ? AbortSignal.any([init.signal, timeoutSignal]) : timeoutSignal;
16182
+ let response;
16183
+ try {
16184
+ response = await (options.fetchImpl ?? fetch)(`${options.serverUrl.replace(/\/$/, "")}${path}`, {
16185
+ ...init,
16186
+ signal,
16187
+ headers: { ...headers, ...init.headers ?? {} }
16188
+ });
16189
+ } catch (error2) {
16190
+ if (timeoutSignal.aborted) throw new Error(`request timed out after ${requestTimeoutMs}ms`);
16191
+ throw error2;
16192
+ }
16193
+ const text = await response.text();
16194
+ let body = {};
16195
+ if (text) {
16179
16196
  try {
16180
- response = await (this.options.fetchImpl ?? fetch)(`${this.options.serverUrl.replace(/\/$/, "")}${path}`, {
16181
- ...init,
16182
- signal,
16183
- headers: { ...this.headers(includeIdentity), ...init.headers ?? {} }
16184
- });
16185
- } catch (error2) {
16186
- if (timeoutSignal.aborted) throw new Error(`request timed out after ${requestTimeoutMs}ms`);
16187
- throw error2;
16188
- }
16189
- const text = await response.text();
16190
- let body = {};
16191
- if (text) {
16192
- try {
16193
- body = JSON.parse(text);
16194
- } catch {
16195
- throw new Error(`hub returned invalid JSON with HTTP ${response.status}`);
16196
- }
16197
+ body = JSON.parse(text);
16198
+ } catch {
16199
+ throw new Error(`hub returned invalid JSON with HTTP ${response.status}`);
16197
16200
  }
16198
- if (!response.ok) {
16199
- const extras = {};
16200
- for (const key of ["operation", "nextAction", "assignedCoordinatorName"]) {
16201
- if (typeof body[key] === "string") extras[key] = body[key];
16202
- }
16203
- if (body.lease && typeof body.lease === "object") extras.lease = body.lease;
16204
- throw new HubHttpError(
16205
- response.status,
16206
- String(body.error ?? `HTTP ${response.status}`),
16207
- typeof body.code === "string" ? body.code : void 0,
16208
- response.headers.get("x-request-id") ?? void 0,
16209
- Object.keys(extras).length > 0 ? extras : void 0
16210
- );
16201
+ }
16202
+ if (!response.ok) {
16203
+ const extras = {};
16204
+ for (const key of ["operation", "nextAction", "assignedCoordinatorName"]) {
16205
+ if (typeof body[key] === "string") extras[key] = body[key];
16211
16206
  }
16212
- return body;
16207
+ if (body.lease && typeof body.lease === "object") extras.lease = body.lease;
16208
+ throw new HubHttpError(
16209
+ response.status,
16210
+ String(body.error ?? `HTTP ${response.status}`),
16211
+ typeof body.code === "string" ? body.code : void 0,
16212
+ response.headers.get("x-request-id") ?? void 0,
16213
+ Object.keys(extras).length > 0 ? extras : void 0
16214
+ );
16213
16215
  }
16214
- };
16216
+ return body;
16217
+ }
16215
16218
 
16216
16219
  // plugins/kxm/src/hub-env.ts
16217
16220
  import { existsSync, mkdirSync, readFileSync, renameSync, rmSync, writeFileSync } from "node:fs";
@@ -17179,7 +17182,7 @@ async function deliverInboxNotification(messageId, delivered, notify) {
17179
17182
  }
17180
17183
 
17181
17184
  // plugins/kxm/src/mcp-server.ts
17182
- var VERSION = "0.7.72";
17185
+ var VERSION = "0.7.73";
17183
17186
  var inbox = /* @__PURE__ */ new Map();
17184
17187
  var notifiedInbox = /* @__PURE__ */ new Set();
17185
17188
  var meshClient;