@finalai/agents 0.12.0 → 0.14.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.
Files changed (46) hide show
  1. package/README.md +1 -1
  2. package/dist/modules/agent-client/channels.d.mts +91 -28
  3. package/dist/modules/agent-client/channels.mjs +176 -46
  4. package/dist/modules/agent-client/channels.mjs.map +2 -2
  5. package/dist/modules/agent-client/client.d.mts +19 -4
  6. package/dist/modules/agent-client/client.mjs +16 -5
  7. package/dist/modules/agent-client/client.mjs.map +2 -2
  8. package/dist/modules/agent-client/conversation-resources.d.mts +18 -1
  9. package/dist/modules/agent-client/conversation-resources.mjs +28 -0
  10. package/dist/modules/agent-client/conversation-resources.mjs.map +2 -2
  11. package/dist/modules/agent-client/conversations.d.mts +21 -25
  12. package/dist/modules/agent-client/conversations.mjs +17 -62
  13. package/dist/modules/agent-client/conversations.mjs.map +2 -2
  14. package/dist/modules/agent-client/index.d.mts +5 -3
  15. package/dist/modules/agent-client/index.mjs.map +2 -2
  16. package/dist/modules/agent-client/integrations.d.mts +5 -1
  17. package/dist/modules/agent-client/integrations.mjs +9 -1
  18. package/dist/modules/agent-client/integrations.mjs.map +2 -2
  19. package/dist/modules/agent-client/organization.d.mts +83 -0
  20. package/dist/modules/agent-client/organization.mjs +209 -0
  21. package/dist/modules/agent-client/organization.mjs.map +7 -0
  22. package/dist/modules/agent-client/participant-configuration.d.mts +21 -0
  23. package/dist/modules/agent-client/participant-configuration.mjs +38 -0
  24. package/dist/modules/agent-client/participant-configuration.mjs.map +7 -0
  25. package/dist/modules/agent-client/project.d.mts +10 -2
  26. package/dist/modules/agent-client/project.mjs +8 -6
  27. package/dist/modules/agent-client/project.mjs.map +2 -2
  28. package/dist/modules/agent-client/provide.d.mts +0 -1
  29. package/dist/modules/agent-client/provide.mjs +0 -1
  30. package/dist/modules/agent-client/provide.mjs.map +2 -2
  31. package/dist/modules/agent-client/sandboxes.d.mts +7 -0
  32. package/dist/modules/agent-client/sandboxes.mjs +9 -1
  33. package/dist/modules/agent-client/sandboxes.mjs.map +2 -2
  34. package/dist/modules/agent-client/schedules.d.mts +7 -22
  35. package/dist/modules/agent-client/schedules.mjs +8 -47
  36. package/dist/modules/agent-client/schedules.mjs.map +2 -2
  37. package/dist/modules/agent-client/sessions.d.mts +8 -1
  38. package/dist/modules/agent-client/sessions.mjs +24 -5
  39. package/dist/modules/agent-client/sessions.mjs.map +2 -2
  40. package/dist/modules/public.d.mts +1 -1
  41. package/dist/modules/public.mjs.map +2 -2
  42. package/examples/release-scout/run-on-a-computer.ts +1 -1
  43. package/package.json +5 -10
  44. package/dist/modules/authoring/final-channel.d.mts +0 -1
  45. package/dist/modules/authoring/final-channel.mjs +0 -2
  46. package/dist/modules/authoring/final-channel.mjs.map +0 -7
@@ -1,5 +1,6 @@
1
+ import { createAllowedEndpointsApi } from "./organization.mjs";
1
2
  import {
2
- createChannelBindingsApi,
3
+ createChannelAppsApi,
3
4
  createProjectChannelsApi
4
5
  } from "./channels.mjs";
5
6
  import { encodePath } from "./context.mjs";
@@ -24,6 +25,7 @@ import {
24
25
  createPublicNamesApi
25
26
  } from "./publishers.mjs";
26
27
  import { createSandboxProvidersApi } from "./sandbox-providers.mjs";
