@arbidocs/sdk 0.5.60 → 0.5.61

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,18 @@
1
+ // Set ARBI_RESPONSE_ID to inspect an existing response without creating another task.
2
+ import { setTimeout } from 'node:timers/promises'
3
+ import { connect } from './session.mjs'
4
+ const arbi = await connect()
5
+ let response = process.env.ARBI_RESPONSE_ID
6
+ ? await arbi.responses.retrieve(process.env.ARBI_RESPONSE_ID)
7
+ : await arbi.responses.create({
8
+ input: process.env.ARBI_QUESTION ?? 'Write a short welcome.',
9
+ background: true,
10
+ })
11
+ console.log(`Save ARBI_RESPONSE_ID=${response.id} to resume inspection later.`)
12
+ const deadline = Date.now() + 60_000
13
+ while (['queued', 'in_progress'].includes(response.status) && Date.now() < deadline) {
14
+ await setTimeout(1000)
15
+ response = await arbi.responses.retrieve(response.id)
16
+ }
17
+ console.log(response)
18
+ // Exiting or timing out never cancels the server task. Use responses.cancel(id) explicitly.
@@ -0,0 +1,97 @@
1
+ {
2
+ "version": 1,
3
+ "responses": [
4
+ {
5
+ "id": "msg-contract-completed",
6
+ "object": "response",
7
+ "status": "completed",
8
+ "background": false,
9
+ "output": [
10
+ {
11
+ "id": "msg-contract-completed",
12
+ "type": "message",
13
+ "role": "assistant",
14
+ "status": "completed",
15
+ "content": [
16
+ {
17
+ "type": "output_text",
18
+ "text": "{\"value\":7}",
19
+ "annotations": []
20
+ }
21
+ ]
22
+ }
23
+ ],
24
+ "metadata": {
25
+ "arbi_extension": "preserved"
26
+ },
27
+ "conversation_ext_id": "con-contract",
28
+ "usage": {
29
+ "input_tokens": 3,
30
+ "output_tokens": 4,
31
+ "total_tokens": 7
32
+ }
33
+ },
34
+ {
35
+ "id": "msg-contract-queued",
36
+ "object": "response",
37
+ "status": "queued",
38
+ "background": true,
39
+ "output": [],
40
+ "metadata": {
41
+ "arbi_extension": "preserved"
42
+ },
43
+ "conversation_ext_id": "con-contract"
44
+ },
45
+ {
46
+ "id": "msg-contract-in_progress",
47
+ "object": "response",
48
+ "status": "in_progress",
49
+ "background": false,
50
+ "output": [],
51
+ "metadata": {
52
+ "arbi_extension": "preserved"
53
+ },
54
+ "conversation_ext_id": "con-contract"
55
+ },
56
+ {
57
+ "id": "msg-contract-failed",
58
+ "object": "response",
59
+ "status": "failed",
60
+ "background": false,
61
+ "output": [],
62
+ "metadata": {
63
+ "arbi_extension": "preserved"
64
+ },
65
+ "conversation_ext_id": "con-contract",
66
+ "error": {
67
+ "code": "STRUCTURED_OUTPUT_INVALID",
68
+ "message": "Invalid output."
69
+ }
70
+ },
71
+ {
72
+ "id": "msg-contract-incomplete",
73
+ "object": "response",
74
+ "status": "incomplete",
75
+ "background": false,
76
+ "output": [],
77
+ "metadata": {
78
+ "arbi_extension": "preserved"
79
+ },
80
+ "conversation_ext_id": "con-contract",
81
+ "incomplete_details": {
82
+ "reason": "max_output_tokens"
83
+ }
84
+ },
85
+ {
86
+ "id": "msg-contract-cancelled",
87
+ "object": "response",
88
+ "status": "cancelled",
89
+ "background": false,
90
+ "output": [],
91
+ "metadata": {
92
+ "arbi_extension": "preserved"
93
+ },
94
+ "conversation_ext_id": "con-contract"
95
+ }
96
+ ]
97
+ }
@@ -0,0 +1,10 @@
1
+ import { Arbi } from '@arbidocs/sdk'
2
+ export async function connect() {
3
+ const { ARBI_URL, ARBI_EMAIL, ARBI_PASSWORD, ARBI_WORKSPACE_ID } = process.env
4
+ if (!ARBI_URL || !ARBI_EMAIL || !ARBI_PASSWORD || !ARBI_WORKSPACE_ID)
5
+ throw new Error('Set ARBI_URL, ARBI_EMAIL, ARBI_PASSWORD and ARBI_WORKSPACE_ID.')
6
+ const arbi = new Arbi({ url: ARBI_URL })
7
+ await arbi.login(ARBI_EMAIL, ARBI_PASSWORD)
8
+ await arbi.selectWorkspace(ARBI_WORKSPACE_ID)
9
+ return arbi
10
+ }
@@ -0,0 +1,20 @@
1
+ // Node 22+: uses Responses text.format; requires backend structured-output support.
2
+ import { connect } from './session.mjs'
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.',
6
+ text: {
7
+ format: {
8
+ type: 'json_schema',
9
+ name: 'person',
10
+ strict: true,
11
+ schema: {
12
+ type: 'object',
13
+ properties: { name: { type: 'string' } },
14
+ required: ['name'],
15
+ additionalProperties: false,
16
+ },
17
+ },
18
+ },
19
+ })
20
+ console.log(data, response.id)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arbidocs/sdk",
3
- "version": "0.5.60",
3
+ "version": "0.5.61",
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,8 @@
45
45
  "typecheck": "tsc --noEmit"
46
46
  },
47
47
  "dependencies": {
48
- "@arbidocs/client": "0.5.60",
48
+ "@arbidocs/client": "0.5.61",
49
+ "ajv": "^8.20.0",
49
50
  "jszip": "^3.10.1"
50
51
  },
51
52
  "devDependencies": {