@wheatley-ai/cli 0.0.0-stage → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +15 -0
- package/bin/wheatley.js +2 -0
- package/dist/approvals/gate.js +278 -0
- package/dist/approvals/module.js +21 -0
- package/dist/approvals/policy.js +30 -0
- package/dist/approvals/preview.js +17 -0
- package/dist/approvals/prompt.js +98 -0
- package/dist/approvals/rpc.js +16 -0
- package/dist/approvals/store.js +159 -0
- package/dist/cli/ask.js +94 -0
- package/dist/cli/chat.js +178 -0
- package/dist/cli/client.js +104 -0
- package/dist/cli/daemon.js +35 -0
- package/dist/cli/init.js +72 -0
- package/dist/cli/io.js +45 -0
- package/dist/cli/main.js +206 -0
- package/dist/cli/session.js +86 -0
- package/dist/cli/status.js +46 -0
- package/dist/contracts/approval-gate.js +1 -0
- package/dist/contracts/config-store.js +1 -0
- package/dist/contracts/delivery-outbox.js +1 -0
- package/dist/contracts/errors.js +28 -0
- package/dist/contracts/extension-catalog.js +1 -0
- package/dist/contracts/maintenance-runner.js +1 -0
- package/dist/contracts/memory-store.js +1 -0
- package/dist/contracts/module.js +7 -0
- package/dist/contracts/tool-names.js +43 -0
- package/dist/contracts/trigger-runtime.js +1 -0
- package/dist/contracts/webhook-ingress.js +2 -0
- package/dist/core/agent/agent-store.js +300 -0
- package/dist/core/agent/agent.js +1033 -0
- package/dist/core/agent/gated-models.js +89 -0
- package/dist/core/agent/pi-adapter.js +401 -0
- package/dist/core/agent/policy-gate.js +44 -0
- package/dist/core/builtin-catalog.js +20 -0
- package/dist/core/concurrency-gate.js +87 -0
- package/dist/core/config/atomic-file.js +72 -0
- package/dist/core/config/config-store.js +138 -0
- package/dist/core/config/pending-restart.js +53 -0
- package/dist/core/config/secret-references.js +69 -0
- package/dist/core/config/secret-store.js +147 -0
- package/dist/core/config/validate.js +55 -0
- package/dist/core/config/yaml-patch.js +57 -0
- package/dist/core/daemon-socket.js +96 -0
- package/dist/core/daemon.js +97 -0
- package/dist/core/deployment.js +379 -0
- package/dist/core/error-message.js +4 -0
- package/dist/core/events.js +25 -0
- package/dist/core/logger.js +81 -0
- package/dist/core/models.js +27 -0
- package/dist/core/module.js +42 -0
- package/dist/core/rpc/agent-handlers.js +82 -0
- package/dist/core/rpc/deployment-handlers.js +63 -0
- package/dist/core/rpc/router.js +96 -0
- package/dist/core/server/connection.js +170 -0
- package/dist/core/server/control-server.js +152 -0
- package/dist/core/server/static-files.js +79 -0
- package/dist/core/supervisor.js +215 -0
- package/dist/core/tool-routing.js +41 -0
- package/dist/dashboard/assets/index-C9Rul5vE.css +2 -0
- package/dist/dashboard/assets/index-DXzGGAxQ.js +11 -0
- package/dist/dashboard/assets/sheet-presentation-DMljN0LW.js +1 -0
- package/dist/dashboard/index.html +18 -0
- package/dist/db/database.js +16 -0
- package/dist/db/migrations.js +184 -0
- package/dist/frontends/discord/approvals.js +199 -0
- package/dist/frontends/discord/attachments.js +115 -0
- package/dist/frontends/discord/binding.js +489 -0
- package/dist/frontends/discord/config.js +107 -0
- package/dist/frontends/discord/discord-runtime.js +52 -0
- package/dist/frontends/discord/errors.js +61 -0
- package/dist/frontends/discord/live-runs.js +189 -0
- package/dist/frontends/discord/module.js +39 -0
- package/dist/frontends/discord/recent-ids.js +20 -0
- package/dist/frontends/slack/approval-blocks.js +98 -0
- package/dist/frontends/slack/attachments.js +102 -0
- package/dist/frontends/slack/background-tasks.js +20 -0
- package/dist/frontends/slack/binding.js +405 -0
- package/dist/frontends/slack/bounded.js +9 -0
- package/dist/frontends/slack/chat-id.js +17 -0
- package/dist/frontends/slack/config.js +80 -0
- package/dist/frontends/slack/delivery-errors.js +81 -0
- package/dist/frontends/slack/inbound.js +76 -0
- package/dist/frontends/slack/live-progress.js +190 -0
- package/dist/frontends/slack/manifest.js +66 -0
- package/dist/frontends/slack/outbound.js +160 -0
- package/dist/frontends/slack/schemas.js +99 -0
- package/dist/frontends/slack/signature.js +30 -0
- package/dist/frontends/slack/slack-client.js +60 -0
- package/dist/frontends/slack/slack-frontend.js +38 -0
- package/dist/frontends/slack/state-store.js +112 -0
- package/dist/frontends/telegram/approvals.js +134 -0
- package/dist/frontends/telegram/attachments.js +126 -0
- package/dist/frontends/telegram/binding.js +144 -0
- package/dist/frontends/telegram/chat-key.js +43 -0
- package/dist/frontends/telegram/client.js +88 -0
- package/dist/frontends/telegram/config.js +93 -0
- package/dist/frontends/telegram/delivery.js +215 -0
- package/dist/frontends/telegram/frontend.js +42 -0
- package/dist/frontends/telegram/grammy-client.js +122 -0
- package/dist/frontends/telegram/http-status.js +6 -0
- package/dist/frontends/telegram/inbound.js +149 -0
- package/dist/frontends/telegram/live.js +182 -0
- package/dist/frontends/telegram/markdown.js +103 -0
- package/dist/frontends/telegram/recent-set.js +18 -0
- package/dist/frontends/telegram/serial-queue.js +23 -0
- package/dist/index.js +7 -0
- package/dist/mcp/content.js +61 -0
- package/dist/mcp/mcp-module.js +35 -0
- package/dist/mcp/mcp-tool-provider.js +93 -0
- package/dist/mcp/server-connection.js +297 -0
- package/dist/memory/consolidation.js +260 -0
- package/dist/memory/format.js +5 -0
- package/dist/memory/migrations.js +76 -0
- package/dist/memory/module.js +69 -0
- package/dist/memory/names.js +20 -0
- package/dist/memory/rows.js +22 -0
- package/dist/memory/rpc.js +49 -0
- package/dist/memory/snapshots.js +12 -0
- package/dist/memory/store.js +281 -0
- package/dist/memory/tools.js +158 -0
- package/dist/node_modules/@wheatley-ai/protocol/dist/config.d.ts +262 -0
- package/dist/node_modules/@wheatley-ai/protocol/dist/config.js +120 -0
- package/dist/node_modules/@wheatley-ai/protocol/dist/domain.d.ts +512 -0
- package/dist/node_modules/@wheatley-ai/protocol/dist/domain.js +441 -0
- package/dist/node_modules/@wheatley-ai/protocol/dist/duration.d.ts +8 -0
- package/dist/node_modules/@wheatley-ai/protocol/dist/duration.js +28 -0
- package/dist/node_modules/@wheatley-ai/protocol/dist/events.d.ts +234 -0
- package/dist/node_modules/@wheatley-ai/protocol/dist/events.js +124 -0
- package/dist/node_modules/@wheatley-ai/protocol/dist/index.d.ts +11 -0
- package/dist/node_modules/@wheatley-ai/protocol/dist/index.js +11 -0
- package/dist/node_modules/@wheatley-ai/protocol/dist/json-rpc.d.ts +81 -0
- package/dist/node_modules/@wheatley-ai/protocol/dist/json-rpc.js +157 -0
- package/dist/node_modules/@wheatley-ai/protocol/dist/json.d.ts +14 -0
- package/dist/node_modules/@wheatley-ai/protocol/dist/json.js +23 -0
- package/dist/node_modules/@wheatley-ai/protocol/dist/limits.d.ts +17 -0
- package/dist/node_modules/@wheatley-ai/protocol/dist/limits.js +17 -0
- package/dist/node_modules/@wheatley-ai/protocol/dist/methods.d.ts +1107 -0
- package/dist/node_modules/@wheatley-ai/protocol/dist/methods.js +201 -0
- package/dist/node_modules/@wheatley-ai/protocol/dist/rpc-error.d.ts +45 -0
- package/dist/node_modules/@wheatley-ai/protocol/dist/rpc-error.js +44 -0
- package/dist/node_modules/@wheatley-ai/protocol/dist/validation.d.ts +20 -0
- package/dist/node_modules/@wheatley-ai/protocol/dist/validation.js +11 -0
- package/dist/node_modules/@wheatley-ai/protocol/package.json +14 -0
- package/dist/node_modules/@wheatley-ai/sdk/dist/chunk.d.ts +11 -0
- package/dist/node_modules/@wheatley-ai/sdk/dist/chunk.js +162 -0
- package/dist/node_modules/@wheatley-ai/sdk/dist/commands.d.ts +48 -0
- package/dist/node_modules/@wheatley-ai/sdk/dist/commands.js +39 -0
- package/dist/node_modules/@wheatley-ai/sdk/dist/delivery-error.d.ts +29 -0
- package/dist/node_modules/@wheatley-ai/sdk/dist/delivery-error.js +27 -0
- package/dist/node_modules/@wheatley-ai/sdk/dist/frontend.d.ts +236 -0
- package/dist/node_modules/@wheatley-ai/sdk/dist/frontend.js +2 -0
- package/dist/node_modules/@wheatley-ai/sdk/dist/index.d.ts +10 -0
- package/dist/node_modules/@wheatley-ai/sdk/dist/index.js +7 -0
- package/dist/node_modules/@wheatley-ai/sdk/dist/json.d.ts +9 -0
- package/dist/node_modules/@wheatley-ai/sdk/dist/json.js +2 -0
- package/dist/node_modules/@wheatley-ai/sdk/dist/logger.d.ts +18 -0
- package/dist/node_modules/@wheatley-ai/sdk/dist/logger.js +2 -0
- package/dist/node_modules/@wheatley-ai/sdk/dist/plugin.d.ts +48 -0
- package/dist/node_modules/@wheatley-ai/sdk/dist/plugin.js +5 -0
- package/dist/node_modules/@wheatley-ai/sdk/dist/schema.d.ts +69 -0
- package/dist/node_modules/@wheatley-ai/sdk/dist/schema.js +3 -0
- package/dist/node_modules/@wheatley-ai/sdk/dist/tool.d.ts +69 -0
- package/dist/node_modules/@wheatley-ai/sdk/dist/tool.js +3 -0
- package/dist/node_modules/@wheatley-ai/sdk/package.json +11 -0
- package/dist/ops/backup.js +185 -0
- package/dist/ops/cli.js +194 -0
- package/dist/ops/command-runner.js +34 -0
- package/dist/ops/dashboard-assets.js +37 -0
- package/dist/ops/migrate.js +63 -0
- package/dist/ops/module.js +47 -0
- package/dist/ops/paths.js +55 -0
- package/dist/ops/service.js +376 -0
- package/dist/ops/update.js +145 -0
- package/dist/plugins/contributions.js +89 -0
- package/dist/plugins/guards.js +111 -0
- package/dist/plugins/load.js +76 -0
- package/dist/plugins/module.js +31 -0
- package/dist/plugins/provider.js +349 -0
- package/dist/plugins/schema.js +69 -0
- package/dist/skills/disclosure.js +142 -0
- package/dist/skills/discovery.js +120 -0
- package/dist/skills/fs-errors.js +8 -0
- package/dist/skills/read-skill-tool.js +3 -0
- package/dist/skills/skill-file.js +90 -0
- package/dist/skills/skills.js +140 -0
- package/dist/tools/builtin-tools.js +61 -0
- package/dist/tools/input.js +45 -0
- package/dist/tools/paths.js +6 -0
- package/dist/tools/read-file.js +65 -0
- package/dist/tools/shell.js +156 -0
- package/dist/tools/write-file.js +58 -0
- package/dist/triggers/delivery-codec.js +99 -0
- package/dist/triggers/delivery-outbox.js +313 -0
- package/dist/triggers/due-timer.js +14 -0
- package/dist/triggers/errors.js +2 -0
- package/dist/triggers/migrations.js +91 -0
- package/dist/triggers/module.js +106 -0
- package/dist/triggers/rpc.js +35 -0
- package/dist/triggers/schedule.js +52 -0
- package/dist/triggers/sql-row.js +59 -0
- package/dist/triggers/trigger-runtime.js +445 -0
- package/dist/triggers/trigger-tools.js +210 -0
- package/dist/triggers/webhook-ingress.js +212 -0
- package/dist/wiring/agent-services.js +151 -0
- package/dist/wiring/catalog.js +81 -0
- package/dist/wiring/daemon.js +83 -0
- package/dist/wiring/frontend-host.js +268 -0
- package/package.json +50 -3
- package/README.md +0 -3
|
@@ -0,0 +1,268 @@
|
|
|
1
|
+
import { mkdir } from "node:fs/promises";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { isJsonValue } from "@wheatley-ai/protocol";
|
|
4
|
+
import { BUILTIN_COMMANDS, DeliveryError } from "@wheatley-ai/sdk";
|
|
5
|
+
import { CLI_BINDING_ID } from "../core/config/validate.js";
|
|
6
|
+
import { errorMessage } from "../core/error-message.js";
|
|
7
|
+
import { compileSchema } from "../plugins/schema.js";
|
|
8
|
+
/** The per-file attachment limit of every binding: 10 MiB (SDK `FrontendContext.maxAttachmentBytes`). */
|
|
9
|
+
export const DEFAULT_MAX_ATTACHMENT_BYTES = 10 * 1024 * 1024;
|
|
10
|
+
/** The folder inside the Agent folder that holds one data folder per Frontend Binding. */
|
|
11
|
+
export const FRONTENDS_DIR = "frontends";
|
|
12
|
+
/** The folder inside the Agent folder for staged attachments of every binding. */
|
|
13
|
+
export const STAGING_DIR = "staging";
|
|
14
|
+
const attachmentNote = (attachment) => attachment.kind === "file"
|
|
15
|
+
? `[Attachment: ${attachment.filename} (${attachment.mimeType}, ${attachment.sizeBytes} bytes) at ${attachment.path}]`
|
|
16
|
+
: `[Attachment: ${attachment.filename} (${attachment.mimeType}), not stored]`;
|
|
17
|
+
/** The Agent takes text only, so staged attachments reach the model as notes with their file paths. */
|
|
18
|
+
const inboundText = (text, attachments) => [text, ...(attachments ?? []).map(attachmentNote)]
|
|
19
|
+
.filter((part) => part !== "")
|
|
20
|
+
.join("\n");
|
|
21
|
+
const failedStatus = (config, error) => ({
|
|
22
|
+
error,
|
|
23
|
+
id: config.id,
|
|
24
|
+
state: "failed",
|
|
25
|
+
type: config.type,
|
|
26
|
+
});
|
|
27
|
+
/** The Run ID of a Run event payload, or `undefined` for any other event. */
|
|
28
|
+
const runIdOf = (payload) => {
|
|
29
|
+
if ("runId" in payload) {
|
|
30
|
+
return payload.runId;
|
|
31
|
+
}
|
|
32
|
+
return "run" in payload ? payload.run.runId : undefined;
|
|
33
|
+
};
|
|
34
|
+
/** Maps a Deployment event of a tracked Run to the binding's ephemeral `RunEvent`. */
|
|
35
|
+
const runEventOf = (name, payload, runId, chatId) => {
|
|
36
|
+
if (name === "run.delta" && "delta" in payload) {
|
|
37
|
+
return { chatId, delta: payload.delta, kind: "text_delta", runId };
|
|
38
|
+
}
|
|
39
|
+
if (name === "run.toolStarted" && "toolCallId" in payload) {
|
|
40
|
+
return {
|
|
41
|
+
chatId,
|
|
42
|
+
kind: "tool_started",
|
|
43
|
+
runId,
|
|
44
|
+
toolCallId: payload.toolCallId,
|
|
45
|
+
toolName: payload.toolName,
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
if (name === "run.toolFinished" &&
|
|
49
|
+
"toolCallId" in payload &&
|
|
50
|
+
"isError" in payload) {
|
|
51
|
+
return {
|
|
52
|
+
chatId,
|
|
53
|
+
isError: payload.isError,
|
|
54
|
+
kind: "tool_finished",
|
|
55
|
+
runId,
|
|
56
|
+
toolCallId: payload.toolCallId,
|
|
57
|
+
toolName: payload.toolName,
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
if (name === "run.finished" && "run" in payload) {
|
|
61
|
+
const { status } = payload.run;
|
|
62
|
+
return status === "completed" || status === "failed" || status === "stopped"
|
|
63
|
+
? { chatId, kind: "run_finished", runId, status }
|
|
64
|
+
: undefined;
|
|
65
|
+
}
|
|
66
|
+
return undefined;
|
|
67
|
+
};
|
|
68
|
+
/**
|
|
69
|
+
* Creates the Frontend Binding host of one Agent (ADR 0007, ADR 0012). For each enabled `frontends` entry, it validates
|
|
70
|
+
* the config against the Frontend's `configSchema`, creates the binding with a `FrontendContext`, and starts it with a
|
|
71
|
+
* sink that hands messages, commands, and Approval decisions to the Agent.
|
|
72
|
+
*/
|
|
73
|
+
export const createFrontendHost = (options) => {
|
|
74
|
+
const bindings = new Map((options.config.frontends ?? [])
|
|
75
|
+
.filter((config) => config.enabled !== false)
|
|
76
|
+
.map((config) => [
|
|
77
|
+
config.id,
|
|
78
|
+
{
|
|
79
|
+
binding: undefined,
|
|
80
|
+
config,
|
|
81
|
+
routes: [],
|
|
82
|
+
status: { id: config.id, state: "starting", type: config.type },
|
|
83
|
+
},
|
|
84
|
+
]));
|
|
85
|
+
/** Run ID to the Chat of a Run that started from a binding of this Agent. */
|
|
86
|
+
const runChats = new Map();
|
|
87
|
+
let stopped = false;
|
|
88
|
+
const deliver = async (bindingId, delivery) => {
|
|
89
|
+
// The CLI and the dashboard read Approvals and replies from live events, so CLI deliveries need no transport.
|
|
90
|
+
if (bindingId === CLI_BINDING_ID) {
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
const hosted = bindings.get(bindingId);
|
|
94
|
+
if (hosted === undefined) {
|
|
95
|
+
throw new DeliveryError(`Unknown Frontend Binding: ${bindingId}`, {
|
|
96
|
+
kind: "permanent",
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
if (hosted.binding === undefined || hosted.status.state !== "ready") {
|
|
100
|
+
throw new DeliveryError(`Frontend Binding ${bindingId} is ${hosted.status.state}`, { kind: hosted.status.state === "failed" ? "permanent" : "retryable" });
|
|
101
|
+
}
|
|
102
|
+
await hosted.binding.deliver(delivery);
|
|
103
|
+
};
|
|
104
|
+
const forward = (bindingId, event) => {
|
|
105
|
+
const binding = bindings.get(bindingId)?.binding;
|
|
106
|
+
try {
|
|
107
|
+
binding?.onEvent?.(event);
|
|
108
|
+
}
|
|
109
|
+
catch {
|
|
110
|
+
// `onEvent` must not throw. A broken adapter must not reach the event bus.
|
|
111
|
+
}
|
|
112
|
+
};
|
|
113
|
+
const routeRunEvent = (name, payload) => {
|
|
114
|
+
if (name === "run.started" && "run" in payload) {
|
|
115
|
+
const { origin } = payload.run;
|
|
116
|
+
if (origin.kind === "chat" && bindings.has(origin.bindingId)) {
|
|
117
|
+
const chat = { bindingId: origin.bindingId, chatId: origin.chatId };
|
|
118
|
+
runChats.set(payload.run.runId, chat);
|
|
119
|
+
forward(chat.bindingId, {
|
|
120
|
+
chatId: chat.chatId,
|
|
121
|
+
kind: "run_started",
|
|
122
|
+
runId: payload.run.runId,
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
127
|
+
const runId = runIdOf(payload);
|
|
128
|
+
const chat = runId === undefined ? undefined : runChats.get(runId);
|
|
129
|
+
if (chat === undefined || runId === undefined) {
|
|
130
|
+
return;
|
|
131
|
+
}
|
|
132
|
+
const event = runEventOf(name, payload, runId, chat.chatId);
|
|
133
|
+
if (event !== undefined) {
|
|
134
|
+
forward(chat.bindingId, event);
|
|
135
|
+
}
|
|
136
|
+
if (name === "run.finished") {
|
|
137
|
+
runChats.delete(runId);
|
|
138
|
+
}
|
|
139
|
+
};
|
|
140
|
+
const mount = async (ctx, host) => {
|
|
141
|
+
await Promise.resolve();
|
|
142
|
+
const stagingDir = path.join(ctx.agentDir, STAGING_DIR);
|
|
143
|
+
const sinkFor = (bindingId) => ({
|
|
144
|
+
command: async (command) => {
|
|
145
|
+
await host.chat.command({ bindingId, chatId: command.chatId }, command.name, command.args);
|
|
146
|
+
},
|
|
147
|
+
commands: BUILTIN_COMMANDS,
|
|
148
|
+
decide: async (decision) => await host.approvals.decide(decision.approvalId, decision.resolution, {
|
|
149
|
+
bindingId,
|
|
150
|
+
chatId: decision.chatId,
|
|
151
|
+
kind: "chat",
|
|
152
|
+
}),
|
|
153
|
+
send: async (message) => {
|
|
154
|
+
await host.chat.send({ bindingId, chatId: message.chatId }, {
|
|
155
|
+
interactive: true,
|
|
156
|
+
senderDisplayName: message.senderDisplayName,
|
|
157
|
+
text: inboundText(message.text, message.attachments),
|
|
158
|
+
});
|
|
159
|
+
},
|
|
160
|
+
});
|
|
161
|
+
const contextFor = (hosted) => {
|
|
162
|
+
const { registerRoute } = options;
|
|
163
|
+
const register = registerRoute === undefined
|
|
164
|
+
? undefined
|
|
165
|
+
: (pathSuffix, handler) => {
|
|
166
|
+
const route = registerRoute(ctx.agentName, hosted.config.id, pathSuffix, handler);
|
|
167
|
+
hosted.routes.push(route);
|
|
168
|
+
return route;
|
|
169
|
+
};
|
|
170
|
+
return {
|
|
171
|
+
agentName: ctx.agentName,
|
|
172
|
+
bindingId: hosted.config.id,
|
|
173
|
+
dataDir: path.join(ctx.agentDir, FRONTENDS_DIR, hosted.config.id),
|
|
174
|
+
log: ctx.log,
|
|
175
|
+
maxAttachmentBytes: options.maxAttachmentBytes ?? DEFAULT_MAX_ATTACHMENT_BYTES,
|
|
176
|
+
registerWebhookRoute: register,
|
|
177
|
+
secrets: options.secrets,
|
|
178
|
+
stagingDir,
|
|
179
|
+
};
|
|
180
|
+
};
|
|
181
|
+
const createBinding = async (frontend, hosted) => {
|
|
182
|
+
const raw = hosted.config.config ?? {};
|
|
183
|
+
if (!isJsonValue(raw)) {
|
|
184
|
+
throw new Error("The binding config is not JSON");
|
|
185
|
+
}
|
|
186
|
+
const checked = await compileSchema(frontend.configSchema).check(raw);
|
|
187
|
+
if (!checked.ok) {
|
|
188
|
+
throw new Error(`Invalid config: ${checked.message}`);
|
|
189
|
+
}
|
|
190
|
+
const context = contextFor(hosted);
|
|
191
|
+
await mkdir(context.dataDir, { recursive: true });
|
|
192
|
+
await mkdir(context.stagingDir, { recursive: true });
|
|
193
|
+
return await frontend.createBinding(raw, context);
|
|
194
|
+
};
|
|
195
|
+
const startOne = async (hosted) => {
|
|
196
|
+
const frontend = host.extensions.frontends().get(hosted.config.type);
|
|
197
|
+
if (frontend === undefined) {
|
|
198
|
+
hosted.status = failedStatus(hosted.config, `Unknown Frontend type: ${hosted.config.type}`);
|
|
199
|
+
return;
|
|
200
|
+
}
|
|
201
|
+
try {
|
|
202
|
+
hosted.binding = await createBinding(frontend, hosted);
|
|
203
|
+
await hosted.binding.start(sinkFor(hosted.config.id));
|
|
204
|
+
hosted.status = {
|
|
205
|
+
id: hosted.config.id,
|
|
206
|
+
state: "ready",
|
|
207
|
+
type: hosted.config.type,
|
|
208
|
+
};
|
|
209
|
+
}
|
|
210
|
+
catch (error) {
|
|
211
|
+
const message = errorMessage(error);
|
|
212
|
+
ctx.log.error("A Frontend Binding failed to start", {
|
|
213
|
+
bindingId: hosted.config.id,
|
|
214
|
+
error: message,
|
|
215
|
+
});
|
|
216
|
+
hosted.status = failedStatus(hosted.config, message);
|
|
217
|
+
}
|
|
218
|
+
};
|
|
219
|
+
const onEvent = (name, payload) => {
|
|
220
|
+
if (!("agent" in payload) || payload.agent !== ctx.agentName) {
|
|
221
|
+
return;
|
|
222
|
+
}
|
|
223
|
+
routeRunEvent(name, payload);
|
|
224
|
+
};
|
|
225
|
+
let unlisten;
|
|
226
|
+
return {
|
|
227
|
+
frontends: () => [...bindings.values()].map((hosted) => hosted.status),
|
|
228
|
+
rpc: {},
|
|
229
|
+
start: async () => {
|
|
230
|
+
unlisten = options.events.listen(onEvent);
|
|
231
|
+
await Promise.all([...bindings.values()].map(startOne));
|
|
232
|
+
},
|
|
233
|
+
stop: async () => {
|
|
234
|
+
stopped = true;
|
|
235
|
+
unlisten?.();
|
|
236
|
+
await Promise.all([...bindings.values()].map(async (hosted) => {
|
|
237
|
+
for (const route of hosted.routes) {
|
|
238
|
+
route.unregister();
|
|
239
|
+
}
|
|
240
|
+
try {
|
|
241
|
+
await hosted.binding?.stop();
|
|
242
|
+
}
|
|
243
|
+
catch (error) {
|
|
244
|
+
ctx.log.warn("A Frontend Binding failed to stop", {
|
|
245
|
+
bindingId: hosted.config.id,
|
|
246
|
+
error: errorMessage(error),
|
|
247
|
+
});
|
|
248
|
+
}
|
|
249
|
+
hosted.binding = undefined;
|
|
250
|
+
hosted.status = {
|
|
251
|
+
id: hosted.config.id,
|
|
252
|
+
state: "stopped",
|
|
253
|
+
type: hosted.config.type,
|
|
254
|
+
};
|
|
255
|
+
}));
|
|
256
|
+
},
|
|
257
|
+
};
|
|
258
|
+
};
|
|
259
|
+
return {
|
|
260
|
+
deliver: async (bindingId, delivery) => {
|
|
261
|
+
if (stopped) {
|
|
262
|
+
throw new DeliveryError("The Agent is stopping", { kind: "retryable" });
|
|
263
|
+
}
|
|
264
|
+
await deliver(bindingId, delivery);
|
|
265
|
+
},
|
|
266
|
+
mount,
|
|
267
|
+
};
|
|
268
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,53 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wheatley-ai/cli",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Wheatley daemon and CLI",
|
|
5
|
+
"license": "ISC",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+https://github.com/SphericalKat/wheatley.git",
|
|
9
|
+
"directory": "packages/wheatley"
|
|
10
|
+
},
|
|
11
|
+
"bin": {
|
|
12
|
+
"wheatley": "bin/wheatley.js"
|
|
13
|
+
},
|
|
14
|
+
"files": [
|
|
15
|
+
"bin",
|
|
16
|
+
"dist"
|
|
17
|
+
],
|
|
18
|
+
"type": "module",
|
|
19
|
+
"main": "dist/index.js",
|
|
20
|
+
"publishConfig": {
|
|
21
|
+
"access": "public"
|
|
22
|
+
},
|
|
23
|
+
"dependencies": {
|
|
24
|
+
"@earendil-works/chord": "1.6.1",
|
|
25
|
+
"@earendil-works/pi-ai": "1.6.1",
|
|
26
|
+
"@earendil-works/pi-durable": "1.6.1",
|
|
27
|
+
"@earendil-works/pi-schema": "1.6.1",
|
|
28
|
+
"@modelcontextprotocol/client": "2.4.0",
|
|
29
|
+
"@slack/socket-mode": "3.2.0",
|
|
30
|
+
"@slack/web-api": "8.5.0",
|
|
31
|
+
"croner": "11.0.1",
|
|
32
|
+
"discord.js": "14.28.1",
|
|
33
|
+
"grammy": "1.48.0",
|
|
34
|
+
"import-meta-resolve": "4.2.0",
|
|
35
|
+
"typebox": "1.4.7",
|
|
36
|
+
"ws": "8.23.0",
|
|
37
|
+
"yaml": "2.9.1"
|
|
38
|
+
},
|
|
39
|
+
"devDependencies": {
|
|
40
|
+
"@modelcontextprotocol/server": "2.4.0",
|
|
41
|
+
"@types/ws": "8.18.2",
|
|
42
|
+
"@wheatley-ai/dashboard": "0.0.0",
|
|
43
|
+
"@wheatley-ai/protocol": "0.0.0",
|
|
44
|
+
"@wheatley-ai/sdk": "0.1.0"
|
|
45
|
+
},
|
|
46
|
+
"engines": {
|
|
47
|
+
"node": ">=26.13.1"
|
|
48
|
+
},
|
|
49
|
+
"scripts": {
|
|
50
|
+
"build": "tsc -p tsconfig.build.json && node scripts/bundle-dashboard.ts && node scripts/vendor-workspace-packages.ts",
|
|
51
|
+
"typecheck": "tsc --noEmit"
|
|
52
|
+
}
|
|
6
53
|
}
|
package/README.md
DELETED