@alisio/core 0.1.0-alpha.10

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 (75) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +25 -0
  3. package/dist/application.d.ts +225 -0
  4. package/dist/application.js +950 -0
  5. package/dist/config.d.ts +481 -0
  6. package/dist/config.js +592 -0
  7. package/dist/core/compaction.d.ts +136 -0
  8. package/dist/core/compaction.js +404 -0
  9. package/dist/core/contracts.d.ts +147 -0
  10. package/dist/core/contracts.js +1 -0
  11. package/dist/core/registry.d.ts +8 -0
  12. package/dist/core/registry.js +54 -0
  13. package/dist/core/runner.d.ts +160 -0
  14. package/dist/core/runner.js +625 -0
  15. package/dist/extensions/registry.d.ts +28 -0
  16. package/dist/extensions/registry.js +58 -0
  17. package/dist/index.d.ts +29 -0
  18. package/dist/index.js +28 -0
  19. package/dist/integrations/herdr.d.ts +34 -0
  20. package/dist/integrations/herdr.js +174 -0
  21. package/dist/mcp/connector.d.ts +65 -0
  22. package/dist/mcp/connector.js +423 -0
  23. package/dist/plugins/host.d.ts +169 -0
  24. package/dist/plugins/host.js +585 -0
  25. package/dist/plugins/install.d.ts +100 -0
  26. package/dist/plugins/install.js +322 -0
  27. package/dist/providers/openai-compatible.d.ts +14 -0
  28. package/dist/providers/openai-compatible.js +228 -0
  29. package/dist/providers/registry.d.ts +35 -0
  30. package/dist/providers/registry.js +74 -0
  31. package/dist/providers/routing.d.ts +11 -0
  32. package/dist/providers/routing.js +41 -0
  33. package/dist/providers/settings.d.ts +30 -0
  34. package/dist/providers/settings.js +80 -0
  35. package/dist/resources/context.d.ts +44 -0
  36. package/dist/resources/context.js +171 -0
  37. package/dist/resources/prompts.d.ts +77 -0
  38. package/dist/resources/prompts.js +182 -0
  39. package/dist/resources/skills.d.ts +82 -0
  40. package/dist/resources/skills.js +214 -0
  41. package/dist/runtime/fs.d.ts +9 -0
  42. package/dist/runtime/fs.js +73 -0
  43. package/dist/runtime/modules.d.ts +16 -0
  44. package/dist/runtime/modules.js +83 -0
  45. package/dist/runtime/paths.d.ts +4 -0
  46. package/dist/runtime/paths.js +42 -0
  47. package/dist/runtime/process.d.ts +25 -0
  48. package/dist/runtime/process.js +122 -0
  49. package/dist/runtime/sqlite.d.ts +3 -0
  50. package/dist/runtime/sqlite.js +85 -0
  51. package/dist/runtime/store.d.ts +38 -0
  52. package/dist/runtime/store.js +259 -0
  53. package/dist/sessions/children.d.ts +55 -0
  54. package/dist/sessions/children.js +233 -0
  55. package/dist/startup/index.d.ts +41 -0
  56. package/dist/startup/index.js +105 -0
  57. package/dist/startup/mascot.d.ts +6 -0
  58. package/dist/startup/mascot.js +30 -0
  59. package/dist/startup/screen.d.ts +18 -0
  60. package/dist/startup/screen.js +117 -0
  61. package/dist/startup/text.d.ts +19 -0
  62. package/dist/startup/text.js +68 -0
  63. package/dist/tools/execute.d.ts +16 -0
  64. package/dist/tools/execute.js +96 -0
  65. package/dist/tools/search.d.ts +69 -0
  66. package/dist/tools/search.js +232 -0
  67. package/dist/tools/standard.d.ts +22 -0
  68. package/dist/tools/standard.js +419 -0
  69. package/dist/tools/webfetch.d.ts +26 -0
  70. package/dist/tools/webfetch.js +119 -0
  71. package/dist/trust.d.ts +34 -0
  72. package/dist/trust.js +113 -0
  73. package/dist/version.d.ts +7 -0
  74. package/dist/version.js +26 -0
  75. package/package.json +62 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Gustavo Gutiérrez
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,25 @@
1
+ # @alisio/core
2
+
3
+ Embeddable core of [Alisio](https://github.com/GustavoGutierrez/alisio): the agent tool loop, structured
4
+ context compaction, the OpenAI-compatible provider (Chat Completions and Responses), local tools with
5
+ explicit permissions, the MCP client, the plugin host (with hook timeouts and failure isolation) and a
6
+ SQLite session store. Runs on Node.js >= 22.16 (`node:sqlite` with FTS5) and on Bun.
7
+
8
+ ```ts
9
+ import { createApplication } from "@alisio/core";
10
+
11
+ const app = await createApplication({ config: "./alisio.json", readOnly: true });
12
+ try {
13
+ const session = app.store.create(app.workspace, app.provider.id, app.provider.model);
14
+ const { text } = await app.runner.run(session.id, "Summarize this repository");
15
+ console.log(text);
16
+ } finally {
17
+ await app.close();
18
+ }
19
+ ```
20
+
21
+ Built-in plugins are opt-in for embedders: pass `builtins` (the `alisio` CLI wires
22
+ `@alisio/plugin-memory`). See the [architecture](https://gustavogutierrez.github.io/alisio/architecture) and
23
+ [configuration](https://gustavogutierrez.github.io/alisio/configuration) docs.
24
+
25
+ Maintainer: Gustavo Gutiérrez · License: MIT
@@ -0,0 +1,225 @@
1
+ import type { AvailableProviderModel, ModelInfo, ModelProvider, Plugin, PluginCategory, ProviderConfigurationValue, ResolvedProviderModel, RunEvent } from "@alisio/sdk";
2
+ import { type SettableSettingKey } from "./config.ts";
3
+ import type { ApprovalHandler } from "./core/contracts.ts";
4
+ import { ToolRegistry } from "./core/registry.ts";
5
+ import { AgentRunner } from "./core/runner.ts";
6
+ import { HerdrBridge } from "./integrations/herdr.ts";
7
+ import { McpConnector } from "./mcp/connector.ts";
8
+ import { PluginHost } from "./plugins/host.ts";
9
+ import { ActiveProvider, ProviderRegistry } from "./providers/registry.ts";
10
+ import { ProviderSettingsStore } from "./providers/settings.ts";
11
+ import { ProjectContext } from "./resources/context.ts";
12
+ import { Skills } from "./resources/skills.ts";
13
+ import { SQLiteStore } from "./runtime/store.ts";
14
+ export interface AppOptions {
15
+ cwd?: string;
16
+ config?: string;
17
+ trustProject?: boolean;
18
+ plugin?: string[];
19
+ allowWrite?: boolean;
20
+ allowProcess?: boolean;
21
+ /** Allow network tools (webfetch, websearch) and a provider-native search tool. */
22
+ allowExternal?: boolean;
23
+ allowMcp?: boolean;
24
+ readOnly?: boolean;
25
+ allowAgents?: boolean;
26
+ noHerdr?: boolean;
27
+ model?: string;
28
+ baseURL?: string;
29
+ apiMode?: string;
30
+ db?: string;
31
+ provider?: ModelProvider;
32
+ onEvent?: (event: RunEvent) => void;
33
+ /** First-party plugins activated through the trusted path (the CLI passes its registry). */
34
+ builtins?: BuiltinPlugin[];
35
+ /** Prompt templates shipped by the embedder (lowest precedence). */
36
+ builtinPrompts?: Array<{
37
+ name: string;
38
+ text: string;
39
+ }>;
40
+ /** Names templates may not take (e.g. the UI's own slash commands). */
41
+ reservedPromptNames?: string[];
42
+ /** Options merged over `builtinPlugins.<id>` from the configuration (e.g. CLI flags). */
43
+ pluginOptions?: Record<string, Record<string, unknown>>;
44
+ /** Built-in plugin ids to disable (e.g. `memory`). */
45
+ disablePlugins?: string[];
46
+ /** Interactive approval for write/process tools; ignored in read-only mode. */
47
+ approve?: ApprovalHandler;
48
+ }
49
+ export interface BuiltinContext {
50
+ workspace: string;
51
+ cwd: string;
52
+ stateHome: string;
53
+ configHome: string;
54
+ home: string;
55
+ /** Project-level resources may load (--trust-project or an explicit --config). */
56
+ trusted: boolean;
57
+ /** Directory of the configuration file, for relative paths in plugin options. */
58
+ configDir: string;
59
+ }
60
+ export interface BuiltinPlugin {
61
+ id: string;
62
+ name?: string;
63
+ description: string;
64
+ categories?: PluginCategory[];
65
+ /** Marks the initial provider plugin used for legacy root provider configuration. */
66
+ defaultProvider?: boolean;
67
+ /** `options` is the raw `builtinPlugins.<id>` object; the plugin validates it. */
68
+ create(options: unknown, context: BuiltinContext): Plugin;
69
+ }
70
+ export type PluginCatalogStatus = "active" | "inactive" | "failed" | "restart-required";
71
+ export interface PluginCatalogEntry {
72
+ id: string;
73
+ name: string;
74
+ description: string;
75
+ version?: string;
76
+ categories: PluginCategory[];
77
+ builtin: boolean;
78
+ source: string;
79
+ status: PluginCatalogStatus;
80
+ enabled: boolean;
81
+ manageable: boolean;
82
+ diagnostic?: string;
83
+ }
84
+ export interface ConfiguredProviderCatalog {
85
+ profile: string;
86
+ provider: string;
87
+ title: string;
88
+ configuredModel: string;
89
+ models: ModelInfo[];
90
+ unavailable: boolean;
91
+ }
92
+ /** A built-in runs unless its config sets `enabled: false` or it is disabled by id. */
93
+ export declare function enabledBuiltins(available: BuiltinPlugin[], config: Record<string, {
94
+ enabled?: boolean;
95
+ } & Record<string, unknown>>, disabled?: string[]): BuiltinPlugin[];
96
+ export declare function createApplication(options?: AppOptions): Promise<{
97
+ workspace: string;
98
+ config: import("./config.ts").LoadedConfig;
99
+ prompts: {
100
+ templates: Map<string, import("./index.ts").PromptTemplate>;
101
+ diagnostics: import("./index.ts").PromptDiagnostic[];
102
+ };
103
+ expandPrompt: (input: string) => {
104
+ name: string;
105
+ args: string;
106
+ display: string;
107
+ text: string;
108
+ template: import("./index.ts").PromptTemplate;
109
+ } | undefined;
110
+ store: SQLiteStore;
111
+ registry: ToolRegistry;
112
+ context: ProjectContext;
113
+ skills: Skills;
114
+ /** Path- and content-safe metadata for the interactive skills manager. */
115
+ skillCatalog(): {
116
+ name: string;
117
+ id: string;
118
+ effectiveId: string;
119
+ displayId: string;
120
+ description: string;
121
+ scope: import("./index.ts").SkillScope;
122
+ source: string;
123
+ owner?: {
124
+ id: string;
125
+ name: string;
126
+ };
127
+ manageable: boolean;
128
+ locked: boolean;
129
+ enabled: boolean;
130
+ effective: boolean;
131
+ shadowedBy?: string;
132
+ approximateTokens: number;
133
+ }[];
134
+ /** Persist a project-local override and apply it to model-visible skills immediately. */
135
+ setSkillEnabled(id: string, enabled: boolean): Promise<import("./index.ts").Skill>;
136
+ plugins: PluginHost;
137
+ /** Credential- and path-safe catalog for the current resolved plugin set. */
138
+ pluginCatalog(): PluginCatalogEntry[];
139
+ /** Persist a project-local override. Runtime registrations intentionally change on restart. */
140
+ setPluginEnabled(id: string, enabled: boolean, lifecycle?: {
141
+ liveSession?: boolean;
142
+ }): Promise<PluginCatalogEntry>;
143
+ mcp: McpConnector;
144
+ /** Current-process MCP grant; deliberately independent from persisted server enablement. */
145
+ mcpRuntimePermission(): "granted" | "not-granted" | "read-only";
146
+ /** Whether global MCP consent (`mcp.allow`) is persisted for this user right now. */
147
+ mcpAllowPersisted(): boolean;
148
+ /**
149
+ * Sanitized per-server failures collected while auto-connecting enabled servers at startup
150
+ * (only when runtime permission was granted). Never includes credentials or command paths.
151
+ */
152
+ mcpStartupFailures(): string[];
153
+ /** Host-owned interactive consent boundary. Headless callers remain blocked unless flagged. */
154
+ grantMcpRuntimePermission(request: {
155
+ source: "interactive-tui";
156
+ confirmed: boolean;
157
+ }): "granted" | "not-granted" | "read-only";
158
+ /** Persist global consent atomically, then grant runtime permission for this process. */
159
+ rememberGlobalMcpConsent(): Promise<void>;
160
+ /**
161
+ * Clear the persisted global consent atomically and drop the runtime permission (disconnecting
162
+ * servers as cleanup does). An explicit this-run `--allow-mcp` flag keeps the grant alive.
163
+ */
164
+ revokeGlobalMcpConsent(): Promise<void>;
165
+ /** Persist an MCP toggle in its defining layer, then safely update this process. */
166
+ setMcpEnabled(id: string, enabled: boolean, connect?: boolean): Promise<import("./index.ts").McpServerInfo>;
167
+ /**
168
+ * Persist one user-facing setting to the GLOBAL user config (`<config home>/config.json`)
169
+ * and apply it to this process where the value can change live. Compaction and limits land
170
+ * in the runner (honored by the next run/compact), `context.*` lands in the project context
171
+ * (next instructions load), `websearch.provider` mutates the shared config object the search
172
+ * chain reads per call, `pluginHooks.timeoutMs` lands in the plugin host (next hook call),
173
+ * and `tui.*` is persisted for the host to apply. Nothing in this set requires a restart.
174
+ * `mcp.allow` is deliberately not routed here: it flows through
175
+ * `rememberGlobalMcpConsent`/`revokeGlobalMcpConsent` instead.
176
+ * Throws under `--read-only`. Returns the written config file.
177
+ */
178
+ updateSetting(key: SettableSettingKey, value: unknown): Promise<string>;
179
+ provider: ActiveProvider;
180
+ providers: ProviderRegistry;
181
+ providerSettings: ProviderSettingsStore;
182
+ readonly providerError: string | undefined;
183
+ readonly providerInfo: {
184
+ id: string;
185
+ profile: Record<string, ProviderConfigurationValue>;
186
+ persisted: boolean;
187
+ profileName: string;
188
+ } | {
189
+ id: string;
190
+ profile: Record<string, import("@alisio/sdk").ProviderConfigurationValue>;
191
+ persisted: boolean;
192
+ profileName: undefined;
193
+ } | undefined;
194
+ runner: AgentRunner;
195
+ herdr: HerdrBridge;
196
+ contextWindow: (model: string) => number | undefined;
197
+ /** Effective context budget + compaction point shared by the runner and the TUI bar. */
198
+ contextBudget: (model: string) => {
199
+ total?: number;
200
+ basis: "window" | "unknown";
201
+ compactionAt: number;
202
+ };
203
+ loadModels: (signal: AbortSignal) => Promise<ModelInfo[]>;
204
+ /** Creates a provider for validation/model discovery without changing the active provider. */
205
+ probeProvider(id: string, profile: Record<string, import("@alisio/sdk").ProviderConfigurationValue>, credentials: Record<string, string>, signal: AbortSignal): Promise<ModelInfo[]>;
206
+ /** Lists every plugin-configured profile without returning credentials or provider errors. */
207
+ configuredProviderCatalogs(signal: AbortSignal): Promise<ConfiguredProviderCatalog[]>;
208
+ /** Lists credential-free models from globally configured `/connect` profiles. */
209
+ listAvailableModels: (signal?: AbortSignal) => Promise<AvailableProviderModel[]>;
210
+ /** Resolves `provider/model` or a unique bare model id without exposing credentials. */
211
+ resolveModel: (reference: string, signal?: AbortSignal) => Promise<ResolvedProviderModel>;
212
+ /** Creates and binds a fresh session to an optional configured model selector. */
213
+ createSession(reference?: string): Promise<import("./index.ts").Session>;
214
+ /** Persists and activates only after construction succeeds; programmatic overrides stay fixed. */
215
+ activateProvider(id: string, profile: Record<string, import("@alisio/sdk").ProviderConfigurationValue>, credentials: Record<string, string>, model: string, profileName?: string): Promise<void>;
216
+ /** Activates a stored profile without exposing its credentials. Returns false for a no-op. */
217
+ activateProviderProfile(name: string, model: string): Promise<boolean>;
218
+ /** Resolves, globally activates, and creates the fresh session required by a main switch. */
219
+ switchModel(reference: string): Promise<import("./index.ts").Session | undefined>;
220
+ /** Runs session-end plugin hooks (bounded by the host timeout). */
221
+ endSession(sessionId: string, reason: "clear" | "exit"): Promise<{
222
+ failures: import("./index.ts").HookFailure[];
223
+ }>;
224
+ close(): Promise<void>;
225
+ }>;