@finchtech/cli 0.2.0 → 0.2.2

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 (2) hide show
  1. package/dist/finch.js +702 -200
  2. package/package.json +16 -15
package/dist/finch.js CHANGED
@@ -28055,6 +28055,58 @@ var init_agent_service = __esm({
28055
28055
  }
28056
28056
  });
28057
28057
 
28058
+ // ../../packages/deployment-manifest/src/chains/legacy-skill-indexer.json
28059
+ var legacy_skill_indexer_default;
28060
+ var init_legacy_skill_indexer = __esm({
28061
+ "../../packages/deployment-manifest/src/chains/legacy-skill-indexer.json"() {
28062
+ legacy_skill_indexer_default = {
28063
+ schemaVersion: 1,
28064
+ service: "legacy_skill_indexer",
28065
+ chains: {
28066
+ "1": {
28067
+ tailRpcUrls: ["https://eth.drpc.org", "https://ethereum.reth.rs/rpc"],
28068
+ backfillRpcUrls: ["https://eth.drpc.org", "https://ethereum.reth.rs/rpc"],
28069
+ archiveStateRpcUrls: ["https://eth.drpc.org", "https://ethereum.reth.rs/rpc"]
28070
+ },
28071
+ "10": {
28072
+ tailRpcUrls: ["https://optimism.drpc.org", "https://optimism.gateway.tenderly.co"],
28073
+ backfillRpcUrls: ["https://optimism.drpc.org", "https://optimism.gateway.tenderly.co"],
28074
+ archiveStateRpcUrls: ["https://optimism.drpc.org", "https://optimism.gateway.tenderly.co"]
28075
+ },
28076
+ "56": {
28077
+ tailRpcUrls: [
28078
+ "https://0.48.club",
28079
+ "https://bsc.rpc.blxrbdn.com",
28080
+ "https://bsc-mainnet.public.blastapi.io"
28081
+ ],
28082
+ backfillRpcUrls: [
28083
+ "https://bsc.rpc.blxrbdn.com",
28084
+ "https://0.48.club",
28085
+ "https://bsc-mainnet.public.blastapi.io"
28086
+ ],
28087
+ archiveStateRpcUrls: [
28088
+ "https://bsc-mainnet.public.blastapi.io",
28089
+ "https://api.zan.top/bsc-mainnet"
28090
+ ]
28091
+ },
28092
+ "8453": {
28093
+ tailRpcUrls: ["https://mainnet.base.org", "https://base.gateway.tenderly.co"],
28094
+ backfillRpcUrls: ["https://mainnet.base.org", "https://base.gateway.tenderly.co"],
28095
+ archiveStateRpcUrls: ["https://mainnet.base.org", "https://base.gateway.tenderly.co"]
28096
+ },
28097
+ "42161": {
28098
+ tailRpcUrls: ["https://arb1.arbitrum.io/rpc", "https://arbitrum.gateway.tenderly.co"],
28099
+ backfillRpcUrls: ["https://arb1.arbitrum.io/rpc", "https://arbitrum.gateway.tenderly.co"],
28100
+ archiveStateRpcUrls: [
28101
+ "https://arbitrum.gateway.tenderly.co",
28102
+ "https://arbitrum-one.public.blastapi.io"
28103
+ ]
28104
+ }
28105
+ }
28106
+ };
28107
+ }
28108
+ });
28109
+
28058
28110
  // ../../packages/deployment-manifest/src/chains/skill-protocol.json
28059
28111
  var skill_protocol_default;
28060
28112
  var init_skill_protocol = __esm({
@@ -28465,13 +28517,14 @@ function getSkillProtocolDeployment(environment3, chainId) {
28465
28517
  maxLogBlockRange: value.network.maxLogBlockRange ?? DEFAULT_LOG_BLOCK_RANGE
28466
28518
  });
28467
28519
  }
