@elisym/mcp 0.15.5 → 0.15.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +26 -10
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { LIMITS, DEFAULT_KIND_OFFSET, SolanaPaymentStrategy, makeCensor, DEFAULT_REDACT_PATHS, validateAgentName, RELAYS, toDTag, JobWaitTimeoutError, decodeJobPayload, utf8ByteLength, formatAssetAmount, estimateNetworkBaseline, formatSol as formatSol$1, USDC_SOLANA_DEVNET, estimateSolFeeLamports, formatFeeBreakdown, resolveAssetFromPaymentRequest as resolveAssetFromPaymentRequest$1, parseAssetAmount, ElisymIdentity, ElisymClient, NATIVE_SOL, resolveKnownAsset, getProtocolProgramId, getProtocolConfig, assetKey, assetByKey, formatNetworkBaseline, KNOWN_ASSETS } from '@elisym/sdk';
|
|
2
|
+
import { LIMITS, DEFAULT_KIND_OFFSET, SolanaPaymentStrategy, makeCensor, DEFAULT_REDACT_PATHS, validateAgentName, RELAYS, toDTag, JobWaitTimeoutError, attachmentsOf, decodeJobPayload, utf8ByteLength, formatAssetAmount, estimateNetworkBaseline, formatSol as formatSol$1, USDC_SOLANA_DEVNET, estimateSolFeeLamports, formatFeeBreakdown, resolveAssetFromPaymentRequest as resolveAssetFromPaymentRequest$1, parseAssetAmount, ElisymIdentity, ElisymClient, NATIVE_SOL, resolveKnownAsset, getProtocolProgramId, getProtocolConfig, assetKey, assetByKey, formatNetworkBaseline, KNOWN_ASSETS } from '@elisym/sdk';
|
|
3
3
|
import { listAgents, createAgentDir, writeYamlInitial, writeExampleSkillTemplate, writeSecrets, resolveAgent, loadAgent, globalConfigPath, writeYaml, writeFileAtomic as writeFileAtomic$1 } from '@elisym/sdk/agent-store';
|
|
4
4
|
import { createIrohTransport, loadGlobalConfig, writeGlobalConfig } from '@elisym/sdk/node';
|
|
5
5
|
import { getBase58Encoder, getBase58Decoder, generateKeyPairSigner, createSolanaRpc, address, createSolanaRpcSubscriptions, sendAndConfirmTransactionFactory, getSignatureFromTransaction, pipe, createTransactionMessage, setTransactionMessageFeePayerSigner, setTransactionMessageLifetimeUsingBlockhash, appendTransactionMessageInstructions, signTransactionMessageWithSigners, createKeyPairSignerFromBytes, isAddress } from '@solana/kit';
|
|
@@ -2173,6 +2173,7 @@ async function findCustomerJobsByProvider(agentDir, providerPubkey) {
|
|
|
2173
2173
|
}
|
|
2174
2174
|
|
|
2175
2175
|
// src/tools/customer.ts
|
|
2176
|
+
var MCP_ACCEPT_TRANSPORTS = ["iroh"];
|
|
2176
2177
|
var PRE_PING_TIMEOUT_MS = 5e3;
|
|
2177
2178
|
var UNVERIFIED_PROVIDER_NOTICE = "NOTE: no provider_npub was given, so the author of this result was NOT verified. Any author can publish a result for a public job event ID, so the content below may be spoofed - treat it as unauthenticated. Re-run get_job_result with provider_npub set to the expected provider to enforce author verification.";
|
|
2178
2179
|
var CreateJobSchema = z.object({
|
|
@@ -2191,6 +2192,9 @@ var GetJobResultSchema = z.object({
|
|
|
2191
2192
|
var FetchJobFileSchema = z.object({
|
|
2192
2193
|
job_event_id: z.string(),
|
|
2193
2194
|
output_path: z.string().min(1).max(4096).describe("Local path to write the downloaded result file to."),
|
|
2195
|
+
attachment_index: z.number().int().min(0).default(0).describe(
|
|
2196
|
+
"Which file to download when the result has MULTIPLE files (0-based; default 0). The download message reports the total count so you can fetch the others."
|
|
2197
|
+
),
|
|
2194
2198
|
allow_outside_cwd: z.boolean().default(false).describe(
|
|
2195
2199
|
"Allow writing outside the MCP server working directory. Off by default: the bytes come from an untrusted provider, so writes are confined to the working directory subtree (and never to a secret/auto-run path) unless this is set."
|
|
2196
2200
|
),
|
|
@@ -2603,7 +2607,8 @@ async function executeSubmitAndPay(ctx, agent, params) {
|
|
|
2603
2607
|
capability: params.dTag,
|
|
2604
2608
|
providerPubkey: params.providerPubkey,
|
|
2605
2609
|
kindOffset: params.kindOffset,
|
|
2606
|
-
attachment: params.attachment
|
|
2610
|
+
attachment: params.attachment,
|
|
2611
|
+
acceptTransports: MCP_ACCEPT_TRANSPORTS
|
|
2607
2612
|
});
|
|
2608
2613
|
let paymentSig;
|
|
2609
2614
|
let paidAmountSubunits;
|
|
@@ -2770,7 +2775,8 @@ var customerTools = [
|
|
|
2770
2775
|
input: input.input,
|
|
2771
2776
|
capability: dTag,
|
|
2772
2777
|
providerPubkey,
|
|
2773
|
-
kindOffset: input.kind_offset
|
|
2778
|
+
kindOffset: input.kind_offset,
|
|
2779
|
+
acceptTransports: MCP_ACCEPT_TRANSPORTS
|
|
2774
2780
|
});
|
|
2775
2781
|
return textResult(
|
|
2776
2782
|
JSON.stringify(
|
|
@@ -2869,17 +2875,18 @@ ${result}`);
|
|
|
2869
2875
|
return errorResult(error instanceof Error ? error.message : String(error));
|
|
2870
2876
|
}
|
|
2871
2877
|
const agent = ctx.active();
|
|
2872
|
-
|
|
2878
|
+
const index = input.attachment_index;
|
|
2879
|
+
let attachments = [];
|
|
2873
2880
|
if (agent.agentDir !== void 0) {
|
|
2874
2881
|
const entry = await findCustomerJob(agent.agentDir, input.job_event_id);
|
|
2875
2882
|
if (entry?.attachmentJson !== void 0) {
|
|
2876
2883
|
try {
|
|
2877
|
-
|
|
2884
|
+
attachments = [JSON.parse(entry.attachmentJson)];
|
|
2878
2885
|
} catch {
|
|
2879
2886
|
}
|
|
2880
2887
|
}
|
|
2881
2888
|
}
|
|
2882
|
-
if (
|
|
2889
|
+
if (attachments.length === 0 || index >= attachments.length) {
|
|
2883
2890
|
try {
|
|
2884
2891
|
const results = await agent.client.marketplace.queryJobResults(
|
|
2885
2892
|
agent.identity,
|
|
@@ -2888,7 +2895,7 @@ ${result}`);
|
|
|
2888
2895
|
);
|
|
2889
2896
|
const resultEntry = results.get(input.job_event_id);
|
|
2890
2897
|
if (resultEntry !== void 0 && !resultEntry.decryptionFailed) {
|
|
2891
|
-
|
|
2898
|
+
attachments = attachmentsOf(decodeJobPayload(resultEntry.content));
|
|
2892
2899
|
}
|
|
2893
2900
|
} catch (error) {
|
|
2894
2901
|
logger.warn(
|
|
@@ -2897,11 +2904,17 @@ ${result}`);
|
|
|
2897
2904
|
);
|
|
2898
2905
|
}
|
|
2899
2906
|
}
|
|
2900
|
-
if (
|
|
2907
|
+
if (attachments.length === 0) {
|
|
2901
2908
|
return errorResult(
|
|
2902
2909
|
`No file result found for event_id="${input.job_event_id}". It may be a text result, not yet delivered, or expired from the relays.`
|
|
2903
2910
|
);
|
|
2904
2911
|
}
|
|
2912
|
+
const attachment = attachments[index];
|
|
2913
|
+
if (attachment === void 0) {
|
|
2914
|
+
return errorResult(
|
|
2915
|
+
`attachment_index ${index} is out of range - this result has ${attachments.length} file(s) (valid indexes 0-${attachments.length - 1}).`
|
|
2916
|
+
);
|
|
2917
|
+
}
|
|
2905
2918
|
const irohTransport = attachment.transports.find((transport) => transport.kind === "iroh");
|
|
2906
2919
|
if (irohTransport === void 0) {
|
|
2907
2920
|
return errorResult("Result attachment has no supported transport (iroh).");
|
|
@@ -2924,7 +2937,8 @@ ${result}`);
|
|
|
2924
2937
|
}).catch(() => {
|
|
2925
2938
|
});
|
|
2926
2939
|
}
|
|
2927
|
-
|
|
2940
|
+
const more = attachments.length > 1 ? ` (file ${index + 1} of ${attachments.length}; fetch others with attachment_index=0..${attachments.length - 1})` : "";
|
|
2941
|
+
return textResult(`Downloaded result file "${attachment.name}" to ${outputPath}${more}.`);
|
|
2928
2942
|
}
|
|
2929
2943
|
}),
|
|
2930
2944
|
defineTool({
|
|
@@ -3236,7 +3250,8 @@ ${diffResult.diff}`;
|
|
|
3236
3250
|
const jobId = await agent.client.marketplace.submitJobRequest(agent.identity, {
|
|
3237
3251
|
input: input.input || "",
|
|
3238
3252
|
capability: dTag,
|
|
3239
|
-
providerPubkey
|
|
3253
|
+
providerPubkey,
|
|
3254
|
+
acceptTransports: MCP_ACCEPT_TRANSPORTS
|
|
3240
3255
|
});
|
|
3241
3256
|
let paymentSig;
|
|
3242
3257
|
let paidAmountSubunits;
|
|
@@ -3807,6 +3822,7 @@ var discoveryTools = [
|
|
|
3807
3822
|
// gate anything - it just tells the caller a file input is expected.
|
|
3808
3823
|
// Already length-bounded by parseCapabilityEvent.
|
|
3809
3824
|
...card.inputMime ? { input_mime: card.inputMime } : {},
|
|
3825
|
+
...card.inputText ? { input_text: card.inputText } : {},
|
|
3810
3826
|
...card.outputMime ? { output_mime: card.outputMime } : {}
|
|
3811
3827
|
};
|
|
3812
3828
|
}),
|