@base44-preview/platform 0.2.0-pr.315.9332712 → 0.2.0-pr.315.b2d4aaf
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/dist/react/chat-items.d.ts +30 -30
- package/dist/react/chat-items.js +122 -89
- package/dist/react/chat.types.d.ts +185 -101
- package/dist/react/index.d.ts +1 -1
- package/dist/react/index.js +1 -1
- package/dist/react/useBase44Chat.d.ts +15 -13
- package/dist/react/useBase44Chat.js +225 -170
- package/package.json +1 -1
|
@@ -1,36 +1,36 @@
|
|
|
1
1
|
import type { Message } from "../client/modules/builder.events.generated.js";
|
|
2
2
|
import type { ToolCall } from "../client/modules/builder.events.types.js";
|
|
3
3
|
import type { ChatItem, ChatQuestion, ChatStep } from "./chat.types.js";
|
|
4
|
-
/** @internal
|
|
5
|
-
export type
|
|
6
|
-
/** @internal
|
|
7
|
-
export type
|
|
4
|
+
/** @internal Sends the answer to the one tool call a question belongs to. */
|
|
5
|
+
export type AnswerToolCall = (approve: boolean, extraUserInput?: Record<string, unknown>) => Promise<void>;
|
|
6
|
+
/** @internal Sends an answer to a given tool call in a given message. */
|
|
7
|
+
export type SubmitAnswer = (toolCallId: string, messageId: string, approve: boolean, extraUserInput?: Record<string, unknown>) => Promise<void>;
|
|
8
8
|
/** @internal Events can arrive out of order, so messages are ordered by when they were created. */
|
|
9
9
|
export declare function sortMessages(messages: Message[]): Message[];
|
|
10
10
|
/** @internal Replaces the message with the same id in place, or adds it at the end. */
|
|
11
|
-
export declare function mergeMessage(
|
|
11
|
+
export declare function mergeMessage(messages: Message[], updatedMessage: Message): Message[];
|
|
12
12
|
/** @internal How many of the newest messages a snapshot holds. */
|
|
13
13
|
export declare const SNAPSHOT_SIZE = 50;
|
|
14
14
|
/** @internal A rejoin's snapshot holds only the newest messages: it is the truth for its window,
|
|
15
15
|
* and the messages before its oldest one stay. A snapshot with room to spare holds them all. */
|
|
16
|
-
export declare function mergeSnapshot(
|
|
17
|
-
/** @internal Turns sorted messages into items. A waiting tool call that is not
|
|
18
|
-
* of a kind this release knows carries its own question, in the last
|
|
19
|
-
*
|
|
20
|
-
export declare function toItems(
|
|
16
|
+
export declare function mergeSnapshot(heldMessages: Message[], snapshotMessages: Message[]): Message[];
|
|
17
|
+
/** @internal Turns sorted messages into items. A waiting tool call that is not answered yet and is
|
|
18
|
+
* of a kind this release knows carries its own question, in the last turn reply only: the one that
|
|
19
|
+
* makes the chat wait. Older waiting calls keep their status but no question. */
|
|
20
|
+
export declare function toItems(sortedMessages: Message[], answeredToolCallIds: string[], submitAnswer: SubmitAnswer): ChatItem[];
|
|
21
21
|
/** @internal Base44's tool call status, as a step's. */
|
|
22
|
-
export declare function stepStatus(
|
|
23
|
-
/** @internal Whether the chat waits on the user. Like Base44's builder, only the last
|
|
24
|
-
*
|
|
25
|
-
export declare function
|
|
26
|
-
/** @internal Waiting calls on the last
|
|
27
|
-
*
|
|
28
|
-
export declare function
|
|
22
|
+
export declare function stepStatus(toolCall: ToolCall): ChatStep["status"];
|
|
23
|
+
/** @internal Whether the chat waits on the user. Like Base44's builder, only the last turn reply
|
|
24
|
+
* counts, and a call answered or declined here stops counting. */
|
|
25
|
+
export declare function isWaitingForUser(sortedMessages: Message[], answeredToolCallIds: string[]): boolean;
|
|
26
|
+
/** @internal Waiting calls on the last turn reply whose kind Base44 names and this release doesn't
|
|
27
|
+
* know, to decline. A call with no kind comes only from old messages and is left alone. */
|
|
28
|
+
export declare function unknownKindToolCalls(sortedMessages: Message[]): {
|
|
29
29
|
toolCallId: string;
|
|
30
30
|
messageId: string;
|
|
31
31
|
}[];
|
|
32
|
-
/** @internal The ids of tool
|
|
33
|
-
export declare function
|
|
32
|
+
/** @internal The ids of every tool call Base44 reports waiting. */
|
|
33
|
+
export declare function waitingToolCallIds(sortedMessages: Message[]): Set<string>;
|
|
34
34
|
/** @internal A prompt sent from this chat that Base44 has not confirmed, for the app it went to. */
|
|
35
35
|
export interface PendingPrompt {
|
|
36
36
|
id: string;
|
|
@@ -38,14 +38,14 @@ export interface PendingPrompt {
|
|
|
38
38
|
createdAt: string;
|
|
39
39
|
appId: string;
|
|
40
40
|
}
|
|
41
|
-
/** @internal Prompts that arrived from Base44 as messages settle the pending ones
|
|
42
|
-
*
|
|
43
|
-
*
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
*
|
|
50
|
-
* release doesn't know has no shape. */
|
|
51
|
-
export declare function
|
|
41
|
+
/** @internal Prompts that arrived from Base44 as messages settle the pending ones with the same
|
|
42
|
+
* text. Base44's public send carries no client id, so text is the only link, and a prompt someone
|
|
43
|
+
* else sent to the same app never settles one of ours. */
|
|
44
|
+
export declare function settlePendingPrompts(pendingPrompts: PendingPrompt[], appId: string, arrivedPrompts: string[]): PendingPrompt[];
|
|
45
|
+
/** @internal Pending prompts as items, drawn after the messages Base44 has. */
|
|
46
|
+
export declare function pendingPromptItems(pendingPrompts: PendingPrompt[]): ChatItem[];
|
|
47
|
+
/** @internal Base44's question formats, as one simple shape per kind, each bound to the call that
|
|
48
|
+
* answers it. Base44 keys choice answers by position, so `picked` and `texts` follow `questions`,
|
|
49
|
+
* and like Base44's builder a single pick goes in `selected_label`, several in `selected_labels`,
|
|
50
|
+
* and free text in `custom_text`. A kind this release doesn't know has no shape. */
|
|
51
|
+
export declare function toQuestion(toolCall: ToolCall, answerToolCall: AnswerToolCall): ChatQuestion | undefined;
|
package/dist/react/chat-items.js
CHANGED
|
@@ -1,152 +1,185 @@
|
|
|
1
1
|
/** @internal Events can arrive out of order, so messages are ordered by when they were created. */
|
|
2
2
|
export function sortMessages(messages) {
|
|
3
|
-
return [...messages].sort((
|
|
3
|
+
return [...messages].sort((first, second) => { var _a, _b, _c, _d; return ((_b = (_a = first.metadata) === null || _a === void 0 ? void 0 : _a.created_date) !== null && _b !== void 0 ? _b : "").localeCompare((_d = (_c = second.metadata) === null || _c === void 0 ? void 0 : _c.created_date) !== null && _d !== void 0 ? _d : ""); });
|
|
4
4
|
}
|
|
5
5
|
/** @internal Replaces the message with the same id in place, or adds it at the end. */
|
|
6
|
-
export function mergeMessage(
|
|
7
|
-
|
|
6
|
+
export function mergeMessage(messages, updatedMessage) {
|
|
7
|
+
const isKnown = messages.some(message => message.id === updatedMessage.id);
|
|
8
|
+
if (!isKnown)
|
|
9
|
+
return [...messages, updatedMessage];
|
|
10
|
+
return messages.map(message => (message.id === updatedMessage.id ? updatedMessage : message));
|
|
8
11
|
}
|
|
9
12
|
/** @internal How many of the newest messages a snapshot holds. */
|
|
10
13
|
export const SNAPSHOT_SIZE = 50;
|
|
11
14
|
/** @internal A rejoin's snapshot holds only the newest messages: it is the truth for its window,
|
|
12
15
|
* and the messages before its oldest one stay. A snapshot with room to spare holds them all. */
|
|
13
|
-
export function mergeSnapshot(
|
|
16
|
+
export function mergeSnapshot(heldMessages, snapshotMessages) {
|
|
14
17
|
var _a, _b, _c;
|
|
15
|
-
if (
|
|
16
|
-
return
|
|
17
|
-
const
|
|
18
|
-
const
|
|
19
|
-
|
|
18
|
+
if (snapshotMessages.length < SNAPSHOT_SIZE)
|
|
19
|
+
return snapshotMessages;
|
|
20
|
+
const oldestSnapshotDate = (_c = (_b = (_a = sortMessages(snapshotMessages)[0]) === null || _a === void 0 ? void 0 : _a.metadata) === null || _b === void 0 ? void 0 : _b.created_date) !== null && _c !== void 0 ? _c : "";
|
|
21
|
+
const snapshotIds = new Set(snapshotMessages.map(message => message.id));
|
|
22
|
+
const olderMessages = heldMessages.filter(message => { var _a, _b; return !snapshotIds.has(message.id) && ((_b = (_a = message.metadata) === null || _a === void 0 ? void 0 : _a.created_date) !== null && _b !== void 0 ? _b : "") < oldestSnapshotDate; });
|
|
23
|
+
return [...olderMessages, ...snapshotMessages];
|
|
20
24
|
}
|
|
21
25
|
/** @internal An assistant message that answers a turn. Base44 injects notices that expect no reply. */
|
|
22
|
-
function
|
|
26
|
+
function isTurnReply(message) {
|
|
23
27
|
var _a;
|
|
24
|
-
return (
|
|
28
|
+
return (message === null || message === void 0 ? void 0 : message.role) === "assistant" && !((_a = message.additional_message_params) === null || _a === void 0 ? void 0 : _a.skip_ai_response);
|
|
25
29
|
}
|
|
26
|
-
/** @internal
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
30
|
+
/** @internal The last assistant message that answers a turn, as Base44's own builder finds it. */
|
|
31
|
+
function lastTurnReply(sortedMessages) {
|
|
32
|
+
return [...sortedMessages].reverse().find(isTurnReply);
|
|
33
|
+
}
|
|
34
|
+
/** @internal Turns sorted messages into items. A waiting tool call that is not answered yet and is
|
|
35
|
+
* of a kind this release knows carries its own question, in the last turn reply only: the one that
|
|
36
|
+
* makes the chat wait. Older waiting calls keep their status but no question. */
|
|
37
|
+
export function toItems(sortedMessages, answeredToolCallIds, submitAnswer) {
|
|
38
|
+
const lastReply = lastTurnReply(sortedMessages);
|
|
39
|
+
return sortedMessages.map(message => {
|
|
32
40
|
var _a, _b, _c, _d;
|
|
33
41
|
return ({
|
|
34
|
-
id:
|
|
35
|
-
role:
|
|
36
|
-
text: (_a =
|
|
37
|
-
createdAt: (_c = (_b =
|
|
42
|
+
id: message.id,
|
|
43
|
+
role: message.role === "user" ? "user" : "assistant",
|
|
44
|
+
text: (_a = message.content) !== null && _a !== void 0 ? _a : "",
|
|
45
|
+
createdAt: (_c = (_b = message.metadata) === null || _b === void 0 ? void 0 : _b.created_date) !== null && _c !== void 0 ? _c : "",
|
|
38
46
|
pending: false,
|
|
39
|
-
steps: ((_d =
|
|
47
|
+
steps: ((_d = message.tool_calls) !== null && _d !== void 0 ? _d : []).map(toolCall => {
|
|
48
|
+
const isAnswerable = message === lastReply && !answeredToolCallIds.includes(toolCall.id);
|
|
49
|
+
const answerToolCall = isAnswerable
|
|
50
|
+
? (approve, extraUserInput) => submitAnswer(toolCall.id, message.id, approve, extraUserInput)
|
|
51
|
+
: undefined;
|
|
52
|
+
return toStep(toolCall, answerToolCall);
|
|
53
|
+
}),
|
|
40
54
|
});
|
|
41
55
|
});
|
|
42
56
|
}
|
|
43
|
-
|
|
44
|
-
function lastActionable(sorted) {
|
|
45
|
-
return [...sorted].reverse().find(isActionable);
|
|
46
|
-
}
|
|
47
|
-
function toStep(tool, reply) {
|
|
57
|
+
function toStep(toolCall, answerToolCall) {
|
|
48
58
|
var _a, _b;
|
|
49
|
-
const
|
|
59
|
+
const toolName = (_a = toolCall.name) !== null && _a !== void 0 ? _a : "";
|
|
50
60
|
// Only file tools carry `display.file_paths`.
|
|
51
|
-
const display = "display" in
|
|
61
|
+
const display = "display" in toolCall ? toolCall.display : undefined;
|
|
52
62
|
const files = (_b = display === null || display === void 0 ? void 0 : display.file_paths) !== null && _b !== void 0 ? _b : [];
|
|
53
|
-
const status = stepStatus(
|
|
54
|
-
const question = status === "waiting" &&
|
|
55
|
-
return { id:
|
|
63
|
+
const status = stepStatus(toolCall);
|
|
64
|
+
const question = status === "waiting" && answerToolCall ? toQuestion(toolCall, answerToolCall) : undefined;
|
|
65
|
+
return { id: toolCall.id, tool: toolName, files, label: [toolName, ...files].join(" "), status, ...(question && { question }) };
|
|
56
66
|
}
|
|
57
67
|
/** @internal Base44's tool call status, as a step's. */
|
|
58
|
-
export function stepStatus(
|
|
59
|
-
if (
|
|
68
|
+
export function stepStatus(toolCall) {
|
|
69
|
+
if (toolCall.status === "running")
|
|
60
70
|
return "running";
|
|
61
|
-
if (
|
|
71
|
+
if (toolCall.status === "waiting_for_user_input")
|
|
62
72
|
return "waiting";
|
|
63
|
-
if (
|
|
73
|
+
if (toolCall.status === "stopped")
|
|
64
74
|
return "stopped";
|
|
65
|
-
if (
|
|
75
|
+
if (toolCall.status === "error")
|
|
66
76
|
return "error";
|
|
67
77
|
return "done";
|
|
68
78
|
}
|
|
69
|
-
/** @internal Whether the chat waits on the user. Like Base44's builder, only the last
|
|
70
|
-
*
|
|
71
|
-
export function
|
|
79
|
+
/** @internal Whether the chat waits on the user. Like Base44's builder, only the last turn reply
|
|
80
|
+
* counts, and a call answered or declined here stops counting. */
|
|
81
|
+
export function isWaitingForUser(sortedMessages, answeredToolCallIds) {
|
|
72
82
|
var _a;
|
|
73
|
-
const
|
|
74
|
-
return !!((_a =
|
|
83
|
+
const lastReply = lastTurnReply(sortedMessages);
|
|
84
|
+
return !!((_a = lastReply === null || lastReply === void 0 ? void 0 : lastReply.tool_calls) === null || _a === void 0 ? void 0 : _a.some(toolCall => toolCall.status === "waiting_for_user_input" && !answeredToolCallIds.includes(toolCall.id)));
|
|
75
85
|
}
|
|
76
|
-
const
|
|
77
|
-
/** @internal Waiting calls on the last
|
|
78
|
-
*
|
|
79
|
-
export function
|
|
86
|
+
const KNOWN_QUESTION_KINDS = ["approval", "choice", "input"];
|
|
87
|
+
/** @internal Waiting calls on the last turn reply whose kind Base44 names and this release doesn't
|
|
88
|
+
* know, to decline. A call with no kind comes only from old messages and is left alone. */
|
|
89
|
+
export function unknownKindToolCalls(sortedMessages) {
|
|
80
90
|
var _a;
|
|
81
|
-
const
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
91
|
+
const lastReply = lastTurnReply(sortedMessages);
|
|
92
|
+
if (!lastReply)
|
|
93
|
+
return [];
|
|
94
|
+
return ((_a = lastReply.tool_calls) !== null && _a !== void 0 ? _a : [])
|
|
95
|
+
.filter(toolCall => {
|
|
96
|
+
var _a;
|
|
97
|
+
const kind = (_a = toolCall.waiting_on) === null || _a === void 0 ? void 0 : _a.kind;
|
|
98
|
+
return toolCall.status === "waiting_for_user_input" && !!kind && !KNOWN_QUESTION_KINDS.includes(kind);
|
|
99
|
+
})
|
|
100
|
+
.map(toolCall => ({ toolCallId: toolCall.id, messageId: lastReply.id }));
|
|
85
101
|
}
|
|
86
|
-
/** @internal The ids of tool
|
|
87
|
-
export function
|
|
88
|
-
return new Set(
|
|
102
|
+
/** @internal The ids of every tool call Base44 reports waiting. */
|
|
103
|
+
export function waitingToolCallIds(sortedMessages) {
|
|
104
|
+
return new Set(sortedMessages.flatMap(message => { var _a; return ((_a = message.tool_calls) !== null && _a !== void 0 ? _a : []).filter(toolCall => toolCall.status === "waiting_for_user_input").map(toolCall => toolCall.id); }));
|
|
89
105
|
}
|
|
90
|
-
/** @internal Prompts that arrived from Base44 as messages settle the pending ones
|
|
91
|
-
*
|
|
92
|
-
*
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
const match = (_a = mine.find(p => p.content.trim() === text.trim())) !== null && _a !== void 0 ? _a : (oldestOtherwise ? mine[0] : undefined);
|
|
100
|
-
if (match)
|
|
101
|
-
rest = rest.filter(p => p !== match);
|
|
106
|
+
/** @internal Prompts that arrived from Base44 as messages settle the pending ones with the same
|
|
107
|
+
* text. Base44's public send carries no client id, so text is the only link, and a prompt someone
|
|
108
|
+
* else sent to the same app never settles one of ours. */
|
|
109
|
+
export function settlePendingPrompts(pendingPrompts, appId, arrivedPrompts) {
|
|
110
|
+
let stillPending = pendingPrompts;
|
|
111
|
+
for (const arrivedPrompt of arrivedPrompts) {
|
|
112
|
+
const settled = stillPending.find(prompt => prompt.appId === appId && prompt.content.trim() === arrivedPrompt.trim());
|
|
113
|
+
if (settled)
|
|
114
|
+
stillPending = stillPending.filter(prompt => prompt !== settled);
|
|
102
115
|
}
|
|
103
|
-
return
|
|
116
|
+
return stillPending;
|
|
104
117
|
}
|
|
105
|
-
/** @internal Pending prompts as items, after the messages Base44 has. */
|
|
106
|
-
export function
|
|
107
|
-
return
|
|
118
|
+
/** @internal Pending prompts as items, drawn after the messages Base44 has. */
|
|
119
|
+
export function pendingPromptItems(pendingPrompts) {
|
|
120
|
+
return pendingPrompts.map(prompt => ({ id: prompt.id, role: "user", text: prompt.content, createdAt: prompt.createdAt, steps: [], pending: true }));
|
|
108
121
|
}
|
|
109
|
-
/** @internal Base44's question formats, as one simple shape per kind, each bound to the
|
|
110
|
-
* answers it. Base44 keys choice answers by position, so `picked`
|
|
111
|
-
*
|
|
112
|
-
|
|
122
|
+
/** @internal Base44's question formats, as one simple shape per kind, each bound to the call that
|
|
123
|
+
* answers it. Base44 keys choice answers by position, so `picked` and `texts` follow `questions`,
|
|
124
|
+
* and like Base44's builder a single pick goes in `selected_label`, several in `selected_labels`,
|
|
125
|
+
* and free text in `custom_text`. A kind this release doesn't know has no shape. */
|
|
126
|
+
export function toQuestion(toolCall, answerToolCall) {
|
|
113
127
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
114
|
-
const kind = (_a =
|
|
115
|
-
const decline = () =>
|
|
128
|
+
const kind = (_a = toolCall.waiting_on) === null || _a === void 0 ? void 0 : _a.kind;
|
|
129
|
+
const decline = () => answerToolCall(false);
|
|
116
130
|
if (kind === "choice") {
|
|
117
|
-
const questions = (_c = (_b =
|
|
131
|
+
const questions = (_c = (_b = toolArguments(toolCall)) === null || _b === void 0 ? void 0 : _b.questions) !== null && _c !== void 0 ? _c : [];
|
|
118
132
|
return {
|
|
119
133
|
kind,
|
|
120
|
-
questions: questions.map(
|
|
134
|
+
questions: questions.map(question => {
|
|
121
135
|
var _a, _b;
|
|
122
136
|
return ({
|
|
123
|
-
text: (_a =
|
|
124
|
-
description:
|
|
125
|
-
|
|
126
|
-
|
|
137
|
+
text: (_a = question.question) !== null && _a !== void 0 ? _a : "",
|
|
138
|
+
description: question.description,
|
|
139
|
+
type: question.type,
|
|
140
|
+
options: ((_b = question.options) !== null && _b !== void 0 ? _b : []).map(option => { var _a; return (typeof option === "string" ? option : (_a = option.label) !== null && _a !== void 0 ? _a : ""); }),
|
|
141
|
+
multi: !!question.multi_select,
|
|
127
142
|
});
|
|
128
143
|
}),
|
|
129
|
-
answer: picked
|
|
144
|
+
answer: (picked, texts = []) => {
|
|
145
|
+
const answers = questions.flatMap((question, questionIndex) => {
|
|
146
|
+
var _a, _b;
|
|
147
|
+
const labels = (_a = picked[questionIndex]) !== null && _a !== void 0 ? _a : [];
|
|
148
|
+
const customText = (_b = texts[questionIndex]) === null || _b === void 0 ? void 0 : _b.trim();
|
|
149
|
+
if (!labels.length && !customText)
|
|
150
|
+
return [];
|
|
151
|
+
const answer = { question_index: questionIndex };
|
|
152
|
+
if (question.multi_select && labels.length)
|
|
153
|
+
answer.selected_labels = labels;
|
|
154
|
+
if (!question.multi_select && labels.length)
|
|
155
|
+
answer.selected_label = labels[0];
|
|
156
|
+
if (customText)
|
|
157
|
+
answer.custom_text = customText;
|
|
158
|
+
return [answer];
|
|
159
|
+
});
|
|
160
|
+
return answerToolCall(true, { answers });
|
|
161
|
+
},
|
|
130
162
|
decline,
|
|
131
163
|
};
|
|
132
164
|
}
|
|
133
165
|
if (kind === "input") {
|
|
134
|
-
const
|
|
166
|
+
const secretFields = (_e = (_d = toolArguments(toolCall)) === null || _d === void 0 ? void 0 : _d.secrets_schema) !== null && _e !== void 0 ? _e : [];
|
|
135
167
|
return {
|
|
136
168
|
kind: "secrets",
|
|
137
|
-
fields:
|
|
138
|
-
submit: values =>
|
|
169
|
+
fields: secretFields.map(field => { var _a; return ({ name: (_a = field.secretName) !== null && _a !== void 0 ? _a : "", description: field.description }); }),
|
|
170
|
+
submit: values => answerToolCall(true, { secrets: values }),
|
|
139
171
|
decline,
|
|
140
172
|
};
|
|
141
173
|
}
|
|
142
174
|
if (kind === "approval") {
|
|
143
175
|
// Guards that declare a reason or a summary carry them; the others name only themselves.
|
|
144
|
-
const approval =
|
|
145
|
-
|
|
176
|
+
const approval = toolCall.approval;
|
|
177
|
+
const reason = (_h = (_f = approval === null || approval === void 0 ? void 0 : approval.reason) !== null && _f !== void 0 ? _f : (_g = approval === null || approval === void 0 ? void 0 : approval.details) === null || _g === void 0 ? void 0 : _g.summary) !== null && _h !== void 0 ? _h : "";
|
|
178
|
+
return { kind, action: (_j = toolCall.name) !== null && _j !== void 0 ? _j : "", reason, approve: () => answerToolCall(true), decline };
|
|
146
179
|
}
|
|
147
180
|
return undefined;
|
|
148
181
|
}
|
|
149
182
|
// The waiting kind says which arguments a call carries; the tool's name only narrows the union.
|
|
150
|
-
function
|
|
151
|
-
return "arguments" in
|
|
183
|
+
function toolArguments(toolCall) {
|
|
184
|
+
return "arguments" in toolCall ? toolCall.arguments : undefined;
|
|
152
185
|
}
|