@gravity-rail/sdk 0.36.1 → 0.42.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.
Files changed (57) hide show
  1. package/README.md +46 -23
  2. package/dist/agui.d.cts +1 -1
  3. package/dist/agui.d.ts +1 -1
  4. package/dist/audio.d.cts +1 -1
  5. package/dist/audio.d.ts +1 -1
  6. package/dist/{chat-interaction-DqjEfj7G.d.ts → chat-interaction-BBBeSKGl.d.cts} +9056 -6127
  7. package/dist/{chat-interaction-CbkSPz3m.d.cts → chat-interaction-C9dD0qbD.d.ts} +9056 -6127
  8. package/dist/{chunk-P2E6LU7I.js → chunk-67QXTQVL.js} +1 -26
  9. package/dist/chunk-67QXTQVL.js.map +1 -0
  10. package/dist/chunk-6KPGCPGW.js +48 -0
  11. package/dist/chunk-6KPGCPGW.js.map +1 -0
  12. package/dist/{chunk-HRUMZ46V.js → chunk-72SWNLVD.js} +2 -1
  13. package/dist/chunk-72SWNLVD.js.map +1 -0
  14. package/dist/{chunk-R6S5RXW5.js → chunk-JTOMGNUO.js} +1246 -212
  15. package/dist/chunk-JTOMGNUO.js.map +1 -0
  16. package/dist/helpers.cjs +47 -0
  17. package/dist/helpers.cjs.map +1 -1
  18. package/dist/helpers.d.cts +4 -3
  19. package/dist/helpers.d.ts +4 -3
  20. package/dist/helpers.js +7 -1
  21. package/dist/helpers.js.map +1 -1
  22. package/dist/index.cjs +1368 -341
  23. package/dist/index.cjs.map +1 -1
  24. package/dist/index.d.cts +13 -35
  25. package/dist/index.d.ts +13 -35
  26. package/dist/index.js +117 -116
  27. package/dist/index.js.map +1 -1
  28. package/dist/internal.cjs +1277 -243
  29. package/dist/internal.cjs.map +1 -1
  30. package/dist/internal.d.cts +324 -79
  31. package/dist/internal.d.ts +324 -79
  32. package/dist/internal.js +61 -15
  33. package/dist/internal.js.map +1 -1
  34. package/dist/member-import-BXReoljG.d.cts +46 -0
  35. package/dist/member-import-jjfQHlWl.d.ts +46 -0
  36. package/dist/realtime.cjs +91 -20
  37. package/dist/realtime.cjs.map +1 -1
  38. package/dist/realtime.d.cts +34 -9
  39. package/dist/realtime.d.ts +34 -9
  40. package/dist/realtime.js +90 -20
  41. package/dist/realtime.js.map +1 -1
  42. package/dist/{revision-state-CSQ7J3ZU.d.cts → revision-state-Bp7WKk6z.d.cts} +270 -54
  43. package/dist/{revision-state-92LHz1jQ.d.ts → revision-state-QkNQXWJC.d.ts} +270 -54
  44. package/dist/schemas.cjs +58 -81
  45. package/dist/schemas.cjs.map +1 -1
  46. package/dist/schemas.d.cts +88 -225
  47. package/dist/schemas.d.ts +88 -225
  48. package/dist/schemas.js +58 -76
  49. package/dist/schemas.js.map +1 -1
  50. package/dist/{tasks-CrF1qC4G.d.cts → tasks-BsLI-h11.d.cts} +3259 -2507
  51. package/dist/{tasks-CrF1qC4G.d.ts → tasks-BsLI-h11.d.ts} +3259 -2507
  52. package/dist/{types-0c6_NGU4.d.cts → types-DlfADjPR.d.cts} +17 -2
  53. package/dist/{types-0c6_NGU4.d.ts → types-DlfADjPR.d.ts} +17 -2
  54. package/package.json +9 -7
  55. package/dist/chunk-HRUMZ46V.js.map +0 -1
  56. package/dist/chunk-P2E6LU7I.js.map +0 -1
  57. package/dist/chunk-R6S5RXW5.js.map +0 -1
package/README.md CHANGED
@@ -22,6 +22,11 @@ npm install zod # optional, for runtime validation
22
22
 
23
23
  ## Quick Start
24
24
 
