@yanlinglabs/winter-agent-sdk 0.0.39 → 0.0.40
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 +8 -6
- package/dist/options.d.ts +10 -1
- package/dist/protocol/config.d.ts +11 -0
- package/package.json +5 -5
package/dist/index.js
CHANGED
|
@@ -429,13 +429,15 @@ function toWireMcpServers(servers) {
|
|
|
429
429
|
name: cfg.name,
|
|
430
430
|
...cfg.timeout !== undefined ? { timeout: cfg.timeout } : {},
|
|
431
431
|
...isWinterMcpServerInstance(cfg.instance) ? { tools: cfg.instance.listTools() } : {},
|
|
432
|
-
...cfg.toolNames !== undefined ? { toolNames: { ...cfg.toolNames } } : {}
|
|
432
|
+
...cfg.toolNames !== undefined ? { toolNames: { ...cfg.toolNames } } : {},
|
|
433
|
+
...cfg.toolLanes !== undefined ? { toolLanes: { ...cfg.toolLanes } } : {}
|
|
433
434
|
} : cfg;
|
|
434
435
|
}
|
|
435
436
|
return out;
|
|
436
437
|
}
|
|
438
|
+
var ANSWERED_AFTER_CANCEL = new Set(["sdk_mcp_call"]);
|
|
437
439
|
function makeSdkMcpCallHandler(mcpServers) {
|
|
438
|
-
return async (payload) => {
|
|
440
|
+
return async (payload, handlerCtx) => {
|
|
439
441
|
const req = payload;
|
|
440
442
|
const cfg = req.server !== undefined ? mcpServers[req.server] : undefined;
|
|
441
443
|
if (!cfg || cfg.type !== "sdk") {
|
|
@@ -451,7 +453,7 @@ function makeSdkMcpCallHandler(mcpServers) {
|
|
|
451
453
|
};
|
|
452
454
|
}
|
|
453
455
|
try {
|
|
454
|
-
const result = await cfg.instance.callTool(req.tool ?? "", req.arguments ?? {});
|
|
456
|
+
const result = await cfg.instance.callTool(req.tool ?? "", req.arguments ?? {}, ...handlerCtx !== undefined ? [{ signal: handlerCtx.signal }] : []);
|
|
455
457
|
return { ok: true, payload: result };
|
|
456
458
|
} catch (err) {
|
|
457
459
|
const message = err instanceof Error ? err.message : String(err);
|
|
@@ -895,7 +897,7 @@ function query(args) {
|
|
|
895
897
|
incomingRequestAborts.set(cf.requestId, cancel);
|
|
896
898
|
try {
|
|
897
899
|
const result = await handler(cf.payload, { signal: cancel.signal });
|
|
898
|
-
if (cancel.signal.aborted)
|
|
900
|
+
if (cancel.signal.aborted && !ANSWERED_AFTER_CANCEL.has(cf.subtype))
|
|
899
901
|
return;
|
|
900
902
|
if (result.ok) {
|
|
901
903
|
writeControlResponse({
|
|
@@ -908,7 +910,7 @@ function query(args) {
|
|
|
908
910
|
writeControlResponse({ type: "control_response", requestId: cf.requestId, ok: false, error: result.error });
|
|
909
911
|
}
|
|
910
912
|
} catch (err) {
|
|
911
|
-
if (cancel.signal.aborted)
|
|
913
|
+
if (cancel.signal.aborted && !ANSWERED_AFTER_CANCEL.has(cf.subtype))
|
|
912
914
|
return;
|
|
913
915
|
const message = err instanceof Error ? err.message : String(err);
|
|
914
916
|
writeControlResponse({ type: "control_response", requestId: cf.requestId, ok: false, error: { code: "handler_threw", message } });
|
|
@@ -1268,7 +1270,7 @@ function withTestKeychainRedirect(env) {
|
|
|
1268
1270
|
return { ...env, [TEST_KEYCHAIN_ENV]: redirect };
|
|
1269
1271
|
}
|
|
1270
1272
|
// src/version.ts
|
|
1271
|
-
var SDK_VERSION = "0.0.
|
|
1273
|
+
var SDK_VERSION = "0.0.40";
|
|
1272
1274
|
// src/paths/project-key.ts
|
|
1273
1275
|
var TRANSCRIPT_PROJECT_KEY_MAX_LENGTH = 64;
|
|
1274
1276
|
var VENDOR_PROJECT_KEY_PATTERN = /^[A-Za-z0-9_-]{1,64}$/;
|
package/dist/options.d.ts
CHANGED
|
@@ -128,7 +128,16 @@ export interface WinterMcpServerInstance {
|
|
|
128
128
|
};
|
|
129
129
|
_meta?: Record<string, unknown>;
|
|
130
130
|
}>;
|
|
131
|
-
|
|
131
|
+
/**
|
|
132
|
+
* `extra.signal` (SDK 0.0.40) is ABORTED when the runtime cancels the call (an interrupted turn sends
|
|
133
|
+
* `control_cancel_request`). A tool that holds an exclusive resource should stop promptly and then return:
|
|
134
|
+
* the runtime keeps the tool's concurrency lane held until this promise settles (or a bounded grace runs
|
|
135
|
+
* out), so the next call of that lane never overlaps a tool still running. Optional: an instance that
|
|
136
|
+
* ignores it behaves as before.
|
|
137
|
+
*/
|
|
138
|
+
callTool(name: string, args: Record<string, unknown>, extra?: {
|
|
139
|
+
signal?: AbortSignal;
|
|
140
|
+
}): Promise<{
|
|
132
141
|
content: unknown[];
|
|
133
142
|
isError?: boolean;
|
|
134
143
|
}>;
|
|
@@ -395,6 +395,17 @@ export interface McpSdkServerConfig {
|
|
|
395
395
|
* host owns it.
|
|
396
396
|
*/
|
|
397
397
|
toolNames?: Record<string, string>;
|
|
398
|
+
/**
|
|
399
|
+
* SDK 0.0.40, a Winter extension: CONCURRENCY LANES for some of this server's tools, keyed by the
|
|
400
|
+
* server's own tool name (`{ computer: "computer", browser: "browser" }`). A round's calls normally run
|
|
401
|
+
* one at a time unless the tool is read-only (`readOnlyHint: true`); a tool in a lane instead runs BESIDE
|
|
402
|
+
* the round's other calls, but never beside another call of the SAME lane -- calls of one lane run one at
|
|
403
|
+
* a time, in call order, across the round. Use it for a tool that holds one exclusive resource (a screen,
|
|
404
|
+
* a browser) yet is safe next to everything else. A call that is neither read-only nor in a lane is a
|
|
405
|
+
* barrier, exactly as before. A lane key is 1-64 characters of `[A-Za-z0-9_.:-]`; anything else is
|
|
406
|
+
* ignored. Only an in-process (`sdk`) server may declare lanes; the host vouches for its own tools.
|
|
407
|
+
*/
|
|
408
|
+
toolLanes?: Record<string, string>;
|
|
398
409
|
}
|
|
399
410
|
export type McpServerConfigForProcessTransport = McpStdioServerConfig | McpHttpServerConfig | McpSSEServerConfig | McpSdkServerConfig;
|
|
400
411
|
export type AgentMcpServerSpec = string | Record<string, McpServerConfigForProcessTransport>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@yanlinglabs/winter-agent-sdk",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.40",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"engines": {
|
|
@@ -45,15 +45,15 @@
|
|
|
45
45
|
}
|
|
46
46
|
},
|
|
47
47
|
"dependencies": {
|
|
48
|
-
"@yanlinglabs/winter-provider-catalog": "0.0.
|
|
48
|
+
"@yanlinglabs/winter-provider-catalog": "0.0.40"
|
|
49
49
|
},
|
|
50
50
|
"optionalDependencies": {
|
|
51
|
-
"@yanlinglabs/winter-agent-sdk-darwin-arm64": "0.0.
|
|
51
|
+
"@yanlinglabs/winter-agent-sdk-darwin-arm64": "0.0.40"
|
|
52
52
|
},
|
|
53
53
|
"devDependencies": {
|
|
54
54
|
"@types/node": "^26.4.0",
|
|
55
|
-
"@yanlinglabs/winter-agent-runtime": "0.0.
|
|
56
|
-
"@yanlinglabs/winter-conformance": "0.0.
|
|
55
|
+
"@yanlinglabs/winter-agent-runtime": "0.0.40",
|
|
56
|
+
"@yanlinglabs/winter-conformance": "0.0.40"
|
|
57
57
|
},
|
|
58
58
|
"scripts": {}
|
|
59
59
|
}
|