@agentchatme/openclaw 0.10.1 → 0.10.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/CHANGELOG.md +25 -0
- package/README.md +3 -3
- package/RUNBOOK.md +3 -2
- package/dist/index.cjs +240 -21
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +240 -21
- package/dist/index.js.map +1 -1
- package/dist/setup-entry.cjs +240 -21
- package/dist/setup-entry.cjs.map +1 -1
- package/dist/setup-entry.js +240 -21
- package/dist/setup-entry.js.map +1 -1
- package/openclaw.plugin.json +1 -1
- package/package.json +2 -2
- package/skills/agentchat/SKILL.md +14 -14
package/dist/setup-entry.js
CHANGED
|
@@ -106,7 +106,7 @@ function applyAgentchatAccountPatch(cfg, accountId, patch) {
|
|
|
106
106
|
}
|
|
107
107
|
|
|
108
108
|
// src/version.ts
|
|
109
|
-
var PACKAGE_VERSION = "0.10.
|
|
109
|
+
var PACKAGE_VERSION = "0.10.2";
|
|
110
110
|
|
|
111
111
|
// src/client-identity.ts
|
|
112
112
|
var AGENTCHAT_CLIENT_NAME = "openclaw";
|
|
@@ -602,47 +602,258 @@ async function watchRunUntilEnded(options) {
|
|
|
602
602
|
if (elapsedMs < MIN_WAIT_SPACING_MS) await sleep(MIN_WAIT_SPACING_MS - elapsedMs);
|
|
603
603
|
}
|
|
604
604
|
}
|
|
605
|
-
function countAgentChatCalls(messages, runId) {
|
|
605
|
+
function countAgentChatCalls(messages, runId, host = {}) {
|
|
606
606
|
if (messages.length === 0) return null;
|
|
607
|
-
|
|
608
|
-
let made = 0;
|
|
609
|
-
let failed = 0;
|
|
607
|
+
const rows = [];
|
|
610
608
|
for (const row of messages) {
|
|
611
609
|
const message = unwrapMessage(row);
|
|
612
|
-
if (!message)
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
610
|
+
if (!message) return null;
|
|
611
|
+
rows.push(message);
|
|
612
|
+
}
|
|
613
|
+
if (!coversWholeSession(rows)) return null;
|
|
614
|
+
if (runId && rows.some((row) => isOtherRun(row, runId))) return null;
|
|
615
|
+
const calls = assistantToolCalls(rows);
|
|
616
|
+
const nested = rows.flatMap((row) => {
|
|
617
|
+
const call = nestedCallOf(row);
|
|
618
|
+
return call ? [call] : [];
|
|
619
|
+
});
|
|
620
|
+
const release = releaseOf(rows, calls, nested, host.openclawVersion);
|
|
621
|
+
if (delegatedToChild(rows, calls, nested)) return null;
|
|
622
|
+
if (usedCodeMode(rows, calls)) {
|
|
623
|
+
if (!release.recordsNestedCalls) return null;
|
|
624
|
+
if (!codeModeScriptsCompleted(rows, calls)) return null;
|
|
625
|
+
}
|
|
626
|
+
const parents = new Set(nested.flatMap((call) => typeof call.parentToolCallId === "string" ? [call.parentToolCallId] : []));
|
|
627
|
+
let made = 0;
|
|
628
|
+
let failed = 0;
|
|
629
|
+
for (const message of rows) {
|
|
630
|
+
let verdict;
|
|
631
|
+
const call = nestedCallOf(message);
|
|
632
|
+
if (call) verdict = nestedVerdict(call);
|
|
633
|
+
else if (message.role !== "toolResult" && message.role !== "tool") continue;
|
|
634
|
+
else if (typeof message.toolCallId === "string" && parents.has(message.toolCallId)) continue;
|
|
635
|
+
else verdict = callVerdict(message, calls, release);
|
|
636
|
+
if (verdict === "not_agentchat") continue;
|
|
637
|
+
if (verdict === "unknown") return null;
|
|
620
638
|
made += 1;
|
|
621
|
-
if (
|
|
639
|
+
if (verdict === "failed") failed += 1;
|
|
622
640
|
}
|
|
623
|
-
return
|
|
641
|
+
return { made, failed };
|
|
624
642
|
}
|
|
625
643
|
async function readAgentChatCalls(runtime, sessionKey, runId) {
|
|
626
644
|
if (!runtime || typeof runtime.subagent?.getSessionMessages !== "function") return null;
|
|
627
645
|
try {
|
|
628
646
|
const result = await runtime.subagent.getSessionMessages({ sessionKey, limit: TRANSCRIPT_READ_LIMIT });
|
|
629
647
|
const messages = result?.messages;
|
|
630
|
-
|
|
648
|
+
const openclawVersion = typeof runtime.version === "string" ? runtime.version : void 0;
|
|
649
|
+
return Array.isArray(messages) ? countAgentChatCalls(messages, runId, openclawVersion ? { openclawVersion } : {}) : null;
|
|
631
650
|
} catch {
|
|
632
651
|
return null;
|
|
633
652
|
}
|
|
634
653
|
}
|
|
635
654
|
var TOOL_PREFIX = `${MCP_SERVER_NAME}${MCP_TOOL_DELIMITER}`;
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
655
|
+
var DISPATCHER_TOOL_NAMES = /* @__PURE__ */ new Set(["tool_call", "dispatch_action"]);
|
|
656
|
+
var FAILURE_STATUSES = /* @__PURE__ */ new Set([
|
|
657
|
+
"error",
|
|
658
|
+
"failed",
|
|
659
|
+
"failure",
|
|
660
|
+
"timeout",
|
|
661
|
+
"timed_out",
|
|
662
|
+
"blocked",
|
|
663
|
+
"denied",
|
|
664
|
+
"forbidden",
|
|
665
|
+
"unavailable",
|
|
666
|
+
"approval-unavailable",
|
|
667
|
+
"disabled",
|
|
668
|
+
"aborted",
|
|
669
|
+
"cancelled",
|
|
670
|
+
"canceled",
|
|
671
|
+
"killed",
|
|
672
|
+
"invalid"
|
|
673
|
+
]);
|
|
674
|
+
function coversWholeSession(rows) {
|
|
675
|
+
if (asRecord2(rows[0]?.__openclaw)?.seq !== 1) return false;
|
|
676
|
+
return rows.every((row) => {
|
|
677
|
+
const meta = asRecord2(row.__openclaw);
|
|
678
|
+
return meta?.kind !== "compaction" && meta?.kind !== "reset" && meta?.truncated !== true;
|
|
679
|
+
});
|
|
680
|
+
}
|
|
681
|
+
function isOtherRun(row, runId) {
|
|
682
|
+
const tagged = asRecord2(row.__openclaw)?.runId ?? nestedCallOf(row)?.runId;
|
|
683
|
+
return typeof tagged === "string" && tagged.trim().length > 0 && tagged.trim() !== runId;
|
|
684
|
+
}
|
|
685
|
+
var CODE_MODE_ONLY_TOOL_NAMES = /* @__PURE__ */ new Set(["tool_search_code", "wait"]);
|
|
686
|
+
function usedCodeMode(rows, calls) {
|
|
687
|
+
return [...calls.values()].some(isCodeModeCall) || rows.some((row) => isCodeModeResult(row, calls));
|
|
688
|
+
}
|
|
689
|
+
function codeModeScriptsCompleted(rows, calls) {
|
|
690
|
+
const results = /* @__PURE__ */ new Map();
|
|
691
|
+
for (const row of rows) {
|
|
692
|
+
if ((row.role === "toolResult" || row.role === "tool") && typeof row.toolCallId === "string") results.set(row.toolCallId, row);
|
|
693
|
+
}
|
|
694
|
+
const completed = (row) => row !== void 0 && row.isError !== true && asRecord2(row.details)?.status === "completed";
|
|
695
|
+
for (const [id, call] of calls) {
|
|
696
|
+
if (isCodeModeCall(call) && !completed(results.get(id))) return false;
|
|
697
|
+
}
|
|
698
|
+
return rows.every((row) => !isCodeModeResult(row, calls) || completed(row));
|
|
699
|
+
}
|
|
700
|
+
function isCodeModeCall(call) {
|
|
701
|
+
const name = typeof call.name === "string" ? call.name : "";
|
|
702
|
+
return CODE_MODE_ONLY_TOOL_NAMES.has(name) || name === "exec" && typeof callArguments(call)?.code === "string";
|
|
703
|
+
}
|
|
704
|
+
function isCodeModeResult(row, calls) {
|
|
705
|
+
if (row.role !== "toolResult" && row.role !== "tool") return false;
|
|
706
|
+
const name = toolNameOf(row);
|
|
707
|
+
return CODE_MODE_ONLY_TOOL_NAMES.has(name) || name === "exec" && !isShellExecResult(row, calls);
|
|
708
|
+
}
|
|
709
|
+
function isShellExecResult(row, calls) {
|
|
710
|
+
const call = typeof row.toolCallId === "string" ? calls.get(row.toolCallId) : void 0;
|
|
711
|
+
const args = callArguments(call);
|
|
712
|
+
if (!args || typeof args.command !== "string" || args.code !== void 0) return false;
|
|
713
|
+
const details = asRecord2(row.details);
|
|
714
|
+
if (!details || details.telemetry !== void 0) return false;
|
|
715
|
+
return details.exitCode !== void 0 || typeof details.durationMs === "number" || typeof details.aggregated === "string";
|
|
716
|
+
}
|
|
717
|
+
function assistantToolCalls(rows) {
|
|
718
|
+
const calls = /* @__PURE__ */ new Map();
|
|
719
|
+
for (const row of rows) {
|
|
720
|
+
if (row.role !== "assistant" || !Array.isArray(row.content)) continue;
|
|
721
|
+
for (const block of row.content) {
|
|
722
|
+
const call = asRecord2(block);
|
|
723
|
+
if (call?.type === "toolCall" && typeof call.id === "string") calls.set(call.id, call);
|
|
724
|
+
}
|
|
725
|
+
}
|
|
726
|
+
return calls;
|
|
727
|
+
}
|
|
728
|
+
var TRUSTED_RELEASE = "2026.9.3";
|
|
729
|
+
function releaseOf(rows, calls, nested, version) {
|
|
730
|
+
if (version !== void 0 && isOpenClawVersion(version)) {
|
|
731
|
+
const trusted = openclawVersionAtLeast(version, TRUSTED_RELEASE);
|
|
732
|
+
return { recordsNestedCalls: trusted, marksFailedRows: trusted };
|
|
733
|
+
}
|
|
734
|
+
const parents = new Set(nested.map((call) => call.parentToolCallId));
|
|
735
|
+
const dispatchAction = rows.some((row) => (row.role === "toolResult" || row.role === "tool") && toolNameOf(row) === "dispatch_action" && asRecord2(asRecord2(row.details)?.tool) !== null) || [...calls].some(([id, call]) => call.name === "dispatch_action" && parents.has(id));
|
|
736
|
+
return { recordsNestedCalls: nested.length > 0 || dispatchAction, marksFailedRows: dispatchAction };
|
|
737
|
+
}
|
|
738
|
+
var OPENCLAW_VERSION = /^(\d+)\.(\d+)\.(\d+)(-.+)?$/;
|
|
739
|
+
function isOpenClawVersion(value) {
|
|
740
|
+
return OPENCLAW_VERSION.test(value.trim());
|
|
741
|
+
}
|
|
742
|
+
function openclawVersionAtLeast(a, b) {
|
|
743
|
+
const parse = (v) => {
|
|
744
|
+
const match = OPENCLAW_VERSION.exec(v.trim());
|
|
745
|
+
return match ? { parts: [Number(match[1]), Number(match[2]), Number(match[3])], pre: match[4] !== void 0 } : null;
|
|
746
|
+
};
|
|
747
|
+
const [x, y] = [parse(a), parse(b)];
|
|
748
|
+
if (!x || !y) return false;
|
|
749
|
+
for (let i = 0; i < 3; i += 1) {
|
|
750
|
+
const d = (x.parts[i] ?? 0) - (y.parts[i] ?? 0);
|
|
751
|
+
if (d !== 0) return d > 0;
|
|
752
|
+
}
|
|
753
|
+
return !x.pre || y.pre;
|
|
754
|
+
}
|
|
755
|
+
function toolNameOf(row) {
|
|
756
|
+
return typeof row.toolName === "string" ? row.toolName : typeof row.name === "string" ? row.name : "";
|
|
757
|
+
}
|
|
758
|
+
var NESTED_TOOL_ACTIVITY = "openclaw.nested-tool.v1";
|
|
759
|
+
function nestedCallOf(row) {
|
|
760
|
+
if (row.role !== "custom" || row.customType !== NESTED_TOOL_ACTIVITY) return null;
|
|
761
|
+
return asRecord2(row.details);
|
|
762
|
+
}
|
|
763
|
+
function nestedVerdict(call) {
|
|
764
|
+
const toolName = typeof call.toolName === "string" ? call.toolName : "";
|
|
765
|
+
if (!toolName.startsWith(TOOL_PREFIX)) return "not_agentchat";
|
|
766
|
+
const result = asRecord2(call.result);
|
|
767
|
+
if (call.isError === true || result !== null && failedResult(result.isError, asRecord2(result.details))) return "failed";
|
|
768
|
+
return call.isError === false ? "ok" : "unknown";
|
|
769
|
+
}
|
|
770
|
+
var OTHER_SESSION_TOOLS = /* @__PURE__ */ new Set(["sessions_spawn", "sessions_send"]);
|
|
771
|
+
function delegatedToChild(rows, calls, nested) {
|
|
772
|
+
const names = (value) => typeof value === "string" && OTHER_SESSION_TOOLS.has(value);
|
|
773
|
+
for (const call of calls.values()) {
|
|
774
|
+
if (names(call.name)) return true;
|
|
775
|
+
if (typeof call.name === "string" && DISPATCHER_TOOL_NAMES.has(call.name) && names(dispatchTarget(call))) return true;
|
|
776
|
+
}
|
|
777
|
+
if (nested.some((call) => names(call.toolName))) return true;
|
|
778
|
+
return rows.some((row) => names(toolNameOf(row)) || names(asRecord2(asRecord2(row.details)?.tool)?.name));
|
|
779
|
+
}
|
|
780
|
+
function callVerdict(message, calls, release) {
|
|
781
|
+
const toolName = toolNameOf(message);
|
|
782
|
+
const details = asRecord2(message.details);
|
|
783
|
+
if (toolName.startsWith(TOOL_PREFIX)) return directVerdict(message.isError, details);
|
|
784
|
+
const entry = asRecord2(details?.tool);
|
|
785
|
+
if (entry && isAgentChatEntry(entry)) return dispatchedVerdict(message.isError, details);
|
|
786
|
+
if (!DISPATCHER_TOOL_NAMES.has(toolName) || entry) return "not_agentchat";
|
|
787
|
+
const target = dispatchTarget(typeof message.toolCallId === "string" ? calls.get(message.toolCallId) : void 0);
|
|
788
|
+
if (target === null) return "unknown";
|
|
789
|
+
if (!target.startsWith(TOOL_PREFIX)) return "not_agentchat";
|
|
790
|
+
if (failedResult(message.isError, details)) return "failed";
|
|
791
|
+
if (release.marksFailedRows && isTruncated(details) && message.isError === false && details?.status === void 0) return "ok";
|
|
792
|
+
return "unknown";
|
|
793
|
+
}
|
|
794
|
+
function isTruncated(details) {
|
|
795
|
+
return details?.persistedDetailsTruncated === true;
|
|
796
|
+
}
|
|
797
|
+
function directVerdict(isError, details) {
|
|
798
|
+
if (failedResult(isError, details)) return "failed";
|
|
799
|
+
if (isError !== false) return "unknown";
|
|
800
|
+
if (isTruncated(details)) return details?.status === void 0 && wasHostedResult(details) ? "ok" : "unknown";
|
|
801
|
+
return isHostedSuccessDetails(details) ? "ok" : "unknown";
|
|
802
|
+
}
|
|
803
|
+
function wasHostedResult(details) {
|
|
804
|
+
const keys = Array.isArray(details?.originalDetailKeys) ? details.originalDetailKeys : [];
|
|
805
|
+
return keys.includes("mcpServer") && (keys.includes("mcpTool") || keys.includes("mcpOperation"));
|
|
806
|
+
}
|
|
807
|
+
function dispatchedVerdict(isError, details) {
|
|
808
|
+
const result = asRecord2(details?.result);
|
|
809
|
+
if (failedResult(isError, details)) return "failed";
|
|
810
|
+
if (result && failedResult(result.isError, asRecord2(result.details))) return "failed";
|
|
811
|
+
const ok = isError === false && details?.status === void 0 && isHostedSuccessDetails(asRecord2(result?.details));
|
|
812
|
+
return ok ? "ok" : "unknown";
|
|
813
|
+
}
|
|
814
|
+
function failedResult(isError, details) {
|
|
815
|
+
return isError === true || detailsSayFailed(details);
|
|
816
|
+
}
|
|
817
|
+
function detailsSayFailed(details) {
|
|
818
|
+
if (!details) return false;
|
|
819
|
+
if (details.ok === false || details.success === false) return true;
|
|
820
|
+
const status = typeof details.status === "string" ? details.status.trim().toLowerCase() : "";
|
|
821
|
+
const explicitlyOk = details.ok === true || details.success === true;
|
|
822
|
+
if (FAILURE_STATUSES.has(status) && !explicitlyOk) return true;
|
|
823
|
+
if (details.timedOut === true || Boolean(details.error)) return true;
|
|
824
|
+
if (status === "completed") return false;
|
|
825
|
+
const exitCode = details.exitCode;
|
|
826
|
+
return typeof exitCode === "number" && Number.isFinite(exitCode) && exitCode !== 0;
|
|
827
|
+
}
|
|
828
|
+
function isHostedSuccessDetails(details) {
|
|
829
|
+
if (!details || details.mcpServer !== MCP_SERVER_NAME || details.status !== void 0) return false;
|
|
830
|
+
return nonEmpty(details.mcpTool) !== void 0 || nonEmpty(details.mcpOperation) !== void 0;
|
|
831
|
+
}
|
|
832
|
+
function isAgentChatEntry(tool) {
|
|
641
833
|
if (typeof tool.name === "string" && tool.name.startsWith(TOOL_PREFIX)) return true;
|
|
642
834
|
if (tool.sourceName === MCP_SERVER_NAME) return true;
|
|
643
835
|
const mcp = asRecord2(tool.mcp);
|
|
644
836
|
return mcp?.serverName === MCP_SERVER_NAME;
|
|
645
837
|
}
|
|
838
|
+
function dispatchTarget(call) {
|
|
839
|
+
const record = callArguments(call);
|
|
840
|
+
const selector = nonEmpty(record?.id) ?? nonEmpty(record?.toolId) ?? nonEmpty(record?.name);
|
|
841
|
+
if (!selector) return null;
|
|
842
|
+
const trimmed = selector.trim();
|
|
843
|
+
return trimmed.slice(trimmed.lastIndexOf(":") + 1);
|
|
844
|
+
}
|
|
845
|
+
function callArguments(call) {
|
|
846
|
+
if (!call) return null;
|
|
847
|
+
let args = call.arguments;
|
|
848
|
+
if (typeof args === "string") {
|
|
849
|
+
try {
|
|
850
|
+
args = JSON.parse(args);
|
|
851
|
+
} catch {
|
|
852
|
+
return null;
|
|
853
|
+
}
|
|
854
|
+
}
|
|
855
|
+
return asRecord2(args);
|
|
856
|
+
}
|
|
646
857
|
function unwrapMessage(row) {
|
|
647
858
|
const record = asRecord2(row);
|
|
648
859
|
if (!record) return null;
|
|
@@ -1138,8 +1349,10 @@ function textsCachePath(accountId, stateDir) {
|
|
|
1138
1349
|
return path2.join(integrationStateDir(accountId, stateDir), TEXTS_CACHE_FILE);
|
|
1139
1350
|
}
|
|
1140
1351
|
function spellTextsForOpenClaw(texts) {
|
|
1352
|
+
const newer = texts;
|
|
1141
1353
|
return {
|
|
1142
1354
|
...texts,
|
|
1355
|
+
...typeof newer.reply_turn_template === "string" ? { reply_turn_template: spellToolsForOpenClaw(newer.reply_turn_template) } : {},
|
|
1143
1356
|
wake_instruction: spellToolsForOpenClaw(texts.wake_instruction),
|
|
1144
1357
|
invite_prompt: spellToolsForOpenClaw(texts.invite_prompt),
|
|
1145
1358
|
identity_line: spellToolsForOpenClaw(texts.identity_line),
|
|
@@ -3110,6 +3323,12 @@ function logEvent(event, logger, metrics) {
|
|
|
3110
3323
|
case "echo":
|
|
3111
3324
|
logger.debug(event.conversationId ? { conversationId: event.conversationId } : {}, "own echo \u2014 not a wake");
|
|
3112
3325
|
return;
|
|
3326
|
+
case "notice":
|
|
3327
|
+
logger.debug(event.conversationId ? { conversationId: event.conversationId } : {}, "system notice \u2014 acked, not a wake");
|
|
3328
|
+
return;
|
|
3329
|
+
case "gate_chunk":
|
|
3330
|
+
logger.debug({ cycle: event.cycle, chunk: event.index, of: event.of, cards: event.cards, outcome: event.outcome, undecided: event.undecided, ...event.failure ? { failure: event.failure } : {} }, "gate chunk");
|
|
3331
|
+
return;
|
|
3113
3332
|
case "cycle": {
|
|
3114
3333
|
const s = event.summary;
|
|
3115
3334
|
const fields = {
|