@honeybee-ai/waggle-cli 1.0.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/README.md +77 -0
- package/dist/cli.d.ts +1 -0
- package/dist/cli.js +4307 -0
- package/dist/cli.js.map +7 -0
- package/dist/commands/auth.d.ts +1 -0
- package/dist/commands/auth.js +155 -0
- package/dist/commands/auth.js.map +1 -0
- package/dist/commands/claim.d.ts +1 -0
- package/dist/commands/claim.js +36 -0
- package/dist/commands/claim.js.map +1 -0
- package/dist/commands/completion.d.ts +1 -0
- package/dist/commands/completion.js +191 -0
- package/dist/commands/completion.js.map +1 -0
- package/dist/commands/config-cmd.d.ts +1 -0
- package/dist/commands/config-cmd.js +61 -0
- package/dist/commands/config-cmd.js.map +1 -0
- package/dist/commands/events.d.ts +1 -0
- package/dist/commands/events.js +129 -0
- package/dist/commands/events.js.map +1 -0
- package/dist/commands/halt.d.ts +1 -0
- package/dist/commands/halt.js +25 -0
- package/dist/commands/halt.js.map +1 -0
- package/dist/commands/help-cmd.d.ts +1 -0
- package/dist/commands/help-cmd.js +125 -0
- package/dist/commands/help-cmd.js.map +1 -0
- package/dist/commands/hooks-cmd.d.ts +1 -0
- package/dist/commands/hooks-cmd.js +83 -0
- package/dist/commands/hooks-cmd.js.map +1 -0
- package/dist/commands/init.d.ts +1 -0
- package/dist/commands/init.js +78 -0
- package/dist/commands/init.js.map +1 -0
- package/dist/commands/integrations.d.ts +1 -0
- package/dist/commands/integrations.js +375 -0
- package/dist/commands/integrations.js.map +1 -0
- package/dist/commands/join.d.ts +1 -0
- package/dist/commands/join.js +81 -0
- package/dist/commands/join.js.map +1 -0
- package/dist/commands/leave.d.ts +1 -0
- package/dist/commands/leave.js +36 -0
- package/dist/commands/leave.js.map +1 -0
- package/dist/commands/marketplace.d.ts +1 -0
- package/dist/commands/marketplace.js +291 -0
- package/dist/commands/marketplace.js.map +1 -0
- package/dist/commands/msg.d.ts +1 -0
- package/dist/commands/msg.js +105 -0
- package/dist/commands/msg.js.map +1 -0
- package/dist/commands/namespace.d.ts +1 -0
- package/dist/commands/namespace.js +95 -0
- package/dist/commands/namespace.js.map +1 -0
- package/dist/commands/pause.d.ts +2 -0
- package/dist/commands/pause.js +45 -0
- package/dist/commands/pause.js.map +1 -0
- package/dist/commands/protocol.d.ts +1 -0
- package/dist/commands/protocol.js +341 -0
- package/dist/commands/protocol.js.map +1 -0
- package/dist/commands/release.d.ts +1 -0
- package/dist/commands/release.js +29 -0
- package/dist/commands/release.js.map +1 -0
- package/dist/commands/scan.d.ts +1 -0
- package/dist/commands/scan.js +157 -0
- package/dist/commands/scan.js.map +1 -0
- package/dist/commands/serve.d.ts +1 -0
- package/dist/commands/serve.js +78 -0
- package/dist/commands/serve.js.map +1 -0
- package/dist/commands/state.d.ts +1 -0
- package/dist/commands/state.js +119 -0
- package/dist/commands/state.js.map +1 -0
- package/dist/commands/status.d.ts +1 -0
- package/dist/commands/status.js +78 -0
- package/dist/commands/status.js.map +1 -0
- package/dist/commands/swarm.d.ts +1 -0
- package/dist/commands/swarm.js +404 -0
- package/dist/commands/swarm.js.map +1 -0
- package/dist/commands/team.d.ts +1 -0
- package/dist/commands/team.js +35 -0
- package/dist/commands/team.js.map +1 -0
- package/dist/commands/upgrade.d.ts +1 -0
- package/dist/commands/upgrade.js +99 -0
- package/dist/commands/upgrade.js.map +1 -0
- package/dist/hook.d.ts +1 -0
- package/dist/hook.js +531 -0
- package/dist/hook.js.map +7 -0
- package/dist/hooks/post-tool-use.d.ts +2 -0
- package/dist/hooks/post-tool-use.js +16 -0
- package/dist/hooks/post-tool-use.js.map +1 -0
- package/dist/hooks/pre-tool-use.d.ts +2 -0
- package/dist/hooks/pre-tool-use.js +49 -0
- package/dist/hooks/pre-tool-use.js.map +1 -0
- package/dist/hooks/prompt-submit.d.ts +2 -0
- package/dist/hooks/prompt-submit.js +64 -0
- package/dist/hooks/prompt-submit.js.map +1 -0
- package/dist/hooks/session-start.d.ts +2 -0
- package/dist/hooks/session-start.js +101 -0
- package/dist/hooks/session-start.js.map +1 -0
- package/dist/hooks/stop.d.ts +2 -0
- package/dist/hooks/stop.js +52 -0
- package/dist/hooks/stop.js.map +1 -0
- package/dist/lib/config.d.ts +6 -0
- package/dist/lib/config.js +53 -0
- package/dist/lib/config.js.map +1 -0
- package/dist/lib/format.d.ts +22 -0
- package/dist/lib/format.js +42 -0
- package/dist/lib/format.js.map +1 -0
- package/dist/lib/global-config.d.ts +13 -0
- package/dist/lib/global-config.js +52 -0
- package/dist/lib/global-config.js.map +1 -0
- package/dist/lib/hooks.d.ts +2 -0
- package/dist/lib/hooks.js +75 -0
- package/dist/lib/hooks.js.map +1 -0
- package/dist/lib/id.d.ts +1 -0
- package/dist/lib/id.js +5 -0
- package/dist/lib/id.js.map +1 -0
- package/dist/types.d.ts +26 -0
- package/dist/types.js +3 -0
- package/dist/types.js.map +1 -0
- package/hooks/post-tool-use.sh +13 -0
- package/hooks/pre-tool-use.sh +13 -0
- package/hooks/prompt-submit.sh +13 -0
- package/hooks/session-start.sh +13 -0
- package/hooks/stop.sh +13 -0
- package/package.json +68 -0
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { loadConfig } from '../lib/config.js';
|
|
2
|
+
import { createAcpClient } from '@agentcoordinationprotocol/sdk';
|
|
3
|
+
import { c, error, heading } from '../lib/format.js';
|
|
4
|
+
export async function team() {
|
|
5
|
+
const config = loadConfig();
|
|
6
|
+
if (!config) {
|
|
7
|
+
console.log(error('Not initialized. Run `wgl init` or `wgl join` first.'));
|
|
8
|
+
process.exit(1);
|
|
9
|
+
}
|
|
10
|
+
const client = createAcpClient(config);
|
|
11
|
+
try {
|
|
12
|
+
const res = await client.getRoles();
|
|
13
|
+
if (!res.ok) {
|
|
14
|
+
console.log(error(`Server returned ${res.status}`));
|
|
15
|
+
process.exit(1);
|
|
16
|
+
}
|
|
17
|
+
const roles = res.data;
|
|
18
|
+
console.log(heading('Team'));
|
|
19
|
+
if (roles.length === 0) {
|
|
20
|
+
console.log(` ${c('dim', 'No agents connected')}`);
|
|
21
|
+
}
|
|
22
|
+
else {
|
|
23
|
+
for (const r of roles) {
|
|
24
|
+
const you = r.agent === config.agentId ? c('green', ' (you)') : '';
|
|
25
|
+
console.log(` ${c('bold', r.role.padEnd(15))} ${r.agent}${you}`);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
catch {
|
|
30
|
+
console.log(error('Cannot reach server'));
|
|
31
|
+
process.exit(1);
|
|
32
|
+
}
|
|
33
|
+
console.log();
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=team.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"team.js","sourceRoot":"","sources":["../../src/commands/team.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AACjE,OAAO,EAAE,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAGrD,MAAM,CAAC,KAAK,UAAU,IAAI;IACxB,MAAM,MAAM,GAAG,UAAU,EAAE,CAAC;IAC5B,IAAI,CAAC,MAAM,EAAE,CAAC;QACZ,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,sDAAsD,CAAC,CAAC,CAAC;QAC3E,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;IAED,MAAM,MAAM,GAAG,eAAe,CAAC,MAAM,CAAC,CAAC;IAEvC,IAAI,CAAC;QACH,MAAM,GAAG,GAAG,MAAM,MAAM,CAAC,QAAQ,EAAE,CAAC;QACpC,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC;YACZ,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,mBAAmB,GAAG,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC;YACpD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAClB,CAAC;QAED,MAAM,KAAK,GAAG,GAAG,CAAC,IAAwB,CAAC;QAC3C,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC;QAE7B,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACvB,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,qBAAqB,CAAC,EAAE,CAAC,CAAC;QACtD,CAAC;aAAM,CAAC;YACN,KAAK,MAAM,CAAC,IAAI,KAAK,EAAE,CAAC;gBACtB,MAAM,GAAG,GAAG,CAAC,CAAC,KAAK,KAAK,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;gBACnE,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,KAAK,GAAG,GAAG,EAAE,CAAC,CAAC;YACpE,CAAC;QACH,CAAC;IACH,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,qBAAqB,CAAC,CAAC,CAAC;QAC1C,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;IAED,OAAO,CAAC,GAAG,EAAE,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function upgrade(args: string[]): Promise<void>;
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { readFileSync } from 'node:fs';
|
|
2
|
+
import { join, dirname } from 'node:path';
|
|
3
|
+
import { request as httpsRequest } from 'node:https';
|
|
4
|
+
import { execSync } from 'node:child_process';
|
|
5
|
+
import { c, error, label, success } from '../lib/format.js';
|
|
6
|
+
const REGISTRY_URL = 'https://registry.npmjs.org/@honeybee-ai/waggle-cli/latest';
|
|
7
|
+
function getCurrentVersion() {
|
|
8
|
+
if (typeof WGL_VERSION !== 'undefined')
|
|
9
|
+
return WGL_VERSION;
|
|
10
|
+
try {
|
|
11
|
+
const pkgPath = join(dirname(new URL(import.meta.url).pathname), '..', 'package.json');
|
|
12
|
+
return JSON.parse(readFileSync(pkgPath, 'utf8')).version;
|
|
13
|
+
}
|
|
14
|
+
catch {
|
|
15
|
+
return '0.0.0-dev';
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
function fetchLatestVersion() {
|
|
19
|
+
return new Promise((resolve, reject) => {
|
|
20
|
+
const req = httpsRequest(REGISTRY_URL, { timeout: 10000 }, (res) => {
|
|
21
|
+
let data = '';
|
|
22
|
+
res.on('data', (chunk) => data += chunk);
|
|
23
|
+
res.on('end', () => {
|
|
24
|
+
try {
|
|
25
|
+
const parsed = JSON.parse(data);
|
|
26
|
+
resolve(parsed.version);
|
|
27
|
+
}
|
|
28
|
+
catch {
|
|
29
|
+
reject(new Error('Failed to parse registry response'));
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
});
|
|
33
|
+
req.on('error', (err) => reject(err));
|
|
34
|
+
req.on('timeout', () => { req.destroy(); reject(new Error('timeout')); });
|
|
35
|
+
req.end();
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
export async function upgrade(args) {
|
|
39
|
+
if (args[0] === '--help' || args[0] === '-h') {
|
|
40
|
+
console.log(`
|
|
41
|
+
${c('bold', 'wgl upgrade')} — update waggle-cli to the latest version
|
|
42
|
+
|
|
43
|
+
${c('cyan', 'USAGE:')}
|
|
44
|
+
wgl upgrade Update to latest version
|
|
45
|
+
wgl upgrade --check Just check, don't install
|
|
46
|
+
`);
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
const checkOnly = args.includes('--check');
|
|
50
|
+
const current = getCurrentVersion();
|
|
51
|
+
console.log(label('Current', current));
|
|
52
|
+
let latest;
|
|
53
|
+
try {
|
|
54
|
+
latest = await fetchLatestVersion();
|
|
55
|
+
}
|
|
56
|
+
catch {
|
|
57
|
+
console.log(error('Cannot reach npm registry'));
|
|
58
|
+
process.exit(1);
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
console.log(label('Latest', latest));
|
|
62
|
+
if (current === latest) {
|
|
63
|
+
console.log(`\n ${c('green', 'Already up to date')}`);
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
// Compare versions
|
|
67
|
+
const currentParts = current.split('.').map(Number);
|
|
68
|
+
const latestParts = latest.split('.').map(Number);
|
|
69
|
+
let isNewer = false;
|
|
70
|
+
for (let i = 0; i < 3; i++) {
|
|
71
|
+
if (latestParts[i] > currentParts[i]) {
|
|
72
|
+
isNewer = true;
|
|
73
|
+
break;
|
|
74
|
+
}
|
|
75
|
+
if (latestParts[i] < currentParts[i])
|
|
76
|
+
break;
|
|
77
|
+
}
|
|
78
|
+
if (!isNewer) {
|
|
79
|
+
console.log(`\n ${c('green', 'Already up to date (or ahead)')}`);
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
if (checkOnly) {
|
|
83
|
+
console.log(`\n ${c('yellow', `Update available: ${current} → ${latest}`)}`);
|
|
84
|
+
console.log(c('dim', ' Run `wgl upgrade` to install'));
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
console.log(`\n Upgrading ${current} → ${latest}...`);
|
|
88
|
+
try {
|
|
89
|
+
execSync('npm install -g @honeybee-ai/waggle-cli@latest', {
|
|
90
|
+
stdio: 'inherit',
|
|
91
|
+
});
|
|
92
|
+
console.log(success(`Updated to ${latest}`));
|
|
93
|
+
}
|
|
94
|
+
catch {
|
|
95
|
+
console.log(error('Upgrade failed. Try manually: npm install -g @honeybee-ai/waggle-cli@latest'));
|
|
96
|
+
process.exit(1);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
//# sourceMappingURL=upgrade.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"upgrade.js","sourceRo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;QAC9E,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,KAAK,EAAE,gCAAgC,CAAC,CAAC,CAAC;QACxD,OAAO;IACT,CAAC;IAED,OAAO,CAAC,GAAG,CAAC,iBAAiB,OAAO,MAAM,MAAM,KAAK,CAAC,CAAC;IAEvD,IAAI,CAAC;QACH,QAAQ,CAAC,+CAA+C,EAAE;YACxD,KAAK,EAAE,SAAS;SACjB,CAAC,CAAC;QACH,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,cAAc,MAAM,EAAE,CAAC,CAAC,CAAC;IAC/C,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,6EAA6E,CAAC,CAAC,CAAC;QAClG,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;AACH,CAAC"}
|
package/dist/hook.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/hook.js
ADDED
|
@@ -0,0 +1,531 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __esm = (fn, res) => function __init() {
|
|
5
|
+
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
6
|
+
};
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
// node_modules/.pnpm/@agentcoordinationprotocol+sdk@file+..+acp+packages+sdk/node_modules/@agentcoordinationprotocol/sdk/dist/client.js
|
|
13
|
+
import { request as httpRequest } from "node:http";
|
|
14
|
+
import { request as httpsRequest } from "node:https";
|
|
15
|
+
function createAcpClient(config2) {
|
|
16
|
+
const base = config2.server.replace(/\/$/, "");
|
|
17
|
+
const ns = (config2.namespace ?? "default") === "default" ? "" : `/${config2.namespace}`;
|
|
18
|
+
function fetch(method, path, body) {
|
|
19
|
+
return new Promise((resolve, reject) => {
|
|
20
|
+
const url = new URL(`${base}/api${ns}${path}`);
|
|
21
|
+
const isHttps = url.protocol === "https:";
|
|
22
|
+
const reqFn = isHttps ? httpsRequest : httpRequest;
|
|
23
|
+
const headers = {
|
|
24
|
+
"X-Agent-Id": config2.agentId
|
|
25
|
+
};
|
|
26
|
+
let payload;
|
|
27
|
+
if (body !== void 0) {
|
|
28
|
+
payload = JSON.stringify(body);
|
|
29
|
+
headers["Content-Type"] = "application/json";
|
|
30
|
+
headers["Content-Length"] = Buffer.byteLength(payload).toString();
|
|
31
|
+
}
|
|
32
|
+
const req = reqFn(url, { method, headers, timeout: TIMEOUT }, (res) => {
|
|
33
|
+
let data = "";
|
|
34
|
+
res.on("data", (chunk) => data += chunk);
|
|
35
|
+
res.on("end", () => {
|
|
36
|
+
try {
|
|
37
|
+
const parsed = data ? JSON.parse(data) : {};
|
|
38
|
+
resolve({ ok: res.statusCode >= 200 && res.statusCode < 300, status: res.statusCode, data: parsed });
|
|
39
|
+
} catch {
|
|
40
|
+
resolve({ ok: false, status: res.statusCode, data: {} });
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
});
|
|
44
|
+
req.on("error", (err) => reject(err));
|
|
45
|
+
req.on("timeout", () => {
|
|
46
|
+
req.destroy();
|
|
47
|
+
reject(new Error("timeout"));
|
|
48
|
+
});
|
|
49
|
+
if (payload)
|
|
50
|
+
req.write(payload);
|
|
51
|
+
req.end();
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
return {
|
|
55
|
+
// Health
|
|
56
|
+
health: () => fetch("GET", "/health"),
|
|
57
|
+
// Control
|
|
58
|
+
getControlStatus: () => fetch("GET", "/control/status"),
|
|
59
|
+
halt: (reason, opts) => fetch("POST", "/control/halt", { reason, ...opts }),
|
|
60
|
+
pause: (reason, opts) => fetch("POST", "/control/pause", { reason, ...opts }),
|
|
61
|
+
resume: (opts) => fetch("POST", "/control/resume", opts ?? {}),
|
|
62
|
+
// Claims
|
|
63
|
+
claim: (resource, value, opts) => fetch("POST", "/claims", { resource, value: value || resource, ...opts }),
|
|
64
|
+
releaseClaim: (resource) => fetch("DELETE", `/claims/${encodeURIComponent(resource)}`),
|
|
65
|
+
getClaims: (pattern) => {
|
|
66
|
+
const qs = pattern ? `?pattern=${encodeURIComponent(pattern)}` : "";
|
|
67
|
+
return fetch("GET", `/claims${qs}`);
|
|
68
|
+
},
|
|
69
|
+
checkClaim: (resource) => fetch("GET", `/claims/${encodeURIComponent(resource)}`),
|
|
70
|
+
listClaims: (pattern) => {
|
|
71
|
+
const qs = pattern ? `?pattern=${encodeURIComponent(pattern)}` : "";
|
|
72
|
+
return fetch("GET", `/claims${qs}`);
|
|
73
|
+
},
|
|
74
|
+
// Events
|
|
75
|
+
publishEvent: (type, data) => fetch("POST", "/events", { type, data }),
|
|
76
|
+
getEvents: (since, opts) => {
|
|
77
|
+
const params = [];
|
|
78
|
+
if (since !== void 0)
|
|
79
|
+
params.push(`since=${since}`);
|
|
80
|
+
if (opts?.type)
|
|
81
|
+
params.push(`type=${encodeURIComponent(opts.type)}`);
|
|
82
|
+
const qs = params.length ? `?${params.join("&")}` : "";
|
|
83
|
+
return fetch("GET", `/events${qs}`);
|
|
84
|
+
},
|
|
85
|
+
// Discoveries
|
|
86
|
+
publishDiscovery: (topic, content, category) => fetch("POST", "/discoveries", { topic, content, category }),
|
|
87
|
+
getDiscoveries: () => fetch("GET", "/discoveries"),
|
|
88
|
+
searchDiscoveries: (opts) => {
|
|
89
|
+
const params = [];
|
|
90
|
+
if (opts?.query)
|
|
91
|
+
params.push(`query=${encodeURIComponent(opts.query)}`);
|
|
92
|
+
if (opts?.category)
|
|
93
|
+
params.push(`category=${encodeURIComponent(opts.category)}`);
|
|
94
|
+
const qs = params.length ? `?${params.join("&")}` : "";
|
|
95
|
+
return fetch("GET", `/discoveries${qs}`);
|
|
96
|
+
},
|
|
97
|
+
// Messages
|
|
98
|
+
sendMessage: (to, content, opts) => fetch("POST", "/messages", { to, content, ...opts }),
|
|
99
|
+
getMessages: (opts) => {
|
|
100
|
+
const qs = opts?.since ? `?since=${encodeURIComponent(opts.since)}` : "";
|
|
101
|
+
return fetch("GET", `/messages${qs}`);
|
|
102
|
+
},
|
|
103
|
+
// Roles
|
|
104
|
+
requestRole: (role, opts) => fetch("POST", "/roles/request", { role, ...opts }),
|
|
105
|
+
getRoles: () => fetch("GET", "/roles"),
|
|
106
|
+
// Help
|
|
107
|
+
getHelp: () => fetch("GET", "/help"),
|
|
108
|
+
requestHelp: (problem, needs_capability, urgency) => fetch("POST", "/help", { problem, needs_capability, urgency }),
|
|
109
|
+
claimHelp: (id) => fetch("POST", `/help/${encodeURIComponent(id)}/claim`),
|
|
110
|
+
resolveHelp: (id) => fetch("POST", `/help/${encodeURIComponent(id)}/resolve`),
|
|
111
|
+
// Progress
|
|
112
|
+
reportProgress: (claim, progress, note) => fetch("POST", "/progress", { claim, progress, note }),
|
|
113
|
+
// Protocol
|
|
114
|
+
getProtocol: (role) => {
|
|
115
|
+
const qs = role ? `?role=${encodeURIComponent(role)}` : "";
|
|
116
|
+
return fetch("GET", `/protocol${qs}`);
|
|
117
|
+
},
|
|
118
|
+
loadProtocol: (protocol) => fetch("PUT", "/protocol", protocol),
|
|
119
|
+
// State
|
|
120
|
+
getState: (pattern, category) => {
|
|
121
|
+
const params = [];
|
|
122
|
+
if (pattern)
|
|
123
|
+
params.push(`pattern=${encodeURIComponent(pattern)}`);
|
|
124
|
+
if (category)
|
|
125
|
+
params.push(`category=${encodeURIComponent(category)}`);
|
|
126
|
+
const qs = params.length ? `?${params.join("&")}` : "";
|
|
127
|
+
return fetch("GET", `/state${qs}`);
|
|
128
|
+
},
|
|
129
|
+
getStateKey: (key) => fetch("GET", `/state/${encodeURIComponent(key)}`),
|
|
130
|
+
queryState: (opts) => {
|
|
131
|
+
const params = [];
|
|
132
|
+
if (opts?.pattern)
|
|
133
|
+
params.push(`pattern=${encodeURIComponent(opts.pattern)}`);
|
|
134
|
+
if (opts?.category)
|
|
135
|
+
params.push(`category=${encodeURIComponent(opts.category)}`);
|
|
136
|
+
const qs = params.length ? `?${params.join("&")}` : "";
|
|
137
|
+
return fetch("GET", `/state${qs}`);
|
|
138
|
+
},
|
|
139
|
+
setState: (key, value, category, ttlMs) => fetch("PUT", `/state/${encodeURIComponent(key)}`, { value, category, ttlMs }),
|
|
140
|
+
deleteState: (key) => fetch("DELETE", `/state/${encodeURIComponent(key)}`),
|
|
141
|
+
// Conflicts
|
|
142
|
+
flagConflict: (discovery_a, discovery_b, reason) => fetch("POST", "/conflicts", { discovery_a, discovery_b, reason }),
|
|
143
|
+
// Reinforcements
|
|
144
|
+
requestReinforcement: (role, opts) => fetch("POST", "/reinforcements", { role, ...opts }),
|
|
145
|
+
// Governance
|
|
146
|
+
requestApproval: (action, opts) => fetch("POST", "/governance/approve", { action, ...opts }),
|
|
147
|
+
escalate: (reason, context) => fetch("POST", "/governance/escalate", { reason, context }),
|
|
148
|
+
proposeAction: (action, opts) => fetch("POST", "/governance/propose", { action, ...opts }),
|
|
149
|
+
endorseAction: (proposalId) => fetch("POST", `/governance/endorse/${encodeURIComponent(proposalId)}`),
|
|
150
|
+
requestRollback: (reason, scope) => fetch("POST", "/governance/rollback", { reason, scope }),
|
|
151
|
+
// Topics (Honeycomb cross-namespace routing)
|
|
152
|
+
getTopics: () => fetch("GET", "/topics"),
|
|
153
|
+
subscribeTopic: (topic) => fetch("POST", "/topics/subscribe", { topic }),
|
|
154
|
+
unsubscribeTopic: (topic) => fetch("DELETE", `/topics/subscribe/${encodeURIComponent(topic)}`),
|
|
155
|
+
publishTopic: (topic) => fetch("POST", "/topics/publish", { topic }),
|
|
156
|
+
unpublishTopic: (topic) => fetch("DELETE", `/topics/publish/${encodeURIComponent(topic)}`),
|
|
157
|
+
// Namespaces
|
|
158
|
+
getNamespaces: () => fetch("GET", "/_ns"),
|
|
159
|
+
createNamespace: (name) => fetch("POST", "/_ns", { name }),
|
|
160
|
+
deleteNamespace: (name) => fetch("DELETE", `/_ns/${encodeURIComponent(name)}`)
|
|
161
|
+
};
|
|
162
|
+
}
|
|
163
|
+
var TIMEOUT;
|
|
164
|
+
var init_client = __esm({
|
|
165
|
+
"node_modules/.pnpm/@agentcoordinationprotocol+sdk@file+..+acp+packages+sdk/node_modules/@agentcoordinationprotocol/sdk/dist/client.js"() {
|
|
166
|
+
TIMEOUT = 3e3;
|
|
167
|
+
}
|
|
168
|
+
});
|
|
169
|
+
|
|
170
|
+
// node_modules/.pnpm/@agentcoordinationprotocol+sdk@file+..+acp+packages+sdk/node_modules/@agentcoordinationprotocol/sdk/dist/index.js
|
|
171
|
+
var init_dist = __esm({
|
|
172
|
+
"node_modules/.pnpm/@agentcoordinationprotocol+sdk@file+..+acp+packages+sdk/node_modules/@agentcoordinationprotocol/sdk/dist/index.js"() {
|
|
173
|
+
init_client();
|
|
174
|
+
}
|
|
175
|
+
});
|
|
176
|
+
|
|
177
|
+
// src/hooks/session-start.ts
|
|
178
|
+
var session_start_exports = {};
|
|
179
|
+
__export(session_start_exports, {
|
|
180
|
+
handleSessionStart: () => handleSessionStart
|
|
181
|
+
});
|
|
182
|
+
import { appendFileSync } from "node:fs";
|
|
183
|
+
async function handleSessionStart(config2, configPath2, _input) {
|
|
184
|
+
const envFile = process.env.CLAUDE_ENV_FILE;
|
|
185
|
+
if (envFile) {
|
|
186
|
+
appendFileSync(envFile, [
|
|
187
|
+
`export WGL_SERVER="${config2.server}"`,
|
|
188
|
+
`export WGL_AGENT_ID="${config2.agentId}"`,
|
|
189
|
+
`export WGL_NAMESPACE="${config2.namespace}"`,
|
|
190
|
+
`export WGL_ROLE="${config2.role}"`,
|
|
191
|
+
`export WGL_CONFIG="${configPath2}"`
|
|
192
|
+
].join("\n") + "\n");
|
|
193
|
+
}
|
|
194
|
+
const client = createAcpClient(config2);
|
|
195
|
+
const context = [];
|
|
196
|
+
try {
|
|
197
|
+
const [controlRes, protocolRes, rolesRes, claimsRes, messagesRes] = await Promise.all([
|
|
198
|
+
client.getControlStatus().catch(() => null),
|
|
199
|
+
client.getProtocol().catch(() => null),
|
|
200
|
+
client.getRoles().catch(() => null),
|
|
201
|
+
client.getClaims().catch(() => null),
|
|
202
|
+
client.getMessages().catch(() => null)
|
|
203
|
+
]);
|
|
204
|
+
if (controlRes?.ok) {
|
|
205
|
+
const ctrl = controlRes.data;
|
|
206
|
+
if (ctrl.halted) {
|
|
207
|
+
context.push(`COORDINATION HALTED${ctrl.reason ? `: ${ctrl.reason}` : ""}. Do not proceed with any coordinated work.`);
|
|
208
|
+
} else if (ctrl.paused) {
|
|
209
|
+
context.push(`Coordination paused${ctrl.reason ? `: ${ctrl.reason}` : ""}. Proceed cautiously.`);
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
try {
|
|
213
|
+
await client.requestRole(config2.role);
|
|
214
|
+
} catch {
|
|
215
|
+
}
|
|
216
|
+
if (protocolRes?.ok) {
|
|
217
|
+
const p = protocolRes.data;
|
|
218
|
+
if (p.name) {
|
|
219
|
+
context.push(`Protocol: ${p.name}${p.description ? ` \u2014 ${p.description}` : ""}`);
|
|
220
|
+
if (p.phases?.length) {
|
|
221
|
+
context.push(`Phases: ${p.phases.map((ph) => ph.name).join(" \u2192 ")}`);
|
|
222
|
+
}
|
|
223
|
+
if (p.rules?.length) {
|
|
224
|
+
context.push(`Rules:
|
|
225
|
+
${p.rules.map((r) => ` - ${r}`).join("\n")}`);
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
if (rolesRes?.ok && Array.isArray(rolesRes.data)) {
|
|
230
|
+
const roles = rolesRes.data;
|
|
231
|
+
if (roles.length > 0) {
|
|
232
|
+
context.push(`Team: ${roles.map((r) => `${r.agent} (${r.role})`).join(", ")}`);
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
if (claimsRes?.ok && Array.isArray(claimsRes.data)) {
|
|
236
|
+
const claims = claimsRes.data.filter((c) => c.status === "active");
|
|
237
|
+
if (claims.length > 0) {
|
|
238
|
+
const mine = claims.filter((c) => c.owner === config2.agentId);
|
|
239
|
+
const others = claims.filter((c) => c.owner !== config2.agentId);
|
|
240
|
+
if (mine.length > 0) {
|
|
241
|
+
context.push(`Your claims: ${mine.map((c) => c.resource).join(", ")}`);
|
|
242
|
+
}
|
|
243
|
+
if (others.length > 0) {
|
|
244
|
+
context.push(`Locked by others: ${others.map((c) => `${c.resource} (${c.owner})`).join(", ")}`);
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
if (messagesRes?.ok && Array.isArray(messagesRes.data)) {
|
|
249
|
+
const msgs = messagesRes.data.filter((m) => m.to === config2.agentId || m.to === "*");
|
|
250
|
+
if (msgs.length > 0) {
|
|
251
|
+
context.push(`Messages:
|
|
252
|
+
${msgs.map((m) => ` [${m.from}]: ${m.content}`).join("\n")}`);
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
} catch {
|
|
256
|
+
}
|
|
257
|
+
client.publishEvent("agent.session_start", {
|
|
258
|
+
agentId: config2.agentId,
|
|
259
|
+
role: config2.role
|
|
260
|
+
}).catch(() => {
|
|
261
|
+
});
|
|
262
|
+
if (context.length > 0) {
|
|
263
|
+
const output = {
|
|
264
|
+
additionalContext: `[waggle-cli] You are agent ${config2.agentId} (role: ${config2.role}) coordinating via ACP.
|
|
265
|
+
Server: ${config2.server} | Namespace: ${config2.namespace}
|
|
266
|
+
|
|
267
|
+
${context.join("\n\n")}
|
|
268
|
+
|
|
269
|
+
File edits are auto-claimed. Use wgl commands for manual coordination.`
|
|
270
|
+
};
|
|
271
|
+
console.log(JSON.stringify(output));
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
var init_session_start = __esm({
|
|
275
|
+
"src/hooks/session-start.ts"() {
|
|
276
|
+
"use strict";
|
|
277
|
+
init_dist();
|
|
278
|
+
}
|
|
279
|
+
});
|
|
280
|
+
|
|
281
|
+
// src/hooks/pre-tool-use.ts
|
|
282
|
+
var pre_tool_use_exports = {};
|
|
283
|
+
__export(pre_tool_use_exports, {
|
|
284
|
+
handlePreToolUse: () => handlePreToolUse
|
|
285
|
+
});
|
|
286
|
+
async function handlePreToolUse(config2, input2) {
|
|
287
|
+
const client = createAcpClient(config2);
|
|
288
|
+
try {
|
|
289
|
+
const controlRes = await client.getControlStatus();
|
|
290
|
+
if (controlRes.ok) {
|
|
291
|
+
const ctrl = controlRes.data;
|
|
292
|
+
if (ctrl.halted) {
|
|
293
|
+
const output = {
|
|
294
|
+
decision: "block",
|
|
295
|
+
reason: `Coordination HALTED${ctrl.reason ? `: ${ctrl.reason}` : ""}. File edits blocked.`
|
|
296
|
+
};
|
|
297
|
+
console.log(JSON.stringify(output));
|
|
298
|
+
return;
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
} catch {
|
|
302
|
+
}
|
|
303
|
+
if (!config2.autoClaimFiles) return;
|
|
304
|
+
const filePath = input2.tool_input?.file_path;
|
|
305
|
+
if (!filePath) return;
|
|
306
|
+
const resource = `file:${filePath}`;
|
|
307
|
+
try {
|
|
308
|
+
const res = await client.claim(resource, filePath);
|
|
309
|
+
if (res.ok) {
|
|
310
|
+
const result = res.data;
|
|
311
|
+
if (result.status === "rejected") {
|
|
312
|
+
const owner = result.claim?.owner || "another agent";
|
|
313
|
+
const output = {
|
|
314
|
+
decision: "block",
|
|
315
|
+
reason: `File locked by ${owner}: ${filePath}`
|
|
316
|
+
};
|
|
317
|
+
console.log(JSON.stringify(output));
|
|
318
|
+
return;
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
} catch {
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
var init_pre_tool_use = __esm({
|
|
325
|
+
"src/hooks/pre-tool-use.ts"() {
|
|
326
|
+
"use strict";
|
|
327
|
+
init_dist();
|
|
328
|
+
}
|
|
329
|
+
});
|
|
330
|
+
|
|
331
|
+
// src/hooks/post-tool-use.ts
|
|
332
|
+
var post_tool_use_exports = {};
|
|
333
|
+
__export(post_tool_use_exports, {
|
|
334
|
+
handlePostToolUse: () => handlePostToolUse
|
|
335
|
+
});
|
|
336
|
+
async function handlePostToolUse(config2, input2) {
|
|
337
|
+
const client = createAcpClient(config2);
|
|
338
|
+
const filePath = input2.tool_input?.file_path;
|
|
339
|
+
if (!filePath) return;
|
|
340
|
+
const resource = `file:${filePath}`;
|
|
341
|
+
if (config2.autoPublishDiscoveries) {
|
|
342
|
+
const toolName = input2.tool_name || "unknown";
|
|
343
|
+
client.publishDiscovery(
|
|
344
|
+
`file-change:${filePath}`,
|
|
345
|
+
`${config2.agentId} ${toolName === "Write" ? "created" : "edited"} ${filePath}`,
|
|
346
|
+
"file-change"
|
|
347
|
+
).catch(() => {
|
|
348
|
+
});
|
|
349
|
+
}
|
|
350
|
+
client.reportProgress(resource, 0, `${input2.tool_name || "edit"} completed`).catch(() => {
|
|
351
|
+
});
|
|
352
|
+
}
|
|
353
|
+
var init_post_tool_use = __esm({
|
|
354
|
+
"src/hooks/post-tool-use.ts"() {
|
|
355
|
+
"use strict";
|
|
356
|
+
init_dist();
|
|
357
|
+
}
|
|
358
|
+
});
|
|
359
|
+
|
|
360
|
+
// src/hooks/stop.ts
|
|
361
|
+
var stop_exports = {};
|
|
362
|
+
__export(stop_exports, {
|
|
363
|
+
handleStop: () => handleStop
|
|
364
|
+
});
|
|
365
|
+
async function handleStop(config2, _input) {
|
|
366
|
+
const client = createAcpClient(config2);
|
|
367
|
+
try {
|
|
368
|
+
const [messagesRes, helpRes, claimsRes] = await Promise.all([
|
|
369
|
+
client.getMessages().catch(() => null),
|
|
370
|
+
client.getHelp().catch(() => null),
|
|
371
|
+
client.getClaims().catch(() => null)
|
|
372
|
+
]);
|
|
373
|
+
const blockers = [];
|
|
374
|
+
if (messagesRes?.ok && Array.isArray(messagesRes.data)) {
|
|
375
|
+
const unread = messagesRes.data.filter(
|
|
376
|
+
(m) => m.to === config2.agentId || m.to === "*"
|
|
377
|
+
);
|
|
378
|
+
if (unread.length > 0) {
|
|
379
|
+
blockers.push(`${unread.length} unread message(s) \u2014 check with \`wgl status\``);
|
|
380
|
+
}
|
|
381
|
+
}
|
|
382
|
+
if (helpRes?.ok && Array.isArray(helpRes.data)) {
|
|
383
|
+
const openHelp = helpRes.data.filter((h) => h.status === "open");
|
|
384
|
+
if (openHelp.length > 0) {
|
|
385
|
+
blockers.push(`${openHelp.length} open help request(s) need attention`);
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
if (claimsRes?.ok && Array.isArray(claimsRes.data)) {
|
|
389
|
+
const mine = claimsRes.data.filter(
|
|
390
|
+
(c) => c.owner === config2.agentId && c.status === "active"
|
|
391
|
+
);
|
|
392
|
+
for (const claim of mine) {
|
|
393
|
+
client.releaseClaim(claim.resource).catch(() => {
|
|
394
|
+
});
|
|
395
|
+
}
|
|
396
|
+
}
|
|
397
|
+
if (blockers.length > 0) {
|
|
398
|
+
const output = {
|
|
399
|
+
decision: "block",
|
|
400
|
+
reason: `Cannot stop \u2014 coordination items pending:
|
|
401
|
+
${blockers.map((b) => ` \u2022 ${b}`).join("\n")}`
|
|
402
|
+
};
|
|
403
|
+
console.log(JSON.stringify(output));
|
|
404
|
+
return;
|
|
405
|
+
}
|
|
406
|
+
} catch {
|
|
407
|
+
}
|
|
408
|
+
client.publishEvent("agent.session_complete", {
|
|
409
|
+
agentId: config2.agentId,
|
|
410
|
+
role: config2.role
|
|
411
|
+
}).catch(() => {
|
|
412
|
+
});
|
|
413
|
+
}
|
|
414
|
+
var init_stop = __esm({
|
|
415
|
+
"src/hooks/stop.ts"() {
|
|
416
|
+
"use strict";
|
|
417
|
+
init_dist();
|
|
418
|
+
}
|
|
419
|
+
});
|
|
420
|
+
|
|
421
|
+
// src/hooks/prompt-submit.ts
|
|
422
|
+
var prompt_submit_exports = {};
|
|
423
|
+
__export(prompt_submit_exports, {
|
|
424
|
+
handlePromptSubmit: () => handlePromptSubmit
|
|
425
|
+
});
|
|
426
|
+
import { writeFileSync } from "node:fs";
|
|
427
|
+
async function handlePromptSubmit(config2, configPath2, _input) {
|
|
428
|
+
const client = createAcpClient(config2);
|
|
429
|
+
const context = [];
|
|
430
|
+
try {
|
|
431
|
+
const [controlRes, eventsRes] = await Promise.all([
|
|
432
|
+
client.getControlStatus().catch(() => null),
|
|
433
|
+
client.getEvents(config2.lastEventCursor).catch(() => null)
|
|
434
|
+
]);
|
|
435
|
+
if (controlRes?.ok) {
|
|
436
|
+
const ctrl = controlRes.data;
|
|
437
|
+
if (ctrl.halted) {
|
|
438
|
+
context.push(`COORDINATION HALTED${ctrl.reason ? `: ${ctrl.reason}` : ""}. Do not proceed with coordinated work.`);
|
|
439
|
+
} else if (ctrl.paused) {
|
|
440
|
+
context.push(`Coordination paused${ctrl.reason ? `: ${ctrl.reason}` : ""}.`);
|
|
441
|
+
}
|
|
442
|
+
}
|
|
443
|
+
if (eventsRes?.ok && Array.isArray(eventsRes.data)) {
|
|
444
|
+
const events = eventsRes.data;
|
|
445
|
+
if (events.length > 0) {
|
|
446
|
+
const maxId = Math.max(...events.map((e) => e.id));
|
|
447
|
+
config2.lastEventCursor = maxId;
|
|
448
|
+
try {
|
|
449
|
+
writeFileSync(configPath2, JSON.stringify(config2, null, 2) + "\n");
|
|
450
|
+
} catch {
|
|
451
|
+
}
|
|
452
|
+
const byType = {};
|
|
453
|
+
for (const ev of events) {
|
|
454
|
+
byType[ev.type] = (byType[ev.type] || 0) + 1;
|
|
455
|
+
}
|
|
456
|
+
const summary = Object.entries(byType).map(([type, count]) => `${type} (${count})`).join(", ");
|
|
457
|
+
context.push(`New events since last prompt: ${summary}`);
|
|
458
|
+
const important = events.filter(
|
|
459
|
+
(e) => e.type.startsWith("agent.") || e.type.startsWith("control.") || e.type.startsWith("conflict.")
|
|
460
|
+
);
|
|
461
|
+
if (important.length > 0) {
|
|
462
|
+
for (const ev of important.slice(-5)) {
|
|
463
|
+
context.push(` [${ev.type}] ${JSON.stringify(ev.data)}`);
|
|
464
|
+
}
|
|
465
|
+
}
|
|
466
|
+
}
|
|
467
|
+
}
|
|
468
|
+
} catch {
|
|
469
|
+
}
|
|
470
|
+
if (context.length > 0) {
|
|
471
|
+
console.log(`[waggle-cli] ${context.join("\n")}`);
|
|
472
|
+
}
|
|
473
|
+
}
|
|
474
|
+
var init_prompt_submit = __esm({
|
|
475
|
+
"src/hooks/prompt-submit.ts"() {
|
|
476
|
+
"use strict";
|
|
477
|
+
init_dist();
|
|
478
|
+
}
|
|
479
|
+
});
|
|
480
|
+
|
|
481
|
+
// src/hook.ts
|
|
482
|
+
import { readFileSync as readFileSync2 } from "node:fs";
|
|
483
|
+
var hookName = process.argv[2];
|
|
484
|
+
var configPath = process.argv[3];
|
|
485
|
+
if (!hookName || !configPath) process.exit(0);
|
|
486
|
+
var config;
|
|
487
|
+
try {
|
|
488
|
+
config = JSON.parse(readFileSync2(configPath, "utf8"));
|
|
489
|
+
} catch {
|
|
490
|
+
process.exit(0);
|
|
491
|
+
}
|
|
492
|
+
var input;
|
|
493
|
+
try {
|
|
494
|
+
const raw = readFileSync2(0, "utf8");
|
|
495
|
+
input = raw ? JSON.parse(raw) : {};
|
|
496
|
+
} catch {
|
|
497
|
+
input = {};
|
|
498
|
+
}
|
|
499
|
+
async function run() {
|
|
500
|
+
switch (hookName) {
|
|
501
|
+
case "session-start": {
|
|
502
|
+
const { handleSessionStart: handleSessionStart2 } = await Promise.resolve().then(() => (init_session_start(), session_start_exports));
|
|
503
|
+
await handleSessionStart2(config, configPath, input);
|
|
504
|
+
break;
|
|
505
|
+
}
|
|
506
|
+
case "pre-tool-use": {
|
|
507
|
+
const { handlePreToolUse: handlePreToolUse2 } = await Promise.resolve().then(() => (init_pre_tool_use(), pre_tool_use_exports));
|
|
508
|
+
await handlePreToolUse2(config, input);
|
|
509
|
+
break;
|
|
510
|
+
}
|
|
511
|
+
case "post-tool-use": {
|
|
512
|
+
const { handlePostToolUse: handlePostToolUse2 } = await Promise.resolve().then(() => (init_post_tool_use(), post_tool_use_exports));
|
|
513
|
+
await handlePostToolUse2(config, input);
|
|
514
|
+
break;
|
|
515
|
+
}
|
|
516
|
+
case "stop": {
|
|
517
|
+
const { handleStop: handleStop2 } = await Promise.resolve().then(() => (init_stop(), stop_exports));
|
|
518
|
+
await handleStop2(config, input);
|
|
519
|
+
break;
|
|
520
|
+
}
|
|
521
|
+
case "prompt-submit": {
|
|
522
|
+
const { handlePromptSubmit: handlePromptSubmit2 } = await Promise.resolve().then(() => (init_prompt_submit(), prompt_submit_exports));
|
|
523
|
+
await handlePromptSubmit2(config, configPath, input);
|
|
524
|
+
break;
|
|
525
|
+
}
|
|
526
|
+
default:
|
|
527
|
+
process.exit(0);
|
|
528
|
+
}
|
|
529
|
+
}
|
|
530
|
+
run().catch(() => process.exit(0));
|
|
531
|
+
//# sourceMappingURL=hook.js.map
|