28
+ import { createProjectSchedulesApi } from "./schedules.mjs";
27
29
  import {
28
30
  createSandboxesApi,
29
31
  createSandboxSetupsApi
@@ -44,10 +46,9 @@ const createProjectClient = (args) => {
44
46
  integrations: createIntegrationsApi({ context, projectId }),
45
47
  harnesses: createHarnessesApi({ context, projectId, store }),
46
48
  acpAdapters: createAcpAdaptersApi({ context, projectId }),
47
- channels: {
48
- ...createProjectChannelsApi({ context, projectId, sourceOf: args.channelSourceOf }),
49
- ...createChannelBindingsApi(context)
50
- },
49
+ channels: createProjectChannelsApi({ context, projectId, sourceOf: args.channelSourceOf }),
50
+ channelApps: createChannelAppsApi({ context, projectId }),
51
+ schedules: createProjectSchedulesApi({ context, projectId }),
51
52
  events: createEventsApi({ context, projectId }),
52
53
  eventSubscriptions: createEventSubscriptionsApi({
53
54
  context,
@@ -57,7 +58,8 @@ const createProjectClient = (args) => {
57
58
  oauthClients: createOAuthClientsApi({ context, projectId }),
58
59
  signInReturnOrigins: createSignInReturnOriginsApi({ context, projectId }),
59
60
  publisher: createProjectPublisherApi({ context, projectId }),
60
- publicNames: createPublicNamesApi({ context, projectId })
61
+ publicNames: createPublicNamesApi({ context, projectId }),
62
+ allowedEndpoints: createAllowedEndpointsApi({ context, projectId })
61
63
  };
62
64
  };
63
65
  export {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../src/agent-client/project.ts"],
4
- "sourcesContent": ["import type { AgentInput } from \"./agent-input.mjs\";\nimport {\n createChannelBindingsApi,\n createProjectChannelsApi,\n type ChannelBindingsApiIface,\n type ChannelSourceOf,\n type ProjectChannelsApiIface,\n} from \"./channels.mjs\";\nimport { encodePath, type ClientContextIface } from \"./context.mjs\";\nimport { createProjectConversationsApi, type ProjectConversationsApiIface } from \"./conversations.mjs\";\nimport {\n createEventsApi,\n createEventSubscriptionsApi,\n type EventsApiIface,\n type EventSubscriptionsApiIface,\n} from \"./events.mjs\";\nimport {\n createAcpAdaptersApi,\n createHarnessesApi,\n type AcpAdaptersApiIface,\n type HarnessesApiIface,\n} from \"./harnesses.mjs\";\nimport { createIntegrationsApi, type IntegrationsApiIface } from \"./integrations.mjs\";\nimport {\n createOAuthClientsApi,\n createSignInReturnOriginsApi,\n type OAuthClientsApiIface,\n type SignInReturnOriginsApiIface,\n} from \"./oauth-clients.mjs\";\nimport { createProjectAgentsApi, type ProjectAgentsApiIface } from \"./project-agents.mjs\";\nimport { createProjectResourceApi, type ProjectResourceApiIface } from \"./projects.mjs\";\nimport {\n createProjectPublisherApi,\n createPublicNamesApi,\n type ProjectPublisherApiIface,\n type PublicNamesApiIface,\n} from \"./publishers.mjs\";\nimport { createSandboxProvidersApi, type SandboxProvidersApiIface } from \"./sandbox-providers.mjs\";\nimport {\n createSandboxesApi,\n createSandboxSetupsApi,\n type SandboxesApiIface,\n type SandboxSetupsApiIface,\n} from \"./sandboxes.mjs\";\nimport { createProjectSessionsApi, type ProjectSessionsApiIface } from \"./sessions.mjs\";\nimport type { AgentStartDepsIface } from \"./start.mjs\";\n\n// One project: everything is created through it, and a session can only be\n// provided things from its own project.\n\nexport interface ProjectClientIface extends ProjectResourceApiIface {\n readonly id: string;\n sessions: ProjectSessionsApiIface;\n conversations: ProjectConversationsApiIface;\n agents: ProjectAgentsApiIface;\n sandboxes: SandboxesApiIface;\n sandboxSetups: SandboxSetupsApiIface;\n integrations: IntegrationsApiIface;\n harnesses: HarnessesApiIface;\n acpAdapters: AcpAdaptersApiIface;\n channels: ProjectChannelsApiIface & ChannelBindingsApiIface;\n /** The event feed for this project and those below it. */\n events: EventsApiIface;\n /** Pushes this project's feed to a URL (`webhooks:write`, project admin). */\n eventSubscriptions: EventSubscriptionsApiIface;\n sandboxProviders: SandboxProvidersApiIface;\n oauthClients: OAuthClientsApiIface;\n signInReturnOrigins: SignInReturnOriginsApiIface;\n /** The project's publisher handle. */\n publisher: ProjectPublisherApiIface;\n /** Which of the project's names resolve as `handle/name` from any organization. */\n publicNames: PublicNamesApiIface;\n}\n\nexport const createProjectClient = (args: {\n context: ClientContextIface;\n start: AgentStartDepsIface;\n channelSourceOf: ChannelSourceOf;\n projectId: string;\n}): ProjectClientIface => {\n const { context, projectId } = args;\n const agents = createProjectAgentsApi({ context, projectId, codec: args.start.codec });\n // The document must be stored before the platform can check a harness against it.\n const store = async (agent: AgentInput, signal?: AbortSignal): Promise<string> =>\n (await agents.store({ agent, signal })).hash;\n return {\n ...createProjectResourceApi({ context, projectId }),\n id: projectId,\n sessions: createProjectSessionsApi({ context, projectId, start: args.start }),\n conversations: createProjectConversationsApi({ context, projectId, start: args.start }),\n agents,\n sandboxes: createSandboxesApi({ context, projectId }),\n sandboxSetups: createSandboxSetupsApi({ context, projectId }),\n integrations: createIntegrationsApi({ context, projectId }),\n harnesses: createHarnessesApi({ context, projectId, store }),\n acpAdapters: createAcpAdaptersApi({ context, projectId }),\n channels: {\n ...createProjectChannelsApi({ context, projectId, sourceOf: args.channelSourceOf }),\n ...createChannelBindingsApi(context),\n },\n events: createEventsApi({ context, projectId }),\n eventSubscriptions: createEventSubscriptionsApi({\n context,\n basePath: `/v1/projects/${encodePath(projectId)}/event-subscriptions`,\n }),\n sandboxProviders: createSandboxProvidersApi({ context, projectId }),\n oauthClients: createOAuthClientsApi({ context, projectId }),\n signInReturnOrigins: createSignInReturnOriginsApi({ context, projectId }),\n publisher: createProjectPublisherApi({ context, projectId }),\n publicNames: createPublicNamesApi({ context, projectId }),\n };\n};\n"],
5
- "mappings": "AACA;AAAA,EACE;AAAA,EACA;AAAA,OAIK;AACP,SAAS,kBAA2C;AACpD,SAAS,qCAAwE;AACjF;AAAA,EACE;AAAA,EACA;AAAA,OAGK;AACP;AAAA,EACE;AAAA,EACA;AAAA,OAGK;AACP,SAAS,6BAAwD;AACjE;AAAA,EACE;AAAA,EACA;AAAA,OAGK;AACP,SAAS,8BAA0D;AACnE,SAAS,gCAA8D;AACvE;AAAA,EACE;AAAA,EACA;AAAA,OAGK;AACP,SAAS,iCAAgE;AACzE;AAAA,EACE;AAAA,EACA;AAAA,OAGK;AACP,SAAS,gCAA8D;AA8BhE,MAAM,sBAAsB,CAAC,SAKV;AACxB,QAAM,EAAE,SAAS,UAAU,IAAI;AAC/B,QAAM,SAAS,uBAAuB,EAAE,SAAS,WAAW,OAAO,KAAK,MAAM,MAAM,CAAC;AAErF,QAAM,QAAQ,OAAO,OAAmB,YACrC,MAAM,OAAO,MAAM,EAAE,OAAO,OAAO,CAAC,GAAG;AAC1C,SAAO;AAAA,IACL,GAAG,yBAAyB,EAAE,SAAS,UAAU,CAAC;AAAA,IAClD,IAAI;AAAA,IACJ,UAAU,yBAAyB,EAAE,SAAS,WAAW,OAAO,KAAK,MAAM,CAAC;AAAA,IAC5E,eAAe,8BAA8B,EAAE,SAAS,WAAW,OAAO,KAAK,MAAM,CAAC;AAAA,IACtF;AAAA,IACA,WAAW,mBAAmB,EAAE,SAAS,UAAU,CAAC;AAAA,IACpD,eAAe,uBAAuB,EAAE,SAAS,UAAU,CAAC;AAAA,IAC5D,cAAc,sBAAsB,EAAE,SAAS,UAAU,CAAC;AAAA,IAC1D,WAAW,mBAAmB,EAAE,SAAS,WAAW,MAAM,CAAC;AAAA,IAC3D,aAAa,qBAAqB,EAAE,SAAS,UAAU,CAAC;AAAA,IACxD,UAAU;AAAA,MACR,GAAG,yBAAyB,EAAE,SAAS,WAAW,UAAU,KAAK,gBAAgB,CAAC;AAAA,MAClF,GAAG,yBAAyB,OAAO;AAAA,IACrC;AAAA,IACA,QAAQ,gBAAgB,EAAE,SAAS,UAAU,CAAC;AAAA,IAC9C,oBAAoB,4BAA4B;AAAA,MAC9C;AAAA,MACA,UAAU,gBAAgB,WAAW,SAAS,CAAC;AAAA,IACjD,CAAC;AAAA,IACD,kBAAkB,0BAA0B,EAAE,SAAS,UAAU,CAAC;AAAA,IAClE,cAAc,sBAAsB,EAAE,SAAS,UAAU,CAAC;AAAA,IAC1D,qBAAqB,6BAA6B,EAAE,SAAS,UAAU,CAAC;AAAA,IACxE,WAAW,0BAA0B,EAAE,SAAS,UAAU,CAAC;AAAA,IAC3D,aAAa,qBAAqB,EAAE,SAAS,UAAU,CAAC;AAAA,EAC1D;AACF;",
4
+ "sourcesContent": ["import { createAllowedEndpointsApi, type AllowedEndpointsApiIface } from \"./organization.mjs\";\nimport type { AgentInput } from \"./agent-input.mjs\";\nimport {\n createChannelAppsApi,\n createProjectChannelsApi,\n type ChannelAppsApiIface,\n type ChannelSourceOf,\n type ProjectChannelsApiIface,\n} from \"./channels.mjs\";\nimport { encodePath, type ClientContextIface } from \"./context.mjs\";\nimport { createProjectConversationsApi, type ProjectConversationsApiIface } from \"./conversations.mjs\";\nimport {\n createEventsApi,\n createEventSubscriptionsApi,\n type EventsApiIface,\n type EventSubscriptionsApiIface,\n} from \"./events.mjs\";\nimport {\n createAcpAdaptersApi,\n createHarnessesApi,\n type AcpAdaptersApiIface,\n type HarnessesApiIface,\n} from \"./harnesses.mjs\";\nimport { createIntegrationsApi, type IntegrationsApiIface } from \"./integrations.mjs\";\nimport {\n createOAuthClientsApi,\n createSignInReturnOriginsApi,\n type OAuthClientsApiIface,\n type SignInReturnOriginsApiIface,\n} from \"./oauth-clients.mjs\";\nimport { createProjectAgentsApi, type ProjectAgentsApiIface } from \"./project-agents.mjs\";\nimport { createProjectResourceApi, type ProjectResourceApiIface } from \"./projects.mjs\";\nimport {\n createProjectPublisherApi,\n createPublicNamesApi,\n type ProjectPublisherApiIface,\n type PublicNamesApiIface,\n} from \"./publishers.mjs\";\nimport { createSandboxProvidersApi, type SandboxProvidersApiIface } from \"./sandbox-providers.mjs\";\nimport { createProjectSchedulesApi, type ProjectSchedulesApiIface } from \"./schedules.mjs\";\nimport {\n createSandboxesApi,\n createSandboxSetupsApi,\n type SandboxesApiIface,\n type SandboxSetupsApiIface,\n} from \"./sandboxes.mjs\";\nimport { createProjectSessionsApi, type ProjectSessionsApiIface } from \"./sessions.mjs\";\nimport type { AgentStartDepsIface } from \"./start.mjs\";\n\n// One project: everything is created through it, and a session can only be\n// provided things from its own project.\n\nexport interface ProjectClientIface extends ProjectResourceApiIface {\n readonly id: string;\n sessions: ProjectSessionsApiIface;\n conversations: ProjectConversationsApiIface;\n agents: ProjectAgentsApiIface;\n sandboxes: SandboxesApiIface;\n sandboxSetups: SandboxSetupsApiIface;\n integrations: IntegrationsApiIface;\n harnesses: HarnessesApiIface;\n acpAdapters: AcpAdaptersApiIface;\n channels: ProjectChannelsApiIface;\n /** Provider application credentials the project's channel installs use. */\n channelApps: ChannelAppsApiIface;\n /** The schedules of the project's conversations. */\n schedules: ProjectSchedulesApiIface;\n /** The event feed for this project and those below it. */\n events: EventsApiIface;\n /** Pushes this project's feed to a URL (`webhooks:write`, project admin). */\n eventSubscriptions: EventSubscriptionsApiIface;\n sandboxProviders: SandboxProvidersApiIface;\n oauthClients: OAuthClientsApiIface;\n signInReturnOrigins: SignInReturnOriginsApiIface;\n /** The project's publisher handle. */\n publisher: ProjectPublisherApiIface;\n /** Which of the project's names resolve as `handle/name` from any organization. */\n publicNames: PublicNamesApiIface;\n /** Where the project lets its secrets go beyond model vendors' own APIs. */\n allowedEndpoints: AllowedEndpointsApiIface;\n}\n\nexport const createProjectClient = (args: {\n context: ClientContextIface;\n start: AgentStartDepsIface;\n channelSourceOf: ChannelSourceOf;\n projectId: string;\n}): ProjectClientIface => {\n const { context, projectId } = args;\n const agents = createProjectAgentsApi({ context, projectId, codec: args.start.codec });\n // The document must be stored before the platform can check a harness against it.\n const store = async (agent: AgentInput, signal?: AbortSignal): Promise<string> =>\n (await agents.store({ agent, signal })).hash;\n return {\n ...createProjectResourceApi({ context, projectId }),\n id: projectId,\n sessions: createProjectSessionsApi({ context, projectId, start: args.start }),\n conversations: createProjectConversationsApi({ context, projectId, start: args.start }),\n agents,\n sandboxes: createSandboxesApi({ context, projectId }),\n sandboxSetups: createSandboxSetupsApi({ context, projectId }),\n integrations: createIntegrationsApi({ context, projectId }),\n harnesses: createHarnessesApi({ context, projectId, store }),\n acpAdapters: createAcpAdaptersApi({ context, projectId }),\n channels: createProjectChannelsApi({ context, projectId, sourceOf: args.channelSourceOf }),\n channelApps: createChannelAppsApi({ context, projectId }),\n schedules: createProjectSchedulesApi({ context, projectId }),\n events: createEventsApi({ context, projectId }),\n eventSubscriptions: createEventSubscriptionsApi({\n context,\n basePath: `/v1/projects/${encodePath(projectId)}/event-subscriptions`,\n }),\n sandboxProviders: createSandboxProvidersApi({ context, projectId }),\n oauthClients: createOAuthClientsApi({ context, projectId }),\n signInReturnOrigins: createSignInReturnOriginsApi({ context, projectId }),\n publisher: createProjectPublisherApi({ context, projectId }),\n publicNames: createPublicNamesApi({ context, projectId }),\n allowedEndpoints: createAllowedEndpointsApi({ context, projectId }),\n };\n};\n"],
5
+ "mapp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,qBAAqB,EAAE,SAAS,UAAU,CAAC;AAAA,IACxD,WAAW,0BAA0B,EAAE,SAAS,UAAU,CAAC;AAAA,IAC3D,QAAQ,gBAAgB,EAAE,SAAS,UAAU,CAAC;AAAA,IAC9C,oBAAoB,4BAA4B;AAAA,MAC9C;AAAA,MACA,UAAU,gBAAgB,WAAW,SAAS,CAAC;AAAA,IACjD,CAAC;AAAA,IACD,kBAAkB,0BAA0B,EAAE,SAAS,UAAU,CAAC;AAAA,IAClE,cAAc,sBAAsB,EAAE,SAAS,UAAU,CAAC;AAAA,IAC1D,qBAAqB,6BAA6B,EAAE,SAAS,UAAU,CAAC;AAAA,IACxE,WAAW,0BAA0B,EAAE,SAAS,UAAU,CAAC;AAAA,IAC3D,aAAa,qBAAqB,EAAE,SAAS,UAAU,CAAC;AAAA,IACxD,kBAAkB,0BAA0B,EAAE,SAAS,UAAU,CAAC;AAAA,EACpE;AACF;",
6
6
  "names": []
7
7
  }
@@ -22,7 +22,6 @@ export interface ProvidePatchIface {
22
22
  harness?: HarnessSettingsIface;
23
23
  compute?: Partial<Record<Capability | `${Capability}`, ResourceRef | null>>;
24
24
  integrations?: Record<string, ResourceRef | null>;
25
- instructions?: string | null;
26
25
  tools?: string[] | null;
27
26
  /** The settings revision you read; a stale one fails with `conflict`. */
28
27
  revision?: number;
@@ -39,7 +39,6 @@ const providePatchOf = (patch) => ({
39
39
  ...patch.harness == null ? {} : { harness: patch.harness },
40
40
  ...patch.compute == null ? {} : { compute: computePatchOf(patch.compute) },
41
41
  ...patch.integrations == null ? {} : { integrations: slotPatchOf(patch.integrations) },
42
- ...patch.instructions === void 0 ? {} : { instructions: patch.instructions },
43
42
  ...patch.tools === void 0 ? {} : { tools: patch.tools },
44
43
  ...patch.revision == null ? {} : { revision: patch.revision }
45
44
  });
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../src/agent-client/provide.ts"],
4
- "sourcesContent": ["import { CAPABILITIES, type Capability } from '@finalai/agent-protocol';\nimport {\n harnessSettingsSchema,\n type HarnessSettingsIface,\n type HarnessSettingsViewIface,\n type ProvideDocumentIface,\n type ProvideDocumentViewIface,\n type ProvideParticipantRequestIface,\n} from '@finalai/agent-protocol/agent-platform';\nimport { clientError, ClientErrorCode } from \"./errors.mjs\";\n\n// What a caller provides to meet an agent's requirements, as the SDK accepts\n// it: the wire document, except that a sandbox or an integration may be given\n// as the handle `project.sandboxes.create` or `project.integrations.create`\n// returned. Handles are sent as their ids.\n\n/** Anything with the id of a project resource: a handle, or a fetched record. */\nexport interface ResourceRefIface {\n readonly id: string;\n}\n\nexport type ResourceRef = string | ResourceRefIface;\n\nexport interface ProvideIface {\n /** Harness settings, inline: `serverlessPi({ model, inference })`. */\n harness?: HarnessSettingsIface;\n /**\n * Capability \u2192 the sandbox that provides it. `files` and `shell` must name the\n * same sandbox. A capability left out runs in this process unless the client\n * was created with `localCompute: false`.\n */\n compute?: Partial<Record<Capability | `${Capability}`, ResourceRef>>;\n /** Integration slot \u2192 the integration that fills it. */\n integrations?: Record<string, ResourceRef>;\n}\n\n/** A change to one agent participant's settings; `null` removes a capability or slot. */\nexport interface ProvidePatchIface {\n harness?: HarnessSettingsIface;\n compute?: Partial<Record<Capability | `${Capability}`, ResourceRef | null>>;\n integrations?: Record<string, ResourceRef | null>;\n instructions?: string | null;\n tools?: string[] | null;\n /** The settings revision you read; a stale one fails with `conflict`. */\n revision?: number;\n}\n\nexport const resourceIdOf = (ref: ResourceRef): string => (typeof ref === 'string' ? ref : ref.id);\n\nconst capabilityOf = (key: string): Capability => {\n const capability = CAPABILITIES.find((candidate) => candidate === key);\n if (capability == null)\n throw clientError({\n message: `Unknown compute capability ${key}: use ${CAPABILITIES.join(', ')}`,\n status: 0,\n code: ClientErrorCode.InvalidRequest,\n });\n return capability;\n};\n\nconst computeIdsOf = (\n refs: Partial<Record<string, ResourceRef>>,\n): Partial<Record<Capability, string>> => {\n const ids: Partial<Record<Capability, string>> = {};\n for (const [key, ref] of Object.entries(refs))\n if (ref != null) ids[capabilityOf(key)] = resourceIdOf(ref);\n return ids;\n};\n\nconst computePatchOf = (\n refs: Partial<Record<string, ResourceRef | null>>,\n): Partial<Record<Capability, string | null>> => {\n const ids: Partial<Record<Capability, string | null>> = {};\n for (const [key, ref] of Object.entries(refs))\n if (ref !== undefined) ids[capabilityOf(key)] = ref == null ? null : resourceIdOf(ref);\n return ids;\n};\n\nconst slotIdsOf = (refs: Record<string, ResourceRef>): Record<string, string> =>\n Object.fromEntries(Object.entries(refs).map(([slot, ref]) => [slot, resourceIdOf(ref)]));\n\nconst slotPatchOf = (refs: Record<string, ResourceRef | null>): Record<string, string | null> =>\n Object.fromEntries(\n Object.entries(refs).map(([slot, ref]) => [slot, ref == null ? null : resourceIdOf(ref)]),\n );\n\n/** The wire document for `provide`: handles become ids. */\nexport const provideDocumentOf = (provide: ProvideIface): ProvideDocumentIface => ({\n ...(provide.harness == null ? {} : { harness: provide.harness }),\n ...(provide.compute == null ? {} : { compute: computeIdsOf(provide.compute) }),\n ...(provide.integrations == null ? {} : { integrations: slotIdsOf(provide.integrations) }),\n});\n\nexport const providePatchOf = (patch: ProvidePatchIface): ProvideParticipantRequestIface => ({\n ...(patch.harness == null ? {} : { harness: patch.harness }),\n ...(patch.compute == null ? {} : { compute: computePatchOf(patch.compute) }),\n ...(patch.integrations == null ? {} : { integrations: slotPatchOf(patch.integrations) }),\n ...(patch.instructions === undefined ? {} : { instructions: patch.instructions }),\n ...(patch.tools === undefined ? {} : { tools: patch.tools }),\n ...(patch.revision == null ? {} : { revision: patch.revision }),\n});\n\n// Settings the SDK cannot read back in full (a newer server's inference\n// source) still name the harness, which is what the local check needs.\nconst harnessOfView = (view: HarnessSettingsViewIface): HarnessSettingsIface => {\n const environment =\n view.environment == null\n ? {}\n : {\n environment:\n typeof view.environment === 'string'\n ? view.environment\n : {\n url: view.environment.url,\n ...(view.environment.hop == null ? {} : { hop: view.environment.hop }),\n },\n };\n const parsed = harnessSettingsSchema.safeParse({\n harness: view.harness,\n ...(view.adapter == null ? {} : { adapter: view.adapter }),\n configuration: view.configuration,\n ...environment,\n });\n return parsed.success ? parsed.data : { harness: view.harness };\n};\n\n/** A provide document as the server returns it, back in the form calls send. */\nexport const provideDocumentOfView = (view: ProvideDocumentViewIface): ProvideDocumentIface => {\n const compute: Partial<Record<Capability, string>> = {};\n for (const [key, id] of Object.entries(view.compute)) {\n const capability = CAPABILITIES.find((candidate) => candidate === key);\n if (capability != null) compute[capability] = id;\n }\n return {\n ...(view.harness == null ? {} : { harness: harnessOfView(view.harness) }),\n ...(Object.keys(compute).length === 0 ? {} : { compute }),\n ...(Object.keys(view.integrations).length === 0 ? {} : { integrations: view.integrations }),\n };\n};\n\n/**\n * What an agent is provided, as the platform layers it: the nearest scope that\n * sets a top-level key wins it whole, so compute never mixes sandboxes from\n * two scopes.\n */\nexport const layerProvide = (\n own: ProvideDocumentIface,\n shared: ProvideDocumentIface | null,\n): ProvideDocumentIface => {\n const harness = own.harness ?? shared?.harness;\n const compute = own.compute ?? shared?.compute;\n const integrations = own.integrations ?? shared?.integrations;\n return {\n ...(harness == null ? {} : { harness }),\n ...(compute == null ? {} : { compute }),\n ...(integrations == null ? {} : { integrations }),\n };\n};\n"],
5
- "mappings": "AAAA,SAAS,oBAAqC;AAC9C;AAAA,EACE;AAAA,OAMK;AACP,SAAS,aAAa,uBAAuB;AAsCtC,MAAM,eAAe,CAAC,QAA8B,OAAO,QAAQ,WAAW,MAAM,IAAI;AAE/F,MAAM,eAAe,CAAC,QAA4B;AAChD,QAAM,aAAa,aAAa,KAAK,CAAC,cAAc,cAAc,GAAG;AACrE,MAAI,cAAc;AAChB,UAAM,YAAY;AAAA,MAChB,SAAS,8BAA8B,GAAG,SAAS,aAAa,KAAK,IAAI,CAAC;AAAA,MAC1E,QAAQ;AAAA,MACR,MAAM,gBAAgB;AAAA,IACxB,CAAC;AACH,SAAO;AACT;AAEA,MAAM,eAAe,CACnB,SACwC;AACxC,QAA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AK,YAAY,EAAE,WAAW,IAAI,CAAC,IAAI,EAAE,cAAc,KAAK,aAAa;AAAA,EAC3F;AACF;AAOO,MAAM,eAAe,CAC1B,KACA,WACyB;AACzB,QAAM,UAAU,IAAI,WAAW,QAAQ;AACvC,QAAM,UAAU,IAAI,WAAW,QAAQ;AACvC,QAAM,eAAe,IAAI,gBAAgB,QAAQ;AACjD,SAAO;AAAA,IACL,GAAI,WAAW,OAAO,CAAC,IAAI,EAAE,QAAQ;AAAA,IACrC,GAAI,WAAW,OAAO,CAAC,IAAI,EAAE,QAAQ;AAAA,IACrC,GAAI,gBAAgB,OAAO,CAAC,IAAI,EAAE,aAAa;AAAA,EACjD;AACF;",
4
+ "sourcesContent": ["import { CAPABILITIES, type Capability } from '@finalai/agent-protocol';\nimport {\n harnessSettingsSchema,\n type HarnessSettingsIface,\n type HarnessSettingsViewIface,\n type ProvideDocumentIface,\n type ProvideDocumentViewIface,\n type ProvideParticipantRequestIface,\n} from '@finalai/agent-protocol/agent-platform';\nimport { clientError, ClientErrorCode } from \"./errors.mjs\";\n\n// What a caller provides to meet an agent's requirements, as the SDK accepts\n// it: the wire document, except that a sandbox or an integration may be given\n// as the handle `project.sandboxes.create` or `project.integrations.create`\n// returned. Handles are sent as their ids.\n\n/** Anything with the id of a project resource: a handle, or a fetched record. */\nexport interface ResourceRefIface {\n readonly id: string;\n}\n\nexport type ResourceRef = string | ResourceRefIface;\n\nexport interface ProvideIface {\n /** Harness settings, inline: `serverlessPi({ model, inference })`. */\n harness?: HarnessSettingsIface;\n /**\n * Capability \u2192 the sandbox that provides it. `files` and `shell` must name the\n * same sandbox. A capability left out runs in this process unless the client\n * was created with `localCompute: false`.\n */\n compute?: Partial<Record<Capability | `${Capability}`, ResourceRef>>;\n /** Integration slot \u2192 the integration that fills it. */\n integrations?: Record<string, ResourceRef>;\n}\n\n/** A change to one agent participant's settings; `null` removes a capability or slot. */\nexport interface ProvidePatchIface {\n harness?: HarnessSettingsIface;\n compute?: Partial<Record<Capability | `${Capability}`, ResourceRef | null>>;\n integrations?: Record<string, ResourceRef | null>;\n tools?: string[] | null;\n /** The settings revision you read; a stale one fails with `conflict`. */\n revision?: number;\n}\n\nexport const resourceIdOf = (ref: ResourceRef): string => (typeof ref === 'string' ? ref : ref.id);\n\nconst capabilityOf = (key: string): Capability => {\n const capability = CAPABILITIES.find((candidate) => candidate === key);\n if (capability == null)\n throw clientError({\n message: `Unknown compute capability ${key}: use ${CAPABILITIES.join(', ')}`,\n status: 0,\n code: ClientErrorCode.InvalidRequest,\n });\n return capability;\n};\n\nconst computeIdsOf = (\n refs: Partial<Record<string, ResourceRef>>,\n): Partial<Record<Capability, string>> => {\n const ids: Partial<Record<Capability, string>> = {};\n for (const [key, ref] of Object.entries(refs))\n if (ref != null) ids[capabilityOf(key)] = resourceIdOf(ref);\n return ids;\n};\n\nconst computePatchOf = (\n refs: Partial<Record<string, ResourceRef | null>>,\n): Partial<Record<Capability, string | null>> => {\n const ids: Partial<Record<Capability, string | null>> = {};\n for (const [key, ref] of Object.entries(refs))\n if (ref !== undefined) ids[capabilityOf(key)] = ref == null ? null : resourceIdOf(ref);\n return ids;\n};\n\nconst slotIdsOf = (refs: Record<string, ResourceRef>): Record<string, string> =>\n Object.fromEntries(Object.entries(refs).map(([slot, ref]) => [slot, resourceIdOf(ref)]));\n\nconst slotPatchOf = (refs: Record<string, ResourceRef | null>): Record<string, string | null> =>\n Object.fromEntries(\n Object.entries(refs).map(([slot, ref]) => [slot, ref == null ? null : resourceIdOf(ref)]),\n );\n\n/** The wire document for `provide`: handles become ids. */\nexport const provideDocumentOf = (provide: ProvideIface): ProvideDocumentIface => ({\n ...(provide.harness == null ? {} : { harness: provide.harness }),\n ...(provide.compute == null ? {} : { compute: computeIdsOf(provide.compute) }),\n ...(provide.integrations == null ? {} : { integrations: slotIdsOf(provide.integrations) }),\n});\n\nexport const providePatchOf = (patch: ProvidePatchIface): ProvideParticipantRequestIface => ({\n ...(patch.harness == null ? {} : { harness: patch.harness }),\n ...(patch.compute == null ? {} : { compute: computePatchOf(patch.compute) }),\n ...(patch.integrations == null ? {} : { integrations: slotPatchOf(patch.integrations) }),\n ...(patch.tools === undefined ? {} : { tools: patch.tools }),\n ...(patch.revision == null ? {} : { revision: patch.revision }),\n});\n\n// Settings the SDK cannot read back in full (a newer server's inference\n// source) still name the harness, which is what the local check needs.\nconst harnessOfView = (view: HarnessSettingsViewIface): HarnessSettingsIface => {\n const environment =\n view.environment == null\n ? {}\n : {\n environment:\n typeof view.environment === 'string'\n ? view.environment\n : {\n url: view.environment.url,\n ...(view.environment.hop == null ? {} : { hop: view.environment.hop }),\n },\n };\n const parsed = harnessSettingsSchema.safeParse({\n harness: view.harness,\n ...(view.adapter == null ? {} : { adapter: view.adapter }),\n configuration: view.configuration,\n ...environment,\n });\n return parsed.success ? parsed.data : { harness: view.harness };\n};\n\n/** A provide document as the server returns it, back in the form calls send. */\nexport const provideDocumentOfView = (view: ProvideDocumentViewIface): ProvideDocumentIface => {\n const compute: Partial<Record<Capability, string>> = {};\n for (const [key, id] of Object.entries(view.compute)) {\n const capability = CAPABILITIES.find((candidate) => candidate === key);\n if (capability != null) compute[capability] = id;\n }\n return {\n ...(view.harness == null ? {} : { harness: harnessOfView(view.harness) }),\n ...(Object.keys(compute).length === 0 ? {} : { compute }),\n ...(Object.keys(view.integrations).length === 0 ? {} : { integrations: view.integrations }),\n };\n};\n\n/**\n * What an agent is provided, as the platform layers it: the nearest scope that\n * sets a top-level key wins it whole, so compute never mixes sandboxes from\n * two scopes.\n */\nexport const layerProvide = (\n own: ProvideDocumentIface,\n shared: ProvideDocumentIface | null,\n): ProvideDocumentIface => {\n const harness = own.harness ?? shared?.harness;\n const compute = own.compute ?? shared?.compute;\n const integrations = own.integrations ?? shared?.integrations;\n return {\n ...(harness == null ? {} : { harness }),\n ...(compute == null ? {} : { compute }),\n ...(integrations == null ? {} : { integrations }),\n };\n};\n"],
5
+ "mappings": "AAAA,SAAS,oBAAqC;AAC9C;A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QAAQ,KAAK,OAAO,GAAG;AACpD,UAAM,aAAa,aAAa,KAAK,CAAC,cAAc,cAAc,GAAG;AACrE,QAAI,cAAc,KAAM,SAAQ,UAAU,IAAI;AAAA,EAChD;AACA,SAAO;AAAA,IACL,GAAI,KAAK,WAAW,OAAO,CAAC,IAAI,EAAE,SAAS,cAAc,KAAK,OAAO,EAAE;AAAA,IACvE,GAAI,OAAO,KAAK,OAAO,EAAE,WAAW,IAAI,CAAC,IAAI,EAAE,QAAQ;AAAA,IACvD,GAAI,OAAO,KAAK,KAAK,YAAY,EAAE,WAAW,IAAI,CAAC,IAAI,EAAE,cAAc,KAAK,aAAa;AAAA,EAC3F;AACF;AAOO,MAAM,eAAe,CAC1B,KACA,WACyB;AACzB,QAAM,UAAU,IAAI,WAAW,QAAQ;AACvC,QAAM,UAAU,IAAI,WAAW,QAAQ;AACvC,QAAM,eAAe,IAAI,gBAAgB,QAAQ;AACjD,SAAO;AAAA,IACL,GAAI,WAAW,OAAO,CAAC,IAAI,EAAE,QAAQ;AAAA,IACrC,GAAI,WAAW,OAAO,CAAC,IAAI,EAAE,QAAQ;AAAA,IACrC,GAAI,gBAAgB,OAAO,CAAC,IAAI,EAAE,aAAa;AAAA,EACjD;AACF;",
6
6
  "names": []
7
7
  }
@@ -26,6 +26,13 @@ export interface SandboxHandleIface {
26
26
  run: (args: RunSandboxCommandRequestIface & SignalOptionsIface) => Promise<RunSandboxCommandResponseIface>;
27
27
  /** What is known about the machine: checkouts, services, commands, notes. */
28
28
  description: (options?: SignalOptionsIface) => Promise<SandboxDescriptionIface>;
29
+ /**
30
+ * Sends the sandbox's outbound traffic through an integration's egress exit (`intg_...`),
31
+ * or straight out with `null`.
32
+ */
33
+ setEgressExit: (args: {
34
+ integration: string | null;
35
+ } & SignalOptionsIface) => Promise<SandboxResourceIface>;
29
36
  delete: (options?: SignalOptionsIface) => Promise<void>;
30
37
  }
31
38
  export interface SandboxesApiIface {
@@ -11,7 +11,8 @@ import {
11
11
  sandboxProviderListSchema,
12
12
  sandboxResourceSchema,
13
13
  sandboxSetupListSchema,
14
- sandboxSetupResourceSchema
14
+ sandboxSetupResourceSchema,
15
+ setSandboxEgressExitRequestSchema
15
16
  } from "@finalai/agent-protocol/agent-platform";
16
17
  import { encodePath } from "./context.mjs";
17
18
  import { HttpMethod } from "./http.mjs";
@@ -41,6 +42,13 @@ const createSandboxesApi = (args) => {
41
42
  response: sandboxDescriptionSchema,
42
43
  signal: options?.signal
43
44
  }),
45
+ setEgressExit: ({ signal, ...value }) => http.request({
46
+ method: HttpMethod.Put,
47
+ path: sandboxPath(resource.id, "/egress-exit"),
48
+ body: { schema: setSandboxEgressExitRequestSchema, value },
49
+ response: sandboxResourceSchema,
50
+ signal
51
+ }),
44
52
  delete: async (options) => {
45
53
  await http.request({
46
54
  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 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 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 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,OAWK;AACP,SAAS,kBAAoE;AAC7E,SAAS,kBAAkB;AAkE3B,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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A,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 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,c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AAC;AAAA,IACH,KAAK,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;",
6
6
  "names": []
7
7
  }
@@ -1,24 +1,9 @@
1
- import { type ScheduleIface, type ScheduleRunResultIface, type UpdateScheduleRequestIface } from '@finalai/agent-protocol/agent-platform';
1
+ import { type ConversationScheduleIface } from '@finalai/agent-protocol/agent-platform';
2
2
  import { type ClientContextIface, type SignalOptionsIface } from "./context.mjs";
3
- import { type ProvideIface } from "./provide.mjs";
4
- export type ScheduleRef = {
5
- scheduleId: string;
6
- } | {
7
- agent: string;
8
- key: string;
9
- };
10
- export interface ScheduleUpdateIface extends Omit<UpdateScheduleRequestIface, 'provide'> {
11
- /** What its runs start with; fails with `requirements_unmet` unless it meets the agent's requirements. */
12
- provide?: ProvideIface;
3
+ export interface ProjectSchedulesApiIface {
4
+ list: (options?: SignalOptionsIface) => Promise<ConversationScheduleIface[]>;
13
5
  }
14
- export interface SchedulesApiIface {
15
- /** `agent` narrows to one agent's schedules, by its id. */
16
- list: (options?: SignalOptionsIface & {
17
- agent?: string;
18
- }) => Promise<ScheduleIface[]>;
19
- runNow: (args: ScheduleRef & SignalOptionsIface) => Promise<ScheduleRunResultIface>;
20
- update: (args: {
21
- scheduleId: string;
22
- } & ScheduleUpdateIface & SignalOptionsIface) => Promise<ScheduleIface>;
23
- }
24
- export declare const createSchedulesApi: ({ http }: ClientContextIface) => SchedulesApiIface;
6
+ export declare const createProjectSchedulesApi: (args: {
7
+ context: ClientContextIface;
8
+ projectId: string;
9
+ }) => ProjectSchedulesApiIface;
@@ -1,56 +1,17 @@
1
1
  import {
2
- scheduleListSchema,
3
- scheduleRunResultSchema,
4
- scheduleSchema,
5
- updateScheduleRequestSchema
2
+ projectScheduleListSchema
6
3
  } from "@finalai/agent-protocol/agent-platform";
7
4
  import { encodePath } from "./context.mjs";
8
- import { clientError, ClientErrorCode } from "./errors.mjs";
9
5
  import { HttpMethod } from "./http.mjs";
10
- import { provideDocumentOf } from "./provide.mjs";
11
- const createSchedulesApi = ({ http }) => {
12
- const list = async (options) => (await http.request({
6
+ const createProjectSchedulesApi = (args) => ({
7
+ list: async (options) => (await args.context.http.request({
13
8
  method: HttpMethod.Get,
14
- path: "/v1/schedules",
15
- query: { agent: options?.agent },
16
- response: scheduleListSchema,
9
+ path: `/v1/projects/${encodePath(args.projectId)}/schedules`,
10
+ response: projectScheduleListSchema,
17
11
  signal: options?.signal
18
- })).schedules;
19
- const scheduleIdOf = async (args) => {
20
- if ("scheduleId" in args) return args.scheduleId;
21
- const found = (await list({ agent: args.agent, signal: args.signal })).find(
22
- (schedule) => schedule.key === args.key
23
- );
24
- if (found == null) {
25
- throw clientError({
26
- message: `No schedule ${args.key} on agent ${args.agent}`,
27
- status: 0,
28
- code: ClientErrorCode.NotFound
29
- });
30
- }
31
- return found.id;
32
- };
33
- return {
34
- list,
35
- runNow: async (args) => http.request({
36
- method: HttpMethod.Post,
37
- path: `/v1/schedules/${encodePath(await scheduleIdOf(args))}/run-now`,
38
- response: scheduleRunResultSchema,
39
- signal: args.signal
40
- }),
41
- update: ({ scheduleId, signal, provide, ...value }) => http.request({
42
- method: HttpMethod.Patch,
43
- path: `/v1/schedules/${encodePath(scheduleId)}`,
44
- body: {
45
- schema: updateScheduleRequestSchema,
46
- value: { ...value, ...provide == null ? {} : { provide: provideDocumentOf(provide) } }
47
- },
48
- response: scheduleSchema,
49
- signal
50
- })
51
- };
52
- };
12
+ })).schedules
13
+ });
53
14
  export {
54
- createSchedulesApi
15
+ createProjectSchedulesApi
55
16
  };
56
17
  //# sourceMappingURL=schedules.mjs.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../src/agent-client/schedules.ts"],
4
- "sourcesContent": ["import {\n scheduleListSchema,\n scheduleRunResultSchema,\n scheduleSchema,\n updateScheduleRequestSchema,\n type ScheduleIface,\n type ScheduleRunResultIface,\n type UpdateScheduleRequestIface,\n} from '@finalai/agent-protocol/agent-platform';\nimport { encodePath, type ClientContextIface, type SignalOptionsIface } from \"./context.mjs\";\nimport { clientError, ClientErrorCode } from \"./errors.mjs\";\nimport { HttpMethod } from \"./http.mjs\";\nimport { provideDocumentOf, type ProvideIface } from \"./provide.mjs\";\n\n// An agent's own schedules. Nobody is calling when one fires, so each carries\n// what its runs are provided.\n\nexport type ScheduleRef = { scheduleId: string } | { agent: string; key: string };\n\nexport interface ScheduleUpdateIface extends Omit<UpdateScheduleRequestIface, 'provide'> {\n /** What its runs start with; fails with `requirements_unmet` unless it meets the agent's requirements. */\n provide?: ProvideIface;\n}\n\nexport interface SchedulesApiIface {\n /** `agent` narrows to one agent's schedules, by its id. */\n list: (options?: SignalOptionsIface & { agent?: string }) => Promise<ScheduleIface[]>;\n runNow: (args: ScheduleRef & SignalOptionsIface) => Promise<ScheduleRunResultIface>;\n update: (\n args: { scheduleId: string } & ScheduleUpdateIface & SignalOptionsIface,\n ) => Promise<ScheduleIface>;\n}\n\nexport const createSchedulesApi = ({ http }: ClientContextIface): SchedulesApiIface => {\n const list: SchedulesApiIface['list'] = async (options) =>\n (\n await http.request({\n method: HttpMethod.Get,\n path: '/v1/schedules',\n query: { agent: options?.agent },\n response: scheduleListSchema,\n signal: options?.signal,\n })\n ).schedules;\n\n const scheduleIdOf = async (args: ScheduleRef & SignalOptionsIface): Promise<string> => {\n if ('scheduleId' in args) return args.scheduleId;\n const found = (await list({ agent: args.agent, signal: args.signal })).find(\n (schedule) => schedule.key === args.key,\n );\n if (found == null) {\n throw clientError({\n message: `No schedule ${args.key} on agent ${args.agent}`,\n status: 0,\n code: ClientErrorCode.NotFound,\n });\n }\n return found.id;\n };\n\n return {\n list,\n runNow: async (args) =>\n http.request({\n method: HttpMethod.Post,\n path: `/v1/schedules/${encodePath(await scheduleIdOf(args))}/run-now`,\n response: scheduleRunResultSchema,\n signal: args.signal,\n }),\n update: ({ scheduleId, signal, provide, ...value }) =>\n http.request({\n method: HttpMethod.Patch,\n path: `/v1/schedules/${encodePath(scheduleId)}`,\n body: {\n schema: updateScheduleRequestSchema,\n value: { ...value, ...(provide == null ? {} : { provide: provideDocumentOf(provide) }) },\n },\n response: scheduleSchema,\n signal,\n }),\n };\n};\n"],
5
- "mappings": "AAAA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAIK;AACP,SAAS,kBAAoE;AAC7E,SAAS,aAAa,uBAAuB;AAC7C,SAAS,kBAAkB;AAC3B,SAAS,yBAA4C;AAqB9C,MAAM,qBAAqB,CAAC,EAAE,KAAK,MAA6C;AACrF,QAAM,OAAkC,OAAO,aAE3C,MAAM,KAAK,QAAQ;AAAA,IACjB,QAAQ,WAAW;AAAA,IACnB,MAAM;AAAA,IACN,OAAO,EAAE,OAAO,SAAS,MAAM;AAAA,IAC/B,UAAU;AAAA,IACV,QAAQ,SAAS;AAAA,EACnB,CAAC,GACD;AAEJ,QAAM,eAAe,OAAO,SAA4D;AACtF,QAAI,gBAAgB,KAAM,QAAO,KAAK;AACtC,UAAM,SAAS,MAAM,KAAK,EAAE,OAAO,KAAK,OAAO,QAAQ,KAAK,OAAO,CAAC,GAAG;AAAA,MACrE,CAAC,aAAa,SAAS,QAAQ,KAAK;AAAA,IACtC;AACA,QAAI,SAAS,MAAM;AACjB,YAAM,YAAY;AAAA,QAChB,SAAS,eAAe,KAAK,GAAG,aAAa,KAAK,KAAK;AAAA,QACvD,QAAQ;AAAA,QACR,MAAM,gBAAgB;AAAA,MACxB,CAAC;AAAA,IACH;AACA,WAAO,MAAM;AAAA,EACf;AAEA,SAAO;AAAA,IACL;AAAA,IACA,QAAQ,OAAO,SACb,KAAK,QAAQ;AAAA,MACX,QAAQ,WAAW;AAAA,MACnB,MAAM,iBAAiB,WAAW,MAAM,aAAa,IAAI,CAAC,CAAC;AAAA,MAC3D,UAAU;AAAA,MACV,QAAQ,KAAK;AAAA,IACf,CAAC;AAAA,IACH,QAAQ,CAAC,EAAE,YAAY,QAAQ,SAAS,GAAG,MAAM,MAC/C,KAAK,QAAQ;AAAA,MACX,QAAQ,WAAW;AAAA,MACnB,MAAM,iBAAiB,WAAW,UAAU,CAAC;AAAA,MAC7C,MAAM;AAAA,QACJ,QAAQ;AAAA,QACR,OAAO,EAAE,GAAG,OAAO,GAAI,WAAW,OAAO,CAAC,IAAI,EAAE,SAAS,kBAAkB,OAAO,EAAE,EAAG;AAAA,MACzF;AAAA,MACA,UAAU;AAAA,MACV;AAAA,IACF,CAAC;AAAA,EACL;AACF;",
4
+ "sourcesContent": ["import {\n projectScheduleListSchema,\n type ConversationScheduleIface,\n} from '@finalai/agent-protocol/agent-platform';\nimport { encodePath, type ClientContextIface, type SignalOptionsIface } from \"./context.mjs\";\nimport { HttpMethod } from \"./http.mjs\";\n\n// A project's schedules: the timers in its conversations. Create, change and run them through\n// their conversation (`conversations.get(id).createSchedule`, `.runSchedule`).\n\nexport interface ProjectSchedulesApiIface {\n list: (options?: SignalOptionsIface) => Promise<ConversationScheduleIface[]>;\n}\n\nexport const createProjectSchedulesApi = (args: {\n context: ClientContextIface;\n projectId: string;\n}): ProjectSchedulesApiIface => ({\n list: async (options) =>\n (\n await args.context.http.request({\n method: HttpMethod.Get,\n path: `/v1/projects/${encodePath(args.projectId)}/schedules`,\n response: projectScheduleListSchema,\n signal: options?.signal,\n })\n ).schedules,\n});\n"],
5
+ "mappings": "AAAA;AAAA,EACE;AAAA,OAEK;AACP,SAAS,kBAAoE;AAC7E,SAAS,kBAAkB;AASpB,MAAM,4BAA4B,CAAC,UAGT;AAAA,EAC/B,MAAM,OAAO,aAET,MAAM,KAAK,QAAQ,KAAK,QAAQ;AAAA,IAC9B,QAAQ,WAAW;AAAA,IACnB,MAAM,gBAAgB,WAAW,KAAK,SAAS,CAAC;AAAA,IAChD,UAAU;AAAA,IACV,QAAQ,SAAS;AAAA,EACnB,CAAC,GACD;AACN;",
6
6
  "names": []
7
7
  }
@@ -1,5 +1,5 @@
1
1
  import type { JsonObjectIface, JsonValue } from '@finalai/agent-protocol';
2
- import { type AcpFrameEventIface, type AcpPreviewEventIface, type ActorIface, type AgentSessionIface, type AgentTurnIface, type AgentTurnPolicy, type AttachmentDownloadIface, type ContentInput, type DecisionOutcomeInput, type DecisionRecordIface, type PromptAcceptedIface, type ProvideDocumentViewIface, type RequirementStatusIface, type RespondDecisionResponseIface, type SessionFramesPageIface, type SessionManifestIface, type SessionPlanIface } from '@finalai/agent-protocol/agent-platform';
2
+ import { type AcpFrameEventIface, type AcpLiveTextEventIface, type AcpPreviewEventIface, type ActorIface, type AgentSessionIface, type AgentTurnIface, type AgentTurnPolicy, type AttachmentDownloadIface, type ContentInput, type DecisionOutcomeInput, type DecisionRecordIface, type PromptAcceptedIface, type ProvideDocumentViewIface, type RequirementStatusIface, type RespondDecisionResponseIface, type SessionFramesPageIface, type SessionLiveTextIface, type SessionManifestIface, type SessionPlanIface } from '@finalai/agent-protocol/agent-platform';
3
3
  import type { AgentInput } from "./agent-input.mjs";
4
4
  import { type ClientContextIface, type EnumInput, type SignalOptionsIface } from "./context.mjs";
5
5
  import { type SessionLiveEvent } from "./live-stream.mjs";
@@ -73,6 +73,13 @@ export interface SessionHandleIface {
73
73
  * ahead of the durable frames and the conversation's projected messages.
74
74
  */
75
75
  previews: (options?: SignalOptionsIface) => AsyncIterableIterator<AcpPreviewEventIface>;
76
+ /**
77
+ * The agent's text as it streams, in arrival order: the saved chunks (`acp.preview`) and the
78
+ * model's live text ahead of them (`acp.live_text`). Live only; start from `liveText()`.
79
+ */
80
+ textEvents: (options?: SignalOptionsIface) => AsyncIterableIterator<AcpPreviewEventIface | AcpLiveTextEventIface>;
81
+ /** What each agent message of the session's open turns has streamed so far. */
82
+ liveText: (options?: SignalOptionsIface) => Promise<SessionLiveTextIface>;
76
83
  /** One replay page (`GET /sessions/:id/frames`). */
77
84
  frames: (options: SignalOptionsIface & {
78
85
  fromSeq: number;
@@ -1,5 +1,6 @@
1
1
  import {
2
2
  acpFrameEventSchema,
3
+ acpLiveTextEventSchema,
3
4
  acpPreviewEventSchema,
4
5
  agentRealtimeFrameSchema,
5
6
  AgentRealtimeFrameType,
@@ -19,6 +20,8 @@ import {
19
20
  respondDecisionResponseSchema,
20
21
  respondDecisionSchema,
21
22
  sessionFramesPageSchema,
23
+ sessionLiveTextSchema,
24
+ SessionRealtimeKind,
22
25
  sessionManifestSchema,
23
26
  sessionPlanResponseSchema,
24
27
  sessionRequirementsSchema,
@@ -141,7 +144,7 @@ async function* streamFramesOverHttp(args) {
141
144
  }
142
145
  }
143
146
  }
144
- const streamPreviews = (args) => {
147
+ const streamSessionEvents = (args) => {
145
148
  const topic = agentRealtimeTopics.session(args.sessionId);
146
149
  let unsubscribe = null;
147
150
  let detachAbort = () => {
@@ -167,9 +170,8 @@ const streamPreviews = (args) => {
167
170
  return;
168
171
  }
169
172
  if (frame.data.type !== AgentRealtimeFrameType.Event) return;
170
- if (frame.data.kind !== AgentRealtimeKind.AcpPreview) return;
171
- const preview = acpPreviewEventSchema.safeParse(frame.data.payload);
172
- if (preview.success) queue.push(preview.data);
173
+ const value = args.parse(frame.data.kind, frame.data.payload);
174
+ if (value != null) queue.push(value);
173
175
  };
174
176
  detachAbort = failOnAbort(queue, args.signal);
175
177
  detachClose = failOnAbort(queue, args.context.closeSignal);
@@ -180,6 +182,16 @@ const streamPreviews = (args) => {
180
182
  }
181
183
  return queue.iterator;
182
184
  };
185
+ const parsePreview = (kind, payload) => {
186
+ if (kind !== AgentRealtimeKind.AcpPreview) return null;
187
+ const preview = acpPreviewEventSchema.safeParse(payload);
188
+ return preview.success ? preview.data : null;
189
+ };
190
+ const parseTextEvent = (kind, payload) => {
191
+ if (kind !== SessionRealtimeKind.AcpLiveText) return parsePreview(kind, payload);
192
+ const live = acpLiveTextEventSchema.safeParse(payload);
193
+ return live.success ? live.data : null;
194
+ };
183
195
  const frameSources = (args) => ({
184
196
  replay: (page) => replay({ context: args.context, sessionId: args.sessionId, ...page }),
185
197
  decisions: (signal) => openDecisions({ ...args, signal }),
@@ -293,7 +305,14 @@ const createSessionHandle = (context, sessionId) => {
293
305
  closeSignal: context.closeSignal
294
306
  }),
295
307
  liveEvents: (options) => streamSessionLiveEvents({ context, sessionId, signal: options?.signal }),
296
- previews: (options) => streamPreviews({ context, sessionId, signal: options?.signal }),
308
+ previews: (options) => streamSessionEvents({ context, sessionId, signal: options?.signal, parse: parsePreview }),
309
+ textEvents: (options) => streamSessionEvents({ context, sessionId, signal: options?.signal, parse: parseTextEvent }),
310
+ liveText: (options) => http.request({
311
+ method: HttpMethod.Get,
312
+ path: sessionPath(sessionId, "/live-text"),
313
+ response: sessionLiveTextSchema,
314
+ signal: options?.signal
315
+ }),
297
316
  frames: (options) => replay({ context, sessionId, ...options }),
298
317
  decisions: (options) => openDecisions({ context, sessionId, signal: options?.signal }),
299
318
  turn: (turnId, options) => getTurn({ context, sessionId, turnId, signal: options?.signal }),