@standardagents/spec 0.41.20 → 0.41.22

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -1514,21 +1514,89 @@ interface ThreadStatusEvent {
1514
1514
  }
1515
1515
  /** Severity of an application log entry. */
1516
1516
  type ThreadLogLevel = 'debug' | 'info' | 'warn' | 'error';
1517
+ /**
1518
+ * Outcome of the operation an application log entry records.
1519
+ *
1520
+ * - `success` — the operation completed and produced its result.
1521
+ * - `error` — the operation failed; put the reason in `error`.
1522
+ * - `skipped` — the operation was deliberately not performed (a guard,
1523
+ * cache hit, or policy decided against it).
1524
+ */
1525
+ type ThreadLogStatus = 'success' | 'error' | 'skipped';
1526
+ /**
1527
+ * The event that caused an application log entry: what woke the code that
1528
+ * wrote it. `kind` is a short category the application chooses (for example
1529
+ * `message`, `webhook`, `schedule`, `tool_call`); `id` identifies the
1530
+ * specific event when one exists; `summary` is a one-line human description.
1531
+ */
1532
+ interface ThreadLogTrigger {
1533
+ /** Short category of the triggering event, e.g. `message` or `webhook`. */
1534
+ kind: string;
1535
+ /** Identifier of the triggering event (a message id, delivery id, …). */
1536
+ id?: string;
1537
+ /** One-line human description of the triggering event. */
1538
+ summary?: string;
1539
+ }
1517
1540
  /**
1518
1541
  * An application log entry recorded with {@link ThreadState.log}.
1519
1542
  *
1520
- * Runtimes bound entry sizes and truncate oversized fields with a marker
1521
- * instead of rejecting the entry: `name` to 120 characters, `message` to
1522
- * 4 KiB, and the JSON encoding of `data` to 16 KiB.
1543
+ * Any code with a `ThreadState` (hooks, tools, endpoints, handlers) can record
1544
+ * one. Only `name` is required; a plain event is `{ name, message }`. When the
1545
+ * entry records an operation — a call to another service, a decision, a
1546
+ * background job — fill in the operation fields so a reader can see what was
1547
+ * sent, what came back, how long it took, what it cost, and what caused it:
1548
+ *
1549
+ * ```typescript
1550
+ * await state.log({
1551
+ * name: 'search.query',
1552
+ * status: 'success',
1553
+ * trigger: { kind: 'message', id: messageId, summary: 'User asked for flights' },
1554
+ * request: { q: 'flights to Lisbon' },
1555
+ * response: { results: 12 },
1556
+ * duration_ms: 182,
1557
+ * cost: 0.0004,
1558
+ * });
1559
+ * ```
1560
+ *
1561
+ * Every field other than `name` is optional, and runtimes ignore fields of the
1562
+ * wrong type rather than rejecting the entry. Runtimes bound entry sizes and
1563
+ * truncate oversized fields with a marker instead of rejecting the entry:
1564
+ * `name` to 120 characters, `message` and `error` to 4 KiB, the JSON
1565
+ * encoding of `data` to 16 KiB, and the JSON encodings of `request` and
1566
+ * `response` to 64 KiB each. A value that cannot be JSON-encoded is replaced
1567
+ * by a marker object; logging never throws because of an entry's content.
1523
1568
  */
1524
1569
  interface ThreadLogEntry {
1525
- /** Short event name, e.g. `cache.miss` or `sync.completed`. */
1570
+ /** Short event name, e.g. `cache.miss` or `sync.completed`. Required. */
1526
1571
  name: string;
1527
- /** Human-readable detail. */
1572
+ /** Human-readable detail: one line a person reads first. */
1528
1573
  message?: string;
1529
- /** Severity. Defaults to `info`. */
1574
+ /**
1575
+ * Severity. Defaults to `error` when `status` is `error`, otherwise `info`.
1576
+ */
1530
1577
  level?: ThreadLogLevel;
1531
- /** Structured, JSON-serializable detail. */
1578
+ /** Outcome of the recorded operation. Omit for a plain event. */
1579
+ status?: ThreadLogStatus;
1580
+ /**
1581
+ * What was sent, or the input that triggered the work: a request payload,
1582
+ * the arguments of a call, the content of an incoming event. Any
1583
+ * JSON-serializable value; strings are kept as text.
1584
+ */
1585
+ request?: unknown;
1586
+ /**
1587
+ * What came back: the response payload or result of the operation. Any
1588
+ * JSON-serializable value; strings are kept as text.
1589
+ */
1590
+ response?: unknown;
1591
+ /** Failure reason when the operation failed (usually with `status: 'error'`). */
1592
+ error?: string;
1593
+ /** Wall-clock duration of the operation in milliseconds (finite, ≥ 0). */
1594
+ duration_ms?: number;
1595
+ /** Cost of the operation in USD, when it cost money (finite, ≥ 0). */
1596
+ cost?: number;
1597
+ /** The event that caused this entry. */
1598
+ trigger?: ThreadLogTrigger;
1599
+ /** Any other structured, JSON-serializable detail. */
1532
1600
  data?: Record<string, unknown>;
1533
1601
  }
