@simple-ai-lab/sdk 0.11.0 → 0.12.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/agents.d.cts +4 -0
- package/dist/agents.d.ts +4 -0
- 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 +3 -2
- package/dist/index.d.cts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +1 -1
- 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 +26 -13
- package/dist/projects.js +26 -13
- package/dist/schemas.cjs +27 -1
- package/dist/schemas.d.cts +22 -0
- package/dist/schemas.d.ts +22 -0
- package/dist/schemas.js +26 -0
- package/package.json +2 -2
package/dist/agents.d.cts
CHANGED
|
@@ -350,6 +350,10 @@ export type AgentV2ConfigWire = {
|
|
|
350
350
|
beforeCallStart: (ActionUseSiteWire & {
|
|
351
351
|
trigger: 'before_call_start';
|
|
352
352
|
}) | null;
|
|
353
|
+
/** Absent in commits written before the trigger existed. Source cannot author it yet; snapshots carry it. */
|
|
354
|
+
callEnd?: (ActionUseSiteWire & {
|
|
355
|
+
trigger: 'call_end';
|
|
356
|
+
}) | null;
|
|
353
357
|
};
|
|
354
358
|
knowledgeBaseIds: string[];
|
|
355
359
|
abTestGroupIds: string[];
|
package/dist/agents.d.ts
CHANGED
|
@@ -350,6 +350,10 @@ export type AgentV2ConfigWire = {
|
|
|
350
350
|
beforeCallStart: (ActionUseSiteWire & {
|
|
351
351
|
trigger: 'before_call_start';
|
|
352
352
|
}) | null;
|
|
353
|
+
/** Absent in commits written before the trigger existed. Source cannot author it yet; snapshots carry it. */
|
|
354
|
+
callEnd?: (ActionUseSiteWire & {
|
|
355
|
+
trigger: 'call_end';
|
|
356
|
+
}) | null;
|
|
353
357
|
};
|
|
354
358
|
knowledgeBaseIds: string[];
|
|
355
359
|
abTestGroupIds: string[];
|
package/dist/client.cjs
CHANGED
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.SimpleAI = void 0;
|
|
4
4
|
const data_1 = require("./data.cjs");
|
|
5
5
|
const http_1 = require("./http.cjs");
|
|
6
|
+
const oauth_1 = require("./oauth.cjs");
|
|
6
7
|
const DEFAULT_BASE_URL = 'https://api.prod.usesimple.ai/api/v1';
|
|
7
8
|
function envVar(name) {
|
|
8
9
|
if (typeof process === 'undefined' || process.env === undefined) {
|
|
@@ -14,6 +15,8 @@ function envVar(name) {
|
|
|
14
15
|
class SimpleAI {
|
|
15
16
|
/** Custom data tables — query, read, and write records. */
|
|
16
17
|
data;
|
|
18
|
+
/** OAuth 2.0 access tokens for calling your own systems. */
|
|
19
|
+
oauth;
|
|
17
20
|
constructor(options = {}) {
|
|
18
21
|
const apiKey = options.apiKey ?? envVar('SIMPLE_API_KEY');
|
|
19
22
|
if (apiKey === undefined) {
|
|
@@ -24,6 +27,7 @@ class SimpleAI {
|
|
|
24
27
|
const fetchImplementation = options.fetch ?? ((url, init) => fetch(url, init));
|
|
25
28
|
const http = (0, http_1.createHttpClient)({ baseUrl, apiKey, fetchImplementation });
|
|
26
29
|
this.data = new data_1.DataClient(http);
|
|
30
|
+
this.oauth = new oauth_1.OAuthClient(http);
|
|
27
31
|
}
|
|
28
32
|
}
|
|
29
33
|
exports.SimpleAI = SimpleAI;
|
package/dist/client.d.cts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { DataClient } from "./data.cjs";
|
|
2
2
|
import type { FetchLike } from "./http.cjs";
|
|
3
|
+
import { OAuthClient } from "./oauth.cjs";
|
|
3
4
|
export type SimpleAIOptions = {
|
|
4
5
|
/** API key (dashboard: Settings → API Keys). Defaults to SIMPLE_API_KEY — inside code actions this is injected automatically. */
|
|
5
6
|
apiKey?: string;
|
|
@@ -11,5 +12,7 @@ export type SimpleAIOptions = {
|
|
|
11
12
|
export declare class SimpleAI {
|
|
12
13
|
/** Custom data tables — query, read, and write records. */
|
|
13
14
|
readonly data: DataClient;
|
|
15
|
+
/** OAuth 2.0 access tokens for calling your own systems. */
|
|
16
|
+
readonly oauth: OAuthClient;
|
|
14
17
|
constructor(options?: SimpleAIOptions);
|
|
15
18
|
}
|
package/dist/client.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { DataClient } from "./data.js";
|
|
2
2
|
import type { FetchLike } from "./http.js";
|
|
3
|
+
import { OAuthClient } from "./oauth.js";
|
|
3
4
|
export type SimpleAIOptions = {
|
|
4
5
|
/** API key (dashboard: Settings → API Keys). Defaults to SIMPLE_API_KEY — inside code actions this is injected automatically. */
|
|
5
6
|
apiKey?: string;
|
|
@@ -11,5 +12,7 @@ export type SimpleAIOptions = {
|
|
|
11
12
|
export declare class SimpleAI {
|
|
12
13
|
/** Custom data tables — query, read, and write records. */
|
|
13
14
|
readonly data: DataClient;
|
|
15
|
+
/** OAuth 2.0 access tokens for calling your own systems. */
|
|
16
|
+
readonly oauth: OAuthClient;
|
|
14
17
|
constructor(options?: SimpleAIOptions);
|
|
15
18
|
}
|
package/dist/client.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { DataClient } from "./data.js";
|
|
2
2
|
import { createHttpClient } from "./http.js";
|
|
3
|
+
import { OAuthClient } from "./oauth.js";
|
|
3
4
|
const DEFAULT_BASE_URL = 'https://api.prod.usesimple.ai/api/v1';
|
|
4
5
|
function envVar(name) {
|
|
5
6
|
if (typeof process === 'undefined' || process.env === undefined) {
|
|
@@ -11,6 +12,8 @@ function envVar(name) {
|
|
|
11
12
|
export class SimpleAI {
|
|
12
13
|
/** Custom data tables — query, read, and write records. */
|
|
13
14
|
data;
|
|
15
|
+
/** OAuth 2.0 access tokens for calling your own systems. */
|
|
16
|
+
oauth;
|
|
14
17
|
constructor(options = {}) {
|
|
15
18
|
const apiKey = options.apiKey ?? envVar('SIMPLE_API_KEY');
|
|
16
19
|
if (apiKey === undefined) {
|
|
@@ -21,5 +24,6 @@ export class SimpleAI {
|
|
|
21
24
|
const fetchImplementation = options.fetch ?? ((url, init) => fetch(url, init));
|
|
22
25
|
const http = createHttpClient({ baseUrl, apiKey, fetchImplementation });
|
|
23
26
|
this.data = new DataClient(http);
|
|
27
|
+
this.oauth = new OAuthClient(http);
|
|
24
28
|
}
|
|
25
29
|
}
|
|
@@ -46,6 +46,7 @@ function defineAction(handler) {
|
|
|
46
46
|
inputs,
|
|
47
47
|
config,
|
|
48
48
|
metadata,
|
|
49
|
+
simulation: invocation.simulation ?? null,
|
|
49
50
|
client,
|
|
50
51
|
workflow: (0, workflow_1.createActionWorkflow)({ metadata, carrier: invocation }),
|
|
51
52
|
llm: (0, llm_1.createActionLlm)({ metadata }),
|
|
@@ -69,6 +70,7 @@ function defineCustomDataTransform(handler) {
|
|
|
69
70
|
operation,
|
|
70
71
|
config,
|
|
71
72
|
metadata,
|
|
73
|
+
simulation: invocation.simulation ?? null,
|
|
72
74
|
client,
|
|
73
75
|
llm: (0, llm_1.createActionLlm)({ metadata }),
|
|
74
76
|
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { SimpleAI } from "../client.cjs";
|
|
2
2
|
import { type ActionLlm } from "./llm.cjs";
|
|
3
|
-
import type { ActionInvocationMetadata } from "./types.cjs";
|
|
3
|
+
import type { ActionInvocationMetadata, ActionSimulation } from "./types.cjs";
|
|
4
4
|
import { type ActionDirectiveCarrier, type ActionWorkflow } from "./workflow.cjs";
|
|
5
5
|
/**
|
|
6
6
|
* Brand the code-action runner uses to recognize `defineAction` handlers. The
|
|
@@ -39,6 +39,12 @@ export type CustomDataTransformContext<TItem = Record<string, unknown>, TInputs
|
|
|
39
39
|
config: Record<string, string>;
|
|
40
40
|
/** What this invocation is allowed to do, decided by the use site that invoked it. */
|
|
41
41
|
metadata: ActionInvocationMetadata;
|
|
42
|
+
/**
|
|
43
|
+
* Present when this invocation runs inside a simulation; null on real calls. The simulated clock
|
|
44
|
+
* is also installed on `Date`, so this tells you the clock is simulated rather than being the
|
|
45
|
+
* way to read it.
|
|
46
|
+
*/
|
|
47
|
+
simulation: ActionSimulation | null;
|
|
42
48
|
client: SimpleAI;
|
|
43
49
|
/** Call an LLM through Simple's LLM router. */
|
|
44
50
|
llm: ActionLlm;
|
|
@@ -50,6 +56,12 @@ export type ActionContext<TInputs = Record<string, unknown>> = {
|
|
|
50
56
|
config: Record<string, string>;
|
|
51
57
|
/** What this invocation is allowed to do, decided by the use site that invoked it. */
|
|
52
58
|
metadata: ActionInvocationMetadata;
|
|
59
|
+
/**
|
|
60
|
+
* Present when this invocation runs inside a simulation; null on real calls. The simulated clock
|
|
61
|
+
* is also installed on `Date`, so this tells you the clock is simulated rather than being the
|
|
62
|
+
* way to read it.
|
|
63
|
+
*/
|
|
64
|
+
simulation: ActionSimulation | null;
|
|
53
65
|
/** The Simple AI SDK, authenticated for your organization. */
|
|
54
66
|
client: SimpleAI;
|
|
55
67
|
/** Ask the workflow that invoked this Action to do something, e.g. run a different node next. */
|
|
@@ -62,6 +74,8 @@ export type ActionHandler<TInputs = Record<string, unknown>, TResult = unknown>
|
|
|
62
74
|
config: Record<string, string>;
|
|
63
75
|
/** Omitted by runtimes that predate invocation metadata; the handler still receives one. */
|
|
64
76
|
metadata?: ActionInvocationMetadata;
|
|
77
|
+
/** Omitted by runtimes that predate simulations; the handler then receives null. */
|
|
78
|
+
simulation?: ActionSimulation | null;
|
|
65
79
|
[SIMPLE_ACTION_RUNTIME]?: ActionRuntime;
|
|
66
80
|
} & ActionDirectiveCarrier) => Promise<TResult>) & {
|
|
67
81
|
[SIMPLE_ACTION_BRAND]: true;
|
|
@@ -73,6 +87,8 @@ export type CustomDataTransformHandler<TItem = Record<string, unknown>, TInputs
|
|
|
73
87
|
config: Record<string, string>;
|
|
74
88
|
/** Omitted by runtimes that predate invocation metadata; the handler still receives one. */
|
|
75
89
|
metadata?: ActionInvocationMetadata;
|
|
90
|
+
/** Omitted by runtimes that predate simulations; the handler then receives null. */
|
|
91
|
+
simulation?: ActionSimulation | null;
|
|
76
92
|
[SIMPLE_ACTION_RUNTIME]?: ActionRuntime;
|
|
77
93
|
}) => Promise<TResult>) & {
|
|
78
94
|
[SIMPLE_ACTION_BRAND]: true;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { SimpleAI } from "../client.js";
|
|
2
2
|
import { type ActionLlm } from "./llm.js";
|
|
3
|
-
import type { ActionInvocationMetadata } from "./types.js";
|
|
3
|
+
import type { ActionInvocationMetadata, ActionSimulation } from "./types.js";
|
|
4
4
|
import { type ActionDirectiveCarrier, type ActionWorkflow } from "./workflow.js";
|
|
5
5
|
/**
|
|
6
6
|
* Brand the code-action runner uses to recognize `defineAction` handlers. The
|
|
@@ -39,6 +39,12 @@ export type CustomDataTransformContext<TItem = Record<string, unknown>, TInputs
|
|
|
39
39
|
config: Record<string, string>;
|
|
40
40
|
/** What this invocation is allowed to do, decided by the use site that invoked it. */
|
|
41
41
|
metadata: ActionInvocationMetadata;
|
|
42
|
+
/**
|
|
43
|
+
* Present when this invocation runs inside a simulation; null on real calls. The simulated clock
|
|
44
|
+
* is also installed on `Date`, so this tells you the clock is simulated rather than being the
|
|
45
|
+
* way to read it.
|
|
46
|
+
*/
|
|
47
|
+
simulation: ActionSimulation | null;
|
|
42
48
|
client: SimpleAI;
|
|
43
49
|
/** Call an LLM through Simple's LLM router. */
|
|
44
50
|
llm: ActionLlm;
|
|
@@ -50,6 +56,12 @@ export type ActionContext<TInputs = Record<string, unknown>> = {
|
|
|
50
56
|
config: Record<string, string>;
|
|
51
57
|
/** What this invocation is allowed to do, decided by the use site that invoked it. */
|
|
52
58
|
metadata: ActionInvocationMetadata;
|
|
59
|
+
/**
|
|
60
|
+
* Present when this invocation runs inside a simulation; null on real calls. The simulated clock
|
|
61
|
+
* is also installed on `Date`, so this tells you the clock is simulated rather than being the
|
|
62
|
+
* way to read it.
|
|
63
|
+
*/
|
|
64
|
+
simulation: ActionSimulation | null;
|
|
53
65
|
/** The Simple AI SDK, authenticated for your organization. */
|
|
54
66
|
client: SimpleAI;
|
|
55
67
|
/** Ask the workflow that invoked this Action to do something, e.g. run a different node next. */
|
|
@@ -62,6 +74,8 @@ export type ActionHandler<TInputs = Record<string, unknown>, TResult = unknown>
|
|
|
62
74
|
config: Record<string, string>;
|
|
63
75
|
/** Omitted by runtimes that predate invocation metadata; the handler still receives one. */
|
|
64
76
|
metadata?: ActionInvocationMetadata;
|
|
77
|
+
/** Omitted by runtimes that predate simulations; the handler then receives null. */
|
|
78
|
+
simulation?: ActionSimulation | null;
|
|
65
79
|
[SIMPLE_ACTION_RUNTIME]?: ActionRuntime;
|
|
66
80
|
} & ActionDirectiveCarrier) => Promise<TResult>) & {
|
|
67
81
|
[SIMPLE_ACTION_BRAND]: true;
|
|
@@ -73,6 +87,8 @@ export type CustomDataTransformHandler<TItem = Record<string, unknown>, TInputs
|
|
|
73
87
|
config: Record<string, string>;
|
|
74
88
|
/** Omitted by runtimes that predate invocation metadata; the handler still receives one. */
|
|
75
89
|
metadata?: ActionInvocationMetadata;
|
|
90
|
+
/** Omitted by runtimes that predate simulations; the handler then receives null. */
|
|
91
|
+
simulation?: ActionSimulation | null;
|
|
76
92
|
[SIMPLE_ACTION_RUNTIME]?: ActionRuntime;
|
|
77
93
|
}) => Promise<TResult>) & {
|
|
78
94
|
[SIMPLE_ACTION_BRAND]: true;
|
|
@@ -41,6 +41,7 @@ export function defineAction(handler) {
|
|
|
41
41
|
inputs,
|
|
42
42
|
config,
|
|
43
43
|
metadata,
|
|
44
|
+
simulation: invocation.simulation ?? null,
|
|
44
45
|
client,
|
|
45
46
|
workflow: createActionWorkflow({ metadata, carrier: invocation }),
|
|
46
47
|
llm: createActionLlm({ metadata }),
|
|
@@ -64,6 +65,7 @@ export function defineCustomDataTransform(handler) {
|
|
|
64
65
|
operation,
|
|
65
66
|
config,
|
|
66
67
|
metadata,
|
|
68
|
+
simulation: invocation.simulation ?? null,
|
|
67
69
|
client,
|
|
68
70
|
llm: createActionLlm({ metadata }),
|
|
69
71
|
});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export { MissingCapabilityError } from "../shared/errors.cjs";
|
|
2
2
|
export { type ActionContext, type ActionHandler, type CustomDataResult, type CustomDataTransformContext, type CustomDataTransformHandler, type CustomDataTransformOperation, defineAction, defineCustomDataTransform, SIMPLE_ACTION_BRAND, } from "./define-action.cjs";
|
|
3
|
-
export { ActionCapability, type ActionInvocationMetadata } from "./types.cjs";
|
|
3
|
+
export { ActionCapability, type ActionInvocationMetadata, type ActionSimulation } from "./types.cjs";
|
|
4
4
|
export type { ActionWorkflow, TransitionToOptions } from "./workflow.cjs";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export { MissingCapabilityError } from "../shared/errors.js";
|
|
2
2
|
export { type ActionContext, type ActionHandler, type CustomDataResult, type CustomDataTransformContext, type CustomDataTransformHandler, type CustomDataTransformOperation, defineAction, defineCustomDataTransform, SIMPLE_ACTION_BRAND, } from "./define-action.js";
|
|
3
|
-
export { ActionCapability, type ActionInvocationMetadata } from "./types.js";
|
|
3
|
+
export { ActionCapability, type ActionInvocationMetadata, type ActionSimulation } from "./types.js";
|
|
4
4
|
export type { ActionWorkflow, TransitionToOptions } from "./workflow.js";
|
|
@@ -17,3 +17,14 @@ export interface ActionInvocationMetadata {
|
|
|
17
17
|
apiKey: string;
|
|
18
18
|
};
|
|
19
19
|
}
|
|
20
|
+
/**
|
|
21
|
+
* Mirror of the simulation block the runtime puts on the wire — `CodeActionSimulationContext`
|
|
22
|
+
* in `@simple-ai-lab/shared` is the source of truth and these declarations must track it.
|
|
23
|
+
*/
|
|
24
|
+
export interface ActionSimulation {
|
|
25
|
+
/** The simulated clock, as milliseconds added to the real clock, and the time zone it runs in. */
|
|
26
|
+
clock: {
|
|
27
|
+
offset_ms: number;
|
|
28
|
+
timezone: string | null;
|
|
29
|
+
} | null;
|
|
30
|
+
}
|
|
@@ -17,3 +17,14 @@ export interface ActionInvocationMetadata {
|
|
|
17
17
|
apiKey: string;
|
|
18
18
|
};
|
|
19
19
|
}
|
|
20
|
+
/**
|
|
21
|
+
* Mirror of the simulation block the runtime puts on the wire — `CodeActionSimulationContext`
|
|
22
|
+
* in `@simple-ai-lab/shared` is the source of truth and these declarations must track it.
|
|
23
|
+
*/
|
|
24
|
+
export interface ActionSimulation {
|
|
25
|
+
/** The simulated clock, as milliseconds added to the real clock, and the time zone it runs in. */
|
|
26
|
+
clock: {
|
|
27
|
+
offset_ms: number;
|
|
28
|
+
timezone: string | null;
|
|
29
|
+
} | null;
|
|
30
|
+
}
|
package/dist/index.cjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
exports.SimpleAIError = exports.MissingCapabilityError = exports.tableNameSchema = exports.recordPayloadSchema = exports.queryInputSchema = exports.MAX_QUERY_SIZE = exports.MAX_BATCH_ROWS = exports.listOptionsSchema = exports.dataFilterSchema = void 0;
|
|
3
|
+
exports.clientCredentialsTokenInputSchema = exports.batchUpsertRowsSchema = exports.normalizeAgentV2CommitContent = exports.defineAgentSnapshot = exports.compileAgentProject = exports.collectActionVersionUuids = exports.DataClient = exports.ActionCapability = exports.SIMPLE_ACTION_BRAND = exports.defineCustomDataTransform = exports.defineAction = exports.SimpleAI = exports.WEB_SEARCH_OUTPUT_SCHEMA = exports.WEB_SEARCH_OUTPUT_MAPPINGS = exports.WEB_SEARCH_INPUT_SCHEMA = exports.VALIDATE_ADDRESS_OUTPUT_SCHEMA = exports.VALIDATE_ADDRESS_OUTPUT_MAPPINGS = exports.VALIDATE_ADDRESS_INPUT_SCHEMA = exports.SEND_TEXT_MESSAGE_OUTPUT_SCHEMA = exports.SEND_TEXT_MESSAGE_OUTPUT_MAPPINGS = exports.SEND_TEXT_MESSAGE_INPUT_SCHEMA = exports.SEND_EMAIL_OUTPUT_SCHEMA = exports.SEND_EMAIL_OUTPUT_MAPPINGS = exports.SEND_EMAIL_INPUT_SCHEMA = exports.BUILT_IN_ACTION_CONTRACTS = exports.TRANSITION_FILTER_MAX_DEPTH = exports.TRANSITION_FILTER_MAX_CONDITIONS = exports.resolveExtractionFields = exports.reference = exports.prompt = exports.PII_REDACTION_CATEGORIES = exports.node = exports.MAX_CONTAINMENT_RULE_DEPTH = exports.FIVE9_SIP_BYE_HEADER_NAMES = exports.defineAgent = exports.defaultBackgroundNoise = exports.DEFAULT_TRANSITION_MESSAGE = exports.DEFAULT_PER_TURN_RETRIEVAL_TOP_K = exports.DEFAULT_PER_TURN_RETRIEVAL_RECENT_TURNS = exports.DEFAULT_CHECK_IN_AFTER_SILENCE_DELAY_SECONDS = exports.compileAgent = exports.canonicalAuthoringKeys = exports.canonicalAuthoringKey = exports.sourceFile = exports.resolveActionIoSchema = exports.resolveActionHttpHeaders = exports.compileAction = exports.canonicalActionSource = exports.actionsIoSchemaFromZod = exports.action = void 0;
|
|
4
|
+
exports.SimpleAIError = exports.MissingCapabilityError = exports.tableNameSchema = exports.recordPayloadSchema = exports.queryInputSchema = exports.MAX_QUERY_SIZE = exports.MAX_BATCH_ROWS = exports.listOptionsSchema = exports.dataFilterSchema = exports.dataColumnPathSchema = void 0;
|
|
5
5
|
var actions_1 = require("./actions.cjs");
|
|
6
6
|
Object.defineProperty(exports, "action", { enumerable: true, get: function () { return actions_1.action; } });
|
|
7
7
|
Object.defineProperty(exports, "actionsIoSchemaFromZod", { enumerable: true, get: function () { return actions_1.actionsIoSchemaFromZod; } });
|
|
@@ -60,6 +60,7 @@ Object.defineProperty(exports, "defineAgentSnapshot", { enumerable: true, get: f
|
|
|
60
60
|
Object.defineProperty(exports, "normalizeAgentV2CommitContent", { enumerable: true, get: function () { return projects_1.normalizeAgentV2CommitContent; } });
|
|
61
61
|
var schemas_1 = require("./schemas.cjs");
|
|
62
62
|
Object.defineProperty(exports, "batchUpsertRowsSchema", { enumerable: true, get: function () { return schemas_1.batchUpsertRowsSchema; } });
|
|
63
|
+
Object.defineProperty(exports, "clientCredentialsTokenInputSchema", { enumerable: true, get: function () { return schemas_1.clientCredentialsTokenInputSchema; } });
|
|
63
64
|
Object.defineProperty(exports, "dataColumnPathSchema", { enumerable: true, get: function () { return schemas_1.dataColumnPathSchema; } });
|
|
64
65
|
Object.defineProperty(exports, "dataFilterSchema", { enumerable: true, get: function () { return schemas_1.dataFilterSchema; } });
|
|
65
66
|
Object.defineProperty(exports, "listOptionsSchema", { enumerable: true, get: function () { return schemas_1.listOptionsSchema; } });
|
package/dist/index.d.cts
CHANGED
|
@@ -3,10 +3,10 @@ export { type AbTestNodeDefinition, type ActionNodeDefinition, type AgentCompile
|
|
|
3
3
|
export { BUILT_IN_ACTION_CONTRACTS, SEND_EMAIL_INPUT_SCHEMA, SEND_EMAIL_OUTPUT_MAPPINGS, SEND_EMAIL_OUTPUT_SCHEMA, SEND_TEXT_MESSAGE_INPUT_SCHEMA, SEND_TEXT_MESSAGE_OUTPUT_MAPPINGS, SEND_TEXT_MESSAGE_OUTPUT_SCHEMA, VALIDATE_ADDRESS_INPUT_SCHEMA, VALIDATE_ADDRESS_OUTPUT_MAPPINGS, VALIDATE_ADDRESS_OUTPUT_SCHEMA, WEB_SEARCH_INPUT_SCHEMA, WEB_SEARCH_OUTPUT_MAPPINGS, WEB_SEARCH_OUTPUT_SCHEMA, } from "./built-in-actions.cjs";
|
|
4
4
|
export { SimpleAI, type SimpleAIOptions } from "./client.cjs";
|
|
5
5
|
export { type ActionContext, type ActionHandler, type CustomDataResult, type CustomDataTransformContext, type CustomDataTransformHandler, type CustomDataTransformOperation, defineAction, defineCustomDataTransform, SIMPLE_ACTION_BRAND, } from "./code-action/define-action.cjs";
|
|
6
|
-
export { ActionCapability, type ActionInvocationMetadata } from "./code-action/types.cjs";
|
|
6
|
+
export { ActionCapability, type ActionInvocationMetadata, type ActionSimulation } from "./code-action/types.cjs";
|
|
7
7
|
export type { ActionWorkflow, TransitionToOptions } from "./code-action/workflow.cjs";
|
|
8
8
|
export { DataClient } from "./data.cjs";
|
|
9
9
|
export { type AgentProjectSource, type AgentSnapshotDefinition, collectActionVersionUuids, compileAgentProject, defineAgentSnapshot, normalizeAgentV2CommitContent, type SnapshotAction, } from "./projects.cjs";
|
|
10
|
-
export type { BatchUpsertResult, DataFilter, DataRecord, DeleteResult, FacetsResult, IngestBatchStatus, ListOptions, ListResult, QueryInput, QueryResult, RecordPayload, RecordResult, } from "./schemas.cjs";
|
|
11
|
-
export { batchUpsertRowsSchema, dataColumnPathSchema, dataFilterSchema, listOptionsSchema, MAX_BATCH_ROWS, MAX_QUERY_SIZE, queryInputSchema, recordPayloadSchema, tableNameSchema, } from "./schemas.cjs";
|
|
10
|
+
export type { BatchUpsertResult, ClientCredentialsToken, ClientCredentialsTokenInput, DataFilter, DataRecord, DeleteResult, FacetsResult, IngestBatchStatus, ListOptions, ListResult, QueryInput, QueryResult, RecordPayload, RecordResult, } from "./schemas.cjs";
|
|
11
|
+
export { batchUpsertRowsSchema, clientCredentialsTokenInputSchema, dataColumnPathSchema, dataFilterSchema, listOptionsSchema, MAX_BATCH_ROWS, MAX_QUERY_SIZE, queryInputSchema, recordPayloadSchema, tableNameSchema, } from "./schemas.cjs";
|
|
12
12
|
export { MissingCapabilityError, SimpleAIError } from "./shared/errors.cjs";
|
package/dist/index.d.ts
CHANGED
|
@@ -3,10 +3,10 @@ export { type AbTestNodeDefinition, type ActionNodeDefinition, type AgentCompile
|
|
|
3
3
|
export { BUILT_IN_ACTION_CONTRACTS, SEND_EMAIL_INPUT_SCHEMA, SEND_EMAIL_OUTPUT_MAPPINGS, SEND_EMAIL_OUTPUT_SCHEMA, SEND_TEXT_MESSAGE_INPUT_SCHEMA, SEND_TEXT_MESSAGE_OUTPUT_MAPPINGS, SEND_TEXT_MESSAGE_OUTPUT_SCHEMA, VALIDATE_ADDRESS_INPUT_SCHEMA, VALIDATE_ADDRESS_OUTPUT_MAPPINGS, VALIDATE_ADDRESS_OUTPUT_SCHEMA, WEB_SEARCH_INPUT_SCHEMA, WEB_SEARCH_OUTPUT_MAPPINGS, WEB_SEARCH_OUTPUT_SCHEMA, } from "./built-in-actions.js";
|
|
4
4
|
export { SimpleAI, type SimpleAIOptions } from "./client.js";
|
|
5
5
|
export { type ActionContext, type ActionHandler, type CustomDataResult, type CustomDataTransformContext, type CustomDataTransformHandler, type CustomDataTransformOperation, defineAction, defineCustomDataTransform, SIMPLE_ACTION_BRAND, } from "./code-action/define-action.js";
|
|
6
|
-
export { ActionCapability, type ActionInvocationMetadata } from "./code-action/types.js";
|
|
6
|
+
export { ActionCapability, type ActionInvocationMetadata, type ActionSimulation } from "./code-action/types.js";
|
|
7
7
|
export type { ActionWorkflow, TransitionToOptions } from "./code-action/workflow.js";
|
|
8
8
|
export { DataClient } from "./data.js";
|
|
9
9
|
export { type AgentProjectSource, type AgentSnapshotDefinition, collectActionVersionUuids, compileAgentProject, defineAgentSnapshot, normalizeAgentV2CommitContent, type SnapshotAction, } from "./projects.js";
|
|
10
|
-
export type { BatchUpsertResult, DataFilter, DataRecord, DeleteResult, FacetsResult, IngestBatchStatus, ListOptions, ListResult, QueryInput, QueryResult, RecordPayload, RecordResult, } from "./schemas.js";
|
|
11
|
-
export { batchUpsertRowsSchema, dataColumnPathSchema, dataFilterSchema, listOptionsSchema, MAX_BATCH_ROWS, MAX_QUERY_SIZE, queryInputSchema, recordPayloadSchema, tableNameSchema, } from "./schemas.js";
|
|
10
|
+
export type { BatchUpsertResult, ClientCredentialsToken, ClientCredentialsTokenInput, DataFilter, DataRecord, DeleteResult, FacetsResult, IngestBatchStatus, ListOptions, ListResult, QueryInput, QueryResult, RecordPayload, RecordResult, } from "./schemas.js";
|
|
11
|
+
export { batchUpsertRowsSchema, clientCredentialsTokenInputSchema, dataColumnPathSchema, dataFilterSchema, listOptionsSchema, MAX_BATCH_ROWS, MAX_QUERY_SIZE, queryInputSchema, recordPayloadSchema, tableNameSchema, } from "./schemas.js";
|
|
12
12
|
export { MissingCapabilityError, SimpleAIError } from "./shared/errors.js";
|
package/dist/index.js
CHANGED
|
@@ -6,5 +6,5 @@ export { defineAction, defineCustomDataTransform, SIMPLE_ACTION_BRAND, } from ".
|
|
|
6
6
|
export { ActionCapability } from "./code-action/types.js";
|
|
7
7
|
export { DataClient } from "./data.js";
|
|
8
8
|
export { collectActionVersionUuids, compileAgentProject, defineAgentSnapshot, normalizeAgentV2CommitContent, } from "./projects.js";
|
|
9
|
-
export { batchUpsertRowsSchema, dataColumnPathSchema, dataFilterSchema, listOptionsSchema, MAX_BATCH_ROWS, MAX_QUERY_SIZE, queryInputSchema, recordPayloadSchema, tableNameSchema, } from "./schemas.js";
|
|
9
|
+
export { batchUpsertRowsSchema, clientCredentialsTokenInputSchema, dataColumnPathSchema, dataFilterSchema, listOptionsSchema, MAX_BATCH_ROWS, MAX_QUERY_SIZE, queryInputSchema, recordPayloadSchema, tableNameSchema, } from "./schemas.js";
|
|
10
10
|
export { MissingCapabilityError, SimpleAIError } from "./shared/errors.js";
|
package/dist/oauth.cjs
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.OAuthClient = void 0;
|
|
4
|
+
const schemas_1 = require("./schemas.cjs");
|
|
5
|
+
/** OAuth 2.0 access tokens for calling your own systems, via `/api/v1/oauth_tokens`. */
|
|
6
|
+
class OAuthClient {
|
|
7
|
+
#http;
|
|
8
|
+
constructor(http) {
|
|
9
|
+
this.#http = http;
|
|
10
|
+
}
|
|
11
|
+
/** Reused across runs until shortly before expiry; pass `forceRefresh: true` when the token is rejected. */
|
|
12
|
+
async clientCredentials(input) {
|
|
13
|
+
const parsed = schemas_1.clientCredentialsTokenInputSchema.parse(input);
|
|
14
|
+
const result = await this.#http.request({ method: 'POST', path: '/oauth_tokens/client_credentials', body: parsed });
|
|
15
|
+
return schemas_1.clientCredentialsTokenSchema.parse(result);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
exports.OAuthClient = OAuthClient;
|
package/dist/oauth.d.cts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { HttpClient } from "./http.cjs";
|
|
2
|
+
import { type ClientCredentialsToken, type ClientCredentialsTokenInput } from "./schemas.cjs";
|
|
3
|
+
/** OAuth 2.0 access tokens for calling your own systems, via `/api/v1/oauth_tokens`. */
|
|
4
|
+
export declare class OAuthClient {
|
|
5
|
+
#private;
|
|
6
|
+
constructor(http: HttpClient);
|
|
7
|
+
/** Reused across runs until shortly before expiry; pass `forceRefresh: true` when the token is rejected. */
|
|
8
|
+
clientCredentials(input: ClientCredentialsTokenInput): Promise<ClientCredentialsToken>;
|
|
9
|
+
}
|
package/dist/oauth.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { HttpClient } from "./http.js";
|
|
2
|
+
import { type ClientCredentialsToken, type ClientCredentialsTokenInput } from "./schemas.js";
|
|
3
|
+
/** OAuth 2.0 access tokens for calling your own systems, via `/api/v1/oauth_tokens`. */
|
|
4
|
+
export declare class OAuthClient {
|
|
5
|
+
#private;
|
|
6
|
+
constructor(http: HttpClient);
|
|
7
|
+
/** Reused across runs until shortly before expiry; pass `forceRefresh: true` when the token is rejected. */
|
|
8
|
+
clientCredentials(input: ClientCredentialsTokenInput): Promise<ClientCredentialsToken>;
|
|
9
|
+
}
|
package/dist/oauth.js
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { clientCredentialsTokenInputSchema, clientCredentialsTokenSchema, } from "./schemas.js";
|
|
2
|
+
/** OAuth 2.0 access tokens for calling your own systems, via `/api/v1/oauth_tokens`. */
|
|
3
|
+
export class OAuthClient {
|
|
4
|
+
#http;
|
|
5
|
+
constructor(http) {
|
|
6
|
+
this.#http = http;
|
|
7
|
+
}
|
|
8
|
+
/** Reused across runs until shortly before expiry; pass `forceRefresh: true` when the token is rejected. */
|
|
9
|
+
async clientCredentials(input) {
|
|
10
|
+
const parsed = clientCredentialsTokenInputSchema.parse(input);
|
|
11
|
+
const result = await this.#http.request({ method: 'POST', path: '/oauth_tokens/client_credentials', body: parsed });
|
|
12
|
+
return clientCredentialsTokenSchema.parse(result);
|
|
13
|
+
}
|
|
14
|
+
}
|
package/dist/projects.cjs
CHANGED
|
@@ -96,6 +96,12 @@ function normalizeAgentV2CommitContent(content) {
|
|
|
96
96
|
// the organization.
|
|
97
97
|
piiRedaction: content.config.call.piiRedaction ?? null,
|
|
98
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
|
+
},
|
|
99
105
|
// The server declares a `null` default for the background message, so a
|
|
100
106
|
// commit that predates the field means the same as one storing null.
|
|
101
107
|
...(content.config.toolUseSites === undefined
|
|
@@ -169,6 +175,16 @@ function compileSnapshot(definition, options) {
|
|
|
169
175
|
}
|
|
170
176
|
}
|
|
171
177
|
};
|
|
178
|
+
const repinAutomaticAction = (useSite) => useSite == null
|
|
179
|
+
? null
|
|
180
|
+
: {
|
|
181
|
+
...useSite,
|
|
182
|
+
actionVersionUuid: replaceActionVersionUuid({
|
|
183
|
+
versionUuid: useSite.actionVersionUuid,
|
|
184
|
+
actions: definition.actions,
|
|
185
|
+
options,
|
|
186
|
+
}),
|
|
187
|
+
};
|
|
172
188
|
return {
|
|
173
189
|
agent: definition.agent,
|
|
174
190
|
branch: definition.branch,
|
|
@@ -198,16 +214,11 @@ function compileSnapshot(definition, options) {
|
|
|
198
214
|
})),
|
|
199
215
|
}),
|
|
200
216
|
automaticActions: {
|
|
201
|
-
beforeCallStart: normalizedContent.config.automaticActions.beforeCallStart
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
versionUuid: normalizedContent.config.automaticActions.beforeCallStart.actionVersionUuid,
|
|
207
|
-
actions: definition.actions,
|
|
208
|
-
options,
|
|
209
|
-
}),
|
|
210
|
-
},
|
|
217
|
+
beforeCallStart: repinAutomaticAction(normalizedContent.config.automaticActions.beforeCallStart),
|
|
218
|
+
// Compiled source never carries `callEnd`, so a snapshot without one omits it too and the two stay comparable.
|
|
219
|
+
...(normalizedContent.config.automaticActions.callEnd == null
|
|
220
|
+
? {}
|
|
221
|
+
: { callEnd: repinAutomaticAction(normalizedContent.config.automaticActions.callEnd) }),
|
|
211
222
|
},
|
|
212
223
|
},
|
|
213
224
|
nodes: normalizedContent.nodes.map((node) => compileSnapshotNode({ node, actions: definition.actions, options })),
|
|
@@ -224,9 +235,11 @@ function collectActionVersionUuids(content) {
|
|
|
224
235
|
for (const useSite of content.config.toolUseSites ?? []) {
|
|
225
236
|
versionUuids.add(useSite.actionVersionUuid);
|
|
226
237
|
}
|
|
227
|
-
const
|
|
228
|
-
|
|
229
|
-
|
|
238
|
+
const { beforeCallStart, callEnd } = content.config.automaticActions;
|
|
239
|
+
for (const automaticAction of [beforeCallStart, callEnd]) {
|
|
240
|
+
if (automaticAction != null) {
|
|
241
|
+
versionUuids.add(automaticAction.actionVersionUuid);
|
|
242
|
+
}
|
|
230
243
|
}
|
|
231
244
|
for (const node of content.nodes) {
|
|
232
245
|
if (node.type === 'action_node') {
|
package/dist/projects.js
CHANGED
|
@@ -90,6 +90,12 @@ export function normalizeAgentV2CommitContent(content) {
|
|
|
90
90
|
// the organization.
|
|
91
91
|
piiRedaction: content.config.call.piiRedaction ?? null,
|
|
92
92
|
},
|
|
93
|
+
// The server declares a `null` default for the call-end Action, so a commit
|
|
94
|
+
// without one means the same as one storing null.
|
|
95
|
+
automaticActions: {
|
|
96
|
+
...content.config.automaticActions,
|
|
97
|
+
callEnd: content.config.automaticActions.callEnd ?? null,
|
|
98
|
+
},
|
|
93
99
|
// The server declares a `null` default for the background message, so a
|
|
94
100
|
// commit that predates the field means the same as one storing null.
|
|
95
101
|
...(content.config.toolUseSites === undefined
|
|
@@ -163,6 +169,16 @@ function compileSnapshot(definition, options) {
|
|
|
163
169
|
}
|
|
164
170
|
}
|
|
165
171
|
};
|
|
172
|
+
const repinAutomaticAction = (useSite) => useSite == null
|
|
173
|
+
? null
|
|
174
|
+
: {
|
|
175
|
+
...useSite,
|
|
176
|
+
actionVersionUuid: replaceActionVersionUuid({
|
|
177
|
+
versionUuid: useSite.actionVersionUuid,
|
|
178
|
+
actions: definition.actions,
|
|
179
|
+
options,
|
|
180
|
+
}),
|
|
181
|
+
};
|
|
166
182
|
return {
|
|
167
183
|
agent: definition.agent,
|
|
168
184
|
branch: definition.branch,
|
|
@@ -192,16 +208,11 @@ function compileSnapshot(definition, options) {
|
|
|
192
208
|
})),
|
|
193
209
|
}),
|
|
194
210
|
automaticActions: {
|
|
195
|
-
beforeCallStart: normalizedContent.config.automaticActions.beforeCallStart
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
versionUuid: normalizedContent.config.automaticActions.beforeCallStart.actionVersionUuid,
|
|
201
|
-
actions: definition.actions,
|
|
202
|
-
options,
|
|
203
|
-
}),
|
|
204
|
-
},
|
|
211
|
+
beforeCallStart: repinAutomaticAction(normalizedContent.config.automaticActions.beforeCallStart),
|
|
212
|
+
// Compiled source never carries `callEnd`, so a snapshot without one omits it too and the two stay comparable.
|
|
213
|
+
...(normalizedContent.config.automaticActions.callEnd == null
|
|
214
|
+
? {}
|
|
215
|
+
: { callEnd: repinAutomaticAction(normalizedContent.config.automaticActions.callEnd) }),
|
|
205
216
|
},
|
|
206
217
|
},
|
|
207
218
|
nodes: normalizedContent.nodes.map((node) => compileSnapshotNode({ node, actions: definition.actions, options })),
|
|
@@ -218,9 +229,11 @@ export function collectActionVersionUuids(content) {
|
|
|
218
229
|
for (const useSite of content.config.toolUseSites ?? []) {
|
|
219
230
|
versionUuids.add(useSite.actionVersionUuid);
|
|
220
231
|
}
|
|
221
|
-
const
|
|
222
|
-
|
|
223
|
-
|
|
232
|
+
const { beforeCallStart, callEnd } = content.config.automaticActions;
|
|
233
|
+
for (const automaticAction of [beforeCallStart, callEnd]) {
|
|
234
|
+
if (automaticAction != null) {
|
|
235
|
+
versionUuids.add(automaticAction.actionVersionUuid);
|
|
236
|
+
}
|
|
224
237
|
}
|
|
225
238
|
for (const node of content.nodes) {
|
|
226
239
|
if (node.type === 'action_node') {
|
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,28 @@ 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
|
+
/** How the client authenticates to the token endpoint; HTTP Basic is the one RFC 6749 requires servers to support. */
|
|
54
|
+
clientAuthentication: z.ZodDefault<z.ZodEnum<{
|
|
55
|
+
client_secret_basic: "client_secret_basic";
|
|
56
|
+
client_secret_post: "client_secret_post";
|
|
57
|
+
}>>;
|
|
58
|
+
scope: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
59
|
+
/** Additional token request parameters, such as `audience` (Auth0) or `resource` (Azure AD v1). */
|
|
60
|
+
extraParameters: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
61
|
+
forceRefresh: z.ZodDefault<z.ZodBoolean>;
|
|
62
|
+
}, z.core.$strict>;
|
|
63
|
+
export type ClientCredentialsTokenInput = z.input<typeof clientCredentialsTokenInputSchema>;
|
|
64
|
+
export declare const clientCredentialsTokenSchema: z.ZodObject<{
|
|
65
|
+
accessToken: z.ZodString;
|
|
66
|
+
tokenType: z.ZodNullable<z.ZodString>;
|
|
67
|
+
expiresAt: z.ZodNullable<z.ZodString>;
|
|
68
|
+
}, z.core.$strip>;
|
|
69
|
+
export type ClientCredentialsToken = z.infer<typeof clientCredentialsTokenSchema>;
|
|
48
70
|
export type DataRecord = Record<string, unknown>;
|
|
49
71
|
export type QueryResult = {
|
|
50
72
|
records: DataRecord[];
|
package/dist/schemas.d.ts
CHANGED
|
@@ -45,6 +45,28 @@ 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
|
+
/** How the client authenticates to the token endpoint; HTTP Basic is the one RFC 6749 requires servers to support. */
|
|
54
|
+
clientAuthentication: z.ZodDefault<z.ZodEnum<{
|
|
55
|
+
client_secret_basic: "client_secret_basic";
|
|
56
|
+
client_secret_post: "client_secret_post";
|
|
57
|
+
}>>;
|
|
58
|
+
scope: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
59
|
+
/** Additional token request parameters, such as `audience` (Auth0) or `resource` (Azure AD v1). */
|
|
60
|
+
extraParameters: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
61
|
+
forceRefresh: z.ZodDefault<z.ZodBoolean>;
|
|
62
|
+
}, z.core.$strict>;
|
|
63
|
+
export type ClientCredentialsTokenInput = z.input<typeof clientCredentialsTokenInputSchema>;
|
|
64
|
+
export declare const clientCredentialsTokenSchema: z.ZodObject<{
|
|
65
|
+
accessToken: z.ZodString;
|
|
66
|
+
tokenType: z.ZodNullable<z.ZodString>;
|
|
67
|
+
expiresAt: z.ZodNullable<z.ZodString>;
|
|
68
|
+
}, z.core.$strip>;
|
|
69
|
+
export type ClientCredentialsToken = z.infer<typeof clientCredentialsTokenSchema>;
|
|
48
70
|
export type DataRecord = Record<string, unknown>;
|
|
49
71
|
export type QueryResult = {
|
|
50
72
|
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.12.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",
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"@biomejs/biome": "^2.4.4",
|
|
29
29
|
"@types/node": "^25.9.3",
|
|
30
30
|
"typescript": "^5.9.3",
|
|
31
|
-
"vitest": "4.1.
|
|
31
|
+
"vitest": "4.1.12",
|
|
32
32
|
"zod": "^4.1.12",
|
|
33
33
|
"zshy": "^0.7.3"
|
|
34
34
|
},
|