@kontextmind/kxm 0.7.21 → 0.7.22
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.
- package/.claude-plugin/marketplace.json +1 -1
- package/package.json +1 -1
- package/plugins/kxm/.claude-plugin/plugin.json +1 -1
- package/plugins/kxm/dist/cli.js +924 -849
- package/plugins/kxm/dist/client.js +2 -2
- package/plugins/kxm/dist/extension.js +2 -2
- package/plugins/kxm/dist/mcp-server.js +3 -3
- package/plugins/kxm/package.json +1 -1
- package/plugins/kxm/src/cli.ts +13 -1
- package/plugins/kxm/src/client.ts +4 -2
- package/plugins/kxm/src/mcp-server.ts +1 -1
|
@@ -299,7 +299,7 @@ var HubClient = class {
|
|
|
299
299
|
while (!this.stopped && this.agent) {
|
|
300
300
|
this.eventsAbort = new AbortController();
|
|
301
301
|
try {
|
|
302
|
-
const response = await fetch(
|
|
302
|
+
const response = await (this.options.fetchImpl ?? fetch)(
|
|
303
303
|
`${this.options.serverUrl.replace(/\/$/, "")}/v1/events?agentId=${encodeURIComponent(this.agent.id)}`,
|
|
304
304
|
{
|
|
305
305
|
headers: this.headers(),
|
|
@@ -376,7 +376,7 @@ var HubClient = class {
|
|
|
376
376
|
const signal = init.signal ? AbortSignal.any([init.signal, timeoutSignal]) : timeoutSignal;
|
|
377
377
|
let response;
|
|
378
378
|
try {
|
|
379
|
-
response = await fetch(`${this.options.serverUrl.replace(/\/$/, "")}${path}`, {
|
|
379
|
+
response = await (this.options.fetchImpl ?? fetch)(`${this.options.serverUrl.replace(/\/$/, "")}${path}`, {
|
|
380
380
|
...init,
|
|
381
381
|
signal,
|
|
382
382
|
headers: { ...this.headers(includeIdentity), ...init.headers ?? {} }
|
|
@@ -14834,7 +14834,7 @@ var HubClient = class {
|
|
|
14834
14834
|
while (!this.stopped && this.agent) {
|
|
14835
14835
|
this.eventsAbort = new AbortController();
|
|
14836
14836
|
try {
|
|
14837
|
-
const response = await fetch(
|
|
14837
|
+
const response = await (this.options.fetchImpl ?? fetch)(
|
|
14838
14838
|
`${this.options.serverUrl.replace(/\/$/, "")}/v1/events?agentId=${encodeURIComponent(this.agent.id)}`,
|
|
14839
14839
|
{
|
|
14840
14840
|
headers: this.headers(),
|
|
@@ -14911,7 +14911,7 @@ var HubClient = class {
|
|
|
14911
14911
|
const signal = init.signal ? AbortSignal.any([init.signal, timeoutSignal]) : timeoutSignal;
|
|
14912
14912
|
let response;
|
|
14913
14913
|
try {
|
|
14914
|
-
response = await fetch(`${this.options.serverUrl.replace(/\/$/, "")}${path}`, {
|
|
14914
|
+
response = await (this.options.fetchImpl ?? fetch)(`${this.options.serverUrl.replace(/\/$/, "")}${path}`, {
|
|
14915
14915
|
...init,
|
|
14916
14916
|
signal,
|
|
14917
14917
|
headers: { ...this.headers(includeIdentity), ...init.headers ?? {} }
|
|
@@ -16054,7 +16054,7 @@ var HubClient = class {
|
|
|
16054
16054
|
while (!this.stopped && this.agent) {
|
|
16055
16055
|
this.eventsAbort = new AbortController();
|
|
16056
16056
|
try {
|
|
16057
|
-
const response = await fetch(
|
|
16057
|
+
const response = await (this.options.fetchImpl ?? fetch)(
|
|
16058
16058
|
`${this.options.serverUrl.replace(/\/$/, "")}/v1/events?agentId=${encodeURIComponent(this.agent.id)}`,
|
|
16059
16059
|
{
|
|
16060
16060
|
headers: this.headers(),
|
|
@@ -16131,7 +16131,7 @@ var HubClient = class {
|
|
|
16131
16131
|
const signal = init.signal ? AbortSignal.any([init.signal, timeoutSignal]) : timeoutSignal;
|
|
16132
16132
|
let response;
|
|
16133
16133
|
try {
|
|
16134
|
-
response = await fetch(`${this.options.serverUrl.replace(/\/$/, "")}${path}`, {
|
|
16134
|
+
response = await (this.options.fetchImpl ?? fetch)(`${this.options.serverUrl.replace(/\/$/, "")}${path}`, {
|
|
16135
16135
|
...init,
|
|
16136
16136
|
signal,
|
|
16137
16137
|
headers: { ...this.headers(includeIdentity), ...init.headers ?? {} }
|
|
@@ -17047,7 +17047,7 @@ async function deliverInboxNotification(messageId, delivered, notify) {
|
|
|
17047
17047
|
}
|
|
17048
17048
|
|
|
17049
17049
|
// plugins/kxm/src/mcp-server.ts
|
|
17050
|
-
var VERSION = "0.7.
|
|
17050
|
+
var VERSION = "0.7.22";
|
|
17051
17051
|
var inbox = /* @__PURE__ */ new Map();
|
|
17052
17052
|
var notifiedInbox = /* @__PURE__ */ new Set();
|
|
17053
17053
|
var meshClient;
|
package/plugins/kxm/package.json
CHANGED
package/plugins/kxm/src/cli.ts
CHANGED
|
@@ -18,6 +18,7 @@ import { Command, CommanderError } from "commander";
|
|
|
18
18
|
import { readInstalledKxmVersion } from "./kxm-update.ts";
|
|
19
19
|
import { findKxmRepoRoot } from "./repo-root.ts";
|
|
20
20
|
import { HubClient } from "./client.ts";
|
|
21
|
+
import { readHubEnvRecord } from "./hub-env.ts";
|
|
21
22
|
import { defaultProjectName } from "./project-name.ts";
|
|
22
23
|
import {
|
|
23
24
|
AGENT_COMMANDS_MAP,
|
|
@@ -157,6 +158,16 @@ export { hubContextPost };
|
|
|
157
158
|
|
|
158
159
|
const CLI_NAME = "kxm";
|
|
159
160
|
|
|
161
|
+
/** Authenticate CLI hub clients: explicit KXM_AUTH_TOKEN first, then the
|
|
162
|
+
* persisted hub env record (project token for this project, then the admin
|
|
163
|
+
* token), matching the credential precedence `kxm hub start` prints. */
|
|
164
|
+
function resolveCliAuthToken(runtime: Runtime, project: string): string | undefined {
|
|
165
|
+
const envToken = runtime.env.KXM_AUTH_TOKEN?.trim();
|
|
166
|
+
if (envToken) return envToken;
|
|
167
|
+
const record = readHubEnvRecord(runtime.env);
|
|
168
|
+
return record?.projectTokens?.[project]?.trim() || record?.authToken?.trim() || undefined;
|
|
169
|
+
}
|
|
170
|
+
|
|
160
171
|
const USAGE_ERROR_CODES = new Set([
|
|
161
172
|
"commander.help",
|
|
162
173
|
"commander.helpDisplayed",
|
|
@@ -183,12 +194,13 @@ async function ensureCliClient(runtime: Runtime): Promise<HubClient> {
|
|
|
183
194
|
const project = defaultProjectName(runtime.cwd, runtime.env);
|
|
184
195
|
const name = runtime.env.KXM_AGENT_NAME?.trim() || `cli-${process.pid}`;
|
|
185
196
|
const purpose = runtime.env.KXM_AGENT_PURPOSE?.trim() || "CLI agent client";
|
|
186
|
-
const authToken = runtime
|
|
197
|
+
const authToken = resolveCliAuthToken(runtime, project);
|
|
187
198
|
const client = new HubClient({
|
|
188
199
|
serverUrl,
|
|
189
200
|
name,
|
|
190
201
|
project,
|
|
191
202
|
purpose,
|
|
203
|
+
fetchImpl: runtime.fetchImpl,
|
|
192
204
|
...(authToken ? { authToken } : {}),
|
|
193
205
|
});
|
|
194
206
|
await client.start(() => {});
|
|
@@ -55,6 +55,8 @@ export interface HubClientOptions {
|
|
|
55
55
|
heartbeatMs?: number;
|
|
56
56
|
reconnectMs?: number;
|
|
57
57
|
requestTimeoutMs?: number;
|
|
58
|
+
/** Injectable fetch for CLI/tests; defaults to global fetch. */
|
|
59
|
+
fetchImpl?: typeof fetch;
|
|
58
60
|
}
|
|
59
61
|
|
|
60
62
|
export interface SendOptions {
|
|
@@ -493,7 +495,7 @@ export class HubClient {
|
|
|
493
495
|
while (!this.stopped && this.agent) {
|
|
494
496
|
this.eventsAbort = new AbortController();
|
|
495
497
|
try {
|
|
496
|
-
const response = await fetch(
|
|
498
|
+
const response = await (this.options.fetchImpl ?? fetch)(
|
|
497
499
|
`${this.options.serverUrl.replace(/\/$/, "")}/v1/events?agentId=${encodeURIComponent(this.agent.id)}`,
|
|
498
500
|
{
|
|
499
501
|
headers: this.headers(),
|
|
@@ -578,7 +580,7 @@ export class HubClient {
|
|
|
578
580
|
const signal = init.signal ? AbortSignal.any([init.signal, timeoutSignal]) : timeoutSignal;
|
|
579
581
|
let response: Response;
|
|
580
582
|
try {
|
|
581
|
-
response = await fetch(`${this.options.serverUrl.replace(/\/$/, "")}${path}`, {
|
|
583
|
+
response = await (this.options.fetchImpl ?? fetch)(`${this.options.serverUrl.replace(/\/$/, "")}${path}`, {
|
|
582
584
|
...init,
|
|
583
585
|
signal,
|
|
584
586
|
headers: { ...this.headers(includeIdentity), ...(init.headers ?? {}) },
|
|
@@ -7,7 +7,7 @@ import { AGENT_COMMANDS_MAP, enforceToolPolicy, getMcpTools, reconcileInbox } fr
|
|
|
7
7
|
import { deliverInboxNotification } from "./inbox.ts";
|
|
8
8
|
import type { HubEvent, MessageRecord } from "./protocol.ts";
|
|
9
9
|
|
|
10
|
-
const VERSION = "0.7.
|
|
10
|
+
const VERSION = "0.7.22";
|
|
11
11
|
const inbox = new Map<string, MessageRecord>();
|
|
12
12
|
const notifiedInbox = new Set<string>();
|
|
13
13
|
let meshClient: HubClient | undefined;
|