@finalai/agents 0.14.0 → 0.16.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/README.md CHANGED
@@ -118,6 +118,12 @@ gives the model a shell in that backend. A server provides every capability and
118
118
  creates its client with `createClient({ auth, localCompute: false })`, so an
119
119
  omission fails instead.
120
120
 
121
+ In browsers, React Native and Workers, `@finalai/agents/client` resolves (through
122
+ its `browser` and `react-native` export conditions) to a build that imports
123
+ nothing Node-only and serves no compute: `localCompute` defaults to false there,
124
+ and serving in-process tools needs your own `localHosts.dial`. No bundler
125
+ configuration is needed.
126
+
121
127
  An agent is always passed as an object: the value you defined, or one fetched
122
128
  with `project.agents.get({ name } | { id } | { hash })`. A fetched agent is data
123
129
  only; starting one that has in-process tools fails and names them.
@@ -0,0 +1,35 @@
1
+ export * from '@finalai/agent-protocol/agent-platform';
2
+ export { Capability, FilesAccess, ScreenAccess, ShellAccess, type CapabilityAccess, } from '@finalai/agent-protocol';
3
+ export { AcpAuthMode, type AcpApiIface, type AcpConnectArgsIface } from "./acp.mjs";
4
+ export { createTextCollector, isUserMessageFor, sessionUpdateOf, textOf, turnEndOf, type AcpSessionUpdateIface, type TurnEndIface, } from "./acp-frames.mjs";
5
+ export type { AgentInput, AgentValue, AgentValueCodecIface } from "./agent-input.mjs";
6
+ export type { ActorOptionIface, ChannelAppsApiIface, ChannelBindingsApiIface, ChannelSourceIface, ChannelSourceOf, ChannelTicketsApiIface, IdentityLinksApiIface, InstallChannelArgsIface, ProjectChannelsApiIface, PublishChannelArgsIface, UpdateChannelBindingArgsIface, } from "./channels.mjs";
7
+ export { DEFAULT_AGENTS_HOST, type AgentClientIface, type AgentsApiIface, type AppApiIface, type CreateClientOptionsIface, type DecisionsApiIface, type InferenceApiIface, type PeopleApiIface, type PlatformIdentityApiIface, type RealtimeApiIface, } from "./client.mjs";
8
+ export { CollectionEventKind, CollectionResyncReason, type CollectionEvent, type CollectionEventsOptionsIface, type CollectionResyncEventIface, } from "./collection-events.mjs";
9
+ export { ConfigOptionCategory, configSelectFor, configSelectsOf, type ConfigSelectChoiceIface, type ConfigSelectIface, type SessionConfigOptionIface, } from "./config-options.mjs";
10
+ export type { EnumInput, SignalOptionsIface } from "./context.mjs";
11
+ export type { AllowedEndpointsApiIface, BudgetsApiIface, ModelCredentialGrantsApiIface, ModelCredentialsApiIface, OrganizationApiIface, OrganizationPolicyApiIface, SpendingRestrictionsApiIface, } from "./organization.mjs";
12
+ export type { ParticipantConfigurationApiIface } from "./participant-configuration.mjs";
13
+ export type { ConversationChannelRoutesApiIface, ConversationContextApiIface, ConversationContextEntryInputIface, ConversationDecisionsApiIface, ConversationInputsApiIface, ConversationLabelsApiIface, ConversationReadGrantsApiIface, ConversationResourcesIface, ResourceSubscriptionsApiIface, SendInputArgsIface, } from "./conversation-resources.mjs";
14
+ export { TURN_OPEN_SESSION_STATES, isNewerMessageVersion, messageVersionOf, type MessageVersionIface, } from "./conversations.mjs";
15
+ export type { ConversationAgentTurnIface, ConversationEvent, ConversationEventMetaIface, ConversationEventsOptionsIface, ConversationHandleIface, ConversationsApiIface, CreateConversationArgsIface, ListMessagesOptionsIface, OpenedConversationIface, ParticipantCreateInput, ParticipantsApiIface, ProjectConversationsApiIface, SandboxFileContentArgsIface, SandboxFileContentRequestIface, SendMessageOptionsIface, SentMessageIface, UploadAttachmentArgsIface, } from "./conversations.mjs";
16
+ export { AgentClientErrorName, ClientErrorCode, DecisionErrorReason, clientError, decisionError, isClientError, isDecisionError, isRealtimeSubscriptionError, isRequirementsUnmetError, isTerminalRealtimeError, isTurnRejectedError, realtimeSubscriptionError, requirementsUnmetError, turnRejectedError, type AgentClientError, type ClientErrorIface, type DecisionErrorIface, type RealtimeSubscriptionErrorIface, type RequirementsUnmetErrorIface, type TurnRejectedErrorIface, } from "./errors.mjs";
17
+ export { EVENTS_POLL_INTERVAL_MS, type EventsApiIface, type EventSubscriptionsApiIface, type ListEventsOptionsIface, type StreamEventsOptionsIface, } from "./events.mjs";
18
+ export { defaultStreamTiming, type StreamTimingIface } from "./frame-stream.mjs";
19
+ export type { AgentClientAuth, FetchIface, HeadersOption } from "./http.mjs";
20
+ export type { AcpAdaptersApiIface, DefinitionSelectorIface, HarnessesApiIface, SubscriptionAllowancesApiIface, } from "./harnesses.mjs";
21
+ export type { IntegrationsApiIface } from "./integrations.mjs";
22
+ export { SessionLiveEventKind, type SessionLiveEvent } from "./live-stream.mjs";
23
+ export type { LocalComputeIface } from "./local-host.mjs";
24
+ export type { OAuthClientsApiIface, SignInReturnOriginsApiIface } from "./oauth-clients.mjs";
25
+ export type { ProjectClientIface } from "./project.mjs";
26
+ export type { AgentSelectorIface, ProjectAgentsApiIface } from "./project-agents.mjs";
27
+ export type { ProjectApiKeysApiIface, ProjectMembersApiIface, ProjectResourceApiIface, ProjectsApiIface, } from "./projects.mjs";
28
+ export type { ProjectPublisherApiIface, PublicNamesApiIface, PublisherHandleIface, PublishersApiIface, } from "./publishers.mjs";
29
+ export { provideDocumentOf, resourceIdOf, type ProvideIface, type ProvidePatchIface, type ResourceRef, type ResourceRefIface, } from "./provide.mjs";
30
+ export { createGatewayRealtimeTransport, type GatewayConnect, type GatewayConnectionIface, type GatewayRealtimeTransportOptionsIface, type RealtimeSubscribeOptionsIface, type RealtimeTransportFrameIface, type RealtimeTransportIface, } from "./realtime.mjs";
31
+ export { SANDBOX_FILE_URI_SCHEME, createSandboxFileUri, parseSandboxFileUri, type SandboxFileTargetIface, } from "./sandbox-uri.mjs";
32
+ export type { SandboxProvidersApiIface } from "./sandbox-providers.mjs";
33
+ export type { CreateSandboxOptionsIface, SandboxEnvironmentValueIface, SandboxHandleIface, SandboxOwnerIface, SandboxSetupRefIface, SandboxSetupsApiIface, SandboxesApiIface, } from "./sandboxes.mjs";
34
+ export type { ProjectSchedulesApiIface } from "./schedules.mjs";
35
+ export type { CreateSessionArgsIface, CreatedSessionIface, ForkSessionOptionsIface, ProjectSessionsApiIface, RespondArgs, SendOptionsIface, SessionHandleIface, SessionsApiIface, StreamOptionsIface, TurnHandleIface, TurnResultIface, } from "./sessions.mjs";
@@ -0,0 +1,110 @@
1
+ export * from "@finalai/agent-protocol/agent-platform";
2
+ import {
3
+ Capability,
4
+ FilesAccess,
5
+ ScreenAccess,
6
+ ShellAccess
7
+ } from "@finalai/agent-protocol";
8
+ import { AcpAuthMode } from "./acp.mjs";
9
+ import {
10
+ createTextCollector,
11
+ isUserMessageFor,
12
+ sessionUpdateOf,
13
+ textOf,
14
+ turnEndOf
15
+ } from "./acp-frames.mjs";
16
+ import {
17
+ DEFAULT_AGENTS_HOST
18
+ } from "./client.mjs";
19
+ import {
20
+ CollectionEventKind,
21
+ CollectionResyncReason
22
+ } from "./collection-events.mjs";
23
+ import {
24
+ ConfigOptionCategory,
25
+ configSelectFor,
26
+ configSelectsOf
27
+ } from "./config-options.mjs";
28
+ import {
29
+ TURN_OPEN_SESSION_STATES,
30
+ isNewerMessageVersion,
31
+ messageVersionOf
32
+ } from "./conversations.mjs";
33
+ import {
34
+ AgentClientErrorName,
35
+ ClientErrorCode,
36
+ DecisionErrorReason,
37
+ clientError,
38
+ decisionError,
39
+ isClientError,
40
+ isDecisionError,
41
+ isRealtimeSubscriptionError,
42
+ isRequirementsUnmetError,
43
+ isTerminalRealtimeError,
44
+ isTurnRejectedError,
45
+ realtimeSubscriptionError,
46
+ requirementsUnmetError,
47
+ turnRejectedError
48
+ } from "./errors.mjs";
49
+ import {
50
+ EVENTS_POLL_INTERVAL_MS
51
+ } from "./events.mjs";
52
+ import { defaultStreamTiming } from "./frame-stream.mjs";
53
+ import { SessionLiveEventKind } from "./live-stream.mjs";
54
+ import {
55
+ provideDocumentOf,
56
+ resourceIdOf
57
+ } from "./provide.mjs";
58
+ import {
59
+ createGatewayRealtimeTransport
60
+ } from "./realtime.mjs";
61
+ import {
62
+ SANDBOX_FILE_URI_SCHEME,
63
+ createSandboxFileUri,
64
+ parseSandboxFileUri
65
+ } from "./sandbox-uri.mjs";
66
+ export {
67
+ AcpAuthMode,
68
+ AgentClientErrorName,
69
+ Capability,
70
+ ClientErrorCode,
71
+ CollectionEventKind,
72
+ CollectionResyncReason,
73
+ ConfigOptionCategory,
74
+ DEFAULT_AGENTS_HOST,
75
+ DecisionErrorReason,
76
+ EVENTS_POLL_INTERVAL_MS,
77
+ FilesAccess,
78
+ SANDBOX_FILE_URI_SCHEME,
79
+ ScreenAccess,
80
+ SessionLiveEventKind,
81
+ ShellAccess,
82
+ TURN_OPEN_SESSION_STATES,
83
+ clientError,
84
+ configSelectFor,
85
+ configSelectsOf,
86
+ createGatewayRealtimeTransport,
87
+ createSandboxFileUri,
88
+ createTextCollector,
89
+ decisionError,
90
+ defaultStreamTiming,
91
+ isClientError,
92
+ isDecisionError,
93
+ isNewerMessageVersion,
94
+ isRealtimeSubscriptionError,
95
+ isRequirementsUnmetError,
96
+ isTerminalRealtimeError,
97
+ isTurnRejectedError,
98
+ isUserMessageFor,
99
+ messageVersionOf,
100
+ parseSandboxFileUri,
101
+ provideDocumentOf,
102
+ realtimeSubscriptionError,
103
+ requirementsUnmetError,
104
+ resourceIdOf,
105
+ sessionUpdateOf,
106
+ textOf,
107
+ turnEndOf,
108
+ turnRejectedError
109
+ };
110
+ //# sourceMappingURL=api.mjs.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../src/agent-client/api.ts"],
4
+ "sourcesContent": ["// Everything `@finalai/agents/client` exports in every runtime except\n// `createClient`, which each runtime's entry binds to its own defaults.\n// Wire types come from `@finalai/agent-protocol/agent-platform`, re-exported\n// here so consumers need one import.\n\nexport * from '@finalai/agent-protocol/agent-platform';\nexport {\n Capability,\n FilesAccess,\n ScreenAccess,\n ShellAccess,\n type CapabilityAccess,\n} from '@finalai/agent-protocol';\nexport { AcpAuthMode, type AcpApiIface, type AcpConnectArgsIface } from \"./acp.mjs\";\nexport {\n createTextCollector,\n isUserMessageFor,\n sessionUpdateOf,\n textOf,\n turnEndOf,\n type AcpSessionUpdateIface,\n type TurnEndIface,\n} from \"./acp-frames.mjs\";\nexport type { AgentInput, AgentValue, AgentValueCodecIface } from \"./agent-input.mjs\";\nexport type {\n ActorOptionIface,\n ChannelAppsApiIface,\n ChannelBindingsApiIface,\n ChannelSourceIface,\n ChannelSourceOf,\n ChannelTicketsApiIface,\n IdentityLinksApiIface,\n InstallChannelArgsIface,\n ProjectChannelsApiIface,\n PublishChannelArgsIface,\n UpdateChannelBindingArgsIface,\n} from \"./channels.mjs\";\nexport {\n DEFAULT_AGENTS_HOST,\n type AgentClientIface,\n type AgentsApiIface,\n type AppApiIface,\n type CreateClientOptionsIface,\n type DecisionsApiIface,\n type InferenceApiIface,\n type PeopleApiIface,\n type PlatformIdentityApiIface,\n type RealtimeApiIface,\n} from \"./client.mjs\";\nexport {\n CollectionEventKind,\n CollectionResyncReason,\n type CollectionEvent,\n type CollectionEventsOptionsIface,\n type CollectionResyncEventIface,\n} from \"./collection-events.mjs\";\nexport {\n ConfigOptionCategory,\n configSelectFor,\n configSelectsOf,\n type ConfigSelectChoiceIface,\n type ConfigSelectIface,\n type SessionConfigOptionIface,\n} from \"./config-options.mjs\";\nexport type { EnumInput, SignalOptionsIface } from \"./context.mjs\";\nexport type {\n AllowedEndpointsApiIface,\n BudgetsApiIface,\n ModelCredentialGrantsApiIface,\n ModelCredentialsApiIface,\n OrganizationApiIface,\n OrganizationPolicyApiIface,\n SpendingRestrictionsApiIface,\n} from \"./organization.mjs\";\nexport type { ParticipantConfigurationApiIface } from \"./participant-configuration.mjs\";\nexport type {\n ConversationChannelRoutesApiIface,\n ConversationContextApiIface,\n ConversationContextEntryInputIface,\n ConversationDecisionsApiIface,\n ConversationInputsApiIface,\n ConversationLabelsApiIface,\n ConversationReadGrantsApiIface,\n ConversationResourcesIface,\n ResourceSubscriptionsApiIface,\n SendInputArgsIface,\n} from \"./conversation-resources.mjs\";\nexport {\n TURN_OPEN_SESSION_STATES,\n isNewerMessageVersion,\n messageVersionOf,\n type MessageVersionIface,\n} from \"./conversations.mjs\";\nexport type {\n ConversationAgentTurnIface,\n ConversationEvent,\n ConversationEventMetaIface,\n ConversationEventsOptionsIface,\n ConversationHandleIface,\n ConversationsApiIface,\n CreateConversationArgsIface,\n ListMessagesOptionsIface,\n OpenedConversationIface,\n ParticipantCreateInput,\n ParticipantsApiIface,\n ProjectConversationsApiIface,\n SandboxFileContentArgsIface,\n SandboxFileContentRequestIface,\n SendMessageOptionsIface,\n SentMessageIface,\n UploadAttachmentArgsIface,\n} from \"./conversations.mjs\";\nexport {\n AgentClientErrorName,\n ClientErrorCode,\n DecisionErrorReason,\n clientError,\n decisionError,\n isClientError,\n isDecisionError,\n isRealtimeSubscriptionError,\n isRequirementsUnmetError,\n isTerminalRealtimeError,\n isTurnRejectedError,\n realtimeSubscriptionError,\n requirementsUnmetError,\n turnRejectedError,\n type AgentClientError,\n type ClientErrorIface,\n type DecisionErrorIface,\n type RealtimeSubscriptionErrorIface,\n type RequirementsUnmetErrorIface,\n type TurnRejectedErrorIface,\n} from \"./errors.mjs\";\nexport {\n EVENTS_POLL_INTERVAL_MS,\n type EventsApiIface,\n type EventSubscriptionsApiIface,\n type ListEventsOptionsIface,\n type StreamEventsOptionsIface,\n} from \"./events.mjs\";\nexport { defaultStreamTiming, type StreamTimingIface } from \"./frame-stream.mjs\";\nexport type { AgentClientAuth, FetchIface, HeadersOption } from \"./http.mjs\";\nexport type {\n AcpAdaptersApiIface,\n DefinitionSelectorIface,\n HarnessesApiIface,\n SubscriptionAllowancesApiIface,\n} from \"./harnesses.mjs\";\nexport type { IntegrationsApiIface } from \"./integrations.mjs\";\nexport { SessionLiveEventKind, type SessionLiveEvent } from \"./live-stream.mjs\";\nexport type { LocalComputeIface } from \"./local-host.mjs\";\nexport type { OAuthClientsApiIface, SignInReturnOriginsApiIface } from \"./oauth-clients.mjs\";\nexport type { ProjectClientIface } from \"./project.mjs\";\nexport type { AgentSelectorIface, ProjectAgentsApiIface } from \"./project-agents.mjs\";\nexport type {\n ProjectApiKeysApiIface,\n ProjectMembersApiIface,\n ProjectResourceApiIface,\n ProjectsApiIface,\n} from \"./projects.mjs\";\nexport type {\n ProjectPublisherApiIface,\n PublicNamesApiIface,\n PublisherHandleIface,\n PublishersApiIface,\n} from \"./publishers.mjs\";\nexport {\n provideDocumentOf,\n resourceIdOf,\n type ProvideIface,\n type ProvidePatchIface,\n type ResourceRef,\n type ResourceRefIface,\n} from \"./provide.mjs\";\nexport {\n createGatewayRealtimeTransport,\n type GatewayConnect,\n type GatewayConnectionIface,\n type GatewayRealtimeTransportOptionsIface,\n type RealtimeSubscribeOptionsIface,\n type RealtimeTransportFrameIface,\n type RealtimeTransportIface,\n} from \"./realtime.mjs\";\nexport {\n SANDBOX_FILE_URI_SCHEME,\n createSandboxFileUri,\n parseSandboxFileUri,\n type SandboxFileTargetIface,\n} from \"./sandbox-uri.mjs\";\nexport type { SandboxProvidersApiIface } from \"./sandbox-providers.mjs\";\nexport type {\n CreateSandboxOptionsIface,\n SandboxEnvironmentValueIface,\n SandboxHandleIface,\n SandboxOwnerIface,\n SandboxSetupRefIface,\n SandboxSetupsApiIface,\n SandboxesApiIface,\n} from \"./sandboxes.mjs\";\nexport type { ProjectSchedulesApiIface } from \"./schedules.mjs\";\nexport type {\n CreateSessionArgsIface,\n CreatedSessionIface,\n ForkSessionOptionsIface,\n ProjectSessionsApiIface,\n RespondArgs,\n SendOptionsIface,\n SessionHandleIface,\n SessionsApiIface,\n StreamOptionsIface,\n TurnHandleIface,\n TurnResultIface,\n} from \"./sessions.mjs\";\n"],
5
+ "mappings": "AAKA,cAAc;AACd;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAEK;AACP,SAAS,mBAA+D;AACxE;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAGK;AAeP;AAAA,EACE;AAAA,OAUK;AACP;AAAA,EACE;AAAA,EACA;AAAA,OAIK;AACP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OAIK;AAwBP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OAEK;AAoBP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAOK;AACP;AAAA,EACE;AAAA,OAKK;AACP,SAAS,2BAAmD;AAS5D,SAAS,4BAAmD;AAiB5D;AAAA,EACE;AAAA,EACA;AAAA,OAKK;AACP;AAAA,EACE;AAAA,OAOK;AACP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OAEK;",
6
+ "names": []
7
+ }
@@ -6,7 +6,7 @@ import { type SignalOptionsIface } from "./context.mjs";
6
6
  import { type ConversationsApiIface } from "./conversations.mjs";
