@flow-engineer/flow 0.0.0-stage → 0.2.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 +21 -0
- package/README.md +594 -2
- package/coding-agents/skill.md +321 -0
- package/coding-agents/test-skill.md +223 -0
- package/coding-agents/tools-skill.md +89 -0
- package/dist/flow-messaging/src/client.d.ts +34 -0
- package/dist/flow-messaging/src/client.js +130 -0
- package/dist/flow-messaging/src/index.d.ts +37 -0
- package/dist/flow-messaging/src/index.js +409 -0
- package/dist/simulators/src/index.d.ts +2 -0
- package/dist/simulators/src/index.js +2 -0
- package/dist/simulators/src/page.html +1245 -0
- package/dist/simulators/src/person.html +100 -0
- package/dist/simulators/src/platforms.d.ts +29 -0
- package/dist/simulators/src/platforms.js +72 -0
- package/dist/simulators/src/server.d.ts +201 -0
- package/dist/simulators/src/server.js +759 -0
- package/dist/src/agent.d.ts +504 -0
- package/dist/src/agent.js +818 -0
- package/dist/src/channels.d.ts +178 -0
- package/dist/src/channels.js +243 -0
- package/dist/src/conversation.d.ts +361 -0
- package/dist/src/conversation.js +1487 -0
- package/dist/src/db.d.ts +18 -0
- package/dist/src/db.js +57 -0
- package/dist/src/events.d.ts +17 -0
- package/dist/src/events.js +20 -0
- package/dist/src/http.d.ts +45 -0
- package/dist/src/http.js +269 -0
- package/dist/src/index.d.ts +14 -0
- package/dist/src/index.js +11 -0
- package/dist/src/model.d.ts +21 -0
- package/dist/src/model.js +96 -0
- package/dist/src/names.d.ts +17 -0
- package/dist/src/names.js +38 -0
- package/dist/src/nudges.d.ts +23 -0
- package/dist/src/nudges.js +117 -0
- package/dist/src/postgres.d.ts +20 -0
- package/dist/src/postgres.js +62 -0
- package/dist/src/schedules.d.ts +60 -0
- package/dist/src/schedules.js +249 -0
- package/dist/src/skills.d.ts +12 -0
- package/dist/src/skills.js +69 -0
- package/dist/src/store.d.ts +214 -0
- package/dist/src/store.js +448 -0
- package/dist/src/talk.d.ts +57 -0
- package/dist/src/talk.js +166 -0
- package/dist/src/time.d.ts +71 -0
- package/dist/src/time.js +170 -0
- package/dist/src/tools.d.ts +43 -0
- package/dist/src/tools.js +26 -0
- package/dist/src/traces.d.ts +31 -0
- package/dist/src/traces.js +303 -0
- package/dist/src/types.d.ts +260 -0
- package/dist/src/types.js +2 -0
- package/dist/testing/src/check-endpoint.d.ts +31 -0
- package/dist/testing/src/check-endpoint.js +158 -0
- package/dist/testing/src/chinwag.d.ts +2 -0
- package/dist/testing/src/chinwag.js +6 -0
- package/dist/testing/src/cli.d.ts +2 -0
- package/dist/testing/src/cli.js +563 -0
- package/dist/testing/src/client.d.ts +115 -0
- package/dist/testing/src/client.js +955 -0
- package/dist/testing/src/http-agent.d.ts +47 -0
- package/dist/testing/src/http-agent.js +155 -0
- package/dist/testing/src/index.d.ts +3 -0
- package/dist/testing/src/index.js +2 -0
- package/dist/testing/src/new.d.ts +9 -0
- package/dist/testing/src/new.js +122 -0
- package/dist/testing/src/print-run.d.ts +3 -0
- package/dist/testing/src/print-run.js +22 -0
- package/dist/testing/src/protocol.d.ts +159 -0
- package/dist/testing/src/protocol.js +28 -0
- package/dist/testing/src/report.d.ts +74 -0
- package/dist/testing/src/report.js +90 -0
- package/dist/testing/src/show.d.ts +36 -0
- package/dist/testing/src/show.js +280 -0
- package/dist/testing/src/suite.d.ts +87 -0
- package/dist/testing/src/suite.js +198 -0
- package/examples/cafe/agent/AGENTS.md +10 -0
- package/examples/cafe/agent/skills/allergens/SKILL.md +7 -0
- package/examples/cafe/src/agent.ts +39 -0
- package/examples/cafe/src/main.ts +16 -0
- package/examples/cafe/src/tools.ts +62 -0
- package/examples/cafe/tests/scenarios/latte-correction.yaml +30 -0
- package/examples/cafe/tests/scenarios/order-fails.yaml +26 -0
- package/examples/cafe/tests/tools/get_menu.yaml +14 -0
- package/examples/cafe/tests/tools/place_order.yaml +29 -0
- package/examples/http-agent/server.mjs +32 -0
- package/examples/http-agent/tests/scenarios/opening-hours.yaml +16 -0
- package/flow-messaging/README.md +152 -0
- package/package.json +65 -4
- package/spec/agent-endpoint.openapi.yaml +148 -0
- package/spec/nudges.openapi.yaml +167 -0
- package/spec/request.schema.json +121 -0
- package/spec/response.schema.json +284 -0
|
@@ -0,0 +1,361 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import type { Emit, EventSink } from "./events.ts";
|
|
3
|
+
import type { ConversationRow, InboxRow, QuietHours, StoreApi, TimeZoneSource } from "./store.ts";
|
|
4
|
+
import { type TalkSettings } from "./talk.ts";
|
|
5
|
+
import { type Tool } from "./tools.ts";
|
|
6
|
+
import type { ChannelInfo, ChatMessage, Deliver, Incoming, Model, TemplateDefinition, ToolSpec, Transcribe } from "./types.ts";
|
|
7
|
+
export interface ConversationSettings {
|
|
8
|
+
model: Model;
|
|
9
|
+
/** Speech to text for voice notes; without it the agent is told it can't listen to them. */
|
|
10
|
+
transcribe?: Transcribe;
|
|
11
|
+
tools: Map<string, Tool>;
|
|
12
|
+
specs: ToolSpec[];
|
|
13
|
+
instructions: string;
|
|
14
|
+
/** Per-turn context for the system prompt (the person's profile, the time). */
|
|
15
|
+
context?: (conversationId: string) => Promise<string> | string;
|
|
16
|
+
/** Sinks that asked for turn.context. Others, traces included, do not receive it. */
|
|
17
|
+
contextSinks: EventSink[];
|
|
18
|
+
/** The longest a reply waits for a tool that sets no limit of its own. */
|
|
19
|
+
deadlineMs: number;
|
|
20
|
+
/** When one tool of a response is done and others still run this long after, the finished results go back. */
|
|
21
|
+
partialAfterMs: number;
|
|
22
|
+
debounceMs: number;
|
|
23
|
+
maxSteps: number;
|
|
24
|
+
/** About how many tokens one model call may carry (instructions, tools and history). */
|
|
25
|
+
historyTokens: number;
|
|
26
|
+
/** The longest a tool result is kept, in characters. */
|
|
27
|
+
toolResultChars: number;
|
|
28
|
+
/** How many times one step restarts for new messages before it lets the step finish. */
|
|
29
|
+
maxRestarts: number;
|
|
30
|
+
talk: TalkSettings;
|
|
31
|
+
emit: Emit;
|
|
32
|
+
store: StoreApi;
|
|
33
|
+
/** Resolves once the store's tables exist. */
|
|
34
|
+
ready: Promise<void>;
|
|
35
|
+
now: () => number;
|
|
36
|
+
/** The agent's own time zone (the business's): the time it is told when the person's is not known. */
|
|
37
|
+
timeZone?: string;
|
|
38
|
+
/** The agent's quiet hours for everyone (false: none), unless a person set their own. */
|
|
39
|
+
quietHours?: QuietHours | false;
|
|
40
|
+
/** The WhatsApp templates the owner declared: a sent one's text goes in the history. */
|
|
41
|
+
templates: TemplateDefinition[];
|
|
42
|
+
/** The declared template Flow Framework sends when no other one fits a closed window (createAgent's fallbackTemplate). */
|
|
43
|
+
fallbackTemplate?: string;
|
|
44
|
+
/** Tag every message with its channel (the agent has several), even for a person on one so far. */
|
|
45
|
+
tagChannels: boolean;
|
|
46
|
+
/** How the channels of a conversation loaded from the store are reached again. */
|
|
47
|
+
links(conversationId: string): Promise<ChannelLink[]>;
|
|
48
|
+
/** Records how a scheduled run or a nudge ended. */
|
|
49
|
+
settle(target: {
|
|
50
|
+
run?: string;
|
|
51
|
+
nudge?: string;
|
|
52
|
+
}, status: string, reason?: string): Promise<void>;
|
|
53
|
+
/** A window-closed prompt nudge the agent sent no template for: held until they reply, and the fallback goes. */
|
|
54
|
+
windowClosed(nudge: string, to: {
|
|
55
|
+
channel: string;
|
|
56
|
+
address: string;
|
|
57
|
+
}): Promise<void>;
|
|
58
|
+
}
|
|
59
|
+
/** One channel this person writes on, and how to reach them there. */
|
|
60
|
+
export interface ChannelLink {
|
|
61
|
+
name: string;
|
|
62
|
+
info: ChannelInfo;
|
|
63
|
+
/** The channel's own extra fields on its send tool. */
|
|
64
|
+
params?: Record<string, z.ZodType>;
|
|
65
|
+
/** The agent author's guidance for this channel, in the system prompt while it is in use. */
|
|
66
|
+
instructions?: string;
|
|
67
|
+
address: string;
|
|
68
|
+
deliver: Deliver;
|
|
69
|
+
lastMessageAt: number | null;
|
|
70
|
+
}
|
|
71
|
+
interface Task {
|
|
72
|
+
id: string;
|
|
73
|
+
tool: string;
|
|
74
|
+
/** Its input, as checked, with keys in a fixed order: a repeat of a running call has the same. */
|
|
75
|
+
input: string;
|
|
76
|
+
startedAt: number;
|
|
77
|
+
}
|
|
78
|
+
export declare class Conversation {
|
|
79
|
+
readonly id: string;
|
|
80
|
+
readonly personKey: string;
|
|
81
|
+
readonly history: ChatMessage[];
|
|
82
|
+
private readonly settings;
|
|
83
|
+
private readonly channels;
|
|
84
|
+
private pending;
|
|
85
|
+
private notes;
|
|
86
|
+
/** A tool's result is in the history and no message has gone out since: from the background, or returned to a response. */
|
|
87
|
+
private resultUnsent;
|
|
88
|
+
/** What the agent has sent in this turn, to tell its own text repeated from something new. */
|
|
89
|
+
private sentThisTurn;
|
|
90
|
+
private direct;
|
|
91
|
+
private owed;
|
|
92
|
+
/** The person's message ids, and the channel each came on. */
|
|
93
|
+
private readonly messageIds;
|
|
94
|
+
private readonly knownInbox;
|
|
95
|
+
private messageCount;
|
|
96
|
+
/** Turns begun, kept in the store: tools' idempotency keys carry the turn's number. */
|
|
97
|
+
private turns;
|
|
98
|
+
/** Aborted when the conversation closes: tools' signal. */
|
|
99
|
+
private readonly lifetime;
|
|
100
|
+
private recentChannels;
|
|
101
|
+
private timeZone;
|
|
102
|
+
/** Their own quiet hours ("off": none), or null for the agent's. */
|
|
103
|
+
private quietHours;
|
|
104
|
+
private running;
|
|
105
|
+
/** Messages whose files are still being read (downloaded, transcribed); later ones wait behind them. */
|
|
106
|
+
private preparing;
|
|
107
|
+
private stepAbort;
|
|
108
|
+
/** Ends the reply's wait for its tools now (the person wrote). */
|
|
109
|
+
private wakeTools;
|
|
110
|
+
private timer;
|
|
111
|
+
private readonly tasks;
|
|
112
|
+
private taskCount;
|
|
113
|
+
private idleSince;
|
|
114
|
+
private settled;
|
|
115
|
+
/** Channels where nothing has reached the person since their latest message there. */
|
|
116
|
+
private readonly unanswered;
|
|
117
|
+
/** The next model response is the first since their latest message. */
|
|
118
|
+
private firstResponse;
|
|
119
|
+
private readonly typingOn;
|
|
120
|
+
/** The send tool for each channel, this turn. */
|
|
121
|
+
private sendTools;
|
|
122
|
+
private readonly builtins;
|
|
123
|
+
private readonly builtinSpecs;
|
|
124
|
+
private readonly loaded;
|
|
125
|
+
private writes;
|
|
126
|
+
/** History entries already in the store. */
|
|
127
|
+
private saved;
|
|
128
|
+
/** A turn was cut off by a restart: it runs again with the history so far. */
|
|
129
|
+
private resumeTurn;
|
|
130
|
+
/** Forgotten: nothing more runs, is sent or is kept. */
|
|
131
|
+
private closed;
|
|
132
|
+
/** This turn took in a message from the person: if it fails, they are told. */
|
|
133
|
+
private theirMessages;
|
|
134
|
+
/** History entries left out of the latest model call (0: none), so a change is an event once. */
|
|
135
|
+
private leftOut;
|
|
136
|
+
/** They texted STOP (as of the latest look): what the business starts is dropped, with no model call. */
|
|
137
|
+
private stop;
|
|
138
|
+
constructor(id: string, personKey: string, settings: ConversationSettings, existing?: ConversationRow | null);
|
|
139
|
+
/** Their time zone, as the business set it or they said it: schedules, quiet hours and the time line use it from now on. */
|
|
140
|
+
setTimeZone(zone: string, source: TimeZoneSource): Promise<void>;
|
|
141
|
+
/** Their own quiet hours ("off": none; null: back to the agent's). */
|
|
142
|
+
setQuietHours(hours: QuietHours | "off" | null): Promise<void>;
|
|
143
|
+
/**
|
|
144
|
+
* send_template: the agent sends one of the business's WhatsApp templates, its values filled, when
|
|
145
|
+
* Flow Framework tells it their 24-hour window is closed. The fallback template is Flow Framework's to send.
|
|
146
|
+
*/
|
|
147
|
+
private templateTool;
|
|
148
|
+
/** What a channel of this conversation can show, if the person has written on it. */
|
|
149
|
+
channelInfo(channel: string): ChannelInfo | undefined;
|
|
150
|
+
/** Reach the person on this channel (again): a new channel, or a fresh way to deliver. */
|
|
151
|
+
link(link: ChannelLink): void;
|
|
152
|
+
/** A message from the person on `channel`; returns the id the agent sees it by. */
|
|
153
|
+
receive(input: string | Incoming, options: {
|
|
154
|
+
channel: string;
|
|
155
|
+
messageId?: string;
|
|
156
|
+
}): string;
|
|
157
|
+
/** The message is ready for the agent: it joins the reply in progress, or starts one. */
|
|
158
|
+
private arrive;
|
|
159
|
+
/**
|
|
160
|
+
* A message the agent's own rules answered with no model call (its intercept, a STOP, START or
|
|
161
|
+
* HELP keyword), and `reply`, what goes back to them ("" for nothing). Both join the history in
|
|
162
|
+
* order with their other messages, at the next step of a turn running now or else at once, and
|
|
163
|
+
* start no turn. Null when the channel gave this message before.
|
|
164
|
+
*
|
|
165
|
+
* `taken` is false when its provider id was taken first (by another runner, or before the STOP
|
|
166
|
+
* written in `claimed`, which already holds the id): nothing is kept then. `send` delivers the
|
|
167
|
+
* reply, unless it was not taken; it starts the delivery at once, so call it once `taken` where
|
|
168
|
+
* a retry must not be answered twice.
|
|
169
|
+
*/
|
|
170
|
+
answered(input: string | Incoming, options: {
|
|
171
|
+
channel: string;
|
|
172
|
+
messageId?: string;
|
|
173
|
+
claimed?: Promise<boolean>;
|
|
174
|
+
note?: string;
|
|
175
|
+
}, reply: string): {
|
|
176
|
+
id: string;
|
|
177
|
+
taken: Promise<boolean>;
|
|
178
|
+
send(): Promise<void>;
|
|
179
|
+
} | null;
|
|
180
|
+
/**
|
|
181
|
+
* What the agent gets of the person's files: photos and PDFs the model reads, a voice note as its
|
|
182
|
+
* transcript, and for anything else a mark saying why it cannot be read, so it can ask for text.
|
|
183
|
+
*/
|
|
184
|
+
private readFiles;
|
|
185
|
+
/** An event from the inbox (a scheduled run, a nudge) for this conversation. */
|
|
186
|
+
enqueue(row: InboxRow): void;
|
|
187
|
+
/**
|
|
188
|
+
* The person reacted to one of the agent's messages. The agent learns it at its next turn; a
|
|
189
|
+
* reaction alone does not start one.
|
|
190
|
+
*/
|
|
191
|
+
reacted(emoji: string, toText: string): void;
|
|
192
|
+
/** The channel reports, now or later, that a message did not reach the person. */
|
|
193
|
+
undelivered(text: string, reason: string): void;
|
|
194
|
+
/**
|
|
195
|
+
* They texted a STOP or START keyword: their STOP is kept (or lifted) with no model call, with
|
|
196
|
+
* the message's provider id. Returns the line the agent learns it by, kept with the message
|
|
197
|
+
* (`answered`), and `stored`, false when that id was taken before.
|
|
198
|
+
*/
|
|
199
|
+
keyword(kind: "stop" | "start", text: string, channel: string, messageId?: string): {
|
|
200
|
+
note: string;
|
|
201
|
+
stored: Promise<boolean>;
|
|
202
|
+
};
|
|
203
|
+
get busy(): boolean;
|
|
204
|
+
get idleForMs(): number;
|
|
205
|
+
get backgroundTasks(): Task[];
|
|
206
|
+
/** Resolves once nothing is running or waiting (no turn, no background task) and all is stored. */
|
|
207
|
+
whenIdle(): Promise<void>;
|
|
208
|
+
/** Resolves once everything so far is in the store. */
|
|
209
|
+
stored(): Promise<void>;
|
|
210
|
+
/**
|
|
211
|
+
* The person was forgotten: a step in flight is cut off, nothing waiting runs, nothing more is
|
|
212
|
+
* sent or kept. Tools already running finish on their own, and their results go nowhere.
|
|
213
|
+
*/
|
|
214
|
+
close(): void;
|
|
215
|
+
/** Runs `work` after every earlier write to the store, in order. */
|
|
216
|
+
persist(work: () => Promise<unknown>): Promise<void>;
|
|
217
|
+
/** Picks up where the conversation was: its history, events not yet handled, tools cut off. */
|
|
218
|
+
private load;
|
|
219
|
+
/** Messages from the person the agent has yet to answer (not those answered with no model call). */
|
|
220
|
+
private unread;
|
|
221
|
+
private hasWork;
|
|
222
|
+
private note;
|
|
223
|
+
private schedule;
|
|
224
|
+
private run;
|
|
225
|
+
/**
|
|
226
|
+
* A turn threw (the model failed): what it owed is settled as failed, what was waiting is taken
|
|
227
|
+
* in so it is not tried again, and only a person waiting on a reply is told something went wrong.
|
|
228
|
+
* A turn they did not start (a nudge, a scheduled message, a background result) stays silent.
|
|
229
|
+
*/
|
|
230
|
+
private turnFailed;
|
|
231
|
+
private checkIdle;
|
|
232
|
+
private views;
|
|
233
|
+
/** The channel of the person's latest message. */
|
|
234
|
+
private currentChannel;
|
|
235
|
+
/** Move waiting messages and notes into the history; the person's messages are now read. */
|
|
236
|
+
private absorb;
|
|
237
|
+
/** Stores history entries not yet stored, and marks the inbox rows they came from handled. */
|
|
238
|
+
private flush;
|
|
239
|
+
/** Only the latest MEDIA_SHOWN photos and PDFs keep their bytes; older ones are named, not shown. */
|
|
240
|
+
private showLatestMedia;
|
|
241
|
+
private turn;
|
|
242
|
+
private isTalk;
|
|
243
|
+
/** The channels a talk call reaches (for the acknowledgement rule), before it runs. */
|
|
244
|
+
private targets;
|
|
245
|
+
/**
|
|
246
|
+
* Run one of the send tools, react or share_updates. A message that went out says where it was
|
|
247
|
+
* delivered; one that failed on the way is told as a message of its own. `refused` is a call
|
|
248
|
+
* that did nothing because of its input: the agent gets another step to fix it.
|
|
249
|
+
*/
|
|
250
|
+
private talk;
|
|
251
|
+
/** How a scheduled run or a nudge ended, stored in order with everything else. */
|
|
252
|
+
private settle;
|
|
253
|
+
/** A message reached the person: whatever this turn owed them is sent. */
|
|
254
|
+
private sent;
|
|
255
|
+
private acknowledged;
|
|
256
|
+
private typing;
|
|
257
|
+
/** Hand one outbound to a channel; returns why it failed, or null. */
|
|
258
|
+
private send;
|
|
259
|
+
/** A fixed-text scheduled message or a text or template nudge, sent with no model turn. */
|
|
260
|
+
private sendDirect;
|
|
261
|
+
/**
|
|
262
|
+
* The history the model is sent: all of it while it fits the budget, else the latest entries
|
|
263
|
+
* that do, from the start of one (never between a call and its result), after a line that says
|
|
264
|
+
* older ones are left out. The latest turn always goes, however long.
|
|
265
|
+
*/
|
|
266
|
+
private window;
|
|
267
|
+
/** A tool result as the history keeps it: cut at toolResultChars, saying so. */
|
|
268
|
+
private capped;
|
|
269
|
+
/** The send tools the agent has right now, for Flow Framework's notes: "send_sms", or "send_sms or send_app". */
|
|
270
|
+
private sendToolsNow;
|
|
271
|
+
/**
|
|
272
|
+
* Run a response's tool calls together and wait for all of them, except: a message from the
|
|
273
|
+
* person ends the wait, a finished result waits at most partialAfterMs for the others, and a tool
|
|
274
|
+
* past its limit stops holding the reply. Whatever is still running then moves to the background.
|
|
275
|
+
*/
|
|
276
|
+
private runTools;
|
|
277
|
+
/** Start one tool call; the model's input is checked first (a refusal is the call's result). */
|
|
278
|
+
private start;
|
|
279
|
+
/** The reply stops waiting for this tool: it carries on in the background and its result comes back as a note. */
|
|
280
|
+
private detach;
|
|
281
|
+
}
|
|
282
|
+
/** The business may not message first on this channel now (WhatsApp, past 24 hours). */
|
|
283
|
+
export declare function windowClosed(link: {
|
|
284
|
+
info: ChannelInfo;
|
|
285
|
+
lastMessageAt: number | null;
|
|
286
|
+
}, now: number): boolean;
|
|
287
|
+
/** One line of a conversation as the person saw it, read back from the history (the playground shows these). */
|
|
288
|
+
export type TranscriptEntry = {
|
|
289
|
+
kind: "in";
|
|
290
|
+
channel: string;
|
|
291
|
+
id: string;
|
|
292
|
+
text: string;
|
|
293
|
+
at: number;
|
|
294
|
+
choice?: boolean;
|
|
295
|
+
} | {
|
|
296
|
+
kind: "out";
|
|
297
|
+
channel: string;
|
|
298
|
+
text: string;
|
|
299
|
+
at: number;
|
|
300
|
+
replyTo?: string;
|
|
301
|
+
buttons?: string[];
|
|
302
|
+
list?: {
|
|
303
|
+
button: string;
|
|
304
|
+
rows: Array<{
|
|
305
|
+
id: string;
|
|
306
|
+
title: string;
|
|
307
|
+
description?: string;
|
|
308
|
+
}>;
|
|
309
|
+
};
|
|
310
|
+
/** As the agent sent them: fitMessage shows them as a channel can. */
|
|
311
|
+
link?: {
|
|
312
|
+
label: string;
|
|
313
|
+
url: string;
|
|
314
|
+
};
|
|
315
|
+
image?: {
|
|
316
|
+
url: string;
|
|
317
|
+
};
|
|
318
|
+
/** The channel's own params the agent filled in. */
|
|
319
|
+
fields?: Record<string, unknown>;
|
|
320
|
+
/** A WhatsApp template the business sent, by name; the text is its body when it was declared. */
|
|
321
|
+
template?: string;
|
|
322
|
+
} | {
|
|
323
|
+
kind: "reaction";
|
|
324
|
+
channel: string;
|
|
325
|
+
messageId: string;
|
|
326
|
+
emoji: string;
|
|
327
|
+
at: number;
|
|
328
|
+
} | {
|
|
329
|
+
kind: "tool";
|
|
330
|
+
callId: string;
|
|
331
|
+
tool: string;
|
|
332
|
+
input: unknown;
|
|
333
|
+
output: string;
|
|
334
|
+
ok: boolean;
|
|
335
|
+
at: number;
|
|
336
|
+
};
|
|
337
|
+
/**
|
|
338
|
+
* The history as the person saw it: their messages (with their ids and channels), what the agent
|
|
339
|
+
* delivered with its send tools and reactions, and its other tool calls with their results.
|
|
340
|
+
* Flow Framework's notes and the agent's plain text never reached the person and are left out. `only` is
|
|
341
|
+
* the channel of untagged messages (an agent with one channel does not tag them).
|
|
342
|
+
*/
|
|
343
|
+
export declare function transcriptOf(history: Array<{
|
|
344
|
+
entry: ChatMessage;
|
|
345
|
+
at: number;
|
|
346
|
+
}>, only: string): TranscriptEntry[];
|
|
347
|
+
/**
|
|
348
|
+
* The time, for every turn: in their zone when the business or the person gave it, else in the
|
|
349
|
+
* business's, saying theirs is not known (never guessed from the business's).
|
|
350
|
+
*/
|
|
351
|
+
export declare function nowLine(now: number, personZone: string | null, agentZone: string | undefined): string;
|
|
352
|
+
export declare const PROFILE_TOOL = "get_user_profile";
|
|
353
|
+
/** The built-in tool over createAgent's `profile`: no input, so it is always about the person in this conversation. */
|
|
354
|
+
export declare function profileTool(profile: Profile): Tool;
|
|
355
|
+
/** createAgent's `profile`: what the business knows about the person, fetched only when the agent asks. */
|
|
356
|
+
export type Profile = (who: {
|
|
357
|
+
conversationId: string;
|
|
358
|
+
person: string;
|
|
359
|
+
channel: string;
|
|
360
|
+
}) => Promise<unknown> | unknown;
|
|
361
|
+
export {};
|