@simple-ai-lab/sdk 0.12.0 → 0.15.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/index.d.ts CHANGED
@@ -1,12 +1,12 @@
1
- export { type ActionCompileOptions, type ActionDefinition, type ActionHttpHeaders, type ActionIoInput, type ActionOutputParameterMappings, type ActionOutputParameters, type ActionRunDefinition, type ActionsIoSchema, type ActionsIoSchemaNode, type ActionVersionValues, type AgentActionInput, action, actionsIoSchemaFromZod, type BackgroundMessage, type BuiltInActionValues, type BuiltInOperation, type CallableActionDefinition, canonicalActionSource, compileAction, type InlineActionDefinition, type ReferencedActionDefinition, resolveActionHttpHeaders, resolveActionIoSchema, type SourceFileReference, sourceFile, } from "./actions.js";
2
- export { type AbTestNodeDefinition, type ActionNodeDefinition, type AgentCompileOptions, type AgentDefinition, type AgentDefinitionInput, type AgentIdentityKind, type AgentV2CommitContentWire, type AgentV2ConfigWire, type AgentV2EdgeWire, type AgentV2NodeWire, type AlwaysAvailableCapability, type AlwaysAvailableTransitionFilterWire, type BackgroundNoise, type BackgroundNoiseConfig, type CallParameterFilter, type CartActionRef, type CartCheckoutDefinition, type CartCheckoutWhenWire, type CartConfigWire, type CartDefinition, type CartPointer, type CartSummaryLineWire, type CartViewWire, type CheckInAfterSilence, type CheckInAfterSilenceInput, type CollectCreditCardNodeDefinition, type CompiledAgentProject, type ContainableCondition, type ContainableRuleGroup, type ContainableRuleSet, type ContainedCondition, type ContainedRuleGroup, type ContainedRuleSet, type ContainmentConfig, type ContainmentEndedByCondition, type ContainmentParameterCondition, type ContainmentTagCondition, type ContainmentVisitedNodeCondition, canonicalAuthoringKey, canonicalAuthoringKeys, compileAgent, DEFAULT_CHECK_IN_AFTER_SILENCE_DELAY_SECONDS, DEFAULT_PER_TURN_RETRIEVAL_RECENT_TURNS, DEFAULT_PER_TURN_RETRIEVAL_TOP_K, DEFAULT_TRANSITION_MESSAGE, defaultBackgroundNoise, defineAgent, type EdgeDefinition, type EnabledWithDescription, type EndCallNodeDefinition, type EotEagerness, type ExtractionField, type ExtractionInput, type ExtractNodeDefinition, FIVE9_SIP_BYE_HEADER_NAMES, type Five9SipByeHeaderName, type GeneratedExamples, type GeneratedExamplesPolicy, type GlobalNodeDefinition, type HttpNodeDefinition, type InterruptionEagerness, type LlmOverrideDefinition, type LlmOverrideWire, MAX_CONTAINMENT_RULE_DEPTH, type NodeDefinition, node, type ParameterUpdate, type PerTurnRetrievalDefinition, type PerTurnRetrievalWire, PII_REDACTION_CATEGORIES, type PiiRedactionCategory, type PiiRedactionConfig, type PromptExample, type PromptNodeDefinition, type PromptReference, type Pronunciation, prompt, type RemoteReference, reference, resolveExtractionFields, type SayNodeDefinition, type SopGlobalContext, type SopSection, type SopSectionEdge, type SopSpec, type SopToolRef, type StaticRouterNodeDefinition, type ToolUseSiteWire, TRANSITION_FILTER_MAX_CONDITIONS, TRANSITION_FILTER_MAX_DEPTH, type TransferCapability, type TransferChatNodeDefinition, type TransferNodeDefinition, type TransitionFilter, type TransitionFilterCondition, type TransitionFilterJs, type TransitionFilterValue, type TransitionFilterWire, type TransitionMessageWire, type UpdateParametersNodeDefinition, } from "./agents.js";
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";
1
+ export { type ActionCompileOptions, type ActionDefinition, type ActionHttpHeaders, type ActionInputLabel, type ActionIoInput, type ActionOutputParameterMappings, type ActionOutputParameters, type ActionRunDefinition, type ActionsIoSchema, type ActionsIoSchemaNode, type ActionVersionValues, type AgentActionInput, action, actionsIoSchemaFromZod, type BackgroundMessage, type BuiltInActionValues, type BuiltInOperation, type CallableActionDefinition, canonicalActionSource, compileAction, type InlineActionDefinition, type ReferencedActionDefinition, resolveActionHttpHeaders, resolveActionIoSchema, type SensitiveInputScope, type SourceFileReference, sourceFile, } from "./actions.js";
2
+ export { type AbTestNodeDefinition, type ActionNodeDefinition, type AgentCompileOptions, type AgentDefinition, type AgentDefinitionInput, type AgentIdentityKind, type AgentModality, type AgentV2CommitContentWire, type AgentV2ConfigWire, type AgentV2EdgeWire, type AgentV2NodeWire, type AlwaysAvailableCapability, type AlwaysAvailableTransitionFilterWire, type AssistActionUseSiteWire, type AssistCardButtonDefinition, type AssistCardButtonWire, type AssistCardDefinition, type AssistCardTone, type AssistCardWire, type AssistChecklistDefinition, type AssistChecklistWire, type AssistMomentTriggerWire, type AssistParameterConditionWire, type AssistPlaybookConfigWire, type AssistPlaybookDefinition, type AssistProcedureDefinition, type AssistProcedureHookWire, type AssistProcedureStepDefinition, type AssistProcedureStepWire, type AssistProcedureWire, assistActionRunKey, type BackgroundNoise, type BackgroundNoiseConfig, BEFORE_CALL_ACTION_KEY, CALL_END_ACTION_KEY, type CallParameterFilter, type CartActionRef, type CartCheckoutDefinition, type CartCheckoutWhenWire, type CartConfigWire, type CartDefinition, type CartPointer, type CartSummaryLineWire, type CartViewWire, type CheckInAfterSilence, type CheckInAfterSilenceInput, type CollectCreditCardNodeDefinition, type CompiledAgentProject, type ConditionOperator, type ContainableCondition, type ContainableRuleGroup, type ContainableRuleSet, type ContainedCondition, type ContainedRuleGroup, type ContainedRuleSet, type ContainmentConfig, type ContainmentEndedByCondition, type ContainmentParameterCondition, type ContainmentTagCondition, type ContainmentVisitedNodeCondition, canonicalAuthoringKey, canonicalAuthoringKeys, compileAgent, DEFAULT_CHECK_IN_AFTER_SILENCE_DELAY_SECONDS, DEFAULT_PER_TURN_RETRIEVAL_RECENT_TURNS, DEFAULT_PER_TURN_RETRIEVAL_TOP_K, DEFAULT_TRANSITION_MESSAGE, defaultBackgroundNoise, defineAgent, type EdgeDefinition, type EnabledWithDescription, type EndCallNodeDefinition, type EotEagerness, type ExtractionField, type ExtractionInput, type ExtractNodeDefinition, FIVE9_SIP_BYE_HEADER_NAMES, type Five9SipByeHeaderName, type GeneratedExamples, type GeneratedExamplesPolicy, type GlobalNodeDefinition, GUARDRAIL_MODES, type GuardrailAssignmentDefinition, type GuardrailAssignmentWire, type GuardrailMode, type HttpNodeDefinition, type InterruptionEagerness, type LlmOverrideDefinition, type LlmOverrideWire, MAX_CONTAINMENT_RULE_DEPTH, type NodeDefinition, node, type ParameterUpdate, type PerTurnRetrievalDefinition, type PerTurnRetrievalWire, PII_REDACTION_CATEGORIES, type PiiRedactionCategory, type PiiRedactionConfig, type PromptExample, type PromptNodeDefinition, type PromptReference, type Pronunciation, prompt, type RemoteReference, reference, resolveExtractionFields, type SayNodeDefinition, type SopGlobalContext, type SopSection, type SopSectionEdge, type SopSpec, type SopToolRef, type StaticRouterNodeDefinition, type ToolUseSiteWire, TRANSITION_FILTER_MAX_CONDITIONS, TRANSITION_FILTER_MAX_DEPTH, type TransferCapability, type TransferChatNodeDefinition, type TransferNodeDefinition, type TransitionFilter, type TransitionFilterCondition, type TransitionFilterJs, type TransitionFilterValue, type TransitionFilterWire, type TransitionMessageWire, type UpdateParametersNodeDefinition, } from "./agents.js";
3
+ export { BROWSER_ACTION_ENVIRONMENTS, BROWSER_ACTION_KINDS, BROWSER_ACTION_TIMEOUT_MS_DEFAULT, 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
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
- export { type AgentProjectSource, type AgentSnapshotDefinition, collectActionVersionUuids, compileAgentProject, defineAgentSnapshot, normalizeAgentV2CommitContent, type SnapshotAction, } from "./projects.js";
9
+ export { assistActionUseSites, collectActionVersionUuids, normalizeAgentV2CommitContent } from "./projects.js";
10
10
  export type { BatchUpsertResult, ClientCredentialsToken, ClientCredentialsTokenInput, DataFilter, DataRecord, DeleteResult, FacetsResult, IngestBatchStatus, ListOptions, ListResult, QueryInput, QueryResult, RecordPayload, RecordResult, } from "./schemas.js";
11
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
@@ -1,10 +1,10 @@
1
1
  export { action, actionsIoSchemaFromZod, canonicalActionSource, compileAction, resolveActionHttpHeaders, resolveActionIoSchema, sourceFile, } from "./actions.js";
2
- export { canonicalAuthoringKey, canonicalAuthoringKeys, compileAgent, DEFAULT_CHECK_IN_AFTER_SILENCE_DELAY_SECONDS, DEFAULT_PER_TURN_RETRIEVAL_RECENT_TURNS, DEFAULT_PER_TURN_RETRIEVAL_TOP_K, DEFAULT_TRANSITION_MESSAGE, defaultBackgroundNoise, defineAgent, FIVE9_SIP_BYE_HEADER_NAMES, MAX_CONTAINMENT_RULE_DEPTH, node, PII_REDACTION_CATEGORIES, prompt, reference, resolveExtractionFields, TRANSITION_FILTER_MAX_CONDITIONS, TRANSITION_FILTER_MAX_DEPTH, } from "./agents.js";
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";
2
+ export { assistActionRunKey, BEFORE_CALL_ACTION_KEY, CALL_END_ACTION_KEY, canonicalAuthoringKey, canonicalAuthoringKeys, compileAgent, DEFAULT_CHECK_IN_AFTER_SILENCE_DELAY_SECONDS, DEFAULT_PER_TURN_RETRIEVAL_RECENT_TURNS, DEFAULT_PER_TURN_RETRIEVAL_TOP_K, DEFAULT_TRANSITION_MESSAGE, defaultBackgroundNoise, defineAgent, FIVE9_SIP_BYE_HEADER_NAMES, GUARDRAIL_MODES, MAX_CONTAINMENT_RULE_DEPTH, node, PII_REDACTION_CATEGORIES, prompt, reference, resolveExtractionFields, TRANSITION_FILTER_MAX_CONDITIONS, TRANSITION_FILTER_MAX_DEPTH, } from "./agents.js";
3
+ export { BROWSER_ACTION_ENVIRONMENTS, BROWSER_ACTION_KINDS, BROWSER_ACTION_TIMEOUT_MS_DEFAULT, 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 } from "./client.js";
5
5
  export { defineAction, defineCustomDataTransform, SIMPLE_ACTION_BRAND, } from "./code-action/define-action.js";
6
6
  export { ActionCapability } from "./code-action/types.js";
7
7
  export { DataClient } from "./data.js";
8
- export { collectActionVersionUuids, compileAgentProject, defineAgentSnapshot, normalizeAgentV2CommitContent, } from "./projects.js";
8
+ export { assistActionUseSites, collectActionVersionUuids, normalizeAgentV2CommitContent } from "./projects.js";
9
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/projects.cjs CHANGED
@@ -1,13 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.defineAgentSnapshot = defineAgentSnapshot;
4
3
  exports.normalizeAgentV2CommitContent = normalizeAgentV2CommitContent;
5
- exports.compileAgentProject = compileAgentProject;
6
4
  exports.collectActionVersionUuids = collectActionVersionUuids;
7
- const agents_1 = require("./agents.cjs");
8
- function defineAgentSnapshot(definition) {
9
- return { kind: 'agent-snapshot', ...definition };
10
- }
5
+ exports.assistActionUseSites = assistActionUseSites;
11
6
  function normalizeNodeCompatibilityDefaults(node) {
12
7
  // Commits predating a setting omit its key. The server declares each with a
13
8
  // default (`{}` for SIP headers, `null` for a shared extraction Schema), so
@@ -19,6 +14,11 @@ function normalizeNodeCompatibilityDefaults(node) {
19
14
  if (typed.type === 'extract' && typed.schemaUuid === undefined) {
20
15
  typed = { ...typed, schemaUuid: null };
21
16
  }
17
+ // No override normalizes to a node written before overrides existed, the shape older locks hashed.
18
+ if (typed.type === 'extract' && typed.overrides?.llm === undefined) {
19
+ const { overrides: _noOverride, ...withoutOverrides } = typed;
20
+ typed = withoutOverrides;
21
+ }
22
22
  // A chat transfer is the one node whose execution message has no default, so
23
23
  // absent survives a parse. The call serializer reads it as `?? null`, which
24
24
  // makes the two the same value to everything downstream.
@@ -47,7 +47,11 @@ function normalizePromptDefaults(node) {
47
47
  function normalizeSharedNodeDefaults(untypedNode) {
48
48
  const node = normalizePromptDefaults(untypedNode);
49
49
  const normalizedEdges = node.edges.map((edge) => (edge.filter === undefined ? { ...edge, filter: null } : edge));
50
- const alwaysAvailable = node.builtInTools?.alwaysAvailable;
50
+ // The global, update-parameters and collect-credit-card nodes have no capabilities.
51
+ if (!('builtInTools' in node)) {
52
+ return { ...node, edges: normalizedEdges };
53
+ }
54
+ const alwaysAvailable = node.builtInTools.alwaysAvailable;
51
55
  if (alwaysAvailable === undefined || alwaysAvailable.filter !== undefined) {
52
56
  return { ...node, edges: normalizedEdges };
53
57
  }
@@ -76,15 +80,16 @@ function normalizeSharedNodeDefaults(untypedNode) {
76
80
  }
77
81
  /**
78
82
  * 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.
83
+ * pull verification must all use this same canonical content shape so a freshly
84
+ * pulled project is clean against its lock.
81
85
  */
82
86
  function normalizeAgentV2CommitContent(content) {
87
+ const { guardrails, nodeCheck, ...config } = content.config;
83
88
  return {
84
89
  ...content,
85
90
  nodes: content.nodes.map(normalizeNodeCompatibilityDefaults),
86
91
  config: {
87
- ...content.config,
92
+ ...config,
88
93
  speech: {
89
94
  ...content.config.speech,
90
95
  voiceFormattingEnabled: content.config.speech.voiceFormattingEnabled ?? false,
@@ -103,15 +108,21 @@ function normalizeAgentV2CommitContent(content) {
103
108
  callEnd: content.config.automaticActions.callEnd ?? null,
104
109
  },
105
110
  // The server declares a `null` default for the background message, so a
106
- // commit that predates the field means the same as one storing null.
111
+ // commit that predates the field means the same as one storing null. An
112
+ // empty `inputLabels` means the same as none, which is how compile writes it.
107
113
  ...(content.config.toolUseSites === undefined
108
114
  ? {}
109
115
  : {
110
- toolUseSites: content.config.toolUseSites.map((useSite) => ({
116
+ toolUseSites: content.config.toolUseSites.map(({ inputLabels, ...useSite }) => ({
111
117
  ...useSite,
118
+ ...(inputLabels === undefined || Object.keys(inputLabels).length === 0 ? {} : { inputLabels }),
112
119
  backgroundMessage: useSite.backgroundMessage ?? null,
113
120
  })),
114
121
  }),
122
+ // Defaults normalize to a commit written before the field, which is what a lock written then hashed, so an
123
+ // upgrade does not report a pristine project as changed.
124
+ ...(guardrails === undefined || guardrails.length === 0 ? {} : { guardrails }),
125
+ ...(nodeCheck?.enabled === true ? { nodeCheck } : {}),
115
126
  // `toneGuidelines` and `checkInAfterSilence.delaySeconds` are deliberately
116
127
  // not filled here. Both are three-state on the wire, and the authoring API
117
128
  // reproduces each state exactly, so filling a default would rewrite a
@@ -119,117 +130,6 @@ function normalizeAgentV2CommitContent(content) {
119
130
  },
120
131
  };
121
132
  }
122
- function replaceActionVersionUuid({ versionUuid, actions, options, }) {
123
- const actionDefinition = actions.find((item) => item.sourceVersionUuid === versionUuid);
124
- if (actionDefinition === undefined) {
125
- return versionUuid;
126
- }
127
- return options.actionVersionUuids?.[actionDefinition.key] ?? versionUuid;
128
- }
129
- function compileSnapshotNode({ node, actions, options, }) {
130
- if (node.type === 'action_node') {
131
- return {
132
- ...node,
133
- actionVersionUuid: replaceActionVersionUuid({
134
- versionUuid: node.actionVersionUuid,
135
- actions,
136
- options,
137
- }),
138
- };
139
- }
140
- if (node.type === 'standard' && node.perTurnAction != null) {
141
- return {
142
- ...node,
143
- perTurnAction: {
144
- ...node.perTurnAction,
145
- actionVersionUuid: replaceActionVersionUuid({
146
- versionUuid: node.perTurnAction.actionVersionUuid,
147
- actions,
148
- options,
149
- }),
150
- },
151
- };
152
- }
153
- return node;
154
- }
155
- function compileSnapshot(definition, options) {
156
- const normalizedContent = normalizeAgentV2CommitContent(definition.content);
157
- const snapshotActionValues = (values) => {
158
- switch (values.actionType) {
159
- case 'code':
160
- return {
161
- ...values,
162
- operation: {
163
- ...values.operation,
164
- compiledJs: null,
165
- },
166
- };
167
- case 'http':
168
- case 'custom_data':
169
- case 'knowledge_base':
170
- case 'built_in':
171
- return values;
172
- default: {
173
- values;
174
- throw new Error(`Unsupported Action type in snapshot: ${JSON.stringify(values)}`);
175
- }
176
- }
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
- };
188
- return {
189
- agent: definition.agent,
190
- branch: definition.branch,
191
- actions: definition.actions.map((item) => ({
192
- key: item.key,
193
- versionUuid: replaceActionVersionUuid({
194
- versionUuid: item.sourceVersionUuid,
195
- actions: definition.actions,
196
- options,
197
- }),
198
- values: snapshotActionValues(item.values),
199
- })),
200
- content: {
201
- ...normalizedContent,
202
- config: {
203
- ...normalizedContent.config,
204
- ...(normalizedContent.config.toolUseSites === undefined
205
- ? {}
206
- : {
207
- toolUseSites: normalizedContent.config.toolUseSites.map((useSite) => ({
208
- ...useSite,
209
- actionVersionUuid: replaceActionVersionUuid({
210
- versionUuid: useSite.actionVersionUuid,
211
- actions: definition.actions,
212
- options,
213
- }),
214
- })),
215
- }),
216
- automaticActions: {
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) }),
222
- },
223
- },
224
- nodes: normalizedContent.nodes.map((node) => compileSnapshotNode({ node, actions: definition.actions, options })),
225
- },
226
- };
227
- }
228
- function compileAgentProject(definition, options = {}) {
229
- return definition.kind === 'agent-definition'
230
- ? (0, agents_1.compileAgent)(definition, options)
231
- : compileSnapshot(definition, options);
232
- }
233
133
  function collectActionVersionUuids(content) {
234
134
  const versionUuids = new Set();
235
135
  for (const useSite of content.config.toolUseSites ?? []) {
@@ -241,6 +141,9 @@ function collectActionVersionUuids(content) {
241
141
  versionUuids.add(automaticAction.actionVersionUuid);
242
142
  }
243
143
  }
144
+ for (const useSite of assistActionUseSites(content.config.assist)) {
145
+ versionUuids.add(useSite.actionVersionUuid);
146
+ }
244
147
  for (const node of content.nodes) {
245
148
  if (node.type === 'action_node') {
246
149
  versionUuids.add(node.actionVersionUuid);
@@ -251,3 +154,13 @@ function collectActionVersionUuids(content) {
251
154
  }
252
155
  return [...versionUuids];
253
156
  }
157
+ /** Every Action use site an Agent Assist playbook runs: its procedures' steps first, then its card buttons. */
158
+ function assistActionUseSites(assist) {
159
+ if (assist === undefined) {
160
+ return [];
161
+ }
162
+ return [
163
+ ...assist.procedures.flatMap((procedure) => procedure.steps.flatMap((step) => (step.kind === 'run_action' ? [step.action] : []))),
164
+ ...assist.cards.flatMap((card) => card.buttons.map((button) => button.action)),
165
+ ];
166
+ }
@@ -1,24 +1,10 @@
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;
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
- * snapshot compilation must all use this same canonical content shape so a
20
- * freshly pulled project is clean against its lock.
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[];
@@ -1,24 +1,10 @@
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;
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
- * snapshot compilation must all use this same canonical content shape so a
20
- * freshly pulled project is clean against its lock.
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
- const alwaysAvailable = node.builtInTools?.alwaysAvailable;
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
- * snapshot compilation must all use this same canonical content shape so a
74
- * freshly pulled project is clean against its lock.
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
- ...content.config,
87
+ ...config,
82
88
  speech: {
83
89
  ...content.config.speech,
84
90
  voiceFormattingEnabled: content.config.speech.voiceFormattingEnabled ?? false,
@@ -97,15 +103,21 @@ export function normalizeAgentV2CommitContent(content) {
97
103
  callEnd: content.config.automaticActions.callEnd ?? null,
98
104
  },
99
105
  // The server declares a `null` default for the background message, so a
100
- // 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.
101
108
  ...(content.config.toolUseSites === undefined
102
109
  ? {}
103
110
  : {
104
- toolUseSites: content.config.toolUseSites.map((useSite) => ({
111
+ toolUseSites: content.config.toolUseSites.map(({ inputLabels, ...useSite }) => ({
105
112
  ...useSite,
113
+ ...(inputLabels === undefined || Object.keys(inputLabels).length === 0 ? {} : { inputLabels }),
106
114
  backgroundMessage: useSite.backgroundMessage ?? null,
107
115
  })),
108
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 } : {}),
109
121
  // `toneGuidelines` and `checkInAfterSilence.delaySeconds` are deliberately
110
122
  // not filled here. Both are three-state on the wire, and the authoring API
111
123
  // reproduces each state exactly, so filling a default would rewrite a
@@ -113,117 +125,6 @@ export function normalizeAgentV2CommitContent(content) {
113
125
  },
114
126
  };
115
127
  }
116
- function replaceActionVersionUuid({ versionUuid, actions, options, }) {
117
- const actionDefinition = actions.find((item) => item.sourceVersionUuid === versionUuid);
118
- if (actionDefinition === undefined) {
119
- return versionUuid;
120
- }
121
- return options.actionVersionUuids?.[actionDefinition.key] ?? versionUuid;
122
- }
123
- function compileSnapshotNode({ node, actions, options, }) {
124
- if (node.type === 'action_node') {
125
- return {
126
- ...node,
127
- actionVersionUuid: replaceActionVersionUuid({
128
- versionUuid: node.actionVersionUuid,
129
- actions,
130
- options,
131
- }),
132
- };
133
- }
134
- if (node.type === 'standard' && node.perTurnAction != null) {
135
- return {
136
- ...node,
137
- perTurnAction: {
138
- ...node.perTurnAction,
139
- actionVersionUuid: replaceActionVersionUuid({
140
- versionUuid: node.perTurnAction.actionVersionUuid,
141
- actions,
142
- options,
143
- }),
144
- },
145
- };
146
- }
147
- return node;
148
- }
149
- function compileSnapshot(definition, options) {
150
- const normalizedContent = normalizeAgentV2CommitContent(definition.content);
151
- const snapshotActionValues = (values) => {
152
- switch (values.actionType) {
153
- case 'code':
154
- return {
155
- ...values,
156
- operation: {
157
- ...values.operation,
158
- compiledJs: null,
159
- },
160
- };
161
- case 'http':
162
- case 'custom_data':
163
- case 'knowledge_base':
164
- case 'built_in':
165
- return values;
166
- default: {
167
- values;
168
- throw new Error(`Unsupported Action type in snapshot: ${JSON.stringify(values)}`);
169
- }
170
- }
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
- };
182
- return {
183
- agent: definition.agent,
184
- branch: definition.branch,
185
- actions: definition.actions.map((item) => ({
186
- key: item.key,
187
- versionUuid: replaceActionVersionUuid({
188
- versionUuid: item.sourceVersionUuid,
189
- actions: definition.actions,
190
- options,
191
- }),
192
- values: snapshotActionValues(item.values),
193
- })),
194
- content: {
195
- ...normalizedContent,
196
- config: {
197
- ...normalizedContent.config,
198
- ...(normalizedContent.config.toolUseSites === undefined
199
- ? {}
200
- : {
201
- toolUseSites: normalizedContent.config.toolUseSites.map((useSite) => ({
202
- ...useSite,
203
- actionVersionUuid: replaceActionVersionUuid({
204
- versionUuid: useSite.actionVersionUuid,
205
- actions: definition.actions,
206
- options,
207
- }),
208
- })),
209
- }),
210
- automaticActions: {
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) }),
216
- },
217
- },
218
- nodes: normalizedContent.nodes.map((node) => compileSnapshotNode({ node, actions: definition.actions, options })),
219
- },
220
- };
221
- }
222
- export function compileAgentProject(definition, options = {}) {
223
- return definition.kind === 'agent-definition'
224
- ? compileAgent(definition, options)
225
- : compileSnapshot(definition, options);
226
- }
227
128
  export function collectActionVersionUuids(content) {
228
129
  const versionUuids = new Set();
229
130
  for (const useSite of content.config.toolUseSites ?? []) {
@@ -235,6 +136,9 @@ export function collectActionVersionUuids(content) {
235
136
  versionUuids.add(automaticAction.actionVersionUuid);
236
137
  }
237
138
  }
139
+ for (const useSite of assistActionUseSites(content.config.assist)) {
140
+ versionUuids.add(useSite.actionVersionUuid);
141
+ }
238
142
  for (const node of content.nodes) {
239
143
  if (node.type === 'action_node') {
240
144
  versionUuids.add(node.actionVersionUuid);
@@ -245,3 +149,13 @@ export function collectActionVersionUuids(content) {
245
149
  }
246
150
  return [...versionUuids];
247
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
+ }
@@ -50,13 +50,11 @@ export declare const clientCredentialsTokenInputSchema: z.ZodObject<{
50
50
  tokenUrl: z.ZodURL;
51
51
  clientId: z.ZodString;
52
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
53
  clientAuthentication: z.ZodDefault<z.ZodEnum<{
55
54
  client_secret_basic: "client_secret_basic";
56
55
  client_secret_post: "client_secret_post";
57
56
  }>>;
58
57
  scope: z.ZodDefault<z.ZodNullable<z.ZodString>>;
59
- /** Additional token request parameters, such as `audience` (Auth0) or `resource` (Azure AD v1). */
60
58
  extraParameters: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodString>>;
61
59
  forceRefresh: z.ZodDefault<z.ZodBoolean>;
62
60
  }, z.core.$strict>;
package/dist/schemas.d.ts CHANGED
@@ -50,13 +50,11 @@ export declare const clientCredentialsTokenInputSchema: z.ZodObject<{
50
50
  tokenUrl: z.ZodURL;
51
51
  clientId: z.ZodString;
52
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
53
  clientAuthentication: z.ZodDefault<z.ZodEnum<{
55
54
  client_secret_basic: "client_secret_basic";
56
55
  client_secret_post: "client_secret_post";
57
56
  }>>;
58
57
  scope: z.ZodDefault<z.ZodNullable<z.ZodString>>;
59
- /** Additional token request parameters, such as `audience` (Auth0) or `resource` (Azure AD v1). */
60
58
  extraParameters: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodString>>;
61
59
  forceRefresh: z.ZodDefault<z.ZodBoolean>;
62
60
  }, z.core.$strict>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@simple-ai-lab/sdk",
3
- "version": "0.12.0",
3
+ "version": "0.15.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.1.12"
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
31
  "vitest": "4.1.12",
32
- "zod": "^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": "tsc --noEmit",
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
- "typecheck": "tsc --noEmit",
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
  }