@cadenya/cadenya 1.0.2 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/api.md +45 -45
- package/dist/client.d.ts +2 -2
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +4 -4
- package/dist/client.js.map +1 -1
- package/dist/core/http.d.ts +6 -1
- package/dist/core/http.d.ts.map +1 -1
- package/dist/core/http.js +33 -6
- package/dist/core/http.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/resources/agent-variations.d.ts +42 -32
- package/dist/resources/agent-variations.d.ts.map +1 -1
- package/dist/resources/agent-variations.js +22 -20
- package/dist/resources/agent-variations.js.map +1 -1
- package/dist/resources/agents.d.ts +4 -2
- package/dist/resources/agents.d.ts.map +1 -1
- package/dist/resources/agents.js +1 -1
- package/dist/resources/agents.js.map +1 -1
- package/dist/resources/ai-provider-keys.d.ts +11 -1
- package/dist/resources/ai-provider-keys.d.ts.map +1 -1
- package/dist/resources/ai-provider-keys.js +2 -2
- package/dist/resources/ai-provider-keys.js.map +1 -1
- package/dist/resources/memory-layers.d.ts +1 -1
- package/dist/resources/memory-layers.js +1 -1
- package/dist/resources/memory-layers.js.map +1 -1
- package/dist/resources/models.d.ts +51 -1
- package/dist/resources/models.d.ts.map +1 -1
- package/dist/resources/models.js +32 -0
- package/dist/resources/models.js.map +1 -1
- package/dist/resources/objectives.d.ts +1 -46
- package/dist/resources/objectives.d.ts.map +1 -1
- package/dist/resources/objectives.js +0 -35
- package/dist/resources/objectives.js.map +1 -1
- package/dist/resources/tool-search.d.ts +1 -1
- package/dist/resources/tool-search.js +1 -1
- package/dist/resources/tool-search.js.map +1 -1
- package/dist/resources/tools.d.ts +1 -1
- package/dist/resources/tools.js +1 -1
- package/dist/resources/tools.js.map +1 -1
- package/dist/types.d.ts +449 -100
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +40 -0
- package/dist/types.js.map +1 -1
- package/dist/webhooks.d.ts +7 -1
- package/dist/webhooks.d.ts.map +1 -1
- package/dist/webhooks.js.map +1 -1
- package/package.json +1 -1
- package/src/client.ts +4 -4
- package/src/core/http.ts +45 -6
- package/src/index.ts +1 -1
- package/src/resources/agent-variations.ts +59 -47
- package/src/resources/agents.ts +4 -2
- package/src/resources/ai-provider-keys.ts +13 -3
- package/src/resources/memory-layers.ts +1 -1
- package/src/resources/models.ts +67 -1
- package/src/resources/objectives.ts +1 -62
- package/src/resources/tool-search.ts +1 -1
- package/src/resources/tools.ts +1 -1
- package/src/types.ts +517 -103
- package/src/webhooks.ts +7 -1
package/dist/webhooks.d.ts
CHANGED
|
@@ -78,7 +78,13 @@ export type ObjectiveEventMemoryReadWebhookEvent = ObjectiveEventWebhookData & {
|
|
|
78
78
|
export type ObjectiveEventReasoningWebhookEvent = ObjectiveEventWebhookData & {
|
|
79
79
|
type: 'objective_event.reasoning';
|
|
80
80
|
};
|
|
81
|
-
|
|
81
|
+
/**
|
|
82
|
+
* Objective state changed event
|
|
83
|
+
*/
|
|
84
|
+
export type ObjectiveEventStateChangedWebhookEvent = ObjectiveEventWebhookData & {
|
|
85
|
+
type: 'objective_event.state_changed';
|
|
86
|
+
};
|
|
87
|
+
export type UnwrapWebhookEvent = ObjectiveEventUserMessageWebhookEvent | ObjectiveEventAssistantMessageWebhookEvent | ObjectiveEventToolResultWebhookEvent | ObjectiveEventToolApprovalRequestedWebhookEvent | ObjectiveEventToolCalledWebhookEvent | ObjectiveEventToolApprovedWebhookEvent | ObjectiveEventToolDeniedWebhookEvent | ObjectiveEventToolErrorWebhookEvent | ObjectiveEventSubAgentSpawnedWebhookEvent | ObjectiveEventSubAgentUpdatedWebhookEvent | ObjectiveEventErrorWebhookEvent | ObjectiveEventMemoryReadWebhookEvent | ObjectiveEventReasoningWebhookEvent | ObjectiveEventStateChangedWebhookEvent;
|
|
82
88
|
export declare class Webhooks {
|
|
83
89
|
private readonly secret;
|
|
84
90
|
constructor(secret: string | undefined);
|
package/dist/webhooks.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webhooks.d.ts","sourceRoot":"","sources":["../src/webhooks.ts"],"names":[],"mappings":"AAEA,OAAO,EAAmB,cAAc,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAC3F,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,YAAY,CAAC;AAE5D;;GAEG;AACH,MAAM,MAAM,qCAAqC,GAAG,yBAAyB,GAAG;IAAE,IAAI,EAAE,8BAA8B,CAAA;CAAE,CAAC;AAEzH;;GAEG;AACH,MAAM,MAAM,0CAA0C,GAAG,yBAAyB,GAAG;IAAE,IAAI,EAAE,mCAAmC,CAAA;CAAE,CAAC;AAEnI;;GAEG;AACH,MAAM,MAAM,oCAAoC,GAAG,yBAAyB,GAAG;IAAE,IAAI,EAAE,6BAA6B,CAAA;CAAE,CAAC;AAEvH;;GAEG;AACH,MAAM,MAAM,+CAA+C,GAAG,yBAAyB,GAAG;IAAE,IAAI,EAAE,yCAAyC,CAAA;CAAE,CAAC;AAE9I;;GAEG;AACH,MAAM,MAAM,oCAAoC,GAAG,yBAAyB,GAAG;IAAE,IAAI,EAAE,6BAA6B,CAAA;CAAE,CAAC;AAEvH;;GAEG;AACH,MAAM,MAAM,sCAAsC,GAAG,yBAAyB,GAAG;IAAE,IAAI,EAAE,+BAA+B,CAAA;CAAE,CAAC;AAE3H;;GAEG;AACH,MAAM,MAAM,oCAAoC,GAAG,yBAAyB,GAAG;IAAE,IAAI,EAAE,6BAA6B,CAAA;CAAE,CAAC;AAEvH;;GAEG;AACH,MAAM,MAAM,mCAAmC,GAAG,yBAAyB,GAAG;IAAE,IAAI,EAAE,4BAA4B,CAAA;CAAE,CAAC;AAErH;;GAEG;AACH,MAAM,MAAM,yCAAyC,GAAG,yBAAyB,GAAG;IAAE,IAAI,EAAE,mCAAmC,CAAA;CAAE,CAAC;AAElI;;GAEG;AACH,MAAM,MAAM,yCAAyC,GAAG,yBAAyB,GAAG;IAAE,IAAI,EAAE,mCAAmC,CAAA;CAAE,CAAC;AAElI;;GAEG;AACH,MAAM,MAAM,+BAA+B,GAAG,yBAAyB,GAAG;IAAE,IAAI,EAAE,uBAAuB,CAAA;CAAE,CAAC;AAE5G;;GAEG;AACH,MAAM,MAAM,oCAAoC,GAAG,yBAAyB,GAAG;IAAE,IAAI,EAAE,6BAA6B,CAAA;CAAE,CAAC;AAEvH;;GAEG;AACH,MAAM,MAAM,mCAAmC,GAAG,yBAAyB,GAAG;IAAE,IAAI,EAAE,2BAA2B,CAAA;CAAE,CAAC;AAEpH,MAAM,MAAM,kBAAkB,GAC1B,qCAAqC,GACrC,0CAA0C,GAC1C,oCAAoC,GACpC,+CAA+C,GAC/C,oCAAoC,GACpC,sCAAsC,GACtC,oCAAoC,GACpC,mCAAmC,GACnC,yCAAyC,GACzC,yCAAyC,GACzC,+BAA+B,GAC/B,oCAAoC,GACpC,mCAAmC,CAAC;
|
|
1
|
+
{"version":3,"file":"webhooks.d.ts","sourceRoot":"","sources":["../src/webhooks.ts"],"names":[],"mappings":"AAEA,OAAO,EAAmB,cAAc,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAC3F,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,YAAY,CAAC;AAE5D;;GAEG;AACH,MAAM,MAAM,qCAAqC,GAAG,yBAAyB,GAAG;IAAE,IAAI,EAAE,8BAA8B,CAAA;CAAE,CAAC;AAEzH;;GAEG;AACH,MAAM,MAAM,0CAA0C,GAAG,yBAAyB,GAAG;IAAE,IAAI,EAAE,mCAAmC,CAAA;CAAE,CAAC;AAEnI;;GAEG;AACH,MAAM,MAAM,oCAAoC,GAAG,yBAAyB,GAAG;IAAE,IAAI,EAAE,6BAA6B,CAAA;CAAE,CAAC;AAEvH;;GAEG;AACH,MAAM,MAAM,+CAA+C,GAAG,yBAAyB,GAAG;IAAE,IAAI,EAAE,yCAAyC,CAAA;CAAE,CAAC;AAE9I;;GAEG;AACH,MAAM,MAAM,oCAAoC,GAAG,yBAAyB,GAAG;IAAE,IAAI,EAAE,6BAA6B,CAAA;CAAE,CAAC;AAEvH;;GAEG;AACH,MAAM,MAAM,sCAAsC,GAAG,yBAAyB,GAAG;IAAE,IAAI,EAAE,+BAA+B,CAAA;CAAE,CAAC;AAE3H;;GAEG;AACH,MAAM,MAAM,oCAAoC,GAAG,yBAAyB,GAAG;IAAE,IAAI,EAAE,6BAA6B,CAAA;CAAE,CAAC;AAEvH;;GAEG;AACH,MAAM,MAAM,mCAAmC,GAAG,yBAAyB,GAAG;IAAE,IAAI,EAAE,4BAA4B,CAAA;CAAE,CAAC;AAErH;;GAEG;AACH,MAAM,MAAM,yCAAyC,GAAG,yBAAyB,GAAG;IAAE,IAAI,EAAE,mCAAmC,CAAA;CAAE,CAAC;AAElI;;GAEG;AACH,MAAM,MAAM,yCAAyC,GAAG,yBAAyB,GAAG;IAAE,IAAI,EAAE,mCAAmC,CAAA;CAAE,CAAC;AAElI;;GAEG;AACH,MAAM,MAAM,+BAA+B,GAAG,yBAAyB,GAAG;IAAE,IAAI,EAAE,uBAAuB,CAAA;CAAE,CAAC;AAE5G;;GAEG;AACH,MAAM,MAAM,oCAAoC,GAAG,yBAAyB,GAAG;IAAE,IAAI,EAAE,6BAA6B,CAAA;CAAE,CAAC;AAEvH;;GAEG;AACH,MAAM,MAAM,mCAAmC,GAAG,yBAAyB,GAAG;IAAE,IAAI,EAAE,2BAA2B,CAAA;CAAE,CAAC;AAEpH;;GAEG;AACH,MAAM,MAAM,sCAAsC,GAAG,yBAAyB,GAAG;IAAE,IAAI,EAAE,+BAA+B,CAAA;CAAE,CAAC;AAE3H,MAAM,MAAM,kBAAkB,GAC1B,qCAAqC,GACrC,0CAA0C,GAC1C,oCAAoC,GACpC,+CAA+C,GAC/C,oCAAoC,GACpC,sCAAsC,GACtC,oCAAoC,GACpC,mCAAmC,GACnC,yCAAyC,GACzC,yCAAyC,GACzC,+BAA+B,GAC/B,oCAAoC,GACpC,mCAAmC,GACnC,sCAAsC,CAAC;AAE3C,qBAAa,QAAQ;IACP,OAAO,CAAC,QAAQ,CAAC,MAAM;gBAAN,MAAM,EAAE,MAAM,GAAG,SAAS;IAEvD;;;OAGG;IACG,MAAM,CACV,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,cAAc,EACvB,OAAO,CAAC,EAAE,oBAAoB,GAAG;QAAE,MAAM,CAAC,EAAE,MAAM,CAAA;KAAE,GACnD,OAAO,CAAC,kBAAkB,CAAC;CAU/B"}
|
package/dist/webhooks.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webhooks.js","sourceRoot":"","sources":["../src/webhooks.ts"],"names":[],"mappings":"AAAA,6CAA6C;AAE7C,OAAO,EAAE,eAAe,EAAwC,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"webhooks.js","sourceRoot":"","sources":["../src/webhooks.ts"],"names":[],"mappings":"AAAA,6CAA6C;AAE7C,OAAO,EAAE,eAAe,EAAwC,MAAM,oBAAoB,CAAC;AAyF3F,MAAM,OAAO,QAAQ;IACU;IAA7B,YAA6B,MAA0B;QAA1B,WAAM,GAAN,MAAM,CAAoB;IAAG,CAAC;IAE3D;;;OAGG;IACH,KAAK,CAAC,MAAM,CACV,OAAe,EACf,OAAuB,EACvB,OAAoD;QAEpD,MAAM,MAAM,GAAG,CAAC,OAAO,EAAE,MAAM,IAAI,IAAI,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,CAAC;QACxD,IAAI,CAAC,MAAM,EAAE,CAAC;YACZ,MAAM,IAAI,KAAK,CACb,2IAA2I,CAC5I,CAAC;QACJ,CAAC;QACD,MAAM,IAAI,eAAe,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,OAAO,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;QACpE,OAAO,IAAI,CAAC,KAAK,CAAC,OAAO,CAAuB,CAAC;IACnD,CAAC;CACF","sourcesContent":["// Generated by redwood. Do not edit by hand.\n\nimport { WebhookVerifier, WebhookHeaders, WebhookVerifyOptions } from './core/webhooks.js';\nimport type { ObjectiveEventWebhookData } from './types.js';\n\n/**\n * Objective user message event\n */\nexport type ObjectiveEventUserMessageWebhookEvent = ObjectiveEventWebhookData & { type: 'objective_event.user_message' };\n\n/**\n * Objective assistant message event\n */\nexport type ObjectiveEventAssistantMessageWebhookEvent = ObjectiveEventWebhookData & { type: 'objective_event.assistant_message' };\n\n/**\n * Objective tool result event\n */\nexport type ObjectiveEventToolResultWebhookEvent = ObjectiveEventWebhookData & { type: 'objective_event.tool_result' };\n\n/**\n * Objective tool approval requested event\n */\nexport type ObjectiveEventToolApprovalRequestedWebhookEvent = ObjectiveEventWebhookData & { type: 'objective_event.tool_approval_requested' };\n\n/**\n * Objective tool called event\n */\nexport type ObjectiveEventToolCalledWebhookEvent = ObjectiveEventWebhookData & { type: 'objective_event.tool_called' };\n\n/**\n * Objective tool approved event\n */\nexport type ObjectiveEventToolApprovedWebhookEvent = ObjectiveEventWebhookData & { type: 'objective_event.tool_approved' };\n\n/**\n * Objective tool denied event\n */\nexport type ObjectiveEventToolDeniedWebhookEvent = ObjectiveEventWebhookData & { type: 'objective_event.tool_denied' };\n\n/**\n * Objective tool error event\n */\nexport type ObjectiveEventToolErrorWebhookEvent = ObjectiveEventWebhookData & { type: 'objective_event.tool_error' };\n\n/**\n * Objective sub-agent spawned event\n */\nexport type ObjectiveEventSubAgentSpawnedWebhookEvent = ObjectiveEventWebhookData & { type: 'objective_event.sub_agent_spawned' };\n\n/**\n * Objective sub-agent updated event\n */\nexport type ObjectiveEventSubAgentUpdatedWebhookEvent = ObjectiveEventWebhookData & { type: 'objective_event.sub_agent_updated' };\n\n/**\n * Objective error event\n */\nexport type ObjectiveEventErrorWebhookEvent = ObjectiveEventWebhookData & { type: 'objective_event.error' };\n\n/**\n * Objective memory read event\n */\nexport type ObjectiveEventMemoryReadWebhookEvent = ObjectiveEventWebhookData & { type: 'objective_event.memory_read' };\n\n/**\n * Objective reasoning event\n */\nexport type ObjectiveEventReasoningWebhookEvent = ObjectiveEventWebhookData & { type: 'objective_event.reasoning' };\n\n/**\n * Objective state changed event\n */\nexport type ObjectiveEventStateChangedWebhookEvent = ObjectiveEventWebhookData & { type: 'objective_event.state_changed' };\n\nexport type UnwrapWebhookEvent =\n | ObjectiveEventUserMessageWebhookEvent\n | ObjectiveEventAssistantMessageWebhookEvent\n | ObjectiveEventToolResultWebhookEvent\n | ObjectiveEventToolApprovalRequestedWebhookEvent\n | ObjectiveEventToolCalledWebhookEvent\n | ObjectiveEventToolApprovedWebhookEvent\n | ObjectiveEventToolDeniedWebhookEvent\n | ObjectiveEventToolErrorWebhookEvent\n | ObjectiveEventSubAgentSpawnedWebhookEvent\n | ObjectiveEventSubAgentUpdatedWebhookEvent\n | ObjectiveEventErrorWebhookEvent\n | ObjectiveEventMemoryReadWebhookEvent\n | ObjectiveEventReasoningWebhookEvent\n | ObjectiveEventStateChangedWebhookEvent;\n\nexport class Webhooks {\n constructor(private readonly secret: string | undefined) {}\n\n /**\n * Verify a Standard Webhooks delivery (webhook-id / webhook-timestamp /\n * webhook-signature headers) and return its typed payload.\n */\n async unwrap(\n payload: string,\n headers: WebhookHeaders,\n options?: WebhookVerifyOptions & { secret?: string },\n ): Promise<UnwrapWebhookEvent> {\n const secret = (options?.secret ?? this.secret)?.trim();\n if (!secret) {\n throw new Error(\n \"Missing webhook secret. Pass { secret }, construct the client with webhookSecret, or set the CADENYA_WEBHOOK_SECRET environment variable.\",\n );\n }\n await new WebhookVerifier(secret).verify(payload, headers, options);\n return JSON.parse(payload) as UnwrapWebhookEvent;\n }\n}\n"]}
|
package/package.json
CHANGED
package/src/client.ts
CHANGED
|
@@ -10,8 +10,8 @@ import { Profiles } from './resources/profiles.js';
|
|
|
10
10
|
import { Workspaces } from './resources/workspaces.js';
|
|
11
11
|
import { Agents } from './resources/agents.js';
|
|
12
12
|
import { AiProviderKeys } from './resources/ai-provider-keys.js';
|
|
13
|
-
import { MemoryLayers } from './resources/memory-layers.js';
|
|
14
13
|
import { Models } from './resources/models.js';
|
|
14
|
+
import { MemoryLayers } from './resources/memory-layers.js';
|
|
15
15
|
import { Objectives } from './resources/objectives.js';
|
|
16
16
|
import { ToolSearch } from './resources/tool-search.js';
|
|
17
17
|
import { Tenants } from './resources/tenants.js';
|
|
@@ -57,8 +57,8 @@ export class Cadenya {
|
|
|
57
57
|
readonly workspaces: Workspaces;
|
|
58
58
|
readonly agents: Agents;
|
|
59
59
|
readonly aiProviderKeys: AiProviderKeys;
|
|
60
|
-
readonly memoryLayers: MemoryLayers;
|
|
61
60
|
readonly models: Models;
|
|
61
|
+
readonly memoryLayers: MemoryLayers;
|
|
62
62
|
readonly objectives: Objectives;
|
|
63
63
|
readonly toolSearch: ToolSearch;
|
|
64
64
|
readonly tenants: Tenants;
|
|
@@ -85,7 +85,7 @@ export class Cadenya {
|
|
|
85
85
|
authHeader: () => ({ Authorization: `Bearer ${apiKey}` }),
|
|
86
86
|
maxRetries: options.maxRetries ?? 0,
|
|
87
87
|
timeout: options.timeout,
|
|
88
|
-
defaultHeaders: { 'User-Agent': 'cadenya-typescript/1.0
|
|
88
|
+
defaultHeaders: { 'User-Agent': 'cadenya-typescript/1.2.0 (api 1.0)', ...options.defaultHeaders },
|
|
89
89
|
fetch: options.fetch,
|
|
90
90
|
logger: options.logger,
|
|
91
91
|
logLevel: options.logLevel,
|
|
@@ -99,8 +99,8 @@ export class Cadenya {
|
|
|
99
99
|
this.workspaces = new Workspaces(this._client);
|
|
100
100
|
this.agents = new Agents(this._client);
|
|
101
101
|
this.aiProviderKeys = new AiProviderKeys(this._client);
|
|
102
|
-
this.memoryLayers = new MemoryLayers(this._client);
|
|
103
102
|
this.models = new Models(this._client);
|
|
103
|
+
this.memoryLayers = new MemoryLayers(this._client);
|
|
104
104
|
this.objectives = new Objectives(this._client);
|
|
105
105
|
this.toolSearch = new ToolSearch(this._client);
|
|
106
106
|
this.tenants = new Tenants(this._client);
|
package/src/core/http.ts
CHANGED
|
@@ -38,7 +38,12 @@ export interface RequestOptions {
|
|
|
38
38
|
}
|
|
39
39
|
|
|
40
40
|
export type QueryPrimitive = string | number | boolean;
|
|
41
|
-
|
|
41
|
+
/**
|
|
42
|
+
* Query objects are flattened to dot-delimited paths. `object` is used here
|
|
43
|
+
* deliberately so generated named interfaces (which do not declare an index
|
|
44
|
+
* signature) remain assignable as query parameter values.
|
|
45
|
+
*/
|
|
46
|
+
export type QueryValue = QueryPrimitive | readonly QueryPrimitive[] | object | undefined | null;
|
|
42
47
|
|
|
43
48
|
export interface RequestSpec {
|
|
44
49
|
method: 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE';
|
|
@@ -589,17 +594,51 @@ export class HttpClient {
|
|
|
589
594
|
|
|
590
595
|
private buildURL(path: string, query?: Record<string, QueryValue>): string {
|
|
591
596
|
const url = new URL(this.baseURL + path);
|
|
597
|
+
const ancestors = new Set<object>();
|
|
592
598
|
for (const [key, value] of Object.entries(query ?? {})) {
|
|
593
|
-
|
|
594
|
-
// Arrays serialize as repeated params: ?state=a&state=b
|
|
595
|
-
for (const item of Array.isArray(value) ? value : [value]) {
|
|
596
|
-
url.searchParams.append(key, String(item));
|
|
597
|
-
}
|
|
599
|
+
appendQueryValue(url.searchParams, key, value, ancestors);
|
|
598
600
|
}
|
|
599
601
|
return url.toString();
|
|
600
602
|
}
|
|
601
603
|
}
|
|
602
604
|
|
|
605
|
+
/**
|
|
606
|
+
* Flatten nested query objects to dot-delimited paths. Arrays retain the
|
|
607
|
+
* existing repeated-parameter behavior at whichever path they occur:
|
|
608
|
+
* `{ filters: { state: ['a', 'b'] } }` becomes
|
|
609
|
+
* `?filters.state=a&filters.state=b`.
|
|
610
|
+
*/
|
|
611
|
+
function appendQueryValue(
|
|
612
|
+
searchParams: URLSearchParams,
|
|
613
|
+
key: string,
|
|
614
|
+
value: unknown,
|
|
615
|
+
ancestors: Set<object>,
|
|
616
|
+
): void {
|
|
617
|
+
if (value === undefined || value === null) return;
|
|
618
|
+
|
|
619
|
+
if (typeof value !== 'object') {
|
|
620
|
+
searchParams.append(key, String(value));
|
|
621
|
+
return;
|
|
622
|
+
}
|
|
623
|
+
|
|
624
|
+
if (ancestors.has(value)) {
|
|
625
|
+
throw new APIRequestError('query parameters contain a circular reference', undefined);
|
|
626
|
+
}
|
|
627
|
+
ancestors.add(value);
|
|
628
|
+
try {
|
|
629
|
+
if (Array.isArray(value)) {
|
|
630
|
+
for (const item of value) appendQueryValue(searchParams, key, item, ancestors);
|
|
631
|
+
return;
|
|
632
|
+
}
|
|
633
|
+
|
|
634
|
+
for (const [childKey, childValue] of Object.entries(value)) {
|
|
635
|
+
appendQueryValue(searchParams, `${key}.${childKey}`, childValue, ancestors);
|
|
636
|
+
}
|
|
637
|
+
} finally {
|
|
638
|
+
ancestors.delete(value);
|
|
639
|
+
}
|
|
640
|
+
}
|
|
641
|
+
|
|
603
642
|
/** Retry counts must be bounded non-negative integers; anything else (NaN,
|
|
604
643
|
* Infinity, negatives, fractions) is treated as the nearest sane value. */
|
|
605
644
|
function normalizeRetries(value: number): number {
|
package/src/index.ts
CHANGED
|
@@ -21,9 +21,9 @@ export * from './resources/agents.js';
|
|
|
21
21
|
export * from './resources/agent-schedules.js';
|
|
22
22
|
export * from './resources/agent-variations.js';
|
|
23
23
|
export * from './resources/ai-provider-keys.js';
|
|
24
|
+
export * from './resources/models.js';
|
|
24
25
|
export * from './resources/memory-layers.js';
|
|
25
26
|
export * from './resources/memory-entries.js';
|
|
26
|
-
export * from './resources/models.js';
|
|
27
27
|
export * from './resources/objectives.js';
|
|
28
28
|
export * from './resources/tool-search.js';
|
|
29
29
|
export * from './resources/tenants.js';
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
import { HttpClient, RequestOptions, APIPromise, pathSegment, snapshotParams } from '../core/http.js';
|
|
4
4
|
import { Page } from '../core/pagination.js';
|
|
5
|
-
import type { AddAgentVariationAssignmentRequestParam, AgentVariation, AgentVariationSpec, CreateResourceMetadata, ListAgentVariationsResponse,
|
|
6
|
-
import { wireAddAgentVariationAssignmentRequest } from '../types.js';
|
|
5
|
+
import type { AddAgentVariationAssignmentRequestParam, AgentVariation, AgentVariationSpec, CreateResourceMetadata, ListAgentVariationsResponse, RemoveAgentVariationAssignmentRequestParam, UpdateResourceMetadata } from '../types.js';
|
|
6
|
+
import { wireAddAgentVariationAssignmentRequest, wireRemoveAgentVariationAssignmentRequest } from '../types.js';
|
|
7
7
|
|
|
8
8
|
export interface AgentVariationListParams {
|
|
9
9
|
/**
|
|
@@ -76,32 +76,25 @@ export interface AgentVariationUpdateParams {
|
|
|
76
76
|
metadata?: UpdateResourceMetadata;
|
|
77
77
|
spec?: AgentVariationSpec;
|
|
78
78
|
/**
|
|
79
|
-
* Fields to update
|
|
79
|
+
* Fields to update. Assignment lists are replaced as a whole, never merged.
|
|
80
|
+
* Select spec.assignments or spec.memory_layer_assignments to replace/clear
|
|
81
|
+
* one list. Selecting spec replaces the entire spec (including omitted lists);
|
|
82
|
+
* * replaces all mutable fields. Element/index paths are not supported.
|
|
83
|
+
* Without a mask, infer paths from non-empty fields: non-empty assignment
|
|
84
|
+
* lists replace existing lists, while omitted/empty lists remain unchanged.
|
|
85
|
+
* To clear a list, explicitly include its path in the mask.
|
|
80
86
|
*/
|
|
81
87
|
updateMask?: string;
|
|
82
88
|
}
|
|
83
89
|
|
|
84
|
-
export
|
|
85
|
-
/**
|
|
86
|
-
* The request body, sent as-is.
|
|
87
|
-
*/
|
|
88
|
-
body: AddAgentVariationAssignmentRequestParam;
|
|
89
|
-
/**
|
|
90
|
-
* Workspace ID.
|
|
91
|
-
*
|
|
92
|
-
* Defaults to the client-level `workspaceId` option or the CADENYA_WORKSPACE_ID environment variable.
|
|
93
|
-
*/
|
|
94
|
-
workspaceId?: string;
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
export interface AgentVariationRemoveAssignmentParams {
|
|
90
|
+
export type AgentVariationAddAssignmentParams = AddAgentVariationAssignmentRequestParam & {
|
|
98
91
|
/**
|
|
99
92
|
* Workspace ID.
|
|
100
93
|
*
|
|
101
94
|
* Defaults to the client-level `workspaceId` option or the CADENYA_WORKSPACE_ID environment variable.
|
|
102
95
|
*/
|
|
103
96
|
workspaceId?: string;
|
|
104
|
-
}
|
|
97
|
+
};
|
|
105
98
|
|
|
106
99
|
export interface AgentVariationAddMemoryLayerParams {
|
|
107
100
|
/**
|
|
@@ -122,26 +115,43 @@ export interface AgentVariationAddMemoryLayerParams {
|
|
|
122
115
|
position?: number;
|
|
123
116
|
}
|
|
124
117
|
|
|
125
|
-
export
|
|
118
|
+
export type AgentVariationRemoveAssignmentParams = RemoveAgentVariationAssignmentRequestParam & {
|
|
126
119
|
/**
|
|
127
120
|
* Workspace ID.
|
|
128
121
|
*
|
|
129
122
|
* Defaults to the client-level `workspaceId` option or the CADENYA_WORKSPACE_ID environment variable.
|
|
130
123
|
*/
|
|
131
124
|
workspaceId?: string;
|
|
132
|
-
}
|
|
125
|
+
};
|
|
133
126
|
|
|
134
|
-
export interface
|
|
127
|
+
export interface AgentVariationRemoveMemoryLayerParams {
|
|
128
|
+
/**
|
|
129
|
+
* Layer to detach. Accepts memlyr_… or external_id:<value>.
|
|
130
|
+
*/
|
|
131
|
+
memoryLayerId: string;
|
|
135
132
|
/**
|
|
136
133
|
* Workspace ID.
|
|
137
134
|
*
|
|
138
135
|
* Defaults to the client-level `workspaceId` option or the CADENYA_WORKSPACE_ID environment variable.
|
|
139
136
|
*/
|
|
140
137
|
workspaceId?: string;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
export interface AgentVariationUpdateMemoryLayerParams {
|
|
141
|
+
/**
|
|
142
|
+
* Layer to reposition. Accepts memlyr_… or external_id:<value>.
|
|
143
|
+
*/
|
|
144
|
+
memoryLayerId: string;
|
|
141
145
|
/**
|
|
142
146
|
* New position. Only field currently updatable on an assignment.
|
|
143
147
|
*/
|
|
144
|
-
position
|
|
148
|
+
position: number;
|
|
149
|
+
/**
|
|
150
|
+
* Workspace ID.
|
|
151
|
+
*
|
|
152
|
+
* Defaults to the client-level `workspaceId` option or the CADENYA_WORKSPACE_ID environment variable.
|
|
153
|
+
*/
|
|
154
|
+
workspaceId?: string;
|
|
145
155
|
}
|
|
146
156
|
|
|
147
157
|
export class AgentVariations {
|
|
@@ -235,46 +245,48 @@ export class AgentVariations {
|
|
|
235
245
|
*
|
|
236
246
|
* @example
|
|
237
247
|
* ```ts
|
|
238
|
-
* const
|
|
248
|
+
* const agentVariation = await client.agents.variations.addAssignment('agent_123', 'variation_123', { toolId: 'sample', type: 'toolId' });
|
|
239
249
|
* ```
|
|
240
250
|
*/
|
|
241
|
-
addAssignment(agentId: string, variationId: string, params: AgentVariationAddAssignmentParams, options?: RequestOptions): APIPromise<
|
|
242
|
-
return this._client.requestAPI<
|
|
251
|
+
addAssignment(agentId: string, variationId: string, params: AgentVariationAddAssignmentParams, options?: RequestOptions): APIPromise<AgentVariation> {
|
|
252
|
+
return this._client.requestAPI<AgentVariation>(() => {
|
|
253
|
+
const { workspaceId: _bodyParam0, ..._body } = params;
|
|
243
254
|
const workspaceId = String(params.workspaceId ?? this._client.defaults['workspaceId'] ?? '').trim() || undefined;
|
|
244
255
|
if (workspaceId === undefined) throw new Error("Missing 'workspaceId': pass it in params, set it on the client, or set the CADENYA_WORKSPACE_ID environment variable.");
|
|
245
|
-
return { method: 'POST', path: `/v1/workspaces/${pathSegment('workspaceId', workspaceId)}/agents/${pathSegment('agentId', agentId)}/variations/${pathSegment('variationId', variationId)}
|
|
256
|
+
return { method: 'POST', path: `/v1/workspaces/${pathSegment('workspaceId', workspaceId)}/agents/${pathSegment('agentId', agentId)}/variations/${pathSegment('variationId', variationId)}:addAssignment`, body: wireAddAgentVariationAssignmentRequest(_body) };
|
|
246
257
|
}, options);
|
|
247
258
|
}
|
|
248
259
|
|
|
249
260
|
/**
|
|
250
|
-
*
|
|
261
|
+
* Attach a memory layer to a variation
|
|
251
262
|
*
|
|
252
263
|
* @example
|
|
253
264
|
* ```ts
|
|
254
|
-
* await client.agents.variations.
|
|
265
|
+
* const agentVariation = await client.agents.variations.addMemoryLayer('agent_123', 'variation_123', { memoryLayerId: 'sample' });
|
|
255
266
|
* ```
|
|
256
267
|
*/
|
|
257
|
-
|
|
258
|
-
return this._client.requestAPI<
|
|
259
|
-
const workspaceId = String(params
|
|
268
|
+
addMemoryLayer(agentId: string, variationId: string, params: AgentVariationAddMemoryLayerParams, options?: RequestOptions): APIPromise<AgentVariation> {
|
|
269
|
+
return this._client.requestAPI<AgentVariation>(() => {
|
|
270
|
+
const workspaceId = String(params.workspaceId ?? this._client.defaults['workspaceId'] ?? '').trim() || undefined;
|
|
260
271
|
if (workspaceId === undefined) throw new Error("Missing 'workspaceId': pass it in params, set it on the client, or set the CADENYA_WORKSPACE_ID environment variable.");
|
|
261
|
-
return { method: '
|
|
272
|
+
return { method: 'POST', path: `/v1/workspaces/${pathSegment('workspaceId', workspaceId)}/agents/${pathSegment('agentId', agentId)}/variations/${pathSegment('variationId', variationId)}:addMemoryLayer`, body: { memoryLayerId: params.memoryLayerId, position: params.position } };
|
|
262
273
|
}, options);
|
|
263
274
|
}
|
|
264
275
|
|
|
265
276
|
/**
|
|
266
|
-
*
|
|
277
|
+
* Remove an assignment from a variation
|
|
267
278
|
*
|
|
268
279
|
* @example
|
|
269
280
|
* ```ts
|
|
270
|
-
* const
|
|
281
|
+
* const agentVariation = await client.agents.variations.removeAssignment('agent_123', 'variation_123', { toolId: 'sample', type: 'toolId' });
|
|
271
282
|
* ```
|
|
272
283
|
*/
|
|
273
|
-
|
|
274
|
-
return this._client.requestAPI<
|
|
284
|
+
removeAssignment(agentId: string, variationId: string, params: AgentVariationRemoveAssignmentParams, options?: RequestOptions): APIPromise<AgentVariation> {
|
|
285
|
+
return this._client.requestAPI<AgentVariation>(() => {
|
|
286
|
+
const { workspaceId: _bodyParam0, ..._body } = params;
|
|
275
287
|
const workspaceId = String(params.workspaceId ?? this._client.defaults['workspaceId'] ?? '').trim() || undefined;
|
|
276
288
|
if (workspaceId === undefined) throw new Error("Missing 'workspaceId': pass it in params, set it on the client, or set the CADENYA_WORKSPACE_ID environment variable.");
|
|
277
|
-
return { method: 'POST', path: `/v1/workspaces/${pathSegment('workspaceId', workspaceId)}/agents/${pathSegment('agentId', agentId)}/variations/${pathSegment('variationId', variationId)}
|
|
289
|
+
return { method: 'POST', path: `/v1/workspaces/${pathSegment('workspaceId', workspaceId)}/agents/${pathSegment('agentId', agentId)}/variations/${pathSegment('variationId', variationId)}:removeAssignment`, body: wireRemoveAgentVariationAssignmentRequest(_body) };
|
|
278
290
|
}, options);
|
|
279
291
|
}
|
|
280
292
|
|
|
@@ -283,14 +295,14 @@ export class AgentVariations {
|
|
|
283
295
|
*
|
|
284
296
|
* @example
|
|
285
297
|
* ```ts
|
|
286
|
-
* await client.agents.variations.removeMemoryLayer('agent_123', 'variation_123', '
|
|
298
|
+
* const agentVariation = await client.agents.variations.removeMemoryLayer('agent_123', 'variation_123', { memoryLayerId: 'sample' });
|
|
287
299
|
* ```
|
|
288
300
|
*/
|
|
289
|
-
removeMemoryLayer(agentId: string, variationId: string,
|
|
290
|
-
return this._client.requestAPI<
|
|
291
|
-
const workspaceId = String(params
|
|
301
|
+
removeMemoryLayer(agentId: string, variationId: string, params: AgentVariationRemoveMemoryLayerParams, options?: RequestOptions): APIPromise<AgentVariation> {
|
|
302
|
+
return this._client.requestAPI<AgentVariation>(() => {
|
|
303
|
+
const workspaceId = String(params.workspaceId ?? this._client.defaults['workspaceId'] ?? '').trim() || undefined;
|
|
292
304
|
if (workspaceId === undefined) throw new Error("Missing 'workspaceId': pass it in params, set it on the client, or set the CADENYA_WORKSPACE_ID environment variable.");
|
|
293
|
-
return { method: '
|
|
305
|
+
return { method: 'POST', path: `/v1/workspaces/${pathSegment('workspaceId', workspaceId)}/agents/${pathSegment('agentId', agentId)}/variations/${pathSegment('variationId', variationId)}:removeMemoryLayer`, body: { memoryLayerId: params.memoryLayerId } };
|
|
294
306
|
}, options);
|
|
295
307
|
}
|
|
296
308
|
|
|
@@ -299,14 +311,14 @@ export class AgentVariations {
|
|
|
299
311
|
*
|
|
300
312
|
* @example
|
|
301
313
|
* ```ts
|
|
302
|
-
* const
|
|
314
|
+
* const agentVariation = await client.agents.variations.updateMemoryLayer('agent_123', 'variation_123', { memoryLayerId: 'sample', position: 1 });
|
|
303
315
|
* ```
|
|
304
316
|
*/
|
|
305
|
-
updateMemoryLayer(agentId: string, variationId: string,
|
|
306
|
-
return this._client.requestAPI<
|
|
307
|
-
const workspaceId = String(params
|
|
317
|
+
updateMemoryLayer(agentId: string, variationId: string, params: AgentVariationUpdateMemoryLayerParams, options?: RequestOptions): APIPromise<AgentVariation> {
|
|
318
|
+
return this._client.requestAPI<AgentVariation>(() => {
|
|
319
|
+
const workspaceId = String(params.workspaceId ?? this._client.defaults['workspaceId'] ?? '').trim() || undefined;
|
|
308
320
|
if (workspaceId === undefined) throw new Error("Missing 'workspaceId': pass it in params, set it on the client, or set the CADENYA_WORKSPACE_ID environment variable.");
|
|
309
|
-
return { method: '
|
|
321
|
+
return { method: 'POST', path: `/v1/workspaces/${pathSegment('workspaceId', workspaceId)}/agents/${pathSegment('agentId', agentId)}/variations/${pathSegment('variationId', variationId)}:updateMemoryLayer`, body: { memoryLayerId: params.memoryLayerId, position: params.position } };
|
|
310
322
|
}, options);
|
|
311
323
|
}
|
|
312
324
|
}
|
package/src/resources/agents.ts
CHANGED
|
@@ -65,7 +65,9 @@ export interface AgentCreateParams {
|
|
|
65
65
|
*/
|
|
66
66
|
workspaceId?: string;
|
|
67
67
|
/**
|
|
68
|
-
* Optional default variation to add to the agent on create
|
|
68
|
+
* Optional default variation to add to the agent on create. Its spec accepts
|
|
69
|
+
* assignments and memory_layer_assignments using the same atomic validation
|
|
70
|
+
* as CreateAgentVariation. Failure rejects the entire agent creation.
|
|
69
71
|
*/
|
|
70
72
|
defaultVariation?: CreateAgentVariationRequestParam;
|
|
71
73
|
}
|
|
@@ -248,7 +250,7 @@ export class Agents {
|
|
|
248
250
|
*
|
|
249
251
|
* @example
|
|
250
252
|
* ```ts
|
|
251
|
-
* const agent = await client.agents.create({ metadata: { name: 'sample' }, spec: {
|
|
253
|
+
* const agent = await client.agents.create({ metadata: { name: 'sample' }, spec: { } });
|
|
252
254
|
* ```
|
|
253
255
|
*/
|
|
254
256
|
create(params: AgentCreateParams, options?: RequestOptions): APIPromise<Agent> {
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
import { HttpClient, RequestOptions, APIPromise, pathSegment, snapshotParams } from '../core/http.js';
|
|
4
4
|
import { Page } from '../core/pagination.js';
|
|
5
|
-
import type { AIProviderKey, AIProviderKeySpec, CreateResourceMetadata, ListAIProviderKeysResponse, UpdateResourceMetadata } from '../types.js';
|
|
5
|
+
import type { AIProviderCredentialPatch, AIProviderKey, AIProviderKeySpec, CreateResourceMetadata, ListAIProviderKeysResponse, UpdateResourceMetadata } from '../types.js';
|
|
6
6
|
|
|
7
7
|
export interface AiProviderKeyListParams {
|
|
8
8
|
/**
|
|
@@ -68,6 +68,11 @@ export interface AiProviderKeyRetrieveParams {
|
|
|
68
68
|
* Defaults to the client-level `workspaceId` option or the CADENYA_WORKSPACE_ID environment variable.
|
|
69
69
|
*/
|
|
70
70
|
workspaceId?: string;
|
|
71
|
+
/**
|
|
72
|
+
* When true, populate info (model counts, promotional status, model
|
|
73
|
+
* management), at the cost of extra lookups.
|
|
74
|
+
*/
|
|
75
|
+
includeInfo?: boolean;
|
|
71
76
|
}
|
|
72
77
|
|
|
73
78
|
export interface AiProviderKeyDeleteParams {
|
|
@@ -92,6 +97,11 @@ export interface AiProviderKeyUpdateParams {
|
|
|
92
97
|
* Fields to update.
|
|
93
98
|
*/
|
|
94
99
|
updateMask?: string;
|
|
100
|
+
/**
|
|
101
|
+
* Field-level credential changes. This is independent of update_mask;
|
|
102
|
+
* legacy clients may continue replacing spec.credentials atomically.
|
|
103
|
+
*/
|
|
104
|
+
credentialPatch?: AIProviderCredentialPatch;
|
|
95
105
|
}
|
|
96
106
|
|
|
97
107
|
export class AiProviderKeys {
|
|
@@ -144,7 +154,7 @@ export class AiProviderKeys {
|
|
|
144
154
|
return this._client.requestAPI<AIProviderKey>(() => {
|
|
145
155
|
const workspaceId = String(params?.workspaceId ?? this._client.defaults['workspaceId'] ?? '').trim() || undefined;
|
|
146
156
|
if (workspaceId === undefined) throw new Error("Missing 'workspaceId': pass it in params, set it on the client, or set the CADENYA_WORKSPACE_ID environment variable.");
|
|
147
|
-
return { method: 'GET', path: `/v1/workspaces/${pathSegment('workspaceId', workspaceId)}/ai_provider_keys/${pathSegment('id', id)}
|
|
157
|
+
return { method: 'GET', path: `/v1/workspaces/${pathSegment('workspaceId', workspaceId)}/ai_provider_keys/${pathSegment('id', id)}`, query: { includeInfo: params?.includeInfo } };
|
|
148
158
|
}, options);
|
|
149
159
|
}
|
|
150
160
|
|
|
@@ -176,7 +186,7 @@ export class AiProviderKeys {
|
|
|
176
186
|
return this._client.requestAPI<AIProviderKey>(() => {
|
|
177
187
|
const workspaceId = String(params?.workspaceId ?? this._client.defaults['workspaceId'] ?? '').trim() || undefined;
|
|
178
188
|
if (workspaceId === undefined) throw new Error("Missing 'workspaceId': pass it in params, set it on the client, or set the CADENYA_WORKSPACE_ID environment variable.");
|
|
179
|
-
return { method: 'PATCH', path: `/v1/workspaces/${pathSegment('workspaceId', workspaceId)}/ai_provider_keys/${pathSegment('id', id)}`, body: { metadata: params?.metadata, spec: params?.spec, updateMask: params?.updateMask } };
|
|
189
|
+
return { method: 'PATCH', path: `/v1/workspaces/${pathSegment('workspaceId', workspaceId)}/ai_provider_keys/${pathSegment('id', id)}`, body: { metadata: params?.metadata, spec: params?.spec, updateMask: params?.updateMask, credentialPatch: params?.credentialPatch } };
|
|
180
190
|
}, options);
|
|
181
191
|
}
|
|
182
192
|
}
|
|
@@ -120,7 +120,7 @@ export class MemoryLayers {
|
|
|
120
120
|
*
|
|
121
121
|
* @example
|
|
122
122
|
* ```ts
|
|
123
|
-
* const memoryLayer = await client.memoryLayers.create({ metadata: { name: 'sample' }, spec: { type: '
|
|
123
|
+
* const memoryLayer = await client.memoryLayers.create({ metadata: { name: 'sample' }, spec: { type: 'MEMORY_LAYER_TYPE_EPISODIC' } });
|
|
124
124
|
* ```
|
|
125
125
|
*/
|
|
126
126
|
create(params: MemoryLayerCreateParams, options?: RequestOptions): APIPromise<MemoryLayer> {
|
package/src/resources/models.ts
CHANGED
|
@@ -2,7 +2,18 @@
|
|
|
2
2
|
|
|
3
3
|
import { HttpClient, RequestOptions, APIPromise, pathSegment, snapshotParams } from '../core/http.js';
|
|
4
4
|
import { Page } from '../core/pagination.js';
|
|
5
|
-
import type { ListModelsResponse, Model, ModelServiceListModelsState, SwapModelOnVariationsRequest_ModelSwap } from '../types.js';
|
|
5
|
+
import type { CreateResourceMetadata, ListModelsResponse, Model, ModelPricingOverride, ModelServiceListModelsState, ModelSpec, SwapModelOnVariationsRequest_ModelSwap, UpdateResourceMetadata } from '../types.js';
|
|
6
|
+
|
|
7
|
+
export interface ModelCreateParams {
|
|
8
|
+
metadata: CreateResourceMetadata;
|
|
9
|
+
spec: ModelSpec;
|
|
10
|
+
/**
|
|
11
|
+
* Workspace ID.
|
|
12
|
+
*
|
|
13
|
+
* Defaults to the client-level `workspaceId` option or the CADENYA_WORKSPACE_ID environment variable.
|
|
14
|
+
*/
|
|
15
|
+
workspaceId?: string;
|
|
16
|
+
}
|
|
6
17
|
|
|
7
18
|
export interface ModelListParams {
|
|
8
19
|
/**
|
|
@@ -70,6 +81,29 @@ export interface ModelRetrieveParams {
|
|
|
70
81
|
workspaceId?: string;
|
|
71
82
|
}
|
|
72
83
|
|
|
84
|
+
export interface ModelUpdateParams {
|
|
85
|
+
/**
|
|
86
|
+
* Workspace ID.
|
|
87
|
+
*
|
|
88
|
+
* Defaults to the client-level `workspaceId` option or the CADENYA_WORKSPACE_ID environment variable.
|
|
89
|
+
*/
|
|
90
|
+
workspaceId?: string;
|
|
91
|
+
metadata?: UpdateResourceMetadata;
|
|
92
|
+
/**
|
|
93
|
+
* When any spec.* path is masked, send the complete spec (current values
|
|
94
|
+
* plus edits); it is validated as a whole.
|
|
95
|
+
*/
|
|
96
|
+
spec?: ModelSpec;
|
|
97
|
+
/**
|
|
98
|
+
* Customer price overrides, applied per masked path.
|
|
99
|
+
*/
|
|
100
|
+
pricingOverride?: ModelPricingOverride;
|
|
101
|
+
/**
|
|
102
|
+
* Fields to update. Required; leaf paths only.
|
|
103
|
+
*/
|
|
104
|
+
updateMask?: string;
|
|
105
|
+
}
|
|
106
|
+
|
|
73
107
|
export interface ModelDisableParams {
|
|
74
108
|
/**
|
|
75
109
|
* Workspace ID.
|
|
@@ -104,6 +138,22 @@ export interface ModelSwapOnVariationsParams {
|
|
|
104
138
|
export class Models {
|
|
105
139
|
constructor(private readonly _client: HttpClient) {}
|
|
106
140
|
|
|
141
|
+
/**
|
|
142
|
+
* Create a model
|
|
143
|
+
*
|
|
144
|
+
* @example
|
|
145
|
+
* ```ts
|
|
146
|
+
* const model = await client.models.create('ai_provider_key_123', { metadata: { name: 'sample' }, spec: { capabilities: [{ temperature: { }, type: 'temperature' }], family: 'sample', inputPricePerMillionTokens: 'sample', maxInputTokens: 1, maxOutputTokens: 1, outputPricePerMillionTokens: 'sample', provider: 'sample', providerModelId: 'sample' } });
|
|
147
|
+
* ```
|
|
148
|
+
*/
|
|
149
|
+
create(aiProviderKeyId: string, params: ModelCreateParams, options?: RequestOptions): APIPromise<Model> {
|
|
150
|
+
return this._client.requestAPI<Model>(() => {
|
|
151
|
+
const workspaceId = String(params.workspaceId ?? this._client.defaults['workspaceId'] ?? '').trim() || undefined;
|
|
152
|
+
if (workspaceId === undefined) throw new Error("Missing 'workspaceId': pass it in params, set it on the client, or set the CADENYA_WORKSPACE_ID environment variable.");
|
|
153
|
+
return { method: 'POST', path: `/v1/workspaces/${pathSegment('workspaceId', workspaceId)}/ai_provider_keys/${pathSegment('aiProviderKeyId', aiProviderKeyId)}/models`, body: { metadata: params.metadata, spec: params.spec } };
|
|
154
|
+
}, options);
|
|
155
|
+
}
|
|
156
|
+
|
|
107
157
|
/**
|
|
108
158
|
* List models
|
|
109
159
|
*
|
|
@@ -139,6 +189,22 @@ export class Models {
|
|
|
139
189
|
}, options);
|
|
140
190
|
}
|
|
141
191
|
|
|
192
|
+
/**
|
|
193
|
+
* Update a model
|
|
194
|
+
*
|
|
195
|
+
* @example
|
|
196
|
+
* ```ts
|
|
197
|
+
* const model = await client.models.update('_123');
|
|
198
|
+
* ```
|
|
199
|
+
*/
|
|
200
|
+
update(id: string, params?: ModelUpdateParams, options?: RequestOptions): APIPromise<Model> {
|
|
201
|
+
return this._client.requestAPI<Model>(() => {
|
|
202
|
+
const workspaceId = String(params?.workspaceId ?? this._client.defaults['workspaceId'] ?? '').trim() || undefined;
|
|
203
|
+
if (workspaceId === undefined) throw new Error("Missing 'workspaceId': pass it in params, set it on the client, or set the CADENYA_WORKSPACE_ID environment variable.");
|
|
204
|
+
return { method: 'PATCH', path: `/v1/workspaces/${pathSegment('workspaceId', workspaceId)}/models/${pathSegment('id', id)}`, body: { metadata: params?.metadata, spec: params?.spec, pricingOverride: params?.pricingOverride, updateMask: params?.updateMask } };
|
|
205
|
+
}, options);
|
|
206
|
+
}
|
|
207
|
+
|
|
142
208
|
/**
|
|
143
209
|
* Disable a model
|
|
144
210
|
*
|