@clawos-dev/clawd 0.2.269 → 0.2.270

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 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: path76, errorMaps, issueData } = params;
454
- const fullPath = [...path76, ...issueData.path || []];
453
+ const { data, path: path77, errorMaps, issueData } = params;
454
+ const fullPath = [...path77, ...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, path76, key) {
765
+ constructor(parent, value, path77, key) {
766
766
  this._cachedPath = [];
767
767
  this.parent = parent;
768
768
  this.data = value;
769
- this._path = path76;
769
+ this._path = path77;
770
770
  this._key = key;
771
771
  }
772
772
  get path() {
@@ -4149,6 +4149,1626 @@ var init_zod = __esm({
4149
4149
  }
4150
4150
  });
4151
4151
 
4152
+ // ../node_modules/.pnpm/zod-to-json-schema@3.25.2_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/Options.js
4153
+ var ignoreOverride, defaultOptions, getDefaultOptions;
4154
+ var init_Options = __esm({
4155
+ "../node_modules/.pnpm/zod-to-json-schema@3.25.2_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/Options.js"() {
4156
+ "use strict";
4157
+ ignoreOverride = /* @__PURE__ */ Symbol("Let zodToJsonSchema decide on which parser to use");
4158
+ defaultOptions = {
4159
+ name: void 0,
4160
+ $refStrategy: "root",
4161
+ basePath: ["#"],
4162
+ effectStrategy: "input",
4163
+ pipeStrategy: "all",
4164
+ dateStrategy: "format:date-time",
4165
+ mapStrategy: "entries",
4166
+ removeAdditionalStrategy: "passthrough",
4167
+ allowedAdditionalProperties: true,
4168
+ rejectedAdditionalProperties: false,
4169
+ definitionPath: "definitions",
4170
+ target: "jsonSchema7",
4171
+ strictUnions: false,
4172
+ definitions: {},
4173
+ errorMessages: false,
4174
+ markdownDescription: false,
4175
+ patternStrategy: "escape",
4176
+ applyRegexFlags: false,
4177
+ emailStrategy: "format:email",
4178
+ base64Strategy: "contentEncoding:base64",
4179
+ nameStrategy: "ref",
4180
+ openAiAnyTypeName: "OpenAiAnyType"
4181
+ };
4182
+ getDefaultOptions = (options) => typeof options === "string" ? {
4183
+ ...defaultOptions,
4184
+ name: options
4185
+ } : {
4186
+ ...defaultOptions,
4187
+ ...options
4188
+ };
4189
+ }
4190
+ });
4191
+
4192
+ // ../node_modules/.pnpm/zod-to-json-schema@3.25.2_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/Refs.js
4193
+ var getRefs;
4194
+ var init_Refs = __esm({
4195
+ "../node_modules/.pnpm/zod-to-json-schema@3.25.2_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/Refs.js"() {
4196
+ "use strict";
4197
+ init_Options();
4198
+ getRefs = (options) => {
4199
+ const _options = getDefaultOptions(options);
4200
+ const currentPath = _options.name !== void 0 ? [..._options.basePath, _options.definitionPath, _options.name] : _options.basePath;
4201
+ return {
4202
+ ..._options,
4203
+ flags: { hasReferencedOpenAiAnyType: false },
4204
+ currentPath,
4205
+ propertyPath: void 0,
4206
+ seen: new Map(Object.entries(_options.definitions).map(([name, def]) => [
4207
+ def._def,
4208
+ {
4209
+ def: def._def,
4210
+ path: [..._options.basePath, _options.definitionPath, name],
4211
+ // Resolution of references will be forced even though seen, so it's ok that the schema is undefined here for now.
4212
+ jsonSchema: void 0
4213
+ }
4214
+ ]))
4215
+ };
4216
+ };
4217
+ }
4218
+ });
4219
+
4220
+ // ../node_modules/.pnpm/zod-to-json-schema@3.25.2_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/errorMessages.js
4221
+ function addErrorMessage(res, key, errorMessage, refs) {
4222
+ if (!refs?.errorMessages)
4223
+ return;
4224
+ if (errorMessage) {
4225
+ res.errorMessage = {
4226
+ ...res.errorMessage,
4227
+ [key]: errorMessage
4228
+ };
4229
+ }
4230
+ }
4231
+ function setResponseValueAndErrors(res, key, value, errorMessage, refs) {
4232
+ res[key] = value;
4233
+ addErrorMessage(res, key, errorMessage, refs);
4234
+ }
4235
+ var init_errorMessages = __esm({
4236
+ "../node_modules/.pnpm/zod-to-json-schema@3.25.2_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/errorMessages.js"() {
4237
+ "use strict";
4238
+ }
4239
+ });
4240
+
4241
+ // ../node_modules/.pnpm/zod-to-json-schema@3.25.2_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/getRelativePath.js
4242
+ var getRelativePath;
4243
+ var init_getRelativePath = __esm({
4244
+ "../node_modules/.pnpm/zod-to-json-schema@3.25.2_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/getRelativePath.js"() {
4245
+ "use strict";
4246
+ getRelativePath = (pathA, pathB) => {
4247
+ let i = 0;
4248
+ for (; i < pathA.length && i < pathB.length; i++) {
4249
+ if (pathA[i] !== pathB[i])
4250
+ break;
4251
+ }
4252
+ return [(pathA.length - i).toString(), ...pathB.slice(i)].join("/");
4253
+ };
4254
+ }
4255
+ });
4256
+
4257
+ // ../node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/index.js
4258
+ var init_v3 = __esm({
4259
+ "../node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/index.js"() {
4260
+ "use strict";
4261
+ init_external();
4262
+ }
4263
+ });
4264
+
4265
+ // ../node_modules/.pnpm/zod-to-json-schema@3.25.2_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/any.js
4266
+ function parseAnyDef(refs) {
4267
+ if (refs.target !== "openAi") {
4268
+ return {};
4269
+ }
4270
+ const anyDefinitionPath = [
4271
+ ...refs.basePath,
4272
+ refs.definitionPath,
4273
+ refs.openAiAnyTypeName
4274
+ ];
4275
+ refs.flags.hasReferencedOpenAiAnyType = true;
4276
+ return {
4277
+ $ref: refs.$refStrategy === "relative" ? getRelativePath(anyDefinitionPath, refs.currentPath) : anyDefinitionPath.join("/")
4278
+ };
4279
+ }
4280
+ var init_any = __esm({
4281
+ "../node_modules/.pnpm/zod-to-json-schema@3.25.2_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/any.js"() {
4282
+ "use strict";
4283
+ init_getRelativePath();
4284
+ }
4285
+ });
4286
+
4287
+ // ../node_modules/.pnpm/zod-to-json-schema@3.25.2_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/array.js
4288
+ function parseArrayDef(def, refs) {
4289
+ const res = {
4290
+ type: "array"
4291
+ };
4292
+ if (def.type?._def && def.type?._def?.typeName !== ZodFirstPartyTypeKind.ZodAny) {
4293
+ res.items = parseDef(def.type._def, {
4294
+ ...refs,
4295
+ currentPath: [...refs.currentPath, "items"]
4296
+ });
4297
+ }
4298
+ if (def.minLength) {
4299
+ setResponseValueAndErrors(res, "minItems", def.minLength.value, def.minLength.message, refs);
4300
+ }
4301
+ if (def.maxLength) {
4302
+ setResponseValueAndErrors(res, "maxItems", def.maxLength.value, def.maxLength.message, refs);
4303
+ }
4304
+ if (def.exactLength) {
4305
+ setResponseValueAndErrors(res, "minItems", def.exactLength.value, def.exactLength.message, refs);
4306
+ setResponseValueAndErrors(res, "maxItems", def.exactLength.value, def.exactLength.message, refs);
4307
+ }
4308
+ return res;
4309
+ }
4310
+ var init_array = __esm({
4311
+ "../node_modules/.pnpm/zod-to-json-schema@3.25.2_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/array.js"() {
4312
+ "use strict";
4313
+ init_v3();
4314
+ init_errorMessages();
4315
+ init_parseDef();
4316
+ }
4317
+ });
4318
+
4319
+ // ../node_modules/.pnpm/zod-to-json-schema@3.25.2_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/bigint.js
4320
+ function parseBigintDef(def, refs) {
4321
+ const res = {
4322
+ type: "integer",
4323
+ format: "int64"
4324
+ };
4325
+ if (!def.checks)
4326
+ return res;
4327
+ for (const check of def.checks) {
4328
+ switch (check.kind) {
4329
+ case "min":
4330
+ if (refs.target === "jsonSchema7") {
4331
+ if (check.inclusive) {
4332
+ setResponseValueAndErrors(res, "minimum", check.value, check.message, refs);
4333
+ } else {
4334
+ setResponseValueAndErrors(res, "exclusiveMinimum", check.value, check.message, refs);
4335
+ }
4336
+ } else {
4337
+ if (!check.inclusive) {
4338
+ res.exclusiveMinimum = true;
4339
+ }
4340
+ setResponseValueAndErrors(res, "minimum", check.value, check.message, refs);
4341
+ }
4342
+ break;
4343
+ case "max":
4344
+ if (refs.target === "jsonSchema7") {
4345
+ if (check.inclusive) {
4346
+ setResponseValueAndErrors(res, "maximum", check.value, check.message, refs);
4347
+ } else {
4348
+ setResponseValueAndErrors(res, "exclusiveMaximum", check.value, check.message, refs);
4349
+ }
4350
+ } else {
4351
+ if (!check.inclusive) {
4352
+ res.exclusiveMaximum = true;
4353
+ }
4354
+ setResponseValueAndErrors(res, "maximum", check.value, check.message, refs);
4355
+ }
4356
+ break;
4357
+ case "multipleOf":
4358
+ setResponseValueAndErrors(res, "multipleOf", check.value, check.message, refs);
4359
+ break;
4360
+ }
4361
+ }
4362
+ return res;
4363
+ }
4364
+ var init_bigint = __esm({
4365
+ "../node_modules/.pnpm/zod-to-json-schema@3.25.2_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/bigint.js"() {
4366
+ "use strict";
4367
+ init_errorMessages();
4368
+ }
4369
+ });
4370
+
4371
+ // ../node_modules/.pnpm/zod-to-json-schema@3.25.2_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/boolean.js
4372
+ function parseBooleanDef() {
4373
+ return {
4374
+ type: "boolean"
4375
+ };
4376
+ }
4377
+ var init_boolean = __esm({
4378
+ "../node_modules/.pnpm/zod-to-json-schema@3.25.2_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/boolean.js"() {
4379
+ "use strict";
4380
+ }
4381
+ });
4382
+
4383
+ // ../node_modules/.pnpm/zod-to-json-schema@3.25.2_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/branded.js
4384
+ function parseBrandedDef(_def, refs) {
4385
+ return parseDef(_def.type._def, refs);
4386
+ }
4387
+ var init_branded = __esm({
4388
+ "../node_modules/.pnpm/zod-to-json-schema@3.25.2_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/branded.js"() {
4389
+ "use strict";
4390
+ init_parseDef();
4391
+ }
4392
+ });
4393
+
4394
+ // ../node_modules/.pnpm/zod-to-json-schema@3.25.2_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/catch.js
4395
+ var parseCatchDef;
4396
+ var init_catch = __esm({
4397
+ "../node_modules/.pnpm/zod-to-json-schema@3.25.2_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/catch.js"() {
4398
+ "use strict";
4399
+ init_parseDef();
4400
+ parseCatchDef = (def, refs) => {
4401
+ return parseDef(def.innerType._def, refs);
4402
+ };
4403
+ }
4404
+ });
4405
+
4406
+ // ../node_modules/.pnpm/zod-to-json-schema@3.25.2_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/date.js
4407
+ function parseDateDef(def, refs, overrideDateStrategy) {
4408
+ const strategy = overrideDateStrategy ?? refs.dateStrategy;
4409
+ if (Array.isArray(strategy)) {
4410
+ return {
4411
+ anyOf: strategy.map((item, i) => parseDateDef(def, refs, item))
4412
+ };
4413
+ }
4414
+ switch (strategy) {
4415
+ case "string":
4416
+ case "format:date-time":
4417
+ return {
4418
+ type: "string",
4419
+ format: "date-time"
4420
+ };
4421
+ case "format:date":
4422
+ return {
4423
+ type: "string",
4424
+ format: "date"
4425
+ };
4426
+ case "integer":
4427
+ return integerDateParser(def, refs);
4428
+ }
4429
+ }
4430
+ var integerDateParser;
4431
+ var init_date = __esm({
4432
+ "../node_modules/.pnpm/zod-to-json-schema@3.25.2_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/date.js"() {
4433
+ "use strict";
4434
+ init_errorMessages();
4435
+ integerDateParser = (def, refs) => {
4436
+ const res = {
4437
+ type: "integer",
4438
+ format: "unix-time"
4439
+ };
4440
+ if (refs.target === "openApi3") {
4441
+ return res;
4442
+ }
4443
+ for (const check of def.checks) {
4444
+ switch (check.kind) {
4445
+ case "min":
4446
+ setResponseValueAndErrors(
4447
+ res,
4448
+ "minimum",
4449
+ check.value,
4450
+ // This is in milliseconds
4451
+ check.message,
4452
+ refs
4453
+ );
4454
+ break;
4455
+ case "max":
4456
+ setResponseValueAndErrors(
4457
+ res,
4458
+ "maximum",
4459
+ check.value,
4460
+ // This is in milliseconds
4461
+ check.message,
4462
+ refs
4463
+ );
4464
+ break;
4465
+ }
4466
+ }
4467
+ return res;
4468
+ };
4469
+ }
4470
+ });
4471
+
4472
+ // ../node_modules/.pnpm/zod-to-json-schema@3.25.2_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/default.js
4473
+ function parseDefaultDef(_def, refs) {
4474
+ return {
4475
+ ...parseDef(_def.innerType._def, refs),
4476
+ default: _def.defaultValue()
4477
+ };
4478
+ }
4479
+ var init_default = __esm({
4480
+ "../node_modules/.pnpm/zod-to-json-schema@3.25.2_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/default.js"() {
4481
+ "use strict";
4482
+ init_parseDef();
4483
+ }
4484
+ });
4485
+
4486
+ // ../node_modules/.pnpm/zod-to-json-schema@3.25.2_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/effects.js
4487
+ function parseEffectsDef(_def, refs) {
4488
+ return refs.effectStrategy === "input" ? parseDef(_def.schema._def, refs) : parseAnyDef(refs);
4489
+ }
4490
+ var init_effects = __esm({
4491
+ "../node_modules/.pnpm/zod-to-json-schema@3.25.2_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/effects.js"() {
4492
+ "use strict";
4493
+ init_parseDef();
4494
+ init_any();
4495
+ }
4496
+ });
4497
+
4498
+ // ../node_modules/.pnpm/zod-to-json-schema@3.25.2_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/enum.js
4499
+ function parseEnumDef(def) {
4500
+ return {
4501
+ type: "string",
4502
+ enum: Array.from(def.values)
4503
+ };
4504
+ }
4505
+ var init_enum = __esm({
4506
+ "../node_modules/.pnpm/zod-to-json-schema@3.25.2_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/enum.js"() {
4507
+ "use strict";
4508
+ }
4509
+ });
4510
+
4511
+ // ../node_modules/.pnpm/zod-to-json-schema@3.25.2_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/intersection.js
4512
+ function parseIntersectionDef(def, refs) {
4513
+ const allOf = [
4514
+ parseDef(def.left._def, {
4515
+ ...refs,
4516
+ currentPath: [...refs.currentPath, "allOf", "0"]
4517
+ }),
4518
+ parseDef(def.right._def, {
4519
+ ...refs,
4520
+ currentPath: [...refs.currentPath, "allOf", "1"]
4521
+ })
4522
+ ].filter((x) => !!x);
4523
+ let unevaluatedProperties = refs.target === "jsonSchema2019-09" ? { unevaluatedProperties: false } : void 0;
4524
+ const mergedAllOf = [];
4525
+ allOf.forEach((schema) => {
4526
+ if (isJsonSchema7AllOfType(schema)) {
4527
+ mergedAllOf.push(...schema.allOf);
4528
+ if (schema.unevaluatedProperties === void 0) {
4529
+ unevaluatedProperties = void 0;
4530
+ }
4531
+ } else {
4532
+ let nestedSchema = schema;
4533
+ if ("additionalProperties" in schema && schema.additionalProperties === false) {
4534
+ const { additionalProperties, ...rest } = schema;
4535
+ nestedSchema = rest;
4536
+ } else {
4537
+ unevaluatedProperties = void 0;
4538
+ }
4539
+ mergedAllOf.push(nestedSchema);
4540
+ }
4541
+ });
4542
+ return mergedAllOf.length ? {
4543
+ allOf: mergedAllOf,
4544
+ ...unevaluatedProperties
4545
+ } : void 0;
4546
+ }
4547
+ var isJsonSchema7AllOfType;
4548
+ var init_intersection = __esm({
4549
+ "../node_modules/.pnpm/zod-to-json-schema@3.25.2_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/intersection.js"() {
4550
+ "use strict";
4551
+ init_parseDef();
4552
+ isJsonSchema7AllOfType = (type) => {
4553
+ if ("type" in type && type.type === "string")
4554
+ return false;
4555
+ return "allOf" in type;
4556
+ };
4557
+ }
4558
+ });
4559
+
4560
+ // ../node_modules/.pnpm/zod-to-json-schema@3.25.2_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/literal.js
4561
+ function parseLiteralDef(def, refs) {
4562
+ const parsedType = typeof def.value;
4563
+ if (parsedType !== "bigint" && parsedType !== "number" && parsedType !== "boolean" && parsedType !== "string") {
4564
+ return {
4565
+ type: Array.isArray(def.value) ? "array" : "object"
4566
+ };
4567
+ }
4568
+ if (refs.target === "openApi3") {
4569
+ return {
4570
+ type: parsedType === "bigint" ? "integer" : parsedType,
4571
+ enum: [def.value]
4572
+ };
4573
+ }
4574
+ return {
4575
+ type: parsedType === "bigint" ? "integer" : parsedType,
4576
+ const: def.value
4577
+ };
4578
+ }
4579
+ var init_literal = __esm({
4580
+ "../node_modules/.pnpm/zod-to-json-schema@3.25.2_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/literal.js"() {
4581
+ "use strict";
4582
+ }
4583
+ });
4584
+
4585
+ // ../node_modules/.pnpm/zod-to-json-schema@3.25.2_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/string.js
4586
+ function parseStringDef(def, refs) {
4587
+ const res = {
4588
+ type: "string"
4589
+ };
4590
+ if (def.checks) {
4591
+ for (const check of def.checks) {
4592
+ switch (check.kind) {
4593
+ case "min":
4594
+ setResponseValueAndErrors(res, "minLength", typeof res.minLength === "number" ? Math.max(res.minLength, check.value) : check.value, check.message, refs);
4595
+ break;
4596
+ case "max":
4597
+ setResponseValueAndErrors(res, "maxLength", typeof res.maxLength === "number" ? Math.min(res.maxLength, check.value) : check.value, check.message, refs);
4598
+ break;
4599
+ case "email":
4600
+ switch (refs.emailStrategy) {
4601
+ case "format:email":
4602
+ addFormat(res, "email", check.message, refs);
4603
+ break;
4604
+ case "format:idn-email":
4605
+ addFormat(res, "idn-email", check.message, refs);
4606
+ break;
4607
+ case "pattern:zod":
4608
+ addPattern(res, zodPatterns.email, check.message, refs);
4609
+ break;
4610
+ }
4611
+ break;
4612
+ case "url":
4613
+ addFormat(res, "uri", check.message, refs);
4614
+ break;
4615
+ case "uuid":
4616
+ addFormat(res, "uuid", check.message, refs);
4617
+ break;
4618
+ case "regex":
4619
+ addPattern(res, check.regex, check.message, refs);
4620
+ break;
4621
+ case "cuid":
4622
+ addPattern(res, zodPatterns.cuid, check.message, refs);
4623
+ break;
4624
+ case "cuid2":
4625
+ addPattern(res, zodPatterns.cuid2, check.message, refs);
4626
+ break;
4627
+ case "startsWith":
4628
+ addPattern(res, RegExp(`^${escapeLiteralCheckValue(check.value, refs)}`), check.message, refs);
4629
+ break;
4630
+ case "endsWith":
4631
+ addPattern(res, RegExp(`${escapeLiteralCheckValue(check.value, refs)}$`), check.message, refs);
4632
+ break;
4633
+ case "datetime":
4634
+ addFormat(res, "date-time", check.message, refs);
4635
+ break;
4636
+ case "date":
4637
+ addFormat(res, "date", check.message, refs);
4638
+ break;
4639
+ case "time":
4640
+ addFormat(res, "time", check.message, refs);
4641
+ break;
4642
+ case "duration":
4643
+ addFormat(res, "duration", check.message, refs);
4644
+ break;
4645
+ case "length":
4646
+ setResponseValueAndErrors(res, "minLength", typeof res.minLength === "number" ? Math.max(res.minLength, check.value) : check.value, check.message, refs);
4647
+ setResponseValueAndErrors(res, "maxLength", typeof res.maxLength === "number" ? Math.min(res.maxLength, check.value) : check.value, check.message, refs);
4648
+ break;
4649
+ case "includes": {
4650
+ addPattern(res, RegExp(escapeLiteralCheckValue(check.value, refs)), check.message, refs);
4651
+ break;
4652
+ }
4653
+ case "ip": {
4654
+ if (check.version !== "v6") {
4655
+ addFormat(res, "ipv4", check.message, refs);
4656
+ }
4657
+ if (check.version !== "v4") {
4658
+ addFormat(res, "ipv6", check.message, refs);
4659
+ }
4660
+ break;
4661
+ }
4662
+ case "base64url":
4663
+ addPattern(res, zodPatterns.base64url, check.message, refs);
4664
+ break;
4665
+ case "jwt":
4666
+ addPattern(res, zodPatterns.jwt, check.message, refs);
4667
+ break;
4668
+ case "cidr": {
4669
+ if (check.version !== "v6") {
4670
+ addPattern(res, zodPatterns.ipv4Cidr, check.message, refs);
4671
+ }
4672
+ if (check.version !== "v4") {
4673
+ addPattern(res, zodPatterns.ipv6Cidr, check.message, refs);
4674
+ }
4675
+ break;
4676
+ }
4677
+ case "emoji":
4678
+ addPattern(res, zodPatterns.emoji(), check.message, refs);
4679
+ break;
4680
+ case "ulid": {
4681
+ addPattern(res, zodPatterns.ulid, check.message, refs);
4682
+ break;
4683
+ }
4684
+ case "base64": {
4685
+ switch (refs.base64Strategy) {
4686
+ case "format:binary": {
4687
+ addFormat(res, "binary", check.message, refs);
4688
+ break;
4689
+ }
4690
+ case "contentEncoding:base64": {
4691
+ setResponseValueAndErrors(res, "contentEncoding", "base64", check.message, refs);
4692
+ break;
4693
+ }
4694
+ case "pattern:zod": {
4695
+ addPattern(res, zodPatterns.base64, check.message, refs);
4696
+ break;
4697
+ }
4698
+ }
4699
+ break;
4700
+ }
4701
+ case "nanoid": {
4702
+ addPattern(res, zodPatterns.nanoid, check.message, refs);
4703
+ }
4704
+ case "toLowerCase":
4705
+ case "toUpperCase":
4706
+ case "trim":
4707
+ break;
4708
+ default:
4709
+ /* @__PURE__ */ ((_2) => {
4710
+ })(check);
4711
+ }
4712
+ }
4713
+ }
4714
+ return res;
4715
+ }
4716
+ function escapeLiteralCheckValue(literal, refs) {
4717
+ return refs.patternStrategy === "escape" ? escapeNonAlphaNumeric(literal) : literal;
4718
+ }
4719
+ function escapeNonAlphaNumeric(source) {
4720
+ let result = "";
4721
+ for (let i = 0; i < source.length; i++) {
4722
+ if (!ALPHA_NUMERIC.has(source[i])) {
4723
+ result += "\\";
4724
+ }
4725
+ result += source[i];
4726
+ }
4727
+ return result;
4728
+ }
4729
+ function addFormat(schema, value, message, refs) {
4730
+ if (schema.format || schema.anyOf?.some((x) => x.format)) {
4731
+ if (!schema.anyOf) {
4732
+ schema.anyOf = [];
4733
+ }
4734
+ if (schema.format) {
4735
+ schema.anyOf.push({
4736
+ format: schema.format,
4737
+ ...schema.errorMessage && refs.errorMessages && {
4738
+ errorMessage: { format: schema.errorMessage.format }
4739
+ }
4740
+ });
4741
+ delete schema.format;
4742
+ if (schema.errorMessage) {
4743
+ delete schema.errorMessage.format;
4744
+ if (Object.keys(schema.errorMessage).length === 0) {
4745
+ delete schema.errorMessage;
4746
+ }
4747
+ }
4748
+ }
4749
+ schema.anyOf.push({
4750
+ format: value,
4751
+ ...message && refs.errorMessages && { errorMessage: { format: message } }
4752
+ });
4753
+ } else {
4754
+ setResponseValueAndErrors(schema, "format", value, message, refs);
4755
+ }
4756
+ }
4757
+ function addPattern(schema, regex, message, refs) {
4758
+ if (schema.pattern || schema.allOf?.some((x) => x.pattern)) {
4759
+ if (!schema.allOf) {
4760
+ schema.allOf = [];
4761
+ }
4762
+ if (schema.pattern) {
4763
+ schema.allOf.push({
4764
+ pattern: schema.pattern,
4765
+ ...schema.errorMessage && refs.errorMessages && {
4766
+ errorMessage: { pattern: schema.errorMessage.pattern }
4767
+ }
4768
+ });
4769
+ delete schema.pattern;
4770
+ if (schema.errorMessage) {
4771
+ delete schema.errorMessage.pattern;
4772
+ if (Object.keys(schema.errorMessage).length === 0) {
4773
+ delete schema.errorMessage;
4774
+ }
4775
+ }
4776
+ }
4777
+ schema.allOf.push({
4778
+ pattern: stringifyRegExpWithFlags(regex, refs),
4779
+ ...message && refs.errorMessages && { errorMessage: { pattern: message } }
4780
+ });
4781
+ } else {
4782
+ setResponseValueAndErrors(schema, "pattern", stringifyRegExpWithFlags(regex, refs), message, refs);
4783
+ }
4784
+ }
4785
+ function stringifyRegExpWithFlags(regex, refs) {
4786
+ if (!refs.applyRegexFlags || !regex.flags) {
4787
+ return regex.source;
4788
+ }
4789
+ const flags = {
4790
+ i: regex.flags.includes("i"),
4791
+ m: regex.flags.includes("m"),
4792
+ s: regex.flags.includes("s")
4793
+ // `.` matches newlines
4794
+ };
4795
+ const source = flags.i ? regex.source.toLowerCase() : regex.source;
4796
+ let pattern = "";
4797
+ let isEscaped = false;
4798
+ let inCharGroup = false;
4799
+ let inCharRange = false;
4800
+ for (let i = 0; i < source.length; i++) {
4801
+ if (isEscaped) {
4802
+ pattern += source[i];
4803
+ isEscaped = false;
4804
+ continue;
4805
+ }
4806
+ if (flags.i) {
4807
+ if (inCharGroup) {
4808
+ if (source[i].match(/[a-z]/)) {
4809
+ if (inCharRange) {
4810
+ pattern += source[i];
4811
+ pattern += `${source[i - 2]}-${source[i]}`.toUpperCase();
4812
+ inCharRange = false;
4813
+ } else if (source[i + 1] === "-" && source[i + 2]?.match(/[a-z]/)) {
4814
+ pattern += source[i];
4815
+ inCharRange = true;
4816
+ } else {
4817
+ pattern += `${source[i]}${source[i].toUpperCase()}`;
4818
+ }
4819
+ continue;
4820
+ }
4821
+ } else if (source[i].match(/[a-z]/)) {
4822
+ pattern += `[${source[i]}${source[i].toUpperCase()}]`;
4823
+ continue;
4824
+ }
4825
+ }
4826
+ if (flags.m) {
4827
+ if (source[i] === "^") {
4828
+ pattern += `(^|(?<=[\r
4829
+ ]))`;
4830
+ continue;
4831
+ } else if (source[i] === "$") {
4832
+ pattern += `($|(?=[\r
4833
+ ]))`;
4834
+ continue;
4835
+ }
4836
+ }
4837
+ if (flags.s && source[i] === ".") {
4838
+ pattern += inCharGroup ? `${source[i]}\r
4839
+ ` : `[${source[i]}\r
4840
+ ]`;
4841
+ continue;
4842
+ }
4843
+ pattern += source[i];
4844
+ if (source[i] === "\\") {
4845
+ isEscaped = true;
4846
+ } else if (inCharGroup && source[i] === "]") {
4847
+ inCharGroup = false;
4848
+ } else if (!inCharGroup && source[i] === "[") {
4849
+ inCharGroup = true;
4850
+ }
4851
+ }
4852
+ try {
4853
+ new RegExp(pattern);
4854
+ } catch {
4855
+ console.warn(`Could not convert regex pattern at ${refs.currentPath.join("/")} to a flag-independent form! Falling back to the flag-ignorant source`);
4856
+ return regex.source;
4857
+ }
4858
+ return pattern;
4859
+ }
4860
+ var emojiRegex2, zodPatterns, ALPHA_NUMERIC;
4861
+ var init_string = __esm({
4862
+ "../node_modules/.pnpm/zod-to-json-schema@3.25.2_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/string.js"() {
4863
+ "use strict";
4864
+ init_errorMessages();
4865
+ emojiRegex2 = void 0;
4866
+ zodPatterns = {
4867
+ /**
4868
+ * `c` was changed to `[cC]` to replicate /i flag
4869
+ */
4870
+ cuid: /^[cC][^\s-]{8,}$/,
4871
+ cuid2: /^[0-9a-z]+$/,
4872
+ ulid: /^[0-9A-HJKMNP-TV-Z]{26}$/,
4873
+ /**
4874
+ * `a-z` was added to replicate /i flag
4875
+ */
4876
+ email: /^(?!\.)(?!.*\.\.)([a-zA-Z0-9_'+\-\.]*)[a-zA-Z0-9_+-]@([a-zA-Z0-9][a-zA-Z0-9\-]*\.)+[a-zA-Z]{2,}$/,
4877
+ /**
4878
+ * Constructed a valid Unicode RegExp
4879
+ *
4880
+ * Lazily instantiate since this type of regex isn't supported
4881
+ * in all envs (e.g. React Native).
4882
+ *
4883
+ * See:
4884
+ * https://github.com/colinhacks/zod/issues/2433
4885
+ * Fix in Zod:
4886
+ * https://github.com/colinhacks/zod/commit/9340fd51e48576a75adc919bff65dbc4a5d4c99b
4887
+ */
4888
+ emoji: () => {
4889
+ if (emojiRegex2 === void 0) {
4890
+ emojiRegex2 = RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$", "u");
4891
+ }
4892
+ return emojiRegex2;
4893
+ },
4894
+ /**
4895
+ * Unused
4896
+ */
4897
+ uuid: /^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/,
4898
+ /**
4899
+ * Unused
4900
+ */
4901
+ ipv4: /^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,
4902
+ ipv4Cidr: /^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,
4903
+ /**
4904
+ * Unused
4905
+ */
4906
+ ipv6: /^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/,
4907
+ ipv6Cidr: /^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,
4908
+ base64: /^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,
4909
+ base64url: /^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,
4910
+ nanoid: /^[a-zA-Z0-9_-]{21}$/,
4911
+ jwt: /^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/
4912
+ };
4913
+ ALPHA_NUMERIC = new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");
4914
+ }
4915
+ });
4916
+
4917
+ // ../node_modules/.pnpm/zod-to-json-schema@3.25.2_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/record.js
4918
+ function parseRecordDef(def, refs) {
4919
+ if (refs.target === "openAi") {
4920
+ console.warn("Warning: OpenAI may not support records in schemas! Try an array of key-value pairs instead.");
4921
+ }
4922
+ if (refs.target === "openApi3" && def.keyType?._def.typeName === ZodFirstPartyTypeKind.ZodEnum) {
4923
+ return {
4924
+ type: "object",
4925
+ required: def.keyType._def.values,
4926
+ properties: def.keyType._def.values.reduce((acc, key) => ({
4927
+ ...acc,
4928
+ [key]: parseDef(def.valueType._def, {
4929
+ ...refs,
4930
+ currentPath: [...refs.currentPath, "properties", key]
4931
+ }) ?? parseAnyDef(refs)
4932
+ }), {}),
4933
+ additionalProperties: refs.rejectedAdditionalProperties
4934
+ };
4935
+ }
4936
+ const schema = {
4937
+ type: "object",
4938
+ additionalProperties: parseDef(def.valueType._def, {
4939
+ ...refs,
4940
+ currentPath: [...refs.currentPath, "additionalProperties"]
4941
+ }) ?? refs.allowedAdditionalProperties
4942
+ };
4943
+ if (refs.target === "openApi3") {
4944
+ return schema;
4945
+ }
4946
+ if (def.keyType?._def.typeName === ZodFirstPartyTypeKind.ZodString && def.keyType._def.checks?.length) {
4947
+ const { type, ...keyType } = parseStringDef(def.keyType._def, refs);
4948
+ return {
4949
+ ...schema,
4950
+ propertyNames: keyType
4951
+ };
4952
+ } else if (def.keyType?._def.typeName === ZodFirstPartyTypeKind.ZodEnum) {
4953
+ return {
4954
+ ...schema,
4955
+ propertyNames: {
4956
+ enum: def.keyType._def.values
4957
+ }
4958
+ };
4959
+ } else if (def.keyType?._def.typeName === ZodFirstPartyTypeKind.ZodBranded && def.keyType._def.type._def.typeName === ZodFirstPartyTypeKind.ZodString && def.keyType._def.type._def.checks?.length) {
4960
+ const { type, ...keyType } = parseBrandedDef(def.keyType._def, refs);
4961
+ return {
4962
+ ...schema,
4963
+ propertyNames: keyType
4964
+ };
4965
+ }
4966
+ return schema;
4967
+ }
4968
+ var init_record = __esm({
4969
+ "../node_modules/.pnpm/zod-to-json-schema@3.25.2_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/record.js"() {
4970
+ "use strict";
4971
+ init_v3();
4972
+ init_parseDef();
4973
+ init_string();
4974
+ init_branded();
4975
+ init_any();
4976
+ }
4977
+ });
4978
+
4979
+ // ../node_modules/.pnpm/zod-to-json-schema@3.25.2_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/map.js
4980
+ function parseMapDef(def, refs) {
4981
+ if (refs.mapStrategy === "record") {
4982
+ return parseRecordDef(def, refs);
4983
+ }
4984
+ const keys = parseDef(def.keyType._def, {
4985
+ ...refs,
4986
+ currentPath: [...refs.currentPath, "items", "items", "0"]
4987
+ }) || parseAnyDef(refs);
4988
+ const values = parseDef(def.valueType._def, {
4989
+ ...refs,
4990
+ currentPath: [...refs.currentPath, "items", "items", "1"]
4991
+ }) || parseAnyDef(refs);
4992
+ return {
4993
+ type: "array",
4994
+ maxItems: 125,
4995
+ items: {
4996
+ type: "array",
4997
+ items: [keys, values],
4998
+ minItems: 2,
4999
+ maxItems: 2
5000
+ }
5001
+ };
5002
+ }
5003
+ var init_map = __esm({
5004
+ "../node_modules/.pnpm/zod-to-json-schema@3.25.2_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/map.js"() {
5005
+ "use strict";
5006
+ init_parseDef();
5007
+ init_record();
5008
+ init_any();
5009
+ }
5010
+ });
5011
+
5012
+ // ../node_modules/.pnpm/zod-to-json-schema@3.25.2_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/nativeEnum.js
5013
+ function parseNativeEnumDef(def) {
5014
+ const object = def.values;
5015
+ const actualKeys = Object.keys(def.values).filter((key) => {
5016
+ return typeof object[object[key]] !== "number";
5017
+ });
5018
+ const actualValues = actualKeys.map((key) => object[key]);
5019
+ const parsedTypes = Array.from(new Set(actualValues.map((values) => typeof values)));
5020
+ return {
5021
+ type: parsedTypes.length === 1 ? parsedTypes[0] === "string" ? "string" : "number" : ["string", "number"],
5022
+ enum: actualValues
5023
+ };
5024
+ }
5025
+ var init_nativeEnum = __esm({
5026
+ "../node_modules/.pnpm/zod-to-json-schema@3.25.2_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/nativeEnum.js"() {
5027
+ "use strict";
5028
+ }
5029
+ });
5030
+
5031
+ // ../node_modules/.pnpm/zod-to-json-schema@3.25.2_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/never.js
5032
+ function parseNeverDef(refs) {
5033
+ return refs.target === "openAi" ? void 0 : {
5034
+ not: parseAnyDef({
5035
+ ...refs,
5036
+ currentPath: [...refs.currentPath, "not"]
5037
+ })
5038
+ };
5039
+ }
5040
+ var init_never = __esm({
5041
+ "../node_modules/.pnpm/zod-to-json-schema@3.25.2_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/never.js"() {
5042
+ "use strict";
5043
+ init_any();
5044
+ }
5045
+ });
5046
+
5047
+ // ../node_modules/.pnpm/zod-to-json-schema@3.25.2_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/null.js
5048
+ function parseNullDef(refs) {
5049
+ return refs.target === "openApi3" ? {
5050
+ enum: ["null"],
5051
+ nullable: true
5052
+ } : {
5053
+ type: "null"
5054
+ };
5055
+ }
5056
+ var init_null = __esm({
5057
+ "../node_modules/.pnpm/zod-to-json-schema@3.25.2_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/null.js"() {
5058
+ "use strict";
5059
+ }
5060
+ });
5061
+
5062
+ // ../node_modules/.pnpm/zod-to-json-schema@3.25.2_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/union.js
5063
+ function parseUnionDef(def, refs) {
5064
+ if (refs.target === "openApi3")
5065
+ return asAnyOf(def, refs);
5066
+ const options = def.options instanceof Map ? Array.from(def.options.values()) : def.options;
5067
+ if (options.every((x) => x._def.typeName in primitiveMappings && (!x._def.checks || !x._def.checks.length))) {
5068
+ const types = options.reduce((types2, x) => {
5069
+ const type = primitiveMappings[x._def.typeName];
5070
+ return type && !types2.includes(type) ? [...types2, type] : types2;
5071
+ }, []);
5072
+ return {
5073
+ type: types.length > 1 ? types : types[0]
5074
+ };
5075
+ } else if (options.every((x) => x._def.typeName === "ZodLiteral" && !x.description)) {
5076
+ const types = options.reduce((acc, x) => {
5077
+ const type = typeof x._def.value;
5078
+ switch (type) {
5079
+ case "string":
5080
+ case "number":
5081
+ case "boolean":
5082
+ return [...acc, type];
5083
+ case "bigint":
5084
+ return [...acc, "integer"];
5085
+ case "object":
5086
+ if (x._def.value === null)
5087
+ return [...acc, "null"];
5088
+ case "symbol":
5089
+ case "undefined":
5090
+ case "function":
5091
+ default:
5092
+ return acc;
5093
+ }
5094
+ }, []);
5095
+ if (types.length === options.length) {
5096
+ const uniqueTypes = types.filter((x, i, a) => a.indexOf(x) === i);
5097
+ return {
5098
+ type: uniqueTypes.length > 1 ? uniqueTypes : uniqueTypes[0],
5099
+ enum: options.reduce((acc, x) => {
5100
+ return acc.includes(x._def.value) ? acc : [...acc, x._def.value];
5101
+ }, [])
5102
+ };
5103
+ }
5104
+ } else if (options.every((x) => x._def.typeName === "ZodEnum")) {
5105
+ return {
5106
+ type: "string",
5107
+ enum: options.reduce((acc, x) => [
5108
+ ...acc,
5109
+ ...x._def.values.filter((x2) => !acc.includes(x2))
5110
+ ], [])
5111
+ };
5112
+ }
5113
+ return asAnyOf(def, refs);
5114
+ }
5115
+ var primitiveMappings, asAnyOf;
5116
+ var init_union = __esm({
5117
+ "../node_modules/.pnpm/zod-to-json-schema@3.25.2_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/union.js"() {
5118
+ "use strict";
5119
+ init_parseDef();
5120
+ primitiveMappings = {
5121
+ ZodString: "string",
5122
+ ZodNumber: "number",
5123
+ ZodBigInt: "integer",
5124
+ ZodBoolean: "boolean",
5125
+ ZodNull: "null"
5126
+ };
5127
+ asAnyOf = (def, refs) => {
5128
+ const anyOf = (def.options instanceof Map ? Array.from(def.options.values()) : def.options).map((x, i) => parseDef(x._def, {
5129
+ ...refs,
5130
+ currentPath: [...refs.currentPath, "anyOf", `${i}`]
5131
+ })).filter((x) => !!x && (!refs.strictUnions || typeof x === "object" && Object.keys(x).length > 0));
5132
+ return anyOf.length ? { anyOf } : void 0;
5133
+ };
5134
+ }
5135
+ });
5136
+
5137
+ // ../node_modules/.pnpm/zod-to-json-schema@3.25.2_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/nullable.js
5138
+ function parseNullableDef(def, refs) {
5139
+ if (["ZodString", "ZodNumber", "ZodBigInt", "ZodBoolean", "ZodNull"].includes(def.innerType._def.typeName) && (!def.innerType._def.checks || !def.innerType._def.checks.length)) {
5140
+ if (refs.target === "openApi3") {
5141
+ return {
5142
+ type: primitiveMappings[def.innerType._def.typeName],
5143
+ nullable: true
5144
+ };
5145
+ }
5146
+ return {
5147
+ type: [
5148
+ primitiveMappings[def.innerType._def.typeName],
5149
+ "null"
5150
+ ]
5151
+ };
5152
+ }
5153
+ if (refs.target === "openApi3") {
5154
+ const base2 = parseDef(def.innerType._def, {
5155
+ ...refs,
5156
+ currentPath: [...refs.currentPath]
5157
+ });
5158
+ if (base2 && "$ref" in base2)
5159
+ return { allOf: [base2], nullable: true };
5160
+ return base2 && { ...base2, nullable: true };
5161
+ }
5162
+ const base = parseDef(def.innerType._def, {
5163
+ ...refs,
5164
+ currentPath: [...refs.currentPath, "anyOf", "0"]
5165
+ });
5166
+ return base && { anyOf: [base, { type: "null" }] };
5167
+ }
5168
+ var init_nullable = __esm({
5169
+ "../node_modules/.pnpm/zod-to-json-schema@3.25.2_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/nullable.js"() {
5170
+ "use strict";
5171
+ init_parseDef();
5172
+ init_union();
5173
+ }
5174
+ });
5175
+
5176
+ // ../node_modules/.pnpm/zod-to-json-schema@3.25.2_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/number.js
5177
+ function parseNumberDef(def, refs) {
5178
+ const res = {
5179
+ type: "number"
5180
+ };
5181
+ if (!def.checks)
5182
+ return res;
5183
+ for (const check of def.checks) {
5184
+ switch (check.kind) {
5185
+ case "int":
5186
+ res.type = "integer";
5187
+ addErrorMessage(res, "type", check.message, refs);
5188
+ break;
5189
+ case "min":
5190
+ if (refs.target === "jsonSchema7") {
5191
+ if (check.inclusive) {
5192
+ setResponseValueAndErrors(res, "minimum", check.value, check.message, refs);
5193
+ } else {
5194
+ setResponseValueAndErrors(res, "exclusiveMinimum", check.value, check.message, refs);
5195
+ }
5196
+ } else {
5197
+ if (!check.inclusive) {
5198
+ res.exclusiveMinimum = true;
5199
+ }
5200
+ setResponseValueAndErrors(res, "minimum", check.value, check.message, refs);
5201
+ }
5202
+ break;
5203
+ case "max":
5204
+ if (refs.target === "jsonSchema7") {
5205
+ if (check.inclusive) {
5206
+ setResponseValueAndErrors(res, "maximum", check.value, check.message, refs);
5207
+ } else {
5208
+ setResponseValueAndErrors(res, "exclusiveMaximum", check.value, check.message, refs);
5209
+ }
5210
+ } else {
5211
+ if (!check.inclusive) {
5212
+ res.exclusiveMaximum = true;
5213
+ }
5214
+ setResponseValueAndErrors(res, "maximum", check.value, check.message, refs);
5215
+ }
5216
+ break;
5217
+ case "multipleOf":
5218
+ setResponseValueAndErrors(res, "multipleOf", check.value, check.message, refs);
5219
+ break;
5220
+ }
5221
+ }
5222
+ return res;
5223
+ }
5224
+ var init_number = __esm({
5225
+ "../node_modules/.pnpm/zod-to-json-schema@3.25.2_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/number.js"() {
5226
+ "use strict";
5227
+ init_errorMessages();
5228
+ }
5229
+ });
5230
+
5231
+ // ../node_modules/.pnpm/zod-to-json-schema@3.25.2_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/object.js
5232
+ function parseObjectDef(def, refs) {
5233
+ const forceOptionalIntoNullable = refs.target === "openAi";
5234
+ const result = {
5235
+ type: "object",
5236
+ properties: {}
5237
+ };
5238
+ const required = [];
5239
+ const shape = def.shape();
5240
+ for (const propName in shape) {
5241
+ let propDef = shape[propName];
5242
+ if (propDef === void 0 || propDef._def === void 0) {
5243
+ continue;
5244
+ }
5245
+ let propOptional = safeIsOptional(propDef);
5246
+ if (propOptional && forceOptionalIntoNullable) {
5247
+ if (propDef._def.typeName === "ZodOptional") {
5248
+ propDef = propDef._def.innerType;
5249
+ }
5250
+ if (!propDef.isNullable()) {
5251
+ propDef = propDef.nullable();
5252
+ }
5253
+ propOptional = false;
5254
+ }
5255
+ const parsedDef = parseDef(propDef._def, {
5256
+ ...refs,
5257
+ currentPath: [...refs.currentPath, "properties", propName],
5258
+ propertyPath: [...refs.currentPath, "properties", propName]
5259
+ });
5260
+ if (parsedDef === void 0) {
5261
+ continue;
5262
+ }
5263
+ result.properties[propName] = parsedDef;
5264
+ if (!propOptional) {
5265
+ required.push(propName);
5266
+ }
5267
+ }
5268
+ if (required.length) {
5269
+ result.required = required;
5270
+ }
5271
+ const additionalProperties = decideAdditionalProperties(def, refs);
5272
+ if (additionalProperties !== void 0) {
5273
+ result.additionalProperties = additionalProperties;
5274
+ }
5275
+ return result;
5276
+ }
5277
+ function decideAdditionalProperties(def, refs) {
5278
+ if (def.catchall._def.typeName !== "ZodNever") {
5279
+ return parseDef(def.catchall._def, {
5280
+ ...refs,
5281
+ currentPath: [...refs.currentPath, "additionalProperties"]
5282
+ });
5283
+ }
5284
+ switch (def.unknownKeys) {
5285
+ case "passthrough":
5286
+ return refs.allowedAdditionalProperties;
5287
+ case "strict":
5288
+ return refs.rejectedAdditionalProperties;
5289
+ case "strip":
5290
+ return refs.removeAdditionalStrategy === "strict" ? refs.allowedAdditionalProperties : refs.rejectedAdditionalProperties;
5291
+ }
5292
+ }
5293
+ function safeIsOptional(schema) {
5294
+ try {
5295
+ return schema.isOptional();
5296
+ } catch {
5297
+ return true;
5298
+ }
5299
+ }
5300
+ var init_object = __esm({
5301
+ "../node_modules/.pnpm/zod-to-json-schema@3.25.2_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/object.js"() {
5302
+ "use strict";
5303
+ init_parseDef();
5304
+ }
5305
+ });
5306
+
5307
+ // ../node_modules/.pnpm/zod-to-json-schema@3.25.2_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/optional.js
5308
+ var parseOptionalDef;
5309
+ var init_optional = __esm({
5310
+ "../node_modules/.pnpm/zod-to-json-schema@3.25.2_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/optional.js"() {
5311
+ "use strict";
5312
+ init_parseDef();
5313
+ init_any();
5314
+ parseOptionalDef = (def, refs) => {
5315
+ if (refs.currentPath.toString() === refs.propertyPath?.toString()) {
5316
+ return parseDef(def.innerType._def, refs);
5317
+ }
5318
+ const innerSchema = parseDef(def.innerType._def, {
5319
+ ...refs,
5320
+ currentPath: [...refs.currentPath, "anyOf", "1"]
5321
+ });
5322
+ return innerSchema ? {
5323
+ anyOf: [
5324
+ {
5325
+ not: parseAnyDef(refs)
5326
+ },
5327
+ innerSchema
5328
+ ]
5329
+ } : parseAnyDef(refs);
5330
+ };
5331
+ }
5332
+ });
5333
+
5334
+ // ../node_modules/.pnpm/zod-to-json-schema@3.25.2_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/pipeline.js
5335
+ var parsePipelineDef;
5336
+ var init_pipeline = __esm({
5337
+ "../node_modules/.pnpm/zod-to-json-schema@3.25.2_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/pipeline.js"() {
5338
+ "use strict";
5339
+ init_parseDef();
5340
+ parsePipelineDef = (def, refs) => {
5341
+ if (refs.pipeStrategy === "input") {
5342
+ return parseDef(def.in._def, refs);
5343
+ } else if (refs.pipeStrategy === "output") {
5344
+ return parseDef(def.out._def, refs);
5345
+ }
5346
+ const a = parseDef(def.in._def, {
5347
+ ...refs,
5348
+ currentPath: [...refs.currentPath, "allOf", "0"]
5349
+ });
5350
+ const b2 = parseDef(def.out._def, {
5351
+ ...refs,
5352
+ currentPath: [...refs.currentPath, "allOf", a ? "1" : "0"]
5353
+ });
5354
+ return {
5355
+ allOf: [a, b2].filter((x) => x !== void 0)
5356
+ };
5357
+ };
5358
+ }
5359
+ });
5360
+
5361
+ // ../node_modules/.pnpm/zod-to-json-schema@3.25.2_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/promise.js
5362
+ function parsePromiseDef(def, refs) {
5363
+ return parseDef(def.type._def, refs);
5364
+ }
5365
+ var init_promise = __esm({
5366
+ "../node_modules/.pnpm/zod-to-json-schema@3.25.2_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/promise.js"() {
5367
+ "use strict";
5368
+ init_parseDef();
5369
+ }
5370
+ });
5371
+
5372
+ // ../node_modules/.pnpm/zod-to-json-schema@3.25.2_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/set.js
5373
+ function parseSetDef(def, refs) {
5374
+ const items = parseDef(def.valueType._def, {
5375
+ ...refs,
5376
+ currentPath: [...refs.currentPath, "items"]
5377
+ });
5378
+ const schema = {
5379
+ type: "array",
5380
+ uniqueItems: true,
5381
+ items
5382
+ };
5383
+ if (def.minSize) {
5384
+ setResponseValueAndErrors(schema, "minItems", def.minSize.value, def.minSize.message, refs);
5385
+ }
5386
+ if (def.maxSize) {
5387
+ setResponseValueAndErrors(schema, "maxItems", def.maxSize.value, def.maxSize.message, refs);
5388
+ }
5389
+ return schema;
5390
+ }
5391
+ var init_set = __esm({
5392
+ "../node_modules/.pnpm/zod-to-json-schema@3.25.2_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/set.js"() {
5393
+ "use strict";
5394
+ init_errorMessages();
5395
+ init_parseDef();
5396
+ }
5397
+ });
5398
+
5399
+ // ../node_modules/.pnpm/zod-to-json-schema@3.25.2_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/tuple.js
5400
+ function parseTupleDef(def, refs) {
5401
+ if (def.rest) {
5402
+ return {
5403
+ type: "array",
5404
+ minItems: def.items.length,
5405
+ items: def.items.map((x, i) => parseDef(x._def, {
5406
+ ...refs,
5407
+ currentPath: [...refs.currentPath, "items", `${i}`]
5408
+ })).reduce((acc, x) => x === void 0 ? acc : [...acc, x], []),
5409
+ additionalItems: parseDef(def.rest._def, {
5410
+ ...refs,
5411
+ currentPath: [...refs.currentPath, "additionalItems"]
5412
+ })
5413
+ };
5414
+ } else {
5415
+ return {
5416
+ type: "array",
5417
+ minItems: def.items.length,
5418
+ maxItems: def.items.length,
5419
+ items: def.items.map((x, i) => parseDef(x._def, {
5420
+ ...refs,
5421
+ currentPath: [...refs.currentPath, "items", `${i}`]
5422
+ })).reduce((acc, x) => x === void 0 ? acc : [...acc, x], [])
5423
+ };
5424
+ }
5425
+ }
5426
+ var init_tuple = __esm({
5427
+ "../node_modules/.pnpm/zod-to-json-schema@3.25.2_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/tuple.js"() {
5428
+ "use strict";
5429
+ init_parseDef();
5430
+ }
5431
+ });
5432
+
5433
+ // ../node_modules/.pnpm/zod-to-json-schema@3.25.2_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/undefined.js
5434
+ function parseUndefinedDef(refs) {
5435
+ return {
5436
+ not: parseAnyDef(refs)
5437
+ };
5438
+ }
5439
+ var init_undefined = __esm({
5440
+ "../node_modules/.pnpm/zod-to-json-schema@3.25.2_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/undefined.js"() {
5441
+ "use strict";
5442
+ init_any();
5443
+ }
5444
+ });
5445
+
5446
+ // ../node_modules/.pnpm/zod-to-json-schema@3.25.2_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/unknown.js
5447
+ function parseUnknownDef(refs) {
5448
+ return parseAnyDef(refs);
5449
+ }
5450
+ var init_unknown = __esm({
5451
+ "../node_modules/.pnpm/zod-to-json-schema@3.25.2_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/unknown.js"() {
5452
+ "use strict";
5453
+ init_any();
5454
+ }
5455
+ });
5456
+
5457
+ // ../node_modules/.pnpm/zod-to-json-schema@3.25.2_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/readonly.js
5458
+ var parseReadonlyDef;
5459
+ var init_readonly = __esm({
5460
+ "../node_modules/.pnpm/zod-to-json-schema@3.25.2_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/readonly.js"() {
5461
+ "use strict";
5462
+ init_parseDef();
5463
+ parseReadonlyDef = (def, refs) => {
5464
+ return parseDef(def.innerType._def, refs);
5465
+ };
5466
+ }
5467
+ });
5468
+
5469
+ // ../node_modules/.pnpm/zod-to-json-schema@3.25.2_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/selectParser.js
5470
+ var selectParser;
5471
+ var init_selectParser = __esm({
5472
+ "../node_modules/.pnpm/zod-to-json-schema@3.25.2_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/selectParser.js"() {
5473
+ "use strict";
5474
+ init_v3();
5475
+ init_any();
5476
+ init_array();
5477
+ init_bigint();
5478
+ init_boolean();
5479
+ init_branded();
5480
+ init_catch();
5481
+ init_date();
5482
+ init_default();
5483
+ init_effects();
5484
+ init_enum();
5485
+ init_intersection();
5486
+ init_literal();
5487
+ init_map();
5488
+ init_nativeEnum();
5489
+ init_never();
5490
+ init_null();
5491
+ init_nullable();
5492
+ init_number();
5493
+ init_object();
5494
+ init_optional();
5495
+ init_pipeline();
5496
+ init_promise();
5497
+ init_record();
5498
+ init_set();
5499
+ init_string();
5500
+ init_tuple();
5501
+ init_undefined();
5502
+ init_union();
5503
+ init_unknown();
5504
+ init_readonly();
5505
+ selectParser = (def, typeName, refs) => {
5506
+ switch (typeName) {
5507
+ case ZodFirstPartyTypeKind.ZodString:
5508
+ return parseStringDef(def, refs);
5509
+ case ZodFirstPartyTypeKind.ZodNumber:
5510
+ return parseNumberDef(def, refs);
5511
+ case ZodFirstPartyTypeKind.ZodObject:
5512
+ return parseObjectDef(def, refs);
5513
+ case ZodFirstPartyTypeKind.ZodBigInt:
5514
+ return parseBigintDef(def, refs);
5515
+ case ZodFirstPartyTypeKind.ZodBoolean:
5516
+ return parseBooleanDef();
5517
+ case ZodFirstPartyTypeKind.ZodDate:
5518
+ return parseDateDef(def, refs);
5519
+ case ZodFirstPartyTypeKind.ZodUndefined:
5520
+ return parseUndefinedDef(refs);
5521
+ case ZodFirstPartyTypeKind.ZodNull:
5522
+ return parseNullDef(refs);
5523
+ case ZodFirstPartyTypeKind.ZodArray:
5524
+ return parseArrayDef(def, refs);
5525
+ case ZodFirstPartyTypeKind.ZodUnion:
5526
+ case ZodFirstPartyTypeKind.ZodDiscriminatedUnion:
5527
+ return parseUnionDef(def, refs);
5528
+ case ZodFirstPartyTypeKind.ZodIntersection:
5529
+ return parseIntersectionDef(def, refs);
5530
+ case ZodFirstPartyTypeKind.ZodTuple:
5531
+ return parseTupleDef(def, refs);
5532
+ case ZodFirstPartyTypeKind.ZodRecord:
5533
+ return parseRecordDef(def, refs);
5534
+ case ZodFirstPartyTypeKind.ZodLiteral:
5535
+ return parseLiteralDef(def, refs);
5536
+ case ZodFirstPartyTypeKind.ZodEnum:
5537
+ return parseEnumDef(def);
5538
+ case ZodFirstPartyTypeKind.ZodNativeEnum:
5539
+ return parseNativeEnumDef(def);
5540
+ case ZodFirstPartyTypeKind.ZodNullable:
5541
+ return parseNullableDef(def, refs);
5542
+ case ZodFirstPartyTypeKind.ZodOptional:
5543
+ return parseOptionalDef(def, refs);
5544
+ case ZodFirstPartyTypeKind.ZodMap:
5545
+ return parseMapDef(def, refs);
5546
+ case ZodFirstPartyTypeKind.ZodSet:
5547
+ return parseSetDef(def, refs);
5548
+ case ZodFirstPartyTypeKind.ZodLazy:
5549
+ return () => def.getter()._def;
5550
+ case ZodFirstPartyTypeKind.ZodPromise:
5551
+ return parsePromiseDef(def, refs);
5552
+ case ZodFirstPartyTypeKind.ZodNaN:
5553
+ case ZodFirstPartyTypeKind.ZodNever:
5554
+ return parseNeverDef(refs);
5555
+ case ZodFirstPartyTypeKind.ZodEffects:
5556
+ return parseEffectsDef(def, refs);
5557
+ case ZodFirstPartyTypeKind.ZodAny:
5558
+ return parseAnyDef(refs);
5559
+ case ZodFirstPartyTypeKind.ZodUnknown:
5560
+ return parseUnknownDef(refs);
5561
+ case ZodFirstPartyTypeKind.ZodDefault:
5562
+ return parseDefaultDef(def, refs);
5563
+ case ZodFirstPartyTypeKind.ZodBranded:
5564
+ return parseBrandedDef(def, refs);
5565
+ case ZodFirstPartyTypeKind.ZodReadonly:
5566
+ return parseReadonlyDef(def, refs);
5567
+ case ZodFirstPartyTypeKind.ZodCatch:
5568
+ return parseCatchDef(def, refs);
5569
+ case ZodFirstPartyTypeKind.ZodPipeline:
5570
+ return parsePipelineDef(def, refs);
5571
+ case ZodFirstPartyTypeKind.ZodFunction:
5572
+ case ZodFirstPartyTypeKind.ZodVoid:
5573
+ case ZodFirstPartyTypeKind.ZodSymbol:
5574
+ return void 0;
5575
+ default:
5576
+ return /* @__PURE__ */ ((_2) => void 0)(typeName);
5577
+ }
5578
+ };
5579
+ }
5580
+ });
5581
+
5582
+ // ../node_modules/.pnpm/zod-to-json-schema@3.25.2_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parseDef.js
5583
+ function parseDef(def, refs, forceResolution = false) {
5584
+ const seenItem = refs.seen.get(def);
5585
+ if (refs.override) {
5586
+ const overrideResult = refs.override?.(def, refs, seenItem, forceResolution);
5587
+ if (overrideResult !== ignoreOverride) {
5588
+ return overrideResult;
5589
+ }
5590
+ }
5591
+ if (seenItem && !forceResolution) {
5592
+ const seenSchema = get$ref(seenItem, refs);
5593
+ if (seenSchema !== void 0) {
5594
+ return seenSchema;
5595
+ }
5596
+ }
5597
+ const newItem = { def, path: refs.currentPath, jsonSchema: void 0 };
5598
+ refs.seen.set(def, newItem);
5599
+ const jsonSchemaOrGetter = selectParser(def, def.typeName, refs);
5600
+ const jsonSchema = typeof jsonSchemaOrGetter === "function" ? parseDef(jsonSchemaOrGetter(), refs) : jsonSchemaOrGetter;
5601
+ if (jsonSchema) {
5602
+ addMeta(def, refs, jsonSchema);
5603
+ }
5604
+ if (refs.postProcess) {
5605
+ const postProcessResult = refs.postProcess(jsonSchema, def, refs);
5606
+ newItem.jsonSchema = jsonSchema;
5607
+ return postProcessResult;
5608
+ }
5609
+ newItem.jsonSchema = jsonSchema;
5610
+ return jsonSchema;
5611
+ }
5612
+ var get$ref, addMeta;
5613
+ var init_parseDef = __esm({
5614
+ "../node_modules/.pnpm/zod-to-json-schema@3.25.2_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parseDef.js"() {
5615
+ "use strict";
5616
+ init_Options();
5617
+ init_selectParser();
5618
+ init_getRelativePath();
5619
+ init_any();
5620
+ get$ref = (item, refs) => {
5621
+ switch (refs.$refStrategy) {
5622
+ case "root":
5623
+ return { $ref: item.path.join("/") };
5624
+ case "relative":
5625
+ return { $ref: getRelativePath(refs.currentPath, item.path) };
5626
+ case "none":
5627
+ case "seen": {
5628
+ if (item.path.length < refs.currentPath.length && item.path.every((value, index) => refs.currentPath[index] === value)) {
5629
+ console.warn(`Recursive reference detected at ${refs.currentPath.join("/")}! Defaulting to any`);
5630
+ return parseAnyDef(refs);
5631
+ }
5632
+ return refs.$refStrategy === "seen" ? parseAnyDef(refs) : void 0;
5633
+ }
5634
+ }
5635
+ };
5636
+ addMeta = (def, refs, jsonSchema) => {
5637
+ if (def.description) {
5638
+ jsonSchema.description = def.description;
5639
+ if (refs.markdownDescription) {
5640
+ jsonSchema.markdownDescription = def.description;
5641
+ }
5642
+ }
5643
+ return jsonSchema;
5644
+ };
5645
+ }
5646
+ });
5647
+
5648
+ // ../node_modules/.pnpm/zod-to-json-schema@3.25.2_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parseTypes.js
5649
+ var init_parseTypes = __esm({
5650
+ "../node_modules/.pnpm/zod-to-json-schema@3.25.2_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parseTypes.js"() {
5651
+ "use strict";
5652
+ }
5653
+ });
5654
+
5655
+ // ../node_modules/.pnpm/zod-to-json-schema@3.25.2_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/zodToJsonSchema.js
5656
+ var zodToJsonSchema;
5657
+ var init_zodToJsonSchema = __esm({
5658
+ "../node_modules/.pnpm/zod-to-json-schema@3.25.2_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/zodToJsonSchema.js"() {
5659
+ "use strict";
5660
+ init_parseDef();
5661
+ init_Refs();
5662
+ init_any();
5663
+ zodToJsonSchema = (schema, options) => {
5664
+ const refs = getRefs(options);
5665
+ let definitions = typeof options === "object" && options.definitions ? Object.entries(options.definitions).reduce((acc, [name2, schema2]) => ({
5666
+ ...acc,
5667
+ [name2]: parseDef(schema2._def, {
5668
+ ...refs,
5669
+ currentPath: [...refs.basePath, refs.definitionPath, name2]
5670
+ }, true) ?? parseAnyDef(refs)
5671
+ }), {}) : void 0;
5672
+ const name = typeof options === "string" ? options : options?.nameStrategy === "title" ? void 0 : options?.name;
5673
+ const main2 = parseDef(schema._def, name === void 0 ? refs : {
5674
+ ...refs,
5675
+ currentPath: [...refs.basePath, refs.definitionPath, name]
5676
+ }, false) ?? parseAnyDef(refs);
5677
+ const title = typeof options === "object" && options.name !== void 0 && options.nameStrategy === "title" ? options.name : void 0;
5678
+ if (title !== void 0) {
5679
+ main2.title = title;
5680
+ }
5681
+ if (refs.flags.hasReferencedOpenAiAnyType) {
5682
+ if (!definitions) {
5683
+ definitions = {};
5684
+ }
5685
+ if (!definitions[refs.openAiAnyTypeName]) {
5686
+ definitions[refs.openAiAnyTypeName] = {
5687
+ // Skipping "object" as no properties can be defined and additionalProperties must be "false"
5688
+ type: ["string", "number", "integer", "boolean", "array", "null"],
5689
+ items: {
5690
+ $ref: refs.$refStrategy === "relative" ? "1" : [
5691
+ ...refs.basePath,
5692
+ refs.definitionPath,
5693
+ refs.openAiAnyTypeName
5694
+ ].join("/")
5695
+ }
5696
+ };
5697
+ }
5698
+ }
5699
+ const combined = name === void 0 ? definitions ? {
5700
+ ...main2,
5701
+ [refs.definitionPath]: definitions
5702
+ } : main2 : {
5703
+ $ref: [
5704
+ ...refs.$refStrategy === "relative" ? [] : refs.basePath,
5705
+ refs.definitionPath,
5706
+ name
5707
+ ].join("/"),
5708
+ [refs.definitionPath]: {
5709
+ ...definitions,
5710
+ [name]: main2
5711
+ }
5712
+ };
5713
+ if (refs.target === "jsonSchema7") {
5714
+ combined.$schema = "http://json-schema.org/draft-07/schema#";
5715
+ } else if (refs.target === "jsonSchema2019-09" || refs.target === "openAi") {
5716
+ combined.$schema = "https://json-schema.org/draft/2019-09/schema#";
5717
+ }
5718
+ if (refs.target === "openAi" && ("anyOf" in combined || "oneOf" in combined || "allOf" in combined || "type" in combined && Array.isArray(combined.type))) {
5719
+ console.warn("Warning: OpenAI may not support schemas with unions as roots! Try wrapping it in an object property.");
5720
+ }
5721
+ return combined;
5722
+ };
5723
+ }
5724
+ });
5725
+
5726
+ // ../node_modules/.pnpm/zod-to-json-schema@3.25.2_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/index.js
5727
+ var init_esm = __esm({
5728
+ "../node_modules/.pnpm/zod-to-json-schema@3.25.2_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/index.js"() {
5729
+ "use strict";
5730
+ init_Options();
5731
+ init_Refs();
5732
+ init_errorMessages();
5733
+ init_getRelativePath();
5734
+ init_parseDef();
5735
+ init_parseTypes();
5736
+ init_any();
5737
+ init_array();
5738
+ init_bigint();
5739
+ init_boolean();
5740
+ init_branded();
5741
+ init_catch();
5742
+ init_date();
5743
+ init_default();
5744
+ init_effects();
5745
+ init_enum();
5746
+ init_intersection();
5747
+ init_literal();
5748
+ init_map();
5749
+ init_nativeEnum();
5750
+ init_never();
5751
+ init_null();
5752
+ init_nullable();
5753
+ init_number();
5754
+ init_object();
5755
+ init_optional();
5756
+ init_pipeline();
5757
+ init_promise();
5758
+ init_readonly();
5759
+ init_record();
5760
+ init_set();
5761
+ init_string();
5762
+ init_tuple();
5763
+ init_undefined();
5764
+ init_union();
5765
+ init_unknown();
5766
+ init_selectParser();
5767
+ init_zodToJsonSchema();
5768
+ init_zodToJsonSchema();
5769
+ }
5770
+ });
5771
+
4152
5772
  // ../protocol/src/attachment-schemas.ts
4153
5773
  var TOKEN_ROLES, GROUP_FILE_SOURCES, GroupFileEntrySchema, AttachmentSignUrlArgs, AttachmentSignUrlResponseSchema, AttachmentGroupAddArgs, AttachmentGroupAddResponseSchema, AttachmentGroupRemoveArgs, AttachmentGroupRemoveResponseSchema, AttachmentGroupListArgs, AttachmentGroupListResponseSchema, AttachmentUploadResponseSchema;
4154
5774
  var init_attachment_schemas = __esm({
@@ -4534,11 +6154,12 @@ var init_feishu_auth = __esm({
4534
6154
  });
4535
6155
 
4536
6156
  // ../protocol/src/dispatch.ts
4537
- var DispatchOutcomeSchema, DispatchRunArgsSchema, DispatchCompleteArgsSchema, DISPATCH_STATUSES, DispatchStatusSchema, DispatchRecordSchema, DispatchListArgsSchema, DispatchListResultSchema, DispatchGetArgsSchema, DispatchGetOkSchema;
6157
+ var EXTERNAL_DISPATCH_SOURCE, DispatchOutcomeSchema, DispatchRunArgsSchema, DispatchCompleteArgsSchema, DISPATCH_STATUSES, DispatchStatusSchema, DispatchRecordSchema, DispatchListArgsSchema, DispatchListResultSchema, DispatchGetArgsSchema, DispatchGetOkSchema;
4538
6158
  var init_dispatch = __esm({
4539
6159
  "../protocol/src/dispatch.ts"() {
4540
6160
  "use strict";
4541
6161
  init_zod();
6162
+ EXTERNAL_DISPATCH_SOURCE = "external-agent";
4542
6163
  DispatchOutcomeSchema = external_exports.discriminatedUnion("kind", [
4543
6164
  external_exports.object({
4544
6165
  kind: external_exports.literal("success"),
@@ -6116,21 +7737,28 @@ var init_schemas = __esm({
6116
7737
  });
6117
7738
 
6118
7739
  // ../protocol/src/methods.ts
7740
+ function isMethodName(name) {
7741
+ return METHOD_NAMES.includes(name);
7742
+ }
7743
+ function methodArgsSchema(method) {
7744
+ const doc = METHOD_DOCS[method];
7745
+ if (!doc.args) return null;
7746
+ const base = zodToJsonSchema(doc.args, { $refStrategy: "none" });
7747
+ return doc.argsConstraints ? { ...base, ...doc.argsConstraints } : base;
7748
+ }
6119
7749
  function methodArgFields(method) {
6120
- let schema = METHOD_DOCS[method].args;
7750
+ const schema = methodArgsSchema(method);
6121
7751
  if (!schema) return null;
6122
- for (let i = 0; i < 5 && schema && !schema.shape; i += 1) {
6123
- schema = schema._def?.schema;
6124
- }
6125
- const shape = schema?.shape;
6126
- if (!shape) return null;
6127
- return Object.entries(shape).map(([name, def]) => ({ name, required: !def.isOptional() }));
7752
+ const props = schema.properties ?? {};
7753
+ const required = new Set(schema.required ?? []);
7754
+ return Object.keys(props).map((name) => ({ name, required: required.has(name) }));
6128
7755
  }
6129
- var NO_ARGS, METHOD_DOCS, METHOD_NAMES, RPC_METHOD_STATUSES, RpcMethodStatusSchema, RpcMethodInfoSchema, MetaMethodsResultSchema;
7756
+ var NO_ARGS, MetaMethodsArgs, METHOD_DOCS, METHOD_NAMES, RPC_METHOD_STATUSES, RpcMethodStatusSchema, RpcMethodInfoSchema, MetaMethodsResultSchema;
6130
7757
  var init_methods = __esm({
6131
7758
  "../protocol/src/methods.ts"() {
6132
7759
  "use strict";
6133
7760
  init_zod();
7761
+ init_esm();
6134
7762
  init_attachment_schemas();
6135
7763
  init_contact_handshake();
6136
7764
  init_contact_remote_access();
@@ -6144,10 +7772,16 @@ var init_methods = __esm({
6144
7772
  init_persona_schemas();
6145
7773
  init_schemas();
6146
7774
  NO_ARGS = external_exports.object({});
7775
+ MetaMethodsArgs = external_exports.object({
7776
+ method: external_exports.string().min(1).optional()
7777
+ });
6147
7778
  METHOD_DOCS = {
6148
7779
  "session:create": {
6149
- summary: "\u65B0\u5EFA\u4F1A\u8BDD\u5E76\u62C9\u8D77 tool \u8FDB\u7A0B\uFF08claude / codex\uFF09\u3002**cwd \u4E0E ownerPersonaId \u81F3\u5C11\u4F20\u4E00\u4E2A**\uFF08\u5E26 ownerPersonaId \u65F6 cwd \u7531 daemon \u6D3E\u751F\uFF09\u2014\u2014\u8FD9\u6761\u4E92\u65A5\u7EA6\u675F\u662F schema \u7684 refine\uFF0C\u53CD\u5C04\u4E0D\u51FA\u6765",
6150
- args: SessionCreateArgs
7780
+ summary: "\u65B0\u5EFA\u4F1A\u8BDD\u5E76\u62C9\u8D77 tool \u8FDB\u7A0B\uFF08claude / codex\uFF09\u3002**cwd \u4E0E ownerPersonaId \u81F3\u5C11\u4F20\u4E00\u4E2A**\uFF08\u5E26 ownerPersonaId \u65F6 cwd \u7531 daemon \u6D3E\u751F\uFF09",
7781
+ args: SessionCreateArgs,
7782
+ argsConstraints: {
7783
+ anyOf: [{ required: ["cwd"] }, { required: ["ownerPersonaId"] }]
7784
+ }
6151
7785
  },
6152
7786
  "session:list": {
6153
7787
  summary: "\u5217\u51FA\u5F53\u524D\u8EAB\u4EFD\u53EF\u89C1\u7684\u4F1A\u8BDD\uFF08owner \u5168\u91CF\uFF1Bguest \u9650\u88AB\u6388\u6743 persona\uFF09",
@@ -6355,7 +7989,11 @@ var init_methods = __esm({
6355
7989
  },
6356
7990
  "personaDispatch:run": {
6357
7991
  summary: "\u628A\u4EFB\u52A1\u59D4\u6D3E\u7ED9\u53E6\u4E00\u4E2A persona\uFF08\u53EF\u8DE8\u8BBE\u5907\uFF09\uFF0C\u5F02\u6B65\u79D2\u56DE { dispatchId }\u3002targetPersona \u4E0E dispatchId **\u81F3\u5C11\u7ED9\u4E00\u4E2A**\uFF08\u524D\u8005\u65B0\u5F00\u3001\u540E\u8005\u7EED\u6D3E\uFF09\uFF1BdispatchId \u4E0E targetDeviceId **\u4E92\u65A5**",
6358
- args: DispatchRunArgsSchema
7992
+ args: DispatchRunArgsSchema,
7993
+ argsConstraints: {
7994
+ anyOf: [{ required: ["targetPersona"] }, { required: ["dispatchId"] }],
7995
+ not: { required: ["dispatchId", "targetDeviceId"] }
7996
+ }
6359
7997
  },
6360
7998
  "personaDispatch:complete": {
6361
7999
  summary: '\u88AB\u59D4\u6D3E\u65B9\u56DE\u62A5\u7ED3\u679C\uFF1A\u5199\u53F0\u8D26\u5E76\u628A\u7ED3\u679C\u6295\u9012\u56DE\u53D1\u8D77\u65B9\u4F1A\u8BDD\u3002outcome \u662F { kind:"success", text, filePaths? } \u6216 { kind:"failure", reason } \u4E8C\u9009\u4E00',
@@ -6451,8 +8089,8 @@ var init_methods = __esm({
6451
8089
  args: NO_ARGS
6452
8090
  },
6453
8091
  "meta:methods": {
6454
- summary: "RPC \u81EA\u7701\uFF1A\u8FD4\u56DE METHOD_NAMES \u5168\u96C6 + **\u5BF9\u672C\u8FDE\u63A5**\u7684\u53EF\u8C03\u7528\u6027\u4E09\u6001\uFF08allowed / conditional / denied\uFF09+ \u6BCF\u6761\u7684\u8BF4\u660E\u3002agent \u4FA7 clawd-rpc \u7684 list tool \u662F\u552F\u4E00\u6D88\u8D39\u65B9",
6455
- args: NO_ARGS
8092
+ summary: "RPC \u81EA\u7701\uFF1A\u8FD4\u56DE METHOD_NAMES \u5168\u96C6 + **\u5BF9\u672C\u8FDE\u63A5**\u7684\u53EF\u8C03\u7528\u6027\u4E09\u6001\uFF08allowed / conditional / denied\uFF09+ \u6BCF\u6761\u7684\u8BF4\u660E\u3002\u4F20 method \u5219\u53EA\u8FD4\u90A3\u4E00\u6761\uFF0C\u5E76\u989D\u5916\u5E26\u5B8C\u6574 args JSON Schema\u3002agent \u4FA7 clawd-rpc \u7684 list tool \u662F\u552F\u4E00\u6D88\u8D39\u65B9",
8093
+ args: MetaMethodsArgs
6456
8094
  },
6457
8095
  "extension.list": {
6458
8096
  summary: "\u5217\u51FA\u5DF2\u5B89\u88C5\u7684 extension",
@@ -6577,6 +8215,11 @@ var init_methods = __esm({
6577
8215
  * `null` = 该 method 还没有中央 zod schema(欠账,见 RpcMethodDoc),调用方需自行试探。
6578
8216
  */
6579
8217
  args: external_exports.array(external_exports.object({ name: external_exports.string(), required: external_exports.boolean() })).nullable(),
8218
+ /**
8219
+ * 完整 args JSON Schema(draft-07),来自 {@link methodArgsSchema}。
8220
+ * **只在按 method 单查时下发**——全量目录带上 105 份 schema 会吃掉消费方一大块 context。
8221
+ */
8222
+ argsSchema: external_exports.record(external_exports.unknown()).optional(),
6580
8223
  /**
6581
8224
  * `denied` 必带:daemon error code(`UNAUTHORIZED` / `FEISHU_LOGIN_REQUIRED` /
6582
8225
  * `METHOD_NOT_IMPLEMENTED`)。`conditional` 必带:谁来做二次校验。
@@ -7008,8 +8651,8 @@ var require_req = __commonJS({
7008
8651
  if (req.originalUrl) {
7009
8652
  _req.url = req.originalUrl;
7010
8653
  } else {
7011
- const path76 = req.path;
7012
- _req.url = typeof path76 === "string" ? path76 : req.url ? req.url.path || req.url : void 0;
8654
+ const path77 = req.path;
8655
+ _req.url = typeof path77 === "string" ? path77 : req.url ? req.url.path || req.url : void 0;
7013
8656
  }
7014
8657
  if (req.query) {
7015
8658
  _req.query = req.query;
@@ -7174,14 +8817,14 @@ var require_redact = __commonJS({
7174
8817
  }
7175
8818
  return obj;
7176
8819
  }
7177
- function parsePath(path76) {
8820
+ function parsePath(path77) {
7178
8821
  const parts = [];
7179
8822
  let current = "";
7180
8823
  let inBrackets = false;
7181
8824
  let inQuotes = false;
7182
8825
  let quoteChar = "";
7183
- for (let i = 0; i < path76.length; i++) {
7184
- const char = path76[i];
8826
+ for (let i = 0; i < path77.length; i++) {
8827
+ const char = path77[i];
7185
8828
  if (!inBrackets && char === ".") {
7186
8829
  if (current) {
7187
8830
  parts.push(current);
@@ -7312,10 +8955,10 @@ var require_redact = __commonJS({
7312
8955
  return current;
7313
8956
  }
7314
8957
  function redactPaths(obj, paths, censor, remove = false) {
7315
- for (const path76 of paths) {
7316
- const parts = parsePath(path76);
8958
+ for (const path77 of paths) {
8959
+ const parts = parsePath(path77);
7317
8960
  if (parts.includes("*")) {
7318
- redactWildcardPath(obj, parts, censor, path76, remove);
8961
+ redactWildcardPath(obj, parts, censor, path77, remove);
7319
8962
  } else {
7320
8963
  if (remove) {
7321
8964
  removeKey(obj, parts);
@@ -7400,8 +9043,8 @@ var require_redact = __commonJS({
7400
9043
  }
7401
9044
  } else {
7402
9045
  if (afterWildcard.includes("*")) {
7403
- const wrappedCensor = typeof censor === "function" ? (value, path76) => {
7404
- const fullPath = [...pathArray.slice(0, pathLength), ...path76];
9046
+ const wrappedCensor = typeof censor === "function" ? (value, path77) => {
9047
+ const fullPath = [...pathArray.slice(0, pathLength), ...path77];
7405
9048
  return censor(value, fullPath);
7406
9049
  } : censor;
7407
9050
  redactWildcardPath(current, afterWildcard, wrappedCensor, originalPath, remove);
@@ -7436,8 +9079,8 @@ var require_redact = __commonJS({
7436
9079
  return null;
7437
9080
  }
7438
9081
  const pathStructure = /* @__PURE__ */ new Map();
7439
- for (const path76 of pathsToClone) {
7440
- const parts = parsePath(path76);
9082
+ for (const path77 of pathsToClone) {
9083
+ const parts = parsePath(path77);
7441
9084
  let current = pathStructure;
7442
9085
  for (let i = 0; i < parts.length; i++) {
7443
9086
  const part = parts[i];
@@ -7489,24 +9132,24 @@ var require_redact = __commonJS({
7489
9132
  }
7490
9133
  return cloneSelectively(obj, pathStructure);
7491
9134
  }
7492
- function validatePath(path76) {
7493
- if (typeof path76 !== "string") {
9135
+ function validatePath(path77) {
9136
+ if (typeof path77 !== "string") {
7494
9137
  throw new Error("Paths must be (non-empty) strings");
7495
9138
  }
7496
- if (path76 === "") {
9139
+ if (path77 === "") {
7497
9140
  throw new Error("Invalid redaction path ()");
7498
9141
  }
7499
- if (path76.includes("..")) {
7500
- throw new Error(`Invalid redaction path (${path76})`);
9142
+ if (path77.includes("..")) {
9143
+ throw new Error(`Invalid redaction path (${path77})`);
7501
9144
  }
7502
- if (path76.includes(",")) {
7503
- throw new Error(`Invalid redaction path (${path76})`);
9145
+ if (path77.includes(",")) {
9146
+ throw new Error(`Invalid redaction path (${path77})`);
7504
9147
  }
7505
9148
  let bracketCount = 0;
7506
9149
  let inQuotes = false;
7507
9150
  let quoteChar = "";
7508
- for (let i = 0; i < path76.length; i++) {
7509
- const char = path76[i];
9151
+ for (let i = 0; i < path77.length; i++) {
9152
+ const char = path77[i];
7510
9153
  if ((char === '"' || char === "'") && bracketCount > 0) {
7511
9154
  if (!inQuotes) {
7512
9155
  inQuotes = true;
@@ -7520,20 +9163,20 @@ var require_redact = __commonJS({
7520
9163
  } else if (char === "]" && !inQuotes) {
7521
9164
  bracketCount--;
7522
9165
  if (bracketCount < 0) {
7523
- throw new Error(`Invalid redaction path (${path76})`);
9166
+ throw new Error(`Invalid redaction path (${path77})`);
7524
9167
  }
7525
9168
  }
7526
9169
  }
7527
9170
  if (bracketCount !== 0) {
7528
- throw new Error(`Invalid redaction path (${path76})`);
9171
+ throw new Error(`Invalid redaction path (${path77})`);
7529
9172
  }
7530
9173
  }
7531
9174
  function validatePaths(paths) {
7532
9175
  if (!Array.isArray(paths)) {
7533
9176
  throw new TypeError("paths must be an array");
7534
9177
  }
7535
- for (const path76 of paths) {
7536
- validatePath(path76);
9178
+ for (const path77 of paths) {
9179
+ validatePath(path77);
7537
9180
  }
7538
9181
  }
7539
9182
  function slowRedact(options = {}) {
@@ -7701,8 +9344,8 @@ var require_redaction = __commonJS({
7701
9344
  if (shape[k2] === null) {
7702
9345
  o[k2] = (value) => topCensor(value, [k2]);
7703
9346
  } else {
7704
- const wrappedCensor = typeof censor === "function" ? (value, path76) => {
7705
- return censor(value, [k2, ...path76]);
9347
+ const wrappedCensor = typeof censor === "function" ? (value, path77) => {
9348
+ return censor(value, [k2, ...path77]);
7706
9349
  } : censor;
7707
9350
  o[k2] = Redact({
7708
9351
  paths: shape[k2],
@@ -7923,7 +9566,7 @@ var require_sonic_boom = __commonJS({
7923
9566
  var fs67 = require("fs");
7924
9567
  var EventEmitter3 = require("events");
7925
9568
  var inherits = require("util").inherits;
7926
- var path76 = require("path");
9569
+ var path77 = require("path");
7927
9570
  var sleep2 = require_atomic_sleep();
7928
9571
  var assert = require("assert");
7929
9572
  var BUSY_WRITE_TIMEOUT = 100;
@@ -7977,7 +9620,7 @@ var require_sonic_boom = __commonJS({
7977
9620
  const mode = sonic.mode;
7978
9621
  if (sonic.sync) {
7979
9622
  try {
7980
- if (sonic.mkdir) fs67.mkdirSync(path76.dirname(file), { recursive: true });
9623
+ if (sonic.mkdir) fs67.mkdirSync(path77.dirname(file), { recursive: true });
7981
9624
  const fd = fs67.openSync(file, flags, mode);
7982
9625
  fileOpened(null, fd);
7983
9626
  } catch (err) {
@@ -7985,7 +9628,7 @@ var require_sonic_boom = __commonJS({
7985
9628
  throw err;
7986
9629
  }
7987
9630
  } else if (sonic.mkdir) {
7988
- fs67.mkdir(path76.dirname(file), { recursive: true }, (err) => {
9631
+ fs67.mkdir(path77.dirname(file), { recursive: true }, (err) => {
7989
9632
  if (err) return fileOpened(err);
7990
9633
  fs67.open(file, flags, mode, fileOpened);
7991
9634
  });
@@ -9534,7 +11177,7 @@ var require_tools = __commonJS({
9534
11177
  stream.flushSync();
9535
11178
  }
9536
11179
  }
9537
- function createArgsNormalizer(defaultOptions) {
11180
+ function createArgsNormalizer(defaultOptions2) {
9538
11181
  return function normalizeArgs(instance, caller, opts = {}, stream) {
9539
11182
  if (typeof opts === "string") {
9540
11183
  stream = buildSafeSonicBoom({ dest: opts });
@@ -9560,9 +11203,9 @@ var require_tools = __commonJS({
9560
11203
  }
9561
11204
  stream = transport({ caller, ...opts.transport, levels: customLevels });
9562
11205
  }
9563
- opts = Object.assign({}, defaultOptions, opts);
9564
- opts.serializers = Object.assign({}, defaultOptions.serializers, opts.serializers);
9565
- opts.formatters = Object.assign({}, defaultOptions.formatters, opts.formatters);
11206
+ opts = Object.assign({}, defaultOptions2, opts);
11207
+ opts.serializers = Object.assign({}, defaultOptions2.serializers, opts.serializers);
11208
+ opts.formatters = Object.assign({}, defaultOptions2.formatters, opts.formatters);
9566
11209
  if (opts.prettyPrint) {
9567
11210
  throw new Error("prettyPrint option is no longer supported, see the pino-pretty package (https://github.com/pinojs/pino-pretty)");
9568
11211
  }
@@ -10894,7 +12537,7 @@ var require_pino = __commonJS({
10894
12537
  var { pid } = process;
10895
12538
  var hostname = os24.hostname();
10896
12539
  var defaultErrorSerializer = stdSerializers.err;
10897
- var defaultOptions = {
12540
+ var defaultOptions2 = {
10898
12541
  level: "info",
10899
12542
  levelComparison: SORTING_ORDER.ASC,
10900
12543
  levels: DEFAULT_LEVELS,
@@ -10926,7 +12569,7 @@ var require_pino = __commonJS({
10926
12569
  depthLimit: 5,
10927
12570
  edgeLimit: 100
10928
12571
  };
10929
- var normalize = createArgsNormalizer(defaultOptions);
12572
+ var normalize = createArgsNormalizer(defaultOptions2);
10930
12573
  var serializers = Object.assign(/* @__PURE__ */ Object.create(null), stdSerializers);
10931
12574
  function pino2(...args) {
10932
12575
  const instance = {};
@@ -11616,11 +13259,11 @@ var init_lib = __esm({
11616
13259
  }
11617
13260
  }
11618
13261
  },
11619
- addToPath: function addToPath(path76, added, removed, oldPosInc, options) {
11620
- var last = path76.lastComponent;
13262
+ addToPath: function addToPath(path77, added, removed, oldPosInc, options) {
13263
+ var last = path77.lastComponent;
11621
13264
  if (last && !options.oneChangePerToken && last.added === added && last.removed === removed) {
11622
13265
  return {
11623
- oldPos: path76.oldPos + oldPosInc,
13266
+ oldPos: path77.oldPos + oldPosInc,
11624
13267
  lastComponent: {
11625
13268
  count: last.count + 1,
11626
13269
  added,
@@ -11630,7 +13273,7 @@ var init_lib = __esm({
11630
13273
  };
11631
13274
  } else {
11632
13275
  return {
11633
- oldPos: path76.oldPos + oldPosInc,
13276
+ oldPos: path77.oldPos + oldPosInc,
11634
13277
  lastComponent: {
11635
13278
  count: 1,
11636
13279
  added,
@@ -12139,10 +13782,10 @@ function attachmentToHistoryMessage(o, ts) {
12139
13782
  const memories = raw.map((m2) => {
12140
13783
  if (!m2 || typeof m2 !== "object") return null;
12141
13784
  const rec3 = m2;
12142
- const path76 = typeof rec3.path === "string" ? rec3.path : null;
13785
+ const path77 = typeof rec3.path === "string" ? rec3.path : null;
12143
13786
  const content = typeof rec3.content === "string" ? rec3.content : null;
12144
- if (!path76 || content == null) return null;
12145
- const entry = { path: path76, content };
13787
+ if (!path77 || content == null) return null;
13788
+ const entry = { path: path77, content };
12146
13789
  if (typeof rec3.mtimeMs === "number") entry.mtimeMs = rec3.mtimeMs;
12147
13790
  return entry;
12148
13791
  }).filter((m2) => m2 !== null);
@@ -12945,10 +14588,10 @@ function parseAttachment(obj) {
12945
14588
  const memories = raw.map((m2) => {
12946
14589
  if (!m2 || typeof m2 !== "object") return null;
12947
14590
  const rec3 = m2;
12948
- const path76 = typeof rec3.path === "string" ? rec3.path : null;
14591
+ const path77 = typeof rec3.path === "string" ? rec3.path : null;
12949
14592
  const content = typeof rec3.content === "string" ? rec3.content : null;
12950
- if (!path76 || content == null) return null;
12951
- const out = { path: path76, content };
14593
+ if (!path77 || content == null) return null;
14594
+ const out = { path: path77, content };
12952
14595
  if (typeof rec3.mtimeMs === "number") out.mtimeMs = rec3.mtimeMs;
12953
14596
  return out;
12954
14597
  }).filter((m2) => m2 !== null);
@@ -33917,8 +35560,8 @@ var require_utils = __commonJS({
33917
35560
  var result = transform[inputType][outputType](input);
33918
35561
  return result;
33919
35562
  };
33920
- exports2.resolve = function(path76) {
33921
- var parts = path76.split("/");
35563
+ exports2.resolve = function(path77) {
35564
+ var parts = path77.split("/");
33922
35565
  var result = [];
33923
35566
  for (var index = 0; index < parts.length; index++) {
33924
35567
  var part = parts[index];
@@ -39771,18 +41414,18 @@ var require_object = __commonJS({
39771
41414
  var object = new ZipObject(name, zipObjectContent, o);
39772
41415
  this.files[name] = object;
39773
41416
  };
39774
- var parentFolder = function(path76) {
39775
- if (path76.slice(-1) === "/") {
39776
- path76 = path76.substring(0, path76.length - 1);
41417
+ var parentFolder = function(path77) {
41418
+ if (path77.slice(-1) === "/") {
41419
+ path77 = path77.substring(0, path77.length - 1);
39777
41420
  }
39778
- var lastSlash = path76.lastIndexOf("/");
39779
- return lastSlash > 0 ? path76.substring(0, lastSlash) : "";
41421
+ var lastSlash = path77.lastIndexOf("/");
41422
+ return lastSlash > 0 ? path77.substring(0, lastSlash) : "";
39780
41423
  };
39781
- var forceTrailingSlash = function(path76) {
39782
- if (path76.slice(-1) !== "/") {
39783
- path76 += "/";
41424
+ var forceTrailingSlash = function(path77) {
41425
+ if (path77.slice(-1) !== "/") {
41426
+ path77 += "/";
39784
41427
  }
39785
- return path76;
41428
+ return path77;
39786
41429
  };
39787
41430
  var folderAdd = function(name, createFolders) {
39788
41431
  createFolders = typeof createFolders !== "undefined" ? createFolders : defaults.createFolders;
@@ -40784,7 +42427,7 @@ var require_lib3 = __commonJS({
40784
42427
  // src/run-case/recorder.ts
40785
42428
  function startRunCaseRecorder(opts) {
40786
42429
  const now = opts.now ?? Date.now;
40787
- const dir = import_node_path63.default.dirname(opts.recordPath);
42430
+ const dir = import_node_path64.default.dirname(opts.recordPath);
40788
42431
  let stream = null;
40789
42432
  let closing = false;
40790
42433
  let closedSettled = false;
@@ -40824,12 +42467,12 @@ function startRunCaseRecorder(opts) {
40824
42467
  };
40825
42468
  return { tap, close, closed };
40826
42469
  }
40827
- var import_node_fs48, import_node_path63;
42470
+ var import_node_fs48, import_node_path64;
40828
42471
  var init_recorder = __esm({
40829
42472
  "src/run-case/recorder.ts"() {
40830
42473
  "use strict";
40831
42474
  import_node_fs48 = __toESM(require("fs"), 1);
40832
- import_node_path63 = __toESM(require("path"), 1);
42475
+ import_node_path64 = __toESM(require("path"), 1);
40833
42476
  }
40834
42477
  });
40835
42478
 
@@ -40872,7 +42515,7 @@ var init_wire = __esm({
40872
42515
  // src/run-case/controller.ts
40873
42516
  async function runController(opts) {
40874
42517
  const now = opts.now ?? Date.now;
40875
- const cwd = opts.cwd ?? (0, import_node_fs49.mkdtempSync)(import_node_path64.default.join(import_node_os23.default.tmpdir(), "clawd-runcase-"));
42518
+ const cwd = opts.cwd ?? (0, import_node_fs49.mkdtempSync)(import_node_path65.default.join(import_node_os23.default.tmpdir(), "clawd-runcase-"));
40876
42519
  const ownsCwd = opts.cwd === void 0;
40877
42520
  const recorder = startRunCaseRecorder({ recordPath: opts.record, now });
40878
42521
  const spawnCtx = { cwd };
@@ -41039,13 +42682,13 @@ async function runController(opts) {
41039
42682
  }
41040
42683
  return exitCode ?? 0;
41041
42684
  }
41042
- var import_node_fs49, import_node_os23, import_node_path64;
42685
+ var import_node_fs49, import_node_os23, import_node_path65;
41043
42686
  var init_controller = __esm({
41044
42687
  "src/run-case/controller.ts"() {
41045
42688
  "use strict";
41046
42689
  import_node_fs49 = require("fs");
41047
42690
  import_node_os23 = __toESM(require("os"), 1);
41048
- import_node_path64 = __toESM(require("path"), 1);
42691
+ import_node_path65 = __toESM(require("path"), 1);
41049
42692
  init_claude();
41050
42693
  init_stdout_splitter();
41051
42694
  init_permission_stdio();
@@ -41320,7 +42963,7 @@ Env (advanced):
41320
42963
  `;
41321
42964
 
41322
42965
  // src/index.ts
41323
- var import_node_path62 = __toESM(require("path"), 1);
42966
+ var import_node_path63 = __toESM(require("path"), 1);
41324
42967
  var import_node_fs47 = __toESM(require("fs"), 1);
41325
42968
  var import_node_os22 = __toESM(require("os"), 1);
41326
42969
 
@@ -47248,8 +48891,8 @@ function turnStartInput(text) {
47248
48891
  const items = [];
47249
48892
  let leftover = text;
47250
48893
  for (const m2 of text.matchAll(SKILL_RE)) {
47251
- const [marker, name, path76] = m2;
47252
- items.push({ type: "skill", name, path: path76 });
48894
+ const [marker, name, path77] = m2;
48895
+ items.push({ type: "skill", name, path: path77 });
47253
48896
  leftover = leftover.replace(marker, "");
47254
48897
  }
47255
48898
  for (const m2 of text.matchAll(ATTACHMENT_RE2)) {
@@ -49174,9 +50817,24 @@ function writeRpcToolMcpConfig(args) {
49174
50817
  return cfgPath;
49175
50818
  }
49176
50819
 
50820
+ // src/dispatch/source-transcript.ts
50821
+ var import_node_path25 = __toESM(require("path"), 1);
50822
+ init_claude_history();
50823
+ var NO_SOURCE_TRANSCRIPT = "(no transcript yet \u2014 operate from the task description alone)";
50824
+ function resolveSourceJsonlPath(sourceFile, home) {
50825
+ if (!sourceFile?.toolSessionId) return NO_SOURCE_TRANSCRIPT;
50826
+ return import_node_path25.default.join(
50827
+ home,
50828
+ ".claude",
50829
+ "projects",
50830
+ cwdToHashDir(sourceFile.cwd),
50831
+ `${sourceFile.toolSessionId}.jsonl`
50832
+ );
50833
+ }
50834
+
49177
50835
  // src/shift/store.ts
49178
50836
  var import_promises2 = __toESM(require("fs/promises"), 1);
49179
- var import_node_path25 = __toESM(require("path"), 1);
50837
+ var import_node_path26 = __toESM(require("path"), 1);
49180
50838
  var import_node_crypto6 = require("crypto");
49181
50839
 
49182
50840
  // src/shift/schedule.ts
@@ -49251,7 +50909,7 @@ function createShiftStore(deps) {
49251
50909
  flushTimer = null;
49252
50910
  }
49253
50911
  const content = { version: 1, shifts };
49254
- await import_promises2.default.mkdir(import_node_path25.default.dirname(deps.filePath), { recursive: true });
50912
+ await import_promises2.default.mkdir(import_node_path26.default.dirname(deps.filePath), { recursive: true });
49255
50913
  const tmp = `${deps.filePath}.tmp-${deps.now()}-${Math.floor(Math.random() * 1e6)}`;
49256
50914
  await import_promises2.default.writeFile(tmp, JSON.stringify(content, null, 2), "utf8");
49257
50915
  await import_promises2.default.rename(tmp, deps.filePath);
@@ -49678,7 +51336,14 @@ function buildPersonaDispatchHandlers(deps) {
49678
51336
  const { personaDispatchManager: mgr, spawnB, logger } = deps;
49679
51337
  const run = async (frame, _client, ctx) => {
49680
51338
  const { type: _t, requestId: _r, ...rest } = frame;
49681
- const sourceSessionId = typeof rest.sessionId === "string" ? rest.sessionId : void 0;
51339
+ const rawSessionId = typeof rest.sessionId === "string" && rest.sessionId.length > 0 ? rest.sessionId : void 0;
51340
+ const sourceSessionId = rawSessionId ?? EXTERNAL_DISPATCH_SOURCE;
51341
+ if (!rawSessionId) {
51342
+ logger?.warn("dispatch.run.external-source", {
51343
+ targetPersona: typeof rest.targetPersona === "string" ? rest.targetPersona : void 0,
51344
+ sourceSessionId
51345
+ });
51346
+ }
49682
51347
  const args = DispatchRunArgsSchema.parse(rest);
49683
51348
  if (args.model !== void 0) {
49684
51349
  const targetPersona2 = args.targetPersona ?? (args.dispatchId ? deps.store.get(args.dispatchId)?.targetPersonaId : void 0);
@@ -49698,11 +51363,6 @@ function buildPersonaDispatchHandlers(deps) {
49698
51363
  "follow-up dispatch cannot be initiated by a guest"
49699
51364
  );
49700
51365
  }
49701
- if (!sourceSessionId) {
49702
- throw new Error(
49703
- "personaDispatch:run requires sessionId in the request body"
49704
- );
49705
- }
49706
51366
  const rec3 = deps.store.get(args.dispatchId);
49707
51367
  if (!rec3) {
49708
51368
  throw new ClawdError(ERROR_CODES.INVALID_PARAM, `dispatch not found: ${args.dispatchId}`);
@@ -49771,11 +51431,6 @@ function buildPersonaDispatchHandlers(deps) {
49771
51431
  if (!deps.forwardToPeer) {
49772
51432
  throw new Error("cross-device dispatch not wired (forwardToPeer missing)");
49773
51433
  }
49774
- if (!sourceSessionId) {
49775
- throw new Error(
49776
- "personaDispatch:run requires sessionId in the request body"
49777
- );
49778
- }
49779
51434
  const { dispatchId: dispatchId2 } = mgr.start({
49780
51435
  sourceSessionId,
49781
51436
  targetPersona,
@@ -49844,11 +51499,6 @@ function buildPersonaDispatchHandlers(deps) {
49844
51499
  response: { type: "personaDispatch:run:ok", dispatchId: dispatchId2 }
49845
51500
  };
49846
51501
  }
49847
- if (!sourceSessionId) {
49848
- throw new Error(
49849
- "personaDispatch:run requires sessionId in the request body"
49850
- );
49851
- }
49852
51502
  const { dispatchId } = mgr.start({
49853
51503
  sourceSessionId,
49854
51504
  targetPersona,
@@ -50271,7 +51921,7 @@ var CodexHistoryReader = class {
50271
51921
 
50272
51922
  // src/tools/codex-skills.ts
50273
51923
  var import_node_child_process7 = require("child_process");
50274
- var import_node_path26 = __toESM(require("path"), 1);
51924
+ var import_node_path27 = __toESM(require("path"), 1);
50275
51925
  var DEFAULT_TIMEOUT_MS3 = 8e3;
50276
51926
  function str3(v2) {
50277
51927
  return typeof v2 === "string" ? v2 : void 0;
@@ -50287,13 +51937,13 @@ function mapSkillsListResponse(res) {
50287
51937
  const r = s ?? {};
50288
51938
  const name = str3(r.name);
50289
51939
  if (!name) continue;
50290
- const path76 = str3(r.path);
51940
+ const path77 = str3(r.path);
50291
51941
  const description = str3(r.description);
50292
51942
  const isPlugin = name.includes(":");
50293
51943
  out.push({
50294
51944
  name,
50295
51945
  source: isPlugin ? "plugin" : "project",
50296
- ...path76 ? { path: path76 } : {},
51946
+ ...path77 ? { path: path77 } : {},
50297
51947
  ...description ? { description } : {},
50298
51948
  ...isPlugin ? { plugin: name.split(":")[0] } : {}
50299
51949
  });
@@ -50323,7 +51973,7 @@ async function listCodexSkills(cwd, deps = {}) {
50323
51973
  })(),
50324
51974
  timeout
50325
51975
  ]);
50326
- void client.request("skills/extraRoots/set", { extraRoots: [import_node_path26.default.join(cwd, ".claude", "skills")] }).catch(() => void 0);
51976
+ void client.request("skills/extraRoots/set", { extraRoots: [import_node_path27.default.join(cwd, ".claude", "skills")] }).catch(() => void 0);
50327
51977
  const res = await Promise.race([client.request("skills/list", { cwds: [cwd] }), timeout]);
50328
51978
  return mapSkillsListResponse(res);
50329
51979
  } finally {
@@ -50335,14 +51985,14 @@ async function listCodexSkills(cwd, deps = {}) {
50335
51985
  // src/workspace/browser.ts
50336
51986
  var import_node_fs26 = __toESM(require("fs"), 1);
50337
51987
  var import_node_os8 = __toESM(require("os"), 1);
50338
- var import_node_path27 = __toESM(require("path"), 1);
51988
+ var import_node_path28 = __toESM(require("path"), 1);
50339
51989
  init_protocol();
50340
51990
  var MAX_FILE_BYTES = 2 * 1024 * 1024;
50341
51991
  function resolveInsideCwd(cwd, subpath) {
50342
- const absCwd = import_node_path27.default.resolve(cwd);
50343
- const joined = import_node_path27.default.resolve(absCwd, subpath ?? ".");
50344
- const rel = import_node_path27.default.relative(absCwd, joined);
50345
- if (rel.startsWith("..") || import_node_path27.default.isAbsolute(rel)) {
51992
+ const absCwd = import_node_path28.default.resolve(cwd);
51993
+ const joined = import_node_path28.default.resolve(absCwd, subpath ?? ".");
51994
+ const rel = import_node_path28.default.relative(absCwd, joined);
51995
+ if (rel.startsWith("..") || import_node_path28.default.isAbsolute(rel)) {
50346
51996
  throw new ClawdError(ERROR_CODES.INVALID_PATH, `path escapes cwd: ${subpath}`);
50347
51997
  }
50348
51998
  return joined;
@@ -50373,7 +52023,7 @@ var WorkspaceBrowser = class {
50373
52023
  mtime: ""
50374
52024
  };
50375
52025
  try {
50376
- const st = import_node_fs26.default.statSync(import_node_path27.default.join(full, d.name));
52026
+ const st = import_node_fs26.default.statSync(import_node_path28.default.join(full, d.name));
50377
52027
  entry.mtime = new Date(st.mtimeMs).toISOString();
50378
52028
  if (d.isFile()) entry.size = st.size;
50379
52029
  } catch {
@@ -50420,7 +52070,7 @@ var WorkspaceBrowser = class {
50420
52070
  // src/skills/agents-scanner.ts
50421
52071
  var import_node_fs27 = __toESM(require("fs"), 1);
50422
52072
  var import_node_os9 = __toESM(require("os"), 1);
50423
- var import_node_path28 = __toESM(require("path"), 1);
52073
+ var import_node_path29 = __toESM(require("path"), 1);
50424
52074
  var DEFAULT_POLICY_DIR_DARWIN = "/Library/Application Support/ClaudeCode/.claude/agents";
50425
52075
  function isDirLikeSync2(p2) {
50426
52076
  try {
@@ -50458,10 +52108,10 @@ function scanAgentsDir(dir, source, seen, out) {
50458
52108
  }
50459
52109
  for (const ent of entries) {
50460
52110
  if (!ent.name.endsWith(".md")) continue;
50461
- if (!ent.isFile() && !(ent.isSymbolicLink() && fileExistsSync(import_node_path28.default.join(dir, ent.name)))) {
52111
+ if (!ent.isFile() && !(ent.isSymbolicLink() && fileExistsSync(import_node_path29.default.join(dir, ent.name)))) {
50462
52112
  continue;
50463
52113
  }
50464
- const filePath = import_node_path28.default.join(dir, ent.name);
52114
+ const filePath = import_node_path29.default.join(dir, ent.name);
50465
52115
  const baseName = ent.name.replace(/\.md$/, "");
50466
52116
  if (seen.has(baseName)) continue;
50467
52117
  seen.add(baseName);
@@ -50484,7 +52134,7 @@ function scanPluginAgentsTree(root, pluginName, seen, out) {
50484
52134
  return;
50485
52135
  }
50486
52136
  for (const ent of entries) {
50487
- const childPath = import_node_path28.default.join(dir, ent.name);
52137
+ const childPath = import_node_path29.default.join(dir, ent.name);
50488
52138
  if (ent.isDirectory() || ent.isSymbolicLink() && isDirLikeSync2(childPath)) {
50489
52139
  walk2(childPath, [...namespaces, ent.name]);
50490
52140
  continue;
@@ -50509,9 +52159,9 @@ function scanPluginAgentsTree(root, pluginName, seen, out) {
50509
52159
  walk2(root, []);
50510
52160
  }
50511
52161
  function readInstalledPlugins2(home) {
50512
- const pluginsDir = import_node_path28.default.join(home, ".claude", "plugins");
50513
- const v2 = import_node_path28.default.join(pluginsDir, "installed_plugins_v2.json");
50514
- const v1 = import_node_path28.default.join(pluginsDir, "installed_plugins.json");
52162
+ const pluginsDir = import_node_path29.default.join(home, ".claude", "plugins");
52163
+ const v2 = import_node_path29.default.join(pluginsDir, "installed_plugins_v2.json");
52164
+ const v1 = import_node_path29.default.join(pluginsDir, "installed_plugins.json");
50515
52165
  let raw = null;
50516
52166
  for (const candidate of [v2, v1]) {
50517
52167
  try {
@@ -50540,19 +52190,19 @@ function readInstalledPlugins2(home) {
50540
52190
  return out;
50541
52191
  }
50542
52192
  function walkUpProjectAgentsDirs(startCwd, home, seen, out) {
50543
- let cur = import_node_path28.default.resolve(startCwd);
50544
- const fsRoot = import_node_path28.default.parse(cur).root;
52193
+ let cur = import_node_path29.default.resolve(startCwd);
52194
+ const fsRoot = import_node_path29.default.parse(cur).root;
50545
52195
  while (true) {
50546
- scanAgentsDir(import_node_path28.default.join(cur, ".claude", "agents"), "project", seen, out);
52196
+ scanAgentsDir(import_node_path29.default.join(cur, ".claude", "agents"), "project", seen, out);
50547
52197
  let hasGit = false;
50548
52198
  try {
50549
- hasGit = import_node_fs27.default.existsSync(import_node_path28.default.join(cur, ".git"));
52199
+ hasGit = import_node_fs27.default.existsSync(import_node_path29.default.join(cur, ".git"));
50550
52200
  } catch {
50551
52201
  }
50552
52202
  if (hasGit) return;
50553
52203
  if (cur === home) return;
50554
52204
  if (cur === fsRoot) return;
50555
- const parent = import_node_path28.default.dirname(cur);
52205
+ const parent = import_node_path29.default.dirname(cur);
50556
52206
  if (parent === cur) return;
50557
52207
  cur = parent;
50558
52208
  }
@@ -50587,7 +52237,7 @@ var AgentsScanner = class {
50587
52237
  }
50588
52238
  const fsBlock = [];
50589
52239
  scanAgentsDir(
50590
- import_node_path28.default.join(this.home, ".claude", "agents"),
52240
+ import_node_path29.default.join(this.home, ".claude", "agents"),
50591
52241
  "global",
50592
52242
  seen,
50593
52243
  fsBlock
@@ -50601,7 +52251,7 @@ var AgentsScanner = class {
50601
52251
  ...this.extraPluginRoots
50602
52252
  ];
50603
52253
  for (const { name, root } of plugins) {
50604
- const agentsRoot = import_node_path28.default.join(root, "agents");
52254
+ const agentsRoot = import_node_path29.default.join(root, "agents");
50605
52255
  scanPluginAgentsTree(agentsRoot, name, seen, fsBlock);
50606
52256
  }
50607
52257
  return [...builtinBlock, ...fsBlock];
@@ -50611,13 +52261,13 @@ var AgentsScanner = class {
50611
52261
  // src/observer/session-observer.ts
50612
52262
  var import_node_fs29 = __toESM(require("fs"), 1);
50613
52263
  var import_node_os11 = __toESM(require("os"), 1);
50614
- var import_node_path30 = __toESM(require("path"), 1);
52264
+ var import_node_path31 = __toESM(require("path"), 1);
50615
52265
  init_claude_history();
50616
52266
 
50617
52267
  // src/observer/subagent-meta-observer.ts
50618
52268
  var import_node_fs28 = __toESM(require("fs"), 1);
50619
52269
  var import_node_os10 = __toESM(require("os"), 1);
50620
- var import_node_path29 = __toESM(require("path"), 1);
52270
+ var import_node_path30 = __toESM(require("path"), 1);
50621
52271
  init_claude_history();
50622
52272
  var META_RE = /^agent-([A-Za-z0-9_-]+)\.meta\.json$/;
50623
52273
  var SubagentMetaObserver = class {
@@ -50630,7 +52280,7 @@ var SubagentMetaObserver = class {
50630
52280
  watches = /* @__PURE__ */ new Map();
50631
52281
  // public for spec only:测试直接拼路径写假 meta.json;生产 start() 内部自己解析
50632
52282
  resolveSubagentDir(cwd, toolSessionId) {
50633
- return import_node_path29.default.join(
52283
+ return import_node_path30.default.join(
50634
52284
  this.home,
50635
52285
  ".claude",
50636
52286
  "projects",
@@ -50686,7 +52336,7 @@ var SubagentMetaObserver = class {
50686
52336
  if (!m2) return;
50687
52337
  const agentId = m2[1];
50688
52338
  if (w2.emitted.has(agentId)) return;
50689
- const file = import_node_path29.default.join(w2.dirPath, name);
52339
+ const file = import_node_path30.default.join(w2.dirPath, name);
50690
52340
  let raw;
50691
52341
  try {
50692
52342
  raw = import_node_fs28.default.readFileSync(file, "utf8");
@@ -50746,7 +52396,7 @@ var SessionObserver = class {
50746
52396
  metaObserver;
50747
52397
  resolveJsonlPath(cwd, toolSessionId, override) {
50748
52398
  if (override) return override;
50749
- return import_node_path30.default.join(this.home, ".claude", "projects", cwdToHashDir(cwd), `${toolSessionId}.jsonl`);
52399
+ return import_node_path31.default.join(this.home, ".claude", "projects", cwdToHashDir(cwd), `${toolSessionId}.jsonl`);
50750
52400
  }
50751
52401
  start(args) {
50752
52402
  this.stop(args.sessionId);
@@ -50772,10 +52422,10 @@ var SessionObserver = class {
50772
52422
  lastDeriveMs: 0
50773
52423
  };
50774
52424
  try {
50775
- import_node_fs29.default.mkdirSync(import_node_path30.default.dirname(filePath), { recursive: true });
52425
+ import_node_fs29.default.mkdirSync(import_node_path31.default.dirname(filePath), { recursive: true });
50776
52426
  } catch {
50777
52427
  }
50778
- w2.watcher = import_node_fs29.default.watch(import_node_path30.default.dirname(filePath), { persistent: false }, (_event, changedName) => {
52428
+ w2.watcher = import_node_fs29.default.watch(import_node_path31.default.dirname(filePath), { persistent: false }, (_event, changedName) => {
50779
52429
  if (!changedName || !w2.filePath.endsWith(changedName)) return;
50780
52430
  this.poll(w2);
50781
52431
  });
@@ -50872,7 +52522,7 @@ var SessionObserver = class {
50872
52522
  const now = Date.now();
50873
52523
  if (now - w2.lastRelocateScanMs < 1e3) return;
50874
52524
  w2.lastRelocateScanMs = now;
50875
- const projectsRoot = import_node_path30.default.join(this.home, ".claude", "projects");
52525
+ const projectsRoot = import_node_path31.default.join(this.home, ".claude", "projects");
50876
52526
  const found = findTranscriptByToolSessionId(projectsRoot, w2.toolSessionId);
50877
52527
  if (!found || found === w2.filePath) return;
50878
52528
  try {
@@ -50881,7 +52531,7 @@ var SessionObserver = class {
50881
52531
  }
50882
52532
  w2.filePath = found;
50883
52533
  try {
50884
- w2.watcher = import_node_fs29.default.watch(import_node_path30.default.dirname(found), { persistent: false }, (_event, changedName) => {
52534
+ w2.watcher = import_node_fs29.default.watch(import_node_path31.default.dirname(found), { persistent: false }, (_event, changedName) => {
50885
52535
  if (!changedName || !w2.filePath.endsWith(changedName)) return;
50886
52536
  this.poll(w2);
50887
52537
  });
@@ -51665,7 +53315,7 @@ async function authenticate(token, deps) {
51665
53315
 
51666
53316
  // src/legacy-cleanup.ts
51667
53317
  var fs34 = __toESM(require("fs/promises"), 1);
51668
- var path35 = __toESM(require("path"), 1);
53318
+ var path36 = __toESM(require("path"), 1);
51669
53319
  var LEGACY_FILES = [
51670
53320
  "personal-capability.json",
51671
53321
  "received-capabilities.json",
@@ -51674,7 +53324,7 @@ var LEGACY_FILES = [
51674
53324
  async function cleanupLegacyCapabilityFiles(dataDir, logger) {
51675
53325
  const removed = [];
51676
53326
  for (const name of LEGACY_FILES) {
51677
- const p2 = path35.join(dataDir, name);
53327
+ const p2 = path36.join(dataDir, name);
51678
53328
  try {
51679
53329
  await fs34.unlink(p2);
51680
53330
  removed.push(name);
@@ -51689,7 +53339,7 @@ async function cleanupLegacyCapabilityFiles(dataDir, logger) {
51689
53339
 
51690
53340
  // src/inbox/inbox-store.ts
51691
53341
  var fs35 = __toESM(require("fs"), 1);
51692
- var path36 = __toESM(require("path"), 1);
53342
+ var path37 = __toESM(require("path"), 1);
51693
53343
  var INBOX_SUBDIR = "inbox";
51694
53344
  var InboxStore = class {
51695
53345
  constructor(dataDir) {
@@ -51787,10 +53437,10 @@ var InboxStore = class {
51787
53437
  }
51788
53438
  }
51789
53439
  dirPath() {
51790
- return path36.join(this.dataDir, INBOX_SUBDIR);
53440
+ return path37.join(this.dataDir, INBOX_SUBDIR);
51791
53441
  }
51792
53442
  filePath(peerDeviceId) {
51793
- return path36.join(this.dirPath(), `${peerDeviceId}.jsonl`);
53443
+ return path37.join(this.dirPath(), `${peerDeviceId}.jsonl`);
51794
53444
  }
51795
53445
  };
51796
53446
  function parseAllLines(raw) {
@@ -51879,7 +53529,7 @@ var InboxManager = class {
51879
53529
 
51880
53530
  // src/state/contact-store.ts
51881
53531
  var fs36 = __toESM(require("fs"), 1);
51882
- var path37 = __toESM(require("path"), 1);
53532
+ var path38 = __toESM(require("path"), 1);
51883
53533
  var FILE_NAME = "contacts.json";
51884
53534
  var ContactStore = class {
51885
53535
  constructor(dataDir) {
@@ -51889,7 +53539,7 @@ var ContactStore = class {
51889
53539
  contacts = /* @__PURE__ */ new Map();
51890
53540
  load() {
51891
53541
  this.contacts.clear();
51892
- const file = path37.join(this.dataDir, FILE_NAME);
53542
+ const file = path38.join(this.dataDir, FILE_NAME);
51893
53543
  let raw;
51894
53544
  try {
51895
53545
  raw = fs36.readFileSync(file, "utf8");
@@ -51961,7 +53611,7 @@ var ContactStore = class {
51961
53611
  return true;
51962
53612
  }
51963
53613
  flush() {
51964
- const file = path37.join(this.dataDir, FILE_NAME);
53614
+ const file = path38.join(this.dataDir, FILE_NAME);
51965
53615
  const tmp = `${file}.tmp-${process.pid}-${Date.now()}`;
51966
53616
  const content = JSON.stringify(
51967
53617
  { contacts: Array.from(this.contacts.values()) },
@@ -52083,52 +53733,52 @@ async function connectRemote(args) {
52083
53733
 
52084
53734
  // src/migrations/2026-05-20-flatten-sessions.ts
52085
53735
  var fs37 = __toESM(require("fs"), 1);
52086
- var path38 = __toESM(require("path"), 1);
53736
+ var path39 = __toESM(require("path"), 1);
52087
53737
  var MIGRATION_FLAG_NAME = ".migration.v1.done";
52088
53738
  function migrateFlattenSessions(opts) {
52089
53739
  const dataDir = opts.dataDir;
52090
53740
  const now = opts.now ?? Date.now;
52091
- const sessionsDir = path38.join(dataDir, "sessions");
52092
- const flagPath = path38.join(sessionsDir, MIGRATION_FLAG_NAME);
53741
+ const sessionsDir = path39.join(dataDir, "sessions");
53742
+ const flagPath = path39.join(sessionsDir, MIGRATION_FLAG_NAME);
52093
53743
  if (existsSync3(flagPath)) {
52094
53744
  return { skipped: true, flagWritten: false, movedBare: 0, movedVmOwner: 0, archivedListener: 0 };
52095
53745
  }
52096
53746
  let movedBare = 0;
52097
53747
  let movedVmOwner = 0;
52098
53748
  let archivedListener = 0;
52099
- const defaultDir = path38.join(sessionsDir, "default");
53749
+ const defaultDir = path39.join(sessionsDir, "default");
52100
53750
  if (existsSync3(defaultDir)) {
52101
53751
  for (const entry of readdirSafe(defaultDir)) {
52102
53752
  if (!entry.endsWith(".json")) continue;
52103
- const src = path38.join(defaultDir, entry);
52104
- const dst = path38.join(sessionsDir, entry);
53753
+ const src = path39.join(defaultDir, entry);
53754
+ const dst = path39.join(sessionsDir, entry);
52105
53755
  fs37.renameSync(src, dst);
52106
53756
  movedBare += 1;
52107
53757
  }
52108
53758
  rmdirIfEmpty(defaultDir);
52109
53759
  }
52110
53760
  for (const pid of readdirSafe(sessionsDir)) {
52111
- const personaDir = path38.join(sessionsDir, pid);
53761
+ const personaDir = path39.join(sessionsDir, pid);
52112
53762
  if (!isDir(personaDir)) continue;
52113
53763
  if (pid === "default") continue;
52114
- const ownerSrc = path38.join(personaDir, "owner");
53764
+ const ownerSrc = path39.join(personaDir, "owner");
52115
53765
  if (existsSync3(ownerSrc) && isDir(ownerSrc)) {
52116
- const ownerDst = path38.join(dataDir, "personas", pid, ".clawd", "sessions", "owner");
53766
+ const ownerDst = path39.join(dataDir, "personas", pid, ".clawd", "sessions", "owner");
52117
53767
  fs37.mkdirSync(ownerDst, { recursive: true });
52118
53768
  for (const file of readdirSafe(ownerSrc)) {
52119
53769
  if (!file.endsWith(".json")) continue;
52120
- fs37.renameSync(path38.join(ownerSrc, file), path38.join(ownerDst, file));
53770
+ fs37.renameSync(path39.join(ownerSrc, file), path39.join(ownerDst, file));
52121
53771
  movedVmOwner += 1;
52122
53772
  }
52123
53773
  rmdirIfEmpty(ownerSrc);
52124
53774
  }
52125
- const listenerSrc = path38.join(personaDir, "listener");
53775
+ const listenerSrc = path39.join(personaDir, "listener");
52126
53776
  if (existsSync3(listenerSrc) && isDir(listenerSrc)) {
52127
- const archiveDst = path38.join(dataDir, ".legacy", `listener-${pid}`);
53777
+ const archiveDst = path39.join(dataDir, ".legacy", `listener-${pid}`);
52128
53778
  fs37.mkdirSync(archiveDst, { recursive: true });
52129
53779
  for (const file of readdirSafe(listenerSrc)) {
52130
53780
  if (!file.endsWith(".json")) continue;
52131
- fs37.renameSync(path38.join(listenerSrc, file), path38.join(archiveDst, file));
53781
+ fs37.renameSync(path39.join(listenerSrc, file), path39.join(archiveDst, file));
52132
53782
  archivedListener += 1;
52133
53783
  }
52134
53784
  rmdirIfEmpty(listenerSrc);
@@ -52176,10 +53826,10 @@ function rmdirIfEmpty(p2) {
52176
53826
 
52177
53827
  // src/transport/http-router.ts
52178
53828
  var import_node_fs31 = __toESM(require("fs"), 1);
52179
- var import_node_path34 = __toESM(require("path"), 1);
53829
+ var import_node_path35 = __toESM(require("path"), 1);
52180
53830
 
52181
53831
  // src/attachment/mime.ts
52182
- var import_node_path31 = __toESM(require("path"), 1);
53832
+ var import_node_path32 = __toESM(require("path"), 1);
52183
53833
  var TEXT_PLAIN = "text/plain; charset=utf-8";
52184
53834
  var EXT_TO_NATIVE_MIME = {
52185
53835
  // 图片
@@ -52286,7 +53936,7 @@ var TEXT_EXTENSIONS = /* @__PURE__ */ new Set([
52286
53936
  ".mk"
52287
53937
  ]);
52288
53938
  function lookupMime(filePathOrName) {
52289
- const ext = import_node_path31.default.extname(filePathOrName).toLowerCase();
53939
+ const ext = import_node_path32.default.extname(filePathOrName).toLowerCase();
52290
53940
  if (EXT_TO_NATIVE_MIME[ext]) return EXT_TO_NATIVE_MIME[ext];
52291
53941
  if (TEXT_EXTENSIONS.has(ext)) return TEXT_PLAIN;
52292
53942
  return "application/octet-stream";
@@ -52357,7 +54007,7 @@ function verifySignedUrl(secret, absPath, eRaw, s, now = Date.now) {
52357
54007
 
52358
54008
  // src/attachment/upload.ts
52359
54009
  var import_node_fs30 = __toESM(require("fs"), 1);
52360
- var import_node_path32 = __toESM(require("path"), 1);
54010
+ var import_node_path33 = __toESM(require("path"), 1);
52361
54011
  var import_node_crypto8 = __toESM(require("crypto"), 1);
52362
54012
  var import_promises3 = require("stream/promises");
52363
54013
  var UploadError = class extends Error {
@@ -52369,14 +54019,14 @@ var UploadError = class extends Error {
52369
54019
  code;
52370
54020
  };
52371
54021
  function assertValidFileName(fileName) {
52372
- if (fileName.length === 0 || fileName === "." || fileName === ".." || fileName.startsWith(".") || fileName.includes("/") || fileName.includes("\\") || fileName !== import_node_path32.default.basename(fileName)) {
54022
+ if (fileName.length === 0 || fileName === "." || fileName === ".." || fileName.startsWith(".") || fileName.includes("/") || fileName.includes("\\") || fileName !== import_node_path33.default.basename(fileName)) {
52373
54023
  throw new UploadError("INVALID_FILENAME", `fileName must be a plain basename, got: ${fileName}`);
52374
54024
  }
52375
54025
  }
52376
54026
  var HASH_PREFIX_LEN = 16;
52377
54027
  async function writeUploadedAttachment(args) {
52378
54028
  assertValidFileName(args.fileName);
52379
- const attachmentsRoot = import_node_path32.default.join(args.sessionDir, ".attachments");
54029
+ const attachmentsRoot = import_node_path33.default.join(args.sessionDir, ".attachments");
52380
54030
  try {
52381
54031
  import_node_fs30.default.mkdirSync(attachmentsRoot, { recursive: true });
52382
54032
  } catch (err) {
@@ -52384,7 +54034,7 @@ async function writeUploadedAttachment(args) {
52384
54034
  }
52385
54035
  const hasher = import_node_crypto8.default.createHash("sha256");
52386
54036
  let actualSize = 0;
52387
- const tmpPath = import_node_path32.default.join(
54037
+ const tmpPath = import_node_path33.default.join(
52388
54038
  attachmentsRoot,
52389
54039
  `.upload-${process.pid}-${Date.now()}-${import_node_crypto8.default.randomBytes(4).toString("hex")}`
52390
54040
  );
@@ -52419,7 +54069,7 @@ async function writeUploadedAttachment(args) {
52419
54069
  );
52420
54070
  }
52421
54071
  const attachmentId = hasher.digest("hex").slice(0, HASH_PREFIX_LEN);
52422
- const hashDir = import_node_path32.default.join(attachmentsRoot, attachmentId);
54072
+ const hashDir = import_node_path33.default.join(attachmentsRoot, attachmentId);
52423
54073
  let finalFileName;
52424
54074
  let hashDirExists = false;
52425
54075
  try {
@@ -52437,7 +54087,7 @@ async function writeUploadedAttachment(args) {
52437
54087
  try {
52438
54088
  import_node_fs30.default.mkdirSync(hashDir, { recursive: true });
52439
54089
  finalFileName = args.fileName;
52440
- import_node_fs30.default.renameSync(tmpPath, import_node_path32.default.join(hashDir, finalFileName));
54090
+ import_node_fs30.default.renameSync(tmpPath, import_node_path33.default.join(hashDir, finalFileName));
52441
54091
  } catch (err) {
52442
54092
  try {
52443
54093
  import_node_fs30.default.unlinkSync(tmpPath);
@@ -52446,8 +54096,8 @@ async function writeUploadedAttachment(args) {
52446
54096
  throw new UploadError("STORAGE_ERROR", `rename failed: ${err.message}`);
52447
54097
  }
52448
54098
  }
52449
- const absPath = import_node_path32.default.join(hashDir, finalFileName);
52450
- const relPath = import_node_path32.default.relative(args.sessionDir, absPath);
54099
+ const absPath = import_node_path33.default.join(hashDir, finalFileName);
54100
+ const relPath = import_node_path33.default.relative(args.sessionDir, absPath);
52451
54101
  args.groupFileStore.upsert(args.scope, args.sessionId, {
52452
54102
  relPath: absPath,
52453
54103
  // 存绝对路径,与现有 agent 入清单的形态一致(attachment.ts:144 双形态兼容)
@@ -52461,7 +54111,7 @@ async function writeUploadedAttachment(args) {
52461
54111
 
52462
54112
  // src/extension/import.ts
52463
54113
  var import_promises4 = __toESM(require("fs/promises"), 1);
52464
- var import_node_path33 = __toESM(require("path"), 1);
54114
+ var import_node_path34 = __toESM(require("path"), 1);
52465
54115
  var import_node_os12 = __toESM(require("os"), 1);
52466
54116
  var import_jszip = __toESM(require_lib3(), 1);
52467
54117
  var ImportError = class extends Error {
@@ -52479,7 +54129,7 @@ async function importZip(buf, root) {
52479
54129
  throw new ImportError("ZIP_INVALID", `failed to load zip: ${e.message}`);
52480
54130
  }
52481
54131
  for (const name of Object.keys(zip.files)) {
52482
- if (name.includes("..") || name.startsWith("/") || import_node_path33.default.isAbsolute(name)) {
54132
+ if (name.includes("..") || name.startsWith("/") || import_node_path34.default.isAbsolute(name)) {
52483
54133
  throw new ImportError("ZIP_INVALID", `unsafe zip entry path: ${name}`);
52484
54134
  }
52485
54135
  }
@@ -52512,7 +54162,7 @@ async function importZip(buf, root) {
52512
54162
  );
52513
54163
  }
52514
54164
  }
52515
- const destDir = import_node_path33.default.join(root, manifest.id);
54165
+ const destDir = import_node_path34.default.join(root, manifest.id);
52516
54166
  let destExists = false;
52517
54167
  try {
52518
54168
  await import_promises4.default.access(destDir);
@@ -52522,15 +54172,15 @@ async function importZip(buf, root) {
52522
54172
  if (destExists) {
52523
54173
  throw new ImportError("ALREADY_EXISTS", `extension ${manifest.id} already installed`);
52524
54174
  }
52525
- const stage = await import_promises4.default.mkdtemp(import_node_path33.default.join(import_node_os12.default.tmpdir(), `clawd-ext-stage-${manifest.id}-`));
54175
+ const stage = await import_promises4.default.mkdtemp(import_node_path34.default.join(import_node_os12.default.tmpdir(), `clawd-ext-stage-${manifest.id}-`));
52526
54176
  try {
52527
54177
  for (const [name, entry] of Object.entries(zip.files)) {
52528
- const dest = import_node_path33.default.join(stage, name);
54178
+ const dest = import_node_path34.default.join(stage, name);
52529
54179
  if (entry.dir) {
52530
54180
  await import_promises4.default.mkdir(dest, { recursive: true });
52531
54181
  continue;
52532
54182
  }
52533
- await import_promises4.default.mkdir(import_node_path33.default.dirname(dest), { recursive: true });
54183
+ await import_promises4.default.mkdir(import_node_path34.default.dirname(dest), { recursive: true });
52534
54184
  const content = await entry.async("nodebuffer");
52535
54185
  await import_promises4.default.writeFile(dest, content);
52536
54186
  }
@@ -52560,7 +54210,7 @@ var SHARE_UI_ASSET_MIME = {
52560
54210
  ".wasm": "application/wasm"
52561
54211
  };
52562
54212
  function shareUiAssetMime(filePath) {
52563
- const ext = import_node_path34.default.extname(filePath).toLowerCase();
54213
+ const ext = import_node_path35.default.extname(filePath).toLowerCase();
52564
54214
  return SHARE_UI_ASSET_MIME[ext] ?? lookupMime(filePath);
52565
54215
  }
52566
54216
  var AUTHED_RPC_ROUTE_PREFIX = "/rpc/";
@@ -52641,7 +54291,7 @@ function isValidUploadFileName(fileName) {
52641
54291
  if (fileName === "." || fileName === "..") return false;
52642
54292
  if (fileName.startsWith(".")) return false;
52643
54293
  if (fileName.includes("/") || fileName.includes("\\")) return false;
52644
- return fileName === import_node_path34.default.basename(fileName);
54294
+ return fileName === import_node_path35.default.basename(fileName);
52645
54295
  }
52646
54296
  function createHttpRouter(deps) {
52647
54297
  return async (req, res) => {
@@ -52858,7 +54508,7 @@ function createHttpRouter(deps) {
52858
54508
  sendHtml(res, statusByCode[r.code], loader.renderErrorHtml(r.code, msgByCode[r.code]));
52859
54509
  return true;
52860
54510
  }
52861
- sendHtml(res, 200, loader.renderViewerHtml(import_node_path34.default.basename(r.absPath)));
54511
+ sendHtml(res, 200, loader.renderViewerHtml(import_node_path35.default.basename(r.absPath)));
52862
54512
  return true;
52863
54513
  }
52864
54514
  const ctx = deps.authResolver.resolveFromHeader(
@@ -52979,7 +54629,7 @@ function createHttpRouter(deps) {
52979
54629
  return true;
52980
54630
  }
52981
54631
  let absPath;
52982
- if (import_node_path34.default.isAbsolute(pathParam)) {
54632
+ if (import_node_path35.default.isAbsolute(pathParam)) {
52983
54633
  absPath = pathParam;
52984
54634
  } else if (deps.sessionStore) {
52985
54635
  const file = deps.sessionStore.read(sid);
@@ -52987,7 +54637,7 @@ function createHttpRouter(deps) {
52987
54637
  sendJson(res, 404, { code: "NOT_FOUND", message: `session ${sid} not found` });
52988
54638
  return true;
52989
54639
  }
52990
- absPath = import_node_path34.default.join(file.cwd, pathParam);
54640
+ absPath = import_node_path35.default.join(file.cwd, pathParam);
52991
54641
  } else {
52992
54642
  sendJson(res, 501, withCtx(ctx, { code: "NOT_IMPLEMENTED", message: "sessionStore not wired" }));
52993
54643
  return true;
@@ -53089,7 +54739,7 @@ function streamFile(res, absPath, logger) {
53089
54739
  return;
53090
54740
  }
53091
54741
  const mime = lookupMime(absPath);
53092
- const basename = import_node_path34.default.basename(absPath);
54742
+ const basename = import_node_path35.default.basename(absPath);
53093
54743
  res.writeHead(200, {
53094
54744
  "Content-Type": mime,
53095
54745
  "Content-Length": String(stat.size),
@@ -53107,7 +54757,7 @@ function streamFile(res, absPath, logger) {
53107
54757
 
53108
54758
  // src/attachment/gc.ts
53109
54759
  var import_node_fs32 = __toESM(require("fs"), 1);
53110
- var import_node_path35 = __toESM(require("path"), 1);
54760
+ var import_node_path36 = __toESM(require("path"), 1);
53111
54761
  var DEFAULT_TTL_MS = 30 * 24 * 3600 * 1e3;
53112
54762
  function runAttachmentGc(args) {
53113
54763
  const now = (args.now ?? Date.now)();
@@ -53116,17 +54766,17 @@ function runAttachmentGc(args) {
53116
54766
  for (const { scope, sessionId } of args.sessionScopes) {
53117
54767
  for (const entry of args.groupFileStore.list(scope, sessionId)) {
53118
54768
  if (entry.stale) continue;
53119
- if (import_node_path35.default.isAbsolute(entry.relPath)) liveAbs.add(entry.relPath);
54769
+ if (import_node_path36.default.isAbsolute(entry.relPath)) liveAbs.add(entry.relPath);
53120
54770
  }
53121
54771
  }
53122
54772
  for (const { scope, sessionId } of args.sessionScopes) {
53123
- const sessionDir = args.getSessionCwd?.(sessionId) ?? import_node_path35.default.join(
54773
+ const sessionDir = args.getSessionCwd?.(sessionId) ?? import_node_path36.default.join(
53124
54774
  args.dataDir,
53125
54775
  "sessions",
53126
54776
  ...scopeSubPath(scope).map(safeFileName),
53127
54777
  safeFileName(sessionId)
53128
54778
  );
53129
- const attRoot = import_node_path35.default.join(sessionDir, ".attachments");
54779
+ const attRoot = import_node_path36.default.join(sessionDir, ".attachments");
53130
54780
  let hashDirs;
53131
54781
  try {
53132
54782
  hashDirs = import_node_fs32.default.readdirSync(attRoot);
@@ -53136,7 +54786,7 @@ function runAttachmentGc(args) {
53136
54786
  continue;
53137
54787
  }
53138
54788
  for (const hashDir of hashDirs) {
53139
- const hashDirAbs = import_node_path35.default.join(attRoot, hashDir);
54789
+ const hashDirAbs = import_node_path36.default.join(attRoot, hashDir);
53140
54790
  let files;
53141
54791
  try {
53142
54792
  files = import_node_fs32.default.readdirSync(hashDirAbs);
@@ -53144,7 +54794,7 @@ function runAttachmentGc(args) {
53144
54794
  continue;
53145
54795
  }
53146
54796
  for (const name of files) {
53147
- const file = import_node_path35.default.join(hashDirAbs, name);
54797
+ const file = import_node_path36.default.join(hashDirAbs, name);
53148
54798
  let stat;
53149
54799
  try {
53150
54800
  stat = import_node_fs32.default.statSync(file);
@@ -53175,7 +54825,7 @@ function runAttachmentGc(args) {
53175
54825
 
53176
54826
  // src/attachment/group.ts
53177
54827
  var import_node_fs33 = __toESM(require("fs"), 1);
53178
- var import_node_path36 = __toESM(require("path"), 1);
54828
+ var import_node_path37 = __toESM(require("path"), 1);
53179
54829
  var import_node_crypto9 = __toESM(require("crypto"), 1);
53180
54830
  init_protocol();
53181
54831
  var GroupFileStore = class {
@@ -53187,11 +54837,11 @@ var GroupFileStore = class {
53187
54837
  this.logger = opts.logger;
53188
54838
  }
53189
54839
  rootForScope(scope) {
53190
- return import_node_path36.default.join(this.dataDir, "sessions", ...scopeSubPath(scope).map(safeFileName));
54840
+ return import_node_path37.default.join(this.dataDir, "sessions", ...scopeSubPath(scope).map(safeFileName));
53191
54841
  }
53192
54842
  /** 与 SessionStore.filePath 平级,扩展名 .group-files.json */
53193
54843
  filePath(scope, sessionId) {
53194
- return import_node_path36.default.join(this.rootForScope(scope), `${safeFileName(sessionId)}.group-files.json`);
54844
+ return import_node_path37.default.join(this.rootForScope(scope), `${safeFileName(sessionId)}.group-files.json`);
53195
54845
  }
53196
54846
  cacheKey(scope, sessionId) {
53197
54847
  return scope.kind === "default" ? `default::${sessionId}` : `persona:${scope.personaId}:${scope.mode}::${sessionId}`;
@@ -53226,7 +54876,7 @@ var GroupFileStore = class {
53226
54876
  }
53227
54877
  writeFile(scope, sessionId, entries) {
53228
54878
  const file = this.filePath(scope, sessionId);
53229
- import_node_fs33.default.mkdirSync(import_node_path36.default.dirname(file), { recursive: true });
54879
+ import_node_fs33.default.mkdirSync(import_node_path37.default.dirname(file), { recursive: true });
53230
54880
  const tmp = `${file}.tmp-${process.pid}-${Date.now()}`;
53231
54881
  import_node_fs33.default.writeFileSync(tmp, JSON.stringify(entries, null, 2), { mode: 384 });
53232
54882
  import_node_fs33.default.renameSync(tmp, file);
@@ -53316,9 +54966,9 @@ var GroupFileStore = class {
53316
54966
 
53317
54967
  // src/discovery/state-file.ts
53318
54968
  var import_node_fs34 = __toESM(require("fs"), 1);
53319
- var import_node_path37 = __toESM(require("path"), 1);
54969
+ var import_node_path38 = __toESM(require("path"), 1);
53320
54970
  function defaultStateFilePath(dataDir) {
53321
- return import_node_path37.default.join(dataDir, "state.json");
54971
+ return import_node_path38.default.join(dataDir, "state.json");
53322
54972
  }
53323
54973
  function isPidAlive(pid) {
53324
54974
  if (!Number.isFinite(pid) || pid <= 0) return false;
@@ -53354,7 +55004,7 @@ var StateFileManager = class {
53354
55004
  return { status: "stale", existing };
53355
55005
  }
53356
55006
  write(state) {
53357
- import_node_fs34.default.mkdirSync(import_node_path37.default.dirname(this.file), { recursive: true });
55007
+ import_node_fs34.default.mkdirSync(import_node_path38.default.dirname(this.file), { recursive: true });
53358
55008
  const tmp = `${this.file}.tmp.${process.pid}.${Date.now()}`;
53359
55009
  import_node_fs34.default.writeFileSync(tmp, JSON.stringify(state, null, 2), { mode: 384 });
53360
55010
  import_node_fs34.default.renameSync(tmp, this.file);
@@ -53382,13 +55032,13 @@ function readSpawnedByDesktopFromEnv(env = process.env) {
53382
55032
 
53383
55033
  // src/tunnel/tunnel-manager.ts
53384
55034
  var import_node_fs38 = __toESM(require("fs"), 1);
53385
- var import_node_path41 = __toESM(require("path"), 1);
55035
+ var import_node_path42 = __toESM(require("path"), 1);
53386
55036
  var import_node_crypto10 = __toESM(require("crypto"), 1);
53387
55037
  var import_node_child_process10 = require("child_process");
53388
55038
 
53389
55039
  // src/tunnel/tunnel-store.ts
53390
55040
  var import_node_fs35 = __toESM(require("fs"), 1);
53391
- var import_node_path38 = __toESM(require("path"), 1);
55041
+ var import_node_path39 = __toESM(require("path"), 1);
53392
55042
  var TunnelStore = class {
53393
55043
  constructor(filePath) {
53394
55044
  this.filePath = filePath;
@@ -53407,7 +55057,7 @@ var TunnelStore = class {
53407
55057
  }
53408
55058
  }
53409
55059
  async set(v2) {
53410
- const dir = import_node_path38.default.dirname(this.filePath);
55060
+ const dir = import_node_path39.default.dirname(this.filePath);
53411
55061
  await import_node_fs35.default.promises.mkdir(dir, { recursive: true });
53412
55062
  const data = JSON.stringify(v2, null, 2);
53413
55063
  const tmp = `${this.filePath}.tmp.${process.pid}.${Date.now()}`;
@@ -53519,7 +55169,7 @@ function escape(v2) {
53519
55169
  // src/tunnel/frpc-binary.ts
53520
55170
  var import_node_fs36 = __toESM(require("fs"), 1);
53521
55171
  var import_node_os13 = __toESM(require("os"), 1);
53522
- var import_node_path39 = __toESM(require("path"), 1);
55172
+ var import_node_path40 = __toESM(require("path"), 1);
53523
55173
  var import_node_child_process8 = require("child_process");
53524
55174
  var import_node_stream3 = require("stream");
53525
55175
  var import_promises5 = require("stream/promises");
@@ -53558,13 +55208,13 @@ async function ensureFrpcBinary(opts) {
53558
55208
  }
53559
55209
  const version2 = opts.version ?? FRPC_VERSION;
53560
55210
  const platform = opts.platform ?? detectPlatform();
53561
- const binDir = import_node_path39.default.join(opts.dataDir, "bin");
55211
+ const binDir = import_node_path40.default.join(opts.dataDir, "bin");
53562
55212
  import_node_fs36.default.mkdirSync(binDir, { recursive: true });
53563
55213
  cleanupStaleArtifacts(binDir);
53564
- const stableBin = import_node_path39.default.join(binDir, "frpc");
55214
+ const stableBin = import_node_path40.default.join(binDir, "frpc");
53565
55215
  if (import_node_fs36.default.existsSync(stableBin)) return stableBin;
53566
55216
  const partialBin = `${stableBin}.partial`;
53567
- const tarballPath = import_node_path39.default.join(binDir, `frp_${version2}_${platform.os}_${platform.arch}.tar.gz.partial`);
55217
+ const tarballPath = import_node_path40.default.join(binDir, `frp_${version2}_${platform.os}_${platform.arch}.tar.gz.partial`);
53568
55218
  try {
53569
55219
  const url = frpcDownloadUrl(version2, platform);
53570
55220
  await downloadToFile(url, tarballPath, opts.fetchImpl);
@@ -53590,7 +55240,7 @@ function cleanupStaleArtifacts(binDir) {
53590
55240
  }
53591
55241
  for (const name of entries) {
53592
55242
  if (name.endsWith(".partial") || name.startsWith("extract-")) {
53593
- const full = import_node_path39.default.join(binDir, name);
55243
+ const full = import_node_path40.default.join(binDir, name);
53594
55244
  try {
53595
55245
  import_node_fs36.default.rmSync(full, { recursive: true, force: true });
53596
55246
  } catch {
@@ -53616,7 +55266,7 @@ async function downloadToFile(url, dest, fetchImpl) {
53616
55266
  await (0, import_promises5.pipeline)(nodeStream, out);
53617
55267
  }
53618
55268
  async function extractFrpcFromTarball(tarball, binDir, version2, platform, destBin) {
53619
- const work = import_node_path39.default.join(binDir, `extract-${process.pid}-${Date.now()}`);
55269
+ const work = import_node_path40.default.join(binDir, `extract-${process.pid}-${Date.now()}`);
53620
55270
  import_node_fs36.default.mkdirSync(work, { recursive: true });
53621
55271
  try {
53622
55272
  await new Promise((resolve6, reject) => {
@@ -53625,7 +55275,7 @@ async function extractFrpcFromTarball(tarball, binDir, version2, platform, destB
53625
55275
  proc.on("exit", (code) => code === 0 ? resolve6() : reject(new Error(`tar exited ${code}`)));
53626
55276
  });
53627
55277
  const dirName = `frp_${version2}_${platform.os}_${platform.arch}`;
53628
- const src = import_node_path39.default.join(work, dirName, "frpc");
55278
+ const src = import_node_path40.default.join(work, dirName, "frpc");
53629
55279
  if (!import_node_fs36.default.existsSync(src)) {
53630
55280
  throw new Error(`frpc not found inside tarball at ${src}`);
53631
55281
  }
@@ -53637,10 +55287,10 @@ async function extractFrpcFromTarball(tarball, binDir, version2, platform, destB
53637
55287
 
53638
55288
  // src/tunnel/frpc-process.ts
53639
55289
  var import_node_fs37 = __toESM(require("fs"), 1);
53640
- var import_node_path40 = __toESM(require("path"), 1);
55290
+ var import_node_path41 = __toESM(require("path"), 1);
53641
55291
  var import_node_child_process9 = require("child_process");
53642
55292
  function frpcPidFilePath(dataDir) {
53643
- return import_node_path40.default.join(dataDir, "frpc.pid");
55293
+ return import_node_path41.default.join(dataDir, "frpc.pid");
53644
55294
  }
53645
55295
  function writeFrpcPid(dataDir, pid) {
53646
55296
  try {
@@ -53682,7 +55332,7 @@ function defaultSleep2(ms) {
53682
55332
  }
53683
55333
  async function killStaleFrpc(deps) {
53684
55334
  const pidFile = frpcPidFilePath(deps.dataDir);
53685
- const tomlPath = import_node_path40.default.join(deps.dataDir, "frpc.toml");
55335
+ const tomlPath = import_node_path41.default.join(deps.dataDir, "frpc.toml");
53686
55336
  const readPidFile = deps.readPidFileImpl ?? defaultReadPidFile;
53687
55337
  const isAlive = deps.isPidAliveImpl ?? defaultIsPidAlive;
53688
55338
  const killPid = deps.killPidImpl ?? defaultKillPid;
@@ -53754,7 +55404,7 @@ var DEFAULT_TUNNEL_TTL_MS = 7 * 24 * 60 * 60 * 1e3;
53754
55404
  var TunnelManager = class {
53755
55405
  constructor(deps) {
53756
55406
  this.deps = deps;
53757
- this.store = deps.store ?? new TunnelStore(import_node_path41.default.join(deps.dataDir, "tunnel.json"));
55407
+ this.store = deps.store ?? new TunnelStore(import_node_path42.default.join(deps.dataDir, "tunnel.json"));
53758
55408
  this.ttlMs = deps.ttlMs ?? DEFAULT_TUNNEL_TTL_MS;
53759
55409
  this.startupTimeoutMs = deps.startupTimeoutMs ?? 15e3;
53760
55410
  }
@@ -53881,7 +55531,7 @@ var TunnelManager = class {
53881
55531
  dataDir: this.deps.dataDir,
53882
55532
  override: this.deps.frpcBinaryOverride ?? void 0
53883
55533
  });
53884
- const tomlPath = import_node_path41.default.join(this.deps.dataDir, "frpc.toml");
55534
+ const tomlPath = import_node_path42.default.join(this.deps.dataDir, "frpc.toml");
53885
55535
  const proxyName = `clawd-${t.subdomain}-${localPort}-${import_node_crypto10.default.randomBytes(3).toString("hex")}`;
53886
55536
  const toml = buildFrpcToml({
53887
55537
  serverAddr: t.frpsHost,
@@ -53896,9 +55546,9 @@ var TunnelManager = class {
53896
55546
  const proc = (this.deps.spawnImpl ?? import_node_child_process10.spawn)(frpcBin, ["-c", tomlPath], {
53897
55547
  stdio: ["ignore", "pipe", "pipe"]
53898
55548
  });
53899
- const logDir = import_node_path41.default.join(this.deps.dataDir, "log");
55549
+ const logDir = import_node_path42.default.join(this.deps.dataDir, "log");
53900
55550
  import_node_fs38.default.mkdirSync(logDir, { recursive: true });
53901
- const logFilePath = import_node_path41.default.join(logDir, "frpc.log");
55551
+ const logFilePath = import_node_path42.default.join(logDir, "frpc.log");
53902
55552
  const logStream = import_node_fs38.default.createWriteStream(logFilePath, { flags: "a", mode: 384 });
53903
55553
  logStream.on("error", () => {
53904
55554
  });
@@ -53982,15 +55632,15 @@ async function waitForFrpcReady(proc, timeoutMs) {
53982
55632
 
53983
55633
  // src/tunnel/device-key.ts
53984
55634
  var import_node_os14 = __toESM(require("os"), 1);
53985
- var import_node_path42 = __toESM(require("path"), 1);
55635
+ var import_node_path43 = __toESM(require("path"), 1);
53986
55636
  var import_node_crypto11 = __toESM(require("crypto"), 1);
53987
55637
  var DERIVE_SALT = "clawd-tunnel-device-v1";
53988
55638
  function deriveStableDeviceKey(opts = {}) {
53989
55639
  const hostname = opts.hostname ?? import_node_os14.default.hostname();
53990
55640
  const uid = opts.uid ?? (typeof import_node_os14.default.userInfo === "function" ? import_node_os14.default.userInfo().uid : 0);
53991
55641
  const home = opts.home ?? import_node_os14.default.homedir();
53992
- const defaultDataDir = import_node_path42.default.resolve(import_node_path42.default.join(home, ".clawd"));
53993
- const normalizedDataDir = opts.dataDir ? import_node_path42.default.resolve(opts.dataDir) : null;
55642
+ const defaultDataDir = import_node_path43.default.resolve(import_node_path43.default.join(home, ".clawd"));
55643
+ const normalizedDataDir = opts.dataDir ? import_node_path43.default.resolve(opts.dataDir) : null;
53994
55644
  const isDefaultDir = normalizedDataDir == null || normalizedDataDir === defaultDataDir;
53995
55645
  const input = isDefaultDir ? `${hostname}::${uid}` : `${hostname}::${uid}::${normalizedDataDir}`;
53996
55646
  return import_node_crypto11.default.createHmac("sha256", DERIVE_SALT).update(input).digest("hex").slice(0, 32);
@@ -53998,11 +55648,11 @@ function deriveStableDeviceKey(opts = {}) {
53998
55648
 
53999
55649
  // src/auth-store.ts
54000
55650
  var import_node_fs39 = __toESM(require("fs"), 1);
54001
- var import_node_path43 = __toESM(require("path"), 1);
55651
+ var import_node_path44 = __toESM(require("path"), 1);
54002
55652
  var import_node_crypto12 = __toESM(require("crypto"), 1);
54003
55653
  var AUTH_FILE_NAME = "auth.json";
54004
55654
  function authFilePath(dataDir) {
54005
- return import_node_path43.default.join(dataDir, AUTH_FILE_NAME);
55655
+ return import_node_path44.default.join(dataDir, AUTH_FILE_NAME);
54006
55656
  }
54007
55657
  function loadOrCreateAuthFile(opts) {
54008
55658
  const file = authFilePath(opts.dataDir);
@@ -54054,7 +55704,7 @@ function readAuthFile(file) {
54054
55704
  }
54055
55705
  }
54056
55706
  function writeAuthFile(file, content) {
54057
- import_node_fs39.default.mkdirSync(import_node_path43.default.dirname(file), { recursive: true });
55707
+ import_node_fs39.default.mkdirSync(import_node_path44.default.dirname(file), { recursive: true });
54058
55708
  import_node_fs39.default.writeFileSync(file, JSON.stringify(content, null, 2), { mode: 384 });
54059
55709
  try {
54060
55710
  import_node_fs39.default.chmodSync(file, 384);
@@ -54065,11 +55715,11 @@ function writeAuthFile(file, content) {
54065
55715
  // src/owner-profile.ts
54066
55716
  var import_node_fs40 = __toESM(require("fs"), 1);
54067
55717
  var import_node_os15 = __toESM(require("os"), 1);
54068
- var import_node_path44 = __toESM(require("path"), 1);
55718
+ var import_node_path45 = __toESM(require("path"), 1);
54069
55719
  var PROFILE_FILENAME = "profile.json";
54070
55720
  function loadOwnerDisplayName(dataDir) {
54071
55721
  const fallback = import_node_os15.default.userInfo().username;
54072
- const profilePath = import_node_path44.default.join(dataDir, PROFILE_FILENAME);
55722
+ const profilePath = import_node_path45.default.join(dataDir, PROFILE_FILENAME);
54073
55723
  let raw;
54074
55724
  try {
54075
55725
  raw = import_node_fs40.default.readFileSync(profilePath, "utf8");
@@ -54096,12 +55746,12 @@ function loadOwnerDisplayName(dataDir) {
54096
55746
 
54097
55747
  // src/feishu-auth/owner-identity-store.ts
54098
55748
  var import_node_fs41 = __toESM(require("fs"), 1);
54099
- var import_node_path45 = __toESM(require("path"), 1);
55749
+ var import_node_path46 = __toESM(require("path"), 1);
54100
55750
  var OWNER_IDENTITY_FILE_NAME = "owner-identity.json";
54101
55751
  var OwnerIdentityStore = class {
54102
55752
  file;
54103
55753
  constructor(dataDir) {
54104
- this.file = import_node_path45.default.join(dataDir, OWNER_IDENTITY_FILE_NAME);
55754
+ this.file = import_node_path46.default.join(dataDir, OWNER_IDENTITY_FILE_NAME);
54105
55755
  }
54106
55756
  read() {
54107
55757
  let raw;
@@ -54134,7 +55784,7 @@ var OwnerIdentityStore = class {
54134
55784
  };
54135
55785
  }
54136
55786
  write(record) {
54137
- import_node_fs41.default.mkdirSync(import_node_path45.default.dirname(this.file), { recursive: true });
55787
+ import_node_fs41.default.mkdirSync(import_node_path46.default.dirname(this.file), { recursive: true });
54138
55788
  import_node_fs41.default.writeFileSync(this.file, JSON.stringify(record, null, 2), { mode: 384 });
54139
55789
  try {
54140
55790
  import_node_fs41.default.chmodSync(this.file, 384);
@@ -54280,9 +55930,9 @@ var CentralClientError = class extends Error {
54280
55930
  code;
54281
55931
  cause;
54282
55932
  };
54283
- async function centralRequest(opts, path76, init) {
55933
+ async function centralRequest(opts, path77, init) {
54284
55934
  const f = opts.fetchImpl ?? globalThis.fetch;
54285
- const url = `${opts.api.replace(/\/+$/, "")}${path76}`;
55935
+ const url = `${opts.api.replace(/\/+$/, "")}${path77}`;
54286
55936
  const ctrl = new AbortController();
54287
55937
  const timer = setTimeout(() => ctrl.abort(), opts.timeoutMs ?? 15e3);
54288
55938
  let res;
@@ -54477,7 +56127,7 @@ function verifyConnectToken(args) {
54477
56127
 
54478
56128
  // src/feishu-auth/server-key.ts
54479
56129
  var fs51 = __toESM(require("fs"), 1);
54480
- var path54 = __toESM(require("path"), 1);
56130
+ var path55 = __toESM(require("path"), 1);
54481
56131
  var FILE_NAME2 = "server-signing-key.json";
54482
56132
  var ServerKeyStore = class {
54483
56133
  constructor(dataDir) {
@@ -54485,7 +56135,7 @@ var ServerKeyStore = class {
54485
56135
  }
54486
56136
  dataDir;
54487
56137
  filePath() {
54488
- return path54.join(this.dataDir, FILE_NAME2);
56138
+ return path55.join(this.dataDir, FILE_NAME2);
54489
56139
  }
54490
56140
  /** 读缓存的公钥;无缓存 / 损坏 → null(调用方决定是否触发拉取) */
54491
56141
  read() {
@@ -54525,7 +56175,7 @@ init_protocol();
54525
56175
  // src/session/fork.ts
54526
56176
  var import_node_fs42 = __toESM(require("fs"), 1);
54527
56177
  var import_node_os16 = __toESM(require("os"), 1);
54528
- var import_node_path46 = __toESM(require("path"), 1);
56178
+ var import_node_path47 = __toESM(require("path"), 1);
54529
56179
  init_claude_history();
54530
56180
  function readJsonlEntries(file) {
54531
56181
  const raw = import_node_fs42.default.readFileSync(file, "utf8");
@@ -54541,19 +56191,19 @@ function readJsonlEntries(file) {
54541
56191
  return out;
54542
56192
  }
54543
56193
  function forkSession(input) {
54544
- const baseDir = input.baseDir ?? import_node_path46.default.join(import_node_os16.default.homedir(), ".claude");
54545
- let projectDir = import_node_path46.default.join(baseDir, "projects", cwdToHashDir(input.cwd));
54546
- let sourceFile = import_node_path46.default.join(projectDir, `${input.toolSessionId}.jsonl`);
56194
+ const baseDir = input.baseDir ?? import_node_path47.default.join(import_node_os16.default.homedir(), ".claude");
56195
+ let projectDir = import_node_path47.default.join(baseDir, "projects", cwdToHashDir(input.cwd));
56196
+ let sourceFile = import_node_path47.default.join(projectDir, `${input.toolSessionId}.jsonl`);
54547
56197
  if (!import_node_fs42.default.existsSync(sourceFile)) {
54548
56198
  const found = findTranscriptByToolSessionId(
54549
- import_node_path46.default.join(baseDir, "projects"),
56199
+ import_node_path47.default.join(baseDir, "projects"),
54550
56200
  input.toolSessionId
54551
56201
  );
54552
56202
  if (!found) {
54553
56203
  throw new Error(`fork: source transcript not found: ${sourceFile}`);
54554
56204
  }
54555
56205
  sourceFile = found;
54556
- projectDir = import_node_path46.default.dirname(found);
56206
+ projectDir = import_node_path47.default.dirname(found);
54557
56207
  }
54558
56208
  const entries = readJsonlEntries(sourceFile);
54559
56209
  const mainEntries = entries.filter((e) => e.isSidechain !== true);
@@ -54582,7 +56232,7 @@ function forkSession(input) {
54582
56232
  }
54583
56233
  forkedLines.push(JSON.stringify(forked));
54584
56234
  }
54585
- const forkedFilePath = import_node_path46.default.join(projectDir, `${forkedToolSessionId}.jsonl`);
56235
+ const forkedFilePath = import_node_path47.default.join(projectDir, `${forkedToolSessionId}.jsonl`);
54586
56236
  import_node_fs42.default.mkdirSync(projectDir, { recursive: true });
54587
56237
  import_node_fs42.default.writeFileSync(forkedFilePath, forkedLines.join("\n") + "\n", { mode: 384 });
54588
56238
  return { forkedToolSessionId, forkedFilePath };
@@ -55001,7 +56651,7 @@ function buildPermissionHandlers(deps) {
55001
56651
  }
55002
56652
 
55003
56653
  // src/handlers/history.ts
55004
- var path57 = __toESM(require("path"), 1);
56654
+ var path58 = __toESM(require("path"), 1);
55005
56655
  init_protocol();
55006
56656
 
55007
56657
  // src/session/recent-dirs.ts
@@ -55019,7 +56669,7 @@ function listRecentDirs(store, limit = 50) {
55019
56669
  }
55020
56670
 
55021
56671
  // src/permission/persona-paths.ts
55022
- var path56 = __toESM(require("path"), 1);
56672
+ var path57 = __toESM(require("path"), 1);
55023
56673
  function getAllowedPersonaIds(grants, action) {
55024
56674
  const ids = /* @__PURE__ */ new Set();
55025
56675
  for (const g2 of grants) {
@@ -55032,42 +56682,42 @@ function getAllowedPersonaIds(grants, action) {
55032
56682
  return ids;
55033
56683
  }
55034
56684
  function isGuestPathAllowed(grants, absPath, personaRoot, action = "read", userWorkDir) {
55035
- const target = path56.resolve(absPath);
56685
+ const target = path57.resolve(absPath);
55036
56686
  if (userWorkDir) {
55037
- const u = path56.resolve(userWorkDir);
55038
- const usep = u.endsWith(path56.sep) ? "" : path56.sep;
56687
+ const u = path57.resolve(userWorkDir);
56688
+ const usep = u.endsWith(path57.sep) ? "" : path57.sep;
55039
56689
  if (target === u || target.startsWith(u + usep)) return true;
55040
56690
  }
55041
- const root = path56.resolve(personaRoot);
55042
- const sep3 = root.endsWith(path56.sep) ? "" : path56.sep;
56691
+ const root = path57.resolve(personaRoot);
56692
+ const sep3 = root.endsWith(path57.sep) ? "" : path57.sep;
55043
56693
  if (!target.startsWith(root + sep3)) return false;
55044
- const rel = path56.relative(root, target);
56694
+ const rel = path57.relative(root, target);
55045
56695
  if (!rel || rel.startsWith("..")) return false;
55046
- const personaId2 = rel.split(path56.sep)[0];
56696
+ const personaId2 = rel.split(path57.sep)[0];
55047
56697
  if (!personaId2) return false;
55048
56698
  const allowed = getAllowedPersonaIds(grants, action);
55049
56699
  if (allowed === "*") return true;
55050
56700
  return allowed.has(personaId2);
55051
56701
  }
55052
56702
  function personaIdFromPath(absPath, personaRoot) {
55053
- const root = path56.resolve(personaRoot);
55054
- const target = path56.resolve(absPath);
55055
- const sep3 = root.endsWith(path56.sep) ? "" : path56.sep;
56703
+ const root = path57.resolve(personaRoot);
56704
+ const target = path57.resolve(absPath);
56705
+ const sep3 = root.endsWith(path57.sep) ? "" : path57.sep;
55056
56706
  if (!target.startsWith(root + sep3)) return null;
55057
- const rel = path56.relative(root, target);
56707
+ const rel = path57.relative(root, target);
55058
56708
  if (!rel || rel.startsWith("..")) return null;
55059
- const id = rel.split(path56.sep)[0];
56709
+ const id = rel.split(path57.sep)[0];
55060
56710
  return id || null;
55061
56711
  }
55062
56712
  function isPathWithin(dir, absPath) {
55063
- const d = path56.resolve(dir);
55064
- const t = path56.resolve(absPath);
55065
- const sep3 = d.endsWith(path56.sep) ? "" : path56.sep;
56713
+ const d = path57.resolve(dir);
56714
+ const t = path57.resolve(absPath);
56715
+ const sep3 = d.endsWith(path57.sep) ? "" : path57.sep;
55066
56716
  return t === d || t.startsWith(d + sep3);
55067
56717
  }
55068
56718
  function isPathInGuestBoundary(personaRoot, personaId2, userWorkDir, absPath) {
55069
56719
  if (userWorkDir && isPathWithin(userWorkDir, absPath)) return true;
55070
- return personaIdFromPath(path56.resolve(absPath), personaRoot) === personaId2;
56720
+ return personaIdFromPath(path57.resolve(absPath), personaRoot) === personaId2;
55071
56721
  }
55072
56722
 
55073
56723
  // src/handlers/history.ts
@@ -55119,7 +56769,7 @@ function buildHistoryHandlers(deps) {
55119
56769
  if (!pid) return false;
55120
56770
  return isGuestPathAllowed(
55121
56771
  ctx.grants,
55122
- path57.join(personaRoot, pid),
56772
+ path58.join(personaRoot, pid),
55123
56773
  personaRoot,
55124
56774
  "read",
55125
56775
  userWorkDir
@@ -55131,7 +56781,7 @@ function buildHistoryHandlers(deps) {
55131
56781
  };
55132
56782
  const list = async (frame, _client, ctx) => {
55133
56783
  const args = HistoryListArgs.parse(frame);
55134
- assertGuestPath(ctx, path57.resolve(args.projectPath), personaRoot, "history:list", usersRoot);
56784
+ assertGuestPath(ctx, path58.resolve(args.projectPath), personaRoot, "history:list", usersRoot);
55135
56785
  const sessions = await history.listSessions(args);
55136
56786
  return { response: { type: "history:list", sessions } };
55137
56787
  };
@@ -55164,13 +56814,13 @@ function buildHistoryHandlers(deps) {
55164
56814
  };
55165
56815
  const subagents = async (frame, _client, ctx) => {
55166
56816
  const args = HistorySubagentsArgs.parse(frame);
55167
- assertGuestPath(ctx, path57.resolve(args.cwd), personaRoot, "history:subagents", usersRoot);
56817
+ assertGuestPath(ctx, path58.resolve(args.cwd), personaRoot, "history:subagents", usersRoot);
55168
56818
  const subs = await history.listSubagents(args);
55169
56819
  return { response: { type: "history:subagents", subagents: subs } };
55170
56820
  };
55171
56821
  const subagentRead = async (frame, _client, ctx) => {
55172
56822
  const args = HistorySubagentReadArgs.parse(frame);
55173
- assertGuestPath(ctx, path57.resolve(args.cwd), personaRoot, "history:subagent-read", usersRoot);
56823
+ assertGuestPath(ctx, path58.resolve(args.cwd), personaRoot, "history:subagent-read", usersRoot);
55174
56824
  const res = await history.readSubagent(args);
55175
56825
  return { response: { type: "history:subagent-read", ...res } };
55176
56826
  };
@@ -55179,7 +56829,7 @@ function buildHistoryHandlers(deps) {
55179
56829
  if (ctx?.principal.kind === "guest" && personaRoot) {
55180
56830
  const userWorkDir = usersRoot ? deriveUserWorkDir(ctx.principal.id, usersRoot) : void 0;
55181
56831
  const filtered = dirs.filter(
55182
- (d) => isGuestPathAllowed(ctx.grants, path57.resolve(d.cwd), personaRoot, "read", userWorkDir)
56832
+ (d) => isGuestPathAllowed(ctx.grants, path58.resolve(d.cwd), personaRoot, "read", userWorkDir)
55183
56833
  );
55184
56834
  return { response: { type: "history:recentDirs", dirs: filtered } };
55185
56835
  }
@@ -55196,7 +56846,7 @@ function buildHistoryHandlers(deps) {
55196
56846
  }
55197
56847
 
55198
56848
  // src/handlers/workspace.ts
55199
- var path58 = __toESM(require("path"), 1);
56849
+ var path59 = __toESM(require("path"), 1);
55200
56850
  var os16 = __toESM(require("os"), 1);
55201
56851
  init_protocol();
55202
56852
  init_protocol();
@@ -55238,22 +56888,22 @@ function buildWorkspaceHandlers(deps) {
55238
56888
  const args = WorkspaceListArgs.parse(frame);
55239
56889
  const isGuest = ctx?.principal.kind === "guest";
55240
56890
  const fallbackCwd = isGuest && personaRoot ? personaRoot : os16.homedir();
55241
- const resolvedCwd = path58.resolve(args.cwd ?? fallbackCwd);
55242
- const target = args.path ? path58.resolve(resolvedCwd, args.path) : resolvedCwd;
56891
+ const resolvedCwd = path59.resolve(args.cwd ?? fallbackCwd);
56892
+ const target = args.path ? path59.resolve(resolvedCwd, args.path) : resolvedCwd;
55243
56893
  assertGuestPath2(ctx, target, personaRoot, "workspace:list", usersRoot);
55244
56894
  const res = workspace.list({ ...args, cwd: resolvedCwd });
55245
56895
  return { response: { type: "workspace:list", ...res } };
55246
56896
  };
55247
56897
  const read = async (frame, _client, ctx) => {
55248
56898
  const args = WorkspaceReadArgs.parse(frame);
55249
- const target = path58.isAbsolute(args.path) ? path58.resolve(args.path) : path58.resolve(args.cwd, args.path);
56899
+ const target = path59.isAbsolute(args.path) ? path59.resolve(args.path) : path59.resolve(args.cwd, args.path);
55250
56900
  assertGuestPath2(ctx, target, personaRoot, "workspace:read", usersRoot);
55251
56901
  const res = workspace.read(args);
55252
56902
  return { response: { type: "workspace:read", ...res } };
55253
56903
  };
55254
56904
  const skillsList = async (frame, _client, ctx) => {
55255
56905
  const args = SkillsListArgs.parse(frame);
55256
- const cwdAbs = path58.resolve(args.cwd);
56906
+ const cwdAbs = path59.resolve(args.cwd);
55257
56907
  assertGuestPath2(ctx, cwdAbs, personaRoot, "skills:list", usersRoot);
55258
56908
  const list2 = await getSkillsForTool(args.tool ?? "claude", cwdAbs);
55259
56909
  if (ctx?.principal.kind === "guest" && personaRoot) {
@@ -55265,7 +56915,7 @@ function buildWorkspaceHandlers(deps) {
55265
56915
  };
55266
56916
  const agentsList = async (frame, _client, ctx) => {
55267
56917
  const args = AgentsListArgs.parse(frame);
55268
- const cwdAbs = path58.resolve(args.cwd);
56918
+ const cwdAbs = path59.resolve(args.cwd);
55269
56919
  assertGuestPath2(ctx, cwdAbs, personaRoot, "agents:list", usersRoot);
55270
56920
  if (args.tool === "codex") {
55271
56921
  return { response: { type: "agents:list", agents: [] } };
@@ -55287,18 +56937,18 @@ function buildWorkspaceHandlers(deps) {
55287
56937
  }
55288
56938
 
55289
56939
  // src/handlers/git.ts
55290
- var path60 = __toESM(require("path"), 1);
56940
+ var path61 = __toESM(require("path"), 1);
55291
56941
  init_protocol();
55292
56942
  init_protocol();
55293
56943
 
55294
56944
  // src/workspace/git.ts
55295
56945
  var import_node_child_process11 = require("child_process");
55296
56946
  var import_node_fs43 = __toESM(require("fs"), 1);
55297
- var import_node_path47 = __toESM(require("path"), 1);
56947
+ var import_node_path48 = __toESM(require("path"), 1);
55298
56948
  var import_node_util = require("util");
55299
56949
  var pexec = (0, import_node_util.promisify)(import_node_child_process11.execFile);
55300
56950
  function normalizePath(p2) {
55301
- const resolved = import_node_path47.default.resolve(p2);
56951
+ const resolved = import_node_path48.default.resolve(p2);
55302
56952
  try {
55303
56953
  return import_node_fs43.default.realpathSync(resolved);
55304
56954
  } catch {
@@ -55374,7 +57024,7 @@ async function listGitBranches(cwd) {
55374
57024
  function assertGuestCwd(ctx, cwd, personaRoot, method, usersRoot) {
55375
57025
  if (!ctx || ctx.principal.kind !== "guest" || !personaRoot) return;
55376
57026
  const userWorkDir = usersRoot ? deriveUserWorkDir(ctx.principal.id, usersRoot) : void 0;
55377
- if (!isGuestPathAllowed(ctx.grants, path60.resolve(cwd), personaRoot, "read", userWorkDir)) {
57027
+ if (!isGuestPathAllowed(ctx.grants, path61.resolve(cwd), personaRoot, "read", userWorkDir)) {
55378
57028
  throw new ClawdError(
55379
57029
  ERROR_CODES.UNAUTHORIZED,
55380
57030
  `guest ${ctx.principal.id} cannot ${method} cwd ${cwd}`
@@ -56222,21 +57872,21 @@ function computeMethodAccess(args) {
56222
57872
  }
56223
57873
 
56224
57874
  // src/version.ts
56225
- var version = "0.2.269".length > 0 ? "0.2.269" : "dev";
57875
+ var version = "0.2.270".length > 0 ? "0.2.270" : "dev";
56226
57876
 
56227
57877
  // src/cli-probe/probe.ts
56228
57878
  var fs54 = __toESM(require("fs"), 1);
56229
- var path61 = __toESM(require("path"), 1);
57879
+ var path62 = __toESM(require("path"), 1);
56230
57880
  var PKG_NAME = "@clawos-dev/clawd";
56231
57881
  var BIN_NAME = "clawd";
56232
57882
  var MAX_PARENT_HOPS = 5;
56233
57883
  function probeGlobalCli(pathEnv) {
56234
57884
  if (!pathEnv) return null;
56235
- for (const dir of pathEnv.split(path61.delimiter)) {
57885
+ for (const dir of pathEnv.split(path62.delimiter)) {
56236
57886
  if (!dir) continue;
56237
57887
  let real;
56238
57888
  try {
56239
- real = fs54.realpathSync(path61.join(dir, BIN_NAME));
57889
+ real = fs54.realpathSync(path62.join(dir, BIN_NAME));
56240
57890
  } catch {
56241
57891
  continue;
56242
57892
  }
@@ -56246,15 +57896,15 @@ function probeGlobalCli(pathEnv) {
56246
57896
  return null;
56247
57897
  }
56248
57898
  function readOwnPackageVersion(entryPath) {
56249
- let dir = path61.dirname(entryPath);
57899
+ let dir = path62.dirname(entryPath);
56250
57900
  for (let i = 0; i < MAX_PARENT_HOPS; i++) {
56251
57901
  try {
56252
- const raw = fs54.readFileSync(path61.join(dir, "package.json"), "utf8");
57902
+ const raw = fs54.readFileSync(path62.join(dir, "package.json"), "utf8");
56253
57903
  const pkg = JSON.parse(raw);
56254
57904
  if (pkg.name !== PKG_NAME) return null;
56255
57905
  return typeof pkg.version === "string" && pkg.version ? pkg.version : null;
56256
57906
  } catch {
56257
- const parent = path61.dirname(dir);
57907
+ const parent = path62.dirname(dir);
56258
57908
  if (parent === dir) return null;
56259
57909
  dir = parent;
56260
57910
  }
@@ -56314,17 +57964,28 @@ function buildMetaHandlers(deps) {
56314
57964
  };
56315
57965
  }
56316
57966
  function buildMetaMethodsHandler(deps) {
56317
- return async (_frame, _client, ctx) => {
57967
+ return async (frame, _client, ctx) => {
56318
57968
  const grants = ctx?.grants ?? [];
56319
- const methods = METHOD_NAMES.map(
56320
- (method) => computeMethodAccess({
56321
- method,
56322
- grants,
56323
- feishuActive: deps.feishuActive(),
56324
- isImplemented: deps.isImplemented
56325
- })
56326
- );
56327
- return { response: { type: "meta:methods", methods } };
57969
+ const { method } = MetaMethodsArgs.parse(frame);
57970
+ const compute = (m2) => computeMethodAccess({
57971
+ method: m2,
57972
+ grants,
57973
+ feishuActive: deps.feishuActive(),
57974
+ isImplemented: deps.isImplemented
57975
+ });
57976
+ if (method !== void 0) {
57977
+ if (!isMethodName(method)) {
57978
+ throw new ClawdError(ERROR_CODES.INVALID_PARAM, `unknown method: ${method}`);
57979
+ }
57980
+ const argsSchema = methodArgsSchema(method);
57981
+ return {
57982
+ response: {
57983
+ type: "meta:methods",
57984
+ methods: [{ ...compute(method), ...argsSchema ? { argsSchema } : {} }]
57985
+ }
57986
+ };
57987
+ }
57988
+ return { response: { type: "meta:methods", methods: METHOD_NAMES.map(compute) } };
56328
57989
  };
56329
57990
  }
56330
57991
 
@@ -56401,7 +58062,7 @@ function buildPersonaHandlers(deps) {
56401
58062
  }
56402
58063
 
56403
58064
  // src/handlers/attachment.ts
56404
- var import_node_path48 = __toESM(require("path"), 1);
58065
+ var import_node_path49 = __toESM(require("path"), 1);
56405
58066
  init_protocol();
56406
58067
  init_protocol();
56407
58068
  var DEFAULT_TTL_SECONDS = 24 * 3600;
@@ -56481,12 +58142,12 @@ function buildAttachmentHandlers(deps) {
56481
58142
  `session ${args.sessionId} scope unresolved`
56482
58143
  );
56483
58144
  }
56484
- const cwdAbs = import_node_path48.default.resolve(sessionFile.cwd);
56485
- const candidateAbs = import_node_path48.default.isAbsolute(args.relPath) ? import_node_path48.default.resolve(args.relPath) : import_node_path48.default.resolve(cwdAbs, args.relPath);
58145
+ const cwdAbs = import_node_path49.default.resolve(sessionFile.cwd);
58146
+ const candidateAbs = import_node_path49.default.isAbsolute(args.relPath) ? import_node_path49.default.resolve(args.relPath) : import_node_path49.default.resolve(cwdAbs, args.relPath);
56486
58147
  guardAttachmentPath(ctx, args.sessionId, candidateAbs, "attachment.signUrl", "group-acl");
56487
58148
  const entries = deps.groupFileStore.list(scope, args.sessionId);
56488
58149
  const entry = entries.find((e) => {
56489
- const storedAbs = import_node_path48.default.isAbsolute(e.relPath) ? import_node_path48.default.resolve(e.relPath) : import_node_path48.default.resolve(cwdAbs, e.relPath);
58150
+ const storedAbs = import_node_path49.default.isAbsolute(e.relPath) ? import_node_path49.default.resolve(e.relPath) : import_node_path49.default.resolve(cwdAbs, e.relPath);
56490
58151
  return storedAbs === candidateAbs && !e.stale;
56491
58152
  });
56492
58153
  if (!entry) {
@@ -56511,7 +58172,7 @@ function buildAttachmentHandlers(deps) {
56511
58172
  if (!ctx || ctx.principal.kind !== "guest" || !deps.personaRoot || !deps.sessionStore) return;
56512
58173
  const f = deps.sessionStore.read(sessionId);
56513
58174
  if (!f) return;
56514
- assertGuestAttachmentPath(ctx, import_node_path48.default.resolve(f.cwd), deps.personaRoot, method, deps.usersRoot);
58175
+ assertGuestAttachmentPath(ctx, import_node_path49.default.resolve(f.cwd), deps.personaRoot, method, deps.usersRoot);
56515
58176
  }
56516
58177
  const groupAdd = async (frame, _client, ctx) => {
56517
58178
  if (!deps.groupFileStore || !deps.getSessionScope) {
@@ -56526,8 +58187,8 @@ function buildAttachmentHandlers(deps) {
56526
58187
  if (!scope) {
56527
58188
  throw new ClawdError(ERROR_CODES.VALIDATION_ERROR, `session ${args.sessionId} not found`);
56528
58189
  }
56529
- const cwdAbs = import_node_path48.default.resolve(deps.sessionStore?.read(args.sessionId)?.cwd ?? ".");
56530
- const candidateAbs = import_node_path48.default.isAbsolute(args.relPath) ? import_node_path48.default.resolve(args.relPath) : import_node_path48.default.resolve(cwdAbs, args.relPath);
58190
+ const cwdAbs = import_node_path49.default.resolve(deps.sessionStore?.read(args.sessionId)?.cwd ?? ".");
58191
+ const candidateAbs = import_node_path49.default.isAbsolute(args.relPath) ? import_node_path49.default.resolve(args.relPath) : import_node_path49.default.resolve(cwdAbs, args.relPath);
56531
58192
  guardAttachmentPath(ctx, args.sessionId, candidateAbs, "attachment.groupAdd", "cwd-subtree");
56532
58193
  const from = args.origin === "agent" ? "agent" : ctx?.principal.kind === "owner" ? "owner" : "agent";
56533
58194
  const size = 0;
@@ -56586,19 +58247,19 @@ function buildAttachmentHandlers(deps) {
56586
58247
 
56587
58248
  // src/handlers/extension.ts
56588
58249
  var import_promises9 = __toESM(require("fs/promises"), 1);
56589
- var import_node_path53 = __toESM(require("path"), 1);
58250
+ var import_node_path54 = __toESM(require("path"), 1);
56590
58251
  init_protocol();
56591
58252
 
56592
58253
  // src/extension/bundle-zip.ts
56593
58254
  var import_promises6 = __toESM(require("fs/promises"), 1);
56594
- var import_node_path49 = __toESM(require("path"), 1);
58255
+ var import_node_path50 = __toESM(require("path"), 1);
56595
58256
  var import_node_crypto14 = __toESM(require("crypto"), 1);
56596
58257
  var import_jszip2 = __toESM(require_lib3(), 1);
56597
58258
  async function bundleExtensionDir(dir) {
56598
58259
  const entries = await listFilesSorted(dir);
56599
58260
  const zip = new import_jszip2.default();
56600
58261
  for (const rel of entries) {
56601
- const abs = import_node_path49.default.join(dir, rel);
58262
+ const abs = import_node_path50.default.join(dir, rel);
56602
58263
  const content = await import_promises6.default.readFile(abs);
56603
58264
  zip.file(rel, content, { date: FIXED_DATE });
56604
58265
  }
@@ -56619,7 +58280,7 @@ async function listFilesSorted(rootDir) {
56619
58280
  return out;
56620
58281
  }
56621
58282
  async function walk(absRoot, relPrefix, out) {
56622
- const dirAbs = import_node_path49.default.join(absRoot, relPrefix);
58283
+ const dirAbs = import_node_path50.default.join(absRoot, relPrefix);
56623
58284
  const entries = await import_promises6.default.readdir(dirAbs, { withFileTypes: true });
56624
58285
  for (const e of entries) {
56625
58286
  if (IGNORE_BASENAMES.has(e.name)) continue;
@@ -56673,25 +58334,25 @@ function computePublishCheck(args) {
56673
58334
 
56674
58335
  // src/extension/install-flow.ts
56675
58336
  var import_promises7 = __toESM(require("fs/promises"), 1);
56676
- var import_node_path51 = __toESM(require("path"), 1);
58337
+ var import_node_path52 = __toESM(require("path"), 1);
56677
58338
  var import_node_os19 = __toESM(require("os"), 1);
56678
58339
  var import_node_crypto15 = __toESM(require("crypto"), 1);
56679
58340
  var import_jszip3 = __toESM(require_lib3(), 1);
56680
58341
 
56681
58342
  // src/extension/paths.ts
56682
58343
  var import_node_os18 = __toESM(require("os"), 1);
56683
- var import_node_path50 = __toESM(require("path"), 1);
58344
+ var import_node_path51 = __toESM(require("path"), 1);
56684
58345
  function clawdHomeRoot(override) {
56685
- return override ?? process.env.CLAWD_HOME ?? import_node_path50.default.join(import_node_os18.default.homedir(), ".clawd");
58346
+ return override ?? process.env.CLAWD_HOME ?? import_node_path51.default.join(import_node_os18.default.homedir(), ".clawd");
56686
58347
  }
56687
58348
  function extensionsRoot(override) {
56688
- return import_node_path50.default.join(clawdHomeRoot(override), "extensions");
58349
+ return import_node_path51.default.join(clawdHomeRoot(override), "extensions");
56689
58350
  }
56690
58351
  function publishedChannelsFile(override) {
56691
- return import_node_path50.default.join(clawdHomeRoot(override), "extensions-published.json");
58352
+ return import_node_path51.default.join(clawdHomeRoot(override), "extensions-published.json");
56692
58353
  }
56693
58354
  function bundleCacheRoot(override) {
56694
- return import_node_path50.default.join(clawdHomeRoot(override), "extension-bundles");
58355
+ return import_node_path51.default.join(clawdHomeRoot(override), "extension-bundles");
56695
58356
  }
56696
58357
 
56697
58358
  // src/extension/install-flow.ts
@@ -56718,7 +58379,7 @@ async function installFromChannel(args, deps) {
56718
58379
  throw new InstallError("ZIP_INVALID", `failed to load zip: ${e.message}`);
56719
58380
  }
56720
58381
  for (const name of Object.keys(zip.files)) {
56721
- if (name.includes("..") || name.startsWith("/") || import_node_path51.default.isAbsolute(name)) {
58382
+ if (name.includes("..") || name.startsWith("/") || import_node_path52.default.isAbsolute(name)) {
56722
58383
  throw new InstallError("ZIP_INVALID", `unsafe zip entry: ${name}`);
56723
58384
  }
56724
58385
  }
@@ -56750,7 +58411,7 @@ async function installFromChannel(args, deps) {
56750
58411
  );
56751
58412
  }
56752
58413
  const localExtId = namespacedExtId(ownerSlug, channelRef.ownerPrincipalId);
56753
- const destDir = import_node_path51.default.join(deps.extensionsRoot, localExtId);
58414
+ const destDir = import_node_path52.default.join(deps.extensionsRoot, localExtId);
56754
58415
  let destExists = false;
56755
58416
  try {
56756
58417
  await import_promises7.default.access(destDir);
@@ -56764,16 +58425,16 @@ async function installFromChannel(args, deps) {
56764
58425
  );
56765
58426
  }
56766
58427
  const stage = await import_promises7.default.mkdtemp(
56767
- import_node_path51.default.join(import_node_os19.default.tmpdir(), `clawd-ext-install-${localExtId}-`)
58428
+ import_node_path52.default.join(import_node_os19.default.tmpdir(), `clawd-ext-install-${localExtId}-`)
56768
58429
  );
56769
58430
  try {
56770
58431
  for (const [name, entry] of Object.entries(zip.files)) {
56771
- const dest = import_node_path51.default.join(stage, name);
58432
+ const dest = import_node_path52.default.join(stage, name);
56772
58433
  if (entry.dir) {
56773
58434
  await import_promises7.default.mkdir(dest, { recursive: true });
56774
58435
  continue;
56775
58436
  }
56776
- await import_promises7.default.mkdir(import_node_path51.default.dirname(dest), { recursive: true });
58437
+ await import_promises7.default.mkdir(import_node_path52.default.dirname(dest), { recursive: true });
56777
58438
  if (name === "manifest.json") {
56778
58439
  const rewritten = { ...parsed.data, id: localExtId };
56779
58440
  await import_promises7.default.writeFile(dest, JSON.stringify(rewritten, null, 2));
@@ -56794,7 +58455,7 @@ async function installFromChannel(args, deps) {
56794
58455
 
56795
58456
  // src/extension/update-flow.ts
56796
58457
  var import_promises8 = __toESM(require("fs/promises"), 1);
56797
- var import_node_path52 = __toESM(require("path"), 1);
58458
+ var import_node_path53 = __toESM(require("path"), 1);
56798
58459
  var import_node_os20 = __toESM(require("os"), 1);
56799
58460
  var import_node_crypto16 = __toESM(require("crypto"), 1);
56800
58461
  var import_jszip4 = __toESM(require_lib3(), 1);
@@ -56811,11 +58472,11 @@ async function updateFromChannel(args, deps) {
56811
58472
  channelRef.extId,
56812
58473
  channelRef.ownerPrincipalId
56813
58474
  );
56814
- const liveDir = import_node_path52.default.join(deps.extensionsRoot, localExtId);
58475
+ const liveDir = import_node_path53.default.join(deps.extensionsRoot, localExtId);
56815
58476
  const prevDir = `${liveDir}.prev`;
56816
58477
  let existingVersion;
56817
58478
  try {
56818
- const raw = await import_promises8.default.readFile(import_node_path52.default.join(liveDir, "manifest.json"), "utf8");
58479
+ const raw = await import_promises8.default.readFile(import_node_path53.default.join(liveDir, "manifest.json"), "utf8");
56819
58480
  const parsed2 = ExtensionManifestSchema.safeParse(JSON.parse(raw));
56820
58481
  if (!parsed2.success) {
56821
58482
  throw new UpdateError(
@@ -56848,7 +58509,7 @@ async function updateFromChannel(args, deps) {
56848
58509
  throw new UpdateError("ZIP_INVALID", `failed to load zip: ${e.message}`);
56849
58510
  }
56850
58511
  for (const name of Object.keys(zip.files)) {
56851
- if (name.includes("..") || name.startsWith("/") || import_node_path52.default.isAbsolute(name)) {
58512
+ if (name.includes("..") || name.startsWith("/") || import_node_path53.default.isAbsolute(name)) {
56852
58513
  throw new UpdateError("ZIP_INVALID", `unsafe zip entry: ${name}`);
56853
58514
  }
56854
58515
  }
@@ -56883,16 +58544,16 @@ async function updateFromChannel(args, deps) {
56883
58544
  await import_promises8.default.rm(prevDir, { recursive: true, force: true });
56884
58545
  await import_promises8.default.rename(liveDir, prevDir);
56885
58546
  const stage = await import_promises8.default.mkdtemp(
56886
- import_node_path52.default.join(import_node_os20.default.tmpdir(), `clawd-ext-update-${localExtId}-`)
58547
+ import_node_path53.default.join(import_node_os20.default.tmpdir(), `clawd-ext-update-${localExtId}-`)
56887
58548
  );
56888
58549
  try {
56889
58550
  for (const [name, entry] of Object.entries(zip.files)) {
56890
- const dest = import_node_path52.default.join(stage, name);
58551
+ const dest = import_node_path53.default.join(stage, name);
56891
58552
  if (entry.dir) {
56892
58553
  await import_promises8.default.mkdir(dest, { recursive: true });
56893
58554
  continue;
56894
58555
  }
56895
- await import_promises8.default.mkdir(import_node_path52.default.dirname(dest), { recursive: true });
58556
+ await import_promises8.default.mkdir(import_node_path53.default.dirname(dest), { recursive: true });
56896
58557
  if (name === "manifest.json") {
56897
58558
  const rewritten = { ...parsed.data, id: localExtId };
56898
58559
  await import_promises8.default.writeFile(dest, JSON.stringify(rewritten, null, 2));
@@ -56959,7 +58620,7 @@ async function rewriteManifestVersion(root, extId, newVersion, previousPublished
56959
58620
  );
56960
58621
  }
56961
58622
  }
56962
- const manifestPath = import_node_path53.default.join(root, extId, "manifest.json");
58623
+ const manifestPath = import_node_path54.default.join(root, extId, "manifest.json");
56963
58624
  const manifest = await readManifest(root, extId);
56964
58625
  const next = { ...manifest, version: newVersion };
56965
58626
  const tmp = `${manifestPath}.tmp`;
@@ -56967,7 +58628,7 @@ async function rewriteManifestVersion(root, extId, newVersion, previousPublished
56967
58628
  await import_promises9.default.rename(tmp, manifestPath);
56968
58629
  }
56969
58630
  async function readManifest(root, extId) {
56970
- const file = import_node_path53.default.join(root, extId, "manifest.json");
58631
+ const file = import_node_path54.default.join(root, extId, "manifest.json");
56971
58632
  let raw;
56972
58633
  try {
56973
58634
  raw = await import_promises9.default.readFile(file, "utf8");
@@ -57051,7 +58712,7 @@ function buildExtensionHandlers(deps) {
57051
58712
  };
57052
58713
  async function buildSnapshotMeta(extId) {
57053
58714
  const manifest = await readManifest(deps.root, extId);
57054
- const { sha256, buffer } = await bundleExtensionDir(import_node_path53.default.join(deps.root, extId));
58715
+ const { sha256, buffer } = await bundleExtensionDir(import_node_path54.default.join(deps.root, extId));
57055
58716
  return { manifest, contentHash: sha256, buffer };
57056
58717
  }
57057
58718
  const publish = async (frame, _client, ctx) => {
@@ -57228,7 +58889,7 @@ function buildExtensionHandlers(deps) {
57228
58889
  // src/app-builder/project-store.ts
57229
58890
  var import_node_fs44 = require("fs");
57230
58891
  var import_node_child_process12 = require("child_process");
57231
- var import_node_path54 = require("path");
58892
+ var import_node_path55 = require("path");
57232
58893
  init_protocol();
57233
58894
  var PROJECTS_DIR = "projects";
57234
58895
  var META_FILE = ".clawd-project.json";
@@ -57242,14 +58903,14 @@ var ProjectStore = class {
57242
58903
  root;
57243
58904
  /** projects/<name>/.clawd-project.json 路径 */
57244
58905
  metaPath(name) {
57245
- return (0, import_node_path54.join)(this.projectsRoot(), name, META_FILE);
58906
+ return (0, import_node_path55.join)(this.projectsRoot(), name, META_FILE);
57246
58907
  }
57247
58908
  /** projects/<name>/ 目录路径(cwd 用) */
57248
58909
  projectDir(name) {
57249
- return (0, import_node_path54.join)(this.projectsRoot(), name);
58910
+ return (0, import_node_path55.join)(this.projectsRoot(), name);
57250
58911
  }
57251
58912
  projectsRoot() {
57252
- return (0, import_node_path54.join)(this.root, PROJECTS_DIR);
58913
+ return (0, import_node_path55.join)(this.root, PROJECTS_DIR);
57253
58914
  }
57254
58915
  async list() {
57255
58916
  let entries;
@@ -57552,7 +59213,7 @@ var PublishJobRegistry = class {
57552
59213
  // src/app-builder/publish-job-runner.ts
57553
59214
  var import_node_child_process14 = require("child_process");
57554
59215
  var import_node_fs45 = require("fs");
57555
- var import_node_path55 = require("path");
59216
+ var import_node_path56 = require("path");
57556
59217
 
57557
59218
  // src/app-builder/publish-stage-parser.ts
57558
59219
  var STAGE_RE = /^\s*::stage::(build|deploy|verify)\s*$/;
@@ -57584,7 +59245,7 @@ async function startPublishJob(deps, args) {
57584
59245
  return { jobId: registry2.get(args.name).jobId, status: "already-publishing" };
57585
59246
  }
57586
59247
  const projDir = projectDir(args.name);
57587
- const logPath = (0, import_node_path55.join)(projDir, ".publish.log");
59248
+ const logPath = (0, import_node_path56.join)(projDir, ".publish.log");
57588
59249
  let logStream = null;
57589
59250
  try {
57590
59251
  logStream = (0, import_node_fs45.createWriteStream)(logPath, { flags: "w" });
@@ -57844,7 +59505,7 @@ async function recoverInterruptedJobs(deps) {
57844
59505
 
57845
59506
  // src/handlers/app-builder.ts
57846
59507
  init_protocol();
57847
- var import_node_path56 = require("path");
59508
+ var import_node_path57 = require("path");
57848
59509
  var import_node_fs46 = require("fs");
57849
59510
  var APP_BUILDER_PERSONAS = ["persona-app-builder", "persona-dataclaw-builder"];
57850
59511
  var DEV_SERVER_READY_TIMEOUT_MS = 3e4;
@@ -57995,8 +59656,8 @@ function buildAppBuilderHandlers(deps) {
57995
59656
  const project = await userStore.create(f.name, reservedPorts);
57996
59657
  try {
57997
59658
  const personaRoot = deps.resolvePersonaRoot ? deps.resolvePersonaRoot(session.ownerPersonaId ?? "") : deps.personaRoot;
57998
- const templateSrcDir = (0, import_node_path56.join)(personaRoot, "extension-kit", "examples", DEFAULT_TEMPLATE);
57999
- const scaffoldScript = (0, import_node_path56.join)(deps.deployKitRoot, "scripts", "new-extension.sh");
59659
+ const templateSrcDir = (0, import_node_path57.join)(personaRoot, "extension-kit", "examples", DEFAULT_TEMPLATE);
59660
+ const scaffoldScript = (0, import_node_path57.join)(deps.deployKitRoot, "scripts", "new-extension.sh");
58000
59661
  const scaffoldResult = await userStore.scaffold(project.name, templateSrcDir, scaffoldScript);
58001
59662
  deps.logger?.info("app-builder.scaffold.done", {
58002
59663
  name: project.name,
@@ -58200,7 +59861,7 @@ function buildAppBuilderHandlers(deps) {
58200
59861
  await userStore.clearPublishJob(args.name);
58201
59862
  }
58202
59863
  const personaRoot = deps.resolvePersonaRoot ? deps.resolvePersonaRoot(boundSession.ownerPersonaId ?? "") : deps.personaRoot;
58203
- const scriptPath = (0, import_node_path56.join)(deps.deployKitRoot, "scripts", "publish.sh");
59864
+ const scriptPath = (0, import_node_path57.join)(deps.deployKitRoot, "scripts", "publish.sh");
58204
59865
  deps.logger?.info("app-builder.publish.start", {
58205
59866
  name: args.name,
58206
59867
  sessionId: boundSession.sessionId,
@@ -58376,7 +60037,7 @@ function buildVisitorHandlers(deps) {
58376
60037
 
58377
60038
  // src/extension/registry.ts
58378
60039
  var import_promises10 = __toESM(require("fs/promises"), 1);
58379
- var import_node_path57 = __toESM(require("path"), 1);
60040
+ var import_node_path58 = __toESM(require("path"), 1);
58380
60041
  async function loadAll(root) {
58381
60042
  let entries;
58382
60043
  try {
@@ -58389,13 +60050,13 @@ async function loadAll(root) {
58389
60050
  for (const ent of entries) {
58390
60051
  if (!ent.isDirectory()) continue;
58391
60052
  if (ent.name.startsWith(".")) continue;
58392
- records.push(await loadOne(import_node_path57.default.join(root, ent.name), ent.name));
60053
+ records.push(await loadOne(import_node_path58.default.join(root, ent.name), ent.name));
58393
60054
  }
58394
60055
  records.sort((a, b2) => a.extId < b2.extId ? -1 : a.extId > b2.extId ? 1 : 0);
58395
60056
  return records;
58396
60057
  }
58397
60058
  async function loadOne(dir, dirName) {
58398
- const manifestPath = import_node_path57.default.join(dir, "manifest.json");
60059
+ const manifestPath = import_node_path58.default.join(dir, "manifest.json");
58399
60060
  let raw;
58400
60061
  try {
58401
60062
  raw = await import_promises10.default.readFile(manifestPath, "utf8");
@@ -58440,7 +60101,7 @@ async function loadOne(dir, dirName) {
58440
60101
 
58441
60102
  // src/extension/uninstall.ts
58442
60103
  var import_promises11 = __toESM(require("fs/promises"), 1);
58443
- var import_node_path58 = __toESM(require("path"), 1);
60104
+ var import_node_path59 = __toESM(require("path"), 1);
58444
60105
  var UninstallError = class extends Error {
58445
60106
  constructor(code, message) {
58446
60107
  super(message);
@@ -58449,7 +60110,7 @@ var UninstallError = class extends Error {
58449
60110
  code;
58450
60111
  };
58451
60112
  async function uninstall(deps) {
58452
- const dir = import_node_path58.default.join(deps.root, deps.extId);
60113
+ const dir = import_node_path59.default.join(deps.root, deps.extId);
58453
60114
  try {
58454
60115
  await import_promises11.default.access(dir);
58455
60116
  } catch {
@@ -58979,7 +60640,7 @@ async function dispatchRpc(method, frame, client, ctx, deps) {
58979
60640
 
58980
60641
  // src/extension/runtime.ts
58981
60642
  var import_node_child_process17 = require("child_process");
58982
- var import_node_path59 = __toESM(require("path"), 1);
60643
+ var import_node_path60 = __toESM(require("path"), 1);
58983
60644
  var import_promises12 = require("timers/promises");
58984
60645
 
58985
60646
  // src/extension/port-allocator.ts
@@ -59080,7 +60741,7 @@ var Runtime = class {
59080
60741
  /\$CLAWOS_EXT_PORT/g,
59081
60742
  String(port)
59082
60743
  );
59083
- const dir = import_node_path59.default.join(this.root, extId);
60744
+ const dir = import_node_path60.default.join(this.root, extId);
59084
60745
  const env = {
59085
60746
  ...process.env,
59086
60747
  CLAWOS_EXT_PORT: String(port),
@@ -59192,7 +60853,7 @@ ${handle.stderrTail}`
59192
60853
 
59193
60854
  // src/extension/published-channels.ts
59194
60855
  var import_promises13 = __toESM(require("fs/promises"), 1);
59195
- var import_node_path60 = __toESM(require("path"), 1);
60856
+ var import_node_path61 = __toESM(require("path"), 1);
59196
60857
  init_zod();
59197
60858
  var PublishedChannelsError = class extends Error {
59198
60859
  constructor(code, message) {
@@ -59291,7 +60952,7 @@ var PublishedChannelStore = class {
59291
60952
  )
59292
60953
  };
59293
60954
  const tmp = `${this.filePath}.tmp`;
59294
- await import_promises13.default.mkdir(import_node_path60.default.dirname(this.filePath), { recursive: true });
60955
+ await import_promises13.default.mkdir(import_node_path61.default.dirname(this.filePath), { recursive: true });
59295
60956
  await import_promises13.default.writeFile(tmp, JSON.stringify(data, null, 2), { mode: 384 });
59296
60957
  await import_promises13.default.rename(tmp, this.filePath);
59297
60958
  }
@@ -59299,7 +60960,7 @@ var PublishedChannelStore = class {
59299
60960
 
59300
60961
  // src/extension/bundle-cache.ts
59301
60962
  var import_promises14 = __toESM(require("fs/promises"), 1);
59302
- var import_node_path61 = __toESM(require("path"), 1);
60963
+ var import_node_path62 = __toESM(require("path"), 1);
59303
60964
  var BundleCache = class {
59304
60965
  constructor(rootDir) {
59305
60966
  this.rootDir = rootDir;
@@ -59308,14 +60969,14 @@ var BundleCache = class {
59308
60969
  /** Atomic write: stage tmp → rename. Caller passes the hex sha256. */
59309
60970
  async write(snapshotHash, buffer) {
59310
60971
  await import_promises14.default.mkdir(this.rootDir, { recursive: true });
59311
- const file = import_node_path61.default.join(this.rootDir, `${snapshotHash}.zip`);
60972
+ const file = import_node_path62.default.join(this.rootDir, `${snapshotHash}.zip`);
59312
60973
  const tmp = `${file}.tmp`;
59313
60974
  await import_promises14.default.writeFile(tmp, buffer, { mode: 384 });
59314
60975
  await import_promises14.default.rename(tmp, file);
59315
60976
  }
59316
60977
  /** Returns the bundle bytes, or null when the file doesn't exist. */
59317
60978
  async read(snapshotHash) {
59318
- const file = import_node_path61.default.join(this.rootDir, `${snapshotHash}.zip`);
60979
+ const file = import_node_path62.default.join(this.rootDir, `${snapshotHash}.zip`);
59319
60980
  try {
59320
60981
  return await import_promises14.default.readFile(file);
59321
60982
  } catch (e) {
@@ -59325,7 +60986,7 @@ var BundleCache = class {
59325
60986
  }
59326
60987
  /** Idempotent — missing file is not an error. */
59327
60988
  async delete(snapshotHash) {
59328
- const file = import_node_path61.default.join(this.rootDir, `${snapshotHash}.zip`);
60989
+ const file = import_node_path62.default.join(this.rootDir, `${snapshotHash}.zip`);
59329
60990
  await import_promises14.default.rm(file, { force: true });
59330
60991
  }
59331
60992
  };
@@ -59348,24 +61009,24 @@ async function startDaemon(config) {
59348
61009
  sampling: logShippingCfg.sampling,
59349
61010
  homeDir: import_node_os22.default.homedir()
59350
61011
  });
59351
- const logDir = import_node_path62.default.join(config.dataDir, "log");
61012
+ const logDir = import_node_path63.default.join(config.dataDir, "log");
59352
61013
  import_node_fs47.default.mkdirSync(logDir, { recursive: true });
59353
61014
  const logger = createLogger({
59354
61015
  level: config.logLevel,
59355
- file: import_node_path62.default.join(logDir, "clawd.log"),
61016
+ file: import_node_path63.default.join(logDir, "clawd.log"),
59356
61017
  logClient
59357
61018
  });
59358
61019
  logger.info("starting clawd", { version, config: { port: config.port, host: config.host, dataDir: config.dataDir } });
59359
61020
  const screenIdleProbeLogger = createFileOnlyLogger({
59360
- file: import_node_path62.default.join(logDir, "screen-idle-probe.log"),
61021
+ file: import_node_path63.default.join(logDir, "screen-idle-probe.log"),
59361
61022
  level: "debug"
59362
61023
  });
59363
61024
  logger.info("screen-idle probe logger enabled", {
59364
- file: import_node_path62.default.join(logDir, "screen-idle-probe.log")
61025
+ file: import_node_path63.default.join(logDir, "screen-idle-probe.log")
59365
61026
  });
59366
61027
  const CAP_TARGETS = [
59367
- import_node_path62.default.join(logDir, "clawd.log"),
59368
- import_node_path62.default.join(logDir, "screen-idle-probe.log")
61028
+ import_node_path63.default.join(logDir, "clawd.log"),
61029
+ import_node_path63.default.join(logDir, "screen-idle-probe.log")
59369
61030
  ];
59370
61031
  const LOG_CAP_MAX_BYTES = 10 * 1024 * 1024;
59371
61032
  const LOG_CAP_KEEP_BYTES = 5 * 1024 * 1024;
@@ -59461,8 +61122,8 @@ async function startDaemon(config) {
59461
61122
  const agents = new AgentsScanner();
59462
61123
  const history = new ClaudeHistoryReader();
59463
61124
  let transport = null;
59464
- const personaStore = new PersonaStore(import_node_path62.default.join(config.dataDir, "personas"));
59465
- const usersRoot = import_node_path62.default.join(config.dataDir, "users");
61125
+ const personaStore = new PersonaStore(import_node_path63.default.join(config.dataDir, "personas"));
61126
+ const usersRoot = import_node_path63.default.join(config.dataDir, "users");
59466
61127
  const defaultsRoot = findDefaultsRoot(logger);
59467
61128
  if (defaultsRoot) {
59468
61129
  seedDefaultPersonas({ store: personaStore, defaultsRoot, logger });
@@ -59482,7 +61143,7 @@ async function startDaemon(config) {
59482
61143
  migrateCodexSandbox({ store: personaStore, logger });
59483
61144
  const groupFileStore = new GroupFileStore({ dataDir: config.dataDir, logger });
59484
61145
  const dispatchStore = createDispatchStore({
59485
- filePath: import_node_path62.default.join(config.dataDir, "dispatch.json"),
61146
+ filePath: import_node_path63.default.join(config.dataDir, "dispatch.json"),
59486
61147
  now: () => Date.now(),
59487
61148
  onFlushError: (err) => logger.error("dispatch store flush failed", {
59488
61149
  reason: err instanceof Error ? err.message : String(err)
@@ -59497,18 +61158,18 @@ async function startDaemon(config) {
59497
61158
  now: () => Date.now(),
59498
61159
  onCompleted: (sid) => deliverPendingRef?.(sid)
59499
61160
  });
59500
- const here = typeof __dirname === "string" ? __dirname : import_node_path62.default.dirname((0, import_node_url4.fileURLToPath)(import_meta6.url));
61161
+ const here = typeof __dirname === "string" ? __dirname : import_node_path63.default.dirname((0, import_node_url4.fileURLToPath)(import_meta6.url));
59501
61162
  const mcpConfigs = [];
59502
61163
  const mcpDaemonUrl = `http://127.0.0.1:${config.port}`;
59503
61164
  const dispatchServerCandidates = [
59504
- import_node_path62.default.join(here, "dispatch", "mcp-server.cjs"),
61165
+ import_node_path63.default.join(here, "dispatch", "mcp-server.cjs"),
59505
61166
  // 生产 dist/index → dist/dispatch/mcp-server.cjs
59506
- import_node_path62.default.join(here, "..", "dist", "dispatch", "mcp-server.cjs")
61167
+ import_node_path63.default.join(here, "..", "dist", "dispatch", "mcp-server.cjs")
59507
61168
  // dev tsx src/index → ../dist/dispatch/mcp-server.cjs
59508
61169
  ];
59509
61170
  const dispatchServerScriptPath = dispatchServerCandidates.find((p2) => import_node_fs47.default.existsSync(p2));
59510
61171
  if (dispatchServerScriptPath) {
59511
- const dispatchLogPath = import_node_path62.default.join(logDir, "dispatch-mcp-server.log");
61172
+ const dispatchLogPath = import_node_path63.default.join(logDir, "dispatch-mcp-server.log");
59512
61173
  const dispatchCfgPath = writeDispatchMcpConfig({
59513
61174
  dataDir: config.dataDir,
59514
61175
  serverScriptPath: dispatchServerScriptPath,
@@ -59528,12 +61189,12 @@ async function startDaemon(config) {
59528
61189
  });
59529
61190
  }
59530
61191
  const ticketServerCandidates = [
59531
- import_node_path62.default.join(here, "ticket", "mcp-server.cjs"),
59532
- import_node_path62.default.join(here, "..", "dist", "ticket", "mcp-server.cjs")
61192
+ import_node_path63.default.join(here, "ticket", "mcp-server.cjs"),
61193
+ import_node_path63.default.join(here, "..", "dist", "ticket", "mcp-server.cjs")
59533
61194
  ];
59534
61195
  const ticketServerScriptPath = ticketServerCandidates.find((p2) => import_node_fs47.default.existsSync(p2));
59535
61196
  if (ticketServerScriptPath) {
59536
- const ticketLogPath = import_node_path62.default.join(logDir, "ticket-mcp-server.log");
61197
+ const ticketLogPath = import_node_path63.default.join(logDir, "ticket-mcp-server.log");
59537
61198
  const ticketCfgPath = writeTicketMcpConfig({
59538
61199
  dataDir: config.dataDir,
59539
61200
  serverScriptPath: ticketServerScriptPath,
@@ -59555,12 +61216,12 @@ async function startDaemon(config) {
59555
61216
  });
59556
61217
  }
59557
61218
  const shiftServerCandidates = [
59558
- import_node_path62.default.join(here, "shift", "mcp-server.cjs"),
59559
- import_node_path62.default.join(here, "..", "dist", "shift", "mcp-server.cjs")
61219
+ import_node_path63.default.join(here, "shift", "mcp-server.cjs"),
61220
+ import_node_path63.default.join(here, "..", "dist", "shift", "mcp-server.cjs")
59560
61221
  ];
59561
61222
  const shiftServerScriptPath = shiftServerCandidates.find((p2) => import_node_fs47.default.existsSync(p2));
59562
61223
  if (shiftServerScriptPath) {
59563
- const shiftLogPath = import_node_path62.default.join(logDir, "shift-mcp-server.log");
61224
+ const shiftLogPath = import_node_path63.default.join(logDir, "shift-mcp-server.log");
59564
61225
  const shiftCfgPath = await writeShiftMcpConfig({
59565
61226
  dataDir: config.dataDir,
59566
61227
  serverScriptPath: shiftServerScriptPath,
@@ -59581,12 +61242,12 @@ async function startDaemon(config) {
59581
61242
  );
59582
61243
  }
59583
61244
  const inboxServerCandidates = [
59584
- import_node_path62.default.join(here, "inbox", "mcp-server.cjs"),
59585
- import_node_path62.default.join(here, "..", "dist", "inbox", "mcp-server.cjs")
61245
+ import_node_path63.default.join(here, "inbox", "mcp-server.cjs"),
61246
+ import_node_path63.default.join(here, "..", "dist", "inbox", "mcp-server.cjs")
59586
61247
  ];
59587
61248
  const inboxServerScriptPath = inboxServerCandidates.find((p2) => import_node_fs47.default.existsSync(p2));
59588
61249
  if (inboxServerScriptPath) {
59589
- const inboxLogPath = import_node_path62.default.join(logDir, "inbox-mcp-server.log");
61250
+ const inboxLogPath = import_node_path63.default.join(logDir, "inbox-mcp-server.log");
59590
61251
  const inboxCfgPath = await writeInboxMcpConfig({
59591
61252
  dataDir: config.dataDir,
59592
61253
  serverScriptPath: inboxServerScriptPath,
@@ -59607,8 +61268,8 @@ async function startDaemon(config) {
59607
61268
  );
59608
61269
  }
59609
61270
  const peerOpsServerCandidates = [
59610
- import_node_path62.default.join(here, "peer-ops", "mcp-server.cjs"),
59611
- import_node_path62.default.join(here, "..", "dist", "peer-ops", "mcp-server.cjs")
61271
+ import_node_path63.default.join(here, "peer-ops", "mcp-server.cjs"),
61272
+ import_node_path63.default.join(here, "..", "dist", "peer-ops", "mcp-server.cjs")
59612
61273
  ];
59613
61274
  const peerOpsServerScriptPath = peerOpsServerCandidates.find((p2) => import_node_fs47.default.existsSync(p2));
59614
61275
  if (peerOpsServerScriptPath) {
@@ -59630,12 +61291,12 @@ async function startDaemon(config) {
59630
61291
  );
59631
61292
  }
59632
61293
  const rpcToolServerCandidates = [
59633
- import_node_path62.default.join(here, "rpc-tool", "mcp-server.cjs"),
59634
- import_node_path62.default.join(here, "..", "dist", "rpc-tool", "mcp-server.cjs")
61294
+ import_node_path63.default.join(here, "rpc-tool", "mcp-server.cjs"),
61295
+ import_node_path63.default.join(here, "..", "dist", "rpc-tool", "mcp-server.cjs")
59635
61296
  ];
59636
61297
  const rpcToolServerScriptPath = rpcToolServerCandidates.find((p2) => import_node_fs47.default.existsSync(p2));
59637
61298
  if (rpcToolServerScriptPath) {
59638
- const rpcToolLogPath = import_node_path62.default.join(logDir, "rpc-tool-mcp-server.log");
61299
+ const rpcToolLogPath = import_node_path63.default.join(logDir, "rpc-tool-mcp-server.log");
59639
61300
  const rpcToolCfgPath = writeRpcToolMcpConfig({
59640
61301
  dataDir: config.dataDir,
59641
61302
  serverScriptPath: rpcToolServerScriptPath,
@@ -59656,7 +61317,7 @@ async function startDaemon(config) {
59656
61317
  );
59657
61318
  }
59658
61319
  const shiftStore = createShiftStore({
59659
- filePath: import_node_path62.default.join(config.dataDir, "shift.json"),
61320
+ filePath: import_node_path63.default.join(config.dataDir, "shift.json"),
59660
61321
  ownerIdProvider: () => ownerPrincipalId,
59661
61322
  now: () => Date.now()
59662
61323
  });
@@ -59678,7 +61339,7 @@ async function startDaemon(config) {
59678
61339
  getAdapter,
59679
61340
  historyReader: history,
59680
61341
  dataDir: config.dataDir,
59681
- personaRoot: import_node_path62.default.join(config.dataDir, "personas"),
61342
+ personaRoot: import_node_path63.default.join(config.dataDir, "personas"),
59682
61343
  // dispatch / shift 自动化 spawn 按 persona 绑定 tool 起 B session(codex persona 用 codex)。
59683
61344
  // personaRegistry 声明在 manager 之后(同作用域 const,调用时机在启动完成后,无 TDZ 风险)。
59684
61345
  getPersonaTool: (personaId2) => personaRegistry.get(personaId2)?.tool,
@@ -59729,7 +61390,7 @@ async function startDaemon(config) {
59729
61390
  // 文件可能 agent 写完又被自己删(罕见),用 size=0 / fallback mime 兜底。
59730
61391
  attachmentGroup: {
59731
61392
  onFileEdit: (input) => {
59732
- const absPath = import_node_path62.default.isAbsolute(input.relPath) ? input.relPath : import_node_path62.default.join(input.cwd, input.relPath);
61393
+ const absPath = import_node_path63.default.isAbsolute(input.relPath) ? input.relPath : import_node_path63.default.join(input.cwd, input.relPath);
59733
61394
  let size = 0;
59734
61395
  try {
59735
61396
  size = import_node_fs47.default.statSync(absPath).size;
@@ -59973,11 +61634,11 @@ async function startDaemon(config) {
59973
61634
  // 'persona/<pid>/owner',default 走 'default'。
59974
61635
  getSessionScope: (sid) => manager.findOwnedSessionScope(sid),
59975
61636
  // guest path guard:candidate 必须在 personaRoot 子树或调用者自己的 user-dir 下
59976
- personaRoot: import_node_path62.default.join(config.dataDir, "personas"),
61637
+ personaRoot: import_node_path63.default.join(config.dataDir, "personas"),
59977
61638
  usersRoot
59978
61639
  },
59979
61640
  // workspace/git/history/skills/agents handler 共用的 guest path guard 锚点
59980
- personaRoot: import_node_path62.default.join(config.dataDir, "personas"),
61641
+ personaRoot: import_node_path63.default.join(config.dataDir, "personas"),
59981
61642
  // v2 多人 persona 隔离:handler 派生 guest user-dir 放行
59982
61643
  usersRoot,
59983
61644
  // v2 Phase 6: whoami handler 装在 owner principal.displayName + persona 解析
@@ -60101,11 +61762,11 @@ async function startDaemon(config) {
60101
61762
  // 发布上线脚手架化 (spec 2026-06-03 §5.2):
60102
61763
  // appBuilderPersonaRoot 用于拼 publish.sh 绝对路径(persona-app-builder 安装在
60103
61764
  // dataDir/personas/persona-app-builder 之下,extension-kit/scripts/publish.sh 是相对路径)。
60104
- appBuilderPersonaRoot: import_node_path62.default.join(config.dataDir, "personas", "persona-app-builder"),
61765
+ appBuilderPersonaRoot: import_node_path63.default.join(config.dataDir, "personas", "persona-app-builder"),
60105
61766
  // 共享 deploy-kit 根:scaffold/publish 脚本骨架 + 阿里云凭证单一真源。
60106
- deployKitRoot: import_node_path62.default.join(config.dataDir, "deploy-kit"),
61767
+ deployKitRoot: import_node_path63.default.join(config.dataDir, "deploy-kit"),
60107
61768
  // scaffold/publish 按当前 session 的 persona 解析其安装根,让每个 persona 用自己的模板/注入配置。
60108
- resolvePersonaRoot: (personaId2) => import_node_path62.default.join(config.dataDir, "personas", personaId2),
61769
+ resolvePersonaRoot: (personaId2) => import_node_path63.default.join(config.dataDir, "personas", personaId2),
60109
61770
  // 发布上线脚手架化 (spec 2026-06-03 §5.2.2):
60110
61771
  // 复用 SessionManagerDeps.broadcastFrame 同款 dispatch 逻辑 —— runner 调 manager.send
60111
61772
  // 取回 broadcast 帧后逐帧 push 到 transport,跟 manager 自身的 deps 一致。
@@ -60146,19 +61807,7 @@ async function startDaemon(config) {
60146
61807
  sourceSessionId: args.sourceSessionId
60147
61808
  });
60148
61809
  const sourceFile = manager.findOwnedSession(args.sourceSessionId);
60149
- if (!sourceFile && !args.guestPrincipalId) {
60150
- throw new Error(`personaDispatch:run source session not found: ${args.sourceSessionId}`);
60151
- }
60152
- let sourceJsonlPath = "(no transcript yet \u2014 operate from the task description alone)";
60153
- if (sourceFile && sourceFile.toolSessionId) {
60154
- sourceJsonlPath = import_node_path62.default.join(
60155
- import_node_os22.default.homedir(),
60156
- ".claude",
60157
- "projects",
60158
- cwdToHashDir(sourceFile.cwd),
60159
- `${sourceFile.toolSessionId}.jsonl`
60160
- );
60161
- }
61810
+ const sourceJsonlPath = resolveSourceJsonlPath(sourceFile, import_node_os22.default.homedir());
60162
61811
  logger.info("dispatch.spawnB.source-resolved", {
60163
61812
  dispatchId: args.dispatchId,
60164
61813
  sourceJsonlPath,
@@ -60452,8 +62101,8 @@ async function startDaemon(config) {
60452
62101
  const lines = [
60453
62102
  `Tunnel: ${r.url}`,
60454
62103
  ...resolvedAuthToken ? [`Connect: ${connectUrl}`] : [],
60455
- `Frpc config: ${import_node_path62.default.join(config.dataDir, "frpc.toml")}`,
60456
- `Frpc log: ${import_node_path62.default.join(logDir, "frpc.log")}`
62104
+ `Frpc config: ${import_node_path63.default.join(config.dataDir, "frpc.toml")}`,
62105
+ `Frpc log: ${import_node_path63.default.join(logDir, "frpc.log")}`
60457
62106
  ];
60458
62107
  const width = Math.max(...lines.map((l) => l.length));
60459
62108
  const bar = "\u2550".repeat(width + 4);
@@ -60466,7 +62115,7 @@ ${bar}
60466
62115
 
60467
62116
  `);
60468
62117
  try {
60469
- const connectPath = import_node_path62.default.join(config.dataDir, "connect.txt");
62118
+ const connectPath = import_node_path63.default.join(config.dataDir, "connect.txt");
60470
62119
  import_node_fs47.default.writeFileSync(connectPath, lines.join("\n") + "\n", { mode: 384 });
60471
62120
  } catch {
60472
62121
  }
@@ -60539,7 +62188,7 @@ ${bar}
60539
62188
  };
60540
62189
  }
60541
62190
  function migrateDropPersonsDir(dataDir) {
60542
- const dir = import_node_path62.default.join(dataDir, "persons");
62191
+ const dir = import_node_path63.default.join(dataDir, "persons");
60543
62192
  try {
60544
62193
  import_node_fs47.default.rmSync(dir, { recursive: true, force: true });
60545
62194
  } catch {