@simple-ai-lab/sdk 0.11.0 → 0.14.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/README.md +1 -0
- package/dist/actions.cjs +29 -0
- package/dist/actions.d.cts +35 -1
- package/dist/actions.d.ts +35 -1
- package/dist/actions.js +30 -1
- package/dist/agents.cjs +187 -15
- package/dist/agents.d.cts +231 -9
- package/dist/agents.d.ts +231 -9
- package/dist/agents.js +185 -14
- package/dist/built-in-actions.cjs +31 -2
- package/dist/built-in-actions.d.cts +27 -1
- package/dist/built-in-actions.d.ts +27 -1
- package/dist/built-in-actions.js +29 -1
- package/dist/client.cjs +4 -0
- package/dist/client.d.cts +3 -0
- package/dist/client.d.ts +3 -0
- package/dist/client.js +4 -0
- package/dist/code-action/define-action.cjs +2 -0
- package/dist/code-action/define-action.d.cts +17 -1
- package/dist/code-action/define-action.d.ts +17 -1
- package/dist/code-action/define-action.js +2 -0
- package/dist/code-action/index.d.cts +1 -1
- package/dist/code-action/index.d.ts +1 -1
- package/dist/code-action/types.d.cts +11 -0
- package/dist/code-action/types.d.ts +11 -0
- package/dist/index.cjs +11 -4
- package/dist/index.d.cts +7 -7
- package/dist/index.d.ts +7 -7
- package/dist/index.js +4 -4
- package/dist/oauth.cjs +18 -0
- package/dist/oauth.d.cts +9 -0
- package/dist/oauth.d.ts +9 -0
- package/dist/oauth.js +14 -0
- package/dist/projects.cjs +47 -121
- package/dist/projects.d.cts +5 -19
- package/dist/projects.d.ts +5 -19
- package/dist/projects.js +46 -119
- package/dist/schemas.cjs +27 -1
- package/dist/schemas.d.cts +20 -0
- package/dist/schemas.d.ts +20 -0
- package/dist/schemas.js +26 -0
- package/package.json +9 -9
package/dist/projects.d.cts
CHANGED
|
@@ -1,24 +1,10 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import { type AgentCompileOptions, type AgentDefinition, type AgentV2CommitContentWire, type CompiledAgentProject } from "./agents.cjs";
|
|
3
|
-
export type AgentProjectSource = AgentDefinition | AgentSnapshotDefinition;
|
|
4
|
-
export type SnapshotAction = {
|
|
5
|
-
key: string;
|
|
6
|
-
sourceVersionUuid: string;
|
|
7
|
-
values: ActionVersionValues;
|
|
8
|
-
};
|
|
9
|
-
export type AgentSnapshotDefinition = {
|
|
10
|
-
kind: 'agent-snapshot';
|
|
11
|
-
agent: CompiledAgentProject['agent'];
|
|
12
|
-
branch: CompiledAgentProject['branch'];
|
|
13
|
-
actions: SnapshotAction[];
|
|
14
|
-
content: AgentV2CommitContentWire;
|
|
15
|
-
};
|
|
16
|
-
export declare function defineAgentSnapshot(definition: Omit<AgentSnapshotDefinition, 'kind'>): AgentSnapshotDefinition;
|
|
1
|
+
import type { AgentV2CommitContentWire, AssistActionUseSiteWire, AssistPlaybookConfigWire } from "./agents.cjs";
|
|
17
2
|
/**
|
|
18
3
|
* Fills defaults added after older Agent commits were stored. Pull, diff, and
|
|
19
|
-
*
|
|
20
|
-
*
|
|
4
|
+
* pull verification must all use this same canonical content shape so a freshly
|
|
5
|
+
* pulled project is clean against its lock.
|
|
21
6
|
*/
|
|
22
7
|
export declare function normalizeAgentV2CommitContent(content: AgentV2CommitContentWire): AgentV2CommitContentWire;
|
|
23
|
-
export declare function compileAgentProject(definition: AgentProjectSource, options?: AgentCompileOptions): CompiledAgentProject;
|
|
24
8
|
export declare function collectActionVersionUuids(content: AgentV2CommitContentWire): string[];
|
|
9
|
+
/** Every Action use site an Agent Assist playbook runs: its procedures' steps first, then its card buttons. */
|
|
10
|
+
export declare function assistActionUseSites(assist: AssistPlaybookConfigWire | undefined): AssistActionUseSiteWire[];
|
package/dist/projects.d.ts
CHANGED
|
@@ -1,24 +1,10 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import { type AgentCompileOptions, type AgentDefinition, type AgentV2CommitContentWire, type CompiledAgentProject } from "./agents.js";
|
|
3
|
-
export type AgentProjectSource = AgentDefinition | AgentSnapshotDefinition;
|
|
4
|
-
export type SnapshotAction = {
|
|
5
|
-
key: string;
|
|
6
|
-
sourceVersionUuid: string;
|
|
7
|
-
values: ActionVersionValues;
|
|
8
|
-
};
|
|
9
|
-
export type AgentSnapshotDefinition = {
|
|
10
|
-
kind: 'agent-snapshot';
|
|
11
|
-
agent: CompiledAgentProject['agent'];
|
|
12
|
-
branch: CompiledAgentProject['branch'];
|
|
13
|
-
actions: SnapshotAction[];
|
|
14
|
-
content: AgentV2CommitContentWire;
|
|
15
|
-
};
|
|
16
|
-
export declare function defineAgentSnapshot(definition: Omit<AgentSnapshotDefinition, 'kind'>): AgentSnapshotDefinition;
|
|
1
|
+
import type { AgentV2CommitContentWire, AssistActionUseSiteWire, AssistPlaybookConfigWire } from "./agents.js";
|
|
17
2
|
/**
|
|
18
3
|
* Fills defaults added after older Agent commits were stored. Pull, diff, and
|
|
19
|
-
*
|
|
20
|
-
*
|
|
4
|
+
* pull verification must all use this same canonical content shape so a freshly
|
|
5
|
+
* pulled project is clean against its lock.
|
|
21
6
|
*/
|
|
22
7
|
export declare function normalizeAgentV2CommitContent(content: AgentV2CommitContentWire): AgentV2CommitContentWire;
|
|
23
|
-
export declare function compileAgentProject(definition: AgentProjectSource, options?: AgentCompileOptions): CompiledAgentProject;
|
|
24
8
|
export declare function collectActionVersionUuids(content: AgentV2CommitContentWire): string[];
|
|
9
|
+
/** Every Action use site an Agent Assist playbook runs: its procedures' steps first, then its card buttons. */
|
|
10
|
+
export declare function assistActionUseSites(assist: AssistPlaybookConfigWire | undefined): AssistActionUseSiteWire[];
|
package/dist/projects.js
CHANGED
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
import { compileAgent, } from "./agents.js";
|
|
2
|
-
export function defineAgentSnapshot(definition) {
|
|
3
|
-
return { kind: 'agent-snapshot', ...definition };
|
|
4
|
-
}
|
|
5
1
|
function normalizeNodeCompatibilityDefaults(node) {
|
|
6
2
|
// Commits predating a setting omit its key. The server declares each with a
|
|
7
3
|
// default (`{}` for SIP headers, `null` for a shared extraction Schema), so
|
|
@@ -13,6 +9,11 @@ function normalizeNodeCompatibilityDefaults(node) {
|
|
|
13
9
|
if (typed.type === 'extract' && typed.schemaUuid === undefined) {
|
|
14
10
|
typed = { ...typed, schemaUuid: null };
|
|
15
11
|
}
|
|
12
|
+
// No override normalizes to a node written before overrides existed, the shape older locks hashed.
|
|
13
|
+
if (typed.type === 'extract' && typed.overrides?.llm === undefined) {
|
|
14
|
+
const { overrides: _noOverride, ...withoutOverrides } = typed;
|
|
15
|
+
typed = withoutOverrides;
|
|
16
|
+
}
|
|
16
17
|
// A chat transfer is the one node whose execution message has no default, so
|
|
17
18
|
// absent survives a parse. The call serializer reads it as `?? null`, which
|
|
18
19
|
// makes the two the same value to everything downstream.
|
|
@@ -41,7 +42,11 @@ function normalizePromptDefaults(node) {
|
|
|
41
42
|
function normalizeSharedNodeDefaults(untypedNode) {
|
|
42
43
|
const node = normalizePromptDefaults(untypedNode);
|
|
43
44
|
const normalizedEdges = node.edges.map((edge) => (edge.filter === undefined ? { ...edge, filter: null } : edge));
|
|
44
|
-
|
|
45
|
+
// The global, update-parameters and collect-credit-card nodes have no capabilities.
|
|
46
|
+
if (!('builtInTools' in node)) {
|
|
47
|
+
return { ...node, edges: normalizedEdges };
|
|
48
|
+
}
|
|
49
|
+
const alwaysAvailable = node.builtInTools.alwaysAvailable;
|
|
45
50
|
if (alwaysAvailable === undefined || alwaysAvailable.filter !== undefined) {
|
|
46
51
|
return { ...node, edges: normalizedEdges };
|
|
47
52
|
}
|
|
@@ -70,15 +75,16 @@ function normalizeSharedNodeDefaults(untypedNode) {
|
|
|
70
75
|
}
|
|
71
76
|
/**
|
|
72
77
|
* Fills defaults added after older Agent commits were stored. Pull, diff, and
|
|
73
|
-
*
|
|
74
|
-
*
|
|
78
|
+
* pull verification must all use this same canonical content shape so a freshly
|
|
79
|
+
* pulled project is clean against its lock.
|
|
75
80
|
*/
|
|
76
81
|
export function normalizeAgentV2CommitContent(content) {
|
|
82
|
+
const { guardrails, nodeCheck, ...config } = content.config;
|
|
77
83
|
return {
|
|
78
84
|
...content,
|
|
79
85
|
nodes: content.nodes.map(normalizeNodeCompatibilityDefaults),
|
|
80
86
|
config: {
|
|
81
|
-
...
|
|
87
|
+
...config,
|
|
82
88
|
speech: {
|
|
83
89
|
...content.config.speech,
|
|
84
90
|
voiceFormattingEnabled: content.config.speech.voiceFormattingEnabled ?? false,
|
|
@@ -90,16 +96,28 @@ export function normalizeAgentV2CommitContent(content) {
|
|
|
90
96
|
// the organization.
|
|
91
97
|
piiRedaction: content.config.call.piiRedaction ?? null,
|
|
92
98
|
},
|
|
99
|
+
// The server declares a `null` default for the call-end Action, so a commit
|
|
100
|
+
// without one means the same as one storing null.
|
|
101
|
+
automaticActions: {
|
|
102
|
+
...content.config.automaticActions,
|
|
103
|
+
callEnd: content.config.automaticActions.callEnd ?? null,
|
|
104
|
+
},
|
|
93
105
|
// The server declares a `null` default for the background message, so a
|
|
94
|
-
// commit that predates the field means the same as one storing null.
|
|
106
|
+
// commit that predates the field means the same as one storing null. An
|
|
107
|
+
// empty `inputLabels` means the same as none, which is how compile writes it.
|
|
95
108
|
...(content.config.toolUseSites === undefined
|
|
96
109
|
? {}
|
|
97
110
|
: {
|
|
98
|
-
toolUseSites: content.config.toolUseSites.map((useSite) => ({
|
|
111
|
+
toolUseSites: content.config.toolUseSites.map(({ inputLabels, ...useSite }) => ({
|
|
99
112
|
...useSite,
|
|
113
|
+
...(inputLabels === undefined || Object.keys(inputLabels).length === 0 ? {} : { inputLabels }),
|
|
100
114
|
backgroundMessage: useSite.backgroundMessage ?? null,
|
|
101
115
|
})),
|
|
102
116
|
}),
|
|
117
|
+
// Defaults normalize to a commit written before the field, which is what a lock written then hashed, so an
|
|
118
|
+
// upgrade does not report a pristine project as changed.
|
|
119
|
+
...(guardrails === undefined || guardrails.length === 0 ? {} : { guardrails }),
|
|
120
|
+
...(nodeCheck?.enabled === true ? { nodeCheck } : {}),
|
|
103
121
|
// `toneGuidelines` and `checkInAfterSilence.delaySeconds` are deliberately
|
|
104
122
|
// not filled here. Both are three-state on the wire, and the authoring API
|
|
105
123
|
// reproduces each state exactly, so filling a default would rewrite a
|
|
@@ -107,120 +125,19 @@ export function normalizeAgentV2CommitContent(content) {
|
|
|
107
125
|
},
|
|
108
126
|
};
|
|
109
127
|
}
|
|
110
|
-
function replaceActionVersionUuid({ versionUuid, actions, options, }) {
|
|
111
|
-
const actionDefinition = actions.find((item) => item.sourceVersionUuid === versionUuid);
|
|
112
|
-
if (actionDefinition === undefined) {
|
|
113
|
-
return versionUuid;
|
|
114
|
-
}
|
|
115
|
-
return options.actionVersionUuids?.[actionDefinition.key] ?? versionUuid;
|
|
116
|
-
}
|
|
117
|
-
function compileSnapshotNode({ node, actions, options, }) {
|
|
118
|
-
if (node.type === 'action_node') {
|
|
119
|
-
return {
|
|
120
|
-
...node,
|
|
121
|
-
actionVersionUuid: replaceActionVersionUuid({
|
|
122
|
-
versionUuid: node.actionVersionUuid,
|
|
123
|
-
actions,
|
|
124
|
-
options,
|
|
125
|
-
}),
|
|
126
|
-
};
|
|
127
|
-
}
|
|
128
|
-
if (node.type === 'standard' && node.perTurnAction != null) {
|
|
129
|
-
return {
|
|
130
|
-
...node,
|
|
131
|
-
perTurnAction: {
|
|
132
|
-
...node.perTurnAction,
|
|
133
|
-
actionVersionUuid: replaceActionVersionUuid({
|
|
134
|
-
versionUuid: node.perTurnAction.actionVersionUuid,
|
|
135
|
-
actions,
|
|
136
|
-
options,
|
|
137
|
-
}),
|
|
138
|
-
},
|
|
139
|
-
};
|
|
140
|
-
}
|
|
141
|
-
return node;
|
|
142
|
-
}
|
|
143
|
-
function compileSnapshot(definition, options) {
|
|
144
|
-
const normalizedContent = normalizeAgentV2CommitContent(definition.content);
|
|
145
|
-
const snapshotActionValues = (values) => {
|
|
146
|
-
switch (values.actionType) {
|
|
147
|
-
case 'code':
|
|
148
|
-
return {
|
|
149
|
-
...values,
|
|
150
|
-
operation: {
|
|
151
|
-
...values.operation,
|
|
152
|
-
compiledJs: null,
|
|
153
|
-
},
|
|
154
|
-
};
|
|
155
|
-
case 'http':
|
|
156
|
-
case 'custom_data':
|
|
157
|
-
case 'knowledge_base':
|
|
158
|
-
case 'built_in':
|
|
159
|
-
return values;
|
|
160
|
-
default: {
|
|
161
|
-
values;
|
|
162
|
-
throw new Error(`Unsupported Action type in snapshot: ${JSON.stringify(values)}`);
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
};
|
|
166
|
-
return {
|
|
167
|
-
agent: definition.agent,
|
|
168
|
-
branch: definition.branch,
|
|
169
|
-
actions: definition.actions.map((item) => ({
|
|
170
|
-
key: item.key,
|
|
171
|
-
versionUuid: replaceActionVersionUuid({
|
|
172
|
-
versionUuid: item.sourceVersionUuid,
|
|
173
|
-
actions: definition.actions,
|
|
174
|
-
options,
|
|
175
|
-
}),
|
|
176
|
-
values: snapshotActionValues(item.values),
|
|
177
|
-
})),
|
|
178
|
-
content: {
|
|
179
|
-
...normalizedContent,
|
|
180
|
-
config: {
|
|
181
|
-
...normalizedContent.config,
|
|
182
|
-
...(normalizedContent.config.toolUseSites === undefined
|
|
183
|
-
? {}
|
|
184
|
-
: {
|
|
185
|
-
toolUseSites: normalizedContent.config.toolUseSites.map((useSite) => ({
|
|
186
|
-
...useSite,
|
|
187
|
-
actionVersionUuid: replaceActionVersionUuid({
|
|
188
|
-
versionUuid: useSite.actionVersionUuid,
|
|
189
|
-
actions: definition.actions,
|
|
190
|
-
options,
|
|
191
|
-
}),
|
|
192
|
-
})),
|
|
193
|
-
}),
|
|
194
|
-
automaticActions: {
|
|
195
|
-
beforeCallStart: normalizedContent.config.automaticActions.beforeCallStart === null
|
|
196
|
-
? null
|
|
197
|
-
: {
|
|
198
|
-
...normalizedContent.config.automaticActions.beforeCallStart,
|
|
199
|
-
actionVersionUuid: replaceActionVersionUuid({
|
|
200
|
-
versionUuid: normalizedContent.config.automaticActions.beforeCallStart.actionVersionUuid,
|
|
201
|
-
actions: definition.actions,
|
|
202
|
-
options,
|
|
203
|
-
}),
|
|
204
|
-
},
|
|
205
|
-
},
|
|
206
|
-
},
|
|
207
|
-
nodes: normalizedContent.nodes.map((node) => compileSnapshotNode({ node, actions: definition.actions, options })),
|
|
208
|
-
},
|
|
209
|
-
};
|
|
210
|
-
}
|
|
211
|
-
export function compileAgentProject(definition, options = {}) {
|
|
212
|
-
return definition.kind === 'agent-definition'
|
|
213
|
-
? compileAgent(definition, options)
|
|
214
|
-
: compileSnapshot(definition, options);
|
|
215
|
-
}
|
|
216
128
|
export function collectActionVersionUuids(content) {
|
|
217
129
|
const versionUuids = new Set();
|
|
218
130
|
for (const useSite of content.config.toolUseSites ?? []) {
|
|
219
131
|
versionUuids.add(useSite.actionVersionUuid);
|
|
220
132
|
}
|
|
221
|
-
const
|
|
222
|
-
|
|
223
|
-
|
|
133
|
+
const { beforeCallStart, callEnd } = content.config.automaticActions;
|
|
134
|
+
for (const automaticAction of [beforeCallStart, callEnd]) {
|
|
135
|
+
if (automaticAction != null) {
|
|
136
|
+
versionUuids.add(automaticAction.actionVersionUuid);
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
for (const useSite of assistActionUseSites(content.config.assist)) {
|
|
140
|
+
versionUuids.add(useSite.actionVersionUuid);
|
|
224
141
|
}
|
|
225
142
|
for (const node of content.nodes) {
|
|
226
143
|
if (node.type === 'action_node') {
|
|
@@ -232,3 +149,13 @@ export function collectActionVersionUuids(content) {
|
|
|
232
149
|
}
|
|
233
150
|
return [...versionUuids];
|
|
234
151
|
}
|
|
152
|
+
/** Every Action use site an Agent Assist playbook runs: its procedures' steps first, then its card buttons. */
|
|
153
|
+
export function assistActionUseSites(assist) {
|
|
154
|
+
if (assist === undefined) {
|
|
155
|
+
return [];
|
|
156
|
+
}
|
|
157
|
+
return [
|
|
158
|
+
...assist.procedures.flatMap((procedure) => procedure.steps.flatMap((step) => (step.kind === 'run_action' ? [step.action] : []))),
|
|
159
|
+
...assist.cards.flatMap((card) => card.buttons.map((button) => button.action)),
|
|
160
|
+
];
|
|
161
|
+
}
|
package/dist/schemas.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.batchUpsertRowsSchema = exports.recordPayloadSchema = exports.listOptionsSchema = exports.queryInputSchema = exports.dataFilterSchema = exports.dataColumnPathSchema = exports.filterValueSchema = exports.tableNameSchema = exports.MAX_BATCH_ROWS = exports.MAX_QUERY_SIZE = void 0;
|
|
3
|
+
exports.clientCredentialsTokenSchema = exports.clientCredentialsTokenInputSchema = exports.batchUpsertRowsSchema = exports.recordPayloadSchema = exports.listOptionsSchema = exports.queryInputSchema = exports.dataFilterSchema = exports.dataColumnPathSchema = exports.filterValueSchema = exports.tableNameSchema = exports.MAX_BATCH_ROWS = exports.MAX_QUERY_SIZE = void 0;
|
|
4
4
|
const zod_1 = require("zod");
|
|
5
5
|
/**
|
|
6
6
|
* Request wire schemas for the Simple AI public REST API (`/api/v1`).
|
|
@@ -48,3 +48,29 @@ exports.listOptionsSchema = zod_1.z.object({
|
|
|
48
48
|
});
|
|
49
49
|
exports.recordPayloadSchema = zod_1.z.record(zod_1.z.string(), zod_1.z.unknown());
|
|
50
50
|
exports.batchUpsertRowsSchema = zod_1.z.array(exports.recordPayloadSchema).min(1).max(exports.MAX_BATCH_ROWS);
|
|
51
|
+
const RESERVED_TOKEN_PARAMETERS = new Set(['grant_type', 'client_id', 'client_secret', 'scope']);
|
|
52
|
+
/** Strict, so a misspelled or unsupported option fails here instead of being silently dropped. */
|
|
53
|
+
exports.clientCredentialsTokenInputSchema = zod_1.z.strictObject({
|
|
54
|
+
tokenUrl: zod_1.z.url({ protocol: /^https$/ }),
|
|
55
|
+
clientId: zod_1.z.string().min(1),
|
|
56
|
+
clientSecret: zod_1.z.string().min(1),
|
|
57
|
+
/** How the client authenticates to the token endpoint; HTTP Basic is the one RFC 6749 requires servers to support. */
|
|
58
|
+
clientAuthentication: zod_1.z.enum(['client_secret_basic', 'client_secret_post']).default('client_secret_basic'),
|
|
59
|
+
scope: zod_1.z.string().min(1).nullable().default(null),
|
|
60
|
+
/** Additional token request parameters, such as `audience` (Auth0) or `resource` (Azure AD v1). */
|
|
61
|
+
extraParameters: zod_1.z
|
|
62
|
+
.record(zod_1.z.string().min(1), zod_1.z.string())
|
|
63
|
+
.refine((parameters) => Object.keys(parameters).every((name) => !RESERVED_TOKEN_PARAMETERS.has(name)), {
|
|
64
|
+
message: 'extraParameters cannot set grant_type, client_id, client_secret or scope',
|
|
65
|
+
})
|
|
66
|
+
.default({}),
|
|
67
|
+
forceRefresh: zod_1.z.boolean().default(false),
|
|
68
|
+
});
|
|
69
|
+
// ---------------------------------------------------------------------------
|
|
70
|
+
// Response types (typed, tolerantly parsed)
|
|
71
|
+
// ---------------------------------------------------------------------------
|
|
72
|
+
exports.clientCredentialsTokenSchema = zod_1.z.object({
|
|
73
|
+
accessToken: zod_1.z.string(),
|
|
74
|
+
tokenType: zod_1.z.string().nullable(),
|
|
75
|
+
expiresAt: zod_1.z.string().nullable(),
|
|
76
|
+
});
|
package/dist/schemas.d.cts
CHANGED
|
@@ -45,6 +45,26 @@ export type ListOptions = z.input<typeof listOptionsSchema>;
|
|
|
45
45
|
export declare const recordPayloadSchema: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
46
46
|
export type RecordPayload = z.infer<typeof recordPayloadSchema>;
|
|
47
47
|
export declare const batchUpsertRowsSchema: z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
48
|
+
/** Strict, so a misspelled or unsupported option fails here instead of being silently dropped. */
|
|
49
|
+
export declare const clientCredentialsTokenInputSchema: z.ZodObject<{
|
|
50
|
+
tokenUrl: z.ZodURL;
|
|
51
|
+
clientId: z.ZodString;
|
|
52
|
+
clientSecret: z.ZodString;
|
|
53
|
+
clientAuthentication: z.ZodDefault<z.ZodEnum<{
|
|
54
|
+
client_secret_basic: "client_secret_basic";
|
|
55
|
+
client_secret_post: "client_secret_post";
|
|
56
|
+
}>>;
|
|
57
|
+
scope: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
58
|
+
extraParameters: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
59
|
+
forceRefresh: z.ZodDefault<z.ZodBoolean>;
|
|
60
|
+
}, z.core.$strict>;
|
|
61
|
+
export type ClientCredentialsTokenInput = z.input<typeof clientCredentialsTokenInputSchema>;
|
|
62
|
+
export declare const clientCredentialsTokenSchema: z.ZodObject<{
|
|
63
|
+
accessToken: z.ZodString;
|
|
64
|
+
tokenType: z.ZodNullable<z.ZodString>;
|
|
65
|
+
expiresAt: z.ZodNullable<z.ZodString>;
|
|
66
|
+
}, z.core.$strip>;
|
|
67
|
+
export type ClientCredentialsToken = z.infer<typeof clientCredentialsTokenSchema>;
|
|
48
68
|
export type DataRecord = Record<string, unknown>;
|
|
49
69
|
export type QueryResult = {
|
|
50
70
|
records: DataRecord[];
|
package/dist/schemas.d.ts
CHANGED
|
@@ -45,6 +45,26 @@ export type ListOptions = z.input<typeof listOptionsSchema>;
|
|
|
45
45
|
export declare const recordPayloadSchema: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
46
46
|
export type RecordPayload = z.infer<typeof recordPayloadSchema>;
|
|
47
47
|
export declare const batchUpsertRowsSchema: z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
48
|
+
/** Strict, so a misspelled or unsupported option fails here instead of being silently dropped. */
|
|
49
|
+
export declare const clientCredentialsTokenInputSchema: z.ZodObject<{
|
|
50
|
+
tokenUrl: z.ZodURL;
|
|
51
|
+
clientId: z.ZodString;
|
|
52
|
+
clientSecret: z.ZodString;
|
|
53
|
+
clientAuthentication: z.ZodDefault<z.ZodEnum<{
|
|
54
|
+
client_secret_basic: "client_secret_basic";
|
|
55
|
+
client_secret_post: "client_secret_post";
|
|
56
|
+
}>>;
|
|
57
|
+
scope: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
58
|
+
extraParameters: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
59
|
+
forceRefresh: z.ZodDefault<z.ZodBoolean>;
|
|
60
|
+
}, z.core.$strict>;
|
|
61
|
+
export type ClientCredentialsTokenInput = z.input<typeof clientCredentialsTokenInputSchema>;
|
|
62
|
+
export declare const clientCredentialsTokenSchema: z.ZodObject<{
|
|
63
|
+
accessToken: z.ZodString;
|
|
64
|
+
tokenType: z.ZodNullable<z.ZodString>;
|
|
65
|
+
expiresAt: z.ZodNullable<z.ZodString>;
|
|
66
|
+
}, z.core.$strip>;
|
|
67
|
+
export type ClientCredentialsToken = z.infer<typeof clientCredentialsTokenSchema>;
|
|
48
68
|
export type DataRecord = Record<string, unknown>;
|
|
49
69
|
export type QueryResult = {
|
|
50
70
|
records: DataRecord[];
|
package/dist/schemas.js
CHANGED
|
@@ -45,3 +45,29 @@ export const listOptionsSchema = z.object({
|
|
|
45
45
|
});
|
|
46
46
|
export const recordPayloadSchema = z.record(z.string(), z.unknown());
|
|
47
47
|
export const batchUpsertRowsSchema = z.array(recordPayloadSchema).min(1).max(MAX_BATCH_ROWS);
|
|
48
|
+
const RESERVED_TOKEN_PARAMETERS = new Set(['grant_type', 'client_id', 'client_secret', 'scope']);
|
|
49
|
+
/** Strict, so a misspelled or unsupported option fails here instead of being silently dropped. */
|
|
50
|
+
export const clientCredentialsTokenInputSchema = z.strictObject({
|
|
51
|
+
tokenUrl: z.url({ protocol: /^https$/ }),
|
|
52
|
+
clientId: z.string().min(1),
|
|
53
|
+
clientSecret: z.string().min(1),
|
|
54
|
+
/** How the client authenticates to the token endpoint; HTTP Basic is the one RFC 6749 requires servers to support. */
|
|
55
|
+
clientAuthentication: z.enum(['client_secret_basic', 'client_secret_post']).default('client_secret_basic'),
|
|
56
|
+
scope: z.string().min(1).nullable().default(null),
|
|
57
|
+
/** Additional token request parameters, such as `audience` (Auth0) or `resource` (Azure AD v1). */
|
|
58
|
+
extraParameters: z
|
|
59
|
+
.record(z.string().min(1), z.string())
|
|
60
|
+
.refine((parameters) => Object.keys(parameters).every((name) => !RESERVED_TOKEN_PARAMETERS.has(name)), {
|
|
61
|
+
message: 'extraParameters cannot set grant_type, client_id, client_secret or scope',
|
|
62
|
+
})
|
|
63
|
+
.default({}),
|
|
64
|
+
forceRefresh: z.boolean().default(false),
|
|
65
|
+
});
|
|
66
|
+
// ---------------------------------------------------------------------------
|
|
67
|
+
// Response types (typed, tolerantly parsed)
|
|
68
|
+
// ---------------------------------------------------------------------------
|
|
69
|
+
export const clientCredentialsTokenSchema = z.object({
|
|
70
|
+
accessToken: z.string(),
|
|
71
|
+
tokenType: z.string().nullable(),
|
|
72
|
+
expiresAt: z.string().nullable(),
|
|
73
|
+
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@simple-ai-lab/sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.14.0",
|
|
4
4
|
"description": "Simple AI SDK - define action-first agents and access your organization's data.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "Elastic-2.0",
|
|
@@ -22,14 +22,14 @@
|
|
|
22
22
|
}
|
|
23
23
|
},
|
|
24
24
|
"peerDependencies": {
|
|
25
|
-
"zod": "^4.
|
|
25
|
+
"zod": "^4.6.6"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
28
|
"@biomejs/biome": "^2.4.4",
|
|
29
29
|
"@types/node": "^25.9.3",
|
|
30
30
|
"typescript": "^5.9.3",
|
|
31
|
-
"vitest": "4.1.
|
|
32
|
-
"zod": "^4.
|
|
31
|
+
"vitest": "4.1.12",
|
|
32
|
+
"zod": "^4.6.6",
|
|
33
33
|
"zshy": "^0.7.3"
|
|
34
34
|
},
|
|
35
35
|
"publishConfig": {
|
|
@@ -64,11 +64,11 @@
|
|
|
64
64
|
}
|
|
65
65
|
},
|
|
66
66
|
"scripts": {
|
|
67
|
-
"build": "zshy",
|
|
68
|
-
"lint": "
|
|
67
|
+
"build": "zshy && pnpm --dir ../.. exec biome format --write projects/simple-ai-sdk/package.json",
|
|
68
|
+
"lint": "run-p -c -l 'lint:*' typecheck",
|
|
69
|
+
"lint:biome": "pnpm --dir ../.. exec biome check projects/simple-ai-sdk/src",
|
|
70
|
+
"typecheck": "tsrs --noEmit",
|
|
69
71
|
"lint-fix": "pnpm --dir ../.. exec biome check --fix projects/simple-ai-sdk/src",
|
|
70
|
-
"
|
|
71
|
-
"test": "vitest --run",
|
|
72
|
-
"format": "pnpm --dir ../.. exec biome check --fix projects/simple-ai-sdk/src"
|
|
72
|
+
"test": "vitest --run"
|
|
73
73
|
}
|
|
74
74
|
}
|