@slates/provider 1.0.0-rc.12 → 1.0.0-rc.14

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.cjs CHANGED
@@ -233,7 +233,7 @@ var normalizeRetryable = (code, retryable) => {
233
233
  return code === "request.rate_limited" || code === "upstream.rate_limited" || code === "upstream.timeout" || code === "upstream.network_error" || code === "upstream.unavailable" || code === "upstream.error" || code === "transport.invoke_failed" || code === "internal.timeout";
234
234
  };
235
235
  var getDefaultMessage = (code, message) => {
236
- if (message && message.trim()) return message;
236
+ if (message?.trim()) return message;
237
237
  return DEFAULT_MESSAGES[code] ?? DEFAULT_MESSAGES[DEFAULT_CODE];
238
238
  };
239
239
  var cleanRecord = (value) => {
@@ -510,7 +510,9 @@ var normalizeServiceErrorIssues = (errors) => {
510
510
  return issues.length > 0 ? issues : void 0;
511
511
  };
512
512
  var getServiceErrorBaggage = (data) => {
513
- let extraEntries = Object.entries(data).filter(([key]) => !SERVICE_ERROR_DATA_RESERVED_KEYS.has(key));
513
+ let extraEntries = Object.entries(data).filter(
514
+ ([key]) => !SERVICE_ERROR_DATA_RESERVED_KEYS.has(key)
515
+ );
514
516
  return cleanRecord({
515
517
  serviceError: {
516
518
  code: data.code,
@@ -728,7 +730,9 @@ var normalizeClause = (input) => {
728
730
  };
729
731
  var assertScopeValues = (scopes) => {
730
732
  if (scopes.length === 0) {
731
- throw new SlateDeclarationError("Each action scope clause must include at least one OR scope");
733
+ throw new SlateDeclarationError(
734
+ "Each action scope clause must include at least one OR scope"
735
+ );
732
736
  }
733
737
  for (let scope of scopes) {
734
738
  if (typeof scope !== "string" || scope.trim().length === 0) {
@@ -1134,15 +1138,9 @@ var CORE_SECRET_KEY_ATOMS = [
1134
1138
  "license[-_.]?key"
1135
1139
  ];
1136
1140
  var URL_FORM_SECRET_KEY_ATOMS = [...CORE_SECRET_KEY_ATOMS, "code"];
1137
- var buildKeyBoundaryPattern = (atoms, flags) => new RegExp(
1138
- `(?:^|[^A-Za-z0-9])(?:${atoms.join("|")})(?=[^A-Za-z0-9]|$)`,
1139
- flags
1140
- );
1141
+ var buildKeyBoundaryPattern = (atoms, flags) => new RegExp(`(?:^|[^A-Za-z0-9])(?:${atoms.join("|")})(?=[^A-Za-z0-9]|$)`, flags);
1141
1142
  var SECRET_KEY_PATTERN = buildKeyBoundaryPattern(CORE_SECRET_KEY_ATOMS, "i");
1142
- var URL_FORM_SECRET_KEY_PATTERN = buildKeyBoundaryPattern(
1143
- URL_FORM_SECRET_KEY_ATOMS,
1144
- "i"
1145
- );
1143
+ var URL_FORM_SECRET_KEY_PATTERN = buildKeyBoundaryPattern(URL_FORM_SECRET_KEY_ATOMS, "i");
1146
1144
  var NON_SECRET_KEY_EXACT = /* @__PURE__ */ new Set([
1147
1145
  "token_type",
1148
1146
  "token-type",
@@ -1320,7 +1318,7 @@ var redactStructuredValue = (value, depth = 0) => {
1320
1318
  var maybeParseJson = (text, contentType) => {
1321
1319
  let trimmed = text.trim();
1322
1320
  if (!trimmed) return null;
1323
- if (!contentType?.includes("json") && !/^[\[{]/.test(trimmed)) {
1321
+ if (!contentType?.includes("json") && !/^[[{]/.test(trimmed)) {
1324
1322
  return null;
1325
1323
  }
1326
1324
  try {
@@ -1380,7 +1378,7 @@ var buildUrl = (baseURL, url) => {
1380
1378
  var REDACTED_ENCODED = encodeURIComponent(REDACTED_VALUE);
1381
1379
  var decodeRedactedMarker = (value) => REDACTED_ENCODED === REDACTED_VALUE ? value : value.split(REDACTED_ENCODED).join(REDACTED_VALUE);
1382
1380
  var redactHashFragment = (hash) => {
1383
- if (!hash || !hash.includes("=")) return hash;
1381
+ if (!hash?.includes("=")) return hash;
1384
1382
  let withoutHash = hash.startsWith("#") ? hash.slice(1) : hash;
1385
1383
  let redacted = withoutHash.replace(
1386
1384
  /(?<![A-Za-z0-9])([A-Za-z0-9][A-Za-z0-9_\-.]*)=([^&]*)/g,
@@ -1458,7 +1456,7 @@ var takeTraceDraft = (config2) => {
1458
1456
  var clearTraceDraft = (config2, draft) => {
1459
1457
  if (!config2) return;
1460
1458
  if (config2.__slatesHttpTraceDraft === draft) {
1461
- delete config2.__slatesHttpTraceDraft;
1459
+ config2.__slatesHttpTraceDraft = void 0;
1462
1460
  }
1463
1461
  if (isObjectLike(config2)) {
1464
1462
  traceDraftsByConfig.delete(config2);
package/dist/index.d.cts CHANGED
@@ -50,6 +50,7 @@ declare class SlateLogger {
50
50
  progress(...message: SlateLogMessageInput[]): void;
51
51
  }
52
52
 
53
+ type SlateAuthCallbackConfig = Record<string, any>;
53
54
  type SlateAuthWithOauth<InputType extends {}, OutputType extends {
54
55
  token: string;
55
56
  refreshToken?: string;
@@ -64,6 +65,10 @@ type SlateAuthWithOauth<InputType extends {}, OutputType extends {
64
65
  defaultChecked?: boolean;
65
66
  scope: string;
66
67
  }[];
68
+ docs?: {
69
+ oauthDocsLink?: string;
70
+ oauthScopesLink?: string;
71
+ };
67
72
  inputSchema?: z.ZodType<InputType>;
68
73
  onInputChanged?: (params: {
69
74
  previousInput: InputType | null;
@@ -79,6 +84,7 @@ type SlateAuthWithOauth<InputType extends {}, OutputType extends {
79
84
  clientId: string;
80
85
  clientSecret: string;
81
86
  scopes: string[];
87
+ config?: SlateAuthCallbackConfig;
82
88
  }) => Promise<{
83
89
  url: string;
84
90
  input?: InputType;
@@ -94,6 +100,7 @@ type SlateAuthWithOauth<InputType extends {}, OutputType extends {
94
100
  scopes: string[];
95
101
  callbackParams?: Record<string, string>;
96
102
  callbackState: Record<string, any>;
103
+ config?: SlateAuthCallbackConfig;
97
104
  }) => Promise<{
98
105
  output: OutputType;
99
106
  input?: InputType;
@@ -105,6 +112,7 @@ type SlateAuthWithOauth<InputType extends {}, OutputType extends {
105
112
  clientId: string;
106
113
  clientSecret: string;
107
114
  scopes: string[];
115
+ config?: SlateAuthCallbackConfig;
108
116
  }) => Promise<{
109
117
  output: OutputType;
110
118
  input?: InputType;
@@ -113,6 +121,7 @@ type SlateAuthWithOauth<InputType extends {}, OutputType extends {
113
121
  output: OutputType;
114
122
  input: InputType;
115
123
  scopes: string[];
124
+ config?: SlateAuthCallbackConfig;
116
125
  }) => Promise<{
117
126
  profile: Record<string, any>;
118
127
  }>;
@@ -124,6 +133,9 @@ type SlateAuthWithToken<InputType extends {}, OutputType extends {
124
133
  name: string;
125
134
  key: string;
126
135
  inputSchema?: z.ZodType<InputType>;
136
+ docs?: {
137
+ tokenDocsLink?: string;
138
+ };
127
139
  getOutput: (ctx: {
128
140
  input: InputType;
129
141
  }) => Promise<{
@@ -148,6 +160,9 @@ type SlateAuthWithServiceAccount<InputType extends {}, OutputType extends {}> =
148
160
  name: string;
149
161
  key: string;
150
162
  inputSchema?: z.ZodType<InputType>;
163
+ docs?: {
164
+ serviceAccountDocsLink?: string;
165
+ };
151
166
  getOutput: (ctx: {
152
167
  input: InputType;
153
168
  }) => Promise<{
@@ -172,6 +187,9 @@ type SlateAuthWithCustomData<InputType extends {}, OutputType extends {}> = {
172
187
  name: string;
173
188
  key: string;
174
189
  inputSchema?: z.ZodType<InputType>;
190
+ docs?: {
191
+ customAuthDocsLink?: string;
192
+ };
175
193
  getOutput: (ctx: {
176
194
  input: InputType;
177
195
  }) => Promise<{
@@ -455,15 +473,6 @@ declare abstract class SlateAction<Type extends SlateActionType, ConfigType exte
455
473
  get scopes(): SlateActionScopes | undefined;
456
474
  }
457
475
 
458
- type SlateActionScopeValue = string;
459
- type SlateActionScopeClauseInput = SlateActionScopeValue | readonly SlateActionScopeValue[] | SlateActionScopeClause;
460
- type SlateActionScopesInput = SlateActionScopeClauseInput | SlateActionScopes;
461
- declare let scopeClause: (...scopes: SlateActionScopeValue[]) => SlateActionScopeClause;
462
- declare let anyOf: (...scopes: SlateActionScopeValue[]) => SlateActionScopes;
463
- declare let allOf: (...inputs: SlateActionScopesInput[]) => SlateActionScopes;
464
- declare let mergeScopes: (...inputs: Array<SlateActionScopes | null | undefined | false>) => SlateActionScopes | undefined;
465
- declare let validateScopes: (scopes: SlateActionScopes) => SlateActionScopes;
466
-
467
476
  declare class SlateActionBuilder<Type extends SlateActionType, ConfigType extends {}, AuthType extends {}, InputType extends {}, OutputType extends {}, Result extends SlateAction<Type, ConfigType, AuthType, any, any>> {
468
477
  #private;
469
478
  private readonly type;
@@ -489,6 +498,15 @@ declare class SlateActionBuilder<Type extends SlateActionType, ConfigType extend
489
498
  build(): Result;
490
499
  }
491
500
 
501
+ type SlateActionScopeValue = string;
502
+ type SlateActionScopeClauseInput = SlateActionScopeValue | readonly SlateActionScopeValue[] | SlateActionScopeClause;
503
+ type SlateActionScopesInput = SlateActionScopeClauseInput | SlateActionScopes;
504
+ declare let scopeClause: (...scopes: SlateActionScopeValue[]) => SlateActionScopeClause;
505
+ declare let anyOf: (...scopes: SlateActionScopeValue[]) => SlateActionScopes;
506
+ declare let allOf: (...inputs: SlateActionScopesInput[]) => SlateActionScopes;
507
+ declare let mergeScopes: (...inputs: Array<SlateActionScopes | null | undefined | false>) => SlateActionScopes | undefined;
508
+ declare let validateScopes: (scopes: SlateActionScopes) => SlateActionScopes;
509
+
492
510
  interface SlateToolParameters<ConfigType extends {}, AuthType extends {}, InputType extends {}, OutputType extends {}> extends SlateActionParameters {
493
511
  handleInvocation: SlateToolInvocationHandler<ConfigType, AuthType, InputType, OutputType>;
494
512
  }
@@ -585,7 +603,7 @@ interface SlateErrorInput extends Omit<SlateErrorResponse, 'kind'> {
585
603
  interface SlateAxiosErrorOptions {
586
604
  defaults?: Partial<SlateErrorResponse>;
587
605
  extractResponseData?: (response: AxiosResponse) => unknown;
588
- mapAxiosError?: (error: AxiosError, inferred: SlateErrorResponse) => SlateError | Partial<SlateErrorResponse> | void;
606
+ mapAxiosError?: (error: AxiosError, inferred: SlateErrorResponse) => SlateError | Partial<SlateErrorResponse> | undefined;
589
607
  }
590
608
  interface SlateServiceErrorData {
591
609
  status: number;
package/dist/index.d.ts CHANGED
@@ -50,6 +50,7 @@ declare class SlateLogger {
50
50
  progress(...message: SlateLogMessageInput[]): void;
51
51
  }
52
52
 
53
+ type SlateAuthCallbackConfig = Record<string, any>;
53
54
  type SlateAuthWithOauth<InputType extends {}, OutputType extends {
54
55
  token: string;
55
56
  refreshToken?: string;
@@ -64,6 +65,10 @@ type SlateAuthWithOauth<InputType extends {}, OutputType extends {
64
65
  defaultChecked?: boolean;
65
66
  scope: string;
66
67
  }[];
68
+ docs?: {
69
+ oauthDocsLink?: string;
70
+ oauthScopesLink?: string;
71
+ };
67
72
  inputSchema?: z.ZodType<InputType>;
68
73
  onInputChanged?: (params: {
69
74
  previousInput: InputType | null;
@@ -79,6 +84,7 @@ type SlateAuthWithOauth<InputType extends {}, OutputType extends {
79
84
  clientId: string;
80
85
  clientSecret: string;
81
86
  scopes: string[];
87
+ config?: SlateAuthCallbackConfig;
82
88
  }) => Promise<{
83
89
  url: string;
84
90
  input?: InputType;
@@ -94,6 +100,7 @@ type SlateAuthWithOauth<InputType extends {}, OutputType extends {
94
100
  scopes: string[];
95
101
  callbackParams?: Record<string, string>;
96
102
  callbackState: Record<string, any>;
103
+ config?: SlateAuthCallbackConfig;
97
104
  }) => Promise<{
98
105
  output: OutputType;
99
106
  input?: InputType;
@@ -105,6 +112,7 @@ type SlateAuthWithOauth<InputType extends {}, OutputType extends {
105
112
  clientId: string;
106
113
  clientSecret: string;
107
114
  scopes: string[];
115
+ config?: SlateAuthCallbackConfig;
108
116
  }) => Promise<{
109
117
  output: OutputType;
110
118
  input?: InputType;
@@ -113,6 +121,7 @@ type SlateAuthWithOauth<InputType extends {}, OutputType extends {
113
121
  output: OutputType;
114
122
  input: InputType;
115
123
  scopes: string[];
124
+ config?: SlateAuthCallbackConfig;
116
125
  }) => Promise<{
117
126
  profile: Record<string, any>;
118
127
  }>;
@@ -124,6 +133,9 @@ type SlateAuthWithToken<InputType extends {}, OutputType extends {
124
133
  name: string;
125
134
  key: string;
126
135
  inputSchema?: z.ZodType<InputType>;
136
+ docs?: {
137
+ tokenDocsLink?: string;
138
+ };
127
139
  getOutput: (ctx: {
128
140
  input: InputType;
129
141
  }) => Promise<{
@@ -148,6 +160,9 @@ type SlateAuthWithServiceAccount<InputType extends {}, OutputType extends {}> =
148
160
  name: string;
149
161
  key: string;
150
162
  inputSchema?: z.ZodType<InputType>;
163
+ docs?: {
164
+ serviceAccountDocsLink?: string;
165
+ };
151
166
  getOutput: (ctx: {
152
167
  input: InputType;
153
168
  }) => Promise<{
@@ -172,6 +187,9 @@ type SlateAuthWithCustomData<InputType extends {}, OutputType extends {}> = {
172
187
  name: string;
173
188
  key: string;
174
189
  inputSchema?: z.ZodType<InputType>;
190
+ docs?: {
191
+ customAuthDocsLink?: string;
192
+ };
175
193
  getOutput: (ctx: {
176
194
  input: InputType;
177
195
  }) => Promise<{
@@ -455,15 +473,6 @@ declare abstract class SlateAction<Type extends SlateActionType, ConfigType exte
455
473
  get scopes(): SlateActionScopes | undefined;
456
474
  }
457
475
 
458
- type SlateActionScopeValue = string;
459
- type SlateActionScopeClauseInput = SlateActionScopeValue | readonly SlateActionScopeValue[] | SlateActionScopeClause;
460
- type SlateActionScopesInput = SlateActionScopeClauseInput | SlateActionScopes;
461
- declare let scopeClause: (...scopes: SlateActionScopeValue[]) => SlateActionScopeClause;
462
- declare let anyOf: (...scopes: SlateActionScopeValue[]) => SlateActionScopes;
463
- declare let allOf: (...inputs: SlateActionScopesInput[]) => SlateActionScopes;
464
- declare let mergeScopes: (...inputs: Array<SlateActionScopes | null | undefined | false>) => SlateActionScopes | undefined;
465
- declare let validateScopes: (scopes: SlateActionScopes) => SlateActionScopes;
466
-
467
476
  declare class SlateActionBuilder<Type extends SlateActionType, ConfigType extends {}, AuthType extends {}, InputType extends {}, OutputType extends {}, Result extends SlateAction<Type, ConfigType, AuthType, any, any>> {
468
477
  #private;
469
478
  private readonly type;
@@ -489,6 +498,15 @@ declare class SlateActionBuilder<Type extends SlateActionType, ConfigType extend
489
498
  build(): Result;
490
499
  }
491
500
 
501
+ type SlateActionScopeValue = string;
502
+ type SlateActionScopeClauseInput = SlateActionScopeValue | readonly SlateActionScopeValue[] | SlateActionScopeClause;
503
+ type SlateActionScopesInput = SlateActionScopeClauseInput | SlateActionScopes;
504
+ declare let scopeClause: (...scopes: SlateActionScopeValue[]) => SlateActionScopeClause;
505
+ declare let anyOf: (...scopes: SlateActionScopeValue[]) => SlateActionScopes;
506
+ declare let allOf: (...inputs: SlateActionScopesInput[]) => SlateActionScopes;
507
+ declare let mergeScopes: (...inputs: Array<SlateActionScopes | null | undefined | false>) => SlateActionScopes | undefined;
508
+ declare let validateScopes: (scopes: SlateActionScopes) => SlateActionScopes;
509
+
492
510
  interface SlateToolParameters<ConfigType extends {}, AuthType extends {}, InputType extends {}, OutputType extends {}> extends SlateActionParameters {
493
511
  handleInvocation: SlateToolInvocationHandler<ConfigType, AuthType, InputType, OutputType>;
494
512
  }
@@ -585,7 +603,7 @@ interface SlateErrorInput extends Omit<SlateErrorResponse, 'kind'> {
585
603
  interface SlateAxiosErrorOptions {
586
604
  defaults?: Partial<SlateErrorResponse>;
587
605
  extractResponseData?: (response: AxiosResponse) => unknown;
588
- mapAxiosError?: (error: AxiosError, inferred: SlateErrorResponse) => SlateError | Partial<SlateErrorResponse> | void;
606
+ mapAxiosError?: (error: AxiosError, inferred: SlateErrorResponse) => SlateError | Partial<SlateErrorResponse> | undefined;
589
607
  }
590
608
  interface SlateServiceErrorData {
591
609
  status: number;
@@ -162,7 +162,7 @@ var normalizeRetryable = (code, retryable) => {
162
162
  return code === "request.rate_limited" || code === "upstream.rate_limited" || code === "upstream.timeout" || code === "upstream.network_error" || code === "upstream.unavailable" || code === "upstream.error" || code === "transport.invoke_failed" || code === "internal.timeout";
163
163
  };
164
164
  var getDefaultMessage = (code, message) => {
165
- if (message && message.trim()) return message;
165
+ if (message?.trim()) return message;
166
166
  return DEFAULT_MESSAGES[code] ?? DEFAULT_MESSAGES[DEFAULT_CODE];
167
167
  };
168
168
  var cleanRecord = (value) => {
@@ -439,7 +439,9 @@ var normalizeServiceErrorIssues = (errors) => {
439
439
  return issues.length > 0 ? issues : void 0;
440
440
  };
441
441
  var getServiceErrorBaggage = (data) => {
442
- let extraEntries = Object.entries(data).filter(([key]) => !SERVICE_ERROR_DATA_RESERVED_KEYS.has(key));
442
+ let extraEntries = Object.entries(data).filter(
443
+ ([key]) => !SERVICE_ERROR_DATA_RESERVED_KEYS.has(key)
444
+ );
443
445
  return cleanRecord({
444
446
  serviceError: {
445
447
  code: data.code,
@@ -657,7 +659,9 @@ var normalizeClause = (input) => {
657
659
  };
658
660
  var assertScopeValues = (scopes) => {
659
661
  if (scopes.length === 0) {
660
- throw new SlateDeclarationError("Each action scope clause must include at least one OR scope");
662
+ throw new SlateDeclarationError(
663
+ "Each action scope clause must include at least one OR scope"
664
+ );
661
665
  }
662
666
  for (let scope of scopes) {
663
667
  if (typeof scope !== "string" || scope.trim().length === 0) {
@@ -1063,15 +1067,9 @@ var CORE_SECRET_KEY_ATOMS = [
1063
1067
  "license[-_.]?key"
1064
1068
  ];
1065
1069
  var URL_FORM_SECRET_KEY_ATOMS = [...CORE_SECRET_KEY_ATOMS, "code"];
1066
- var buildKeyBoundaryPattern = (atoms, flags) => new RegExp(
1067
- `(?:^|[^A-Za-z0-9])(?:${atoms.join("|")})(?=[^A-Za-z0-9]|$)`,
1068
- flags
1069
- );
1070
+ var buildKeyBoundaryPattern = (atoms, flags) => new RegExp(`(?:^|[^A-Za-z0-9])(?:${atoms.join("|")})(?=[^A-Za-z0-9]|$)`, flags);
1070
1071
  var SECRET_KEY_PATTERN = buildKeyBoundaryPattern(CORE_SECRET_KEY_ATOMS, "i");
1071
- var URL_FORM_SECRET_KEY_PATTERN = buildKeyBoundaryPattern(
1072
- URL_FORM_SECRET_KEY_ATOMS,
1073
- "i"
1074
- );
1072
+ var URL_FORM_SECRET_KEY_PATTERN = buildKeyBoundaryPattern(URL_FORM_SECRET_KEY_ATOMS, "i");
1075
1073
  var NON_SECRET_KEY_EXACT = /* @__PURE__ */ new Set([
1076
1074
  "token_type",
1077
1075
  "token-type",
@@ -1249,7 +1247,7 @@ var redactStructuredValue = (value, depth = 0) => {
1249
1247
  var maybeParseJson = (text, contentType) => {
1250
1248
  let trimmed = text.trim();
1251
1249
  if (!trimmed) return null;
1252
- if (!contentType?.includes("json") && !/^[\[{]/.test(trimmed)) {
1250
+ if (!contentType?.includes("json") && !/^[[{]/.test(trimmed)) {
1253
1251
  return null;
1254
1252
  }
1255
1253
  try {
@@ -1309,7 +1307,7 @@ var buildUrl = (baseURL, url) => {
1309
1307
  var REDACTED_ENCODED = encodeURIComponent(REDACTED_VALUE);
1310
1308
  var decodeRedactedMarker = (value) => REDACTED_ENCODED === REDACTED_VALUE ? value : value.split(REDACTED_ENCODED).join(REDACTED_VALUE);
1311
1309
  var redactHashFragment = (hash) => {
1312
- if (!hash || !hash.includes("=")) return hash;
1310
+ if (!hash?.includes("=")) return hash;
1313
1311
  let withoutHash = hash.startsWith("#") ? hash.slice(1) : hash;
1314
1312
  let redacted = withoutHash.replace(
1315
1313
  /(?<![A-Za-z0-9])([A-Za-z0-9][A-Za-z0-9_\-.]*)=([^&]*)/g,
@@ -1387,7 +1385,7 @@ var takeTraceDraft = (config2) => {
1387
1385
  var clearTraceDraft = (config2, draft) => {
1388
1386
  if (!config2) return;
1389
1387
  if (config2.__slatesHttpTraceDraft === draft) {
1390
- delete config2.__slatesHttpTraceDraft;
1388
+ config2.__slatesHttpTraceDraft = void 0;
1391
1389
  }
1392
1390
  if (isObjectLike(config2)) {
1393
1391
  traceDraftsByConfig.delete(config2);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@slates/provider",
3
- "version": "1.0.0-rc.12",
3
+ "version": "1.0.0-rc.14",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -26,9 +26,9 @@
26
26
  "unpkg": "./dist/index.module.js",
27
27
  "scripts": {
28
28
  "test": "vitest run --passWithNoTests",
29
- "lint": "prettier src/**/*.ts --check",
30
29
  "build": "tsup --config ../../tsup.packages.config.ts --external async_hooks",
31
- "typecheck": "tsc --noEmit"
30
+ "typecheck": "tsc --noEmit",
31
+ "biome:check": "biome check --write src"
32
32
  },
33
33
  "dependencies": {
34
34
  "@lowerdeck/error": "^1.1.0",
@@ -4,10 +4,10 @@ import type { SlateSpecification } from '../specification/specification';
4
4
  import type {
5
5
  SlateAction,
6
6
  SlateActionCreateParameters,
7
- SlateActionScopes,
8
7
  SlateActionParameters,
9
8
  SlateActionParametersTool,
10
9
  SlateActionParametersTrigger,
10
+ SlateActionScopes,
11
11
  SlateActionType,
12
12
  SlatePollingOptions,
13
13
  SlateToolInvocationHandler,
@@ -1,5 +1,5 @@
1
1
  export * from './action';
2
- export * from './scopes';
3
2
  export type * from './builder';
3
+ export * from './scopes';
4
4
  export * from './tool';
5
5
  export * from './trigger';
@@ -12,10 +12,7 @@ describe('action scope helpers', () => {
12
12
  });
13
13
 
14
14
  expect(allOf(['scope:calendar'], ['scope:sharing', 'scope:sharing:admin'])).toEqual({
15
- AND: [
16
- { OR: ['scope:calendar'] },
17
- { OR: ['scope:sharing', 'scope:sharing:admin'] }
18
- ]
15
+ AND: [{ OR: ['scope:calendar'] }, { OR: ['scope:sharing', 'scope:sharing:admin'] }]
19
16
  });
20
17
  });
21
18
 
@@ -68,7 +65,9 @@ describe('action scope helpers', () => {
68
65
  });
69
66
 
70
67
  it('throws helpful errors for invalid scope definitions', () => {
71
- expect(() => scopeClause()).toThrow('Each action scope clause must include at least one OR scope');
68
+ expect(() => scopeClause()).toThrow(
69
+ 'Each action scope clause must include at least one OR scope'
70
+ );
72
71
  expect(() => scopeClause('')).toThrow('Action scopes must be non-empty strings');
73
72
  expect(() => validateScopes({ AND: [] })).toThrow(
74
73
  'Action scopes must include at least one AND clause'
@@ -78,7 +78,9 @@ let normalizeClause = (input: SlateActionScopeClauseInput): SlateActionScopeClau
78
78
 
79
79
  let assertScopeValues = (scopes: readonly SlateActionScopeValue[]) => {
80
80
  if (scopes.length === 0) {
81
- throw new SlateDeclarationError('Each action scope clause must include at least one OR scope');
81
+ throw new SlateDeclarationError(
82
+ 'Each action scope clause must include at least one OR scope'
83
+ );
82
84
  }
83
85
 
84
86
  for (let scope of scopes) {
package/src/auth/types.ts CHANGED
@@ -1,5 +1,7 @@
1
1
  import type z from 'zod';
2
2
 
3
+ type SlateAuthCallbackConfig = Record<string, any>;
4
+
3
5
  export type SlateAuthWithOauth<
4
6
  InputType extends {},
5
7
  OutputType extends {
@@ -20,6 +22,11 @@ export type SlateAuthWithOauth<
20
22
  scope: string;
21
23
  }[];
22
24
 
25
+ docs?: {
26
+ oauthDocsLink?: string;
27
+ oauthScopesLink?: string;
28
+ };
29
+
23
30
  inputSchema?: z.ZodType<InputType>;
24
31
 
25
32
  onInputChanged?: (params: {
@@ -36,6 +43,7 @@ export type SlateAuthWithOauth<
36
43
  clientId: string;
37
44
  clientSecret: string;
38
45
  scopes: string[];
46
+ config?: SlateAuthCallbackConfig;
39
47
  }) => Promise<{
40
48
  url: string;
41
49
  input?: InputType;
@@ -52,6 +60,7 @@ export type SlateAuthWithOauth<
52
60
  scopes: string[];
53
61
  callbackParams?: Record<string, string>;
54
62
  callbackState: Record<string, any>;
63
+ config?: SlateAuthCallbackConfig;
55
64
  }) => Promise<{
56
65
  output: OutputType;
57
66
  input?: InputType;
@@ -64,12 +73,18 @@ export type SlateAuthWithOauth<
64
73
  clientId: string;
65
74
  clientSecret: string;
66
75
  scopes: string[];
76
+ config?: SlateAuthCallbackConfig;
67
77
  }) => Promise<{
68
78
  output: OutputType;
69
79
  input?: InputType;
70
80
  }>;
71
81
 
72
- getProfile?: (ctx: { output: OutputType; input: InputType; scopes: string[] }) => Promise<{
82
+ getProfile?: (ctx: {
83
+ output: OutputType;
84
+ input: InputType;
85
+ scopes: string[];
86
+ config?: SlateAuthCallbackConfig;
87
+ }) => Promise<{
73
88
  profile: Record<string, any>;
74
89
  }>;
75
90
  };
@@ -82,6 +97,10 @@ export type SlateAuthWithToken<InputType extends {}, OutputType extends { token?
82
97
 
83
98
  inputSchema?: z.ZodType<InputType>;
84
99
 
100
+ docs?: {
101
+ tokenDocsLink?: string;
102
+ };
103
+
85
104
  getOutput: (ctx: { input: InputType }) => Promise<{ output: OutputType }>;
86
105
 
87
106
  onInputChanged?: (params: {
@@ -104,6 +123,10 @@ export type SlateAuthWithServiceAccount<InputType extends {}, OutputType extends
104
123
 
105
124
  inputSchema?: z.ZodType<InputType>;
106
125
 
126
+ docs?: {
127
+ serviceAccountDocsLink?: string;
128
+ };
129
+
107
130
  getOutput: (ctx: { input: InputType }) => Promise<{ output: OutputType }>;
108
131
 
109
132
  onInputChanged?: (params: {
@@ -126,6 +149,10 @@ export type SlateAuthWithCustomData<InputType extends {}, OutputType extends {}>
126
149
 
127
150
  inputSchema?: z.ZodType<InputType>;
128
151
 
152
+ docs?: {
153
+ customAuthDocsLink?: string;
154
+ };
155
+
129
156
  getOutput: (ctx: { input: InputType }) => Promise<{ output: OutputType }>;
130
157
 
131
158
  handleTokenRefresh?: (ctx: {
@@ -19,7 +19,7 @@ let applySlateInterceptors = (
19
19
  ) => {
20
20
  instance.interceptors.request.use(
21
21
  request => {
22
- // Has to be called in the context of an action execution
22
+ // Has to be called in the context of an action execution
23
23
  let ctx = getCurrentContext();
24
24
  let spec = ctx.specification;
25
25
  let providerToken = spec.key.replace(/[^A-Za-z0-9!#$%&'*+\-.^_`|~]/g, '-');
@@ -174,7 +174,7 @@ describe('sanitizeFreeText', () => {
174
174
  });
175
175
 
176
176
  it('redacts GitHub tokens', () => {
177
- let token = 'ghp_' + 'a'.repeat(40);
177
+ let token = `ghp_${'a'.repeat(40)}`;
178
178
  expect(sanitizeFreeText(token)).toBe('[redacted]');
179
179
  });
180
180
 
@@ -184,22 +184,22 @@ describe('sanitizeFreeText', () => {
184
184
  });
185
185
 
186
186
  it('redacts Stripe secret keys', () => {
187
- let key = 'sk_live_' + 'a'.repeat(24);
187
+ let key = `sk_live_${'a'.repeat(24)}`;
188
188
  expect(sanitizeFreeText(`{"key":"${key}"}`)).not.toContain(key);
189
189
  });
190
190
 
191
191
  it('redacts OpenAI API keys', () => {
192
- let key = 'sk-proj-' + 'a'.repeat(40);
192
+ let key = `sk-proj-${'a'.repeat(40)}`;
193
193
  expect(sanitizeFreeText(key)).toBe('[redacted]');
194
194
  });
195
195
 
196
196
  it('redacts Anthropic API keys', () => {
197
- let key = 'sk-ant-' + 'a'.repeat(40);
197
+ let key = `sk-ant-${'a'.repeat(40)}`;
198
198
  expect(sanitizeFreeText(key)).toBe('[redacted]');
199
199
  });
200
200
 
201
201
  it('redacts Google API keys', () => {
202
- let key = 'AIza' + 'a'.repeat(35);
202
+ let key = `AIza${'a'.repeat(35)}`;
203
203
  expect(sanitizeFreeText(key)).toBe('[redacted]');
204
204
  });
205
205
 
@@ -265,8 +265,7 @@ describe('sanitizeUrl', () => {
265
265
  });
266
266
 
267
267
  it('redacts secrets embedded in URL fragment (OAuth implicit flow)', () => {
268
- let input =
269
- 'https://example.com/cb#access_token=xyz&token_type=bearer&expires_in=3600';
268
+ let input = 'https://example.com/cb#access_token=xyz&token_type=bearer&expires_in=3600';
270
269
  let out = sanitizeUrl(input);
271
270
  expect(out).toContain('access_token=[redacted]');
272
271
  expect(out).toContain('token_type=bearer');
@@ -205,16 +205,10 @@ let CORE_SECRET_KEY_ATOMS = [
205
205
  let URL_FORM_SECRET_KEY_ATOMS = [...CORE_SECRET_KEY_ATOMS, 'code'];
206
206
 
207
207
  let buildKeyBoundaryPattern = (atoms: string[], flags: string) =>
208
- new RegExp(
209
- `(?:^|[^A-Za-z0-9])(?:${atoms.join('|')})(?=[^A-Za-z0-9]|$)`,
210
- flags
211
- );
208
+ new RegExp(`(?:^|[^A-Za-z0-9])(?:${atoms.join('|')})(?=[^A-Za-z0-9]|$)`, flags);
212
209
 
213
210
  let SECRET_KEY_PATTERN = buildKeyBoundaryPattern(CORE_SECRET_KEY_ATOMS, 'i');
214
- let URL_FORM_SECRET_KEY_PATTERN = buildKeyBoundaryPattern(
215
- URL_FORM_SECRET_KEY_ATOMS,
216
- 'i'
217
- );
211
+ let URL_FORM_SECRET_KEY_PATTERN = buildKeyBoundaryPattern(URL_FORM_SECRET_KEY_ATOMS, 'i');
218
212
 
219
213
  // Explicit non-secret keys that would otherwise trip the patterns above because
220
214
  // they embed a secret-sounding token (e.g. `token_type` contains `token`).
@@ -307,7 +301,8 @@ let HTTP_AUTH_SCHEME_PATTERN =
307
301
 
308
302
  // Generic `key=value` scan; the key is filtered via isUrlFormSecretKeyName at replace time
309
303
  // so we can apply a deny-list for compound keys like `token_type` or `grant_type`.
310
- let GENERIC_KEY_VALUE_PATTERN = /(?<![A-Za-z0-9])([A-Za-z0-9][A-Za-z0-9_\-.]*)(\s*=\s*)([^&#\s;]+)/g;
304
+ let GENERIC_KEY_VALUE_PATTERN =
305
+ /(?<![A-Za-z0-9])([A-Za-z0-9][A-Za-z0-9_\-.]*)(\s*=\s*)([^&#\s;]+)/g;
311
306
 
312
307
  // Generic `"key": "value"` scan; the key is filtered via isSecretKeyName at replace time.
313
308
  let GENERIC_JSON_KEY_VALUE_PATTERN =
@@ -438,9 +433,7 @@ let redactStructuredValue = (value: unknown, depth = 0): unknown => {
438
433
  .slice(0, STRUCTURED_ENTRY_LIMIT)
439
434
  .map(([key, entry]) => [
440
435
  key,
441
- isSecretKeyName(key)
442
- ? REDACTED_VALUE
443
- : redactStructuredValue(entry, depth + 1)
436
+ isSecretKeyName(key) ? REDACTED_VALUE : redactStructuredValue(entry, depth + 1)
444
437
  ])
445
438
  );
446
439
  }
@@ -451,7 +444,7 @@ let redactStructuredValue = (value: unknown, depth = 0): unknown => {
451
444
  let maybeParseJson = (text: string, contentType?: string) => {
452
445
  let trimmed = text.trim();
453
446
  if (!trimmed) return null;
454
- if (!contentType?.includes('json') && !/^[\[{]/.test(trimmed)) {
447
+ if (!contentType?.includes('json') && !/^[[{]/.test(trimmed)) {
455
448
  return null;
456
449
  }
457
450
 
@@ -541,7 +534,7 @@ let decodeRedactedMarker = (value: string) =>
541
534
  : value.split(REDACTED_ENCODED).join(REDACTED_VALUE);
542
535
 
543
536
  let redactHashFragment = (hash: string) => {
544
- if (!hash || !hash.includes('=')) return hash;
537
+ if (!hash?.includes('=')) return hash;
545
538
  let withoutHash = hash.startsWith('#') ? hash.slice(1) : hash;
546
539
  let redacted = withoutHash.replace(
547
540
  /(?<![A-Za-z0-9])([A-Za-z0-9][A-Za-z0-9_\-.]*)=([^&]*)/g,
@@ -657,7 +650,7 @@ let clearTraceDraft = (
657
650
  if (!config) return;
658
651
 
659
652
  if (config.__slatesHttpTraceDraft === draft) {
660
- delete config.__slatesHttpTraceDraft;
653
+ config.__slatesHttpTraceDraft = undefined;
661
654
  }
662
655
 
663
656
  if (isObjectLike(config)) {
@@ -6,13 +6,19 @@ describe('slate context hook', () => {
6
6
  it('shares context storage across duplicate module instances', async () => {
7
7
  // @ts-expect-error Vite treats the query as a distinct module instance.
8
8
  let duplicateHook: typeof import('./hook') = await import('./hook?duplicate-instance');
9
- let context = new SlateContext({}, {}, {}, {} as any, {
10
- debug: () => {},
11
- error: () => {},
12
- info: () => {},
13
- progress: () => {},
14
- warn: () => {}
15
- } as any);
9
+ let context = new SlateContext(
10
+ {},
11
+ {},
12
+ {},
13
+ {} as any,
14
+ {
15
+ debug: () => {},
16
+ error: () => {},
17
+ info: () => {},
18
+ progress: () => {},
19
+ warn: () => {}
20
+ } as any
21
+ );
16
22
 
17
23
  let result = await runWithContext(context, async () => duplicateHook.getCurrentContext());
18
24
 
@@ -1,8 +1,14 @@
1
- import { isServiceError } from '@lowerdeck/error';
2
1
  import type { ErrorData, ErrorRecord, ServiceError } from '@lowerdeck/error';
2
+ import { isServiceError } from '@lowerdeck/error';
3
3
  import { DEFAULT_CODE, SERVICE_ERROR_CODE_MAP } from './defaults';
4
4
  import type { SlateErrorInput, SlateErrorIssue, SlateServiceErrorData } from './types';
5
- import { cleanRecord, isRecord, normalizeKind, normalizeRetryable, sanitizeForBaggage } from './utils';
5
+ import {
6
+ cleanRecord,
7
+ isRecord,
8
+ normalizeKind,
9
+ normalizeRetryable,
10
+ sanitizeForBaggage
11
+ } from './utils';
6
12
 
7
13
  let SERVICE_ERROR_DATA_RESERVED_KEYS = new Set([
8
14
  'status',
@@ -46,9 +52,7 @@ let normalizeServiceErrorIssues = (errors: unknown): SlateErrorIssue[] | undefin
46
52
  };
47
53
  }
48
54
 
49
- let path = Array.isArray(error.path)
50
- ? error.path.map(entry => String(entry))
51
- : undefined;
55
+ let path = Array.isArray(error.path) ? error.path.map(entry => String(entry)) : undefined;
52
56
 
53
57
  return {
54
58
  ...error,
@@ -67,7 +71,9 @@ let normalizeServiceErrorIssues = (errors: unknown): SlateErrorIssue[] | undefin
67
71
  };
68
72
 
69
73
  let getServiceErrorBaggage = (data: SlateServiceErrorData) => {
70
- let extraEntries = Object.entries(data).filter(([key]) => !SERVICE_ERROR_DATA_RESERVED_KEYS.has(key));
74
+ let extraEntries = Object.entries(data).filter(
75
+ ([key]) => !SERVICE_ERROR_DATA_RESERVED_KEYS.has(key)
76
+ );
71
77
 
72
78
  return cleanRecord({
73
79
  serviceError: {
@@ -111,7 +117,11 @@ export let getServiceErrorData = (error: unknown): SlateServiceErrorData | null
111
117
  return error.data;
112
118
  }
113
119
 
114
- if (isStructuredValue(error) && 'toResponse' in error && typeof error.toResponse === 'function') {
120
+ if (
121
+ isStructuredValue(error) &&
122
+ 'toResponse' in error &&
123
+ typeof error.toResponse === 'function'
124
+ ) {
115
125
  let response = error.toResponse();
116
126
  return isServiceErrorData(response) ? response : null;
117
127
  }
@@ -60,7 +60,7 @@ export interface SlateAxiosErrorOptions {
60
60
  mapAxiosError?: (
61
61
  error: AxiosError,
62
62
  inferred: SlateErrorResponse
63
- ) => SlateError | Partial<SlateErrorResponse> | void;
63
+ ) => SlateError | Partial<SlateErrorResponse> | undefined;
64
64
  }
65
65
 
66
66
  export interface SlateServiceErrorData {
@@ -62,7 +62,7 @@ export let normalizeRetryable = (code: string, retryable?: boolean) => {
62
62
  };
63
63
 
64
64
  export let getDefaultMessage = (code: string, message?: string) => {
65
- if (message && message.trim()) return message;
65
+ if (message?.trim()) return message;
66
66
  return DEFAULT_MESSAGES[code] ?? DEFAULT_MESSAGES[DEFAULT_CODE];
67
67
  };
68
68
 
@@ -1,5 +1,5 @@
1
1
  import { describe, expect, it } from 'vitest';
2
- import { SlateLogger, type SlateLogEntry } from './logger';
2
+ import { type SlateLogEntry, SlateLogger } from './logger';
3
3
 
4
4
  let flushLogs = async () => {
5
5
  await new Promise(resolve => setTimeout(resolve, 20));
@@ -9,10 +9,8 @@ export interface SlateSpecificationParameters {
9
9
  metadata?: Record<string, any>;
10
10
  }
11
11
 
12
- export interface SlateSpecificationCreateParameters<
13
- ConfigType extends {},
14
- AuthType extends {}
15
- > extends SlateSpecificationParameters {
12
+ export interface SlateSpecificationCreateParameters<ConfigType extends {}, AuthType extends {}>
13
+ extends SlateSpecificationParameters {
16
14
  config: SlateConfig<ConfigType>;
17
15
  auth: SlateAuth<AuthType>;
18
16
  }