@clawos-dev/clawd 0.2.355 → 0.2.357
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.cjs +56 -26
- package/package.json +1 -1
package/dist/cli.cjs
CHANGED
|
@@ -5924,12 +5924,13 @@ var init_capability = __esm({
|
|
|
5924
5924
|
});
|
|
5925
5925
|
|
|
5926
5926
|
// ../protocol/src/contact-handshake.ts
|
|
5927
|
-
var ContactHandshakeArgsSchema, ContactHandshakeOkSchema;
|
|
5927
|
+
var PEER_LOGIN_EXPIRED_ERROR_MARKER, ContactHandshakeArgsSchema, ContactHandshakeOkSchema;
|
|
5928
5928
|
var init_contact_handshake = __esm({
|
|
5929
5929
|
"../protocol/src/contact-handshake.ts"() {
|
|
5930
5930
|
"use strict";
|
|
5931
5931
|
init_zod();
|
|
5932
5932
|
init_capability();
|
|
5933
|
+
PEER_LOGIN_EXPIRED_ERROR_MARKER = "PEER_LOGIN_EXPIRED";
|
|
5933
5934
|
ContactHandshakeArgsSchema = external_exports.object({
|
|
5934
5935
|
selfUrl: external_exports.string().min(1)
|
|
5935
5936
|
});
|
|
@@ -14860,11 +14861,15 @@ function parseClaudeObjectInner(obj) {
|
|
|
14860
14861
|
}
|
|
14861
14862
|
if (type === "usage") return events;
|
|
14862
14863
|
if (type === "result") {
|
|
14864
|
+
const resultIsError = obj.is_error === true || typeof subtype === "string" && subtype.startsWith("error");
|
|
14863
14865
|
const ev = {
|
|
14864
14866
|
kind: "turn_end",
|
|
14865
|
-
reason: typeof subtype === "string" && subtype !== "success" ? "interrupted" : "completed"
|
|
14867
|
+
reason: resultIsError || typeof subtype === "string" && subtype !== "success" ? "interrupted" : "completed"
|
|
14866
14868
|
};
|
|
14867
14869
|
if (typeof obj.duration_ms === "number") ev.durationMs = obj.duration_ms;
|
|
14870
|
+
if (resultIsError) {
|
|
14871
|
+
events.push({ kind: "error", message: extractResultErrorMessage(obj, subtype) });
|
|
14872
|
+
}
|
|
14868
14873
|
events.push(ev);
|
|
14869
14874
|
return events;
|
|
14870
14875
|
}
|
|
@@ -14877,6 +14882,19 @@ function parseClaudeObjectInner(obj) {
|
|
|
14877
14882
|
}
|
|
14878
14883
|
return events;
|
|
14879
14884
|
}
|
|
14885
|
+
function extractResultErrorMessage(obj, subtype) {
|
|
14886
|
+
const errors = Array.isArray(obj.errors) ? obj.errors.filter((value) => typeof value === "string" && value.length > 0) : [];
|
|
14887
|
+
if (errors.length > 0) return errors.join("\n");
|
|
14888
|
+
for (const key of ["message", "error", "result"]) {
|
|
14889
|
+
const value = obj[key];
|
|
14890
|
+
if (typeof value === "string" && value.length > 0) return value;
|
|
14891
|
+
if (value && typeof value === "object") {
|
|
14892
|
+
const nestedMessage = value.message;
|
|
14893
|
+
if (typeof nestedMessage === "string" && nestedMessage.length > 0) return nestedMessage;
|
|
14894
|
+
}
|
|
14895
|
+
}
|
|
14896
|
+
return subtype ?? "claude result error";
|
|
14897
|
+
}
|
|
14880
14898
|
function extractStructuredPatch(raw) {
|
|
14881
14899
|
if (!Array.isArray(raw)) return void 0;
|
|
14882
14900
|
const hunks = [];
|
|
@@ -59777,7 +59795,7 @@ function upsertPeerContact(args) {
|
|
|
59777
59795
|
provider: args.provider,
|
|
59778
59796
|
displayName: args.displayName,
|
|
59779
59797
|
remoteUrl: args.selfUrl,
|
|
59780
|
-
connectToken:
|
|
59798
|
+
connectToken: args.connectToken,
|
|
59781
59799
|
grants,
|
|
59782
59800
|
addedAt: now(),
|
|
59783
59801
|
pinnedAt: existing?.pinnedAt ?? null,
|
|
@@ -59787,17 +59805,6 @@ function upsertPeerContact(args) {
|
|
|
59787
59805
|
args.broadcast({ type: "contact:added", contact: base });
|
|
59788
59806
|
return base;
|
|
59789
59807
|
}
|
|
59790
|
-
async function backfillConnectToken(args) {
|
|
59791
|
-
try {
|
|
59792
|
-
const token = await args.exchangeToken(args.contact.deviceId);
|
|
59793
|
-
if (!token) return;
|
|
59794
|
-
const upgraded = { ...args.contact, connectToken: token };
|
|
59795
|
-
args.store.upsert(upgraded);
|
|
59796
|
-
args.broadcast({ type: "contact:added", contact: upgraded });
|
|
59797
|
-
} catch {
|
|
59798
|
-
return;
|
|
59799
|
-
}
|
|
59800
|
-
}
|
|
59801
59808
|
|
|
59802
59809
|
// src/handlers/contact.ts
|
|
59803
59810
|
function ensureOwner(ctx) {
|
|
@@ -59865,7 +59872,22 @@ function buildContactHandlers(deps) {
|
|
|
59865
59872
|
);
|
|
59866
59873
|
}
|
|
59867
59874
|
const args = parseArgs2(ContactHandshakeArgsSchema, frame, "contact:handshake");
|
|
59868
|
-
|
|
59875
|
+
let token;
|
|
59876
|
+
try {
|
|
59877
|
+
token = await deps.exchangeToken(ctx.principal.id);
|
|
59878
|
+
} catch (e) {
|
|
59879
|
+
throw new ClawdError(
|
|
59880
|
+
ERROR_CODES.INTERNAL,
|
|
59881
|
+
`TOKEN_EXCHANGE_FAILED: \u6362\u7968\u5931\u8D25\uFF08${e.message}\uFF09\uFF0C\u7A0D\u540E\u91CD\u8BD5`
|
|
59882
|
+
);
|
|
59883
|
+
}
|
|
59884
|
+
if (!token) {
|
|
59885
|
+
throw new ClawdError(
|
|
59886
|
+
ERROR_CODES.VALIDATION_ERROR,
|
|
59887
|
+
`${PEER_LOGIN_EXPIRED_ERROR_MARKER}: \u672C\u673A\u767B\u5F55\u6001\u7F3A\u5931\u6216\u5DF2\u8FC7\u671F\uFF0C\u65E0\u6CD5\u5B8C\u6210\u5EFA\u8054`
|
|
59888
|
+
);
|
|
59889
|
+
}
|
|
59890
|
+
upsertPeerContact({
|
|
59869
59891
|
store: deps.store,
|
|
59870
59892
|
broadcast: deps.broadcast,
|
|
59871
59893
|
deviceId: ctx.principal.id,
|
|
@@ -59873,14 +59895,9 @@ function buildContactHandlers(deps) {
|
|
|
59873
59895
|
provider: ctx.provider ?? "",
|
|
59874
59896
|
displayName: ctx.principal.displayName ?? ctx.principal.id,
|
|
59875
59897
|
selfUrl: args.selfUrl,
|
|
59898
|
+
connectToken: token,
|
|
59876
59899
|
now: deps.now
|
|
59877
59900
|
});
|
|
59878
|
-
void backfillConnectToken({
|
|
59879
|
-
store: deps.store,
|
|
59880
|
-
broadcast: deps.broadcast,
|
|
59881
|
-
contact,
|
|
59882
|
-
exchangeToken: deps.exchangeToken
|
|
59883
|
-
});
|
|
59884
59901
|
const identity = deps.getOwnerIdentity();
|
|
59885
59902
|
return {
|
|
59886
59903
|
response: {
|
|
@@ -60113,6 +60130,12 @@ function buildDeviceHandlers(deps) {
|
|
|
60113
60130
|
"REVERSE_UNSUPPORTED: \u5BF9\u65B9 clawd \u7248\u672C\u8FC7\u65E7\uFF0C\u8BF7\u8BA9\u5BF9\u65B9\u5347\u7EA7\u540E\u91CD\u8BD5"
|
|
60114
60131
|
);
|
|
60115
60132
|
}
|
|
60133
|
+
if (msg.includes(PEER_LOGIN_EXPIRED_ERROR_MARKER)) {
|
|
60134
|
+
throw new ClawdError(
|
|
60135
|
+
ERROR_CODES.VALIDATION_ERROR,
|
|
60136
|
+
`${PEER_LOGIN_EXPIRED_ERROR_MARKER}: \u5BF9\u65B9\u8BBE\u5907\u767B\u5F55\u5DF2\u8FC7\u671F\u6216\u672A\u767B\u5F55\uFF0C\u8BF7\u5BF9\u65B9\u5728 clawd \u91CD\u65B0\u767B\u5F55\u540E\u518D\u8BD5`
|
|
60137
|
+
);
|
|
60138
|
+
}
|
|
60116
60139
|
throw e;
|
|
60117
60140
|
}
|
|
60118
60141
|
const existing = deps.store.get(args.deviceId) ?? void 0;
|
|
@@ -60429,7 +60452,7 @@ function computeMethodAccess(args) {
|
|
|
60429
60452
|
}
|
|
60430
60453
|
|
|
60431
60454
|
// src/version.ts
|
|
60432
|
-
var version = "0.2.
|
|
60455
|
+
var version = "0.2.357".length > 0 ? "0.2.357" : "dev";
|
|
60433
60456
|
|
|
60434
60457
|
// src/cli-probe/probe.ts
|
|
60435
60458
|
var fs60 = __toESM(require("fs"), 1);
|
|
@@ -64613,8 +64636,10 @@ async function startDaemon(config) {
|
|
|
64613
64636
|
inboxStore,
|
|
64614
64637
|
// 联系人列表 store(device:connect 出站 / contact:handshake 入站落同一 store)
|
|
64615
64638
|
contactStore,
|
|
64616
|
-
// contact:handshake
|
|
64617
|
-
//
|
|
64639
|
+
// contact:handshake 换票(spec 2026-07-22;2026-08-17 起硬失败,不再是回填):
|
|
64640
|
+
// 用 owner 当前 jwt 换 aud=对方设备 的票,现读 ownerIdentityStore(热切换后用新身份)。
|
|
64641
|
+
// 契约(ContactHandlerDeps.exchangeToken):null = 本机登录问题(未登录 / JWT 过期),
|
|
64642
|
+
// 其他失败原样抛给 handler——两种都会让握手硬失败,只是给对端的错误文案不同。
|
|
64618
64643
|
exchangeToken: async (targetDeviceId) => {
|
|
64619
64644
|
const record = ownerIdentityStore.read();
|
|
64620
64645
|
if (!record) return null;
|
|
@@ -64624,7 +64649,11 @@ async function startDaemon(config) {
|
|
|
64624
64649
|
jwt: record.ttcToken,
|
|
64625
64650
|
provider: record.identity.provider,
|
|
64626
64651
|
deviceId: targetDeviceId,
|
|
64627
|
-
selfDeviceId: authFile.deviceId
|
|
64652
|
+
selfDeviceId: authFile.deviceId,
|
|
64653
|
+
// 换票在握手关键路径上(硬失败),对端 connect-remote RPC_TIMEOUT_MS=5s:
|
|
64654
|
+
// 必须在其内失败/成功,否则对端先超时不落库、本机后换票成功落库 → 反向半连,
|
|
64655
|
+
// 破坏「两侧都不落库」不变量。4s 留 1s 余量给 ws 往返
|
|
64656
|
+
timeoutMs: 4e3
|
|
64628
64657
|
});
|
|
64629
64658
|
return r.token;
|
|
64630
64659
|
} catch (e) {
|
|
@@ -64632,7 +64661,8 @@ async function startDaemon(config) {
|
|
|
64632
64661
|
targetDeviceId,
|
|
64633
64662
|
err: e.message
|
|
64634
64663
|
});
|
|
64635
|
-
return null;
|
|
64664
|
+
if (e instanceof CentralClientError && e.code === "UNAUTHORIZED") return null;
|
|
64665
|
+
throw e;
|
|
64636
64666
|
}
|
|
64637
64667
|
},
|
|
64638
64668
|
// inbox:sendDm 用:sessionId → session 出身(复用 attachment 同款 findOwnedSessionScope)
|