gemi 0.163.3 → 0.164.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/dist/ai/client/index.d.ts +1 -0
- package/dist/ai/client/index.d.ts.map +1 -1
- package/dist/ai/client/index.js +49 -4
- package/dist/ai/client/index.js.map +1 -1
- package/dist/ai/client/reducer.d.ts +13 -0
- package/dist/ai/client/reducer.d.ts.map +1 -1
- package/dist/ai/index.js +2 -2
- package/dist/ai/index.js.map +3 -3
- package/dist/ai/types.d.ts +16 -0
- package/dist/ai/types.d.ts.map +1 -1
- package/dist/ai/useChat.d.ts +15 -1
- package/dist/ai/useChat.d.ts.map +1 -1
- package/dist/{chunk-n8j5hn90.js → chunk-34svz95a.js} +2 -2
- package/dist/{chunk-n8j5hn90.js.map → chunk-34svz95a.js.map} +1 -1
- package/dist/{chunk-qze2eh68.js → chunk-472qd3v9.js} +1 -1
- package/dist/{chunk-s8kenmvr.js → chunk-dcnz24yt.js} +1 -1
- package/dist/{chunk-0e1e64h1.js → chunk-mvj8q5a7.js} +1 -1
- package/dist/{chunk-y4bjsyt4.js → chunk-pq86vmxv.js} +4 -4
- package/dist/{chunk-y4bjsyt4.js.map → chunk-pq86vmxv.js.map} +3 -3
- package/dist/kernel/index.js +1 -1
- package/dist/server/index.js +1 -1
- package/dist/services/index.js +1 -1
- package/package.json +1 -1
- /package/dist/{chunk-qze2eh68.js.map → chunk-472qd3v9.js.map} +0 -0
- /package/dist/{chunk-s8kenmvr.js.map → chunk-dcnz24yt.js.map} +0 -0
- /package/dist/{chunk-0e1e64h1.js.map → chunk-mvj8q5a7.js.map} +0 -0
|
@@ -19,6 +19,7 @@
|
|
|
19
19
|
* for `applyFrame` is reimplementing the hook.
|
|
20
20
|
*/
|
|
21
21
|
export { AttachError, useChat } from "../useChat";
|
|
22
|
+
export { openPending } from "./reducer";
|
|
22
23
|
export type { AgentAttachBody, AttachOptions, AgentRequestBody, AgentStopBody, ChatStatus, SendMessageOptions, UseChatParams, UseChatResult, } from "../useChat";
|
|
23
24
|
export type { AgentContentPart, AgentError, AgentJobRef, AgentErrorCode, AgentMessage, AgentStreamEvent, AgentStreamFrame, ClientToolResult, ClientTurn, FilePart, FinishReason, NestedRun, OutputPart, PendingToolCall, ReasoningPart, TextPart, ToolCallPart, ToolProgress, ToolResultPart, ToolShape, ToolShapes, Usage, } from "../types";
|
|
24
25
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../ai/client/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../ai/client/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAIlD,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AACxC,YAAY,EACV,eAAe,EACf,aAAa,EACb,gBAAgB,EAChB,aAAa,EACb,UAAU,EACV,kBAAkB,EAClB,aAAa,EACb,aAAa,GACd,MAAM,YAAY,CAAC;AAMpB,YAAY,EACV,gBAAgB,EAChB,UAAU,EACV,WAAW,EACX,cAAc,EACd,YAAY,EACZ,gBAAgB,EAChB,gBAAgB,EAChB,gBAAgB,EAChB,UAAU,EACV,QAAQ,EACR,YAAY,EAGZ,SAAS,EACT,UAAU,EACV,eAAe,EACf,aAAa,EACb,QAAQ,EACR,YAAY,EAKZ,YAAY,EACZ,cAAc,EACd,SAAS,EACT,UAAU,EACV,KAAK,GACN,MAAM,UAAU,CAAC"}
|
package/dist/ai/client/index.js
CHANGED
|
@@ -14,6 +14,25 @@ function initialChatState(init = {}) {
|
|
|
14
14
|
};
|
|
15
15
|
}
|
|
16
16
|
/**
|
|
17
|
+
* The calls a stored transcript is still waiting on (#1052): every
|
|
18
|
+
* `AgentMessage.pending` entry whose tool call has no result yet.
|
|
19
|
+
*
|
|
20
|
+
* What a page opened after the turn ended needs in order to answer it. The
|
|
21
|
+
* `awaiting-input` frame went to whichever client was watching then; the
|
|
22
|
+
* message kept a copy, and this reads it back. A call that has a result since
|
|
23
|
+
* (answered, refused by a later turn, closed as interrupted) is left out, so a
|
|
24
|
+
* thread read late does not hand back a question nobody can answer any more.
|
|
25
|
+
* A sub-agent's question is open while the top-level call it is nested under
|
|
26
|
+
* (`path[0]`) is.
|
|
27
|
+
*/
|
|
28
|
+
function openPending(messages) {
|
|
29
|
+
const resolved = /* @__PURE__ */ new Set();
|
|
30
|
+
for (const message of messages) for (const part of message.content) if (part.type === "tool-result") resolved.add(part.toolCallId);
|
|
31
|
+
const open = [];
|
|
32
|
+
for (const message of messages) for (const call of message.pending ?? []) if (!resolved.has(call.path?.[0] ?? call.toolCallId)) open.push(call);
|
|
33
|
+
return open;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
17
36
|
* Apply one frame.
|
|
18
37
|
*
|
|
19
38
|
* `now` is an argument rather than a `Date.now()` call so the reducer stays a
|
|
@@ -623,6 +642,29 @@ var AttachError = class extends Error {
|
|
|
623
642
|
if (status !== void 0) this.status = status;
|
|
624
643
|
}
|
|
625
644
|
};
|
|
645
|
+
/**
|
|
646
|
+
* What `pending` is after `setMessages` (#1052).
|
|
647
|
+
*
|
|
648
|
+
* A re-read thread says itself what is open (`AgentMessage.pending`), and that
|
|
649
|
+
* wins: it is the server's word, and it is empty for a question another tab
|
|
650
|
+
* has answered since. Messages this chat built from frames carry no copy, so
|
|
651
|
+
* an app that only rearranges its own list keeps what the `awaiting-input`
|
|
652
|
+
* frame said, for the calls that are still open in the list it set.
|
|
653
|
+
*/
|
|
654
|
+
function restatedPending(state, messages) {
|
|
655
|
+
const stored = openPending(messages);
|
|
656
|
+
if (stored.length > 0 || state.pending.length === 0) return stored;
|
|
657
|
+
const resolved = /* @__PURE__ */ new Set();
|
|
658
|
+
const called = /* @__PURE__ */ new Set();
|
|
659
|
+
for (const message of messages) for (const part of message.content) {
|
|
660
|
+
if (part.type === "tool-result") resolved.add(part.toolCallId);
|
|
661
|
+
if (part.type === "tool-call") called.add(part.toolCallId);
|
|
662
|
+
}
|
|
663
|
+
return state.pending.filter((call) => {
|
|
664
|
+
const host = call.path?.[0] ?? call.toolCallId;
|
|
665
|
+
return called.has(host) && !resolved.has(host);
|
|
666
|
+
});
|
|
667
|
+
}
|
|
626
668
|
var localIdCounter = 0;
|
|
627
669
|
/** Ids the client mints: messages it authored, and the correlation id it names a
|
|
628
670
|
* run by before the server has. Server-assigned ids are what keep a reattached
|
|
@@ -831,7 +873,7 @@ function findToolCall(messages, toolCallId) {
|
|
|
831
873
|
* first boundary.
|
|
832
874
|
*/
|
|
833
875
|
function useChat(path, params = {}) {
|
|
834
|
-
const { threadId: initialThreadId, initialMessages, cursor: initialCursor, attach: attachOnMount = true, reattachOnFocus = false, body: extraBody, headers, onFinish, onToolResult, onToolProgress, onError, onAwaitingInput, onAttachMiss } = params;
|
|
876
|
+
const { threadId: initialThreadId, initialMessages, initialPending, cursor: initialCursor, attach: attachOnMount = true, reattachOnFocus = false, body: extraBody, headers, onFinish, onToolResult, onToolProgress, onError, onAwaitingInput, onAttachMiss } = params;
|
|
835
877
|
const routeParams = useParams();
|
|
836
878
|
const base = useMemo(() => `/api${applyRouteParams(String(path).replace(/^[A-Z]+:/, ""), routeParams)}`, [path, routeParams]);
|
|
837
879
|
/**
|
|
@@ -847,6 +889,7 @@ function useChat(path, params = {}) {
|
|
|
847
889
|
const stateRef = useRef(null);
|
|
848
890
|
if (stateRef.current === null) stateRef.current = initialChatState({
|
|
849
891
|
messages: initialMessages,
|
|
892
|
+
pending: initialPending ?? (initialMessages && openPending(initialMessages)),
|
|
850
893
|
threadId: initialThreadId,
|
|
851
894
|
seq: initialCursor?.seq,
|
|
852
895
|
cursorRunId: initialCursor?.runId
|
|
@@ -1197,9 +1240,11 @@ function useChat(path, params = {}) {
|
|
|
1197
1240
|
});
|
|
1198
1241
|
}, [commit, send]);
|
|
1199
1242
|
const setMessages = useCallback((messages) => {
|
|
1243
|
+
const current = stateRef.current;
|
|
1200
1244
|
commit({
|
|
1201
|
-
...
|
|
1202
|
-
messages
|
|
1245
|
+
...current,
|
|
1246
|
+
messages,
|
|
1247
|
+
pending: restatedPending(current, messages)
|
|
1203
1248
|
});
|
|
1204
1249
|
}, [commit]);
|
|
1205
1250
|
const uploadFile = useCallback(async (file, options = {}) => {
|
|
@@ -1312,6 +1357,6 @@ function useChat(path, params = {}) {
|
|
|
1312
1357
|
};
|
|
1313
1358
|
}
|
|
1314
1359
|
//#endregion
|
|
1315
|
-
export { AttachError, useChat };
|
|
1360
|
+
export { AttachError, openPending, useChat };
|
|
1316
1361
|
|
|
1317
1362
|
//# sourceMappingURL=index.js.map
|