@stina/extension-api 1.0.0 → 1.3.1
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/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/runtime.cjs +10 -2
- package/dist/runtime.cjs.map +1 -1
- package/dist/runtime.d.cts +2 -2
- package/dist/runtime.d.ts +2 -2
- package/dist/runtime.js +10 -2
- package/dist/runtime.js.map +1 -1
- package/dist/schemas/index.cjs +6 -0
- package/dist/schemas/index.cjs.map +1 -1
- package/dist/schemas/index.d.cts +12 -1
- package/dist/schemas/index.d.ts +12 -1
- package/dist/schemas/index.js +5 -0
- package/dist/schemas/index.js.map +1 -1
- package/dist/{types.tools-CQrbET-n.d.cts → types.tools-C0GqXQlu.d.cts} +39 -1
- package/dist/{types.tools-CQrbET-n.d.ts → types.tools-C0GqXQlu.d.ts} +39 -1
- package/package.json +1 -1
- package/src/index.ts +2 -0
- package/src/runtime.ts +29 -3
- package/src/schemas/components.schema.ts +9 -0
- package/src/schemas/index.ts +2 -0
- package/src/types.components.ts +13 -0
- package/src/types.tools.ts +28 -0
- package/src/types.ts +1 -1
|
@@ -171,6 +171,18 @@ interface LabelProps extends ExtensionComponentData {
|
|
|
171
171
|
component: 'Label';
|
|
172
172
|
text: string;
|
|
173
173
|
}
|
|
174
|
+
/**
|
|
175
|
+
* The extension API properties for the Clock component.
|
|
176
|
+
*
|
|
177
|
+
* The odd one out among the display components: it takes no facts, because the
|
|
178
|
+
* fact it shows is what time it is, and that is not something an action can
|
|
179
|
+
* hand over once. It reads the clock and the timezone from the host and keeps
|
|
180
|
+
* itself current, so a card carrying one stays right while the window is left
|
|
181
|
+
* open.
|
|
182
|
+
*/
|
|
183
|
+
interface ClockProps extends ExtensionComponentData {
|
|
184
|
+
component: 'Clock';
|
|
185
|
+
}
|
|
174
186
|
/** The extension API properties for the paragraph component. */
|
|
175
187
|
interface ParagraphProps extends ExtensionComponentData {
|
|
176
188
|
component: 'Paragraph';
|
|
@@ -2340,6 +2352,32 @@ interface ToolResult {
|
|
|
2340
2352
|
* would send her after a component that does not exist.
|
|
2341
2353
|
*/
|
|
2342
2354
|
cardSuggestion?: string;
|
|
2355
|
+
/**
|
|
2356
|
+
* Pictures to show the user, rendered in the conversation where the tool ran.
|
|
2357
|
+
*
|
|
2358
|
+
* For what a card cannot hold and the model cannot reproduce: a generated
|
|
2359
|
+
* image, a rendered document, a photo fetched on the user's behalf. Like
|
|
2360
|
+
* {@link ToolResult.display}, this is for the user only — it is lifted out
|
|
2361
|
+
* before the result reaches the model, which would have nothing to do with
|
|
2362
|
+
* the bytes but spend tokens on them. Say in `data` that a picture was shown,
|
|
2363
|
+
* so she can talk about it without describing it back.
|
|
2364
|
+
*
|
|
2365
|
+
* The host stores each one as an attachment of the conversation, the same way
|
|
2366
|
+
* a picture the user sends is stored, so it is served to every client and can
|
|
2367
|
+
* be saved or shared from there. JPEG and PNG only, and 20 MB at most, since
|
|
2368
|
+
* those are the limits the attachment store already holds users to. One that
|
|
2369
|
+
* fails them is dropped with a warning rather than half-shown.
|
|
2370
|
+
*/
|
|
2371
|
+
attachments?: ToolAttachment[];
|
|
2372
|
+
}
|
|
2373
|
+
/**
|
|
2374
|
+
* One picture a tool wants shown. See {@link ToolResult.attachments}.
|
|
2375
|
+
*/
|
|
2376
|
+
interface ToolAttachment {
|
|
2377
|
+
/** The image bytes, base64 encoded. The format is read from the bytes. */
|
|
2378
|
+
data: string;
|
|
2379
|
+
/** A file name to offer when the user saves it, e.g. `friday.png`. */
|
|
2380
|
+
name?: string;
|
|
2343
2381
|
}
|
|
2344
2382
|
/**
|
|
2345
2383
|
* Action implementation for UI interactions.
|
|
@@ -2367,4 +2405,4 @@ interface ActionResult {
|
|
|
2367
2405
|
error?: string;
|
|
2368
2406
|
}
|
|
2369
2407
|
|
|
2370
|
-
export { type BackgroundTaskContext as $, type ActionResult as A, type ActionsAPI as B, type ChatMessage as C, type Disposable as D, type ExtensionContributions as E, type EventsAPI as F, type GetModelsOptions as G, type HugeIconName as H, type SchedulerAPI as I, type SchedulerJobRequest as J, type SchedulerSchedule as K, type LocalizedString as L, type ModelInfo as M, type NetworkAPI as N, type UserProfile as O, type PanelDefinition as P, type ChatAPI as Q, type ChatInstructionMessage as R, type SchedulerFirePayload as S, type ToolResult as T, type UserAPI as U, type VoiceSessionOptions as V, type ConversationPresentation as W, type LogAPI as X, type BackgroundWorkersAPI as Y, type BackgroundTaskConfig as Z, type BackgroundTaskCallback as _, type ChatOptions as a, type
|
|
2408
|
+
export { type BackgroundTaskContext as $, type ActionResult as A, type ActionsAPI as B, type ChatMessage as C, type Disposable as D, type ExtensionContributions as E, type EventsAPI as F, type GetModelsOptions as G, type HugeIconName as H, type SchedulerAPI as I, type SchedulerJobRequest as J, type SchedulerSchedule as K, type LocalizedString as L, type ModelInfo as M, type NetworkAPI as N, type UserProfile as O, type PanelDefinition as P, type ChatAPI as Q, type ChatInstructionMessage as R, type SchedulerFirePayload as S, type ToolResult as T, type UserAPI as U, type VoiceSessionOptions as V, type ConversationPresentation as W, type LogAPI as X, type BackgroundWorkersAPI as Y, type BackgroundTaskConfig as Z, type BackgroundTaskCallback as _, type ChatOptions as a, type WeatherForecastProps as a$, type BackgroundTaskHealth as a0, type BackgroundRestartPolicy as a1, type Query as a2, type QueryOptions as a3, type StorageAPI as a4, type SecretsAPI as a5, type StorageCollectionConfig as a6, type StorageContributions as a7, type AIProvider as a8, type ModelCapabilities as a9, type SelectProps as aA, type IconPickerProps as aB, type VerticalStackProps as aC, type HorizontalStackProps as aD, type GridProps as aE, type DividerProps as aF, type IconProps as aG, type IconButtonType as aH, type IconButtonProps as aI, type PanelAction as aJ, type PanelProps as aK, type ToggleProps as aL, type CollapsibleProps as aM, type FrameVariant as aN, type FrameProps as aO, type ListProps as aP, type PillVariant as aQ, type PillProps as aR, type CheckboxProps as aS, type MarkdownProps as aT, type TextPreviewProps as aU, type ModalProps as aV, type ConditionalGroupProps as aW, type WeatherCondition as aX, type WeatherWind as aY, type WeatherNowProps as aZ, type WeatherForecastStep as a_, type ChatImage as aa, type ToolCall as ab, type VoiceTransportRequest as ac, type Tool as ad, type ToolAttachment as ae, type Action as af, type ExtensionModule as ag, type AllowedCSSProperty as ah, type ExtensionComponentStyle as ai, type ExtensionComponentData as aj, type ExtensionComponentIterator as ak, type ExtensionComponentChildren as al, type ExtensionActionCall as am, type ExtensionActionRef as an, type ExtensionDataSource as ao, type ExtensionPanelDefinition as ap, type HeaderProps as aq, type LabelProps as ar, type ClockProps as as, type ParagraphProps as at, type ButtonProps as au, type TextInputProps as av, type PasswordInputProps as aw, type NumberInputProps as ax, type TextAreaProps as ay, type DateTimeInputProps as az, type StreamEvent as b, type ChartKind as b0, type ChartSeries as b1, type ChartProps as b2, type StatTrend as b3, type StatTileProps as b4, type ProgressShape as b5, type ProgressColor as b6, type ProgressBarProps as b7, type KeyValueRow as b8, type KeyValueListProps as b9, type TimelineVariant as ba, type TimelineEntry as bb, type TimelineProps as bc, type NoteVariant as bd, type NoteProps as be, type CalendarEventStatus as bf, type CalendarEventProps as bg, type ExecutionContext as bh, type VoiceSessionDescriptor as c, type ToolSettingsViewDefinition as d, type ToolSettingsView as e, type ToolSettingsListView as f, type ToolSettingsListMapping as g, type ToolSettingsComponentView as h, type ToolSettingsActionDataSource as i, type StatusCardDefinition as j, type PanelView as k, type PanelComponentView as l, type PanelActionDataSource as m, type PanelUnknownView as n, type ProviderDefinition as o, type ProviderConfigView as p, type PromptContribution as q, resolveLocalizedString as r, type PromptSection as s, type ToolDefinition as t, type ToolConfirmationConfig as u, type CommandDefinition as v, type ExtensionContext as w, type SettingsAPI as x, type ProvidersAPI as y, type ToolsAPI as z };
|
|
@@ -171,6 +171,18 @@ interface LabelProps extends ExtensionComponentData {
|
|
|
171
171
|
component: 'Label';
|
|
172
172
|
text: string;
|
|
173
173
|
}
|
|
174
|
+
/**
|
|
175
|
+
* The extension API properties for the Clock component.
|
|
176
|
+
*
|
|
177
|
+
* The odd one out among the display components: it takes no facts, because the
|
|
178
|
+
* fact it shows is what time it is, and that is not something an action can
|
|
179
|
+
* hand over once. It reads the clock and the timezone from the host and keeps
|
|
180
|
+
* itself current, so a card carrying one stays right while the window is left
|
|
181
|
+
* open.
|
|
182
|
+
*/
|
|
183
|
+
interface ClockProps extends ExtensionComponentData {
|
|
184
|
+
component: 'Clock';
|
|
185
|
+
}
|
|
174
186
|
/** The extension API properties for the paragraph component. */
|
|
175
187
|
interface ParagraphProps extends ExtensionComponentData {
|
|
176
188
|
component: 'Paragraph';
|
|
@@ -2340,6 +2352,32 @@ interface ToolResult {
|
|
|
2340
2352
|
* would send her after a component that does not exist.
|
|
2341
2353
|
*/
|
|
2342
2354
|
cardSuggestion?: string;
|
|
2355
|
+
/**
|
|
2356
|
+
* Pictures to show the user, rendered in the conversation where the tool ran.
|
|
2357
|
+
*
|
|
2358
|
+
* For what a card cannot hold and the model cannot reproduce: a generated
|
|
2359
|
+
* image, a rendered document, a photo fetched on the user's behalf. Like
|
|
2360
|
+
* {@link ToolResult.display}, this is for the user only — it is lifted out
|
|
2361
|
+
* before the result reaches the model, which would have nothing to do with
|
|
2362
|
+
* the bytes but spend tokens on them. Say in `data` that a picture was shown,
|
|
2363
|
+
* so she can talk about it without describing it back.
|
|
2364
|
+
*
|
|
2365
|
+
* The host stores each one as an attachment of the conversation, the same way
|
|
2366
|
+
* a picture the user sends is stored, so it is served to every client and can
|
|
2367
|
+
* be saved or shared from there. JPEG and PNG only, and 20 MB at most, since
|
|
2368
|
+
* those are the limits the attachment store already holds users to. One that
|
|
2369
|
+
* fails them is dropped with a warning rather than half-shown.
|
|
2370
|
+
*/
|
|
2371
|
+
attachments?: ToolAttachment[];
|
|
2372
|
+
}
|
|
2373
|
+
/**
|
|
2374
|
+
* One picture a tool wants shown. See {@link ToolResult.attachments}.
|
|
2375
|
+
*/
|
|
2376
|
+
interface ToolAttachment {
|
|
2377
|
+
/** The image bytes, base64 encoded. The format is read from the bytes. */
|
|
2378
|
+
data: string;
|
|
2379
|
+
/** A file name to offer when the user saves it, e.g. `friday.png`. */
|
|
2380
|
+
name?: string;
|
|
2343
2381
|
}
|
|
2344
2382
|
/**
|
|
2345
2383
|
* Action implementation for UI interactions.
|
|
@@ -2367,4 +2405,4 @@ interface ActionResult {
|
|
|
2367
2405
|
error?: string;
|
|
2368
2406
|
}
|
|
2369
2407
|
|
|
2370
|
-
export { type BackgroundTaskContext as $, type ActionResult as A, type ActionsAPI as B, type ChatMessage as C, type Disposable as D, type ExtensionContributions as E, type EventsAPI as F, type GetModelsOptions as G, type HugeIconName as H, type SchedulerAPI as I, type SchedulerJobRequest as J, type SchedulerSchedule as K, type LocalizedString as L, type ModelInfo as M, type NetworkAPI as N, type UserProfile as O, type PanelDefinition as P, type ChatAPI as Q, type ChatInstructionMessage as R, type SchedulerFirePayload as S, type ToolResult as T, type UserAPI as U, type VoiceSessionOptions as V, type ConversationPresentation as W, type LogAPI as X, type BackgroundWorkersAPI as Y, type BackgroundTaskConfig as Z, type BackgroundTaskCallback as _, type ChatOptions as a, type
|
|
2408
|
+
export { type BackgroundTaskContext as $, type ActionResult as A, type ActionsAPI as B, type ChatMessage as C, type Disposable as D, type ExtensionContributions as E, type EventsAPI as F, type GetModelsOptions as G, type HugeIconName as H, type SchedulerAPI as I, type SchedulerJobRequest as J, type SchedulerSchedule as K, type LocalizedString as L, type ModelInfo as M, type NetworkAPI as N, type UserProfile as O, type PanelDefinition as P, type ChatAPI as Q, type ChatInstructionMessage as R, type SchedulerFirePayload as S, type ToolResult as T, type UserAPI as U, type VoiceSessionOptions as V, type ConversationPresentation as W, type LogAPI as X, type BackgroundWorkersAPI as Y, type BackgroundTaskConfig as Z, type BackgroundTaskCallback as _, type ChatOptions as a, type WeatherForecastProps as a$, type BackgroundTaskHealth as a0, type BackgroundRestartPolicy as a1, type Query as a2, type QueryOptions as a3, type StorageAPI as a4, type SecretsAPI as a5, type StorageCollectionConfig as a6, type StorageContributions as a7, type AIProvider as a8, type ModelCapabilities as a9, type SelectProps as aA, type IconPickerProps as aB, type VerticalStackProps as aC, type HorizontalStackProps as aD, type GridProps as aE, type DividerProps as aF, type IconProps as aG, type IconButtonType as aH, type IconButtonProps as aI, type PanelAction as aJ, type PanelProps as aK, type ToggleProps as aL, type CollapsibleProps as aM, type FrameVariant as aN, type FrameProps as aO, type ListProps as aP, type PillVariant as aQ, type PillProps as aR, type CheckboxProps as aS, type MarkdownProps as aT, type TextPreviewProps as aU, type ModalProps as aV, type ConditionalGroupProps as aW, type WeatherCondition as aX, type WeatherWind as aY, type WeatherNowProps as aZ, type WeatherForecastStep as a_, type ChatImage as aa, type ToolCall as ab, type VoiceTransportRequest as ac, type Tool as ad, type ToolAttachment as ae, type Action as af, type ExtensionModule as ag, type AllowedCSSProperty as ah, type ExtensionComponentStyle as ai, type ExtensionComponentData as aj, type ExtensionComponentIterator as ak, type ExtensionComponentChildren as al, type ExtensionActionCall as am, type ExtensionActionRef as an, type ExtensionDataSource as ao, type ExtensionPanelDefinition as ap, type HeaderProps as aq, type LabelProps as ar, type ClockProps as as, type ParagraphProps as at, type ButtonProps as au, type TextInputProps as av, type PasswordInputProps as aw, type NumberInputProps as ax, type TextAreaProps as ay, type DateTimeInputProps as az, type StreamEvent as b, type ChartKind as b0, type ChartSeries as b1, type ChartProps as b2, type StatTrend as b3, type StatTileProps as b4, type ProgressShape as b5, type ProgressColor as b6, type ProgressBarProps as b7, type KeyValueRow as b8, type KeyValueListProps as b9, type TimelineVariant as ba, type TimelineEntry as bb, type TimelineProps as bc, type NoteVariant as bd, type NoteProps as be, type CalendarEventStatus as bf, type CalendarEventProps as bg, type ExecutionContext as bh, type VoiceSessionDescriptor as c, type ToolSettingsViewDefinition as d, type ToolSettingsView as e, type ToolSettingsListView as f, type ToolSettingsListMapping as g, type ToolSettingsComponentView as h, type ToolSettingsActionDataSource as i, type StatusCardDefinition as j, type PanelView as k, type PanelComponentView as l, type PanelActionDataSource as m, type PanelUnknownView as n, type ProviderDefinition as o, type ProviderConfigView as p, type PromptContribution as q, resolveLocalizedString as r, type PromptSection as s, type ToolDefinition as t, type ToolConfirmationConfig as u, type CommandDefinition as v, type ExtensionContext as w, type SettingsAPI as x, type ProvidersAPI as y, type ToolsAPI as z };
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -100,6 +100,7 @@ export type {
|
|
|
100
100
|
// Tools
|
|
101
101
|
Tool,
|
|
102
102
|
ToolResult,
|
|
103
|
+
ToolAttachment,
|
|
103
104
|
|
|
104
105
|
// Actions
|
|
105
106
|
Action,
|
|
@@ -163,6 +164,7 @@ export type {
|
|
|
163
164
|
// Component Props
|
|
164
165
|
HeaderProps,
|
|
165
166
|
LabelProps,
|
|
167
|
+
ClockProps,
|
|
166
168
|
ParagraphProps,
|
|
167
169
|
ButtonProps,
|
|
168
170
|
TextInputProps,
|
package/src/runtime.ts
CHANGED
|
@@ -648,11 +648,36 @@ function buildContext(
|
|
|
648
648
|
if (permissions.some((p) => p.startsWith('network:'))) {
|
|
649
649
|
const networkApi: NetworkAPI = {
|
|
650
650
|
async fetch(url: string, options?: RequestInit): Promise<Response> {
|
|
651
|
-
const result = await sendRequest<{
|
|
652
|
-
|
|
651
|
+
const result = await sendRequest<{
|
|
652
|
+
status: number
|
|
653
|
+
statusText: string
|
|
654
|
+
headers: Record<string, string>
|
|
655
|
+
body: string
|
|
656
|
+
bodyEncoding?: 'base64'
|
|
657
|
+
}>('network.fetch', { url, options })
|
|
658
|
+
// The host sends a body that is not text as base64, since the bridge is
|
|
659
|
+
// JSON. Turn it back into bytes here so `response.arrayBuffer()` gives
|
|
660
|
+
// the extension what the server sent and `text()` still works.
|
|
661
|
+
const isBase64 = result.bodyEncoding === 'base64'
|
|
662
|
+
const body = isBase64
|
|
663
|
+
? Uint8Array.from(atob(result.body), (char) => char.charCodeAt(0))
|
|
664
|
+
: result.body
|
|
665
|
+
|
|
666
|
+
// The host says the same thing in a header, for extensions whose bundled
|
|
667
|
+
// copy of this runtime is older than the encoding and would hand the
|
|
668
|
+
// base64 on as text. This runtime just decoded it, so the header would be
|
|
669
|
+
// a lie by the time the extension reads it: take it back out.
|
|
670
|
+
const headers = { ...result.headers }
|
|
671
|
+
if (isBase64) {
|
|
672
|
+
for (const name of Object.keys(headers)) {
|
|
673
|
+
if (name.toLowerCase() === 'x-stina-body-encoding') delete headers[name]
|
|
674
|
+
}
|
|
675
|
+
}
|
|
676
|
+
|
|
677
|
+
return new Response(body, {
|
|
653
678
|
status: result.status,
|
|
654
679
|
statusText: result.statusText,
|
|
655
|
-
headers
|
|
680
|
+
headers,
|
|
656
681
|
})
|
|
657
682
|
},
|
|
658
683
|
|
|
@@ -996,6 +1021,7 @@ export type {
|
|
|
996
1021
|
Tool,
|
|
997
1022
|
ToolDefinition,
|
|
998
1023
|
ToolResult,
|
|
1024
|
+
ToolAttachment,
|
|
999
1025
|
ToolCall,
|
|
1000
1026
|
Action,
|
|
1001
1027
|
ActionResult,
|
|
@@ -197,6 +197,14 @@ export const LabelPropsSchema = z
|
|
|
197
197
|
.passthrough()
|
|
198
198
|
.describe('Label component')
|
|
199
199
|
|
|
200
|
+
export const ClockPropsSchema = z
|
|
201
|
+
.object({
|
|
202
|
+
component: z.literal('Clock'),
|
|
203
|
+
style: ExtensionComponentStyleSchema.optional(),
|
|
204
|
+
})
|
|
205
|
+
.passthrough()
|
|
206
|
+
.describe('Clock component: the current date and time where the user is')
|
|
207
|
+
|
|
200
208
|
export const ParagraphPropsSchema = z
|
|
201
209
|
.object({
|
|
202
210
|
component: z.literal('Paragraph'),
|
|
@@ -820,6 +828,7 @@ export type ChartSeries = z.infer<typeof ChartSeriesSchema>
|
|
|
820
828
|
export type ChartProps = z.infer<typeof ChartPropsSchema>
|
|
821
829
|
export type StatTrend = z.infer<typeof StatTrendSchema>
|
|
822
830
|
export type StatTileProps = z.infer<typeof StatTilePropsSchema>
|
|
831
|
+
export type ClockProps = z.infer<typeof ClockPropsSchema>
|
|
823
832
|
export type ProgressShape = z.infer<typeof ProgressShapeSchema>
|
|
824
833
|
export type ProgressColor = z.infer<typeof ProgressColorSchema>
|
|
825
834
|
export type ProgressBarProps = z.infer<typeof ProgressBarPropsSchema>
|
package/src/schemas/index.ts
CHANGED
|
@@ -96,6 +96,7 @@ export {
|
|
|
96
96
|
PanelActionSchema,
|
|
97
97
|
HeaderPropsSchema,
|
|
98
98
|
LabelPropsSchema,
|
|
99
|
+
ClockPropsSchema,
|
|
99
100
|
ParagraphPropsSchema,
|
|
100
101
|
ButtonPropsSchema,
|
|
101
102
|
TextInputPropsSchema,
|
|
@@ -155,6 +156,7 @@ export {
|
|
|
155
156
|
type PanelAction,
|
|
156
157
|
type HeaderProps,
|
|
157
158
|
type LabelProps,
|
|
159
|
+
type ClockProps,
|
|
158
160
|
type ParagraphProps,
|
|
159
161
|
type ButtonProps,
|
|
160
162
|
type TextInputProps,
|
package/src/types.components.ts
CHANGED
|
@@ -251,6 +251,19 @@ export interface LabelProps extends ExtensionComponentData {
|
|
|
251
251
|
text: string
|
|
252
252
|
}
|
|
253
253
|
|
|
254
|
+
/**
|
|
255
|
+
* The extension API properties for the Clock component.
|
|
256
|
+
*
|
|
257
|
+
* The odd one out among the display components: it takes no facts, because the
|
|
258
|
+
* fact it shows is what time it is, and that is not something an action can
|
|
259
|
+
* hand over once. It reads the clock and the timezone from the host and keeps
|
|
260
|
+
* itself current, so a card carrying one stays right while the window is left
|
|
261
|
+
* open.
|
|
262
|
+
*/
|
|
263
|
+
export interface ClockProps extends ExtensionComponentData {
|
|
264
|
+
component: 'Clock'
|
|
265
|
+
}
|
|
266
|
+
|
|
254
267
|
/** The extension API properties for the paragraph component. */
|
|
255
268
|
export interface ParagraphProps extends ExtensionComponentData {
|
|
256
269
|
component: 'Paragraph'
|
package/src/types.tools.ts
CHANGED
|
@@ -73,6 +73,34 @@ export interface ToolResult {
|
|
|
73
73
|
* would send her after a component that does not exist.
|
|
74
74
|
*/
|
|
75
75
|
cardSuggestion?: string
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Pictures to show the user, rendered in the conversation where the tool ran.
|
|
79
|
+
*
|
|
80
|
+
* For what a card cannot hold and the model cannot reproduce: a generated
|
|
81
|
+
* image, a rendered document, a photo fetched on the user's behalf. Like
|
|
82
|
+
* {@link ToolResult.display}, this is for the user only — it is lifted out
|
|
83
|
+
* before the result reaches the model, which would have nothing to do with
|
|
84
|
+
* the bytes but spend tokens on them. Say in `data` that a picture was shown,
|
|
85
|
+
* so she can talk about it without describing it back.
|
|
86
|
+
*
|
|
87
|
+
* The host stores each one as an attachment of the conversation, the same way
|
|
88
|
+
* a picture the user sends is stored, so it is served to every client and can
|
|
89
|
+
* be saved or shared from there. JPEG and PNG only, and 20 MB at most, since
|
|
90
|
+
* those are the limits the attachment store already holds users to. One that
|
|
91
|
+
* fails them is dropped with a warning rather than half-shown.
|
|
92
|
+
*/
|
|
93
|
+
attachments?: ToolAttachment[]
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* One picture a tool wants shown. See {@link ToolResult.attachments}.
|
|
98
|
+
*/
|
|
99
|
+
export interface ToolAttachment {
|
|
100
|
+
/** The image bytes, base64 encoded. The format is read from the bytes. */
|
|
101
|
+
data: string
|
|
102
|
+
/** A file name to offer when the user saves it, e.g. `friday.png`. */
|
|
103
|
+
name?: string
|
|
76
104
|
}
|
|
77
105
|
|
|
78
106
|
/**
|
package/src/types.ts
CHANGED
|
@@ -69,7 +69,7 @@ export type {
|
|
|
69
69
|
} from './types.provider.js'
|
|
70
70
|
|
|
71
71
|
// Tools and Actions
|
|
72
|
-
export type { Tool, ToolResult, Action, ActionResult } from './types.tools.js'
|
|
72
|
+
export type { Tool, ToolResult, ToolAttachment, Action, ActionResult } from './types.tools.js'
|
|
73
73
|
|
|
74
74
|
// Context and APIs
|
|
75
75
|
export type {
|