@orchestration-ai/sdk 0.1.0 → 0.3.1
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 +280 -207
- package/dist/cjs/app-builder.d.ts +39 -0
- package/dist/cjs/app-builder.d.ts.map +1 -0
- package/dist/cjs/app-builder.js +589 -0
- package/dist/cjs/app-builder.js.map +1 -0
- package/dist/cjs/oauth-utils.d.ts +41 -0
- package/dist/cjs/oauth-utils.d.ts.map +1 -0
- package/dist/cjs/oauth-utils.js +194 -0
- package/dist/cjs/oauth-utils.js.map +1 -0
- package/dist/cjs/services.d.ts +33 -0
- package/dist/cjs/services.d.ts.map +1 -0
- package/dist/cjs/services.js +121 -0
- package/dist/cjs/services.js.map +1 -0
- package/dist/cjs/shared-types.d.ts +66 -0
- package/dist/cjs/shared-types.d.ts.map +1 -0
- package/dist/cjs/shared-types.js +30 -0
- package/dist/cjs/shared-types.js.map +1 -0
- package/dist/cjs/types.gen.d.ts +28 -0
- package/dist/cjs/types.gen.d.ts.map +1 -1
- package/dist/esm/app-builder.d.ts +39 -0
- package/dist/esm/app-builder.d.ts.map +1 -0
- package/dist/esm/app-builder.js +547 -0
- package/dist/esm/app-builder.js.map +1 -0
- package/dist/esm/oauth-utils.d.ts +41 -0
- package/dist/esm/oauth-utils.d.ts.map +1 -0
- package/dist/esm/oauth-utils.js +184 -0
- package/dist/esm/oauth-utils.js.map +1 -0
- package/dist/esm/services.d.ts +33 -0
- package/dist/esm/services.d.ts.map +1 -0
- package/dist/esm/services.js +104 -0
- package/dist/esm/services.js.map +1 -0
- package/dist/esm/shared-types.d.ts +66 -0
- package/dist/esm/shared-types.d.ts.map +1 -0
- package/dist/esm/shared-types.js +25 -0
- package/dist/esm/shared-types.js.map +1 -0
- package/dist/esm/types.gen.d.ts +28 -0
- package/dist/esm/types.gen.d.ts.map +1 -1
- package/package.json +73 -10
- package/dist/cjs/index.d.ts +0 -3
- package/dist/cjs/index.d.ts.map +0 -1
- package/dist/cjs/index.js +0 -72
- package/dist/cjs/index.js.map +0 -1
- package/dist/esm/index.d.ts +0 -3
- package/dist/esm/index.d.ts.map +0 -1
- package/dist/esm/index.js +0 -3
- package/dist/esm/index.js.map +0 -1
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
import { oAuthToken } from './sdk.gen.js';
|
|
2
|
+
const STORAGE_KEY = 'oai_oauth_tokens';
|
|
3
|
+
function isBrowser() {
|
|
4
|
+
return typeof window !== 'undefined' && typeof localStorage !== 'undefined';
|
|
5
|
+
}
|
|
6
|
+
function toTokens(tokenResponse) {
|
|
7
|
+
if (!(tokenResponse === null || tokenResponse === void 0 ? void 0 : tokenResponse.access_token))
|
|
8
|
+
return null;
|
|
9
|
+
return {
|
|
10
|
+
access_token: tokenResponse.access_token,
|
|
11
|
+
refresh_token: tokenResponse.refresh_token,
|
|
12
|
+
token_type: tokenResponse.token_type || 'Bearer',
|
|
13
|
+
expires_in: tokenResponse.expires_in || 3600,
|
|
14
|
+
scope: tokenResponse.scope,
|
|
15
|
+
expires_at: Date.now() + (tokenResponse.expires_in || 3600) * 1000,
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
function isTokenExpired(tokens) {
|
|
19
|
+
return Date.now() >= tokens.expires_at - 30000;
|
|
20
|
+
}
|
|
21
|
+
// --- Browser: token storage ---
|
|
22
|
+
export function saveLogin(tokens) {
|
|
23
|
+
if (isBrowser())
|
|
24
|
+
localStorage.setItem(STORAGE_KEY, JSON.stringify(tokens));
|
|
25
|
+
}
|
|
26
|
+
export function getCurrentLogin() {
|
|
27
|
+
if (!isBrowser())
|
|
28
|
+
return null;
|
|
29
|
+
const raw = localStorage.getItem(STORAGE_KEY);
|
|
30
|
+
if (!raw)
|
|
31
|
+
return null;
|
|
32
|
+
try {
|
|
33
|
+
return JSON.parse(raw);
|
|
34
|
+
}
|
|
35
|
+
catch (_a) {
|
|
36
|
+
return null;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
export function isLoginExpired() {
|
|
40
|
+
const tokens = getCurrentLogin();
|
|
41
|
+
if (!tokens)
|
|
42
|
+
return true;
|
|
43
|
+
return isTokenExpired(tokens);
|
|
44
|
+
}
|
|
45
|
+
export function logout() {
|
|
46
|
+
if (isBrowser())
|
|
47
|
+
localStorage.removeItem(STORAGE_KEY);
|
|
48
|
+
}
|
|
49
|
+
// --- Browser: OAuth redirect flow ---
|
|
50
|
+
export function initiateLogin(baseUrl, config, state) {
|
|
51
|
+
if (!isBrowser())
|
|
52
|
+
throw new Error('initiateLogin can only be used in the browser');
|
|
53
|
+
const params = new URLSearchParams({
|
|
54
|
+
response_type: 'code',
|
|
55
|
+
client_id: config.client_id,
|
|
56
|
+
redirect_uri: config.redirect_uri,
|
|
57
|
+
...(config.scope && { scope: config.scope }),
|
|
58
|
+
...(state && { state }),
|
|
59
|
+
});
|
|
60
|
+
window.location.href = `${baseUrl}/oauth/ui/authorize?${params.toString()}`;
|
|
61
|
+
}
|
|
62
|
+
export function parseLoginRedirect() {
|
|
63
|
+
if (!isBrowser())
|
|
64
|
+
throw new Error('parseLoginRedirect can only be used in the browser');
|
|
65
|
+
const params = new URLSearchParams(window.location.search);
|
|
66
|
+
const error = params.get('error');
|
|
67
|
+
if (error) {
|
|
68
|
+
return {
|
|
69
|
+
granted: false,
|
|
70
|
+
error,
|
|
71
|
+
error_description: params.get('error_description') || '',
|
|
72
|
+
state: params.get('state') || undefined,
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
const code = params.get('code');
|
|
76
|
+
if (!code)
|
|
77
|
+
throw new Error('No code or error found in redirect URL');
|
|
78
|
+
return { granted: true, code, state: params.get('state') || undefined };
|
|
79
|
+
}
|
|
80
|
+
export function setupBrowserAuth(sdkClient, options) {
|
|
81
|
+
if (!isBrowser())
|
|
82
|
+
return;
|
|
83
|
+
let refreshPromise = null;
|
|
84
|
+
async function refresh() {
|
|
85
|
+
if (!(options === null || options === void 0 ? void 0 : options.onRefreshToken))
|
|
86
|
+
return null;
|
|
87
|
+
try {
|
|
88
|
+
const tokens = await options.onRefreshToken();
|
|
89
|
+
if (tokens)
|
|
90
|
+
saveLogin(tokens);
|
|
91
|
+
return tokens;
|
|
92
|
+
}
|
|
93
|
+
catch (_a) {
|
|
94
|
+
return null;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
sdkClient.instance.interceptors.request.use(async (reqConfig) => {
|
|
98
|
+
let tokens = getCurrentLogin();
|
|
99
|
+
if (!tokens)
|
|
100
|
+
return reqConfig;
|
|
101
|
+
if (isTokenExpired(tokens) && (options === null || options === void 0 ? void 0 : options.onRefreshToken)) {
|
|
102
|
+
if (!refreshPromise)
|
|
103
|
+
refreshPromise = refresh().finally(() => { refreshPromise = null; });
|
|
104
|
+
tokens = await refreshPromise;
|
|
105
|
+
if (!tokens)
|
|
106
|
+
return reqConfig;
|
|
107
|
+
}
|
|
108
|
+
if (tokens && !isTokenExpired(tokens)) {
|
|
109
|
+
reqConfig.headers = reqConfig.headers || {};
|
|
110
|
+
reqConfig.headers['Authorization'] = `Bearer ${tokens.access_token}`;
|
|
111
|
+
}
|
|
112
|
+
return reqConfig;
|
|
113
|
+
});
|
|
114
|
+
if (options === null || options === void 0 ? void 0 : options.onRefreshToken) {
|
|
115
|
+
sdkClient.instance.interceptors.response.use(undefined, async (error) => {
|
|
116
|
+
var _a;
|
|
117
|
+
const originalRequest = error.config;
|
|
118
|
+
if (((_a = error.response) === null || _a === void 0 ? void 0 : _a.status) === 401 && !originalRequest._retried) {
|
|
119
|
+
originalRequest._retried = true;
|
|
120
|
+
if (!refreshPromise)
|
|
121
|
+
refreshPromise = refresh().finally(() => { refreshPromise = null; });
|
|
122
|
+
const tokens = await refreshPromise;
|
|
123
|
+
if (tokens) {
|
|
124
|
+
originalRequest.headers['Authorization'] = `Bearer ${tokens.access_token}`;
|
|
125
|
+
return sdkClient.instance(originalRequest);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
return Promise.reject(error);
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
// --- Node.js: client_credentials flow ---
|
|
133
|
+
export function setupClientCredentials(sdkClient, config) {
|
|
134
|
+
let tokens = null;
|
|
135
|
+
let refreshPromise = null;
|
|
136
|
+
async function fetchToken() {
|
|
137
|
+
try {
|
|
138
|
+
const response = await oAuthToken({
|
|
139
|
+
client: sdkClient,
|
|
140
|
+
body: {
|
|
141
|
+
grant_type: 'client_credentials',
|
|
142
|
+
client_id: config.client_id,
|
|
143
|
+
client_secret: config.client_secret,
|
|
144
|
+
...(config.scope && { scope: config.scope }),
|
|
145
|
+
},
|
|
146
|
+
});
|
|
147
|
+
if (response.error)
|
|
148
|
+
return null;
|
|
149
|
+
tokens = toTokens(response.data);
|
|
150
|
+
return tokens;
|
|
151
|
+
}
|
|
152
|
+
catch (_a) {
|
|
153
|
+
return null;
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
sdkClient.instance.interceptors.request.use(async (reqConfig) => {
|
|
157
|
+
if (!tokens || isTokenExpired(tokens)) {
|
|
158
|
+
if (!refreshPromise)
|
|
159
|
+
refreshPromise = fetchToken().finally(() => { refreshPromise = null; });
|
|
160
|
+
tokens = await refreshPromise;
|
|
161
|
+
}
|
|
162
|
+
if (tokens) {
|
|
163
|
+
reqConfig.headers = reqConfig.headers || {};
|
|
164
|
+
reqConfig.headers['Authorization'] = `Bearer ${tokens.access_token}`;
|
|
165
|
+
}
|
|
166
|
+
return reqConfig;
|
|
167
|
+
});
|
|
168
|
+
sdkClient.instance.interceptors.response.use(undefined, async (error) => {
|
|
169
|
+
var _a;
|
|
170
|
+
const originalRequest = error.config;
|
|
171
|
+
if (((_a = error.response) === null || _a === void 0 ? void 0 : _a.status) === 401 && !originalRequest._retried) {
|
|
172
|
+
originalRequest._retried = true;
|
|
173
|
+
if (!refreshPromise)
|
|
174
|
+
refreshPromise = fetchToken().finally(() => { refreshPromise = null; });
|
|
175
|
+
tokens = await refreshPromise;
|
|
176
|
+
if (tokens) {
|
|
177
|
+
originalRequest.headers['Authorization'] = `Bearer ${tokens.access_token}`;
|
|
178
|
+
return sdkClient.instance(originalRequest);
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
return Promise.reject(error);
|
|
182
|
+
});
|
|
183
|
+
}
|
|
184
|
+
//# sourceMappingURL=oauth-utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"oauth-utils.js","sourceRoot":"","sources":["../../typescript/oauth-utils.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAEvC,MAAM,WAAW,GAAG,kBAAkB,CAAC;AAuBvC,SAAS,SAAS;IAChB,OAAO,OAAO,MAAM,KAAK,WAAW,IAAI,OAAO,YAAY,KAAK,WAAW,CAAC;AAC9E,CAAC;AAED,SAAS,QAAQ,CAAC,aAAiC;IACjD,IAAI,CAAC,CAAA,aAAa,aAAb,aAAa,uBAAb,aAAa,CAAE,YAAY,CAAA;QAAE,OAAO,IAAI,CAAC;IAC9C,OAAO;QACL,YAAY,EAAE,aAAa,CAAC,YAAa;QACzC,aAAa,EAAE,aAAa,CAAC,aAAa;QAC1C,UAAU,EAAE,aAAa,CAAC,UAAU,IAAI,QAAQ;QAChD,UAAU,EAAE,aAAa,CAAC,UAAU,IAAI,IAAI;QAC5C,KAAK,EAAE,aAAa,CAAC,KAAK;QAC1B,UAAU,EAAE,IAAI,CAAC,GAAG,EAAE,GAAG,CAAC,aAAa,CAAC,UAAU,IAAI,IAAI,CAAC,GAAG,IAAI;KACnE,CAAC;AACJ,CAAC;AAED,SAAS,cAAc,CAAC,MAAmB;IACzC,OAAO,IAAI,CAAC,GAAG,EAAE,IAAI,MAAM,CAAC,UAAU,GAAG,KAAM,CAAC;AAClD,CAAC;AAED,iCAAiC;AAEjC,MAAM,UAAU,SAAS,CAAC,MAAmB;IAC3C,IAAI,SAAS,EAAE;QAAE,YAAY,CAAC,OAAO,CAAC,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,CAAC,eAAe,CAAC,CAAC;YAC7C,CAAC;QACH,CAAC;QACD,OAAO,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IAC/B,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { Client } from './client';
|
|
2
|
+
import type { Application } from './types.gen';
|
|
3
|
+
import type { Context, Message, Permission, ServiceDescription, ServiceInfo, Setting } from './shared-types';
|
|
4
|
+
export type { AgentIdentity, Context, Message, Permission, PermissionName, ServiceDescription, ServiceDescriptionPart, ServiceInfo, Setting, } from './shared-types';
|
|
5
|
+
export { getBooleanSetting, getTextSetting, getSecretSetting } from './shared-types';
|
|
6
|
+
/** Create a client configured for an application's URL, optionally with a layer ID for context */
|
|
7
|
+
export declare function createApplicationClient(application: Application, layerId?: string): Client;
|
|
8
|
+
/** Create a bare API client (no auth configured). Use with setupClientCredentials. */
|
|
9
|
+
export declare function createApiClient(): Client;
|
|
10
|
+
/** Create a client configured for the engine URL with an access key */
|
|
11
|
+
export declare function createEngineClient(engineUrl: string | null, accessKey: string): Client;
|
|
12
|
+
/** Create a client configured for the production engine with an access key */
|
|
13
|
+
export declare function createEngineClient(accessKey: string): Client;
|
|
14
|
+
/** List all available services */
|
|
15
|
+
export declare function listServices(client: Client): Promise<ServiceInfo[]>;
|
|
16
|
+
/** Get permissions required by the application */
|
|
17
|
+
export declare function getPermissions(client: Client): Promise<Permission[]>;
|
|
18
|
+
/** Get default settings for a service */
|
|
19
|
+
export declare function getDefaultSettings(serviceName: string, client: Client): Promise<Setting[]>;
|
|
20
|
+
/** Get the service description (tools it exposes) */
|
|
21
|
+
export declare function getServiceDescription(serviceName: string, client: Client): Promise<ServiceDescription>;
|
|
22
|
+
/** Touch a service to notify it that its context may have changed */
|
|
23
|
+
export declare function touchService(serviceName: string, client: Client): Promise<void>;
|
|
24
|
+
/** Call a service tool (arbitrary endpoint exposed by a service) */
|
|
25
|
+
export declare function callServiceTool<TBody = unknown, TResponse = unknown>(serviceName: string, toolPath: string, client: Client, options?: {
|
|
26
|
+
method?: "POST" | "GET" | "PATCH" | "DELETE" | "PUT";
|
|
27
|
+
body?: TBody;
|
|
28
|
+
}): Promise<TResponse>;
|
|
29
|
+
/** Get the context for a layer */
|
|
30
|
+
export declare function getContext(layerId: string, client: Client): Promise<Context>;
|
|
31
|
+
/** Send messages to an agent's layer and get the inference response */
|
|
32
|
+
export declare function sendMessages(agentId: string, layerIndex: number, messages: Message[], layerId: string, client: Client): Promise<string>;
|
|
33
|
+
//# sourceMappingURL=services.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"services.d.ts","sourceRoot":"","sources":["../../typescript/services.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAU,MAAM,UAAU,CAAC;AAE/C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,KAAK,EACV,OAAO,EACP,OAAO,EACP,UAAU,EACV,kBAAkB,EAClB,WAAW,EACX,OAAO,EACR,MAAM,gBAAgB,CAAC;AAGxB,YAAY,EACV,aAAa,EACb,OAAO,EACP,OAAO,EACP,UAAU,EACV,cAAc,EACd,kBAAkB,EAClB,sBAAsB,EACtB,WAAW,EACX,OAAO,GACR,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAIrF,kGAAkG;AAClG,wBAAgB,uBAAuB,CAAC,WAAW,EAAE,WAAW,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM,CAO1F;AAED,sFAAsF;AACtF,wBAAgB,eAAe,IAAI,MAAM,CAExC;AAED,uEAAuE;AACvE,wBAAgB,kBAAkB,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM,CAAC;AACxF,8EAA8E;AAC9E,wBAAgB,kBAAkB,CAAC,S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,CAAC,MAAM,CAAC,CAYjB"}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import { createClient, createConfig } from './client/index.js';
|
|
2
|
+
export { getBooleanSetting, getTextSetting, getSecretSetting } from './shared-types.js';
|
|
3
|
+
// --- Client Factories ---
|
|
4
|
+
/** Create a client configured for an application's URL, optionally with a layer ID for context */
|
|
5
|
+
export function createApplicationClient(application, layerId) {
|
|
6
|
+
return createClient(createConfig({
|
|
7
|
+
baseURL: application.application_url,
|
|
8
|
+
headers: {
|
|
9
|
+
...(layerId ? { 'X-LayerId': layerId } : {}),
|
|
10
|
+
},
|
|
11
|
+
}));
|
|
12
|
+
}
|
|
13
|
+
/** Create a bare API client (no auth configured). Use with setupClientCredentials. */
|
|
14
|
+
export function createApiClient() {
|
|
15
|
+
return createClient(createConfig());
|
|
16
|
+
}
|
|
17
|
+
export function createEngineClient(engineUrlOrAccessKey, accessKey) {
|
|
18
|
+
const url = accessKey
|
|
19
|
+
? (engineUrlOrAccessKey !== null && engineUrlOrAccessKey !== void 0 ? engineUrlOrAccessKey : "https://orchestration-ai-online-prod.ey.r.appspot.com")
|
|
20
|
+
: "https://orchestration-ai-online-prod.ey.r.appspot.com";
|
|
21
|
+
const key = accessKey !== null && accessKey !== void 0 ? accessKey : engineUrlOrAccessKey;
|
|
22
|
+
return createClient(createConfig({
|
|
23
|
+
baseURL: url,
|
|
24
|
+
headers: {
|
|
25
|
+
Authorization: `Bearer ${key}`,
|
|
26
|
+
},
|
|
27
|
+
}));
|
|
28
|
+
}
|
|
29
|
+
// --- Application Service Endpoints ---
|
|
30
|
+
/** List all available services */
|
|
31
|
+
export async function listServices(client) {
|
|
32
|
+
const response = await client.get({
|
|
33
|
+
url: '/services',
|
|
34
|
+
responseType: 'json',
|
|
35
|
+
});
|
|
36
|
+
return response.data;
|
|
37
|
+
}
|
|
38
|
+
/** Get permissions required by the application */
|
|
39
|
+
export async function getPermissions(client) {
|
|
40
|
+
const response = await client.get({
|
|
41
|
+
url: '/permissions',
|
|
42
|
+
responseType: 'json',
|
|
43
|
+
});
|
|
44
|
+
return response.data;
|
|
45
|
+
}
|
|
46
|
+
/** Get default settings for a service */
|
|
47
|
+
export async function getDefaultSettings(serviceName, client) {
|
|
48
|
+
const response = await client.get({
|
|
49
|
+
url: `/services/${serviceName}/api/default-settings`,
|
|
50
|
+
responseType: 'json',
|
|
51
|
+
});
|
|
52
|
+
return response.data;
|
|
53
|
+
}
|
|
54
|
+
/** Get the service description (tools it exposes) */
|
|
55
|
+
export async function getServiceDescription(serviceName, client) {
|
|
56
|
+
const response = await client.get({
|
|
57
|
+
url: `/services/${serviceName}/api/description`,
|
|
58
|
+
responseType: 'json',
|
|
59
|
+
});
|
|
60
|
+
return response.data;
|
|
61
|
+
}
|
|
62
|
+
/** Touch a service to notify it that its context may have changed */
|
|
63
|
+
export async function touchService(serviceName, client) {
|
|
64
|
+
await client.post({
|
|
65
|
+
url: `/services/${serviceName}/api/touch`,
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
/** Call a service tool (arbitrary endpoint exposed by a service) */
|
|
69
|
+
export async function callServiceTool(serviceName, toolPath, client, options) {
|
|
70
|
+
var _a;
|
|
71
|
+
const method = ((_a = options === null || options === void 0 ? void 0 : options.method) !== null && _a !== void 0 ? _a : "POST").toLowerCase();
|
|
72
|
+
const response = await client[method]({
|
|
73
|
+
url: `/services/${serviceName}/api/${toolPath}`,
|
|
74
|
+
headers: (options === null || options === void 0 ? void 0 : options.body) ? { 'Content-Type': 'application/json' } : undefined,
|
|
75
|
+
body: options === null || options === void 0 ? void 0 : options.body,
|
|
76
|
+
responseType: 'json',
|
|
77
|
+
});
|
|
78
|
+
return response.data;
|
|
79
|
+
}
|
|
80
|
+
// --- Engine Agent Endpoints ---
|
|
81
|
+
/** Get the context for a layer */
|
|
82
|
+
export async function getContext(layerId, client) {
|
|
83
|
+
const response = await client.get({
|
|
84
|
+
url: `/agents/context/${layerId}`,
|
|
85
|
+
responseType: 'json',
|
|
86
|
+
security: [{ scheme: 'bearer', type: 'http' }],
|
|
87
|
+
});
|
|
88
|
+
return response.data;
|
|
89
|
+
}
|
|
90
|
+
/** Send messages to an agent's layer and get the inference response */
|
|
91
|
+
export async function sendMessages(agentId, layerIndex, messages, layerId, client) {
|
|
92
|
+
const response = await client.post({
|
|
93
|
+
url: `/agents/${agentId}/layers/${layerIndex}/messages`,
|
|
94
|
+
headers: {
|
|
95
|
+
'X-LayerId': layerId,
|
|
96
|
+
'Content-Type': 'application/json',
|
|
97
|
+
},
|
|
98
|
+
body: messages,
|
|
99
|
+
responseType: 'text',
|
|
100
|
+
security: [{ scheme: 'bearer', type: 'http' }],
|
|
101
|
+
});
|
|
102
|
+
return response.data;
|
|
103
|
+
}
|
|
104
|
+
//# sourceMappingURL=services.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"services.js","sourceRoot":"","sources":["../../typescript/services.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAuBtD,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAErF,2BAA2B;AAE3B,kGAAkG;AAClG,MAAM,UAAU,uBAAuB,CAAC,WAAwB,EAAE,OAAgB;IAChF,OAAO,YAAY,CAAC,YAAY,CAAC;QAC/B,OAAO,EAAE,WAAW,CAAC,eAAe;QACpC,OAAO,EAAE;YACP,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,WAAW,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;SAC7C;KACQ,CAAC,CAAC,CAAC;AAChB,CAAC;AAED,sFAAsF;AACtF,MAAM,UAAU,eAAe;IAC7B,OAAO,YAAY,CAAC,YAAY,EAAE,CAAC,CAAC;AACtC,CAAC;AAMD,MAAM,UAAU,kBAAkB,CAAC,oBAAmC,EAAE,SAAkB;IACxF,MAAM,GAAG,GAAG,SAAS;Q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,CAAC,CAAC;IACH,OAAO,QAAQ,CAAC,IAAe,CAAC;AAClC,CAAC;AAED,uEAAuE;AACvE,MAAM,CAAC,KAAK,UAAU,YAAY,CAChC,OAAe,EACf,UAAkB,EAClB,QAAmB,EACnB,OAAe,EACf,MAAc;IAEd,MAAM,QAAQ,GAAG,MAAM,MAAM,CAAC,IAAI,CAAC;QACjC,GAAG,EAAE,WAAW,OAAO,WAAW,UAAU,WAAW;QACvD,OAAO,EAAE;YACP,WAAW,EAAE,OAAO;YACpB,cAAc,EAAE,kBAAkB;SACnC;QACD,IAAI,EAAE,QAAQ;QACd,YAAY,EAAE,MAAM;QACpB,QAAQ,EAAE,CAAC,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;KAC/C,CAAC,CAAC;IACH,OAAO,QAAQ,CAAC,IAAc,CAAC;AACjC,CAAC"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
export type AgentIdentity = {
|
|
2
|
+
agentId: string;
|
|
3
|
+
agentName: string;
|
|
4
|
+
layerId: string;
|
|
5
|
+
layerIndex: number;
|
|
6
|
+
numberOfLayers: number;
|
|
7
|
+
orchestrationId: string;
|
|
8
|
+
workspaceId: string;
|
|
9
|
+
workspaceOwnerId: string;
|
|
10
|
+
};
|
|
11
|
+
export type Setting = {
|
|
12
|
+
setting_name: string;
|
|
13
|
+
setting_description: string;
|
|
14
|
+
setting_type: "Text";
|
|
15
|
+
text_value: string;
|
|
16
|
+
} | {
|
|
17
|
+
setting_name: string;
|
|
18
|
+
setting_description: string;
|
|
19
|
+
setting_type: "Boolean";
|
|
20
|
+
boolean_value: boolean;
|
|
21
|
+
} | {
|
|
22
|
+
setting_name: string;
|
|
23
|
+
setting_description: string;
|
|
24
|
+
setting_type: "Secret";
|
|
25
|
+
text_value: string;
|
|
26
|
+
};
|
|
27
|
+
export type ServiceInfo = {
|
|
28
|
+
unique_name: string;
|
|
29
|
+
service_name: string;
|
|
30
|
+
service_description: string;
|
|
31
|
+
};
|
|
32
|
+
type ServiceDescriptionParameters = Record<string, {
|
|
33
|
+
optional: boolean;
|
|
34
|
+
description: string;
|
|
35
|
+
} & ({
|
|
36
|
+
type: "string" | "boolean" | "number";
|
|
37
|
+
} | {
|
|
38
|
+
type: "enum";
|
|
39
|
+
options: string[];
|
|
40
|
+
} | {
|
|
41
|
+
type: "object";
|
|
42
|
+
properties: ServiceDescriptionParameters;
|
|
43
|
+
})>;
|
|
44
|
+
export type ServiceDescriptionPart = {
|
|
45
|
+
path: string;
|
|
46
|
+
description: string;
|
|
47
|
+
method: "POST" | "GET" | "PATCH" | "DELETE" | "PUT";
|
|
48
|
+
parameters: ServiceDescriptionParameters;
|
|
49
|
+
};
|
|
50
|
+
export type ServiceDescription = ServiceDescriptionPart[];
|
|
51
|
+
export type PermissionName = "role_workspace_inserter" | "role_workspace_reader" | "role_workspace_lister" | "role_workspace_updater" | "role_workspace_deleter" | "role_workspace_writer" | "role_workspace_admin" | "role_orchestration_inserter" | "role_orchestration_reader" | "role_orchestration_lister" | "role_orchestration_updater" | "role_orchestration_deleter" | "role_orchestration_writer" | "role_orchestration_admin" | "role_agent_inserter" | "role_agent_reader" | "role_agent_lister" | "role_agent_updater" | "role_agent_deleter" | "role_agent_writer" | "role_agent_admin" | "role_application_inserter" | "role_application_reader" | "role_application_lister" | "role_application_updater" | "role_application_deleter" | "role_application_writer" | "role_application_admin" | "role_access_inserter" | "role_access_reader" | "role_access_lister" | "role_access_deleter" | "role_access_writer" | "role_access_admin" | "role_llm_keys_inserter" | "role_llm_keys_reader" | "role_llm_keys_lister" | "role_llm_keys_updater" | "role_llm_keys_writer" | "role_llm_keys_admin" | "role_llm_reader" | "role_llm_lister" | "role_service_reader" | "role_service_lister" | "role_day_pass_transaction_lister" | "role_admin";
|
|
52
|
+
export type Permission = {
|
|
53
|
+
permission_name: PermissionName;
|
|
54
|
+
justification: string;
|
|
55
|
+
};
|
|
56
|
+
export type Context = {
|
|
57
|
+
identity: AgentIdentity;
|
|
58
|
+
};
|
|
59
|
+
export type Message = {
|
|
60
|
+
message: string;
|
|
61
|
+
};
|
|
62
|
+
export declare function getBooleanSetting(settings: Setting[], key: string): boolean;
|
|
63
|
+
export declare function getTextSetting(settings: Setting[], key: string): string | undefined;
|
|
64
|
+
export declare function getSecretSetting(settings: Setting[], key: string): string | undefined;
|
|
65
|
+
export {};
|
|
66
|
+
//# sourceMappingURL=shared-types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shared-types.d.ts","sourceRoot":"","sources":["../../typescript/shared-types.ts"],"names":[],"mappings":"AAKA,MAAM,MAAM,aAAa,GAAG;IAC1B,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;IACnB,cAAc,EAAE,MAAM,CAAC;IACvB,eAAe,EAAE,MAAM,CAAC;IACxB,WAAW,EAAE,MAAM,CAAC;IACpB,gBAAgB,EAAE,MAAM,CAAC;CAC1B,CAAC;AAEF,MAAM,MAAM,OAAO,GACf;IAAE,YAAY,EAAE,MAAM,CAAC;IAAC,mBAAmB,EAAE,MAAM,CAAC;IAAC,YAAY,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,MAAM,CAAA;CAAE,GAC/F;IAAE,YAAY,EAAE,MAAM,CAAC;IAAC,mBAAmB,EAAE,MAAM,CAAC;IAAC,YAAY,EAAE,SAAS,CAAC;IAAC,aAAa,EAAE,OAAO,CAAA;CAAE,GACtG;IAAE,YAAY,EAAE,MAAM,CAAC;IAAC,mBAAmB,EAAE,MAAM,CAAC;IAAC,YAAY,EAAE,QAAQ,CAAC;IAAC,UAAU,EAAE,MAAM,CAAA;CAAE,CAAC;AAEtG,MAAM,MAAM,WAAW,GAAG;IACxB,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;IACrB,mBAAmB,EAAE,MAAM,CAAC;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vB,sBAAsB,GACtB,qBAAqB,GACrB,iBAAiB,GACjB,iBAAiB,GACjB,qBAAqB,GACrB,qBAAqB,GACrB,kCAAkC,GAClC,YAAY,CAAC;AAEjB,MAAM,MAAM,UAAU,GAAG;IACvB,eAAe,EAAE,cAAc,CAAC;IAChC,aAAa,EAAE,MAAM,CAAC;CACvB,CAAC;AAEF,MAAM,MAAM,OAAO,GAAG;IACpB,QAAQ,EAAE,aAAa,CAAC;CACzB,CAAC;AAEF,MAAM,MAAM,OAAO,GAAG;IACpB,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAIF,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,OAAO,EAAE,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAM3E;AAED,wBAAgB,cAAc,CAAC,QAAQ,EAAE,OAAO,EAAE,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAMnF;AAED,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,OAAO,EAAE,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAMrF"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
// Shared types and utilities for Orchestration AI services.
|
|
2
|
+
// This module has no external dependencies and can be consumed by any runtime.
|
|
3
|
+
// --- Setting Utilities ---
|
|
4
|
+
export function getBooleanSetting(settings, key) {
|
|
5
|
+
const setting = settings.find((s) => s.setting_name === key);
|
|
6
|
+
if ((setting === null || setting === void 0 ? void 0 : setting.setting_type) === "Boolean") {
|
|
7
|
+
return setting.boolean_value;
|
|
8
|
+
}
|
|
9
|
+
return false;
|
|
10
|
+
}
|
|
11
|
+
export function getTextSetting(settings, key) {
|
|
12
|
+
const setting = settings.find((s) => s.setting_name === key);
|
|
13
|
+
if ((setting === null || setting === void 0 ? void 0 : setting.setting_type) === "Text") {
|
|
14
|
+
return setting.text_value;
|
|
15
|
+
}
|
|
16
|
+
return undefined;
|
|
17
|
+
}
|
|
18
|
+
export function getSecretSetting(settings, key) {
|
|
19
|
+
const setting = settings.find((s) => s.setting_name === key);
|
|
20
|
+
if ((setting === null || setting === void 0 ? void 0 : setting.setting_type) === "Secret") {
|
|
21
|
+
return setting.text_value;
|
|
22
|
+
}
|
|
23
|
+
return undefined;
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=shared-types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shared-types.js","sourceRoot":"","sources":["../../typescript/shared-types.ts"],"names":[],"mappings":"AAAA,4DAA4D;AAC5D,+EAA+E;AA4G/E,4BAA4B;AAE5B,MAAM,UAAU,iBAAiB,CAAC,QAAmB,EAAE,GAAW;IAChE,MAAM,OAAO,GAAG,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,YAAY,KAAK,GAAG,CAAC,CAAC;IAC7D,IAAI,CAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,YAAY,MAAK,SAAS,EAAE,CAAC;QACxC,OAAO,OAAO,CAAC,aAAa,CAAC;IAC/B,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAED,MAAM,UAAU,cAAc,CAAC,QAAmB,EAAE,GAAW;IAC7D,MAAM,OAAO,GAAG,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,YAAY,KAAK,GAAG,CAAC,CAAC;IAC7D,IAAI,CAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,YAAY,MAAK,MAAM,EAAE,CAAC;QACrC,OAAO,OAAO,CAAC,UAAU,CAAC;IAC5B,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC;AAED,MAAM,UAAU,gBAAgB,CAAC,QAAmB,EAAE,GAAW;IAC/D,MAAM,OAAO,GAAG,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,YAAY,KAAK,GAAG,CAAC,CAAC;IAC7D,IAAI,CAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,YAAY,MAAK,QAAQ,EAAE,CAAC;QACvC,OAAO,OAAO,CAAC,UAAU,CAAC;IAC5B,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC"}
|
package/dist/esm/types.gen.d.ts
CHANGED
|
@@ -93,6 +93,10 @@ export type Application = {
|
|
|
93
93
|
private: boolean;
|
|
94
94
|
time_created: string;
|
|
95
95
|
visible: boolean;
|
|
96
|
+
/**
|
|
97
|
+
* Encoded client ID in the format "appId:userId". Use this as client_id for the client_credentials OAuth grant.
|
|
98
|
+
*/
|
|
99
|
+
client_id?: string;
|
|
96
100
|
};
|
|
97
101
|
/**
|
|
98
102
|
* Setting
|
|
@@ -411,6 +415,10 @@ export type NewApplication = {
|
|
|
411
415
|
application_url: string;
|
|
412
416
|
private: boolean;
|
|
413
417
|
visible: boolean;
|
|
418
|
+
/**
|
|
419
|
+
* Encoded client ID in the format "appId:userId". Use this as client_id for the client_credentials OAuth grant.
|
|
420
|
+
*/
|
|
421
|
+
client_id?: string;
|
|
414
422
|
};
|
|
415
423
|
/**
|
|
416
424
|
* ApplicationWithRelations
|
|
@@ -428,6 +436,10 @@ export type ApplicationWithRelations = {
|
|
|
428
436
|
private: boolean;
|
|
429
437
|
time_created: string;
|
|
430
438
|
visible: boolean;
|
|
439
|
+
/**
|
|
440
|
+
* Encoded client ID in the format "appId:userId". Use this as client_id for the client_credentials OAuth grant.
|
|
441
|
+
*/
|
|
442
|
+
client_id?: string;
|
|
431
443
|
};
|
|
432
444
|
/**
|
|
433
445
|
* ApplicationPartialExcluding_id-owner-time_created-last_edited_
|
|
@@ -441,6 +453,10 @@ export type ApplicationPartialExcludingIdOwnerTimeCreatedLastEdited = {
|
|
|
441
453
|
application_url?: string;
|
|
442
454
|
private?: boolean;
|
|
443
455
|
visible?: boolean;
|
|
456
|
+
/**
|
|
457
|
+
* Encoded client ID in the format "appId:userId". Use this as client_id for the client_credentials OAuth grant.
|
|
458
|
+
*/
|
|
459
|
+
client_id?: string;
|
|
444
460
|
};
|
|
445
461
|
/**
|
|
446
462
|
* ApplicationExcluding_access_key_WithRelations
|
|
@@ -457,6 +473,10 @@ export type ApplicationExcludingAccessKeyWithRelations = {
|
|
|
457
473
|
private: boolean;
|
|
458
474
|
time_created: string;
|
|
459
475
|
visible: boolean;
|
|
476
|
+
/**
|
|
477
|
+
* Encoded client ID in the format "appId:userId". Use this as client_id for the client_credentials OAuth grant.
|
|
478
|
+
*/
|
|
479
|
+
client_id?: string;
|
|
460
480
|
};
|
|
461
481
|
/**
|
|
462
482
|
* NewAgent
|
|
@@ -542,6 +562,7 @@ export type AccessFindByPrincipalData = {
|
|
|
542
562
|
path?: never;
|
|
543
563
|
query?: {
|
|
544
564
|
resourceId?: string;
|
|
565
|
+
onBehalfOf?: string;
|
|
545
566
|
limit?: number;
|
|
546
567
|
offset?: number;
|
|
547
568
|
};
|
|
@@ -1626,12 +1647,19 @@ export type OAuthAuthorizeErrors = {
|
|
|
1626
1647
|
export type OAuthAuthorizeError = OAuthAuthorizeErrors[keyof OAuthAuthorizeErrors];
|
|
1627
1648
|
export type OAuthTokenData = {
|
|
1628
1649
|
body?: {
|
|
1650
|
+
/**
|
|
1651
|
+
* One of "authorization_code", "client_credentials", or "refresh_token"
|
|
1652
|
+
*/
|
|
1629
1653
|
grant_type: string;
|
|
1630
1654
|
code?: string;
|
|
1631
1655
|
refresh_token?: string;
|
|
1656
|
+
/**
|
|
1657
|
+
* Plain app ID or encoded "appId:userId". client_credentials grant REQUIRES the encoded format.
|
|
1658
|
+
*/
|
|
1632
1659
|
client_id: string;
|
|
1633
1660
|
client_secret: string;
|
|
1634
1661
|
redirect_uri?: string;
|
|
1662
|
+
scope?: string;
|
|
1635
1663
|
};
|
|
1636
1664
|
path?: never;
|
|
1637
1665
|
query?: never;
|