@slates/client 1.0.0-rc.14 → 1.0.0-rc.16

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
@@ -237,7 +237,9 @@ var SlatesProtocolClient = class {
237
237
  }
238
238
  async listTools() {
239
239
  let result = await this.listActions();
240
- return result.actions.filter((action) => action.type === "action.tool");
240
+ return result.actions.filter(
241
+ (action) => action.type === "action.tool"
242
+ );
241
243
  }
242
244
  async listTriggers() {
243
245
  let result = await this.listActions();
package/dist/index.d.cts CHANGED
@@ -1,4 +1,4 @@
1
- import { SlatesProtocolVersion, SlatesParticipant, SlatesNotifications, SlatesRequests, SlatesResponses, SlatesResponsesByMethod, SlatesMessageProviderIdentifyResponse, SlatesMessageActionsListResponse, SlatesAction, SlatesMessageActionGetResponse, SlatesMessageConfigSchemaGetResponse, SlatesMessageConfigDefaultGetResponse, SlatesMessageConfigChangedResponse, SlateAuthenticationMethod, SlatesMessageAuthMethodGetResponse, SlatesMessageAuthDefaultInputGetResponse, SlatesMessageAuthInputChangedResponse, SlatesMessageAuthOutputGetResponse, SlatesMessageAuthAuthorizationUrlGetResponse, SlatesMessageAuthTokenRefreshHandleResponse, SlatesMessageAuthProfileGetResponse, SlatesMessageActionInvokeResponse, SlatesMessageActionTriggerEventMapResponse, SlatesMessageActionTriggerWebhookRegisterResponse, SlatesMessageActionTriggerWebhookHandleResponse, SlatesMessageActionTriggerWebhookUnregisterResponse } from '@slates/proto';
1
+ import { SlatesProtocolVersion, SlatesParticipant, SlatesNotifications, SlatesRequests, SlatesResponses, SlatesResponsesByMethod, SlatesMessageProviderIdentifyResponse, SlatesMessageActionsListResponse, SlatesActionTool, SlatesAction, SlatesMessageActionGetResponse, SlatesMessageConfigSchemaGetResponse, SlatesMessageConfigDefaultGetResponse, SlatesMessageConfigChangedResponse, SlateAuthenticationMethod, SlatesMessageAuthMethodGetResponse, SlatesMessageAuthDefaultInputGetResponse, SlatesMessageAuthInputChangedResponse, SlatesMessageAuthOutputGetResponse, SlatesMessageAuthAuthorizationUrlGetResponse, SlatesMessageAuthTokenRefreshHandleResponse, SlatesMessageAuthProfileGetResponse, SlatesMessageActionInvokeResponse, SlatesMessageActionTriggerEventMapResponse, SlatesMessageActionTriggerWebhookRegisterResponse, SlatesMessageActionTriggerWebhookHandleResponse, SlatesMessageActionTriggerWebhookUnregisterResponse } from '@slates/proto';
2
2
  import { Slate, SlateLogListener } from '@slates/provider';
3
3
 
4
4
  type SlatesJsonObject = Record<string, any>;
@@ -46,7 +46,7 @@ declare class SlatesProtocolClient {
46
46
  }>['params']): Promise<SlatesResponsesByMethod[Key]['result']>;
47
47
  identify(): Promise<SlatesMessageProviderIdentifyResponse['result']>;
48
48
  listActions(): Promise<SlatesMessageActionsListResponse['result']>;
49
- listTools(): Promise<SlatesAction[]>;
49
+ listTools(): Promise<SlatesActionTool[]>;
50
50
  listTriggers(): Promise<SlatesAction[]>;
51
51
  getAction(actionId: string): Promise<SlatesMessageActionGetResponse['result']>;
52
52
  getTool(actionId: string): Promise<{
@@ -61,6 +61,7 @@ declare class SlatesProtocolClient {
61
61
  }[];
62
62
  type: "action.tool";
63
63
  capabilities: Record<string, never>;
64
+ isPublic: boolean;
64
65
  description?: string | undefined;
65
66
  instructions?: string[] | undefined;
66
67
  constraints?: string[] | undefined;
@@ -75,6 +76,7 @@ declare class SlatesProtocolClient {
75
76
  }[];
76
77
  } | undefined;