25
+ Create an account or organization API key with the scopes your integration needs.
26
+ See [Authentication](https://docs.gravityrail.com/developer/guides/connect/authentication)
27
+ for key reach, OAuth, and step-up requirements. Keep credentials in your server's
28
+ environment or secrets manager; do not embed an API key in a public browser bundle.
29
+
25
30
  ```typescript
26
31
  import { GravityRailClient } from '@gravity-rail/sdk';
27
32
 
@@ -30,26 +35,55 @@ const client = new GravityRailClient(
30
35
  'https://api.gravityrail.com'
31
36
  );
32
37
 
33
- // List all workflows in a workspace
38
+ const workspaces = await client.getWorkspaces();
39
+ if (workspaces.length === 0) throw new Error('No workspace available');
40
+ const workspaceId = workspaces[0].id;
34
41
  const workflows = await client.getWorkflows(workspaceId);
35
-
36
- // Get active chats across every channel
37
42
  const chats = await client.getChats(workspaceId);
43
+ ```
44
+
45
+ Use [Creating Members](https://docs.gravityrail.com/developer/guides/data/creating-members)
46
+ to select the appropriate creation/import endpoint and role. A direct SDK call
47
+ uses the request type's wire names:
38
48
 
39
- // Create a new member
49
+ ```typescript
50
+ const roleId = Number(process.env.GRAVITY_RAIL_MEMBER_ROLE_ID);
51
+ if (!Number.isInteger(roleId) || roleId <= 0) {
52
+ throw new Error('Set GRAVITY_RAIL_MEMBER_ROLE_ID to an authorized role ID');
53
+ }
40
54
  const member = await client.createWorkspaceMember(workspaceId, {
41
- first_name: 'Jane',
42
- last_name: 'Doe',
43
- email: 'jane@example.com',
44
- role_id: roleId,
55
+ name: 'Integration Test',
56
+ email: 'integration-test@example.com',
57
+ memberRoleId: roleId, // an authorized role selected for the new Member
45
58
  });
46
59
  ```
47
60
 
61
+ ### Handle API errors
62
+
63
+ ```typescript
64
+ import { ApiError } from '@gravity-rail/sdk';
65
+
66
+ try {
67
+ await client.getWorkflows(workspaceId);
68
+ } catch (error) {
69
+ if (error instanceof ApiError && error.statusCode === 403) {
70
+ // Check the acting identity and scopes for this workspace.
71
+ }
72
+ throw error;
73
+ }
74
+ ```
75
+
76
+ See [Error Handling](https://docs.gravityrail.com/developer/guides/connect/error-handling)
77
+ for status codes and safe reporting. The [SDK Reference](https://docs.gravityrail.com/sdk)
78
+ and [GravityRailClient](https://docs.gravityrail.com/sdk/classes/GravityRailClient)
79
+ reference document methods and types. This package README also supplies the
80
+ canonical [SDK usage guide](https://docs.gravityrail.com/developer/libraries/sdk).
81
+
48
82
  ## Authentication
49
83
 
50
84
  ### API Key
51
85
 
52
- Scoped API keys are the simplest way to authenticate. Create one from workspace settings or via the SDK:
86
+ Create an account or organization API key with the required permissions:
53
87
 
54
88
  ```typescript
55
89
  const client = new GravityRailClient(
@@ -58,7 +92,7 @@ const client = new GravityRailClient(
58
92
  );
59
93
  ```
60
94
 
61
- Keys can be scoped to specific permissions (read-only, workspace-limited, time-expiring) using the [granular scope system](#scopes--permissions).
95
+ Select the required scopes and expiry using the [granular scope system](#scopes--permissions). Key reach depends on the issuing account or organization; a key created in workspace settings is not inherently limited to that workspace.
62
96
 
63
97
  ### OAuth2 with PKCE
64
98
 
@@ -73,17 +107,6 @@ client.setEnhancedAuthHandler(async (authInfo) => {
73
107
  });
74
108
  ```
75
109
 
76
- ### Member Identity Switching
77
-
78
- Act on behalf of a specific workspace member:
79
-
80
- ```typescript
81
- client.setActingMember(memberUuid);
82
- // All subsequent requests use this member's identity
83
- const myChats = await client.getChats(workspaceId);
84
- client.setActingMember(undefined); // reset
85
- ```
86
-
87
110
  ## Core Concepts
88
111
 
89
112
  Every Gravity Rail workspace is a self-contained environment with isolated data, workflows, and configuration. The SDK organizes its 500+ methods by domain:
@@ -122,14 +145,14 @@ const workflow = await client.createWorkflow(workspaceId, {
122
145
  // Create an AI assistant
123
146
  const assistant = await client.createAssistant(workspaceId, {
124
147
  name: 'Onboarding Guide',
125
- model: 'claude-sonnet-4-20250514',
148
+ model: 'aws:bedrock:claude-5-5-sonnet',
126
149
  bio: 'A friendly assistant that helps new customers get started.',
127
150
  });
128
151
 
129
152
  // Add a supervisor for quality assurance
130
153
  const supervisor = await client.createSupervisor(workspaceId, {
131
154
  name: 'QA Reviewer',
132
- model: 'claude-sonnet-4-20250514',
155
+ model: 'aws:bedrock:claude-5-5-sonnet',
133
156
  instructions: 'Review assistant responses for accuracy and tone.',
134
157
  });
135
158
 
package/dist/agui.d.cts CHANGED
@@ -1,4 +1,4 @@
1
- import { C as ChannelEvent } from './types-0c6_NGU4.cjs';
1
+ import { C as ChannelEvent } from './types-DlfADjPR.cjs';
2
2
 
3
3
  interface TranscriptMessage {
4
4
  id: string;
package/dist/agui.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { C as ChannelEvent } from './types-0c6_NGU4.js';
1
+ import { C as ChannelEvent } from './types-DlfADjPR.js';
2
2
 
3
3
  interface TranscriptMessage {
4
4
  id: string;
package/dist/audio.d.cts CHANGED
@@ -1,4 +1,4 @@
1
- import { C as ChannelEvent } from './types-0c6_NGU4.cjs';
1
+ import { C as ChannelEvent } from './types-DlfADjPR.cjs';
2
2
 
3
3
  /** PCM16 helpers aligned with main-app web voice (24 kHz). */
4
4
  declare const SERVER_SAMPLE_RATE = 24000;
package/dist/audio.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { C as ChannelEvent } from './types-0c6_NGU4.js';
1
+ import { C as ChannelEvent } from './types-DlfADjPR.js';
2
2
 
3
3
  /** PCM16 helpers aligned with main-app web voice (24 kHz). */
4
4
  declare const SERVER_SAMPLE_RATE = 24000;