@clawos-dev/clawd 0.2.71-beta.126.06f4cfa → 0.2.71-beta.128.2805736
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 +97 -5
- package/package.json +1 -1
package/dist/cli.cjs
CHANGED
|
@@ -133,6 +133,11 @@ var init_methods = __esm({
|
|
|
133
133
|
"remote-persona:add",
|
|
134
134
|
"remote-persona:list",
|
|
135
135
|
"remote-persona:remove",
|
|
136
|
+
// ---- whoami (v2 capability platform) ----
|
|
137
|
+
// 任何 authed connection 都能调;返回 owner 显示名 + 当前 capability wire 形态 +
|
|
138
|
+
// grants 对应的 persona 元数据 (id + displayName)。UI 端 AddRemotePersonaDialog
|
|
139
|
+
// 的 preview 一次性临时 client 用它判定身份和可用 persona。
|
|
140
|
+
"whoami",
|
|
136
141
|
"info",
|
|
137
142
|
"ping"
|
|
138
143
|
];
|
|
@@ -5086,7 +5091,7 @@ function stripSecretHash(cap) {
|
|
|
5086
5091
|
const { secretHash: _hash, ...wire } = cap;
|
|
5087
5092
|
return wire;
|
|
5088
5093
|
}
|
|
5089
|
-
var ResourceSchema, ActionSchema, GrantSchema, CapabilitySchema, CapabilityWireSchema, CapabilityErrorCodeSchema;
|
|
5094
|
+
var ResourceSchema, ActionSchema, GrantSchema, CapabilitySchema, CapabilityWireSchema, CapabilityErrorCodeSchema, WhoamiResponseSchema;
|
|
5090
5095
|
var init_capability = __esm({
|
|
5091
5096
|
"../protocol/src/capability.ts"() {
|
|
5092
5097
|
"use strict";
|
|
@@ -5121,6 +5126,21 @@ var init_capability = __esm({
|
|
|
5121
5126
|
"TOKEN_EXPIRED",
|
|
5122
5127
|
"TOKEN_EXHAUSTED"
|
|
5123
5128
|
]);
|
|
5129
|
+
WhoamiResponseSchema = external_exports.object({
|
|
5130
|
+
type: external_exports.literal("whoami:ok"),
|
|
5131
|
+
owner: external_exports.object({
|
|
5132
|
+
id: external_exports.string(),
|
|
5133
|
+
kind: external_exports.enum(["owner", "guest"]),
|
|
5134
|
+
displayName: external_exports.string()
|
|
5135
|
+
}).strict(),
|
|
5136
|
+
capability: CapabilityWireSchema,
|
|
5137
|
+
grantedPersonas: external_exports.array(
|
|
5138
|
+
external_exports.object({
|
|
5139
|
+
id: external_exports.string().min(1),
|
|
5140
|
+
displayName: external_exports.string()
|
|
5141
|
+
}).strict()
|
|
5142
|
+
)
|
|
5143
|
+
}).strict();
|
|
5124
5144
|
}
|
|
5125
5145
|
});
|
|
5126
5146
|
|
|
@@ -26156,6 +26176,11 @@ var CapabilityManager = class {
|
|
|
26156
26176
|
list() {
|
|
26157
26177
|
return this.registry.list();
|
|
26158
26178
|
}
|
|
26179
|
+
// whoami handler 用:根据 capabilityId 反查 caller 的 capability 实体。
|
|
26180
|
+
// 返回 Capability 持久化形态;handler 调 stripSecretHash 后再上 wire。
|
|
26181
|
+
findById(id) {
|
|
26182
|
+
return this.registry.findById(id);
|
|
26183
|
+
}
|
|
26159
26184
|
issue(args) {
|
|
26160
26185
|
if (!args.displayName.trim()) {
|
|
26161
26186
|
throw new Error("CapabilityManager.issue: displayName must be non-empty");
|
|
@@ -28370,15 +28395,18 @@ var RevokeArgsSchema = external_exports.object({
|
|
|
28370
28395
|
capabilityId: external_exports.string().min(1)
|
|
28371
28396
|
}).strict();
|
|
28372
28397
|
function buildCapabilityHandlers(deps) {
|
|
28373
|
-
const { manager } = deps;
|
|
28398
|
+
const { manager, getShareBaseUrl } = deps;
|
|
28374
28399
|
const issue = async (frame) => {
|
|
28375
28400
|
const { type: _type, requestId: _requestId, ...rest } = frame;
|
|
28376
28401
|
const args = IssueArgsSchema.parse(rest);
|
|
28377
28402
|
const { token, capability } = manager.issue(args);
|
|
28403
|
+
const base = getShareBaseUrl().replace(/\/$/, "");
|
|
28404
|
+
const shareUrl = `${base}/?token=${encodeURIComponent(token)}`;
|
|
28378
28405
|
return {
|
|
28379
28406
|
response: {
|
|
28380
28407
|
type: "capability:issued",
|
|
28381
28408
|
token,
|
|
28409
|
+
shareUrl,
|
|
28382
28410
|
capability: stripSecretHash(capability)
|
|
28383
28411
|
}
|
|
28384
28412
|
};
|
|
@@ -28499,12 +28527,13 @@ function buildRemotePersonaHandlers(deps) {
|
|
|
28499
28527
|
response: { type: "remote-persona:add:ok", remotePersona: stripRemotePersonaSecret(rp) }
|
|
28500
28528
|
};
|
|
28501
28529
|
};
|
|
28502
|
-
const list = async () => {
|
|
28530
|
+
const list = async (_frame, _client, ctx) => {
|
|
28503
28531
|
const all = store.list();
|
|
28532
|
+
const projected = ctx?.principal.kind === "owner" ? all : all.map(stripRemotePersonaSecret);
|
|
28504
28533
|
return {
|
|
28505
28534
|
response: {
|
|
28506
28535
|
type: "remote-persona:list",
|
|
28507
|
-
remotePersonas:
|
|
28536
|
+
remotePersonas: projected
|
|
28508
28537
|
}
|
|
28509
28538
|
};
|
|
28510
28539
|
};
|
|
@@ -28523,6 +28552,51 @@ function buildRemotePersonaHandlers(deps) {
|
|
|
28523
28552
|
};
|
|
28524
28553
|
}
|
|
28525
28554
|
|
|
28555
|
+
// src/handlers/whoami.ts
|
|
28556
|
+
init_protocol();
|
|
28557
|
+
function buildWhoamiHandler(deps) {
|
|
28558
|
+
return async (_frame, _client, ctx) => {
|
|
28559
|
+
if (!ctx) {
|
|
28560
|
+
throw new ClawdError(ERROR_CODES.INTERNAL, "whoami: missing ConnectionContext");
|
|
28561
|
+
}
|
|
28562
|
+
const owner = { ...OWNER_PRINCIPAL, displayName: deps.ownerDisplayName };
|
|
28563
|
+
let capability;
|
|
28564
|
+
if (ctx.principal.kind === "owner") {
|
|
28565
|
+
capability = {
|
|
28566
|
+
id: "owner",
|
|
28567
|
+
displayName: deps.ownerDisplayName,
|
|
28568
|
+
grants: ctx.grants,
|
|
28569
|
+
issuedAt: 0,
|
|
28570
|
+
usedCount: 0
|
|
28571
|
+
};
|
|
28572
|
+
} else {
|
|
28573
|
+
if (!ctx.capabilityId) {
|
|
28574
|
+
throw new ClawdError(ERROR_CODES.UNAUTHORIZED, "whoami: guest ctx without capabilityId");
|
|
28575
|
+
}
|
|
28576
|
+
const cap = deps.capabilityManager.findById(ctx.capabilityId);
|
|
28577
|
+
if (!cap) {
|
|
28578
|
+
throw new ClawdError(ERROR_CODES.UNAUTHORIZED, `whoami: capability not found: ${ctx.capabilityId}`);
|
|
28579
|
+
}
|
|
28580
|
+
capability = stripSecretHash(cap);
|
|
28581
|
+
}
|
|
28582
|
+
const grantedPersonas = [];
|
|
28583
|
+
for (const g2 of capability.grants) {
|
|
28584
|
+
if (g2.resource.type !== "persona") continue;
|
|
28585
|
+
const file = deps.personaStore.read(g2.resource.id);
|
|
28586
|
+
if (!file) continue;
|
|
28587
|
+
grantedPersonas.push({ id: file.personaId, displayName: file.label });
|
|
28588
|
+
}
|
|
28589
|
+
return {
|
|
28590
|
+
response: {
|
|
28591
|
+
type: "whoami:ok",
|
|
28592
|
+
owner,
|
|
28593
|
+
capability,
|
|
28594
|
+
grantedPersonas
|
|
28595
|
+
}
|
|
28596
|
+
};
|
|
28597
|
+
};
|
|
28598
|
+
}
|
|
28599
|
+
|
|
28526
28600
|
// src/handlers/meta.ts
|
|
28527
28601
|
var import_node_os13 = __toESM(require("os"), 1);
|
|
28528
28602
|
init_protocol();
|
|
@@ -28774,12 +28848,20 @@ function buildMethodHandlers(deps) {
|
|
|
28774
28848
|
personaManager: deps.personaManager,
|
|
28775
28849
|
personaRegistry: deps.personaRegistry
|
|
28776
28850
|
}),
|
|
28777
|
-
...buildCapabilityHandlers({
|
|
28851
|
+
...buildCapabilityHandlers({
|
|
28852
|
+
manager: deps.capabilityManager,
|
|
28853
|
+
getShareBaseUrl: deps.getShareBaseUrl
|
|
28854
|
+
}),
|
|
28778
28855
|
...buildInboxHandlers({
|
|
28779
28856
|
manager: deps.inboxManager,
|
|
28780
28857
|
capabilityRegistry: deps.capabilityRegistry
|
|
28781
28858
|
}),
|
|
28782
28859
|
...buildRemotePersonaHandlers({ store: deps.remotePersonaStore }),
|
|
28860
|
+
whoami: buildWhoamiHandler({
|
|
28861
|
+
ownerDisplayName: deps.ownerDisplayName,
|
|
28862
|
+
personaStore: deps.personaStore,
|
|
28863
|
+
capabilityManager: deps.capabilityManager
|
|
28864
|
+
}),
|
|
28783
28865
|
...deps.attachment ? buildAttachmentHandlers(deps.attachment) : {}
|
|
28784
28866
|
};
|
|
28785
28867
|
}
|
|
@@ -28794,6 +28876,10 @@ var METHOD_GRANT_MAP = {
|
|
|
28794
28876
|
// ---- public(meta-only,guest 也能调) ----
|
|
28795
28877
|
"info": { kind: "public" },
|
|
28796
28878
|
"ping": { kind: "public" },
|
|
28879
|
+
// v2 Phase 6: whoami 是身份反查,任何 authed connection (owner / guest) 都能调;
|
|
28880
|
+
// handler 内部按 ctx.principal.kind 决定返回 "合成 owner self capability" 还是
|
|
28881
|
+
// "查 capabilityManager 拿 caller 的 guest capability"。
|
|
28882
|
+
"whoami": { kind: "public" },
|
|
28797
28883
|
// ---- capability platform(admin-only,本 PR 新增) ----
|
|
28798
28884
|
"capability:issue": ADMIN_ANY,
|
|
28799
28885
|
"capability:list": ADMIN_ANY,
|
|
@@ -29140,6 +29226,12 @@ async function startDaemon(config) {
|
|
|
29140
29226
|
},
|
|
29141
29227
|
// Task 1.9: capability:issue/list/revoke handler 依赖
|
|
29142
29228
|
capabilityManager,
|
|
29229
|
+
// v2 Phase 5: capability:issue 返回的 shareUrl 用此 base URL 拼接。
|
|
29230
|
+
// tunnel 拉起后切到反代 wss://... 地址;否则本机 ws://host:port。
|
|
29231
|
+
getShareBaseUrl: () => currentTunnelUrl ?? `ws://${config.host}:${config.port}`,
|
|
29232
|
+
// v2 Phase 6: whoami handler 装在 owner principal.displayName + persona 解析
|
|
29233
|
+
ownerDisplayName,
|
|
29234
|
+
personaStore,
|
|
29143
29235
|
// Phase 4 Task 4.2: inbox:postMessage 要查 capabilityRegistry 解析 peer Principal
|
|
29144
29236
|
capabilityRegistry,
|
|
29145
29237
|
// Phase 3 Task 3.4: inbox:list/markRead handler 依赖
|
package/package.json
CHANGED