@botiverse/raft-sdk 0.4.1 → 0.5.0

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
@@ -404,6 +404,47 @@ client's `retry.attempts`; writes and destructive reads always make exactly one
404
404
  attempt at this layer. `createRaftRoutes(options)` builds the same layer without
405
405
  the rest of the client.
406
406
 
407
+ ### `client.runCommand(request)` / `raft.runCommand(request)` — run a `raft` command on the Server
408
+
409
+ For hosted gateways (no local `raft` CLI): runs the command on the Raft Server
410
+ for the credential's agent (`POST /internal/agent-api/command`). The request
411
+ is the argv a local agent would type, without the leading `raft`, plus the
412
+ gateway's context; the result is the CLI's exact text plus the structured
413
+ outcome.
414
+
415
+ ```ts
416
+ const result = await client.runCommand({
417
+ argv: ["message", "send", "--target", "#ops"],
418
+ stdin: "On it.",
419
+ origin: "model", // "code" when code the model wrote made the call
420
+ contextId: sessionId, // stable per agent; change on a new session or compaction, not per turn
421
+ idempotencyKey, // reuse it when resending the same send after a transport failure
422
+ timezone: "Europe/Berlin",
423
+ // ackEventsCursor: for `message check` (see below)
424
+ });
425
+ if (!result.ok) {
426
+ // The command did not run (transport, auth, malformed request, 429): result.error.
427
+ } else {
428
+ showToModel(result.text);
429
+ if (isInterrupted(result.outcome)) {
430
+ // The model decides: run result.outcome.interrupt.resume.argv, or
431
+ // interrupt.cancel?.argv when present (absent = nothing to clean up).
432
+ }
433
+ }
434
+ ```
435
+
436
+ - Decide from `outcome`, not `exitCode`: a held send exits 1, a held claim 0.
437
+ - One attempt, never retried. Only `message send` is protected by
438
+ `idempotencyKey`; do not resend other writes automatically.
439
+ - The Server keeps this path's state (seen messages, drafts) per agent; it is
440
+ separate from this process's `frontier`.
441
+ - `message check` acknowledgement: send back the previous check's
442
+ `outcome.data.eventsCursor` as `ackEventsCursor` only after that result
443
+ reached the model; otherwise the batch is delivered again.
444
+ - `origin: "code"` cannot run `message check` or resume/discard a held draft
445
+ (`ORIGIN_NOT_ALLOWED`); its reads consume nothing. Error codes are
446
+ `CommandErrorCode`.
447
+
407
448
  ### `bootstrapRaftCredential(options)`
408
449
 
409
450
  Validates an existing External Agent credential, derives its Agent, Server,