@namzu/sdk 63.1.0 → 64.1.0
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/CHANGELOG.md +96 -0
- package/dist/agents/QueryAgent.d.ts.map +1 -1
- package/dist/agents/QueryAgent.js +2 -1
- package/dist/agents/QueryAgent.js.map +1 -1
- package/dist/agents/file-definitions.d.ts +10 -0
- package/dist/agents/file-definitions.d.ts.map +1 -1
- package/dist/agents/file-definitions.js +10 -2
- package/dist/agents/file-definitions.js.map +1 -1
- package/dist/compaction/hooks.d.ts +57 -0
- package/dist/compaction/hooks.d.ts.map +1 -0
- package/dist/compaction/hooks.js +44 -0
- package/dist/compaction/hooks.js.map +1 -0
- package/dist/compaction/manual.d.ts +9 -0
- package/dist/compaction/manual.d.ts.map +1 -1
- package/dist/compaction/manual.js +74 -5
- package/dist/compaction/manual.js.map +1 -1
- package/dist/compaction/model-summary.d.ts +6 -0
- package/dist/compaction/model-summary.d.ts.map +1 -1
- package/dist/compaction/model-summary.js +13 -3
- package/dist/compaction/model-summary.js.map +1 -1
- package/dist/compaction/verifier.d.ts +8 -2
- package/dist/compaction/verifier.d.ts.map +1 -1
- package/dist/compaction/verifier.js +23 -7
- package/dist/compaction/verifier.js.map +1 -1
- package/dist/plugin/file-change-hooks.d.ts +53 -0
- package/dist/plugin/file-change-hooks.d.ts.map +1 -0
- package/dist/plugin/file-change-hooks.js +111 -0
- package/dist/plugin/file-change-hooks.js.map +1 -0
- package/dist/plugin/file-change-watch.d.ts +111 -0
- package/dist/plugin/file-change-watch.d.ts.map +1 -0
- package/dist/plugin/file-change-watch.js +324 -0
- package/dist/plugin/file-change-watch.js.map +1 -0
- package/dist/plugin/hook-context.d.ts +16 -0
- package/dist/plugin/hook-context.d.ts.map +1 -1
- package/dist/plugin/hook-context.js +40 -0
- package/dist/plugin/hook-context.js.map +1 -1
- package/dist/plugin/index.d.ts +14 -4
- package/dist/plugin/index.d.ts.map +1 -1
- package/dist/plugin/index.js +10 -3
- package/dist/plugin/index.js.map +1 -1
- package/dist/plugin/lifecycle.d.ts +60 -1
- package/dist/plugin/lifecycle.d.ts.map +1 -1
- package/dist/plugin/lifecycle.js +118 -7
- package/dist/plugin/lifecycle.js.map +1 -1
- package/dist/plugin/loader.d.ts.map +1 -1
- package/dist/plugin/loader.js +24 -1
- package/dist/plugin/loader.js.map +1 -1
- package/dist/plugin/session-hook-env.d.ts +140 -0
- package/dist/plugin/session-hook-env.d.ts.map +1 -0
- package/dist/plugin/session-hook-env.js +458 -0
- package/dist/plugin/session-hook-env.js.map +1 -0
- package/dist/plugin/shell-hook-command.d.ts +25 -0
- package/dist/plugin/shell-hook-command.d.ts.map +1 -0
- package/dist/plugin/shell-hook-command.js +218 -0
- package/dist/plugin/shell-hook-command.js.map +1 -0
- package/dist/plugin/shell-hook-env.d.ts +107 -0
- package/dist/plugin/shell-hook-env.d.ts.map +1 -0
- package/dist/plugin/shell-hook-env.js +272 -0
- package/dist/plugin/shell-hook-env.js.map +1 -0
- package/dist/plugin/shell-hook-tool-names.d.ts +20 -0
- package/dist/plugin/shell-hook-tool-names.d.ts.map +1 -0
- package/dist/plugin/shell-hook-tool-names.js +43 -0
- package/dist/plugin/shell-hook-tool-names.js.map +1 -0
- package/dist/plugin/shell-hook.d.ts +167 -22
- package/dist/plugin/shell-hook.d.ts.map +1 -1
- package/dist/plugin/shell-hook.js +651 -106
- package/dist/plugin/shell-hook.js.map +1 -1
- package/dist/plugin/worktree-hook-answer.d.ts +26 -0
- package/dist/plugin/worktree-hook-answer.d.ts.map +1 -0
- package/dist/plugin/worktree-hook-answer.js +132 -0
- package/dist/plugin/worktree-hook-answer.js.map +1 -0
- package/dist/public-runtime.d.ts +5 -3
- package/dist/public-runtime.d.ts.map +1 -1
- package/dist/public-runtime.js +4 -3
- package/dist/public-runtime.js.map +1 -1
- package/dist/public-types.d.ts +9 -2
- package/dist/public-types.d.ts.map +1 -1
- package/dist/runtime/query/compact-session.d.ts +7 -1
- package/dist/runtime/query/compact-session.d.ts.map +1 -1
- package/dist/runtime/query/compact-session.js +8 -3
- package/dist/runtime/query/compact-session.js.map +1 -1
- package/dist/runtime/query/executor/tool-call-admission.d.ts +1 -1
- package/dist/runtime/query/executor/tool-call-admission.d.ts.map +1 -1
- package/dist/runtime/query/executor/tool-call-admission.js +4 -3
- package/dist/runtime/query/executor/tool-call-admission.js.map +1 -1
- package/dist/runtime/query/executor.d.ts +5 -0
- package/dist/runtime/query/executor.d.ts.map +1 -1
- package/dist/runtime/query/executor.js +8 -3
- package/dist/runtime/query/executor.js.map +1 -1
- package/dist/runtime/query/finalize-turn.d.ts.map +1 -1
- package/dist/runtime/query/finalize-turn.js +9 -2
- package/dist/runtime/query/finalize-turn.js.map +1 -1
- package/dist/runtime/query/index.d.ts +9 -0
- package/dist/runtime/query/index.d.ts.map +1 -1
- package/dist/runtime/query/index.js +3 -0
- package/dist/runtime/query/index.js.map +1 -1
- package/dist/runtime/query/iteration/index.d.ts.map +1 -1
- package/dist/runtime/query/iteration/index.js +2 -1
- package/dist/runtime/query/iteration/index.js.map +1 -1
- package/dist/runtime/query/iteration/phases/compaction.d.ts.map +1 -1
- package/dist/runtime/query/iteration/phases/compaction.js +24 -12
- package/dist/runtime/query/iteration/phases/compaction.js.map +1 -1
- package/dist/runtime/query/iteration/phases/tool-review.d.ts.map +1 -1
- package/dist/runtime/query/iteration/phases/tool-review.js +2 -0
- package/dist/runtime/query/iteration/phases/tool-review.js.map +1 -1
- package/dist/runtime/query/plugin-hooks.d.ts +13 -0
- package/dist/runtime/query/plugin-hooks.d.ts.map +1 -1
- package/dist/runtime/query/plugin-hooks.js +29 -2
- package/dist/runtime/query/plugin-hooks.js.map +1 -1
- package/dist/runtime/query/tooling.d.ts +5 -0
- package/dist/runtime/query/tooling.d.ts.map +1 -1
- package/dist/runtime/query/tooling.js +3 -0
- package/dist/runtime/query/tooling.js.map +1 -1
- package/dist/session/workspace/hooked-driver.d.ts +72 -0
- package/dist/session/workspace/hooked-driver.d.ts.map +1 -0
- package/dist/session/workspace/hooked-driver.js +204 -0
- package/dist/session/workspace/hooked-driver.js.map +1 -0
- package/dist/session/workspace/index.d.ts +2 -0
- package/dist/session/workspace/index.d.ts.map +1 -1
- package/dist/session/workspace/index.js +1 -0
- package/dist/session/workspace/index.js.map +1 -1
- package/dist/skills/index.d.ts +1 -1
- package/dist/skills/index.d.ts.map +1 -1
- package/dist/skills/index.js +1 -1
- package/dist/skills/index.js.map +1 -1
- package/dist/skills/loader.d.ts +22 -0
- package/dist/skills/loader.d.ts.map +1 -1
- package/dist/skills/loader.js +41 -0
- package/dist/skills/loader.js.map +1 -1
- package/dist/tools/builtins/bash-cwd.d.ts +6 -1
- package/dist/tools/builtins/bash-cwd.d.ts.map +1 -1
- package/dist/tools/builtins/bash-cwd.js +27 -2
- package/dist/tools/builtins/bash-cwd.js.map +1 -1
- package/dist/tools/builtins/bash.js +1 -1
- package/dist/tools/builtins/bash.js.map +1 -1
- package/dist/tools/builtins/skill.d.ts.map +1 -1
- package/dist/tools/builtins/skill.js +93 -16
- package/dist/tools/builtins/skill.js.map +1 -1
- package/dist/types/agent/query.d.ts +8 -0
- package/dist/types/agent/query.d.ts.map +1 -1
- package/dist/types/plugin/index.d.ts +130 -13
- package/dist/types/plugin/index.d.ts.map +1 -1
- package/dist/types/plugin/index.js +5 -0
- package/dist/types/plugin/index.js.map +1 -1
- package/dist/types/skills/index.d.ts +8 -0
- package/dist/types/skills/index.d.ts.map +1 -1
- package/dist/types/skills/index.js.map +1 -1
- package/dist/types/tool/index.d.ts +68 -0
- package/dist/types/tool/index.d.ts.map +1 -1
- package/dist/types/tool/index.js.map +1 -1
- package/dist/types/workspace/ref.d.ts +6 -0
- package/dist/types/workspace/ref.d.ts.map +1 -1
- package/dist/utils/frontmatter.d.ts +16 -0
- package/dist/utils/frontmatter.d.ts.map +1 -1
- package/dist/utils/frontmatter.js +31 -1
- package/dist/utils/frontmatter.js.map +1 -1
- package/package.json +1 -1
- package/src/agents/QueryAgent.ts +2 -1
- package/src/agents/file-definitions.ts +17 -2
- package/src/compaction/hooks.ts +104 -0
- package/src/compaction/manual.ts +117 -4
- package/src/compaction/model-summary.ts +19 -3
- package/src/compaction/verifier.ts +33 -3
- package/src/plugin/file-change-hooks.ts +131 -0
- package/src/plugin/file-change-watch.ts +367 -0
- package/src/plugin/hook-context.ts +46 -0
- package/src/plugin/index.ts +53 -1
- package/src/plugin/lifecycle.ts +162 -8
- package/src/plugin/loader.ts +22 -1
- package/src/plugin/session-hook-env.ts +475 -0
- package/src/plugin/shell-hook-command.ts +215 -0
- package/src/plugin/shell-hook-env.ts +335 -0
- package/src/plugin/shell-hook-tool-names.ts +46 -0
- package/src/plugin/shell-hook.ts +818 -100
- package/src/plugin/worktree-hook-answer.ts +142 -0
- package/src/public-runtime.ts +44 -0
- package/src/public-types.ts +22 -1
- package/src/runtime/query/compact-session.ts +16 -4
- package/src/runtime/query/executor/tool-call-admission.ts +10 -2
- package/src/runtime/query/executor.ts +13 -2
- package/src/runtime/query/finalize-turn.ts +9 -2
- package/src/runtime/query/index.ts +12 -0
- package/src/runtime/query/iteration/index.ts +2 -1
- package/src/runtime/query/iteration/phases/compaction.ts +31 -12
- package/src/runtime/query/iteration/phases/tool-review.ts +2 -0
- package/src/runtime/query/plugin-hooks.ts +32 -2
- package/src/runtime/query/tooling.ts +8 -0
- package/src/session/workspace/hooked-driver.ts +272 -0
- package/src/session/workspace/index.ts +7 -0
- package/src/skills/index.ts +3 -0
- package/src/skills/loader.ts +47 -0
- package/src/tools/builtins/bash-cwd.ts +25 -1
- package/src/tools/builtins/bash.ts +1 -1
- package/src/tools/builtins/skill.ts +115 -26
- package/src/types/agent/query.ts +9 -0
- package/src/types/plugin/index.ts +150 -23
- package/src/types/skills/index.ts +9 -0
- package/src/types/tool/index.ts +74 -0
- package/src/types/workspace/ref.ts +6 -0
- package/src/utils/frontmatter.ts +52 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,101 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 64.1.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 53e644a: Hooks gain two events and can set variables for later commands. `file_changed` fires once a watched file has been still for half a second (`filePath`, `change`: `add`, `change` or `unlink`); `cwd_changed` fires when the folder the shell tool's next command starts in changes (`oldCwd`, `newCwd`). Both are in `PluginHookEvent` and `SHELL_HOOK_EVENTS` (`FileChanged`, `CwdChanged` in the common shape); a hook answers with `hookSpecificOutput.watchPaths` (the files to watch from now on) and `systemMessage`, and cannot refuse anything. A command hook on `session_start`, `cwd_changed` or `file_changed` is started with `NAMZU_ENV_FILE`; with `ShellHookOptions.hookEnv` (a `SessionHookEnv`) its `export NAME=value` lines become the environment of later shell commands. New exports: `SessionHookEnv`, `FileChangeHooks`, `FileChangeWatcher`, `fileChangedMatches`, `fileChangedMatcherPaths`, `QueryParams.onWorkingDirectoryChange`, `ToolContext.workingDirectoryChanged`. Nothing is removed or changed by default. If you switch on a union of event names (`PluginHookEvent`, `ShellHookEvent`) with an exhaustive check, add the two new names. A `file_changed` hook that writes the file it watches runs once for the change that started it, not again every half second; a matcher naming a file in a folder not yet made is watched when the folder appears. A variable two hooks of one kind both set takes the value of the one later in the configuration. `__proto__`, `SHELL`, `PYTHONPATH`, `PYTHONHOME`, `RUBYLIB` and the programs Git runs on its own (`GIT_SSH`, `GIT_SSH_COMMAND`, `GIT_ASKPASS`, `GIT_PROXY_COMMAND`, `GIT_EXEC_PATH`, `GIT_EXTERNAL_DIFF`) are refused as hook variables: set `PATH` to reach another interpreter or tool instead. `SessionHookEnv.fileFor` and `absorb` take an optional slot (the hook's place in the configuration); callers that pass none behave as before.
|
|
8
|
+
|
|
9
|
+
A `file_changed` hook attached by anything is watched: `createShellHook` returns a definition with `watches` (the paths its matcher names), `PluginLifecycleManager.listHooks()` lists them, `PluginLifecycleManager.onHooksChanged(listener)` tells a host when hooks come or go, and `FileChangeHooks` follows them, so a hook a plugin ships or a skill carries is watched and fires like one in a config file. `NAMZU_ENV_FILE` joins the names an entry's `env` cannot replace, and an unset variable in a command whose name ends in `_ENV_FILE` is given the same file on the events that have one (`MOVED_FOLDER_ENDINGS` gains `_ENV_FILE`; `MovedFolder` gains `envFile`).
|
|
10
|
+
|
|
11
|
+
- f5be253: An agent file can carry a `hooks` key. Nothing is removed or renamed.
|
|
12
|
+
|
|
13
|
+
What you can now do:
|
|
14
|
+
|
|
15
|
+
- Write a `hooks` block in an agent file's front matter. The kernel keeps the block as text (`AgentFileDefinition.hooksSource`, read by the same raw-block option the skill reader uses) because it is a list of mappings, which the front matter reader cannot hold, and no other key is read differently. `hooks` joins `AGENT_FILE_KEYS`, so a host that checks agent files against that list no longer reports it as an unknown key.
|
|
16
|
+
|
|
17
|
+
What to do: if an agent file of yours already has a `hooks:` block written for another tool, it was ignored until now (or the file was refused, if its shape could not be read). A host that runs agent hooks (the CLI does) will run it for each run of the agent, so read it first. A host that does not read `hooksSource` is not affected.
|
|
18
|
+
|
|
19
|
+
- f5be253: A skill can carry hooks, and a host can take hooks off again. No exported name, key, field or default is removed or renamed. One behaviour changes for a skill that carries a `hooks:` block: a host that does not implement the new optional `SkillRegistryRef.prepareHooks` no longer applies that skill's `allowed-tools` pre-approval (it loads, with a line telling the model why); a skill without a `hooks:` block is read exactly as before.
|
|
20
|
+
|
|
21
|
+
What you can now do:
|
|
22
|
+
|
|
23
|
+
- Write a `hooks` key in a skill's `SKILL.md` front matter. The kernel keeps the block as text (`SkillMetadata.hooksSource`; `parseFrontmatter` takes a `raw` option and returns `rawBlocks`, and `SKILL_FRONTMATTER_RAW_KEYS` lists the keys read this way) because it is a list of mappings, which the front matter reader cannot hold, and no other key is read differently. `hooks` joins `SKILL_FRONTMATTER_KEYS`.
|
|
24
|
+
- Run a skill's hooks from your own host: the `skill` tool asks `SkillRegistryRef.prepareHooks` (new, optional) what to do about a skill that carries them. The answer says what to tell the model, whether the skill's `allowed-tools` pre-approval must be withheld (a guard that could not be loaded must not leave the skill running pre-approved), and `attach`, which the tool calls once the instructions are delivered, and for a `context: fork` skill around the delegated agent's run. A registry without `prepareHooks` loads a skill that carries hooks without its pre-approval and tells the model why.
|
|
25
|
+
- Attach hooks that can leave: `PluginLifecycleManager.attachHooks(pluginId, hooks)` returns a `HookAttachment` whose `remove` takes off exactly the hooks that call attached and `removeAt` one of them. Before, hooks left only by plugin id.
|
|
26
|
+
- Give every command of a `ShellHookOptions` adapter extra variables (`extraEnv`, which never replaces the kernel's own) and hear when a hook was selected to run (`onRun`).
|
|
27
|
+
|
|
28
|
+
What to do: if a skill of yours already has a `hooks:` block written for another tool, it was ignored until now. A host that runs skill hooks (the CLI does) will run it when the skill is used, so read it first. To keep the pre-approval on your own host, implement `prepareHooks` and return `withholdGrants: false`.
|
|
29
|
+
|
|
30
|
+
Also added: a hook event written at the top level of the front matter (`PreToolUse:` beside `name:`) is read as if it were under `hooks:` (`skillHooksSource`, `SKILL_FRONTMATTER_HOOK_EVENT_KEYS`; `SKILL_FRONTMATTER_RAW_KEYS` is unchanged); `SkillHooksOptions.prompt` carries a forked skill's delegated prompt so a host can bind the skill's hooks to the agent that received it; and the `skill` tool is an `executionBarrier`, so in one message the calls written before it finish first and the calls after it wait for it (their `pre_tool_use` hooks were still asked before the batch started, so a skill's `pre_tool_use` guard does not see a call written in the same message).
|
|
31
|
+
|
|
32
|
+
The rule by the shape of a variable name that serves a moved command also serves a skill's hooks: `ShellHookOptions.skillRoot` (new, optional) is the skill's folder, and an unset variable the command or its arguments refer to whose name ends in `_PLUGIN_ROOT` or `_SKILL_ROOT` is given it, under the name the command used. `_PLUGIN_DATA` is not given to a skill. `MovedFolder` gains `'skill'` and `MOVED_FOLDER_ENDINGS` gains `_SKILL_ROOT`; `movedFolderFor` is new.
|
|
33
|
+
|
|
34
|
+
- efcfde6: A hook command written for another tool now finds the project folder. When a shell hook's `command` or `args` refer to a variable (`$NAME` or `${NAME}`) that is not set and whose name ends in `_PROJECT_DIR`, the command is started with that variable set to the project folder, the value of `NAMZU_PROJECT_DIR`. A variable that is already set is never overwritten, and an entry that refers to no such variable starts with exactly the environment it had.
|
|
35
|
+
|
|
36
|
+
A command entry (`ShellHookEntry`) also takes `env`, a map of names to text, for a script that reads such a variable inside its own file. A value may use `$NAME` or `${NAME}` of a variable the hook already has, such as `${NAMZU_PROJECT_DIR}`. The variables Namzu sets for every hook cannot be replaced. When a hook cannot find its program and its command refers to a variable that is set nowhere, its failure reason (and the warning in the log) names the variable and the `env` key. New exports: `shellHookEnvProblems`, `shellHookEnvNameProblem`, `referencedVariables`, `MOVED_FOLDER_ENDINGS`, `SHELL_HOOK_RESERVED_ENV`, and `ShellHookOutcome.unsetVariables`. Nothing existing changes and nothing has to be done to upgrade; if you pass your own environment variable ending in `_PROJECT_DIR` through a hook, it is still never replaced.
|
|
37
|
+
|
|
38
|
+
- efcfde6: A plugin can ship hook entries (a command, an http address or a prompt), and a command started for one finds the plugin's own folder. Nothing existing changes and nothing has to be done to upgrade: a hook command in a config file that refers to a variable ending in `_PLUGIN_ROOT` or `_PLUGIN_DATA` keeps running exactly as it did.
|
|
39
|
+
|
|
40
|
+
For a host that embeds the kernel: `PluginLifecycleManagerConfig.hooksFor` is called when a plugin is enabled and returns the hooks the host read for it; they are registered under the plugin's id, so disabling, uninstalling or a failed enable removes them with the plugin's other hooks, and `listHooks()` marks them `shell: true` so a host can list them apart from the plugin's JavaScript hooks. The manifest gains `hookEntries`, an events object written inline (kept as written; the host reads it), and a path in the manifest's `hooks` that ends in `.json` is now a file of entries and is no longer imported as a module (`isHookEntriesPath`); `hooks` is still a list of paths. `parsePluginManifestText` also reads the two spellings the common hook contract uses, `"hooks": "<file>"` (one path) and `"hooks": { <events> }` (read as `hookEntries`); both used to be refused. `ShellHookOptions.plugin` (`{ root, dataDir }`) starts every command of those entries with `NAMZU_PLUGIN_ROOT` and `NAMZU_PLUGIN_DATA` and creates the data folder when a command first runs. A name ending in `_PLUGIN_ROOT` or `_PLUGIN_DATA` that the command refers to and nothing sets is exported with the folder, under that name, so the script the command starts reads it; a shell command expands it itself and an entry in the exec form (`args`) has the folder put into its command and arguments (`MOVED_FOLDER_ENDINGS`, `isPluginFolderVariable`, `PluginFolders`; `substitutePluginFolders` stays exported).
|
|
41
|
+
|
|
42
|
+
Smaller: the hook's shell is found on the host's own `PATH`, so an entry whose `env` sets `PATH` to something without `sh` still starts; the "refers to variables set nowhere" report skips loop and `read` variables and names a shell keeps for itself (new exports `assignedWithin` and `isShellOwnVariable`); in the exec form the project folder variable (`$X_PROJECT_DIR`) is put into the command and arguments as the plugin folders are.
|
|
43
|
+
|
|
44
|
+
- 53e644a: Hooks can take over making and removing worktrees. `worktree_create` (`WorktreeCreate`) fires before a worktree is made with `worktreeName`, `worktreeRoot` and `worktreeBaseRef`; a shell hook makes the folder and prints it as its last line (or answers `hookSpecificOutput.worktreePath`) and the host uses it instead of Git. `worktree_remove` (`WorktreeRemove`) fires with `worktreePath` and the hook does the removing. With hooks on `worktree_create`, a failure or a missing path fails the creation with the hook's own words and never falls back to Git. New exports: `HookedWorkspaceDriver` and `worktreeHookHost` (wrap any `WorkspaceBackendDriver` so the two events apply to it), `WorktreeHookError`, `worktreeHookVerdict`, and the types `WorkspaceBackendDriver`, `CreateWorkspaceParams`, `BranchWorkspaceParams`, `WorkspaceInspection`, `WorktreeHookHost`, `WorktreeHookContext`; `GitWorktreeBackendMeta.hookOwned` marks a folder a hook made (the Git driver never removes it). Both events are in `PluginHookEvent` and `SHELL_HOOK_EVENTS`; `PluginHookContext` gains `worktreeName`, `worktreeRoot`, `worktreeBaseRef`, `worktreePath` and `PluginHookNotes` gains `worktreePath`. Nothing is removed and no default changes: a host that registers `GitWorktreeDriver` as before behaves as before. If you switch on a union of event names with an exhaustive check, add the two new names.
|
|
45
|
+
|
|
46
|
+
## 64.0.0
|
|
47
|
+
|
|
48
|
+
### Major Changes
|
|
49
|
+
|
|
50
|
+
- f2bbb1e: Breaking: `PluginSessionSource` and `PluginSessionEndReason` are wider unions, so an exhaustive `switch` on them stops compiling until it handles `clear`. A shell hook with no `matcher` on `session_start` or `session_end` also runs for the new occasions (see the CLI note).
|
|
51
|
+
|
|
52
|
+
Hooks can now tell a cleared conversation from the rest. `PluginSessionSource` gains `clear` (a conversation that begins empty after the old one was cleared) and `PluginSessionEndReason` gains `clear` (a conversation that ended because the person cleared it). A shell hook's `matcher` on `session_start` and `session_end` can name them, and its stdin carries them as `source` and `reason`. The existing values, names and fields are unchanged.
|
|
53
|
+
|
|
54
|
+
If your code switches exhaustively on `context.source` or `context.endReason` (a `never` check in the default branch), TypeScript will now ask you to handle `clear`; handle it as you handle `startup` for a start and `replaced` for an end if you have no other plan. This is the only thing that can fail to compile; nothing at runtime changes for a host that does not announce a clear. A host that embeds the kernel announces a clear by running `executeHooks('session_end', { endReason: 'clear', ... })` and `executeHooks('session_start', { source: 'clear', ... })` itself.
|
|
55
|
+
|
|
56
|
+
- f2bbb1e: Breaking default: what an attached shell hook prints to stdout on `pre_compact` (exit 0, not JSON) used to be ignored and is now given to the summariser. To keep the old behaviour, print it to stderr.
|
|
57
|
+
|
|
58
|
+
Hooks now see every compaction and the model's last message, and a `pre_compact` hook can say what the summary keeps.
|
|
59
|
+
|
|
60
|
+
- `pre_compact` and `post_compact` fire for a pass a person asked for (`compactNow`, `compactRegion`, `compactSession`, `compactSessionRange` with the new `hooks` option, `{ manager }`) and for the idle pass, not only for the kernel's own. The context's `compaction` gains `trigger` (`manual` or `auto`; idle is `auto`), `instructions` on `pre_compact` (what the person typed, or `null`) and `summary` on `post_compact` (8000 characters at most). A shell hook's `matcher` on these events tests `trigger`; its stdin gains `trigger`, `custom_instructions` and `compact_summary`.
|
|
61
|
+
- A `pre_compact` refusal now also refuses a pass a person asked for: those functions throw the new `CompactionRefusedError` (with `reason`); an idle pass is cancelled and returns `null`. A pass the provider forced still cannot be refused.
|
|
62
|
+
- What a `pre_compact` hook prints with exit 0, its `additionalContext`, or an in-process `annotate` (now accepted on this event) or `continue` with `context` is given to the summariser after the person's instructions, framed as a hook's, 8000 characters at most. The summary model step runs for it even with `llmVerification` off. A hook that prints to stdout on `pre_compact` for its own log now has that text sent to the summariser: print to stderr instead.
|
|
63
|
+
- `turn_end` and `subagent_stop` carry `lastAssistantMessage` (`last_assistant_message` in the shell payload), 8000 characters at most, absent when the turn produced no text.
|
|
64
|
+
|
|
65
|
+
`PluginCompactionInfo.reason` gains the value `manual` (used by passes a host asks for outside a turn); a consumer that switches exhaustively on `reason` should handle it, or test `trigger` instead. Nothing is removed or renamed.
|
|
66
|
+
|
|
67
|
+
### Minor Changes
|
|
68
|
+
|
|
69
|
+
- 33b320e: A shell hook entry can ask for the tool names a person writes in a matcher. Nothing is removed or renamed and no default changes.
|
|
70
|
+
|
|
71
|
+
What you can now do:
|
|
72
|
+
|
|
73
|
+
- Give an entry `toolNames: 'written'` (type `ShellHookToolNames`, on every entry kind) and its hook is sent `Bash`, `Edit`, `WebFetch` as `tool_name`, as `NAMZU_TOOL_NAME` and inside `tool_calls` on `post_tool_batch`, so a script that tests `tool_name == "Bash"` works unchanged. `toolNames: 'namzu'`, or no key, keeps the name the tool is registered under (`bash`). A tool with no common name (`job`, `view_image`) and every tool-server tool keep their own names; nothing else in the payload depends on the key, and `matcher` and `if` read either spelling whichever you choose.
|
|
74
|
+
- Use the same table yourself: `SHELL_HOOK_WRITTEN_TOOL_NAMES` and `shellHookToolName(name, mode)`. `SHELL_HOOK_PASCAL_EVENT_NAMES` is the table of PascalCase event names (`PreToolUse`) a host needs to read a hooks block written in the common shape; `attachShellHooks` still takes entries of the SDK's own shape only, and the reading of the other shape is the host's.
|
|
75
|
+
|
|
76
|
+
Nothing you must do.
|
|
77
|
+
|
|
78
|
+
- 33b320e: A shell hook moved from the common hook contract now sees the values it reads, and its answers are read in the shapes it writes. Nothing is removed or renamed; what is added sits beside what was there.
|
|
79
|
+
|
|
80
|
+
What you can now do:
|
|
81
|
+
|
|
82
|
+
- Pair a before and an after: `pre_tool_use`, `post_tool_use`, `post_tool_use_failure`, `permission_request` and `permission_denied` carry `tool_use_id`, the id `post_tool_batch` already carried (in process, the optional `PluginHookContext.toolCallId`). A call a tool makes through `dispatchTool` has no model-issued id and carries none.
|
|
83
|
+
- Read a file tool's file as `.tool_input.file_path`: for `read`, `write`, `edit`, `grep`, `glob`, `ls`, `view_image` and `lsp` the input has `file_path` with the same value as `path`. A `pre_tool_use` rewrite that echoes it is read: if one of the two keys changed, that is the new path; two different values make the answer unreadable.
|
|
84
|
+
- Answer `updatedToolOutput` with any JSON type: a string, an object shaped like the result (`output`, optional `success` and `error`), any other object, array, number or boolean (shown as JSON text), or `null` for no replacement. It is also read on `post_tool_use_failure`, and `updatedMCPToolOutput` is read for tool-server tools (`updatedToolOutput` wins when both are set). The documentation lists every remaining way a replacement can leave the original result shown, and what `onFailure` does for each.
|
|
85
|
+
- Write `if: "Agent"`, `Task`, `Edit|Write`, `mcp__github__*`: the tool part takes every spelling a `matcher` list takes, and the sub-agent tool `Agent` is named by `Agent` and `Task`. A shell-command `if` matches through `env`, `sudo`, `nohup`, `xargs`, `find -exec`, a full program path and git's global options, and runs the hook for a command whose name is only known at run time.
|
|
86
|
+
- `matcher` reads a glob in the middle of a name (`mcp__*__get_issue`) and a bare tool-server name (`mcp__github`), and a name without its `_` (`ViewImage`). New exports: `shellHookMatcherProblem`, `shellHookIfProblem`, `ShellHookCall`. `QueryAgentConfig.agentType` names the agent to `subagent_start` and `subagent_stop` hooks.
|
|
87
|
+
- A `matcher` on an event that has no name to match (`turn_end`, `user_prompt_submit`, `turn_start`, `turn_failure`, `post_tool_batch`) is ignored and the hook fires, as in the common contract; it used to match nothing, so a moved `Stop` or `UserPromptSubmit` group with a matcher never ran.
|
|
88
|
+
- With `onFailure: block`, a redaction on `post_tool_use` or `post_tool_use_failure` that put its answer where it is not read (`updatedToolOutput` at the top level of the answer, a log line before the JSON, the JSON on stderr) withholds the result instead of showing the original. `shellHookMatcherProblem` also reports a matcher written as `Tool(pattern)`, which is an `if`.
|
|
89
|
+
- `if` also reads through `busybox`, `watch` and `flock`.
|
|
90
|
+
- `subagent_stop` now carries `agentType` on every path a child's turn ends by.
|
|
91
|
+
|
|
92
|
+
What changes for a config that works today, and what to do:
|
|
93
|
+
|
|
94
|
+
- A `matcher` that is not a valid regular expression used to match nothing, so its hook never ran; it now matches every name, so the hook runs. Fix the pattern (`namzu doctor` and `/hooks` now say which one), or attach the hook with an `if`.
|
|
95
|
+
- A `matcher` of `Task` now also fires for the sub-agent tool `Agent`.
|
|
96
|
+
- An `updatedToolOutput` that is not a string used to make the whole answer unreadable (and, with `onFailure: continue`, show the original result); it is now the replacement.
|
|
97
|
+
- A hook that reads `tool_input` strictly, comparing the whole object, sees the added `file_path`.
|
|
98
|
+
|
|
3
99
|
## 63.1.0
|
|
4
100
|
|
|
5
101
|
### Minor Changes
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"QueryAgent.d.ts","sourceRoot":"","sources":["../../src/agents/QueryAgent.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAEX,aAAa,EACb,iBAAiB,EACjB,gBAAgB,EAChB,gBAAgB,EAChB,MAAM,yBAAyB,CAAA;AAGhC,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAA;AACtE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAA;AAChD,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;
|
|
1
|
+
{"version":3,"file":"QueryAgent.d.ts","sourceRoot":"","sources":["../../src/agents/QueryAgent.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAEX,aAAa,EACb,iBAAiB,EACjB,gBAAgB,EAChB,gBAAgB,EAChB,MAAM,yBAAyB,CAAA;AAGhC,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAA;AACtE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAA;AAChD,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AA0JlD,qBAAa,UAAW,SAAQ,aAAa,CAAC,gBAAgB,EAAE,gBAAgB,CAAC;IAChF,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;gBAET,QAAQ,EAAE,IAAI,CAAC,aAAa,EAAE,cAAc,CAAC,EAAE,GAAG,CAAC,EAAE,MAAM;IAiBvE;;;;;;;;OAQG;IACG,GAAG,CACR,KAAK,EAAE,iBAAiB,EACxB,MAAM,EAAE,gBAAgB,EACxB,QAAQ,CAAC,EAAE,oBAAoB,GAC7B,OAAO,CAAC,gBAAgB,CAAC;YAmBd,YAAY;IAqEX,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC;CAGtC"}
|
|
@@ -31,6 +31,7 @@ const configRoutes = {
|
|
|
31
31
|
fileReadTracker: 'query',
|
|
32
32
|
deniedTools: 'special',
|
|
33
33
|
persona: 'query',
|
|
34
|
+
agentType: 'special',
|
|
34
35
|
logger: 'special',
|
|
35
36
|
env: 'turn',
|
|
36
37
|
thinking: 'turn',
|
|
@@ -186,7 +187,7 @@ export class QueryAgent extends AbstractAgent {
|
|
|
186
187
|
},
|
|
187
188
|
agentId: this.metadata.id,
|
|
188
189
|
agentName: this.metadata.name,
|
|
189
|
-
agentType: this.type,
|
|
190
|
+
agentType: config.agentType ?? this.type,
|
|
190
191
|
workingDirectory: input.workingDirectory,
|
|
191
192
|
sessionId: scope.sessionId,
|
|
192
193
|
topicId: scope.topicId,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"QueryAgent.js","sourceRoot":"","sources":["../../src/agents/QueryAgent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAA;AAYtD,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAClD,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAA;AAExD,oFAAoF;AACpF,MAAM,YAAY,GAAG;IACpB,KAA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AC,QAAQ,EAAE,CAAC;YACjC,IAAI,GAAG,CAAC,IAAI,KAAK,WAAW,EAAE,CAAC;gBAC9B,MAAM,YAAY,GAAG,GAAuB,CAAA;gBAC5C,IAAI,YAAY,CAAC,SAAS,EAAE,CAAC;oBAC5B,aAAa,IAAI,YAAY,CAAC,SAAS,CAAC,MAAM,CAAA;gBAC/C,CAAC;YACF,CAAC;QACF,CAAC;QAED,OAAO;YACN,SAAS,EAAE,IAAI,CAAC,SAAS;YACzB,MAAM,EAAE,IAAI,CAAC,EAAE;YACf,MAAM,EAAE,IAAI,CAAC,MAAM;YACnB,UAAU,EAAE,IAAI,CAAC,UAAU;YAC3B,KAAK,EAAE,IAAI,CAAC,UAAU;YACtB,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;YAC/C,IAAI,EAAE,IAAI,CAAC,QAAQ;YACnB,UAAU,EAAE,IAAI,CAAC,gBAAgB;YACjC,UAAU,EAAE,IAAI,CAAC,GAAG,EAAE,GAAG,SAAS;YAClC,QAAQ,EAAE,IAAI,CAAC,QAAQ;YACvB,MAAM,EAAE,IAAI,CAAC,MAAM;YACnB,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;YAClD,gBAAgB,EAAE,IAAI,CAAC,gBAAgB;YACvC,SAAS,EAAE,IAAI,CAAC,SAAS;YACzB,aAAa;SACb,CAAA;IACF,CAAC;IAEQ,KAAK,CAAC,MAAM;QACpB,IAAI,CAAC,eAAe,CAAC,KAAK,EAAE,CAAA;IAC7B,CAAC;CACD"}
|
|
@@ -27,6 +27,10 @@
|
|
|
27
27
|
* You review changes for this repository. Cite file:line for every finding …
|
|
28
28
|
* ```
|
|
29
29
|
*
|
|
30
|
+
* `hooks` is a block of hook entries in either shape a config file takes (see
|
|
31
|
+
* `AgentFileDefinition.hooksSource`); the kernel keeps its text and the host
|
|
32
|
+
* reads it.
|
|
33
|
+
*
|
|
30
34
|
* `tools`, `disallowedTools` and `skills` are each one comma-separated line: this kernel's frontmatter reader
|
|
31
35
|
* refuses block lists and flow sequences by design, so there is no other
|
|
32
36
|
* form to accept.
|
|
@@ -79,6 +83,12 @@ export interface AgentFileDefinition {
|
|
|
79
83
|
*/
|
|
80
84
|
readonly permissionMode?: string;
|
|
81
85
|
readonly readOnly: boolean;
|
|
86
|
+
/**
|
|
87
|
+
* The text of the file's `hooks` key, as written (the key's own line and the
|
|
88
|
+
* lines under it), for the host to read with a YAML reader: the frontmatter
|
|
89
|
+
* reader here cannot hold a list of mappings. The kernel only keeps it.
|
|
90
|
+
*/
|
|
91
|
+
readonly hooksSource?: string;
|
|
82
92
|
readonly path: string;
|
|
83
93
|
/** The host's label for the root this file came from (`user`, `project`, …). */
|
|
84
94
|
readonly source: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"file-definitions.d.ts","sourceRoot":"","sources":["../../src/agents/file-definitions.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"file-definitions.d.ts","sourceRoot":"","sources":["../../src/agents/file-definitions.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4CG;AAKH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAA;AAGhE,OAAO,EAAE,KAAK,MAAM,EAAiB,MAAM,oBAAoB,CAAA;AAE/D,qDAAqD;AACrD,eAAO,MAAM,oBAAoB,QAAS,CAAA;AAK1C,kFAAkF;AAClF,eAAO,MAAM,4BAA4B,EAAE,WAAW,CAAC,MAAM,CAG3D,CAAA;AAeF;;;;;GAKG;AACH,eAAO,MAAM,eAAe,EAAE,SAAS,MAAM,EAc3C,CAAA;AAEF,MAAM,WAAW,mBAAmB;IACnC,QAA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;IAC1C,kFAAkF;IAClF,QAAQ,CAAC,WAAW,EAAE,SAAS,mBAAmB,EAAE,CAAA;IACpD,QAAQ,CAAC,OAAO,EAAE,SAAS,gBAAgB,EAAE,CAAA;CAC7C;AAED,MAAM,WAAW,+BAA+B;IAC/C,2EAA2E;IAC3E,QAAQ,CAAC,QAAQ,CAAC,EAAE,WAAW,CAAC,MAAM,CAAC,CAAA;IACvC;;;OAGG;IACH,QAAQ,CAAC,eAAe,CAAC,EAAE,WAAW,CAAC,MAAM,CAAC,CAAA;IAC9C,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,CAAA;CACrB;AAED;;;;GAIG;AACH,wBAAsB,wBAAwB,CAC7C,KAAK,EAAE,SAAS,mBAAmB,EAAE,EACrC,OAAO,GAAE,+BAAoC,GAC3C,OAAO,CAAC,0BAA0B,CAAC,CA2BrC;AAED,wBAAsB,cAAc,CACnC,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,MAAM,EACd,QAAQ,GAAE,WAAW,CAAC,MAAM,CAAgC,EAC5D,eAAe,CAAC,EAAE,WAAW,CAAC,MAAM,CAAC,GACnC,OAAO,CAAC,mBAAmB,GAAG,gBAAgB,CAAC,CAcjD;AAED,0EAA0E;AAC1E,wBAAgB,kBAAkB,CACjC,GAAG,EAAE,MAAM,EACX,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,MAAM,EACd,QAAQ,GAAE,WAAW,CAAC,MAAM,CAAgC,EAC5D,eAAe,CAAC,EAAE,WAAW,CAAC,MAAM,CAAC,GACnC,mBAAmB,GAAG,gBAAgB,CA+IxC"}
|
|
@@ -27,6 +27,10 @@
|
|
|
27
27
|
* You review changes for this repository. Cite file:line for every finding …
|
|
28
28
|
* ```
|
|
29
29
|
*
|
|
30
|
+
* `hooks` is a block of hook entries in either shape a config file takes (see
|
|
31
|
+
* `AgentFileDefinition.hooksSource`); the kernel keeps its text and the host
|
|
32
|
+
* reads it.
|
|
33
|
+
*
|
|
30
34
|
* `tools`, `disallowedTools` and `skills` are each one comma-separated line: this kernel's frontmatter reader
|
|
31
35
|
* refuses block lists and flow sequences by design, so there is no other
|
|
32
36
|
* form to accept.
|
|
@@ -83,6 +87,7 @@ export const AGENT_FILE_KEYS = Object.freeze([
|
|
|
83
87
|
'skills',
|
|
84
88
|
'permissionMode',
|
|
85
89
|
'readOnly',
|
|
90
|
+
'hooks',
|
|
86
91
|
]);
|
|
87
92
|
/**
|
|
88
93
|
* Every `*.md` in every root, later roots shadowing earlier ones by name.
|
|
@@ -138,7 +143,7 @@ export function parseAgentMarkdown(raw, path, source, reserved = DEFAULT_RESERVE
|
|
|
138
143
|
}
|
|
139
144
|
let parsed;
|
|
140
145
|
try {
|
|
141
|
-
parsed = parseFrontmatter(raw, path);
|
|
146
|
+
parsed = parseFrontmatter(raw, path, { raw: ['hooks'] });
|
|
142
147
|
}
|
|
143
148
|
catch (error) {
|
|
144
149
|
return {
|
|
@@ -146,7 +151,7 @@ export function parseAgentMarkdown(raw, path, source, reserved = DEFAULT_RESERVE
|
|
|
146
151
|
reason: `frontmatter did not parse: ${error instanceof Error ? error.message : String(error)}`,
|
|
147
152
|
};
|
|
148
153
|
}
|
|
149
|
-
const { values, body } = parsed;
|
|
154
|
+
const { values, body, rawBlocks } = parsed;
|
|
150
155
|
const name = scalar(values.name);
|
|
151
156
|
if (name === undefined)
|
|
152
157
|
return { path, reason: 'has no `name:` in its frontmatter' };
|
|
@@ -246,6 +251,8 @@ export function parseAgentMarkdown(raw, path, source, reserved = DEFAULT_RESERVE
|
|
|
246
251
|
}
|
|
247
252
|
readOnly = flag === 'true';
|
|
248
253
|
}
|
|
254
|
+
const hooksText = Object.hasOwn(rawBlocks, 'hooks') ? rawBlocks.hooks : undefined;
|
|
255
|
+
const hooksSource = hooksText !== undefined && hooksText.trim() !== '' ? hooksText : undefined;
|
|
249
256
|
const trimmed = body.trim();
|
|
250
257
|
if (trimmed.length === 0) {
|
|
251
258
|
return { path, reason: "has an empty body; the body is the agent's system prompt" };
|
|
@@ -267,6 +274,7 @@ export function parseAgentMarkdown(raw, path, source, reserved = DEFAULT_RESERVE
|
|
|
267
274
|
...(preloaded.list ? { skills: preloaded.list } : {}),
|
|
268
275
|
...(permissionMode ? { permissionMode } : {}),
|
|
269
276
|
readOnly,
|
|
277
|
+
...(hooksSource !== undefined ? { hooksSource } : {}),
|
|
270
278
|
path,
|
|
271
279
|
source,
|
|
272
280
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"file-definitions.js","sourceRoot":"","sources":["../../src/agents/file-definitions.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"file-definitions.js","sourceRoot":"","sources":["../../src/agents/file-definitions.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4CG;AAEH,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAA;AAC1D,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAGhC,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAA;AAC1D,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAA;AACvD,OAAO,EAAe,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAE/D,qDAAqD;AACrD,MAAM,CAAC,MAAM,oBAAoB,GAAG,MAAM,CAAA;AAE1C,iDAAiD;AACjD,MAAM,oBAAoB,GAAG,CAAC,GAAG,IAAI,GAAG,IAAI,CAAA;AAE5C,kFAAkF;AAClF,MAAM,CAAC,MAAM,4BAA4B,GAAwB,IAAI,GAAG,CAAC;IACxE,iBAAiB;IACjB,SAAS;CACT,CAAC,CAAA;AAEF,MAAM,aAAa,GAAwB,IAAI,GAAG,CAAkB;IACnE,MAAM;IACN,SAAS;IACT,KAAK;IACL,QAAQ;IACR,MAAM;IACN,OAAO;IACP,KAAK;IACL,OAAO;CACP,CAAC,CAAA;AAEF,MAAM,YAAY,G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CAAC,KAAuB;IAC1C,IAAI,KAAK,CAAC,IAAI,KAAK,QAAQ;QAAE,OAAO,SAAS,CAAA;IAC7C,MAAM,IAAI,GAAG,KAAK,CAAC,KAAK,CAAC,IAAI,EAAE,CAAA;IAC/B,MAAM,KAAK,GAAG,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAA;IACnF,MAAM,KAAK,GAAG,KAAK;SACjB,KAAK,CAAC,GAAG,CAAC;SACV,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC;SAC1B,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAA;IACnC,OAAO,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAA;AAC5C,CAAC"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import type { SessionId, TurnId } from '../types/ids/index.js';
|
|
2
|
+
import type { PluginCompactionInfo, PluginHookContext, PluginHookEvent, PluginHookResult } from '../types/plugin/index.js';
|
|
3
|
+
import type { SessionEvent } from '../types/session/index.js';
|
|
4
|
+
/**
|
|
5
|
+
* What a compaction needs of the plugin lifecycle manager: the one call that
|
|
6
|
+
* runs the hooks of an event. Structural, so a pass outside a turn does not
|
|
7
|
+
* need the manager's whole type.
|
|
8
|
+
*/
|
|
9
|
+
export interface CompactionHookHost {
|
|
10
|
+
executeHooks(event: PluginHookEvent, context: Omit<PluginHookContext, 'pluginId' | 'event'>, emitSessionEvent?: (event: SessionEvent) => Promise<void>): Promise<PluginHookResult[]>;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* The hooks around a compaction pass a host asked for outside any turn: a
|
|
14
|
+
* person's `/compact`, a summarised span, an idle pass. The pass fires
|
|
15
|
+
* `pre_compact` and `post_compact` as an automatic one does, on the same
|
|
16
|
+
* payload, with `trigger` saying which it is.
|
|
17
|
+
*/
|
|
18
|
+
export interface ManualCompactionHooks {
|
|
19
|
+
readonly manager: CompactionHookHost;
|
|
20
|
+
readonly sessionId: SessionId;
|
|
21
|
+
/** `manual` (the default) is a person's request; `idle` is a host compacting a quiet conversation, which the hooks see as `auto`. */
|
|
22
|
+
readonly trigger?: 'manual' | 'idle';
|
|
23
|
+
readonly emitEvent?: (event: SessionEvent) => Promise<void>;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* A `pre_compact` hook refused a pass a person asked for. Thrown by
|
|
27
|
+
* {@link compactNow}, {@link compactRegion} and the session variants; a host
|
|
28
|
+
* shows {@link CompactionRefusedError.reason} in one line. A pass the kernel
|
|
29
|
+
* started on its own is cancelled quietly instead, and one the provider forced
|
|
30
|
+
* cannot be refused.
|
|
31
|
+
*/
|
|
32
|
+
export declare class CompactionRefusedError extends Error {
|
|
33
|
+
readonly reason: string;
|
|
34
|
+
constructor(reason: string);
|
|
35
|
+
}
|
|
36
|
+
/** What the `pre_compact` hooks of a pass answered. */
|
|
37
|
+
export interface PreCompactAnswer {
|
|
38
|
+
/** The first refusal in answer order, when any hook refused. */
|
|
39
|
+
readonly refusal?: string;
|
|
40
|
+
/** What the hooks said the summary should keep, joined and bounded. */
|
|
41
|
+
readonly instructions?: string;
|
|
42
|
+
}
|
|
43
|
+
/** Run the `pre_compact` hooks and read their answers. `error` answers throw, as in a turn. */
|
|
44
|
+
export declare function askPreCompact(host: CompactionHookHost, base: {
|
|
45
|
+
readonly sessionId: SessionId;
|
|
46
|
+
readonly turnId?: TurnId;
|
|
47
|
+
readonly iteration?: number;
|
|
48
|
+
readonly signal?: AbortSignal;
|
|
49
|
+
readonly emitEvent?: (event: SessionEvent) => Promise<void>;
|
|
50
|
+
}, compaction: PluginCompactionInfo): Promise<PreCompactAnswer>;
|
|
51
|
+
/** The summary a `post_compact` hook receives, bounded; the pass's own text is not cut. */
|
|
52
|
+
export declare function postCompactSummary(summary: string | undefined): {
|
|
53
|
+
summary?: string;
|
|
54
|
+
};
|
|
55
|
+
/** The text of a message, for a hook: only a string body counts. */
|
|
56
|
+
export declare function messageText(content: unknown): string | undefined;
|
|
57
|
+
//# sourceMappingURL=hooks.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hooks.d.ts","sourceRoot":"","sources":["../../src/compaction/hooks.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAA;AAC9D,OAAO,KAAK,EACX,oBAAoB,EACpB,iBAAiB,EACjB,eAAe,EACf,gBAAgB,EAChB,MAAM,0BAA0B,CAAA;AACjC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAA;AAE7D;;;;GAIG;AACH,MAAM,WAAW,kBAAkB;IAClC,YAAY,CACX,KAAK,EAAE,eAAe,EACtB,OAAO,EAAE,IAAI,CAAC,iBAAiB,EAAE,UAAU,GAAG,OAAO,CAAC,EACtD,gBAAgB,CAAC,EAAE,CAAC,KAAK,EAAE,YAAY,KAAK,OAAO,CAAC,IAAI,CAAC,GACvD,OAAO,CAAC,gBAAgB,EAAE,CAAC,CAAA;CAC9B;AAED;;;;;GAKG;AACH,MAAM,WAAW,qBAAqB;IACrC,QAAQ,CAAC,OAAO,EAAE,kBAAkB,CAAA;IACpC,QAAQ,CAAC,SAAS,EAAE,SAAS,CAAA;IAC7B,qIAAqI;IACrI,QAAQ,CAAC,OAAO,CAAC,EAAE,QAAQ,GAAG,MAAM,CAAA;IACpC,QAAQ,CAAC,SAAS,CAAC,EAAE,CAAC,KAAK,EAAE,YAAY,KAAK,OAAO,CAAC,IAAI,CAAC,CAAA;CAC3D;AAED;;;;;;GAMG;AACH,qBAAa,sBAAuB,SAAQ,KAAK;IAChD,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;gBACX,MAAM,EAAE,MAAM;CAK1B;AAED,uDAAuD;AACvD,MAAM,WAAW,gBAAgB;IAChC,gEAAgE;IAChE,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAA;IACzB,uEAAuE;IACvE,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,CAAA;CAC9B;AAED,+FAA+F;AAC/F,wBAAsB,aAAa,CAClC,IAAI,EAAE,kBAAkB,EACxB,IAAI,EAAE;IACL,QAAQ,CAAC,SAAS,EAAE,SAAS,CAAA;IAC7B,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAA;IACxB,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAA;IAC3B,QAAQ,CAAC,MAAM,CAAC,EAAE,WAAW,CAAA;IAC7B,QAAQ,CAAC,SAAS,CAAC,EAAE,CAAC,KAAK,EAAE,YAAY,KAAK,OAAO,CAAC,IAAI,CAAC,CAAA;CAC3D,EACD,UAAU,EAAE,oBAAoB,GAC9B,OAAO,CAAC,gBAAgB,CAAC,CAmB3B;AAED,2FAA2F;AAC3F,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,MAAM,GAAG,SAAS,GAAG;IAAE,OAAO,CAAC,EAAE,MAAM,CAAA;CAAE,CAGpF;AAED,oEAAoE;AACpE,wBAAgB,WAAW,CAAC,OAAO,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,CAEhE"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { boundCompactionSummary, compactionHookInstructions } from '../plugin/hook-context.js';
|
|
2
|
+
import { applyLifecycleHookResults } from '../runtime/query/plugin-hooks.js';
|
|
3
|
+
/**
|
|
4
|
+
* A `pre_compact` hook refused a pass a person asked for. Thrown by
|
|
5
|
+
* {@link compactNow}, {@link compactRegion} and the session variants; a host
|
|
6
|
+
* shows {@link CompactionRefusedError.reason} in one line. A pass the kernel
|
|
7
|
+
* started on its own is cancelled quietly instead, and one the provider forced
|
|
8
|
+
* cannot be refused.
|
|
9
|
+
*/
|
|
10
|
+
export class CompactionRefusedError extends Error {
|
|
11
|
+
reason;
|
|
12
|
+
constructor(reason) {
|
|
13
|
+
super(`A pre_compact hook refused the compaction: ${reason}`);
|
|
14
|
+
this.name = 'CompactionRefusedError';
|
|
15
|
+
this.reason = reason;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
/** Run the `pre_compact` hooks and read their answers. `error` answers throw, as in a turn. */
|
|
19
|
+
export async function askPreCompact(host, base, compaction) {
|
|
20
|
+
const results = await host.executeHooks('pre_compact', {
|
|
21
|
+
sessionId: base.sessionId,
|
|
22
|
+
...(base.turnId !== undefined ? { turnId: base.turnId } : {}),
|
|
23
|
+
...(base.iteration !== undefined ? { iteration: base.iteration } : {}),
|
|
24
|
+
compaction,
|
|
25
|
+
...(base.signal ? { signal: base.signal } : {}),
|
|
26
|
+
}, base.emitEvent);
|
|
27
|
+
applyLifecycleHookResults('pre_compact', results);
|
|
28
|
+
const refusal = results.find((result) => result.action === 'skip');
|
|
29
|
+
const instructions = compactionHookInstructions(results);
|
|
30
|
+
return {
|
|
31
|
+
...(refusal?.action === 'skip' ? { refusal: refusal.reason } : {}),
|
|
32
|
+
...(instructions !== undefined ? { instructions } : {}),
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
/** The summary a `post_compact` hook receives, bounded; the pass's own text is not cut. */
|
|
36
|
+
export function postCompactSummary(summary) {
|
|
37
|
+
const bounded = boundCompactionSummary(summary);
|
|
38
|
+
return bounded === undefined ? {} : { summary: bounded };
|
|
39
|
+
}
|
|
40
|
+
/** The text of a message, for a hook: only a string body counts. */
|
|
41
|
+
export function messageText(content) {
|
|
42
|
+
return typeof content === 'string' ? content : undefined;
|
|
43
|
+
}
|
|
44
|
+
//# sourceMappingURL=hooks.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hooks.js","sourceRoot":"","sources":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M,YAAY,GAAG,0BAA0B,CAAC,OAAO,CAAC,CAAA;IACxD,OAAO;QACN,GAAG,CAAC,OAAO,EAAE,MAAM,KAAK,MAAM,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QAClE,GAAG,CAAC,YAAY,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,YAAY,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KACvD,CAAA;AACF,CAAC;AAED,2FAA2F;AAC3F,MAAM,UAAU,kBAAkB,CAAC,OAA2B;IAC7D,MAAM,OAAO,GAAG,sBAAsB,CAAC,OAAO,CAAC,CAAA;IAC/C,OAAO,OAAO,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,OAAO,EAAE,CAAA;AACzD,CAAC;AAED,oEAAoE;AACpE,MAAM,UAAU,WAAW,CAAC,OAAgB;IAC3C,OAAO,OAAO,OAAO,KAAK,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS,CAAA;AACzD,CAAC"}
|
|
@@ -2,6 +2,7 @@ import type { CompactionConfig } from '../config/runtime.js';
|
|
|
2
2
|
import { type TokenUsage } from '../types/common/index.js';
|
|
3
3
|
import type { Message } from '../types/message/index.js';
|
|
4
4
|
import type { LLMProvider } from '../types/provider/index.js';
|
|
5
|
+
import { type ManualCompactionHooks } from './hooks.js';
|
|
5
6
|
import { type CompactionSummaryRouter } from './model-summary.js';
|
|
6
7
|
import { type CompactionVerificationOptions } from './verifier.js';
|
|
7
8
|
/**
|
|
@@ -58,6 +59,14 @@ export interface CompactNowInput extends CompactionVerificationOptions {
|
|
|
58
59
|
* summary is built from the extracted state as before.
|
|
59
60
|
*/
|
|
60
61
|
readonly summaryRoute?: CompactionSummaryRouter;
|
|
62
|
+
/**
|
|
63
|
+
* Fire `pre_compact` and `post_compact` around the pass, as an automatic
|
|
64
|
+
* one does. A `pre_compact` refusal of a person's pass throws
|
|
65
|
+
* {@link CompactionRefusedError}; of an idle pass, ends it as a no-op
|
|
66
|
+
* (`null`). What the hooks print for the summariser joins the person's
|
|
67
|
+
* `instructions`. Absent, no hook runs.
|
|
68
|
+
*/
|
|
69
|
+
readonly hooks?: ManualCompactionHooks;
|
|
61
70
|
}
|
|
62
71
|
/**
|
|
63
72
|
* Compact a history now, whatever its size.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"manual.d.ts","sourceRoot":"","sources":["../../src/compaction/manual.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAA;AAI5D,OAAO,EAAE,KAAK,UAAU,EAAwB,MAAM,0BAA0B,CAAA;AAGhF,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,2BAA2B,CAAA;AACxD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAA;
|
|
1
|
+
{"version":3,"file":"manual.d.ts","sourceRoot":"","sources":["../../src/compaction/manual.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAA;AAI5D,OAAO,EAAE,KAAK,UAAU,EAAwB,MAAM,0BAA0B,CAAA;AAGhF,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,2BAA2B,CAAA;AACxD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAA;AAS7D,OAAO,EAEN,KAAK,qBAAqB,EAI1B,MAAM,YAAY,CAAA;AAGnB,OAAO,EACN,KAAK,uBAAuB,EAG5B,MAAM,oBAAoB,CAAA;AAM3B,OAAO,EAAE,KAAK,6BAA6B,EAAwB,MAAM,eAAe,CAAA;AAExF;;;;;;;;;;;;GAYG;AAEH,MAAM,WAAW,gBAAgB;IAChC,kEAAkE;IAClE,QAAQ,CAAC,QAAQ,EAAE,SAAS,OAAO,EAAE,CAAA;IACrC,+DAA+D;IA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