@arbidocs/sdk 0.5.61 → 0.5.63

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.
@@ -1,36 +1,6 @@
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
- }
1
+ // Node 22+: set the environment variables in session.mjs.
2
+ import { connect } from './session.mjs'
3
+ const arbi = await connect()
4
+ const response = await arbi.responses.create({ input: process.env.ARBI_QUESTION ?? 'Say hello.' })
5
+ if (response.status !== 'completed') throw new Error(`Response ${response.id}: ${response.status}`)
6
+ console.log(response.output_text)
@@ -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
+ }
@@ -0,0 +1,11 @@
1
+ import { connect } from './session.mjs'
2
+ const arbi = await connect()
3
+ const stream = await arbi.responses.create({
4
+ input: process.env.ARBI_QUESTION ?? 'Say hello.',
5
+ stream: true,
6
+ })
7
+ for await (const event of stream) {
8
+ if (event.type === 'response.output_text.delta') process.stdout.write(event.delta)
9
+ }
10
+ console.log()
11
+ // Advanced: stream.handle exposes ARBI detach, cancel, snapshots and terminal outcomes.
@@ -1,8 +1,8 @@
1
1
  // Node 22+: uses Responses text.format; requires backend structured-output support.
2
2
  import { connect } from './session.mjs'
3
3
  const arbi = await connect()
4
- const { data, response } = await arbi.assistant.parseResponse({
5
- question: process.env.ARBI_QUESTION ?? 'Extract the name from: My name is Ada.',
4
+ const response = await arbi.responses.parse({
5
+ input: process.env.ARBI_QUESTION ?? 'Extract the name from: My name is Ada.',
6
6
  text: {
7
7
  format: {
8
8
  type: 'json_schema',
@@ -17,4 +17,4 @@ const { data, response } = await arbi.assistant.parseResponse({
17
17
  },
18
18
  },
19
19
  })
20
- console.log(data, response.id)
20
+ console.log(response.output_parsed, response.id)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arbidocs/sdk",
3
- "version": "0.5.61",
3
+ "version": "0.5.63",
4
4
  "description": "Shared operations layer for ARBI — auth, config, SSE, WebSocket, and API operations",
5
5
  "type": "module",
6
6
  "sideEffects": false,
@@ -45,7 +45,7 @@
45
45
  "typecheck": "tsc --noEmit"
46
46
  },
47
47
  "dependencies": {
48
- "@arbidocs/client": "0.5.61",
48
+ "@arbidocs/client": "0.5.63",
49
49
  "ajv": "^8.20.0",
50
50
  "jszip": "^3.10.1"
51
51
  },