@clawos-dev/clawd 0.2.359 → 0.2.364
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 +571 -401
- package/dist/dispatch/mcp-server.cjs +36 -3
- package/dist/share-md-viewer-error.html +1 -1
- package/dist/share-md-viewer.html +1 -1
- package/dist/share-ui/assets/guest-DH8MvELd.css +32 -0
- package/dist/share-ui/assets/{guest-DvEjHpn5.js → guest-N4gsEYg3.js} +109 -104
- package/dist/share-ui/guest.html +2 -2
- package/package.json +1 -1
- package/dist/share-ui/assets/guest-Dd5QCK4c.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: path83, errorMaps, issueData } = params;
|
|
454
|
+
const fullPath = [...path83, ...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, path83, key) {
|
|
766
766
|
this._cachedPath = [];
|
|
767
767
|
this.parent = parent;
|
|
768
768
|
this.data = value;
|
|
769
|
-
this._path =
|
|
769
|
+
this._path = path83;
|
|
770
770
|
this._key = key;
|
|
771
771
|
}
|
|
772
772
|
get path() {
|
|
@@ -6913,7 +6913,7 @@ var init_principal = __esm({
|
|
|
6913
6913
|
});
|
|
6914
6914
|
|
|
6915
6915
|
// ../protocol/src/schemas.ts
|
|
6916
|
-
var SessionStatusSchema, UsageSchema, 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, SessionImportExternalArgs, SessionListArgs, SessionIdArgs, SessionUpdateArgs, SessionSendArgs, SessionInterruptArgs, SessionRewindArgs, SessionRewindResponseSchema, SessionRewindDiffArgs, RewindDiffHunkSchema, RewindDiffFileSchema, SessionRewindDiffResponseSchema, SessionRewindableMessageIdsArgs, 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, HistoryRecentDirsArgs, 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;
|
|
6916
|
+
var SessionStatusSchema, UsageSchema, 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, ProjectCreateArgs, SessionImportExternalArgs, SessionListArgs, SessionIdArgs, SessionUpdateArgs, SessionSendArgs, SessionInterruptArgs, SessionRewindArgs, SessionRewindResponseSchema, SessionRewindDiffArgs, RewindDiffHunkSchema, RewindDiffFileSchema, SessionRewindDiffResponseSchema, SessionRewindableMessageIdsArgs, 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, HistoryRecentDirsArgs, 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;
|
|
6917
6917
|
var init_schemas = __esm({
|
|
6918
6918
|
"../protocol/src/schemas.ts"() {
|
|
6919
6919
|
"use strict";
|
|
@@ -7051,6 +7051,12 @@ var init_schemas = __esm({
|
|
|
7051
7051
|
// owner-mode persona session 身份标识;UI 用它在 SessionList 过滤 + jump,
|
|
7052
7052
|
// daemon 用它做 idempotent dedupe + spawn 时派生 ctx.personaMode='owner'
|
|
7053
7053
|
ownerPersonaId: external_exports.string().min(1).optional(),
|
|
7054
|
+
/**
|
|
7055
|
+
* project 归组字段(spec 2026-08-17-projects-sidebar §3.2):只在「project + persona
|
|
7056
|
+
* 同时选」时写入(project-only 会话 cwd 即 project 路径,靠 UI 前缀匹配归组,不冗余写)。
|
|
7057
|
+
* 本机资源指针——mirror 上与 ownerPersonaId 同地点 strip(#750 防线)。
|
|
7058
|
+
*/
|
|
7059
|
+
projectPath: external_exports.string().min(1).optional(),
|
|
7054
7060
|
// app-builder Project 反向索引(spec: superpowers/specs/2026-06-01-app-builder-project-picker-design.md)。
|
|
7055
7061
|
// 当此 session 绑定到某个 build 中的 project 时填写;name 与 projects/<name>/ 子目录同名,
|
|
7056
7062
|
// 受 projectNameSchema regex 约束。daemon session:resume 时校验该目录存在,不存在则拒。
|
|
@@ -7389,13 +7395,32 @@ var init_schemas = __esm({
|
|
|
7389
7395
|
ephemeral: external_exports.boolean().optional(),
|
|
7390
7396
|
// owner-mode persona session:传此字段时 daemon 自行派生 cwd 和启动参数,
|
|
7391
7397
|
// 且按 ownerPersonaId 做 idempotent dedupe(每 persona 永远只有一个 owner session)
|
|
7392
|
-
ownerPersonaId: external_exports.string().min(1).optional()
|
|
7398
|
+
ownerPersonaId: external_exports.string().min(1).optional(),
|
|
7393
7399
|
// 单栏默认 refactor (spec 2026-06-02):appBuilderProject 字段已从 SessionCreateArgs 砍掉。
|
|
7394
7400
|
// 绑定路径收敛到 appBuilder:createProject —— 先创建空 session(仅传 ownerPersonaId=persona-app-builder),
|
|
7395
7401
|
// 后通过 createProject RPC 创建 project 并 daemon 内部 mutate 写入 appBuilderProject。
|
|
7396
7402
|
// SessionFile schema 仍保留该字段供 daemon 内部 mutate(manager.update 内部调用通道)。
|
|
7397
|
-
|
|
7398
|
-
|
|
7403
|
+
/**
|
|
7404
|
+
* 新建会话选择的 project(spec 2026-08-17-projects-sidebar §4.2):
|
|
7405
|
+
* - 单独出现:daemon 以它为 cwd(等价传 cwd)
|
|
7406
|
+
* - 与 ownerPersonaId 同时出现:cwd 仍派生为 persona 目录,project 目录经
|
|
7407
|
+
* addDirs(CC --add-dir)/ codexSandbox.writableRoots(codex guest)挂载,
|
|
7408
|
+
* 并写入 SessionFile.projectPath 供归组
|
|
7409
|
+
*/
|
|
7410
|
+
projectPath: external_exports.string().min(1).optional()
|
|
7411
|
+
}).refine((args) => args.cwd != null || args.ownerPersonaId != null || args.projectPath != null, {
|
|
7412
|
+
message: "cwd / ownerPersonaId / projectPath \u81F3\u5C11\u4F20\u4E00\u4E2A"
|
|
7413
|
+
});
|
|
7414
|
+
ProjectEntry = external_exports.object({
|
|
7415
|
+
/** 归一化绝对路径(daemon 侧 ~ 展开 + resolve) */
|
|
7416
|
+
path: external_exports.string().min(1),
|
|
7417
|
+
/** 展示名,缺省 basename */
|
|
7418
|
+
name: external_exports.string().min(1),
|
|
7419
|
+
createdAt: external_exports.string().datetime()
|
|
7420
|
+
});
|
|
7421
|
+
ProjectCreateArgs = external_exports.object({
|
|
7422
|
+
path: external_exports.string().min(1),
|
|
7423
|
+
name: external_exports.string().min(1).optional()
|
|
7399
7424
|
});
|
|
7400
7425
|
SessionImportExternalArgs = external_exports.object({
|
|
7401
7426
|
cwd: external_exports.string().min(1),
|
|
@@ -8143,6 +8168,14 @@ var init_methods = __esm({
|
|
|
8143
8168
|
summary: "\u6700\u8FD1\u7528\u8FC7\u7684\u5DE5\u4F5C\u76EE\u5F55\u5217\u8868\uFF08\u6309 cwd \u53BB\u91CD\u3001\u53D6\u6700\u65B0 updatedAt\uFF09\u3002\u65E0\u53C2\u6570",
|
|
8144
8169
|
args: NO_ARGS
|
|
8145
8170
|
},
|
|
8171
|
+
"project:list": {
|
|
8172
|
+
summary: "\u5217\u51FA project registry\uFF08owner-only\uFF09\uFF1Bpersona / ~/.clawd \u5185\u90E8\u76EE\u5F55\u5DF2\u88AB\u8FC7\u6EE4\uFF0C\u4F1A\u8BDD\u5F52\u7EC4\u5728 UI \u4FA7\u505A",
|
|
8173
|
+
args: NO_ARGS
|
|
8174
|
+
},
|
|
8175
|
+
"project:create": {
|
|
8176
|
+
summary: "\u65B0\u5EFA project\uFF1A\u6821\u9A8C\u76EE\u5F55\u5B58\u5728 + \u975E ~/.clawd \u5B50\u6811\uFF0Cupsert \u8FDB ~/.clawd/projects.json\uFF08owner-only\uFF09",
|
|
8177
|
+
args: ProjectCreateArgs
|
|
8178
|
+
},
|
|
8146
8179
|
"workspace:list": {
|
|
8147
8180
|
summary: "\u5217\u76EE\u5F55\u5185\u5BB9\uFF08\u6587\u4EF6\u6D4F\u89C8\uFF09\uFF1Bguest \u88AB\u9650\u5236\u5728\u88AB\u6388\u6743 persona \u5B50\u6811\u5185",
|
|
8148
8181
|
args: WorkspaceListArgs
|
|
@@ -8966,8 +8999,8 @@ var require_req = __commonJS({
|
|
|
8966
8999
|
if (req.originalUrl) {
|
|
8967
9000
|
_req.url = req.originalUrl;
|
|
8968
9001
|
} else {
|
|
8969
|
-
const
|
|
8970
|
-
_req.url = typeof
|
|
9002
|
+
const path83 = req.path;
|
|
9003
|
+
_req.url = typeof path83 === "string" ? path83 : req.url ? req.url.path || req.url : void 0;
|
|
8971
9004
|
}
|
|
8972
9005
|
if (req.query) {
|
|
8973
9006
|
_req.query = req.query;
|
|
@@ -9132,14 +9165,14 @@ var require_redact = __commonJS({
|
|
|
9132
9165
|
}
|
|
9133
9166
|
return obj;
|
|
9134
9167
|
}
|
|
9135
|
-
function parsePath(
|
|
9168
|
+
function parsePath(path83) {
|
|
9136
9169
|
const parts = [];
|
|
9137
9170
|
let current = "";
|
|
9138
9171
|
let inBrackets = false;
|
|
9139
9172
|
let inQuotes = false;
|
|
9140
9173
|
let quoteChar = "";
|
|
9141
|
-
for (let i = 0; i <
|
|
9142
|
-
const char =
|
|
9174
|
+
for (let i = 0; i < path83.length; i++) {
|
|
9175
|
+
const char = path83[i];
|
|
9143
9176
|
if (!inBrackets && char === ".") {
|
|
9144
9177
|
if (current) {
|
|
9145
9178
|
parts.push(current);
|
|
@@ -9270,10 +9303,10 @@ var require_redact = __commonJS({
|
|
|
9270
9303
|
return current;
|
|
9271
9304
|
}
|
|
9272
9305
|
function redactPaths(obj, paths, censor, remove = false) {
|
|
9273
|
-
for (const
|
|
9274
|
-
const parts = parsePath(
|
|
9306
|
+
for (const path83 of paths) {
|
|
9307
|
+
const parts = parsePath(path83);
|
|
9275
9308
|
if (parts.includes("*")) {
|
|
9276
|
-
redactWildcardPath(obj, parts, censor,
|
|
9309
|
+
redactWildcardPath(obj, parts, censor, path83, remove);
|
|
9277
9310
|
} else {
|
|
9278
9311
|
if (remove) {
|
|
9279
9312
|
removeKey(obj, parts);
|
|
@@ -9358,8 +9391,8 @@ var require_redact = __commonJS({
|
|
|
9358
9391
|
}
|
|
9359
9392
|
} else {
|
|
9360
9393
|
if (afterWildcard.includes("*")) {
|
|
9361
|
-
const wrappedCensor = typeof censor === "function" ? (value,
|
|
9362
|
-
const fullPath = [...pathArray.slice(0, pathLength), ...
|
|
9394
|
+
const wrappedCensor = typeof censor === "function" ? (value, path83) => {
|
|
9395
|
+
const fullPath = [...pathArray.slice(0, pathLength), ...path83];
|
|
9363
9396
|
return censor(value, fullPath);
|
|
9364
9397
|
} : censor;
|
|
9365
9398
|
redactWildcardPath(current, afterWildcard, wrappedCensor, originalPath, remove);
|
|
@@ -9394,8 +9427,8 @@ var require_redact = __commonJS({
|
|
|
9394
9427
|
return null;
|
|
9395
9428
|
}
|
|
9396
9429
|
const pathStructure = /* @__PURE__ */ new Map();
|
|
9397
|
-
for (const
|
|
9398
|
-
const parts = parsePath(
|
|
9430
|
+
for (const path83 of pathsToClone) {
|
|
9431
|
+
const parts = parsePath(path83);
|
|
9399
9432
|
let current = pathStructure;
|
|
9400
9433
|
for (let i = 0; i < parts.length; i++) {
|
|
9401
9434
|
const part = parts[i];
|
|
@@ -9447,24 +9480,24 @@ var require_redact = __commonJS({
|
|
|
9447
9480
|
}
|
|
9448
9481
|
return cloneSelectively(obj, pathStructure);
|
|
9449
9482
|
}
|
|
9450
|
-
function validatePath(
|
|
9451
|
-
if (typeof
|
|
9483
|
+
function validatePath(path83) {
|
|
9484
|
+
if (typeof path83 !== "string") {
|
|
9452
9485
|
throw new Error("Paths must be (non-empty) strings");
|
|
9453
9486
|
}
|
|
9454
|
-
if (
|
|
9487
|
+
if (path83 === "") {
|
|
9455
9488
|
throw new Error("Invalid redaction path ()");
|
|
9456
9489
|
}
|
|
9457
|
-
if (
|
|
9458
|
-
throw new Error(`Invalid redaction path (${
|
|
9490
|
+
if (path83.includes("..")) {
|
|
9491
|
+
throw new Error(`Invalid redaction path (${path83})`);
|
|
9459
9492
|
}
|
|
9460
|
-
if (
|
|
9461
|
-
throw new Error(`Invalid redaction path (${
|
|
9493
|
+
if (path83.includes(",")) {
|
|
9494
|
+
throw new Error(`Invalid redaction path (${path83})`);
|
|
9462
9495
|
}
|
|
9463
9496
|
let bracketCount = 0;
|
|
9464
9497
|
let inQuotes = false;
|
|
9465
9498
|
let quoteChar = "";
|
|
9466
|
-
for (let i = 0; i <
|
|
9467
|
-
const char =
|
|
9499
|
+
for (let i = 0; i < path83.length; i++) {
|
|
9500
|
+
const char = path83[i];
|
|
9468
9501
|
if ((char === '"' || char === "'") && bracketCount > 0) {
|
|
9469
9502
|
if (!inQuotes) {
|
|
9470
9503
|
inQuotes = true;
|
|
@@ -9478,20 +9511,20 @@ var require_redact = __commonJS({
|
|
|
9478
9511
|
} else if (char === "]" && !inQuotes) {
|
|
9479
9512
|
bracketCount--;
|
|
9480
9513
|
if (bracketCount < 0) {
|
|
9481
|
-
throw new Error(`Invalid redaction path (${
|
|
9514
|
+
throw new Error(`Invalid redaction path (${path83})`);
|
|
9482
9515
|
}
|
|
9483
9516
|
}
|
|
9484
9517
|
}
|
|
9485
9518
|
if (bracketCount !== 0) {
|
|
9486
|
-
throw new Error(`Invalid redaction path (${
|
|
9519
|
+
throw new Error(`Invalid redaction path (${path83})`);
|
|
9487
9520
|
}
|
|
9488
9521
|
}
|
|
9489
9522
|
function validatePaths(paths) {
|
|
9490
9523
|
if (!Array.isArray(paths)) {
|
|
9491
9524
|
throw new TypeError("paths must be an array");
|
|
9492
9525
|
}
|
|
9493
|
-
for (const
|
|
9494
|
-
validatePath(
|
|
9526
|
+
for (const path83 of paths) {
|
|
9527
|
+
validatePath(path83);
|
|
9495
9528
|
}
|
|
9496
9529
|
}
|
|
9497
9530
|
function slowRedact(options = {}) {
|
|
@@ -9659,8 +9692,8 @@ var require_redaction = __commonJS({
|
|
|
9659
9692
|
if (shape[k2] === null) {
|
|
9660
9693
|
o[k2] = (value) => topCensor(value, [k2]);
|
|
9661
9694
|
} else {
|
|
9662
|
-
const wrappedCensor = typeof censor === "function" ? (value,
|
|
9663
|
-
return censor(value, [k2, ...
|
|
9695
|
+
const wrappedCensor = typeof censor === "function" ? (value, path83) => {
|
|
9696
|
+
return censor(value, [k2, ...path83]);
|
|
9664
9697
|
} : censor;
|
|
9665
9698
|
o[k2] = Redact({
|
|
9666
9699
|
paths: shape[k2],
|
|
@@ -9878,10 +9911,10 @@ var require_atomic_sleep = __commonJS({
|
|
|
9878
9911
|
var require_sonic_boom = __commonJS({
|
|
9879
9912
|
"../node_modules/.pnpm/sonic-boom@4.2.1/node_modules/sonic-boom/index.js"(exports2, module2) {
|
|
9880
9913
|
"use strict";
|
|
9881
|
-
var
|
|
9914
|
+
var fs75 = require("fs");
|
|
9882
9915
|
var EventEmitter3 = require("events");
|
|
9883
9916
|
var inherits = require("util").inherits;
|
|
9884
|
-
var
|
|
9917
|
+
var path83 = require("path");
|
|
9885
9918
|
var sleep2 = require_atomic_sleep();
|
|
9886
9919
|
var assert = require("assert");
|
|
9887
9920
|
var BUSY_WRITE_TIMEOUT = 100;
|
|
@@ -9935,20 +9968,20 @@ var require_sonic_boom = __commonJS({
|
|
|
9935
9968
|
const mode = sonic.mode;
|
|
9936
9969
|
if (sonic.sync) {
|
|
9937
9970
|
try {
|
|
9938
|
-
if (sonic.mkdir)
|
|
9939
|
-
const fd =
|
|
9971
|
+
if (sonic.mkdir) fs75.mkdirSync(path83.dirname(file), { recursive: true });
|
|
9972
|
+
const fd = fs75.openSync(file, flags, mode);
|
|
9940
9973
|
fileOpened(null, fd);
|
|
9941
9974
|
} catch (err) {
|
|
9942
9975
|
fileOpened(err);
|
|
9943
9976
|
throw err;
|
|
9944
9977
|
}
|
|
9945
9978
|
} else if (sonic.mkdir) {
|
|
9946
|
-
|
|
9979
|
+
fs75.mkdir(path83.dirname(file), { recursive: true }, (err) => {
|
|
9947
9980
|
if (err) return fileOpened(err);
|
|
9948
|
-
|
|
9981
|
+
fs75.open(file, flags, mode, fileOpened);
|
|
9949
9982
|
});
|
|
9950
9983
|
} else {
|
|
9951
|
-
|
|
9984
|
+
fs75.open(file, flags, mode, fileOpened);
|
|
9952
9985
|
}
|
|
9953
9986
|
}
|
|
9954
9987
|
function SonicBoom(opts) {
|
|
@@ -9989,8 +10022,8 @@ var require_sonic_boom = __commonJS({
|
|
|
9989
10022
|
this.flush = flushBuffer;
|
|
9990
10023
|
this.flushSync = flushBufferSync;
|
|
9991
10024
|
this._actualWrite = actualWriteBuffer;
|
|
9992
|
-
fsWriteSync = () =>
|
|
9993
|
-
fsWrite = () =>
|
|
10025
|
+
fsWriteSync = () => fs75.writeSync(this.fd, this._writingBuf);
|
|
10026
|
+
fsWrite = () => fs75.write(this.fd, this._writingBuf, this.release);
|
|
9994
10027
|
} else if (contentMode === void 0 || contentMode === kContentModeUtf8) {
|
|
9995
10028
|
this._writingBuf = "";
|
|
9996
10029
|
this.write = write;
|
|
@@ -9999,15 +10032,15 @@ var require_sonic_boom = __commonJS({
|
|
|
9999
10032
|
this._actualWrite = actualWrite;
|
|
10000
10033
|
fsWriteSync = () => {
|
|
10001
10034
|
if (Buffer.isBuffer(this._writingBuf)) {
|
|
10002
|
-
return
|
|
10035
|
+
return fs75.writeSync(this.fd, this._writingBuf);
|
|
10003
10036
|
}
|
|
10004
|
-
return
|
|
10037
|
+
return fs75.writeSync(this.fd, this._writingBuf, "utf8");
|
|
10005
10038
|
};
|
|
10006
10039
|
fsWrite = () => {
|
|
10007
10040
|
if (Buffer.isBuffer(this._writingBuf)) {
|
|
10008
|
-
return
|
|
10041
|
+
return fs75.write(this.fd, this._writingBuf, this.release);
|
|
10009
10042
|
}
|
|
10010
|
-
return
|
|
10043
|
+
return fs75.write(this.fd, this._writingBuf, "utf8", this.release);
|
|
10011
10044
|
};
|
|
10012
10045
|
} else {
|
|
10013
10046
|
throw new Error(`SonicBoom supports "${kContentModeUtf8}" and "${kContentModeBuffer}", but passed ${contentMode}`);
|
|
@@ -10064,7 +10097,7 @@ var require_sonic_boom = __commonJS({
|
|
|
10064
10097
|
}
|
|
10065
10098
|
}
|
|
10066
10099
|
if (this._fsync) {
|
|
10067
|
-
|
|
10100
|
+
fs75.fsyncSync(this.fd);
|
|
10068
10101
|
}
|
|
10069
10102
|
const len = this._len;
|
|
10070
10103
|
if (this._reopening) {
|
|
@@ -10178,7 +10211,7 @@ var require_sonic_boom = __commonJS({
|
|
|
10178
10211
|
const onDrain = () => {
|
|
10179
10212
|
if (!this._fsync) {
|
|
10180
10213
|
try {
|
|
10181
|
-
|
|
10214
|
+
fs75.fsync(this.fd, (err) => {
|
|
10182
10215
|
this._flushPending = false;
|
|
10183
10216
|
cb(err);
|
|
10184
10217
|
});
|
|
@@ -10280,7 +10313,7 @@ var require_sonic_boom = __commonJS({
|
|
|
10280
10313
|
const fd = this.fd;
|
|
10281
10314
|
this.once("ready", () => {
|
|
10282
10315
|
if (fd !== this.fd) {
|
|
10283
|
-
|
|
10316
|
+
fs75.close(fd, (err) => {
|
|
10284
10317
|
if (err) {
|
|
10285
10318
|
return this.emit("error", err);
|
|
10286
10319
|
}
|
|
@@ -10329,7 +10362,7 @@ var require_sonic_boom = __commonJS({
|
|
|
10329
10362
|
buf = this._bufs[0];
|
|
10330
10363
|
}
|
|
10331
10364
|
try {
|
|
10332
|
-
const n = Buffer.isBuffer(buf) ?
|
|
10365
|
+
const n = Buffer.isBuffer(buf) ? fs75.writeSync(this.fd, buf) : fs75.writeSync(this.fd, buf, "utf8");
|
|
10333
10366
|
const releasedBufObj = releaseWritingBuf(buf, this._len, n);
|
|
10334
10367
|
buf = releasedBufObj.writingBuf;
|
|
10335
10368
|
this._len = releasedBufObj.len;
|
|
@@ -10345,7 +10378,7 @@ var require_sonic_boom = __commonJS({
|
|
|
10345
10378
|
}
|
|
10346
10379
|
}
|
|
10347
10380
|
try {
|
|
10348
|
-
|
|
10381
|
+
fs75.fsyncSync(this.fd);
|
|
10349
10382
|
} catch {
|
|
10350
10383
|
}
|
|
10351
10384
|
}
|
|
@@ -10366,7 +10399,7 @@ var require_sonic_boom = __commonJS({
|
|
|
10366
10399
|
buf = mergeBuf(this._bufs[0], this._lens[0]);
|
|
10367
10400
|
}
|
|
10368
10401
|
try {
|
|
10369
|
-
const n =
|
|
10402
|
+
const n = fs75.writeSync(this.fd, buf);
|
|
10370
10403
|
buf = buf.subarray(n);
|
|
10371
10404
|
this._len = Math.max(this._len - n, 0);
|
|
10372
10405
|
if (buf.length <= 0) {
|
|
@@ -10394,13 +10427,13 @@ var require_sonic_boom = __commonJS({
|
|
|
10394
10427
|
this._writingBuf = this._writingBuf.length ? this._writingBuf : this._bufs.shift() || "";
|
|
10395
10428
|
if (this.sync) {
|
|
10396
10429
|
try {
|
|
10397
|
-
const written = Buffer.isBuffer(this._writingBuf) ?
|
|
10430
|
+
const written = Buffer.isBuffer(this._writingBuf) ? fs75.writeSync(this.fd, this._writingBuf) : fs75.writeSync(this.fd, this._writingBuf, "utf8");
|
|
10398
10431
|
release(null, written);
|
|
10399
10432
|
} catch (err) {
|
|
10400
10433
|
release(err);
|
|
10401
10434
|
}
|
|
10402
10435
|
} else {
|
|
10403
|
-
|
|
10436
|
+
fs75.write(this.fd, this._writingBuf, release);
|
|
10404
10437
|
}
|
|
10405
10438
|
}
|
|
10406
10439
|
function actualWriteBuffer() {
|
|
@@ -10409,7 +10442,7 @@ var require_sonic_boom = __commonJS({
|
|
|
10409
10442
|
this._writingBuf = this._writingBuf.length ? this._writingBuf : mergeBuf(this._bufs.shift(), this._lens.shift());
|
|
10410
10443
|
if (this.sync) {
|
|
10411
10444
|
try {
|
|
10412
|
-
const written =
|
|
10445
|
+
const written = fs75.writeSync(this.fd, this._writingBuf);
|
|
10413
10446
|
release(null, written);
|
|
10414
10447
|
} catch (err) {
|
|
10415
10448
|
release(err);
|
|
@@ -10418,7 +10451,7 @@ var require_sonic_boom = __commonJS({
|
|
|
10418
10451
|
if (kCopyBuffer) {
|
|
10419
10452
|
this._writingBuf = Buffer.from(this._writingBuf);
|
|
10420
10453
|
}
|
|
10421
|
-
|
|
10454
|
+
fs75.write(this.fd, this._writingBuf, release);
|
|
10422
10455
|
}
|
|
10423
10456
|
}
|
|
10424
10457
|
function actualClose(sonic) {
|
|
@@ -10434,12 +10467,12 @@ var require_sonic_boom = __commonJS({
|
|
|
10434
10467
|
sonic._lens = [];
|
|
10435
10468
|
assert(typeof sonic.fd === "number", `sonic.fd must be a number, got ${typeof sonic.fd}`);
|
|
10436
10469
|
try {
|
|
10437
|
-
|
|
10470
|
+
fs75.fsync(sonic.fd, closeWrapped);
|
|
10438
10471
|
} catch {
|
|
10439
10472
|
}
|
|
10440
10473
|
function closeWrapped() {
|
|
10441
10474
|
if (sonic.fd !== 1 && sonic.fd !== 2) {
|
|
10442
|
-
|
|
10475
|
+
fs75.close(sonic.fd, done);
|
|
10443
10476
|
} else {
|
|
10444
10477
|
done();
|
|
10445
10478
|
}
|
|
@@ -10696,7 +10729,7 @@ var require_thread_stream = __commonJS({
|
|
|
10696
10729
|
var { version: version2 } = require_package();
|
|
10697
10730
|
var { EventEmitter: EventEmitter3 } = require("events");
|
|
10698
10731
|
var { Worker } = require("worker_threads");
|
|
10699
|
-
var { join:
|
|
10732
|
+
var { join: join17 } = require("path");
|
|
10700
10733
|
var { pathToFileURL } = require("url");
|
|
10701
10734
|
var { wait } = require_wait();
|
|
10702
10735
|
var {
|
|
@@ -10732,7 +10765,7 @@ var require_thread_stream = __commonJS({
|
|
|
10732
10765
|
function createWorker(stream, opts) {
|
|
10733
10766
|
const { filename, workerData } = opts;
|
|
10734
10767
|
const bundlerOverrides = "__bundlerPathsOverrides" in globalThis ? globalThis.__bundlerPathsOverrides : {};
|
|
10735
|
-
const toExecute = bundlerOverrides["thread-stream-worker"] ||
|
|
10768
|
+
const toExecute = bundlerOverrides["thread-stream-worker"] || join17(__dirname, "lib", "worker.js");
|
|
10736
10769
|
const worker = new Worker(toExecute, {
|
|
10737
10770
|
...opts.workerOpts,
|
|
10738
10771
|
trackUnmanagedFds: false,
|
|
@@ -11118,7 +11151,7 @@ var require_transport = __commonJS({
|
|
|
11118
11151
|
"use strict";
|
|
11119
11152
|
var { createRequire: createRequire2 } = require("module");
|
|
11120
11153
|
var getCallers = require_caller();
|
|
11121
|
-
var { join:
|
|
11154
|
+
var { join: join17, isAbsolute: isAbsolute3, sep: sep3 } = require("path");
|
|
11122
11155
|
var sleep2 = require_atomic_sleep();
|
|
11123
11156
|
var onExit = require_on_exit_leak_free();
|
|
11124
11157
|
var ThreadStream = require_thread_stream();
|
|
@@ -11181,7 +11214,7 @@ var require_transport = __commonJS({
|
|
|
11181
11214
|
throw new Error("only one of target or targets can be specified");
|
|
11182
11215
|
}
|
|
11183
11216
|
if (targets) {
|
|
11184
|
-
target = bundlerOverrides["pino-worker"] ||
|
|
11217
|
+
target = bundlerOverrides["pino-worker"] || join17(__dirname, "worker.js");
|
|
11185
11218
|
options.targets = targets.filter((dest) => dest.target).map((dest) => {
|
|
11186
11219
|
return {
|
|
11187
11220
|
...dest,
|
|
@@ -11199,7 +11232,7 @@ var require_transport = __commonJS({
|
|
|
11199
11232
|
});
|
|
11200
11233
|
});
|
|
11201
11234
|
} else if (pipeline3) {
|
|
11202
|
-
target = bundlerOverrides["pino-worker"] ||
|
|
11235
|
+
target = bundlerOverrides["pino-worker"] || join17(__dirname, "worker.js");
|
|
11203
11236
|
options.pipelines = [pipeline3.map((dest) => {
|
|
11204
11237
|
return {
|
|
11205
11238
|
...dest,
|
|
@@ -11217,11 +11250,11 @@ var require_transport = __commonJS({
|
|
|
11217
11250
|
return buildStream(fixTarget(target), options, worker, sync);
|
|
11218
11251
|
function fixTarget(origin) {
|
|
11219
11252
|
origin = bundlerOverrides[origin] || origin;
|
|
11220
|
-
if (
|
|
11253
|
+
if (isAbsolute3(origin) || origin.indexOf("file://") === 0) {
|
|
11221
11254
|
return origin;
|
|
11222
11255
|
}
|
|
11223
11256
|
if (origin === "pino/file") {
|
|
11224
|
-
return
|
|
11257
|
+
return join17(__dirname, "..", "file.js");
|
|
11225
11258
|
}
|
|
11226
11259
|
let fixTarget2;
|
|
11227
11260
|
for (const filePath of callers) {
|
|
@@ -12211,7 +12244,7 @@ var require_safe_stable_stringify = __commonJS({
|
|
|
12211
12244
|
return circularValue;
|
|
12212
12245
|
}
|
|
12213
12246
|
let res = "";
|
|
12214
|
-
let
|
|
12247
|
+
let join17 = ",";
|
|
12215
12248
|
const originalIndentation = indentation;
|
|
12216
12249
|
if (Array.isArray(value)) {
|
|
12217
12250
|
if (value.length === 0) {
|
|
@@ -12225,7 +12258,7 @@ var require_safe_stable_stringify = __commonJS({
|
|
|
12225
12258
|
indentation += spacer;
|
|
12226
12259
|
res += `
|
|
12227
12260
|
${indentation}`;
|
|
12228
|
-
|
|
12261
|
+
join17 = `,
|
|
12229
12262
|
${indentation}`;
|
|
12230
12263
|
}
|
|
12231
12264
|
const maximumValuesToStringify = Math.min(value.length, maximumBreadth);
|
|
@@ -12233,13 +12266,13 @@ ${indentation}`;
|
|
|
12233
12266
|
for (; i < maximumValuesToStringify - 1; i++) {
|
|
12234
12267
|
const tmp2 = stringifyFnReplacer(String(i), value, stack, replacer, spacer, indentation);
|
|
12235
12268
|
res += tmp2 !== void 0 ? tmp2 : "null";
|
|
12236
|
-
res +=
|
|
12269
|
+
res += join17;
|
|
12237
12270
|
}
|
|
12238
12271
|
const tmp = stringifyFnReplacer(String(i), value, stack, replacer, spacer, indentation);
|
|
12239
12272
|
res += tmp !== void 0 ? tmp : "null";
|
|
12240
12273
|
if (value.length - 1 > maximumBreadth) {
|
|
12241
12274
|
const removedKeys = value.length - maximumBreadth - 1;
|
|
12242
|
-
res += `${
|
|
12275
|
+
res += `${join17}"... ${getItemCount(removedKeys)} not stringified"`;
|
|
12243
12276
|
}
|
|
12244
12277
|
if (spacer !== "") {
|
|
12245
12278
|
res += `
|
|
@@ -12260,7 +12293,7 @@ ${originalIndentation}`;
|
|
|
12260
12293
|
let separator = "";
|
|
12261
12294
|
if (spacer !== "") {
|
|
12262
12295
|
indentation += spacer;
|
|
12263
|
-
|
|
12296
|
+
join17 = `,
|
|
12264
12297
|
${indentation}`;
|
|
12265
12298
|
whitespace = " ";
|
|
12266
12299
|
}
|
|
@@ -12274,13 +12307,13 @@ ${indentation}`;
|
|
|
12274
12307
|
const tmp = stringifyFnReplacer(key2, value, stack, replacer, spacer, indentation);
|
|
12275
12308
|
if (tmp !== void 0) {
|
|
12276
12309
|
res += `${separator}${strEscape(key2)}:${whitespace}${tmp}`;
|
|
12277
|
-
separator =
|
|
12310
|
+
separator = join17;
|
|
12278
12311
|
}
|
|
12279
12312
|
}
|
|
12280
12313
|
if (keyLength > maximumBreadth) {
|
|
12281
12314
|
const removedKeys = keyLength - maximumBreadth;
|
|
12282
12315
|
res += `${separator}"...":${whitespace}"${getItemCount(removedKeys)} not stringified"`;
|
|
12283
|
-
separator =
|
|
12316
|
+
separator = join17;
|
|
12284
12317
|
}
|
|
12285
12318
|
if (spacer !== "" && separator.length > 1) {
|
|
12286
12319
|
res = `
|
|
@@ -12321,7 +12354,7 @@ ${originalIndentation}`;
|
|
|
12321
12354
|
}
|
|
12322
12355
|
const originalIndentation = indentation;
|
|
12323
12356
|
let res = "";
|
|
12324
|
-
let
|
|
12357
|
+
let join17 = ",";
|
|
12325
12358
|
if (Array.isArray(value)) {
|
|
12326
12359
|
if (value.length === 0) {
|
|
12327
12360
|
return "[]";
|
|
@@ -12334,7 +12367,7 @@ ${originalIndentation}`;
|
|
|
12334
12367
|
indentation += spacer;
|
|
12335
12368
|
res += `
|
|
12336
12369
|
${indentation}`;
|
|
12337
|
-
|
|
12370
|
+
join17 = `,
|
|
12338
12371
|
${indentation}`;
|
|
12339
12372
|
}
|
|
12340
12373
|
const maximumValuesToStringify = Math.min(value.length, maximumBreadth);
|
|
@@ -12342,13 +12375,13 @@ ${indentation}`;
|
|
|
12342
12375
|
for (; i < maximumValuesToStringify - 1; i++) {
|
|
12343
12376
|
const tmp2 = stringifyArrayReplacer(String(i), value[i], stack, replacer, spacer, indentation);
|
|
12344
12377
|
res += tmp2 !== void 0 ? tmp2 : "null";
|
|
12345
|
-
res +=
|
|
12378
|
+
res += join17;
|
|
12346
12379
|
}
|
|
12347
12380
|
const tmp = stringifyArrayReplacer(String(i), value[i], stack, replacer, spacer, indentation);
|
|
12348
12381
|
res += tmp !== void 0 ? tmp : "null";
|
|
12349
12382
|
if (value.length - 1 > maximumBreadth) {
|
|
12350
12383
|
const removedKeys = value.length - maximumBreadth - 1;
|
|
12351
|
-
res += `${
|
|
12384
|
+
res += `${join17}"... ${getItemCount(removedKeys)} not stringified"`;
|
|
12352
12385
|
}
|
|
12353
12386
|
if (spacer !== "") {
|
|
12354
12387
|
res += `
|
|
@@ -12361,7 +12394,7 @@ ${originalIndentation}`;
|
|
|
12361
12394
|
let whitespace = "";
|
|
12362
12395
|
if (spacer !== "") {
|
|
12363
12396
|
indentation += spacer;
|
|
12364
|
-
|
|
12397
|
+
join17 = `,
|
|
12365
12398
|
${indentation}`;
|
|
12366
12399
|
whitespace = " ";
|
|
12367
12400
|
}
|
|
@@ -12370,7 +12403,7 @@ ${indentation}`;
|
|
|
12370
12403
|
const tmp = stringifyArrayReplacer(key2, value[key2], stack, replacer, spacer, indentation);
|
|
12371
12404
|
if (tmp !== void 0) {
|
|
12372
12405
|
res += `${separator}${strEscape(key2)}:${whitespace}${tmp}`;
|
|
12373
|
-
separator =
|
|
12406
|
+
separator = join17;
|
|
12374
12407
|
}
|
|
12375
12408
|
}
|
|
12376
12409
|
if (spacer !== "" && separator.length > 1) {
|
|
@@ -12428,20 +12461,20 @@ ${originalIndentation}`;
|
|
|
12428
12461
|
indentation += spacer;
|
|
12429
12462
|
let res2 = `
|
|
12430
12463
|
${indentation}`;
|
|
12431
|
-
const
|
|
12464
|
+
const join18 = `,
|
|
12432
12465
|
${indentation}`;
|
|
12433
12466
|
const maximumValuesToStringify = Math.min(value.length, maximumBreadth);
|
|
12434
12467
|
let i = 0;
|
|
12435
12468
|
for (; i < maximumValuesToStringify - 1; i++) {
|
|
12436
12469
|
const tmp2 = stringifyIndent(String(i), value[i], stack, spacer, indentation);
|
|
12437
12470
|
res2 += tmp2 !== void 0 ? tmp2 : "null";
|
|
12438
|
-
res2 +=
|
|
12471
|
+
res2 += join18;
|
|
12439
12472
|
}
|
|
12440
12473
|
const tmp = stringifyIndent(String(i), value[i], stack, spacer, indentation);
|
|
12441
12474
|
res2 += tmp !== void 0 ? tmp : "null";
|
|
12442
12475
|
if (value.length - 1 > maximumBreadth) {
|
|
12443
12476
|
const removedKeys = value.length - maximumBreadth - 1;
|
|
12444
|
-
res2 += `${
|
|
12477
|
+
res2 += `${join18}"... ${getItemCount(removedKeys)} not stringified"`;
|
|
12445
12478
|
}
|
|
12446
12479
|
res2 += `
|
|
12447
12480
|
${originalIndentation}`;
|
|
@@ -12457,16 +12490,16 @@ ${originalIndentation}`;
|
|
|
12457
12490
|
return '"[Object]"';
|
|
12458
12491
|
}
|
|
12459
12492
|
indentation += spacer;
|
|
12460
|
-
const
|
|
12493
|
+
const join17 = `,
|
|
12461
12494
|
${indentation}`;
|
|
12462
12495
|
let res = "";
|
|
12463
12496
|
let separator = "";
|
|
12464
12497
|
let maximumPropertiesToStringify = Math.min(keyLength, maximumBreadth);
|
|
12465
12498
|
if (isTypedArrayWithEntries(value)) {
|
|
12466
|
-
res += stringifyTypedArray(value,
|
|
12499
|
+
res += stringifyTypedArray(value, join17, maximumBreadth);
|
|
12467
12500
|
keys = keys.slice(value.length);
|
|
12468
12501
|
maximumPropertiesToStringify -= value.length;
|
|
12469
|
-
separator =
|
|
12502
|
+
separator = join17;
|
|
12470
12503
|
}
|
|
12471
12504
|
if (deterministic) {
|
|
12472
12505
|
keys = sort(keys, comparator);
|
|
@@ -12477,13 +12510,13 @@ ${indentation}`;
|
|
|
12477
12510
|
const tmp = stringifyIndent(key2, value[key2], stack, spacer, indentation);
|
|
12478
12511
|
if (tmp !== void 0) {
|
|
12479
12512
|
res += `${separator}${strEscape(key2)}: ${tmp}`;
|
|
12480
|
-
separator =
|
|
12513
|
+
separator = join17;
|
|
12481
12514
|
}
|
|
12482
12515
|
}
|
|
12483
12516
|
if (keyLength > maximumBreadth) {
|
|
12484
12517
|
const removedKeys = keyLength - maximumBreadth;
|
|
12485
12518
|
res += `${separator}"...": "${getItemCount(removedKeys)} not stringified"`;
|
|
12486
|
-
separator =
|
|
12519
|
+
separator = join17;
|
|
12487
12520
|
}
|
|
12488
12521
|
if (separator !== "") {
|
|
12489
12522
|
res = `
|
|
@@ -12803,7 +12836,7 @@ var require_multistream = __commonJS({
|
|
|
12803
12836
|
var require_pino = __commonJS({
|
|
12804
12837
|
"../node_modules/.pnpm/pino@9.14.0/node_modules/pino/pino.js"(exports2, module2) {
|
|
12805
12838
|
"use strict";
|
|
12806
|
-
var
|
|
12839
|
+
var os27 = require("os");
|
|
12807
12840
|
var stdSerializers = require_pino_std_serializers();
|
|
12808
12841
|
var caller = require_caller();
|
|
12809
12842
|
var redaction = require_redaction();
|
|
@@ -12850,7 +12883,7 @@ var require_pino = __commonJS({
|
|
|
12850
12883
|
} = symbols;
|
|
12851
12884
|
var { epochTime, nullTime } = time;
|
|
12852
12885
|
var { pid } = process;
|
|
12853
|
-
var hostname =
|
|
12886
|
+
var hostname = os27.hostname();
|
|
12854
12887
|
var defaultErrorSerializer = stdSerializers.err;
|
|
12855
12888
|
var defaultOptions2 = {
|
|
12856
12889
|
level: "info",
|
|
@@ -13574,11 +13607,11 @@ var init_lib = __esm({
|
|
|
13574
13607
|
}
|
|
13575
13608
|
}
|
|
13576
13609
|
},
|
|
13577
|
-
addToPath: function addToPath(
|
|
13578
|
-
var last =
|
|
13610
|
+
addToPath: function addToPath(path83, added, removed, oldPosInc, options) {
|
|
13611
|
+
var last = path83.lastComponent;
|
|
13579
13612
|
if (last && !options.oneChangePerToken && last.added === added && last.removed === removed) {
|
|
13580
13613
|
return {
|
|
13581
|
-
oldPos:
|
|
13614
|
+
oldPos: path83.oldPos + oldPosInc,
|
|
13582
13615
|
lastComponent: {
|
|
13583
13616
|
count: last.count + 1,
|
|
13584
13617
|
added,
|
|
@@ -13588,7 +13621,7 @@ var init_lib = __esm({
|
|
|
13588
13621
|
};
|
|
13589
13622
|
} else {
|
|
13590
13623
|
return {
|
|
13591
|
-
oldPos:
|
|
13624
|
+
oldPos: path83.oldPos + oldPosInc,
|
|
13592
13625
|
lastComponent: {
|
|
13593
13626
|
count: 1,
|
|
13594
13627
|
added,
|
|
@@ -14120,10 +14153,10 @@ function attachmentToHistoryMessage(o, ts) {
|
|
|
14120
14153
|
const memories = raw.map((m2) => {
|
|
14121
14154
|
if (!m2 || typeof m2 !== "object") return null;
|
|
14122
14155
|
const rec4 = m2;
|
|
14123
|
-
const
|
|
14156
|
+
const path83 = typeof rec4.path === "string" ? rec4.path : null;
|
|
14124
14157
|
const content = typeof rec4.content === "string" ? rec4.content : null;
|
|
14125
|
-
if (!
|
|
14126
|
-
const entry = { path:
|
|
14158
|
+
if (!path83 || content == null) return null;
|
|
14159
|
+
const entry = { path: path83, content };
|
|
14127
14160
|
if (typeof rec4.mtimeMs === "number") entry.mtimeMs = rec4.mtimeMs;
|
|
14128
14161
|
return entry;
|
|
14129
14162
|
}).filter((m2) => m2 !== null);
|
|
@@ -14974,10 +15007,10 @@ function parseAttachment(obj) {
|
|
|
14974
15007
|
const memories = raw.map((m2) => {
|
|
14975
15008
|
if (!m2 || typeof m2 !== "object") return null;
|
|
14976
15009
|
const rec4 = m2;
|
|
14977
|
-
const
|
|
15010
|
+
const path83 = typeof rec4.path === "string" ? rec4.path : null;
|
|
14978
15011
|
const content = typeof rec4.content === "string" ? rec4.content : null;
|
|
14979
|
-
if (!
|
|
14980
|
-
const out = { path:
|
|
15012
|
+
if (!path83 || content == null) return null;
|
|
15013
|
+
const out = { path: path83, content };
|
|
14981
15014
|
if (typeof rec4.mtimeMs === "number") out.mtimeMs = rec4.mtimeMs;
|
|
14982
15015
|
return out;
|
|
14983
15016
|
}).filter((m2) => m2 !== null);
|
|
@@ -29359,8 +29392,8 @@ var require_CronFileParser = __commonJS({
|
|
|
29359
29392
|
* @throws If file cannot be read
|
|
29360
29393
|
*/
|
|
29361
29394
|
static parseFileSync(filePath) {
|
|
29362
|
-
const { readFileSync:
|
|
29363
|
-
const data =
|
|
29395
|
+
const { readFileSync: readFileSync8 } = require("fs");
|
|
29396
|
+
const data = readFileSync8(filePath, "utf8");
|
|
29364
29397
|
return _CronFileParser.#parseContent(data);
|
|
29365
29398
|
}
|
|
29366
29399
|
/**
|
|
@@ -33361,7 +33394,7 @@ var require_BufferList = __commonJS({
|
|
|
33361
33394
|
this.head = this.tail = null;
|
|
33362
33395
|
this.length = 0;
|
|
33363
33396
|
};
|
|
33364
|
-
BufferList.prototype.join = function
|
|
33397
|
+
BufferList.prototype.join = function join17(s) {
|
|
33365
33398
|
if (this.length === 0) return "";
|
|
33366
33399
|
var p2 = this.head;
|
|
33367
33400
|
var ret = "" + p2.data;
|
|
@@ -35338,8 +35371,8 @@ var require_lib2 = __commonJS({
|
|
|
35338
35371
|
return this;
|
|
35339
35372
|
}
|
|
35340
35373
|
var p2 = this.constructor;
|
|
35341
|
-
return this.then(
|
|
35342
|
-
function
|
|
35374
|
+
return this.then(resolve8, reject2);
|
|
35375
|
+
function resolve8(value) {
|
|
35343
35376
|
function yes() {
|
|
35344
35377
|
return value;
|
|
35345
35378
|
}
|
|
@@ -35492,8 +35525,8 @@ var require_lib2 = __commonJS({
|
|
|
35492
35525
|
}
|
|
35493
35526
|
return out;
|
|
35494
35527
|
}
|
|
35495
|
-
Promise2.resolve =
|
|
35496
|
-
function
|
|
35528
|
+
Promise2.resolve = resolve7;
|
|
35529
|
+
function resolve7(value) {
|
|
35497
35530
|
if (value instanceof this) {
|
|
35498
35531
|
return value;
|
|
35499
35532
|
}
|
|
@@ -35951,8 +35984,8 @@ var require_utils = __commonJS({
|
|
|
35951
35984
|
var result = transform[inputType][outputType](input);
|
|
35952
35985
|
return result;
|
|
35953
35986
|
};
|
|
35954
|
-
exports2.resolve = function(
|
|
35955
|
-
var parts =
|
|
35987
|
+
exports2.resolve = function(path83) {
|
|
35988
|
+
var parts = path83.split("/");
|
|
35956
35989
|
var result = [];
|
|
35957
35990
|
for (var index = 0; index < parts.length; index++) {
|
|
35958
35991
|
var part = parts[index];
|
|
@@ -36025,10 +36058,10 @@ var require_utils = __commonJS({
|
|
|
36025
36058
|
var promise = external.Promise.resolve(inputData).then(function(data) {
|
|
36026
36059
|
var isBlob = support.blob && (data instanceof Blob || ["[object File]", "[object Blob]"].indexOf(Object.prototype.toString.call(data)) !== -1);
|
|
36027
36060
|
if (isBlob && typeof FileReader !== "undefined") {
|
|
36028
|
-
return new external.Promise(function(
|
|
36061
|
+
return new external.Promise(function(resolve7, reject) {
|
|
36029
36062
|
var reader = new FileReader();
|
|
36030
36063
|
reader.onload = function(e) {
|
|
36031
|
-
|
|
36064
|
+
resolve7(e.target.result);
|
|
36032
36065
|
};
|
|
36033
36066
|
reader.onerror = function(e) {
|
|
36034
36067
|
reject(e.target.error);
|
|
@@ -36583,7 +36616,7 @@ var require_StreamHelper = __commonJS({
|
|
|
36583
36616
|
}
|
|
36584
36617
|
}
|
|
36585
36618
|
function accumulate(helper, updateCallback) {
|
|
36586
|
-
return new external.Promise(function(
|
|
36619
|
+
return new external.Promise(function(resolve7, reject) {
|
|
36587
36620
|
var dataArray = [];
|
|
36588
36621
|
var chunkType = helper._internalType, resultType = helper._outputType, mimeType = helper._mimeType;
|
|
36589
36622
|
helper.on("data", function(data, meta) {
|
|
@@ -36597,7 +36630,7 @@ var require_StreamHelper = __commonJS({
|
|
|
36597
36630
|
}).on("end", function() {
|
|
36598
36631
|
try {
|
|
36599
36632
|
var result = transformZipOutput(resultType, concat(chunkType, dataArray), mimeType);
|
|
36600
|
-
|
|
36633
|
+
resolve7(result);
|
|
36601
36634
|
} catch (e) {
|
|
36602
36635
|
reject(e);
|
|
36603
36636
|
}
|
|
@@ -41805,18 +41838,18 @@ var require_object = __commonJS({
|
|
|
41805
41838
|
var object = new ZipObject(name, zipObjectContent, o);
|
|
41806
41839
|
this.files[name] = object;
|
|
41807
41840
|
};
|
|
41808
|
-
var parentFolder = function(
|
|
41809
|
-
if (
|
|
41810
|
-
|
|
41841
|
+
var parentFolder = function(path83) {
|
|
41842
|
+
if (path83.slice(-1) === "/") {
|
|
41843
|
+
path83 = path83.substring(0, path83.length - 1);
|
|
41811
41844
|
}
|
|
41812
|
-
var lastSlash =
|
|
41813
|
-
return lastSlash > 0 ?
|
|
41845
|
+
var lastSlash = path83.lastIndexOf("/");
|
|
41846
|
+
return lastSlash > 0 ? path83.substring(0, lastSlash) : "";
|
|
41814
41847
|
};
|
|
41815
|
-
var forceTrailingSlash = function(
|
|
41816
|
-
if (
|
|
41817
|
-
|
|
41848
|
+
var forceTrailingSlash = function(path83) {
|
|
41849
|
+
if (path83.slice(-1) !== "/") {
|
|
41850
|
+
path83 += "/";
|
|
41818
41851
|
}
|
|
41819
|
-
return
|
|
41852
|
+
return path83;
|
|
41820
41853
|
};
|
|
41821
41854
|
var folderAdd = function(name, createFolders) {
|
|
41822
41855
|
createFolders = typeof createFolders !== "undefined" ? createFolders : defaults.createFolders;
|
|
@@ -42710,7 +42743,7 @@ var require_load = __commonJS({
|
|
|
42710
42743
|
var Crc32Probe = require_Crc32Probe();
|
|
42711
42744
|
var nodejsUtils = require_nodejsUtils();
|
|
42712
42745
|
function checkEntryCRC32(zipEntry) {
|
|
42713
|
-
return new external.Promise(function(
|
|
42746
|
+
return new external.Promise(function(resolve7, reject) {
|
|
42714
42747
|
var worker = zipEntry.decompressed.getContentWorker().pipe(new Crc32Probe());
|
|
42715
42748
|
worker.on("error", function(e) {
|
|
42716
42749
|
reject(e);
|
|
@@ -42718,7 +42751,7 @@ var require_load = __commonJS({
|
|
|
42718
42751
|
if (worker.streamInfo.crc32 !== zipEntry.decompressed.crc32) {
|
|
42719
42752
|
reject(new Error("Corrupted zip : CRC32 mismatch"));
|
|
42720
42753
|
} else {
|
|
42721
|
-
|
|
42754
|
+
resolve7();
|
|
42722
42755
|
}
|
|
42723
42756
|
}).resume();
|
|
42724
42757
|
});
|
|
@@ -42823,11 +42856,11 @@ function startRunCaseRecorder(opts) {
|
|
|
42823
42856
|
let closing = false;
|
|
42824
42857
|
let closedSettled = false;
|
|
42825
42858
|
let closedResolve;
|
|
42826
|
-
const closed = new Promise((
|
|
42859
|
+
const closed = new Promise((resolve7) => {
|
|
42827
42860
|
closedResolve = () => {
|
|
42828
42861
|
if (closedSettled) return;
|
|
42829
42862
|
closedSettled = true;
|
|
42830
|
-
|
|
42863
|
+
resolve7();
|
|
42831
42864
|
};
|
|
42832
42865
|
});
|
|
42833
42866
|
const ensureStream = () => {
|
|
@@ -42919,8 +42952,8 @@ async function runController(opts) {
|
|
|
42919
42952
|
let exitCode = null;
|
|
42920
42953
|
let procExited = false;
|
|
42921
42954
|
let resolveProcExit;
|
|
42922
|
-
const procExitPromise = new Promise((
|
|
42923
|
-
resolveProcExit =
|
|
42955
|
+
const procExitPromise = new Promise((resolve7) => {
|
|
42956
|
+
resolveProcExit = resolve7;
|
|
42924
42957
|
});
|
|
42925
42958
|
const writeEvent = (event) => {
|
|
42926
42959
|
try {
|
|
@@ -45351,8 +45384,8 @@ function startRecorder(opts) {
|
|
|
45351
45384
|
const filePath = import_node_path6.default.join(dir, `${tsForFilename(now())}.jsonl`);
|
|
45352
45385
|
let stream = null;
|
|
45353
45386
|
let closedResolve;
|
|
45354
|
-
const closed = new Promise((
|
|
45355
|
-
closedResolve =
|
|
45387
|
+
const closed = new Promise((resolve7) => {
|
|
45388
|
+
closedResolve = resolve7;
|
|
45356
45389
|
});
|
|
45357
45390
|
let exited = false;
|
|
45358
45391
|
const ensureStream = () => {
|
|
@@ -45485,13 +45518,13 @@ var SessionRunner = class {
|
|
|
45485
45518
|
// 已经停止则立即 resolve;超时(默认 3000ms)抛错由上层透传成 RPC error
|
|
45486
45519
|
async waitUntilStopped(timeoutMs = DEFAULT_WAIT_STOP_TIMEOUT_MS) {
|
|
45487
45520
|
if (!this.state.procAlive) return;
|
|
45488
|
-
return new Promise((
|
|
45521
|
+
return new Promise((resolve7, reject) => {
|
|
45489
45522
|
let settled = false;
|
|
45490
45523
|
const onStop = () => {
|
|
45491
45524
|
if (settled) return;
|
|
45492
45525
|
settled = true;
|
|
45493
45526
|
clearTimeout(timer);
|
|
45494
|
-
|
|
45527
|
+
resolve7();
|
|
45495
45528
|
};
|
|
45496
45529
|
const timer = setTimeout(() => {
|
|
45497
45530
|
if (settled) return;
|
|
@@ -45591,7 +45624,7 @@ var SessionRunner = class {
|
|
|
45591
45624
|
};
|
|
45592
45625
|
const payload = JSON.stringify(frame) + "\n";
|
|
45593
45626
|
const timeoutMs = opts.timeoutMs ?? DEFAULT_CONTROL_REQUEST_TIMEOUT_MS;
|
|
45594
|
-
return new Promise((
|
|
45627
|
+
return new Promise((resolve7, reject) => {
|
|
45595
45628
|
const timer = setTimeout(() => {
|
|
45596
45629
|
const pending = this.pendingControlRequests.get(requestId);
|
|
45597
45630
|
if (!pending) return;
|
|
@@ -45599,7 +45632,7 @@ var SessionRunner = class {
|
|
|
45599
45632
|
reject(new Error(`control_request timeout: ${subtype}`));
|
|
45600
45633
|
}, timeoutMs);
|
|
45601
45634
|
timer.unref?.();
|
|
45602
|
-
this.pendingControlRequests.set(requestId, { resolve:
|
|
45635
|
+
this.pendingControlRequests.set(requestId, { resolve: resolve7, reject, timer });
|
|
45603
45636
|
try {
|
|
45604
45637
|
proc.stdin?.write(payload);
|
|
45605
45638
|
this.recorder?.tapStdinWrite(payload);
|
|
@@ -46264,6 +46297,9 @@ var SessionManager = class {
|
|
|
46264
46297
|
network: codexCfg?.network ?? false
|
|
46265
46298
|
};
|
|
46266
46299
|
}
|
|
46300
|
+
if (subSessionMeta?.personaMode === "owner" && file.projectPath) {
|
|
46301
|
+
subSessionMeta.addDirs = [...subSessionMeta.addDirs ?? [], file.projectPath];
|
|
46302
|
+
}
|
|
46267
46303
|
const attachmentGroup = this.deps.attachmentGroup;
|
|
46268
46304
|
const runner = new SessionRunner(makeInitialState(file, subSessionMeta), {
|
|
46269
46305
|
broadcastFrame: (frame, target) => this.routeFromRunner(frame, target),
|
|
@@ -46431,8 +46467,8 @@ var SessionManager = class {
|
|
|
46431
46467
|
forkedFromSessionId: args.forkedFromSessionId
|
|
46432
46468
|
});
|
|
46433
46469
|
}
|
|
46434
|
-
} else if (args.cwd) {
|
|
46435
|
-
cwd = args.cwd;
|
|
46470
|
+
} else if (args.cwd ?? args.projectPath) {
|
|
46471
|
+
cwd = args.cwd ?? args.projectPath;
|
|
46436
46472
|
} else {
|
|
46437
46473
|
throw new ClawdError(ERROR_CODES.INVALID_CWD, "cwd required when ownerPersonaId is absent");
|
|
46438
46474
|
}
|
|
@@ -46459,6 +46495,9 @@ var SessionManager = class {
|
|
|
46459
46495
|
iconKey: args.iconKey,
|
|
46460
46496
|
forkedFromSessionId: args.forkedFromSessionId,
|
|
46461
46497
|
ownerPersonaId: args.ownerPersonaId,
|
|
46498
|
+
// projectPath 只在 persona+project 组合写入(spec 2026-08-17-projects-sidebar §3.2);
|
|
46499
|
+
// project-only 会话 cwd 即 project 路径,靠 UI 前缀匹配归组
|
|
46500
|
+
...args.ownerPersonaId && args.projectPath ? { projectPath: args.projectPath } : {},
|
|
46462
46501
|
appBuilderProject: args.appBuilderProject,
|
|
46463
46502
|
ephemeral: args.ephemeral,
|
|
46464
46503
|
creatorPrincipalId,
|
|
@@ -48136,29 +48175,101 @@ var SessionManager = class {
|
|
|
48136
48175
|
}
|
|
48137
48176
|
};
|
|
48138
48177
|
|
|
48139
|
-
// src/
|
|
48178
|
+
// src/projects/store.ts
|
|
48140
48179
|
var fs10 = __toESM(require("fs"), 1);
|
|
48180
|
+
var os5 = __toESM(require("os"), 1);
|
|
48141
48181
|
var path12 = __toESM(require("path"), 1);
|
|
48142
48182
|
init_protocol();
|
|
48183
|
+
var ProjectsStore = class {
|
|
48184
|
+
constructor(opts) {
|
|
48185
|
+
this.opts = opts;
|
|
48186
|
+
this.load();
|
|
48187
|
+
}
|
|
48188
|
+
opts;
|
|
48189
|
+
entries = [];
|
|
48190
|
+
load() {
|
|
48191
|
+
let raw;
|
|
48192
|
+
try {
|
|
48193
|
+
raw = fs10.readFileSync(this.opts.file, "utf8");
|
|
48194
|
+
} catch {
|
|
48195
|
+
return;
|
|
48196
|
+
}
|
|
48197
|
+
try {
|
|
48198
|
+
const parsed = JSON.parse(raw);
|
|
48199
|
+
this.entries = (parsed.projects ?? []).map((p2) => ProjectEntry.parse(p2));
|
|
48200
|
+
} catch (err) {
|
|
48201
|
+
this.opts.logger?.warn("projects.json corrupt, rebuilding", { err: String(err) });
|
|
48202
|
+
this.entries = [];
|
|
48203
|
+
}
|
|
48204
|
+
}
|
|
48205
|
+
save() {
|
|
48206
|
+
fs10.mkdirSync(path12.dirname(this.opts.file), { recursive: true });
|
|
48207
|
+
fs10.writeFileSync(this.opts.file, JSON.stringify({ projects: this.entries }, null, 2));
|
|
48208
|
+
}
|
|
48209
|
+
normalize(p2) {
|
|
48210
|
+
const home = os5.homedir();
|
|
48211
|
+
const expanded = p2 === "~" ? home : p2.startsWith("~/") ? path12.join(home, p2.slice(2)) : p2;
|
|
48212
|
+
return path12.resolve(expanded);
|
|
48213
|
+
}
|
|
48214
|
+
isProjectablePath(p2) {
|
|
48215
|
+
const rel = path12.relative(path12.resolve(this.opts.clawdDir), this.normalize(p2));
|
|
48216
|
+
return rel.startsWith("..") || path12.isAbsolute(rel);
|
|
48217
|
+
}
|
|
48218
|
+
list() {
|
|
48219
|
+
return [...this.entries];
|
|
48220
|
+
}
|
|
48221
|
+
upsert(rawPath, name) {
|
|
48222
|
+
const entry = this.add(rawPath, name);
|
|
48223
|
+
if (entry) this.save();
|
|
48224
|
+
return entry;
|
|
48225
|
+
}
|
|
48226
|
+
/** upsert 不落盘版(seed 批量用);已存在时返回既有条目(upsert 幂等语义靠它) */
|
|
48227
|
+
add(rawPath, name) {
|
|
48228
|
+
const abs = this.normalize(rawPath);
|
|
48229
|
+
if (!this.isProjectablePath(abs)) return null;
|
|
48230
|
+
const existing = this.entries.find((e) => e.path === abs);
|
|
48231
|
+
if (existing) return existing;
|
|
48232
|
+
const entry = {
|
|
48233
|
+
path: abs,
|
|
48234
|
+
name: name ?? path12.basename(abs),
|
|
48235
|
+
createdAt: (this.opts.now ?? (() => (/* @__PURE__ */ new Date()).toISOString()))()
|
|
48236
|
+
};
|
|
48237
|
+
this.entries.push(entry);
|
|
48238
|
+
return entry;
|
|
48239
|
+
}
|
|
48240
|
+
seedFromSessions(files) {
|
|
48241
|
+
for (const f of files) {
|
|
48242
|
+
if (f.originOwnerPrincipalId) continue;
|
|
48243
|
+
if (f.projectPath) this.add(f.projectPath);
|
|
48244
|
+
this.add(f.cwd);
|
|
48245
|
+
}
|
|
48246
|
+
this.save();
|
|
48247
|
+
}
|
|
48248
|
+
};
|
|
48249
|
+
|
|
48250
|
+
// src/persona/store.ts
|
|
48251
|
+
var fs11 = __toESM(require("fs"), 1);
|
|
48252
|
+
var path13 = __toESM(require("path"), 1);
|
|
48253
|
+
init_protocol();
|
|
48143
48254
|
var PersonaStore = class {
|
|
48144
48255
|
constructor(root) {
|
|
48145
48256
|
this.root = root;
|
|
48146
|
-
|
|
48257
|
+
fs11.mkdirSync(root, { recursive: true });
|
|
48147
48258
|
}
|
|
48148
48259
|
root;
|
|
48149
48260
|
personaDir(personaId2) {
|
|
48150
|
-
return
|
|
48261
|
+
return path13.join(this.root, safeFileName(personaId2));
|
|
48151
48262
|
}
|
|
48152
48263
|
metaPath(personaId2) {
|
|
48153
|
-
return
|
|
48264
|
+
return path13.join(this.personaDir(personaId2), ".clawd", "persona.json");
|
|
48154
48265
|
}
|
|
48155
48266
|
claudeMdPath(personaId2) {
|
|
48156
|
-
return
|
|
48267
|
+
return path13.join(this.personaDir(personaId2), "CLAUDE.md");
|
|
48157
48268
|
}
|
|
48158
48269
|
// codex 原生读 cwd 的 AGENTS.md。人格双写镜像:claude 读 CLAUDE.md、codex 读 AGENTS.md,
|
|
48159
48270
|
// 两份内容恒一致,persona 切 tool 零迁移。
|
|
48160
48271
|
agentsMdPath(personaId2) {
|
|
48161
|
-
return
|
|
48272
|
+
return path13.join(this.personaDir(personaId2), "AGENTS.md");
|
|
48162
48273
|
}
|
|
48163
48274
|
/**
|
|
48164
48275
|
* persona 级 sandbox base 落盘路径 —— 故意放 `.clawd/` 而非 `.claude/`,让 CC 的 project
|
|
@@ -48167,11 +48278,11 @@ var PersonaStore = class {
|
|
|
48167
48278
|
* spawn 前 per-guest 动态拼到各自 session 目录的那份(base + 强制底座 + 本 guest userWorkDir carve)。
|
|
48168
48279
|
*/
|
|
48169
48280
|
sandboxSettingsPath(personaId2) {
|
|
48170
|
-
return
|
|
48281
|
+
return path13.join(this.personaDir(personaId2), ".clawd", "sandbox-settings.json");
|
|
48171
48282
|
}
|
|
48172
48283
|
write(persona, personality) {
|
|
48173
48284
|
const dir = this.personaDir(persona.personaId);
|
|
48174
|
-
|
|
48285
|
+
fs11.mkdirSync(path13.join(dir, ".clawd"), { recursive: true });
|
|
48175
48286
|
this.atomicWrite(this.claudeMdPath(persona.personaId), personality);
|
|
48176
48287
|
this.atomicWrite(this.agentsMdPath(persona.personaId), personality);
|
|
48177
48288
|
this.writeSandboxSettings(persona.personaId, buildGuestSettingsV1());
|
|
@@ -48190,9 +48301,9 @@ var PersonaStore = class {
|
|
|
48190
48301
|
ensureAgentsMirror(personaId2) {
|
|
48191
48302
|
const claudeMd = this.claudeMdPath(personaId2);
|
|
48192
48303
|
const agentsMd = this.agentsMdPath(personaId2);
|
|
48193
|
-
if (!
|
|
48194
|
-
if (
|
|
48195
|
-
this.atomicWrite(agentsMd,
|
|
48304
|
+
if (!fs11.existsSync(claudeMd)) return false;
|
|
48305
|
+
if (fs11.existsSync(agentsMd)) return false;
|
|
48306
|
+
this.atomicWrite(agentsMd, fs11.readFileSync(claudeMd, "utf8"));
|
|
48196
48307
|
return true;
|
|
48197
48308
|
}
|
|
48198
48309
|
/**
|
|
@@ -48242,22 +48353,22 @@ var PersonaStore = class {
|
|
|
48242
48353
|
};
|
|
48243
48354
|
}
|
|
48244
48355
|
codexSandboxSettingsPath(personaId2) {
|
|
48245
|
-
return
|
|
48356
|
+
return path13.join(this.personaDir(personaId2), ".clawd", "codex-sandbox.json");
|
|
48246
48357
|
}
|
|
48247
48358
|
/** 读 codex-sandbox.json;不存在/损坏 → null。 */
|
|
48248
48359
|
readCodexSandboxSettings(personaId2) {
|
|
48249
48360
|
const p2 = this.codexSandboxSettingsPath(personaId2);
|
|
48250
|
-
if (!
|
|
48361
|
+
if (!fs11.existsSync(p2)) return null;
|
|
48251
48362
|
try {
|
|
48252
|
-
return CodexSandboxSettingsSchema.parse(JSON.parse(
|
|
48363
|
+
return CodexSandboxSettingsSchema.parse(JSON.parse(fs11.readFileSync(p2, "utf8")));
|
|
48253
48364
|
} catch {
|
|
48254
48365
|
return null;
|
|
48255
48366
|
}
|
|
48256
48367
|
}
|
|
48257
48368
|
/** 覆盖写 codex-sandbox.json(seed/migrate 用)。 */
|
|
48258
48369
|
writeCodexSandboxSettings(personaId2, settings) {
|
|
48259
|
-
const dir =
|
|
48260
|
-
|
|
48370
|
+
const dir = path13.join(this.personaDir(personaId2), ".clawd");
|
|
48371
|
+
fs11.mkdirSync(dir, { recursive: true });
|
|
48261
48372
|
this.atomicWrite(this.codexSandboxSettingsPath(personaId2), JSON.stringify(settings, null, 2));
|
|
48262
48373
|
}
|
|
48263
48374
|
writeMeta(persona) {
|
|
@@ -48265,8 +48376,8 @@ var PersonaStore = class {
|
|
|
48265
48376
|
}
|
|
48266
48377
|
read(personaId2) {
|
|
48267
48378
|
const p2 = this.metaPath(personaId2);
|
|
48268
|
-
if (!
|
|
48269
|
-
const raw = JSON.parse(
|
|
48379
|
+
if (!fs11.existsSync(p2)) return null;
|
|
48380
|
+
const raw = JSON.parse(fs11.readFileSync(p2, "utf8"));
|
|
48270
48381
|
if (raw && typeof raw === "object" && "tokenMap" in raw) {
|
|
48271
48382
|
delete raw.tokenMap;
|
|
48272
48383
|
this.atomicWrite(p2, JSON.stringify(raw, null, 2));
|
|
@@ -48274,13 +48385,13 @@ var PersonaStore = class {
|
|
|
48274
48385
|
return PersonaFileSchema.parse(raw);
|
|
48275
48386
|
}
|
|
48276
48387
|
has(personaId2) {
|
|
48277
|
-
return
|
|
48388
|
+
return fs11.existsSync(this.metaPath(personaId2));
|
|
48278
48389
|
}
|
|
48279
48390
|
readPersonality(personaId2) {
|
|
48280
48391
|
const claudeMd = this.claudeMdPath(personaId2);
|
|
48281
|
-
if (
|
|
48392
|
+
if (fs11.existsSync(claudeMd)) return fs11.readFileSync(claudeMd, "utf8");
|
|
48282
48393
|
const agentsMd = this.agentsMdPath(personaId2);
|
|
48283
|
-
if (
|
|
48394
|
+
if (fs11.existsSync(agentsMd)) return fs11.readFileSync(agentsMd, "utf8");
|
|
48284
48395
|
return null;
|
|
48285
48396
|
}
|
|
48286
48397
|
/**
|
|
@@ -48289,23 +48400,23 @@ var PersonaStore = class {
|
|
|
48289
48400
|
*/
|
|
48290
48401
|
readSandboxSettings(personaId2) {
|
|
48291
48402
|
const p2 = this.sandboxSettingsPath(personaId2);
|
|
48292
|
-
if (!
|
|
48403
|
+
if (!fs11.existsSync(p2)) return null;
|
|
48293
48404
|
try {
|
|
48294
|
-
return JSON.parse(
|
|
48405
|
+
return JSON.parse(fs11.readFileSync(p2, "utf8"));
|
|
48295
48406
|
} catch {
|
|
48296
48407
|
return null;
|
|
48297
48408
|
}
|
|
48298
48409
|
}
|
|
48299
48410
|
/** Persona 私有 skills 目录路径:<personaDir>/.claude/skills */
|
|
48300
48411
|
skillsDir(personaId2) {
|
|
48301
|
-
return
|
|
48412
|
+
return path13.join(this.personaDir(personaId2), ".claude", "skills");
|
|
48302
48413
|
}
|
|
48303
48414
|
/**
|
|
48304
48415
|
* Claude Code 项目级 settings 路径:`<personaDir>/.claude/settings.json`。
|
|
48305
48416
|
* 这里只读 `enabledPlugins` 字段,由 owner 通过 CC `/plugin` 之类命令维护,daemon 不写。
|
|
48306
48417
|
*/
|
|
48307
48418
|
claudeSettingsPath(personaId2) {
|
|
48308
|
-
return
|
|
48419
|
+
return path13.join(this.personaDir(personaId2), ".claude", "settings.json");
|
|
48309
48420
|
}
|
|
48310
48421
|
/**
|
|
48311
48422
|
* 读取 persona 的 `.claude/settings.json` 中 `enabledPlugins` map,把 value === true
|
|
@@ -48320,10 +48431,10 @@ var PersonaStore = class {
|
|
|
48320
48431
|
*/
|
|
48321
48432
|
readEnabledPlugins(personaId2) {
|
|
48322
48433
|
const p2 = this.claudeSettingsPath(personaId2);
|
|
48323
|
-
if (!
|
|
48434
|
+
if (!fs11.existsSync(p2)) return [];
|
|
48324
48435
|
let raw;
|
|
48325
48436
|
try {
|
|
48326
|
-
raw = JSON.parse(
|
|
48437
|
+
raw = JSON.parse(fs11.readFileSync(p2, "utf8"));
|
|
48327
48438
|
} catch {
|
|
48328
48439
|
return [];
|
|
48329
48440
|
}
|
|
@@ -48337,22 +48448,22 @@ var PersonaStore = class {
|
|
|
48337
48448
|
return out;
|
|
48338
48449
|
}
|
|
48339
48450
|
list() {
|
|
48340
|
-
if (!
|
|
48341
|
-
return
|
|
48342
|
-
return
|
|
48451
|
+
if (!fs11.existsSync(this.root)) return [];
|
|
48452
|
+
return fs11.readdirSync(this.root).filter((name) => {
|
|
48453
|
+
return fs11.existsSync(path13.join(this.root, name, ".clawd", "persona.json"));
|
|
48343
48454
|
});
|
|
48344
48455
|
}
|
|
48345
48456
|
remove(personaId2) {
|
|
48346
48457
|
const dir = this.personaDir(personaId2);
|
|
48347
|
-
if (
|
|
48458
|
+
if (fs11.existsSync(dir)) fs11.rmSync(dir, { recursive: true, force: true });
|
|
48348
48459
|
}
|
|
48349
48460
|
personaDirPath(personaId2) {
|
|
48350
48461
|
return this.personaDir(personaId2);
|
|
48351
48462
|
}
|
|
48352
48463
|
atomicWrite(file, content) {
|
|
48353
48464
|
const tmp = `${file}.tmp-${process.pid}-${Date.now()}-${Math.random().toString(36).slice(2)}`;
|
|
48354
|
-
|
|
48355
|
-
|
|
48465
|
+
fs11.writeFileSync(tmp, content, { mode: 384 });
|
|
48466
|
+
fs11.renameSync(tmp, file);
|
|
48356
48467
|
}
|
|
48357
48468
|
};
|
|
48358
48469
|
|
|
@@ -48764,8 +48875,8 @@ var PersonaManager = class {
|
|
|
48764
48875
|
};
|
|
48765
48876
|
|
|
48766
48877
|
// src/persona/seed.ts
|
|
48767
|
-
var
|
|
48768
|
-
var
|
|
48878
|
+
var fs13 = __toESM(require("fs"), 1);
|
|
48879
|
+
var path15 = __toESM(require("path"), 1);
|
|
48769
48880
|
var import_node_url = require("url");
|
|
48770
48881
|
var import_meta = {};
|
|
48771
48882
|
var DEFAULT_BYPASS_PROFILE = {
|
|
@@ -48941,24 +49052,24 @@ function bundleSiblingFromArgv(argv1, sibling) {
|
|
|
48941
49052
|
if (!argv1) return null;
|
|
48942
49053
|
let real = argv1;
|
|
48943
49054
|
try {
|
|
48944
|
-
real =
|
|
49055
|
+
real = fs13.realpathSync(argv1);
|
|
48945
49056
|
} catch {
|
|
48946
49057
|
}
|
|
48947
|
-
return
|
|
49058
|
+
return path15.resolve(path15.dirname(real), sibling);
|
|
48948
49059
|
}
|
|
48949
49060
|
function findDefaultsRoot(logger) {
|
|
48950
49061
|
const candidates = [];
|
|
48951
49062
|
try {
|
|
48952
|
-
const here =
|
|
48953
|
-
candidates.push(
|
|
48954
|
-
candidates.push(
|
|
49063
|
+
const here = path15.dirname((0, import_node_url.fileURLToPath)(import_meta.url));
|
|
49064
|
+
candidates.push(path15.resolve(here, "defaults"));
|
|
49065
|
+
candidates.push(path15.resolve(here, "persona-defaults"));
|
|
48955
49066
|
} catch {
|
|
48956
49067
|
}
|
|
48957
49068
|
const fromArgv = bundleSiblingFromArgv(process.argv[1], "persona-defaults");
|
|
48958
49069
|
if (fromArgv) candidates.push(fromArgv);
|
|
48959
49070
|
for (const c of candidates) {
|
|
48960
49071
|
try {
|
|
48961
|
-
if (
|
|
49072
|
+
if (fs13.statSync(c).isDirectory()) {
|
|
48962
49073
|
logger?.info("persona.defaults-root.resolved", { root: c });
|
|
48963
49074
|
return c;
|
|
48964
49075
|
}
|
|
@@ -48975,8 +49086,8 @@ function seedDefaultPersonas(args) {
|
|
|
48975
49086
|
args.logger.info("persona.seed.skip", { personaId: entry.personaId, reason: "exists" });
|
|
48976
49087
|
continue;
|
|
48977
49088
|
}
|
|
48978
|
-
const bundleDir =
|
|
48979
|
-
if (!
|
|
49089
|
+
const bundleDir = path15.join(args.defaultsRoot, entry.personaId);
|
|
49090
|
+
if (!fs13.existsSync(bundleDir)) {
|
|
48980
49091
|
args.logger.warn("persona.seed.skip", {
|
|
48981
49092
|
personaId: entry.personaId,
|
|
48982
49093
|
reason: "bundle-missing",
|
|
@@ -48984,8 +49095,8 @@ function seedDefaultPersonas(args) {
|
|
|
48984
49095
|
});
|
|
48985
49096
|
continue;
|
|
48986
49097
|
}
|
|
48987
|
-
const claudeMdPath =
|
|
48988
|
-
if (!
|
|
49098
|
+
const claudeMdPath = path15.join(bundleDir, "CLAUDE.md");
|
|
49099
|
+
if (!fs13.existsSync(claudeMdPath)) {
|
|
48989
49100
|
args.logger.warn("persona.seed.skip", {
|
|
48990
49101
|
personaId: entry.personaId,
|
|
48991
49102
|
reason: "no-CLAUDE.md",
|
|
@@ -48993,7 +49104,7 @@ function seedDefaultPersonas(args) {
|
|
|
48993
49104
|
});
|
|
48994
49105
|
continue;
|
|
48995
49106
|
}
|
|
48996
|
-
const personality =
|
|
49107
|
+
const personality = fs13.readFileSync(claudeMdPath, "utf8");
|
|
48997
49108
|
const now = Date.now();
|
|
48998
49109
|
const persona = {
|
|
48999
49110
|
personaId: entry.personaId,
|
|
@@ -49020,51 +49131,51 @@ function seedDefaultPersonas(args) {
|
|
|
49020
49131
|
}
|
|
49021
49132
|
}
|
|
49022
49133
|
function skipNodeModulesUnder(srcRoot) {
|
|
49023
|
-
return (src) => !
|
|
49134
|
+
return (src) => !path15.relative(srcRoot, src).split(path15.sep).includes("node_modules");
|
|
49024
49135
|
}
|
|
49025
49136
|
function copyBundleExtras(srcDir, dstDir) {
|
|
49026
|
-
for (const entry of
|
|
49137
|
+
for (const entry of fs13.readdirSync(srcDir, { withFileTypes: true })) {
|
|
49027
49138
|
if (entry.name === "CLAUDE.md" || entry.name === ".clawd") continue;
|
|
49028
|
-
const srcPath =
|
|
49029
|
-
const dstPath =
|
|
49139
|
+
const srcPath = path15.join(srcDir, entry.name);
|
|
49140
|
+
const dstPath = path15.join(dstDir, entry.name);
|
|
49030
49141
|
if (entry.isDirectory()) {
|
|
49031
|
-
|
|
49142
|
+
fs13.cpSync(srcPath, dstPath, { recursive: true, dereference: true, filter: skipNodeModulesUnder(srcPath) });
|
|
49032
49143
|
} else if (entry.isFile()) {
|
|
49033
|
-
|
|
49144
|
+
fs13.copyFileSync(srcPath, dstPath);
|
|
49034
49145
|
}
|
|
49035
49146
|
}
|
|
49036
49147
|
}
|
|
49037
49148
|
var DAEMON_MANAGED_PATHS = ["extension-kit", "CLAUDE.md", ".mcp.json", ".claude/skills"];
|
|
49038
49149
|
function replaceManagedPath(src, dst) {
|
|
49039
|
-
if (!
|
|
49040
|
-
|
|
49041
|
-
|
|
49042
|
-
|
|
49150
|
+
if (!fs13.statSync(src).isDirectory()) {
|
|
49151
|
+
fs13.mkdirSync(path15.dirname(dst), { recursive: true });
|
|
49152
|
+
fs13.rmSync(dst, { recursive: true, force: true });
|
|
49153
|
+
fs13.cpSync(src, dst, { dereference: true });
|
|
49043
49154
|
return;
|
|
49044
49155
|
}
|
|
49045
|
-
|
|
49046
|
-
for (const e of
|
|
49156
|
+
fs13.mkdirSync(dst, { recursive: true });
|
|
49157
|
+
for (const e of fs13.readdirSync(src, { withFileTypes: true })) {
|
|
49047
49158
|
if (e.name === "node_modules") continue;
|
|
49048
|
-
const child =
|
|
49049
|
-
|
|
49050
|
-
|
|
49159
|
+
const child = path15.join(dst, e.name);
|
|
49160
|
+
fs13.rmSync(child, { recursive: true, force: true });
|
|
49161
|
+
fs13.cpSync(path15.join(src, e.name), child, { recursive: true, dereference: true });
|
|
49051
49162
|
}
|
|
49052
49163
|
}
|
|
49053
49164
|
function refreshDaemonManagedDirs(args) {
|
|
49054
49165
|
const entries = args.entries ?? DEFAULT_PERSONAS;
|
|
49055
49166
|
for (const entry of entries) {
|
|
49056
|
-
const bundleDir =
|
|
49057
|
-
if (!
|
|
49167
|
+
const bundleDir = path15.join(args.defaultsRoot, entry.personaId);
|
|
49168
|
+
if (!fs13.existsSync(bundleDir)) continue;
|
|
49058
49169
|
const personaDir = args.store.personaDirPath(entry.personaId);
|
|
49059
|
-
if (!
|
|
49170
|
+
if (!fs13.existsSync(personaDir)) continue;
|
|
49060
49171
|
for (const relPath of DAEMON_MANAGED_PATHS) {
|
|
49061
|
-
const srcPath =
|
|
49062
|
-
if (!
|
|
49063
|
-
const dstPath =
|
|
49172
|
+
const srcPath = path15.join(bundleDir, relPath);
|
|
49173
|
+
if (!fs13.existsSync(srcPath)) continue;
|
|
49174
|
+
const dstPath = path15.join(personaDir, relPath);
|
|
49064
49175
|
try {
|
|
49065
49176
|
replaceManagedPath(srcPath, dstPath);
|
|
49066
49177
|
if (relPath === "CLAUDE.md") {
|
|
49067
|
-
replaceManagedPath(srcPath,
|
|
49178
|
+
replaceManagedPath(srcPath, path15.join(personaDir, "AGENTS.md"));
|
|
49068
49179
|
}
|
|
49069
49180
|
args.logger.info("persona.refresh.synced", {
|
|
49070
49181
|
personaId: entry.personaId,
|
|
@@ -49164,7 +49275,7 @@ function migrateSandboxAllowRead(args) {
|
|
|
49164
49275
|
for (const personaId2 of args.store.list()) {
|
|
49165
49276
|
try {
|
|
49166
49277
|
const readPath = tildePath(args.store.personaDirPath(personaId2));
|
|
49167
|
-
if (!
|
|
49278
|
+
if (!fs13.existsSync(args.store.sandboxSettingsPath(personaId2))) {
|
|
49168
49279
|
args.store.writeSandboxSettings(personaId2, buildGuestSettingsV1());
|
|
49169
49280
|
n++;
|
|
49170
49281
|
continue;
|
|
@@ -49207,13 +49318,13 @@ var PERSONA_BUILDER_TOMBSTONE = `${PERSONA_BUILDER_TOMBSTONE_MARKER}
|
|
|
49207
49318
|
function containsAnyFile(dir) {
|
|
49208
49319
|
let entries;
|
|
49209
49320
|
try {
|
|
49210
|
-
entries =
|
|
49321
|
+
entries = fs13.readdirSync(dir, { withFileTypes: true });
|
|
49211
49322
|
} catch {
|
|
49212
49323
|
return false;
|
|
49213
49324
|
}
|
|
49214
49325
|
for (const e of entries) {
|
|
49215
49326
|
if (e.isDirectory()) {
|
|
49216
|
-
if (containsAnyFile(
|
|
49327
|
+
if (containsAnyFile(path15.join(dir, e.name))) return true;
|
|
49217
49328
|
} else {
|
|
49218
49329
|
return true;
|
|
49219
49330
|
}
|
|
@@ -49222,9 +49333,9 @@ function containsAnyFile(dir) {
|
|
|
49222
49333
|
}
|
|
49223
49334
|
function retirePersonaBuilder(args) {
|
|
49224
49335
|
const dir = args.store.personaDirPath(PERSONA_BUILDER_ID);
|
|
49225
|
-
if (!
|
|
49336
|
+
if (!fs13.existsSync(dir)) return;
|
|
49226
49337
|
try {
|
|
49227
|
-
const used = containsAnyFile(
|
|
49338
|
+
const used = containsAnyFile(path15.join(dir, ".clawd", "sessions")) || containsAnyFile(path15.join(dir, ".claude", "skills")) || containsAnyFile(path15.join(dir, "projects"));
|
|
49228
49339
|
if (!used) {
|
|
49229
49340
|
args.store.remove(PERSONA_BUILDER_ID);
|
|
49230
49341
|
args.logger.info("persona.retire-builder.removed", { personaId: PERSONA_BUILDER_ID });
|
|
@@ -49232,10 +49343,10 @@ function retirePersonaBuilder(args) {
|
|
|
49232
49343
|
}
|
|
49233
49344
|
let wrote = false;
|
|
49234
49345
|
for (const name of ["CLAUDE.md", "AGENTS.md"]) {
|
|
49235
|
-
const p2 =
|
|
49236
|
-
const cur =
|
|
49346
|
+
const p2 = path15.join(dir, name);
|
|
49347
|
+
const cur = fs13.existsSync(p2) ? fs13.readFileSync(p2, "utf8") : null;
|
|
49237
49348
|
if (cur?.startsWith(PERSONA_BUILDER_TOMBSTONE_MARKER)) continue;
|
|
49238
|
-
|
|
49349
|
+
fs13.writeFileSync(p2, PERSONA_BUILDER_TOMBSTONE);
|
|
49239
49350
|
wrote = true;
|
|
49240
49351
|
}
|
|
49241
49352
|
if (wrote) args.logger.info("persona.retire-builder.tombstoned", { personaId: PERSONA_BUILDER_ID });
|
|
@@ -49249,15 +49360,15 @@ function retirePersonaBuilder(args) {
|
|
|
49249
49360
|
function findDeployKitRoot(logger) {
|
|
49250
49361
|
const candidates = [];
|
|
49251
49362
|
try {
|
|
49252
|
-
const here =
|
|
49253
|
-
candidates.push(
|
|
49363
|
+
const here = path15.dirname((0, import_node_url.fileURLToPath)(import_meta.url));
|
|
49364
|
+
candidates.push(path15.resolve(here, "..", "deploy-kit"));
|
|
49254
49365
|
} catch {
|
|
49255
49366
|
}
|
|
49256
49367
|
const fromArgv = bundleSiblingFromArgv(process.argv[1], "deploy-kit");
|
|
49257
49368
|
if (fromArgv) candidates.push(fromArgv);
|
|
49258
49369
|
for (const c of candidates) {
|
|
49259
49370
|
try {
|
|
49260
|
-
if (
|
|
49371
|
+
if (fs13.statSync(c).isDirectory()) {
|
|
49261
49372
|
logger?.info("persona.deploy-kit-root.resolved", { root: c });
|
|
49262
49373
|
return c;
|
|
49263
49374
|
}
|
|
@@ -49268,8 +49379,8 @@ function findDeployKitRoot(logger) {
|
|
|
49268
49379
|
return null;
|
|
49269
49380
|
}
|
|
49270
49381
|
function seedDeployKit(args) {
|
|
49271
|
-
const dst =
|
|
49272
|
-
|
|
49382
|
+
const dst = path15.join(args.dataDir, "deploy-kit");
|
|
49383
|
+
fs13.cpSync(args.deployKitBundleRoot, dst, {
|
|
49273
49384
|
recursive: true,
|
|
49274
49385
|
dereference: true,
|
|
49275
49386
|
force: false,
|
|
@@ -49278,23 +49389,23 @@ function seedDeployKit(args) {
|
|
|
49278
49389
|
args.logger.info("deploy-kit.seed.done", { dst });
|
|
49279
49390
|
}
|
|
49280
49391
|
function refreshDeployKit(args) {
|
|
49281
|
-
const dst =
|
|
49282
|
-
if (!
|
|
49392
|
+
const dst = path15.join(args.dataDir, "deploy-kit");
|
|
49393
|
+
if (!fs13.existsSync(dst)) {
|
|
49283
49394
|
seedDeployKit(args);
|
|
49284
49395
|
return;
|
|
49285
49396
|
}
|
|
49286
49397
|
for (const sub of ["scripts", "contract"]) {
|
|
49287
|
-
const s =
|
|
49288
|
-
if (
|
|
49289
|
-
|
|
49398
|
+
const s = path15.join(args.deployKitBundleRoot, sub);
|
|
49399
|
+
if (fs13.existsSync(s)) {
|
|
49400
|
+
fs13.cpSync(s, path15.join(dst, sub), { recursive: true, force: true, dereference: true });
|
|
49290
49401
|
}
|
|
49291
49402
|
}
|
|
49292
|
-
const secretsSrc =
|
|
49293
|
-
if (
|
|
49294
|
-
|
|
49295
|
-
for (const f of
|
|
49403
|
+
const secretsSrc = path15.join(args.deployKitBundleRoot, ".secrets");
|
|
49404
|
+
if (fs13.existsSync(secretsSrc)) {
|
|
49405
|
+
fs13.mkdirSync(path15.join(dst, ".secrets"), { recursive: true });
|
|
49406
|
+
for (const f of fs13.readdirSync(secretsSrc)) {
|
|
49296
49407
|
if (f.endsWith(".local")) continue;
|
|
49297
|
-
|
|
49408
|
+
fs13.copyFileSync(path15.join(secretsSrc, f), path15.join(dst, ".secrets", f));
|
|
49298
49409
|
}
|
|
49299
49410
|
}
|
|
49300
49411
|
args.logger.info("deploy-kit.refresh.done", { dst });
|
|
@@ -49324,8 +49435,8 @@ function createViewerAssetLoader(opts) {
|
|
|
49324
49435
|
throw new Error(`viewer error asset not found at ${opts.errorHtmlPath}: ${err.message}`);
|
|
49325
49436
|
}
|
|
49326
49437
|
return {
|
|
49327
|
-
renderViewerHtml(
|
|
49328
|
-
return viewerTemplate.replace(/\{\{TITLE\}\}/g, htmlEscape(
|
|
49438
|
+
renderViewerHtml(basename2) {
|
|
49439
|
+
return viewerTemplate.replace(/\{\{TITLE\}\}/g, htmlEscape(basename2));
|
|
49329
49440
|
},
|
|
49330
49441
|
renderErrorHtml(code, message) {
|
|
49331
49442
|
return errorTemplate.replace(/\{\{ERROR_CODE\}\}/g, htmlEscape(code)).replace(/\{\{ERROR_MESSAGE\}\}/g, htmlEscape(message));
|
|
@@ -49585,8 +49696,8 @@ var CodexAppServerClient = class {
|
|
|
49585
49696
|
pending = /* @__PURE__ */ new Map();
|
|
49586
49697
|
request(method, params) {
|
|
49587
49698
|
const id = this.nextId++;
|
|
49588
|
-
return new Promise((
|
|
49589
|
-
this.pending.set(id, { resolve:
|
|
49699
|
+
return new Promise((resolve7, reject) => {
|
|
49700
|
+
this.pending.set(id, { resolve: resolve7, reject });
|
|
49590
49701
|
this.write({ jsonrpc: "2.0", method, id, params });
|
|
49591
49702
|
});
|
|
49592
49703
|
}
|
|
@@ -49830,8 +49941,8 @@ function turnStartInput(text) {
|
|
|
49830
49941
|
const items = [];
|
|
49831
49942
|
let leftover = text;
|
|
49832
49943
|
for (const m2 of text.matchAll(SKILL_RE)) {
|
|
49833
|
-
const [marker, name,
|
|
49834
|
-
items.push({ type: "skill", name, path:
|
|
49944
|
+
const [marker, name, path83] = m2;
|
|
49945
|
+
items.push({ type: "skill", name, path: path83 });
|
|
49835
49946
|
leftover = leftover.replace(marker, "");
|
|
49836
49947
|
}
|
|
49837
49948
|
for (const m2 of text.matchAll(ATTACHMENT_RE2)) {
|
|
@@ -50875,10 +50986,10 @@ function createTerminalSurface(opts) {
|
|
|
50875
50986
|
},
|
|
50876
50987
|
writeBytes(data, seq) {
|
|
50877
50988
|
pendingParse++;
|
|
50878
|
-
return new Promise((
|
|
50989
|
+
return new Promise((resolve7) => {
|
|
50879
50990
|
term.write(data, () => {
|
|
50880
50991
|
if (disposed) {
|
|
50881
|
-
|
|
50992
|
+
resolve7();
|
|
50882
50993
|
return;
|
|
50883
50994
|
}
|
|
50884
50995
|
if (typeof seq === "number" && seq > parseSeq) parseSeq = seq;
|
|
@@ -50892,14 +51003,14 @@ function createTerminalSurface(opts) {
|
|
|
50892
51003
|
drainWaiters = [];
|
|
50893
51004
|
for (const w2 of waiters) w2();
|
|
50894
51005
|
}
|
|
50895
|
-
|
|
51006
|
+
resolve7();
|
|
50896
51007
|
});
|
|
50897
51008
|
});
|
|
50898
51009
|
},
|
|
50899
51010
|
drain() {
|
|
50900
51011
|
if (pendingParse === 0) return Promise.resolve();
|
|
50901
|
-
return new Promise((
|
|
50902
|
-
drainWaiters.push(
|
|
51012
|
+
return new Promise((resolve7) => {
|
|
51013
|
+
drainWaiters.push(resolve7);
|
|
50903
51014
|
});
|
|
50904
51015
|
},
|
|
50905
51016
|
resize(cols, rows) {
|
|
@@ -50940,7 +51051,7 @@ function inputBoxContent(lines) {
|
|
|
50940
51051
|
function waitInputEcho(surface, opts = {}) {
|
|
50941
51052
|
const stableMs = opts.stableMs ?? 150;
|
|
50942
51053
|
const maxMs = opts.maxMs ?? 5e3;
|
|
50943
|
-
return new Promise((
|
|
51054
|
+
return new Promise((resolve7) => {
|
|
50944
51055
|
let settled = false;
|
|
50945
51056
|
let stableTimer = null;
|
|
50946
51057
|
const finish = () => {
|
|
@@ -50949,7 +51060,7 @@ function waitInputEcho(surface, opts = {}) {
|
|
|
50949
51060
|
unsub();
|
|
50950
51061
|
if (stableTimer) clearTimeout(stableTimer);
|
|
50951
51062
|
clearTimeout(maxTimer);
|
|
50952
|
-
|
|
51063
|
+
resolve7();
|
|
50953
51064
|
};
|
|
50954
51065
|
const unsub = surface.onTick((lines) => {
|
|
50955
51066
|
if (!stableTimer && inputBoxContent(lines).length > 0) {
|
|
@@ -52069,13 +52180,13 @@ function createGhRunner(defaults) {
|
|
|
52069
52180
|
const baseTimeoutMs = defaults?.timeoutMs ?? DEFAULT_TIMEOUT_MS2;
|
|
52070
52181
|
return {
|
|
52071
52182
|
run(args, opts) {
|
|
52072
|
-
return new Promise((
|
|
52183
|
+
return new Promise((resolve7, reject) => {
|
|
52073
52184
|
(0, import_node_child_process7.execFile)(
|
|
52074
52185
|
"gh",
|
|
52075
52186
|
args,
|
|
52076
52187
|
{ timeout: opts?.timeoutMs ?? baseTimeoutMs, maxBuffer: MAX_BUFFER },
|
|
52077
52188
|
(err, stdout, stderr) => {
|
|
52078
|
-
if (!err) return
|
|
52189
|
+
if (!err) return resolve7(stdout);
|
|
52079
52190
|
if (err.code === "ENOENT") {
|
|
52080
52191
|
return reject(new GhError("gh-missing", "GitHub CLI (gh) \u672A\u5B89\u88C5"));
|
|
52081
52192
|
}
|
|
@@ -53787,13 +53898,13 @@ function mapSkillsListResponse(res) {
|
|
|
53787
53898
|
const r = s ?? {};
|
|
53788
53899
|
const name = str3(r.name);
|
|
53789
53900
|
if (!name) continue;
|
|
53790
|
-
const
|
|
53901
|
+
const path83 = str3(r.path);
|
|
53791
53902
|
const description = str3(r.description);
|
|
53792
53903
|
const isPlugin = name.includes(":");
|
|
53793
53904
|
out.push({
|
|
53794
53905
|
name,
|
|
53795
53906
|
source: isPlugin ? "plugin" : "project",
|
|
53796
|
-
...
|
|
53907
|
+
...path83 ? { path: path83 } : {},
|
|
53797
53908
|
...description ? { description } : {},
|
|
53798
53909
|
...isPlugin ? { plugin: name.split(":")[0] } : {}
|
|
53799
53910
|
});
|
|
@@ -54653,13 +54764,13 @@ async function generateSessionTitle(tool, firstMessage, deps = {}) {
|
|
|
54653
54764
|
const args = tool === "claude" ? buildClaudeTitleArgs(buildClaudeTitlePrompt(text)) : buildCodexTitleArgs(buildTitlePrompt(text), outFile, schemaFile);
|
|
54654
54765
|
const doSpawn = deps.spawnOverride ?? ((c, a, o) => (0, import_node_child_process8.spawn)(c, a, { ...o, stdio: ["ignore", "pipe", "pipe"] }));
|
|
54655
54766
|
const timeoutMs = deps.timeoutMs ?? DEFAULT_TITLE_GEN_TIMEOUT_MS;
|
|
54656
|
-
return await new Promise((
|
|
54767
|
+
return await new Promise((resolve7) => {
|
|
54657
54768
|
let proc;
|
|
54658
54769
|
try {
|
|
54659
54770
|
proc = doSpawn(cmd, args, { cwd: workDir });
|
|
54660
54771
|
} catch (err) {
|
|
54661
54772
|
deps.logger?.warn("title-gen spawn failed", { tool, message: err.message });
|
|
54662
|
-
return
|
|
54773
|
+
return resolve7(null);
|
|
54663
54774
|
}
|
|
54664
54775
|
let stdout = "";
|
|
54665
54776
|
let settled = false;
|
|
@@ -54672,7 +54783,7 @@ async function generateSessionTitle(tool, firstMessage, deps = {}) {
|
|
|
54672
54783
|
import_node_fs32.default.rmSync(outFile, { force: true });
|
|
54673
54784
|
} catch {
|
|
54674
54785
|
}
|
|
54675
|
-
|
|
54786
|
+
resolve7(title);
|
|
54676
54787
|
};
|
|
54677
54788
|
const timer = setTimeout(() => {
|
|
54678
54789
|
deps.logger?.warn("title-gen timed out", { tool, timeoutMs });
|
|
@@ -54730,13 +54841,13 @@ function isPreviewPortAllowed(port, cfg) {
|
|
|
54730
54841
|
return cfg.allowedPorts.includes(port);
|
|
54731
54842
|
}
|
|
54732
54843
|
function proxyPreviewHttp(req, res, port) {
|
|
54733
|
-
return new Promise((
|
|
54844
|
+
return new Promise((resolve7) => {
|
|
54734
54845
|
const upstream = import_node_http.default.request(
|
|
54735
54846
|
{ host: "localhost", port, method: req.method, path: req.url, headers: req.headers },
|
|
54736
54847
|
(upRes) => {
|
|
54737
54848
|
res.writeHead(upRes.statusCode || 502, upRes.headers);
|
|
54738
54849
|
upRes.pipe(res);
|
|
54739
|
-
upRes.on("end", () =>
|
|
54850
|
+
upRes.on("end", () => resolve7());
|
|
54740
54851
|
}
|
|
54741
54852
|
);
|
|
54742
54853
|
upstream.on("error", (e) => {
|
|
@@ -54744,7 +54855,7 @@ function proxyPreviewHttp(req, res, port) {
|
|
|
54744
54855
|
res.writeHead(502, { "content-type": "text/plain; charset=utf-8" });
|
|
54745
54856
|
}
|
|
54746
54857
|
res.end(`preview upstream error: ${e.message}`);
|
|
54747
|
-
|
|
54858
|
+
resolve7();
|
|
54748
54859
|
});
|
|
54749
54860
|
req.pipe(upstream);
|
|
54750
54861
|
});
|
|
@@ -54787,7 +54898,7 @@ var LocalWsServer = class {
|
|
|
54787
54898
|
pingIntervalMs;
|
|
54788
54899
|
async start() {
|
|
54789
54900
|
const host = this.opts.host ?? "127.0.0.1";
|
|
54790
|
-
await new Promise((
|
|
54901
|
+
await new Promise((resolve7, reject) => {
|
|
54791
54902
|
const httpServer = import_node_http2.default.createServer((req, res) => this.handleHttpRequest(req, res));
|
|
54792
54903
|
const wss = new import_websocket_server.default({ noServer: true, clientTracking: true });
|
|
54793
54904
|
httpServer.on("upgrade", (req, socket, head) => {
|
|
@@ -54813,7 +54924,7 @@ var LocalWsServer = class {
|
|
|
54813
54924
|
});
|
|
54814
54925
|
httpServer.on("listening", () => {
|
|
54815
54926
|
this.logger?.info("ws listening", { host, port: this.opts.port });
|
|
54816
|
-
|
|
54927
|
+
resolve7();
|
|
54817
54928
|
});
|
|
54818
54929
|
httpServer.on("error", (err) => {
|
|
54819
54930
|
this.logger?.error("ws server error", { err: err.message });
|
|
@@ -54834,11 +54945,11 @@ var LocalWsServer = class {
|
|
|
54834
54945
|
if (c.pingTimer) clearInterval(c.pingTimer);
|
|
54835
54946
|
}
|
|
54836
54947
|
this.clients.clear();
|
|
54837
|
-
await new Promise((
|
|
54838
|
-
this.wss?.close(() =>
|
|
54948
|
+
await new Promise((resolve7) => {
|
|
54949
|
+
this.wss?.close(() => resolve7());
|
|
54839
54950
|
});
|
|
54840
|
-
await new Promise((
|
|
54841
|
-
this.httpServer?.close(() =>
|
|
54951
|
+
await new Promise((resolve7) => {
|
|
54952
|
+
this.httpServer?.close(() => resolve7());
|
|
54842
54953
|
});
|
|
54843
54954
|
this.wss = null;
|
|
54844
54955
|
this.httpServer = null;
|
|
@@ -55380,8 +55491,8 @@ async function authenticate(token, deps) {
|
|
|
55380
55491
|
}
|
|
55381
55492
|
|
|
55382
55493
|
// src/legacy-cleanup.ts
|
|
55383
|
-
var
|
|
55384
|
-
var
|
|
55494
|
+
var fs39 = __toESM(require("fs/promises"), 1);
|
|
55495
|
+
var path40 = __toESM(require("path"), 1);
|
|
55385
55496
|
var LEGACY_FILES = [
|
|
55386
55497
|
"personal-capability.json",
|
|
55387
55498
|
"received-capabilities.json",
|
|
@@ -55390,9 +55501,9 @@ var LEGACY_FILES = [
|
|
|
55390
55501
|
async function cleanupLegacyCapabilityFiles(dataDir, logger) {
|
|
55391
55502
|
const removed = [];
|
|
55392
55503
|
for (const name of LEGACY_FILES) {
|
|
55393
|
-
const p2 =
|
|
55504
|
+
const p2 = path40.join(dataDir, name);
|
|
55394
55505
|
try {
|
|
55395
|
-
await
|
|
55506
|
+
await fs39.unlink(p2);
|
|
55396
55507
|
removed.push(name);
|
|
55397
55508
|
logger.debug("legacy capability file removed", { file: name });
|
|
55398
55509
|
} catch (err) {
|
|
@@ -55404,13 +55515,13 @@ async function cleanupLegacyCapabilityFiles(dataDir, logger) {
|
|
|
55404
55515
|
}
|
|
55405
55516
|
|
|
55406
55517
|
// src/inbox/inbox-store.ts
|
|
55407
|
-
var
|
|
55408
|
-
var
|
|
55518
|
+
var fs40 = __toESM(require("fs"), 1);
|
|
55519
|
+
var path41 = __toESM(require("path"), 1);
|
|
55409
55520
|
var INBOX_SUBDIR = "inbox";
|
|
55410
55521
|
var InboxStore = class {
|
|
55411
55522
|
constructor(dataDir) {
|
|
55412
55523
|
this.dataDir = dataDir;
|
|
55413
|
-
|
|
55524
|
+
fs40.mkdirSync(this.dirPath(), { recursive: true });
|
|
55414
55525
|
}
|
|
55415
55526
|
dataDir;
|
|
55416
55527
|
/**
|
|
@@ -55422,7 +55533,7 @@ var InboxStore = class {
|
|
|
55422
55533
|
const file = this.filePath(peerDeviceId);
|
|
55423
55534
|
let raw;
|
|
55424
55535
|
try {
|
|
55425
|
-
raw =
|
|
55536
|
+
raw = fs40.readFileSync(file, "utf8");
|
|
55426
55537
|
} catch (err) {
|
|
55427
55538
|
if (err?.code === "ENOENT") return [];
|
|
55428
55539
|
return [];
|
|
@@ -55438,7 +55549,7 @@ var InboxStore = class {
|
|
|
55438
55549
|
const dir = this.dirPath();
|
|
55439
55550
|
let entries;
|
|
55440
55551
|
try {
|
|
55441
|
-
entries =
|
|
55552
|
+
entries = fs40.readdirSync(dir);
|
|
55442
55553
|
} catch (err) {
|
|
55443
55554
|
if (err?.code === "ENOENT") return [];
|
|
55444
55555
|
return [];
|
|
@@ -55454,9 +55565,9 @@ var InboxStore = class {
|
|
|
55454
55565
|
if (existing.some((m2) => m2.id === message.id)) return;
|
|
55455
55566
|
const file = this.filePath(message.peerDeviceId);
|
|
55456
55567
|
const line = JSON.stringify(message) + "\n";
|
|
55457
|
-
|
|
55568
|
+
fs40.appendFileSync(file, line, { mode: 384 });
|
|
55458
55569
|
try {
|
|
55459
|
-
|
|
55570
|
+
fs40.chmodSync(file, 384);
|
|
55460
55571
|
} catch {
|
|
55461
55572
|
}
|
|
55462
55573
|
}
|
|
@@ -55486,7 +55597,7 @@ var InboxStore = class {
|
|
|
55486
55597
|
removeByPeerDeviceId(peerDeviceId) {
|
|
55487
55598
|
const file = this.filePath(peerDeviceId);
|
|
55488
55599
|
try {
|
|
55489
|
-
|
|
55600
|
+
fs40.unlinkSync(file);
|
|
55490
55601
|
} catch (err) {
|
|
55491
55602
|
if (err?.code === "ENOENT") return;
|
|
55492
55603
|
}
|
|
@@ -55495,18 +55606,18 @@ var InboxStore = class {
|
|
|
55495
55606
|
const file = this.filePath(peerDeviceId);
|
|
55496
55607
|
const tmp = `${file}.tmp-${process.pid}-${Date.now()}-${Math.random().toString(36).slice(2)}`;
|
|
55497
55608
|
const content = messages.map((m2) => JSON.stringify(m2)).join("\n") + (messages.length > 0 ? "\n" : "");
|
|
55498
|
-
|
|
55499
|
-
|
|
55609
|
+
fs40.writeFileSync(tmp, content, { mode: 384 });
|
|
55610
|
+
fs40.renameSync(tmp, file);
|
|
55500
55611
|
try {
|
|
55501
|
-
|
|
55612
|
+
fs40.chmodSync(file, 384);
|
|
55502
55613
|
} catch {
|
|
55503
55614
|
}
|
|
55504
55615
|
}
|
|
55505
55616
|
dirPath() {
|
|
55506
|
-
return
|
|
55617
|
+
return path41.join(this.dataDir, INBOX_SUBDIR);
|
|
55507
55618
|
}
|
|
55508
55619
|
filePath(peerDeviceId) {
|
|
55509
|
-
return
|
|
55620
|
+
return path41.join(this.dirPath(), `${peerDeviceId}.jsonl`);
|
|
55510
55621
|
}
|
|
55511
55622
|
};
|
|
55512
55623
|
function parseAllLines(raw) {
|
|
@@ -55594,8 +55705,8 @@ var InboxManager = class {
|
|
|
55594
55705
|
};
|
|
55595
55706
|
|
|
55596
55707
|
// src/state/contact-store.ts
|
|
55597
|
-
var
|
|
55598
|
-
var
|
|
55708
|
+
var fs41 = __toESM(require("fs"), 1);
|
|
55709
|
+
var path42 = __toESM(require("path"), 1);
|
|
55599
55710
|
var FILE_NAME = "contacts.json";
|
|
55600
55711
|
var ContactStore = class {
|
|
55601
55712
|
constructor(dataDir) {
|
|
@@ -55605,10 +55716,10 @@ var ContactStore = class {
|
|
|
55605
55716
|
contacts = /* @__PURE__ */ new Map();
|
|
55606
55717
|
load() {
|
|
55607
55718
|
this.contacts.clear();
|
|
55608
|
-
const file =
|
|
55719
|
+
const file = path42.join(this.dataDir, FILE_NAME);
|
|
55609
55720
|
let raw;
|
|
55610
55721
|
try {
|
|
55611
|
-
raw =
|
|
55722
|
+
raw = fs41.readFileSync(file, "utf8");
|
|
55612
55723
|
} catch (err) {
|
|
55613
55724
|
if (err?.code !== "ENOENT") this.renameBak(file);
|
|
55614
55725
|
return;
|
|
@@ -55677,20 +55788,20 @@ var ContactStore = class {
|
|
|
55677
55788
|
return true;
|
|
55678
55789
|
}
|
|
55679
55790
|
flush() {
|
|
55680
|
-
const file =
|
|
55791
|
+
const file = path42.join(this.dataDir, FILE_NAME);
|
|
55681
55792
|
const tmp = `${file}.tmp-${process.pid}-${Date.now()}`;
|
|
55682
55793
|
const content = JSON.stringify(
|
|
55683
55794
|
{ contacts: Array.from(this.contacts.values()) },
|
|
55684
55795
|
null,
|
|
55685
55796
|
2
|
|
55686
55797
|
);
|
|
55687
|
-
|
|
55688
|
-
|
|
55689
|
-
|
|
55798
|
+
fs41.mkdirSync(this.dataDir, { recursive: true });
|
|
55799
|
+
fs41.writeFileSync(tmp, content, { mode: 384 });
|
|
55800
|
+
fs41.renameSync(tmp, file);
|
|
55690
55801
|
}
|
|
55691
55802
|
renameBak(file) {
|
|
55692
55803
|
try {
|
|
55693
|
-
|
|
55804
|
+
fs41.renameSync(file, `${file}.bak`);
|
|
55694
55805
|
} catch {
|
|
55695
55806
|
}
|
|
55696
55807
|
}
|
|
@@ -55703,16 +55814,16 @@ var HANDSHAKE_TIMEOUT_MS = 5e3;
|
|
|
55703
55814
|
var RPC_TIMEOUT_MS = 5e3;
|
|
55704
55815
|
async function connectRemote(args) {
|
|
55705
55816
|
const ws = new wrapper_default(args.url);
|
|
55706
|
-
await new Promise((
|
|
55817
|
+
await new Promise((resolve7, reject) => {
|
|
55707
55818
|
const onError = (e) => reject(e);
|
|
55708
55819
|
ws.once("open", () => {
|
|
55709
55820
|
ws.off("error", onError);
|
|
55710
|
-
|
|
55821
|
+
resolve7();
|
|
55711
55822
|
});
|
|
55712
55823
|
ws.once("error", onError);
|
|
55713
55824
|
});
|
|
55714
55825
|
ws.send(JSON.stringify({ type: "auth", token: args.token }));
|
|
55715
|
-
await new Promise((
|
|
55826
|
+
await new Promise((resolve7, reject) => {
|
|
55716
55827
|
const onMessage = (raw) => {
|
|
55717
55828
|
let f;
|
|
55718
55829
|
try {
|
|
@@ -55722,7 +55833,7 @@ async function connectRemote(args) {
|
|
|
55722
55833
|
}
|
|
55723
55834
|
if (f.type === "auth:ok") {
|
|
55724
55835
|
finish();
|
|
55725
|
-
|
|
55836
|
+
resolve7();
|
|
55726
55837
|
return;
|
|
55727
55838
|
}
|
|
55728
55839
|
if (f.type === "auth:error" || f.code === 4401) {
|
|
@@ -55753,7 +55864,7 @@ async function connectRemote(args) {
|
|
|
55753
55864
|
});
|
|
55754
55865
|
function call(method, payload) {
|
|
55755
55866
|
const requestId = crypto5.randomUUID();
|
|
55756
|
-
return new Promise((
|
|
55867
|
+
return new Promise((resolve7, reject) => {
|
|
55757
55868
|
const onMessage = (raw) => {
|
|
55758
55869
|
let f;
|
|
55759
55870
|
try {
|
|
@@ -55766,7 +55877,7 @@ async function connectRemote(args) {
|
|
|
55766
55877
|
if (f.error || f.type === "error" || f.type?.endsWith(":error")) {
|
|
55767
55878
|
reject(new Error(f.message ?? f.error ?? "rpc error"));
|
|
55768
55879
|
} else {
|
|
55769
|
-
|
|
55880
|
+
resolve7(f);
|
|
55770
55881
|
}
|
|
55771
55882
|
};
|
|
55772
55883
|
ws.on("message", onMessage);
|
|
@@ -55798,61 +55909,61 @@ async function connectRemote(args) {
|
|
|
55798
55909
|
}
|
|
55799
55910
|
|
|
55800
55911
|
// src/migrations/2026-05-20-flatten-sessions.ts
|
|
55801
|
-
var
|
|
55802
|
-
var
|
|
55912
|
+
var fs42 = __toESM(require("fs"), 1);
|
|
55913
|
+
var path43 = __toESM(require("path"), 1);
|
|
55803
55914
|
var MIGRATION_FLAG_NAME = ".migration.v1.done";
|
|
55804
55915
|
function migrateFlattenSessions(opts) {
|
|
55805
55916
|
const dataDir = opts.dataDir;
|
|
55806
55917
|
const now = opts.now ?? Date.now;
|
|
55807
|
-
const sessionsDir =
|
|
55808
|
-
const flagPath =
|
|
55918
|
+
const sessionsDir = path43.join(dataDir, "sessions");
|
|
55919
|
+
const flagPath = path43.join(sessionsDir, MIGRATION_FLAG_NAME);
|
|
55809
55920
|
if (existsSync3(flagPath)) {
|
|
55810
55921
|
return { skipped: true, flagWritten: false, movedBare: 0, movedVmOwner: 0, archivedListener: 0 };
|
|
55811
55922
|
}
|
|
55812
55923
|
let movedBare = 0;
|
|
55813
55924
|
let movedVmOwner = 0;
|
|
55814
55925
|
let archivedListener = 0;
|
|
55815
|
-
const defaultDir =
|
|
55926
|
+
const defaultDir = path43.join(sessionsDir, "default");
|
|
55816
55927
|
if (existsSync3(defaultDir)) {
|
|
55817
55928
|
for (const entry of readdirSafe(defaultDir)) {
|
|
55818
55929
|
if (!entry.endsWith(".json")) continue;
|
|
55819
|
-
const src =
|
|
55820
|
-
const dst =
|
|
55821
|
-
|
|
55930
|
+
const src = path43.join(defaultDir, entry);
|
|
55931
|
+
const dst = path43.join(sessionsDir, entry);
|
|
55932
|
+
fs42.renameSync(src, dst);
|
|
55822
55933
|
movedBare += 1;
|
|
55823
55934
|
}
|
|
55824
55935
|
rmdirIfEmpty(defaultDir);
|
|
55825
55936
|
}
|
|
55826
55937
|
for (const pid of readdirSafe(sessionsDir)) {
|
|
55827
|
-
const personaDir =
|
|
55938
|
+
const personaDir = path43.join(sessionsDir, pid);
|
|
55828
55939
|
if (!isDir(personaDir)) continue;
|
|
55829
55940
|
if (pid === "default") continue;
|
|
55830
|
-
const ownerSrc =
|
|
55941
|
+
const ownerSrc = path43.join(personaDir, "owner");
|
|
55831
55942
|
if (existsSync3(ownerSrc) && isDir(ownerSrc)) {
|
|
55832
|
-
const ownerDst =
|
|
55833
|
-
|
|
55943
|
+
const ownerDst = path43.join(dataDir, "personas", pid, ".clawd", "sessions", "owner");
|
|
55944
|
+
fs42.mkdirSync(ownerDst, { recursive: true });
|
|
55834
55945
|
for (const file of readdirSafe(ownerSrc)) {
|
|
55835
55946
|
if (!file.endsWith(".json")) continue;
|
|
55836
|
-
|
|
55947
|
+
fs42.renameSync(path43.join(ownerSrc, file), path43.join(ownerDst, file));
|
|
55837
55948
|
movedVmOwner += 1;
|
|
55838
55949
|
}
|
|
55839
55950
|
rmdirIfEmpty(ownerSrc);
|
|
55840
55951
|
}
|
|
55841
|
-
const listenerSrc =
|
|
55952
|
+
const listenerSrc = path43.join(personaDir, "listener");
|
|
55842
55953
|
if (existsSync3(listenerSrc) && isDir(listenerSrc)) {
|
|
55843
|
-
const archiveDst =
|
|
55844
|
-
|
|
55954
|
+
const archiveDst = path43.join(dataDir, ".legacy", `listener-${pid}`);
|
|
55955
|
+
fs42.mkdirSync(archiveDst, { recursive: true });
|
|
55845
55956
|
for (const file of readdirSafe(listenerSrc)) {
|
|
55846
55957
|
if (!file.endsWith(".json")) continue;
|
|
55847
|
-
|
|
55958
|
+
fs42.renameSync(path43.join(listenerSrc, file), path43.join(archiveDst, file));
|
|
55848
55959
|
archivedListener += 1;
|
|
55849
55960
|
}
|
|
55850
55961
|
rmdirIfEmpty(listenerSrc);
|
|
55851
55962
|
}
|
|
55852
55963
|
rmdirIfEmpty(personaDir);
|
|
55853
55964
|
}
|
|
55854
|
-
|
|
55855
|
-
|
|
55965
|
+
fs42.mkdirSync(sessionsDir, { recursive: true });
|
|
55966
|
+
fs42.writeFileSync(flagPath, JSON.stringify({ migratedAt: now() }, null, 2));
|
|
55856
55967
|
return {
|
|
55857
55968
|
skipped: false,
|
|
55858
55969
|
flagWritten: true,
|
|
@@ -55863,7 +55974,7 @@ function migrateFlattenSessions(opts) {
|
|
|
55863
55974
|
}
|
|
55864
55975
|
function existsSync3(p2) {
|
|
55865
55976
|
try {
|
|
55866
|
-
|
|
55977
|
+
fs42.statSync(p2);
|
|
55867
55978
|
return true;
|
|
55868
55979
|
} catch {
|
|
55869
55980
|
return false;
|
|
@@ -55871,21 +55982,21 @@ function existsSync3(p2) {
|
|
|
55871
55982
|
}
|
|
55872
55983
|
function isDir(p2) {
|
|
55873
55984
|
try {
|
|
55874
|
-
return
|
|
55985
|
+
return fs42.statSync(p2).isDirectory();
|
|
55875
55986
|
} catch {
|
|
55876
55987
|
return false;
|
|
55877
55988
|
}
|
|
55878
55989
|
}
|
|
55879
55990
|
function readdirSafe(p2) {
|
|
55880
55991
|
try {
|
|
55881
|
-
return
|
|
55992
|
+
return fs42.readdirSync(p2);
|
|
55882
55993
|
} catch {
|
|
55883
55994
|
return [];
|
|
55884
55995
|
}
|
|
55885
55996
|
}
|
|
55886
55997
|
function rmdirIfEmpty(p2) {
|
|
55887
55998
|
try {
|
|
55888
|
-
|
|
55999
|
+
fs42.rmdirSync(p2);
|
|
55889
56000
|
} catch {
|
|
55890
56001
|
}
|
|
55891
56002
|
}
|
|
@@ -56303,7 +56414,7 @@ function authedRpcErrorStatus(code) {
|
|
|
56303
56414
|
}
|
|
56304
56415
|
var LARK_BOT_EVENT_MAX_BYTES = 64 * 1024;
|
|
56305
56416
|
async function readRawBody(req, max) {
|
|
56306
|
-
return await new Promise((
|
|
56417
|
+
return await new Promise((resolve7, reject) => {
|
|
56307
56418
|
let size = 0;
|
|
56308
56419
|
const chunks = [];
|
|
56309
56420
|
req.on("data", (c) => {
|
|
@@ -56315,12 +56426,12 @@ async function readRawBody(req, max) {
|
|
|
56315
56426
|
}
|
|
56316
56427
|
chunks.push(c);
|
|
56317
56428
|
});
|
|
56318
|
-
req.on("end", () =>
|
|
56429
|
+
req.on("end", () => resolve7(Buffer.concat(chunks).toString("utf8")));
|
|
56319
56430
|
req.on("error", reject);
|
|
56320
56431
|
});
|
|
56321
56432
|
}
|
|
56322
56433
|
async function readJsonBody(req, max) {
|
|
56323
|
-
return await new Promise((
|
|
56434
|
+
return await new Promise((resolve7, reject) => {
|
|
56324
56435
|
let size = 0;
|
|
56325
56436
|
const chunks = [];
|
|
56326
56437
|
req.on("data", (c) => {
|
|
@@ -56334,9 +56445,9 @@ async function readJsonBody(req, max) {
|
|
|
56334
56445
|
});
|
|
56335
56446
|
req.on("end", () => {
|
|
56336
56447
|
const raw = Buffer.concat(chunks).toString("utf8");
|
|
56337
|
-
if (!raw) return
|
|
56448
|
+
if (!raw) return resolve7({});
|
|
56338
56449
|
try {
|
|
56339
|
-
|
|
56450
|
+
resolve7(JSON.parse(raw));
|
|
56340
56451
|
} catch {
|
|
56341
56452
|
reject(new Error("invalid JSON body"));
|
|
56342
56453
|
}
|
|
@@ -56842,11 +56953,11 @@ function streamFile(res, absPath, logger) {
|
|
|
56842
56953
|
return;
|
|
56843
56954
|
}
|
|
56844
56955
|
const mime = lookupMime(absPath);
|
|
56845
|
-
const
|
|
56956
|
+
const basename2 = import_node_path38.default.basename(absPath);
|
|
56846
56957
|
res.writeHead(200, {
|
|
56847
56958
|
"Content-Type": mime,
|
|
56848
56959
|
"Content-Length": String(stat.size),
|
|
56849
|
-
"Content-Disposition": `inline; filename*=UTF-8''${encodeURIComponent(
|
|
56960
|
+
"Content-Disposition": `inline; filename*=UTF-8''${encodeURIComponent(basename2)}`,
|
|
56850
56961
|
// 防止浏览器把任意 mime 当 html 渲染
|
|
56851
56962
|
"X-Content-Type-Options": "nosniff"
|
|
56852
56963
|
});
|
|
@@ -57381,10 +57492,10 @@ async function extractFrpcFromTarball(tarball, binDir, version2, platform, destB
|
|
|
57381
57492
|
const work = import_node_path43.default.join(binDir, `extract-${process.pid}-${Date.now()}`);
|
|
57382
57493
|
import_node_fs39.default.mkdirSync(work, { recursive: true });
|
|
57383
57494
|
try {
|
|
57384
|
-
await new Promise((
|
|
57495
|
+
await new Promise((resolve7, reject) => {
|
|
57385
57496
|
const proc = (0, import_node_child_process9.spawn)("tar", ["xzf", tarball, "-C", work], { stdio: "pipe" });
|
|
57386
57497
|
proc.on("error", reject);
|
|
57387
|
-
proc.on("exit", (code) => code === 0 ?
|
|
57498
|
+
proc.on("exit", (code) => code === 0 ? resolve7() : reject(new Error(`tar exited ${code}`)));
|
|
57388
57499
|
});
|
|
57389
57500
|
const dirName = `frp_${version2}_${platform.os}_${platform.arch}`;
|
|
57390
57501
|
const src = import_node_path43.default.join(work, dirName, "frpc");
|
|
@@ -57485,7 +57596,7 @@ async function killStaleFrpc(deps) {
|
|
|
57485
57596
|
}
|
|
57486
57597
|
async function defaultScanFrpcPidsByCmdline(tomlPath, logger) {
|
|
57487
57598
|
if (process.platform === "win32") return [];
|
|
57488
|
-
return new Promise((
|
|
57599
|
+
return new Promise((resolve7) => {
|
|
57489
57600
|
const ps = (0, import_node_child_process10.spawn)("ps", ["-axo", "pid=,command="], { stdio: ["ignore", "pipe", "ignore"] });
|
|
57490
57601
|
let buf = "";
|
|
57491
57602
|
ps.stdout.on("data", (c) => {
|
|
@@ -57502,11 +57613,11 @@ async function defaultScanFrpcPidsByCmdline(tomlPath, logger) {
|
|
|
57502
57613
|
const pid = parseInt(m2[1], 10);
|
|
57503
57614
|
if (Number.isFinite(pid) && pid > 0) pids.push(pid);
|
|
57504
57615
|
}
|
|
57505
|
-
|
|
57616
|
+
resolve7(pids);
|
|
57506
57617
|
});
|
|
57507
57618
|
ps.on("error", (e) => {
|
|
57508
57619
|
logger?.warn("tunnel: ps scan failed", { err: e.message });
|
|
57509
|
-
|
|
57620
|
+
resolve7([]);
|
|
57510
57621
|
});
|
|
57511
57622
|
});
|
|
57512
57623
|
}
|
|
@@ -57584,17 +57695,17 @@ var TunnelManager = class {
|
|
|
57584
57695
|
return;
|
|
57585
57696
|
}
|
|
57586
57697
|
proc.kill("SIGTERM");
|
|
57587
|
-
await new Promise((
|
|
57698
|
+
await new Promise((resolve7) => {
|
|
57588
57699
|
const t = setTimeout(() => {
|
|
57589
57700
|
try {
|
|
57590
57701
|
proc.kill("SIGKILL");
|
|
57591
57702
|
} catch {
|
|
57592
57703
|
}
|
|
57593
|
-
|
|
57704
|
+
resolve7();
|
|
57594
57705
|
}, 5e3);
|
|
57595
57706
|
proc.once("exit", () => {
|
|
57596
57707
|
clearTimeout(t);
|
|
57597
|
-
|
|
57708
|
+
resolve7();
|
|
57598
57709
|
});
|
|
57599
57710
|
});
|
|
57600
57711
|
clearFrpcPid(this.deps.dataDir);
|
|
@@ -57700,14 +57811,14 @@ function formatFrpcTail(raw, maxLines = 12) {
|
|
|
57700
57811
|
return ["\u2500\u2500\u2500 frpc output (last lines) \u2500\u2500\u2500", tail, "\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"].join("\n");
|
|
57701
57812
|
}
|
|
57702
57813
|
async function waitForFrpcReady(proc, timeoutMs) {
|
|
57703
|
-
return new Promise((
|
|
57814
|
+
return new Promise((resolve7) => {
|
|
57704
57815
|
let settled = false;
|
|
57705
57816
|
let buf = "";
|
|
57706
57817
|
const finish = (r) => {
|
|
57707
57818
|
if (settled) return;
|
|
57708
57819
|
settled = true;
|
|
57709
57820
|
cleanup();
|
|
57710
|
-
|
|
57821
|
+
resolve7(r);
|
|
57711
57822
|
};
|
|
57712
57823
|
const onData = (chunk) => {
|
|
57713
57824
|
buf += String(chunk);
|
|
@@ -58052,9 +58163,9 @@ var CentralClientError = class extends Error {
|
|
|
58052
58163
|
code;
|
|
58053
58164
|
cause;
|
|
58054
58165
|
};
|
|
58055
|
-
async function centralRequest(opts,
|
|
58166
|
+
async function centralRequest(opts, path83, init) {
|
|
58056
58167
|
const f = opts.fetchImpl ?? globalThis.fetch;
|
|
58057
|
-
const url = `${opts.api.replace(/\/+$/, "")}${
|
|
58168
|
+
const url = `${opts.api.replace(/\/+$/, "")}${path83}`;
|
|
58058
58169
|
const ctrl = new AbortController();
|
|
58059
58170
|
const timer = setTimeout(() => ctrl.abort(), opts.timeoutMs ?? 15e3);
|
|
58060
58171
|
let res;
|
|
@@ -58248,8 +58359,8 @@ function verifyConnectToken(args) {
|
|
|
58248
58359
|
}
|
|
58249
58360
|
|
|
58250
58361
|
// src/feishu-auth/server-key.ts
|
|
58251
|
-
var
|
|
58252
|
-
var
|
|
58362
|
+
var fs56 = __toESM(require("fs"), 1);
|
|
58363
|
+
var path59 = __toESM(require("path"), 1);
|
|
58253
58364
|
var FILE_NAME2 = "server-signing-key.json";
|
|
58254
58365
|
var ServerKeyStore = class {
|
|
58255
58366
|
constructor(dataDir) {
|
|
@@ -58257,12 +58368,12 @@ var ServerKeyStore = class {
|
|
|
58257
58368
|
}
|
|
58258
58369
|
dataDir;
|
|
58259
58370
|
filePath() {
|
|
58260
|
-
return
|
|
58371
|
+
return path59.join(this.dataDir, FILE_NAME2);
|
|
58261
58372
|
}
|
|
58262
58373
|
/** 读缓存的公钥;无缓存 / 损坏 → null(调用方决定是否触发拉取) */
|
|
58263
58374
|
read() {
|
|
58264
58375
|
try {
|
|
58265
|
-
const raw =
|
|
58376
|
+
const raw = fs56.readFileSync(this.filePath(), "utf8");
|
|
58266
58377
|
const parsed = JSON.parse(raw);
|
|
58267
58378
|
if (typeof parsed.publicKeyPem === "string" && parsed.publicKeyPem.includes("PUBLIC KEY")) {
|
|
58268
58379
|
return parsed.publicKeyPem;
|
|
@@ -58277,12 +58388,12 @@ var ServerKeyStore = class {
|
|
|
58277
58388
|
publicKeyPem,
|
|
58278
58389
|
fetchedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
58279
58390
|
};
|
|
58280
|
-
|
|
58281
|
-
|
|
58391
|
+
fs56.mkdirSync(this.dataDir, { recursive: true });
|
|
58392
|
+
fs56.writeFileSync(this.filePath(), JSON.stringify(content, null, 2), { mode: 384 });
|
|
58282
58393
|
}
|
|
58283
58394
|
clear() {
|
|
58284
58395
|
try {
|
|
58285
|
-
|
|
58396
|
+
fs56.unlinkSync(this.filePath());
|
|
58286
58397
|
} catch {
|
|
58287
58398
|
}
|
|
58288
58399
|
}
|
|
@@ -58720,6 +58831,12 @@ function buildSessionHandlers(deps) {
|
|
|
58720
58831
|
effort = args.effort ?? (toolOverridden ? void 0 : persona.effort);
|
|
58721
58832
|
}
|
|
58722
58833
|
ensurePersonaAccess(ctx, args.ownerPersonaId, "send");
|
|
58834
|
+
if (args.projectPath && ctx && ctx.principal.kind !== "owner") {
|
|
58835
|
+
throw new ClawdError(
|
|
58836
|
+
ERROR_CODES.UNAUTHORIZED,
|
|
58837
|
+
`principal ${ctx.principal.kind}:${ctx.principal.id} cannot pass projectPath`
|
|
58838
|
+
);
|
|
58839
|
+
}
|
|
58723
58840
|
const creatorPrincipalId = ctx?.principal.id ?? ownerPrincipalId;
|
|
58724
58841
|
const creatorDisplayName = ctx?.principal.displayName ?? "Owner";
|
|
58725
58842
|
const creatorFeishuUnionId = ctx?.principal.feishuUnionId;
|
|
@@ -58729,6 +58846,12 @@ function buildSessionHandlers(deps) {
|
|
|
58729
58846
|
creatorDisplayName,
|
|
58730
58847
|
creatorFeishuUnionId
|
|
58731
58848
|
);
|
|
58849
|
+
deps.projects?.seedFromSessions([
|
|
58850
|
+
{
|
|
58851
|
+
cwd: response.cwd,
|
|
58852
|
+
...args.projectPath ? { projectPath: args.projectPath } : {}
|
|
58853
|
+
}
|
|
58854
|
+
]);
|
|
58732
58855
|
return { response: { type: "session:info", ...response }, broadcast };
|
|
58733
58856
|
};
|
|
58734
58857
|
const importExternal = async (frame, _client, ctx) => {
|
|
@@ -58754,6 +58877,7 @@ function buildSessionHandlers(deps) {
|
|
|
58754
58877
|
creatorDisplayName,
|
|
58755
58878
|
creatorFeishuUnionId
|
|
58756
58879
|
);
|
|
58880
|
+
deps.projects?.seedFromSessions([{ cwd: args.cwd }]);
|
|
58757
58881
|
if (deps.dataDir && !("alreadyLinked" in response)) {
|
|
58758
58882
|
appendImportLedger(deps.dataDir, {
|
|
58759
58883
|
sessionId: String(response.sessionId),
|
|
@@ -59168,7 +59292,7 @@ function buildPermissionHandlers(deps) {
|
|
|
59168
59292
|
}
|
|
59169
59293
|
|
|
59170
59294
|
// src/handlers/history.ts
|
|
59171
|
-
var
|
|
59295
|
+
var path64 = __toESM(require("path"), 1);
|
|
59172
59296
|
init_protocol();
|
|
59173
59297
|
|
|
59174
59298
|
// src/session/recent-dirs.ts
|
|
@@ -59186,7 +59310,7 @@ function listRecentDirs(store, limit = 50) {
|
|
|
59186
59310
|
}
|
|
59187
59311
|
|
|
59188
59312
|
// src/permission/persona-paths.ts
|
|
59189
|
-
var
|
|
59313
|
+
var path63 = __toESM(require("path"), 1);
|
|
59190
59314
|
function getAllowedPersonaIds(grants, action) {
|
|
59191
59315
|
const ids = /* @__PURE__ */ new Set();
|
|
59192
59316
|
for (const g2 of grants) {
|
|
@@ -59199,42 +59323,42 @@ function getAllowedPersonaIds(grants, action) {
|
|
|
59199
59323
|
return ids;
|
|
59200
59324
|
}
|
|
59201
59325
|
function isGuestPathAllowed(grants, absPath, personaRoot, action = "read", userWorkDir) {
|
|
59202
|
-
const target =
|
|
59326
|
+
const target = path63.resolve(absPath);
|
|
59203
59327
|
if (userWorkDir) {
|
|
59204
|
-
const u =
|
|
59205
|
-
const usep = u.endsWith(
|
|
59328
|
+
const u = path63.resolve(userWorkDir);
|
|
59329
|
+
const usep = u.endsWith(path63.sep) ? "" : path63.sep;
|
|
59206
59330
|
if (target === u || target.startsWith(u + usep)) return true;
|
|
59207
59331
|
}
|
|
59208
|
-
const root =
|
|
59209
|
-
const sep3 = root.endsWith(
|
|
59332
|
+
const root = path63.resolve(personaRoot);
|
|
59333
|
+
const sep3 = root.endsWith(path63.sep) ? "" : path63.sep;
|
|
59210
59334
|
if (!target.startsWith(root + sep3)) return false;
|
|
59211
|
-
const rel =
|
|
59335
|
+
const rel = path63.relative(root, target);
|
|
59212
59336
|
if (!rel || rel.startsWith("..")) return false;
|
|
59213
|
-
const personaId2 = rel.split(
|
|
59337
|
+
const personaId2 = rel.split(path63.sep)[0];
|
|
59214
59338
|
if (!personaId2) return false;
|
|
59215
59339
|
const allowed = getAllowedPersonaIds(grants, action);
|
|
59216
59340
|
if (allowed === "*") return true;
|
|
59217
59341
|
return allowed.has(personaId2);
|
|
59218
59342
|
}
|
|
59219
59343
|
function personaIdFromPath(absPath, personaRoot) {
|
|
59220
|
-
const root =
|
|
59221
|
-
const target =
|
|
59222
|
-
const sep3 = root.endsWith(
|
|
59344
|
+
const root = path63.resolve(personaRoot);
|
|
59345
|
+
const target = path63.resolve(absPath);
|
|
59346
|
+
const sep3 = root.endsWith(path63.sep) ? "" : path63.sep;
|
|
59223
59347
|
if (!target.startsWith(root + sep3)) return null;
|
|
59224
|
-
const rel =
|
|
59348
|
+
const rel = path63.relative(root, target);
|
|
59225
59349
|
if (!rel || rel.startsWith("..")) return null;
|
|
59226
|
-
const id = rel.split(
|
|
59350
|
+
const id = rel.split(path63.sep)[0];
|
|
59227
59351
|
return id || null;
|
|
59228
59352
|
}
|
|
59229
59353
|
function isPathWithin(dir, absPath) {
|
|
59230
|
-
const d =
|
|
59231
|
-
const t =
|
|
59232
|
-
const sep3 = d.endsWith(
|
|
59354
|
+
const d = path63.resolve(dir);
|
|
59355
|
+
const t = path63.resolve(absPath);
|
|
59356
|
+
const sep3 = d.endsWith(path63.sep) ? "" : path63.sep;
|
|
59233
59357
|
return t === d || t.startsWith(d + sep3);
|
|
59234
59358
|
}
|
|
59235
59359
|
function isPathInGuestBoundary(personaRoot, personaId2, userWorkDir, absPath) {
|
|
59236
59360
|
if (userWorkDir && isPathWithin(userWorkDir, absPath)) return true;
|
|
59237
|
-
return personaIdFromPath(
|
|
59361
|
+
return personaIdFromPath(path63.resolve(absPath), personaRoot) === personaId2;
|
|
59238
59362
|
}
|
|
59239
59363
|
|
|
59240
59364
|
// src/handlers/history.ts
|
|
@@ -59287,7 +59411,7 @@ function buildHistoryHandlers(deps) {
|
|
|
59287
59411
|
if (!pid) return false;
|
|
59288
59412
|
return isGuestPathAllowed(
|
|
59289
59413
|
ctx.grants,
|
|
59290
|
-
|
|
59414
|
+
path64.join(personaRoot, pid),
|
|
59291
59415
|
personaRoot,
|
|
59292
59416
|
"read",
|
|
59293
59417
|
userWorkDir
|
|
@@ -59299,7 +59423,7 @@ function buildHistoryHandlers(deps) {
|
|
|
59299
59423
|
};
|
|
59300
59424
|
const list = async (frame, _client, ctx) => {
|
|
59301
59425
|
const args = HistoryListArgs.parse(frame);
|
|
59302
|
-
assertGuestPath(ctx,
|
|
59426
|
+
assertGuestPath(ctx, path64.resolve(args.projectPath), personaRoot, "history:list", usersRoot);
|
|
59303
59427
|
const sessions = await history.listSessions(args);
|
|
59304
59428
|
return { response: { type: "history:list", sessions } };
|
|
59305
59429
|
};
|
|
@@ -59343,14 +59467,14 @@ function buildHistoryHandlers(deps) {
|
|
|
59343
59467
|
};
|
|
59344
59468
|
const subagents = async (frame, _client, ctx) => {
|
|
59345
59469
|
const args = HistorySubagentsArgs.parse(frame);
|
|
59346
|
-
assertGuestPath(ctx,
|
|
59470
|
+
assertGuestPath(ctx, path64.resolve(args.cwd), personaRoot, "history:subagents", usersRoot);
|
|
59347
59471
|
assertGuestOwnsToolSession(ctx, args.toolSessionId, "history:subagents");
|
|
59348
59472
|
const subs = await history.listSubagents(args);
|
|
59349
59473
|
return { response: { type: "history:subagents", subagents: subs } };
|
|
59350
59474
|
};
|
|
59351
59475
|
const subagentRead = async (frame, _client, ctx) => {
|
|
59352
59476
|
const args = HistorySubagentReadArgs.parse(frame);
|
|
59353
|
-
assertGuestPath(ctx,
|
|
59477
|
+
assertGuestPath(ctx, path64.resolve(args.cwd), personaRoot, "history:subagent-read", usersRoot);
|
|
59354
59478
|
assertGuestOwnsToolSession(ctx, args.toolSessionId, "history:subagent-read");
|
|
59355
59479
|
const res = await history.readSubagent(args);
|
|
59356
59480
|
return { response: { type: "history:subagent-read", ...res } };
|
|
@@ -59360,7 +59484,7 @@ function buildHistoryHandlers(deps) {
|
|
|
59360
59484
|
if (ctx?.principal.kind === "guest" && personaRoot) {
|
|
59361
59485
|
const userWorkDir = usersRoot ? deriveUserWorkDir(ctx.principal.id, usersRoot) : void 0;
|
|
59362
59486
|
const filtered = dirs.filter(
|
|
59363
|
-
(d) => isGuestPathAllowed(ctx.grants,
|
|
59487
|
+
(d) => isGuestPathAllowed(ctx.grants, path64.resolve(d.cwd), personaRoot, "read", userWorkDir)
|
|
59364
59488
|
);
|
|
59365
59489
|
return { response: { type: "history:recentDirs", dirs: filtered } };
|
|
59366
59490
|
}
|
|
@@ -59376,9 +59500,42 @@ function buildHistoryHandlers(deps) {
|
|
|
59376
59500
|
};
|
|
59377
59501
|
}
|
|
59378
59502
|
|
|
59503
|
+
// src/handlers/projects.ts
|
|
59504
|
+
var fs60 = __toESM(require("fs"), 1);
|
|
59505
|
+
init_protocol();
|
|
59506
|
+
function buildProjectHandlers(deps) {
|
|
59507
|
+
const store = () => {
|
|
59508
|
+
if (!deps.projects) {
|
|
59509
|
+
throw new ClawdError(ERROR_CODES.INVALID_CWD, "projects store not wired");
|
|
59510
|
+
}
|
|
59511
|
+
return deps.projects;
|
|
59512
|
+
};
|
|
59513
|
+
const list = async () => ({
|
|
59514
|
+
response: { type: "project:list", projects: store().list() }
|
|
59515
|
+
});
|
|
59516
|
+
const create = async (frame) => {
|
|
59517
|
+
const args = ProjectCreateArgs.parse(frame);
|
|
59518
|
+
try {
|
|
59519
|
+
const stat = fs60.statSync(args.path);
|
|
59520
|
+
if (!stat.isDirectory()) throw new Error("not dir");
|
|
59521
|
+
} catch {
|
|
59522
|
+
throw new ClawdError(ERROR_CODES.INVALID_CWD, `not a directory: ${args.path}`);
|
|
59523
|
+
}
|
|
59524
|
+
const entry = store().upsert(args.path, args.name);
|
|
59525
|
+
if (!entry) {
|
|
59526
|
+
throw new ClawdError(
|
|
59527
|
+
ERROR_CODES.INVALID_CWD,
|
|
59528
|
+
`\u4E0D\u662F\u53EF\u7528\u7684\u9879\u76EE\u76EE\u5F55\uFF08~/.clawd \u5185\u90E8\u8DEF\u5F84\uFF09: ${args.path}`
|
|
59529
|
+
);
|
|
59530
|
+
}
|
|
59531
|
+
return { response: { type: "project:create", project: entry } };
|
|
59532
|
+
};
|
|
59533
|
+
return { "project:list": list, "project:create": create };
|
|
59534
|
+
}
|
|
59535
|
+
|
|
59379
59536
|
// src/handlers/workspace.ts
|
|
59380
|
-
var
|
|
59381
|
-
var
|
|
59537
|
+
var path65 = __toESM(require("path"), 1);
|
|
59538
|
+
var os19 = __toESM(require("os"), 1);
|
|
59382
59539
|
init_protocol();
|
|
59383
59540
|
init_protocol();
|
|
59384
59541
|
function buildEnabledPluginNames(personaManager, personaId2) {
|
|
@@ -59418,23 +59575,23 @@ function buildWorkspaceHandlers(deps) {
|
|
|
59418
59575
|
const list = async (frame, _client, ctx) => {
|
|
59419
59576
|
const args = WorkspaceListArgs.parse(frame);
|
|
59420
59577
|
const isGuest = ctx?.principal.kind === "guest";
|
|
59421
|
-
const fallbackCwd = isGuest && personaRoot ? personaRoot :
|
|
59422
|
-
const resolvedCwd =
|
|
59423
|
-
const target = args.path ?
|
|
59578
|
+
const fallbackCwd = isGuest && personaRoot ? personaRoot : os19.homedir();
|
|
59579
|
+
const resolvedCwd = path65.resolve(args.cwd ?? fallbackCwd);
|
|
59580
|
+
const target = args.path ? path65.resolve(resolvedCwd, args.path) : resolvedCwd;
|
|
59424
59581
|
assertGuestPath2(ctx, target, personaRoot, "workspace:list", usersRoot);
|
|
59425
59582
|
const res = workspace.list({ ...args, cwd: resolvedCwd });
|
|
59426
59583
|
return { response: { type: "workspace:list", ...res } };
|
|
59427
59584
|
};
|
|
59428
59585
|
const read = async (frame, _client, ctx) => {
|
|
59429
59586
|
const args = WorkspaceReadArgs.parse(frame);
|
|
59430
|
-
const target =
|
|
59587
|
+
const target = path65.isAbsolute(args.path) ? path65.resolve(args.path) : path65.resolve(args.cwd, args.path);
|
|
59431
59588
|
assertGuestPath2(ctx, target, personaRoot, "workspace:read", usersRoot);
|
|
59432
59589
|
const res = workspace.read(args);
|
|
59433
59590
|
return { response: { type: "workspace:read", ...res } };
|
|
59434
59591
|
};
|
|
59435
59592
|
const skillsList = async (frame, _client, ctx) => {
|
|
59436
59593
|
const args = SkillsListArgs.parse(frame);
|
|
59437
|
-
const cwdAbs =
|
|
59594
|
+
const cwdAbs = path65.resolve(args.cwd);
|
|
59438
59595
|
assertGuestPath2(ctx, cwdAbs, personaRoot, "skills:list", usersRoot);
|
|
59439
59596
|
const list2 = await getSkillsForTool(args.tool ?? "claude", cwdAbs);
|
|
59440
59597
|
if (ctx?.principal.kind === "guest" && personaRoot) {
|
|
@@ -59446,7 +59603,7 @@ function buildWorkspaceHandlers(deps) {
|
|
|
59446
59603
|
};
|
|
59447
59604
|
const agentsList = async (frame, _client, ctx) => {
|
|
59448
59605
|
const args = AgentsListArgs.parse(frame);
|
|
59449
|
-
const cwdAbs =
|
|
59606
|
+
const cwdAbs = path65.resolve(args.cwd);
|
|
59450
59607
|
assertGuestPath2(ctx, cwdAbs, personaRoot, "agents:list", usersRoot);
|
|
59451
59608
|
if (args.tool === "codex") {
|
|
59452
59609
|
return { response: { type: "agents:list", agents: [] } };
|
|
@@ -59468,7 +59625,7 @@ function buildWorkspaceHandlers(deps) {
|
|
|
59468
59625
|
}
|
|
59469
59626
|
|
|
59470
59627
|
// src/handlers/git.ts
|
|
59471
|
-
var
|
|
59628
|
+
var path67 = __toESM(require("path"), 1);
|
|
59472
59629
|
init_protocol();
|
|
59473
59630
|
init_protocol();
|
|
59474
59631
|
|
|
@@ -59555,7 +59712,7 @@ async function listGitBranches(cwd) {
|
|
|
59555
59712
|
function assertGuestCwd(ctx, cwd, personaRoot, method, usersRoot) {
|
|
59556
59713
|
if (!ctx || ctx.principal.kind !== "guest" || !personaRoot) return;
|
|
59557
59714
|
const userWorkDir = usersRoot ? deriveUserWorkDir(ctx.principal.id, usersRoot) : void 0;
|
|
59558
|
-
if (!isGuestPathAllowed(ctx.grants,
|
|
59715
|
+
if (!isGuestPathAllowed(ctx.grants, path67.resolve(cwd), personaRoot, "read", userWorkDir)) {
|
|
59559
59716
|
throw new ClawdError(
|
|
59560
59717
|
ERROR_CODES.UNAUTHORIZED,
|
|
59561
59718
|
`guest ${ctx.principal.id} cannot ${method} cwd ${cwd}`
|
|
@@ -60293,6 +60450,9 @@ var METHOD_GRANT_MAP = {
|
|
|
60293
60450
|
// ---- shift:* (排班 mock,owner-only 读) ----
|
|
60294
60451
|
// mock 阶段只 owner 用;接 guest 后再考虑分级
|
|
60295
60452
|
"shift:list": ADMIN_ANY,
|
|
60453
|
+
// project:*(sidebar 项目分区,spec 2026-08-17):registry 是 owner 本机资源,owner-only 一刀切
|
|
60454
|
+
"project:list": ADMIN_ANY,
|
|
60455
|
+
"project:create": ADMIN_ANY,
|
|
60296
60456
|
// github:*(PR 收件箱,spec 2026-08-11):走 owner 本机 gh 凭据,owner-only 一刀切
|
|
60297
60457
|
"github:status": ADMIN_ANY,
|
|
60298
60458
|
"github:prList": ADMIN_ANY,
|
|
@@ -60453,21 +60613,21 @@ function computeMethodAccess(args) {
|
|
|
60453
60613
|
}
|
|
60454
60614
|
|
|
60455
60615
|
// src/version.ts
|
|
60456
|
-
var version = "0.2.
|
|
60616
|
+
var version = "0.2.364".length > 0 ? "0.2.364" : "dev";
|
|
60457
60617
|
|
|
60458
60618
|
// src/cli-probe/probe.ts
|
|
60459
|
-
var
|
|
60460
|
-
var
|
|
60619
|
+
var fs62 = __toESM(require("fs"), 1);
|
|
60620
|
+
var path68 = __toESM(require("path"), 1);
|
|
60461
60621
|
var PKG_NAME = "@clawos-dev/clawd";
|
|
60462
60622
|
var BIN_NAME = "clawd";
|
|
60463
60623
|
var MAX_PARENT_HOPS = 5;
|
|
60464
60624
|
function probeGlobalCli(pathEnv) {
|
|
60465
60625
|
if (!pathEnv) return null;
|
|
60466
|
-
for (const dir of pathEnv.split(
|
|
60626
|
+
for (const dir of pathEnv.split(path68.delimiter)) {
|
|
60467
60627
|
if (!dir) continue;
|
|
60468
60628
|
let real;
|
|
60469
60629
|
try {
|
|
60470
|
-
real =
|
|
60630
|
+
real = fs62.realpathSync(path68.join(dir, BIN_NAME));
|
|
60471
60631
|
} catch {
|
|
60472
60632
|
continue;
|
|
60473
60633
|
}
|
|
@@ -60477,15 +60637,15 @@ function probeGlobalCli(pathEnv) {
|
|
|
60477
60637
|
return null;
|
|
60478
60638
|
}
|
|
60479
60639
|
function readOwnPackageVersion(entryPath) {
|
|
60480
|
-
let dir =
|
|
60640
|
+
let dir = path68.dirname(entryPath);
|
|
60481
60641
|
for (let i = 0; i < MAX_PARENT_HOPS; i++) {
|
|
60482
60642
|
try {
|
|
60483
|
-
const raw =
|
|
60643
|
+
const raw = fs62.readFileSync(path68.join(dir, "package.json"), "utf8");
|
|
60484
60644
|
const pkg = JSON.parse(raw);
|
|
60485
60645
|
if (pkg.name !== PKG_NAME) return null;
|
|
60486
60646
|
return typeof pkg.version === "string" && pkg.version ? pkg.version : null;
|
|
60487
60647
|
} catch {
|
|
60488
|
-
const parent =
|
|
60648
|
+
const parent = path68.dirname(dir);
|
|
60489
60649
|
if (parent === dir) return null;
|
|
60490
60650
|
dir = parent;
|
|
60491
60651
|
}
|
|
@@ -61578,7 +61738,7 @@ var ProjectStore = class {
|
|
|
61578
61738
|
*/
|
|
61579
61739
|
async scaffold(name, templateSrcDir, scaffoldScriptPath) {
|
|
61580
61740
|
const destDir = this.projectDir(name);
|
|
61581
|
-
return await new Promise((
|
|
61741
|
+
return await new Promise((resolve7, reject) => {
|
|
61582
61742
|
const child = (0, import_node_child_process14.spawn)("bash", [scaffoldScriptPath, name, templateSrcDir, destDir], {
|
|
61583
61743
|
env: { ...process.env, PATH: process.env.PATH ?? "" },
|
|
61584
61744
|
stdio: ["ignore", "pipe", "pipe"]
|
|
@@ -61601,7 +61761,7 @@ var ProjectStore = class {
|
|
|
61601
61761
|
});
|
|
61602
61762
|
child.on("exit", (code, signal) => {
|
|
61603
61763
|
clearTimeout(timer);
|
|
61604
|
-
if (code === 0)
|
|
61764
|
+
if (code === 0) resolve7({ stdout, stderr });
|
|
61605
61765
|
else reject(new Error(`scaffold exit ${code ?? signal}: ${stderr.slice(0, 500)}`));
|
|
61606
61766
|
});
|
|
61607
61767
|
});
|
|
@@ -61724,7 +61884,7 @@ async function killPortOccupants(port, ownedPids, logger) {
|
|
|
61724
61884
|
}
|
|
61725
61885
|
}
|
|
61726
61886
|
function listPidsOnPort(port) {
|
|
61727
|
-
return new Promise((
|
|
61887
|
+
return new Promise((resolve7, reject) => {
|
|
61728
61888
|
(0, import_node_child_process15.execFile)(
|
|
61729
61889
|
"lsof",
|
|
61730
61890
|
["-ti", `:${port}`],
|
|
@@ -61736,11 +61896,11 @@ function listPidsOnPort(port) {
|
|
|
61736
61896
|
}
|
|
61737
61897
|
const text = (stdout ?? "").toString().trim();
|
|
61738
61898
|
if (!text) {
|
|
61739
|
-
|
|
61899
|
+
resolve7([]);
|
|
61740
61900
|
return;
|
|
61741
61901
|
}
|
|
61742
61902
|
const list = text.split("\n").map((s) => Number(s.trim())).filter((n) => Number.isInteger(n) && n > 0);
|
|
61743
|
-
|
|
61903
|
+
resolve7(list);
|
|
61744
61904
|
}
|
|
61745
61905
|
);
|
|
61746
61906
|
});
|
|
@@ -62964,7 +63124,7 @@ var MAX_TIMEOUT_MS = 3e5;
|
|
|
62964
63124
|
var MAX_OUTPUT_BYTES = 1048576;
|
|
62965
63125
|
function runCommand(command, opts = {}) {
|
|
62966
63126
|
const timeoutMs = Math.min(opts.timeoutMs ?? DEFAULT_TIMEOUT_MS4, MAX_TIMEOUT_MS);
|
|
62967
|
-
return new Promise((
|
|
63127
|
+
return new Promise((resolve7) => {
|
|
62968
63128
|
const child = (0, import_node_child_process17.spawn)("bash", ["-c", command], { cwd: import_node_os23.default.homedir() });
|
|
62969
63129
|
const out = [];
|
|
62970
63130
|
const err = [];
|
|
@@ -63005,7 +63165,7 @@ function runCommand(command, opts = {}) {
|
|
|
63005
63165
|
}, timeoutMs);
|
|
63006
63166
|
child.on("close", (code) => {
|
|
63007
63167
|
clearTimeout(timer);
|
|
63008
|
-
|
|
63168
|
+
resolve7({
|
|
63009
63169
|
stdout: Buffer.concat(out).toString("utf8"),
|
|
63010
63170
|
stderr: Buffer.concat(err).toString("utf8"),
|
|
63011
63171
|
exitCode: timedOut ? null : code,
|
|
@@ -63016,7 +63176,7 @@ function runCommand(command, opts = {}) {
|
|
|
63016
63176
|
});
|
|
63017
63177
|
child.on("error", () => {
|
|
63018
63178
|
clearTimeout(timer);
|
|
63019
|
-
|
|
63179
|
+
resolve7({
|
|
63020
63180
|
stdout: Buffer.concat(out).toString("utf8"),
|
|
63021
63181
|
stderr: Buffer.concat(err).toString("utf8"),
|
|
63022
63182
|
exitCode: null,
|
|
@@ -63089,6 +63249,7 @@ function buildMethodHandlers(deps) {
|
|
|
63089
63249
|
}),
|
|
63090
63250
|
...buildPermissionHandlers(deps),
|
|
63091
63251
|
...buildHistoryHandlers(deps),
|
|
63252
|
+
...buildProjectHandlers(deps),
|
|
63092
63253
|
...buildWorkspaceHandlers(deps),
|
|
63093
63254
|
...buildGitHandlers(deps),
|
|
63094
63255
|
...buildCapabilitiesHandlers(deps),
|
|
@@ -63190,10 +63351,10 @@ function parseVersionOutput(out) {
|
|
|
63190
63351
|
return /(\d+\.\d+\.\d+)/.exec(out)?.[1];
|
|
63191
63352
|
}
|
|
63192
63353
|
function execVersion(bin) {
|
|
63193
|
-
return new Promise((
|
|
63354
|
+
return new Promise((resolve7, reject) => {
|
|
63194
63355
|
(0, import_node_child_process18.execFile)(bin, ["--version"], { timeout: 5e3 }, (err, stdout) => {
|
|
63195
63356
|
if (err) reject(err);
|
|
63196
|
-
else
|
|
63357
|
+
else resolve7(String(stdout));
|
|
63197
63358
|
});
|
|
63198
63359
|
});
|
|
63199
63360
|
}
|
|
@@ -63347,8 +63508,8 @@ var DevServerSupervisor = class extends import_node_events2.EventEmitter {
|
|
|
63347
63508
|
});
|
|
63348
63509
|
let readyResolve;
|
|
63349
63510
|
let readyReject;
|
|
63350
|
-
const readyPromise = new Promise((
|
|
63351
|
-
readyResolve =
|
|
63511
|
+
const readyPromise = new Promise((resolve7, reject) => {
|
|
63512
|
+
readyResolve = resolve7;
|
|
63352
63513
|
readyReject = reject;
|
|
63353
63514
|
});
|
|
63354
63515
|
readyPromise.catch(() => {
|
|
@@ -63427,7 +63588,7 @@ var DevServerSupervisor = class extends import_node_events2.EventEmitter {
|
|
|
63427
63588
|
if (!entry.ready) {
|
|
63428
63589
|
entry.readyReject(new Error("dev server stopped before ready"));
|
|
63429
63590
|
}
|
|
63430
|
-
return new Promise((
|
|
63591
|
+
return new Promise((resolve7) => {
|
|
63431
63592
|
let settled = false;
|
|
63432
63593
|
let killTimer;
|
|
63433
63594
|
const cleanup = () => {
|
|
@@ -63435,7 +63596,7 @@ var DevServerSupervisor = class extends import_node_events2.EventEmitter {
|
|
|
63435
63596
|
settled = true;
|
|
63436
63597
|
if (killTimer) clearTimeout(killTimer);
|
|
63437
63598
|
this.running.delete(sessionId);
|
|
63438
|
-
|
|
63599
|
+
resolve7();
|
|
63439
63600
|
};
|
|
63440
63601
|
entry.process.once("exit", cleanup);
|
|
63441
63602
|
const pid = entry.process.pid;
|
|
@@ -63517,7 +63678,7 @@ var DevServerSupervisor = class extends import_node_events2.EventEmitter {
|
|
|
63517
63678
|
if (!entry) {
|
|
63518
63679
|
return Promise.reject(new Error(`dev server for project "${projectName}" not running`));
|
|
63519
63680
|
}
|
|
63520
|
-
return new Promise((
|
|
63681
|
+
return new Promise((resolve7, reject) => {
|
|
63521
63682
|
let settled = false;
|
|
63522
63683
|
let timer;
|
|
63523
63684
|
const finish = (err) => {
|
|
@@ -63525,7 +63686,7 @@ var DevServerSupervisor = class extends import_node_events2.EventEmitter {
|
|
|
63525
63686
|
settled = true;
|
|
63526
63687
|
if (timer) clearTimeout(timer);
|
|
63527
63688
|
if (opts.signal) opts.signal.removeEventListener("abort", onAbort);
|
|
63528
|
-
err ? reject(err) :
|
|
63689
|
+
err ? reject(err) : resolve7();
|
|
63529
63690
|
};
|
|
63530
63691
|
const onAbort = () => finish(new Error("awaitReady aborted via signal"));
|
|
63531
63692
|
entry.readyPromise.then(() => finish(), (err) => finish(err));
|
|
@@ -63608,16 +63769,16 @@ var PortExhaustedError = class extends Error {
|
|
|
63608
63769
|
code = "PORT_EXHAUSTED";
|
|
63609
63770
|
};
|
|
63610
63771
|
function probe(port) {
|
|
63611
|
-
return new Promise((
|
|
63772
|
+
return new Promise((resolve7) => {
|
|
63612
63773
|
const srv = import_node_net2.default.createServer();
|
|
63613
|
-
srv.once("error", () =>
|
|
63774
|
+
srv.once("error", () => resolve7(false));
|
|
63614
63775
|
srv.once("listening", () => {
|
|
63615
|
-
srv.close(() =>
|
|
63776
|
+
srv.close(() => resolve7(true));
|
|
63616
63777
|
});
|
|
63617
63778
|
try {
|
|
63618
63779
|
srv.listen({ port, host: "127.0.0.1", exclusive: true });
|
|
63619
63780
|
} catch {
|
|
63620
|
-
|
|
63781
|
+
resolve7(false);
|
|
63621
63782
|
}
|
|
63622
63783
|
});
|
|
63623
63784
|
}
|
|
@@ -63712,7 +63873,7 @@ var Runtime = class {
|
|
|
63712
63873
|
child.stdout.on("data", () => {
|
|
63713
63874
|
});
|
|
63714
63875
|
let earlyExit = null;
|
|
63715
|
-
const exitPromise = new Promise((
|
|
63876
|
+
const exitPromise = new Promise((resolve7) => {
|
|
63716
63877
|
child.once("exit", (code, signal) => {
|
|
63717
63878
|
earlyExit = { code, signal };
|
|
63718
63879
|
const wasUnexpected = this.handles.get(extId) === handle;
|
|
@@ -63720,7 +63881,7 @@ var Runtime = class {
|
|
|
63720
63881
|
this.handles.delete(extId);
|
|
63721
63882
|
this.crashed.add(extId);
|
|
63722
63883
|
}
|
|
63723
|
-
|
|
63884
|
+
resolve7();
|
|
63724
63885
|
});
|
|
63725
63886
|
});
|
|
63726
63887
|
this.handles.set(extId, handle);
|
|
@@ -63793,7 +63954,7 @@ ${handle.stderrTail}`
|
|
|
63793
63954
|
}
|
|
63794
63955
|
};
|
|
63795
63956
|
killGroup("SIGTERM");
|
|
63796
|
-
const exited = new Promise((
|
|
63957
|
+
const exited = new Promise((resolve7) => child.once("exit", () => resolve7()));
|
|
63797
63958
|
const timed = (0, import_promises14.setTimeout)(5e3).then(() => "timeout");
|
|
63798
63959
|
const winner = await Promise.race([exited.then(() => "exited"), timed]);
|
|
63799
63960
|
if (winner === "timeout" && child.exitCode === null) {
|
|
@@ -64376,6 +64537,14 @@ async function startDaemon(config) {
|
|
|
64376
64537
|
}
|
|
64377
64538
|
}
|
|
64378
64539
|
});
|
|
64540
|
+
const projectsStore = new ProjectsStore({
|
|
64541
|
+
file: import_node_path68.default.join(config.dataDir, "projects.json"),
|
|
64542
|
+
clawdDir: config.dataDir,
|
|
64543
|
+
logger
|
|
64544
|
+
});
|
|
64545
|
+
projectsStore.seedFromSessions(
|
|
64546
|
+
manager.list().response.sessions
|
|
64547
|
+
);
|
|
64379
64548
|
const observer = new SessionObserver({
|
|
64380
64549
|
// TUI 模式 pty 跑 CC 不发 SDK system.task_started 帧 → UI pending 期 progress.agentId
|
|
64381
64550
|
// 永远 undefined,子 agent 调用过程没有抽屉入口。开 meta observer 后从 subagents 目录
|
|
@@ -64578,6 +64747,7 @@ async function startDaemon(config) {
|
|
|
64578
64747
|
// onboarding 判定(info 帧字段)+ importExternal 台账落点
|
|
64579
64748
|
dataDir: config.dataDir,
|
|
64580
64749
|
manager,
|
|
64750
|
+
projects: projectsStore,
|
|
64581
64751
|
workspace,
|
|
64582
64752
|
skills,
|
|
64583
64753
|
agents,
|