@wheatley-ai/cli 0.0.0-stage → 0.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/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 +180 -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 +204 -0
- package/dist/cli/session.js +87 -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 +1020 -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 +61 -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.js +88 -0
- package/dist/core/deployment.js +347 -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 +95 -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 +206 -0
- package/dist/core/tool-routing.js +41 -0
- package/dist/dashboard/assets/index-3COz_MZq.css +2 -0
- package/dist/dashboard/assets/index-RnxedkKh.js +11 -0
- package/dist/dashboard/assets/sheet-presentation-U1UUymXc.js +1 -0
- package/dist/dashboard/index.html +13 -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 +252 -0
- package/dist/node_modules/@wheatley-ai/protocol/dist/config.js +110 -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 +195 -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 +104 -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 +207 -0
- package/dist/triggers/webhook-ingress.js +216 -0
- package/dist/wiring/agent-services.js +144 -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,441 @@
|
|
|
1
|
+
import { Type } from "typebox";
|
|
2
|
+
import { APPROVAL_REASON_MAX_LENGTH, CRON_EXPRESSION_MIN_LENGTH, DELIVERY_PREVIEW_MAX_LENGTH, DISPLAY_NAME_MAX_LENGTH, TOOL_INPUT_PREVIEW_MAX_LENGTH, TRIGGER_NAME_MAX_LENGTH, } from "./limits.js";
|
|
3
|
+
/** An Agent name. It is the permanent Agent ID and its folder name under `agents/`. */
|
|
4
|
+
export const AgentNameSchema = Type.String({
|
|
5
|
+
pattern: "^[a-z][a-z0-9-]{0,62}$",
|
|
6
|
+
});
|
|
7
|
+
/** A non-empty opaque ID. */
|
|
8
|
+
export const IdSchema = Type.String({ minLength: 1 });
|
|
9
|
+
/** An ISO 8601 UTC timestamp, for example `2026-11-26T09:30:00.000Z`. */
|
|
10
|
+
export const TimestampSchema = Type.String({
|
|
11
|
+
pattern: String.raw `^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d+)?Z$`,
|
|
12
|
+
});
|
|
13
|
+
/** A duration such as `500ms`, `30s`, `15m`, `2h`, or `1d`. */
|
|
14
|
+
export const DurationSchema = Type.String({ pattern: "^[0-9]+(ms|s|m|h|d)$" });
|
|
15
|
+
/** A count of zero or more. */
|
|
16
|
+
export const Count = Type.Integer({ minimum: 0 });
|
|
17
|
+
/** A secret name in `secrets.yaml` or the environment, never its value. */
|
|
18
|
+
export const SecretNameSchema = Type.String({
|
|
19
|
+
pattern: "^[A-Za-z_][A-Za-z0-9_]{0,127}$",
|
|
20
|
+
});
|
|
21
|
+
/** The Supervisor state of an Agent. */
|
|
22
|
+
export const AgentStateSchema = Type.Union([
|
|
23
|
+
Type.Literal("starting"),
|
|
24
|
+
Type.Literal("running"),
|
|
25
|
+
Type.Literal("degraded"),
|
|
26
|
+
Type.Literal("stopped"),
|
|
27
|
+
]);
|
|
28
|
+
/** One Chat: a Frontend Binding and the platform Chat ID inside it. */
|
|
29
|
+
export const ChatKeySchema = Type.Object({
|
|
30
|
+
bindingId: IdSchema,
|
|
31
|
+
chatId: IdSchema,
|
|
32
|
+
});
|
|
33
|
+
/** The state of a Plugin, MCP Server, or Frontend Binding inside an Agent. */
|
|
34
|
+
export const ExtensionStateSchema = Type.Union([
|
|
35
|
+
Type.Literal("starting"),
|
|
36
|
+
Type.Literal("ready"),
|
|
37
|
+
Type.Literal("failed"),
|
|
38
|
+
Type.Literal("disabled"),
|
|
39
|
+
Type.Literal("stopped"),
|
|
40
|
+
]);
|
|
41
|
+
/** Load or connection status of one extension. */
|
|
42
|
+
export const ExtensionStatusSchema = Type.Object({
|
|
43
|
+
error: Type.Optional(Type.String()),
|
|
44
|
+
name: Type.String(),
|
|
45
|
+
state: ExtensionStateSchema,
|
|
46
|
+
});
|
|
47
|
+
/** Status of one Frontend Binding. */
|
|
48
|
+
export const BindingStatusSchema = Type.Object({
|
|
49
|
+
error: Type.Optional(Type.String()),
|
|
50
|
+
id: IdSchema,
|
|
51
|
+
state: ExtensionStateSchema,
|
|
52
|
+
type: Type.String(),
|
|
53
|
+
});
|
|
54
|
+
/** Health of one Agent, as the Overview view shows it. */
|
|
55
|
+
export const AgentHealthSchema = Type.Object({
|
|
56
|
+
activeRuns: Count,
|
|
57
|
+
frontends: Type.Array(BindingStatusSchema),
|
|
58
|
+
lastError: Type.Union([Type.String(), Type.Null()]),
|
|
59
|
+
mcpServers: Type.Array(ExtensionStatusSchema),
|
|
60
|
+
name: AgentNameSchema,
|
|
61
|
+
pendingRestart: Type.Boolean(),
|
|
62
|
+
plugins: Type.Array(ExtensionStatusSchema),
|
|
63
|
+
/** Milliseconds until the next restart attempt, or `null` if no restart waits. */
|
|
64
|
+
restartBackoffMs: Type.Union([Count, Type.Null()]),
|
|
65
|
+
skillWarnings: Type.Array(Type.String()),
|
|
66
|
+
state: AgentStateSchema,
|
|
67
|
+
});
|
|
68
|
+
/** Use of one Concurrency Gate key, which is one provider credential. */
|
|
69
|
+
export const GatePressureSchema = Type.Object({
|
|
70
|
+
credential: Type.String(),
|
|
71
|
+
inUse: Count,
|
|
72
|
+
limit: Count,
|
|
73
|
+
waiting: Count,
|
|
74
|
+
});
|
|
75
|
+
/** Deployment health for the Overview view and `wheatley status`. */
|
|
76
|
+
export const DaemonStatusSchema = Type.Object({
|
|
77
|
+
agents: Type.Array(AgentHealthSchema),
|
|
78
|
+
concurrency: Type.Array(GatePressureSchema),
|
|
79
|
+
protocolVersion: Type.Integer({ minimum: 1 }),
|
|
80
|
+
startedAt: TimestampSchema,
|
|
81
|
+
uptimeMs: Count,
|
|
82
|
+
version: Type.String(),
|
|
83
|
+
});
|
|
84
|
+
/** A Permission Policy action. */
|
|
85
|
+
export const PermissionActionSchema = Type.Union([
|
|
86
|
+
Type.Literal("allow"),
|
|
87
|
+
Type.Literal("ask"),
|
|
88
|
+
Type.Literal("deny"),
|
|
89
|
+
]);
|
|
90
|
+
/**
|
|
91
|
+
* One Permission Policy rule. `tool` is a canonical Tool name with optional `*` wildcards, for example `shell`,
|
|
92
|
+
* `notes:*`, `mcp:github:*`, or `mcp:context7:resolve-library-id`. Matching is case-sensitive, because MCP Tool names
|
|
93
|
+
* can contain uppercase letters.
|
|
94
|
+
*/
|
|
95
|
+
export const PermissionRuleSchema = Type.Object({
|
|
96
|
+
action: PermissionActionSchema,
|
|
97
|
+
tool: Type.String({
|
|
98
|
+
pattern: String.raw `^[A-Za-z0-9_*.][A-Za-z0-9_*.:\-]*$`,
|
|
99
|
+
}),
|
|
100
|
+
}, { additionalProperties: false });
|
|
101
|
+
/** A Sender or Operator decision on an Approval. */
|
|
102
|
+
export const ApprovalDecisionSchema = Type.Union([
|
|
103
|
+
Type.Literal("allow_once"),
|
|
104
|
+
Type.Literal("allow_conversation"),
|
|
105
|
+
Type.Literal("allow_always"),
|
|
106
|
+
Type.Literal("deny"),
|
|
107
|
+
]);
|
|
108
|
+
/** How an Approval ended. */
|
|
109
|
+
export const ApprovalOutcomeSchema = Type.Union([
|
|
110
|
+
ApprovalDecisionSchema,
|
|
111
|
+
Type.Literal("timeout"),
|
|
112
|
+
Type.Literal("cancelled"),
|
|
113
|
+
]);
|
|
114
|
+
/** A decision with optional attribution and reason. */
|
|
115
|
+
export const ApprovalResolutionSchema = Type.Object({
|
|
116
|
+
decision: ApprovalDecisionSchema,
|
|
117
|
+
reason: Type.Optional(Type.String({ maxLength: APPROVAL_REASON_MAX_LENGTH })),
|
|
118
|
+
resolvedBy: Type.Optional(Type.String({ maxLength: DISPLAY_NAME_MAX_LENGTH })),
|
|
119
|
+
}, { additionalProperties: false });
|
|
120
|
+
/** An Approval that waits for a decision. */
|
|
121
|
+
export const PendingApprovalSchema = Type.Object({
|
|
122
|
+
agent: AgentNameSchema,
|
|
123
|
+
approvalId: IdSchema,
|
|
124
|
+
/** The originating Chat, or `null` for a Run without a Chat. */
|
|
125
|
+
chat: Type.Union([ChatKeySchema, Type.Null()]),
|
|
126
|
+
conversationId: IdSchema,
|
|
127
|
+
createdAt: TimestampSchema,
|
|
128
|
+
expiresAt: Type.Union([TimestampSchema, Type.Null()]),
|
|
129
|
+
/** Formatted Tool input, at most 500 characters, with secret values redacted. */
|
|
130
|
+
inputPreview: Type.String({ maxLength: TOOL_INPUT_PREVIEW_MAX_LENGTH }),
|
|
131
|
+
runId: IdSchema,
|
|
132
|
+
toolName: Type.String(),
|
|
133
|
+
});
|
|
134
|
+
/** What started a Run. */
|
|
135
|
+
export const RunOriginSchema = Type.Union([
|
|
136
|
+
Type.Object({
|
|
137
|
+
bindingId: IdSchema,
|
|
138
|
+
chatId: IdSchema,
|
|
139
|
+
kind: Type.Literal("chat"),
|
|
140
|
+
}),
|
|
141
|
+
Type.Object({ kind: Type.Literal("trigger"), triggerId: IdSchema }),
|
|
142
|
+
Type.Object({ job: Type.String(), kind: Type.Literal("maintenance") }),
|
|
143
|
+
]);
|
|
144
|
+
/** The state of a Run. */
|
|
145
|
+
export const RunStatusSchema = Type.Union([
|
|
146
|
+
Type.Literal("running"),
|
|
147
|
+
Type.Literal("waiting_approval"),
|
|
148
|
+
Type.Literal("completed"),
|
|
149
|
+
Type.Literal("failed"),
|
|
150
|
+
Type.Literal("stopped"),
|
|
151
|
+
]);
|
|
152
|
+
/** Token use and cost of a Run. */
|
|
153
|
+
export const RunUsageSchema = Type.Object({
|
|
154
|
+
costUsd: Type.Optional(Type.Number({ minimum: 0 })),
|
|
155
|
+
inputTokens: Count,
|
|
156
|
+
outputTokens: Count,
|
|
157
|
+
});
|
|
158
|
+
/** One Run. */
|
|
159
|
+
export const RunSummarySchema = Type.Object({
|
|
160
|
+
agent: AgentNameSchema,
|
|
161
|
+
conversationId: IdSchema,
|
|
162
|
+
endedAt: Type.Union([TimestampSchema, Type.Null()]),
|
|
163
|
+
error: Type.Optional(Type.String()),
|
|
164
|
+
model: Type.Optional(Type.String()),
|
|
165
|
+
origin: RunOriginSchema,
|
|
166
|
+
runId: IdSchema,
|
|
167
|
+
startedAt: TimestampSchema,
|
|
168
|
+
status: RunStatusSchema,
|
|
169
|
+
usage: Type.Optional(RunUsageSchema),
|
|
170
|
+
});
|
|
171
|
+
/** One item of a Run timeline. */
|
|
172
|
+
export const RunTimelineItemSchema = Type.Union([
|
|
173
|
+
Type.Object({
|
|
174
|
+
at: TimestampSchema,
|
|
175
|
+
kind: Type.Literal("user_message"),
|
|
176
|
+
senderDisplayName: Type.Optional(Type.String()),
|
|
177
|
+
text: Type.String(),
|
|
178
|
+
}),
|
|
179
|
+
Type.Object({
|
|
180
|
+
at: TimestampSchema,
|
|
181
|
+
kind: Type.Literal("assistant_text"),
|
|
182
|
+
text: Type.String(),
|
|
183
|
+
}),
|
|
184
|
+
Type.Object({
|
|
185
|
+
endedAt: Type.Union([TimestampSchema, Type.Null()]),
|
|
186
|
+
inputPreview: Type.String(),
|
|
187
|
+
isError: Type.Optional(Type.Boolean()),
|
|
188
|
+
kind: Type.Literal("tool_call"),
|
|
189
|
+
outputPreview: Type.Optional(Type.String()),
|
|
190
|
+
startedAt: TimestampSchema,
|
|
191
|
+
toolCallId: IdSchema,
|
|
192
|
+
toolName: Type.String(),
|
|
193
|
+
}),
|
|
194
|
+
Type.Object({
|
|
195
|
+
approvalId: IdSchema,
|
|
196
|
+
at: TimestampSchema,
|
|
197
|
+
decision: Type.Optional(ApprovalOutcomeSchema),
|
|
198
|
+
kind: Type.Literal("approval"),
|
|
199
|
+
toolName: Type.String(),
|
|
200
|
+
}),
|
|
201
|
+
]);
|
|
202
|
+
/** File metadata of an attachment. */
|
|
203
|
+
export const AttachmentInfoSchema = Type.Object({
|
|
204
|
+
filename: Type.String(),
|
|
205
|
+
mimeType: Type.String(),
|
|
206
|
+
sizeBytes: Count,
|
|
207
|
+
});
|
|
208
|
+
/** A file that a client uploads with `chat.send` or `chat.ask`. `data` is base64. */
|
|
209
|
+
export const AttachmentUploadSchema = Type.Object({
|
|
210
|
+
data: Type.String({ contentEncoding: "base64" }),
|
|
211
|
+
filename: Type.String({ minLength: 1 }),
|
|
212
|
+
mimeType: Type.String({ minLength: 1 }),
|
|
213
|
+
}, { additionalProperties: false });
|
|
214
|
+
/** One message in the CLI and dashboard Chat. */
|
|
215
|
+
export const ChatMessageSchema = Type.Object({
|
|
216
|
+
at: TimestampSchema,
|
|
217
|
+
attachments: Type.Optional(Type.Array(AttachmentInfoSchema)),
|
|
218
|
+
messageId: IdSchema,
|
|
219
|
+
role: Type.Union([Type.Literal("user"), Type.Literal("assistant")]),
|
|
220
|
+
runId: Type.Optional(IdSchema),
|
|
221
|
+
senderDisplayName: Type.Optional(Type.String()),
|
|
222
|
+
source: Type.Optional(Type.Union([
|
|
223
|
+
Type.Literal("reply"),
|
|
224
|
+
Type.Literal("command"),
|
|
225
|
+
Type.Literal("trigger"),
|
|
226
|
+
])),
|
|
227
|
+
text: Type.String(),
|
|
228
|
+
});
|
|
229
|
+
/** The built-in Chat commands, without the leading slash. */
|
|
230
|
+
export const CommandNameSchema = Type.Union([
|
|
231
|
+
Type.Literal("new"),
|
|
232
|
+
Type.Literal("model"),
|
|
233
|
+
Type.Literal("compact"),
|
|
234
|
+
Type.Literal("stop"),
|
|
235
|
+
Type.Literal("goal"),
|
|
236
|
+
Type.Literal("status"),
|
|
237
|
+
Type.Literal("restart"),
|
|
238
|
+
]);
|
|
239
|
+
/** How a TriggerSchema maps firings to Conversations. */
|
|
240
|
+
export const ConversationModeSchema = Type.Union([
|
|
241
|
+
Type.Literal("per_firing"),
|
|
242
|
+
Type.Literal("shared"),
|
|
243
|
+
]);
|
|
244
|
+
/** The schedule part of a TriggerSchema. */
|
|
245
|
+
export const TriggerScheduleSchema = Type.Union([
|
|
246
|
+
Type.Object({
|
|
247
|
+
kind: Type.Literal("cron"),
|
|
248
|
+
/** A 5-field cron expression. */
|
|
249
|
+
schedule: Type.String({ minLength: CRON_EXPRESSION_MIN_LENGTH }),
|
|
250
|
+
/** An IANA time zone, for example `Europe/Berlin`. */
|
|
251
|
+
timezone: Type.String({ minLength: 1 }),
|
|
252
|
+
}, { additionalProperties: false }),
|
|
253
|
+
Type.Object({ at: TimestampSchema, kind: Type.Literal("once") }, { additionalProperties: false }),
|
|
254
|
+
Type.Object({
|
|
255
|
+
kind: Type.Literal("webhook"),
|
|
256
|
+
/** The name of the Bearer token secret in `secrets.yaml`. */
|
|
257
|
+
tokenSecret: SecretNameSchema,
|
|
258
|
+
}, { additionalProperties: false }),
|
|
259
|
+
]);
|
|
260
|
+
/** Fields of a new TriggerSchema. */
|
|
261
|
+
export const TriggerInputSchema = Type.Object({
|
|
262
|
+
conversationMode: Type.Optional(ConversationModeSchema),
|
|
263
|
+
name: Type.String({ maxLength: TRIGGER_NAME_MAX_LENGTH, minLength: 1 }),
|
|
264
|
+
paused: Type.Optional(Type.Boolean()),
|
|
265
|
+
/** The instruction for each firing. A webhook firing appends the request body. */
|
|
266
|
+
prompt: Type.String({ minLength: 1 }),
|
|
267
|
+
schedule: TriggerScheduleSchema,
|
|
268
|
+
target: ChatKeySchema,
|
|
269
|
+
}, { additionalProperties: false });
|
|
270
|
+
/** Fields to change on a TriggerSchema. Absent fields stay the same. */
|
|
271
|
+
export const TriggerPatchSchema = Type.Object({
|
|
272
|
+
conversationMode: Type.Optional(ConversationModeSchema),
|
|
273
|
+
name: Type.Optional(Type.String({ maxLength: TRIGGER_NAME_MAX_LENGTH, minLength: 1 })),
|
|
274
|
+
paused: Type.Optional(Type.Boolean()),
|
|
275
|
+
prompt: Type.Optional(Type.String({ minLength: 1 })),
|
|
276
|
+
schedule: Type.Optional(TriggerScheduleSchema),
|
|
277
|
+
target: Type.Optional(ChatKeySchema),
|
|
278
|
+
}, { additionalProperties: false });
|
|
279
|
+
/** A stored TriggerSchema. */
|
|
280
|
+
export const TriggerSchema = Type.Object({
|
|
281
|
+
conversationMode: ConversationModeSchema,
|
|
282
|
+
createdAt: TimestampSchema,
|
|
283
|
+
/** Agents create `cron` and `once` Triggers through Tools. Only the Operator creates `webhook` Triggers. */
|
|
284
|
+
createdBy: Type.Union([Type.Literal("agent"), Type.Literal("operator")]),
|
|
285
|
+
id: IdSchema,
|
|
286
|
+
lastFiredAt: Type.Union([TimestampSchema, Type.Null()]),
|
|
287
|
+
name: Type.String(),
|
|
288
|
+
nextFireAt: Type.Union([TimestampSchema, Type.Null()]),
|
|
289
|
+
paused: Type.Boolean(),
|
|
290
|
+
prompt: Type.String(),
|
|
291
|
+
schedule: TriggerScheduleSchema,
|
|
292
|
+
target: ChatKeySchema,
|
|
293
|
+
});
|
|
294
|
+
/** The kinds of Frontend delivery. */
|
|
295
|
+
export const DeliveryKindSchema = Type.Union([
|
|
296
|
+
Type.Literal("message"),
|
|
297
|
+
Type.Literal("approval_requested"),
|
|
298
|
+
Type.Literal("approval_resolved"),
|
|
299
|
+
]);
|
|
300
|
+
/** An outbox entry that failed. */
|
|
301
|
+
export const FailedDeliverySchema = Type.Object({
|
|
302
|
+
agent: AgentNameSchema,
|
|
303
|
+
attempts: Count,
|
|
304
|
+
bindingId: IdSchema,
|
|
305
|
+
chatId: IdSchema,
|
|
306
|
+
createdAt: TimestampSchema,
|
|
307
|
+
deliveryId: IdSchema,
|
|
308
|
+
failedAt: TimestampSchema,
|
|
309
|
+
kind: DeliveryKindSchema,
|
|
310
|
+
lastError: Type.String(),
|
|
311
|
+
permanent: Type.Boolean(),
|
|
312
|
+
preview: Type.String({ maxLength: DELIVERY_PREVIEW_MAX_LENGTH }),
|
|
313
|
+
});
|
|
314
|
+
/** A Memory file name: `MEMORY` for `MEMORY.md`, otherwise the slug of `<slug>.md`. */
|
|
315
|
+
export const MemoryNameSchema = Type.String({
|
|
316
|
+
pattern: "^(MEMORY|[a-z0-9][a-z0-9-]{0,63})$",
|
|
317
|
+
});
|
|
318
|
+
/** Metadata of one Memory file. */
|
|
319
|
+
export const MemoryFileSchema = Type.Object({
|
|
320
|
+
chars: Count,
|
|
321
|
+
name: MemoryNameSchema,
|
|
322
|
+
updatedAt: TimestampSchema,
|
|
323
|
+
});
|
|
324
|
+
/** The `MEMORY.md` character budget. */
|
|
325
|
+
export const MemoryBudgetSchema = Type.Object({
|
|
326
|
+
maxChars: Count,
|
|
327
|
+
usedChars: Count,
|
|
328
|
+
});
|
|
329
|
+
/** Where a Memory search looks. */
|
|
330
|
+
export const MemorySearchScopeSchema = Type.Union([
|
|
331
|
+
Type.Literal("memory"),
|
|
332
|
+
Type.Literal("conversations"),
|
|
333
|
+
Type.Literal("all"),
|
|
334
|
+
]);
|
|
335
|
+
/** One Memory search result. */
|
|
336
|
+
export const MemorySearchHitSchema = Type.Union([
|
|
337
|
+
Type.Object({
|
|
338
|
+
kind: Type.Literal("memory"),
|
|
339
|
+
name: MemoryNameSchema,
|
|
340
|
+
score: Type.Number(),
|
|
341
|
+
snippet: Type.String(),
|
|
342
|
+
}),
|
|
343
|
+
Type.Object({
|
|
344
|
+
at: TimestampSchema,
|
|
345
|
+
conversationId: IdSchema,
|
|
346
|
+
kind: Type.Literal("conversation"),
|
|
347
|
+
role: Type.Union([Type.Literal("user"), Type.Literal("assistant")]),
|
|
348
|
+
score: Type.Number(),
|
|
349
|
+
snippet: Type.String(),
|
|
350
|
+
}),
|
|
351
|
+
]);
|
|
352
|
+
/** One run of the Memory consolidation job. */
|
|
353
|
+
export const ConsolidationLogEntrySchema = Type.Object({
|
|
354
|
+
endedAt: Type.Union([TimestampSchema, Type.Null()]),
|
|
355
|
+
error: Type.Optional(Type.String()),
|
|
356
|
+
id: IdSchema,
|
|
357
|
+
runId: Type.Optional(IdSchema),
|
|
358
|
+
startedAt: TimestampSchema,
|
|
359
|
+
status: Type.Union([
|
|
360
|
+
Type.Literal("running"),
|
|
361
|
+
Type.Literal("completed"),
|
|
362
|
+
Type.Literal("failed"),
|
|
363
|
+
]),
|
|
364
|
+
summary: Type.Optional(Type.String()),
|
|
365
|
+
});
|
|
366
|
+
/** Where a secret value comes from. */
|
|
367
|
+
export const SecretSourceSchema = Type.Union([
|
|
368
|
+
Type.Literal("file"),
|
|
369
|
+
Type.Literal("env"),
|
|
370
|
+
Type.Literal("both"),
|
|
371
|
+
]);
|
|
372
|
+
/** A secret and the config entries that refer to it. */
|
|
373
|
+
export const SecretInfoSchema = Type.Object({
|
|
374
|
+
name: SecretNameSchema,
|
|
375
|
+
references: Type.Array(Type.Object({
|
|
376
|
+
agent: Type.Optional(AgentNameSchema),
|
|
377
|
+
id: Type.String(),
|
|
378
|
+
kind: Type.Union([
|
|
379
|
+
Type.Literal("provider"),
|
|
380
|
+
Type.Literal("frontend"),
|
|
381
|
+
Type.Literal("mcp"),
|
|
382
|
+
Type.Literal("plugin"),
|
|
383
|
+
Type.Literal("trigger"),
|
|
384
|
+
]),
|
|
385
|
+
})),
|
|
386
|
+
source: SecretSourceSchema,
|
|
387
|
+
});
|
|
388
|
+
/** A diagnostic log level. */
|
|
389
|
+
export const LogLevelSchema = Type.Union([
|
|
390
|
+
Type.Literal("debug"),
|
|
391
|
+
Type.Literal("info"),
|
|
392
|
+
Type.Literal("warn"),
|
|
393
|
+
Type.Literal("error"),
|
|
394
|
+
]);
|
|
395
|
+
/** One diagnostic log record. Records never contain secret values. */
|
|
396
|
+
export const LogRecordSchema = Type.Object({
|
|
397
|
+
agent: Type.Optional(AgentNameSchema),
|
|
398
|
+
at: TimestampSchema,
|
|
399
|
+
fields: Type.Optional(Type.Record(Type.String(), Type.Unknown())),
|
|
400
|
+
level: LogLevelSchema,
|
|
401
|
+
message: Type.String(),
|
|
402
|
+
module: Type.String(),
|
|
403
|
+
/** Increases by one for each record in a daemon process. */
|
|
404
|
+
seq: Count,
|
|
405
|
+
});
|
|
406
|
+
/** A config change that waits for a restart to take effect. */
|
|
407
|
+
export const PendingRestartSchema = Type.Union([
|
|
408
|
+
Type.Object({ agent: AgentNameSchema, kind: Type.Literal("agent") }),
|
|
409
|
+
Type.Object({
|
|
410
|
+
agent: AgentNameSchema,
|
|
411
|
+
bindingId: IdSchema,
|
|
412
|
+
kind: Type.Literal("binding"),
|
|
413
|
+
}),
|
|
414
|
+
Type.Object({ kind: Type.Literal("daemon"), reason: Type.String() }),
|
|
415
|
+
]);
|
|
416
|
+
/** One problem in a config file. `path` is a JSON Pointer, for example `/agents/home/model`. */
|
|
417
|
+
export const ConfigIssueSchema = Type.Object({
|
|
418
|
+
message: Type.String(),
|
|
419
|
+
path: Type.String(),
|
|
420
|
+
});
|
|
421
|
+
/** Where a Tool comes from. */
|
|
422
|
+
export const ToolSourceSchema = Type.Union([
|
|
423
|
+
Type.Literal("builtin"),
|
|
424
|
+
Type.Literal("plugin"),
|
|
425
|
+
Type.Literal("mcp"),
|
|
426
|
+
]);
|
|
427
|
+
/** A Tool that an Agent offers, with its effective Permission Policy action. */
|
|
428
|
+
export const ToolInfoSchema = Type.Object({
|
|
429
|
+
action: PermissionActionSchema,
|
|
430
|
+
description: Type.String(),
|
|
431
|
+
name: Type.String(),
|
|
432
|
+
source: ToolSourceSchema,
|
|
433
|
+
});
|
|
434
|
+
/** A discovered Skill. */
|
|
435
|
+
export const SkillInfoSchema = Type.Object({
|
|
436
|
+
description: Type.String(),
|
|
437
|
+
name: Type.String(),
|
|
438
|
+
origin: Type.Union([Type.Literal("shared"), Type.Literal("agent")]),
|
|
439
|
+
path: Type.String(),
|
|
440
|
+
});
|
|
441
|
+
//# sourceMappingURL=domain.js.map
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Converts a config duration such as `15m` or `30s` to milliseconds.
|
|
3
|
+
*
|
|
4
|
+
* Throws a `RangeError` for text that does not match the `Duration` schema or exceeds `Number.MAX_SAFE_INTEGER`
|
|
5
|
+
* milliseconds.
|
|
6
|
+
*/
|
|
7
|
+
export declare const parseDuration: (text: string) => number;
|
|
8
|
+
//# sourceMappingURL=duration.d.ts.map
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
const DURATION = /^(?<amount>\d+)(?<unit>ms|s|m|h|d)$/u;
|
|
2
|
+
const UNIT_MS = {
|
|
3
|
+
d: 86_400_000,
|
|
4
|
+
h: 3_600_000,
|
|
5
|
+
m: 60_000,
|
|
6
|
+
ms: 1,
|
|
7
|
+
s: 1000,
|
|
8
|
+
};
|
|
9
|
+
const isUnit = (unit) => Object.hasOwn(UNIT_MS, unit);
|
|
10
|
+
/**
|
|
11
|
+
* Converts a config duration such as `15m` or `30s` to milliseconds.
|
|
12
|
+
*
|
|
13
|
+
* Throws a `RangeError` for text that does not match the `Duration` schema or exceeds `Number.MAX_SAFE_INTEGER`
|
|
14
|
+
* milliseconds.
|
|
15
|
+
*/
|
|
16
|
+
export const parseDuration = (text) => {
|
|
17
|
+
const groups = DURATION.exec(text)?.groups;
|
|
18
|
+
const unit = groups?.unit ?? "";
|
|
19
|
+
if (groups?.amount === undefined || !isUnit(unit)) {
|
|
20
|
+
throw new RangeError(`Invalid duration: ${text}`);
|
|
21
|
+
}
|
|
22
|
+
const milliseconds = Number(groups.amount) * UNIT_MS[unit];
|
|
23
|
+
if (!Number.isSafeInteger(milliseconds)) {
|
|
24
|
+
throw new RangeError(`Duration is too long: ${text}`);
|
|
25
|
+
}
|
|
26
|
+
return milliseconds;
|
|
27
|
+
};
|
|
28
|
+
//# sourceMappingURL=duration.js.map
|