@arbidocs/sdk 0.1.0 → 0.3.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
@@ -159,62 +159,6 @@ async function main() {
159
159
  main()
160
160
  ```
161
161
 
162
- ### Build an MCP Server or CLI Tool
163
-
164
- ```typescript
165
- import 'fake-indexeddb/auto'
166
- import { createArbiClient, getSession, sealedBoxDecrypt,
167
- deriveEncryptionKeypairFromSigning, createWorkspaceKeyHeader } from '@arbidocs/sdk'
168
-
169
- // Reusable helper: select a workspace and set up the crypto header
170
- async function selectWorkspace(arbi, workspaceId, serverSessionKey) {
171
- // Fetch workspaces to get the wrapped key
172
- const { data: workspaces } = await arbi.fetch.GET('/api/user/workspaces')
173
- const ws = workspaces.find(w => w.external_id === workspaceId)
174
- if (!ws?.wrapped_key) throw new Error(`Workspace ${workspaceId} not found`)
175
-
176
- const session = await getSession()
177
- const pubKey = session.signingPrivateKey.slice(32, 64)
178
- const encKP = deriveEncryptionKeypairFromSigning({
179
- publicKey: pubKey,
180
- secretKey: session.signingPrivateKey,
181
- })
182
- const wsKey = sealedBoxDecrypt(ws.wrapped_key, encKP.secretKey)
183
- const header = await createWorkspaceKeyHeader(wsKey, serverSessionKey)
184
-
185
- arbi.session.setSelectedWorkspace(workspaceId)
186
- arbi.session.setCachedWorkspaceHeader(workspaceId, header)
187
- }
188
-
189
- // Example: CLI that searches documents
190
- async function searchDocuments(query: string) {
191
- const arbi = createArbiClient({
192
- baseUrl: process.env.ARBI_API_URL!,
193
- deploymentDomain: process.env.ARBI_DOMAIN!,
194
- credentials: 'omit',
195
- })
196
-
197
- const { serverSessionKey } = await arbi.auth.login({
198
- email: process.env.ARBI_EMAIL!,
199
- password: process.env.ARBI_PASSWORD!,
200
- })
201
-
202
- await selectWorkspace(arbi, process.env.ARBI_WORKSPACE!, serverSessionKey)
203
-
204
- // Use the assistant API to ask a question about your documents
205
- const { data } = await arbi.fetch.POST('/api/assistant/query', {
206
- body: {
207
- workspace_ext_id: process.env.ARBI_WORKSPACE!,
208
- query,
209
- },
210
- })
211
-
212
- console.log(data)
213
- }
214
-
215
- searchDocuments('What are the key terms of the contract?')
216
- ```
217
-
218
162
  ### Subscribe to Session State Changes
219
163
 
220
164
  The SDK's `SessionManager` supports a subscribe pattern for reactive updates:
package/dist/index.d.cts CHANGED
@@ -1038,6 +1038,26 @@ interface paths {
1038
1038
  patch?: never;
1039
1039
  trace?: never;
1040
1040
  };
1041
+ '/api/health/mcp-tools': {
1042
+ parameters: {
1043
+ query?: never;
1044
+ header?: never;
1045
+ path?: never;
1046
+ cookie?: never;
1047
+ };
1048
+ /**
1049
+ * Get Mcp Tools
1050
+ * @description Returns available MCP tools registered on the LiteLLM proxy.
1051
+ */
1052
+ get: operations['get_mcp_tools'];
1053
+ put?: never;
1054
+ post?: never;
1055
+ delete?: never;
1056
+ options?: never;
1057
+ head?: never;
1058
+ patch?: never;
1059
+ trace?: never;
1060
+ };
1041
1061
  '/api/tag/': {
1042
1062
  parameters: {
1043
1063
  query?: never;
@@ -1288,24 +1308,32 @@ interface components {
1288
1308
  * @description A single agent step with a sequential index.
1289
1309
  *
1290
1310
  * Tool call steps have a detail list; lifecycle steps have a step string.
1311
+ * The focus field carries the agent's current focus: what it's zeroing in on.
1312
+ * The content field carries extended text (e.g. the research plan).
1291
1313
  *
1292
1314
  * Examples:
1293
- * {"type": "agent_step", "index": 1, "detail": [
1315
+ * {"type": "agent_step", "index": 1, "step": "planning",
1316
+ * "content": "1. Search for force majeure clauses across all three contracts\n2. Compare scope and exclusions"}
1317
+ * {"type": "agent_step", "index": 2,
1318
+ * "focus": "Searching for force majeure clauses across the selected contracts.",
1319
+ * "detail": [
1294
1320
  * {"tool": "search_documents", "query": "force majeure", "search_mode": "hybrid"},
1295
1321
  * {"tool": "get_table_of_contents", "doc_count": 2}
1296
1322
  * ]}
1297
- * {"type": "agent_step", "index": 2, "detail": [
1323
+ * {"type": "agent_step", "index": 3,
1324
+ * "focus": "Comparing the provisions found in Contract A with Contract B.",
1325
+ * "detail": [
1298
1326
  * {"tool": "get_document_passages", "doc_ext_id": "doc-abc12345", "from_ref": "5", "to_ref": "8"}
1299
1327
  * ]}
1300
- * {"type": "agent_step", "index": 3, "detail": [
1301
- * {"tool": "web_search", "query": "latest arbitration developments 2026"}
1302
- * ]}
1303
1328
  * {"type": "agent_step", "index": 4, "step": "evaluation", "detail": [
1304
1329
  * {"statement": "Newton prosecuted 28 coiners", "chunk_ids": ["chunk-abc"]},
1305
1330
  * {"statement": "Counterfeiting was high treason", "chunk_ids": ["chunk-def"]}
1306
1331
  * ]}
1307
- * {"type": "agent_step", "index": 5, "step": "answering"}
1308
- * {"type": "agent_step", "index": 6, "step": "reviewing"}
1332
+ * {"type": "agent_step", "index": 5, "step": "tool_progress", "detail": [
1333
+ * {"tool": "read_urls", "message": "Fetching 2 pages"}
1334
+ * ]}
1335
+ * {"type": "agent_step", "index": 6, "step": "answering"}
1336
+ * {"type": "agent_step", "index": 7, "step": "reviewing"}
1309
1337
  */
1310
1338
  AgentStepEvent: {
1311
1339
  /**
@@ -1321,9 +1349,19 @@ interface components {
1321
1349
  index: number;
1322
1350
  /**
1323
1351
  * Step
1324
- * @description Lifecycle step (answering, reviewing). Absent for tool calls.
1352
+ * @description Lifecycle step (planning, answering, reviewing). Absent for tool calls.
1325
1353
  */
1326
1354
  step?: string | null;
1355
+ /**
1356
+ * Focus
1357
+ * @description Agent's current focus (single sentence). Present on tool call steps.
1358
+ */
1359
+ focus?: string | null;
1360
+ /**
1361
+ * Content
1362
+ * @description Extended text content (e.g. research plan). Present on planning step.
1363
+ */
1364
+ content?: string | null;
1327
1365
  /**
1328
1366
  * Detail
1329
1367
  * @description Tool calls list. Each entry has 'tool' key plus tool-specific params.
@@ -1351,10 +1389,34 @@ interface components {
1351
1389
  HUMAN_IN_THE_LOOP: boolean;
1352
1390
  /**
1353
1391
  * Web Search
1354
- * @description Enable the web_search tool for searching the web.
1392
+ * @description Enable web tools: web_search (find URLs) and read_url (fetch and process webpages).
1355
1393
  * @default false
1356
1394
  */
1357
1395
  WEB_SEARCH: boolean;
1396
+ /**
1397
+ * Mcp Tools
1398
+ * @description MCP tool names to enable from LiteLLM (e.g. ['read_wiki_contents', 'ask_question']).
1399
+ * @default []
1400
+ */
1401
+ MCP_TOOLS: string[];
1402
+ /**
1403
+ * Planning Enabled
1404
+ * @description Run a planning step before the first agent decision. The agent generates a text plan that guides subsequent tool calls.
1405
+ * @default false
1406
+ */
1407
+ PLANNING_ENABLED: boolean;
1408
+ /**
1409
+ * Planning Approval
1410
+ * @description When planning is enabled, pause after generating the plan to allow the user to approve, skip, or comment before proceeding. Requires PLANNING_ENABLED=True to have any effect.
1411
+ * @default false
1412
+ */
1413
+ PLANNING_APPROVAL: boolean;
1414
+ /**
1415
+ * Suggested Queries
1416
+ * @description Generate a single suggested follow-up query after each response.
1417
+ * @default false
1418
+ */
1419
+ SUGGESTED_QUERIES: boolean;
1358
1420
  /**
1359
1421
  * Persona
1360
1422
  * @description Agent persona prepended to the system prompt. Customise to change the agent's identity and tone.
@@ -1411,6 +1473,8 @@ interface components {
1411
1473
  * - get_document_passages: Read specific pages from a document
1412
1474
  * - get_table_of_contents: Get headings and page references for documents
1413
1475
  * - web_search: Search the web for current/external information
1476
+ * - read_urls: Fetch and index webpages. Always call immediately after web_search
1477
+ * with the 2-3 most relevant URLs. Then use search_documents to query them.
1414
1478
  * - ask_user: Ask the user a clarifying question with structured options.
1415
1479
  * You MUST call this tool to ask the user anything — do NOT write questions
1416
1480
  * or options as plain text. Only the tool delivers the question to the user.
@@ -1423,7 +1487,8 @@ interface components {
1423
1487
  * 1. PARALLEL CALLS: When a query has multiple aspects, call multiple tools in parallel (e.g., search different keywords simultaneously)
1424
1488
  * 2. AVOID DUPLICATION: Before searching, review learnings from previous results. Do not repeat searches for information you already have
1425
1489
  * 3. TARGETED SEARCHES: Use specific, focused queries rather than broad ones
1426
- * 4. STOP WHEN READY: Provide your answer when you have sufficient evidence. Signs you have enough:
1490
+ * 4. BROAD PASSAGE RANGES: When using get_document_passages, request broad ranges (5-10+ pages per call). A few large fetches are far better than many small ones
1491
+ * 5. STOP WHEN READY: Provide your answer when you have sufficient evidence. Signs you have enough:
1427
1492
  * - Multiple sources confirm the same facts
1428
1493
  * - Key questions from the query are addressed
1429
1494
  * - Additional searches return redundant information
@@ -1448,6 +1513,10 @@ interface components {
1448
1513
  * "ENABLED": true,
1449
1514
  * "HUMAN_IN_THE_LOOP": true,
1450
1515
  * "WEB_SEARCH": false,
1516
+ * "MCP_TOOLS": [],
1517
+ * "PLANNING_ENABLED": false,
1518
+ * "PLANNING_APPROVAL": false,
1519
+ * "SUGGESTED_QUERIES": false,
1451
1520
  * "PERSONA": "You are ARBI, an AI assistant created by ARBI CITY.\n\nYou maintain formal, objective tone appropriate for professional/legal contexts. If any part of the answer is based on general knowledge instead of the supplied sources, you must state so clearly and recognise that it may not be accurate.",
1452
1521
  * "AGENT_MODEL_NAME": "Q3VL@ARBICITY",
1453
1522
  * "AGENT_API_TYPE": "remote",
@@ -1455,7 +1524,7 @@ interface components {
1455
1524
  * "AGENT_MAX_TOKENS": 20000,
1456
1525
  * "AGENT_MAX_ITERATIONS": 10,
1457
1526
  * "AGENT_HISTORY_CHAR_THRESHOLD": 8000,
1458
- * "AGENT_SYSTEM_PROMPT": "YOUR TASK:\nDetermine which, if any, of the available documents contain information relevant to the user's query. Use your tools to retrieve and examine document content.\n\nTOOLS AVAILABLE:\n- search_documents: Search for relevant passages across documents\n- get_document_passages: Read specific pages from a document\n- get_table_of_contents: Get headings and page references for documents\n- web_search: Search the web for current/external information\n- ask_user: Ask the user a clarifying question with structured options.\n You MUST call this tool to ask the user anything — do NOT write questions\n or options as plain text. Only the tool delivers the question to the user.\n IMPORTANT: Once the user responds, do NOT ask the same question again.\n Use their answer and proceed with research. If the user's answer is\n unexpected (e.g. refers to something not in the documents), explain what\n you found and answer based on available information.\n\nEFFICIENCY GUIDELINES:\n1. PARALLEL CALLS: When a query has multiple aspects, call multiple tools in parallel (e.g., search different keywords simultaneously)\n2. AVOID DUPLICATION: Before searching, review learnings from previous results. Do not repeat searches for information you already have\n3. TARGETED SEARCHES: Use specific, focused queries rather than broad ones\n4. STOP WHEN READY: Provide your answer when you have sufficient evidence. Signs you have enough:\n - Multiple sources confirm the same facts\n - Key questions from the query are addressed\n - Additional searches return redundant information\n\nWORKFLOW:\n1. Analyze the query to identify distinct information needs\n2. Execute parallel searches for different aspects when appropriate\n3. Evaluate results - extract learnings, note gaps\n4. Only search again if specific gaps remain unfilled\n5. Answer when confident (no tool call) - do not over-research\n\nIMPORTANT:\n- The document index contains metadata only - you must retrieve actual content\n- Do not add inline citation markers - the system handles citations automatically"
1527
+ * "AGENT_SYSTEM_PROMPT": "YOUR TASK:\nDetermine which, if any, of the available documents contain information relevant to the user's query. Use your tools to retrieve and examine document content.\n\nTOOLS AVAILABLE:\n- search_documents: Search for relevant passages across documents\n- get_document_passages: Read specific pages from a document\n- get_table_of_contents: Get headings and page references for documents\n- web_search: Search the web for current/external information\n- read_urls: Fetch and index webpages. Always call immediately after web_search\n with the 2-3 most relevant URLs. Then use search_documents to query them.\n- ask_user: Ask the user a clarifying question with structured options.\n You MUST call this tool to ask the user anything — do NOT write questions\n or options as plain text. Only the tool delivers the question to the user.\n IMPORTANT: Once the user responds, do NOT ask the same question again.\n Use their answer and proceed with research. If the user's answer is\n unexpected (e.g. refers to something not in the documents), explain what\n you found and answer based on available information.\n\nEFFICIENCY GUIDELINES:\n1. PARALLEL CALLS: When a query has multiple aspects, call multiple tools in parallel (e.g., search different keywords simultaneously)\n2. AVOID DUPLICATION: Before searching, review learnings from previous results. Do not repeat searches for information you already have\n3. TARGETED SEARCHES: Use specific, focused queries rather than broad ones\n4. BROAD PASSAGE RANGES: When using get_document_passages, request broad ranges (5-10+ pages per call). A few large fetches are far better than many small ones\n5. STOP WHEN READY: Provide your answer when you have sufficient evidence. Signs you have enough:\n - Multiple sources confirm the same facts\n - Key questions from the query are addressed\n - Additional searches return redundant information\n\nWORKFLOW:\n1. Analyze the query to identify distinct information needs\n2. Execute parallel searches for different aspects when appropriate\n3. Evaluate results - extract learnings, note gaps\n4. Only search again if specific gaps remain unfilled\n5. Answer when confident (no tool call) - do not over-research\n\nIMPORTANT:\n- The document index contains metadata only - you must retrieve actual content\n- Do not add inline citation markers - the system handles citations automatically"
1459
1528
  * }
1460
1529
  */
1461
1530
  Agents: components['schemas']['AgentsConfig'];
@@ -1570,10 +1639,9 @@ interface components {
1570
1639
  * "API_TYPE": "remote",
1571
1640
  * "MODEL_NAME": "Q3VL@ARBICITY",
1572
1641
  * "ENABLED": true,
1573
- * "SKILL_SYSTEM_INSTRUCTION": "You are a skill synthesizer. You analyze work patterns, retrieval results, and conversation learnings to produce reusable procedural documents.\n\nGuidelines:\n- Create well-structured markdown with clear headings and numbered steps\n- Focus on reproducible procedures, not one-off observations\n- Include decision criteria, checklists, and edge cases where relevant\n- Be specific and actionable another agent should be able to follow this skill\n- Ground everything in the provided context, do not invent information",
1574
- * "MEMORY_SYSTEM_INSTRUCTION": "You are a knowledge recorder. You distill factual findings, preferences, and observations into concise reference documents.\n\nOutput format — use this markdown structure:\n```\n# [Descriptive Title]\n\n**Date:** [date from context]\n**Source:** [user query or conversation topic]\n\n## Key Findings\n[bullet points of facts learned]\n\n## Source Documents\n[list any document names referenced in the learnings]\n```\n\nGuidelines:\n- Record facts and observations, not procedures\n- Be concise — this is a reference document, not an essay\n- Always include the date and source query prominently\n- List source documents when learnings reference specific files\n- Distinguish between confirmed facts and inferences",
1642
+ * "SYSTEM_INSTRUCTION": "You are a knowledge synthesizer. You receive the full agent scratchpad from a completed conversation and decide what, if anything, is worth saving.\n\n## Artifact Types\n- **\"memory\"**: Facts, findings, reference data for *looking up* information.\n- **\"skill\"**: Procedures, workflows, step-by-step instructions — for *doing* something.\n\nWhen ambiguous, default to memory.\n\n## Rules\n- Return an empty artifacts array if the conversation is trivial or produced nothing substantive.\n- Each artifact must cover ONE coherent topic. Never combine disparate subjects into a single artifact — create separate artifacts for each distinct topic.\n- Ground everything in the provided context. Do not invent information.\n- Be concise. These are reference documents, not essays.\n\n## Output Format\nJSON with an `artifacts` array. Each item has `wp_type`, `title`, and `content` (markdown).\n\nMemory content: `# Title`, date, source, key findings as bullets, source documents.\nSkill content: `# Title`, prerequisites, numbered steps, when to apply.",
1575
1643
  * "TEMPERATURE": 0.3,
1576
- * "MAX_TOKENS": 4000,
1644
+ * "MAX_TOKENS": 8000,
1577
1645
  * "MAX_CHAR_CONTEXT": 100000,
1578
1646
  * "MAX_CONCURRENT": 5
1579
1647
  * }
