@yanlinglabs/winter-agent-runtime 0.0.32 → 0.0.33
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/embedded-worker.js +4 -4
- package/dist/embedded.js +4 -4
- package/dist/hooks/runner.d.ts +12 -1
- package/dist/{index-9s68t0pd.js → index-6edffgta.js} +42 -7
- package/dist/{index-yg5ve6sg.js → index-d2yr5j8d.js} +1 -1
- package/dist/{index-qdang0ag.js → index-tk2cfedd.js} +14710 -14594
- package/dist/{index-y8vfq85w.js → index-vq1x7nc4.js} +2 -2
- package/dist/index.d.ts +3 -0
- package/dist/index.js +6 -2
- package/dist/mcp/client.d.ts +5 -0
- package/dist/mcp/elicitation.d.ts +11 -2
- package/dist/mcp-client.js +1 -1
- package/dist/permissions/evaluator.d.ts +7 -1
- package/dist/store/dialect.d.ts +1 -1
- package/dist/testing.js +3 -3
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/dist/workflows/runtime.d.ts +21 -0
- package/package.json +4 -4
package/dist/embedded-worker.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import"./index-
|
|
1
|
+
import"./index-tk2cfedd.js";
|
|
2
2
|
import {
|
|
3
3
|
liveProcessGroups,
|
|
4
4
|
onProcessGroupChange
|
|
5
|
-
} from "./index-
|
|
5
|
+
} from "./index-6edffgta.js";
|
|
6
6
|
import"./index-z6s3r4xm.js";
|
|
7
7
|
import"./index-bgeqc7ax.js";
|
|
8
8
|
import"./index-bef62z3r.js";
|
|
9
|
-
import"./index-
|
|
9
|
+
import"./index-d2yr5j8d.js";
|
|
10
10
|
import {
|
|
11
11
|
runEmbeddedSession2
|
|
12
|
-
} from "./index-
|
|
12
|
+
} from "./index-vq1x7nc4.js";
|
|
13
13
|
import {
|
|
14
14
|
Queue
|
|
15
15
|
} from "./index-97t2rmtf.js";
|
package/dist/embedded.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import {
|
|
2
2
|
runEmbeddedSession2
|
|
3
|
-
} from "./index-
|
|
4
|
-
import"./index-
|
|
5
|
-
import"./index-
|
|
3
|
+
} from "./index-vq1x7nc4.js";
|
|
4
|
+
import"./index-d2yr5j8d.js";
|
|
5
|
+
import"./index-tk2cfedd.js";
|
|
6
6
|
import"./index-bgeqc7ax.js";
|
|
7
7
|
import"./index-bef62z3r.js";
|
|
8
|
-
import"./index-
|
|
8
|
+
import"./index-6edffgta.js";
|
|
9
9
|
import"./index-z6s3r4xm.js";
|
|
10
10
|
export {
|
|
11
11
|
runEmbeddedSession2 as runEmbeddedSession
|
package/dist/hooks/runner.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { HookEvent, HookPermissionDecision } from "@yanlinglabs/winter-agent-sdk";
|
|
1
|
+
import type { HookEvent, HookPermissionDecision, McpServerIdentity } from "@yanlinglabs/winter-agent-sdk";
|
|
2
2
|
import { type HookRegistry } from "./registry.js";
|
|
3
3
|
import { type HookComposite } from "./reducer.js";
|
|
4
4
|
import type { AsyncHookQueue } from "./async-hooks.js";
|
|
@@ -17,6 +17,12 @@ export interface HookInvocationRequest {
|
|
|
17
17
|
*/
|
|
18
18
|
mcpServerName?: string;
|
|
19
19
|
mcpToolName?: string;
|
|
20
|
+
/**
|
|
21
|
+
* WS-27: the exact server identity (`mcpServerIdentity` below) -- PreToolUse/PostToolUse/
|
|
22
|
+
* PostToolUseFailure only (`MCP_SERVER_IDENTITY_EVENTS`). Both input builders turn it into
|
|
23
|
+
* `winter_mcp_server`.
|
|
24
|
+
*/
|
|
25
|
+
mcpServer?: McpServerIdentity;
|
|
20
26
|
input?: Record<string, unknown>;
|
|
21
27
|
payload?: unknown;
|
|
22
28
|
policyVersion: string;
|
|
@@ -29,6 +35,9 @@ export interface McpToolProvenanceInfo {
|
|
|
29
35
|
tool: string;
|
|
30
36
|
}
|
|
31
37
|
export declare function mcpToolProvenance(toolName: string): McpToolProvenanceInfo | undefined;
|
|
38
|
+
export declare function mcpServerIdentity(toolName: string, renames?: Readonly<Record<string, string>>): McpServerIdentity | undefined;
|
|
39
|
+
/** The events whose input carries `winter_mcp_server` (the pinned WS-27 contract). */
|
|
40
|
+
export declare const MCP_SERVER_IDENTITY_EVENTS: ReadonlySet<HookEvent>;
|
|
32
41
|
export interface HookInvoker {
|
|
33
42
|
invoke(request: HookInvocationRequest, opts: {
|
|
34
43
|
signal: AbortSignal;
|
|
@@ -77,6 +86,8 @@ export declare function isGatingHookEvent(event: HookEvent): boolean;
|
|
|
77
86
|
export interface RunHooksCallInfo {
|
|
78
87
|
toolUseID?: string;
|
|
79
88
|
toolName?: string;
|
|
89
|
+
/** WS-27: the called tool's server identity, as the ENGINE computed it (`mcpServerIdentity`, from the name the model called). Never derived here. */
|
|
90
|
+
mcpServer?: McpServerIdentity;
|
|
80
91
|
input?: Record<string, unknown>;
|
|
81
92
|
payload?: unknown;
|
|
82
93
|
}
|
|
@@ -46,6 +46,7 @@ function onProcessGroupChange(listener) {
|
|
|
46
46
|
// src/mcp/elicitation.ts
|
|
47
47
|
var MCP_ELICITATION_SUBTYPE = "mcp_elicitation";
|
|
48
48
|
var DETERMINISTIC_DECLINE = { action: "decline" };
|
|
49
|
+
var CANCELLED = { action: "cancel" };
|
|
49
50
|
function isElicitationAction(value) {
|
|
50
51
|
return value === "accept" || value === "decline" || value === "cancel";
|
|
51
52
|
}
|
|
@@ -64,11 +65,17 @@ function createElicitationAsker2(sender) {
|
|
|
64
65
|
if (!sender) {
|
|
65
66
|
return async () => DETERMINISTIC_DECLINE;
|
|
66
67
|
}
|
|
67
|
-
return async (payload) => {
|
|
68
|
+
return async (payload, opts) => {
|
|
69
|
+
const signal = opts?.signal;
|
|
70
|
+
const cancelled = () => signal?.aborted === true;
|
|
71
|
+
if (cancelled())
|
|
72
|
+
return CANCELLED;
|
|
68
73
|
let raw;
|
|
69
74
|
try {
|
|
70
|
-
raw = await sender.request(MCP_ELICITATION_SUBTYPE, payload);
|
|
75
|
+
raw = await sender.request(MCP_ELICITATION_SUBTYPE, payload, signal !== undefined ? { signal } : undefined);
|
|
71
76
|
} catch {
|
|
77
|
+
if (cancelled())
|
|
78
|
+
return CANCELLED;
|
|
72
79
|
return DETERMINISTIC_DECLINE;
|
|
73
80
|
}
|
|
74
81
|
return toResultPayload(raw);
|
|
@@ -94,10 +101,12 @@ function rawElicitParamsOf(params) {
|
|
|
94
101
|
...p.requestedSchema !== undefined ? { requestedSchema: p.requestedSchema } : {}
|
|
95
102
|
};
|
|
96
103
|
}
|
|
97
|
-
function installElicitationHandler(client, serverName, ask) {
|
|
98
|
-
client.setRequestHandler("elicitation/create", async (request) => {
|
|
104
|
+
function installElicitationHandler(client, serverName, ask, callScope) {
|
|
105
|
+
client.setRequestHandler("elicitation/create", async (request, ctx) => {
|
|
99
106
|
const payload = buildElicitationPayload(serverName, rawElicitParamsOf(request.params));
|
|
100
|
-
const
|
|
107
|
+
const signals = [ctx?.mcpReq?.signal, callScope?.()].filter((s) => s !== undefined);
|
|
108
|
+
const signal = signals.length === 0 ? undefined : signals.length === 1 ? signals[0] : AbortSignal.any(signals);
|
|
109
|
+
const result = await ask(payload, signal !== undefined ? { signal } : undefined);
|
|
101
110
|
if (result.content === undefined)
|
|
102
111
|
return { action: result.action };
|
|
103
112
|
const content = toWireElicitContent(result.content);
|
|
@@ -585,7 +594,22 @@ async function connectOnce(opts, mode, connectTimeoutMs, probeTimeoutMs) {
|
|
|
585
594
|
}
|
|
586
595
|
} : {}
|
|
587
596
|
});
|
|
588
|
-
|
|
597
|
+
const callsInFlight = new Set;
|
|
598
|
+
const callScope = () => {
|
|
599
|
+
if (callsInFlight.size === 0)
|
|
600
|
+
return;
|
|
601
|
+
const ended = new AbortController;
|
|
602
|
+
let remaining = callsInFlight.size;
|
|
603
|
+
const settle = () => {
|
|
604
|
+
remaining--;
|
|
605
|
+
if (remaining === 0)
|
|
606
|
+
ended.abort();
|
|
607
|
+
};
|
|
608
|
+
for (const call of callsInFlight)
|
|
609
|
+
call.then(settle, settle);
|
|
610
|
+
return ended.signal;
|
|
611
|
+
};
|
|
612
|
+
installElicitationHandler(client, name, elicitationAsk, callScope);
|
|
589
613
|
await raceConnect(client, transport, connectTimeoutMs);
|
|
590
614
|
const protocolVersion = client.getNegotiatedProtocolVersion();
|
|
591
615
|
let closed = false;
|
|
@@ -629,7 +653,18 @@ async function connectOnce(opts, mode, connectTimeoutMs, probeTimeoutMs) {
|
|
|
629
653
|
});
|
|
630
654
|
},
|
|
631
655
|
async callTool(toolName, args, callOpts) {
|
|
632
|
-
const
|
|
656
|
+
const requestOpts = {
|
|
657
|
+
...callOpts?.timeoutMs !== undefined ? { timeout: callOpts.timeoutMs } : {},
|
|
658
|
+
...callOpts?.signal !== undefined ? { signal: callOpts.signal } : {}
|
|
659
|
+
};
|
|
660
|
+
const call = client.callTool({ name: toolName, arguments: args }, Object.keys(requestOpts).length > 0 ? requestOpts : undefined);
|
|
661
|
+
callsInFlight.add(call);
|
|
662
|
+
let result;
|
|
663
|
+
try {
|
|
664
|
+
result = await call;
|
|
665
|
+
} finally {
|
|
666
|
+
callsInFlight.delete(call);
|
|
667
|
+
}
|
|
633
668
|
return {
|
|
634
669
|
content: result.content ?? [],
|
|
635
670
|
...result.isError === true ? { isError: true } : {}
|