77
78
  authMethods?: string[] | undefined;
79
+ adapter?: string | null | undefined;
78
80
  }>;
79
81
  getTrigger(actionId: string): Promise<{
80
82
  id: string;
@@ -130,6 +132,7 @@ declare class SlatesProtocolClient {
130
132
  }[];
131
133
  } | undefined;
132
134
  authMethods?: string[] | undefined;
135
+ adapter?: string | null | undefined;
133
136
  }>;
134
137
  getConfigSchema(): Promise<SlatesMessageConfigSchemaGetResponse['result']>;
135
138
  getDefaultConfig(): Promise<SlatesMessageConfigDefaultGetResponse['result']>;
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { SlatesProtocolVersion, SlatesParticipant, SlatesNotifications, SlatesRequests, SlatesResponses, SlatesResponsesByMethod, SlatesMessageProviderIdentifyResponse, SlatesMessageActionsListResponse, SlatesAction, SlatesMessageActionGetResponse, SlatesMessageConfigSchemaGetResponse, SlatesMessageConfigDefaultGetResponse, SlatesMessageConfigChangedResponse, SlateAuthenticationMethod, SlatesMessageAuthMethodGetResponse, SlatesMessageAuthDefaultInputGetResponse, SlatesMessageAuthInputChangedResponse, SlatesMessageAuthOutputGetResponse, SlatesMessageAuthAuthorizationUrlGetResponse, SlatesMessageAuthTokenRefreshHandleResponse, SlatesMessageAuthProfileGetResponse, SlatesMessageActionInvokeResponse, SlatesMessageActionTriggerEventMapResponse, SlatesMessageActionTriggerWebhookRegisterResponse, SlatesMessageActionTriggerWebhookHandleResponse, SlatesMessageActionTriggerWebhookUnregisterResponse } from '@slates/proto';
1
+ import { SlatesProtocolVersion, SlatesParticipant, SlatesNotifications, SlatesRequests, SlatesResponses, SlatesResponsesByMethod, SlatesMessageProviderIdentifyResponse, SlatesMessageActionsListResponse, SlatesActionTool, SlatesAction, SlatesMessageActionGetResponse, SlatesMessageConfigSchemaGetResponse, SlatesMessageConfigDefaultGetResponse, SlatesMessageConfigChangedResponse, SlateAuthenticationMethod, SlatesMessageAuthMethodGetResponse, SlatesMessageAuthDefaultInputGetResponse, SlatesMessageAuthInputChangedResponse, SlatesMessageAuthOutputGetResponse, SlatesMessageAuthAuthorizationUrlGetResponse, SlatesMessageAuthTokenRefreshHandleResponse, SlatesMessageAuthProfileGetResponse, SlatesMessageActionInvokeResponse, SlatesMessageActionTriggerEventMapResponse, SlatesMessageActionTriggerWebhookRegisterResponse, SlatesMessageActionTriggerWebhookHandleResponse, SlatesMessageActionTriggerWebhookUnregisterResponse } from '@slates/proto';
2
2
  import { Slate, SlateLogListener } from '@slates/provider';
3
3
 
4
4
  type SlatesJsonObject = Record<string, any>;
@@ -46,7 +46,7 @@ declare class SlatesProtocolClient {
46
46
  }>['params']): Promise<SlatesResponsesByMethod[Key]['result']>;
47
47
  identify(): Promise<SlatesMessageProviderIdentifyResponse['result']>;
48
48
  listActions(): Promise<SlatesMessageActionsListResponse['result']>;
49
- listTools(): Promise<SlatesAction[]>;
49
+ listTools(): Promise<SlatesActionTool[]>;
50
50
  listTriggers(): Promise<SlatesAction[]>;
51
51
  getAction(actionId: string): Promise<SlatesMessageActionGetResponse['result']>;
