@yanlinglabs/winter-agent-sdk 0.0.27 → 0.0.28
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 +1 -1
- package/dist/index.js +8 -2
- package/dist/permissions/types.d.ts +14 -5
- package/dist/protocol/frames.d.ts +3 -2
- package/dist/settings/types.d.ts +12 -1
- package/package.json +5 -5
package/dist/index.d.ts
CHANGED
|
@@ -50,7 +50,7 @@ export type { PermissionMode, PermissionBehavior, PermissionRuleValue } from "./
|
|
|
50
50
|
export type { PermissionUpdate, PermissionUpdateDestination, RuleSource } from "./permissions/types.js";
|
|
51
51
|
export type { CanUseTool, PermissionResult, PermissionDecisionClassification, PermissionRequestPayload } from "./permissions/types.js";
|
|
52
52
|
export { HOOK_EVENTS } from "./permissions/types.js";
|
|
53
|
-
export type { HookEvent, HookEventName, HookSource, HookPermissionDecision, BaseHookInput, 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";
|
|
53
|
+
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";
|
|
54
54
|
export { CATALOG_TAG_RENAMES } from "@yanlinglabs/winter-provider-catalog";
|
|
55
55
|
export { PluginManagerError, listMarketplaces, addMarketplace, removeMarketplace, updateMarketplace, installPlugin, uninstallPlugin, setPluginEnabled, updatePlugin, listPlugins } from "./plugins/manage.js";
|
|
56
56
|
export type { PluginScope, PluginManagerOptions, MarketplaceInfo, InstalledPlugin, PluginListing } from "./plugins/manage.js";
|
package/dist/index.js
CHANGED
|
@@ -504,6 +504,8 @@ function buildHookInput(req, cwd) {
|
|
|
504
504
|
...req.agentID !== undefined ? { agent_id: req.agentID } : {},
|
|
505
505
|
hook_event_name: req.event,
|
|
506
506
|
...req.toolName !== undefined ? { tool_name: req.toolName } : {},
|
|
507
|
+
...req.mcpServerName !== undefined ? { mcp_server_name: req.mcpServerName } : {},
|
|
508
|
+
...req.mcpToolName !== undefined ? { mcp_tool_name: req.mcpToolName } : {},
|
|
507
509
|
...req.input !== undefined ? { tool_input: req.input } : {},
|
|
508
510
|
...req.toolUseID !== undefined ? { tool_use_id: req.toolUseID } : {},
|
|
509
511
|
...payload
|
|
@@ -518,7 +520,7 @@ function makeHookHandler(hooks, cwd, abortController) {
|
|
|
518
520
|
});
|
|
519
521
|
});
|
|
520
522
|
}
|
|
521
|
-
return async (payload) => {
|
|
523
|
+
return async (payload, handlerCtx) => {
|
|
522
524
|
const req = payload;
|
|
523
525
|
const callback = byId.get(req.hookId);
|
|
524
526
|
if (!callback) {
|
|
@@ -529,6 +531,10 @@ function makeHookHandler(hooks, cwd, abortController) {
|
|
|
529
531
|
controller.abort();
|
|
530
532
|
else
|
|
531
533
|
abortController?.signal.addEventListener("abort", () => controller.abort(), { once: true });
|
|
534
|
+
if (handlerCtx?.signal.aborted === true)
|
|
535
|
+
controller.abort();
|
|
536
|
+
else
|
|
537
|
+
handlerCtx?.signal.addEventListener("abort", () => controller.abort(), { once: true });
|
|
532
538
|
const input = buildHookInput(req, cwd);
|
|
533
539
|
let output;
|
|
534
540
|
try {
|
|
@@ -1032,7 +1038,7 @@ function query(args) {
|
|
|
1032
1038
|
return gen;
|
|
1033
1039
|
}
|
|
1034
1040
|
// src/version.ts
|
|
1035
|
-
var SDK_VERSION = "0.0.
|
|
1041
|
+
var SDK_VERSION = "0.0.28";
|
|
1036
1042
|
// src/paths/project-key.ts
|
|
1037
1043
|
var TRANSCRIPT_PROJECT_KEY_MAX_LENGTH = 64;
|
|
1038
1044
|
var VENDOR_PROJECT_KEY_PATTERN = /^[A-Za-z0-9_-]{1,64}$/;
|
|
@@ -101,13 +101,17 @@ export interface BaseHookInput {
|
|
|
101
101
|
};
|
|
102
102
|
}
|
|
103
103
|
export type HookPermissionDecision = "allow" | "ask" | "deny" | "defer";
|
|
104
|
-
export interface
|
|
104
|
+
export interface McpToolProvenance {
|
|
105
|
+
mcp_server_name?: string;
|
|
106
|
+
mcp_tool_name?: string;
|
|
107
|
+
}
|
|
108
|
+
export interface PreToolUseHookInput extends BaseHookInput, McpToolProvenance {
|
|
105
109
|
hook_event_name: "PreToolUse";
|
|
106
110
|
tool_name: string;
|
|
107
111
|
tool_input: unknown;
|
|
108
112
|
tool_use_id: string;
|
|
109
113
|
}
|
|
110
|
-
export interface PostToolUseHookInput extends BaseHookInput {
|
|
114
|
+
export interface PostToolUseHookInput extends BaseHookInput, McpToolProvenance {
|
|
111
115
|
hook_event_name: "PostToolUse";
|
|
112
116
|
tool_name: string;
|
|
113
117
|
tool_input: unknown;
|
|
@@ -115,7 +119,7 @@ export interface PostToolUseHookInput extends BaseHookInput {
|
|
|
115
119
|
tool_use_id: string;
|
|
116
120
|
duration_ms?: number;
|
|
117
121
|
}
|
|
118
|
-
export interface PostToolUseFailureHookInput extends BaseHookInput {
|
|
122
|
+
export interface PostToolUseFailureHookInput extends BaseHookInput, McpToolProvenance {
|
|
119
123
|
hook_event_name: "PostToolUseFailure";
|
|
120
124
|
tool_name: string;
|
|
121
125
|
tool_input: unknown;
|
|
@@ -154,13 +158,13 @@ export interface NotificationHookInput extends BaseHookInput {
|
|
|
154
158
|
title?: string;
|
|
155
159
|
notification_type: string;
|
|
156
160
|
}
|
|
157
|
-
export interface PermissionRequestHookInput extends BaseHookInput {
|
|
161
|
+
export interface PermissionRequestHookInput extends BaseHookInput, McpToolProvenance {
|
|
158
162
|
hook_event_name: "PermissionRequest";
|
|
159
163
|
tool_name: string;
|
|
160
164
|
tool_input: unknown;
|
|
161
165
|
permission_suggestions?: PermissionUpdate[];
|
|
162
166
|
}
|
|
163
|
-
export interface PermissionDeniedHookInput extends BaseHookInput {
|
|
167
|
+
export interface PermissionDeniedHookInput extends BaseHookInput, McpToolProvenance {
|
|
164
168
|
hook_event_name: "PermissionDenied";
|
|
165
169
|
tool_name: string;
|
|
166
170
|
tool_input: unknown;
|
|
@@ -186,6 +190,7 @@ export interface GenericHookInput extends BaseHookInput {
|
|
|
186
190
|
export type HookInput = PreToolUseHookInput | PostToolUseHookInput | PostToolUseFailureHookInput | UserPromptSubmitHookInput | StopHookInput | SessionStartHookInput | SessionEndHookInput | NotificationHookInput | PermissionRequestHookInput | PermissionDeniedHookInput | SubagentStartHookInput | SubagentStopHookInput | GenericHookInput;
|
|
187
191
|
export interface AsyncHookJSONOutput {
|
|
188
192
|
async: true;
|
|
193
|
+
/** Milliseconds the background run may take (the runtime's default is 10 minutes). */
|
|
189
194
|
asyncTimeout?: number;
|
|
190
195
|
}
|
|
191
196
|
export interface PreToolUseHookSpecificOutput {
|
|
@@ -293,6 +298,10 @@ export interface HookInvocationPayload {
|
|
|
293
298
|
agentID?: string;
|
|
294
299
|
toolUseID?: string;
|
|
295
300
|
toolName?: string;
|
|
301
|
+
/** WS-24: for an MCP tool, the connected server that registered `toolName` -- see `McpToolProvenance`. */
|
|
302
|
+
mcpServerName?: string;
|
|
303
|
+
/** WS-24: for an MCP tool, the tool's own name on that server -- see `McpToolProvenance`. */
|
|
304
|
+
mcpToolName?: string;
|
|
296
305
|
input?: Record<string, unknown>;
|
|
297
306
|
payload?: unknown;
|
|
298
307
|
policyVersion: string;
|
|
@@ -58,8 +58,9 @@ export interface ControlResponseFrame {
|
|
|
58
58
|
* adapters send `{type: "ephemeral"}` with no ttl), so `ephemeral_5m_input_tokens` equals
|
|
59
59
|
* `cache_creation_input_tokens` and `ephemeral_1h_input_tokens` is 0;
|
|
60
60
|
* - `server_tool_use`: Winter's WebSearch/WebFetch run client-side, never as billed server tools: 0/0;
|
|
61
|
-
* - `output_tokens_details.thinking_tokens`:
|
|
62
|
-
*
|
|
61
|
+
* - `output_tokens_details.thinking_tokens`: the Responses family's reasoning-token count (WS-24
|
|
62
|
+
* follow-up 1) when the turn's provider reported one, else 0 -- always a SUBSET of `output_tokens`,
|
|
63
|
+
* never added on top. Anthropic reports no separate count, so a Claude-only turn stays 0;
|
|
63
64
|
* - `service_tier: "standard"`, `inference_geo: ""`, `iterations: []`, `speed: "standard"`: the
|
|
64
65
|
* pinned EMPTY_USAGE's own values.
|
|
65
66
|
*/
|
package/dist/settings/types.d.ts
CHANGED
|
@@ -18,12 +18,23 @@ export interface SettingsHookHandler {
|
|
|
18
18
|
/** `"command"` is the only shape a settings file can express; see buildHookEntriesFromSettings. */
|
|
19
19
|
type?: string;
|
|
20
20
|
command?: string;
|
|
21
|
-
/** SECONDS (HookCallbackMatcher.timeout's pinned unit) -- converted to ms exactly once, at entry-build time. */
|
|
21
|
+
/** SECONDS (HookCallbackMatcher.timeout's pinned unit) -- converted to ms exactly once, at entry-build time. For an `async` handler, its background run's timeout. */
|
|
22
22
|
timeout?: number;
|
|
23
|
+
/** WS-23: fail CLOSED on PreToolUse/PermissionRequest (an error, a timeout or malformed output denies the call). Only a literal `true`. */
|
|
24
|
+
failClosed?: boolean;
|
|
25
|
+
/**
|
|
26
|
+
* WS-24: run in the BACKGROUND -- the event never waits, the hook can never allow or deny anything, and
|
|
27
|
+
* what it later says (`systemMessage`, `additionalContext`) reaches the model at the next safe point as
|
|
28
|
+
* a reminder. Refused (the hook stays synchronous, and the refusal is reported) on a fail-closed
|
|
29
|
+
* PreToolUse/PermissionRequest hook. Only a literal `true`.
|
|
30
|
+
*/
|
|
31
|
+
async?: boolean;
|
|
23
32
|
}
|
|
24
33
|
export interface SettingsHookMatcherGroup {
|
|
25
34
|
matcher?: string;
|
|
26
35
|
hooks?: SettingsHookHandler[];
|
|
36
|
+
/** WS-23: `failClosed` for every handler in the group. */
|
|
37
|
+
failClosed?: boolean;
|
|
27
38
|
}
|
|
28
39
|
/** Open-keyed for the same reason RuntimeHooksConfig is (protocol/config.ts): unknown event names are accepted, preserved and inert. */
|
|
29
40
|
export type SettingsHooksConfig = Partial<Record<string, SettingsHookMatcherGroup[]>>;
|
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.28",
|
|
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.28"
|
|
49
49
|
},
|
|
50
50
|
"optionalDependencies": {
|
|
51
|
-
"@yanlinglabs/winter-agent-sdk-darwin-arm64": "0.0.
|
|
51
|
+
"@yanlinglabs/winter-agent-sdk-darwin-arm64": "0.0.28"
|
|
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.28",
|
|
56
|
+
"@yanlinglabs/winter-conformance": "0.0.28"
|
|
57
57
|
},
|
|
58
58
|
"scripts": {}
|
|
59
59
|
}
|