@simple-ai-lab/sdk 0.4.0 → 0.8.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.
Files changed (78) hide show
  1. package/README.md +79 -1
  2. package/dist/actions.cjs +452 -0
  3. package/dist/actions.d.cts +348 -0
  4. package/dist/actions.d.ts +348 -0
  5. package/dist/actions.js +443 -0
  6. package/dist/agents.cjs +1176 -0
  7. package/dist/agents.d.cts +1138 -0
  8. package/dist/agents.d.ts +1138 -0
  9. package/dist/agents.js +1166 -0
  10. package/dist/built-in-actions.cjs +456 -0
  11. package/dist/built-in-actions.d.cts +53 -0
  12. package/dist/built-in-actions.d.ts +53 -0
  13. package/dist/built-in-actions.js +453 -0
  14. package/dist/client.cjs +29 -0
  15. package/dist/client.d.cts +15 -0
  16. package/dist/client.d.ts +15 -0
  17. package/dist/client.js +25 -0
  18. package/dist/code-action/defaults.cjs +11 -0
  19. package/dist/code-action/defaults.d.cts +7 -0
  20. package/dist/code-action/defaults.d.ts +7 -0
  21. package/dist/code-action/defaults.js +8 -0
  22. package/dist/code-action/define-action.cjs +78 -0
  23. package/dist/code-action/define-action.d.cts +99 -0
  24. package/dist/code-action/define-action.d.ts +99 -0
  25. package/dist/code-action/define-action.js +73 -0
  26. package/dist/code-action/index.cjs +11 -0
  27. package/dist/code-action/index.d.cts +4 -0
  28. package/dist/code-action/index.d.ts +4 -0
  29. package/dist/code-action/index.js +3 -0
  30. package/dist/code-action/llm.cjs +34 -0
  31. package/dist/code-action/llm.d.cts +28 -0
  32. package/dist/code-action/llm.d.ts +28 -0
  33. package/dist/code-action/llm.js +31 -0
  34. package/dist/code-action/types.cjs +14 -0
  35. package/dist/code-action/types.d.cts +19 -0
  36. package/dist/code-action/types.d.ts +19 -0
  37. package/dist/code-action/types.js +11 -0
  38. package/dist/code-action/workflow.cjs +29 -0
  39. package/dist/code-action/workflow.d.cts +53 -0
  40. package/dist/code-action/workflow.d.ts +53 -0
  41. package/dist/code-action/workflow.js +26 -0
  42. package/dist/data.cjs +98 -0
  43. package/dist/data.d.cts +44 -0
  44. package/dist/data.d.ts +44 -0
  45. package/dist/data.js +94 -0
  46. package/dist/http.cjs +72 -0
  47. package/dist/http.d.cts +14 -0
  48. package/dist/http.d.ts +14 -0
  49. package/dist/http.js +69 -0
  50. package/dist/index.cjs +71 -1597
  51. package/dist/index.d.cts +12 -780
  52. package/dist/index.d.ts +12 -780
  53. package/dist/index.js +10 -1311
  54. package/dist/projects.cjs +234 -0
  55. package/dist/projects.d.cts +24 -0
  56. package/dist/projects.d.ts +24 -0
  57. package/dist/projects.js +228 -0
  58. package/dist/schemas.cjs +50 -0
  59. package/dist/schemas.d.cts +81 -0
  60. package/dist/schemas.d.ts +81 -0
  61. package/dist/schemas.js +47 -0
  62. package/dist/shared/errors.cjs +31 -0
  63. package/dist/shared/errors.d.cts +22 -0
  64. package/dist/shared/errors.d.ts +22 -0
  65. package/dist/shared/errors.js +26 -0
  66. package/package.json +27 -31
  67. package/dist/chunk-V4E5PSKB.js +0 -267
  68. package/dist/chunk-V4E5PSKB.js.map +0 -1
  69. package/dist/code-action-CDt77m7I.d.cts +0 -191
  70. package/dist/code-action-CDt77m7I.d.ts +0 -191
  71. package/dist/code-action.cjs +0 -282
  72. package/dist/code-action.cjs.map +0 -1
  73. package/dist/code-action.d.cts +0 -2
  74. package/dist/code-action.d.ts +0 -2
  75. package/dist/code-action.js +0 -9
  76. package/dist/code-action.js.map +0 -1
  77. package/dist/index.cjs.map +0 -1
  78. package/dist/index.js.map +0 -1
