@carbonaitech/ottofiles-mcp 1.1.0-rc.1 → 1.2.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 +60 -12
- package/dist/config.js +9 -2
- package/dist/config.js.map +1 -1
- package/dist/content.js +22 -0
- package/dist/content.js.map +1 -0
- package/dist/gateway.js +99 -17
- package/dist/gateway.js.map +1 -1
- package/dist/http.js +549 -0
- package/dist/http.js.map +1 -0
- package/dist/index.js +75 -227
- package/dist/index.js.map +1 -1
- package/dist/introspect.js +285 -0
- package/dist/introspect.js.map +1 -0
- package/dist/readTools.js +130 -0
- package/dist/readTools.js.map +1 -0
- package/dist/tools/addWorkspaceDocuments.js +4 -4
- package/dist/tools/addWorkspaceDocuments.js.map +1 -1
- package/dist/tools/addWorkspaceMember.js +3 -3
- package/dist/tools/addWorkspaceMember.js.map +1 -1
- package/dist/tools/cloneDocument.js +247 -0
- package/dist/tools/cloneDocument.js.map +1 -0
- package/dist/tools/createDocument.js +14 -5
- package/dist/tools/createDocument.js.map +1 -1
- package/dist/tools/createWorkspace.js +27 -9
- package/dist/tools/createWorkspace.js.map +1 -1
- package/dist/tools/deleteWorkspace.js +3 -5
- package/dist/tools/deleteWorkspace.js.map +1 -1
- package/dist/tools/documentAccessRoster.js +25 -10
- package/dist/tools/documentAccessRoster.js.map +1 -1
- package/dist/tools/editMetadata.js +2 -2
- package/dist/tools/editMetadata.js.map +1 -1
- package/dist/tools/exportDocuments.js +264 -0
- package/dist/tools/exportDocuments.js.map +1 -0
- package/dist/tools/fileTypes.js +21 -0
- package/dist/tools/fileTypes.js.map +1 -0
- package/dist/tools/getDocument.js +3 -3
- package/dist/tools/getDocument.js.map +1 -1
- package/dist/tools/getDocumentHistory.js +5 -5
- package/dist/tools/getDocumentHistory.js.map +1 -1
- package/dist/tools/getDocumentVersions.js +3 -3
- package/dist/tools/getDocumentVersions.js.map +1 -1
- package/dist/tools/getPolicyStats.js +4 -4
- package/dist/tools/getPolicyStats.js.map +1 -1
- package/dist/tools/groupDocuments.js +35 -14
- package/dist/tools/groupDocuments.js.map +1 -1
- package/dist/tools/guarded.js +22 -2
- package/dist/tools/guarded.js.map +1 -1
- package/dist/tools/listCompanies.js +2 -2
- package/dist/tools/listCompanies.js.map +1 -1
- package/dist/tools/listPolicies.js +3 -3
- package/dist/tools/listPolicies.js.map +1 -1
- package/dist/tools/listWorkspaces.js +18 -4
- package/dist/tools/listWorkspaces.js.map +1 -1
- package/dist/tools/lockDocument.js +1 -1
- package/dist/tools/lockDocument.js.map +1 -1
- package/dist/tools/manageAccess.js +60 -101
- package/dist/tools/manageAccess.js.map +1 -1
- package/dist/tools/myAccess.js +5 -5
- package/dist/tools/myAccess.js.map +1 -1
- package/dist/tools/policyAccessRoster.js +23 -9
- package/dist/tools/policyAccessRoster.js.map +1 -1
- package/dist/tools/reactivateWorkspace.js +2 -2
- package/dist/tools/reactivateWorkspace.js.map +1 -1
- package/dist/tools/removeWorkspaceDocument.js +3 -7
- package/dist/tools/removeWorkspaceDocument.js.map +1 -1
- package/dist/tools/removeWorkspaceMember.js +4 -4
- package/dist/tools/removeWorkspaceMember.js.map +1 -1
- package/dist/tools/searchContent.js +14 -8
- package/dist/tools/searchContent.js.map +1 -1
- package/dist/tools/searchDocuments.js +20 -14
- package/dist/tools/searchDocuments.js.map +1 -1
- package/dist/tools/setStatus.js +3 -3
- package/dist/tools/setStatus.js.map +1 -1
- package/dist/tools/shareDocument.js +20 -16
- package/dist/tools/shareDocument.js.map +1 -1
- package/dist/tools/switchCompany.js +1 -2
- package/dist/tools/switchCompany.js.map +1 -1
- package/dist/tools/unlockDocument.js +2 -2
- package/dist/tools/unlockDocument.js.map +1 -1
- package/dist/tools/unshareDocument.js +7 -7
- package/dist/tools/unshareDocument.js.map +1 -1
- package/dist/tools/uploadVersion.js +12 -1
- package/dist/tools/uploadVersion.js.map +1 -1
- package/package.json +7 -5
- package/dist/tools/deleteDocument.js +0 -98
- package/dist/tools/deleteDocument.js.map +0 -1
- package/dist/tools/restoreDocument.js +0 -101
- package/dist/tools/restoreDocument.js.map +0 -1
package/README.md
CHANGED
|
@@ -16,7 +16,8 @@ CLI**. Cloud-only clients (**claude.ai web/mobile, ChatGPT, Microsoft Copilot**)
|
|
|
16
16
|
can connect only to a remote HTTPS MCP server and **cannot use this package** —
|
|
17
17
|
see [Cloud clients](#cloud-clients-not-supported-by-this-package).
|
|
18
18
|
|
|
19
|
-
Requires **Node
|
|
19
|
+
Requires **Node 20.3+** on your PATH (the gateway path uses `AbortSignal.any`).
|
|
20
|
+
The three `OTTOFILES_*` values below are the
|
|
20
21
|
**dev** environment and are identical for every user; pin the version
|
|
21
22
|
(`@1.1.0`) so a client always spawns a known build.
|
|
22
23
|
|
|
@@ -24,7 +25,7 @@ Requires **Node 18+** on your PATH. The three `OTTOFILES_*` values below are the
|
|
|
24
25
|
|
|
25
26
|
```bash
|
|
26
27
|
claude mcp add ottofiles \
|
|
27
|
-
--env OTTOFILES_ISSUER=https://
|
|
28
|
+
--env OTTOFILES_ISSUER=https://identity.dev.lukla.com \
|
|
28
29
|
--env OTTOFILES_GATEWAY_URL=https://gateways.ottofiles.dev.carbonai.ca \
|
|
29
30
|
--env OTTOFILES_CLIENT_ID=ottofiles_mcp_cli \
|
|
30
31
|
-- npx -y @carbonaitech/ottofiles-mcp@1.1.0
|
|
@@ -52,7 +53,7 @@ Edit Config):
|
|
|
52
53
|
"command": "npx",
|
|
53
54
|
"args": ["-y", "@carbonaitech/ottofiles-mcp@1.1.0"],
|
|
54
55
|
"env": {
|
|
55
|
-
"OTTOFILES_ISSUER": "https://
|
|
56
|
+
"OTTOFILES_ISSUER": "https://identity.dev.lukla.com",
|
|
56
57
|
"OTTOFILES_GATEWAY_URL": "https://gateways.ottofiles.dev.carbonai.ca",
|
|
57
58
|
"OTTOFILES_CLIENT_ID": "ottofiles_mcp_cli"
|
|
58
59
|
}
|
|
@@ -80,7 +81,7 @@ VS Code's `mcp.json`, or Windsurf's `mcp_config.json`):
|
|
|
80
81
|
"command": "npx",
|
|
81
82
|
"args": ["-y", "@carbonaitech/ottofiles-mcp@1.1.0"],
|
|
82
83
|
"env": {
|
|
83
|
-
"OTTOFILES_ISSUER": "https://
|
|
84
|
+
"OTTOFILES_ISSUER": "https://identity.dev.lukla.com",
|
|
84
85
|
"OTTOFILES_GATEWAY_URL": "https://gateways.ottofiles.dev.carbonai.ca",
|
|
85
86
|
"OTTOFILES_CLIENT_ID": "ottofiles_mcp_cli"
|
|
86
87
|
}
|
|
@@ -101,8 +102,48 @@ env values above.
|
|
|
101
102
|
|
|
102
103
|
**claude.ai (web + mobile), ChatGPT, and Microsoft Copilot** can only add a
|
|
103
104
|
**remote HTTPS** MCP server with OAuth; they cannot spawn a local stdio process.
|
|
104
|
-
This package is stdio-only, so those clients
|
|
105
|
-
|
|
105
|
+
This npm package is stdio-only, so those clients install it only via the hosted
|
|
106
|
+
transport below.
|
|
107
|
+
|
|
108
|
+
### Hosted mode (preview)
|
|
109
|
+
|
|
110
|
+
A hosted **Streamable HTTP** transport runs the same server for cloud clients at
|
|
111
|
+
`https://mcp.ottofiles.dev.carbonai.ca/mcp` (dev). It exposes the **read-only
|
|
112
|
+
tools only** — the write tools stay on stdio for now, because their preview-token
|
|
113
|
+
key is per-process and can't survive multiple stateless replicas. Add that URL as
|
|
114
|
+
a remote MCP server; the client runs OAuth against `https://identity.dev.lukla.com`
|
|
115
|
+
(the server advertises Protected Resource Metadata and requires the
|
|
116
|
+
`lukla_mcp_api` scope). Each request carries your bearer, which the server
|
|
117
|
+
introspects for audience and then forwards to the gateway, so results are scoped
|
|
118
|
+
to your own tier and ACLs exactly as on stdio.
|
|
119
|
+
|
|
120
|
+
Run it locally with `npm run start:http` (or the `ottofiles-mcp-http` bin); it
|
|
121
|
+
needs `OTTOFILES_INTROSPECTION_CLIENT_ID` / `OTTOFILES_INTROSPECTION_CLIENT_SECRET`
|
|
122
|
+
to validate incoming tokens, and listens on `PORT` (default 8080) with a
|
|
123
|
+
`/healthz` probe. The POST body is capped at 256 KB (`OTTOFILES_MAX_BODY_BYTES`);
|
|
124
|
+
JSON-RPC batches (a top-level array) are rejected 400, and each request is
|
|
125
|
+
admission-controlled by a **two-tier** limiter keyed per user by the token's
|
|
126
|
+
`sub` (so a user's reconnect/refresh tokens share one budget). Tier 1 is a
|
|
127
|
+
per-user flood token bucket over all message types, checked before the body is
|
|
128
|
+
read (`OTTOFILES_FLOOD_RPS` 20 / `OTTOFILES_FLOOD_BURST` 40 → 429). Tier 2
|
|
129
|
+
applies only to `tools/call`: a global in-flight ceiling (`OTTOFILES_MAX_INFLIGHT`
|
|
130
|
+
24 → 503), a per-user in-flight cap (`OTTOFILES_USER_MAX_INFLIGHT` 6) and a
|
|
131
|
+
per-user token bucket (`OTTOFILES_USER_RPS` 10 / `OTTOFILES_USER_BURST` 20 → 429);
|
|
132
|
+
all with `Retry-After`. Concurrent **live** introspections (cache misses) are
|
|
133
|
+
bounded by a semaphore inside the introspector (`OTTOFILES_MAX_INTROSPECTIONS`
|
|
134
|
+
16); a cache **hit** takes no slot, so a junk-bearer flood can't turn away a
|
|
135
|
+
signed-in user whose token is cached. On saturation a miss waits ~1s for a slot,
|
|
136
|
+
then → 503 `introspection_busy`. Under a sustained junk-bearer flood a **first**
|
|
137
|
+
login may get a 503 `introspection_busy` (`Retry-After: 1`) and a signed-in user
|
|
138
|
+
may see at most one 503 per ~45s cache expiry — acceptable and self-recovering.
|
|
139
|
+
A client disconnect cancels the in-flight
|
|
140
|
+
gateway work for a **read** tool call (the tool-call abort signal is forwarded to
|
|
141
|
+
the gateway fetch) and releases the slot. The `/mcp` response is byte-capped at
|
|
142
|
+
1 MB (`OTTOFILES_MAX_MCP_RESPONSE_BYTES`), a backstop well above any legitimate
|
|
143
|
+
result. The HTTP server sets `headersTimeout` 20s and `requestTimeout` 120s. The
|
|
144
|
+
container (`Dockerfile`) deploys to dev AKS via `.helm-dev/`. Write tools are
|
|
145
|
+
stdio-only and run to completion (not exposed over HTTP); a client cancel never
|
|
146
|
+
tears a write midway.
|
|
106
147
|
|
|
107
148
|
### Signing in (loopback OAuth)
|
|
108
149
|
|
|
@@ -123,14 +164,14 @@ All read-only except `switch_company` and the write tools below, all scoped to t
|
|
|
123
164
|
| Tool | Wraps | Purpose |
|
|
124
165
|
|------|-------|---------|
|
|
125
166
|
| `search_documents` | `POST /api/search/documents` | Find documents by text, number, type, status, policy, tier, or date — paged and sorted. |
|
|
126
|
-
| `group_documents` | `POST /api/search/documents/group` | Per-bucket counts + last-modified over the whole tier-visible corpus (the "group summary"). |
|
|
167
|
+
| `group_documents` | `POST /api/search/documents/group` | Per-bucket counts + last-modified over the whole tier-visible corpus (the "group summary"). `statusCodeId` buckets also carry `policyId`/`policyName`. Capped at 200 buckets (`truncated` flag, real `total`). |
|
|
127
168
|
| `list_policies` | `GET /api/policies` | List accessible policies with code, name, state, and document count. |
|
|
128
169
|
| `get_policy_stats` | `GET /api/policies/{id}/stats` | Aggregate a policy: document count, storage, counts by type/status, top contributors. |
|
|
129
|
-
| `policy_access_roster` | `GET /api/policies/{id}/access-roster` | Who can access a policy and who is denied, with effective tier
|
|
170
|
+
| `policy_access_roster` | `GET /api/policies/{id}/access-roster` | Administrator only. Who can access a policy and who is denied, with each user's effective tier. Counts come on page 1 only. |
|
|
130
171
|
| `get_document` | `GET /documents/{id}` | Full detail for one document: status, version, file metadata, anchors, lock state. |
|
|
131
172
|
| `get_document_versions` | `GET /documents/{id}/versions` | Every version — increment, label, file, upload status, who and when. |
|
|
132
|
-
| `document_access_roster` | `GET /api/documents/{id}/access-roster` | Who can access a document and who
|
|
133
|
-
| `list_workspaces` | `GET /api/workspaces` | External share spaces — title, document and member counts, expiry state. |
|
|
173
|
+
| `document_access_roster` | `GET /api/documents/{id}/access-roster` | Who can access a document and who holds an explicit grant. Deny flags, the denied count, granted-by and tiers are shown to administrators only. Counts come on page 1 only. |
|
|
174
|
+
| `list_workspaces` | `GET /api/workspaces` | External share spaces — title, document and member counts, expiry state. Capped at 200 (`truncated` flag, real `total`). `includeRevoked`/`includeExpired` only widen the set. |
|
|
134
175
|
| `search_content` | `POST /api/search/documents` (`ContentSearch: true`) | Search inside extracted file-body text, with a snippet and `matchedInContent` flag per hit. |
|
|
135
176
|
| `get_document_history` | `GET /audits/streams/scope` (`Type=Document`) | A document's audit trail — who did what and when, with before/after values. Access-checked via `GET /documents/{id}`. |
|
|
136
177
|
| `my_access` | `GET /profile`, `GET /api/tiers/users/{id}`, `GET /api/tiers/users/{id}/policy-overrides`, `GET /api/policies` | The signed-in user's roles, security tier, policy tier overrides, and visible policies. |
|
|
@@ -139,15 +180,22 @@ All read-only except `switch_company` and the write tools below, all scoped to t
|
|
|
139
180
|
|
|
140
181
|
## Write tools
|
|
141
182
|
|
|
142
|
-
`create_document`, `set_status`, `edit_metadata`, `manage_access`, `upload_version`, `lock_document`, `unlock_document`, `share_document`, `unshare_document`, `create_workspace`, `delete_workspace`, `reactivate_workspace`, `add_workspace_member`, `remove_workspace_member`, `add_workspace_documents` and `remove_workspace_document` change data. All are interactive-OAuth only.
|
|
183
|
+
`create_document`, `clone_document`, `set_status`, `edit_metadata`, `manage_access`, `upload_version`, `lock_document`, `unlock_document`, `share_document`, `unshare_document`, `create_workspace`, `delete_workspace`, `reactivate_workspace`, `add_workspace_member`, `remove_workspace_member`, `add_workspace_documents` and `remove_workspace_document` change data. All are interactive-OAuth only.
|
|
143
184
|
|
|
144
185
|
`create_document` creates a brand-new document in an explicit `policyId` (the policy must be Published; drafts are refused) and uploads a file as its first version. Every number-forming anchor (an anchor whose name is in the policy's document-number pattern) is required; tier and status default to the policy's defaults. The preview renders the expected document number before anything is written.
|
|
145
186
|
|
|
187
|
+
`clone_document` creates a new document by copying an existing one's metadata (policy, title, description, clientNumber, status, tier, anchors) and attaching a **new** file — it does not copy the source file and does not link the two. The title defaults to the source title + " (Copy)"; any field can be overridden, and `anchorOverrides` replaces or adds specific anchors while the rest carry over. Source anchors the target policy's schema no longer has (migration drift) are dropped from the carry-over and listed as `droppedAnchors` in the preview/result; an explicit override naming a non-policy anchor still errors. Like `create_document`, it previews (rendering the expected document number) then confirms.
|
|
188
|
+
|
|
189
|
+
`export_documents` is **members only** and is not a preview/confirm tool: it exports documents (scoped by `policyId` and/or `documentIds`) to an `.xlsx` and saves it directly to a local folder. It writes a backend export-history row too. See "Local exports" below.
|
|
190
|
+
|
|
146
191
|
**Do NOT allowlist or auto-approve the write tools in your MCP client.** Leave them on per-call approval. The preview token and confirmation prompts below cannot create a human gate that the client has approved away; an agent that controls both the preview and the confirm call (for example through prompt injection in a document it read) can still satisfy the token.
|
|
147
192
|
|
|
148
193
|
- **Preview, then confirm.** Every write tool previews first (`confirm` omitted or `false`; nothing changes). The preview returns a `previewToken`. `confirm:true` is refused unless it carries a valid, unexpired `previewToken` from a preview with identical effect-defining arguments. The token is an HMAC signed with a per-process random key (not persisted; restarting the server invalidates outstanding tokens) and lives 10 minutes (`OTTOFILES_PREVIEW_TTL_SECONDS`, clamped to 30-3600).
|
|
149
194
|
- **External disclosure.** When a tool would expose documents to someone outside the company (`create_workspace`, `add_workspace_member`, `add_workspace_documents`, `reactivate_workspace`), the client is asked via MCP elicitation, naming the recipients. If the client does not support elicitation, the call is refused unless `confirmedExternalEmails` contains exactly the external emails from the preview. `manage_access` deny and revoke also ask via elicitation when available.
|
|
150
|
-
- **
|
|
195
|
+
- **Document access.** `manage_access` can only revoke, deny or undeny (Administrator role; revoke runs through `POST /api/permissions/bulk/assign` with `grant:false`, deny/undeny through `POST`/`DELETE /api/permissions/deny`). It cannot grant: grants come only from document shares and workspaces, so use `share_document` to give someone access.
|
|
196
|
+
- **Local file uploads.** `upload_version`, `create_document` and `clone_document` read a file from this machine and are **disabled by default**. Set `OTTOFILES_UPLOAD_ROOTS` to the absolute directories they may read from (separated by `:` on Linux/macOS, `;` on Windows, or commas). Paths are resolved through symlinks and must sit under one of the roots; anything else is refused without revealing whether it exists.
|
|
197
|
+
- **Local exports.** `export_documents` writes an `.xlsx` to this machine and is **disabled by default**. Set `OTTOFILES_DOWNLOAD_ROOTS` (parsed exactly like `OTTOFILES_UPLOAD_ROOTS`) to the absolute directories it may write into. `outputDir` is resolved through symlinks, must already exist, and must sit under one of the roots; the file name is sanitized to a bare `.xlsx` name. Export is restricted to company members (a portal/external token is refused by the service).
|
|
198
|
+
- **File types.** Only these endings can be uploaded (case-insensitive, last ending counts): `.pdf`, `.doc`, `.docx`, `.xls`, `.xlsx`, `.ppt`, `.pptx`, `.dwg`, `.dxf`, `.jpg`, `.jpeg`, `.png`, `.heic`, `.heif`, `.txt`, `.csv`, `.md`, `.eml`, `.zip`, `.key`. A file without an ending is refused. The MCP checks this before calling the Document service, so a refused file never leaves an empty document behind; the list mirrors Document's `AllowedFileTypes`.
|
|
151
199
|
- **Workspaces.** `expiresAt` must be within 90 days; `message` is capped at 500 characters, titles at 200, member names at 100. All three are sent verbatim in the invitation email and shown in the preview.
|
|
152
200
|
- Duplicate-submission guards are per process and are lost when the server restarts.
|
|
153
201
|
|
package/dist/config.js
CHANGED
|
@@ -75,9 +75,10 @@ export function loadConfig() {
|
|
|
75
75
|
mode,
|
|
76
76
|
redirectPort: parseRedirectPort(process.env.OTTOFILES_REDIRECT_PORT),
|
|
77
77
|
uploadRoots: parseUploadRoots(process.env.OTTOFILES_UPLOAD_ROOTS),
|
|
78
|
+
downloadRoots: parseDownloadRoots(process.env.OTTOFILES_DOWNLOAD_ROOTS),
|
|
78
79
|
};
|
|
79
80
|
}
|
|
80
|
-
|
|
81
|
+
function parseRoots(raw, varName) {
|
|
81
82
|
if (!raw || raw.trim() === "")
|
|
82
83
|
return [];
|
|
83
84
|
const roots = [];
|
|
@@ -86,12 +87,18 @@ export function parseUploadRoots(raw) {
|
|
|
86
87
|
if (!v)
|
|
87
88
|
continue;
|
|
88
89
|
if (!path.isAbsolute(v)) {
|
|
89
|
-
throw new Error(
|
|
90
|
+
throw new Error(`${varName} entries must be absolute directories (got "${v}").`);
|
|
90
91
|
}
|
|
91
92
|
roots.push(path.resolve(v));
|
|
92
93
|
}
|
|
93
94
|
return roots;
|
|
94
95
|
}
|
|
96
|
+
export function parseUploadRoots(raw) {
|
|
97
|
+
return parseRoots(raw, "OTTOFILES_UPLOAD_ROOTS");
|
|
98
|
+
}
|
|
99
|
+
export function parseDownloadRoots(raw) {
|
|
100
|
+
return parseRoots(raw, "OTTOFILES_DOWNLOAD_ROOTS");
|
|
101
|
+
}
|
|
95
102
|
function parseRedirectPort(raw) {
|
|
96
103
|
if (raw === undefined || raw.trim() === "")
|
|
97
104
|
return 8765;
|
package/dist/config.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACnD,OAAO,IAAI,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAChD,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACnD,OAAO,IAAI,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAChD,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAmBzC,0EAA0E;AAC1E,0EAA0E;AAC1E,8EAA8E;AAC9E,6EAA6E;AAC7E,kBAAkB;AAClB,SAAS,UAAU;IACjB,MAAM,IAAI,GAAG,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;IACrD,+EAA+E;IAC/E,iFAAiF;IACjF,gEAAgE;IAChE,2EAA2E;IAC3E,iFAAiF;IACjF,MAAM,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC,k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;IACxD,OAAO,UAAU,CAAC,GAAG,EAAE,0BAA0B,CAAC,CAAC;AACrD,CAAC;AAED,SAAS,iBAAiB,CAAC,GAAuB;IAChD,IAAI,GAAG,KAAK,SAAS,IAAI,GAAG,CAAC,IAAI,EAAE,KAAK,EAAE;QAAE,OAAO,IAAI,CAAC;IACxD,MAAM,CAAC,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC;IACtB,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,KAAK,EAAE,CAAC;QAC/C,MAAM,IAAI,KAAK,CACb,4DAA4D,GAAG,mDAAmD,CACnH,CAAC;IACJ,CAAC;IACD,OAAO,CAAC,CAAC;AACX,CAAC"}
|
package/dist/content.js
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { GatewayError } from "./gateway.js";
|
|
2
|
+
export function jsonContent(data) {
|
|
3
|
+
return {
|
|
4
|
+
content: [{ type: "text", text: JSON.stringify(data, null, 2) }],
|
|
5
|
+
};
|
|
6
|
+
}
|
|
7
|
+
export function errorContent(err) {
|
|
8
|
+
let text;
|
|
9
|
+
if (err instanceof GatewayError) {
|
|
10
|
+
text =
|
|
11
|
+
`OttoFiles request failed (HTTP ${err.status}).\n${err.message}` +
|
|
12
|
+
(err.body ? `\nResponse: ${err.body.slice(0, 800)}` : "");
|
|
13
|
+
}
|
|
14
|
+
else if (err instanceof Error) {
|
|
15
|
+
text = err.message;
|
|
16
|
+
}
|
|
17
|
+
else {
|
|
18
|
+
text = String(err);
|
|
19
|
+
}
|
|
20
|
+
return { isError: true, content: [{ type: "text", text }] };
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=content.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"content.js","sourceRoot":"","sources":["../src/content.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAE5C,MAAM,UAAU,WAAW,CAAC,IAAa;IACvC,OAAO;QACL,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAe,EAAE,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,CAAC;KAC1E,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,YAAY,CAAC,GAAY;IACvC,IAAI,IAAY,CAAC;IACjB,IAAI,GAAG,YAAY,YAAY,EAAE,CAAC;QAChC,IAAI;YACF,kCAAkC,GAAG,CAAC,MAAM,OAAO,GAAG,CAAC,OAAO,EAAE;gBAChE,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,eAAe,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;IAC9D,CAAC;SAAM,IAAI,GAAG,YAAY,KAAK,EAAE,CAAC;QAChC,IAAI,GAAG,GAAG,CAAC,OAAO,CAAC;IACrB,CAAC;SAAM,CAAC;QACN,IAAI,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC;IACrB,CAAC;IACD,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAe,EAAE,IAAI,EAAE,CAAC,EAAE,CAAC;AACvE,CAAC"}
|
package/dist/gateway.js
CHANGED
|
@@ -12,6 +12,11 @@ export class GatewayError extends Error {
|
|
|
12
12
|
* Thin authed HTTP client for the OttoFiles gateway. Attaches the bearer token
|
|
13
13
|
* and retries exactly once on a 401 with a freshly-minted token (covers a token
|
|
14
14
|
* that expired or was revoked between cache and call).
|
|
15
|
+
*
|
|
16
|
+
* A call can carry an `AbortSignal` (from a read tool's `extra.signal`), combined
|
|
17
|
+
* with the per-request timeout so a client disconnect cancels the in-flight gateway
|
|
18
|
+
* fetch instead of leaving it to run. Write tools pass no signal (they run to
|
|
19
|
+
* completion), so cancelling a read is harmless while a write is never torn midway.
|
|
15
20
|
*/
|
|
16
21
|
export class GatewayClient {
|
|
17
22
|
config;
|
|
@@ -29,21 +34,32 @@ export class GatewayClient {
|
|
|
29
34
|
this.config = config;
|
|
30
35
|
this.tokens = tokens;
|
|
31
36
|
}
|
|
32
|
-
async postJson(path, payload) {
|
|
33
|
-
return this.gate(() => this.request("POST", path, payload));
|
|
37
|
+
async postJson(path, payload, signal) {
|
|
38
|
+
return this.gate(() => this.request("POST", path, payload, false, 0, signal));
|
|
34
39
|
}
|
|
35
|
-
async putJson(path, payload) {
|
|
36
|
-
return this.gate(() => this.request("PUT", path, payload));
|
|
40
|
+
async putJson(path, payload, signal) {
|
|
41
|
+
return this.gate(() => this.request("PUT", path, payload, false, 0, signal));
|
|
37
42
|
}
|
|
38
43
|
/** PUT raw bytes (application/octet-stream), e.g. one upload chunk. */
|
|
39
|
-
async putBytes(path, bytes) {
|
|
40
|
-
return this.gate(() => this.request("PUT", path, bytes));
|
|
44
|
+
async putBytes(path, bytes, signal) {
|
|
45
|
+
return this.gate(() => this.request("PUT", path, bytes, false, 0, signal));
|
|
41
46
|
}
|
|
42
|
-
async deleteJson(path) {
|
|
43
|
-
return this.gate(() => this.request("DELETE", path));
|
|
47
|
+
async deleteJson(path, signal) {
|
|
48
|
+
return this.gate(() => this.request("DELETE", path, undefined, false, 0, signal));
|
|
44
49
|
}
|
|
45
|
-
async getJson(path) {
|
|
46
|
-
return this.gate(() => this.request("GET", path));
|
|
50
|
+
async getJson(path, signal) {
|
|
51
|
+
return this.gate(() => this.request("GET", path, undefined, false, 0, signal));
|
|
52
|
+
}
|
|
53
|
+
/** GET returning the raw response bytes (not JSON-parsed), e.g. an export .xlsx download. */
|
|
54
|
+
async getRaw(path, signal) {
|
|
55
|
+
return this.gate(() => this.requestRaw("GET", path, undefined, false, 0, signal));
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* POST a JSON payload, returning the raw response bytes (not JSON-parsed). The caller
|
|
59
|
+
* branches on `status` (e.g. 200 .xlsx bytes vs 202 async-job JSON).
|
|
60
|
+
*/
|
|
61
|
+
async postRaw(path, payload, signal) {
|
|
62
|
+
return this.gate(() => this.requestRaw("POST", path, payload, false, 0, signal));
|
|
47
63
|
}
|
|
48
64
|
/** Run `fn` under the concurrency limit. */
|
|
49
65
|
async gate(fn) {
|
|
@@ -59,15 +75,38 @@ export class GatewayClient {
|
|
|
59
75
|
this.queue.shift()?.();
|
|
60
76
|
}
|
|
61
77
|
}
|
|
62
|
-
|
|
63
|
-
|
|
78
|
+
// Abortable sleep: resolves after `ms`, or rejects early if the per-call signal
|
|
79
|
+
// aborts, so a client disconnect cancels a 429 back-off wait instead of parking
|
|
80
|
+
// the request (and its concurrency slot) for up to the capped delay.
|
|
81
|
+
static sleep(ms, signal) {
|
|
82
|
+
return new Promise((resolve, reject) => {
|
|
83
|
+
if (signal?.aborted)
|
|
84
|
+
return reject(new DOMException("Aborted", "AbortError"));
|
|
85
|
+
const onAbort = () => {
|
|
86
|
+
clearTimeout(t);
|
|
87
|
+
reject(new DOMException("Aborted", "AbortError"));
|
|
88
|
+
};
|
|
89
|
+
const t = setTimeout(() => {
|
|
90
|
+
signal?.removeEventListener("abort", onAbort);
|
|
91
|
+
resolve();
|
|
92
|
+
}, ms);
|
|
93
|
+
signal?.addEventListener("abort", onAbort, { once: true });
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
// Combine the per-request timeout with the caller's per-call AbortSignal so a
|
|
97
|
+
// client disconnect cancels the fetch. Write tools pass none.
|
|
98
|
+
combinedSignal(perCall) {
|
|
99
|
+
const timeout = AbortSignal.timeout(GatewayClient.REQUEST_TIMEOUT_MS);
|
|
100
|
+
return perCall ? AbortSignal.any([timeout, perCall]) : timeout;
|
|
64
101
|
}
|
|
65
|
-
async request(method, path, payload, isRetry = false, retry429 = 0) {
|
|
102
|
+
async request(method, path, payload, isRetry = false, retry429 = 0, signal) {
|
|
66
103
|
const token = await this.tokens.getToken();
|
|
67
104
|
const url = `${this.config.gatewayUrl}${path}`;
|
|
68
105
|
const isBytes = payload instanceof Uint8Array;
|
|
69
106
|
const res = await fetch(url, {
|
|
70
|
-
signal:
|
|
107
|
+
signal: this.combinedSignal(signal),
|
|
108
|
+
// Never follow a redirect off the configured gateway origin.
|
|
109
|
+
redirect: "error",
|
|
71
110
|
method,
|
|
72
111
|
headers: {
|
|
73
112
|
Authorization: `Bearer ${token}`,
|
|
@@ -95,14 +134,14 @@ export class GatewayClient {
|
|
|
95
134
|
const waitMs = Number.isFinite(retryAfter) && retryAfter > 0
|
|
96
135
|
? Math.min(retryAfter * 1000, 30_000)
|
|
97
136
|
: Math.min(1000 * 2 ** retry429, 8000);
|
|
98
|
-
await GatewayClient.sleep(waitMs);
|
|
99
|
-
return this.request(method, path, payload, isRetry, retry429 + 1);
|
|
137
|
+
await GatewayClient.sleep(waitMs, signal);
|
|
138
|
+
return this.request(method, path, payload, isRetry, retry429 + 1, signal);
|
|
100
139
|
}
|
|
101
140
|
if (res.status === 401 && !isRetry) {
|
|
102
141
|
// Drop the cached token so getToken() actually re-acquires (refresh, or
|
|
103
142
|
// re-mint) rather than replaying the same rejected token, then retry once.
|
|
104
143
|
this.tokens.invalidate();
|
|
105
|
-
return this.request(method, path, payload, true);
|
|
144
|
+
return this.request(method, path, payload, true, 0, signal);
|
|
106
145
|
}
|
|
107
146
|
if (!res.ok) {
|
|
108
147
|
const body = await res.text().catch(() => "");
|
|
@@ -112,5 +151,48 @@ export class GatewayClient {
|
|
|
112
151
|
const text = await res.text();
|
|
113
152
|
return (text ? JSON.parse(text) : undefined);
|
|
114
153
|
}
|
|
154
|
+
// Raw-bytes sibling of request(): same bearer attach, redirect:"error", one 401
|
|
155
|
+
// re-acquire-and-retry, and 429 Retry-After backoff, but it returns the response
|
|
156
|
+
// bytes untouched (no JSON.parse) on any 2xx so a caller can branch on the status
|
|
157
|
+
// (e.g. 200 .xlsx vs 202 job JSON). Non-2xx still throws GatewayError, as the JSON path does.
|
|
158
|
+
async requestRaw(method, path, payload, isRetry = false, retry429 = 0, signal) {
|
|
159
|
+
const token = await this.tokens.getToken();
|
|
160
|
+
const url = `${this.config.gatewayUrl}${path}`;
|
|
161
|
+
const res = await fetch(url, {
|
|
162
|
+
signal: this.combinedSignal(signal),
|
|
163
|
+
redirect: "error",
|
|
164
|
+
method,
|
|
165
|
+
headers: {
|
|
166
|
+
Authorization: `Bearer ${token}`,
|
|
167
|
+
Accept: "*/*",
|
|
168
|
+
...(payload !== undefined ? { "Content-Type": "application/json" } : {}),
|
|
169
|
+
},
|
|
170
|
+
body: payload === undefined ? undefined : JSON.stringify(payload),
|
|
171
|
+
});
|
|
172
|
+
if (res.status === 429 && retry429 < GatewayClient.MAX_429_RETRIES) {
|
|
173
|
+
const retryAfter = Number(res.headers.get("retry-after"));
|
|
174
|
+
const waitMs = Number.isFinite(retryAfter) && retryAfter > 0
|
|
175
|
+
? Math.min(retryAfter * 1000, 30_000)
|
|
176
|
+
: Math.min(1000 * 2 ** retry429, 8000);
|
|
177
|
+
await GatewayClient.sleep(waitMs, signal);
|
|
178
|
+
return this.requestRaw(method, path, payload, isRetry, retry429 + 1, signal);
|
|
179
|
+
}
|
|
180
|
+
if (res.status === 401 && !isRetry) {
|
|
181
|
+
this.tokens.invalidate();
|
|
182
|
+
return this.requestRaw(method, path, payload, true, 0, signal);
|
|
183
|
+
}
|
|
184
|
+
if (!res.ok) {
|
|
185
|
+
const body = await res.text().catch(() => "");
|
|
186
|
+
throw new GatewayError(`OttoFiles gateway ${method} ${path} failed: ${res.status} ${res.statusText}`, res.status, body);
|
|
187
|
+
}
|
|
188
|
+
const bytes = new Uint8Array(await res.arrayBuffer());
|
|
189
|
+
return {
|
|
190
|
+
status: res.status,
|
|
191
|
+
contentType: res.headers.get("content-type"),
|
|
192
|
+
headers: res.headers,
|
|
193
|
+
bytes,
|
|
194
|
+
text: () => new TextDecoder().decode(bytes),
|
|
195
|
+
};
|
|
196
|
+
}
|
|
115
197
|
}
|
|
116
198
|
//# sourceMappingURL=gateway.js.map
|
package/dist/gateway.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gateway.js","sourceRoot":"","sources":["../src/gateway.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"gateway.js","sourceRoot":"","sources":["../src/gateway.ts"],"names":[],"mappings":"AAiBA,MAAM,OAAO,YAAa,SAAQ,KAAK;IAG1B;IACA;IAHX,YACE,OAAe,EACN,MAAc,EACd,IAAY;QAErB,KAAK,CAAC,OAAO,CAAC,CAAC;QAHN,WAAM,GAAN,MAAM,CAAQ;QACd,SAAI,GAAJ,IAAI,CAAQ;QAGrB,IAAI,CAAC,IAAI,GAAG,cAAc,CAAC;IAC7B,CAAC;CACF;AAED;;;;;;;;;GASG;AACH,MAAM,OAAO,aAAa;IAYL;IACA;IAZnB,2EAA2E;IAC3E,2DAA2D;IAC1C,aAAa,GAAG,CAAC,CAAC;IAC3B,MAAM,GAAG,CAAC,CAAC;IACF,KAAK,GAAsB,EAAE,CAAC;IAC/C,mDAAmD;IAC3C,MAAM,CAAU,eAAe,GAAG,CAAC,CAAC;IAC5C,+EAA+E;IACvE,MAAM,CAAU,kBAAkB,GAAG,OAAO,CAAC;IAErD,YACmB,MAAuB,EACvB,MAAmB;QADnB,WAAM,GAAN,MAAM,CAAiB;QACvB,WAAM,GAAN,MAAM,CAAa;IACnC,CAAC;IAEJ,KAAK,CAAC,QAAQ,CAAI,IAAY,EAAE,OAAgB,EAAE,MAAoB;QACpE,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,OAAO,CAAI,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC;IACnF,CAAC;IAED,KAAK,CAAC,OAAO,CAAI,IAAY,EAAE,OAAgB,EAAE,MAAoB;QACnE,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,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