@yanlinglabs/winter-agent-runtime 0.0.32 → 0.0.34
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 +6 -6
- package/dist/embedded.js +6 -6
- package/dist/hooks/runner.d.ts +12 -1
- package/dist/{index-y8vfq85w.js → index-1bcfabm4.js} +2 -2
- package/dist/{index-9s68t0pd.js → index-1hef2gff.js} +43 -8
- package/dist/{index-bgeqc7ax.js → index-2wgfv0pa.js} +1 -1
- package/dist/{index-yg5ve6sg.js → index-dske1c00.js} +2 -2
- package/dist/{index-z6s3r4xm.js → index-mwew595z.js} +32 -1
- package/dist/{index-qdang0ag.js → index-rprst8z5.js} +14712 -14596
- package/dist/index.d.ts +3 -0
- package/dist/index.js +8 -4
- package/dist/mcp/client.d.ts +5 -0
- package/dist/mcp/elicitation.d.ts +11 -2
- package/dist/mcp-auth.js +2 -2
- package/dist/mcp-client.js +2 -2
- package/dist/permissions/evaluator.d.ts +7 -1
- package/dist/provider/keychain-store.d.ts +2 -2
- package/dist/store/dialect.d.ts +1 -1
- package/dist/testing.js +5 -5
- 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-rprst8z5.js";
|
|
2
2
|
import {
|
|
3
3
|
liveProcessGroups,
|
|
4
4
|
onProcessGroupChange
|
|
5
|
-
} from "./index-
|
|
6
|
-
import"./index-
|
|
7
|
-
import"./index-
|
|
5
|
+
} from "./index-1hef2gff.js";
|
|
6
|
+
import"./index-mwew595z.js";
|
|
7
|
+
import"./index-2wgfv0pa.js";
|
|
8
8
|
import"./index-bef62z3r.js";
|
|
9
|
-
import"./index-
|
|
9
|
+
import"./index-dske1c00.js";
|
|
10
10
|
import {
|
|
11
11
|
runEmbeddedSession2
|
|
12
|
-
} from "./index-
|
|
12
|
+
} from "./index-1bcfabm4.js";
|
|
13
13
|
import {
|
|
14
14
|
Queue
|
|
15
15
|
} from "./index-97t2rmtf.js";
|
package/dist/embedded.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
2
|
runEmbeddedSession2
|
|
3
|
-
} from "./index-
|
|
4
|
-
import"./index-
|
|
5
|
-
import"./index-
|
|
6
|
-
import"./index-
|
|
3
|
+
} from "./index-1bcfabm4.js";
|
|
4
|
+
import"./index-dske1c00.js";
|
|
5
|
+
import"./index-rprst8z5.js";
|
|
6
|
+
import"./index-2wgfv0pa.js";
|
|
7
7
|
import"./index-bef62z3r.js";
|
|
8
|
-
import"./index-
|
|
9
|
-
import"./index-
|
|
8
|
+
import"./index-1hef2gff.js";
|
|
9
|
+
import"./index-mwew595z.js";
|
|
10
10
|
export {
|
|
11
11
|
runEmbeddedSession2 as runEmbeddedSession
|
|
12
12
|
};
|
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
|
}
|
|
@@ -9,14 +9,14 @@ import {
|
|
|
9
9
|
resolveEngineSession2,
|
|
10
10
|
resolveProductionWinterHome2,
|
|
11
11
|
resolveProductionStoreHome
|
|
12
|
-
} from "./index-
|
|
12
|
+
} from "./index-rprst8z5.js";
|
|
13
13
|
import {
|
|
14
14
|
registerDefaultChildEngineFactory,
|
|
15
15
|
loadResumedChain,
|
|
16
16
|
buildProductionWiring,
|
|
17
17
|
withAutoSkillPermissions,
|
|
18
18
|
restoreChildRoster
|
|
19
|
-
} from "./index-
|
|
19
|
+
} from "./index-dske1c00.js";
|
|
20
20
|
|
|
21
21
|
// src/embedded.ts
|
|
22
22
|
import { splitFrames, encodeFrame } from "@yanlinglabs/winter-agent-sdk";
|
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
MCP_OAUTH_SESSION_CACHE_MS2,
|
|
5
5
|
readTokenRecordLenient,
|
|
6
6
|
refreshMcpOAuthToken2
|
|
7
|
-
} from "./index-
|
|
7
|
+
} from "./index-mwew595z.js";
|
|
8
8
|
|
|
9
9
|
// src/process-groups.ts
|
|
10
10
|
var live = new Map;
|
|
@@ -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 } : {}
|
|
@@ -85,7 +85,7 @@ import {
|
|
|
85
85
|
providerCredentialRef2,
|
|
86
86
|
createModelClassifier2,
|
|
87
87
|
selectClassifierRoute2
|
|
88
|
-
} from "./index-
|
|
88
|
+
} from "./index-rprst8z5.js";
|
|
89
89
|
import {
|
|
90
90
|
createKeychainCredentialStore,
|
|
91
91
|
createKeychainSecretReader,
|
|
@@ -95,7 +95,7 @@ import {
|
|
|
95
95
|
mcpOAuthTestStoreEnvName,
|
|
96
96
|
resolveSessionMcpOAuthStore,
|
|
97
97
|
createHostBrokeredMcpOAuthStore
|
|
98
|
-
} from "./index-
|
|
98
|
+
} from "./index-mwew595z.js";
|
|
99
99
|
import {
|
|
100
100
|
createInMemoryChannel2
|
|
101
101
|
} from "./index-97t2rmtf.js";
|
|
@@ -421,8 +421,39 @@ import { DEFAULT_KEYCHAIN_SERVICE as DEFAULT_KEYCHAIN_SERVICE2, envName, WINTER_
|
|
|
421
421
|
|
|
422
422
|
// src/provider/keychain-store.ts
|
|
423
423
|
import { CredentialResolutionError, redactRef } from "@yanlinglabs/winter-provider-runtime";
|
|
424
|
-
import { DEFAULT_KEYCHAIN_SERVICE } from "@yanlinglabs/winter-agent-sdk";
|
|
424
|
+
import { DEFAULT_KEYCHAIN_SERVICE, TEST_KEYCHAIN_ENV, TEST_KEYCHAIN_MEMORY } from "@yanlinglabs/winter-agent-sdk";
|
|
425
|
+
var memorySecrets = new Map;
|
|
426
|
+
var memoryKey = (service, name) => `${service}\x00${name}`;
|
|
427
|
+
var MEMORY_SECRETS_BACKEND = {
|
|
428
|
+
async get({ service, name }) {
|
|
429
|
+
return memorySecrets.get(memoryKey(service, name)) ?? null;
|
|
430
|
+
},
|
|
431
|
+
async set({ service, name, value }) {
|
|
432
|
+
memorySecrets.set(memoryKey(service, name), value);
|
|
433
|
+
},
|
|
434
|
+
async delete({ service, name }) {
|
|
435
|
+
return memorySecrets.delete(memoryKey(service, name));
|
|
436
|
+
}
|
|
437
|
+
};
|
|
438
|
+
var memoryBackendAnnounced = false;
|
|
439
|
+
function announceMemoryBackend() {
|
|
440
|
+
if (memoryBackendAnnounced)
|
|
441
|
+
return;
|
|
442
|
+
memoryBackendAnnounced = true;
|
|
443
|
+
try {
|
|
444
|
+
process.stderr.write(`winter: ${TEST_KEYCHAIN_ENV}=${TEST_KEYCHAIN_MEMORY} -- the Keychain is replaced by an in-memory store for this process (test runs only)
|
|
445
|
+
`);
|
|
446
|
+
} catch {}
|
|
447
|
+
}
|
|
425
448
|
function defaultSecretsBackend() {
|
|
449
|
+
const redirect = process.env[TEST_KEYCHAIN_ENV];
|
|
450
|
+
if (redirect !== undefined && redirect !== "") {
|
|
451
|
+
if (redirect === TEST_KEYCHAIN_MEMORY) {
|
|
452
|
+
announceMemoryBackend();
|
|
453
|
+
return MEMORY_SECRETS_BACKEND;
|
|
454
|
+
}
|
|
455
|
+
throw new CredentialResolutionError("io", `${TEST_KEYCHAIN_ENV} is set to an unrecognized value; the only accepted value is "${TEST_KEYCHAIN_MEMORY}" (test runs only) -- unset it to use the Keychain`);
|
|
456
|
+
}
|
|
426
457
|
const secrets = globalThis.Bun?.secrets;
|
|
427
458
|
if (secrets === undefined) {
|
|
428
459
|
throw new CredentialResolutionError("unsupported", "the Keychain credential store requires Bun.secrets, which is unavailable in this runtime");
|