@@ -1672,45 +1740,29 @@ interface components {
1672
1740
  */
1673
1741
  ENABLED: boolean;
1674
1742
  /**
1675
- * Skill System Instruction
1676
- * @description System instruction for skill synthesis.
1677
- * @default You are a skill synthesizer. You analyze work patterns, retrieval results, and conversation learnings to produce reusable procedural documents.
1678
- *
1679
- * Guidelines:
1680
- * - Create well-structured markdown with clear headings and numbered steps
1681
- * - Focus on reproducible procedures, not one-off observations
1682
- * - Include decision criteria, checklists, and edge cases where relevant
1683
- * - Be specific and actionable — another agent should be able to follow this skill
1684
- * - Ground everything in the provided context, do not invent information
1685
- */
1686
- SKILL_SYSTEM_INSTRUCTION: string;
1687
- /**
1688
- * Memory System Instruction
1689
- * @description System instruction for memory synthesis.
1690
- * @default You are a knowledge recorder. You distill factual findings, preferences, and observations into concise reference documents.
1743
+ * System Instruction
1744
+ * @description System instruction for artifact classification and synthesis.
1745
+ * @default You are a knowledge synthesizer. You receive the full agent scratchpad from a completed conversation and decide what, if anything, is worth saving.
1691
1746
  *
1692
- * Output format — use this markdown structure:
1693
- * ```
1694
- * # [Descriptive Title]
1747
+ * ## Artifact Types
1748
+ * - **"memory"**: Facts, findings, reference data — for *looking up* information.
1749
+ * - **"skill"**: Procedures, workflows, step-by-step instructions — for *doing* something.
1695
1750
  *
1696
- * **Date:** [date from context]
1697
- * **Source:** [user query or conversation topic]
1751
+ * When ambiguous, default to memory.
1698
1752
  *
1699
- * ## Key Findings
1700
- * [bullet points of facts learned]
1753
+ * ## Rules
1754
+ * - Return an empty artifacts array if the conversation is trivial or produced nothing substantive.
1755
+ * - Each artifact must cover ONE coherent topic. Never combine disparate subjects into a single artifact — create separate artifacts for each distinct topic.
1756
+ * - Ground everything in the provided context. Do not invent information.
1757
+ * - Be concise. These are reference documents, not essays.
1701
1758
  *
1702
- * ## Source Documents
1703
- * [list any document names referenced in the learnings]
1704
- * ```
1759
+ * ## Output Format
1760
+ * JSON with an `artifacts` array. Each item has `wp_type`, `title`, and `content` (markdown).
1705
1761
  *
1706
- * Guidelines:
1707
- * - Record facts and observations, not procedures
1708
- * - Be concise — this is a reference document, not an essay
1709
- * - Always include the date and source query prominently
1710
- * - List source documents when learnings reference specific files
1711
- * - Distinguish between confirmed facts and inferences
1762
+ * Memory content: `# Title`, date, source, key findings as bullets, source documents.
1763
+ * Skill content: `# Title`, prerequisites, numbered steps, when to apply.
1712
1764
  */
1713
- MEMORY_SYSTEM_INSTRUCTION: string;
1765
+ SYSTEM_INSTRUCTION: string;
1714
1766
  /**
1715
1767
  * Temperature
1716
1768
  * @description Temperature for synthesis.
@@ -1720,7 +1772,7 @@ interface components {
1720
1772
  /**
1721
1773
  * Max Tokens
1722
1774
  * @description Maximum tokens for artifact content.
1723
- * @default 4000
1775
+ * @default 8000
1724
1776
  */
1725
1777
  MAX_TOKENS: number;
1726
1778
  /**
@@ -2651,6 +2703,20 @@ interface components {
2651
2703
  /** Detail */
2652
2704
  detail: string;
2653
2705
  };
