@yanlinglabs/winter-agent-runtime 0.0.27
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/LICENSE +21 -0
- package/NOTICE +41 -0
- package/README.md +64 -0
- package/dist/checkpoint/file-history.d.ts +81 -0
- package/dist/checkpoint/rewind.d.ts +55 -0
- package/dist/checkpoint/seam.d.ts +47 -0
- package/dist/checkpoint/sink.d.ts +66 -0
- package/dist/commands/builtins-listing.d.ts +40 -0
- package/dist/commands/resolver.d.ts +103 -0
- package/dist/commands/seam.d.ts +53 -0
- package/dist/compaction/controller.d.ts +23 -0
- package/dist/compaction/retention.d.ts +35 -0
- package/dist/compaction/seam.d.ts +115 -0
- package/dist/compaction/summarizer.d.ts +79 -0
- package/dist/context/agent-listing.d.ts +39 -0
- package/dist/context/assembler.d.ts +46 -0
- package/dist/context/attachments.d.ts +104 -0
- package/dist/context/dynamic-sections.d.ts +31 -0
- package/dist/context/git-fixture.d.ts +18 -0
- package/dist/context/git-status.d.ts +16 -0
- package/dist/context/imports.d.ts +22 -0
- package/dist/context/injection.d.ts +53 -0
- package/dist/context/memory-key.d.ts +46 -0
- package/dist/context/memory.d.ts +28 -0
- package/dist/context/minimal-prompt.d.ts +5 -0
- package/dist/context/output-styles.d.ts +68 -0
- package/dist/context/plan-mode.d.ts +29 -0
- package/dist/context/request-layout.d.ts +138 -0
- package/dist/context/rules.d.ts +63 -0
- package/dist/context/seam.d.ts +136 -0
- package/dist/context/tool-epoch.d.ts +118 -0
- package/dist/context/winter-code-preset.d.ts +39 -0
- package/dist/context/winter-md.d.ts +81 -0
- package/dist/embedded-host.d.ts +48 -0
- package/dist/embedded-host.js +155 -0
- package/dist/embedded-protocol.d.ts +44 -0
- package/dist/embedded-worker.d.ts +1 -0
- package/dist/embedded-worker.js +74 -0
- package/dist/embedded.d.ts +34 -0
- package/dist/embedded.js +9 -0
- package/dist/engine.d.ts +1298 -0
- package/dist/hooks/additional-context.d.ts +21 -0
- package/dist/hooks/bounds.d.ts +6 -0
- package/dist/hooks/bridge-invoker.d.ts +3 -0
- package/dist/hooks/command-invoker.d.ts +52 -0
- package/dist/hooks/from-config.d.ts +31 -0
- package/dist/hooks/hook-stage.d.ts +25 -0
- package/dist/hooks/input-validator.d.ts +6 -0
- package/dist/hooks/reducer.d.ts +74 -0
- package/dist/hooks/registry.d.ts +33 -0
- package/dist/hooks/runner.d.ts +105 -0
- package/dist/index-584yahed.js +6037 -0
- package/dist/index-97t2rmtf.js +42 -0
- package/dist/index-9qgkpv56.js +27183 -0
- package/dist/index-bef62z3r.js +437 -0
- package/dist/index-rkhh0457.js +187 -0
- package/dist/index.d.ts +37 -0
- package/dist/index.js +353 -0
- package/dist/main.d.ts +1 -0
- package/dist/mcp/client.d.ts +105 -0
- package/dist/mcp/control-seam.d.ts +25 -0
- package/dist/mcp/control.d.ts +5 -0
- package/dist/mcp/elicitation.d.ts +35 -0
- package/dist/mcp/env.d.ts +12 -0
- package/dist/mcp/lifecycle.d.ts +142 -0
- package/dist/mcp/output-cap.d.ts +15 -0
- package/dist/mcp/state.d.ts +24 -0
- package/dist/mcp/test-fixtures.d.ts +88 -0
- package/dist/mcp/transports/__fixtures__/stdio-server.d.ts +1 -0
- package/dist/mcp/transports/http.d.ts +5 -0
- package/dist/mcp/transports/sdk.d.ts +5 -0
- package/dist/mcp/transports/sse.d.ts +3 -0
- package/dist/mcp/transports/stdio.d.ts +35 -0
- package/dist/mcp/winter-server.d.ts +2 -0
- package/dist/messaging/reference-adapter.d.ts +88 -0
- package/dist/messaging/router.d.ts +8 -0
- package/dist/paths/project-dir-name.d.ts +2 -0
- package/dist/paths/temp.d.ts +25 -0
- package/dist/permissions/approvals.d.ts +107 -0
- package/dist/permissions/auto/caches.d.ts +53 -0
- package/dist/permissions/auto/config.d.ts +37 -0
- package/dist/permissions/auto/engine.d.ts +74 -0
- package/dist/permissions/auto/envelope.d.ts +45 -0
- package/dist/permissions/auto/inheritance.d.ts +27 -0
- package/dist/permissions/edit-recognition.d.ts +30 -0
- package/dist/permissions/evaluator.d.ts +284 -0
- package/dist/permissions/file-rules.d.ts +384 -0
- package/dist/permissions/grammar.d.ts +113 -0
- package/dist/permissions/paths.d.ts +32 -0
- package/dist/permissions/policy-state.d.ts +64 -0
- package/dist/permissions/prompt-stage.d.ts +3 -0
- package/dist/permissions/protected.d.ts +54 -0
- package/dist/permissions/ruleset.d.ts +134 -0
- package/dist/permissions/shell-structure.d.ts +41 -0
- package/dist/plugins/bundle.d.ts +100 -0
- package/dist/plugins/installed.d.ts +30 -0
- package/dist/plugins/loader.d.ts +56 -0
- package/dist/plugins/manifest.d.ts +115 -0
- package/dist/production-wiring.d.ts +340 -0
- package/dist/protocol/channel.d.ts +22 -0
- package/dist/provider/advisor-route.d.ts +47 -0
- package/dist/provider/bridge.d.ts +124 -0
- package/dist/provider/classifier/model-classifier.d.ts +82 -0
- package/dist/provider/classifier/prompt.d.ts +62 -0
- package/dist/provider/classifier/verdict-schema.d.ts +83 -0
- package/dist/provider/credential-api.d.ts +160 -0
- package/dist/provider/family-listing.d.ts +27 -0
- package/dist/provider/first-party.d.ts +4 -0
- package/dist/provider/keychain-store.d.ts +59 -0
- package/dist/provider/lean-prompt.d.ts +7 -0
- package/dist/provider/mock.d.ts +55 -0
- package/dist/provider/scenario-fake.d.ts +96 -0
- package/dist/provider/selection.d.ts +115 -0
- package/dist/provider/session-provider.d.ts +426 -0
- package/dist/provider/slots.d.ts +120 -0
- package/dist/provider/stream-frames.d.ts +25 -0
- package/dist/provider/tool-secret.d.ts +57 -0
- package/dist/rpc/bridge.d.ts +14 -0
- package/dist/rpc/mcp-control.d.ts +26 -0
- package/dist/runtime.d.ts +14 -0
- package/dist/sandbox/profile.d.ts +249 -0
- package/dist/sandbox/spawn.d.ts +139 -0
- package/dist/settings/env-filter.d.ts +52 -0
- package/dist/settings/loaders/hooks.d.ts +44 -0
- package/dist/settings/loaders/mcp-config.d.ts +83 -0
- package/dist/settings/loaders/plugin-mcp.d.ts +3 -0
- package/dist/settings/loaders/strict-plugin-only.d.ts +13 -0
- package/dist/settings/resolve.d.ts +2 -0
- package/dist/settings/sources.d.ts +2 -0
- package/dist/settings/trust.d.ts +36 -0
- package/dist/skills/attachment.d.ts +25 -0
- package/dist/skills/frontmatter.d.ts +64 -0
- package/dist/skills/index.d.ts +16 -0
- package/dist/skills/listing.d.ts +89 -0
- package/dist/skills/loader.d.ts +104 -0
- package/dist/skills/option.d.ts +68 -0
- package/dist/skills/permission-rules.d.ts +21 -0
- package/dist/skills/runtime.d.ts +21 -0
- package/dist/skills/store.d.ts +163 -0
- package/dist/store/continuation-attach.d.ts +44 -0
- package/dist/store/dialect.d.ts +526 -0
- package/dist/store/provider-state.d.ts +188 -0
- package/dist/store/resume.d.ts +92 -0
- package/dist/structured/ajv-seam.d.ts +7 -0
- package/dist/structured/descriptor.d.ts +9 -0
- package/dist/structured/seam.d.ts +51 -0
- package/dist/structured/validator.d.ts +22 -0
- package/dist/subagents/activity.d.ts +13 -0
- package/dist/subagents/availability.d.ts +30 -0
- package/dist/subagents/builtin-agents.d.ts +37 -0
- package/dist/subagents/child-engine.d.ts +198 -0
- package/dist/subagents/child-handle.d.ts +344 -0
- package/dist/subagents/definitions.d.ts +189 -0
- package/dist/subagents/fork.d.ts +55 -0
- package/dist/subagents/git-root.d.ts +1 -0
- package/dist/subagents/limits.d.ts +28 -0
- package/dist/subagents/notification-queue.d.ts +233 -0
- package/dist/subagents/plugin-agents.d.ts +5 -0
- package/dist/subagents/policy.d.ts +46 -0
- package/dist/subagents/register-default-factory.d.ts +66 -0
- package/dist/subagents/resolution.d.ts +56 -0
- package/dist/subagents/restore.d.ts +9 -0
- package/dist/subagents/roster.d.ts +17 -0
- package/dist/subagents/test-fakes.d.ts +12 -0
- package/dist/subagents/tool-pools.d.ts +69 -0
- package/dist/subagents/watchdog.d.ts +13 -0
- package/dist/subagents/workspace.d.ts +27 -0
- package/dist/testing.d.ts +5 -0
- package/dist/testing.js +194 -0
- package/dist/tools/background-tasks.d.ts +10 -0
- package/dist/tools/descriptors/_shared.d.ts +34 -0
- package/dist/tools/descriptors/advisor.d.ts +1 -0
- package/dist/tools/descriptors/agent.d.ts +47 -0
- package/dist/tools/descriptors/artifact.d.ts +1 -0
- package/dist/tools/descriptors/ask-user-question.d.ts +1 -0
- package/dist/tools/descriptors/bash.d.ts +20 -0
- package/dist/tools/descriptors/claude-design.d.ts +1 -0
- package/dist/tools/descriptors/cron-create.d.ts +1 -0
- package/dist/tools/descriptors/cron-delete.d.ts +1 -0
- package/dist/tools/descriptors/cron-list.d.ts +1 -0
- package/dist/tools/descriptors/edit.d.ts +1 -0
- package/dist/tools/descriptors/end-conversation.d.ts +1 -0
- package/dist/tools/descriptors/enter-plan-mode.d.ts +1 -0
- package/dist/tools/descriptors/enter-worktree.d.ts +1 -0
- package/dist/tools/descriptors/exit-plan-mode.d.ts +1 -0
- package/dist/tools/descriptors/exit-worktree.d.ts +1 -0
- package/dist/tools/descriptors/glob.d.ts +1 -0
- package/dist/tools/descriptors/grep.d.ts +1 -0
- package/dist/tools/descriptors/index.d.ts +59 -0
- package/dist/tools/descriptors/list-agents.d.ts +1 -0
- package/dist/tools/descriptors/list-mcp-resources-tool.d.ts +1 -0
- package/dist/tools/descriptors/lsp.d.ts +1 -0
- package/dist/tools/descriptors/monitor.d.ts +1 -0
- package/dist/tools/descriptors/notebook-edit.d.ts +1 -0
- package/dist/tools/descriptors/powershell.d.ts +1 -0
- package/dist/tools/descriptors/projects.d.ts +1 -0
- package/dist/tools/descriptors/propose-goal.d.ts +1 -0
- package/dist/tools/descriptors/propose-skills.d.ts +1 -0
- package/dist/tools/descriptors/push-notification.d.ts +1 -0
- package/dist/tools/descriptors/read-mcp-resource-dir-tool.d.ts +1 -0
- package/dist/tools/descriptors/read-mcp-resource-tool.d.ts +1 -0
- package/dist/tools/descriptors/read-notifications.d.ts +1 -0
- package/dist/tools/descriptors/read.d.ts +1 -0
- package/dist/tools/descriptors/refresh-mcp-tools.d.ts +1 -0
- package/dist/tools/descriptors/remote-trigger.d.ts +1 -0
- package/dist/tools/descriptors/repl.d.ts +1 -0
- package/dist/tools/descriptors/report-findings.d.ts +1 -0
- package/dist/tools/descriptors/schedule-wakeup.d.ts +1 -0
- package/dist/tools/descriptors/send-feedback.d.ts +1 -0
- package/dist/tools/descriptors/send-message.d.ts +1 -0
- package/dist/tools/descriptors/send-user-file.d.ts +1 -0
- package/dist/tools/descriptors/share-onboarding-guide.d.ts +1 -0
- package/dist/tools/descriptors/show-onboarding-role-picker.d.ts +1 -0
- package/dist/tools/descriptors/skill.d.ts +1 -0
- package/dist/tools/descriptors/structured-output.d.ts +1 -0
- package/dist/tools/descriptors/task-create.d.ts +1 -0
- package/dist/tools/descriptors/task-get.d.ts +1 -0
- package/dist/tools/descriptors/task-list.d.ts +1 -0
- package/dist/tools/descriptors/task-output.d.ts +1 -0
- package/dist/tools/descriptors/task-stop.d.ts +1 -0
- package/dist/tools/descriptors/task-update.d.ts +1 -0
- package/dist/tools/descriptors/todo-write.d.ts +1 -0
- package/dist/tools/descriptors/tool-search.d.ts +1 -0
- package/dist/tools/descriptors/wait-for-mcp-servers.d.ts +1 -0
- package/dist/tools/descriptors/web-fetch.d.ts +8 -0
- package/dist/tools/descriptors/web-search.d.ts +15 -0
- package/dist/tools/descriptors/winter-list-agents.d.ts +1 -0
- package/dist/tools/descriptors/winter-send-message.d.ts +1 -0
- package/dist/tools/descriptors/workflow.d.ts +1 -0
- package/dist/tools/descriptors/write.d.ts +1 -0
- package/dist/tools/impl/_caller.d.ts +14 -0
- package/dist/tools/impl/_domains.d.ts +25 -0
- package/dist/tools/impl/_exa-client.d.ts +122 -0
- package/dist/tools/impl/_exa-session-client.d.ts +23 -0
- package/dist/tools/impl/_inner-model.d.ts +135 -0
- package/dist/tools/impl/_search-budget.d.ts +36 -0
- package/dist/tools/impl/_web-fetch-cache.d.ts +37 -0
- package/dist/tools/impl/_web-fetch-html.d.ts +26 -0
- package/dist/tools/impl/_web-fetch-net.d.ts +99 -0
- package/dist/tools/impl/_web-search-assembler.d.ts +57 -0
- package/dist/tools/impl/advisor.d.ts +37 -0
- package/dist/tools/impl/agent.d.ts +10 -0
- package/dist/tools/impl/ask-user-question.d.ts +5 -0
- package/dist/tools/impl/background-task-runtime.d.ts +272 -0
- package/dist/tools/impl/bash.d.ts +78 -0
- package/dist/tools/impl/cron.d.ts +11 -0
- package/dist/tools/impl/edit.d.ts +1 -0
- package/dist/tools/impl/enter-plan-mode.d.ts +4 -0
- package/dist/tools/impl/enter-worktree.d.ts +25 -0
- package/dist/tools/impl/exit-plan-mode.d.ts +4 -0
- package/dist/tools/impl/exit-worktree.d.ts +4 -0
- package/dist/tools/impl/glob.d.ts +1 -0
- package/dist/tools/impl/grep.d.ts +19 -0
- package/dist/tools/impl/index.d.ts +37 -0
- package/dist/tools/impl/list-agents.d.ts +7 -0
- package/dist/tools/impl/list-mcp-resources-tool.d.ts +9 -0
- package/dist/tools/impl/monitor.d.ts +66 -0
- package/dist/tools/impl/notebook-edit.d.ts +1 -0
- package/dist/tools/impl/push-notification.d.ts +4 -0
- package/dist/tools/impl/read-ladder.d.ts +25 -0
- package/dist/tools/impl/read-mcp-resource-dir-tool.d.ts +9 -0
- package/dist/tools/impl/read-mcp-resource-tool.d.ts +9 -0
- package/dist/tools/impl/read-notifications.d.ts +5 -0
- package/dist/tools/impl/read.d.ts +44 -0
- package/dist/tools/impl/refresh-mcp-tools.d.ts +8 -0
- package/dist/tools/impl/report-findings.d.ts +1 -0
- package/dist/tools/impl/schedule-wakeup.d.ts +2 -0
- package/dist/tools/impl/send-message.d.ts +7 -0
- package/dist/tools/impl/skill.d.ts +5 -0
- package/dist/tools/impl/task-graph.d.ts +1 -0
- package/dist/tools/impl/task-output.d.ts +16 -0
- package/dist/tools/impl/task-stop.d.ts +11 -0
- package/dist/tools/impl/todo-write.d.ts +8 -0
- package/dist/tools/impl/tool-search.d.ts +4 -0
- package/dist/tools/impl/wait-for-mcp-servers.d.ts +29 -0
- package/dist/tools/impl/web-fetch.d.ts +36 -0
- package/dist/tools/impl/web-search.d.ts +30 -0
- package/dist/tools/impl/workflow.d.ts +5 -0
- package/dist/tools/impl/write.d.ts +8 -0
- package/dist/tools/paths-seam.d.ts +6 -0
- package/dist/tools/read-state.d.ts +12 -0
- package/dist/tools/registry.d.ts +423 -0
- package/dist/tools/task-graph-store.d.ts +61 -0
- package/dist/toolsearch/aliases.d.ts +26 -0
- package/dist/toolsearch/exposure.d.ts +30 -0
- package/dist/toolsearch/ranking.d.ts +6 -0
- package/dist/toolsearch/search.d.ts +45 -0
- package/dist/version.d.ts +1 -0
- package/dist/version.js +5 -0
- package/dist/web/fetchable-url.d.ts +28 -0
- package/dist/web/preapproved-hosts.d.ts +52 -0
- package/dist/web/private-address.d.ts +55 -0
- package/dist/web/session-runtime.d.ts +86 -0
- package/dist/workflows/bridge.d.ts +87 -0
- package/dist/workflows/budget.d.ts +24 -0
- package/dist/workflows/host-registry.d.ts +142 -0
- package/dist/workflows/journal.d.ts +29 -0
- package/dist/workflows/meta.d.ts +45 -0
- package/dist/workflows/registry.d.ts +24 -0
- package/dist/workflows/runtime.d.ts +254 -0
- package/dist/workflows/sandbox.d.ts +49 -0
- package/dist/workflows/script-api.d.ts +58 -0
- package/dist/workflows/seam.d.ts +92 -0
- package/dist/workflows/semaphore.d.ts +16 -0
- package/dist/workflows/store.d.ts +177 -0
- package/dist/workflows/subprocess-entry.d.ts +38 -0
- package/dist/workflows/subprocess-entry.js +14 -0
- package/dist/workflows/transcript.d.ts +56 -0
- package/dist/workflows/types.d.ts +84 -0
- package/dist/workflows/worker-harness.d.ts +45 -0
- package/package.json +76 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { type AttachmentPayload } from "../context/attachments.js";
|
|
2
|
+
export declare const HOOK_ADDITIONAL_CONTEXT_ATTACHMENT = "hook_additional_context";
|
|
3
|
+
export declare const HOOK_FEEDBACK_ATTACHMENT = "hook_feedback";
|
|
4
|
+
export interface HookAdditionalContextAttachment extends AttachmentPayload {
|
|
5
|
+
type: typeof HOOK_ADDITIONAL_CONTEXT_ATTACHMENT;
|
|
6
|
+
hookName: string;
|
|
7
|
+
content: string[];
|
|
8
|
+
toolUseID?: string;
|
|
9
|
+
}
|
|
10
|
+
export interface HookFeedbackAttachment extends AttachmentPayload {
|
|
11
|
+
type: typeof HOOK_FEEDBACK_ATTACHMENT;
|
|
12
|
+
hookName: string;
|
|
13
|
+
content: string[];
|
|
14
|
+
}
|
|
15
|
+
/** The `additionalContext` strings a composite accumulated, in evaluation order (non-string or empty entries dropped). */
|
|
16
|
+
export declare function contextStrings(extraContext: ReadonlyArray<{
|
|
17
|
+
context: unknown;
|
|
18
|
+
}> | undefined): string[];
|
|
19
|
+
/** `undefined` when there is nothing to say -- the caller then appends nothing at all. */
|
|
20
|
+
export declare function hookAdditionalContextAttachment(hookName: string, content: readonly string[], toolUseID?: string): HookAdditionalContextAttachment | undefined;
|
|
21
|
+
export declare function hookFeedbackAttachment(hookName: string, content: readonly string[]): HookFeedbackAttachment | undefined;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export declare const MAX_HOOK_TEXT_CHARS = 10000;
|
|
2
|
+
export declare const MAX_HOOK_TOOL_OUTPUT_CHARS = 100000;
|
|
3
|
+
export declare const MAX_HOOK_STDOUT_CAPTURE: number;
|
|
4
|
+
export declare function hookTruncationMarker(limit: number): string;
|
|
5
|
+
/** `text` unchanged when within `limit`, else its first `limit` characters plus the visible marker. */
|
|
6
|
+
export declare function capHookText(text: string, limit?: number): string;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { type BrandProfile } from "@yanlinglabs/winter-agent-sdk";
|
|
2
|
+
import { type HookInvocationRequest, type HookInvoker } from "./runner.js";
|
|
3
|
+
import type { SourcedHookEntry } from "./registry.js";
|
|
4
|
+
/** Grace between SIGTERM and SIGKILL. Short: by the time this fires the runner has already given up on the hook. */
|
|
5
|
+
export declare const COMMAND_HOOK_KILL_GRACE_MS = 250;
|
|
6
|
+
export declare class CommandHookError extends Error {
|
|
7
|
+
readonly exitCode: number | null;
|
|
8
|
+
readonly stderr: string;
|
|
9
|
+
/** Fix round 1 (M3): the failure's machine-readable class -- what a fail-closed denial names instead of this error's message (which embeds the command line). */
|
|
10
|
+
readonly code: string;
|
|
11
|
+
constructor(message: string, exitCode: number | null, stderr: string, stdout?: string, code?: string);
|
|
12
|
+
}
|
|
13
|
+
export interface CommandHookInvokerOptions {
|
|
14
|
+
/** Where a non-command entry's invocation goes -- normally `createBridgeHookInvoker(bridge)`. */
|
|
15
|
+
next: HookInvoker;
|
|
16
|
+
/** Working directory for the spawned command. The session cwd; never `process.cwd()` picked up implicitly. */
|
|
17
|
+
cwd: string;
|
|
18
|
+
/** Environment for the spawned command. Passed explicitly so a caller states which environment governs, matching this codebase's standing rule for env-derived behaviour. */
|
|
19
|
+
env?: Record<string, string | undefined>;
|
|
20
|
+
/** The shell used to interpret a command string. Overridable for tests; never taken from `$SHELL`, which a repository could influence. */
|
|
21
|
+
shellPath?: string;
|
|
22
|
+
killGraceMs?: number;
|
|
23
|
+
/** WS-23: `CLAUDE_PROJECT_DIR` (and its brand twin). Defaults to `cwd` -- the session's project directory. */
|
|
24
|
+
projectDir?: string;
|
|
25
|
+
/** WS-23: the brand whose env prefix names the Winter twins of `CLAUDE_PROJECT_DIR`/`CLAUDE_PLUGIN_ROOT`. Absent = no twin exported. */
|
|
26
|
+
brand?: Pick<BrandProfile, "envPrefix">;
|
|
27
|
+
/** WS-23: the stdin input's `transcript_path` -- the session transcript's absolute path, or `""` when there is none to name. */
|
|
28
|
+
transcriptPath?: string;
|
|
29
|
+
/** WS-23: the stdin input's `permission_mode`, read at invocation time (it changes mid-session). */
|
|
30
|
+
permissionMode?: () => string | undefined;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Wraps `opts.next`, executing any invocation whose `hookId` belongs to a command-bearing entry as a
|
|
34
|
+
* subprocess instead.
|
|
35
|
+
*
|
|
36
|
+
* The entry list is snapshotted at construction, matching `buildHookRegistry`'s own "a registry is
|
|
37
|
+
* immutable for the life of a run" contract -- a run builds both from the same entries.
|
|
38
|
+
*/
|
|
39
|
+
export declare function createCommandHookInvoker(entries: readonly SourcedHookEntry[], opts: CommandHookInvokerOptions): HookInvoker;
|
|
40
|
+
/**
|
|
41
|
+
* claude's command-hook stdin: the snake_case `HookInput` for this event, built from the runner's
|
|
42
|
+
* camelCase request. `payload` already carries each event's own fields in claude's spelling (the
|
|
43
|
+
* engine's firing sites pass `tool_response`, `prompt`, `source`, `stop_hook_active`, ...), so it is
|
|
44
|
+
* spread last and verbatim -- the same lossless construction query.ts's `buildHookInput` applies for
|
|
45
|
+
* a JS callback. `transcript_path` is claude's non-optional field: `""` when the session has no
|
|
46
|
+
* durable transcript to point at, never a guessed path.
|
|
47
|
+
*/
|
|
48
|
+
export declare function commandHookInput(request: HookInvocationRequest, ctx: {
|
|
49
|
+
cwd: string;
|
|
50
|
+
transcriptPath: string;
|
|
51
|
+
permissionMode?: string;
|
|
52
|
+
}): Record<string, unknown>;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { type ResolvedSettingSource, type RuntimeHooksConfig } from "@yanlinglabs/winter-agent-sdk";
|
|
2
|
+
import type { SourcedHookEntry } from "./registry.js";
|
|
3
|
+
export declare function buildHookEntriesFromConfig(config: RuntimeHooksConfig | undefined): SourcedHookEntry[];
|
|
4
|
+
/** A settings hook block that could not be turned into an entry. Reported, never thrown (the brief's own MUST). */
|
|
5
|
+
export interface RejectedHookBlock {
|
|
6
|
+
source: ResolvedSettingSource;
|
|
7
|
+
path?: string;
|
|
8
|
+
event?: string;
|
|
9
|
+
reason: string;
|
|
10
|
+
}
|
|
11
|
+
export interface HookEntriesFromSettings {
|
|
12
|
+
entries: SourcedHookEntry[];
|
|
13
|
+
rejected: RejectedHookBlock[];
|
|
14
|
+
}
|
|
15
|
+
/** One settings tier's contribution, as `resolveSettingsDetailed` reports it (`perSource`) or as the pinned `ResolvedSettings.sources` does. */
|
|
16
|
+
export interface SettingsHookSourceInput {
|
|
17
|
+
source: ResolvedSettingSource;
|
|
18
|
+
path?: string;
|
|
19
|
+
settings?: {
|
|
20
|
+
hooks?: unknown;
|
|
21
|
+
[key: string]: unknown;
|
|
22
|
+
};
|
|
23
|
+
values?: {
|
|
24
|
+
hooks?: unknown;
|
|
25
|
+
[key: string]: unknown;
|
|
26
|
+
};
|
|
27
|
+
policyOrigin?: string;
|
|
28
|
+
loaded?: boolean;
|
|
29
|
+
error?: string;
|
|
30
|
+
}
|
|
31
|
+
export declare function buildHookEntriesFromSettings(perSource: readonly SettingsHookSourceInput[] | undefined): HookEntriesFromSettings;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { PermissionCall, HookStage } from "../permissions/evaluator.js";
|
|
2
|
+
import { type HookInvoker, type HookAuditRecorder, type HookTimeoutConfig, type ToolInputValidator, type HookLifecycleSink } from "./runner.js";
|
|
3
|
+
import type { HookRegistry } from "./registry.js";
|
|
4
|
+
import type { HookComposite } from "./reducer.js";
|
|
5
|
+
export interface HookStageDeps {
|
|
6
|
+
registry: HookRegistry;
|
|
7
|
+
invoker: HookInvoker;
|
|
8
|
+
audit: HookAuditRecorder;
|
|
9
|
+
sessionId: string;
|
|
10
|
+
agentID?: string;
|
|
11
|
+
timeouts?: HookTimeoutConfig;
|
|
12
|
+
validator?: ToolInputValidator;
|
|
13
|
+
lifecycle?: HookLifecycleSink;
|
|
14
|
+
/**
|
|
15
|
+
* WS-23: every composite this stage computes, handed to the engine BESIDE the decision -- the
|
|
16
|
+
* parts of a PreToolUse/PermissionRequest answer that are not a permission decision
|
|
17
|
+
* (`extraContext`, `systemMessages`, `preventContinuation`) and so have no field on evaluator.ts's
|
|
18
|
+
* `HookDecision`/`PermissionDecisionRecord`. A side channel rather than thirty new spreads through
|
|
19
|
+
* every record construction site in evaluate(): the engine keys what it receives by `toolUseId`
|
|
20
|
+
* and OVERWRITES on each call, so evaluateWithFreshPolicy's stale-policy re-evaluation replaces
|
|
21
|
+
* the earlier composite instead of doubling its context.
|
|
22
|
+
*/
|
|
23
|
+
onComposite?: (event: "PreToolUse" | "PermissionRequest", call: PermissionCall, composite: HookComposite) => void;
|
|
24
|
+
}
|
|
25
|
+
export declare function createHookStage(deps: HookStageDeps): HookStage;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { ToolInputValidator } from "./runner.js";
|
|
2
|
+
export interface RegistryToolInputValidatorOptions {
|
|
3
|
+
/** Where the once-per-tool "this schema does not compile" note goes. Defaults to stderr. */
|
|
4
|
+
warn?: (line: string) => void;
|
|
5
|
+
}
|
|
6
|
+
export declare function createRegistryToolInputValidator(opts?: RegistryToolInputValidatorOptions): ToolInputValidator;
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import type { HookEvent, HookSource, HookPermissionDecision, PermissionUpdate } from "@yanlinglabs/winter-agent-sdk";
|
|
2
|
+
export interface HookOutcomeFields {
|
|
3
|
+
transformedInput?: Record<string, unknown>;
|
|
4
|
+
transformedOutput?: unknown;
|
|
5
|
+
extraContext?: unknown;
|
|
6
|
+
classifierContext?: string;
|
|
7
|
+
message?: string;
|
|
8
|
+
interrupt?: boolean;
|
|
9
|
+
updatedPermissions?: PermissionUpdate[];
|
|
10
|
+
blockReason?: string;
|
|
11
|
+
preventContinuation?: boolean;
|
|
12
|
+
stopReason?: string;
|
|
13
|
+
systemMessage?: string;
|
|
14
|
+
suppressOutput?: boolean;
|
|
15
|
+
}
|
|
16
|
+
export type HookOutcome = ({
|
|
17
|
+
kind: "decision";
|
|
18
|
+
decision: HookPermissionDecision;
|
|
19
|
+
} & HookOutcomeFields) | ({
|
|
20
|
+
kind: "none";
|
|
21
|
+
} & HookOutcomeFields) | {
|
|
22
|
+
kind: "error";
|
|
23
|
+
reason?: string;
|
|
24
|
+
code?: string;
|
|
25
|
+
} | {
|
|
26
|
+
kind: "timeout";
|
|
27
|
+
} | {
|
|
28
|
+
kind: "skipped";
|
|
29
|
+
};
|
|
30
|
+
export interface HookParticipant {
|
|
31
|
+
id: string;
|
|
32
|
+
name?: string;
|
|
33
|
+
event: HookEvent;
|
|
34
|
+
matcher?: string;
|
|
35
|
+
source: HookSource;
|
|
36
|
+
}
|
|
37
|
+
export interface AttributedContext {
|
|
38
|
+
hookId: string;
|
|
39
|
+
hookName?: string;
|
|
40
|
+
context: unknown;
|
|
41
|
+
}
|
|
42
|
+
export type HookInvocationOutcome = "decision" | "none" | "error" | "timeout" | "skipped";
|
|
43
|
+
export interface HookLifecycleRecord {
|
|
44
|
+
hookId: string;
|
|
45
|
+
hookName?: string;
|
|
46
|
+
event: HookEvent;
|
|
47
|
+
matchedMatcher?: string;
|
|
48
|
+
source: HookSource;
|
|
49
|
+
outcome: HookInvocationOutcome;
|
|
50
|
+
decision?: HookPermissionDecision;
|
|
51
|
+
}
|
|
52
|
+
export interface HookComposite {
|
|
53
|
+
decision?: HookPermissionDecision;
|
|
54
|
+
transformedInput?: Record<string, unknown>;
|
|
55
|
+
transformedOutput?: unknown;
|
|
56
|
+
extraContext?: AttributedContext[];
|
|
57
|
+
classifierContext?: AttributedContext[];
|
|
58
|
+
message?: string;
|
|
59
|
+
interrupt?: boolean;
|
|
60
|
+
updatedPermissions?: PermissionUpdate[];
|
|
61
|
+
blockReasons?: AttributedContext[];
|
|
62
|
+
systemMessages?: AttributedContext[];
|
|
63
|
+
preventContinuation?: {
|
|
64
|
+
hookId: string;
|
|
65
|
+
hookName?: string;
|
|
66
|
+
reason?: string;
|
|
67
|
+
};
|
|
68
|
+
lifecycleMessages: HookLifecycleRecord[];
|
|
69
|
+
}
|
|
70
|
+
export interface HookOutcomeEntry {
|
|
71
|
+
participant: HookParticipant;
|
|
72
|
+
outcome: HookOutcome;
|
|
73
|
+
}
|
|
74
|
+
export declare function reduceHookOutcomes(results: HookOutcomeEntry[]): HookComposite;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { HookEvent } from "@yanlinglabs/winter-agent-sdk";
|
|
2
|
+
import type { HookParticipant } from "./reducer.js";
|
|
3
|
+
export declare const TOOL_SCOPED_HOOK_EVENTS: ReadonlySet<HookEvent>;
|
|
4
|
+
export declare function isToolScopedHookEvent(event: HookEvent): boolean;
|
|
5
|
+
export declare const MATCHER_SUBJECT_FIELD: Readonly<Partial<Record<HookEvent, string>>>;
|
|
6
|
+
export interface SourcedHookEntry extends HookParticipant {
|
|
7
|
+
timeoutMs?: number;
|
|
8
|
+
command?: string;
|
|
9
|
+
/**
|
|
10
|
+
* WS-23: fail CLOSED on PreToolUse/PermissionRequest -- an error, a timeout or a malformed output
|
|
11
|
+
* from THIS hook denies the call (runner.ts's `failClosedDenial`) instead of contributing nothing.
|
|
12
|
+
* Absent = the long-standing non-blocking default. Set from `HookCallbackMatcher.failClosed` (per
|
|
13
|
+
* callback matcher, riding the wire as `RuntimeHookMatcherGroup.failClosed`) or from a settings /
|
|
14
|
+
* plugin command handler's own `failClosed: true`.
|
|
15
|
+
*/
|
|
16
|
+
failClosed?: boolean;
|
|
17
|
+
/**
|
|
18
|
+
* WS-23: the plugin's own root directory, for a plugin-sourced command hook -- exported as
|
|
19
|
+
* `CLAUDE_PLUGIN_ROOT` (and its brand twin) in the hook's environment, so `/bin/sh` expands a
|
|
20
|
+
* `${CLAUDE_PLUGIN_ROOT}` in `command` itself; never spliced into the command text
|
|
21
|
+
* (command-invoker.ts). Absent on every non-plugin entry.
|
|
22
|
+
*/
|
|
23
|
+
pluginRoot?: string;
|
|
24
|
+
}
|
|
25
|
+
export interface HookRegistry {
|
|
26
|
+
matching(event: HookEvent, toolName?: string): SourcedHookEntry[];
|
|
27
|
+
}
|
|
28
|
+
export interface HookRegistryOptions {
|
|
29
|
+
trustedWorkspace?: boolean;
|
|
30
|
+
/** WS-23: where a matcher that will not compile is reported, once. Defaults to stderr. */
|
|
31
|
+
warn?: (line: string) => void;
|
|
32
|
+
}
|
|
33
|
+
export declare function buildHookRegistry(entries: SourcedHookEntry[], opts?: HookRegistryOptions): HookRegistry;
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import type { HookEvent, HookPermissionDecision } from "@yanlinglabs/winter-agent-sdk";
|
|
2
|
+
import { type HookRegistry } from "./registry.js";
|
|
3
|
+
import { type HookComposite } from "./reducer.js";
|
|
4
|
+
export interface HookInvocationRequest {
|
|
5
|
+
event: HookEvent;
|
|
6
|
+
matchedMatcher?: string;
|
|
7
|
+
sessionId: string;
|
|
8
|
+
agentID?: string;
|
|
9
|
+
toolUseID?: string;
|
|
10
|
+
toolName?: string;
|
|
11
|
+
input?: Record<string, unknown>;
|
|
12
|
+
payload?: unknown;
|
|
13
|
+
policyVersion: string;
|
|
14
|
+
requestId: string;
|
|
15
|
+
hookId: string;
|
|
16
|
+
hookName?: string;
|
|
17
|
+
}
|
|
18
|
+
export interface HookInvoker {
|
|
19
|
+
invoke(request: HookInvocationRequest, opts: {
|
|
20
|
+
signal: AbortSignal;
|
|
21
|
+
}): Promise<unknown>;
|
|
22
|
+
}
|
|
23
|
+
export type HookAuditOutcome = "decision" | "none" | "error" | "timeout" | "skipped";
|
|
24
|
+
export interface HookAuditRecord {
|
|
25
|
+
hookId: string;
|
|
26
|
+
hookName?: string;
|
|
27
|
+
hookEvent: HookEvent;
|
|
28
|
+
sessionId: string;
|
|
29
|
+
uuid: string;
|
|
30
|
+
toolUseID?: string;
|
|
31
|
+
requestId?: string;
|
|
32
|
+
outcome: HookAuditOutcome;
|
|
33
|
+
decision?: HookPermissionDecision;
|
|
34
|
+
durationMs?: number;
|
|
35
|
+
agentID?: string;
|
|
36
|
+
}
|
|
37
|
+
export interface HookAuditRecorder {
|
|
38
|
+
record(entry: HookAuditRecord): void | Promise<void>;
|
|
39
|
+
}
|
|
40
|
+
export interface ToolInputValidator {
|
|
41
|
+
validate(toolName: string, input: Record<string, unknown>): {
|
|
42
|
+
valid: true;
|
|
43
|
+
} | {
|
|
44
|
+
valid: false;
|
|
45
|
+
reason?: string;
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
export declare const NO_SCHEMAS_YET_VALIDATOR: ToolInputValidator;
|
|
49
|
+
export interface HookTimeoutConfig {
|
|
50
|
+
gatingTimeoutMs?: number;
|
|
51
|
+
observationalTimeoutMs?: number;
|
|
52
|
+
}
|
|
53
|
+
export declare const DEFAULT_GATING_TIMEOUT_MS = 60000;
|
|
54
|
+
export declare const DEFAULT_OBSERVATIONAL_TIMEOUT_MS = 30000;
|
|
55
|
+
export declare const GATING_HOOK_EVENTS: ReadonlySet<HookEvent>;
|
|
56
|
+
export declare function isGatingHookEvent(event: HookEvent): boolean;
|
|
57
|
+
export interface RunHooksCallInfo {
|
|
58
|
+
toolUseID?: string;
|
|
59
|
+
toolName?: string;
|
|
60
|
+
input?: Record<string, unknown>;
|
|
61
|
+
payload?: unknown;
|
|
62
|
+
}
|
|
63
|
+
export interface HookLifecycleSink {
|
|
64
|
+
started(info: {
|
|
65
|
+
hookId: string;
|
|
66
|
+
hookName?: string;
|
|
67
|
+
hookEvent: HookEvent;
|
|
68
|
+
sessionId: string;
|
|
69
|
+
}): void;
|
|
70
|
+
response(info: {
|
|
71
|
+
hookId: string;
|
|
72
|
+
hookName?: string;
|
|
73
|
+
hookEvent: HookEvent;
|
|
74
|
+
sessionId: string;
|
|
75
|
+
outcome: "success" | "error" | "cancelled";
|
|
76
|
+
stdout?: string;
|
|
77
|
+
stderr?: string;
|
|
78
|
+
exitCode?: number;
|
|
79
|
+
}): void;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* WS-23: the side channel a command hook's own process output rides from the invoker to the lifecycle
|
|
83
|
+
* sink. A SYMBOL-keyed, non-enumerable property on the output object the invoker returns: invisible to
|
|
84
|
+
* every interpreter (which read string keys) and to `JSON.stringify`, so no hook output shape changes.
|
|
85
|
+
* Only a command invoker ever sets it; a callback hook has no process and no stdout.
|
|
86
|
+
*/
|
|
87
|
+
export declare const HOOK_PROCESS_OUTPUT: unique symbol;
|
|
88
|
+
export interface HookProcessOutput {
|
|
89
|
+
stdout: string;
|
|
90
|
+
stderr: string;
|
|
91
|
+
exitCode: number | null;
|
|
92
|
+
}
|
|
93
|
+
export interface RunHooksContext {
|
|
94
|
+
registry: HookRegistry;
|
|
95
|
+
invoker: HookInvoker;
|
|
96
|
+
audit: HookAuditRecorder;
|
|
97
|
+
sessionId: string;
|
|
98
|
+
policyVersion: string | number;
|
|
99
|
+
agentID?: string;
|
|
100
|
+
timeouts?: HookTimeoutConfig;
|
|
101
|
+
validator?: ToolInputValidator;
|
|
102
|
+
lifecycle?: HookLifecycleSink;
|
|
103
|
+
}
|
|
104
|
+
export declare const FAIL_CLOSED_EVENTS: ReadonlySet<HookEvent>;
|
|
105
|
+
export declare function runHooks(event: HookEvent, call: RunHooksCallInfo, ctx: RunHooksContext): Promise<HookComposite>;
|