@anuma/sdk 11.1.0 → 11.3.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/expo/index.cjs +303 -148
- package/dist/expo/index.d.mts +17 -2
- package/dist/expo/index.d.ts +17 -2
- package/dist/expo/index.mjs +300 -145
- package/dist/index.d.mts +9 -1
- package/dist/index.d.ts +9 -1
- package/dist/react/index.cjs +433 -293
- package/dist/react/index.d.mts +16 -1
- package/dist/react/index.d.ts +16 -1
- package/dist/react/index.mjs +430 -290
- package/dist/server/index.cjs +162 -129
- package/dist/server/index.d.mts +11 -1
- package/dist/server/index.d.ts +11 -1
- package/dist/server/index.mjs +159 -126
- package/dist/tools/index.cjs +161 -3
- package/dist/tools/index.d.mts +50 -2
- package/dist/tools/index.d.ts +50 -2
- package/dist/tools/index.mjs +158 -3
- package/dist/tools/selection/index.d.mts +9 -1
- package/dist/tools/selection/index.d.ts +9 -1
- package/package.json +1 -1
package/dist/tools/index.d.mts
CHANGED
|
@@ -13,7 +13,13 @@ type ToolExecutionResult = {
|
|
|
13
13
|
/**
|
|
14
14
|
* Tool executor function type
|
|
15
15
|
*/
|
|
16
|
-
type ToolExecutor = (args: Record<string, unknown>, signal?: AbortSignal) => Promise<unknown> | unknown;
|
|
16
|
+
type ToolExecutor = (args: Record<string, unknown>, signal?: AbortSignal, context?: ToolExecutionContext) => Promise<unknown> | unknown;
|
|
17
|
+
/** How the portal treats a call to this device tool while the device is away. */
|
|
18
|
+
type DetachedToolClass = "render" | "deferred";
|
|
19
|
+
/** Context for one executor run; `detached` marks a call from an answer finished while the device was away. */
|
|
20
|
+
type ToolExecutionContext = {
|
|
21
|
+
detached?: boolean;
|
|
22
|
+
};
|
|
17
23
|
/**
|
|
18
24
|
* Tool configuration with optional executor
|
|
19
25
|
*/
|
|
@@ -83,6 +89,8 @@ type ToolConfig = LlmapiChatCompletionTool & {
|
|
|
83
89
|
* files from IndexedDB that `create_file` writes.
|
|
84
90
|
*/
|
|
85
91
|
dependsOn?: string[];
|
|
92
|
+
/** How the portal handles a call to this tool while the device is away; unset tools pause the turn. */
|
|
93
|
+
detachedClass?: DetachedToolClass;
|
|
86
94
|
};
|
|
87
95
|
|
|
88
96
|
/**
|
|
@@ -1418,6 +1426,46 @@ type DisplayChartResult = {
|
|
|
1418
1426
|
*/
|
|
1419
1427
|
declare function createChartTool(options: CreateUIToolsOptions): ToolConfig;
|
|
1420
1428
|
|
|
1429
|
+
type ChartSpec = Exclude<DisplayChartResult, {
|
|
1430
|
+
error: string;
|
|
1431
|
+
}>;
|
|
1432
|
+
type ChartFormatters = {
|
|
1433
|
+
tick: (value: number) => string;
|
|
1434
|
+
value: (value: number) => string;
|
|
1435
|
+
change: (difference: number) => string;
|
|
1436
|
+
};
|
|
1437
|
+
type ChartTrendDirection = "up" | "down" | "flat";
|
|
1438
|
+
type ChartTrend = {
|
|
1439
|
+
value: string;
|
|
1440
|
+
change: string;
|
|
1441
|
+
direction: ChartTrendDirection;
|
|
1442
|
+
range?: string;
|
|
1443
|
+
};
|
|
1444
|
+
type ChartModel = {
|
|
1445
|
+
isTrendChart: boolean;
|
|
1446
|
+
plottedKeys: string[];
|
|
1447
|
+
seriesLabels: Record<string, string>;
|
|
1448
|
+
labelKey?: string;
|
|
1449
|
+
values: number[];
|
|
1450
|
+
yTicks?: number[];
|
|
1451
|
+
yDomain?: [number, number];
|
|
1452
|
+
formatters: ChartFormatters;
|
|
1453
|
+
trend?: ChartTrend;
|
|
1454
|
+
title?: string;
|
|
1455
|
+
showDots: boolean;
|
|
1456
|
+
endIndexes: Record<string, number>;
|
|
1457
|
+
curve: "linear" | "monotone";
|
|
1458
|
+
hasNegative: boolean;
|
|
1459
|
+
longestTickLength: number;
|
|
1460
|
+
total: number;
|
|
1461
|
+
};
|
|
1462
|
+
/** Returns a chart cell value as display text, or an empty string for non-primitive values. */
|
|
1463
|
+
declare function chartCellText(value: unknown): string;
|
|
1464
|
+
/** Returns the display label for a series key. */
|
|
1465
|
+
declare function chartSeriesLabel(key: string): string;
|
|
1466
|
+
/** Computes a renderer-agnostic layout for a `display_chart` result: axis ticks, formatters, headline trend and mark policy. */
|
|
1467
|
+
declare function buildChartModel(spec: ChartSpec): ChartModel;
|
|
1468
|
+
|
|
1421
1469
|
/** Tool name surfaced to the LLM. */
|
|
1422
1470
|
declare const CHOICE_TOOL_NAME = "prompt_user_choice";
|
|
1423
1471
|
type ChoiceOption = {
|
|
@@ -2932,4 +2980,4 @@ interface XGetMyPostsArgs {
|
|
|
2932
2980
|
*/
|
|
2933
2981
|
declare function createXTools(callProxy: XProxyCaller): Record<string, ToolConfig>;
|
|
2934
2982
|
|
|
2935
|
-
export { ADD_SLIDE_SCHEMA, APP_BUILDER_PROMPT, APP_COMPLETE_CONNECT_ACK_TYPE, APP_COMPLETE_CONNECT_TYPE, APP_COMPLETE_DEFAULT_TIMEOUT_MS, APP_COMPLETE_IFRAME_SHIM_SCRIPT, APP_COMPLETE_REQUEST_TYPE, APP_COMPLETE_RESPONSE_TYPE, APP_COMPLETE_STUB_SCRIPT, APP_FILE_TOOL_NAMES, APP_PREVIEW_BASELINE_CSS, AUDIT_DESIGN_SCHEMA, type AgentresAccount, type AgentresClient, type AgentresClientOptions, AgentresError, type AgentresErrorCode, type AgentresLinkStatus, type AgentresLinkStep, AgentresPathError, type AnchorMatch, type AnumaChild, AnumaJsxError, type AnumaNode, type AppCompleteBridge, type AppCompleteBridgeOptions, type AppFileRecord, type AppFileStorage, type AttrValue, type AuditIssue, type AuditIssueType, type AuditResult, type AuditSeverity, type AuditTokens, type BuildSlideSystemPromptOptions, CHOICE_TOOL_NAME, CONNECTOR_ERROR_MARKER, CREATE_DOCUMENT_SCHEMA, CREATE_FILE_SCHEMA, CRITIQUE_DESIGN_SCHEMA, type CalendarEvent, type ChartDataPoint, type ChartValueFormat, type ChoiceOption, type ConfirmParameter, type ConfirmToolResult, type ConnectorErrorCode, type ConnectorMintError, type ConnectorMintResult, type ConnectorTokenGetterOpts, type ConnectorTokenSource, type CreateAppGenerationToolsOptions, type CreateDocumentToolsOptions, type CreateEventArgs, type CreateFileArgs, type CreateSelectPaymentWalletToolOptions, type CreateSlideToolsOptions, type CreateUIToolsOptions, type CreateWalletPaymentToolOptions, type CreateWeatherToolOptions, DEFAULT_DESIGN_CRITIQUE_RUBRIC, DEFAULT_DOCUMENT_ID, DEFAULT_MAX_CONVERSATIONS, DEFAULT_MAX_DOCUMENT_CONVERSATIONS, DELETE_FILE_SCHEMA, DOCUMENT_BUILDER_PROMPT, DOCUMENT_TOOL_NAMES, type DisplayChartResult, type DisplayConnectorResult, type DisplayPhoneCallOfferResult, type DisplayToolConfig, type DisplayToolMigrations, type DisplayWeatherResult, type DocAttrValue, type DocChild, DocDslError, type DocNode, type DriveFile, type DropboxRequestAccess, type DropboxTokenGetter, type ExportAppOptions, FONT_LIBRARY, FONT_PRESETS, type FileChangeEvent, type FileSnippet, type FontCategory, type FontPreset, type FontSpec, type ForecastDay, type FormField, type FormFieldOption, type FormFieldType, type GetFileContentArgs, type GmailGetMessageArgs, type GmailMessageDetail, type GmailMessageSummary, type GmailRequestAccess, type GmailSearchArgs, type GmailSendConfirmation, type GmailSendMessageArgs, type GmailTokenGetter, type InteractiveToolConfig, type KnownTag, LAYOUT_MODES, LIST_FILES_SCHEMA, type LayoutMode, type LegacyDeckJson, type ListEventsArgs, type ListRecentFilesArgs, MapFileStorage, type NotionCreatePagesArgs, type NotionFetchArgs, type NotionMcpCaller, type NotionMovePagesArgs, type NotionSearchArgs, type NotionUpdatePageArgs, PATCH_DOCUMENT_SCHEMA, PATCH_FILE_SCHEMA, PATCH_SLIDES_SCHEMA, PLAN_DECK_SCHEMA, type PatchFailure, type PatchFailureReason, type PaymentWallet, type PdfTag, READ_DOCUMENT_SCHEMA, READ_FILE_SCHEMA, READ_SLIDES_SCHEMA, RUNTIME_ERROR_OVERLAY_SCRIPT, SELECT_PAYMENT_WALLET_TOOL_NAME, SLIDES_FILE_PATH, SLIDE_CANVAS_HEIGHT, SLIDE_CANVAS_WIDTH, type SearchFilesArgs, type SelectPaymentWalletResult, SiwxChallengeError, SiwxUnsupportedError, type SlackGetChannelHistoryArgs, type SlackGetThreadRepliesArgs, type SlackListChannelsArgs, type SlackListDmsArgs, type SlackListUsersArgs, type SlackPostMessageArgs, type SlackProxyCaller, type SlackSearchMessagesArgs, type SlideToolSet, type SolanaSignMessageFn, THEME_ATTRS, type ThemeAttr, type ToolConfig, type ToolExecutionErrorType, type ToolExecutionResult, type UIInteractionContext, type UpdateEventArgs, type UpdateFileArgs, VERIFY_APP_SCHEMA, type VerifyAppResult, WALLET_PAYMENT_TOOL_NAME, type WalletPaymentOutcome, type WalletPaymentPassenger, type WalletPaymentRequest, type WalletPaymentResult, type XGetMeArgs, type XGetMyPostsArgs, type XProxyCaller, applyPatches, auditDesign, buildAppFileManifest, buildAppSystemPrompt, buildConnectorErrorResult, buildDocumentSystemPrompt, buildFontsUrl, buildSlideSystemPrompt, callNotionMCPTool, connectorMintErrorToToolResult, convertLegacyDeckJson, createAgentresClient, createAppCompleteBridge, createAppGenerationTools, createChartTool, createChatTools, createChoiceTool, createConfirmTool, createConnectorOfferTool, createConnectorTokenGetter, createDisplayTool, createDocumentTools, createDriveTools, createDropboxTools, createFormTool, createGitHubTools, createGmailTools, createGoogleCalendarCreateEventTool, createGoogleCalendarTool, createGoogleCalendarUpdateEventTool, createGoogleDriveCreateFileTool, createGoogleDriveGetContentTool, createGoogleDriveListRecentTool, createGoogleDriveSearchTool, createGoogleDriveUpdateFileTool, createInteractiveTool, createNotionCreateCommentTool, createNotionCreateDatabaseTool, createNotionCreatePagesTool, createNotionDuplicatePageTool, createNotionFetchTool, createNotionGetCommentsTool, createNotionGetTeamsTool, createNotionGetUsersTool, createNotionMovePagesTool, createNotionProxyTools, createNotionSearchTool, createNotionTools, createNotionUpdateDataSourceTool, createNotionUpdatePageTool, createPhoneCallOfferTool, createSelectPaymentWalletTool, createSlackTools, createSlideTools, createWalletPaymentTool, createWeatherTool, createXTools, documentPath, exportAppToHtml, findById, findParentOfId, getFontByName, getId, getMCPEndpoints, getNumberAttr, getStringAttr, insertAfterId, insertChild, installAppCompleteIframeShim, isAnumaTag, isHtmlTag, isKnownFont, isLegacyDeckJson, isPdfTag, migrateDisplayResult, normalizePath, parseDocumentDsl, parseJsx, pdfStyleKeys, pdfTags, removeById, replaceById, serializeJsx, truncateContent, updateAttrs, walk };
|
|
2983
|
+
export { ADD_SLIDE_SCHEMA, APP_BUILDER_PROMPT, APP_COMPLETE_CONNECT_ACK_TYPE, APP_COMPLETE_CONNECT_TYPE, APP_COMPLETE_DEFAULT_TIMEOUT_MS, APP_COMPLETE_IFRAME_SHIM_SCRIPT, APP_COMPLETE_REQUEST_TYPE, APP_COMPLETE_RESPONSE_TYPE, APP_COMPLETE_STUB_SCRIPT, APP_FILE_TOOL_NAMES, APP_PREVIEW_BASELINE_CSS, AUDIT_DESIGN_SCHEMA, type AgentresAccount, type AgentresClient, type AgentresClientOptions, AgentresError, type AgentresErrorCode, type AgentresLinkStatus, type AgentresLinkStep, AgentresPathError, type AnchorMatch, type AnumaChild, AnumaJsxError, type AnumaNode, type AppCompleteBridge, type AppCompleteBridgeOptions, type AppFileRecord, type AppFileStorage, type AttrValue, type AuditIssue, type AuditIssueType, type AuditResult, type AuditSeverity, type AuditTokens, type BuildSlideSystemPromptOptions, CHOICE_TOOL_NAME, CONNECTOR_ERROR_MARKER, CREATE_DOCUMENT_SCHEMA, CREATE_FILE_SCHEMA, CRITIQUE_DESIGN_SCHEMA, type CalendarEvent, type ChartDataPoint, type ChartFormatters, type ChartModel, type ChartSpec, type ChartTrend, type ChartTrendDirection, type ChartValueFormat, type ChoiceOption, type ConfirmParameter, type ConfirmToolResult, type ConnectorErrorCode, type ConnectorMintError, type ConnectorMintResult, type ConnectorTokenGetterOpts, type ConnectorTokenSource, type CreateAppGenerationToolsOptions, type CreateDocumentToolsOptions, type CreateEventArgs, type CreateFileArgs, type CreateSelectPaymentWalletToolOptions, type CreateSlideToolsOptions, type CreateUIToolsOptions, type CreateWalletPaymentToolOptions, type CreateWeatherToolOptions, DEFAULT_DESIGN_CRITIQUE_RUBRIC, DEFAULT_DOCUMENT_ID, DEFAULT_MAX_CONVERSATIONS, DEFAULT_MAX_DOCUMENT_CONVERSATIONS, DELETE_FILE_SCHEMA, DOCUMENT_BUILDER_PROMPT, DOCUMENT_TOOL_NAMES, type DisplayChartResult, type DisplayConnectorResult, type DisplayPhoneCallOfferResult, type DisplayToolConfig, type DisplayToolMigrations, type DisplayWeatherResult, type DocAttrValue, type DocChild, DocDslError, type DocNode, type DriveFile, type DropboxRequestAccess, type DropboxTokenGetter, type ExportAppOptions, FONT_LIBRARY, FONT_PRESETS, type FileChangeEvent, type FileSnippet, type FontCategory, type FontPreset, type FontSpec, type ForecastDay, type FormField, type FormFieldOption, type FormFieldType, type GetFileContentArgs, type GmailGetMessageArgs, type GmailMessageDetail, type GmailMessageSummary, type GmailRequestAccess, type GmailSearchArgs, type GmailSendConfirmation, type GmailSendMessageArgs, type GmailTokenGetter, type InteractiveToolConfig, type KnownTag, LAYOUT_MODES, LIST_FILES_SCHEMA, type LayoutMode, type LegacyDeckJson, type ListEventsArgs, type ListRecentFilesArgs, MapFileStorage, type NotionCreatePagesArgs, type NotionFetchArgs, type NotionMcpCaller, type NotionMovePagesArgs, type NotionSearchArgs, type NotionUpdatePageArgs, PATCH_DOCUMENT_SCHEMA, PATCH_FILE_SCHEMA, PATCH_SLIDES_SCHEMA, PLAN_DECK_SCHEMA, type PatchFailure, type PatchFailureReason, type PaymentWallet, type PdfTag, READ_DOCUMENT_SCHEMA, READ_FILE_SCHEMA, READ_SLIDES_SCHEMA, RUNTIME_ERROR_OVERLAY_SCRIPT, SELECT_PAYMENT_WALLET_TOOL_NAME, SLIDES_FILE_PATH, SLIDE_CANVAS_HEIGHT, SLIDE_CANVAS_WIDTH, type SearchFilesArgs, type SelectPaymentWalletResult, SiwxChallengeError, SiwxUnsupportedError, type SlackGetChannelHistoryArgs, type SlackGetThreadRepliesArgs, type SlackListChannelsArgs, type SlackListDmsArgs, type SlackListUsersArgs, type SlackPostMessageArgs, type SlackProxyCaller, type SlackSearchMessagesArgs, type SlideToolSet, type SolanaSignMessageFn, THEME_ATTRS, type ThemeAttr, type ToolConfig, type ToolExecutionErrorType, type ToolExecutionResult, type UIInteractionContext, type UpdateEventArgs, type UpdateFileArgs, VERIFY_APP_SCHEMA, type VerifyAppResult, WALLET_PAYMENT_TOOL_NAME, type WalletPaymentOutcome, type WalletPaymentPassenger, type WalletPaymentRequest, type WalletPaymentResult, type XGetMeArgs, type XGetMyPostsArgs, type XProxyCaller, applyPatches, auditDesign, buildAppFileManifest, buildAppSystemPrompt, buildChartModel, buildConnectorErrorResult, buildDocumentSystemPrompt, buildFontsUrl, buildSlideSystemPrompt, callNotionMCPTool, chartCellText, chartSeriesLabel, connectorMintErrorToToolResult, convertLegacyDeckJson, createAgentresClient, createAppCompleteBridge, createAppGenerationTools, createChartTool, createChatTools, createChoiceTool, createConfirmTool, createConnectorOfferTool, createConnectorTokenGetter, createDisplayTool, createDocumentTools, createDriveTools, createDropboxTools, createFormTool, createGitHubTools, createGmailTools, createGoogleCalendarCreateEventTool, createGoogleCalendarTool, createGoogleCalendarUpdateEventTool, createGoogleDriveCreateFileTool, createGoogleDriveGetContentTool, createGoogleDriveListRecentTool, createGoogleDriveSearchTool, createGoogleDriveUpdateFileTool, createInteractiveTool, createNotionCreateCommentTool, createNotionCreateDatabaseTool, createNotionCreatePagesTool, createNotionDuplicatePageTool, createNotionFetchTool, createNotionGetCommentsTool, createNotionGetTeamsTool, createNotionGetUsersTool, createNotionMovePagesTool, createNotionProxyTools, createNotionSearchTool, createNotionTools, createNotionUpdateDataSourceTool, createNotionUpdatePageTool, createPhoneCallOfferTool, createSelectPaymentWalletTool, createSlackTools, createSlideTools, createWalletPaymentTool, createWeatherTool, createXTools, documentPath, exportAppToHtml, findById, findParentOfId, getFontByName, getId, getMCPEndpoints, getNumberAttr, getStringAttr, insertAfterId, insertChild, installAppCompleteIframeShim, isAnumaTag, isHtmlTag, isKnownFont, isLegacyDeckJson, isPdfTag, migrateDisplayResult, normalizePath, parseDocumentDsl, parseJsx, pdfStyleKeys, pdfTags, removeById, replaceById, serializeJsx, truncateContent, updateAttrs, walk };
|
package/dist/tools/index.d.ts
CHANGED
|
@@ -13,7 +13,13 @@ type ToolExecutionResult = {
|
|
|
13
13
|
/**
|
|
14
14
|
* Tool executor function type
|
|
15
15
|
*/
|
|
16
|
-
type ToolExecutor = (args: Record<string, unknown>, signal?: AbortSignal) => Promise<unknown> | unknown;
|
|
16
|
+
type ToolExecutor = (args: Record<string, unknown>, signal?: AbortSignal, context?: ToolExecutionContext) => Promise<unknown> | unknown;
|
|
17
|
+
/** How the portal treats a call to this device tool while the device is away. */
|
|
18
|
+
type DetachedToolClass = "render" | "deferred";
|
|
19
|
+
/** Context for one executor run; `detached` marks a call from an answer finished while the device was away. */
|
|
20
|
+
type ToolExecutionContext = {
|
|
21
|
+
detached?: boolean;
|
|
22
|
+
};
|
|
17
23
|
/**
|
|
18
24
|
* Tool configuration with optional executor
|
|
19
25
|
*/
|
|
@@ -83,6 +89,8 @@ type ToolConfig = LlmapiChatCompletionTool & {
|
|
|
83
89
|
* files from IndexedDB that `create_file` writes.
|
|
84
90
|
*/
|
|
85
91
|
dependsOn?: string[];
|
|
92
|
+
/** How the portal handles a call to this tool while the device is away; unset tools pause the turn. */
|
|
93
|
+
detachedClass?: DetachedToolClass;
|
|
86
94
|
};
|
|
87
95
|
|
|
88
96
|
/**
|
|
@@ -1418,6 +1426,46 @@ type DisplayChartResult = {
|
|
|
1418
1426
|
*/
|
|
1419
1427
|
declare function createChartTool(options: CreateUIToolsOptions): ToolConfig;
|
|
1420
1428
|
|
|
1429
|
+
type ChartSpec = Exclude<DisplayChartResult, {
|
|
1430
|
+
error: string;
|
|
1431
|
+
}>;
|
|
1432
|
+
type ChartFormatters = {
|
|
1433
|
+
tick: (value: number) => string;
|
|
1434
|
+
value: (value: number) => string;
|
|
1435
|
+
change: (difference: number) => string;
|
|
1436
|
+
};
|
|
1437
|
+
type ChartTrendDirection = "up" | "down" | "flat";
|
|
1438
|
+
type ChartTrend = {
|
|
1439
|
+
value: string;
|
|
1440
|
+
change: string;
|
|
1441
|
+
direction: ChartTrendDirection;
|
|
1442
|
+
range?: string;
|
|
1443
|
+
};
|
|
1444
|
+
type ChartModel = {
|
|
1445
|
+
isTrendChart: boolean;
|
|
1446
|
+
plottedKeys: string[];
|
|
1447
|
+
seriesLabels: Record<string, string>;
|
|
1448
|
+
labelKey?: string;
|
|
1449
|
+
values: number[];
|
|
1450
|
+
yTicks?: number[];
|
|
1451
|
+
yDomain?: [number, number];
|
|
1452
|
+
formatters: ChartFormatters;
|
|
1453
|
+
trend?: ChartTrend;
|
|
1454
|
+
title?: string;
|
|
1455
|
+
showDots: boolean;
|
|
1456
|
+
endIndexes: Record<string, number>;
|
|
1457
|
+
curve: "linear" | "monotone";
|
|
1458
|
+
hasNegative: boolean;
|
|
1459
|
+
longestTickLength: number;
|
|
1460
|
+
total: number;
|
|
1461
|
+
};
|
|
1462
|
+
/** Returns a chart cell value as display text, or an empty string for non-primitive values. */
|
|
1463
|
+
declare function chartCellText(value: unknown): string;
|
|
1464
|
+
/** Returns the display label for a series key. */
|
|
1465
|
+
declare function chartSeriesLabel(key: string): string;
|
|
1466
|
+
/** Computes a renderer-agnostic layout for a `display_chart` result: axis ticks, formatters, headline trend and mark policy. */
|
|
1467
|
+
declare function buildChartModel(spec: ChartSpec): ChartModel;
|
|
1468
|
+
|
|
1421
1469
|
/** Tool name surfaced to the LLM. */
|
|
1422
1470
|
declare const CHOICE_TOOL_NAME = "prompt_user_choice";
|
|
1423
1471
|
type ChoiceOption = {
|
|
@@ -2932,4 +2980,4 @@ interface XGetMyPostsArgs {
|
|
|
2932
2980
|
*/
|
|
2933
2981
|
declare function createXTools(callProxy: XProxyCaller): Record<string, ToolConfig>;
|
|
2934
2982
|
|
|
2935
|
-
export { ADD_SLIDE_SCHEMA, APP_BUILDER_PROMPT, APP_COMPLETE_CONNECT_ACK_TYPE, APP_COMPLETE_CONNECT_TYPE, APP_COMPLETE_DEFAULT_TIMEOUT_MS, APP_COMPLETE_IFRAME_SHIM_SCRIPT, APP_COMPLETE_REQUEST_TYPE, APP_COMPLETE_RESPONSE_TYPE, APP_COMPLETE_STUB_SCRIPT, APP_FILE_TOOL_NAMES, APP_PREVIEW_BASELINE_CSS, AUDIT_DESIGN_SCHEMA, type AgentresAccount, type AgentresClient, type AgentresClientOptions, AgentresError, type AgentresErrorCode, type AgentresLinkStatus, type AgentresLinkStep, AgentresPathError, type AnchorMatch, type AnumaChild, AnumaJsxError, type AnumaNode, type AppCompleteBridge, type AppCompleteBridgeOptions, type AppFileRecord, type AppFileStorage, type AttrValue, type AuditIssue, type AuditIssueType, type AuditResult, type AuditSeverity, type AuditTokens, type BuildSlideSystemPromptOptions, CHOICE_TOOL_NAME, CONNECTOR_ERROR_MARKER, CREATE_DOCUMENT_SCHEMA, CREATE_FILE_SCHEMA, CRITIQUE_DESIGN_SCHEMA, type CalendarEvent, type ChartDataPoint, type ChartValueFormat, type ChoiceOption, type ConfirmParameter, type ConfirmToolResult, type ConnectorErrorCode, type ConnectorMintError, type ConnectorMintResult, type ConnectorTokenGetterOpts, type ConnectorTokenSource, type CreateAppGenerationToolsOptions, type CreateDocumentToolsOptions, type CreateEventArgs, type CreateFileArgs, type CreateSelectPaymentWalletToolOptions, type CreateSlideToolsOptions, type CreateUIToolsOptions, type CreateWalletPaymentToolOptions, type CreateWeatherToolOptions, DEFAULT_DESIGN_CRITIQUE_RUBRIC, DEFAULT_DOCUMENT_ID, DEFAULT_MAX_CONVERSATIONS, DEFAULT_MAX_DOCUMENT_CONVERSATIONS, DELETE_FILE_SCHEMA, DOCUMENT_BUILDER_PROMPT, DOCUMENT_TOOL_NAMES, type DisplayChartResult, type DisplayConnectorResult, type DisplayPhoneCallOfferResult, type DisplayToolConfig, type DisplayToolMigrations, type DisplayWeatherResult, type DocAttrValue, type DocChild, DocDslError, type DocNode, type DriveFile, type DropboxRequestAccess, type DropboxTokenGetter, type ExportAppOptions, FONT_LIBRARY, FONT_PRESETS, type FileChangeEvent, type FileSnippet, type FontCategory, type FontPreset, type FontSpec, type ForecastDay, type FormField, type FormFieldOption, type FormFieldType, type GetFileContentArgs, type GmailGetMessageArgs, type GmailMessageDetail, type GmailMessageSummary, type GmailRequestAccess, type GmailSearchArgs, type GmailSendConfirmation, type GmailSendMessageArgs, type GmailTokenGetter, type InteractiveToolConfig, type KnownTag, LAYOUT_MODES, LIST_FILES_SCHEMA, type LayoutMode, type LegacyDeckJson, type ListEventsArgs, type ListRecentFilesArgs, MapFileStorage, type NotionCreatePagesArgs, type NotionFetchArgs, type NotionMcpCaller, type NotionMovePagesArgs, type NotionSearchArgs, type NotionUpdatePageArgs, PATCH_DOCUMENT_SCHEMA, PATCH_FILE_SCHEMA, PATCH_SLIDES_SCHEMA, PLAN_DECK_SCHEMA, type PatchFailure, type PatchFailureReason, type PaymentWallet, type PdfTag, READ_DOCUMENT_SCHEMA, READ_FILE_SCHEMA, READ_SLIDES_SCHEMA, RUNTIME_ERROR_OVERLAY_SCRIPT, SELECT_PAYMENT_WALLET_TOOL_NAME, SLIDES_FILE_PATH, SLIDE_CANVAS_HEIGHT, SLIDE_CANVAS_WIDTH, type SearchFilesArgs, type SelectPaymentWalletResult, SiwxChallengeError, SiwxUnsupportedError, type SlackGetChannelHistoryArgs, type SlackGetThreadRepliesArgs, type SlackListChannelsArgs, type SlackListDmsArgs, type SlackListUsersArgs, type SlackPostMessageArgs, type SlackProxyCaller, type SlackSearchMessagesArgs, type SlideToolSet, type SolanaSignMessageFn, THEME_ATTRS, type ThemeAttr, type ToolConfig, type ToolExecutionErrorType, type ToolExecutionResult, type UIInteractionContext, type UpdateEventArgs, type UpdateFileArgs, VERIFY_APP_SCHEMA, type VerifyAppResult, WALLET_PAYMENT_TOOL_NAME, type WalletPaymentOutcome, type WalletPaymentPassenger, type WalletPaymentRequest, type WalletPaymentResult, type XGetMeArgs, type XGetMyPostsArgs, type XProxyCaller, applyPatches, auditDesign, buildAppFileManifest, buildAppSystemPrompt, buildConnectorErrorResult, buildDocumentSystemPrompt, buildFontsUrl, buildSlideSystemPrompt, callNotionMCPTool, connectorMintErrorToToolResult, convertLegacyDeckJson, createAgentresClient, createAppCompleteBridge, createAppGenerationTools, createChartTool, createChatTools, createChoiceTool, createConfirmTool, createConnectorOfferTool, createConnectorTokenGetter, createDisplayTool, createDocumentTools, createDriveTools, createDropboxTools, createFormTool, createGitHubTools, createGmailTools, createGoogleCalendarCreateEventTool, createGoogleCalendarTool, createGoogleCalendarUpdateEventTool, createGoogleDriveCreateFileTool, createGoogleDriveGetContentTool, createGoogleDriveListRecentTool, createGoogleDriveSearchTool, createGoogleDriveUpdateFileTool, createInteractiveTool, createNotionCreateCommentTool, createNotionCreateDatabaseTool, createNotionCreatePagesTool, createNotionDuplicatePageTool, createNotionFetchTool, createNotionGetCommentsTool, createNotionGetTeamsTool, createNotionGetUsersTool, createNotionMovePagesTool, createNotionProxyTools, createNotionSearchTool, createNotionTools, createNotionUpdateDataSourceTool, createNotionUpdatePageTool, createPhoneCallOfferTool, createSelectPaymentWalletTool, createSlackTools, createSlideTools, createWalletPaymentTool, createWeatherTool, createXTools, documentPath, exportAppToHtml, findById, findParentOfId, getFontByName, getId, getMCPEndpoints, getNumberAttr, getStringAttr, insertAfterId, insertChild, installAppCompleteIframeShim, isAnumaTag, isHtmlTag, isKnownFont, isLegacyDeckJson, isPdfTag, migrateDisplayResult, normalizePath, parseDocumentDsl, parseJsx, pdfStyleKeys, pdfTags, removeById, replaceById, serializeJsx, truncateContent, updateAttrs, walk };
|
|
2983
|
+
export { ADD_SLIDE_SCHEMA, APP_BUILDER_PROMPT, APP_COMPLETE_CONNECT_ACK_TYPE, APP_COMPLETE_CONNECT_TYPE, APP_COMPLETE_DEFAULT_TIMEOUT_MS, APP_COMPLETE_IFRAME_SHIM_SCRIPT, APP_COMPLETE_REQUEST_TYPE, APP_COMPLETE_RESPONSE_TYPE, APP_COMPLETE_STUB_SCRIPT, APP_FILE_TOOL_NAMES, APP_PREVIEW_BASELINE_CSS, AUDIT_DESIGN_SCHEMA, type AgentresAccount, type AgentresClient, type AgentresClientOptions, AgentresError, type AgentresErrorCode, type AgentresLinkStatus, type AgentresLinkStep, AgentresPathError, type AnchorMatch, type AnumaChild, AnumaJsxError, type AnumaNode, type AppCompleteBridge, type AppCompleteBridgeOptions, type AppFileRecord, type AppFileStorage, type AttrValue, type AuditIssue, type AuditIssueType, type AuditResult, type AuditSeverity, type AuditTokens, type BuildSlideSystemPromptOptions, CHOICE_TOOL_NAME, CONNECTOR_ERROR_MARKER, CREATE_DOCUMENT_SCHEMA, CREATE_FILE_SCHEMA, CRITIQUE_DESIGN_SCHEMA, type CalendarEvent, type ChartDataPoint, type ChartFormatters, type ChartModel, type ChartSpec, type ChartTrend, type ChartTrendDirection, type ChartValueFormat, type ChoiceOption, type ConfirmParameter, type ConfirmToolResult, type ConnectorErrorCode, type ConnectorMintError, type ConnectorMintResult, type ConnectorTokenGetterOpts, type ConnectorTokenSource, type CreateAppGenerationToolsOptions, type CreateDocumentToolsOptions, type CreateEventArgs, type CreateFileArgs, type CreateSelectPaymentWalletToolOptions, type CreateSlideToolsOptions, type CreateUIToolsOptions, type CreateWalletPaymentToolOptions, type CreateWeatherToolOptions, DEFAULT_DESIGN_CRITIQUE_RUBRIC, DEFAULT_DOCUMENT_ID, DEFAULT_MAX_CONVERSATIONS, DEFAULT_MAX_DOCUMENT_CONVERSATIONS, DELETE_FILE_SCHEMA, DOCUMENT_BUILDER_PROMPT, DOCUMENT_TOOL_NAMES, type DisplayChartResult, type DisplayConnectorResult, type DisplayPhoneCallOfferResult, type DisplayToolConfig, type DisplayToolMigrations, type DisplayWeatherResult, type DocAttrValue, type DocChild, DocDslError, type DocNode, type DriveFile, type DropboxRequestAccess, type DropboxTokenGetter, type ExportAppOptions, FONT_LIBRARY, FONT_PRESETS, type FileChangeEvent, type FileSnippet, type FontCategory, type FontPreset, type FontSpec, type ForecastDay, type FormField, type FormFieldOption, type FormFieldType, type GetFileContentArgs, type GmailGetMessageArgs, type GmailMessageDetail, type GmailMessageSummary, type GmailRequestAccess, type GmailSearchArgs, type GmailSendConfirmation, type GmailSendMessageArgs, type GmailTokenGetter, type InteractiveToolConfig, type KnownTag, LAYOUT_MODES, LIST_FILES_SCHEMA, type LayoutMode, type LegacyDeckJson, type ListEventsArgs, type ListRecentFilesArgs, MapFileStorage, type NotionCreatePagesArgs, type NotionFetchArgs, type NotionMcpCaller, type NotionMovePagesArgs, type NotionSearchArgs, type NotionUpdatePageArgs, PATCH_DOCUMENT_SCHEMA, PATCH_FILE_SCHEMA, PATCH_SLIDES_SCHEMA, PLAN_DECK_SCHEMA, type PatchFailure, type PatchFailureReason, type PaymentWallet, type PdfTag, READ_DOCUMENT_SCHEMA, READ_FILE_SCHEMA, READ_SLIDES_SCHEMA, RUNTIME_ERROR_OVERLAY_SCRIPT, SELECT_PAYMENT_WALLET_TOOL_NAME, SLIDES_FILE_PATH, SLIDE_CANVAS_HEIGHT, SLIDE_CANVAS_WIDTH, type SearchFilesArgs, type SelectPaymentWalletResult, SiwxChallengeError, SiwxUnsupportedError, type SlackGetChannelHistoryArgs, type SlackGetThreadRepliesArgs, type SlackListChannelsArgs, type SlackListDmsArgs, type SlackListUsersArgs, type SlackPostMessageArgs, type SlackProxyCaller, type SlackSearchMessagesArgs, type SlideToolSet, type SolanaSignMessageFn, THEME_ATTRS, type ThemeAttr, type ToolConfig, type ToolExecutionErrorType, type ToolExecutionResult, type UIInteractionContext, type UpdateEventArgs, type UpdateFileArgs, VERIFY_APP_SCHEMA, type VerifyAppResult, WALLET_PAYMENT_TOOL_NAME, type WalletPaymentOutcome, type WalletPaymentPassenger, type WalletPaymentRequest, type WalletPaymentResult, type XGetMeArgs, type XGetMyPostsArgs, type XProxyCaller, applyPatches, auditDesign, buildAppFileManifest, buildAppSystemPrompt, buildChartModel, buildConnectorErrorResult, buildDocumentSystemPrompt, buildFontsUrl, buildSlideSystemPrompt, callNotionMCPTool, chartCellText, chartSeriesLabel, connectorMintErrorToToolResult, convertLegacyDeckJson, createAgentresClient, createAppCompleteBridge, createAppGenerationTools, createChartTool, createChatTools, createChoiceTool, createConfirmTool, createConnectorOfferTool, createConnectorTokenGetter, createDisplayTool, createDocumentTools, createDriveTools, createDropboxTools, createFormTool, createGitHubTools, createGmailTools, createGoogleCalendarCreateEventTool, createGoogleCalendarTool, createGoogleCalendarUpdateEventTool, createGoogleDriveCreateFileTool, createGoogleDriveGetContentTool, createGoogleDriveListRecentTool, createGoogleDriveSearchTool, createGoogleDriveUpdateFileTool, createInteractiveTool, createNotionCreateCommentTool, createNotionCreateDatabaseTool, createNotionCreatePagesTool, createNotionDuplicatePageTool, createNotionFetchTool, createNotionGetCommentsTool, createNotionGetTeamsTool, createNotionGetUsersTool, createNotionMovePagesTool, createNotionProxyTools, createNotionSearchTool, createNotionTools, createNotionUpdateDataSourceTool, createNotionUpdatePageTool, createPhoneCallOfferTool, createSelectPaymentWalletTool, createSlackTools, createSlideTools, createWalletPaymentTool, createWeatherTool, createXTools, documentPath, exportAppToHtml, findById, findParentOfId, getFontByName, getId, getMCPEndpoints, getNumberAttr, getStringAttr, insertAfterId, insertChild, installAppCompleteIframeShim, isAnumaTag, isHtmlTag, isKnownFont, isLegacyDeckJson, isPdfTag, migrateDisplayResult, normalizePath, parseDocumentDsl, parseJsx, pdfStyleKeys, pdfTags, removeById, replaceById, serializeJsx, truncateContent, updateAttrs, walk };
|
package/dist/tools/index.mjs
CHANGED
|
@@ -2346,9 +2346,9 @@ function createDisplayTool(options, config) {
|
|
|
2346
2346
|
description: config.description,
|
|
2347
2347
|
arguments: config.parameters
|
|
2348
2348
|
},
|
|
2349
|
-
executor: async (args) => {
|
|
2349
|
+
executor: async (args, _signal, execution) => {
|
|
2350
2350
|
const result = await Promise.resolve(config.execute(args));
|
|
2351
|
-
const context = options.getContext();
|
|
2351
|
+
const context = execution?.detached ? null : options.getContext();
|
|
2352
2352
|
if (context) {
|
|
2353
2353
|
const interactionId = generateInteractionId(config.displayType);
|
|
2354
2354
|
const replacesInteractionId = config.getReplacesInteractionId?.(args);
|
|
@@ -2363,7 +2363,8 @@ function createDisplayTool(options, config) {
|
|
|
2363
2363
|
}
|
|
2364
2364
|
return result;
|
|
2365
2365
|
},
|
|
2366
|
-
skipContinuation: true
|
|
2366
|
+
skipContinuation: true,
|
|
2367
|
+
detachedClass: "render"
|
|
2367
2368
|
};
|
|
2368
2369
|
}
|
|
2369
2370
|
|
|
@@ -2496,6 +2497,157 @@ function createChartTool(options) {
|
|
|
2496
2497
|
});
|
|
2497
2498
|
}
|
|
2498
2499
|
|
|
2500
|
+
// src/tools/chartModel.ts
|
|
2501
|
+
var DOT_LIMIT = 12;
|
|
2502
|
+
var MAX_TICKS = 8;
|
|
2503
|
+
var MINUS = "\u2212";
|
|
2504
|
+
function chartCellText(value) {
|
|
2505
|
+
return typeof value === "string" || typeof value === "number" || typeof value === "boolean" ? String(value) : "";
|
|
2506
|
+
}
|
|
2507
|
+
function tickDigits(ticks) {
|
|
2508
|
+
if (!ticks || ticks.length < 2) return 3;
|
|
2509
|
+
const step = ticks[1] - ticks[0];
|
|
2510
|
+
const magnitude = Math.max(...ticks.map(Math.abs));
|
|
2511
|
+
if (step <= 0 || magnitude === 0) return 3;
|
|
2512
|
+
const needed = Math.floor(Math.log10(magnitude)) - Math.floor(Math.log10(step)) + 1;
|
|
2513
|
+
return Math.min(21, Math.max(3, needed));
|
|
2514
|
+
}
|
|
2515
|
+
function keepSmall(options) {
|
|
2516
|
+
const small = new Intl.NumberFormat(void 0, { ...options, maximumSignificantDigits: 3 });
|
|
2517
|
+
const regular = new Intl.NumberFormat(void 0, { ...options, maximumFractionDigits: 2 });
|
|
2518
|
+
return (n, format) => format(n !== 0 && Math.abs(n) < 1 ? small : regular, n);
|
|
2519
|
+
}
|
|
2520
|
+
function buildFormatters(format, currency, ticks) {
|
|
2521
|
+
const digits = tickDigits(ticks);
|
|
2522
|
+
if (format === "currency") {
|
|
2523
|
+
const money = (options) => new Intl.NumberFormat(void 0, {
|
|
2524
|
+
style: "currency",
|
|
2525
|
+
currency: currency ?? "USD",
|
|
2526
|
+
...options
|
|
2527
|
+
});
|
|
2528
|
+
const compact2 = money({ notation: "compact", maximumSignificantDigits: 3 });
|
|
2529
|
+
const tick2 = money({ notation: "compact", maximumSignificantDigits: digits });
|
|
2530
|
+
const small2 = money({ maximumSignificantDigits: 4 });
|
|
2531
|
+
const cents = money({ minimumFractionDigits: 2, maximumFractionDigits: 2 });
|
|
2532
|
+
const value2 = (n) => Math.abs(n) >= 1e6 ? compact2.format(n) : n !== 0 && Math.abs(n) < 1 ? small2.format(n) : cents.format(n);
|
|
2533
|
+
return { tick: (n) => tick2.format(n), value: value2, change: (d) => value2(Math.abs(d)) };
|
|
2534
|
+
}
|
|
2535
|
+
if (format === "percent") {
|
|
2536
|
+
const percent = keepSmall({ style: "percent" });
|
|
2537
|
+
const points = keepSmall({});
|
|
2538
|
+
const tick2 = new Intl.NumberFormat(void 0, {
|
|
2539
|
+
style: "percent",
|
|
2540
|
+
maximumSignificantDigits: digits
|
|
2541
|
+
});
|
|
2542
|
+
return {
|
|
2543
|
+
tick: (n) => tick2.format(n / 100),
|
|
2544
|
+
value: (n) => percent(n, (formatter) => formatter.format(n / 100)),
|
|
2545
|
+
change: (d) => `${points(Math.abs(d), (formatter, n) => formatter.format(n))} pts`
|
|
2546
|
+
};
|
|
2547
|
+
}
|
|
2548
|
+
const tick = new Intl.NumberFormat(void 0, {
|
|
2549
|
+
notation: "compact",
|
|
2550
|
+
maximumSignificantDigits: digits
|
|
2551
|
+
});
|
|
2552
|
+
const compact = new Intl.NumberFormat(void 0, {
|
|
2553
|
+
notation: "compact",
|
|
2554
|
+
maximumSignificantDigits: 3
|
|
2555
|
+
});
|
|
2556
|
+
const small = new Intl.NumberFormat(void 0, { maximumSignificantDigits: 4 });
|
|
2557
|
+
const plain = new Intl.NumberFormat(void 0, { maximumFractionDigits: 2 });
|
|
2558
|
+
const value = (n) => Math.abs(n) >= 1e6 ? compact.format(n) : n !== 0 && Math.abs(n) < 1 ? small.format(n) : plain.format(n);
|
|
2559
|
+
return { tick: (n) => tick.format(n), value, change: (d) => value(Math.abs(d)) };
|
|
2560
|
+
}
|
|
2561
|
+
function seriesValues(points, keys) {
|
|
2562
|
+
return points.flatMap(
|
|
2563
|
+
(point) => keys.map((key) => point[key]).filter((v) => typeof v === "number")
|
|
2564
|
+
);
|
|
2565
|
+
}
|
|
2566
|
+
function niceStep(rough) {
|
|
2567
|
+
const exponent = Math.floor(Math.log10(rough));
|
|
2568
|
+
const base = 10 ** exponent;
|
|
2569
|
+
const fraction = rough / base;
|
|
2570
|
+
const nice = fraction <= 1 ? 1 : fraction <= 2 ? 2 : fraction <= 2.5 ? 2.5 : fraction <= 5 ? 5 : 10;
|
|
2571
|
+
return nice * base;
|
|
2572
|
+
}
|
|
2573
|
+
function niceTicks(values) {
|
|
2574
|
+
if (values.length === 0) return void 0;
|
|
2575
|
+
const min = Math.min(...values);
|
|
2576
|
+
const max = Math.max(...values);
|
|
2577
|
+
const span = max - min || Math.abs(max) * 0.02 || 1;
|
|
2578
|
+
const low = min - span * 0.1;
|
|
2579
|
+
const high = max + span * 0.1;
|
|
2580
|
+
const step = niceStep((high - low) / 3);
|
|
2581
|
+
const start = min >= 0 ? Math.max(0, Math.floor(low / step) * step) : Math.floor(low / step) * step;
|
|
2582
|
+
const ticks = [];
|
|
2583
|
+
for (let index = 0; index <= MAX_TICKS; index++) {
|
|
2584
|
+
const tick = Number((start + index * step).toPrecision(15));
|
|
2585
|
+
if (ticks.length > 0 && tick <= ticks[ticks.length - 1]) break;
|
|
2586
|
+
ticks.push(tick);
|
|
2587
|
+
if (tick >= high) break;
|
|
2588
|
+
}
|
|
2589
|
+
return ticks.length >= 2 ? ticks : void 0;
|
|
2590
|
+
}
|
|
2591
|
+
function buildTrend(values, format, formatters) {
|
|
2592
|
+
if (values.length < 2) return void 0;
|
|
2593
|
+
const first = values[0];
|
|
2594
|
+
const last = values[values.length - 1];
|
|
2595
|
+
const difference = last - first;
|
|
2596
|
+
const direction = difference > 0 ? "up" : difference < 0 ? "down" : "flat";
|
|
2597
|
+
const sign = direction === "up" ? "+" : direction === "down" ? MINUS : "";
|
|
2598
|
+
const percent = format !== "percent" && first !== 0 ? ` (${sign}${new Intl.NumberFormat(void 0, { maximumFractionDigits: 2 }).format(
|
|
2599
|
+
Math.abs(difference / Math.abs(first) * 100)
|
|
2600
|
+
)}%)` : "";
|
|
2601
|
+
return {
|
|
2602
|
+
value: formatters.value(last),
|
|
2603
|
+
change: `${sign}${formatters.change(difference)}${percent}`,
|
|
2604
|
+
direction
|
|
2605
|
+
};
|
|
2606
|
+
}
|
|
2607
|
+
function lastValueIndex(points, key) {
|
|
2608
|
+
for (let index = points.length - 1; index >= 0; index--) {
|
|
2609
|
+
if (typeof points[index][key] === "number") return index;
|
|
2610
|
+
}
|
|
2611
|
+
return -1;
|
|
2612
|
+
}
|
|
2613
|
+
function chartSeriesLabel(key) {
|
|
2614
|
+
return key.charAt(0).toUpperCase() + key.slice(1);
|
|
2615
|
+
}
|
|
2616
|
+
function buildChartModel(spec) {
|
|
2617
|
+
const { chartType, title, data, dataKeys, xAxisKey, valueFormat, currency } = spec;
|
|
2618
|
+
const isTrendChart = chartType === "line" || chartType === "area";
|
|
2619
|
+
const plottedKeys = chartType === "pie" ? dataKeys.slice(0, 1) : dataKeys;
|
|
2620
|
+
const values = seriesValues(data, plottedKeys);
|
|
2621
|
+
const yTicks = isTrendChart ? niceTicks(values) : void 0;
|
|
2622
|
+
const yDomain = yTicks ? [yTicks[0], yTicks[yTicks.length - 1]] : void 0;
|
|
2623
|
+
const formatters = buildFormatters(valueFormat, currency, yTicks);
|
|
2624
|
+
const seriesLabels = Object.fromEntries(dataKeys.map((key) => [key, chartSeriesLabel(key)]));
|
|
2625
|
+
const trendBase = isTrendChart && dataKeys.length === 1 ? buildTrend(values, valueFormat, formatters) : void 0;
|
|
2626
|
+
const trendRows = trendBase ? data.filter((point) => typeof point[dataKeys[0]] === "number") : [];
|
|
2627
|
+
const range = trendBase && xAxisKey ? [trendRows[0], trendRows[trendRows.length - 1]].map((point) => chartCellText(point[xAxisKey])).filter(Boolean).join(" \u2013 ") || void 0 : void 0;
|
|
2628
|
+
const trend = trendBase ? { ...trendBase, range } : void 0;
|
|
2629
|
+
const tickSamples = [...yDomain ?? [], ...values].map((value) => formatters.tick(value));
|
|
2630
|
+
const showDots = data.length <= DOT_LIMIT;
|
|
2631
|
+
return {
|
|
2632
|
+
isTrendChart,
|
|
2633
|
+
plottedKeys,
|
|
2634
|
+
seriesLabels,
|
|
2635
|
+
labelKey: chartType === "pie" ? xAxisKey || "name" : xAxisKey,
|
|
2636
|
+
values,
|
|
2637
|
+
yTicks,
|
|
2638
|
+
yDomain,
|
|
2639
|
+
formatters,
|
|
2640
|
+
trend,
|
|
2641
|
+
title: title ?? (trend ? seriesLabels[dataKeys[0]] : void 0),
|
|
2642
|
+
showDots,
|
|
2643
|
+
endIndexes: Object.fromEntries(plottedKeys.map((key) => [key, lastValueIndex(data, key)])),
|
|
2644
|
+
curve: showDots ? "linear" : "monotone",
|
|
2645
|
+
hasNegative: values.some((value) => value < 0),
|
|
2646
|
+
longestTickLength: tickSamples.reduce((max, label) => Math.max(max, label.length), 0),
|
|
2647
|
+
total: values.reduce((sum, value) => sum + value, 0)
|
|
2648
|
+
};
|
|
2649
|
+
}
|
|
2650
|
+
|
|
2499
2651
|
// src/tools/choice.ts
|
|
2500
2652
|
var CHOICE_TOOL_NAME = "prompt_user_choice";
|
|
2501
2653
|
function createChoiceTool(options) {
|
|
@@ -13978,11 +14130,14 @@ export {
|
|
|
13978
14130
|
auditDesign,
|
|
13979
14131
|
buildAppFileManifest,
|
|
13980
14132
|
buildAppSystemPrompt,
|
|
14133
|
+
buildChartModel,
|
|
13981
14134
|
buildConnectorErrorResult,
|
|
13982
14135
|
buildDocumentSystemPrompt,
|
|
13983
14136
|
buildFontsUrl,
|
|
13984
14137
|
buildSlideSystemPrompt,
|
|
13985
14138
|
callNotionMCPTool,
|
|
14139
|
+
chartCellText,
|
|
14140
|
+
chartSeriesLabel,
|
|
13986
14141
|
connectorMintErrorToToolResult,
|
|
13987
14142
|
convertLegacyDeckJson,
|
|
13988
14143
|
createAgentresClient,
|
|
@@ -5,7 +5,13 @@ type LlmapiChatCompletionTool = {
|
|
|
5
5
|
/**
|
|
6
6
|
* Tool executor function type
|
|
7
7
|
*/
|
|
8
|
-
type ToolExecutor = (args: Record<string, unknown>, signal?: AbortSignal) => Promise<unknown> | unknown;
|
|
8
|
+
type ToolExecutor = (args: Record<string, unknown>, signal?: AbortSignal, context?: ToolExecutionContext) => Promise<unknown> | unknown;
|
|
9
|
+
/** How the portal treats a call to this device tool while the device is away. */
|
|
10
|
+
type DetachedToolClass = "render" | "deferred";
|
|
11
|
+
/** Context for one executor run; `detached` marks a call from an answer finished while the device was away. */
|
|
12
|
+
type ToolExecutionContext = {
|
|
13
|
+
detached?: boolean;
|
|
14
|
+
};
|
|
9
15
|
/**
|
|
10
16
|
* Tool configuration with optional executor
|
|
11
17
|
*/
|
|
@@ -75,6 +81,8 @@ type ToolConfig = LlmapiChatCompletionTool & {
|
|
|
75
81
|
* files from IndexedDB that `create_file` writes.
|
|
76
82
|
*/
|
|
77
83
|
dependsOn?: string[];
|
|
84
|
+
/** How the portal handles a call to this tool while the device is away; unset tools pause the turn. */
|
|
85
|
+
detachedClass?: DetachedToolClass;
|
|
78
86
|
};
|
|
79
87
|
|
|
80
88
|
/** Tool parameters schema */
|
|
@@ -5,7 +5,13 @@ type LlmapiChatCompletionTool = {
|
|
|
5
5
|
/**
|
|
6
6
|
* Tool executor function type
|
|
7
7
|
*/
|
|
8
|
-
type ToolExecutor = (args: Record<string, unknown>, signal?: AbortSignal) => Promise<unknown> | unknown;
|
|
8
|
+
type ToolExecutor = (args: Record<string, unknown>, signal?: AbortSignal, context?: ToolExecutionContext) => Promise<unknown> | unknown;
|
|
9
|
+
/** How the portal treats a call to this device tool while the device is away. */
|
|
10
|
+
type DetachedToolClass = "render" | "deferred";
|
|
11
|
+
/** Context for one executor run; `detached` marks a call from an answer finished while the device was away. */
|
|
12
|
+
type ToolExecutionContext = {
|
|
13
|
+
detached?: boolean;
|
|
14
|
+
};
|
|
9
15
|
/**
|
|
10
16
|
* Tool configuration with optional executor
|
|
11
17
|
*/
|
|
@@ -75,6 +81,8 @@ type ToolConfig = LlmapiChatCompletionTool & {
|
|
|
75
81
|
* files from IndexedDB that `create_file` writes.
|
|
76
82
|
*/
|
|
77
83
|
dependsOn?: string[];
|
|
84
|
+
/** How the portal handles a call to this tool while the device is away; unset tools pause the turn. */
|
|
85
|
+
detachedClass?: DetachedToolClass;
|
|
78
86
|
};
|
|
79
87
|
|
|
80
88
|
/** Tool parameters schema */
|