@agentfield/sdk 0.1.92-rc.6 → 0.1.92-rc.8
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 +62 -1
- package/dist/index.js +90 -3
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1085,6 +1085,45 @@ declare class HarnessRunner {
|
|
|
1085
1085
|
private sleep;
|
|
1086
1086
|
}
|
|
1087
1087
|
|
|
1088
|
+
interface SessionDefinition {
|
|
1089
|
+
name: string;
|
|
1090
|
+
provider: string;
|
|
1091
|
+
transport: string;
|
|
1092
|
+
model?: string;
|
|
1093
|
+
modalities: string[];
|
|
1094
|
+
voice?: string;
|
|
1095
|
+
tools: string[];
|
|
1096
|
+
tags: string[];
|
|
1097
|
+
proposed_tags: string[];
|
|
1098
|
+
approved_tags: string[];
|
|
1099
|
+
metadata: Record<string, unknown>;
|
|
1100
|
+
}
|
|
1101
|
+
interface SessionOptions {
|
|
1102
|
+
provider: string;
|
|
1103
|
+
transport: string;
|
|
1104
|
+
model?: string;
|
|
1105
|
+
modalities?: string[];
|
|
1106
|
+
voice?: string;
|
|
1107
|
+
tools?: string[];
|
|
1108
|
+
tags?: string[];
|
|
1109
|
+
metadata?: Record<string, unknown>;
|
|
1110
|
+
}
|
|
1111
|
+
interface SessionTurn {
|
|
1112
|
+
text?: string;
|
|
1113
|
+
transcript?: string;
|
|
1114
|
+
audio?: unknown;
|
|
1115
|
+
audioFormat?: string;
|
|
1116
|
+
channel?: string;
|
|
1117
|
+
metadata?: Record<string, unknown>;
|
|
1118
|
+
}
|
|
1119
|
+
declare class RealtimeSession {
|
|
1120
|
+
readonly sessionId: string;
|
|
1121
|
+
readonly definition: SessionDefinition;
|
|
1122
|
+
constructor(sessionId: string, definition: SessionDefinition);
|
|
1123
|
+
input(): Promise<SessionTurn>;
|
|
1124
|
+
}
|
|
1125
|
+
declare function buildSessionDefinition(name: string, options: SessionOptions): SessionDefinition;
|
|
1126
|
+
|
|
1088
1127
|
declare class Agent {
|
|
1089
1128
|
readonly config: AgentConfig;
|
|
1090
1129
|
readonly app: express.Express;
|
|
@@ -1101,6 +1140,7 @@ declare class Agent {
|
|
|
1101
1140
|
private readonly memoryWatchers;
|
|
1102
1141
|
private readonly localVerifier?;
|
|
1103
1142
|
private readonly realtimeValidationFunctions;
|
|
1143
|
+
private readonly sessions;
|
|
1104
1144
|
private readonly processLogRing;
|
|
1105
1145
|
private readonly executionLogger;
|
|
1106
1146
|
/** Tracks an AbortController per in-flight execution_id so the
|
|
@@ -1112,6 +1152,8 @@ declare class Agent {
|
|
|
1112
1152
|
reasoner<TInput = any, TOutput = any>(name: string, handler: ReasonerHandler<TInput, TOutput>, options?: ReasonerOptions): this;
|
|
1113
1153
|
skill<TInput = any, TOutput = any>(name: string, handler: SkillHandler<TInput, TOutput>, options?: SkillOptions): this;
|
|
1114
1154
|
includeRouter(router: AgentRouter): void;
|
|
1155
|
+
session(name: string, options: SessionOptions, handler: (session: RealtimeSession) => Promise<unknown> | unknown): this;
|
|
1156
|
+
sessionDefinitions(): SessionDefinition[];
|
|
1115
1157
|
handler(adapter?: (event: any, context?: any) => ServerlessEvent): AgentHandler;
|
|
1116
1158
|
watchMemory(pattern: string | string[], handler: MemoryWatchHandler, options?: {
|
|
1117
1159
|
scope?: string;
|
|
@@ -1929,4 +1971,23 @@ declare class ApprovalClient {
|
|
|
1929
1971
|
waitForApproval(executionId: string, opts?: WaitForApprovalOptions): Promise<ApprovalStatusResponse>;
|
|
1930
1972
|
}
|
|
1931
1973
|
|
|
1932
|
-
|
|
1974
|
+
declare const SUPPORTED_SESSION_TRANSPORTS: {
|
|
1975
|
+
readonly openai: readonly ["webrtc", "websocket"];
|
|
1976
|
+
readonly openrouter: readonly ["audio_turns"];
|
|
1977
|
+
};
|
|
1978
|
+
type SessionProvider = keyof typeof SUPPORTED_SESSION_TRANSPORTS;
|
|
1979
|
+
type SessionTransport = (typeof SUPPORTED_SESSION_TRANSPORTS)[SessionProvider][number];
|
|
1980
|
+
interface SessionTransportCapability {
|
|
1981
|
+
provider: SessionProvider;
|
|
1982
|
+
transport: SessionTransport;
|
|
1983
|
+
}
|
|
1984
|
+
declare class SessionTransportError extends Error {
|
|
1985
|
+
readonly provider: string;
|
|
1986
|
+
readonly transport: string;
|
|
1987
|
+
readonly supported: readonly string[];
|
|
1988
|
+
constructor(provider: string, transport: string, supported: readonly string[]);
|
|
1989
|
+
}
|
|
1990
|
+
declare function normalizeSessionTransportValue(value: string): string;
|
|
1991
|
+
declare function validateSessionTransport(provider: string, transport: string): SessionTransportCapability;
|
|
1992
|
+
|
|
1993
|
+
export { ACTIVE_STATUSES, AIClient, type AIConfig, type AIEmbeddingOptions, type AIRequestOptions, type AIStream, type AIToolRequestOptions, Agent, type AgentCapability, type AgentConfig, type AgentHandler, AgentRouter, type AgentRouterOptions, type AgentState, ApprovalClient, type ApprovalRequestResponse, type ApprovalStatusResponse, Audio, type AudioOutput, type AudioRequest, type AuditTrailExport, type AuditTrailFilters, type Awaitable, CANONICAL_STATUSES, type CompactCapability, type CompactDiscoveryResponse, DIDAuthenticator, type DIDIdentity, type DIDIdentityPackage, type DIDRegistrationRequest, type DIDRegistrationResponse, type DeploymentType, DidClient, DidInterface, DidManager, type DiscoveryFormat, type DiscoveryOptions, type DiscoveryPagination, type DiscoveryResponse, type DiscoveryResult, ExecutionContext, type ExecutionCredential, type ExecutionLogAttributes, type ExecutionLogBatchPayload, type ExecutionLogContext, type ExecutionLogEmitOptions, type ExecutionLogEntry, type ExecutionLogLevel, type ExecutionLogTransport, type ExecutionLogTransportPayload, type ExecutionLogWireEntry, ExecutionLogger, type ExecutionLoggerOptions, type ExecutionMetadata, ExecutionStatus, type ExecutionStatusValue, File, type FileOutput, type GenerateCredentialOptions, type GenerateCredentialParams, HEADER_CALLER_DID, HEADER_DID_NONCE, HEADER_DID_SIGNATURE, HEADER_DID_TIMESTAMP, type HarnessConfig, type HarnessOptions, type HarnessProvider, type HarnessResult, HarnessRunner, type HealthStatus, Image, type ImageOutput, type ImageRequest, type MediaProvider, MediaProviderError, type MediaResponse, MediaRouter, type MemoryChangeEvent, MemoryClient, MemoryClientBase, type MemoryConfig, MemoryEventClient, type MemoryEventHandler, type MemoryEventHistoryOptions, MemoryInterface, type MemoryRequestMetadata, type MemoryRequestOptions, type MemoryScope, type MemoryWatchHandler, type Metrics, type MultimodalContent, MultimodalResponse, OpenRouterMediaProvider, type OpenRouterMediaProviderOptions, RateLimitError, type RateLimiterOptions, type RawExecutionContext, type RawResult, RealtimeSession, type ReasonerCapability, ReasonerContext, type ReasonerDefinition, type ReasonerHandler, type ReasonerOptions, type RequestApprovalPayload, SUPPORTED_PROVIDERS, SUPPORTED_SESSION_TRANSPORTS, type ServerlessAdapter, type ServerlessEvent, type ServerlessResponse, type SessionDefinition, type SessionOptions, type SessionProvider, type SessionTransport, type SessionTransportCapability, SessionTransportError, type SessionTurn, type SkillCapability, SkillContext, type SkillDefinition, type SkillHandler, type SkillOptions, StatelessRateLimiter, TERMINAL_STATUSES, Text, type ToolCallConfig, type ToolCallRecord, type ToolCallTrace, type ToolsOption, type VectorSearchOptions, type VectorSearchResult, Video, type VideoFrameImage, type VideoInputReference, type VideoRequest, type WaitForApprovalOptions, type WorkflowCredential, type WorkflowMetadata, type WorkflowProgressOptions, WorkflowReporter, type ZodSchema, audioFromBase64, audioFromBuffer, audioFromFile, audioFromUrl, buildProvider, buildSessionDefinition, buildToolConfig, capabilitiesToTools, capabilityToMetadataTool, capabilityToTool, createExecutionLogger, createHarnessResult, createMetrics, createMultimodalResponse, createRawResult, executeToolCallLoop, fileFromBase64, fileFromBuffer, fileFromPath, fileFromUrl, getCurrentContext, getCurrentSkillContext, imageFromBase64, imageFromBuffer, imageFromFile, imageFromUrl, isActive, isExecutionLogBatchPayload, isTerminal, normalizeExecutionLogEntry, normalizeSessionTransportValue, normalizeStatus, serializeExecutionLogEntry, text, validateSessionTransport, videoFromBase64, videoFromBuffer, videoFromFile, videoFromUrl };
|
package/dist/index.js
CHANGED
|
@@ -3811,6 +3811,83 @@ function registerAgentfieldLogsRoute(app, ring) {
|
|
|
3811
3811
|
});
|
|
3812
3812
|
}
|
|
3813
3813
|
|
|
3814
|
+
// src/sessionTransport.ts
|
|
3815
|
+
var SUPPORTED_SESSION_TRANSPORTS = {
|
|
3816
|
+
openai: ["webrtc", "websocket"],
|
|
3817
|
+
openrouter: ["audio_turns"]
|
|
3818
|
+
};
|
|
3819
|
+
var SessionTransportError = class extends Error {
|
|
3820
|
+
provider;
|
|
3821
|
+
transport;
|
|
3822
|
+
supported;
|
|
3823
|
+
constructor(provider, transport, supported) {
|
|
3824
|
+
const supportedDisplay = supported.length > 0 ? supported.join(", ") : "none";
|
|
3825
|
+
super(
|
|
3826
|
+
`Unsupported session transport '${transport}' for provider '${provider}'. Supported transports: ${supportedDisplay}. AgentField does not infer or switch providers; set provider and transport explicitly.`
|
|
3827
|
+
);
|
|
3828
|
+
this.name = "SessionTransportError";
|
|
3829
|
+
this.provider = provider;
|
|
3830
|
+
this.transport = transport;
|
|
3831
|
+
this.supported = supported;
|
|
3832
|
+
}
|
|
3833
|
+
};
|
|
3834
|
+
function normalizeSessionTransportValue(value) {
|
|
3835
|
+
return value.trim().toLowerCase().replace(/-/g, "_");
|
|
3836
|
+
}
|
|
3837
|
+
function validateSessionTransport(provider, transport) {
|
|
3838
|
+
const normalizedProvider = normalizeSessionTransportValue(provider);
|
|
3839
|
+
const normalizedTransport = normalizeSessionTransportValue(transport);
|
|
3840
|
+
if (!normalizedProvider) {
|
|
3841
|
+
throw new Error("Session provider is required; AgentField does not infer providers.");
|
|
3842
|
+
}
|
|
3843
|
+
if (!normalizedTransport) {
|
|
3844
|
+
throw new Error("Session transport is required; AgentField does not infer transports.");
|
|
3845
|
+
}
|
|
3846
|
+
const supported = SUPPORTED_SESSION_TRANSPORTS[normalizedProvider];
|
|
3847
|
+
if (!supported) {
|
|
3848
|
+
const known = Object.keys(SUPPORTED_SESSION_TRANSPORTS).sort().join(", ");
|
|
3849
|
+
throw new Error(
|
|
3850
|
+
`Unknown session provider '${provider}'. Known providers: ${known}. Register provider capabilities before using a custom session provider.`
|
|
3851
|
+
);
|
|
3852
|
+
}
|
|
3853
|
+
if (!supported.includes(normalizedTransport)) {
|
|
3854
|
+
throw new SessionTransportError(normalizedProvider, normalizedTransport, supported);
|
|
3855
|
+
}
|
|
3856
|
+
return {
|
|
3857
|
+
provider: normalizedProvider,
|
|
3858
|
+
transport: normalizedTransport
|
|
3859
|
+
};
|
|
3860
|
+
}
|
|
3861
|
+
|
|
3862
|
+
// src/session.ts
|
|
3863
|
+
var RealtimeSession = class {
|
|
3864
|
+
sessionId;
|
|
3865
|
+
definition;
|
|
3866
|
+
constructor(sessionId, definition) {
|
|
3867
|
+
this.sessionId = sessionId;
|
|
3868
|
+
this.definition = definition;
|
|
3869
|
+
}
|
|
3870
|
+
async input() {
|
|
3871
|
+
throw new Error("session.input() is populated by the AgentField control plane transport adapter");
|
|
3872
|
+
}
|
|
3873
|
+
};
|
|
3874
|
+
function buildSessionDefinition(name, options) {
|
|
3875
|
+
const capability = validateSessionTransport(options.provider, options.transport);
|
|
3876
|
+
return {
|
|
3877
|
+
name,
|
|
3878
|
+
provider: capability.provider,
|
|
3879
|
+
transport: capability.transport,
|
|
3880
|
+
model: options.model,
|
|
3881
|
+
modalities: options.modalities ?? ["audio", "text"],
|
|
3882
|
+
voice: options.voice,
|
|
3883
|
+
tools: options.tools ?? [],
|
|
3884
|
+
tags: options.tags ?? [],
|
|
3885
|
+
proposed_tags: options.tags ?? [],
|
|
3886
|
+
approved_tags: [],
|
|
3887
|
+
metadata: options.metadata ?? {}
|
|
3888
|
+
};
|
|
3889
|
+
}
|
|
3890
|
+
|
|
3814
3891
|
// src/agent/Agent.ts
|
|
3815
3892
|
var TargetNotFoundError = class extends Error {
|
|
3816
3893
|
};
|
|
@@ -3847,6 +3924,7 @@ var Agent = class {
|
|
|
3847
3924
|
memoryWatchers = [];
|
|
3848
3925
|
localVerifier;
|
|
3849
3926
|
realtimeValidationFunctions = /* @__PURE__ */ new Set();
|
|
3927
|
+
sessions = /* @__PURE__ */ new Map();
|
|
3850
3928
|
processLogRing = new ProcessLogRing();
|
|
3851
3929
|
executionLogger;
|
|
3852
3930
|
/** Tracks an AbortController per in-flight execution_id so the
|
|
@@ -3911,6 +3989,13 @@ var Agent = class {
|
|
|
3911
3989
|
this.reasoners.includeRouter(router);
|
|
3912
3990
|
this.skills.includeRouter(router);
|
|
3913
3991
|
}
|
|
3992
|
+
session(name, options, handler) {
|
|
3993
|
+
this.sessions.set(name, { definition: buildSessionDefinition(name, options), handler });
|
|
3994
|
+
return this;
|
|
3995
|
+
}
|
|
3996
|
+
sessionDefinitions() {
|
|
3997
|
+
return Array.from(this.sessions.values()).map((entry) => entry.definition);
|
|
3998
|
+
}
|
|
3914
3999
|
handler(adapter) {
|
|
3915
4000
|
return async (event, res) => {
|
|
3916
4001
|
if (res && typeof res === "object" && typeof res.setHeader === "function") {
|
|
@@ -4707,7 +4792,8 @@ var Agent = class {
|
|
|
4707
4792
|
version: this.config.version,
|
|
4708
4793
|
deployment_type: deploymentType,
|
|
4709
4794
|
reasoners: this.reasonerDefinitions(),
|
|
4710
|
-
skills: this.skillDefinitions()
|
|
4795
|
+
skills: this.skillDefinitions(),
|
|
4796
|
+
sessions: this.sessionDefinitions()
|
|
4711
4797
|
};
|
|
4712
4798
|
}
|
|
4713
4799
|
async executeInvocation(params) {
|
|
@@ -4992,7 +5078,8 @@ var Agent = class {
|
|
|
4992
5078
|
sdk: {
|
|
4993
5079
|
language: "typescript",
|
|
4994
5080
|
version: AGENTFIELD_TS_SDK_VERSION
|
|
4995
|
-
}
|
|
5081
|
+
},
|
|
5082
|
+
sessions: this.sessionDefinitions()
|
|
4996
5083
|
}
|
|
4997
5084
|
}
|
|
4998
5085
|
});
|
|
@@ -6531,6 +6618,6 @@ function sleep2(ms) {
|
|
|
6531
6618
|
return new Promise((resolve2) => setTimeout(resolve2, ms));
|
|
6532
6619
|
}
|
|
6533
6620
|
|
|
6534
|
-
export { ACTIVE_STATUSES, AIClient, Agent, AgentRouter, ApprovalClient, Audio, CANONICAL_STATUSES, DIDAuthenticator, DidClient, DidInterface, DidManager, ExecutionContext, ExecutionLogger, ExecutionStatus, File, HEADER_CALLER_DID, HEADER_DID_NONCE, HEADER_DID_SIGNATURE, HEADER_DID_TIMESTAMP, HarnessRunner, Image, MediaProviderError, MediaRouter, MemoryClient, MemoryClientBase, MemoryEventClient, MemoryInterface, MultimodalResponse, OpenRouterMediaProvider, RateLimitError, ReasonerContext, SUPPORTED_PROVIDERS, SkillContext, StatelessRateLimiter, TERMINAL_STATUSES, Text, Video, WorkflowReporter, audioFromBase64, audioFromBuffer, audioFromFile, audioFromUrl, buildProvider, buildToolConfig, capabilitiesToTools, capabilityToMetadataTool, capabilityToTool, createExecutionLogger, createHarnessResult, createMetrics, createMultimodalResponse, createRawResult, executeToolCallLoop, fileFromBase64, fileFromBuffer, fileFromPath, fileFromUrl, getCurrentContext, getCurrentSkillContext, imageFromBase64, imageFromBuffer, imageFromFile, imageFromUrl, isActive, isExecutionLogBatchPayload, isTerminal, normalizeExecutionLogEntry, normalizeStatus, serializeExecutionLogEntry, text, videoFromBase64, videoFromBuffer, videoFromFile, videoFromUrl };
|
|
6621
|
+
export { ACTIVE_STATUSES, AIClient, Agent, AgentRouter, ApprovalClient, Audio, CANONICAL_STATUSES, DIDAuthenticator, DidClient, DidInterface, DidManager, ExecutionContext, ExecutionLogger, ExecutionStatus, File, HEADER_CALLER_DID, HEADER_DID_NONCE, HEADER_DID_SIGNATURE, HEADER_DID_TIMESTAMP, HarnessRunner, Image, MediaProviderError, MediaRouter, MemoryClient, MemoryClientBase, MemoryEventClient, MemoryInterface, MultimodalResponse, OpenRouterMediaProvider, RateLimitError, RealtimeSession, ReasonerContext, SUPPORTED_PROVIDERS, SUPPORTED_SESSION_TRANSPORTS, SessionTransportError, SkillContext, StatelessRateLimiter, TERMINAL_STATUSES, Text, Video, WorkflowReporter, audioFromBase64, audioFromBuffer, audioFromFile, audioFromUrl, buildProvider, buildSessionDefinition, buildToolConfig, capabilitiesToTools, capabilityToMetadataTool, capabilityToTool, createExecutionLogger, createHarnessResult, createMetrics, createMultimodalResponse, createRawResult, executeToolCallLoop, fileFromBase64, fileFromBuffer, fileFromPath, fileFromUrl, getCurrentContext, getCurrentSkillContext, imageFromBase64, imageFromBuffer, imageFromFile, imageFromUrl, isActive, isExecutionLogBatchPayload, isTerminal, normalizeExecutionLogEntry, normalizeSessionTransportValue, normalizeStatus, serializeExecutionLogEntry, text, validateSessionTransport, videoFromBase64, videoFromBuffer, videoFromFile, videoFromUrl };
|
|
6535
6622
|
//# sourceMappingURL=index.js.map
|
|
6536
6623
|
//# sourceMappingURL=index.js.map
|