@tbox.cn/app-agent-sdk-server 1.0.0-alpha.7 → 1.0.0-alpha.8

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.
@@ -204,4 +204,4 @@ declare function toolUser(execCtx: ToolExecContextLike, toolId?: string): {
204
204
  avatar?: string;
205
205
  };
206
206
 
207
- export { type CardPool as C, type PoolEntry as P, type RegisteredUserState as R, TOOL_CARDS_FIELD as T, type UserState as U, CARD_EMISSION_HINT_ACTIONS as a, CARD_EMISSION_HINT_BASE as b, CARD_EMISSION_HINT_KEYWORD as c, type CardPoolOptions as d, type CreateUserStateOptions as e, TOOL_CARD_DESCRIPTOR_SCHEMA as f, type ToolCardDescriptor as g, type ToolCardSpec as h, type ToolExecContextLike as i, type ToolRunMetadata as j, captureToolCards as k, cardOf as l, createCardPool as m, createToolExecContext as n, createUserState as o, defineCardMeta as p, getToolRequestContext as q, getToolRunMetadata as r, requireToolRequestContext as s, toolCardScope as t, userStates as u, toolUser as v, wrapToolsForCardCapture as w };
207
+ export { type CardPool as C, type PoolEntry as P, type RegisteredUserState as R, type ToolCardSpec as T, type UserState as U, CARD_EMISSION_HINT_ACTIONS as a, CARD_EMISSION_HINT_BASE as b, CARD_EMISSION_HINT_KEYWORD as c, type CardPoolOptions as d, type CreateUserStateOptions as e, TOOL_CARDS_FIELD as f, TOOL_CARD_DESCRIPTOR_SCHEMA as g, type ToolCardDescriptor as h, type ToolExecContextLike as i, type ToolRunMetadata as j, captureToolCards as k, cardOf as l, createCardPool as m, createToolExecContext as n, createUserState as o, defineCardMeta as p, getToolRequestContext as q, getToolRunMetadata as r, requireToolRequestContext as s, toolCardScope as t, userStates as u, toolUser as v, wrapToolsForCardCapture as w };
@@ -3,14 +3,14 @@ export * from '@tbox.cn/app-sdk-server';
3
3
  export { LocalSkill, TtsVoiceConfig } from '@tbox.cn/app-sdk-server';
4
4
  export { InferModuleCards } from '@tbox.cn/app-sdk-core';
5
5
  import * as _tbox_cn_app_contracts from '@tbox.cn/app-contracts';
6
- import { SendMessageMediaItem, SkillRecord, ServerEvent, PreToolRecord, MemoryKind, MemoryRecord, MemoryStore, MemoryStoreCapabilities, MemoryErrorCode, RequestContext as RequestContext$1, CardMeta, CardSnapshot, Identity, ExternalCredentials, HelloAckChatConfig, CardActionResult, TboxCardPayload } from '@tbox.cn/app-contracts';
6
+ import { SendMessageMediaItem, SkillRecord, ServerEvent, PreToolRecord, MemoryKind, MemoryRecord, MemoryStore, MemoryStoreCapabilities, MemoryErrorCode, RequestContext as RequestContext$1, CardMeta, CardSnapshot, Identity, ExternalCredentials, HelloAckChatConfig, CardView, cardViewSchema, CardActionResult, TboxCardPayload } from '@tbox.cn/app-contracts';
7
7
  import * as _mastra_core_tools from '@mastra/core/tools';
8
8
  import { Tool, createTool } from '@mastra/core/tools';
9
9
  export { Tool, createTool } from '@mastra/core/tools';
10
10
  import { ObservabilityExporter, TracingEvent, SpanType } from '@mastra/core/observability';
11
11
  import { ModelMessage, LanguageModel } from 'ai';