1534
1602
  /**
@@ -2676,11 +2744,24 @@ interface ThreadState {
2676
2744
  * requests, tool and handler executions) and is delivered to live log
2677
2745
  * subscribers. Logging never creates a message, never starts or wakes an
2678
2746
  * execution, and never throws because an entry is too large (see
2679
- * {@link ThreadLogEntry} for the size bounds).
2747
+ * {@link ThreadLogEntry} for the size bounds). An entry may record a plain
2748
+ * event or a whole operation: its outcome, what triggered it, what was sent,
2749
+ * what came back, its duration and its cost.
2680
2750
  *
2681
2751
  * @example
2682
2752
  * ```typescript
2683
2753
  * await state.log({ name: 'cache.miss', level: 'debug', data: { key } });
2754
+ *
2755
+ * await state.log({
2756
+ * name: 'reply.skipped',
2757
+ * status: 'skipped',
2758
+ * message: 'Nothing new to say',
2759
+ * trigger: { kind: 'message', id: messageId },
2760
+ * request: { prompt },
2761
+ * response: { decision: 'skip' },
2762
+ * duration_ms: 412,
2763
+ * cost: 0.0012,
2764
+ * });
2684
2765
  * ```
2685
2766
  */
2686
2767
  log(entry: ThreadLogEntry): Promise<void>;
@@ -6350,4 +6431,4 @@ declare function validateAgentDefinition(def: unknown): DefinitionIssue[];
6350
6431
  */
6351
6432
  declare const SPEC_VERSION = "0.2.0";
6352
6433
 
