nextclaw 0.14.1 → 0.14.2
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/dist/cli/index.js +29 -63
- package/package.json +8 -8
package/dist/cli/index.js
CHANGED
|
@@ -5475,8 +5475,7 @@ var resolveCliSubcommandEntry = (params) => {
|
|
|
5475
5475
|
|
|
5476
5476
|
// src/cli/commands/ncp/create-ui-ncp-agent.ts
|
|
5477
5477
|
import {
|
|
5478
|
-
DisposableStore
|
|
5479
|
-
resolveProviderRuntime
|
|
5478
|
+
DisposableStore
|
|
5480
5479
|
} from "@nextclaw/core";
|
|
5481
5480
|
import { McpRegistryService as McpRegistryService2, McpServerLifecycleManager } from "@nextclaw/mcp";
|
|
5482
5481
|
import { DefaultNcpAgentRuntime } from "@nextclaw/ncp-agent-runtime";
|
|
@@ -6663,36 +6662,9 @@ var UiNcpRuntimeRegistry = class {
|
|
|
6663
6662
|
// src/cli/commands/ncp/create-ui-ncp-agent.ts
|
|
6664
6663
|
var CODEX_RUNTIME_KIND = "codex";
|
|
6665
6664
|
var CODEX_DIRECT_RUNTIME_BACKEND = "codex-sdk";
|
|
6666
|
-
var CODEX_NATIVE_RUNTIME_BACKEND = "native-openai-compatible";
|
|
6667
6665
|
function isRecord5(value) {
|
|
6668
6666
|
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
6669
6667
|
}
|
|
6670
|
-
function readOptionalString(value) {
|
|
6671
|
-
if (typeof value !== "string") {
|
|
6672
|
-
return null;
|
|
6673
|
-
}
|
|
6674
|
-
const normalized = value.trim();
|
|
6675
|
-
return normalized.length > 0 ? normalized : null;
|
|
6676
|
-
}
|
|
6677
|
-
function resolveCodexRequestedModel(params) {
|
|
6678
|
-
return readOptionalString(params.sessionMetadata.preferred_model) ?? readOptionalString(params.sessionMetadata.model) ?? params.config.agents.defaults.model;
|
|
6679
|
-
}
|
|
6680
|
-
function isCodexDirectModelFamily(model) {
|
|
6681
|
-
const normalized = model.trim().toLowerCase();
|
|
6682
|
-
return normalized.startsWith("gpt-") || normalized.startsWith("chatgpt-") || normalized.startsWith("codex-") || normalized.startsWith("o1") || normalized.startsWith("o3") || normalized.startsWith("o4");
|
|
6683
|
-
}
|
|
6684
|
-
function shouldRouteCodexSessionToNativeRuntime(params) {
|
|
6685
|
-
const requestedModel = resolveCodexRequestedModel(params);
|
|
6686
|
-
try {
|
|
6687
|
-
const resolvedProviderRuntime = resolveProviderRuntime(params.config, requestedModel);
|
|
6688
|
-
if (resolvedProviderRuntime.providerName === "openai") {
|
|
6689
|
-
return false;
|
|
6690
|
-
}
|
|
6691
|
-
return !isCodexDirectModelFamily(resolvedProviderRuntime.providerLocalModel);
|
|
6692
|
-
} catch {
|
|
6693
|
-
return false;
|
|
6694
|
-
}
|
|
6695
|
-
}
|
|
6696
6668
|
function decorateCodexRuntimeFactoryParams(runtimeParams, backend) {
|
|
6697
6669
|
const nextSessionMetadata = {
|
|
6698
6670
|
...runtimeParams.sessionMetadata,
|
|
@@ -6805,15 +6777,11 @@ function createNativeRuntimeFactory(params, mcpToolRegistryAdapter) {
|
|
|
6805
6777
|
}
|
|
6806
6778
|
function createCodexAwareRuntimeFactory(params) {
|
|
6807
6779
|
return (runtimeParams) => {
|
|
6808
|
-
const backend = shouldRouteCodexSessionToNativeRuntime({
|
|
6809
|
-
config: params.getConfig(),
|
|
6810
|
-
sessionMetadata: runtimeParams.sessionMetadata
|
|
6811
|
-
}) ? CODEX_NATIVE_RUNTIME_BACKEND : CODEX_DIRECT_RUNTIME_BACKEND;
|
|
6812
6780
|
const decoratedRuntimeParams = decorateCodexRuntimeFactoryParams(
|
|
6813
6781
|
runtimeParams,
|
|
6814
|
-
|
|
6782
|
+
CODEX_DIRECT_RUNTIME_BACKEND
|
|
6815
6783
|
);
|
|
6816
|
-
return
|
|
6784
|
+
return params.registration.createRuntime(decoratedRuntimeParams);
|
|
6817
6785
|
};
|
|
6818
6786
|
}
|
|
6819
6787
|
function resolveRegisteredRuntimeFactory(params) {
|
|
@@ -6841,8 +6809,6 @@ function createPluginRuntimeRegistrationController(params) {
|
|
|
6841
6809
|
kind: registration.kind,
|
|
6842
6810
|
label: registration.label,
|
|
6843
6811
|
createRuntime: resolveRegisteredRuntimeFactory({
|
|
6844
|
-
getConfig: params.getConfig,
|
|
6845
|
-
createNativeRuntime: params.createNativeRuntime,
|
|
6846
6812
|
registration
|
|
6847
6813
|
}),
|
|
6848
6814
|
describeSessionType: registration.describeSessionType
|
|
@@ -7318,7 +7284,7 @@ function createRunId() {
|
|
|
7318
7284
|
function isRecord6(value) {
|
|
7319
7285
|
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
7320
7286
|
}
|
|
7321
|
-
function
|
|
7287
|
+
function readOptionalString(value) {
|
|
7322
7288
|
if (typeof value !== "string") {
|
|
7323
7289
|
return void 0;
|
|
7324
7290
|
}
|
|
@@ -7408,7 +7374,7 @@ var UiChatRunCoordinator = class {
|
|
|
7408
7374
|
return run ? this.toRunView(run) : null;
|
|
7409
7375
|
}
|
|
7410
7376
|
listRuns(params = {}) {
|
|
7411
|
-
const sessionKey =
|
|
7377
|
+
const sessionKey = readOptionalString(params.sessionKey);
|
|
7412
7378
|
const stateFilter = Array.isArray(params.states) && params.states.length > 0 ? new Set(params.states) : null;
|
|
7413
7379
|
const limit = Number.isFinite(params.limit) ? Math.max(0, Math.trunc(params.limit)) : 0;
|
|
7414
7380
|
const records = Array.from(this.runs.values()).filter((run) => {
|
|
@@ -7445,7 +7411,7 @@ var UiChatRunCoordinator = class {
|
|
|
7445
7411
|
}
|
|
7446
7412
|
}
|
|
7447
7413
|
async stopRun(params) {
|
|
7448
|
-
const runId =
|
|
7414
|
+
const runId = readOptionalString(params.runId) ?? "";
|
|
7449
7415
|
if (!runId) {
|
|
7450
7416
|
return {
|
|
7451
7417
|
stopped: false,
|
|
@@ -7458,11 +7424,11 @@ var UiChatRunCoordinator = class {
|
|
|
7458
7424
|
return {
|
|
7459
7425
|
stopped: false,
|
|
7460
7426
|
runId,
|
|
7461
|
-
...
|
|
7427
|
+
...readOptionalString(params.sessionKey) ? { sessionKey: readOptionalString(params.sessionKey) } : {},
|
|
7462
7428
|
reason: "run not found or already completed"
|
|
7463
7429
|
};
|
|
7464
7430
|
}
|
|
7465
|
-
const requestedSessionKey =
|
|
7431
|
+
const requestedSessionKey = readOptionalString(params.sessionKey);
|
|
7466
7432
|
if (requestedSessionKey && requestedSessionKey !== run.sessionKey) {
|
|
7467
7433
|
return {
|
|
7468
7434
|
stopped: false,
|
|
@@ -7499,17 +7465,17 @@ var UiChatRunCoordinator = class {
|
|
|
7499
7465
|
};
|
|
7500
7466
|
}
|
|
7501
7467
|
resolveRequest(input) {
|
|
7502
|
-
const message =
|
|
7503
|
-
const sessionKey =
|
|
7504
|
-
const explicitAgentId =
|
|
7468
|
+
const message = readOptionalString(input.message) ?? "";
|
|
7469
|
+
const sessionKey = readOptionalString(input.sessionKey) ?? `ui:${Date.now().toString(36)}:${Math.random().toString(36).slice(2, 8)}`;
|
|
7470
|
+
const explicitAgentId = readOptionalString(input.agentId);
|
|
7505
7471
|
const parsedAgentId = parseAgentScopedSessionKey3(sessionKey)?.agentId;
|
|
7506
|
-
const agentId = explicitAgentId ??
|
|
7507
|
-
const model =
|
|
7472
|
+
const agentId = explicitAgentId ?? readOptionalString(parsedAgentId);
|
|
7473
|
+
const model = readOptionalString(input.model);
|
|
7508
7474
|
const metadata = isRecord6(input.metadata) ? { ...input.metadata } : {};
|
|
7509
7475
|
if (model) {
|
|
7510
7476
|
metadata.model = model;
|
|
7511
7477
|
}
|
|
7512
|
-
const runId =
|
|
7478
|
+
const runId = readOptionalString(input.runId) ?? createRunId();
|
|
7513
7479
|
return {
|
|
7514
7480
|
runId,
|
|
7515
7481
|
message,
|
|
@@ -7517,16 +7483,16 @@ var UiChatRunCoordinator = class {
|
|
|
7517
7483
|
...agentId ? { agentId } : {},
|
|
7518
7484
|
...model ? { model } : {},
|
|
7519
7485
|
metadata,
|
|
7520
|
-
channel:
|
|
7521
|
-
chatId:
|
|
7486
|
+
channel: readOptionalString(input.channel) ?? "ui",
|
|
7487
|
+
chatId: readOptionalString(input.chatId) ?? "web-ui"
|
|
7522
7488
|
};
|
|
7523
7489
|
}
|
|
7524
7490
|
readRequestedSessionType(metadata) {
|
|
7525
|
-
const value =
|
|
7491
|
+
const value = readOptionalString(metadata.session_type) ?? readOptionalString(metadata.sessionType);
|
|
7526
7492
|
return value ? value.toLowerCase() : void 0;
|
|
7527
7493
|
}
|
|
7528
7494
|
readStoredSessionType(metadata) {
|
|
7529
|
-
const value =
|
|
7495
|
+
const value = readOptionalString(metadata[SESSION_TYPE_METADATA_KEY]);
|
|
7530
7496
|
return value ? value.toLowerCase() : DEFAULT_SESSION_TYPE;
|
|
7531
7497
|
}
|
|
7532
7498
|
countUserMessages(session) {
|
|
@@ -7649,7 +7615,7 @@ var UiChatRunCoordinator = class {
|
|
|
7649
7615
|
});
|
|
7650
7616
|
run.reply = partialReply;
|
|
7651
7617
|
this.transitionState(run, "aborted", {
|
|
7652
|
-
error: abortController?.signal.reason instanceof Error ? abortController.signal.reason.message :
|
|
7618
|
+
error: abortController?.signal.reason instanceof Error ? abortController.signal.reason.message : readOptionalString(abortController?.signal.reason)
|
|
7653
7619
|
});
|
|
7654
7620
|
return;
|
|
7655
7621
|
}
|
|
@@ -7864,8 +7830,8 @@ var UiChatRunCoordinator = class {
|
|
|
7864
7830
|
const path2 = join5(RUNS_DIR, entry.name);
|
|
7865
7831
|
try {
|
|
7866
7832
|
const parsed = JSON.parse(readFileSync8(path2, "utf-8"));
|
|
7867
|
-
const runId =
|
|
7868
|
-
const sessionKey =
|
|
7833
|
+
const runId = readOptionalString(parsed.runId);
|
|
7834
|
+
const sessionKey = readOptionalString(parsed.sessionKey);
|
|
7869
7835
|
if (!runId || !sessionKey) {
|
|
7870
7836
|
continue;
|
|
7871
7837
|
}
|
|
@@ -7874,15 +7840,15 @@ var UiChatRunCoordinator = class {
|
|
|
7874
7840
|
const run = {
|
|
7875
7841
|
runId,
|
|
7876
7842
|
sessionKey,
|
|
7877
|
-
...
|
|
7878
|
-
...
|
|
7843
|
+
...readOptionalString(parsed.agentId) ? { agentId: readOptionalString(parsed.agentId) } : {},
|
|
7844
|
+
...readOptionalString(parsed.model) ? { model: readOptionalString(parsed.model) } : {},
|
|
7879
7845
|
state,
|
|
7880
|
-
requestedAt:
|
|
7881
|
-
...
|
|
7882
|
-
...
|
|
7846
|
+
requestedAt: readOptionalString(parsed.requestedAt) ?? (/* @__PURE__ */ new Date()).toISOString(),
|
|
7847
|
+
...readOptionalString(parsed.startedAt) ? { startedAt: readOptionalString(parsed.startedAt) } : {},
|
|
7848
|
+
...readOptionalString(parsed.completedAt) ? { completedAt: readOptionalString(parsed.completedAt) } : {},
|
|
7883
7849
|
stopSupported: Boolean(parsed.stopSupported),
|
|
7884
|
-
...
|
|
7885
|
-
...
|
|
7850
|
+
...readOptionalString(parsed.stopReason) ? { stopReason: readOptionalString(parsed.stopReason) } : {},
|
|
7851
|
+
...readOptionalString(parsed.error) ? { error: readOptionalString(parsed.error) } : {},
|
|
7886
7852
|
...typeof parsed.reply === "string" ? { reply: parsed.reply } : {},
|
|
7887
7853
|
events,
|
|
7888
7854
|
waiters: /* @__PURE__ */ new Set(),
|
|
@@ -7908,7 +7874,7 @@ var UiChatRunCoordinator = class {
|
|
|
7908
7874
|
return "failed";
|
|
7909
7875
|
}
|
|
7910
7876
|
getRunRecord(runId) {
|
|
7911
|
-
const normalized =
|
|
7877
|
+
const normalized = readOptionalString(runId);
|
|
7912
7878
|
if (!normalized) {
|
|
7913
7879
|
return null;
|
|
7914
7880
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nextclaw",
|
|
3
|
-
"version": "0.14.
|
|
3
|
+
"version": "0.14.2",
|
|
4
4
|
"description": "Lightweight personal AI assistant with CLI, multi-provider routing, and channel integrations.",
|
|
5
5
|
"private": false,
|
|
6
6
|
"type": "module",
|
|
@@ -40,15 +40,15 @@
|
|
|
40
40
|
"commander": "^12.1.0",
|
|
41
41
|
"yaml": "^2.8.1",
|
|
42
42
|
"@nextclaw/core": "0.10.0",
|
|
43
|
+
"@nextclaw/mcp": "0.1.35",
|
|
43
44
|
"@nextclaw/ncp": "0.3.2",
|
|
44
|
-
"@nextclaw/mcp": "0.1.34",
|
|
45
|
-
"@nextclaw/ncp-mcp": "0.1.33",
|
|
46
|
-
"@nextclaw/ncp-agent-runtime": "0.2.2",
|
|
47
|
-
"@nextclaw/remote": "0.1.32",
|
|
48
|
-
"@nextclaw/ncp-toolkit": "0.4.2",
|
|
49
|
-
"@nextclaw/openclaw-compat": "0.3.20",
|
|
45
|
+
"@nextclaw/ncp-mcp": "0.1.34",
|
|
50
46
|
"@nextclaw/runtime": "0.2.13",
|
|
51
|
-
"@nextclaw/
|
|
47
|
+
"@nextclaw/openclaw-compat": "0.3.20",
|
|
48
|
+
"@nextclaw/server": "0.10.39",
|
|
49
|
+
"@nextclaw/remote": "0.1.33",
|
|
50
|
+
"@nextclaw/ncp-toolkit": "0.4.2",
|
|
51
|
+
"@nextclaw/ncp-agent-runtime": "0.2.2"
|
|
52
52
|
},
|
|
53
53
|
"devDependencies": {
|
|
54
54
|
"@types/node": "^20.17.6",
|