@yanlinglabs/winter-agent-sdk 0.0.31 → 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/index.d.ts +2 -2
- package/dist/index.js +12 -3
- package/dist/permissions/types.d.ts +44 -3
- package/package.json +5 -5
package/dist/index.d.ts
CHANGED
|
@@ -50,9 +50,9 @@ export type { SettingSource, ResolvedSettingSource, PolicySettingsOrigin, Settin
|
|
|
50
50
|
export type { WorkspaceTrustFilterOptions } from "./settings/resolve.js";
|
|
51
51
|
export type { PermissionMode, PermissionBehavior, PermissionRuleValue } from "./permissions/types.js";
|
|
52
52
|
export type { PermissionUpdate, PermissionUpdateDestination, RuleSource } from "./permissions/types.js";
|
|
53
|
-
export type { CanUseTool, PermissionResult, PermissionDecisionClassification, PermissionRequestPayload } from "./permissions/types.js";
|
|
53
|
+
export type { CanUseTool, McpServerIdentity, PermissionResult, PermissionDecisionClassification, PermissionRequestPayload } from "./permissions/types.js";
|
|
54
54
|
export { HOOK_EVENTS } from "./permissions/types.js";
|
|
55
|
-
export type { HookEvent, HookEventName, HookSource, HookPermissionDecision, BaseHookInput, McpToolProvenance, PreToolUseHookInput, PostToolUseHookInput, PostToolUseFailureHookInput, UserPromptSubmitHookInput, StopHookInput, SessionStartHookInput, SessionEndHookInput, NotificationHookInput, PermissionRequestHookInput, PermissionDeniedHookInput, SubagentStartHookInput, SubagentStopHookInput, GenericHookInput, HookInput, AsyncHookJSONOutput, SyncHookJSONOutput, HookJSONOutput, PreToolUseHookSpecificOutput, PostToolUseHookSpecificOutput, PostToolUseFailureHookSpecificOutput, UserPromptSubmitHookSpecificOutput, StopHookSpecificOutput, SubagentStartHookSpecificOutput, SubagentStopHookSpecificOutput, SessionStartHookSpecificOutput, NotificationHookSpecificOutput, PermissionRequestHookSpecificOutput, PermissionDeniedHookSpecificOutput, GenericHookSpecificOutput, HookSpecificOutput, HookCallback, HookCallbackMatcher, HookInvocationPayload, } from "./permissions/types.js";
|
|
55
|
+
export type { HookEvent, HookEventName, HookSource, HookPermissionDecision, BaseHookInput, McpToolProvenance, WinterMcpServerHookField, PreToolUseHookInput, PostToolUseHookInput, PostToolUseFailureHookInput, UserPromptSubmitHookInput, StopHookInput, SessionStartHookInput, SessionEndHookInput, NotificationHookInput, PermissionRequestHookInput, PermissionDeniedHookInput, SubagentStartHookInput, SubagentStopHookInput, GenericHookInput, HookInput, AsyncHookJSONOutput, SyncHookJSONOutput, HookJSONOutput, PreToolUseHookSpecificOutput, PostToolUseHookSpecificOutput, PostToolUseFailureHookSpecificOutput, UserPromptSubmitHookSpecificOutput, StopHookSpecificOutput, SubagentStartHookSpecificOutput, SubagentStopHookSpecificOutput, SessionStartHookSpecificOutput, NotificationHookSpecificOutput, PermissionRequestHookSpecificOutput, PermissionDeniedHookSpecificOutput, GenericHookSpecificOutput, HookSpecificOutput, HookCallback, HookCallbackMatcher, HookInvocationPayload, } from "./permissions/types.js";
|
|
56
56
|
export { CATALOG_TAG_RENAMES } from "@yanlinglabs/winter-provider-catalog";
|
|
57
57
|
export { PluginManagerError, listMarketplaces, addMarketplace, removeMarketplace, updateMarketplace, installPlugin, uninstallPlugin, setPluginEnabled, updatePlugin, listPlugins } from "./plugins/manage.js";
|
|
58
58
|
export type { PluginScope, PluginManagerOptions, MarketplaceInfo, InstalledPlugin, PluginListing } from "./plugins/manage.js";
|
package/dist/index.js
CHANGED
|
@@ -448,13 +448,17 @@ function makeSdkMcpCallHandler(mcpServers) {
|
|
|
448
448
|
};
|
|
449
449
|
}
|
|
450
450
|
function makeElicitationHandler(onElicitation, abortController) {
|
|
451
|
-
return async (payload) => {
|
|
451
|
+
return async (payload, handlerCtx) => {
|
|
452
452
|
const req = payload;
|
|
453
453
|
const controller = new AbortController;
|
|
454
454
|
if (abortController?.signal.aborted)
|
|
455
455
|
controller.abort();
|
|
456
456
|
else
|
|
457
457
|
abortController?.signal.addEventListener("abort", () => controller.abort(), { once: true });
|
|
458
|
+
if (handlerCtx?.signal.aborted === true)
|
|
459
|
+
controller.abort();
|
|
460
|
+
else
|
|
461
|
+
handlerCtx?.signal.addEventListener("abort", () => controller.abort(), { once: true });
|
|
458
462
|
let result;
|
|
459
463
|
try {
|
|
460
464
|
result = await onElicitation({
|
|
@@ -565,6 +569,9 @@ function buildRuntimeHooksConfig(hooks) {
|
|
|
565
569
|
}
|
|
566
570
|
return Object.keys(out).length > 0 ? out : undefined;
|
|
567
571
|
}
|
|
572
|
+
function winterMcpServerHookField(server) {
|
|
573
|
+
return { name: server.name, config_name: server.configName, ...server.readOnlyHint !== undefined ? { read_only_hint: server.readOnlyHint } : {} };
|
|
574
|
+
}
|
|
568
575
|
function buildHookInput(req, cwd) {
|
|
569
576
|
const payload = req.payload ?? {};
|
|
570
577
|
return {
|
|
@@ -576,6 +583,7 @@ function buildHookInput(req, cwd) {
|
|
|
576
583
|
...req.toolName !== undefined ? { tool_name: req.toolName } : {},
|
|
577
584
|
...req.mcpServerName !== undefined ? { mcp_server_name: req.mcpServerName } : {},
|
|
578
585
|
...req.mcpToolName !== undefined ? { mcp_tool_name: req.mcpToolName } : {},
|
|
586
|
+
...req.mcpServer !== undefined ? { winter_mcp_server: winterMcpServerHookField(req.mcpServer) } : {},
|
|
579
587
|
...req.input !== undefined ? { tool_input: req.input } : {},
|
|
580
588
|
...req.toolUseID !== undefined ? { tool_use_id: req.toolUseID } : {},
|
|
581
589
|
...payload
|
|
@@ -810,7 +818,8 @@ function query(args) {
|
|
|
810
818
|
toolUseID: req.toolUseID,
|
|
811
819
|
...req.agentID !== undefined ? { agentID: req.agentID } : {},
|
|
812
820
|
requestId: req.requestId,
|
|
813
|
-
...req.matchedAskRule !== undefined ? { matchedAskRule: req.matchedAskRule } : {}
|
|
821
|
+
...req.matchedAskRule !== undefined ? { matchedAskRule: req.matchedAskRule } : {},
|
|
822
|
+
...req.mcpServer !== undefined ? { mcpServer: req.mcpServer } : {}
|
|
814
823
|
});
|
|
815
824
|
} catch (err) {
|
|
816
825
|
const message = err instanceof Error ? err.message : String(err);
|
|
@@ -1119,7 +1128,7 @@ function query(args) {
|
|
|
1119
1128
|
return gen;
|
|
1120
1129
|
}
|
|
1121
1130
|
// src/version.ts
|
|
1122
|
-
var SDK_VERSION = "0.0.
|
|
1131
|
+
var SDK_VERSION = "0.0.33";
|
|
1123
1132
|
// src/paths/project-key.ts
|
|
1124
1133
|
var TRANSCRIPT_PROJECT_KEY_MAX_LENGTH = 64;
|
|
1125
1134
|
var VENDOR_PROJECT_KEY_PATTERN = /^[A-Za-z0-9_-]{1,64}$/;
|
|
@@ -34,6 +34,31 @@ export type PermissionUpdate = {
|
|
|
34
34
|
};
|
|
35
35
|
export type PermissionUpdateDestination = "userSettings" | "projectSettings" | "localSettings" | "session" | "cliArg";
|
|
36
36
|
export type RuleSource = "managed" | "user" | "project" | "local" | "cliArg" | "session" | "sdk";
|
|
37
|
+
/**
|
|
38
|
+
* WS-27 (Winter-only): WHICH MCP SERVER a tool call is for, stated exactly by the runtime -- on
|
|
39
|
+
* `canUseTool`'s options as `mcpServer`, and on the PreToolUse / PostToolUse / PostToolUseFailure hook
|
|
40
|
+
* input as `winter_mcp_server` (`WinterMcpServerHookField`, the same facts in snake_case). Present when
|
|
41
|
+
* the tool belongs to a connected MCP server (a stdio/http/sse server, or a host's in-process `sdk` one);
|
|
42
|
+
* absent for every other tool, and on an older runtime -- a host keeps its own resolver as the fallback.
|
|
43
|
+
*
|
|
44
|
+
* - `name`: the server's name as it appears in the tool name `mcp__<name>__<tool>` -- AFTER any rename.
|
|
45
|
+
* A subagent definition's inline server that collides with a name already in use is connected under a
|
|
46
|
+
* fresh one (`cf` -> `cf_2`); `name` is then `cf_2`.
|
|
47
|
+
* - `configName`: the key the server had in the config it came from, BEFORE any rename (`cf` above);
|
|
48
|
+
* equal to `name` when nothing was renamed. For a plugin's server, the raw name its `.mcp.json` (or
|
|
49
|
+
* manifest) declares -- the runtime registers plugin servers under exactly that name.
|
|
50
|
+
* - `readOnlyHint`: the tool's own `annotations.readOnlyHint` from that server's `tools/list`, only when
|
|
51
|
+
* the server states it as a boolean. Absent means "not stated", never "false".
|
|
52
|
+
*
|
|
53
|
+
* Why the runtime states it: `mcp__<server>__<tool>` cannot be split reliably (a server name may contain
|
|
54
|
+
* `__`), a rename is invisible in the tool name, and the annotation lives only on the runtime's side of
|
|
55
|
+
* the wire.
|
|
56
|
+
*/
|
|
57
|
+
export interface McpServerIdentity {
|
|
58
|
+
name: string;
|
|
59
|
+
configName: string;
|
|
60
|
+
readOnlyHint?: boolean;
|
|
61
|
+
}
|
|
37
62
|
export type CanUseTool = (toolName: string, input: Record<string, unknown>, options: {
|
|
38
63
|
signal: AbortSignal;
|
|
39
64
|
suggestions?: PermissionUpdate[];
|
|
@@ -50,6 +75,8 @@ export type CanUseTool = (toolName: string, input: Record<string, unknown>, opti
|
|
|
50
75
|
toolName: string;
|
|
51
76
|
ruleContent?: string;
|
|
52
77
|
};
|
|
78
|
+
/** WS-27, Winter-only: the MCP server this tool belongs to -- see `McpServerIdentity`. */
|
|
79
|
+
mcpServer?: McpServerIdentity;
|
|
53
80
|
}) => Promise<PermissionResult | null>;
|
|
54
81
|
export type PermissionDecisionClassification = "user_temporary" | "user_permanent" | "user_reject";
|
|
55
82
|
export type PermissionResult = {
|
|
@@ -82,6 +109,8 @@ export interface PermissionRequestPayload {
|
|
|
82
109
|
toolName: string;
|
|
83
110
|
ruleContent?: string;
|
|
84
111
|
};
|
|
112
|
+
/** WS-27: forwarded to `canUseTool` verbatim -- see `McpServerIdentity`. */
|
|
113
|
+
mcpServer?: McpServerIdentity;
|
|
85
114
|
policyVersion: number;
|
|
86
115
|
}
|
|
87
116
|
export declare const HOOK_EVENTS: readonly ["PreToolUse", "PostToolUse", "PostToolUseFailure", "UserPromptSubmit", "Stop", "SubagentStart", "SubagentStop", "PreCompact", "PermissionRequest", "Notification", "PostToolBatch", "UserPromptExpansion", "MessageDisplay", "StopFailure", "PostCompact", "PermissionDenied", "SessionStart", "SessionEnd", "Setup", "TeammateIdle", "TaskCreated", "TaskCompleted", "Elicitation", "ElicitationResult", "ConfigChange", "InstructionsLoaded", "WorktreeCreate", "WorktreeRemove", "CwdChanged", "FileChanged", "DirectoryAdded"];
|
|
@@ -105,13 +134,23 @@ export interface McpToolProvenance {
|
|
|
105
134
|
mcp_server_name?: string;
|
|
106
135
|
mcp_tool_name?: string;
|
|
107
136
|
}
|
|
108
|
-
export interface
|
|
137
|
+
export interface WinterMcpServerHookField {
|
|
138
|
+
winter_mcp_server?: {
|
|
139
|
+
/** The server's name in the called tool's name `mcp__<name>__<tool>`, after any rename. */
|
|
140
|
+
name: string;
|
|
141
|
+
/** The server's key in the config it came from, before any rename (a plugin server: the raw name its `.mcp.json` declares). */
|
|
142
|
+
config_name: string;
|
|
143
|
+
/** The tool's own `annotations.readOnlyHint` from the server's `tools/list`, only when stated. */
|
|
144
|
+
read_only_hint?: boolean;
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
export interface PreToolUseHookInput extends BaseHookInput, McpToolProvenance, WinterMcpServerHookField {
|
|
109
148
|
hook_event_name: "PreToolUse";
|
|
110
149
|
tool_name: string;
|
|
111
150
|
tool_input: unknown;
|
|
112
151
|
tool_use_id: string;
|
|
113
152
|
}
|
|
114
|
-
export interface PostToolUseHookInput extends BaseHookInput, McpToolProvenance {
|
|
153
|
+
export interface PostToolUseHookInput extends BaseHookInput, McpToolProvenance, WinterMcpServerHookField {
|
|
115
154
|
hook_event_name: "PostToolUse";
|
|
116
155
|
tool_name: string;
|
|
117
156
|
tool_input: unknown;
|
|
@@ -119,7 +158,7 @@ export interface PostToolUseHookInput extends BaseHookInput, McpToolProvenance {
|
|
|
119
158
|
tool_use_id: string;
|
|
120
159
|
duration_ms?: number;
|
|
121
160
|
}
|
|
122
|
-
export interface PostToolUseFailureHookInput extends BaseHookInput, McpToolProvenance {
|
|
161
|
+
export interface PostToolUseFailureHookInput extends BaseHookInput, McpToolProvenance, WinterMcpServerHookField {
|
|
123
162
|
hook_event_name: "PostToolUseFailure";
|
|
124
163
|
tool_name: string;
|
|
125
164
|
tool_input: unknown;
|
|
@@ -302,6 +341,8 @@ export interface HookInvocationPayload {
|
|
|
302
341
|
mcpServerName?: string;
|
|
303
342
|
/** WS-24: for an MCP tool, the tool's own name on that server -- see `McpToolProvenance`. */
|
|
304
343
|
mcpToolName?: string;
|
|
344
|
+
/** WS-27: PreToolUse/PostToolUse/PostToolUseFailure only -- becomes `winter_mcp_server`, see `McpServerIdentity`. */
|
|
345
|
+
mcpServer?: McpServerIdentity;
|
|
305
346
|
input?: Record<string, unknown>;
|
|
306
347
|
payload?: unknown;
|
|
307
348
|
policyVersion: string;
|
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.33",
|
|
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.33"
|
|
49
49
|
},
|
|
50
50
|
"optionalDependencies": {
|
|
51
|
-
"@yanlinglabs/winter-agent-sdk-darwin-arm64": "0.0.
|
|
51
|
+
"@yanlinglabs/winter-agent-sdk-darwin-arm64": "0.0.33"
|
|
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.33",
|
|
56
|
+
"@yanlinglabs/winter-conformance": "0.0.33"
|
|
57
57
|
},
|
|
58
58
|
"scripts": {}
|
|
59
59
|
}
|