@tbox.cn/app-agent-sdk-server 0.1.0 → 0.1.2

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.
@@ -153,11 +153,13 @@ type ContentPart = ImagePart | TextPart;
153
153
  declare function buildUserContent(text: string, mediaItems?: SendMessageMediaItem[], fileUrlPrefix?: string): string | ContentPart[];
154
154
  /**
155
155
  * 轮级注入块组(composeTurnUserContent 输入)。
156
- * 块语义见 platform-instructions 注入块协议节(四类块清单)。
156
+ * 块语义见 platform-instructions 注入块协议节(五类块清单)。
157
157
  */
158
158
  interface TurnReminderBlocks {
159
159
  /** card-decision 决策提醒块(modelEnabled 轮恒注入) */
160
160
  cardDecision?: string;
161
+ /** runtime-context 服务端可信运行时间块(配置后 modelEnabled 轮恒注入) */
162
+ runtimeContext?: string;
161
163
  /** pre-tool 预执行数据块(每 done 工具一个,按完成序) */
162
164
  preToolBlocks?: string[];
163
165
  /** memory 背景数据块(recall 命中轮) */
@@ -167,7 +169,7 @@ interface TurnReminderBlocks {
167
169
  }
168
170
  /**
169
171
  * 轮级 user 内容统一组装(W3,2026-09-01;顺序契约唯一真源):
170
- * `[card-decision → preTool₁..n → memory → skill → userText]`。
172
+ * `[card-decision → runtime-context → preTool₁..n → memory → skill → userText]`。
171
173
  * 分组逻辑:协议指令 → 本轮数据族(前景 preTool + 背景 memory 相邻)→ 域规程(紧邻正文,
172
174
  * 注意力就近)→ 正文。chat() 与 submitForm 单点共用;与 buildInjectedUserContent 字节级同构
173
175
  * (仅传 skillBlock 时产物恒等——测试钉死)。
@@ -554,7 +556,7 @@ declare function withRecallCache(store: MemoryStore, opts?: RecallCacheOptions):
554
556
  * trace-transform → recall → logger → trace-exporter → trace-transform)。
555
557
  *
556
558
  * 块协议:`<system-reminder …>…</system-reminder>`(skill / preTool / memory /
557
- * card-decision 四类注入块统一围栏,属性不限——见 platform-instructions)。
559
+ * card-decision / runtime-context 五类注入块统一围栏,属性不限——见 platform-instructions)。
558
560
  */
559
561
  /**
560
562
  * 剥离完整 `<system-reminder …>` 块(任意属性——skill/preTool/memory 等注入块):
@@ -1124,6 +1126,29 @@ interface EngineStepController {
1124
1126
  }
1125
1127
  type EngineStepControlFactory = (input: EngineStepControlInput) => EngineStepController | Promise<EngineStepController>;
1126
1128
 
1129
+ interface RuntimeContextOptions {
1130
+ readonly timeZone: string;
1131
+ readonly now?: () => number;
1132
+ }
1133
+ interface ResolvedRuntimeContextOptions {
1134
+ readonly timeZone: string;
1135
+ readonly now: () => number;
1136
+ }
1137
+ interface RuntimeTemporalContext {
1138
+ readonly v: 1;
1139
+ readonly asOf: string;
1140
+ readonly timeZone: string;
1141
+ }
1142
+ interface RuntimeTemporalContextSnapshot {
1143
+ readonly startedAt: number;
1144
+ readonly context: RuntimeTemporalContext;
1145
+ readonly reminder: string;
1146
+ }
1147
+ /** Validate once at engine construction and retain the canonical IANA identifier. */
1148
+ declare function resolveRuntimeContextOptions(options: RuntimeContextOptions): ResolvedRuntimeContextOptions;
1149
+ /** Build one temporal snapshot for a model run. The clock is sampled exactly once. */
1150
+ declare function createRuntimeTemporalContext(options: ResolvedRuntimeContextOptions): RuntimeTemporalContextSnapshot;
1151
+
1127
1152
  interface ChatEngineOptions {
1128
1153
  instructions: string;
1129
1154
  model: any;
@@ -1132,6 +1157,8 @@ interface ChatEngineOptions {
1132
1157
  cardRegistry: Record<string, CardMeta>;
1133
1158
  /** Optional run-local, domain-neutral model/tool control. Not used by deterministic or form paths. */
1134
1159
  stepControl?: EngineStepControlFactory;
1160
+ /** 服务端可信运行时间上下文;仅模型路径按 run 注入,不进入前端事件或 saveMessage。 */
1161
+ runtimeContext?: RuntimeContextOptions;
1135
1162
  /** trace exporter(默认使用 SDK 内置单例) */
1136
1163
  traceExporter?: TboxTraceExporter;
1137
1164
  /** 文件 URL 前缀(content-builder 用) */
@@ -1739,6 +1766,8 @@ interface BuildEngineOptions extends SdkRuntimeOptions {
1739
1766
  */
1740
1767
  memoryInstructions?: string;
1741
1768
  model: unknown;
1769
+ /** 服务端可信运行时间上下文(构造期校验时区;每个 model run 独立采样) */
1770
+ runtimeContext?: ChatEngineOptions['runtimeContext'];
1742
1771
  stepControl?: ChatEngineOptions['stepControl'];
1743
1772
  /** 模型名(日志用) */
1744
1773
  modelName?: string;
@@ -2279,4 +2308,4 @@ interface SampleShapeReport {
2279
2308
  */
2280
2309
  declare function findSampleShapeViolations(meta: CardMeta): SampleShapeReport;
2281
2310
 
2282
- export { type AnyTool, BROAD_ROUTING_TERMS, BUILTIN_HYGIENE_NAMES, type BootstrapMemoryKbOptions, type BootstrapMemoryKbResult, type BuildEngineOptions, CARDS_SPEC, CARD_DECISION_HOLD_LIMIT, CARD_DECISION_TAG, CARD_EMISSION_HINT_ACTIONS, CARD_EMISSION_HINT_BASE, CARD_EMISSION_HINT_KEYWORD, type CardDecisionPlan, type CardDecisionStripper, type CardPersistenceBackend, type CardPool, type CardPoolOptions, 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, EARLY_EXECUTION_MARKER, type EngineModelStepInput, 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, type PoolEntry, type PreFilterTerm, type PreToolExecContext, PreToolTimeoutError, PreviewActionError, type QuickCommand, type RecallCacheOptions, type RecallCacheState, type ResolvedTagSpecs, 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, TOOL_CARDS_FIELD, TOOL_CARD_DESCRIPTOR_SCHEMA, type TagBodyPolicy, type TagEngineFinish, type TagHit, type TagSeal, type TagSource, type TagSpec, type TagTrack, TboxTraceExporter, type ThinkingControl, type ToolCardDescriptor, type ToolCardSpec, type ToolExecContextLike, type ToolRunMetadata, type TurnReminderBlocks, applySkillReminder, bootstrapMemoryKnowledgeBase, buildCardDecisionReminder, buildInjectedUserContent, buildMemoryRecallToolCallEvents, buildMemoryReminder, buildMessageInputs, buildPlatformInstructions, buildPreToolCallEndEvents, buildPreToolCallStartEvents, buildPreToolDirectives, buildRecapUserContent, buildSkillRecapReminder, buildSkillReminder, buildSkillToolCallEvents, buildUserContent, captureToolCards, clampMaxCards, clampMemoryMaxChars, clampMemoryTopK, coerceStringifiedFields, composeTurnUserContent, createCardDecisionStripper, createCardPool, createCardTool, createChatEngine, createConversationRouter, createEngineFromContext, createGatedMemoryStore, createInMemoryMemoryStore, createIntentDispatcher, createKnowledgeMemoryStore, createKnowledgeOpenapiTransport, createMemoryRouter, createMemoryTools, createModelProvider, createPlatformApiRouter, createPluginIntegration, createSdkToolRuntime, createStreamTagEngine, createToolExecContext, createTtsProxy, createWsServer, decideCards, decideSkillInjection, definePreTool, envelopeTag, executePreTool, extractImageUrls, findSampleShapeViolations, formSubmitTool, generateMemoryId, getLastRecallCacheState, getToolRequestContext, getToolRunMetadata, getTtsClient, hardenToolsForLlm, hashContent, healthRouter, hygieneXmlTag, installTboxDev, internalTool, loadAgentPromptConfig, loadChatConfig, loadLocalSkills, loadModuleSkills, matchIntent, memoryStoreCapabilities, mergePreTools, mergeSkills, normalizePreTools, omitInternal, pickFallbackCard, projectHistory, recallMemories, requireToolRequestContext, resetTtsClient, resolveEarlyToolExecution, resolveMaxSteps, resolveMemoryEngineOptions, resolveMemoryRecallTimeout, resolveMemoryStore, resolveMemoryStoreGuarded, resolveMemoryValidateMode, resolveMemoryValidateTimeout, resolvePreToolTimeout, resolveSkillMode, resolveTagSpecs, resolveToolDebug, restoreCardSnapshot, sanitizeLlmToolInput, scanInjectedSkills, scopeToKey, selectPreTools, selectSkill, stableStringify, stripSystemReminderBlocks, router as tboxSessionRouter, tboxTraceExporter, toCardSnapshot, toMastraSkill, toWsChatConfig, tokenizeTagBody, toolCardScope, validateMemoryKnowledgeBase, withCardEmissionHint, withDeadline, withEarlyExecution, withLlmInputSanitize, withRecallCache, wrapToolsForCardCapture, xmlTag, xmlTagDecision };
2311
+ export { type AnyTool, BROAD_ROUTING_TERMS, BUILTIN_HYGIENE_NAMES, type BootstrapMemoryKbOptions, type BootstrapMemoryKbResult, type BuildEngineOptions, CARDS_SPEC, CARD_DECISION_HOLD_LIMIT, CARD_DECISION_TAG, CARD_EMISSION_HINT_ACTIONS, CARD_EMISSION_HINT_BASE, CARD_EMISSION_HINT_KEYWORD, type CardDecisionPlan, type CardDecisionStripper, type CardPersistenceBackend, type CardPool, type CardPoolOptions, 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, EARLY_EXECUTION_MARKER, type EngineModelStepInput, 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, type PoolEntry, type PreFilterTerm, type PreToolExecContext, PreToolTimeoutError, PreviewActionError, type QuickCommand, 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, TOOL_CARDS_FIELD, TOOL_CARD_DESCRIPTOR_SCHEMA, type TagBodyPolicy, type TagEngineFinish, type TagHit, type TagSeal, type TagSource, type TagSpec, type TagTrack, TboxTraceExporter, type ThinkingControl, type ToolCardDescriptor, type ToolCardSpec, type ToolExecContextLike, type ToolRunMetadata, type TurnReminderBlocks, applySkillReminder, bootstrapMemoryKnowledgeBase, buildCardDecisionReminder, buildInjectedUserContent, buildMemoryRecallToolCallEvents, buildMemoryReminder, buildMessageInputs, buildPlatformInstructions, buildPreToolCallEndEvents, buildPreToolCallStartEvents, buildPreToolDirectives, buildRecapUserContent, buildSkillRecapReminder, buildSkillReminder, buildSkillToolCallEvents, buildUserContent, captureToolCards, clampMaxCards, clampMemoryMaxChars, clampMemoryTopK, coerceStringifiedFields, composeTurnUserContent, createCardDecisionStripper, createCardPool, createCardTool, createChatEngine, createConversationRouter, createEngineFromContext, createGatedMemoryStore, createInMemoryMemoryStore, createIntentDispatcher, createKnowledgeMemoryStore, createKnowledgeOpenapiTransport, createMemoryRouter, createMemoryTools, createModelProvider, createPlatformApiRouter, createPluginIntegration, createRuntimeTemporalContext, createSdkToolRuntime, createStreamTagEngine, createToolExecContext, createTtsProxy, createWsServer, decideCards, decideSkillInjection, definePreTool, envelopeTag, executePreTool, extractImageUrls, findSampleShapeViolations, formSubmitTool, generateMemoryId, getLastRecallCacheState, getToolRequestContext, getToolRunMetadata, getTtsClient, hardenToolsForLlm, hashContent, healthRouter, hygieneXmlTag, installTboxDev, internalTool, loadAgentPromptConfig, loadChatConfig, loadLocalSkills, loadModuleSkills, matchIntent, memoryStoreCapabilities, mergePreTools, mergeSkills, normalizePreTools, omitInternal, pickFallbackCard, projectHistory, recallMemories, requireToolRequestContext, 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, toolCardScope, validateMemoryKnowledgeBase, withCardEmissionHint, withDeadline, withEarlyExecution, withLlmInputSanitize, withRecallCache, wrapToolsForCardCapture, xmlTag, xmlTagDecision };