@layernorm/overlay-agent-host 0.9.0 → 0.11.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.
Files changed (121) hide show
  1. package/README.md +7 -4
  2. package/dist/browser-debug-sanitize.d.ts +10 -0
  3. package/dist/browser-debug-sanitize.d.ts.map +1 -0
  4. package/dist/browser-debug-sanitize.js +98 -0
  5. package/dist/browser-debug-sanitize.js.map +1 -0
  6. package/dist/cli.js +1 -1
  7. package/dist/cli.js.map +1 -1
  8. package/dist/host-capabilities.d.ts +1 -1
  9. package/dist/host-capabilities.d.ts.map +1 -1
  10. package/dist/host-capabilities.js +1 -1
  11. package/dist/host-capabilities.js.map +1 -1
  12. package/dist/local-browser-debug.d.ts +48 -0
  13. package/dist/local-browser-debug.d.ts.map +1 -0
  14. package/dist/local-browser-debug.js +260 -0
  15. package/dist/local-browser-debug.js.map +1 -0
  16. package/dist/local-project-instructions.d.ts +3 -0
  17. package/dist/local-project-instructions.d.ts.map +1 -0
  18. package/dist/local-project-instructions.js +41 -0
  19. package/dist/local-project-instructions.js.map +1 -0
  20. package/dist/local-tools-browser.d.ts +11 -2
  21. package/dist/local-tools-browser.d.ts.map +1 -1
  22. package/dist/local-tools-browser.js +26 -2
  23. package/dist/local-tools-browser.js.map +1 -1
  24. package/dist/local-tools-desktop-ui.d.ts +59 -0
  25. package/dist/local-tools-desktop-ui.d.ts.map +1 -0
  26. package/dist/local-tools-desktop-ui.js +319 -0
  27. package/dist/local-tools-desktop-ui.js.map +1 -0
  28. package/dist/local-tools-exec.d.ts +2 -2
  29. package/dist/local-tools-exec.d.ts.map +1 -1
  30. package/dist/local-tools-exec.js +13 -29
  31. package/dist/local-tools-exec.js.map +1 -1
  32. package/dist/local-tools-output.d.ts +37 -0
  33. package/dist/local-tools-output.d.ts.map +1 -0
  34. package/dist/local-tools-output.js +172 -0
  35. package/dist/local-tools-output.js.map +1 -0
  36. package/dist/local-tools-terminal.d.ts +11 -1
  37. package/dist/local-tools-terminal.d.ts.map +1 -1
  38. package/dist/local-tools-terminal.js +47 -6
  39. package/dist/local-tools-terminal.js.map +1 -1
  40. package/dist/local-tools.d.ts +13 -0
  41. package/dist/local-tools.d.ts.map +1 -1
  42. package/dist/local-tools.js +40 -7
  43. package/dist/local-tools.js.map +1 -1
  44. package/dist/private-threads-access.d.ts +62 -0
  45. package/dist/private-threads-access.d.ts.map +1 -0
  46. package/dist/private-threads-access.js +141 -0
  47. package/dist/private-threads-access.js.map +1 -0
  48. package/dist/private-threads-context.d.ts +47 -10
  49. package/dist/private-threads-context.d.ts.map +1 -1
  50. package/dist/private-threads-context.js +118 -34
  51. package/dist/private-threads-context.js.map +1 -1
  52. package/dist/private-threads-control.d.ts +25 -0
  53. package/dist/private-threads-control.d.ts.map +1 -0
  54. package/dist/private-threads-control.js +84 -0
  55. package/dist/private-threads-control.js.map +1 -0
  56. package/dist/private-threads-images.d.ts +15 -0
  57. package/dist/private-threads-images.d.ts.map +1 -0
  58. package/dist/private-threads-images.js +38 -0
  59. package/dist/private-threads-images.js.map +1 -0
  60. package/dist/private-threads-ipc.d.ts +16 -0
  61. package/dist/private-threads-ipc.d.ts.map +1 -1
  62. package/dist/private-threads-ipc.js +73 -12
  63. package/dist/private-threads-ipc.js.map +1 -1
  64. package/dist/private-threads-limits.d.ts +51 -0
  65. package/dist/private-threads-limits.d.ts.map +1 -0
  66. package/dist/private-threads-limits.js +51 -0
  67. package/dist/private-threads-limits.js.map +1 -0
  68. package/dist/private-threads-messages.d.ts +77 -0
  69. package/dist/private-threads-messages.d.ts.map +1 -0
  70. package/dist/private-threads-messages.js +204 -0
  71. package/dist/private-threads-messages.js.map +1 -0
  72. package/dist/private-threads-models.d.ts +7 -1
  73. package/dist/private-threads-models.d.ts.map +1 -1
  74. package/dist/private-threads-models.js +43 -0
  75. package/dist/private-threads-models.js.map +1 -1
  76. package/dist/private-threads-overlay-model.d.ts +1 -0
  77. package/dist/private-threads-overlay-model.d.ts.map +1 -1
  78. package/dist/private-threads-overlay-tools.d.ts +2 -0
  79. package/dist/private-threads-overlay-tools.d.ts.map +1 -1
  80. package/dist/private-threads-overlay-tools.js +2 -1
  81. package/dist/private-threads-overlay-tools.js.map +1 -1
  82. package/dist/private-threads-pieces.d.ts +14 -0
  83. package/dist/private-threads-pieces.d.ts.map +1 -0
  84. package/dist/private-threads-pieces.js +85 -0
  85. package/dist/private-threads-pieces.js.map +1 -0
  86. package/dist/private-threads-progress.d.ts +36 -0
  87. package/dist/private-threads-progress.d.ts.map +1 -0
  88. package/dist/private-threads-progress.js +83 -0
  89. package/dist/private-threads-progress.js.map +1 -0
  90. package/dist/private-threads-protocol.d.ts +237 -4
  91. package/dist/private-threads-protocol.d.ts.map +1 -1
  92. package/dist/private-threads-protocol.js +71 -6
  93. package/dist/private-threads-protocol.js.map +1 -1
  94. package/dist/private-threads-recall.d.ts +10 -0
  95. package/dist/private-threads-recall.d.ts.map +1 -0
  96. package/dist/private-threads-recall.js +40 -0
  97. package/dist/private-threads-recall.js.map +1 -0
  98. package/dist/private-threads-schema.d.ts +8 -0
  99. package/dist/private-threads-schema.d.ts.map +1 -0
  100. package/dist/private-threads-schema.js +188 -0
  101. package/dist/private-threads-schema.js.map +1 -0
  102. package/dist/private-threads-store.d.ts +120 -10
  103. package/dist/private-threads-store.d.ts.map +1 -1
  104. package/dist/private-threads-store.js +485 -62
  105. package/dist/private-threads-store.js.map +1 -1
  106. package/dist/private-threads-tools.d.ts.map +1 -1
  107. package/dist/private-threads-tools.js +40 -7
  108. package/dist/private-threads-tools.js.map +1 -1
  109. package/dist/private-threads-turn-model.d.ts +7 -0
  110. package/dist/private-threads-turn-model.d.ts.map +1 -0
  111. package/dist/private-threads-turn-model.js +31 -0
  112. package/dist/private-threads-turn-model.js.map +1 -0
  113. package/dist/private-threads.d.ts +44 -19
  114. package/dist/private-threads.d.ts.map +1 -1
  115. package/dist/private-threads.js +362 -213
  116. package/dist/private-threads.js.map +1 -1
  117. package/dist/process-identity.d.ts +14 -0
  118. package/dist/process-identity.d.ts.map +1 -0
  119. package/dist/process-identity.js +39 -0
  120. package/dist/process-identity.js.map +1 -0
  121. package/package.json +3 -2
