@finchtech/cli 0.5.0 → 0.5.1

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.
Files changed (3) hide show
  1. package/README.md +14 -5
  2. package/dist/finch.js +252 -497
  3. package/package.json +4 -4
package/dist/finch.js CHANGED
@@ -6619,7 +6619,7 @@ var init_package = __esm({
6619
6619
  "package.json"() {
6620
6620
  package_default = {
6621
6621
  name: "@finchtech/cli",
6622
- version: "0.5.0",
6622
+ version: "0.5.1",
6623
6623
  description: "Finch Agent CLI for wallet custody, Session-owned execution, and MCP OAuth approval.",
6624
6624
  type: "module",
6625
6625
  bin: {
@@ -6954,9 +6954,9 @@ function floatSafeRemainder(val, step) {
6954
6954
  return 0;
6955
6955
  return ratio - roundedRatio;
6956
6956
  }
6957
- function defineLazy(object6, key, getter) {
6957
+ function defineLazy(object5, key, getter) {
6958
6958
  let value = void 0;
6959
- Object.defineProperty(object6, key, {
6959
+ Object.defineProperty(object5, key, {
6960
6960
  get() {
6961
6961
  if (value === EVALUATING) {
6962
6962
  return void 0;
@@ -6968,7 +6968,7 @@ function defineLazy(object6, key, getter) {
6968
6968
  return value;
6969
6969
  },
6970
6970
  set(v) {
6971
- Object.defineProperty(object6, key, {
6971
+ Object.defineProperty(object5, key, {
6972
6972
  value: v
6973
6973
  // configurable: true,
6974
6974
  });
@@ -22809,6 +22809,39 @@ var init_chains = __esm({
22809
22809
  }
22810
22810
  });
22811
22811
 
22812
+ // ../../packages/deployment-manifest/src/platform/dashboard-prices.json
22813
+ var dashboard_prices_default;
22814
+ var init_dashboard_prices = __esm({
22815
+ "../../packages/deployment-manifest/src/platform/dashboard-prices.json"() {
22816
+ dashboard_prices_default = {
22817
+ schemaVersion: 1,
22818
+ kind: "dashboard_prices",
22819
+ endpoint: "https://api.coingecko.com/api/v3/simple/price",
22820
+ assetIds: {
22821
+ ETH: "ethereum",
22822
+ BNB: "binancecoin",
22823
+ AVAX: "avalanche-2"
22824
+ }
22825
+ };
22826
+ }
22827
+ });
22828
+
22829
+ // ../../packages/deployment-manifest/src/platform/dashboard-prices.ts
22830
+ var manifest;
22831
+ var init_dashboard_prices2 = __esm({
22832
+ "../../packages/deployment-manifest/src/platform/dashboard-prices.ts"() {
22833
+ "use strict";
22834
+ init_zod();
22835
+ init_dashboard_prices();
22836
+ manifest = external_exports.strictObject({
22837
+ schemaVersion: external_exports.literal(1),
22838
+ kind: external_exports.literal("dashboard_prices"),
22839
+ endpoint: external_exports.url().refine((value) => new URL(value).protocol === "https:"),
22840
+ assetIds: external_exports.record(external_exports.string(), external_exports.string().regex(/^[a-z0-9-]+$/))
22841
+ }).parse(dashboard_prices_default);
22842
+ }
22843
+ });
22844
+
22812
22845
  // ../../packages/deployment-manifest/src/platform/get-help.json
22813
22846
  var get_help_default;
22814
22847
  var init_get_help = __esm({
@@ -22877,7 +22910,7 @@ var init_passkey_safe = __esm({
22877
22910
  function parsePasskeySafeManifest(input) {
22878
22911
  return schema2.parse(input);
22879
22912
  }
22880
- var disabled, enabled, schema2, manifest;
22913
+ var disabled, enabled, schema2, manifest2;
22881
22914
  var init_passkey_safe2 = __esm({
22882
22915
  "../../packages/deployment-manifest/src/platform/passkey-safe.ts"() {
22883
22916
  "use strict";
@@ -22903,7 +22936,7 @@ var init_passkey_safe2 = __esm({
22903
22936
  production: disabled
22904
22937
  })
22905
22938
  });
22906
- manifest = parsePasskeySafeManifest(passkey_safe_default);
22939
+ manifest2 = parsePasskeySafeManifest(passkey_safe_default);
22907
22940
  }
22908
22941
  });
22909
22942
 
@@ -23162,7 +23195,7 @@ var init_agenton_payout = __esm({
23162
23195
  function parseAgentonPayoutManifest(input) {
23163
23196
  return schema3.parse(input);
23164
23197
  }
23165
- var origin, environment, schema3, manifest2;
23198
+ var origin, environment, schema3, manifest3;
23166
23199
  var init_agenton_payout2 = __esm({
23167
23200
  "../../packages/deployment-manifest/src/platform/agenton-payout.ts"() {
23168
23201
  "use strict";
@@ -23180,7 +23213,7 @@ var init_agenton_payout2 = __esm({
23180
23213
  walletApiBaseUrl: origin,
23181
23214
  environments: external_exports.strictObject({ local: environment, test: environment, production: environment })
23182
23215
  });
23183
- manifest2 = parseAgentonPayoutManifest(agenton_payout_default);
23216
+ manifest3 = parseAgentonPayoutManifest(agenton_payout_default);
23184
23217
  }
23185
23218
  });
23186
23219
 
@@ -23214,7 +23247,7 @@ var init_merchant_avatar_video = __esm({
23214
23247
  function parseMerchantAvatarVideoManifest(input) {
23215
23248
  return schema4.parse(input);
23216
23249
  }
23217
- var policy2, schema4, manifest3;
23250
+ var policy2, schema4, manifest4;
23218
23251
  var init_merchant_avatar_video2 = __esm({
23219
23252
  "../../packages/deployment-manifest/src/platform/merchant-avatar-video.ts"() {
23220
23253
  "use strict";
@@ -23229,7 +23262,7 @@ var init_merchant_avatar_video2 = __esm({
23229
23262
  kind: external_exports.literal("merchant_avatar_video"),
23230
23263
  environments: external_exports.strictObject({ local: policy2, test: policy2, production: policy2 })
23231
23264
  });
23232
- manifest3 = parseMerchantAvatarVideoManifest(merchant_avatar_video_default);
23265
+ manifest4 = parseMerchantAvatarVideoManifest(merchant_avatar_video_default);
23233
23266
  }
23234
23267
  });
23235
23268
 
@@ -23247,14 +23280,14 @@ var init_generator = __esm({
23247
23280
  });
23248
23281
 
23249
23282
  // ../../packages/deployment-manifest/src/platform/generator.ts
23250
- var policy3, manifest4;
23283
+ var policy3, manifest5;
23251
23284
  var init_generator2 = __esm({
23252
23285
  "../../packages/deployment-manifest/src/platform/generator.ts"() {
23253
23286
  "use strict";
23254
23287
  init_zod();
23255
23288
  init_generator();
23256
23289
  policy3 = external_exports.strictObject({ enabled: external_exports.boolean() });
23257
- manifest4 = external_exports.strictObject({ schemaVersion: external_exports.literal(1), kind: external_exports.literal("generator"), provider: external_exports.strictObject({ endpoint: external_exports.literal("https://api.tokenrouter.com/v1"), model: external_exports.literal("openai/gpt-6-luna") }), environments: external_exports.strictObject({ local: policy3, test: policy3, production: policy3 }) }).parse(generator_default);
23290
+ manifest5 = external_exports.strictObject({ schemaVersion: external_exports.literal(1), kind: external_exports.literal("generator"), provider: external_exports.strictObject({ endpoint: external_exports.literal("https://api.tokenrouter.com/v1"), model: external_exports.literal("openai/gpt-6-luna") }), environments: external_exports.strictObject({ local: policy3, test: policy3, production: policy3 }) }).parse(generator_default);
23258
23291
  }
23259
23292
  });
23260
23293
 
@@ -23304,6 +23337,7 @@ var init_platform = __esm({
23304
23337
  "../../packages/deployment-manifest/src/platform/index.ts"() {
23305
23338
  "use strict";
23306
23339
  init_zod();
23340
+ init_dashboard_prices2();
23307
23341
  init_get_help2();
23308
23342
  init_passkey_safe2();
23309
23343
  init_web_analytics();
@@ -24129,7 +24163,7 @@ function localFailureMessage(error51) {
24129
24163
  if (publicInputMessages.includes(error51.message)) return error51.message;
24130
24164
  return "Command input does not match the expected schema. Check finch help for this command.";
24131
24165
  }
24132
- var CliAuthorityError, CliProductionUnavailableError, BrowserOpenError, MCP_AUTHORIZATION_FLOW_GUIDANCE, McpAuthorizationFlowError, PUBLIC_RECOVERY_COMMAND, CliRecoveryBlockedError, CliSkillSourceError, CliSkillPresentationStaleError, CliSkillRecoveryUncertainError, CliSkillPublicationError;
24166
+ var CliAuthorityError, CliProductionUnavailableError, BrowserOpenError, MCP_AUTHORIZATION_FLOW_GUIDANCE, McpAuthorizationFlowError, CLI_SESSION_RENEWAL_GUIDANCE, CliSkillSourceError, CliSkillPresentationStaleError, CliSkillRecoveryUncertainError, CliSkillPublicationError;
24133
24167
  var init_cli_error = __esm({
24134
24168
  "src/cli-error.ts"() {
24135
24169
  "use strict";
@@ -24179,19 +24213,7 @@ var init_cli_error = __esm({
24179
24213
  code = "MCP_AUTHORIZATION_FLOW_FAILED";
24180
24214
  guidance;
24181
24215
  };
24182
- PUBLIC_RECOVERY_COMMAND = /^(?:finch purchase (?:submit|recover-approval) [0-9a-f-]+(?: --transaction-hash 0x[0-9a-f]{64})?|finch task recover [0-9a-f-]+ (?:publish|award|reclaim)|finch skill recover (?:publication|intent) [0-9a-f]{64})$/u;
24183
- CliRecoveryBlockedError = class extends Error {
24184
- code = "CLI_RECOVERY_BLOCKED";
24185
- recoveryCommands;
24186
- constructor(recoveryCommands) {
24187
- if (recoveryCommands.length === 0 || recoveryCommands.some((command) => !PUBLIC_RECOVERY_COMMAND.test(command))) {
24188
- throw new TypeError("Recovery commands must contain only supported public recovery syntax.");
24189
- }
24190
- super("CLI_RECOVERY_BLOCKED");
24191
- this.name = "CliRecoveryBlockedError";
24192
- this.recoveryCommands = Object.freeze([...new Set(recoveryCommands)].sort());
24193
- }
24194
- };
24216
+ CLI_SESSION_RENEWAL_GUIDANCE = "The CLI Session is invalid or expired. Run finch login --chain-id <CHAIN_ID> using the same wallet, endpoint and authentication chain. Use finch login --help to list supported authentication chains. Existing recovery journals are preserved.";
24195
24217
  CliSkillSourceError = class extends TypeError {
24196
24218
  constructor(diagnosticCode, details, message) {
24197
24219
  super(message);
@@ -28419,7 +28441,7 @@ async function buildSkillRoot(input) {
28419
28441
  if (contentKey !== null) encrypted[file2.path] = { ciphertext: cid.toString(), plaintextHash: await sha256Hex(file2.content) };
28420
28442
  }
28421
28443
  if (!md) throw new RangeError("SkillRoot primary document is missing.");
28422
- const manifest5 = jsonBytes({
28444
+ const manifest6 = jsonBytes({
28423
28445
  schemaVersion: "1.0",
28424
28446
  name: input.name,
28425
28447
  skillVersion: String(input.version),
@@ -28428,7 +28450,7 @@ async function buildSkillRoot(input) {
28428
28450
  });
28429
28451
  const root = {
28430
28452
  md,
28431
- manifest: await put(manifest5),
28453
+ manifest: await put(manifest6),
28432
28454
  entry: { ...md, profile: ENTRY_PROFILE },
28433
28455
  ...Object.keys(files).length ? { files } : {},
28434
28456
  ...input.previousHash === void 0 ? {} : { prev: hashCID(input.previousHash, 113) }
@@ -28442,7 +28464,7 @@ async function buildSkillRoot(input) {
28442
28464
  const proof = {
28443
28465
  scheme: SKILL_ROOT_SCHEME,
28444
28466
  root: toBase64(rootBytes),
28445
- manifest: toBase64(manifest5),
28467
+ manifest: toBase64(manifest6),
28446
28468
  ...confidentiality === void 0 ? {} : { confidentiality: toBase64(confidentiality) }
28447
28469
  };
28448
28470
  const packageHash = await sha256Hex(rootBytes);
@@ -28479,8 +28501,8 @@ async function verifySkillRootProof(proof, packageHash, version6, previousHash)
28479
28501
  const paths = Object.keys(refs);
28480
28502
  if (paths.length > MAX_SKILL_IMPORT_FILES || paths.some((name) => paths.some((other) => other.startsWith(`${name}/`)))) throw new RangeError("SkillRoot file paths exceed limits or conflict.");
28481
28503
  if (!refs[executable.path]?.equals(executable.cid)) throw new RangeError("SkillRoot entrypoint is outside the committed files.");
28482
- const manifest5 = await authenticatedJSON(proof.manifest, CID.asCID(root.manifest));
28483
- if (manifest5.schemaVersion !== "1.0" || typeof manifest5.name !== "string" || typeof manifest5.summary !== "string" || manifest5.skillVersion !== String(version6) || manifest5.entrypoint !== executable.path) throw new RangeError("Invalid SkillRoot manifest.");
28504
+ const manifest6 = await authenticatedJSON(proof.manifest, CID.asCID(root.manifest));
28505
+ if (manifest6.schemaVersion !== "1.0" || typeof manifest6.name !== "string" || typeof manifest6.summary !== "string" || manifest6.skillVersion !== String(version6) || manifest6.entrypoint !== executable.path) throw new RangeError("Invalid SkillRoot manifest.");
28484
28506
  const hashes = /* @__PURE__ */ Object.create(null);
28485
28507
  if (root.confidentiality === void 0) {
28486
28508
  if (proof.confidentiality !== void 0) throw new RangeError("Public SkillRoot declares encrypted transport.");
@@ -28492,10 +28514,10 @@ async function verifySkillRootProof(proof, packageHash, version6, previousHash)
28492
28514
  const objects = record2(descriptor.objects);
28493
28515
  if (Object.keys(objects).length !== Object.keys(refs).length) throw new RangeError("SkillRoot confidentiality paths do not match files.");
28494
28516
  for (const [name, cid] of Object.entries(refs)) {
28495
- const object6 = record2(objects[name]);
28496
- exact(object6, ["ciphertext", "plaintextHash"]);
28497
- if (object6.ciphertext !== cid.toString() || typeof object6.plaintextHash !== "string" || !HASH.test(object6.plaintextHash)) throw new RangeError("SkillRoot ciphertext CID or plaintext hash mismatch.");
28498
- hashes[name] = object6.plaintextHash;
28517
+ const object5 = record2(objects[name]);
28518
+ exact(object5, ["ciphertext", "plaintextHash"]);
28519
+ if (object5.ciphertext !== cid.toString() || typeof object5.plaintextHash !== "string" || !HASH.test(object5.plaintextHash)) throw new RangeError("SkillRoot ciphertext CID or plaintext hash mismatch.");
28520
+ hashes[name] = object5.plaintextHash;
28499
28521
  }
28500
28522
  }
28501
28523
  return {
@@ -28503,8 +28525,8 @@ async function verifySkillRootProof(proof, packageHash, version6, previousHash)
28503
28525
  mdHash: hashes[md.path],
28504
28526
  primaryPath: md.path,
28505
28527
  plaintext: root.confidentiality === void 0,
28506
- name: manifest5.name,
28507
- summary: manifest5.summary,
28528
+ name: manifest6.name,
28529
+ summary: manifest6.summary,
28508
28530
  fileHashes: hashes
28509
28531
  };
28510
28532
  }
@@ -28691,15 +28713,15 @@ function buildDetailDocuments(input) {
28691
28713
  if (raw === null || typeof raw !== "object" || Array.isArray(raw)) {
28692
28714
  throw new RangeError(`Skill ${kind} document is invalid.`);
28693
28715
  }
28694
- const document2 = raw;
28695
- const shape = Object.keys(document2).sort().join(",");
28696
- if (shape !== "assets,entry,mode" && shape !== "assets,entry,externalMediaHosts,mode" || document2.mode !== "html" || !Array.isArray(document2.assets) || document2.assets.length > 50) {
28716
+ const document = raw;
28717
+ const shape = Object.keys(document).sort().join(",");
28718
+ if (shape !== "assets,entry,mode" && shape !== "assets,entry,externalMediaHosts,mode" || document.mode !== "html" || !Array.isArray(document.assets) || document.assets.length > 50) {
28697
28719
  throw new RangeError(`Skill ${kind} document is invalid.`);
28698
28720
  }
28699
- const externalMediaHosts = detailExternalMediaHosts(document2.externalMediaHosts, kind);
28700
- const entry2 = detailObject(document2.entry, `Skill ${kind} HTML`, "text/html", kind);
28721
+ const externalMediaHosts = detailExternalMediaHosts(document.externalMediaHosts, kind);
28722
+ const entry2 = detailObject(document.entry, `Skill ${kind} HTML`, "text/html", kind);
28701
28723
  const names = /* @__PURE__ */ new Set();
28702
- const assets = document2.assets.map((rawAsset) => {
28724
+ const assets = document.assets.map((rawAsset) => {
28703
28725
  if (rawAsset === null || typeof rawAsset !== "object" || Array.isArray(rawAsset)) {
28704
28726
  throw new RangeError(`Skill ${kind} asset is invalid.`);
28705
28727
  }
@@ -28757,8 +28779,8 @@ function buildManifest(entries, presentation, documents) {
28757
28779
  ...normalizedDocuments === void 0 ? {} : { documents: normalizedDocuments }
28758
28780
  };
28759
28781
  }
28760
- function serializeManifest(manifest5) {
28761
- return new TextEncoder().encode(JSON.stringify(manifest5));
28782
+ function serializeManifest(manifest6) {
28783
+ return new TextEncoder().encode(JSON.stringify(manifest6));
28762
28784
  }
28763
28785
  function parseManifest2(bytes) {
28764
28786
  let value;
@@ -28780,14 +28802,14 @@ function parseManifest2(bytes) {
28780
28802
  return null;
28781
28803
  }
28782
28804
  }
28783
- function packageForVersion(manifest5, version6) {
28784
- return manifest5.versions.find((entry2) => entry2.version === version6) ?? null;
28805
+ function packageForVersion(manifest6, version6) {
28806
+ return manifest6.versions.find((entry2) => entry2.version === version6) ?? null;
28785
28807
  }
28786
- function withVersion(manifest5, entry2) {
28787
- return buildManifest([...manifest5?.versions ?? [], entry2], manifest5?.presentation, manifest5?.documents);
28808
+ function withVersion(manifest6, entry2) {
28809
+ return buildManifest([...manifest6?.versions ?? [], entry2], manifest6?.presentation, manifest6?.documents);
28788
28810
  }
28789
- function withPresentation(manifest5, presentation) {
28790
- return buildManifest(manifest5.versions, presentation, manifest5.documents);
28811
+ function withPresentation(manifest6, presentation) {
28812
+ return buildManifest(manifest6.versions, presentation, manifest6.documents);
28791
28813
  }
28792
28814
  var MAX_SKILL_MANIFEST_BYTES, SKILL_MANIFEST_SCHEME, SKILL_DETAIL_KINDS, DETAIL_MEDIA_TYPES, DETAIL_HASH, DETAIL_ASSET_PATH, DETAIL_IPFS_URI, DETAIL_STORAGE_URI, DETAIL_BUCKET_BY_KIND, DETAIL_MEDIA_HOST;
28793
28815
  var init_manifest = __esm({
@@ -28848,8 +28870,8 @@ async function createOracleDevice() {
28848
28870
  async function oracleNonce(device) {
28849
28871
  assertOraclePublicKey(device.publicKey);
28850
28872
  if (!Number.isSafeInteger(device.nonceMs) || device.nonceMs <= 0) throw new TypeError("Invalid Oracle request timestamp.");
28851
- const fingerprint2 = await sha256Hex(new TextEncoder().encode(`${device.publicKey.x}.${device.publicKey.y}`));
28852
- return `${ORACLE_DELIVERY}:${device.nonceMs}:${fingerprint2.slice(2)}`;
28873
+ const fingerprint = await sha256Hex(new TextEncoder().encode(`${device.publicKey.x}.${device.publicKey.y}`));
28874
+ return `${ORACLE_DELIVERY}:${device.nonceMs}:${fingerprint.slice(2)}`;
28853
28875
  }
28854
28876
  async function openOracleKey(sealed, privateKey3) {
28855
28877
  assertOraclePublicKey(sealed.ephemeralPublicJwk);
@@ -29645,7 +29667,7 @@ var init_validation_input = __esm({
29645
29667
  });
29646
29668
 
29647
29669
  // ../../packages/agent-market-contracts/src/v1/errors.ts
29648
- var creatorRequestReasonCodes, agentMarketErrorCodes, nextActionValues, AGENT_MARKET_ERROR_DEFINITIONS, nullableStringSchema, nullableUuidSchema, nullableRevisionSchema2, agentMarketErrorEnvelopeSchema;
29670
+ var creatorRequestReasonCodes, buyerStateReasonCodes, agentMarketErrorCodes, nextActionValues, AGENT_MARKET_ERROR_DEFINITIONS, nullableStringSchema, nullableUuidSchema, nullableRevisionSchema2, agentMarketErrorEnvelopeSchema;
29649
29671
  var init_errors3 = __esm({
29650
29672
  "../../packages/agent-market-contracts/src/v1/errors.ts"() {
29651
29673
  "use strict";
@@ -29658,6 +29680,14 @@ var init_errors3 = __esm({
29658
29680
  "creator_text_invalid_unicode",
29659
29681
  "creator_database_constraint"
29660
29682
  ];
29683
+ buyerStateReasonCodes = [
29684
+ "AGENT_MARKET_INVOCATION_NOT_CONTINUABLE",
29685
+ "AGENT_REVIEW_WALLET_REQUIRED",
29686
+ "AGENT_REVIEW_CREATOR_FORBIDDEN",
29687
+ "AGENT_REVIEW_USAGE_REQUIRED",
29688
+ "AVATAR_VIDEO_ACCOUNT_DAILY_LIMIT_REACHED",
29689
+ "AVATAR_VIDEO_PLATFORM_DAILY_LIMIT_REACHED"
29690
+ ];
29661
29691
  agentMarketErrorCodes = [
29662
29692
  "AGENT_MARKET_AUTH_REQUIRED",
29663
29693
  "AGENT_MARKET_SCOPE_DENIED",
@@ -29736,7 +29766,11 @@ var init_errors3 = __esm({
29736
29766
  error: strictObjectSchema2({
29737
29767
  code: { type: "string", enum: agentMarketErrorCodes },
29738
29768
  message: { type: "string", minLength: 1, maxLength: 500 },
29739
- reasonCode: { anyOf: [{ type: "string", enum: [...validationInputReasonCodes, ...creatorRequestReasonCodes] }, { type: "null" }] },
29769
+ reasonCode: { anyOf: [{ type: "string", enum: [
29770
+ ...validationInputReasonCodes,
29771
+ ...creatorRequestReasonCodes,
29772
+ ...buyerStateReasonCodes
29773
+ ] }, { type: "null" }] },
29740
29774
  retryable: { type: "boolean" },
29741
29775
  nextAction: { type: "string", enum: nextActionValues },
29742
29776
  state: nullableStringSchema,
@@ -30976,7 +31010,17 @@ function taskMutationReceiptProperties(status) {
30976
31010
  function taskMutationReceipt(status) {
30977
31011
  return strictObjectSchema2(taskMutationReceiptProperties(status));
30978
31012
  }
30979
- var booleanSchema2, jsonValueSchema, nullSchema2, agentOnInitialInputSchema, agentOnFollowUpContentSchema, feeBpsCapSchema, createPurchaseIntentRequestSchema, purchaseIntentAcceptedSchema, PURCHASE_FEE_DECISION_CONTRACT, feeSnapshotCommon, purchaseFeeDecisionSnapshotSchema, PURCHASE_LIFECYCLE_CONTRACT, FINANCIAL_AUTHORIZATION_CONTRACT, nonNegativeIntegerStringSchema2, callRightPurchaseBatchSchema, callRightsListResponseSchema, CALL_RIGHTS_PAGE_CONTRACT, CALL_FUNDING_SOURCES, fundingSourceSchema, callEligibilityQuerySchema, described2, callEligibilityResponseSchema, invocationStartRequestSchema, invocationContinueRequestSchema, runtimeHandoffStateSchema, p1InvocationReceiptProperties, p1InvocationReceiptSchema, p1InvocationAcceptedSchema, directInvocationAcceptedSchema, supplementalQuestionOptionSchema, p1QuestionSchema, p1QuestionsSchema, p1AwaitingCompletionQuestionsSchema, taskQuestionSchema, taskQuestionsSchema, closedPublicFailureSchema, timeoutFailureSchema, invocationCommon, p1InvocationResponseSchema, directInvocationCommon, directPublicFailureSchema, directInvocationResponseSchema, DIRECT_INVOCATION_READ_CONTRACT, invocationResponseSchema, createTaskRequestSchema, TASK_QUANTITY_AUTHORITY_CONTRACT, taskCreateReceiptProperties, taskCreateReceiptSchema, taskCreateAcceptedSchema, taskStrongEtagSchema, taskInputReceiptSchema, taskInputAcceptedSchema, taskCommon, buyerOutputArtifactSchema, buyerOutputArtifactsSchema, taskResponseSchema, BUYER_AGENTON_RECOVERY_CONTRACT, appendTaskInputRequestSchema, directInvocationRequestSchema, TASK_COMPLETED_CANONICALIZATION;
31013
+ function taskProjectionSchema(properties) {
31014
+ return strictObjectSchema2({
31015
+ ...properties,
31016
+ failureCode: { anyOf: [taskFailureCodeSchema, nullSchema2] },
31017
+ providerFailureCode: { anyOf: [{ type: "string", minLength: 1, maxLength: 120 }, nullSchema2] },
31018
+ failureMessage: { anyOf: [{ type: "string", maxLength: 4e3 }, nullSchema2] },
31019
+ interimContent: taskPresentationContentSchema,
31020
+ terminalContent: taskPresentationContentSchema
31021
+ }, Object.keys(properties));
31022
+ }
31023
+ var booleanSchema2, jsonValueSchema, nullSchema2, agentOnInitialInputSchema, agentOnFollowUpContentSchema, feeBpsCapSchema, createPurchaseIntentRequestSchema, purchaseIntentAcceptedSchema, PURCHASE_FEE_DECISION_CONTRACT, feeSnapshotCommon, purchaseFeeDecisionSnapshotSchema, PURCHASE_LIFECYCLE_CONTRACT, FINANCIAL_AUTHORIZATION_CONTRACT, nonNegativeIntegerStringSchema2, callRightPurchaseBatchSchema, callRightsListResponseSchema, CALL_RIGHTS_PAGE_CONTRACT, CALL_FUNDING_SOURCES, fundingSourceSchema, callEligibilityQuerySchema, described2, callEligibilityResponseSchema, invocationStartRequestSchema, invocationContinueRequestSchema, runtimeHandoffStateSchema, p1InvocationReceiptProperties, p1InvocationReceiptSchema, p1InvocationAcceptedSchema, directInvocationAcceptedSchema, supplementalQuestionOptionSchema, p1QuestionSchema, p1QuestionsSchema, p1AwaitingCompletionQuestionsSchema, taskQuestionSchema, taskQuestionsSchema, closedPublicFailureSchema, timeoutFailureSchema, invocationCommon, p1InvocationResponseSchema, directInvocationCommon, directPublicFailureSchema, directInvocationResponseSchema, DIRECT_INVOCATION_READ_CONTRACT, invocationResponseSchema, createTaskRequestSchema, TASK_QUANTITY_AUTHORITY_CONTRACT, taskCreateReceiptProperties, taskCreateReceiptSchema, taskCreateAcceptedSchema, taskStrongEtagSchema, taskInputReceiptSchema, taskInputAcceptedSchema, taskCommon, buyerOutputArtifactSchema, buyerOutputArtifactsSchema, taskFailureCodeSchema, taskFailureSchema, taskPresentationContentSchema, taskResponseSchema, BUYER_AGENTON_RECOVERY_CONTRACT, appendTaskInputRequestSchema, directInvocationRequestSchema, TASK_COMPLETED_CANONICALIZATION;
30980
31024
  var init_buyer = __esm({
30981
31025
  "../../packages/agent-market-contracts/src/v1/buyer.ts"() {
30982
31026
  "use strict";
@@ -31260,7 +31304,7 @@ var init_buyer = __esm({
31260
31304
  });
31261
31305
  timeoutFailureSchema = strictObjectSchema2({
31262
31306
  code: { const: "AGENT_MARKET_RUNTIME_TIMEOUT" },
31263
- message: nullSchema2
31307
+ message: { anyOf: [{ type: "string", maxLength: 4e3 }, nullSchema2] }
31264
31308
  });
31265
31309
  invocationCommon = {
31266
31310
  operationId: canonicalUuidSchema2,
@@ -31459,40 +31503,56 @@ var init_buyer = __esm({
31459
31503
  maxItems: 100,
31460
31504
  items: buyerOutputArtifactSchema
31461
31505
  });
31506
+ taskFailureCodeSchema = Object.freeze({
31507
+ type: "string",
31508
+ enum: ["AGENT_MARKET_RUNTIME_TIMEOUT", "AGENT_MARKET_RUNTIME_REJECTED", "AGENT_MARKET_RUNTIME_UNAVAILABLE"]
31509
+ });
31510
+ taskFailureSchema = strictObjectSchema2({
31511
+ code: taskFailureCodeSchema,
31512
+ message: { anyOf: [{ type: "string", maxLength: 4e3 }, nullSchema2] }
31513
+ });
31514
+ taskPresentationContentSchema = Object.freeze({
31515
+ anyOf: [nullSchema2, { type: "array", minItems: 1, maxItems: 100, items: { oneOf: [
31516
+ strictObjectSchema2({ type: { const: "text" }, text: { type: "string" } }),
31517
+ strictObjectSchema2({ type: { const: "json" }, json: jsonValueSchema })
31518
+ ] } }]
31519
+ });
31462
31520
  taskResponseSchema = Object.freeze({
31463
31521
  oneOf: [
31464
- ...["submitted", "working"].map((status) => strictObjectSchema2({
31522
+ ...["submitted", "working"].map((status) => taskProjectionSchema({
31465
31523
  ...taskCommon,
31466
31524
  status: { const: status },
31467
31525
  output: nullSchema2,
31468
31526
  error: nullSchema2
31469
31527
  })),
31470
- strictObjectSchema2({
31528
+ taskProjectionSchema({
31471
31529
  ...taskCommon,
31472
31530
  status: { const: "input_required" },
31531
+ inputRound: { type: "integer", minimum: 1, maximum: 100 },
31532
+ inputToken: hex32Schema,
31473
31533
  output: strictObjectSchema2({ questions: taskQuestionsSchema }),
31474
31534
  error: nullSchema2
31475
31535
  }),
31476
- strictObjectSchema2({
31536
+ taskProjectionSchema({
31477
31537
  ...taskCommon,
31478
31538
  status: { const: "completed" },
31479
31539
  output: jsonValueSchema,
31480
31540
  artifacts: buyerOutputArtifactsSchema,
31481
31541
  error: nullSchema2
31482
31542
  }),
31483
- strictObjectSchema2({
31543
+ taskProjectionSchema({
31484
31544
  ...taskCommon,
31485
31545
  status: { const: "failed" },
31486
31546
  output: nullSchema2,
31487
- error: closedPublicFailureSchema
31547
+ error: taskFailureSchema
31488
31548
  }),
31489
- strictObjectSchema2({
31549
+ taskProjectionSchema({
31490
31550
  ...taskCommon,
31491
31551
  status: { const: "canceled" },
31492
31552
  output: nullSchema2,
31493
- error: nullSchema2
31553
+ error: { anyOf: [taskFailureSchema, nullSchema2] }
31494
31554
  }),
31495
- strictObjectSchema2({
31555
+ taskProjectionSchema({
31496
31556
  ...taskCommon,
31497
31557
  status: { const: "expired" },
31498
31558
  output: nullSchema2,
@@ -31514,7 +31574,7 @@ var init_buyer = __esm({
31514
31574
  p1ContinueOperationIdIsGenericRecovery: true,
31515
31575
  missingOrForeignOperationError: "AGENT_MARKET_OPERATION_NOT_FOUND"
31516
31576
  });
31517
- appendTaskInputRequestSchema = strictObjectSchema2({ content: agentOnFollowUpContentSchema });
31577
+ appendTaskInputRequestSchema = strictObjectSchema2({ content: agentOnFollowUpContentSchema, inputToken: hex32Schema });
31518
31578
  directInvocationRequestSchema = strictObjectSchema2({ input: jsonValueSchema });
31519
31579
  TASK_COMPLETED_CANONICALIZATION = Object.freeze({
31520
31580
  omitted: true,
@@ -32374,31 +32434,13 @@ var init_foundation = __esm({
32374
32434
  });
32375
32435
 
32376
32436
  // ../../packages/agent-market-contracts/src/v1/identity.ts
32377
- var PRODUCTION_AUTH_CHAIN_IDS, TEST_AUTH_CHAIN_IDS, identityScopeValues, IDENTITY_SCOPE_ORDER_CONTRACT, identityEnvironmentValues, environmentSchema, chainIdSchema2, dateTimeSchema, grantScopesSchema, identityChallengeRequestSchema, identityChallengeResponseSchema, identityLoginRequestSchema, identitySessionResponseSchema, identitySessionStatusResponseSchema, identityLogoutRequestSchema, identityMcpActorResponseSchema, identityGrantCreateRequestSchema, identityGrantCreateResponseSchema, identityGrantShowResponseSchema, identityGrantRevokeRequestSchema, identityErrorCodes, identityErrorEnvelopeSchema, IDENTITY_V1_ROUTES, IDENTITY_V1_OPERATIONS, IDENTITY_MCP_V1_MANIFEST, CLI_GRANT_SHOW_WIRE;
32437
+ var PRODUCTION_AUTH_CHAIN_IDS, TEST_AUTH_CHAIN_IDS, IDENTITY_SCOPE_ORDER_CONTRACT, identityEnvironmentValues, environmentSchema, chainIdSchema2, dateTimeSchema, identityChallengeRequestSchema, identityChallengeResponseSchema, identityLoginRequestSchema, identitySessionResponseSchema, identitySessionStatusResponseSchema, identityLogoutRequestSchema, identityMcpActorResponseSchema, identityErrorCodes, identityErrorEnvelopeSchema, IDENTITY_V1_ROUTES, IDENTITY_V1_OPERATIONS, IDENTITY_MCP_V1_MANIFEST;
32378
32438
  var init_identity = __esm({
32379
32439
  "../../packages/agent-market-contracts/src/v1/identity.ts"() {
32380
32440
  "use strict";
32381
32441
  init_common3();
32382
- PRODUCTION_AUTH_CHAIN_IDS = Object.freeze([1, 10, 56, 8453, 42161]);
32442
+ PRODUCTION_AUTH_CHAIN_IDS = Object.freeze([1, 10, 56, 8453, 42161, 43114]);
32383
32443
  TEST_AUTH_CHAIN_IDS = Object.freeze([84532]);
32384
- identityScopeValues = [
32385
- "account:read",
32386
- "agent_market:buyer:invoke",
32387
- "agent_market:buyer:purchase",
32388
- "agent_market:buyer:read",
32389
- "agent_market:discover",
32390
- "agent_market:merchant:read",
32391
- "agent_market:merchant:write",
32392
- "agent_market:operations:read",
32393
- "skill_market:buyer:write",
32394
- "skill_market:creator:write",
32395
- "skill_market:discover",
32396
- "task_market:discover",
32397
- "task_market:participant:read",
32398
- "task_market:participant:write",
32399
- "task_market:requester:read",
32400
- "task_market:requester:write"
32401
- ];
32402
32444
  IDENTITY_SCOPE_ORDER_CONTRACT = Object.freeze({
32403
32445
  order: "ascii_lexicographic",
32404
32446
  duplicatesAllowed: false,
@@ -32408,15 +32450,6 @@ var init_identity = __esm({
32408
32450
  environmentSchema = { type: "string", enum: identityEnvironmentValues };
32409
32451
  chainIdSchema2 = { type: "integer", minimum: 1, maximum: 2147483647 };
32410
32452
  dateTimeSchema = { type: "string", format: "date-time" };
32411
- grantScopesSchema = {
32412
- type: "array",
32413
- minItems: 1,
32414
- maxItems: 16,
32415
- uniqueItems: true,
32416
- items: { type: "string", enum: identityScopeValues },
32417
- description: "Strictly ASCII-lexicographically sorted unique grant scopes.",
32418
- "x-finch-order": IDENTITY_SCOPE_ORDER_CONTRACT.order
32419
- };
32420
32453
  identityChallengeRequestSchema = strictObjectSchema2({
32421
32454
  walletAddress: evmAddressSchema,
32422
32455
  chainId: chainIdSchema2
@@ -32463,33 +32496,6 @@ var init_identity = __esm({
32463
32496
  description: "Finch environment serving this MCP request. In normal end-user use, this should be `production`. It does not select the CLI endpoint or transaction chain."
32464
32497
  }
32465
32498
  });
32466
- identityGrantCreateRequestSchema = strictObjectSchema2({
32467
- grantId: canonicalUuidSchema2,
32468
- grantTokenCommitment: hex32Schema,
32469
- scopes: grantScopesSchema,
32470
- expiresAt: dateTimeSchema
32471
- });
32472
- identityGrantCreateResponseSchema = strictObjectSchema2({
32473
- grantId: canonicalUuidSchema2,
32474
- accountId: canonicalUuidSchema2,
32475
- audience: { const: "finch_mcp" },
32476
- environment: environmentSchema,
32477
- scopes: grantScopesSchema,
32478
- expiresAt: dateTimeSchema,
32479
- replayed: { type: "boolean" }
32480
- });
32481
- identityGrantShowResponseSchema = strictObjectSchema2({
32482
- grantId: canonicalUuidSchema2,
32483
- audience: { const: "finch_mcp" },
32484
- environment: environmentSchema,
32485
- scopes: grantScopesSchema,
32486
- createdAt: dateTimeSchema,
32487
- expiresAt: dateTimeSchema,
32488
- revokedAt: { type: ["string", "null"], format: "date-time" },
32489
- status: { type: "string", enum: ["active", "expired", "revoked"] },
32490
- parentSessionExpiresAt: dateTimeSchema
32491
- });
32492
- identityGrantRevokeRequestSchema = emptyStrictObjectSchema;
32493
32499
  identityErrorCodes = [
32494
32500
  "AGENT_AUTH_REQUEST_INVALID",
32495
32501
  "AGENT_AUTH_CHAIN_UNSUPPORTED",
@@ -32519,9 +32525,6 @@ var init_identity = __esm({
32519
32525
  login: "/api/v1/identity/agent-cli/sessions",
32520
32526
  session: "/api/v1/identity/agent-cli/session",
32521
32527
  logout: "/api/v1/identity/agent-cli/session/logout",
32522
- grantCreate: "/api/v1/identity/agent-cli/grants",
32523
- grantShow: "/api/v1/identity/agent-cli/grants/{grantId}",
32524
- grantRevoke: "/api/v1/identity/agent-cli/grants/{grantId}/revoke",
32525
32528
  mcpActor: "/api/v1/identity/mcp/actor"
32526
32529
  });
32527
32530
  IDENTITY_V1_OPERATIONS = Object.freeze({
@@ -32529,9 +32532,6 @@ var init_identity = __esm({
32529
32532
  login: { id: "identity.login", method: "post", path: IDENTITY_V1_ROUTES.login, successStatus: 201, auth: "public", requestSchema: identityLoginRequestSchema, responseSchema: identitySessionResponseSchema },
32530
32533
  session: { id: "identity.session", method: "get", path: IDENTITY_V1_ROUTES.session, successStatus: 200, auth: "agent_cli_session", responseSchema: identitySessionStatusResponseSchema },
32531
32534
  logout: { id: "identity.logout", method: "post", path: IDENTITY_V1_ROUTES.logout, successStatus: 204, auth: "agent_cli_session", requestSchema: identityLogoutRequestSchema },
32532
- grantCreate: { id: "identity.grant_create", method: "post", path: IDENTITY_V1_ROUTES.grantCreate, successStatus: 201, auth: "agent_cli_session", idempotencySchema: idempotencyHeaderSchema, requestSchema: identityGrantCreateRequestSchema, responseSchema: identityGrantCreateResponseSchema },
32533
- grantShow: { id: "identity.grant_show", method: "get", path: IDENTITY_V1_ROUTES.grantShow, successStatus: 200, auth: "agent_cli_session", responseSchema: identityGrantShowResponseSchema },
32534
- grantRevoke: { id: "identity.grant_revoke", method: "post", path: IDENTITY_V1_ROUTES.grantRevoke, successStatus: 204, auth: "agent_cli_session", idempotencySchema: idempotencyHeaderSchema, requestSchema: identityGrantRevokeRequestSchema },
32535
32535
  mcpActor: {
32536
32536
  id: "identity.actor",
32537
32537
  method: "get",
@@ -32557,11 +32557,6 @@ var init_identity = __esm({
32557
32557
  sideEffect: "read"
32558
32558
  })])
32559
32559
  });
32560
- CLI_GRANT_SHOW_WIRE = Object.freeze({
32561
- operation: "grant.show",
32562
- responseSchema: identityGrantShowResponseSchema,
32563
- rawGrantTokenInResponse: false
32564
- });
32565
32560
  }
32566
32561
  });
32567
32562
 
@@ -34570,8 +34565,6 @@ var init_operations = __esm({
34570
34565
  requestSchema: appendTaskInputRequestSchema,
34571
34566
  responseSchema: taskInputAcceptedSchema,
34572
34567
  idempotencyRequired: true,
34573
- ifMatchRequired: true,
34574
- ifMatchResourceKind: "task",
34575
34568
  etagReturned: true
34576
34569
  }),
34577
34570
  mcp: { name: "agent_market_buyer_task_input" },
@@ -37899,15 +37892,15 @@ function createHmacDrbg(hashLen, qByteLen, hmacFn) {
37899
37892
  };
37900
37893
  return genUntil;
37901
37894
  }
37902
- function validateObject(object6, validators, optValidators = {}) {
37895
+ function validateObject(object5, validators, optValidators = {}) {
37903
37896
  const checkField = (fieldName, type, isOptional) => {
37904
37897
  const checkVal = validatorFns[type];
37905
37898
  if (typeof checkVal !== "function")
37906
37899
  throw new Error("invalid validator function");
37907
- const val = object6[fieldName];
37900
+ const val = object5[fieldName];
37908
37901
  if (isOptional && val === void 0)
37909
37902
  return;
37910
- if (!checkVal(val, object6)) {
37903
+ if (!checkVal(val, object5)) {
37911
37904
  throw new Error("param " + String(fieldName) + " is invalid. Expected " + type + ", got " + val);
37912
37905
  }
37913
37906
  };
@@ -37915,7 +37908,7 @@ function validateObject(object6, validators, optValidators = {}) {
37915
37908
  checkField(fieldName, type, false);
37916
37909
  for (const [fieldName, type] of Object.entries(optValidators))
37917
37910
  checkField(fieldName, type, true);
37918
- return object6;
37911
+ return object5;
37919
37912
  }
37920
37913
  function memoized(fn) {
37921
37914
  const map2 = /* @__PURE__ */ new WeakMap();
@@ -37949,7 +37942,7 @@ var init_utils2 = __esm({
37949
37942
  stringOrUint8Array: (val) => typeof val === "string" || isBytes2(val),
37950
37943
  isSafeInteger: (val) => Number.isSafeInteger(val),
37951
37944
  array: (val) => Array.isArray(val),
37952
- field: (val, object6) => object6.Fp.isValid(val),
37945
+ field: (val, object5) => object5.Fp.isValid(val),
37953
37946
  hash: (val) => typeof val === "function" && Number.isSafeInteger(val.outputLen)
37954
37947
  };
37955
37948
  }
@@ -57752,7 +57745,7 @@ function recoveryFingerprint(kind, plan, walletAddress2, intentId) {
57752
57745
  sourceCommit: skillV3SourceCommit(chainId)
57753
57746
  })).digest("hex");
57754
57747
  }
57755
- function recoveryJournal(value, fingerprint2, kind, context) {
57748
+ function recoveryJournal(value, fingerprint, kind, context) {
57756
57749
  const journal = object2(value, "Skill publication recovery");
57757
57750
  exact2(journal, [
57758
57751
  "version",
@@ -57779,7 +57772,7 @@ function recoveryJournal(value, fingerprint2, kind, context) {
57779
57772
  ], "Skill publication recovery");
57780
57773
  if (journal.intentId !== void 0 && (typeof journal.intentId !== "string" || !UUID.test(journal.intentId) || journal.origin !== context.origin)) throw new TypeError("Skill recovery endpoint or intent is invalid.");
57781
57774
  const chainId = skillChain(journal.chainId, "Skill recovery chain");
57782
- if (journal.version !== 4 && journal.version !== 5 && journal.version !== 6 || journal.kind !== kind || journal.fingerprint !== fingerprint2 || !/^[0-9a-f]{64}$/u.test(fingerprint2) || typeof journal.walletAddress !== "string" || journal.walletAddress.toLowerCase() !== context.walletAddress.toLowerCase()) throw new TypeError("Skill publication recovery authority does not match this command.");
57775
+ if (journal.version !== 4 && journal.version !== 5 && journal.version !== 6 || journal.kind !== kind || journal.fingerprint !== fingerprint || !/^[0-9a-f]{64}$/u.test(fingerprint) || typeof journal.walletAddress !== "string" || journal.walletAddress.toLowerCase() !== context.walletAddress.toLowerCase()) throw new TypeError("Skill publication recovery authority does not match this command.");
57783
57776
  const recoveredAuthority = assertPublicationAuthority(
57784
57777
  signingAuthority(journal.signingAuthority, context.walletAddress),
57785
57778
  context
@@ -57881,14 +57874,14 @@ var init_skill_local_flow = __esm({
57881
57874
  ...Object.entries(progress.journal?.receipts ?? {}).flatMap(([stage, receipt]) => receipt && HASH2.test(receipt.transactionHash) ? [[stage, receipt.transactionHash]] : []),
57882
57875
  ...Object.entries(progress.broadcast ?? {}).filter(([, hash5]) => HASH2.test(hash5))
57883
57876
  ]);
57884
- const fingerprint2 = progress.journal && progress.fingerprint ? progress.fingerprint : progress.walletFingerprint ?? null;
57877
+ const fingerprint = progress.journal && progress.fingerprint ? progress.fingerprint : progress.walletFingerprint ?? null;
57885
57878
  throw new CliSkillPublicationError({
57886
57879
  phase: progress.phase,
57887
- fingerprint: fingerprint2,
57880
+ fingerprint,
57888
57881
  transactionHashes,
57889
57882
  unconfirmedActions: unconfirmed,
57890
57883
  submissionStatus: progress.uncertain ? "uncertain" : Object.keys(transactionHashes).length ? "hash_known" : "not_attempted",
57891
- recoveryCommand: progress.journalSaved && !progress.uncertain && progress.phase !== "cleanup" && fingerprint2 ? `finch skill recover ${progress.walletFingerprint ? "intent" : "publication"} ${fingerprint2}` : null,
57884
+ recoveryCommand: progress.journalSaved && !progress.uncertain && progress.phase !== "cleanup" && fingerprint ? `finch skill recover ${progress.walletFingerprint ? "intent" : "publication"} ${fingerprint}` : null,
57892
57885
  resubmitSafe: progress.resubmitSafe === true
57893
57886
  }, cause);
57894
57887
  }
@@ -57899,8 +57892,8 @@ var init_skill_local_flow = __esm({
57899
57892
  async publishVersion(path2, plan, context) {
57900
57893
  return this.publication((progress) => this.publishVersionWithProgress(path2, plan, context, progress));
57901
57894
  }
57902
- async recoverPublication(fingerprint2, context) {
57903
- return this.publication((progress) => this.recoverWithProgress(fingerprint2, context, progress));
57895
+ async recoverPublication(fingerprint, context) {
57896
+ return this.publication((progress) => this.recoverWithProgress(fingerprint, context, progress));
57904
57897
  }
57905
57898
  async send(context, action, request2, prepared, authority, onBroadcast) {
57906
57899
  return required2(this.sender.submitPrepared, "Skill prepared-intent sender").call(this.sender, {
@@ -58049,24 +58042,24 @@ var init_skill_local_flow = __esm({
58049
58042
  async verify(context, action, request2, receipt) {
58050
58043
  return required2(this.sender.verifyPrepared, "Skill transaction verifier").call(this.sender, { privateKey: context.privateKey, walletAddress: context.walletAddress, action, request: request2, ...receipt });
58051
58044
  }
58052
- async save(fingerprint2, journal) {
58053
- await required2(this.recovery, "Skill publication recovery").saveSkillPublicationRecovery(fingerprint2, journal);
58045
+ async save(fingerprint, journal) {
58046
+ await required2(this.recovery, "Skill publication recovery").saveSkillPublicationRecovery(fingerprint, journal);
58054
58047
  }
58055
58048
  async project(chainId, transactionHash3, bearer, intentId, stage) {
58056
58049
  if (intentId === void 0 && this.api.confirmSkillProjection === void 0) return;
58057
58050
  const status = await required2(this.api.confirmSkillProjection, "Skill projection confirmation").call(this.api, chainId, transactionHash3, bearer, intentId, stage);
58058
58051
  if (intentId !== void 0 && status !== "projected") throw new TypeError("Skill projection is pending. Resume the saved Skill recovery.");
58059
58052
  }
58060
- async stage(progress, context, fingerprint2, journal, stage, action, request2, prepare) {
58053
+ async stage(progress, context, fingerprint, journal, stage, action, request2, prepare) {
58061
58054
  progress.journal = journal;
58062
- progress.fingerprint = fingerprint2;
58055
+ progress.fingerprint = fingerprint;
58063
58056
  progress.journalSaved = true;
58064
58057
  progress.phase = "transaction";
58065
58058
  const existing = journal.receipts[stage];
58066
58059
  if (existing !== null) {
58067
58060
  journal.receipts[stage] = context.intentId !== void 0 && existing.blockNumber !== null ? existing : await this.verify(context, action, request2, existing);
58068
58061
  if (journal.pendingStage === stage) journal.pendingStage = null;
58069
- await this.save(fingerprint2, journal);
58062
+ await this.save(fingerprint, journal);
58070
58063
  progress.uncertain = false;
58071
58064
  progress.phase = "projection";
58072
58065
  await this.project(journal.chainId, journal.receipts[stage].transactionHash, context.bearer, context.intentId, stage);
@@ -58088,7 +58081,7 @@ var init_skill_local_flow = __esm({
58088
58081
  const marks = journal.version === 6;
58089
58082
  if (marks) {
58090
58083
  journal.pendingStage = stage;
58091
- await this.save(fingerprint2, journal);
58084
+ await this.save(fingerprint, journal);
58092
58085
  }
58093
58086
  progress.uncertain = true;
58094
58087
  journal.receipts[stage] = await this.send(
@@ -58099,29 +58092,29 @@ var init_skill_local_flow = __esm({
58099
58092
  journal.signingAuthority,
58100
58093
  async ({ transactionHash: transactionHash3 }) => {
58101
58094
  journal.receipts[stage] = { transactionHash: transactionHash3, blockNumber: null };
58102
- await this.save(fingerprint2, journal);
58095
+ await this.save(fingerprint, journal);
58103
58096
  if (marks) {
58104
58097
  journal.pendingStage = null;
58105
- await this.save(fingerprint2, journal);
58098
+ await this.save(fingerprint, journal);
58106
58099
  }
58107
58100
  progress.uncertain = false;
58108
58101
  }
58109
58102
  );
58110
58103
  if (marks) journal.pendingStage = null;
58111
- await this.save(fingerprint2, journal);
58104
+ await this.save(fingerprint, journal);
58112
58105
  progress.uncertain = false;
58113
58106
  progress.phase = "projection";
58114
58107
  await this.project(journal.chainId, journal.receipts[stage].transactionHash, context.bearer, context.intentId, stage);
58115
58108
  }
58116
- async recoverWithProgress(fingerprint2, context, progress) {
58109
+ async recoverWithProgress(fingerprint, context, progress) {
58117
58110
  progress.phase = "recovery";
58118
- if (!/^[0-9a-f]{64}$/u.test(fingerprint2)) throw new TypeError("Skill publication recovery fingerprint is invalid.");
58111
+ if (!/^[0-9a-f]{64}$/u.test(fingerprint)) throw new TypeError("Skill publication recovery fingerprint is invalid.");
58119
58112
  const store = required2(this.recovery, "Skill publication recovery");
58120
- const stored = await store.readSkillPublicationRecovery(fingerprint2);
58113
+ const stored = await store.readSkillPublicationRecovery(fingerprint);
58121
58114
  if (stored === null) throw new TypeError("Skill publication recovery was not found.");
58122
58115
  const candidate = object2(stored, "Skill publication recovery");
58123
58116
  if (candidate.kind !== "publish" && candidate.kind !== "version") throw new TypeError("Skill publication recovery kind is invalid.");
58124
- const journal = recoveryJournal(stored, fingerprint2, candidate.kind, context);
58117
+ const journal = recoveryJournal(stored, fingerprint, candidate.kind, context);
58125
58118
  if (journal.intentId !== void 0) {
58126
58119
  const owned = object2(await required2(this.api.getSkillSigningIntent, "Skill wallet intent API").call(this.api, journal.intentId, context.bearer), "Skill wallet intent");
58127
58120
  if (owned.intentId !== journal.intentId || owned.origin !== context.origin || owned.kind !== journal.kind) throw new TypeError("Skill recovery intent does not match its endpoint or action.");
@@ -58129,13 +58122,13 @@ var init_skill_local_flow = __esm({
58129
58122
  context = { ...context, intentId: journal.intentId };
58130
58123
  }
58131
58124
  progress.journal = journal;
58132
- progress.fingerprint = fingerprint2;
58125
+ progress.fingerprint = fingerprint;
58133
58126
  progress.journalSaved = true;
58134
58127
  if (journal.kind === "publish") {
58135
58128
  await this.stage(
58136
58129
  progress,
58137
58130
  context,
58138
- fingerprint2,
58131
+ fingerprint,
58139
58132
  journal,
58140
58133
  "primary",
58141
58134
  "createSkill",
@@ -58168,13 +58161,13 @@ var init_skill_local_flow = __esm({
58168
58161
  journal.contentMode,
58169
58162
  required2(journal.contentKey, "Skill recovery content key")
58170
58163
  );
58171
- await this.save(fingerprint2, journal);
58164
+ await this.save(fingerprint, journal);
58172
58165
  }
58173
58166
  const litRequest = required2(journal.requests.lit, "Skill Lit recovery request");
58174
58167
  await this.stage(
58175
58168
  progress,
58176
58169
  context,
58177
- fingerprint2,
58170
+ fingerprint,
58178
58171
  journal,
58179
58172
  "lit",
58180
58173
  "setLitData",
@@ -58183,7 +58176,7 @@ var init_skill_local_flow = __esm({
58183
58176
  );
58184
58177
  }
58185
58178
  progress.phase = "cleanup";
58186
- await store.clearSkillPublicationRecovery(fingerprint2);
58179
+ await store.clearSkillPublicationRecovery(fingerprint);
58187
58180
  return {
58188
58181
  chainId: journal.chainId,
58189
58182
  skillId: skillId2,
@@ -58203,7 +58196,7 @@ var init_skill_local_flow = __esm({
58203
58196
  await this.stage(
58204
58197
  progress,
58205
58198
  context,
58206
- fingerprint2,
58199
+ fingerprint,
58207
58200
  journal,
58208
58201
  "primary",
58209
58202
  "updateSkill",
@@ -58224,7 +58217,7 @@ var init_skill_local_flow = __esm({
58224
58217
  await this.stage(
58225
58218
  progress,
58226
58219
  context,
58227
- fingerprint2,
58220
+ fingerprint,
58228
58221
  journal,
58229
58222
  "uri",
58230
58223
  "setSkillURI",
@@ -58242,13 +58235,13 @@ var init_skill_local_flow = __esm({
58242
58235
  journal.contentMode,
58243
58236
  required2(journal.contentKey, "Skill recovery content key")
58244
58237
  );
58245
- await this.save(fingerprint2, journal);
58238
+ await this.save(fingerprint, journal);
58246
58239
  }
58247
58240
  const litRequest = required2(journal.requests.lit, "Skill Lit recovery request");
58248
58241
  await this.stage(
58249
58242
  progress,
58250
58243
  context,
58251
- fingerprint2,
58244
+ fingerprint,
58252
58245
  journal,
58253
58246
  "lit",
58254
58247
  "setLitData",
@@ -58257,7 +58250,7 @@ var init_skill_local_flow = __esm({
58257
58250
  );
58258
58251
  }
58259
58252
  progress.phase = "cleanup";
58260
- await store.clearSkillPublicationRecovery(fingerprint2);
58253
+ await store.clearSkillPublicationRecovery(fingerprint);
58261
58254
  return {
58262
58255
  chainId: journal.chainId,
58263
58256
  skillId,
@@ -58277,13 +58270,13 @@ var init_skill_local_flow = __esm({
58277
58270
  async publishWithProgress(path2, planValue, context, progress) {
58278
58271
  const plan = publishPlan(planValue, context);
58279
58272
  const request2 = plan.request;
58280
- const fingerprint2 = recoveryFingerprint("publish", planValue, context.walletAddress, context.intentId);
58273
+ const fingerprint = recoveryFingerprint("publish", planValue, context.walletAddress, context.intentId);
58281
58274
  const store = required2(this.recovery, "Skill publication recovery");
58282
58275
  progress.phase = "recovery";
58283
- const prior = await store.readSkillPublicationRecovery(fingerprint2);
58276
+ const prior = await store.readSkillPublicationRecovery(fingerprint);
58284
58277
  if (prior !== null) {
58285
- progress.journal = recoveryJournal(prior, fingerprint2, "publish", context);
58286
- progress.fingerprint = fingerprint2;
58278
+ progress.journal = recoveryJournal(prior, fingerprint, "publish", context);
58279
+ progress.fingerprint = fingerprint;
58287
58280
  progress.journalSaved = true;
58288
58281
  }
58289
58282
  progress.phase = "source";
@@ -58295,7 +58288,7 @@ var init_skill_local_flow = __esm({
58295
58288
  const packaged = await this.package(selected.files, prior === null ? mode : "plaintext", selected.excluded);
58296
58289
  let journal;
58297
58290
  if (prior !== null) {
58298
- journal = recoveryJournal(prior, fingerprint2, "publish", context);
58291
+ journal = recoveryJournal(prior, fingerprint, "publish", context);
58299
58292
  if (journal.sourceKind !== expectedSourceKind || journal.contentMode !== mode || (journal.sourceHash ?? journal.packageHash).toLowerCase() !== packaged.packageHash.toLowerCase() || canonical(journal.excluded) !== canonical(packaged.excluded)) throw new TypeError("Skill publication content no longer matches its protected recovery.");
58300
58293
  } else {
58301
58294
  let publishedBytes;
@@ -58343,7 +58336,7 @@ var init_skill_local_flow = __esm({
58343
58336
  pendingStage: null,
58344
58337
  sourceHash: packaged.packageHash,
58345
58338
  kind: "publish",
58346
- fingerprint: fingerprint2,
58339
+ fingerprint,
58347
58340
  walletAddress: context.walletAddress.toLowerCase(),
58348
58341
  chainId: plan.chainId,
58349
58342
  signingAuthority: plan.signingAuthority,
@@ -58361,15 +58354,15 @@ var init_skill_local_flow = __esm({
58361
58354
  receipts: { primary: null, uri: null, lit: null }
58362
58355
  };
58363
58356
  progress.journal = journal;
58364
- progress.fingerprint = fingerprint2;
58357
+ progress.fingerprint = fingerprint;
58365
58358
  progress.phase = "recovery";
58366
- await this.save(fingerprint2, journal);
58359
+ await this.save(fingerprint, journal);
58367
58360
  progress.journalSaved = true;
58368
58361
  }
58369
58362
  await this.stage(
58370
58363
  progress,
58371
58364
  context,
58372
- fingerprint2,
58365
+ fingerprint,
58373
58366
  journal,
58374
58367
  "primary",
58375
58368
  "createSkill",
@@ -58401,13 +58394,13 @@ var init_skill_local_flow = __esm({
58401
58394
  journal.contentMode,
58402
58395
  required2(journal.contentKey, "Skill recovery content key")
58403
58396
  );
58404
- await this.save(fingerprint2, journal);
58397
+ await this.save(fingerprint, journal);
58405
58398
  }
58406
58399
  const litRequest = required2(journal.requests.lit, "Skill Lit recovery request");
58407
58400
  await this.stage(
58408
58401
  progress,
58409
58402
  context,
58410
- fingerprint2,
58403
+ fingerprint,
58411
58404
  journal,
58412
58405
  "lit",
58413
58406
  "setLitData",
@@ -58416,18 +58409,18 @@ var init_skill_local_flow = __esm({
58416
58409
  );
58417
58410
  }
58418
58411
  progress.phase = "cleanup";
58419
- await store.clearSkillPublicationRecovery(fingerprint2);
58412
+ await store.clearSkillPublicationRecovery(fingerprint);
58420
58413
  return { chainId: journal.chainId, skillId, version: 1, contentMode: journal.contentMode, packageHash: journal.packageHash, excluded: journal.excluded, transactions: { create: required2(journal.receipts.primary, "Skill create receipt").transactionHash, ...journal.contentMode === "plaintext" ? {} : { setLitData: required2(journal.receipts.lit, "Skill Lit receipt").transactionHash } } };
58421
58414
  }
58422
58415
  async publishVersionWithProgress(path2, planValue, context, progress) {
58423
58416
  const plan = versionPlan(planValue, context);
58424
- const fingerprint2 = recoveryFingerprint("version", planValue, context.walletAddress, context.intentId);
58417
+ const fingerprint = recoveryFingerprint("version", planValue, context.walletAddress, context.intentId);
58425
58418
  progress.phase = "recovery";
58426
58419
  const store = required2(this.recovery, "Skill publication recovery");
58427
- const prior = await store.readSkillPublicationRecovery(fingerprint2);
58420
+ const prior = await store.readSkillPublicationRecovery(fingerprint);
58428
58421
  if (prior !== null) {
58429
- progress.journal = recoveryJournal(prior, fingerprint2, "version", context);
58430
- progress.fingerprint = fingerprint2;
58422
+ progress.journal = recoveryJournal(prior, fingerprint, "version", context);
58423
+ progress.fingerprint = fingerprint;
58431
58424
  progress.journalSaved = true;
58432
58425
  }
58433
58426
  const observedVersion = await required2(this.api.readSkillCurrentVersion, "Skill version API").call(
@@ -58447,7 +58440,7 @@ var init_skill_local_flow = __esm({
58447
58440
  const packaged = await this.package(selected.files, prior === null ? plan.contentMode : "plaintext", selected.excluded);
58448
58441
  let journal;
58449
58442
  if (prior !== null) {
58450
- journal = recoveryJournal(prior, fingerprint2, "version", context);
58443
+ journal = recoveryJournal(prior, fingerprint, "version", context);
58451
58444
  if (journal.sourceKind !== plan.sourceKind || journal.contentMode !== plan.contentMode || (journal.sourceHash ?? journal.packageHash).toLowerCase() !== packaged.packageHash.toLowerCase() || canonical(journal.excluded) !== canonical(packaged.excluded)) throw new TypeError("Skill publication content no longer matches its protected recovery.");
58452
58445
  } else {
58453
58446
  const currentBytes = await required2(this.api.fetchSkillStoredContent, "Skill content relay").call(this.api, plan.currentPackageURI, context.bearer);
@@ -58490,7 +58483,7 @@ var init_skill_local_flow = __esm({
58490
58483
  pendingStage: null,
58491
58484
  sourceHash: packaged.packageHash,
58492
58485
  kind: "version",
58493
- fingerprint: fingerprint2,
58486
+ fingerprint,
58494
58487
  walletAddress: context.walletAddress.toLowerCase(),
58495
58488
  chainId: plan.chainId,
58496
58489
  signingAuthority: plan.signingAuthority,
@@ -58508,15 +58501,15 @@ var init_skill_local_flow = __esm({
58508
58501
  receipts: { primary: null, uri: null, lit: null }
58509
58502
  };
58510
58503
  progress.journal = journal;
58511
- progress.fingerprint = fingerprint2;
58504
+ progress.fingerprint = fingerprint;
58512
58505
  progress.phase = "recovery";
58513
- await this.save(fingerprint2, journal);
58506
+ await this.save(fingerprint, journal);
58514
58507
  progress.journalSaved = true;
58515
58508
  }
58516
58509
  await this.stage(
58517
58510
  progress,
58518
58511
  context,
58519
- fingerprint2,
58512
+ fingerprint,
58520
58513
  journal,
58521
58514
  "primary",
58522
58515
  "updateSkill",
@@ -58534,7 +58527,7 @@ var init_skill_local_flow = __esm({
58534
58527
  await this.stage(
58535
58528
  progress,
58536
58529
  context,
58537
- fingerprint2,
58530
+ fingerprint,
58538
58531
  journal,
58539
58532
  "uri",
58540
58533
  "setSkillURI",
@@ -58552,13 +58545,13 @@ var init_skill_local_flow = __esm({
58552
58545
  journal.contentMode,
58553
58546
  required2(journal.contentKey, "Skill recovery content key")
58554
58547
  );
58555
- await this.save(fingerprint2, journal);
58548
+ await this.save(fingerprint, journal);
58556
58549
  }
58557
58550
  const litRequest = required2(journal.requests.lit, "Skill Lit recovery request");
58558
58551
  await this.stage(
58559
58552
  progress,
58560
58553
  context,
58561
- fingerprint2,
58554
+ fingerprint,
58562
58555
  journal,
58563
58556
  "lit",
58564
58557
  "setLitData",
@@ -58567,7 +58560,7 @@ var init_skill_local_flow = __esm({
58567
58560
  );
58568
58561
  }
58569
58562
  progress.phase = "cleanup";
58570
- await store.clearSkillPublicationRecovery(fingerprint2);
58563
+ await store.clearSkillPublicationRecovery(fingerprint);
58571
58564
  return { chainId: journal.chainId, skillId: plan.request.skillId, version: plan.nextVersion, contentMode: journal.contentMode, packageHash: journal.packageHash, excluded: journal.excluded, transactions: { update: required2(journal.receipts.primary, "Skill update receipt").transactionHash, setSkillURI: required2(journal.receipts.uri, "Skill URI receipt").transactionHash, ...journal.contentMode === "plaintext" ? {} : { setLitData: required2(journal.receipts.lit, "Skill Lit receipt").transactionHash } } };
58572
58565
  }
58573
58566
  async manage(kind, planValue, context) {
@@ -58624,9 +58617,9 @@ var init_skill_local_flow = __esm({
58624
58617
  plan.signingAuthority,
58625
58618
  async ({ transactionHash: transactionHash3 }) => {
58626
58619
  progress.broadcast = { setSkillURI: transactionHash3 };
58627
- const fingerprint2 = await context.onBroadcast?.({ request: request2, intent: object2(prepared, "Skill presentation intent"), transactionHash: transactionHash3 });
58628
- if (fingerprint2) {
58629
- progress.walletFingerprint = fingerprint2;
58620
+ const fingerprint = await context.onBroadcast?.({ request: request2, intent: object2(prepared, "Skill presentation intent"), transactionHash: transactionHash3 });
58621
+ if (fingerprint) {
58622
+ progress.walletFingerprint = fingerprint;
58630
58623
  progress.journalSaved = true;
58631
58624
  progress.resubmitSafe = false;
58632
58625
  }
@@ -58672,12 +58665,12 @@ var init_skill_local_flow = __esm({
58672
58665
  const plan = deliveryPlan(planValue, context);
58673
58666
  if (!context) throw new TypeError("Sign in with Finch CLI before downloading Skills.");
58674
58667
  const located = await this.fetchDeliveryContent(plan.packageURI, context?.bearer);
58675
- const manifest5 = parseManifest2(located);
58668
+ const manifest6 = parseManifest2(located);
58676
58669
  let stored = located;
58677
58670
  const expectedHash = plan.packageHash;
58678
- const root = manifest5 === null ? void 0 : packageForVersion(manifest5, plan.version)?.skillRoot;
58679
- if (manifest5 !== null) {
58680
- const entry2 = packageForVersion(manifest5, plan.version);
58671
+ const root = manifest6 === null ? void 0 : packageForVersion(manifest6, plan.version)?.skillRoot;
58672
+ if (manifest6 !== null) {
58673
+ const entry2 = packageForVersion(manifest6, plan.version);
58681
58674
  if (entry2 === null) throw new TypeError(`Skill manifest does not list version ${plan.version}.`);
58682
58675
  if (entry2.packageHash.toLowerCase() !== plan.packageHash.toLowerCase()) throw new TypeError("Skill manifest package hash does not match chain authority.");
58683
58676
  stored = await this.fetchDeliveryContent(entry2.packageURI, context?.bearer);
@@ -59089,7 +59082,7 @@ function agentPurchaseAuthority(snapshot, operationId, walletAddress2) {
59089
59082
  if (snapshot.operationId !== operationId || snapshot.chainId !== String(deployment.chainId) || snapshot.deploymentHash !== deployment.deploymentHash || snapshot.paymentTokenAddress !== deployment.paymentTokenAddress || typeof snapshot.totalPaidAtomic !== "string" || !/^[1-9][0-9]{0,77}$/u.test(snapshot.totalPaidAtomic) || typeof approval.spender !== "string" || approval.spender !== deployment.vaultAddress || approval.amountAtomic !== snapshot.totalPaidAtomic || approvalTransaction.to !== snapshot.paymentTokenAddress || revokeApprovalTransaction.to !== snapshot.paymentTokenAddress || purchaseTransaction.to !== approval.spender || confirmation.contractAddress !== approval.spender || confirmation.eventName !== "PurchaseConfirmed" || confirmation.minimumConfirmations !== deployment.confirmations || typeof snapshot.confirmationDeadlineAt !== "string" || Date.parse(snapshot.confirmationDeadlineAt) <= Date.now() || typeof approvalTransaction.data !== "string" || typeof revokeApprovalTransaction.data !== "string" || typeof purchaseTransaction.data !== "string" || approvalTransaction.value !== "0" || revokeApprovalTransaction.value !== "0" || purchaseTransaction.value !== "0") {
59090
59083
  throw new TypeError("The Agent purchase transaction authority is invalid or expired.");
59091
59084
  }
59092
- const fingerprint2 = createHash3("sha256").update(JSON.stringify([
59085
+ const fingerprint = createHash3("sha256").update(JSON.stringify([
59093
59086
  "finch.cli.agent_purchase_recovery.v2",
59094
59087
  operationId,
59095
59088
  walletAddress2,
@@ -59114,7 +59107,7 @@ function agentPurchaseAuthority(snapshot, operationId, walletAddress2) {
59114
59107
  confirmation.minimumConfirmations
59115
59108
  ]), "utf8").digest("hex");
59116
59109
  return Object.freeze({
59117
- fingerprint: fingerprint2,
59110
+ fingerprint,
59118
59111
  chainId: deployment.chainId,
59119
59112
  deploymentHash: deployment.deploymentHash,
59120
59113
  confirmations: deployment.confirmations,
@@ -59625,7 +59618,7 @@ var init_application = __esm({
59625
59618
  );
59626
59619
  const [session, sessionCheck] = await inspect(
59627
59620
  () => required3(this.state.readSession, "state.readSession").call(this.state),
59628
- "Run finch logout --local, then finch login --help to log in again."
59621
+ "Run finch login --help for supported authentication chains, then finch login --chain-id <CHAIN_ID>."
59629
59622
  );
59630
59623
  let remoteSession = null;
59631
59624
  let remoteSessionCheck;
@@ -59637,7 +59630,7 @@ var init_application = __esm({
59637
59630
  const remote = asObject(await required3(this.api.getSession, "api.getSession").call(this.api, session.rawBearer, AbortSignal.timeout(15e3)), "MCP doctor Session");
59638
59631
  if (remote.sessionId !== session.sessionId || remote.accountId !== session.accountId || remote.walletAddress !== session.walletAddress || remote.environment !== session.environment || remote.audience !== "agent_cli" || typeof remote.sessionExpiresAt !== "string" || !Number.isFinite(Date.parse(remote.sessionExpiresAt)) || Date.parse(remote.sessionExpiresAt) <= Date.now()) throw new CliAuthorityError();
59639
59632
  return { sessionExpiresAt: remote.sessionExpiresAt };
59640
- }, "Verify the endpoint and current wallet, then run finch login --help to renew the CLI login. If the server is unavailable, retry later.");
59633
+ }, `Verify the endpoint and current wallet. If the CLI Session is invalid or expired, run finch login --chain-id ${session.loginChainId} using the same wallet and endpoint. If the server is unavailable, retry later.`);
59641
59634
  } else {
59642
59635
  remoteSessionCheck = { status: "skipped", message: "Requires a valid endpoint, local wallet, and CLI Session." };
59643
59636
  }
@@ -59681,12 +59674,6 @@ var init_application = __esm({
59681
59674
  ...mcp === null ? {} : { mcp }
59682
59675
  });
59683
59676
  }
59684
- async assertNoBlockingRecoveries() {
59685
- const recoveries = await this.state.listBlockingRecoveries?.call(this.state) ?? [];
59686
- if (recoveries.length > 0) {
59687
- throw new CliRecoveryBlockedError(recoveries.map((recovery) => recovery.command));
59688
- }
59689
- }
59690
59677
  async temporaryLoginBearer(profile, wallet, expectedAccountId, chainId) {
59691
59678
  const challenge2 = parseChallenge(await required3(this.api.createChallenge, "api.createChallenge").call(this.api, {
59692
59679
  walletAddress: wallet.walletAddress,
@@ -59724,7 +59711,6 @@ var init_application = __esm({
59724
59711
  await required3(this.state.removeAuthorization, "state.removeAuthorization").call(this.state);
59725
59712
  return Object.freeze({ loggedOut: true, remoteRevoked: false });
59726
59713
  }
59727
- await this.assertNoBlockingRecoveries();
59728
59714
  const profile = await this.authorizedProfile();
59729
59715
  const session = await this.networkSession(profile);
59730
59716
  const wallet = await required3(this.state.readWallet, "state.readWallet").call(this.state);
@@ -59737,7 +59723,6 @@ var init_application = __esm({
59737
59723
  if (input.address === void 0 === (input.file === void 0)) {
59738
59724
  throw new TypeError("wallet use requires exactly one registered address or --file path.");
59739
59725
  }
59740
- await this.assertNoBlockingRecoveries();
59741
59726
  let current;
59742
59727
  try {
59743
59728
  current = await required3(this.state.readWallet, "state.readWallet").call(this.state);
@@ -59959,14 +59944,14 @@ var init_application = __esm({
59959
59944
  const owned = await this.skillWalletIntent(intentFile, expectedKind, session);
59960
59945
  const intent2 = { ...owned.preparation, walletIntent: { intentId: owned.intentId, kind: owned.kind } };
59961
59946
  assertSigningAuthority(intent2, session);
59962
- const fingerprint2 = skillBuyerIntentFingerprint(intent2);
59947
+ const fingerprint = skillBuyerIntentFingerprint(intent2);
59963
59948
  if (owned.stages.primary?.transactionHash) {
59964
59949
  const receipt = await this.confirmSkillWalletResult(owned.intentId, owned.stages.primary.transactionHash, session);
59965
- if (receipt.status === "projected") await this.state.clearSkillBuyerIntentRecovery?.(fingerprint2);
59950
+ if (receipt.status === "projected") await this.state.clearSkillBuyerIntentRecovery?.(fingerprint);
59966
59951
  return { ...receipt, chainId: intent2.chainId, skillId: asObject(intent2.request, "Skill request").skillId };
59967
59952
  }
59968
- const prior = await this.state.readSkillBuyerIntentRecovery?.(fingerprint2);
59969
- if (prior !== void 0 && prior !== null) return this.recoverSkill("intent", fingerprint2);
59953
+ const prior = await this.state.readSkillBuyerIntentRecovery?.(fingerprint);
59954
+ if (prior !== void 0 && prior !== null) return this.recoverSkill("intent", fingerprint);
59970
59955
  const sender = required3(this.skillIntentSender, "skill intent sender");
59971
59956
  const checkpoint = {};
59972
59957
  const submission = await sender.submit({
@@ -59975,7 +59960,7 @@ var init_application = __esm({
59975
59960
  expectedKind,
59976
59961
  intent: intent2,
59977
59962
  onBroadcast: async (broadcast) => {
59978
- if (broadcast.fingerprint !== fingerprint2) {
59963
+ if (broadcast.fingerprint !== fingerprint) {
59979
59964
  throw new TypeError("Skill buyer checkpoint fingerprint does not match its OAuth intent.");
59980
59965
  }
59981
59966
  checkpoint.journal = createSkillBuyerIntentJournal({
@@ -59991,15 +59976,15 @@ var init_application = __esm({
59991
59976
  broadcast.transactionHash
59992
59977
  )
59993
59978
  });
59994
- await required3(this.state.saveSkillBuyerIntentRecovery, "state.saveSkillBuyerIntentRecovery").call(this.state, fingerprint2, checkpoint.journal);
59979
+ await required3(this.state.saveSkillBuyerIntentRecovery, "state.saveSkillBuyerIntentRecovery").call(this.state, fingerprint, checkpoint.journal);
59995
59980
  }
59996
59981
  });
59997
59982
  if (checkpoint.journal === void 0) throw new TypeError("Skill buyer sender did not checkpoint its broadcast.");
59998
59983
  const journal = withSkillBuyerIntentReceipt(checkpoint.journal, submission.blockNumber);
59999
- await required3(this.state.saveSkillBuyerIntentRecovery, "state.saveSkillBuyerIntentRecovery").call(this.state, fingerprint2, journal);
59984
+ await required3(this.state.saveSkillBuyerIntentRecovery, "state.saveSkillBuyerIntentRecovery").call(this.state, fingerprint, journal);
60000
59985
  const confirmation = await this.confirmSkillWalletResult(owned.intentId, submission.transactionHash, session);
60001
59986
  if (confirmation.status === "projected") {
60002
- await required3(this.state.clearSkillBuyerIntentRecovery, "state.clearSkillBuyerIntentRecovery").call(this.state, fingerprint2);
59987
+ await required3(this.state.clearSkillBuyerIntentRecovery, "state.clearSkillBuyerIntentRecovery").call(this.state, fingerprint);
60003
59988
  }
60004
59989
  return { ...confirmation, transactionHash: submission.transactionHash, blockNumber: submission.blockNumber, chainId: intent2.chainId, skillId: asObject(intent2.request, "Skill request").skillId };
60005
59990
  }
@@ -60008,8 +59993,8 @@ var init_application = __esm({
60008
59993
  const owned = await this.skillWalletIntent(planFile, "publish", authority.session);
60009
59994
  const plan = owned.preparation;
60010
59995
  if (owned.stages.primary?.transactionHash) {
60011
- const fingerprint2 = recoveryFingerprint("publish", plan, authority.wallet.walletAddress, owned.intentId);
60012
- const saved = await this.state.readSkillPublicationRecovery?.(fingerprint2);
59996
+ const fingerprint = recoveryFingerprint("publish", plan, authority.wallet.walletAddress, owned.intentId);
59997
+ const saved = await this.state.readSkillPublicationRecovery?.(fingerprint);
60013
59998
  if (saved == null) {
60014
59999
  const stages = ["primary"];
60015
60000
  if (asObject(plan.request, "Skill request").contentMode !== "plaintext") stages.push("lit");
@@ -60040,8 +60025,8 @@ var init_application = __esm({
60040
60025
  const owned = await this.skillWalletIntent(planFile, "version", authority.session);
60041
60026
  const plan = owned.preparation;
60042
60027
  if (owned.stages.primary?.transactionHash) {
60043
- const fingerprint2 = recoveryFingerprint("version", plan, authority.wallet.walletAddress, owned.intentId);
60044
- const saved = await this.state.readSkillPublicationRecovery?.(fingerprint2);
60028
+ const fingerprint = recoveryFingerprint("version", plan, authority.wallet.walletAddress, owned.intentId);
60029
+ const saved = await this.state.readSkillPublicationRecovery?.(fingerprint);
60045
60030
  if (saved == null) {
60046
60031
  const stages = ["primary", "uri"];
60047
60032
  if (plan.contentMode !== "plaintext") stages.push("lit");
@@ -60087,10 +60072,10 @@ var init_application = __esm({
60087
60072
  intentId: owned.intentId,
60088
60073
  origin: authority.session.origin,
60089
60074
  resumePrepared: async (request2, intent2) => {
60090
- const fingerprint2 = skillBuyerIntentFingerprint(walletPlan(request2, intent2));
60091
- const stored = await this.state.readSkillBuyerIntentRecovery?.(fingerprint2);
60075
+ const fingerprint = skillBuyerIntentFingerprint(walletPlan(request2, intent2));
60076
+ const stored = await this.state.readSkillBuyerIntentRecovery?.(fingerprint);
60092
60077
  if (stored == null) return null;
60093
- const recovered = await this.recoverSkill("intent", fingerprint2);
60078
+ const recovered = await this.recoverSkill("intent", fingerprint);
60094
60079
  if (recovered.status !== "projected") throw new TypeError("Skill projection is pending. Resume the recorded wallet result.");
60095
60080
  return { transactionHash: String(recovered.transactionHash), blockNumber: String(recovered.blockNumber) };
60096
60081
  },
@@ -60125,8 +60110,8 @@ var init_application = __esm({
60125
60110
  }
60126
60111
  } };
60127
60112
  }
60128
- async recoverSkill(kind, fingerprint2) {
60129
- if (!["publication", "intent"].includes(kind) || !/^[0-9a-f]{64}$/u.test(fingerprint2)) {
60113
+ async recoverSkill(kind, fingerprint) {
60114
+ if (!["publication", "intent"].includes(kind) || !/^[0-9a-f]{64}$/u.test(fingerprint)) {
60130
60115
  throw new TypeError("Skill recovery kind or fingerprint is invalid.");
60131
60116
  }
60132
60117
  const { wallet, session } = await this.walletAuthority();
@@ -60142,16 +60127,16 @@ var init_application = __esm({
60142
60127
  return asObject(await required3(
60143
60128
  required3(this.skillLocalFlow, "skill local flow").recoverPublication,
60144
60129
  "skill publication recovery"
60145
- ).call(this.skillLocalFlow, fingerprint2, context), "Skill publication recovery");
60130
+ ).call(this.skillLocalFlow, fingerprint, context), "Skill publication recovery");
60146
60131
  }
60147
- const stored = await required3(this.state.readSkillBuyerIntentRecovery, "state.readSkillBuyerIntentRecovery").call(this.state, fingerprint2);
60132
+ const stored = await required3(this.state.readSkillBuyerIntentRecovery, "state.readSkillBuyerIntentRecovery").call(this.state, fingerprint);
60148
60133
  if (stored === null) throw new TypeError("Skill buyer intent recovery journal was not found.");
60149
60134
  let journal = assertSkillBuyerIntentJournalAuthority(stored, {
60150
60135
  accountId: session.accountId,
60151
60136
  walletAddress: wallet.walletAddress,
60152
60137
  environment: session.environment
60153
60138
  });
60154
- if (journal.fingerprint !== fingerprint2) throw new TypeError("Skill buyer intent fingerprint is invalid.");
60139
+ if (journal.fingerprint !== fingerprint) throw new TypeError("Skill buyer intent fingerprint is invalid.");
60155
60140
  assertSigningAuthority(journal.intent, session);
60156
60141
  if (journal.origin !== void 0 && journal.origin !== session.origin) throw new TypeError("Skill recovery belongs to another endpoint.");
60157
60142
  if (journal.intentId === void 0) {
@@ -60162,7 +60147,7 @@ var init_application = __esm({
60162
60147
  const receipt = owned.stages.primary;
60163
60148
  if (!receipt || receipt.transactionHash !== journal.transactionHash || receipt.blockNumber === null) throw new TypeError("Legacy Skill adoption has no canonical receipt.");
60164
60149
  if (journal.blockNumber === null) journal = withSkillBuyerIntentReceipt(journal, receipt.blockNumber);
60165
- await required3(this.state.saveSkillBuyerIntentRecovery, "state.saveSkillBuyerIntentRecovery").call(this.state, fingerprint2, journal);
60150
+ await required3(this.state.saveSkillBuyerIntentRecovery, "state.saveSkillBuyerIntentRecovery").call(this.state, fingerprint, journal);
60166
60151
  } else {
60167
60152
  const owned = await this.skillWalletIntent(journal.intentId, journal.kind, session);
60168
60153
  const stage = owned.stages.primary;
@@ -60186,12 +60171,12 @@ var init_application = __esm({
60186
60171
  blockNumber: null
60187
60172
  });
60188
60173
  journal = withSkillBuyerIntentReceipt(journal, receipt.blockNumber);
60189
- await required3(this.state.saveSkillBuyerIntentRecovery, "state.saveSkillBuyerIntentRecovery").call(this.state, fingerprint2, journal);
60174
+ await required3(this.state.saveSkillBuyerIntentRecovery, "state.saveSkillBuyerIntentRecovery").call(this.state, fingerprint, journal);
60190
60175
  }
60191
60176
  }
60192
60177
  const confirmation = await this.confirmSkillWalletResult(journal.intentId, journal.transactionHash, session);
60193
60178
  if (confirmation.status === "projected") {
60194
- await required3(this.state.clearSkillBuyerIntentRecovery, "state.clearSkillBuyerIntentRecovery").call(this.state, fingerprint2);
60179
+ await required3(this.state.clearSkillBuyerIntentRecovery, "state.clearSkillBuyerIntentRecovery").call(this.state, fingerprint);
60195
60180
  }
60196
60181
  return { ...confirmation, transactionHash: journal.transactionHash, blockNumber: confirmation.blockNumber };
60197
60182
  }
@@ -61573,191 +61558,6 @@ var init_stdin_reader = __esm({
61573
61558
  }
61574
61559
  });
61575
61560
 
61576
- // src/recovery-inventory.ts
61577
- function object4(value, name) {
61578
- if (typeof value !== "object" || value === null || Array.isArray(value)) {
61579
- throw new TypeError(`${name} must contain exact public fields.`);
61580
- }
61581
- return value;
61582
- }
61583
- function exactKeys2(value, keys, name) {
61584
- const actual = Object.keys(value).sort();
61585
- const expected = [...keys].sort();
61586
- if (actual.length !== expected.length || actual.some((key, index2) => key !== expected[index2])) {
61587
- throw new TypeError(`${name} must contain exact public fields.`);
61588
- }
61589
- }
61590
- function uuid5(value, name) {
61591
- if (typeof value !== "string" || !UUID3.test(value)) throw new TypeError(`${name} is invalid.`);
61592
- return value;
61593
- }
61594
- function fingerprint(value) {
61595
- if (typeof value !== "string" || !FINGERPRINT2.test(value)) {
61596
- throw new TypeError("Recovery fingerprint is invalid.");
61597
- }
61598
- return value;
61599
- }
61600
- function taskKind(value) {
61601
- if (!TASK_KINDS.includes(value)) {
61602
- throw new TypeError("Task recovery kind is invalid.");
61603
- }
61604
- return value;
61605
- }
61606
- function skillKind(value) {
61607
- if (!SKILL_KINDS.includes(value)) {
61608
- throw new TypeError("Skill recovery kind is invalid.");
61609
- }
61610
- return value;
61611
- }
61612
- function parseEntry(value) {
61613
- const candidate = object4(value, "Recovery inventory entry");
61614
- if (candidate.type === "agent_purchase") {
61615
- exactKeys2(candidate, ["type", "operationId"], "Agent purchase recovery entry");
61616
- return Object.freeze({
61617
- type: "agent_purchase",
61618
- operationId: uuid5(candidate.operationId, "Agent purchase operationId")
61619
- });
61620
- }
61621
- if (candidate.type === "task") {
61622
- exactKeys2(candidate, ["type", "taskId", "kind"], "Task recovery entry");
61623
- return Object.freeze({
61624
- type: "task",
61625
- taskId: uuid5(candidate.taskId, "Task taskId"),
61626
- kind: taskKind(candidate.kind)
61627
- });
61628
- }
61629
- if (candidate.type === "skill") {
61630
- exactKeys2(candidate, ["type", "kind", "fingerprint"], "Skill recovery entry");
61631
- return Object.freeze({
61632
- type: "skill",
61633
- kind: skillKind(candidate.kind),
61634
- fingerprint: fingerprint(candidate.fingerprint)
61635
- });
61636
- }
61637
- throw new TypeError("Recovery inventory entry type is invalid.");
61638
- }
61639
- function parseKey(value) {
61640
- const candidate = object4(value, "Recovery inventory key");
61641
- if (candidate.type === "agent_purchase") {
61642
- exactKeys2(candidate, ["type", "operationId"], "Agent purchase recovery key");
61643
- return Object.freeze({
61644
- type: "agent_purchase",
61645
- operationId: uuid5(candidate.operationId, "Agent purchase operationId")
61646
- });
61647
- }
61648
- if (candidate.type === "task") {
61649
- exactKeys2(candidate, ["type", "taskId", "kind"], "Task recovery key");
61650
- return Object.freeze({
61651
- type: "task",
61652
- taskId: uuid5(candidate.taskId, "Task taskId"),
61653
- kind: taskKind(candidate.kind)
61654
- });
61655
- }
61656
- if (candidate.type === "skill") {
61657
- exactKeys2(candidate, ["type", "kind", "fingerprint"], "Skill recovery key");
61658
- return Object.freeze({
61659
- type: "skill",
61660
- kind: skillKind(candidate.kind),
61661
- fingerprint: fingerprint(candidate.fingerprint)
61662
- });
61663
- }
61664
- throw new TypeError("Recovery inventory key type is invalid.");
61665
- }
61666
- function entryKey(entry2) {
61667
- if (entry2.type === "agent_purchase") return `agent_purchase:${entry2.operationId}`;
61668
- if (entry2.type === "task") return `task:${entry2.taskId}:${entry2.kind}`;
61669
- return `skill:${entry2.kind}:${entry2.fingerprint}`;
61670
- }
61671
- function document(value) {
61672
- if (value === null) return Object.freeze({ version: 1, entries: Object.freeze([]) });
61673
- const candidate = object4(value, "Recovery inventory");
61674
- exactKeys2(candidate, ["version", "entries"], "Recovery inventory");
61675
- if (candidate.version !== 1 || !Array.isArray(candidate.entries)) {
61676
- throw new TypeError("Recovery inventory is invalid.");
61677
- }
61678
- const entries = candidate.entries.map(parseEntry).sort((left, right) => entryKey(left).localeCompare(entryKey(right)));
61679
- if (new Set(entries.map(entryKey)).size !== entries.length) {
61680
- throw new TypeError("Recovery inventory contains duplicate entries.");
61681
- }
61682
- return Object.freeze({ version: 1, entries: Object.freeze(entries) });
61683
- }
61684
- function publicDocument(entries) {
61685
- return Object.freeze({
61686
- version: 1,
61687
- entries: Object.freeze([...entries].sort((left, right) => entryKey(left).localeCompare(entryKey(right))))
61688
- });
61689
- }
61690
- function formatRecoveryInventoryEntry(entryValue) {
61691
- const entry2 = parseEntry(entryValue);
61692
- if (entry2.type === "agent_purchase") {
61693
- return Object.freeze({
61694
- type: "agent_purchase",
61695
- operationId: entry2.operationId,
61696
- command: `finch purchase submit ${entry2.operationId}`,
61697
- blockedReason: null,
61698
- guidance: null
61699
- });
61700
- }
61701
- if (entry2.type === "task") {
61702
- return Object.freeze({
61703
- type: "task",
61704
- taskId: entry2.taskId,
61705
- kind: entry2.kind,
61706
- command: `finch task recover ${entry2.taskId} ${entry2.kind}`,
61707
- blockedReason: null,
61708
- guidance: null
61709
- });
61710
- }
61711
- return Object.freeze({
61712
- type: "skill",
61713
- kind: entry2.kind,
61714
- fingerprint: entry2.fingerprint,
61715
- command: `finch skill recover ${entry2.kind} ${entry2.fingerprint}`,
61716
- blockedReason: null,
61717
- guidance: null
61718
- });
61719
- }
61720
- var UUID3, FINGERPRINT2, TASK_KINDS, SKILL_KINDS, RecoveryInventory;
61721
- var init_recovery_inventory = __esm({
61722
- "src/recovery-inventory.ts"() {
61723
- "use strict";
61724
- UUID3 = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/u;
61725
- FINGERPRINT2 = /^[0-9a-f]{64}$/u;
61726
- TASK_KINDS = Object.freeze(["publish", "award", "reclaim"]);
61727
- SKILL_KINDS = Object.freeze(["publication", "intent"]);
61728
- RecoveryInventory = class {
61729
- constructor(storage) {
61730
- this.storage = storage;
61731
- }
61732
- storage;
61733
- async add(entryValue) {
61734
- const entry2 = parseEntry(entryValue);
61735
- const current = await this.list();
61736
- const key = entryKey(entry2);
61737
- const existing = current.find((candidate) => entryKey(candidate) === key);
61738
- if (existing !== void 0) return existing;
61739
- const next = [...current, entry2];
61740
- await this.storage.write(publicDocument(next));
61741
- return entry2;
61742
- }
61743
- async remove(keyValue) {
61744
- const key = parseKey(keyValue);
61745
- const current = await this.list();
61746
- const next = current.filter((entry2) => entryKey(entry2) !== entryKey(key));
61747
- if (next.length === current.length) return false;
61748
- await this.storage.write(publicDocument(next));
61749
- return true;
61750
- }
61751
- async list() {
61752
- return document(await this.storage.read()).entries;
61753
- }
61754
- async format() {
61755
- return Object.freeze((await this.list()).map(formatRecoveryInventoryEntry));
61756
- }
61757
- };
61758
- }
61759
- });
61760
-
61761
61561
  // src/wallet-store.ts
61762
61562
  function record3(value) {
61763
61563
  if (typeof value !== "object" || value === null || Array.isArray(value)) {
@@ -61967,7 +61767,7 @@ var init_wallet_store = __esm({
61967
61767
  import { randomBytes as randomBytes2 } from "node:crypto";
61968
61768
  import { lstat as lstat3 } from "node:fs/promises";
61969
61769
  import { join as join3 } from "node:path";
61970
- function object5(value, name) {
61770
+ function object4(value, name) {
61971
61771
  if (typeof value !== "object" || value === null || Array.isArray(value)) {
61972
61772
  throw new CliStateError("CLI_STATE_CORRUPT", { cause: new TypeError(`${name} must be an object.`) });
61973
61773
  }
@@ -61990,7 +61790,7 @@ function endpointOrigin(value) {
61990
61790
  }
61991
61791
  function secretRecord(value, name) {
61992
61792
  try {
61993
- return object5(JSON.parse(value.toString("utf8")), name);
61793
+ return object4(JSON.parse(value.toString("utf8")), name);
61994
61794
  } catch (cause) {
61995
61795
  if (cause instanceof CliStateError) throw cause;
61996
61796
  throw new CliStateError("CLI_STATE_CORRUPT", { cause });
@@ -62007,20 +61807,6 @@ function taskRecoveryKind(value) {
62007
61807
  function hasCheckpoint(value) {
62008
61808
  return typeof value === "object" && value !== null && !Array.isArray(value) && typeof value.transactionHash === "string" && TRANSACTION_HASH.test(value.transactionHash);
62009
61809
  }
62010
- function hasAgentPurchaseCheckpoint(value) {
62011
- if (typeof value !== "object" || value === null || Array.isArray(value)) return false;
62012
- const journal = value;
62013
- return ["approval", "purchase", "revocation"].some((phase) => hasCheckpoint(journal[phase]));
62014
- }
62015
- function hasSkillPublicationCheckpoint(value) {
62016
- if (typeof value !== "object" || value === null || Array.isArray(value)) return false;
62017
- const journal = value;
62018
- if (journal.version === 6 && ["primary", "uri", "lit"].includes(String(journal.pendingStage))) return true;
62019
- const receipts = value.receipts;
62020
- if (typeof receipts !== "object" || receipts === null || Array.isArray(receipts)) return false;
62021
- const stages = receipts;
62022
- return ["primary", "uri", "lit"].some((stage) => hasCheckpoint(stages[stage]));
62023
- }
62024
61810
  function hasTaskRecoveryCheckpoint(value, kind) {
62025
61811
  if (typeof value !== "object" || value === null || Array.isArray(value)) return false;
62026
61812
  if (kind === "award") {
@@ -62029,7 +61815,7 @@ function hasTaskRecoveryCheckpoint(value, kind) {
62029
61815
  }
62030
61816
  return hasCheckpoint(value);
62031
61817
  }
62032
- function hasSkillBuyerIntentCheckpoint(value, fingerprint2) {
61818
+ function hasSkillBuyerIntentCheckpoint(value, fingerprint) {
62033
61819
  if (typeof value !== "object" || value === null || Array.isArray(value)) return false;
62034
61820
  const journal = value;
62035
61821
  const intent2 = journal.intent;
@@ -62038,37 +61824,24 @@ function hasSkillBuyerIntentCheckpoint(value, fingerprint2) {
62038
61824
  const authority = intentRecord.signingAuthority;
62039
61825
  if (typeof authority !== "object" || authority === null || Array.isArray(authority)) return false;
62040
61826
  const authorityRecord = authority;
62041
- return journal.version === 1 && journal.journalKind === "buyer_intent" && journal.fingerprint === fingerprint2 && ["purchase", "convert", "set_unit_price", "set_max_supply", "presentation"].includes(String(journal.kind)) && intentRecord.kind === journal.kind && typeof journal.accountId === "string" && UUID4.test(journal.accountId) && typeof journal.walletAddress === "string" && /^0x[0-9a-f]{40}$/u.test(journal.walletAddress) && (journal.environment === "local" || journal.environment === "test" || journal.environment === "production") && intentRecord.walletAddress === journal.walletAddress && authorityRecord.accountId === journal.accountId && authorityRecord.walletAddress === journal.walletAddress && authorityRecord.environment === journal.environment && typeof journal.transactionHash === "string" && TRANSACTION_HASH.test(journal.transactionHash) && (journal.blockNumber === null || typeof journal.blockNumber === "string" && /^[1-9][0-9]*$/u.test(journal.blockNumber)) && (journal.confirmStatus === "broadcast" || journal.confirmStatus === "receipt_confirmed" || journal.confirmStatus === "projection_confirmed") && (journal.confirmStatus === "broadcast" ? journal.blockNumber === null : journal.blockNumber !== null) && typeof journal.idempotencyKey === "string" && journal.idempotencyKey.length > 0;
61827
+ return journal.version === 1 && journal.journalKind === "buyer_intent" && journal.fingerprint === fingerprint && ["purchase", "convert", "set_unit_price", "set_max_supply", "presentation"].includes(String(journal.kind)) && intentRecord.kind === journal.kind && typeof journal.accountId === "string" && UUID3.test(journal.accountId) && typeof journal.walletAddress === "string" && /^0x[0-9a-f]{40}$/u.test(journal.walletAddress) && (journal.environment === "local" || journal.environment === "test" || journal.environment === "production") && intentRecord.walletAddress === journal.walletAddress && authorityRecord.accountId === journal.accountId && authorityRecord.walletAddress === journal.walletAddress && authorityRecord.environment === journal.environment && typeof journal.transactionHash === "string" && TRANSACTION_HASH.test(journal.transactionHash) && (journal.blockNumber === null || typeof journal.blockNumber === "string" && /^[1-9][0-9]*$/u.test(journal.blockNumber)) && (journal.confirmStatus === "broadcast" || journal.confirmStatus === "receipt_confirmed" || journal.confirmStatus === "projection_confirmed") && (journal.confirmStatus === "broadcast" ? journal.blockNumber === null : journal.blockNumber !== null) && typeof journal.idempotencyKey === "string" && journal.idempotencyKey.length > 0;
62042
61828
  }
62043
- var RECOVERY_FINGERPRINT, TRANSACTION_HASH, UUID4, LocalCliState;
61829
+ var RECOVERY_FINGERPRINT, TRANSACTION_HASH, UUID3, LocalCliState;
62044
61830
  var init_local_state = __esm({
62045
61831
  "src/local-state.ts"() {
62046
61832
  "use strict";
62047
61833
  init_v1();
62048
61834
  init_state();
62049
- init_recovery_inventory();
62050
61835
  init_wallet_store();
62051
61836
  RECOVERY_FINGERPRINT = /^[0-9a-f]{64}$/u;
62052
61837
  TRANSACTION_HASH = /^0x[0-9a-f]{64}$/u;
62053
- UUID4 = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/u;
61838
+ UUID3 = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/u;
62054
61839
  LocalCliState = class {
62055
61840
  files;
62056
61841
  wallets;
62057
- recoveryInventory;
62058
61842
  constructor(home, fileStoreOptions = {}) {
62059
61843
  this.files = new HardenedFileStore(home, fileStoreOptions);
62060
61844
  this.wallets = new WalletStore(home, { fileStoreOptions });
62061
- this.recoveryInventory = new RecoveryInventory({
62062
- read: async () => {
62063
- try {
62064
- return await this.files.readJson("mutations/recovery-index.json");
62065
- } catch (cause) {
62066
- if (cause instanceof CliStateError && cause.code === "CLI_STATE_NOT_FOUND") return null;
62067
- throw cause;
62068
- }
62069
- },
62070
- write: async (document2) => this.files.writeJson("mutations/recovery-index.json", document2)
62071
- });
62072
61845
  }
62073
61846
  async readAgentPurchaseRecovery(operationId) {
62074
61847
  parseCanonicalUuid(operationId, "operationId");
@@ -62082,35 +61855,27 @@ var init_local_state = __esm({
62082
61855
  async saveAgentPurchaseRecovery(operationId, value) {
62083
61856
  parseCanonicalUuid(operationId, "operationId");
62084
61857
  await this.files.writeJson(`mutations/agent-purchases/${operationId}.secret`, value);
62085
- if (hasAgentPurchaseCheckpoint(value)) {
62086
- await this.recoveryInventory.add({ type: "agent_purchase", operationId });
62087
- }
62088
61858
  }
62089
61859
  async clearAgentPurchaseRecovery(operationId) {
62090
61860
  parseCanonicalUuid(operationId, "operationId");
62091
61861
  await this.files.remove(`mutations/agent-purchases/${operationId}.secret`);
62092
- await this.recoveryInventory.remove({ type: "agent_purchase", operationId });
62093
61862
  }
62094
- async readSkillPublicationRecovery(fingerprint2) {
62095
- recoveryFingerprint2(fingerprint2);
61863
+ async readSkillPublicationRecovery(fingerprint) {
61864
+ recoveryFingerprint2(fingerprint);
62096
61865
  try {
62097
- return await this.files.readJson(`mutations/skill-publications/${fingerprint2}.secret`);
61866
+ return await this.files.readJson(`mutations/skill-publications/${fingerprint}.secret`);
62098
61867
  } catch (cause) {
62099
61868
  if (cause instanceof CliStateError && cause.code === "CLI_STATE_NOT_FOUND") return null;
62100
61869
  throw cause;
62101
61870
  }
62102
61871
  }
62103
- async saveSkillPublicationRecovery(fingerprint2, value) {
62104
- recoveryFingerprint2(fingerprint2);
62105
- await this.files.writeJson(`mutations/skill-publications/${fingerprint2}.secret`, value);
62106
- if (hasSkillPublicationCheckpoint(value)) {
62107
- await this.recoveryInventory.add({ type: "skill", kind: "publication", fingerprint: fingerprint2 });
62108
- }
61872
+ async saveSkillPublicationRecovery(fingerprint, value) {
61873
+ recoveryFingerprint2(fingerprint);
61874
+ await this.files.writeJson(`mutations/skill-publications/${fingerprint}.secret`, value);
62109
61875
  }
62110
- async clearSkillPublicationRecovery(fingerprint2) {
62111
- recoveryFingerprint2(fingerprint2);
62112
- await this.files.remove(`mutations/skill-publications/${fingerprint2}.secret`);
62113
- await this.recoveryInventory.remove({ type: "skill", kind: "publication", fingerprint: fingerprint2 });
61876
+ async clearSkillPublicationRecovery(fingerprint) {
61877
+ recoveryFingerprint2(fingerprint);
61878
+ await this.files.remove(`mutations/skill-publications/${fingerprint}.secret`);
62114
61879
  }
62115
61880
  async readTaskRecovery(taskId, kindValue) {
62116
61881
  const id = parseCanonicalUuid(taskId, "taskId");
@@ -62127,43 +61892,36 @@ var init_local_state = __esm({
62127
61892
  const kind = taskRecoveryKind(kindValue);
62128
61893
  if (!hasTaskRecoveryCheckpoint(value, kind)) throw new CliStateError("CLI_STATE_CORRUPT");
62129
61894
  await this.files.writeJson(`mutations/tasks/${id}/${kind}.secret`, value);
62130
- await this.recoveryInventory.add({ type: "task", taskId: id, kind });
62131
61895
  }
62132
61896
  async clearTaskRecovery(taskId, kindValue) {
62133
61897
  const id = parseCanonicalUuid(taskId, "taskId");
62134
61898
  const kind = taskRecoveryKind(kindValue);
62135
61899
  await this.files.remove(`mutations/tasks/${id}/${kind}.secret`);
62136
- await this.recoveryInventory.remove({ type: "task", taskId: id, kind });
62137
61900
  }
62138
61901
  async readSkillBuyerIntentRecovery(fingerprintValue) {
62139
- const fingerprint2 = recoveryFingerprint2(fingerprintValue);
61902
+ const fingerprint = recoveryFingerprint2(fingerprintValue);
62140
61903
  try {
62141
- return await this.files.readJson(`mutations/skill-buyer-intents/${fingerprint2}.secret`);
61904
+ return await this.files.readJson(`mutations/skill-buyer-intents/${fingerprint}.secret`);
62142
61905
  } catch (cause) {
62143
61906
  if (cause instanceof CliStateError && cause.code === "CLI_STATE_NOT_FOUND") return null;
62144
61907
  throw cause;
62145
61908
  }
62146
61909
  }
62147
61910
  async saveSkillBuyerIntentRecovery(fingerprintValue, value) {
62148
- const fingerprint2 = recoveryFingerprint2(fingerprintValue);
62149
- if (!hasSkillBuyerIntentCheckpoint(value, fingerprint2)) throw new CliStateError("CLI_STATE_CORRUPT");
62150
- await this.files.writeJson(`mutations/skill-buyer-intents/${fingerprint2}.secret`, value);
62151
- await this.recoveryInventory.add({ type: "skill", kind: "intent", fingerprint: fingerprint2 });
61911
+ const fingerprint = recoveryFingerprint2(fingerprintValue);
61912
+ if (!hasSkillBuyerIntentCheckpoint(value, fingerprint)) throw new CliStateError("CLI_STATE_CORRUPT");
61913
+ await this.files.writeJson(`mutations/skill-buyer-intents/${fingerprint}.secret`, value);
62152
61914
  }
62153
61915
  async clearSkillBuyerIntentRecovery(fingerprintValue) {
62154
- const fingerprint2 = recoveryFingerprint2(fingerprintValue);
62155
- await this.files.remove(`mutations/skill-buyer-intents/${fingerprint2}.secret`);
62156
- await this.recoveryInventory.remove({ type: "skill", kind: "intent", fingerprint: fingerprint2 });
62157
- }
62158
- async listBlockingRecoveries() {
62159
- return this.recoveryInventory.format();
61916
+ const fingerprint = recoveryFingerprint2(fingerprintValue);
61917
+ await this.files.remove(`mutations/skill-buyer-intents/${fingerprint}.secret`);
62160
61918
  }
62161
61919
  async writeProfile(input) {
62162
61920
  await this.files.writeJson("profile.json", { version: 1, origin: endpointOrigin(input.origin) });
62163
61921
  }
62164
61922
  async readProfile() {
62165
61923
  try {
62166
- const value = object5(await this.files.readJson("profile.json"), "profile");
61924
+ const value = object4(await this.files.readJson("profile.json"), "profile");
62167
61925
  if (value.version !== 1 || Object.keys(value).sort().join(",") !== "origin,version") {
62168
61926
  throw new CliStateError("CLI_STATE_CORRUPT");
62169
61927
  }
@@ -62222,7 +61980,7 @@ var init_local_state = __esm({
62222
61980
  }), "utf8"), { exclusive: true });
62223
61981
  }
62224
61982
  async activateSession(input) {
62225
- const value = object5(input, "session");
61983
+ const value = object4(input, "session");
62226
61984
  parseCanonicalUuid(value.sessionId, "sessionId");
62227
61985
  parseCanonicalUuid(value.accountId, "accountId");
62228
61986
  if (typeof value.walletAddress !== "string" || !/^0x[0-9a-f]{40}$/u.test(value.walletAddress) || value.audience !== "agent_cli" || typeof value.sessionExpiresAt !== "string") {
@@ -62275,7 +62033,7 @@ var init_local_state = __esm({
62275
62033
  }
62276
62034
  async readSession() {
62277
62035
  try {
62278
- const metadata = object5(await this.files.readJson("session/metadata.json"), "session metadata");
62036
+ const metadata = object4(await this.files.readJson("session/metadata.json"), "session metadata");
62279
62037
  const rawBearer = (await this.files.readSecret("session/bearer")).toString("utf8");
62280
62038
  const sessionId = parseCanonicalUuid(metadata.sessionId, "sessionId");
62281
62039
  const accountId = parseCanonicalUuid(metadata.accountId, "accountId");
@@ -64123,14 +63881,6 @@ function failure(error51) {
64123
63881
  message: `${marker === "pending" ? "This recovery stopped after the transaction was prepared for sending" : "This recovery journal predates the pre-send marker"}, so whether ${unknown2} cannot be established locally. Read the Skill on chain first: if ${settled}, the transaction landed and only the local journal is behind. Contact support with this state rather than re-running the command.`
64124
63882
  };
64125
63883
  }
64126
- if (error51 instanceof CliRecoveryBlockedError) {
64127
- return {
64128
- code: "AGENT_MARKET_STATE_CONFLICT",
64129
- exitCode: AGENT_CLI_OUTPUT_CONTRACT.exitCodes.conflictOrPrecondition,
64130
- message: "Recover the listed irreversible operations before logging out or switching Account.",
64131
- state: JSON.stringify({ recoveryCommands: error51.recoveryCommands })
64132
- };
64133
- }
64134
63884
  if (error51 instanceof CliHttpError) {
64135
63885
  if (error51.code === "CLI_RESPONSE_INVALID") {
64136
63886
  return { code: "CLI_RESPONSE_INVALID", exitCode: 7, message: "Remote response is invalid." };
@@ -64226,6 +63976,11 @@ function emitCliOutcome(outcome, sinks) {
64226
63976
  return AGENT_CLI_OUTPUT_CONTRACT.exitCodes.conflictOrPrecondition;
64227
63977
  }
64228
63978
  if (outcome instanceof CliHttpError && outcome.envelope !== null && outcome.status !== null) {
63979
+ const remoteError = outcome.envelope.error;
63980
+ if (outcome.status === 401 && remoteError?.code === "AGENT_SESSION_INVALID") {
63981
+ sinks.stderr(`${CLI_SESSION_RENEWAL_GUIDANCE}
63982
+ `);
63983
+ }
64229
63984
  sinks.stdout(`${JSON.stringify(outcome.envelope)}
64230
63985
  `);
64231
63986
  return remoteExitCode(outcome.status);