@cadenya/cadenya 1.0.1 → 1.1.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 +39 -39
- 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/agents.d.ts +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 +8 -50
- package/dist/resources/objectives.d.ts.map +1 -1
- package/dist/resources/objectives.js +1 -36
- package/dist/resources/objectives.js.map +1 -1
- package/dist/resources/tool-search.d.ts +1 -3
- package/dist/resources/tool-search.d.ts.map +1 -1
- package/dist/resources/tool-search.js.map +1 -1
- package/dist/resources/tools.d.ts +9 -1
- package/dist/resources/tools.d.ts.map +1 -1
- package/dist/resources/tools.js +2 -2
- package/dist/resources/tools.js.map +1 -1
- package/dist/types.d.ts +712 -74
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/package.json +13 -4
- package/src/client.ts +4 -4
- package/src/core/http.ts +45 -6
- package/src/index.ts +1 -1
- package/src/resources/agents.ts +1 -1
- 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 +8 -66
- package/src/resources/tool-search.ts +1 -3
- package/src/resources/tools.ts +10 -2
- package/src/types.ts +762 -77
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cadenya/cadenya",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "The official TypeScript SDK for the Cadenya API",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"type": "module",
|
|
@@ -13,12 +13,21 @@
|
|
|
13
13
|
}
|
|
14
14
|
},
|
|
15
15
|
"sideEffects": false,
|
|
16
|
-
"publishConfig": {
|
|
17
|
-
|
|
16
|
+
"publishConfig": {
|
|
17
|
+
"access": "public"
|
|
18
|
+
},
|
|
19
|
+
"repository": {
|
|
20
|
+
"type": "git",
|
|
21
|
+
"url": "https://github.com/cadenya/cadenya-typescript"
|
|
22
|
+
},
|
|
18
23
|
"engines": {
|
|
19
24
|
"node": ">=18"
|
|
20
25
|
},
|
|
21
|
-
"files": [
|
|
26
|
+
"files": [
|
|
27
|
+
"dist",
|
|
28
|
+
"src",
|
|
29
|
+
"api.md"
|
|
30
|
+
],
|
|
22
31
|
"scripts": {
|
|
23
32
|
"build": "tsc",
|
|
24
33
|
"typecheck": "tsc --noEmit"
|
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.0.2 (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';
|
package/src/resources/agents.ts
CHANGED
|
@@ -248,7 +248,7 @@ export class Agents {
|
|
|
248
248
|
*
|
|
249
249
|
* @example
|
|
250
250
|
* ```ts
|
|
251
|
-
* const agent = await client.agents.create({ metadata: { name: 'sample' }, spec: {
|
|
251
|
+
* const agent = await client.agents.create({ metadata: { name: 'sample' }, spec: { } });
|
|
252
252
|
* ```
|
|
253
253
|
*/
|
|
254
254
|
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
|
*
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
import { HttpClient, RequestOptions, RequestSpec, APIPromise, pathSegment, snapshotParams } from '../core/http.js';
|
|
4
4
|
import { Page } from '../core/pagination.js';
|
|
5
5
|
import { Stream } from '../core/sse.js';
|
|
6
|
-
import type { AgentVariationSpec_CompactionConfig, CompactObjectiveResponse, CreateObjectiveRequest_Secret, CreateOperationMetadata, GetObjectiveDiagnosticsResponse, ListObjectiveContextWindowsResponse, ListObjectiveEventsResponse, ListObjectiveFeedbackResponse,
|
|
6
|
+
import type { AgentVariationSpec_CompactionConfig, CompactObjectiveResponse, CreateObjectiveRequest_Secret, CreateOperationMetadata, GetObjectiveDiagnosticsResponse, ListObjectiveContextWindowsResponse, ListObjectiveEventsResponse, ListObjectiveFeedbackResponse, ListObjectiveToolCallsResponse, ListObjectiveToolsResponse, ListObjectivesResponse, MemoryReference, Objective, ObjectiveContextWindow, ObjectiveEpisodicConfigParam, ObjectiveEvent, ObjectiveFeedback, ObjectiveFeedbackData, ObjectiveServiceListObjectiveToolCallsExecutionStatus, ObjectiveServiceListObjectiveToolCallsStatus, ObjectiveServiceListObjectivesState, ObjectiveTool, ObjectiveToolCall, ObjectiveToolCallWithResult, SetToolCallContentRequest_ContentBlock, SubjectAssertion, TenantAssertion } from '../types.js';
|
|
7
7
|
import { wireObjectiveEpisodicConfig } from '../types.js';
|
|
8
8
|
|
|
9
9
|
export interface ObjectiveListParams {
|
|
@@ -144,9 +144,12 @@ export interface ObjectiveCreateParams {
|
|
|
144
144
|
subject?: SubjectAssertion;
|
|
145
145
|
/**
|
|
146
146
|
* Parameters forced onto this objective's tool calls. A pinned parameter
|
|
147
|
-
* is
|
|
148
|
-
*
|
|
149
|
-
*
|
|
147
|
+
* is removed from the tool schema the LLM sees, and its value is always
|
|
148
|
+
* overwritten server-side with the pinned value — the model cannot choose
|
|
149
|
+
* a different value for it. By default a pinned key applies to every tool
|
|
150
|
+
* with a top-level parameter of the same name; a tool set's overlays
|
|
151
|
+
* (ToolSetSpec.overlays) can bind pinned keys to nested paths, differently
|
|
152
|
+
* named parameters, or a subset of tools.
|
|
150
153
|
*/
|
|
151
154
|
pinnedParameters?: Record<string, string>;
|
|
152
155
|
}
|
|
@@ -264,32 +267,6 @@ export interface ObjectiveCreateFeedbackParams {
|
|
|
264
267
|
workspaceId?: string;
|
|
265
268
|
}
|
|
266
269
|
|
|
267
|
-
export interface ObjectiveListTasksParams {
|
|
268
|
-
/**
|
|
269
|
-
* Defaults to the client-level `workspaceId` option or the CADENYA_WORKSPACE_ID environment variable.
|
|
270
|
-
*/
|
|
271
|
-
workspaceId?: string;
|
|
272
|
-
/**
|
|
273
|
-
* Maximum number of results to return
|
|
274
|
-
*/
|
|
275
|
-
limit?: number;
|
|
276
|
-
/**
|
|
277
|
-
* Pagination cursor from previous response
|
|
278
|
-
*/
|
|
279
|
-
cursor?: string;
|
|
280
|
-
/**
|
|
281
|
-
* Sort order for results
|
|
282
|
-
*/
|
|
283
|
-
sortOrder?: string;
|
|
284
|
-
}
|
|
285
|
-
|
|
286
|
-
export interface ObjectiveRetrieveTaskParams {
|
|
287
|
-
/**
|
|
288
|
-
* Defaults to the client-level `workspaceId` option or the CADENYA_WORKSPACE_ID environment variable.
|
|
289
|
-
*/
|
|
290
|
-
workspaceId?: string;
|
|
291
|
-
}
|
|
292
|
-
|
|
293
270
|
export interface ObjectiveListToolCallsParams {
|
|
294
271
|
/**
|
|
295
272
|
* Defaults to the client-level `workspaceId` option or the CADENYA_WORKSPACE_ID environment variable.
|
|
@@ -489,7 +466,7 @@ export class Objectives {
|
|
|
489
466
|
}
|
|
490
467
|
|
|
491
468
|
/**
|
|
492
|
-
* Get objective context
|
|
469
|
+
* Get objective context usage
|
|
493
470
|
*
|
|
494
471
|
* @example
|
|
495
472
|
* ```ts
|
|
@@ -577,41 +554,6 @@ export class Objectives {
|
|
|
577
554
|
}, options);
|
|
578
555
|
}
|
|
579
556
|
|
|
580
|
-
/**
|
|
581
|
-
* List objective tasks
|
|
582
|
-
*
|
|
583
|
-
* @example
|
|
584
|
-
* ```ts
|
|
585
|
-
* const page = await client.objectives.listTasks('objective_123');
|
|
586
|
-
* for await (const item of page) {
|
|
587
|
-
* // auto-fetches every page
|
|
588
|
-
* }
|
|
589
|
-
* ```
|
|
590
|
-
*/
|
|
591
|
-
async listTasks(objectiveId: string, params?: ObjectiveListTasksParams, options?: RequestOptions): Promise<Page<ObjectiveTask>> {
|
|
592
|
-
const workspaceId = String(params?.workspaceId ?? this._client.defaults['workspaceId'] ?? '').trim() || undefined;
|
|
593
|
-
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.");
|
|
594
|
-
const _base = snapshotParams(params);
|
|
595
|
-
const response = await this._client.request<ListObjectiveTasksResponse>({ method: 'GET', path: `/v1/workspaces/${pathSegment('workspaceId', workspaceId)}/objectives/${pathSegment('objectiveId', objectiveId)}/tasks`, query: { limit: params?.limit, cursor: params?.cursor, sortOrder: params?.sortOrder } }, options);
|
|
596
|
-
return new Page(response.items ?? [], response.pagination?.nextCursor, (cursor) => this.listTasks(objectiveId, { ..._base, cursor: cursor }, options));
|
|
597
|
-
}
|
|
598
|
-
|
|
599
|
-
/**
|
|
600
|
-
* Get an objective task by ID
|
|
601
|
-
*
|
|
602
|
-
* @example
|
|
603
|
-
* ```ts
|
|
604
|
-
* const objectiveTask = await client.objectives.retrieveTask('objective_123', '_123');
|
|
605
|
-
* ```
|
|
606
|
-
*/
|
|
607
|
-
retrieveTask(objectiveId: string, id: string, params?: ObjectiveRetrieveTaskParams, options?: RequestOptions): APIPromise<ObjectiveTask> {
|
|
608
|
-
return this._client.requestAPI<ObjectiveTask>(() => {
|
|
609
|
-
const workspaceId = String(params?.workspaceId ?? this._client.defaults['workspaceId'] ?? '').trim() || undefined;
|
|
610
|
-
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.");
|
|
611
|
-
return { method: 'GET', path: `/v1/workspaces/${pathSegment('workspaceId', workspaceId)}/objectives/${pathSegment('objectiveId', objectiveId)}/tasks/${pathSegment('id', id)}` };
|
|
612
|
-
}, options);
|
|
613
|
-
}
|
|
614
|
-
|
|
615
557
|
/**
|
|
616
558
|
* List objective tool calls
|
|
617
559
|
*
|
|
@@ -6,9 +6,7 @@ import type { SearchToolsOrToolSetsResponse } from '../types.js';
|
|
|
6
6
|
export interface ToolSearchSearchOrSetsParams {
|
|
7
7
|
query: string;
|
|
8
8
|
/**
|
|
9
|
-
*
|
|
10
|
-
* does not propagate message-level schema `required` to GET query
|
|
11
|
-
* parameters — overlay.yaml marks the parameter required instead.
|
|
9
|
+
* Workspace that contains the tools and tool sets to search.
|
|
12
10
|
*
|
|
13
11
|
* Defaults to the client-level `workspaceId` option or the CADENYA_WORKSPACE_ID environment variable.
|
|
14
12
|
*/
|
package/src/resources/tools.ts
CHANGED
|
@@ -40,6 +40,14 @@ export interface ToolListParams {
|
|
|
40
40
|
* requiring approval; false = only tools not requiring approval.
|
|
41
41
|
*/
|
|
42
42
|
requiresApproval?: boolean;
|
|
43
|
+
/**
|
|
44
|
+
* Filter to tools matched by the tool set overlays with these keys
|
|
45
|
+
* (ToolSetSpec.overlays), i.e. tools whose info.overlays contains the
|
|
46
|
+
* key. Multiple values are OR'd together. Selectors are evaluated
|
|
47
|
+
* against every tool in the set to answer this, so total counts reflect
|
|
48
|
+
* the filtered set. An unknown overlay key matches nothing.
|
|
49
|
+
*/
|
|
50
|
+
overlays?: Array<string>;
|
|
43
51
|
/**
|
|
44
52
|
* Filters by metadata labels. Comma-separated key=value pairs,
|
|
45
53
|
* e.g. "env=prod,team=ai". A resource matches only if every pair
|
|
@@ -133,7 +141,7 @@ export class Tools {
|
|
|
133
141
|
const workspaceId = String(params?.workspaceId ?? this._client.defaults['workspaceId'] ?? '').trim() || undefined;
|
|
134
142
|
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.");
|
|
135
143
|
const _base = snapshotParams(params);
|
|
136
|
-
const response = await this._client.request<ListToolsResponse>({ method: 'GET', path: `/v1/workspaces/${pathSegment('workspaceId', workspaceId)}/tool_sets/${pathSegment('toolSetId', toolSetId)}/tools`, query: { limit: params?.limit, cursor: params?.cursor, prefix: params?.prefix, query: params?.query, names: params?.names, states: params?.states, requiresApproval: params?.requiresApproval, labels: params?.labels, sortOrder: params?.sortOrder, includeInfo: params?.includeInfo } }, options);
|
|
144
|
+
const response = await this._client.request<ListToolsResponse>({ method: 'GET', path: `/v1/workspaces/${pathSegment('workspaceId', workspaceId)}/tool_sets/${pathSegment('toolSetId', toolSetId)}/tools`, query: { limit: params?.limit, cursor: params?.cursor, prefix: params?.prefix, query: params?.query, names: params?.names, states: params?.states, requiresApproval: params?.requiresApproval, overlays: params?.overlays, labels: params?.labels, sortOrder: params?.sortOrder, includeInfo: params?.includeInfo } }, options);
|
|
137
145
|
return new Page(response.items ?? [], response.pagination?.nextCursor, (cursor) => this.list(toolSetId, { ..._base, cursor: cursor }, options));
|
|
138
146
|
}
|
|
139
147
|
|
|
@@ -142,7 +150,7 @@ export class Tools {
|
|
|
142
150
|
*
|
|
143
151
|
* @example
|
|
144
152
|
* ```ts
|
|
145
|
-
* const tool = await client.toolSets.tools.create('tool_set_123', { metadata: { name: 'sample' }, spec: { config: { http: { requestMethod: '
|
|
153
|
+
* const tool = await client.toolSets.tools.create('tool_set_123', { metadata: { name: 'sample' }, spec: { config: { http: { requestMethod: 'GET' }, type: 'http' }, description: 'sample', parameters: { }, requiresApproval: true } });
|
|
146
154
|
* ```
|
|
147
155
|
*/
|
|
148
156
|
create(toolSetId: string, params: ToolCreateParams, options?: RequestOptions): APIPromise<Tool> {
|