@finalai/agents 0.13.0 → 0.15.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 +7 -1
- package/dist/modules/agent-client/api.d.mts +35 -0
- package/dist/modules/agent-client/api.mjs +110 -0
- package/dist/modules/agent-client/api.mjs.map +7 -0
- package/dist/modules/agent-client/channels.mjs +9 -1
- package/dist/modules/agent-client/channels.mjs.map +2 -2
- package/dist/modules/agent-client/client.d.mts +29 -7
- package/dist/modules/agent-client/client.mjs +15 -12
- package/dist/modules/agent-client/client.mjs.map +2 -2
- package/dist/modules/agent-client/conversations.d.mts +17 -25
- package/dist/modules/agent-client/conversations.mjs +10 -62
- package/dist/modules/agent-client/conversations.mjs.map +2 -2
- package/dist/modules/agent-client/defaults.d.mts +0 -4
- package/dist/modules/agent-client/defaults.mjs +1 -52
- package/dist/modules/agent-client/defaults.mjs.map +2 -2
- package/dist/modules/agent-client/index.d.mts +2 -33
- package/dist/modules/agent-client/index.mjs +3 -109
- package/dist/modules/agent-client/index.mjs.map +2 -2
- package/dist/modules/agent-client/integrations.d.mts +5 -1
- package/dist/modules/agent-client/integrations.mjs +9 -1
- package/dist/modules/agent-client/integrations.mjs.map +2 -2
- package/dist/modules/agent-client/node.d.mts +2 -0
- package/dist/modules/agent-client/node.mjs +62 -0
- package/dist/modules/agent-client/node.mjs.map +7 -0
- package/dist/modules/agent-client/organization.d.mts +83 -0
- package/dist/modules/agent-client/organization.mjs +209 -0
- package/dist/modules/agent-client/organization.mjs.map +7 -0
- package/dist/modules/agent-client/participant-configuration.d.mts +21 -0
- package/dist/modules/agent-client/participant-configuration.mjs +38 -0
- package/dist/modules/agent-client/participant-configuration.mjs.map +7 -0
- package/dist/modules/agent-client/portable.d.mts +3 -0
- package/dist/modules/agent-client/portable.mjs +28 -0
- package/dist/modules/agent-client/portable.mjs.map +7 -0
- package/dist/modules/agent-client/project.d.mts +3 -0
- package/dist/modules/agent-client/project.mjs +3 -1
- package/dist/modules/agent-client/project.mjs.map +2 -2
- package/dist/modules/agent-client/provide.d.mts +0 -1
- package/dist/modules/agent-client/provide.mjs +0 -1
- package/dist/modules/agent-client/provide.mjs.map +2 -2
- package/dist/modules/agent-client/sandboxes.d.mts +8 -1
- package/dist/modules/agent-client/sandboxes.mjs +9 -0
- package/dist/modules/agent-client/sandboxes.mjs.map +2 -2
- package/dist/modules/agent-client/sessions.d.mts +8 -1
- package/dist/modules/agent-client/sessions.mjs +24 -5
- package/dist/modules/agent-client/sessions.mjs.map +2 -2
- package/dist/modules/cli/cli.mjs +2 -1
- package/dist/modules/cli/cli.mjs.map +2 -2
- package/package.json +7 -6
|
@@ -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
|
|
5
|
-
"mappings": "AACA,
|
|
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,33 +1,2 @@
|
|
|
1
|
-
export * from
|
|
2
|
-
export {
|
|
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 { ConversationChannelRoutesApiIface, ConversationContextApiIface, ConversationContextEntryInputIface, ConversationDecisionsApiIface, ConversationInputsApiIface, ConversationLabelsApiIface, ConversationReadGrantsApiIface, ConversationResourcesIface, ResourceSubscriptionsApiIface, SendInputArgsIface, } from "./conversation-resources.mjs";
|
|
12
|
-
export { TURN_OPEN_SESSION_STATES, isNewerMessageVersion, messageVersionOf, type MessageVersionIface, } from "./conversations.mjs";
|
|
13
|
-
export type { ConversationAgentTurnIface, ConversationEvent, ConversationEventMetaIface, ConversationEventsOptionsIface, ConversationHandleIface, ConversationsApiIface, CreateConversationArgsIface, ListMessagesOptionsIface, OpenedConversationIface, ParticipantCreateInput, ParticipantsApiIface, ProjectConversationsApiIface, SandboxFileContentArgsIface, SandboxFileContentRequestIface, SendMessageOptionsIface, SentMessageIface, UploadAttachmentArgsIface, } from "./conversations.mjs";
|
|
14
|
-
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";
|
|
15
|
-
export { EVENTS_POLL_INTERVAL_MS, type EventsApiIface, type EventSubscriptionsApiIface, type ListEventsOptionsIface, type StreamEventsOptionsIface, } from "./events.mjs";
|
|
16
|
-
export { defaultStreamTiming, type StreamTimingIface } from "./frame-stream.mjs";
|
|
17
|
-
export type { AgentClientAuth, FetchIface, HeadersOption } from "./http.mjs";
|
|
18
|
-
export type { AcpAdaptersApiIface, DefinitionSelectorIface, HarnessesApiIface, SubscriptionAllowancesApiIface, } from "./harnesses.mjs";
|
|
19
|
-
export type { IntegrationsApiIface } from "./integrations.mjs";
|
|
20
|
-
export { SessionLiveEventKind, type SessionLiveEvent } from "./live-stream.mjs";
|
|
21
|
-
export type { LocalComputeIface } from "./local-host.mjs";
|
|
22
|
-
export type { OAuthClientsApiIface, SignInReturnOriginsApiIface } from "./oauth-clients.mjs";
|
|
23
|
-
export type { ProjectClientIface } from "./project.mjs";
|
|
24
|
-
export type { AgentSelectorIface, ProjectAgentsApiIface } from "./project-agents.mjs";
|
|
25
|
-
export type { ProjectApiKeysApiIface, ProjectMembersApiIface, ProjectResourceApiIface, ProjectsApiIface, } from "./projects.mjs";
|
|
26
|
-
export type { ProjectPublisherApiIface, PublicNamesApiIface, PublisherHandleIface, PublishersApiIface, } from "./publishers.mjs";
|
|
27
|
-
export { provideDocumentOf, resourceIdOf, type ProvideIface, type ProvidePatchIface, type ResourceRef, type ResourceRefIface, } from "./provide.mjs";
|
|
28
|
-
export { createGatewayRealtimeTransport, type GatewayConnect, type GatewayConnectionIface, type GatewayRealtimeTransportOptionsIface, type RealtimeSubscribeOptionsIface, type RealtimeTransportFrameIface, type RealtimeTransportIface, } from "./realtime.mjs";
|
|
29
|
-
export { SANDBOX_FILE_URI_SCHEME, createSandboxFileUri, parseSandboxFileUri, type SandboxFileTargetIface, } from "./sandbox-uri.mjs";
|
|
30
|
-
export type { SandboxProvidersApiIface } from "./sandbox-providers.mjs";
|
|
31
|
-
export type { CreateSandboxOptionsIface, SandboxEnvironmentValueIface, SandboxHandleIface, SandboxOwnerIface, SandboxSetupRefIface, SandboxSetupsApiIface, SandboxesApiIface, } from "./sandboxes.mjs";
|
|
32
|
-
export type { ProjectSchedulesApiIface } from "./schedules.mjs";
|
|
33
|
-
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 "
|
|
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
|
-
|
|
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
|
|
5
|
-
"mappings": "
|
|
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
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type CompleteSignInResponseIface, type CreateIntegrationRequestIface, type IntegrationIface, type IntegrationListIface, type StartSignInResponseIface } from '@finalai/agent-protocol/agent-platform';
|
|
1
|
+
import { type CompleteSignInResponseIface, type CreateIntegrationRequestIface, type IntegrationIface, type IntegrationListIface, type StartSignInResponseIface, type UpdateIntegrationRequestIface } from '@finalai/agent-protocol/agent-platform';
|
|
2
2
|
import { type ClientContextIface, type SignalOptionsIface } from "./context.mjs";
|
|
3
3
|
export interface IntegrationsApiIface {
|
|
4
4
|
/** Names are unique in a project. Returns the integration; pass it in `provide.integrations`. */
|
|
@@ -12,6 +12,10 @@ export interface IntegrationsApiIface {
|
|
|
12
12
|
cursor?: string;
|
|
13
13
|
limit?: number;
|
|
14
14
|
}) => Promise<IntegrationListIface>;
|
|
15
|
+
/** Changes it in place: the id, and so every `provide` naming it, stays. */
|
|
16
|
+
update: (args: {
|
|
17
|
+
id: string;
|
|
18
|
+
} & UpdateIntegrationRequestIface & SignalOptionsIface) => Promise<IntegrationIface>;
|
|
15
19
|
delete: (args: {
|
|
16
20
|
id: string;
|
|
17
21
|
} & SignalOptionsIface) => Promise<void>;
|
|
@@ -6,7 +6,8 @@ import {
|
|
|
6
6
|
integrationSchema,
|
|
7
7
|
okResponseSchema,
|
|
8
8
|
startSignInRequestSchema,
|
|
9
|
-
startSignInResponseSchema
|
|
9
|
+
startSignInResponseSchema,
|
|
10
|
+
updateIntegrationRequestSchema
|
|
10
11
|
} from "@finalai/agent-protocol/agent-platform";
|
|
11
12
|
import { encodePath } from "./context.mjs";
|
|
12
13
|
import { clientError, ClientErrorCode } from "./errors.mjs";
|
|
@@ -54,6 +55,13 @@ const createIntegrationsApi = (args) => {
|
|
|
54
55
|
response: integrationListSchema,
|
|
55
56
|
signal: options?.signal
|
|
56
57
|
}),
|
|
58
|
+
update: ({ id, signal, ...value }) => http.request({
|
|
59
|
+
method: HttpMethod.Patch,
|
|
60
|
+
path: integrationPath(id),
|
|
61
|
+
body: { schema: updateIntegrationRequestSchema, value },
|
|
62
|
+
response: integrationSchema,
|
|
63
|
+
signal
|
|
64
|
+
}),
|
|
57
65
|
delete: async ({ id, signal }) => {
|
|
58
66
|
await http.request({
|
|
59
67
|
method: HttpMethod.Delete,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../src/agent-client/integrations.ts"],
|
|
4
|
-
"sourcesContent": ["import {\n completeSignInRequestSchema,\n completeSignInResponseSchema,\n createIntegrationRequestSchema,\n integrationListSchema,\n integrationSchema,\n okResponseSchema,\n startSignInRequestSchema,\n startSignInResponseSchema,\n type CompleteSignInResponseIface,\n type CreateIntegrationRequestIface,\n type IntegrationIface,\n type IntegrationListIface,\n type StartSignInResponseIface,\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\";\n\n// Integrations (sources of tools: MCP servers, Final's gateway among them),\n// scoped to one project.\n\nexport interface IntegrationsApiIface {\n /** Names are unique in a project. Returns the integration; pass it in `provide.integrations`. */\n create: (args: CreateIntegrationRequestIface & SignalOptionsIface) => Promise<IntegrationIface>;\n get: (\n selector: ({ name: string } | { id: string }) & SignalOptionsIface,\n ) => Promise<IntegrationIface>;\n list: (\n options?: SignalOptionsIface & { cursor?: string; limit?: number },\n ) => Promise<IntegrationListIface>;\n delete: (args: { id: string } & SignalOptionsIface) => Promise<void>;\n /**\n * Starts the caller's own sign-in: an authorization URL to open. Pass the\n * sign-in decision's id to resolve it when the sign-in completes.\n */\n signIn: (\n args: { id: string; returnUrl?: string; decisionId?: string } & SignalOptionsIface,\n ) => Promise<StartSignInResponseIface>;\n /** Activates a sign-in with the `state` and `code` the provider redirected with. */\n completeSignIn: (\n args: { state: string; code: string } & SignalOptionsIface,\n ) => Promise<CompleteSignInResponseIface>;\n /** Forgets the caller's own sign-in. */\n signOut: (args: { id: string } & SignalOptionsIface) => Promise<void>;\n}\n\nconst projectPath = (projectId: string, suffix: string): string =>\n `/v1/projects/${encodePath(projectId)}${suffix}`;\n\nexport const createIntegrationsApi = (args: {\n context: ClientContextIface;\n projectId: string;\n}): IntegrationsApiIface => {\n const { http } = args.context;\n const integrationPath = (id: string, suffix = '') =>\n projectPath(args.projectId, `/integrations/${encodePath(id)}${suffix}`);\n return {\n create: ({ signal, ...value }) =>\n http.request({\n method: HttpMethod.Post,\n path: projectPath(args.projectId, '/integrations'),\n body: { schema: createIntegrationRequestSchema, value },\n response: integrationSchema,\n signal,\n }),\n get: async ({ signal, ...selector }) => {\n if ('id' in selector)\n return http.request({\n method: HttpMethod.Get,\n path: integrationPath(selector.id),\n response: integrationSchema,\n signal,\n });\n const { integrations } = await http.request({\n method: HttpMethod.Get,\n path: projectPath(args.projectId, '/integrations'),\n query: { name: selector.name },\n response: integrationListSchema,\n signal,\n });\n const found = integrations.find((integration) => integration.name === selector.name);\n if (found == null)\n throw clientError({\n message: `No integration named ${selector.name} in this project`,\n status: 404,\n code: ClientErrorCode.NotFound,\n });\n return found;\n },\n list: (options) =>\n http.request({\n method: HttpMethod.Get,\n path: projectPath(args.projectId, '/integrations'),\n query: { cursor: options?.cursor, limit: options?.limit },\n response: integrationListSchema,\n signal: options?.signal,\n }),\n delete: async ({ id, signal }) => {\n await http.request({\n method: HttpMethod.Delete,\n path: integrationPath(id),\n response: okResponseSchema,\n signal,\n });\n },\n signIn: ({ id, signal, ...value }) =>\n http.request({\n method: HttpMethod.Post,\n path: integrationPath(id, '/sign-in'),\n body: { schema: startSignInRequestSchema, value },\n response: startSignInResponseSchema,\n signal,\n }),\n completeSignIn: ({ signal, ...value }) =>\n http.request({\n method: HttpMethod.Post,\n path: '/v1/sign-ins/complete',\n body: { schema: completeSignInRequestSchema, value },\n response: completeSignInResponseSchema,\n signal,\n }),\n signOut: async ({ id, signal }) => {\n await http.request({\n method: HttpMethod.Delete,\n path: integrationPath(id, '/sign-in'),\n response: okResponseSchema,\n signal,\n });\n },\n };\n};\n"],
|
|
5
|
-
"mappings": "AAAA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,
|
|
4
|
+
"sourcesContent": ["import {\n completeSignInRequestSchema,\n completeSignInResponseSchema,\n createIntegrationRequestSchema,\n integrationListSchema,\n integrationSchema,\n okResponseSchema,\n startSignInRequestSchema,\n startSignInResponseSchema,\n updateIntegrationRequestSchema,\n type CompleteSignInResponseIface,\n type CreateIntegrationRequestIface,\n type IntegrationIface,\n type IntegrationListIface,\n type StartSignInResponseIface,\n type UpdateIntegrationRequestIface,\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\";\n\n// Integrations (sources of tools: MCP servers, Final's gateway among them),\n// scoped to one project.\n\nexport interface IntegrationsApiIface {\n /** Names are unique in a project. Returns the integration; pass it in `provide.integrations`. */\n create: (args: CreateIntegrationRequestIface & SignalOptionsIface) => Promise<IntegrationIface>;\n get: (\n selector: ({ name: string } | { id: string }) & SignalOptionsIface,\n ) => Promise<IntegrationIface>;\n list: (\n options?: SignalOptionsIface & { cursor?: string; limit?: number },\n ) => Promise<IntegrationListIface>;\n /** Changes it in place: the id, and so every `provide` naming it, stays. */\n update: (\n args: { id: string } & UpdateIntegrationRequestIface & SignalOptionsIface,\n ) => Promise<IntegrationIface>;\n delete: (args: { id: string } & SignalOptionsIface) => Promise<void>;\n /**\n * Starts the caller's own sign-in: an authorization URL to open. Pass the\n * sign-in decision's id to resolve it when the sign-in completes.\n */\n signIn: (\n args: { id: string; returnUrl?: string; decisionId?: string } & SignalOptionsIface,\n ) => Promise<StartSignInResponseIface>;\n /** Activates a sign-in with the `state` and `code` the provider redirected with. */\n completeSignIn: (\n args: { state: string; code: string } & SignalOptionsIface,\n ) => Promise<CompleteSignInResponseIface>;\n /** Forgets the caller's own sign-in. */\n signOut: (args: { id: string } & SignalOptionsIface) => Promise<void>;\n}\n\nconst projectPath = (projectId: string, suffix: string): string =>\n `/v1/projects/${encodePath(projectId)}${suffix}`;\n\nexport const createIntegrationsApi = (args: {\n context: ClientContextIface;\n projectId: string;\n}): IntegrationsApiIface => {\n const { http } = args.context;\n const integrationPath = (id: string, suffix = '') =>\n projectPath(args.projectId, `/integrations/${encodePath(id)}${suffix}`);\n return {\n create: ({ signal, ...value }) =>\n http.request({\n method: HttpMethod.Post,\n path: projectPath(args.projectId, '/integrations'),\n body: { schema: createIntegrationRequestSchema, value },\n response: integrationSchema,\n signal,\n }),\n get: async ({ signal, ...selector }) => {\n if ('id' in selector)\n return http.request({\n method: HttpMethod.Get,\n path: integrationPath(selector.id),\n response: integrationSchema,\n signal,\n });\n const { integrations } = await http.request({\n method: HttpMethod.Get,\n path: projectPath(args.projectId, '/integrations'),\n query: { name: selector.name },\n response: integrationListSchema,\n signal,\n });\n const found = integrations.find((integration) => integration.name === selector.name);\n if (found == null)\n throw clientError({\n message: `No integration named ${selector.name} in this project`,\n status: 404,\n code: ClientErrorCode.NotFound,\n });\n return found;\n },\n list: (options) =>\n http.request({\n method: HttpMethod.Get,\n path: projectPath(args.projectId, '/integrations'),\n query: { cursor: options?.cursor, limit: options?.limit },\n response: integrationListSchema,\n signal: options?.signal,\n }),\n update: ({ id, signal, ...value }) =>\n http.request({\n method: HttpMethod.Patch,\n path: integrationPath(id),\n body: { schema: updateIntegrationRequestSchema, value },\n response: integrationSchema,\n signal,\n }),\n delete: async ({ id, signal }) => {\n await http.request({\n method: HttpMethod.Delete,\n path: integrationPath(id),\n response: okResponseSchema,\n signal,\n });\n },\n signIn: ({ id, signal, ...value }) =>\n http.request({\n method: HttpMethod.Post,\n path: integrationPath(id, '/sign-in'),\n body: { schema: startSignInRequestSchema, value },\n response: startSignInResponseSchema,\n signal,\n }),\n completeSignIn: ({ signal, ...value }) =>\n http.request({\n method: HttpMethod.Post,\n path: '/v1/sign-ins/complete',\n body: { schema: completeSignInRequestSchema, value },\n response: completeSignInResponseSchema,\n signal,\n }),\n signOut: async ({ id, signal }) => {\n await http.request({\n method: HttpMethod.Delete,\n path: integrationPath(id, '/sign-in'),\n response: okResponseSchema,\n signal,\n });\n },\n };\n};\n"],
|
|
5
|
+
"mappings": "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",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -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(nodeRuntime, options);\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,4BAA4B;AACrC,SAAS,iCAAiC;AAC1C;AAAA,EACE;AAAA,OAIK;AAEP,SAAS,8BAA8B;AAQvC,MAAM,mBAAmB,OAA0B;AAAA,EACjD,SAAS,YAAY;AACnB,UAAM,EAAE,mBAAmB,IAAI,MAAM,OAAO,+CAA+C;AAC3F,WAAO,mBAAmB,EAAE,MAAM,WAAW,QAAQ,IAAI,EAAE,CAAC;AAAA,EAC9D;AAAA,EACA,aAAa,CAAC,aACZ,qBAAqB;AAAA,IACnB,KAAK,SAAS;AAAA,IACd,OAAO,SAAS;AAAA,IAChB,WAAW,SAAS;AAAA,EACtB,CAAC;AACL;AAMA,MAAM,oBACJ,CAAC,SACD,OAAO,MAAc,WAAwD;AAC3E,QAAM,MAAM,KAAK,IAAI,IAAI;AACzB,MAAI,WAAW,IAAI,aAAa,UAAU,QAAQ;AAClD,QAAM,UAAU,MAAM,KAAK,QAAQ;AACnC,QAAM,EAAE,UAAU,IAAI,MAAM,OAAO,IAAI;AACvC,UAAQ,eAAe;AACvB,QAAM,SAAS,IAAI,UAAU,KAAK,CAAC,sBAAsB,GAAG,EAAE,QAAQ,CAAC;AACvE,MAAI,MAA2D;AAC/D,MAAI,aAAa;AACjB,SAAO,GAAG,WAAW,CAAC,aAAa;AACjC,UAAM,SAAS;AACf,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;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,83 @@
|
|
|
1
|
+
import { type AddAllowedEndpointRequestIface, type AllowedEndpointIface, type BudgetIface, type ChatGptSubscriptionChallengeIface, type ChatGptSubscriptionPollIface, type ConnectApiKeyRequestIface, type ConnectClaudeSubscriptionRequestIface, type CreateBudgetRequestIface, type CreateModelCredentialGrantRequestIface, type ModelCredentialGrantIface, type ModelCredentialIface, type OrganizationAgentPolicyIface, type PlatformSpendingRestrictionsIface, type StartChatGptSubscriptionRequestIface, type UpdateModelCredentialRequestIface, type UpdateOrganizationAgentPolicyRequestIface, type UpdatePlatformSpendingRestrictionsRequestIface } from '@finalai/agent-protocol/agent-platform';
|
|
2
|
+
import { type ClientContextIface, type SignalOptionsIface } from "./context.mjs";
|
|
3
|
+
export interface ModelCredentialGrantsApiIface {
|
|
4
|
+
list: (args: {
|
|
5
|
+
credentialId: string;
|
|
6
|
+
} & SignalOptionsIface) => Promise<ModelCredentialGrantIface[]>;
|
|
7
|
+
/** Shares the credential with a project or a member; idempotent per grantee. */
|
|
8
|
+
create: (args: {
|
|
9
|
+
credentialId: string;
|
|
10
|
+
} & CreateModelCredentialGrantRequestIface & SignalOptionsIface) => Promise<ModelCredentialGrantIface>;
|
|
11
|
+
revoke: (args: {
|
|
12
|
+
credentialId: string;
|
|
13
|
+
grantId: string;
|
|
14
|
+
} & SignalOptionsIface) => Promise<void>;
|
|
15
|
+
}
|
|
16
|
+
/** The subscriptions and API keys the caller's projects run models with. */
|
|
17
|
+
export interface ModelCredentialsApiIface {
|
|
18
|
+
/** The caller's credentials; with `projectId`, that project's and those it inherits. */
|
|
19
|
+
list: (options?: {
|
|
20
|
+
projectId?: string;
|
|
21
|
+
} & SignalOptionsIface) => Promise<ModelCredentialIface[]>;
|
|
22
|
+
connectApiKey: (args: ConnectApiKeyRequestIface & SignalOptionsIface) => Promise<ModelCredentialIface>;
|
|
23
|
+
connectClaudeSubscription: (args: ConnectClaudeSubscriptionRequestIface & SignalOptionsIface) => Promise<ModelCredentialIface>;
|
|
24
|
+
/** Starts a device-code sign-in; poll it with the returned `state`. */
|
|
25
|
+
startChatGptSubscription: (args: StartChatGptSubscriptionRequestIface & SignalOptionsIface) => Promise<ChatGptSubscriptionChallengeIface>;
|
|
26
|
+
pollChatGptSubscription: (args: {
|
|
27
|
+
state: string;
|
|
28
|
+
} & SignalOptionsIface) => Promise<ChatGptSubscriptionPollIface>;
|
|
29
|
+
/** The owner's settings (an editor of the credential's project). */
|
|
30
|
+
update: (args: {
|
|
31
|
+
credentialId: string;
|
|
32
|
+
} & UpdateModelCredentialRequestIface & SignalOptionsIface) => Promise<ModelCredentialIface>;
|
|
33
|
+
/** Clears a subscription's remembered limit after the vendor reset it. */
|
|
34
|
+
resetUsage: (args: {
|
|
35
|
+
credentialId: string;
|
|
36
|
+
} & SignalOptionsIface) => Promise<ModelCredentialIface>;
|
|
37
|
+
disconnect: (args: {
|
|
38
|
+
credentialId: string;
|
|
39
|
+
} & SignalOptionsIface) => Promise<void>;
|
|
40
|
+
/** Who else may use a credential (its managers only). */
|
|
41
|
+
grants: ModelCredentialGrantsApiIface;
|
|
42
|
+
}
|
|
43
|
+
/** Spend limits; organization admins write them. */
|
|
44
|
+
export interface BudgetsApiIface {
|
|
45
|
+
list: (options?: SignalOptionsIface) => Promise<BudgetIface[]>;
|
|
46
|
+
create: (args: CreateBudgetRequestIface & SignalOptionsIface) => Promise<BudgetIface>;
|
|
47
|
+
update: (args: {
|
|
48
|
+
budgetId: string;
|
|
49
|
+
} & CreateBudgetRequestIface & SignalOptionsIface) => Promise<BudgetIface>;
|
|
50
|
+
delete: (args: {
|
|
51
|
+
budgetId: string;
|
|
52
|
+
} & SignalOptionsIface) => Promise<void>;
|
|
53
|
+
}
|
|
54
|
+
/** The organization's provider gates and turn limits; organization admins update it. */
|
|
55
|
+
export interface OrganizationPolicyApiIface {
|
|
56
|
+
get: (options?: SignalOptionsIface) => Promise<OrganizationAgentPolicyIface>;
|
|
57
|
+
update: (args: UpdateOrganizationAgentPolicyRequestIface & SignalOptionsIface) => Promise<OrganizationAgentPolicyIface>;
|
|
58
|
+
}
|
|
59
|
+
/** Who may spend the platform's own metered inference; organization admins update it. */
|
|
60
|
+
export interface SpendingRestrictionsApiIface {
|
|
61
|
+
get: (options?: SignalOptionsIface) => Promise<PlatformSpendingRestrictionsIface>;
|
|
62
|
+
update: (args: UpdatePlatformSpendingRestrictionsRequestIface & SignalOptionsIface) => Promise<PlatformSpendingRestrictionsIface>;
|
|
63
|
+
}
|
|
64
|
+
/** The caller's organization: model credentials, budgets and policies. */
|
|
65
|
+
export interface OrganizationApiIface {
|
|
66
|
+
modelCredentials: ModelCredentialsApiIface;
|
|
67
|
+
budgets: BudgetsApiIface;
|
|
68
|
+
policy: OrganizationPolicyApiIface;
|
|
69
|
+
spendingRestrictions: SpendingRestrictionsApiIface;
|
|
70
|
+
}
|
|
71
|
+
/** Where a project lets its secrets go beyond model vendors' own APIs; its admins change it. */
|
|
72
|
+
export interface AllowedEndpointsApiIface {
|
|
73
|
+
list: (options?: SignalOptionsIface) => Promise<AllowedEndpointIface[]>;
|
|
74
|
+
add: (args: AddAllowedEndpointRequestIface & SignalOptionsIface) => Promise<AllowedEndpointIface>;
|
|
75
|
+
remove: (args: {
|
|
76
|
+
endpointId: string;
|
|
77
|
+
} & SignalOptionsIface) => Promise<void>;
|
|
78
|
+
}
|
|
79
|
+
export declare const createOrganizationApi: (context: ClientContextIface) => OrganizationApiIface;
|
|
80
|
+
export declare const createAllowedEndpointsApi: (args: {
|
|
81
|
+
context: ClientContextIface;
|
|
82
|
+
projectId: string;
|
|
83
|
+
}) => AllowedEndpointsApiIface;
|