koneck 2.31.1 → 2.33.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/dist/aside.d.ts +35 -0
- package/dist/aside.d.ts.map +1 -0
- package/dist/aside.js +69 -0
- package/dist/aside.js.map +1 -0
- package/dist/engine.d.ts.map +1 -1
- package/dist/engine.js +48 -0
- package/dist/engine.js.map +1 -1
- package/dist/hooks.d.ts +110 -0
- package/dist/hooks.d.ts.map +1 -0
- package/dist/hooks.js +258 -0
- package/dist/hooks.js.map +1 -0
- package/dist/ink-chat.d.ts +2 -51
- package/dist/ink-chat.d.ts.map +1 -1
- package/dist/ink-chat.js +27 -238
- package/dist/ink-chat.js.map +1 -1
- package/dist/types.d.ts +5 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/web/api.d.ts.map +1 -1
- package/dist/web/api.js +29 -0
- package/dist/web/api.js.map +1 -1
- package/dist/web/mark.d.ts +15 -9
- package/dist/web/mark.d.ts.map +1 -1
- package/dist/web/mark.js +72 -9
- package/dist/web/mark.js.map +1 -1
- package/dist/web/ui-client.d.ts.map +1 -1
- package/dist/web/ui-client.js +278 -28
- package/dist/web/ui-client.js.map +1 -1
- package/dist/web/ui-css.d.ts.map +1 -1
- package/dist/web/ui-css.js +41 -0
- package/dist/web/ui-css.js.map +1 -1
- package/dist/web/ui.d.ts.map +1 -1
- package/dist/web/ui.js +19 -1
- package/dist/web/ui.js.map +1 -1
- package/dist/work-words.d.ts +57 -0
- package/dist/work-words.d.ts.map +1 -0
- package/dist/work-words.js +234 -0
- package/dist/work-words.js.map +1 -0
- package/package.json +1 -1
package/dist/hooks.d.ts
ADDED
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Hooks: commands KONECK runs at the moments that matter, declared rather than coded.
|
|
3
|
+
*
|
|
4
|
+
* The point is extending KONECK without touching KONECK. A team that must run `prettier` after
|
|
5
|
+
* every write, or log every shell command to an audit trail, or refuse edits to `entitymodel.xml`
|
|
6
|
+
* outside a review window, should not have to fork an agent to get it — those are policies about
|
|
7
|
+
* their workspace, and they change more often than an agent does.
|
|
8
|
+
*
|
|
9
|
+
* Two kinds, and the difference is the whole design:
|
|
10
|
+
*
|
|
11
|
+
* - A `pre-tool` hook is asked, and may REFUSE. A non-zero exit blocks the tool and its stderr
|
|
12
|
+
* becomes the reason the model is given. This is the one that makes hooks worth having: it is
|
|
13
|
+
* an enforcement point, not a notification.
|
|
14
|
+
* - Every other hook is told. It runs, its output is collected, and a failure is reported but
|
|
15
|
+
* changes nothing — a broken notifier must not be able to stop work.
|
|
16
|
+
*
|
|
17
|
+
* Declared in `.koneck/hooks.json` in the project, and `~/.koneck/hooks.json` for every project.
|
|
18
|
+
* Project first, because a repository's own rules should win over a personal default.
|
|
19
|
+
*
|
|
20
|
+
* {
|
|
21
|
+
* "hooks": [
|
|
22
|
+
* { "on": "pre-tool", "match": "execute_command", "run": "scripts/audit.sh" },
|
|
23
|
+
* { "on": "post-tool", "match": "write_file|edit_file", "run": "npx prettier --write \"$KONECK_PATH\"" },
|
|
24
|
+
* { "on": "session-end", "run": "notify-send 'KONECK finished'" }
|
|
25
|
+
* ]
|
|
26
|
+
* }
|
|
27
|
+
*
|
|
28
|
+
* `match` is a regular expression against the tool name, absent meaning every tool. The command is
|
|
29
|
+
* run through the shell, in the workspace, with the event in the environment rather than on the
|
|
30
|
+
* command line — an argument list is a quoting bug waiting to happen, and a path from a model is
|
|
31
|
+
* exactly the kind of string that finds it.
|
|
32
|
+
*/
|
|
33
|
+
export type HookEvent = 'session-start' | 'session-end' | 'user-prompt' | 'pre-tool' | 'post-tool' | 'turn-end';
|
|
34
|
+
export declare const HOOK_EVENTS: readonly HookEvent[];
|
|
35
|
+
export interface Hook {
|
|
36
|
+
on: HookEvent;
|
|
37
|
+
/** A regular expression against the tool name. Absent matches every tool. */
|
|
38
|
+
match?: string;
|
|
39
|
+
run: string;
|
|
40
|
+
/** Seconds before the hook is killed. A hook must never be able to hang a run. */
|
|
41
|
+
timeout?: number;
|
|
42
|
+
/** Shown instead of the command when a hook blocks something. */
|
|
43
|
+
name?: string;
|
|
44
|
+
/** Where it was declared, for reporting. Filled in by the loader. */
|
|
45
|
+
source?: 'project' | 'user';
|
|
46
|
+
}
|
|
47
|
+
/** What a hook is told about, in its environment. */
|
|
48
|
+
export interface HookContext {
|
|
49
|
+
event: HookEvent;
|
|
50
|
+
cwd: string;
|
|
51
|
+
tool?: string;
|
|
52
|
+
args?: string;
|
|
53
|
+
/** The file a tool is acting on, when there is one. */
|
|
54
|
+
filePath?: string;
|
|
55
|
+
sessionId?: string;
|
|
56
|
+
ok?: boolean;
|
|
57
|
+
/** The prompt, for user-prompt. */
|
|
58
|
+
text?: string;
|
|
59
|
+
}
|
|
60
|
+
export interface HookOutcome {
|
|
61
|
+
hook: Hook;
|
|
62
|
+
ok: boolean;
|
|
63
|
+
/** Set when a pre-tool hook refused, and given to the model as the reason. */
|
|
64
|
+
refusal?: string;
|
|
65
|
+
stdout: string;
|
|
66
|
+
stderr: string;
|
|
67
|
+
ms: number;
|
|
68
|
+
timedOut: boolean;
|
|
69
|
+
}
|
|
70
|
+
/** A hook gets ten seconds unless it says otherwise. Long enough to format a file. */
|
|
71
|
+
export declare const DEFAULT_TIMEOUT_S = 10;
|
|
72
|
+
/** Nothing above this, or "timeout" stops meaning anything. */
|
|
73
|
+
export declare const MAX_TIMEOUT_S = 120;
|
|
74
|
+
export declare function projectHooksPath(cwd: string): string;
|
|
75
|
+
export declare function userHooksPath(home: string): string;
|
|
76
|
+
/** Project hooks first: a repository's own rules outrank a personal default. */
|
|
77
|
+
export declare function loadHooks(cwd: string, home: string): Promise<Hook[]>;
|
|
78
|
+
/** The hooks that apply to an event, in declaration order. */
|
|
79
|
+
export declare function hooksFor(hooks: readonly Hook[], event: HookEvent, tool?: string): Hook[];
|
|
80
|
+
/** The file a tool is acting on, from its arguments — what a formatter or a linter needs. */
|
|
81
|
+
export declare function filePathFrom(args: string | undefined): string | undefined;
|
|
82
|
+
/** The event, as environment. Not as arguments: a path from a model is a quoting bug waiting. */
|
|
83
|
+
export declare function envFor(ctx: HookContext): Record<string, string>;
|
|
84
|
+
/**
|
|
85
|
+
* Runs one hook.
|
|
86
|
+
*
|
|
87
|
+
* Never throws. A hook that fails to launch at all is an ordinary failure with the reason in
|
|
88
|
+
* stderr, because the alternative is that a typo in a config file takes down a session.
|
|
89
|
+
*/
|
|
90
|
+
export declare function runHook(hook: Hook, ctx: HookContext): Promise<HookOutcome>;
|
|
91
|
+
/**
|
|
92
|
+
* Asks every pre-tool hook, and stops at the first refusal.
|
|
93
|
+
*
|
|
94
|
+
* Sequential on purpose: hooks at this point are policy, and policy that runs in a race is policy
|
|
95
|
+
* you cannot reason about. The first refusal is the answer, and the rest are not consulted —
|
|
96
|
+
* exactly as a chain of guards should behave.
|
|
97
|
+
*/
|
|
98
|
+
export declare function askHooks(hooks: readonly Hook[], ctx: HookContext): Promise<{
|
|
99
|
+
allowed: boolean;
|
|
100
|
+
reason?: string;
|
|
101
|
+
ran: HookOutcome[];
|
|
102
|
+
}>;
|
|
103
|
+
/**
|
|
104
|
+
* Runs the hooks that are merely told, and reports how it went.
|
|
105
|
+
*
|
|
106
|
+
* Concurrent, because none of them can change the outcome and a formatter should not have to wait
|
|
107
|
+
* for a notifier. Failures are collected rather than thrown.
|
|
108
|
+
*/
|
|
109
|
+
export declare function notifyHooks(hooks: readonly Hook[], ctx: HookContext): Promise<HookOutcome[]>;
|
|
110
|
+
//# sourceMappingURL=hooks.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hooks.d.ts","sourceRoot":"","sources":["../src/hooks.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AAMH,MAAM,MAAM,SAAS,GACjB,eAAe,GACf,aAAa,GACb,aAAa,GACb,UAAU,GACV,WAAW,GACX,UAAU,CAAC;AAEf,eAAO,MAAM,WAA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,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,EAAE,CAAC,CAQ1E;AAED,8DAA8D;AAC9D,wBAAgB,QAAQ,CAAC,KAAK,EAAE,SAAS,IAAI,EAAE,EAAE,KAAK,EAAE,SAAS,EAAE,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,EAAE,CAOxF;AAED,6FAA6F;AAC7F,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,CAYzE;AAED,iGAAiG;AACjG,wBAAgB,MAAM,CAAC,GAAG,EAAE,WAAW,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAW/D;AAED;;;;;GAKG;AACH,wBAAsB,OAAO,CAAC,IAAI,EAAE,IAAI,EAAE,GAAG,EAAE,WAAW,GAAG,OAAO,CAAC,WAAW,CAAC,CA0DhF;AAED;;;;;;GAMG;AACH,wBAAsB,QAAQ,CAC5B,KAAK,EAAE,SAAS,IAAI,EAAE,EACtB,GAAG,EAAE,WAAW,GACf,OAAO,CAAC;IAAE,OAAO,EAAE,OAAO,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,WAAW,EAAE,CAAA;CAAE,CAAC,CAQpE;AAED;;;;;GAKG;AACH,wBAAsB,WAAW,CAC/B,KAAK,EAAE,SAAS,IAAI,EAAE,EACtB,GAAG,EAAE,WAAW,GACf,OAAO,CAAC,WAAW,EAAE,CAAC,CAIxB"}
|
package/dist/hooks.js
ADDED
|
@@ -0,0 +1,258 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Hooks: commands KONECK runs at the moments that matter, declared rather than coded.
|
|
3
|
+
*
|
|
4
|
+
* The point is extending KONECK without touching KONECK. A team that must run `prettier` after
|
|
5
|
+
* every write, or log every shell command to an audit trail, or refuse edits to `entitymodel.xml`
|
|
6
|
+
* outside a review window, should not have to fork an agent to get it — those are policies about
|
|
7
|
+
* their workspace, and they change more often than an agent does.
|
|
8
|
+
*
|
|
9
|
+
* Two kinds, and the difference is the whole design:
|
|
10
|
+
*
|
|
11
|
+
* - A `pre-tool` hook is asked, and may REFUSE. A non-zero exit blocks the tool and its stderr
|
|
12
|
+
* becomes the reason the model is given. This is the one that makes hooks worth having: it is
|
|
13
|
+
* an enforcement point, not a notification.
|
|
14
|
+
* - Every other hook is told. It runs, its output is collected, and a failure is reported but
|
|
15
|
+
* changes nothing — a broken notifier must not be able to stop work.
|
|
16
|
+
*
|
|
17
|
+
* Declared in `.koneck/hooks.json` in the project, and `~/.koneck/hooks.json` for every project.
|
|
18
|
+
* Project first, because a repository's own rules should win over a personal default.
|
|
19
|
+
*
|
|
20
|
+
* {
|
|
21
|
+
* "hooks": [
|
|
22
|
+
* { "on": "pre-tool", "match": "execute_command", "run": "scripts/audit.sh" },
|
|
23
|
+
* { "on": "post-tool", "match": "write_file|edit_file", "run": "npx prettier --write \"$KONECK_PATH\"" },
|
|
24
|
+
* { "on": "session-end", "run": "notify-send 'KONECK finished'" }
|
|
25
|
+
* ]
|
|
26
|
+
* }
|
|
27
|
+
*
|
|
28
|
+
* `match` is a regular expression against the tool name, absent meaning every tool. The command is
|
|
29
|
+
* run through the shell, in the workspace, with the event in the environment rather than on the
|
|
30
|
+
* command line — an argument list is a quoting bug waiting to happen, and a path from a model is
|
|
31
|
+
* exactly the kind of string that finds it.
|
|
32
|
+
*/
|
|
33
|
+
import { readFile } from 'fs/promises';
|
|
34
|
+
import path from 'path';
|
|
35
|
+
import { execa } from 'execa';
|
|
36
|
+
export const HOOK_EVENTS = [
|
|
37
|
+
'session-start', 'session-end', 'user-prompt', 'pre-tool', 'post-tool', 'turn-end',
|
|
38
|
+
];
|
|
39
|
+
/** A hook gets ten seconds unless it says otherwise. Long enough to format a file. */
|
|
40
|
+
export const DEFAULT_TIMEOUT_S = 10;
|
|
41
|
+
/** Nothing above this, or "timeout" stops meaning anything. */
|
|
42
|
+
export const MAX_TIMEOUT_S = 120;
|
|
43
|
+
/** Output kept per hook. A hook that prints a megabyte is not trying to tell you something. */
|
|
44
|
+
const MAX_OUTPUT = 8_000;
|
|
45
|
+
function validate(raw, source) {
|
|
46
|
+
if (raw == null || typeof raw !== 'object')
|
|
47
|
+
return [];
|
|
48
|
+
const list = raw.hooks;
|
|
49
|
+
if (!Array.isArray(list))
|
|
50
|
+
return [];
|
|
51
|
+
const out = [];
|
|
52
|
+
for (const item of list) {
|
|
53
|
+
if (item == null || typeof item !== 'object')
|
|
54
|
+
continue;
|
|
55
|
+
const h = item;
|
|
56
|
+
if (typeof h.on !== 'string' || !HOOK_EVENTS.includes(h.on))
|
|
57
|
+
continue;
|
|
58
|
+
if (typeof h.run !== 'string' || h.run.trim() === '')
|
|
59
|
+
continue;
|
|
60
|
+
// A match that does not compile is dropped rather than silently matching everything, which is
|
|
61
|
+
// the failure that would quietly disable a policy.
|
|
62
|
+
if (typeof h.match === 'string') {
|
|
63
|
+
try {
|
|
64
|
+
new RegExp(h.match);
|
|
65
|
+
}
|
|
66
|
+
catch {
|
|
67
|
+
continue;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
out.push({
|
|
71
|
+
on: h.on,
|
|
72
|
+
run: h.run.trim(),
|
|
73
|
+
...(typeof h.match === 'string' ? { match: h.match } : {}),
|
|
74
|
+
...(typeof h.name === 'string' && h.name ? { name: h.name } : {}),
|
|
75
|
+
timeout: Math.min(MAX_TIMEOUT_S, Math.max(1, typeof h.timeout === 'number' && h.timeout > 0 ? h.timeout : DEFAULT_TIMEOUT_S)),
|
|
76
|
+
source,
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
return out;
|
|
80
|
+
}
|
|
81
|
+
async function readHookFile(file, source) {
|
|
82
|
+
try {
|
|
83
|
+
return validate(JSON.parse(await readFile(file, 'utf-8')), source);
|
|
84
|
+
}
|
|
85
|
+
catch {
|
|
86
|
+
return []; // absent or malformed: no hooks, never a failed run
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
export function projectHooksPath(cwd) {
|
|
90
|
+
return path.join(cwd, '.koneck', 'hooks.json');
|
|
91
|
+
}
|
|
92
|
+
export function userHooksPath(home) {
|
|
93
|
+
return path.join(home, '.koneck', 'hooks.json');
|
|
94
|
+
}
|
|
95
|
+
/** Project hooks first: a repository's own rules outrank a personal default. */
|
|
96
|
+
export async function loadHooks(cwd, home) {
|
|
97
|
+
const projectFile = projectHooksPath(cwd);
|
|
98
|
+
const userFile = userHooksPath(home);
|
|
99
|
+
const project = await readHookFile(projectFile, 'project');
|
|
100
|
+
// Running KONECK in the home directory itself makes both paths the same file, and reading it
|
|
101
|
+
// twice would run every hook twice — including a formatter, and including an audit entry.
|
|
102
|
+
if (path.resolve(projectFile) === path.resolve(userFile))
|
|
103
|
+
return project;
|
|
104
|
+
return [...project, ...await readHookFile(userFile, 'user')];
|
|
105
|
+
}
|
|
106
|
+
/** The hooks that apply to an event, in declaration order. */
|
|
107
|
+
export function hooksFor(hooks, event, tool) {
|
|
108
|
+
return hooks.filter(h => {
|
|
109
|
+
if (h.on !== event)
|
|
110
|
+
return false;
|
|
111
|
+
if (h.match === undefined)
|
|
112
|
+
return true;
|
|
113
|
+
if (tool === undefined)
|
|
114
|
+
return false;
|
|
115
|
+
try {
|
|
116
|
+
return new RegExp(h.match).test(tool);
|
|
117
|
+
}
|
|
118
|
+
catch {
|
|
119
|
+
return false;
|
|
120
|
+
}
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
/** The file a tool is acting on, from its arguments — what a formatter or a linter needs. */
|
|
124
|
+
export function filePathFrom(args) {
|
|
125
|
+
if (!args)
|
|
126
|
+
return undefined;
|
|
127
|
+
try {
|
|
128
|
+
const parsed = JSON.parse(args);
|
|
129
|
+
for (const key of ['path', 'file', 'file_path', 'filename']) {
|
|
130
|
+
const value = parsed[key];
|
|
131
|
+
if (typeof value === 'string' && value.trim())
|
|
132
|
+
return value.trim();
|
|
133
|
+
}
|
|
134
|
+
const many = parsed['paths'];
|
|
135
|
+
if (Array.isArray(many) && typeof many[0] === 'string')
|
|
136
|
+
return many[0];
|
|
137
|
+
}
|
|
138
|
+
catch { /* not JSON */ }
|
|
139
|
+
return undefined;
|
|
140
|
+
}
|
|
141
|
+
/** The event, as environment. Not as arguments: a path from a model is a quoting bug waiting. */
|
|
142
|
+
export function envFor(ctx) {
|
|
143
|
+
return {
|
|
144
|
+
KONECK_EVENT: ctx.event,
|
|
145
|
+
KONECK_CWD: ctx.cwd,
|
|
146
|
+
...(ctx.tool ? { KONECK_TOOL: ctx.tool } : {}),
|
|
147
|
+
...(ctx.args ? { KONECK_TOOL_ARGS: ctx.args.slice(0, 16_000) } : {}),
|
|
148
|
+
...(ctx.filePath ? { KONECK_PATH: ctx.filePath } : {}),
|
|
149
|
+
...(ctx.sessionId ? { KONECK_SESSION: ctx.sessionId } : {}),
|
|
150
|
+
...(ctx.ok !== undefined ? { KONECK_OK: ctx.ok ? '1' : '0' } : {}),
|
|
151
|
+
...(ctx.text ? { KONECK_TEXT: ctx.text.slice(0, 16_000) } : {}),
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* Runs one hook.
|
|
156
|
+
*
|
|
157
|
+
* Never throws. A hook that fails to launch at all is an ordinary failure with the reason in
|
|
158
|
+
* stderr, because the alternative is that a typo in a config file takes down a session.
|
|
159
|
+
*/
|
|
160
|
+
export async function runHook(hook, ctx) {
|
|
161
|
+
const started = Date.now();
|
|
162
|
+
const limitMs = (hook.timeout ?? DEFAULT_TIMEOUT_S) * 1000;
|
|
163
|
+
let killed = false;
|
|
164
|
+
try {
|
|
165
|
+
/*
|
|
166
|
+
* Detached, so the hook gets its own process group, and killed as a group on timeout.
|
|
167
|
+
*
|
|
168
|
+
* execa's own `timeout` is not enough here. It signals the process it started, then waits for
|
|
169
|
+
* that process's pipes to close — and a hook runs through a shell, so `sh -c "sleep 30"` hands
|
|
170
|
+
* its stdio to a grandchild that execa never learns about. Measured: a 1-second timeout on
|
|
171
|
+
* `sleep 30` settled after 30 seconds, having correctly reported `timedOut: true` thirty
|
|
172
|
+
* seconds too late. Killing the group takes the grandchild with it: the same case settles in
|
|
173
|
+
* 1.02 seconds.
|
|
174
|
+
*/
|
|
175
|
+
const child = execa(hook.run, {
|
|
176
|
+
shell: true,
|
|
177
|
+
cwd: ctx.cwd,
|
|
178
|
+
env: { ...process.env, ...envFor(ctx) },
|
|
179
|
+
reject: false,
|
|
180
|
+
all: false,
|
|
181
|
+
detached: true,
|
|
182
|
+
});
|
|
183
|
+
const timer = setTimeout(() => {
|
|
184
|
+
killed = true;
|
|
185
|
+
try {
|
|
186
|
+
if (child.pid !== undefined)
|
|
187
|
+
process.kill(-child.pid, 'SIGKILL');
|
|
188
|
+
}
|
|
189
|
+
catch {
|
|
190
|
+
// The group may already be gone, or this platform may not have process groups; falling
|
|
191
|
+
// back to the process itself is better than leaving the hook running.
|
|
192
|
+
try {
|
|
193
|
+
child.kill('SIGKILL');
|
|
194
|
+
}
|
|
195
|
+
catch { /* already dead */ }
|
|
196
|
+
}
|
|
197
|
+
}, limitMs);
|
|
198
|
+
let result;
|
|
199
|
+
try {
|
|
200
|
+
result = await child;
|
|
201
|
+
}
|
|
202
|
+
finally {
|
|
203
|
+
clearTimeout(timer);
|
|
204
|
+
}
|
|
205
|
+
const stdout = (result.stdout ?? '').slice(0, MAX_OUTPUT);
|
|
206
|
+
const stderr = (result.stderr ?? '').slice(0, MAX_OUTPUT);
|
|
207
|
+
const timedOut = killed || result.timedOut === true;
|
|
208
|
+
const ok = result.exitCode === 0 && !timedOut;
|
|
209
|
+
return {
|
|
210
|
+
hook, ok, stdout, stderr, timedOut, ms: Date.now() - started,
|
|
211
|
+
// Only a pre-tool hook can refuse; elsewhere a non-zero exit is reported, not obeyed.
|
|
212
|
+
...(hook.on === 'pre-tool' && !ok
|
|
213
|
+
? {
|
|
214
|
+
refusal: timedOut
|
|
215
|
+
? `${hook.name ?? hook.run} did not answer within ${hook.timeout}s`
|
|
216
|
+
: (stderr.trim() || stdout.trim() || `${hook.name ?? hook.run} refused it`),
|
|
217
|
+
}
|
|
218
|
+
: {}),
|
|
219
|
+
};
|
|
220
|
+
}
|
|
221
|
+
catch (e) {
|
|
222
|
+
const why = e instanceof Error ? e.message : String(e);
|
|
223
|
+
return {
|
|
224
|
+
hook, ok: false, stdout: '', stderr: why, timedOut: false, ms: Date.now() - started,
|
|
225
|
+
...(hook.on === 'pre-tool' ? { refusal: `${hook.name ?? hook.run} could not run: ${why}` } : {}),
|
|
226
|
+
};
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
/**
|
|
230
|
+
* Asks every pre-tool hook, and stops at the first refusal.
|
|
231
|
+
*
|
|
232
|
+
* Sequential on purpose: hooks at this point are policy, and policy that runs in a race is policy
|
|
233
|
+
* you cannot reason about. The first refusal is the answer, and the rest are not consulted —
|
|
234
|
+
* exactly as a chain of guards should behave.
|
|
235
|
+
*/
|
|
236
|
+
export async function askHooks(hooks, ctx) {
|
|
237
|
+
const ran = [];
|
|
238
|
+
for (const hook of hooksFor(hooks, 'pre-tool', ctx.tool)) {
|
|
239
|
+
const outcome = await runHook(hook, { ...ctx, event: 'pre-tool' });
|
|
240
|
+
ran.push(outcome);
|
|
241
|
+
if (outcome.refusal)
|
|
242
|
+
return { allowed: false, reason: outcome.refusal, ran };
|
|
243
|
+
}
|
|
244
|
+
return { allowed: true, ran };
|
|
245
|
+
}
|
|
246
|
+
/**
|
|
247
|
+
* Runs the hooks that are merely told, and reports how it went.
|
|
248
|
+
*
|
|
249
|
+
* Concurrent, because none of them can change the outcome and a formatter should not have to wait
|
|
250
|
+
* for a notifier. Failures are collected rather than thrown.
|
|
251
|
+
*/
|
|
252
|
+
export async function notifyHooks(hooks, ctx) {
|
|
253
|
+
const applicable = hooksFor(hooks, ctx.event, ctx.tool);
|
|
254
|
+
if (applicable.length === 0)
|
|
255
|
+
return [];
|
|
256
|
+
return Promise.all(applicable.map(h => runHook(h, ctx)));
|
|
257
|
+
}
|
|
258
|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AM,OAAO,CAAC,IAAI,EAAE,EAAE,GAAG,GAAG,EAAE,KAAK,EAAE,UAAU,EAAE,CAAC,CAAC;QACnE,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QAClB,IAAI,OAAO,CAAC,OAAO;YAAE,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,OAAO,EAAE,GAAG,EAAE,CAAC;IAC/E,CAAC;IACD,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE,CAAC;AAChC,CAAC;AAED;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,WAAW,CAC/B,KAAsB,EACtB,GAAgB;IAEhB,MAAM,UAAU,GAAG,QAAQ,CAAC,KAAK,EAAE,GAAG,CAAC,KAAK,EAAE,GAAG,CAAC,IAAI,CAAC,CAAC;IACxD,IAAI,UAAU,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,EAAE,CAAC;IACvC,OAAO,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,OAAO,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC;AAC3D,CAAC"}
|
package/dist/ink-chat.d.ts
CHANGED
|
@@ -42,55 +42,7 @@ export declare function pasteForDisplay(text: string, maxRows?: number): string;
|
|
|
42
42
|
export declare function liveReplyLines(termRows: number | undefined): number;
|
|
43
43
|
/** Sampling cadence for live stream refs: quick enough to read, slow enough not to flash. */
|
|
44
44
|
export declare function liveRefreshDelay(idleForMs: number): number;
|
|
45
|
-
|
|
46
|
-
* What KONECK says it is doing, and what it says it did.
|
|
47
|
-
*
|
|
48
|
-
* Grouped by how much work the turn turned out to be, so the wording matches the wait: a
|
|
49
|
-
* sub-three-second answer gets something snappy, a two-minute one gets something that sounds
|
|
50
|
-
* like effort, and a turn that had to recover from a failed tool gets a clutch verb. The word
|
|
51
|
-
* shown while working escalates through the tiers as time passes, and the finished row reports
|
|
52
|
-
* the tense that matches the real elapsed time.
|
|
53
|
-
*
|
|
54
|
-
* Apostrophes are ASCII on purpose: U+2019 is East Asian Ambiguous, the same class of character
|
|
55
|
-
* that used to tear the panel borders.
|
|
56
|
-
*/
|
|
57
|
-
export type WorkTier = 'reply' | 'quick' | 'normal' | 'heavy' | 'recovery';
|
|
58
|
-
export declare const WORK_WORDS: Record<WorkTier, Array<readonly [string, string]>>;
|
|
59
|
-
/** Which vocabulary the wait deserves. */
|
|
60
|
-
/** What a turn actually amounted to, which is what the wording should follow. */
|
|
61
|
-
export interface TurnEffort {
|
|
62
|
-
elapsedMs: number;
|
|
63
|
-
/** Tools the turn ran. Zero means it only thought and answered. */
|
|
64
|
-
tools: number;
|
|
65
|
-
/** Output tokens produced. */
|
|
66
|
-
tokens: number;
|
|
67
|
-
/** A tool failed and the turn recovered from it. */
|
|
68
|
-
recovered: boolean;
|
|
69
|
-
}
|
|
70
|
-
/**
|
|
71
|
-
* Whether the turn earned a verb at all.
|
|
72
|
-
*
|
|
73
|
-
* "Cooked lekker in 5.0s" for answering "hi" is a boast about nothing: no tool ran, ten tokens
|
|
74
|
-
* came back, and the only reason it took five seconds is that the provider is slow. Elapsed time
|
|
75
|
-
* alone cannot tell effort from latency, so a turn that ran no tools and said almost nothing gets
|
|
76
|
-
* its timing reported plainly and no verb.
|
|
77
|
-
*/
|
|
78
|
-
export declare function shouldName(effort: TurnEffort): boolean;
|
|
79
|
-
/**
|
|
80
|
-
* Which family of words fits.
|
|
81
|
-
*
|
|
82
|
-
* Time still decides between quick, normal and heavy, but only once the turn has done something.
|
|
83
|
-
* A turn with no tools belongs to `reply` however long it took, because nothing was built and a
|
|
84
|
-
* cooking verb would be describing work that never happened.
|
|
85
|
-
*/
|
|
86
|
-
export declare function tierFor(effort: TurnEffort): WorkTier;
|
|
87
|
-
/**
|
|
88
|
-
* The gerund to show while working, and the past tense to report when the turn lands.
|
|
89
|
-
*
|
|
90
|
-
* The past tense is empty when the turn did not earn one, which the caller renders as timing
|
|
91
|
-
* alone.
|
|
92
|
-
*/
|
|
93
|
-
export declare function workWord(effort: TurnEffort, seed: number): readonly [string, string];
|
|
45
|
+
export { WORK_WORDS, shouldName, tierFor, workWord, type WorkTier, type TurnEffort, } from './work-words.js';
|
|
94
46
|
/** Logical families for the searchable command palette; headers reuse an existing row. */
|
|
95
47
|
export declare function commandGroup(command: string): string;
|
|
96
48
|
/** What the overlay is currently offering. */
|
|
@@ -243,7 +195,7 @@ export declare function reviewTask(kind: 'code' | 'security', fix?: boolean): st
|
|
|
243
195
|
export declare function taskTranscriptLabel(task: string, generatedLabel?: string): string;
|
|
244
196
|
/** The summary model gets useful context, never an accidental credential from the transcript. */
|
|
245
197
|
export declare function handoffSummaryInput(transcript: string): string;
|
|
246
|
-
export
|
|
198
|
+
export { asideAllowsTool } from './aside.js';
|
|
247
199
|
export declare function readOnlyReviewAllows(tool: string, args: string): boolean;
|
|
248
200
|
/** A goal is compact enough to preserve context room, but rich enough to guide a long session. */
|
|
249
201
|
export declare function normalizeSessionGoal(value: string): string;
|
|
@@ -300,5 +252,4 @@ export declare function defaultAltScreen(stdout?: {
|
|
|
300
252
|
columns?: number;
|
|
301
253
|
}, env?: NodeJS.ProcessEnv): boolean;
|
|
302
254
|
export declare function runInkChatMode(config: AgentConfig): Promise<void>;
|
|
303
|
-
export {};
|
|
304
255
|
//# sourceMappingURL=ink-chat.d.ts.map
|
package/dist/ink-chat.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ink-chat.d.ts","sourceRoot":"","sources":["../src/ink-chat.tsx"],"names":[],"mappings":"AAqDA,OAAO,KAAK,EAAY,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAY5D,OAAO,EAA6C,KAAK,YAAY,EAAE,MAAM,aAAa,CAAC;AAK3F,OAAO,KAAK,EAAE,WAAW,EAAiB,MAAM,YAAY,CAAC;AA+B7D,KAAK,MAAM,GAAG,KAAK,GAAG,QAAQ,GAAG,MAAM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