@@ -0,0 +1,51 @@
1
+ /**
2
+ * Every limit on reading, saving and recalling a private thread, with its reason. Each one limits a single operation,
3
+ * never how long a thread can be: whatever doesn't fit is on the next page, in the next part or in the next batch.
4
+ */
5
+ /** A page of messages: the same 30 that every AI thread in Overlay opens with. */
6
+ export declare const MESSAGE_PAGE_SIZE = 30;
7
+ /** A page also stops here, so one page is parsed and sent between processes in a few milliseconds. A larger message
8
+ * comes alone, as a run of pieces that stops here too, and the page can ask for the rest. */
9
+ export declare const MESSAGE_PAGE_BYTES: number;
10
+ /** A part of a large message over this size isn't sent whole: text is cut into slices, and anything else is read by itself. */
11
+ export declare const LARGE_PART_BYTES: number;
12
+ export declare const TEXT_SLICE_CHARACTERS: number;
13
+ /** One read of a large part's JSON, at most about 1 MB. */
14
+ export declare const PART_SLICE_CHARACTERS: number;
15
+ /** A page of the thread list. A row is a few hundred bytes. */
16
+ export declare const THREAD_PAGE_SIZE = 100;
17
+ /** A page of tool calls, which also stops at `MESSAGE_PAGE_BYTES`. */
18
+ export declare const TOOL_CALL_PAGE_SIZE = 50;
19
+ /** A page of edited files. A row is a path and two numbers. */
20
+ export declare const EDIT_PAGE_SIZE = 100;
21
+ /** One message from the person, in characters: about a million tokens, more than models can read at once. Longer text
22
+ * can go in a file in the thread's folder, which the agent reads in parts. */
23
+ export declare const MAX_USER_MESSAGE_CHARACTERS = 4000000;
24
+ /** Answers in one send. They all belong to one model step, which never asks for close to this many actions. */
25
+ export declare const MAX_APPROVAL_ANSWERS = 1000;
26
+ /**
27
+ * A long reply is saved as several messages. Each step saves the open one again and the page copies it on every
28
+ * update, so its size, not the run's length, sets the cost of a step. It closes at the first step past this size, so
29
+ * one page usually holds several. Screenshots are counted separately: they are large but are dropped when the turn ends.
30
+ */
31
+ export declare const REPLY_PART_BYTES: number;
32
+ export declare const REPLY_PART_IMAGE_BYTES: number;
33
+ /** Text is searched and read back in pieces of this many characters, so a very long message can be read in parts. */
34
+ export declare const RECALL_PIECE_CHARACTERS = 4000;
35
+ /** One read or search result, about 3,000 tokens: small beside the smallest supported context window. */
36
+ export declare const RECALL_RESULT_CHARACTERS = 12000;
37
+ export declare const RECALL_PAGE_PIECES = 40;
38
+ export declare const RECALL_SEARCH_RESULTS = 10;
39
+ export declare const RECALL_EXCERPT_CHARACTERS = 600;
40
+ /** Messages are added to search in batches of this many or this size (but at least one), so other threads keep running
41
+ * while a long one is indexed for the first time. */
42
+ export declare const INDEX_BATCH_SIZE = 100;
43
+ export declare const INDEX_BATCH_BYTES: number;
44
+ /** The person's search waits this long for indexing, then returns what it has and says it isn't finished. */
45
+ export declare const SEARCH_WAIT_MS = 400;
46
+ /** A page of the person's search: one excerpt for each message. */
47
+ export declare const MESSAGE_SEARCH_RESULTS = 20;
48
+ export declare const MAX_SEARCH_CHARACTERS = 500;
49
+ /** A thread's messages are deleted this many at a time (a few milliseconds each), so other threads keep running. */
50
+ export declare const DELETE_BATCH_SIZE = 500;
51
+ //# sourceMappingURL=private-threads-limits.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"private-threads-limits.d.ts","sourceRoot":"","sources":["../src/private-threads-limits.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,kFAAkF;AAClF,eAAO,MAAM,iBAAiB,KAAK,CAAA;AACnC;6FAC6F;AAC7F,eAAO,MAAM,kBAAkB,QAAc,CAAA;AAC7C,+HAA+H;AAC/H,eAAO,MAAM,gBAAgB,QAAa,CAAA;AAC1C,eAAO,MAAM,qBAAqB,QAAY,CAAA;AAC9C,2DAA2D;AAC3D,eAAO,MAAM,qBAAqB,QAAa,CAAA;AAC/C,+DAA+D;AAC/D,eAAO,MAAM,gBAAgB,MAAM,CAAA;AACnC,sEAAsE;AACtE,eAAO,MAAM,mBAAmB,KAAK,CAAA;AACrC,+DAA+D;AAC/D,eAAO,MAAM,cAAc,MAAM,CAAA;AAEjC;8EAC8E;AAC9E,eAAO,MAAM,2BAA2B,UAAY,CAAA;AACpD,+GAA+G;AAC/G,eAAO,MAAM,oBAAoB,OAAQ,CAAA;AAEzC;;;;GAIG;AACH,eAAO,MAAM,gBAAgB,QAAa,CAAA;AAC1C,eAAO,MAAM,sBAAsB,QAAkB,CAAA;AAErD,qHAAqH;AACrH,eAAO,MAAM,uBAAuB,OAAQ,CAAA;AAC5C,yGAAyG;AACzG,eAAO,MAAM,wBAAwB,QAAS,CAAA;AAC9C,eAAO,MAAM,kBAAkB,KAAK,CAAA;AACpC,eAAO,MAAM,qBAAqB,KAAK,CAAA;AACvC,eAAO,MAAM,yBAAyB,MAAM,CAAA;AAC5C;qDACqD;AACrD,eAAO,MAAM,gBAAgB,MAAM,CAAA;AACnC,eAAO,MAAM,iBAAiB,QAAc,CAAA;AAC5C,6GAA6G;AAC7G,eAAO,MAAM,cAAc,MAAM,CAAA;AACjC,mEAAmE;AACnE,eAAO,MAAM,sBAAsB,KAAK,CAAA;AACxC,eAAO,MAAM,qBAAqB,MAAM,CAAA;AACxC,oHAAoH;AACpH,eAAO,MAAM,iBAAiB,MAAM,CAAA"}
@@ -0,0 +1,51 @@
1
+ /**
2
+ * Every limit on reading, saving and recalling a private thread, with its reason. Each one limits a single operation,
3
+ * never how long a thread can be: whatever doesn't fit is on the next page, in the next part or in the next batch.
4
+ */
5
+ /** A page of messages: the same 30 that every AI thread in Overlay opens with. */
6
+ export const MESSAGE_PAGE_SIZE = 30;
7
+ /** A page also stops here, so one page is parsed and sent between processes in a few milliseconds. A larger message
8
+ * comes alone, as a run of pieces that stops here too, and the page can ask for the rest. */
9
+ export const MESSAGE_PAGE_BYTES = 1024 * 1024;
10
+ /** A part of a large message over this size isn't sent whole: text is cut into slices, and anything else is read by itself. */
11
+ export const LARGE_PART_BYTES = 128 * 1024;
12
+ export const TEXT_SLICE_CHARACTERS = 32 * 1024;
13
+ /** One read of a large part's JSON, at most about 1 MB. */
14
+ export const PART_SLICE_CHARACTERS = 256 * 1024;
15
+ /** A page of the thread list. A row is a few hundred bytes. */
16
+ export const THREAD_PAGE_SIZE = 100;
17
+ /** A page of tool calls, which also stops at `MESSAGE_PAGE_BYTES`. */
18
+ export const TOOL_CALL_PAGE_SIZE = 50;
19
+ /** A page of edited files. A row is a path and two numbers. */
20
+ export const EDIT_PAGE_SIZE = 100;
21
+ /** One message from the person, in characters: about a million tokens, more than models can read at once. Longer text
22
+ * can go in a file in the thread's folder, which the agent reads in parts. */
23
+ export const MAX_USER_MESSAGE_CHARACTERS = 4_000_000;
24
+ /** Answers in one send. They all belong to one model step, which never asks for close to this many actions. */
25
+ export const MAX_APPROVAL_ANSWERS = 1_000;
26
+ /**
27
+ * A long reply is saved as several messages. Each step saves the open one again and the page copies it on every
28
+ * update, so its size, not the run's length, sets the cost of a step. It closes at the first step past this size, so
29
+ * one page usually holds several. Screenshots are counted separately: they are large but are dropped when the turn ends.
30
+ */
31
+ export const REPLY_PART_BYTES = 256 * 1024;
32
+ export const REPLY_PART_IMAGE_BYTES = 4 * 1024 * 1024;
33
+ /** Text is searched and read back in pieces of this many characters, so a very long message can be read in parts. */
34
+ export const RECALL_PIECE_CHARACTERS = 4_000;
35
+ /** One read or search result, about 3,000 tokens: small beside the smallest supported context window. */
36
+ export const RECALL_RESULT_CHARACTERS = 12_000;
37
+ export const RECALL_PAGE_PIECES = 40;
38
+ export const RECALL_SEARCH_RESULTS = 10;
39
+ export const RECALL_EXCERPT_CHARACTERS = 600;
40
+ /** Messages are added to search in batches of this many or this size (but at least one), so other threads keep running
41
+ * while a long one is indexed for the first time. */
42
+ export const INDEX_BATCH_SIZE = 100;
43
+ export const INDEX_BATCH_BYTES = 1024 * 1024;
44
+ /** The person's search waits this long for indexing, then returns what it has and says it isn't finished. */
45
+ export const SEARCH_WAIT_MS = 400;
46
+ /** A page of the person's search: one excerpt for each message. */
47
+ export const MESSAGE_SEARCH_RESULTS = 20;
48
+ export const MAX_SEARCH_CHARACTERS = 500;
49
+ /** A thread's messages are deleted this many at a time (a few milliseconds each), so other threads keep running. */
50
+ export const DELETE_BATCH_SIZE = 500;
51
+ //# sourceMappingURL=private-threads-limits.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"private-threads-limits.js","sourceRoot":"","sources":["../src/private-threads-limits.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,kFAAkF;AAClF,MAAM,CAAC,MAAM,iBAAiB,GAAG,EAAE,CAAA;AACnC;6FAC6F;AAC7F,MAAM,CAAC,MAAM,kBAAkB,GAAG,IAAI,GAAG,IAAI,CAAA;AAC7C,+HAA+H;AAC/H,MAAM,CAAC,MAAM,gBAAgB,GAAG,GAAG,GAAG,IAAI,CAAA;AAC1C,MAAM,CAAC,MAAM,qBAAqB,GAAG,EAAE,GAAG,IAAI,CAAA;AAC9C,2DAA2D;AAC3D,MAAM,CAAC,MAAM,qBAAqB,GAAG,GAAG,GAAG,IAAI,CAAA;AAC/C,+DAA+D;AAC/D,MAAM,CAAC,MAAM,gBAAgB,GAAG,GAAG,CAAA;AACnC,sEAAsE;AACtE,MAAM,CAAC,MAAM,mBAAmB,GAAG,EAAE,CAAA;AACrC,+DAA+D;AAC/D,MAAM,CAAC,MAAM,cAAc,GAAG,GAAG,CAAA;AAEjC;8EAC8E;AAC9E,MAAM,CAAC,MAAM,2BAA2B,GAAG,SAAS,CAAA;AACpD,+GAA+G;AAC/G,MAAM,CAAC,MAAM,oBAAoB,GAAG,KAAK,CAAA;AAEzC;;;;GAIG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,GAAG,GAAG,IAAI,CAAA;AAC1C,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAC,GAAG,IAAI,GAAG,IAAI,CAAA;AAErD,qHAAqH;AACrH,MAAM,CAAC,MAAM,uBAAuB,GAAG,KAAK,CAAA;AAC5C,yGAAyG;AACzG,MAAM,CAAC,MAAM,wBAAwB,GAAG,MAAM,CAAA;AAC9C,MAAM,CAAC,MAAM,kBAAkB,GAAG,EAAE,CAAA;AACpC,MAAM,CAAC,MAAM,qBAAqB,GAAG,EAAE,CAAA;AACvC,MAAM,CAAC,MAAM,yBAAyB,GAAG,GAAG,CAAA;AAC5C;qDACqD;AACrD,MAAM,CAAC,MAAM,gBAAgB,GAAG,GAAG,CAAA;AACnC,MAAM,CAAC,MAAM,iBAAiB,GAAG,IAAI,GAAG,IAAI,CAAA;AAC5C,6GAA6G;AAC7G,MAAM,CAAC,MAAM,cAAc,GAAG,GAAG,CAAA;AACjC,mEAAmE;AACnE,MAAM,CAAC,MAAM,sBAAsB,GAAG,EAAE,CAAA;AACxC,MAAM,CAAC,MAAM,qBAAqB,GAAG,GAAG,CAAA;AACxC,oHAAoH;AACpH,MAAM,CAAC,MAAM,iBAAiB,GAAG,GAAG,CAAA"}
@@ -0,0 +1,77 @@
1
+ import type { PrivateUIMessage } from './private-threads-protocol.js';
2
+ /** What the host reads of a message's tool part; the AI SDK's own type depends on the tools of one turn. */
3
+ export type ToolPart = {
4
+ type: string;
5
+ toolName?: string;
6
+ toolCallId: string;
7
+ state: string;
8
+ input?: unknown;
9
+ output?: unknown;
10
+ errorText?: string;
11
+ approval?: {
12
+ id: string;
13
+ approved?: boolean;
14
+ reason?: string;
15
+ };
16
+ };
17
+ export declare function toolPart(part: unknown): ToolPart | null;
18
+ export declare function toolName(part: ToolPart): string;
19
+ /** JSON without the images tools return, which are counted but never searched, recalled or compared. */
20
+ export declare function jsonWithoutImages(value: unknown, onImage?: (characters: number) => void): string;
21
+ export declare function toolCallRows(message: PrivateUIMessage): {
22
+ part: number;
23
+ path: string | null;
24
+ added: number | null;
25
+ removed: number | null;
26
+ }[];
27
+ /**
28
+ * The lines a file tool changed, counted as tool rows show them (`describeToolCall` in `@overlay/chat-core`, which a
29
+ * published package can't import). `src/features/chat/components/private-threads/host-activity.test.ts` compares both.
30
+ */
31
+ export declare function fileEdit(call: ToolPart): {
32
+ path: string;
33
+ added: number;
34
+ removed: number;
35
+ } | null;
36
+ /** Their results only repeat the thread, so they aren't searched or summarized themselves. */
37
+ export declare const RECALL_TOOLS: {
38
+ readonly search: "search_this_thread";
39
+ readonly read: "read_this_thread";
40
+ };
41
+ /** A message's text in order: what was said, and every tool call with its result. */
42
+ export declare function messageSections(message: PrivateUIMessage): {
43
+ said: boolean;
44
+ text: string;
45
+ }[];
46
+ export declare function messageText(message: PrivateUIMessage): string;
47
+ /** Splits text without losing any of it, between words where it can. */
48
+ export declare function textPieces(text: string, size?: number): string[];
49
+ /**
50
+ * Applies the person's decisions and answers to what the saved reply is waiting for. A question takes only an answer
51
+ * and an approval only a decision, every one needs its own, and nothing else in the reply can change.
52
+ */
53
+ export declare function answerReply(reply: PrivateUIMessage | null, decisions: readonly {
54
+ id: string;
55
+ approved: boolean;
56
+ reason?: string;
57
+ }[], answers?: readonly {
58
+ toolCallId: string;
59
+ answer: string;
60
+ }[]): PrivateUIMessage;
61
+ /** The calls of the questions a reply is waiting for. */
62
+ export declare function pendingQuestions(message: PrivateUIMessage | null): string[];
63
+ /** Whether a reply waits for the person: an approval or a question. */
64
+ export declare function waitsForPerson(message: PrivateUIMessage | null): boolean;
65
+ /** Applies the person's decisions to the actions the saved reply is waiting for. Nothing else in the reply can change. */
66
+ export declare function answerApprovals(reply: PrivateUIMessage | null, answers: readonly {
67
+ id: string;
68
+ approved: boolean;
69
+ reason?: string;
70
+ }[]): PrivateUIMessage;
71
+ export declare function pendingApprovals(message: PrivateUIMessage | null): string[];
72
+ /**
73
+ * Ends the calls a reply left open: stopped, interrupted, or waiting for an approval a newer message passed by. They
74
+ * can't finish any more, and a model refuses a conversation with a call that has no result.
75
+ */
76
+ export declare function closeOpenCalls(message: PrivateUIMessage): PrivateUIMessage;
77
+ //# sourceMappingURL=private-threads-messages.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"private-threads-messages.d.ts","sourceRoot":"","sources":["../src/private-threads-messages.ts"],"names":[],"mappings":"AACA,OAAO,KAA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,204 @@
1
+ import { readRunAnswer, RUN_QUESTION_TOOL, RUN_WAIT_TOOL } from '@layernorm/overlay-agent-bridge-protocol';
2
+ import { RECALL_PIECE_CHARACTERS } from './private-threads-limits.js';
3
+ export function toolPart(part) {
4
+ const value = part;
5
+ const isTool = typeof value?.type === 'string' && (value.type.startsWith('tool-') || value.type === 'dynamic-tool');
6
+ return isTool && typeof value.toolCallId === 'string' ? value : null;
7
+ }
8
+ export function toolName(part) {
9
+ return part.type === 'dynamic-tool' ? part.toolName ?? 'tool' : part.type.slice('tool-'.length);
10
+ }
11
+ const IMAGE_FIELD = 'imageBase64';
12
+ /** JSON without the images tools return, which are counted but never searched, recalled or compared. */
13
+ export function jsonWithoutImages(value, onImage) {
14
+ return JSON.stringify(value, (key, entry) => {
15
+ if (key !== IMAGE_FIELD || typeof entry !== 'string')
16
+ return entry;
17
+ onImage?.(entry.length);
18
+ return undefined;
19
+ }) ?? '';
20
+ }
21
+ /** The calls in a message, and what each finished file edit changed. */
22
+ /** Plans and questions have their own place in the app, so like its tool rows, activity leaves their calls out. */
23
+ function isShownCall(call) {
24
+ const name = toolName(call);
25
+ return !name.startsWith('harness_') || name === RUN_WAIT_TOOL;
26
+ }
27
+ export function toolCallRows(message) {
28
+ return message.parts.flatMap((entry, part) => {
29
+ const call = message.role === 'assistant' ? toolPart(entry) : null;
30
+ if (!call || !isShownCall(call))
31
+ return [];
32
+ const edit = fileEdit(call);
33
+ return [{ part, path: edit?.path ?? null, added: edit?.added ?? null, removed: edit?.removed ?? null }];
34
+ });
35
+ }
36
+ /**
37
+ * The lines a file tool changed, counted as tool rows show them (`describeToolCall` in `@overlay/chat-core`, which a
38
+ * published package can't import). `src/features/chat/components/private-threads/host-activity.test.ts` compares both.
39
+ */
40
+ export function fileEdit(call) {
41
+ const name = toolName(call);
42
+ if ((name !== 'computer_write_file' && name !== 'computer_edit_file') || call.state !== 'output-available')
43
+ return null;
44
+ const input = record(call.input);
45
+ const output = record(call.output);
46
+ const path = typeof input.path === 'string' ? input.path.trim() : '';
47
+ if (!path || output.success === false)
48
+ return null;
49
+ if (typeof output.linesAdded === 'number' && typeof output.linesRemoved === 'number') {
50
+ return { path, added: output.linesAdded, removed: output.linesRemoved };
51
+ }
52
+ if (output.created !== true)
53
+ return null;
54
+ // Missing contents can't be counted, which is not the same as an empty file.
55
+ const { contents } = input;
56
+ if (typeof contents !== 'string')
57
+ return null;
58
+ return { path, added: contents ? contents.split('\n').length - (contents.endsWith('\n') ? 1 : 0) : 0, removed: 0 };
59
+ }
60
+ function record(value) {
61
+ return value && typeof value === 'object' ? value : {};
62
+ }
63
+ /** Their results only repeat the thread, so they aren't searched or summarized themselves. */
64
+ export const RECALL_TOOLS = { search: 'search_this_thread', read: 'read_this_thread' };
65
+ const RECALL_TOOL_NAMES = new Set(Object.values(RECALL_TOOLS));
66
+ /** A message's text in order: what was said, and every tool call with its result. */
67
+ export function messageSections(message) {
68
+ return message.parts.flatMap((part) => {
69
+ if (part.type === 'text')
70
+ return part.text.trim() ? [{ said: true, text: part.text.trim() }] : [];
71
+ const call = toolPart(part);
72
+ if (!call || RECALL_TOOL_NAMES.has(toolName(call)))
73
+ return [];
74
+ const result = call.state === 'output-available' ? jsonWithoutImages(call.output) : call.errorText ?? call.state;
75
+ return [{ said: false, text: `[${toolName(call)}] ${jsonWithoutImages(call.input)}\nResult: ${result}` }];
76
+ });
77
+ }
78
+ export function messageText(message) {
79
+ return messageSections(message).map(({ text }) => text).join('\n\n');
80
+ }
81
+ /** Splits text without losing any of it, between words where it can. */
82
+ export function textPieces(text, size = RECALL_PIECE_CHARACTERS) {
83
+ const pieces = [];
84
+ for (let start = 0; start < text.length;) {
85
+ let end = Math.min(text.length, start + size);
86
+ if (end < text.length) {
87
+ const space = text.lastIndexOf(' ', end);
88
+ if (space > start + size / 2)
89
+ end = space + 1;
90
+ // Never between the halves of one character.
91
+ else if (/[\uD800-\uDBFF]/.test(text[end - 1]))
92
+ end--;
93
+ }
94
+ pieces.push(text.slice(start, end));
95
+ start = end;
96
+ }
97
+ return pieces;
98
+ }
99
+ /**
100
+ * Applies the person's decisions and answers to what the saved reply is waiting for. A question takes only an answer
101
+ * and an approval only a decision, every one needs its own, and nothing else in the reply can change.
102
+ */
103
+ export function answerReply(reply, decisions, answers = []) {
104
+ const questions = new Set(pendingQuestions(reply));
105
+ const said = new Map(answers.map(answer => [answer.toolCallId, answer.answer]));
106
+ const decided = pendingApprovals(reply).length || decisions.length ? answerApprovals(reply, decisions) : reply;
107
+ if (!decided || (decisions.length === 0 && questions.size === 0) || answers.some(answer => !questions.has(answer.toolCallId))) {
108
+ throw new Error('This request is no longer waiting for an answer. Open the thread again to see where it is.');
109
+ }
110
+ if (said.size !== answers.length)
111
+ throw new Error('Answer each question once.');
112
+ if (said.size !== questions.size)
113
+ throw new Error('Answer every question before continuing.');
114
+ return mapToolParts(decided, (call) => {
115
+ if (!isPendingQuestion(call))
116
+ return call;
117
+ const output = readRunAnswer({ answer: said.get(call.toolCallId) });
118
+ if (!output)
119
+ throw new Error('This answer is empty or too long.');
120
+ return { ...call, state: 'output-available', output };
121
+ });
122
+ }
123
+ function isPendingQuestion(call) {
124
+ return call.type === `tool-${RUN_QUESTION_TOOL}` && call.state === 'input-available';
125
+ }
126
+ /** The calls of the questions a reply is waiting for. */
127
+ export function pendingQuestions(message) {
128
+ if (message?.role !== 'assistant')
129
+ return [];
130
+ return message.parts.flatMap((part) => {
131
+ const call = toolPart(part);
132
+ return call && isPendingQuestion(call) ? [call.toolCallId] : [];
133
+ });
134
+ }
135
+ /** Whether a reply waits for the person: an approval or a question. */
136
+ export function waitsForPerson(message) {
137
+ return pendingApprovals(message).length > 0 || pendingQuestions(message).length > 0;
138
+ }
139
+ /** Applies the person's decisions to the actions the saved reply is waiting for. Nothing else in the reply can change. */
140
+ export function answerApprovals(reply, answers) {
141
+ const waiting = new Set(pendingApprovals(reply));
142
+ const given = new Map(answers.map(answer => [answer.id, answer]));
143
+ if (!reply || waiting.size === 0 || answers.some(answer => !waiting.has(answer.id))) {
144
+ throw new Error('This request is no longer waiting for an answer. Open the thread again to see where it is.');
145
+ }
146
+ if (given.size !== answers.length)
147
+ throw new Error('Answer each request once.');
148
+ if (given.size !== waiting.size)
149
+ throw new Error('Answer every request before continuing.');
150
+ return mapToolParts(reply, (call) => {
151
+ const answer = call.state === 'approval-requested' && call.approval ? given.get(call.approval.id) : undefined;
152
+ if (!answer)
153
+ return call;
154
+ const { approved, reason } = answer;
155
+ return { ...call, state: 'approval-responded', approval: { ...call.approval, approved, ...(reason ? { reason } : {}) } };
156
+ });
157
+ }
158
+ export function pendingApprovals(message) {
159
+ if (message?.role !== 'assistant')
160
+ return [];
161
+ return message.parts.flatMap((part) => {
162
+ const call = toolPart(part);
163
+ return call?.state === 'approval-requested' && call.approval ? [call.approval.id] : [];
164
+ });
165
+ }
166
+ const FINISHED = new Set(['output-available', 'output-error', 'output-denied']);
167
+ /**
168
+ * Ends the calls a reply left open: stopped, interrupted, or waiting for an approval a newer message passed by. They
169
+ * can't finish any more, and a model refuses a conversation with a call that has no result.
170
+ */
171
+ export function closeOpenCalls(message) {
172
+ return mapToolParts(message, (call) => {
173
+ if (FINISHED.has(call.state))
174
+ return call;
175
+ if (call.state === 'approval-requested' && call.approval) {
176
+ return { ...call, state: 'output-denied', approval: { ...call.approval, approved: false, reason: 'It was not approved.' } };
177
+ }
178
+ if (call.state === 'approval-responded' && call.approval?.approved === false)
179
+ return { ...call, state: 'output-denied' };
180
+ if (isPendingQuestion(call))
181
+ return { ...call, state: 'output-error', errorText: 'The person did not answer this.' };
182
+ const { output: _output, ...rest } = call;
183
+ void _output;
184
+ return {
185
+ ...rest, state: 'output-error', input: call.input ?? {},
186
+ errorText: call.state === 'input-streaming' ? 'It was stopped before it ran.' : 'It was stopped before it finished, so it may have run in part.',
187
+ };
188
+ });
189
+ }
190
+ function mapToolParts(message, change) {
191
+ let changed = false;
192
+ const parts = message.parts.map((part) => {
193
+ const call = toolPart(part);
194
+ if (!call)
195
+ return part;
196
+ const next = change(call);
197
+ if (next === call)
198
+ return part;
199
+ changed = true;
200
+ return next;
201
+ });
202
+ return changed ? { ...message, parts } : message;
203
+ }
204
+ //# sourceMappingURL=private-threads-messages.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"private-threads-messages.js","sourceRoot":"","sources":["../src/private-threads-messages.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,iBAAiB,EAAE,aAAa,EAAE,MAAM,0CAA0C,CAAA;AAE1G,OAAO,EAAE,uBAAuB,EAAE,MAAM,6BAA6B,CAAA;AAcrE,MAAM,UAAU,QAAQ,CAAC,IAAa;IACpC,MAAM,KAAK,GAAG,IAAgC,CAAA;IAC9C,MAAM,MAAM,GAAG,OAAO,KAAK,EAAE,IAAI,KAAK,QAAQ,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,IAAI,KAAK,CAAC,IAAI,KAAK,cAAc,CAAC,CAAA;IACnH,OAAO,MAAM,IAAI,OAAO,KAAK,CAAC,UAAU,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAiB,CAAC,CAAC,CAAC,IAAI,CAAA;AAClF,CAAC;AAED,MAAM,UAAU,QAAQ,CAAC,IAAc;IACrC,OAAO,IAAI,CAAC,IAAI,KAAK,cAAc,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ,IAAI,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,CAAA;AACjG,CAAC;AAED,MAAM,WAAW,GAAG,aAAa,CAAA;AAEjC,wGAAwG;AACxG,MAAM,UAAU,iBAAiB,CAAC,KAAc,EAAE,OAAsC;IACtF,OAAO,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,CAAC,GAAG,EAAE,KAAc,EAAE,EAAE;QACnD,IAAI,GAAG,KAAK,WAAW,IAAI,OAAO,KAAK,KAAK,QAAQ;YAAE,OAAO,KAAK,CAAA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,OAAO,GAAG,KAAK,CAAA;IACnB,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE;QACvC,MAAM,IAAI,GAAG,QAAQ,CAAC,IAAI,CAAC,CAAA;QAC3B,IAAI,CAAC,IAAI;YAAE,OAAO,IAAI,CAAA;QACtB,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,CAAA;QACzB,IAAI,IAAI,KAAK,IAAI;YAAE,OAAO,IAAI,CAAA;QAC9B,OAAO,GAAG,IAAI,CAAA;QACd,OAAO,IAA8B,CAAA;IACvC,CAAC,CAAC,CAAA;IACF,OAAO,OAAO,CAAC,CAAC,CAAC,EAAE,GAAG,OAAO,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,OAAO,CAAA;AAClD,CAAC"}
@@ -1,4 +1,4 @@
1
- import type { PrivateModelProvider } from './private-threads-protocol.js';
1
+ import type { PrivateModelProvider, PrivateTurnModel } from './private-threads-protocol.js';
2
2
  export type PrivateModelInfo = {
3
3
  id: string;
4
4
  name: string;
@@ -8,4 +8,10 @@ export type PrivateModelInfo = {
8
8
  * a key when the person adds it and to fill the model picker; nothing is cached.
9
9
  */
10
10
  export declare function listProviderModels(provider: PrivateModelProvider, apiKey: string, fetchImpl?: typeof fetch): Promise<PrivateModelInfo[]>;
11
+ /**
12
+ * The model's context window, from whoever runs it: Overlay's catalog (sent with the turn) or the provider's own model
13
+ * list. When neither says, as with OpenAI's API and provider connections, or the list can't be reached in time, it's
14
+ * the cloud's safe default, which only means older messages are summarized sooner.
15
+ */
16
+ export declare function modelContextWindow(model: PrivateTurnModel, fetchImpl?: typeof fetch): Promise<number>;
11
17
  //# sourceMappingURL=private-threads-models.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"private-threads-models.d.ts","sourceRoot":"","sources":["../src/private-threads-models.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,+BAA+B,CAAA;AAEzE,MAAM,MAAM,gBAAgB,GAAG;IAAE,EAAE,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAAA;AAE3D;;;GAGG;AACH,wBAAsB,kBAAkB,CACtC,QAAQ,EAAE,oBAAoB,EAC9B,MAAM,EAAE,MAAM,EACd,SAAS,GAAE,OAAO,KAAa,GAC9B,OAAO,CAAC,gBAAgB,EAAE,CAAC,CAiC7B"}
1
+ {"version":3,"file":"private-threads-models.d.ts","sourceRoot":"","sources":["../src/private-threads-models.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,oBAAoB,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAA;AAE3F,MAAM,MAAM,gBAAgB,GAAG;IAAE,EAAE,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAAA;AAE3D;;;GAGG;AACH,wBAAsB,kBAAkB,CACtC,QAAQ,EAAE,oBAAoB,EAC9B,MAAM,EAAE,MAAM,EACd,SAAS,GAAE,OAAO,KAAa,GAC9B,OAAO,CAAC,gBAAgB,EAAE,CAAC,CAiC7B;AAMD;;;;GAIG;AACH,wBAAsB,kBAAkB,CAAC,KAAK,EAAE,gBAAgB,EAAE,SAAS,GAAE,OAAO,KAAa,GAAG,OAAO,CAAC,MAAM,CAAC,CASlH"}
@@ -1,3 +1,4 @@
1
+ import { FALLBACK_CONTEXT_WINDOW } from '@layernorm/overlay-agent-bridge-protocol';
1
2
  /**
2
3
  * Lists the chat models a key can use, straight from the provider. Used to check
3
4
  * a key when the person adds it and to fill the model picker; nothing is cached.
@@ -38,6 +39,48 @@ export async function listProviderModels(provider, apiKey, fetchImpl = fetch) {
38
39
  }
39
40
  }
40
41
  }
42
+ const CONTEXT_WINDOW_TIMEOUT_MS = 5_000;
43
+ /** Windows the providers reported, while the host runs. Models rarely change theirs. */
44
+ const contextWindows = new Map();
45
+ /**
46
+ * The model's context window, from whoever runs it: Overlay's catalog (sent with the turn) or the provider's own model
47
+ * list. When neither says, as with OpenAI's API and provider connections, or the list can't be reached in time, it's
48
+ * the cloud's safe default, which only means older messages are summarized sooner.
49
+ */
50
+ export async function modelContextWindow(model, fetchImpl = fetch) {
51
+ if (model.provider === 'overlay')
52
+ return model.contextWindow ?? FALLBACK_CONTEXT_WINDOW;
53
+ const key = `${model.provider}/${model.modelId}`;
54
+ const known = contextWindows.get(key);
55
+ if (known)
56
+ return known;
57
+ const reported = await reportedContextWindow(model, fetchImpl).catch((_error) => undefined);
58
+ if (typeof reported !== 'number' || !Number.isSafeInteger(reported) || reported <= 0)
59
+ return FALLBACK_CONTEXT_WINDOW;
60
+ contextWindows.set(key, reported);
61
+ return reported;
62
+ }
63
+ async function reportedContextWindow({ provider, modelId, apiKey }, fetchImpl) {
64
+ const get = async (url, headers) => {
65
+ const response = await fetchImpl(url, { headers, redirect: 'error', signal: AbortSignal.timeout(CONTEXT_WINDOW_TIMEOUT_MS) });
66
+ return response.ok ? await response.json() : {};
67
+ };
68
+ switch (provider) {
69
+ case 'anthropic':
70
+ return (await get(`https://api.anthropic.com/v1/models/${encodeURIComponent(modelId)}`, { 'x-api-key': apiKey, 'anthropic-version': '2023-06-01' })).max_input_tokens;
71
+ case 'google':
72
+ return (await get(`https://generativelanguage.googleapis.com/v1beta/models/${encodeURIComponent(modelId)}`, { 'x-goog-api-key': apiKey })).inputTokenLimit;
73
+ case 'openrouter': {
74
+ const body = await get('https://openrouter.ai/api/v1/models', { authorization: `Bearer ${apiKey}` });
75
+ const model = rows(body.data).find(row => row.id === modelId);
76
+ const provided = model?.top_provider?.context_length;
77
+ // The provider OpenRouter uses first can allow less than the model does.
78
+ return typeof provided === 'number' ? Math.min(provided, Number(model?.context_length)) : model?.context_length;
79
+ }
80
+ case 'openai':
81
+ return undefined;
82
+ }
83
+ }
41
84
  function rows(value) {
42
85
  return Array.isArray(value) ? value.filter((row) => Boolean(row && typeof row === 'object')) : [];
43
86
  }
@@ -1 +1 @@
1
- {"version":3,"file":"private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AAO,QAAQ,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,QAAQ,EAAE,MAAM,CAAC,KAAK,EAAE,cAAc,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,EAAE,cAAc,CAAA;QACjH,CAAC;QACD,KAAK,QAAQ;YACX,OAAO,SAAS,CAAA;IACpB,CAAC;AACH,CAAC;AAED,SAAS,IAAI,CAAC,KAAc;IAC1B,OAAO,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,GAAG,EAAkC,EAAE,CAAC,OAAO,CAAC,GAAG,IAAI,OAAO,GAAG,KAAK,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAA;AACnI,CAAC"}
@@ -7,6 +7,7 @@ import type { LanguageModelV4 } from '@ai-sdk/provider';
7
7
  export type OverlayRelayAccess = {
8
8
  url: string;
9
9
  token: string;
10
+ expiresAt?: number;
10
11
  };
11
12
  export declare class OverlayRelayError extends Error {
12
13
  readonly status: number;
@@ -1 +1 @@
1
- {"version":3,"file":"private-threads-overlay-model.d.ts","sourceRoot":"","sources":["../src/private-threads-overlay-model.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,eAAe,EAIhB,MAAM,kBAAkB,CAAA;AAQzB;;;;GAIG;AACH,MAAM,MAAM,kBAAkB,GAAG;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAA;AAE/D,qBAAa,iBAAkB,SAAQ,KAAK;IACb,QAAQ,CAAC,MAAM,EAAE,MAAM;IAAE,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM;gBAAhE,OAAO,EAAE,MAAM,EAAW,MAAM,EAAE,MAAM,EAAW,IAAI,CAAC,EAAE,MAAM,YAAA;CAI7E;AAED,wBAAgB,uBAAuB,CACrC,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,kBAAkB,EAC1B,SAAS,GAAE,OAAO,KAAa,GAC9B,eAAe,CAgCjB"}
1
+ {"version":3,"file":"private-threads-overlay-model.d.ts","sourceRoot":"","sources":["../src/private-threads-overlay-model.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,eAAe,EAIhB,MAAM,kBAAkB,CAAA;AAQzB;;;;GAIG;AACH,MAAM,MAAM,kBAAkB,GAAG;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,CAAA;CAAE,CAAA;AAEnF,qBAAa,iBAAkB,SAAQ,KAAK;IACb,QAAQ,CAAC,MAAM,EAAE,MAAM;IAAE,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM;gBAAhE,OAAO,EAAE,MAAM,EAAW,MAAM,EAAE,MAAM,EAAW,IAAI,CAAC,EAAE,MAAM,YAAA;CAI7E;AAED,wBAAgB,uBAAuB,CACrC,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,kBAAkB,EAC1B,SAAS,GAAE,OAAO,KAAa,GAC9B,eAAe,CAgCjB"}
@@ -15,10 +15,12 @@ export type OverlayToolsConnection = {
15
15
  export type OverlayToolsAccess = {
16
16
  url: string;
17
17
  token: string;
18
+ expiresAt?: number;
18
19
  };
19
20
  /** Never fails the turn: without Overlay's tools the thread still has this computer's. */
20
21
  export declare function connectOverlayTools(access: OverlayToolsAccess | undefined, options: {
21
22
  signal: AbortSignal;
23
+ fetch: typeof fetch;
22
24
  onUnavailable?: (reason: string) => void;
23
25
  connect?: typeof createMCPClient;
24
26
  }): Promise<OverlayToolsConnection | null>;
@@ -1 +1 @@
1
- {"version":3,"file":"private-threads-overlay-tools.d.ts","sourceRoot":"","sources":["../src/private-threads-overlay-tools.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAkB,MAAM,aAAa,CAAA;AAC7D,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,IAAI,CAAA;AAEjC;;;;;GAKG;AACH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1F,wBAAsB,mBAAmB,CACvC,MAAM,EAAE,kBAAkB,GAAG,SAAS,EACtC,OAAO,EAAE;IAAE,MAAM,EAAE,WAAW,CAAC;IAAC,KAAK,EAAE,OAAO,KAAK,CAAC;IAAC,aAAa,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC;IAAC,OAAO,CAAC,EAAE,OAAO,eAAe,CAAA;CAAE,GAChI,OAAO,CAAC,sBAAsB,GAAG,IAAI,CAAC,CA6BxC;AAWD,gFAAgF;AAChF,wBAAgB,gBAAgB,CAAC,aAAa,EAAE,OAAO,EAAE,OAAO,EAAE,sBAAsB,GAAG,IAAI,GAAG,OAAO,CAOxG"}
@@ -9,7 +9,8 @@ export async function connectOverlayTools(access, options) {
9
9
  const signal = AbortSignal.any([options.signal, AbortSignal.timeout(CONNECT_TIMEOUT_MS)]);
10
10
  try {
11
11
  const connecting = (options.connect ?? createMCPClient)({
12
- transport: { type: 'http', url: access.url, headers: { Authorization: `Bearer ${access.token}` }, redirect: 'error' },
12
+ // `fetch` adds the turn's token, which can be renewed while the connection is open.
13
+ transport: { type: 'http', url: access.url, fetch: options.fetch, redirect: 'error' },
13
14
  // Overlay's server is stateless and answers `initialize` directly.
14
15
  protocolVersionDiscovery: false,
15
16
  clientName: 'overlay-private-thread',
@@ -1 +1 @@
1
- {"version":3,"file":"private-threads-overlay-tools.js","sourceRoot":"","sources":["../src/private-threads-overlay-tools.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAkB,MAAM,aAAa,CAAA;AAkB7D,MAAM,kBAAkB,GAAG,MAAM,CAAA;AAEjC,0FAA0F;AAC1F,MAAM,CAAC,KAAK,UAAU,mBAAmB,CACvC,MAAsC,EACtC,OAA4G;IAE5G,IAAI,CAAC,MAAM;QAAE,OAAO,IAAI,CAAA;IACxB,IAAI,MAAM,GAAqB,IAAI,CAAA;IACnC,8FAA8F;IAC9F,MAAM,MAAM,GAAG,WAAW,CAAC,GAAG,CAAC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AAA;IACtF,CAAC,CAAC,CAAA;AACJ,CAAC;AAED,gFAAgF;AAChF,MAAM,UAAU,gBAAgB,CAAC,aAAsB,EAAE,OAAsC;IAC7F,IAAI,CAAC,OAAO;QAAE,OAAO,aAAa,CAAA;IAClC,MAAM,MAAM,GAAY,EAAE,CAAA;IAC1B,KAAK,MAAM,CAAC,IAAI,EAAE,UAAU,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QAC/D,IAAI,CAAC,CAAC,IAAI,IAAI,aAAa,CAAC;YAAE,MAAM,CAAC,IAAI,CAAC,GAAG,UAAU,CAAA;IACzD,CAAC;IACD,OAAO,EAAE,GAAG,MAAM,EAAE,GAAG,aAAa,EAAE,CAAA;AACxC,CAAC"}
@@ -0,0 +1,14 @@
1
+ import type { PrivateMessagePieces, PrivatePartSlice, PrivateShortened, PrivateUIMessage } from './private-threads-protocol.js';
2
+ /** A large message as a page first shows it: the start of what the person wrote, or the end of a reply, with its answer. */
3
+ export declare function shortenMessage(message: PrivateUIMessage, revision: number): {
4
+ message: PrivateUIMessage;
5
+ shortened: PrivateShortened;
6
+ };
7
+ export declare function messagePieces(message: PrivateUIMessage, from: {
8
+ before: string;
9
+ } | {
10
+ after: string;
11
+ }): PrivateMessagePieces;
12
+ /** Part of a large part's JSON. The page puts the slices together before it reads them. */
13
+ export declare function partSlice(message: PrivateUIMessage, part: number, from: number): PrivatePartSlice;
14
+ //# sourceMappingURL=private-threads-pieces.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"private-threads-pieces.d.ts","sourceRoot":"","sources":["../src/private-threads-pieces.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAuB,oBAAoB,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAA;AA4DpJ,4HAA4H;AAC5H,wBAAgB,cAAc,CAAC,OAAO,EAAE,gBAAgB,EAAE,QAAQ,EAAE,MAAM,GAAG;IAAE,OAAO,EAAE,gBAAgB,CAAC;IAAC,SAAS,EAAE,gBAAgB,CAAA;CAAE,CAYtI;AAED,wBAAgB,aAAa,CAAC,OAAO,EAAE,gBAAgB,EAAE,IAAI,EAAE;IAAE,MAAM,EAAE,MAAM,CAAA;CAAE,GAAG;IAAE,KAAK,EAAE,MAAM,CAAA;CAAE,GAAG,oBAAoB,CAO3H;AAED,2FAA2F;AAC3F,wBAAgB,SAAS,CAAC,OAAO,EAAE,gBAAgB,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,gBAAgB,CAOjG"}