@elizaos/plugin-commands 2.0.3-beta.2 → 2.0.3-beta.3

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.
Files changed (38) hide show
  1. package/dist/cjs/index.cjs +1757 -0
  2. package/dist/cjs/index.cjs.map +23 -0
  3. package/dist/index.d.ts +3 -0
  4. package/dist/index.d.ts.map +1 -0
  5. package/dist/index.js +1719 -0
  6. package/dist/index.js.map +23 -0
  7. package/dist/src/actions/command-actions.d.ts +17 -0
  8. package/dist/src/actions/command-actions.d.ts.map +1 -0
  9. package/dist/src/actions/command-settings.d.ts +35 -0
  10. package/dist/src/actions/command-settings.d.ts.map +1 -0
  11. package/dist/src/actions/dispatch.d.ts +54 -0
  12. package/dist/src/actions/dispatch.d.ts.map +1 -0
  13. package/dist/src/actions/handlers.d.ts +26 -0
  14. package/dist/src/actions/handlers.d.ts.map +1 -0
  15. package/dist/src/actions/index.d.ts +19 -0
  16. package/dist/src/actions/index.d.ts.map +1 -0
  17. package/dist/src/actions/shortcuts.d.ts +41 -0
  18. package/dist/src/actions/shortcuts.d.ts.map +1 -0
  19. package/dist/src/connector-bridge.d.ts +128 -0
  20. package/dist/src/connector-bridge.d.ts.map +1 -0
  21. package/dist/src/connector-catalog.d.ts +71 -0
  22. package/dist/src/connector-catalog.d.ts.map +1 -0
  23. package/dist/src/index.d.ts +68 -0
  24. package/dist/src/index.d.ts.map +1 -0
  25. package/dist/src/navigation-commands.d.ts +28 -0
  26. package/dist/src/navigation-commands.d.ts.map +1 -0
  27. package/dist/src/parser.d.ts +32 -0
  28. package/dist/src/parser.d.ts.map +1 -0
  29. package/dist/src/registry.d.ts +66 -0
  30. package/dist/src/registry.d.ts.map +1 -0
  31. package/dist/src/serialize.d.ts +30 -0
  32. package/dist/src/serialize.d.ts.map +1 -0
  33. package/dist/src/settings-sections.d.ts +32 -0
  34. package/dist/src/settings-sections.d.ts.map +1 -0
  35. package/dist/src/types.d.ts +175 -0
  36. package/dist/src/types.d.ts.map +1 -0
  37. package/package.json +4 -3
  38. package/registry-entry.json +63 -0