52
52
  getTool(actionId: string): Promise<{
@@ -61,6 +61,7 @@ declare class SlatesProtocolClient {
61
61
  }[];
62
62
  type: "action.tool";
63
63
  capabilities: Record<string, never>;
64
+ isPublic: boolean;
64
65
  description?: string | undefined;
65
66
  instructions?: string[] | undefined;
66
67
  constraints?: string[] | undefined;
@@ -75,6 +76,7 @@ declare class SlatesProtocolClient {
75
76
  }[];
76
77
  } | undefined;
77
78
  authMethods?: string[] | undefined;
79
+ adapter?: string | null | undefined;
78
80
  }>;
79
81
  getTrigger(actionId: string): Promise<{
80
82
  id: string;
@@ -130,6 +132,7 @@ declare class SlatesProtocolClient {
130
132
  }[];
131
133
  } | undefined;
132
134
  authMethods?: string[] | undefined;
135
+ adapter?: string | null | undefined;
133
136
  }>;
134
137
  getConfigSchema(): Promise<SlatesMessageConfigSchemaGetResponse['result']>;
135
138
  getDefaultConfig(): Promise<SlatesMessageConfigDefaultGetResponse['result']>;
@@ -210,7 +210,9 @@ var SlatesProtocolClient = class {
210
210
  }
211
211
  async listTools() {
212
212
  let result = await this.listActions();
213
- return result.actions.filter((action) => action.type === "action.tool");
213
+ return result.actions.filter(
214
+ (action) => action.type === "action.tool"
215
+ );
214
216
  }
215
217
  async listTriggers() {
216
218
  let result = await this.listActions();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@slates/client",
3
- "version": "1.0.0-rc.14",
3
+ "version": "1.0.0-rc.16",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -31,9 +31,9 @@
31
31
  "biome:check": "biome check --write src"
32
32
  },
33
33
  "dependencies": {
34
- "@slates/proto": "1.0.0-rc.13",
35
- "@slates/provider": "1.0.0-rc.17",
36
- "@slates/provider-handler": "1.0.0-rc.19"
34
+ "@slates/proto": "1.0.0-rc.14",
35
+ "@slates/provider": "1.0.0-rc.18",
36
+ "@slates/provider-handler": "1.0.0-rc.21"
37
37
  },
38
38
  "devDependencies": {
39
39
  "@slates/tsconfig": "1.0.0-rc.1",
@@ -4,6 +4,7 @@ import {
4
4
  SlateAuth,
5
5
  SlateConfig,
6
6
  type SlateLogEntry,
7
+ SlatePublicTool,
7
8
  SlateSpecification,
8
9
  SlateTool,
9
10
  SlateTrigger
@@ -547,6 +548,7 @@ describe('@slates/client local transport', () => {
547
548
  ]
548
549
  });
549
550
  expect(actions[0]!.authMethods).toEqual(['token_auth']);
551
+ expect(actions[0]!.isPublic).toBe(false);
550
552
 
551
553
  let configSchema = await client.getConfigSchema();
552
554
  expect(configSchema.schema.properties.prefix.type).toBe('string');
@@ -1039,4 +1041,114 @@ describe('@slates/client local transport', () => {
1039
1041
  });
1040
1042
  }
1041
1043
  });
