@getmodus/sdk 0.3.0 → 0.4.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 +6 -89
- package/README.md +4 -0
- package/dist/{chunk-D3NU2M6B.js → chunk-I56O44TR.js} +123 -3
- package/dist/chunk-I56O44TR.js.map +1 -0
- package/dist/{conversations-GNBMPpyr.d.cts → conversations-Cq6OVlpQ.d.cts} +371 -14
- package/dist/{conversations-GNBMPpyr.d.ts → conversations-Cq6OVlpQ.d.ts} +371 -14
- package/dist/index.cjs +476 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +484 -9
- package/dist/index.d.ts +484 -9
- package/dist/index.js +355 -1
- package/dist/index.js.map +1 -1
- package/dist/management/index.cjs +568 -8
- package/dist/management/index.cjs.map +1 -1
- package/dist/management/index.d.cts +450 -6
- package/dist/management/index.d.ts +450 -6
- package/dist/management/index.js +447 -7
- package/dist/management/index.js.map +1 -1
- package/package.json +3 -1
- package/dist/chunk-D3NU2M6B.js.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,101 +1,18 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
-
**Current npm release:** [`0.
|
|
3
|
+
**Current npm release:** [`0.4.0`](https://www.npmjs.com/package/@getmodus/sdk/v/0.4.0).
|
|
4
4
|
|
|
5
|
+
Pre-1.0 (`0.x`) releases are internal. Detailed release notes are not maintained
|
|
6
|
+
until `1.0.0` — keep `[Unreleased]` empty while the package stays on `0.x`.
|
|
5
7
|
|
|
8
|
+
## [0.4.0] — 2026-08-01
|
|
6
9
|
|
|
7
|
-
## [0.3.0] — 2026-07-26
|
|
8
|
-
|
|
9
|
-
> Breaking surface vs `0.2.x` (pre-1.0 minor bump). See `distribution/docs/COMPATIBILITY.md`.
|
|
10
|
-
|
|
11
|
-
### Added
|
|
12
|
-
|
|
13
|
-
- `mgmt.usage.list()` gains an optional `userEmail` filter (repeated `user_email` query param).
|
|
14
|
-
- `mgmt.usage.listUsers({ since, until })` — distinct acting-user emails observed in the window.
|
|
15
|
-
|
|
16
|
-
### Deprecated
|
|
17
|
-
|
|
18
|
-
- **`Skill` / `Agent` type names** — use `Scope` / `Workflow` (OpenAPI `ScopeDto` / `WorkflowDto`).
|
|
19
|
-
- **`CreateSkillOptions` / `UpdateSkillOptions`** — use `CreateScopeOptions` / `UpdateScopeOptions`.
|
|
20
|
-
- **`CreateAgentOptions` / `UpdateAgentOptions`** — use `CreateWorkflowOptions` / `UpdateWorkflowOptions`.
|
|
21
|
-
- **`conversationSkillId()`** — use `conversationScopeId()`.
|
|
22
10
|
|
|
23
11
|
### Changed
|
|
24
12
|
|
|
25
|
-
-
|
|
26
|
-
- Custom context create responses always expose `.uid` (same value as `contextItemId`).
|
|
13
|
+
- Public OpenAPI updates from production release.
|
|
27
14
|
|
|
28
|
-
### Removed
|
|
29
|
-
|
|
30
|
-
- Dual list/deploy envelopes — responses use `scopes` / `workflows` and `scope` / `workflow` only (no `skills` / `agents` / `skill` / `agent` aliases).
|
|
31
|
-
- OpenAPI public schema aliases **`SkillDto` / `AgentDto`** — use `ScopeDto` / `WorkflowDto`.
|
|
32
|
-
- Conversation `kind=skills` — use `kind=scopes`.
|
|
33
|
-
- `mgmt.organization.delete()` — organization deletion is no longer part of the
|
|
34
|
-
public API / PAT surface (SPA-only).
|
|
35
|
-
- `GET /api/v1/users/member-groups` and `/org-members` no longer advertise `pageSize` /
|
|
36
|
-
`pageToken` query params or an always-`null` `nextPageToken` response field (OpenAPI /
|
|
37
|
-
Management MCP surface — `mgmt.users.listMemberGroups()` / `listOrgMembers()` never
|
|
38
|
-
exposed either). Both endpoints return the full org-bounded roster; pagination was never
|
|
39
|
-
honored server-side.
|
|
40
15
|
|
|
41
16
|
## [Unreleased]
|
|
42
17
|
|
|
43
|
-
## [0.
|
|
44
|
-
|
|
45
|
-
### Fixed
|
|
46
|
-
|
|
47
|
-
- Streaming requests send `Accept: text/event-stream`; a non-SSE response (e.g. JSON polling body) raises `ModusError` instead of returning an empty stream.
|
|
48
|
-
- `createModus` / `createScope` / `runs.create()` / `resume()` always mint (or reuse) a `sessionId`.
|
|
49
|
-
|
|
50
|
-
## [0.2.2] — 2026-07-20
|
|
51
|
-
|
|
52
|
-
### Fixed
|
|
53
|
-
|
|
54
|
-
- `chatStream` posts to agent-host `/agent/v1/.../runs` (parity with Python), not `/api/v1/.../chat/stream`.
|
|
55
|
-
- Streaming always sends `sessionId`; optional `organizationId` / `MODUS_ORGANIZATION_ID`.
|
|
56
|
-
- Default API/agent hosts are `*.getmodus.com`.
|
|
57
|
-
- `invokeOperation` supports **PUT** (unblocks `supervision.set` / `evaluations.updateConfig`).
|
|
58
|
-
- Agent-service calls honor `agentHost` / `MODUS_AGENT_HOST` over codegen `serverUrl`.
|
|
59
|
-
- `suggestions.recordEvent` accepts camelCase aliases and sends snake_case wire keys.
|
|
60
|
-
- `runs.create` / `createModus` / `createScope` / `resume` return a sync async-iterable stream (not a Promise wrapper).
|
|
61
|
-
|
|
62
|
-
### Added
|
|
63
|
-
|
|
64
|
-
- Runtime `AgentType.task` / `AgentType.workflow` (not type-only).
|
|
65
|
-
- Create responses expose `.uid` as an alias of `contextItemId`.
|
|
66
|
-
|
|
67
|
-
## [0.2.1] — 2026-07-20
|
|
68
|
-
|
|
69
|
-
### Changed
|
|
70
|
-
|
|
71
|
-
- Public README brought to parity with the Python SDK guide (product framing, auth, Modus vs scopes, chat/stream/context, management, pagination, errors).
|
|
72
|
-
- Added `assets/modus-logo.png` / `.svg` for GitHub mirror and package docs.
|
|
73
|
-
|
|
74
|
-
## [0.2.0] — 2026-07-20
|
|
75
|
-
|
|
76
|
-
### Added
|
|
77
|
-
|
|
78
|
-
- Canonical **`client.scopes` / `client.workflows`** and **`mgmt.scopes` / `mgmt.workflows`** against `/api/v1/scopes` and `/api/v1/workflows`.
|
|
79
|
-
- **`client.suggestions`** — `list()` / `recordEvent()`.
|
|
80
|
-
- **`client.workflows.runs.active()` / `activeBySession(...)`** — active conversation runs.
|
|
81
|
-
- **`mgmt.scopes.evaluations(scopeId)`** — evaluation config, trigger, run history.
|
|
82
|
-
- Bounded conversation windows via optional `{ messageLimit, beforeMessageIndex }` on `conversations(id).get()`.
|
|
83
|
-
- MCP **`get_context_data`** batch + ACL: `{ items[], sessionId? }` → `{ results[] }` (max 20).
|
|
84
|
-
- Shipped examples under `examples/scripts/`.
|
|
85
|
-
- Full public OpenAPI operation coverage (contract-tested). Dual ESM + CJS. Zero runtime dependencies.
|
|
86
|
-
|
|
87
|
-
### Changed
|
|
88
|
-
|
|
89
|
-
- Package name is **`@getmodus/sdk`** (npm org `getmodus`). Install: `npm install @getmodus/sdk`.
|
|
90
|
-
- Run creation: `client.workflows.runs.createScope(scopeId, body)` (not `createSkill`).
|
|
91
|
-
- Public docs use **Scope** / **Workflow** vocabulary.
|
|
92
|
-
|
|
93
|
-
### Removed
|
|
94
|
-
|
|
95
|
-
- Legacy **`client.skills` / `client.agents`** and **`mgmt.skills` / `mgmt.agents`** accessors — use `scopes` / `workflows`.
|
|
96
|
-
|
|
97
|
-
## [0.1.0] — 2026-07-20
|
|
98
|
-
|
|
99
|
-
### Added
|
|
100
|
-
|
|
101
|
-
- First public npm release of **`@getmodus/sdk`** (Node.js 18+): `Modus` + `ModusManagement`, pagination, retries, SSE chat, OpenAPI contract coverage.
|
|
18
|
+
## [0.3.0] — 2026-07-26
|
package/README.md
CHANGED
|
@@ -224,3 +224,7 @@ npx tsx examples/scripts/quickstart.ts
|
|
|
224
224
|
```
|
|
225
225
|
|
|
226
226
|
See [CHANGELOG.md](./CHANGELOG.md) for release history.
|
|
227
|
+
|
|
228
|
+
## Docs
|
|
229
|
+
|
|
230
|
+
Full guides: [docs.getmodus.com/guides/sdk](https://docs.getmodus.com/guides/sdk) (TypeScript page: [sdk-typescript](https://docs.getmodus.com/guides/sdk-typescript)).
|
|
@@ -640,6 +640,16 @@ var OPERATIONS = {
|
|
|
640
640
|
requestSchema: "RecordSuggestionEventDto",
|
|
641
641
|
responseSchema: null
|
|
642
642
|
},
|
|
643
|
+
"ToolsController_list": {
|
|
644
|
+
method: "GET",
|
|
645
|
+
path: "/api/v1/tools",
|
|
646
|
+
service: "modus-api",
|
|
647
|
+
serverUrl: "https://api.getmodus.com",
|
|
648
|
+
pathParams: [],
|
|
649
|
+
queryParams: ["pageToken", "pageSize"],
|
|
650
|
+
requestSchema: null,
|
|
651
|
+
responseSchema: "ListToolsResponseDto"
|
|
652
|
+
},
|
|
643
653
|
"UsageController_list": {
|
|
644
654
|
method: "GET",
|
|
645
655
|
path: "/api/v1/usage",
|
|
@@ -961,9 +971,20 @@ var Page = class {
|
|
|
961
971
|
this.nextPageToken = normalizePageToken(nextPageToken);
|
|
962
972
|
this.fetchPage = fetchPage;
|
|
963
973
|
}
|
|
974
|
+
/**
|
|
975
|
+
* Whether another page of results is available.
|
|
976
|
+
*
|
|
977
|
+
* @returns `true` when {@link Page.nextPageToken} is set.
|
|
978
|
+
*/
|
|
964
979
|
hasNextPage() {
|
|
965
980
|
return this.nextPageToken !== void 0;
|
|
966
981
|
}
|
|
982
|
+
/**
|
|
983
|
+
* Fetch the next page using {@link Page.nextPageToken}.
|
|
984
|
+
*
|
|
985
|
+
* @returns The following page of results.
|
|
986
|
+
* @throws {Error} When there is no next page. Check {@link Page.hasNextPage} first.
|
|
987
|
+
*/
|
|
967
988
|
async getNextPage() {
|
|
968
989
|
if (this.nextPageToken === void 0) {
|
|
969
990
|
throw new Error(
|
|
@@ -972,6 +993,12 @@ var Page = class {
|
|
|
972
993
|
}
|
|
973
994
|
return this.fetchPage(this.nextPageToken);
|
|
974
995
|
}
|
|
996
|
+
/**
|
|
997
|
+
* Async-iterate over all items across every page, fetching additional pages as needed.
|
|
998
|
+
*
|
|
999
|
+
* @returns An async generator yielding every item in the result set.
|
|
1000
|
+
* @throws {ModusError} When a follow-up page request fails.
|
|
1001
|
+
*/
|
|
975
1002
|
async *autoPagingIter() {
|
|
976
1003
|
for (const item of this.items) yield item;
|
|
977
1004
|
let nextPageToken = this.nextPageToken;
|
|
@@ -981,6 +1008,7 @@ var Page = class {
|
|
|
981
1008
|
nextPageToken = page.nextPageToken;
|
|
982
1009
|
}
|
|
983
1010
|
}
|
|
1011
|
+
/** Iterate over the current page's items only. */
|
|
984
1012
|
[Symbol.iterator]() {
|
|
985
1013
|
return this.items[Symbol.iterator]();
|
|
986
1014
|
}
|
|
@@ -1047,6 +1075,19 @@ function resolveBaseUrl(baseUrl) {
|
|
|
1047
1075
|
function resolveAgentHost(agentHost) {
|
|
1048
1076
|
return agentHost ?? process.env[ENV_AGENT_HOST] ?? void 0;
|
|
1049
1077
|
}
|
|
1078
|
+
function isModusApiHostname(hostname) {
|
|
1079
|
+
return hostname === "api.getmodus.com" || /^api\.[a-z0-9-]+\.getmodus\.com$/i.test(hostname);
|
|
1080
|
+
}
|
|
1081
|
+
function deriveAgentHostFromBaseUrl(baseUrl) {
|
|
1082
|
+
try {
|
|
1083
|
+
const url = new URL(baseUrl);
|
|
1084
|
+
if (!isModusApiHostname(url.hostname)) return void 0;
|
|
1085
|
+
url.hostname = `agent.${url.hostname.slice("api.".length)}`;
|
|
1086
|
+
return url.origin;
|
|
1087
|
+
} catch {
|
|
1088
|
+
return void 0;
|
|
1089
|
+
}
|
|
1090
|
+
}
|
|
1050
1091
|
function resolveOrganizationId(organizationId) {
|
|
1051
1092
|
const raw = organizationId ?? process.env[ENV_ORGANIZATION_ID];
|
|
1052
1093
|
if (raw === void 0) return void 0;
|
|
@@ -1098,7 +1139,7 @@ function createModusConfig(options = {}) {
|
|
|
1098
1139
|
const baseUrl = normalizeBaseUrl(resolveBaseUrl(options.baseUrl) ?? DEFAULT_BASE_URL);
|
|
1099
1140
|
const baseUrlOverrides = normalizeBaseUrls(options.baseUrls);
|
|
1100
1141
|
const agentHost = normalizeBaseUrl(
|
|
1101
|
-
baseUrlOverrides["agent-service"] ?? resolveAgentHost(options.agentHost) ?? DEFAULT_AGENT_HOST
|
|
1142
|
+
baseUrlOverrides["agent-service"] ?? resolveAgentHost(options.agentHost) ?? deriveAgentHostFromBaseUrl(baseUrl) ?? DEFAULT_AGENT_HOST
|
|
1102
1143
|
);
|
|
1103
1144
|
const organizationId = resolveOrganizationId(options.organizationId);
|
|
1104
1145
|
return Object.freeze({
|
|
@@ -1128,7 +1169,7 @@ function formatConfigForLog(config) {
|
|
|
1128
1169
|
}
|
|
1129
1170
|
|
|
1130
1171
|
// src/_http.ts
|
|
1131
|
-
var USER_AGENT = `modus-typescript/${"0.
|
|
1172
|
+
var USER_AGENT = `modus-typescript/${"0.4.0"} (node/${process.version}; ${process.platform})`;
|
|
1132
1173
|
function buildUrl(baseUrl, path, params) {
|
|
1133
1174
|
const url = new URL(path.startsWith("/") ? path : `/${path}`, baseUrl);
|
|
1134
1175
|
if (params) {
|
|
@@ -1605,10 +1646,20 @@ function parseDeletion(raw) {
|
|
|
1605
1646
|
return raw;
|
|
1606
1647
|
}
|
|
1607
1648
|
var CustomContextItemsResource = class {
|
|
1649
|
+
/** @internal */
|
|
1608
1650
|
constructor(http, config) {
|
|
1609
1651
|
this.http = http;
|
|
1610
1652
|
this.config = config;
|
|
1611
1653
|
}
|
|
1654
|
+
/**
|
|
1655
|
+
* List custom context items.
|
|
1656
|
+
*
|
|
1657
|
+
* @param options.pageSize - Maximum items per page (default 25).
|
|
1658
|
+
* @param options.pageToken - Opaque token from a previous page.
|
|
1659
|
+
* @param options.searchQuery - Free-text search filter.
|
|
1660
|
+
* @param options.topics - Filter to items tagged with any of these topics.
|
|
1661
|
+
* @returns A page of custom context items.
|
|
1662
|
+
*/
|
|
1612
1663
|
list(options = {}) {
|
|
1613
1664
|
const pageSize = options.pageSize ?? 25;
|
|
1614
1665
|
validatePageSize(pageSize);
|
|
@@ -1630,6 +1681,13 @@ var CustomContextItemsResource = class {
|
|
|
1630
1681
|
(token) => this.listPage(pageSize, token, options)
|
|
1631
1682
|
);
|
|
1632
1683
|
}
|
|
1684
|
+
/**
|
|
1685
|
+
* Retrieve a custom context item by uid.
|
|
1686
|
+
*
|
|
1687
|
+
* @param uid - Item uid.
|
|
1688
|
+
* @returns The custom context item.
|
|
1689
|
+
* @throws {NotFoundError} When no item matches the uid.
|
|
1690
|
+
*/
|
|
1633
1691
|
async get(uid) {
|
|
1634
1692
|
return parseContextItem(
|
|
1635
1693
|
await invokeWithRetry(this.config, this.http, "CustomContextItemsController_get", {
|
|
@@ -1637,6 +1695,26 @@ var CustomContextItemsResource = class {
|
|
|
1637
1695
|
})
|
|
1638
1696
|
);
|
|
1639
1697
|
}
|
|
1698
|
+
/**
|
|
1699
|
+
* Create a custom context item.
|
|
1700
|
+
*
|
|
1701
|
+
* @param input.kind - Item kind (`source`, `collection`, `entity`, `field`, or `entity_samples`).
|
|
1702
|
+
* @param input.sourceId - Source identifier for the item hierarchy.
|
|
1703
|
+
* @param input.name - Display name when applicable.
|
|
1704
|
+
* @param input.content - Item payload.
|
|
1705
|
+
* @param input.idempotencyKey - Optional idempotency key for safe retries.
|
|
1706
|
+
* @returns Created item ids and hierarchy metadata.
|
|
1707
|
+
*
|
|
1708
|
+
* @example
|
|
1709
|
+
* ```ts
|
|
1710
|
+
* const created = await client.context.customItems.create({
|
|
1711
|
+
* kind: 'entity',
|
|
1712
|
+
* sourceId: 'my-source',
|
|
1713
|
+
* name: 'Q3 churn notes',
|
|
1714
|
+
* content: { summary: 'Key findings…' },
|
|
1715
|
+
* })
|
|
1716
|
+
* ```
|
|
1717
|
+
*/
|
|
1640
1718
|
async create(input) {
|
|
1641
1719
|
return parseCreatedCustomContextItem(
|
|
1642
1720
|
await invokeWithRetry(this.config, this.http, "CustomContextItemsController_create", {
|
|
@@ -1644,6 +1722,20 @@ var CustomContextItemsResource = class {
|
|
|
1644
1722
|
})
|
|
1645
1723
|
);
|
|
1646
1724
|
}
|
|
1725
|
+
/**
|
|
1726
|
+
* Create multiple custom context items in one request.
|
|
1727
|
+
*
|
|
1728
|
+
* @param inputs - Items to create (same fields as {@link CustomContextItemsResource.create}).
|
|
1729
|
+
* @returns Created item metadata for each input.
|
|
1730
|
+
*
|
|
1731
|
+
* @example
|
|
1732
|
+
* ```ts
|
|
1733
|
+
* const created = await client.context.customItems.batchCreate([
|
|
1734
|
+
* { kind: 'field', sourceId: 'src', fieldName: 'region', dataType: 'string' },
|
|
1735
|
+
* { kind: 'field', sourceId: 'src', fieldName: 'amount', dataType: 'number' },
|
|
1736
|
+
* ])
|
|
1737
|
+
* ```
|
|
1738
|
+
*/
|
|
1647
1739
|
async batchCreate(inputs) {
|
|
1648
1740
|
const data = asRecord(
|
|
1649
1741
|
await invokeWithRetry(this.config, this.http, "CustomContextItemsController_batchCreate", {
|
|
@@ -1655,6 +1747,13 @@ var CustomContextItemsResource = class {
|
|
|
1655
1747
|
const items = data.contextItems;
|
|
1656
1748
|
return Array.isArray(items) ? items.map(parseCreatedCustomContextItem) : [];
|
|
1657
1749
|
}
|
|
1750
|
+
/**
|
|
1751
|
+
* Update a custom context item.
|
|
1752
|
+
*
|
|
1753
|
+
* @param uid - Item uid.
|
|
1754
|
+
* @param input - Fields to change (kind and hierarchy ids cannot be changed).
|
|
1755
|
+
* @returns The updated item uid.
|
|
1756
|
+
*/
|
|
1658
1757
|
async update(uid, input) {
|
|
1659
1758
|
return asRecord(
|
|
1660
1759
|
await invokeWithRetry(this.config, this.http, "CustomContextItemsController_update", {
|
|
@@ -1663,6 +1762,12 @@ var CustomContextItemsResource = class {
|
|
|
1663
1762
|
})
|
|
1664
1763
|
);
|
|
1665
1764
|
}
|
|
1765
|
+
/**
|
|
1766
|
+
* Delete a custom context item.
|
|
1767
|
+
*
|
|
1768
|
+
* @param uid - Item uid.
|
|
1769
|
+
* @returns Deletion confirmation with uid and context type.
|
|
1770
|
+
*/
|
|
1666
1771
|
async delete(uid) {
|
|
1667
1772
|
return parseDeletion(
|
|
1668
1773
|
await invokeWithRetry(this.config, this.http, "CustomContextItemsController_delete", {
|
|
@@ -1685,6 +1790,13 @@ var ScopeConversationsResource = class {
|
|
|
1685
1790
|
this.config = config;
|
|
1686
1791
|
this.scopeId = scopeId;
|
|
1687
1792
|
}
|
|
1793
|
+
/**
|
|
1794
|
+
* List conversation threads for this scope, newest first.
|
|
1795
|
+
*
|
|
1796
|
+
* @param options.pageSize - Items per page (default 25).
|
|
1797
|
+
* @param options.pageToken - Opaque token from a previous page.
|
|
1798
|
+
* @returns Page of conversation list items.
|
|
1799
|
+
*/
|
|
1688
1800
|
list(options = {}) {
|
|
1689
1801
|
const pageSize = options.pageSize ?? 25;
|
|
1690
1802
|
validatePageSize(pageSize);
|
|
@@ -1705,6 +1817,14 @@ var ScopeConversationsResource = class {
|
|
|
1705
1817
|
(token) => this.listPage(pageSize, token)
|
|
1706
1818
|
);
|
|
1707
1819
|
}
|
|
1820
|
+
/**
|
|
1821
|
+
* Retrieve a thread with full message history.
|
|
1822
|
+
*
|
|
1823
|
+
* @param threadId - Conversation thread id.
|
|
1824
|
+
* @param options.messageLimit - Maximum messages to return (1–100).
|
|
1825
|
+
* @param options.beforeMessageIndex - Return messages before this index (requires messageLimit).
|
|
1826
|
+
* @returns Conversation with messages.
|
|
1827
|
+
*/
|
|
1708
1828
|
async get(threadId, options = {}) {
|
|
1709
1829
|
validateId(this.scopeId, "scope_id");
|
|
1710
1830
|
validateId(threadId, "thread_id");
|
|
@@ -1754,4 +1874,4 @@ export {
|
|
|
1754
1874
|
CustomContextItemsResource,
|
|
1755
1875
|
ScopeConversationsResource
|
|
1756
1876
|
};
|
|
1757
|
-
//# sourceMappingURL=chunk-
|
|
1877
|
+
//# sourceMappingURL=chunk-I56O44TR.js.map
|