@finchtech/cli 0.5.0 → 0.5.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.
- package/README.md +22 -9
- package/dist/finch.js +438 -650
- package/package.json +3 -3
package/dist/finch.js
CHANGED
|
@@ -6619,7 +6619,7 @@ var init_package = __esm({
|
|
|
6619
6619
|
"package.json"() {
|
|
6620
6620
|
package_default = {
|
|
6621
6621
|
name: "@finchtech/cli",
|
|
6622
|
-
version: "0.5.
|
|
6622
|
+
version: "0.5.2",
|
|
6623
6623
|
description: "Finch Agent CLI for wallet custody, Session-owned execution, and MCP OAuth approval.",
|
|
6624
6624
|
type: "module",
|
|
6625
6625
|
bin: {
|
|
@@ -6954,9 +6954,9 @@ function floatSafeRemainder(val, step) {
|
|
|
6954
6954
|
return 0;
|
|
6955
6955
|
return ratio - roundedRatio;
|
|
6956
6956
|
}
|
|
6957
|
-
function defineLazy(
|
|
6957
|
+
function defineLazy(object5, key, getter) {
|
|
6958
6958
|
let value = void 0;
|
|
6959
|
-
Object.defineProperty(
|
|
6959
|
+
Object.defineProperty(object5, key, {
|
|
6960
6960
|
get() {
|
|
6961
6961
|
if (value === EVALUATING) {
|
|
6962
6962
|
return void 0;
|
|
@@ -6968,7 +6968,7 @@ function defineLazy(object6, key, getter) {
|
|
|
6968
6968
|
return value;
|
|
6969
6969
|
},
|
|
6970
6970
|
set(v) {
|
|
6971
|
-
Object.defineProperty(
|
|
6971
|
+
Object.defineProperty(object5, key, {
|
|
6972
6972
|
value: v
|
|
6973
6973
|
// configurable: true,
|
|
6974
6974
|
});
|
|
@@ -21941,6 +21941,45 @@ var init_agent_service = __esm({
|
|
|
21941
21941
|
paymentTokenSymbol: "USDC",
|
|
21942
21942
|
paymentTokenDecimals: 6
|
|
21943
21943
|
}
|
|
21944
|
+
},
|
|
21945
|
+
"1776": {
|
|
21946
|
+
enabled: true,
|
|
21947
|
+
network: {
|
|
21948
|
+
chainId: 1776,
|
|
21949
|
+
name: "Injective",
|
|
21950
|
+
explorerUrl: "https://blockscout.injective.network",
|
|
21951
|
+
defaultRpcUrls: [
|
|
21952
|
+
"https://sentry.evm-rpc.injective.network"
|
|
21953
|
+
]
|
|
21954
|
+
},
|
|
21955
|
+
sourceRepository: "FinchipAI/Finch-Agent-Service-Protocol",
|
|
21956
|
+
sourceCommit: "97f6f0810932b282de482238ec0f9460cdc177b3",
|
|
21957
|
+
contracts: {
|
|
21958
|
+
protocol: "0xd0f6f5be7581ad76f0b6cf10e468c017c9aad902",
|
|
21959
|
+
protocolImplementation: "0xeb426199277c10cd12ade7858bff24eb67d3342e",
|
|
21960
|
+
protocolProxyAdmin: "0xa6cb95ee7262b198c7727344cae7e95afd2922ee",
|
|
21961
|
+
vault: "0xf5bdf5f74c5597151bd3fd978cdd741d9f7f7103",
|
|
21962
|
+
vaultImplementation: "0xe8e53bca9ada0dfc77d977db5d929973db79d2df",
|
|
21963
|
+
vaultProxyAdmin: "0x45869f4af762ff7adee9a8a1a3264c5518320b98",
|
|
21964
|
+
paymentToken: "0xa00c59ff5a080d2b954d0c75e46e22a0c371235a"
|
|
21965
|
+
},
|
|
21966
|
+
authority: {
|
|
21967
|
+
admin: "0x4fcb985a020dc1dd8a5dfc4adf4606eac4f68075",
|
|
21968
|
+
treasury: "0xd5ca4d96a17723fd008b2c3f1a413cb0736a2848",
|
|
21969
|
+
settlementAttestor: "0x1dc1ccc1ebdcdd6c57a8c22776883b45c6824cf6",
|
|
21970
|
+
refundAttestor: "0x1dc1ccc1ebdcdd6c57a8c22776883b45c6824cf6",
|
|
21971
|
+
freezeKeeper: "0x1dc1ccc1ebdcdd6c57a8c22776883b45c6824cf6"
|
|
21972
|
+
},
|
|
21973
|
+
deployment: {
|
|
21974
|
+
firstBlock: "185194836",
|
|
21975
|
+
completedBlock: "185194908",
|
|
21976
|
+
confirmations: 2,
|
|
21977
|
+
deploymentHash: "0x3b6a22dfb42ecc1d4800a60971ccf932bd39a005cec796a9bcef9a31702e0b33"
|
|
21978
|
+
},
|
|
21979
|
+
policy: {
|
|
21980
|
+
paymentTokenSymbol: "USDC",
|
|
21981
|
+
paymentTokenDecimals: 6
|
|
21982
|
+
}
|
|
21944
21983
|
}
|
|
21945
21984
|
}
|
|
21946
21985
|
}
|
|
@@ -22328,6 +22367,44 @@ var init_task_protocol = __esm({
|
|
|
22328
22367
|
paymentTokenSymbol: "USDC",
|
|
22329
22368
|
paymentTokenDecimals: 6
|
|
22330
22369
|
}
|
|
22370
|
+
},
|
|
22371
|
+
"1776": {
|
|
22372
|
+
enabled: true,
|
|
22373
|
+
network: {
|
|
22374
|
+
chainId: 1776,
|
|
22375
|
+
name: "Injective",
|
|
22376
|
+
explorerUrl: "https://blockscout.injective.network",
|
|
22377
|
+
defaultRpcUrls: [
|
|
22378
|
+
"https://sentry.evm-rpc.injective.network"
|
|
22379
|
+
]
|
|
22380
|
+
},
|
|
22381
|
+
sourceRepository: "FinchipAI/Finch-Task-Protocol",
|
|
22382
|
+
sourceCommit: "b3331c2488e9b5cc7159beb58be0ba3f60430d7e",
|
|
22383
|
+
abiSourceCommit: "c4491b8fe85a09840c5873bc6ac142c580febd32",
|
|
22384
|
+
contracts: {
|
|
22385
|
+
protocol: "0x20ab3a991f987a6f7ccb4e8f21a9c6e1097d7a19",
|
|
22386
|
+
protocolImplementation: "0xe520cd670add2f8813e3c76bd69a033c5cfa5b92",
|
|
22387
|
+
protocolProxyAdmin: "0x2ae16beefb2a74efceb32379a54052871c86aeb8",
|
|
22388
|
+
vault: "0xcb19ea4fa56c3fc0c03892ec4b76e546572ba2b8",
|
|
22389
|
+
vaultImplementation: "0x43fe3e0afb3ed8c2851b6326522e031599a44a30",
|
|
22390
|
+
vaultProxyAdmin: "0xa19b2318184e1f826ccf4d6d7eaeb5356efe3dce",
|
|
22391
|
+
paymentToken: "0xa00c59ff5a080d2b954d0c75e46e22a0c371235a"
|
|
22392
|
+
},
|
|
22393
|
+
authority: {
|
|
22394
|
+
admin: "0x4fcb985a020dc1dd8a5dfc4adf4606eac4f68075",
|
|
22395
|
+
treasury: "0xd5ca4d96a17723fd008b2c3f1a413cb0736a2848",
|
|
22396
|
+
awardAttestor: "0x1dc1ccc1ebdcdd6c57a8c22776883b45c6824cf6",
|
|
22397
|
+
freezeKeeper: "0x1dc1ccc1ebdcdd6c57a8c22776883b45c6824cf6"
|
|
22398
|
+
},
|
|
22399
|
+
deployment: {
|
|
22400
|
+
firstBlock: "185193254",
|
|
22401
|
+
completedBlock: "185193311",
|
|
22402
|
+
confirmations: 2
|
|
22403
|
+
},
|
|
22404
|
+
policy: {
|
|
22405
|
+
paymentTokenSymbol: "USDC",
|
|
22406
|
+
paymentTokenDecimals: 6
|
|
22407
|
+
}
|
|
22331
22408
|
}
|
|
22332
22409
|
}
|
|
22333
22410
|
}
|
|
@@ -22809,6 +22886,39 @@ var init_chains = __esm({
|
|
|
22809
22886
|
}
|
|
22810
22887
|
});
|
|
22811
22888
|
|
|
22889
|
+
// ../../packages/deployment-manifest/src/platform/dashboard-prices.json
|
|
22890
|
+
var dashboard_prices_default;
|
|
22891
|
+
var init_dashboard_prices = __esm({
|
|
22892
|
+
"../../packages/deployment-manifest/src/platform/dashboard-prices.json"() {
|
|
22893
|
+
dashboard_prices_default = {
|
|
22894
|
+
schemaVersion: 1,
|
|
22895
|
+
kind: "dashboard_prices",
|
|
22896
|
+
endpoint: "https://api.coingecko.com/api/v3/simple/price",
|
|
22897
|
+
assetIds: {
|
|
22898
|
+
ETH: "ethereum",
|
|
22899
|
+
BNB: "binancecoin",
|
|
22900
|
+
AVAX: "avalanche-2"
|
|
22901
|
+
}
|
|
22902
|
+
};
|
|
22903
|
+
}
|
|
22904
|
+
});
|
|
22905
|
+
|
|
22906
|
+
// ../../packages/deployment-manifest/src/platform/dashboard-prices.ts
|
|
22907
|
+
var manifest;
|
|
22908
|
+
var init_dashboard_prices2 = __esm({
|
|
22909
|
+
"../../packages/deployment-manifest/src/platform/dashboard-prices.ts"() {
|
|
22910
|
+
"use strict";
|
|
22911
|
+
init_zod();
|
|
22912
|
+
init_dashboard_prices();
|
|
22913
|
+
manifest = external_exports.strictObject({
|
|
22914
|
+
schemaVersion: external_exports.literal(1),
|
|
22915
|
+
kind: external_exports.literal("dashboard_prices"),
|
|
22916
|
+
endpoint: external_exports.url().refine((value) => new URL(value).protocol === "https:"),
|
|
22917
|
+
assetIds: external_exports.record(external_exports.string(), external_exports.string().regex(/^[a-z0-9-]+$/))
|
|
22918
|
+
}).parse(dashboard_prices_default);
|
|
22919
|
+
}
|
|
22920
|
+
});
|
|
22921
|
+
|
|
22812
22922
|
// ../../packages/deployment-manifest/src/platform/get-help.json
|
|
22813
22923
|
var get_help_default;
|
|
22814
22924
|
var init_get_help = __esm({
|
|
@@ -22877,7 +22987,7 @@ var init_passkey_safe = __esm({
|
|
|
22877
22987
|
function parsePasskeySafeManifest(input) {
|
|
22878
22988
|
return schema2.parse(input);
|
|
22879
22989
|
}
|
|
22880
|
-
var disabled, enabled, schema2,
|
|
22990
|
+
var disabled, enabled, schema2, manifest2;
|
|
22881
22991
|
var init_passkey_safe2 = __esm({
|
|
22882
22992
|
"../../packages/deployment-manifest/src/platform/passkey-safe.ts"() {
|
|
22883
22993
|
"use strict";
|
|
@@ -22903,7 +23013,7 @@ var init_passkey_safe2 = __esm({
|
|
|
22903
23013
|
production: disabled
|
|
22904
23014
|
})
|
|
22905
23015
|
});
|
|
22906
|
-
|
|
23016
|
+
manifest2 = parsePasskeySafeManifest(passkey_safe_default);
|
|
22907
23017
|
}
|
|
22908
23018
|
});
|
|
22909
23019
|
|
|
@@ -22958,7 +23068,7 @@ var init_internal_apps = __esm({
|
|
|
22958
23068
|
sessionTtlSeconds: 28800,
|
|
22959
23069
|
queryAgentEnabled: true,
|
|
22960
23070
|
aiBaseUrl: "https://api.tokenrouter.com/v1",
|
|
22961
|
-
aiModel: "xiaomi/mimo-v2.6-
|
|
23071
|
+
aiModel: "xiaomi/mimo-v2.6-pro"
|
|
22962
23072
|
},
|
|
22963
23073
|
ops: {
|
|
22964
23074
|
sessionTtlSeconds: 28800,
|
|
@@ -22970,7 +23080,7 @@ var init_internal_apps = __esm({
|
|
|
22970
23080
|
sessionTtlSeconds: 28800,
|
|
22971
23081
|
queryAgentEnabled: true,
|
|
22972
23082
|
aiBaseUrl: "https://api.tokenrouter.com/v1",
|
|
22973
|
-
aiModel: "xiaomi/mimo-v2.6-
|
|
23083
|
+
aiModel: "xiaomi/mimo-v2.6-pro"
|
|
22974
23084
|
},
|
|
22975
23085
|
ops: {
|
|
22976
23086
|
sessionTtlSeconds: 28800,
|
|
@@ -22980,9 +23090,9 @@ var init_internal_apps = __esm({
|
|
|
22980
23090
|
production: {
|
|
22981
23091
|
data: {
|
|
22982
23092
|
sessionTtlSeconds: 28800,
|
|
22983
|
-
queryAgentEnabled:
|
|
23093
|
+
queryAgentEnabled: true,
|
|
22984
23094
|
aiBaseUrl: "https://api.tokenrouter.com/v1",
|
|
22985
|
-
aiModel: "xiaomi/mimo-v2.6-
|
|
23095
|
+
aiModel: "xiaomi/mimo-v2.6-pro"
|
|
22986
23096
|
},
|
|
22987
23097
|
ops: {
|
|
22988
23098
|
sessionTtlSeconds: 28800,
|
|
@@ -23162,7 +23272,7 @@ var init_agenton_payout = __esm({
|
|
|
23162
23272
|
function parseAgentonPayoutManifest(input) {
|
|
23163
23273
|
return schema3.parse(input);
|
|
23164
23274
|
}
|
|
23165
|
-
var origin, environment, schema3,
|
|
23275
|
+
var origin, environment, schema3, manifest3;
|
|
23166
23276
|
var init_agenton_payout2 = __esm({
|
|
23167
23277
|
"../../packages/deployment-manifest/src/platform/agenton-payout.ts"() {
|
|
23168
23278
|
"use strict";
|
|
@@ -23180,7 +23290,7 @@ var init_agenton_payout2 = __esm({
|
|
|
23180
23290
|
walletApiBaseUrl: origin,
|
|
23181
23291
|
environments: external_exports.strictObject({ local: environment, test: environment, production: environment })
|
|
23182
23292
|
});
|
|
23183
|
-
|
|
23293
|
+
manifest3 = parseAgentonPayoutManifest(agenton_payout_default);
|
|
23184
23294
|
}
|
|
23185
23295
|
});
|
|
23186
23296
|
|
|
@@ -23214,7 +23324,7 @@ var init_merchant_avatar_video = __esm({
|
|
|
23214
23324
|
function parseMerchantAvatarVideoManifest(input) {
|
|
23215
23325
|
return schema4.parse(input);
|
|
23216
23326
|
}
|
|
23217
|
-
var policy2, schema4,
|
|
23327
|
+
var policy2, schema4, manifest4;
|
|
23218
23328
|
var init_merchant_avatar_video2 = __esm({
|
|
23219
23329
|
"../../packages/deployment-manifest/src/platform/merchant-avatar-video.ts"() {
|
|
23220
23330
|
"use strict";
|
|
@@ -23229,7 +23339,7 @@ var init_merchant_avatar_video2 = __esm({
|
|
|
23229
23339
|
kind: external_exports.literal("merchant_avatar_video"),
|
|
23230
23340
|
environments: external_exports.strictObject({ local: policy2, test: policy2, production: policy2 })
|
|
23231
23341
|
});
|
|
23232
|
-
|
|
23342
|
+
manifest4 = parseMerchantAvatarVideoManifest(merchant_avatar_video_default);
|
|
23233
23343
|
}
|
|
23234
23344
|
});
|
|
23235
23345
|
|
|
@@ -23247,14 +23357,14 @@ var init_generator = __esm({
|
|
|
23247
23357
|
});
|
|
23248
23358
|
|
|
23249
23359
|
// ../../packages/deployment-manifest/src/platform/generator.ts
|
|
23250
|
-
var policy3,
|
|
23360
|
+
var policy3, manifest5;
|
|
23251
23361
|
var init_generator2 = __esm({
|
|
23252
23362
|
"../../packages/deployment-manifest/src/platform/generator.ts"() {
|
|
23253
23363
|
"use strict";
|
|
23254
23364
|
init_zod();
|
|
23255
23365
|
init_generator();
|
|
23256
23366
|
policy3 = external_exports.strictObject({ enabled: external_exports.boolean() });
|
|
23257
|
-
|
|
23367
|
+
manifest5 = external_exports.strictObject({ schemaVersion: external_exports.literal(1), kind: external_exports.literal("generator"), provider: external_exports.strictObject({ endpoint: external_exports.literal("https://api.tokenrouter.com/v1"), model: external_exports.literal("openai/gpt-6-luna") }), environments: external_exports.strictObject({ local: policy3, test: policy3, production: policy3 }) }).parse(generator_default);
|
|
23258
23368
|
}
|
|
23259
23369
|
});
|
|
23260
23370
|
|
|
@@ -23304,6 +23414,7 @@ var init_platform = __esm({
|
|
|
23304
23414
|
"../../packages/deployment-manifest/src/platform/index.ts"() {
|
|
23305
23415
|
"use strict";
|
|
23306
23416
|
init_zod();
|
|
23417
|
+
init_dashboard_prices2();
|
|
23307
23418
|
init_get_help2();
|
|
23308
23419
|
init_passkey_safe2();
|
|
23309
23420
|
init_web_analytics();
|
|
@@ -23458,13 +23569,15 @@ var init_src = __esm({
|
|
|
23458
23569
|
});
|
|
23459
23570
|
|
|
23460
23571
|
// ../../packages/skill-market-contracts/src/public.ts
|
|
23461
|
-
var SKILL_V3_ENVELOPE_SCHEME, SKILL_V3_LIT_ENVELOPE_SCHEME;
|
|
23572
|
+
var SKILL_V3_ENVELOPE_SCHEME, SKILL_V3_LIT_ENVELOPE_SCHEME, SKILL_PUBLICATION_ROYALTY_BPS, SKILL_PUBLICATION_USAGE_LIMIT;
|
|
23462
23573
|
var init_public = __esm({
|
|
23463
23574
|
"../../packages/skill-market-contracts/src/public.ts"() {
|
|
23464
23575
|
"use strict";
|
|
23465
23576
|
init_src();
|
|
23466
23577
|
SKILL_V3_ENVELOPE_SCHEME = "FINCHIP_V2";
|
|
23467
23578
|
SKILL_V3_LIT_ENVELOPE_SCHEME = "LIT_V1";
|
|
23579
|
+
SKILL_PUBLICATION_ROYALTY_BPS = 250;
|
|
23580
|
+
SKILL_PUBLICATION_USAGE_LIMIT = 0;
|
|
23468
23581
|
}
|
|
23469
23582
|
});
|
|
23470
23583
|
|
|
@@ -24116,6 +24229,7 @@ function localFailureMessage(error51) {
|
|
|
24116
24229
|
}
|
|
24117
24230
|
return "Protected local state is corrupt. Recreate the affected profile, login, or recovery state.";
|
|
24118
24231
|
}
|
|
24232
|
+
if (error51 instanceof CliUsageError) return error51.message;
|
|
24119
24233
|
if (error51.message === "FINCHTECH_HOME is required.") {
|
|
24120
24234
|
return "FINCHTECH_HOME is required. Set it to the protected Finch Agent CLI state directory.";
|
|
24121
24235
|
}
|
|
@@ -24129,7 +24243,7 @@ function localFailureMessage(error51) {
|
|
|
24129
24243
|
if (publicInputMessages.includes(error51.message)) return error51.message;
|
|
24130
24244
|
return "Command input does not match the expected schema. Check finch help for this command.";
|
|
24131
24245
|
}
|
|
24132
|
-
var CliAuthorityError, CliProductionUnavailableError, BrowserOpenError, MCP_AUTHORIZATION_FLOW_GUIDANCE, McpAuthorizationFlowError,
|
|
24246
|
+
var CliAuthorityError, CliProductionUnavailableError, BrowserOpenError, MCP_AUTHORIZATION_FLOW_GUIDANCE, McpAuthorizationFlowError, CliUsageError, CLI_SESSION_RENEWAL_GUIDANCE, CliSkillSourceError, CliSkillPresentationStaleError, CliSkillRecoveryUncertainError, CliSkillPublicationError;
|
|
24133
24247
|
var init_cli_error = __esm({
|
|
24134
24248
|
"src/cli-error.ts"() {
|
|
24135
24249
|
"use strict";
|
|
@@ -24179,19 +24293,13 @@ var init_cli_error = __esm({
|
|
|
24179
24293
|
code = "MCP_AUTHORIZATION_FLOW_FAILED";
|
|
24180
24294
|
guidance;
|
|
24181
24295
|
};
|
|
24182
|
-
|
|
24183
|
-
|
|
24184
|
-
|
|
24185
|
-
|
|
24186
|
-
constructor(recoveryCommands) {
|
|
24187
|
-
if (recoveryCommands.length === 0 || recoveryCommands.some((command) => !PUBLIC_RECOVERY_COMMAND.test(command))) {
|
|
24188
|
-
throw new TypeError("Recovery commands must contain only supported public recovery syntax.");
|
|
24189
|
-
}
|
|
24190
|
-
super("CLI_RECOVERY_BLOCKED");
|
|
24191
|
-
this.name = "CliRecoveryBlockedError";
|
|
24192
|
-
this.recoveryCommands = Object.freeze([...new Set(recoveryCommands)].sort());
|
|
24296
|
+
CliUsageError = class extends TypeError {
|
|
24297
|
+
constructor(message) {
|
|
24298
|
+
super(message);
|
|
24299
|
+
this.name = "CliUsageError";
|
|
24193
24300
|
}
|
|
24194
24301
|
};
|
|
24302
|
+
CLI_SESSION_RENEWAL_GUIDANCE = "The CLI Session is invalid or expired. Run finch login --chain-id <CHAIN_ID> using the same wallet, endpoint and authentication chain. Use finch login --help to list supported authentication chains. Existing recovery journals are preserved.";
|
|
24195
24303
|
CliSkillSourceError = class extends TypeError {
|
|
24196
24304
|
constructor(diagnosticCode, details, message) {
|
|
24197
24305
|
super(message);
|
|
@@ -28419,7 +28527,7 @@ async function buildSkillRoot(input) {
|
|
|
28419
28527
|
if (contentKey !== null) encrypted[file2.path] = { ciphertext: cid.toString(), plaintextHash: await sha256Hex(file2.content) };
|
|
28420
28528
|
}
|
|
28421
28529
|
if (!md) throw new RangeError("SkillRoot primary document is missing.");
|
|
28422
|
-
const
|
|
28530
|
+
const manifest6 = jsonBytes({
|
|
28423
28531
|
schemaVersion: "1.0",
|
|
28424
28532
|
name: input.name,
|
|
28425
28533
|
skillVersion: String(input.version),
|
|
@@ -28428,7 +28536,7 @@ async function buildSkillRoot(input) {
|
|
|
28428
28536
|
});
|
|
28429
28537
|
const root = {
|
|
28430
28538
|
md,
|
|
28431
|
-
manifest: await put(
|
|
28539
|
+
manifest: await put(manifest6),
|
|
28432
28540
|
entry: { ...md, profile: ENTRY_PROFILE },
|
|
28433
28541
|
...Object.keys(files).length ? { files } : {},
|
|
28434
28542
|
...input.previousHash === void 0 ? {} : { prev: hashCID(input.previousHash, 113) }
|
|
@@ -28442,7 +28550,7 @@ async function buildSkillRoot(input) {
|
|
|
28442
28550
|
const proof = {
|
|
28443
28551
|
scheme: SKILL_ROOT_SCHEME,
|
|
28444
28552
|
root: toBase64(rootBytes),
|
|
28445
|
-
manifest: toBase64(
|
|
28553
|
+
manifest: toBase64(manifest6),
|
|
28446
28554
|
...confidentiality === void 0 ? {} : { confidentiality: toBase64(confidentiality) }
|
|
28447
28555
|
};
|
|
28448
28556
|
const packageHash = await sha256Hex(rootBytes);
|
|
@@ -28479,8 +28587,8 @@ async function verifySkillRootProof(proof, packageHash, version6, previousHash)
|
|
|
28479
28587
|
const paths = Object.keys(refs);
|
|
28480
28588
|
if (paths.length > MAX_SKILL_IMPORT_FILES || paths.some((name) => paths.some((other) => other.startsWith(`${name}/`)))) throw new RangeError("SkillRoot file paths exceed limits or conflict.");
|
|
28481
28589
|
if (!refs[executable.path]?.equals(executable.cid)) throw new RangeError("SkillRoot entrypoint is outside the committed files.");
|
|
28482
|
-
const
|
|
28483
|
-
if (
|
|
28590
|
+
const manifest6 = await authenticatedJSON(proof.manifest, CID.asCID(root.manifest));
|
|
28591
|
+
if (manifest6.schemaVersion !== "1.0" || typeof manifest6.name !== "string" || typeof manifest6.summary !== "string" || manifest6.skillVersion !== String(version6) || manifest6.entrypoint !== executable.path) throw new RangeError("Invalid SkillRoot manifest.");
|
|
28484
28592
|
const hashes = /* @__PURE__ */ Object.create(null);
|
|
28485
28593
|
if (root.confidentiality === void 0) {
|
|
28486
28594
|
if (proof.confidentiality !== void 0) throw new RangeError("Public SkillRoot declares encrypted transport.");
|
|
@@ -28492,10 +28600,10 @@ async function verifySkillRootProof(proof, packageHash, version6, previousHash)
|
|
|
28492
28600
|
const objects = record2(descriptor.objects);
|
|
28493
28601
|
if (Object.keys(objects).length !== Object.keys(refs).length) throw new RangeError("SkillRoot confidentiality paths do not match files.");
|
|
28494
28602
|
for (const [name, cid] of Object.entries(refs)) {
|
|
28495
|
-
const
|
|
28496
|
-
exact(
|
|
28497
|
-
if (
|
|
28498
|
-
hashes[name] =
|
|
28603
|
+
const object5 = record2(objects[name]);
|
|
28604
|
+
exact(object5, ["ciphertext", "plaintextHash"]);
|
|
28605
|
+
if (object5.ciphertext !== cid.toString() || typeof object5.plaintextHash !== "string" || !HASH.test(object5.plaintextHash)) throw new RangeError("SkillRoot ciphertext CID or plaintext hash mismatch.");
|
|
28606
|
+
hashes[name] = object5.plaintextHash;
|
|
28499
28607
|
}
|
|
28500
28608
|
}
|
|
28501
28609
|
return {
|
|
@@ -28503,8 +28611,8 @@ async function verifySkillRootProof(proof, packageHash, version6, previousHash)
|
|
|
28503
28611
|
mdHash: hashes[md.path],
|
|
28504
28612
|
primaryPath: md.path,
|
|
28505
28613
|
plaintext: root.confidentiality === void 0,
|
|
28506
|
-
name:
|
|
28507
|
-
summary:
|
|
28614
|
+
name: manifest6.name,
|
|
28615
|
+
summary: manifest6.summary,
|
|
28508
28616
|
fileHashes: hashes
|
|
28509
28617
|
};
|
|
28510
28618
|
}
|
|
@@ -28691,15 +28799,15 @@ function buildDetailDocuments(input) {
|
|
|
28691
28799
|
if (raw === null || typeof raw !== "object" || Array.isArray(raw)) {
|
|
28692
28800
|
throw new RangeError(`Skill ${kind} document is invalid.`);
|
|
28693
28801
|
}
|
|
28694
|
-
const
|
|
28695
|
-
const shape = Object.keys(
|
|
28696
|
-
if (shape !== "assets,entry,mode" && shape !== "assets,entry,externalMediaHosts,mode" ||
|
|
28802
|
+
const document = raw;
|
|
28803
|
+
const shape = Object.keys(document).sort().join(",");
|
|
28804
|
+
if (shape !== "assets,entry,mode" && shape !== "assets,entry,externalMediaHosts,mode" || document.mode !== "html" || !Array.isArray(document.assets) || document.assets.length > 50) {
|
|
28697
28805
|
throw new RangeError(`Skill ${kind} document is invalid.`);
|
|
28698
28806
|
}
|
|
28699
|
-
const externalMediaHosts = detailExternalMediaHosts(
|
|
28700
|
-
const entry2 = detailObject(
|
|
28807
|
+
const externalMediaHosts = detailExternalMediaHosts(document.externalMediaHosts, kind);
|
|
28808
|
+
const entry2 = detailObject(document.entry, `Skill ${kind} HTML`, "text/html", kind);
|
|
28701
28809
|
const names = /* @__PURE__ */ new Set();
|
|
28702
|
-
const assets =
|
|
28810
|
+
const assets = document.assets.map((rawAsset) => {
|
|
28703
28811
|
if (rawAsset === null || typeof rawAsset !== "object" || Array.isArray(rawAsset)) {
|
|
28704
28812
|
throw new RangeError(`Skill ${kind} asset is invalid.`);
|
|
28705
28813
|
}
|
|
@@ -28757,8 +28865,8 @@ function buildManifest(entries, presentation, documents) {
|
|
|
28757
28865
|
...normalizedDocuments === void 0 ? {} : { documents: normalizedDocuments }
|
|
28758
28866
|
};
|
|
28759
28867
|
}
|
|
28760
|
-
function serializeManifest(
|
|
28761
|
-
return new TextEncoder().encode(JSON.stringify(
|
|
28868
|
+
function serializeManifest(manifest6) {
|
|
28869
|
+
return new TextEncoder().encode(JSON.stringify(manifest6));
|
|
28762
28870
|
}
|
|
28763
28871
|
function parseManifest2(bytes) {
|
|
28764
28872
|
let value;
|
|
@@ -28780,14 +28888,11 @@ function parseManifest2(bytes) {
|
|
|
28780
28888
|
return null;
|
|
28781
28889
|
}
|
|
28782
28890
|
}
|
|
28783
|
-
function packageForVersion(
|
|
28784
|
-
return
|
|
28891
|
+
function packageForVersion(manifest6, version6) {
|
|
28892
|
+
return manifest6.versions.find((entry2) => entry2.version === version6) ?? null;
|
|
28785
28893
|
}
|
|
28786
|
-
function withVersion(
|
|
28787
|
-
return buildManifest([...
|
|
28788
|
-
}
|
|
28789
|
-
function withPresentation(manifest5, presentation) {
|
|
28790
|
-
return buildManifest(manifest5.versions, presentation, manifest5.documents);
|
|
28894
|
+
function withVersion(manifest6, entry2) {
|
|
28895
|
+
return buildManifest([...manifest6?.versions ?? [], entry2], manifest6?.presentation, manifest6?.documents);
|
|
28791
28896
|
}
|
|
28792
28897
|
var MAX_SKILL_MANIFEST_BYTES, SKILL_MANIFEST_SCHEME, SKILL_DETAIL_KINDS, DETAIL_MEDIA_TYPES, DETAIL_HASH, DETAIL_ASSET_PATH, DETAIL_IPFS_URI, DETAIL_STORAGE_URI, DETAIL_BUCKET_BY_KIND, DETAIL_MEDIA_HOST;
|
|
28793
28898
|
var init_manifest = __esm({
|
|
@@ -28848,8 +28953,8 @@ async function createOracleDevice() {
|
|
|
28848
28953
|
async function oracleNonce(device) {
|
|
28849
28954
|
assertOraclePublicKey(device.publicKey);
|
|
28850
28955
|
if (!Number.isSafeInteger(device.nonceMs) || device.nonceMs <= 0) throw new TypeError("Invalid Oracle request timestamp.");
|
|
28851
|
-
const
|
|
28852
|
-
return `${ORACLE_DELIVERY}:${device.nonceMs}:${
|
|
28956
|
+
const fingerprint = await sha256Hex(new TextEncoder().encode(`${device.publicKey.x}.${device.publicKey.y}`));
|
|
28957
|
+
return `${ORACLE_DELIVERY}:${device.nonceMs}:${fingerprint.slice(2)}`;
|
|
28853
28958
|
}
|
|
28854
28959
|
async function openOracleKey(sealed, privateKey3) {
|
|
28855
28960
|
assertOraclePublicKey(sealed.ephemeralPublicJwk);
|
|
@@ -29645,7 +29750,7 @@ var init_validation_input = __esm({
|
|
|
29645
29750
|
});
|
|
29646
29751
|
|
|
29647
29752
|
// ../../packages/agent-market-contracts/src/v1/errors.ts
|
|
29648
|
-
var creatorRequestReasonCodes, agentMarketErrorCodes, nextActionValues, AGENT_MARKET_ERROR_DEFINITIONS, nullableStringSchema, nullableUuidSchema, nullableRevisionSchema2, agentMarketErrorEnvelopeSchema;
|
|
29753
|
+
var creatorRequestReasonCodes, buyerStateReasonCodes, agentMarketErrorCodes, nextActionValues, AGENT_MARKET_ERROR_DEFINITIONS, nullableStringSchema, nullableUuidSchema, nullableRevisionSchema2, agentMarketErrorEnvelopeSchema;
|
|
29649
29754
|
var init_errors3 = __esm({
|
|
29650
29755
|
"../../packages/agent-market-contracts/src/v1/errors.ts"() {
|
|
29651
29756
|
"use strict";
|
|
@@ -29658,6 +29763,14 @@ var init_errors3 = __esm({
|
|
|
29658
29763
|
"creator_text_invalid_unicode",
|
|
29659
29764
|
"creator_database_constraint"
|
|
29660
29765
|
];
|
|
29766
|
+
buyerStateReasonCodes = [
|
|
29767
|
+
"AGENT_MARKET_INVOCATION_NOT_CONTINUABLE",
|
|
29768
|
+
"AGENT_REVIEW_WALLET_REQUIRED",
|
|
29769
|
+
"AGENT_REVIEW_CREATOR_FORBIDDEN",
|
|
29770
|
+
"AGENT_REVIEW_USAGE_REQUIRED",
|
|
29771
|
+
"AVATAR_VIDEO_ACCOUNT_DAILY_LIMIT_REACHED",
|
|
29772
|
+
"AVATAR_VIDEO_PLATFORM_DAILY_LIMIT_REACHED"
|
|
29773
|
+
];
|
|
29661
29774
|
agentMarketErrorCodes = [
|
|
29662
29775
|
"AGENT_MARKET_AUTH_REQUIRED",
|
|
29663
29776
|
"AGENT_MARKET_SCOPE_DENIED",
|
|
@@ -29736,7 +29849,11 @@ var init_errors3 = __esm({
|
|
|
29736
29849
|
error: strictObjectSchema2({
|
|
29737
29850
|
code: { type: "string", enum: agentMarketErrorCodes },
|
|
29738
29851
|
message: { type: "string", minLength: 1, maxLength: 500 },
|
|
29739
|
-
reasonCode: { anyOf: [{ type: "string", enum: [
|
|
29852
|
+
reasonCode: { anyOf: [{ type: "string", enum: [
|
|
29853
|
+
...validationInputReasonCodes,
|
|
29854
|
+
...creatorRequestReasonCodes,
|
|
29855
|
+
...buyerStateReasonCodes
|
|
29856
|
+
] }, { type: "null" }] },
|
|
29740
29857
|
retryable: { type: "boolean" },
|
|
29741
29858
|
nextAction: { type: "string", enum: nextActionValues },
|
|
29742
29859
|
state: nullableStringSchema,
|
|
@@ -30976,7 +31093,17 @@ function taskMutationReceiptProperties(status) {
|
|
|
30976
31093
|
function taskMutationReceipt(status) {
|
|
30977
31094
|
return strictObjectSchema2(taskMutationReceiptProperties(status));
|
|
30978
31095
|
}
|
|
30979
|
-
|
|
31096
|
+
function taskProjectionSchema(properties) {
|
|
31097
|
+
return strictObjectSchema2({
|
|
31098
|
+
...properties,
|
|
31099
|
+
failureCode: { anyOf: [taskFailureCodeSchema, nullSchema2] },
|
|
31100
|
+
providerFailureCode: { anyOf: [{ type: "string", minLength: 1, maxLength: 120 }, nullSchema2] },
|
|
31101
|
+
failureMessage: { anyOf: [{ type: "string", maxLength: 4e3 }, nullSchema2] },
|
|
31102
|
+
interimContent: taskPresentationContentSchema,
|
|
31103
|
+
terminalContent: taskPresentationContentSchema
|
|
31104
|
+
}, Object.keys(properties));
|
|
31105
|
+
}
|
|
31106
|
+
var booleanSchema2, jsonValueSchema, nullSchema2, agentOnInitialInputSchema, agentOnFollowUpContentSchema, feeBpsCapSchema, createPurchaseIntentRequestSchema, purchaseIntentAcceptedSchema, PURCHASE_FEE_DECISION_CONTRACT, feeSnapshotCommon, purchaseFeeDecisionSnapshotSchema, PURCHASE_LIFECYCLE_CONTRACT, FINANCIAL_AUTHORIZATION_CONTRACT, nonNegativeIntegerStringSchema2, callRightPurchaseBatchSchema, callRightsListResponseSchema, CALL_RIGHTS_PAGE_CONTRACT, CALL_FUNDING_SOURCES, fundingSourceSchema, callEligibilityQuerySchema, described2, callEligibilityResponseSchema, invocationStartRequestSchema, invocationContinueRequestSchema, runtimeHandoffStateSchema, p1InvocationReceiptProperties, p1InvocationReceiptSchema, p1InvocationAcceptedSchema, directInvocationAcceptedSchema, supplementalQuestionOptionSchema, p1QuestionSchema, p1QuestionsSchema, p1AwaitingCompletionQuestionsSchema, taskQuestionSchema, taskQuestionsSchema, closedPublicFailureSchema, timeoutFailureSchema, invocationCommon, p1InvocationResponseSchema, directInvocationCommon, directPublicFailureSchema, directInvocationResponseSchema, DIRECT_INVOCATION_READ_CONTRACT, invocationResponseSchema, createTaskRequestSchema, TASK_QUANTITY_AUTHORITY_CONTRACT, taskCreateReceiptProperties, taskCreateReceiptSchema, taskCreateAcceptedSchema, taskStrongEtagSchema, taskInputReceiptSchema, taskInputAcceptedSchema, taskCommon, buyerOutputArtifactSchema, buyerOutputArtifactsSchema, taskFailureCodeSchema, taskFailureSchema, taskPresentationContentSchema, taskResponseSchema, BUYER_AGENTON_RECOVERY_CONTRACT, appendTaskInputRequestSchema, directInvocationRequestSchema, TASK_COMPLETED_CANONICALIZATION;
|
|
30980
31107
|
var init_buyer = __esm({
|
|
30981
31108
|
"../../packages/agent-market-contracts/src/v1/buyer.ts"() {
|
|
30982
31109
|
"use strict";
|
|
@@ -31260,7 +31387,7 @@ var init_buyer = __esm({
|
|
|
31260
31387
|
});
|
|
31261
31388
|
timeoutFailureSchema = strictObjectSchema2({
|
|
31262
31389
|
code: { const: "AGENT_MARKET_RUNTIME_TIMEOUT" },
|
|
31263
|
-
message: nullSchema2
|
|
31390
|
+
message: { anyOf: [{ type: "string", maxLength: 4e3 }, nullSchema2] }
|
|
31264
31391
|
});
|
|
31265
31392
|
invocationCommon = {
|
|
31266
31393
|
operationId: canonicalUuidSchema2,
|
|
@@ -31459,40 +31586,56 @@ var init_buyer = __esm({
|
|
|
31459
31586
|
maxItems: 100,
|
|
31460
31587
|
items: buyerOutputArtifactSchema
|
|
31461
31588
|
});
|
|
31589
|
+
taskFailureCodeSchema = Object.freeze({
|
|
31590
|
+
type: "string",
|
|
31591
|
+
enum: ["AGENT_MARKET_RUNTIME_TIMEOUT", "AGENT_MARKET_RUNTIME_REJECTED", "AGENT_MARKET_RUNTIME_UNAVAILABLE"]
|
|
31592
|
+
});
|
|
31593
|
+
taskFailureSchema = strictObjectSchema2({
|
|
31594
|
+
code: taskFailureCodeSchema,
|
|
31595
|
+
message: { anyOf: [{ type: "string", maxLength: 4e3 }, nullSchema2] }
|
|
31596
|
+
});
|
|
31597
|
+
taskPresentationContentSchema = Object.freeze({
|
|
31598
|
+
anyOf: [nullSchema2, { type: "array", minItems: 1, maxItems: 100, items: { oneOf: [
|
|
31599
|
+
strictObjectSchema2({ type: { const: "text" }, text: { type: "string" } }),
|
|
31600
|
+
strictObjectSchema2({ type: { const: "json" }, json: jsonValueSchema })
|
|
31601
|
+
] } }]
|
|
31602
|
+
});
|
|
31462
31603
|
taskResponseSchema = Object.freeze({
|
|
31463
31604
|
oneOf: [
|
|
31464
|
-
...["submitted", "working"].map((status) =>
|
|
31605
|
+
...["submitted", "working"].map((status) => taskProjectionSchema({
|
|
31465
31606
|
...taskCommon,
|
|
31466
31607
|
status: { const: status },
|
|
31467
31608
|
output: nullSchema2,
|
|
31468
31609
|
error: nullSchema2
|
|
31469
31610
|
})),
|
|
31470
|
-
|
|
31611
|
+
taskProjectionSchema({
|
|
31471
31612
|
...taskCommon,
|
|
31472
31613
|
status: { const: "input_required" },
|
|
31614
|
+
inputRound: { type: "integer", minimum: 1, maximum: 100 },
|
|
31615
|
+
inputToken: hex32Schema,
|
|
31473
31616
|
output: strictObjectSchema2({ questions: taskQuestionsSchema }),
|
|
31474
31617
|
error: nullSchema2
|
|
31475
31618
|
}),
|
|
31476
|
-
|
|
31619
|
+
taskProjectionSchema({
|
|
31477
31620
|
...taskCommon,
|
|
31478
31621
|
status: { const: "completed" },
|
|
31479
31622
|
output: jsonValueSchema,
|
|
31480
31623
|
artifacts: buyerOutputArtifactsSchema,
|
|
31481
31624
|
error: nullSchema2
|
|
31482
31625
|
}),
|
|
31483
|
-
|
|
31626
|
+
taskProjectionSchema({
|
|
31484
31627
|
...taskCommon,
|
|
31485
31628
|
status: { const: "failed" },
|
|
31486
31629
|
output: nullSchema2,
|
|
31487
|
-
error:
|
|
31630
|
+
error: taskFailureSchema
|
|
31488
31631
|
}),
|
|
31489
|
-
|
|
31632
|
+
taskProjectionSchema({
|
|
31490
31633
|
...taskCommon,
|
|
31491
31634
|
status: { const: "canceled" },
|
|
31492
31635
|
output: nullSchema2,
|
|
31493
|
-
error: nullSchema2
|
|
31636
|
+
error: { anyOf: [taskFailureSchema, nullSchema2] }
|
|
31494
31637
|
}),
|
|
31495
|
-
|
|
31638
|
+
taskProjectionSchema({
|
|
31496
31639
|
...taskCommon,
|
|
31497
31640
|
status: { const: "expired" },
|
|
31498
31641
|
output: nullSchema2,
|
|
@@ -31514,7 +31657,7 @@ var init_buyer = __esm({
|
|
|
31514
31657
|
p1ContinueOperationIdIsGenericRecovery: true,
|
|
31515
31658
|
missingOrForeignOperationError: "AGENT_MARKET_OPERATION_NOT_FOUND"
|
|
31516
31659
|
});
|
|
31517
|
-
appendTaskInputRequestSchema = strictObjectSchema2({ content: agentOnFollowUpContentSchema });
|
|
31660
|
+
appendTaskInputRequestSchema = strictObjectSchema2({ content: agentOnFollowUpContentSchema, inputToken: hex32Schema });
|
|
31518
31661
|
directInvocationRequestSchema = strictObjectSchema2({ input: jsonValueSchema });
|
|
31519
31662
|
TASK_COMPLETED_CANONICALIZATION = Object.freeze({
|
|
31520
31663
|
omitted: true,
|
|
@@ -32374,31 +32517,13 @@ var init_foundation = __esm({
|
|
|
32374
32517
|
});
|
|
32375
32518
|
|
|
32376
32519
|
// ../../packages/agent-market-contracts/src/v1/identity.ts
|
|
32377
|
-
var PRODUCTION_AUTH_CHAIN_IDS, TEST_AUTH_CHAIN_IDS,
|
|
32520
|
+
var PRODUCTION_AUTH_CHAIN_IDS, TEST_AUTH_CHAIN_IDS, IDENTITY_SCOPE_ORDER_CONTRACT, identityEnvironmentValues, environmentSchema, chainIdSchema2, dateTimeSchema, identityChallengeRequestSchema, identityChallengeResponseSchema, identityLoginRequestSchema, identitySessionResponseSchema, identitySessionStatusResponseSchema, identityLogoutRequestSchema, identityMcpActorResponseSchema, identityErrorCodes, identityErrorEnvelopeSchema, IDENTITY_V1_ROUTES, IDENTITY_V1_OPERATIONS, IDENTITY_MCP_V1_MANIFEST;
|
|
32378
32521
|
var init_identity = __esm({
|
|
32379
32522
|
"../../packages/agent-market-contracts/src/v1/identity.ts"() {
|
|
32380
32523
|
"use strict";
|
|
32381
32524
|
init_common3();
|
|
32382
|
-
PRODUCTION_AUTH_CHAIN_IDS = Object.freeze([1, 10, 56, 8453, 42161]);
|
|
32525
|
+
PRODUCTION_AUTH_CHAIN_IDS = Object.freeze([1, 10, 56, 8453, 42161, 43114, 1776]);
|
|
32383
32526
|
TEST_AUTH_CHAIN_IDS = Object.freeze([84532]);
|
|
32384
|
-
identityScopeValues = [
|
|
32385
|
-
"account:read",
|
|
32386
|
-
"agent_market:buyer:invoke",
|
|
32387
|
-
"agent_market:buyer:purchase",
|
|
32388
|
-
"agent_market:buyer:read",
|
|
32389
|
-
"agent_market:discover",
|
|
32390
|
-
"agent_market:merchant:read",
|
|
32391
|
-
"agent_market:merchant:write",
|
|
32392
|
-
"agent_market:operations:read",
|
|
32393
|
-
"skill_market:buyer:write",
|
|
32394
|
-
"skill_market:creator:write",
|
|
32395
|
-
"skill_market:discover",
|
|
32396
|
-
"task_market:discover",
|
|
32397
|
-
"task_market:participant:read",
|
|
32398
|
-
"task_market:participant:write",
|
|
32399
|
-
"task_market:requester:read",
|
|
32400
|
-
"task_market:requester:write"
|
|
32401
|
-
];
|
|
32402
32527
|
IDENTITY_SCOPE_ORDER_CONTRACT = Object.freeze({
|
|
32403
32528
|
order: "ascii_lexicographic",
|
|
32404
32529
|
duplicatesAllowed: false,
|
|
@@ -32408,15 +32533,6 @@ var init_identity = __esm({
|
|
|
32408
32533
|
environmentSchema = { type: "string", enum: identityEnvironmentValues };
|
|
32409
32534
|
chainIdSchema2 = { type: "integer", minimum: 1, maximum: 2147483647 };
|
|
32410
32535
|
dateTimeSchema = { type: "string", format: "date-time" };
|
|
32411
|
-
grantScopesSchema = {
|
|
32412
|
-
type: "array",
|
|
32413
|
-
minItems: 1,
|
|
32414
|
-
maxItems: 16,
|
|
32415
|
-
uniqueItems: true,
|
|
32416
|
-
items: { type: "string", enum: identityScopeValues },
|
|
32417
|
-
description: "Strictly ASCII-lexicographically sorted unique grant scopes.",
|
|
32418
|
-
"x-finch-order": IDENTITY_SCOPE_ORDER_CONTRACT.order
|
|
32419
|
-
};
|
|
32420
32536
|
identityChallengeRequestSchema = strictObjectSchema2({
|
|
32421
32537
|
walletAddress: evmAddressSchema,
|
|
32422
32538
|
chainId: chainIdSchema2
|
|
@@ -32463,33 +32579,6 @@ var init_identity = __esm({
|
|
|
32463
32579
|
description: "Finch environment serving this MCP request. In normal end-user use, this should be `production`. It does not select the CLI endpoint or transaction chain."
|
|
32464
32580
|
}
|
|
32465
32581
|
});
|
|
32466
|
-
identityGrantCreateRequestSchema = strictObjectSchema2({
|
|
32467
|
-
grantId: canonicalUuidSchema2,
|
|
32468
|
-
grantTokenCommitment: hex32Schema,
|
|
32469
|
-
scopes: grantScopesSchema,
|
|
32470
|
-
expiresAt: dateTimeSchema
|
|
32471
|
-
});
|
|
32472
|
-
identityGrantCreateResponseSchema = strictObjectSchema2({
|
|
32473
|
-
grantId: canonicalUuidSchema2,
|
|
32474
|
-
accountId: canonicalUuidSchema2,
|
|
32475
|
-
audience: { const: "finch_mcp" },
|
|
32476
|
-
environment: environmentSchema,
|
|
32477
|
-
scopes: grantScopesSchema,
|
|
32478
|
-
expiresAt: dateTimeSchema,
|
|
32479
|
-
replayed: { type: "boolean" }
|
|
32480
|
-
});
|
|
32481
|
-
identityGrantShowResponseSchema = strictObjectSchema2({
|
|
32482
|
-
grantId: canonicalUuidSchema2,
|
|
32483
|
-
audience: { const: "finch_mcp" },
|
|
32484
|
-
environment: environmentSchema,
|
|
32485
|
-
scopes: grantScopesSchema,
|
|
32486
|
-
createdAt: dateTimeSchema,
|
|
32487
|
-
expiresAt: dateTimeSchema,
|
|
32488
|
-
revokedAt: { type: ["string", "null"], format: "date-time" },
|
|
32489
|
-
status: { type: "string", enum: ["active", "expired", "revoked"] },
|
|
32490
|
-
parentSessionExpiresAt: dateTimeSchema
|
|
32491
|
-
});
|
|
32492
|
-
identityGrantRevokeRequestSchema = emptyStrictObjectSchema;
|
|
32493
32582
|
identityErrorCodes = [
|
|
32494
32583
|
"AGENT_AUTH_REQUEST_INVALID",
|
|
32495
32584
|
"AGENT_AUTH_CHAIN_UNSUPPORTED",
|
|
@@ -32519,9 +32608,6 @@ var init_identity = __esm({
|
|
|
32519
32608
|
login: "/api/v1/identity/agent-cli/sessions",
|
|
32520
32609
|
session: "/api/v1/identity/agent-cli/session",
|
|
32521
32610
|
logout: "/api/v1/identity/agent-cli/session/logout",
|
|
32522
|
-
grantCreate: "/api/v1/identity/agent-cli/grants",
|
|
32523
|
-
grantShow: "/api/v1/identity/agent-cli/grants/{grantId}",
|
|
32524
|
-
grantRevoke: "/api/v1/identity/agent-cli/grants/{grantId}/revoke",
|
|
32525
32611
|
mcpActor: "/api/v1/identity/mcp/actor"
|
|
32526
32612
|
});
|
|
32527
32613
|
IDENTITY_V1_OPERATIONS = Object.freeze({
|
|
@@ -32529,9 +32615,6 @@ var init_identity = __esm({
|
|
|
32529
32615
|
login: { id: "identity.login", method: "post", path: IDENTITY_V1_ROUTES.login, successStatus: 201, auth: "public", requestSchema: identityLoginRequestSchema, responseSchema: identitySessionResponseSchema },
|
|
32530
32616
|
session: { id: "identity.session", method: "get", path: IDENTITY_V1_ROUTES.session, successStatus: 200, auth: "agent_cli_session", responseSchema: identitySessionStatusResponseSchema },
|
|
32531
32617
|
logout: { id: "identity.logout", method: "post", path: IDENTITY_V1_ROUTES.logout, successStatus: 204, auth: "agent_cli_session", requestSchema: identityLogoutRequestSchema },
|
|
32532
|
-
grantCreate: { id: "identity.grant_create", method: "post", path: IDENTITY_V1_ROUTES.grantCreate, successStatus: 201, auth: "agent_cli_session", idempotencySchema: idempotencyHeaderSchema, requestSchema: identityGrantCreateRequestSchema, responseSchema: identityGrantCreateResponseSchema },
|
|
32533
|
-
grantShow: { id: "identity.grant_show", method: "get", path: IDENTITY_V1_ROUTES.grantShow, successStatus: 200, auth: "agent_cli_session", responseSchema: identityGrantShowResponseSchema },
|
|
32534
|
-
grantRevoke: { id: "identity.grant_revoke", method: "post", path: IDENTITY_V1_ROUTES.grantRevoke, successStatus: 204, auth: "agent_cli_session", idempotencySchema: idempotencyHeaderSchema, requestSchema: identityGrantRevokeRequestSchema },
|
|
32535
32618
|
mcpActor: {
|
|
32536
32619
|
id: "identity.actor",
|
|
32537
32620
|
method: "get",
|
|
@@ -32557,11 +32640,6 @@ var init_identity = __esm({
|
|
|
32557
32640
|
sideEffect: "read"
|
|
32558
32641
|
})])
|
|
32559
32642
|
});
|
|
32560
|
-
CLI_GRANT_SHOW_WIRE = Object.freeze({
|
|
32561
|
-
operation: "grant.show",
|
|
32562
|
-
responseSchema: identityGrantShowResponseSchema,
|
|
32563
|
-
rawGrantTokenInResponse: false
|
|
32564
|
-
});
|
|
32565
32643
|
}
|
|
32566
32644
|
});
|
|
32567
32645
|
|
|
@@ -34570,8 +34648,6 @@ var init_operations = __esm({
|
|
|
34570
34648
|
requestSchema: appendTaskInputRequestSchema,
|
|
34571
34649
|
responseSchema: taskInputAcceptedSchema,
|
|
34572
34650
|
idempotencyRequired: true,
|
|
34573
|
-
ifMatchRequired: true,
|
|
34574
|
-
ifMatchResourceKind: "task",
|
|
34575
34651
|
etagReturned: true
|
|
34576
34652
|
}),
|
|
34577
34653
|
mcp: { name: "agent_market_buyer_task_input" },
|
|
@@ -37899,15 +37975,15 @@ function createHmacDrbg(hashLen, qByteLen, hmacFn) {
|
|
|
37899
37975
|
};
|
|
37900
37976
|
return genUntil;
|
|
37901
37977
|
}
|
|
37902
|
-
function validateObject(
|
|
37978
|
+
function validateObject(object5, validators, optValidators = {}) {
|
|
37903
37979
|
const checkField = (fieldName, type, isOptional) => {
|
|
37904
37980
|
const checkVal = validatorFns[type];
|
|
37905
37981
|
if (typeof checkVal !== "function")
|
|
37906
37982
|
throw new Error("invalid validator function");
|
|
37907
|
-
const val =
|
|
37983
|
+
const val = object5[fieldName];
|
|
37908
37984
|
if (isOptional && val === void 0)
|
|
37909
37985
|
return;
|
|
37910
|
-
if (!checkVal(val,
|
|
37986
|
+
if (!checkVal(val, object5)) {
|
|
37911
37987
|
throw new Error("param " + String(fieldName) + " is invalid. Expected " + type + ", got " + val);
|
|
37912
37988
|
}
|
|
37913
37989
|
};
|
|
@@ -37915,7 +37991,7 @@ function validateObject(object6, validators, optValidators = {}) {
|
|
|
37915
37991
|
checkField(fieldName, type, false);
|
|
37916
37992
|
for (const [fieldName, type] of Object.entries(optValidators))
|
|
37917
37993
|
checkField(fieldName, type, true);
|
|
37918
|
-
return
|
|
37994
|
+
return object5;
|
|
37919
37995
|
}
|
|
37920
37996
|
function memoized(fn) {
|
|
37921
37997
|
const map2 = /* @__PURE__ */ new WeakMap();
|
|
@@ -37949,7 +38025,7 @@ var init_utils2 = __esm({
|
|
|
37949
38025
|
stringOrUint8Array: (val) => typeof val === "string" || isBytes2(val),
|
|
37950
38026
|
isSafeInteger: (val) => Number.isSafeInteger(val),
|
|
37951
38027
|
array: (val) => Array.isArray(val),
|
|
37952
|
-
field: (val,
|
|
38028
|
+
field: (val, object5) => object5.Fp.isValid(val),
|
|
37953
38029
|
hash: (val) => typeof val === "function" && Number.isSafeInteger(val.outputLen)
|
|
37954
38030
|
};
|
|
37955
38031
|
}
|
|
@@ -57576,7 +57652,7 @@ function publishPlan(value, context) {
|
|
|
57576
57652
|
const chainId = assertAuthority(plan, "publish", context.walletAddress);
|
|
57577
57653
|
assertLocalAction(plan.localAction, "skill publish-submit");
|
|
57578
57654
|
const request2 = object2(plan.request, "Skill publish request");
|
|
57579
|
-
exact2(request2, ["chainId", "slug", "name", "category", "licenseTypeName", "imageURI", "sourceKind", "contentMode", "unitPrice", "maxSupply",
|
|
57655
|
+
exact2(request2, ["chainId", "slug", "name", "category", "licenseTypeName", "imageURI", "sourceKind", "contentMode", "unitPrice", "maxSupply", ...Object.hasOwn(request2, "summary") ? ["summary"] : []], "Skill publish request");
|
|
57580
57656
|
if (request2.chainId !== chainId) throw new TypeError("Skill publish request chain is invalid.");
|
|
57581
57657
|
string4(request2.slug, "Skill slug");
|
|
57582
57658
|
string4(request2.name, "Skill name");
|
|
@@ -57590,8 +57666,6 @@ function publishPlan(value, context) {
|
|
|
57590
57666
|
contentMode(request2.contentMode);
|
|
57591
57667
|
string4(request2.unitPrice, "Skill unitPrice", DECIMAL);
|
|
57592
57668
|
string4(request2.maxSupply, "Skill maxSupply", DECIMAL);
|
|
57593
|
-
string4(request2.usageLimit, "Skill usageLimit", DECIMAL);
|
|
57594
|
-
if (!Number.isInteger(request2.royaltyBPS) || Number(request2.royaltyBPS) < 0 || Number(request2.royaltyBPS) > 1e3) throw new TypeError("Skill royaltyBPS is invalid.");
|
|
57595
57669
|
return {
|
|
57596
57670
|
chainId,
|
|
57597
57671
|
request: request2,
|
|
@@ -57638,32 +57712,6 @@ function managePlan(value, walletAddress2, kind) {
|
|
|
57638
57712
|
signingAuthority: plan.signingAuthority
|
|
57639
57713
|
}, walletAddress2) };
|
|
57640
57714
|
}
|
|
57641
|
-
function presentationPlan(value, walletAddress2) {
|
|
57642
|
-
const plan = object2(value, "Skill presentation plan");
|
|
57643
|
-
exact2(plan, [
|
|
57644
|
-
"kind",
|
|
57645
|
-
"sourceCommit",
|
|
57646
|
-
"chainId",
|
|
57647
|
-
"walletAddress",
|
|
57648
|
-
"signingAuthority",
|
|
57649
|
-
"skillId",
|
|
57650
|
-
"currentVersion",
|
|
57651
|
-
"currentManifestURI",
|
|
57652
|
-
"presentation",
|
|
57653
|
-
"localAction"
|
|
57654
|
-
], "Skill presentation plan");
|
|
57655
|
-
const chainId = assertAuthority(plan, "presentation", walletAddress2);
|
|
57656
|
-
const skillId = string4(plan.skillId, "Skill id", /^[1-9][0-9]*$/u);
|
|
57657
|
-
assertLocalAction(plan.localAction, "skill presentation-submit", skillId);
|
|
57658
|
-
return {
|
|
57659
|
-
chainId,
|
|
57660
|
-
skillId,
|
|
57661
|
-
currentVersion: integer2(plan.currentVersion, "Current version"),
|
|
57662
|
-
currentManifestURI: string4(plan.currentManifestURI, "Current manifest URI", IPFS),
|
|
57663
|
-
presentation: buildPresentation(plan.presentation),
|
|
57664
|
-
signingAuthority: signingAuthority(plan.signingAuthority, walletAddress2)
|
|
57665
|
-
};
|
|
57666
|
-
}
|
|
57667
57715
|
function assetPlan(value, walletAddress2) {
|
|
57668
57716
|
const plan = object2(value, "Skill asset plan");
|
|
57669
57717
|
exact2(plan, [
|
|
@@ -57752,7 +57800,7 @@ function recoveryFingerprint(kind, plan, walletAddress2, intentId) {
|
|
|
57752
57800
|
sourceCommit: skillV3SourceCommit(chainId)
|
|
57753
57801
|
})).digest("hex");
|
|
57754
57802
|
}
|
|
57755
|
-
function recoveryJournal(value,
|
|
57803
|
+
function recoveryJournal(value, fingerprint, kind, context) {
|
|
57756
57804
|
const journal = object2(value, "Skill publication recovery");
|
|
57757
57805
|
exact2(journal, [
|
|
57758
57806
|
"version",
|
|
@@ -57779,7 +57827,7 @@ function recoveryJournal(value, fingerprint2, kind, context) {
|
|
|
57779
57827
|
], "Skill publication recovery");
|
|
57780
57828
|
if (journal.intentId !== void 0 && (typeof journal.intentId !== "string" || !UUID.test(journal.intentId) || journal.origin !== context.origin)) throw new TypeError("Skill recovery endpoint or intent is invalid.");
|
|
57781
57829
|
const chainId = skillChain(journal.chainId, "Skill recovery chain");
|
|
57782
|
-
if (journal.version !== 4 && journal.version !== 5 && journal.version !== 6 || journal.kind !== kind || journal.fingerprint !==
|
|
57830
|
+
if (journal.version !== 4 && journal.version !== 5 && journal.version !== 6 || journal.kind !== kind || journal.fingerprint !== fingerprint || !/^[0-9a-f]{64}$/u.test(fingerprint) || typeof journal.walletAddress !== "string" || journal.walletAddress.toLowerCase() !== context.walletAddress.toLowerCase()) throw new TypeError("Skill publication recovery authority does not match this command.");
|
|
57783
57831
|
const recoveredAuthority = assertPublicationAuthority(
|
|
57784
57832
|
signingAuthority(journal.signingAuthority, context.walletAddress),
|
|
57785
57833
|
context
|
|
@@ -57881,14 +57929,14 @@ var init_skill_local_flow = __esm({
|
|
|
57881
57929
|
...Object.entries(progress.journal?.receipts ?? {}).flatMap(([stage, receipt]) => receipt && HASH2.test(receipt.transactionHash) ? [[stage, receipt.transactionHash]] : []),
|
|
57882
57930
|
...Object.entries(progress.broadcast ?? {}).filter(([, hash5]) => HASH2.test(hash5))
|
|
57883
57931
|
]);
|
|
57884
|
-
const
|
|
57932
|
+
const fingerprint = progress.journal && progress.fingerprint ? progress.fingerprint : progress.walletFingerprint ?? null;
|
|
57885
57933
|
throw new CliSkillPublicationError({
|
|
57886
57934
|
phase: progress.phase,
|
|
57887
|
-
fingerprint
|
|
57935
|
+
fingerprint,
|
|
57888
57936
|
transactionHashes,
|
|
57889
57937
|
unconfirmedActions: unconfirmed,
|
|
57890
57938
|
submissionStatus: progress.uncertain ? "uncertain" : Object.keys(transactionHashes).length ? "hash_known" : "not_attempted",
|
|
57891
|
-
recoveryCommand: progress.journalSaved && !progress.uncertain && progress.phase !== "cleanup" &&
|
|
57939
|
+
recoveryCommand: progress.journalSaved && !progress.uncertain && progress.phase !== "cleanup" && fingerprint ? `finch skill recover ${progress.walletFingerprint ? "intent" : "publication"} ${fingerprint}` : null,
|
|
57892
57940
|
resubmitSafe: progress.resubmitSafe === true
|
|
57893
57941
|
}, cause);
|
|
57894
57942
|
}
|
|
@@ -57899,8 +57947,8 @@ var init_skill_local_flow = __esm({
|
|
|
57899
57947
|
async publishVersion(path2, plan, context) {
|
|
57900
57948
|
return this.publication((progress) => this.publishVersionWithProgress(path2, plan, context, progress));
|
|
57901
57949
|
}
|
|
57902
|
-
async recoverPublication(
|
|
57903
|
-
return this.publication((progress) => this.recoverWithProgress(
|
|
57950
|
+
async recoverPublication(fingerprint, context) {
|
|
57951
|
+
return this.publication((progress) => this.recoverWithProgress(fingerprint, context, progress));
|
|
57904
57952
|
}
|
|
57905
57953
|
async send(context, action, request2, prepared, authority, onBroadcast) {
|
|
57906
57954
|
return required2(this.sender.submitPrepared, "Skill prepared-intent sender").call(this.sender, {
|
|
@@ -58049,27 +58097,27 @@ var init_skill_local_flow = __esm({
|
|
|
58049
58097
|
async verify(context, action, request2, receipt) {
|
|
58050
58098
|
return required2(this.sender.verifyPrepared, "Skill transaction verifier").call(this.sender, { privateKey: context.privateKey, walletAddress: context.walletAddress, action, request: request2, ...receipt });
|
|
58051
58099
|
}
|
|
58052
|
-
async save(
|
|
58053
|
-
await required2(this.recovery, "Skill publication recovery").saveSkillPublicationRecovery(
|
|
58100
|
+
async save(fingerprint, journal) {
|
|
58101
|
+
await required2(this.recovery, "Skill publication recovery").saveSkillPublicationRecovery(fingerprint, journal);
|
|
58054
58102
|
}
|
|
58055
|
-
async project(chainId, transactionHash3, bearer, intentId, stage) {
|
|
58103
|
+
async project(chainId, transactionHash3, bearer, intentId, stage, requireReady = true) {
|
|
58056
58104
|
if (intentId === void 0 && this.api.confirmSkillProjection === void 0) return;
|
|
58057
58105
|
const status = await required2(this.api.confirmSkillProjection, "Skill projection confirmation").call(this.api, chainId, transactionHash3, bearer, intentId, stage);
|
|
58058
|
-
if (intentId !== void 0 && status !== "projected") throw new TypeError("Skill projection is pending. Resume the saved Skill recovery.");
|
|
58106
|
+
if (requireReady && intentId !== void 0 && status !== "projected") throw new TypeError("The Skill transaction is confirmed; presentation projection is pending. Resume the saved Skill recovery to retry projection without sending another transaction.");
|
|
58059
58107
|
}
|
|
58060
|
-
async stage(progress, context,
|
|
58108
|
+
async stage(progress, context, fingerprint, journal, stage, action, request2, prepare) {
|
|
58061
58109
|
progress.journal = journal;
|
|
58062
|
-
progress.fingerprint =
|
|
58110
|
+
progress.fingerprint = fingerprint;
|
|
58063
58111
|
progress.journalSaved = true;
|
|
58064
58112
|
progress.phase = "transaction";
|
|
58065
58113
|
const existing = journal.receipts[stage];
|
|
58066
58114
|
if (existing !== null) {
|
|
58067
58115
|
journal.receipts[stage] = context.intentId !== void 0 && existing.blockNumber !== null ? existing : await this.verify(context, action, request2, existing);
|
|
58068
58116
|
if (journal.pendingStage === stage) journal.pendingStage = null;
|
|
58069
|
-
await this.save(
|
|
58117
|
+
await this.save(fingerprint, journal);
|
|
58070
58118
|
progress.uncertain = false;
|
|
58071
58119
|
progress.phase = "projection";
|
|
58072
|
-
await this.project(journal.chainId, journal.receipts[stage].transactionHash, context.bearer, context.intentId, stage);
|
|
58120
|
+
await this.project(journal.chainId, journal.receipts[stage].transactionHash, context.bearer, context.intentId, stage, journal.kind !== "version" || stage !== "primary");
|
|
58073
58121
|
return;
|
|
58074
58122
|
}
|
|
58075
58123
|
if ((stage !== "uri" || context.intentId !== void 0) && (journal.pendingStage != null || journal.version !== 6)) {
|
|
@@ -58088,7 +58136,7 @@ var init_skill_local_flow = __esm({
|
|
|
58088
58136
|
const marks = journal.version === 6;
|
|
58089
58137
|
if (marks) {
|
|
58090
58138
|
journal.pendingStage = stage;
|
|
58091
|
-
await this.save(
|
|
58139
|
+
await this.save(fingerprint, journal);
|
|
58092
58140
|
}
|
|
58093
58141
|
progress.uncertain = true;
|
|
58094
58142
|
journal.receipts[stage] = await this.send(
|
|
@@ -58099,29 +58147,29 @@ var init_skill_local_flow = __esm({
|
|
|
58099
58147
|
journal.signingAuthority,
|
|
58100
58148
|
async ({ transactionHash: transactionHash3 }) => {
|
|
58101
58149
|
journal.receipts[stage] = { transactionHash: transactionHash3, blockNumber: null };
|
|
58102
|
-
await this.save(
|
|
58150
|
+
await this.save(fingerprint, journal);
|
|
58103
58151
|
if (marks) {
|
|
58104
58152
|
journal.pendingStage = null;
|
|
58105
|
-
await this.save(
|
|
58153
|
+
await this.save(fingerprint, journal);
|
|
58106
58154
|
}
|
|
58107
58155
|
progress.uncertain = false;
|
|
58108
58156
|
}
|
|
58109
58157
|
);
|
|
58110
58158
|
if (marks) journal.pendingStage = null;
|
|
58111
|
-
await this.save(
|
|
58159
|
+
await this.save(fingerprint, journal);
|
|
58112
58160
|
progress.uncertain = false;
|
|
58113
58161
|
progress.phase = "projection";
|
|
58114
|
-
await this.project(journal.chainId, journal.receipts[stage].transactionHash, context.bearer, context.intentId, stage);
|
|
58162
|
+
await this.project(journal.chainId, journal.receipts[stage].transactionHash, context.bearer, context.intentId, stage, journal.kind !== "version" || stage !== "primary");
|
|
58115
58163
|
}
|
|
58116
|
-
async recoverWithProgress(
|
|
58164
|
+
async recoverWithProgress(fingerprint, context, progress) {
|
|
58117
58165
|
progress.phase = "recovery";
|
|
58118
|
-
if (!/^[0-9a-f]{64}$/u.test(
|
|
58166
|
+
if (!/^[0-9a-f]{64}$/u.test(fingerprint)) throw new TypeError("Skill publication recovery fingerprint is invalid.");
|
|
58119
58167
|
const store = required2(this.recovery, "Skill publication recovery");
|
|
58120
|
-
const stored = await store.readSkillPublicationRecovery(
|
|
58168
|
+
const stored = await store.readSkillPublicationRecovery(fingerprint);
|
|
58121
58169
|
if (stored === null) throw new TypeError("Skill publication recovery was not found.");
|
|
58122
58170
|
const candidate = object2(stored, "Skill publication recovery");
|
|
58123
58171
|
if (candidate.kind !== "publish" && candidate.kind !== "version") throw new TypeError("Skill publication recovery kind is invalid.");
|
|
58124
|
-
const journal = recoveryJournal(stored,
|
|
58172
|
+
const journal = recoveryJournal(stored, fingerprint, candidate.kind, context);
|
|
58125
58173
|
if (journal.intentId !== void 0) {
|
|
58126
58174
|
const owned = object2(await required2(this.api.getSkillSigningIntent, "Skill wallet intent API").call(this.api, journal.intentId, context.bearer), "Skill wallet intent");
|
|
58127
58175
|
if (owned.intentId !== journal.intentId || owned.origin !== context.origin || owned.kind !== journal.kind) throw new TypeError("Skill recovery intent does not match its endpoint or action.");
|
|
@@ -58129,13 +58177,13 @@ var init_skill_local_flow = __esm({
|
|
|
58129
58177
|
context = { ...context, intentId: journal.intentId };
|
|
58130
58178
|
}
|
|
58131
58179
|
progress.journal = journal;
|
|
58132
|
-
progress.fingerprint =
|
|
58180
|
+
progress.fingerprint = fingerprint;
|
|
58133
58181
|
progress.journalSaved = true;
|
|
58134
58182
|
if (journal.kind === "publish") {
|
|
58135
58183
|
await this.stage(
|
|
58136
58184
|
progress,
|
|
58137
58185
|
context,
|
|
58138
|
-
|
|
58186
|
+
fingerprint,
|
|
58139
58187
|
journal,
|
|
58140
58188
|
"primary",
|
|
58141
58189
|
"createSkill",
|
|
@@ -58168,13 +58216,13 @@ var init_skill_local_flow = __esm({
|
|
|
58168
58216
|
journal.contentMode,
|
|
58169
58217
|
required2(journal.contentKey, "Skill recovery content key")
|
|
58170
58218
|
);
|
|
58171
|
-
await this.save(
|
|
58219
|
+
await this.save(fingerprint, journal);
|
|
58172
58220
|
}
|
|
58173
58221
|
const litRequest = required2(journal.requests.lit, "Skill Lit recovery request");
|
|
58174
58222
|
await this.stage(
|
|
58175
58223
|
progress,
|
|
58176
58224
|
context,
|
|
58177
|
-
|
|
58225
|
+
fingerprint,
|
|
58178
58226
|
journal,
|
|
58179
58227
|
"lit",
|
|
58180
58228
|
"setLitData",
|
|
@@ -58183,7 +58231,7 @@ var init_skill_local_flow = __esm({
|
|
|
58183
58231
|
);
|
|
58184
58232
|
}
|
|
58185
58233
|
progress.phase = "cleanup";
|
|
58186
|
-
await store.clearSkillPublicationRecovery(
|
|
58234
|
+
await store.clearSkillPublicationRecovery(fingerprint);
|
|
58187
58235
|
return {
|
|
58188
58236
|
chainId: journal.chainId,
|
|
58189
58237
|
skillId: skillId2,
|
|
@@ -58203,7 +58251,7 @@ var init_skill_local_flow = __esm({
|
|
|
58203
58251
|
await this.stage(
|
|
58204
58252
|
progress,
|
|
58205
58253
|
context,
|
|
58206
|
-
|
|
58254
|
+
fingerprint,
|
|
58207
58255
|
journal,
|
|
58208
58256
|
"primary",
|
|
58209
58257
|
"updateSkill",
|
|
@@ -58224,7 +58272,7 @@ var init_skill_local_flow = __esm({
|
|
|
58224
58272
|
await this.stage(
|
|
58225
58273
|
progress,
|
|
58226
58274
|
context,
|
|
58227
|
-
|
|
58275
|
+
fingerprint,
|
|
58228
58276
|
journal,
|
|
58229
58277
|
"uri",
|
|
58230
58278
|
"setSkillURI",
|
|
@@ -58242,13 +58290,13 @@ var init_skill_local_flow = __esm({
|
|
|
58242
58290
|
journal.contentMode,
|
|
58243
58291
|
required2(journal.contentKey, "Skill recovery content key")
|
|
58244
58292
|
);
|
|
58245
|
-
await this.save(
|
|
58293
|
+
await this.save(fingerprint, journal);
|
|
58246
58294
|
}
|
|
58247
58295
|
const litRequest = required2(journal.requests.lit, "Skill Lit recovery request");
|
|
58248
58296
|
await this.stage(
|
|
58249
58297
|
progress,
|
|
58250
58298
|
context,
|
|
58251
|
-
|
|
58299
|
+
fingerprint,
|
|
58252
58300
|
journal,
|
|
58253
58301
|
"lit",
|
|
58254
58302
|
"setLitData",
|
|
@@ -58257,7 +58305,7 @@ var init_skill_local_flow = __esm({
|
|
|
58257
58305
|
);
|
|
58258
58306
|
}
|
|
58259
58307
|
progress.phase = "cleanup";
|
|
58260
|
-
await store.clearSkillPublicationRecovery(
|
|
58308
|
+
await store.clearSkillPublicationRecovery(fingerprint);
|
|
58261
58309
|
return {
|
|
58262
58310
|
chainId: journal.chainId,
|
|
58263
58311
|
skillId,
|
|
@@ -58277,13 +58325,13 @@ var init_skill_local_flow = __esm({
|
|
|
58277
58325
|
async publishWithProgress(path2, planValue, context, progress) {
|
|
58278
58326
|
const plan = publishPlan(planValue, context);
|
|
58279
58327
|
const request2 = plan.request;
|
|
58280
|
-
const
|
|
58328
|
+
const fingerprint = recoveryFingerprint("publish", planValue, context.walletAddress, context.intentId);
|
|
58281
58329
|
const store = required2(this.recovery, "Skill publication recovery");
|
|
58282
58330
|
progress.phase = "recovery";
|
|
58283
|
-
const prior = await store.readSkillPublicationRecovery(
|
|
58331
|
+
const prior = await store.readSkillPublicationRecovery(fingerprint);
|
|
58284
58332
|
if (prior !== null) {
|
|
58285
|
-
progress.journal = recoveryJournal(prior,
|
|
58286
|
-
progress.fingerprint =
|
|
58333
|
+
progress.journal = recoveryJournal(prior, fingerprint, "publish", context);
|
|
58334
|
+
progress.fingerprint = fingerprint;
|
|
58287
58335
|
progress.journalSaved = true;
|
|
58288
58336
|
}
|
|
58289
58337
|
progress.phase = "source";
|
|
@@ -58295,7 +58343,7 @@ var init_skill_local_flow = __esm({
|
|
|
58295
58343
|
const packaged = await this.package(selected.files, prior === null ? mode : "plaintext", selected.excluded);
|
|
58296
58344
|
let journal;
|
|
58297
58345
|
if (prior !== null) {
|
|
58298
|
-
journal = recoveryJournal(prior,
|
|
58346
|
+
journal = recoveryJournal(prior, fingerprint, "publish", context);
|
|
58299
58347
|
if (journal.sourceKind !== expectedSourceKind || journal.contentMode !== mode || (journal.sourceHash ?? journal.packageHash).toLowerCase() !== packaged.packageHash.toLowerCase() || canonical(journal.excluded) !== canonical(packaged.excluded)) throw new TypeError("Skill publication content no longer matches its protected recovery.");
|
|
58300
58348
|
} else {
|
|
58301
58349
|
let publishedBytes;
|
|
@@ -58343,7 +58391,7 @@ var init_skill_local_flow = __esm({
|
|
|
58343
58391
|
pendingStage: null,
|
|
58344
58392
|
sourceHash: packaged.packageHash,
|
|
58345
58393
|
kind: "publish",
|
|
58346
|
-
fingerprint
|
|
58394
|
+
fingerprint,
|
|
58347
58395
|
walletAddress: context.walletAddress.toLowerCase(),
|
|
58348
58396
|
chainId: plan.chainId,
|
|
58349
58397
|
signingAuthority: plan.signingAuthority,
|
|
@@ -58361,15 +58409,15 @@ var init_skill_local_flow = __esm({
|
|
|
58361
58409
|
receipts: { primary: null, uri: null, lit: null }
|
|
58362
58410
|
};
|
|
58363
58411
|
progress.journal = journal;
|
|
58364
|
-
progress.fingerprint =
|
|
58412
|
+
progress.fingerprint = fingerprint;
|
|
58365
58413
|
progress.phase = "recovery";
|
|
58366
|
-
await this.save(
|
|
58414
|
+
await this.save(fingerprint, journal);
|
|
58367
58415
|
progress.journalSaved = true;
|
|
58368
58416
|
}
|
|
58369
58417
|
await this.stage(
|
|
58370
58418
|
progress,
|
|
58371
58419
|
context,
|
|
58372
|
-
|
|
58420
|
+
fingerprint,
|
|
58373
58421
|
journal,
|
|
58374
58422
|
"primary",
|
|
58375
58423
|
"createSkill",
|
|
@@ -58401,13 +58449,13 @@ var init_skill_local_flow = __esm({
|
|
|
58401
58449
|
journal.contentMode,
|
|
58402
58450
|
required2(journal.contentKey, "Skill recovery content key")
|
|
58403
58451
|
);
|
|
58404
|
-
await this.save(
|
|
58452
|
+
await this.save(fingerprint, journal);
|
|
58405
58453
|
}
|
|
58406
58454
|
const litRequest = required2(journal.requests.lit, "Skill Lit recovery request");
|
|
58407
58455
|
await this.stage(
|
|
58408
58456
|
progress,
|
|
58409
58457
|
context,
|
|
58410
|
-
|
|
58458
|
+
fingerprint,
|
|
58411
58459
|
journal,
|
|
58412
58460
|
"lit",
|
|
58413
58461
|
"setLitData",
|
|
@@ -58416,18 +58464,18 @@ var init_skill_local_flow = __esm({
|
|
|
58416
58464
|
);
|
|
58417
58465
|
}
|
|
58418
58466
|
progress.phase = "cleanup";
|
|
58419
|
-
await store.clearSkillPublicationRecovery(
|
|
58467
|
+
await store.clearSkillPublicationRecovery(fingerprint);
|
|
58420
58468
|
return { chainId: journal.chainId, skillId, version: 1, contentMode: journal.contentMode, packageHash: journal.packageHash, excluded: journal.excluded, transactions: { create: required2(journal.receipts.primary, "Skill create receipt").transactionHash, ...journal.contentMode === "plaintext" ? {} : { setLitData: required2(journal.receipts.lit, "Skill Lit receipt").transactionHash } } };
|
|
58421
58469
|
}
|
|
58422
58470
|
async publishVersionWithProgress(path2, planValue, context, progress) {
|
|
58423
58471
|
const plan = versionPlan(planValue, context);
|
|
58424
|
-
const
|
|
58472
|
+
const fingerprint = recoveryFingerprint("version", planValue, context.walletAddress, context.intentId);
|
|
58425
58473
|
progress.phase = "recovery";
|
|
58426
58474
|
const store = required2(this.recovery, "Skill publication recovery");
|
|
58427
|
-
const prior = await store.readSkillPublicationRecovery(
|
|
58475
|
+
const prior = await store.readSkillPublicationRecovery(fingerprint);
|
|
58428
58476
|
if (prior !== null) {
|
|
58429
|
-
progress.journal = recoveryJournal(prior,
|
|
58430
|
-
progress.fingerprint =
|
|
58477
|
+
progress.journal = recoveryJournal(prior, fingerprint, "version", context);
|
|
58478
|
+
progress.fingerprint = fingerprint;
|
|
58431
58479
|
progress.journalSaved = true;
|
|
58432
58480
|
}
|
|
58433
58481
|
const observedVersion = await required2(this.api.readSkillCurrentVersion, "Skill version API").call(
|
|
@@ -58447,7 +58495,7 @@ var init_skill_local_flow = __esm({
|
|
|
58447
58495
|
const packaged = await this.package(selected.files, prior === null ? plan.contentMode : "plaintext", selected.excluded);
|
|
58448
58496
|
let journal;
|
|
58449
58497
|
if (prior !== null) {
|
|
58450
|
-
journal = recoveryJournal(prior,
|
|
58498
|
+
journal = recoveryJournal(prior, fingerprint, "version", context);
|
|
58451
58499
|
if (journal.sourceKind !== plan.sourceKind || journal.contentMode !== plan.contentMode || (journal.sourceHash ?? journal.packageHash).toLowerCase() !== packaged.packageHash.toLowerCase() || canonical(journal.excluded) !== canonical(packaged.excluded)) throw new TypeError("Skill publication content no longer matches its protected recovery.");
|
|
58452
58500
|
} else {
|
|
58453
58501
|
const currentBytes = await required2(this.api.fetchSkillStoredContent, "Skill content relay").call(this.api, plan.currentPackageURI, context.bearer);
|
|
@@ -58490,7 +58538,7 @@ var init_skill_local_flow = __esm({
|
|
|
58490
58538
|
pendingStage: null,
|
|
58491
58539
|
sourceHash: packaged.packageHash,
|
|
58492
58540
|
kind: "version",
|
|
58493
|
-
fingerprint
|
|
58541
|
+
fingerprint,
|
|
58494
58542
|
walletAddress: context.walletAddress.toLowerCase(),
|
|
58495
58543
|
chainId: plan.chainId,
|
|
58496
58544
|
signingAuthority: plan.signingAuthority,
|
|
@@ -58508,15 +58556,15 @@ var init_skill_local_flow = __esm({
|
|
|
58508
58556
|
receipts: { primary: null, uri: null, lit: null }
|
|
58509
58557
|
};
|
|
58510
58558
|
progress.journal = journal;
|
|
58511
|
-
progress.fingerprint =
|
|
58559
|
+
progress.fingerprint = fingerprint;
|
|
58512
58560
|
progress.phase = "recovery";
|
|
58513
|
-
await this.save(
|
|
58561
|
+
await this.save(fingerprint, journal);
|
|
58514
58562
|
progress.journalSaved = true;
|
|
58515
58563
|
}
|
|
58516
58564
|
await this.stage(
|
|
58517
58565
|
progress,
|
|
58518
58566
|
context,
|
|
58519
|
-
|
|
58567
|
+
fingerprint,
|
|
58520
58568
|
journal,
|
|
58521
58569
|
"primary",
|
|
58522
58570
|
"updateSkill",
|
|
@@ -58534,7 +58582,7 @@ var init_skill_local_flow = __esm({
|
|
|
58534
58582
|
await this.stage(
|
|
58535
58583
|
progress,
|
|
58536
58584
|
context,
|
|
58537
|
-
|
|
58585
|
+
fingerprint,
|
|
58538
58586
|
journal,
|
|
58539
58587
|
"uri",
|
|
58540
58588
|
"setSkillURI",
|
|
@@ -58552,13 +58600,13 @@ var init_skill_local_flow = __esm({
|
|
|
58552
58600
|
journal.contentMode,
|
|
58553
58601
|
required2(journal.contentKey, "Skill recovery content key")
|
|
58554
58602
|
);
|
|
58555
|
-
await this.save(
|
|
58603
|
+
await this.save(fingerprint, journal);
|
|
58556
58604
|
}
|
|
58557
58605
|
const litRequest = required2(journal.requests.lit, "Skill Lit recovery request");
|
|
58558
58606
|
await this.stage(
|
|
58559
58607
|
progress,
|
|
58560
58608
|
context,
|
|
58561
|
-
|
|
58609
|
+
fingerprint,
|
|
58562
58610
|
journal,
|
|
58563
58611
|
"lit",
|
|
58564
58612
|
"setLitData",
|
|
@@ -58567,7 +58615,7 @@ var init_skill_local_flow = __esm({
|
|
|
58567
58615
|
);
|
|
58568
58616
|
}
|
|
58569
58617
|
progress.phase = "cleanup";
|
|
58570
|
-
await store.clearSkillPublicationRecovery(
|
|
58618
|
+
await store.clearSkillPublicationRecovery(fingerprint);
|
|
58571
58619
|
return { chainId: journal.chainId, skillId: plan.request.skillId, version: plan.nextVersion, contentMode: journal.contentMode, packageHash: journal.packageHash, excluded: journal.excluded, transactions: { update: required2(journal.receipts.primary, "Skill update receipt").transactionHash, setSkillURI: required2(journal.receipts.uri, "Skill URI receipt").transactionHash, ...journal.contentMode === "plaintext" ? {} : { setLitData: required2(journal.receipts.lit, "Skill Lit receipt").transactionHash } } };
|
|
58572
58620
|
}
|
|
58573
58621
|
async manage(kind, planValue, context) {
|
|
@@ -58577,68 +58625,11 @@ var init_skill_local_flow = __esm({
|
|
|
58577
58625
|
await this.project(plan.chainId, submission.transactionHash, context.bearer, context.intentId);
|
|
58578
58626
|
return { ...submission, chainId: plan.chainId, skillId: plan.request.skillId, kind };
|
|
58579
58627
|
}
|
|
58580
|
-
/**
|
|
58581
|
-
|
|
58582
|
-
|
|
58583
|
-
|
|
58584
|
-
|
|
58585
|
-
* through the caller before receipt waiting; legacy callers retain the convergent URI retry.
|
|
58586
|
-
*/
|
|
58587
|
-
async publishPresentation(planValue, context) {
|
|
58588
|
-
return this.publication((progress) => this.publishPresentationWithProgress(planValue, context, progress));
|
|
58589
|
-
}
|
|
58590
|
-
async publishPresentationWithProgress(planValue, context, progress) {
|
|
58591
|
-
const plan = presentationPlan(planValue, context.walletAddress);
|
|
58592
|
-
progress.resubmitSafe = true;
|
|
58593
|
-
const liveVersion = await required2(this.api.readSkillCurrentVersion, "Skill version API").call(this.api, plan.chainId, plan.skillId, context.bearer, context.intentId);
|
|
58594
|
-
if (liveVersion !== plan.currentVersion) {
|
|
58595
|
-
throw new CliSkillPresentationStaleError("version_moved", plan.currentVersion, liveVersion);
|
|
58596
|
-
}
|
|
58597
|
-
const currentBytes = await required2(this.api.fetchSkillStoredContent, "Skill content relay").call(this.api, plan.currentManifestURI, context.bearer);
|
|
58598
|
-
const currentManifest = parseManifest2(currentBytes);
|
|
58599
|
-
if (currentManifest === null) {
|
|
58600
|
-
throw new CliSkillPresentationStaleError("manifest_unreadable", plan.currentVersion, liveVersion);
|
|
58601
|
-
}
|
|
58602
|
-
progress.phase = "upload";
|
|
58603
|
-
const manifestURI = await this.upload({
|
|
58604
|
-
bytes: serializeManifest(withPresentation(currentManifest, plan.presentation)),
|
|
58605
|
-
filename: `skill-${plan.skillId}.versions.json`,
|
|
58606
|
-
bearer: context.bearer,
|
|
58607
|
-
objectKind: "manifest"
|
|
58608
|
-
});
|
|
58609
|
-
const request2 = { action: "setSkillURI", chainId: plan.chainId, skillId: plan.skillId, packageURI: manifestURI };
|
|
58610
|
-
progress.phase = "intent";
|
|
58611
|
-
const prepared = await required2(this.api.requestSkillIntent, "Skill intent API").call(this.api, request2, context.bearer, context.intentId);
|
|
58612
|
-
const resumed = await context.resumePrepared?.(request2, object2(prepared, "Skill presentation intent"));
|
|
58613
|
-
if (resumed) {
|
|
58614
|
-
await this.project(plan.chainId, resumed.transactionHash, context.bearer, context.intentId);
|
|
58615
|
-
return { ...resumed, chainId: plan.chainId, skillId: plan.skillId, currentVersion: plan.currentVersion, manifestURI };
|
|
58616
|
-
}
|
|
58617
|
-
progress.phase = "transaction";
|
|
58618
|
-
progress.uncertain = true;
|
|
58619
|
-
const submission = await this.send(
|
|
58620
|
-
context,
|
|
58621
|
-
"setSkillURI",
|
|
58622
|
-
request2,
|
|
58623
|
-
prepared,
|
|
58624
|
-
plan.signingAuthority,
|
|
58625
|
-
async ({ transactionHash: transactionHash3 }) => {
|
|
58626
|
-
progress.broadcast = { setSkillURI: transactionHash3 };
|
|
58627
|
-
const fingerprint2 = await context.onBroadcast?.({ request: request2, intent: object2(prepared, "Skill presentation intent"), transactionHash: transactionHash3 });
|
|
58628
|
-
if (fingerprint2) {
|
|
58629
|
-
progress.walletFingerprint = fingerprint2;
|
|
58630
|
-
progress.journalSaved = true;
|
|
58631
|
-
progress.resubmitSafe = false;
|
|
58632
|
-
}
|
|
58633
|
-
progress.uncertain = false;
|
|
58634
|
-
}
|
|
58635
|
-
);
|
|
58636
|
-
await context.onReceipt?.(submission.blockNumber);
|
|
58637
|
-
progress.broadcast = { setSkillURI: submission.transactionHash };
|
|
58638
|
-
progress.uncertain = false;
|
|
58639
|
-
progress.phase = "projection";
|
|
58640
|
-
await this.project(plan.chainId, submission.transactionHash, context.bearer, context.intentId);
|
|
58641
|
-
return { ...submission, chainId: plan.chainId, skillId: plan.skillId, currentVersion: plan.currentVersion, manifestURI };
|
|
58628
|
+
/** Retained only to give installed callers an explicit upgrade instruction before any I/O. */
|
|
58629
|
+
async publishPresentation(_planValue, _context) {
|
|
58630
|
+
void _planValue;
|
|
58631
|
+
void _context;
|
|
58632
|
+
throw new TypeError("SKILL_PRESENTATION_FLOW_REMOVED: Use skill_market_presentation_update through Remote MCP.");
|
|
58642
58633
|
}
|
|
58643
58634
|
async uploadCover(path2, planValue, context) {
|
|
58644
58635
|
const plan = assetPlan(planValue, context.walletAddress);
|
|
@@ -58672,12 +58663,12 @@ var init_skill_local_flow = __esm({
|
|
|
58672
58663
|
const plan = deliveryPlan(planValue, context);
|
|
58673
58664
|
if (!context) throw new TypeError("Sign in with Finch CLI before downloading Skills.");
|
|
58674
58665
|
const located = await this.fetchDeliveryContent(plan.packageURI, context?.bearer);
|
|
58675
|
-
const
|
|
58666
|
+
const manifest6 = parseManifest2(located);
|
|
58676
58667
|
let stored = located;
|
|
58677
58668
|
const expectedHash = plan.packageHash;
|
|
58678
|
-
const root =
|
|
58679
|
-
if (
|
|
58680
|
-
const entry2 = packageForVersion(
|
|
58669
|
+
const root = manifest6 === null ? void 0 : packageForVersion(manifest6, plan.version)?.skillRoot;
|
|
58670
|
+
if (manifest6 !== null) {
|
|
58671
|
+
const entry2 = packageForVersion(manifest6, plan.version);
|
|
58681
58672
|
if (entry2 === null) throw new TypeError(`Skill manifest does not list version ${plan.version}.`);
|
|
58682
58673
|
if (entry2.packageHash.toLowerCase() !== plan.packageHash.toLowerCase()) throw new TypeError("Skill manifest package hash does not match chain authority.");
|
|
58683
58674
|
stored = await this.fetchDeliveryContent(entry2.packageURI, context?.bearer);
|
|
@@ -58943,6 +58934,26 @@ var init_loopback_callback = __esm({
|
|
|
58943
58934
|
import { createHash as createHash3, randomUUID } from "node:crypto";
|
|
58944
58935
|
import { isDeepStrictEqual } from "node:util";
|
|
58945
58936
|
import { open as open2 } from "node:fs/promises";
|
|
58937
|
+
function transportErrorCode(error51) {
|
|
58938
|
+
let current = error51.cause;
|
|
58939
|
+
for (let depth = 0; depth < 4 && current instanceof Error; depth += 1) {
|
|
58940
|
+
if (current.name === "TimeoutError") return "TIMEOUT";
|
|
58941
|
+
const code = current.code;
|
|
58942
|
+
if (typeof code === "string" && /^[A-Z][A-Z0-9_]{1,63}$/u.test(code)) return code;
|
|
58943
|
+
current = current.cause;
|
|
58944
|
+
}
|
|
58945
|
+
return null;
|
|
58946
|
+
}
|
|
58947
|
+
function httpFailureCheck(cause, status, guidance) {
|
|
58948
|
+
if (cause.status !== null) return { status, message: guidance, httpStatus: cause.status };
|
|
58949
|
+
const networkErrorCode = transportErrorCode(cause);
|
|
58950
|
+
if (networkErrorCode === null) return { status, message: `No HTTP response was received. ${guidance}` };
|
|
58951
|
+
return {
|
|
58952
|
+
status,
|
|
58953
|
+
message: TLS_ERROR_CODE.test(networkErrorCode) ? `TLS certificate verification failed. If a proxy, VPN or security software intercepts HTTPS on this machine, make Node.js trust its certificate authority, for example with NODE_EXTRA_CA_CERTS. ${guidance}` : `No HTTP response was received. ${guidance}`,
|
|
58954
|
+
networkErrorCode
|
|
58955
|
+
};
|
|
58956
|
+
}
|
|
58946
58957
|
function required3(value, name) {
|
|
58947
58958
|
if (value === void 0) throw new TypeError(`CLI dependency ${name} is unavailable.`);
|
|
58948
58959
|
return value;
|
|
@@ -59089,7 +59100,7 @@ function agentPurchaseAuthority(snapshot, operationId, walletAddress2) {
|
|
|
59089
59100
|
if (snapshot.operationId !== operationId || snapshot.chainId !== String(deployment.chainId) || snapshot.deploymentHash !== deployment.deploymentHash || snapshot.paymentTokenAddress !== deployment.paymentTokenAddress || typeof snapshot.totalPaidAtomic !== "string" || !/^[1-9][0-9]{0,77}$/u.test(snapshot.totalPaidAtomic) || typeof approval.spender !== "string" || approval.spender !== deployment.vaultAddress || approval.amountAtomic !== snapshot.totalPaidAtomic || approvalTransaction.to !== snapshot.paymentTokenAddress || revokeApprovalTransaction.to !== snapshot.paymentTokenAddress || purchaseTransaction.to !== approval.spender || confirmation.contractAddress !== approval.spender || confirmation.eventName !== "PurchaseConfirmed" || confirmation.minimumConfirmations !== deployment.confirmations || typeof snapshot.confirmationDeadlineAt !== "string" || Date.parse(snapshot.confirmationDeadlineAt) <= Date.now() || typeof approvalTransaction.data !== "string" || typeof revokeApprovalTransaction.data !== "string" || typeof purchaseTransaction.data !== "string" || approvalTransaction.value !== "0" || revokeApprovalTransaction.value !== "0" || purchaseTransaction.value !== "0") {
|
|
59090
59101
|
throw new TypeError("The Agent purchase transaction authority is invalid or expired.");
|
|
59091
59102
|
}
|
|
59092
|
-
const
|
|
59103
|
+
const fingerprint = createHash3("sha256").update(JSON.stringify([
|
|
59093
59104
|
"finch.cli.agent_purchase_recovery.v2",
|
|
59094
59105
|
operationId,
|
|
59095
59106
|
walletAddress2,
|
|
@@ -59114,7 +59125,7 @@ function agentPurchaseAuthority(snapshot, operationId, walletAddress2) {
|
|
|
59114
59125
|
confirmation.minimumConfirmations
|
|
59115
59126
|
]), "utf8").digest("hex");
|
|
59116
59127
|
return Object.freeze({
|
|
59117
|
-
fingerprint
|
|
59128
|
+
fingerprint,
|
|
59118
59129
|
chainId: deployment.chainId,
|
|
59119
59130
|
deploymentHash: deployment.deploymentHash,
|
|
59120
59131
|
confirmations: deployment.confirmations,
|
|
@@ -59210,7 +59221,7 @@ function parseTaskRecoveryJournal(value, expected) {
|
|
|
59210
59221
|
idempotencyKey: journal.idempotencyKey
|
|
59211
59222
|
});
|
|
59212
59223
|
}
|
|
59213
|
-
var MAXIMUM_STDIN_AUTHORIZATION_BYTES, FinchCliApplication;
|
|
59224
|
+
var MAXIMUM_STDIN_AUTHORIZATION_BYTES, TLS_ERROR_CODE, FinchCliApplication;
|
|
59214
59225
|
var init_application = __esm({
|
|
59215
59226
|
"src/application.ts"() {
|
|
59216
59227
|
"use strict";
|
|
@@ -59227,6 +59238,7 @@ var init_application = __esm({
|
|
|
59227
59238
|
init_cli_error();
|
|
59228
59239
|
init_loopback_callback();
|
|
59229
59240
|
MAXIMUM_STDIN_AUTHORIZATION_BYTES = 4098;
|
|
59241
|
+
TLS_ERROR_CODE = /CERT|SSL|TLS|SELF_SIGNED/u;
|
|
59230
59242
|
FinchCliApplication = class {
|
|
59231
59243
|
api;
|
|
59232
59244
|
state;
|
|
@@ -59526,6 +59538,12 @@ var init_application = __esm({
|
|
|
59526
59538
|
await required3(this.state.saveWallet, "state.saveWallet").call(this.state, { walletAddress: walletAddress2, privateKey: privateKey3 });
|
|
59527
59539
|
return Object.freeze({ walletAddress: walletAddress2 });
|
|
59528
59540
|
}
|
|
59541
|
+
async listWallets() {
|
|
59542
|
+
const walletAddresses = await required3(this.state.listWalletAddresses, "state.listWalletAddresses").call(this.state);
|
|
59543
|
+
if (walletAddresses.length === 0) return Object.freeze({ currentWalletAddress: null, walletAddresses });
|
|
59544
|
+
const current = await required3(this.state.readWalletAddress, "state.readWalletAddress").call(this.state);
|
|
59545
|
+
return Object.freeze({ currentWalletAddress: current.walletAddress, walletAddresses });
|
|
59546
|
+
}
|
|
59529
59547
|
async showWallet() {
|
|
59530
59548
|
const wallet = await required3(this.state.readWalletAddress, "state.readWalletAddress").call(this.state);
|
|
59531
59549
|
return Object.freeze({ walletAddress: wallet.walletAddress });
|
|
@@ -59607,7 +59625,7 @@ var init_application = __esm({
|
|
|
59607
59625
|
}];
|
|
59608
59626
|
} else if (cause instanceof CliHttpError) {
|
|
59609
59627
|
const unavailable = cause.status === 429 || cause.status !== null && cause.status >= 500;
|
|
59610
|
-
return [null,
|
|
59628
|
+
return [null, httpFailureCheck(cause, !unavailable && (cause.status === 401 || cause.status === 403 || cause.code === "CLI_RESPONSE_INVALID") ? "invalid" : "unavailable", guidance)];
|
|
59611
59629
|
} else if (cause instanceof TypeError || cause instanceof CliAuthorityError) {
|
|
59612
59630
|
return [null, { status: "invalid", message: guidance }];
|
|
59613
59631
|
} else {
|
|
@@ -59625,7 +59643,7 @@ var init_application = __esm({
|
|
|
59625
59643
|
);
|
|
59626
59644
|
const [session, sessionCheck] = await inspect(
|
|
59627
59645
|
() => required3(this.state.readSession, "state.readSession").call(this.state),
|
|
59628
|
-
"Run finch
|
|
59646
|
+
"Run finch login --help for supported authentication chains, then finch login --chain-id <CHAIN_ID>."
|
|
59629
59647
|
);
|
|
59630
59648
|
let remoteSession = null;
|
|
59631
59649
|
let remoteSessionCheck;
|
|
@@ -59637,7 +59655,7 @@ var init_application = __esm({
|
|
|
59637
59655
|
const remote = asObject(await required3(this.api.getSession, "api.getSession").call(this.api, session.rawBearer, AbortSignal.timeout(15e3)), "MCP doctor Session");
|
|
59638
59656
|
if (remote.sessionId !== session.sessionId || remote.accountId !== session.accountId || remote.walletAddress !== session.walletAddress || remote.environment !== session.environment || remote.audience !== "agent_cli" || typeof remote.sessionExpiresAt !== "string" || !Number.isFinite(Date.parse(remote.sessionExpiresAt)) || Date.parse(remote.sessionExpiresAt) <= Date.now()) throw new CliAuthorityError();
|
|
59639
59657
|
return { sessionExpiresAt: remote.sessionExpiresAt };
|
|
59640
|
-
},
|
|
59658
|
+
}, `Verify the endpoint and current wallet. If the CLI Session is invalid or expired, run finch login --chain-id ${session.loginChainId} using the same wallet and endpoint. If the server is unavailable, retry later.`);
|
|
59641
59659
|
} else {
|
|
59642
59660
|
remoteSessionCheck = { status: "skipped", message: "Requires a valid endpoint, local wallet, and CLI Session." };
|
|
59643
59661
|
}
|
|
@@ -59681,12 +59699,6 @@ var init_application = __esm({
|
|
|
59681
59699
|
...mcp === null ? {} : { mcp }
|
|
59682
59700
|
});
|
|
59683
59701
|
}
|
|
59684
|
-
async assertNoBlockingRecoveries() {
|
|
59685
|
-
const recoveries = await this.state.listBlockingRecoveries?.call(this.state) ?? [];
|
|
59686
|
-
if (recoveries.length > 0) {
|
|
59687
|
-
throw new CliRecoveryBlockedError(recoveries.map((recovery) => recovery.command));
|
|
59688
|
-
}
|
|
59689
|
-
}
|
|
59690
59702
|
async temporaryLoginBearer(profile, wallet, expectedAccountId, chainId) {
|
|
59691
59703
|
const challenge2 = parseChallenge(await required3(this.api.createChallenge, "api.createChallenge").call(this.api, {
|
|
59692
59704
|
walletAddress: wallet.walletAddress,
|
|
@@ -59724,7 +59736,6 @@ var init_application = __esm({
|
|
|
59724
59736
|
await required3(this.state.removeAuthorization, "state.removeAuthorization").call(this.state);
|
|
59725
59737
|
return Object.freeze({ loggedOut: true, remoteRevoked: false });
|
|
59726
59738
|
}
|
|
59727
|
-
await this.assertNoBlockingRecoveries();
|
|
59728
59739
|
const profile = await this.authorizedProfile();
|
|
59729
59740
|
const session = await this.networkSession(profile);
|
|
59730
59741
|
const wallet = await required3(this.state.readWallet, "state.readWallet").call(this.state);
|
|
@@ -59737,7 +59748,6 @@ var init_application = __esm({
|
|
|
59737
59748
|
if (input.address === void 0 === (input.file === void 0)) {
|
|
59738
59749
|
throw new TypeError("wallet use requires exactly one registered address or --file path.");
|
|
59739
59750
|
}
|
|
59740
|
-
await this.assertNoBlockingRecoveries();
|
|
59741
59751
|
let current;
|
|
59742
59752
|
try {
|
|
59743
59753
|
current = await required3(this.state.readWallet, "state.readWallet").call(this.state);
|
|
@@ -59752,7 +59762,9 @@ var init_application = __esm({
|
|
|
59752
59762
|
if (!/^0x[0-9a-f]{40}$/u.test(target.walletAddress)) throw new TypeError("Wallet address is invalid.");
|
|
59753
59763
|
if (input.file === void 0) {
|
|
59754
59764
|
const wallets = await required3(this.state.listWalletAddresses, "state.listWalletAddresses").call(this.state);
|
|
59755
|
-
if (!wallets.includes(target.walletAddress))
|
|
59765
|
+
if (!wallets.includes(target.walletAddress)) {
|
|
59766
|
+
throw new CliUsageError("Wallet is not registered in FINCHTECH_HOME. Run finch wallet list to see registered wallets, or finch wallet use --file <PATH> to import a private key.");
|
|
59767
|
+
}
|
|
59756
59768
|
}
|
|
59757
59769
|
if (target.walletAddress === current.walletAddress.toLowerCase()) return Object.freeze(target);
|
|
59758
59770
|
if (this.state.readOptionalSession !== void 0 && await this.state.readOptionalSession.call(this.state) === null) {
|
|
@@ -59959,14 +59971,14 @@ var init_application = __esm({
|
|
|
59959
59971
|
const owned = await this.skillWalletIntent(intentFile, expectedKind, session);
|
|
59960
59972
|
const intent2 = { ...owned.preparation, walletIntent: { intentId: owned.intentId, kind: owned.kind } };
|
|
59961
59973
|
assertSigningAuthority(intent2, session);
|
|
59962
|
-
const
|
|
59974
|
+
const fingerprint = skillBuyerIntentFingerprint(intent2);
|
|
59963
59975
|
if (owned.stages.primary?.transactionHash) {
|
|
59964
59976
|
const receipt = await this.confirmSkillWalletResult(owned.intentId, owned.stages.primary.transactionHash, session);
|
|
59965
|
-
if (receipt.status === "projected") await this.state.clearSkillBuyerIntentRecovery?.(
|
|
59977
|
+
if (receipt.status === "projected") await this.state.clearSkillBuyerIntentRecovery?.(fingerprint);
|
|
59966
59978
|
return { ...receipt, chainId: intent2.chainId, skillId: asObject(intent2.request, "Skill request").skillId };
|
|
59967
59979
|
}
|
|
59968
|
-
const prior = await this.state.readSkillBuyerIntentRecovery?.(
|
|
59969
|
-
if (prior !== void 0 && prior !== null) return this.recoverSkill("intent",
|
|
59980
|
+
const prior = await this.state.readSkillBuyerIntentRecovery?.(fingerprint);
|
|
59981
|
+
if (prior !== void 0 && prior !== null) return this.recoverSkill("intent", fingerprint);
|
|
59970
59982
|
const sender = required3(this.skillIntentSender, "skill intent sender");
|
|
59971
59983
|
const checkpoint = {};
|
|
59972
59984
|
const submission = await sender.submit({
|
|
@@ -59975,7 +59987,7 @@ var init_application = __esm({
|
|
|
59975
59987
|
expectedKind,
|
|
59976
59988
|
intent: intent2,
|
|
59977
59989
|
onBroadcast: async (broadcast) => {
|
|
59978
|
-
if (broadcast.fingerprint !==
|
|
59990
|
+
if (broadcast.fingerprint !== fingerprint) {
|
|
59979
59991
|
throw new TypeError("Skill buyer checkpoint fingerprint does not match its OAuth intent.");
|
|
59980
59992
|
}
|
|
59981
59993
|
checkpoint.journal = createSkillBuyerIntentJournal({
|
|
@@ -59991,15 +60003,15 @@ var init_application = __esm({
|
|
|
59991
60003
|
broadcast.transactionHash
|
|
59992
60004
|
)
|
|
59993
60005
|
});
|
|
59994
|
-
await required3(this.state.saveSkillBuyerIntentRecovery, "state.saveSkillBuyerIntentRecovery").call(this.state,
|
|
60006
|
+
await required3(this.state.saveSkillBuyerIntentRecovery, "state.saveSkillBuyerIntentRecovery").call(this.state, fingerprint, checkpoint.journal);
|
|
59995
60007
|
}
|
|
59996
60008
|
});
|
|
59997
60009
|
if (checkpoint.journal === void 0) throw new TypeError("Skill buyer sender did not checkpoint its broadcast.");
|
|
59998
60010
|
const journal = withSkillBuyerIntentReceipt(checkpoint.journal, submission.blockNumber);
|
|
59999
|
-
await required3(this.state.saveSkillBuyerIntentRecovery, "state.saveSkillBuyerIntentRecovery").call(this.state,
|
|
60011
|
+
await required3(this.state.saveSkillBuyerIntentRecovery, "state.saveSkillBuyerIntentRecovery").call(this.state, fingerprint, journal);
|
|
60000
60012
|
const confirmation = await this.confirmSkillWalletResult(owned.intentId, submission.transactionHash, session);
|
|
60001
60013
|
if (confirmation.status === "projected") {
|
|
60002
|
-
await required3(this.state.clearSkillBuyerIntentRecovery, "state.clearSkillBuyerIntentRecovery").call(this.state,
|
|
60014
|
+
await required3(this.state.clearSkillBuyerIntentRecovery, "state.clearSkillBuyerIntentRecovery").call(this.state, fingerprint);
|
|
60003
60015
|
}
|
|
60004
60016
|
return { ...confirmation, transactionHash: submission.transactionHash, blockNumber: submission.blockNumber, chainId: intent2.chainId, skillId: asObject(intent2.request, "Skill request").skillId };
|
|
60005
60017
|
}
|
|
@@ -60008,8 +60020,8 @@ var init_application = __esm({
|
|
|
60008
60020
|
const owned = await this.skillWalletIntent(planFile, "publish", authority.session);
|
|
60009
60021
|
const plan = owned.preparation;
|
|
60010
60022
|
if (owned.stages.primary?.transactionHash) {
|
|
60011
|
-
const
|
|
60012
|
-
const saved = await this.state.readSkillPublicationRecovery?.(
|
|
60023
|
+
const fingerprint = recoveryFingerprint("publish", plan, authority.wallet.walletAddress, owned.intentId);
|
|
60024
|
+
const saved = await this.state.readSkillPublicationRecovery?.(fingerprint);
|
|
60013
60025
|
if (saved == null) {
|
|
60014
60026
|
const stages = ["primary"];
|
|
60015
60027
|
if (asObject(plan.request, "Skill request").contentMode !== "plaintext") stages.push("lit");
|
|
@@ -60040,8 +60052,8 @@ var init_application = __esm({
|
|
|
60040
60052
|
const owned = await this.skillWalletIntent(planFile, "version", authority.session);
|
|
60041
60053
|
const plan = owned.preparation;
|
|
60042
60054
|
if (owned.stages.primary?.transactionHash) {
|
|
60043
|
-
const
|
|
60044
|
-
const saved = await this.state.readSkillPublicationRecovery?.(
|
|
60055
|
+
const fingerprint = recoveryFingerprint("version", plan, authority.wallet.walletAddress, owned.intentId);
|
|
60056
|
+
const saved = await this.state.readSkillPublicationRecovery?.(fingerprint);
|
|
60045
60057
|
if (saved == null) {
|
|
60046
60058
|
const stages = ["primary", "uri"];
|
|
60047
60059
|
if (plan.contentMode !== "plaintext") stages.push("lit");
|
|
@@ -60072,45 +60084,9 @@ var init_application = __esm({
|
|
|
60072
60084
|
const managed = await this.submitSkillIntent(kind === "price" ? "set_unit_price" : "set_max_supply", planFile);
|
|
60073
60085
|
return { ...managed, nextAction: { operationId: "skill_market.skills.get", request: { chainId: managed.chainId, skillId: managed.skillId } } };
|
|
60074
60086
|
}
|
|
60075
|
-
async submitSkillPresentation(
|
|
60076
|
-
|
|
60077
|
-
|
|
60078
|
-
const plan = owned.preparation;
|
|
60079
|
-
assertSigningAuthority(plan, authority.session);
|
|
60080
|
-
if (owned.stages.primary?.transactionHash) return this.confirmSkillWalletResult(owned.intentId, owned.stages.primary.transactionHash, authority.session);
|
|
60081
|
-
let journal;
|
|
60082
|
-
const walletPlan = (request2, intent2) => ({ kind: "presentation", sourceCommit: plan.sourceCommit, walletAddress: plan.walletAddress, signingAuthority: plan.signingAuthority, request: request2, ...intent2, walletIntent: { intentId: owned.intentId, kind: owned.kind } });
|
|
60083
|
-
const context = Object.freeze({
|
|
60084
|
-
privateKey: authority.wallet.privateKey,
|
|
60085
|
-
walletAddress: authority.wallet.walletAddress,
|
|
60086
|
-
bearer: authority.session.rawBearer,
|
|
60087
|
-
intentId: owned.intentId,
|
|
60088
|
-
origin: authority.session.origin,
|
|
60089
|
-
resumePrepared: async (request2, intent2) => {
|
|
60090
|
-
const fingerprint2 = skillBuyerIntentFingerprint(walletPlan(request2, intent2));
|
|
60091
|
-
const stored = await this.state.readSkillBuyerIntentRecovery?.(fingerprint2);
|
|
60092
|
-
if (stored == null) return null;
|
|
60093
|
-
const recovered = await this.recoverSkill("intent", fingerprint2);
|
|
60094
|
-
if (recovered.status !== "projected") throw new TypeError("Skill projection is pending. Resume the recorded wallet result.");
|
|
60095
|
-
return { transactionHash: String(recovered.transactionHash), blockNumber: String(recovered.blockNumber) };
|
|
60096
|
-
},
|
|
60097
|
-
onBroadcast: async (broadcast) => {
|
|
60098
|
-
journal = createSkillBuyerIntentJournal({ intent: walletPlan(broadcast.request, broadcast.intent), intentId: owned.intentId, origin: authority.session.origin, accountId: authority.session.accountId, walletAddress: authority.wallet.walletAddress, environment: authority.session.environment, transactionHash: broadcast.transactionHash, idempotencyKey: skillIntentConfirmationIdempotencyKey(Number(plan.chainId), broadcast.transactionHash) });
|
|
60099
|
-
await required3(this.state.saveSkillBuyerIntentRecovery, "state.saveSkillBuyerIntentRecovery").call(this.state, journal.fingerprint, journal);
|
|
60100
|
-
return journal.fingerprint;
|
|
60101
|
-
},
|
|
60102
|
-
onReceipt: async (blockNumber2) => {
|
|
60103
|
-
if (!journal) throw new TypeError("Skill presentation broadcast was not checkpointed.");
|
|
60104
|
-
journal = withSkillBuyerIntentReceipt(journal, blockNumber2);
|
|
60105
|
-
await required3(this.state.saveSkillBuyerIntentRecovery, "state.saveSkillBuyerIntentRecovery").call(this.state, journal.fingerprint, journal);
|
|
60106
|
-
}
|
|
60107
|
-
});
|
|
60108
|
-
const published = await required3(this.skillLocalFlow, "skill local flow").publishPresentation(plan, context);
|
|
60109
|
-
if (journal) await required3(this.state.clearSkillBuyerIntentRecovery, "state.clearSkillBuyerIntentRecovery").call(this.state, journal.fingerprint);
|
|
60110
|
-
return { ...published, nextAction: { operationId: "skill_market.manage.get", request: {
|
|
60111
|
-
chainId: published.chainId,
|
|
60112
|
-
skillId: published.skillId
|
|
60113
|
-
} } };
|
|
60087
|
+
async submitSkillPresentation(_planFile) {
|
|
60088
|
+
void _planFile;
|
|
60089
|
+
throw new TypeError("SKILL_PRESENTATION_FLOW_REMOVED: Use skill_market_presentation_update through Remote MCP to save presentation, documents and video directly without a wallet transaction.");
|
|
60114
60090
|
}
|
|
60115
60091
|
async uploadSkillAsset(path2, planFile) {
|
|
60116
60092
|
const authority = await this.walletAuthority();
|
|
@@ -60125,8 +60101,8 @@ var init_application = __esm({
|
|
|
60125
60101
|
}
|
|
60126
60102
|
} };
|
|
60127
60103
|
}
|
|
60128
|
-
async recoverSkill(kind,
|
|
60129
|
-
if (!["publication", "intent"].includes(kind) || !/^[0-9a-f]{64}$/u.test(
|
|
60104
|
+
async recoverSkill(kind, fingerprint) {
|
|
60105
|
+
if (!["publication", "intent"].includes(kind) || !/^[0-9a-f]{64}$/u.test(fingerprint)) {
|
|
60130
60106
|
throw new TypeError("Skill recovery kind or fingerprint is invalid.");
|
|
60131
60107
|
}
|
|
60132
60108
|
const { wallet, session } = await this.walletAuthority();
|
|
@@ -60142,16 +60118,16 @@ var init_application = __esm({
|
|
|
60142
60118
|
return asObject(await required3(
|
|
60143
60119
|
required3(this.skillLocalFlow, "skill local flow").recoverPublication,
|
|
60144
60120
|
"skill publication recovery"
|
|
60145
|
-
).call(this.skillLocalFlow,
|
|
60121
|
+
).call(this.skillLocalFlow, fingerprint, context), "Skill publication recovery");
|
|
60146
60122
|
}
|
|
60147
|
-
const stored = await required3(this.state.readSkillBuyerIntentRecovery, "state.readSkillBuyerIntentRecovery").call(this.state,
|
|
60123
|
+
const stored = await required3(this.state.readSkillBuyerIntentRecovery, "state.readSkillBuyerIntentRecovery").call(this.state, fingerprint);
|
|
60148
60124
|
if (stored === null) throw new TypeError("Skill buyer intent recovery journal was not found.");
|
|
60149
60125
|
let journal = assertSkillBuyerIntentJournalAuthority(stored, {
|
|
60150
60126
|
accountId: session.accountId,
|
|
60151
60127
|
walletAddress: wallet.walletAddress,
|
|
60152
60128
|
environment: session.environment
|
|
60153
60129
|
});
|
|
60154
|
-
if (journal.fingerprint !==
|
|
60130
|
+
if (journal.fingerprint !== fingerprint) throw new TypeError("Skill buyer intent fingerprint is invalid.");
|
|
60155
60131
|
assertSigningAuthority(journal.intent, session);
|
|
60156
60132
|
if (journal.origin !== void 0 && journal.origin !== session.origin) throw new TypeError("Skill recovery belongs to another endpoint.");
|
|
60157
60133
|
if (journal.intentId === void 0) {
|
|
@@ -60162,7 +60138,7 @@ var init_application = __esm({
|
|
|
60162
60138
|
const receipt = owned.stages.primary;
|
|
60163
60139
|
if (!receipt || receipt.transactionHash !== journal.transactionHash || receipt.blockNumber === null) throw new TypeError("Legacy Skill adoption has no canonical receipt.");
|
|
60164
60140
|
if (journal.blockNumber === null) journal = withSkillBuyerIntentReceipt(journal, receipt.blockNumber);
|
|
60165
|
-
await required3(this.state.saveSkillBuyerIntentRecovery, "state.saveSkillBuyerIntentRecovery").call(this.state,
|
|
60141
|
+
await required3(this.state.saveSkillBuyerIntentRecovery, "state.saveSkillBuyerIntentRecovery").call(this.state, fingerprint, journal);
|
|
60166
60142
|
} else {
|
|
60167
60143
|
const owned = await this.skillWalletIntent(journal.intentId, journal.kind, session);
|
|
60168
60144
|
const stage = owned.stages.primary;
|
|
@@ -60186,12 +60162,12 @@ var init_application = __esm({
|
|
|
60186
60162
|
blockNumber: null
|
|
60187
60163
|
});
|
|
60188
60164
|
journal = withSkillBuyerIntentReceipt(journal, receipt.blockNumber);
|
|
60189
|
-
await required3(this.state.saveSkillBuyerIntentRecovery, "state.saveSkillBuyerIntentRecovery").call(this.state,
|
|
60165
|
+
await required3(this.state.saveSkillBuyerIntentRecovery, "state.saveSkillBuyerIntentRecovery").call(this.state, fingerprint, journal);
|
|
60190
60166
|
}
|
|
60191
60167
|
}
|
|
60192
60168
|
const confirmation = await this.confirmSkillWalletResult(journal.intentId, journal.transactionHash, session);
|
|
60193
60169
|
if (confirmation.status === "projected") {
|
|
60194
|
-
await required3(this.state.clearSkillBuyerIntentRecovery, "state.clearSkillBuyerIntentRecovery").call(this.state,
|
|
60170
|
+
await required3(this.state.clearSkillBuyerIntentRecovery, "state.clearSkillBuyerIntentRecovery").call(this.state, fingerprint);
|
|
60195
60171
|
}
|
|
60196
60172
|
return { ...confirmation, transactionHash: journal.transactionHash, blockNumber: confirmation.blockNumber };
|
|
60197
60173
|
}
|
|
@@ -60514,6 +60490,23 @@ function helpTopic(allArguments) {
|
|
|
60514
60490
|
}
|
|
60515
60491
|
return null;
|
|
60516
60492
|
}
|
|
60493
|
+
function usageError(allArguments, grammar) {
|
|
60494
|
+
const arguments_ = finchOwnArguments(allArguments);
|
|
60495
|
+
const command = FINCH_COMMANDS.filter((candidate) => candidate.split(" ").every((word, index2) => arguments_[index2] === word)).sort((left, right) => right.length - left.length)[0];
|
|
60496
|
+
if (command === void 0) {
|
|
60497
|
+
const group = FINCH_COMMANDS.filter((candidate) => candidate.startsWith(`${arguments_[0]} `));
|
|
60498
|
+
if (group.length > 0) {
|
|
60499
|
+
return new CliUsageError(`Unknown finch ${arguments_[0]} command. Supported: ${group.map((candidate) => `finch ${candidate}`).join(", ")}.`);
|
|
60500
|
+
}
|
|
60501
|
+
return new CliUsageError(`${grammar.detail ?? "Unknown finch command."} Run finch help to list supported commands.`);
|
|
60502
|
+
}
|
|
60503
|
+
const usage = FINCH_COMMAND_USAGE[command];
|
|
60504
|
+
if (grammar.detail !== null) return new CliUsageError(`${grammar.detail} Usage: ${usage}`);
|
|
60505
|
+
const accepted = new Set(usage.match(/--[a-z][a-z0-9-]*/gu) ?? []);
|
|
60506
|
+
if (accepted.has("--intent")) accepted.add("--from-file");
|
|
60507
|
+
const unsupported = [...new Set(arguments_.filter((argument) => OPTION_NAME.test(argument) && argument !== "--help" && !accepted.has(argument)))];
|
|
60508
|
+
return new CliUsageError(unsupported.length > 0 ? `finch ${command} does not accept ${unsupported.join(", ")}. Usage: ${usage}` : `Unexpected arguments for finch ${command}. Usage: ${usage}`);
|
|
60509
|
+
}
|
|
60517
60510
|
function method(value, name) {
|
|
60518
60511
|
if (value === void 0) throw new TypeError(`Command ${name} is unavailable.`);
|
|
60519
60512
|
return value;
|
|
@@ -60521,31 +60514,31 @@ function method(value, name) {
|
|
|
60521
60514
|
function exactOption(arguments_, name) {
|
|
60522
60515
|
const index2 = arguments_.indexOf(name);
|
|
60523
60516
|
if (index2 < 0 || index2 !== arguments_.lastIndexOf(name) || index2 + 1 >= arguments_.length) {
|
|
60524
|
-
throw new
|
|
60517
|
+
throw new CommandGrammarError(`${name} is required exactly once.`);
|
|
60525
60518
|
}
|
|
60526
60519
|
const value = arguments_[index2 + 1];
|
|
60527
|
-
if (value === void 0 || value.startsWith("--")) throw new
|
|
60520
|
+
if (value === void 0 || value.startsWith("--")) throw new CommandGrammarError(`${name} requires a value.`);
|
|
60528
60521
|
return value;
|
|
60529
60522
|
}
|
|
60530
60523
|
function assertExactOptions(arguments_, start, names) {
|
|
60531
60524
|
const options = arguments_.slice(start);
|
|
60532
60525
|
if (options.length !== names.length * 2) {
|
|
60533
|
-
throw new
|
|
60526
|
+
throw new CommandGrammarError();
|
|
60534
60527
|
}
|
|
60535
60528
|
const actualNames = options.filter((_value, index2) => index2 % 2 === 0);
|
|
60536
60529
|
if (actualNames.some((name) => !names.includes(name)) || new Set(actualNames).size !== names.length) {
|
|
60537
|
-
throw new
|
|
60530
|
+
throw new CommandGrammarError();
|
|
60538
60531
|
}
|
|
60539
60532
|
}
|
|
60540
60533
|
function optionalOptions(arguments_, start, names) {
|
|
60541
60534
|
const options = arguments_.slice(start);
|
|
60542
|
-
if (options.length % 2 !== 0) throw new
|
|
60535
|
+
if (options.length % 2 !== 0) throw new CommandGrammarError();
|
|
60543
60536
|
const result2 = {};
|
|
60544
60537
|
for (let index2 = 0; index2 < options.length; index2 += 2) {
|
|
60545
60538
|
const name = options[index2];
|
|
60546
60539
|
const value = options[index2 + 1];
|
|
60547
60540
|
if (name === void 0 || value === void 0 || !names.includes(name) || Object.hasOwn(result2, name) || value.startsWith("--")) {
|
|
60548
|
-
throw new
|
|
60541
|
+
throw new CommandGrammarError();
|
|
60549
60542
|
}
|
|
60550
60543
|
result2[name] = value;
|
|
60551
60544
|
}
|
|
@@ -60557,10 +60550,18 @@ function result(command, data) {
|
|
|
60557
60550
|
function walletIntentInput(arguments_) {
|
|
60558
60551
|
const file2 = arguments_.includes("--from-file") ? exactOption(arguments_, "--from-file") : void 0;
|
|
60559
60552
|
const intent2 = arguments_.includes("--intent") ? exactOption(arguments_, "--intent") : void 0;
|
|
60560
|
-
if (file2 === void 0 === (intent2 === void 0)) throw new
|
|
60553
|
+
if (file2 === void 0 === (intent2 === void 0)) throw new CommandGrammarError("Provide exactly one of --intent or --from-file.");
|
|
60561
60554
|
return intent2 ?? file2;
|
|
60562
60555
|
}
|
|
60563
60556
|
async function routeCommand(arguments_, application) {
|
|
60557
|
+
try {
|
|
60558
|
+
return await dispatchCommand(arguments_, application);
|
|
60559
|
+
} catch (cause) {
|
|
60560
|
+
if (cause instanceof CommandGrammarError) throw usageError(arguments_, cause);
|
|
60561
|
+
throw cause;
|
|
60562
|
+
}
|
|
60563
|
+
}
|
|
60564
|
+
async function dispatchCommand(arguments_, application) {
|
|
60564
60565
|
if (arguments_.length === 0 || arguments_.length === 1 && ["--help", "help"].includes(arguments_[0])) {
|
|
60565
60566
|
return Object.freeze({ command: "help", commands: FINCH_COMMANDS });
|
|
60566
60567
|
}
|
|
@@ -60588,12 +60589,15 @@ async function routeCommand(arguments_, application) {
|
|
|
60588
60589
|
}
|
|
60589
60590
|
const commands = FINCH_COMMANDS.filter((command) => command.startsWith(`${topic} `));
|
|
60590
60591
|
if (commands.length > 0) return Object.freeze({ command: "help", topic, commands });
|
|
60591
|
-
throw new
|
|
60592
|
+
throw new CommandGrammarError("Unknown finch help topic.");
|
|
60592
60593
|
}
|
|
60593
60594
|
const [first, second, third] = arguments_;
|
|
60594
60595
|
if (first === "wallet" && second === "create" && arguments_.length === 2) {
|
|
60595
60596
|
return result("wallet.create", await method(application.createWallet, "wallet create").call(application));
|
|
60596
60597
|
}
|
|
60598
|
+
if (first === "wallet" && second === "list" && arguments_.length === 2) {
|
|
60599
|
+
return result("wallet.list", await method(application.listWallets, "wallet list").call(application));
|
|
60600
|
+
}
|
|
60597
60601
|
if (first === "wallet" && second === "show" && arguments_.length === 2) {
|
|
60598
60602
|
return result("wallet.show", await method(application.showWallet, "wallet show").call(application));
|
|
60599
60603
|
}
|
|
@@ -60604,13 +60608,13 @@ async function routeCommand(arguments_, application) {
|
|
|
60604
60608
|
if (arguments_.length === 4 && third === "--file" && arguments_[3] !== void 0 && !arguments_[3].startsWith("--")) {
|
|
60605
60609
|
return result("wallet.use", await method(application.useWallet, "wallet use").call(application, Object.freeze({ file: arguments_[3] })));
|
|
60606
60610
|
}
|
|
60607
|
-
throw new
|
|
60611
|
+
throw new CommandGrammarError();
|
|
60608
60612
|
}
|
|
60609
60613
|
if (first === "login") {
|
|
60610
60614
|
const rawChainId = exactOption(arguments_, "--chain-id");
|
|
60611
60615
|
assertExactOptions(arguments_, 1, ["--chain-id"]);
|
|
60612
60616
|
if (!/^[1-9][0-9]*$/u.test(rawChainId) || !Number.isSafeInteger(Number(rawChainId))) {
|
|
60613
|
-
throw new
|
|
60617
|
+
throw new CommandGrammarError("--chain-id must be a positive safe integer.");
|
|
60614
60618
|
}
|
|
60615
60619
|
return result("login", await method(application.login, "login").call(application, Number(rawChainId)));
|
|
60616
60620
|
}
|
|
@@ -60647,7 +60651,7 @@ async function routeCommand(arguments_, application) {
|
|
|
60647
60651
|
const framed = arguments_.includes("--from-file");
|
|
60648
60652
|
const bearer = arguments_.includes("--bearer-token-file");
|
|
60649
60653
|
if (framed === bearer) {
|
|
60650
|
-
throw new
|
|
60654
|
+
throw new CommandGrammarError("Choose exactly one of --from-file or --bearer-token-file.");
|
|
60651
60655
|
}
|
|
60652
60656
|
const input = framed ? Object.freeze({ kind: "framed", path: exactOption(arguments_, "--from-file") }) : Object.freeze({
|
|
60653
60657
|
kind: "bearer_token",
|
|
@@ -60712,7 +60716,7 @@ async function routeCommand(arguments_, application) {
|
|
|
60712
60716
|
if (first === "task" && second === "recover" && third !== void 0 && arguments_.length === 4) {
|
|
60713
60717
|
const kind = arguments_[3];
|
|
60714
60718
|
if (!["publish", "award", "reclaim"].includes(String(kind))) {
|
|
60715
|
-
throw new
|
|
60719
|
+
throw new CommandGrammarError("Task recovery kind must be publish, award, or reclaim.");
|
|
60716
60720
|
}
|
|
60717
60721
|
return result("task.recover", await method(application.recoverTask, "task recover").call(application, third, kind));
|
|
60718
60722
|
}
|
|
@@ -60723,7 +60727,7 @@ async function routeCommand(arguments_, application) {
|
|
|
60723
60727
|
}
|
|
60724
60728
|
if (first === "skill" && second === "recover" && arguments_.length === 4) {
|
|
60725
60729
|
if (!["publication", "intent"].includes(String(third)) || arguments_[3] === void 0) {
|
|
60726
|
-
throw new
|
|
60730
|
+
throw new CommandGrammarError("Skill recovery kind must be publication or intent.");
|
|
60727
60731
|
}
|
|
60728
60732
|
return result("skill.recover", await method(application.recoverSkill, "skill recover").call(application, third, arguments_[3]));
|
|
60729
60733
|
}
|
|
@@ -60754,16 +60758,18 @@ async function routeCommand(arguments_, application) {
|
|
|
60754
60758
|
optionalOptions(arguments_, 2, ["--from-file", "--intent", "--out-file"]);
|
|
60755
60759
|
return result("skill.download", await method(application.downloadSkill, "skill download").call(application, walletIntentInput(arguments_), exactOption(arguments_, "--out-file")));
|
|
60756
60760
|
}
|
|
60757
|
-
throw new
|
|
60761
|
+
throw new CommandGrammarError();
|
|
60758
60762
|
}
|
|
60759
|
-
var FINCH_COMMANDS, FINCH_CLI_IDENTITY, FINCH_CLI_PACKAGE, FINCH_CLI_VERSION, FINCH_COMMAND_USAGE;
|
|
60763
|
+
var FINCH_COMMANDS, FINCH_CLI_IDENTITY, FINCH_CLI_PACKAGE, FINCH_CLI_VERSION, FINCH_COMMAND_USAGE, CommandGrammarError, OPTION_NAME;
|
|
60760
60764
|
var init_command_router = __esm({
|
|
60761
60765
|
"src/command-router.ts"() {
|
|
60762
60766
|
"use strict";
|
|
60763
60767
|
init_package();
|
|
60764
60768
|
init_v1();
|
|
60769
|
+
init_cli_error();
|
|
60765
60770
|
FINCH_COMMANDS = Object.freeze([
|
|
60766
60771
|
"wallet create",
|
|
60772
|
+
"wallet list",
|
|
60767
60773
|
"wallet show",
|
|
60768
60774
|
"wallet use",
|
|
60769
60775
|
"login",
|
|
@@ -60805,6 +60811,7 @@ var init_command_router = __esm({
|
|
|
60805
60811
|
FINCH_CLI_VERSION = package_default.version;
|
|
60806
60812
|
FINCH_COMMAND_USAGE = Object.freeze({
|
|
60807
60813
|
"wallet create": "finch wallet create",
|
|
60814
|
+
"wallet list": "finch wallet list",
|
|
60808
60815
|
"wallet show": "finch wallet show",
|
|
60809
60816
|
"wallet use": "finch wallet use <ADDRESS> | finch wallet use --file <PATH>",
|
|
60810
60817
|
login: "finch login --chain-id <CHAIN_ID>",
|
|
@@ -60841,6 +60848,15 @@ var init_command_router = __esm({
|
|
|
60841
60848
|
"skill recover publication": "finch skill recover publication <FINGERPRINT>",
|
|
60842
60849
|
"skill recover intent": "finch skill recover intent <FINGERPRINT>"
|
|
60843
60850
|
});
|
|
60851
|
+
CommandGrammarError = class extends Error {
|
|
60852
|
+
constructor(detail = null) {
|
|
60853
|
+
super(detail ?? "Command arguments do not match the finch command tree.");
|
|
60854
|
+
this.detail = detail;
|
|
60855
|
+
this.name = "CommandGrammarError";
|
|
60856
|
+
}
|
|
60857
|
+
detail;
|
|
60858
|
+
};
|
|
60859
|
+
OPTION_NAME = /^--[a-z][a-z0-9-]{0,39}$/u;
|
|
60844
60860
|
}
|
|
60845
60861
|
});
|
|
60846
60862
|
|
|
@@ -61573,191 +61589,6 @@ var init_stdin_reader = __esm({
|
|
|
61573
61589
|
}
|
|
61574
61590
|
});
|
|
61575
61591
|
|
|
61576
|
-
// src/recovery-inventory.ts
|
|
61577
|
-
function object4(value, name) {
|
|
61578
|
-
if (typeof value !== "object" || value === null || Array.isArray(value)) {
|
|
61579
|
-
throw new TypeError(`${name} must contain exact public fields.`);
|
|
61580
|
-
}
|
|
61581
|
-
return value;
|
|
61582
|
-
}
|
|
61583
|
-
function exactKeys2(value, keys, name) {
|
|
61584
|
-
const actual = Object.keys(value).sort();
|
|
61585
|
-
const expected = [...keys].sort();
|
|
61586
|
-
if (actual.length !== expected.length || actual.some((key, index2) => key !== expected[index2])) {
|
|
61587
|
-
throw new TypeError(`${name} must contain exact public fields.`);
|
|
61588
|
-
}
|
|
61589
|
-
}
|
|
61590
|
-
function uuid5(value, name) {
|
|
61591
|
-
if (typeof value !== "string" || !UUID3.test(value)) throw new TypeError(`${name} is invalid.`);
|
|
61592
|
-
return value;
|
|
61593
|
-
}
|
|
61594
|
-
function fingerprint(value) {
|
|
61595
|
-
if (typeof value !== "string" || !FINGERPRINT2.test(value)) {
|
|
61596
|
-
throw new TypeError("Recovery fingerprint is invalid.");
|
|
61597
|
-
}
|
|
61598
|
-
return value;
|
|
61599
|
-
}
|
|
61600
|
-
function taskKind(value) {
|
|
61601
|
-
if (!TASK_KINDS.includes(value)) {
|
|
61602
|
-
throw new TypeError("Task recovery kind is invalid.");
|
|
61603
|
-
}
|
|
61604
|
-
return value;
|
|
61605
|
-
}
|
|
61606
|
-
function skillKind(value) {
|
|
61607
|
-
if (!SKILL_KINDS.includes(value)) {
|
|
61608
|
-
throw new TypeError("Skill recovery kind is invalid.");
|
|
61609
|
-
}
|
|
61610
|
-
return value;
|
|
61611
|
-
}
|
|
61612
|
-
function parseEntry(value) {
|
|
61613
|
-
const candidate = object4(value, "Recovery inventory entry");
|
|
61614
|
-
if (candidate.type === "agent_purchase") {
|
|
61615
|
-
exactKeys2(candidate, ["type", "operationId"], "Agent purchase recovery entry");
|
|
61616
|
-
return Object.freeze({
|
|
61617
|
-
type: "agent_purchase",
|
|
61618
|
-
operationId: uuid5(candidate.operationId, "Agent purchase operationId")
|
|
61619
|
-
});
|
|
61620
|
-
}
|
|
61621
|
-
if (candidate.type === "task") {
|
|
61622
|
-
exactKeys2(candidate, ["type", "taskId", "kind"], "Task recovery entry");
|
|
61623
|
-
return Object.freeze({
|
|
61624
|
-
type: "task",
|
|
61625
|
-
taskId: uuid5(candidate.taskId, "Task taskId"),
|
|
61626
|
-
kind: taskKind(candidate.kind)
|
|
61627
|
-
});
|
|
61628
|
-
}
|
|
61629
|
-
if (candidate.type === "skill") {
|
|
61630
|
-
exactKeys2(candidate, ["type", "kind", "fingerprint"], "Skill recovery entry");
|
|
61631
|
-
return Object.freeze({
|
|
61632
|
-
type: "skill",
|
|
61633
|
-
kind: skillKind(candidate.kind),
|
|
61634
|
-
fingerprint: fingerprint(candidate.fingerprint)
|
|
61635
|
-
});
|
|
61636
|
-
}
|
|
61637
|
-
throw new TypeError("Recovery inventory entry type is invalid.");
|
|
61638
|
-
}
|
|
61639
|
-
function parseKey(value) {
|
|
61640
|
-
const candidate = object4(value, "Recovery inventory key");
|
|
61641
|
-
if (candidate.type === "agent_purchase") {
|
|
61642
|
-
exactKeys2(candidate, ["type", "operationId"], "Agent purchase recovery key");
|
|
61643
|
-
return Object.freeze({
|
|
61644
|
-
type: "agent_purchase",
|
|
61645
|
-
operationId: uuid5(candidate.operationId, "Agent purchase operationId")
|
|
61646
|
-
});
|
|
61647
|
-
}
|
|
61648
|
-
if (candidate.type === "task") {
|
|
61649
|
-
exactKeys2(candidate, ["type", "taskId", "kind"], "Task recovery key");
|
|
61650
|
-
return Object.freeze({
|
|
61651
|
-
type: "task",
|
|
61652
|
-
taskId: uuid5(candidate.taskId, "Task taskId"),
|
|
61653
|
-
kind: taskKind(candidate.kind)
|
|
61654
|
-
});
|
|
61655
|
-
}
|
|
61656
|
-
if (candidate.type === "skill") {
|
|
61657
|
-
exactKeys2(candidate, ["type", "kind", "fingerprint"], "Skill recovery key");
|
|
61658
|
-
return Object.freeze({
|
|
61659
|
-
type: "skill",
|
|
61660
|
-
kind: skillKind(candidate.kind),
|
|
61661
|
-
fingerprint: fingerprint(candidate.fingerprint)
|
|
61662
|
-
});
|
|
61663
|
-
}
|
|
61664
|
-
throw new TypeError("Recovery inventory key type is invalid.");
|
|
61665
|
-
}
|
|
61666
|
-
function entryKey(entry2) {
|
|
61667
|
-
if (entry2.type === "agent_purchase") return `agent_purchase:${entry2.operationId}`;
|
|
61668
|
-
if (entry2.type === "task") return `task:${entry2.taskId}:${entry2.kind}`;
|
|
61669
|
-
return `skill:${entry2.kind}:${entry2.fingerprint}`;
|
|
61670
|
-
}
|
|
61671
|
-
function document(value) {
|
|
61672
|
-
if (value === null) return Object.freeze({ version: 1, entries: Object.freeze([]) });
|
|
61673
|
-
const candidate = object4(value, "Recovery inventory");
|
|
61674
|
-
exactKeys2(candidate, ["version", "entries"], "Recovery inventory");
|
|
61675
|
-
if (candidate.version !== 1 || !Array.isArray(candidate.entries)) {
|
|
61676
|
-
throw new TypeError("Recovery inventory is invalid.");
|
|
61677
|
-
}
|
|
61678
|
-
const entries = candidate.entries.map(parseEntry).sort((left, right) => entryKey(left).localeCompare(entryKey(right)));
|
|
61679
|
-
if (new Set(entries.map(entryKey)).size !== entries.length) {
|
|
61680
|
-
throw new TypeError("Recovery inventory contains duplicate entries.");
|
|
61681
|
-
}
|
|
61682
|
-
return Object.freeze({ version: 1, entries: Object.freeze(entries) });
|
|
61683
|
-
}
|
|
61684
|
-
function publicDocument(entries) {
|
|
61685
|
-
return Object.freeze({
|
|
61686
|
-
version: 1,
|
|
61687
|
-
entries: Object.freeze([...entries].sort((left, right) => entryKey(left).localeCompare(entryKey(right))))
|
|
61688
|
-
});
|
|
61689
|
-
}
|
|
61690
|
-
function formatRecoveryInventoryEntry(entryValue) {
|
|
61691
|
-
const entry2 = parseEntry(entryValue);
|
|
61692
|
-
if (entry2.type === "agent_purchase") {
|
|
61693
|
-
return Object.freeze({
|
|
61694
|
-
type: "agent_purchase",
|
|
61695
|
-
operationId: entry2.operationId,
|
|
61696
|
-
command: `finch purchase submit ${entry2.operationId}`,
|
|
61697
|
-
blockedReason: null,
|
|
61698
|
-
guidance: null
|
|
61699
|
-
});
|
|
61700
|
-
}
|
|
61701
|
-
if (entry2.type === "task") {
|
|
61702
|
-
return Object.freeze({
|
|
61703
|
-
type: "task",
|
|
61704
|
-
taskId: entry2.taskId,
|
|
61705
|
-
kind: entry2.kind,
|
|
61706
|
-
command: `finch task recover ${entry2.taskId} ${entry2.kind}`,
|
|
61707
|
-
blockedReason: null,
|
|
61708
|
-
guidance: null
|
|
61709
|
-
});
|
|
61710
|
-
}
|
|
61711
|
-
return Object.freeze({
|
|
61712
|
-
type: "skill",
|
|
61713
|
-
kind: entry2.kind,
|
|
61714
|
-
fingerprint: entry2.fingerprint,
|
|
61715
|
-
command: `finch skill recover ${entry2.kind} ${entry2.fingerprint}`,
|
|
61716
|
-
blockedReason: null,
|
|
61717
|
-
guidance: null
|
|
61718
|
-
});
|
|
61719
|
-
}
|
|
61720
|
-
var UUID3, FINGERPRINT2, TASK_KINDS, SKILL_KINDS, RecoveryInventory;
|
|
61721
|
-
var init_recovery_inventory = __esm({
|
|
61722
|
-
"src/recovery-inventory.ts"() {
|
|
61723
|
-
"use strict";
|
|
61724
|
-
UUID3 = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/u;
|
|
61725
|
-
FINGERPRINT2 = /^[0-9a-f]{64}$/u;
|
|
61726
|
-
TASK_KINDS = Object.freeze(["publish", "award", "reclaim"]);
|
|
61727
|
-
SKILL_KINDS = Object.freeze(["publication", "intent"]);
|
|
61728
|
-
RecoveryInventory = class {
|
|
61729
|
-
constructor(storage) {
|
|
61730
|
-
this.storage = storage;
|
|
61731
|
-
}
|
|
61732
|
-
storage;
|
|
61733
|
-
async add(entryValue) {
|
|
61734
|
-
const entry2 = parseEntry(entryValue);
|
|
61735
|
-
const current = await this.list();
|
|
61736
|
-
const key = entryKey(entry2);
|
|
61737
|
-
const existing = current.find((candidate) => entryKey(candidate) === key);
|
|
61738
|
-
if (existing !== void 0) return existing;
|
|
61739
|
-
const next = [...current, entry2];
|
|
61740
|
-
await this.storage.write(publicDocument(next));
|
|
61741
|
-
return entry2;
|
|
61742
|
-
}
|
|
61743
|
-
async remove(keyValue) {
|
|
61744
|
-
const key = parseKey(keyValue);
|
|
61745
|
-
const current = await this.list();
|
|
61746
|
-
const next = current.filter((entry2) => entryKey(entry2) !== entryKey(key));
|
|
61747
|
-
if (next.length === current.length) return false;
|
|
61748
|
-
await this.storage.write(publicDocument(next));
|
|
61749
|
-
return true;
|
|
61750
|
-
}
|
|
61751
|
-
async list() {
|
|
61752
|
-
return document(await this.storage.read()).entries;
|
|
61753
|
-
}
|
|
61754
|
-
async format() {
|
|
61755
|
-
return Object.freeze((await this.list()).map(formatRecoveryInventoryEntry));
|
|
61756
|
-
}
|
|
61757
|
-
};
|
|
61758
|
-
}
|
|
61759
|
-
});
|
|
61760
|
-
|
|
61761
61592
|
// src/wallet-store.ts
|
|
61762
61593
|
function record3(value) {
|
|
61763
61594
|
if (typeof value !== "object" || value === null || Array.isArray(value)) {
|
|
@@ -61967,7 +61798,7 @@ var init_wallet_store = __esm({
|
|
|
61967
61798
|
import { randomBytes as randomBytes2 } from "node:crypto";
|
|
61968
61799
|
import { lstat as lstat3 } from "node:fs/promises";
|
|
61969
61800
|
import { join as join3 } from "node:path";
|
|
61970
|
-
function
|
|
61801
|
+
function object4(value, name) {
|
|
61971
61802
|
if (typeof value !== "object" || value === null || Array.isArray(value)) {
|
|
61972
61803
|
throw new CliStateError("CLI_STATE_CORRUPT", { cause: new TypeError(`${name} must be an object.`) });
|
|
61973
61804
|
}
|
|
@@ -61990,7 +61821,7 @@ function endpointOrigin(value) {
|
|
|
61990
61821
|
}
|
|
61991
61822
|
function secretRecord(value, name) {
|
|
61992
61823
|
try {
|
|
61993
|
-
return
|
|
61824
|
+
return object4(JSON.parse(value.toString("utf8")), name);
|
|
61994
61825
|
} catch (cause) {
|
|
61995
61826
|
if (cause instanceof CliStateError) throw cause;
|
|
61996
61827
|
throw new CliStateError("CLI_STATE_CORRUPT", { cause });
|
|
@@ -62007,20 +61838,6 @@ function taskRecoveryKind(value) {
|
|
|
62007
61838
|
function hasCheckpoint(value) {
|
|
62008
61839
|
return typeof value === "object" && value !== null && !Array.isArray(value) && typeof value.transactionHash === "string" && TRANSACTION_HASH.test(value.transactionHash);
|
|
62009
61840
|
}
|
|
62010
|
-
function hasAgentPurchaseCheckpoint(value) {
|
|
62011
|
-
if (typeof value !== "object" || value === null || Array.isArray(value)) return false;
|
|
62012
|
-
const journal = value;
|
|
62013
|
-
return ["approval", "purchase", "revocation"].some((phase) => hasCheckpoint(journal[phase]));
|
|
62014
|
-
}
|
|
62015
|
-
function hasSkillPublicationCheckpoint(value) {
|
|
62016
|
-
if (typeof value !== "object" || value === null || Array.isArray(value)) return false;
|
|
62017
|
-
const journal = value;
|
|
62018
|
-
if (journal.version === 6 && ["primary", "uri", "lit"].includes(String(journal.pendingStage))) return true;
|
|
62019
|
-
const receipts = value.receipts;
|
|
62020
|
-
if (typeof receipts !== "object" || receipts === null || Array.isArray(receipts)) return false;
|
|
62021
|
-
const stages = receipts;
|
|
62022
|
-
return ["primary", "uri", "lit"].some((stage) => hasCheckpoint(stages[stage]));
|
|
62023
|
-
}
|
|
62024
61841
|
function hasTaskRecoveryCheckpoint(value, kind) {
|
|
62025
61842
|
if (typeof value !== "object" || value === null || Array.isArray(value)) return false;
|
|
62026
61843
|
if (kind === "award") {
|
|
@@ -62029,7 +61846,7 @@ function hasTaskRecoveryCheckpoint(value, kind) {
|
|
|
62029
61846
|
}
|
|
62030
61847
|
return hasCheckpoint(value);
|
|
62031
61848
|
}
|
|
62032
|
-
function hasSkillBuyerIntentCheckpoint(value,
|
|
61849
|
+
function hasSkillBuyerIntentCheckpoint(value, fingerprint) {
|
|
62033
61850
|
if (typeof value !== "object" || value === null || Array.isArray(value)) return false;
|
|
62034
61851
|
const journal = value;
|
|
62035
61852
|
const intent2 = journal.intent;
|
|
@@ -62038,37 +61855,24 @@ function hasSkillBuyerIntentCheckpoint(value, fingerprint2) {
|
|
|
62038
61855
|
const authority = intentRecord.signingAuthority;
|
|
62039
61856
|
if (typeof authority !== "object" || authority === null || Array.isArray(authority)) return false;
|
|
62040
61857
|
const authorityRecord = authority;
|
|
62041
|
-
return journal.version === 1 && journal.journalKind === "buyer_intent" && journal.fingerprint ===
|
|
61858
|
+
return journal.version === 1 && journal.journalKind === "buyer_intent" && journal.fingerprint === fingerprint && ["purchase", "convert", "set_unit_price", "set_max_supply", "presentation"].includes(String(journal.kind)) && intentRecord.kind === journal.kind && typeof journal.accountId === "string" && UUID3.test(journal.accountId) && typeof journal.walletAddress === "string" && /^0x[0-9a-f]{40}$/u.test(journal.walletAddress) && (journal.environment === "local" || journal.environment === "test" || journal.environment === "production") && intentRecord.walletAddress === journal.walletAddress && authorityRecord.accountId === journal.accountId && authorityRecord.walletAddress === journal.walletAddress && authorityRecord.environment === journal.environment && typeof journal.transactionHash === "string" && TRANSACTION_HASH.test(journal.transactionHash) && (journal.blockNumber === null || typeof journal.blockNumber === "string" && /^[1-9][0-9]*$/u.test(journal.blockNumber)) && (journal.confirmStatus === "broadcast" || journal.confirmStatus === "receipt_confirmed" || journal.confirmStatus === "projection_confirmed") && (journal.confirmStatus === "broadcast" ? journal.blockNumber === null : journal.blockNumber !== null) && typeof journal.idempotencyKey === "string" && journal.idempotencyKey.length > 0;
|
|
62042
61859
|
}
|
|
62043
|
-
var RECOVERY_FINGERPRINT, TRANSACTION_HASH,
|
|
61860
|
+
var RECOVERY_FINGERPRINT, TRANSACTION_HASH, UUID3, LocalCliState;
|
|
62044
61861
|
var init_local_state = __esm({
|
|
62045
61862
|
"src/local-state.ts"() {
|
|
62046
61863
|
"use strict";
|
|
62047
61864
|
init_v1();
|
|
62048
61865
|
init_state();
|
|
62049
|
-
init_recovery_inventory();
|
|
62050
61866
|
init_wallet_store();
|
|
62051
61867
|
RECOVERY_FINGERPRINT = /^[0-9a-f]{64}$/u;
|
|
62052
61868
|
TRANSACTION_HASH = /^0x[0-9a-f]{64}$/u;
|
|
62053
|
-
|
|
61869
|
+
UUID3 = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/u;
|
|
62054
61870
|
LocalCliState = class {
|
|
62055
61871
|
files;
|
|
62056
61872
|
wallets;
|
|
62057
|
-
recoveryInventory;
|
|
62058
61873
|
constructor(home, fileStoreOptions = {}) {
|
|
62059
61874
|
this.files = new HardenedFileStore(home, fileStoreOptions);
|
|
62060
61875
|
this.wallets = new WalletStore(home, { fileStoreOptions });
|
|
62061
|
-
this.recoveryInventory = new RecoveryInventory({
|
|
62062
|
-
read: async () => {
|
|
62063
|
-
try {
|
|
62064
|
-
return await this.files.readJson("mutations/recovery-index.json");
|
|
62065
|
-
} catch (cause) {
|
|
62066
|
-
if (cause instanceof CliStateError && cause.code === "CLI_STATE_NOT_FOUND") return null;
|
|
62067
|
-
throw cause;
|
|
62068
|
-
}
|
|
62069
|
-
},
|
|
62070
|
-
write: async (document2) => this.files.writeJson("mutations/recovery-index.json", document2)
|
|
62071
|
-
});
|
|
62072
61876
|
}
|
|
62073
61877
|
async readAgentPurchaseRecovery(operationId) {
|
|
62074
61878
|
parseCanonicalUuid(operationId, "operationId");
|
|
@@ -62082,35 +61886,27 @@ var init_local_state = __esm({
|
|
|
62082
61886
|
async saveAgentPurchaseRecovery(operationId, value) {
|
|
62083
61887
|
parseCanonicalUuid(operationId, "operationId");
|
|
62084
61888
|
await this.files.writeJson(`mutations/agent-purchases/${operationId}.secret`, value);
|
|
62085
|
-
if (hasAgentPurchaseCheckpoint(value)) {
|
|
62086
|
-
await this.recoveryInventory.add({ type: "agent_purchase", operationId });
|
|
62087
|
-
}
|
|
62088
61889
|
}
|
|
62089
61890
|
async clearAgentPurchaseRecovery(operationId) {
|
|
62090
61891
|
parseCanonicalUuid(operationId, "operationId");
|
|
62091
61892
|
await this.files.remove(`mutations/agent-purchases/${operationId}.secret`);
|
|
62092
|
-
await this.recoveryInventory.remove({ type: "agent_purchase", operationId });
|
|
62093
61893
|
}
|
|
62094
|
-
async readSkillPublicationRecovery(
|
|
62095
|
-
recoveryFingerprint2(
|
|
61894
|
+
async readSkillPublicationRecovery(fingerprint) {
|
|
61895
|
+
recoveryFingerprint2(fingerprint);
|
|
62096
61896
|
try {
|
|
62097
|
-
return await this.files.readJson(`mutations/skill-publications/${
|
|
61897
|
+
return await this.files.readJson(`mutations/skill-publications/${fingerprint}.secret`);
|
|
62098
61898
|
} catch (cause) {
|
|
62099
61899
|
if (cause instanceof CliStateError && cause.code === "CLI_STATE_NOT_FOUND") return null;
|
|
62100
61900
|
throw cause;
|
|
62101
61901
|
}
|
|
62102
61902
|
}
|
|
62103
|
-
async saveSkillPublicationRecovery(
|
|
62104
|
-
recoveryFingerprint2(
|
|
62105
|
-
await this.files.writeJson(`mutations/skill-publications/${
|
|
62106
|
-
if (hasSkillPublicationCheckpoint(value)) {
|
|
62107
|
-
await this.recoveryInventory.add({ type: "skill", kind: "publication", fingerprint: fingerprint2 });
|
|
62108
|
-
}
|
|
61903
|
+
async saveSkillPublicationRecovery(fingerprint, value) {
|
|
61904
|
+
recoveryFingerprint2(fingerprint);
|
|
61905
|
+
await this.files.writeJson(`mutations/skill-publications/${fingerprint}.secret`, value);
|
|
62109
61906
|
}
|
|
62110
|
-
async clearSkillPublicationRecovery(
|
|
62111
|
-
recoveryFingerprint2(
|
|
62112
|
-
await this.files.remove(`mutations/skill-publications/${
|
|
62113
|
-
await this.recoveryInventory.remove({ type: "skill", kind: "publication", fingerprint: fingerprint2 });
|
|
61907
|
+
async clearSkillPublicationRecovery(fingerprint) {
|
|
61908
|
+
recoveryFingerprint2(fingerprint);
|
|
61909
|
+
await this.files.remove(`mutations/skill-publications/${fingerprint}.secret`);
|
|
62114
61910
|
}
|
|
62115
61911
|
async readTaskRecovery(taskId, kindValue) {
|
|
62116
61912
|
const id = parseCanonicalUuid(taskId, "taskId");
|
|
@@ -62127,43 +61923,36 @@ var init_local_state = __esm({
|
|
|
62127
61923
|
const kind = taskRecoveryKind(kindValue);
|
|
62128
61924
|
if (!hasTaskRecoveryCheckpoint(value, kind)) throw new CliStateError("CLI_STATE_CORRUPT");
|
|
62129
61925
|
await this.files.writeJson(`mutations/tasks/${id}/${kind}.secret`, value);
|
|
62130
|
-
await this.recoveryInventory.add({ type: "task", taskId: id, kind });
|
|
62131
61926
|
}
|
|
62132
61927
|
async clearTaskRecovery(taskId, kindValue) {
|
|
62133
61928
|
const id = parseCanonicalUuid(taskId, "taskId");
|
|
62134
61929
|
const kind = taskRecoveryKind(kindValue);
|
|
62135
61930
|
await this.files.remove(`mutations/tasks/${id}/${kind}.secret`);
|
|
62136
|
-
await this.recoveryInventory.remove({ type: "task", taskId: id, kind });
|
|
62137
61931
|
}
|
|
62138
61932
|
async readSkillBuyerIntentRecovery(fingerprintValue) {
|
|
62139
|
-
const
|
|
61933
|
+
const fingerprint = recoveryFingerprint2(fingerprintValue);
|
|
62140
61934
|
try {
|
|
62141
|
-
return await this.files.readJson(`mutations/skill-buyer-intents/${
|
|
61935
|
+
return await this.files.readJson(`mutations/skill-buyer-intents/${fingerprint}.secret`);
|
|
62142
61936
|
} catch (cause) {
|
|
62143
61937
|
if (cause instanceof CliStateError && cause.code === "CLI_STATE_NOT_FOUND") return null;
|
|
62144
61938
|
throw cause;
|
|
62145
61939
|
}
|
|
62146
61940
|
}
|
|
62147
61941
|
async saveSkillBuyerIntentRecovery(fingerprintValue, value) {
|
|
62148
|
-
const
|
|
62149
|
-
if (!hasSkillBuyerIntentCheckpoint(value,
|
|
62150
|
-
await this.files.writeJson(`mutations/skill-buyer-intents/${
|
|
62151
|
-
await this.recoveryInventory.add({ type: "skill", kind: "intent", fingerprint: fingerprint2 });
|
|
61942
|
+
const fingerprint = recoveryFingerprint2(fingerprintValue);
|
|
61943
|
+
if (!hasSkillBuyerIntentCheckpoint(value, fingerprint)) throw new CliStateError("CLI_STATE_CORRUPT");
|
|
61944
|
+
await this.files.writeJson(`mutations/skill-buyer-intents/${fingerprint}.secret`, value);
|
|
62152
61945
|
}
|
|
62153
61946
|
async clearSkillBuyerIntentRecovery(fingerprintValue) {
|
|
62154
|
-
const
|
|
62155
|
-
await this.files.remove(`mutations/skill-buyer-intents/${
|
|
62156
|
-
await this.recoveryInventory.remove({ type: "skill", kind: "intent", fingerprint: fingerprint2 });
|
|
62157
|
-
}
|
|
62158
|
-
async listBlockingRecoveries() {
|
|
62159
|
-
return this.recoveryInventory.format();
|
|
61947
|
+
const fingerprint = recoveryFingerprint2(fingerprintValue);
|
|
61948
|
+
await this.files.remove(`mutations/skill-buyer-intents/${fingerprint}.secret`);
|
|
62160
61949
|
}
|
|
62161
61950
|
async writeProfile(input) {
|
|
62162
61951
|
await this.files.writeJson("profile.json", { version: 1, origin: endpointOrigin(input.origin) });
|
|
62163
61952
|
}
|
|
62164
61953
|
async readProfile() {
|
|
62165
61954
|
try {
|
|
62166
|
-
const value =
|
|
61955
|
+
const value = object4(await this.files.readJson("profile.json"), "profile");
|
|
62167
61956
|
if (value.version !== 1 || Object.keys(value).sort().join(",") !== "origin,version") {
|
|
62168
61957
|
throw new CliStateError("CLI_STATE_CORRUPT");
|
|
62169
61958
|
}
|
|
@@ -62222,7 +62011,7 @@ var init_local_state = __esm({
|
|
|
62222
62011
|
}), "utf8"), { exclusive: true });
|
|
62223
62012
|
}
|
|
62224
62013
|
async activateSession(input) {
|
|
62225
|
-
const value =
|
|
62014
|
+
const value = object4(input, "session");
|
|
62226
62015
|
parseCanonicalUuid(value.sessionId, "sessionId");
|
|
62227
62016
|
parseCanonicalUuid(value.accountId, "accountId");
|
|
62228
62017
|
if (typeof value.walletAddress !== "string" || !/^0x[0-9a-f]{40}$/u.test(value.walletAddress) || value.audience !== "agent_cli" || typeof value.sessionExpiresAt !== "string") {
|
|
@@ -62275,7 +62064,7 @@ var init_local_state = __esm({
|
|
|
62275
62064
|
}
|
|
62276
62065
|
async readSession() {
|
|
62277
62066
|
try {
|
|
62278
|
-
const metadata =
|
|
62067
|
+
const metadata = object4(await this.files.readJson("session/metadata.json"), "session metadata");
|
|
62279
62068
|
const rawBearer = (await this.files.readSecret("session/bearer")).toString("utf8");
|
|
62280
62069
|
const sessionId = parseCanonicalUuid(metadata.sessionId, "sessionId");
|
|
62281
62070
|
const accountId = parseCanonicalUuid(metadata.accountId, "accountId");
|
|
@@ -63729,7 +63518,7 @@ function expectedCall(kind, request2, deployment) {
|
|
|
63729
63518
|
function expectedPreparedCall(action, request2, deployment) {
|
|
63730
63519
|
const skillId = () => unsigned2(request2.skillId, "Skill id", true);
|
|
63731
63520
|
if (action === "createSkill") {
|
|
63732
|
-
if (typeof request2.plaintext !== "boolean"
|
|
63521
|
+
if (typeof request2.plaintext !== "boolean") throw new TypeError("Skill create request is invalid.");
|
|
63733
63522
|
return {
|
|
63734
63523
|
to: getAddress(deployment.skillFactoryAddress),
|
|
63735
63524
|
value: BigInt(0),
|
|
@@ -63745,8 +63534,10 @@ function expectedPreparedCall(action, request2, deployment) {
|
|
|
63745
63534
|
plaintext: request2.plaintext,
|
|
63746
63535
|
unitPrice: unsigned2(request2.unitPrice, "Skill unit price"),
|
|
63747
63536
|
maxSupply: unsigned2(request2.maxSupply, "Skill max supply"),
|
|
63748
|
-
|
|
63749
|
-
|
|
63537
|
+
// Immutable and Finch-enforced nowhere, so every entrance writes the same fixed
|
|
63538
|
+
// values (Finch-Site issue #1240) instead of trusting caller-supplied ones.
|
|
63539
|
+
royaltyBPS: BigInt(SKILL_PUBLICATION_ROYALTY_BPS),
|
|
63540
|
+
usageLimit: BigInt(SKILL_PUBLICATION_USAGE_LIMIT)
|
|
63750
63541
|
}] })
|
|
63751
63542
|
};
|
|
63752
63543
|
}
|
|
@@ -64123,14 +63914,6 @@ function failure(error51) {
|
|
|
64123
63914
|
message: `${marker === "pending" ? "This recovery stopped after the transaction was prepared for sending" : "This recovery journal predates the pre-send marker"}, so whether ${unknown2} cannot be established locally. Read the Skill on chain first: if ${settled}, the transaction landed and only the local journal is behind. Contact support with this state rather than re-running the command.`
|
|
64124
63915
|
};
|
|
64125
63916
|
}
|
|
64126
|
-
if (error51 instanceof CliRecoveryBlockedError) {
|
|
64127
|
-
return {
|
|
64128
|
-
code: "AGENT_MARKET_STATE_CONFLICT",
|
|
64129
|
-
exitCode: AGENT_CLI_OUTPUT_CONTRACT.exitCodes.conflictOrPrecondition,
|
|
64130
|
-
message: "Recover the listed irreversible operations before logging out or switching Account.",
|
|
64131
|
-
state: JSON.stringify({ recoveryCommands: error51.recoveryCommands })
|
|
64132
|
-
};
|
|
64133
|
-
}
|
|
64134
63917
|
if (error51 instanceof CliHttpError) {
|
|
64135
63918
|
if (error51.code === "CLI_RESPONSE_INVALID") {
|
|
64136
63919
|
return { code: "CLI_RESPONSE_INVALID", exitCode: 7, message: "Remote response is invalid." };
|
|
@@ -64226,6 +64009,11 @@ function emitCliOutcome(outcome, sinks) {
|
|
|
64226
64009
|
return AGENT_CLI_OUTPUT_CONTRACT.exitCodes.conflictOrPrecondition;
|
|
64227
64010
|
}
|
|
64228
64011
|
if (outcome instanceof CliHttpError && outcome.envelope !== null && outcome.status !== null) {
|
|
64012
|
+
const remoteError = outcome.envelope.error;
|
|
64013
|
+
if (outcome.status === 401 && remoteError?.code === "AGENT_SESSION_INVALID") {
|
|
64014
|
+
sinks.stderr(`${CLI_SESSION_RENEWAL_GUIDANCE}
|
|
64015
|
+
`);
|
|
64016
|
+
}
|
|
64229
64017
|
sinks.stdout(`${JSON.stringify(outcome.envelope)}
|
|
64230
64018
|
`);
|
|
64231
64019
|
return remoteExitCode(outcome.status);
|