@elisym/mcp 0.15.6 → 0.15.9
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 +35 -9
- 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';
|
|
@@ -2192,6 +2192,9 @@ var GetJobResultSchema = z.object({
|
|
|
2192
2192
|
var FetchJobFileSchema = z.object({
|
|
2193
2193
|
job_event_id: z.string(),
|
|
2194
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
|
+
),
|
|
2195
2198
|
allow_outside_cwd: z.boolean().default(false).describe(
|
|
2196
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."
|
|
2197
2200
|
),
|
|
@@ -2254,7 +2257,8 @@ function paymentCardForCapability(provider, dTag) {
|
|
|
2254
2257
|
const candidates = dTag ? cards.filter(
|
|
2255
2258
|
(card) => toDTag(card.name) === dTag || card.capabilities?.some((capability) => toDTag(capability) === dTag)
|
|
2256
2259
|
) : cards;
|
|
2257
|
-
|
|
2260
|
+
const pool = dTag !== void 0 ? candidates : cards;
|
|
2261
|
+
for (const card of pool) {
|
|
2258
2262
|
if (card.payment?.chain === "solana" && card.payment?.address) {
|
|
2259
2263
|
return card;
|
|
2260
2264
|
}
|
|
@@ -2872,17 +2876,18 @@ ${result}`);
|
|
|
2872
2876
|
return errorResult(error instanceof Error ? error.message : String(error));
|
|
2873
2877
|
}
|
|
2874
2878
|
const agent = ctx.active();
|
|
2875
|
-
|
|
2879
|
+
const index = input.attachment_index;
|
|
2880
|
+
let attachments = [];
|
|
2876
2881
|
if (agent.agentDir !== void 0) {
|
|
2877
2882
|
const entry = await findCustomerJob(agent.agentDir, input.job_event_id);
|
|
2878
2883
|
if (entry?.attachmentJson !== void 0) {
|
|
2879
2884
|
try {
|
|
2880
|
-
|
|
2885
|
+
attachments = [JSON.parse(entry.attachmentJson)];
|
|
2881
2886
|
} catch {
|
|
2882
2887
|
}
|
|
2883
2888
|
}
|
|
2884
2889
|
}
|
|
2885
|
-
if (
|
|
2890
|
+
if (attachments.length === 0 || index >= attachments.length) {
|
|
2886
2891
|
try {
|
|
2887
2892
|
const results = await agent.client.marketplace.queryJobResults(
|
|
2888
2893
|
agent.identity,
|
|
@@ -2891,7 +2896,7 @@ ${result}`);
|
|
|
2891
2896
|
);
|
|
2892
2897
|
const resultEntry = results.get(input.job_event_id);
|
|
2893
2898
|
if (resultEntry !== void 0 && !resultEntry.decryptionFailed) {
|
|
2894
|
-
|
|
2899
|
+
attachments = attachmentsOf(decodeJobPayload(resultEntry.content));
|
|
2895
2900
|
}
|
|
2896
2901
|
} catch (error) {
|
|
2897
2902
|
logger.warn(
|
|
@@ -2900,11 +2905,17 @@ ${result}`);
|
|
|
2900
2905
|
);
|
|
2901
2906
|
}
|
|
2902
2907
|
}
|
|
2903
|
-
if (
|
|
2908
|
+
if (attachments.length === 0) {
|
|
2904
2909
|
return errorResult(
|
|
2905
2910
|
`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.`
|
|
2906
2911
|
);
|
|
2907
2912
|
}
|
|
2913
|
+
const attachment = attachments[index];
|
|
2914
|
+
if (attachment === void 0) {
|
|
2915
|
+
return errorResult(
|
|
2916
|
+
`attachment_index ${index} is out of range - this result has ${attachments.length} file(s) (valid indexes 0-${attachments.length - 1}).`
|
|
2917
|
+
);
|
|
2918
|
+
}
|
|
2908
2919
|
const irohTransport = attachment.transports.find((transport) => transport.kind === "iroh");
|
|
2909
2920
|
if (irohTransport === void 0) {
|
|
2910
2921
|
return errorResult("Result attachment has no supported transport (iroh).");
|
|
@@ -2927,7 +2938,8 @@ ${result}`);
|
|
|
2927
2938
|
}).catch(() => {
|
|
2928
2939
|
});
|
|
2929
2940
|
}
|
|
2930
|
-
|
|
2941
|
+
const more = attachments.length > 1 ? ` (file ${index + 1} of ${attachments.length}; fetch others with attachment_index=0..${attachments.length - 1})` : "";
|
|
2942
|
+
return textResult(`Downloaded result file "${attachment.name}" to ${outputPath}${more}.`);
|
|
2931
2943
|
}
|
|
2932
2944
|
}),
|
|
2933
2945
|
defineTool({
|
|
@@ -3516,6 +3528,7 @@ async function removeContact(agentDir, pubkey) {
|
|
|
3516
3528
|
|
|
3517
3529
|
// src/tools/discovery.ts
|
|
3518
3530
|
var SEARCH_PING_TIMEOUT_MS = 3e3;
|
|
3531
|
+
var MAX_SEARCH_CANDIDATES = 100;
|
|
3519
3532
|
var STOP_WORDS = /* @__PURE__ */ new Set([
|
|
3520
3533
|
"a",
|
|
3521
3534
|
"an",
|
|
@@ -3646,7 +3659,7 @@ var STOP_WORDS = /* @__PURE__ */ new Set([
|
|
|
3646
3659
|
"provides"
|
|
3647
3660
|
]);
|
|
3648
3661
|
var SearchAgentsSchema = z.object({
|
|
3649
|
-
capabilities: z.array(z.string()).min(1).describe("OR-matched substring filter on agent names, descriptions, and capability tags."),
|
|
3662
|
+
capabilities: z.array(z.string().min(1)).min(1).describe("OR-matched substring filter on agent names, descriptions, and capability tags."),
|
|
3650
3663
|
query: z.string().optional().describe("Optional secondary scoring for re-ranking. Omit when you have precise tokens."),
|
|
3651
3664
|
max_price_lamports: z.number().int().optional(),
|
|
3652
3665
|
include_offline: z.boolean().default(false).describe(
|
|
@@ -3704,6 +3717,11 @@ var discoveryTools = [
|
|
|
3704
3717
|
)
|
|
3705
3718
|
);
|
|
3706
3719
|
}
|
|
3720
|
+
const matchedCount = filtered.length;
|
|
3721
|
+
const truncated = matchedCount > MAX_SEARCH_CANDIDATES;
|
|
3722
|
+
if (truncated) {
|
|
3723
|
+
filtered = filtered.slice(0, MAX_SEARCH_CANDIDATES);
|
|
3724
|
+
}
|
|
3707
3725
|
if (!include_offline && filtered.length > 0) {
|
|
3708
3726
|
const probes = await Promise.allSettled(
|
|
3709
3727
|
filtered.map(
|
|
@@ -3811,6 +3829,7 @@ var discoveryTools = [
|
|
|
3811
3829
|
// gate anything - it just tells the caller a file input is expected.
|
|
3812
3830
|
// Already length-bounded by parseCapabilityEvent.
|
|
3813
3831
|
...card.inputMime ? { input_mime: card.inputMime } : {},
|
|
3832
|
+
...card.inputText ? { input_text: card.inputText } : {},
|
|
3814
3833
|
...card.outputMime ? { output_mime: card.outputMime } : {}
|
|
3815
3834
|
};
|
|
3816
3835
|
}),
|
|
@@ -3822,6 +3841,13 @@ var discoveryTools = [
|
|
|
3822
3841
|
};
|
|
3823
3842
|
});
|
|
3824
3843
|
const { text } = sanitizeUntrusted(JSON.stringify(results, null, 2), "structured");
|
|
3844
|
+
if (truncated) {
|
|
3845
|
+
return textResult(
|
|
3846
|
+
`Matched ${matchedCount} agents; only the first ${MAX_SEARCH_CANDIDATES} were probed for availability (online-ping cap). Use more specific \`capabilities\` tokens for full coverage.
|
|
3847
|
+
|
|
3848
|
+
` + text
|
|
3849
|
+
);
|
|
3850
|
+
}
|
|
3825
3851
|
return textResult(text);
|
|
3826
3852
|
}
|
|
3827
3853
|
}),
|