28468
- var canonicalAddressSchema, hashSchema, commitSchema, positiveDecimalSchema, DEFAULT_LOG_BLOCK_RANGE, networkSchema, sourceSchema, disabledDeploymentSchema, deploymentsShape, agentActiveSchema, taskActiveSchema, skillActiveSchema, agentRegistrySchema, taskRegistrySchema, skillEnvironmentSchema, skillRegistrySchema, registrySchema, agentRegistry, taskRegistry, skillRegistry;
28520
+ var canonicalAddressSchema, hashSchema, commitSchema, positiveDecimalSchema, DEFAULT_LOG_BLOCK_RANGE, networkSchema, publicRpcUrlsSchema, legacySkillIndexerChainSchema, legacySkillIndexerRegistrySchema, sourceSchema, disabledDeploymentSchema, deploymentsShape, agentActiveSchema, taskActiveSchema, skillActiveSchema, agentRegistrySchema, taskRegistrySchema, skillEnvironmentSchema, skillRegistrySchema, registrySchema, agentRegistry, taskRegistry, skillRegistry, legacySkillIndexerRegistry;
28469
28521
  var init_chains = __esm({
28470
28522
  "../../packages/deployment-manifest/src/chains/index.ts"() {
28471
28523
  "use strict";
28472
28524
  init_zod();
28473
28525
  init_shared();
28474
28526
  init_agent_service();
28527
+ init_legacy_skill_indexer();
28475
28528
  init_skill_protocol();
28476
28529
  init_task_protocol();
28477
28530
  init_shared();
@@ -28488,6 +28541,23 @@ var init_chains = __esm({
28488
28541
  /** Omit where every listed endpoint serves the default window. */
28489
28542
  maxLogBlockRange: external_exports.number().int().min(1).max(DEFAULT_LOG_BLOCK_RANGE).optional()
28490
28543
  });
28544
+ publicRpcUrlsSchema = external_exports.array(
28545
+ external_exports.url().refine((value) => new URL(value).protocol === "https:")
28546
+ ).min(1).max(4);
28547
+ legacySkillIndexerChainSchema = external_exports.strictObject({
28548
+ tailRpcUrls: publicRpcUrlsSchema,
28549
+ backfillRpcUrls: publicRpcUrlsSchema,
28550
+ archiveStateRpcUrls: publicRpcUrlsSchema
28551
+ });
28552
+ legacySkillIndexerRegistrySchema = external_exports.strictObject({
28553
+ schemaVersion: external_exports.literal(1),
28554
+ service: external_exports.literal("legacy_skill_indexer"),
28555
+ chains: external_exports.record(external_exports.string().regex(/^[1-9][0-9]*$/u), legacySkillIndexerChainSchema)
28556
+ }).superRefine((value, context) => {
28557
+ if (Object.keys(value.chains).length === 0) {
28558
+ context.addIssue({ code: "custom", message: "The Legacy Skill indexer must list at least one chain." });
28559
+ }
28560
+ });
28491
28561
  sourceSchema = {
28492
28562
  sourceRepository: external_exports.string().regex(/^[A-Za-z0-9_.-]+\/[A-Za-z0-9_.-]+$/u),
28493
28563
  sourceCommit: commitSchema
@@ -28662,6 +28732,10 @@ var init_chains = __esm({
28662
28732
  agentRegistry = parseTypedRegistry(agentRegistrySchema, agent_service_default);
28663
28733
  taskRegistry = parseTypedRegistry(taskRegistrySchema, task_protocol_default);
28664
28734
  skillRegistry = parseTypedRegistry(skillRegistrySchema, skill_protocol_default);
28735
+ legacySkillIndexerRegistry = parseTypedRegistry(
28736
+ legacySkillIndexerRegistrySchema,
28737
+ legacy_skill_indexer_default
28738
+ );
28665
28739
  }
28666
28740
  });
28667
28741
 
@@ -35826,7 +35900,17 @@ var init_public = __esm({
35826
35900
  });
35827
35901
 
35828
35902
  // ../../packages/skill-market-contracts/src/deployment.ts
35829
- var environment2, deployment, delivery, SKILL_V3_SOURCE_COMMIT, SKILL_V3_CHAIN_ID, SKILL_V3_DEPLOYMENT_BLOCK, SKILL_V3_FACTORY_DEPLOYMENT_BLOCK, SKILL_V3_CHAIN_TAG, SKILL_V3_ADDRESSES, SKILL_V3_CHAIN_IDS;
35903
+ function skillV3SourceCommit(chainId) {
35904
+ const selected = SKILL_V3_DEPLOYMENTS.find((candidate) => candidate.chainId === chainId);
35905
+ if (selected === void 0) {
35906
+ throw new TypeError(`Skill V3 is not deployed to chain ${chainId} in this environment.`);
35907
+ }
35908
+ return selected.sourceCommit;
35909
+ }
35910
+ function skillV3ChainTag(chainId) {
35911
+ return getSkillDeliveryDeployment(environment2, chainId).chainTag;
35912
+ }
35913
+ var environment2, deployment, delivery, SKILL_V3_DEPLOYMENTS, SKILL_V3_CHAIN_IDS, SKILL_V3_CHAIN_ID, SKILL_V3_SOURCE_COMMIT, SKILL_V3_DEPLOYMENT_BLOCK, SKILL_V3_FACTORY_DEPLOYMENT_BLOCK, SKILL_V3_CHAIN_TAG, SKILL_V3_ADDRESSES;
35830
35914
  var init_deployment = __esm({
35831
35915
  "../../packages/skill-market-contracts/src/deployment.ts"() {
35832
35916
  "use strict";
@@ -35836,8 +35920,17 @@ var init_deployment = __esm({
35836
35920
  environment2 = resolveSkillProtocolEnvironment(process.env.FINCH_ENVIRONMENT);
35837
35921
  deployment = getSkillProtocolDeployment(environment2);
35838
35922
  delivery = getSkillDeliveryDeployment(environment2, deployment.chainId);
35839
- SKILL_V3_SOURCE_COMMIT = deployment.sourceCommit;
35923
+ SKILL_V3_DEPLOYMENTS = Object.freeze(
35924
+ getSkillProtocolChainIds(environment2).map((chainId) => {
35925
+ const selected = getSkillProtocolDeployment(environment2, chainId);
35926
+ return Object.freeze({ chainId, sourceCommit: selected.sourceCommit });
35927
+ })
35928
+ );
35929
+ SKILL_V3_CHAIN_IDS = Object.freeze(
35930
+ SKILL_V3_DEPLOYMENTS.map(({ chainId }) => chainId)
35931
+ );
35840
35932
  SKILL_V3_CHAIN_ID = deployment.chainId;
35933
+ SKILL_V3_SOURCE_COMMIT = skillV3SourceCommit(SKILL_V3_CHAIN_ID);
35841
35934
  SKILL_V3_DEPLOYMENT_BLOCK = BigInt(deployment.deploymentBlock);
35842
35935
  SKILL_V3_FACTORY_DEPLOYMENT_BLOCK = BigInt(deployment.factoryDeploymentBlock);
35843
35936
  SKILL_V3_CHAIN_TAG = delivery.chainTag;
@@ -35849,18 +35942,27 @@ var init_deployment = __esm({
35849
35942
  skillMarket: deployment.skillMarketAddress,
35850
35943
  feeRouter: deployment.feeRouterAddress
35851
35944
  });
35852
- SKILL_V3_CHAIN_IDS = getSkillProtocolChainIds(environment2);
35853
35945
  }
35854
35946
  });
35855
35947
 
35856
35948
  // ../../packages/skill-market-contracts/src/schemas.ts
35949
+ function authorityVariants(properties) {
35950
+ return Object.freeze(SKILL_V3_DEPLOYMENTS.map(({ chainId, sourceCommit }) => strictObjectSchema3({
35951
+ ...properties,
35952
+ sourceCommit: { const: sourceCommit },
35953
+ chainId: { const: chainId }
35954
+ })));
35955
+ }
35956
+ function authorityObjectSchema(properties) {
35957
+ return Object.freeze({ oneOf: authorityVariants(properties) });
35958
+ }
35857
35959
  function skillIntentConfirmationIdempotencyKey(chainId, transactionHash3) {
35858
- if (chainId !== 8453 && chainId !== 84532 || !/^0x[0-9a-f]{64}$/u.test(transactionHash3)) {
35960
+ if (!SKILL_V3_CHAIN_IDS.includes(chainId) || !/^0x[0-9a-f]{64}$/u.test(transactionHash3)) {
35859
35961
  throw new TypeError("Skill confirmation identity is invalid.");
35860
35962
  }
35861
35963
  return `skill-intent-confirm:${chainId}:${transactionHash3}`;
35862
35964
  }
35863
- var versionSchema, skillCategorySchema, nullableSkillCategorySchema, skillSigningAuthoritySchema, skillSourceKindSchema, skillContentModeSchema, skillListRequestSchema, skillDetailRequestSchema, skillDeliveryRequestSchema, skillPurchaseIntentRequestSchema, skillConvertIntentRequestSchema, skillPublicationPrepareRequestFields, skillPublicationPrepareRequestSchema, skillVersionPrepareRequestSchema, skillSetUnitPriceIntentRequestSchema, skillSetMaxSupplyIntentRequestSchema, skillDisplayCategoryUpdateRequestSchema, skillDisplayCategoryResponseSchema, sellStatusSchema, skillProjectionSchema, skillSearchProjectionSchema, skillListResponseSchema, skillLitDataSchema, skillDeliveryFields, skillDeliveryResponseSchema, intentResponseFields, skillBuyerIntentResponseSchema, skillSetUnitPriceIntentResponseSchema, skillSetMaxSupplyIntentResponseSchema, skillIntentResponseSchema, publishLocalActionSchema, versionLocalActionSchema, skillPublicationPrepareResponseSchema, skillVersionPrepareResponseSchema, nullableText, boundedTextList, skillPresentationSchema, skillDetailResponseSchema, skillManageRequestSchema, skillManageResponseSchema, skillPresentationPrepareRequestSchema, skillPresentationPrepareResponseSchema, skillAssetPrepareRequestSchema, skillAssetPrepareResponseSchema, skillIntentConfirmRequestSchema, skillIntentConfirmResponseSchema, skillErrorEnvelopeSchema;
35965
+ var versionSchema, skillChainIdSchema, SKILL_MARKET_MAX_JSON_BODY_BYTES, SKILL_PRESENTATION_MAX_INLINE_DECODED_BYTES, skillCategorySchema, nullableSkillCategorySchema, skillSigningAuthoritySchema, skillSourceKindSchema, skillContentModeSchema, skillListRequestSchema, skillDetailRequestSchema, skillDeliveryRequestSchema, skillPurchaseIntentRequestSchema, skillConvertIntentRequestSchema, skillPublicationPrepareRequestFields, skillPublicationPrepareRequestSchema, skillVersionPrepareRequestSchema, skillSetUnitPriceIntentRequestSchema, skillSetMaxSupplyIntentRequestSchema, skillDisplayCategoryUpdateRequestSchema, skillDisplayCategoryResponseSchema, sellStatusSchema, skillProjectionSchema, skillSearchProjectionSchema, skillListResponseSchema, skillLitDataSchema, skillDeliveryFields, skillDeliveryResponseSchema, intentResponseFields, skillBuyerIntentResponseVariants, skillSetUnitPriceIntentResponseVariants, skillSetMaxSupplyIntentResponseVariants, skillIntentResponseSchema, publishLocalActionSchema, versionLocalActionSchema, skillPublicationPrepareResponseSchema, skillVersionPrepareResponseSchema, nullableText, boundedTextList, skillPresentationSchema, skillDetailResponseSchema, skillManageRequestSchema, skillDocumentObjectSummarySchema, skillDocumentSummarySchema, nullableSkillDocumentSummarySchema, skillDocumentsSummarySchema, skillManageResponseSchema, skillInlineDetailAssetSchema, skillInlineDetailReplacementSchema, skillDocumentUpdatesSchema, skillPresentationPrepareRequestSchema, skillPresentationPrepareResponseSchema, skillAssetPrepareRequestSchema, skillAssetPrepareResponseSchema, skillIntentConfirmRequestSchema, skillIntentConfirmResponseSchema, skillErrorEnvelopeSchema;
35864
35966
  var init_schemas4 = __esm({
35865
35967
  "../../packages/skill-market-contracts/src/schemas.ts"() {
35866
35968
  "use strict";
@@ -35869,6 +35971,9 @@ var init_schemas4 = __esm({
35869
35971
  init_public();
35870
35972
  init_public();
35871
35973
  versionSchema = { type: "integer", minimum: 1, maximum: 4294967295 };
35974
+ skillChainIdSchema = { type: "integer", enum: SKILL_V3_CHAIN_IDS };
35975
+ SKILL_MARKET_MAX_JSON_BODY_BYTES = 4e6;
35976
+ SKILL_PRESENTATION_MAX_INLINE_DECODED_BYTES = 3e6;
35872
35977
  skillCategorySchema = { type: "string", enum: SKILL_CATEGORIES };
35873
35978
  nullableSkillCategorySchema = { type: ["string", "null"], enum: [...SKILL_CATEGORIES, null] };
35874
35979
  skillSigningAuthoritySchema = strictObjectSchema3({
@@ -35892,25 +35997,30 @@ var init_schemas4 = __esm({
35892
35997
  cursor: { type: "string", minLength: 1, maxLength: 512, pattern: "^[A-Za-z0-9_-]+$" }
35893
35998
  }, []);
35894
35999
  skillDetailRequestSchema = strictObjectSchema3({
36000
+ chainId: skillChainIdSchema,
35895
36001
  skillId: positiveIntegerStringSchema2,
35896
36002
  version: versionSchema
35897
- }, ["skillId"]);
36003
+ }, ["chainId", "skillId"]);
35898
36004
  skillDeliveryRequestSchema = strictObjectSchema3({
36005
+ chainId: skillChainIdSchema,
35899
36006
  skillId: positiveIntegerStringSchema2,
35900
36007
  version: versionSchema
35901
36008
  });
35902
36009
  skillPurchaseIntentRequestSchema = strictObjectSchema3({
36010
+ chainId: skillChainIdSchema,
35903
36011
  skillId: positiveIntegerStringSchema2,
35904
36012
  version: versionSchema,
35905
36013
  quantity: positiveIntegerStringSchema2
35906
36014
  });
35907
36015
  skillConvertIntentRequestSchema = strictObjectSchema3({
36016
+ chainId: skillChainIdSchema,
35908
36017
  skillId: positiveIntegerStringSchema2,
35909
36018
  fromVersion: versionSchema,
35910
36019
  toVersion: versionSchema,
35911
36020
  quantity: positiveIntegerStringSchema2
35912
36021
  });
35913
36022
  skillPublicationPrepareRequestFields = {
36023
+ chainId: skillChainIdSchema,
35914
36024
  slug: { type: "string", minLength: 9, maxLength: 200, pattern: "^[a-z0-9]+(?:-[a-z0-9]+)*_finchip$" },
35915
36025
  name: { type: "string", minLength: 1, maxLength: 200 },
35916
36026
  category: skillCategorySchema,
@@ -35925,23 +36035,28 @@ var init_schemas4 = __esm({
35925
36035
  };
35926
36036
  skillPublicationPrepareRequestSchema = strictObjectSchema3(skillPublicationPrepareRequestFields);
35927
36037
  skillVersionPrepareRequestSchema = strictObjectSchema3({
36038
+ chainId: skillChainIdSchema,
35928
36039
  skillId: positiveIntegerStringSchema2,
35929
36040
  sourceKind: skillSourceKindSchema,
35930
36041
  contentMode: skillContentModeSchema
35931
36042
  });
35932
36043
  skillSetUnitPriceIntentRequestSchema = strictObjectSchema3({
36044
+ chainId: skillChainIdSchema,
35933
36045
  skillId: positiveIntegerStringSchema2,
35934
36046
  unitPrice: unsignedIntegerStringSchema
35935
36047
  });
35936
36048
  skillSetMaxSupplyIntentRequestSchema = strictObjectSchema3({
36049
+ chainId: skillChainIdSchema,
35937
36050
  skillId: positiveIntegerStringSchema2,
35938
36051
  maxSupply: unsignedIntegerStringSchema
35939
36052
  });
35940
36053
  skillDisplayCategoryUpdateRequestSchema = strictObjectSchema3({
36054
+ chainId: skillChainIdSchema,
35941
36055
  skillId: positiveIntegerStringSchema2,
35942
36056
  displayCategory: nullableSkillCategorySchema
35943
36057
  });
35944
36058
  skillDisplayCategoryResponseSchema = strictObjectSchema3({
36059
+ chainId: skillChainIdSchema,
35945
36060
  skillId: positiveIntegerStringSchema2,
35946
36061
  declaredCategory: { type: "string", minLength: 1, maxLength: 100 },
35947
36062
  displayCategory: { type: ["string", "null"], minLength: 1, maxLength: 100 },
@@ -35954,7 +36069,7 @@ var init_schemas4 = __esm({
35954
36069
  supplyAvailable: { type: "boolean" }
35955
36070
  });
35956
36071
  skillProjectionSchema = strictObjectSchema3({
35957
- chainId: { const: SKILL_V3_CHAIN_ID },
36072
+ chainId: skillChainIdSchema,
35958
36073
  skillId: positiveIntegerStringSchema2,
35959
36074
  slug: { type: "string" },
35960
36075
  name: { type: "string" },
@@ -35978,7 +36093,7 @@ var init_schemas4 = __esm({
35978
36093
  sellStatus: sellStatusSchema
35979
36094
  });
35980
36095
  skillSearchProjectionSchema = strictObjectSchema3({
35981
- chainId: { const: SKILL_V3_CHAIN_ID },
36096
+ chainId: skillChainIdSchema,
35982
36097
  skillId: positiveIntegerStringSchema2,
35983
36098
  slug: { type: "string" },
35984
36099
  name: { type: "string" },
@@ -36013,7 +36128,7 @@ var init_schemas4 = __esm({
36013
36128
  chain: { type: "string", minLength: 1, maxLength: 100 }
36014
36129
  });
36015
36130
  skillDeliveryFields = {
36016
- chainId: { const: SKILL_V3_CHAIN_ID },
36131
+ chainId: skillChainIdSchema,
36017
36132
  skillId: positiveIntegerStringSchema2,
36018
36133
  version: versionSchema,
36019
36134
  packageURI: { type: "string", minLength: 1, maxLength: 2e3 },
@@ -36024,28 +36139,26 @@ var init_schemas4 = __esm({
36024
36139
  strictObjectSchema3({ ...skillDeliveryFields, entitledWallet: addressSchema2, plaintext: { const: false }, litData: skillLitDataSchema })
36025
36140
  ] });
36026
36141
  intentResponseFields = {
36027
- sourceCommit: { const: SKILL_V3_SOURCE_COMMIT },
36028
- chainId: { const: SKILL_V3_CHAIN_ID },
36029
36142
  to: addressSchema2,
36030
36143
  data: { type: "string", pattern: "^0x(?:[0-9a-fA-F]{2})+$" },
36031
36144
  value: unsignedIntegerStringSchema,
36032
36145
  summary: { type: "string", minLength: 1, maxLength: 500 }
36033
36146
  };
36034
- skillBuyerIntentResponseSchema = strictObjectSchema3({
36147
+ skillBuyerIntentResponseVariants = authorityVariants({
36035
36148
  kind: { type: "string", enum: ["purchase", "convert"] },
36036
36149
  ...intentResponseFields,
36037
36150
  walletAddress: addressSchema2,
36038
36151
  request: openObjectSchema2,
36039
36152
  signingAuthority: skillSigningAuthoritySchema
36040
36153
  });
36041
- skillSetUnitPriceIntentResponseSchema = strictObjectSchema3({
36154
+ skillSetUnitPriceIntentResponseVariants = authorityVariants({
36042
36155
  kind: { const: "set_unit_price" },
36043
36156
  ...intentResponseFields,
36044
36157
  walletAddress: addressSchema2,
36045
36158
  request: skillSetUnitPriceIntentRequestSchema,
36046
36159
  signingAuthority: skillSigningAuthoritySchema
36047
36160
  });
36048
- skillSetMaxSupplyIntentResponseSchema = strictObjectSchema3({
36161
+ skillSetMaxSupplyIntentResponseVariants = authorityVariants({
36049
36162
  kind: { const: "set_max_supply" },
36050
36163
  ...intentResponseFields,
36051
36164
  walletAddress: addressSchema2,
@@ -36053,9 +36166,9 @@ var init_schemas4 = __esm({
36053
36166
  signingAuthority: skillSigningAuthoritySchema
36054
36167
  });
36055
36168
  skillIntentResponseSchema = Object.freeze({ oneOf: [
36056
- skillBuyerIntentResponseSchema,
36057
- skillSetUnitPriceIntentResponseSchema,
36058
- skillSetMaxSupplyIntentResponseSchema
36169
+ ...skillBuyerIntentResponseVariants,
36170
+ ...skillSetUnitPriceIntentResponseVariants,
36171
+ ...skillSetMaxSupplyIntentResponseVariants
36059
36172
  ] });
36060
36173
  publishLocalActionSchema = strictObjectSchema3({
36061
36174
  client: { const: "finch" },
@@ -36066,10 +36179,8 @@ var init_schemas4 = __esm({
36066
36179
  command: { const: "skill version-submit" },
36067
36180
  arguments: strictObjectSchema3({ skillId: positiveIntegerStringSchema2 })
36068
36181
  });
36069
- skillPublicationPrepareResponseSchema = strictObjectSchema3({
36182
+ skillPublicationPrepareResponseSchema = authorityObjectSchema({
36070
36183
  kind: { const: "publish" },
36071
- sourceCommit: { const: SKILL_V3_SOURCE_COMMIT },
36072
- chainId: { const: SKILL_V3_CHAIN_ID },
36073
36184
  walletAddress: addressSchema2,
36074
36185
  signingAuthority: skillSigningAuthoritySchema,
36075
36186
  request: strictObjectSchema3({
@@ -36077,10 +36188,8 @@ var init_schemas4 = __esm({
36077
36188
  }),
36078
36189
  localAction: publishLocalActionSchema
36079
36190
  });
36080
- skillVersionPrepareResponseSchema = strictObjectSchema3({
36191
+ skillVersionPrepareResponseSchema = authorityObjectSchema({
36081
36192
  kind: { const: "version" },
36082
- sourceCommit: { const: SKILL_V3_SOURCE_COMMIT },
36083
- chainId: { const: SKILL_V3_CHAIN_ID },
36084
36193
  walletAddress: addressSchema2,
36085
36194
  signingAuthority: skillSigningAuthoritySchema,
36086
36195
  skillId: positiveIntegerStringSchema2,
@@ -36140,21 +36249,61 @@ var init_schemas4 = __esm({
36140
36249
  ...skillProjectionSchema.properties,
36141
36250
  presentation: { oneOf: [{ type: "null" }, skillPresentationSchema] }
36142
36251
  });
36143
- skillManageRequestSchema = strictObjectSchema3({ skillId: positiveIntegerStringSchema2 });
36252
+ skillManageRequestSchema = strictObjectSchema3({
36253
+ chainId: skillChainIdSchema,
36254
+ skillId: positiveIntegerStringSchema2
36255
+ });
36256
+ skillDocumentObjectSummarySchema = strictObjectSchema3({
36257
+ hash: bytes32Schema,
36258
+ mediaType: { type: "string", minLength: 1, maxLength: 100 },
36259
+ size: { type: "integer", minimum: 1, maximum: 4194304 }
36260
+ });
36261
+ skillDocumentSummarySchema = strictObjectSchema3({
36262
+ entry: skillDocumentObjectSummarySchema,
36263
+ assets: { type: "array", maxItems: 50, items: strictObjectSchema3({
36264
+ path: { type: "string", minLength: 1, maxLength: 135 },
36265
+ ...skillDocumentObjectSummarySchema.properties
36266
+ }) }
36267
+ });
36268
+ nullableSkillDocumentSummarySchema = {
36269
+ oneOf: [{ type: "null" }, skillDocumentSummarySchema]
36270
+ };
36271
+ skillDocumentsSummarySchema = strictObjectSchema3({
36272
+ information: nullableSkillDocumentSummarySchema,
36273
+ instruction: nullableSkillDocumentSummarySchema,
36274
+ benchmark: nullableSkillDocumentSummarySchema,
36275
+ showcase: nullableSkillDocumentSummarySchema
36276
+ });
36144
36277
  skillManageResponseSchema = strictObjectSchema3({
36145
36278
  skill: skillProjectionSchema,
36146
36279
  contentMode: skillContentModeSchema,
36147
36280
  currentManifestURI: { type: "string", minLength: 1, maxLength: 2e3 },
36148
- presentation: { oneOf: [{ type: "null" }, skillPresentationSchema] }
36149
- });
36281
+ presentation: { oneOf: [{ type: "null" }, skillPresentationSchema] },
36282
+ documents: skillDocumentsSummarySchema
36283
+ });
36284
+ skillInlineDetailAssetSchema = strictObjectSchema3({
36285
+ filename: { type: "string", minLength: 1, maxLength: 128 },
36286
+ mediaType: { type: "string", minLength: 1, maxLength: 100 },
36287
+ contentBase64: { type: "string", minLength: 4, maxLength: SKILL_MARKET_MAX_JSON_BODY_BYTES }
36288
+ });
36289
+ skillInlineDetailReplacementSchema = strictObjectSchema3({
36290
+ html: { type: "string", minLength: 1, maxLength: SKILL_PRESENTATION_MAX_INLINE_DECODED_BYTES },
36291
+ assets: { type: "array", maxItems: 50, items: skillInlineDetailAssetSchema }
36292
+ });
36293
+ skillDocumentUpdatesSchema = strictObjectSchema3({
36294
+ information: { oneOf: [{ type: "null" }, skillInlineDetailReplacementSchema] },
36295
+ instruction: { oneOf: [{ type: "null" }, skillInlineDetailReplacementSchema] },
36296
+ benchmark: { oneOf: [{ type: "null" }, skillInlineDetailReplacementSchema] },
36297
+ showcase: { oneOf: [{ type: "null" }, skillInlineDetailReplacementSchema] }
36298
+ }, []);
36150
36299
  skillPresentationPrepareRequestSchema = strictObjectSchema3({
36300
+ chainId: skillChainIdSchema,
36151
36301
  skillId: positiveIntegerStringSchema2,
36152
- presentation: skillPresentationSchema
36153
- });
36154
- skillPresentationPrepareResponseSchema = strictObjectSchema3({
36302
+ presentation: skillPresentationSchema,
36303
+ documentUpdates: skillDocumentUpdatesSchema
36304
+ }, ["chainId", "skillId", "presentation"]);
36305
+ skillPresentationPrepareResponseSchema = authorityObjectSchema({
36155
36306
  kind: { const: "presentation" },
36156
- sourceCommit: { const: SKILL_V3_SOURCE_COMMIT },
36157
- chainId: { const: SKILL_V3_CHAIN_ID },
36158
36307
  walletAddress: addressSchema2,
36159
36308
  signingAuthority: skillSigningAuthoritySchema,
36160
36309
  skillId: positiveIntegerStringSchema2,
@@ -36168,13 +36317,12 @@ var init_schemas4 = __esm({
36168
36317
  })
36169
36318
  });
36170
36319
  skillAssetPrepareRequestSchema = strictObjectSchema3({
36320
+ chainId: skillChainIdSchema,
36171
36321
  skillId: positiveIntegerStringSchema2,
36172
36322
  assetKind: { const: "cover" }
36173
36323
  });
36174
- skillAssetPrepareResponseSchema = strictObjectSchema3({
36324
+ skillAssetPrepareResponseSchema = authorityObjectSchema({
36175
36325
  kind: { const: "asset_upload" },
36176
- sourceCommit: { const: SKILL_V3_SOURCE_COMMIT },
36177
- chainId: { const: SKILL_V3_CHAIN_ID },
36178
36326
  walletAddress: addressSchema2,
36179
36327
  skillId: positiveIntegerStringSchema2,
36180
36328
  assetKind: { const: "cover" },
@@ -36193,14 +36341,18 @@ var init_schemas4 = __esm({
36193
36341
  })
36194
36342
  });
36195
36343
  skillIntentConfirmRequestSchema = strictObjectSchema3({
36196
- chainId: { type: "integer", enum: [8453, 84532] },
36344
+ chainId: skillChainIdSchema,
36197
36345
  transactionHash: transactionHashSchema2
36198
36346
  });
36199
36347
  skillIntentConfirmResponseSchema = strictObjectSchema3({
36200
36348
  status: { type: "string", enum: ["projected", "indexing_pending"] }
36201
36349
  });
36202
36350
  skillErrorEnvelopeSchema = strictObjectSchema3({
36203
- error: strictObjectSchema3({ code: { type: "string" }, message: { type: "string" } })
36351
+ error: strictObjectSchema3({
36352
+ code: { type: "string" },
36353
+ message: { type: "string" },
36354
+ traceId: { type: "string", minLength: 1, maxLength: 128, pattern: "^[A-Za-z0-9_-]+$" }
36355
+ })
36204
36356
  });
36205
36357
  }
36206
36358
  });
@@ -36305,6 +36457,27 @@ function jsonObject(value) {
36305
36457
  }
36306
36458
  return value;
36307
36459
  }
36460
+ function protectedResourceMetadataAuthority(authenticate, origin, resourcePath) {
36461
+ const matches = [...authenticate.matchAll(/(?:^|[\s,])resource_metadata="([^"]+)"/gu)];
36462
+ if (!/(?:^|[\s,])Bearer(?:[\s,]|$)/iu.test(authenticate) || matches.length !== 1) {
36463
+ throw new CliHttpError("CLI_RESPONSE_INVALID", 401);
36464
+ }
36465
+ let metadata;
36466
+ try {
36467
+ metadata = new URL(matches[0]?.[1] ?? "");
36468
+ } catch (cause) {
36469
+ throw new CliHttpError("CLI_RESPONSE_INVALID", 401, { cause });
36470
+ }
36471
+ const rootPath = "/.well-known/oauth-protected-resource";
36472
+ const allowedPaths = /* @__PURE__ */ new Set([rootPath, `${rootPath}${resourcePath}`]);
36473
+ if (metadata.origin !== origin || metadata.username !== "" || metadata.password !== "" || metadata.search !== "" || metadata.hash !== "" || !allowedPaths.has(metadata.pathname)) {
36474
+ throw new CliHttpError("CLI_RESPONSE_INVALID", 401);
36475
+ }
36476
+ return Object.freeze({
36477
+ path: metadata.pathname,
36478
+ resource: metadata.pathname === rootPath ? `${origin}/` : `${origin}${resourcePath}`
36479
+ });
36480
+ }
36308
36481
  async function readBoundedJson(response, maximumBytes = 65536) {
36309
36482
  const length = response.headers.get("content-length");
36310
36483
  if (length !== null && (!/^(?:0|[1-9][0-9]*)$/u.test(length) || Number(length) > maximumBytes)) {
@@ -36388,6 +36561,20 @@ function parseRemoteError(response, value) {
36388
36561
  }
36389
36562
  return envelope;
36390
36563
  }
36564
+ function parseSkillRemoteError(value) {
36565
+ if (value === null || typeof value !== "object" || Array.isArray(value)) throw new TypeError("Skill error envelope is invalid.");
36566
+ const error51 = value.error;
36567
+ if (error51 === null || typeof error51 !== "object" || Array.isArray(error51)) throw new TypeError("Skill error envelope is invalid.");
36568
+ const candidate = error51;
36569
+ if (typeof candidate.code !== "string" || candidate.code.length < 1 || typeof candidate.message !== "string" || candidate.message.length < 1 || candidate.traceId !== void 0 && (typeof candidate.traceId !== "string" || !/^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/u.test(candidate.traceId))) {
36570
+ throw new TypeError("Skill error envelope is invalid.");
36571
+ }
36572
+ return Object.freeze({ error: Object.freeze({
36573
+ code: candidate.code,
36574
+ message: candidate.message,
36575
+ ...candidate.traceId === void 0 ? {} : { traceId: candidate.traceId }
36576
+ }) });
36577
+ }
36391
36578
  var import_ajv, CLI_MERCHANT_OPERATION_IDS, CliHttpError, ajv, validatorCache, oauthAuthorizationResponseSchema, oauthErrorResponseSchema, AgentCliHttpClient;
36392
36579
  var init_api2 = __esm({
36393
36580
  "src/api.ts"() {
@@ -36524,8 +36711,13 @@ var init_api2 = __esm({
36524
36711
  throw new CliHttpError("CLI_REMOTE_UNAVAILABLE", null, { cause });
36525
36712
  }
36526
36713
  if (response.status !== expectedStatus) {
36527
- await readBoundedJson(response).catch(() => null);
36528
- throw new CliHttpError("CLI_REMOTE_UNAVAILABLE", response.status);
36714
+ try {
36715
+ const envelope = parseSkillRemoteError(await readBoundedJson(response));
36716
+ throw new CliHttpError("CLI_REMOTE_UNAVAILABLE", response.status, { envelope });
36717
+ } catch (cause) {
36718
+ if (cause instanceof CliHttpError) throw cause;
36719
+ throw new CliHttpError("CLI_RESPONSE_INVALID", response.status, { cause });
36720
+ }
36529
36721
  }
36530
36722
  return response;
36531
36723
  }
@@ -36542,22 +36734,28 @@ var init_api2 = __esm({
36542
36734
  }
36543
36735
  async inspectRemoteMcp() {
36544
36736
  const mcpUrl = `${this.origin}/mcp`;
36545
- const resourceMetadataUrl = `${this.origin}/.well-known/oauth-protected-resource`;
36546
36737
  const compatibilityManifestUrl = `${this.origin}/mcp/client-compatibility.json`;
36547
36738
  const challenge2 = await this.publicFetch("/mcp");
36548
36739
  const authenticate = challenge2.headers.get("www-authenticate");
36549
- if (challenge2.status !== 401 || authenticate === null || !authenticate.includes(`resource_metadata="${resourceMetadataUrl}"`)) {
36740
+ if (challenge2.status !== 401 || authenticate === null) {
36550
36741
  await challenge2.body?.cancel().catch(() => void 0);
36551
36742
  throw new CliHttpError("CLI_RESPONSE_INVALID", challenge2.status);
36552
36743
  }
36744
+ let resourceMetadataAuthority;
36745
+ try {
36746
+ resourceMetadataAuthority = protectedResourceMetadataAuthority(authenticate, this.origin, "/mcp");
36747
+ } catch (cause) {
36748
+ await challenge2.body?.cancel().catch(() => void 0);
36749
+ throw cause;
36750
+ }
36553
36751
  await challenge2.body?.cancel().catch(() => void 0);
36554
- const resourceResponse = await this.publicFetch("/.well-known/oauth-protected-resource");
36752
+ const resourceResponse = await this.publicFetch(resourceMetadataAuthority.path);
36555
36753
  if (resourceResponse.status !== 200) {
36556
36754
  await resourceResponse.body?.cancel().catch(() => void 0);
36557
36755
  throw new CliHttpError("CLI_REMOTE_UNAVAILABLE", resourceResponse.status);
36558
36756
  }
36559
36757
  const resource = jsonObject(await readBoundedJson(resourceResponse));
36560
- if (resource.resource !== `${this.origin}/` || JSON.stringify(resource.authorization_servers) !== JSON.stringify([this.origin])) {
36758
+ if (resource.resource !== resourceMetadataAuthority.resource || JSON.stringify(resource.authorization_servers) !== JSON.stringify([this.origin])) {
36561
36759
  throw new CliHttpError("CLI_RESPONSE_INVALID", resourceResponse.status);
36562
36760
  }
36563
36761
  const authorizationResponse = await this.publicFetch("/.well-known/oauth-authorization-server");
@@ -36620,10 +36818,10 @@ var init_api2 = __esm({
36620
36818
  body: JSON.stringify(body)
36621
36819
  }));
36622
36820
  }
36623
- async resolveSkillId(slug, bearer) {
36821
+ async resolveSkillId(chainId, slug, bearer) {
36624
36822
  let response;
36625
36823
  try {
36626
- response = await this.fetchImplementation(`${this.origin}/api/skills/resolve?${new URLSearchParams({ slug })}`, {
36824
+ response = await this.fetchImplementation(`${this.origin}/api/skills/resolve?${new URLSearchParams({ chainId: String(chainId), slug })}`, {
36627
36825
  method: "GET",
36628
36826
  headers: { authorization: `Bearer ${bearer}` },
36629
36827
  redirect: "error",
@@ -36637,15 +36835,20 @@ var init_api2 = __esm({
36637
36835
  return null;
36638
36836
  }
36639
36837
  if (response.status !== 200) {
36640
- await readBoundedJson(response).catch(() => null);
36641
- throw new CliHttpError("CLI_REMOTE_UNAVAILABLE", response.status);
36838
+ try {
36839
+ const envelope = parseSkillRemoteError(await readBoundedJson(response));
36840
+ throw new CliHttpError("CLI_REMOTE_UNAVAILABLE", response.status, { envelope });
36841
+ } catch (cause) {
36842
+ if (cause instanceof CliHttpError) throw cause;
36843
+ throw new CliHttpError("CLI_RESPONSE_INVALID", response.status, { cause });
36844
+ }
36642
36845
  }
36643
36846
  const body = await readBoundedJson(response);
36644
36847
  if (typeof body?.skillId !== "string" || !/^[1-9][0-9]*$/u.test(body.skillId)) throw new CliHttpError("CLI_RESPONSE_INVALID", 200);
36645
36848
  return body.skillId;
36646
36849
  }
36647
- async readSkillCurrentVersion(skillId, bearer) {
36648
- const response = await this.skillFetch(`/api/skills/resolve?${new URLSearchParams({ skillId })}`, {
36850
+ async readSkillCurrentVersion(chainId, skillId, bearer) {
36851
+ const response = await this.skillFetch(`/api/skills/resolve?${new URLSearchParams({ chainId: String(chainId), skillId })}`, {
36649
36852
  method: "GET",
36650
36853
  headers: { authorization: `Bearer ${bearer}` },
36651
36854
  cache: "no-store"
@@ -36658,7 +36861,7 @@ var init_api2 = __esm({
36658
36861
  const response = await this.skillFetch("/api/skills/content-key", {
36659
36862
  method: "POST",
36660
36863
  headers: { authorization: `Bearer ${input.bearer}`, "content-type": "application/json" },
36661
- body: JSON.stringify({ skillId: input.skillId, version: input.version, wallet: input.wallet, message: input.message, signature: input.signature })
36864
+ body: JSON.stringify({ chainId: input.chainId, skillId: input.skillId, version: input.version, wallet: input.wallet, message: input.message, signature: input.signature })
36662
36865
  });
36663
36866
  const body = await readBoundedJson(response);
36664
36867
  if (body.scheme === "FINCHIP_V2" && typeof body.key === "string" && /^0x[0-9a-fA-F]{64}$/u.test(body.key) && body.contentKey === null) return Object.freeze({ scheme: body.scheme, key: body.key, contentKey: null });
@@ -36675,6 +36878,7 @@ var init_api2 = __esm({
36675
36878
  "content-type": "application/json"
36676
36879
  },
36677
36880
  body: JSON.stringify({
36881
+ chainId: input.chainId,
36678
36882
  skillId: input.skillId,
36679
36883
  version: input.version,
36680
36884
  contentKey: input.contentKey
@@ -36694,24 +36898,36 @@ var init_api2 = __esm({
36694
36898
  });
36695
36899
  return readBoundedBytes(response, 1, 10 * 1024 * 1024);
36696
36900
  }
36697
- async confirmSkillProjection(transactionHash3, bearer) {
36901
+ async confirmSkillProjection(chainId, transactionHash3, bearer) {
36698
36902
  let response;
36699
36903
  try {
36700
36904
  response = await this.fetchImplementation(`${this.origin}/api/skills/projection`, {
36701
36905
  method: "POST",
36702
36906
  redirect: "error",
36703
36907
  headers: { authorization: `Bearer ${bearer}`, "content-type": "application/json" },
36704
- body: JSON.stringify({ transactionHash: transactionHash3 })
36908
+ body: JSON.stringify({ chainId, transactionHash: transactionHash3 })
36705
36909
  });
36706
36910
  } catch {
36707
36911
  return "indexing_pending";
36708
36912
  }
36709
36913
  if (response.status !== 200 && response.status !== 202) {
36710
- await response.body?.cancel().catch(() => void 0);
36711
- return "indexing_pending";
36914
+ try {
36915
+ const envelope = parseSkillRemoteError(await readBoundedJson(response));
36916
+ throw new CliHttpError("CLI_REMOTE_UNAVAILABLE", response.status, { envelope });
36917
+ } catch (cause) {
36918
+ if (cause instanceof CliHttpError) throw cause;
36919
+ throw new CliHttpError("CLI_RESPONSE_INVALID", response.status, { cause });
36920
+ }
36921
+ }
36922
+ let body;
36923
+ try {
36924
+ body = await readBoundedJson(response);
36925
+ } catch (cause) {
36926
+ throw new CliHttpError("CLI_RESPONSE_INVALID", response.status, { cause });
36712
36927
  }
36713
- const body = await readBoundedJson(response).catch(() => null);
36714
- return body?.status === "projected" ? "projected" : "indexing_pending";
36928
+ if (response.status === 200 && body?.status === "projected") return "projected";
36929
+ if (response.status === 202 && body?.status === "indexing_pending") return "indexing_pending";
36930
+ throw new CliHttpError("CLI_RESPONSE_INVALID", response.status);
36715
36931
  }
36716
36932
  getSession(bearer) {
36717
36933
  const operation4 = IDENTITY_V1_OPERATIONS.session;
@@ -37478,6 +37694,16 @@ var init_manifest = __esm({
37478
37694
  }
37479
37695
  });
37480
37696
 
37697
+ // ../../packages/skill-content/src/detail-documents.ts
37698
+ var init_detail_documents = __esm({
37699
+ "../../packages/skill-content/src/detail-documents.ts"() {
37700
+ "use strict";
37701
+ init_crypto();
37702
+ init_static_detail();
37703
+ init_manifest();
37704
+ }
37705
+ });
37706
+
37481
37707
  // ../../packages/skill-content/src/packaging.ts
37482
37708
  function filterPublishableFiles(files) {
37483
37709
  const included = [];
@@ -37627,6 +37853,7 @@ var init_src3 = __esm({
37627
37853
  "use strict";
37628
37854
  init_crypto();
37629
37855
  init_delivery_message();
37856
+ init_detail_documents();
37630
37857
  init_manifest();
37631
37858
  init_packaging();
37632
37859
  init_static_detail();
@@ -37655,6 +37882,11 @@ function integer2(value, name, minimum = 1) {
37655
37882
  if (!Number.isInteger(value) || Number(value) < minimum || Number(value) > 4294967295) throw new TypeError(`${name} is invalid.`);
37656
37883
  return Number(value);
37657
37884
  }
37885
+ function skillChain(value, name = "Skill chain") {
37886
+ const chainId = integer2(value, name);
37887
+ if (!SKILL_V3_CHAIN_IDS.includes(chainId)) throw new TypeError(`${name} is not deployed in this environment.`);
37888
+ return chainId;
37889
+ }
37658
37890
  function deliveryPackageUri(value) {
37659
37891
  return string4(value, "Skill package URI", IPFS);
37660
37892
  }
@@ -37678,10 +37910,12 @@ function assertPublicationAuthority(authority, context) {
37678
37910
  return authority;
37679
37911
  }
37680
37912
  function assertAuthority(plan, kind, walletAddress2, requiresSigning = true) {
37681
- if (plan.kind !== kind || plan.sourceCommit !== SKILL_V3_SOURCE_COMMIT || plan.chainId !== SKILL_V3_CHAIN_ID || typeof plan.walletAddress !== "string" || plan.walletAddress.toLowerCase() !== walletAddress2.toLowerCase()) {
37682
- throw new TypeError("Skill local-action authority does not match the active TEST wallet and deployment.");
37913
+ const chainId = skillChain(plan.chainId);
37914
+ if (plan.kind !== kind || plan.sourceCommit !== skillV3SourceCommit(chainId) || typeof plan.walletAddress !== "string" || plan.walletAddress.toLowerCase() !== walletAddress2.toLowerCase()) {
37915
+ throw new TypeError("Skill local-action authority does not match the active wallet and deployment.");
37683
37916
  }
37684
37917
  if (requiresSigning) signingAuthority(plan.signingAuthority, walletAddress2);
37918
+ return chainId;
37685
37919
  }
37686
37920
  function assertLocalAction(value, command, skillId) {
37687
37921
  const action = object4(value, "Skill local action");
@@ -37696,9 +37930,9 @@ function assertLocalAction(value, command, skillId) {
37696
37930
  function intent(value, walletAddress2) {
37697
37931
  const parsed = object4(value, "Skill intent");
37698
37932
  exact(parsed, ["chainId", "to", "data", "value", "summary", "signingAuthority"], "Skill intent");
37699
- if (parsed.chainId !== SKILL_V3_CHAIN_ID) throw new TypeError("Skill intent chain is invalid.");
37933
+ const chainId = skillChain(parsed.chainId, "Skill intent chain");
37700
37934
  return Object.freeze({
37701
- chainId: SKILL_V3_CHAIN_ID,
37935
+ chainId,
37702
37936
  to: string4(parsed.to, "Skill intent target", /^0x[0-9a-fA-F]{40}$/u),
37703
37937
  data: string4(parsed.data, "Skill intent calldata", /^0x(?:[0-9a-fA-F]{2})+$/u),
37704
37938
  value: string4(parsed.value, "Skill intent value", DECIMAL),
@@ -37706,6 +37940,11 @@ function intent(value, walletAddress2) {
37706
37940
  signingAuthority: signingAuthority(parsed.signingAuthority, walletAddress2)
37707
37941
  });
37708
37942
  }
37943
+ function legacyIntent(value, walletAddress2, authority) {
37944
+ const prepared = object4(value, "Skill legacy intent");
37945
+ exact(prepared, ["chainId", "to", "data", "value", "summary"], "Skill legacy intent");
37946
+ return intent({ ...prepared, signingAuthority: authority }, walletAddress2);
37947
+ }
37709
37948
  async function readPublishablePath(inputPath) {
37710
37949
  const root = resolve2(inputPath);
37711
37950
  const rootStat = await lstat2(root);
@@ -37742,10 +37981,11 @@ function contentMode(value) {
37742
37981
  function publishPlan(value, context) {
37743
37982
  const plan = object4(value, "Skill publish plan");
37744
37983
  exact(plan, ["kind", "sourceCommit", "chainId", "walletAddress", "signingAuthority", "request", "localAction"], "Skill publish plan");
37745
- assertAuthority(plan, "publish", context.walletAddress);
37984
+ const chainId = assertAuthority(plan, "publish", context.walletAddress);
37746
37985
  assertLocalAction(plan.localAction, "skill publish-submit");
37747
37986
  const request = object4(plan.request, "Skill publish request");
37748
- exact(request, ["slug", "name", "category", "licenseTypeName", "imageURI", "sourceKind", "contentMode", "unitPrice", "maxSupply", "royaltyBPS", "usageLimit"], "Skill publish request");
37987
+ exact(request, ["chainId", "slug", "name", "category", "licenseTypeName", "imageURI", "sourceKind", "contentMode", "unitPrice", "maxSupply", "royaltyBPS", "usageLimit"], "Skill publish request");
37988
+ if (request.chainId !== chainId) throw new TypeError("Skill publish request chain is invalid.");
37749
37989
  string4(request.slug, "Skill slug");
37750
37990
  string4(request.name, "Skill name");
37751
37991
  string4(request.category, "Skill category");
@@ -37760,6 +38000,7 @@ function publishPlan(value, context) {
37760
38000
  string4(request.usageLimit, "Skill usageLimit", DECIMAL);
37761
38001
  if (!Number.isInteger(request.royaltyBPS) || Number(request.royaltyBPS) < 0 || Number(request.royaltyBPS) > 1e3) throw new TypeError("Skill royaltyBPS is invalid.");
37762
38002
  return {
38003
+ chainId,
37763
38004
  request,
37764
38005
  signingAuthority: assertPublicationAuthority(signingAuthority(plan.signingAuthority, context.walletAddress), context)
37765
38006
  };
@@ -37767,14 +38008,15 @@ function publishPlan(value, context) {
37767
38008
  function versionPlan(value, context) {
37768
38009
  const plan = object4(value, "Skill version plan");
37769
38010
  exact(plan, ["kind", "sourceCommit", "chainId", "walletAddress", "signingAuthority", "skillId", "currentVersion", "nextVersion", "currentManifestURI", "sourceKind", "contentMode", "localAction"], "Skill version plan");
37770
- assertAuthority(plan, "version", context.walletAddress);
38011
+ const chainId = assertAuthority(plan, "version", context.walletAddress);
37771
38012
  const skillId = string4(plan.skillId, "Skill id", /^[1-9][0-9]*$/u);
37772
38013
  assertLocalAction(plan.localAction, "skill version-submit", skillId);
37773
- const request = { skillId, sourceKind: sourceKind(plan.sourceKind), contentMode: contentMode(plan.contentMode) };
38014
+ const request = { chainId, skillId, sourceKind: sourceKind(plan.sourceKind), contentMode: contentMode(plan.contentMode) };
37774
38015
  const currentVersion = integer2(plan.currentVersion, "Current version");
37775
38016
  const nextVersion = integer2(plan.nextVersion, "Next version");
37776
38017
  if (nextVersion !== currentVersion + 1) throw new TypeError("Skill version plan does not advance exactly one version.");
37777
38018
  return {
38019
+ chainId,
37778
38020
  request,
37779
38021
  currentVersion,
37780
38022
  nextVersion,
@@ -37787,13 +38029,14 @@ function versionPlan(value, context) {
37787
38029
  function managePlan(value, walletAddress2, kind) {
37788
38030
  const plan = object4(value, `Skill ${kind} plan`);
37789
38031
  exact(plan, ["kind", "sourceCommit", "chainId", "to", "data", "value", "summary", "walletAddress", "signingAuthority", "request"], `Skill ${kind} plan`);
37790
- assertAuthority(plan, kind === "price" ? "set_unit_price" : "set_max_supply", walletAddress2);
38032
+ const chainId = assertAuthority(plan, kind === "price" ? "set_unit_price" : "set_max_supply", walletAddress2);
37791
38033
  const request = object4(plan.request, `Skill ${kind} request`);
37792
38034
  const field = kind === "price" ? "unitPrice" : "maxSupply";
37793
- exact(request, ["skillId", field], `Skill ${kind} request`);
38035
+ exact(request, ["chainId", "skillId", field], `Skill ${kind} request`);
38036
+ if (request.chainId !== chainId) throw new TypeError(`Skill ${kind} request chain is invalid.`);
37794
38037
  string4(request.skillId, "Skill id", /^[1-9][0-9]*$/u);
37795
38038
  string4(request[field], `Skill ${field}`, DECIMAL);
37796
- return { request, intent: intent({
38039
+ return { chainId, request, intent: intent({
37797
38040
  chainId: plan.chainId,
37798
38041
  to: plan.to,
37799
38042
  data: plan.data,
@@ -37816,14 +38059,16 @@ function presentationPlan(value, walletAddress2) {
37816
38059
  "presentation",
37817
38060
  "localAction"
37818
38061
  ], "Skill presentation plan");
37819
- assertAuthority(plan, "presentation", walletAddress2);
38062
+ const chainId = assertAuthority(plan, "presentation", walletAddress2);
37820
38063
  const skillId = string4(plan.skillId, "Skill id", /^[1-9][0-9]*$/u);
37821
38064
  assertLocalAction(plan.localAction, "skill presentation-submit", skillId);
37822
38065
  return {
38066
+ chainId,
37823
38067
  skillId,
37824
38068
  currentVersion: integer2(plan.currentVersion, "Current version"),
37825
38069
  currentManifestURI: string4(plan.currentManifestURI, "Current manifest URI", IPFS),
37826
- presentation: buildPresentation(plan.presentation)
38070
+ presentation: buildPresentation(plan.presentation),
38071
+ signingAuthority: signingAuthority(plan.signingAuthority, walletAddress2)
37827
38072
  };
37828
38073
  }
37829
38074
  function assetPlan(value, walletAddress2) {
@@ -37839,7 +38084,7 @@ function assetPlan(value, walletAddress2) {
37839
38084
  "maxBytes",
37840
38085
  "localAction"
37841
38086
  ], "Skill asset plan");
37842
- assertAuthority(plan, "asset_upload", walletAddress2, false);
38087
+ const chainId = assertAuthority(plan, "asset_upload", walletAddress2, false);
37843
38088
  const skillId = string4(plan.skillId, "Skill id", /^[1-9][0-9]*$/u);
37844
38089
  if (plan.assetKind !== "cover" || plan.maxBytes !== 5242880) throw new TypeError("Skill cover authority is invalid.");
37845
38090
  const accepted = plan.acceptedMediaTypes;
@@ -37853,7 +38098,7 @@ function assetPlan(value, walletAddress2) {
37853
38098
  if (action.client !== "finch" || action.command !== "skill asset-upload" || args.assetKind !== "cover") {
37854
38099
  throw new TypeError("Skill cover local action is invalid.");
37855
38100
  }
37856
- return { skillId, acceptedMediaTypes: accepted, maxBytes: plan.maxBytes };
38101
+ return { chainId, skillId, acceptedMediaTypes: accepted, maxBytes: plan.maxBytes };
37857
38102
  }
37858
38103
  function coverMediaType(bytes) {
37859
38104
  const png = [137, 80, 78, 71, 13, 10, 26, 10];
@@ -37870,9 +38115,7 @@ function isPlaintextSkillDelivery(value) {
37870
38115
  function deliveryPlan(value, context) {
37871
38116
  const delivery2 = object4(value, "Skill delivery");
37872
38117
  exact(delivery2, ["chainId", "skillId", "version", "packageURI", "packageHash", "plaintext", "litData", "entitledWallet"], "Skill delivery");
37873
- if (delivery2.chainId !== SKILL_V3_CHAIN_ID) {
37874
- throw new TypeError("Skill delivery authority is invalid.");
37875
- }
38118
+ const chainId = skillChain(delivery2.chainId, "Skill delivery chain");
37876
38119
  const skillId = string4(delivery2.skillId, "Skill id", /^[1-9][0-9]*$/u);
37877
38120
  const version6 = integer2(delivery2.version, "Skill version");
37878
38121
  const packageHash = string4(delivery2.packageHash, "Skill package hash", HASH);
@@ -37880,16 +38123,16 @@ function deliveryPlan(value, context) {
37880
38123
  const packageURI = deliveryPackageUri(delivery2.packageURI);
37881
38124
  if (delivery2.plaintext) {
37882
38125
  if (delivery2.litData !== null || delivery2.entitledWallet !== null) throw new TypeError("Plaintext Skill delivery cannot contain wallet or Lit authority.");
37883
- return { skillId, version: version6, packageURI, packageHash, plaintext: true, litData: null };
38126
+ return { chainId, skillId, version: version6, packageURI, packageHash, plaintext: true, litData: null };
37884
38127
  }
37885
38128
  if (context === null || typeof delivery2.entitledWallet !== "string" || !/^0x[0-9a-fA-F]{40}$/u.test(delivery2.entitledWallet) || delivery2.entitledWallet.toLowerCase() !== context.walletAddress.toLowerCase()) {
37886
- throw new TypeError("Protected Skill delivery is not entitled to the active TEST wallet.");
38129
+ throw new TypeError("Protected Skill delivery is not entitled to the active wallet.");
37887
38130
  }
37888
38131
  const litData = object4(delivery2.litData, "Skill Lit data");
37889
38132
  exact(litData, ["ciphertext", "scheme", "chain"], "Skill Lit data");
37890
- if (litData.scheme !== SKILL_V3_ENVELOPE_SCHEME && litData.scheme !== SKILL_V3_LIT_ENVELOPE_SCHEME || litData.chain !== SKILL_V3_CHAIN_TAG) throw new TypeError("Skill Lit data does not match the source-controlled deployment.");
38133
+ if (litData.scheme !== SKILL_V3_ENVELOPE_SCHEME && litData.scheme !== SKILL_V3_LIT_ENVELOPE_SCHEME || litData.chain !== skillV3ChainTag(chainId)) throw new TypeError("Skill Lit data does not match the source-controlled deployment.");
37891
38134
  string4(litData.ciphertext, "Skill Lit ciphertext");
37892
- return { skillId, version: version6, packageURI, packageHash, plaintext: false, litData };
38135
+ return { chainId, skillId, version: version6, packageURI, packageHash, plaintext: false, litData };
37893
38136
  }
37894
38137
  function required3(value, name) {
37895
38138
  if (value === void 0 || value === null) throw new TypeError(`${name} is unavailable.`);
@@ -37904,10 +38147,12 @@ function recoveryReceipt(value, name) {
37904
38147
  blockNumber: receipt.blockNumber === null ? null : string4(receipt.blockNumber, `${name} block number`, /^[1-9][0-9]*$/u)
37905
38148
  });
37906
38149
  }
37907
- function recoveryRequest(value, action, name) {
38150
+ function recoveryRequest(value, action, name, chainId) {
37908
38151
  const request = object4(value, name);
37909
- if (request.action !== action) throw new TypeError(`${name} action is invalid.`);
37910
- return request;
38152
+ if (request.action !== action || request.chainId !== void 0 && request.chainId !== chainId) {
38153
+ throw new TypeError(`${name} authority is invalid.`);
38154
+ }
38155
+ return { ...request, chainId };
37911
38156
  }
37912
38157
  function canonical(value) {
37913
38158
  if (Array.isArray(value)) return `[${value.map(canonical).join(",")}]`;
@@ -37915,7 +38160,15 @@ function canonical(value) {
37915
38160
  return JSON.stringify(value);
37916
38161
  }
37917
38162
  function recoveryFingerprint2(kind, plan, walletAddress2) {
37918
- return createHash2("sha256").update(canonical({ kind, plan, walletAddress: walletAddress2.toLowerCase(), chainId: SKILL_V3_CHAIN_ID, sourceCommit: SKILL_V3_SOURCE_COMMIT })).digest("hex");
38163
+ const authority = object4(plan, "Skill recovery plan");
38164
+ const chainId = skillChain(authority.chainId, "Skill recovery plan chain");
38165
+ return createHash2("sha256").update(canonical({
38166
+ kind,
38167
+ plan,
38168
+ walletAddress: walletAddress2.toLowerCase(),
38169
+ chainId,
38170
+ sourceCommit: skillV3SourceCommit(chainId)
38171
+ })).digest("hex");
37919
38172
  }
37920
38173
  function recoveryJournal(value, fingerprint2, kind, context) {
37921
38174
  const journal = object4(value, "Skill publication recovery");
@@ -37939,7 +38192,8 @@ function recoveryJournal(value, fingerprint2, kind, context) {
37939
38192
  "requests",
37940
38193
  "receipts"
37941
38194
  ], "Skill publication recovery");
37942
- if (journal.version !== 4 || journal.kind !== kind || journal.fingerprint !== fingerprint2 || !/^[0-9a-f]{64}$/u.test(fingerprint2) || journal.chainId !== SKILL_V3_CHAIN_ID || typeof journal.walletAddress !== "string" || journal.walletAddress.toLowerCase() !== context.walletAddress.toLowerCase()) throw new TypeError("Skill publication recovery authority does not match this command.");
38195
+ const chainId = skillChain(journal.chainId, "Skill recovery chain");
38196
+ if (journal.version !== 4 || 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.");
37943
38197
  const recoveredAuthority = assertPublicationAuthority(
37944
38198
  signingAuthority(journal.signingAuthority, context.walletAddress),
37945
38199
  context
@@ -37960,9 +38214,9 @@ function recoveryJournal(value, fingerprint2, kind, context) {
37960
38214
  exact(requests, ["primary", "uri", "lit"], "Skill recovery requests");
37961
38215
  const receipts = object4(journal.receipts, "Skill recovery receipts");
37962
38216
  exact(receipts, ["primary", "uri", "lit"], "Skill recovery receipts");
37963
- const primary = recoveryRequest(requests.primary, kind === "publish" ? "createSkill" : "updateSkill", "Skill primary recovery request");
37964
- const uri = requests.uri === null ? null : recoveryRequest(requests.uri, "setSkillURI", "Skill URI recovery request");
37965
- const lit = requests.lit === null ? null : recoveryRequest(requests.lit, "setLitData", "Skill Lit recovery request");
38217
+ const primary = recoveryRequest(requests.primary, kind === "publish" ? "createSkill" : "updateSkill", "Skill primary recovery request", chainId);
38218
+ const uri = requests.uri === null ? null : recoveryRequest(requests.uri, "setSkillURI", "Skill URI recovery request", chainId);
38219
+ const lit = requests.lit === null ? null : recoveryRequest(requests.lit, "setLitData", "Skill Lit recovery request", chainId);
37966
38220
  const parsedReceipts = {
37967
38221
  primary: recoveryReceipt(receipts.primary, "Skill primary recovery receipt"),
37968
38222
  uri: recoveryReceipt(receipts.uri, "Skill URI recovery receipt"),
@@ -38014,13 +38268,13 @@ var init_skill_local_flow = __esm({
38014
38268
  pause;
38015
38269
  nonce;
38016
38270
  recovery;
38017
- async send(context, action, request, prepared, onBroadcast) {
38271
+ async send(context, action, request, prepared, authority, onBroadcast) {
38018
38272
  return required3(this.sender.submitPrepared, "Skill prepared-intent sender").call(this.sender, {
38019
38273
  privateKey: context.privateKey,
38020
38274
  walletAddress: context.walletAddress,
38021
38275
  action,
38022
38276
  request,
38023
- intent: intent(prepared, context.walletAddress),
38277
+ intent: authority === void 0 ? intent(prepared, context.walletAddress) : legacyIntent(prepared, context.walletAddress, authority),
38024
38278
  onBroadcast
38025
38279
  });
38026
38280
  }
@@ -38034,10 +38288,18 @@ var init_skill_local_flow = __esm({
38034
38288
  string4(uri, "Skill package URI", IPFS);
38035
38289
  return required3(this.api.fetchSkillStoredContent, "Skill content relay").call(this.api, uri, bearer);
38036
38290
  }
38037
- async contentKey(context, skillId, version6) {
38038
- const message = buildKeyRequestMessage({ chainId: SKILL_V3_CHAIN_ID, skillId: BigInt(skillId), version: version6 }, context.walletAddress, this.nonce());
38291
+ async contentKey(context, chainId, skillId, version6) {
38292
+ const message = buildKeyRequestMessage({ chainId, skillId: BigInt(skillId), version: version6 }, context.walletAddress, this.nonce());
38039
38293
  const signature = await this.signer.signMessage({ privateKey: context.privateKey, message });
38040
- const result2 = await required3(this.api.requestSkillContentKey, "Skill content-key request").call(this.api, { skillId, version: version6, wallet: context.walletAddress, message, signature, bearer: context.bearer });
38294
+ const result2 = await required3(this.api.requestSkillContentKey, "Skill content-key request").call(this.api, {
38295
+ chainId,
38296
+ skillId,
38297
+ version: version6,
38298
+ wallet: context.walletAddress,
38299
+ message,
38300
+ signature,
38301
+ bearer: context.bearer
38302
+ });
38041
38303
  if (result2.scheme === SKILL_V3_ENVELOPE_SCHEME) {
38042
38304
  return Object.freeze({ scheme: result2.scheme, key: string4(result2.key, "Skill key-encryption key", HASH) });
38043
38305
  }
@@ -38064,32 +38326,35 @@ var init_skill_local_flow = __esm({
38064
38326
  excluded: sealed.excluded
38065
38327
  });
38066
38328
  }
38067
- async protectedEnvelope(context, skillId, version6, mode, packageContentKey) {
38329
+ async protectedEnvelope(context, chainId, skillId, version6, mode, packageContentKey) {
38068
38330
  if (mode === "finchip_v2") {
38069
- const wrapping = await this.contentKey(context, skillId, version6);
38331
+ const wrapping = await this.contentKey(context, chainId, skillId, version6);
38070
38332
  if (wrapping.scheme !== SKILL_V3_ENVELOPE_SCHEME) {
38071
38333
  throw new TypeError("Finch key authority returned the wrong envelope scheme.");
38072
38334
  }
38073
38335
  return {
38074
38336
  action: "setLitData",
38337
+ chainId,
38075
38338
  skillId,
38076
38339
  version: version6,
38077
38340
  ciphertext: await sealEnvelope(wrapping.key, packageContentKey),
38078
38341
  scheme: SKILL_V3_ENVELOPE_SCHEME,
38079
- chain: SKILL_V3_CHAIN_TAG
38342
+ chain: skillV3ChainTag(chainId)
38080
38343
  };
38081
38344
  }
38082
38345
  const sealed = await required3(this.api.sealSkillContentKeyWithLit, "Skill Lit sealing").call(this.api, {
38346
+ chainId,
38083
38347
  skillId,
38084
38348
  version: version6,
38085
38349
  contentKey: packageContentKey,
38086
38350
  bearer: context.bearer
38087
38351
  });
38088
- if (sealed.scheme !== SKILL_V3_LIT_ENVELOPE_SCHEME || sealed.chain !== SKILL_V3_CHAIN_TAG) {
38352
+ if (sealed.scheme !== SKILL_V3_LIT_ENVELOPE_SCHEME || sealed.chain !== skillV3ChainTag(chainId)) {
38089
38353
  throw new TypeError("Skill Lit sealing authority is invalid.");
38090
38354
  }
38091
38355
  return {
38092
38356
  action: "setLitData",
38357
+ chainId,
38093
38358
  skillId,
38094
38359
  version: version6,
38095
38360
  ciphertext: string4(sealed.ciphertext, "Skill Lit ciphertext"),
@@ -38110,24 +38375,31 @@ var init_skill_local_flow = __esm({
38110
38375
  async save(fingerprint2, journal) {
38111
38376
  await required3(this.recovery, "Skill publication recovery").saveSkillPublicationRecovery(fingerprint2, journal);
38112
38377
  }
38113
- async project(transactionHash3, bearer) {
38114
- await this.api.confirmSkillProjection?.(transactionHash3, bearer);
38378
+ async project(chainId, transactionHash3, bearer) {
38379
+ await this.api.confirmSkillProjection?.(chainId, transactionHash3, bearer);
38115
38380
  }
38116
38381
  async stage(context, fingerprint2, journal, stage, action, request, prepare) {
38117
38382
  const existing = journal.receipts[stage];
38118
38383
  if (existing !== null) {
38119
38384
  journal.receipts[stage] = await this.verify(context, action, request, existing);
38120
38385
  await this.save(fingerprint2, journal);
38121
- await this.project(journal.receipts[stage].transactionHash, context.bearer);
38386
+ await this.project(journal.chainId, journal.receipts[stage].transactionHash, context.bearer);
38122
38387
  return;
38123
38388
  }
38124
38389
  const prepared = await prepare();
38125
- journal.receipts[stage] = await this.send(context, action, request, prepared, async ({ transactionHash: transactionHash3 }) => {
38126
- journal.receipts[stage] = { transactionHash: transactionHash3, blockNumber: null };
38127
- await this.save(fingerprint2, journal);
38128
- });
38390
+ journal.receipts[stage] = await this.send(
38391
+ context,
38392
+ action,
38393
+ request,
38394
+ prepared,
38395
+ journal.signingAuthority,
38396
+ async ({ transactionHash: transactionHash3 }) => {
38397
+ journal.receipts[stage] = { transactionHash: transactionHash3, blockNumber: null };
38398
+ await this.save(fingerprint2, journal);
38399
+ }
38400
+ );
38129
38401
  await this.save(fingerprint2, journal);
38130
- await this.project(journal.receipts[stage].transactionHash, context.bearer);
38402
+ await this.project(journal.chainId, journal.receipts[stage].transactionHash, context.bearer);
38131
38403
  }
38132
38404
  async recoverPublication(fingerprint2, context) {
38133
38405
  if (!/^[0-9a-f]{64}$/u.test(fingerprint2)) throw new TypeError("Skill publication recovery fingerprint is invalid.");
@@ -38150,7 +38422,12 @@ var init_skill_local_flow = __esm({
38150
38422
  const slug = string4(journal.requests.primary.slug, "Skill recovery slug");
38151
38423
  let skillId2 = journal.skillId;
38152
38424
  await this.settle(async () => {
38153
- skillId2 = await required3(this.api.resolveSkillId, "Skill resolve API").call(this.api, slug, context.bearer);
38425
+ skillId2 = await required3(this.api.resolveSkillId, "Skill resolve API").call(
38426
+ this.api,
38427
+ journal.chainId,
38428
+ slug,
38429
+ context.bearer
38430
+ );
38154
38431
  return skillId2 !== null;
38155
38432
  }, `Skill ${slug} publication`);
38156
38433
  if (skillId2 === null) throw new TypeError("Published Skill slug did not resolve.");
@@ -38160,6 +38437,7 @@ var init_skill_local_flow = __esm({
38160
38437
  if (journal.requests.lit === null) {
38161
38438
  journal.requests.lit = await this.protectedEnvelope(
38162
38439
  context,
38440
+ journal.chainId,
38163
38441
  skillId2,
38164
38442
  1,
38165
38443
  journal.contentMode,
@@ -38180,6 +38458,7 @@ var init_skill_local_flow = __esm({
38180
38458
  }
38181
38459
  await store.clearSkillPublicationRecovery(fingerprint2);
38182
38460
  return {
38461
+ chainId: journal.chainId,
38183
38462
  skillId: skillId2,
38184
38463
  version: 1,
38185
38464
  contentMode: journal.contentMode,
@@ -38204,7 +38483,12 @@ var init_skill_local_flow = __esm({
38204
38483
  () => required3(this.api.requestSkillIntent, "Skill intent API").call(this.api, journal.requests.primary, context.bearer)
38205
38484
  );
38206
38485
  await this.settle(
38207
- async () => await required3(this.api.readSkillCurrentVersion, "Skill version API").call(this.api, skillId, context.bearer) === journal.targetVersion,
38486
+ async () => await required3(this.api.readSkillCurrentVersion, "Skill version API").call(
38487
+ this.api,
38488
+ journal.chainId,
38489
+ skillId,
38490
+ context.bearer
38491
+ ) === journal.targetVersion,
38208
38492
  `Skill ${skillId} version ${journal.targetVersion}`
38209
38493
  );
38210
38494
  const uriRequest = required3(journal.requests.uri, "Skill URI recovery request");
@@ -38221,6 +38505,7 @@ var init_skill_local_flow = __esm({
38221
38505
  if (journal.requests.lit === null) {
38222
38506
  journal.requests.lit = await this.protectedEnvelope(
38223
38507
  context,
38508
+ journal.chainId,
38224
38509
  skillId,
38225
38510
  journal.targetVersion,
38226
38511
  journal.contentMode,
@@ -38241,6 +38526,7 @@ var init_skill_local_flow = __esm({
38241
38526
  }
38242
38527
  await store.clearSkillPublicationRecovery(fingerprint2);
38243
38528
  return {
38529
+ chainId: journal.chainId,
38244
38530
  skillId,
38245
38531
  version: journal.targetVersion,
38246
38532
  contentMode: journal.contentMode,
@@ -38302,7 +38588,7 @@ var init_skill_local_flow = __esm({
38302
38588
  kind: "publish",
38303
38589
  fingerprint: fingerprint2,
38304
38590
  walletAddress: context.walletAddress.toLowerCase(),
38305
- chainId: SKILL_V3_CHAIN_ID,
38591
+ chainId: plan.chainId,
38306
38592
  signingAuthority: plan.signingAuthority,
38307
38593
  sourceKind: expectedSourceKind,
38308
38594
  contentMode: mode,
@@ -38330,7 +38616,12 @@ var init_skill_local_flow = __esm({
38330
38616
  );
38331
38617
  let skillId = journal.skillId;
38332
38618
  await this.settle(async () => {
38333
- skillId = await required3(this.api.resolveSkillId, "Skill resolve API").call(this.api, String(request.slug), context.bearer);
38619
+ skillId = await required3(this.api.resolveSkillId, "Skill resolve API").call(
38620
+ this.api,
38621
+ journal.chainId,
38622
+ String(request.slug),
38623
+ context.bearer
38624
+ );
38334
38625
  return skillId !== null;
38335
38626
  }, `Skill ${request.slug} publication`);
38336
38627
  if (skillId === null) throw new TypeError("Published Skill slug did not resolve.");
@@ -38340,6 +38631,7 @@ var init_skill_local_flow = __esm({
38340
38631
  if (journal.requests.lit === null) {
38341
38632
  journal.requests.lit = await this.protectedEnvelope(
38342
38633
  context,
38634
+ journal.chainId,
38343
38635
  skillId,
38344
38636
  1,
38345
38637
  journal.contentMode,
@@ -38359,14 +38651,19 @@ var init_skill_local_flow = __esm({
38359
38651
  );
38360
38652
  }
38361
38653
  await store.clearSkillPublicationRecovery(fingerprint2);
38362
- return { skillId, version: 1, contentMode: journal.contentMode, packageHash: journal.packageHash, excluded: journal.excluded, transactions: { create: required3(journal.receipts.primary, "Skill create receipt").transactionHash, ...journal.contentMode === "plaintext" ? {} : { setLitData: required3(journal.receipts.lit, "Skill Lit receipt").transactionHash } } };
38654
+ return { chainId: journal.chainId, skillId, version: 1, contentMode: journal.contentMode, packageHash: journal.packageHash, excluded: journal.excluded, transactions: { create: required3(journal.receipts.primary, "Skill create receipt").transactionHash, ...journal.contentMode === "plaintext" ? {} : { setLitData: required3(journal.receipts.lit, "Skill Lit receipt").transactionHash } } };
38363
38655
  }
38364
38656
  async publishVersion(path, planValue, context) {
38365
38657
  const plan = versionPlan(planValue, context);
38366
38658
  const fingerprint2 = recoveryFingerprint2("version", planValue, context.walletAddress);
38367
38659
  const store = required3(this.recovery, "Skill publication recovery");
38368
38660
  const prior = await store.readSkillPublicationRecovery(fingerprint2);
38369
- const observedVersion = await required3(this.api.readSkillCurrentVersion, "Skill version API").call(this.api, String(plan.request.skillId), context.bearer);
38661
+ const observedVersion = await required3(this.api.readSkillCurrentVersion, "Skill version API").call(
38662
+ this.api,
38663
+ plan.chainId,
38664
+ String(plan.request.skillId),
38665
+ context.bearer
38666
+ );
38370
38667
  if (prior === null && observedVersion !== plan.currentVersion) {
38371
38668
  throw new TypeError(`Skill current version ${observedVersion} no longer matches plan version ${plan.currentVersion}.`);
38372
38669
  }
@@ -38399,14 +38696,14 @@ var init_skill_local_flow = __esm({
38399
38696
  bearer: context.bearer,
38400
38697
  objectKind: "manifest"
38401
38698
  });
38402
- const updateRequest = { action: "updateSkill", skillId: plan.request.skillId, mdHash: packaged.packageHash, packageHash: packaged.packageHash };
38403
- const uriRequest2 = { action: "setSkillURI", skillId: plan.request.skillId, packageURI: manifestURI };
38699
+ const updateRequest = { action: "updateSkill", chainId: plan.chainId, skillId: plan.request.skillId, mdHash: packaged.packageHash, packageHash: packaged.packageHash };
38700
+ const uriRequest2 = { action: "setSkillURI", chainId: plan.chainId, skillId: plan.request.skillId, packageURI: manifestURI };
38404
38701
  journal = {
38405
38702
  version: 4,
38406
38703
  kind: "version",
38407
38704
  fingerprint: fingerprint2,
38408
38705
  walletAddress: context.walletAddress.toLowerCase(),
38409
- chainId: SKILL_V3_CHAIN_ID,
38706
+ chainId: plan.chainId,
38410
38707
  signingAuthority: plan.signingAuthority,
38411
38708
  sourceKind: plan.sourceKind,
38412
38709
  contentMode: plan.contentMode,
@@ -38432,7 +38729,12 @@ var init_skill_local_flow = __esm({
38432
38729
  journal.requests.primary,
38433
38730
  () => required3(this.api.requestSkillIntent, "Skill intent API").call(this.api, journal.requests.primary, context.bearer)
38434
38731
  );
38435
- await this.settle(async () => await required3(this.api.readSkillCurrentVersion, "Skill version API").call(this.api, String(plan.request.skillId), context.bearer) === plan.nextVersion, `Skill ${plan.request.skillId} version ${plan.nextVersion}`);
38732
+ await this.settle(async () => await required3(this.api.readSkillCurrentVersion, "Skill version API").call(
38733
+ this.api,
38734
+ journal.chainId,
38735
+ String(plan.request.skillId),
38736
+ context.bearer
38737
+ ) === plan.nextVersion, `Skill ${plan.request.skillId} version ${plan.nextVersion}`);
38436
38738
  const uriRequest = required3(journal.requests.uri, "Skill URI recovery request");
38437
38739
  await this.stage(
38438
38740
  context,
@@ -38447,6 +38749,7 @@ var init_skill_local_flow = __esm({
38447
38749
  if (journal.requests.lit === null) {
38448
38750
  journal.requests.lit = await this.protectedEnvelope(
38449
38751
  context,
38752
+ journal.chainId,
38450
38753
  String(plan.request.skillId),
38451
38754
  plan.nextVersion,
38452
38755
  journal.contentMode,
@@ -38466,18 +38769,18 @@ var init_skill_local_flow = __esm({
38466
38769
  );
38467
38770
  }
38468
38771
  await store.clearSkillPublicationRecovery(fingerprint2);
38469
- return { skillId: plan.request.skillId, version: plan.nextVersion, contentMode: journal.contentMode, packageHash: journal.packageHash, excluded: journal.excluded, transactions: { update: required3(journal.receipts.primary, "Skill update receipt").transactionHash, setSkillURI: required3(journal.receipts.uri, "Skill URI receipt").transactionHash, ...journal.contentMode === "plaintext" ? {} : { setLitData: required3(journal.receipts.lit, "Skill Lit receipt").transactionHash } } };
38772
+ return { chainId: journal.chainId, skillId: plan.request.skillId, version: plan.nextVersion, contentMode: journal.contentMode, packageHash: journal.packageHash, excluded: journal.excluded, transactions: { update: required3(journal.receipts.primary, "Skill update receipt").transactionHash, setSkillURI: required3(journal.receipts.uri, "Skill URI receipt").transactionHash, ...journal.contentMode === "plaintext" ? {} : { setLitData: required3(journal.receipts.lit, "Skill Lit receipt").transactionHash } } };
38470
38773
  }
38471
38774
  async manage(kind, planValue, context) {
38472
38775
  const plan = managePlan(planValue, context.walletAddress, kind);
38473
38776
  const action = kind === "price" ? "setUnitPrice" : "setMaxSupply";
38474
38777
  const submission = await this.send(context, action, { action, ...plan.request }, plan.intent);
38475
- await this.project(submission.transactionHash, context.bearer);
38476
- return { ...submission, skillId: plan.request.skillId, kind };
38778
+ await this.project(plan.chainId, submission.transactionHash, context.bearer);
38779
+ return { ...submission, chainId: plan.chainId, skillId: plan.request.skillId, kind };
38477
38780
  }
38478
38781
  async publishPresentation(planValue, context) {
38479
38782
  const plan = presentationPlan(planValue, context.walletAddress);
38480
- const liveVersion = await required3(this.api.readSkillCurrentVersion, "Skill version API").call(this.api, plan.skillId, context.bearer);
38783
+ const liveVersion = await required3(this.api.readSkillCurrentVersion, "Skill version API").call(this.api, plan.chainId, plan.skillId, context.bearer);
38481
38784
  if (liveVersion !== plan.currentVersion) {
38482
38785
  throw new TypeError(`Skill current version ${liveVersion} no longer matches presentation plan version ${plan.currentVersion}.`);
38483
38786
  }
@@ -38490,11 +38793,17 @@ var init_skill_local_flow = __esm({
38490
38793
  bearer: context.bearer,
38491
38794
  objectKind: "manifest"
38492
38795
  });
38493
- const request = { action: "setSkillURI", skillId: plan.skillId, packageURI: manifestURI };
38796
+ const request = { action: "setSkillURI", chainId: plan.chainId, skillId: plan.skillId, packageURI: manifestURI };
38494
38797
  const prepared = await required3(this.api.requestSkillIntent, "Skill intent API").call(this.api, request, context.bearer);
38495
- const submission = await this.send(context, "setSkillURI", request, prepared);
38496
- await this.project(submission.transactionHash, context.bearer);
38497
- return { ...submission, skillId: plan.skillId, currentVersion: plan.currentVersion, manifestURI };
38798
+ const submission = await this.send(
38799
+ context,
38800
+ "setSkillURI",
38801
+ request,
38802
+ prepared,
38803
+ plan.signingAuthority
38804
+ );
38805
+ await this.project(plan.chainId, submission.transactionHash, context.bearer);
38806
+ return { ...submission, chainId: plan.chainId, skillId: plan.skillId, currentVersion: plan.currentVersion, manifestURI };
38498
38807
  }
38499
38808
  async uploadCover(path, planValue, context) {
38500
38809
  const plan = assetPlan(planValue, context.walletAddress);
@@ -38514,7 +38823,7 @@ var init_skill_local_flow = __esm({
38514
38823
  objectKind: "cover",
38515
38824
  mediaType
38516
38825
  });
38517
- return { skillId: plan.skillId, assetKind: "cover", uri, mediaType, bytes: bytes.byteLength };
38826
+ return { chainId: plan.chainId, skillId: plan.skillId, assetKind: "cover", uri, mediaType, bytes: bytes.byteLength };
38518
38827
  }
38519
38828
  async download(planValue, context) {
38520
38829
  const plan = deliveryPlan(planValue, context);
@@ -38531,7 +38840,12 @@ var init_skill_local_flow = __esm({
38531
38840
  if (!HASH.test(expectedHash)) throw new TypeError("Skill delivery has no verifiable plaintext package hash.");
38532
38841
  let plaintext = stored;
38533
38842
  if (!plan.plaintext) {
38534
- const resolved = await this.contentKey(required3(context, "Protected Skill wallet context"), plan.skillId, plan.version);
38843
+ const resolved = await this.contentKey(
38844
+ required3(context, "Protected Skill wallet context"),
38845
+ plan.chainId,
38846
+ plan.skillId,
38847
+ plan.version
38848
+ );
38535
38849
  const envelopeScheme = String(plan.litData.scheme);
38536
38850
  if (resolved.scheme !== envelopeScheme) throw new TypeError("Skill content-key response does not match its on-chain envelope.");
38537
38851
  const contentKey = resolved.scheme === SKILL_V3_ENVELOPE_SCHEME ? await openEnvelope(resolved.key, String(plan.litData.ciphertext)) : resolved.key;
@@ -38539,7 +38853,7 @@ var init_skill_local_flow = __esm({
38539
38853
  }
38540
38854
  const actualHash = await sha256Hex(plaintext);
38541
38855
  if (actualHash.toLowerCase() !== expectedHash.toLowerCase()) throw new TypeError("Decrypted Skill package hash does not match its published authority.");
38542
- return Object.freeze({ bytes: plaintext, skillId: plan.skillId, version: plan.version, packageHash: actualHash });
38856
+ return Object.freeze({ bytes: plaintext, chainId: plan.chainId, skillId: plan.skillId, version: plan.version, packageHash: actualHash });
38543
38857
  }
38544
38858
  };
38545
38859
  }
@@ -39797,7 +40111,10 @@ var init_application = __esm({
39797
40111
  environment: authority.session.environment
39798
40112
  });
39799
40113
  const published = await required4(this.skillLocalFlow, "skill local flow").publish(path, plan, context);
39800
- return { ...published, nextAction: { operationId: "skill_market.skills.get", request: { skillId: published.skillId } } };
40114
+ return { ...published, nextAction: { operationId: "skill_market.skills.get", request: {
40115
+ chainId: published.chainId,
40116
+ skillId: published.skillId
40117
+ } } };
39801
40118
  }
39802
40119
  async submitSkillVersion(path, planFile) {
39803
40120
  const plan = await readBoundedJsonFile(planFile);
@@ -39811,7 +40128,11 @@ var init_application = __esm({
39811
40128
  environment: authority.session.environment
39812
40129
  });
39813
40130
  const published = await required4(this.skillLocalFlow, "skill local flow").publishVersion(path, plan, context);
39814
- return { ...published, nextAction: { operationId: "skill_market.skills.get", request: { skillId: published.skillId, version: published.version } } };
40131
+ return { ...published, nextAction: { operationId: "skill_market.skills.get", request: {
40132
+ chainId: published.chainId,
40133
+ skillId: published.skillId,
40134
+ version: published.version
40135
+ } } };
39815
40136
  }
39816
40137
  async submitSkillManage(kind, planFile) {
39817
40138
  const plan = await readBoundedJsonFile(planFile);
@@ -39819,7 +40140,10 @@ var init_application = __esm({
39819
40140
  assertSigningAuthority(plan, authority.session);
39820
40141
  const context = Object.freeze({ privateKey: authority.wallet.privateKey, walletAddress: authority.wallet.walletAddress, bearer: authority.session.rawBearer });
39821
40142
  const managed = await required4(this.skillLocalFlow, "skill local flow").manage(kind, plan, context);
39822
- return { ...managed, nextAction: { operationId: "skill_market.skills.get", request: { skillId: managed.skillId } } };
40143
+ return { ...managed, nextAction: { operationId: "skill_market.skills.get", request: {
40144
+ chainId: managed.chainId,
40145
+ skillId: managed.skillId
40146
+ } } };
39823
40147
  }
39824
40148
  async submitSkillPresentation(planFile) {
39825
40149
  const plan = await readBoundedJsonFile(planFile);
@@ -39827,7 +40151,10 @@ var init_application = __esm({
39827
40151
  assertSigningAuthority(plan, authority.session);
39828
40152
  const context = Object.freeze({ privateKey: authority.wallet.privateKey, walletAddress: authority.wallet.walletAddress, bearer: authority.session.rawBearer });
39829
40153
  const published = await required4(this.skillLocalFlow, "skill local flow").publishPresentation(plan, context);
39830
- return { ...published, nextAction: { operationId: "skill_market.manage.get", request: { skillId: published.skillId } } };
40154
+ return { ...published, nextAction: { operationId: "skill_market.manage.get", request: {
40155
+ chainId: published.chainId,
40156
+ skillId: published.skillId
40157
+ } } };
39831
40158
  }
39832
40159
  async uploadSkillAsset(path, planFile) {
39833
40160
  const plan = await readBoundedJsonFile(planFile);
@@ -39835,7 +40162,10 @@ var init_application = __esm({
39835
40162
  const uploaded = await required4(this.skillLocalFlow, "skill local flow").uploadCover(path, plan, context);
39836
40163
  return { ...uploaded, nextAction: {
39837
40164
  operationId: "skill_market.manage.get",
39838
- query: { skillId: uploaded.skillId }
40165
+ request: {
40166
+ chainId: uploaded.chainId,
40167
+ skillId: uploaded.skillId
40168
+ }
39839
40169
  } };
39840
40170
  }
39841
40171
  async recoverSkill(kind, fingerprint2) {
@@ -40170,7 +40500,7 @@ var init_package = __esm({
40170
40500
  "package.json"() {
40171
40501
  package_default = {
40172
40502
  name: "@finchtech/cli",
40173
- version: "0.2.0",
40503
+ version: "0.2.2",
40174
40504
  description: "Finch Agent CLI for wallet-owned marketplace and MCP workflows.",
40175
40505
  type: "module",
40176
40506
  bin: {
@@ -55450,6 +55780,38 @@ var init_chainConfig = __esm({
55450
55780
  }
55451
55781
  });
55452
55782
 
55783
+ // ../../node_modules/.pnpm/viem@2.55.15_bufferutil@4.1_ce20031be19c56210207d462110a7a29/node_modules/viem/_esm/chains/definitions/arbitrum.js
55784
+ var arbitrum;
55785
+ var init_arbitrum = __esm({
55786
+ "../../node_modules/.pnpm/viem@2.55.15_bufferutil@4.1_ce20031be19c56210207d462110a7a29/node_modules/viem/_esm/chains/definitions/arbitrum.js"() {
55787
+ init_defineChain();
55788
+ arbitrum = /* @__PURE__ */ defineChain({
55789
+ id: 42161,
55790
+ name: "Arbitrum One",
55791
+ nativeCurrency: { name: "Ether", symbol: "ETH", decimals: 18 },
55792
+ blockTime: 250,
55793
+ rpcUrls: {
55794
+ default: {
55795
+ http: ["https://arb1.arbitrum.io/rpc"]
55796
+ }
55797
+ },
55798
+ blockExplorers: {
55799
+ default: {
55800
+ name: "Arbiscan",
55801
+ url: "https://arbiscan.io",
55802
+ apiUrl: "https://api.arbiscan.io/api"
55803
+ }
55804
+ },
55805
+ contracts: {
55806
+ multicall3: {
55807
+ address: "0xca11bde05977b3631167028862be2a173976ca11",
55808
+ blockCreated: 7654707
55809
+ }
55810
+ }
55811
+ });
55812
+ }
55813
+ });
55814
+
55453
55815
  // ../../node_modules/.pnpm/viem@2.55.15_bufferutil@4.1_ce20031be19c56210207d462110a7a29/node_modules/viem/_esm/chains/definitions/base.js
55454
55816
  var sourceId, base, basePreconf;
55455
55817
  var init_base2 = __esm({
@@ -55586,11 +55948,141 @@ var init_baseSepolia = __esm({
55586
55948
  }
55587
55949
  });
55588
55950
 
55951
+ // ../../node_modules/.pnpm/viem@2.55.15_bufferutil@4.1_ce20031be19c56210207d462110a7a29/node_modules/viem/_esm/chains/definitions/bsc.js
55952
+ var bsc;
55953
+ var init_bsc = __esm({
55954
+ "../../node_modules/.pnpm/viem@2.55.15_bufferutil@4.1_ce20031be19c56210207d462110a7a29/node_modules/viem/_esm/chains/definitions/bsc.js"() {
55955
+ init_defineChain();
55956
+ bsc = /* @__PURE__ */ defineChain({
55957
+ id: 56,
55958
+ name: "BNB Smart Chain",
55959
+ blockTime: 750,
55960
+ nativeCurrency: {
55961
+ decimals: 18,
55962
+ name: "BNB",
55963
+ symbol: "BNB"
55964
+ },
55965
+ rpcUrls: {
55966
+ default: { http: ["https://56.rpc.thirdweb.com"] }
55967
+ },
55968
+ blockExplorers: {
55969
+ default: {
55970
+ name: "BscScan",
55971
+ url: "https://bscscan.com",
55972
+ apiUrl: "https://api.bscscan.com/api"
55973
+ }
55974
+ },
55975
+ contracts: {
55976
+ multicall3: {
55977
+ address: "0xca11bde05977b3631167028862be2a173976ca11",
55978
+ blockCreated: 15921452
55979
+ }
55980
+ }
55981
+ });
55982
+ }
55983
+ });
55984
+
55985
+ // ../../node_modules/.pnpm/viem@2.55.15_bufferutil@4.1_ce20031be19c56210207d462110a7a29/node_modules/viem/_esm/chains/definitions/mainnet.js
55986
+ var mainnet;
55987
+ var init_mainnet = __esm({
55988
+ "../../node_modules/.pnpm/viem@2.55.15_bufferutil@4.1_ce20031be19c56210207d462110a7a29/node_modules/viem/_esm/chains/definitions/mainnet.js"() {
55989
+ init_defineChain();
55990
+ mainnet = /* @__PURE__ */ defineChain({
55991
+ id: 1,
55992
+ name: "Ethereum",
55993
+ nativeCurrency: { name: "Ether", symbol: "ETH", decimals: 18 },
55994
+ blockTime: 12e3,
55995
+ rpcUrls: {
55996
+ default: {
55997
+ http: ["https://ethereum.reth.rs/rpc"]
55998
+ }
55999
+ },
56000
+ blockExplorers: {
56001
+ default: {
56002
+ name: "Etherscan",
56003
+ url: "https://etherscan.io",
56004
+ apiUrl: "https://api.etherscan.io/api"
56005
+ }
56006
+ },
56007
+ contracts: {
56008
+ ensUniversalResolver: {
56009
+ address: "0xeeeeeeee14d718c2b47d9923deab1335e144eeee",
56010
+ blockCreated: 23085558
56011
+ },
56012
+ multicall3: {
56013
+ address: "0xca11bde05977b3631167028862be2a173976ca11",
56014
+ blockCreated: 14353601
56015
+ }
56016
+ }
56017
+ });
56018
+ }
56019
+ });
56020
+
56021
+ // ../../node_modules/.pnpm/viem@2.55.15_bufferutil@4.1_ce20031be19c56210207d462110a7a29/node_modules/viem/_esm/chains/definitions/optimism.js
56022
+ var sourceId3, optimism;
56023
+ var init_optimism = __esm({
56024
+ "../../node_modules/.pnpm/viem@2.55.15_bufferutil@4.1_ce20031be19c56210207d462110a7a29/node_modules/viem/_esm/chains/definitions/optimism.js"() {
56025
+ init_chainConfig();
56026
+ init_defineChain();
56027
+ sourceId3 = 1;
56028
+ optimism = /* @__PURE__ */ defineChain({
56029
+ ...chainConfig,
56030
+ id: 10,
56031
+ name: "OP Mainnet",
56032
+ nativeCurrency: { name: "Ether", symbol: "ETH", decimals: 18 },
56033
+ rpcUrls: {
56034
+ default: {
56035
+ http: ["https://mainnet.optimism.io"]
56036
+ }
56037
+ },
56038
+ blockExplorers: {
56039
+ default: {
56040
+ name: "Optimism Explorer",
56041
+ url: "https://optimistic.etherscan.io",
56042
+ apiUrl: "https://api-optimistic.etherscan.io/api"
56043
+ }
56044
+ },
56045
+ contracts: {
56046
+ ...chainConfig.contracts,
56047
+ disputeGameFactory: {
56048
+ [sourceId3]: {
56049
+ address: "0xe5965Ab5962eDc7477C8520243A95517CD252fA9"
56050
+ }
56051
+ },
56052
+ l2OutputOracle: {
56053
+ [sourceId3]: {
56054
+ address: "0xdfe97868233d1aa22e815a266982f2cf17685a27"
56055
+ }
56056
+ },
56057
+ multicall3: {
56058
+ address: "0xca11bde05977b3631167028862be2a173976ca11",
56059
+ blockCreated: 4286263
56060
+ },
56061
+ portal: {
56062
+ [sourceId3]: {
56063
+ address: "0xbEb5Fc579115071764c7423A4f12eDde41f106Ed"
56064
+ }
56065
+ },
56066
+ l1StandardBridge: {
56067
+ [sourceId3]: {
56068
+ address: "0x99C9fc46f92E8a1c0deC1b1747d010903E884bE1"
56069
+ }
56070
+ }
56071
+ },
56072
+ sourceId: sourceId3
56073
+ });
56074
+ }
56075
+ });
56076
+
55589
56077
  // ../../node_modules/.pnpm/viem@2.55.15_bufferutil@4.1_ce20031be19c56210207d462110a7a29/node_modules/viem/_esm/chains/index.js
55590
56078
  var init_chains2 = __esm({
55591
56079
  "../../node_modules/.pnpm/viem@2.55.15_bufferutil@4.1_ce20031be19c56210207d462110a7a29/node_modules/viem/_esm/chains/index.js"() {
56080
+ init_arbitrum();
55592
56081
  init_base2();
55593
56082
  init_baseSepolia();
56083
+ init_bsc();
56084
+ init_mainnet();
56085
+ init_optimism();
55594
56086
  }
55595
56087
  });
55596
56088
 
@@ -56196,40 +56688,10 @@ function textValue(value, name, allowEmpty = false) {
56196
56688
  return value;
56197
56689
  }
56198
56690
  function resolveSkillViemChain(chainId) {
56199
- if (chainId === base.id) return base;
56200
- if (chainId === baseSepolia.id) return baseSepolia;
56691
+ const chain = [mainnet, optimism, bsc, base, arbitrum, baseSepolia].find((candidate) => candidate.id === chainId);
56692
+ if (chain !== void 0) return chain;
56201
56693
  throw new TypeError(`Unsupported Skill chain ${String(chainId)}.`);
56202
56694
  }
56203
- function viemFactory2(rpcUrl) {
56204
- const transport = http2(parseRpcUrl3(rpcUrl), { retryCount: 0, timeout: 2e4 });
56205
- return (key, chainId) => {
56206
- const chain = resolveSkillViemChain(chainId);
56207
- const account = privateKeyToAccount(key);
56208
- const publicClient = createPublicClient({ chain, transport });
56209
- const walletClient = createWalletClient({ account, chain, transport });
56210
- return Object.freeze({
56211
- walletAddress: account.address.toLowerCase(),
56212
- getChainId: () => publicClient.getChainId(),
56213
- sendTransaction: (input) => walletClient.sendTransaction({ account, chain, ...input }),
56214
- waitForReceipt: async (hash5) => {
56215
- const receipt = await publicClient.waitForTransactionReceipt({ hash: hash5, confirmations: 1, timeout: 12e4 });
56216
- return Object.freeze({ status: receipt.status, blockNumber: receipt.blockNumber });
56217
- },
56218
- getTransactionCall: async (hash5) => {
56219
- const transaction2 = await publicClient.getTransaction({ hash: hash5 });
56220
- return Object.freeze({ from: transaction2.from, to: transaction2.to, data: transaction2.input, value: transaction2.value });
56221
- },
56222
- getTransactionRecord: async (hash5) => {
56223
- const [transaction2, receipt] = await Promise.all([
56224
- publicClient.getTransaction({ hash: hash5 }),
56225
- publicClient.getTransactionReceipt({ hash: hash5 })
56226
- ]);
56227
- if (transaction2.blockNumber === null || transaction2.blockNumber !== receipt.blockNumber) throw new TypeError("Skill recovery transaction is not settled in its recorded block.");
56228
- return Object.freeze({ from: transaction2.from, to: transaction2.to, data: transaction2.input, value: transaction2.value, status: receipt.status, blockNumber: receipt.blockNumber });
56229
- }
56230
- });
56231
- };
56232
- }
56233
56695
  function expectedCall(kind, request, deployment2) {
56234
56696
  const skillId = () => unsigned2(request.skillId, "Skill id", true);
56235
56697
  if (kind === "purchase") {
@@ -56289,7 +56751,7 @@ function assertIntentMatches(raw, expected, chainId) {
56289
56751
  throw new TypeError("Skill intent calldata, target, or value does not match its reviewed request.");
56290
56752
  }
56291
56753
  }
56292
- var import_ajv3, instanceAbi, tokenAbi, revenueAbi, factoryAbi, validateIntent2, InstalledSkillIntentSender;
56754
+ var import_ajv3, instanceAbi, tokenAbi, revenueAbi, factoryAbi, validateIntent2, viemFactory2, InstalledSkillIntentSender;
56293
56755
  var init_skill_intent_sender = __esm({
56294
56756
  "src/skill-intent-sender.ts"() {
56295
56757
  "use strict";
@@ -56317,34 +56779,80 @@ var init_skill_intent_sender = __esm({
56317
56779
  "function createSkill((bytes32 mdHash, bytes32 packageHash, string packageURI, string slug, string name, string category, string licenseTypeName, string imageURI, bool plaintext, uint256 unitPrice, uint256 maxSupply, uint96 royaltyBPS, uint256 usageLimit) params)"
56318
56780
  ]);
56319
56781
  validateIntent2 = new import_ajv3.default({ allErrors: true, strict: false }).compile(skillIntentResponseSchema);
56782
+ viemFactory2 = (key, chainId, rpcUrl) => {
56783
+ const transport = http2(parseRpcUrl3(rpcUrl), { retryCount: 0, timeout: 2e4 });
56784
+ const chain = resolveSkillViemChain(chainId);
56785
+ const account = privateKeyToAccount(key);
56786
+ const publicClient = createPublicClient({ chain, transport });
56787
+ const walletClient = createWalletClient({ account, chain, transport });
56788
+ return Object.freeze({
56789
+ walletAddress: account.address.toLowerCase(),
56790
+ getChainId: () => publicClient.getChainId(),
56791
+ sendTransaction: (input) => walletClient.sendTransaction({ account, chain, ...input }),
56792
+ waitForReceipt: async (hash5) => {
56793
+ const receipt = await publicClient.waitForTransactionReceipt({ hash: hash5, confirmations: 1, timeout: 12e4 });
56794
+ return Object.freeze({ status: receipt.status, blockNumber: receipt.blockNumber });
56795
+ },
56796
+ getTransactionCall: async (hash5) => {
56797
+ const transaction2 = await publicClient.getTransaction({ hash: hash5 });
56798
+ return Object.freeze({ from: transaction2.from, to: transaction2.to, data: transaction2.input, value: transaction2.value });
56799
+ },
56800
+ getTransactionRecord: async (hash5) => {
56801
+ const [transaction2, receipt] = await Promise.all([
56802
+ publicClient.getTransaction({ hash: hash5 }),
56803
+ publicClient.getTransactionReceipt({ hash: hash5 })
56804
+ ]);
56805
+ if (transaction2.blockNumber === null || transaction2.blockNumber !== receipt.blockNumber) throw new TypeError("Skill recovery transaction is not settled in its recorded block.");
56806
+ return Object.freeze({ from: transaction2.from, to: transaction2.to, data: transaction2.input, value: transaction2.value, status: receipt.status, blockNumber: receipt.blockNumber });
56807
+ }
56808
+ });
56809
+ };
56320
56810
  InstalledSkillIntentSender = class {
56811
+ constructor(environment3 = resolveSkillProtocolEnvironment(process.env.FINCH_ENVIRONMENT), environmentVariables = process.env, rpcFactory = viemFactory2) {
56812
+ this.environment = environment3;
56813
+ this.environmentVariables = environmentVariables;
56814
+ this.rpcFactory = rpcFactory;
56815
+ }
56816
+ environment;
56817
+ environmentVariables;
56321
56818
  rpcFactory;
56322
- deployment;
56323
- constructor(rpcUrl, factory, environment3 = resolveSkillProtocolEnvironment(process.env.FINCH_ENVIRONMENT)) {
56324
- parseRpcUrl3(rpcUrl);
56325
- this.rpcFactory = factory ?? viemFactory2(rpcUrl);
56326
- this.deployment = getSkillProtocolDeployment(resolveSkillProtocolEnvironment(environment3));
56819
+ authority(chainIdValue) {
56820
+ if (!Number.isInteger(chainIdValue) || Number(chainIdValue) < 1) {
56821
+ throw new TypeError("Skill request chain is invalid.");
56822
+ }
56823
+ return getSkillProtocolDeployment(resolveSkillProtocolEnvironment(this.environment), Number(chainIdValue));
56824
+ }
56825
+ async rpc(privateKey3, walletAddress2, deployment2) {
56826
+ const override = this.environmentVariables[`FINCHTECH_RPC_URL_${deployment2.chainId}`];
56827
+ const rpcUrl = parseRpcUrl3(override ?? deployment2.defaultRpcUrls[0]);
56828
+ const rpc = this.rpcFactory(installedPrivateKey2(privateKey3), deployment2.chainId, rpcUrl);
56829
+ if (rpc.walletAddress.toLowerCase() !== walletAddress2.toLowerCase() || await rpc.getChainId() !== deployment2.chainId) {
56830
+ throw new TypeError("The wallet or RPC chain does not match the selected Skill authority.");
56831
+ }
56832
+ return rpc;
56327
56833
  }
56328
56834
  buyerCall(input) {
56329
56835
  if (!validateIntent2(input.intent)) throw new TypeError("Skill intent does not match the frozen contract.");
56330
- if (input.intent.kind !== input.expectedKind || input.intent.sourceCommit !== this.deployment.sourceCommit || input.intent.chainId !== this.deployment.chainId) throw new TypeError("Skill intent authority is invalid.");
56836
+ const deployment2 = this.authority(input.intent.chainId);
56837
+ if (input.intent.kind !== input.expectedKind || input.intent.sourceCommit !== deployment2.sourceCommit) {
56838
+ throw new TypeError("Skill intent authority is invalid.");
56839
+ }
56331
56840
  if (typeof input.intent.walletAddress !== "string" || input.intent.walletAddress.toLowerCase() !== input.walletAddress.toLowerCase()) {
56332
56841
  throw new TypeError("Skill intent wallet does not match the active CLI wallet.");
56333
56842
  }
56334
- const expected = expectedCall(input.expectedKind, record4(input.intent.request, "Skill intent request"), this.deployment);
56335
- assertIntentMatches(input.intent, expected, this.deployment.chainId);
56336
- return expected;
56337
- }
56338
- async buyerRpc(privateKey3, walletAddress2) {
56339
- const rpc = this.rpcFactory(installedPrivateKey2(privateKey3), this.deployment.chainId);
56340
- if (rpc.walletAddress !== walletAddress2 || await rpc.getChainId() !== this.deployment.chainId) {
56341
- throw new TypeError("The wallet or RPC chain does not match the selected Skill authority.");
56342
- }
56343
- return rpc;
56843
+ const request = record4(input.intent.request, "Skill intent request");
56844
+ if (request.chainId !== deployment2.chainId) throw new TypeError("Skill intent request chain is invalid.");
56845
+ const expected = expectedCall(input.expectedKind, request, deployment2);
56846
+ assertIntentMatches(
56847
+ input.intent,
56848
+ expected,
56849
+ deployment2.chainId
56850
+ );
56851
+ return Object.freeze({ expected, deployment: deployment2 });
56344
56852
  }
56345
56853
  async submit(input) {
56346
- const expected = this.buyerCall(input);
56347
- const rpc = await this.buyerRpc(input.privateKey, input.walletAddress);
56854
+ const { expected, deployment: deployment2 } = this.buyerCall(input);
56855
+ const rpc = await this.rpc(input.privateKey, input.walletAddress, deployment2);
56348
56856
  const transactionHash3 = await rpc.sendTransaction(expected);
56349
56857
  await input.onBroadcast?.({ fingerprint: skillBuyerIntentFingerprint(input.intent), transactionHash: transactionHash3 });
56350
56858
  const receipt = await rpc.waitForReceipt(transactionHash3);
@@ -56352,8 +56860,8 @@ var init_skill_intent_sender = __esm({
56352
56860
  return Object.freeze({ transactionHash: transactionHash3, blockNumber: receipt.blockNumber.toString() });
56353
56861
  }
56354
56862
  async verifyBuyerIntent(input) {
56355
- const expected = this.buyerCall(input);
56356
- const rpc = await this.buyerRpc(input.privateKey, input.walletAddress);
56863
+ const { expected, deployment: deployment2 } = this.buyerCall(input);
56864
+ const rpc = await this.rpc(input.privateKey, input.walletAddress, deployment2);
56357
56865
  const transactionHash3 = hash4(input.transactionHash, "Skill buyer recovery transaction hash");
56358
56866
  const exactTransaction2 = (actual2) => actual2.from.toLowerCase() === input.walletAddress.toLowerCase() && actual2.to?.toLowerCase() === expected.to.toLowerCase() && actual2.data === expected.data && actual2.value === expected.value;
56359
56867
  if (input.blockNumber === null) {
@@ -56372,10 +56880,12 @@ var init_skill_intent_sender = __esm({
56372
56880
  return Object.freeze({ transactionHash: transactionHash3, blockNumber: actual.blockNumber.toString() });
56373
56881
  }
56374
56882
  async submitPrepared(input) {
56375
- const rpc = this.rpcFactory(installedPrivateKey2(input.privateKey), this.deployment.chainId);
56376
- if (rpc.walletAddress !== input.walletAddress || await rpc.getChainId() !== this.deployment.chainId) throw new TypeError("The wallet or RPC chain does not match the selected Skill authority.");
56377
- const expected = expectedPreparedCall(input.action, record4(input.request, "Skill prepared request"), this.deployment);
56378
- assertIntentMatches(input.intent, expected, this.deployment.chainId);
56883
+ const request = record4(input.request, "Skill prepared request");
56884
+ const deployment2 = this.authority(request.chainId);
56885
+ if (input.intent.chainId !== deployment2.chainId) throw new TypeError("Skill prepared intent chain is invalid.");
56886
+ const expected = expectedPreparedCall(input.action, request, deployment2);
56887
+ assertIntentMatches(input.intent, expected, deployment2.chainId);
56888
+ const rpc = await this.rpc(input.privateKey, input.walletAddress, deployment2);
56379
56889
  const transactionHash3 = await rpc.sendTransaction(expected);
56380
56890
  await input.onBroadcast?.({ transactionHash: transactionHash3 });
56381
56891
  const receipt = await rpc.waitForReceipt(transactionHash3);
@@ -56383,9 +56893,10 @@ var init_skill_intent_sender = __esm({
56383
56893
  return Object.freeze({ transactionHash: transactionHash3, blockNumber: receipt.blockNumber.toString() });
56384
56894
  }
56385
56895
  async verifyPrepared(input) {
56386
- const rpc = this.rpcFactory(installedPrivateKey2(input.privateKey), this.deployment.chainId);
56387
- if (rpc.walletAddress !== input.walletAddress || await rpc.getChainId() !== this.deployment.chainId) throw new TypeError("The wallet or RPC chain does not match the selected Skill authority.");
56388
- const expected = expectedPreparedCall(input.action, record4(input.request, "Skill prepared request"), this.deployment);
56896
+ const request = record4(input.request, "Skill prepared request");
56897
+ const deployment2 = this.authority(request.chainId);
56898
+ const expected = expectedPreparedCall(input.action, request, deployment2);
56899
+ const rpc = await this.rpc(input.privateKey, input.walletAddress, deployment2);
56389
56900
  const transactionHash3 = hash4(input.transactionHash, "Skill recovery transaction hash");
56390
56901
  const exactTransaction2 = (actual2) => actual2.from.toLowerCase() === input.walletAddress && actual2.to?.toLowerCase() === expected.to.toLowerCase() && actual2.data === expected.data && actual2.value === expected.value;
56391
56902
  if (input.blockNumber === null) {
@@ -56519,15 +57030,6 @@ function resolveInstalledRpcUrls(profile, explicitRpcUrl, command) {
56519
57030
  task: explicitRpcUrl ?? deployment2.defaultRpcUrls[0]
56520
57031
  });
56521
57032
  }
56522
- if (command === "skill") {
56523
- if (profile.environment === "local") {
56524
- return explicitRpcUrl === void 0 ? Object.freeze({}) : Object.freeze({ skill: explicitRpcUrl });
56525
- }
56526
- const deployment2 = getSkillProtocolDeployment(profile.environment);
56527
- return Object.freeze({
56528
- skill: explicitRpcUrl ?? deployment2.defaultRpcUrls[0]
56529
- });
56530
- }
56531
57033
  return Object.freeze({});
56532
57034
  }
56533
57035
  async function runInstalledCli(arguments_, environment3 = process.env, authorities = {}) {
@@ -56541,7 +57043,7 @@ async function runInstalledCli(arguments_, environment3 = process.env, authoriti
56541
57043
  const signer = new InstalledWalletSigner();
56542
57044
  const explicitRpcUrl = profile?.chainId === 8453 ? environment3.FINCHTECH_RPC_URL_8453 : environment3.FINCHTECH_RPC_URL_84532;
56543
57045
  const rpcUrls = resolveInstalledRpcUrls(profile, explicitRpcUrl, arguments_[0]);
56544
- const skillIntentSender = rpcUrls.skill === void 0 ? void 0 : new InstalledSkillIntentSender(rpcUrls.skill, void 0, profile?.environment);
57046
+ const skillIntentSender = profile === void 0 || arguments_[0] !== "skill" ? void 0 : new InstalledSkillIntentSender(profile.environment, environment3);
56545
57047
  const application = new FinchCliApplication({
56546
57048
  api,
56547
57049
  state,