@verentis/sdk 0.2.6 → 1.0.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
@@ -13,9 +13,9 @@ npm install @verentis/sdk
13
13
  ### Consented Marketplace installation graphs
14
14
 
15
15
  Installation administration uses a **workspace-bound user token**, not an iframe's delegated
16
- app token or an API key. The token needs `marketplace.install.create` for preview/install and
17
- `marketplace.install.read` for outcomes, plus the Node/Resource installer scopes documented by
18
- Marketplace. Explicit recovery also needs `marketplace.install.update` and `node.file.delete`.
16
+ app token or an API key. The token needs `installation.write` for install, `installation.read` for preview and
17
+ outcomes, plus the Node/Resource installer scopes documented by
18
+ Marketplace. Explicit recovery also needs `installation.write` and `file.delete`.
19
19
 
20
20
  ```ts
21
21
  const preview = await client.installations.preview(invoicingPackageId, {
@@ -56,16 +56,14 @@ const save = client.bridge!.registerAction({
56
56
  label: 'Save',
57
57
  icon: 'lucide:save',
58
58
  variant: 'default',
59
- scopes: ['node.file.read', 'node.node.create', 'node.node.update', 'node.journal.create'],
59
+ scopes: ['file.read', 'file.write'],
60
60
  enabled: false,
61
61
  }, async () => {
62
62
  await persistDocument()
63
63
  })
64
64
 
65
65
  // Pass the complete descriptor when document state changes.
66
- save.update({ id: 'document.save', label: 'Save', scopes: [
67
- 'node.file.read', 'node.node.create', 'node.node.update', 'node.journal.create',
68
- ], enabled: true })
66
+ save.update({ id: 'document.save', label: 'Save', scopes: ['file.read', 'file.write'], enabled: true })
69
67
  save.dispose()
70
68
  ```
71
69
 
@@ -171,7 +169,7 @@ Content-Type: application/x-www-form-urlencoded
171
169
  grant_type=urn:ietf:params:oauth:grant-type:token-exchange
172
170
  &subject_token=<forwarded access token>
173
171
  &subject_token_type=urn:ietf:params:oauth:token-type:access_token
174
- &scope=node.file.read
172
+ &scope=file.read
175
173
  ```
176
174
 
177
175
  The issued token carries an `act` claim naming the backend client. Add
@@ -221,6 +219,10 @@ const started = await client.executions.run('/scripts/report.py')
221
219
  const current = await client.executions.get(started.id)
222
220
  const logs = await client.executions.logs(started.id)
223
221
  await client.executions.cancel(started.id)
222
+
223
+ // Scripts that declare their arguments export `<script>.arguments.json`; read it to build a form.
224
+ // Runs never prompt: missing or invalid arguments fail with a validation error.
225
+ const declared = await client.executions.getArguments('/scripts/report.py') // null when none are declared
224
226
  ```
225
227
 
226
228
 
@@ -293,11 +295,42 @@ contracts must not assume a locally present feature-branch API is already deploy
293
295
  | `BridgeAuth` | Auth strategy that receives tokens via the bridge |
294
296
  | `matchMimeType` / `findBestMatch` | MIME type matching utilities |
295
297
 
298
+ ### Chat
299
+
300
+ `client.chat` is the documented workspace chat API (`/v1/chat`). The caller and workspace always come from the
301
+ token; message content is untrusted Markdown that readers render without raw HTML.
302
+
303
+ ```ts
304
+ const conversation = await client.chat.openDirect({ kind: 'user', id: colleagueId })
305
+ await client.chat.sendText(conversation.id, 'Hi **there**', { idempotencyKey: crypto.randomUUID() })
306
+
307
+ // Inside the workspace (needs the approved `chat.read` permission): identifier-only live hints over the
308
+ // host's realtime connection. Hints can be lost or repeated, so catch up from durable events.
309
+ const stop = client.chat.subscribeChanges({
310
+ onChange: async (hint) => {
311
+ const page = await client.chat.events(hint.conversationId, { afterSeq: lastAppliedSeq })
312
+ // apply page.items; if page.resetRequired, reload the conversation and its history
313
+ },
314
+ onConnection: (status) => { if (status === 'connected') void reconcile() },
315
+ })
316
+
317
+ // From an installed app's script: post as the app's bot (declared in `spec.chat.bots`). A command script receives
318
+ // chat_conversation_id and chat_invocation_key with its arguments; reusing the key makes a retried run reply once.
319
+ await client.chat.postAsBot({
320
+ conversationId: params.chat_conversation_id,
321
+ parts: [{ type: 'text', data: { markdown: 'Invoice 42 needs approval' } }],
322
+ idempotencyKey: params.chat_invocation_key,
323
+ })
324
+
325
+ // Run an installed app's slash command as the current user.
326
+ await client.chat.runCommand(conversationId, 'invoicing/approve-invoice', { invoice: 'INV-42' })
327
+ ```
328
+
296
329
  ### Workspace settings
297
330
 
298
331
  Apps whose manifest declares `spec.settings[]` get workspace setting definitions auto-registered
299
332
  (namespaced `{manifest-name}.{key}`). Read them with the settings module — the app token needs the
300
- `fabric.setting.read` / `fabric.setting.read-all` permissions from `spec.permissions`:
333
+ `setting.read` permission from `spec.permissions`:
301
334
 
302
335
  ```ts
303
336
  const settings = client.settings.namespaced('my-app')