@arbidocs/sdk 0.5.57 → 0.5.59

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.
@@ -0,0 +1,36 @@
1
+ // Install @arbidocs/sdk, then set the variables below and run with Node 22+.
2
+ // No IndexedDB polyfill is needed. Credentials stay in this process's memory.
3
+ import { Arbi } from '@arbidocs/sdk'
4
+
5
+ const { ARBI_URL, ARBI_EMAIL, ARBI_PASSWORD, ARBI_WORKSPACE_ID, ARBI_QUESTION } = process.env
6
+ if (!ARBI_URL || !ARBI_EMAIL || !ARBI_PASSWORD || !ARBI_WORKSPACE_ID) {
7
+ throw new Error('Set ARBI_URL, ARBI_EMAIL, ARBI_PASSWORD and ARBI_WORKSPACE_ID.')
8
+ }
9
+ const arbi = new Arbi({ url: ARBI_URL })
10
+ await arbi.login(ARBI_EMAIL, ARBI_PASSWORD)
11
+ // An explicit choice: subsequent operations use this current workspace.
12
+ await arbi.selectWorkspace(ARBI_WORKSPACE_ID)
13
+ const started = await arbi.assistant.startResponse({
14
+ question: ARBI_QUESTION ?? 'What can you help me with?',
15
+ docIds: [],
16
+ })
17
+ if (started.kind === 'acknowledged') {
18
+ console.log('Control request acknowledged.')
19
+ } else {
20
+ const { handle } = started
21
+ const abort = () => handle.detach() // closes this reader; does not cancel server execution
22
+ process.once('SIGINT', abort)
23
+ try {
24
+ const outcome = await handle.outcome
25
+ console.log(handle.snapshot().displayText)
26
+ console.log(`Response ${handle.id}: ${outcome.status}`)
27
+ if (outcome.status === 'disconnected') {
28
+ // Reconcile the accepted response; never blindly submit the same question again.
29
+ const stored = await arbi.assistant.getResponse(handle.id)
30
+ console.log(`Stored status: ${stored.status}`)
31
+ }
32
+ } finally {
33
+ process.removeListener('SIGINT', abort)
34
+ handle.detach()
35
+ }
36
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arbidocs/sdk",
3
- "version": "0.5.57",
3
+ "version": "0.5.59",
4
4
  "description": "Shared operations layer for ARBI — auth, config, SSE, WebSocket, and API operations",
5
5
  "type": "module",
6
6
  "sideEffects": false,
@@ -35,7 +35,8 @@
35
35
  }
36
36
  },
37
37
  "files": [
38
- "dist"
38
+ "dist",
39
+ "examples"
39
40
  ],
40
41
  "scripts": {
41
42
  "build": "tsup",
@@ -44,7 +45,7 @@
44
45
  "typecheck": "tsc --noEmit"
45
46
  },
46
47
  "dependencies": {
47
- "@arbidocs/client": "0.5.57",
48
+ "@arbidocs/client": "0.5.59",
48
49
  "jszip": "^3.10.1"
49
50
  },
50
51
  "devDependencies": {