12
- import { P as PoolEntry, C as CardPool } from '../app-primitives-BU-_eI-T.js';
13
- export { a as CARD_EMISSION_HINT_ACTIONS, b as CARD_EMISSION_HINT_BASE, c as CARD_EMISSION_HINT_KEYWORD, d as CardPoolOptions, e as CreateUserStateOptions, R as RegisteredUserState, T as TOOL_CARDS_FIELD, f as TOOL_CARD_DESCRIPTOR_SCHEMA, g as ToolCardDescriptor, h as ToolCardSpec, i as ToolExecContextLike, j as ToolRunMetadata, U as UserState, k as captureToolCards, l as cardOf, m as createCardPool, n as createToolExecContext, o as createUserState, p as defineCardMeta, q as getToolRequestContext, r as getToolRunMetadata, s as requireToolRequestContext, t as toolCardScope, v as toolUser, u as userStates, w as wrapToolsForCardCapture } from '../app-primitives-BU-_eI-T.js';
12
+ import { P as PoolEntry, C as CardPool, T as ToolCardSpec } from '../app-primitives-DYbywZcQ.js';
13
+ export { a as CARD_EMISSION_HINT_ACTIONS, b as CARD_EMISSION_HINT_BASE, c as CARD_EMISSION_HINT_KEYWORD, d as CardPoolOptions, e as CreateUserStateOptions, R as RegisteredUserState, f as TOOL_CARDS_FIELD, g as TOOL_CARD_DESCRIPTOR_SCHEMA, h as ToolCardDescriptor, i as ToolExecContextLike, j as ToolRunMetadata, U as UserState, k as captureToolCards, l as cardOf, m as createCardPool, n as createToolExecContext, o as createUserState, p as defineCardMeta, q as getToolRequestContext, r as getToolRunMetadata, s as requireToolRequestContext, t as toolCardScope, v as toolUser, u as userStates, w as wrapToolsForCardCapture } from '../app-primitives-DYbywZcQ.js';
14
14
  import { ZodTypeAny, z } from 'zod';
15
15
  import { SkillInput } from '@mastra/core/skills';
16
16
  import { RequestContext } from '@mastra/core/request-context';
@@ -1886,6 +1886,45 @@ interface CreateCardToolOptions<TSchema extends ZodTypeAny> {
1886
1886
  }
1887
1887
  declare function createCardTool<TSchema extends ZodTypeAny>(opts: CreateCardToolOptions<TSchema>): _mastra_core_tools.Tool<TSchema extends _mastra_core_schema.PublicSchema<any> ? _mastra_core_schema.InferPublicSchema<TSchema> : unknown, unknown, unknown, unknown, _mastra_core_tools.ToolExecutionContext<unknown, unknown, unknown>, string, unknown>;
1888
1888
 
1889
+ /**
1890
+ * defineViewCard:一张卡只有服务端一个文件。
1891
+ *
1892
+ * - 卡的 data 就是视图 JSON(CardView),dataSchema = cardViewSchema;
1893
+ * - 样例由 view(state) 派生,不再手写大段 sampleData;
1894
+ * - app-build 见到 meta 上的 view 标记时,自动派生客户端 stub(ViewCard),
1895
+ * 不再要求 apps/client/src/cards/<id>.card.tsx 成对文件。
1896
+ */
1897
+
1898
+ interface ViewCardSampleState<T> {
1899
+ /** 样本名(考察点短标签) */
1900
+ label: string;
1901
+ /** 考察点说明 */
1902
+ note?: string;
1903
+ /** 该状态的领域数据;渲染前经 view() 转成视图 JSON */
1904
+ state: T;
1905
+ }
1906
+ interface DefineViewCardOptions<T> {
1907
+ cardType: string;
1908
+ displayName: string;
1909
+ description: string;
1910
+ /** 领域数据 -> 视图 JSON(纯函数:不读 IO、不依赖 React) */
1911
+ view: (data: T) => CardView;
1912
+ /** 基准态领域数据(sampleData 由它派生) */
1913
+ sampleState: T;
1914
+ /** 附加状态样本 */
1915
+ samples?: ViewCardSampleState<T>[];
1916
+ schemaVersion?: number;
1917
+ }
1918
+ type ViewCardMeta<T> = Omit<CardMeta<typeof cardViewSchema>, 'view'> & {
1919
+ view: (data: T) => CardView;
1920
+ };
1921
+ declare function defineViewCard<T>(options: DefineViewCardOptions<T>): ViewCardMeta<T>;
1922
+ /**
1923
+ * 出卡:领域数据 -> 视图 JSON -> 出卡条目。
1924
+ * 生产侧先 normalize(截断超预算),再交给 tool-cards 的统一校验,不整张卡丢弃。
1925
+ */
1926
+ declare function cardOfView<T>(meta: ViewCardMeta<T>, data: T, note: string): ToolCardSpec;
1927
+
1889
1928
  /**
1890
1929
  * 应用级卡片动作:把「点了按钮之后确定要发生什么」从模型手里拿走。
1891
1930
  *
@@ -2331,4 +2370,4 @@ interface SampleShapeReport {
2331
2370
  */