@@ -0,0 +1,128 @@
1
+ /**
2
+ * ConnectorCommandBridge — the one documented contract every communication
3
+ * connector (Discord, Telegram, …) implements to register and dispatch the
4
+ * universal slash-command catalog onto its native command surface (#8790).
5
+ *
6
+ * The catalog (`getConnectorCommands(surface)`) is connector-neutral; each
7
+ * connector still has to (a) map those commands onto its own command registry
8
+ * and (b) run them when invoked. Before this contract, each connector invented
9
+ * its own register/dispatch shape and — critically — neither gated
10
+ * `requiresAuth` / `requiresElevated` commands at the connector boundary. This
11
+ * module pins down a single shape so the two connectors behave consistently and
12
+ * share one auth-gating decision instead of two divergent copies.
13
+ *
14
+ * The bridge is deliberately a thin interface + a few pure helpers, NOT a
15
+ * framework: connectors keep owning their own message pipelines and reply
16
+ * mechanics. What they share is:
17
+ *
18
+ * 1. the three target kinds and how they route (`agent` / `navigate` /
19
+ * `client`),
20
+ * 2. one auth-gating decision (`gateConnectorCommand`) producing one refusal
21
+ * message, and
22
+ * 3. one place to read a command's auth requirements
23
+ * (`resolveConnectorCommandAuth`).
24
+ *
25
+ * Auth model: the connector resolves the *sender's* trust level
26
+ * (`isAuthorized` / `isElevated`) using whatever owner/allowlist mechanism it
27
+ * already has — the canonical-owner / world-role model in `@elizaos/core`
28
+ * (`hasRoleAccess`). The bridge does not invent a new auth model; it only
29
+ * decides whether a given command may run for an already-resolved sender.
30
+ */
31
+ import type { CommandTarget } from "./types";
32
+ /**
33
+ * The sender's resolved trust level on a connector surface. The connector fills
34
+ * this in from its own owner/allowlist resolution before dispatching; the
35
+ * bridge treats missing/false as "fails closed" (unauthorized).
36
+ */
37
+ export interface ConnectorSenderAuth {
38
+ isAuthorized: boolean;
39
+ isElevated: boolean;
40
+ /** Optional human label for `/whoami`-style replies. */
41
+ senderName?: string;
42
+ }
43
+ /** A command's auth requirements, read from its catalog definition. */
44
+ export interface ConnectorCommandAuth {
45
+ requiresAuth: boolean;
46
+ requiresElevated: boolean;
47
+ }
48
+ /** The outcome of gating a command for a sender. */
49
+ export type ConnectorGateDecision = {
50
+ allowed: true;
51
+ } | {
52
+ allowed: false;
53
+ reply: string;
54
+ };
55
+ /**
56
+ * Resolve a command's auth requirements from the active command registry.
57
+ * `name` is the connector command name (`ConnectorCommand.name`), which is the
58
+ * command's `nativeName ?? key`; the registry is keyed by `key`, so the lookup
59
+ * tries the name as a key directly. Unknown commands are treated as requiring
60
+ * no special auth (the catalog only emits real commands, and agent-target
61
+ * commands are auth-gated again inside `runCommand`).
62
+ *
63
+ * The lookup is scoped directly by `agentId` so concurrent connector requests
64
+ * cannot move a shared active-store cursor underneath each other.
65
+ */
66
+ export declare function resolveConnectorCommandAuth(agentId: string, name: string): ConnectorCommandAuth;
67
+ /**
68
+ * The single auth-gating decision both connectors share. Given a command's
69
+ * requirements and the sender's resolved trust level, decide whether the
70
+ * command may run — and, when it may not, produce the one refusal message
71
+ * every connector emits. Fails closed: an unresolved sender (`isAuthorized:
72
+ * false`) is refused for any auth-gated command.
73
+ */
74
+ export declare function gateConnectorCommand(requirements: ConnectorCommandAuth, sender: ConnectorSenderAuth): ConnectorGateDecision;
75
+ /**
76
+ * Convenience: resolve a command's requirements and gate it in one call.
77
+ */
78
+ export declare function gateConnectorCommandByName(agentId: string, name: string, sender: ConnectorSenderAuth): ConnectorGateDecision;
79
+ /**
80
+ * The contract every connector command bridge implements. `TCommand` is the
81
+ * connector's native command shape (Discord `SlashCommand`, Telegram
82
+ * descriptor, …) and `TContext` is its per-invocation context (a Discord
83
+ * interaction, a Telegraf `Context`, …). Implementations are expected to:
84
+ *
85
+ * - `registerCommands()` — project `getConnectorCommands(surface)` onto
86
+ * the native command registry (deduping against
87
+ * connector built-ins) and return what was
88
+ * registered.
89
+ * - `dispatch(target, ...)` — run a single command, branching on its target
90
+ * kind, after the sender has been gated. The
91
+ * bridge's auth helpers (`gateConnectorCommand`)
92
+ * are applied before `dispatch` so refused
93
+ * commands never reach it.
94
+ *
95
+ * The three target kinds behave consistently across connectors:
96
+ *
97
+ * - `agent` → run the command. Gate-safe deterministic commands
98
+ * (help/status/models/usage/…) resolve to a local reply via
99
+ * `resolveCommand`; option/lifecycle commands route the
100
+ * reconstructed command text through the connector's message
101
+ * pipeline and surface the agent reply.
102
+ * - `navigate` → reply with a description of the in-app destination (a deep
103
+ * link); the connector cannot open the Eliza app itself.
104
+ * - `client` → a GUI/TUI-only behavior with no remote surface; the catalog
105
+ * filters these off connector surfaces, so this is defensive.
106
+ */
107
+ export interface ConnectorCommandBridge<TCommand, TContext> {
108
+ /** The catalog surface this bridge serves ("discord" | "telegram"). */
109
+ readonly surface: string;
110
+ /**
111
+ * Project the catalog onto the connector's native command registry and
112
+ * return the registered native commands. Deduping against connector
113
+ * built-ins is the implementation's responsibility.
114
+ */
115
+ registerCommands(): TCommand[];
116
+ /**
117
+ * Resolve the invoking sender's trust level from the connector's own
118
+ * owner/allowlist mechanism. Fails closed (unauthorized) when identity
119
+ * cannot be resolved.
120
+ */
121
+ resolveSenderAuth(context: TContext): Promise<ConnectorSenderAuth>;
122
+ /**
123
+ * Run a single command for an already-gated sender, branching on its target
124
+ * kind. Returns once the reply has been surfaced on the connector.
125
+ */
126
+ dispatch(target: CommandTarget, context: TContext, sender: ConnectorSenderAuth): Promise<void>;
127
+ }
128
+ //# sourceMappingURL=connector-bridge.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"connector-bridge.d.ts","sourceRoot":"","sources":["../../src/connector-bridge.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAGH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAE7C;;;;GAIG;AACH,MAAM,WAAW,mBAAmB;IACnC,YAAY,EAAE,OAAO,CAAC;IACtB,UAAU,EAAE,OAAO,CAAC;IACpB,wDAAwD;IACxD,UAAU,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,uEAAuE;AACvE,MAAM,WAAW,oBAAoB;IACpC,YAAY,EAAE,OAAO,CAAC;IACtB,gBAAgB,EAAE,OAAO,CAAC;CAC1B;AAED,oDAAoD;AACpD,MAAM,MAAM,qBAAqB,GAC9B;IAAE,OAAO,EAAE,IAAI,CAAA;CAAE,GACjB;IAAE,OAAO,EAAE,KAAK,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC;AAErC;;;;;;;;;;GAUG;AACH,wBAAgB,2BAA2B,CAC1C,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,MAAM,GACV,oBAAoB,CAMtB;AAED;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CACnC,YAAY,EAAE,oBAAoB,EAClC,MAAM,EAAE,mBAAmB,GACzB,qBAAqB,CAevB;AAED;;GAEG;AACH,wBAAgB,0BAA0B,CACzC,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,mBAAmB,GACzB,qBAAqB,CAKvB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,MAAM,WAAW,sBAAsB,CAAC,QAAQ,EAAE,QAAQ;IACzD,uEAAuE;IACvE,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IAEzB;;;;OAIG;IACH,gBAAgB,IAAI,QAAQ,EAAE,CAAC;IAE/B;;;;OAIG;IACH,iBAAiB,CAAC,OAAO,EAAE,QAAQ,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAAC;IAEnE;;;OAGG;IACH,QAAQ,CACP,MAAM,EAAE,aAAa,EACrB,OAAO,EAAE,QAAQ,EACjB,MAAM,EAAE,mBAAmB,GACzB,OAAO,CAAC,IAAI,CAAC,CAAC;CACjB"}
@@ -0,0 +1,71 @@
1
+ /**
2
+ * Connector-neutral command catalog.
3
+ *
4
+ * The text command registry (`registry.ts`) describes the agent's slash
5
+ * capabilities; `navigation-commands.ts` describes the app's navigation/client
6
+ * commands. Both are `CommandDefinition`s now, so the catalog treats them
7
+ * uniformly: it unions them, dedupes (navigation wins name collisions), filters
8
+ * by surface (`surfaces`) and active view (`views`), and projects onto either:
9
+ *
10
+ * - `ConnectorCommand` — the shape a connector (Discord, Telegram, …) maps
11
+ * onto its native command surface (`getConnectorCommands`), or
12
+ * - `SerializedCommand` — the wire shape `GET /api/commands` serves the web
13
+ * composer / TUI (`getCatalogCommands`), via `serializeCommand`.
14
+ *
15
+ * Each command declares a `target` discriminating where it executes (`agent` /
16
+ * `navigate` / `client`). `ConnectorCommand` options carry a fully-resolved
17
+ * `choices: string[]` so connectors never evaluate function-valued choices.
18
+ */
19
+ import type { CommandTarget, SerializedCommand, SerializedCommandSource } from "./types";
20
+ export type { ClientCommandAction, CommandTarget } from "./types";
21
+ export type ConnectorCommandTarget = CommandTarget;
22
+ /** A single argument of a connector command. */
23
+ export interface ConnectorCommandOption {
24
+ name: string;
25
+ description: string;
26
+ required: boolean;
27
+ /** Resolved choice values; empty when the option is free-form. */
28
+ choices: string[];
29
+ }
30
+ /** A connector-neutral command ready to map onto a native command surface. */
31
+ export interface ConnectorCommand {
32
+ name: string;
33
+ description: string;
34
+ target: CommandTarget;
35
+ options: ConnectorCommandOption[];
36
+ /**
37
+ * View ids this command is scoped to (#8798): present only while one of these
38
+ * views is the active surface. Omitted = globally available.
39
+ */
40
+ views?: string[];
41
+ }
42
+ /**
43
+ * Whether a command with the given `views` scoping is visible for the active
44
+ * view. Global commands (no `views`, or an empty list) are always visible;
45
+ * view-scoped commands appear only when their view is foreground. (#8798)
46
+ */
47
+ export declare function commandVisibleForView(views: readonly string[] | undefined, activeViewId: string | null | undefined): boolean;
48
+ /**
49
+ * Build the connector command catalog for a given surface (Discord, Telegram, …).
50
+ *
51
+ * @param surface "gui" | "tui" | "discord" | "telegram".
52
+ * @param options.activeViewId when set, view-scoped commands (#8798) are
53
+ * included only if this is one of their views; global commands always appear.
54
+ * When unset, view-scoped commands are filtered out entirely.
55
+ */
56
+ export declare function getConnectorCommands(surface: string, options?: {
57
+ activeViewId?: string | null;
58
+ agentId?: string | null;
59
+ }): ConnectorCommand[];
60
+ /**
61
+ * Build the wire-safe catalog (`SerializedCommand[]`) served by
62
+ * `GET /api/commands`. This is the pure projection: surface- and view-filtered
63
+ * unified definitions, each run through `serializeCommand` so `surfaces`, auth
64
+ * flags, `category`, `dynamicChoices`, and `icon` all survive intact.
65
+ */
66
+ export declare function getCatalogCommands(surface: string, options?: {
67
+ activeViewId?: string | null;
68
+ agentId?: string | null;
69
+ source?: SerializedCommandSource;
70
+ }): SerializedCommand[];
71
+ //# sourceMappingURL=connector-catalog.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"connector-catalog.d.ts","sourceRoot":"","sources":["../../src/connector-catalog.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAKH,OAAO,KAAK,EAGX,aAAa,EACb,iBAAiB,EACjB,uBAAuB,EACvB,MAAM,SAAS,CAAC;AAIjB,YAAY,EAAE,mBAAmB,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAClE,MAAM,MAAM,sBAAsB,GAAG,aAAa,CAAC;AAEnD,gDAAgD;AAChD,MAAM,WAAW,sBAAsB;IACtC,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,OAAO,CAAC;IAClB,kEAAkE;IAClE,OAAO,EAAE,MAAM,EAAE,CAAC;CAClB;AAED,8EAA8E;AAC9E,MAAM,WAAW,gBAAgB;IAChC,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,aAAa,CAAC;IACtB,OAAO,EAAE,sBAAsB,EAAE,CAAC;IAClC;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;CACjB;AASD;;;;GAIG;AACH,wBAAgB,qBAAqB,CACpC,KAAK,EAAE,SAAS,MAAM,EAAE,GAAG,SAAS,EACpC,YAAY,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GACrC,OAAO,CAIT;AA0ED;;;;;;;GAOG;AACH,wBAAgB,oBAAoB,CACnC,OAAO,EAAE,MAAM,EACf,OAAO,GAAE;IAAE,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;CAAO,GACrE,gBAAgB,EAAE,CAIpB;AAED;;;;;GAKG;AACH,wBAAgB,kBAAkB,CACjC,OAAO,EAAE,MAAM,EACf,OAAO,GAAE;IACR,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,MAAM,CAAC,EAAE,uBAAuB,CAAC;CAC5B,GACJ,iBAAiB,EAAE,CAQrB"}
@@ -0,0 +1,68 @@
1
+ /**
2
+ * Plugin Commands - Chat command system for Eliza agents
3
+ *
4
+ * Provides a slash-command system with:
5
+ * - /help, /status, /commands for information
6
+ * - /stop, /reset, /compact for session control
7
+ * - /think, /verbose, /model for options
8
+ * - /allowlist, /approve for management
9
+ * - /tts for media
10
+ * - /bash for tools (elevated)
11
+ *
12
+ * INTEGRATION NOTES:
13
+ * - Commands are registered as Actions with strict validate() that only
14
+ * matches slash-prefixed messages (e.g. /help, !stop). This prevents
15
+ * conflicts with bootstrap actions (STATUS, IGNORE) and messaging plugins.
16
+ * - Similes use ONLY slash-command forms (no natural language) so the LLM
17
+ * won't accidentally route "I need help" to HELP_COMMAND instead of REPLY.
18
+ * - The registry is scoped per runtime to prevent cross-agent state leaks.
19
+ * - The COMMAND_REGISTRY provider includes the command list in the LLM context
20
+ * ONLY when the message is a command, reducing prompt noise for normal messages.
21
+ */
22
+ import { type Plugin, type Provider } from "@elizaos/core";
23
+ import type { CommandContext, CommandDefinition, CommandResult } from "./types";
24
+ export * from "./actions";
25
+ export * from "./connector-bridge";
26
+ export * from "./connector-catalog";
27
+ export * from "./navigation-commands";
28
+ export * from "./parser";
29
+ export * from "./registry";
30
+ export * from "./serialize";
31
+ export * from "./settings-sections";
32
+ export * from "./types";
33
+ /**
34
+ * Provider that exposes available commands to the LLM context.
35
+ *
36
+ * Only injects the full command list when the message looks like a command.
37
+ * For normal messages, returns a minimal hint so the LLM knows commands
38
+ * exist but doesn't get a wall of command documentation in its context.
39
+ */
40
+ export declare const commandRegistryProvider: Provider;
41
+ /**
42
+ * Format command result for display
43
+ */
44
+ export declare function formatCommandResult(result: CommandResult): string;
45
+ /**
46
+ * Check if a sender is authorized
47
+ */
48
+ export declare function isAuthorized(context: CommandContext, command: CommandDefinition): boolean;
49
+ /**
50
+ * Check if a sender has elevated permissions
51
+ */
52
+ export declare function isElevated(context: CommandContext, command: CommandDefinition): boolean;
53
+ /**
54
+ * Plugin Commands
55
+ *
56
+ * Provides chat commands as Eliza actions. Commands are detected
57
+ * by their text aliases (e.g., /help, /status) and executed as actions.
58
+ *
59
+ * Design decisions for messaging integration:
60
+ * 1. Actions use strict validate() — only true for slash-prefixed messages
61
+ * 2. Similes are slash-only — no natural language to prevent LLM misrouting
62
+ * 3. Provider is context-aware — full docs for commands, empty for normal msgs
63
+ * 4. Registry is scoped per agentId — no cross-agent contamination
64
+ * 5. Events use proper EventType enums — not raw strings
65
+ */
66
+ export declare const commandsPlugin: Plugin;
67
+ export default commandsPlugin;
68
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,EAIN,KAAK,MAAM,EACX,KAAK,QAAQ,EAGb,MAAM,eAAe,CAAC;AAevB,OAAO,KAAK,EAAE,cAAc,EAAE,iBAAiB,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAIhF,cAAc,WAAW,CAAC;AAG1B,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC;AACpC,cAAc,uBAAuB,CAAC;AACtC,cAAc,UAAU,CAAC;AACzB,cAAc,YAAY,CAAC;AAE3B,cAAc,aAAa,CAAC;AAC5B,cAAc,qBAAqB,CAAC;AAEpC,cAAc,SAAS,CAAC;AAExB;;;;;;GAMG;AACH,eAAO,MAAM,uBAAuB,EAAE,QA+CrC,CAAC;AAEF;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,aAAa,GAAG,MAAM,CAKjE;AAED;;GAEG;AACH,wBAAgB,YAAY,CAC3B,OAAO,EAAE,cAAc,EACvB,OAAO,EAAE,iBAAiB,GACxB,OAAO,CAKT;AAED;;GAEG;AACH,wBAAgB,UAAU,CACzB,OAAO,EAAE,cAAc,EACvB,OAAO,EAAE,iBAAiB,GACxB,OAAO,CAKT;AAED;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,cAAc,EAAE,MAkO5B,CAAC;AAEF,eAAe,cAAc,CAAC"}
@@ -0,0 +1,28 @@
1
+ /**
2
+ * Navigation + client commands as first-class `CommandDefinition`s.
3
+ *
4
+ * These used to be defined inline in `connector-catalog.ts` as bare
5
+ * `ConnectorCommand`s, which meant they could not carry `surfaces`, auth flags,
6
+ * `category`, or flow through `serializeCommand` like agent commands do (#8790).
7
+ * Defining them as `CommandDefinition`s with an explicit `target` and `surfaces`
8
+ * lets the catalog treat agent / navigate / client commands uniformly:
9
+ *
10
+ * - `navigate` commands open a destination in the Eliza app; `path` is the
11
+ * in-app deep link a connector advertises, `tab`/`viewId`/`section` are the
12
+ * routing hints the GUI/TUI use to open it deterministically. Offered on
13
+ * every surface (chat connectors reply with the deep link).
14
+ * - `client` commands run a GUI/TUI-only behavior with no remote surface, so
15
+ * they declare `surfaces: ["gui", "tui"]` and are filtered off chat
16
+ * connectors by surface, not by an ad-hoc branch.
17
+ *
18
+ * The `path`/`tab` values mirror the canonical route table in `@elizaos/ui`
19
+ * (`navigation/index.ts` `TAB_PATHS`); keep them in sync there.
20
+ */
21
+ import type { CommandDefinition } from "./types";
22
+ /**
23
+ * Navigation + client commands the app surfaces in addition to the agent
24
+ * capabilities from the text command registry. Returns a fresh array so callers
25
+ * can't mutate the shared definitions.
26
+ */
27
+ export declare function navigationCommandDefinitions(): CommandDefinition[];
28
+ //# sourceMappingURL=navigation-commands.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"navigation-commands.d.ts","sourceRoot":"","sources":["../../src/navigation-commands.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAGH,OAAO,KAAK,EAAE,iBAAiB,EAAkB,MAAM,SAAS,CAAC;AAmRjE;;;;GAIG;AACH,wBAAgB,4BAA4B,IAAI,iBAAiB,EAAE,CAElE"}
@@ -0,0 +1,32 @@
1
+ /**
2
+ * Command parser - detects and parses commands from message text
3
+ */
4
+ import type { CommandDefinition, CommandDetectionResult, ParsedCommand } from "./types";
5
+ /**
6
+ * Check if text contains a command
7
+ */
8
+ export declare function hasCommand(text: string): boolean;
9
+ /**
10
+ * Detect command in text
11
+ */
12
+ export declare function detectCommand(text: string): CommandDetectionResult;
13
+ /**
14
+ * Parse a command from text
15
+ */
16
+ export declare function parseCommand(text: string, definition: CommandDefinition): ParsedCommand | null;
17
+ /**
18
+ * Normalize command body (handle bot mentions, colon syntax, etc.)
19
+ */
20
+ export declare function normalizeCommandBody(text: string, botMention?: string): string;
21
+ /**
22
+ * Check if text is a command-only message (no other content)
23
+ */
24
+ export declare function isCommandOnly(text: string): boolean;
25
+ /**
26
+ * Get command and remaining text
27
+ */
28
+ export declare function extractCommand(text: string): {
29
+ command: ParsedCommand;
30
+ remainingText: string;
31
+ } | null;
32
+ //# sourceMappingURL=parser.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parser.d.ts","sourceRoot":"","sources":["../../src/parser.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,KAAK,EACX,iBAAiB,EACjB,sBAAsB,EACtB,aAAa,EACb,MAAM,SAAS,CAAC;AAKjB;;GAEG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAKhD;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,sBAAsB,CAuBlE;AAED;;GAEG;AACH,wBAAgB,YAAY,CAC3B,IAAI,EAAE,MAAM,EACZ,UAAU,EAAE,iBAAiB,GAC3B,aAAa,GAAG,IAAI,CA6CtB;AA+ED;;GAEG;AACH,wBAAgB,oBAAoB,CACnC,IAAI,EAAE,MAAM,EACZ,UAAU,CAAC,EAAE,MAAM,GACjB,MAAM,CAaR;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAanD;AAED;;GAEG;AACH,wBAAgB,cAAc,CAC7B,IAAI,EAAE,MAAM,GACV;IAAE,OAAO,EAAE,aAAa,CAAC;IAAC,aAAa,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CAc1D"}
@@ -0,0 +1,66 @@
1
+ /**
2
+ * Command registry - defines all available chat commands
3
+ *
4
+ * IMPORTANT: The registry uses module-level state for convenience, but
5
+ * provides `cloneCommands()` and `resetCommands()` so that `init()` can
6
+ * work on isolated copies per runtime. The `init()` function in the main
7
+ * plugin file should clone before mutating to avoid cross-agent contamination.
8
+ */
9
+ import type { CommandDefinition } from "./types";
10
+ export declare const DEFAULT_COMMANDS: ReadonlyArray<CommandDefinition>;
11
+ /**
12
+ * Initialize an isolated command store for a specific runtime.
13
+ * Called from plugin init() to prevent cross-agent contamination.
14
+ */
15
+ export declare function initForRuntime(agentId: string): void;
16
+ /**
17
+ * Set the active command store for a given runtime.
18
+ * Providers and actions should call this before accessing commands.
19
+ */
20
+ export declare function useRuntime(agentId: string): void;
21
+ /**
22
+ * Get all registered commands
23
+ */
24
+ export declare function getCommands(): CommandDefinition[];
25
+ /**
26
+ * Get enabled commands
27
+ */
28
+ export declare function getEnabledCommands(): CommandDefinition[];
29
+ /**
30
+ * Get commands by category
31
+ */
32
+ export declare function getCommandsByCategory(category: string): CommandDefinition[];
33
+ /**
34
+ * Register a custom command
35
+ */
36
+ export declare function registerCommand(command: CommandDefinition): void;
37
+ /**
38
+ * Register multiple commands
39
+ */
40
+ export declare function registerCommands(newCommands: CommandDefinition[]): void;
41
+ /**
42
+ * Unregister a command
43
+ */
44
+ export declare function unregisterCommand(key: string): void;
45
+ /**
46
+ * Reset to default commands (for the active store)
47
+ */
48
+ export declare function resetCommands(): void;
49
+ /**
50
+ * Find command by alias
51
+ */
52
+ export declare function findCommandByAlias(alias: string): CommandDefinition | undefined;
53
+ /**
54
+ * Find command by key
55
+ */
56
+ export declare function findCommandByKey(key: string): CommandDefinition | undefined;
57
+ /**
58
+ * Check if text starts with any command alias
59
+ */
60
+ export declare function startsWithCommand(text: string): CommandDefinition | undefined;
61
+ export declare function getCommandsForRuntime(agentId?: string | null): CommandDefinition[];
62
+ export declare function getEnabledCommandsForRuntime(agentId?: string | null): CommandDefinition[];
63
+ export declare function getCommandsByCategoryForRuntime(category: string, agentId?: string | null): CommandDefinition[];
64
+ export declare function findCommandByAliasForRuntime(alias: string, agentId?: string | null): CommandDefinition | undefined;
65
+ export declare function findCommandByKeyForRuntime(key: string, agentId?: string | null): CommandDefinition | undefined;
66
+ //# sourceMappingURL=registry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../src/registry.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAGjD,eAAO,MAAM,gBAAgB,EAAE,aAAa,CAAC,iBAAiB,CAqT7D,CAAC;AAwBF;;;GAGG;AACH,wBAAgB,cAAc,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAOpD;AAED;;;GAGG;AACH,wBAAgB,UAAU,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAEhD;AAED;;GAEG;AACH,wBAAgB,WAAW,IAAI,iBAAiB,EAAE,CAEjD;AAED;;GAEG;AACH,wBAAgB,kBAAkB,IAAI,iBAAiB,EAAE,CAExD;AAED;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,QAAQ,EAAE,MAAM,GAAG,iBAAiB,EAAE,CAI3E;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,iBAAiB,GAAG,IAAI,CAOhE;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,WAAW,EAAE,iBAAiB,EAAE,GAAG,IAAI,CAIvE;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAGnD;AAED;;GAEG;AACH,wBAAgB,aAAa,IAAI,IAAI,CAGpC;AAsBD;;GAEG;AACH,wBAAgB,kBAAkB,CACjC,KAAK,EAAE,MAAM,GACX,iBAAiB,GAAG,SAAS,CAG/B;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,MAAM,GAAG,iBAAiB,GAAG,SAAS,CAE3E;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,iBAAiB,GAAG,SAAS,CAgB7E;AAuCD,wBAAgB,qBAAqB,CACpC,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,GACrB,iBAAiB,EAAE,CAErB;AAED,wBAAgB,4BAA4B,CAC3C,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,GACrB,iBAAiB,EAAE,CAErB;AAED,wBAAgB,+BAA+B,CAC9C,QAAQ,EAAE,MAAM,EAChB,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,GACrB,iBAAiB,EAAE,CAErB;AAED,wBAAgB,4BAA4B,CAC3C,KAAK,EAAE,MAAM,EACb,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,GACrB,iBAAiB,GAAG,SAAS,CAI/B;AAED,wBAAgB,0BAA0B,CACzC,GAAG,EAAE,MAAM,EACX,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,GACrB,iBAAiB,GAAG,SAAS,CAE/B"}
@@ -0,0 +1,30 @@
1
+ /**
2
+ * Canonical command serialization.
3
+ *
4
+ * `serializeCommand` is the single projection from a `CommandDefinition` onto
5
+ * the wire-safe `SerializedCommand` shape every client consumes (web composer,
6
+ * TUI autocomplete, connector bridges). The `GET /api/commands` route is a pure
7
+ * pass-through of this function — it fabricates nothing. This is what closes the
8
+ * "catalog contract dropped at the route" gap (#8790): `surfaces`, auth flags,
9
+ * `category`, real `dynamicChoices`, `icon`, and the full `textAliases` all
10
+ * survive instead of being hardcoded to `false`/`"both"`/`"builtin"`.
11
+ */
12
+ import type { CommandDefinition, CommandSurface, SerializedCommand, SerializedCommandSource } from "./types";
13
+ /**
14
+ * Whether a command is offered on `surface`. A definition with no `surfaces`
15
+ * is offered everywhere (the default). When `surface` is omitted the command is
16
+ * always included (the catalog query is surface-agnostic).
17
+ */
18
+ export declare function commandVisibleForSurface(surfaces: readonly CommandSurface[] | undefined, surface: CommandSurface | null | undefined): boolean;
19
+ /**
20
+ * Serialize a `CommandDefinition` onto the canonical `SerializedCommand` wire
21
+ * shape. Every field is read from the definition — nothing is fabricated.
22
+ *
23
+ * @param command the registry definition.
24
+ * @param options.source where the item came from (default `"builtin"`); skills
25
+ * pass `"custom-action"`/`"saved"` so the menu can group/label them.
26
+ */
27
+ export declare function serializeCommand(command: CommandDefinition, options?: {
28
+ source?: SerializedCommandSource;
29
+ }): SerializedCommand;
30
+ //# sourceMappingURL=serialize.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"serialize.d.ts","sourceRoot":"","sources":["../../src/serialize.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,EAEX,iBAAiB,EACjB,cAAc,EACd,iBAAiB,EAEjB,uBAAuB,EACvB,MAAM,SAAS,CAAC;AAKjB;;;;GAIG;AACH,wBAAgB,wBAAwB,CACvC,QAAQ,EAAE,SAAS,cAAc,EAAE,GAAG,SAAS,EAC/C,OAAO,EAAE,cAAc,GAAG,IAAI,GAAG,SAAS,GACxC,OAAO,CAIT;AAmBD;;;;;;;GAOG;AACH,wBAAgB,gBAAgB,CAC/B,OAAO,EAAE,iBAAiB,EAC1B,OAAO,GAAE;IAAE,MAAM,CAAC,EAAE,uBAAuB,CAAA;CAAO,GAChD,iBAAiB,CAwBnB"}
@@ -0,0 +1,32 @@
1
+ /**
2
+ * Settings sections — the canonical destinations the `/settings <section>`
3
+ * command can open in the Eliza app.
4
+ *
5
+ * Each section has a stable `id` (the canonical token connectors advertise and
6
+ * the app routes on), a human `label`, and optional `aliases` that map common
7
+ * synonyms onto the canonical id. `resolveSettingsSection` turns any raw token
8
+ * (id or alias) into its canonical id.
9
+ */
10
+ export interface SettingsSection {
11
+ /** Canonical, stable section id used for routing and as the choice token. */
12
+ id: string;
13
+ /** Human-readable label for display. */
14
+ label: string;
15
+ /** Alternate tokens that resolve to this section. */
16
+ aliases?: string[];
17
+ }
18
+ /** All canonical section ids, in declaration order. */
19
+ export declare function getSettingsSections(): SettingsSection[];
20
+ /**
21
+ * Canonical section ids, usable directly as connector option choices.
22
+ *
23
+ * Returns ids only (not aliases) so the choice list stays small and stable; the
24
+ * count is well under Discord's 25-choice cap.
25
+ */
26
+ export declare function getSettingsSectionChoices(): string[];
27
+ /**
28
+ * Resolve a raw `/settings` section token (canonical id or alias) to its
29
+ * canonical section id. Returns `undefined` when the token matches nothing.
30
+ */
31
+ export declare function resolveSettingsSection(raw: string): string | undefined;
32
+ //# sourceMappingURL=settings-sections.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"settings-sections.d.ts","sourceRoot":"","sources":["../../src/settings-sections.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,MAAM,WAAW,eAAe;IAC/B,6EAA6E;IAC7E,EAAE,EAAE,MAAM,CAAC;IACX,wCAAwC;IACxC,KAAK,EAAE,MAAM,CAAC;IACd,qDAAqD;IACrD,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;CACnB;AAqCD,uDAAuD;AACvD,wBAAgB,mBAAmB,IAAI,eAAe,EAAE,CAEvD;AAED;;;;;GAKG;AACH,wBAAgB,yBAAyB,IAAI,MAAM,EAAE,CAEpD;AAED;;;GAGG;AACH,wBAAgB,sBAAsB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAItE"}