nextclaw 0.15.1 → 0.15.3

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 (2) hide show
  1. package/dist/cli/index.js +80 -30
  2. package/package.json +7 -7
package/dist/cli/index.js CHANGED
@@ -4713,12 +4713,14 @@ function resolvePluginRuntimeRequest(ctx) {
4713
4713
  const agentId = typeof ctx.AgentId === "string" ? ctx.AgentId : void 0;
4714
4714
  const modelOverride = resolveModelOverride(ctx);
4715
4715
  const accountId = typeof ctx.AccountId === "string" && ctx.AccountId.trim().length > 0 ? ctx.AccountId : void 0;
4716
+ const attachments = resolvePluginRuntimeAttachments(ctx);
4716
4717
  return {
4717
4718
  content,
4718
4719
  sessionKey,
4719
4720
  channel,
4720
4721
  chatId,
4721
4722
  agentId,
4723
+ attachments,
4722
4724
  metadata: {
4723
4725
  ...accountId ? { account_id: accountId } : {},
4724
4726
  ...modelOverride ? { model: modelOverride } : {}
@@ -4734,6 +4736,51 @@ function resolveModelOverride(ctx) {
4734
4736
  }
4735
4737
  return void 0;
4736
4738
  }
4739
+ function readStringList(value) {
4740
+ if (!Array.isArray(value)) {
4741
+ return [];
4742
+ }
4743
+ return value.map((entry) => typeof entry === "string" ? entry.trim() : "").filter(Boolean);
4744
+ }
4745
+ function readOptionalString(value) {
4746
+ if (typeof value !== "string") {
4747
+ return void 0;
4748
+ }
4749
+ const trimmed = value.trim();
4750
+ return trimmed || void 0;
4751
+ }
4752
+ function resolvePluginRuntimeAttachments(ctx) {
4753
+ const mediaPaths = readStringList(ctx.MediaPaths);
4754
+ const mediaUrls = readStringList(ctx.MediaUrls);
4755
+ const fallbackPath = readOptionalString(ctx.MediaPath);
4756
+ const fallbackUrl = readOptionalString(ctx.MediaUrl);
4757
+ const mediaTypes = readStringList(ctx.MediaTypes);
4758
+ const fallbackType = readOptionalString(ctx.MediaType);
4759
+ const entryCount = Math.max(
4760
+ mediaPaths.length,
4761
+ mediaUrls.length,
4762
+ fallbackPath ? 1 : 0,
4763
+ fallbackUrl ? 1 : 0
4764
+ );
4765
+ const attachments = [];
4766
+ for (let index = 0; index < entryCount; index += 1) {
4767
+ const path2 = mediaPaths[index] ?? (index === 0 ? fallbackPath : void 0);
4768
+ const rawUrl = mediaUrls[index] ?? (index === 0 ? fallbackUrl : void 0);
4769
+ const url = rawUrl && rawUrl !== path2 ? rawUrl : void 0;
4770
+ const mimeType = mediaTypes[index] ?? fallbackType;
4771
+ if (!path2 && !url) {
4772
+ continue;
4773
+ }
4774
+ attachments.push({
4775
+ path: path2,
4776
+ url,
4777
+ mimeType,
4778
+ source: "plugin-runtime",
4779
+ status: path2 ? "ready" : "remote-only"
4780
+ });
4781
+ }
4782
+ return attachments;
4783
+ }
4737
4784
 
4738
4785
  // src/cli/commands/service-ui-chat-runtime.ts
4739
4786
  import { parseAgentScopedSessionKey } from "@nextclaw/core";
@@ -5083,6 +5130,7 @@ var GatewayAgentRuntimePool = class {
5083
5130
  sessionKey: params.sessionKey,
5084
5131
  channel: params.channel,
5085
5132
  chatId: params.chatId,
5133
+ attachments: params.attachments,
5086
5134
  metadata: params.metadata,
5087
5135
  agentId: params.agentId
5088
5136
  });
@@ -5092,10 +5140,12 @@ var GatewayAgentRuntimePool = class {
5092
5140
  chatId: message.chatId,
5093
5141
  sessionKey: route.sessionKey
5094
5142
  });
