@agent-os-sdk/client 0.9.25 → 0.9.27
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/generated/openapi.d.ts +82 -0
- package/dist/generated/openapi.d.ts.map +1 -1
- package/dist/modules/runs.d.ts.map +1 -1
- package/dist/modules/templates.d.ts +23 -0
- package/dist/modules/templates.d.ts.map +1 -1
- package/dist/modules/templates.js +7 -0
- package/package.json +2 -2
- package/src/client/AgentOsClient.ts +0 -294
- package/src/client/HttpRequestBuilder.ts +0 -115
- package/src/client/OperationContext.ts +0 -22
- package/src/client/OperationContextProvider.ts +0 -89
- package/src/client/auth.ts +0 -136
- package/src/client/config.ts +0 -100
- package/src/client/helpers.ts +0 -98
- package/src/client/pagination.ts +0 -218
- package/src/client/raw.ts +0 -609
- package/src/client/retry.ts +0 -150
- package/src/client/sanitize.ts +0 -31
- package/src/client/timeout.ts +0 -59
- package/src/errors/factory.ts +0 -140
- package/src/errors/index.ts +0 -365
- package/src/generated/client.ts +0 -32
- package/src/generated/index.ts +0 -2
- package/src/generated/openapi.ts +0 -12302
- package/src/generated/swagger.json +0 -16851
- package/src/index.ts +0 -131
- package/src/modules/a2a.ts +0 -64
- package/src/modules/agents.ts +0 -604
- package/src/modules/apiTokens.ts +0 -101
- package/src/modules/approvals.ts +0 -151
- package/src/modules/audit.ts +0 -145
- package/src/modules/auth.ts +0 -33
- package/src/modules/catalog.ts +0 -241
- package/src/modules/chatwoot.ts +0 -242
- package/src/modules/checkpoints.ts +0 -87
- package/src/modules/contracts.ts +0 -80
- package/src/modules/credentials.ts +0 -216
- package/src/modules/crons.ts +0 -115
- package/src/modules/datasets.ts +0 -142
- package/src/modules/evaluation.ts +0 -269
- package/src/modules/files.ts +0 -208
- package/src/modules/improvements.ts +0 -71
- package/src/modules/info.ts +0 -143
- package/src/modules/me.ts +0 -74
- package/src/modules/members.ts +0 -199
- package/src/modules/memberships.ts +0 -42
- package/src/modules/metaAgent.ts +0 -131
- package/src/modules/metrics.ts +0 -34
- package/src/modules/observability.ts +0 -28
- package/src/modules/playground.ts +0 -68
- package/src/modules/presets.ts +0 -246
- package/src/modules/prompts.ts +0 -147
- package/src/modules/roles.ts +0 -112
- package/src/modules/runs.ts +0 -878
- package/src/modules/store.ts +0 -65
- package/src/modules/templates.ts +0 -40
- package/src/modules/tenants.ts +0 -79
- package/src/modules/threads.ts +0 -343
- package/src/modules/tools.ts +0 -91
- package/src/modules/traces.ts +0 -133
- package/src/modules/triggers.ts +0 -357
- package/src/modules/usage.ts +0 -117
- package/src/modules/vectorStores.ts +0 -257
- package/src/modules/workspaces.ts +0 -216
- package/src/sse/client.ts +0 -179
package/src/modules/traces.ts
DELETED
|
@@ -1,133 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Traces Module - Fully Typed
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
import type { RawClient, APIResponse, components } from "../client/raw.js";
|
|
6
|
-
|
|
7
|
-
export type SpanData = components["schemas"]["SpanData"];
|
|
8
|
-
type BatchIngestRequest = components["schemas"]["BatchIngestRequest"];
|
|
9
|
-
type AddFeedbackRequest = components["schemas"]["AddFeedbackRequest"];
|
|
10
|
-
|
|
11
|
-
export interface FeedbackRequest {
|
|
12
|
-
span_id: string;
|
|
13
|
-
score?: string;
|
|
14
|
-
comment?: string;
|
|
15
|
-
corrections?: Record<string, unknown>;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
export interface Trace {
|
|
19
|
-
trace_id: string;
|
|
20
|
-
run_id?: string;
|
|
21
|
-
root_span_id: string;
|
|
22
|
-
name: string;
|
|
23
|
-
status: "ok" | "error" | "pending";
|
|
24
|
-
start_time: string;
|
|
25
|
-
end_time?: string;
|
|
26
|
-
duration_ms?: number;
|
|
27
|
-
span_count: number;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
export interface Span {
|
|
31
|
-
trace_id: string;
|
|
32
|
-
span_id: string;
|
|
33
|
-
parent_span_id?: string;
|
|
34
|
-
name: string;
|
|
35
|
-
kind: string;
|
|
36
|
-
status: string;
|
|
37
|
-
status_message?: string;
|
|
38
|
-
start_time_unix_nano: number;
|
|
39
|
-
end_time_unix_nano?: number;
|
|
40
|
-
run_id?: string;
|
|
41
|
-
attributes?: Record<string, unknown>;
|
|
42
|
-
events?: unknown[];
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
export interface TraceListResponse {
|
|
46
|
-
items: Trace[];
|
|
47
|
-
total: number;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
export interface SpanListResponse {
|
|
51
|
-
items: Span[];
|
|
52
|
-
total: number;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
export interface TraceDetail extends Trace {
|
|
56
|
-
spans: Span[];
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
export interface SpansByRunResponse {
|
|
60
|
-
run_id: string;
|
|
61
|
-
spans: Span[];
|
|
62
|
-
count: number;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
export class TracesModule {
|
|
66
|
-
constructor(private client: RawClient, private headers: () => Record<string, string>) { }
|
|
67
|
-
|
|
68
|
-
/**
|
|
69
|
-
* List traces.
|
|
70
|
-
*/
|
|
71
|
-
async list(params?: {
|
|
72
|
-
run_id?: string;
|
|
73
|
-
from?: string;
|
|
74
|
-
to?: string;
|
|
75
|
-
limit?: number;
|
|
76
|
-
offset?: number;
|
|
77
|
-
}): Promise<APIResponse<TraceListResponse>> {
|
|
78
|
-
return this.client.GET<TraceListResponse>("/v1/api/traces", {
|
|
79
|
-
params: { query: params },
|
|
80
|
-
headers: this.headers(),
|
|
81
|
-
});
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
/**
|
|
85
|
-
* Get a trace by ID.
|
|
86
|
-
*/
|
|
87
|
-
async get(traceId: string): Promise<APIResponse<TraceDetail>> {
|
|
88
|
-
return this.client.GET<TraceDetail>("/v1/api/traces/{id}", {
|
|
89
|
-
params: { path: { id: traceId } },
|
|
90
|
-
headers: this.headers(),
|
|
91
|
-
});
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
/**
|
|
95
|
-
* Get spans for a trace.
|
|
96
|
-
*/
|
|
97
|
-
async getSpans(traceId: string): Promise<APIResponse<SpanListResponse>> {
|
|
98
|
-
return this.client.GET<SpanListResponse>("/v1/api/traces/{id}/spans", {
|
|
99
|
-
params: { path: { id: traceId } },
|
|
100
|
-
headers: this.headers(),
|
|
101
|
-
});
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
/**
|
|
105
|
-
* Get all spans associated with a run.
|
|
106
|
-
* Maps to: GET /v1/api/traces/by-run/{runId}
|
|
107
|
-
*/
|
|
108
|
-
async getByRun(runId: string): Promise<APIResponse<SpansByRunResponse>> {
|
|
109
|
-
return this.client.GET<SpansByRunResponse>(`/v1/api/traces/by-run/${runId}`, {
|
|
110
|
-
headers: this.headers(),
|
|
111
|
-
});
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
/**
|
|
115
|
-
* Ingest spans (batch).
|
|
116
|
-
*/
|
|
117
|
-
async ingest(spans: SpanData[]): Promise<APIResponse<void>> {
|
|
118
|
-
return this.client.POST<void>("/v1/api/traces/ingest", {
|
|
119
|
-
body: { spans },
|
|
120
|
-
headers: this.headers(),
|
|
121
|
-
});
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
/**
|
|
125
|
-
* Add feedback to a span.
|
|
126
|
-
*/
|
|
127
|
-
async addFeedback(feedback: FeedbackRequest): Promise<APIResponse<void>> {
|
|
128
|
-
return this.client.POST<void>("/v1/api/traces/feedback", {
|
|
129
|
-
body: feedback,
|
|
130
|
-
headers: this.headers(),
|
|
131
|
-
});
|
|
132
|
-
}
|
|
133
|
-
}
|
package/src/modules/triggers.ts
DELETED
|
@@ -1,357 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Triggers Module - Wave 5 Aligned
|
|
3
|
-
*
|
|
4
|
-
* Provides typed access to trigger management and execution.
|
|
5
|
-
* Follows Law 065 (Security DTO Bifurcation) - secrets only via dedicated endpoint.
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
import type { RawClient, APIResponse } from "../client/raw.js";
|
|
9
|
-
|
|
10
|
-
// =============================================================================
|
|
11
|
-
// Types - Wave 5 Aligned
|
|
12
|
-
// =============================================================================
|
|
13
|
-
|
|
14
|
-
export type JsonSchema = Record<string, unknown>;
|
|
15
|
-
export type TriggerInputMappingSpec = Record<string, unknown>;
|
|
16
|
-
|
|
17
|
-
export interface Trigger {
|
|
18
|
-
id: string;
|
|
19
|
-
name: string;
|
|
20
|
-
workspace_id: string;
|
|
21
|
-
agent_id: string;
|
|
22
|
-
trigger_type: string; // String label, not union - frontend treats as display value
|
|
23
|
-
template_slug?: string;
|
|
24
|
-
is_active: boolean;
|
|
25
|
-
invoke_url: string;
|
|
26
|
-
request_contract?: TriggerRequestContract;
|
|
27
|
-
/** Custom configuration JSON (e.g., event filters, schedule cron, require_signature) */
|
|
28
|
-
config_json?: string;
|
|
29
|
-
/** JSON array of PayloadVariantConfig — defines accepted payload shapes */
|
|
30
|
-
payload_variants_json?: string;
|
|
31
|
-
/** ThreadKeySpec config: { json_path, required, fallback } */
|
|
32
|
-
thread_key_spec_json?: string;
|
|
33
|
-
/** IdempotencySpec config: { event_id_json_path, fallback } */
|
|
34
|
-
idempotency_spec_json?: string;
|
|
35
|
-
created_at: string;
|
|
36
|
-
updated_at: string | null;
|
|
37
|
-
// Law 065: webhook_secret REMOVED - use getSecret() for sensitive data
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
export interface TriggerRequestContract {
|
|
41
|
-
method: string;
|
|
42
|
-
invoke_url: string;
|
|
43
|
-
headers: Record<string, string>;
|
|
44
|
-
signing: SigningContract;
|
|
45
|
-
body_schema_json?: string;
|
|
46
|
-
example_payload_json?: string;
|
|
47
|
-
curl_example: string;
|
|
48
|
-
curl_command_parts?: {
|
|
49
|
-
method: string;
|
|
50
|
-
url: string;
|
|
51
|
-
headers: Record<string, string>;
|
|
52
|
-
body_json?: string | null;
|
|
53
|
-
} | null;
|
|
54
|
-
/** @deprecated Use body_schema_json */
|
|
55
|
-
body_schema?: Record<string, unknown>;
|
|
56
|
-
/** @deprecated Use example_payload_json */
|
|
57
|
-
example_payload?: Record<string, unknown>;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
export interface SigningContract {
|
|
61
|
-
algorithm: string;
|
|
62
|
-
signature_header: string;
|
|
63
|
-
timestamp_header: string;
|
|
64
|
-
timestamp_format: string;
|
|
65
|
-
string_to_sign: string;
|
|
66
|
-
signature_format: string;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
export interface TriggerSecretResponse {
|
|
70
|
-
id: string;
|
|
71
|
-
name: string;
|
|
72
|
-
secret_key: string;
|
|
73
|
-
invoke_url: string;
|
|
74
|
-
request_contract?: TriggerRequestContract;
|
|
75
|
-
created_at: string;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
export interface TestTriggerResponse {
|
|
79
|
-
run_id: string;
|
|
80
|
-
trigger_id: string;
|
|
81
|
-
agent_id: string;
|
|
82
|
-
status: string;
|
|
83
|
-
triggered_at: string;
|
|
84
|
-
reused: boolean;
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
export interface TriggerListResponse {
|
|
88
|
-
items: Trigger[];
|
|
89
|
-
total: number;
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
// =============================================================================
|
|
93
|
-
// Input Mapping Types (Wave 2)
|
|
94
|
-
// =============================================================================
|
|
95
|
-
|
|
96
|
-
export interface TriggerInputContractResponse {
|
|
97
|
-
trigger_id: string;
|
|
98
|
-
template_slug?: string;
|
|
99
|
-
external_body_schema?: JsonSchema;
|
|
100
|
-
run_input_schema?: JsonSchema;
|
|
101
|
-
effective_input_mapping_spec?: TriggerInputMappingSpec;
|
|
102
|
-
example_payload?: JsonSchema;
|
|
103
|
-
has_input_mapping: boolean;
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
export interface MappingValidationError {
|
|
107
|
-
code: string;
|
|
108
|
-
path?: string;
|
|
109
|
-
message: string;
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
export interface TestMappingResponse {
|
|
113
|
-
original_payload: unknown;
|
|
114
|
-
transformed_graph_input: unknown;
|
|
115
|
-
mapping_configured: boolean;
|
|
116
|
-
mapping_executed: boolean;
|
|
117
|
-
validation_errors?: MappingValidationError[];
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
export interface InferSchemaPathInfo {
|
|
121
|
-
path: string;
|
|
122
|
-
kind: string;
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
export interface InferSchemaResponse {
|
|
126
|
-
inferred_schema: JsonSchema;
|
|
127
|
-
paths: InferSchemaPathInfo[];
|
|
128
|
-
warnings: string[];
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
export interface SaveInputMappingResponse {
|
|
132
|
-
trigger_id: string;
|
|
133
|
-
input_mapping_override: TriggerInputMappingSpec;
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
export interface RegeneratedSecretResponse {
|
|
137
|
-
id: string;
|
|
138
|
-
secret_key: string;
|
|
139
|
-
regenerated_at: string;
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
// =============================================================================
|
|
143
|
-
// Module
|
|
144
|
-
// =============================================================================
|
|
145
|
-
|
|
146
|
-
export class TriggersModule {
|
|
147
|
-
constructor(private client: RawClient, private headers: () => Record<string, string>) { }
|
|
148
|
-
|
|
149
|
-
/**
|
|
150
|
-
* List all triggers (workspace-scoped).
|
|
151
|
-
*/
|
|
152
|
-
async list(params?: {
|
|
153
|
-
workspace_id?: string;
|
|
154
|
-
agent_id?: string;
|
|
155
|
-
trigger_type?: string;
|
|
156
|
-
limit?: number;
|
|
157
|
-
offset?: number;
|
|
158
|
-
}): Promise<APIResponse<TriggerListResponse>> {
|
|
159
|
-
return this.client.GET<TriggerListResponse>("/v1/api/triggers", {
|
|
160
|
-
params: { query: params },
|
|
161
|
-
headers: this.headers(),
|
|
162
|
-
});
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
/**
|
|
166
|
-
* List triggers for a specific agent.
|
|
167
|
-
* Convenience wrapper around list() with agent_id filter.
|
|
168
|
-
*/
|
|
169
|
-
async listByAgent(agentId: string): Promise<APIResponse<TriggerListResponse>> {
|
|
170
|
-
return this.list({ agent_id: agentId });
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
/**
|
|
174
|
-
* Get a trigger by ID.
|
|
175
|
-
*/
|
|
176
|
-
async get(triggerId: string): Promise<APIResponse<Trigger>> {
|
|
177
|
-
return this.client.GET<Trigger>("/v1/api/triggers/{id}", {
|
|
178
|
-
params: { path: { id: triggerId } },
|
|
179
|
-
headers: this.headers(),
|
|
180
|
-
});
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
/**
|
|
184
|
-
* Get trigger with secret (Law 065 - Security DTO).
|
|
185
|
-
* Use this when you need the webhook_secret for signing.
|
|
186
|
-
*/
|
|
187
|
-
async getSecret(triggerId: string): Promise<APIResponse<TriggerSecretResponse>> {
|
|
188
|
-
return this.client.GET<TriggerSecretResponse>("/v1/api/triggers/{id}/secret", {
|
|
189
|
-
params: { path: { id: triggerId } },
|
|
190
|
-
headers: this.headers(),
|
|
191
|
-
});
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
/**
|
|
195
|
-
* Create a new trigger.
|
|
196
|
-
* @example
|
|
197
|
-
* ```ts
|
|
198
|
-
* const { data: trigger } = await client.triggers.create({
|
|
199
|
-
* name: "My Webhook",
|
|
200
|
-
* agent_id: "agent-uuid",
|
|
201
|
-
* trigger_type: "webhook",
|
|
202
|
-
* idempotency_key: "create-trigger-unique-key"
|
|
203
|
-
* });
|
|
204
|
-
* ```
|
|
205
|
-
*/
|
|
206
|
-
async create(body: {
|
|
207
|
-
name: string;
|
|
208
|
-
agent_id: string;
|
|
209
|
-
trigger_type: string;
|
|
210
|
-
template_slug?: string;
|
|
211
|
-
config?: Record<string, unknown>;
|
|
212
|
-
/** Payload variant definitions (accepted webhook shapes) */
|
|
213
|
-
payload_variants_json?: unknown;
|
|
214
|
-
/** Thread key extraction spec */
|
|
215
|
-
thread_key_spec_json?: unknown;
|
|
216
|
-
/** Idempotency key extraction spec */
|
|
217
|
-
idempotency_spec_json?: unknown;
|
|
218
|
-
/** Idempotency key for safe retries. When set, duplicate requests with the same key return 409 Conflict. */
|
|
219
|
-
idempotency_key?: string;
|
|
220
|
-
}): Promise<APIResponse<Trigger>> {
|
|
221
|
-
const headers: Record<string, string> = { ...this.headers() };
|
|
222
|
-
if (body.idempotency_key) {
|
|
223
|
-
headers["X-Idempotency-Key"] = body.idempotency_key;
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
// Send body without idempotency_key (it's header-only)
|
|
227
|
-
const { idempotency_key, ...requestBody } = body;
|
|
228
|
-
|
|
229
|
-
return this.client.POST<Trigger>("/v1/api/triggers", {
|
|
230
|
-
body: requestBody,
|
|
231
|
-
headers,
|
|
232
|
-
});
|
|
233
|
-
}
|
|
234
|
-
|
|
235
|
-
/**
|
|
236
|
-
* Update a trigger.
|
|
237
|
-
*/
|
|
238
|
-
async update(triggerId: string, body: {
|
|
239
|
-
name?: string;
|
|
240
|
-
is_active?: boolean;
|
|
241
|
-
config?: Record<string, unknown>;
|
|
242
|
-
/** Payload variant definitions (accepted webhook shapes) */
|
|
243
|
-
payload_variants_json?: unknown;
|
|
244
|
-
/** Thread key extraction spec */
|
|
245
|
-
thread_key_spec_json?: unknown;
|
|
246
|
-
/** Idempotency key extraction spec */
|
|
247
|
-
idempotency_spec_json?: unknown;
|
|
248
|
-
}): Promise<APIResponse<Trigger>> {
|
|
249
|
-
return this.client.PATCH<Trigger>("/v1/api/triggers/{id}", {
|
|
250
|
-
params: { path: { id: triggerId } },
|
|
251
|
-
body,
|
|
252
|
-
headers: this.headers(),
|
|
253
|
-
});
|
|
254
|
-
}
|
|
255
|
-
|
|
256
|
-
/**
|
|
257
|
-
* Delete a trigger.
|
|
258
|
-
*/
|
|
259
|
-
async delete(triggerId: string): Promise<APIResponse<void>> {
|
|
260
|
-
return this.client.DELETE<void>("/v1/api/triggers/{id}", {
|
|
261
|
-
params: { path: { id: triggerId } },
|
|
262
|
-
headers: this.headers(),
|
|
263
|
-
});
|
|
264
|
-
}
|
|
265
|
-
|
|
266
|
-
/**
|
|
267
|
-
* Test a trigger (server-side execution).
|
|
268
|
-
* Avoids client-side secret exposure - server signs the request.
|
|
269
|
-
* @param triggerId - The trigger to test
|
|
270
|
-
* @param payload - Optional JSON payload (wrapped in { payload: ... } per backend contract)
|
|
271
|
-
* @param threadKey - Optional thread key for conversation context
|
|
272
|
-
* @param idempotencyKey - Optional idempotency key for deduplication
|
|
273
|
-
*/
|
|
274
|
-
async test(triggerId: string, payload?: unknown, threadKey?: string, idempotencyKey?: string): Promise<APIResponse<TestTriggerResponse>> {
|
|
275
|
-
return this.client.POST<TestTriggerResponse>("/v1/api/triggers/{id}/test", {
|
|
276
|
-
params: { path: { id: triggerId } },
|
|
277
|
-
body: {
|
|
278
|
-
payload: payload ?? undefined,
|
|
279
|
-
thread_key: threadKey ?? undefined,
|
|
280
|
-
idempotency_key: idempotencyKey ?? undefined,
|
|
281
|
-
},
|
|
282
|
-
headers: this.headers(),
|
|
283
|
-
});
|
|
284
|
-
}
|
|
285
|
-
|
|
286
|
-
/**
|
|
287
|
-
* Get the full input contract for a trigger.
|
|
288
|
-
* Returns schemas and mapping spec for transformation configuration.
|
|
289
|
-
*/
|
|
290
|
-
async getContract(triggerId: string): Promise<APIResponse<TriggerInputContractResponse>> {
|
|
291
|
-
return this.client.GET<TriggerInputContractResponse>("/v1/api/triggers/{id}/contract", {
|
|
292
|
-
params: { path: { id: triggerId } },
|
|
293
|
-
headers: this.headers(),
|
|
294
|
-
});
|
|
295
|
-
}
|
|
296
|
-
|
|
297
|
-
/**
|
|
298
|
-
* Test input mapping transformation without executing a run.
|
|
299
|
-
* Preview how a payload will be transformed before execution.
|
|
300
|
-
* @param triggerId - The trigger to test mapping for
|
|
301
|
-
* @param samplePayload - Sample payload to transform
|
|
302
|
-
*/
|
|
303
|
-
async testMapping(triggerId: string, samplePayload: unknown): Promise<APIResponse<TestMappingResponse>> {
|
|
304
|
-
return this.client.POST<TestMappingResponse>("/v1/api/triggers/{id}/test-mapping", {
|
|
305
|
-
params: { path: { id: triggerId } },
|
|
306
|
-
body: { sample_payload: samplePayload },
|
|
307
|
-
headers: this.headers(),
|
|
308
|
-
});
|
|
309
|
-
}
|
|
310
|
-
|
|
311
|
-
/**
|
|
312
|
-
* Regenerate the webhook secret for a trigger.
|
|
313
|
-
*/
|
|
314
|
-
async regenerateSecret(triggerId: string): Promise<APIResponse<RegeneratedSecretResponse>> {
|
|
315
|
-
return this.client.POST<RegeneratedSecretResponse>("/v1/api/triggers/{id}/regenerate-secret", {
|
|
316
|
-
params: { path: { id: triggerId } },
|
|
317
|
-
headers: this.headers(),
|
|
318
|
-
});
|
|
319
|
-
}
|
|
320
|
-
|
|
321
|
-
/**
|
|
322
|
-
* Infer schema from a sample payload.
|
|
323
|
-
*/
|
|
324
|
-
async inferSchema(triggerId: string, samplePayload: unknown): Promise<APIResponse<InferSchemaResponse>> {
|
|
325
|
-
return this.client.POST<InferSchemaResponse>("/v1/api/triggers/{id}/infer-schema", {
|
|
326
|
-
params: { path: { id: triggerId } },
|
|
327
|
-
body: { sample_payload: samplePayload },
|
|
328
|
-
headers: this.headers(),
|
|
329
|
-
});
|
|
330
|
-
}
|
|
331
|
-
|
|
332
|
-
/**
|
|
333
|
-
* Set/update the input mapping for a trigger.
|
|
334
|
-
*/
|
|
335
|
-
async putInputMapping(triggerId: string, inputMappingOverride: TriggerInputMappingSpec): Promise<APIResponse<SaveInputMappingResponse>> {
|
|
336
|
-
return this.client.PUT<SaveInputMappingResponse>("/v1/api/triggers/{id}/input-mapping", {
|
|
337
|
-
params: { path: { id: triggerId } },
|
|
338
|
-
body: { input_mapping_override: inputMappingOverride },
|
|
339
|
-
headers: this.headers(),
|
|
340
|
-
});
|
|
341
|
-
}
|
|
342
|
-
|
|
343
|
-
/**
|
|
344
|
-
* Preview input mapping transformation result.
|
|
345
|
-
*/
|
|
346
|
-
async previewInputMapping(
|
|
347
|
-
triggerId: string,
|
|
348
|
-
samplePayload: unknown,
|
|
349
|
-
inputMappingOverride: TriggerInputMappingSpec
|
|
350
|
-
): Promise<APIResponse<TestMappingResponse>> {
|
|
351
|
-
return this.client.POST<TestMappingResponse>("/v1/api/triggers/{id}/preview-input-mapping", {
|
|
352
|
-
params: { path: { id: triggerId } },
|
|
353
|
-
body: { sample_payload: samplePayload, input_mapping_override: inputMappingOverride },
|
|
354
|
-
headers: this.headers(),
|
|
355
|
-
});
|
|
356
|
-
}
|
|
357
|
-
}
|
package/src/modules/usage.ts
DELETED
|
@@ -1,117 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Usage Module — Tenant-level usage metrics and quotas.
|
|
3
|
-
*
|
|
4
|
-
* Endpoints: GET /v1/api/quotas, GET /v1/api/usage
|
|
5
|
-
* Source: runtime.cost_events aggregation
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
import type { RawClient, APIResponse } from "../client/raw.js";
|
|
9
|
-
|
|
10
|
-
// =============================================================================
|
|
11
|
-
// Types
|
|
12
|
-
// =============================================================================
|
|
13
|
-
|
|
14
|
-
export interface QuotaItem {
|
|
15
|
-
limit: number;
|
|
16
|
-
used: number;
|
|
17
|
-
remaining: number;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export interface QuotasResponse {
|
|
21
|
-
tenant_id: string;
|
|
22
|
-
workspace_id?: string;
|
|
23
|
-
quotas: {
|
|
24
|
-
runs_per_month: QuotaItem;
|
|
25
|
-
tokens_per_month: QuotaItem;
|
|
26
|
-
agents_max: QuotaItem;
|
|
27
|
-
storage_mb: QuotaItem;
|
|
28
|
-
};
|
|
29
|
-
reset_at: string;
|
|
30
|
-
source: string;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
export interface UsageAggregated {
|
|
34
|
-
total_runs: number;
|
|
35
|
-
completed_runs: number;
|
|
36
|
-
failed_runs: number;
|
|
37
|
-
llm_events: number;
|
|
38
|
-
total_tokens: number;
|
|
39
|
-
input_tokens: number;
|
|
40
|
-
output_tokens: number;
|
|
41
|
-
total_duration_ms: number;
|
|
42
|
-
estimated_count: number;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
export interface DailyBreakdownItem {
|
|
46
|
-
date: string;
|
|
47
|
-
runs: number;
|
|
48
|
-
llm_events: number;
|
|
49
|
-
tokens_in: number;
|
|
50
|
-
tokens_out: number;
|
|
51
|
-
duration_ms: number;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
export interface ProviderBreakdownItem {
|
|
55
|
-
provider: string;
|
|
56
|
-
runs: number;
|
|
57
|
-
llm_events: number;
|
|
58
|
-
tokens: number;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
export interface UsageResponse {
|
|
62
|
-
tenant_id: string;
|
|
63
|
-
workspace_id?: string;
|
|
64
|
-
period: { from: string; to: string };
|
|
65
|
-
usage: UsageAggregated;
|
|
66
|
-
daily_breakdown: DailyBreakdownItem[];
|
|
67
|
-
provider_breakdown: ProviderBreakdownItem[];
|
|
68
|
-
source: string;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
// =============================================================================
|
|
72
|
-
// Module
|
|
73
|
-
// =============================================================================
|
|
74
|
-
|
|
75
|
-
export class UsageModule {
|
|
76
|
-
constructor(private client: RawClient, private headers: () => Record<string, string>) { }
|
|
77
|
-
|
|
78
|
-
/**
|
|
79
|
-
* Get current quota status (tenant-level).
|
|
80
|
-
*/
|
|
81
|
-
async getQuotas(params?: {
|
|
82
|
-
workspaceId?: string;
|
|
83
|
-
/** @deprecated Use workspaceId */
|
|
84
|
-
workspace_id?: string;
|
|
85
|
-
}): Promise<APIResponse<QuotasResponse>> {
|
|
86
|
-
const query = {
|
|
87
|
-
workspaceId: params?.workspaceId ?? params?.workspace_id,
|
|
88
|
-
};
|
|
89
|
-
|
|
90
|
-
return this.client.GET<QuotasResponse>("/v1/api/quotas", {
|
|
91
|
-
params: { query },
|
|
92
|
-
headers: this.headers(),
|
|
93
|
-
});
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
/**
|
|
97
|
-
* Get usage metrics with real data from runtime.cost_events.
|
|
98
|
-
*/
|
|
99
|
-
async getUsage(params?: {
|
|
100
|
-
workspaceId?: string;
|
|
101
|
-
/** @deprecated Use workspaceId */
|
|
102
|
-
workspace_id?: string;
|
|
103
|
-
from?: string;
|
|
104
|
-
to?: string;
|
|
105
|
-
}): Promise<APIResponse<UsageResponse>> {
|
|
106
|
-
const query = {
|
|
107
|
-
workspaceId: params?.workspaceId ?? params?.workspace_id,
|
|
108
|
-
from: params?.from,
|
|
109
|
-
to: params?.to,
|
|
110
|
-
};
|
|
111
|
-
|
|
112
|
-
return this.client.GET<UsageResponse>("/v1/api/usage", {
|
|
113
|
-
params: { query },
|
|
114
|
-
headers: this.headers(),
|
|
115
|
-
});
|
|
116
|
-
}
|
|
117
|
-
}
|