@wheatley-ai/cli 0.3.0 → 0.4.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/cli/ask.js +8 -4
- package/dist/cli/chat.js +8 -4
- package/dist/cli/daemon.js +45 -0
- package/dist/cli/io.js +1 -0
- package/dist/cli/main.js +145 -163
- package/dist/cli/session.js +59 -3
- package/dist/cli/status.js +4 -4
- package/dist/cli/tui/app.js +14 -2
- package/dist/cli/tui/controller.js +80 -19
- package/dist/cli/tui/markdown.js +229 -104
- package/dist/cli/tui/model-picker.js +76 -0
- package/dist/cli/tui/picker-panel.js +39 -0
- package/dist/core/agent/agent.js +23 -12
- package/dist/core/config/config-store.js +11 -6
- package/dist/core/config/diagnostics.js +116 -0
- package/dist/core/config/secret-store.js +13 -9
- package/dist/core/deployment.js +19 -1
- package/dist/core/markdown-tokens.js +60 -0
- package/dist/core/model-catalog.js +54 -0
- package/dist/core/rpc/deployment-handlers.js +2 -1
- package/dist/core/server/control-server.js +19 -21
- package/dist/core/server/http-server.js +17 -0
- package/dist/core/server/static-files.js +40 -66
- package/dist/dashboard/assets/index-DGa2Ps9u.js +12 -0
- package/dist/dashboard/assets/index-DeERxJOJ.css +2 -0
- package/dist/dashboard/assets/{sheet-presentation-CkgiDsTg.js → sheet-presentation-CZ1dO2kr.js} +1 -1
- package/dist/dashboard/index.html +2 -2
- package/dist/frontends/discord/approvals.js +8 -43
- package/dist/frontends/discord/binding.js +81 -8
- package/dist/frontends/discord/json-file.js +57 -0
- package/dist/frontends/discord/model-picker.js +276 -0
- package/dist/frontends/slack/binding.js +33 -3
- package/dist/frontends/slack/inbound.js +21 -12
- package/dist/frontends/slack/model-picker-blocks.js +147 -0
- package/dist/frontends/slack/outbound.js +27 -2
- package/dist/frontends/slack/schemas.js +9 -2
- package/dist/frontends/telegram/approvals.js +13 -48
- package/dist/frontends/telegram/binding.js +5 -0
- package/dist/frontends/telegram/client.js +7 -0
- package/dist/frontends/telegram/delivery.js +19 -6
- package/dist/frontends/telegram/inbound.js +64 -8
- package/dist/frontends/telegram/markdown.js +120 -83
- package/dist/frontends/telegram/model-picker.js +160 -0
- package/dist/frontends/telegram/token-store.js +73 -0
- package/dist/node_modules/@wheatley-ai/protocol/dist/domain.d.ts +13 -0
- package/dist/node_modules/@wheatley-ai/protocol/dist/domain.js +11 -0
- package/dist/node_modules/@wheatley-ai/protocol/dist/index.d.ts +1 -1
- package/dist/node_modules/@wheatley-ai/protocol/dist/index.js +1 -1
- package/dist/node_modules/@wheatley-ai/protocol/dist/methods.d.ts +20 -0
- package/dist/node_modules/@wheatley-ai/protocol/dist/methods.js +9 -1
- package/dist/node_modules/@wheatley-ai/sdk/dist/commands.d.ts +2 -2
- package/dist/node_modules/@wheatley-ai/sdk/dist/commands.js +2 -2
- package/dist/node_modules/@wheatley-ai/sdk/dist/frontend.d.ts +23 -0
- package/dist/node_modules/@wheatley-ai/sdk/dist/index.d.ts +1 -1
- package/dist/node_modules/@wheatley-ai/sdk/package.json +1 -1
- package/dist/ops/cli.js +92 -98
- package/dist/ops/service.js +6 -1
- package/dist/ops/update.js +14 -27
- package/dist/triggers/delivery-codec.js +13 -0
- package/dist/triggers/webhook-ingress.js +89 -82
- package/package.json +9 -2
- package/dist/dashboard/assets/index-C9Rul5vE.css +0 -2
- package/dist/dashboard/assets/index-DThc2x_d.js +0 -11
|
@@ -1,79 +1,53 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { existsSync } from "node:fs";
|
|
2
2
|
import path from "node:path";
|
|
3
|
+
import { serveStatic } from "@hono/node-server/serve-static";
|
|
3
4
|
/** The dashboard entry file. Paths without a file extension fall back to it, so the SPA can route itself. */
|
|
4
5
|
const INDEX_FILE = "index.html";
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
[".map", "application/json; charset=utf-8"],
|
|
12
|
-
[".png", "image/png"],
|
|
13
|
-
[".svg", "image/svg+xml"],
|
|
14
|
-
[".txt", "text/plain; charset=utf-8"],
|
|
15
|
-
[".webp", "image/webp"],
|
|
16
|
-
[".woff", "font/woff"],
|
|
17
|
-
[".woff2", "font/woff2"],
|
|
18
|
-
]);
|
|
19
|
-
const contentTypeOf = (file) => CONTENT_TYPES.get(path.extname(file).toLowerCase()) ??
|
|
20
|
-
"application/octet-stream";
|
|
21
|
-
const isFile = async (file) => {
|
|
22
|
-
try {
|
|
23
|
-
const info = await stat(file);
|
|
24
|
-
return info.isFile();
|
|
25
|
-
}
|
|
26
|
-
catch {
|
|
27
|
-
return false;
|
|
28
|
-
}
|
|
6
|
+
/** A Hono path pattern for every path whose last segment has no file extension, such as `/agents/foo/chat`. */
|
|
7
|
+
const SPA_ROUTE = "/:route{(?:[^/]+/)*[^/.]*}";
|
|
8
|
+
/** The file that `serveStatic` found for a request. */
|
|
9
|
+
const servedFiles = new WeakMap();
|
|
10
|
+
const recordFile = (file, c) => {
|
|
11
|
+
servedFiles.set(c, file);
|
|
29
12
|
};
|
|
30
13
|
/**
|
|
31
|
-
*
|
|
32
|
-
*
|
|
14
|
+
* Adds the cache and `nosniff` headers to a file response of `serve`. `serveStatic` builds its response before it
|
|
15
|
+
* calls `onFound`, so headers that `onFound` sets do not reach the response.
|
|
33
16
|
*/
|
|
34
|
-
const
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
17
|
+
const withHeaders = (serve) => async (c, next) => {
|
|
18
|
+
const response = await serve(c, next);
|
|
19
|
+
const file = servedFiles.get(c);
|
|
20
|
+
if (response instanceof Response && file !== undefined) {
|
|
21
|
+
response.headers.set("cache-control", path.basename(file) === INDEX_FILE ? "no-cache" : "max-age=3600");
|
|
22
|
+
response.headers.set("x-content-type-options", "nosniff");
|
|
23
|
+
}
|
|
24
|
+
return response;
|
|
25
|
+
};
|
|
26
|
+
const passOn = async (_c, proceed) => {
|
|
27
|
+
await proceed();
|
|
28
|
+
};
|
|
29
|
+
/**
|
|
30
|
+
* Runs the handler that `create` builds while `root` exists, and passes the request on while it does not. It checks on
|
|
31
|
+
* each request, so a dashboard built after the daemon starts is served without a restart. `serveStatic` logs an error
|
|
32
|
+
* for a missing root when it is built, so `create` runs on the first request that finds the folder.
|
|
33
|
+
*/
|
|
34
|
+
const whileRootExists = (root, create) => {
|
|
35
|
+
let created;
|
|
36
|
+
return async (c, next) => {
|
|
37
|
+
const handler = existsSync(root) ? (created ??= create()) : passOn;
|
|
38
|
+
return await handler(c, next);
|
|
39
|
+
};
|
|
53
40
|
};
|
|
54
41
|
/**
|
|
55
|
-
* Serves `GET` and `HEAD` requests from the bundled dashboard folder
|
|
56
|
-
*
|
|
42
|
+
* Serves `GET` and `HEAD` requests from the bundled dashboard folder on `app`. A path without a file extension that
|
|
43
|
+
* matches no file serves the SPA entry. Requests that match no file fall through to the next handler, and so do all
|
|
44
|
+
* requests while the folder is missing, for example in a source checkout without a built dashboard.
|
|
57
45
|
*
|
|
58
46
|
* The dashboard is static and holds no data. It reads everything over `/ws`, where the Control Server checks the
|
|
59
47
|
* browser `Origin`.
|
|
60
48
|
*/
|
|
61
|
-
export const
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
}
|
|
65
|
-
const { pathname } = new URL(request.url ?? "/", "http://localhost");
|
|
66
|
-
const file = await resolveFile(path.resolve(root), pathname);
|
|
67
|
-
if (file === undefined) {
|
|
68
|
-
return false;
|
|
69
|
-
}
|
|
70
|
-
const body = await readFile(file);
|
|
71
|
-
response.writeHead(200, {
|
|
72
|
-
"cache-control": path.basename(file) === INDEX_FILE ? "no-cache" : "max-age=3600",
|
|
73
|
-
"content-length": body.byteLength,
|
|
74
|
-
"content-type": contentTypeOf(file),
|
|
75
|
-
"x-content-type-options": "nosniff",
|
|
76
|
-
});
|
|
77
|
-
response.end(request.method === "HEAD" ? undefined : body);
|
|
78
|
-
return true;
|
|
49
|
+
export const mountStaticFiles = (app, root) => {
|
|
50
|
+
const absolute = path.resolve(root);
|
|
51
|
+
app.get("*", whileRootExists(absolute, () => withHeaders(serveStatic({ onFound: recordFile, root: absolute }))));
|
|
52
|
+
app.get(SPA_ROUTE, whileRootExists(absolute, () => withHeaders(serveStatic({ onFound: recordFile, path: INDEX_FILE, root: absolute }))));
|
|
79
53
|
};
|