@agent-os-sdk/client 0.9.24 → 0.9.26
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/package.json +15 -8
- package/src/generated/openapi.ts +90 -0
- package/src/generated/swagger.json +181 -0
- package/src/modules/runs.ts +64 -0
- package/src/modules/templates.ts +35 -0
- package/dist/client/AgentOsClient.d.ts +0 -141
- package/dist/client/AgentOsClient.d.ts.map +0 -1
- package/dist/client/AgentOsClient.js +0 -250
- package/dist/client/HttpRequestBuilder.d.ts +0 -50
- package/dist/client/HttpRequestBuilder.d.ts.map +0 -1
- package/dist/client/HttpRequestBuilder.js +0 -83
- package/dist/client/OperationContext.d.ts +0 -19
- package/dist/client/OperationContext.d.ts.map +0 -1
- package/dist/client/OperationContext.js +0 -13
- package/dist/client/OperationContextProvider.d.ts +0 -54
- package/dist/client/OperationContextProvider.d.ts.map +0 -1
- package/dist/client/OperationContextProvider.js +0 -71
- package/dist/client/auth.d.ts +0 -100
- package/dist/client/auth.d.ts.map +0 -1
- package/dist/client/auth.js +0 -38
- package/dist/client/config.d.ts +0 -49
- package/dist/client/config.d.ts.map +0 -1
- package/dist/client/config.js +0 -62
- package/dist/client/helpers.d.ts +0 -63
- package/dist/client/helpers.d.ts.map +0 -1
- package/dist/client/helpers.js +0 -55
- package/dist/client/pagination.d.ts +0 -105
- package/dist/client/pagination.d.ts.map +0 -1
- package/dist/client/pagination.js +0 -117
- package/dist/client/raw.d.ts +0 -277
- package/dist/client/raw.d.ts.map +0 -1
- package/dist/client/raw.js +0 -337
- package/dist/client/retry.d.ts +0 -37
- package/dist/client/retry.d.ts.map +0 -1
- package/dist/client/retry.js +0 -108
- package/dist/client/sanitize.d.ts +0 -19
- package/dist/client/sanitize.d.ts.map +0 -1
- package/dist/client/sanitize.js +0 -28
- package/dist/client/timeout.d.ts +0 -26
- package/dist/client/timeout.d.ts.map +0 -1
- package/dist/client/timeout.js +0 -51
- package/dist/errors/factory.d.ts +0 -22
- package/dist/errors/factory.d.ts.map +0 -1
- package/dist/errors/factory.js +0 -101
- package/dist/errors/index.d.ts +0 -210
- package/dist/errors/index.d.ts.map +0 -1
- package/dist/errors/index.js +0 -283
- package/dist/generated/client.d.ts +0 -20
- package/dist/generated/client.d.ts.map +0 -1
- package/dist/generated/client.js +0 -15
- package/dist/generated/index.d.ts +0 -2
- package/dist/generated/index.d.ts.map +0 -1
- package/dist/generated/index.js +0 -1
- package/dist/generated/openapi.d.ts +0 -12294
- package/dist/generated/openapi.d.ts.map +0 -1
- package/dist/generated/openapi.js +0 -5
- package/dist/index.d.ts +0 -69
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -81
- package/dist/modules/a2a.d.ts +0 -48
- package/dist/modules/a2a.d.ts.map +0 -1
- package/dist/modules/a2a.js +0 -37
- package/dist/modules/agents.d.ts +0 -346
- package/dist/modules/agents.d.ts.map +0 -1
- package/dist/modules/agents.js +0 -296
- package/dist/modules/apiTokens.d.ts +0 -62
- package/dist/modules/apiTokens.d.ts.map +0 -1
- package/dist/modules/apiTokens.js +0 -56
- package/dist/modules/approvals.d.ts +0 -75
- package/dist/modules/approvals.d.ts.map +0 -1
- package/dist/modules/approvals.js +0 -91
- package/dist/modules/audit.d.ts +0 -78
- package/dist/modules/audit.d.ts.map +0 -1
- package/dist/modules/audit.js +0 -94
- package/dist/modules/auth.d.ts +0 -28
- package/dist/modules/auth.d.ts.map +0 -1
- package/dist/modules/auth.js +0 -22
- package/dist/modules/builder.d.ts +0 -242
- package/dist/modules/builder.d.ts.map +0 -1
- package/dist/modules/builder.js +0 -248
- package/dist/modules/catalog.d.ts +0 -142
- package/dist/modules/catalog.d.ts.map +0 -1
- package/dist/modules/catalog.js +0 -136
- package/dist/modules/chatwoot.d.ts +0 -59
- package/dist/modules/chatwoot.d.ts.map +0 -1
- package/dist/modules/chatwoot.js +0 -200
- package/dist/modules/checkpoints.d.ts +0 -62
- package/dist/modules/checkpoints.d.ts.map +0 -1
- package/dist/modules/checkpoints.js +0 -48
- package/dist/modules/contracts.d.ts +0 -48
- package/dist/modules/contracts.d.ts.map +0 -1
- package/dist/modules/contracts.js +0 -25
- package/dist/modules/credentials.d.ts +0 -105
- package/dist/modules/credentials.d.ts.map +0 -1
- package/dist/modules/credentials.js +0 -135
- package/dist/modules/crons.d.ts +0 -73
- package/dist/modules/crons.d.ts.map +0 -1
- package/dist/modules/crons.js +0 -67
- package/dist/modules/datasets.d.ts +0 -80
- package/dist/modules/datasets.d.ts.map +0 -1
- package/dist/modules/datasets.js +0 -91
- package/dist/modules/evaluation.d.ts +0 -183
- package/dist/modules/evaluation.d.ts.map +0 -1
- package/dist/modules/evaluation.js +0 -108
- package/dist/modules/files.d.ts +0 -89
- package/dist/modules/files.d.ts.map +0 -1
- package/dist/modules/files.js +0 -133
- package/dist/modules/graphs.d.ts +0 -120
- package/dist/modules/graphs.d.ts.map +0 -1
- package/dist/modules/graphs.js +0 -69
- package/dist/modules/improvements.d.ts +0 -52
- package/dist/modules/improvements.d.ts.map +0 -1
- package/dist/modules/improvements.js +0 -27
- package/dist/modules/info.d.ts +0 -76
- package/dist/modules/info.d.ts.map +0 -1
- package/dist/modules/info.js +0 -93
- package/dist/modules/knowledge.d.ts +0 -91
- package/dist/modules/knowledge.d.ts.map +0 -1
- package/dist/modules/knowledge.js +0 -80
- package/dist/modules/me.d.ts +0 -58
- package/dist/modules/me.d.ts.map +0 -1
- package/dist/modules/me.js +0 -28
- package/dist/modules/members.d.ts +0 -124
- package/dist/modules/members.d.ts.map +0 -1
- package/dist/modules/members.js +0 -142
- package/dist/modules/memberships.d.ts +0 -25
- package/dist/modules/memberships.d.ts.map +0 -1
- package/dist/modules/memberships.js +0 -20
- package/dist/modules/metaAgent.d.ts +0 -95
- package/dist/modules/metaAgent.d.ts.map +0 -1
- package/dist/modules/metaAgent.js +0 -32
- package/dist/modules/metrics.d.ts +0 -20
- package/dist/modules/metrics.d.ts.map +0 -1
- package/dist/modules/metrics.js +0 -27
- package/dist/modules/observability.d.ts +0 -19
- package/dist/modules/observability.d.ts.map +0 -1
- package/dist/modules/observability.js +0 -14
- package/dist/modules/playground.d.ts +0 -42
- package/dist/modules/playground.d.ts.map +0 -1
- package/dist/modules/playground.js +0 -48
- package/dist/modules/presets.d.ts +0 -32
- package/dist/modules/presets.d.ts.map +0 -1
- package/dist/modules/presets.js +0 -199
- package/dist/modules/prompts.d.ts +0 -87
- package/dist/modules/prompts.d.ts.map +0 -1
- package/dist/modules/prompts.js +0 -87
- package/dist/modules/roles.d.ts +0 -64
- package/dist/modules/roles.d.ts.map +0 -1
- package/dist/modules/roles.js +0 -79
- package/dist/modules/runs.d.ts +0 -400
- package/dist/modules/runs.d.ts.map +0 -1
- package/dist/modules/runs.js +0 -526
- package/dist/modules/store.d.ts +0 -37
- package/dist/modules/store.d.ts.map +0 -1
- package/dist/modules/store.js +0 -48
- package/dist/modules/templates.d.ts +0 -28
- package/dist/modules/templates.d.ts.map +0 -1
- package/dist/modules/templates.js +0 -19
- package/dist/modules/tenants.d.ts +0 -49
- package/dist/modules/tenants.d.ts.map +0 -1
- package/dist/modules/tenants.js +0 -56
- package/dist/modules/threads.d.ts +0 -205
- package/dist/modules/threads.d.ts.map +0 -1
- package/dist/modules/threads.js +0 -225
- package/dist/modules/tools.d.ts +0 -62
- package/dist/modules/tools.d.ts.map +0 -1
- package/dist/modules/tools.js +0 -45
- package/dist/modules/traces.d.ts +0 -89
- package/dist/modules/traces.d.ts.map +0 -1
- package/dist/modules/traces.js +0 -65
- package/dist/modules/triggers.d.ts +0 -228
- package/dist/modules/triggers.d.ts.map +0 -1
- package/dist/modules/triggers.js +0 -176
- package/dist/modules/usage.d.ts +0 -85
- package/dist/modules/usage.d.ts.map +0 -1
- package/dist/modules/usage.js +0 -43
- package/dist/modules/vectorStores.d.ts +0 -100
- package/dist/modules/vectorStores.d.ts.map +0 -1
- package/dist/modules/vectorStores.js +0 -159
- package/dist/modules/workspaces.d.ts +0 -138
- package/dist/modules/workspaces.d.ts.map +0 -1
- package/dist/modules/workspaces.js +0 -121
- package/dist/sse/client.d.ts +0 -140
- package/dist/sse/client.d.ts.map +0 -1
- package/dist/sse/client.js +0 -103
|
@@ -1,141 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Agent OS SDK - Main Client
|
|
3
|
-
*
|
|
4
|
-
* Fully typed API client for Agent OS platform.
|
|
5
|
-
*
|
|
6
|
-
* Two authentication modes:
|
|
7
|
-
* - API Token (server-to-server): aosk_* tokens with embedded claims
|
|
8
|
-
* - JWT (browser): Supabase JWT + X-Workspace-Id header
|
|
9
|
-
*
|
|
10
|
-
* @example
|
|
11
|
-
* ```ts
|
|
12
|
-
* // API Token (server-to-server)
|
|
13
|
-
* const api = new AgentOsClient({
|
|
14
|
-
* baseUrl: "https://api.agentos.io",
|
|
15
|
-
* auth: { type: "api_token", apiKey: "aosk_live_xxx" }
|
|
16
|
-
* });
|
|
17
|
-
*
|
|
18
|
-
* // JWT (browser)
|
|
19
|
-
* const api = new AgentOsClient({
|
|
20
|
-
* baseUrl: "https://api.agentos.io",
|
|
21
|
-
* auth: {
|
|
22
|
-
* type: "jwt",
|
|
23
|
-
* getToken: () => supabase.auth.getSession().then(s => s.data.session?.access_token ?? ""),
|
|
24
|
-
* getWorkspaceId: () => localStorage.getItem("agentos.workspaceId") ?? ""
|
|
25
|
-
* }
|
|
26
|
-
* });
|
|
27
|
-
* ```
|
|
28
|
-
*/
|
|
29
|
-
import { type AgentOsClientOptions } from "./auth.js";
|
|
30
|
-
import { type RawClient } from "./raw.js";
|
|
31
|
-
import { AgentsModule } from "../modules/agents.js";
|
|
32
|
-
import { ChatwootModule } from "../modules/chatwoot.js";
|
|
33
|
-
import { CredentialsModule } from "../modules/credentials.js";
|
|
34
|
-
import { DatasetsModule } from "../modules/datasets.js";
|
|
35
|
-
import { RolesModule } from "../modules/roles.js";
|
|
36
|
-
import { MembersModule } from "../modules/members.js";
|
|
37
|
-
import { RunsModule } from "../modules/runs.js";
|
|
38
|
-
import { TenantsModule } from "../modules/tenants.js";
|
|
39
|
-
import { ThreadsModule } from "../modules/threads.js";
|
|
40
|
-
import { ToolsModule } from "../modules/tools.js";
|
|
41
|
-
import { TriggersModule } from "../modules/triggers.js";
|
|
42
|
-
import { WorkspacesModule } from "../modules/workspaces.js";
|
|
43
|
-
import { A2aModule } from "../modules/a2a.js";
|
|
44
|
-
import { ApiTokensModule } from "../modules/apiTokens.js";
|
|
45
|
-
import { ApprovalsModule } from "../modules/approvals.js";
|
|
46
|
-
import { AuditModule } from "../modules/audit.js";
|
|
47
|
-
import { AuthModule } from "../modules/auth.js";
|
|
48
|
-
import { CatalogModule } from "../modules/catalog.js";
|
|
49
|
-
import { CheckpointsModule } from "../modules/checkpoints.js";
|
|
50
|
-
import { ContractsModule } from "../modules/contracts.js";
|
|
51
|
-
import { CronsModule } from "../modules/crons.js";
|
|
52
|
-
import { EvaluationModule } from "../modules/evaluation.js";
|
|
53
|
-
import { FilesModule } from "../modules/files.js";
|
|
54
|
-
import { InfoModule } from "../modules/info.js";
|
|
55
|
-
import { ImprovementsModule } from "../modules/improvements.js";
|
|
56
|
-
import { MeModule } from "../modules/me.js";
|
|
57
|
-
import { MembershipsModule } from "../modules/memberships.js";
|
|
58
|
-
import { MetaAgentModule } from "../modules/metaAgent.js";
|
|
59
|
-
import { MetricsModule } from "../modules/metrics.js";
|
|
60
|
-
import { ObservabilityModule } from "../modules/observability.js";
|
|
61
|
-
import { PlaygroundModule } from "../modules/playground.js";
|
|
62
|
-
import { PresetsModule } from "../modules/presets.js";
|
|
63
|
-
import { PromptsModule } from "../modules/prompts.js";
|
|
64
|
-
import { StoreModule } from "../modules/store.js";
|
|
65
|
-
import { TemplatesModule } from "../modules/templates.js";
|
|
66
|
-
import { TracesModule } from "../modules/traces.js";
|
|
67
|
-
import { UsageModule } from "../modules/usage.js";
|
|
68
|
-
import { VectorStoresModule } from "../modules/vectorStores.js";
|
|
69
|
-
export { isApiTokenAuth, isJwtAuth } from "./auth.js";
|
|
70
|
-
export type { AgentOsClientOptions, AuthProvider } from "./auth.js";
|
|
71
|
-
export declare class AgentOsClient {
|
|
72
|
-
private readonly _client;
|
|
73
|
-
private readonly _baseUrl;
|
|
74
|
-
private readonly _auth;
|
|
75
|
-
private readonly _customHeaders;
|
|
76
|
-
readonly agents: AgentsModule;
|
|
77
|
-
readonly runs: RunsModule;
|
|
78
|
-
readonly threads: ThreadsModule;
|
|
79
|
-
readonly tools: ToolsModule;
|
|
80
|
-
readonly datasets: DatasetsModule;
|
|
81
|
-
readonly roles: RolesModule;
|
|
82
|
-
readonly triggers: TriggersModule;
|
|
83
|
-
readonly credentials: CredentialsModule;
|
|
84
|
-
readonly members: MembersModule;
|
|
85
|
-
readonly tenants: TenantsModule;
|
|
86
|
-
readonly workspaces: WorkspacesModule;
|
|
87
|
-
readonly chatwoot: ChatwootModule;
|
|
88
|
-
readonly prompts: PromptsModule;
|
|
89
|
-
readonly traces: TracesModule;
|
|
90
|
-
readonly files: FilesModule;
|
|
91
|
-
readonly vectorStores: VectorStoresModule;
|
|
92
|
-
readonly evaluation: EvaluationModule;
|
|
93
|
-
readonly checkpoints: CheckpointsModule;
|
|
94
|
-
readonly playground: PlaygroundModule;
|
|
95
|
-
readonly crons: CronsModule;
|
|
96
|
-
readonly store: StoreModule;
|
|
97
|
-
readonly audit: AuditModule;
|
|
98
|
-
readonly usage: UsageModule;
|
|
99
|
-
readonly a2a: A2aModule;
|
|
100
|
-
readonly me: MeModule;
|
|
101
|
-
readonly info: InfoModule;
|
|
102
|
-
readonly improvements: ImprovementsModule;
|
|
103
|
-
readonly metrics: MetricsModule;
|
|
104
|
-
readonly metaAgent: MetaAgentModule;
|
|
105
|
-
readonly contracts: ContractsModule;
|
|
106
|
-
readonly catalog: CatalogModule;
|
|
107
|
-
readonly approvals: ApprovalsModule;
|
|
108
|
-
readonly auth: AuthModule;
|
|
109
|
-
readonly observability: ObservabilityModule;
|
|
110
|
-
readonly templates: TemplatesModule;
|
|
111
|
-
readonly experiments: {
|
|
112
|
-
list: EvaluationModule["listExperiments"];
|
|
113
|
-
get: EvaluationModule["getExperiment"];
|
|
114
|
-
create: EvaluationModule["createExperiment"];
|
|
115
|
-
};
|
|
116
|
-
readonly apiTokens: ApiTokensModule;
|
|
117
|
-
readonly memberships: MembershipsModule;
|
|
118
|
-
readonly presets: PresetsModule;
|
|
119
|
-
constructor(options: AgentOsClientOptions);
|
|
120
|
-
/**
|
|
121
|
-
* Validate auth configuration at construction time
|
|
122
|
-
*/
|
|
123
|
-
private _validateAuth;
|
|
124
|
-
/**
|
|
125
|
-
* Resolve headers for each request (async)
|
|
126
|
-
*
|
|
127
|
-
* SECURITY INVARIANTS:
|
|
128
|
-
* - JWT: Authorization + X-Workspace-Id (REQUIRED), NO X-Tenant-Id
|
|
129
|
-
* - API Token: Authorization only, NO X-Workspace-Id, NO X-Tenant-Id
|
|
130
|
-
*/
|
|
131
|
-
private _resolveHeaders;
|
|
132
|
-
/**
|
|
133
|
-
* Get resolved headers (for debugging/testing)
|
|
134
|
-
*/
|
|
135
|
-
getHeadersAsync(): Promise<Record<string, string>>;
|
|
136
|
-
/** Auth provider type */
|
|
137
|
-
get authType(): "api_token" | "jwt";
|
|
138
|
-
/** Raw HTTP client (use modules instead) */
|
|
139
|
-
get raw(): RawClient;
|
|
140
|
-
}
|
|
141
|
-
//# sourceMappingURL=AgentOsClient.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"AgentOsClient.d.ts","sourceRoot":"","sources":["../../src/client/AgentOsClient.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAEH,OAAO,EACH,KAAK,oBAAoB,EAK5B,MAAM,WAAW,CAAC;AACnB,OAAO,EAAmB,KAAK,SAAS,EAAE,MAAM,UAAU,CAAC;AAE3D,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,EAAE,cAAc,EAAE,MAAM,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AAmB,CAAC;IAC5C,QAAQ,CAAC,SAAS,EAAE,eAAe,CAAC;IAGpC,QAAQ,CAAC,WAAW,EAAE;QAClB,IAAI,EAAE,gBAAgB,CAAC,iBAAiB,CAAC,CAAC;QAC1C,GAAG,EAAE,gBAAgB,CAAC,eAAe,CAAC,CAAC;QACvC,MAAM,EAAE,gBAAgB,CAAC,kBAAkB,CAAC,CAAC;KAChD,CAAC;IAEF,SAAgB,SAAS,EAAE,eAAe,CAAC;IAC3C,SAAgB,WAAW,EAAE,iBAAiB,CAAC;IAC/C,SAAgB,OAAO,EAAE,aAAa,CAAC;gBAI3B,OAAO,EAAE,oBAAoB;IA0EzC;;OAEG;IACH,OAAO,CAAC,aAAa;IAYrB;;;;;;OAMG;YACW,eAAe;IAwC7B;;OAEG;IACG,eAAe,IAAI,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAIxD,yBAAyB;IACzB,IAAI,QAAQ,IAAI,WAAW,GAAG,KAAK,CAElC;IAED,4CAA4C;IAC5C,IAAI,GAAG,IAAI,SAAS,CAEnB;CACJ"}
|
|
@@ -1,250 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Agent OS SDK - Main Client
|
|
3
|
-
*
|
|
4
|
-
* Fully typed API client for Agent OS platform.
|
|
5
|
-
*
|
|
6
|
-
* Two authentication modes:
|
|
7
|
-
* - API Token (server-to-server): aosk_* tokens with embedded claims
|
|
8
|
-
* - JWT (browser): Supabase JWT + X-Workspace-Id header
|
|
9
|
-
*
|
|
10
|
-
* @example
|
|
11
|
-
* ```ts
|
|
12
|
-
* // API Token (server-to-server)
|
|
13
|
-
* const api = new AgentOsClient({
|
|
14
|
-
* baseUrl: "https://api.agentos.io",
|
|
15
|
-
* auth: { type: "api_token", apiKey: "aosk_live_xxx" }
|
|
16
|
-
* });
|
|
17
|
-
*
|
|
18
|
-
* // JWT (browser)
|
|
19
|
-
* const api = new AgentOsClient({
|
|
20
|
-
* baseUrl: "https://api.agentos.io",
|
|
21
|
-
* auth: {
|
|
22
|
-
* type: "jwt",
|
|
23
|
-
* getToken: () => supabase.auth.getSession().then(s => s.data.session?.access_token ?? ""),
|
|
24
|
-
* getWorkspaceId: () => localStorage.getItem("agentos.workspaceId") ?? ""
|
|
25
|
-
* }
|
|
26
|
-
* });
|
|
27
|
-
* ```
|
|
28
|
-
*/
|
|
29
|
-
import { isApiTokenAuth, isBrowser, isJwtAuth, } from "./auth.js";
|
|
30
|
-
import { createRawClient } from "./raw.js";
|
|
31
|
-
import { AgentsModule } from "../modules/agents.js";
|
|
32
|
-
import { ChatwootModule } from "../modules/chatwoot.js";
|
|
33
|
-
import { CredentialsModule } from "../modules/credentials.js";
|
|
34
|
-
import { DatasetsModule } from "../modules/datasets.js";
|
|
35
|
-
import { RolesModule } from "../modules/roles.js";
|
|
36
|
-
import { MembersModule } from "../modules/members.js";
|
|
37
|
-
import { RunsModule } from "../modules/runs.js";
|
|
38
|
-
import { TenantsModule } from "../modules/tenants.js";
|
|
39
|
-
import { ThreadsModule } from "../modules/threads.js";
|
|
40
|
-
import { ToolsModule } from "../modules/tools.js";
|
|
41
|
-
import { TriggersModule } from "../modules/triggers.js";
|
|
42
|
-
import { WorkspacesModule } from "../modules/workspaces.js";
|
|
43
|
-
// Platform modules
|
|
44
|
-
import { A2aModule } from "../modules/a2a.js";
|
|
45
|
-
import { ApiTokensModule } from "../modules/apiTokens.js";
|
|
46
|
-
import { ApprovalsModule } from "../modules/approvals.js";
|
|
47
|
-
import { AuditModule } from "../modules/audit.js";
|
|
48
|
-
import { AuthModule } from "../modules/auth.js";
|
|
49
|
-
import { CatalogModule } from "../modules/catalog.js";
|
|
50
|
-
import { CheckpointsModule } from "../modules/checkpoints.js";
|
|
51
|
-
import { ContractsModule } from "../modules/contracts.js";
|
|
52
|
-
import { CronsModule } from "../modules/crons.js";
|
|
53
|
-
import { EvaluationModule } from "../modules/evaluation.js";
|
|
54
|
-
import { FilesModule } from "../modules/files.js";
|
|
55
|
-
import { InfoModule } from "../modules/info.js";
|
|
56
|
-
import { ImprovementsModule } from "../modules/improvements.js";
|
|
57
|
-
import { MeModule } from "../modules/me.js";
|
|
58
|
-
import { MembershipsModule } from "../modules/memberships.js";
|
|
59
|
-
import { MetaAgentModule } from "../modules/metaAgent.js";
|
|
60
|
-
import { MetricsModule } from "../modules/metrics.js";
|
|
61
|
-
import { ObservabilityModule } from "../modules/observability.js";
|
|
62
|
-
import { PlaygroundModule } from "../modules/playground.js";
|
|
63
|
-
import { PresetsModule } from "../modules/presets.js";
|
|
64
|
-
import { PromptsModule } from "../modules/prompts.js";
|
|
65
|
-
import { StoreModule } from "../modules/store.js";
|
|
66
|
-
import { TemplatesModule } from "../modules/templates.js";
|
|
67
|
-
import { TracesModule } from "../modules/traces.js";
|
|
68
|
-
import { UsageModule } from "../modules/usage.js";
|
|
69
|
-
import { VectorStoresModule } from "../modules/vectorStores.js";
|
|
70
|
-
// Re-export auth types
|
|
71
|
-
export { isApiTokenAuth, isJwtAuth } from "./auth.js";
|
|
72
|
-
export class AgentOsClient {
|
|
73
|
-
_client;
|
|
74
|
-
_baseUrl;
|
|
75
|
-
_auth;
|
|
76
|
-
_customHeaders;
|
|
77
|
-
// Core modules
|
|
78
|
-
agents;
|
|
79
|
-
runs;
|
|
80
|
-
threads;
|
|
81
|
-
tools;
|
|
82
|
-
datasets;
|
|
83
|
-
roles;
|
|
84
|
-
triggers;
|
|
85
|
-
credentials;
|
|
86
|
-
members;
|
|
87
|
-
tenants;
|
|
88
|
-
workspaces;
|
|
89
|
-
chatwoot;
|
|
90
|
-
// Platform modules
|
|
91
|
-
prompts;
|
|
92
|
-
traces;
|
|
93
|
-
files;
|
|
94
|
-
vectorStores;
|
|
95
|
-
evaluation;
|
|
96
|
-
checkpoints;
|
|
97
|
-
playground;
|
|
98
|
-
crons;
|
|
99
|
-
store;
|
|
100
|
-
audit;
|
|
101
|
-
usage;
|
|
102
|
-
a2a;
|
|
103
|
-
me;
|
|
104
|
-
info;
|
|
105
|
-
improvements;
|
|
106
|
-
metrics;
|
|
107
|
-
metaAgent;
|
|
108
|
-
contracts;
|
|
109
|
-
catalog;
|
|
110
|
-
approvals;
|
|
111
|
-
auth;
|
|
112
|
-
observability;
|
|
113
|
-
templates;
|
|
114
|
-
// Convenience aliases
|
|
115
|
-
experiments;
|
|
116
|
-
apiTokens;
|
|
117
|
-
memberships;
|
|
118
|
-
presets;
|
|
119
|
-
constructor(options) {
|
|
120
|
-
this._baseUrl = options.baseUrl;
|
|
121
|
-
this._auth = options.auth;
|
|
122
|
-
this._customHeaders = options.headers ?? {};
|
|
123
|
-
// Validate auth configuration
|
|
124
|
-
this._validateAuth(options);
|
|
125
|
-
// Create raw client with async header provider
|
|
126
|
-
this._client = createRawClient({
|
|
127
|
-
baseUrl: options.baseUrl,
|
|
128
|
-
headerProvider: () => this._resolveHeaders(),
|
|
129
|
-
contextProvider: options.contextProvider,
|
|
130
|
-
network: options.network,
|
|
131
|
-
hooks: options.hooks,
|
|
132
|
-
});
|
|
133
|
-
// Module header getter (sync fallback for backwards compat with module internals)
|
|
134
|
-
const getHeaders = () => this._customHeaders;
|
|
135
|
-
const getWorkspaceId = () => "";
|
|
136
|
-
const getTenantId = () => "";
|
|
137
|
-
// Initialize core modules
|
|
138
|
-
this.agents = new AgentsModule(this._client, getHeaders);
|
|
139
|
-
this.runs = new RunsModule(this._client);
|
|
140
|
-
this.threads = new ThreadsModule(this._client, getHeaders);
|
|
141
|
-
this.tools = new ToolsModule(this._client, getHeaders);
|
|
142
|
-
this.datasets = new DatasetsModule(this._client, getHeaders);
|
|
143
|
-
this.roles = new RolesModule(this._client, getHeaders);
|
|
144
|
-
this.triggers = new TriggersModule(this._client, getHeaders);
|
|
145
|
-
this.credentials = new CredentialsModule(this._client, getWorkspaceId, getHeaders);
|
|
146
|
-
this.members = new MembersModule(this._client, getHeaders);
|
|
147
|
-
this.tenants = new TenantsModule(this._client, getHeaders);
|
|
148
|
-
this.workspaces = new WorkspacesModule(this._client, getTenantId, getHeaders);
|
|
149
|
-
this.chatwoot = new ChatwootModule(this._client, getHeaders);
|
|
150
|
-
// Initialize platform modules
|
|
151
|
-
this.prompts = new PromptsModule(this._client, getHeaders);
|
|
152
|
-
this.traces = new TracesModule(this._client, getHeaders);
|
|
153
|
-
this.files = new FilesModule(this._client, getHeaders);
|
|
154
|
-
this.vectorStores = new VectorStoresModule(this._client, getHeaders);
|
|
155
|
-
this.evaluation = new EvaluationModule(this._client, getHeaders);
|
|
156
|
-
this.checkpoints = new CheckpointsModule(this._client, getHeaders);
|
|
157
|
-
this.playground = new PlaygroundModule(this._client, getHeaders);
|
|
158
|
-
this.crons = new CronsModule(this._client, getHeaders);
|
|
159
|
-
this.store = new StoreModule(this._client, getHeaders);
|
|
160
|
-
this.audit = new AuditModule(this._client, getHeaders);
|
|
161
|
-
this.usage = new UsageModule(this._client, getHeaders);
|
|
162
|
-
this.a2a = new A2aModule(this._client, getHeaders);
|
|
163
|
-
this.me = new MeModule(this._client, getHeaders);
|
|
164
|
-
this.info = new InfoModule(this._client, getHeaders);
|
|
165
|
-
this.improvements = new ImprovementsModule(this._client, getHeaders);
|
|
166
|
-
this.metrics = new MetricsModule(this._client);
|
|
167
|
-
this.metaAgent = new MetaAgentModule(this._client, getHeaders);
|
|
168
|
-
this.contracts = new ContractsModule(this._client, getHeaders);
|
|
169
|
-
this.catalog = new CatalogModule(this._client);
|
|
170
|
-
this.approvals = new ApprovalsModule(this._client, getHeaders);
|
|
171
|
-
this.auth = new AuthModule(this._client, getHeaders);
|
|
172
|
-
this.observability = new ObservabilityModule(this._client, getHeaders);
|
|
173
|
-
this.templates = new TemplatesModule(this._client, getHeaders);
|
|
174
|
-
// Initialize convenience aliases
|
|
175
|
-
this.experiments = {
|
|
176
|
-
list: this.evaluation.listExperiments.bind(this.evaluation),
|
|
177
|
-
get: this.evaluation.getExperiment.bind(this.evaluation),
|
|
178
|
-
create: this.evaluation.createExperiment.bind(this.evaluation),
|
|
179
|
-
};
|
|
180
|
-
this.apiTokens = new ApiTokensModule(this._client);
|
|
181
|
-
this.memberships = new MembershipsModule(this._client);
|
|
182
|
-
this.presets = new PresetsModule(this._client, getHeaders);
|
|
183
|
-
}
|
|
184
|
-
/**
|
|
185
|
-
* Validate auth configuration at construction time
|
|
186
|
-
*/
|
|
187
|
-
_validateAuth(options) {
|
|
188
|
-
const { auth, allowApiTokenInBrowser } = options;
|
|
189
|
-
// Browser security guard for API tokens
|
|
190
|
-
if (isApiTokenAuth(auth) && isBrowser() && !allowApiTokenInBrowser) {
|
|
191
|
-
throw new Error("[AgentOS SDK] SECURITY: API tokens (aosk_*) are SERVER-SIDE only. " +
|
|
192
|
-
"Use JWT auth in the browser. Set allowApiTokenInBrowser: true only if you understand the risks.");
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
|
-
/**
|
|
196
|
-
* Resolve headers for each request (async)
|
|
197
|
-
*
|
|
198
|
-
* SECURITY INVARIANTS:
|
|
199
|
-
* - JWT: Authorization + X-Workspace-Id (REQUIRED), NO X-Tenant-Id
|
|
200
|
-
* - API Token: Authorization only, NO X-Workspace-Id, NO X-Tenant-Id
|
|
201
|
-
*/
|
|
202
|
-
async _resolveHeaders() {
|
|
203
|
-
const headers = {
|
|
204
|
-
"Content-Type": "application/json",
|
|
205
|
-
...this._customHeaders,
|
|
206
|
-
};
|
|
207
|
-
if (isApiTokenAuth(this._auth)) {
|
|
208
|
-
// API Token: Authorization header only
|
|
209
|
-
const apiKey = typeof this._auth.apiKey === "function"
|
|
210
|
-
? await this._auth.apiKey()
|
|
211
|
-
: this._auth.apiKey;
|
|
212
|
-
if (apiKey) {
|
|
213
|
-
headers["Authorization"] = `Bearer ${apiKey}`;
|
|
214
|
-
}
|
|
215
|
-
// NO X-Workspace-Id (embedded in token claims)
|
|
216
|
-
// NO X-Tenant-Id (embedded in token claims)
|
|
217
|
-
}
|
|
218
|
-
else if (isJwtAuth(this._auth)) {
|
|
219
|
-
// JWT: Authorization + X-Workspace-Id
|
|
220
|
-
const [token, workspaceId] = await Promise.all([
|
|
221
|
-
Promise.resolve(this._auth.getToken()),
|
|
222
|
-
Promise.resolve(this._auth.getWorkspaceId()),
|
|
223
|
-
]);
|
|
224
|
-
if (token) {
|
|
225
|
-
headers["Authorization"] = `Bearer ${token}`;
|
|
226
|
-
}
|
|
227
|
-
// Workspace ID is optional for bootstrap endpoints (e.g., /me)
|
|
228
|
-
// Most endpoints require it, but the header provider allows empty strings
|
|
229
|
-
if (workspaceId) {
|
|
230
|
-
headers["X-Workspace-Id"] = workspaceId;
|
|
231
|
-
}
|
|
232
|
-
// NO X-Tenant-Id (backend derives from workspace membership)
|
|
233
|
-
}
|
|
234
|
-
return headers;
|
|
235
|
-
}
|
|
236
|
-
/**
|
|
237
|
-
* Get resolved headers (for debugging/testing)
|
|
238
|
-
*/
|
|
239
|
-
async getHeadersAsync() {
|
|
240
|
-
return this._resolveHeaders();
|
|
241
|
-
}
|
|
242
|
-
/** Auth provider type */
|
|
243
|
-
get authType() {
|
|
244
|
-
return this._auth.type;
|
|
245
|
-
}
|
|
246
|
-
/** Raw HTTP client (use modules instead) */
|
|
247
|
-
get raw() {
|
|
248
|
-
return this._client;
|
|
249
|
-
}
|
|
250
|
-
}
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* HttpRequestBuilder — Single source of truth for headers
|
|
3
|
-
*
|
|
4
|
-
* All header generation flows through this builder.
|
|
5
|
-
* raw.ts should NOT generate headers directly.
|
|
6
|
-
*
|
|
7
|
-
* Headers generated:
|
|
8
|
-
* - X-Request-Id: Per-request, always new (crypto.randomUUID)
|
|
9
|
-
* - X-Correlation-Id: Per-flow, immutable within flow
|
|
10
|
-
* - Authorization: Bearer token
|
|
11
|
-
* - X-Workspace-Id: Workspace binding (from context)
|
|
12
|
-
* - X-Idempotency-Key: Opt-in for POST requests
|
|
13
|
-
* - User-Agent: SDK version + runtime info
|
|
14
|
-
*
|
|
15
|
-
* @see sdk-upgrade.md Section 1.3
|
|
16
|
-
*/
|
|
17
|
-
import type { OperationContext } from "./OperationContext.js";
|
|
18
|
-
export declare function sanitizeValidCorrelationId(raw?: string): string | null;
|
|
19
|
-
/**
|
|
20
|
-
* Options for building request headers
|
|
21
|
-
*/
|
|
22
|
-
export interface HttpRequestBuilderOptions {
|
|
23
|
-
/** Bearer token for Authorization header */
|
|
24
|
-
token?: string;
|
|
25
|
-
/** Operation context with correlationId and workspaceId */
|
|
26
|
-
context?: OperationContext;
|
|
27
|
-
/** Idempotency key for POST requests */
|
|
28
|
-
idempotencyKey?: string;
|
|
29
|
-
/** If true, throws if correlationId is missing */
|
|
30
|
-
requireFlow?: boolean;
|
|
31
|
-
}
|
|
32
|
-
/**
|
|
33
|
-
* Build headers for HTTP requests.
|
|
34
|
-
* This is the SINGLE SOURCE OF TRUTH for header generation.
|
|
35
|
-
*/
|
|
36
|
-
export declare class HttpRequestBuilder {
|
|
37
|
-
/**
|
|
38
|
-
* Build headers from options.
|
|
39
|
-
*
|
|
40
|
-
* @throws Error if requireFlow is true and correlationId is missing
|
|
41
|
-
*/
|
|
42
|
-
build(opts: HttpRequestBuilderOptions): Record<string, string>;
|
|
43
|
-
private resolveCorrelationId;
|
|
44
|
-
/**
|
|
45
|
-
* Build User-Agent string with SDK version and runtime info
|
|
46
|
-
*/
|
|
47
|
-
private buildUserAgent;
|
|
48
|
-
}
|
|
49
|
-
export declare const httpRequestBuilder: HttpRequestBuilder;
|
|
50
|
-
//# sourceMappingURL=HttpRequestBuilder.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"HttpRequestBuilder.d.ts","sourceRoot":"","sources":["../../src/client/HttpRequestBuilder.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAQ9D,wBAAgB,0BAA0B,CAAC,GAAG,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAGtE;AAED;;GAEG;AACH,MAAM,WAAW,yBAAyB;IACtC,4CAA4C;IAC5C,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,2DAA2D;IAC3D,OAAO,CAAC,EAAE,gBAAgB,CAAC;IAC3B,wCAAwC;IACxC,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,kDAAkD;IAClD,WAAW,CAAC,EAAE,OAAO,CAAC;CACzB;AAED;;;GAGG;AACH,qBAAa,kBAAkB;IAC3B;;;;OAIG;IACH,KAAK,CAAC,IAAI,EAAE,yBAAyB,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;IAiC9D,OAAO,CAAC,oBAAoB;IAS5B;;OAEG;IACH,OAAO,CAAC,cAAc;CAYzB;AAGD,eAAO,MAAM,kBAAkB,oBAA2B,CAAC"}
|
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* HttpRequestBuilder — Single source of truth for headers
|
|
3
|
-
*
|
|
4
|
-
* All header generation flows through this builder.
|
|
5
|
-
* raw.ts should NOT generate headers directly.
|
|
6
|
-
*
|
|
7
|
-
* Headers generated:
|
|
8
|
-
* - X-Request-Id: Per-request, always new (crypto.randomUUID)
|
|
9
|
-
* - X-Correlation-Id: Per-flow, immutable within flow
|
|
10
|
-
* - Authorization: Bearer token
|
|
11
|
-
* - X-Workspace-Id: Workspace binding (from context)
|
|
12
|
-
* - X-Idempotency-Key: Opt-in for POST requests
|
|
13
|
-
* - User-Agent: SDK version + runtime info
|
|
14
|
-
*
|
|
15
|
-
* @see sdk-upgrade.md Section 1.3
|
|
16
|
-
*/
|
|
17
|
-
import { sanitizeHeader, sanitizeHeaders } from "./sanitize.js";
|
|
18
|
-
const SDK_VERSION = typeof __SDK_VERSION__ !== "undefined" ? __SDK_VERSION__ : "0.7.12-dev";
|
|
19
|
-
const CORRELATION_ID_PATTERN = /^[A-Za-z0-9._:-]{8,128}$/;
|
|
20
|
-
export function sanitizeValidCorrelationId(raw) {
|
|
21
|
-
const candidate = sanitizeHeader((raw ?? "").trim());
|
|
22
|
-
return CORRELATION_ID_PATTERN.test(candidate) ? candidate : null;
|
|
23
|
-
}
|
|
24
|
-
/**
|
|
25
|
-
* Build headers for HTTP requests.
|
|
26
|
-
* This is the SINGLE SOURCE OF TRUTH for header generation.
|
|
27
|
-
*/
|
|
28
|
-
export class HttpRequestBuilder {
|
|
29
|
-
/**
|
|
30
|
-
* Build headers from options.
|
|
31
|
-
*
|
|
32
|
-
* @throws Error if requireFlow is true and correlationId is missing
|
|
33
|
-
*/
|
|
34
|
-
build(opts) {
|
|
35
|
-
const headers = {};
|
|
36
|
-
// I2: X-Request-Id always exists (per request)
|
|
37
|
-
headers["X-Request-Id"] = crypto.randomUUID();
|
|
38
|
-
// User-Agent: Dynamic SDK version
|
|
39
|
-
headers["User-Agent"] = this.buildUserAgent();
|
|
40
|
-
// I3: X-Correlation-Id is per flow
|
|
41
|
-
if (opts.requireFlow && !opts.context?.correlationId) {
|
|
42
|
-
throw new Error("X-Correlation-Id required for flow-scoped operations");
|
|
43
|
-
}
|
|
44
|
-
headers["X-Correlation-Id"] = this.resolveCorrelationId(opts.context?.correlationId);
|
|
45
|
-
// Authorization
|
|
46
|
-
if (opts.token) {
|
|
47
|
-
headers["Authorization"] = `Bearer ${opts.token}`;
|
|
48
|
-
}
|
|
49
|
-
// X-Workspace-Id from context
|
|
50
|
-
if (opts.context?.workspaceId) {
|
|
51
|
-
headers["X-Workspace-Id"] = opts.context.workspaceId;
|
|
52
|
-
}
|
|
53
|
-
// I7: Idempotency is opt-in
|
|
54
|
-
if (opts.idempotencyKey) {
|
|
55
|
-
headers["X-Idempotency-Key"] = sanitizeHeader(opts.idempotencyKey);
|
|
56
|
-
}
|
|
57
|
-
return sanitizeHeaders(headers);
|
|
58
|
-
}
|
|
59
|
-
resolveCorrelationId(raw) {
|
|
60
|
-
const candidate = sanitizeValidCorrelationId(raw);
|
|
61
|
-
if (candidate) {
|
|
62
|
-
return candidate;
|
|
63
|
-
}
|
|
64
|
-
return crypto.randomUUID();
|
|
65
|
-
}
|
|
66
|
-
/**
|
|
67
|
-
* Build User-Agent string with SDK version and runtime info
|
|
68
|
-
*/
|
|
69
|
-
buildUserAgent() {
|
|
70
|
-
// Node.js environment
|
|
71
|
-
if (typeof process !== "undefined" && process.version) {
|
|
72
|
-
return `agent-os-sdk/${SDK_VERSION} (node/${process.version})`;
|
|
73
|
-
}
|
|
74
|
-
// Browser environment
|
|
75
|
-
if (typeof navigator !== "undefined" && navigator.userAgent) {
|
|
76
|
-
return `agent-os-sdk/${SDK_VERSION} (browser)`;
|
|
77
|
-
}
|
|
78
|
-
// Unknown environment
|
|
79
|
-
return `agent-os-sdk/${SDK_VERSION}`;
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
// Singleton instance for convenience
|
|
83
|
-
export const httpRequestBuilder = new HttpRequestBuilder();
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* OperationContext — Immutable flow context
|
|
3
|
-
*
|
|
4
|
-
* Created at the start of a logical flow and never mutates.
|
|
5
|
-
*
|
|
6
|
-
* - correlationId: Tracks the entire logical operation (immutable per flow)
|
|
7
|
-
* - workspaceId: Optional workspace binding
|
|
8
|
-
*
|
|
9
|
-
* @see sdk-upgrade.md Section 1.1
|
|
10
|
-
*/
|
|
11
|
-
export type OperationContext = Readonly<{
|
|
12
|
-
correlationId: string;
|
|
13
|
-
workspaceId?: string;
|
|
14
|
-
}>;
|
|
15
|
-
export declare function createOperationContext(input: {
|
|
16
|
-
correlationId: string;
|
|
17
|
-
workspaceId?: string;
|
|
18
|
-
}): OperationContext;
|
|
19
|
-
//# sourceMappingURL=OperationContext.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"OperationContext.d.ts","sourceRoot":"","sources":["../../src/client/OperationContext.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,MAAM,MAAM,gBAAgB,GAAG,QAAQ,CAAC;IACpC,aAAa,EAAE,MAAM,CAAC;IACtB,WAAW,CAAC,EAAE,MAAM,CAAC;CACxB,CAAC,CAAC;AAEH,wBAAgB,sBAAsB,CAAC,KAAK,EAAE;IAC1C,aAAa,EAAE,MAAM,CAAC;IACtB,WAAW,CAAC,EAAE,MAAM,CAAC;CACxB,GAAG,gBAAgB,CAEnB"}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* OperationContext — Immutable flow context
|
|
3
|
-
*
|
|
4
|
-
* Created at the start of a logical flow and never mutates.
|
|
5
|
-
*
|
|
6
|
-
* - correlationId: Tracks the entire logical operation (immutable per flow)
|
|
7
|
-
* - workspaceId: Optional workspace binding
|
|
8
|
-
*
|
|
9
|
-
* @see sdk-upgrade.md Section 1.1
|
|
10
|
-
*/
|
|
11
|
-
export function createOperationContext(input) {
|
|
12
|
-
return Object.freeze({ ...input });
|
|
13
|
-
}
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* OperationContextProvider — Flow lifecycle management
|
|
3
|
-
*
|
|
4
|
-
* Provider defines the lifecycle of a flow context.
|
|
5
|
-
* Implementations can use AsyncLocalStorage or manual context passing.
|
|
6
|
-
*
|
|
7
|
-
* @see sdk-upgrade.md Section 1.2
|
|
8
|
-
*/
|
|
9
|
-
import type { OperationContext } from "./OperationContext.js";
|
|
10
|
-
/**
|
|
11
|
-
* Interface for context providers
|
|
12
|
-
*/
|
|
13
|
-
export interface OperationContextProvider {
|
|
14
|
-
get(): OperationContext | undefined;
|
|
15
|
-
}
|
|
16
|
-
/**
|
|
17
|
-
* Default provider that always returns undefined.
|
|
18
|
-
* Used when no flow context is established.
|
|
19
|
-
*/
|
|
20
|
-
export declare class DefaultContextProvider implements OperationContextProvider {
|
|
21
|
-
get(): OperationContext | undefined;
|
|
22
|
-
}
|
|
23
|
-
/**
|
|
24
|
-
* AsyncLocalStorage-based provider for Node.js environments.
|
|
25
|
-
* Automatically propagates context through async call chains.
|
|
26
|
-
*
|
|
27
|
-
* Note: This class requires Node.js async_hooks module.
|
|
28
|
-
* Import and use only in Node.js environments.
|
|
29
|
-
*/
|
|
30
|
-
export declare class AsyncLocalStorageContextProvider implements OperationContextProvider {
|
|
31
|
-
private readonly storage;
|
|
32
|
-
constructor();
|
|
33
|
-
get(): OperationContext | undefined;
|
|
34
|
-
/**
|
|
35
|
-
* Run a function within a context.
|
|
36
|
-
* The context is automatically available to all async operations within.
|
|
37
|
-
*/
|
|
38
|
-
run<T>(context: OperationContext, fn: () => T): T;
|
|
39
|
-
/**
|
|
40
|
-
* Run an async function within a context.
|
|
41
|
-
*/
|
|
42
|
-
runAsync<T>(context: OperationContext, fn: () => Promise<T>): Promise<T>;
|
|
43
|
-
}
|
|
44
|
-
/**
|
|
45
|
-
* Manual provider for environments without AsyncLocalStorage.
|
|
46
|
-
* Context must be explicitly set and cleared.
|
|
47
|
-
*/
|
|
48
|
-
export declare class ManualContextProvider implements OperationContextProvider {
|
|
49
|
-
private context;
|
|
50
|
-
get(): OperationContext | undefined;
|
|
51
|
-
set(context: OperationContext): void;
|
|
52
|
-
clear(): void;
|
|
53
|
-
}
|
|
54
|
-
//# sourceMappingURL=OperationContextProvider.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"OperationContextProvider.d.ts","sourceRoot":"","sources":["../../src/client/OperationContextProvider.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAE9D;;GAEG;AACH,MAAM,WAAW,wBAAwB;IACrC,GAAG,IAAI,gBAAgB,GAAG,SAAS,CAAC;CACvC;AAED;;;GAGG;AACH,qBAAa,sBAAuB,YAAW,wBAAwB;IACnE,GAAG,IAAI,gBAAgB,GAAG,SAAS;CAGtC;AAED;;;;;;GAMG;AACH,qBAAa,gCAAiC,YAAW,wBAAwB;IAE7E,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAM;;IAa9B,GAAG,IAAI,gBAAgB,GAAG,SAAS;IAInC;;;OAGG;IACH,GAAG,CAAC,CAAC,EAAE,OAAO,EAAE,gBAAgB,EAAE,EAAE,EAAE,MAAM,CAAC,GAAG,CAAC;IAIjD;;OAEG;IACH,QAAQ,CAAC,CAAC,EAAE,OAAO,EAAE,gBAAgB,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC;CAG3E;AAED;;;GAGG;AACH,qBAAa,qBAAsB,YAAW,wBAAwB;IAClE,OAAO,CAAC,OAAO,CAA+B;IAE9C,GAAG,IAAI,gBAAgB,GAAG,SAAS;IAInC,GAAG,CAAC,OAAO,EAAE,gBAAgB,GAAG,IAAI;IAIpC,KAAK,IAAI,IAAI;CAGhB"}
|