@standardagents/spec 0.41.8 → 0.41.10
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 +94 -4
- package/dist/index.js +10 -0
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -806,11 +806,24 @@ interface UserState {
|
|
|
806
806
|
env(name: string): Promise<string>;
|
|
807
807
|
/**
|
|
808
808
|
* Broadcast an event to every socket attached to this user's event stream
|
|
809
|
-
* (`{runtime_prefix}/users/me/stream`)
|
|
810
|
-
* live-only: the stream carries no history and no
|
|
811
|
-
* Packages SHOULD namespace event names
|
|
809
|
+
* (`{runtime_prefix}/users/me/stream`) and to every room socket. Delivery
|
|
810
|
+
* is at-most-once and live-only: the stream carries no history and no
|
|
811
|
+
* acknowledgements. Packages SHOULD namespace event names
|
|
812
|
+
* (`my_package.thing_changed`).
|
|
812
813
|
*/
|
|
813
814
|
emit(event: string, data?: unknown): void;
|
|
815
|
+
/**
|
|
816
|
+
* The user's live room connections (`{runtime_prefix}/users/me/hub`
|
|
817
|
+
* sockets that presented a `client_id`), newest attachment last. One entry
|
|
818
|
+
* per client id: a reconnecting client supersedes its older socket.
|
|
819
|
+
*/
|
|
820
|
+
clients(): Promise<UserRoomConnection[]>;
|
|
821
|
+
/**
|
|
822
|
+
* Deliver one frame to one room connection. Resolves `false` when no live
|
|
823
|
+
* socket carries that client id; the frame is then dropped, never queued.
|
|
824
|
+
* Delivery is at-most-once.
|
|
825
|
+
*/
|
|
826
|
+
send(clientId: string, frame: unknown): Promise<boolean>;
|
|
814
827
|
/** Registry metadata for the user's threads. */
|
|
815
828
|
listThreads(options?: ListUserThreadsOptions): Promise<{
|
|
816
829
|
threads: UserThreadSummary[];
|
|
@@ -896,6 +909,12 @@ interface CredentialGrant {
|
|
|
896
909
|
tools?: string[];
|
|
897
910
|
endpoints?: string[];
|
|
898
911
|
userEndpoints?: string[];
|
|
912
|
+
/**
|
|
913
|
+
* Room definitions by registry key (for example `my_package/room`). When
|
|
914
|
+
* absent, rooms are matched against `userEndpoints`, so a policy that
|
|
915
|
+
* names the room there works too.
|
|
916
|
+
*/
|
|
917
|
+
userRooms?: string[];
|
|
899
918
|
agents?: string[];
|
|
900
919
|
};
|
|
901
920
|
/** Non-secret metadata: account label, scopes, expiry. */
|
|
@@ -909,6 +928,77 @@ interface CredentialGrant {
|
|
|
909
928
|
* with a UserState.
|
|
910
929
|
*/
|
|
911
930
|
declare const USER_ENDPOINT_SYMBOL: unique symbol;
|
|
931
|
+
/** One live room connection on the user's hub socket. */
|
|
932
|
+
interface UserRoomConnection {
|
|
933
|
+
/** The `client_id` the socket presented at connect (trimmed, ≤ 256 chars). */
|
|
934
|
+
clientId: string;
|
|
935
|
+
/** The self-declared `client_kind`, when presented. */
|
|
936
|
+
clientKind: string | null;
|
|
937
|
+
/** Unix milliseconds when this socket attached. */
|
|
938
|
+
since: number;
|
|
939
|
+
}
|
|
940
|
+
/**
|
|
941
|
+
* A frame a room connection sends: `{ type: "room", id, ... }`. `id` is the
|
|
942
|
+
* client's correlation id for replies made through {@link UserState.send}.
|
|
943
|
+
* Everything else is the package's own protocol.
|
|
944
|
+
*/
|
|
945
|
+
interface UserRoomFrame {
|
|
946
|
+
type: 'room';
|
|
947
|
+
id: string;
|
|
948
|
+
[key: string]: unknown;
|
|
949
|
+
}
|
|
950
|
+
/** A room connection attaching or detaching. */
|
|
951
|
+
interface UserRoomPresenceEvent {
|
|
952
|
+
kind: 'attached' | 'detached';
|
|
953
|
+
connection: UserRoomConnection;
|
|
954
|
+
/** Unix milliseconds of the observation. */
|
|
955
|
+
at: number;
|
|
956
|
+
}
|
|
957
|
+
/**
|
|
958
|
+
* A packaged user room: the handler for room frames on the user's hub
|
|
959
|
+
* socket. Frames and presence events execute in the user scope under the
|
|
960
|
+
* same per-user serialization as user endpoints, so a presence write cannot
|
|
961
|
+
* race a mutation. At most one room definition is active per project.
|
|
962
|
+
*/
|
|
963
|
+
interface UserRoomDefinition {
|
|
964
|
+
/**
|
|
965
|
+
* Keys under this prefix are room-owned: the runtime keeps them out of
|
|
966
|
+
* client-writable value routes and does not raise `user_value_changed`
|
|
967
|
+
* for them, so the room can write state without hook churn.
|
|
968
|
+
*/
|
|
969
|
+
valuePrefix?: string;
|
|
970
|
+
/** Called for every `{ type: "room" }` frame from a verified-attached socket. */
|
|
971
|
+
onFrame(user: UserState, connection: UserRoomConnection, frame: UserRoomFrame): Promise<void>;
|
|
972
|
+
/** Called when a room connection attaches or, after a grace period, detaches. */
|
|
973
|
+
onPresence?(user: UserState, event: UserRoomPresenceEvent): Promise<void>;
|
|
974
|
+
}
|
|
975
|
+
declare const USER_ROOM_SYMBOL: unique symbol;
|
|
976
|
+
interface MarkedUserRoom extends UserRoomDefinition {
|
|
977
|
+
[USER_ROOM_SYMBOL]: true;
|
|
978
|
+
}
|
|
979
|
+
declare function isUserRoom(value: unknown): value is MarkedUserRoom;
|
|
980
|
+
/**
|
|
981
|
+
* Define the project's user room. The file lives in the `users/` directory
|
|
982
|
+
* like an endpoint (packages SHOULD root it in a package-named directory,
|
|
983
|
+
* for example `users/my_package/room.ts`); it is never HTTP-routed.
|
|
984
|
+
*
|
|
985
|
+
* @example
|
|
986
|
+
* ```typescript
|
|
987
|
+
* // users/my_package/room.ts
|
|
988
|
+
* import { defineUserRoom } from '@standardagents/spec';
|
|
989
|
+
*
|
|
990
|
+
* export default defineUserRoom({
|
|
991
|
+
* valuePrefix: 'my_package.v2.',
|
|
992
|
+
* async onFrame(user, connection, frame) {
|
|
993
|
+
* if (frame.op === 'ping') await user.send(connection.clientId, { type: 'room', id: frame.id, ok: true });
|
|
994
|
+
* },
|
|
995
|
+
* async onPresence(user, event) {
|
|
996
|
+
* user.emit('my_package.presence', { client: event.connection.clientId, online: event.kind === 'attached' });
|
|
997
|
+
* },
|
|
998
|
+
* });
|
|
999
|
+
* ```
|
|
1000
|
+
*/
|
|
1001
|
+
declare function defineUserRoom(definition: UserRoomDefinition): MarkedUserRoom;
|
|
912
1002
|
/**
|
|
913
1003
|
* Route parameters captured from `[param]` and `[*]` segments of a user
|
|
914
1004
|
* endpoint file path.
|
|
@@ -6142,4 +6232,4 @@ declare function validateAgentDefinition(def: unknown): DefinitionIssue[];
|
|
|
6142
6232
|
*/
|
|
6143
6233
|
declare const SPEC_VERSION = "0.2.0";
|
|
6144
6234
|
|
|
6145
|
-
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 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 ThreadState, 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, type UserClientInfo, type UserEndpointHandler, type UserEndpointRouteParams, type UserHandle, type UserIdentity, 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, getEndpointAccess, isHandler, isPacked, isThreadEndpoint, isUserEndpoint, isVisibleInNamespace, mapReasoningLevel, providerConst, providerEnv, providerValue, validateAgentDefinition, validateToolName };
|
|
6235
|
+
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 ThreadMessageChunkEvent, type ThreadMetadata, type ThreadReasoningChunkEvent, type ThreadState, 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 };
|
package/dist/index.js
CHANGED
|
@@ -716,6 +716,13 @@ function defineThreadEndpoint(handler, options) {
|
|
|
716
716
|
|
|
717
717
|
// src/users.ts
|
|
718
718
|
var USER_ENDPOINT_SYMBOL = Symbol.for("standardagents.userEndpoint");
|
|
719
|
+
var USER_ROOM_SYMBOL = Symbol.for("standardagents.userRoom");
|
|
720
|
+
function isUserRoom(value) {
|
|
721
|
+
return typeof value === "object" && value !== null && USER_ROOM_SYMBOL in value && value[USER_ROOM_SYMBOL] === true && typeof value.onFrame === "function";
|
|
722
|
+
}
|
|
723
|
+
function defineUserRoom(definition) {
|
|
724
|
+
return { ...definition, [USER_ROOM_SYMBOL]: true };
|
|
725
|
+
}
|
|
719
726
|
function isUserEndpoint(value) {
|
|
720
727
|
return typeof value === "function" && USER_ENDPOINT_SYMBOL in value && value[USER_ENDPOINT_SYMBOL] === true;
|
|
721
728
|
}
|
|
@@ -795,6 +802,7 @@ export {
|
|
|
795
802
|
THREAD_ENDPOINT_SYMBOL,
|
|
796
803
|
THREAD_STREAM_REASONING_PARAM,
|
|
797
804
|
USER_ENDPOINT_SYMBOL,
|
|
805
|
+
USER_ROOM_SYMBOL,
|
|
798
806
|
belongsToPackage,
|
|
799
807
|
defineAgent,
|
|
800
808
|
defineController,
|
|
@@ -807,11 +815,13 @@ export {
|
|
|
807
815
|
defineThreadEndpoint,
|
|
808
816
|
defineTool,
|
|
809
817
|
defineUserEndpoint,
|
|
818
|
+
defineUserRoom,
|
|
810
819
|
getEndpointAccess,
|
|
811
820
|
isHandler,
|
|
812
821
|
isPacked,
|
|
813
822
|
isThreadEndpoint,
|
|
814
823
|
isUserEndpoint,
|
|
824
|
+
isUserRoom,
|
|
815
825
|
isVisibleInNamespace,
|
|
816
826
|
mapReasoningLevel,
|
|
817
827
|
providerConst,
|