@alisio/core 0.1.0-alpha.17 → 0.1.0-alpha.19
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/agents/active.d.ts +66 -0
- package/dist/agents/active.js +113 -0
- package/dist/application.d.ts +12 -3
- package/dist/application.js +25 -5
- package/dist/commands/builtins.d.ts +10 -0
- package/dist/commands/builtins.js +122 -0
- package/dist/commands/catalog.d.ts +86 -0
- package/dist/commands/catalog.js +292 -0
- package/dist/config.d.ts +7 -0
- package/dist/config.js +27 -0
- package/dist/core/contracts.d.ts +109 -2
- package/dist/core/runner.d.ts +21 -0
- package/dist/core/runner.js +73 -12
- package/dist/index.d.ts +9 -4
- package/dist/index.js +8 -3
- package/dist/mcp/rich.js +68 -0
- package/dist/plugins/host.d.ts +4 -0
- package/dist/plugins/host.js +22 -8
- package/dist/providers/settings.d.ts +15 -0
- package/dist/providers/settings.js +38 -0
- package/dist/runtime/blobs.d.ts +29 -0
- package/dist/runtime/blobs.js +94 -0
- package/dist/runtime/diff.d.ts +23 -0
- package/dist/runtime/diff.js +154 -0
- package/dist/runtime/store.d.ts +75 -3
- package/dist/runtime/store.js +309 -11
- package/dist/sessions/side-questions.d.ts +57 -0
- package/dist/sessions/side-questions.js +161 -0
- package/dist/tools/standard.js +59 -9
- package/package.json +2 -2
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pure logic for the ACTIVE (main-session) agent: the built-in catalog, user/plugin
|
|
3
|
+
* contributions, resolution and the per-run options an agent implies. No terminal or pi-tui
|
|
4
|
+
* imports here — the Picker and status-line rendering live in each surface (e.g. the TUI shell).
|
|
5
|
+
*
|
|
6
|
+
* The active agent drives the MAIN session (its `instructions` are appended per run and an
|
|
7
|
+
* agent-specific `model` is offered on selection). This is deliberately separate from the
|
|
8
|
+
* delegated child-session agents of the subagents plugin: a subagent definition becomes a main
|
|
9
|
+
* agent only when it is marked main-capable (`mode: primary|all`), which the subagents plugin
|
|
10
|
+
* publishes for the host to read.
|
|
11
|
+
*/
|
|
12
|
+
export interface ActiveAgent {
|
|
13
|
+
/** Stable id, also the persisted `agents.active` value. */
|
|
14
|
+
id: string;
|
|
15
|
+
name: string;
|
|
16
|
+
description: string;
|
|
17
|
+
/** System prompt appended to the main session's instructions on every run. */
|
|
18
|
+
instructions?: string;
|
|
19
|
+
/** Optional default model selector (`provider/model` or an unambiguous model id). */
|
|
20
|
+
model?: string;
|
|
21
|
+
/** Read-only agents run with write/process/external tools disabled and approvals off. */
|
|
22
|
+
readOnly?: boolean;
|
|
23
|
+
/** Product built-ins are shown as built-in and never shadowed by contributed definitions. */
|
|
24
|
+
source: "builtin" | "user" | "plugin";
|
|
25
|
+
}
|
|
26
|
+
export declare const DEFAULT_AGENT_ID = "build";
|
|
27
|
+
/** Product built-ins. `build` keeps the CURRENT behavior exactly: no added persona, full power. */
|
|
28
|
+
export declare const BUILTIN_AGENTS: ActiveAgent[];
|
|
29
|
+
export interface MainCapableAgentRecord {
|
|
30
|
+
name: string;
|
|
31
|
+
description: string;
|
|
32
|
+
prompt: string;
|
|
33
|
+
model?: string;
|
|
34
|
+
readOnly?: boolean;
|
|
35
|
+
source: string;
|
|
36
|
+
path?: string;
|
|
37
|
+
}
|
|
38
|
+
/** Maps a main-capable definition published by the subagents plugin to an active agent. */
|
|
39
|
+
export declare function mainAgentFromRecord(record: MainCapableAgentRecord): ActiveAgent;
|
|
40
|
+
/** Builds the selectable catalog from the subagents plugin's published state (best-effort). */
|
|
41
|
+
export declare function agentCatalogFromState(untrusted: unknown): ActiveAgent[];
|
|
42
|
+
/**
|
|
43
|
+
* The full selectable catalog: built-ins first, then contributed main-capable definitions.
|
|
44
|
+
* A contributed definition may never shadow a built-in id; later duplicates of a contributed id
|
|
45
|
+
* are dropped (the subagents plugin already resolved precedence by its own discovery order).
|
|
46
|
+
*/
|
|
47
|
+
export declare function activeAgentCatalog(contributions?: ActiveAgent[]): ActiveAgent[];
|
|
48
|
+
/** Resolves the persisted agent id; unknown ids fall back to the built-in default (`build`). */
|
|
49
|
+
export declare function resolveActiveAgent(agents: ActiveAgent[], id: string | undefined): ActiveAgent;
|
|
50
|
+
/** The run options an active agent implies. An undefined agent yields the current behavior. */
|
|
51
|
+
export declare function agentRunOptions(agent: ActiveAgent | undefined): {
|
|
52
|
+
instructions?: string;
|
|
53
|
+
policy?: {
|
|
54
|
+
write: false;
|
|
55
|
+
process: false;
|
|
56
|
+
external: false;
|
|
57
|
+
};
|
|
58
|
+
approvals?: false;
|
|
59
|
+
};
|
|
60
|
+
export interface AgentPickerItem {
|
|
61
|
+
value: string;
|
|
62
|
+
label: string;
|
|
63
|
+
description: string;
|
|
64
|
+
}
|
|
65
|
+
/** Picker rows for `/agents`: name with (current), built-in/default and read-only markers. */
|
|
66
|
+
export declare function agentPickerItems(agents: ActiveAgent[], activeId: string): AgentPickerItem[];
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
export const DEFAULT_AGENT_ID = "build";
|
|
2
|
+
const PLAN_INSTRUCTIONS = `You are the "plan" agent: a read-only planning assistant for this main session.
|
|
3
|
+
|
|
4
|
+
Your job is analysis and planning only. Investigate the repository with read-only tools
|
|
5
|
+
(list_files, search_text, read_file, git_status, git_diff) and return a concrete, ordered plan:
|
|
6
|
+
files to change, functions to touch, risks and verification steps. You may run context and
|
|
7
|
+
inspection tools that do not modify anything.
|
|
8
|
+
|
|
9
|
+
You never edit, write or delete files, and you never start processes that change the workspace
|
|
10
|
+
or the network. If a task requires changes, hand back a precise plan (and the exact commands)
|
|
11
|
+
instead of making them.`;
|
|
12
|
+
/** Product built-ins. `build` keeps the CURRENT behavior exactly: no added persona, full power. */
|
|
13
|
+
export const BUILTIN_AGENTS = [
|
|
14
|
+
{
|
|
15
|
+
id: DEFAULT_AGENT_ID,
|
|
16
|
+
name: "build",
|
|
17
|
+
description: "Default full-power agent: edits code and files, runs processes and verifies its work through the normal permission flow.",
|
|
18
|
+
source: "builtin",
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
id: "plan",
|
|
22
|
+
name: "plan",
|
|
23
|
+
description: "Read-only planning agent: analyzes the codebase and returns an implementation plan without modifying anything.",
|
|
24
|
+
instructions: PLAN_INSTRUCTIONS,
|
|
25
|
+
readOnly: true,
|
|
26
|
+
source: "builtin",
|
|
27
|
+
},
|
|
28
|
+
];
|
|
29
|
+
/** Maps a main-capable definition published by the subagents plugin to an active agent. */
|
|
30
|
+
export function mainAgentFromRecord(record) {
|
|
31
|
+
const source = String(record.source ?? "");
|
|
32
|
+
return {
|
|
33
|
+
id: record.name,
|
|
34
|
+
name: record.name,
|
|
35
|
+
description: record.description,
|
|
36
|
+
...(record.prompt ? { instructions: record.prompt } : {}),
|
|
37
|
+
...(record.model ? { model: record.model } : {}),
|
|
38
|
+
...(record.readOnly ? { readOnly: true } : {}),
|
|
39
|
+
...(source.startsWith("plugin:")
|
|
40
|
+
? { source: "plugin" }
|
|
41
|
+
: { source: "user" }),
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
/** Builds the selectable catalog from the subagents plugin's published state (best-effort). */
|
|
45
|
+
export function agentCatalogFromState(untrusted) {
|
|
46
|
+
if (!Array.isArray(untrusted))
|
|
47
|
+
return activeAgentCatalog([]);
|
|
48
|
+
const records = untrusted.filter((entry) => !!entry &&
|
|
49
|
+
typeof entry === "object" &&
|
|
50
|
+
typeof entry.name === "string" &&
|
|
51
|
+
typeof entry.description === "string" &&
|
|
52
|
+
entry.description.length > 0 &&
|
|
53
|
+
typeof entry.prompt === "string");
|
|
54
|
+
return activeAgentCatalog(records.map(mainAgentFromRecord));
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* The full selectable catalog: built-ins first, then contributed main-capable definitions.
|
|
58
|
+
* A contributed definition may never shadow a built-in id; later duplicates of a contributed id
|
|
59
|
+
* are dropped (the subagents plugin already resolved precedence by its own discovery order).
|
|
60
|
+
*/
|
|
61
|
+
export function activeAgentCatalog(contributions = []) {
|
|
62
|
+
const seen = new Set();
|
|
63
|
+
const out = [];
|
|
64
|
+
for (const agent of [...BUILTIN_AGENTS, ...contributions]) {
|
|
65
|
+
if (seen.has(agent.id))
|
|
66
|
+
continue;
|
|
67
|
+
seen.add(agent.id);
|
|
68
|
+
out.push(agent);
|
|
69
|
+
}
|
|
70
|
+
return out;
|
|
71
|
+
}
|
|
72
|
+
/** Resolves the persisted agent id; unknown ids fall back to the built-in default (`build`). */
|
|
73
|
+
export function resolveActiveAgent(agents, id) {
|
|
74
|
+
const found = id ? agents.find((a) => a.id === id) : undefined;
|
|
75
|
+
if (found)
|
|
76
|
+
return found;
|
|
77
|
+
return agents.find((a) => a.id === DEFAULT_AGENT_ID) ?? agents[0] ?? BUILTIN_AGENTS[0];
|
|
78
|
+
}
|
|
79
|
+
/** The run options an active agent implies. An undefined agent yields the current behavior. */
|
|
80
|
+
export function agentRunOptions(agent) {
|
|
81
|
+
if (!agent)
|
|
82
|
+
return {};
|
|
83
|
+
return {
|
|
84
|
+
...(agent.instructions ? { instructions: agent.instructions } : {}),
|
|
85
|
+
...(agent.readOnly
|
|
86
|
+
? {
|
|
87
|
+
policy: { write: false, process: false, external: false },
|
|
88
|
+
approvals: false,
|
|
89
|
+
}
|
|
90
|
+
: {}),
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
/** Picker rows for `/agents`: name with (current), built-in/default and read-only markers. */
|
|
94
|
+
export function agentPickerItems(agents, activeId) {
|
|
95
|
+
return agents.map((agent) => ({
|
|
96
|
+
value: agent.id,
|
|
97
|
+
label: [
|
|
98
|
+
agent.name,
|
|
99
|
+
agent.id === activeId ? "(current)" : undefined,
|
|
100
|
+
agent.id === DEFAULT_AGENT_ID ? "(default)" : undefined,
|
|
101
|
+
agent.readOnly ? "read-only" : undefined,
|
|
102
|
+
]
|
|
103
|
+
.filter(Boolean)
|
|
104
|
+
.join(" · "),
|
|
105
|
+
description: [
|
|
106
|
+
agent.description,
|
|
107
|
+
agent.model ? `default model: ${agent.model}` : undefined,
|
|
108
|
+
agent.instructions ? "injects its system prompt from the next prompt" : undefined,
|
|
109
|
+
]
|
|
110
|
+
.filter(Boolean)
|
|
111
|
+
.join(" · "),
|
|
112
|
+
}));
|
|
113
|
+
}
|
package/dist/application.d.ts
CHANGED
|
@@ -11,7 +11,9 @@ import { ProviderSettingsStore } from "./providers/settings.ts";
|
|
|
11
11
|
import { ProjectContext } from "./resources/context.ts";
|
|
12
12
|
import { Skills } from "./resources/skills.ts";
|
|
13
13
|
import { type ExternalDirectoryHandler, PathAccess } from "./runtime/access.ts";
|
|
14
|
+
import { BlobStore } from "./runtime/blobs.ts";
|
|
14
15
|
import { SQLiteStore } from "./runtime/store.ts";
|
|
16
|
+
import { SideQuestions } from "./sessions/side-questions.ts";
|
|
15
17
|
export interface AppOptions {
|
|
16
18
|
cwd?: string;
|
|
17
19
|
config?: string;
|
|
@@ -117,6 +119,8 @@ export declare function createApplication(options?: AppOptions): Promise<{
|
|
|
117
119
|
template: import("./index.ts").PromptTemplate;
|
|
118
120
|
} | undefined;
|
|
119
121
|
store: SQLiteStore;
|
|
122
|
+
/** Uploaded attachment bytes; resolve a `BlobRef` with `blobs.attachment(ref)` before a run. */
|
|
123
|
+
blobs: BlobStore;
|
|
120
124
|
registry: ToolRegistry;
|
|
121
125
|
context: ProjectContext;
|
|
122
126
|
skills: Skills;
|
|
@@ -159,13 +163,16 @@ export declare function createApplication(options?: AppOptions): Promise<{
|
|
|
159
163
|
* (only when runtime permission was granted). Never includes credentials or command paths.
|
|
160
164
|
*/
|
|
161
165
|
mcpStartupFailures(): string[];
|
|
162
|
-
/**
|
|
166
|
+
/**
|
|
167
|
+
* Host-owned interactive consent boundary: the TUI and the web UI (`alisio serve`, after an
|
|
168
|
+
* explicit confirmation dialog) may grant. Headless callers remain blocked unless flagged.
|
|
169
|
+
*/
|
|
163
170
|
grantMcpRuntimePermission(request: {
|
|
164
|
-
source: "interactive-tui";
|
|
171
|
+
source: "interactive-tui" | "interactive-web";
|
|
165
172
|
confirmed: boolean;
|
|
166
173
|
}): "granted" | "not-granted" | "read-only";
|
|
167
174
|
/** Persist global consent atomically, then grant runtime permission for this process. */
|
|
168
|
-
rememberGlobalMcpConsent(): Promise<void>;
|
|
175
|
+
rememberGlobalMcpConsent(source?: "interactive-tui" | "interactive-web"): Promise<void>;
|
|
169
176
|
/**
|
|
170
177
|
* Clear the persisted global consent atomically and drop the runtime permission (disconnecting
|
|
171
178
|
* servers as cleanup does). An explicit this-run `--allow-mcp` flag keeps the grant alive.
|
|
@@ -203,6 +210,8 @@ export declare function createApplication(options?: AppOptions): Promise<{
|
|
|
203
210
|
profileName: undefined;
|
|
204
211
|
} | undefined;
|
|
205
212
|
runner: AgentRunner;
|
|
213
|
+
/** `/btw` side questions: tool-less answers about a session outside its conversation. */
|
|
214
|
+
sideQuestions: SideQuestions;
|
|
206
215
|
herdr: HerdrBridge;
|
|
207
216
|
contextWindow: (model: string) => number | undefined;
|
|
208
217
|
/** Effective context budget + compaction point shared by the runner and the TUI bar. */
|
package/dist/application.js
CHANGED
|
@@ -15,10 +15,12 @@ import { ProjectContext } from "./resources/context.js";
|
|
|
15
15
|
import { expandSlashPrompt, loadPromptTemplates, promptSources } from "./resources/prompts.js";
|
|
16
16
|
import { Skills, skillRoots } from "./resources/skills.js";
|
|
17
17
|
import { PathAccess } from "./runtime/access.js";
|
|
18
|
+
import { BlobStore } from "./runtime/blobs.js";
|
|
18
19
|
import { isPathSpec } from "./runtime/modules.js";
|
|
19
20
|
import { findWorkspace } from "./runtime/paths.js";
|
|
20
21
|
import { SQLiteStore } from "./runtime/store.js";
|
|
21
22
|
import { ChildSessions } from "./sessions/children.js";
|
|
23
|
+
import { SideQuestions } from "./sessions/side-questions.js";
|
|
22
24
|
const delay = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
23
25
|
/**
|
|
24
26
|
* Cap per teardown stage of `app.close()`: exit must never wait longer than this on a hanging
|
|
@@ -76,6 +78,13 @@ export async function createApplication(options = {}) {
|
|
|
76
78
|
readOnly: !!options.readOnly,
|
|
77
79
|
});
|
|
78
80
|
const store = new SQLiteStore(options.db ?? join(stateHome(), "sessions.sqlite"));
|
|
81
|
+
// Content-addressed attachment bytes next to the session database (no I/O until `put`).
|
|
82
|
+
const blobs = new BlobStore({
|
|
83
|
+
root: options.db && options.db !== ":memory:"
|
|
84
|
+
? join(dirname(options.db), "blobs")
|
|
85
|
+
: join(stateHome(), "blobs"),
|
|
86
|
+
db: store.db,
|
|
87
|
+
});
|
|
79
88
|
const registry = new ToolRegistry(), skills = new Skills({ overrides: config.skillOverrides }), context = new ProjectContext(workspace, {
|
|
80
89
|
globalDir: configHome(),
|
|
81
90
|
cwd,
|
|
@@ -532,6 +541,10 @@ export async function createApplication(options = {}) {
|
|
|
532
541
|
// Child sessions (generic delegation service for plugins). Contexts are cached per workspace
|
|
533
542
|
// so a child in a git worktree reads that worktree's AGENTS.md files.
|
|
534
543
|
const contexts = new Map([[workspace, context]]);
|
|
544
|
+
// Startup reconciliation: runs left queued/running by a dead process become `interrupted`
|
|
545
|
+
// (runs of this process, e.g. another Application in a server, are kept). Child sessions are
|
|
546
|
+
// reconciled by `interruptStale()` in the ChildSessions constructor right below.
|
|
547
|
+
store.interruptRuns();
|
|
535
548
|
plugins.setSessions(new ChildSessions({
|
|
536
549
|
store,
|
|
537
550
|
runner,
|
|
@@ -605,6 +618,8 @@ export async function createApplication(options = {}) {
|
|
|
605
618
|
prompts,
|
|
606
619
|
expandPrompt,
|
|
607
620
|
store,
|
|
621
|
+
/** Uploaded attachment bytes; resolve a `BlobRef` with `blobs.attachment(ref)` before a run. */
|
|
622
|
+
blobs,
|
|
608
623
|
registry,
|
|
609
624
|
context,
|
|
610
625
|
skills,
|
|
@@ -697,12 +712,15 @@ export async function createApplication(options = {}) {
|
|
|
697
712
|
mcpStartupFailures() {
|
|
698
713
|
return [...mcpStartupFailures];
|
|
699
714
|
},
|
|
700
|
-
/**
|
|
715
|
+
/**
|
|
716
|
+
* Host-owned interactive consent boundary: the TUI and the web UI (`alisio serve`, after an
|
|
717
|
+
* explicit confirmation dialog) may grant. Headless callers remain blocked unless flagged.
|
|
718
|
+
*/
|
|
701
719
|
grantMcpRuntimePermission(request) {
|
|
702
720
|
if (!request.confirmed)
|
|
703
721
|
return mcpRuntimePermission;
|
|
704
|
-
if (request.source !== "interactive-tui")
|
|
705
|
-
throw new Error("MCP runtime permission may only be granted by
|
|
722
|
+
if (request.source !== "interactive-tui" && request.source !== "interactive-web")
|
|
723
|
+
throw new Error("MCP runtime permission may only be granted by an interactive UI");
|
|
706
724
|
if (options.readOnly)
|
|
707
725
|
throw new Error("MCP is unavailable under --read-only");
|
|
708
726
|
if (mcpRuntimePermission === "granted")
|
|
@@ -713,12 +731,12 @@ export async function createApplication(options = {}) {
|
|
|
713
731
|
return mcpRuntimePermission;
|
|
714
732
|
},
|
|
715
733
|
/** Persist global consent atomically, then grant runtime permission for this process. */
|
|
716
|
-
async rememberGlobalMcpConsent() {
|
|
734
|
+
async rememberGlobalMcpConsent(source = "interactive-tui") {
|
|
717
735
|
if (options.readOnly)
|
|
718
736
|
throw new Error("MCP is unavailable under --read-only");
|
|
719
737
|
await setGlobalMcpAllow({ allow: true });
|
|
720
738
|
persistedMcpAllow = true;
|
|
721
|
-
this.grantMcpRuntimePermission({ source
|
|
739
|
+
this.grantMcpRuntimePermission({ source, confirmed: true });
|
|
722
740
|
},
|
|
723
741
|
/**
|
|
724
742
|
* Clear the persisted global consent atomically and drop the runtime permission (disconnecting
|
|
@@ -842,6 +860,8 @@ export async function createApplication(options = {}) {
|
|
|
842
860
|
return providerInfo;
|
|
843
861
|
},
|
|
844
862
|
runner,
|
|
863
|
+
/** `/btw` side questions: tool-less answers about a session outside its conversation. */
|
|
864
|
+
sideQuestions: new SideQuestions({ runner, state: store }),
|
|
845
865
|
herdr,
|
|
846
866
|
contextWindow,
|
|
847
867
|
/** Effective context budget + compaction point shared by the runner and the TUI bar. */
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { CommandDescriptor } from "@alisio/sdk";
|
|
2
|
+
/** A built-in slash command: a descriptor without `source`/`owner` (always `builtin`). */
|
|
3
|
+
export type BuiltinCommand = Omit<CommandDescriptor, "source" | "owner">;
|
|
4
|
+
/**
|
|
5
|
+
* Built-in slash commands, in the order the TUI lists them. Names, aliases, descriptions and
|
|
6
|
+
* argument hints are the TUI's `COMMANDS` moved here as data (the TUI re-exports them).
|
|
7
|
+
* `execution: "core"` commands have a handler in `CommandCatalog.execute`; `surface` commands
|
|
8
|
+
* (clipboard, exit, settings/connect wizards, help, `/ask`) are handled by each UI.
|
|
9
|
+
*/
|
|
10
|
+
export declare const BUILTIN_COMMANDS: readonly BuiltinCommand[];
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
const ALL = ["tui", "web", "api"];
|
|
2
|
+
const TUI = ["tui"];
|
|
3
|
+
const INTERACTIVE = ["tui", "web"];
|
|
4
|
+
/**
|
|
5
|
+
* Built-in slash commands, in the order the TUI lists them. Names, aliases, descriptions and
|
|
6
|
+
* argument hints are the TUI's `COMMANDS` moved here as data (the TUI re-exports them).
|
|
7
|
+
* `execution: "core"` commands have a handler in `CommandCatalog.execute`; `surface` commands
|
|
8
|
+
* (clipboard, exit, settings/connect wizards, help, `/ask`) are handled by each UI.
|
|
9
|
+
*/
|
|
10
|
+
export const BUILTIN_COMMANDS = [
|
|
11
|
+
{
|
|
12
|
+
name: "help",
|
|
13
|
+
description: "Show commands and keys",
|
|
14
|
+
surfaces: INTERACTIVE,
|
|
15
|
+
execution: "surface",
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
name: "connect",
|
|
19
|
+
description: "Configure a provider and choose its active model",
|
|
20
|
+
surfaces: TUI,
|
|
21
|
+
execution: "surface",
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
name: "model",
|
|
25
|
+
description: "Switch provider and model",
|
|
26
|
+
aliases: ["models"],
|
|
27
|
+
surfaces: ALL,
|
|
28
|
+
execution: "core",
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
name: "compact",
|
|
32
|
+
description: "Summarize older history",
|
|
33
|
+
argumentHint: "[focus]",
|
|
34
|
+
surfaces: ALL,
|
|
35
|
+
execution: "core",
|
|
36
|
+
},
|
|
37
|
+
{ name: "stats", description: "Session statistics", surfaces: ALL, execution: "core" },
|
|
38
|
+
{
|
|
39
|
+
name: "clear",
|
|
40
|
+
description: "Start a new session",
|
|
41
|
+
aliases: ["new"],
|
|
42
|
+
surfaces: ALL,
|
|
43
|
+
execution: "core",
|
|
44
|
+
},
|
|
45
|
+
{ name: "sessions", description: "List recent sessions", surfaces: ALL, execution: "core" },
|
|
46
|
+
{
|
|
47
|
+
name: "resume",
|
|
48
|
+
description: "Resume a session by ID or prefix",
|
|
49
|
+
argumentHint: "<id>",
|
|
50
|
+
surfaces: ALL,
|
|
51
|
+
execution: "core",
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
name: "tools",
|
|
55
|
+
description: "List tools and permission state",
|
|
56
|
+
surfaces: ALL,
|
|
57
|
+
execution: "core",
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
name: "plugins",
|
|
61
|
+
description: "Browse and manage project plugins",
|
|
62
|
+
aliases: ["plugin"],
|
|
63
|
+
surfaces: ALL,
|
|
64
|
+
execution: "core",
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
name: "skills",
|
|
68
|
+
description: "Browse and manage effective skills",
|
|
69
|
+
aliases: ["skill"],
|
|
70
|
+
surfaces: ALL,
|
|
71
|
+
execution: "core",
|
|
72
|
+
},
|
|
73
|
+
{ name: "mcp", description: "Browse and manage MCP servers", surfaces: ALL, execution: "core" },
|
|
74
|
+
{
|
|
75
|
+
name: "settings",
|
|
76
|
+
description: "Open the settings menu",
|
|
77
|
+
aliases: ["prefs"],
|
|
78
|
+
surfaces: TUI,
|
|
79
|
+
execution: "surface",
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
name: "copy",
|
|
83
|
+
description: "Copy the last assistant response to the clipboard",
|
|
84
|
+
surfaces: TUI,
|
|
85
|
+
execution: "surface",
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
name: "agents",
|
|
89
|
+
description: "List and switch the active agent (applies from the next prompt)",
|
|
90
|
+
argumentHint: "[<verb>]",
|
|
91
|
+
surfaces: ALL,
|
|
92
|
+
execution: "core",
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
name: "effort",
|
|
96
|
+
description: "Set the reasoning effort level for the active model",
|
|
97
|
+
argumentHint: "[level]",
|
|
98
|
+
surfaces: ALL,
|
|
99
|
+
execution: "core",
|
|
100
|
+
},
|
|
101
|
+
{
|
|
102
|
+
name: "ask",
|
|
103
|
+
description: "Ask the agent to turn your question into a multiple-choice ask_user_question",
|
|
104
|
+
argumentHint: "<question>",
|
|
105
|
+
surfaces: INTERACTIVE,
|
|
106
|
+
execution: "surface",
|
|
107
|
+
},
|
|
108
|
+
{
|
|
109
|
+
name: "btw",
|
|
110
|
+
description: "Ask a side question about the session without adding to the conversation",
|
|
111
|
+
argumentHint: "[question]",
|
|
112
|
+
surfaces: ALL,
|
|
113
|
+
execution: "core",
|
|
114
|
+
},
|
|
115
|
+
{
|
|
116
|
+
name: "exit",
|
|
117
|
+
description: "Exit Alisio",
|
|
118
|
+
aliases: ["quit"],
|
|
119
|
+
surfaces: TUI,
|
|
120
|
+
execution: "surface",
|
|
121
|
+
},
|
|
122
|
+
];
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* One catalog of slash commands for every surface (TUI, web, API): built-ins, plugin commands,
|
|
3
|
+
* prompt templates and skills, with the pure core handlers of `execution: "core"` commands.
|
|
4
|
+
* The catalog reads its sources live from the host on each call, so plugin/template/skill
|
|
5
|
+
* changes show up without rebuilding it.
|
|
6
|
+
*/
|
|
7
|
+
import type { CommandDescriptor, ToolDefinition } from "@alisio/sdk";
|
|
8
|
+
import type { PluginCatalogEntry } from "../application.ts";
|
|
9
|
+
import type { SessionStore } from "../core/contracts.ts";
|
|
10
|
+
import type { AgentRunner } from "../core/runner.ts";
|
|
11
|
+
import type { McpServerInfo } from "../mcp/connector.ts";
|
|
12
|
+
import type { PromptTemplate } from "../resources/prompts.ts";
|
|
13
|
+
import type { SkillCatalogEntry } from "../resources/skills.ts";
|
|
14
|
+
import { type SideQuestions } from "../sessions/side-questions.ts";
|
|
15
|
+
import { BUILTIN_COMMANDS, type BuiltinCommand } from "./builtins.ts";
|
|
16
|
+
export { BUILTIN_COMMANDS, type BuiltinCommand };
|
|
17
|
+
export type CommandSurface = CommandDescriptor["surfaces"][number];
|
|
18
|
+
type PluginCommandHandler = (args: string, context?: {
|
|
19
|
+
sessionId?: string;
|
|
20
|
+
}) => Promise<string>;
|
|
21
|
+
/**
|
|
22
|
+
* What the catalog needs from an application. `createApplication()`'s result satisfies it; the
|
|
23
|
+
* optional members only enable the matching sources and handlers.
|
|
24
|
+
*/
|
|
25
|
+
export interface CommandHost {
|
|
26
|
+
workspace: string;
|
|
27
|
+
store: SessionStore;
|
|
28
|
+
runner: Pick<AgentRunner, "policy" | "approvals" | "compact" | "setModel">;
|
|
29
|
+
registry: {
|
|
30
|
+
list(): ToolDefinition[];
|
|
31
|
+
};
|
|
32
|
+
provider: {
|
|
33
|
+
id: string;
|
|
34
|
+
};
|
|
35
|
+
plugins?: {
|
|
36
|
+
commands: ReadonlyMap<string, PluginCommandHandler>;
|
|
37
|
+
commandInfo: ReadonlyMap<string, {
|
|
38
|
+
plugin: string;
|
|
39
|
+
description?: string;
|
|
40
|
+
argumentHint?: string;
|
|
41
|
+
}>;
|
|
42
|
+
pluginState?(plugin: string, key: string): unknown;
|
|
43
|
+
};
|
|
44
|
+
prompts?: {
|
|
45
|
+
templates: ReadonlyMap<string, PromptTemplate>;
|
|
46
|
+
};
|
|
47
|
+
skillCatalog?(): SkillCatalogEntry[];
|
|
48
|
+
pluginCatalog?(): PluginCatalogEntry[];
|
|
49
|
+
mcp?: {
|
|
50
|
+
list(): McpServerInfo[];
|
|
51
|
+
};
|
|
52
|
+
config?: {
|
|
53
|
+
agents: {
|
|
54
|
+
active?: string;
|
|
55
|
+
effort?: string;
|
|
56
|
+
};
|
|
57
|
+
};
|
|
58
|
+
updateSetting?(key: "agents.effort", value: unknown): Promise<string>;
|
|
59
|
+
/** `/btw` side questions (tool-less, outside the conversation). */
|
|
60
|
+
sideQuestions?: Pick<SideQuestions, "ask" | "history">;
|
|
61
|
+
}
|
|
62
|
+
export interface CommandExecutionContext {
|
|
63
|
+
sessionId: string;
|
|
64
|
+
signal?: AbortSignal;
|
|
65
|
+
}
|
|
66
|
+
export interface CommandResult {
|
|
67
|
+
/** Markdown for the user. */
|
|
68
|
+
text?: string;
|
|
69
|
+
/** `notice` is a short status line; `info` (default) a report. */
|
|
70
|
+
tone?: "info" | "notice";
|
|
71
|
+
/** The session the surface should switch to (`clear`/`new`, `resume`). */
|
|
72
|
+
sessionId?: string;
|
|
73
|
+
/** Structured result for programmatic callers (e.g. a `CompactionResult`). */
|
|
74
|
+
data?: unknown;
|
|
75
|
+
}
|
|
76
|
+
export declare class CommandCatalog {
|
|
77
|
+
private readonly host?;
|
|
78
|
+
constructor(host?: CommandHost | undefined);
|
|
79
|
+
private builtins;
|
|
80
|
+
/** Every descriptor (optionally for one surface). Precedence: builtin > plugin > prompt > skill. */
|
|
81
|
+
list(surface?: CommandSurface): CommandDescriptor[];
|
|
82
|
+
/** A command by name or alias (built-in names and aliases are case-insensitive). */
|
|
83
|
+
resolve(name: string): CommandDescriptor | undefined;
|
|
84
|
+
/** Runs an `execution: "core"` command. Surface commands and unknown names throw. */
|
|
85
|
+
execute(name: string, args: string, ctx: CommandExecutionContext): Promise<CommandResult>;
|
|
86
|
+
}
|