Support · 推荐实现与策略
共同合同与辅助入口
| 符号 | 类别 | 用途 |
|---|---|---|
agent | function | Instantiate an Engine configuration class without creating an Engine, budget or request. |
Agent | type | Original Engine configuration; union branches retain their required App/model relationships. |
AgentOptions | type | Agent id is an external pool identity, not an override of Core branch or request identity. |
agentPool | constant | |
AssociatedRegistration | interface | Owners retain their business fields; Support only reads model interface associations. |
AssociationOptions | interface | Shared independent tools and a default projection from existing contracts. |
AssociationSource | interface | Local provenance, never an extra model input requirement. |
ClassDecoration | type | |
DecorationOptions | interface | Namespaces group external registration without changing Core options. |
defineAssociatedCatalog | function | Compile independent and owner-derived Tool declarations, validating all references eagerly. |
DefinitionReader | interface | Read-only roots. A typed read describes the expected contract, not a static id/type lookup. |
fragment | function | Instantiate a self-describing fragment class; the original builder owns formatting checks. Bind a host's formatter method into an original fragment configuration. |
Fragment | type | A formatter and its original provenance, trust and budget configuration. |
fragmentPool | constant | |
IdentifiedDefinition | interface | Registration identity; ids are unique within one kind and namespace. |
Intent | function | Mark a WorkflowTool for demand discovery; alone this decorator registers nothing. |
MethodDecoration | type | |
model | function | Instantiate and validate model options without creating a Runner or consuming calls. |
Model | type | Original Runner configuration; the decorator's pool id is not a model identity override. |
ModelOptions | type | Model id is only a pool key; Core still owns the configured model/transport identities. |
modelPool | constant | |
node | function | Instantiate a node definition class once, injecting its id; graph validation stays in Workflow. Bind a named host method as run without renaming or manually binding the original object. |
Node | type | A node implementation; its public id is supplied by |
nodePool | constant | |
Support | namespace | |
tool | function | Instantiate a tool definition class; schema and authorization stay with existing defineTool. Bind an existing host method as the tool's execute callback. A model-only tool method provides its synchronous resolver. |
Tool | type | A tool implementation with the original schema, authorization and execution contracts. |
ToolAssociation | type | Explicit tool references or inline overrides of the owner's default model interface. |
toolPool | constant | |
workflow | function | Instantiate and validate workflow options, leaving actual execution with the original Engine. |
Workflow | type | A complete graph definition whose workflow id is supplied by |
workflowPool | constant |
工具与能力
| 符号 | 类别 | 用途 |
|---|---|---|
CapabilityCatalogOptions | interface | Catalog construction options. |
CapabilityModule | interface | Minimal composition contract; lifecycle and domain fields remain application-owned. |
CapabilityToolReferences | interface | Tool references declared by one owner module. |
CompiledTool | type | Tool definition type derived from a declaration literal, preserving input/output/id. |
defineCapabilityCatalog | function | Build a frozen capability catalog from application module declarations. Each module must carry a non-empty description, and every contributed tool ID must be unique across modules. Reference projections run during construction and must be synchronous. |
defineTool | function | Validate one tool declaration and freeze a detached copy of it. authorize must settle with void; a rejection has to be thrown, so a returned false cannot silently pass. Handlers are bound to the declaration object, and the input schema is re-snapshotted so later mutation cannot widen the accepted input. |
defineToolCatalog | function | Infer the host context from existing executable definitions, without widening it to unknown. Explicit host typing remains available for contextually typed declaration lists. |
SelectedTools | type | Catalog narrowed to the given ids: each kept tool's id literal is intersected with Id. |
ToolCatalog | interface | Frozen tool catalog with model tools and per-request binding. |
ToolCatalogEntry | type | Public declaration surface of one tool, without registry internals. |
ToolModelView | interface | Model capability view of a tool catalog, retaining the host context type. |
ToolOutput | type | Output type of the tool whose id matches Id; never for any other id. |
ToolRuntime | interface | Catalog bound to one App request. |
validateToolReferences | function | Validate tool references against the complete registered set. Checking against every registered tool (not only the ones available in the current request) keeps the declaration honest: a module may reference a tool that this request filters out, but never one that does not exist. |
模型与交互
| 符号 | 类别 | 用途 |
|---|---|---|
chatCompletionFunctionOptions | function | Build the tool-selection request fields for a function-calling stage. The adapter expects exactly one function call per response, so tool use is required and parallel calls are disabled. |
chatCompletionMessages | function | Map Core and provider messages to chat-completions message payloads. Only declared message fields are sent. Assistant tool declarations become nested tool_calls, and tool results become tool_call_id; both are rewritten explicitly rather than forwarded as-is. Messages with images become a content-block array; images are accepted only on user messages and only as http(s) or data:image URLs. |
chatCompletionParts | function | Convert one streamed choice.delta into Core model parts. Text is emitted only when non-empty; each tool-call fragment carries its index so Core can reassemble arguments that arrive across chunks. |
CompatibleModelConfig | interface | Configuration of one OpenAI-compatible endpoint. |
CompatibleModelPorts | interface | Adapter ports the App may override without replacing the provider. |
CompatibleModelProvider | class | HTTP/SSE lifecycle shared by hosts. Apps supply config and user-visible error mapping only. A static configuration is validated and frozen in the constructor. A configuration function is called once per request instead, so credentials and models may rotate between calls. |
CompatibleModelProviderOptions | interface | Construction options for a compatible provider. |
CompletionFailure | type | Build the classified failure a policy throws; the provider records it like its own failures. |
CompletionPolicy | interface | Decision whether a finished stream satisfies the request. |
completionPolicyCatalog | constant | |
CompletionRequestFacts | interface | Facts the provider reads from the request it actually sends. functions reports the Core call options and keeps the default policy equivalent to the behavior that existed before policies were configurable. toolChoice is the effective field of the serialized body, so a host override, or a field dropped for being undefined, is visible exactly as the upstream receives it. |
CompletionSession | interface | Per-request completion state observed by one policy. |
createJsonTransport | function | Create a typed JSON transport without a capability-selection envelope. The transport embeds the JSON Schema in the instruction and requires the response to be one complete JSON value. The returned response parser rejects native call events and invalid JSON, then validates the value through the supplied schema. |
createModelStrategy | function | Compose runner options in precedence order: budget preset, selected model, declared reasoning, exact budget, then explicit Core fields. The result is validated through the same Core binding rules but creates no runner and spends no calls. |
createProviderObservationScope | function | Bind provider observations to a caller-owned destination across diagnostic child spans. attach returns a scoped diagnostic context; contexts that were not attached through this scope produce no observations. Child contexts inherit the owner and a parent/child span path. |
createReplyPreview | function | Create a model-output event handler that publishes preview bubbles. The handler resets on model.start, ignores other invocations, disables itself on unexpected output, and clears the preview when a call ends unsuccessfully. Rules are snapshotted at creation, and only explicitly registered prose fields are projected. |
createReplyPreviewRules | function | Generate frozen preview rules from capability and stage declarations. Capabilities without preview metadata are skipped even when their stage opts in. Default paths are text and bubbles[*], each kept only when the capability schema declares it. |
createSessionModelTransport | function | Create a session transport. |
createStageModelTransport | function | Build a transport that projects a capability source through declared stage references. |
createTextTransport | function | Create a plain-text transport that trims the assembled response. |
defaultCompletionPolicy | constant | |
defineModelTools | function | Build a sealed capability catalog from typed declarations. |
modelBudgetStrategies | constant | |
ModelBudgetStrategy | type | Preset name, or an explicit partial set of Core runner settings. |
ModelChildrenOptions | interface | Group options: worker count, extra cancellation and accept/commit hooks. |
ModelChildTask | interface | One child call in a group: its own limits plus the work to run with the child runner. |
ModelChoiceIndex | interface | Minimal selector shape used while filtering the provider response choices. |
modelInteractionCatalog | constant | |
ModelProviderErrorCode | type | Stable failure classification reported by the compatible provider adapter. |
ModelProviderFailure | interface | Failure detail passed to the App's error factory. |
ModelStageTransportRegistration | interface | Stage IDs and capability references are App-owned; this adapter only compiles their relation. |
ModelStrategyOptions | type | Input of createModelStrategy: model selection, optional reasoning and budget plus explicit Core overrides. Explicit Core fields win over every generated value. |
PreparedSessionTransport | interface | Prepared session transport handed to the runner. |
prepareSessionFunctions | function | Build the session policy for one stage. |
PreviewTool | interface | A model tool with an explicit, presentation-only streaming preview contract. |
ProviderAssistantMessage | interface | Assistant turn; content may be empty when the turn is only a tool declaration. |
ProviderErrorCapture | interface | Captured upstream error body and whether it had to be truncated. |
ProviderEventDescriptor | interface | Provider event name plus its content class. |
ProviderEventName | type | Union of provider event names. |
ProviderEventPayloads | interface | Payload of each provider event. Content-bearing events are accepted explicitly. |
ProviderMessage | type | Message list a host may pass to the compatible provider directly. |
ProviderObservation | type | One observation: event name with its payload. |
ProviderObserver | interface | The caller can correlate each observation using the original, request-local model options. |
ProviderReasoningLevel | type | Supplier wire shape is explicit; levels express requested effort, not measured quality. |
ProviderReasoningStrategy | type | How a reasoning level is translated into request fields. requestBody entries override generated fields, so a host can correct a provider that expects a different shape. |
ProviderSystemMessage | interface | System instruction turn; text only, so the union rejects images and tool fields here. |
ProviderToolCall | type | One tool call the assistant declared, in wire order; aliases the Core shape. |
ProviderToolMessage | interface | Tool result answering one declared call. |
ProviderUserMessage | interface | User turn; the only message type that may carry images, and never tool calls. |
ReplyPreviewOptions | interface | Settings for createReplyPreview; sink receives every bubble list and is required. |
ReplyPreviewRule | interface | One projection rule: which stage/capability it matches and which prose fields may be shown. A rule without toolId may only match a registered plain-text stage. |
ReplyPreviewStage | interface | Stage declaration: which tools it exposes and whether it previews text or arguments. |
ReplyPreviewTool | interface | Capability declaration used to derive preview rules. Omitted preview means the capability never previews, so previewing is an explicit opt-in. |
ResolvedSessionCall | interface | One completed call with host-facing resolution; unknown tools and bad JSON stay non-fatal. |
ResolvedSessionResult | interface | Complete result of one session response after host-facing resolution. |
runChildren | function | Run child tasks concurrently and return their values in declaration order. The first failure aborts the remaining group, but an already in-flight commit is still awaited because cancellation does not mean the write was rolled back. |
sessionCompletionPolicy | constant | |
SessionFunctionOptions | interface | Options a session transport may pass through to provider options. |
SessionModelTransportRegistration | interface | Registration for one session transport. |
上下文与日志
| 符号 | 类别 | 用途 |
|---|---|---|
ContextAssemblyOptions | interface | Assembly options for placement-based projections. |
ContextBuilder | interface | Compiled builder. It holds no request state and may be shared across invocations. |
ContextBuilderOptions | interface | Shared builder options. |
ContextCompressionCall | interface | One compression request. |
ContextCompressor | interface | Registered compressor handler. |
ContextFragmentConfig | interface | Self-describing fragment declaration: metadata plus a formatter. |
contextHandlerCalls | function | |
ContextHandlerReference | interface | Reference to a registered compressor or selector handler. |
ContextHistoryGrouping | type | How a message history is split into groups for trimming. |
contextHistoryStrategies | constant | |
ContextModelCall | interface | Same runner and same fixed invocation result as public model calls. |
ContextModelRequest | interface | One model call made on behalf of a selector or compressor. |
ContextNodeResult | interface | Outcome of one context node: the built input, its prepared model call and the change report. |
ContextPolicy | type | Declared context policy for one stage. |
contextPolicyCatalog | constant | |
ContextProcessingNodeDefinition | type | Definition accepted by createContextProcessingNode. It is a normal Core WorkflowNode except that the node body is declared here: plan builds the context, update decides the committed state, and policy/handlers/timeout are validated when the node is created. |
ContextProcessingOptions | interface | Runtime inputs for one processing run. |
ContextProcessingReport | interface | Facts recorded for one processing run. |
ContextProjection | type | One declared projection: a single fragment or a placement expanded into fragments. |
ContextRecentHistory | interface | Recent history that compression must keep verbatim. |
ContextReduction | type | One declared reduction step. |
contextReductionCatalog | constant | |
ContextReductionNodeDefinition | type | Definition of a reduction node: one registered step is applied per node run. stepId may be fixed or derived from state, which lets a graph route over several steps. |
ContextSelection | type | Selection is independent of ownership; omitted selection preserves ordered execution. |
ContextSelectionCall | interface | Everything a selector may inspect for one decision. |
ContextSelectionCandidate | interface | Candidate step considered by selection, with its measured cost. |
contextSelectionCatalog | constant | |
ContextSelectionNodeDefinition | type | Definition of a selection node: like a processing node, but update receives chosen step IDs. |
ContextSelectionResult | interface | Selection stage result: the chosen step IDs plus the unchanged stage snapshot. |
ContextSelector | interface | Model or local selector that chooses which reductions to apply. |
ContextStageResult | interface | Result of a selection or reduction stage, before the node's update commits chosen fields. |
ContextStrategy | interface | Validated inputs ready to pass to a context processing node. |
ContextStrategyOptions | type | One history declaration that generates a step, or an explicit step list with optional history fields (fragment, field, preset, targetChars, keepGroups, grouping). |
ContextStrategySettings | type | Shared reduce-policy settings applied to the whole strategy. Trigger and target fields follow the Core policy contract; omitted values fall back to the plan budget or to the trigger. Supplying steps disables generation and uses the explicit list. |
ContextTokenMeasurement | interface | Injected token measurement for token-triggered policies. |
createContextCompressor | function | Build a compressor that asks a model to rewrite one fragment. The request pairs a system instruction with a user message carrying the fragment ID, its current value and the target character count. Only the model's parsed value is returned; the caller decides whether the result fits the reduction contract. |
createContextProcessingNode | function | Create one node that runs the complete context policy and returns the built context. Use this when the graph does not need to route between selection and reduction phases. |
createContextReductionNode | function | Create a node that applies exactly one registered reduction step. Partial plans keep the full budget until final assembly, so intermediate nodes do not shrink the allowance reserved for the reply. |
createContextSelectionNode | function | Create an ordinary node that selects reduction steps without executing them. The node reports the registered step IDs so the graph can route to reduction nodes itself. |
createContextSelector | function | Build a selector that asks a model to pick reduction steps. Without a custom parser the model must answer with a JSON object containing a stepIds array; with a custom parser the application owns that contract but must still return step IDs. |
createContextStrategy | function | Build a reduction policy from one or more history declarations. recent keeps a window of recent groups; continuity summarizes older groups while preserving the most recent originals. Neither preset claims semantic quality, only bounded input size. |
defineContextAssembly | function | Compile ordered context projections into a builder. A projection is either a single fragment (with its own formatter) or a placement whose contribution handler expands to any number of fragments at request time. |
defineContextFragments | function | Compile self-describing fragment declarations into a builder. Each definition carries its own trust, lifetime and size metadata, so no separate metadata catalog is needed. The budget may be a constant or a function of the request input. |
processContext | function | Run a complete context policy in one call: snapshot, execute and finalize. |
reservedContextCalls | function | |
selectContextSteps | function | Choose steps that fit the remaining call budget. Feasibility uses exact trim previews and declared call ceilings; the reply reserve and the selector's own allowance are subtracted before candidates are considered, so neither can be spent on reductions. |
transformContextText | function | Apply a text transform to a fragment value, including strings nested inside objects. Structured values are walked through a JSON round trip, which is what the budget measurement serializes later; values that JSON cannot represent are therefore not preserved. |
validateContextPolicy | function | Validate a complete context policy and every handler it can reference. Handler IDs must be unique and each handler must declare a non-negative integer call ceiling. Reduction targets and selection modes are checked by their own catalog entries. |
validateContextSelection | function | Validate selector declarations and the selection mode they serve. |
配置、清单与策略
| 符号 | 类别 | 用途 |
|---|---|---|
defineRegistrationCatalog | function | Compile an ordered installation plan. Predicates observe the effects of preceding installations at request time; a predicate that throws rejects the install instead of being treated as false. Callbacks are bound to their declaring definition so implementations may rely on this. |
defineSchema | function | Re-snapshot an existing adapter without changing its behavior. Used to detach a caller-owned adapter from later mutation before it is exposed or reused. |
fromJsonSchema | function | Build an adapter from a caller-owned typed JSON Schema compiler. The schema is cloned and frozen before it reaches the compiler, so later mutation of the input cannot change validation. Compilation and validation must both be synchronous. |
fromParserSchema | function | Wrap a library schema that already parses values (for example Zod or Valibot style). parse is delegated unchanged, so the library keeps ownership of coercion and error reporting; only the JSON Schema projection is produced here. |
JsonSchemaOptions | interface | Options for building an adapter from a JSON Schema compiler. |
JsonSchemaValidator | interface | App-owned JSON Schema compilers provide synchronous validation. |
RegistrationDefinition | interface | One install step. |
传输与流
| 符号 | 类别 | 用途 |
|---|---|---|
encodeSseEvent | function | Encode one event in the server-sent events wire format. Every line of data gets its own data: field, because a raw newline would start a new field. |
JsonFrameLimits | interface | Bounds applied while scanning a streamed text. |
JsonTransportPart | type | One scanned span: a complete object frame or a character outside any frame. |
parseJsonFrames | function | Parse complete object frames under explicit count and size limits. Only whitespace may appear outside frames; a stray closing brace is tolerated only up to maxExtraClosings, which covers transports that repeat the delimiter after the payload. |
scanJsonObjectFrames | function | Extract complete object-shaped spans from surrounding text, without parsing or selecting them. |
SseOutputEvent | interface | One outbound event before wire encoding. |
SseWriter | interface | Destination that reports backpressure instead of buffering without bound. |
writeSseFrame | function | Write one encoded frame and wait for drain when the writer reports backpressure. The signal is re-checked around the write and the drain wait, so cancellation does not leave a pending write considered successful. |
过程观察与诊断
| 符号 | 类别 | 用途 |
|---|---|---|
streamEvents | function | Bridge a push-style producer to a pull-style async iterable with a one-slot rendezvous. The producer must await every emit call before emitting again; concurrent emissions are rejected rather than buffered. The slot is released only after the consumer receives the event, so backpressure is exact. |