@alisio/sdk 0.1.0-alpha.14 → 0.1.0-alpha.16
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/index.d.ts +782 -1
- package/dist/index.js +28 -0
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -44,7 +44,86 @@ export type UiBlock = {
|
|
|
44
44
|
} | {
|
|
45
45
|
kind: "markdown";
|
|
46
46
|
text: string;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* A file change: a unified `patch`, or `before`/`after` contents when no patch is available.
|
|
50
|
+
* Producers bound the payload (about 200 KB).
|
|
51
|
+
*/
|
|
52
|
+
| {
|
|
53
|
+
kind: "diff";
|
|
54
|
+
path?: string;
|
|
55
|
+
patch?: string;
|
|
56
|
+
before?: string;
|
|
57
|
+
after?: string;
|
|
58
|
+
lang?: string;
|
|
59
|
+
caption?: string;
|
|
60
|
+
}
|
|
61
|
+
/** Output of a command. `output` may contain ANSI escapes; producers bound it (about 256 KB). */
|
|
62
|
+
| {
|
|
63
|
+
kind: "terminal";
|
|
64
|
+
command?: string;
|
|
65
|
+
cwd?: string;
|
|
66
|
+
output: string;
|
|
67
|
+
exitCode?: number;
|
|
68
|
+
durationMs?: number;
|
|
69
|
+
truncated?: boolean;
|
|
70
|
+
}
|
|
71
|
+
/** Mermaid diagram source; text surfaces show the source verbatim. */
|
|
72
|
+
| {
|
|
73
|
+
kind: "mermaid";
|
|
74
|
+
source: string;
|
|
75
|
+
title?: string;
|
|
76
|
+
}
|
|
77
|
+
/** A LaTeX formula; `display` requests block (not inline) layout. */
|
|
78
|
+
| {
|
|
79
|
+
kind: "math";
|
|
80
|
+
latex: string;
|
|
81
|
+
display?: boolean;
|
|
82
|
+
}
|
|
83
|
+
/** Any JSON value, shown as a collapsible tree by rich surfaces (bounded to about 256 KB). */
|
|
84
|
+
| {
|
|
85
|
+
kind: "json";
|
|
86
|
+
value: unknown;
|
|
87
|
+
collapsedDepth?: number;
|
|
88
|
+
caption?: string;
|
|
89
|
+
}
|
|
90
|
+
/** Test run results grouped by suite. */
|
|
91
|
+
| {
|
|
92
|
+
kind: "test-results";
|
|
93
|
+
framework?: string;
|
|
94
|
+
durationMs?: number;
|
|
95
|
+
suites: Array<{
|
|
96
|
+
name: string;
|
|
97
|
+
file?: string;
|
|
98
|
+
cases: TestCaseResult[];
|
|
99
|
+
}>;
|
|
100
|
+
}
|
|
101
|
+
/** A checklist of steps with their current status. */
|
|
102
|
+
| {
|
|
103
|
+
kind: "progress";
|
|
104
|
+
title?: string;
|
|
105
|
+
steps: ProgressStep[];
|
|
47
106
|
};
|
|
107
|
+
/** One case of a `{ kind: "test-results" }` UI block. */
|
|
108
|
+
export interface TestCaseResult {
|
|
109
|
+
name: string;
|
|
110
|
+
status: "passed" | "failed" | "skipped" | "todo";
|
|
111
|
+
durationMs?: number;
|
|
112
|
+
error?: string;
|
|
113
|
+
line?: number;
|
|
114
|
+
}
|
|
115
|
+
/** One step of a `{ kind: "progress" }` UI block. */
|
|
116
|
+
export interface ProgressStep {
|
|
117
|
+
label: string;
|
|
118
|
+
status: "pending" | "running" | "completed" | "failed" | "cancelled";
|
|
119
|
+
detail?: string;
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Every `UiBlock` kind, for surfaces that dispatch on the kind at runtime (renderer registries,
|
|
123
|
+
* validators). Surfaces must still render an unknown kind as text: blocks persisted by a newer
|
|
124
|
+
* Alisio can be replayed by an older one.
|
|
125
|
+
*/
|
|
126
|
+
export declare const UI_BLOCK_KINDS: readonly ["table", "key-value", "tree", "code", "markdown", "diff", "terminal", "mermaid", "math", "json", "test-results", "progress"];
|
|
48
127
|
export interface ToolResult {
|
|
49
128
|
content: Array<{
|
|
50
129
|
type: "text";
|
|
@@ -67,7 +146,11 @@ export interface ToolResult {
|
|
|
67
146
|
export interface Attachment {
|
|
68
147
|
kind: "image";
|
|
69
148
|
mimeType: string;
|
|
70
|
-
/**
|
|
149
|
+
/**
|
|
150
|
+
* Base64-encoded bytes, no `data:` prefix. Required: providers and plugins read it directly,
|
|
151
|
+
* and no runtime check yet guarantees an alternative source. Content-addressed uploads travel
|
|
152
|
+
* as `BlobRef` and are resolved to `data` by the host before they reach an `Attachment`.
|
|
153
|
+
*/
|
|
71
154
|
data: string;
|
|
72
155
|
bytes: number;
|
|
73
156
|
width?: number;
|
|
@@ -253,15 +336,170 @@ export interface ToolDefinition {
|
|
|
253
336
|
paths?: (input: Record<string, unknown>) => string[];
|
|
254
337
|
execute(input: Record<string, unknown>, context: ToolContext): Promise<ToolResult>;
|
|
255
338
|
}
|
|
339
|
+
/**
|
|
340
|
+
* One event of an agent run, as delivered to `onEvent`, plugins and `alisio run --json` (JSONL).
|
|
341
|
+
* `schemaVersion` stays `1` while changes are additive (new optional fields, new event types);
|
|
342
|
+
* consumers must ignore unknown fields and unknown `type` values. See `KnownRunEvent` for the
|
|
343
|
+
* typed payloads of the events the core emits today.
|
|
344
|
+
*/
|
|
256
345
|
export interface RunEvent {
|
|
257
346
|
schemaVersion: 1;
|
|
258
347
|
runId: string;
|
|
259
348
|
sessionId: string;
|
|
349
|
+
/** Per-run counter starting at 1 (restarts on every run; not unique within a session). */
|
|
260
350
|
seq: number;
|
|
261
351
|
type: string;
|
|
262
352
|
timestamp: string;
|
|
263
353
|
data: unknown;
|
|
354
|
+
/**
|
|
355
|
+
* Stable id of a durable event: the persisted global `events.seq`, as a decimal string. Absent
|
|
356
|
+
* for ephemeral events (`EphemeralRunEventType`) and when the host store does not report it.
|
|
357
|
+
*/
|
|
358
|
+
eventId?: string;
|
|
359
|
+
/** Embedder-supplied correlation id (for example an HTTP `X-Request-Id`), when given. */
|
|
360
|
+
correlationId?: string;
|
|
264
361
|
}
|
|
362
|
+
/**
|
|
363
|
+
* Payload of each event type the core emits today, keyed by `RunEvent.type`. Additive: new
|
|
364
|
+
* types and new optional fields may appear; existing fields keep their meaning.
|
|
365
|
+
*/
|
|
366
|
+
export interface RunEventDataMap {
|
|
367
|
+
run_started: {
|
|
368
|
+
model: string;
|
|
369
|
+
};
|
|
370
|
+
text_delta: {
|
|
371
|
+
delta: string;
|
|
372
|
+
};
|
|
373
|
+
/** Provider-visible reasoning text; display only, never persisted. */
|
|
374
|
+
reasoning_delta: {
|
|
375
|
+
delta: string;
|
|
376
|
+
};
|
|
377
|
+
turn_completed: {
|
|
378
|
+
/** 1-based turn number within the run. */
|
|
379
|
+
turn: number;
|
|
380
|
+
/** Cumulative input + output tokens of the run so far. */
|
|
381
|
+
tokens: number;
|
|
382
|
+
calls: number;
|
|
383
|
+
model: string;
|
|
384
|
+
usage?: Usage;
|
|
385
|
+
/** Milliseconds from sending the provider request to its completed response. */
|
|
386
|
+
durationMs?: number;
|
|
387
|
+
/** Milliseconds to the first streamed text/reasoning delta; absent when nothing streamed. */
|
|
388
|
+
ttftMs?: number;
|
|
389
|
+
};
|
|
390
|
+
tool_started: {
|
|
391
|
+
id: string;
|
|
392
|
+
name: string;
|
|
393
|
+
arguments: string;
|
|
394
|
+
effect: Effect;
|
|
395
|
+
};
|
|
396
|
+
/** `data` is whatever the tool passed to `ToolContext.emit`. */
|
|
397
|
+
tool_progress: {
|
|
398
|
+
id: string;
|
|
399
|
+
data: unknown;
|
|
400
|
+
};
|
|
401
|
+
tool_completed: {
|
|
402
|
+
id: string;
|
|
403
|
+
name: string;
|
|
404
|
+
isError: boolean;
|
|
405
|
+
durationMs: number;
|
|
406
|
+
/** Text projection of the result, capped at 2,000 characters. */
|
|
407
|
+
preview: string;
|
|
408
|
+
};
|
|
409
|
+
approval_requested: {
|
|
410
|
+
id: string;
|
|
411
|
+
name: string;
|
|
412
|
+
effect: "write" | "process" | "external";
|
|
413
|
+
label?: string;
|
|
414
|
+
};
|
|
415
|
+
approval_resolved: {
|
|
416
|
+
id: string;
|
|
417
|
+
name: string;
|
|
418
|
+
effect: "write" | "process" | "external";
|
|
419
|
+
decision: "once" | "session" | "deny";
|
|
420
|
+
};
|
|
421
|
+
run_completed: {
|
|
422
|
+
tokens: number;
|
|
423
|
+
text: string;
|
|
424
|
+
truncated?: boolean;
|
|
425
|
+
};
|
|
426
|
+
response_truncated: {
|
|
427
|
+
turn: number;
|
|
428
|
+
maxOutputTokens: number;
|
|
429
|
+
};
|
|
430
|
+
run_turns_exceeded: {
|
|
431
|
+
turns: number;
|
|
432
|
+
maxTurns: number;
|
|
433
|
+
};
|
|
434
|
+
run_failed: {
|
|
435
|
+
error: string;
|
|
436
|
+
};
|
|
437
|
+
run_cancelled: {
|
|
438
|
+
error: string;
|
|
439
|
+
};
|
|
440
|
+
model_changed: {
|
|
441
|
+
model: string;
|
|
442
|
+
previous: string;
|
|
443
|
+
};
|
|
444
|
+
compaction_started: {
|
|
445
|
+
reason: "manual" | "auto";
|
|
446
|
+
before: number;
|
|
447
|
+
messages: number;
|
|
448
|
+
};
|
|
449
|
+
compaction_completed: {
|
|
450
|
+
reason: "manual" | "auto";
|
|
451
|
+
before: number;
|
|
452
|
+
after: number;
|
|
453
|
+
replaced: number;
|
|
454
|
+
structured: boolean;
|
|
455
|
+
summarizedTokens: number;
|
|
456
|
+
checkpointTokens: number;
|
|
457
|
+
/** Per-plugin `CompactionOutcome.report`, keyed by plugin id. */
|
|
458
|
+
plugins: Record<string, Record<string, unknown>>;
|
|
459
|
+
/** The summary hit its output budget and was accepted as partial. */
|
|
460
|
+
partial?: true;
|
|
461
|
+
};
|
|
462
|
+
compaction_skipped: {
|
|
463
|
+
reason: "manual" | "auto";
|
|
464
|
+
before: number;
|
|
465
|
+
detail: string;
|
|
466
|
+
};
|
|
467
|
+
compaction_failed: {
|
|
468
|
+
reason: "manual" | "auto";
|
|
469
|
+
error: string;
|
|
470
|
+
};
|
|
471
|
+
/** Tool results clipped in place to fit the context budget. */
|
|
472
|
+
context_reduced: {
|
|
473
|
+
messages: number;
|
|
474
|
+
};
|
|
475
|
+
session_context_injected: {
|
|
476
|
+
tokens: number;
|
|
477
|
+
sources: string[];
|
|
478
|
+
};
|
|
479
|
+
plugin_hook_failed: {
|
|
480
|
+
source: string;
|
|
481
|
+
hook: string;
|
|
482
|
+
error: string;
|
|
483
|
+
continued: true;
|
|
484
|
+
};
|
|
485
|
+
}
|
|
486
|
+
/** Every `RunEvent.type` the core emits today. `RunEvent.type` itself stays `string`. */
|
|
487
|
+
export type RunEventType = keyof RunEventDataMap;
|
|
488
|
+
/** Event types never persisted to the session store (and therefore without `eventId`). */
|
|
489
|
+
export type EphemeralRunEventType = "text_delta" | "reasoning_delta" | "tool_progress";
|
|
490
|
+
export declare const EPHEMERAL_RUN_EVENT_TYPES: readonly EphemeralRunEventType[];
|
|
491
|
+
/** True for streaming-only event types that are never persisted. */
|
|
492
|
+
export declare function isEphemeralRunEventType(type: string): type is EphemeralRunEventType;
|
|
493
|
+
/**
|
|
494
|
+
* Discriminated view of `RunEvent` with typed `data`, for consumers that narrow on `type`.
|
|
495
|
+
* Every member is assignable to `RunEvent`; events of unknown types remain plain `RunEvent`s.
|
|
496
|
+
*/
|
|
497
|
+
export type KnownRunEvent = {
|
|
498
|
+
[K in RunEventType]: RunEvent & {
|
|
499
|
+
type: K;
|
|
500
|
+
data: RunEventDataMap[K];
|
|
501
|
+
};
|
|
502
|
+
}[RunEventType];
|
|
265
503
|
/** Generic structured checkpoint produced by core context compaction. */
|
|
266
504
|
export interface CompactionCheckpoint {
|
|
267
505
|
goal: string;
|
|
@@ -717,6 +955,549 @@ export interface Plugin {
|
|
|
717
955
|
setup(api: PluginAPI): void | Promise<void>;
|
|
718
956
|
dispose?(): void | Promise<void>;
|
|
719
957
|
}
|
|
958
|
+
/** Derived status of a root session as shown by web clients (never persisted). */
|
|
959
|
+
export type SessionUiStatus = "idle" | "queued" | "running" | "awaiting_input" | "locked" | "error";
|
|
960
|
+
/** A content-addressed upload (for example an image attached from the web composer). */
|
|
961
|
+
export interface BlobRef {
|
|
962
|
+
/** Lowercase hex sha256 of the bytes. */
|
|
963
|
+
hash: string;
|
|
964
|
+
mimeType: string;
|
|
965
|
+
bytes: number;
|
|
966
|
+
width?: number;
|
|
967
|
+
height?: number;
|
|
968
|
+
}
|
|
969
|
+
/** One entry of `GET /api/workspaces/:wid/tree` (paths are workspace-relative, `/`-separated). */
|
|
970
|
+
export interface FileEntry {
|
|
971
|
+
name: string;
|
|
972
|
+
path: string;
|
|
973
|
+
type: "file" | "dir" | "symlink" | "other";
|
|
974
|
+
/** Bytes, for files. */
|
|
975
|
+
size?: number;
|
|
976
|
+
/** Last modification, ms epoch. */
|
|
977
|
+
mtime?: number;
|
|
978
|
+
}
|
|
979
|
+
/** A page of a directory listing; `next` is an opaque cursor for the following page. */
|
|
980
|
+
export interface FileTreePage {
|
|
981
|
+
entries: FileEntry[];
|
|
982
|
+
next?: string;
|
|
983
|
+
}
|
|
984
|
+
/** A file the session changed (write-effect tool calls), for the Changes dock. */
|
|
985
|
+
export interface SessionChange {
|
|
986
|
+
path: string;
|
|
987
|
+
lastRunId?: string;
|
|
988
|
+
effect: "write";
|
|
989
|
+
/** `git status --porcelain` code when the workspace is a git repository (`M`, `A`, `D`, `??`…). */
|
|
990
|
+
gitStatus?: string;
|
|
991
|
+
}
|
|
992
|
+
/** Session metadata carried by snapshot frames. */
|
|
993
|
+
export interface SessionDetailWire {
|
|
994
|
+
id: string;
|
|
995
|
+
/** Opaque, stable workspace id (never a filesystem path in URLs). */
|
|
996
|
+
workspaceId: string;
|
|
997
|
+
/** Absolute workspace path, for display. */
|
|
998
|
+
workspace: string;
|
|
999
|
+
provider: string;
|
|
1000
|
+
model: string;
|
|
1001
|
+
status: SessionUiStatus;
|
|
1002
|
+
title?: string;
|
|
1003
|
+
parentId?: string;
|
|
1004
|
+
/** Persisted child-session status, shown verbatim for child sessions. */
|
|
1005
|
+
childStatus?: SessionStatus;
|
|
1006
|
+
createdAt?: number;
|
|
1007
|
+
updatedAt?: number;
|
|
1008
|
+
}
|
|
1009
|
+
/** In-flight state of a running run, rebuilt by the server for snapshots. */
|
|
1010
|
+
export interface InflightState {
|
|
1011
|
+
runId: string;
|
|
1012
|
+
status: "queued" | "running";
|
|
1013
|
+
/** Assistant text streamed since the last `turn_completed`. */
|
|
1014
|
+
text: string;
|
|
1015
|
+
/** Reasoning streamed since the last `turn_completed` (never persisted). */
|
|
1016
|
+
reasoning: string;
|
|
1017
|
+
tools: Array<{
|
|
1018
|
+
id: string;
|
|
1019
|
+
name: string;
|
|
1020
|
+
arguments: string;
|
|
1021
|
+
effect: Effect;
|
|
1022
|
+
startedAt: number;
|
|
1023
|
+
/** Latest progress output, bounded. */
|
|
1024
|
+
tail: string;
|
|
1025
|
+
}>;
|
|
1026
|
+
}
|
|
1027
|
+
/** An approval waiting for a decision from a web client. */
|
|
1028
|
+
export interface PendingApproval {
|
|
1029
|
+
/** `<sessionId>:<callId>` for tool effects; `<sessionId>:dir:<uuid>` for directories. */
|
|
1030
|
+
approvalId: string;
|
|
1031
|
+
sessionId: string;
|
|
1032
|
+
/** Root of `sessionId`, so child-session approvals show in the root session view. */
|
|
1033
|
+
rootSessionId: string;
|
|
1034
|
+
runId?: string;
|
|
1035
|
+
kind: "effect" | "directory";
|
|
1036
|
+
callId?: string;
|
|
1037
|
+
name?: string;
|
|
1038
|
+
effect?: "write" | "process" | "external";
|
|
1039
|
+
label?: string;
|
|
1040
|
+
directory?: string;
|
|
1041
|
+
/** Pretty-printed tool input, truncated to 4 KB. */
|
|
1042
|
+
input: string;
|
|
1043
|
+
expiresAt?: number;
|
|
1044
|
+
}
|
|
1045
|
+
/** A plugin UI request (`ui.select` / `ui.askQuestions`) waiting for a web client. */
|
|
1046
|
+
export interface PendingInteraction {
|
|
1047
|
+
interactionId: string;
|
|
1048
|
+
/** Present when the request names a session (`AskQuestionsRequest.session`). */
|
|
1049
|
+
sessionId?: string;
|
|
1050
|
+
workspaceId: string;
|
|
1051
|
+
request: {
|
|
1052
|
+
kind: "select";
|
|
1053
|
+
select: SelectRequest;
|
|
1054
|
+
} | {
|
|
1055
|
+
kind: "questions";
|
|
1056
|
+
questions: Question[];
|
|
1057
|
+
label?: string;
|
|
1058
|
+
};
|
|
1059
|
+
}
|
|
1060
|
+
/** One entry of the shared slash-command catalog. */
|
|
1061
|
+
export interface CommandDescriptor {
|
|
1062
|
+
name: string;
|
|
1063
|
+
description: string;
|
|
1064
|
+
aliases?: string[];
|
|
1065
|
+
argumentHint?: string;
|
|
1066
|
+
source: "builtin" | "plugin" | "prompt" | "skill";
|
|
1067
|
+
/** Plugin id or resource owner, when not built in. */
|
|
1068
|
+
owner?: string;
|
|
1069
|
+
surfaces: Array<"tui" | "web" | "api">;
|
|
1070
|
+
/** `core` commands run through the catalog; `surface` commands are handled by each UI. */
|
|
1071
|
+
execution: "core" | "surface";
|
|
1072
|
+
}
|
|
1073
|
+
/** One JSON object per SSE `data:` line. Clients ignore unknown `t` values. */
|
|
1074
|
+
export type ServerFrame = {
|
|
1075
|
+
t: "hello";
|
|
1076
|
+
protocolVersion: 1;
|
|
1077
|
+
streamId: string;
|
|
1078
|
+
serverTime: number;
|
|
1079
|
+
} | {
|
|
1080
|
+
t: "snapshot";
|
|
1081
|
+
sessionId: string;
|
|
1082
|
+
/** `MAX(events.seq)` of the session when the snapshot was taken. */
|
|
1083
|
+
cursor: number;
|
|
1084
|
+
session: SessionDetailWire;
|
|
1085
|
+
messages: {
|
|
1086
|
+
items: Array<{
|
|
1087
|
+
seq: number;
|
|
1088
|
+
message: Message;
|
|
1089
|
+
compacted: boolean;
|
|
1090
|
+
}>;
|
|
1091
|
+
hasMore: boolean;
|
|
1092
|
+
};
|
|
1093
|
+
inflight?: InflightState;
|
|
1094
|
+
pending: {
|
|
1095
|
+
approvals: PendingApproval[];
|
|
1096
|
+
interactions: PendingInteraction[];
|
|
1097
|
+
};
|
|
1098
|
+
}
|
|
1099
|
+
/** Durable event; its SSE `id` is `event.eventId`. */
|
|
1100
|
+
| {
|
|
1101
|
+
t: "event";
|
|
1102
|
+
sessionId: string;
|
|
1103
|
+
event: RunEvent;
|
|
1104
|
+
}
|
|
1105
|
+
/** Coalesced ephemeral output; carries no SSE `id`. */
|
|
1106
|
+
| {
|
|
1107
|
+
t: "delta";
|
|
1108
|
+
sessionId: string;
|
|
1109
|
+
runId: string;
|
|
1110
|
+
text?: string;
|
|
1111
|
+
reasoning?: string;
|
|
1112
|
+
progress?: Array<{
|
|
1113
|
+
toolId: string;
|
|
1114
|
+
chunk: string;
|
|
1115
|
+
}>;
|
|
1116
|
+
} | {
|
|
1117
|
+
t: "tool_result";
|
|
1118
|
+
sessionId: string;
|
|
1119
|
+
runId: string;
|
|
1120
|
+
callId: string;
|
|
1121
|
+
result: ToolResult;
|
|
1122
|
+
truncated?: boolean;
|
|
1123
|
+
} | {
|
|
1124
|
+
t: "message";
|
|
1125
|
+
sessionId: string;
|
|
1126
|
+
seq: number;
|
|
1127
|
+
message: Message;
|
|
1128
|
+
} | {
|
|
1129
|
+
t: "approval";
|
|
1130
|
+
approval: PendingApproval;
|
|
1131
|
+
} | {
|
|
1132
|
+
t: "approval_withdrawn";
|
|
1133
|
+
approvalId: string;
|
|
1134
|
+
reason: "cancelled" | "timeout" | "resolved_elsewhere";
|
|
1135
|
+
} | {
|
|
1136
|
+
t: "interaction";
|
|
1137
|
+
interaction: PendingInteraction;
|
|
1138
|
+
} | {
|
|
1139
|
+
t: "interaction_withdrawn";
|
|
1140
|
+
interactionId: string;
|
|
1141
|
+
} | {
|
|
1142
|
+
t: "session_status";
|
|
1143
|
+
sessionId: string;
|
|
1144
|
+
workspaceId: string;
|
|
1145
|
+
status: SessionUiStatus;
|
|
1146
|
+
title?: string;
|
|
1147
|
+
updatedAt?: number;
|
|
1148
|
+
} | {
|
|
1149
|
+
t: "catalog_changed";
|
|
1150
|
+
workspaceId: string;
|
|
1151
|
+
scope: "commands" | "plugins" | "skills" | "mcp" | "models" | "agents";
|
|
1152
|
+
} | {
|
|
1153
|
+
t: "resync";
|
|
1154
|
+
sessionId?: string;
|
|
1155
|
+
reason: "overflow" | "gap" | "server_restart";
|
|
1156
|
+
};
|
|
1157
|
+
export type ApiErrorCode = "unauthorized" | "forbidden_origin" | "forbidden_host" | "validation_failed" | "not_found" | "unknown_command" | "session_busy" | "session_locked" | "workspace_limit"
|
|
1158
|
+
/** A known workspace whose folder was deleted, moved or is no longer accessible (404). */
|
|
1159
|
+
| "workspace_missing" | "payload_too_large" | "unsupported_media_type" | "path_outside_workspace" | "not_a_git_repo" | "approval_resolved" | "capability_ceiling" | "not_manageable" | "mcp_not_permitted" | "runs_active" | "provider_unavailable" | "protocol_mismatch" | "shutting_down"
|
|
1160
|
+
/** Too many concurrent event streams (SSE) for this server. */
|
|
1161
|
+
| "stream_limit"
|
|
1162
|
+
/** The workspace is archived: unarchive it before starting new sessions (409). */
|
|
1163
|
+
| "workspace_archived"
|
|
1164
|
+
/** A native folder dialog is already open on the server machine (409). */
|
|
1165
|
+
| "picker_busy"
|
|
1166
|
+
/** No native folder dialog / folder browser on this server (remote bind, no desktop) (503). */
|
|
1167
|
+
| "picker_unavailable"
|
|
1168
|
+
/** The server user may not read that directory (403). */
|
|
1169
|
+
| "permission_denied"
|
|
1170
|
+
/** The request was cancelled before it finished, e.g. a `/btw` side question (409). */
|
|
1171
|
+
| "cancelled" | "internal";
|
|
1172
|
+
/** `GET /api/health` (the only unauthenticated API route). */
|
|
1173
|
+
export interface HealthInfo {
|
|
1174
|
+
name: "alisio";
|
|
1175
|
+
version: string;
|
|
1176
|
+
protocolVersion: 1;
|
|
1177
|
+
capabilities: {
|
|
1178
|
+
sse: boolean;
|
|
1179
|
+
websocket: boolean;
|
|
1180
|
+
multiWorkspace: boolean;
|
|
1181
|
+
attachments: boolean;
|
|
1182
|
+
uiBlocks: string[];
|
|
1183
|
+
mcpApps: boolean;
|
|
1184
|
+
automation: boolean;
|
|
1185
|
+
/** The server listens on a non-loopback address (`--allow-remote`). */
|
|
1186
|
+
remote: boolean;
|
|
1187
|
+
/**
|
|
1188
|
+
* `POST /api/workspaces/pick` can open a native folder dialog on this machine (loopback only,
|
|
1189
|
+
* with a desktop session and a dialog tool). Absent on older servers.
|
|
1190
|
+
*/
|
|
1191
|
+
nativePicker?: boolean;
|
|
1192
|
+
/** `GET /api/fs/dirs` lists directory names for the in-app folder browser (loopback only). */
|
|
1193
|
+
folderBrowser?: boolean;
|
|
1194
|
+
};
|
|
1195
|
+
}
|
|
1196
|
+
/** `POST /api/workspaces/pick`: the folder chosen in the native dialog, or a cancellation. */
|
|
1197
|
+
export type FolderPickResult = {
|
|
1198
|
+
path: string;
|
|
1199
|
+
} | {
|
|
1200
|
+
cancelled: true;
|
|
1201
|
+
};
|
|
1202
|
+
/** One page of the in-app folder browser (`GET /api/fs/dirs`): subdirectory names only. */
|
|
1203
|
+
export interface DirectoryListing {
|
|
1204
|
+
/** Absolute path listed (the server's own separators; `""` for the drive list on Windows). */
|
|
1205
|
+
path: string;
|
|
1206
|
+
/** Parent directory, absent at a filesystem root (and at the drive list). */
|
|
1207
|
+
parent?: string;
|
|
1208
|
+
/** Breadcrumbs from the root to `path`, built by the server (no separator assumptions). */
|
|
1209
|
+
segments: Array<{
|
|
1210
|
+
name: string;
|
|
1211
|
+
path: string;
|
|
1212
|
+
}>;
|
|
1213
|
+
/** Subdirectories (names and absolute paths; never files, never contents). */
|
|
1214
|
+
entries: Array<{
|
|
1215
|
+
name: string;
|
|
1216
|
+
path: string;
|
|
1217
|
+
hidden: boolean;
|
|
1218
|
+
}>;
|
|
1219
|
+
/** The server user's home directory (where browsing starts). */
|
|
1220
|
+
home: string;
|
|
1221
|
+
/** Path separator of the server platform. */
|
|
1222
|
+
separator: "/" | "\\";
|
|
1223
|
+
/** More than the listing cap: the rest is not shown. */
|
|
1224
|
+
truncated?: boolean;
|
|
1225
|
+
}
|
|
1226
|
+
/** A workspace known to the server (`GET /api/workspaces`). */
|
|
1227
|
+
export interface WorkspaceInfo {
|
|
1228
|
+
/** Opaque, stable id: a short sha256 of the canonical path. */
|
|
1229
|
+
id: string;
|
|
1230
|
+
/** Canonical absolute path (display only; URLs use `id`). */
|
|
1231
|
+
path: string;
|
|
1232
|
+
label?: string;
|
|
1233
|
+
pinned: boolean;
|
|
1234
|
+
/** An `Application` is open for it in the server right now. */
|
|
1235
|
+
open: boolean;
|
|
1236
|
+
/**
|
|
1237
|
+
* The folder is still an accessible directory. A workspace known from old sessions may have been
|
|
1238
|
+
* deleted or moved: its sessions stay readable, but it cannot be opened (`workspace_missing`).
|
|
1239
|
+
*/
|
|
1240
|
+
exists: boolean;
|
|
1241
|
+
/** Project resources load (trusted from the terminal or by a launch flag). */
|
|
1242
|
+
trusted: boolean;
|
|
1243
|
+
/** The directory has project resources that are not trusted (shown as "untrusted"). */
|
|
1244
|
+
untrustedResources: boolean;
|
|
1245
|
+
/** Archived: hidden from the default list; its sessions stay readable, new ones are refused. */
|
|
1246
|
+
archived: boolean;
|
|
1247
|
+
lastOpenedAt?: number;
|
|
1248
|
+
}
|
|
1249
|
+
/** Permission presets of the web composer (RF-08). */
|
|
1250
|
+
export type PermissionPresetId = "read-only" | "ask" | "workspace-write" | "full-access";
|
|
1251
|
+
export interface PermissionPresetInfo {
|
|
1252
|
+
id: PermissionPresetId;
|
|
1253
|
+
/** Selectable under the server's launch flags (its capability ceiling). */
|
|
1254
|
+
available: boolean;
|
|
1255
|
+
/** Why it is unavailable, or which effects still ask because of the ceiling. */
|
|
1256
|
+
reason?: string;
|
|
1257
|
+
/** Effects allowed without asking once the ceiling is applied. */
|
|
1258
|
+
policy: {
|
|
1259
|
+
write: boolean;
|
|
1260
|
+
process: boolean;
|
|
1261
|
+
external: boolean;
|
|
1262
|
+
};
|
|
1263
|
+
/** Whether non-allowed effects ask for approval (false: they are denied). */
|
|
1264
|
+
approvals: boolean;
|
|
1265
|
+
}
|
|
1266
|
+
/** A row of the session list (`GET /api/sessions`). */
|
|
1267
|
+
export interface SessionSummary extends SessionDetailWire {
|
|
1268
|
+
pinned: boolean;
|
|
1269
|
+
archived: boolean;
|
|
1270
|
+
}
|
|
1271
|
+
/** `GET /api/sessions/:sid` and the result of creating or patching a session. */
|
|
1272
|
+
export interface SessionDetail extends SessionSummary {
|
|
1273
|
+
preset: PermissionPresetId;
|
|
1274
|
+
effort?: string;
|
|
1275
|
+
agent?: string;
|
|
1276
|
+
presets: PermissionPresetInfo[];
|
|
1277
|
+
children: SessionDetailWire[];
|
|
1278
|
+
}
|
|
1279
|
+
/** Answer of `POST /api/sessions/:sid/prompts`. */
|
|
1280
|
+
export type PromptAccepted = {
|
|
1281
|
+
runId: string;
|
|
1282
|
+
status: "queued" | "running";
|
|
1283
|
+
duplicate?: false;
|
|
1284
|
+
} | {
|
|
1285
|
+
runId: string;
|
|
1286
|
+
status: string;
|
|
1287
|
+
duplicate: true;
|
|
1288
|
+
} | {
|
|
1289
|
+
status: "enqueued";
|
|
1290
|
+
duplicate?: boolean;
|
|
1291
|
+
};
|
|
1292
|
+
/**
|
|
1293
|
+
* Answer of `POST /api/sessions/:sid/commands`. A command either reports (`output`, Markdown),
|
|
1294
|
+
* points the client at another session (`/clear`, `/resume`) or expands into a prompt the client
|
|
1295
|
+
* sends through `POST .../prompts` (prompt templates, skills, `/ask`). A repeated `requestId`
|
|
1296
|
+
* answers `{duplicate: true}` without running the command again.
|
|
1297
|
+
*/
|
|
1298
|
+
export interface CommandOutcome {
|
|
1299
|
+
output?: string;
|
|
1300
|
+
/** `notice` is a short status line; `info` (default) a report. */
|
|
1301
|
+
tone?: "info" | "notice";
|
|
1302
|
+
sessionId?: string;
|
|
1303
|
+
prompt?: {
|
|
1304
|
+
text: string;
|
|
1305
|
+
display: string;
|
|
1306
|
+
};
|
|
1307
|
+
/** What changed, e.g. `"model"` or `"effort"`, so clients refresh the session. */
|
|
1308
|
+
effects?: string[];
|
|
1309
|
+
duplicate?: boolean;
|
|
1310
|
+
}
|
|
1311
|
+
/**
|
|
1312
|
+
* One `/btw` side question: a tool-less question about a session answered outside its
|
|
1313
|
+
* conversation (never persisted as messages, events, runs or session usage). Answer of
|
|
1314
|
+
* `POST /api/sessions/:sid/btw`; `GET /api/sessions/:sid/btw` lists them, oldest first.
|
|
1315
|
+
*/
|
|
1316
|
+
export interface SideQuestionEntry {
|
|
1317
|
+
id: string;
|
|
1318
|
+
question: string;
|
|
1319
|
+
/** Markdown answer. */
|
|
1320
|
+
answer: string;
|
|
1321
|
+
/** Model that answered (the session's model at the time). */
|
|
1322
|
+
model: string;
|
|
1323
|
+
usage: {
|
|
1324
|
+
input: number;
|
|
1325
|
+
output: number;
|
|
1326
|
+
};
|
|
1327
|
+
/** Epoch milliseconds. */
|
|
1328
|
+
createdAt: number;
|
|
1329
|
+
/** The provider cut the answer at the output-token budget. */
|
|
1330
|
+
truncated?: boolean;
|
|
1331
|
+
}
|
|
1332
|
+
/** `GET /api/sessions/:sid/models`: models of the session's provider (credential-free). */
|
|
1333
|
+
export interface SessionModels {
|
|
1334
|
+
provider: string;
|
|
1335
|
+
model: string;
|
|
1336
|
+
/** Session reasoning effort, when set. */
|
|
1337
|
+
effort?: string;
|
|
1338
|
+
models: ModelInfo[];
|
|
1339
|
+
/** The provider could not list its models (the current model still works). */
|
|
1340
|
+
unavailable: boolean;
|
|
1341
|
+
}
|
|
1342
|
+
/** `GET /api/sessions/:sid/context`: estimated tokens of the next request and the budget. */
|
|
1343
|
+
export interface SessionContextUsage {
|
|
1344
|
+
estimated: number;
|
|
1345
|
+
/** Model context window, when known. */
|
|
1346
|
+
total?: number;
|
|
1347
|
+
basis: "window" | "unknown";
|
|
1348
|
+
/** Percentage of `total` at which auto-compaction triggers. */
|
|
1349
|
+
compactionAt: number;
|
|
1350
|
+
}
|
|
1351
|
+
/** `GET /api/plugins`: one plugin of a workspace (credential- and path-safe). */
|
|
1352
|
+
export interface PluginInfo {
|
|
1353
|
+
id: string;
|
|
1354
|
+
name: string;
|
|
1355
|
+
description: string;
|
|
1356
|
+
version?: string;
|
|
1357
|
+
categories: string[];
|
|
1358
|
+
builtin: boolean;
|
|
1359
|
+
source: string;
|
|
1360
|
+
status: "active" | "inactive" | "failed" | "restart-required";
|
|
1361
|
+
enabled: boolean;
|
|
1362
|
+
/** Whether the web may toggle it (else `diagnostic` says why). */
|
|
1363
|
+
manageable: boolean;
|
|
1364
|
+
diagnostic?: string;
|
|
1365
|
+
/** Tools it contributes, without the namespacing prefix. */
|
|
1366
|
+
tools: string[];
|
|
1367
|
+
/** Slash commands it contributes. */
|
|
1368
|
+
commands: string[];
|
|
1369
|
+
/** Prefix of its namespaced tool names (`p_<hash>`), to label tool calls. */
|
|
1370
|
+
toolPrefix: string;
|
|
1371
|
+
}
|
|
1372
|
+
/** `GET /api/skills`: one discovered skill (no file paths). */
|
|
1373
|
+
export interface SkillInfo {
|
|
1374
|
+
id: string;
|
|
1375
|
+
name: string;
|
|
1376
|
+
displayId: string;
|
|
1377
|
+
description: string;
|
|
1378
|
+
scope: "project" | "config" | "user" | "plugin";
|
|
1379
|
+
source: string;
|
|
1380
|
+
owner?: {
|
|
1381
|
+
id: string;
|
|
1382
|
+
name: string;
|
|
1383
|
+
};
|
|
1384
|
+
manageable: boolean;
|
|
1385
|
+
locked: boolean;
|
|
1386
|
+
enabled: boolean;
|
|
1387
|
+
effective: boolean;
|
|
1388
|
+
shadowedBy?: string;
|
|
1389
|
+
approximateTokens: number;
|
|
1390
|
+
}
|
|
1391
|
+
/** One MCP server of a workspace; commands, arguments and URLs are never sent. */
|
|
1392
|
+
export interface McpServerWire {
|
|
1393
|
+
name: string;
|
|
1394
|
+
displayName: string;
|
|
1395
|
+
/** Configuration layer that defines it (`global`, `project`, …). */
|
|
1396
|
+
source: string;
|
|
1397
|
+
status: string;
|
|
1398
|
+
enabled: boolean;
|
|
1399
|
+
transport: "stdio" | "http";
|
|
1400
|
+
capabilities: string[];
|
|
1401
|
+
counts: {
|
|
1402
|
+
tools: number;
|
|
1403
|
+
resources: number;
|
|
1404
|
+
prompts: number;
|
|
1405
|
+
};
|
|
1406
|
+
diagnostic?: string;
|
|
1407
|
+
}
|
|
1408
|
+
/** `GET /api/mcp`: the workspace's MCP runtime permission and servers. */
|
|
1409
|
+
export interface McpOverview {
|
|
1410
|
+
permission: "granted" | "not-granted" | "read-only";
|
|
1411
|
+
/** Global consent (`mcp.allow`) is persisted for this user. */
|
|
1412
|
+
persisted: boolean;
|
|
1413
|
+
servers: McpServerWire[];
|
|
1414
|
+
}
|
|
1415
|
+
/** `GET /api/agents`: a selectable main-session agent. */
|
|
1416
|
+
export interface AgentInfo {
|
|
1417
|
+
id: string;
|
|
1418
|
+
name: string;
|
|
1419
|
+
description: string;
|
|
1420
|
+
instructions?: string;
|
|
1421
|
+
model?: string;
|
|
1422
|
+
readOnly?: boolean;
|
|
1423
|
+
source: "builtin" | "user" | "plugin";
|
|
1424
|
+
/** The workspace default (`agents.active`) used by sessions without their own agent. */
|
|
1425
|
+
default: boolean;
|
|
1426
|
+
}
|
|
1427
|
+
/** One user-facing setting (`SettableSettingKey`) and its effective value. */
|
|
1428
|
+
export interface SettingInfo {
|
|
1429
|
+
key: string;
|
|
1430
|
+
kind: "boolean" | "number" | "string" | "enum";
|
|
1431
|
+
options?: string[];
|
|
1432
|
+
value?: string | number | boolean;
|
|
1433
|
+
}
|
|
1434
|
+
/** `GET /api/settings`: effective settings and where configuration lives. */
|
|
1435
|
+
export interface SettingsOverview {
|
|
1436
|
+
/** Highest-priority configuration file of the workspace (it may not exist yet). */
|
|
1437
|
+
configPath: string;
|
|
1438
|
+
/** Global file that setting changes are written to. */
|
|
1439
|
+
settingsPath: string;
|
|
1440
|
+
/** Provider profiles (`providers.json`); credentials live apart, never shown. */
|
|
1441
|
+
providersPath: string;
|
|
1442
|
+
trusted: boolean;
|
|
1443
|
+
readOnly: boolean;
|
|
1444
|
+
settings: SettingInfo[];
|
|
1445
|
+
}
|
|
1446
|
+
/** A credential as the web sees it: never the value, at most a short masked tail. */
|
|
1447
|
+
export interface CredentialStatus {
|
|
1448
|
+
configured: boolean;
|
|
1449
|
+
source?: "file" | "env";
|
|
1450
|
+
/** Last characters behind an ellipsis (`…71B`), only for long stored secrets. */
|
|
1451
|
+
tail?: string;
|
|
1452
|
+
}
|
|
1453
|
+
/** One stored provider profile (non-secret values only). */
|
|
1454
|
+
export interface ProviderProfileInfo {
|
|
1455
|
+
name: string;
|
|
1456
|
+
provider: string;
|
|
1457
|
+
model: string;
|
|
1458
|
+
values: Record<string, ProviderConfigurationValue>;
|
|
1459
|
+
/** The globally active profile (`providers.json`). */
|
|
1460
|
+
active: boolean;
|
|
1461
|
+
credentials: Record<string, CredentialStatus>;
|
|
1462
|
+
}
|
|
1463
|
+
/** A provider type a profile can use, with its configuration fields. */
|
|
1464
|
+
export interface ProviderTypeInfo {
|
|
1465
|
+
id: string;
|
|
1466
|
+
name: string;
|
|
1467
|
+
description?: string;
|
|
1468
|
+
fields: ProviderConfigurationField[];
|
|
1469
|
+
}
|
|
1470
|
+
/** `GET /api/providers`. */
|
|
1471
|
+
export interface ProvidersOverview {
|
|
1472
|
+
active?: string;
|
|
1473
|
+
profiles: ProviderProfileInfo[];
|
|
1474
|
+
/** Provider types of the requested workspace (empty without `?workspace=`). */
|
|
1475
|
+
types: ProviderTypeInfo[];
|
|
1476
|
+
/** What the requested workspace's application currently runs. */
|
|
1477
|
+
current?: {
|
|
1478
|
+
provider: string;
|
|
1479
|
+
model: string;
|
|
1480
|
+
profile?: string;
|
|
1481
|
+
};
|
|
1482
|
+
}
|
|
1483
|
+
/** `GET /api/models`: models of every configured profile (credential-free). */
|
|
1484
|
+
export interface ProviderModelsInfo {
|
|
1485
|
+
profile: string;
|
|
1486
|
+
provider: string;
|
|
1487
|
+
title: string;
|
|
1488
|
+
configuredModel: string;
|
|
1489
|
+
models: ModelInfo[];
|
|
1490
|
+
unavailable: boolean;
|
|
1491
|
+
}
|
|
1492
|
+
/** Body of every non-2xx web API response. */
|
|
1493
|
+
export interface ApiError {
|
|
1494
|
+
error: {
|
|
1495
|
+
code: ApiErrorCode;
|
|
1496
|
+
message: string;
|
|
1497
|
+
details?: unknown;
|
|
1498
|
+
};
|
|
1499
|
+
correlationId: string;
|
|
1500
|
+
}
|
|
720
1501
|
export declare function definePlugin<T extends Plugin>(plugin: T): T;
|
|
721
1502
|
export declare const textResult: (text: string, isError?: boolean) => ToolResult;
|
|
722
1503
|
/**
|
package/dist/index.js
CHANGED
|
@@ -1,3 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Every `UiBlock` kind, for surfaces that dispatch on the kind at runtime (renderer registries,
|
|
3
|
+
* validators). Surfaces must still render an unknown kind as text: blocks persisted by a newer
|
|
4
|
+
* Alisio can be replayed by an older one.
|
|
5
|
+
*/
|
|
6
|
+
export const UI_BLOCK_KINDS = [
|
|
7
|
+
"table",
|
|
8
|
+
"key-value",
|
|
9
|
+
"tree",
|
|
10
|
+
"code",
|
|
11
|
+
"markdown",
|
|
12
|
+
"diff",
|
|
13
|
+
"terminal",
|
|
14
|
+
"mermaid",
|
|
15
|
+
"math",
|
|
16
|
+
"json",
|
|
17
|
+
"test-results",
|
|
18
|
+
"progress",
|
|
19
|
+
];
|
|
20
|
+
export const EPHEMERAL_RUN_EVENT_TYPES = [
|
|
21
|
+
"text_delta",
|
|
22
|
+
"reasoning_delta",
|
|
23
|
+
"tool_progress",
|
|
24
|
+
];
|
|
25
|
+
/** True for streaming-only event types that are never persisted. */
|
|
26
|
+
export function isEphemeralRunEventType(type) {
|
|
27
|
+
return EPHEMERAL_RUN_EVENT_TYPES.includes(type);
|
|
28
|
+
}
|
|
1
29
|
export function definePlugin(plugin) {
|
|
2
30
|
return plugin;
|
|
3
31
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@alisio/sdk",
|
|
3
|
-
"version": "0.1.0-alpha.
|
|
3
|
+
"version": "0.1.0-alpha.16",
|
|
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",
|