@openlegion/platform 0.0.0-stage → 0.1.0
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/LICENSE +202 -0
- package/README.md +1189 -2
- package/dist/body.d.ts +9 -0
- package/dist/body.js +28 -0
- package/dist/chat-history.d.ts +53 -0
- package/dist/chat-history.js +11 -0
- package/dist/client.d.ts +217 -0
- package/dist/client.js +367 -0
- package/dist/core.d.ts +47 -0
- package/dist/core.js +1 -0
- package/dist/crypto.d.ts +25 -0
- package/dist/crypto.js +81 -0
- package/dist/errors.d.ts +111 -0
- package/dist/errors.js +134 -0
- package/dist/events.d.ts +131 -0
- package/dist/events.js +5 -0
- package/dist/generated/api.d.ts +5505 -0
- package/dist/generated/api.js +446 -0
- package/dist/handler.d.ts +201 -0
- package/dist/handler.js +682 -0
- package/dist/index.d.ts +24 -0
- package/dist/index.js +12 -0
- package/dist/kit-agents.d.ts +95 -0
- package/dist/kit-agents.js +280 -0
- package/dist/kit-codes.d.ts +279 -0
- package/dist/kit-codes.js +44 -0
- package/dist/kit-connections.d.ts +21 -0
- package/dist/kit-connections.js +189 -0
- package/dist/kit-files.d.ts +8 -0
- package/dist/kit-files.js +117 -0
- package/dist/kit-model-keys.d.ts +8 -0
- package/dist/kit-model-keys.js +86 -0
- package/dist/kit-threads.d.ts +3 -0
- package/dist/kit-threads.js +92 -0
- package/dist/kit-tools.d.ts +21 -0
- package/dist/kit-tools.js +47 -0
- package/dist/kit.d.ts +130 -0
- package/dist/kit.js +155 -0
- package/dist/mcp-server.d.ts +27 -0
- package/dist/mcp-server.js +166 -0
- package/dist/next.d.ts +24 -0
- package/dist/next.js +6 -0
- package/dist/ol-signed.d.ts +82 -0
- package/dist/ol-signed.js +115 -0
- package/dist/react/add-server.d.ts +90 -0
- package/dist/react/add-server.js +183 -0
- package/dist/react/agent-chat.d.ts +925 -0
- package/dist/react/agent-chat.js +1917 -0
- package/dist/react/agent-editor.d.ts +133 -0
- package/dist/react/agent-editor.js +222 -0
- package/dist/react/agent-kit.d.ts +160 -0
- package/dist/react/agent-kit.js +279 -0
- package/dist/react/agent-list.d.ts +247 -0
- package/dist/react/agent-list.js +248 -0
- package/dist/react/approval-card.d.ts +272 -0
- package/dist/react/approval-card.js +372 -0
- package/dist/react/artifact-card.d.ts +38 -0
- package/dist/react/artifact-card.js +39 -0
- package/dist/react/avatar.d.ts +21 -0
- package/dist/react/avatar.js +33 -0
- package/dist/react/card-ledger.d.ts +30 -0
- package/dist/react/card-ledger.js +49 -0
- package/dist/react/chat-timing.d.ts +121 -0
- package/dist/react/chat-timing.js +229 -0
- package/dist/react/computer-view.d.ts +309 -0
- package/dist/react/computer-view.js +543 -0
- package/dist/react/computer-viewer.d.ts +175 -0
- package/dist/react/computer-viewer.js +555 -0
- package/dist/react/computer-wire.d.ts +178 -0
- package/dist/react/computer-wire.js +244 -0
- package/dist/react/connect-button.d.ts +145 -0
- package/dist/react/connect-button.js +212 -0
- package/dist/react/connection-request.d.ts +16 -0
- package/dist/react/connection-request.js +18 -0
- package/dist/react/connections-list.d.ts +90 -0
- package/dist/react/connections-list.js +76 -0
- package/dist/react/errors.d.ts +250 -0
- package/dist/react/errors.js +146 -0
- package/dist/react/files.d.ts +41 -0
- package/dist/react/files.js +78 -0
- package/dist/react/index.d.ts +35 -0
- package/dist/react/index.js +26 -0
- package/dist/react/limit-words.d.ts +80 -0
- package/dist/react/limit-words.js +53 -0
- package/dist/react/markdown.d.ts +42 -0
- package/dist/react/markdown.js +56 -0
- package/dist/react/md-parse.d.ts +106 -0
- package/dist/react/md-parse.js +638 -0
- package/dist/react/model-keys-card.d.ts +94 -0
- package/dist/react/model-keys-card.js +123 -0
- package/dist/react/reload.d.ts +211 -0
- package/dist/react/reload.js +339 -0
- package/dist/react/reveal.d.ts +17 -0
- package/dist/react/reveal.js +22 -0
- package/dist/react/schedule-editor.d.ts +107 -0
- package/dist/react/schedule-editor.js +172 -0
- package/dist/react/schedule-time.d.ts +66 -0
- package/dist/react/schedule-time.js +90 -0
- package/dist/react/styles.css +1274 -0
- package/dist/react/transport.d.ts +49 -0
- package/dist/react/transport.js +380 -0
- package/dist/react/use-connections.d.ts +155 -0
- package/dist/react/use-connections.js +231 -0
- package/dist/react/use-model-keys.d.ts +47 -0
- package/dist/react/use-model-keys.js +57 -0
- package/dist/react/use-threads.d.ts +63 -0
- package/dist/react/use-threads.js +73 -0
- package/dist/react/vault-form.d.ts +92 -0
- package/dist/react/vault-form.js +151 -0
- package/dist/schema.d.ts +47 -0
- package/dist/schema.js +16 -0
- package/dist/secrets.d.ts +15 -0
- package/dist/secrets.js +18 -0
- package/dist/stream.d.ts +129 -0
- package/dist/stream.js +192 -0
- package/dist/testing.d.ts +33 -0
- package/dist/testing.js +40 -0
- package/dist/webhooks.d.ts +31 -0
- package/dist/webhooks.js +72 -0
- package/package.json +85 -3
package/dist/body.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Bodies (a request's, or a fetched response's), read with a cap that holds while they stream.
|
|
3
|
+
*
|
|
4
|
+
* A declared content-length over the cap is refused before anything is read. A body with no length (a
|
|
5
|
+
* chunked upload) is counted as it arrives: the read stops, and the upload is cancelled, at the first
|
|
6
|
+
* chunk past the cap. Nothing is buffered beyond the cap plus that one chunk.
|
|
7
|
+
*/
|
|
8
|
+
/** The body's bytes, or null when it is larger than `max`. */
|
|
9
|
+
export declare function readCapped(req: Pick<Request, "headers" | "body">, max: number): Promise<Uint8Array | null>;
|
package/dist/body.js
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export async function readCapped(req, max) {
|
|
2
|
+
const declared = Number(req.headers.get("content-length") ?? "NaN");
|
|
3
|
+
if (Number.isFinite(declared) && declared > max)
|
|
4
|
+
return null;
|
|
5
|
+
if (!req.body)
|
|
6
|
+
return new Uint8Array(0);
|
|
7
|
+
const reader = req.body.getReader();
|
|
8
|
+
const chunks = [];
|
|
9
|
+
let size = 0;
|
|
10
|
+
for (;;) {
|
|
11
|
+
const { done, value } = await reader.read();
|
|
12
|
+
if (done)
|
|
13
|
+
break;
|
|
14
|
+
size += value.byteLength;
|
|
15
|
+
if (size > max) {
|
|
16
|
+
await reader.cancel().catch(() => undefined);
|
|
17
|
+
return null;
|
|
18
|
+
}
|
|
19
|
+
chunks.push(value);
|
|
20
|
+
}
|
|
21
|
+
const out = new Uint8Array(size);
|
|
22
|
+
let at = 0;
|
|
23
|
+
for (const c of chunks) {
|
|
24
|
+
out.set(c, at);
|
|
25
|
+
at += c.byteLength;
|
|
26
|
+
}
|
|
27
|
+
return out;
|
|
28
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A thread's history, as `<AgentChat initialMessages>` takes it.
|
|
3
|
+
*
|
|
4
|
+
* `GET /threads/{id}/messages` answers newest first, each message's `parts` as its run streamed them. The chat wants
|
|
5
|
+
* the oldest first, without system messages, and it reads more than the parts:
|
|
6
|
+
* - `tainted`: did untrusted content reach the run that wrote a reply? Without it, every past reply counts as
|
|
7
|
+
* tainted (`isMessageTainted`).
|
|
8
|
+
* - `run`: on a person's message, the run it started. When that run left no answer, a reload asks the kit how it
|
|
9
|
+
* ended and draws its refusal or its tool lines under the message. Without it, nothing is drawn.
|
|
10
|
+
* - `stopped`: a person stopped the run that wrote a reply. The chat says "Stopped." under that reply, whatever
|
|
11
|
+
* parts it has. Without it, a stopped reply reads as a finished one.
|
|
12
|
+
* - `trigger` and `schedule`: what started the run that wrote a message ("schedule", "message", …; null on a
|
|
13
|
+
* person's message) and the schedule (sch_…) when one did. A reply a schedule started gets one quiet line above
|
|
14
|
+
* it ("From your schedule"). Read tolerantly: an engine that does not send them gives null, and no line.
|
|
15
|
+
* - `id` and `role`.
|
|
16
|
+
* The API's `metadata` (your own key-value map) is left out: the chat's own `metadata` is what the stream says.
|
|
17
|
+
*
|
|
18
|
+
* Every page that shows a history calls this, so a field the chat starts reading is added here once, not dropped in
|
|
19
|
+
* each page's own mapping. Server-safe: it imports nothing from `react` or `ai`.
|
|
20
|
+
*/
|
|
21
|
+
import type { Message } from "./generated/api.ts";
|
|
22
|
+
/** A history message as `<AgentChat initialMessages>` takes it. */
|
|
23
|
+
export interface AgentChatMessage {
|
|
24
|
+
/** msg_… */
|
|
25
|
+
id: string;
|
|
26
|
+
role: "user" | "assistant";
|
|
27
|
+
/** The AI SDK UI message parts, as the run streamed them. */
|
|
28
|
+
parts: Message["parts"];
|
|
29
|
+
/** Untrusted content reached the run that wrote this message. */
|
|
30
|
+
tainted: boolean;
|
|
31
|
+
/** run_…: the run this message started (a person's) or came from (a reply). */
|
|
32
|
+
run: string | null;
|
|
33
|
+
/** A person stopped the run that wrote this reply. False for every other message. */
|
|
34
|
+
stopped: boolean;
|
|
35
|
+
/** What started the run that wrote this message ("schedule", "message", …); null on a person's message, or when the API does not say. */
|
|
36
|
+
trigger: string | null;
|
|
37
|
+
/** sch_…: the schedule that started it; null otherwise, or when the API does not say. */
|
|
38
|
+
schedule: string | null;
|
|
39
|
+
}
|
|
40
|
+
/** The fields the API may not send yet (an older engine): read as strings, else null. */
|
|
41
|
+
type Started = {
|
|
42
|
+
trigger?: unknown;
|
|
43
|
+
schedule?: unknown;
|
|
44
|
+
};
|
|
45
|
+
/**
|
|
46
|
+
* `GET /threads/{id}/messages`'s `data`, newest first as the API sends it, to the chat's history: oldest first, no
|
|
47
|
+
* system messages, each with what the chat reads.
|
|
48
|
+
*
|
|
49
|
+
* const page = await ws.messages.list(threadId, { limit: 100 });
|
|
50
|
+
* <AgentChat threadId={threadId} initialMessages={toAgentChatMessages(page.data)} />
|
|
51
|
+
*/
|
|
52
|
+
export declare function toAgentChatMessages(messages: readonly (Pick<Message, "id" | "role" | "parts" | "tainted" | "run"> & Partial<Pick<Message, "stopped">> & Started)[]): AgentChatMessage[];
|
|
53
|
+
export {};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
const textOrNull = (v) => (typeof v === "string" && v !== "" ? v : null);
|
|
2
|
+
export function toAgentChatMessages(messages) {
|
|
3
|
+
const out = [];
|
|
4
|
+
for (let i = messages.length - 1; i >= 0; i--) {
|
|
5
|
+
const m = messages[i];
|
|
6
|
+
if (m.role === "system")
|
|
7
|
+
continue;
|
|
8
|
+
out.push({ id: m.id, role: m.role, parts: m.parts, tainted: m.tainted, run: m.run, stopped: m.stopped === true, trigger: textOrNull(m.trigger), schedule: textOrNull(m.schedule) });
|
|
9
|
+
}
|
|
10
|
+
return out;
|
|
11
|
+
}
|
package/dist/client.d.ts
ADDED
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* THE CLIENT: `new OpenLegion({ apiKey })`, then `ol.<namespace>.<method>(…)` for every operation of the
|
|
3
|
+
* Platform API (the namespaces are generated, `generated/api.ts`).
|
|
4
|
+
*
|
|
5
|
+
* What it does for every call, from the contract:
|
|
6
|
+
* - Authorization: Bearer <key> (an org key olp_test_/olp_live_, or a session token ols_…), and
|
|
7
|
+
* OpenLegion-Version: the version the types were generated for, unless overridden;
|
|
8
|
+
* - Idempotency-Key on every POST: a fresh UUID per call unless you pass one, and the SAME key on every
|
|
9
|
+
* retry of that call, so a retry is the original answer replayed or a fresh try, never a second effect
|
|
10
|
+
* (a request that throws rolls its key back; only a 2xx is stored);
|
|
11
|
+
* - OpenLegion-Workspace / OpenLegion-Subject on the workspace-scoped operations;
|
|
12
|
+
* - retries only where the contract makes one safe (`shouldRetry`), with backoff, honouring Retry-After;
|
|
13
|
+
* - a typed error per envelope `type` (`errors.ts`);
|
|
14
|
+
* - the HTTP answer's status, Request-Id and Idempotent-Replayed on `result.lastResponse`
|
|
15
|
+
* (non-enumerable: JSON.stringify of a result is the API object alone).
|
|
16
|
+
*
|
|
17
|
+
* It refuses, at construction, two things in a browser page:
|
|
18
|
+
* - an org key: an olp_ key is a server secret;
|
|
19
|
+
* - any key with a base URL on another origin: /platform/v1 sends no CORS headers, so the call could only
|
|
20
|
+
* fail, and opaquely. A browser talks to YOUR routes — the kit's chat proxy is that door — and a session
|
|
21
|
+
* token (POST /sessions) is for your server, or for a route on your own origin that forwards to the API.
|
|
22
|
+
* A base URL on the page's own origin (your forwarding route) is allowed.
|
|
23
|
+
*/
|
|
24
|
+
import type { Caller, ListPromise, RequestOptions, ResponseMeta, WithResponse } from "./core.ts";
|
|
25
|
+
import { GeneratedResources, type AttachedFile, type DevRequestAnswer, type DevSessionsRequestsResource, type DevSessionsResource, type MessagesCreateBody, type MessagesResource, type OperationId, type RunsResource, type ThreadsResource } from "./generated/api.ts";
|
|
26
|
+
import { RunStream } from "./stream.ts";
|
|
27
|
+
export declare const SDK_VERSION = "0.1.0";
|
|
28
|
+
export interface ClientOptions {
|
|
29
|
+
/** olp_test_… / olp_live_… (server only), or a session token ols_…. Default: env OPENLEGION_API_KEY. */
|
|
30
|
+
apiKey?: string;
|
|
31
|
+
/** Default: env OPENLEGION_BASE_URL, else https://api.openlegion.ai/platform/v1. */
|
|
32
|
+
baseUrl?: string;
|
|
33
|
+
/** OpenLegion-Version. Default: the version these types describe. */
|
|
34
|
+
apiVersion?: string;
|
|
35
|
+
/** The default OpenLegion-Workspace (ws_…) for workspace-scoped calls. See also `ol.workspace(id)`. */
|
|
36
|
+
workspace?: string;
|
|
37
|
+
/** The default OpenLegion-Subject: your user's id, to act as them (the act_as scope). */
|
|
38
|
+
subject?: string;
|
|
39
|
+
/** The default subject's name, sent as OpenLegion-Subject-Name with it; null clears it (`RequestOptions.subjectName`). */
|
|
40
|
+
subjectName?: string | null;
|
|
41
|
+
/** Retries per call where a retry is safe. Default 2. */
|
|
42
|
+
maxRetries?: number;
|
|
43
|
+
/** Per attempt, in ms. Default 60000. For a stream, until its headers arrive. */
|
|
44
|
+
timeoutMs?: number;
|
|
45
|
+
/** Default: the global fetch. */
|
|
46
|
+
fetch?: typeof fetch;
|
|
47
|
+
}
|
|
48
|
+
interface Resolved {
|
|
49
|
+
apiKey: string;
|
|
50
|
+
baseUrl: string;
|
|
51
|
+
apiVersion: string;
|
|
52
|
+
workspace: string | undefined;
|
|
53
|
+
subject: string | undefined;
|
|
54
|
+
subjectName: string | null | undefined;
|
|
55
|
+
maxRetries: number;
|
|
56
|
+
timeoutMs: number;
|
|
57
|
+
fetch: typeof fetch;
|
|
58
|
+
}
|
|
59
|
+
/** Extra wire details for the hand-written methods (the stream). */
|
|
60
|
+
export interface SendExtra {
|
|
61
|
+
/** Query parameters the generated method does not take (messages.create's stream=true). */
|
|
62
|
+
query?: Record<string, string>;
|
|
63
|
+
accept?: string;
|
|
64
|
+
headers?: Record<string, string>;
|
|
65
|
+
/** The body as bytes, sent as they are, instead of JSON (the dev session's answer). */
|
|
66
|
+
rawBody?: Uint8Array;
|
|
67
|
+
/** Takes over the attempt's timer and abort listener on a 2xx, to keep them until the body is read. */
|
|
68
|
+
untilRead?: (attempt: {
|
|
69
|
+
timedOut: () => boolean;
|
|
70
|
+
done: () => void;
|
|
71
|
+
}) => void;
|
|
72
|
+
}
|
|
73
|
+
/** The environment, where there is one (Node, Bun, Vercel Edge); never required. */
|
|
74
|
+
export declare function envVar(name: string): string | undefined;
|
|
75
|
+
/** A browser page (not a server, not a worker, not an edge function). */
|
|
76
|
+
export declare function inBrowser(): boolean;
|
|
77
|
+
/**
|
|
78
|
+
* Whether a failed attempt may be retried. Only these, and only within maxRetries:
|
|
79
|
+
* - 429: always (the request was not processed);
|
|
80
|
+
* - 409 idempotency_in_flight: the same key is still running (a connector op holds it up to 60 s);
|
|
81
|
+
* - a network failure, a timeout or a 5xx: on GET and DELETE, and on a POST that carries its
|
|
82
|
+
* Idempotency-Key (a throw rolls the key back, so the retry is a replay or a fresh try).
|
|
83
|
+
* Never a POST without its key on a 5xx, and never 400/401/402/403/404/422 or any other 409: a refusal
|
|
84
|
+
* stays a refusal. Updates are POSTs, so they carry a key like any other write.
|
|
85
|
+
*/
|
|
86
|
+
export declare function shouldRetry(method: string, idempotencyKey: boolean, failure: {
|
|
87
|
+
status: number;
|
|
88
|
+
code: string | null;
|
|
89
|
+
} | "network"): boolean;
|
|
90
|
+
/** Attach the HTTP answer to a result, non-enumerably. */
|
|
91
|
+
export declare function withResponse<T>(value: T, meta: ResponseMeta): WithResponse<T>;
|
|
92
|
+
export declare function responseMeta(res: Response): ResponseMeta;
|
|
93
|
+
/** The transport: one call, its retries, its errors. Implements what the generated namespaces call. */
|
|
94
|
+
export declare class Transport implements Caller {
|
|
95
|
+
readonly config: Resolved;
|
|
96
|
+
constructor(config: Resolved);
|
|
97
|
+
/** The URL of an operation, path parameters filled in and encoded. */
|
|
98
|
+
url(op: OperationId, pathParams: readonly string[], query?: Record<string, unknown>): string;
|
|
99
|
+
/**
|
|
100
|
+
* Send one call and answer its 2xx Response, body unread; a non-2xx is thrown as its typed error.
|
|
101
|
+
* Retries happen here, before any 2xx: a stream is never re-sent once its headers have arrived.
|
|
102
|
+
*/
|
|
103
|
+
send(op: OperationId, pathParams: readonly string[], payload: object | undefined, options: RequestOptions | undefined, extra?: SendExtra): Promise<Response>;
|
|
104
|
+
request<T>(op: OperationId, pathParams: readonly string[], payload: object | undefined, options: RequestOptions | undefined): Promise<WithResponse<T>>;
|
|
105
|
+
list<T>(op: OperationId, pathParams: readonly string[], query: object | undefined, options: RequestOptions | undefined): ListPromise<T>;
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Why OpenLegion would refuse `name` as OpenLegion-Subject-Name, by its own rule (the trimmed name: at most 120
|
|
109
|
+
* characters, no control character, `\p{Cc}`), and what to do about it; or null when it can be sent. A blank name is
|
|
110
|
+
* no problem: it is not sent. `why` is a clause ("it is 121 characters once trimmed, …"); `fix` says which change
|
|
111
|
+
* makes it sendable, so each caller words the remedy for its own reader.
|
|
112
|
+
*/
|
|
113
|
+
export declare function subjectNameProblem(name: unknown): {
|
|
114
|
+
why: string;
|
|
115
|
+
fix: "string" | "shorter" | "remove";
|
|
116
|
+
} | null;
|
|
117
|
+
/** Options for a stream: a call's options, plus whether to re-attach when it is cut short (default true). */
|
|
118
|
+
export interface StreamOptions extends RequestOptions {
|
|
119
|
+
reattach?: boolean;
|
|
120
|
+
}
|
|
121
|
+
/** The run stream, written by hand (it is Server-Sent Events, not JSON). */
|
|
122
|
+
export interface RunsStreamMethods {
|
|
123
|
+
/**
|
|
124
|
+
* Attach to a run's stream: replay from the start (or after `after`), then follow it live until it ends.
|
|
125
|
+
* Closing the stream never cancels the run. Throws a typed error (404, …) before any part.
|
|
126
|
+
*
|
|
127
|
+
* `GET /runs/{id}/stream`
|
|
128
|
+
*/
|
|
129
|
+
stream(runId: string, options?: StreamOptions & {
|
|
130
|
+
after?: number;
|
|
131
|
+
}): Promise<RunStream>;
|
|
132
|
+
}
|
|
133
|
+
export interface MessagesStreamMethods {
|
|
134
|
+
/**
|
|
135
|
+
* Send a message and read the agent's answer live (`?stream=true`). A refusal before the run starts
|
|
136
|
+
* (402 credits_exhausted, 409 agent_paused, …) throws, and no stream opens. Retrying with the same
|
|
137
|
+
* Idempotency-Key never starts a second run: the replay is followed by re-attaching.
|
|
138
|
+
*
|
|
139
|
+
* `POST /threads/{id}/messages?stream=true`
|
|
140
|
+
*/
|
|
141
|
+
stream(threadId: string, body: MessagesCreateBody, options?: StreamOptions): Promise<RunStream>;
|
|
142
|
+
}
|
|
143
|
+
/** What `openlegion dev` posts for one relayed request. */
|
|
144
|
+
export interface DevAnswerInput {
|
|
145
|
+
/** The HTTP status the app answered: 200–599. */
|
|
146
|
+
status: number;
|
|
147
|
+
/** The app's answer headers. Only content-type and mcp-* are sent; the rest are dropped here and again by OpenLegion. */
|
|
148
|
+
headers?: Record<string, string>;
|
|
149
|
+
/** The answer's bytes, exactly (at most 4 MiB). */
|
|
150
|
+
body: Uint8Array | string;
|
|
151
|
+
}
|
|
152
|
+
/** The dev session's answer route, written by hand (its body is raw bytes, not JSON). */
|
|
153
|
+
export interface DevRequestsRespondMethods {
|
|
154
|
+
/**
|
|
155
|
+
* Post your app's answer to one request this session was handed. Single use: a second answer is a 409
|
|
156
|
+
* dev_request_answered, one past the request's deadline a 409 dev_request_expired.
|
|
157
|
+
*
|
|
158
|
+
* `POST /dev_sessions/{id}/requests/{request_id}/response`
|
|
159
|
+
*/
|
|
160
|
+
respond(sessionId: string, requestId: string, answer: DevAnswerInput, options?: RequestOptions): Promise<WithResponse<DevRequestAnswer>>;
|
|
161
|
+
}
|
|
162
|
+
/** One file for `ol.files.create`. */
|
|
163
|
+
export interface FileUploadInput {
|
|
164
|
+
/** thr_…: the thread the file will be sent in. It can only be sent there. */
|
|
165
|
+
thread: string;
|
|
166
|
+
/** The file's name, as the person sees it (1 to 200 characters). */
|
|
167
|
+
name: string;
|
|
168
|
+
/** The file's type, e.g. application/pdf or text/csv. OpenLegion reads the type from the bytes; this names which text type a text file is. */
|
|
169
|
+
type: string;
|
|
170
|
+
/** The file's bytes, at most 4 MB. */
|
|
171
|
+
body: Uint8Array | string;
|
|
172
|
+
}
|
|
173
|
+
/** The upload route, written by hand (its body is the file's bytes, not JSON). */
|
|
174
|
+
export interface FilesMethods {
|
|
175
|
+
/**
|
|
176
|
+
* Upload a file a person attaches to a message: an image (PNG, JPEG, WebP or GIF), a PDF, or a text file
|
|
177
|
+
* (plain text, Markdown, CSV or JSON), at most 4 MB. Then send it, in the same thread and as the same person:
|
|
178
|
+
* `ol.messages.create(thread, { content, attachments: [file.id] })`, at most 5 a message.
|
|
179
|
+
*
|
|
180
|
+
* `POST /files`
|
|
181
|
+
*/
|
|
182
|
+
create(input: FileUploadInput, options?: RequestOptions): Promise<WithResponse<AttachedFile>>;
|
|
183
|
+
}
|
|
184
|
+
export interface ThreadsAttachMethods {
|
|
185
|
+
/** The stream of the thread's active run (from its start), or null when the thread is idle. */
|
|
186
|
+
attach(threadId: string, options?: StreamOptions): Promise<RunStream | null>;
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* The Platform API client.
|
|
190
|
+
*
|
|
191
|
+
* ```ts
|
|
192
|
+
* const ol = new OpenLegion(); // OPENLEGION_API_KEY
|
|
193
|
+
* const ws = await ol.workspaces.create({ external_ref: user.orgId, name: "Acme", template: "support" });
|
|
194
|
+
* const thread = await ol.workspace(ws.id).threads.create({ agent: "agt_…" });
|
|
195
|
+
* const stream = await ol.workspace(ws.id).messages.stream(thread.id, { content: "Where is order A-1?" });
|
|
196
|
+
* for await (const part of stream) if (part.type === "text-delta") process.stdout.write(String(part["delta"]));
|
|
197
|
+
* ```
|
|
198
|
+
*/
|
|
199
|
+
export declare class OpenLegion extends GeneratedResources {
|
|
200
|
+
#private;
|
|
201
|
+
readonly runs: RunsResource & RunsStreamMethods;
|
|
202
|
+
readonly messages: MessagesResource & MessagesStreamMethods;
|
|
203
|
+
readonly threads: ThreadsResource & ThreadsAttachMethods;
|
|
204
|
+
readonly devSessions: DevSessionsResource & {
|
|
205
|
+
readonly requests: DevSessionsRequestsResource & DevRequestsRespondMethods;
|
|
206
|
+
};
|
|
207
|
+
readonly files: FilesMethods;
|
|
208
|
+
/** @internal */
|
|
209
|
+
readonly transport: Transport;
|
|
210
|
+
constructor(options?: ClientOptions);
|
|
211
|
+
/** A client whose workspace-scoped calls go to this workspace (and, optionally, act as this subject). */
|
|
212
|
+
workspace(id: string, opts?: {
|
|
213
|
+
subject?: string;
|
|
214
|
+
subjectName?: string | null;
|
|
215
|
+
}): OpenLegion;
|
|
216
|
+
}
|
|
217
|
+
export {};
|