5095
- if (commandResult) {
5096
- return commandResult;
5097
- }
5143
+ if (commandResult) return commandResult;
5098
5144
  const runtime2 = forcedEngineKind ? this.resolveRuntimeForEngineKind(forcedEngineKind, route.agentId) : this.resolveRuntime(route.agentId);
5145
+ if (message.attachments.length > 0) {
5146
+ const outbound = await runtime2.engine.handleInbound({ message, sessionKey: route.sessionKey, publishResponse: false, onAssistantDelta: params.onAssistantDelta });
5147
+ return outbound?.content ?? "";
5148
+ }
5099
5149
  return runtime2.engine.processDirect({
5100
5150
  content: params.content,
5101
5151
  sessionKey: route.sessionKey,
@@ -5234,7 +5284,7 @@ var GatewayAgentRuntimePool = class {
5234
5284
  chatId: params.chatId ?? "direct",
5235
5285
  content: params.content,
5236
5286
  timestamp: /* @__PURE__ */ new Date(),
5237
- attachments: [],
5287
+ attachments: params.attachments ?? [],
5238
5288
  metadata: params.metadata ?? {}
5239
5289
  };
5240
5290
  const forcedAgentId = this.readString(params.agentId) ?? parseAgentScopedSessionKey2(params.sessionKey)?.agentId ?? void 0;
@@ -7430,7 +7480,7 @@ function createRunId() {
7430
7480
  function isRecord6(value) {
7431
7481
  return Boolean(value) && typeof value === "object" && !Array.isArray(value);
7432
7482
  }
7433
- function readOptionalString(value) {
7483
+ function readOptionalString2(value) {
7434
7484
  if (typeof value !== "string") {
7435
7485
  return void 0;
7436
7486
  }
@@ -7520,7 +7570,7 @@ var UiChatRunCoordinator = class {
7520
7570
  return run ? this.toRunView(run) : null;
7521
7571
  }
7522
7572
  listRuns(params = {}) {
7523
- const sessionKey = readOptionalString(params.sessionKey);
7573
+ const sessionKey = readOptionalString2(params.sessionKey);
7524
7574
  const stateFilter = Array.isArray(params.states) && params.states.length > 0 ? new Set(params.states) : null;
7525
7575
  const limit = Number.isFinite(params.limit) ? Math.max(0, Math.trunc(params.limit)) : 0;
7526
7576
  const records = Array.from(this.runs.values()).filter((run) => {
@@ -7557,7 +7607,7 @@ var UiChatRunCoordinator = class {
7557
7607
  }
7558
7608
  }
7559
7609
  async stopRun(params) {
7560
- const runId = readOptionalString(params.runId) ?? "";
7610
+ const runId = readOptionalString2(params.runId) ?? "";
7561
7611
  if (!runId) {
7562
7612
  return {
7563
7613
  stopped: false,
@@ -7570,11 +7620,11 @@ var UiChatRunCoordinator = class {
7570
7620
  return {
7571
7621
  stopped: false,
7572
7622
  runId,
7573
- ...readOptionalString(params.sessionKey) ? { sessionKey: readOptionalString(params.sessionKey) } : {},
7623
+ ...readOptionalString2(params.sessionKey) ? { sessionKey: readOptionalString2(params.sessionKey) } : {},
7574
7624
  reason: "run not found or already completed"
7575
7625
  };
7576
7626
  }
7577
- const requestedSessionKey = readOptionalString(params.sessionKey);
7627
+ const requestedSessionKey = readOptionalString2(params.sessionKey);
7578
7628
  if (requestedSessionKey && requestedSessionKey !== run.sessionKey) {
7579
7629
  return {
7580
7630
  stopped: false,
@@ -7611,17 +7661,17 @@ var UiChatRunCoordinator = class {
7611
7661
  };
7612
7662
  }
7613
7663
  resolveRequest(input) {
7614
- const message = readOptionalString(input.message) ?? "";
7615
- const sessionKey = readOptionalString(input.sessionKey) ?? `ui:${Date.now().toString(36)}:${Math.random().toString(36).slice(2, 8)}`;
7616
- const explicitAgentId = readOptionalString(input.agentId);
7664
+ const message = readOptionalString2(input.message) ?? "";
7665
+ const sessionKey = readOptionalString2(input.sessionKey) ?? `ui:${Date.now().toString(36)}:${Math.random().toString(36).slice(2, 8)}`;
7666
+ const explicitAgentId = readOptionalString2(input.agentId);
7617
7667
  const parsedAgentId = parseAgentScopedSessionKey3(sessionKey)?.agentId;
7618
- const agentId = explicitAgentId ?? readOptionalString(parsedAgentId);
7619
- const model = readOptionalString(input.model);
7668
+ const agentId = explicitAgentId ?? readOptionalString2(parsedAgentId);
7669
+ const model = readOptionalString2(input.model);
7620
7670
  const metadata = isRecord6(input.metadata) ? { ...input.metadata } : {};
7621
7671
  if (model) {
7622
7672
  metadata.model = model;
7623
7673
  }
7624
- const runId = readOptionalString(input.runId) ?? createRunId();
7674
+ const runId = readOptionalString2(input.runId) ?? createRunId();
7625
7675
  return {
7626
7676
  runId,
7627
7677
  message,
@@ -7629,16 +7679,16 @@ var UiChatRunCoordinator = class {
7629
7679
  ...agentId ? { agentId } : {},
7630
7680
  ...model ? { model } : {},
7631
7681
  metadata,
7632
- channel: readOptionalString(input.channel) ?? "ui",
7633
- chatId: readOptionalString(input.chatId) ?? "web-ui"
7682
+ channel: readOptionalString2(input.channel) ?? "ui",
7683
+ chatId: readOptionalString2(input.chatId) ?? "web-ui"
7634
7684
  };
7635
7685
  }
7636
7686
  readRequestedSessionType(metadata) {
7637
- const value = readOptionalString(metadata.session_type) ?? readOptionalString(metadata.sessionType);
7687
+ const value = readOptionalString2(metadata.session_type) ?? readOptionalString2(metadata.sessionType);
7638
7688
  return value ? value.toLowerCase() : void 0;
7639
7689
  }
7640
7690
  readStoredSessionType(metadata) {
7641
- const value = readOptionalString(metadata[SESSION_TYPE_METADATA_KEY]);
7691
+ const value = readOptionalString2(metadata[SESSION_TYPE_METADATA_KEY]);
7642
7692
  return value ? value.toLowerCase() : DEFAULT_SESSION_TYPE;
7643
7693
  }
7644
7694
  countUserMessages(session) {
@@ -7761,7 +7811,7 @@ var UiChatRunCoordinator = class {
7761
7811
  });
7762
7812
  run.reply = partialReply;
7763
7813
  this.transitionState(run, "aborted", {
7764
- error: abortController?.signal.reason instanceof Error ? abortController.signal.reason.message : readOptionalString(abortController?.signal.reason)
7814
+ error: abortController?.signal.reason instanceof Error ? abortController.signal.reason.message : readOptionalString2(abortController?.signal.reason)
7765
7815
  });
7766
7816
  return;
7767
7817
  }
@@ -7976,8 +8026,8 @@ var UiChatRunCoordinator = class {
7976
8026
  const path2 = join5(RUNS_DIR, entry.name);
7977
8027
  try {
7978
8028
  const parsed = JSON.parse(readFileSync9(path2, "utf-8"));
7979
- const runId = readOptionalString(parsed.runId);
7980
- const sessionKey = readOptionalString(parsed.sessionKey);
8029
+ const runId = readOptionalString2(parsed.runId);
8030
+ const sessionKey = readOptionalString2(parsed.sessionKey);
7981
8031
  if (!runId || !sessionKey) {
7982
8032
  continue;
7983
8033
  }
@@ -7986,15 +8036,15 @@ var UiChatRunCoordinator = class {
7986
8036
  const run = {
7987
8037
  runId,
7988
8038
  sessionKey,
7989
- ...readOptionalString(parsed.agentId) ? { agentId: readOptionalString(parsed.agentId) } : {},
7990
- ...readOptionalString(parsed.model) ? { model: readOptionalString(parsed.model) } : {},
8039
+ ...readOptionalString2(parsed.agentId) ? { agentId: readOptionalString2(parsed.agentId) } : {},
8040
+ ...readOptionalString2(parsed.model) ? { model: readOptionalString2(parsed.model) } : {},
7991
8041
  state,
7992
- requestedAt: readOptionalString(parsed.requestedAt) ?? (/* @__PURE__ */ new Date()).toISOString(),
7993
- ...readOptionalString(parsed.startedAt) ? { startedAt: readOptionalString(parsed.startedAt) } : {},
7994
- ...readOptionalString(parsed.completedAt) ? { completedAt: readOptionalString(parsed.completedAt) } : {},
8042
+ requestedAt: readOptionalString2(parsed.requestedAt) ?? (/* @__PURE__ */ new Date()).toISOString(),
8043
+ ...readOptionalString2(parsed.startedAt) ? { startedAt: readOptionalString2(parsed.startedAt) } : {},
8044
+ ...readOptionalString2(parsed.completedAt) ? { completedAt: readOptionalString2(parsed.completedAt) } : {},
7995
8045
  stopSupported: Boolean(parsed.stopSupported),
7996
- ...readOptionalString(parsed.stopReason) ? { stopReason: readOptionalString(parsed.stopReason) } : {},
7997
- ...readOptionalString(parsed.error) ? { error: readOptionalString(parsed.error) } : {},
8046
+ ...readOptionalString2(parsed.stopReason) ? { stopReason: readOptionalString2(parsed.stopReason) } : {},
8047
+ ...readOptionalString2(parsed.error) ? { error: readOptionalString2(parsed.error) } : {},
7998
8048
  ...typeof parsed.reply === "string" ? { reply: parsed.reply } : {},
7999
8049
  events,
8000
8050
  waiters: /* @__PURE__ */ new Set(),
@@ -8020,7 +8070,7 @@ var UiChatRunCoordinator = class {
8020
8070
  return "failed";
8021
8071
  }
8022
8072
  getRunRecord(runId) {
8023
- const normalized = readOptionalString(runId);
8073
+ const normalized = readOptionalString2(runId);
8024
8074
  if (!normalized) {
8025
8075
  return null;
8026
8076
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nextclaw",
3
- "version": "0.15.1",
3
+ "version": "0.15.3",
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.11.0",
43
- "@nextclaw/mcp": "0.1.39",
44
- "@nextclaw/ncp-agent-runtime": "0.2.2",
45
43
  "@nextclaw/ncp": "0.3.2",
46
- "@nextclaw/ncp-mcp": "0.1.38",
44
+ "@nextclaw/mcp": "0.1.41",
45
+ "@nextclaw/ncp-agent-runtime": "0.2.2",
46
+ "@nextclaw/ncp-mcp": "0.1.40",
47
47
  "@nextclaw/ncp-toolkit": "0.4.2",
48
+ "@nextclaw/remote": "0.1.39",
48
49
  "@nextclaw/runtime": "0.2.14",
49
- "@nextclaw/server": "0.10.43",
50
- "@nextclaw/openclaw-compat": "0.3.25",
51
- "@nextclaw/remote": "0.1.37"
50
+ "@nextclaw/server": "0.10.45",
51
+ "@nextclaw/openclaw-compat": "0.3.26"
52
52
  },
53
53
  "devDependencies": {
54
54
  "@types/node": "^20.17.6",