7
7
  import { type EventsApiIface, type EventSubscriptionsApiIface } from "./events.mjs";
8
8
  import { type StreamTimingIface } from "./frame-stream.mjs";
9
- import { type AgentClientAuth, type FetchIface, type HeadersOption } from "./http.mjs";
9
+ import { type AgentClientAuth, type FetchIface, type HeadersOption, type HttpIface } from "./http.mjs";
10
10
  import { type GatewayConnect, type RealtimeTransportIface } from "./realtime.mjs";
11
11
  import type { LocalComputeIface, LocalHostSocketIface } from "./local-host.mjs";
12
12
  import { type ProjectClientIface } from "./project.mjs";
@@ -20,10 +20,11 @@ export interface CreateClientOptionsIface {
20
20
  auth: AgentClientAuth;
21
21
  /**
22
22
  * Whether this process provides the files and shell an agent requires when
23
- * the caller leaves them out (default true), so the model's file edits and
24
- * commands run here, on this machine. A server should provide every
25
- * capability explicitly and pass false, so an omission fails with
26
- * `requirements_unmet` instead of giving the model a shell in the server.
23
+ * the caller leaves them out, so the model's file edits and commands run
24
+ * here, on this machine. Defaults to true in Node and false in browsers and
25
+ * React Native, which have no files or shell to give. A server should
26
+ * provide every capability explicitly and pass false, so an omission fails
27
+ * with `requirements_unmet` instead of giving the model a shell in the server.
27
28
  */
28
29
  localCompute?: boolean;
29
30
  /**
@@ -178,4 +179,15 @@ export interface AgentClientIface {
178
179
  close: () => void;
179
180
  [Symbol.asyncDispose]: () => Promise<void>;
180
181
  }
181
- export declare const createClient: (options: CreateClientOptionsIface) => AgentClientIface;
182
+ /**
183
+ * What `createClient` uses unless a seam replaces it, where that differs by
184
+ * runtime: Node serves compute and dials the local host socket itself;
185
+ * browsers and React Native do neither unless the caller passes the seams.
186
+ */
187
+ export interface ClientRuntimeIface {
188
+ /** `localCompute` when the caller leaves it out. */
189
+ localCompute: boolean;
190
+ compute: () => LocalComputeIface;
191
+ dial: (http: HttpIface) => (path: string, signal?: AbortSignal) => Promise<LocalHostSocketIface>;
192
+ }
193
+ export declare const createClientFor: (runtime: ClientRuntimeIface, options: CreateClientOptionsIface) => AgentClientIface;
@@ -18,12 +18,7 @@ import {
18
18
  } from "./channels.mjs";
19
19
  import { encodePath } from "./context.mjs";
20
20
  import { createConversationsApi } from "./conversations.mjs";
21
- import {
22
- defaultAgentCodec,
23
- defaultChannelSourceOf,
24
- defaultLocalCompute,
25
- defaultLocalHostDial
26
- } from "./defaults.mjs";
21
+ import { defaultAgentCodec, defaultChannelSourceOf } from "./defaults.mjs";
27
22
  import { clientError, ClientErrorCode } from "./errors.mjs";
28
23
  import {
29
24
  createEventsApi,
@@ -43,7 +38,7 @@ import { createOrganizationApi } from "./organization.mjs";
43
38
  import { createPublishersApi } from "./publishers.mjs";
44
39
  import { createSessionsApi } from "./sessions.mjs";
45
40
  const DEFAULT_AGENTS_HOST = "https://agent-session.final.ai";
46
- const createClient = (options) => {
41
+ const createClientFor = (runtime, options) => {
47
42
  const http = createHttp({
48
43
  host: options.host ?? DEFAULT_AGENTS_HOST,
49
44
  auth: options.auth,
@@ -110,13 +105,12 @@ const createClient = (options) => {
110
105
  now: options.now ?? Date.now
111
106
  };
112
107
  const hosts = /* @__PURE__ */ new Set();
113
- const localCompute = defaultLocalCompute();
114
108
  const start = {
115
109
  context,
116
110
  codec: options.agentCodec ?? defaultAgentCodec,
117
- localCompute: options.localCompute ?? true,
118
- compute: { ...localCompute, ...options.localHosts?.compute },
119
- dial: options.localHosts?.dial ?? defaultLocalHostDial(http),
111
+ localCompute: options.localCompute ?? runtime.localCompute,
112
+ compute: { ...runtime.compute(), ...options.localHosts?.compute },
113
+ dial: options.localHosts?.dial ?? runtime.dial(http),
120
114
  hosts
121
115
  };
122
116
  const channelSourceOf = options.channelSourceOf ?? defaultChannelSourceOf;
@@ -228,6 +222,6 @@ const createClient = (options) => {
228
222
  };
229
223
  export {
230
224
  DEFAULT_AGENTS_HOST,
231
- createClient
225
+ createClientFor
232
226
  };
233
227
  //# sourceMappingURL=client.mjs.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../src/agent-client/client.ts"],
4
- "sourcesContent": ["import {\n agentListSchema,\n agentRealtimeTopics,\n agentSummarySchema,\n decisionResponseSchema,\n healthResponseSchema,\n inferenceOfferingSchema,\n personListSchema,\n platformIdentityExchangeRequestSchema,\n platformIdentityExchangeResponseSchema,\n realtimeSessionResponseSchema,\n type AgentListIface,\n type AgentSummaryIface,\n type DecisionIface,\n type HealthResponseIface,\n type InferenceOfferingIface,\n type PersonIface,\n type PersonListIface,\n type PlatformIdentityExchangeRequestIface,\n type PlatformIdentityExchangeResponseIface,\n type RealtimeSessionResponseIface,\n} from '@finalai/agent-protocol/agent-platform';\nimport { createAcpApi, type AcpApiIface } from \"./acp.mjs\";\nimport type { AgentValueCodecIface } from \"./agent-input.mjs\";\nimport {\n createChannelBindingsApi,\n createChannelTicketsApi,\n createIdentityLinksApi,\n type ChannelBindingsApiIface,\n type ChannelSourceOf,\n type ChannelTicketsApiIface,\n type IdentityLinksApiIface,\n} from \"./channels.mjs\";\nimport { encodePath, type ClientContextIface, type SignalOptionsIface } from \"./context.mjs\";\nimport { createConversationsApi, type ConversationsApiIface } from \"./conversations.mjs\";\nimport {\n defaultAgentCodec,\n defaultChannelSourceOf,\n defaultLocalCompute,\n defaultLocalHostDial,\n} from \"./defaults.mjs\";\nimport { clientError, ClientErrorCode } from \"./errors.mjs\";\nimport {\n createEventsApi,\n createEventSubscriptionsApi,\n type EventsApiIface,\n type EventSubscriptionsApiIface,\n} from \"./events.mjs\";\nimport { defaultStreamTiming, type StreamTimingIface } from \"./frame-stream.mjs\";\nimport {\n createHttp,\n HttpMethod,\n type AgentClientAuth,\n type FetchIface,\n type HeadersOption,\n} from \"./http.mjs\";\nimport {\n createGatewayRealtimeTransport,\n type GatewayConnect,\n type GatewayRealtimeTransportIface,\n type RealtimeTransportIface,\n} from \"./realtime.mjs\";\nimport type { LocalComputeIface, LocalHostIface, LocalHostSocketIface } from \"./local-host.mjs\";\nimport { createProjectClient, type ProjectClientIface } from \"./project.mjs\";\nimport { createProjectsApi, type ProjectsApiIface } from \"./projects.mjs\";\nimport { createOrganizationApi, type OrganizationApiIface } from \"./organization.mjs\";\nimport { createPublishersApi, type PublishersApiIface } from \"./publishers.mjs\";\nimport { createSessionsApi, type SessionsApiIface } from \"./sessions.mjs\";\nimport type { AgentStartDepsIface } from \"./start.mjs\";\n\n/** Final's agents API. */\nexport const DEFAULT_AGENTS_HOST = 'https://agent-session.final.ai';\n\nexport interface CreateClientOptionsIface {\n auth: AgentClientAuth;\n /**\n * Whether this process provides the files and shell an agent requires when\n * the caller leaves them out (default true), so the model's file edits and\n * commands run here, on this machine. A server should provide every\n * capability explicitly and pass false, so an omission fails with\n * `requirements_unmet` instead of giving the model a shell in the server.\n */\n localCompute?: boolean;\n /**\n * The agents API origin (default `https://agent-session.final.ai`; its API is\n * under `/api` and ACP at `/acp/ws`), or a base URL the API routes are mounted under.\n */\n host?: string;\n /** Extra headers per request; console clients send their client identity header here. */\n headers?: HeadersOption;\n /** API requests (the host's routes); carries auth and caller headers. */\n fetch?: FetchIface;\n /**\n * Presigned storage requests (attachment uploads). Gets only the headers the\n * presign requires, never auth, client identity or cookies, so a storage\n * bucket's CORS and third-party hosts see nothing of the caller. Defaults to\n * `globalThis.fetch`; keep it free of header-injecting wrappers.\n */\n storageFetch?: FetchIface;\n /** console-web and console-mobile pass their realtime clients; defaults to a gateway connection. */\n realtime?: RealtimeTransportIface;\n /** Seam for the default transport's gateway connection. */\n gatewayConnect?: GatewayConnect;\n /** Seam for stream retry timing (tests). */\n timing?: Partial<StreamTimingIface>;\n /** Seam for idempotency keys and client message ids; defaults to `crypto.randomUUID`. */\n newKey?: () => string;\n /** Seam for the client clock (conversation recovery windows). */\n now?: () => number;\n /** Seam: how agent values become documents and in-process code. */\n agentCodec?: AgentValueCodecIface;\n /** Seam: how a channel value becomes its source. */\n channelSourceOf?: ChannelSourceOf;\n /** Seams for local hosts: the socket, and the sandbox this process serves. */\n localHosts?: {\n /** Opens the local host socket; abandons it when `signal` aborts. */\n dial?: (path: string, signal?: AbortSignal) => Promise<LocalHostSocketIface>;\n compute?: Partial<LocalComputeIface>;\n };\n}\n\nexport interface AgentsApiIface {\n /**\n * The agents the caller can use; with `projectId`, those usable there (its own and those\n * inherited from its ancestors). Without it, everything the caller can access (an API key: its\n * parent project and every project it is granted; a person: every project they can read).\n * Fetch one as data with `client.project({ id }).agents.get`.\n */\n list: (\n options?: SignalOptionsIface & { cursor?: string; limit?: number; projectId?: string },\n ) => Promise<AgentListIface>;\n /**\n * One agent the caller can use, by id, in whichever project owns it; also one that was never\n * published (`hash` and `revisionId` are null). Archived agents are not found.\n */\n get: (args: { id: string } & SignalOptionsIface) => Promise<AgentSummaryIface>;\n}\n\nexport interface PeopleApiIface {\n /** One page of the caller's organization members, by name; pass `nextCursor` as `cursor` for the next. */\n list: (\n options?: SignalOptionsIface & { cursor?: string; limit?: number },\n ) => Promise<PersonListIface>;\n /** Every member of the caller's organization (all pages). */\n all: (options?: SignalOptionsIface) => Promise<PersonIface[]>;\n /** The caller's own person (or, for an API key or app, the actor it names). */\n me: { identityLinks: IdentityLinksApiIface };\n}\n\nexport interface RealtimeApiIface {\n /**\n * Mints a gateway session (`POST /v1/realtime/session`) for the signed-in user:\n * the gateway URL, a short-lived token, and the user id realtime topics are keyed by.\n * Pass it as `createSession` to `createGatewayRealtimeTransport` when supplying a transport.\n */\n createSession: (options?: SignalOptionsIface) => Promise<RealtimeSessionResponseIface>;\n}\n\nexport interface InferenceApiIface {\n /**\n * The vendors and models the platform's own metered inference serves, with\n * prices (`GET /v1/inference/offering`, public). A harness using the\n * platform's inference can run only models listed here.\n */\n offering: (options?: SignalOptionsIface) => Promise<InferenceOfferingIface>;\n}\n\nexport interface PlatformIdentityApiIface {\n /**\n * Exchanges a sandbox-provider (or downstream) assertion the platform issued\n * for a fresh one: for the provider's own URL (a refresh) or a backend its\n * registration was granted. The subject token is the credential.\n */\n exchange: (\n args: PlatformIdentityExchangeRequestIface & SignalOptionsIface,\n ) => Promise<PlatformIdentityExchangeResponseIface>;\n}\n\nexport interface DecisionsApiIface {\n /** One decision awaiting the caller's answer, as `conversations.decisions` lists it. */\n get: (args: { id: string } & SignalOptionsIface) => Promise<DecisionIface>;\n}\n\nexport interface AppApiIface {\n /**\n * The calling app's event subscriptions, across every organization that\n * installed it. Needs an app-level token.\n */\n eventSubscriptions: EventSubscriptionsApiIface;\n}\n\nexport interface AgentClientIface {\n /** One project: where sessions, conversations, sandboxes and integrations are created. */\n project: (args: { id: string }) => ProjectClientIface;\n /** The project tree: list projects and create them. */\n projects: ProjectsApiIface;\n /** The event feed across everything the caller can see; `project({ id }).events` narrows it. */\n events: EventsApiIface;\n app: AppApiIface;\n /** Publishers' public agents, channels, harnesses and ACP adapters. */\n publishers: PublishersApiIface;\n inference: InferenceApiIface;\n platformIdentity: PlatformIdentityApiIface;\n decisions: DecisionsApiIface;\n health: (options?: SignalOptionsIface) => Promise<HealthResponseIface>;\n /** The caller's organization: model credentials, budgets and policies. */\n organization: OrganizationApiIface;\n agents: AgentsApiIface;\n people: PeopleApiIface;\n realtime: RealtimeApiIface;\n /** Existing sessions by id; create them through `project({ id }).sessions`. */\n sessions: SessionsApiIface;\n /** The caller's conversations; create them through `project({ id }).conversations`. */\n conversations: ConversationsApiIface;\n /** Channel installs by id; install them through `project({ id }).channels`. */\n channelBindings: ChannelBindingsApiIface;\n /** Tickets from an installer's link and connect pages. */\n channelTickets: ChannelTicketsApiIface;\n /**\n * ACP-native access (`/acp/ws`): an ACP v2 ClientApp connection on which the\n * agents API is the agent. The ACP SDK loads on the first `connect`.\n */\n acp: AcpApiIface;\n /**\n * Ends every stream (they reject with a `client_closed` ClientError) and every\n * local host connection (the platform then reports this process's tools and\n * compute as unavailable; sessions carry on) and, when the client created its\n * own realtime transport, closes the gateway connection and cancels its\n * retries. A transport passed in `realtime` belongs to the caller and is left\n * open. Idempotent.\n */\n close: () => void;\n [Symbol.asyncDispose]: () => Promise<void>;\n}\n\nexport const createClient = (options: CreateClientOptionsIface): AgentClientIface => {\n const http = createHttp({\n host: options.host ?? DEFAULT_AGENTS_HOST,\n auth: options.auth,\n headers: options.headers,\n fetch: options.fetch,\n });\n let realtime = options.realtime ?? null;\n let ownTransport: GatewayRealtimeTransportIface | null = null;\n const closing = new AbortController();\n const createRealtimeSession: RealtimeApiIface['createSession'] = (sessionOptions) =>\n http.request({\n method: HttpMethod.Post,\n path: '/v1/realtime/session',\n response: realtimeSessionResponseSchema,\n signal: sessionOptions?.signal,\n });\n let realtimeOwner: Promise<RealtimeSessionResponseIface> | null = null;\n const realtimeOwnerSession = () => {\n if (realtimeOwner != null) return realtimeOwner;\n const pending = createRealtimeSession({ signal: closing.signal });\n realtimeOwner = pending;\n void pending.catch(() => {\n if (realtimeOwner === pending) realtimeOwner = null;\n });\n return pending;\n };\n let realtimeUser: Promise<string> | null = null;\n // Shared by every stream, so it is cancelled only with the client, never by one caller.\n const realtimeUserId: ClientContextIface['realtimeUserId'] = () => {\n if (realtimeUser != null) return realtimeUser;\n const pending = realtimeOwnerSession().then((session) => {\n if (session.userId == null)\n throw new Error('This client authenticates as an API-key owner, not a user');\n return session.userId;\n });\n realtimeUser = pending;\n // A failed (or aborted) read is not cached.\n pending.catch(() => {\n if (realtimeUser === pending) realtimeUser = null;\n });\n return pending;\n };\n const context: ClientContextIface = {\n http,\n closeSignal: closing.signal,\n realtimeUserId,\n // Conversations is the only collection.\n realtimeCollectionTopic: async () => {\n const owner = await realtimeOwnerSession();\n // API keys act in their project, not as members: they reach agents through channels.\n if (owner.userId == null)\n throw new Error('Collection streams belong to users; API-key owners use session streams');\n return agentRealtimeTopics.userConversations(owner.userId);\n },\n storageFetch: options.storageFetch ?? ((input, init) => globalThis.fetch(input, init)),\n realtime: () => {\n if (realtime != null) return realtime;\n ownTransport = createGatewayRealtimeTransport({\n createSession: () => createRealtimeSession(),\n connect: options.gatewayConnect,\n });\n if (closing.signal.aborted) ownTransport.close();\n realtime = ownTransport;\n return realtime;\n },\n timing: { ...defaultStreamTiming, ...options.timing },\n newKey: options.newKey ?? (() => globalThis.crypto.randomUUID()),\n now: options.now ?? Date.now,\n };\n\n const hosts = new Set<LocalHostIface>();\n const localCompute = defaultLocalCompute();\n const start: AgentStartDepsIface = {\n context,\n codec: options.agentCodec ?? defaultAgentCodec,\n localCompute: options.localCompute ?? true,\n compute: { ...localCompute, ...options.localHosts?.compute },\n dial: options.localHosts?.dial ?? defaultLocalHostDial(http),\n hosts,\n };\n const channelSourceOf = options.channelSourceOf ?? defaultChannelSourceOf;\n const clientLevel = { deps: start, projectId: null };\n\n const close = (): void => {\n if (closing.signal.aborted) return;\n closing.abort(\n clientError({ message: 'Agent client closed', status: 0, code: ClientErrorCode.Closed }),\n );\n for (const host of hosts) host.close();\n hosts.clear();\n ownTransport?.close();\n };\n\n return {\n close,\n [Symbol.asyncDispose]: async () => close(),\n health: (healthOptions) =>\n http.request({\n method: HttpMethod.Get,\n path: '/v1/health',\n response: healthResponseSchema,\n signal: healthOptions?.signal,\n }),\n agents: {\n list: (listOptions) =>\n http.request({\n method: HttpMethod.Get,\n path: '/v1/agents',\n query: {\n cursor: listOptions?.cursor,\n limit: listOptions?.limit,\n projectId: listOptions?.projectId,\n },\n response: agentListSchema,\n signal: listOptions?.signal,\n }),\n get: ({ id, signal }) =>\n http.request({\n method: HttpMethod.Get,\n path: `/v1/agents/${encodePath(id)}`,\n response: agentSummarySchema,\n signal,\n }),\n },\n people: (() => {\n const list: PeopleApiIface['list'] = (listOptions) =>\n http.request({\n method: HttpMethod.Get,\n path: '/v1/people',\n query: { cursor: listOptions?.cursor, limit: listOptions?.limit },\n response: personListSchema,\n signal: listOptions?.signal,\n });\n return {\n list,\n all: async (allOptions) => {\n const all: PersonIface[] = [];\n let cursor: string | undefined;\n for (;;) {\n const next = await list({ cursor, signal: allOptions?.signal });\n all.push(...next.people);\n if (next.nextCursor == null) return all;\n cursor = next.nextCursor;\n }\n },\n me: { identityLinks: createIdentityLinksApi(context) },\n };\n })(),\n realtime: { createSession: createRealtimeSession },\n project: ({ id }) => createProjectClient({ context, start, channelSourceOf, projectId: id }),\n projects: createProjectsApi(context),\n events: createEventsApi({ context, projectId: null }),\n organization: createOrganizationApi(context),\n app: {\n eventSubscriptions: createEventSubscriptionsApi({\n context,\n basePath: '/v1/apps/me/event-subscriptions',\n }),\n },\n publishers: createPublishersApi(context),\n inference: {\n offering: (offeringOptions) =>\n http.request({\n method: HttpMethod.Get,\n path: '/v1/inference/offering',\n response: inferenceOfferingSchema,\n signal: offeringOptions?.signal,\n }),\n },\n platformIdentity: {\n exchange: ({ signal, ...value }) =>\n http.request({\n method: HttpMethod.Post,\n path: '/v1/platform-identity/exchange',\n body: { schema: platformIdentityExchangeRequestSchema, value },\n response: platformIdentityExchangeResponseSchema,\n signal,\n }),\n },\n decisions: {\n get: async ({ id, signal }) =>\n (\n await http.request({\n method: HttpMethod.Get,\n path: `/v1/decisions/${encodePath(id)}`,\n response: decisionResponseSchema,\n signal,\n context: { decisionId: id },\n })\n ).decision,\n },\n sessions: createSessionsApi(context),\n conversations: createConversationsApi(context, clientLevel),\n channelBindings: createChannelBindingsApi(context),\n channelTickets: createChannelT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W;AAAA,QACnB,MAAM;AAAA,QACN,MAAM,EAAE,QAAQ,uCAAuC,MAAM;AAAA,QAC7D,UAAU;AAAA,QACV;AAAA,MACF,CAAC;AAAA,IACL;AAAA,IACA,WAAW;AAAA,MACT,KAAK,OAAO,EAAE,IAAI,OAAO,OAErB,MAAM,KAAK,QAAQ;AAAA,QACjB,QAAQ,WAAW;AAAA,QACnB,MAAM,iBAAiB,WAAW,EAAE,CAAC;AAAA,QACrC,UAAU;AAAA,QACV;AAAA,QACA,SAAS,EAAE,YAAY,GAAG;AAAA,MAC5B,CAAC,GACD;AAAA,IACN;AAAA,IACA,UAAU,kBAAkB,OAAO;AAAA,IACnC,eAAe,uBAAuB,SAAS,WAAW;AAAA,IAC1D,iBAAiB,yBAAyB,OAAO;AAAA,IACjD,gBAAgB,wBAAwB,OAAO;AAAA,IAC/C,KAAK,aAAa,EAAE,KAAK,CAAC;AAAA,EAC5B;AACF;",
4
+ "sourcesContent": ["import {\n agentListSchema,\n agentRealtimeTopics,\n agentSummarySchema,\n decisionResponseSchema,\n healthResponseSchema,\n inferenceOfferingSchema,\n personListSchema,\n platformIdentityExchangeRequestSchema,\n platformIdentityExchangeResponseSchema,\n realtimeSessionResponseSchema,\n type AgentListIface,\n type AgentSummaryIface,\n type DecisionIface,\n type HealthResponseIface,\n type InferenceOfferingIface,\n type PersonIface,\n type PersonListIface,\n type PlatformIdentityExchangeRequestIface,\n type PlatformIdentityExchangeResponseIface,\n type RealtimeSessionResponseIface,\n} from '@finalai/agent-protocol/agent-platform';\nimport { createAcpApi, type AcpApiIface } from \"./acp.mjs\";\nimport type { AgentValueCodecIface } from \"./agent-input.mjs\";\nimport {\n createChannelBindingsApi,\n createChannelTicketsApi,\n createIdentityLinksApi,\n type ChannelBindingsApiIface,\n type ChannelSourceOf,\n type ChannelTicketsApiIface,\n type IdentityLinksApiIface,\n} from \"./channels.mjs\";\nimport { encodePath, type ClientContextIface, type SignalOptionsIface } from \"./context.mjs\";\nimport { createConversationsApi, type ConversationsApiIface } from \"./conversations.mjs\";\nimport { defaultAgentCodec, defaultChannelSourceOf } from \"./defaults.mjs\";\nimport { clientError, ClientErrorCode } from \"./errors.mjs\";\nimport {\n createEventsApi,\n createEventSubscriptionsApi,\n type EventsApiIface,\n type EventSubscriptionsApiIface,\n} from \"./events.mjs\";\nimport { defaultStreamTiming, type StreamTimingIface } from \"./frame-stream.mjs\";\nimport {\n createHttp,\n HttpMethod,\n type AgentClientAuth,\n type FetchIface,\n type HeadersOption,\n type HttpIface,\n} from \"./http.mjs\";\nimport {\n createGatewayRealtimeTransport,\n type GatewayConnect,\n type GatewayRealtimeTransportIface,\n type RealtimeTransportIface,\n} from \"./realtime.mjs\";\nimport type { LocalComputeIface, LocalHostIface, LocalHostSocketIface } from \"./local-host.mjs\";\nimport { createProjectClient, type ProjectClientIface } from \"./project.mjs\";\nimport { createProjectsApi, type ProjectsApiIface } from \"./projects.mjs\";\nimport { createOrganizationApi, type OrganizationApiIface } from \"./organization.mjs\";\nimport { createPublishersApi, type PublishersApiIface } from \"./publishers.mjs\";\nimport { createSessionsApi, type SessionsApiIface } from \"./sessions.mjs\";\nimport type { AgentStartDepsIface } from \"./start.mjs\";\n\n/** Final's agents API. */\nexport const DEFAULT_AGENTS_HOST = 'https://agent-session.final.ai';\n\nexport interface CreateClientOptionsIface {\n auth: AgentClientAuth;\n /**\n * Whether this process provides the files and shell an agent requires when\n * the caller leaves them out, so the model's file edits and commands run\n * here, on this machine. Defaults to true in Node and false in browsers and\n * React Native, which have no files or shell to give. A server should\n * provide every capability explicitly and pass false, so an omission fails\n * with `requirements_unmet` instead of giving the model a shell in the server.\n */\n localCompute?: boolean;\n /**\n * The agents API origin (default `https://agent-session.final.ai`; its API is\n * under `/api` and ACP at `/acp/ws`), or a base URL the API routes are mounted under.\n */\n host?: string;\n /** Extra headers per request; console clients send their client identity header here. */\n headers?: HeadersOption;\n /** API requests (the host's routes); carries auth and caller headers. */\n fetch?: FetchIface;\n /**\n * Presigned storage requests (attachment uploads). Gets only the headers the\n * presign requires, never auth, client identity or cookies, so a storage\n * bucket's CORS and third-party hosts see nothing of the caller. Defaults to\n * `globalThis.fetch`; keep it free of header-injecting wrappers.\n */\n storageFetch?: FetchIface;\n /** console-web and console-mobile pass their realtime clients; defaults to a gateway connection. */\n realtime?: RealtimeTransportIface;\n /** Seam for the default transport's gateway connection. */\n gatewayConnect?: GatewayConnect;\n /** Seam for stream retry timing (tests). */\n timing?: Partial<StreamTimingIface>;\n /** Seam for idempotency keys and client message ids; defaults to `crypto.randomUUID`. */\n newKey?: () => string;\n /** Seam for the client clock (conversation recovery windows). */\n now?: () => number;\n /** Seam: how agent values become documents and in-process code. */\n agentCodec?: AgentValueCodecIface;\n /** Seam: how a channel value becomes its source. */\n channelSourceOf?: ChannelSourceOf;\n /** Seams for local hosts: the socket, and the sandbox this process serves. */\n localHosts?: {\n /** Opens the local host socket; abandons it when `signal` aborts. */\n dial?: (path: string, signal?: AbortSignal) => Promise<LocalHostSocketIface>;\n compute?: Partial<LocalComputeIface>;\n };\n}\n\nexport interface AgentsApiIface {\n /**\n * The agents the caller can use; with `projectId`, those usable there (its own and those\n * inherited from its ancestors). Without it, everything the caller can access (an API key: its\n * parent project and every project it is granted; a person: every project they can read).\n * Fetch one as data with `client.project({ id }).agents.get`.\n */\n list: (\n options?: SignalOptionsIface & { cursor?: string; limit?: number; projectId?: string },\n ) => Promise<AgentListIface>;\n /**\n * One agent the caller can use, by id, in whichever project owns it; also one that was never\n * published (`hash` and `revisionId` are null). Archived agents are not found.\n */\n get: (args: { id: string } & SignalOptionsIface) => Promise<AgentSummaryIface>;\n}\n\nexport interface PeopleApiIface {\n /** One page of the caller's organization members, by name; pass `nextCursor` as `cursor` for the next. */\n list: (\n options?: SignalOptionsIface & { cursor?: string; limit?: number },\n ) => Promise<PersonListIface>;\n /** Every member of the caller's organization (all pages). */\n all: (options?: SignalOptionsIface) => Promise<PersonIface[]>;\n /** The caller's own person (or, for an API key or app, the actor it names). */\n me: { identityLinks: IdentityLinksApiIface };\n}\n\nexport interface RealtimeApiIface {\n /**\n * Mints a gateway session (`POST /v1/realtime/session`) for the signed-in user:\n * the gateway URL, a short-lived token, and the user id realtime topics are keyed by.\n * Pass it as `createSession` to `createGatewayRealtimeTransport` when supplying a transport.\n */\n createSession: (options?: SignalOptionsIface) => Promise<RealtimeSessionResponseIface>;\n}\n\nexport interface InferenceApiIface {\n /**\n * The vendors and models the platform's own metered inference serves, with\n * prices (`GET /v1/inference/offering`, public). A harness using the\n * platform's inference can run only models listed here.\n */\n offering: (options?: SignalOptionsIface) => Promise<InferenceOfferingIface>;\n}\n\nexport interface PlatformIdentityApiIface {\n /**\n * Exchanges a sandbox-provider (or downstream) assertion the platform issued\n * for a fresh one: for the provider's own URL (a refresh) or a backend its\n * registration was granted. The subject token is the credential.\n */\n exchange: (\n args: PlatformIdentityExchangeRequestIface & SignalOptionsIface,\n ) => Promise<PlatformIdentityExchangeResponseIface>;\n}\n\nexport interface DecisionsApiIface {\n /** One decision awaiting the caller's answer, as `conversations.decisions` lists it. */\n get: (args: { id: string } & SignalOptionsIface) => Promise<DecisionIface>;\n}\n\nexport interface AppApiIface {\n /**\n * The calling app's event subscriptions, across every organization that\n * installed it. Needs an app-level token.\n */\n eventSubscriptions: EventSubscriptionsApiIface;\n}\n\nexport interface AgentClientIface {\n /** One project: where sessions, conversations, sandboxes and integrations are created. */\n project: (args: { id: string }) => ProjectClientIface;\n /** The project tree: list projects and create them. */\n projects: ProjectsApiIface;\n /** The event feed across everything the caller can see; `project({ id }).events` narrows it. */\n events: EventsApiIface;\n app: AppApiIface;\n /** Publishers' public agents, channels, harnesses and ACP adapters. */\n publishers: PublishersApiIface;\n inference: InferenceApiIface;\n platformIdentity: PlatformIdentityApiIface;\n decisions: DecisionsApiIface;\n health: (options?: SignalOptionsIface) => Promise<HealthResponseIface>;\n /** The caller's organization: model credentials, budgets and policies. */\n organization: OrganizationApiIface;\n agents: AgentsApiIface;\n people: PeopleApiIface;\n realtime: RealtimeApiIface;\n /** Existing sessions by id; create them through `project({ id }).sessions`. */\n sessions: SessionsApiIface;\n /** The caller's conversations; create them through `project({ id }).conversations`. */\n conversations: ConversationsApiIface;\n /** Channel installs by id; install them through `project({ id }).channels`. */\n channelBindings: ChannelBindingsApiIface;\n /** Tickets from an installer's link and connect pages. */\n channelTickets: ChannelTicketsApiIface;\n /**\n * ACP-native access (`/acp/ws`): an ACP v2 ClientApp connection on which the\n * agents API is the agent. The ACP SDK loads on the first `connect`.\n */\n acp: AcpApiIface;\n /**\n * Ends every stream (they reject with a `client_closed` ClientError) and every\n * local host connection (the platform then reports this process's tools and\n * compute as unavailable; sessions carry on) and, when the client created its\n * own realtime transport, closes the gateway connection and cancels its\n * retries. A transport passed in `realtime` belongs to the caller and is left\n * open. Idempotent.\n */\n close: () => void;\n [Symbol.asyncDispose]: () => Promise<void>;\n}\n\n/**\n * What `createClient` uses unless a seam replaces it, where that differs by\n * runtime: Node serves compute and dials the local host socket itself;\n * browsers and React Native do neither unless the caller passes the seams.\n */\nexport interface ClientRuntimeIface {\n /** `localCompute` when the caller leaves it out. */\n localCompute: boolean;\n compute: () => LocalComputeIface;\n dial: (http: HttpIface) => (path: string, signal?: AbortSignal) => Promise<LocalHostSocketIface>;\n}\n\nexport const createClientFor = (\n runtime: ClientRuntimeIface,\n options: CreateClientOptionsIface,\n): AgentClientIface => {\n const http = createHttp({\n host: options.host ?? DEFAULT_AGENTS_HOST,\n auth: options.auth,\n headers: options.headers,\n fetch: options.fetch,\n });\n let realtime = options.realtime ?? null;\n let ownTransport: GatewayRealtimeTransportIface | null = null;\n const closing = new AbortController();\n const createRealtimeSession: RealtimeApiIface['createSession'] = (sessionOptions) =>\n http.request({\n method: HttpMethod.Post,\n path: '/v1/realtime/session',\n response: realtimeSessionResponseSchema,\n signal: sessionOptions?.signal,\n });\n let realtimeOwner: Promise<RealtimeSessionResponseIface> | null = null;\n const realtimeOwnerSession = () => {\n if (realtimeOwner != null) return realtimeOwner;\n const pending = createRealtimeSession({ signal: closing.signal });\n realtimeOwner = pending;\n void pending.catch(() => {\n if (realtimeOwner === pending) realtimeOwner = null;\n });\n return pending;\n };\n let realtimeUser: Promise<string> | null = null;\n // Shared by every stream, so it is cancelled only with the client, never by one caller.\n const realtimeUserId: ClientContextIface['realtimeUserId'] = () => {\n if (realtimeUser != null) return realtimeUser;\n const pending = realtimeOwnerSession().then((session) => {\n if (session.userId == null)\n throw new Error('This client authenticates as an API-key owner, not a user');\n return session.userId;\n });\n realtimeUser = pending;\n // A failed (or aborted) read is not cached.\n pending.catch(() => {\n if (realtimeUser === pending) realtimeUser = null;\n });\n return pending;\n };\n const context: ClientContextIface = {\n http,\n closeSignal: closing.signal,\n realtimeUserId,\n // Conversations is the only collection.\n realtimeCollectionTopic: async () => {\n const owner = await realtimeOwnerSession();\n // API keys act in their project, not as members: they reach agents through channels.\n if (owner.userId == null)\n throw new Error('Collection streams belong to users; API-key owners use session streams');\n return agentRealtimeTopics.userConversations(owner.userId);\n },\n storageFetch: options.storageFetch ?? ((input, init) => globalThis.fetch(input, init)),\n realtime: () => {\n if (realtime != null) return realtime;\n ownTransport = createGatewayRealtimeTransport({\n createSession: () => createRealtimeSession(),\n connect: options.gatewayConnect,\n });\n if (closing.signal.aborted) ownTransport.close();\n realtime = ownTransport;\n return realtime;\n },\n timing: { ...defaultStreamTiming, ...options.timing },\n newKey: options.newKey ?? (() => globalThis.crypto.randomUUID()),\n now: options.now ?? Date.now,\n };\n\n const hosts = new Set<LocalHostIface>();\n const start: AgentStartDepsIface = {\n context,\n codec: options.agentCodec ?? defaultAgentCodec,\n localCompute: options.localCompute ?? runtime.localCompute,\n compute: { ...runtime.compute(), ...options.localHosts?.compute },\n dial: options.localHosts?.dial ?? runtime.dial(http),\n hosts,\n };\n const channelSourceOf = options.channelSourceOf ?? defaultChannelSourceOf;\n const clientLevel = { deps: start, projectId: null };\n\n const close = (): void => {\n if (closing.signal.aborted) return;\n closing.abort(\n clientError({ message: 'Agent client closed', status: 0, code: ClientErrorCode.Closed }),\n );\n for (const host of hosts) host.close();\n hosts.clear();\n ownTransport?.close();\n };\n\n return {\n close,\n [Symbol.asyncDispose]: async () => close(),\n health: (healthOptions) =>\n http.request({\n method: HttpMethod.Get,\n path: '/v1/health',\n response: healthResponseSchema,\n signal: healthOptions?.signal,\n }),\n agents: {\n list: (listOptions) =>\n http.request({\n method: HttpMethod.Get,\n path: '/v1/agents',\n query: {\n cursor: listOptions?.cursor,\n limit: listOptions?.limit,\n projectId: listOptions?.projectId,\n },\n response: agentListSchema,\n signal: listOptions?.signal,\n }),\n get: ({ id, signal }) =>\n http.request({\n method: HttpMethod.Get,\n path: `/v1/agents/${encodePath(id)}`,\n response: agentSummarySchema,\n signal,\n }),\n },\n people: (() => {\n const list: PeopleApiIface['list'] = (listOptions) =>\n http.request({\n method: HttpMethod.Get,\n path: '/v1/people',\n query: { cursor: listOptions?.cursor, limit: listOptions?.limit },\n response: personListSchema,\n signal: listOptions?.signal,\n });\n return {\n list,\n all: async (allOptions) => {\n const all: PersonIface[] = [];\n let cursor: string | undefined;\n for (;;) {\n const next = await list({ cursor, signal: allOptions?.signal });\n all.push(...next.people);\n if (next.nextCursor == null) return all;\n cursor = next.nextCursor;\n }\n },\n me: { identityLinks: createIdentityLinksApi(context) },\n };\n })(),\n realtime: { createSession: createRealtimeSession },\n project: ({ id }) => createProjectClient({ context, start, channelSourceOf, projectId: id }),\n projects: createProjectsApi(context),\n events: createEventsApi({ context, projectId: null }),\n organization: createOrganizationApi(context),\n app: {\n eventSubscriptions: createEventSubscriptionsApi({\n context,\n basePath: '/v1/apps/me/event-subscriptions',\n }),\n },\n publishers: createPublishersApi(context),\n inference: {\n offering: (offeringOptions) =>\n http.request({\n method: HttpMethod.Get,\n path: '/v1/inference/offering',\n response: inferenceOfferingSchema,\n signal: offeringOptions?.signal,\n }),\n },\n platformIdentity: {\n exchange: ({ signal, ...value }) =>\n http.request({\n method: HttpMethod.Post,\n path: '/v1/platform-identity/exchange',\n body: { schema: platformIdentityExchangeRequestSchema, value },\n response: platformIdentityExchangeResponseSchema,\n signal,\n }),\n },\n decisions: {\n get: async ({ id, signal }) =>\n (\n await http.request({\n method: HttpMethod.Get,\n path: `/v1/decisions/${encodePath(id)}`,\n response: decisionResponseSchema,\n signal,\n context: { decisionId: id },\n })\n ).decision,\n },\n sessions: createSessionsApi(context),\n conversations: createConversationsApi(context, clientLevel),\n channelBindings: createChannelBindingsApi(context),\n channelTickets: createChannelTicketsApi(context),\n acp: createAcpApi({ http }),\n };\n};\n"],
5
+ "mappings": "AAAA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAWK;AACP,SAAS,oBAAsC;AAE/C;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OAKK;AACP,SAAS,kBAAoE;AAC7E,SAAS,8BAA0D;AACnE,SAAS,mBAAmB,8BAA8B;AAC1D,SAAS,aAAa,uBAAuB;AAC7C;AAAA,EACE;AAAA,EACA;AAAA,OAGK;AACP,SAAS,2BAAmD;AAC5D;AAAA,EACE;AAAA,EACA;AAAA,OAKK;AACP;AAAA,EACE;AAAA,OAIK;AAEP,SAAS,2BAAoD;AAC7D,SAAS,yBAAgD;AACzD,SAAS,6BAAwD;AACjE,SAAS,2BAAoD;AAC7D,SAAS,yBAAgD;AAIlD,MAAM,sBAAsB;AAiL5B,MAAM,kBAAkB,CAC7B,SACA,YACqB;AACrB,QAAM,OAAO,WAAW;AAAA,IACtB,MAAM,QAAQ,QAAQ;AAAA,IACtB,MAAM,QAAQ;AAAA,IACd,SAAS,QAAQ;AAAA,IACjB,OAAO,QAAQ;AAAA,EACjB,CAAC;AACD,MAAI,WAAW,QAAQ,YAAY;AACnC,MAAI,eAAqD;AACzD,QAAM,UAAU,IAAI,gBAAgB;AACpC,QAAM,wBAA2D,CAAC,mBAChE,KAAK,QAAQ;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;AAAA,IACvC,WAAW;AAAA,MACT,UAAU,CAAC,oBACT,KAAK,QAAQ;AAAA,QACX,QAAQ,WAAW;AAAA,QACnB,MAAM;AAAA,QACN,UAAU;AAAA,QACV,QAAQ,iBAAiB;AAAA,MAC3B,CAAC;AAAA,IACL;AAAA,IACA,kBAAkB;AAAA,MAChB,UAAU,CAAC,EAAE,QAAQ,GAAG,MAAM,MAC5B,KAAK,QAAQ;AAAA,QACX,QAAQ,WAAW;AAAA,QACnB,MAAM;AAAA,QACN,MAAM,EAAE,QAAQ,uCAAuC,MAAM;AAAA,QAC7D,UAAU;AAAA,QACV;AAAA,MACF,CAAC;AAAA,IACL;AAAA,IACA,WAAW;AAAA,MACT,KAAK,OAAO,EAAE,IAAI,OAAO,OAErB,MAAM,KAAK,QAAQ;AAAA,QACjB,QAAQ,WAAW;AAAA,QACnB,MAAM,iBAAiB,WAAW,EAAE,CAAC;AAAA,QACrC,UAAU;AAAA,QACV;AAAA,QACA,SAAS,EAAE,YAAY,GAAG;AAAA,MAC5B,CAAC,GACD;AAAA,IACN;AAAA,IACA,UAAU,kBAAkB,OAAO;AAAA,IACnC,eAAe,uBAAuB,SAAS,WAAW;AAAA,IAC1D,iBAAiB,yBAAyB,OAAO;AAAA,IACjD,gBAAgB,wBAAwB,OAAO;AAAA,IAC/C,KAAK,aAAa,EAAE,KAAK,CAAC;AAAA,EAC5B;AACF;",
6
6
  "names": []
7
7
  }
@@ -1,8 +1,4 @@
1
1
  import type { AgentValueCodecIface } from "./agent-input.mjs";
2
2
  import { type ChannelSourceOf } from "./channels.mjs";
3
- import type { HttpIface } from "./http.mjs";
4
- import type { LocalComputeIface, LocalHostSocketIface } from "./local-host.mjs";
5
3
  export declare const defaultAgentCodec: AgentValueCodecIface;
6
4
  export declare const defaultChannelSourceOf: ChannelSourceOf;
7
- export declare const defaultLocalCompute: () => LocalComputeIface;
8
- export declare const defaultLocalHostDial: (http: HttpIface) => (path: string, signal?: AbortSignal) => Promise<LocalHostSocketIface>;
@@ -1,9 +1,6 @@
1
- import { connectSandboxClient } from "@finalai/agent-provider/sandbox/client";
2
- import { frameChannelFromWebSocket } from "@finalai/agent-provider/sandbox/wire";
3
1
  import * as z from "zod";
4
2
  import { noChannelSource } from "./channels.mjs";
5
3
  import { clientError, ClientErrorCode } from "./errors.mjs";
6
- import { LOCAL_HOST_SUBPROTOCOL } from "./local-host-protocol.mjs";
7
4
  const agentValueSchema = z.custom(
8
5
  (value) => typeof value === "object" && value != null && "require" in value && "name" in value,
9
6
  "Not an agent: define it with defineAgent, or fetch it with project.agents.get"
@@ -22,56 +19,8 @@ const defaultAgentCodec = {
22
19
  inProcessCodeOf: async (agent) => (await import("@finalai/agent-definition")).inProcessCodeOf(agentValueOf(agent))
23
20
  };
24
21
  const defaultChannelSourceOf = noChannelSource;
25
- const defaultLocalCompute = () => ({
26
- sandbox: async () => {
27
- const { createLocalSandbox } = await import("@finalai/final-agent-provider/sandboxes/local");
28
- return createLocalSandbox({ root: globalThis.process.cwd() });
29
- },
30
- openSandbox: (endpoint) => connectSandboxClient({
31
- url: endpoint.url,
32
- token: endpoint.token,
33
- expiresAt: endpoint.expiresAt
34
- })
35
- });
36
- const defaultLocalHostDial = (http) => async (path, signal) => {
37
- const url = http.url(path);
38
- url.protocol = url.protocol === "http:" ? "ws:" : "wss:";
39
- const headers = await http.headers();
40
- const { WebSocket } = await import("ws");
41
- signal?.throwIfAborted();
42
- const socket = new WebSocket(url, [LOCAL_HOST_SUBPROTOCOL], { headers });
43
- let tcp = null;
44
- let referenced = true;
45
- socket.on("upgrade", (response) => {
46
- tcp = response.socket;
47
- if (!referenced) tcp.unref();
48
- });
49
- const { channel, opened } = frameChannelFromWebSocket(socket);
50
- const onAbort = () => socket.terminate();
51
- signal?.addEventListener("abort", onAbort, { once: true });
52
- try {
53
- await opened;
54
- } finally {
55
- signal?.removeEventListener("abort", onAbort);
56
- }
57
- return {
58
- ...channel,
59
- keepAlive: {
60
- ref: () => {
61
- referenced = true;
62
- tcp?.ref();
63
- },
64
- unref: () => {
65
- referenced = false;
66
- tcp?.unref();
67
- }
68
- }
69
- };
70
- };
71
22
  export {
72
23
  defaultAgentCodec,
73
- defaultChannelSourceOf,
74
- defaultLocalCompute,
75
- defaultLocalHostDial
24
+ defaultChannelSourceOf
76
25
  };
77
26
  //# sourceMappingURL=defaults.mjs.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../src/agent-client/defaults.ts"],
4
- "sourcesContent": ["import type { AgentIface } from '@finalai/agent-definition';\nimport { connectSandboxClient } from '@finalai/agent-provider/sandbox/client';\nimport { frameChannelFromWebSocket } from '@finalai/agent-provider/sandbox/wire';\nimport * as z from 'zod';\nimport type { AgentValueCodecIface } from \"./agent-input.mjs\";\nimport { noChannelSource, type ChannelSourceOf } from \"./channels.mjs\";\nimport { clientError, ClientErrorCode } from \"./errors.mjs\";\nimport type { HttpIface } from \"./http.mjs\";\nimport { LOCAL_HOST_SUBPROTOCOL } from \"./local-host-protocol.mjs\";\nimport type { LocalComputeIface, LocalHostSocketIface } from \"./local-host.mjs\";\n\n// What `createClient` uses unless a seam replaces it.\n\nconst agentValueSchema = z.custom<AgentIface>(\n (value) => typeof value === 'object' && value != null && 'require' in value && 'name' in value,\n 'Not an agent: define it with defineAgent, or fetch it with project.agents.get',\n);\n\nconst agentValueOf = (agent: object): AgentIface => {\n const value = agentValueSchema.safeParse(agent);\n if (value.success) return value.data;\n throw clientError({\n message: value.error.issues[0]?.message ?? 'Not an agent',\n status: 0,\n code: ClientErrorCode.InvalidRequest,\n });\n};\n\n// Loaded on first use, so browser bundles of the client leave the authoring\n// code (and its source parser) out until an agent value is started.\nexport const defaultAgentCodec: AgentValueCodecIface = {\n documentOf: async (agent) =>\n (await import('@finalai/agent-definition')).documentOf(agentValueOf(agent)),\n inProcessCodeOf: async (agent) =>\n (await import('@finalai/agent-definition')).inProcessCodeOf(agentValueOf(agent)),\n};\n\nexport const defaultChannelSourceOf: ChannelSourceOf = noChannelSource;\n\n// The model's files and shell are this process's working directory, as for a\n// coding agent run on this machine. Loaded on use: it needs Node.\nexport const defaultLocalCompute = (): LocalComputeIface => ({\n sandbox: async () => {\n const { createLocalSandbox } = await import('@finalai/final-agent-provider/sandboxes/local');\n return createLocalSandbox({ root: globalThis.process.cwd() });\n },\n openSandbox: (endpoint) =>\n connectSandboxClient({\n url: endpoint.url,\n token: endpoint.token,\n expiresAt: endpoint.expiresAt,\n }),\n});\n\n// The local host socket is dialed from Node with the client's own headers. It\n// keeps the process alive only while the host starts or is in use (see\n// LocalHostKeepAliveIface), so a script that is done exits and the platform\n// reports its tools and compute as unavailable.\nexport const defaultLocalHostDial =\n (http: HttpIface) =>\n async (path: string, signal?: AbortSignal): Promise<LocalHostSocketIface> => {\n const url = http.url(path);\n url.protocol = url.protocol === 'http:' ? 'ws:' : 'wss:';\n const headers = await http.headers();\n const { WebSocket } = await import('ws');\n signal?.throwIfAborted();\n const socket = new WebSocket(url, [LOCAL_HOST_SUBPROTOCOL], { headers });\n let tcp: { ref: () => unknown; unref: () => unknown } | null = null;\n let referenced = true;\n socket.on('upgrade', (response) => {\n tcp = response.socket;\n if (!referenced) tcp.unref();\n });\n const { channel, opened } = frameChannelFromWebSocket(socket);\n // Aborting while the socket opens tears it down, which rejects `opened`.\n const onAbort = () => socket.terminate();\n signal?.addEventListener('abort', onAbort, { once: true });\n try {\n await opened;\n } finally {\n signal?.removeEventListener('abort', onAbort);\n }\n return {\n ...channel,\n keepAlive: {\n ref: () => {\n referenced = true;\n tcp?.ref();\n },\n unref: () => {\n referenced = false;\n tcp?.unref();\n },\n },\n };\n };\n"],
5
- "mappings": "AACA,SAAS,4BAA4B;AACrC,SAAS,iCAAiC;AAC1C,YAAY,OAAO;AAEnB,SAAS,uBAA6C;AACtD,SAAS,aAAa,uBAAuB;AAE7C,SAAS,8BAA8B;AAKvC,MAAM,mBAAmB,EAAE;AAAA,EACzB,CAAC,UAAU,OAAO,UAAU,YAAY,S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,QAAI,CAAC,WAAY,KAAI,MAAM;AAAA,EAC7B,CAAC;AACD,QAAM,EAAE,SAAS,OAAO,IAAI,0BAA0B,MAAM;AAE5D,QAAM,UAAU,MAAM,OAAO,UAAU;AACvC,UAAQ,iBAAiB,SAAS,SAAS,EAAE,MAAM,KAAK,CAAC;AACzD,MAAI;AACF,UAAM;AAAA,EACR,UAAE;AACA,YAAQ,oBAAoB,SAAS,OAAO;AAAA,EAC9C;AACA,SAAO;AAAA,IACL,GAAG;AAAA,IACH,WAAW;AAAA,MACT,KAAK,MAAM;AACT,qBAAa;AACb,aAAK,IAAI;AAAA,MACX;AAAA,MACA,OAAO,MAAM;AACX,qBAAa;AACb,aAAK,MAAM;AAAA,MACb;AAAA,IACF;AAAA,EACF;AACF;",
4
+ "sourcesContent": ["import type { AgentIface } from '@finalai/agent-definition';\nimport * as z from 'zod';\nimport type { AgentValueCodecIface } from \"./agent-input.mjs\";\nimport { noChannelSource, type ChannelSourceOf } from \"./channels.mjs\";\nimport { clientError, ClientErrorCode } from \"./errors.mjs\";\n\n// What `createClient` uses unless a seam replaces it, in every runtime.\n\nconst agentValueSchema = z.custom<AgentIface>(\n (value) => typeof value === 'object' && value != null && 'require' in value && 'name' in value,\n 'Not an agent: define it with defineAgent, or fetch it with project.agents.get',\n);\n\nconst agentValueOf = (agent: object): AgentIface => {\n const value = agentValueSchema.safeParse(agent);\n if (value.success) return value.data;\n throw clientError({\n message: value.error.issues[0]?.message ?? 'Not an agent',\n status: 0,\n code: ClientErrorCode.InvalidRequest,\n });\n};\n\n// Loaded on first use, so browser bundles of the client leave the authoring\n// code (and its source parser) out until an agent value is started.\nexport const defaultAgentCodec: AgentValueCodecIface = {\n documentOf: async (agent) =>\n (await import('@finalai/agent-definition')).documentOf(agentValueOf(agent)),\n inProcessCodeOf: async (agent) =>\n (await import('@finalai/agent-definition')).inProcessCodeOf(agentValueOf(agent)),\n};\n\nexport const defaultChannelSourceOf: ChannelSourceOf = noChannelSource;\n"],
5
+ "mappings": "AACA,YAAY,OAAO;AAEnB,SAAS,uBAA6C;AACtD,SAAS,aAAa,uBAAuB;AAI7C,MAAM,mBAAmB,EAAE;AAAA,EACzB,CAAC,UAAU,OAAO,UAAU,YAAY,SAAS,QAAQ,aAAa,SAAS,UAAU;AAAA,EACzF;AACF;AAEA,MAAM,eAAe,CAAC,UAA8B;AAClD,QAAM,QAAQ,iBAAiB,UAAU,KAAK;AAC9C,MAAI,MAAM,QAAS,QAAO,MAAM;AAChC,QAAM,YAAY;AAAA,IAChB,SAAS,MAAM,MAAM,OAAO,CAAC,GAAG,WAAW;AAAA,IAC3C,QAAQ;AAAA,IACR,MAAM,gBAAgB;AAAA,EACxB,CAAC;AACH;AAIO,MAAM,oBAA0C;AAAA,EACrD,YAAY,OAAO,WAChB,MAAM,OAAO,2BAA2B,GAAG,WAAW,aAAa,KAAK,CAAC;AAAA,EAC5E,iBAAiB,OAAO,WACrB,MAAM,OAAO,2BAA2B,GAAG,gBAAgB,aAAa,KAAK,CAAC;AACnF;AAEO,MAAM,yBAA0C;",
6
6
  "names": []
7
7
  }
@@ -1,35 +1,2 @@
1
- export * from '@finalai/agent-protocol/agent-platform';
2
- export { Capability, FilesAccess, ScreenAccess, ShellAccess, type CapabilityAccess, } from '@finalai/agent-protocol';
3
- export { AcpAuthMode, type AcpApiIface, type AcpConnectArgsIface } from "./acp.mjs";
4
- export { createTextCollector, isUserMessageFor, sessionUpdateOf, textOf, turnEndOf, type AcpSessionUpdateIface, type TurnEndIface, } from "./acp-frames.mjs";
5
- export type { AgentInput, AgentValue, AgentValueCodecIface } from "./agent-input.mjs";
6
- export type { ActorOptionIface, ChannelAppsApiIface, ChannelBindingsApiIface, ChannelSourceIface, ChannelSourceOf, ChannelTicketsApiIface, IdentityLinksApiIface, InstallChannelArgsIface, ProjectChannelsApiIface, PublishChannelArgsIface, UpdateChannelBindingArgsIface, } from "./channels.mjs";
7
- export { DEFAULT_AGENTS_HOST, createClient, type AgentClientIface, type AgentsApiIface, type AppApiIface, type CreateClientOptionsIface, type DecisionsApiIface, type InferenceApiIface, type PeopleApiIface, type PlatformIdentityApiIface, type RealtimeApiIface, } from "./client.mjs";
8
- export { CollectionEventKind, CollectionResyncReason, type CollectionEvent, type CollectionEventsOptionsIface, type CollectionResyncEventIface, } from "./collection-events.mjs";
9
- export { ConfigOptionCategory, configSelectFor, configSelectsOf, type ConfigSelectChoiceIface, type ConfigSelectIface, type SessionConfigOptionIface, } from "./config-options.mjs";
10
- export type { EnumInput, SignalOptionsIface } from "./context.mjs";
11
- export type { AllowedEndpointsApiIface, BudgetsApiIface, ModelCredentialGrantsApiIface, ModelCredentialsApiIface, OrganizationApiIface, OrganizationPolicyApiIface, SpendingRestrictionsApiIface, } from "./organization.mjs";
12
- export type { ParticipantConfigurationApiIface } from "./participant-configuration.mjs";
13
- export type { ConversationChannelRoutesApiIface, ConversationContextApiIface, ConversationContextEntryInputIface, ConversationDecisionsApiIface, ConversationInputsApiIface, ConversationLabelsApiIface, ConversationReadGrantsApiIface, ConversationResourcesIface, ResourceSubscriptionsApiIface, SendInputArgsIface, } from "./conversation-resources.mjs";
14
- export { TURN_OPEN_SESSION_STATES, isNewerMessageVersion, messageVersionOf, type MessageVersionIface, } from "./conversations.mjs";
15
- export type { ConversationAgentTurnIface, ConversationEvent, ConversationEventMetaIface, ConversationEventsOptionsIface, ConversationHandleIface, ConversationsApiIface, CreateConversationArgsIface, ListMessagesOptionsIface, OpenedConversationIface, ParticipantCreateInput, ParticipantsApiIface, ProjectConversationsApiIface, SandboxFileContentArgsIface, SandboxFileContentRequestIface, SendMessageOptionsIface, SentMessageIface, UploadAttachmentArgsIface, } from "./conversations.mjs";
16
- export { AgentClientErrorName, ClientErrorCode, DecisionErrorReason, clientError, decisionError, isClientError, isDecisionError, isRealtimeSubscriptionError, isRequirementsUnmetError, isTerminalRealtimeError, isTurnRejectedError, realtimeSubscriptionError, requirementsUnmetError, turnRejectedError, type AgentClientError, type ClientErrorIface, type DecisionErrorIface, type RealtimeSubscriptionErrorIface, type RequirementsUnmetErrorIface, type TurnRejectedErrorIface, } from "./errors.mjs";
17
- export { EVENTS_POLL_INTERVAL_MS, type EventsApiIface, type EventSubscriptionsApiIface, type ListEventsOptionsIface, type StreamEventsOptionsIface, } from "./events.mjs";
18
- export { defaultStreamTiming, type StreamTimingIface } from "./frame-stream.mjs";
19
- export type { AgentClientAuth, FetchIface, HeadersOption } from "./http.mjs";
20
- export type { AcpAdaptersApiIface, DefinitionSelectorIface, HarnessesApiIface, SubscriptionAllowancesApiIface, } from "./harnesses.mjs";
21
- export type { IntegrationsApiIface } from "./integrations.mjs";
22
- export { SessionLiveEventKind, type SessionLiveEvent } from "./live-stream.mjs";
23
- export type { LocalComputeIface } from "./local-host.mjs";
24
- export type { OAuthClientsApiIface, SignInReturnOriginsApiIface } from "./oauth-clients.mjs";
25
- export type { ProjectClientIface } from "./project.mjs";
26
- export type { AgentSelectorIface, ProjectAgentsApiIface } from "./project-agents.mjs";
27
- export type { ProjectApiKeysApiIface, ProjectMembersApiIface, ProjectResourceApiIface, ProjectsApiIface, } from "./projects.mjs";
28
- export type { ProjectPublisherApiIface, PublicNamesApiIface, PublisherHandleIface, PublishersApiIface, } from "./publishers.mjs";
29
- export { provideDocumentOf, resourceIdOf, type ProvideIface, type ProvidePatchIface, type ResourceRef, type ResourceRefIface, } from "./provide.mjs";
30
- export { createGatewayRealtimeTransport, type GatewayConnect, type GatewayConnectionIface, type GatewayRealtimeTransportOptionsIface, type RealtimeSubscribeOptionsIface, type RealtimeTransportFrameIface, type RealtimeTransportIface, } from "./realtime.mjs";
31
- export { SANDBOX_FILE_URI_SCHEME, createSandboxFileUri, parseSandboxFileUri, type SandboxFileTargetIface, } from "./sandbox-uri.mjs";
32
- export type { SandboxProvidersApiIface } from "./sandbox-providers.mjs";
33
- export type { CreateSandboxOptionsIface, SandboxEnvironmentValueIface, SandboxHandleIface, SandboxOwnerIface, SandboxSetupRefIface, SandboxSetupsApiIface, SandboxesApiIface, } from "./sandboxes.mjs";
34
- export type { ProjectSchedulesApiIface } from "./schedules.mjs";
35
- export type { CreateSessionArgsIface, CreatedSessionIface, ForkSessionOptionsIface, ProjectSessionsApiIface, RespondArgs, SendOptionsIface, SessionHandleIface, SessionsApiIface, StreamOptionsIface, TurnHandleIface, TurnResultIface, } from "./sessions.mjs";
1
+ export * from "./api.mjs";
2
+ export { createClient } from "./node.mjs";
@@ -1,112 +1,6 @@
1
- export * from "@finalai/agent-protocol/agent-platform";
2
- import {
3
- Capability,
4
- FilesAccess,
5
- ScreenAccess,
6
- ShellAccess
7
- } from "@finalai/agent-protocol";
8
- import { AcpAuthMode } from "./acp.mjs";
9
- import {
10
- createTextCollector,
11
- isUserMessageFor,
12
- sessionUpdateOf,
13
- textOf,
14
- turnEndOf
15
- } from "./acp-frames.mjs";
16
- import {
17
- DEFAULT_AGENTS_HOST,
18
- createClient
19
- } from "./client.mjs";
20
- import {
21
- CollectionEventKind,
22
- CollectionResyncReason
23
- } from "./collection-events.mjs";
24
- import {
25
- ConfigOptionCategory,
26
- configSelectFor,
27
- configSelectsOf
28
- } from "./config-options.mjs";
29
- import {
30
- TURN_OPEN_SESSION_STATES,
31
- isNewerMessageVersion,
32
- messageVersionOf
33
- } from "./conversations.mjs";
34
- import {
35
- AgentClientErrorName,
36
- ClientErrorCode,
37
- DecisionErrorReason,
38
- clientError,
39
- decisionError,
40
- isClientError,
41
- isDecisionError,
42
- isRealtimeSubscriptionError,
43
- isRequirementsUnmetError,
44
- isTerminalRealtimeError,
45
- isTurnRejectedError,
46
- realtimeSubscriptionError,
47
- requirementsUnmetError,
48
- turnRejectedError
49
- } from "./errors.mjs";
50
- import {
51
- EVENTS_POLL_INTERVAL_MS
52
- } from "./events.mjs";
53
- import { defaultStreamTiming } from "./frame-stream.mjs";
54
- import { SessionLiveEventKind } from "./live-stream.mjs";
55
- import {
56
- provideDocumentOf,
57
- resourceIdOf
58
- } from "./provide.mjs";
59
- import {
60
- createGatewayRealtimeTransport
61
- } from "./realtime.mjs";
62
- import {
63
- SANDBOX_FILE_URI_SCHEME,
64
- createSandboxFileUri,
65
- parseSandboxFileUri
66
- } from "./sandbox-uri.mjs";
1
+ export * from "./api.mjs";
2
+ import { createClient } from "./node.mjs";
67
3
  export {
68
- AcpAuthMode,
69
- AgentClientErrorName,
70
- Capability,
71
- ClientErrorCode,
72
- CollectionEventKind,
73
- CollectionResyncReason,
74
- ConfigOptionCategory,
75
- DEFAULT_AGENTS_HOST,
76
- DecisionErrorReason,
77
- EVENTS_POLL_INTERVAL_MS,
78
- FilesAccess,
79
- SANDBOX_FILE_URI_SCHEME,
80
- ScreenAccess,
81
- SessionLiveEventKind,
82
- ShellAccess,
83
- TURN_OPEN_SESSION_STATES,
84
- clientError,
85
- configSelectFor,
86
- configSelectsOf,
87
- createClient,
88
- createGatewayRealtimeTransport,
89
- createSandboxFileUri,
90
- createTextCollector,
91
- decisionError,
92
- defaultStreamTiming,
93
- isClientError,
94
- isDecisionError,
95
- isNewerMessageVersion,
96
- isRealtimeSubscriptionError,
97
- isRequirementsUnmetError,
98
- isTerminalRealtimeError,
99
- isTurnRejectedError,
100
- isUserMessageFor,
101
- messageVersionOf,
102
- parseSandboxFileUri,
103
- provideDocumentOf,
104
- realtimeSubscriptionError,
105
- requirementsUnmetError,
106
- resourceIdOf,
107
- sessionUpdateOf,
108
- textOf,
109
- turnEndOf,
110
- turnRejectedError
4
+ createClient
111
5
  };
112
6
  //# sourceMappingURL=index.mjs.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../src/agent-client/index.ts"],
4
- "sourcesContent": ["// `@finalai/agents/client`: the agent platform client SDK.\n// Wire types come from `@finalai/agent-protocol/agent-platform`, re-exported\n// here so consumers need one import.\n\nexport * from '@finalai/agent-protocol/agent-platform';\nexport {\n Capability,\n FilesAccess,\n ScreenAccess,\n ShellAccess,\n type CapabilityAccess,\n} from '@finalai/agent-protocol';\nexport { AcpAuthMode, type AcpApiIface, type AcpConnectArgsIface } from \"./acp.mjs\";\nexport {\n createTextCollector,\n isUserMessageFor,\n sessionUpdateOf,\n textOf,\n turnEndOf,\n type AcpSessionUpdateIface,\n type TurnEndIface,\n} from \"./acp-frames.mjs\";\nexport type { AgentInput, AgentValue, AgentValueCodecIface } from \"./agent-input.mjs\";\nexport type {\n ActorOptionIface,\n ChannelAppsApiIface,\n ChannelBindingsApiIface,\n ChannelSourceIface,\n ChannelSourceOf,\n ChannelTicketsApiIface,\n IdentityLinksApiIface,\n InstallChannelArgsIface,\n ProjectChannelsApiIface,\n PublishChannelArgsIface,\n UpdateChannelBindingArgsIface,\n} from \"./channels.mjs\";\nexport {\n DEFAULT_AGENTS_HOST,\n createClient,\n type AgentClientIface,\n type AgentsApiIface,\n type AppApiIface,\n type CreateClientOptionsIface,\n type DecisionsApiIface,\n type InferenceApiIface,\n type PeopleApiIface,\n type PlatformIdentityApiIface,\n type RealtimeApiIface,\n} from \"./client.mjs\";\nexport {\n CollectionEventKind,\n CollectionResyncReason,\n type CollectionEvent,\n type CollectionEventsOptionsIface,\n type CollectionResyncEventIface,\n} from \"./collection-events.mjs\";\nexport {\n ConfigOptionCategory,\n configSelectFor,\n configSelectsOf,\n type ConfigSelectChoiceIface,\n type ConfigSelectIface,\n type SessionConfigOptionIface,\n} from \"./config-options.mjs\";\nexport type { EnumInput, SignalOptionsIface } from \"./context.mjs\";\nexport type {\n AllowedEndpointsApiIface,\n BudgetsApiIface,\n ModelCredentialGrantsApiIface,\n ModelCredentialsApiIface,\n OrganizationApiIface,\n OrganizationPolicyApiIface,\n SpendingRestrictionsApiIface,\n} from \"./organization.mjs\";\nexport type { ParticipantConfigurationApiIface } from \"./participant-configuration.mjs\";\nexport type {\n ConversationChannelRoutesApiIface,\n ConversationContextApiIface,\n ConversationContextEntryInputIface,\n ConversationDecisionsApiIface,\n ConversationInputsApiIface,\n ConversationLabelsApiIface,\n ConversationReadGrantsApiIface,\n ConversationResourcesIface,\n ResourceSubscriptionsApiIface,\n SendInputArgsIface,\n} from \"./conversation-resources.mjs\";\nexport {\n TURN_OPEN_SESSION_STATES,\n isNewerMessageVersion,\n messageVersionOf,\n type MessageVersionIface,\n} from \"./conversations.mjs\";\nexport type {\n ConversationAgentTurnIface,\n ConversationEvent,\n ConversationEventMetaIface,\n ConversationEventsOptionsIface,\n ConversationHandleIface,\n ConversationsApiIface,\n CreateConversationArgsIface,\n ListMessagesOptionsIface,\n OpenedConversationIface,\n ParticipantCreateInput,\n ParticipantsApiIface,\n ProjectConversationsApiIface,\n SandboxFileContentArgsIface,\n SandboxFileContentRequestIface,\n SendMessageOptionsIface,\n SentMessageIface,\n UploadAttachmentArgsIface,\n} from \"./conversations.mjs\";\nexport {\n AgentClientErrorName,\n ClientErrorCode,\n DecisionErrorReason,\n clientError,\n decisionError,\n isClientError,\n isDecisionError,\n isRealtimeSubscriptionError,\n isRequirementsUnmetError,\n isTerminalRealtimeError,\n isTurnRejectedError,\n realtimeSubscriptionError,\n requirementsUnmetError,\n turnRejectedError,\n type AgentClientError,\n type ClientErrorIface,\n type DecisionErrorIface,\n type RealtimeSubscriptionErrorIface,\n type RequirementsUnmetErrorIface,\n type TurnRejectedErrorIface,\n} from \"./errors.mjs\";\nexport {\n EVENTS_POLL_INTERVAL_MS,\n type EventsApiIface,\n type EventSubscriptionsApiIface,\n type ListEventsOptionsIface,\n type StreamEventsOptionsIface,\n} from \"./events.mjs\";\nexport { defaultStreamTiming, type StreamTimingIface } from \"./frame-stream.mjs\";\nexport type { AgentClientAuth, FetchIface, HeadersOption } from \"./http.mjs\";\nexport type {\n AcpAdaptersApiIface,\n DefinitionSelectorIface,\n HarnessesApiIface,\n SubscriptionAllowancesApiIface,\n} from \"./harnesses.mjs\";\nexport type { IntegrationsApiIface } from \"./integrations.mjs\";\nexport { SessionLiveEventKind, type SessionLiveEvent } from \"./live-stream.mjs\";\nexport type { LocalComputeIface } from \"./local-host.mjs\";\nexport type { OAuthClientsApiIface, SignInReturnOriginsApiIface } from \"./oauth-clients.mjs\";\nexport type { ProjectClientIface } from \"./project.mjs\";\nexport type { AgentSelectorIface, ProjectAgentsApiIface } from \"./project-agents.mjs\";\nexport type {\n ProjectApiKeysApiIface,\n ProjectMembersApiIface,\n ProjectResourceApiIface,\n ProjectsApiIface,\n} from \"./projects.mjs\";\nexport type {\n ProjectPublisherApiIface,\n PublicNamesApiIface,\n PublisherHandleIface,\n PublishersApiIface,\n} from \"./publishers.mjs\";\nexport {\n provideDocumentOf,\n resourceIdOf,\n type ProvideIface,\n type ProvidePatchIface,\n type ResourceRef,\n type ResourceRefIface,\n} from \"./provide.mjs\";\nexport {\n createGatewayRealtimeTransport,\n type GatewayConnect,\n type GatewayConnectionIface,\n type GatewayRealtimeTransportOptionsIface,\n type RealtimeSubscribeOptionsIface,\n type RealtimeTransportFrameIface,\n type RealtimeTransportIface,\n} from \"./realtime.mjs\";\nexport {\n SANDBOX_FILE_URI_SCHEME,\n createSandboxFileUri,\n parseSandboxFileUri,\n type SandboxFileTargetIface,\n} from \"./sandbox-uri.mjs\";\nexport type { SandboxProvidersApiIface } from \"./sandbox-providers.mjs\";\nexport type {\n CreateSandboxOptionsIface,\n SandboxEnvironmentValueIface,\n SandboxHandleIface,\n SandboxOwnerIface,\n SandboxSetupRefIface,\n SandboxSetupsApiIface,\n SandboxesApiIface,\n} from \"./sandboxes.mjs\";\nexport type { ProjectSchedulesApiIface } from \"./schedules.mjs\";\nexport type {\n CreateSessionArgsIface,\n CreatedSessionIface,\n ForkSessionOptionsIface,\n ProjectSessionsApiIface,\n RespondArgs,\n SendOptionsIface,\n SessionHandleIface,\n SessionsApiIface,\n StreamOptionsIface,\n TurnHandleIface,\n TurnResultIface,\n} from \"./sessions.mjs\";\n"],
5
- "mappings": "AAIA,cAAc;AACd;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAEK;AACP,SAAS,mBAA+D;AACxE;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAGK;AAeP;AAAA,EACE;AAAA,EACA;AAAA,OAUK;AACP;AAAA,EACE;AAAA,EACA;AAAA,OAIK;AACP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OAIK;AAwBP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OAEK;AAoBP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAOK;AACP;AAAA,EACE;AAAA,OAKK;AACP,SAAS,2BAAmD;AAS5D,SAAS,4BAAmD;AAiB5D;AAAA,EACE;AAAA,EACA;AAAA,OAKK;AACP;AAAA,EACE;AAAA,OAOK;AACP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OAEK;",
4
+ "sourcesContent": ["// `@finalai/agents/client`: the agent platform client SDK, as Node resolves it.\n// Browsers, React Native and Workers resolve portable.ts: the same exports.\n\nexport * from \"./api.mjs\";\nexport { createClient } from \"./node.mjs\";\n"],
5
+ "mappings": "AAGA,cAAc;AACd,SAAS,oBAAoB;",
6
6
  "names": []
7
7
  }
@@ -0,0 +1,2 @@
1
+ import { type AgentClientIface, type CreateClientOptionsIface } from "./client.mjs";
2
+ export declare const createClient: (options: CreateClientOptionsIface) => AgentClientIface;
@@ -0,0 +1,62 @@
1
+ import { connectSandboxClient } from "@finalai/agent-provider/sandbox/client";
2
+ import { frameChannelFromWebSocket } from "@finalai/agent-provider/sandbox/wire";
3
+ import {
4
+ createClientFor
5
+ } from "./client.mjs";
6
+ import { LOCAL_HOST_SUBPROTOCOL } from "./local-host-protocol.mjs";
7
+ const nodeLocalCompute = () => ({
8
+ sandbox: async () => {
9
+ const { createLocalSandbox } = await import("@finalai/final-agent-provider/sandboxes/local");
10
+ return createLocalSandbox({ root: globalThis.process.cwd() });
11
+ },
12
+ openSandbox: (endpoint) => connectSandboxClient({
13
+ url: endpoint.url,
14
+ token: endpoint.token,
15
+ expiresAt: endpoint.expiresAt
16
+ })
17
+ });
18
+ const nodeLocalHostDial = (http) => async (path, signal) => {
19
+ const url = http.url(path);
20
+ url.protocol = url.protocol === "http:" ? "ws:" : "wss:";
21
+ const headers = await http.headers();
22
+ const { WebSocket } = await import("ws");
23
+ signal?.throwIfAborted();
24
+ const socket = new WebSocket(url, [LOCAL_HOST_SUBPROTOCOL], { headers });
25
+ let tcp = null;
26
+ let referenced = true;
27
+ socket.on("upgrade", (response) => {
28
+ tcp = response.socket;
29
+ if (!referenced) tcp.unref();
30
+ });
31
+ const { channel, opened } = frameChannelFromWebSocket(socket);
32
+ const onAbort = () => socket.terminate();
33
+ signal?.addEventListener("abort", onAbort, { once: true });
34
+ try {
35
+ await opened;
36
+ } finally {
37
+ signal?.removeEventListener("abort", onAbort);
38
+ }
39
+ return {
40
+ ...channel,
41
+ keepAlive: {
42
+ ref: () => {
43
+ referenced = true;
44
+ tcp?.ref();
45
+ },
46
+ unref: () => {
47
+ referenced = false;
48
+ tcp?.unref();
49
+ }
50
+ }
51
+ };
52
+ };
53
+ const nodeRuntime = {
54
+ localCompute: true,
55
+ compute: nodeLocalCompute,
56
+ dial: nodeLocalHostDial
57
+ };
58
+ const createClient = (options) => createClientFor(nodeRuntime, options);
59
+ export {
60
+ createClient
61
+ };
62
+ //# sourceMappingURL=node.mjs.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../src/agent-client/node.ts"],
4
+ "sourcesContent": ["import { connectSandboxClient } from '@finalai/agent-provider/sandbox/client';\nimport { frameChannelFromWebSocket } from '@finalai/agent-provider/sandbox/wire';\nimport {\n createClientFor,\n type AgentClientIface,\n type ClientRuntimeIface,\n type CreateClientOptionsIface,\n} from \"./client.mjs\";\nimport type { HttpIface } from \"./http.mjs\";\nimport { LOCAL_HOST_SUBPROTOCOL } from \"./local-host-protocol.mjs\";\nimport type { LocalComputeIface, LocalHostSocketIface } from \"./local-host.mjs\";\n\n// `createClient` in Node: the package's default export condition. Browsers and\n// React Native resolve `./portable` instead, which imports none of this.\n\n// The model's files and shell are this process's working directory, as for a\n// coding agent run on this machine. Loaded on use: it needs Node.\nconst nodeLocalCompute = (): LocalComputeIface => ({\n sandbox: async () => {\n const { createLocalSandbox } = await import('@finalai/final-agent-provider/sandboxes/local');\n return createLocalSandbox({ root: globalThis.process.cwd() });\n },\n openSandbox: (endpoint) =>\n connectSandboxClient({\n url: endpoint.url,\n token: endpoint.token,\n expiresAt: endpoint.expiresAt,\n }),\n});\n\n// The local host socket is dialed from Node with the client's own headers. It\n// keeps the process alive only while the host starts or is in use (see\n// LocalHostKeepAliveIface), so a script that is done exits and the platform\n// reports its tools and compute as unavailable.\nconst nodeLocalHostDial =\n (http: HttpIface) =>\n async (path: string, signal?: AbortSignal): Promise<LocalHostSocketIface> => {\n const url = http.url(path);\n url.protocol = url.protocol === 'http:' ? 'ws:' : 'wss:';\n const headers = await http.headers();\n const { WebSocket } = await import('ws');\n signal?.throwIfAborted();\n const socket = new WebSocket(url, [LOCAL_HOST_SUBPROTOCOL], { headers });\n let tcp: { ref: () => unknown; unref: () => unknown } | null = null;\n let referenced = true;\n socket.on('upgrade', (response) => {\n tcp = response.socket;\n if (!referenced) tcp.unref();\n });\n const { channel, opened } = frameChannelFromWebSocket(socket);\n // Aborting while the socket opens tears it down, which rejects `opened`.\n const onAbort = () => socket.terminate();\n signal?.addEventListener('abort', onAbort, { once: true });\n try {\n await opened;\n } finally {\n signal?.removeEventListener('abort', onAbort);\n }\n return {\n ...channel,\n keepAlive: {\n ref: () => {\n referenced = true;\n tcp?.ref();\n },\n unref: () => {\n referenced = false;\n tcp?.unref();\n },\n },\n };\n };\n\nconst nodeRuntime: ClientRuntimeIface = {\n localCompute: true,\n compute: nodeLocalCompute,\n dial: nodeLocalHostDial,\n};\n\nexport const createClient = (options: CreateClientOptionsIface): AgentClientIface =>\n createClientFor(nodeRu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ACA,OAAO,MAAM;AACX,qBAAa;AACb,aAAK,MAAM;AAAA,MACb;AAAA,IACF;AAAA,EACF;AACF;AAEF,MAAM,cAAkC;AAAA,EACtC,cAAc;AAAA,EACd,SAAS;AAAA,EACT,MAAM;AACR;AAEO,MAAM,eAAe,CAAC,YAC3B,gBAAgB,aAAa,OAAO;",
6
+ "names": []
7
+ }
@@ -0,0 +1,3 @@
1
+ import { type AgentClientIface, type CreateClientOptionsIface } from "./client.mjs";
2
+ export * from "./api.mjs";
3
+ export declare const createClient: (options: CreateClientOptionsIface) => AgentClientIface;
@@ -0,0 +1,28 @@
1
+ import { connectSandboxClient } from "@finalai/agent-provider/sandbox/client";
2
+ import {
3
+ createClientFor
4
+ } from "./client.mjs";
5
+ import { clientError, ClientErrorCode } from "./errors.mjs";
6
+ export * from "./api.mjs";
7
+ const unavailable = (what) => clientError({
8
+ message: `${what} is not available in this runtime: pass createClient({ localHosts }) to serve it`,
9
+ status: 0,
10
+ code: ClientErrorCode.InvalidRequest
11
+ });
12
+ const portableRuntime = {
13
+ localCompute: false,
14
+ compute: () => ({
15
+ sandbox: () => Promise.reject(unavailable("A local sandbox")),
16
+ openSandbox: (endpoint) => connectSandboxClient({
17
+ url: endpoint.url,
18
+ token: endpoint.token,
19
+ expiresAt: endpoint.expiresAt
20
+ })
21
+ }),
22
+ dial: () => () => Promise.reject(unavailable("The local host socket"))
23
+ };
24
+ const createClient = (options) => createClientFor(portableRuntime, options);
25
+ export {
26
+ createClient
27
+ };
28
+ //# sourceMappingURL=portable.mjs.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../src/agent-client/portable.ts"],
4
+ "sourcesContent": ["import { connectSandboxClient } from '@finalai/agent-provider/sandbox/client';\nimport {\n createClientFor,\n type AgentClientIface,\n type ClientRuntimeIface,\n type CreateClientOptionsIface,\n} from \"./client.mjs\";\nimport { clientError, ClientErrorCode } from \"./errors.mjs\";\n\n// `@finalai/agents/client` in browsers, React Native and Workers (the\n// `browser` and `react-native` export conditions): the same API as in Node,\n// with defaults that import nothing Node-only. This process serves no files\n// or shell unless the caller passes `localHosts.compute`, and dials no local\n// host socket unless it passes `localHosts.dial`, since a browser socket\n// cannot carry the client's auth headers.\n\nexport * from \"./api.mjs\";\n\nconst unavailable = (what: string) =>\n clientError({\n message: `${what} is not available in this runtime: pass createClient({ localHosts }) to serve it`,\n status: 0,\n code: ClientErrorCode.InvalidRequest,\n });\n\nconst portableRuntime: ClientRuntimeIface = {\n localCompute: false,\n compute: () => ({\n sandbox: () => Promise.reject(unavailable('A local sandbox')),\n openSandbox: (endpoint) =>\n connectSandboxClient({\n url: endpoint.url,\n token: endpoint.token,\n expiresAt: endpoint.expiresAt,\n }),\n }),\n dial: () => () => Promise.reject(unavailable('The local host socket')),\n};\n\nexport const createClient = (options: CreateClientOptionsIface): AgentClientIface =>\n createClientFor(portableRuntime, options);\n"],
5
+ "mappings": "AAAA,SAAS,4BAA4B;AACrC;AAAA,EACE;AAAA,OAIK;AACP,SAAS,aAAa,uBAAuB;AAS7C,cAAc;AAEd,MAAM,cAAc,CAAC,SACnB,YAAY;AAAA,EACV,SAAS,GAAG,IAAI;AAAA,EAChB,QAAQ;AAAA,EACR,MAAM,gBAAgB;AACxB,CAAC;AAEH,MAAM,kBAAsC;AAAA,EAC1C,cAAc;AAAA,EACd,SAAS,OAAO;AAAA,IACd,SAAS,MAAM,QAAQ,OAAO,YAAY,iBAAiB,CAAC;AAAA,IAC5D,aAAa,CAAC,aACZ,qBAAqB;AAAA,MACnB,KAAK,SAAS;AAAA,MACd,OAAO,SAAS;AAAA,MAChB,WAAW,SAAS;AAAA,IACtB,CAAC;AAAA,EACL;AAAA,EACA,MAAM,MAAM,MAAM,QAAQ,OAAO,YAAY,uBAAuB,CAAC;AACvE;AAEO,MAAM,eAAe,CAAC,YAC3B,gBAAgB,iBAAiB,OAAO;",
6
+ "names": []
7
+ }
@@ -1,5 +1,5 @@
1
1
  import type { SandboxEnvironmentValueIface } from '@finalai/agent-provider/sandbox/types';
2
- import { type PublishSandboxSetupResponseIface, type RunSandboxCommandRequestIface, type RunSandboxCommandResponseIface, type SandboxDescriptionIface, type SandboxListIface, type SandboxProviderIface, type SandboxResourceIface, type SandboxSetupInputIface, type SandboxSetupRefInputIface, type SandboxSetupResourceIface } from '@finalai/agent-protocol/agent-platform';
2
+ import { type PublishSandboxSetupResponseIface, type RunSandboxCommandRequestIface, type RunSandboxCommandResponseIface, type SandboxDescriptionIface, type SandboxExitConsentIface, type SandboxListIface, type SandboxProviderIface, type SandboxResourceIface, type SandboxSetupInputIface, type SandboxSetupRefInputIface, type SandboxSetupResourceIface } from '@finalai/agent-protocol/agent-platform';
3
3
  import { type ClientContextIface, type SignalOptionsIface } from "./context.mjs";
4
4
  export type { SandboxEnvironmentValueIface };
5
5
  /** A published sandbox setup at a version, or `latest` (resolved once, at creation). */
@@ -33,6 +33,13 @@ export interface SandboxHandleIface {
33
33
  setEgressExit: (args: {
34
34
  integration: string | null;
35
35
  } & SignalOptionsIface) => Promise<SandboxResourceIface>;
36
+ /**
37
+ * Proof for an integration's egress exit (`intg_...`) that you are the person the sandbox acts
38
+ * for now, to present with your consent to that exit. Refused for anyone else.
39
+ */
40
+ exitConsent: (args: {
41
+ integration: string;
42
+ } & SignalOptionsIface) => Promise<SandboxExitConsentIface>;
36
43
  delete: (options?: SignalOptionsIface) => Promise<void>;
37
44
  }
38
45
  export interface SandboxesApiIface {
@@ -12,6 +12,8 @@ import {
12
12
  sandboxResourceSchema,
13
13
  sandboxSetupListSchema,
14
14
  sandboxSetupResourceSchema,
15
+ sandboxExitConsentRequestSchema,
16
+ sandboxExitConsentSchema,
15
17
  setSandboxEgressExitRequestSchema
16
18
  } from "@finalai/agent-protocol/agent-platform";
17
19
  import { encodePath } from "./context.mjs";
@@ -49,6 +51,13 @@ const createSandboxesApi = (args) => {
49
51
  response: sandboxResourceSchema,
50
52
  signal
51
53
  }),
54
+ exitConsent: ({ signal, ...value }) => http.request({
55
+ method: HttpMethod.Post,
56
+ path: sandboxPath(resource.id, "/exit-consent"),
57
+ body: { schema: sandboxExitConsentRequestSchema, value },
58
+ response: sandboxExitConsentSchema,
59
+ signal
60
+ }),
52
61
  delete: async (options) => {
53
62
  await http.request({
54
63
  method: HttpMethod.Delete,
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../src/agent-client/sandboxes.ts"],
4
- "sourcesContent": ["import { jsonObjectSchema } from '@finalai/agent-protocol';\nimport type { SandboxEnvironmentValueIface } from '@finalai/agent-provider/sandbox/types';\nimport {\n createSandboxRequestSchema,\n okResponseSchema,\n publishSandboxSetupRequestSchema,\n publishSandboxSetupResponseSchema,\n runSandboxCommandRequestSchema,\n runSandboxCommandResponseSchema,\n sandboxDescriptionSchema,\n sandboxListSchema,\n sandboxProviderListSchema,\n sandboxResourceSchema,\n sandboxSetupListSchema,\n sandboxSetupResourceSchema,\n setSandboxEgressExitRequestSchema,\n type PublishSandboxSetupResponseIface,\n type RunSandboxCommandRequestIface,\n type RunSandboxCommandResponseIface,\n type SandboxDescriptionIface,\n type SandboxListIface,\n type SandboxProviderIface,\n type SandboxResourceIface,\n type SandboxSetupInputIface,\n type SandboxSetupRefInputIface,\n type SandboxSetupResourceIface,\n} from '@finalai/agent-protocol/agent-platform';\nimport { encodePath, type ClientContextIface, type SignalOptionsIface } from \"./context.mjs\";\nimport { HttpMethod } from \"./http.mjs\";\n\nexport type { SandboxEnvironmentValueIface };\n\n// Sandboxes are project resources: a machine and its disk from a provider,\n// provided to an agent per capability by id. Creating one boots nothing.\n\n/** A published sandbox setup at a version, or `latest` (resolved once, at creation). */\nexport type SandboxSetupRefIface = SandboxSetupRefInputIface;\n\n/** Who a sandbox belongs to; it is deleted with its owner. */\nexport type SandboxOwnerIface = { conversation: string } | { session: string };\n\nexport interface CreateSandboxOptionsIface extends SignalOptionsIface {\n /** What should be on the machine: `defineSandboxSetup(...)`, or a published setup. */\n setup?: SandboxSetupInputIface | SandboxSetupRefIface;\n ownedBy?: SandboxOwnerIface;\n /** A retry with the same key returns the sandbox the first call created. */\n idempotencyKey?: string;\n}\n\nexport interface SandboxHandleIface {\n readonly id: string;\n /** The sandbox as it was when this handle was made. */\n readonly resource: SandboxResourceIface;\n get: (options?: SignalOptionsIface) => Promise<SandboxResourceIface>;\n /** Runs one command to completion, booting the sandbox if needed. */\n run: (\n args: RunSandboxCommandRequestIface & SignalOptionsIface,\n ) => Promise<RunSandboxCommandResponseIface>;\n /** What is known about the machine: checkouts, services, commands, notes. */\n description: (options?: SignalOptionsIface) => Promise<SandboxDescriptionIface>;\n /**\n * Sends the sandbox's outbound traffic through an integration's egress exit (`intg_...`),\n * or straight out with `null`.\n */\n setEgressExit: (\n args: { integration: string | null } & SignalOptionsIface,\n ) => Promise<SandboxResourceIface>;\n delete: (options?: SignalOptionsIface) => Promise<void>;\n}\n\nexport interface SandboxesApiIface {\n create: (\n environment: SandboxEnvironmentValueIface,\n options?: CreateSandboxOptionsIface,\n ) => Promise<SandboxHandleIface>;\n get: (sandboxId: string, options?: SignalOptionsIface) => Promise<SandboxHandleIface>;\n list: (\n options?: SignalOptionsIface & {\n conversation?: string;\n session?: string;\n cursor?: string;\n limit?: number;\n },\n ) => Promise<SandboxListIface>;\n /** The providers this project can create sandboxes on. */\n providers: (options?: SignalOptionsIface) => Promise<SandboxProviderIface[]>;\n}\n\nexport interface SandboxSetupsApiIface {\n /** Publishes the next version of `name`. */\n publish: (\n args: { name: string; setup: SandboxSetupInputIface } & SignalOptionsIface,\n ) => Promise<PublishSandboxSetupResponseIface>;\n get: (\n args: { id: string; version?: number } & SignalOptionsIface,\n ) => Promise<SandboxSetupResourceIface>;\n list: (\n options?: SignalOptionsIface & { cursor?: string; limit?: number },\n ) => Promise<SandboxSetupResourceIface[]>;\n}\n\nconst projectPath = (projectId: string, suffix: string): string =>\n `/v1/projects/${encodePath(projectId)}${suffix}`;\n\nexport const createSandboxesApi = (args: {\n context: ClientContextIface;\n projectId: string;\n}): SandboxesApiIface => {\n const { http } = args.context;\n const sandboxPath = (sandboxId: string, suffix = '') =>\n projectPath(args.projectId, `/sandboxes/${encodePath(sandboxId)}${suffix}`);\n const handle = (resource: SandboxResourceIface): SandboxHandleIface => ({\n id: resource.id,\n resource,\n get: (options) =>\n http.request({\n method: HttpMethod.Get,\n path: sandboxPath(resource.id),\n response: sandboxResourceSchema,\n signal: options?.signal,\n }),\n run: ({ signal, ...value }) =>\n http.request({\n method: HttpMethod.Post,\n path: sandboxPath(resource.id, '/run'),\n body: { schema: runSandboxCommandRequestSchema, value },\n response: runSandboxCommandResponseSchema,\n signal,\n }),\n description: (options) =>\n http.request({\n method: HttpMethod.Get,\n path: sandboxPath(resource.id, '/description'),\n response: sandboxDescriptionSchema,\n signal: options?.signal,\n }),\n setEgressExit: ({ signal, ...value }) =>\n http.request({\n method: HttpMethod.Put,\n path: sandboxPath(resource.id, '/egress-exit'),\n body: { schema: setSandboxEgressExitRequestSchema, value },\n response: sandboxResourceSchema,\n signal,\n }),\n delete: async (options) => {\n await http.request({\n method: HttpMethod.Delete,\n path: sandboxPath(resource.id),\n response: okResponseSchema,\n signal: options?.signal,\n });\n },\n });\n return {\n create: async (environment, options) =>\n handle(\n await http.request({\n method: HttpMethod.Post,\n path: projectPath(args.projectId, '/sandboxes'),\n body: {\n schema: createSandboxRequestSchema,\n value: {\n provider: environment.provider,\n environment: jsonObjectSchema.parse(environment.environment ?? {}),\n setup: options?.setup,\n ownedBy: options?.ownedBy,\n idempotencyKey: options?.idempotencyKey,\n },\n },\n response: sandboxResourceSchema,\n signal: options?.signal,\n }),\n ),\n get: async (sandboxId, options) =>\n handle(\n await http.request({\n method: HttpMethod.Get,\n path: sandboxPath(sandboxId),\n response: sandboxResourceSchema,\n signal: options?.signal,\n }),\n ),\n list: (options) =>\n http.request({\n method: HttpMethod.Get,\n path: projectPath(args.projectId, '/sandboxes'),\n query: {\n conversation: options?.conversation,\n session: options?.session,\n cursor: options?.cursor,\n limit: options?.limit,\n },\n response: sandboxListSchema,\n signal: options?.signal,\n }),\n providers: async (options) =>\n (\n await http.request({\n method: HttpMethod.Get,\n path: projectPath(args.projectId, '/sandbox-providers'),\n response: sandboxProviderListSchema,\n signal: options?.signal,\n })\n ).providers,\n };\n};\n\nexport const createSandboxSetupsApi = (args: {\n context: ClientContextIface;\n projectId: string;\n}): SandboxSetupsApiIface => {\n const { http } = args.context;\n return {\n publish: ({ signal, ...value }) =>\n http.request({\n method: HttpMethod.Post,\n path: projectPath(args.projectId, '/sandbox-setups'),\n body: { schema: publishSandboxSetupRequestSchema, value },\n response: publishSandboxSetupResponseSchema,\n signal,\n }),\n get: ({ id, version, signal }) =>\n http.request({\n method: HttpMethod.Get,\n path: projectPath(args.projectId, `/sandbox-setups/${encodePath(id)}`),\n query: { version },\n response: sandboxSetupResourceSchema,\n signal,\n }),\n list: async (options) =>\n (\n await http.request({\n method: HttpMethod.Get,\n path: projectPath(args.projectId, '/sandbox-setups'),\n query: { cursor: options?.cursor, limit: options?.limit },\n response: sandboxSetupListSchema,\n signal: options?.signal,\n })\n ).setups,\n };\n};\n"],
5
- "mappings": "AAAA,SAAS,wBAAwB;AAEjC;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAWK;AACP,SAAS,kBAAoE;AAC7E,SAAS,kBAAkB;AAyE3B,MAAM,cAAc,CAAC,WAAmB,WACtC,gBAAgB,WAAW,SAAS,CAAC,GAAG,MAAM;AAEzC,MAAM,qBAAqB,CAAC,SAGV;AACvB,QAAM,EAAE,KAAK,IAAI,KAAK;AACtB,QAAM,cAAc,CAAC,WAAmB,SAAS,OAC/C,YAAY,KAAK,WAAW,cAAc,WAAW,SAAS,CAAC,GAAG,MAAM,EAAE;AAC5E,QAAM,SAAS,CAAC,cAAwD;AAAA,IACtE,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AK,CAAC,EAAE,IAAI,SAAS,OAAO,MAC1B,KAAK,QAAQ;AAAA,MACX,QAAQ,WAAW;AAAA,MACnB,MAAM,YAAY,KAAK,WAAW,mBAAmB,WAAW,EAAE,CAAC,EAAE;AAAA,MACrE,OAAO,EAAE,QAAQ;AAAA,MACjB,UAAU;AAAA,MACV;AAAA,IACF,CAAC;AAAA,IACH,MAAM,OAAO,aAET,MAAM,KAAK,QAAQ;AAAA,MACjB,QAAQ,WAAW;AAAA,MACnB,MAAM,YAAY,KAAK,WAAW,iBAAiB;AAAA,MACnD,OAAO,EAAE,QAAQ,SAAS,QAAQ,OAAO,SAAS,MAAM;AAAA,MACxD,UAAU;AAAA,MACV,QAAQ,SAAS;AAAA,IACnB,CAAC,GACD;AAAA,EACN;AACF;",
4
+ "sourcesContent": ["import { jsonObjectSchema } from '@finalai/agent-protocol';\nimport type { SandboxEnvironmentValueIface } from '@finalai/agent-provider/sandbox/types';\nimport {\n createSandboxRequestSchema,\n okResponseSchema,\n publishSandboxSetupRequestSchema,\n publishSandboxSetupResponseSchema,\n runSandboxCommandRequestSchema,\n runSandboxCommandResponseSchema,\n sandboxDescriptionSchema,\n sandboxListSchema,\n sandboxProviderListSchema,\n sandboxResourceSchema,\n sandboxSetupListSchema,\n sandboxSetupResourceSchema,\n sandboxExitConsentRequestSchema,\n sandboxExitConsentSchema,\n setSandboxEgressExitRequestSchema,\n type PublishSandboxSetupResponseIface,\n type RunSandboxCommandRequestIface,\n type RunSandboxCommandResponseIface,\n type SandboxDescriptionIface,\n type SandboxExitConsentIface,\n type SandboxListIface,\n type SandboxProviderIface,\n type SandboxResourceIface,\n type SandboxSetupInputIface,\n type SandboxSetupRefInputIface,\n type SandboxSetupResourceIface,\n} from '@finalai/agent-protocol/agent-platform';\nimport { encodePath, type ClientContextIface, type SignalOptionsIface } from \"./context.mjs\";\nimport { HttpMethod } from \"./http.mjs\";\n\nexport type { SandboxEnvironmentValueIface };\n\n// Sandboxes are project resources: a machine and its disk from a provider,\n// provided to an agent per capability by id. Creating one boots nothing.\n\n/** A published sandbox setup at a version, or `latest` (resolved once, at creation). */\nexport type SandboxSetupRefIface = SandboxSetupRefInputIface;\n\n/** Who a sandbox belongs to; it is deleted with its owner. */\nexport type SandboxOwnerIface = { conversation: string } | { session: string };\n\nexport interface CreateSandboxOptionsIface extends SignalOptionsIface {\n /** What should be on the machine: `defineSandboxSetup(...)`, or a published setup. */\n setup?: SandboxSetupInputIface | SandboxSetupRefIface;\n ownedBy?: SandboxOwnerIface;\n /** A retry with the same key returns the sandbox the first call created. */\n idempotencyKey?: string;\n}\n\nexport interface SandboxHandleIface {\n readonly id: string;\n /** The sandbox as it was when this handle was made. */\n readonly resource: SandboxResourceIface;\n get: (options?: SignalOptionsIface) => Promise<SandboxResourceIface>;\n /** Runs one command to completion, booting the sandbox if needed. */\n run: (\n args: RunSandboxCommandRequestIface & SignalOptionsIface,\n ) => Promise<RunSandboxCommandResponseIface>;\n /** What is known about the machine: checkouts, services, commands, notes. */\n description: (options?: SignalOptionsIface) => Promise<SandboxDescriptionIface>;\n /**\n * Sends the sandbox's outbound traffic through an integration's egress exit (`intg_...`),\n * or straight out with `null`.\n */\n setEgressExit: (\n args: { integration: string | null } & SignalOptionsIface,\n ) => Promise<SandboxResourceIface>;\n /**\n * Proof for an integration's egress exit (`intg_...`) that you are the person the sandbox acts\n * for now, to present with your consent to that exit. Refused for anyone else.\n */\n exitConsent: (\n args: { integration: string } & SignalOptionsIface,\n ) => Promise<SandboxExitConsentIface>;\n delete: (options?: SignalOptionsIface) => Promise<void>;\n}\n\nexport interface SandboxesApiIface {\n create: (\n environment: SandboxEnvironmentValueIface,\n options?: CreateSandboxOptionsIface,\n ) => Promise<SandboxHandleIface>;\n get: (sandboxId: string, options?: SignalOptionsIface) => Promise<SandboxHandleIface>;\n list: (\n options?: SignalOptionsIface & {\n conversation?: string;\n session?: string;\n cursor?: string;\n limit?: number;\n },\n ) => Promise<SandboxListIface>;\n /** The providers this project can create sandboxes on. */\n providers: (options?: SignalOptionsIface) => Promise<SandboxProviderIface[]>;\n}\n\nexport interface SandboxSetupsApiIface {\n /** Publishes the next version of `name`. */\n publish: (\n args: { name: string; setup: SandboxSetupInputIface } & SignalOptionsIface,\n ) => Promise<PublishSandboxSetupResponseIface>;\n get: (\n args: { id: string; version?: number } & SignalOptionsIface,\n ) => Promise<SandboxSetupResourceIface>;\n list: (\n options?: SignalOptionsIface & { cursor?: string; limit?: number },\n ) => Promise<SandboxSetupResourceIface[]>;\n}\n\nconst projectPath = (projectId: string, suffix: string): string =>\n `/v1/projects/${encodePath(projectId)}${suffix}`;\n\nexport const createSandboxesApi = (args: {\n context: ClientContextIface;\n projectId: string;\n}): SandboxesApiIface => {\n const { http } = args.context;\n const sandboxPath = (sandboxId: string, suffix = '') =>\n projectPath(args.projectId, `/sandboxes/${encodePath(sandboxId)}${suffix}`);\n const handle = (resource: SandboxResourceIface): SandboxHandleIface => ({\n id: resource.id,\n resource,\n get: (options) =>\n http.request({\n method: HttpMethod.Get,\n path: sandboxPath(resource.id),\n response: sandboxResourceSchema,\n signal: options?.signal,\n }),\n run: ({ signal, ...value }) =>\n http.request({\n method: HttpMethod.Post,\n path: sandboxPath(resource.id, '/run'),\n body: { schema: runSandboxCommandRequestSchema, value },\n response: runSandboxCommandResponseSchema,\n signal,\n }),\n description: (options) =>\n http.request({\n method: HttpMethod.Get,\n path: sandboxPath(resource.id, '/description'),\n response: sandboxDescriptionSchema,\n signal: options?.signal,\n }),\n setEgressExit: ({ signal, ...value }) =>\n http.request({\n method: HttpMethod.Put,\n path: sandboxPath(resource.id, '/egress-exit'),\n body: { schema: setSandboxEgressExitRequestSchema, value },\n response: sandboxResourceSchema,\n signal,\n }),\n exitConsent: ({ signal, ...value }) =>\n http.request({\n method: HttpMethod.Post,\n path: sandboxPath(resource.id, '/exit-consent'),\n body: { schema: sandboxExitConsentRequestSchema, value },\n response: sandboxExitConsentSchema,\n signal,\n }),\n delete: async (options) => {\n await http.request({\n method: HttpMethod.Delete,\n path: sandboxPath(resource.id),\n response: okResponseSchema,\n signal: options?.signal,\n });\n },\n });\n return {\n create: async (environment, options) =>\n handle(\n await http.request({\n method: HttpMethod.Post,\n path: projectPath(args.projectId, '/sandboxes'),\n body: {\n schema: createSandboxRequestSchema,\n value: {\n provider: environment.provider,\n environment: jsonObjectSchema.parse(environment.environment ?? {}),\n setup: options?.setup,\n ownedBy: options?.ownedBy,\n idempotencyKey: options?.idempotencyKey,\n },\n },\n response: sandboxResourceSchema,\n signal: options?.signal,\n }),\n ),\n get: async (sandboxId, options) =>\n handle(\n await http.request({\n method: HttpMethod.Get,\n path: sandboxPath(sandboxId),\n response: sandboxResourceSchema,\n signal: options?.signal,\n }),\n ),\n list: (options) =>\n http.request({\n method: HttpMethod.Get,\n path: projectPath(args.projectId, '/sandboxes'),\n query: {\n conversation: options?.conversation,\n session: options?.session,\n cursor: options?.cursor,\n limit: options?.limit,\n },\n response: sandboxListSchema,\n signal: options?.signal,\n }),\n providers: async (options) =>\n (\n await http.request({\n method: HttpMethod.Get,\n path: projectPath(args.projectId, '/sandbox-providers'),\n response: sandboxProviderListSchema,\n signal: options?.signal,\n })\n ).providers,\n };\n};\n\nexport const createSandboxSetupsApi = (args: {\n context: ClientContextIface;\n projectId: string;\n}): SandboxSetupsApiIface => {\n const { http } = args.context;\n return {\n publish: ({ signal, ...value }) =>\n http.request({\n method: HttpMethod.Post,\n path: projectPath(args.projectId, '/sandbox-setups'),\n body: { schema: publishSandboxSetupRequestSchema, value },\n response: publishSandboxSetupResponseSchema,\n signal,\n }),\n get: ({ id, version, signal }) =>\n http.request({\n method: HttpMethod.Get,\n path: projectPath(args.projectId, `/sandbox-setups/${encodePath(id)}`),\n query: { version },\n response: sandboxSetupResourceSchema,\n signal,\n }),\n list: async (options) =>\n (\n await http.request({\n method: HttpMethod.Get,\n path: projectPath(args.projectId, '/sandbox-setups'),\n query: { cursor: options?.cursor, limit: options?.limit },\n response: sandboxSetupListSchema,\n signal: options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AAAA,MACV,QAAQ,SAAS;AAAA,IACnB,CAAC,GACD;AAAA,EACN;AACF;",
6
6
  "names": []
7
7
  }
@@ -1,7 +1,8 @@
1
1
  import { parseArgs } from "node:util";
2
2
  import { documentOf } from "@finalai/agent-definition";
3
3
  import * as z from "zod";
4
- import { createClient, DEFAULT_AGENTS_HOST } from "../agent-client/client.mjs";
4
+ import { DEFAULT_AGENTS_HOST } from "../agent-client/client.mjs";
5
+ import { createClient } from "../agent-client/node.mjs";
5
6
  import { DefinitionKind, loadDefinitionModule } from "./agent-module.mjs";
6
7
  import { runConformance } from "./conformance.mjs";
7
8
  import { errorLines } from "./output.mjs";
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../src/cli/cli.ts"],
4
- "sourcesContent": ["import { parseArgs } from 'node:util';\nimport { documentOf, type AgentIface } from '@finalai/agent-definition';\nimport type { AgentDocumentIface } from '@finalai/agent-provider/document';\nimport * as z from 'zod';\nimport { createClient, DEFAULT_AGENTS_HOST, type AgentClientIface } from \"../agent-client/client.mjs\";\nimport type { FetchIface } from \"../agent-client/http.mjs\";\nimport { DefinitionKind, loadDefinitionModule, type ImportModule } from \"./agent-module.mjs\";\nimport { runConformance } from \"./conformance.mjs\";\nimport { errorLines, type OutputIface } from \"./output.mjs\";\n\n// `final-agents`: `print` writes the document of an agent, a harness or an\n// ACP adapter, `publish` gives it a name in a project, `conformance` checks a\n// harness implementation. Nothing is built or deployed: each is data.\n\nconst USAGE = [\n 'usage: final-agents <command> [options]',\n '',\n 'commands:',\n ' print <module> write the document of the agent, harness or ACP adapter',\n ' the module exports, as JSON',\n ' publish <module> --name <name> store it and point <name> at it in a project',\n ' conformance <module> run the harness conformance kit against a harness the module exports',\n '',\n 'options:',\n ' --export <name> the export to use (print and publish: an agent, a harness or an ACP adapter,',\n ' found by itself when omitted;',\n ' conformance: a HarnessIface or { harness, dial }, default \"default\")',\n ' --name <name> publish: the name to point at it',\n ' --project <id> publish: the project (overrides FINAL_PROJECT_ID)',\n ' --host <url> agents API (overrides FINAL_API_HOST; default ' +\n DEFAULT_AGENTS_HOST +\n ')',\n ' --profile <name> conformance: final (default), final-required (ACP adapters) or plain-acp-v2',\n ' --timeout <ms> conformance: per-case timeout',\n ' --json conformance: print the report as JSON',\n '',\n 'publish authenticates with FINAL_API_KEY. print calls nothing.',\n].join('\\n');\n\nconst envSchema = z.object({\n FINAL_API_KEY: z.string().min(1).optional(),\n FINAL_API_HOST: z.string().url().optional(),\n FINAL_PROJECT_ID: z.string().min(1).optional(),\n});\n\nexport interface AgentsCliDepsIface {\n argv: string[];\n env: Record<string, string | undefined>;\n cwd: string;\n output: OutputIface;\n // Seams: API requests, module loading and document making.\n fetch?: FetchIface;\n importModule?: ImportModule;\n documentOf?: (agent: AgentIface) => AgentDocumentIface;\n // Ends long-running commands; main.ts aborts it on SIGINT and SIGTERM.\n signal?: AbortSignal;\n}\n\nconst optionsConfig = {\n export: { type: 'string' },\n name: { type: 'string' },\n project: { type: 'string' },\n host: { type: 'string' },\n profile: { type: 'string' },\n timeout: { type: 'string' },\n json: { type: 'boolean' },\n help: { type: 'boolean', short: 'h' },\n} as const;\n\nconst parseCommandLine = (argv: string[]) =>\n parseArgs({ args: argv, options: optionsConfig, allowPositionals: true });\n\ntype ParsedResult =\n | { ok: true; parsed: ReturnType<typeof parseCommandLine> }\n | { ok: false; message: string };\n\nconst parse = (argv: string[]): ParsedResult => {\n try {\n return { ok: true, parsed: parseCommandLine(argv) };\n } catch (cause) {\n return { ok: false, message: cause instanceof Error ? cause.message : String(cause) };\n }\n};\n\nexport const runAgentsCommand = async (deps: AgentsCliDepsIface): Promise<number> => {\n const { output } = deps;\n const parsedArgs = parse(deps.argv);\n if (!parsedArgs.ok) {\n output.stderr(`error: ${parsedArgs.message}`);\n output.stderr(USAGE);\n return 2;\n }\n const { values, positionals } = parsedArgs.parsed;\n const [command, moduleArg, ...extra] = positionals;\n if (values.help === true || command == null || command === 'help') {\n (command == null && values.help !== true ? output.stderr : output.stdout)(USAGE);\n return command == null && values.help !== true ? 2 : 0;\n }\n if (extra.length > 0) {\n output.stderr(`error: unexpected arguments: ${extra.join(' ')}`);\n return 2;\n }\n if (command !== 'print' && command !== 'publish' && command !== 'conformance') {\n output.stderr(`error: unknown command ${command}`);\n output.stderr(USAGE);\n return 2;\n }\n if (moduleArg == null) {\n output.stderr(`error: ${command} needs <module>`);\n return 2;\n }\n\n if (command === 'conformance') {\n const timeoutMs = values.timeout == null ? null : Number(values.timeout);\n if (timeoutMs != null && (!Number.isInteger(timeoutMs) || timeoutMs <= 0)) {\n output.stderr('error: --timeout must be a positive number of milliseconds');\n return 2;\n }\n return runConformance({\n module: moduleArg,\n exportName: values.export ?? 'default',\n profile: values.profile ?? 'final',\n timeoutMs,\n json: values.json === true,\n cwd: deps.cwd,\n output,\n importModule: deps.importModule,\n signal: deps.signal,\n });\n }\n\n const env = envSchema.safeParse(deps.env);\n if (!env.success) {\n output.stderr(\n 'error: FINAL_API_KEY must be nonempty and FINAL_API_HOST must be an absolute URL',\n );\n return 2;\n }\n const loaded = await loadDefinitionModule({\n module: moduleArg,\n exportName: values.export ?? null,\n cwd: deps.cwd,\n importModule: deps.importModule,\n documentOf: deps.documentOf ?? documentOf,\n });\n if (!loaded.ok) {\n output.stderr(`error: ${loaded.message}`);\n return 1;\n }\n\n if (command === 'print') {\n output.stdout(JSON.stringify(loaded.document, null, 2));\n return 0;\n }\n\n if (values.name == null) {\n output.stderr('error: publish needs --name <name>');\n return 2;\n }\n const projectId = values.project ?? env.data.FINAL_PROJECT_ID;\n if (projectId == null) {\n output.stderr('error: publish needs --project <id> or FINAL_PROJECT_ID');\n return 2;\n }\n const apiKey = env.data.FINAL_API_KEY;\n if (apiKey == null) {\n output.stderr('error: set FINAL_API_KEY to a Final API key');\n return 2;\n }\n const agentDocument = loaded.kind === DefinitionKind.Agent ? loaded.document : null;\n const client: AgentClientIface = createClient({\n host: values.host ?? env.data.FINAL_API_HOST ?? DEFAULT_AGENTS_HOST,\n auth: { apiKey },\n fetch: deps.fetch,\n localCompute: false,\n // The document is already made; publishing sends exactly it.\n agentCodec: {\n documentOf: () => {\n if (agentDocument == null) throw new Error('Only an agent has an agent document');\n return agentDocument;\n },\n inProcessCodeOf: () => ({ tools: {}, hooks: {}, approvals: {} }),\n },\n });\n try {\n const project = client.project({ id: projectId });\n const name = values.name;\n const signal = deps.signal;\n const published =\n loaded.kind === DefinitionKind.Agent\n ? await project.agents.publish({ agent: loaded.agent, name, signal })\n : loaded.kind === DefinitionKind.Harness\n ? await project.harnesses.publish({ harness: loaded.document, name, signal })\n : await project.acpAdapters.publish({ adapter: loaded.document, name, signal });\n output.stdout(`published ${published.name}: ${published.hash}`);\n if ('id' in published && published.id != null) output.stdout(`id: ${published.id}`);\n return 0;\n } catch (cause) {\n for (const line of errorLines(cause)) output.stderr(line);\n return 1;\n } finally {\n client.close();\n }\n};\n"],
5
- "mappings": "AAAA,SAAS,iBAAiB;AAC1B,SAAS,kBAAmC;AAE5C,YAAY,OAAO;AACnB,SAAS,cAAc,2BAAkD;AAEzE,SAAS,gBAAgB,4BAA+C;AACxE,SAAS,sBAAsB;AAC/B,SAAS,kBAAoC;AAM7C,MAAM,QAAQ;AAAA,EACZ;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,yEACE,sBACA;AAAA,EACF;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,EAAE,KAAK,IAAI;AAEX,MAAM,YAAY,EAAE,OAAO;AAAA,EACzB,eAAe,EAAE,OAAO,EAAE,IAAI,CAAC,EAAE,SAAS;AAAA,EAC1C,gBAAgB,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS;AAAA,EAC1C,kBAAkB,EAAE,OAAO,EAAE,IAAI,CAAC,EAAE,SAAS;AAC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O,OAAO,OAAO,UAAU,EAAE,EAAE;AAClF,WAAO;AAAA,EACT,SAAS,OAAO;AACd,eAAW,QAAQ,WAAW,KAAK,EAAG,QAAO,OAAO,IAAI;AACxD,WAAO;AAAA,EACT,UAAE;AACA,WAAO,MAAM;AAAA,EACf;AACF;",
4
+ "sourcesContent": ["import { parseArgs } from 'node:util';\nimport { documentOf, type AgentIface } from '@finalai/agent-definition';\nimport type { AgentDocumentIface } from '@finalai/agent-provider/document';\nimport * as z from 'zod';\nimport { DEFAULT_AGENTS_HOST, type AgentClientIface } from \"../agent-client/client.mjs\";\nimport { createClient } from \"../agent-client/node.mjs\";\nimport type { FetchIface } from \"../agent-client/http.mjs\";\nimport { DefinitionKind, loadDefinitionModule, type ImportModule } from \"./agent-module.mjs\";\nimport { runConformance } from \"./conformance.mjs\";\nimport { errorLines, type OutputIface } from \"./output.mjs\";\n\n// `final-agents`: `print` writes the document of an agent, a harness or an\n// ACP adapter, `publish` gives it a name in a project, `conformance` checks a\n// harness implementation. Nothing is built or deployed: each is data.\n\nconst USAGE = [\n 'usage: final-agents <command> [options]',\n '',\n 'commands:',\n ' print <module> write the document of the agent, harness or ACP adapter',\n ' the module exports, as JSON',\n ' publish <module> --name <name> store it and point <name> at it in a project',\n ' conformance <module> run the harness conformance kit against a harness the module exports',\n '',\n 'options:',\n ' --export <name> the export to use (print and publish: an agent, a harness or an ACP adapter,',\n ' found by itself when omitted;',\n ' conformance: a HarnessIface or { harness, dial }, default \"default\")',\n ' --name <name> publish: the name to point at it',\n ' --project <id> publish: the project (overrides FINAL_PROJECT_ID)',\n ' --host <url> agents API (overrides FINAL_API_HOST; default ' +\n DEFAULT_AGENTS_HOST +\n ')',\n ' --profile <name> conformance: final (default), final-required (ACP adapters) or plain-acp-v2',\n ' --timeout <ms> conformance: per-case timeout',\n ' --json conformance: print the report as JSON',\n '',\n 'publish authenticates with FINAL_API_KEY. print calls nothing.',\n].join('\\n');\n\nconst envSchema = z.object({\n FINAL_API_KEY: z.string().min(1).optional(),\n FINAL_API_HOST: z.string().url().optional(),\n FINAL_PROJECT_ID: z.string().min(1).optional(),\n});\n\nexport interface AgentsCliDepsIface {\n argv: string[];\n env: Record<string, string | undefined>;\n cwd: string;\n output: OutputIface;\n // Seams: API requests, module loading and document making.\n fetch?: FetchIface;\n importModule?: ImportModule;\n documentOf?: (agent: AgentIface) => AgentDocumentIface;\n // Ends long-running commands; main.ts aborts it on SIGINT and SIGTERM.\n signal?: AbortSignal;\n}\n\nconst optionsConfig = {\n export: { type: 'string' },\n name: { type: 'string' },\n project: { type: 'string' },\n host: { type: 'string' },\n profile: { type: 'string' },\n timeout: { type: 'string' },\n json: { type: 'boolean' },\n help: { type: 'boolean', short: 'h' },\n} as const;\n\nconst parseCommandLine = (argv: string[]) =>\n parseArgs({ args: argv, options: optionsConfig, allowPositionals: true });\n\ntype ParsedResult =\n | { ok: true; parsed: ReturnType<typeof parseCommandLine> }\n | { ok: false; message: string };\n\nconst parse = (argv: string[]): ParsedResult => {\n try {\n return { ok: true, parsed: parseCommandLine(argv) };\n } catch (cause) {\n return { ok: false, message: cause instanceof Error ? cause.message : String(cause) };\n }\n};\n\nexport const runAgentsCommand = async (deps: AgentsCliDepsIface): Promise<number> => {\n const { output } = deps;\n const parsedArgs = parse(deps.argv);\n if (!parsedArgs.ok) {\n output.stderr(`error: ${parsedArgs.message}`);\n output.stderr(USAGE);\n return 2;\n }\n const { values, positionals } = parsedArgs.parsed;\n const [command, moduleArg, ...extra] = positionals;\n if (values.help === true || command == null || command === 'help') {\n (command == null && values.help !== true ? output.stderr : output.stdout)(USAGE);\n return command == null && values.help !== true ? 2 : 0;\n }\n if (extra.length > 0) {\n output.stderr(`error: unexpected arguments: ${extra.join(' ')}`);\n return 2;\n }\n if (command !== 'print' && command !== 'publish' && command !== 'conformance') {\n output.stderr(`error: unknown command ${command}`);\n output.stderr(USAGE);\n return 2;\n }\n if (moduleArg == null) {\n output.stderr(`error: ${command} needs <module>`);\n return 2;\n }\n\n if (command === 'conformance') {\n const timeoutMs = values.timeout == null ? null : Number(values.timeout);\n if (timeoutMs != null && (!Number.isInteger(timeoutMs) || timeoutMs <= 0)) {\n output.stderr('error: --timeout must be a positive number of milliseconds');\n return 2;\n }\n return runConformance({\n module: moduleArg,\n exportName: values.export ?? 'default',\n profile: values.profile ?? 'final',\n timeoutMs,\n json: values.json === true,\n cwd: deps.cwd,\n output,\n importModule: deps.importModule,\n signal: deps.signal,\n });\n }\n\n const env = envSchema.safeParse(deps.env);\n if (!env.success) {\n output.stderr(\n 'error: FINAL_API_KEY must be nonempty and FINAL_API_HOST must be an absolute URL',\n );\n return 2;\n }\n const loaded = await loadDefinitionModule({\n module: moduleArg,\n exportName: values.export ?? null,\n cwd: deps.cwd,\n importModule: deps.importModule,\n documentOf: deps.documentOf ?? documentOf,\n });\n if (!loaded.ok) {\n output.stderr(`error: ${loaded.message}`);\n return 1;\n }\n\n if (command === 'print') {\n output.stdout(JSON.stringify(loaded.document, null, 2));\n return 0;\n }\n\n if (values.name == null) {\n output.stderr('error: publish needs --name <name>');\n return 2;\n }\n const projectId = values.project ?? env.data.FINAL_PROJECT_ID;\n if (projectId == null) {\n output.stderr('error: publish needs --project <id> or FINAL_PROJECT_ID');\n return 2;\n }\n const apiKey = env.data.FINAL_API_KEY;\n if (apiKey == null) {\n output.stderr('error: set FINAL_API_KEY to a Final API key');\n return 2;\n }\n const agentDocument = loaded.kind === DefinitionKind.Agent ? loaded.document : null;\n const client: AgentClientIface = createClient({\n host: values.host ?? env.data.FINAL_API_HOST ?? DEFAULT_AGENTS_HOST,\n auth: { apiKey },\n fetch: deps.fetch,\n localCompute: false,\n // The document is already made; publishing sends exactly it.\n agentCodec: {\n documentOf: () => {\n if (agentDocument == null) throw new Error('Only an agent has an agent document');\n return agentDocument;\n },\n inProcessCodeOf: () => ({ tools: {}, hooks: {}, approvals: {} }),\n },\n });\n try {\n const project = client.project({ id: projectId });\n const name = values.name;\n const signal = deps.signal;\n const published =\n loaded.kind === DefinitionKind.Agent\n ? await project.agents.publish({ agent: loaded.agent, name, signal })\n : loaded.kind === DefinitionKind.Harness\n ? await project.harnesses.publish({ harness: loaded.document, name, signal })\n : await project.acpAdapters.publish({ adapter: loaded.document, name, signal });\n output.stdout(`published ${published.name}: ${published.hash}`);\n if ('id' in published && published.id != null) output.stdout(`id: ${published.id}`);\n return 0;\n } catch (cause) {\n for (const line of errorLines(cause)) output.stderr(line);\n return 1;\n } finally {\n client.close();\n }\n};\n"],
5
+ "mappings": "AAAA,SAAS,iBAAiB;AAC1B,SAAS,kBAAmC;AAE5C,YAAY,OAAO;AACnB,SAAS,2BAAkD;AAC3D,SAAS,oBAAoB;AAE7B,SAAS,gBAAgB,4BAA+C;AACxE,SAAS,sBAAsB;AAC/B,SAAS,kBAAoC;AAM7C,MAAM,QAAQ;AAAA,EACZ;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,yEACE,sBACA;AAAA,EACF;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,EAAE,KAAK,IAAI;AAEX,MAAM,YAAY,EAAE,OAAO;AAAA,EACzB,eAAe,EAAE,OAAO,EAAE,IAAI,CAAC,EAAE,SAAS;AAAA,EAC1C,gBAAgB,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS;AAAA,EAC1C,kBAAkB,EAAE,OAAO,EAAE,IAAI,CAAC,EAAE,SAAS;AAC/C,CAAC;AAeD,MAAM,gBAAgB;AAAA,EACpB,QAAQ,EAAE,MAAM,SAAS;AAAA,EACzB,MAAM,EAAE,MAAM,SAAS;AAAA,EACvB,SAAS,EAAE,MAAM,SAAS;AAAA,EAC1B,MAAM,EAAE,MAAM,SAAS;AAAA,EACvB,SAAS,EAAE,MAAM,SAAS;AAAA,EAC1B,SAAS,EAAE,MAAM,SAAS;AA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"name": "@finalai/agents",
3
- "version": "0.14.0",
3
+ "version": "0.16.0",
4
4
  "private": false,
5
5
  "description": "Agent authoring, client APIs, and CLI.",
6
6
  "license": "Apache-2.0",
@@ -28,7 +28,8 @@
28
28
  },
29
29
  "./client": {
30
30
  "types": "./dist/modules/agent-client/index.d.mts",
31
- "import": "./dist/modules/agent-client/index.mjs",
31
+ "react-native": "./dist/modules/agent-client/portable.mjs",
32
+ "browser": "./dist/modules/agent-client/portable.mjs",
32
33
  "default": "./dist/modules/agent-client/index.mjs"
33
34
  },
34
35
  "./client/acp": {
@@ -114,10 +115,10 @@
114
115
  },
115
116
  "dependencies": {
116
117
  "@agentclientprotocol/sdk": "1.8.0",
117
- "@finalai/agent-definition": "0.11.0",
118
- "@finalai/agent-protocol": "0.11.0",
119
- "@finalai/agent-provider": "0.12.0",
120
- "@finalai/final-agent-provider": "0.13.0",
118
+ "@finalai/agent-definition": "0.13.0",
119
+ "@finalai/agent-protocol": "0.13.0",
120
+ "@finalai/agent-provider": "0.14.0",
121
+ "@finalai/final-agent-provider": "0.15.0",
121
122
  "@finalai/websockets": "0.1.8",
122
123
  "ws": "^8.21.3",
123
124
  "zod": "4.6.6"