@alisio/sdk 0.1.0-alpha.6 → 0.1.0-alpha.8

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/README.md CHANGED
@@ -1,7 +1,23 @@
1
1
  # @alisio/sdk
2
2
 
3
- The typed plugin contract for [Alisio](https://github.com/GustavoGutierrez/alisio). Types plus two tiny
4
- helpers (`definePlugin`, `textResult`); no runtime dependencies and no provider SDKs.
3
+ **The typed plugin contract for [Alisio](https://github.com/GustavoGutierrez/alisio).** Types plus
4
+ two tiny helpers (`definePlugin`, `textResult`) — no runtime dependencies and no provider SDKs.
5
+
6
+ ## What it is
7
+
8
+ `@alisio/sdk` is what plugins depend on. It declares the `Plugin` and `PluginAPI` shapes, the tool
9
+ and provider contracts, compaction and session hooks, the SQLite storage port and the extension
10
+ points. A plugin ships JavaScript, declares the `alisio-plugin` npm keyword and lists
11
+ `@alisio/sdk` as a peer dependency. Because the package is types-only plus helpers, it is safe to
12
+ import from any runtime Alisio runs on.
13
+
14
+ ## Installation
15
+
16
+ ```sh
17
+ npm i @alisio/sdk # peer dependency of every plugin; use it in devDependencies too
18
+ ```
19
+
20
+ ## Quick start: your first plugin
5
21
 
6
22
  ```ts
7
23
  import { definePlugin, textResult } from "@alisio/sdk";
@@ -24,35 +40,64 @@ export default definePlugin({
24
40
  });
25
41
  ```
26
42
 
43
+ Load it with `alisio --plugin ./dist/index.js` (path) or `alisio install npm:acme-hello` (npm
44
+ package). See [Writing plugins](https://gustavogutierrez.github.io/alisio/plugins) for the full
45
+ walkthrough including tool permissions, naming/prefix rules and an example package.
46
+
47
+ ## The PluginAPI
48
+
49
+ Everything a plugin registers is removed automatically when it unloads; every `register`/`on`
50
+ returns an unregister function.
51
+
52
+ - **tools** — `tools.register(ToolDefinition)`; effects `read | write | process | external |
53
+ internal`, optional `paths()` for write checks, `concurrent` for same-turn parallel calls.
54
+ - **commands** — `commands.register(name, handler, { description?, argumentHint? })`, invoked as
55
+ `/command plugin.id:name args`.
56
+ - **events** — versioned `RunEvent`s (`schemaVersion: 1`).
57
+ - **context** — `context.register(() => Promise<string>)` adds text to the model context.
58
+ - **resources** — `skills(path)`, `prompts(path)`, `agents(path)` and `list(kind)` for skill,
59
+ prompt-template and agent-definition directories.
60
+ - **state** — small per-plugin JSON state persisted in the session database.
61
+ - **compaction** — `compaction.register({ beforeCompact, afterCompact })` contributes instructions,
62
+ extra summarizer output fields, recalled context and reports.
63
+ - **session** — `session.onStart(info)` (text injected on a fresh session) and
64
+ `session.onEnd(info)` (called on `/clear`, `/exit`, quit; bounded by a timeout).
65
+ - **model** — provider-agnostic `model.complete(request)`; plugins never import provider SDKs.
66
+ - **models** — credential-free `models.list()` / `models.resolve(reference)` over configured
67
+ `/connect` profiles.
68
+ - **providers** — `providers.register(registration)` adds a selectable model provider to `/connect`;
69
+ registrations coexist instead of competing.
70
+ - **storage** — `storage.sqlite(path)` opens a private (0600) SQLite file (FTS5 available); the
71
+ host provides the driver, so plugins never depend on a specific runtime.
72
+ - **sessions** — child sessions (`spawn`, `create`, `run`, `get`, `children`, `cancel`, `enqueue`,
73
+ …): separate conversations with fresh context and narrowed permissions that never exceed the
74
+ parent.
75
+ - **ui** — `status`, `panel`, `select`, `askQuestions`, `open`, `interactive()`; interactive-only
76
+ calls resolve `undefined` headless instead of hanging.
77
+
27
78
  ## Extension points
28
79
 
29
- Typed, generic extension points let plugins replace parts of the experience without core
30
- changes. Today: `mascot`, `startup-screen` and `websearch`.
80
+ Typed, generic extension points let plugins replace parts of the experience without core changes.
81
+ Today: `mascot`, `startup-screen` and `websearch`.
31
82
 
32
83
  ```ts
33
84
  api.extensions.register("mascot", {
34
85
  id: "kite",
35
86
  render: ({ terminal }) => (terminal.unicode ? [" ◢◣", " ◢██◣", " ◥██◤", " ◥◤"] : [" /\\", " / \\", " \\ /", " \\/"]),
36
87
  }, { priority: 10 });
37
-
38
- api.extensions.register("websearch", {
39
- id: "brave-example",
40
- search: async (query) => [{ title: "...", url: "https://...", snippet: "..." }],
41
- }, { priority: 10 });
42
88
  ```
43
89
 
44
- The highest `priority` wins; ties break by plugin `id`, then registration order, and are reported
45
- as `extension_conflict`. A renderable provider (`mascot`, `startup-screen`) receives only its
46
- context (`terminal.color`, `unicode`, `columns`); its output is sanitized and clamped, and a
47
- failing provider falls back to the default. `websearch` fully replaces Alisio's built-in
48
- search-provider resolution while registered (a throwing provider also falls back, with a
49
- diagnostic). A declarative `extensions: { mascot, "startup-screen", websearch }` field on the
50
- plugin is also accepted. Plugins are identified by `id` (not `name`).
90
+ The highest `priority` wins; ties break by plugin `id`, then registration order (reported as
91
+ `extension_conflict`). A renderable provider receives only its context (`terminal.color`,
92
+ `unicode`, `columns`); output is sanitized and clamped, and a failing provider falls back to the
93
+ default. `websearch` fully replaces Alisio's built-in search-provider resolution while registered.
94
+ A declarative `extensions` field on the plugin is accepted too, at priority 0. Plugins are
95
+ identified by `id`, not `name`.
51
96
 
52
97
  ## Prompt templates
53
98
 
54
- `api.resources.prompts("./prompts")` registers a directory of Markdown templates that become
55
- slash commands (for example `/review src/app.ts`):
99
+ `api.resources.prompts("./prompts")` registers a directory of Markdown templates that become slash
100
+ commands (for example `/review src/app.ts`):
56
101
 
57
102
  ```md
58
103
  ---
@@ -67,27 +112,18 @@ Review $1 carefully. Extra focus: $ARGUMENTS
67
112
  Precedence: built-in < plugin < user (`~/.config/alisio/prompts`) < trusted project
68
113
  (`.alisio/prompts`).
69
114
 
70
- ## Child sessions, panels and choices
71
-
72
- Generic building blocks used by the built-in subagents plugin and available to any plugin:
73
-
74
- - `api.sessions.spawn/run/cancel/enqueue/...`: child sessions with a parent link, fresh context
75
- and narrowed permissions (a child never exceeds its parent); aborting a parent aborts them.
76
- - `api.ui.panel(id, { title, nodes, action })`: a collapsible tree under the TUI editor.
77
- - `api.ui.select({ title, options })`: ask the user to choose one (resolves `undefined` headless).
78
- - `api.ui.askQuestions({ questions, session?, label?, signal? })`: ask 1-4 multiple-choice questions
79
- (2-4 options each, an optional `recommended` one); resolves every question id `undefined` headless.
80
- `session`/`label` attribute the question to the asking (sub)session, mirroring `ApprovalRequest`.
81
- - `api.ui.interactive()`: true when an interactive UI is bound at all (never per-session), so a
82
- child session under an interactive root can safely call `select`/`askQuestions` too.
83
- - `api.ui.open(sessionId)`, `api.resources.agents(dir)`, `api.resources.list(kind)`.
84
- - `ToolContext.label`: who is asking (an agent path such as `"general › explore"`), set for tool
85
- calls made by a labeled child session; mirrors `ApprovalRequest.label`.
86
- - `ToolDefinition.concurrent`: run alongside other read/concurrent calls of the same turn.
87
-
88
- The API covers tools, commands, events, context providers, compaction hooks, session start/end
89
- hooks, provider-agnostic `model.complete`, a SQLite storage port and UI status. Publish plugins as
90
- JavaScript with the `alisio-plugin` keyword and `@alisio/sdk` as a peer dependency. Guide:
91
- [Writing plugins](https://gustavogutierrez.github.io/alisio/plugins).
92
-
93
- Maintainer: Gustavo Gutiérrez · License: MIT
115
+ ## Publishing
116
+
117
+ Publish plugins as JavaScript with the `alisio-plugin` keyword and `@alisio/sdk` as a peer
118
+ dependency; the entry resolves from `exports["."]`, then `main`, then `./index.js`. Guide:
119
+ [Writing plugins](https://gustavogutierrez.github.io/alisio/plugins) ·
120
+ [Publishing](https://gustavogutierrez.github.io/alisio/publishing).
121
+
122
+ ## Requirements
123
+
124
+ Node.js **>= 22.16** (types-only package; consumers run on Node or Bun).
125
+
126
+ ## License
127
+
128
+ MIT. Maintained by Gustavo Gutiérrez Mercado. Source: <https://github.com/GustavoGutierrez/alisio> ·
129
+ npm: <https://www.npmjs.com/settings/alisio/packages>.
package/dist/index.d.ts CHANGED
@@ -137,6 +137,12 @@ export interface ModelProvider {
137
137
  * that does not support one may ignore this or let the provider reject it.
138
138
  */
139
139
  nativeTools?: Array<Record<string, unknown>>;
140
+ /**
141
+ * Provider-declared reasoning effort level (a value from `ModelInfo.effort.supportedLevels`).
142
+ * Providers that advertise effort levels map it to their request field (for example DeepSeek
143
+ * `reasoning_effort`); providers without a concept ignore it.
144
+ */
145
+ reasoningEffort?: string;
140
146
  }): AsyncIterable<ProviderEvent>;
141
147
  /** Optional model catalog. Implementations must not expose credentials. */
142
148
  listModels?(signal: AbortSignal): Promise<ModelInfo[]>;
@@ -276,6 +282,8 @@ export interface CompletionRequest {
276
282
  model?: string;
277
283
  /** Session whose provider binding should be used when model is omitted. */
278
284
  sessionId?: string;
285
+ /** Reasoning effort level when the target model advertises `ModelInfo.effort`. */
286
+ reasoningEffort?: string;
279
287
  signal?: AbortSignal;
280
288
  }
281
289
  export type SqlValue = string | number | bigint | null | Uint8Array;
@@ -442,6 +450,8 @@ export interface ChildRunResult {
442
450
  output: number;
443
451
  };
444
452
  error?: string;
453
+ /** True when the child hit its turn limit: `text` is a usable partial result, not an error. */
454
+ turnsExceeded?: boolean;
445
455
  }
446
456
  /** Generic tree node contributed to an interactive panel (e.g. running agents). */
447
457
  export interface PanelNode {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alisio/sdk",
3
- "version": "0.1.0-alpha.6",
3
+ "version": "0.1.0-alpha.8",
4
4
  "description": "Typed plugin SDK for Alisio: the stable contract for tools, commands, context, compaction and session hooks, model completions and storage. Types only plus tiny helpers; zero runtime dependencies.",
5
5
  "author": "Gustavo Gutiérrez",
6
6
  "license": "MIT",