2332
2371
  declare function findSampleShapeViolations(meta: CardMeta): SampleShapeReport;
2333
2372
 
2334
- export { type ActionDefinition, type AnyTool, BROAD_ROUTING_TERMS, BUILTIN_HYGIENE_NAMES, type BootstrapMemoryKbOptions, type BootstrapMemoryKbResult, type BuildEngineOptions, CARDS_SPEC, CARD_DECISION_HOLD_LIMIT, CARD_DECISION_TAG, type CardDecisionPlan, type CardDecisionStripper, type CardPersistenceBackend, CardPool, type ChatEngine, type ChatEngineOptions, type ContentPart, type ContentTagHygiene, type ConversationRouterDeps, ConversationService, DECISION_HOLD_LIMIT, DEFAULT_INSTRUCTIONS, DEFAULT_KNOWLEDGE_MEMORY_CAPABILITIES, DEFAULT_LIST_TTL_MS, DEFAULT_LLM_PROVIDER_CONFIG_PATH, DEFAULT_MAX_CARDS_PER_TURN, DEFAULT_MAX_ENTRIES, DEFAULT_MAX_PRE_TOOLS_PER_RUN, DEFAULT_MEMORY_MAX_CHARS_PER_RECORD, DEFAULT_MEMORY_RECALL_TIMEOUT_MS, DEFAULT_MEMORY_TOP_K, DEFAULT_MEMORY_VALIDATE_TIMEOUT_MS, DEFAULT_PRE_TOOL_TIMEOUT_MS, DEFAULT_SKILL_MODE, DROP_BODY_SOFT_LIMIT, type DefineToolContext, type DefineToolIdentity, type DefineToolOptions, type DefinedAction, EARLY_EXECUTION_MARKER, type EngineModelStepInput, type EnginePreModelActivityAttestation, type EngineRunEndInput, type EngineRunInput, type EngineStepControlFactory, type EngineStepControlInput, type EngineStepController, type EngineStepResultInput, type EngineStepToolChoice, type EngineToolCallInput, type EngineToolResultInput, FORM_SUBMIT_TOOL_ID, FileCardPersistenceBackend, HYGIENE_TAG_NORMALIZE, type HygieneTagFamily, INTERNAL_TOOL, type InstallTboxDevDeps, type IntentRoute, KB_SCOPE_GLOBAL, KNOWLEDGE_DEFAULT_BASE_URL, KnowledgeBootstrapError, type KnowledgeMemoryStoreOptions, KnowledgeOpenapiError, type KnowledgeOpenapiTransportOptions, type KnowledgeTransport, type LoadedAgentPromptConfig, type LoadedChatConfig, type LoadedPluginTools, MEMORY_IMPORTANCE_BASE, MEMORY_KB_INDEX_COLUMNS, MEMORY_KB_SCHEMA, MEMORY_KB_SEED_CSV, MEMORY_LIST_DEFAULT_LIMIT, MEMORY_LIST_MAX_LIMIT, MEMORY_MAX_PER_USER, type MemoryEngineOptions, type MemoryFilterColumn, type MemoryGuardDeps, type MemoryGuardEnv, type MemoryPromptCaps, type MemoryRouterDeps, type MemoryStoreEnv, MemoryStoreUnsupportedError, type MemoryToolDeps, MemoryUnavailableError, type MemoryValidateMode, type MemoryValidationOutcome, MessageEmbeddedBackend, type ModelProviderOptions, PRE_TOOL_HISTORY_LIMIT, type ParallelToolCallsControl, type PlatformApiRouterDeps, type PluginIntegrationOptions, PoolEntry, type PreFilterTerm, type PreToolExecContext, PreToolTimeoutError, PreviewActionError, type QuickCommand, RAW_TOOL_INPUT_BOUNDARY, type RawToolInputBoundary, type RawToolInputBoundaryResult, type RecallCacheOptions, type RecallCacheState, type ResolvedRuntimeContextOptions, type ResolvedTagSpecs, type RuntimeContextOptions, type RuntimeTemporalContext, type RuntimeTemporalContextSnapshot, type SampleShapeBlindSpot, type SampleShapeReport, type SampleShapeViolation, type SdkRuntimeOptions, type SdkToolRuntime, type SegmentHit, type SkillInjectionDecision, type SkillMode, type SortTerm, type StoredMemoryRecord, type StreamTagEngine, DEFAULT_FILE_URL_PREFIX as TBOX_FILE_URL_PREFIX, THINK_SPECS, TOOL_CALL_TEXT_SPECS, type TagBodyPolicy, type TagEngineFinish, type TagHit, type TagSeal, type TagSource, type TagSpec, type TagTrack, TboxTraceExporter, type ThinkingControl, type TurnReminderBlocks, actionResult, applySkillReminder, bootstrapMemoryKnowledgeBase, buildCardDecisionReminder, buildInjectedUserContent, buildMemoryRecallToolCallEvents, buildMemoryReminder, buildMessageInputs, buildPlatformInstructions, buildPreToolCallEndEvents, buildPreToolCallStartEvents, buildPreToolDirectives, buildRecapUserContent, buildSkillRecapReminder, buildSkillReminder, buildSkillToolCallEvents, buildUserContent, cardResult, clampMaxCards, clampMemoryMaxChars, clampMemoryTopK, coerceStringifiedFields, composeTurnUserContent, createCardDecisionStripper, createCardTool, createChatEngine, createConversationRouter, createEngineFromContext, createGatedMemoryStore, createInMemoryMemoryStore, createIntentDispatcher, createKnowledgeMemoryStore, createKnowledgeOpenapiTransport, createMemoryRouter, createMemoryTools, createModelProvider, createPlatformApiRouter, createPluginIntegration, createRuntimeTemporalContext, createSdkToolRuntime, createStreamTagEngine, createTtsProxy, createWsServer, decideCards, decideSkillInjection, defineAction, definePreTool, defineTool, envelopeTag, executePreTool, extractImageUrls, findSampleShapeViolations, formSubmitTool, generateMemoryId, getLastRecallCacheState, getTtsClient, hardenToolsForLlm, hashContent, healthRouter, hygieneXmlTag, installTboxDev, internalTool, isCleanPreModelActivityAttestation, loadAgentPromptConfig, loadChatConfig, loadLocalSkills, loadModuleSkills, matchIntent, memoryStoreCapabilities, mergePreTools, mergeSkills, normalizePreTools, noticeResult, omitInternal, pickFallbackCard, projectHistory, recallMemories, resetTtsClient, resolveEarlyToolExecution, resolveMaxSteps, resolveMemoryEngineOptions, resolveMemoryRecallTimeout, resolveMemoryStore, resolveMemoryStoreGuarded, resolveMemoryValidateMode, resolveMemoryValidateTimeout, resolvePreToolTimeout, resolveRuntimeContextOptions, resolveSkillMode, resolveTagSpecs, resolveToolDebug, restoreCardSnapshot, sanitizeLlmToolInput, scanInjectedSkills, scopeToKey, selectPreTools, selectSkill, stableStringify, stripSystemReminderBlocks, router as tboxSessionRouter, tboxTraceExporter, toCardSnapshot, toMastraSkill, toWsChatConfig, tokenizeTagBody, updateResult, validateMemoryKnowledgeBase, withCardEmissionHint, withDeadline, withEarlyExecution, withLlmInputSanitize, withRawToolInputBoundary, withRecallCache, xmlTag, xmlTagDecision };
2373
+ export { type ActionDefinition, type AnyTool, BROAD_ROUTING_TERMS, BUILTIN_HYGIENE_NAMES, type BootstrapMemoryKbOptions, type BootstrapMemoryKbResult, type BuildEngineOptions, CARDS_SPEC, CARD_DECISION_HOLD_LIMIT, CARD_DECISION_TAG, type CardDecisionPlan, type CardDecisionStripper, type CardPersistenceBackend, CardPool, type ChatEngine, type ChatEngineOptions, type ContentPart, type ContentTagHygiene, type ConversationRouterDeps, ConversationService, DECISION_HOLD_LIMIT, DEFAULT_INSTRUCTIONS, DEFAULT_KNOWLEDGE_MEMORY_CAPABILITIES, DEFAULT_LIST_TTL_MS, DEFAULT_LLM_PROVIDER_CONFIG_PATH, DEFAULT_MAX_CARDS_PER_TURN, DEFAULT_MAX_ENTRIES, DEFAULT_MAX_PRE_TOOLS_PER_RUN, DEFAULT_MEMORY_MAX_CHARS_PER_RECORD, DEFAULT_MEMORY_RECALL_TIMEOUT_MS, DEFAULT_MEMORY_TOP_K, DEFAULT_MEMORY_VALIDATE_TIMEOUT_MS, DEFAULT_PRE_TOOL_TIMEOUT_MS, DEFAULT_SKILL_MODE, DROP_BODY_SOFT_LIMIT, type DefineToolContext, type DefineToolIdentity, type DefineToolOptions, type DefineViewCardOptions, type DefinedAction, EARLY_EXECUTION_MARKER, type EngineModelStepInput, type EnginePreModelActivityAttestation, type EngineRunEndInput, type EngineRunInput, type EngineStepControlFactory, type EngineStepControlInput, type EngineStepController, type EngineStepResultInput, type EngineStepToolChoice, type EngineToolCallInput, type EngineToolResultInput, FORM_SUBMIT_TOOL_ID, FileCardPersistenceBackend, HYGIENE_TAG_NORMALIZE, type HygieneTagFamily, INTERNAL_TOOL, type InstallTboxDevDeps, type IntentRoute, KB_SCOPE_GLOBAL, KNOWLEDGE_DEFAULT_BASE_URL, KnowledgeBootstrapError, type KnowledgeMemoryStoreOptions, KnowledgeOpenapiError, type KnowledgeOpenapiTransportOptions, type KnowledgeTransport, type LoadedAgentPromptConfig, type LoadedChatConfig, type LoadedPluginTools, MEMORY_IMPORTANCE_BASE, MEMORY_KB_INDEX_COLUMNS, MEMORY_KB_SCHEMA, MEMORY_KB_SEED_CSV, MEMORY_LIST_DEFAULT_LIMIT, MEMORY_LIST_MAX_LIMIT, MEMORY_MAX_PER_USER, type MemoryEngineOptions, type MemoryFilterColumn, type MemoryGuardDeps, type MemoryGuardEnv, type MemoryPromptCaps, type MemoryRouterDeps, type MemoryStoreEnv, MemoryStoreUnsupportedError, type MemoryToolDeps, MemoryUnavailableError, type MemoryValidateMode, type MemoryValidationOutcome, MessageEmbeddedBackend, type ModelProviderOptions, PRE_TOOL_HISTORY_LIMIT, type ParallelToolCallsControl, type PlatformApiRouterDeps, type PluginIntegrationOptions, PoolEntry, type PreFilterTerm, type PreToolExecContext, PreToolTimeoutError, PreviewActionError, type QuickCommand, RAW_TOOL_INPUT_BOUNDARY, type RawToolInputBoundary, type RawToolInputBoundaryResult, type RecallCacheOptions, type RecallCacheState, type ResolvedRuntimeContextOptions, type ResolvedTagSpecs, type RuntimeContextOptions, type RuntimeTemporalContext, type RuntimeTemporalContextSnapshot, type SampleShapeBlindSpot, type SampleShapeReport, type SampleShapeViolation, type SdkRuntimeOptions, type SdkToolRuntime, type SegmentHit, type SkillInjectionDecision, type SkillMode, type SortTerm, type StoredMemoryRecord, type StreamTagEngine, DEFAULT_FILE_URL_PREFIX as TBOX_FILE_URL_PREFIX, THINK_SPECS, TOOL_CALL_TEXT_SPECS, type TagBodyPolicy, type TagEngineFinish, type TagHit, type TagSeal, type TagSource, type TagSpec, type TagTrack, TboxTraceExporter, type ThinkingControl, ToolCardSpec, type TurnReminderBlocks, type ViewCardMeta, type ViewCardSampleState, actionResult, applySkillReminder, bootstrapMemoryKnowledgeBase, buildCardDecisionReminder, buildInjectedUserContent, buildMemoryRecallToolCallEvents, buildMemoryReminder, buildMessageInputs, buildPlatformInstructions, buildPreToolCallEndEvents, buildPreToolCallStartEvents, buildPreToolDirectives, buildRecapUserContent, buildSkillRecapReminder, buildSkillReminder, buildSkillToolCallEvents, buildUserContent, cardOfView, cardResult, clampMaxCards, clampMemoryMaxChars, clampMemoryTopK, coerceStringifiedFields, composeTurnUserContent, createCardDecisionStripper, createCardTool, createChatEngine, createConversationRouter, createEngineFromContext, createGatedMemoryStore, createInMemoryMemoryStore, createIntentDispatcher, createKnowledgeMemoryStore, createKnowledgeOpenapiTransport, createMemoryRouter, createMemoryTools, createModelProvider, createPlatformApiRouter, createPluginIntegration, createRuntimeTemporalContext, createSdkToolRuntime, createStreamTagEngine, createTtsProxy, createWsServer, decideCards, decideSkillInjection, defineAction, definePreTool, defineTool, defineViewCard, envelopeTag, executePreTool, extractImageUrls, findSampleShapeViolations, formSubmitTool, generateMemoryId, getLastRecallCacheState, getTtsClient, hardenToolsForLlm, hashContent, healthRouter, hygieneXmlTag, installTboxDev, internalTool, isCleanPreModelActivityAttestation, loadAgentPromptConfig, loadChatConfig, loadLocalSkills, loadModuleSkills, matchIntent, memoryStoreCapabilities, mergePreTools, mergeSkills, normalizePreTools, noticeResult, omitInternal, pickFallbackCard, projectHistory, recallMemories, resetTtsClient, resolveEarlyToolExecution, resolveMaxSteps, resolveMemoryEngineOptions, resolveMemoryRecallTimeout, resolveMemoryStore, resolveMemoryStoreGuarded, resolveMemoryValidateMode, resolveMemoryValidateTimeout, resolvePreToolTimeout, resolveRuntimeContextOptions, resolveSkillMode, resolveTagSpecs, resolveToolDebug, restoreCardSnapshot, sanitizeLlmToolInput, scanInjectedSkills, scopeToKey, selectPreTools, selectSkill, stableStringify, stripSystemReminderBlocks, router as tboxSessionRouter, tboxTraceExporter, toCardSnapshot, toMastraSkill, toWsChatConfig, tokenizeTagBody, updateResult, validateMemoryKnowledgeBase, withCardEmissionHint, withDeadline, withEarlyExecution, withLlmInputSanitize, withRawToolInputBoundary, withRecallCache, xmlTag, xmlTagDecision };