@ctxprotocol/sdk 0.13.1 → 0.15.0
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 +12 -12
- package/dist/client/index.cjs +3 -42
- package/dist/client/index.cjs.map +1 -1
- package/dist/client/index.d.cts +4 -5
- package/dist/client/index.d.ts +4 -5
- package/dist/client/index.js +3 -42
- package/dist/client/index.js.map +1 -1
- package/dist/contrib/search/index.d.cts +2 -2
- package/dist/contrib/search/index.d.ts +2 -2
- package/dist/index.cjs +3 -42
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +10 -1
- package/dist/index.d.ts +10 -1
- package/dist/index.js +3 -42
- package/dist/index.js.map +1 -1
- package/dist/{types-BStHo4tI.d.cts → types-jbYPIQxq.d.cts} +155 -107
- package/dist/{types-BStHo4tI.d.ts → types-jbYPIQxq.d.ts} +155 -107
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,32 +1,32 @@
|
|
|
1
1
|
# @ctxprotocol/sdk
|
|
2
2
|
|
|
3
|
-
**
|
|
3
|
+
**Grounded context for your AI agents — on demand.**
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
Give your agent the live facts it's missing. Context is a pay-per-response data marketplace: your agent discovers tools at runtime, buys the data its question needs, and drops it straight into its context window — no API keys, no servers, no per-source integration work.
|
|
6
6
|
|
|
7
|
-
Context Protocol is **npm for AI capabilities**. Just as you install packages to add functionality to your code, use the Context SDK to give your Agent instant access to
|
|
7
|
+
Context Protocol is **npm for AI capabilities**. Just as you install packages to add functionality to your code, use the Context SDK to give your Agent instant access to premium data feeds and live tools: the market intelligence usually locked behind steep monthly or annual subscriptions, unbundled into pay-per-response, from crypto and on-chain analytics to gas oracles, weather, and search.
|
|
8
8
|
|
|
9
9
|
[](https://www.npmjs.com/package/@ctxprotocol/sdk)
|
|
10
10
|
[](https://opensource.org/licenses/MIT)
|
|
11
11
|
|
|
12
12
|
---
|
|
13
13
|
|
|
14
|
-
###
|
|
14
|
+
### Contributors
|
|
15
15
|
|
|
16
|
-
|
|
16
|
+
List MCP tools on the permissionless Context marketplace and keep **90% of usage fees** in USDC.
|
|
17
17
|
|
|
18
|
-
-
|
|
19
|
-
-
|
|
20
|
-
-
|
|
18
|
+
- **Build:** Create an MCP server with this SDK
|
|
19
|
+
- **List:** Register at [ctxprotocol.com/contribute](https://ctxprotocol.com/contribute)
|
|
20
|
+
- **Earn:** Revenue share on every Query response and eligible Execute call
|
|
21
21
|
|
|
22
|
-
|
|
22
|
+
Grant batches open periodically — see [Developer Grants](https://docs.ctxprotocol.com/grants) for current batch status and contributor guidance.
|
|
23
23
|
|
|
24
24
|
---
|
|
25
25
|
|
|
26
26
|
## Why use Context?
|
|
27
27
|
|
|
28
28
|
- **🔌 One Interface, Everything:** Stop integrating APIs one by one. Use a single SDK to access any tool in the marketplace.
|
|
29
|
-
- **🧠 Zero-Ops:** We're
|
|
29
|
+
- **🧠 Zero-Ops:** We're the gateway to premium data feeds usually locked behind steep subscriptions. We host the connections; you just send the JSON and get the result.
|
|
30
30
|
- **⚡️ Agentic Discovery:** Your Agent can search the marketplace at runtime to find tools it didn't know it needed.
|
|
31
31
|
- **💸 Dual-Surface Economics:** Use Query for pay-per-response intelligence or Execute for session-budgeted method calls.
|
|
32
32
|
|
|
@@ -96,7 +96,7 @@ const result = await client.tools.execute({
|
|
|
96
96
|
console.log(result.session); // methodPrice, spent, remaining, maxSpend, ...
|
|
97
97
|
```
|
|
98
98
|
|
|
99
|
-
**Query mode** gives you a managed librarian contract — the server runs the live pipeline (`discover -> select -> metadata scout ->
|
|
99
|
+
**Query mode** gives you a managed librarian contract — the server runs the live pipeline (`discover -> select -> metadata scout -> iterative execute -> synthesize -> settle`) with model-aware context budgeting and can return plain answers or structured evidence packages for one flat fee:
|
|
100
100
|
```typescript
|
|
101
101
|
const answer = await client.query.run({
|
|
102
102
|
query: "What are the top whale movements on Base?",
|
|
@@ -417,7 +417,7 @@ const closed = await client.tools.closeSession("sess_123");
|
|
|
417
417
|
|
|
418
418
|
#### `client.query.run(options)`
|
|
419
419
|
|
|
420
|
-
Run an agentic query. The server applies the live librarian pipeline (`discover -> select -> metadata scout ->
|
|
420
|
+
Run an agentic query. The server applies the live librarian pipeline (`discover -> select -> metadata scout -> iterative execute -> synthesize -> settle`) with up to 100 MCP calls per response turn, then returns the selected Query response contract (`answer`, `answer_with_evidence`, or `evidence_only`).
|
|
421
421
|
|
|
422
422
|
The query runtime now exposes a single managed executor surface.
|
|
423
423
|
The server decides internal budgets, ambiguity handling, and exploration policy
|
package/dist/client/index.cjs
CHANGED
|
@@ -53,9 +53,9 @@ var Developer = class {
|
|
|
53
53
|
if (!toolId) {
|
|
54
54
|
throw new ContextError("toolId is required");
|
|
55
55
|
}
|
|
56
|
-
if (updates.name === void 0 && updates.description === void 0 && updates.category === void 0) {
|
|
56
|
+
if (updates.name === void 0 && updates.description === void 0 && updates.suggestedPrompts === void 0 && updates.category === void 0) {
|
|
57
57
|
throw new ContextError(
|
|
58
|
-
"At least one field required: name, description, or category"
|
|
58
|
+
"At least one field required: name, description, suggestedPrompts, or category"
|
|
59
59
|
);
|
|
60
60
|
}
|
|
61
61
|
if (updates.category !== void 0 && updates.category !== null && !ALLOWED_TOOL_CATEGORIES.includes(updates.category)) {
|
|
@@ -304,9 +304,6 @@ var Query = class {
|
|
|
304
304
|
}
|
|
305
305
|
normalizeResult(result) {
|
|
306
306
|
const candidate = result;
|
|
307
|
-
if (candidate.outcomeType === "clarification_required" && "clarification" in candidate && candidate.clarification) {
|
|
308
|
-
return candidate;
|
|
309
|
-
}
|
|
310
307
|
if (candidate.outcomeType === "capability_miss" && "capabilityMiss" in candidate && candidate.capabilityMiss) {
|
|
311
308
|
return candidate;
|
|
312
309
|
}
|
|
@@ -315,34 +312,6 @@ var Query = class {
|
|
|
315
312
|
outcomeType: "answer"
|
|
316
313
|
};
|
|
317
314
|
}
|
|
318
|
-
buildPolicyErrorEvent(params) {
|
|
319
|
-
if (params.clarificationPolicy !== "error") {
|
|
320
|
-
return;
|
|
321
|
-
}
|
|
322
|
-
if (params.result.outcomeType === "clarification_required") {
|
|
323
|
-
return {
|
|
324
|
-
type: "error",
|
|
325
|
-
error: params.result.response,
|
|
326
|
-
code: "clarification_required",
|
|
327
|
-
reasonCode: "clarification_required",
|
|
328
|
-
outcomeType: "clarification_required",
|
|
329
|
-
clarification: params.result.clarification,
|
|
330
|
-
querySession: params.result.querySession
|
|
331
|
-
};
|
|
332
|
-
}
|
|
333
|
-
if (params.result.outcomeType === "capability_miss") {
|
|
334
|
-
return {
|
|
335
|
-
type: "error",
|
|
336
|
-
error: params.result.response,
|
|
337
|
-
code: "capability_miss",
|
|
338
|
-
reasonCode: "capability_miss",
|
|
339
|
-
outcomeType: "capability_miss",
|
|
340
|
-
capabilityMiss: params.result.capabilityMiss,
|
|
341
|
-
querySession: params.result.querySession
|
|
342
|
-
};
|
|
343
|
-
}
|
|
344
|
-
return void 0;
|
|
345
|
-
}
|
|
346
315
|
buildSyntheticTraceFromRunResult(params) {
|
|
347
316
|
const timeline = params.toolsUsed.map((tool, index) => ({
|
|
348
317
|
stepType: "tool-call",
|
|
@@ -556,7 +525,6 @@ var Query = class {
|
|
|
556
525
|
tools: opts.tools,
|
|
557
526
|
resumeFrom: opts.resumeFrom,
|
|
558
527
|
forkFrom: opts.forkFrom,
|
|
559
|
-
clarificationPolicy: opts.clarificationPolicy,
|
|
560
528
|
answerModelId: opts.answerModelId,
|
|
561
529
|
responseShape: opts.responseShape,
|
|
562
530
|
favoritesOnly: opts.favoritesOnly,
|
|
@@ -614,13 +582,6 @@ var Query = class {
|
|
|
614
582
|
normalizedResult.developerTrace = mergedTrace;
|
|
615
583
|
}
|
|
616
584
|
event.result = normalizedResult;
|
|
617
|
-
const policyErrorEvent = this.buildPolicyErrorEvent({
|
|
618
|
-
result: normalizedResult,
|
|
619
|
-
clarificationPolicy: opts.clarificationPolicy
|
|
620
|
-
});
|
|
621
|
-
if (policyErrorEvent) {
|
|
622
|
-
return policyErrorEvent;
|
|
623
|
-
}
|
|
624
585
|
}
|
|
625
586
|
return event;
|
|
626
587
|
};
|
|
@@ -691,7 +652,7 @@ var ContextClient = class {
|
|
|
691
652
|
*
|
|
692
653
|
* Unlike `tools.execute()` which calls a single tool once, `query` sends
|
|
693
654
|
* a natural-language question and lets the server handle discovery,
|
|
694
|
-
* metadata scout,
|
|
655
|
+
* metadata scout, iterative execution, and AI synthesis —
|
|
695
656
|
* one flat fee.
|
|
696
657
|
*/
|
|
697
658
|
query;
|