aui-agent-builder 0.3.112 → 0.3.113
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 +51 -0
- package/dist/api-client/apollo-client.d.ts +162 -0
- package/dist/api-client/apollo-client.d.ts.map +1 -0
- package/dist/api-client/apollo-client.js +285 -0
- package/dist/api-client/apollo-client.js.map +1 -0
- package/dist/commands/apollo.d.ts +77 -0
- package/dist/commands/apollo.d.ts.map +1 -0
- package/dist/commands/apollo.js +410 -0
- package/dist/commands/apollo.js.map +1 -0
- package/dist/commands/index.d.ts +1 -0
- package/dist/commands/index.d.ts.map +1 -1
- package/dist/commands/index.js +1 -0
- package/dist/commands/index.js.map +1 -1
- package/dist/commands/util/bundled-agent.d.ts +46 -0
- package/dist/commands/util/bundled-agent.d.ts.map +1 -0
- package/dist/commands/util/bundled-agent.js +50 -0
- package/dist/commands/util/bundled-agent.js.map +1 -0
- package/dist/commands/validate.d.ts +10 -0
- package/dist/commands/validate.d.ts.map +1 -1
- package/dist/commands/validate.js +8 -0
- package/dist/commands/validate.js.map +1 -1
- package/dist/config/index.d.ts +7 -0
- package/dist/config/index.d.ts.map +1 -1
- package/dist/config/index.js +13 -0
- package/dist/config/index.js.map +1 -1
- package/dist/index.js +102 -0
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -341,6 +341,57 @@ aui serve # Web chat playground (localhost:3141)
|
|
|
341
341
|
aui serve --port 8080 # Custom port
|
|
342
342
|
```
|
|
343
343
|
|
|
344
|
+
### Runtime Messaging — Apollo (bundle-mode agents only)
|
|
345
|
+
|
|
346
|
+
Drive an agent at runtime through the Apollo messaging API. These four
|
|
347
|
+
commands are **fully non-interactive**, support `--json`, and are
|
|
348
|
+
**restricted to bundle-mode agents** (records-mode "regular" agents are
|
|
349
|
+
rejected). The target agent is resolved from `--agent-id` or
|
|
350
|
+
`.auirc.agent_management_id`, and authentication uses your normal CLI
|
|
351
|
+
session (`Authorization: Bearer` — the gateway forwards Apollo's service
|
|
352
|
+
auth for you).
|
|
353
|
+
|
|
354
|
+
```bash
|
|
355
|
+
# Create a runtime task
|
|
356
|
+
aui apollo create-task # uses .auirc agent + logged-in user
|
|
357
|
+
aui apollo create-task --agent-id <id> --user-id <id> --task-origin-type web-widget
|
|
358
|
+
|
|
359
|
+
# Send a message — assembles + validates the local .aui.json files and
|
|
360
|
+
# forwards them as the agent settings bundle (same JSON as `aui push`).
|
|
361
|
+
# The returned `id` IS the interaction id (used by rerun / trace).
|
|
362
|
+
aui apollo send-message --task-id <id> --text "Hello"
|
|
363
|
+
aui apollo send-message --task-id <id> --text "Hello" --include-trace # include trace_info
|
|
364
|
+
aui apollo send-message --task-id <id> --text "Hello" --no-bundle # text only, no bundle
|
|
365
|
+
|
|
366
|
+
# Regenerate a task from an interaction and replay a message
|
|
367
|
+
aui apollo rerun --task-id <id> --interaction-id <iid> --text "Edited"
|
|
368
|
+
aui apollo rerun --task-id <id> --interaction-id <iid> --text "Edited" --with-config # attach validated bundle
|
|
369
|
+
aui apollo rerun --task-id <id> --interaction-id <iid> --text "Edited" --include-trace # include trace_info
|
|
370
|
+
aui apollo rerun --task-id <id> --interaction-id <iid> --text "Edited" --version-id <vid>
|
|
371
|
+
|
|
372
|
+
# Inspect the agent's reasoning (trace)
|
|
373
|
+
aui apollo trace --task-id <id> # all interaction traces
|
|
374
|
+
aui apollo trace --task-id <id> --interaction-id <iid> # a single interaction's trace
|
|
375
|
+
```
|
|
376
|
+
|
|
377
|
+
**Flags by command**
|
|
378
|
+
|
|
379
|
+
| Command | Required | Optional |
|
|
380
|
+
|---|---|---|
|
|
381
|
+
| `create-task` | — | `--agent-id`, `--user-id`, `--task-origin-type`, `--json` |
|
|
382
|
+
| `send-message` | `--task-id`, `--text` | `--include-trace`, `--no-bundle`, `--agent-id`, `--path`, `--json` |
|
|
383
|
+
| `rerun` | `--task-id`, `--interaction-id`, `--text` | `--with-config`, `--include-trace`, `--version-id`, `--agent-id`, `--path`, `--json` |
|
|
384
|
+
| `trace` | `--task-id` | `--interaction-id`, `--agent-id`, `--json` |
|
|
385
|
+
|
|
386
|
+
> **Interaction IDs:** the `id` returned by `aui apollo send-message` is the
|
|
387
|
+
> interaction id — pass it to `rerun --interaction-id` and `trace
|
|
388
|
+
> --interaction-id`.
|
|
389
|
+
|
|
390
|
+
> **Validate-before-send:** `send-message` (and `rerun --with-config`) run
|
|
391
|
+
> the remote validator on your local files first and abort the send if
|
|
392
|
+
> they're invalid — a broken config never reaches the runtime. Run
|
|
393
|
+
> `aui validate` to see specific errors.
|
|
394
|
+
|
|
344
395
|
### Configuration & Utilities
|
|
345
396
|
|
|
346
397
|
```bash
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Apollo API client — runtime messaging orchestration (tasks, messages,
|
|
3
|
+
* rerun, trace).
|
|
4
|
+
*
|
|
5
|
+
* Wraps four Apollo endpoints behind the AUI gateway:
|
|
6
|
+
*
|
|
7
|
+
* POST /apollo-api/v1/messaging/tasks → createTask
|
|
8
|
+
* POST /apollo-api/v1/messaging/messages[?include_trace=] → sendMessage
|
|
9
|
+
* POST /apollo-api/v1/messaging/messages/rerun → rerunMessage
|
|
10
|
+
* GET /apollo-api/v1/messaging/tasks/{task_id}/trace-info → getTaskTraceInfo
|
|
11
|
+
*
|
|
12
|
+
* ─── Authentication ─────────────────────────────────────────────────────
|
|
13
|
+
*
|
|
14
|
+
* Apollo itself is `x-api-key`-only (compared constant-time against its
|
|
15
|
+
* service key) and trusts `x-aui-*` claims injected by the gateway. The
|
|
16
|
+
* CLI never holds that service key — it talks to the GATEWAY, which:
|
|
17
|
+
* 1. validates the CLI's user/session token,
|
|
18
|
+
* 2. strips `Authorization`,
|
|
19
|
+
* 3. forwards `x-api-key` + gateway-enriched `x-aui-organization-id` /
|
|
20
|
+
* `x-aui-user-id` to Apollo.
|
|
21
|
+
*
|
|
22
|
+
* So from the CLI we send the same session auth the agent-settings /
|
|
23
|
+
* agent-management routes use — `Authorization: Bearer <token>` + org
|
|
24
|
+
* headers — which the gateway validates and translates. (The outer-bridge
|
|
25
|
+
* `x-access-token` header does NOT work here: the gateway returns
|
|
26
|
+
* `{"decision":"deny","reason":"missing_credentials"}`.) We additionally
|
|
27
|
+
* forward the org id in the new `x-aui-organization-id`
|
|
28
|
+
* (and legacy `X-Organization-ID`) shapes, and the acting user in
|
|
29
|
+
* `x-aui-user-id` for the rerun route — harmless if the gateway
|
|
30
|
+
* overrides them with its own trusted claims, and correct if a given
|
|
31
|
+
* deployment passes them through.
|
|
32
|
+
*
|
|
33
|
+
* ─── Telemetry ──────────────────────────────────────────────────────────
|
|
34
|
+
*
|
|
35
|
+
* Every call captures the request (for `aui curl`) and attaches a
|
|
36
|
+
* redacted, replayable curl + HTTP status/body/duration onto the active
|
|
37
|
+
* OTel span — the same pattern the agent-settings client uses
|
|
38
|
+
* (`attachHttpCurlTelemetry`). Purely additive; never throws from the
|
|
39
|
+
* telemetry path.
|
|
40
|
+
*/
|
|
41
|
+
import { AUIEnvironment } from "../config/index.js";
|
|
42
|
+
/** Body for `POST /v1/messaging/tasks` (CreateTaskRequestSchema). */
|
|
43
|
+
export interface ApolloCreateTaskRequest {
|
|
44
|
+
/** Agent the task targets. Apollo resolves network_id + active version
|
|
45
|
+
* from agent-settings; the agent's org must match the caller's org. */
|
|
46
|
+
agent_id: string;
|
|
47
|
+
/** End-user ref id used to attribute the task (label, not a security
|
|
48
|
+
* boundary). */
|
|
49
|
+
user_id: string;
|
|
50
|
+
/** RecordOrigin.type value (e.g. web-widget, third-party, stores). */
|
|
51
|
+
task_origin_type: string;
|
|
52
|
+
}
|
|
53
|
+
/** Response from `POST /v1/messaging/tasks` (CreateTaskResponseSchema). */
|
|
54
|
+
export interface ApolloCreateTaskResponse {
|
|
55
|
+
id: string;
|
|
56
|
+
user_id: string;
|
|
57
|
+
title: string;
|
|
58
|
+
welcome_message?: string | null;
|
|
59
|
+
followup_suggestions?: string[] | null;
|
|
60
|
+
[key: string]: unknown;
|
|
61
|
+
}
|
|
62
|
+
/** Body for `POST /v1/messaging/messages` (SubmitMessageRequest). */
|
|
63
|
+
export interface ApolloSubmitMessageRequest {
|
|
64
|
+
type?: "message";
|
|
65
|
+
task_id: string;
|
|
66
|
+
text?: string;
|
|
67
|
+
context?: Record<string, unknown> | null;
|
|
68
|
+
agent_variables?: Record<string, unknown>;
|
|
69
|
+
/** Assembled agent-settings bundle (same JSON shape as the blob /push
|
|
70
|
+
* endpoint). Forwarded to intelligent-agent under
|
|
71
|
+
* `external_context.agent_settings_bundle`. */
|
|
72
|
+
agent_settings_bundle?: Record<string, unknown> | null;
|
|
73
|
+
}
|
|
74
|
+
/** Agent reply (MessageResponse). */
|
|
75
|
+
export interface ApolloMessageResponse {
|
|
76
|
+
id: string;
|
|
77
|
+
created_at: string;
|
|
78
|
+
text: string;
|
|
79
|
+
sender: Record<string, unknown>;
|
|
80
|
+
receiver: Record<string, unknown>;
|
|
81
|
+
cards?: Array<Record<string, unknown>>;
|
|
82
|
+
welcome_message?: string | null;
|
|
83
|
+
followup_suggestions?: string[];
|
|
84
|
+
url?: string | null;
|
|
85
|
+
input_tokens?: number;
|
|
86
|
+
output_tokens?: number;
|
|
87
|
+
trace_info?: Record<string, unknown> | null;
|
|
88
|
+
[key: string]: unknown;
|
|
89
|
+
}
|
|
90
|
+
/** Body for `POST /v1/messaging/messages/rerun` (RerunMessageRequest). */
|
|
91
|
+
export interface ApolloRerunMessageRequest {
|
|
92
|
+
task_id: string;
|
|
93
|
+
interaction_id: string;
|
|
94
|
+
/** Message text to replay onto the regenerated task (min length 1). */
|
|
95
|
+
text: string;
|
|
96
|
+
image?: Record<string, unknown> | null;
|
|
97
|
+
agent?: {
|
|
98
|
+
agent_id?: string | null;
|
|
99
|
+
version_id?: string | null;
|
|
100
|
+
} | null;
|
|
101
|
+
/** Optional agent-settings bundle (same shape as /push). */
|
|
102
|
+
agent_settings_bundle?: Record<string, unknown> | null;
|
|
103
|
+
}
|
|
104
|
+
/** Response from `POST /v1/messaging/messages/rerun` (RerunMessageResponse). */
|
|
105
|
+
export interface ApolloRerunMessageResponse {
|
|
106
|
+
regenerated_task_id: string;
|
|
107
|
+
message: ApolloMessageResponse;
|
|
108
|
+
}
|
|
109
|
+
export interface ApolloClientOptions {
|
|
110
|
+
/** JWT access token from `aui login`. */
|
|
111
|
+
authToken: string;
|
|
112
|
+
/** Organization id (forwarded for the gateway trust boundary). */
|
|
113
|
+
organizationId: string;
|
|
114
|
+
/** Account id (optional, forwarded for parity with other clients). */
|
|
115
|
+
accountId?: string;
|
|
116
|
+
/** Acting user id — forwarded as `x-aui-user-id` on rerun. */
|
|
117
|
+
userId?: string;
|
|
118
|
+
/** Backend environment (selects the Apollo base URL). */
|
|
119
|
+
environment: AUIEnvironment;
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Thin HTTP client for the Apollo runtime messaging endpoints. Stateless
|
|
123
|
+
* apart from the auth/scope it was constructed with.
|
|
124
|
+
*/
|
|
125
|
+
export declare class ApolloClient {
|
|
126
|
+
private authToken;
|
|
127
|
+
private organizationId;
|
|
128
|
+
private accountId;
|
|
129
|
+
private userId;
|
|
130
|
+
private environment;
|
|
131
|
+
constructor(options: ApolloClientOptions);
|
|
132
|
+
private baseUrl;
|
|
133
|
+
/**
|
|
134
|
+
* Build the gateway auth + scope headers. `extra` lets per-route
|
|
135
|
+
* callers add headers like `x-aui-user-id` (rerun only).
|
|
136
|
+
*/
|
|
137
|
+
private headers;
|
|
138
|
+
/** `POST /v1/messaging/tasks` — create a task for an agent. */
|
|
139
|
+
createTask(body: ApolloCreateTaskRequest): Promise<ApolloCreateTaskResponse>;
|
|
140
|
+
/** `POST /v1/messaging/messages` — submit a user message, get the reply. */
|
|
141
|
+
sendMessage(body: ApolloSubmitMessageRequest, options?: {
|
|
142
|
+
includeTrace?: boolean;
|
|
143
|
+
}): Promise<ApolloMessageResponse>;
|
|
144
|
+
/** `POST /v1/messaging/messages/rerun` — regenerate a task + replay. */
|
|
145
|
+
rerunMessage(body: ApolloRerunMessageRequest, options?: {
|
|
146
|
+
includeTrace?: boolean;
|
|
147
|
+
}): Promise<ApolloRerunMessageResponse>;
|
|
148
|
+
/** `GET /v1/messaging/tasks/{task_id}/trace-info` — all interaction traces. */
|
|
149
|
+
getTaskTraceInfo(taskId: string): Promise<Array<Record<string, unknown>>>;
|
|
150
|
+
/**
|
|
151
|
+
* `GET /v1/messaging/tasks/{task_id}/interactions/{interaction_id}/trace-info`
|
|
152
|
+
* — the trace for a single interaction (object, not a list).
|
|
153
|
+
*/
|
|
154
|
+
getInteractionTraceInfo(taskId: string, interactionId: string): Promise<Record<string, unknown>>;
|
|
155
|
+
private request;
|
|
156
|
+
/**
|
|
157
|
+
* Capture the request for `aui curl` and attach a redacted curl repro
|
|
158
|
+
* + HTTP fields onto the active span. Best-effort; never throws.
|
|
159
|
+
*/
|
|
160
|
+
private attachTelemetry;
|
|
161
|
+
}
|
|
162
|
+
//# sourceMappingURL=apollo-client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"apollo-client.d.ts","sourceRoot":"","sources":["../../src/api-client/apollo-client.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AAKH,OAAO,EACL,cAAc,EAEf,MAAM,oBAAoB,CAAC;AAO5B,qEAAqE;AACrE,MAAM,WAAW,uBAAuB;IACtC;4EACwE;IACxE,QAAQ,EAAE,MAAM,CAAC;IACjB;qBACiB;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,sEAAsE;IACtE,gBAAgB,EAAE,MAAM,CAAC;CAC1B;AAED,2EAA2E;AAC3E,MAAM,WAAW,wBAAwB;IACvC,EAAE,EAAE,MAAM,CAAC;IACX,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,eAAe,CAAC,EAAE,MAAM,GAAG,IAAI,CA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AE;QAAE,YAAY,CAAC,EAAE,OAAO,CAAA;KAAO,GACvC,OAAO,CAAC,qBAAqB,CAAC;IAWjC,wEAAwE;IAClE,YAAY,CAChB,IAAI,EAAE,yBAAyB,EAC/B,OAAO,GAAE;QAAE,YAAY,CAAC,EAAE,OAAO,CAAA;KAAO,GACvC,OAAO,CAAC,0BAA0B,CAAC;IAkBtC,+EAA+E;IACzE,gBAAgB,CACpB,MAAM,EAAE,MAAM,GACb,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;IAS1C;;;OAGG;IACG,uBAAuB,CAC3B,MAAM,EAAE,MAAM,EACd,aAAa,EAAE,MAAM,GACpB,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;YAWrB,OAAO;IA6ErB;;;OAGG;IACH,OAAO,CAAC,eAAe;CAqExB"}
|
|
@@ -0,0 +1,285 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Apollo API client — runtime messaging orchestration (tasks, messages,
|
|
3
|
+
* rerun, trace).
|
|
4
|
+
*
|
|
5
|
+
* Wraps four Apollo endpoints behind the AUI gateway:
|
|
6
|
+
*
|
|
7
|
+
* POST /apollo-api/v1/messaging/tasks → createTask
|
|
8
|
+
* POST /apollo-api/v1/messaging/messages[?include_trace=] → sendMessage
|
|
9
|
+
* POST /apollo-api/v1/messaging/messages/rerun → rerunMessage
|
|
10
|
+
* GET /apollo-api/v1/messaging/tasks/{task_id}/trace-info → getTaskTraceInfo
|
|
11
|
+
*
|
|
12
|
+
* ─── Authentication ─────────────────────────────────────────────────────
|
|
13
|
+
*
|
|
14
|
+
* Apollo itself is `x-api-key`-only (compared constant-time against its
|
|
15
|
+
* service key) and trusts `x-aui-*` claims injected by the gateway. The
|
|
16
|
+
* CLI never holds that service key — it talks to the GATEWAY, which:
|
|
17
|
+
* 1. validates the CLI's user/session token,
|
|
18
|
+
* 2. strips `Authorization`,
|
|
19
|
+
* 3. forwards `x-api-key` + gateway-enriched `x-aui-organization-id` /
|
|
20
|
+
* `x-aui-user-id` to Apollo.
|
|
21
|
+
*
|
|
22
|
+
* So from the CLI we send the same session auth the agent-settings /
|
|
23
|
+
* agent-management routes use — `Authorization: Bearer <token>` + org
|
|
24
|
+
* headers — which the gateway validates and translates. (The outer-bridge
|
|
25
|
+
* `x-access-token` header does NOT work here: the gateway returns
|
|
26
|
+
* `{"decision":"deny","reason":"missing_credentials"}`.) We additionally
|
|
27
|
+
* forward the org id in the new `x-aui-organization-id`
|
|
28
|
+
* (and legacy `X-Organization-ID`) shapes, and the acting user in
|
|
29
|
+
* `x-aui-user-id` for the rerun route — harmless if the gateway
|
|
30
|
+
* overrides them with its own trusted claims, and correct if a given
|
|
31
|
+
* deployment passes them through.
|
|
32
|
+
*
|
|
33
|
+
* ─── Telemetry ──────────────────────────────────────────────────────────
|
|
34
|
+
*
|
|
35
|
+
* Every call captures the request (for `aui curl`) and attaches a
|
|
36
|
+
* redacted, replayable curl + HTTP status/body/duration onto the active
|
|
37
|
+
* OTel span — the same pattern the agent-settings client uses
|
|
38
|
+
* (`attachHttpCurlTelemetry`). Purely additive; never throws from the
|
|
39
|
+
* telemetry path.
|
|
40
|
+
*/
|
|
41
|
+
import fetch, { FetchTimeoutError } from "../utils/fetch-with-timeout.js";
|
|
42
|
+
import { randomUUID } from "node:crypto";
|
|
43
|
+
import { getApolloBaseUrl, } from "../config/index.js";
|
|
44
|
+
import { captureRequest, formatAsCurlSafe } from "../utils/request-capture.js";
|
|
45
|
+
import { trace } from "@opentelemetry/api";
|
|
46
|
+
import { AUIAPIError } from "./index.js";
|
|
47
|
+
/**
|
|
48
|
+
* Thin HTTP client for the Apollo runtime messaging endpoints. Stateless
|
|
49
|
+
* apart from the auth/scope it was constructed with.
|
|
50
|
+
*/
|
|
51
|
+
export class ApolloClient {
|
|
52
|
+
authToken;
|
|
53
|
+
organizationId;
|
|
54
|
+
accountId;
|
|
55
|
+
userId;
|
|
56
|
+
environment;
|
|
57
|
+
constructor(options) {
|
|
58
|
+
this.authToken = options.authToken;
|
|
59
|
+
this.organizationId = options.organizationId || "";
|
|
60
|
+
this.accountId = options.accountId || "";
|
|
61
|
+
this.userId = options.userId || "";
|
|
62
|
+
this.environment = options.environment;
|
|
63
|
+
}
|
|
64
|
+
baseUrl() {
|
|
65
|
+
return getApolloBaseUrl(this.environment).replace(/\/+$/, "");
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Build the gateway auth + scope headers. `extra` lets per-route
|
|
69
|
+
* callers add headers like `x-aui-user-id` (rerun only).
|
|
70
|
+
*/
|
|
71
|
+
headers(extra) {
|
|
72
|
+
const h = {
|
|
73
|
+
accept: "application/json, text/plain, */*",
|
|
74
|
+
"content-type": "application/json",
|
|
75
|
+
// The gateway in front of Apollo authenticates on the standard
|
|
76
|
+
// `Authorization: Bearer <token>` header (same as the
|
|
77
|
+
// agent-settings / agent-management routes) — NOT the outer-bridge
|
|
78
|
+
// `x-access-token` convention. It validates the token, strips
|
|
79
|
+
// Authorization, and forwards Apollo's `x-api-key` + `x-aui-*`
|
|
80
|
+
// claims. Sending `x-access-token` instead yields a gateway 401
|
|
81
|
+
// `{"decision":"deny","reason":"missing_credentials"}`.
|
|
82
|
+
Authorization: `Bearer ${this.authToken}`,
|
|
83
|
+
"account-id": this.accountId,
|
|
84
|
+
"organization-id": this.organizationId,
|
|
85
|
+
// New gateway-trusted org claim shape + legacy fallback. Sending
|
|
86
|
+
// both is safe: the gateway overrides with its own trusted claim
|
|
87
|
+
// when it injects one, and passes ours through otherwise.
|
|
88
|
+
"x-aui-organization-id": this.organizationId,
|
|
89
|
+
"X-Organization-ID": this.organizationId,
|
|
90
|
+
"x-aui-client": "AUI",
|
|
91
|
+
"x-aui-environment": this.environment,
|
|
92
|
+
"x-aui-origin": "stores",
|
|
93
|
+
// Marks the caller for billing/task_origin without opting into the
|
|
94
|
+
// gateway network-scope path (which is keyed on the literal "pk").
|
|
95
|
+
"x-aui-source": "cli",
|
|
96
|
+
"x-trace-id": randomUUID(),
|
|
97
|
+
};
|
|
98
|
+
return { ...h, ...(extra ?? {}) };
|
|
99
|
+
}
|
|
100
|
+
// ─── Endpoints ───
|
|
101
|
+
/** `POST /v1/messaging/tasks` — create a task for an agent. */
|
|
102
|
+
async createTask(body) {
|
|
103
|
+
return this.request({
|
|
104
|
+
name: "apollo_create_task",
|
|
105
|
+
label: "apollo create task",
|
|
106
|
+
method: "POST",
|
|
107
|
+
path: "/v1/messaging/tasks",
|
|
108
|
+
body,
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
/** `POST /v1/messaging/messages` — submit a user message, get the reply. */
|
|
112
|
+
async sendMessage(body, options = {}) {
|
|
113
|
+
const query = options.includeTrace ? "?include_trace=true" : "";
|
|
114
|
+
return this.request({
|
|
115
|
+
name: "apollo_send_message",
|
|
116
|
+
label: "apollo send message",
|
|
117
|
+
method: "POST",
|
|
118
|
+
path: `/v1/messaging/messages${query}`,
|
|
119
|
+
body: { type: "message", ...body },
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
/** `POST /v1/messaging/messages/rerun` — regenerate a task + replay. */
|
|
123
|
+
async rerunMessage(body, options = {}) {
|
|
124
|
+
// The acting user is gateway-enriched via `x-aui-user-id` (never the
|
|
125
|
+
// body) — see RerunMessageRequest docs in the openapi spec.
|
|
126
|
+
const extra = this.userId ? { "x-aui-user-id": this.userId } : undefined;
|
|
127
|
+
// `include_trace` mirrors the send-message contract: when true, the
|
|
128
|
+
// runtime makes the extra IA call and returns `trace_info` on the
|
|
129
|
+
// replayed message.
|
|
130
|
+
const query = options.includeTrace ? "?include_trace=true" : "";
|
|
131
|
+
return this.request({
|
|
132
|
+
name: "apollo_rerun_message",
|
|
133
|
+
label: "apollo rerun message",
|
|
134
|
+
method: "POST",
|
|
135
|
+
path: `/v1/messaging/messages/rerun${query}`,
|
|
136
|
+
body,
|
|
137
|
+
extraHeaders: extra,
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
/** `GET /v1/messaging/tasks/{task_id}/trace-info` — all interaction traces. */
|
|
141
|
+
async getTaskTraceInfo(taskId) {
|
|
142
|
+
return this.request({
|
|
143
|
+
name: "apollo_get_task_trace_info",
|
|
144
|
+
label: "apollo get task trace-info",
|
|
145
|
+
method: "GET",
|
|
146
|
+
path: `/v1/messaging/tasks/${encodeURIComponent(taskId)}/trace-info`,
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* `GET /v1/messaging/tasks/{task_id}/interactions/{interaction_id}/trace-info`
|
|
151
|
+
* — the trace for a single interaction (object, not a list).
|
|
152
|
+
*/
|
|
153
|
+
async getInteractionTraceInfo(taskId, interactionId) {
|
|
154
|
+
return this.request({
|
|
155
|
+
name: "apollo_get_interaction_trace_info",
|
|
156
|
+
label: "apollo get interaction trace-info",
|
|
157
|
+
method: "GET",
|
|
158
|
+
path: `/v1/messaging/tasks/${encodeURIComponent(taskId)}/interactions/${encodeURIComponent(interactionId)}/trace-info`,
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
// ─── Core request + telemetry ───
|
|
162
|
+
async request(input) {
|
|
163
|
+
const url = `${this.baseUrl()}${input.path}`;
|
|
164
|
+
const headers = this.headers(input.extraHeaders);
|
|
165
|
+
const init = { method: input.method, headers };
|
|
166
|
+
if (input.body !== undefined)
|
|
167
|
+
init.body = JSON.stringify(input.body);
|
|
168
|
+
const startedAt = Date.now();
|
|
169
|
+
let response;
|
|
170
|
+
try {
|
|
171
|
+
response = await fetch(url, init);
|
|
172
|
+
}
|
|
173
|
+
catch (error) {
|
|
174
|
+
// Attach the failed attempt to the span + capture buffer before
|
|
175
|
+
// re-throwing so `aui curl --failed` and Logfire both show it.
|
|
176
|
+
const networkErr = error instanceof FetchTimeoutError
|
|
177
|
+
? error
|
|
178
|
+
: new Error(`Network error: ${error instanceof Error ? error.message : "Connection failed"}`);
|
|
179
|
+
this.attachTelemetry({
|
|
180
|
+
name: input.name,
|
|
181
|
+
label: input.label,
|
|
182
|
+
method: input.method,
|
|
183
|
+
url,
|
|
184
|
+
headers,
|
|
185
|
+
requestBody: input.body,
|
|
186
|
+
responseText: networkErr.message,
|
|
187
|
+
status: 0,
|
|
188
|
+
success: false,
|
|
189
|
+
durationMs: Date.now() - startedAt,
|
|
190
|
+
});
|
|
191
|
+
throw networkErr;
|
|
192
|
+
}
|
|
193
|
+
const responseText = await response.text().catch(() => "");
|
|
194
|
+
this.attachTelemetry({
|
|
195
|
+
name: input.name,
|
|
196
|
+
label: input.label,
|
|
197
|
+
method: input.method,
|
|
198
|
+
url,
|
|
199
|
+
headers,
|
|
200
|
+
requestBody: input.body,
|
|
201
|
+
responseText,
|
|
202
|
+
status: response.status,
|
|
203
|
+
success: response.ok,
|
|
204
|
+
durationMs: Date.now() - startedAt,
|
|
205
|
+
});
|
|
206
|
+
if (!response.ok) {
|
|
207
|
+
let errorBody;
|
|
208
|
+
try {
|
|
209
|
+
errorBody = JSON.parse(responseText);
|
|
210
|
+
}
|
|
211
|
+
catch {
|
|
212
|
+
errorBody = responseText || null;
|
|
213
|
+
}
|
|
214
|
+
throw new AUIAPIError(response.status, `${input.label}: ${response.statusText}`, errorBody);
|
|
215
|
+
}
|
|
216
|
+
if (!responseText)
|
|
217
|
+
return {};
|
|
218
|
+
try {
|
|
219
|
+
return JSON.parse(responseText);
|
|
220
|
+
}
|
|
221
|
+
catch {
|
|
222
|
+
return responseText;
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
/**
|
|
226
|
+
* Capture the request for `aui curl` and attach a redacted curl repro
|
|
227
|
+
* + HTTP fields onto the active span. Best-effort; never throws.
|
|
228
|
+
*/
|
|
229
|
+
attachTelemetry(input) {
|
|
230
|
+
captureRequest({
|
|
231
|
+
timestamp: new Date().toISOString(),
|
|
232
|
+
method: input.method,
|
|
233
|
+
url: input.url,
|
|
234
|
+
headers: input.headers,
|
|
235
|
+
body: input.requestBody,
|
|
236
|
+
status: input.status,
|
|
237
|
+
responseBody: input.responseText,
|
|
238
|
+
label: input.label,
|
|
239
|
+
success: input.success,
|
|
240
|
+
});
|
|
241
|
+
try {
|
|
242
|
+
const span = trace.getActiveSpan();
|
|
243
|
+
if (!span)
|
|
244
|
+
return;
|
|
245
|
+
const MAX = 32 * 1024;
|
|
246
|
+
const truncatedResponse = input.responseText.length > MAX
|
|
247
|
+
? input.responseText.slice(0, MAX) +
|
|
248
|
+
`... [truncated ${input.responseText.length - MAX} bytes]`
|
|
249
|
+
: input.responseText;
|
|
250
|
+
const curl = formatAsCurlSafe({
|
|
251
|
+
timestamp: new Date().toISOString(),
|
|
252
|
+
method: input.method,
|
|
253
|
+
url: input.url,
|
|
254
|
+
headers: input.headers,
|
|
255
|
+
body: input.requestBody,
|
|
256
|
+
status: input.status,
|
|
257
|
+
responseBody: input.responseText,
|
|
258
|
+
label: input.label,
|
|
259
|
+
success: input.success,
|
|
260
|
+
}, { maxBodyBytes: MAX });
|
|
261
|
+
const eventAttrs = {
|
|
262
|
+
"http.method": input.method,
|
|
263
|
+
"http.url": input.url,
|
|
264
|
+
[`${input.name}.success`]: input.success,
|
|
265
|
+
[`${input.name}.duration_ms`]: input.durationMs,
|
|
266
|
+
[`${input.name}.response_body`]: truncatedResponse,
|
|
267
|
+
"aui.curl_repro": curl,
|
|
268
|
+
};
|
|
269
|
+
if (input.status > 0)
|
|
270
|
+
eventAttrs["http.status_code"] = input.status;
|
|
271
|
+
span.addEvent(`http.${input.name}`, eventAttrs);
|
|
272
|
+
// Mirror onto the span itself for the dedicated per-command span.
|
|
273
|
+
span.setAttribute("aui.curl_repro", curl);
|
|
274
|
+
span.setAttribute("http.method", input.method);
|
|
275
|
+
span.setAttribute("http.url", input.url);
|
|
276
|
+
span.setAttribute("http.response_body", truncatedResponse);
|
|
277
|
+
if (input.status > 0)
|
|
278
|
+
span.setAttribute("http.status_code", input.status);
|
|
279
|
+
}
|
|
280
|
+
catch {
|
|
281
|
+
// Telemetry must never break the call path.
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
//# sourceMappingURL=apollo-client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"apollo-client.js","sourceRoot":"","sources":["../../src/api-client/apollo-client.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AAEH,OAAO,KAAK,EAAE,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAC;AAE1E,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAEL,gBAAgB,GACjB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAC/E,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC3C,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAuFzC;;;GAGG;AACH,MAAM,OAAO,YAAY;IACf,SAAS,CAAS;IAClB,cAAc,CAAS;IACvB,SAAS,CAAS;IAClB,MAAM,CAAS;IACf,WAAW,CAAiB;IAEpC,YAAY,OAA4B;QACtC,IAAI,CAAC,SAAS,GAAG,OAAO,CAAC,SAAS,CAAC;QACnC,IAAI,CAAC,cAAc,GAAG,OAAO,CAAC,cAAc,IAAI,EAAE,CAAC;QACnD,IAAI,CAAC,SAAS,GAAG,OAAO,CAAC,SAAS,IAAI,EAAE,CAAC;QACzC,IAAI,CAAC,MAAM,GAAG,OAAO,CAAC,MAAM,IAAI,EAAE,CAAC;QACnC,IAAI,CAAC,WAAW,GAAG,OAAO,CAAC,WAAW,CAAC;IACzC,CAAC;IAEO,OAAO;QACb,OAAO,gBAAgB,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;IAChE,CAAC;IAED;;;OAGG;IACK,OAAO,CAAC,KAA8B;QAC5C,MAAM,CAAC,GAA2B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C3B,UAAU,EAAE,KAAK,CAAC,GAAG;gBACrB,CAAC,GAAG,KAAK,CAAC,IAAI,UAAU,CAAC,EAAE,KAAK,CAAC,OAAO;gBACxC,CAAC,GAAG,KAAK,CAAC,IAAI,cAAc,CAAC,EAAE,KAAK,CAAC,UAAU;gBAC/C,CAAC,GAAG,KAAK,CAAC,IAAI,gBAAgB,CAAC,EAAE,iBAAiB;gBAClD,gBAAgB,EAAE,IAAI;aACvB,CAAC;YACF,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC;gBAAE,UAAU,CAAC,kBAAkB,CAAC,GAAG,KAAK,CAAC,MAAM,CAAC;YACpE,IAAI,CAAC,QAAQ,CAAC,QAAQ,KAAK,CAAC,IAAI,EAAE,EAAE,UAAU,CAAC,CAAC;YAEhD,kEAAkE;YAClE,IAAI,CAAC,YAAY,CAAC,gBAAgB,EAAE,IAAI,CAAC,CAAC;YAC1C,IAAI,CAAC,YAAY,CAAC,aAAa,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;YAC/C,IAAI,CAAC,YAAY,CAAC,UAAU,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC;YACzC,IAAI,CAAC,YAAY,CAAC,oBAAoB,EAAE,iBAAiB,CAAC,CAAC;YAC3D,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC;gBAAE,IAAI,CAAC,YAAY,CAAC,kBAAkB,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;QAC5E,CAAC;QAAC,MAAM,CAAC;YACP,4CAA4C;QAC9C,CAAC;IACH,CAAC;CACF"}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* apollo command group — runtime messaging against the Apollo API.
|
|
3
|
+
*
|
|
4
|
+
* Four subcommands wrap the four new Apollo endpoints (Linear CTS-16442):
|
|
5
|
+
*
|
|
6
|
+
* aui apollo create-task → POST /v1/messaging/tasks
|
|
7
|
+
* aui apollo send-message → POST /v1/messaging/messages[?include_trace]
|
|
8
|
+
* aui apollo rerun → POST /v1/messaging/messages/rerun
|
|
9
|
+
* aui apollo trace → GET /v1/messaging/tasks/{task_id}/trace-info
|
|
10
|
+
*
|
|
11
|
+
* ─── Design notes ───────────────────────────────────────────────────────
|
|
12
|
+
*
|
|
13
|
+
* - **Bundle-mode only.** All four commands resolve the target agent and
|
|
14
|
+
* assert `bundle_mode === true` via `resolveBundledAgent`. Records-mode
|
|
15
|
+
* ("regular") agents are rejected with a clear message — the runtime
|
|
16
|
+
* contract these endpoints implement is agent-first + bundle-based and
|
|
17
|
+
* does not apply to legacy records-mode agents.
|
|
18
|
+
*
|
|
19
|
+
* - **Validate before send.** `send-message` (and `rerun --with-config`)
|
|
20
|
+
* assemble the local `.aui.json` files into the same bundle shape `aui
|
|
21
|
+
* push` sends to the blob endpoint, but FIRST run the remote validate
|
|
22
|
+
* endpoint on them (silently). A broken bundle aborts the send rather
|
|
23
|
+
* than shipping an unusable config to the runtime.
|
|
24
|
+
*
|
|
25
|
+
* - **Fully non-interactive + `--json`.** No prompts; every input is a
|
|
26
|
+
* flag. `--json` emits the canonical `{ success, data }` envelope and
|
|
27
|
+
* suppresses Ink. Mirrors the rest of the CLI.
|
|
28
|
+
*
|
|
29
|
+
* - **Auth.** Uses the normal CLI session (access token + org/account
|
|
30
|
+
* headers). The gateway validates the token and forwards Apollo's
|
|
31
|
+
* `x-api-key` + `x-aui-*` claims — see `api-client/apollo-client.ts`.
|
|
32
|
+
*
|
|
33
|
+
* - **Logging.** Each subcommand opens an `aui.apollo.*` span (nested in
|
|
34
|
+
* the active CLI session / agent trace). The Apollo client attaches a
|
|
35
|
+
* redacted curl repro + HTTP status/body/duration onto that span and
|
|
36
|
+
* captures the request for `aui curl`, exactly like the other clients.
|
|
37
|
+
*/
|
|
38
|
+
export interface ApolloCreateTaskOptions {
|
|
39
|
+
agentId?: string;
|
|
40
|
+
userId?: string;
|
|
41
|
+
taskOriginType?: string;
|
|
42
|
+
}
|
|
43
|
+
export interface ApolloSendMessageOptions {
|
|
44
|
+
taskId?: string;
|
|
45
|
+
text?: string;
|
|
46
|
+
agentId?: string;
|
|
47
|
+
includeTrace?: boolean;
|
|
48
|
+
/**
|
|
49
|
+
* Commander's `--no-bundle` negation: defaults to `true`, set to
|
|
50
|
+
* `false` when the user passes `--no-bundle`. When `false` we skip
|
|
51
|
+
* assembling/validating/forwarding the local agent files.
|
|
52
|
+
*/
|
|
53
|
+
bundle?: boolean;
|
|
54
|
+
path?: string;
|
|
55
|
+
}
|
|
56
|
+
export interface ApolloRerunOptions {
|
|
57
|
+
taskId?: string;
|
|
58
|
+
interactionId?: string;
|
|
59
|
+
text?: string;
|
|
60
|
+
agentId?: string;
|
|
61
|
+
versionId?: string;
|
|
62
|
+
withConfig?: boolean;
|
|
63
|
+
includeTrace?: boolean;
|
|
64
|
+
path?: string;
|
|
65
|
+
}
|
|
66
|
+
export interface ApolloTraceOptions {
|
|
67
|
+
taskId?: string;
|
|
68
|
+
/** When set, fetch the single-interaction trace instead of all traces. */
|
|
69
|
+
interactionId?: string;
|
|
70
|
+
agentId?: string;
|
|
71
|
+
}
|
|
72
|
+
export declare function apolloCreateTask(options?: ApolloCreateTaskOptions): Promise<void>;
|
|
73
|
+
export declare function apolloSendMessage(options?: ApolloSendMessageOptions): Promise<void>;
|
|
74
|
+
export declare function apolloRerun(options?: ApolloRerunOptions): Promise<void>;
|
|
75
|
+
export declare function apolloTrace(options?: ApolloTraceOptions): Promise<void>;
|
|
76
|
+
export declare function apolloMenu(): Promise<void>;
|
|
77
|
+
//# sourceMappingURL=apollo.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"apollo.d.ts","sourceRoot":"","sources":["../../src/commands/apollo.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AAoDH,MAAM,WAAW,uBAAuB;IACtC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB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