1044
+
1045
+ it('lists, gets, and invokes public tools without config or auth', async () => {
1046
+ let config = SlateConfig.create(
1047
+ z.object({
1048
+ prefix: z.string()
1049
+ })
1050
+ );
1051
+ let auth = SlateAuth.create<{ token: string }>()
1052
+ .output(
1053
+ z.object({
1054
+ token: z.string()
1055
+ })
1056
+ )
1057
+ .addTokenAuth({
1058
+ type: 'auth.token',
1059
+ key: 'token_auth',
1060
+ name: 'Token Auth',
1061
+ inputSchema: z.object({
1062
+ token: z.string()
1063
+ }),
1064
+ getOutput: async ctx => ({
1065
+ output: {
1066
+ token: ctx.input.token
1067
+ }
1068
+ })
1069
+ });
1070
+
1071
+ let spec = SlateSpecification.create({
1072
+ key: 'public-tool-slate',
1073
+ name: 'Public Tool Slate',
1074
+ config,
1075
+ auth
1076
+ });
1077
+
1078
+ let echoTool = SlateTool.create(spec, {
1079
+ key: 'echo',
1080
+ name: 'Echo'
1081
+ })
1082
+ .input(
1083
+ z.object({
1084
+ name: z.string()
1085
+ })
1086
+ )
1087
+ .output(
1088
+ z.object({
1089
+ greeting: z.string()
1090
+ })
1091
+ )
1092
+ .handleInvocation(async ctx => ({
1093
+ output: {
1094
+ greeting: `${ctx.config.prefix} ${ctx.input.name}`
1095
+ },
1096
+ message: 'done'
1097
+ }))
1098
+ .build();
1099
+
1100
+ let setupTool = SlatePublicTool.create(spec, {
1101
+ key: 'setup',
1102
+ name: 'Setup'
1103
+ })
1104
+ .input(z.object({}))
1105
+ .output(
1106
+ z.object({
1107
+ docsUrl: z.string()
1108
+ })
1109
+ )
1110
+ .handleInvocation(async ctx => {
1111
+ expect(ctx).not.toHaveProperty('config');
1112
+ expect(ctx).not.toHaveProperty('auth');
1113
+
1114
+ return {
1115
+ output: {
1116
+ docsUrl: 'https://example.com/setup'
1117
+ },
1118
+ message: 'ok'
1119
+ };
1120
+ })
1121
+ .build();
1122
+
1123
+ let client = createSlatesClient({
1124
+ transport: createLocalSlateTransport({
1125
+ slate: Slate.create({
1126
+ spec,
1127
+ tools: [echoTool, setupTool],
1128
+ triggers: []
1129
+ })
1130
+ })
1131
+ });
1132
+
1133
+ let tools = await client.listTools();
1134
+ expect(tools.map(tool => ({ id: tool.id, isPublic: tool.isPublic }))).toEqual([
1135
+ { id: 'echo', isPublic: false },
1136
+ { id: 'setup', isPublic: true }
1137
+ ]);
1138
+
1139
+ let setup = await client.getTool('setup');
1140
+ expect(setup.isPublic).toBe(true);
1141
+
1142
+ let echo = await client.getTool('echo');
1143
+ expect(echo.isPublic).toBe(false);
1144
+
1145
+ let result = await client.invokeTool('setup', {});
1146
+ expect(result.output).toEqual({
1147
+ docsUrl: 'https://example.com/setup'
1148
+ });
1149
+
1150
+ await expect(client.invokeTool('echo', { name: 'Ada' })).rejects.toMatchObject({
1151
+ message: 'Session context has not been initialized'
1152
+ });
1153
+ });
1042
1154
  });
package/src/client.ts CHANGED
@@ -2,6 +2,7 @@ import {
2
2
  SLATES_PROTOCOL_VERSION,
3
3
  type SlateAuthenticationMethod,
4
4
  type SlatesAction,
5
+ type SlatesActionTool,
5
6
  type SlatesMessageActionGetResponse,
6
7
  type SlatesMessageActionInvokeResponse,
7
8
  type SlatesMessageActionsListResponse,
@@ -173,9 +174,11 @@ export class SlatesProtocolClient {
173
174
  return this.request('slates/actions.list', {});
174
175
  }
175
176
 
176
- async listTools(): Promise<SlatesAction[]> {
177
+ async listTools(): Promise<SlatesActionTool[]> {
177
178
  let result = await this.listActions();
178
- return result.actions.filter(action => action.type === 'action.tool');
179
+ return result.actions.filter(
180
+ (action): action is SlatesActionTool => action.type === 'action.tool'
181
+ );
179
182
  }
180
183
 
181
184
  async listTriggers(): Promise<SlatesAction[]> {