@@ -0,0 +1,234 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.defineAgentSnapshot = defineAgentSnapshot;
4
+ exports.normalizeAgentV2CommitContent = normalizeAgentV2CommitContent;
5
+ exports.compileAgentProject = compileAgentProject;
6
+ exports.collectActionVersionUuids = collectActionVersionUuids;
7
+ const agents_1 = require("./agents.cjs");
8
+ function defineAgentSnapshot(definition) {
9
+ return { kind: 'agent-snapshot', ...definition };
10
+ }
11
+ function normalizeNodeCompatibilityDefaults(node) {
12
+ // Commits predating a setting omit its key. The server declares each with a
13
+ // default (`{}` for SIP headers, `null` for a shared extraction Schema), so
14
+ // absent and default mean the same thing at runtime.
15
+ let typed = node;
16
+ if (typed.type === 'end_call' && typed.sipByeHeaders === undefined) {
17
+ typed = { ...typed, sipByeHeaders: {} };
18
+ }
19
+ if (typed.type === 'extract' && typed.schemaUuid === undefined) {
20
+ typed = { ...typed, schemaUuid: null };
21
+ }
22
+ // A chat transfer is the one node whose execution message has no default, so
23
+ // absent survives a parse. The call serializer reads it as `?? null`, which
24
+ // makes the two the same value to everything downstream.
25
+ if (typed.type === 'transfer_chat' && typed.executionMessage === undefined) {
26
+ typed = { ...typed, executionMessage: null };
27
+ }
28
+ return normalizeSharedNodeDefaults(typed);
29
+ }
30
+ /**
31
+ * The product writes `generatedExamples: null` on every prompt it has not
32
+ * generated examples for, while the authoring API omits the key. The server
33
+ * declares the field nullable and optional and every reader checks it by
34
+ * truthiness, so the two spellings mean the same thing. Dropping the null lets
35
+ * `prompt.file(...)`, which cannot emit the key, round-trip a product prompt.
36
+ */
37
+ function normalizePromptDefaults(node) {
38
+ if (node.type !== 'global' && node.type !== 'standard') {
39
+ return node;
40
+ }
41
+ if (node.prompt.type !== 'inline' || node.prompt.generatedExamples !== null) {
42
+ return node;
43
+ }
44
+ const { generatedExamples: _omitted, ...prompt } = node.prompt;
45
+ return { ...node, prompt };
46
+ }
47
+ function normalizeSharedNodeDefaults(untypedNode) {
48
+ const node = normalizePromptDefaults(untypedNode);
49
+ const normalizedEdges = node.edges.map((edge) => (edge.filter === undefined ? { ...edge, filter: null } : edge));
50
+ const alwaysAvailable = node.builtInTools?.alwaysAvailable;
51
+ if (alwaysAvailable === undefined || alwaysAvailable.filter !== undefined) {
52
+ return { ...node, edges: normalizedEdges };
53
+ }
54
+ const normalizedAlwaysAvailable = {
55
+ ...alwaysAvailable,
56
+ filter: null,
57
+ };
58
+ if (node.type === 'transfer') {
59
+ return {
60
+ ...node,
61
+ edges: normalizedEdges,
62
+ builtInTools: {
63
+ ...node.builtInTools,
64
+ alwaysAvailable: normalizedAlwaysAvailable,
65
+ },
66
+ };
67
+ }
68
+ return {
69
+ ...node,
70
+ edges: normalizedEdges,
71
+ builtInTools: {
72
+ ...node.builtInTools,
73
+ alwaysAvailable: normalizedAlwaysAvailable,
74
+ },
75
+ };
76
+ }
77
+ /**
78
+ * Fills defaults added after older Agent commits were stored. Pull, diff, and
79
+ * snapshot compilation must all use this same canonical content shape so a
80
+ * freshly pulled project is clean against its lock.
81
+ */
82
+ function normalizeAgentV2CommitContent(content) {
83
+ return {
84
+ ...content,
85
+ nodes: content.nodes.map(normalizeNodeCompatibilityDefaults),
86
+ config: {
87
+ ...content.config,
88
+ speech: {
89
+ ...content.config.speech,
90
+ voiceFormattingEnabled: content.config.speech.voiceFormattingEnabled ?? false,
91
+ pronunciations: content.config.speech.pronunciations ?? [],
92
+ },
93
+ // 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.
95
+ ...(content.config.toolUseSites === undefined
96
+ ? {}
97
+ : {
98
+ toolUseSites: content.config.toolUseSites.map((useSite) => ({
99
+ ...useSite,
100
+ backgroundMessage: useSite.backgroundMessage ?? null,
101
+ })),
102
+ }),
103
+ // `toneGuidelines` and `checkInAfterSilence.delaySeconds` are deliberately
104
+ // not filled here. Both are three-state on the wire, and the authoring API
105
+ // reproduces each state exactly, so filling a default would rewrite a
106
+ // commit that never carried the key and push a change nobody authored.
107
+ },
108
+ };
109
+ }
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
+ function compileAgentProject(definition, options = {}) {
212
+ return definition.kind === 'agent-definition'
213
+ ? (0, agents_1.compileAgent)(definition, options)
214
+ : compileSnapshot(definition, options);
215
+ }
216
+ function collectActionVersionUuids(content) {
217
+ const versionUuids = new Set();
218
+ for (const useSite of content.config.toolUseSites ?? []) {
219
+ versionUuids.add(useSite.actionVersionUuid);
220
+ }
221
+ const beforeCallAction = content.config.automaticActions.beforeCallStart;
222
+ if (beforeCallAction !== null) {
223
+ versionUuids.add(beforeCallAction.actionVersionUuid);
224
+ }
225
+ for (const node of content.nodes) {
226
+ if (node.type === 'action_node') {
227
+ versionUuids.add(node.actionVersionUuid);
228
+ }
229
+ if (node.type === 'standard' && node.perTurnAction != null) {
230
+ versionUuids.add(node.perTurnAction.actionVersionUuid);
231
+ }
232
+ }
233
+ return [...versionUuids];
234
+ }
@@ -0,0 +1,24 @@
1
+ import type { ActionVersionValues } from "./actions.cjs";
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;
17
+ /**
18
+ * Fills defaults added after older Agent commits were stored. Pull, diff, and
19
+ * snapshot compilation must all use this same canonical content shape so a
20
+ * freshly pulled project is clean against its lock.
21
+ */
22
+ export declare function normalizeAgentV2CommitContent(content: AgentV2CommitContentWire): AgentV2CommitContentWire;
23
+ export declare function compileAgentProject(definition: AgentProjectSource, options?: AgentCompileOptions): CompiledAgentProject;
24
+ export declare function collectActionVersionUuids(content: AgentV2CommitContentWire): string[];
@@ -0,0 +1,24 @@
1
+ import type { ActionVersionValues } from "./actions.js";
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;
17
+ /**
18
+ * Fills defaults added after older Agent commits were stored. Pull, diff, and
19
+ * snapshot compilation must all use this same canonical content shape so a
20
+ * freshly pulled project is clean against its lock.
21
+ */
22
+ export declare function normalizeAgentV2CommitContent(content: AgentV2CommitContentWire): AgentV2CommitContentWire;
23
+ export declare function compileAgentProject(definition: AgentProjectSource, options?: AgentCompileOptions): CompiledAgentProject;
24
+ export declare function collectActionVersionUuids(content: AgentV2CommitContentWire): string[];
@@ -0,0 +1,228 @@
1
+ import { compileAgent, } from "./agents.js";
2
+ export function defineAgentSnapshot(definition) {
3
+ return { kind: 'agent-snapshot', ...definition };
4
+ }
5
+ function normalizeNodeCompatibilityDefaults(node) {
6
+ // Commits predating a setting omit its key. The server declares each with a
7
+ // default (`{}` for SIP headers, `null` for a shared extraction Schema), so
8
+ // absent and default mean the same thing at runtime.
9
+ let typed = node;
10
+ if (typed.type === 'end_call' && typed.sipByeHeaders === undefined) {
11
+ typed = { ...typed, sipByeHeaders: {} };
12
+ }
13
+ if (typed.type === 'extract' && typed.schemaUuid === undefined) {
14
+ typed = { ...typed, schemaUuid: null };
15
+ }
16
+ // A chat transfer is the one node whose execution message has no default, so
17
+ // absent survives a parse. The call serializer reads it as `?? null`, which
18
+ // makes the two the same value to everything downstream.
19
+ if (typed.type === 'transfer_chat' && typed.executionMessage === undefined) {
20
+ typed = { ...typed, executionMessage: null };
21
+ }
22
+ return normalizeSharedNodeDefaults(typed);
23
+ }
24
+ /**
25
+ * The product writes `generatedExamples: null` on every prompt it has not
26
+ * generated examples for, while the authoring API omits the key. The server
27
+ * declares the field nullable and optional and every reader checks it by
28
+ * truthiness, so the two spellings mean the same thing. Dropping the null lets
29
+ * `prompt.file(...)`, which cannot emit the key, round-trip a product prompt.
30
+ */
31
+ function normalizePromptDefaults(node) {
32
+ if (node.type !== 'global' && node.type !== 'standard') {
33
+ return node;
34
+ }
35
+ if (node.prompt.type !== 'inline' || node.prompt.generatedExamples !== null) {
36
+ return node;
37
+ }
38
+ const { generatedExamples: _omitted, ...prompt } = node.prompt;
39
+ return { ...node, prompt };
40
+ }
41
+ function normalizeSharedNodeDefaults(untypedNode) {
42
+ const node = normalizePromptDefaults(untypedNode);
43
+ const normalizedEdges = node.edges.map((edge) => (edge.filter === undefined ? { ...edge, filter: null } : edge));
44
+ const alwaysAvailable = node.builtInTools?.alwaysAvailable;
45
+ if (alwaysAvailable === undefined || alwaysAvailable.filter !== undefined) {
46
+ return { ...node, edges: normalizedEdges };
47
+ }
48
+ const normalizedAlwaysAvailable = {
49
+ ...alwaysAvailable,
50
+ filter: null,
51
+ };
52
+ if (node.type === 'transfer') {
53
+ return {
54
+ ...node,
55
+ edges: normalizedEdges,
56
+ builtInTools: {
57
+ ...node.builtInTools,
58
+ alwaysAvailable: normalizedAlwaysAvailable,
59
+ },
60
+ };
61
+ }
62
+ return {
63
+ ...node,
64
+ edges: normalizedEdges,
65
+ builtInTools: {
66
+ ...node.builtInTools,
67
+ alwaysAvailable: normalizedAlwaysAvailable,
68
+ },
69
+ };
70
+ }
71
+ /**
72
+ * Fills defaults added after older Agent commits were stored. Pull, diff, and
73
+ * snapshot compilation must all use this same canonical content shape so a
74
+ * freshly pulled project is clean against its lock.
75
+ */
76
+ export function normalizeAgentV2CommitContent(content) {
77
+ return {
78
+ ...content,
79
+ nodes: content.nodes.map(normalizeNodeCompatibilityDefaults),
80
+ config: {
81
+ ...content.config,
82
+ speech: {
83
+ ...content.config.speech,
84
+ voiceFormattingEnabled: content.config.speech.voiceFormattingEnabled ?? false,
85
+ pronunciations: content.config.speech.pronunciations ?? [],
86
+ },
87
+ // The server declares a `null` default for the background message, so a
88
+ // commit that predates the field means the same as one storing null.
89
+ ...(content.config.toolUseSites === undefined
90
+ ? {}
91
+ : {
92
+ toolUseSites: content.config.toolUseSites.map((useSite) => ({
93
+ ...useSite,
94
+ backgroundMessage: useSite.backgroundMessage ?? null,
95
+ })),
96
+ }),
97
+ // `toneGuidelines` and `checkInAfterSilence.delaySeconds` are deliberately
98
+ // not filled here. Both are three-state on the wire, and the authoring API
99
+ // reproduces each state exactly, so filling a default would rewrite a
100
+ // commit that never carried the key and push a change nobody authored.
101
+ },
102
+ };
103
+ }
104
+ function replaceActionVersionUuid({ versionUuid, actions, options, }) {
105
+ const actionDefinition = actions.find((item) => item.sourceVersionUuid === versionUuid);
106
+ if (actionDefinition === undefined) {
107
+ return versionUuid;
108
+ }
109
+ return options.actionVersionUuids?.[actionDefinition.key] ?? versionUuid;
110
+ }
111
+ function compileSnapshotNode({ node, actions, options, }) {
112
+ if (node.type === 'action_node') {
113
+ return {
114
+ ...node,
115
+ actionVersionUuid: replaceActionVersionUuid({
116
+ versionUuid: node.actionVersionUuid,
117
+ actions,
118
+ options,
119
+ }),
120
+ };
121
+ }
122
+ if (node.type === 'standard' && node.perTurnAction != null) {
123
+ return {
124
+ ...node,
125
+ perTurnAction: {
126
+ ...node.perTurnAction,
127
+ actionVersionUuid: replaceActionVersionUuid({
128
+ versionUuid: node.perTurnAction.actionVersionUuid,
129
+ actions,
130
+ options,
131
+ }),
132
+ },
133
+ };
134
+ }
135
+ return node;
136
+ }
137
+ function compileSnapshot(definition, options) {
138
+ const normalizedContent = normalizeAgentV2CommitContent(definition.content);
139
+ const snapshotActionValues = (values) => {
140
+ switch (values.actionType) {
141
+ case 'code':
142
+ return {
143
+ ...values,
144
+ operation: {
145
+ ...values.operation,
146
+ compiledJs: null,
147
+ },
148
+ };
149
+ case 'http':
150
+ case 'custom_data':
151
+ case 'knowledge_base':
152
+ case 'built_in':
153
+ return values;
154
+ default: {
155
+ values;
156
+ throw new Error(`Unsupported Action type in snapshot: ${JSON.stringify(values)}`);
157
+ }
158
+ }
159
+ };
160
+ return {
161
+ agent: definition.agent,
162
+ branch: definition.branch,
163
+ actions: definition.actions.map((item) => ({
164
+ key: item.key,
165
+ versionUuid: replaceActionVersionUuid({
166
+ versionUuid: item.sourceVersionUuid,
167
+ actions: definition.actions,
168
+ options,
169
+ }),
170
+ values: snapshotActionValues(item.values),
171
+ })),
172
+ content: {
173
+ ...normalizedContent,
174
+ config: {
175
+ ...normalizedContent.config,
176
+ ...(normalizedContent.config.toolUseSites === undefined
177
+ ? {}
178
+ : {
179
+ toolUseSites: normalizedContent.config.toolUseSites.map((useSite) => ({
180
+ ...useSite,
181
+ actionVersionUuid: replaceActionVersionUuid({
182
+ versionUuid: useSite.actionVersionUuid,
183
+ actions: definition.actions,
184
+ options,
185
+ }),
186
+ })),
187
+ }),
188
+ automaticActions: {
189
+ beforeCallStart: normalizedContent.config.automaticActions.beforeCallStart === null
190
+ ? null
191
+ : {
192
+ ...normalizedContent.config.automaticActions.beforeCallStart,
193
+ actionVersionUuid: replaceActionVersionUuid({
194
+ versionUuid: normalizedContent.config.automaticActions.beforeCallStart.actionVersionUuid,
195
+ actions: definition.actions,
196
+ options,
197
+ }),
198
+ },
199
+ },
200
+ },
201
+ nodes: normalizedContent.nodes.map((node) => compileSnapshotNode({ node, actions: definition.actions, options })),
202
+ },
203
+ };
204
+ }
205
+ export function compileAgentProject(definition, options = {}) {
206
+ return definition.kind === 'agent-definition'
207
+ ? compileAgent(definition, options)
208
+ : compileSnapshot(definition, options);
209
+ }
210
+ export function collectActionVersionUuids(content) {
211
+ const versionUuids = new Set();
212
+ for (const useSite of content.config.toolUseSites ?? []) {
213
+ versionUuids.add(useSite.actionVersionUuid);
214
+ }
215
+ const beforeCallAction = content.config.automaticActions.beforeCallStart;
216
+ if (beforeCallAction !== null) {
217
+ versionUuids.add(beforeCallAction.actionVersionUuid);
218
+ }
219
+ for (const node of content.nodes) {
220
+ if (node.type === 'action_node') {
221
+ versionUuids.add(node.actionVersionUuid);
222
+ }
223
+ if (node.type === 'standard' && node.perTurnAction != null) {
224
+ versionUuids.add(node.perTurnAction.actionVersionUuid);
225
+ }
226
+ }
227
+ return [...versionUuids];
228
+ }
@@ -0,0 +1,50 @@
1
+ "use strict";
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;
4
+ const zod_1 = require("zod");
5
+ /**
6
+ * Request wire schemas for the Simple AI public REST API (`/api/v1`).
7
+ *
8
+ * These deliberately mirror the server's own schemas (see
9
+ * `projects/server-v2/src/domains/data/query-schemas.ts` and
10
+ * `domains/data/public/types.ts`); a contract test in server-v2 keeps the two
11
+ * in sync. Responses are typed but not strictly validated, so additive server
12
+ * changes never break deployed SDK consumers.
13
+ */
14
+ /** Hard cap on hits a single query may return. */
15
+ exports.MAX_QUERY_SIZE = 50;
16
+ /** Maximum rows accepted by a single batch-upsert chunk. */
17
+ exports.MAX_BATCH_ROWS = 1000;
18
+ exports.tableNameSchema = zod_1.z.string().regex(/^[a-z0-9_]+$/, 'Table names are lowercase snake_case identifiers');
19
+ exports.filterValueSchema = zod_1.z.union([zod_1.z.string(), zod_1.z.number(), zod_1.z.boolean()]);
20
+ // Mirrors the server's customDataFacetAttributePathSchema: dot-separated
21
+ // column paths with no empty segments (OBJECT leaves are parent.child).
22
+ exports.dataColumnPathSchema = zod_1.z
23
+ .string()
24
+ .trim()
25
+ .min(1)
26
+ .max(1024)
27
+ .refine((path) => path.split('.').every((segment) => segment.length > 0), {
28
+ message: 'Must be a dot-separated column path with no empty segments',
29
+ });
30
+ exports.dataFilterSchema = zod_1.z.object({
31
+ column: exports.dataColumnPathSchema,
32
+ values: zod_1.z.array(exports.filterValueSchema),
33
+ });
34
+ exports.queryInputSchema = zod_1.z.object({
35
+ tableName: exports.tableNameSchema,
36
+ filters: zod_1.z.array(exports.dataFilterSchema).optional(),
37
+ text: zod_1.z.string().max(5000).optional(),
38
+ size: zod_1.z.number().int().min(0).max(exports.MAX_QUERY_SIZE).optional(),
39
+ from: zod_1.z.number().int().min(0).optional(),
40
+ });
41
+ exports.listOptionsSchema = zod_1.z.object({
42
+ page: zod_1.z.number().int().min(1).optional(),
43
+ perPage: zod_1.z.number().int().min(1).max(200).optional(),
44
+ orderBy: zod_1.z.string().optional(),
45
+ orderDirection: zod_1.z.enum(['asc', 'desc']).optional(),
46
+ /** Column-name → value equality filters applied server-side. */
47
+ filters: zod_1.z.record(zod_1.z.string(), zod_1.z.string()).optional(),
48
+ });
49
+ exports.recordPayloadSchema = zod_1.z.record(zod_1.z.string(), zod_1.z.unknown());
50
+ exports.batchUpsertRowsSchema = zod_1.z.array(exports.recordPayloadSchema).min(1).max(exports.MAX_BATCH_ROWS);
@@ -0,0 +1,81 @@
1
+ import { z } from 'zod';
2
+ /**
3
+ * Request wire schemas for the Simple AI public REST API (`/api/v1`).
4
+ *
5
+ * These deliberately mirror the server's own schemas (see
6
+ * `projects/server-v2/src/domains/data/query-schemas.ts` and
7
+ * `domains/data/public/types.ts`); a contract test in server-v2 keeps the two
8
+ * in sync. Responses are typed but not strictly validated, so additive server
9
+ * changes never break deployed SDK consumers.
10
+ */
11
+ /** Hard cap on hits a single query may return. */
12
+ export declare const MAX_QUERY_SIZE = 50;
13
+ /** Maximum rows accepted by a single batch-upsert chunk. */
14
+ export declare const MAX_BATCH_ROWS = 1000;
15
+ export declare const tableNameSchema: z.ZodString;
16
+ export declare const filterValueSchema: z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>;
17
+ export declare const dataColumnPathSchema: z.ZodString;
18
+ export declare const dataFilterSchema: z.ZodObject<{
19
+ column: z.ZodString;
20
+ values: z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>;
21
+ }, z.core.$strip>;
22
+ export type DataFilter = z.infer<typeof dataFilterSchema>;
23
+ export declare const queryInputSchema: z.ZodObject<{
24
+ tableName: z.ZodString;
25
+ filters: z.ZodOptional<z.ZodArray<z.ZodObject<{
26
+ column: z.ZodString;
27
+ values: z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>;
28
+ }, z.core.$strip>>>;
29
+ text: z.ZodOptional<z.ZodString>;
30
+ size: z.ZodOptional<z.ZodNumber>;
31
+ from: z.ZodOptional<z.ZodNumber>;
32
+ }, z.core.$strip>;
33
+ export type QueryInput = z.input<typeof queryInputSchema>;
34
+ export declare const listOptionsSchema: z.ZodObject<{
35
+ page: z.ZodOptional<z.ZodNumber>;
36
+ perPage: z.ZodOptional<z.ZodNumber>;
37
+ orderBy: z.ZodOptional<z.ZodString>;
38
+ orderDirection: z.ZodOptional<z.ZodEnum<{
39
+ asc: "asc";
40
+ desc: "desc";
41
+ }>>;
42
+ filters: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
43
+ }, z.core.$strip>;
44
+ export type ListOptions = z.input<typeof listOptionsSchema>;
45
+ export declare const recordPayloadSchema: z.ZodRecord<z.ZodString, z.ZodUnknown>;
46
+ export type RecordPayload = z.infer<typeof recordPayloadSchema>;
47
+ export declare const batchUpsertRowsSchema: z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
48
+ export type DataRecord = Record<string, unknown>;
49
+ export type QueryResult = {
50
+ records: DataRecord[];
51
+ total: number;
52
+ };
53
+ export type ListResult = {
54
+ records: DataRecord[];
55
+ total_count: number;
56
+ page: number;
57
+ per_page: number;
58
+ };
59
+ export type RecordResult = {
60
+ record: DataRecord;
61
+ };
62
+ export type DeleteResult = {
63
+ success: boolean;
64
+ message: string;
65
+ };
66
+ export type BatchUpsertResult = {
67
+ ingestBatchId: string;
68
+ status: string;
69
+ };
70
+ export type IngestBatchStatus = {
71
+ id: string;
72
+ tableName: string;
73
+ status: string;
74
+ rowCount: number;
75
+ upsertedCount: number | null;
76
+ errorMessage: string | null;
77
+ createdAt: string;
78
+ startedAt: string | null;
79
+ finishedAt: string | null;
80
+ };
81
+ export type FacetsResult = Record<string, unknown>;