@aui.io/apollo 0.1.91 → 0.1.92
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/node_modules/@aui.io/apollo-cli/dist/src/commands/bundles.js +2 -2
- package/node_modules/@aui.io/apollo-cli/dist/src/commands/bundles.js.map +1 -1
- package/node_modules/@aui.io/apollo-cli/dist/src/commands/confirm.d.ts +5 -5
- package/node_modules/@aui.io/apollo-cli/dist/src/commands/confirm.js +8 -8
- package/node_modules/@aui.io/apollo-cli/dist/src/commands/confirm.js.map +1 -1
- package/node_modules/@aui.io/apollo-cli/dist/src/commands/operate.js +334 -40
- package/node_modules/@aui.io/apollo-cli/dist/src/commands/operate.js.map +1 -1
- package/node_modules/@aui.io/apollo-cli/dist/src/index.js +3 -0
- package/node_modules/@aui.io/apollo-cli/dist/src/index.js.map +1 -1
- package/node_modules/@aui.io/apollo-cli/dist/src/output/broken-pipe.d.ts +8 -0
- package/node_modules/@aui.io/apollo-cli/dist/src/output/broken-pipe.js +20 -0
- package/node_modules/@aui.io/apollo-cli/dist/src/output/broken-pipe.js.map +1 -0
- package/node_modules/@aui.io/apollo-cli/dist/src/output/live-chat.d.ts +53 -0
- package/node_modules/@aui.io/apollo-cli/dist/src/output/live-chat.js +170 -0
- package/node_modules/@aui.io/apollo-cli/dist/src/output/live-chat.js.map +1 -0
- package/node_modules/@aui.io/apollo-cli/package.json +3 -3
- package/node_modules/@aui.io/apollo-core/dist/src/api/client-types.d.ts +13 -0
- package/node_modules/@aui.io/apollo-core/dist/src/api/runtime-api.d.ts +94 -9
- package/node_modules/@aui.io/apollo-core/dist/src/api/runtime-api.js +45 -4
- package/node_modules/@aui.io/apollo-core/dist/src/api/runtime-api.js.map +1 -1
- package/node_modules/@aui.io/apollo-core/dist/src/api/transport.d.ts +24 -0
- package/node_modules/@aui.io/apollo-core/dist/src/api/transport.js +184 -20
- package/node_modules/@aui.io/apollo-core/dist/src/api/transport.js.map +1 -1
- package/node_modules/@aui.io/apollo-core/dist/src/errors/index.d.ts +4 -0
- package/node_modules/@aui.io/apollo-core/dist/src/errors/index.js +4 -0
- package/node_modules/@aui.io/apollo-core/dist/src/errors/index.js.map +1 -1
- package/node_modules/@aui.io/apollo-core/dist/src/output/index.d.ts +11 -2
- package/node_modules/@aui.io/apollo-core/dist/src/output/index.js +8 -4
- package/node_modules/@aui.io/apollo-core/dist/src/output/index.js.map +1 -1
- package/node_modules/@aui.io/apollo-core/dist/src/output/trace-lines.d.ts +13 -0
- package/node_modules/@aui.io/apollo-core/dist/src/output/trace-lines.js +107 -0
- package/node_modules/@aui.io/apollo-core/dist/src/output/trace-lines.js.map +1 -0
- package/node_modules/@aui.io/apollo-core/dist/src/services/messaging.d.ts +39 -3
- package/node_modules/@aui.io/apollo-core/dist/src/services/messaging.js +158 -23
- package/node_modules/@aui.io/apollo-core/dist/src/services/messaging.js.map +1 -1
- package/node_modules/@aui.io/apollo-core/package.json +1 -1
- package/node_modules/@aui.io/apollo-tui/package.json +2 -2
- package/package.json +4 -4
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import type { ChatStreamEvent } from "@aui.io/apollo-core/api/runtime-api.js";
|
|
2
|
+
export interface LiveTurnOptions {
|
|
3
|
+
/** Where the live view goes — stderr, so stdout stays the reply. */
|
|
4
|
+
out: NodeJS.WritableStream;
|
|
5
|
+
/** A terminal: colors and a status line redrawn in place. Otherwise
|
|
6
|
+
* (a pipe, a coding agent, a CI log) plain lines, one per step. */
|
|
7
|
+
tty: boolean;
|
|
8
|
+
/** Draw nothing at all (`--quiet`, `--json`). */
|
|
9
|
+
enabled: boolean;
|
|
10
|
+
now?: () => number;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* What the agent did on a turn, one line per step: as the turn streams,
|
|
14
|
+
* stamped with the seconds since it started, or — for a turn sent as one
|
|
15
|
+
* request — read off its sealed trace once the reply is in, with no clock,
|
|
16
|
+
* since every step arrived together. A step the engine sends again
|
|
17
|
+
* (`replace`) prints once.
|
|
18
|
+
*
|
|
19
|
+
* Checks wait for the reply. The engine streams a check the moment it runs,
|
|
20
|
+
* and a failure can be one it then recovers from (a reworded draft it
|
|
21
|
+
* rejects, then answers in the program's own words) — so the verdict comes
|
|
22
|
+
* from the sealed trace on the reply, and the live tally only stands in
|
|
23
|
+
* when the reply carries none. An intent is shown by name: its outcome
|
|
24
|
+
* settles after it is streamed.
|
|
25
|
+
*/
|
|
26
|
+
export declare class LiveTurnView {
|
|
27
|
+
private readonly options;
|
|
28
|
+
private readonly now;
|
|
29
|
+
private readonly colors;
|
|
30
|
+
private started;
|
|
31
|
+
private clock;
|
|
32
|
+
private readonly printed;
|
|
33
|
+
private readonly checksSeen;
|
|
34
|
+
private passed;
|
|
35
|
+
private readonly failed;
|
|
36
|
+
private spinner;
|
|
37
|
+
private frame;
|
|
38
|
+
private statusShown;
|
|
39
|
+
constructor(options: LiveTurnOptions);
|
|
40
|
+
/** The turn is being sent. */
|
|
41
|
+
begin(): void;
|
|
42
|
+
readonly onEvent: (event: ChatStreamEvent) => void;
|
|
43
|
+
/** A turn sent as one request: its steps read off the sealed trace, then the checks verdict. */
|
|
44
|
+
summarize(sealed: Record<string, unknown> | null | undefined): void;
|
|
45
|
+
/** Stop drawing: the reply is in, the turn failed, or it was cancelled. */
|
|
46
|
+
end(): void;
|
|
47
|
+
private step;
|
|
48
|
+
private finish;
|
|
49
|
+
private stop;
|
|
50
|
+
private line;
|
|
51
|
+
private drawStatus;
|
|
52
|
+
private clearStatus;
|
|
53
|
+
}
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
import pc from "picocolors";
|
|
2
|
+
import { TRACE_SECTION_LABELS, describeTraceEntry, traceSectionLabel } from "@aui.io/apollo-core/output/trace-lines.js";
|
|
3
|
+
const SPINNER = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"];
|
|
4
|
+
const LABEL_WIDTH = 11;
|
|
5
|
+
/** The sections a turn's steps are read from, in reading order. Checks are a verdict, not a step. */
|
|
6
|
+
const STEP_SECTIONS = Object.keys(TRACE_SECTION_LABELS).filter((section) => section !== "checks");
|
|
7
|
+
/**
|
|
8
|
+
* What the agent did on a turn, one line per step: as the turn streams,
|
|
9
|
+
* stamped with the seconds since it started, or — for a turn sent as one
|
|
10
|
+
* request — read off its sealed trace once the reply is in, with no clock,
|
|
11
|
+
* since every step arrived together. A step the engine sends again
|
|
12
|
+
* (`replace`) prints once.
|
|
13
|
+
*
|
|
14
|
+
* Checks wait for the reply. The engine streams a check the moment it runs,
|
|
15
|
+
* and a failure can be one it then recovers from (a reworded draft it
|
|
16
|
+
* rejects, then answers in the program's own words) — so the verdict comes
|
|
17
|
+
* from the sealed trace on the reply, and the live tally only stands in
|
|
18
|
+
* when the reply carries none. An intent is shown by name: its outcome
|
|
19
|
+
* settles after it is streamed.
|
|
20
|
+
*/
|
|
21
|
+
export class LiveTurnView {
|
|
22
|
+
options;
|
|
23
|
+
now;
|
|
24
|
+
colors;
|
|
25
|
+
started = 0;
|
|
26
|
+
clock = true;
|
|
27
|
+
printed = new Map();
|
|
28
|
+
checksSeen = new Set();
|
|
29
|
+
passed = 0;
|
|
30
|
+
failed = [];
|
|
31
|
+
spinner;
|
|
32
|
+
frame = 0;
|
|
33
|
+
statusShown = false;
|
|
34
|
+
constructor(options) {
|
|
35
|
+
this.options = options;
|
|
36
|
+
this.now = options.now ?? (() => performance.now());
|
|
37
|
+
this.colors = pc.createColors(options.tty && pc.isColorSupported);
|
|
38
|
+
}
|
|
39
|
+
/** The turn is being sent. */
|
|
40
|
+
begin() {
|
|
41
|
+
this.started = this.now();
|
|
42
|
+
this.clock = true;
|
|
43
|
+
this.printed.clear();
|
|
44
|
+
this.checksSeen.clear();
|
|
45
|
+
this.passed = 0;
|
|
46
|
+
this.failed.length = 0;
|
|
47
|
+
if (!this.options.enabled || !this.options.tty)
|
|
48
|
+
return;
|
|
49
|
+
this.spinner = setInterval(() => this.drawStatus(), 120);
|
|
50
|
+
this.spinner.unref();
|
|
51
|
+
this.drawStatus();
|
|
52
|
+
}
|
|
53
|
+
onEvent = (event) => {
|
|
54
|
+
if (!this.options.enabled)
|
|
55
|
+
return;
|
|
56
|
+
if (event.type === "trace") {
|
|
57
|
+
for (const entry of event.data.entries ?? [])
|
|
58
|
+
this.step(event.data.section, entry);
|
|
59
|
+
}
|
|
60
|
+
else if (event.type === "cards") {
|
|
61
|
+
const count = event.data.cards?.length ?? 0;
|
|
62
|
+
if (count)
|
|
63
|
+
this.line("cards", `${count} card${count === 1 ? "" : "s"} for the reply`);
|
|
64
|
+
}
|
|
65
|
+
else if (event.type === "message") {
|
|
66
|
+
this.finish(event.data.trace_info ?? undefined);
|
|
67
|
+
}
|
|
68
|
+
else if (event.type === "error") {
|
|
69
|
+
this.finish();
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
/** A turn sent as one request: its steps read off the sealed trace, then the checks verdict. */
|
|
73
|
+
summarize(sealed) {
|
|
74
|
+
this.stop();
|
|
75
|
+
if (!this.options.enabled || !sealed)
|
|
76
|
+
return;
|
|
77
|
+
this.clock = false;
|
|
78
|
+
for (const section of STEP_SECTIONS) {
|
|
79
|
+
const entries = sealed[section];
|
|
80
|
+
if (Array.isArray(entries))
|
|
81
|
+
for (const entry of entries)
|
|
82
|
+
this.step(section, entry);
|
|
83
|
+
}
|
|
84
|
+
this.finish(sealed);
|
|
85
|
+
}
|
|
86
|
+
/** Stop drawing: the reply is in, the turn failed, or it was cancelled. */
|
|
87
|
+
end() {
|
|
88
|
+
this.finish();
|
|
89
|
+
}
|
|
90
|
+
step(section, entry) {
|
|
91
|
+
if (section === "checks") {
|
|
92
|
+
const key = JSON.stringify(entry);
|
|
93
|
+
if (this.checksSeen.has(key))
|
|
94
|
+
return;
|
|
95
|
+
this.checksSeen.add(key);
|
|
96
|
+
if (failedCheck(entry))
|
|
97
|
+
this.failed.push(entry);
|
|
98
|
+
else
|
|
99
|
+
this.passed += 1;
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
const capability = section === "intents" ? entry?.capability : undefined;
|
|
103
|
+
const text = typeof capability === "string" ? capability : describeTraceEntry(section, entry);
|
|
104
|
+
const seen = this.printed.get(section) ?? new Set();
|
|
105
|
+
this.printed.set(section, seen);
|
|
106
|
+
if (seen.has(text))
|
|
107
|
+
return;
|
|
108
|
+
seen.add(text);
|
|
109
|
+
this.line(section, text);
|
|
110
|
+
}
|
|
111
|
+
finish(sealed) {
|
|
112
|
+
this.stop();
|
|
113
|
+
if (!this.options.enabled)
|
|
114
|
+
return;
|
|
115
|
+
// The sealed trace is the verdict; the live tally only when there is none.
|
|
116
|
+
const sealedChecks = Array.isArray(sealed?.checks) ? sealed.checks : undefined;
|
|
117
|
+
const failed = sealedChecks ? sealedChecks.filter(failedCheck) : [...this.failed];
|
|
118
|
+
const total = sealedChecks ? sealedChecks.length : this.passed + this.failed.length;
|
|
119
|
+
for (const check of failed)
|
|
120
|
+
this.line("checks", describeTraceEntry("checks", check), "bad");
|
|
121
|
+
if (total > 0) {
|
|
122
|
+
this.line("checks", failed.length ? `${failed.length} of ${total} checks failed` : `all ${total} checks passed`, failed.length ? "bad" : "good");
|
|
123
|
+
}
|
|
124
|
+
const rejected = sealed?.revoicing_rejected;
|
|
125
|
+
if (Array.isArray(rejected) && rejected.length > 0) {
|
|
126
|
+
this.line("checks", "a reworded draft was rejected; the program's own words were used");
|
|
127
|
+
}
|
|
128
|
+
this.passed = 0;
|
|
129
|
+
this.failed.length = 0;
|
|
130
|
+
}
|
|
131
|
+
stop() {
|
|
132
|
+
if (this.spinner !== undefined) {
|
|
133
|
+
clearInterval(this.spinner);
|
|
134
|
+
this.spinner = undefined;
|
|
135
|
+
}
|
|
136
|
+
this.clearStatus();
|
|
137
|
+
}
|
|
138
|
+
line(section, text, tone) {
|
|
139
|
+
const c = this.colors;
|
|
140
|
+
const seconds = `${((this.now() - this.started) / 1000).toFixed(1)}s`;
|
|
141
|
+
const label = traceSectionLabel(section).padEnd(LABEL_WIDTH);
|
|
142
|
+
const body = tone === "bad" ? c.red(text) : tone === "good" ? c.green(text) : text;
|
|
143
|
+
this.clearStatus();
|
|
144
|
+
let row;
|
|
145
|
+
if (this.options.tty)
|
|
146
|
+
row = ` ${this.clock ? `${c.dim(seconds.padStart(6))} ` : ""}${c.cyan(label)} ${body}`;
|
|
147
|
+
else
|
|
148
|
+
row = ` ${this.clock ? `[${seconds}] ` : ""}${label} ${text}`;
|
|
149
|
+
this.options.out.write(`${row}\n`);
|
|
150
|
+
if (this.spinner !== undefined)
|
|
151
|
+
this.drawStatus();
|
|
152
|
+
}
|
|
153
|
+
drawStatus() {
|
|
154
|
+
const c = this.colors;
|
|
155
|
+
const seconds = ((this.now() - this.started) / 1000).toFixed(1);
|
|
156
|
+
const glyph = SPINNER[this.frame++ % SPINNER.length] ?? "·";
|
|
157
|
+
this.options.out.write(`\r\x1b[2K ${c.magenta(glyph)} ${c.dim(`working · ${seconds}s`)}`);
|
|
158
|
+
this.statusShown = true;
|
|
159
|
+
}
|
|
160
|
+
clearStatus() {
|
|
161
|
+
if (!this.statusShown)
|
|
162
|
+
return;
|
|
163
|
+
this.options.out.write("\r\x1b[2K");
|
|
164
|
+
this.statusShown = false;
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
function failedCheck(entry) {
|
|
168
|
+
return entry?.passed === false;
|
|
169
|
+
}
|
|
170
|
+
//# sourceMappingURL=live-chat.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"live-chat.js","sourceRoot":"","sources":["../../../src/output/live-chat.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,YAAY,CAAC;AAG5B,OAAO,EAAE,oBAAoB,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,2CAA2C,CAAC;AAExH,MAAM,OAAO,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG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C;IAC1B,CAAC;IAEO,WAAW;QACjB,IAAI,CAAC,IAAI,CAAC,WAAW;YAAE,OAAO;QAC9B,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC;QACpC,IAAI,CAAC,WAAW,GAAG,KAAK,CAAC;IAC3B,CAAC;CACF;AAED,SAAS,WAAW,CAAC,KAAc;IACjC,OAAQ,KAAqC,EAAE,MAAM,KAAK,KAAK,CAAC;AAClE,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aui.io/apollo-cli",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.92",
|
|
4
4
|
"description": "Command-line client for the Apollo runtime",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"engines": {
|
|
@@ -33,12 +33,12 @@
|
|
|
33
33
|
"test": "vitest run"
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@aui.io/apollo-core": "0.1.
|
|
36
|
+
"@aui.io/apollo-core": "0.1.92",
|
|
37
37
|
"commander": "^14.0.3",
|
|
38
38
|
"picocolors": "^1.1.1"
|
|
39
39
|
},
|
|
40
40
|
"optionalDependencies": {
|
|
41
|
-
"@aui.io/apollo-tui": "0.1.
|
|
41
|
+
"@aui.io/apollo-tui": "0.1.92"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
44
|
"@eslint/js": "^9.39.5",
|
|
@@ -11,8 +11,21 @@ export interface RequestOptions {
|
|
|
11
11
|
/** Floor for slow-by-design endpoints; an explicit `--timeout` wins. */
|
|
12
12
|
timeoutMs?: number;
|
|
13
13
|
}
|
|
14
|
+
/** One server-sent event as the wire framed it: `data:` lines joined by newlines. */
|
|
15
|
+
export interface SseEvent {
|
|
16
|
+
event?: string;
|
|
17
|
+
id?: string;
|
|
18
|
+
data: string;
|
|
19
|
+
}
|
|
20
|
+
export interface StreamRequestOptions extends Omit<RequestOptions, "form"> {
|
|
21
|
+
/** Ends the stream early (Ctrl+C): the request is aborted and never retried. */
|
|
22
|
+
signal?: AbortSignal;
|
|
23
|
+
}
|
|
14
24
|
export interface HttpClient {
|
|
15
25
|
request<T>(path: string, options?: RequestOptions): Promise<T>;
|
|
26
|
+
/** Server-sent events, as they arrive. Optional: a client that cannot
|
|
27
|
+
* stream leaves it out, and callers fall back to `request`. */
|
|
28
|
+
stream?(path: string, options?: StreamRequestOptions): AsyncGenerator<SseEvent>;
|
|
16
29
|
}
|
|
17
30
|
export interface Page<T> {
|
|
18
31
|
results: T[];
|
|
@@ -50,6 +50,81 @@ export interface Thread {
|
|
|
50
50
|
updated_at: string;
|
|
51
51
|
[key: string]: unknown;
|
|
52
52
|
}
|
|
53
|
+
/**
|
|
54
|
+
* The runtime's keyset envelope for a thread listing. NOT `client-types.ts`'s
|
|
55
|
+
* `Page<T>` — that is the management API's `{results, meta}` shape, and the two
|
|
56
|
+
* are not interchangeable. Pass `next_cursor` back as `after` for the page past
|
|
57
|
+
* this one.
|
|
58
|
+
*/
|
|
59
|
+
export interface ThreadPage {
|
|
60
|
+
items: Thread[];
|
|
61
|
+
has_next?: boolean;
|
|
62
|
+
has_previous?: boolean;
|
|
63
|
+
next_cursor?: string | null;
|
|
64
|
+
previous_cursor?: string | null;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* One frame of a streamed turn (`POST /messaging/v1/messages/stream`), in the
|
|
68
|
+
* order the runtime sends them: the thread, progress `event`s, live `trace`
|
|
69
|
+
* slices and `cards` while the engine works, the terminal `message`, then —
|
|
70
|
+
* after the reply, never instead of it — late `suggestions`. An `error` frame
|
|
71
|
+
* ends a turn that failed.
|
|
72
|
+
*/
|
|
73
|
+
export type ChatStreamEvent = {
|
|
74
|
+
type: "thread";
|
|
75
|
+
data: {
|
|
76
|
+
thread_id: string;
|
|
77
|
+
};
|
|
78
|
+
} | {
|
|
79
|
+
type: "event";
|
|
80
|
+
seq?: number;
|
|
81
|
+
data: Record<string, unknown>;
|
|
82
|
+
} | {
|
|
83
|
+
type: "trace";
|
|
84
|
+
seq?: number;
|
|
85
|
+
data: {
|
|
86
|
+
section: string;
|
|
87
|
+
entries?: unknown[];
|
|
88
|
+
replace?: boolean;
|
|
89
|
+
};
|
|
90
|
+
} | {
|
|
91
|
+
type: "cards";
|
|
92
|
+
seq?: number;
|
|
93
|
+
data: {
|
|
94
|
+
cards?: unknown[];
|
|
95
|
+
};
|
|
96
|
+
} | {
|
|
97
|
+
type: "message";
|
|
98
|
+
seq?: number;
|
|
99
|
+
data: Message;
|
|
100
|
+
} | {
|
|
101
|
+
type: "suggestions";
|
|
102
|
+
seq?: number;
|
|
103
|
+
data: {
|
|
104
|
+
followup_suggestions?: string[];
|
|
105
|
+
};
|
|
106
|
+
} | {
|
|
107
|
+
type: "error";
|
|
108
|
+
seq?: number;
|
|
109
|
+
data: {
|
|
110
|
+
message?: string;
|
|
111
|
+
status_code?: number;
|
|
112
|
+
error?: string;
|
|
113
|
+
};
|
|
114
|
+
};
|
|
115
|
+
/** The agent listing's filters; they compose (AND). */
|
|
116
|
+
export interface AgentThreadFilters {
|
|
117
|
+
/** Only threads this AUI user opened (`created_by`). */
|
|
118
|
+
userId?: string;
|
|
119
|
+
versionTag?: string;
|
|
120
|
+
/** A case-insensitive fragment of the title. */
|
|
121
|
+
title?: string;
|
|
122
|
+
startTime?: string;
|
|
123
|
+
endTime?: string;
|
|
124
|
+
size?: number;
|
|
125
|
+
after?: string;
|
|
126
|
+
before?: string;
|
|
127
|
+
}
|
|
53
128
|
export interface SkillIndexItem {
|
|
54
129
|
id: string;
|
|
55
130
|
description: string;
|
|
@@ -84,6 +159,16 @@ export declare class RuntimeApiClient {
|
|
|
84
159
|
status: string;
|
|
85
160
|
}>;
|
|
86
161
|
sendMessage(agentId: string | undefined, input: SendMessageRequest): Promise<SendMessageResponse>;
|
|
162
|
+
/** Whether this client can stream a turn (the shared transport can; a bare test double may not). */
|
|
163
|
+
get canStream(): boolean;
|
|
164
|
+
/**
|
|
165
|
+
* The same turn as `sendMessage`, streamed: each frame as the runtime sends
|
|
166
|
+
* it, until `[DONE]`. Frames of a type this build does not know are skipped,
|
|
167
|
+
* so a newer runtime never breaks an older console.
|
|
168
|
+
*/
|
|
169
|
+
streamMessage(agentId: string | undefined, input: SendMessageRequest, options?: {
|
|
170
|
+
signal?: AbortSignal;
|
|
171
|
+
}): AsyncGenerator<ChatStreamEvent>;
|
|
87
172
|
createThread(input: {
|
|
88
173
|
agentId?: string;
|
|
89
174
|
versionId?: string;
|
|
@@ -99,20 +184,20 @@ export declare class RuntimeApiClient {
|
|
|
99
184
|
after?: string;
|
|
100
185
|
before?: string;
|
|
101
186
|
}): Promise<Thread[]>;
|
|
187
|
+
/** The user's threads across every agent, one keyset page. */
|
|
188
|
+
userThreadPage(userId: string, options?: {
|
|
189
|
+
size?: number;
|
|
190
|
+
after?: string;
|
|
191
|
+
before?: string;
|
|
192
|
+
}): Promise<ThreadPage>;
|
|
102
193
|
/**
|
|
103
194
|
* Threads bound to an agent, newest first — the listing the runtime intends
|
|
104
195
|
* UIs to use (the per-user route above stays for tooling). Filters compose:
|
|
105
196
|
* owner, version tag, creation window. Keyset: `after`/`before` + `size`.
|
|
106
197
|
*/
|
|
107
|
-
listAgentThreads(agentId: string, filters?:
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
startTime?: string;
|
|
111
|
-
endTime?: string;
|
|
112
|
-
size?: number;
|
|
113
|
-
after?: string;
|
|
114
|
-
before?: string;
|
|
115
|
-
}): Promise<Thread[]>;
|
|
198
|
+
listAgentThreads(agentId: string, filters?: AgentThreadFilters): Promise<Thread[]>;
|
|
199
|
+
/** An agent's threads, newest first, one keyset page. */
|
|
200
|
+
agentThreadPage(agentId: string, filters?: AgentThreadFilters): Promise<ThreadPage>;
|
|
116
201
|
listMessages(threadId: string): Promise<Message[]>;
|
|
117
202
|
threadTrace(threadId: string): Promise<RuntimeTrace[]>;
|
|
118
203
|
/** Thread-scoped, like the served route: a branch copies the parent's
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { pageLane } from "./lane.js";
|
|
2
2
|
import { GATE_TIMEOUT_MS, TURN_TIMEOUT_MS } from "./timeouts.js";
|
|
3
|
+
const STREAM_EVENT_TYPES = new Set(["thread", "event", "trace", "cards", "message", "suggestions", "error"]);
|
|
3
4
|
/**
|
|
4
5
|
* A send is synchronous on the wire — the response IS the agent's turn, and
|
|
5
6
|
* normal turn latency can exceed the 60s transport default (REPORTS-27).
|
|
@@ -23,6 +24,39 @@ export class RuntimeApiClient {
|
|
|
23
24
|
timeoutMs: TURN_TIMEOUT_MS,
|
|
24
25
|
});
|
|
25
26
|
}
|
|
27
|
+
/** Whether this client can stream a turn (the shared transport can; a bare test double may not). */
|
|
28
|
+
get canStream() {
|
|
29
|
+
return typeof this.http.stream === "function";
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* The same turn as `sendMessage`, streamed: each frame as the runtime sends
|
|
33
|
+
* it, until `[DONE]`. Frames of a type this build does not know are skipped,
|
|
34
|
+
* so a newer runtime never breaks an older console.
|
|
35
|
+
*/
|
|
36
|
+
async *streamMessage(agentId, input, options = {}) {
|
|
37
|
+
if (this.http.stream === undefined)
|
|
38
|
+
throw new Error("This client cannot stream.");
|
|
39
|
+
for await (const frame of this.http.stream("/messaging/v1/messages/stream", {
|
|
40
|
+
method: "POST",
|
|
41
|
+
...(agentId ? { headers: { "x-aui-agent-id": agentId } } : {}),
|
|
42
|
+
body: input,
|
|
43
|
+
timeoutMs: TURN_TIMEOUT_MS,
|
|
44
|
+
...(options.signal ? { signal: options.signal } : {}),
|
|
45
|
+
})) {
|
|
46
|
+
if (frame.data.trim() === "[DONE]")
|
|
47
|
+
return;
|
|
48
|
+
let parsed;
|
|
49
|
+
try {
|
|
50
|
+
parsed = JSON.parse(frame.data);
|
|
51
|
+
}
|
|
52
|
+
catch {
|
|
53
|
+
continue; // a frame that cannot be parsed is one we cannot act on
|
|
54
|
+
}
|
|
55
|
+
const type = parsed?.type;
|
|
56
|
+
if (typeof type === "string" && STREAM_EVENT_TYPES.has(type))
|
|
57
|
+
yield parsed;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
26
60
|
createThread(input) {
|
|
27
61
|
return this.http.request("/api/v1/tasks", {
|
|
28
62
|
method: "POST",
|
|
@@ -45,14 +79,17 @@ export class RuntimeApiClient {
|
|
|
45
79
|
return this.http.request(`/api/v1/tasks/${threadId}`);
|
|
46
80
|
}
|
|
47
81
|
async listThreads(userId, options = {}) {
|
|
48
|
-
|
|
82
|
+
return (await this.userThreadPage(userId, options)).items;
|
|
83
|
+
}
|
|
84
|
+
/** The user's threads across every agent, one keyset page. */
|
|
85
|
+
userThreadPage(userId, options = {}) {
|
|
86
|
+
return this.http.request(`/api/v1/users/${encodeURIComponent(userId)}/tasks`, {
|
|
49
87
|
query: {
|
|
50
88
|
size: options.size ?? 25,
|
|
51
89
|
...(options.after ? { after: options.after } : {}),
|
|
52
90
|
...(options.before ? { before: options.before } : {}),
|
|
53
91
|
},
|
|
54
92
|
});
|
|
55
|
-
return listing.items;
|
|
56
93
|
}
|
|
57
94
|
/**
|
|
58
95
|
* Threads bound to an agent, newest first — the listing the runtime intends
|
|
@@ -60,18 +97,22 @@ export class RuntimeApiClient {
|
|
|
60
97
|
* owner, version tag, creation window. Keyset: `after`/`before` + `size`.
|
|
61
98
|
*/
|
|
62
99
|
async listAgentThreads(agentId, filters = {}) {
|
|
63
|
-
|
|
100
|
+
return (await this.agentThreadPage(agentId, filters)).items;
|
|
101
|
+
}
|
|
102
|
+
/** An agent's threads, newest first, one keyset page. */
|
|
103
|
+
agentThreadPage(agentId, filters = {}) {
|
|
104
|
+
return this.http.request(`/api/v1/agents/${encodeURIComponent(agentId)}/tasks`, {
|
|
64
105
|
query: {
|
|
65
106
|
size: filters.size ?? 25,
|
|
66
107
|
...(filters.after ? { after: filters.after } : {}),
|
|
67
108
|
...(filters.before ? { before: filters.before } : {}),
|
|
68
109
|
...(filters.userId ? { created_by: filters.userId } : {}),
|
|
69
110
|
...(filters.versionTag ? { version_tag: filters.versionTag } : {}),
|
|
111
|
+
...(filters.title ? { title: filters.title } : {}),
|
|
70
112
|
...(filters.startTime ? { start_time: filters.startTime } : {}),
|
|
71
113
|
...(filters.endTime ? { end_time: filters.endTime } : {}),
|
|
72
114
|
},
|
|
73
115
|
});
|
|
74
|
-
return listing.items;
|
|
75
116
|
}
|
|
76
117
|
listMessages(threadId) {
|
|
77
118
|
return this.http.request(`/messaging/v1/threads/${threadId}/messages`);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runtime-api.js","sourceRoot":"","sources":["../../../src/api/runtime-api.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AACrC,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"runtime-api.js","sourceRoot":"","sources":["../../../src/api/runtime-api.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AACrC,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAkFjE,MAAM,kBAAkB,GAAG,IAAI,GAAG,CAAC,CAAC,QAAQ,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,OAAO,CAAC,CAAC,CAAC;AAuC7G;;;;;GAKG;AACH,OAAO,EAAE,eAAe,EAAE,CAAC;AAE3B,MAAM,OAAO,gBAAgB;IACS;IAApC,YAAoC,IAAgB;QAAhB,SAAI,GAAJ,IAAI,CAAY;IAAG,CAAC;IAEjD,MAAM;QACX,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;IACtC,CAAC;IAEM,WAAW,CAChB,OAA2B,EAC3B,KAAyB;QAEzB,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,wBAAwB,EAA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AO,CAAC,kBAAkB,kBAAkB,CAAC,OAAO,CAAC,EAAE,EAAE;YACxE,KAAK,EAAE,EAAE,IAAI,EAAE;SAChB,CAAC,CAAC;IACL,CAAC;IAED;;;;;;;;;;OAUG;IACI,WAAW;QAChB,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,mBAAmB,EAAE;YAC5C,KAAK,EAAE,EAAE,GAAG,QAAQ,EAAE,CAAC,KAAK,EAAE;SAC/B,CAAC,CAAC;IACL,CAAC;IAEM,iBAAiB,CAAC,IAAa;QACpC,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,yBAAyB,EAAE;YAClD,KAAK,EAAE,EAAE,IAAI,EAAE;SAChB,CAAC,CAAC;IACL,CAAC;IAED;;;;;;OAMG;IACI,eAAe,CACpB,MAA+B,EAC/B,UAAgC,EAAE;QASlC,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,2BAA2B,EAAE;YACpD,MAAM,EAAE,MAAM;YACd,IAAI,EAAE,EAAE,MAAM,EAAE,GAAG,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,OAAO,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE;YAC3E,SAAS,EAAE,eAAe;SAC3B,CAAC,CAAC;IACL,CAAC;CAEF"}
|
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
import { type CaptureSink } from "./capture.js";
|
|
2
|
+
import type { SseEvent, StreamRequestOptions } from "./client-types.js";
|
|
3
|
+
/** One streamed frame larger than this is refused rather than buffered. */
|
|
4
|
+
export declare const MAX_SSE_FRAME_BYTES: number;
|
|
2
5
|
export interface RequestCapture {
|
|
3
6
|
/** Optional on the type so entries from older capture files still parse. */
|
|
4
7
|
service?: string;
|
|
@@ -95,9 +98,30 @@ export declare class Transport {
|
|
|
95
98
|
private set token(value);
|
|
96
99
|
request<T>(path: string, requestOptions?: RequestOptions): Promise<T>;
|
|
97
100
|
private route;
|
|
101
|
+
/**
|
|
102
|
+
* Server-sent events from one request, as they arrive. Shares every rule
|
|
103
|
+
* `request` applies — auth and one refresh on a 401, org and routing
|
|
104
|
+
* headers, the timeout floor (here it bounds the WHOLE stream), the capture
|
|
105
|
+
* log — and is never retried after a frame arrived. Aborting `signal`
|
|
106
|
+
* (Ctrl+C) ends it with CANCELLED; a consumer that stops reading early
|
|
107
|
+
* closes the connection.
|
|
108
|
+
*/
|
|
109
|
+
stream(path: string, streamOptions?: StreamRequestOptions): AsyncGenerator<SseEvent>;
|
|
110
|
+
private timedOut;
|
|
111
|
+
private record;
|
|
112
|
+
/** The URL, headers, body, timeout and capture entry of one request. */
|
|
113
|
+
private prepare;
|
|
98
114
|
private perform;
|
|
99
115
|
private apiError;
|
|
100
116
|
}
|
|
117
|
+
/**
|
|
118
|
+
* Server-sent events off a response body (the WHATWG framing: a blank line
|
|
119
|
+
* ends an event; `data:` lines join with newlines; `event:` and `id:` name
|
|
120
|
+
* it; a line starting with `:` is a comment). CRLF and CR line ends are
|
|
121
|
+
* read as LF — a CR at the end of a chunk waits for the next one, which may
|
|
122
|
+
* hold its LF.
|
|
123
|
+
*/
|
|
124
|
+
export declare function readServerSentEvents(body: ReadableStream<Uint8Array>): AsyncGenerator<SseEvent>;
|
|
101
125
|
/** Header redaction for clients that build a plain record instead of `Headers`. */
|
|
102
126
|
export declare function redactHeaderRecord(headers: Record<string, string>): Record<string, string>;
|
|
103
127
|
export declare function redact(value: unknown, key?: string): unknown;
|