6353
- export { type AgentDefinition, type AgentType, type AttachmentRef, type CodeExecution, type CodeExecutionError, type CodeExecutionLog, type CodeExecutionOptions, type CodeExecutionResult, type CodeExecutionStatus, type ContentPart, type Controller, type ControllerContext, type ControllerReturn, type CreateFetch, type CredentialGrant, DEFINITION_ISSUE_CODES, type DefineHandlerOptions, type DefineToolOptions, type DefinitionIssue, type DefinitionIssueCode, type DefinitionLoader, ENDPOINT_ACCESS_SYMBOL, type Effect, type EffectDefinition, type EmptyUsesState, type EndpointAccess, type EndpointOptions, type EnvValueType, type ErrorOrigin, type ExecutionState, type FetchLike, type FileChunk, type FilePart, type FileRecord, type FileStats, type FileStorage, type FindResult, type GetMessagesOptions, type GlobalNamespaceContext, type GrepResult, HANDLER_SYMBOL, type HandlerDefinition, type HandlerSide, type HookContext, type HookDefinition, type HookDefinitionOptions, type HookDefinitionResult, type HookExecutionContext, type HookExecutionSource, type HookMessage, type HookName, type HookSignatures, type HookToolCall, type HookToolResult, type HumanSide, type ImageContent, type ImagePart, type ImageUrlPart, type InferProviderOptions, type InjectMessageInput, type InspectedRequest, type LLMMessage, type LLMProviderInterface, type ListUserThreadsOptions, type ListUserValuesOptions, type MarkedThreadEndpoint, type MarkedUserEndpoint, type MarkedUserRoom, type Message, type MessageUpdates, type MessagesResult, type ModelCapabilities, type ModelDefinition, type ModelProvider, type NamespaceContext, type PackageSignature, type PackedExports, type PackedMeta, type PackedMetadata, type PackedNamespaceContext, type ParentHookRequirement, type ParentHookStage, type PromptContent, type PromptDefinition, type PromptEnvPart, type PromptIncludePart, type PromptInput, type PromptPart, type PromptSide, type PromptTextPart, type PromptToolConfig, type ProviderAssistantMessage, type ProviderAttachment, type ProviderConfigSlot, type ProviderConfigSlots, type ProviderConfigValueSource, type ProviderDefinition, ProviderError, type ProviderErrorCode, type ProviderErrorOptions, type ProviderExecutedToolResult, type ProviderFactory, type ProviderFactoryConfig, type ProviderFactoryWithOptions, type ProviderFinishReason, type ProviderGeneratedImage, type ProviderInstance, type ProviderMessage, type ProviderMessageContent, type ProviderMethodOverrides, type ProviderModelInfo, type ProviderModelsPage, type ProviderModelsQuery, type ProviderOverride, type ProviderOverrideContext, type ProviderReasoningDetail, type ProviderRequest, type ProviderResponse, type ProviderStreamChunk, type ProviderSyncOverride, type ProviderSystemMessage, type ProviderTool, type ProviderToolCallPart, type ProviderToolMessage, type ProviderToolResultContent, type ProviderUsage, type ProviderUsagePricing, type ProviderUserMessage, type ProviderWebSearchResult, type QueueMessageInput, RESERVED_RELATIONSHIP_NAMES, type ReadFileStreamOptions, type ReaddirResult, type ReasoningConfig, type ResolveUsesState, type ResponseSummary, type RuntimeByteStream, type RuntimeStreamErrorCode, type RuntimeStreamRequest, type RuntimeStreamResult, type RuntimeStreams, SPEC_VERSION, type ScheduledEffect, type SessionToolBinding, type SessionToolConfig, type SetEnvOptions, type SideConfig, type SkillFileInput, type SkillMetadata, type SkillsNamespace, type StopSessionOptions, type StructuredPrompt, type SubagentRegistryEntry, type SubagentRelationship, type SubagentToolConfig, type SubpromptConfig, THREAD_ENDPOINT_SYMBOL, THREAD_STREAM_REASONING_PARAM, type TenvRawShape, type TextContent, type TextPart, type ThreadEndpointAuth, type ThreadEndpointHandler, type ThreadEndpointRouteParams, type ThreadHookName, type ThreadLogEntry, type ThreadLogLevel, type ThreadMessageChunkEvent, type ThreadMetadata, type ThreadReasoningChunkEvent, type ThreadRunState, type ThreadState, type ThreadStatus, type ThreadStatusEvent, type ThreadUser, type Tool, type ToolArgs, type ToolArgsNode, type ToolArgsRawShape, type ToolAttachment, type ToolConfig, type ToolContent, type ToolDefinition, type ToolResult, type ToolTenvs, type ToolVariables, USER_ENDPOINT_SYMBOL, USER_ROOM_SYMBOL, type UserClientInfo, type UserEndpointHandler, type UserEndpointRouteParams, type UserHandle, type UserIdentity, type UserRoomConnection, type UserRoomDefinition, type UserRoomFrame, type UserRoomPresenceEvent, type UserState, type UserThreadSummary, type UserValueEntry, type UsesAwareExecute, type UsesConstrainedState, type VariableDefinition, type VariableType, type VirtualModuleLoader, type VirtualModuleRegistry, type WriteFileOptions, belongsToPackage, defineAgent, defineController, defineEffect, defineHandler, defineHook, defineModel, definePrompt, defineProvider, defineThreadEndpoint, defineTool, defineUserEndpoint, defineUserRoom, getEndpointAccess, isHandler, isPacked, isThreadEndpoint, isUserEndpoint, isUserRoom, isVisibleInNamespace, mapReasoningLevel, providerConst, providerEnv, providerValue, validateAgentDefinition, validateToolName };
6434
+ export { type AgentDefinition, type AgentType, type AttachmentRef, type CodeExecution, type CodeExecutionError, type CodeExecutionLog, type CodeExecutionOptions, type CodeExecutionResult, type CodeExecutionStatus, type ContentPart, type Controller, type ControllerContext, type ControllerReturn, type CreateFetch, type CredentialGrant, DEFINITION_ISSUE_CODES, type DefineHandlerOptions, type DefineToolOptions, type DefinitionIssue, type DefinitionIssueCode, type DefinitionLoader, ENDPOINT_ACCESS_SYMBOL, type Effect, type EffectDefinition, type EmptyUsesState, type EndpointAccess, type EndpointOptions, type EnvValueType, type ErrorOrigin, type ExecutionState, type FetchLike, type FileChunk, type FilePart, type FileRecord, type FileStats, type FileStorage, type FindResult, type GetMessagesOptions, type GlobalNamespaceContext, type GrepResult, HANDLER_SYMBOL, type HandlerDefinition, type HandlerSide, type HookContext, type HookDefinition, type HookDefinitionOptions, type HookDefinitionResult, type HookExecutionContext, type HookExecutionSource, type HookMessage, type HookName, type HookSignatures, type HookToolCall, type HookToolResult, type HumanSide, type ImageContent, type ImagePart, type ImageUrlPart, type InferProviderOptions, type InjectMessageInput, type InspectedRequest, type LLMMessage, type LLMProviderInterface, type ListUserThreadsOptions, type ListUserValuesOptions, type MarkedThreadEndpoint, type MarkedUserEndpoint, type MarkedUserRoom, type Message, type MessageUpdates, type MessagesResult, type ModelCapabilities, type ModelDefinition, type ModelProvider, type NamespaceContext, type PackageSignature, type PackedExports, type PackedMeta, type PackedMetadata, type PackedNamespaceContext, type ParentHookRequirement, type ParentHookStage, type PromptContent, type PromptDefinition, type PromptEnvPart, type PromptIncludePart, type PromptInput, type PromptPart, type PromptSide, type PromptTextPart, type PromptToolConfig, type ProviderAssistantMessage, type ProviderAttachment, type ProviderConfigSlot, type ProviderConfigSlots, type ProviderConfigValueSource, type ProviderDefinition, ProviderError, type ProviderErrorCode, type ProviderErrorOptions, type ProviderExecutedToolResult, type ProviderFactory, type ProviderFactoryConfig, type ProviderFactoryWithOptions, type ProviderFinishReason, type ProviderGeneratedImage, type ProviderInstance, type ProviderMessage, type ProviderMessageContent, type ProviderMethodOverrides, type ProviderModelInfo, type ProviderModelsPage, type ProviderModelsQuery, type ProviderOverride, type ProviderOverrideContext, type ProviderReasoningDetail, type ProviderRequest, type ProviderResponse, type ProviderStreamChunk, type ProviderSyncOverride, type ProviderSystemMessage, type ProviderTool, type ProviderToolCallPart, type ProviderToolMessage, type ProviderToolResultContent, type ProviderUsage, type ProviderUsagePricing, type ProviderUserMessage, type ProviderWebSearchResult, type QueueMessageInput, RESERVED_RELATIONSHIP_NAMES, type ReadFileStreamOptions, type ReaddirResult, type ReasoningConfig, type ResolveUsesState, type ResponseSummary, type RuntimeByteStream, type RuntimeStreamErrorCode, type RuntimeStreamRequest, type RuntimeStreamResult, type RuntimeStreams, SPEC_VERSION, type ScheduledEffect, type SessionToolBinding, type SessionToolConfig, type SetEnvOptions, type SideConfig, type SkillFileInput, type SkillMetadata, type SkillsNamespace, type StopSessionOptions, type StructuredPrompt, type SubagentRegistryEntry, type SubagentRelationship, type SubagentToolConfig, type SubpromptConfig, THREAD_ENDPOINT_SYMBOL, THREAD_STREAM_REASONING_PARAM, type TenvRawShape, type TextContent, type TextPart, type ThreadEndpointAuth, type ThreadEndpointHandler, type ThreadEndpointRouteParams, type ThreadHookName, type ThreadLogEntry, type ThreadLogLevel, type ThreadLogStatus, type ThreadLogTrigger, type ThreadMessageChunkEvent, type ThreadMetadata, type ThreadReasoningChunkEvent, type ThreadRunState, type ThreadState, type ThreadStatus, type ThreadStatusEvent, type ThreadUser, type Tool, type ToolArgs, type ToolArgsNode, type ToolArgsRawShape, type ToolAttachment, type ToolConfig, type ToolContent, type ToolDefinition, type ToolResult, type ToolTenvs, type ToolVariables, USER_ENDPOINT_SYMBOL, USER_ROOM_SYMBOL, type UserClientInfo, type UserEndpointHandler, type UserEndpointRouteParams, type UserHandle, type UserIdentity, type UserRoomConnection, type UserRoomDefinition, type UserRoomFrame, type UserRoomPresenceEvent, type UserState, type UserThreadSummary, type UserValueEntry, type UsesAwareExecute, type UsesConstrainedState, type VariableDefinition, type VariableType, type VirtualModuleLoader, type VirtualModuleRegistry, type WriteFileOptions, belongsToPackage, defineAgent, defineController, defineEffect, defineHandler, defineHook, defineModel, definePrompt, defineProvider, defineThreadEndpoint, defineTool, defineUserEndpoint, defineUserRoom, getEndpointAccess, isHandler, isPacked, isThreadEndpoint, isUserEndpoint, isUserRoom, isVisibleInNamespace, mapReasoningLevel, providerConst, providerEnv, providerValue, validateAgentDefinition, validateToolName };