2706
+ /** McpToolInfo */
2707
+ McpToolInfo: {
2708
+ /** Name */
2709
+ name: string;
2710
+ /** Description */
2711
+ description: string;
2712
+ /** Server Name */
2713
+ server_name: string;
2714
+ };
2715
+ /** McpToolsResponse */
2716
+ McpToolsResponse: {
2717
+ /** Tools */
2718
+ tools: components['schemas']['McpToolInfo'][];
2719
+ };
2654
2720
  /** MessageDeleteResponse */
2655
2721
  MessageDeleteResponse: {
2656
2722
  /**
@@ -5873,6 +5939,26 @@ interface operations {
5873
5939
  };
5874
5940
  };
5875
5941
  };
5942
+ get_mcp_tools: {
5943
+ parameters: {
5944
+ query?: never;
5945
+ header?: never;
5946
+ path?: never;
5947
+ cookie?: never;
5948
+ };
5949
+ requestBody?: never;
5950
+ responses: {
5951
+ /** @description Successful Response */
5952
+ 200: {
5953
+ headers: {
5954
+ [name: string]: unknown;
5955
+ };
5956
+ content: {
5957
+ 'application/json': components['schemas']['McpToolsResponse'];
5958
+ };
5959
+ };
5960
+ };
5961
+ };
5876
5962
  create_tag: {
5877
5963
  parameters: {
5878
5964
  query?: never;
package/dist/index.d.ts CHANGED
@@ -1038,6 +1038,26 @@ interface paths {
1038
1038
  patch?: never;
1039
1039
  trace?: never;
1040
1040
  };
1041
+ '/api/health/mcp-tools': {
1042
+ parameters: {
1043
+ query?: never;
1044
+ header?: never;
1045
+ path?: never;
1046
+ cookie?: never;
1047
+ };
1048
+ /**
1049
+ * Get Mcp Tools
1050
+ * @description Returns available MCP tools registered on the LiteLLM proxy.
1051
+ */
1052
+ get: operations['get_mcp_tools'];
1053
+ put?: never;
1054
+ post?: never;
1055
+ delete?: never;
1056
+ options?: never;
1057
+ head?: never;
1058
+ patch?: never;
1059
+ trace?: never;
1060
+ };
1041
1061
  '/api/tag/': {
1042
1062
  parameters: {
1043
1063
  query?: never;
@@ -1288,24 +1308,32 @@ interface components {
1288
1308
  * @description A single agent step with a sequential index.
1289
1309
  *
1290
1310
  * Tool call steps have a detail list; lifecycle steps have a step string.
1311
+ * The focus field carries the agent's current focus: what it's zeroing in on.
1312
+ * The content field carries extended text (e.g. the research plan).
1291
1313
  *
1292
1314
  * Examples:
1293
- * {"type": "agent_step", "index": 1, "detail": [
1315
+ * {"type": "agent_step", "index": 1, "step": "planning",
1316
+ * "content": "1. Search for force majeure clauses across all three contracts\n2. Compare scope and exclusions"}
1317
+ * {"type": "agent_step", "index": 2,
1318
+ * "focus": "Searching for force majeure clauses across the selected contracts.",
1319
+ * "detail": [
1294
1320
  * {"tool": "search_documents", "query": "force majeure", "search_mode": "hybrid"},
1295
1321
  * {"tool": "get_table_of_contents", "doc_count": 2}
1296
1322
  * ]}
1297
- * {"type": "agent_step", "index": 2, "detail": [
1323
+ * {"type": "agent_step", "index": 3,
1324
+ * "focus": "Comparing the provisions found in Contract A with Contract B.",
1325
+ * "detail": [
1298
1326
  * {"tool": "get_document_passages", "doc_ext_id": "doc-abc12345", "from_ref": "5", "to_ref": "8"}
1299
1327
  * ]}
1300
- * {"type": "agent_step", "index": 3, "detail": [
1301
- * {"tool": "web_search", "query": "latest arbitration developments 2026"}
1302
- * ]}
1303
1328
  * {"type": "agent_step", "index": 4, "step": "evaluation", "detail": [
1304
1329
  * {"statement": "Newton prosecuted 28 coiners", "chunk_ids": ["chunk-abc"]},
1305
1330
  * {"statement": "Counterfeiting was high treason", "chunk_ids": ["chunk-def"]}
1306
1331
  * ]}
1307
- * {"type": "agent_step", "index": 5, "step": "answering"}
1308
- * {"type": "agent_step", "index": 6, "step": "reviewing"}
1332
+ * {"type": "agent_step", "index": 5, "step": "tool_progress", "detail": [
1333
+ * {"tool": "read_urls", "message": "Fetching 2 pages"}
1334
+ * ]}
1335
+ * {"type": "agent_step", "index": 6, "step": "answering"}
1336
+ * {"type": "agent_step", "index": 7, "step": "reviewing"}
1309
1337
  */
1310
1338
  AgentStepEvent: {
1311
1339
  /**
@@ -1321,9 +1349,19 @@ interface components {
1321
1349
  index: number;
1322
1350
  /**
1323
1351
  * Step
1324
- * @description Lifecycle step (answering, reviewing). Absent for tool calls.
1352
+ * @description Lifecycle step (planning, answering, reviewing). Absent for tool calls.
1325
1353
  */
1326
1354
  step?: string | null;
1355
+ /**
1356
+ * Focus
1357
+ * @description Agent's current focus (single sentence). Present on tool call steps.
1358
+ */
1359
+ focus?: string | null;
1360
+ /**
1361
+ * Content
1362
+ * @description Extended text content (e.g. research plan). Present on planning step.
1363
+ */
1364
+ content?: string | null;
1327
1365
  /**
1328
1366
  * Detail
1329
1367
  * @description Tool calls list. Each entry has 'tool' key plus tool-specific params.
@@ -1351,10 +1389,34 @@ interface components {
1351
1389
  HUMAN_IN_THE_LOOP: boolean;
1352
1390
  /**
1353
1391
  * Web Search
1354
- * @description Enable the web_search tool for searching the web.
1392
+ * @description Enable web tools: web_search (find URLs) and read_url (fetch and process webpages).
1355
1393
  * @default false
1356
1394
  */
1357
1395
  WEB_SEARCH: boolean;
1396
+ /**
1397
+ * Mcp Tools
1398
+ * @description MCP tool names to enable from LiteLLM (e.g. ['read_wiki_contents', 'ask_question']).
1399
+ * @default []
1400
+ */
1401
+ MCP_TOOLS: string[];
1402
+ /**
1403
+ * Planning Enabled
1404
+ * @description Run a planning step before the first agent decision. The agent generates a text plan that guides subsequent tool calls.
1405
+ * @default false
1406
+ */
1407
+ PLANNING_ENABLED: boolean;
1408
+ /**
1409
+ * Planning Approval
1410
+ * @description When planning is enabled, pause after generating the plan to allow the user to approve, skip, or comment before proceeding. Requires PLANNING_ENABLED=True to have any effect.
1411
+ * @default false
1412
+ */
1413
+ PLANNING_APPROVAL: boolean;
1414
+ /**
1415
+ * Suggested Queries
1416
+ * @description Generate a single suggested follow-up query after each response.
1417
+ * @default false
1418
+ */
1419
+ SUGGESTED_QUERIES: boolean;
1358
1420
  /**
1359
1421
  * Persona
1360
1422
  * @description Agent persona prepended to the system prompt. Customise to change the agent's identity and tone.
@@ -1411,6 +1473,8 @@ interface components {
1411
1473
  * - get_document_passages: Read specific pages from a document
1412
1474
  * - get_table_of_contents: Get headings and page references for documents
1413
1475
  * - web_search: Search the web for current/external information
1476
+ * - read_urls: Fetch and index webpages. Always call immediately after web_search
1477
+ * with the 2-3 most relevant URLs. Then use search_documents to query them.
1414
1478
  * - ask_user: Ask the user a clarifying question with structured options.
1415
1479
  * You MUST call this tool to ask the user anything — do NOT write questions
1416
1480
  * or options as plain text. Only the tool delivers the question to the user.
@@ -1423,7 +1487,8 @@ interface components {
1423
1487
  * 1. PARALLEL CALLS: When a query has multiple aspects, call multiple tools in parallel (e.g., search different keywords simultaneously)
1424
1488
  * 2. AVOID DUPLICATION: Before searching, review learnings from previous results. Do not repeat searches for information you already have
1425
1489
  * 3. TARGETED SEARCHES: Use specific, focused queries rather than broad ones
1426
- * 4. STOP WHEN READY: Provide your answer when you have sufficient evidence. Signs you have enough:
1490
+ * 4. BROAD PASSAGE RANGES: When using get_document_passages, request broad ranges (5-10+ pages per call). A few large fetches are far better than many small ones
1491
+ * 5. STOP WHEN READY: Provide your answer when you have sufficient evidence. Signs you have enough:
1427
1492
  * - Multiple sources confirm the same facts
1428
1493
  * - Key questions from the query are addressed
1429
1494
  * - Additional searches return redundant information
@@ -1448,6 +1513,10 @@ interface components {
1448
1513
  * "ENABLED": true,
1449
1514
  * "HUMAN_IN_THE_LOOP": true,
1450
1515
  * "WEB_SEARCH": false,
1516
+ * "MCP_TOOLS": [],
1517
+ * "PLANNING_ENABLED": false,
1518
+ * "PLANNING_APPROVAL": false,
1519
+ * "SUGGESTED_QUERIES": false,
1451
1520
  * "PERSONA": "You are ARBI, an AI assistant created by ARBI CITY.\n\nYou maintain formal, objective tone appropriate for professional/legal contexts. If any part of the answer is based on general knowledge instead of the supplied sources, you must state so clearly and recognise that it may not be accurate.",
1452
1521
  * "AGENT_MODEL_NAME": "Q3VL@ARBICITY",
1453
1522
  * "AGENT_API_TYPE": "remote",
@@ -1455,7 +1524,7 @@ interface components {
1455
1524
  * "AGENT_MAX_TOKENS": 20000,
1456
1525
  * "AGENT_MAX_ITERATIONS": 10,
1457
1526
  * "AGENT_HISTORY_CHAR_THRESHOLD": 8000,
1458
- * "AGENT_SYSTEM_PROMPT": "YOUR TASK:\nDetermine which, if any, of the available documents contain information relevant to the user's query. Use your tools to retrieve and examine document content.\n\nTOOLS AVAILABLE:\n- search_documents: Search for relevant passages across documents\n- get_document_passages: Read specific pages from a document\n- get_table_of_contents: Get headings and page references for documents\n- web_search: Search the web for current/external information\n- ask_user: Ask the user a clarifying question with structured options.\n You MUST call this tool to ask the user anything — do NOT write questions\n or options as plain text. Only the tool delivers the question to the user.\n IMPORTANT: Once the user responds, do NOT ask the same question again.\n Use their answer and proceed with research. If the user's answer is\n unexpected (e.g. refers to something not in the documents), explain what\n you found and answer based on available information.\n\nEFFICIENCY GUIDELINES:\n1. PARALLEL CALLS: When a query has multiple aspects, call multiple tools in parallel (e.g., search different keywords simultaneously)\n2. AVOID DUPLICATION: Before searching, review learnings from previous results. Do not repeat searches for information you already have\n3. TARGETED SEARCHES: Use specific, focused queries rather than broad ones\n4. STOP WHEN READY: Provide your answer when you have sufficient evidence. Signs you have enough:\n - Multiple sources confirm the same facts\n - Key questions from the query are addressed\n - Additional searches return redundant information\n\nWORKFLOW:\n1. Analyze the query to identify distinct information needs\n2. Execute parallel searches for different aspects when appropriate\n3. Evaluate results - extract learnings, note gaps\n4. Only search again if specific gaps remain unfilled\n5. Answer when confident (no tool call) - do not over-research\n\nIMPORTANT:\n- The document index contains metadata only - you must retrieve actual content\n- Do not add inline citation markers - the system handles citations automatically"
1527
+ * "AGENT_SYSTEM_PROMPT": "YOUR TASK:\nDetermine which, if any, of the available documents contain information relevant to the user's query. Use your tools to retrieve and examine document content.\n\nTOOLS AVAILABLE:\n- search_documents: Search for relevant passages across documents\n- get_document_passages: Read specific pages from a document\n- get_table_of_contents: Get headings and page references for documents\n- web_search: Search the web for current/external information\n- read_urls: Fetch and index webpages. Always call immediately after web_search\n with the 2-3 most relevant URLs. Then use search_documents to query them.\n- ask_user: Ask the user a clarifying question with structured options.\n You MUST call this tool to ask the user anything — do NOT write questions\n or options as plain text. Only the tool delivers the question to the user.\n IMPORTANT: Once the user responds, do NOT ask the same question again.\n Use their answer and proceed with research. If the user's answer is\n unexpected (e.g. refers to something not in the documents), explain what\n you found and answer based on available information.\n\nEFFICIENCY GUIDELINES:\n1. PARALLEL CALLS: When a query has multiple aspects, call multiple tools in parallel (e.g., search different keywords simultaneously)\n2. AVOID DUPLICATION: Before searching, review learnings from previous results. Do not repeat searches for information you already have\n3. TARGETED SEARCHES: Use specific, focused queries rather than broad ones\n4. BROAD PASSAGE RANGES: When using get_document_passages, request broad ranges (5-10+ pages per call). A few large fetches are far better than many small ones\n5. STOP WHEN READY: Provide your answer when you have sufficient evidence. Signs you have enough:\n - Multiple sources confirm the same facts\n - Key questions from the query are addressed\n - Additional searches return redundant information\n\nWORKFLOW:\n1. Analyze the query to identify distinct information needs\n2. Execute parallel searches for different aspects when appropriate\n3. Evaluate results - extract learnings, note gaps\n4. Only search again if specific gaps remain unfilled\n5. Answer when confident (no tool call) - do not over-research\n\nIMPORTANT:\n- The document index contains metadata only - you must retrieve actual content\n- Do not add inline citation markers - the system handles citations automatically"
1459
1528
  * }
1460
1529
  */
1461
1530
  Agents: components['schemas']['AgentsConfig'];
@@ -1570,10 +1639,9 @@ interface components {
1570
1639
  * "API_TYPE": "remote",
1571
1640
  * "MODEL_NAME": "Q3VL@ARBICITY",
1572
1641
  * "ENABLED": true,
1573
- * "SKILL_SYSTEM_INSTRUCTION": "You are a skill synthesizer. You analyze work patterns, retrieval results, and conversation learnings to produce reusable procedural documents.\n\nGuidelines:\n- Create well-structured markdown with clear headings and numbered steps\n- Focus on reproducible procedures, not one-off observations\n- Include decision criteria, checklists, and edge cases where relevant\n- Be specific and actionable another agent should be able to follow this skill\n- Ground everything in the provided context, do not invent information",
1574
- * "MEMORY_SYSTEM_INSTRUCTION": "You are a knowledge recorder. You distill factual findings, preferences, and observations into concise reference documents.\n\nOutput format — use this markdown structure:\n```\n# [Descriptive Title]\n\n**Date:** [date from context]\n**Source:** [user query or conversation topic]\n\n## Key Findings\n[bullet points of facts learned]\n\n## Source Documents\n[list any document names referenced in the learnings]\n```\n\nGuidelines:\n- Record facts and observations, not procedures\n- Be concise — this is a reference document, not an essay\n- Always include the date and source query prominently\n- List source documents when learnings reference specific files\n- Distinguish between confirmed facts and inferences",
1642
+ * "SYSTEM_INSTRUCTION": "You are a knowledge synthesizer. You receive the full agent scratchpad from a completed conversation and decide what, if anything, is worth saving.\n\n## Artifact Types\n- **\"memory\"**: Facts, findings, reference data for *looking up* information.\n- **\"skill\"**: Procedures, workflows, step-by-step instructions — for *doing* something.\n\nWhen ambiguous, default to memory.\n\n## Rules\n- Return an empty artifacts array if the conversation is trivial or produced nothing substantive.\n- Each artifact must cover ONE coherent topic. Never combine disparate subjects into a single artifact — create separate artifacts for each distinct topic.\n- Ground everything in the provided context. Do not invent information.\n- Be concise. These are reference documents, not essays.\n\n## Output Format\nJSON with an `artifacts` array. Each item has `wp_type`, `title`, and `content` (markdown).\n\nMemory content: `# Title`, date, source, key findings as bullets, source documents.\nSkill content: `# Title`, prerequisites, numbered steps, when to apply.",
1575
1643
  * "TEMPERATURE": 0.3,
1576
- * "MAX_TOKENS": 4000,
1644
+ * "MAX_TOKENS": 8000,
1577
1645
  * "MAX_CHAR_CONTEXT": 100000,
1578
1646
  * "MAX_CONCURRENT": 5
1579
1647
  * }
@@ -1672,45 +1740,29 @@ interface components {
1672
1740
  */
1673
1741
  ENABLED: boolean;
1674
1742
  /**
1675
- * Skill System Instruction
1676
- * @description System instruction for skill synthesis.
1677
- * @default You are a skill synthesizer. You analyze work patterns, retrieval results, and conversation learnings to produce reusable procedural documents.
1678
- *
1679
- * Guidelines:
1680
- * - Create well-structured markdown with clear headings and numbered steps
1681
- * - Focus on reproducible procedures, not one-off observations
1682
- * - Include decision criteria, checklists, and edge cases where relevant
1683
- * - Be specific and actionable — another agent should be able to follow this skill
1684
- * - Ground everything in the provided context, do not invent information
1685
- */
1686
- SKILL_SYSTEM_INSTRUCTION: string;
1687
- /**
1688
- * Memory System Instruction
1689
- * @description System instruction for memory synthesis.
1690
- * @default You are a knowledge recorder. You distill factual findings, preferences, and observations into concise reference documents.
1743
+ * System Instruction
1744
+ * @description System instruction for artifact classification and synthesis.
1745
+ * @default You are a knowledge synthesizer. You receive the full agent scratchpad from a completed conversation and decide what, if anything, is worth saving.
1691
1746
  *
1692
- * Output format — use this markdown structure:
1693
- * ```
1694
- * # [Descriptive Title]
1747
+ * ## Artifact Types
1748
+ * - **"memory"**: Facts, findings, reference data — for *looking up* information.
1749
+ * - **"skill"**: Procedures, workflows, step-by-step instructions — for *doing* something.
1695
1750
  *
1696
- * **Date:** [date from context]
1697
- * **Source:** [user query or conversation topic]
1751
+ * When ambiguous, default to memory.
1698
1752
  *
1699
- * ## Key Findings
1700
- * [bullet points of facts learned]
1753
+ * ## Rules
1754
+ * - Return an empty artifacts array if the conversation is trivial or produced nothing substantive.
1755
+ * - Each artifact must cover ONE coherent topic. Never combine disparate subjects into a single artifact — create separate artifacts for each distinct topic.
1756
+ * - Ground everything in the provided context. Do not invent information.
1757
+ * - Be concise. These are reference documents, not essays.
1701
1758
  *
1702
- * ## Source Documents
1703
- * [list any document names referenced in the learnings]
1704
- * ```
1759
+ * ## Output Format
1760
+ * JSON with an `artifacts` array. Each item has `wp_type`, `title`, and `content` (markdown).
1705
1761
  *
1706
- * Guidelines:
1707
- * - Record facts and observations, not procedures
1708
- * - Be concise — this is a reference document, not an essay
1709
- * - Always include the date and source query prominently
1710
- * - List source documents when learnings reference specific files
1711
- * - Distinguish between confirmed facts and inferences
1762
+ * Memory content: `# Title`, date, source, key findings as bullets, source documents.
1763
+ * Skill content: `# Title`, prerequisites, numbered steps, when to apply.
1712
1764
  */
1713
- MEMORY_SYSTEM_INSTRUCTION: string;
1765
+ SYSTEM_INSTRUCTION: string;
1714
1766
  /**
1715
1767
  * Temperature
1716
1768
  * @description Temperature for synthesis.
@@ -1720,7 +1772,7 @@ interface components {
1720
1772
  /**
1721
1773
  * Max Tokens
1722
1774
  * @description Maximum tokens for artifact content.
1723
- * @default 4000
1775
+ * @default 8000
1724
1776
  */
1725
1777
  MAX_TOKENS: number;
1726
1778
  /**
@@ -2651,6 +2703,20 @@ interface components {
2651
2703
  /** Detail */
2652
2704
  detail: string;
2653
2705
  };
2706
+ /** McpToolInfo */
2707
+ McpToolInfo: {
2708
+ /** Name */
2709
+ name: string;
2710
+ /** Description */
2711
+ description: string;
2712
+ /** Server Name */
2713
+ server_name: string;
2714
+ };
2715
+ /** McpToolsResponse */
2716
+ McpToolsResponse: {
2717
+ /** Tools */
2718
+ tools: components['schemas']['McpToolInfo'][];
2719
+ };
2654
2720
  /** MessageDeleteResponse */
2655
2721
  MessageDeleteResponse: {
2656
2722
  /**
@@ -5873,6 +5939,26 @@ interface operations {
5873
5939
  };
5874
5940
  };
5875
5941
  };
5942
+ get_mcp_tools: {
5943
+ parameters: {
5944
+ query?: never;
5945
+ header?: never;
5946
+ path?: never;
5947
+ cookie?: never;
5948
+ };
5949
+ requestBody?: never;
5950
+ responses: {
5951
+ /** @description Successful Response */
5952
+ 200: {
5953
+ headers: {
5954
+ [name: string]: unknown;
5955
+ };
5956
+ content: {
5957
+ 'application/json': components['schemas']['McpToolsResponse'];
5958
+ };
5959
+ };
5960
+ };
5961
+ };
5876
5962
  create_tag: {
5877
5963
  parameters: {
5878
5964
  query?: never;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arbidocs/sdk",
3
- "version": "0.1.0",
3
+ "version": "0.3.1",
4
4
  "description": "TypeScript SDK for the ARBI API — zero-knowledge auth, E2E encryption, and type-safe REST client",
5
5
  "type": "module",
6
6
  "main": "dist/index.cjs",
@@ -22,11 +22,11 @@
22
22
  "typecheck": "tsc --noEmit"
23
23
  },
24
24
  "dependencies": {
25
- "libsodium-wrappers-sumo": "^0.7.15",
25
+ "libsodium-wrappers-sumo": "^0.8.0",
26
26
  "openapi-fetch": "^0.15.0"
27
27
  },
28
28
  "devDependencies": {
29
- "@types/libsodium-wrappers-sumo": "^0.7.8",
29
+ "@types/libsodium-wrappers-sumo": "^0.8.2",
30
30
  "fake-indexeddb": "^6.2.5",
31
31
  "tsup": "^8.4.0",
32
32
  "typescript": "^5.9.3",
@@ -38,8 +38,16 @@
38
38
  },
39
39
  "repository": {
40
40
  "type": "git",
41
- "url": "https://github.com/arbitrationcity/ARBI-frontend.git",
41
+ "url": "git+https://github.com/arbitrationcity/ARBI-frontend.git",
42
42
  "directory": "packages/arbi-api-client"
43
43
  },
44
- "keywords": ["arbi", "api", "sdk", "e2e-encryption", "zero-knowledge", "openapi", "typescript"]
44
+ "keywords": [
45
+ "arbi",
46
+ "api",
47
+ "sdk",
48
+ "e2e-encryption",
49
+ "zero-knowledge",
50
+ "openapi",
51
+ "typescript"
52
+ ]
45
53
  }