@clawsaga/cli 0.1.22 → 0.1.24

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/bin/clawsaga.mjs CHANGED
@@ -19,9 +19,9 @@ var __commonJS = (cb, mod) => function __require2() {
19
19
  throw mod = 0, e;
20
20
  }
21
21
  };
22
- var __export = (target5, all) => {
22
+ var __export = (target2, all) => {
23
23
  for (var name in all)
24
- __defProp(target5, name, { get: all[name], enumerable: true });
24
+ __defProp(target2, name, { get: all[name], enumerable: true });
25
25
  };
26
26
  var __copyProps = (to, from, except, desc) => {
27
27
  if (from && typeof from === "object" || typeof from === "function") {
@@ -31,12 +31,12 @@ var __copyProps = (to, from, except, desc) => {
31
31
  }
32
32
  return to;
33
33
  };
34
- var __toESM = (mod, isNodeMode, target5) => (target5 = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
34
+ var __toESM = (mod, isNodeMode, target2) => (target2 = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
35
35
  // If the importer is in node compatibility mode or this is not an ESM
36
36
  // file that has been converted to a CommonJS file using a Babel-
37
37
  // compatible transform (i.e. "__esModule" has not been set), then set
38
38
  // "default" to the CommonJS "module.exports" for node compatibility.
39
- isNodeMode || !mod || !mod.__esModule ? __defProp(target5, "default", { value: mod, enumerable: true }) : target5,
39
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target2, "default", { value: mod, enumerable: true }) : target2,
40
40
  mod
41
41
  ));
42
42
 
@@ -248,8 +248,8 @@ var require_polyfills = __commonJS({
248
248
  }
249
249
  function chmodFix(orig) {
250
250
  if (!orig) return orig;
251
- return function(target5, mode, cb) {
252
- return orig.call(fs2, target5, mode, function(er) {
251
+ return function(target2, mode, cb) {
252
+ return orig.call(fs2, target2, mode, function(er) {
253
253
  if (chownErOk(er)) er = null;
254
254
  if (cb) cb.apply(this, arguments);
255
255
  });
@@ -257,9 +257,9 @@ var require_polyfills = __commonJS({
257
257
  }
258
258
  function chmodFixSync(orig) {
259
259
  if (!orig) return orig;
260
- return function(target5, mode) {
260
+ return function(target2, mode) {
261
261
  try {
262
- return orig.call(fs2, target5, mode);
262
+ return orig.call(fs2, target2, mode);
263
263
  } catch (er) {
264
264
  if (!chownErOk(er)) throw er;
265
265
  }
@@ -267,8 +267,8 @@ var require_polyfills = __commonJS({
267
267
  }
268
268
  function chownFix(orig) {
269
269
  if (!orig) return orig;
270
- return function(target5, uid, gid, cb) {
271
- return orig.call(fs2, target5, uid, gid, function(er) {
270
+ return function(target2, uid, gid, cb) {
271
+ return orig.call(fs2, target2, uid, gid, function(er) {
272
272
  if (chownErOk(er)) er = null;
273
273
  if (cb) cb.apply(this, arguments);
274
274
  });
@@ -276,9 +276,9 @@ var require_polyfills = __commonJS({
276
276
  }
277
277
  function chownFixSync(orig) {
278
278
  if (!orig) return orig;
279
- return function(target5, uid, gid) {
279
+ return function(target2, uid, gid) {
280
280
  try {
281
- return orig.call(fs2, target5, uid, gid);
281
+ return orig.call(fs2, target2, uid, gid);
282
282
  } catch (er) {
283
283
  if (!chownErOk(er)) throw er;
284
284
  }
@@ -286,7 +286,7 @@ var require_polyfills = __commonJS({
286
286
  }
287
287
  function statFix(orig) {
288
288
  if (!orig) return orig;
289
- return function(target5, options, cb) {
289
+ return function(target2, options, cb) {
290
290
  if (typeof options === "function") {
291
291
  cb = options;
292
292
  options = null;
@@ -298,13 +298,13 @@ var require_polyfills = __commonJS({
298
298
  }
299
299
  if (cb) cb.apply(this, arguments);
300
300
  }
301
- return options ? orig.call(fs2, target5, options, callback) : orig.call(fs2, target5, callback);
301
+ return options ? orig.call(fs2, target2, options, callback) : orig.call(fs2, target2, callback);
302
302
  };
303
303
  }
304
304
  function statFixSync(orig) {
305
305
  if (!orig) return orig;
306
- return function(target5, options) {
307
- var stats = options ? orig.call(fs2, target5, options) : orig.call(fs2, target5);
306
+ return function(target2, options) {
307
+ var stats = options ? orig.call(fs2, target2, options) : orig.call(fs2, target2);
308
308
  if (stats) {
309
309
  if (stats.uid < 0) stats.uid += 4294967296;
310
310
  if (stats.gid < 0) stats.gid += 4294967296;
@@ -3243,9 +3243,9 @@ Expecting one of '${allowedValues.join("', '")}'`);
3243
3243
  * @param {string} invalidArgumentMessage
3244
3244
  * @private
3245
3245
  */
3246
- _callParseArg(target5, value, previous, invalidArgumentMessage) {
3246
+ _callParseArg(target2, value, previous, invalidArgumentMessage) {
3247
3247
  try {
3248
- return target5.parseArg(value, previous);
3248
+ return target2.parseArg(value, previous);
3249
3249
  } catch (err) {
3250
3250
  if (err.code === "commander.invalidArgument") {
3251
3251
  const message = `${invalidArgumentMessage} ${err.message}`;
@@ -3534,13 +3534,13 @@ Expecting one of '${allowedValues.join("', '")}'`);
3534
3534
  * @param {string} source - expected values are default/config/env/cli/implied
3535
3535
  * @return {Command} `this` command for chaining
3536
3536
  */
3537
- setOptionValueWithSource(key, value, source2) {
3537
+ setOptionValueWithSource(key, value, source) {
3538
3538
  if (this._storeOptionsAsProperties) {
3539
3539
  this[key] = value;
3540
3540
  } else {
3541
3541
  this._optionValues[key] = value;
3542
3542
  }
3543
- this._optionValueSources[key] = source2;
3543
+ this._optionValueSources[key] = source;
3544
3544
  return this;
3545
3545
  }
3546
3546
  /**
@@ -3561,13 +3561,13 @@ Expecting one of '${allowedValues.join("', '")}'`);
3561
3561
  * @return {string}
3562
3562
  */
3563
3563
  getOptionValueSourceWithGlobals(key) {
3564
- let source2;
3564
+ let source;
3565
3565
  this._getCommandAndAncestors().forEach((cmd) => {
3566
3566
  if (cmd.getOptionValueSource(key) !== void 0) {
3567
- source2 = cmd.getOptionValueSource(key);
3567
+ source = cmd.getOptionValueSource(key);
3568
3568
  }
3569
3569
  });
3570
- return source2;
3570
+ return source;
3571
3571
  }
3572
3572
  /**
3573
3573
  * Get user arguments from implied or explicit arguments.
@@ -4434,10 +4434,10 @@ Expecting one of '${allowedValues.join("', '")}'`);
4434
4434
  const optionKey2 = option2.attributeName();
4435
4435
  const optionValue = this.getOptionValue(optionKey2);
4436
4436
  const negativeOption = this.options.find(
4437
- (target5) => target5.negate && optionKey2 === target5.attributeName()
4437
+ (target2) => target2.negate && optionKey2 === target2.attributeName()
4438
4438
  );
4439
4439
  const positiveOption = this.options.find(
4440
- (target5) => !target5.negate && optionKey2 === target5.attributeName()
4440
+ (target2) => !target2.negate && optionKey2 === target2.attributeName()
4441
4441
  );
4442
4442
  if (negativeOption && (negativeOption.presetArg === void 0 && optionValue === false || negativeOption.presetArg !== void 0 && optionValue === negativeOption.presetArg)) {
4443
4443
  return negativeOption;
@@ -4447,8 +4447,8 @@ Expecting one of '${allowedValues.join("', '")}'`);
4447
4447
  const getErrorMessage = (option2) => {
4448
4448
  const bestOption = findBestOptionFromValue(option2);
4449
4449
  const optionKey2 = bestOption.attributeName();
4450
- const source2 = this.getOptionValueSource(optionKey2);
4451
- if (source2 === "env") {
4450
+ const source = this.getOptionValueSource(optionKey2);
4451
+ if (source === "env") {
4452
4452
  return `environment variable '${bestOption.envVar}'`;
4453
4453
  }
4454
4454
  return `option '${bestOption.flags}'`;
@@ -5674,10 +5674,10 @@ function cached(getter) {
5674
5674
  function nullish(input2) {
5675
5675
  return input2 === null || input2 === void 0;
5676
5676
  }
5677
- function cleanRegex(source2) {
5678
- const start = source2.startsWith("^") ? 1 : 0;
5679
- const end = source2.endsWith("$") ? source2.length - 1 : source2.length;
5680
- return source2.slice(start, end);
5677
+ function cleanRegex(source) {
5678
+ const start = source.startsWith("^") ? 1 : 0;
5679
+ const end = source.endsWith("$") ? source.length - 1 : source.length;
5680
+ return source.slice(start, end);
5681
5681
  }
5682
5682
  function floatSafeRemainder(val, step) {
5683
5683
  const ratio = val / step;
@@ -5713,8 +5713,8 @@ function defineLazy(object2, key, getter) {
5713
5713
  function objectClone(obj) {
5714
5714
  return Object.create(Object.getPrototypeOf(obj), Object.getOwnPropertyDescriptors(obj));
5715
5715
  }
5716
- function assignProp(target5, prop, value) {
5717
- Object.defineProperty(target5, prop, {
5716
+ function assignProp(target2, prop, value) {
5717
+ Object.defineProperty(target2, prop, {
5718
5718
  value,
5719
5719
  writable: true,
5720
5720
  enumerable: true,
@@ -5897,35 +5897,35 @@ function normalizeParams(_params) {
5897
5897
  return params;
5898
5898
  }
5899
5899
  function createTransparentProxy(getter) {
5900
- let target5;
5900
+ let target2;
5901
5901
  return new Proxy({}, {
5902
5902
  get(_, prop, receiver) {
5903
- target5 ?? (target5 = getter());
5904
- return Reflect.get(target5, prop, receiver);
5903
+ target2 ?? (target2 = getter());
5904
+ return Reflect.get(target2, prop, receiver);
5905
5905
  },
5906
5906
  set(_, prop, value, receiver) {
5907
- target5 ?? (target5 = getter());
5908
- return Reflect.set(target5, prop, value, receiver);
5907
+ target2 ?? (target2 = getter());
5908
+ return Reflect.set(target2, prop, value, receiver);
5909
5909
  },
5910
5910
  has(_, prop) {
5911
- target5 ?? (target5 = getter());
5912
- return Reflect.has(target5, prop);
5911
+ target2 ?? (target2 = getter());
5912
+ return Reflect.has(target2, prop);
5913
5913
  },
5914
5914
  deleteProperty(_, prop) {
5915
- target5 ?? (target5 = getter());
5916
- return Reflect.deleteProperty(target5, prop);
5915
+ target2 ?? (target2 = getter());
5916
+ return Reflect.deleteProperty(target2, prop);
5917
5917
  },
5918
5918
  ownKeys(_) {
5919
- target5 ?? (target5 = getter());
5920
- return Reflect.ownKeys(target5);
5919
+ target2 ?? (target2 = getter());
5920
+ return Reflect.ownKeys(target2);
5921
5921
  },
5922
5922
  getOwnPropertyDescriptor(_, prop) {
5923
- target5 ?? (target5 = getter());
5924
- return Reflect.getOwnPropertyDescriptor(target5, prop);
5923
+ target2 ?? (target2 = getter());
5924
+ return Reflect.getOwnPropertyDescriptor(target2, prop);
5925
5925
  },
5926
5926
  defineProperty(_, prop, descriptor) {
5927
- target5 ?? (target5 = getter());
5928
- return Reflect.defineProperty(target5, prop, descriptor);
5927
+ target2 ?? (target2 = getter());
5928
+ return Reflect.defineProperty(target2, prop, descriptor);
5929
5929
  }
5930
5930
  });
5931
5931
  }
@@ -6447,10 +6447,10 @@ function $constructor(name, initializer3, proto, params) {
6447
6447
  let up = own2;
6448
6448
  while (up && up !== ctorProto)
6449
6449
  up = Object.getPrototypeOf(up);
6450
- const target5 = up ?? own2;
6451
- if (!initialized.has(target5)) {
6452
- initialized.add(target5);
6453
- members(target5, protoMembers);
6450
+ const target2 = up ?? own2;
6451
+ if (!initialized.has(target2)) {
6452
+ initialized.add(target2);
6453
+ members(target2, protoMembers);
6454
6454
  }
6455
6455
  }
6456
6456
  const proto2 = _.prototype;
@@ -6962,8 +6962,8 @@ var httpProtocol = /^https?$/;
6962
6962
  var e164 = /^\+[1-9]\d{6,14}$/;
6963
6963
  var creditCard = /^\d(?:[ -]?\d){11,18}$/;
6964
6964
  var dateSource = `(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))`;
6965
- function anchor(source2) {
6966
- return new RegExp(`^${source2}$`);
6965
+ function anchor(source) {
6966
+ return new RegExp(`^${source}$`);
6967
6967
  }
6968
6968
  var date = /* @__PURE__ */ anchor(dateSource);
6969
6969
  function timeSource(args) {
@@ -9698,12 +9698,12 @@ var $ZodTemplateLiteral = /* @__PURE__ */ $constructor("$ZodTemplateLiteral", (i
9698
9698
  if (!part._zod.pattern) {
9699
9699
  throw new Error(`Invalid template literal part, no pattern found: ${[...part._zod.traits].shift()}`);
9700
9700
  }
9701
- const source2 = part._zod.pattern instanceof RegExp ? part._zod.pattern.source : part._zod.pattern;
9702
- if (!source2)
9701
+ const source = part._zod.pattern instanceof RegExp ? part._zod.pattern.source : part._zod.pattern;
9702
+ if (!source)
9703
9703
  throw new Error(`Invalid template literal part: ${part._zod.traits}`);
9704
- const start = source2.startsWith("^") ? 1 : 0;
9705
- const end = source2.endsWith("$") ? source2.length - 1 : source2.length;
9706
- regexParts.push(source2.slice(start, end));
9704
+ const start = source.startsWith("^") ? 1 : 0;
9705
+ const end = source.endsWith("$") ? source.length - 1 : source.length;
9706
+ regexParts.push(source.slice(start, end));
9707
9707
  } else if (part === null || primitiveTypes.has(typeof part)) {
9708
9708
  regexParts.push(escapeRegex(`${part}`));
9709
9709
  } else {
@@ -17547,9 +17547,9 @@ function compile(schema, options) {
17547
17547
  return schema;
17548
17548
  }
17549
17549
  }
17550
- function installCompiledUserMethods(target5, source2, parser) {
17551
- const targetAny = target5;
17552
- const sourceAny = source2;
17550
+ function installCompiledUserMethods(target2, source, parser) {
17551
+ const targetAny = target2;
17552
+ const sourceAny = source;
17553
17553
  if (typeof sourceAny.safeParse === "function") {
17554
17554
  const originalSafeParse = sourceAny.safeParse;
17555
17555
  targetAny.safeParse = (data, params) => {
@@ -20089,26 +20089,26 @@ function _stringFormat(Class2, format, fnOrRegex, _params = {}) {
20089
20089
  }
20090
20090
 
20091
20091
  // node_modules/.pnpm/zod@4.5.4/node_modules/zod/v4/core/to-json-schema.js
20092
- function assignProps(target5, ...sources) {
20093
- for (const source2 of sources) {
20094
- for (const key of Reflect.ownKeys(source2)) {
20095
- if (Object.prototype.propertyIsEnumerable.call(source2, key)) {
20096
- assignProp(target5, key, source2[key]);
20092
+ function assignProps(target2, ...sources) {
20093
+ for (const source of sources) {
20094
+ for (const key of Reflect.ownKeys(source)) {
20095
+ if (Object.prototype.propertyIsEnumerable.call(source, key)) {
20096
+ assignProp(target2, key, source[key]);
20097
20097
  }
20098
20098
  }
20099
20099
  }
20100
- return target5;
20100
+ return target2;
20101
20101
  }
20102
20102
  function initializeContext(params) {
20103
- let target5 = params?.target ?? "draft-2020-12";
20104
- if (target5 === "draft-4")
20105
- target5 = "draft-04";
20106
- if (target5 === "draft-7")
20107
- target5 = "draft-07";
20103
+ let target2 = params?.target ?? "draft-2020-12";
20104
+ if (target2 === "draft-4")
20105
+ target2 = "draft-04";
20106
+ if (target2 === "draft-7")
20107
+ target2 = "draft-07";
20108
20108
  return {
20109
20109
  processors: params.processors ?? {},
20110
20110
  metadataRegistry: params?.metadata ?? globalRegistry,
20111
- target: target5,
20111
+ target: target2,
20112
20112
  unrepresentable: params?.unrepresentable ?? "throw",
20113
20113
  override: params?.override ?? (() => {
20114
20114
  }),
@@ -20612,8 +20612,8 @@ var createToJSONSchemaMethod = (schema, processors = {}) => (params) => {
20612
20612
  return finalize(ctx, schema);
20613
20613
  };
20614
20614
  var createStandardJSONSchemaMethod = (schema, io, processors = {}) => (params) => {
20615
- const { libraryOptions, target: target5 } = params ?? {};
20616
- const ctx = initializeContext({ ...libraryOptions ?? {}, target: target5, io, processors });
20615
+ const { libraryOptions, target: target2 } = params ?? {};
20616
+ const ctx = initializeContext({ ...libraryOptions ?? {}, target: target2, io, processors });
20617
20617
  process3(schema, ctx);
20618
20618
  extractDefs(ctx, schema);
20619
20619
  return finalize(ctx, schema);
@@ -21713,8 +21713,8 @@ var ZodType = /* @__PURE__ */ $constructor("ZodType", (inst, def) => {
21713
21713
  catch(params) {
21714
21714
  return _catch2(this, params);
21715
21715
  },
21716
- pipe(target5) {
21717
- return pipe(this, target5);
21716
+ pipe(target2) {
21717
+ return pipe(this, target2);
21718
21718
  },
21719
21719
  readonly() {
21720
21720
  return readonly(this);
@@ -23861,6 +23861,10 @@ var unicodeTextSchema = external_exports.string().regex(/^[^\0\p{Cs}]*$/u, "Use
23861
23861
  var localeSchema = external_exports.enum(["ja", "en"]);
23862
23862
  var jobSchema = external_exports.enum(["warrior", "rogue", "mage", "priest", "bard"]);
23863
23863
  var characterIdSchema = external_exports.string().regex(/^[A-Za-z0-9_-]{12}$/);
23864
+ var characterTarget = {
23865
+ character_id: characterIdSchema,
23866
+ locale: localeSchema.optional()
23867
+ };
23864
23868
  var discriminatorSchema = external_exports.string().regex(/^[0-9]{4}$/);
23865
23869
  var uuidSchema = external_exports.uuid();
23866
23870
  var activityIdSchema = external_exports.number().int().min(1);
@@ -23952,12 +23956,12 @@ var guideResponseSchema = external_exports.looseObject({
23952
23956
  guide: external_exports.looseObject({})
23953
23957
  });
23954
23958
  var agentResumeResponseSchema = external_exports.looseObject({
23955
- resume: external_exports.looseObject({})
23959
+ resume: external_exports.looseObject({ body: external_exports.string() })
23956
23960
  });
23957
23961
  var changelogResponseSchema = external_exports.looseObject({
23958
23962
  changelog: external_exports.looseObject({})
23959
23963
  });
23960
- var agentSchemaVersion = "3.14";
23964
+ var agentSchemaVersion = "3.15";
23961
23965
  var agentGameResponseSchema = external_exports.looseObject({
23962
23966
  ok: external_exports.boolean(),
23963
23967
  schema_version: external_exports.literal(agentSchemaVersion),
@@ -24002,45 +24006,43 @@ var getActivitySchema = external_exports.object({
24002
24006
  }).strict();
24003
24007
 
24004
24008
  // src/protocol/production.ts
24005
- var common2 = {
24006
- character_id: characterIdSchema,
24007
- locale: localeSchema.optional()
24008
- };
24009
- var gatherSchema = external_exports.object({ ...common2, item_id: itemIdSchema }).strict();
24009
+ var gatherSchema = external_exports.object({ ...characterTarget, item_id: itemIdSchema }).strict();
24010
24010
  var getRecipesSchema = external_exports.object({
24011
- ...common2,
24011
+ ...characterTarget,
24012
24012
  location_id: locationIdSchema.optional(),
24013
24013
  skill_id: skillIdSchema.optional(),
24014
24014
  recipe_id: external_exports.string().min(1).optional()
24015
24015
  }).strict();
24016
24016
  var getItemsSchema = external_exports.object({
24017
- ...common2,
24017
+ ...characterTarget,
24018
24018
  query: external_exports.string().min(1).optional(),
24019
24019
  item_id: itemIdSchema.optional()
24020
24020
  }).strict();
24021
24021
  var craftSchema = external_exports.object({
24022
- ...common2,
24022
+ ...characterTarget,
24023
24023
  recipe_id: external_exports.string().min(1),
24024
24024
  max_fee_per_lot: external_exports.number().int().min(0).optional(),
24025
24025
  request_id: external_exports.uuid()
24026
24026
  }).strict();
24027
- var stopActivitySchema = external_exports.object({ ...common2, activity_id: activityIdSchema }).strict();
24028
- var getShopSchema = external_exports.object(common2).strict();
24027
+ var stopActivitySchema = external_exports.object({ ...characterTarget, activity_id: activityIdSchema }).strict();
24028
+ var getShopSchema = external_exports.object(characterTarget).strict();
24029
24029
  var buySchema = external_exports.object({
24030
- ...common2,
24030
+ ...characterTarget,
24031
24031
  item_id: itemIdSchema,
24032
24032
  quantity: external_exports.number().int().positive().optional(),
24033
24033
  max_payment: external_exports.number().int().min(0).optional(),
24034
24034
  request_id: external_exports.uuid()
24035
24035
  }).strict();
24036
- var equipSchema = external_exports.object({ ...common2, instance_id: instanceIdSchema }).strict();
24036
+ var equipSchema = external_exports.object({ ...characterTarget, instance_id: instanceIdSchema }).strict();
24037
+ var repairMethodSchema = external_exports.enum(["kit", "npc"]);
24037
24038
  var repairSchema = external_exports.object({
24038
- ...common2,
24039
+ ...characterTarget,
24039
24040
  instance_id: instanceIdSchema,
24040
- method: external_exports.enum(["kit", "npc"])
24041
+ method: repairMethodSchema
24041
24042
  }).strict();
24043
+ var expandBagSchema = external_exports.object({ ...characterTarget, tier: external_exports.number().int().min(1) }).strict();
24042
24044
  var discardItemSchema = external_exports.object({
24043
- ...common2,
24045
+ ...characterTarget,
24044
24046
  target: external_exports.discriminatedUnion("kind", [
24045
24047
  external_exports.object({
24046
24048
  kind: external_exports.literal("stack"),
@@ -24055,10 +24057,6 @@ var discardItemSchema = external_exports.object({
24055
24057
  }).strict();
24056
24058
 
24057
24059
  // src/protocol/combat.ts
24058
- var target2 = {
24059
- character_id: characterIdSchema,
24060
- locale: localeSchema.optional()
24061
- };
24062
24060
  var combatIdSchema = external_exports.string().regex(/^[a-z][a-z0-9_]{0,63}$/);
24063
24061
  var damageTypeSchema = external_exports.enum([
24064
24062
  "physical",
@@ -24138,73 +24136,81 @@ var tacticSchema = external_exports.object({
24138
24136
  )
24139
24137
  }).strict().meta({ id: "Tactic" });
24140
24138
  var presetIdSchema = external_exports.enum(["safe", "aggressive"]);
24141
- var getTacticsSchema = external_exports.object(target2).strict();
24142
- var setTacticsSchema = external_exports.object({ ...target2, tactic: tacticSchema }).strict();
24139
+ var getTacticsSchema = external_exports.object(characterTarget).strict();
24140
+ var setTacticsSchema = external_exports.object({ ...characterTarget, tactic: tacticSchema }).strict();
24143
24141
  var validateTacticsSchema = setTacticsSchema;
24144
24142
  var startCombatSchema = external_exports.object({
24145
- ...target2,
24143
+ ...characterTarget,
24146
24144
  enemy_id: combatIdSchema,
24147
24145
  preset: presetIdSchema.optional(),
24148
24146
  tactic: tacticSchema.optional(),
24149
24147
  practice: external_exports.boolean().optional()
24150
24148
  }).strict();
24151
- var restSchema = external_exports.object(target2).strict();
24149
+ var restSchema = external_exports.object(characterTarget).strict();
24152
24150
  var stayAtInnSchema = restSchema;
24153
24151
  var useItemSchema = external_exports.object({
24154
- ...target2,
24152
+ ...characterTarget,
24155
24153
  item_id: itemIdSchema,
24156
24154
  count: external_exports.number().int().positive().optional().meta({
24157
24155
  description: "Maximum number of this item to use in this one call (default 1). The server uses only as many as still recover HP or MP, limited by the quantity you carry across qualities, and reports the number in used_item."
24158
24156
  })
24159
24157
  }).strict();
24160
- var changeJobSchema = external_exports.object({ ...target2, job_id: jobSchema }).strict();
24158
+ var changeJobSchema = external_exports.object({ ...characterTarget, job_id: jobSchema }).strict();
24161
24159
  var combatReportIncludeSchema = external_exports.enum(["frames", "preparation"]);
24162
24160
  var getCombatReportSchema = external_exports.object({
24163
- ...target2,
24161
+ ...characterTarget,
24164
24162
  activity_id: activityIdSchema,
24165
24163
  include: external_exports.array(combatReportIncludeSchema).optional()
24166
24164
  }).strict();
24167
- var getEncountersSchema = external_exports.object(target2).strict();
24168
- var getLostItemsSchema = external_exports.object(target2).strict();
24169
- var recoverLostItemsSchema = external_exports.object({ ...target2, drop_id: dropIdSchema }).strict();
24165
+ var getEncountersSchema = external_exports.object(characterTarget).strict();
24166
+ var getLostItemsSchema = external_exports.object(characterTarget).strict();
24167
+ var recoverLostItemsSchema = external_exports.object({ ...characterTarget, drop_id: dropIdSchema }).strict();
24170
24168
 
24171
24169
  // src/protocol/quests.ts
24172
- var target3 = {
24173
- character_id: characterIdSchema,
24174
- locale: localeSchema.optional()
24175
- };
24176
24170
  var getQuestsSchema = external_exports.object({
24177
- ...target3,
24171
+ ...characterTarget,
24178
24172
  before: external_exports.number().int().positive().optional(),
24179
24173
  active_only: external_exports.boolean().optional()
24180
24174
  }).strict();
24181
- var getQuestBoardSchema = external_exports.object(target3).strict();
24175
+ var getQuestBoardSchema = external_exports.object(characterTarget).strict();
24182
24176
  var questNumber = external_exports.number().int().min(1);
24183
24177
  var acceptQuestSchema = external_exports.object({
24184
- ...target3,
24178
+ ...characterTarget,
24185
24179
  offer_id: uuidSchema.optional(),
24186
- fixed_quest_id: external_exports.string().regex(/^[a-z][a-z0-9_]{0,63}$/).optional()
24180
+ fixed_quest_id: external_exports.string().regex(/^[a-z][a-z0-9_]{0,63}$/).optional(),
24181
+ goal_id: questNumber.optional()
24187
24182
  }).strict().refine(
24188
- (input2) => input2.offer_id !== void 0 !== (input2.fixed_quest_id !== void 0),
24189
- { message: "Supply exactly one of offer_id and fixed_quest_id" }
24183
+ (input2) => [input2.offer_id, input2.fixed_quest_id, input2.goal_id].filter(
24184
+ (source) => source !== void 0
24185
+ ).length === 1,
24186
+ { message: "Supply exactly one of offer_id, fixed_quest_id and goal_id" }
24190
24187
  );
24191
- var claimQuestSchema = external_exports.object({ ...target3, quest_number: questNumber }).strict();
24192
- var discardQuestSchema = external_exports.object({ ...target3, quest_number: questNumber }).strict();
24188
+ var deliverGoalSchema = external_exports.object({
24189
+ ...characterTarget,
24190
+ goal_id: questNumber,
24191
+ item_id: itemIdSchema,
24192
+ quantity: questNumber
24193
+ }).strict();
24194
+ var claimQuestSchema = external_exports.object({
24195
+ ...characterTarget,
24196
+ quest_number: questNumber.optional(),
24197
+ goal_id: questNumber.optional()
24198
+ }).strict().refine(
24199
+ (input2) => input2.quest_number !== void 0 !== (input2.goal_id !== void 0),
24200
+ { message: "Supply exactly one of quest_number and goal_id" }
24201
+ );
24202
+ var discardQuestSchema = external_exports.object({ ...characterTarget, quest_number: questNumber }).strict();
24193
24203
 
24194
24204
  // src/protocol/social.ts
24195
- var target4 = {
24196
- character_id: characterIdSchema,
24197
- locale: localeSchema.optional()
24198
- };
24199
24205
  var cursor = external_exports.number().int().min(1);
24200
24206
  var text = unicodeTextSchema.min(1);
24201
- var sendMonologueSchema = external_exports.object({ ...target4, text, language: localeSchema }).strict();
24207
+ var sendMonologueSchema = external_exports.object({ ...characterTarget, text, language: localeSchema }).strict();
24202
24208
  var contentReferenceSchema = external_exports.object({
24203
24209
  kind: external_exports.enum(["activity", "quest", "item", "character", "location"]),
24204
24210
  id: unicodeTextSchema.min(1)
24205
24211
  }).strict();
24206
24212
  var journalFields = {
24207
- ...target4,
24213
+ ...characterTarget,
24208
24214
  request_id: uuidSchema,
24209
24215
  text,
24210
24216
  language: localeSchema,
@@ -24216,14 +24222,14 @@ var endSessionSchema = external_exports.object({
24216
24222
  activity_policy: external_exports.enum(["continue", "stop_at_boundary"])
24217
24223
  }).strict();
24218
24224
  var getJournalsSchema = external_exports.object({
24219
- ...target4,
24225
+ ...characterTarget,
24220
24226
  before: cursor.optional(),
24221
24227
  query: unicodeTextSchema.optional(),
24222
24228
  journal_number: cursor.optional()
24223
24229
  }).strict();
24224
- var getPlanSchema = external_exports.object(target4).strict();
24230
+ var getPlanSchema = external_exports.object(characterTarget).strict();
24225
24231
  var updatePlanSchema = external_exports.object({
24226
- ...target4,
24232
+ ...characterTarget,
24227
24233
  text: unicodeTextSchema,
24228
24234
  language: localeSchema
24229
24235
  }).strict();
@@ -24233,38 +24239,38 @@ var messagePage = {
24233
24239
  limit: external_exports.number().int().min(1).optional()
24234
24240
  };
24235
24241
  var getChatSchema = external_exports.object({
24236
- ...target4,
24242
+ ...characterTarget,
24237
24243
  ...messagePage
24238
24244
  }).strict();
24239
24245
  var sendChatSchema = external_exports.object({
24240
- ...target4,
24246
+ ...characterTarget,
24241
24247
  text,
24242
24248
  language: localeSchema,
24243
24249
  references: external_exports.array(contentReferenceSchema).optional()
24244
24250
  }).strict();
24245
24251
  var getDirectMessagesSchema = external_exports.object({
24246
- ...target4,
24252
+ ...characterTarget,
24247
24253
  ...messagePage,
24248
24254
  with_character_id: characterIdSchema.optional(),
24249
24255
  unread_only: external_exports.boolean().optional()
24250
24256
  }).strict();
24251
24257
  var getDirectConversationsSchema = external_exports.object({
24252
- ...target4,
24258
+ ...characterTarget,
24253
24259
  before: cursor.optional(),
24254
24260
  limit: external_exports.number().int().min(1).optional()
24255
24261
  }).strict();
24256
24262
  var sendDirectMessageSchema = external_exports.object({
24257
- ...target4,
24263
+ ...characterTarget,
24258
24264
  recipient_character_id: characterIdSchema,
24259
24265
  text,
24260
24266
  language: localeSchema
24261
24267
  }).strict();
24262
24268
  var getNewsSchema = external_exports.object({
24263
- ...target4,
24269
+ ...characterTarget,
24264
24270
  before: cursor.optional(),
24265
24271
  limit: external_exports.number().int().min(1).optional()
24266
24272
  }).strict();
24267
- var getNewsArticleSchema = external_exports.object({ ...target4, number: cursor }).strict();
24273
+ var getNewsArticleSchema = external_exports.object({ ...characterTarget, number: cursor }).strict();
24268
24274
  var boardCategorySchema = external_exports.enum([
24269
24275
  "general",
24270
24276
  "strategy",
@@ -24273,7 +24279,7 @@ var boardCategorySchema = external_exports.enum([
24273
24279
  "trade"
24274
24280
  ]);
24275
24281
  var listBoardThreadsSchema = external_exports.object({
24276
- ...target4,
24282
+ ...characterTarget,
24277
24283
  category: boardCategorySchema.optional(),
24278
24284
  language: localeSchema.optional(),
24279
24285
  authored_by_self: external_exports.boolean().optional(),
@@ -24284,29 +24290,25 @@ var listBoardThreadsSchema = external_exports.object({
24284
24290
  limit: external_exports.number().int().min(1).optional()
24285
24291
  }).strict();
24286
24292
  var readBoardThreadSchema = external_exports.object({
24287
- ...target4,
24293
+ ...characterTarget,
24288
24294
  thread_number: cursor,
24289
24295
  after: external_exports.number().int().nonnegative().optional(),
24290
24296
  limit: external_exports.number().int().min(1).optional()
24291
24297
  }).strict();
24292
24298
  var createBoardThreadSchema = external_exports.object({
24293
- ...target4,
24299
+ ...characterTarget,
24294
24300
  category: boardCategorySchema,
24295
24301
  title: text,
24296
24302
  body: text,
24297
24303
  language: localeSchema.optional()
24298
24304
  }).strict();
24299
24305
  var replyBoardThreadSchema = external_exports.object({
24300
- ...target4,
24306
+ ...characterTarget,
24301
24307
  thread_number: cursor,
24302
24308
  body: text
24303
24309
  }).strict();
24304
24310
 
24305
24311
  // src/protocol/storage.ts
24306
- var common3 = {
24307
- character_id: characterIdSchema,
24308
- locale: localeSchema.optional()
24309
- };
24310
24312
  var stackTransferSchema = external_exports.object({
24311
24313
  item_id: itemIdSchema,
24312
24314
  quality: external_exports.enum(["standard", "fine", "superior"]).optional(),
@@ -24314,80 +24316,81 @@ var stackTransferSchema = external_exports.object({
24314
24316
  }).strict();
24315
24317
  var individualTransferSchema = external_exports.object({ instance_id: external_exports.string().toLowerCase().pipe(instanceIdSchema) }).strict();
24316
24318
  var storageTransferItemsSchema = external_exports.array(external_exports.union([stackTransferSchema, individualTransferSchema])).min(1);
24317
- var getStorageSchema = external_exports.object({ ...common3, town_id: locationIdSchema }).strict();
24318
- var searchStorageSchema = external_exports.object({ ...common3, query: unicodeTextSchema }).strict();
24319
+ var getStorageSchema = external_exports.object({ ...characterTarget, town_id: locationIdSchema }).strict();
24320
+ var searchStorageSchema = external_exports.object({ ...characterTarget, query: unicodeTextSchema }).strict();
24319
24321
  var depositItemsSchema = external_exports.object({
24320
- ...common3,
24322
+ ...characterTarget,
24321
24323
  town_id: locationIdSchema,
24322
24324
  request_id: uuidSchema,
24323
24325
  items: storageTransferItemsSchema
24324
24326
  }).strict();
24325
24327
  var withdrawItemsSchema = external_exports.object({
24326
- ...common3,
24328
+ ...characterTarget,
24327
24329
  town_id: locationIdSchema,
24328
24330
  request_id: uuidSchema,
24329
24331
  items: storageTransferItemsSchema
24330
24332
  }).strict();
24331
24333
 
24332
24334
  // src/protocol/gift.ts
24333
- var common4 = {
24334
- character_id: characterIdSchema,
24335
- locale: localeSchema.optional()
24336
- };
24337
24335
  var sendGiftSchema = external_exports.object({
24338
- ...common4,
24336
+ ...characterTarget,
24339
24337
  recipient_character_id: characterIdSchema,
24340
24338
  request_id: uuidSchema,
24341
24339
  items: storageTransferItemsSchema.optional(),
24342
24340
  gold: external_exports.number().int().min(1).optional()
24343
24341
  }).strict();
24344
- var claimGiftsSchema = external_exports.object(common4).strict();
24345
- var getGiftsSchema = external_exports.object({ ...common4, cursor: external_exports.number().int().positive().optional() }).strict();
24342
+ var claimGiftsSchema = external_exports.object(characterTarget).strict();
24343
+ var getGiftsSchema = external_exports.object({
24344
+ ...characterTarget,
24345
+ cursor: external_exports.number().int().positive().optional()
24346
+ }).strict();
24346
24347
 
24347
24348
  // src/protocol/market.ts
24348
- var common5 = {
24349
- character_id: characterIdSchema,
24350
- locale: localeSchema.optional()
24351
- };
24352
- var change = { ...common5, request_id: uuidSchema };
24353
- var quality = external_exports.enum(["standard", "fine", "superior"]);
24349
+ var change = { ...characterTarget, request_id: uuidSchema };
24350
+ var marketQualitySchema = external_exports.enum(["standard", "fine", "superior"]);
24354
24351
  var price = external_exports.number().int().positive();
24355
24352
  var quantity = external_exports.number().int().positive();
24356
24353
  var number4 = external_exports.number().int().positive();
24357
- var source = external_exports.enum(["carried", "storage"]);
24354
+ var marketSourceSchema = external_exports.enum(["carried", "storage"]);
24355
+ var marketSectionSchema = external_exports.enum(["orders", "listings", "trades"]);
24358
24356
  var getMarketSchema = external_exports.object({
24359
- ...common5,
24357
+ ...characterTarget,
24360
24358
  town_id: locationIdSchema,
24361
24359
  item_id: itemIdSchema.optional(),
24362
- quality: quality.optional(),
24360
+ quality: marketQualitySchema.optional(),
24363
24361
  levels: external_exports.number().int().min(1).optional(),
24364
24362
  cursor: external_exports.number().int().positive().optional(),
24365
24363
  max_price: price.optional(),
24366
24364
  minimum_durability: external_exports.number().int().nonnegative().optional()
24367
24365
  }).strict();
24368
24366
  var getMyMarketSchema = external_exports.object({
24369
- ...common5,
24370
- section: external_exports.enum(["orders", "listings", "trades"]).optional(),
24367
+ ...characterTarget,
24368
+ section: marketSectionSchema.optional(),
24371
24369
  cursor: external_exports.number().int().positive().optional()
24372
24370
  }).strict();
24373
24371
  var placeMarketSellOrderSchema = external_exports.object({
24374
24372
  ...change,
24375
24373
  item_id: itemIdSchema,
24376
- quality,
24374
+ quality: marketQualitySchema,
24377
24375
  quantity,
24378
24376
  unit_price: price,
24379
- source
24377
+ source: marketSourceSchema
24380
24378
  }).strict();
24381
24379
  var placeMarketBuyOrderSchema = external_exports.object({
24382
24380
  ...change,
24383
24381
  item_id: itemIdSchema,
24384
- quality,
24382
+ quality: marketQualitySchema,
24385
24383
  quantity,
24386
24384
  unit_price: price
24387
24385
  }).strict();
24388
24386
  var cancelMarketOrderSchema = external_exports.object({ ...change, order_id: number4 }).strict();
24389
24387
  var claimMarketOrderSchema = cancelMarketOrderSchema;
24390
- var createMarketListingSchema = external_exports.object({ ...change, instance_id: instanceIdSchema, price, source }).strict();
24388
+ var createMarketListingSchema = external_exports.object({
24389
+ ...change,
24390
+ instance_id: instanceIdSchema,
24391
+ price,
24392
+ source: marketSourceSchema
24393
+ }).strict();
24391
24394
  var buyMarketListingSchema = external_exports.object({
24392
24395
  ...change,
24393
24396
  listing_id: number4,
@@ -24442,6 +24445,9 @@ var CliError = class extends Error {
24442
24445
  code;
24443
24446
  detail;
24444
24447
  };
24448
+ function invalidArguments(fields, message) {
24449
+ return new CliError("INVALID_ARGUMENTS", { fields, message });
24450
+ }
24445
24451
  function cliFailure(error61) {
24446
24452
  const failure = error61 instanceof CliError ? error61 : new CliError("CLIENT_ERROR");
24447
24453
  const { message, ...detail } = failure.detail;
@@ -24495,8 +24501,9 @@ var CredentialStore = class {
24495
24501
  try {
24496
24502
  return storeSchema.parse(JSON.parse(await readFile(this.path, "utf8")));
24497
24503
  } catch (error61) {
24498
- if (error61 instanceof Error && "code" in error61 && error61.code === "ENOENT")
24504
+ if (error61 instanceof Error && "code" in error61 && error61.code === "ENOENT") {
24499
24505
  return {};
24506
+ }
24500
24507
  throw error61;
24501
24508
  }
24502
24509
  }
@@ -24569,6 +24576,9 @@ var retryAfterSchema = external_exports.object({
24569
24576
  var schemaVersionSchema = external_exports.object({ schema_version: external_exports.string() });
24570
24577
  var [supportedSchemaMajor = 0, supportedSchemaMinor = 0] = agentSchemaVersion.split(".").map(Number);
24571
24578
  var checkOutcome = "The action may still have been applied; check its outcome before another change.";
24579
+ async function readBody(response) {
24580
+ return response.json().catch(() => void 0);
24581
+ }
24572
24582
  function serverMessage(body) {
24573
24583
  const parsed = serverMessageSchema.safeParse(body);
24574
24584
  return parsed.success ? parsed.data.error?.message : void 0;
@@ -24593,8 +24603,9 @@ function needsUpdate(body) {
24593
24603
  }
24594
24604
  function serverOrigin(input2) {
24595
24605
  const url2 = URL.parse(input2);
24596
- if (!url2 || url2.username || url2.password || url2.pathname !== "/" || url2.search || url2.hash || url2.protocol !== "https:" && !(url2.protocol === "http:" && ["localhost", "127.0.0.1", "[::1]"].includes(url2.hostname)))
24606
+ if (!url2 || url2.username || url2.password || url2.pathname !== "/" || url2.search || url2.hash || url2.protocol !== "https:" && !(url2.protocol === "http:" && ["localhost", "127.0.0.1", "[::1]"].includes(url2.hostname))) {
24597
24607
  throw new CliError("INVALID_SERVER");
24608
+ }
24598
24609
  return url2.origin;
24599
24610
  }
24600
24611
  function expiringSoon(credential) {
@@ -24627,15 +24638,14 @@ var GameClient = class {
24627
24638
  body: new URLSearchParams(body)
24628
24639
  });
24629
24640
  if (response.status >= 500) throw new CliError("SERVICE_UNAVAILABLE");
24630
- if (response.status === 429)
24631
- throw rateLimited(response, await response.json().catch(() => void 0));
24641
+ if (response.status === 429) {
24642
+ throw rateLimited(response, await readBody(response));
24643
+ }
24632
24644
  return response;
24633
24645
  }
24634
24646
  async decodeTokens(response) {
24635
24647
  if (!response.ok) throw new CliError("AUTH_REQUIRED");
24636
- const parsed = tokensSchema.safeParse(
24637
- await response.json().catch(() => null)
24638
- );
24648
+ const parsed = tokensSchema.safeParse(await readBody(response));
24639
24649
  if (!parsed.success) throw new CliError("INVALID_RESPONSE");
24640
24650
  return {
24641
24651
  ...parsed.data,
@@ -24649,13 +24659,12 @@ var GameClient = class {
24649
24659
  resource: `${this.origin}/mcp`
24650
24660
  });
24651
24661
  if (!response.ok) throw new CliError("AUTH_START_FAILED");
24652
- const parsed = deviceSchema.safeParse(
24653
- await response.json().catch(() => null)
24654
- );
24662
+ const parsed = deviceSchema.safeParse(await readBody(response));
24655
24663
  if (!parsed.success) throw new CliError("INVALID_RESPONSE");
24656
24664
  const device = parsed.data;
24657
- if (new URL(device.verification_uri_complete).origin !== this.origin)
24665
+ if (new URL(device.verification_uri_complete).origin !== this.origin) {
24658
24666
  throw new CliError("INVALID_AUTH_SERVER");
24667
+ }
24659
24668
  await this.credentials.update((entries) => {
24660
24669
  entries[this.origin] = {
24661
24670
  device_code: device.device_code,
@@ -24672,8 +24681,9 @@ var GameClient = class {
24672
24681
  async accessToken() {
24673
24682
  const cached2 = (await this.credentials.read())[this.origin];
24674
24683
  if (!cached2) throw new CliError("AUTH_REQUIRED");
24675
- if (!isPendingAuthorization(cached2) && !expiringSoon(cached2))
24684
+ if (!isPendingAuthorization(cached2) && !expiringSoon(cached2)) {
24676
24685
  return cached2.access_token;
24686
+ }
24677
24687
  const result = await this.credentials.update(async (entries) => {
24678
24688
  const current = entries[this.origin];
24679
24689
  if (!current) throw new CliError("AUTH_REQUIRED");
@@ -24694,16 +24704,16 @@ var GameClient = class {
24694
24704
  entries[this.origin] = credential;
24695
24705
  return credential.access_token;
24696
24706
  }
24697
- const failure = errorSchema.safeParse(
24698
- await polled.json().catch(() => null)
24699
- );
24700
- if (!failure.success)
24707
+ const failure = errorSchema.safeParse(await readBody(polled));
24708
+ if (!failure.success) {
24701
24709
  throw new CliError("AUTH_NOT_COMPLETED", {
24702
24710
  reason: "invalid_response"
24703
24711
  });
24712
+ }
24704
24713
  const reason = failure.data.error;
24705
- if (reason === "authorization_pending" || reason === "slow_down")
24714
+ if (reason === "authorization_pending" || reason === "slow_down") {
24706
24715
  throw new CliError("AUTH_NOT_COMPLETED", { reason });
24716
+ }
24707
24717
  delete entries[this.origin];
24708
24718
  return new CliError("AUTH_NOT_COMPLETED", { reason });
24709
24719
  }
@@ -24737,24 +24747,27 @@ var GameClient = class {
24737
24747
  },
24738
24748
  body: JSON.stringify(input2)
24739
24749
  });
24740
- const body = await response.json().catch(() => void 0);
24750
+ const body = await readBody(response);
24741
24751
  const message = serverMessage(body);
24742
- if (response.status === 401)
24752
+ if (response.status === 401) {
24743
24753
  throw new CliError("AUTH_REQUIRED", {
24744
24754
  message: message ? `${message} Run auth login and try again.` : cliErrorMessage("AUTH_REQUIRED")
24745
24755
  });
24756
+ }
24746
24757
  if (response.status === 429) throw rateLimited(response, body);
24747
- if (response.status >= 500)
24758
+ if (response.status >= 500) {
24748
24759
  throw new CliError("SERVICE_UNAVAILABLE", message ? { message } : {});
24749
- if (body === void 0)
24760
+ }
24761
+ if (body === void 0) {
24750
24762
  throw new CliError("INVALID_RESPONSE", {
24751
24763
  message: `The server returned a response that was not valid JSON. ${checkOutcome}`,
24752
24764
  operation: path2,
24753
24765
  http_status: response.status
24754
24766
  });
24767
+ }
24755
24768
  const parsed = agentGameResponseSchema.safeParse(body);
24756
24769
  if (!parsed.success) {
24757
- if (needsUpdate(body))
24770
+ if (needsUpdate(body)) {
24758
24771
  throw new CliError("UPDATE_REQUIRED", {
24759
24772
  operation: path2,
24760
24773
  http_status: response.status,
@@ -24762,6 +24775,7 @@ var GameClient = class {
24762
24775
  // The automatic update verifies a read against this server.
24763
24776
  server: this.origin
24764
24777
  });
24778
+ }
24765
24779
  throw new CliError("INVALID_RESPONSE", {
24766
24780
  message: `The server response did not match this CLI's expected format. ${checkOutcome}`,
24767
24781
  operation: path2,
@@ -24776,20 +24790,22 @@ var GameClient = class {
24776
24790
  // Public reads stay usable before authorization and are not agent responses.
24777
24791
  async readDocument(path2, schema) {
24778
24792
  const response = await this.send(`/api/v1/${path2}`, { method: "GET" });
24779
- const body = await response.json().catch(() => void 0);
24793
+ const body = await readBody(response);
24780
24794
  if (response.status === 429) throw rateLimited(response, body);
24781
24795
  if (response.status >= 500) throw new CliError("SERVICE_UNAVAILABLE");
24782
24796
  const parsed = schema.safeParse(body);
24783
24797
  if (parsed.success) return parsed.data;
24784
24798
  const message = serverMessage(body);
24785
- if (response.status === 400 && message)
24799
+ if (response.status === 400 && message) {
24786
24800
  throw new CliError("INVALID_ARGUMENTS", { message });
24787
- if (body === void 0)
24801
+ }
24802
+ if (body === void 0) {
24788
24803
  throw new CliError("INVALID_RESPONSE", {
24789
24804
  message: "The server returned a response that was not valid JSON.",
24790
24805
  operation: path2,
24791
24806
  http_status: response.status
24792
24807
  });
24808
+ }
24793
24809
  throw new CliError("INVALID_RESPONSE", {
24794
24810
  message: "The server response did not match this CLI's expected format.",
24795
24811
  operation: path2,
@@ -24833,10 +24849,11 @@ function ambushNotes(response, character) {
24833
24849
  notes.push(
24834
24850
  `The ${lastResult.kind} activity is complete. Read the ambush battle report with \`${activityCommand(ambush.activity_id, character)}\` if you have not seen it.`
24835
24851
  );
24836
- if (activity)
24852
+ if (activity) {
24837
24853
  notes.push(
24838
24854
  `Your ${activity.kind} activity (${activity.activity_id}) is now in progress.`
24839
24855
  );
24856
+ }
24840
24857
  }
24841
24858
  return { notes, supersededActivityId: ambush.activity_id };
24842
24859
  }
@@ -24851,14 +24868,15 @@ function stateNotes(response, character, wait) {
24851
24868
  `Stopped with ${repetition.completed_count} of ${repetition.requested_count} attempts completed. You keep their results.${unconfirmed}`
24852
24869
  );
24853
24870
  } else if (!wait && response.ok) {
24854
- if (lastResult)
24871
+ if (lastResult) {
24855
24872
  notes.push(
24856
24873
  `This ${lastResult.kind} activity has already finished. No new activity was started.`
24857
24874
  );
24858
- else if (activity)
24875
+ } else if (activity) {
24859
24876
  notes.push(
24860
24877
  `Your ${activity.kind} activity is in progress. Check it with \`${activityCommand(activity.activity_id, character)}\`.`
24861
24878
  );
24879
+ }
24862
24880
  }
24863
24881
  return { notes, supersededActivityId };
24864
24882
  }
@@ -24891,8 +24909,9 @@ function itemChangeRecovery(character) {
24891
24909
  }
24892
24910
  function recoveryHint(detail, context) {
24893
24911
  const repetition = detail.repetition;
24894
- if (detail.outcome !== "unknown" && repetition?.stopped_reason !== "unknown")
24912
+ if (detail.outcome !== "unknown" && repetition?.stopped_reason !== "unknown") {
24895
24913
  return void 0;
24914
+ }
24896
24915
  if (context.itemChange) return itemChangeRecovery(context.character);
24897
24916
  const activityId = typeof detail.activity_id === "number" ? detail.activity_id : void 0;
24898
24917
  const requestId = typeof detail.request_id === "string" ? detail.request_id : void 0;
@@ -24910,10 +24929,11 @@ function recoveryHint(detail, context) {
24910
24929
  `Check your current or latest activity with \`${current}\`. Compare its kind and time with your command. If you cannot tell whether it is the same activity, do not repeat the command.`
24911
24930
  );
24912
24931
  }
24913
- if (requestId)
24932
+ if (requestId) {
24914
24933
  parts.push(
24915
24934
  context.craft ? `Retry only that craft with the same recipe, fee limit and \`--request ${requestId}\` to check what happened. This will not start a second craft. Do not start another lot or repeat the remaining count.` : `Retry the same command with the same arguments and \`--request ${requestId}\` to check what happened. This will not repeat the action.`
24916
24935
  );
24936
+ }
24917
24937
  return parts.join(" ");
24918
24938
  }
24919
24939
 
@@ -24978,8 +24998,9 @@ async function readCli(executable, args, timeout) {
24978
24998
  timeout,
24979
24999
  env: { ...process.env, CLAWSAGA_AUTO_UPDATE: "0" }
24980
25000
  }).catch((error61) => {
24981
- if (error61 && typeof error61 === "object" && "stdout" in error61 && typeof error61.stdout === "string" && error61.stdout.trim())
25001
+ if (error61 && typeof error61 === "object" && "stdout" in error61 && typeof error61.stdout === "string" && error61.stdout.trim()) {
24982
25002
  return { stdout: error61.stdout };
25003
+ }
24983
25004
  throw error61;
24984
25005
  });
24985
25006
  return resultSchema.parse(JSON.parse(output2.stdout));
@@ -25016,11 +25037,12 @@ async function updateCli(server) {
25016
25037
  remaining()
25017
25038
  );
25018
25039
  if (check2.ok) return installedVersion;
25019
- if (!check2.error?.update_required)
25040
+ if (!check2.error?.update_required) {
25020
25041
  throw new CliError("UPDATE_FAILED", {
25021
25042
  message: "The CLI was updated, but play could not be verified. Stop and resolve the verification error before continuing.",
25022
25043
  verification_error: check2.error
25023
25044
  });
25045
+ }
25024
25046
  await sleep(Math.min(6e4, remaining()));
25025
25047
  } while (Date.now() < deadline);
25026
25048
  } catch (error61) {
@@ -25031,8 +25053,9 @@ async function updateCli(server) {
25031
25053
  }
25032
25054
  async function recoverUpdate(error61, notify) {
25033
25055
  if (!(error61 instanceof CliError) || error61.code !== "UPDATE_REQUIRED" || // Set for the verification read, which must not start an update of its own.
25034
- process.env.CLAWSAGA_AUTO_UPDATE === "0")
25056
+ process.env.CLAWSAGA_AUTO_UPDATE === "0") {
25035
25057
  return error61;
25058
+ }
25036
25059
  const { server } = error61.detail;
25037
25060
  if (typeof server !== "string") return error61;
25038
25061
  notify?.(
@@ -25058,7 +25081,7 @@ async function recoverUpdate(error61, notify) {
25058
25081
  // package.json
25059
25082
  var package_default = {
25060
25083
  name: "@clawsaga/cli",
25061
- version: "0.1.22",
25084
+ version: "0.1.24",
25062
25085
  homepage: "https://clawsaga.net",
25063
25086
  repository: {
25064
25087
  type: "git",
@@ -25094,6 +25117,7 @@ var package_default = {
25094
25117
  devDependencies: {
25095
25118
  "@eslint-community/eslint-plugin-eslint-comments": "4.8.1",
25096
25119
  "@eslint/js": "10.0.1",
25120
+ "@stylistic/eslint-plugin": "5.10.0",
25097
25121
  "@types/node": "22.20.4",
25098
25122
  "@types/proper-lockfile": "4.1.4",
25099
25123
  commander: "15.0.0",
@@ -25150,8 +25174,9 @@ async function repeatActivity(client, path2, input2, values, count, options) {
25150
25174
  });
25151
25175
  const attempt = async (lotInput, requestId) => {
25152
25176
  const started = await client.invoke(path2, lotInput);
25153
- if (!started.ok)
25177
+ if (!started.ok) {
25154
25178
  return { ...started, repetition: summary("start_rejected") };
25179
+ }
25155
25180
  const completed = started.data.last_result ? started : await waitForActivity(
25156
25181
  client,
25157
25182
  values,
@@ -25159,22 +25184,27 @@ async function repeatActivity(client, path2, input2, values, count, options) {
25159
25184
  options?.notify,
25160
25185
  requestId
25161
25186
  );
25162
- if (!completed.ok)
25187
+ if (!completed.ok) {
25163
25188
  return { ...completed, repetition: summary("activity_failed") };
25189
+ }
25164
25190
  const result = endedProduction(completed);
25165
- if (result.end_reason !== "COMPLETED")
25191
+ if (result.end_reason !== "COMPLETED") {
25166
25192
  return incomplete(completed, "activity_stopped");
25193
+ }
25167
25194
  const output2 = result.output;
25168
- if (!output2)
25195
+ if (!output2) {
25169
25196
  throw new CliError("INVALID_RESPONSE", {
25170
25197
  reason: "unexpected_production_result"
25171
25198
  });
25199
+ }
25172
25200
  confirmed += 1;
25173
25201
  produced[output2.item_id] = (produced[output2.item_id] ?? 0) + output2.quantity;
25174
- if (result.kind === "gather" && result.ambush)
25202
+ if (result.kind === "gather" && result.ambush) {
25175
25203
  return confirmed === count ? { ...completed, repetition: summary("ambush") } : incomplete(completed, "ambush");
25176
- if (confirmed === count)
25204
+ }
25205
+ if (confirmed === count) {
25177
25206
  return { ...completed, repetition: summary("count_reached") };
25207
+ }
25178
25208
  return void 0;
25179
25209
  };
25180
25210
  while (confirmed < count) {
@@ -25186,13 +25216,14 @@ async function repeatActivity(client, path2, input2, values, count, options) {
25186
25216
  const final = await attempt(lotInput, requestId);
25187
25217
  if (final) return final;
25188
25218
  } catch (error61) {
25189
- if (error61 instanceof CliError)
25219
+ if (error61 instanceof CliError) {
25190
25220
  throw new CliError(error61.code, {
25191
25221
  ...error61.detail,
25192
25222
  ...requestId === void 0 ? {} : { request_id: requestId },
25193
25223
  // 送信前の失敗は開始していないため、成果があった可能性を主張しない。
25194
25224
  repetition: summary(notSent(error61) ? "start_rejected" : "unknown")
25195
25225
  });
25226
+ }
25196
25227
  throw error61;
25197
25228
  }
25198
25229
  }
@@ -25200,28 +25231,31 @@ async function repeatActivity(client, path2, input2, values, count, options) {
25200
25231
  }
25201
25232
  function endedProduction(response) {
25202
25233
  const result = response.data.last_result;
25203
- if (!result || result.kind !== "gather" && result.kind !== "craft" || result.status !== "ENDED")
25234
+ if (!result || result.kind !== "gather" && result.kind !== "craft" || result.status !== "ENDED") {
25204
25235
  throw new CliError("INVALID_RESPONSE", {
25205
25236
  reason: "unexpected_production_result"
25206
25237
  });
25238
+ }
25207
25239
  return result;
25208
25240
  }
25209
25241
  async function waitForActivity(client, values, initial, notify, requestId) {
25210
25242
  let result = initial;
25211
25243
  const activity = result.ok ? result.data.activity : void 0;
25212
- if (!activity)
25244
+ if (!activity) {
25213
25245
  throw new CliError("INVALID_RESPONSE", { reason: "missing_activity_id" });
25246
+ }
25214
25247
  const activityId = activity.activity_id;
25215
25248
  notify?.(
25216
25249
  acceptedActivityNote(activity, result.next_poll_after_seconds, requestId)
25217
25250
  );
25218
25251
  while (result.data.activity?.activity_id === activityId) {
25219
25252
  const seconds = result.next_poll_after_seconds;
25220
- if (!seconds)
25253
+ if (!seconds) {
25221
25254
  throw new CliError("INVALID_RESPONSE", {
25222
25255
  reason: "missing_poll_interval",
25223
25256
  activity_id: activityId
25224
25257
  });
25258
+ }
25225
25259
  await sleep2(seconds * 1e3);
25226
25260
  try {
25227
25261
  result = await client.invoke("character/activity", {
@@ -25230,22 +25264,24 @@ async function waitForActivity(client, values, initial, notify, requestId) {
25230
25264
  ...values.locale ? { locale: values.locale } : {}
25231
25265
  });
25232
25266
  } catch (error61) {
25233
- if (error61 instanceof CliError)
25267
+ if (error61 instanceof CliError) {
25234
25268
  throw new CliError(error61.code, {
25235
25269
  ...error61.detail,
25236
25270
  activity_id: activityId,
25237
25271
  outcome: "unknown"
25238
25272
  });
25273
+ }
25239
25274
  throw error61;
25240
25275
  }
25241
25276
  if (!result.ok) return result;
25242
25277
  }
25243
25278
  const lastResult = result.data.last_result;
25244
- if (!lastResult || lastResult.activity_id !== activityId)
25279
+ if (!lastResult || lastResult.activity_id !== activityId) {
25245
25280
  throw new CliError("INVALID_RESPONSE", {
25246
25281
  reason: "activity_id_mismatch",
25247
25282
  activity_id: activityId
25248
25283
  });
25284
+ }
25249
25285
  return result;
25250
25286
  }
25251
25287
 
@@ -25259,7 +25295,7 @@ var globalOptions = [
25259
25295
  {
25260
25296
  flags: "-l, --content-language <language>",
25261
25297
  description: "Game content language for this call",
25262
- choices: ["ja", "en"]
25298
+ choices: localeSchema.options
25263
25299
  },
25264
25300
  {
25265
25301
  flags: "-s, --server <origin>",
@@ -25321,6 +25357,7 @@ var optionsSchema = external_exports.object({
25321
25357
  drop: external_exports.string().optional(),
25322
25358
  offer: external_exports.string().optional(),
25323
25359
  fixedQuest: external_exports.string().optional(),
25360
+ goal: external_exports.string().optional(),
25324
25361
  quest: external_exports.string().optional(),
25325
25362
  journal: external_exports.string().optional(),
25326
25363
  article: external_exports.string().optional(),
@@ -25350,7 +25387,8 @@ var optionsSchema = external_exports.object({
25350
25387
  price: external_exports.string().optional(),
25351
25388
  order: external_exports.string().optional(),
25352
25389
  listing: external_exports.string().optional(),
25353
- section: external_exports.string().optional()
25390
+ section: external_exports.string().optional(),
25391
+ tier: external_exports.string().optional()
25354
25392
  });
25355
25393
  function isJsonObject(value) {
25356
25394
  return typeof value === "object" && value !== null && !Array.isArray(value);
@@ -25379,11 +25417,12 @@ function optionKey(flags) {
25379
25417
  }
25380
25418
  function integerFlag(option, value) {
25381
25419
  const number5 = Number(value);
25382
- if (typeof value !== "string" || !/^\d+$/.test(value) || !Number.isSafeInteger(number5))
25383
- throw new CliError("INVALID_ARGUMENTS", {
25384
- fields: [option],
25385
- message: `--${option.replace(/[A-Z]/g, (letter) => `-${letter.toLowerCase()}`)} must be a non-negative integer.`
25386
- });
25420
+ if (typeof value !== "string" || !/^\d+$/.test(value) || !Number.isSafeInteger(number5)) {
25421
+ throw invalidArguments(
25422
+ [option],
25423
+ `--${option.replace(/[A-Z]/g, (letter) => `-${letter.toLowerCase()}`)} must be a non-negative integer.`
25424
+ );
25425
+ }
25387
25426
  return number5;
25388
25427
  }
25389
25428
  async function commandInput(definition, values) {
@@ -25447,6 +25486,13 @@ var bodyRequestFlag = [
25447
25486
  function requestIdContext(_values, input2) {
25448
25487
  return { request_id: input2.request_id };
25449
25488
  }
25489
+ function exactlyOne(fields, message) {
25490
+ return (values) => {
25491
+ if (fields.filter((field) => values[field] !== void 0).length !== 1) {
25492
+ throw invalidArguments(fields, message);
25493
+ }
25494
+ };
25495
+ }
25450
25496
  var tacticInputExample = {
25451
25497
  rules: [
25452
25498
  {
@@ -25508,18 +25554,21 @@ var adventureCommands = {
25508
25554
  // 同じ戦術ファイルを相手を変えて使い回せるよう、ファイルのenemy_idを任意とし、
25509
25555
  // --enemyがあればそちらを使う。
25510
25556
  bodyInput: (values, body) => {
25511
- if (values.preset !== void 0 || values.practice !== void 0)
25512
- throw new CliError("INVALID_ARGUMENTS", {
25513
- fields: ["input"],
25514
- message: "Use either --input or --preset/--practice. --enemy may be combined with --input."
25515
- });
25516
- if (values.enemy !== void 0)
25557
+ if (values.preset !== void 0 || values.practice !== void 0) {
25558
+ throw invalidArguments(
25559
+ ["input"],
25560
+ "Use either --input or --preset/--practice. --enemy may be combined with --input."
25561
+ );
25562
+ }
25563
+ if (values.enemy !== void 0) {
25517
25564
  return { ...body, enemy_id: values.enemy };
25518
- if (!("enemy_id" in body))
25519
- throw new CliError("INVALID_ARGUMENTS", {
25520
- fields: ["enemy_id"],
25521
- message: "Pass --enemy or include enemy_id in the --input file."
25522
- });
25565
+ }
25566
+ if (!("enemy_id" in body)) {
25567
+ throw invalidArguments(
25568
+ ["enemy_id"],
25569
+ "Pass --enemy or include enemy_id in the --input file."
25570
+ );
25571
+ }
25523
25572
  return body;
25524
25573
  },
25525
25574
  flags: [
@@ -25528,7 +25577,7 @@ var adventureCommands = {
25528
25577
  "Enemy ID from encounters; with --input, replaces the file\u2019s enemy_id"
25529
25578
  ],
25530
25579
  [jsonFlag[0], jsonFlag[1]],
25531
- ["--preset <id>", "Preset name", false, ["safe", "aggressive"]],
25580
+ ["--preset <id>", "Preset name", false, presetIdSchema.options],
25532
25581
  [
25533
25582
  "--practice",
25534
25583
  "Practice against a training dummy in town without rewards or losses"
@@ -25560,7 +25609,7 @@ var adventureCommands = {
25560
25609
  "--include <sections>",
25561
25610
  "Comma-separated frames,preparation: the tick log, and the stats and tactic fixed at the start",
25562
25611
  false,
25563
- ["frames", "preparation"]
25612
+ combatReportIncludeSchema.options
25564
25613
  ]
25565
25614
  ],
25566
25615
  help: "Read a completed battle\u2019s outcome, rewards, rule counters and accuracy. Use --include for the tick log or the starting preparation."
@@ -25614,12 +25663,7 @@ var adventureCommands = {
25614
25663
  schema: changeJobSchema,
25615
25664
  input: { job: "job_id" },
25616
25665
  flags: [
25617
- [
25618
- "--job <id>",
25619
- "Job ID from character.jobs",
25620
- true,
25621
- ["warrior", "rogue", "mage", "priest", "bard"]
25622
- ]
25666
+ ["--job <id>", "Job ID from character.jobs", true, jobSchema.options]
25623
25667
  ],
25624
25668
  help: "Change jobs in town while retaining each job\u2019s experience."
25625
25669
  },
@@ -25640,7 +25684,7 @@ var adventureCommands = {
25640
25684
  path: "character/quests/board",
25641
25685
  schema: getQuestBoardSchema,
25642
25686
  flags: [],
25643
- help: "Read available quests on your current town\u2019s Quest Board."
25687
+ help: "Read available quests on your current town\u2019s Quest Board. data.community_goals lists the world quests running there."
25644
25688
  },
25645
25689
  quests: {
25646
25690
  path: "character/quests",
@@ -25650,33 +25694,58 @@ var adventureCommands = {
25650
25694
  beforeFlag,
25651
25695
  ["--active-only", "Return accepted, unexpired quests only"]
25652
25696
  ],
25653
- help: "Read quest progress and history. Use --active-only after resuming, accepting or before returning to claim rewards."
25697
+ help: "Read quest progress and history. Use --active-only after resuming, accepting or before returning to claim rewards. data.community_goals lists the goals you joined."
25654
25698
  },
25655
25699
  "quest-accept": {
25656
25700
  path: "character/quests/accept",
25657
25701
  schema: acceptQuestSchema,
25658
- input: { offer: "offer_id", fixedQuest: "fixed_quest_id" },
25659
- buildInput: (values) => {
25660
- if (values.offer !== void 0 === (values.fixedQuest !== void 0))
25661
- throw new CliError("INVALID_ARGUMENTS", {
25662
- fields: ["offer", "fixedQuest"],
25663
- message: "Supply exactly one of --offer and --fixed-quest."
25664
- });
25702
+ input: {
25703
+ offer: "offer_id",
25704
+ fixedQuest: "fixed_quest_id",
25705
+ goal: ["goal_id", "number"]
25665
25706
  },
25707
+ buildInput: exactlyOne(
25708
+ ["offer", "fixedQuest", "goal"],
25709
+ "Supply exactly one of --offer, --fixed-quest and --goal."
25710
+ ),
25666
25711
  flags: [
25667
25712
  ["--offer <uuid>", "Shared offer ID from quest-board"],
25668
- ["--fixed-quest <id>", "Personal fixed quest ID from quest-board"]
25713
+ ["--fixed-quest <id>", "Personal fixed quest ID from quest-board"],
25714
+ ["--goal <id>", "World quest ID from quest-board"]
25669
25715
  ],
25670
- help: "Accept one shared offer or personal fixed quest. Supply exactly one of --offer and --fixed-quest."
25716
+ help: "Accept one shared offer or personal fixed quest, or join one world quest. Supply exactly one of --offer, --fixed-quest and --goal. A world quest uses no quest slot."
25717
+ },
25718
+ "goal-deliver": {
25719
+ path: "character/quests/goals/deliver",
25720
+ schema: deliverGoalSchema,
25721
+ input: {
25722
+ goal: ["goal_id", "number"],
25723
+ item: "item_id",
25724
+ quantity: ["quantity", "number"]
25725
+ },
25726
+ flags: [
25727
+ ["--goal <id>", "Joined world quest ID from quests", true],
25728
+ ["--item <id>", "Item ID to deliver", true],
25729
+ ["--quantity <number>", "Number of standard-quality items", true]
25730
+ ],
25731
+ help: "Deliver standard-quality items from your bag to a joined world quest while idle in its town. The items are consumed; data.delivered reports the points, gold and experience paid."
25671
25732
  },
25672
25733
  "quest-claim": {
25673
25734
  path: "character/quests/claim",
25674
25735
  schema: claimQuestSchema,
25675
- input: { quest: ["quest_number", "number"] },
25736
+ input: {
25737
+ quest: ["quest_number", "number"],
25738
+ goal: ["goal_id", "number"]
25739
+ },
25740
+ buildInput: exactlyOne(
25741
+ ["quest", "goal"],
25742
+ "Supply exactly one of --quest and --goal."
25743
+ ),
25676
25744
  flags: [
25677
- ["--quest <number>", "Quest number from quests or quest-accept", true]
25745
+ ["--quest <number>", "Quest number from quests or quest-accept"],
25746
+ ["--goal <id>", "Ended world quest ID from quests"]
25678
25747
  ],
25679
- help: "Claim when idle in the quest\u2019s report town. Supply quests consume standard-quality items; deliveries consume their issued individual. Check the deadline if present."
25748
+ help: "Claim when idle in the quest\u2019s report town. Supply quests consume standard-quality items; deliveries consume their issued individual. Check the deadline if present. --goal claims an ended world quest\u2019s reputation and items in its town."
25680
25749
  },
25681
25750
  "quest-discard": {
25682
25751
  path: "character/quests/discard",
@@ -25710,7 +25779,6 @@ var adventureCommands = {
25710
25779
  schema: writeJournalSchema,
25711
25780
  autoRequestId: true,
25712
25781
  errorContext: requestIdContext,
25713
- input: { request: "request_id" },
25714
25782
  flags: [jsonFlag, bodyRequestFlag],
25715
25783
  help: "Record something new worth remembering in a later session. Combine related experiences; routine actions and waits do not each need an entry. Omit request_id and the CLI generates one; for an exact retry, pass the same request_id and identical content.",
25716
25784
  inputExample: {
@@ -25723,7 +25791,6 @@ var adventureCommands = {
25723
25791
  schema: endSessionSchema,
25724
25792
  autoRequestId: true,
25725
25793
  errorContext: requestIdContext,
25726
- input: { request: "request_id" },
25727
25794
  flags: [jsonFlag, bodyRequestFlag],
25728
25795
  help: "Always use end when ending a play session to save one summary, even if you wrote a journal during play. Do not also save the same summary with journal-write. Choose continue or stop_at_boundary. Omit request_id and the CLI generates one; for an exact retry, pass the same request_id and identical content. Without session_ended.activity_id no activity was running; do not claim one was stopped. Use the returned result without another hello.",
25729
25796
  inputExample: {
@@ -25834,13 +25901,13 @@ var boardCommands = {
25834
25901
  "--category <id>",
25835
25902
  "Filter by category",
25836
25903
  false,
25837
- ["general", "strategy", "lore", "help", "trade"]
25904
+ boardCategorySchema.options
25838
25905
  ],
25839
25906
  [
25840
25907
  "--thread-language <ja|en>",
25841
25908
  "Filter by the language a thread was written in",
25842
25909
  false,
25843
- ["ja", "en"]
25910
+ localeSchema.options
25844
25911
  ],
25845
25912
  ["--authored-by-self", "Only threads you started"],
25846
25913
  ["--participated-by-self", "Only threads you have taken part in"],
@@ -25980,10 +26047,10 @@ var characterCommands = {
25980
26047
  "--include <sections>",
25981
26048
  "Comma-separated profile,inventory,repair_estimates,growth; repair estimates also include inventory",
25982
26049
  false,
25983
- ["profile", "inventory", "repair_estimates", "growth"]
26050
+ includeSchema.options
25984
26051
  ]
25985
26052
  ],
25986
- help: "Read character status, job and skill levels, combat stats, capacity and rest estimate. Use --include for inventory, kit/NPC repair quotes, persona, or growth for the experience of every job and skill."
26053
+ help: "Read character status, job and skill levels, combat stats, collection counts (enemy kinds defeated and recipes crafted), capacity, bag_expansion and rest estimate. collection is always included; no --include option is needed for it. bag_expansion.next previews the next tier capacity and price, and next.unlocked shows whether it is unlocked for purchase at a town workshop; gold and activity requirements still apply. Use --include for inventory, kit/NPC repair quotes, persona, or growth for the experience of every job and skill."
25987
26054
  },
25988
26055
  create: {
25989
26056
  path: "character/create",
@@ -26168,8 +26235,8 @@ var giftCommands = {
26168
26235
  };
26169
26236
 
26170
26237
  // src/market-commands.ts
26171
- var qualityChoices = ["standard", "fine", "superior"];
26172
- var sourceChoices = ["carried", "storage"];
26238
+ var qualityChoices = marketQualitySchema.options;
26239
+ var sourceChoices = marketSourceSchema.options;
26173
26240
  var requestFlag = [
26174
26241
  "--request <uuid>",
26175
26242
  "Reuse the same ID and arguments after an uncertain result"
@@ -26218,7 +26285,7 @@ var marketCommands = {
26218
26285
  "Only listings at or above this durability"
26219
26286
  ]
26220
26287
  ],
26221
- help: "Read every active item and quality in a market town with best bid and ask, one page at a time. Add --item to read one stack board or individual listings.",
26288
+ help: "Read every active item and quality in a market town with best bid and ask, one page at a time. includes_own: true appears only on rows holding your own open order or listing. last_price is the unit price of the most recent trade on that stack board, absent if it has none. Add --item to read one stack board, including last_traded_at and boards with no open orders, or individual listings.",
26222
26289
  examples: [
26223
26290
  "clawsaga market -c m7Qp2_aR9L-x --town corvent",
26224
26291
  "clawsaga market -c m7Qp2_aR9L-x --town corvent --item ore --quality standard"
@@ -26233,7 +26300,7 @@ var marketCommands = {
26233
26300
  "--section <section>",
26234
26301
  "Read only this section; required with --cursor",
26235
26302
  false,
26236
- ["orders", "listings", "trades"]
26303
+ marketSectionSchema.options
26237
26304
  ],
26238
26305
  ["--cursor <number>", "That section's next_cursor from a previous read"]
26239
26306
  ],
@@ -26460,15 +26527,7 @@ var productionCommands = {
26460
26527
  "--skill <id>",
26461
26528
  "Filter the recipe list by required skill",
26462
26529
  false,
26463
- [
26464
- "mining",
26465
- "gathering",
26466
- "smithing",
26467
- "crafting",
26468
- "alchemy",
26469
- "cooking",
26470
- "enchanting"
26471
- ]
26530
+ skillIdSchema.options
26472
26531
  ],
26473
26532
  ["--recipe <id>", "Read one recipe in detail"]
26474
26533
  ],
@@ -26599,7 +26658,7 @@ var productionCommands = {
26599
26658
  "--method <kit|npc>",
26600
26659
  "kit: full repair using parts; npc: paid repair up to 70%, no parts. No fallback",
26601
26660
  true,
26602
- ["kit", "npc"]
26661
+ repairMethodSchema.options
26603
26662
  ],
26604
26663
  [
26605
26664
  "--instance <id>",
@@ -26609,6 +26668,20 @@ var productionCommands = {
26609
26668
  ],
26610
26669
  help: "Choose kit or npc repair explicitly at a town smithy while idle. Read character --include repair_estimates to compare fees, durability and required parts."
26611
26670
  },
26671
+ "bag-expand": {
26672
+ path: "character/bag/expand",
26673
+ schema: expandBagSchema,
26674
+ input: { tier: ["tier", "number"] },
26675
+ flags: [
26676
+ [
26677
+ "--tier <number>",
26678
+ "Tier to buy: one above your current bag_expansion.tier",
26679
+ true
26680
+ ]
26681
+ ],
26682
+ help: "Buy each unlocked tier while idle in a town with a workshop, raising maximum_weight by 10 for a one-time gold price. Read bag_expansion with character for the next capacity, price and next.unlocked. Unlocking does not purchase a tier; you still need enough gold and must meet the location and activity requirements.",
26683
+ examples: ["clawsaga bag-expand -c m7Qp2_aR9L-x --tier 1"]
26684
+ },
26612
26685
  discard: {
26613
26686
  path: "character/item/discard",
26614
26687
  schema: discardItemSchema,
@@ -26662,10 +26735,11 @@ var responseDataKeys = {
26662
26735
  "change-job": ["capacity", "status", "combat_stats", "equipment_change"],
26663
26736
  "lost-items": ["lost_items"],
26664
26737
  recover: ["capacity", "status"],
26665
- "quest-board": ["quest_board", "quest_board_budget"],
26666
- quests: ["quests"],
26667
- "quest-accept": ["quest", "status", "reputation_change"],
26668
- "quest-claim": ["quest", "status", "reputation_change"],
26738
+ "quest-board": ["quest_board", "quest_board_budget", "community_goals"],
26739
+ quests: ["quests", "community_goals"],
26740
+ "quest-accept": ["quest", "community_goal", "status", "reputation_change"],
26741
+ "goal-deliver": ["community_goal", "delivered", "status"],
26742
+ "quest-claim": ["quest", "community_goal", "status", "reputation_change"],
26669
26743
  "quest-discard": ["quest", "status", "reputation_change"],
26670
26744
  journal: ["journal", "journals"],
26671
26745
  "journal-write": ["journal"],
@@ -26726,7 +26800,9 @@ var responseDataKeys = {
26726
26800
  "activity",
26727
26801
  "rest_estimate",
26728
26802
  "combat_stats",
26729
- "growth"
26803
+ "growth",
26804
+ "bag_expansion",
26805
+ "collection"
26730
26806
  ],
26731
26807
  create: ["created"],
26732
26808
  profile: ["profile_saved"],
@@ -26760,6 +26836,7 @@ var responseDataKeys = {
26760
26836
  equip: ["capacity", "status", "combat_stats", "equipment_change"],
26761
26837
  unequip: ["capacity", "status", "combat_stats", "equipment_change"],
26762
26838
  repair: ["capacity", "status", "repair"],
26839
+ "bag-expand": ["capacity", "status", "bag_expansion"],
26763
26840
  discard: ["capacity", "status"],
26764
26841
  storage: ["storage"],
26765
26842
  "search-storage": ["storage_search"],
@@ -26901,8 +26978,8 @@ function schemaHelp() {
26901
26978
  examples: ["clawsaga schema create", "clawsaga schema gather"]
26902
26979
  };
26903
26980
  }
26904
- function structuredHelp(target5) {
26905
- if (target5 === "clawsaga update")
26981
+ function structuredHelp(target2) {
26982
+ if (target2 === "clawsaga update") {
26906
26983
  return {
26907
26984
  command: "clawsaga update",
26908
26985
  description: "Install the latest CLI with npm. Credentials and installed skills are preserved.",
@@ -26910,15 +26987,36 @@ function structuredHelp(target5) {
26910
26987
  options: [],
26911
26988
  examples: ["clawsaga update"]
26912
26989
  };
26913
- if (target5 === "clawsaga") return programHelp();
26914
- if (target5 === "clawsaga guide") return guideHelp();
26915
- if (target5 === "auth login") return authLoginHelp();
26916
- if (target5 === "schema") return schemaHelp();
26917
- const name = target5.startsWith("clawsaga ") ? target5.slice("clawsaga ".length) : target5;
26990
+ }
26991
+ if (target2 === "clawsaga") return programHelp();
26992
+ if (target2 === "clawsaga guide") return guideHelp();
26993
+ if (target2 === "auth login") return authLoginHelp();
26994
+ if (target2 === "schema") return schemaHelp();
26995
+ const name = target2.startsWith("clawsaga ") ? target2.slice("clawsaga ".length) : target2;
26918
26996
  const definition = commands[name];
26919
26997
  return definition ? commandHelp(name, definition) : programHelp();
26920
26998
  }
26921
26999
 
27000
+ // src/resume.ts
27001
+ var cliOutputInstructions = `## CLI output
27002
+
27003
+ Read the complete response when choosing your next action. If a script reduces output, use jq's \`del(...)\` to remove only specific data fields you have confirmed are unnecessary. For example, \`jq 'del(.data.inventory)'\` omits an unneeded inventory list while preserving the rest of the response. Keep unfamiliar fields; they may describe an unexpected result.
27004
+
27005
+ Always preserve \`ok\`, all of \`error\`, every \`hints\` entry, \`attention\`, \`repetition\`, \`next_poll_after_seconds\`, and all of \`data.activity\` and \`data.last_result\`, including \`ambush\`. Read and handle the hints before continuing. Selecting only \`.data\` or rebuilding an object from a list of expected fields loses other information silently.
27006
+
27007
+ The CLI also prints hints and attention to stderr. Read stderr alongside stdout and keep it visible when using \`clawsaga ... | jq '...'\`. Pipe only stdout to jq; \`2>&1\` and \`|&\` mix diagnostics into its JSON input. Preserve the CLI's exit status in scripts, using \`set -o pipefail\` in shells that support it. Never cut output by bytes or lines with \`head\`, \`tail\` or \`cut\`.`;
27008
+ function withCliResumeInstructions(response) {
27009
+ return {
27010
+ ...response,
27011
+ resume: {
27012
+ ...response.resume,
27013
+ body: `${response.resume.body}
27014
+
27015
+ ${cliOutputInstructions}`
27016
+ }
27017
+ };
27018
+ }
27019
+
26922
27020
  // src/commands.ts
26923
27021
  function clientFor(values) {
26924
27022
  return new GameClient(serverOrigin(values.server));
@@ -26936,10 +27034,12 @@ async function execute(args, notify) {
26936
27034
  function helpOrFailure(error61, run) {
26937
27035
  if (error61 instanceof CliError) throw withRecoveryGuidance(error61, run);
26938
27036
  if (!(error61 instanceof CommanderError)) throw error61;
26939
- if (error61.code === "commander.version")
27037
+ if (error61.code === "commander.version") {
26940
27038
  return { ok: true, version: package_default.version };
26941
- if (error61.code === "commander.helpDisplayed" || error61.code === "commander.help" && error61.exitCode === 0)
27039
+ }
27040
+ if (error61.code === "commander.helpDisplayed" || error61.code === "commander.help" && error61.exitCode === 0) {
26942
27041
  return { ok: true, help: structuredHelp(run.helpTarget) };
27042
+ }
26943
27043
  throw new CliError("INVALID_ARGUMENTS", {
26944
27044
  message: error61.message,
26945
27045
  help_command: run.helpCommand
@@ -26983,10 +27083,12 @@ function isLostResponse(error61) {
26983
27083
  }
26984
27084
  function helloNotes(response) {
26985
27085
  const notes = [];
26986
- if (response.data.announcement)
27086
+ if (response.data.announcement) {
26987
27087
  notes.push(announcementNote(response.data.announcement));
26988
- if (response.data.changelog)
27088
+ }
27089
+ if (response.data.changelog) {
26989
27090
  notes.push(changelogNote(response.data.changelog));
27091
+ }
26990
27092
  return notes;
26991
27093
  }
26992
27094
  function createProgram(run, notify) {
@@ -26996,7 +27098,7 @@ function createProgram(run, notify) {
26996
27098
  new Option(
26997
27099
  "-l, --content-language <language>",
26998
27100
  "Game content language for this call"
26999
- ).choices(["ja", "en"])
27101
+ ).choices(localeSchema.options)
27000
27102
  ).addOption(new Option("-c, --character <id>", "Character ID")).exitOverride().configureHelp({
27001
27103
  showGlobalOptions: true,
27002
27104
  optionTerm: (option) => `${option.flags}${option.mandatory ? " (required)" : ""}`
@@ -27016,8 +27118,9 @@ function createProgram(run, notify) {
27016
27118
  });
27017
27119
  addSchemaCommand(program2, run);
27018
27120
  addDocumentCommands(program2, run);
27019
- for (const [name, definition] of Object.entries(commands))
27121
+ for (const [name, definition] of Object.entries(commands)) {
27020
27122
  addGameCommand(program2, run, notify, name, definition);
27123
+ }
27021
27124
  return program2;
27022
27125
  }
27023
27126
  function addSchemaCommand(program2, run) {
@@ -27030,11 +27133,12 @@ function addSchemaCommand(program2, run) {
27030
27133
  }).action((name) => {
27031
27134
  run.helpCommand = "clawsaga schema --help";
27032
27135
  const definition = commands[name];
27033
- if (!definition)
27034
- throw new CliError("INVALID_ARGUMENTS", {
27035
- fields: ["command"],
27036
- message: "Choose a game command from clawsaga --help, then run clawsaga schema <command>."
27037
- });
27136
+ if (!definition) {
27137
+ throw invalidArguments(
27138
+ ["command"],
27139
+ "Choose a game command from clawsaga --help, then run clawsaga schema <command>."
27140
+ );
27141
+ }
27038
27142
  const hasBody = definition.flags.some(([flags]) => flags === jsonFlag[0]);
27039
27143
  run.schemaHelpResult = {
27040
27144
  input_kind: hasBody ? "json_body" : "api_request",
@@ -27066,7 +27170,7 @@ var documentCommands = [
27066
27170
  description: "Read the operating guide to follow when starting or resuming play.",
27067
27171
  options: [],
27068
27172
  path: () => "guide/resume",
27069
- schema: agentResumeResponseSchema
27173
+ schema: agentResumeResponseSchema.transform(withCliResumeInstructions)
27070
27174
  },
27071
27175
  {
27072
27176
  name: "changelog",
@@ -27083,8 +27187,9 @@ function addDocumentCommands(program2, run) {
27083
27187
  run.helpCommand = `clawsaga ${document.name} --help`;
27084
27188
  }
27085
27189
  });
27086
- for (const option of document.options)
27190
+ for (const option of document.options) {
27087
27191
  command2.option(option.flags, option.description);
27192
+ }
27088
27193
  command2.on("--help", () => {
27089
27194
  run.helpTarget = `clawsaga ${document.name}`;
27090
27195
  run.helpCommand = `clawsaga ${document.name} --help`;
@@ -27121,12 +27226,13 @@ function addGameCommand(program2, run, notify, name, definition) {
27121
27226
  for (const [flags, description] of definition.flags) {
27122
27227
  command2.option(flags, description);
27123
27228
  }
27124
- if (definition.inputExample)
27229
+ if (definition.inputExample) {
27125
27230
  command2.addHelpText(
27126
27231
  "after",
27127
27232
  `
27128
27233
  JSON body: use input_example below with your own content. Full schema: clawsaga schema ${name}.`
27129
27234
  );
27235
+ }
27130
27236
  command2.on("--help", () => {
27131
27237
  run.helpTarget = `clawsaga ${name}`;
27132
27238
  });
@@ -27144,8 +27250,9 @@ JSON body: use input_example below with your own content. Full schema: clawsaga
27144
27250
  executed.wait = values.wait !== false;
27145
27251
  assertRequiredOptions(definition, values, command2.opts());
27146
27252
  const requestedId = values.request;
27147
- if (definition.autoRequestId && !values.request)
27253
+ if (definition.autoRequestId && !values.request) {
27148
27254
  values.request = randomUUID3();
27255
+ }
27149
27256
  const input2 = await commandInput(definition, values);
27150
27257
  const client = clientFor(values);
27151
27258
  if (definition.repeat) {
@@ -27174,48 +27281,53 @@ function activityValues(values) {
27174
27281
  return { character: values.character, locale: values.contentLanguage };
27175
27282
  }
27176
27283
  function assertRequiredOptions(definition, values, provided) {
27177
- if (definition.requiresCharacter !== false && !values.character)
27178
- throw new CliError("INVALID_ARGUMENTS", {
27179
- fields: ["character"],
27180
- message: "Required option '-c, --character <id>' was not provided."
27181
- });
27284
+ if (definition.requiresCharacter !== false && !values.character) {
27285
+ throw invalidArguments(
27286
+ ["character"],
27287
+ "Required option '-c, --character <id>' was not provided."
27288
+ );
27289
+ }
27182
27290
  for (const [flags, , required2] of definition.flags) {
27183
27291
  if (!required2 || provided[optionKey(flags)] !== void 0) continue;
27184
- throw new CliError("INVALID_ARGUMENTS", {
27185
- fields: [optionKey(flags)],
27186
- message: `Required option '${flags}' was not provided.`
27187
- });
27292
+ throw invalidArguments(
27293
+ [optionKey(flags)],
27294
+ `Required option '${flags}' was not provided.`
27295
+ );
27188
27296
  }
27189
27297
  }
27190
27298
  async function invokeGame(client, definition, input2, values) {
27191
27299
  try {
27192
27300
  return await client.invoke(definition.path, input2);
27193
27301
  } catch (error61) {
27194
- if (definition.errorContext && error61 instanceof CliError)
27302
+ if (definition.errorContext && error61 instanceof CliError) {
27195
27303
  throw new CliError(error61.code, {
27196
27304
  ...error61.detail,
27197
27305
  ...definition.errorContext(values, input2)
27198
27306
  });
27307
+ }
27199
27308
  throw error61;
27200
27309
  }
27201
27310
  }
27202
27311
  function repeatCount(requestIdPerLot, values, requestedId) {
27203
27312
  const count = values.count === void 0 ? 1 : Number(values.count);
27204
- if (!Number.isSafeInteger(count) || count < 1)
27205
- throw new CliError("INVALID_ARGUMENTS", {
27206
- fields: ["count"],
27207
- message: "--count must be a positive safe integer."
27208
- });
27209
- if (requestIdPerLot && requestedId !== void 0 && count !== 1)
27210
- throw new CliError("INVALID_ARGUMENTS", {
27211
- fields: ["request"],
27212
- message: "--request retries a single lot; use --count 1 or omit --request."
27213
- });
27214
- if (values.wait === false && count !== 1)
27215
- throw new CliError("INVALID_ARGUMENTS", {
27216
- fields: ["count"],
27217
- message: "--no-wait starts one activity; use --count 1 or omit --count."
27218
- });
27313
+ if (!Number.isSafeInteger(count) || count < 1) {
27314
+ throw invalidArguments(
27315
+ ["count"],
27316
+ "--count must be a positive safe integer."
27317
+ );
27318
+ }
27319
+ if (requestIdPerLot && requestedId !== void 0 && count !== 1) {
27320
+ throw invalidArguments(
27321
+ ["request"],
27322
+ "--request retries a single lot; use --count 1 or omit --request."
27323
+ );
27324
+ }
27325
+ if (values.wait === false && count !== 1) {
27326
+ throw invalidArguments(
27327
+ ["count"],
27328
+ "--no-wait starts one activity; use --count 1 or omit --count."
27329
+ );
27330
+ }
27219
27331
  return count;
27220
27332
  }
27221
27333
 
@@ -27227,16 +27339,26 @@ function print(stream, value) {
27227
27339
  stream.write(`${JSON.stringify(output2)}
27228
27340
  `);
27229
27341
  }
27342
+ function printResult(value) {
27343
+ for (const hint of value.hints ?? []) {
27344
+ if (hint.note !== void 0) process.stderr.write(`Hint: ${hint.note}
27345
+ `);
27346
+ }
27347
+ if (value.attention !== void 0) {
27348
+ process.stderr.write(`Attention: ${JSON.stringify(value.attention)}
27349
+ `);
27350
+ }
27351
+ print(process.stdout, value);
27352
+ }
27230
27353
  try {
27231
27354
  const result = await execute(
27232
27355
  process.argv.slice(2),
27233
27356
  (value) => print(process.stderr, value)
27234
27357
  );
27235
- print(process.stdout, result);
27358
+ printResult(result);
27236
27359
  process.exitCode = "ok" in result && !result.ok ? 1 : 0;
27237
27360
  } catch (error61) {
27238
- print(
27239
- process.stdout,
27361
+ printResult(
27240
27362
  cliFailure(
27241
27363
  await recoverUpdate(
27242
27364
  error61,