@clawos-dev/clawd 0.2.438 → 0.2.440
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 +545 -338
- package/dist/dispatch/mcp-server.cjs +40 -10
- package/dist/share-md-viewer-error.html +1 -1
- package/dist/share-md-viewer.html +1 -1
- package/dist/share-ui/assets/{guest-kR-iXTSq.js → guest-D9w-fQvq.js} +130 -130
- package/dist/share-ui/assets/guest-DISx208T.css +32 -0
- package/dist/share-ui/guest.html +2 -2
- package/package.json +1 -1
- package/dist/share-ui/assets/guest-CdTJbtWU.css +0 -32
package/dist/cli.cjs
CHANGED
|
@@ -450,8 +450,8 @@ var init_parseUtil = __esm({
|
|
|
450
450
|
init_errors();
|
|
451
451
|
init_en();
|
|
452
452
|
makeIssue = (params) => {
|
|
453
|
-
const { data, path:
|
|
454
|
-
const fullPath = [...
|
|
453
|
+
const { data, path: path91, errorMaps, issueData } = params;
|
|
454
|
+
const fullPath = [...path91, ...issueData.path || []];
|
|
455
455
|
const fullIssue = {
|
|
456
456
|
...issueData,
|
|
457
457
|
path: fullPath
|
|
@@ -762,11 +762,11 @@ var init_types = __esm({
|
|
|
762
762
|
init_parseUtil();
|
|
763
763
|
init_util();
|
|
764
764
|
ParseInputLazyPath = class {
|
|
765
|
-
constructor(parent, value,
|
|
765
|
+
constructor(parent, value, path91, key) {
|
|
766
766
|
this._cachedPath = [];
|
|
767
767
|
this.parent = parent;
|
|
768
768
|
this.data = value;
|
|
769
|
-
this._path =
|
|
769
|
+
this._path = path91;
|
|
770
770
|
this._key = key;
|
|
771
771
|
}
|
|
772
772
|
get path() {
|
|
@@ -7051,7 +7051,7 @@ var init_onboarding_schemas = __esm({
|
|
|
7051
7051
|
});
|
|
7052
7052
|
|
|
7053
7053
|
// ../protocol/src/persona-schemas.ts
|
|
7054
|
-
var PersonaFileSchema, PersonaSkillSummarySchema, PersonaPluginSummarySchema, PersonaSandboxSettingsSchema, PersonaInfoResponseSchema, PersonaCreateArgsSchema, PersonaIdArgsSchema, PersonaUpdateArgsSchema
|
|
7054
|
+
var PersonaFileSchema, PersonaSkillSummarySchema, PersonaPluginSummarySchema, CodexSandboxSettingsSchema, PersonaSandboxSettingsSchema, PersonaInfoResponseSchema, PersonaCreateArgsSchema, PersonaIdArgsSchema, PersonaUpdateArgsSchema;
|
|
7055
7055
|
var init_persona_schemas = __esm({
|
|
7056
7056
|
"../protocol/src/persona-schemas.ts"() {
|
|
7057
7057
|
"use strict";
|
|
@@ -7084,6 +7084,17 @@ var init_persona_schemas = __esm({
|
|
|
7084
7084
|
// settings.json 中 enabledPlugins 的 key,例如 'superpowers@claude-plugins-official'
|
|
7085
7085
|
id: external_exports.string().min(1)
|
|
7086
7086
|
});
|
|
7087
|
+
CodexSandboxSettingsSchema = external_exports.object({
|
|
7088
|
+
// 额外可写的绝对路径或 ~ 路径(pnpm 工具链等);workspace(cwd) 和 userWorkDir 由 daemon 自动加,不用列。
|
|
7089
|
+
writableRoots: external_exports.array(external_exports.string()).optional(),
|
|
7090
|
+
// 禁读 glob(相对 workspace root 或绝对),如 ".secrets/**"、"**/*.env"。
|
|
7091
|
+
denyRead: external_exports.array(external_exports.string()).optional(),
|
|
7092
|
+
// true → 网络全放(*);false → 断网。**缺省等于联网**:daemon 写入的默认值是 network:true
|
|
7093
|
+
// (对齐 claude guest 一贯的域名全放,见 spec 2026-09-01-codex-guest-network §1.3),
|
|
7094
|
+
// 且 manager / UI 读到 undefined 时都回落 true —— 两侧必须同向,否则出现
|
|
7095
|
+
// 「卡片显示开、实际断网」的幽灵态。
|
|
7096
|
+
network: external_exports.boolean().optional()
|
|
7097
|
+
}).strict();
|
|
7087
7098
|
PersonaSandboxSettingsSchema = external_exports.object({
|
|
7088
7099
|
permissions: external_exports.object({
|
|
7089
7100
|
defaultMode: external_exports.string().optional(),
|
|
@@ -7132,7 +7143,10 @@ var init_persona_schemas = __esm({
|
|
|
7132
7143
|
skills: external_exports.array(PersonaSkillSummarySchema).optional(),
|
|
7133
7144
|
// 仅 'persona:get' 携带;空数组 = 没启用任何插件 / settings.json 不存在;undefined = 不在该响应类型上
|
|
7134
7145
|
plugins: external_exports.array(PersonaPluginSummarySchema).optional(),
|
|
7135
|
-
sandboxSettings: PersonaSandboxSettingsSchema.nullable().optional()
|
|
7146
|
+
sandboxSettings: PersonaSandboxSettingsSchema.nullable().optional(),
|
|
7147
|
+
// 仅 'persona:get' 携带;null = codex-sandbox.json 不存在 / parse 失败。
|
|
7148
|
+
// UI 的「访客联网」开关读它(见 PersonaCardSettings)。
|
|
7149
|
+
codexSandbox: CodexSandboxSettingsSchema.nullable().optional()
|
|
7136
7150
|
});
|
|
7137
7151
|
PersonaCreateArgsSchema = external_exports.object({
|
|
7138
7152
|
// persona 身份。daemon 拼成 personaId = `persona-<slug>`——前缀由 daemon 拥有,调用方只给后半段,
|
|
@@ -7164,17 +7178,13 @@ var init_persona_schemas = __esm({
|
|
|
7164
7178
|
personalityLocal: external_exports.string().optional(),
|
|
7165
7179
|
public: external_exports.boolean().optional(),
|
|
7166
7180
|
// pass `null` to clear; daemon strips the field from PersonaFile on null
|
|
7167
|
-
iconKey: external_exports.string().nullable().optional()
|
|
7181
|
+
iconKey: external_exports.string().nullable().optional(),
|
|
7182
|
+
// codex guest 沙箱(落盘 .clawd/codex-sandbox.json,不在 PersonaFile 里)。与 personality
|
|
7183
|
+
// 同款分层写:handler 剥出来单独落盘,且**局部合并**——只带 network 的 patch 不能抹掉
|
|
7184
|
+
// owner 手配的 writableRoots / denyRead。
|
|
7185
|
+
codexSandbox: CodexSandboxSettingsSchema.optional()
|
|
7168
7186
|
}).strict()
|
|
7169
7187
|
}).strict();
|
|
7170
|
-
CodexSandboxSettingsSchema = external_exports.object({
|
|
7171
|
-
// 额外可写的绝对路径或 ~ 路径(pnpm 工具链等);workspace(cwd) 和 userWorkDir 由 daemon 自动加,不用列。
|
|
7172
|
-
writableRoots: external_exports.array(external_exports.string()).optional(),
|
|
7173
|
-
// 禁读 glob(相对 workspace root 或绝对),如 ".secrets/**"、"**/*.env"。
|
|
7174
|
-
denyRead: external_exports.array(external_exports.string()).optional(),
|
|
7175
|
-
// true → 网络全放(*);缺省/false → 断网。
|
|
7176
|
-
network: external_exports.boolean().optional()
|
|
7177
|
-
}).strict();
|
|
7178
7188
|
}
|
|
7179
7189
|
});
|
|
7180
7190
|
|
|
@@ -7275,7 +7285,7 @@ var init_principal = __esm({
|
|
|
7275
7285
|
});
|
|
7276
7286
|
|
|
7277
7287
|
// ../protocol/src/schemas.ts
|
|
7278
|
-
var SessionStatusSchema, ContextUsageSchema, sessionMetaShape, SessionMetaSchema, SelectOptionSchema, ModelInfoSchema, ModeInfoSchema, ConfigFieldSchemaSchema, CapabilitiesGetArgs, ToolFeaturesSchema, CapabilitiesResponseSchema, AllowRuleSchema, SessionFileSchema, ParsedEventBase, HistoryUserMetaSchema, SubagentToolStatsSchema, StructuredPatchHunkSchema, ToolResultExtraSchema, MemoryEntrySchema, AskQuestionOptionSchema, AskQuestionItemSchema, TURN_END_REASONS, ParsedEventSchema, SessionCreateArgs, ProjectEntry, ProjectPatchArgs, ProjectRevealArgs, ProjectCreateArgs, SessionImportExternalArgs, SessionListArgs, SessionIdArgs, SessionUpdateArgs, QueuedMessage, SessionSendArgs, SessionDequeueArgs, SessionRewindArgs, SessionRewindResponseSchema, SessionRewindDiffArgs, RewindDiffHunkSchema, RewindDiffFileSchema, SessionRewindDiffResponseSchema, SessionRewindableMessageIdsResponseSchema, SessionResumeArgs, SessionForkArgs, SessionForkResponseSchema, SessionObserveArgs, SessionEventsArgs, PermissionRespondArgs, HistoryListArgs, HistoryReadArgs, HistorySubagentsArgs, HistorySubagentReadArgs, WorkspaceListArgs, WorkspaceReadArgs, SkillsListArgs, SkillEntrySchema, AgentEntrySchema, AgentsListArgs, AgentsListResponseSchema, SessionCurrentTurnSenderArgs, SessionSubscribeArgs, SessionPinArgs, SessionArchiveArgs, PeerSessionUpsertArgs, PeerSessionUpsertResponseSchema, PeerSessionRemoveArgs, PeerSessionRemoveResponseSchema, SessionReorderPinsArgs, GitRootArgs, GitRootResponseSchema, GitBranchArgs, GitBranchResponseSchema, GitBranchesArgs, GitBranchesResponseSchema, RecentDirEntrySchema, HistoryRecentDirsResponseSchema, SessionQuestionFrameSchema, SessionQuestionClearedFrameSchema, AnswerQuestionArgs, AnswerQuestionResponseSchema, CancelQuestionArgs, CancelQuestionResponseSchema, ClientInfoSchema, AuthRequestFrameSchema, AuthOkFrameSchema, DeviceConnectionEntrySchema, DeviceConnectionsResponseSchema, TunnelReadyEventSchema, TunnelExitedEventSchema, TunnelUnavailableEventSchema, InfoRunningSessionSchema, InfoResponseSchema, PROJECT_PORT_MIN, PROJECT_PORT_MAX, projectNameRegex, DEFAULT_DEV_COMMAND, ProjectMetadataSchema, PROJECT_STAGE_VALUES, ProjectStageSchema, ProjectWithStatusSchema, ListProjectsArgsSchema, ListProjectsResultSchema, GetProjectArgsSchema, GetProjectResultSchema, CreateProjectArgsSchema, CreateProjectResultSchema, DeleteProjectArgsSchema, DeleteProjectResultSchema, UpdateProjectPortArgsSchema, UpdateProjectPortResultSchema, SetProdUrlArgsSchema, SetProdUrlResultSchema, StartDevServerArgsSchema, StartDevServerResultSchema, ASSISTANT_REPORTABLE_STAGES, ReportStageArgsSchema, ReportStageResultSchema, StopDevServerArgsSchema, StopDevServerResultSchema, AppBuilderProjectUpdatedEventSchema, PublishArgsSchema, PublishResultSchema, DismissPublishJobArgsSchema, DismissPublishJobResultSchema, AppBuilderPublishProgressEventSchema, AppBuilderPublishFailedEventSchema;
|
|
7288
|
+
var SessionStatusSchema, ContextUsageSchema, sessionMetaShape, SessionMetaSchema, SelectOptionSchema, ModelInfoSchema, ModeInfoSchema, ConfigFieldSchemaSchema, CapabilitiesGetArgs, ToolFeaturesSchema, CapabilitiesResponseSchema, AllowRuleSchema, SessionFileSchema, ParsedEventBase, HistoryUserMetaSchema, SubagentToolStatsSchema, StructuredPatchHunkSchema, ToolResultExtraSchema, MemoryEntrySchema, AskQuestionOptionSchema, AskQuestionItemSchema, TURN_END_REASONS, ParsedEventSchema, SessionCreateArgs, ProjectEntry, ProjectPatchArgs, ProjectRevealArgs, ProjectCreateArgs, SessionImportExternalArgs, SessionListArgs, SessionIdArgs, SessionUpdateArgs, QueuedMessage, SessionSendArgs, SessionDequeueArgs, SessionRewindArgs, SessionRewindResponseSchema, SessionRewindDiffArgs, RewindDiffHunkSchema, RewindDiffFileSchema, SessionRewindDiffResponseSchema, SessionRewindableMessageIdsResponseSchema, SessionResumeArgs, SessionForkArgs, SessionForkResponseSchema, SessionObserveArgs, SessionEventsArgs, PermissionRespondArgs, HistoryListArgs, HistoryReadArgs, HistorySubagentsArgs, HistorySubagentReadArgs, WorkspaceListArgs, WorkspaceReadArgs, SkillsListArgs, SkillEntrySchema, AgentEntrySchema, AgentsListArgs, AgentsListResponseSchema, SessionCurrentTurnSenderArgs, SessionSubscribeArgs, SessionPinArgs, SessionArchiveArgs, SessionSearchContentArgs, SessionSearchMatchSchema, SessionSearchContentResponseSchema, PeerSessionUpsertArgs, PeerSessionUpsertResponseSchema, PeerSessionRemoveArgs, PeerSessionRemoveResponseSchema, SessionReorderPinsArgs, GitRootArgs, GitRootResponseSchema, GitBranchArgs, GitBranchResponseSchema, GitBranchesArgs, GitBranchesResponseSchema, RecentDirEntrySchema, HistoryRecentDirsResponseSchema, SessionQuestionFrameSchema, SessionQuestionClearedFrameSchema, AnswerQuestionArgs, AnswerQuestionResponseSchema, CancelQuestionArgs, CancelQuestionResponseSchema, ClientInfoSchema, AuthRequestFrameSchema, AuthOkFrameSchema, DeviceConnectionEntrySchema, DeviceConnectionsResponseSchema, TunnelReadyEventSchema, TunnelExitedEventSchema, TunnelUnavailableEventSchema, InfoRunningSessionSchema, InfoResponseSchema, PROJECT_PORT_MIN, PROJECT_PORT_MAX, projectNameRegex, DEFAULT_DEV_COMMAND, ProjectMetadataSchema, PROJECT_STAGE_VALUES, ProjectStageSchema, ProjectWithStatusSchema, ListProjectsArgsSchema, ListProjectsResultSchema, GetProjectArgsSchema, GetProjectResultSchema, CreateProjectArgsSchema, CreateProjectResultSchema, DeleteProjectArgsSchema, DeleteProjectResultSchema, UpdateProjectPortArgsSchema, UpdateProjectPortResultSchema, SetProdUrlArgsSchema, SetProdUrlResultSchema, StartDevServerArgsSchema, StartDevServerResultSchema, ASSISTANT_REPORTABLE_STAGES, ReportStageArgsSchema, ReportStageResultSchema, StopDevServerArgsSchema, StopDevServerResultSchema, AppBuilderProjectUpdatedEventSchema, PublishArgsSchema, PublishResultSchema, DismissPublishJobArgsSchema, DismissPublishJobResultSchema, AppBuilderPublishProgressEventSchema, AppBuilderPublishFailedEventSchema;
|
|
7279
7289
|
var init_schemas = __esm({
|
|
7280
7290
|
"../protocol/src/schemas.ts"() {
|
|
7281
7291
|
"use strict";
|
|
@@ -8019,6 +8029,22 @@ var init_schemas = __esm({
|
|
|
8019
8029
|
sessionId: external_exports.string().min(1),
|
|
8020
8030
|
archived: external_exports.boolean()
|
|
8021
8031
|
});
|
|
8032
|
+
SessionSearchContentArgs = external_exports.object({
|
|
8033
|
+
query: external_exports.string().min(1),
|
|
8034
|
+
// 扫描顺序 = 数组顺序(调用方按 updatedAt 倒序传),攒够 limit 即停
|
|
8035
|
+
sessionIds: external_exports.array(external_exports.string().min(1)),
|
|
8036
|
+
limit: external_exports.number().int().positive().max(50).optional()
|
|
8037
|
+
});
|
|
8038
|
+
SessionSearchMatchSchema = external_exports.object({
|
|
8039
|
+
sessionId: external_exports.string().min(1),
|
|
8040
|
+
// 命中处上下文片段,已单行化。**不回高亮 offset**:调用方手里有 query,
|
|
8041
|
+
// 自己在 snippet 里 indexOf 就能高亮,wire 上少一组坐标少一处漂
|
|
8042
|
+
snippet: external_exports.string()
|
|
8043
|
+
});
|
|
8044
|
+
SessionSearchContentResponseSchema = external_exports.object({
|
|
8045
|
+
type: external_exports.literal("session:searchContent"),
|
|
8046
|
+
matches: external_exports.array(SessionSearchMatchSchema)
|
|
8047
|
+
});
|
|
8022
8048
|
PeerSessionUpsertArgs = SessionFileSchema;
|
|
8023
8049
|
PeerSessionUpsertResponseSchema = external_exports.object({
|
|
8024
8050
|
type: external_exports.literal("peerSession:upsert:ok")
|
|
@@ -8505,6 +8531,10 @@ var init_methods = __esm({
|
|
|
8505
8531
|
summary: "\u5F52\u6863 / \u53D6\u6D88\u5F52\u6863\u4F1A\u8BDD\uFF08\u5F52\u6863 = \u5168\u5C40\u6536\u7EB3\u6001\uFF1A\u9000\u51FA sidebar\u3001\u539F\u5B50\u6E05 pinnedAt\uFF09",
|
|
8506
8532
|
args: SessionArchiveArgs
|
|
8507
8533
|
},
|
|
8534
|
+
"session:searchContent": {
|
|
8535
|
+
summary: '\u5728 sessionIds \u7ED9\u5B9A\u7684\u8FD9\u6279\u4F1A\u8BDD\u91CC\u641C\u6B63\u6587\u5185\u5BB9\uFF08user / assistant \u7684\u6587\u672C\u6D88\u606F\uFF1B\u5DE5\u5177\u5165\u53C2\u51FA\u53C2\u4E0E\u7CFB\u7EDF\u6CE8\u5165\u4E0D\u7B97\uFF09\uFF0C\u547D\u4E2D\u8FD4\u56DE\u4E0A\u4E0B\u6587\u7247\u6BB5\u3002**\u626B\u63CF\u987A\u5E8F = sessionIds \u6570\u7EC4\u987A\u5E8F\uFF0C\u6512\u591F limit \u5C31\u505C**\uFF08\u8C03\u7528\u65B9\u6309 updatedAt \u5012\u5E8F\u4F20 \u2192 \u65E9\u505C\u7ED3\u679C\u5373"\u6700\u8FD1 N \u6761"\uFF09\uFF1Blimit \u7F3A\u7701 9\u3002\u5019\u9009\u7531\u8C03\u7528\u65B9\u7ED9\u5B9A\uFF0Cdaemon \u4E0D\u81EA\u5DF1\u6309 archivedAt \u7B5B\uFF08\u8BDD\u9898\u5F52\u6863\u53EA\u6253\u5728 Master \u4F1A\u8BDD\u4E0A\uFF0Cworker \u4F1A\u8BDD\u6CA1\u6807\u8BB0\uFF09\uFF1B\u65E0\u6743\u8BFB / \u5B9A\u4F4D\u4E0D\u5230 transcript / transcript \u5DF2\u88AB CC \u6E05\u7406\u7684\u4F1A\u8BDD\u9759\u9ED8\u8DF3\u8FC7\uFF0C\u4E0D\u62A5\u9519',
|
|
8536
|
+
args: SessionSearchContentArgs
|
|
8537
|
+
},
|
|
8508
8538
|
"session:markRead": {
|
|
8509
8539
|
summary: "\u6E05\u6389\u4F1A\u8BDD\u7684\u5171\u4EAB\u672A\u8BFB\u6807\u8BB0\u5E76\u5E7F\u64AD session:info\uFF1B\u5E42\u7B49",
|
|
8510
8540
|
args: SessionIdArgs
|
|
@@ -9564,8 +9594,8 @@ var require_req = __commonJS({
|
|
|
9564
9594
|
if (req.originalUrl) {
|
|
9565
9595
|
_req.url = req.originalUrl;
|
|
9566
9596
|
} else {
|
|
9567
|
-
const
|
|
9568
|
-
_req.url = typeof
|
|
9597
|
+
const path91 = req.path;
|
|
9598
|
+
_req.url = typeof path91 === "string" ? path91 : req.url ? req.url.path || req.url : void 0;
|
|
9569
9599
|
}
|
|
9570
9600
|
if (req.query) {
|
|
9571
9601
|
_req.query = req.query;
|
|
@@ -9730,14 +9760,14 @@ var require_redact = __commonJS({
|
|
|
9730
9760
|
}
|
|
9731
9761
|
return obj;
|
|
9732
9762
|
}
|
|
9733
|
-
function parsePath(
|
|
9763
|
+
function parsePath(path91) {
|
|
9734
9764
|
const parts = [];
|
|
9735
9765
|
let current = "";
|
|
9736
9766
|
let inBrackets = false;
|
|
9737
9767
|
let inQuotes = false;
|
|
9738
9768
|
let quoteChar = "";
|
|
9739
|
-
for (let i = 0; i <
|
|
9740
|
-
const char =
|
|
9769
|
+
for (let i = 0; i < path91.length; i++) {
|
|
9770
|
+
const char = path91[i];
|
|
9741
9771
|
if (!inBrackets && char === ".") {
|
|
9742
9772
|
if (current) {
|
|
9743
9773
|
parts.push(current);
|
|
@@ -9868,10 +9898,10 @@ var require_redact = __commonJS({
|
|
|
9868
9898
|
return current;
|
|
9869
9899
|
}
|
|
9870
9900
|
function redactPaths(obj, paths, censor, remove = false) {
|
|
9871
|
-
for (const
|
|
9872
|
-
const parts = parsePath(
|
|
9901
|
+
for (const path91 of paths) {
|
|
9902
|
+
const parts = parsePath(path91);
|
|
9873
9903
|
if (parts.includes("*")) {
|
|
9874
|
-
redactWildcardPath(obj, parts, censor,
|
|
9904
|
+
redactWildcardPath(obj, parts, censor, path91, remove);
|
|
9875
9905
|
} else {
|
|
9876
9906
|
if (remove) {
|
|
9877
9907
|
removeKey(obj, parts);
|
|
@@ -9956,8 +9986,8 @@ var require_redact = __commonJS({
|
|
|
9956
9986
|
}
|
|
9957
9987
|
} else {
|
|
9958
9988
|
if (afterWildcard.includes("*")) {
|
|
9959
|
-
const wrappedCensor = typeof censor === "function" ? (value,
|
|
9960
|
-
const fullPath = [...pathArray.slice(0, pathLength), ...
|
|
9989
|
+
const wrappedCensor = typeof censor === "function" ? (value, path91) => {
|
|
9990
|
+
const fullPath = [...pathArray.slice(0, pathLength), ...path91];
|
|
9961
9991
|
return censor(value, fullPath);
|
|
9962
9992
|
} : censor;
|
|
9963
9993
|
redactWildcardPath(current, afterWildcard, wrappedCensor, originalPath, remove);
|
|
@@ -9992,8 +10022,8 @@ var require_redact = __commonJS({
|
|
|
9992
10022
|
return null;
|
|
9993
10023
|
}
|
|
9994
10024
|
const pathStructure = /* @__PURE__ */ new Map();
|
|
9995
|
-
for (const
|
|
9996
|
-
const parts = parsePath(
|
|
10025
|
+
for (const path91 of pathsToClone) {
|
|
10026
|
+
const parts = parsePath(path91);
|
|
9997
10027
|
let current = pathStructure;
|
|
9998
10028
|
for (let i = 0; i < parts.length; i++) {
|
|
9999
10029
|
const part = parts[i];
|
|
@@ -10045,24 +10075,24 @@ var require_redact = __commonJS({
|
|
|
10045
10075
|
}
|
|
10046
10076
|
return cloneSelectively(obj, pathStructure);
|
|
10047
10077
|
}
|
|
10048
|
-
function validatePath(
|
|
10049
|
-
if (typeof
|
|
10078
|
+
function validatePath(path91) {
|
|
10079
|
+
if (typeof path91 !== "string") {
|
|
10050
10080
|
throw new Error("Paths must be (non-empty) strings");
|
|
10051
10081
|
}
|
|
10052
|
-
if (
|
|
10082
|
+
if (path91 === "") {
|
|
10053
10083
|
throw new Error("Invalid redaction path ()");
|
|
10054
10084
|
}
|
|
10055
|
-
if (
|
|
10056
|
-
throw new Error(`Invalid redaction path (${
|
|
10085
|
+
if (path91.includes("..")) {
|
|
10086
|
+
throw new Error(`Invalid redaction path (${path91})`);
|
|
10057
10087
|
}
|
|
10058
|
-
if (
|
|
10059
|
-
throw new Error(`Invalid redaction path (${
|
|
10088
|
+
if (path91.includes(",")) {
|
|
10089
|
+
throw new Error(`Invalid redaction path (${path91})`);
|
|
10060
10090
|
}
|
|
10061
10091
|
let bracketCount = 0;
|
|
10062
10092
|
let inQuotes = false;
|
|
10063
10093
|
let quoteChar = "";
|
|
10064
|
-
for (let i = 0; i <
|
|
10065
|
-
const char =
|
|
10094
|
+
for (let i = 0; i < path91.length; i++) {
|
|
10095
|
+
const char = path91[i];
|
|
10066
10096
|
if ((char === '"' || char === "'") && bracketCount > 0) {
|
|
10067
10097
|
if (!inQuotes) {
|
|
10068
10098
|
inQuotes = true;
|
|
@@ -10076,20 +10106,20 @@ var require_redact = __commonJS({
|
|
|
10076
10106
|
} else if (char === "]" && !inQuotes) {
|
|
10077
10107
|
bracketCount--;
|
|
10078
10108
|
if (bracketCount < 0) {
|
|
10079
|
-
throw new Error(`Invalid redaction path (${
|
|
10109
|
+
throw new Error(`Invalid redaction path (${path91})`);
|
|
10080
10110
|
}
|
|
10081
10111
|
}
|
|
10082
10112
|
}
|
|
10083
10113
|
if (bracketCount !== 0) {
|
|
10084
|
-
throw new Error(`Invalid redaction path (${
|
|
10114
|
+
throw new Error(`Invalid redaction path (${path91})`);
|
|
10085
10115
|
}
|
|
10086
10116
|
}
|
|
10087
10117
|
function validatePaths(paths) {
|
|
10088
10118
|
if (!Array.isArray(paths)) {
|
|
10089
10119
|
throw new TypeError("paths must be an array");
|
|
10090
10120
|
}
|
|
10091
|
-
for (const
|
|
10092
|
-
validatePath(
|
|
10121
|
+
for (const path91 of paths) {
|
|
10122
|
+
validatePath(path91);
|
|
10093
10123
|
}
|
|
10094
10124
|
}
|
|
10095
10125
|
function slowRedact(options = {}) {
|
|
@@ -10257,8 +10287,8 @@ var require_redaction = __commonJS({
|
|
|
10257
10287
|
if (shape[k2] === null) {
|
|
10258
10288
|
o[k2] = (value) => topCensor(value, [k2]);
|
|
10259
10289
|
} else {
|
|
10260
|
-
const wrappedCensor = typeof censor === "function" ? (value,
|
|
10261
|
-
return censor(value, [k2, ...
|
|
10290
|
+
const wrappedCensor = typeof censor === "function" ? (value, path91) => {
|
|
10291
|
+
return censor(value, [k2, ...path91]);
|
|
10262
10292
|
} : censor;
|
|
10263
10293
|
o[k2] = Redact({
|
|
10264
10294
|
paths: shape[k2],
|
|
@@ -10476,10 +10506,10 @@ var require_atomic_sleep = __commonJS({
|
|
|
10476
10506
|
var require_sonic_boom = __commonJS({
|
|
10477
10507
|
"../node_modules/.pnpm/sonic-boom@4.2.1/node_modules/sonic-boom/index.js"(exports2, module2) {
|
|
10478
10508
|
"use strict";
|
|
10479
|
-
var
|
|
10509
|
+
var fs80 = require("fs");
|
|
10480
10510
|
var EventEmitter3 = require("events");
|
|
10481
10511
|
var inherits = require("util").inherits;
|
|
10482
|
-
var
|
|
10512
|
+
var path91 = require("path");
|
|
10483
10513
|
var sleep2 = require_atomic_sleep();
|
|
10484
10514
|
var assert = require("assert");
|
|
10485
10515
|
var BUSY_WRITE_TIMEOUT = 100;
|
|
@@ -10533,20 +10563,20 @@ var require_sonic_boom = __commonJS({
|
|
|
10533
10563
|
const mode = sonic.mode;
|
|
10534
10564
|
if (sonic.sync) {
|
|
10535
10565
|
try {
|
|
10536
|
-
if (sonic.mkdir)
|
|
10537
|
-
const fd =
|
|
10566
|
+
if (sonic.mkdir) fs80.mkdirSync(path91.dirname(file), { recursive: true });
|
|
10567
|
+
const fd = fs80.openSync(file, flags, mode);
|
|
10538
10568
|
fileOpened(null, fd);
|
|
10539
10569
|
} catch (err) {
|
|
10540
10570
|
fileOpened(err);
|
|
10541
10571
|
throw err;
|
|
10542
10572
|
}
|
|
10543
10573
|
} else if (sonic.mkdir) {
|
|
10544
|
-
|
|
10574
|
+
fs80.mkdir(path91.dirname(file), { recursive: true }, (err) => {
|
|
10545
10575
|
if (err) return fileOpened(err);
|
|
10546
|
-
|
|
10576
|
+
fs80.open(file, flags, mode, fileOpened);
|
|
10547
10577
|
});
|
|
10548
10578
|
} else {
|
|
10549
|
-
|
|
10579
|
+
fs80.open(file, flags, mode, fileOpened);
|
|
10550
10580
|
}
|
|
10551
10581
|
}
|
|
10552
10582
|
function SonicBoom(opts) {
|
|
@@ -10587,8 +10617,8 @@ var require_sonic_boom = __commonJS({
|
|
|
10587
10617
|
this.flush = flushBuffer;
|
|
10588
10618
|
this.flushSync = flushBufferSync;
|
|
10589
10619
|
this._actualWrite = actualWriteBuffer;
|
|
10590
|
-
fsWriteSync = () =>
|
|
10591
|
-
fsWrite = () =>
|
|
10620
|
+
fsWriteSync = () => fs80.writeSync(this.fd, this._writingBuf);
|
|
10621
|
+
fsWrite = () => fs80.write(this.fd, this._writingBuf, this.release);
|
|
10592
10622
|
} else if (contentMode === void 0 || contentMode === kContentModeUtf8) {
|
|
10593
10623
|
this._writingBuf = "";
|
|
10594
10624
|
this.write = write;
|
|
@@ -10597,15 +10627,15 @@ var require_sonic_boom = __commonJS({
|
|
|
10597
10627
|
this._actualWrite = actualWrite;
|
|
10598
10628
|
fsWriteSync = () => {
|
|
10599
10629
|
if (Buffer.isBuffer(this._writingBuf)) {
|
|
10600
|
-
return
|
|
10630
|
+
return fs80.writeSync(this.fd, this._writingBuf);
|
|
10601
10631
|
}
|
|
10602
|
-
return
|
|
10632
|
+
return fs80.writeSync(this.fd, this._writingBuf, "utf8");
|
|
10603
10633
|
};
|
|
10604
10634
|
fsWrite = () => {
|
|
10605
10635
|
if (Buffer.isBuffer(this._writingBuf)) {
|
|
10606
|
-
return
|
|
10636
|
+
return fs80.write(this.fd, this._writingBuf, this.release);
|
|
10607
10637
|
}
|
|
10608
|
-
return
|
|
10638
|
+
return fs80.write(this.fd, this._writingBuf, "utf8", this.release);
|
|
10609
10639
|
};
|
|
10610
10640
|
} else {
|
|
10611
10641
|
throw new Error(`SonicBoom supports "${kContentModeUtf8}" and "${kContentModeBuffer}", but passed ${contentMode}`);
|
|
@@ -10662,7 +10692,7 @@ var require_sonic_boom = __commonJS({
|
|
|
10662
10692
|
}
|
|
10663
10693
|
}
|
|
10664
10694
|
if (this._fsync) {
|
|
10665
|
-
|
|
10695
|
+
fs80.fsyncSync(this.fd);
|
|
10666
10696
|
}
|
|
10667
10697
|
const len = this._len;
|
|
10668
10698
|
if (this._reopening) {
|
|
@@ -10776,7 +10806,7 @@ var require_sonic_boom = __commonJS({
|
|
|
10776
10806
|
const onDrain = () => {
|
|
10777
10807
|
if (!this._fsync) {
|
|
10778
10808
|
try {
|
|
10779
|
-
|
|
10809
|
+
fs80.fsync(this.fd, (err) => {
|
|
10780
10810
|
this._flushPending = false;
|
|
10781
10811
|
cb(err);
|
|
10782
10812
|
});
|
|
@@ -10878,7 +10908,7 @@ var require_sonic_boom = __commonJS({
|
|
|
10878
10908
|
const fd = this.fd;
|
|
10879
10909
|
this.once("ready", () => {
|
|
10880
10910
|
if (fd !== this.fd) {
|
|
10881
|
-
|
|
10911
|
+
fs80.close(fd, (err) => {
|
|
10882
10912
|
if (err) {
|
|
10883
10913
|
return this.emit("error", err);
|
|
10884
10914
|
}
|
|
@@ -10927,7 +10957,7 @@ var require_sonic_boom = __commonJS({
|
|
|
10927
10957
|
buf = this._bufs[0];
|
|
10928
10958
|
}
|
|
10929
10959
|
try {
|
|
10930
|
-
const n = Buffer.isBuffer(buf) ?
|
|
10960
|
+
const n = Buffer.isBuffer(buf) ? fs80.writeSync(this.fd, buf) : fs80.writeSync(this.fd, buf, "utf8");
|
|
10931
10961
|
const releasedBufObj = releaseWritingBuf(buf, this._len, n);
|
|
10932
10962
|
buf = releasedBufObj.writingBuf;
|
|
10933
10963
|
this._len = releasedBufObj.len;
|
|
@@ -10943,7 +10973,7 @@ var require_sonic_boom = __commonJS({
|
|
|
10943
10973
|
}
|
|
10944
10974
|
}
|
|
10945
10975
|
try {
|
|
10946
|
-
|
|
10976
|
+
fs80.fsyncSync(this.fd);
|
|
10947
10977
|
} catch {
|
|
10948
10978
|
}
|
|
10949
10979
|
}
|
|
@@ -10964,7 +10994,7 @@ var require_sonic_boom = __commonJS({
|
|
|
10964
10994
|
buf = mergeBuf(this._bufs[0], this._lens[0]);
|
|
10965
10995
|
}
|
|
10966
10996
|
try {
|
|
10967
|
-
const n =
|
|
10997
|
+
const n = fs80.writeSync(this.fd, buf);
|
|
10968
10998
|
buf = buf.subarray(n);
|
|
10969
10999
|
this._len = Math.max(this._len - n, 0);
|
|
10970
11000
|
if (buf.length <= 0) {
|
|
@@ -10992,13 +11022,13 @@ var require_sonic_boom = __commonJS({
|
|
|
10992
11022
|
this._writingBuf = this._writingBuf.length ? this._writingBuf : this._bufs.shift() || "";
|
|
10993
11023
|
if (this.sync) {
|
|
10994
11024
|
try {
|
|
10995
|
-
const written = Buffer.isBuffer(this._writingBuf) ?
|
|
11025
|
+
const written = Buffer.isBuffer(this._writingBuf) ? fs80.writeSync(this.fd, this._writingBuf) : fs80.writeSync(this.fd, this._writingBuf, "utf8");
|
|
10996
11026
|
release(null, written);
|
|
10997
11027
|
} catch (err) {
|
|
10998
11028
|
release(err);
|
|
10999
11029
|
}
|
|
11000
11030
|
} else {
|
|
11001
|
-
|
|
11031
|
+
fs80.write(this.fd, this._writingBuf, release);
|
|
11002
11032
|
}
|
|
11003
11033
|
}
|
|
11004
11034
|
function actualWriteBuffer() {
|
|
@@ -11007,7 +11037,7 @@ var require_sonic_boom = __commonJS({
|
|
|
11007
11037
|
this._writingBuf = this._writingBuf.length ? this._writingBuf : mergeBuf(this._bufs.shift(), this._lens.shift());
|
|
11008
11038
|
if (this.sync) {
|
|
11009
11039
|
try {
|
|
11010
|
-
const written =
|
|
11040
|
+
const written = fs80.writeSync(this.fd, this._writingBuf);
|
|
11011
11041
|
release(null, written);
|
|
11012
11042
|
} catch (err) {
|
|
11013
11043
|
release(err);
|
|
@@ -11016,7 +11046,7 @@ var require_sonic_boom = __commonJS({
|
|
|
11016
11046
|
if (kCopyBuffer) {
|
|
11017
11047
|
this._writingBuf = Buffer.from(this._writingBuf);
|
|
11018
11048
|
}
|
|
11019
|
-
|
|
11049
|
+
fs80.write(this.fd, this._writingBuf, release);
|
|
11020
11050
|
}
|
|
11021
11051
|
}
|
|
11022
11052
|
function actualClose(sonic) {
|
|
@@ -11032,12 +11062,12 @@ var require_sonic_boom = __commonJS({
|
|
|
11032
11062
|
sonic._lens = [];
|
|
11033
11063
|
assert(typeof sonic.fd === "number", `sonic.fd must be a number, got ${typeof sonic.fd}`);
|
|
11034
11064
|
try {
|
|
11035
|
-
|
|
11065
|
+
fs80.fsync(sonic.fd, closeWrapped);
|
|
11036
11066
|
} catch {
|
|
11037
11067
|
}
|
|
11038
11068
|
function closeWrapped() {
|
|
11039
11069
|
if (sonic.fd !== 1 && sonic.fd !== 2) {
|
|
11040
|
-
|
|
11070
|
+
fs80.close(sonic.fd, done);
|
|
11041
11071
|
} else {
|
|
11042
11072
|
done();
|
|
11043
11073
|
}
|
|
@@ -13401,7 +13431,7 @@ var require_multistream = __commonJS({
|
|
|
13401
13431
|
var require_pino = __commonJS({
|
|
13402
13432
|
"../node_modules/.pnpm/pino@9.14.0/node_modules/pino/pino.js"(exports2, module2) {
|
|
13403
13433
|
"use strict";
|
|
13404
|
-
var
|
|
13434
|
+
var os31 = require("os");
|
|
13405
13435
|
var stdSerializers = require_pino_std_serializers();
|
|
13406
13436
|
var caller = require_caller();
|
|
13407
13437
|
var redaction = require_redaction();
|
|
@@ -13448,7 +13478,7 @@ var require_pino = __commonJS({
|
|
|
13448
13478
|
} = symbols;
|
|
13449
13479
|
var { epochTime, nullTime } = time;
|
|
13450
13480
|
var { pid } = process;
|
|
13451
|
-
var hostname =
|
|
13481
|
+
var hostname = os31.hostname();
|
|
13452
13482
|
var defaultErrorSerializer = stdSerializers.err;
|
|
13453
13483
|
var defaultOptions2 = {
|
|
13454
13484
|
level: "info",
|
|
@@ -14172,11 +14202,11 @@ var init_lib = __esm({
|
|
|
14172
14202
|
}
|
|
14173
14203
|
}
|
|
14174
14204
|
},
|
|
14175
|
-
addToPath: function addToPath(
|
|
14176
|
-
var last =
|
|
14205
|
+
addToPath: function addToPath(path91, added, removed, oldPosInc, options) {
|
|
14206
|
+
var last = path91.lastComponent;
|
|
14177
14207
|
if (last && !options.oneChangePerToken && last.added === added && last.removed === removed) {
|
|
14178
14208
|
return {
|
|
14179
|
-
oldPos:
|
|
14209
|
+
oldPos: path91.oldPos + oldPosInc,
|
|
14180
14210
|
lastComponent: {
|
|
14181
14211
|
count: last.count + 1,
|
|
14182
14212
|
added,
|
|
@@ -14186,7 +14216,7 @@ var init_lib = __esm({
|
|
|
14186
14216
|
};
|
|
14187
14217
|
} else {
|
|
14188
14218
|
return {
|
|
14189
|
-
oldPos:
|
|
14219
|
+
oldPos: path91.oldPos + oldPosInc,
|
|
14190
14220
|
lastComponent: {
|
|
14191
14221
|
count: 1,
|
|
14192
14222
|
added,
|
|
@@ -14768,10 +14798,10 @@ function attachmentToHistoryMessage(o, ts) {
|
|
|
14768
14798
|
const memories = raw.map((m2) => {
|
|
14769
14799
|
if (!m2 || typeof m2 !== "object") return null;
|
|
14770
14800
|
const rec4 = m2;
|
|
14771
|
-
const
|
|
14801
|
+
const path91 = typeof rec4.path === "string" ? rec4.path : null;
|
|
14772
14802
|
const content = typeof rec4.content === "string" ? rec4.content : null;
|
|
14773
|
-
if (!
|
|
14774
|
-
const entry = { path:
|
|
14803
|
+
if (!path91 || content == null) return null;
|
|
14804
|
+
const entry = { path: path91, content };
|
|
14775
14805
|
if (typeof rec4.mtimeMs === "number") entry.mtimeMs = rec4.mtimeMs;
|
|
14776
14806
|
return entry;
|
|
14777
14807
|
}).filter((m2) => m2 !== null);
|
|
@@ -15637,10 +15667,10 @@ function parseAttachment(obj) {
|
|
|
15637
15667
|
const memories = raw.map((m2) => {
|
|
15638
15668
|
if (!m2 || typeof m2 !== "object") return null;
|
|
15639
15669
|
const rec4 = m2;
|
|
15640
|
-
const
|
|
15670
|
+
const path91 = typeof rec4.path === "string" ? rec4.path : null;
|
|
15641
15671
|
const content = typeof rec4.content === "string" ? rec4.content : null;
|
|
15642
|
-
if (!
|
|
15643
|
-
const out = { path:
|
|
15672
|
+
if (!path91 || content == null) return null;
|
|
15673
|
+
const out = { path: path91, content };
|
|
15644
15674
|
if (typeof rec4.mtimeMs === "number") out.mtimeMs = rec4.mtimeMs;
|
|
15645
15675
|
return out;
|
|
15646
15676
|
}).filter((m2) => m2 !== null);
|
|
@@ -36614,8 +36644,8 @@ var require_utils = __commonJS({
|
|
|
36614
36644
|
var result = transform[inputType][outputType](input);
|
|
36615
36645
|
return result;
|
|
36616
36646
|
};
|
|
36617
|
-
exports2.resolve = function(
|
|
36618
|
-
var parts =
|
|
36647
|
+
exports2.resolve = function(path91) {
|
|
36648
|
+
var parts = path91.split("/");
|
|
36619
36649
|
var result = [];
|
|
36620
36650
|
for (var index = 0; index < parts.length; index++) {
|
|
36621
36651
|
var part = parts[index];
|
|
@@ -42468,18 +42498,18 @@ var require_object = __commonJS({
|
|
|
42468
42498
|
var object = new ZipObject(name, zipObjectContent, o);
|
|
42469
42499
|
this.files[name] = object;
|
|
42470
42500
|
};
|
|
42471
|
-
var parentFolder = function(
|
|
42472
|
-
if (
|
|
42473
|
-
|
|
42501
|
+
var parentFolder = function(path91) {
|
|
42502
|
+
if (path91.slice(-1) === "/") {
|
|
42503
|
+
path91 = path91.substring(0, path91.length - 1);
|
|
42474
42504
|
}
|
|
42475
|
-
var lastSlash =
|
|
42476
|
-
return lastSlash > 0 ?
|
|
42505
|
+
var lastSlash = path91.lastIndexOf("/");
|
|
42506
|
+
return lastSlash > 0 ? path91.substring(0, lastSlash) : "";
|
|
42477
42507
|
};
|
|
42478
|
-
var forceTrailingSlash = function(
|
|
42479
|
-
if (
|
|
42480
|
-
|
|
42508
|
+
var forceTrailingSlash = function(path91) {
|
|
42509
|
+
if (path91.slice(-1) !== "/") {
|
|
42510
|
+
path91 += "/";
|
|
42481
42511
|
}
|
|
42482
|
-
return
|
|
42512
|
+
return path91;
|
|
42483
42513
|
};
|
|
42484
42514
|
var folderAdd = function(name, createFolders) {
|
|
42485
42515
|
createFolders = typeof createFolders !== "undefined" ? createFolders : defaults.createFolders;
|
|
@@ -43481,7 +43511,7 @@ var require_lib3 = __commonJS({
|
|
|
43481
43511
|
// src/run-case/recorder.ts
|
|
43482
43512
|
function startRunCaseRecorder(opts) {
|
|
43483
43513
|
const now = opts.now ?? Date.now;
|
|
43484
|
-
const dir =
|
|
43514
|
+
const dir = import_node_path73.default.dirname(opts.recordPath);
|
|
43485
43515
|
let stream = null;
|
|
43486
43516
|
let closing = false;
|
|
43487
43517
|
let closedSettled = false;
|
|
@@ -43495,8 +43525,8 @@ function startRunCaseRecorder(opts) {
|
|
|
43495
43525
|
});
|
|
43496
43526
|
const ensureStream = () => {
|
|
43497
43527
|
if (stream) return stream;
|
|
43498
|
-
|
|
43499
|
-
stream =
|
|
43528
|
+
import_node_fs54.default.mkdirSync(dir, { recursive: true });
|
|
43529
|
+
stream = import_node_fs54.default.createWriteStream(opts.recordPath, { flags: "a" });
|
|
43500
43530
|
stream.on("close", () => closedResolve());
|
|
43501
43531
|
return stream;
|
|
43502
43532
|
};
|
|
@@ -43521,12 +43551,12 @@ function startRunCaseRecorder(opts) {
|
|
|
43521
43551
|
};
|
|
43522
43552
|
return { tap, close, closed };
|
|
43523
43553
|
}
|
|
43524
|
-
var
|
|
43554
|
+
var import_node_fs54, import_node_path73;
|
|
43525
43555
|
var init_recorder = __esm({
|
|
43526
43556
|
"src/run-case/recorder.ts"() {
|
|
43527
43557
|
"use strict";
|
|
43528
|
-
|
|
43529
|
-
|
|
43558
|
+
import_node_fs54 = __toESM(require("fs"), 1);
|
|
43559
|
+
import_node_path73 = __toESM(require("path"), 1);
|
|
43530
43560
|
}
|
|
43531
43561
|
});
|
|
43532
43562
|
|
|
@@ -43569,7 +43599,7 @@ var init_wire = __esm({
|
|
|
43569
43599
|
// src/run-case/controller.ts
|
|
43570
43600
|
async function runController(opts) {
|
|
43571
43601
|
const now = opts.now ?? Date.now;
|
|
43572
|
-
const cwd = opts.cwd ?? (0,
|
|
43602
|
+
const cwd = opts.cwd ?? (0, import_node_fs55.mkdtempSync)(import_node_path74.default.join(import_node_os27.default.tmpdir(), "clawd-runcase-"));
|
|
43573
43603
|
const ownsCwd = opts.cwd === void 0;
|
|
43574
43604
|
const recorder = startRunCaseRecorder({ recordPath: opts.record, now });
|
|
43575
43605
|
const spawnCtx = { cwd };
|
|
@@ -43730,19 +43760,19 @@ async function runController(opts) {
|
|
|
43730
43760
|
if (sigintHandler) process.off("SIGINT", sigintHandler);
|
|
43731
43761
|
if (ownsCwd) {
|
|
43732
43762
|
try {
|
|
43733
|
-
(0,
|
|
43763
|
+
(0, import_node_fs55.rmSync)(cwd, { recursive: true, force: true });
|
|
43734
43764
|
} catch {
|
|
43735
43765
|
}
|
|
43736
43766
|
}
|
|
43737
43767
|
return exitCode ?? 0;
|
|
43738
43768
|
}
|
|
43739
|
-
var
|
|
43769
|
+
var import_node_fs55, import_node_os27, import_node_path74;
|
|
43740
43770
|
var init_controller = __esm({
|
|
43741
43771
|
"src/run-case/controller.ts"() {
|
|
43742
43772
|
"use strict";
|
|
43743
|
-
|
|
43744
|
-
|
|
43745
|
-
|
|
43773
|
+
import_node_fs55 = require("fs");
|
|
43774
|
+
import_node_os27 = __toESM(require("os"), 1);
|
|
43775
|
+
import_node_path74 = __toESM(require("path"), 1);
|
|
43746
43776
|
init_claude();
|
|
43747
43777
|
init_stdout_splitter();
|
|
43748
43778
|
init_permission_stdio();
|
|
@@ -44017,9 +44047,9 @@ Env (advanced):
|
|
|
44017
44047
|
`;
|
|
44018
44048
|
|
|
44019
44049
|
// src/index.ts
|
|
44020
|
-
var
|
|
44021
|
-
var
|
|
44022
|
-
var
|
|
44050
|
+
var import_node_path72 = __toESM(require("path"), 1);
|
|
44051
|
+
var import_node_fs53 = __toESM(require("fs"), 1);
|
|
44052
|
+
var import_node_os26 = __toESM(require("os"), 1);
|
|
44023
44053
|
var import_node_crypto22 = require("crypto");
|
|
44024
44054
|
var import_node_url4 = require("url");
|
|
44025
44055
|
|
|
@@ -47059,7 +47089,7 @@ var SessionManager = class {
|
|
|
47059
47089
|
subSessionMeta.codexSandbox = {
|
|
47060
47090
|
writableRoots: [subSessionMeta.userWorkDir, ...(codexCfg?.writableRoots ?? []).map(expand)],
|
|
47061
47091
|
denyRead: codexCfg?.denyRead ?? [],
|
|
47062
|
-
network: codexCfg?.network ??
|
|
47092
|
+
network: codexCfg?.network ?? true
|
|
47063
47093
|
};
|
|
47064
47094
|
}
|
|
47065
47095
|
if (subSessionMeta?.personaMode === "owner" && file.projectPath) {
|
|
@@ -49797,6 +49827,24 @@ var PersonaManager = class {
|
|
|
49797
49827
|
return this.deps.store.readEnabledPlugins(personaId2);
|
|
49798
49828
|
}
|
|
49799
49829
|
/** 读 sandbox-settings.json;不存在 / 损坏返回 null。供 persona:get handler 拼响应。 */
|
|
49830
|
+
/** 读 codex guest 沙箱配置(`.clawd/codex-sandbox.json`);缺失 / 坏 → null。透传给 handler 拼响应。 */
|
|
49831
|
+
readCodexSandboxSettings(personaId2) {
|
|
49832
|
+
return this.deps.store.readCodexSandboxSettings(personaId2);
|
|
49833
|
+
}
|
|
49834
|
+
/**
|
|
49835
|
+
* 局部合并写 codex guest 沙箱配置,返回合并后的全量。
|
|
49836
|
+
*
|
|
49837
|
+
* **必须是合并不是覆盖**:UI 的「访客联网」开关只发 `{network}`,整体覆盖会静默抹掉 owner
|
|
49838
|
+
* 手配的 writableRoots / denyRead(丢的是安全边界,且用户不会立刻发现)。
|
|
49839
|
+
* 不走 PersonaManager.update 是因为它管的是 PersonaFile meta + 人格两层文本,
|
|
49840
|
+
* 而这份配置是另一个文件、另一套 schema。
|
|
49841
|
+
*/
|
|
49842
|
+
mergeCodexSandbox(personaId2, patch) {
|
|
49843
|
+
if (!this.deps.registry.get(personaId2)) throw new Error(`persona not found: ${personaId2}`);
|
|
49844
|
+
const merged = { ...this.deps.store.readCodexSandboxSettings(personaId2) ?? {}, ...patch };
|
|
49845
|
+
this.deps.store.writeCodexSandboxSettings(personaId2, merged);
|
|
49846
|
+
return merged;
|
|
49847
|
+
}
|
|
49800
49848
|
readSandboxSettings(personaId2) {
|
|
49801
49849
|
return this.deps.store.readSandboxSettings(personaId2);
|
|
49802
49850
|
}
|
|
@@ -50198,13 +50246,15 @@ function migrateAgentsMirror(args) {
|
|
|
50198
50246
|
}
|
|
50199
50247
|
if (mirrored > 0) args.logger.info("persona.agents-mirror.done", { mirrored });
|
|
50200
50248
|
}
|
|
50249
|
+
var PKG_CACHE_ROOTS = ["~/Library/pnpm", "~/.local/share/pnpm", "~/.local/state/pnpm", "~/.npm", "~/.pnpm-store"];
|
|
50250
|
+
var CODEX_SANDBOX_DEFAULT = { writableRoots: [...PKG_CACHE_ROOTS], denyRead: [], network: true };
|
|
50201
50251
|
function migrateCodexSandbox(args) {
|
|
50202
50252
|
const entries = args.entries ?? DEFAULT_PERSONAS;
|
|
50203
50253
|
let n = 0;
|
|
50204
50254
|
for (const personaId2 of args.store.list()) {
|
|
50205
50255
|
if (args.store.readCodexSandboxSettings(personaId2)) continue;
|
|
50206
50256
|
try {
|
|
50207
|
-
const def = entries.find((e) => e.personaId === personaId2)?.codexSandbox ??
|
|
50257
|
+
const def = entries.find((e) => e.personaId === personaId2)?.codexSandbox ?? CODEX_SANDBOX_DEFAULT;
|
|
50208
50258
|
args.store.writeCodexSandboxSettings(personaId2, def);
|
|
50209
50259
|
n++;
|
|
50210
50260
|
args.logger.info("persona.codex-sandbox.synced", { personaId: personaId2 });
|
|
@@ -51124,8 +51174,8 @@ function turnStartInput(text) {
|
|
|
51124
51174
|
const items = [];
|
|
51125
51175
|
let leftover = text;
|
|
51126
51176
|
for (const m2 of text.matchAll(SKILL_RE)) {
|
|
51127
|
-
const [marker, name,
|
|
51128
|
-
items.push({ type: "skill", name, path:
|
|
51177
|
+
const [marker, name, path91] = m2;
|
|
51178
|
+
items.push({ type: "skill", name, path: path91 });
|
|
51129
51179
|
leftover = leftover.replace(marker, "");
|
|
51130
51180
|
}
|
|
51131
51181
|
for (const m2 of text.matchAll(ATTACHMENT_RE2)) {
|
|
@@ -55812,13 +55862,13 @@ function mapSkillsListResponse(res) {
|
|
|
55812
55862
|
const r = s ?? {};
|
|
55813
55863
|
const name = str3(r.name);
|
|
55814
55864
|
if (!name) continue;
|
|
55815
|
-
const
|
|
55865
|
+
const path91 = str3(r.path);
|
|
55816
55866
|
const description = str3(r.description);
|
|
55817
55867
|
const isPlugin = name.includes(":");
|
|
55818
55868
|
out.push({
|
|
55819
55869
|
name,
|
|
55820
55870
|
source: isPlugin ? "plugin" : "project",
|
|
55821
|
-
...
|
|
55871
|
+
...path91 ? { path: path91 } : {},
|
|
55822
55872
|
...description ? { description } : {},
|
|
55823
55873
|
...isPlugin ? { plugin: name.split(":")[0] } : {}
|
|
55824
55874
|
});
|
|
@@ -60140,9 +60190,9 @@ var CentralClientError = class extends Error {
|
|
|
60140
60190
|
code;
|
|
60141
60191
|
cause;
|
|
60142
60192
|
};
|
|
60143
|
-
async function centralRequest(opts,
|
|
60193
|
+
async function centralRequest(opts, path91, init) {
|
|
60144
60194
|
const f = opts.fetchImpl ?? globalThis.fetch;
|
|
60145
|
-
const url = `${opts.api.replace(/\/+$/, "")}${
|
|
60195
|
+
const url = `${opts.api.replace(/\/+$/, "")}${path91}`;
|
|
60146
60196
|
const ctrl = new AbortController();
|
|
60147
60197
|
const timer = setTimeout(() => ctrl.abort(), opts.timeoutMs ?? 15e3);
|
|
60148
60198
|
let res;
|
|
@@ -60623,7 +60673,7 @@ var ServerKeyStore = class {
|
|
|
60623
60673
|
init_protocol();
|
|
60624
60674
|
|
|
60625
60675
|
// src/handlers/index.ts
|
|
60626
|
-
var
|
|
60676
|
+
var import_node_path68 = __toESM(require("path"), 1);
|
|
60627
60677
|
|
|
60628
60678
|
// src/handlers/session.ts
|
|
60629
60679
|
init_protocol();
|
|
@@ -60966,8 +61016,133 @@ function appendImportLedger(dataDir, entry) {
|
|
|
60966
61016
|
import_node_fs47.default.writeFileSync(file, JSON.stringify(entries, null, 2), { encoding: "utf8", mode: 384 });
|
|
60967
61017
|
}
|
|
60968
61018
|
|
|
61019
|
+
// src/tools/transcript-search.ts
|
|
61020
|
+
var import_node_fs48 = __toESM(require("fs"), 1);
|
|
61021
|
+
var import_node_path54 = __toESM(require("path"), 1);
|
|
61022
|
+
var SNIPPET_PAD = 60;
|
|
61023
|
+
var INJECTED_ENVELOPE_RE = /^<(system-reminder|command-name|command-message|command-args|local-command-stdout|local-command-stderr|task-notification|user-prompt-submit-hook|environment_context|user_instructions)\b/;
|
|
61024
|
+
var CODEX_WRAPPER_RE = /<(related-dir|environment_context|user_instructions)>[\s\S]*?<\/\1>/g;
|
|
61025
|
+
function asRecord(v2) {
|
|
61026
|
+
return typeof v2 === "object" && v2 !== null ? v2 : null;
|
|
61027
|
+
}
|
|
61028
|
+
function textOfBlocks(content, types) {
|
|
61029
|
+
if (!Array.isArray(content)) return null;
|
|
61030
|
+
const parts = [];
|
|
61031
|
+
for (const block of content) {
|
|
61032
|
+
const b2 = asRecord(block);
|
|
61033
|
+
if (!b2 || typeof b2.type !== "string" || !types.includes(b2.type)) continue;
|
|
61034
|
+
const text = b2.text;
|
|
61035
|
+
if (typeof text === "string" && text !== "") parts.push(text);
|
|
61036
|
+
}
|
|
61037
|
+
return parts.length > 0 ? parts.join("\n") : null;
|
|
61038
|
+
}
|
|
61039
|
+
function lineToSearchableText(raw) {
|
|
61040
|
+
const line = asRecord(raw);
|
|
61041
|
+
if (!line) return null;
|
|
61042
|
+
if (line.type === "response_item") {
|
|
61043
|
+
const payload = asRecord(line.payload);
|
|
61044
|
+
if (!payload || payload.type !== "message") return null;
|
|
61045
|
+
const role = payload.role;
|
|
61046
|
+
if (role !== "user" && role !== "assistant") return null;
|
|
61047
|
+
const text2 = textOfBlocks(payload.content, ["input_text", "output_text"]);
|
|
61048
|
+
if (text2 === null) return null;
|
|
61049
|
+
if (role !== "user") return text2;
|
|
61050
|
+
const stripped = text2.replace(CODEX_WRAPPER_RE, "").trim();
|
|
61051
|
+
if (stripped === "") return null;
|
|
61052
|
+
return INJECTED_ENVELOPE_RE.test(stripped) ? null : stripped;
|
|
61053
|
+
}
|
|
61054
|
+
if (line.type !== "user" && line.type !== "assistant") return null;
|
|
61055
|
+
const message = asRecord(line.message);
|
|
61056
|
+
if (!message) return null;
|
|
61057
|
+
const content = message.content;
|
|
61058
|
+
const text = typeof content === "string" && content !== "" ? content : textOfBlocks(content, ["text"]);
|
|
61059
|
+
if (text === null) return null;
|
|
61060
|
+
if (line.type === "user" && (line.isMeta === true || line.isSynthetic === true)) return null;
|
|
61061
|
+
if (line.type === "user" && INJECTED_ENVELOPE_RE.test(text.trimStart())) return null;
|
|
61062
|
+
return text;
|
|
61063
|
+
}
|
|
61064
|
+
function escapeRegExp(s) {
|
|
61065
|
+
return s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
61066
|
+
}
|
|
61067
|
+
function makeSnippet(text, at, needleLength) {
|
|
61068
|
+
const from = Math.max(0, at - SNIPPET_PAD);
|
|
61069
|
+
const to = Math.min(text.length, at + needleLength + SNIPPET_PAD);
|
|
61070
|
+
const body = text.slice(from, to).replace(/\s+/g, " ").trim();
|
|
61071
|
+
return `${from > 0 ? "\u2026 " : ""}${body}${to < text.length ? " \u2026" : ""}`;
|
|
61072
|
+
}
|
|
61073
|
+
function searchTranscriptFile(file, query) {
|
|
61074
|
+
let buf;
|
|
61075
|
+
try {
|
|
61076
|
+
buf = import_node_fs48.default.readFileSync(file);
|
|
61077
|
+
} catch {
|
|
61078
|
+
return null;
|
|
61079
|
+
}
|
|
61080
|
+
const haystack = buf.toString("latin1");
|
|
61081
|
+
const needle = Buffer.from(query, "utf8").toString("latin1");
|
|
61082
|
+
const re = new RegExp(escapeRegExp(needle), "gi");
|
|
61083
|
+
let m2;
|
|
61084
|
+
while ((m2 = re.exec(haystack)) !== null) {
|
|
61085
|
+
const lineStart = haystack.lastIndexOf("\n", m2.index) + 1;
|
|
61086
|
+
let lineEnd = haystack.indexOf("\n", m2.index);
|
|
61087
|
+
if (lineEnd < 0) lineEnd = haystack.length;
|
|
61088
|
+
re.lastIndex = lineEnd + 1;
|
|
61089
|
+
let parsed;
|
|
61090
|
+
try {
|
|
61091
|
+
parsed = JSON.parse(Buffer.from(haystack.slice(lineStart, lineEnd), "latin1").toString("utf8"));
|
|
61092
|
+
} catch {
|
|
61093
|
+
continue;
|
|
61094
|
+
}
|
|
61095
|
+
const text = lineToSearchableText(parsed);
|
|
61096
|
+
if (text === null) continue;
|
|
61097
|
+
const at = text.toLowerCase().indexOf(query.toLowerCase());
|
|
61098
|
+
if (at < 0) continue;
|
|
61099
|
+
return makeSnippet(text, at, query.length);
|
|
61100
|
+
}
|
|
61101
|
+
return null;
|
|
61102
|
+
}
|
|
61103
|
+
var ROLLOUT_NAME_RE = /-([0-9a-fA-F-]{36})\.jsonl$/;
|
|
61104
|
+
function createCodexRolloutLocator(roots) {
|
|
61105
|
+
let index = null;
|
|
61106
|
+
const walk2 = (dir, into) => {
|
|
61107
|
+
let entries;
|
|
61108
|
+
try {
|
|
61109
|
+
entries = import_node_fs48.default.readdirSync(dir, { withFileTypes: true });
|
|
61110
|
+
} catch {
|
|
61111
|
+
return;
|
|
61112
|
+
}
|
|
61113
|
+
for (const entry of entries) {
|
|
61114
|
+
const full = import_node_path54.default.join(dir, entry.name);
|
|
61115
|
+
if (entry.isDirectory()) {
|
|
61116
|
+
walk2(full, into);
|
|
61117
|
+
continue;
|
|
61118
|
+
}
|
|
61119
|
+
const matched = ROLLOUT_NAME_RE.exec(entry.name);
|
|
61120
|
+
if (matched) into.set(matched[1].toLowerCase(), full);
|
|
61121
|
+
}
|
|
61122
|
+
};
|
|
61123
|
+
return (toolSessionId) => {
|
|
61124
|
+
if (index === null) {
|
|
61125
|
+
index = /* @__PURE__ */ new Map();
|
|
61126
|
+
for (const root of roots) walk2(root, index);
|
|
61127
|
+
}
|
|
61128
|
+
return index.get(toolSessionId.toLowerCase()) ?? null;
|
|
61129
|
+
};
|
|
61130
|
+
}
|
|
61131
|
+
|
|
60969
61132
|
// src/handlers/session.ts
|
|
60970
61133
|
init_protocol();
|
|
61134
|
+
var import_node_os19 = __toESM(require("os"), 1);
|
|
61135
|
+
var import_node_path55 = __toESM(require("path"), 1);
|
|
61136
|
+
function canReadSearchHit(ctx, file) {
|
|
61137
|
+
if (!ctx || ctx.principal.kind === "owner") return true;
|
|
61138
|
+
return canAccessPersona(ctx.grants, file.ownerPersonaId, "read") && file.creatorPrincipalId === ctx.principal.id;
|
|
61139
|
+
}
|
|
61140
|
+
var DEFAULT_SEARCH_LIMIT = 9;
|
|
61141
|
+
function codexRolloutRoots(dataDir) {
|
|
61142
|
+
const roots = [import_node_path55.default.join(import_node_os19.default.homedir(), ".codex", "sessions")];
|
|
61143
|
+
if (dataDir) roots.push(import_node_path55.default.join(dataDir, "codex-home", "sessions"));
|
|
61144
|
+
return roots;
|
|
61145
|
+
}
|
|
60971
61146
|
function buildSessionHandlers(deps) {
|
|
60972
61147
|
const { manager, observer, getAdapter: getAdapter2, store, ownerPrincipalId } = deps;
|
|
60973
61148
|
const ensureSessionAccess = (ctx, sessionId, action) => {
|
|
@@ -61343,6 +61518,23 @@ ${attribution}` } : args;
|
|
|
61343
61518
|
const { response, broadcast } = manager.markRead(args);
|
|
61344
61519
|
return { response: { type: "session:info", ...response }, broadcast };
|
|
61345
61520
|
};
|
|
61521
|
+
const searchContent = async (frame, _client, ctx) => {
|
|
61522
|
+
const args = SessionSearchContentArgs.parse(frame);
|
|
61523
|
+
const limit = args.limit ?? DEFAULT_SEARCH_LIMIT;
|
|
61524
|
+
const locateCodexRollout = createCodexRolloutLocator(codexRolloutRoots(deps.dataDir));
|
|
61525
|
+
const matches = [];
|
|
61526
|
+
for (const sessionId of args.sessionIds) {
|
|
61527
|
+
if (matches.length >= limit) break;
|
|
61528
|
+
const file = manager.findOwnedSession(sessionId);
|
|
61529
|
+
if (!file?.toolSessionId) continue;
|
|
61530
|
+
if (!canReadSearchHit(ctx, file)) continue;
|
|
61531
|
+
const transcript = file.tool === "codex" ? locateCodexRollout(file.toolSessionId) : deps.history?.resolveTranscriptFile(file.cwd, file.toolSessionId) ?? null;
|
|
61532
|
+
if (!transcript) continue;
|
|
61533
|
+
const snippet = searchTranscriptFile(transcript, args.query);
|
|
61534
|
+
if (snippet !== null) matches.push({ sessionId, snippet });
|
|
61535
|
+
}
|
|
61536
|
+
return { response: { type: "session:searchContent", matches } };
|
|
61537
|
+
};
|
|
61346
61538
|
const reorderPins = async (frame) => {
|
|
61347
61539
|
const args = SessionReorderPinsArgs.parse(frame);
|
|
61348
61540
|
const { response, broadcast } = manager.reorderPins(args);
|
|
@@ -61463,6 +61655,7 @@ ${attribution}` } : args;
|
|
|
61463
61655
|
"session:pin": pin,
|
|
61464
61656
|
"session:archive": archive,
|
|
61465
61657
|
"session:markRead": markRead,
|
|
61658
|
+
"session:searchContent": searchContent,
|
|
61466
61659
|
"session:reorderPins": reorderPins,
|
|
61467
61660
|
"session:answerQuestion": answerQuestion,
|
|
61468
61661
|
"session:cancelQuestion": cancelQuestion,
|
|
@@ -61489,7 +61682,7 @@ function buildPermissionHandlers(deps) {
|
|
|
61489
61682
|
}
|
|
61490
61683
|
|
|
61491
61684
|
// src/handlers/history.ts
|
|
61492
|
-
var
|
|
61685
|
+
var path70 = __toESM(require("path"), 1);
|
|
61493
61686
|
init_protocol();
|
|
61494
61687
|
|
|
61495
61688
|
// src/session/recent-dirs.ts
|
|
@@ -61507,7 +61700,7 @@ function listRecentDirs(store, limit = 50) {
|
|
|
61507
61700
|
}
|
|
61508
61701
|
|
|
61509
61702
|
// src/permission/persona-paths.ts
|
|
61510
|
-
var
|
|
61703
|
+
var path69 = __toESM(require("path"), 1);
|
|
61511
61704
|
function getAllowedPersonaIds(grants, action) {
|
|
61512
61705
|
const ids = /* @__PURE__ */ new Set();
|
|
61513
61706
|
for (const g2 of grants) {
|
|
@@ -61520,42 +61713,42 @@ function getAllowedPersonaIds(grants, action) {
|
|
|
61520
61713
|
return ids;
|
|
61521
61714
|
}
|
|
61522
61715
|
function isGuestPathAllowed(grants, absPath, personaRoot, action = "read", userWorkDir) {
|
|
61523
|
-
const target =
|
|
61716
|
+
const target = path69.resolve(absPath);
|
|
61524
61717
|
if (userWorkDir) {
|
|
61525
|
-
const u =
|
|
61526
|
-
const usep = u.endsWith(
|
|
61718
|
+
const u = path69.resolve(userWorkDir);
|
|
61719
|
+
const usep = u.endsWith(path69.sep) ? "" : path69.sep;
|
|
61527
61720
|
if (target === u || target.startsWith(u + usep)) return true;
|
|
61528
61721
|
}
|
|
61529
|
-
const root =
|
|
61530
|
-
const sep4 = root.endsWith(
|
|
61722
|
+
const root = path69.resolve(personaRoot);
|
|
61723
|
+
const sep4 = root.endsWith(path69.sep) ? "" : path69.sep;
|
|
61531
61724
|
if (!target.startsWith(root + sep4)) return false;
|
|
61532
|
-
const rel =
|
|
61725
|
+
const rel = path69.relative(root, target);
|
|
61533
61726
|
if (!rel || rel.startsWith("..")) return false;
|
|
61534
|
-
const personaId2 = rel.split(
|
|
61727
|
+
const personaId2 = rel.split(path69.sep)[0];
|
|
61535
61728
|
if (!personaId2) return false;
|
|
61536
61729
|
const allowed = getAllowedPersonaIds(grants, action);
|
|
61537
61730
|
if (allowed === "*") return true;
|
|
61538
61731
|
return allowed.has(personaId2);
|
|
61539
61732
|
}
|
|
61540
61733
|
function personaIdFromPath(absPath, personaRoot) {
|
|
61541
|
-
const root =
|
|
61542
|
-
const target =
|
|
61543
|
-
const sep4 = root.endsWith(
|
|
61734
|
+
const root = path69.resolve(personaRoot);
|
|
61735
|
+
const target = path69.resolve(absPath);
|
|
61736
|
+
const sep4 = root.endsWith(path69.sep) ? "" : path69.sep;
|
|
61544
61737
|
if (!target.startsWith(root + sep4)) return null;
|
|
61545
|
-
const rel =
|
|
61738
|
+
const rel = path69.relative(root, target);
|
|
61546
61739
|
if (!rel || rel.startsWith("..")) return null;
|
|
61547
|
-
const id = rel.split(
|
|
61740
|
+
const id = rel.split(path69.sep)[0];
|
|
61548
61741
|
return id || null;
|
|
61549
61742
|
}
|
|
61550
61743
|
function isPathWithin(dir, absPath) {
|
|
61551
|
-
const d =
|
|
61552
|
-
const t =
|
|
61553
|
-
const sep4 = d.endsWith(
|
|
61744
|
+
const d = path69.resolve(dir);
|
|
61745
|
+
const t = path69.resolve(absPath);
|
|
61746
|
+
const sep4 = d.endsWith(path69.sep) ? "" : path69.sep;
|
|
61554
61747
|
return t === d || t.startsWith(d + sep4);
|
|
61555
61748
|
}
|
|
61556
61749
|
function isPathInGuestBoundary(personaRoot, personaId2, userWorkDir, absPath) {
|
|
61557
61750
|
if (userWorkDir && isPathWithin(userWorkDir, absPath)) return true;
|
|
61558
|
-
return personaIdFromPath(
|
|
61751
|
+
return personaIdFromPath(path69.resolve(absPath), personaRoot) === personaId2;
|
|
61559
61752
|
}
|
|
61560
61753
|
|
|
61561
61754
|
// src/handlers/history.ts
|
|
@@ -61608,7 +61801,7 @@ function buildHistoryHandlers(deps) {
|
|
|
61608
61801
|
if (!pid) return false;
|
|
61609
61802
|
return isGuestPathAllowed(
|
|
61610
61803
|
ctx.grants,
|
|
61611
|
-
|
|
61804
|
+
path70.join(personaRoot, pid),
|
|
61612
61805
|
personaRoot,
|
|
61613
61806
|
"read",
|
|
61614
61807
|
userWorkDir
|
|
@@ -61620,7 +61813,7 @@ function buildHistoryHandlers(deps) {
|
|
|
61620
61813
|
};
|
|
61621
61814
|
const list = async (frame, _client, ctx) => {
|
|
61622
61815
|
const args = HistoryListArgs.parse(frame);
|
|
61623
|
-
assertGuestPath(ctx,
|
|
61816
|
+
assertGuestPath(ctx, path70.resolve(args.projectPath), personaRoot, "history:list", usersRoot);
|
|
61624
61817
|
const sessions = await history.listSessions(args);
|
|
61625
61818
|
return { response: { type: "history:list", sessions } };
|
|
61626
61819
|
};
|
|
@@ -61668,14 +61861,14 @@ function buildHistoryHandlers(deps) {
|
|
|
61668
61861
|
};
|
|
61669
61862
|
const subagents = async (frame, _client, ctx) => {
|
|
61670
61863
|
const args = HistorySubagentsArgs.parse(frame);
|
|
61671
|
-
assertGuestPath(ctx,
|
|
61864
|
+
assertGuestPath(ctx, path70.resolve(args.cwd), personaRoot, "history:subagents", usersRoot);
|
|
61672
61865
|
assertGuestOwnsToolSession(ctx, args.toolSessionId, "history:subagents");
|
|
61673
61866
|
const subs = await historyReaderForToolSession(args.toolSessionId).listSubagents(args);
|
|
61674
61867
|
return { response: { type: "history:subagents", subagents: subs } };
|
|
61675
61868
|
};
|
|
61676
61869
|
const subagentRead = async (frame, _client, ctx) => {
|
|
61677
61870
|
const args = HistorySubagentReadArgs.parse(frame);
|
|
61678
|
-
assertGuestPath(ctx,
|
|
61871
|
+
assertGuestPath(ctx, path70.resolve(args.cwd), personaRoot, "history:subagent-read", usersRoot);
|
|
61679
61872
|
assertGuestOwnsToolSession(ctx, args.toolSessionId, "history:subagent-read");
|
|
61680
61873
|
const res = await historyReaderForToolSession(args.toolSessionId).readSubagent(args);
|
|
61681
61874
|
return { response: { type: "history:subagent-read", ...res } };
|
|
@@ -61685,7 +61878,7 @@ function buildHistoryHandlers(deps) {
|
|
|
61685
61878
|
if (ctx?.principal.kind === "guest" && personaRoot) {
|
|
61686
61879
|
const userWorkDir = usersRoot ? deriveUserWorkDir(ctx.principal.id, usersRoot) : void 0;
|
|
61687
61880
|
const filtered = dirs.filter(
|
|
61688
|
-
(d) => isGuestPathAllowed(ctx.grants,
|
|
61881
|
+
(d) => isGuestPathAllowed(ctx.grants, path70.resolve(d.cwd), personaRoot, "read", userWorkDir)
|
|
61689
61882
|
);
|
|
61690
61883
|
return { response: { type: "history:recentDirs", dirs: filtered } };
|
|
61691
61884
|
}
|
|
@@ -61702,17 +61895,17 @@ function buildHistoryHandlers(deps) {
|
|
|
61702
61895
|
}
|
|
61703
61896
|
|
|
61704
61897
|
// src/handlers/projects.ts
|
|
61705
|
-
var
|
|
61706
|
-
var
|
|
61707
|
-
var
|
|
61898
|
+
var fs64 = __toESM(require("fs"), 1);
|
|
61899
|
+
var os21 = __toESM(require("os"), 1);
|
|
61900
|
+
var path71 = __toESM(require("path"), 1);
|
|
61708
61901
|
var import_node_child_process13 = require("child_process");
|
|
61709
61902
|
init_protocol();
|
|
61710
|
-
var DEFAULT_PROJECTS_ROOT =
|
|
61903
|
+
var DEFAULT_PROJECTS_ROOT = path71.join(os21.homedir(), "Documents", "ChatGPT");
|
|
61711
61904
|
function allocateDir(root, name) {
|
|
61712
|
-
let candidate =
|
|
61905
|
+
let candidate = path71.join(root, name);
|
|
61713
61906
|
let n = 2;
|
|
61714
|
-
while (
|
|
61715
|
-
candidate =
|
|
61907
|
+
while (fs64.existsSync(candidate)) {
|
|
61908
|
+
candidate = path71.join(root, `${name} ${n}`);
|
|
61716
61909
|
n += 1;
|
|
61717
61910
|
}
|
|
61718
61911
|
return candidate;
|
|
@@ -61740,7 +61933,7 @@ function buildProjectHandlers(deps) {
|
|
|
61740
61933
|
throw new ClawdError(ERROR_CODES.INVALID_CWD, "project:reveal \u4EC5\u652F\u6301 macOS");
|
|
61741
61934
|
}
|
|
61742
61935
|
try {
|
|
61743
|
-
if (!
|
|
61936
|
+
if (!fs64.statSync(args.path).isDirectory()) throw new Error("not dir");
|
|
61744
61937
|
} catch {
|
|
61745
61938
|
throw new ClawdError(ERROR_CODES.INVALID_CWD, `not a directory: ${args.path}`);
|
|
61746
61939
|
}
|
|
@@ -61756,7 +61949,7 @@ function buildProjectHandlers(deps) {
|
|
|
61756
61949
|
let target;
|
|
61757
61950
|
if (args.path) {
|
|
61758
61951
|
try {
|
|
61759
|
-
if (!
|
|
61952
|
+
if (!fs64.statSync(args.path).isDirectory()) throw new Error("not dir");
|
|
61760
61953
|
} catch {
|
|
61761
61954
|
throw new ClawdError(ERROR_CODES.INVALID_CWD, `not a directory: ${args.path}`);
|
|
61762
61955
|
}
|
|
@@ -61764,15 +61957,15 @@ function buildProjectHandlers(deps) {
|
|
|
61764
61957
|
} else {
|
|
61765
61958
|
const name = args.name;
|
|
61766
61959
|
try {
|
|
61767
|
-
|
|
61960
|
+
fs64.mkdirSync(root, { recursive: true });
|
|
61768
61961
|
target = allocateDir(root, name);
|
|
61769
|
-
|
|
61962
|
+
fs64.mkdirSync(target);
|
|
61770
61963
|
} catch (err) {
|
|
61771
61964
|
throw new ClawdError(ERROR_CODES.INVALID_CWD, `\u521B\u5EFA\u9879\u76EE\u76EE\u5F55\u5931\u8D25: ${String(err)}`);
|
|
61772
61965
|
}
|
|
61773
61966
|
const git = (0, import_node_child_process13.spawnSync)("git", ["init"], { cwd: target, stdio: "ignore" });
|
|
61774
61967
|
if (git.status !== 0) {
|
|
61775
|
-
|
|
61968
|
+
fs64.rmSync(target, { recursive: true, force: true });
|
|
61776
61969
|
throw new ClawdError(
|
|
61777
61970
|
ERROR_CODES.INVALID_CWD,
|
|
61778
61971
|
`git init \u5931\u8D25\uFF08${git.error ? String(git.error) : `exit ${git.status}`}\uFF09: ${target}`
|
|
@@ -61797,8 +61990,8 @@ function buildProjectHandlers(deps) {
|
|
|
61797
61990
|
}
|
|
61798
61991
|
|
|
61799
61992
|
// src/handlers/workspace.ts
|
|
61800
|
-
var
|
|
61801
|
-
var
|
|
61993
|
+
var path72 = __toESM(require("path"), 1);
|
|
61994
|
+
var os22 = __toESM(require("os"), 1);
|
|
61802
61995
|
init_protocol();
|
|
61803
61996
|
init_protocol();
|
|
61804
61997
|
function buildEnabledPluginNames(personaManager, personaId2) {
|
|
@@ -61838,23 +62031,23 @@ function buildWorkspaceHandlers(deps) {
|
|
|
61838
62031
|
const list = async (frame, _client, ctx) => {
|
|
61839
62032
|
const args = WorkspaceListArgs.parse(frame);
|
|
61840
62033
|
const isGuest = ctx?.principal.kind === "guest";
|
|
61841
|
-
const fallbackCwd = isGuest && personaRoot ? personaRoot :
|
|
61842
|
-
const resolvedCwd =
|
|
61843
|
-
const target = args.path ?
|
|
62034
|
+
const fallbackCwd = isGuest && personaRoot ? personaRoot : os22.homedir();
|
|
62035
|
+
const resolvedCwd = path72.resolve(args.cwd ?? fallbackCwd);
|
|
62036
|
+
const target = args.path ? path72.resolve(resolvedCwd, args.path) : resolvedCwd;
|
|
61844
62037
|
assertGuestPath2(ctx, target, personaRoot, "workspace:list", usersRoot);
|
|
61845
62038
|
const res = workspace.list({ ...args, cwd: resolvedCwd });
|
|
61846
62039
|
return { response: { type: "workspace:list", ...res } };
|
|
61847
62040
|
};
|
|
61848
62041
|
const read = async (frame, _client, ctx) => {
|
|
61849
62042
|
const args = WorkspaceReadArgs.parse(frame);
|
|
61850
|
-
const target =
|
|
62043
|
+
const target = path72.isAbsolute(args.path) ? path72.resolve(args.path) : path72.resolve(args.cwd, args.path);
|
|
61851
62044
|
assertGuestPath2(ctx, target, personaRoot, "workspace:read", usersRoot);
|
|
61852
62045
|
const res = workspace.read(args);
|
|
61853
62046
|
return { response: { type: "workspace:read", ...res } };
|
|
61854
62047
|
};
|
|
61855
62048
|
const skillsList = async (frame, _client, ctx) => {
|
|
61856
62049
|
const args = SkillsListArgs.parse(frame);
|
|
61857
|
-
const cwdAbs =
|
|
62050
|
+
const cwdAbs = path72.resolve(args.cwd);
|
|
61858
62051
|
assertGuestPath2(ctx, cwdAbs, personaRoot, "skills:list", usersRoot);
|
|
61859
62052
|
const list2 = await getSkillsForTool(args.tool ?? "claude", cwdAbs);
|
|
61860
62053
|
if (ctx?.principal.kind === "guest" && personaRoot) {
|
|
@@ -61866,7 +62059,7 @@ function buildWorkspaceHandlers(deps) {
|
|
|
61866
62059
|
};
|
|
61867
62060
|
const agentsList = async (frame, _client, ctx) => {
|
|
61868
62061
|
const args = AgentsListArgs.parse(frame);
|
|
61869
|
-
const cwdAbs =
|
|
62062
|
+
const cwdAbs = path72.resolve(args.cwd);
|
|
61870
62063
|
assertGuestPath2(ctx, cwdAbs, personaRoot, "agents:list", usersRoot);
|
|
61871
62064
|
if (args.tool === "codex") {
|
|
61872
62065
|
return { response: { type: "agents:list", agents: [] } };
|
|
@@ -61888,20 +62081,20 @@ function buildWorkspaceHandlers(deps) {
|
|
|
61888
62081
|
}
|
|
61889
62082
|
|
|
61890
62083
|
// src/handlers/git.ts
|
|
61891
|
-
var
|
|
62084
|
+
var path74 = __toESM(require("path"), 1);
|
|
61892
62085
|
init_protocol();
|
|
61893
62086
|
init_protocol();
|
|
61894
62087
|
|
|
61895
62088
|
// src/workspace/git.ts
|
|
61896
62089
|
var import_node_child_process14 = require("child_process");
|
|
61897
|
-
var
|
|
61898
|
-
var
|
|
62090
|
+
var import_node_fs49 = __toESM(require("fs"), 1);
|
|
62091
|
+
var import_node_path56 = __toESM(require("path"), 1);
|
|
61899
62092
|
var import_node_util = require("util");
|
|
61900
62093
|
var pexec = (0, import_node_util.promisify)(import_node_child_process14.execFile);
|
|
61901
62094
|
function normalizePath(p2) {
|
|
61902
|
-
const resolved =
|
|
62095
|
+
const resolved = import_node_path56.default.resolve(p2);
|
|
61903
62096
|
try {
|
|
61904
|
-
return
|
|
62097
|
+
return import_node_fs49.default.realpathSync(resolved);
|
|
61905
62098
|
} catch {
|
|
61906
62099
|
return resolved;
|
|
61907
62100
|
}
|
|
@@ -61975,7 +62168,7 @@ async function listGitBranches(cwd) {
|
|
|
61975
62168
|
function assertGuestCwd(ctx, cwd, personaRoot, method, usersRoot) {
|
|
61976
62169
|
if (!ctx || ctx.principal.kind !== "guest" || !personaRoot) return;
|
|
61977
62170
|
const userWorkDir = usersRoot ? deriveUserWorkDir(ctx.principal.id, usersRoot) : void 0;
|
|
61978
|
-
if (!isGuestPathAllowed(ctx.grants,
|
|
62171
|
+
if (!isGuestPathAllowed(ctx.grants, path74.resolve(cwd), personaRoot, "read", userWorkDir)) {
|
|
61979
62172
|
throw new ClawdError(
|
|
61980
62173
|
ERROR_CODES.UNAUTHORIZED,
|
|
61981
62174
|
`guest ${ctx.principal.id} cannot ${method} cwd ${cwd}`
|
|
@@ -62520,7 +62713,7 @@ function buildFeishuAuthHandlers(deps) {
|
|
|
62520
62713
|
}
|
|
62521
62714
|
|
|
62522
62715
|
// src/handlers/meta.ts
|
|
62523
|
-
var
|
|
62716
|
+
var import_node_os20 = __toESM(require("os"), 1);
|
|
62524
62717
|
init_protocol();
|
|
62525
62718
|
|
|
62526
62719
|
// src/handlers/method-grants.ts
|
|
@@ -62596,6 +62789,9 @@ var METHOD_GRANT_MAP = {
|
|
|
62596
62789
|
"session:pin": CAPABILITY_SCOPED,
|
|
62597
62790
|
"session:archive": CAPABILITY_SCOPED,
|
|
62598
62791
|
"session:markRead": CAPABILITY_SCOPED,
|
|
62792
|
+
// 全局搜索扫 transcript 正文。与 history:read 同档:guest 进 persona VM 后要能搜自己的会话,
|
|
62793
|
+
// handler 内仍逐条 ensureSessionAccess,可见面不因 sessionIds 由客户端给定而放大
|
|
62794
|
+
"session:searchContent": CAPABILITY_SCOPED,
|
|
62599
62795
|
"session:reorderPins": ADMIN_ANY,
|
|
62600
62796
|
// owner 全局操作,无 personaId 维度
|
|
62601
62797
|
// mirror peer sessions (2026-05-26):owner-only — guest 不应能写/删本机 mirror SessionFile
|
|
@@ -62807,21 +63003,21 @@ function computeMethodAccess(args) {
|
|
|
62807
63003
|
}
|
|
62808
63004
|
|
|
62809
63005
|
// src/version.ts
|
|
62810
|
-
var version = "0.2.
|
|
63006
|
+
var version = "0.2.440".length > 0 ? "0.2.440" : "dev";
|
|
62811
63007
|
|
|
62812
63008
|
// src/cli-probe/probe.ts
|
|
62813
|
-
var
|
|
62814
|
-
var
|
|
63009
|
+
var fs66 = __toESM(require("fs"), 1);
|
|
63010
|
+
var path75 = __toESM(require("path"), 1);
|
|
62815
63011
|
var PKG_NAME = "@clawos-dev/clawd";
|
|
62816
63012
|
var BIN_NAME = "clawd";
|
|
62817
63013
|
var MAX_PARENT_HOPS = 5;
|
|
62818
63014
|
function probeGlobalCli(pathEnv) {
|
|
62819
63015
|
if (!pathEnv) return null;
|
|
62820
|
-
for (const dir of pathEnv.split(
|
|
63016
|
+
for (const dir of pathEnv.split(path75.delimiter)) {
|
|
62821
63017
|
if (!dir) continue;
|
|
62822
63018
|
let real;
|
|
62823
63019
|
try {
|
|
62824
|
-
real =
|
|
63020
|
+
real = fs66.realpathSync(path75.join(dir, BIN_NAME));
|
|
62825
63021
|
} catch {
|
|
62826
63022
|
continue;
|
|
62827
63023
|
}
|
|
@@ -62831,15 +63027,15 @@ function probeGlobalCli(pathEnv) {
|
|
|
62831
63027
|
return null;
|
|
62832
63028
|
}
|
|
62833
63029
|
function readOwnPackageVersion(entryPath) {
|
|
62834
|
-
let dir =
|
|
63030
|
+
let dir = path75.dirname(entryPath);
|
|
62835
63031
|
for (let i = 0; i < MAX_PARENT_HOPS; i++) {
|
|
62836
63032
|
try {
|
|
62837
|
-
const raw =
|
|
63033
|
+
const raw = fs66.readFileSync(path75.join(dir, "package.json"), "utf8");
|
|
62838
63034
|
const pkg = JSON.parse(raw);
|
|
62839
63035
|
if (pkg.name !== PKG_NAME) return null;
|
|
62840
63036
|
return typeof pkg.version === "string" && pkg.version ? pkg.version : null;
|
|
62841
63037
|
} catch {
|
|
62842
|
-
const parent =
|
|
63038
|
+
const parent = path75.dirname(dir);
|
|
62843
63039
|
if (parent === dir) return null;
|
|
62844
63040
|
dir = parent;
|
|
62845
63041
|
}
|
|
@@ -62875,7 +63071,7 @@ function buildReadyFrame(deps, client) {
|
|
|
62875
63071
|
return {
|
|
62876
63072
|
version,
|
|
62877
63073
|
protocolVersion: PROTOCOL_VERSION,
|
|
62878
|
-
hostname:
|
|
63074
|
+
hostname: import_node_os20.default.hostname(),
|
|
62879
63075
|
os: process.platform,
|
|
62880
63076
|
tools,
|
|
62881
63077
|
runningSessions: info.runningSessions,
|
|
@@ -62971,6 +63167,7 @@ function buildPersonaHandlers(deps) {
|
|
|
62971
63167
|
const skills = personaManager.listSkills(args.personaId);
|
|
62972
63168
|
const plugins = personaManager.listEnabledPlugins(args.personaId);
|
|
62973
63169
|
const sandboxSettings = personaManager.readSandboxSettings(args.personaId);
|
|
63170
|
+
const codexSandbox = personaManager.readCodexSandboxSettings(args.personaId);
|
|
62974
63171
|
return {
|
|
62975
63172
|
response: {
|
|
62976
63173
|
type: "persona:info",
|
|
@@ -62980,16 +63177,26 @@ function buildPersonaHandlers(deps) {
|
|
|
62980
63177
|
personalityManaged,
|
|
62981
63178
|
skills,
|
|
62982
63179
|
plugins,
|
|
62983
|
-
sandboxSettings
|
|
63180
|
+
sandboxSettings,
|
|
63181
|
+
codexSandbox
|
|
62984
63182
|
}
|
|
62985
63183
|
};
|
|
62986
63184
|
};
|
|
62987
63185
|
const update = async (frame) => {
|
|
62988
63186
|
const { type: _type, requestId: _requestId, ...rest } = frame;
|
|
62989
63187
|
const args = parseArgs2(PersonaUpdateArgsSchema, frame, "persona:update");
|
|
62990
|
-
const { personality, personalityLocal, ...metaPatch } = args.patch;
|
|
63188
|
+
const { personality, personalityLocal, codexSandbox, ...metaPatch } = args.patch;
|
|
62991
63189
|
const persona = personaManager.update(args.personaId, metaPatch, { personality, personalityLocal });
|
|
62992
|
-
|
|
63190
|
+
const mergedCodexSandbox = codexSandbox ? personaManager.mergeCodexSandbox(args.personaId, codexSandbox) : void 0;
|
|
63191
|
+
return {
|
|
63192
|
+
response: {
|
|
63193
|
+
type: "persona:info",
|
|
63194
|
+
...persona,
|
|
63195
|
+
// 只在本次确实动过时回带,让调用方拿到合并后的真值而不用再 get 一次;
|
|
63196
|
+
// 没动就不带(与 personality 等分层字段同口径:persona:update 的响应是 meta 视图)。
|
|
63197
|
+
...mergedCodexSandbox ? { codexSandbox: mergedCodexSandbox } : {}
|
|
63198
|
+
}
|
|
63199
|
+
};
|
|
62993
63200
|
};
|
|
62994
63201
|
const del = async (frame) => {
|
|
62995
63202
|
const args = parseArgs2(PersonaIdArgsSchema, frame, "persona:delete");
|
|
@@ -63008,7 +63215,7 @@ function buildPersonaHandlers(deps) {
|
|
|
63008
63215
|
}
|
|
63009
63216
|
|
|
63010
63217
|
// src/handlers/attachment.ts
|
|
63011
|
-
var
|
|
63218
|
+
var import_node_path57 = __toESM(require("path"), 1);
|
|
63012
63219
|
init_protocol();
|
|
63013
63220
|
init_protocol();
|
|
63014
63221
|
var DEFAULT_TTL_SECONDS = 24 * 3600;
|
|
@@ -63088,12 +63295,12 @@ function buildAttachmentHandlers(deps) {
|
|
|
63088
63295
|
`session ${args.sessionId} scope unresolved`
|
|
63089
63296
|
);
|
|
63090
63297
|
}
|
|
63091
|
-
const cwdAbs =
|
|
63092
|
-
const candidateAbs =
|
|
63298
|
+
const cwdAbs = import_node_path57.default.resolve(sessionFile.cwd);
|
|
63299
|
+
const candidateAbs = import_node_path57.default.isAbsolute(args.relPath) ? import_node_path57.default.resolve(args.relPath) : import_node_path57.default.resolve(cwdAbs, args.relPath);
|
|
63093
63300
|
guardAttachmentPath(ctx, args.sessionId, candidateAbs, "attachment.signUrl", "group-acl");
|
|
63094
63301
|
const entries = deps.groupFileStore.list(scope, args.sessionId);
|
|
63095
63302
|
const entry = entries.find((e) => {
|
|
63096
|
-
const storedAbs =
|
|
63303
|
+
const storedAbs = import_node_path57.default.isAbsolute(e.relPath) ? import_node_path57.default.resolve(e.relPath) : import_node_path57.default.resolve(cwdAbs, e.relPath);
|
|
63097
63304
|
return storedAbs === candidateAbs && !e.stale;
|
|
63098
63305
|
});
|
|
63099
63306
|
if (!entry) {
|
|
@@ -63118,7 +63325,7 @@ function buildAttachmentHandlers(deps) {
|
|
|
63118
63325
|
if (!ctx || ctx.principal.kind !== "guest" || !deps.personaRoot || !deps.sessionStore) return;
|
|
63119
63326
|
const f = deps.sessionStore.read(sessionId);
|
|
63120
63327
|
if (!f) return;
|
|
63121
|
-
assertGuestAttachmentPath(ctx,
|
|
63328
|
+
assertGuestAttachmentPath(ctx, import_node_path57.default.resolve(f.cwd), deps.personaRoot, method, deps.usersRoot);
|
|
63122
63329
|
}
|
|
63123
63330
|
const groupAdd = async (frame, _client, ctx) => {
|
|
63124
63331
|
if (!deps.groupFileStore || !deps.getSessionScope) {
|
|
@@ -63133,8 +63340,8 @@ function buildAttachmentHandlers(deps) {
|
|
|
63133
63340
|
if (!scope) {
|
|
63134
63341
|
throw new ClawdError(ERROR_CODES.VALIDATION_ERROR, `session ${args.sessionId} not found`);
|
|
63135
63342
|
}
|
|
63136
|
-
const cwdAbs =
|
|
63137
|
-
const candidateAbs =
|
|
63343
|
+
const cwdAbs = import_node_path57.default.resolve(deps.sessionStore?.read(args.sessionId)?.cwd ?? ".");
|
|
63344
|
+
const candidateAbs = import_node_path57.default.isAbsolute(args.relPath) ? import_node_path57.default.resolve(args.relPath) : import_node_path57.default.resolve(cwdAbs, args.relPath);
|
|
63138
63345
|
guardAttachmentPath(ctx, args.sessionId, candidateAbs, "attachment.groupAdd", "cwd-subtree");
|
|
63139
63346
|
const from = args.origin === "agent" ? "agent" : ctx?.principal.kind === "owner" ? "owner" : "agent";
|
|
63140
63347
|
const size = 0;
|
|
@@ -63193,19 +63400,19 @@ function buildAttachmentHandlers(deps) {
|
|
|
63193
63400
|
|
|
63194
63401
|
// src/handlers/extension.ts
|
|
63195
63402
|
var import_promises12 = __toESM(require("fs/promises"), 1);
|
|
63196
|
-
var
|
|
63403
|
+
var import_node_path62 = __toESM(require("path"), 1);
|
|
63197
63404
|
init_protocol();
|
|
63198
63405
|
|
|
63199
63406
|
// src/extension/bundle-zip.ts
|
|
63200
63407
|
var import_promises9 = __toESM(require("fs/promises"), 1);
|
|
63201
|
-
var
|
|
63408
|
+
var import_node_path58 = __toESM(require("path"), 1);
|
|
63202
63409
|
var import_node_crypto17 = __toESM(require("crypto"), 1);
|
|
63203
63410
|
var import_jszip2 = __toESM(require_lib3(), 1);
|
|
63204
63411
|
async function bundleExtensionDir(dir) {
|
|
63205
63412
|
const entries = await listFilesSorted(dir);
|
|
63206
63413
|
const zip = new import_jszip2.default();
|
|
63207
63414
|
for (const rel of entries) {
|
|
63208
|
-
const abs =
|
|
63415
|
+
const abs = import_node_path58.default.join(dir, rel);
|
|
63209
63416
|
const content = await import_promises9.default.readFile(abs);
|
|
63210
63417
|
zip.file(rel, content, { date: FIXED_DATE });
|
|
63211
63418
|
}
|
|
@@ -63226,7 +63433,7 @@ async function listFilesSorted(rootDir) {
|
|
|
63226
63433
|
return out;
|
|
63227
63434
|
}
|
|
63228
63435
|
async function walk(absRoot, relPrefix, out) {
|
|
63229
|
-
const dirAbs =
|
|
63436
|
+
const dirAbs = import_node_path58.default.join(absRoot, relPrefix);
|
|
63230
63437
|
const entries = await import_promises9.default.readdir(dirAbs, { withFileTypes: true });
|
|
63231
63438
|
for (const e of entries) {
|
|
63232
63439
|
if (IGNORE_BASENAMES.has(e.name)) continue;
|
|
@@ -63280,25 +63487,25 @@ function computePublishCheck(args) {
|
|
|
63280
63487
|
|
|
63281
63488
|
// src/extension/install-flow.ts
|
|
63282
63489
|
var import_promises10 = __toESM(require("fs/promises"), 1);
|
|
63283
|
-
var
|
|
63284
|
-
var
|
|
63490
|
+
var import_node_path60 = __toESM(require("path"), 1);
|
|
63491
|
+
var import_node_os22 = __toESM(require("os"), 1);
|
|
63285
63492
|
var import_node_crypto18 = __toESM(require("crypto"), 1);
|
|
63286
63493
|
var import_jszip3 = __toESM(require_lib3(), 1);
|
|
63287
63494
|
|
|
63288
63495
|
// src/extension/paths.ts
|
|
63289
|
-
var
|
|
63290
|
-
var
|
|
63496
|
+
var import_node_os21 = __toESM(require("os"), 1);
|
|
63497
|
+
var import_node_path59 = __toESM(require("path"), 1);
|
|
63291
63498
|
function clawdHomeRoot(override) {
|
|
63292
|
-
return override ?? process.env.CLAWD_HOME ??
|
|
63499
|
+
return override ?? process.env.CLAWD_HOME ?? import_node_path59.default.join(import_node_os21.default.homedir(), ".clawd");
|
|
63293
63500
|
}
|
|
63294
63501
|
function extensionsRoot(override) {
|
|
63295
|
-
return
|
|
63502
|
+
return import_node_path59.default.join(clawdHomeRoot(override), "extensions");
|
|
63296
63503
|
}
|
|
63297
63504
|
function publishedChannelsFile(override) {
|
|
63298
|
-
return
|
|
63505
|
+
return import_node_path59.default.join(clawdHomeRoot(override), "extensions-published.json");
|
|
63299
63506
|
}
|
|
63300
63507
|
function bundleCacheRoot(override) {
|
|
63301
|
-
return
|
|
63508
|
+
return import_node_path59.default.join(clawdHomeRoot(override), "extension-bundles");
|
|
63302
63509
|
}
|
|
63303
63510
|
|
|
63304
63511
|
// src/extension/install-flow.ts
|
|
@@ -63325,7 +63532,7 @@ async function installFromChannel(args, deps) {
|
|
|
63325
63532
|
throw new InstallError("ZIP_INVALID", `failed to load zip: ${e.message}`);
|
|
63326
63533
|
}
|
|
63327
63534
|
for (const name of Object.keys(zip.files)) {
|
|
63328
|
-
if (name.includes("..") || name.startsWith("/") ||
|
|
63535
|
+
if (name.includes("..") || name.startsWith("/") || import_node_path60.default.isAbsolute(name)) {
|
|
63329
63536
|
throw new InstallError("ZIP_INVALID", `unsafe zip entry: ${name}`);
|
|
63330
63537
|
}
|
|
63331
63538
|
}
|
|
@@ -63357,7 +63564,7 @@ async function installFromChannel(args, deps) {
|
|
|
63357
63564
|
);
|
|
63358
63565
|
}
|
|
63359
63566
|
const localExtId = namespacedExtId(ownerSlug, channelRef.ownerPrincipalId);
|
|
63360
|
-
const destDir =
|
|
63567
|
+
const destDir = import_node_path60.default.join(deps.extensionsRoot, localExtId);
|
|
63361
63568
|
let destExists = false;
|
|
63362
63569
|
try {
|
|
63363
63570
|
await import_promises10.default.access(destDir);
|
|
@@ -63371,16 +63578,16 @@ async function installFromChannel(args, deps) {
|
|
|
63371
63578
|
);
|
|
63372
63579
|
}
|
|
63373
63580
|
const stage = await import_promises10.default.mkdtemp(
|
|
63374
|
-
|
|
63581
|
+
import_node_path60.default.join(import_node_os22.default.tmpdir(), `clawd-ext-install-${localExtId}-`)
|
|
63375
63582
|
);
|
|
63376
63583
|
try {
|
|
63377
63584
|
for (const [name, entry] of Object.entries(zip.files)) {
|
|
63378
|
-
const dest =
|
|
63585
|
+
const dest = import_node_path60.default.join(stage, name);
|
|
63379
63586
|
if (entry.dir) {
|
|
63380
63587
|
await import_promises10.default.mkdir(dest, { recursive: true });
|
|
63381
63588
|
continue;
|
|
63382
63589
|
}
|
|
63383
|
-
await import_promises10.default.mkdir(
|
|
63590
|
+
await import_promises10.default.mkdir(import_node_path60.default.dirname(dest), { recursive: true });
|
|
63384
63591
|
if (name === "manifest.json") {
|
|
63385
63592
|
const rewritten = { ...parsed.data, id: localExtId };
|
|
63386
63593
|
await import_promises10.default.writeFile(dest, JSON.stringify(rewritten, null, 2));
|
|
@@ -63401,8 +63608,8 @@ async function installFromChannel(args, deps) {
|
|
|
63401
63608
|
|
|
63402
63609
|
// src/extension/update-flow.ts
|
|
63403
63610
|
var import_promises11 = __toESM(require("fs/promises"), 1);
|
|
63404
|
-
var
|
|
63405
|
-
var
|
|
63611
|
+
var import_node_path61 = __toESM(require("path"), 1);
|
|
63612
|
+
var import_node_os23 = __toESM(require("os"), 1);
|
|
63406
63613
|
var import_node_crypto19 = __toESM(require("crypto"), 1);
|
|
63407
63614
|
var import_jszip4 = __toESM(require_lib3(), 1);
|
|
63408
63615
|
var UpdateError = class extends Error {
|
|
@@ -63418,11 +63625,11 @@ async function updateFromChannel(args, deps) {
|
|
|
63418
63625
|
channelRef.extId,
|
|
63419
63626
|
channelRef.ownerPrincipalId
|
|
63420
63627
|
);
|
|
63421
|
-
const liveDir =
|
|
63628
|
+
const liveDir = import_node_path61.default.join(deps.extensionsRoot, localExtId);
|
|
63422
63629
|
const prevDir = `${liveDir}.prev`;
|
|
63423
63630
|
let existingVersion;
|
|
63424
63631
|
try {
|
|
63425
|
-
const raw = await import_promises11.default.readFile(
|
|
63632
|
+
const raw = await import_promises11.default.readFile(import_node_path61.default.join(liveDir, "manifest.json"), "utf8");
|
|
63426
63633
|
const parsed2 = ExtensionManifestSchema.safeParse(JSON.parse(raw));
|
|
63427
63634
|
if (!parsed2.success) {
|
|
63428
63635
|
throw new UpdateError(
|
|
@@ -63455,7 +63662,7 @@ async function updateFromChannel(args, deps) {
|
|
|
63455
63662
|
throw new UpdateError("ZIP_INVALID", `failed to load zip: ${e.message}`);
|
|
63456
63663
|
}
|
|
63457
63664
|
for (const name of Object.keys(zip.files)) {
|
|
63458
|
-
if (name.includes("..") || name.startsWith("/") ||
|
|
63665
|
+
if (name.includes("..") || name.startsWith("/") || import_node_path61.default.isAbsolute(name)) {
|
|
63459
63666
|
throw new UpdateError("ZIP_INVALID", `unsafe zip entry: ${name}`);
|
|
63460
63667
|
}
|
|
63461
63668
|
}
|
|
@@ -63490,16 +63697,16 @@ async function updateFromChannel(args, deps) {
|
|
|
63490
63697
|
await import_promises11.default.rm(prevDir, { recursive: true, force: true });
|
|
63491
63698
|
await import_promises11.default.rename(liveDir, prevDir);
|
|
63492
63699
|
const stage = await import_promises11.default.mkdtemp(
|
|
63493
|
-
|
|
63700
|
+
import_node_path61.default.join(import_node_os23.default.tmpdir(), `clawd-ext-update-${localExtId}-`)
|
|
63494
63701
|
);
|
|
63495
63702
|
try {
|
|
63496
63703
|
for (const [name, entry] of Object.entries(zip.files)) {
|
|
63497
|
-
const dest =
|
|
63704
|
+
const dest = import_node_path61.default.join(stage, name);
|
|
63498
63705
|
if (entry.dir) {
|
|
63499
63706
|
await import_promises11.default.mkdir(dest, { recursive: true });
|
|
63500
63707
|
continue;
|
|
63501
63708
|
}
|
|
63502
|
-
await import_promises11.default.mkdir(
|
|
63709
|
+
await import_promises11.default.mkdir(import_node_path61.default.dirname(dest), { recursive: true });
|
|
63503
63710
|
if (name === "manifest.json") {
|
|
63504
63711
|
const rewritten = { ...parsed.data, id: localExtId };
|
|
63505
63712
|
await import_promises11.default.writeFile(dest, JSON.stringify(rewritten, null, 2));
|
|
@@ -63566,7 +63773,7 @@ async function rewriteManifestVersion(root, extId, newVersion, previousPublished
|
|
|
63566
63773
|
);
|
|
63567
63774
|
}
|
|
63568
63775
|
}
|
|
63569
|
-
const manifestPath =
|
|
63776
|
+
const manifestPath = import_node_path62.default.join(root, extId, "manifest.json");
|
|
63570
63777
|
const manifest = await readManifest(root, extId);
|
|
63571
63778
|
const next = { ...manifest, version: newVersion };
|
|
63572
63779
|
const tmp = `${manifestPath}.tmp`;
|
|
@@ -63574,7 +63781,7 @@ async function rewriteManifestVersion(root, extId, newVersion, previousPublished
|
|
|
63574
63781
|
await import_promises12.default.rename(tmp, manifestPath);
|
|
63575
63782
|
}
|
|
63576
63783
|
async function readManifest(root, extId) {
|
|
63577
|
-
const file =
|
|
63784
|
+
const file = import_node_path62.default.join(root, extId, "manifest.json");
|
|
63578
63785
|
let raw;
|
|
63579
63786
|
try {
|
|
63580
63787
|
raw = await import_promises12.default.readFile(file, "utf8");
|
|
@@ -63658,7 +63865,7 @@ function buildExtensionHandlers(deps) {
|
|
|
63658
63865
|
};
|
|
63659
63866
|
async function buildSnapshotMeta(extId) {
|
|
63660
63867
|
const manifest = await readManifest(deps.root, extId);
|
|
63661
|
-
const { sha256, buffer } = await bundleExtensionDir(
|
|
63868
|
+
const { sha256, buffer } = await bundleExtensionDir(import_node_path62.default.join(deps.root, extId));
|
|
63662
63869
|
return { manifest, contentHash: sha256, buffer };
|
|
63663
63870
|
}
|
|
63664
63871
|
const publish = async (frame, _client, ctx) => {
|
|
@@ -63833,9 +64040,9 @@ function buildExtensionHandlers(deps) {
|
|
|
63833
64040
|
}
|
|
63834
64041
|
|
|
63835
64042
|
// src/app-builder/project-store.ts
|
|
63836
|
-
var
|
|
64043
|
+
var import_node_fs50 = require("fs");
|
|
63837
64044
|
var import_node_child_process15 = require("child_process");
|
|
63838
|
-
var
|
|
64045
|
+
var import_node_path63 = require("path");
|
|
63839
64046
|
init_protocol();
|
|
63840
64047
|
var PROJECTS_DIR = "projects";
|
|
63841
64048
|
var META_FILE = ".clawd-project.json";
|
|
@@ -63849,19 +64056,19 @@ var ProjectStore = class {
|
|
|
63849
64056
|
root;
|
|
63850
64057
|
/** projects/<name>/.clawd-project.json 路径 */
|
|
63851
64058
|
metaPath(name) {
|
|
63852
|
-
return (0,
|
|
64059
|
+
return (0, import_node_path63.join)(this.projectsRoot(), name, META_FILE);
|
|
63853
64060
|
}
|
|
63854
64061
|
/** projects/<name>/ 目录路径(cwd 用) */
|
|
63855
64062
|
projectDir(name) {
|
|
63856
|
-
return (0,
|
|
64063
|
+
return (0, import_node_path63.join)(this.projectsRoot(), name);
|
|
63857
64064
|
}
|
|
63858
64065
|
projectsRoot() {
|
|
63859
|
-
return (0,
|
|
64066
|
+
return (0, import_node_path63.join)(this.root, PROJECTS_DIR);
|
|
63860
64067
|
}
|
|
63861
64068
|
async list() {
|
|
63862
64069
|
let entries;
|
|
63863
64070
|
try {
|
|
63864
|
-
entries = await
|
|
64071
|
+
entries = await import_node_fs50.promises.readdir(this.projectsRoot());
|
|
63865
64072
|
} catch (err) {
|
|
63866
64073
|
if (err.code === "ENOENT") return [];
|
|
63867
64074
|
throw err;
|
|
@@ -63869,7 +64076,7 @@ var ProjectStore = class {
|
|
|
63869
64076
|
const out = [];
|
|
63870
64077
|
for (const name of entries) {
|
|
63871
64078
|
try {
|
|
63872
|
-
const raw = await
|
|
64079
|
+
const raw = await import_node_fs50.promises.readFile(this.metaPath(name), "utf8");
|
|
63873
64080
|
const json = JSON.parse(raw);
|
|
63874
64081
|
let migrated = false;
|
|
63875
64082
|
if (typeof json.devCommand !== "string" || json.devCommand.length === 0) {
|
|
@@ -63880,7 +64087,7 @@ var ProjectStore = class {
|
|
|
63880
64087
|
if (parsed.success) {
|
|
63881
64088
|
out.push(parsed.data);
|
|
63882
64089
|
if (migrated) {
|
|
63883
|
-
void
|
|
64090
|
+
void import_node_fs50.promises.writeFile(this.metaPath(name), JSON.stringify(parsed.data, null, 2) + "\n", "utf8").catch(() => {
|
|
63884
64091
|
});
|
|
63885
64092
|
}
|
|
63886
64093
|
}
|
|
@@ -63924,8 +64131,8 @@ var ProjectStore = class {
|
|
|
63924
64131
|
throw new Error(`invalid name "${name}": ${validated.error.message}`);
|
|
63925
64132
|
}
|
|
63926
64133
|
const dir = this.projectDir(name);
|
|
63927
|
-
await
|
|
63928
|
-
await
|
|
64134
|
+
await import_node_fs50.promises.mkdir(dir, { recursive: true });
|
|
64135
|
+
await import_node_fs50.promises.writeFile(this.metaPath(name), JSON.stringify(meta, null, 2) + "\n", "utf8");
|
|
63929
64136
|
return meta;
|
|
63930
64137
|
}
|
|
63931
64138
|
/**
|
|
@@ -63968,7 +64175,7 @@ var ProjectStore = class {
|
|
|
63968
64175
|
}
|
|
63969
64176
|
async delete(name) {
|
|
63970
64177
|
const dir = this.projectDir(name);
|
|
63971
|
-
await
|
|
64178
|
+
await import_node_fs50.promises.rm(dir, { recursive: true, force: true });
|
|
63972
64179
|
}
|
|
63973
64180
|
async updatePort(name, newPort) {
|
|
63974
64181
|
if (newPort < PROJECT_PORT_MIN || newPort > PROJECT_PORT_MAX) {
|
|
@@ -63984,7 +64191,7 @@ var ProjectStore = class {
|
|
|
63984
64191
|
throw new Error(`port ${newPort} already used / \u5DF2\u88AB project "${conflict.name}" \u5360\u7528`);
|
|
63985
64192
|
}
|
|
63986
64193
|
const updated = { ...target, port: newPort };
|
|
63987
|
-
await
|
|
64194
|
+
await import_node_fs50.promises.writeFile(this.metaPath(name), JSON.stringify(updated, null, 2) + "\n", "utf8");
|
|
63988
64195
|
return updated;
|
|
63989
64196
|
}
|
|
63990
64197
|
/**
|
|
@@ -64001,7 +64208,7 @@ var ProjectStore = class {
|
|
|
64001
64208
|
if (!validated.success) {
|
|
64002
64209
|
throw new Error(`invalid prodUrl "${url}": ${validated.error.message}`);
|
|
64003
64210
|
}
|
|
64004
|
-
await
|
|
64211
|
+
await import_node_fs50.promises.writeFile(this.metaPath(name), JSON.stringify(validated.data, null, 2) + "\n", "utf8");
|
|
64005
64212
|
return validated.data;
|
|
64006
64213
|
}
|
|
64007
64214
|
/**
|
|
@@ -64022,7 +64229,7 @@ var ProjectStore = class {
|
|
|
64022
64229
|
if (!validated.success) {
|
|
64023
64230
|
throw new Error(`invalid publishJob: ${validated.error.message}`);
|
|
64024
64231
|
}
|
|
64025
|
-
await
|
|
64232
|
+
await import_node_fs50.promises.writeFile(this.metaPath(name), JSON.stringify(validated.data, null, 2) + "\n", "utf8");
|
|
64026
64233
|
return validated.data;
|
|
64027
64234
|
}
|
|
64028
64235
|
/** 清掉 .clawd-project.json.publishJob 字段。其他字段保持原样。 */
|
|
@@ -64037,7 +64244,7 @@ var ProjectStore = class {
|
|
|
64037
64244
|
if (!validated.success) {
|
|
64038
64245
|
throw new Error(`failed to clear publishJob: ${validated.error.message}`);
|
|
64039
64246
|
}
|
|
64040
|
-
await
|
|
64247
|
+
await import_node_fs50.promises.writeFile(this.metaPath(name), JSON.stringify(validated.data, null, 2) + "\n", "utf8");
|
|
64041
64248
|
return validated.data;
|
|
64042
64249
|
}
|
|
64043
64250
|
};
|
|
@@ -64158,8 +64365,8 @@ var PublishJobRegistry = class {
|
|
|
64158
64365
|
|
|
64159
64366
|
// src/app-builder/publish-job-runner.ts
|
|
64160
64367
|
var import_node_child_process17 = require("child_process");
|
|
64161
|
-
var
|
|
64162
|
-
var
|
|
64368
|
+
var import_node_fs51 = require("fs");
|
|
64369
|
+
var import_node_path64 = require("path");
|
|
64163
64370
|
|
|
64164
64371
|
// src/app-builder/publish-stage-parser.ts
|
|
64165
64372
|
var STAGE_RE = /^\s*::stage::(build|deploy|verify)\s*$/;
|
|
@@ -64191,10 +64398,10 @@ async function startPublishJob(deps, args) {
|
|
|
64191
64398
|
return { jobId: registry2.get(args.name).jobId, status: "already-publishing" };
|
|
64192
64399
|
}
|
|
64193
64400
|
const projDir = projectDir(args.name);
|
|
64194
|
-
const logPath = (0,
|
|
64401
|
+
const logPath = (0, import_node_path64.join)(projDir, ".publish.log");
|
|
64195
64402
|
let logStream = null;
|
|
64196
64403
|
try {
|
|
64197
|
-
logStream = (0,
|
|
64404
|
+
logStream = (0, import_node_fs51.createWriteStream)(logPath, { flags: "w" });
|
|
64198
64405
|
} catch {
|
|
64199
64406
|
logStream = null;
|
|
64200
64407
|
}
|
|
@@ -64451,8 +64658,8 @@ async function recoverInterruptedJobs(deps) {
|
|
|
64451
64658
|
|
|
64452
64659
|
// src/handlers/app-builder.ts
|
|
64453
64660
|
init_protocol();
|
|
64454
|
-
var
|
|
64455
|
-
var
|
|
64661
|
+
var import_node_path65 = require("path");
|
|
64662
|
+
var import_node_fs52 = require("fs");
|
|
64456
64663
|
var APP_BUILDER_PERSONAS = ["persona-app-builder", "persona-dataclaw-builder"];
|
|
64457
64664
|
var DEV_SERVER_READY_TIMEOUT_MS = 3e4;
|
|
64458
64665
|
async function recoverInterruptedPublishJobs(store, logger) {
|
|
@@ -64533,7 +64740,7 @@ function buildAppBuilderHandlers(deps) {
|
|
|
64533
64740
|
async function listAllUsersProjects() {
|
|
64534
64741
|
if (!deps.usersRoot || !deps.getStore) return [];
|
|
64535
64742
|
const getStore = deps.getStore;
|
|
64536
|
-
const userIds = await
|
|
64743
|
+
const userIds = await import_node_fs52.promises.readdir(deps.usersRoot).catch(() => []);
|
|
64537
64744
|
const perUser = await Promise.all(
|
|
64538
64745
|
userIds.map((uid) => getStore(uid).list().catch(() => []))
|
|
64539
64746
|
);
|
|
@@ -64602,8 +64809,8 @@ function buildAppBuilderHandlers(deps) {
|
|
|
64602
64809
|
const project = await userStore.create(f.name, reservedPorts);
|
|
64603
64810
|
try {
|
|
64604
64811
|
const personaRoot = deps.resolvePersonaRoot ? deps.resolvePersonaRoot(session.ownerPersonaId ?? "") : deps.personaRoot;
|
|
64605
|
-
const templateSrcDir = (0,
|
|
64606
|
-
const scaffoldScript = (0,
|
|
64812
|
+
const templateSrcDir = (0, import_node_path65.join)(personaRoot, "extension-kit", "examples", DEFAULT_TEMPLATE);
|
|
64813
|
+
const scaffoldScript = (0, import_node_path65.join)(deps.deployKitRoot, "scripts", "new-extension.sh");
|
|
64607
64814
|
const scaffoldResult = await userStore.scaffold(project.name, templateSrcDir, scaffoldScript);
|
|
64608
64815
|
deps.logger?.info("app-builder.scaffold.done", {
|
|
64609
64816
|
name: project.name,
|
|
@@ -64807,7 +65014,7 @@ function buildAppBuilderHandlers(deps) {
|
|
|
64807
65014
|
await userStore.clearPublishJob(args.name);
|
|
64808
65015
|
}
|
|
64809
65016
|
const personaRoot = deps.resolvePersonaRoot ? deps.resolvePersonaRoot(boundSession.ownerPersonaId ?? "") : deps.personaRoot;
|
|
64810
|
-
const scriptPath = (0,
|
|
65017
|
+
const scriptPath = (0, import_node_path65.join)(deps.deployKitRoot, "scripts", "publish.sh");
|
|
64811
65018
|
deps.logger?.info("app-builder.publish.start", {
|
|
64812
65019
|
name: args.name,
|
|
64813
65020
|
sessionId: boundSession.sessionId,
|
|
@@ -65363,20 +65570,20 @@ function mapPrState(state, isDraft) {
|
|
|
65363
65570
|
if (state === "CLOSED") return "closed";
|
|
65364
65571
|
return isDraft === true ? "draft" : "open";
|
|
65365
65572
|
}
|
|
65366
|
-
function
|
|
65573
|
+
function asRecord2(v2) {
|
|
65367
65574
|
return typeof v2 === "object" && v2 !== null ? v2 : {};
|
|
65368
65575
|
}
|
|
65369
65576
|
function lastCommitRollup(node) {
|
|
65370
|
-
const first =
|
|
65371
|
-
return
|
|
65577
|
+
const first = asRecord2(node.commits).nodes?.[0];
|
|
65578
|
+
return asRecord2(asRecord2(first).commit).statusCheckRollup;
|
|
65372
65579
|
}
|
|
65373
65580
|
function parsePrListResponse(json) {
|
|
65374
|
-
const nodes =
|
|
65581
|
+
const nodes = asRecord2(asRecord2(asRecord2(json).data).search).nodes ?? [];
|
|
65375
65582
|
const items = [];
|
|
65376
65583
|
for (const raw of nodes) {
|
|
65377
|
-
const n =
|
|
65584
|
+
const n = asRecord2(raw);
|
|
65378
65585
|
if (typeof n.number !== "number") continue;
|
|
65379
|
-
const nameWithOwner = String(
|
|
65586
|
+
const nameWithOwner = String(asRecord2(n.repository).nameWithOwner ?? "");
|
|
65380
65587
|
const slash = nameWithOwner.indexOf("/");
|
|
65381
65588
|
if (slash <= 0) continue;
|
|
65382
65589
|
const rollup = lastCommitRollup(n);
|
|
@@ -65390,27 +65597,27 @@ function parsePrListResponse(json) {
|
|
|
65390
65597
|
additions: typeof n.additions === "number" ? n.additions : 0,
|
|
65391
65598
|
deletions: typeof n.deletions === "number" ? n.deletions : 0,
|
|
65392
65599
|
updatedAt: String(n.updatedAt ?? ""),
|
|
65393
|
-
author: String(
|
|
65394
|
-
checksRollup: rollup == null ? "none" : mapRollupState(
|
|
65600
|
+
author: String(asRecord2(n.author).login ?? ""),
|
|
65601
|
+
checksRollup: rollup == null ? "none" : mapRollupState(asRecord2(rollup).state)
|
|
65395
65602
|
});
|
|
65396
65603
|
}
|
|
65397
65604
|
return items;
|
|
65398
65605
|
}
|
|
65399
65606
|
function parsePrDetailResponse(json, repoRef) {
|
|
65400
|
-
const pr =
|
|
65607
|
+
const pr = asRecord2(asRecord2(asRecord2(json).data).repository).pullRequest;
|
|
65401
65608
|
if (pr == null || typeof pr !== "object") return null;
|
|
65402
|
-
const n =
|
|
65609
|
+
const n = asRecord2(pr);
|
|
65403
65610
|
const rollup = lastCommitRollup(n);
|
|
65404
|
-
const contextNodes =
|
|
65611
|
+
const contextNodes = asRecord2(asRecord2(rollup).contexts).nodes ?? [];
|
|
65405
65612
|
const checks = [];
|
|
65406
65613
|
for (const c of contextNodes) {
|
|
65407
|
-
const mapped = mapCheckNode(
|
|
65614
|
+
const mapped = mapCheckNode(asRecord2(c));
|
|
65408
65615
|
if (mapped) checks.push(mapped);
|
|
65409
65616
|
}
|
|
65410
|
-
const reviewerNodes =
|
|
65411
|
-
const reviewers = reviewerNodes.map((r) => String(
|
|
65617
|
+
const reviewerNodes = asRecord2(n.reviewRequests).nodes ?? [];
|
|
65618
|
+
const reviewers = reviewerNodes.map((r) => String(asRecord2(asRecord2(r).requestedReviewer).login ?? "")).filter((s) => s !== "");
|
|
65412
65619
|
const mergeable = n.mergeable === "MERGEABLE" ? "mergeable" : n.mergeable === "CONFLICTING" ? "conflicting" : "unknown";
|
|
65413
|
-
const commentCountRaw =
|
|
65620
|
+
const commentCountRaw = asRecord2(n.comments).totalCount;
|
|
65414
65621
|
return {
|
|
65415
65622
|
owner: repoRef.owner,
|
|
65416
65623
|
repo: repoRef.repo,
|
|
@@ -65418,7 +65625,7 @@ function parsePrDetailResponse(json, repoRef) {
|
|
|
65418
65625
|
title: String(n.title ?? ""),
|
|
65419
65626
|
body: String(n.body ?? ""),
|
|
65420
65627
|
state: mapPrState(n.state, n.isDraft),
|
|
65421
|
-
author: String(
|
|
65628
|
+
author: String(asRecord2(n.author).login ?? ""),
|
|
65422
65629
|
updatedAt: String(n.updatedAt ?? ""),
|
|
65423
65630
|
headRef: String(n.headRefName ?? ""),
|
|
65424
65631
|
baseRef: String(n.baseRefName ?? ""),
|
|
@@ -65428,7 +65635,7 @@ function parsePrDetailResponse(json, repoRef) {
|
|
|
65428
65635
|
mergeable,
|
|
65429
65636
|
reviewers,
|
|
65430
65637
|
commentCount: typeof commentCountRaw === "number" ? commentCountRaw : 0,
|
|
65431
|
-
checksRollup: rollup == null ? "none" : mapRollupState(
|
|
65638
|
+
checksRollup: rollup == null ? "none" : mapRollupState(asRecord2(rollup).state),
|
|
65432
65639
|
checks
|
|
65433
65640
|
};
|
|
65434
65641
|
}
|
|
@@ -65566,7 +65773,7 @@ function buildVisitorHandlers(deps) {
|
|
|
65566
65773
|
|
|
65567
65774
|
// src/extension/registry.ts
|
|
65568
65775
|
var import_promises14 = __toESM(require("fs/promises"), 1);
|
|
65569
|
-
var
|
|
65776
|
+
var import_node_path66 = __toESM(require("path"), 1);
|
|
65570
65777
|
async function loadAll(root) {
|
|
65571
65778
|
let entries;
|
|
65572
65779
|
try {
|
|
@@ -65579,13 +65786,13 @@ async function loadAll(root) {
|
|
|
65579
65786
|
for (const ent of entries) {
|
|
65580
65787
|
if (!ent.isDirectory()) continue;
|
|
65581
65788
|
if (ent.name.startsWith(".")) continue;
|
|
65582
|
-
records.push(await loadOne(
|
|
65789
|
+
records.push(await loadOne(import_node_path66.default.join(root, ent.name), ent.name));
|
|
65583
65790
|
}
|
|
65584
65791
|
records.sort((a, b2) => a.extId < b2.extId ? -1 : a.extId > b2.extId ? 1 : 0);
|
|
65585
65792
|
return records;
|
|
65586
65793
|
}
|
|
65587
65794
|
async function loadOne(dir, dirName) {
|
|
65588
|
-
const manifestPath =
|
|
65795
|
+
const manifestPath = import_node_path66.default.join(dir, "manifest.json");
|
|
65589
65796
|
let raw;
|
|
65590
65797
|
try {
|
|
65591
65798
|
raw = await import_promises14.default.readFile(manifestPath, "utf8");
|
|
@@ -65630,7 +65837,7 @@ async function loadOne(dir, dirName) {
|
|
|
65630
65837
|
|
|
65631
65838
|
// src/extension/uninstall.ts
|
|
65632
65839
|
var import_promises15 = __toESM(require("fs/promises"), 1);
|
|
65633
|
-
var
|
|
65840
|
+
var import_node_path67 = __toESM(require("path"), 1);
|
|
65634
65841
|
var UninstallError = class extends Error {
|
|
65635
65842
|
constructor(code, message) {
|
|
65636
65843
|
super(message);
|
|
@@ -65639,7 +65846,7 @@ var UninstallError = class extends Error {
|
|
|
65639
65846
|
code;
|
|
65640
65847
|
};
|
|
65641
65848
|
async function uninstall(deps) {
|
|
65642
|
-
const dir =
|
|
65849
|
+
const dir = import_node_path67.default.join(deps.root, deps.extId);
|
|
65643
65850
|
try {
|
|
65644
65851
|
await import_promises15.default.access(dir);
|
|
65645
65852
|
} catch {
|
|
@@ -65657,14 +65864,14 @@ init_protocol();
|
|
|
65657
65864
|
|
|
65658
65865
|
// src/peer-ops/run-command.ts
|
|
65659
65866
|
var import_node_child_process18 = require("child_process");
|
|
65660
|
-
var
|
|
65867
|
+
var import_node_os24 = __toESM(require("os"), 1);
|
|
65661
65868
|
var DEFAULT_TIMEOUT_MS5 = 3e4;
|
|
65662
65869
|
var MAX_TIMEOUT_MS = 3e5;
|
|
65663
65870
|
var MAX_OUTPUT_BYTES = 1048576;
|
|
65664
65871
|
function runCommand(command, opts = {}) {
|
|
65665
65872
|
const timeoutMs = Math.min(opts.timeoutMs ?? DEFAULT_TIMEOUT_MS5, MAX_TIMEOUT_MS);
|
|
65666
65873
|
return new Promise((resolve9) => {
|
|
65667
|
-
const child = (0, import_node_child_process18.spawn)("bash", ["-c", command], { cwd:
|
|
65874
|
+
const child = (0, import_node_child_process18.spawn)("bash", ["-c", command], { cwd: import_node_os24.default.homedir() });
|
|
65668
65875
|
const out = [];
|
|
65669
65876
|
const err = [];
|
|
65670
65877
|
let outBytes = 0;
|
|
@@ -65872,7 +66079,7 @@ function buildMethodHandlers(deps) {
|
|
|
65872
66079
|
broadcast: deps.broadcastToOwners
|
|
65873
66080
|
}),
|
|
65874
66081
|
...buildMasterHandlers({
|
|
65875
|
-
authorityTablePath:
|
|
66082
|
+
authorityTablePath: import_node_path68.default.join(deps.masterDataDir, "master-authority.json")
|
|
65876
66083
|
}),
|
|
65877
66084
|
...buildTopicHandlers({
|
|
65878
66085
|
topicStore: deps.topicStore,
|
|
@@ -65908,18 +66115,18 @@ init_claude();
|
|
|
65908
66115
|
|
|
65909
66116
|
// src/tools/shell-path.ts
|
|
65910
66117
|
var import_node_child_process19 = require("child_process");
|
|
65911
|
-
var
|
|
66118
|
+
var import_node_os25 = __toESM(require("os"), 1);
|
|
65912
66119
|
function refreshPathFromLoginShell() {
|
|
65913
66120
|
if (process.platform === "win32") return;
|
|
65914
|
-
const shell = process.env.SHELL ??
|
|
66121
|
+
const shell = process.env.SHELL ?? import_node_os25.default.userInfo().shell ?? "/bin/zsh";
|
|
65915
66122
|
try {
|
|
65916
66123
|
const out = (0, import_node_child_process19.execFileSync)(shell, ["-ilc", 'command echo -n "$PATH"'], {
|
|
65917
66124
|
encoding: "utf8",
|
|
65918
66125
|
timeout: 3e3,
|
|
65919
66126
|
stdio: ["ignore", "pipe", "ignore"]
|
|
65920
66127
|
});
|
|
65921
|
-
const
|
|
65922
|
-
if (
|
|
66128
|
+
const path91 = out.trim();
|
|
66129
|
+
if (path91) process.env.PATH = path91;
|
|
65923
66130
|
} catch {
|
|
65924
66131
|
}
|
|
65925
66132
|
}
|
|
@@ -66333,7 +66540,7 @@ async function dispatchRpc(method, frame, client, ctx, deps) {
|
|
|
66333
66540
|
|
|
66334
66541
|
// src/extension/runtime.ts
|
|
66335
66542
|
var import_node_child_process22 = require("child_process");
|
|
66336
|
-
var
|
|
66543
|
+
var import_node_path69 = __toESM(require("path"), 1);
|
|
66337
66544
|
var import_promises16 = require("timers/promises");
|
|
66338
66545
|
|
|
66339
66546
|
// src/extension/port-allocator.ts
|
|
@@ -66434,7 +66641,7 @@ var Runtime = class {
|
|
|
66434
66641
|
/\$CLAWOS_EXT_PORT/g,
|
|
66435
66642
|
String(port)
|
|
66436
66643
|
);
|
|
66437
|
-
const dir =
|
|
66644
|
+
const dir = import_node_path69.default.join(this.root, extId);
|
|
66438
66645
|
const env = {
|
|
66439
66646
|
...process.env,
|
|
66440
66647
|
CLAWOS_EXT_PORT: String(port),
|
|
@@ -66546,7 +66753,7 @@ ${handle.stderrTail}`
|
|
|
66546
66753
|
|
|
66547
66754
|
// src/extension/published-channels.ts
|
|
66548
66755
|
var import_promises17 = __toESM(require("fs/promises"), 1);
|
|
66549
|
-
var
|
|
66756
|
+
var import_node_path70 = __toESM(require("path"), 1);
|
|
66550
66757
|
init_zod();
|
|
66551
66758
|
var PublishedChannelsError = class extends Error {
|
|
66552
66759
|
constructor(code, message) {
|
|
@@ -66645,7 +66852,7 @@ var PublishedChannelStore = class {
|
|
|
66645
66852
|
)
|
|
66646
66853
|
};
|
|
66647
66854
|
const tmp = `${this.filePath}.tmp`;
|
|
66648
|
-
await import_promises17.default.mkdir(
|
|
66855
|
+
await import_promises17.default.mkdir(import_node_path70.default.dirname(this.filePath), { recursive: true });
|
|
66649
66856
|
await import_promises17.default.writeFile(tmp, JSON.stringify(data, null, 2), { mode: 384 });
|
|
66650
66857
|
await import_promises17.default.rename(tmp, this.filePath);
|
|
66651
66858
|
}
|
|
@@ -66653,7 +66860,7 @@ var PublishedChannelStore = class {
|
|
|
66653
66860
|
|
|
66654
66861
|
// src/extension/bundle-cache.ts
|
|
66655
66862
|
var import_promises18 = __toESM(require("fs/promises"), 1);
|
|
66656
|
-
var
|
|
66863
|
+
var import_node_path71 = __toESM(require("path"), 1);
|
|
66657
66864
|
var BundleCache = class {
|
|
66658
66865
|
constructor(rootDir) {
|
|
66659
66866
|
this.rootDir = rootDir;
|
|
@@ -66662,14 +66869,14 @@ var BundleCache = class {
|
|
|
66662
66869
|
/** Atomic write: stage tmp → rename. Caller passes the hex sha256. */
|
|
66663
66870
|
async write(snapshotHash, buffer) {
|
|
66664
66871
|
await import_promises18.default.mkdir(this.rootDir, { recursive: true });
|
|
66665
|
-
const file =
|
|
66872
|
+
const file = import_node_path71.default.join(this.rootDir, `${snapshotHash}.zip`);
|
|
66666
66873
|
const tmp = `${file}.tmp`;
|
|
66667
66874
|
await import_promises18.default.writeFile(tmp, buffer, { mode: 384 });
|
|
66668
66875
|
await import_promises18.default.rename(tmp, file);
|
|
66669
66876
|
}
|
|
66670
66877
|
/** Returns the bundle bytes, or null when the file doesn't exist. */
|
|
66671
66878
|
async read(snapshotHash) {
|
|
66672
|
-
const file =
|
|
66879
|
+
const file = import_node_path71.default.join(this.rootDir, `${snapshotHash}.zip`);
|
|
66673
66880
|
try {
|
|
66674
66881
|
return await import_promises18.default.readFile(file);
|
|
66675
66882
|
} catch (e) {
|
|
@@ -66679,7 +66886,7 @@ var BundleCache = class {
|
|
|
66679
66886
|
}
|
|
66680
66887
|
/** Idempotent — missing file is not an error. */
|
|
66681
66888
|
async delete(snapshotHash) {
|
|
66682
|
-
const file =
|
|
66889
|
+
const file = import_node_path71.default.join(this.rootDir, `${snapshotHash}.zip`);
|
|
66683
66890
|
await import_promises18.default.rm(file, { force: true });
|
|
66684
66891
|
}
|
|
66685
66892
|
};
|
|
@@ -66700,26 +66907,26 @@ async function startDaemon(config) {
|
|
|
66700
66907
|
},
|
|
66701
66908
|
source: "daemon",
|
|
66702
66909
|
sampling: logShippingCfg.sampling,
|
|
66703
|
-
homeDir:
|
|
66910
|
+
homeDir: import_node_os26.default.homedir()
|
|
66704
66911
|
});
|
|
66705
|
-
const logDir =
|
|
66706
|
-
|
|
66912
|
+
const logDir = import_node_path72.default.join(config.dataDir, "log");
|
|
66913
|
+
import_node_fs53.default.mkdirSync(logDir, { recursive: true });
|
|
66707
66914
|
const logger = createLogger({
|
|
66708
66915
|
level: config.logLevel,
|
|
66709
|
-
file:
|
|
66916
|
+
file: import_node_path72.default.join(logDir, "clawd.log"),
|
|
66710
66917
|
logClient
|
|
66711
66918
|
});
|
|
66712
66919
|
logger.info("starting clawd", { version, config: { port: config.port, host: config.host, dataDir: config.dataDir } });
|
|
66713
66920
|
const screenIdleProbeLogger = createFileOnlyLogger({
|
|
66714
|
-
file:
|
|
66921
|
+
file: import_node_path72.default.join(logDir, "screen-idle-probe.log"),
|
|
66715
66922
|
level: "debug"
|
|
66716
66923
|
});
|
|
66717
66924
|
logger.info("screen-idle probe logger enabled", {
|
|
66718
|
-
file:
|
|
66925
|
+
file: import_node_path72.default.join(logDir, "screen-idle-probe.log")
|
|
66719
66926
|
});
|
|
66720
66927
|
const CAP_TARGETS = [
|
|
66721
|
-
|
|
66722
|
-
|
|
66928
|
+
import_node_path72.default.join(logDir, "clawd.log"),
|
|
66929
|
+
import_node_path72.default.join(logDir, "screen-idle-probe.log")
|
|
66723
66930
|
];
|
|
66724
66931
|
const LOG_CAP_MAX_BYTES = 10 * 1024 * 1024;
|
|
66725
66932
|
const LOG_CAP_KEEP_BYTES = 5 * 1024 * 1024;
|
|
@@ -66841,8 +67048,8 @@ async function startDaemon(config) {
|
|
|
66841
67048
|
const agents = new AgentsScanner();
|
|
66842
67049
|
const history = new ClaudeHistoryReader();
|
|
66843
67050
|
let transport = null;
|
|
66844
|
-
const personaStore = new PersonaStore(
|
|
66845
|
-
const usersRoot =
|
|
67051
|
+
const personaStore = new PersonaStore(import_node_path72.default.join(config.dataDir, "personas"));
|
|
67052
|
+
const usersRoot = import_node_path72.default.join(config.dataDir, "users");
|
|
66846
67053
|
const defaultsRoot = findDefaultsRoot(logger);
|
|
66847
67054
|
if (defaultsRoot) {
|
|
66848
67055
|
seedDefaultPersonas({ store: personaStore, defaultsRoot, logger });
|
|
@@ -66866,7 +67073,7 @@ async function startDaemon(config) {
|
|
|
66866
67073
|
retirePersonaBuilder({ store: personaStore, logger });
|
|
66867
67074
|
const groupFileStore = new GroupFileStore({ dataDir: config.dataDir, logger });
|
|
66868
67075
|
const dispatchStore = createDispatchStore({
|
|
66869
|
-
filePath:
|
|
67076
|
+
filePath: import_node_path72.default.join(config.dataDir, "dispatch.json"),
|
|
66870
67077
|
now: () => Date.now(),
|
|
66871
67078
|
onFlushError: (err) => logger.error("dispatch store flush failed", {
|
|
66872
67079
|
reason: err instanceof Error ? err.message : String(err)
|
|
@@ -66875,7 +67082,7 @@ async function startDaemon(config) {
|
|
|
66875
67082
|
await dispatchStore.load();
|
|
66876
67083
|
dispatchStore.markInterruptedAsFailed((/* @__PURE__ */ new Date()).toISOString());
|
|
66877
67084
|
const channelStore = createChannelStore({
|
|
66878
|
-
filePath:
|
|
67085
|
+
filePath: import_node_path72.default.join(config.dataDir, "channels.json"),
|
|
66879
67086
|
now: () => Date.now(),
|
|
66880
67087
|
genId: () => `ch-${(0, import_node_crypto22.randomUUID)().slice(0, 8)}`,
|
|
66881
67088
|
onFlushError: (err) => logger.error("channel store flush failed", {
|
|
@@ -66884,7 +67091,7 @@ async function startDaemon(config) {
|
|
|
66884
67091
|
});
|
|
66885
67092
|
await channelStore.load();
|
|
66886
67093
|
const topicStore = createTopicStore({
|
|
66887
|
-
filePath:
|
|
67094
|
+
filePath: import_node_path72.default.join(config.dataDir, "topics.json"),
|
|
66888
67095
|
now: () => Date.now(),
|
|
66889
67096
|
genId: () => `tp-${(0, import_node_crypto22.randomUUID)().slice(0, 8)}`,
|
|
66890
67097
|
onFlushError: (err) => logger.error("topic store flush failed", {
|
|
@@ -66911,18 +67118,18 @@ async function startDaemon(config) {
|
|
|
66911
67118
|
});
|
|
66912
67119
|
}
|
|
66913
67120
|
});
|
|
66914
|
-
const here = typeof __dirname === "string" ? __dirname :
|
|
67121
|
+
const here = typeof __dirname === "string" ? __dirname : import_node_path72.default.dirname((0, import_node_url4.fileURLToPath)(import_meta7.url));
|
|
66915
67122
|
const mcpConfigs = [];
|
|
66916
67123
|
const mcpDaemonUrl = `http://127.0.0.1:${config.port}`;
|
|
66917
67124
|
const dispatchServerCandidates = [
|
|
66918
|
-
|
|
67125
|
+
import_node_path72.default.join(here, "dispatch", "mcp-server.cjs"),
|
|
66919
67126
|
// 生产 dist/index → dist/dispatch/mcp-server.cjs
|
|
66920
|
-
|
|
67127
|
+
import_node_path72.default.join(here, "..", "dist", "dispatch", "mcp-server.cjs")
|
|
66921
67128
|
// dev tsx src/index → ../dist/dispatch/mcp-server.cjs
|
|
66922
67129
|
];
|
|
66923
|
-
const dispatchServerScriptPath = dispatchServerCandidates.find((p2) =>
|
|
67130
|
+
const dispatchServerScriptPath = dispatchServerCandidates.find((p2) => import_node_fs53.default.existsSync(p2));
|
|
66924
67131
|
if (dispatchServerScriptPath) {
|
|
66925
|
-
const dispatchLogPath =
|
|
67132
|
+
const dispatchLogPath = import_node_path72.default.join(logDir, "dispatch-mcp-server.log");
|
|
66926
67133
|
const dispatchCfgPath = writeDispatchMcpConfig({
|
|
66927
67134
|
dataDir: config.dataDir,
|
|
66928
67135
|
serverScriptPath: dispatchServerScriptPath,
|
|
@@ -66942,12 +67149,12 @@ async function startDaemon(config) {
|
|
|
66942
67149
|
});
|
|
66943
67150
|
}
|
|
66944
67151
|
const ticketServerCandidates = [
|
|
66945
|
-
|
|
66946
|
-
|
|
67152
|
+
import_node_path72.default.join(here, "ticket", "mcp-server.cjs"),
|
|
67153
|
+
import_node_path72.default.join(here, "..", "dist", "ticket", "mcp-server.cjs")
|
|
66947
67154
|
];
|
|
66948
|
-
const ticketServerScriptPath = ticketServerCandidates.find((p2) =>
|
|
67155
|
+
const ticketServerScriptPath = ticketServerCandidates.find((p2) => import_node_fs53.default.existsSync(p2));
|
|
66949
67156
|
if (ticketServerScriptPath) {
|
|
66950
|
-
const ticketLogPath =
|
|
67157
|
+
const ticketLogPath = import_node_path72.default.join(logDir, "ticket-mcp-server.log");
|
|
66951
67158
|
const ticketCfgPath = writeTicketMcpConfig({
|
|
66952
67159
|
dataDir: config.dataDir,
|
|
66953
67160
|
serverScriptPath: ticketServerScriptPath,
|
|
@@ -66969,12 +67176,12 @@ async function startDaemon(config) {
|
|
|
66969
67176
|
});
|
|
66970
67177
|
}
|
|
66971
67178
|
const shiftServerCandidates = [
|
|
66972
|
-
|
|
66973
|
-
|
|
67179
|
+
import_node_path72.default.join(here, "shift", "mcp-server.cjs"),
|
|
67180
|
+
import_node_path72.default.join(here, "..", "dist", "shift", "mcp-server.cjs")
|
|
66974
67181
|
];
|
|
66975
|
-
const shiftServerScriptPath = shiftServerCandidates.find((p2) =>
|
|
67182
|
+
const shiftServerScriptPath = shiftServerCandidates.find((p2) => import_node_fs53.default.existsSync(p2));
|
|
66976
67183
|
if (shiftServerScriptPath) {
|
|
66977
|
-
const shiftLogPath =
|
|
67184
|
+
const shiftLogPath = import_node_path72.default.join(logDir, "shift-mcp-server.log");
|
|
66978
67185
|
const shiftCfgPath = await writeShiftMcpConfig({
|
|
66979
67186
|
dataDir: config.dataDir,
|
|
66980
67187
|
serverScriptPath: shiftServerScriptPath,
|
|
@@ -66995,12 +67202,12 @@ async function startDaemon(config) {
|
|
|
66995
67202
|
);
|
|
66996
67203
|
}
|
|
66997
67204
|
const inboxServerCandidates = [
|
|
66998
|
-
|
|
66999
|
-
|
|
67205
|
+
import_node_path72.default.join(here, "inbox", "mcp-server.cjs"),
|
|
67206
|
+
import_node_path72.default.join(here, "..", "dist", "inbox", "mcp-server.cjs")
|
|
67000
67207
|
];
|
|
67001
|
-
const inboxServerScriptPath = inboxServerCandidates.find((p2) =>
|
|
67208
|
+
const inboxServerScriptPath = inboxServerCandidates.find((p2) => import_node_fs53.default.existsSync(p2));
|
|
67002
67209
|
if (inboxServerScriptPath) {
|
|
67003
|
-
const inboxLogPath =
|
|
67210
|
+
const inboxLogPath = import_node_path72.default.join(logDir, "inbox-mcp-server.log");
|
|
67004
67211
|
const inboxCfgPath = await writeInboxMcpConfig({
|
|
67005
67212
|
dataDir: config.dataDir,
|
|
67006
67213
|
serverScriptPath: inboxServerScriptPath,
|
|
@@ -67021,10 +67228,10 @@ async function startDaemon(config) {
|
|
|
67021
67228
|
);
|
|
67022
67229
|
}
|
|
67023
67230
|
const peerOpsServerCandidates = [
|
|
67024
|
-
|
|
67025
|
-
|
|
67231
|
+
import_node_path72.default.join(here, "peer-ops", "mcp-server.cjs"),
|
|
67232
|
+
import_node_path72.default.join(here, "..", "dist", "peer-ops", "mcp-server.cjs")
|
|
67026
67233
|
];
|
|
67027
|
-
const peerOpsServerScriptPath = peerOpsServerCandidates.find((p2) =>
|
|
67234
|
+
const peerOpsServerScriptPath = peerOpsServerCandidates.find((p2) => import_node_fs53.default.existsSync(p2));
|
|
67028
67235
|
if (peerOpsServerScriptPath) {
|
|
67029
67236
|
const peerOpsCfgPath = writePeerOpsMcpConfig({
|
|
67030
67237
|
dataDir: config.dataDir,
|
|
@@ -67044,12 +67251,12 @@ async function startDaemon(config) {
|
|
|
67044
67251
|
);
|
|
67045
67252
|
}
|
|
67046
67253
|
const rpcToolServerCandidates = [
|
|
67047
|
-
|
|
67048
|
-
|
|
67254
|
+
import_node_path72.default.join(here, "rpc-tool", "mcp-server.cjs"),
|
|
67255
|
+
import_node_path72.default.join(here, "..", "dist", "rpc-tool", "mcp-server.cjs")
|
|
67049
67256
|
];
|
|
67050
|
-
const rpcToolServerScriptPath = rpcToolServerCandidates.find((p2) =>
|
|
67257
|
+
const rpcToolServerScriptPath = rpcToolServerCandidates.find((p2) => import_node_fs53.default.existsSync(p2));
|
|
67051
67258
|
if (rpcToolServerScriptPath) {
|
|
67052
|
-
const rpcToolLogPath =
|
|
67259
|
+
const rpcToolLogPath = import_node_path72.default.join(logDir, "rpc-tool-mcp-server.log");
|
|
67053
67260
|
const rpcToolCfgPath = writeRpcToolMcpConfig({
|
|
67054
67261
|
dataDir: config.dataDir,
|
|
67055
67262
|
serverScriptPath: rpcToolServerScriptPath,
|
|
@@ -67070,7 +67277,7 @@ async function startDaemon(config) {
|
|
|
67070
67277
|
);
|
|
67071
67278
|
}
|
|
67072
67279
|
const shiftStore = createShiftStore({
|
|
67073
|
-
filePath:
|
|
67280
|
+
filePath: import_node_path72.default.join(config.dataDir, "shift.json"),
|
|
67074
67281
|
ownerIdProvider: () => ownerPrincipalId,
|
|
67075
67282
|
now: () => Date.now()
|
|
67076
67283
|
});
|
|
@@ -67092,7 +67299,7 @@ async function startDaemon(config) {
|
|
|
67092
67299
|
getAdapter,
|
|
67093
67300
|
historyReader: history,
|
|
67094
67301
|
dataDir: config.dataDir,
|
|
67095
|
-
personaRoot:
|
|
67302
|
+
personaRoot: import_node_path72.default.join(config.dataDir, "personas"),
|
|
67096
67303
|
// dispatch / shift 自动化 spawn 按 persona 绑定 tool 起 B session(codex persona 用 codex)。
|
|
67097
67304
|
// personaRegistry 声明在 manager 之后(同作用域 const,调用时机在启动完成后,无 TDZ 风险)。
|
|
67098
67305
|
getPersonaDefaults: (personaId2) => personaRegistry.get(personaId2),
|
|
@@ -67146,10 +67353,10 @@ async function startDaemon(config) {
|
|
|
67146
67353
|
// 文件可能 agent 写完又被自己删(罕见),用 size=0 / fallback mime 兜底。
|
|
67147
67354
|
attachmentGroup: {
|
|
67148
67355
|
onFileEdit: (input) => {
|
|
67149
|
-
const absPath =
|
|
67356
|
+
const absPath = import_node_path72.default.isAbsolute(input.relPath) ? input.relPath : import_node_path72.default.join(input.cwd, input.relPath);
|
|
67150
67357
|
let size = 0;
|
|
67151
67358
|
try {
|
|
67152
|
-
size =
|
|
67359
|
+
size = import_node_fs53.default.statSync(absPath).size;
|
|
67153
67360
|
} catch (err) {
|
|
67154
67361
|
logger.warn("attachment.onFileEdit stat failed", {
|
|
67155
67362
|
sessionId: input.sessionId,
|
|
@@ -67179,9 +67386,9 @@ async function startDaemon(config) {
|
|
|
67179
67386
|
logger.info("projects.seed-dropped", { dropped: droppedSeed.dropped, backup: droppedSeed.backup });
|
|
67180
67387
|
}
|
|
67181
67388
|
const projectsStore = new ProjectsStore({
|
|
67182
|
-
file:
|
|
67389
|
+
file: import_node_path72.default.join(config.dataDir, "projects.json"),
|
|
67183
67390
|
clawdDir: config.dataDir,
|
|
67184
|
-
codexStateFile:
|
|
67391
|
+
codexStateFile: import_node_path72.default.join(import_node_os26.default.homedir(), ".codex", ".codex-global-state.json"),
|
|
67185
67392
|
logger
|
|
67186
67393
|
});
|
|
67187
67394
|
const observer = new SessionObserver({
|
|
@@ -67241,13 +67448,13 @@ async function startDaemon(config) {
|
|
|
67241
67448
|
screenIdleProbeLogger
|
|
67242
67449
|
}) : new ClaudeAdapter({ logger, historyReader: new ClaudeHistoryReader() });
|
|
67243
67450
|
registerAdapter("claude", claudeAdapter);
|
|
67244
|
-
const codexIsolatedHome =
|
|
67451
|
+
const codexIsolatedHome = import_node_path72.default.join(config.dataDir, "codex-home");
|
|
67245
67452
|
try {
|
|
67246
|
-
|
|
67453
|
+
import_node_fs53.default.mkdirSync(codexIsolatedHome, { recursive: true });
|
|
67247
67454
|
for (const f of ["auth.json", "config.toml"]) {
|
|
67248
|
-
const link =
|
|
67249
|
-
const target =
|
|
67250
|
-
if (!
|
|
67455
|
+
const link = import_node_path72.default.join(codexIsolatedHome, f);
|
|
67456
|
+
const target = import_node_path72.default.join(import_node_os26.default.homedir(), ".codex", f);
|
|
67457
|
+
if (!import_node_fs53.default.existsSync(link) && import_node_fs53.default.existsSync(target)) import_node_fs53.default.symlinkSync(target, link);
|
|
67251
67458
|
}
|
|
67252
67459
|
} catch (err) {
|
|
67253
67460
|
logger.warn("codex isolated home setup failed", { err: String(err) });
|
|
@@ -67260,11 +67467,11 @@ async function startDaemon(config) {
|
|
|
67260
67467
|
// projectPaths 每次调用现取 —— 用户新建 project 后立即生效,不用重启 daemon
|
|
67261
67468
|
codexHomeFor: (cwd) => resolveCodexHome({
|
|
67262
67469
|
cwd,
|
|
67263
|
-
personaRoot:
|
|
67470
|
+
personaRoot: import_node_path72.default.join(config.dataDir, "personas"),
|
|
67264
67471
|
// 必须用 listMerged(Codex registry ∪ 叠加层):只用本地 list() 的话,用户在
|
|
67265
67472
|
// Codex 里建的 project 不在表里,在它下面开的会话会被误判成隔离 → Codex 侧看不到
|
|
67266
67473
|
projectPaths: projectsStore.listMerged().map((x) => x.path),
|
|
67267
|
-
sharedHome:
|
|
67474
|
+
sharedHome: import_node_path72.default.join(import_node_os26.default.homedir(), ".codex"),
|
|
67268
67475
|
isolatedHome: codexIsolatedHome
|
|
67269
67476
|
})
|
|
67270
67477
|
})
|
|
@@ -67548,11 +67755,11 @@ async function startDaemon(config) {
|
|
|
67548
67755
|
// 'persona/<pid>/owner',default 走 'default'。
|
|
67549
67756
|
getSessionScope: (sid) => manager.findOwnedSessionScope(sid),
|
|
67550
67757
|
// guest path guard:candidate 必须在 personaRoot 子树或调用者自己的 user-dir 下
|
|
67551
|
-
personaRoot:
|
|
67758
|
+
personaRoot: import_node_path72.default.join(config.dataDir, "personas"),
|
|
67552
67759
|
usersRoot
|
|
67553
67760
|
},
|
|
67554
67761
|
// workspace/git/history/skills/agents handler 共用的 guest path guard 锚点
|
|
67555
|
-
personaRoot:
|
|
67762
|
+
personaRoot: import_node_path72.default.join(config.dataDir, "personas"),
|
|
67556
67763
|
// v2 多人 persona 隔离:handler 派生 guest user-dir 放行
|
|
67557
67764
|
usersRoot,
|
|
67558
67765
|
// v2 Phase 6: whoami handler 装在 owner principal.displayName + persona 解析
|
|
@@ -67651,11 +67858,11 @@ async function startDaemon(config) {
|
|
|
67651
67858
|
// 发布上线脚手架化 (spec 2026-06-03 §5.2):
|
|
67652
67859
|
// appBuilderPersonaRoot 用于拼 publish.sh 绝对路径(persona-app-builder 安装在
|
|
67653
67860
|
// dataDir/personas/persona-app-builder 之下,extension-kit/scripts/publish.sh 是相对路径)。
|
|
67654
|
-
appBuilderPersonaRoot:
|
|
67861
|
+
appBuilderPersonaRoot: import_node_path72.default.join(config.dataDir, "personas", "persona-app-builder"),
|
|
67655
67862
|
// 共享 deploy-kit 根:scaffold/publish 脚本骨架 + 阿里云凭证单一真源。
|
|
67656
|
-
deployKitRoot:
|
|
67863
|
+
deployKitRoot: import_node_path72.default.join(config.dataDir, "deploy-kit"),
|
|
67657
67864
|
// scaffold/publish 按当前 session 的 persona 解析其安装根,让每个 persona 用自己的模板/注入配置。
|
|
67658
|
-
resolvePersonaRoot: (personaId2) =>
|
|
67865
|
+
resolvePersonaRoot: (personaId2) => import_node_path72.default.join(config.dataDir, "personas", personaId2),
|
|
67659
67866
|
// 发布上线脚手架化 (spec 2026-06-03 §5.2.2):
|
|
67660
67867
|
// 复用 SessionManagerDeps.broadcastFrame 同款 dispatch 逻辑 —— runner 调 manager.send
|
|
67661
67868
|
// 取回 broadcast 帧后逐帧 push 到 transport,跟 manager 自身的 deps 一致。
|
|
@@ -67710,7 +67917,7 @@ async function startDaemon(config) {
|
|
|
67710
67917
|
sourceSessionId: args.sourceSessionId
|
|
67711
67918
|
});
|
|
67712
67919
|
const sourceFile = manager.findOwnedSession(args.sourceSessionId);
|
|
67713
|
-
const sourceJsonlPath = resolveSourceJsonlPath(sourceFile,
|
|
67920
|
+
const sourceJsonlPath = resolveSourceJsonlPath(sourceFile, import_node_os26.default.homedir());
|
|
67714
67921
|
logger.info("dispatch.spawnB.source-resolved", {
|
|
67715
67922
|
dispatchId: args.dispatchId,
|
|
67716
67923
|
sourceJsonlPath,
|
|
@@ -67776,7 +67983,7 @@ async function startDaemon(config) {
|
|
|
67776
67983
|
});
|
|
67777
67984
|
shiftScheduler.start();
|
|
67778
67985
|
logger.info("shift scheduler started", { shiftCount: shiftStore.list().length });
|
|
67779
|
-
const larkBotStore = createLarkBotBindingStore(
|
|
67986
|
+
const larkBotStore = createLarkBotBindingStore(import_node_path72.default.join(config.dataDir, "personas"));
|
|
67780
67987
|
const larkBotCloud = createLarkBotCloudClient({
|
|
67781
67988
|
api: config.clawosApi ?? DEFAULT_CLAWOS_API,
|
|
67782
67989
|
apiKey: resolveClawdTicketsApiKey(),
|
|
@@ -67790,7 +67997,7 @@ async function startDaemon(config) {
|
|
|
67790
67997
|
store: larkBotStore,
|
|
67791
67998
|
fetchResource: (appId, messageId, fileKey, maxBytes, type) => larkBotCloud.fetchResource(appId, messageId, fileKey, maxBytes, type),
|
|
67792
67999
|
// 图片落 guest userWorkDir 下(capId = lark-<chat_id>):CC 经 --add-dir + allowRead carve 可 Read
|
|
67793
|
-
mediaRootFor: (chatId) =>
|
|
68000
|
+
mediaRootFor: (chatId) => import_node_path72.default.join(deriveUserWorkDir(`lark-${chatId}`, usersRoot), "lark-media"),
|
|
67794
68001
|
isShuttingDown: () => larkDraining,
|
|
67795
68002
|
logger: {
|
|
67796
68003
|
warn: (msg) => logger.warn(msg),
|
|
@@ -68095,8 +68302,8 @@ async function startDaemon(config) {
|
|
|
68095
68302
|
const lines = [
|
|
68096
68303
|
`Tunnel: ${r.url}`,
|
|
68097
68304
|
...resolvedAuthToken ? [`Connect: ${connectUrl}`] : [],
|
|
68098
|
-
`Frpc config: ${
|
|
68099
|
-
`Frpc log: ${
|
|
68305
|
+
`Frpc config: ${import_node_path72.default.join(config.dataDir, "frpc.toml")}`,
|
|
68306
|
+
`Frpc log: ${import_node_path72.default.join(logDir, "frpc.log")}`
|
|
68100
68307
|
];
|
|
68101
68308
|
const width2 = Math.max(...lines.map((l) => l.length));
|
|
68102
68309
|
const bar = "\u2550".repeat(width2 + 4);
|
|
@@ -68109,8 +68316,8 @@ ${bar}
|
|
|
68109
68316
|
|
|
68110
68317
|
`);
|
|
68111
68318
|
try {
|
|
68112
|
-
const connectPath =
|
|
68113
|
-
|
|
68319
|
+
const connectPath = import_node_path72.default.join(config.dataDir, "connect.txt");
|
|
68320
|
+
import_node_fs53.default.writeFileSync(connectPath, lines.join("\n") + "\n", { mode: 384 });
|
|
68114
68321
|
} catch {
|
|
68115
68322
|
}
|
|
68116
68323
|
} catch (err) {
|
|
@@ -68197,9 +68404,9 @@ ${bar}
|
|
|
68197
68404
|
};
|
|
68198
68405
|
}
|
|
68199
68406
|
function migrateDropPersonsDir(dataDir) {
|
|
68200
|
-
const dir =
|
|
68407
|
+
const dir = import_node_path72.default.join(dataDir, "persons");
|
|
68201
68408
|
try {
|
|
68202
|
-
|
|
68409
|
+
import_node_fs53.default.rmSync(dir, { recursive: true, force: true });
|
|
68203
68410
|
} catch {
|
|
68204
68411
|
}
|
|
68205
68412
|
}
|