@agent-os-sdk/client 0.1.1 → 0.2.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/dist/client/AgentOsClient.d.ts +57 -38
- package/dist/client/AgentOsClient.d.ts.map +1 -1
- package/dist/client/AgentOsClient.js +192 -37
- package/dist/client/auth.d.ts +102 -0
- package/dist/client/auth.d.ts.map +1 -0
- package/dist/client/auth.js +44 -0
- package/dist/generated/openapi.d.ts +1009 -204
- package/dist/generated/openapi.d.ts.map +1 -1
- package/dist/index.d.ts +12 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +12 -0
- package/dist/modules/approvals.d.ts +64 -0
- package/dist/modules/approvals.d.ts.map +1 -0
- package/dist/modules/approvals.js +54 -0
- package/dist/modules/artifacts.d.ts +49 -0
- package/dist/modules/artifacts.d.ts.map +1 -0
- package/dist/modules/artifacts.js +50 -0
- package/dist/modules/budgets.d.ts +81 -0
- package/dist/modules/budgets.d.ts.map +1 -0
- package/dist/modules/budgets.js +50 -0
- package/dist/modules/builder.d.ts +23 -3
- package/dist/modules/builder.d.ts.map +1 -1
- package/dist/modules/builder.js +28 -6
- package/dist/modules/capabilities.d.ts +57 -0
- package/dist/modules/capabilities.d.ts.map +1 -0
- package/dist/modules/capabilities.js +50 -0
- package/dist/modules/deployments.d.ts +67 -0
- package/dist/modules/deployments.d.ts.map +1 -0
- package/dist/modules/deployments.js +58 -0
- package/dist/modules/flows.d.ts +84 -0
- package/dist/modules/flows.d.ts.map +1 -0
- package/dist/modules/flows.js +66 -0
- package/dist/modules/handoff.d.ts +91 -0
- package/dist/modules/handoff.d.ts.map +1 -0
- package/dist/modules/handoff.js +65 -0
- package/dist/modules/incidents.d.ts +72 -0
- package/dist/modules/incidents.d.ts.map +1 -0
- package/dist/modules/incidents.js +54 -0
- package/dist/modules/members.d.ts +5 -0
- package/dist/modules/members.d.ts.map +1 -1
- package/dist/modules/members.js +10 -0
- package/dist/modules/policies.d.ts +76 -0
- package/dist/modules/policies.d.ts.map +1 -0
- package/dist/modules/policies.js +46 -0
- package/dist/modules/runs.d.ts +89 -3
- package/dist/modules/runs.d.ts.map +1 -1
- package/dist/modules/runs.js +75 -4
- package/dist/modules/tenants.d.ts +4 -0
- package/dist/modules/tenants.d.ts.map +1 -1
- package/dist/modules/tenants.js +8 -0
- package/package.json +49 -48
- package/src/client/AgentOsClient.ts +217 -61
- package/src/client/auth.ts +148 -0
- package/src/generated/openapi.ts +1009 -204
- package/src/generated/swagger.json +947 -700
- package/src/index.ts +25 -2
- package/src/modules/approvals.ts +109 -0
- package/src/modules/artifacts.ts +83 -0
- package/src/modules/budgets.ts +120 -0
- package/src/modules/builder.ts +26 -4
- package/src/modules/capabilities.ts +95 -0
- package/src/modules/deployments.ts +111 -0
- package/src/modules/flows.ts +133 -0
- package/src/modules/handoff.ts +140 -0
- package/src/modules/incidents.ts +113 -0
- package/src/modules/members.ts +11 -0
- package/src/modules/policies.ts +112 -0
- package/src/modules/runs.ts +123 -5
- package/src/modules/tenants.ts +9 -0
|
@@ -2,24 +2,29 @@
|
|
|
2
2
|
* Agent OS SDK - Main Client
|
|
3
3
|
*
|
|
4
4
|
* Fully typed API client for Agent OS platform.
|
|
5
|
-
*
|
|
5
|
+
* Supports both API Token (server) and JWT (browser) authentication.
|
|
6
6
|
*
|
|
7
7
|
* @example
|
|
8
8
|
* ```ts
|
|
9
|
+
* // API Token (server-to-server)
|
|
9
10
|
* const api = new AgentOsClient({
|
|
10
|
-
* baseUrl: "
|
|
11
|
-
*
|
|
12
|
-
* workspaceId: "...",
|
|
13
|
-
* token: "...",
|
|
11
|
+
* baseUrl: "https://api.agentos.io",
|
|
12
|
+
* auth: { type: "api_token", apiKey: "aosk_live_xxx" }
|
|
14
13
|
* });
|
|
15
14
|
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
15
|
+
* // JWT (browser)
|
|
16
|
+
* const api = new AgentOsClient({
|
|
17
|
+
* baseUrl: "https://api.agentos.io",
|
|
18
|
+
* auth: {
|
|
19
|
+
* type: "jwt",
|
|
20
|
+
* getToken: () => supabase.auth.getSession().then(s => s.data.session?.access_token),
|
|
21
|
+
* getWorkspaceId: () => localStorage.getItem("agentos.workspaceId")!
|
|
22
|
+
* }
|
|
19
23
|
* });
|
|
20
24
|
* ```
|
|
21
25
|
*/
|
|
22
26
|
import { type RawClient } from "./raw.js";
|
|
27
|
+
import { type AgentOsClientOptions, type AgentOsClientOptionsLegacy } from "./auth.js";
|
|
23
28
|
import { AgentsModule } from "../modules/agents.js";
|
|
24
29
|
import { RunsModule } from "../modules/runs.js";
|
|
25
30
|
import { ThreadsModule } from "../modules/threads.js";
|
|
@@ -49,31 +54,26 @@ import { MeModule } from "../modules/me.js";
|
|
|
49
54
|
import { InfoModule } from "../modules/info.js";
|
|
50
55
|
import { MetricsModule } from "../modules/metrics.js";
|
|
51
56
|
import { GraphsModule } from "../modules/graphs.js";
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
/** Custom headers */
|
|
64
|
-
headers?: Record<string, string>;
|
|
65
|
-
/** Kernel base URL (for meta-agent, different from control plane) */
|
|
66
|
-
kernelBaseUrl?: string;
|
|
67
|
-
};
|
|
57
|
+
import { HandoffModule } from "../modules/handoff.js";
|
|
58
|
+
import { FlowsModule } from "../modules/flows.js";
|
|
59
|
+
import { CapabilitiesModule } from "../modules/capabilities.js";
|
|
60
|
+
import { PoliciesModule } from "../modules/policies.js";
|
|
61
|
+
import { ApprovalsModule } from "../modules/approvals.js";
|
|
62
|
+
import { BudgetsModule } from "../modules/budgets.js";
|
|
63
|
+
import { DeploymentsModule } from "../modules/deployments.js";
|
|
64
|
+
import { IncidentsModule } from "../modules/incidents.js";
|
|
65
|
+
import { ArtifactsModule } from "../modules/artifacts.js";
|
|
66
|
+
export type { AgentOsClientOptions, AgentOsClientOptionsLegacy, AuthProvider } from "./auth.js";
|
|
67
|
+
export { isApiTokenAuth, isJwtAuth, isNewAuthOptions } from "./auth.js";
|
|
68
68
|
export declare class AgentOsClient {
|
|
69
69
|
private readonly _client;
|
|
70
70
|
private readonly _baseUrl;
|
|
71
|
-
private readonly
|
|
72
|
-
private readonly
|
|
71
|
+
private readonly _auth;
|
|
72
|
+
private readonly _customHeaders;
|
|
73
|
+
private readonly _tenantId?;
|
|
74
|
+
private readonly _workspaceId?;
|
|
73
75
|
private readonly _token?;
|
|
74
76
|
private readonly _memberId?;
|
|
75
|
-
private readonly _customHeaders;
|
|
76
|
-
private readonly _kernelBaseUrl;
|
|
77
77
|
/** Agents API: CRUD, versions, graph */
|
|
78
78
|
readonly agents: AgentsModule;
|
|
79
79
|
/** Runs API: create, stream, cancel, resume, replay */
|
|
@@ -132,29 +132,48 @@ export declare class AgentOsClient {
|
|
|
132
132
|
readonly metrics: MetricsModule;
|
|
133
133
|
/** Graphs API: Validation and introspection */
|
|
134
134
|
readonly graphs: GraphsModule;
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
135
|
+
readonly handoff: HandoffModule;
|
|
136
|
+
readonly flows: FlowsModule;
|
|
137
|
+
readonly capabilities: CapabilitiesModule;
|
|
138
|
+
readonly policies: PoliciesModule;
|
|
139
|
+
readonly approvals: ApprovalsModule;
|
|
140
|
+
readonly budgets: BudgetsModule;
|
|
141
|
+
readonly deployments: DeploymentsModule;
|
|
142
|
+
readonly incidents: IncidentsModule;
|
|
143
|
+
readonly artifacts: ArtifactsModule;
|
|
139
144
|
readonly experiments: {
|
|
140
145
|
list: EvaluationModule["listExperiments"];
|
|
141
146
|
get: EvaluationModule["getExperiment"];
|
|
142
147
|
create: EvaluationModule["createExperiment"];
|
|
143
148
|
};
|
|
144
|
-
/**
|
|
145
|
-
* Alias for agents.listVersions() - provides first-level access to agent versions
|
|
146
|
-
*/
|
|
147
149
|
readonly agentVersions: {
|
|
148
150
|
list: (agentId: string) => ReturnType<AgentsModule["listVersions"]>;
|
|
149
151
|
get: (agentId: string, versionId: string) => ReturnType<AgentsModule["getVersion"]>;
|
|
150
152
|
create: (agentId: string, body: Parameters<AgentsModule["createVersion"]>[1]) => ReturnType<AgentsModule["createVersion"]>;
|
|
151
153
|
};
|
|
152
|
-
constructor(options: AgentOsClientOptions);
|
|
154
|
+
constructor(options: AgentOsClientOptions | AgentOsClientOptionsLegacy);
|
|
155
|
+
/**
|
|
156
|
+
* Validate auth configuration
|
|
157
|
+
*/
|
|
158
|
+
private _validateAuth;
|
|
159
|
+
/**
|
|
160
|
+
* Get headers for current request (sync version for modules)
|
|
161
|
+
*/
|
|
153
162
|
private _getHeaders;
|
|
154
|
-
/**
|
|
163
|
+
/**
|
|
164
|
+
* Get headers for current request (async version - resolves auth functions)
|
|
165
|
+
*/
|
|
166
|
+
getHeadersAsync(): Promise<Record<string, string>>;
|
|
167
|
+
/**
|
|
168
|
+
* Get workspace ID synchronously (for modules that need it)
|
|
169
|
+
*/
|
|
170
|
+
private _getWorkspaceIdSync;
|
|
171
|
+
/** Current tenant ID (legacy) */
|
|
155
172
|
get tenantId(): string;
|
|
156
|
-
/** Current workspace ID */
|
|
173
|
+
/** Current workspace ID (legacy) */
|
|
157
174
|
get workspaceId(): string;
|
|
175
|
+
/** Auth provider type */
|
|
176
|
+
get authType(): "api_token" | "jwt" | "legacy";
|
|
158
177
|
/** Raw HTTP client (use modules instead) */
|
|
159
178
|
get raw(): RawClient;
|
|
160
179
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AgentOsClient.d.ts","sourceRoot":"","sources":["../../src/client/AgentOsClient.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"AgentOsClient.d.ts","sourceRoot":"","sources":["../../src/client/AgentOsClient.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH,OAAO,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CAAC;KAChD,CAAC;IAEF,QAAQ,CAAC,aAAa,EAAE;QACpB,IAAI,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,UAAU,CAAC,YAAY,CAAC,cAAc,CAAC,CAAC,CAAC;QACpE,GAAG,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,KAAK,UAAU,CAAC,YAAY,CAAC,YAAY,CAAC,CAAC,CAAC;QACpF,MAAM,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,UAAU,CAAC,YAAY,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,UAAU,CAAC,YAAY,CAAC,eAAe,CAAC,CAAC,CAAC;KAC9H,CAAC;gBAEU,OAAO,EAAE,oBAAoB,GAAG,0BAA0B;IAmGtE;;OAEG;IACH,OAAO,CAAC,aAAa;IAarB;;OAEG;IACH,OAAO,CAAC,WAAW;IA0CnB;;OAEG;IACG,eAAe,IAAI,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAmDxD;;OAEG;IACH,OAAO,CAAC,mBAAmB;IAI3B,iCAAiC;IACjC,IAAI,QAAQ,IAAI,MAAM,CAErB;IAED,oCAAoC;IACpC,IAAI,WAAW,IAAI,MAAM,CAExB;IAED,yBAAyB;IACzB,IAAI,QAAQ,IAAI,WAAW,GAAG,KAAK,GAAG,QAAQ,CAG7C;IAED,4CAA4C;IAC5C,IAAI,GAAG,IAAI,SAAS,CAEnB;CACJ"}
|
|
@@ -2,24 +2,29 @@
|
|
|
2
2
|
* Agent OS SDK - Main Client
|
|
3
3
|
*
|
|
4
4
|
* Fully typed API client for Agent OS platform.
|
|
5
|
-
*
|
|
5
|
+
* Supports both API Token (server) and JWT (browser) authentication.
|
|
6
6
|
*
|
|
7
7
|
* @example
|
|
8
8
|
* ```ts
|
|
9
|
+
* // API Token (server-to-server)
|
|
9
10
|
* const api = new AgentOsClient({
|
|
10
|
-
* baseUrl: "
|
|
11
|
-
*
|
|
12
|
-
* workspaceId: "...",
|
|
13
|
-
* token: "...",
|
|
11
|
+
* baseUrl: "https://api.agentos.io",
|
|
12
|
+
* auth: { type: "api_token", apiKey: "aosk_live_xxx" }
|
|
14
13
|
* });
|
|
15
14
|
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
15
|
+
* // JWT (browser)
|
|
16
|
+
* const api = new AgentOsClient({
|
|
17
|
+
* baseUrl: "https://api.agentos.io",
|
|
18
|
+
* auth: {
|
|
19
|
+
* type: "jwt",
|
|
20
|
+
* getToken: () => supabase.auth.getSession().then(s => s.data.session?.access_token),
|
|
21
|
+
* getWorkspaceId: () => localStorage.getItem("agentos.workspaceId")!
|
|
22
|
+
* }
|
|
19
23
|
* });
|
|
20
24
|
* ```
|
|
21
25
|
*/
|
|
22
26
|
import { createRawClient } from "./raw.js";
|
|
27
|
+
import { isNewAuthOptions, isApiTokenAuth, isJwtAuth, isApiToken, isBrowser, } from "./auth.js";
|
|
23
28
|
import { AgentsModule } from "../modules/agents.js";
|
|
24
29
|
import { RunsModule } from "../modules/runs.js";
|
|
25
30
|
import { ThreadsModule } from "../modules/threads.js";
|
|
@@ -50,15 +55,27 @@ import { MeModule } from "../modules/me.js";
|
|
|
50
55
|
import { InfoModule } from "../modules/info.js";
|
|
51
56
|
import { MetricsModule } from "../modules/metrics.js";
|
|
52
57
|
import { GraphsModule } from "../modules/graphs.js";
|
|
58
|
+
// MOCK - Future modules (marked for replacement when backend is ready)
|
|
59
|
+
import { HandoffModule } from "../modules/handoff.js";
|
|
60
|
+
import { FlowsModule } from "../modules/flows.js";
|
|
61
|
+
import { CapabilitiesModule } from "../modules/capabilities.js";
|
|
62
|
+
import { PoliciesModule } from "../modules/policies.js";
|
|
63
|
+
import { ApprovalsModule } from "../modules/approvals.js";
|
|
64
|
+
import { BudgetsModule } from "../modules/budgets.js";
|
|
65
|
+
import { DeploymentsModule } from "../modules/deployments.js";
|
|
66
|
+
import { IncidentsModule } from "../modules/incidents.js";
|
|
67
|
+
import { ArtifactsModule } from "../modules/artifacts.js";
|
|
68
|
+
export { isApiTokenAuth, isJwtAuth, isNewAuthOptions } from "./auth.js";
|
|
53
69
|
export class AgentOsClient {
|
|
54
70
|
_client;
|
|
55
71
|
_baseUrl;
|
|
72
|
+
_auth;
|
|
73
|
+
_customHeaders;
|
|
74
|
+
// Legacy fields (for backwards compat)
|
|
56
75
|
_tenantId;
|
|
57
76
|
_workspaceId;
|
|
58
77
|
_token;
|
|
59
78
|
_memberId;
|
|
60
|
-
_customHeaders;
|
|
61
|
-
_kernelBaseUrl;
|
|
62
79
|
// Core modules
|
|
63
80
|
/** Agents API: CRUD, versions, graph */
|
|
64
81
|
agents;
|
|
@@ -119,31 +136,55 @@ export class AgentOsClient {
|
|
|
119
136
|
metrics;
|
|
120
137
|
/** Graphs API: Validation and introspection */
|
|
121
138
|
graphs;
|
|
122
|
-
//
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
139
|
+
// MOCK - Future modules
|
|
140
|
+
handoff;
|
|
141
|
+
flows;
|
|
142
|
+
capabilities;
|
|
143
|
+
policies;
|
|
144
|
+
approvals;
|
|
145
|
+
budgets;
|
|
146
|
+
deployments;
|
|
147
|
+
incidents;
|
|
148
|
+
artifacts;
|
|
149
|
+
// Convenience Aliases
|
|
127
150
|
experiments;
|
|
128
|
-
/**
|
|
129
|
-
* Alias for agents.listVersions() - provides first-level access to agent versions
|
|
130
|
-
*/
|
|
131
151
|
agentVersions;
|
|
132
152
|
constructor(options) {
|
|
133
153
|
this._baseUrl = options.baseUrl;
|
|
134
|
-
this._kernelBaseUrl = options.kernelBaseUrl ?? options.baseUrl.replace(':5000', ':8001');
|
|
135
|
-
this._tenantId = options.tenantId;
|
|
136
|
-
this._workspaceId = options.workspaceId;
|
|
137
|
-
this._token = options.token;
|
|
138
|
-
this._memberId = options.memberId;
|
|
139
154
|
this._customHeaders = options.headers ?? {};
|
|
155
|
+
// Detect auth mode
|
|
156
|
+
if (isNewAuthOptions(options)) {
|
|
157
|
+
// New auth provider mode
|
|
158
|
+
this._auth = options.auth;
|
|
159
|
+
this._validateAuth(options);
|
|
160
|
+
}
|
|
161
|
+
else {
|
|
162
|
+
// Legacy mode - convert to new auth if possible
|
|
163
|
+
this._tenantId = options.tenantId;
|
|
164
|
+
this._workspaceId = options.workspaceId;
|
|
165
|
+
this._token = options.token;
|
|
166
|
+
this._memberId = options.memberId;
|
|
167
|
+
// Attempt to detect auth type from token
|
|
168
|
+
if (options.token && isApiToken(options.token)) {
|
|
169
|
+
// Token looks like API token - use as api_token
|
|
170
|
+
this._auth = { type: "api_token", apiKey: options.token };
|
|
171
|
+
console.warn("[AgentOS SDK] Using legacy options with API token. " +
|
|
172
|
+
"Consider migrating to: new AgentOsClient({ auth: { type: 'api_token', apiKey: '...' } })");
|
|
173
|
+
}
|
|
174
|
+
else {
|
|
175
|
+
// Legacy JWT mode - keep using headers
|
|
176
|
+
this._auth = null;
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
// Create raw HTTP client
|
|
140
180
|
this._client = createRawClient({
|
|
141
181
|
baseUrl: options.baseUrl,
|
|
142
|
-
headers:
|
|
182
|
+
headers: {}, // Headers resolved dynamically
|
|
143
183
|
});
|
|
184
|
+
// Bound header getter
|
|
144
185
|
const getHeaders = () => this._getHeaders();
|
|
145
|
-
const getWorkspaceId = () => this.
|
|
146
|
-
const getTenantId = () => this._tenantId;
|
|
186
|
+
const getWorkspaceId = () => this._getWorkspaceIdSync();
|
|
187
|
+
const getTenantId = () => this._tenantId ?? "";
|
|
147
188
|
// Initialize core modules
|
|
148
189
|
this.agents = new AgentsModule(this._client, getHeaders);
|
|
149
190
|
this.runs = new RunsModule(this._client, this._baseUrl, getHeaders);
|
|
@@ -152,7 +193,7 @@ export class AgentOsClient {
|
|
|
152
193
|
this.knowledge = new KnowledgeModule(this._client, getWorkspaceId, getHeaders);
|
|
153
194
|
this.triggers = new TriggersModule(this._client, getHeaders);
|
|
154
195
|
this.credentials = new CredentialsModule(this._client, getWorkspaceId, getHeaders);
|
|
155
|
-
this.builder = new BuilderModule(this.
|
|
196
|
+
this.builder = new BuilderModule(this._baseUrl, getHeaders);
|
|
156
197
|
this.members = new MembersModule(this._client, getHeaders);
|
|
157
198
|
this.tenants = new TenantsModule(this._client, getHeaders);
|
|
158
199
|
this.workspaces = new WorkspacesModule(this._client, getTenantId, getHeaders);
|
|
@@ -175,6 +216,16 @@ export class AgentOsClient {
|
|
|
175
216
|
this.info = new InfoModule(this._client, getHeaders);
|
|
176
217
|
this.metrics = new MetricsModule(this._baseUrl, getHeaders);
|
|
177
218
|
this.graphs = new GraphsModule(this._client, getHeaders);
|
|
219
|
+
// MOCK - Initialize future modules
|
|
220
|
+
this.handoff = new HandoffModule(this._client, getHeaders);
|
|
221
|
+
this.flows = new FlowsModule(this._client, getHeaders);
|
|
222
|
+
this.capabilities = new CapabilitiesModule(this._client, getHeaders);
|
|
223
|
+
this.policies = new PoliciesModule(this._client, getHeaders);
|
|
224
|
+
this.approvals = new ApprovalsModule(this._client, getHeaders);
|
|
225
|
+
this.budgets = new BudgetsModule(this._client, getHeaders);
|
|
226
|
+
this.deployments = new DeploymentsModule(this._client, getHeaders);
|
|
227
|
+
this.incidents = new IncidentsModule(this._client, getHeaders);
|
|
228
|
+
this.artifacts = new ArtifactsModule(this._client, getHeaders);
|
|
178
229
|
// Initialize convenience aliases
|
|
179
230
|
this.experiments = {
|
|
180
231
|
list: this.evaluation.listExperiments.bind(this.evaluation),
|
|
@@ -187,28 +238,132 @@ export class AgentOsClient {
|
|
|
187
238
|
create: (agentId, body) => this.agents.createVersion(agentId, body),
|
|
188
239
|
};
|
|
189
240
|
}
|
|
241
|
+
/**
|
|
242
|
+
* Validate auth configuration
|
|
243
|
+
*/
|
|
244
|
+
_validateAuth(options) {
|
|
245
|
+
const { auth, allowApiTokenInBrowser } = options;
|
|
246
|
+
// Browser guard for API tokens
|
|
247
|
+
if (isApiTokenAuth(auth) && isBrowser() && !allowApiTokenInBrowser) {
|
|
248
|
+
throw new Error("[AgentOS SDK] API tokens should not be used in the browser. " +
|
|
249
|
+
"They may be exposed in network requests. " +
|
|
250
|
+
"Use JWT auth for browser clients, or set allowApiTokenInBrowser: true if you understand the risks.");
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
/**
|
|
254
|
+
* Get headers for current request (sync version for modules)
|
|
255
|
+
*/
|
|
190
256
|
_getHeaders() {
|
|
191
257
|
const headers = {
|
|
192
258
|
"Content-Type": "application/json",
|
|
193
|
-
"X-Tenant-Id": this._tenantId,
|
|
194
|
-
"X-Workspace-Id": this._workspaceId,
|
|
195
259
|
...this._customHeaders,
|
|
196
260
|
};
|
|
197
|
-
if (this.
|
|
198
|
-
|
|
261
|
+
if (this._auth) {
|
|
262
|
+
// New auth mode
|
|
263
|
+
if (isApiTokenAuth(this._auth)) {
|
|
264
|
+
// API Token: Only Authorization header
|
|
265
|
+
const apiKey = typeof this._auth.apiKey === "function"
|
|
266
|
+
? "" // Will be resolved async
|
|
267
|
+
: this._auth.apiKey;
|
|
268
|
+
if (apiKey) {
|
|
269
|
+
headers["Authorization"] = `Bearer ${apiKey}`;
|
|
270
|
+
}
|
|
271
|
+
// NO X-Tenant-Id, NO X-Workspace-Id (backend resolves from claims)
|
|
272
|
+
}
|
|
273
|
+
else if (isJwtAuth(this._auth)) {
|
|
274
|
+
// JWT: Authorization + X-Workspace-Id
|
|
275
|
+
// Note: For sync header getter, we use empty strings as placeholders
|
|
276
|
+
// The actual values are resolved in _getHeadersAsync
|
|
277
|
+
// This is a limitation of the current module architecture
|
|
278
|
+
}
|
|
199
279
|
}
|
|
200
|
-
|
|
201
|
-
|
|
280
|
+
else {
|
|
281
|
+
// Legacy mode - use stored values
|
|
282
|
+
if (this._token) {
|
|
283
|
+
headers["Authorization"] = `Bearer ${this._token}`;
|
|
284
|
+
}
|
|
285
|
+
if (this._tenantId) {
|
|
286
|
+
headers["X-Tenant-Id"] = this._tenantId;
|
|
287
|
+
}
|
|
288
|
+
if (this._workspaceId) {
|
|
289
|
+
headers["X-Workspace-Id"] = this._workspaceId;
|
|
290
|
+
}
|
|
291
|
+
if (this._memberId) {
|
|
292
|
+
headers["X-Member-Id"] = this._memberId;
|
|
293
|
+
}
|
|
202
294
|
}
|
|
203
295
|
return headers;
|
|
204
296
|
}
|
|
205
|
-
/**
|
|
297
|
+
/**
|
|
298
|
+
* Get headers for current request (async version - resolves auth functions)
|
|
299
|
+
*/
|
|
300
|
+
async getHeadersAsync() {
|
|
301
|
+
const headers = {
|
|
302
|
+
"Content-Type": "application/json",
|
|
303
|
+
...this._customHeaders,
|
|
304
|
+
};
|
|
305
|
+
if (this._auth) {
|
|
306
|
+
if (isApiTokenAuth(this._auth)) {
|
|
307
|
+
// API Token
|
|
308
|
+
const apiKey = typeof this._auth.apiKey === "function"
|
|
309
|
+
? await this._auth.apiKey()
|
|
310
|
+
: this._auth.apiKey;
|
|
311
|
+
headers["Authorization"] = `Bearer ${apiKey}`;
|
|
312
|
+
// NO X-Tenant-Id, NO X-Workspace-Id
|
|
313
|
+
}
|
|
314
|
+
else if (isJwtAuth(this._auth)) {
|
|
315
|
+
// JWT
|
|
316
|
+
const [token, workspaceId] = await Promise.all([
|
|
317
|
+
this._auth.getToken(),
|
|
318
|
+
this._auth.getWorkspaceId(),
|
|
319
|
+
]);
|
|
320
|
+
if (!token) {
|
|
321
|
+
throw new Error("[AgentOS SDK] JWT token not available. User may not be authenticated.");
|
|
322
|
+
}
|
|
323
|
+
if (!workspaceId) {
|
|
324
|
+
throw new Error("[AgentOS SDK] Workspace ID not available. Please select a workspace first.");
|
|
325
|
+
}
|
|
326
|
+
headers["Authorization"] = `Bearer ${token}`;
|
|
327
|
+
headers["X-Workspace-Id"] = workspaceId;
|
|
328
|
+
// NO X-Tenant-Id (backend derives from workspace membership)
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
else {
|
|
332
|
+
// Legacy mode
|
|
333
|
+
if (this._token) {
|
|
334
|
+
headers["Authorization"] = `Bearer ${this._token}`;
|
|
335
|
+
}
|
|
336
|
+
if (this._tenantId) {
|
|
337
|
+
headers["X-Tenant-Id"] = this._tenantId;
|
|
338
|
+
}
|
|
339
|
+
if (this._workspaceId) {
|
|
340
|
+
headers["X-Workspace-Id"] = this._workspaceId;
|
|
341
|
+
}
|
|
342
|
+
if (this._memberId) {
|
|
343
|
+
headers["X-Member-Id"] = this._memberId;
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
return headers;
|
|
347
|
+
}
|
|
348
|
+
/**
|
|
349
|
+
* Get workspace ID synchronously (for modules that need it)
|
|
350
|
+
*/
|
|
351
|
+
_getWorkspaceIdSync() {
|
|
352
|
+
return this._workspaceId ?? "";
|
|
353
|
+
}
|
|
354
|
+
/** Current tenant ID (legacy) */
|
|
206
355
|
get tenantId() {
|
|
207
|
-
return this._tenantId;
|
|
356
|
+
return this._tenantId ?? "";
|
|
208
357
|
}
|
|
209
|
-
/** Current workspace ID */
|
|
358
|
+
/** Current workspace ID (legacy) */
|
|
210
359
|
get workspaceId() {
|
|
211
|
-
return this._workspaceId;
|
|
360
|
+
return this._workspaceId ?? "";
|
|
361
|
+
}
|
|
362
|
+
/** Auth provider type */
|
|
363
|
+
get authType() {
|
|
364
|
+
if (!this._auth)
|
|
365
|
+
return "legacy";
|
|
366
|
+
return this._auth.type;
|
|
212
367
|
}
|
|
213
368
|
/** Raw HTTP client (use modules instead) */
|
|
214
369
|
get raw() {
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Auth Provider Types for Agent OS SDK
|
|
3
|
+
*
|
|
4
|
+
* Supports two modes:
|
|
5
|
+
* - JWT (browser): Uses Supabase JWT + workspace header
|
|
6
|
+
* - API Token (server): Uses aosk_* token with embedded claims
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* API Token authentication for server-to-server integrations.
|
|
10
|
+
* Token format: aosk_live_* or aosk_test_*
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```ts
|
|
14
|
+
* const client = new AgentOsClient({
|
|
15
|
+
* baseUrl: "https://api.example.com",
|
|
16
|
+
* auth: { type: "api_token", apiKey: "aosk_live_xxx" }
|
|
17
|
+
* })
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
20
|
+
export type ApiTokenAuth = {
|
|
21
|
+
type: "api_token";
|
|
22
|
+
/** API key (aosk_*) or function that returns one */
|
|
23
|
+
apiKey: string | (() => string | Promise<string>);
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* JWT authentication for browser/frontend clients.
|
|
27
|
+
* Uses Supabase JWT with workspace header.
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* ```ts
|
|
31
|
+
* const client = new AgentOsClient({
|
|
32
|
+
* baseUrl: "https://api.example.com",
|
|
33
|
+
* auth: {
|
|
34
|
+
* type: "jwt",
|
|
35
|
+
* getToken: async () => (await supabase.auth.getSession()).data.session?.access_token,
|
|
36
|
+
* getWorkspaceId: () => localStorage.getItem("agentos.workspaceId")!,
|
|
37
|
+
* }
|
|
38
|
+
* })
|
|
39
|
+
* ```
|
|
40
|
+
*/
|
|
41
|
+
export type JwtAuth = {
|
|
42
|
+
type: "jwt";
|
|
43
|
+
/** Function to get the JWT access token */
|
|
44
|
+
getToken: () => string | Promise<string>;
|
|
45
|
+
/** Function to get the current workspace ID */
|
|
46
|
+
getWorkspaceId: () => string | Promise<string>;
|
|
47
|
+
};
|
|
48
|
+
/**
|
|
49
|
+
* Auth provider union type
|
|
50
|
+
*/
|
|
51
|
+
export type AuthProvider = ApiTokenAuth | JwtAuth;
|
|
52
|
+
/**
|
|
53
|
+
* New auth-aware options for AgentOsClient
|
|
54
|
+
*/
|
|
55
|
+
export type AgentOsClientOptions = {
|
|
56
|
+
/** Base URL of the Agent OS Control Plane */
|
|
57
|
+
baseUrl: string;
|
|
58
|
+
/** Authentication provider */
|
|
59
|
+
auth: AuthProvider;
|
|
60
|
+
/**
|
|
61
|
+
* Allow API token in browser environment.
|
|
62
|
+
* Default: false (throws error to prevent accidental exposure)
|
|
63
|
+
*/
|
|
64
|
+
allowApiTokenInBrowser?: boolean;
|
|
65
|
+
/** Custom headers to add to all requests */
|
|
66
|
+
headers?: Record<string, string>;
|
|
67
|
+
};
|
|
68
|
+
/**
|
|
69
|
+
* Legacy options (backwards compatibility)
|
|
70
|
+
* @deprecated Use AgentOsClientOptions with auth provider instead
|
|
71
|
+
*/
|
|
72
|
+
export type AgentOsClientOptionsLegacy = {
|
|
73
|
+
/** Base URL of the Agent OS API */
|
|
74
|
+
baseUrl: string;
|
|
75
|
+
/** Tenant ID @deprecated */
|
|
76
|
+
tenantId: string;
|
|
77
|
+
/** Workspace ID @deprecated */
|
|
78
|
+
workspaceId: string;
|
|
79
|
+
/** Auth token @deprecated */
|
|
80
|
+
token?: string;
|
|
81
|
+
/** Member ID @deprecated */
|
|
82
|
+
memberId?: string;
|
|
83
|
+
/** Custom headers */
|
|
84
|
+
headers?: Record<string, string>;
|
|
85
|
+
};
|
|
86
|
+
export declare function isNewAuthOptions(opts: AgentOsClientOptions | AgentOsClientOptionsLegacy): opts is AgentOsClientOptions;
|
|
87
|
+
export declare function isLegacyOptions(opts: AgentOsClientOptions | AgentOsClientOptionsLegacy): opts is AgentOsClientOptionsLegacy;
|
|
88
|
+
export declare function isApiTokenAuth(auth: AuthProvider): auth is ApiTokenAuth;
|
|
89
|
+
export declare function isJwtAuth(auth: AuthProvider): auth is JwtAuth;
|
|
90
|
+
/**
|
|
91
|
+
* Detect browser environment
|
|
92
|
+
*/
|
|
93
|
+
export declare function isBrowser(): boolean;
|
|
94
|
+
/**
|
|
95
|
+
* Check if token looks like an API token (aosk_*)
|
|
96
|
+
*/
|
|
97
|
+
export declare function isApiToken(token: string): boolean;
|
|
98
|
+
/**
|
|
99
|
+
* Check if token looks like a JWT (three base64 segments)
|
|
100
|
+
*/
|
|
101
|
+
export declare function isJwtToken(token: string): boolean;
|
|
102
|
+
//# sourceMappingURL=auth.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../src/client/auth.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAMH;;;;;;;;;;;GAWG;AACH,MAAM,MAAM,YAAY,GAAG;IACvB,IAAI,EAAE,WAAW,CAAA;IACjB,oDAAoD;IACpD,MAAM,EAAE,MAAM,GAAG,CAAC,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,CAAA;CACpD,CAAA;AAED;;;;;;;;;;;;;;;GAeG;AACH,MAAM,MAAM,OAAO,GAAG;IAClB,IAAI,EAAE,KAAK,CAAA;IACX,2CAA2C;IAC3C,QAAQ,EAAE,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAA;IACxC,+CAA+C;IAC/C,cAAc,EAAE,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAA;CACjD,CAAA;AAED;;GAEG;AACH,MAAM,MAAM,YAAY,GAAG,YAAY,GAAG,OAAO,CAAA;AAMjD;;GAEG;AACH,MAAM,MAAM,oBAAoB,GAAG;IAC/B,6CAA6C;IAC7C,OAAO,EAAE,MAAM,CAAA;IACf,8BAA8B;IAC9B,IAAI,EAAE,YAAY,CAAA;IAClB;;;OAGG;IACH,sBAAsB,CAAC,EAAE,OAAO,CAAA;IAChC,4CAA4C;IAC5C,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CACnC,CAAA;AAED;;;GAGG;AACH,MAAM,MAAM,0BAA0B,GAAG;IACrC,mCAAmC;IACnC,OAAO,EAAE,MAAM,CAAA;IACf,4BAA4B;IAC5B,QAAQ,EAAE,MAAM,CAAA;IAChB,+BAA+B;IAC/B,WAAW,EAAE,MAAM,CAAA;IACnB,6BAA6B;IAC7B,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,4BAA4B;IAC5B,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,qBAAqB;IACrB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CACnC,CAAA;AAMD,wBAAgB,gBAAgB,CAC5B,IAAI,EAAE,oBAAoB,GAAG,0BAA0B,GACxD,IAAI,IAAI,oBAAoB,CAE9B;AAED,wBAAgB,eAAe,CAC3B,IAAI,EAAE,oBAAoB,GAAG,0BAA0B,GACxD,IAAI,IAAI,0BAA0B,CAEpC;AAED,wBAAgB,cAAc,CAAC,IAAI,EAAE,YAAY,GAAG,IAAI,IAAI,YAAY,CAEvE;AAED,wBAAgB,SAAS,CAAC,IAAI,EAAE,YAAY,GAAG,IAAI,IAAI,OAAO,CAE7D;AAMD;;GAEG;AACH,wBAAgB,SAAS,IAAI,OAAO,CAEnC;AAED;;GAEG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAEjD;AAED;;GAEG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAGjD"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Auth Provider Types for Agent OS SDK
|
|
3
|
+
*
|
|
4
|
+
* Supports two modes:
|
|
5
|
+
* - JWT (browser): Uses Supabase JWT + workspace header
|
|
6
|
+
* - API Token (server): Uses aosk_* token with embedded claims
|
|
7
|
+
*/
|
|
8
|
+
// ============================================================================
|
|
9
|
+
// Type Guards
|
|
10
|
+
// ============================================================================
|
|
11
|
+
export function isNewAuthOptions(opts) {
|
|
12
|
+
return "auth" in opts && opts.auth !== undefined;
|
|
13
|
+
}
|
|
14
|
+
export function isLegacyOptions(opts) {
|
|
15
|
+
return "tenantId" in opts || "workspaceId" in opts;
|
|
16
|
+
}
|
|
17
|
+
export function isApiTokenAuth(auth) {
|
|
18
|
+
return auth.type === "api_token";
|
|
19
|
+
}
|
|
20
|
+
export function isJwtAuth(auth) {
|
|
21
|
+
return auth.type === "jwt";
|
|
22
|
+
}
|
|
23
|
+
// ============================================================================
|
|
24
|
+
// Helpers
|
|
25
|
+
// ============================================================================
|
|
26
|
+
/**
|
|
27
|
+
* Detect browser environment
|
|
28
|
+
*/
|
|
29
|
+
export function isBrowser() {
|
|
30
|
+
return typeof window !== "undefined" && typeof document !== "undefined";
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Check if token looks like an API token (aosk_*)
|
|
34
|
+
*/
|
|
35
|
+
export function isApiToken(token) {
|
|
36
|
+
return token.startsWith("aosk_");
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Check if token looks like a JWT (three base64 segments)
|
|
40
|
+
*/
|
|
41
|
+
export function isJwtToken(token) {
|
|
42
|
+
const parts = token.split(".");
|
|
43
|
+
return parts.length === 3 && parts.every(p => p.length > 0);
|
|
44
|
+
}
|