@standardagents/spec 0.42.3 → 0.43.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/index.d.ts CHANGED
@@ -1494,7 +1494,8 @@ interface UserState {
1494
1494
  instanceEnv?(name: string): Promise<string | undefined>;
1495
1495
  /**
1496
1496
  * Broadcast an event to every socket attached to this user's event stream
1497
- * (`{runtime_prefix}/users/me/stream`) and to every room socket. Delivery
1497
+ * (`{runtime_prefix}/users/me/stream`) and to every admitted, identified room
1498
+ * socket. Delivery
1498
1499
  * is at-most-once and live-only: the stream carries no history and no
1499
1500
  * acknowledgements. Packages SHOULD namespace event names
1500
1501
  * (`my_package.thing_changed`).
@@ -1503,7 +1504,8 @@ interface UserState {
1503
1504
  /**
1504
1505
  * The user's live room connections (`{runtime_prefix}/users/me/hub`
1505
1506
  * sockets that presented a `client_id`), newest attachment last. One entry
1506
- * per client id: a reconnecting client supersedes its older socket.
1507
+ * per client id: admission of a reconnecting client supersedes its older socket.
1508
+ * Pending explicit-admission attachments are excluded.
1507
1509
  */
1508
1510
  clients(): Promise<UserRoomConnection[]>;
1509
1511
  /**
@@ -1512,6 +1514,8 @@ interface UserState {
1512
1514
  * Delivery is at-most-once.
1513
1515
  */
1514
1516
  send(clientId: string, frame: unknown): Promise<boolean>;
1517
+ /** Optional attachment-addressed replies, admission and close for user rooms. */
1518
+ roomAttachments?: UserRoomAttachments;
1515
1519
  /** Registry metadata for the user's threads. */
1516
1520
  listThreads(options?: ListUserThreadsOptions): Promise<{
1517
1521
  threads: UserThreadSummary[];
@@ -1622,8 +1626,33 @@ interface UserRoomConnection {
1622
1626
  clientId: string;
1623
1627
  /** The self-declared `client_kind`, when presented. */
1624
1628
  clientKind: string | null;
1625
- /** Unix milliseconds when this socket attached. */
1629
+ /** Unix milliseconds when this socket attached; not a unique socket identity. */
1626
1630
  since: number;
1631
+ /** Opaque identity of this physical attachment; never reused on reconnect. */
1632
+ attachmentId?: string;
1633
+ }
1634
+ /**
1635
+ * Optional room admission capability. Operations address a physical attachment
1636
+ * in this user's room and run within the caller's per-user serialized execution.
1637
+ * Available during serialized room/endpoint handlers, not observational hooks.
1638
+ * A client id or timestamp is never a substitute for an attachment id.
1639
+ */
1640
+ interface UserRoomAttachments {
1641
+ /** Reply to exactly this live attachment, even before admission. No buffering. */
1642
+ send(attachmentId: string, frame: unknown): Promise<boolean>;
1643
+ /**
1644
+ * Admit a live attachment after the room verifies its application proof.
1645
+ * Atomically supersedes the admitted socket with the same client id, never
1646
+ * other pending sockets. Repeating admission is harmless. Returns false if
1647
+ * the attachment has detached or was superseded; it can never be resurrected.
1648
+ */
1649
+ admit(attachmentId: string): Promise<boolean>;
1650
+ /**
1651
+ * Close exactly this live attachment and report its detach. Returns false for
1652
+ * unknown, detached, superseded or foreign attachments. Defaults to 1000/"";
1653
+ * code must be 1000 or 3000–4999; reason is at most 123 UTF-8 bytes.
1654
+ */
1655
+ close(attachmentId: string, code?: number, reason?: string): Promise<boolean>;
1627
1656
  }
1628
1657
  /**
1629
1658
  * A frame a room connection sends: `{ type: "room", id, ... }`. `id` is the
@@ -1646,9 +1675,23 @@ interface UserRoomPresenceEvent {
1646
1675
  * A packaged user room: the handler for room frames on the user's hub
1647
1676
  * socket. Frames and presence events execute in the user scope under the
1648
1677
  * same per-user serialization as user endpoints, so a presence write cannot
1649
- * race a mutation. At most one room definition is active per project.
1678
+ * race a mutation. Multiple room definitions fail room upgrades and delivery
1679
+ * closed; other user surfaces remain available.
1650
1680
  */
1651
1681
  interface UserRoomDefinition {
1682
+ /**
1683
+ * Automatic admission is the default. In explicit mode a newly attached
1684
+ * socket cannot replace an admitted socket or receive send/emit/wake traffic
1685
+ * until the room calls roomAttachments.admit after verifying its proof.
1686
+ * clients() lists admitted sockets only. onFrame still receives pending
1687
+ * frames so the room can implement a challenge protocol; use attachment-
1688
+ * addressed replies for these frames. Runtimes supporting this option MUST
1689
+ * provide roomAttachments and attachmentId; consumers MUST fail closed when
1690
+ * either is absent. Restored legacy attachments require admission too.
1691
+ * Explicit-mode presence reports each physical attach/detach immediately,
1692
+ * including pending and superseded attachments, without reconnect grace.
1693
+ */
1694
+ admission?: 'automatic' | 'explicit';
1652
1695
  /**
1653
1696
  * The user endpoint this room fronts, by policy name (for example
1654
1697
  * `standard/account`). Room executions then run as that endpoint for
@@ -1662,9 +1705,9 @@ interface UserRoomDefinition {
1662
1705
  * for them, so the room can write state without hook churn.
1663
1706
  */
1664
1707
  valuePrefix?: string;
1665
- /** Called for every `{ type: "room" }` frame from a verified-attached socket. */
1708
+ /** Called for every room frame from a live socket, including pending admission. */
1666
1709
  onFrame(user: UserState, connection: UserRoomConnection, frame: UserRoomFrame): Promise<void>;
1667
- /** Called when a room connection attaches or, after a grace period, detaches. */
1710
+ /** Physical presence in explicit mode; client presence with grace in automatic mode. */
1668
1711
  onPresence?(user: UserState, event: UserRoomPresenceEvent): Promise<void>;
1669
1712
  }
1670
1713
  declare const USER_ROOM_SYMBOL: unique symbol;
@@ -6408,4 +6451,4 @@ declare function validateAgentDefinition(def: unknown): DefinitionIssue[];
6408
6451
  */
6409
6452
  declare const SPEC_VERSION = "0.2.0";
6410
6453
 
6411
- 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 DecideOptions, type DecisionAnswer, type DecisionAnswers, type DecisionBooleanAnswer, type DecisionChoiceAnswer, type DecisionContext, type DecisionJson, type DecisionProviderFactory, type DecisionProviderInterface, type DecisionQuestion, type DecisionQuestions, type DecisionRequest, type DecisionResult, type DecisionScoreAnswer, 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 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, decide, 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 };
6454
+ 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 DecideOptions, type DecisionAnswer, type DecisionAnswers, type DecisionBooleanAnswer, type DecisionChoiceAnswer, type DecisionContext, type DecisionJson, type DecisionProviderFactory, type DecisionProviderInterface, type DecisionQuestion, type DecisionQuestions, type DecisionRequest, type DecisionResult, type DecisionScoreAnswer, 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 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 UserRoomAttachments, 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, decide, 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 };