@signalcore/ui 1.0.0-beta.1 → 1.0.0-beta.3
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 +55 -22
- package/dist/AgentAbout.js +11 -4
- package/dist/AgentAbout.js.map +1 -1
- package/dist/AgentChat.d.ts +7 -1
- package/dist/AgentChat.js +154 -2
- package/dist/AgentChat.js.map +1 -1
- package/dist/AgentSpace.d.ts +12 -3
- package/dist/AgentSpace.js +53 -11
- package/dist/AgentSpace.js.map +1 -1
- package/dist/AgentTasks.js +2 -1
- package/dist/AgentTasks.js.map +1 -1
- package/dist/Threads.d.ts +73 -0
- package/dist/Threads.js +140 -0
- package/dist/Threads.js.map +1 -0
- package/dist/VoiceCall.js +1 -1
- package/dist/VoiceCall.js.map +1 -1
- package/dist/about.d.ts +34 -144
- package/dist/about.js +6 -8
- package/dist/about.js.map +1 -1
- package/dist/automation/cron.d.ts +1 -1
- package/dist/automation/cron.js.map +1 -1
- package/dist/automation/marks.js +13 -5
- package/dist/automation/marks.js.map +1 -1
- package/dist/automation/messages.d.ts +6 -0
- package/dist/automation/messages.js +7 -1
- package/dist/automation/messages.js.map +1 -1
- package/dist/automation/types.d.ts +25 -128
- package/dist/automation/types.js +36 -0
- package/dist/automation/types.js.map +1 -0
- package/dist/automation/when.d.ts +1 -1
- package/dist/automation/when.js +13 -1
- package/dist/automation/when.js.map +1 -1
- package/dist/blocks.d.ts +23 -1
- package/dist/browser.js +2 -2
- package/dist/browser.js.map +1 -1
- package/dist/call.d.ts +1 -1
- package/dist/call.js.map +1 -1
- package/dist/client.d.ts +14 -4
- package/dist/client.js +7 -2
- package/dist/client.js.map +1 -1
- package/dist/contract.d.ts +267 -0
- package/dist/credentials.js.map +1 -1
- package/dist/dev.js +1 -1
- package/dist/dev.js.map +1 -1
- package/dist/es.d.ts +2 -0
- package/dist/es.js +31 -4
- package/dist/es.js.map +1 -1
- package/dist/frames.d.ts +7 -1
- package/dist/frames.js.map +1 -1
- package/dist/index.d.ts +6 -5
- package/dist/index.js +6 -4
- package/dist/kit/AudioPlayer.js +1 -1
- package/dist/kit/AudioPlayer.js.map +1 -1
- package/dist/kit/Choices.js +1 -1
- package/dist/kit/Choices.js.map +1 -1
- package/dist/kit/FileField.js +1 -1
- package/dist/kit/FileField.js.map +1 -1
- package/dist/kit/Popover.js.map +1 -1
- package/dist/kit/Tile.d.ts +1 -1
- package/dist/kit/Tile.js +1 -1
- package/dist/kit/Tile.js.map +1 -1
- package/dist/kit/messages.d.ts +13 -0
- package/dist/kit/messages.js +7 -1
- package/dist/kit/messages.js.map +1 -1
- package/dist/kit/uploads.d.ts +2 -1
- package/dist/kit/uploads.js +1 -1
- package/dist/kit/uploads.js.map +1 -1
- package/dist/kit/waveform.js.map +1 -1
- package/dist/markdown.js.map +1 -1
- package/dist/marks.js +2 -3
- package/dist/marks.js.map +1 -1
- package/dist/surface/Form.js +1 -1
- package/dist/surface/Markdown.js +1 -1
- package/dist/surface/Markdown.js.map +1 -1
- package/dist/surface/Surface.js +43 -4
- package/dist/surface/Surface.js.map +1 -1
- package/dist/surface/scope.d.ts +1 -1
- package/dist/surface/scope.js.map +1 -1
- package/dist/surface/values.js +1 -1
- package/dist/surface/values.js.map +1 -1
- package/dist/tint.d.ts +1 -1
- package/dist/tint.js +1 -1
- package/dist/tint.js.map +1 -1
- package/dist/types.d.ts +11 -0
- package/dist/types.js.map +1 -1
- package/dist/useConversation.d.ts +2 -0
- package/dist/useConversation.js +16 -0
- package/dist/useConversation.js.map +1 -1
- package/dist/usePolled.js +1 -1
- package/dist/usePolled.js.map +1 -1
- package/dist/voice/webgl.js +1 -1
- package/dist/voice/webgl.js.map +1 -1
- package/dist/widget.js +17 -16
- package/package.json +1 -1
- package/src/AgentAbout.tsx +14 -3
- package/src/AgentChat.tsx +203 -1
- package/src/AgentSpace.tsx +89 -13
- package/src/AgentTasks.tsx +2 -2
- package/src/Threads.tsx +218 -0
- package/src/VoiceCall.tsx +1 -1
- package/src/about.ts +42 -144
- package/src/automation/cron.ts +1 -1
- package/src/automation/marks.tsx +13 -2
- package/src/automation/messages.ts +12 -0
- package/src/automation/types.ts +58 -118
- package/src/automation/when.ts +7 -1
- package/src/blocks.ts +25 -0
- package/src/browser.ts +4 -4
- package/src/call.ts +1 -1
- package/src/client.ts +26 -10
- package/src/contract.ts +1934 -0
- package/src/credentials.ts +2 -2
- package/src/dev.ts +1 -1
- package/src/es.ts +29 -0
- package/src/frames.ts +3 -1
- package/src/index.ts +10 -1
- package/src/kit/AudioPlayer.tsx +1 -1
- package/src/kit/Choices.tsx +1 -1
- package/src/kit/FileField.tsx +1 -1
- package/src/kit/Popover.tsx +1 -1
- package/src/kit/Tile.tsx +1 -1
- package/src/kit/messages.ts +20 -0
- package/src/kit/uploads.ts +2 -2
- package/src/kit/waveform.ts +1 -1
- package/src/markdown.ts +1 -1
- package/src/marks.tsx +3 -123
- package/src/styles.css +206 -0
- package/src/surface/Markdown.tsx +1 -1
- package/src/surface/Surface.tsx +53 -4
- package/src/surface/scope.ts +3 -1
- package/src/surface/values.ts +5 -5
- package/src/tint.ts +1 -1
- package/src/types.ts +11 -0
- package/src/useConversation.ts +10 -0
- package/src/usePolled.ts +2 -2
- package/src/voice/webgl.ts +1 -1
- package/src/widget/element.tsx +13 -4
- package/src/widget/widget.css +13 -0
package/src/automation/types.ts
CHANGED
|
@@ -1,146 +1,86 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* An agent's automations and their runs, as the API gives them (v3/AUTOMATIONS.md): what starts
|
|
3
|
-
* each one, the steps its code names, the table it moves, and every run with its record.
|
|
4
|
-
*
|
|
3
|
+
* each one, the steps its code names, the table it moves, and every run with its record. The
|
|
4
|
+
* contract's own types (`contract.ts`, generated from the API's); times are ISO 8601 in UTC.
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
+
import type * as C from "../contract";
|
|
8
|
+
|
|
7
9
|
/**
|
|
8
10
|
* What a step uses, as the manifest reads it from the code before any run: an app, the model,
|
|
9
11
|
* the agent, the owner's inbox, a message to a contact on a channel (`sc.send`), a table, the web.
|
|
10
12
|
*/
|
|
11
|
-
export
|
|
12
|
-
kind: "app" | "ai" | "agent" | "notify" | "send" | "data" | "http";
|
|
13
|
-
/** An app's: the connection's name (its alias). */
|
|
14
|
-
app: string | null;
|
|
15
|
-
/** An app's: its display name. */
|
|
16
|
-
title: string | null;
|
|
17
|
-
/** An app's: its logo (https), when known. */
|
|
18
|
-
icon: string | null;
|
|
19
|
-
}
|
|
13
|
+
export type Use = C.Use;
|
|
20
14
|
|
|
21
15
|
/** A step of the code (`sc.step("…")`), in the code's order, with what it uses. */
|
|
22
|
-
export
|
|
23
|
-
name: string;
|
|
24
|
-
uses: Use[];
|
|
25
|
-
}
|
|
16
|
+
export type Step = C.Step;
|
|
26
17
|
|
|
27
|
-
/** What starts an automation: a time (cron, on a zone's clock), a call to its URL, an app's
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
/** Five-field cron. */
|
|
31
|
-
schedule: string | null;
|
|
32
|
-
/** IANA zone. */
|
|
33
|
-
timezone: string | null;
|
|
34
|
-
/** The webhook's full URL. */
|
|
35
|
-
url: string | null;
|
|
36
|
-
/** An event's app: the connection's name, its display name, its logo. */
|
|
37
|
-
app: string | null;
|
|
38
|
-
app_title: string | null;
|
|
39
|
-
/** The provider's event slug, and the event in words when the provider gives them. */
|
|
40
|
-
event: string | null;
|
|
41
|
-
event_title: string | null;
|
|
42
|
-
icon: string | null;
|
|
43
|
-
}
|
|
18
|
+
/** What starts an automation: a time (cron, on a zone's clock), a call to its URL, an app's
|
|
19
|
+
* event, one of the platform's. */
|
|
20
|
+
export type Trigger = C.TriggerView;
|
|
44
21
|
|
|
45
|
-
/** The table an automation moves, as counts of its rows per value of one field
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
/** The table's title. */
|
|
49
|
-
title: string;
|
|
50
|
-
/** The field the rows are counted by. */
|
|
51
|
-
field: string;
|
|
52
|
-
/** Per value, biggest first, at most 8. */
|
|
53
|
-
counts: { value: string; count: number }[];
|
|
54
|
-
}
|
|
22
|
+
/** The table an automation moves, as counts of its rows per value of one field (biggest first,
|
|
23
|
+
* at most 8). */
|
|
24
|
+
export type Board = C.Board;
|
|
55
25
|
|
|
56
|
-
export type RunStatus = "
|
|
26
|
+
export type RunStatus = C.RunOut["status"];
|
|
57
27
|
|
|
58
|
-
/** What started a run: its time, a call, an app's event, the
|
|
59
|
-
export type RunBy = "
|
|
28
|
+
/** What started a run: its time, a call, an app's event, the platform, the agent, a test. */
|
|
29
|
+
export type RunBy = C.RunOut["by"];
|
|
60
30
|
|
|
61
31
|
/** One start of an automation, whatever started it. */
|
|
62
|
-
export
|
|
63
|
-
id: string;
|
|
64
|
-
agent_id: string;
|
|
65
|
-
/** The automation's name. */
|
|
66
|
-
automation: string;
|
|
67
|
-
/** The automation's title when it ran. */
|
|
68
|
-
title: string;
|
|
69
|
-
by: RunBy;
|
|
70
|
-
/** Started by the agent: the conversation it was asked in. */
|
|
71
|
-
conversation_id: string | null;
|
|
72
|
-
status: RunStatus;
|
|
73
|
-
/** What the code returned: the run's one line. */
|
|
74
|
-
summary: string | null;
|
|
75
|
-
/** Why it failed, in words, naming the step: "Paró en «…»: …". */
|
|
76
|
-
error: string | null;
|
|
77
|
-
/** A test: what would change the world was recorded, not done. */
|
|
78
|
-
dry: boolean;
|
|
79
|
-
started_at: string;
|
|
80
|
-
ended_at: string | null;
|
|
81
|
-
tokens_in: number;
|
|
82
|
-
tokens_out: number;
|
|
83
|
-
/** The conversations it opened. */
|
|
84
|
-
opened: string[];
|
|
85
|
-
}
|
|
32
|
+
export type Run = C.RunOut;
|
|
86
33
|
|
|
87
34
|
/** One call of a run's record, in the order it was made. */
|
|
88
|
-
export
|
|
89
|
-
seq: number;
|
|
90
|
-
/** The `sc.step` it ran in. */
|
|
91
|
-
step: string | null;
|
|
92
|
-
/**
|
|
93
|
-
* `tool:<app>.<TOOL>` · `ai` · `notify` · `send` · `agent.start` · `data.find` · `data.add` ·
|
|
94
|
-
* `data.update` · `http` · `files.search` · `memory.remember` · `memory.recall`.
|
|
95
|
-
*/
|
|
96
|
-
call: string;
|
|
97
|
-
/** Both trimmed. */
|
|
98
|
-
input: unknown;
|
|
99
|
-
output: unknown;
|
|
100
|
-
error: string | null;
|
|
101
|
-
ms: number;
|
|
102
|
-
at: string;
|
|
103
|
-
/** A test's write: recorded, not done. */
|
|
104
|
-
would: boolean;
|
|
105
|
-
}
|
|
35
|
+
export type RunStep = C.RunStepOut;
|
|
106
36
|
|
|
107
37
|
/** A run with its record (`GET /runs/{id}`). */
|
|
108
|
-
export type RunRecord =
|
|
38
|
+
export type RunRecord = C.RunDetailOut;
|
|
109
39
|
|
|
110
|
-
export type AutomationState = "
|
|
40
|
+
export type AutomationState = C.AutomationOut["state"];
|
|
111
41
|
|
|
112
42
|
/** One automation: `automations/<name>.py` in the agent's folder, with its trigger and its state. */
|
|
113
|
-
export
|
|
114
|
-
/** Its trigger's id. */
|
|
115
|
-
id: string;
|
|
116
|
-
agent_id: string;
|
|
117
|
-
/** Its file's name; unique per agent. */
|
|
118
|
-
name: string;
|
|
119
|
-
title: string;
|
|
120
|
-
/** What it does, in the owner's words. */
|
|
121
|
-
summary: string;
|
|
122
|
-
trigger: Trigger;
|
|
123
|
-
on: boolean;
|
|
124
|
-
next_run_at: string | null;
|
|
125
|
-
steps: Step[];
|
|
126
|
-
board: Board | null;
|
|
127
|
-
/** `failing`: its last finished real run failed. */
|
|
128
|
-
state: AutomationState;
|
|
129
|
-
/** Its newest run, tests included. */
|
|
130
|
-
last_run: Run | null;
|
|
131
|
-
}
|
|
43
|
+
export type Automation = C.AutomationOut;
|
|
132
44
|
|
|
133
45
|
/** An automation with its newest runs (`GET /agents/{id}/automations/{name}`: 20; in a block: 5). */
|
|
134
|
-
export type AutomationView =
|
|
46
|
+
export type AutomationView = C.AutomationDetailOut;
|
|
135
47
|
|
|
136
48
|
/**
|
|
137
|
-
* A task the agent runs for one contact (`GET /agents/{id}/tasks`):
|
|
138
|
-
*
|
|
139
|
-
*
|
|
49
|
+
* A task the agent runs for one contact (`GET /agents/{id}/tasks`): an instance of an automation
|
|
50
|
+
* for contacts (`automation`), or of the platform's instruction (its words in `inputs`), on a
|
|
51
|
+
* schedule (a cron line, or once at `next_run_at`), with its newest five runs.
|
|
140
52
|
*/
|
|
141
|
-
export type Task =
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
53
|
+
export type Task = C.TaskOut;
|
|
54
|
+
|
|
55
|
+
/** A task as the automation card draws it, from what it is: its words its summary, its trigger
|
|
56
|
+
* its schedule, failing when its last finished real run failed. */
|
|
57
|
+
export function taskCard(task: Task): AutomationView {
|
|
58
|
+
const ended = task.runs.filter((run) => run.status !== "running" && run.status !== "waiting");
|
|
59
|
+
const last = ended.find((run) => !run.dry);
|
|
60
|
+
const words = task.inputs["instruction"];
|
|
61
|
+
return {
|
|
62
|
+
id: task.id,
|
|
63
|
+
agent_id: task.agent_id,
|
|
64
|
+
name: task.automation ?? "instruction",
|
|
65
|
+
title: task.title,
|
|
66
|
+
summary: typeof words === "string" ? words : "",
|
|
67
|
+
trigger: {
|
|
68
|
+
kind: "schedule",
|
|
69
|
+
schedule: task.schedule,
|
|
70
|
+
timezone: task.timezone,
|
|
71
|
+
url: null,
|
|
72
|
+
app: null,
|
|
73
|
+
app_title: null,
|
|
74
|
+
event: null,
|
|
75
|
+
event_title: null,
|
|
76
|
+
icon: null,
|
|
77
|
+
},
|
|
78
|
+
on: task.on,
|
|
79
|
+
next_run_at: task.next_run_at,
|
|
80
|
+
steps: [],
|
|
81
|
+
board: null,
|
|
82
|
+
state: !task.on ? "paused" : last?.status === "failed" ? "failing" : "active",
|
|
83
|
+
last_run: task.runs[0] ?? null,
|
|
84
|
+
runs: task.runs,
|
|
85
|
+
};
|
|
86
|
+
}
|
package/src/automation/when.ts
CHANGED
|
@@ -24,7 +24,7 @@ export interface When {
|
|
|
24
24
|
timed: boolean;
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
-
/** A trigger in words: its schedule as a sentence, a webhook's call, an app's event. */
|
|
27
|
+
/** A trigger in words: its schedule as a sentence, a webhook's call, an app's event, a message. */
|
|
28
28
|
export function whenOf(trigger: Trigger, words: AutomationMessages, code: string): When {
|
|
29
29
|
switch (trigger.kind) {
|
|
30
30
|
case "schedule":
|
|
@@ -33,6 +33,12 @@ export function whenOf(trigger: Trigger, words: AutomationMessages, code: string
|
|
|
33
33
|
: scheduleOf(trigger.schedule, words, code);
|
|
34
34
|
case "webhook":
|
|
35
35
|
return { text: words.webhook, timed: false };
|
|
36
|
+
case "platform":
|
|
37
|
+
return { text: words.platform, timed: false };
|
|
38
|
+
case "manual":
|
|
39
|
+
return { text: words.manual, timed: false };
|
|
40
|
+
case "after":
|
|
41
|
+
return { text: words.after(trigger.after ?? null), timed: false };
|
|
36
42
|
case "event":
|
|
37
43
|
return {
|
|
38
44
|
text: words.event(trigger.app_title ?? trigger.app, trigger.event_title),
|
package/src/blocks.ts
CHANGED
|
@@ -100,6 +100,30 @@ export interface AutomationBlock {
|
|
|
100
100
|
view: AutomationView | null;
|
|
101
101
|
}
|
|
102
102
|
|
|
103
|
+
/**
|
|
104
|
+
* How the connection an app's card asked for stands: its name and logo, and where the person
|
|
105
|
+
* authorizes it while it waits for them.
|
|
106
|
+
*/
|
|
107
|
+
export interface ConnectView {
|
|
108
|
+
title: string;
|
|
109
|
+
icon: string | null;
|
|
110
|
+
status: "pending" | "active" | "error" | "disconnected";
|
|
111
|
+
url: string | null;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* An app for the person to connect, drawn by the platform alone (the agent's `connect_app`,
|
|
116
|
+
* never composed): its name and logo, the line the agent wrote of what it will do with it, and
|
|
117
|
+
* the button that opens its consent page; the API fills in `connection`, and the card changes
|
|
118
|
+
* live as it does (waiting, working, failed). Null while there is none yet.
|
|
119
|
+
*/
|
|
120
|
+
export interface ConnectBlock {
|
|
121
|
+
type: "connect";
|
|
122
|
+
app: string;
|
|
123
|
+
purpose: string;
|
|
124
|
+
connection: ConnectView | null;
|
|
125
|
+
}
|
|
126
|
+
|
|
103
127
|
// --- Action -------------------------------------------------------------------------------
|
|
104
128
|
|
|
105
129
|
/** One thing the person can do: pressing it sends `action`, or, with `url`, opens that page. */
|
|
@@ -238,6 +262,7 @@ export type Block =
|
|
|
238
262
|
| ImageBlock
|
|
239
263
|
| AutomationBlock
|
|
240
264
|
| FileBlock
|
|
265
|
+
| ConnectBlock
|
|
241
266
|
| ButtonBlock
|
|
242
267
|
| ChoiceBlock
|
|
243
268
|
| FormBlock;
|
package/src/browser.ts
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
import type { BrowserFrame, BrowserInput, Message } from "./types";
|
|
7
7
|
|
|
8
8
|
/** The action that hands the person the browser; the turn waits on it until they give it back. */
|
|
9
|
-
|
|
9
|
+
const HAND_OVER = "browser_hand_over";
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
12
|
* The browser's screen as it comes: the latest picture, and whoever watches. Kept out of the
|
|
@@ -66,7 +66,7 @@ export function siteOf(url: string): { host: string; rest: string } {
|
|
|
66
66
|
}
|
|
67
67
|
}
|
|
68
68
|
|
|
69
|
-
|
|
69
|
+
interface Size {
|
|
70
70
|
width: number;
|
|
71
71
|
height: number;
|
|
72
72
|
}
|
|
@@ -86,7 +86,7 @@ export function pointOf(
|
|
|
86
86
|
}
|
|
87
87
|
|
|
88
88
|
/** DevTools' mask of the keys held with another: Alt 1, Ctrl 2, Meta 4, Shift 8. */
|
|
89
|
-
|
|
89
|
+
function modifiersOf(event: {
|
|
90
90
|
altKey: boolean;
|
|
91
91
|
ctrlKey: boolean;
|
|
92
92
|
metaKey: boolean;
|
|
@@ -268,7 +268,7 @@ export function bytesOf(base64: string): Uint8Array<ArrayBuffer> {
|
|
|
268
268
|
}
|
|
269
269
|
|
|
270
270
|
/** Draws a picture on a canvas, unless a newer one comes while it is still being decoded. */
|
|
271
|
-
|
|
271
|
+
interface Painter {
|
|
272
272
|
paint: (jpeg: string) => void;
|
|
273
273
|
dispose: () => void;
|
|
274
274
|
}
|
package/src/call.ts
CHANGED
|
@@ -34,7 +34,7 @@ export type CallProblem =
|
|
|
34
34
|
| "unsupported"
|
|
35
35
|
/** Calls aren't set up where the agent works (the API refused with `no_calls`). */
|
|
36
36
|
| "off"
|
|
37
|
-
/** The agent takes no calls:
|
|
37
|
+
/** The agent takes no calls: the builder (`builder`). */
|
|
38
38
|
| "builder"
|
|
39
39
|
/** The API wouldn't make the call, for any other reason it named. */
|
|
40
40
|
| "refused"
|
package/src/client.ts
CHANGED
|
@@ -127,8 +127,10 @@ export interface Client {
|
|
|
127
127
|
/** Takes one memory from it. */
|
|
128
128
|
forget: (id: string, memoryId: string) => Promise<void>;
|
|
129
129
|
/**
|
|
130
|
-
* The owner's call with the agent, from
|
|
131
|
-
* conversation (a test) made now, and where to join it (`VoiceCall`'s `connect`).
|
|
130
|
+
* The owner's call with the agent, from our own app (v3/VOICE.md): the call and its
|
|
131
|
+
* conversation (a test) made now, and where to join it (`VoiceCall`'s `connect`). App only:
|
|
132
|
+
* it is `/api`'s, signed in by the owner's cookie, and 404s on `/v1`; a host's page calls with
|
|
133
|
+
* `conversations.call(agentId)`.
|
|
132
134
|
*/
|
|
133
135
|
call: (id: string) => Promise<CallToken>;
|
|
134
136
|
};
|
|
@@ -169,8 +171,14 @@ export interface Client {
|
|
|
169
171
|
conversations: {
|
|
170
172
|
/** One conversation with its messages. */
|
|
171
173
|
get: (id: string) => Promise<ConversationDetail>;
|
|
172
|
-
/**
|
|
173
|
-
|
|
174
|
+
/** The agent's conversations, newest first: a person's own only, each with what is unread. */
|
|
175
|
+
list: (agentId: string) => Promise<Conversation[]>;
|
|
176
|
+
/** A new conversation with an agent, titled when given. */
|
|
177
|
+
start: (agentId: string, options?: { title?: string | undefined }) => Promise<Conversation>;
|
|
178
|
+
/** How far the person has read it: all of it, now. */
|
|
179
|
+
read: (id: string) => Promise<Conversation>;
|
|
180
|
+
/** Its title, as the person gives it. */
|
|
181
|
+
rename: (id: string, title: string) => Promise<Conversation>;
|
|
174
182
|
/** The files that arrived in a conversation: attached, sent through a form. */
|
|
175
183
|
files: (id: string) => Promise<ConversationFile[]>;
|
|
176
184
|
/**
|
|
@@ -201,6 +209,10 @@ export interface Client {
|
|
|
201
209
|
|
|
202
210
|
const seg = encodeURIComponent;
|
|
203
211
|
|
|
212
|
+
/** A request's JSON body. */
|
|
213
|
+
const body = (value: unknown): Blob =>
|
|
214
|
+
new Blob([JSON.stringify(value)], { type: "application/json" });
|
|
215
|
+
|
|
204
216
|
/** A file's path in a URL: each name of it encoded, the slashes between them kept. */
|
|
205
217
|
const filePath = (path: string): string => path.split("/").map(seg).join("/");
|
|
206
218
|
|
|
@@ -357,11 +369,7 @@ export function createClient(options: ClientOptions): Client {
|
|
|
357
369
|
tasks: {
|
|
358
370
|
list: (agentId) => json("GET", `/agents/${seg(agentId)}/tasks`),
|
|
359
371
|
switch: (agentId, taskId, on) =>
|
|
360
|
-
json(
|
|
361
|
-
"PATCH",
|
|
362
|
-
`/agents/${seg(agentId)}/tasks/${seg(taskId)}`,
|
|
363
|
-
new Blob([JSON.stringify({ on })], { type: "application/json" }),
|
|
364
|
-
),
|
|
372
|
+
json("PATCH", `/agents/${seg(agentId)}/tasks/${seg(taskId)}`, body({ on })),
|
|
365
373
|
remove: (agentId, taskId) => run("DELETE", `/agents/${seg(agentId)}/tasks/${seg(taskId)}`),
|
|
366
374
|
},
|
|
367
375
|
channels: {
|
|
@@ -370,7 +378,15 @@ export function createClient(options: ClientOptions): Client {
|
|
|
370
378
|
},
|
|
371
379
|
conversations: {
|
|
372
380
|
get: (id) => json("GET", `/conversations/${seg(id)}`),
|
|
373
|
-
|
|
381
|
+
list: (agentId) => json("GET", `/agents/${seg(agentId)}/conversations`),
|
|
382
|
+
start: (agentId, { title } = {}) =>
|
|
383
|
+
json(
|
|
384
|
+
"POST",
|
|
385
|
+
`/agents/${seg(agentId)}/conversations`,
|
|
386
|
+
title === undefined ? undefined : body({ title }),
|
|
387
|
+
),
|
|
388
|
+
read: (id) => json("POST", `/conversations/${seg(id)}/read`, body({})),
|
|
389
|
+
rename: (id, title) => json("PATCH", `/conversations/${seg(id)}`, body({ title })),
|
|
374
390
|
files: (id) => json("GET", `/conversations/${seg(id)}/files`),
|
|
375
391
|
upload: (id, file, options) => sendFile(`/conversations/${seg(id)}/files`, file, options),
|
|
376
392
|
play: async (id, fileId) => {
|