@simple-ai-lab/sdk 0.9.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/README.md CHANGED
@@ -131,6 +131,7 @@ export default defineAgent({
131
131
  key: 'support',
132
132
  name: 'Support',
133
133
  branch: 'main',
134
+ llm: { modelUuid: 'your-llm-model-uuid' },
134
135
  nodes: [
135
136
  node.prompt({
136
137
  key: 'root',
package/dist/agents.cjs CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.DEFAULT_PER_TURN_RETRIEVAL_RECENT_TURNS = exports.DEFAULT_PER_TURN_RETRIEVAL_TOP_K = exports.prompt = exports.node = exports.MAX_CONTAINMENT_RULE_DEPTH = exports.CONTAINMENT_CONTAINED_CONDITION_TYPES = exports.CONTAINMENT_CONTAINABLE_CONDITION_TYPES = exports.CONTAINMENT_RULE_MATCHES = exports.FIVE9_SIP_BYE_HEADER_NAMES = exports.SOP_TOOL_REF_TYPES = exports.DEFAULT_CHECK_IN_AFTER_SILENCE_DELAY_SECONDS = exports.DEFAULT_TRANSITION_MESSAGE = exports.TRANSITION_FILTER_MAX_CONDITIONS = exports.TRANSITION_FILTER_MAX_DEPTH = exports.TRANSITION_FILTER_EXISTENCE_OPERATORS = exports.TRANSITION_FILTER_STRING_OPERATORS = exports.TRANSITION_FILTER_CONTAINS_OPERATORS = exports.TRANSITION_FILTER_NUMERIC_OPERATORS = exports.TRANSITION_FILTER_EQUALITY_OPERATORS = void 0;
3
+ exports.DEFAULT_PER_TURN_RETRIEVAL_RECENT_TURNS = exports.DEFAULT_PER_TURN_RETRIEVAL_TOP_K = exports.prompt = exports.node = exports.MAX_CONTAINMENT_RULE_DEPTH = exports.CONTAINMENT_CONTAINED_CONDITION_TYPES = exports.CONTAINMENT_CONTAINABLE_CONDITION_TYPES = exports.CONTAINMENT_RULE_MATCHES = exports.FIVE9_SIP_BYE_HEADER_NAMES = exports.SOP_TOOL_REF_TYPES = exports.DEFAULT_CHECK_IN_AFTER_SILENCE_DELAY_SECONDS = exports.DEFAULT_TRANSITION_MESSAGE = exports.TRANSITION_FILTER_MAX_CONDITIONS = exports.TRANSITION_FILTER_MAX_DEPTH = exports.PII_REDACTION_CATEGORIES = exports.TRANSITION_FILTER_EXISTENCE_OPERATORS = exports.TRANSITION_FILTER_STRING_OPERATORS = exports.TRANSITION_FILTER_CONTAINS_OPERATORS = exports.TRANSITION_FILTER_NUMERIC_OPERATORS = exports.TRANSITION_FILTER_EQUALITY_OPERATORS = void 0;
4
4
  exports.defaultBackgroundNoise = defaultBackgroundNoise;
5
5
  exports.defineAgent = defineAgent;
6
6
  exports.reference = reference;
@@ -28,6 +28,8 @@ exports.TRANSITION_FILTER_NUMERIC_OPERATORS = [
28
28
  exports.TRANSITION_FILTER_CONTAINS_OPERATORS = ['contains', 'not_contains'];
29
29
  exports.TRANSITION_FILTER_STRING_OPERATORS = ['starts_with', 'ends_with'];
30
30
  exports.TRANSITION_FILTER_EXISTENCE_OPERATORS = ['exists', 'not_exists'];
31
+ /** The kinds of personal information a voice agent can redact from its transcripts. Mirrors the platform enum. */
32
+ exports.PII_REDACTION_CATEGORIES = ['name', 'dob', 'ssn', 'phone', 'email', 'address'];
31
33
  exports.TRANSITION_FILTER_MAX_DEPTH = 8;
32
34
  exports.TRANSITION_FILTER_MAX_CONDITIONS = 100;
33
35
  /** Speaking on a transition is opt-in per edge. */
@@ -43,7 +45,7 @@ function defaultBackgroundNoise({ voiceBackgroundNoise, }) {
43
45
  /** How long the agent waits before checking in on a silent caller. Matches the product default. */
44
46
  exports.DEFAULT_CHECK_IN_AFTER_SILENCE_DELAY_SECONDS = 30;
45
47
  function llmOverrideWire(override) {
46
- return { model: override.model, llmModelUuid: override.modelUuid, temperature: override.temperature };
48
+ return { llmModelUuid: override.modelUuid, temperature: override.temperature };
47
49
  }
48
50
  /** A tool a SOP section may use, by the uuid the graph already assigns it. */
49
51
  exports.SOP_TOOL_REF_TYPES = ['http', 'knowledge-base', 'action'];
@@ -107,9 +109,8 @@ function defineAgent(input) {
107
109
  backgroundNoise: voiceBackgroundNoise,
108
110
  },
109
111
  llm: {
110
- model: input.llm?.model ?? 'gpt-4.1',
111
- modelUuid: input.llm?.modelUuid ?? null,
112
- temperature: input.llm?.temperature ?? 0.65,
112
+ modelUuid: input.llm.modelUuid,
113
+ temperature: input.llm.temperature ?? 0.65,
113
114
  },
114
115
  speech: {
115
116
  language: input.speech?.language ?? 'en',
@@ -135,6 +136,7 @@ function defineAgent(input) {
135
136
  },
136
137
  endCallAfterExtendedSilence: input.call?.endCallAfterExtendedSilence ?? false,
137
138
  pciEnabled: input.call?.pciEnabled ?? false,
139
+ piiRedaction: normalizePiiRedaction(input.call?.piiRedaction),
138
140
  backgroundNoise: input.call?.backgroundNoise === undefined
139
141
  ? defaultBackgroundNoise({ voiceBackgroundNoise })
140
142
  : input.call.backgroundNoise,
@@ -1006,6 +1008,27 @@ function compileCartCheckout({ checkout, resolveAction, nodeAt, }) {
1006
1008
  }
1007
1009
  }
1008
1010
  }
1011
+ /**
1012
+ * Each category at most once, in the order authored, so a pulled commit compiles back to itself.
1013
+ * An omitted or null selection stays null and leaves the choice to the organization.
1014
+ */
1015
+ function normalizePiiRedaction(input) {
1016
+ if (input == null) {
1017
+ return null;
1018
+ }
1019
+ const requested = input.categories;
1020
+ const seen = new Set();
1021
+ for (const category of requested) {
1022
+ if (!exports.PII_REDACTION_CATEGORIES.includes(category)) {
1023
+ throw new Error(`Unknown PII redaction category: ${String(category)}`);
1024
+ }
1025
+ if (seen.has(category)) {
1026
+ throw new Error(`PII redaction category listed more than once: ${category}`);
1027
+ }
1028
+ seen.add(category);
1029
+ }
1030
+ return { categories: [...requested] };
1031
+ }
1009
1032
  /** Plain JavaScript callers aren't held to the types; order ids only come from an Action's outputs. */
1010
1033
  function assertNoCheckoutOrderIds(checkout) {
1011
1034
  if (checkout.orderIds != null) {
@@ -1123,7 +1146,6 @@ function compileAgent(definition, options = {}) {
1123
1146
  backgroundNoise: definition.voice.backgroundNoise,
1124
1147
  },
1125
1148
  llm: {
1126
- model: definition.llm.model,
1127
1149
  llmModelUuid: definition.llm.modelUuid,
1128
1150
  temperature: definition.llm.temperature,
1129
1151
  },
@@ -1137,6 +1159,7 @@ function compileAgent(definition, options = {}) {
1137
1159
  checkInAfterSilence: definition.call.checkInAfterSilence,
1138
1160
  endCallAfterExtendedSilence: definition.call.endCallAfterExtendedSilence,
1139
1161
  pciEnabled: definition.call.pciEnabled,
1162
+ piiRedaction: definition.call.piiRedaction,
1140
1163
  ...(definition.call.backgroundNoise === null ? {} : { backgroundNoise: definition.call.backgroundNoise }),
1141
1164
  // Absent and a value are the only two states the product writes, so
1142
1165
  // `null` means omit rather than sending an invented default. The platform derives the
package/dist/agents.d.cts CHANGED
@@ -8,6 +8,18 @@ export declare const TRANSITION_FILTER_NUMERIC_OPERATORS: readonly ["greater_tha
8
8
  export declare const TRANSITION_FILTER_CONTAINS_OPERATORS: readonly ["contains", "not_contains"];
9
9
  export declare const TRANSITION_FILTER_STRING_OPERATORS: readonly ["starts_with", "ends_with"];
10
10
  export declare const TRANSITION_FILTER_EXISTENCE_OPERATORS: readonly ["exists", "not_exists"];
11
+ /** The kinds of personal information a voice agent can redact from its transcripts. Mirrors the platform enum. */
12
+ export declare const PII_REDACTION_CATEGORIES: readonly ["name", "dob", "ssn", "phone", "email", "address"];
13
+ export type PiiRedactionCategory = (typeof PII_REDACTION_CATEGORIES)[number];
14
+ export interface PiiRedactionConfig {
15
+ /**
16
+ * Empty means the agent chose no category. Payment-card data and credentials are redacted
17
+ * whenever redaction runs, and the organization's default can still turn it on. The list
18
+ * directs the redactor rather than bounding it: a transcript records every category it
19
+ * actually redacted, which can include one outside the list.
20
+ */
21
+ categories: PiiRedactionCategory[];
22
+ }
11
23
  export type TransitionFilterCondition = {
12
24
  path: TransitionFilterPath;
13
25
  operator: (typeof TRANSITION_FILTER_EQUALITY_OPERATORS)[number];
@@ -282,8 +294,7 @@ export type AgentV2ConfigWire = {
282
294
  backgroundNoise: BackgroundNoise;
283
295
  };
284
296
  llm: {
285
- model: string;
286
- llmModelUuid: string | null;
297
+ llmModelUuid: string;
287
298
  temperature: number;
288
299
  };
289
300
  speech: {
@@ -307,6 +318,8 @@ export type AgentV2ConfigWire = {
307
318
  };
308
319
  endCallAfterExtendedSilence: boolean;
309
320
  pciEnabled: boolean;
321
+ /** Null while the version leaves the choice to the organization; absent in commits written before it existed. */
322
+ piiRedaction?: PiiRedactionConfig | null;
310
323
  /** Absent in commits with no background noise configured. */
311
324
  backgroundNoise?: BackgroundNoiseConfig;
312
325
  /** Optional only for commit snapshots written before the Voice Analysis settings existed. */
@@ -337,6 +350,10 @@ export type AgentV2ConfigWire = {
337
350
  beforeCallStart: (ActionUseSiteWire & {
338
351
  trigger: 'before_call_start';
339
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;
340
357
  };
341
358
  knowledgeBaseIds: string[];
342
359
  abTestGroupIds: string[];
@@ -518,7 +535,6 @@ export type ParameterUpdate = {
518
535
  };
519
536
  /** A per-node model override on the wire, where the model UUID is `llmModelUuid`. */
520
537
  export type LlmOverrideWire = {
521
- model: string | null;
522
538
  llmModelUuid: string | null;
523
539
  temperature: number | null;
524
540
  };
@@ -528,7 +544,6 @@ export type LlmOverrideWire = {
528
544
  * cannot drift; `modelUuid` is the authoring spelling of `llmModelUuid`.
529
545
  */
530
546
  export type LlmOverrideDefinition = {
531
- model: string | null;
532
547
  modelUuid: string | null;
533
548
  temperature: number | null;
534
549
  };
@@ -938,8 +953,7 @@ export type AgentDefinition = {
938
953
  backgroundNoise: BackgroundNoise;
939
954
  };
940
955
  llm: {
941
- model: string;
942
- modelUuid: string | null;
956
+ modelUuid: string;
943
957
  temperature: number;
944
958
  };
945
959
  speech: {
@@ -964,6 +978,11 @@ export type AgentDefinition = {
964
978
  checkInAfterSilence: CheckInAfterSilence;
965
979
  endCallAfterExtendedSilence: boolean;
966
980
  pciEnabled: boolean;
981
+ /**
982
+ * `null` leaves the choice to the organization's default at call time. An empty list is
983
+ * an explicit choice of none.
984
+ */
985
+ piiRedaction: PiiRedactionConfig | null;
967
986
  /**
968
987
  * Agent v2's `call.backgroundNoise`, which is what a call actually plays.
969
988
  * It is stored apart from `voice.backgroundNoise`, and the two can
@@ -1033,9 +1052,8 @@ export type AgentDefinitionInput = {
1033
1052
  voiceUuid?: string | null;
1034
1053
  backgroundNoise?: BackgroundNoise;
1035
1054
  };
1036
- llm?: {
1037
- model?: string;
1038
- modelUuid?: string | null;
1055
+ llm: {
1056
+ modelUuid: string;
1039
1057
  temperature?: number;
1040
1058
  };
1041
1059
  speech?: {
package/dist/agents.d.ts CHANGED
@@ -8,6 +8,18 @@ export declare const TRANSITION_FILTER_NUMERIC_OPERATORS: readonly ["greater_tha
8
8
  export declare const TRANSITION_FILTER_CONTAINS_OPERATORS: readonly ["contains", "not_contains"];
9
9
  export declare const TRANSITION_FILTER_STRING_OPERATORS: readonly ["starts_with", "ends_with"];
10
10
  export declare const TRANSITION_FILTER_EXISTENCE_OPERATORS: readonly ["exists", "not_exists"];
11
+ /** The kinds of personal information a voice agent can redact from its transcripts. Mirrors the platform enum. */
12
+ export declare const PII_REDACTION_CATEGORIES: readonly ["name", "dob", "ssn", "phone", "email", "address"];
13
+ export type PiiRedactionCategory = (typeof PII_REDACTION_CATEGORIES)[number];
14
+ export interface PiiRedactionConfig {
15
+ /**
16
+ * Empty means the agent chose no category. Payment-card data and credentials are redacted
17
+ * whenever redaction runs, and the organization's default can still turn it on. The list
18
+ * directs the redactor rather than bounding it: a transcript records every category it
19
+ * actually redacted, which can include one outside the list.
20
+ */
21
+ categories: PiiRedactionCategory[];
22
+ }
11
23
  export type TransitionFilterCondition = {
12
24
  path: TransitionFilterPath;
13
25
  operator: (typeof TRANSITION_FILTER_EQUALITY_OPERATORS)[number];
@@ -282,8 +294,7 @@ export type AgentV2ConfigWire = {
282
294
  backgroundNoise: BackgroundNoise;
283
295
  };
284
296
  llm: {
285
- model: string;
286
- llmModelUuid: string | null;
297
+ llmModelUuid: string;
287
298
  temperature: number;
288
299
  };
289
300
  speech: {
@@ -307,6 +318,8 @@ export type AgentV2ConfigWire = {
307
318
  };
308
319
  endCallAfterExtendedSilence: boolean;
309
320
  pciEnabled: boolean;
321
+ /** Null while the version leaves the choice to the organization; absent in commits written before it existed. */
322
+ piiRedaction?: PiiRedactionConfig | null;
310
323
  /** Absent in commits with no background noise configured. */
311
324
  backgroundNoise?: BackgroundNoiseConfig;
312
325
  /** Optional only for commit snapshots written before the Voice Analysis settings existed. */
@@ -337,6 +350,10 @@ export type AgentV2ConfigWire = {
337
350
  beforeCallStart: (ActionUseSiteWire & {
338
351
  trigger: 'before_call_start';
339
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;
340
357
  };
341
358
  knowledgeBaseIds: string[];
342
359
  abTestGroupIds: string[];
@@ -518,7 +535,6 @@ export type ParameterUpdate = {
518
535
  };
519
536
  /** A per-node model override on the wire, where the model UUID is `llmModelUuid`. */
520
537
  export type LlmOverrideWire = {
521
- model: string | null;
522
538
  llmModelUuid: string | null;
523
539
  temperature: number | null;
524
540
  };
@@ -528,7 +544,6 @@ export type LlmOverrideWire = {
528
544
  * cannot drift; `modelUuid` is the authoring spelling of `llmModelUuid`.
529
545
  */
530
546
  export type LlmOverrideDefinition = {
531
- model: string | null;
532
547
  modelUuid: string | null;
533
548
  temperature: number | null;
534
549
  };
@@ -938,8 +953,7 @@ export type AgentDefinition = {
938
953
  backgroundNoise: BackgroundNoise;
939
954
  };
940
955
  llm: {
941
- model: string;
942
- modelUuid: string | null;
956
+ modelUuid: string;
943
957
  temperature: number;
944
958
  };
945
959
  speech: {
@@ -964,6 +978,11 @@ export type AgentDefinition = {
964
978
  checkInAfterSilence: CheckInAfterSilence;
965
979
  endCallAfterExtendedSilence: boolean;
966
980
  pciEnabled: boolean;
981
+ /**
982
+ * `null` leaves the choice to the organization's default at call time. An empty list is
983
+ * an explicit choice of none.
984
+ */
985
+ piiRedaction: PiiRedactionConfig | null;
967
986
  /**
968
987
  * Agent v2's `call.backgroundNoise`, which is what a call actually plays.
969
988
  * It is stored apart from `voice.backgroundNoise`, and the two can
@@ -1033,9 +1052,8 @@ export type AgentDefinitionInput = {
1033
1052
  voiceUuid?: string | null;
1034
1053
  backgroundNoise?: BackgroundNoise;
1035
1054
  };
1036
- llm?: {
1037
- model?: string;
1038
- modelUuid?: string | null;
1055
+ llm: {
1056
+ modelUuid: string;
1039
1057
  temperature?: number;
1040
1058
  };
1041
1059
  speech?: {
package/dist/agents.js CHANGED
@@ -18,6 +18,8 @@ export const TRANSITION_FILTER_NUMERIC_OPERATORS = [
18
18
  export const TRANSITION_FILTER_CONTAINS_OPERATORS = ['contains', 'not_contains'];
19
19
  export const TRANSITION_FILTER_STRING_OPERATORS = ['starts_with', 'ends_with'];
20
20
  export const TRANSITION_FILTER_EXISTENCE_OPERATORS = ['exists', 'not_exists'];
21
+ /** The kinds of personal information a voice agent can redact from its transcripts. Mirrors the platform enum. */
22
+ export const PII_REDACTION_CATEGORIES = ['name', 'dob', 'ssn', 'phone', 'email', 'address'];
21
23
  export const TRANSITION_FILTER_MAX_DEPTH = 8;
22
24
  export const TRANSITION_FILTER_MAX_CONDITIONS = 100;
23
25
  /** Speaking on a transition is opt-in per edge. */
@@ -33,7 +35,7 @@ export function defaultBackgroundNoise({ voiceBackgroundNoise, }) {
33
35
  /** How long the agent waits before checking in on a silent caller. Matches the product default. */
34
36
  export const DEFAULT_CHECK_IN_AFTER_SILENCE_DELAY_SECONDS = 30;
35
37
  function llmOverrideWire(override) {
36
- return { model: override.model, llmModelUuid: override.modelUuid, temperature: override.temperature };
38
+ return { llmModelUuid: override.modelUuid, temperature: override.temperature };
37
39
  }
38
40
  /** A tool a SOP section may use, by the uuid the graph already assigns it. */
39
41
  export const SOP_TOOL_REF_TYPES = ['http', 'knowledge-base', 'action'];
@@ -97,9 +99,8 @@ export function defineAgent(input) {
97
99
  backgroundNoise: voiceBackgroundNoise,
98
100
  },
99
101
  llm: {
100
- model: input.llm?.model ?? 'gpt-4.1',
101
- modelUuid: input.llm?.modelUuid ?? null,
102
- temperature: input.llm?.temperature ?? 0.65,
102
+ modelUuid: input.llm.modelUuid,
103
+ temperature: input.llm.temperature ?? 0.65,
103
104
  },
104
105
  speech: {
105
106
  language: input.speech?.language ?? 'en',
@@ -125,6 +126,7 @@ export function defineAgent(input) {
125
126
  },
126
127
  endCallAfterExtendedSilence: input.call?.endCallAfterExtendedSilence ?? false,
127
128
  pciEnabled: input.call?.pciEnabled ?? false,
129
+ piiRedaction: normalizePiiRedaction(input.call?.piiRedaction),
128
130
  backgroundNoise: input.call?.backgroundNoise === undefined
129
131
  ? defaultBackgroundNoise({ voiceBackgroundNoise })
130
132
  : input.call.backgroundNoise,
@@ -996,6 +998,27 @@ function compileCartCheckout({ checkout, resolveAction, nodeAt, }) {
996
998
  }
997
999
  }
998
1000
  }
1001
+ /**
1002
+ * Each category at most once, in the order authored, so a pulled commit compiles back to itself.
1003
+ * An omitted or null selection stays null and leaves the choice to the organization.
1004
+ */
1005
+ function normalizePiiRedaction(input) {
1006
+ if (input == null) {
1007
+ return null;
1008
+ }
1009
+ const requested = input.categories;
1010
+ const seen = new Set();
1011
+ for (const category of requested) {
1012
+ if (!PII_REDACTION_CATEGORIES.includes(category)) {
1013
+ throw new Error(`Unknown PII redaction category: ${String(category)}`);
1014
+ }
1015
+ if (seen.has(category)) {
1016
+ throw new Error(`PII redaction category listed more than once: ${category}`);
1017
+ }
1018
+ seen.add(category);
1019
+ }
1020
+ return { categories: [...requested] };
1021
+ }
999
1022
  /** Plain JavaScript callers aren't held to the types; order ids only come from an Action's outputs. */
1000
1023
  function assertNoCheckoutOrderIds(checkout) {
1001
1024
  if (checkout.orderIds != null) {
@@ -1113,7 +1136,6 @@ export function compileAgent(definition, options = {}) {
1113
1136
  backgroundNoise: definition.voice.backgroundNoise,
1114
1137
  },
1115
1138
  llm: {
1116
- model: definition.llm.model,
1117
1139
  llmModelUuid: definition.llm.modelUuid,
1118
1140
  temperature: definition.llm.temperature,
1119
1141
  },
@@ -1127,6 +1149,7 @@ export function compileAgent(definition, options = {}) {
1127
1149
  checkInAfterSilence: definition.call.checkInAfterSilence,
1128
1150
  endCallAfterExtendedSilence: definition.call.endCallAfterExtendedSilence,
1129
1151
  pciEnabled: definition.call.pciEnabled,
1152
+ piiRedaction: definition.call.piiRedaction,
1130
1153
  ...(definition.call.backgroundNoise === null ? {} : { backgroundNoise: definition.call.backgroundNoise }),
1131
1154
  // Absent and a value are the only two states the product writes, so
1132
1155
  // `null` means omit rather than sending an invented default. The platform derives the
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.dataFilterSchema = exports.dataColumnPathSchema = 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.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 = 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; } });
@@ -23,6 +23,7 @@ Object.defineProperty(exports, "defineAgent", { enumerable: true, get: function
23
23
  Object.defineProperty(exports, "FIVE9_SIP_BYE_HEADER_NAMES", { enumerable: true, get: function () { return agents_1.FIVE9_SIP_BYE_HEADER_NAMES; } });
24
24
  Object.defineProperty(exports, "MAX_CONTAINMENT_RULE_DEPTH", { enumerable: true, get: function () { return agents_1.MAX_CONTAINMENT_RULE_DEPTH; } });
25
25
  Object.defineProperty(exports, "node", { enumerable: true, get: function () { return agents_1.node; } });
26
+ Object.defineProperty(exports, "PII_REDACTION_CATEGORIES", { enumerable: true, get: function () { return agents_1.PII_REDACTION_CATEGORIES; } });
26
27
  Object.defineProperty(exports, "prompt", { enumerable: true, get: function () { return agents_1.prompt; } });
27
28
  Object.defineProperty(exports, "reference", { enumerable: true, get: function () { return agents_1.reference; } });
28
29
  Object.defineProperty(exports, "resolveExtractionFields", { enumerable: true, get: function () { return agents_1.resolveExtractionFields; } });
@@ -59,6 +60,7 @@ Object.defineProperty(exports, "defineAgentSnapshot", { enumerable: true, get: f
59
60
  Object.defineProperty(exports, "normalizeAgentV2CommitContent", { enumerable: true, get: function () { return projects_1.normalizeAgentV2CommitContent; } });
60
61
  var schemas_1 = require("./schemas.cjs");
61
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; } });
62
64
  Object.defineProperty(exports, "dataColumnPathSchema", { enumerable: true, get: function () { return schemas_1.dataColumnPathSchema; } });
63
65
  Object.defineProperty(exports, "dataFilterSchema", { enumerable: true, get: function () { return schemas_1.dataFilterSchema; } });
64
66
  Object.defineProperty(exports, "listOptionsSchema", { enumerable: true, get: function () { return schemas_1.listOptionsSchema; } });
package/dist/index.d.cts CHANGED
@@ -1,12 +1,12 @@
1
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.cjs";
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, 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.cjs";
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.cjs";
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
@@ -1,12 +1,12 @@
1
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, 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";
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
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
@@ -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, prompt, reference, resolveExtractionFields, TRANSITION_FILTER_MAX_CONDITIONS, TRANSITION_FILTER_MAX_DEPTH, } from "./agents.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
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 } 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
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;
@@ -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
+ }
@@ -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
@@ -90,6 +90,18 @@ function normalizeAgentV2CommitContent(content) {
90
90
  voiceFormattingEnabled: content.config.speech.voiceFormattingEnabled ?? false,
91
91
  pronunciations: content.config.speech.pronunciations ?? [],
92
92
  },
93
+ call: {
94
+ ...content.config.call,
95
+ // The server reads a commit that predates the setting as null, leaving the choice to
96
+ // the organization.
97
+ piiRedaction: content.config.call.piiRedaction ?? null,
98
+ },
99
+ // The server declares a `null` default for the call-end Action, so a commit
100
+ // without one means the same as one storing null.
101
+ automaticActions: {
102
+ ...content.config.automaticActions,
103
+ callEnd: content.config.automaticActions.callEnd ?? null,
104
+ },
93
105
  // The server declares a `null` default for the background message, so a
94
106
  // commit that predates the field means the same as one storing null.
95
107
  ...(content.config.toolUseSites === undefined
@@ -163,6 +175,16 @@ function compileSnapshot(definition, options) {
163
175
  }
164
176
  }
165
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
+ };
166
188
  return {
167
189
  agent: definition.agent,
168
190
  branch: definition.branch,
@@ -192,16 +214,11 @@ function compileSnapshot(definition, options) {
192
214
  })),
193
215
  }),
194
216
  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
- },
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) }),
205
222
  },
206
223
  },
207
224
  nodes: normalizedContent.nodes.map((node) => compileSnapshotNode({ node, actions: definition.actions, options })),
@@ -218,9 +235,11 @@ function collectActionVersionUuids(content) {
218
235
  for (const useSite of content.config.toolUseSites ?? []) {
219
236
  versionUuids.add(useSite.actionVersionUuid);
220
237
  }
221
- const beforeCallAction = content.config.automaticActions.beforeCallStart;
222
- if (beforeCallAction !== null) {
223
- versionUuids.add(beforeCallAction.actionVersionUuid);
238
+ const { beforeCallStart, callEnd } = content.config.automaticActions;
239
+ for (const automaticAction of [beforeCallStart, callEnd]) {
240
+ if (automaticAction != null) {
241
+ versionUuids.add(automaticAction.actionVersionUuid);
242
+ }
224
243
  }
225
244
  for (const node of content.nodes) {
226
245
  if (node.type === 'action_node') {
package/dist/projects.js CHANGED
@@ -84,6 +84,18 @@ export function normalizeAgentV2CommitContent(content) {
84
84
  voiceFormattingEnabled: content.config.speech.voiceFormattingEnabled ?? false,
85
85
  pronunciations: content.config.speech.pronunciations ?? [],
86
86
  },
87
+ call: {
88
+ ...content.config.call,
89
+ // The server reads a commit that predates the setting as null, leaving the choice to
90
+ // the organization.
91
+ piiRedaction: content.config.call.piiRedaction ?? null,
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
+ },
87
99
  // The server declares a `null` default for the background message, so a
88
100
  // commit that predates the field means the same as one storing null.
89
101
  ...(content.config.toolUseSites === undefined
@@ -157,6 +169,16 @@ function compileSnapshot(definition, options) {
157
169
  }
158
170
  }
159
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
+ };
160
182
  return {
161
183
  agent: definition.agent,
162
184
  branch: definition.branch,
@@ -186,16 +208,11 @@ function compileSnapshot(definition, options) {
186
208
  })),
187
209
  }),
188
210
  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
- },
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) }),
199
216
  },
200
217
  },
201
218
  nodes: normalizedContent.nodes.map((node) => compileSnapshotNode({ node, actions: definition.actions, options })),
@@ -212,9 +229,11 @@ export function collectActionVersionUuids(content) {
212
229
  for (const useSite of content.config.toolUseSites ?? []) {
213
230
  versionUuids.add(useSite.actionVersionUuid);
214
231
  }
215
- const beforeCallAction = content.config.automaticActions.beforeCallStart;
216
- if (beforeCallAction !== null) {
217
- versionUuids.add(beforeCallAction.actionVersionUuid);
232
+ const { beforeCallStart, callEnd } = content.config.automaticActions;
233
+ for (const automaticAction of [beforeCallStart, callEnd]) {
234
+ if (automaticAction != null) {
235
+ versionUuids.add(automaticAction.actionVersionUuid);
236
+ }
218
237
  }
219
238
  for (const node of content.nodes) {
220
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
+ });
@@ -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.9.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.11",
31
+ "vitest": "4.1.12",
32
32
  "zod": "^4.1.12",
33
33
  "zshy": "^0.7.3"
34
34
  },