@rayrun/sdk 0.2.0 → 0.2.1

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
@@ -73,6 +73,9 @@ const valid = verifyWebhookSignature({
73
73
 
74
74
  After verification, parse the body as `WebhookPayload`. Every event has a stable `id`, `type`, and
75
75
  `occurredAt`; its `data` shape is narrowed by `type`. Use `id` to deduplicate retries.
76
+ For `activity.call`, `arguments` and `result` contain the captured tool payloads, or `null` when
77
+ capture was disabled for that connection, the webhook did not opt in with
78
+ `forwardToolPayloads: true`, or no result existed.
76
79
 
77
80
  ```ts
78
81
  import type { WebhookPayload } from '@rayrun/sdk';
package/index.d.ts CHANGED
@@ -1,5 +1,12 @@
1
1
  /* oxlint-disable perfectionist/sort-classes, perfectionist/sort-modules, perfectionist/sort-object-types, perfectionist/sort-union-types -- Public types follow the documented API resource order. */
2
2
  export type CursorPage<T> = { items: T[]; page: { nextCursor: string | null } };
3
+ export type JsonValue =
4
+ | boolean
5
+ | null
6
+ | number
7
+ | string
8
+ | JsonValue[]
9
+ | { [key: string]: JsonValue };
3
10
  export type PageQuery = { cursor?: string; limit?: number };
4
11
  export type ToolDecision = 'allow' | 'ask' | 'block';
5
12
  export type ToolAccessMode = 'read-only' | 'ask-before-changes' | 'allow-all' | 'custom';
@@ -77,6 +84,7 @@ export type Webhook = {
77
84
  description: string | null;
78
85
  enabled: boolean;
79
86
  eventTypes: WebhookEvent[];
87
+ forwardToolPayloads: boolean;
80
88
  uid: string;
81
89
  url: string;
82
90
  };
@@ -114,10 +122,12 @@ export type WebhookPayload =
114
122
  'activity.call',
115
123
  {
116
124
  activityId: string;
125
+ arguments: JsonValue;
117
126
  calledAt: string;
118
127
  connectionUid: string | null;
119
128
  errorCode: string | null;
120
129
  policyDecision: ToolDecision | null;
130
+ result: JsonValue;
121
131
  succeeded: boolean | null;
122
132
  toolName: string;
123
133
  }
@@ -232,6 +242,7 @@ export class Rayrun {
232
242
  url: string;
233
243
  description?: string | null;
234
244
  eventTypes: WebhookEvent[];
245
+ forwardToolPayloads?: boolean;
235
246
  }): Promise<{ uid: string; secret: string }>;
236
247
  delete(uid: string): Promise<void>;
237
248
  list(): Promise<{ items: Webhook[] }>;
package/index.js CHANGED
@@ -80,6 +80,8 @@ export const verifyWebhookSignature = ({
80
80
  };
81
81
 
82
82
  export class Rayrun {
83
+ #apiKey;
84
+
83
85
  constructor({
84
86
  apiKey,
85
87
  baseUrl = 'https://ray.run',
@@ -88,7 +90,7 @@ export class Rayrun {
88
90
  if (!apiKey) throw new TypeError('Rayrun requires an apiKey.');
89
91
  if (!fetchImplementation) throw new TypeError('Rayrun requires a fetch implementation.');
90
92
 
91
- this.apiKey = apiKey;
93
+ this.#apiKey = apiKey;
92
94
  this.baseUrl = baseUrl.replace(/\/$/u, '');
93
95
  this.fetch = fetchImplementation;
94
96
 
@@ -140,7 +142,7 @@ export class Rayrun {
140
142
  response = await this.fetch(url, {
141
143
  body: body === undefined ? undefined : JSON.stringify(body),
142
144
  headers: withoutUndefined({
143
- authorization: `Bearer ${this.apiKey}`,
145
+ authorization: `Bearer ${this.#apiKey}`,
144
146
  'content-type': body === undefined ? undefined : 'application/json',
145
147
  'user-agent': '@rayrun/sdk',
146
148
  }),
@@ -266,6 +268,8 @@ export class RayrunCodeRunAheadSession {
266
268
  }
267
269
 
268
270
  export class RayrunGateway {
271
+ #accessToken;
272
+
269
273
  constructor({
270
274
  accessToken,
271
275
  baseUrl = 'https://ray.run',
@@ -274,7 +278,7 @@ export class RayrunGateway {
274
278
  if (!accessToken) throw new TypeError('RayrunGateway requires an accessToken.');
275
279
  if (!fetchImplementation) throw new TypeError('RayrunGateway requires a fetch implementation.');
276
280
 
277
- this.accessToken = accessToken;
281
+ this.#accessToken = accessToken;
278
282
  this.baseUrl = baseUrl.replace(/\/$/u, '');
279
283
  this.fetch = fetchImplementation;
280
284
  this.codeRunAhead = {
@@ -298,7 +302,7 @@ export class RayrunGateway {
298
302
  const response = await this.fetch(`${this.baseUrl}/mcp/run-ahead`, {
299
303
  body: JSON.stringify(body),
300
304
  headers: {
301
- authorization: `Bearer ${this.accessToken}`,
305
+ authorization: `Bearer ${this.#accessToken}`,
302
306
  'content-type': 'application/json',
303
307
  'user-agent': '@rayrun/sdk',
304
308
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rayrun/sdk",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "description": "Type-safe client for the Rayrun public API",
5
5
  "license": "MIT",
6
6
  "repository": {