agy-worker-mcp 0.3.1
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 +141 -0
- package/LICENSE +21 -0
- package/README.md +309 -0
- package/commands/agy-ceiling.md +31 -0
- package/dist/broker/blockers.d.ts +86 -0
- package/dist/broker/blockers.d.ts.map +1 -0
- package/dist/broker/blockers.js +390 -0
- package/dist/broker/blockers.js.map +1 -0
- package/dist/broker/outcome.d.ts +85 -0
- package/dist/broker/outcome.d.ts.map +1 -0
- package/dist/broker/outcome.js +147 -0
- package/dist/broker/outcome.js.map +1 -0
- package/dist/broker/reconcile.d.ts +74 -0
- package/dist/broker/reconcile.d.ts.map +1 -0
- package/dist/broker/reconcile.js +415 -0
- package/dist/broker/reconcile.js.map +1 -0
- package/dist/broker/result.d.ts +88 -0
- package/dist/broker/result.d.ts.map +1 -0
- package/dist/broker/result.js +234 -0
- package/dist/broker/result.js.map +1 -0
- package/dist/broker/verify.d.ts +52 -0
- package/dist/broker/verify.d.ts.map +1 -0
- package/dist/broker/verify.js +174 -0
- package/dist/broker/verify.js.map +1 -0
- package/dist/contract/errors.d.ts +119 -0
- package/dist/contract/errors.d.ts.map +1 -0
- package/dist/contract/errors.js +99 -0
- package/dist/contract/errors.js.map +1 -0
- package/dist/contract/index.d.ts +10 -0
- package/dist/contract/index.d.ts.map +1 -0
- package/dist/contract/index.js +10 -0
- package/dist/contract/index.js.map +1 -0
- package/dist/contract/paths.d.ts +139 -0
- package/dist/contract/paths.d.ts.map +1 -0
- package/dist/contract/paths.js +359 -0
- package/dist/contract/paths.js.map +1 -0
- package/dist/contract/schema.sql +64 -0
- package/dist/contract/types.d.ts +1113 -0
- package/dist/contract/types.d.ts.map +1 -0
- package/dist/contract/types.js +114 -0
- package/dist/contract/types.js.map +1 -0
- package/dist/events/cursor.d.ts +65 -0
- package/dist/events/cursor.d.ts.map +1 -0
- package/dist/events/cursor.js +286 -0
- package/dist/events/cursor.js.map +1 -0
- package/dist/events/detect.d.ts +58 -0
- package/dist/events/detect.d.ts.map +1 -0
- package/dist/events/detect.js +183 -0
- package/dist/events/detect.js.map +1 -0
- package/dist/events/normalize.d.ts +30 -0
- package/dist/events/normalize.d.ts.map +1 -0
- package/dist/events/normalize.js +158 -0
- package/dist/events/normalize.js.map +1 -0
- package/dist/events/parse.d.ts +41 -0
- package/dist/events/parse.d.ts.map +1 -0
- package/dist/events/parse.js +89 -0
- package/dist/events/parse.js.map +1 -0
- package/dist/gate/bind.d.ts +28 -0
- package/dist/gate/bind.d.ts.map +1 -0
- package/dist/gate/bind.js +154 -0
- package/dist/gate/bind.js.map +1 -0
- package/dist/gate/gate.d.ts +139 -0
- package/dist/gate/gate.d.ts.map +1 -0
- package/dist/gate/gate.js +488 -0
- package/dist/gate/gate.js.map +1 -0
- package/dist/gate/hooks-file.d.ts +55 -0
- package/dist/gate/hooks-file.d.ts.map +1 -0
- package/dist/gate/hooks-file.js +104 -0
- package/dist/gate/hooks-file.js.map +1 -0
- package/dist/gate.d.ts +3 -0
- package/dist/gate.d.ts.map +1 -0
- package/dist/gate.js +20 -0
- package/dist/gate.js.map +1 -0
- package/dist/policy/ceiling-review.d.ts +22 -0
- package/dist/policy/ceiling-review.d.ts.map +1 -0
- package/dist/policy/ceiling-review.js +170 -0
- package/dist/policy/ceiling-review.js.map +1 -0
- package/dist/policy/ceiling.d.ts +128 -0
- package/dist/policy/ceiling.d.ts.map +1 -0
- package/dist/policy/ceiling.js +273 -0
- package/dist/policy/ceiling.js.map +1 -0
- package/dist/policy/containment.d.ts +100 -0
- package/dist/policy/containment.d.ts.map +1 -0
- package/dist/policy/containment.js +1071 -0
- package/dist/policy/containment.js.map +1 -0
- package/dist/policy/hard-deny.d.ts +28 -0
- package/dist/policy/hard-deny.d.ts.map +1 -0
- package/dist/policy/hard-deny.js +78 -0
- package/dist/policy/hard-deny.js.map +1 -0
- package/dist/policy/profiles.d.ts +82 -0
- package/dist/policy/profiles.d.ts.map +1 -0
- package/dist/policy/profiles.js +317 -0
- package/dist/policy/profiles.js.map +1 -0
- package/dist/policy/rules.d.ts +138 -0
- package/dist/policy/rules.d.ts.map +1 -0
- package/dist/policy/rules.js +1180 -0
- package/dist/policy/rules.js.map +1 -0
- package/dist/policy/seatbelt.d.ts +32 -0
- package/dist/policy/seatbelt.d.ts.map +1 -0
- package/dist/policy/seatbelt.js +59 -0
- package/dist/policy/seatbelt.js.map +1 -0
- package/dist/policy/tools.d.ts +36 -0
- package/dist/policy/tools.d.ts.map +1 -0
- package/dist/policy/tools.js +94 -0
- package/dist/policy/tools.js.map +1 -0
- package/dist/runner/gate-watchdog.d.ts +93 -0
- package/dist/runner/gate-watchdog.d.ts.map +1 -0
- package/dist/runner/gate-watchdog.js +153 -0
- package/dist/runner/gate-watchdog.js.map +1 -0
- package/dist/runner/idle.d.ts +51 -0
- package/dist/runner/idle.d.ts.map +1 -0
- package/dist/runner/idle.js +81 -0
- package/dist/runner/idle.js.map +1 -0
- package/dist/runner/inbox.d.ts +56 -0
- package/dist/runner/inbox.d.ts.map +1 -0
- package/dist/runner/inbox.js +134 -0
- package/dist/runner/inbox.js.map +1 -0
- package/dist/runner/reap.d.ts +65 -0
- package/dist/runner/reap.d.ts.map +1 -0
- package/dist/runner/reap.js +168 -0
- package/dist/runner/reap.js.map +1 -0
- package/dist/runner/runner.d.ts +51 -0
- package/dist/runner/runner.d.ts.map +1 -0
- package/dist/runner/runner.js +289 -0
- package/dist/runner/runner.js.map +1 -0
- package/dist/runner/spawn.d.ts +98 -0
- package/dist/runner/spawn.d.ts.map +1 -0
- package/dist/runner/spawn.js +230 -0
- package/dist/runner/spawn.js.map +1 -0
- package/dist/runner/verify.d.ts +24 -0
- package/dist/runner/verify.d.ts.map +1 -0
- package/dist/runner/verify.js +108 -0
- package/dist/runner/verify.js.map +1 -0
- package/dist/runner.d.ts +3 -0
- package/dist/runner.d.ts.map +1 -0
- package/dist/runner.js +15 -0
- package/dist/runner.js.map +1 -0
- package/dist/server/context.d.ts +41 -0
- package/dist/server/context.d.ts.map +1 -0
- package/dist/server/context.js +59 -0
- package/dist/server/context.js.map +1 -0
- package/dist/server/instructions.d.ts +13 -0
- package/dist/server/instructions.d.ts.map +1 -0
- package/dist/server/instructions.js +121 -0
- package/dist/server/instructions.js.map +1 -0
- package/dist/server/server.d.ts +20 -0
- package/dist/server/server.d.ts.map +1 -0
- package/dist/server/server.js +55 -0
- package/dist/server/server.js.map +1 -0
- package/dist/server/tools/cancel.d.ts +24 -0
- package/dist/server/tools/cancel.d.ts.map +1 -0
- package/dist/server/tools/cancel.js +59 -0
- package/dist/server/tools/cancel.js.map +1 -0
- package/dist/server/tools/capabilities.d.ts +36 -0
- package/dist/server/tools/capabilities.d.ts.map +1 -0
- package/dist/server/tools/capabilities.js +116 -0
- package/dist/server/tools/capabilities.js.map +1 -0
- package/dist/server/tools/ceiling.d.ts +31 -0
- package/dist/server/tools/ceiling.d.ts.map +1 -0
- package/dist/server/tools/ceiling.js +121 -0
- package/dist/server/tools/ceiling.js.map +1 -0
- package/dist/server/tools/index.d.ts +38 -0
- package/dist/server/tools/index.d.ts.map +1 -0
- package/dist/server/tools/index.js +115 -0
- package/dist/server/tools/index.js.map +1 -0
- package/dist/server/tools/listJobs.d.ts +30 -0
- package/dist/server/tools/listJobs.d.ts.map +1 -0
- package/dist/server/tools/listJobs.js +37 -0
- package/dist/server/tools/listJobs.js.map +1 -0
- package/dist/server/tools/logs.d.ts +31 -0
- package/dist/server/tools/logs.d.ts.map +1 -0
- package/dist/server/tools/logs.js +96 -0
- package/dist/server/tools/logs.js.map +1 -0
- package/dist/server/tools/result.d.ts +32 -0
- package/dist/server/tools/result.d.ts.map +1 -0
- package/dist/server/tools/result.js +95 -0
- package/dist/server/tools/result.js.map +1 -0
- package/dist/server/tools/send.d.ts +37 -0
- package/dist/server/tools/send.d.ts.map +1 -0
- package/dist/server/tools/send.js +71 -0
- package/dist/server/tools/send.js.map +1 -0
- package/dist/server/tools/sessions.d.ts +28 -0
- package/dist/server/tools/sessions.d.ts.map +1 -0
- package/dist/server/tools/sessions.js +54 -0
- package/dist/server/tools/sessions.js.map +1 -0
- package/dist/server/tools/start.d.ts +107 -0
- package/dist/server/tools/start.d.ts.map +1 -0
- package/dist/server/tools/start.js +482 -0
- package/dist/server/tools/start.js.map +1 -0
- package/dist/server/tools/wait.d.ts +29 -0
- package/dist/server/tools/wait.d.ts.map +1 -0
- package/dist/server/tools/wait.js +120 -0
- package/dist/server/tools/wait.js.map +1 -0
- package/dist/server.d.ts +3 -0
- package/dist/server.d.ts.map +1 -0
- package/dist/server.js +17 -0
- package/dist/server.js.map +1 -0
- package/dist/setup/install.d.ts +52 -0
- package/dist/setup/install.d.ts.map +1 -0
- package/dist/setup/install.js +108 -0
- package/dist/setup/install.js.map +1 -0
- package/dist/setup.d.ts +3 -0
- package/dist/setup.d.ts.map +1 -0
- package/dist/setup.js +24 -0
- package/dist/setup.js.map +1 -0
- package/dist/store/db.d.ts +49 -0
- package/dist/store/db.d.ts.map +1 -0
- package/dist/store/db.js +101 -0
- package/dist/store/db.js.map +1 -0
- package/dist/store/jobs.d.ts +45 -0
- package/dist/store/jobs.d.ts.map +1 -0
- package/dist/store/jobs.js +150 -0
- package/dist/store/jobs.js.map +1 -0
- package/dist/store/locks.d.ts +60 -0
- package/dist/store/locks.d.ts.map +1 -0
- package/dist/store/locks.js +172 -0
- package/dist/store/locks.js.map +1 -0
- package/dist/store/sessions.d.ts +37 -0
- package/dist/store/sessions.d.ts.map +1 -0
- package/dist/store/sessions.js +117 -0
- package/dist/store/sessions.js.map +1 -0
- package/dist/trace/digest.d.ts +77 -0
- package/dist/trace/digest.d.ts.map +1 -0
- package/dist/trace/digest.js +481 -0
- package/dist/trace/digest.js.map +1 -0
- package/package.json +68 -0
- package/skills/agy-ceiling/SKILL.md +72 -0
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { type ModelCapability } from '../../contract/types.js';
|
|
3
|
+
import { type ToolContext, type ToolReply } from '../context.js';
|
|
4
|
+
/**
|
|
5
|
+
* `agy_capabilities` — models, profiles, limits, and server version.
|
|
6
|
+
*
|
|
7
|
+
* Worth calling before the first `agy_start`: it reports the project root that was
|
|
8
|
+
* discovered, whether the agy binary is actually present, and the profile ceilings
|
|
9
|
+
* a `permissions.allow` request will be intersected against.
|
|
10
|
+
*/
|
|
11
|
+
export declare const capabilitiesInput: z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>;
|
|
12
|
+
export type CapabilitiesInput = z.infer<typeof capabilitiesInput>;
|
|
13
|
+
/**
|
|
14
|
+
* Models `agy models` lists (agy 1.1.27, 2026-09-08) with the `--effort`
|
|
15
|
+
* values each one accepts — measured, not inferred (M8, one
|
|
16
|
+
* trivial print-mode run per cell):
|
|
17
|
+
*
|
|
18
|
+
* - a name ending in `-high|-medium|-low` accepts exactly that effort, or
|
|
19
|
+
* none; any other value fails with "conflicts with --effort=…";
|
|
20
|
+
* - `claude-*` accepts no `--effort` at all ("--effort is not supported for
|
|
21
|
+
* model …").
|
|
22
|
+
*
|
|
23
|
+
* `efforts` therefore lists what may be *passed*; omitting `effort` is always
|
|
24
|
+
* fine. An empty list means "never pass it".
|
|
25
|
+
*/
|
|
26
|
+
export declare const MEASURED_MODELS: readonly ModelCapability[];
|
|
27
|
+
/**
|
|
28
|
+
* The `--effort` values agy accepts for `model`, or `null` when we cannot
|
|
29
|
+
* tell. Measured models answer from the table; an unmeasured name that still
|
|
30
|
+
* carries an effort suffix follows the measured suffix rule (M8 held for every
|
|
31
|
+
* suffixed model, across three families); anything else is unknown and the
|
|
32
|
+
* caller must let agy decide.
|
|
33
|
+
*/
|
|
34
|
+
export declare function acceptedEfforts(model: string): readonly string[] | null;
|
|
35
|
+
export declare function handleCapabilities(ctx: ToolContext, _input: CapabilitiesInput): Promise<ToolReply>;
|
|
36
|
+
//# sourceMappingURL=capabilities.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"capabilities.d.ts","sourceRoot":"","sources":["../../../src/server/tools/capabilities.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAEvB,OAAO,EAAqC,KAAK,eAAe,EAAE,MAAM,yBAAyB,CAAA;AAKjG,OAAO,EAAqB,KAAK,WAAW,EAAE,KAAK,SAAS,EAAE,MAAM,eAAe,CAAA;AAEnF;;;;;;GAMG;AACH,eAAO,MAAM,iBAAiB,gDAAe,CAAA;AAE7C,MAAM,MAAM,iBAAiB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,iBAAiB,CAAC,CAAA;AAEjE;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,eAAe,EAAE,SAAS,eAAe,EAerD,CAAA;AAID;;;;;;GAMG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,MAAM,EAAE,GAAG,IAAI,CAKvE;AAoBD,wBAAsB,kBAAkB,CACtC,GAAG,EAAE,WAAW,EAChB,MAAM,EAAE,iBAAiB,GACxB,OAAO,CAAC,SAAS,CAAC,CAgCpB"}
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import { existsSync } from 'node:fs';
|
|
2
|
+
import { delimiter, join } from 'node:path';
|
|
3
|
+
import { z } from 'zod';
|
|
4
|
+
import { SCHEMA_VERSION } from '../../contract/types.js';
|
|
5
|
+
import { ceilingPath, describeCeiling, loadCeiling } from '../../policy/ceiling.js';
|
|
6
|
+
import { describeProfiles } from '../../policy/profiles.js';
|
|
7
|
+
import { resolveAgyBin } from '../../runner/spawn.js';
|
|
8
|
+
import { reconcile } from '../../broker/reconcile.js';
|
|
9
|
+
import { errorReply, reply } from '../context.js';
|
|
10
|
+
/**
|
|
11
|
+
* `agy_capabilities` — models, profiles, limits, and server version.
|
|
12
|
+
*
|
|
13
|
+
* Worth calling before the first `agy_start`: it reports the project root that was
|
|
14
|
+
* discovered, whether the agy binary is actually present, and the profile ceilings
|
|
15
|
+
* a `permissions.allow` request will be intersected against.
|
|
16
|
+
*/
|
|
17
|
+
export const capabilitiesInput = z.object({});
|
|
18
|
+
/**
|
|
19
|
+
* Models `agy models` lists (agy 1.1.27, 2026-09-08) with the `--effort`
|
|
20
|
+
* values each one accepts — measured, not inferred (M8, one
|
|
21
|
+
* trivial print-mode run per cell):
|
|
22
|
+
*
|
|
23
|
+
* - a name ending in `-high|-medium|-low` accepts exactly that effort, or
|
|
24
|
+
* none; any other value fails with "conflicts with --effort=…";
|
|
25
|
+
* - `claude-*` accepts no `--effort` at all ("--effort is not supported for
|
|
26
|
+
* model …").
|
|
27
|
+
*
|
|
28
|
+
* `efforts` therefore lists what may be *passed*; omitting `effort` is always
|
|
29
|
+
* fine. An empty list means "never pass it".
|
|
30
|
+
*/
|
|
31
|
+
export const MEASURED_MODELS = [
|
|
32
|
+
{ name: 'gemini-3.8-flash-high', efforts: ['high'] },
|
|
33
|
+
{ name: 'gemini-3.8-flash-medium', efforts: ['medium'] },
|
|
34
|
+
{ name: 'gemini-3.8-flash-low', efforts: ['low'] },
|
|
35
|
+
{ name: 'gemini-3.7-flash-high', efforts: ['high'] },
|
|
36
|
+
{ name: 'gemini-3.7-flash-medium', efforts: ['medium'] },
|
|
37
|
+
{ name: 'gemini-3.7-flash-low', efforts: ['low'] },
|
|
38
|
+
{ name: 'gemini-3.6-flash-high', efforts: ['high'] },
|
|
39
|
+
{ name: 'gemini-3.6-flash-medium', efforts: ['medium'] },
|
|
40
|
+
{ name: 'gemini-3.6-flash-low', efforts: ['low'] },
|
|
41
|
+
{ name: 'gemini-3.1-pro-high', efforts: ['high'] },
|
|
42
|
+
{ name: 'gemini-3.1-pro-low', efforts: ['low'] },
|
|
43
|
+
{ name: 'claude-sonnet-4-6', efforts: [] },
|
|
44
|
+
{ name: 'claude-opus-4-6-thinking', efforts: [] },
|
|
45
|
+
{ name: 'gpt-oss-120b-medium', efforts: ['medium'] },
|
|
46
|
+
];
|
|
47
|
+
const EFFORT_SUFFIX = /-(low|medium|high)$/;
|
|
48
|
+
/**
|
|
49
|
+
* The `--effort` values agy accepts for `model`, or `null` when we cannot
|
|
50
|
+
* tell. Measured models answer from the table; an unmeasured name that still
|
|
51
|
+
* carries an effort suffix follows the measured suffix rule (M8 held for every
|
|
52
|
+
* suffixed model, across three families); anything else is unknown and the
|
|
53
|
+
* caller must let agy decide.
|
|
54
|
+
*/
|
|
55
|
+
export function acceptedEfforts(model) {
|
|
56
|
+
const measured = MEASURED_MODELS.find((m) => m.name === model);
|
|
57
|
+
if (measured)
|
|
58
|
+
return measured.efforts;
|
|
59
|
+
const suffix = EFFORT_SUFFIX.exec(model);
|
|
60
|
+
return suffix ? [suffix[1]] : null;
|
|
61
|
+
}
|
|
62
|
+
/** Only `accept-edits` was actually observed (`agentMode`). */
|
|
63
|
+
const MEASURED_MODES = ['accept-edits'];
|
|
64
|
+
/** Never spawns `agy` — only checks whether the binary is reachable on PATH. */
|
|
65
|
+
function checkAgyBinPresent(bin) {
|
|
66
|
+
try {
|
|
67
|
+
if (bin.includes('/'))
|
|
68
|
+
return existsSync(bin);
|
|
69
|
+
const pathEnv = process.env.PATH ?? '';
|
|
70
|
+
for (const dir of pathEnv.split(delimiter)) {
|
|
71
|
+
if (!dir)
|
|
72
|
+
continue;
|
|
73
|
+
if (existsSync(join(dir, bin)))
|
|
74
|
+
return true;
|
|
75
|
+
}
|
|
76
|
+
return false;
|
|
77
|
+
}
|
|
78
|
+
catch {
|
|
79
|
+
return false;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
export async function handleCapabilities(ctx, _input) {
|
|
83
|
+
try {
|
|
84
|
+
await reconcile(ctx.store);
|
|
85
|
+
const agyBin = resolveAgyBin();
|
|
86
|
+
const ceilingFile = ceilingPath(ctx.paths);
|
|
87
|
+
const ceilingPresent = existsSync(ceilingFile);
|
|
88
|
+
// Not wrapped separately: an invalid policy.json should surface here too
|
|
89
|
+
// (fails the whole call closed via the outer try/catch below), the same
|
|
90
|
+
// as it fails `agy_start` — a caller should never see a capabilities
|
|
91
|
+
// reply that quietly hid a broken ceiling file.
|
|
92
|
+
const ceiling = loadCeiling(ctx.paths);
|
|
93
|
+
const caps = {
|
|
94
|
+
server_version: ctx.version,
|
|
95
|
+
schema_version: SCHEMA_VERSION,
|
|
96
|
+
project_root: ctx.paths.root,
|
|
97
|
+
project_key: ctx.paths.key,
|
|
98
|
+
profiles: describeProfiles(),
|
|
99
|
+
ceiling: describeCeiling(ceiling, ceilingFile, ceilingPresent),
|
|
100
|
+
models: [...MEASURED_MODELS],
|
|
101
|
+
efforts: ['low', 'medium', 'high'],
|
|
102
|
+
modes: [...MEASURED_MODES],
|
|
103
|
+
session_modes: ['oneshot', 'session'],
|
|
104
|
+
on_denial: ['abort', 'continue', 'guide'],
|
|
105
|
+
limits: ctx.limits,
|
|
106
|
+
agy_bin: agyBin,
|
|
107
|
+
agy_bin_present: checkAgyBinPresent(agyBin),
|
|
108
|
+
client: ctx.getClient?.() ?? null,
|
|
109
|
+
};
|
|
110
|
+
return reply(caps);
|
|
111
|
+
}
|
|
112
|
+
catch (e) {
|
|
113
|
+
return errorReply(e);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
//# sourceMappingURL=capabilities.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"capabilities.js","sourceRoot":"","sources":["../../../src/server/tools/capabilities.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;AACpC,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAC3C,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAEvB,OAAO,EAAE,cAAc,EAA2C,MAAM,yBAAyB,CAAA;AACjG,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAA;AACnF,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAA;AAC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A;IACtB,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { type ToolContext, type ToolReply } from '../context.js';
|
|
3
|
+
/**
|
|
4
|
+
* `agy_ceiling` — everything a parent agent needs to propose a project
|
|
5
|
+
* ceiling, and nothing that writes one (0.3.0 PR3, `skills/agy-ceiling/SKILL.md`).
|
|
6
|
+
*
|
|
7
|
+
* Without `draft`: the ceiling file's path and contents, the effective
|
|
8
|
+
* general_worker policy it produces, and the project's denial history
|
|
9
|
+
* (`digestProject` over every job directory). With `draft`: the review of
|
|
10
|
+
* that draft (`loadCeiling`'s own errors, advisory warnings, a risk class
|
|
11
|
+
* per rule) and, optionally, how the draft would judge `expected_commands`.
|
|
12
|
+
*
|
|
13
|
+
* Read-only by construction — there is no code path in this server that
|
|
14
|
+
* writes `policy.json`; the skill's approval rule is the second wall.
|
|
15
|
+
*/
|
|
16
|
+
export declare const ceilingInput: z.ZodObject<{
|
|
17
|
+
draft: z.ZodOptional<z.ZodUnknown>;
|
|
18
|
+
expected_commands: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
19
|
+
history_limit: z.ZodOptional<z.ZodNumber>;
|
|
20
|
+
}, "strip", z.ZodTypeAny, {
|
|
21
|
+
expected_commands?: string[] | undefined;
|
|
22
|
+
draft?: unknown;
|
|
23
|
+
history_limit?: number | undefined;
|
|
24
|
+
}, {
|
|
25
|
+
expected_commands?: string[] | undefined;
|
|
26
|
+
draft?: unknown;
|
|
27
|
+
history_limit?: number | undefined;
|
|
28
|
+
}>;
|
|
29
|
+
export type CeilingInput = z.infer<typeof ceilingInput>;
|
|
30
|
+
export declare function handleCeiling(ctx: ToolContext, input: CeilingInput): Promise<ToolReply>;
|
|
31
|
+
//# sourceMappingURL=ceiling.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ceiling.d.ts","sourceRoot":"","sources":["../../../src/server/tools/ceiling.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAUvB,OAAO,EAAqB,KAAK,WAAW,EAAE,KAAK,SAAS,EAAE,MAAM,eAAe,CAAA;AAEnF;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,YAAY;;;;;;;;;;;;EAgBvB,CAAA;AAEF,MAAM,MAAM,YAAY,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,YAAY,CAAC,CAAA;AA0BvD,wBAAsB,aAAa,CAAC,GAAG,EAAE,WAAW,EAAE,KAAK,EAAE,YAAY,GAAG,OAAO,CAAC,SAAS,CAAC,CAuD7F"}
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import { existsSync, readdirSync, readFileSync, statSync } from 'node:fs';
|
|
2
|
+
import { join } from 'node:path';
|
|
3
|
+
import { z } from 'zod';
|
|
4
|
+
import { reconcile } from '../../broker/reconcile.js';
|
|
5
|
+
import { ceilingPath, describeCeiling, loadCeiling, parseCeilingJson } from '../../policy/ceiling.js';
|
|
6
|
+
import { reviewCeilingDraft } from '../../policy/ceiling-review.js';
|
|
7
|
+
import { HARD_DENY } from '../../policy/hard-deny.js';
|
|
8
|
+
import { resolvePolicy } from '../../policy/profiles.js';
|
|
9
|
+
import { evaluateCommandPolicy, parseRulesLenient } from '../../policy/rules.js';
|
|
10
|
+
import { digestProject, loadJobDigest } from '../../trace/digest.js';
|
|
11
|
+
import { errorReply, reply } from '../context.js';
|
|
12
|
+
/**
|
|
13
|
+
* `agy_ceiling` — everything a parent agent needs to propose a project
|
|
14
|
+
* ceiling, and nothing that writes one (0.3.0 PR3, `skills/agy-ceiling/SKILL.md`).
|
|
15
|
+
*
|
|
16
|
+
* Without `draft`: the ceiling file's path and contents, the effective
|
|
17
|
+
* general_worker policy it produces, and the project's denial history
|
|
18
|
+
* (`digestProject` over every job directory). With `draft`: the review of
|
|
19
|
+
* that draft (`loadCeiling`'s own errors, advisory warnings, a risk class
|
|
20
|
+
* per rule) and, optionally, how the draft would judge `expected_commands`.
|
|
21
|
+
*
|
|
22
|
+
* Read-only by construction — there is no code path in this server that
|
|
23
|
+
* writes `policy.json`; the skill's approval rule is the second wall.
|
|
24
|
+
*/
|
|
25
|
+
export const ceilingInput = z.object({
|
|
26
|
+
draft: z
|
|
27
|
+
.unknown()
|
|
28
|
+
.optional()
|
|
29
|
+
.describe('A candidate policy.json object (version 2). When given, the reply carries its review instead of the current file\'s history.'),
|
|
30
|
+
expected_commands: z
|
|
31
|
+
.array(z.string())
|
|
32
|
+
.optional()
|
|
33
|
+
.describe('Shell commands to judge against the draft (or, without a draft, the current ceiling) as general_worker.'),
|
|
34
|
+
history_limit: z
|
|
35
|
+
.number()
|
|
36
|
+
.int()
|
|
37
|
+
.positive()
|
|
38
|
+
.max(500)
|
|
39
|
+
.optional()
|
|
40
|
+
.describe('How many of the most recent jobs feed the denial history. Default 100.'),
|
|
41
|
+
});
|
|
42
|
+
function projectHistory(jobsDir, limit) {
|
|
43
|
+
if (!existsSync(jobsDir))
|
|
44
|
+
return digestProject([], {});
|
|
45
|
+
const dirs = readdirSync(jobsDir)
|
|
46
|
+
.map((name) => join(jobsDir, name))
|
|
47
|
+
.filter((d) => {
|
|
48
|
+
try {
|
|
49
|
+
return statSync(d).isDirectory();
|
|
50
|
+
}
|
|
51
|
+
catch {
|
|
52
|
+
return false;
|
|
53
|
+
}
|
|
54
|
+
})
|
|
55
|
+
.sort((a, b) => statSync(b).mtimeMs - statSync(a).mtimeMs)
|
|
56
|
+
.slice(0, limit);
|
|
57
|
+
const digests = [];
|
|
58
|
+
const gateLogs = {};
|
|
59
|
+
for (const dir of dirs) {
|
|
60
|
+
const d = loadJobDigest(dir, null);
|
|
61
|
+
digests.push(d);
|
|
62
|
+
const gl = join(dir, 'gate-log.jsonl');
|
|
63
|
+
gateLogs[d.job_id] = existsSync(gl) ? readFileSync(gl, 'utf8') : null;
|
|
64
|
+
}
|
|
65
|
+
return digestProject(digests, gateLogs);
|
|
66
|
+
}
|
|
67
|
+
export async function handleCeiling(ctx, input) {
|
|
68
|
+
try {
|
|
69
|
+
await reconcile(ctx.store);
|
|
70
|
+
const path = ceilingPath(ctx.paths);
|
|
71
|
+
const present = existsSync(path);
|
|
72
|
+
const current = loadCeiling(ctx.paths);
|
|
73
|
+
const review = input.draft !== undefined ? reviewCeilingDraft(input.draft) : null;
|
|
74
|
+
// The policy the commands are judged against: the draft when it loads,
|
|
75
|
+
// else the current file. A draft that fails review still gets a reply —
|
|
76
|
+
// the errors are the point — but no preflight (there is no policy).
|
|
77
|
+
let judged = current;
|
|
78
|
+
if (review !== null) {
|
|
79
|
+
judged = review.ok ? parseCeilingJson(input.draft, '<draft>') : current;
|
|
80
|
+
}
|
|
81
|
+
const effective = resolvePolicy({ profile: 'general_worker', workspace: ctx.paths.root, ceiling: judged });
|
|
82
|
+
let preflight = null;
|
|
83
|
+
if (input.expected_commands && (review === null || review.ok)) {
|
|
84
|
+
const allowRules = parseRulesLenient(effective.allow);
|
|
85
|
+
const denyRules = parseRulesLenient(effective.deny);
|
|
86
|
+
preflight = input.expected_commands.map((command) => {
|
|
87
|
+
const r = evaluateCommandPolicy(command, allowRules, denyRules);
|
|
88
|
+
return {
|
|
89
|
+
command,
|
|
90
|
+
decision: r.allowed ? 'allow' : 'deny',
|
|
91
|
+
stage: r.stage,
|
|
92
|
+
required_rule: r.requiredRule,
|
|
93
|
+
};
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
const out = {
|
|
97
|
+
path,
|
|
98
|
+
present,
|
|
99
|
+
ceiling: describeCeiling(current, path, present),
|
|
100
|
+
effective: {
|
|
101
|
+
profile: 'general_worker',
|
|
102
|
+
allow: effective.allow,
|
|
103
|
+
deny: effective.deny,
|
|
104
|
+
hard_deny: HARD_DENY.map((r) => r.replaceAll('{workspace}', ctx.paths.root)),
|
|
105
|
+
lifted: effective.lifted,
|
|
106
|
+
read_roots: effective.read_roots,
|
|
107
|
+
command_policy: effective.command_policy,
|
|
108
|
+
warnings: effective.warnings ?? [],
|
|
109
|
+
},
|
|
110
|
+
review,
|
|
111
|
+
preflight,
|
|
112
|
+
history: review === null ? projectHistory(ctx.paths.jobsDir, input.history_limit ?? 100) : null,
|
|
113
|
+
writes_nothing: true,
|
|
114
|
+
};
|
|
115
|
+
return reply(out);
|
|
116
|
+
}
|
|
117
|
+
catch (e) {
|
|
118
|
+
return errorReply(e);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
//# sourceMappingURL=ceiling.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ceiling.js","sourceRoot":"","sources":["../../../src/server/tools/ceiling.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAA;AACzE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAChC,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAEvB,OAAO,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAA;AAErD,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAA;AACrG,OAAO,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAA;AACnE,OAAO,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAA;AACrD,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAA;AACxD,OAAO,EAAE,qBAAqB,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAA;AAChF,OAAO,EAAE,aAAa,EAAE,aAAa,EAAkB,MAAM,uBAAuB,CAAA;AACpF,OAAO,EAAE,UAAU,EAAE,KAAK,EAAoC,MAAM,eAAe,CAAA;AAEnF;;;;;;;;;;;;GAYG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,CAAC,MAAM,CAAC;IACnC,KAAK,EAAE,CAAC;SACL,OAAO,EAAE;SACT,QAAQ,EAA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AO,EAAE,MAAM,KAAK,IAAI,CAAC,CAAC,CAAC,cAAc,CAAC,GAAG,CAAC,KAAK,CAAC,OAAO,EAAE,KAAK,CAAC,aAAa,IAAI,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI;YAC/F,cAAc,EAAE,IAAI;SACrB,CAAA;QACD,OAAO,KAAK,CAAC,GAAG,CAAC,CAAA;IACnB,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,OAAO,UAAU,CAAC,CAAC,CAAC,CAAA;IACtB,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
2
|
+
import type { ToolContext } from '../context.js';
|
|
3
|
+
export * from './start.js';
|
|
4
|
+
export * from './wait.js';
|
|
5
|
+
export * from './result.js';
|
|
6
|
+
export * from './logs.js';
|
|
7
|
+
export * from './send.js';
|
|
8
|
+
export * from './cancel.js';
|
|
9
|
+
export * from './listJobs.js';
|
|
10
|
+
export * from './sessions.js';
|
|
11
|
+
export * from './capabilities.js';
|
|
12
|
+
export * from './ceiling.js';
|
|
13
|
+
/**
|
|
14
|
+
* MCP tool annotations for the ten tools.
|
|
15
|
+
*
|
|
16
|
+
* Read-only: wait, result, logs, list_jobs, sessions, capabilities.
|
|
17
|
+
* Idempotent: everything except `agy_start` and `agy_send`, which each append.
|
|
18
|
+
* Destructive: `agy_cancel`. Open-world: `agy_start`, which runs an external agent.
|
|
19
|
+
*/
|
|
20
|
+
export interface ToolAnnotations {
|
|
21
|
+
title?: string;
|
|
22
|
+
readOnlyHint?: boolean;
|
|
23
|
+
idempotentHint?: boolean;
|
|
24
|
+
destructiveHint?: boolean;
|
|
25
|
+
openWorldHint?: boolean;
|
|
26
|
+
}
|
|
27
|
+
export declare const TOOL_NAMES: readonly ["agy_start", "agy_wait", "agy_result", "agy_logs", "agy_send", "agy_cancel", "agy_list_jobs", "agy_sessions", "agy_capabilities", "agy_ceiling"];
|
|
28
|
+
export type ToolName = (typeof TOOL_NAMES)[number];
|
|
29
|
+
export declare const TOOL_ANNOTATIONS: Readonly<Record<ToolName, ToolAnnotations>>;
|
|
30
|
+
/**
|
|
31
|
+
* Register all ten tools.
|
|
32
|
+
*
|
|
33
|
+
* Every handler must call `broker.reconcile()` on entry — that is the only thing
|
|
34
|
+
* standing in for a daemon. Each `handle*` function in this
|
|
35
|
+
* directory does that itself, so registration here is pure wiring.
|
|
36
|
+
*/
|
|
37
|
+
export declare function registerAllTools(server: McpServer, ctx: ToolContext): void;
|
|
38
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/server/tools/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAA;AAGxE,OAAO,KAAK,EAAE,WAAW,EAAa,MAAM,eAAe,CAAA;AAa3D,cAAc,YAAY,CAAA;AAC1B,cAAc,WAAW,CAAA;AACzB,cAAc,aAAa,CAAA;AAC3B,cAAc,WAAW,CAAA;AACzB,cAAc,WAAW,CAAA;AACzB,cAAc,aAAa,CAAA;AAC3B,cAAc,eAAe,CAAA;AAC7B,cAAc,eAAe,CAAA;AAC7B,cAAc,mBAAmB,CAAA;AACjC,cAAc,cAAc,CAAA;AAE5B;;;;;;GAMG;AACH,MAAM,WAAW,eAAe;IAC9B,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,YAAY,CAAC,EAAE,OAAO,CAAA;IACtB,cAAc,CAAC,EAAE,OAAO,CAAA;IACxB,eAAe,CAAC,EAAE,OAAO,CAAA;IACzB,aAAa,CAAC,EAAE,OAAO,CAAA;CACxB;AAED,eAAO,MAAM,UAAU,4JAWb,CAAA;AAEV,MAAM,MAAM,QAAQ,GAAG,CAAC,OAAO,UAAU,CAAC,CAAC,MAAM,CAAC,CAAA;AAElD,eAAO,MAAM,gBAAgB,EAAE,QAAQ,CAAC,MAAM,CAAC,QAAQ,EAAE,eAAe,CAAC,CAgDvE,CAAA;AAEF;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,SAAS,EAAE,GAAG,EAAE,WAAW,GAAG,IAAI,CA4F1E"}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import { startInput, handleStart } from './start.js';
|
|
2
|
+
import { waitInput, handleWait } from './wait.js';
|
|
3
|
+
import { resultInput, handleResult } from './result.js';
|
|
4
|
+
import { logsInput, handleLogs } from './logs.js';
|
|
5
|
+
import { sendInput, handleSend } from './send.js';
|
|
6
|
+
import { cancelInput, handleCancel } from './cancel.js';
|
|
7
|
+
import { listJobsInput, handleListJobs } from './listJobs.js';
|
|
8
|
+
import { sessionsInput, handleSessions } from './sessions.js';
|
|
9
|
+
import { capabilitiesInput, handleCapabilities } from './capabilities.js';
|
|
10
|
+
import { ceilingInput, handleCeiling } from './ceiling.js';
|
|
11
|
+
export * from './start.js';
|
|
12
|
+
export * from './wait.js';
|
|
13
|
+
export * from './result.js';
|
|
14
|
+
export * from './logs.js';
|
|
15
|
+
export * from './send.js';
|
|
16
|
+
export * from './cancel.js';
|
|
17
|
+
export * from './listJobs.js';
|
|
18
|
+
export * from './sessions.js';
|
|
19
|
+
export * from './capabilities.js';
|
|
20
|
+
export * from './ceiling.js';
|
|
21
|
+
export const TOOL_NAMES = [
|
|
22
|
+
'agy_start',
|
|
23
|
+
'agy_wait',
|
|
24
|
+
'agy_result',
|
|
25
|
+
'agy_logs',
|
|
26
|
+
'agy_send',
|
|
27
|
+
'agy_cancel',
|
|
28
|
+
'agy_list_jobs',
|
|
29
|
+
'agy_sessions',
|
|
30
|
+
'agy_capabilities',
|
|
31
|
+
'agy_ceiling',
|
|
32
|
+
];
|
|
33
|
+
export const TOOL_ANNOTATIONS = Object.freeze({
|
|
34
|
+
agy_start: {
|
|
35
|
+
title: 'Start agy job',
|
|
36
|
+
openWorldHint: true,
|
|
37
|
+
},
|
|
38
|
+
agy_wait: {
|
|
39
|
+
title: 'Wait for job state',
|
|
40
|
+
readOnlyHint: true,
|
|
41
|
+
idempotentHint: true,
|
|
42
|
+
},
|
|
43
|
+
agy_result: {
|
|
44
|
+
title: 'Get job result',
|
|
45
|
+
readOnlyHint: true,
|
|
46
|
+
idempotentHint: true,
|
|
47
|
+
},
|
|
48
|
+
agy_logs: {
|
|
49
|
+
title: 'Read job logs',
|
|
50
|
+
readOnlyHint: true,
|
|
51
|
+
idempotentHint: true,
|
|
52
|
+
},
|
|
53
|
+
agy_send: {
|
|
54
|
+
title: 'Queue follow-up turn',
|
|
55
|
+
},
|
|
56
|
+
agy_cancel: {
|
|
57
|
+
title: 'Cancel job',
|
|
58
|
+
destructiveHint: true,
|
|
59
|
+
idempotentHint: true,
|
|
60
|
+
},
|
|
61
|
+
agy_list_jobs: {
|
|
62
|
+
title: 'List jobs',
|
|
63
|
+
readOnlyHint: true,
|
|
64
|
+
idempotentHint: true,
|
|
65
|
+
},
|
|
66
|
+
agy_sessions: {
|
|
67
|
+
title: 'Manage sessions',
|
|
68
|
+
readOnlyHint: true,
|
|
69
|
+
idempotentHint: true,
|
|
70
|
+
},
|
|
71
|
+
agy_capabilities: {
|
|
72
|
+
title: 'Server capabilities',
|
|
73
|
+
readOnlyHint: true,
|
|
74
|
+
idempotentHint: true,
|
|
75
|
+
},
|
|
76
|
+
agy_ceiling: {
|
|
77
|
+
title: 'Ceiling history and draft review',
|
|
78
|
+
readOnlyHint: true,
|
|
79
|
+
idempotentHint: true,
|
|
80
|
+
},
|
|
81
|
+
});
|
|
82
|
+
/**
|
|
83
|
+
* Register all ten tools.
|
|
84
|
+
*
|
|
85
|
+
* Every handler must call `broker.reconcile()` on entry — that is the only thing
|
|
86
|
+
* standing in for a daemon. Each `handle*` function in this
|
|
87
|
+
* directory does that itself, so registration here is pure wiring.
|
|
88
|
+
*/
|
|
89
|
+
export function registerAllTools(server, ctx) {
|
|
90
|
+
// The SDK's `registerTool` generics (`ZodRawShapeCompat`, its own zod-compat
|
|
91
|
+
// layer) do not infer cleanly against a locally generic wrapper. Registration
|
|
92
|
+
// is one-shot, boring wiring, so the loose cast here buys straightforward code
|
|
93
|
+
// over fighting the SDK's overload resolution; each `handle*` function is fully
|
|
94
|
+
// typed on its own, which is where a real mistake would actually be caught.
|
|
95
|
+
function register(name, description, inputSchema, handler) {
|
|
96
|
+
;
|
|
97
|
+
server.registerTool(name, {
|
|
98
|
+
title: TOOL_ANNOTATIONS[name].title,
|
|
99
|
+
description,
|
|
100
|
+
inputSchema,
|
|
101
|
+
annotations: TOOL_ANNOTATIONS[name],
|
|
102
|
+
}, async (args) => handler(ctx, args));
|
|
103
|
+
}
|
|
104
|
+
register('agy_start', 'Begin a new agy job. Returns job_id immediately; never blocks — plus policy_summary and blockers[] for what the profile ceiling did to your permissions request. Use dry_run to resolve config and policy without spawning agy or spending quota.', startInput.shape, handleStart);
|
|
105
|
+
register('agy_wait', 'Long-poll a job until it FINISHES or wait_ms runs out — it does not return early on intermediate transitions like queued->running (200ms internal polling; wait_ms=0 for an immediate snapshot). A short wait_ms is a poll interval, not a change notification: each call blocks for the whole budget unless the job finished. Returns the judgement packet only, not full logs or the response text.', waitInput.shape, handleWait);
|
|
106
|
+
register('agy_result', 'Full, paged result of a finished job: broker summary, agent self-report, and verification (blockers[] with source / actionable / remedy for each thing that stood in the way).', resultInput.shape, handleResult);
|
|
107
|
+
register('agy_logs', 'Read raw events, normalized human-readable lines, or stderr for a job, by byte cursor or tail.', logsInput.shape, handleLogs);
|
|
108
|
+
register('agy_send', 'Queue a follow-up turn on a session-mode job. Only takes effect after the in-flight turn finishes; there is no way to interrupt a running turn.', sendInput.shape, handleSend);
|
|
109
|
+
register('agy_cancel', 'Kill a running job and its whole process group.', cancelInput.shape, handleCancel);
|
|
110
|
+
register('agy_list_jobs', 'List running and recently finished jobs in this project.', listJobsInput.shape, handleListJobs);
|
|
111
|
+
register('agy_sessions', 'List, inspect, or close agy conversations (sessions). A session is one agy conversation; a job is one turn.', sessionsInput.shape, handleSessions);
|
|
112
|
+
register('agy_capabilities', 'Report models, profiles, limits, discovered project root, and server version.', capabilitiesInput.shape, handleCapabilities);
|
|
113
|
+
register('agy_ceiling', 'Read-only helper for proposing the project permission ceiling (policy.json). Without draft: current file, effective general_worker policy, and denial history across jobs. With draft: whether the file would load, advisory warnings, a risk class per rule, and how expected_commands would be judged. Never writes the file — show the draft to the user and let them approve it.', ceilingInput.shape, handleCeiling);
|
|
114
|
+
}
|
|
115
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/server/tools/index.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,YAAY,CAAA;AACpD,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,WAAW,CAAA;AACjD,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AACvD,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,WAAW,CAAA;AACjD,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,WAAW,CAAA;AACjD,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AACvD,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,eAAe,CAAA;AAC7D,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,eAAe,CAAA;AAC7D,OAAO,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAA;AACzE,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,cAAc,CAAA;AAE1D,cAAc,YAAY,CAAA;AAC1B,cAAc,WAAW,CAAA;AACzB,cAAc,aAAa,CAAA;AAC3B,cAAc,WAAW,CAAA;AACzB,cAAc,WAAW,CAAA;AACzB,cAAc,aAAa,CAAA;AAC3B,cAAc,eAAe,CAAA;AAC7B,cA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AAA;IACD,QAAQ,CACN,aAAa,EACb,sXAAsX,EACtX,YAAY,CAAC,KAAK,EAClB,aAAa,CACd,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { type ToolContext, type ToolReply } from '../context.js';
|
|
3
|
+
/**
|
|
4
|
+
* `agy_list_jobs` — running and recently finished jobs in this project.
|
|
5
|
+
*
|
|
6
|
+
* Jobs are per-project by construction; there is no cross-project view, which is
|
|
7
|
+
* the isolation property this design wanted anyway.
|
|
8
|
+
*/
|
|
9
|
+
export declare const listJobsInput: z.ZodObject<{
|
|
10
|
+
lifecycle: z.ZodOptional<z.ZodArray<z.ZodEnum<["queued", "starting", "running", "canceling", "finished"]>, "many">>;
|
|
11
|
+
session_id: z.ZodOptional<z.ZodString>;
|
|
12
|
+
cwd: z.ZodOptional<z.ZodString>;
|
|
13
|
+
since_ms: z.ZodOptional<z.ZodNumber>;
|
|
14
|
+
limit: z.ZodOptional<z.ZodNumber>;
|
|
15
|
+
}, "strip", z.ZodTypeAny, {
|
|
16
|
+
cwd?: string | undefined;
|
|
17
|
+
limit?: number | undefined;
|
|
18
|
+
session_id?: string | undefined;
|
|
19
|
+
lifecycle?: ("queued" | "starting" | "running" | "canceling" | "finished")[] | undefined;
|
|
20
|
+
since_ms?: number | undefined;
|
|
21
|
+
}, {
|
|
22
|
+
cwd?: string | undefined;
|
|
23
|
+
limit?: number | undefined;
|
|
24
|
+
session_id?: string | undefined;
|
|
25
|
+
lifecycle?: ("queued" | "starting" | "running" | "canceling" | "finished")[] | undefined;
|
|
26
|
+
since_ms?: number | undefined;
|
|
27
|
+
}>;
|
|
28
|
+
export type ListJobsInput = z.infer<typeof listJobsInput>;
|
|
29
|
+
export declare function handleListJobs(ctx: ToolContext, input: ListJobsInput): Promise<ToolReply>;
|
|
30
|
+
//# sourceMappingURL=listJobs.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"listJobs.d.ts","sourceRoot":"","sources":["../../../src/server/tools/listJobs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAIvB,OAAO,EAAqB,KAAK,WAAW,EAAE,KAAK,SAAS,EAAE,MAAM,eAAe,CAAA;AAEnF;;;;;GAKG;AACH,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;EASxB,CAAA;AAEF,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,aAAa,CAAC,CAAA;AAEzD,wBAAsB,cAAc,CAAC,GAAG,EAAE,WAAW,EAAE,KAAK,EAAE,aAAa,GAAG,OAAO,CAAC,SAAS,CAAC,CAc/F"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { reconcile } from '../../broker/reconcile.js';
|
|
3
|
+
import { listJobs } from '../../store/jobs.js';
|
|
4
|
+
import { errorReply, reply } from '../context.js';
|
|
5
|
+
/**
|
|
6
|
+
* `agy_list_jobs` — running and recently finished jobs in this project.
|
|
7
|
+
*
|
|
8
|
+
* Jobs are per-project by construction; there is no cross-project view, which is
|
|
9
|
+
* the isolation property this design wanted anyway.
|
|
10
|
+
*/
|
|
11
|
+
export const listJobsInput = z.object({
|
|
12
|
+
lifecycle: z
|
|
13
|
+
.array(z.enum(['queued', 'starting', 'running', 'canceling', 'finished']))
|
|
14
|
+
.optional()
|
|
15
|
+
.describe('Restrict to these lifecycle states.'),
|
|
16
|
+
session_id: z.string().optional(),
|
|
17
|
+
cwd: z.string().optional().describe('Exact match on the canonical workspace path.'),
|
|
18
|
+
since_ms: z.number().int().positive().optional().describe('Only jobs created in the last N ms.'),
|
|
19
|
+
limit: z.number().int().positive().optional(),
|
|
20
|
+
});
|
|
21
|
+
export async function handleListJobs(ctx, input) {
|
|
22
|
+
try {
|
|
23
|
+
await reconcile(ctx.store);
|
|
24
|
+
const rows = listJobs(ctx.store, {
|
|
25
|
+
lifecycle: input.lifecycle,
|
|
26
|
+
sessionId: input.session_id,
|
|
27
|
+
cwd: input.cwd,
|
|
28
|
+
since: input.since_ms !== undefined ? Date.now() - input.since_ms : undefined,
|
|
29
|
+
limit: input.limit,
|
|
30
|
+
});
|
|
31
|
+
return reply({ jobs: rows, count: rows.length });
|
|
32
|
+
}
|
|
33
|
+
catch (e) {
|
|
34
|
+
return errorReply(e);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=listJobs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"listJobs.js","sourceRoot":"","sources":["../../../src/server/tools/listJobs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAEvB,OAAO,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAA;AACrD,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAA;AAC9C,OAAO,EAAE,UAAU,EAAE,KAAK,EAAoC,MAAM,eAAe,CAAA;AAEnF;;;;;GAKG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,CAAC,MAAM,CAAC;IACpC,SAAS,EAAE,CAAC;SACT,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,QAAQ,EAAE,UAAU,EAAE,SAAS,EAAE,WAAW,EAAE,UAAU,CAAC,CAAC,CAAC;SACzE,QAAQ,EAAE;SACV,QAAQ,CAAC,qCAAqC,CAAC;IAClD,UAAU,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IACjC,GAAG,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,8CAA8C,CAAC;IACnF,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,qCAAqC,CAAC;IAChG,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,EAAE;CAC9C,CAAC,CAAA;AAIF,MAAM,CAAC,KAAK,UAAU,cAAc,CAAC,GAAgB,EAAE,KAAoB;IACzE,IAAI,CAAC;QACH,MAAM,SAAS,CAAC,GAAG,CAAC,KAAK,CAAC,CAAA;QAC1B,MAAM,IAAI,GAAG,QAAQ,CAAC,GAAG,CAAC,KAAK,EAAE;YAC/B,SAAS,EAAE,KAAK,CAAC,SAAS;YAC1B,SAAS,EAAE,KAAK,CAAC,UAAU;YAC3B,GAAG,EAAE,KAAK,CAAC,GAAG;YACd,KAAK,EAAE,KAAK,CAAC,QAAQ,KAAK,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,SAAS;YAC7E,KAAK,EAAE,KAAK,CAAC,KAAK;SACnB,CAAC,CAAA;QACF,OAAO,KAAK,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,CAAC,MAAM,EAAE,CAAC,CAAA;IAClD,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,OAAO,UAAU,CAAC,CAAC,CAAC,CAAA;IACtB,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { type ToolContext, type ToolReply } from '../context.js';
|
|
3
|
+
/**
|
|
4
|
+
* `agy_logs` — read events, normalized lines, or stderr by cursor or tail.
|
|
5
|
+
*
|
|
6
|
+
* MVP-essential rather than a later nicety: with jobs owned by no client, this is
|
|
7
|
+
* the only way a client that did not start a job can see what it is doing
|
|
8
|
+
* (see docs/tools.md).
|
|
9
|
+
*/
|
|
10
|
+
export declare const logsInput: z.ZodObject<{
|
|
11
|
+
job_id: z.ZodString;
|
|
12
|
+
stream: z.ZodOptional<z.ZodEnum<["events", "normalized", "stderr", "digest"]>>;
|
|
13
|
+
after_cursor: z.ZodOptional<z.ZodNumber>;
|
|
14
|
+
tail_lines: z.ZodOptional<z.ZodNumber>;
|
|
15
|
+
max_bytes: z.ZodOptional<z.ZodNumber>;
|
|
16
|
+
}, "strip", z.ZodTypeAny, {
|
|
17
|
+
job_id: string;
|
|
18
|
+
after_cursor?: number | undefined;
|
|
19
|
+
stream?: "events" | "normalized" | "stderr" | "digest" | undefined;
|
|
20
|
+
tail_lines?: number | undefined;
|
|
21
|
+
max_bytes?: number | undefined;
|
|
22
|
+
}, {
|
|
23
|
+
job_id: string;
|
|
24
|
+
after_cursor?: number | undefined;
|
|
25
|
+
stream?: "events" | "normalized" | "stderr" | "digest" | undefined;
|
|
26
|
+
tail_lines?: number | undefined;
|
|
27
|
+
max_bytes?: number | undefined;
|
|
28
|
+
}>;
|
|
29
|
+
export type LogsInput = z.infer<typeof logsInput>;
|
|
30
|
+
export declare function handleLogs(ctx: ToolContext, input: LogsInput): Promise<ToolReply>;
|
|
31
|
+
//# sourceMappingURL=logs.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logs.d.ts","sourceRoot":"","sources":["../../../src/server/tools/logs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAUvB,OAAO,EAAqB,KAAK,WAAW,EAAE,KAAK,SAAS,EAAE,MAAM,eAAe,CAAA;AAEnF;;;;;;GAMG;AACH,eAAO,MAAM,SAAS;;;;;;;;;;;;;;;;;;EAqBpB,CAAA;AAEF,MAAM,MAAM,SAAS,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,SAAS,CAAC,CAAA;AAEjD,wBAAsB,UAAU,CAAC,GAAG,EAAE,WAAW,EAAE,KAAK,EAAE,SAAS,GAAG,OAAO,CAAC,SAAS,CAAC,CAgEvF"}
|