@getmodus/sdk 0.8.0 → 0.10.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/CHANGELOG.md +189 -0
- package/README.md +182 -14
- package/dist/{conversations-COA6NW8I.d.cts → _client-base-H5rt5EGy.d.cts} +3789 -972
- package/dist/{conversations-COA6NW8I.d.ts → _client-base-H5rt5EGy.d.ts} +3789 -972
- package/dist/{chunk-GFS7CNON.js → chunk-BMYCORZF.js} +656 -325
- package/dist/chunk-BMYCORZF.js.map +1 -0
- package/dist/chunk-NA3ZD35T.cjs +2666 -0
- package/dist/chunk-NA3ZD35T.cjs.map +1 -0
- package/dist/index.cjs +722 -2870
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +743 -497
- package/dist/index.d.ts +743 -497
- package/dist/index.js +601 -434
- package/dist/index.js.map +1 -1
- package/dist/management/index.cjs +1293 -3126
- package/dist/management/index.cjs.map +1 -1
- package/dist/management/index.d.cts +867 -436
- package/dist/management/index.d.ts +867 -436
- package/dist/management/index.js +1110 -680
- package/dist/management/index.js.map +1 -1
- package/package.json +15 -8
- package/dist/chunk-GFS7CNON.js.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -9,8 +9,195 @@ release, including pre-1.0 (`0.x`) releases.
|
|
|
9
9
|
|
|
10
10
|
## [Unreleased]
|
|
11
11
|
|
|
12
|
+
## [0.10.0] — 2026-11-08
|
|
13
|
+
|
|
14
|
+
### Added
|
|
15
|
+
|
|
16
|
+
- **`generatedDescription` on a scope.** Scope reads include `generatedDescription` (`string | null`), the summary written for the scope so a caller can choose it. Null when none has been written.
|
|
17
|
+
- **Breaking (pre-1.0): `SupervisionView`.** `mgmt.scopes.supervision(id).get({ view })` takes `SupervisionView` (`'active' | 'draft'`). `published` is not a supervision view. `VariationView` now also allows `'published'`, so a value typed as `VariationView` no longer type-checks there. Migration: type it as `SupervisionView`. Runtime values are unchanged.
|
|
18
|
+
- **`view: 'published'` on scope and workflow list and get.** Returns the published version you can use. A scope or workflow that is only a draft, deleted, or that you can manage but not use is left out. For workflows it is also type workflow only; a task is left out. `active` and `draft` are unchanged.
|
|
19
|
+
- **`scopes.applySelectionOps()`.** Apply selection changes to a scope. Pass `{ validateOnly: true }` to run the same checks and return the scope that would be saved, without writing. A preview result carries `validateOnly: true`; a committed one does not, and every other field keeps its stored value, so a preview still needs a second call to save. Send `setConnectionPreferences`. `selectRoot`, `deselectRoot`, and `setRootDeepRules` are deprecated.
|
|
20
|
+
- **`claude-haiku-5.5` model.** Anthropic's Claude Haiku 5.5 is an accepted chat model id.
|
|
21
|
+
- **`gemini-3.8-flash` model.** Google's generally available Gemini 3.8 Flash is an accepted chat
|
|
22
|
+
model id.
|
|
23
|
+
- **`mgmt.scopes.mcpExposureCatalog(scopeId, request)`.** Lists the tools a scope can expose to MCP clients. A field you send replaces the current draft for this call; a field you omit stays as stored. Nothing is saved. Rows you cannot access are left out, and stored selections on them are counted. `McpExposureCatalogRequest` and `McpExposureCatalog` import from `@getmodus/sdk/management`.
|
|
24
|
+
- **Every type a public method takes or returns is exported.** The resource classes (`WorkflowRunsResource`, `ManagementScopesResource`, …), `ModusConfig`, the custom context item inputs and results (`CreateCustomContextItemInput`, `CreatedCustomContextItem`, …), and the evaluation, usage, interface, supervision and user types import from `@getmodus/sdk` or `@getmodus/sdk/management`, so a variable that holds a result can be annotated.
|
|
25
|
+
- **`access` on custom context item creates.** `context.customItems.create()` and `batchCreate()` inputs take `access` (`scope`, `groupIds`, `userIds`), which the endpoint already accepted. Omitted, everyone in the organization can see the item; to change it, delete and re-create the item.
|
|
26
|
+
- **A trace id for every call.** Each request sends a W3C `traceparent` (a new trace per call, kept across its retries, each re-send also carrying `X-Modus-Retry-Attempt`), and every `ModusError` from an HTTP call carries it as `traceId`. Quote `traceId` with `requestId` to support: it also names a call that never reached Modus. A `traceparent` you set in `defaultHeaders` is sent as is.
|
|
27
|
+
- **`access` on file finalize and URL uploads.** `FinalizeUploadDto`, each `BulkFinalizeItemDto`, `UploadFromUrlDto` and each `BulkUploadFromUrlItemDto` take an optional `access` (visibility, group permissions, shared-with) that applies only when the file is first created; omitted, the file is shared with everyone with you as owner. A service-account token cannot set it.
|
|
28
|
+
- **Access on notes, saved queries, links and uploaded files.** `mgmt.context.items.updateAccess(uid, { visibility, groupPermissions, sharedWith })` replaces who can view and manage one of these items; an item with no owner becomes yours. `ContextItem` reads of these types carry `access` and `canManage`.
|
|
29
|
+
- **Resume a dropped run stream.** Every run event, `approval_required` included, carries `id`, its SSE event id (`RunEventBase`), when the server sends one, so `runs.stream(runId, { lastEventId: event.id })` resumes after that event instead of replaying the run from the start.
|
|
30
|
+
- **`ErrorEvent.requestId`.** A run that fails after it started ends with an `error` event that carries the id to quote to support; a chat stream throws `ModusError` with it as `requestId`.
|
|
31
|
+
- **`client.workflows.chat()`.** Send a published workflow a message and stream its node output; `await` it for the workflow's final output.
|
|
32
|
+
- **`AssistantContentResetEvent.subAgent`** marks a correction to a sub-agent's output; a reset without it corrects the assistant's own reply.
|
|
33
|
+
- **Approvals on chat.** A run that stops for a write approval returns `result.approval`; `chat.resume({ decision: 'approve' | 'deny' })` continues the same conversation.
|
|
34
|
+
- **Connection selection preferences on scopes.** A `connectionSet` entry on create and update takes
|
|
35
|
+
`preferences` (`mode` `all` or `manual`, `include` / `exclude` rules of id steps); reads return
|
|
36
|
+
`preferences` on the connection's first row.
|
|
37
|
+
- **`deepseek-v4.1-flash-1017` model.** The October 17, 2026 snapshot of DeepSeek V4.1 Flash is an
|
|
38
|
+
accepted chat model id.
|
|
39
|
+
- **`BadRequestError`** for HTTP 400 (a schema or parse failure), a `ModusError` subclass, so
|
|
40
|
+
existing `catch (e instanceof ModusError)` code is unaffected.
|
|
41
|
+
- **`ModusError.info`** carries the error envelope's structured detail, for example
|
|
42
|
+
`info.missing` (the token scopes a 403 lacks) or `info.violations` on a 422.
|
|
43
|
+
- **`ModusError.retryable`** says whether the SDK's retry rule allowed re-sending the failed call.
|
|
44
|
+
- **`Retry-After` as an HTTP date, and `retry-after-ms`,** fill `RateLimitError.retryAfter`.
|
|
45
|
+
- **An organization owner can give an ownerless scope an owner.** A scope created with a service-account token has no owner. `scopes.requestOwnershipTransfer(id, { newOwnerUserId })` by an organization owner now assigns one: naming yourself takes effect at once, naming another member waits for them to accept. `scopes.cancelOwnershipTransfer(id)` lets the organization owner withdraw that request.
|
|
46
|
+
|
|
47
|
+
### Changed
|
|
48
|
+
|
|
49
|
+
- **Breaking (pre-1.0): MCP tool exposure keys name a connection (CU-z93r0b9hub).** In `mcpToolExposure.allowedIntegrationKeys`, `toolset:<connectionId>` exposes every tool granted on that connection, now and later, and never another connection's; `toolset_action:<platform>:<connectionId>:<action>` exposes one tool, a SQL connection's query tool included (`toolset_action:postgresql:<connectionId>:query`). `toolset:<platform>`, `data_connection:<connectionId>` and `data_connection_tool:` keys are retired: a stored `toolset:<platform>` key became the `toolset:<connectionId>` key of each connection the scope grants on that platform, a stored `data_connection:` key on a SQL connection became that connection's `toolset:<connectionId>`, and a retired key naming no such connection was removed, and a write adding one returns 422. `mcpExposureCatalog` lists one row per connection, and `McpExposureFamily` no longer has `data_connection`.
|
|
50
|
+
- **`workflows.runs.events()` returns `RunEventsPollResponse`** instead of `unknown`: `events` (each with its stream `id` and `type`), `cursor`, `status` and `done`. The response is unchanged.
|
|
51
|
+
- **A numeric id that is not a whole number throws `ValidationError` before any request.** `1.5`, `NaN` or `Infinity` as a scope, workflow or other numeric id was sent, and the server answered 400.
|
|
52
|
+
- **Breaking (pre-1.0): the `access` body on note, saved-query and link creates is dashboard-shaped.** The generated `CreateNoteDto`, `CreateSavedQueryDto` and `CreateLinkDto` types now take `access` as `UpdateContextItemAccessDto` (`visibility`, `groupPermissions`, `sharedWith`, the body `mgmt.context.items.updateAccess` takes) instead of `AccessPolicyDto` (`scope`, `groupIds`, `userIds`); the old shape is rejected with 400. Omitting `access` shares the item with everyone in the organization, with you as owner. `createNote`, `createSavedQuery` and `createLink` send no `access` and are unchanged.
|
|
53
|
+
- **Context compose no longer fails at 30 seconds.** `scopes.getContext()` and `modus.getContext()` now call `POST /agent/v1/scopes/{id}/context` and `POST /agent/v1/modus/context` on the agent host, the host `chat()` uses. The old routes sat behind a 30-second gateway limit, so a slower compose came back as a bare 503 and was retried up to twice more while the first one was still running. Same arguments and result; a compose may now run for up to 90 seconds, and one still running then fails with `UPSTREAM_TIMEOUT` (504). Keep `timeoutMs` above 90 seconds (the default is 300). The agent host is derived the same way as for chat: `agentHost` (or `MODUS_AGENT_HOST`), else from `baseUrl`; with a custom `baseUrl` and neither set, compose throws `ModusError` before sending anything, as chat does. If your network allows only the API host, allow the agent host too.
|
|
54
|
+
- **A resume with nothing to answer raises `ConflictError`.** `runs.resume` on a conversation with no write approval or connection request pending now fails with HTTP 409 (`code` `CONFLICT`) before any event, and the conversation stays usable. It used to yield one error event and leave every later turn on that conversation failing.
|
|
55
|
+
- **A refused run raises before any event.** When the agent host refuses a run (an empty turn, a scope you cannot see, a conflicting `Idempotency-Key`, a full conversation queue), `runs.create*`, `runs.resume` and `workflowActions` streams now raise the typed error for the HTTP status (`NotFoundError`, `PermissionDeniedError`, `ConflictError`, `RateLimitError`, or `ModusError` with `statusCode` 400) with the server's `code` and message, instead of yielding one `error` event. No SDK code changed: the host now answers with the real status. An `error` event still ends a run that fails after it started.
|
|
56
|
+
- **Evaluation types are now accurate (were `Record<string, never>`).** `EvaluationRun` `finishedAt` and `avgScore`, and the result fields `actualOutput`, `passed`, `score`, `reasoning` and `wasPassingBefore`, are `string | null`, `number | null` or `boolean | null`, so they no longer need a cast. An evaluation recipient's `name` is `string | null`, and `slackUserIdByRecipient` is a string-keyed map. `startedAt` and `finishedAt` are ISO 8601 strings (the server sent a JavaScript date string before).
|
|
57
|
+
- **Run request types document the API-token rules.** `message` notes the 32,000-character limit the server holds API tokens to, and `config.model` lists the models an API token may send.
|
|
58
|
+
- **Breaking (pre-1.0): scope `connectionSet` rows have one shape.** `scopes.create` and `scopes.update` accept each entry only as `{ connection_id, path, preferences?, context_enabled? }`, where `path` is an array of strings, `preferences` an object and `context_enabled` a boolean. An empty path selects the whole connection. Any other field, a non-string path segment or an empty or null `connection_id` is rejected with 400; a null `connectionSet` clears the list. `variation.connectionSet` is now `{ connection_id: string; path: string[]; preferences?: Record<string, unknown>; context_enabled?: boolean }` instead of `Record<string, unknown>[]`.
|
|
59
|
+
- **Breaking (pre-1.0): workflow `guardrails` removed.** `workflows.create` and `workflows.update` no longer take `guardrails`. The workflow access configuration has no guardrails, so every call that set it failed with 400 and changed nothing. Scope `guardrails` are unchanged.
|
|
60
|
+
- **Breaking (pre-1.0): `scopes.memories(id).update()` returns `Promise<void>`.** The server answers 204 with no body; the method returned `null` typed as `Memory`.
|
|
61
|
+
- **Breaking (pre-1.0): `managerId` is `number | null`.** `scopes.update({ managerId })` takes the numeric id of the manager scope, or `null` to detach. It was typed `string`, which the server rejects with 400.
|
|
62
|
+
- **Breaking (pre-1.0): evaluation runs `pageSize` is checked.** `scopes.evaluations(id).listRuns()` rejects a `pageSize` outside 1..100 with 400, like every other list (it was clamped above 100).
|
|
63
|
+
- **Breaking (pre-1.0): a POST that fails after being sent now throws instead of being
|
|
64
|
+
re-sent.** Retries depend on the method: GET, PUT, PATCH and DELETE retry 408, 429, 500, 502,
|
|
65
|
+
503, 504, dropped connections and timeouts. A POST retries only on 429 or a connection that
|
|
66
|
+
never opened, except the POSTs that only read or set a state (context compose, item lookup, memory search, active-run lookup, run cancel, run interrupt, workflow-action cancel, workflow toggle, ingested-data upload), which retry like
|
|
67
|
+
a GET. Before, a `scopes.create` that hit a gateway 502 or a timeout was sent again and could
|
|
68
|
+
create a second scope; now it throws and you decide whether to re-create.
|
|
69
|
+
- **A `Retry-After` over 60 s throws `RateLimitError` at once** (with `retryAfter` set)
|
|
70
|
+
instead of sleeping that long. Up to 60 s is still waited out.
|
|
71
|
+
- **Reading a workflow needs use or manage permission, not manage alone.** `workflows.get(id)` returns a workflow you can run or change; `canUse` and `canManage` say which. A workflow you cannot access is a 404 `NotFoundError` instead of a 403. `workflows.interfaces(id).list()` still needs manage permission (403), and is a 404 when you cannot access the workflow.
|
|
72
|
+
- **Deploying a scheduled workflow with no owner is a 409.** `workflows.deploy(id)` no longer reports an ownerless scheduled workflow as enabled when no schedule could be created.
|
|
73
|
+
- **A non-UUID interface id is a 400.** `workflows.interfaces(id).update()` and `.delete()` with an id that is not a UUID return 400 instead of a retried 500.
|
|
74
|
+
- **Dashboard and element titles must contain a non-whitespace character.** A blank title on `context.dashboards.create`, `.updateDraft`, and `.elements(id).create` / `.update` returns 400.
|
|
75
|
+
- **Delete docs match the server.** Deleting a workflow or scope that is already deleted returns 404; deleting a memory that no longer exists returns 404 (it returned 422). Neither is a no-op.
|
|
76
|
+
- **Custom context item writes are documented as opt-in.** `customItems` writes
|
|
77
|
+
reject with `PermissionDeniedError` ("Custom context item writes are not
|
|
78
|
+
enabled") until Modus enables them for the organization.
|
|
79
|
+
- **Breaking (pre-1.0): `runs.interrupt` and `runs.editQueued` take the turn to send.** `runs.interrupt(runId, nextRun, { lastSeenEventId? })` and `runs.editQueued(runId, nextRun)` send `nextRun` (`message` and `sessionId`, the run's conversation id) and return the admitted run as `RunAdmission` (`{ runId, status }`). For `interrupt`, that is the new run that carries the follow-up turn; stream it with `runs.stream(runId)`. The old signatures sent an empty body, which the server always rejected, so no working call changes behaviour. `interrupt` sets `nextRun.runId` when you omit it, so a retried request returns the same run instead of starting a second turn. On a run that has already finished, `interrupt` starts a follow-up turn.
|
|
80
|
+
- **`runs.resume` sends no message.** The documented example now sends only `decision` and `sessionId`; a non-empty `message` is rejected by the server. A blank `sessionId` is refused before any request instead of being replaced by a new random conversation.
|
|
81
|
+
- **Breaking (pre-1.0): `chat()` streams from the agent host.** `client.scopes.chat()`, `client.modus.chat()` and `client.workflows.chat()` return a `ChatSession`. Iterate `textStream()` / `eventStream()` for the reply as it arrives, or `await` it (or `.then` / `.catch` / `.finally`) for `{ content, threadId, runId }` as before; an invalid model or id still rejects rather than throwing. The request is sent when you first iterate or await the session. Runs are no longer cut off after 30 seconds, and `content` is the server's final answer: interim narration and sub-agent output are left out. A session sends one request; iterating it again replays what arrived. A session that reaches `done` releases its connection; call `close()` if you stop reading before then. Iterating `textStream()` after the run applies the server's mid-run corrections (`assistant_content_reset`), so the text matches what `content` was built from.
|
|
82
|
+
- **Workflow streams show their output.** Node tokens are unwrapped, `workflow_done` carries the workflow's final output, and a workflow that fails or is cancelled throws instead of ending the stream silently.
|
|
83
|
+
- **Streams time out on silence, not length.** `timeoutMs` now bounds the gap between chunks of a stream, so a run that keeps streaming is never cut off.
|
|
84
|
+
- **Breaking (pre-1.0): a custom `baseUrl` needs `agentHost` to chat.** When the agent host cannot be derived from `baseUrl` (anything other than `api.<env>.getmodus.com`), chat and runs throw instead of sending your key to the production agent host. Pass `agentHost` or set `MODUS_AGENT_HOST`; a blank value counts as unset.
|
|
85
|
+
|
|
86
|
+
### Removed
|
|
87
|
+
|
|
88
|
+
- **Breaking (pre-1.0): `chatStream()`, `ChatStream` and `ChatRequest`.** Use `chat()`, which streams. `getFinalResult()` is replaced by `await`ing the session.
|
|
89
|
+
- **Breaking (pre-1.0): `version: 'draft'` on scope chat.** API tokens run published scopes only.
|
|
90
|
+
|
|
91
|
+
### Deprecated
|
|
92
|
+
|
|
93
|
+
- **`api-skill-<scopeId>-…` thread ids.** Continuing a conversation with the id an earlier `scopes.chat()` returned still works: the server reads it as the `agent_<scopeId>_…` thread it named. Store the `agent_<scopeId>_…` id the response now returns; the old form is accepted only by the chat continuation call and goes away with it.
|
|
94
|
+
|
|
95
|
+
### Fixed
|
|
96
|
+
|
|
97
|
+
- **`EvaluationConfig.cadence.frequency` can be `null`.** The API returns `null` for a schedule without a frequency, but the type did not allow it.
|
|
98
|
+
- **`@getmodus/sdk/management` resolves under `moduleResolution: "node"`.** A `typesVersions` entry points the subpath at its types, so a tsconfig on the older `node` (node10) resolution no longer fails with TS2307. `node16`, `nodenext` and `bundler` are unchanged.
|
|
99
|
+
- **README.** It shows how to reach staging or a self-hosted API (`baseUrl` / `MODUS_BASE_URL`, `agentHost` / `MODUS_AGENT_HOST`); the error-handling example handles a client-side `ValidationError`, which has no `statusCode`, `code` or `requestId`; tokens are shown as `modus_pat_…`; and the example scripts are said to live in the GitHub repository, not the npm package. `agentHost` is documented as a public option.
|
|
100
|
+
- **`workflows.runs.create()`, `createScope()` and `createModus()` accept a body without `sessionId`.** The types required it, so the documented examples did not compile; the SDK already starts a new conversation when it is omitted. `resume`, `interrupt` and `editQueued` still require it.
|
|
101
|
+
- **Errors from `@getmodus/sdk/management` are `instanceof` the root error classes under CommonJS.** Each CommonJS entrypoint bundled its own copy of `ModusError` and the other classes, so `err instanceof ModusError` was `false` for a `ModusManagement` error under `require`. ESM was not affected.
|
|
102
|
+
- **The `context.items.lookup()` and `scopes.conversations(id).get()` examples compile.**
|
|
103
|
+
- **Server: `conversations.list({ kind })` filters.** `kind: 'modus'` returns only Modus threads and `kind: 'scopes'` only scope threads; before, both returned every conversation.
|
|
104
|
+
- **Server: resuming a finished run ends at once.** `runs.stream(runId, { lastEventId })` with the id of the run's final `done`/`error`/`cancelled` event now ends with no events, instead of waiting forever.
|
|
105
|
+
- **Server: errors use Scope and Workflow.** A missing scope is `Scope not found` with `info.scopeId` (was `Skill not found`, `info.skillId`); a missing workflow is `Workflow not found` with `info.workflowId` (was `Agent not found`, `info.agentId`). Code that read `info.skillId` or `info.agentId` must read the new key.
|
|
106
|
+
- **Every rejected argument now throws `ValidationError`.** An invalid page size, chat model, `kind`, blank
|
|
107
|
+
`runId` or `sessionId`, empty `updateMask`, a `beforeMessageIndex` without `messageLimit`, too many
|
|
108
|
+
`sessionIds`, a bad `waitUntil`, `concurrency` or upload path (including one that does not exist or runs through a regular file), and `getNextPage()` on the last page threw a
|
|
109
|
+
plain `Error` before any request; they now throw `ValidationError`, a `ModusError` subclass, as the Python
|
|
110
|
+
SDK does. Code that catches `Error` still catches it. The CLI now exits 3 on these, not 1.
|
|
111
|
+
- **A path id of `'..'` could target the parent resource, e.g. delete the scope.** `scopes.memories(7).delete('..')` sent `DELETE /scopes/7`. Every path id that is blank, `'.'` or `'..'` now raises `ValidationError` before any request; a blank id no longer returns the list page as one item.
|
|
112
|
+
- **Paging no longer skips items.** `scopes.list()`, `workflows.list()`, `connections.list()` and their auto-paging iterators return every item: a page boundary no longer drops items created in the same millisecond, and `connections.list()` no longer drops a connection or ends early when other members' connections are hidden from you.
|
|
113
|
+
- **Numeric ids above 2147483647 return 404.** Such a scope or workflow id now throws `NotFoundError` instead of a 500 that was retried three times.
|
|
114
|
+
- **Evaluation runs page in a stable order.** Runs that started at the same time are no longer repeated or skipped across pages.
|
|
115
|
+
- **A run started while you page evaluation runs is not repeated.** The `listRuns` page token is now an opaque position in the list, not a row offset, so a run that starts between two pages no longer shows up again on the next page (and a deleted one no longer makes the next page skip a run). A numeric page token from before this release is rejected with 400 (`BadRequestError`); restart from the first page.
|
|
116
|
+
- **`updateConfig` returns what it stored.** The first `scopes.evaluations(id).updateConfig({ judgeModel })` on a scope returned `judgeModel: null` (and the defaults for every other field), although the value was saved; a later partial update could also turn `enabled` back off. The server now reads the configuration it just wrote.
|
|
117
|
+
- **`scopes.chat()` returns the conversation's thread id.** `threadId` is now `agent_<scopeId>_…`, the id `scopes.conversations(id).list()` shows, so `get(threadId)` accepts it. It was `api-skill-<scopeId>-…`, which those calls answered with 404.
|
|
118
|
+
- **`context.createLink()` on a page that cannot be read throws `UnprocessableError` (422), not a 500.** An unreachable or empty page names the URL in the message.
|
|
119
|
+
- **`updateMask` clears the fields it names.** A field named in `updateMask` and left unset is sent as `null`, so the server clears it, on `scopes.update`, `workflows.update`, `context.items.update`, and both `interfaces(id).update`. Before, it was dropped from the body and nothing was cleared.
|
|
120
|
+
- **`suggestions.list({ scopeIds: [] })` throws `ValidationError`** before any request. It sent `scopeIds=`, which the server rejects with 400.
|
|
121
|
+
- **Clearing a masked field no longer fails with 500.** `scopes.update` with `updateMask` naming `description` or `expectedOutput` (or `workflows.update` naming `description`) and the field left unset raised `InternalServerError` three times. A cleared field now takes its empty value: text `''`; a list `[]`; a map `{}`; a context item's `userFeedback` `neutral`; and a memory's `metadata` `{}`. A field with no empty value throws `BadRequestError` saying it cannot be cleared. These are `name`, `accessConfig`, a workflow's `type` and `workflowStructure`, a context item's `content` and `contextType`, a memory's `memory`, and an interface's `name` and `config`.
|
|
122
|
+
- **Updating or deleting a memory that does not exist throws `NotFoundError`.** `scopes.memories(id).update()` and `.delete()` resolved as if they had succeeded when memory is off for the organization.
|
|
123
|
+
- **Docs: ids are numeric.** The getting-started example took a slug (`scopes.get('revenue-analysis')`), which the server rejects with 400; it now takes an id from `list()`. Docs no longer say "id or slug". `type: 'task'` is documented as a deprecated alias on create; `workflows.update` accepts only `workflow`.
|
|
124
|
+
- **`requestId` is set on every API error.** It was always `undefined`, because the API sends
|
|
125
|
+
it in the error body, not in an `x-request-id` header. The header is still used when the body
|
|
126
|
+
has none.
|
|
127
|
+
- **A 2xx response that is not JSON** throws a `ModusError` naming the status, content type and
|
|
128
|
+
the first 200 characters, after one request. It was an `APIConnectionError` ("check
|
|
129
|
+
connectivity") retried three times.
|
|
130
|
+
- **`UnprocessableError` documentation:** 422 is a business-rule failure; schema failures are
|
|
131
|
+
400 (`BadRequestError`).
|
|
132
|
+
- **Breaking (pre-1.0): `context.items.listValues` pages one item's array.** The
|
|
133
|
+
server used to ignore the uid and return one row per item of the context type,
|
|
134
|
+
with each item's whole `content`. It now reads only the item named by `uid`
|
|
135
|
+
(not found when it is missing, unreadable, or of another context type) and pages
|
|
136
|
+
the elements of the array at `contentKeyPath`. `ContextValueRow` is
|
|
137
|
+
`{ index, value }`: the element's 0-based position and the element itself.
|
|
138
|
+
- **Conversation messages carry text.** `conversations.get` returns `content` as a
|
|
139
|
+
string for every message, as typed; tool calls stay in `toolCalls`.
|
|
140
|
+
- **Oversized request bodies say so.** A request body over an operation's size
|
|
141
|
+
limit fails with HTTP 413 and error code `PAYLOAD_TOO_LARGE` instead of
|
|
142
|
+
`BAD_REQUEST`. Dashboards, a custom context item and a note now accept up to
|
|
143
|
+
1 MiB, and `customItems.batchCreate` up to 8 MiB.
|
|
144
|
+
|
|
145
|
+
### Deprecated
|
|
146
|
+
|
|
147
|
+
- **`connectionSet[].path`.** Send `preferences` instead; `path` is derived from it on reads.
|
|
148
|
+
- **`connectionSet[].context_enabled`.** A scope always reads context from its connections; omit the field.
|
|
149
|
+
`false` is accepted only when the connection is already stored with `false`.
|
|
150
|
+
|
|
151
|
+
## [0.9.0] — 2026-10-24
|
|
152
|
+
|
|
153
|
+
### Added
|
|
154
|
+
|
|
155
|
+
- **List selectable units.** `client.connections.listSelections(connectionId)` and
|
|
156
|
+
`iterSelections(connectionId)` page the units a scope can select on a connection
|
|
157
|
+
(`GET /connections/{id}/selections`). `client.connections.list()` items may include
|
|
158
|
+
`selectionModel`.
|
|
159
|
+
- **Evaluation case methods.** `scopes.evaluations(id).addCase()`, `.updateCase(caseId)`, and `.deleteCase(caseId)` add, change, or remove one evaluation case. Omit `id` on add and the client assigns one, so a retry sends the same id. A retry whose id is already stored returns a conflict; an identical body is not treated as success. An empty `task` is allowed. An update with neither field is rejected.
|
|
160
|
+
|
|
161
|
+
### Changed
|
|
162
|
+
|
|
163
|
+
- **MCP config is checked on write.** `scopes.create`, `scopes.update`, and `PATCH /scopes/{id}/mcp-config` return the effective core tools and tool exposure. A changed value must use true or false for each core tool, and version 1 with mode subset or discovery for tool exposure. A newly added exposure key must be one the scope can expose. A key already stored can be sent again or removed.
|
|
164
|
+
- **Breaking (pre-1.0): typed evaluation cases.** `scopes.update` `evaluations` items are `{ id?, task, expectedOutput }`. `task` and `expectedOutput` are required, and any other key, such as `createdAt` or `updatedAt`, is rejected with 400. Omit `id` on a new case and one is assigned. A repeated `id` is rejected. An empty `task` is allowed.
|
|
165
|
+
- **Breaking (pre-1.0): scope `interfaces` have one shape.** `scopes.create` and `scopes.update` (`POST /api/v1/scopes` and `PATCH /api/v1/scopes/{id}`) accept only MCP interface rows. `type` must be `mcp`. Each row has an optional id and name and a config of core tools and exposed integrations. A row without an id or name is assigned one. Responses return only id, type, name, and config; extra stored keys such as `enabled` are no longer returned.
|
|
166
|
+
- **Workflow responses declare their shapes.** `Workflow` variation fields `trigger`, `workflowStructure`, and `agentSelection` are `WorkflowTriggerResponseDto`, `WorkflowStructureResponseDto`, and `AgentSelectionResponseDto` instead of open objects. A non-schedule trigger has `schedule: null`, and a schedule leaves unused cadence fields null. A workflow interface `config` describes Slack and Teams (`accessMode`, `allowedEmails`, `availableChannelIds`) and an empty object for MCP.
|
|
167
|
+
- **Scope create and update describe `connectionSet`.** An entry selects a whole connection (`path: []`) or one selectable unit of it, never anything below. Lists replace the stored list.
|
|
168
|
+
- **Scope `connectionSet` rows must be a selectable unit.** `scopes.create` and `scopes.update` reject a new row whose path is neither the whole connection nor one selectable unit of it, with 422 `root.not_a_root`. A row already stored can stay, and removing it still succeeds.
|
|
169
|
+
- **Workflow interface config.** Slack and Teams `config` on a workflow interface is `accessMode` (`all`, `allow-list`, or `allow-org`), `allowedEmails`, and `availableChannelIds`. An MCP interface accepts no config keys. An unknown key or invalid value in a changed config returns 422 with violations; `config: null` returns 400. Unchanged stored values are accepted.
|
|
170
|
+
- **`searchQuery` documents word search.** `context.customItems.list({ searchQuery })` (`GET /context/custom-items`) describes
|
|
171
|
+
word search: it returns rows that contain every word of the query, case-insensitive.
|
|
172
|
+
- **Known toolset values are validated by the API.** Integration entries require per-connection grants (see **Removed** below).
|
|
173
|
+
General tools retain their formats: `file_publish` takes `{ actions: string[], rules?: { nameMode: "any" | "restricted", allowedNames: string[] } }`;
|
|
174
|
+
Coding tools take an array of `{ connectionUid, repoOwner, repoName, branch }`.
|
|
175
|
+
Invalid nonintegration values return `422` with rule `toolset.bad_value`; unknown keys use `toolset.unknown_key`.
|
|
176
|
+
Unchanged stored nonintegration values can still be resent or removed.
|
|
177
|
+
|
|
178
|
+
### Removed
|
|
179
|
+
|
|
180
|
+
- **Breaking (MAJOR), CU-z93r0b8wwz: implicit integration toolset binding and retired layouts.**
|
|
181
|
+
Use `{ <platform>: { byConnection: { <lowercase connection UUID>: { actions: [...], rules? } } } }`.
|
|
182
|
+
SQL grants use the SQL platform key (for example `postgresql`) with `actions: ['query']`.
|
|
183
|
+
Flat `{ actions }`, integration action arrays, `scope`/personal encodings, action suffixes,
|
|
184
|
+
`sql_runner`, `looker_bi`, `langfuse_observability` and `*_analytics` are rejected with
|
|
185
|
+
`UnprocessableError` (422), including unchanged stored entries. General tools, MCP, Pipedream
|
|
186
|
+
and Coding are unchanged. `PlatformToolsetEntry`, `ToolsetSlot` and `ToolsetRules` are
|
|
187
|
+
exported from `@getmodus/sdk/management`; `ToolsetInput` remains an open map.
|
|
188
|
+
The SQL example now takes `MODUS_SQL_PLATFORM` and `MODUS_SQL_CONNECTION_ID`, not `MODUS_SQL_SELECTOR`.
|
|
189
|
+
- **Breaking: `ToolsetDto` and `ToolsetToolDto`.** Both are removed from `components["schemas"]`. Scope create and update `toolset` is a map of tool key to its configuration; type it with `ToolsetInput` from `@getmodus/sdk/management`. The generated `{ tools: [{ id, enabled, config }] }` models are gone. Unknown keys are rejected.
|
|
190
|
+
- **Breaking (pre-1.0): evaluation case timestamps.** Scope evaluation cases no longer include `createdAt` or `updatedAt`.
|
|
191
|
+
|
|
12
192
|
## [0.8.0] — 2026-10-18
|
|
13
193
|
|
|
194
|
+
### Removed
|
|
195
|
+
|
|
196
|
+
- **Breaking: evaluation Slack `nangoConnectionId`.** Send `connectionId`, the
|
|
197
|
+
Slack connection's Modus UUID, in notification settings instead. The generated
|
|
198
|
+
`EvaluationSlackChannelDto` type uses `connectionId`. No deprecation window;
|
|
199
|
+
requires a major release.
|
|
200
|
+
|
|
14
201
|
### Added
|
|
15
202
|
|
|
16
203
|
- **`includeOwnLearnings` on `scopes.create`.** A new scope reads what is taught while
|
|
@@ -34,6 +221,8 @@ release, including pre-1.0 (`0.x`) releases.
|
|
|
34
221
|
|
|
35
222
|
### Changed
|
|
36
223
|
|
|
224
|
+
- **Scope context file handling.** `scopes.getContext()` returns bounded inline
|
|
225
|
+
previews for large bodies; full file content is not available through this REST method.
|
|
37
226
|
- **Connected-integration toolset entries bind to a connection.** A scope toolset entry
|
|
38
227
|
given as `{ actions: [...], rules }` is bound on create/update to the organization's
|
|
39
228
|
newest workspace connection of that integration and returned as
|
package/README.md
CHANGED
|
@@ -51,7 +51,9 @@ for await (const scope of (await client.scopes.list()).autoPagingIter()) {
|
|
|
51
51
|
console.log(scope.name, scope.status)
|
|
52
52
|
}
|
|
53
53
|
|
|
54
|
-
|
|
54
|
+
// Ids are numeric: take one from list()
|
|
55
|
+
const [first] = (await client.scopes.list()).items
|
|
56
|
+
const scope = await client.scopes.get(first.id)
|
|
55
57
|
console.log(scope.name, scope.description)
|
|
56
58
|
|
|
57
59
|
for await (const item of (await client.context.items.list()).autoPagingIter()) {
|
|
@@ -71,13 +73,39 @@ const client = new Modus({ apiKey: process.env.MODUS_API_KEY })
|
|
|
71
73
|
Create an API token in the Modus app (**Settings → API Tokens** on your Modus home page). Prefer an environment variable over hardcoding keys in source:
|
|
72
74
|
|
|
73
75
|
```bash
|
|
74
|
-
export MODUS_API_KEY=
|
|
76
|
+
export MODUS_API_KEY=modus_pat_xxx
|
|
75
77
|
```
|
|
76
78
|
|
|
77
79
|
```ts
|
|
78
|
-
const client = new Modus({ apiKey: '
|
|
80
|
+
const client = new Modus({ apiKey: 'modus_pat_xxx' })
|
|
79
81
|
```
|
|
80
82
|
|
|
83
|
+
### Staging and custom hosts
|
|
84
|
+
|
|
85
|
+
The client talks to `https://api.getmodus.com` by default. Chat, runs and context compose
|
|
86
|
+
(`modus.getContext()`, `scopes.getContext()`) go to the agent host, which for a Modus API origin
|
|
87
|
+
is derived from it (`api.getmodus.com` → `agent.getmodus.com`, `api.staging.getmodus.com` →
|
|
88
|
+
`agent.staging.getmodus.com`). Any other `baseUrl` needs `agentHost` for those calls. Point the
|
|
89
|
+
client elsewhere with options or environment variables:
|
|
90
|
+
|
|
91
|
+
| Option | Environment variable | Default |
|
|
92
|
+
|--------|----------------------|---------|
|
|
93
|
+
| `baseUrl` | `MODUS_BASE_URL` | `https://api.getmodus.com` |
|
|
94
|
+
| `agentHost` | `MODUS_AGENT_HOST` | derived from `baseUrl`: `api.getmodus.com` → `agent.getmodus.com`, `api.<env>.getmodus.com` → `agent.<env>.getmodus.com`; none for any other host |
|
|
95
|
+
|
|
96
|
+
```ts
|
|
97
|
+
const staging = new Modus({ baseUrl: 'https://api.staging.getmodus.com' })
|
|
98
|
+
|
|
99
|
+
// A host that is not api.getmodus.com or api.<env>.getmodus.com needs its agent host too,
|
|
100
|
+
// or chat, runs and getContext() throw
|
|
101
|
+
const selfHosted = new Modus({
|
|
102
|
+
baseUrl: 'https://modus-api.internal.example.com',
|
|
103
|
+
agentHost: 'https://modus-agent.internal.example.com',
|
|
104
|
+
})
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
An option wins over its environment variable. `ModusManagement` takes the same options.
|
|
108
|
+
|
|
81
109
|
## Using Modus
|
|
82
110
|
|
|
83
111
|
### Modus vs scopes
|
|
@@ -105,10 +133,12 @@ const followUp = await client.modus.chat('Break that down by region.', {
|
|
|
105
133
|
})
|
|
106
134
|
console.log(followUp.content)
|
|
107
135
|
|
|
108
|
-
|
|
109
|
-
|
|
136
|
+
// Every chat streams live from the agent host; iterate it to print tokens as they arrive.
|
|
137
|
+
const live = client.modus.chat('Summarize this week', { model: MODEL })
|
|
138
|
+
for await (const chunk of live.textStream()) {
|
|
110
139
|
process.stdout.write(chunk)
|
|
111
140
|
}
|
|
141
|
+
const { threadId } = await live
|
|
112
142
|
|
|
113
143
|
const ctx = await client.modus.getContext('What tables describe customer churn?', { limit: 10 })
|
|
114
144
|
console.log(ctx.originalCount, ctx.sessionId)
|
|
@@ -128,8 +158,8 @@ const MODEL = 'claude-sonnet-5'
|
|
|
128
158
|
const result = await client.scopes.chat(scopeId, 'Hello', { model: MODEL })
|
|
129
159
|
console.log(result.content, result.threadId)
|
|
130
160
|
|
|
131
|
-
const
|
|
132
|
-
for await (const chunk of
|
|
161
|
+
const live = client.scopes.chat(scopeId, 'Hi', { model: MODEL, threadId: result.threadId })
|
|
162
|
+
for await (const chunk of live.textStream()) {
|
|
133
163
|
process.stdout.write(chunk)
|
|
134
164
|
}
|
|
135
165
|
```
|
|
@@ -151,7 +181,53 @@ for await (const run of (await client.workflows.runs.list(workflowId, { pageSize
|
|
|
151
181
|
}
|
|
152
182
|
```
|
|
153
183
|
|
|
154
|
-
|
|
184
|
+
```ts
|
|
185
|
+
const { content } = await client.workflows.chat(workflowId, 'Run this week\'s digest', { model: 'claude-sonnet-5' })
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
`client.workflows.runs.stream(runId)` follows a run's events. Each event carries an `id` when the server sends one. If the connection drops, call `stream` again with `lastEventId` set to the last `id` you handled: the stream resumes after it instead of replaying the run from the start. Without an `id` it can only replay from the start. The stream ends after a `done`, `error` or `cancelled` event; only `done` is a completed run.
|
|
189
|
+
|
|
190
|
+
```ts
|
|
191
|
+
import { APIConnectionError, type RunEvent } from '@getmodus/sdk'
|
|
192
|
+
|
|
193
|
+
async function followRun(runId: string, handle: (event: RunEvent) => void): Promise<void> {
|
|
194
|
+
let lastEventId: string | undefined
|
|
195
|
+
for (;;) {
|
|
196
|
+
const events = client.workflows.runs.stream(runId, { lastEventId })[Symbol.asyncIterator]()
|
|
197
|
+
for (;;) {
|
|
198
|
+
let next: IteratorResult<RunEvent>
|
|
199
|
+
try {
|
|
200
|
+
next = await events.next()
|
|
201
|
+
} catch (error) {
|
|
202
|
+
if (error instanceof APIConnectionError) break // dropped: resume after lastEventId
|
|
203
|
+
throw error
|
|
204
|
+
}
|
|
205
|
+
if (next.done) break // ended without a final event: resume
|
|
206
|
+
const event = next.value
|
|
207
|
+
handle(event) // a handler error propagates; it is not a disconnect
|
|
208
|
+
lastEventId = event.id ?? lastEventId
|
|
209
|
+
if (event.type === 'done') return
|
|
210
|
+
// A `stream_timeout` event is followed by an `error` event.
|
|
211
|
+
if (event.type === 'error' || event.type === 'cancelled') {
|
|
212
|
+
throw new Error(`Run ${runId} ended with ${event.type}`)
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
### Approvals
|
|
220
|
+
|
|
221
|
+
A run that needs approval for a write stops with `result.approval` set. Continue it with `resume`:
|
|
222
|
+
|
|
223
|
+
```ts
|
|
224
|
+
const chat = client.modus.chat('Fix the typo in the accounts table', { model: 'claude-sonnet-5' })
|
|
225
|
+
const first = await chat
|
|
226
|
+
if (first.approval) {
|
|
227
|
+
const done = await chat.resume({ decision: 'approve' })
|
|
228
|
+
console.log(done.content)
|
|
229
|
+
}
|
|
230
|
+
```
|
|
155
231
|
|
|
156
232
|
## Managing your org
|
|
157
233
|
|
|
@@ -192,10 +268,55 @@ if (destination) {
|
|
|
192
268
|
})
|
|
193
269
|
console.log(moved.movedItems)
|
|
194
270
|
}
|
|
271
|
+
|
|
272
|
+
// Who can view and manage a note, saved query, link or uploaded file; all three settings replace the current ones.
|
|
273
|
+
const access = await mgmt.context.items.updateAccess(note.uid, {
|
|
274
|
+
visibility: 'private',
|
|
275
|
+
groupPermissions: {},
|
|
276
|
+
// Replace with the email of a member of your organization; anyone else is a 422
|
|
277
|
+
sharedWith: [{ email: 'ana@example.com', permission: 'use' }],
|
|
278
|
+
})
|
|
279
|
+
console.log(access.canManage)
|
|
195
280
|
```
|
|
196
281
|
|
|
197
282
|
Requires a token with write access to scopes and workflows (same as the Modus UI). Context file upload/finalize also needs `context:write`; polling status and listing context items need `context:read`.
|
|
198
283
|
|
|
284
|
+
Updating a scope replaces whole lists such as `connectionSet`, `contextSelections`, and `evaluations`. Add or change one evaluation case with `scopes.evaluations(id).addCase`, `updateCase`, or `deleteCase`. Change one connection's selection with `applySelectionOps` (`validateOnly: true` previews and does not write). `selectRoot`, `deselectRoot`, and `setRootDeepRules` are deprecated.
|
|
285
|
+
### Connection-specific toolsets
|
|
286
|
+
|
|
287
|
+
Use the catalog platform key and an explicit lowercase connection UUID. SQL platforms
|
|
288
|
+
(such as `postgresql`, `snowflake` or `bigquery`) grant `query`:
|
|
289
|
+
|
|
290
|
+
```ts
|
|
291
|
+
import type { PlatformToolsetEntry, ToolsetInput } from '@getmodus/sdk/management'
|
|
292
|
+
|
|
293
|
+
const toolset: ToolsetInput = {
|
|
294
|
+
postgresql: {
|
|
295
|
+
byConnection: {
|
|
296
|
+
'11111111-1111-4111-8111-111111111111': { actions: ['query'] },
|
|
297
|
+
},
|
|
298
|
+
} satisfies PlatformToolsetEntry,
|
|
299
|
+
slack: {
|
|
300
|
+
byConnection: {
|
|
301
|
+
'22222222-2222-4222-8222-222222222222': {
|
|
302
|
+
actions: ['SendMessage'],
|
|
303
|
+
rules: { allowedChannelIds: ['C123'], allowedChannelNames: { C123: 'support' } },
|
|
304
|
+
},
|
|
305
|
+
},
|
|
306
|
+
} satisfies PlatformToolsetEntry,
|
|
307
|
+
memory: { enabled: true },
|
|
308
|
+
}
|
|
309
|
+
await mgmt.scopes.update(scope.id, { toolset })
|
|
310
|
+
```
|
|
311
|
+
|
|
312
|
+
Replace the example UUIDs with your chosen connections and use action IDs from
|
|
313
|
+
`mgmt.tools.list()`. Each connection has its own grants; connections are never merged
|
|
314
|
+
or substituted. Empty slots/maps are valid. Actions are trimmed operation names without
|
|
315
|
+
`:` suffixes. The API rejects flat `{ actions }` entries, integration action arrays,
|
|
316
|
+
`scope`/personal encodings and unknown keys (including the retired `sql_runner`, `looker_bi`,
|
|
317
|
+
`langfuse_observability` and `*_analytics`) with a typed `UnprocessableError` (422), even when
|
|
318
|
+
resending a stored value. General tools, MCP, Pipedream and Coding formats are unchanged.
|
|
319
|
+
|
|
199
320
|
## Pagination
|
|
200
321
|
|
|
201
322
|
List endpoints return a `Page<T>`. Iterate the current page, or use `.autoPagingIter()` for all pages:
|
|
@@ -213,9 +334,12 @@ for await (const scope of (await client.scopes.list()).autoPagingIter()) {
|
|
|
213
334
|
```ts
|
|
214
335
|
import {
|
|
215
336
|
Modus,
|
|
337
|
+
BadRequestError,
|
|
216
338
|
NotFoundError,
|
|
217
339
|
AuthenticationError,
|
|
340
|
+
PermissionDeniedError,
|
|
218
341
|
RateLimitError,
|
|
342
|
+
ValidationError,
|
|
219
343
|
ModusError,
|
|
220
344
|
} from '@getmodus/sdk'
|
|
221
345
|
|
|
@@ -224,32 +348,76 @@ try {
|
|
|
224
348
|
} catch (e) {
|
|
225
349
|
if (e instanceof NotFoundError) {
|
|
226
350
|
console.log('Scope not found')
|
|
351
|
+
} else if (e instanceof BadRequestError) {
|
|
352
|
+
console.log(`Invalid request: ${e.message}`)
|
|
227
353
|
} else if (e instanceof AuthenticationError) {
|
|
228
354
|
console.log('Check your MODUS_API_KEY')
|
|
355
|
+
} else if (e instanceof PermissionDeniedError) {
|
|
356
|
+
console.log('Token is missing scopes:', e.info?.missing)
|
|
229
357
|
} else if (e instanceof RateLimitError) {
|
|
230
358
|
console.log(`Rate limited. Retry after ${e.retryAfter}s`)
|
|
359
|
+
} else if (e instanceof ValidationError) {
|
|
360
|
+
// Rejected by the SDK before any request was sent, so there is no status or requestId
|
|
361
|
+
console.log(`Invalid argument: ${e.message}`)
|
|
231
362
|
} else if (e instanceof ModusError) {
|
|
232
|
-
console.log(`API error ${e.statusCode}: ${e.message}`)
|
|
363
|
+
console.log(`API error ${e.statusCode} ${e.code}: ${e.message} (request ${e.requestId}, trace ${e.traceId})`)
|
|
233
364
|
} else {
|
|
234
365
|
throw e
|
|
235
366
|
}
|
|
236
367
|
}
|
|
237
368
|
```
|
|
238
369
|
|
|
370
|
+
Every error the server returns carries `statusCode`, `code` (for example `NOT_FOUND`),
|
|
371
|
+
`requestId` and `traceId` (quote both to support) and, when the server sends one, `info` with
|
|
372
|
+
structured detail. An `APIConnectionError` (no response was received) carries only
|
|
373
|
+
`traceId`, which names the call; the request may still have reached Modus and run, so check
|
|
374
|
+
before repeating a create. A `ValidationError` (for
|
|
375
|
+
example an unsupported chat model) is raised by the SDK before a request is sent, so it has none
|
|
376
|
+
of these. A request that fails schema
|
|
377
|
+
validation is a `BadRequestError` (400); one that is well-formed but breaks a business rule
|
|
378
|
+
is an `UnprocessableError` (422), with the rule in `info`.
|
|
379
|
+
|
|
380
|
+
## Retries
|
|
381
|
+
|
|
382
|
+
A failed request is re-sent up to `maxRetries` times (default 2, with exponential backoff),
|
|
383
|
+
but only when sending it twice cannot do the work twice:
|
|
384
|
+
|
|
385
|
+
- **429**, for every method. A `Retry-After` (or `retry-after-ms`) of up to 60 s is waited
|
|
386
|
+
out; a longer one throws `RateLimitError` at once with `retryAfter` set.
|
|
387
|
+
- **A connection that never opened** (refused, DNS failure, connect timeout), for every method.
|
|
388
|
+
- **408, 500, 502, 503, 504, a dropped connection or a timeout**, for GET, PUT, PATCH and
|
|
389
|
+
DELETE, and for the POSTs that only read or set a state (context compose, item lookup,
|
|
390
|
+
memory search, active-run lookup, run cancel, run interrupt, workflow-action cancel, workflow toggle,
|
|
391
|
+
ingested-data upload).
|
|
392
|
+
|
|
393
|
+
Any other POST (a create, an add, an evaluation run) may already have run on the server, so
|
|
394
|
+
it throws instead of being re-sent: check whether the resource exists before creating it
|
|
395
|
+
again. `e.retryable` tells you whether the SDK considered the failure safe to re-send.
|
|
396
|
+
Pass `maxRetries: 0` to turn retries off.
|
|
397
|
+
|
|
239
398
|
## Examples
|
|
240
399
|
|
|
241
|
-
Runnable scripts
|
|
400
|
+
Runnable scripts live in the [GitHub repository](https://github.com/modus-data/modus-sdk-typescript/tree/main/examples/scripts),
|
|
401
|
+
not in the npm package. Each imports `@getmodus/sdk`, so run it from an ES-module project with the
|
|
402
|
+
SDK installed:
|
|
242
403
|
|
|
243
404
|
- `examples/scripts/quickstart.ts` — list scopes and context (`Modus`)
|
|
244
|
-
- `examples/scripts/modus_chat.ts` —
|
|
245
|
-
- `examples/scripts/chat.ts` —
|
|
405
|
+
- `examples/scripts/modus_chat.ts` — awaited and streamed Modus chat, context compose, conversations
|
|
406
|
+
- `examples/scripts/chat.ts` — scope chat with thread follow-up
|
|
246
407
|
- `examples/scripts/manage_skill.ts` — create and deploy a scope (`ModusManagement`, `--write` optional)
|
|
247
408
|
|
|
248
409
|
```bash
|
|
249
|
-
|
|
250
|
-
|
|
410
|
+
mkdir modus-examples && cd modus-examples
|
|
411
|
+
npm init -y && npm pkg set type=module
|
|
412
|
+
npm install @getmodus/sdk tsx
|
|
413
|
+
curl -fsSLO https://raw.githubusercontent.com/modus-data/modus-sdk-typescript/main/examples/scripts/quickstart.ts
|
|
414
|
+
export MODUS_API_KEY=modus_pat_xxx
|
|
415
|
+
npx tsx quickstart.ts
|
|
251
416
|
```
|
|
252
417
|
|
|
418
|
+
For SQL in `manage_skill.ts`, set both `MODUS_SQL_PLATFORM` (for example `postgresql`)
|
|
419
|
+
and `MODUS_SQL_CONNECTION_ID` to a connection you can access; SQL is omitted otherwise.
|
|
420
|
+
|
|
253
421
|
See [CHANGELOG.md](./CHANGELOG.md) for release history.
|
|
254
422
|
|
|
255
423
|
## Docs
|