@layer-ai/sdk 0.8.1 → 1.0.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/dist/client.d.ts +1 -10
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +0 -21
- package/dist/index.d.ts +1 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +0 -3
- package/dist/resources/gates.d.ts +3 -70
- package/dist/resources/gates.d.ts.map +1 -1
- package/dist/resources/gates.js +3 -77
- package/dist/types/client.d.ts +10 -0
- package/dist/types/client.d.ts.map +1 -0
- package/dist/types/client.js +1 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js +1 -0
- package/package.json +1 -1
package/dist/client.d.ts
CHANGED
|
@@ -1,18 +1,9 @@
|
|
|
1
|
-
import type { LayerConfig, RequestOptions } from './types.js';
|
|
1
|
+
import type { LayerConfig, RequestOptions } from './types/index.js';
|
|
2
2
|
import type { LayerRequest, LayerResponse } from './types/index.js';
|
|
3
|
-
import { GatesResource } from './resources/gates.js';
|
|
4
|
-
import { KeysResource } from './resources/keys.js';
|
|
5
|
-
import { LogsResource } from './resources/logs.js';
|
|
6
3
|
export declare class Layer {
|
|
7
4
|
private apiKey;
|
|
8
5
|
private baseUrl;
|
|
9
|
-
private adminMode;
|
|
10
|
-
gates: GatesResource;
|
|
11
|
-
keys: KeysResource;
|
|
12
|
-
logs: LogsResource;
|
|
13
6
|
constructor(config: LayerConfig);
|
|
14
|
-
/** @internal */
|
|
15
|
-
checkAdminMode(): void;
|
|
16
7
|
request<T>(options: RequestOptions): Promise<T>;
|
|
17
8
|
complete(request: LayerRequest): Promise<LayerResponse>;
|
|
18
9
|
}
|
package/dist/client.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AACpE,OAAO,KAAK,EAAiB,YAAY,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAEnF,qBAAa,KAAK;IAChB,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,OAAO,CAAS;gBAEZ,MAAM,EAAE,WAAW;IAQlB,OAAO,CAAC,CAAC,EAAE,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,CAAC,CAAC;IA4BtD,QAAQ,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,aAAa,CAAC;CAkB9D"}
|
package/dist/client.js
CHANGED
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
import { GatesResource } from './resources/gates.js';
|
|
2
|
-
import { KeysResource } from './resources/keys.js';
|
|
3
|
-
import { LogsResource } from './resources/logs.js';
|
|
4
1
|
export class Layer {
|
|
5
2
|
constructor(config) {
|
|
6
3
|
if (!config.apiKey) {
|
|
@@ -8,24 +5,6 @@ export class Layer {
|
|
|
8
5
|
}
|
|
9
6
|
this.apiKey = config.apiKey;
|
|
10
7
|
this.baseUrl = config.baseUrl || 'http://localhost:3001';
|
|
11
|
-
this.adminMode = config.adminMode || false;
|
|
12
|
-
this.gates = new GatesResource(this);
|
|
13
|
-
this.keys = new KeysResource(this);
|
|
14
|
-
this.logs = new LogsResource(this);
|
|
15
|
-
}
|
|
16
|
-
/** @internal */
|
|
17
|
-
checkAdminMode() {
|
|
18
|
-
if (!this.adminMode) {
|
|
19
|
-
throw new Error('This operation requires adminMode: true in Layer constructor.\n\n' +
|
|
20
|
-
'Example:\n' +
|
|
21
|
-
' const layer = new Layer({ apiKey: "...", adminMode: true });\n\n' +
|
|
22
|
-
'Admin mode is required for mutation operations:\n' +
|
|
23
|
-
' - gates.create/update/delete()\n' +
|
|
24
|
-
' - keys.create/delete()\n\n' +
|
|
25
|
-
'These methods are intended for setup scripts only.\n' +
|
|
26
|
-
'For ongoing managmenent, use CLI or config files.\n\n' +
|
|
27
|
-
'See: https://docs.uselayer.ai/sdk/admin-mode');
|
|
28
|
-
}
|
|
29
8
|
}
|
|
30
9
|
async request(options) {
|
|
31
10
|
const { method, path, body } = options;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,4 @@
|
|
|
1
1
|
export { Layer } from './client.js';
|
|
2
|
-
export type { LayerConfig } from './types.js';
|
|
3
|
-
export { KeysResource } from './resources/keys.js';
|
|
4
|
-
export { GatesResource } from './resources/gates.js';
|
|
5
|
-
export { LogsResource } from './resources/logs.js';
|
|
2
|
+
export type { LayerConfig } from './types/index.js';
|
|
6
3
|
export * from './types/index.js';
|
|
7
4
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACpC,YAAY,EAAE,WAAW,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACpC,YAAY,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAGpD,cAAc,kBAAkB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,3 @@
|
|
|
1
1
|
export { Layer } from './client.js';
|
|
2
|
-
export { KeysResource } from './resources/keys.js';
|
|
3
|
-
export { GatesResource } from './resources/gates.js';
|
|
4
|
-
export { LogsResource } from './resources/logs.js';
|
|
5
2
|
// Re-export all types from types package
|
|
6
3
|
export * from './types/index.js';
|
|
@@ -1,82 +1,15 @@
|
|
|
1
1
|
import type { Layer } from '../client.js';
|
|
2
|
-
import type { Gate
|
|
3
|
-
import type { TaskAnalysis } from '../types/index.js';
|
|
2
|
+
import type { Gate } from '../types/index.js';
|
|
4
3
|
export declare class GatesResource {
|
|
5
4
|
private client;
|
|
6
5
|
constructor(client: Layer);
|
|
7
|
-
/**
|
|
8
|
-
* Create a new gate.
|
|
9
|
-
*
|
|
10
|
-
* Requires `adminMode: true` in Layer constructor.
|
|
11
|
-
*
|
|
12
|
-
* @throws Error if adminMode is not enabled
|
|
13
|
-
* @see https://docs.uselayer.ai/sdk/admin-mode
|
|
14
|
-
*/
|
|
15
|
-
create(data: CreateGateRequest): Promise<Gate>;
|
|
16
6
|
/**
|
|
17
7
|
* Lists all gates
|
|
18
|
-
* No admin mode required.
|
|
19
8
|
*/
|
|
20
9
|
list(): Promise<Gate[]>;
|
|
21
10
|
/**
|
|
22
|
-
* Gets a specific gate by
|
|
23
|
-
* No admin mode required.
|
|
24
|
-
*/
|
|
25
|
-
get(name: string): Promise<Gate>;
|
|
26
|
-
/**
|
|
27
|
-
* Update an existing gate.
|
|
28
|
-
*
|
|
29
|
-
* ⚠️ Requires `adminMode: true` in Layer constructor.
|
|
30
|
-
*
|
|
31
|
-
* @throws Error if adminMode is not enabled
|
|
32
|
-
* @see https://docs.uselayer.ai/sdk/admin-mode
|
|
33
|
-
*/
|
|
34
|
-
update(name: string, data: UpdateGateRequest): Promise<Gate>;
|
|
35
|
-
/**
|
|
36
|
-
* Deletes an existing.
|
|
37
|
-
*
|
|
38
|
-
* ⚠️ Requires `adminMode: true` in Layer constructor.
|
|
39
|
-
*
|
|
40
|
-
* @throws Error if adminMode is not enabled
|
|
41
|
-
* @see https://docs.uselayer.ai/sdk/admin-mode
|
|
42
|
-
*/
|
|
43
|
-
delete(name: string): Promise<void>;
|
|
44
|
-
/**
|
|
45
|
-
* Get AI-powered model suggestions for a gate.
|
|
46
|
-
*
|
|
47
|
-
* Analyzes the gate's task description and returns suggested models
|
|
48
|
-
* with confidence scores based on the task requirements.
|
|
49
|
-
*/
|
|
50
|
-
suggestions(gateName: string): Promise<TaskAnalysis>;
|
|
51
|
-
/**
|
|
52
|
-
* Test a gate configuration with a sample request.
|
|
53
|
-
*
|
|
54
|
-
* Tests the primary model and optionally all fallback models.
|
|
55
|
-
* Can test an unsaved configuration or a saved gate with optional overrides.
|
|
11
|
+
* Gets a specific gate by ID
|
|
56
12
|
*/
|
|
57
|
-
|
|
58
|
-
gateId?: string;
|
|
59
|
-
gate?: Partial<CreateGateRequest>;
|
|
60
|
-
messages: Array<{
|
|
61
|
-
role: string;
|
|
62
|
-
content: string;
|
|
63
|
-
}>;
|
|
64
|
-
quickTest?: boolean;
|
|
65
|
-
}): Promise<{
|
|
66
|
-
primary?: {
|
|
67
|
-
model: string;
|
|
68
|
-
success: boolean;
|
|
69
|
-
latency: number;
|
|
70
|
-
content?: string;
|
|
71
|
-
error?: string;
|
|
72
|
-
};
|
|
73
|
-
fallback?: Array<{
|
|
74
|
-
model: string;
|
|
75
|
-
success: boolean;
|
|
76
|
-
latency: number;
|
|
77
|
-
content?: string;
|
|
78
|
-
error?: string;
|
|
79
|
-
}>;
|
|
80
|
-
}>;
|
|
13
|
+
get(id: string): Promise<Gate>;
|
|
81
14
|
}
|
|
82
15
|
//# sourceMappingURL=gates.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gates.d.ts","sourceRoot":"","sources":["../../src/resources/gates.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,KAAK,EAAE,IAAI,EAAE,
|
|
1
|
+
{"version":3,"file":"gates.d.ts","sourceRoot":"","sources":["../../src/resources/gates.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AAE9C,qBAAa,aAAa;IACZ,OAAO,CAAC,MAAM;gBAAN,MAAM,EAAE,KAAK;IAEjC;;OAEG;IACG,IAAI,IAAI,OAAO,CAAC,IAAI,EAAE,CAAC;IAO7B;;OAEG;IACG,GAAG,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAMrC"}
|
package/dist/resources/gates.js
CHANGED
|
@@ -2,25 +2,8 @@ export class GatesResource {
|
|
|
2
2
|
constructor(client) {
|
|
3
3
|
this.client = client;
|
|
4
4
|
}
|
|
5
|
-
/**
|
|
6
|
-
* Create a new gate.
|
|
7
|
-
*
|
|
8
|
-
* Requires `adminMode: true` in Layer constructor.
|
|
9
|
-
*
|
|
10
|
-
* @throws Error if adminMode is not enabled
|
|
11
|
-
* @see https://docs.uselayer.ai/sdk/admin-mode
|
|
12
|
-
*/
|
|
13
|
-
async create(data) {
|
|
14
|
-
this.client.checkAdminMode();
|
|
15
|
-
return this.client.request({
|
|
16
|
-
method: 'POST',
|
|
17
|
-
path: '/v1/gates',
|
|
18
|
-
body: data,
|
|
19
|
-
});
|
|
20
|
-
}
|
|
21
5
|
/**
|
|
22
6
|
* Lists all gates
|
|
23
|
-
* No admin mode required.
|
|
24
7
|
*/
|
|
25
8
|
async list() {
|
|
26
9
|
return this.client.request({
|
|
@@ -29,69 +12,12 @@ export class GatesResource {
|
|
|
29
12
|
});
|
|
30
13
|
}
|
|
31
14
|
/**
|
|
32
|
-
* Gets a specific gate by
|
|
33
|
-
* No admin mode required.
|
|
34
|
-
*/
|
|
35
|
-
async get(name) {
|
|
36
|
-
return this.client.request({
|
|
37
|
-
method: 'GET',
|
|
38
|
-
path: `/v1/gates/name/${name}`,
|
|
39
|
-
});
|
|
40
|
-
}
|
|
41
|
-
/**
|
|
42
|
-
* Update an existing gate.
|
|
43
|
-
*
|
|
44
|
-
* ⚠️ Requires `adminMode: true` in Layer constructor.
|
|
45
|
-
*
|
|
46
|
-
* @throws Error if adminMode is not enabled
|
|
47
|
-
* @see https://docs.uselayer.ai/sdk/admin-mode
|
|
48
|
-
*/
|
|
49
|
-
async update(name, data) {
|
|
50
|
-
this.client.checkAdminMode();
|
|
51
|
-
return this.client.request({
|
|
52
|
-
method: 'PATCH',
|
|
53
|
-
path: `/v1/gates/name/${name}`,
|
|
54
|
-
body: data,
|
|
55
|
-
});
|
|
56
|
-
}
|
|
57
|
-
/**
|
|
58
|
-
* Deletes an existing.
|
|
59
|
-
*
|
|
60
|
-
* ⚠️ Requires `adminMode: true` in Layer constructor.
|
|
61
|
-
*
|
|
62
|
-
* @throws Error if adminMode is not enabled
|
|
63
|
-
* @see https://docs.uselayer.ai/sdk/admin-mode
|
|
15
|
+
* Gets a specific gate by ID
|
|
64
16
|
*/
|
|
65
|
-
async
|
|
66
|
-
this.client.checkAdminMode();
|
|
67
|
-
await this.client.request({
|
|
68
|
-
method: 'DELETE',
|
|
69
|
-
path: `/v1/gates/name/${name}`,
|
|
70
|
-
});
|
|
71
|
-
}
|
|
72
|
-
/**
|
|
73
|
-
* Get AI-powered model suggestions for a gate.
|
|
74
|
-
*
|
|
75
|
-
* Analyzes the gate's task description and returns suggested models
|
|
76
|
-
* with confidence scores based on the task requirements.
|
|
77
|
-
*/
|
|
78
|
-
async suggestions(gateName) {
|
|
17
|
+
async get(id) {
|
|
79
18
|
return this.client.request({
|
|
80
19
|
method: 'GET',
|
|
81
|
-
path: `/v1/gates/${
|
|
82
|
-
});
|
|
83
|
-
}
|
|
84
|
-
/**
|
|
85
|
-
* Test a gate configuration with a sample request.
|
|
86
|
-
*
|
|
87
|
-
* Tests the primary model and optionally all fallback models.
|
|
88
|
-
* Can test an unsaved configuration or a saved gate with optional overrides.
|
|
89
|
-
*/
|
|
90
|
-
async test(data) {
|
|
91
|
-
return this.client.request({
|
|
92
|
-
method: 'POST',
|
|
93
|
-
path: '/v1/gates/test',
|
|
94
|
-
body: data,
|
|
20
|
+
path: `/v1/gates/${id}`,
|
|
95
21
|
});
|
|
96
22
|
}
|
|
97
23
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/types/client.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,WAAW;IAC1B,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,cAAc;IAC7B,MAAM,EAAE,KAAK,GAAG,MAAM,GAAG,KAAK,GAAG,OAAO,GAAG,QAAQ,CAAC;IACpD,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AACA,cAAc,aAAa,CAAC;AAC5B,cAAc,qBAAqB,CAAC;AACpC,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC;AAC1B,cAAc,oBAAoB,CAAC;AACnC,cAAc,aAAa,CAAC;AAC5B,cAAc,oBAAoB,CAAC;AACnC,cAAc,cAAc,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AACA,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,qBAAqB,CAAC;AACpC,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC;AAC1B,cAAc,oBAAoB,CAAC;AACnC,cAAc,aAAa,CAAC;AAC5B,cAAc,oBAAoB,CAAC;AACnC,cAAc,cAAc,CAAC"}
|
package/dist/types/index.js
CHANGED