@rockhopper-co/mcp-server 0.8.0 → 1.0.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 +78 -0
- package/README.md +8 -0
- package/dist/api-client.d.ts +72 -3
- package/dist/api-client.d.ts.map +1 -1
- package/dist/api-client.js +115 -3
- package/dist/api-client.js.map +1 -1
- package/dist/cli.js +7 -1
- package/dist/cli.js.map +1 -1
- package/dist/not-ready.d.ts +95 -0
- package/dist/not-ready.d.ts.map +1 -0
- package/dist/not-ready.js +151 -0
- package/dist/not-ready.js.map +1 -0
- package/dist/prompts/index.d.ts.map +1 -1
- package/dist/prompts/index.js +8 -0
- package/dist/prompts/index.js.map +1 -1
- package/dist/resources/changes.d.ts.map +1 -1
- package/dist/resources/changes.js +6 -0
- package/dist/resources/changes.js.map +1 -1
- package/dist/resources/orchestration-guide.md +23 -3
- package/dist/resources/teams.d.ts.map +1 -1
- package/dist/resources/teams.js +7 -1
- package/dist/resources/teams.js.map +1 -1
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +4 -2
- package/dist/server.js.map +1 -1
- package/dist/tools/get-cell-history.d.ts.map +1 -1
- package/dist/tools/get-cell-history.js +28 -4
- package/dist/tools/get-cell-history.js.map +1 -1
- package/dist/tools/search.d.ts.map +1 -1
- package/dist/tools/search.js +13 -1
- package/dist/tools/search.js.map +1 -1
- package/dist/tools/write-reviews.d.ts.map +1 -1
- package/dist/tools/write-reviews.js +58 -4
- package/dist/tools/write-reviews.js.map +1 -1
- package/dist/types.d.ts +58 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/zod-schemas.d.ts +24 -0
- package/dist/zod-schemas.d.ts.map +1 -1
- package/dist/zod-schemas.js +24 -0
- package/dist/zod-schemas.js.map +1 -1
- package/package.json +17 -7
package/CHANGELOG.md
CHANGED
|
@@ -4,9 +4,87 @@ All notable changes to this project are documented here. Follows
|
|
|
4
4
|
[Keep a Changelog](https://keepachangelog.com/en/1.1.0/) and
|
|
5
5
|
[Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
6
6
|
|
|
7
|
+
## [1.0.0] — 2026-08-10
|
|
8
|
+
|
|
9
|
+
**No code changed between `0.10.0` and `1.0.0`.** This release exists to fix a
|
|
10
|
+
versioning trap, and states a compatibility promise that was already true.
|
|
11
|
+
|
|
12
|
+
### Why 1.0.0
|
|
13
|
+
|
|
14
|
+
On a `0.x` version npm reads a caret range as **minor-locked**: `^0.9.0` means
|
|
15
|
+
`>=0.9.0 <0.10.0`, not `<1.0.0`. Nobody reads it that way. It cost two releases
|
|
16
|
+
— `mcp-gateway` sat on `^0.9.0` and could not receive `0.10.0`, the very release
|
|
17
|
+
it was waiting for, and before that on the same coupling one release earlier
|
|
18
|
+
(ENG-2165, ENG-2233). At `1.x` a caret finally means "any compatible version".
|
|
19
|
+
|
|
20
|
+
### The compatibility promise
|
|
21
|
+
|
|
22
|
+
From `1.0.0`, a breaking change to any of the following requires a major bump:
|
|
23
|
+
|
|
24
|
+
- **Tool names and their input schemas.** These are the load-bearing ones. The
|
|
25
|
+
schemas are runtime `zod` validators that execute **on the caller's machine**,
|
|
26
|
+
before any request is sent, so narrowing one breaks that caller no matter how
|
|
27
|
+
compatible the backend is. Widening a schema is not breaking; narrowing it is.
|
|
28
|
+
- **Resource URIs and templates**, and the prompts the server registers.
|
|
29
|
+
- **The CLI's flags and its stdio contract.**
|
|
30
|
+
|
|
31
|
+
Explicitly **not** covered, and free to change in a minor: internal modules, the
|
|
32
|
+
`dist/` layout, anything reachable only by deep-importing a path this package
|
|
33
|
+
does not document, and log output.
|
|
34
|
+
|
|
35
|
+
### Note for consumers
|
|
36
|
+
|
|
37
|
+
Move a `^0.x` range to `^1.0.0`. A `0.x` range will not pick this up.
|
|
38
|
+
|
|
7
39
|
## [Unreleased]
|
|
8
40
|
|
|
9
41
|
### Added
|
|
42
|
+
- **User and team ids are accepted as uuids (ENG-2230).** `reviewerIds` on
|
|
43
|
+
`create_review_request` and `{teamId}` in `rockhopper://teams/{teamId}` now
|
|
44
|
+
take either the version-7 uuid or the legacy numeric internal id, mixed
|
|
45
|
+
freely. Rockhopper re-keyed `user`, `team` and `workspace` onto uuids
|
|
46
|
+
(ENG-1966); until this release the published tool schema validated
|
|
47
|
+
`reviewerIds` as `z.array(z.number().int().positive())`, so a uuid was
|
|
48
|
+
refused **on your machine** before any request was sent — every version from
|
|
49
|
+
0.2.0 through 0.10.0 is affected, and no server-side change could fix it.
|
|
50
|
+
`UserSummary`, `Team` and `Workspace` gained the optional `id` (uuid) field
|
|
51
|
+
the API already returns, and `ApiClient.getTeam()` /
|
|
52
|
+
`ApiClient.createReviewRequest()` widened from `number` to `number | string`
|
|
53
|
+
(exported as the new `RockhopperId` type).
|
|
54
|
+
|
|
55
|
+
**Nothing that works today stops working.** The numeric form is accepted
|
|
56
|
+
until **2027-09-14** and removed after that date; migrate to the uuid before
|
|
57
|
+
then. Version, comment and review ids are unaffected and stay numeric.
|
|
58
|
+
|
|
59
|
+
- **Strict no-partial change history (`src/not-ready.ts`).** `get_cell_history`,
|
|
60
|
+
`search` and the `changes` resource refuse to answer while a file's change
|
|
61
|
+
history is still being built, instead of returning the fraction that happens
|
|
62
|
+
to be ready. Callers get an explicit not-ready answer they can retry.
|
|
63
|
+
|
|
64
|
+
### Fixed
|
|
65
|
+
- **The server announced version `0.1.0` to every client, at every release
|
|
66
|
+
(ENG-1955).** `createServer` passed a string literal to `McpServer`, so the
|
|
67
|
+
version in the MCP `initialize` response was `0.1.0` — unchanged since the
|
|
68
|
+
initial commit, so every published version (0.2.0 through 0.8.0) announced
|
|
69
|
+
itself as 0.1.0, both for the locally installed server and for every web
|
|
70
|
+
client reaching the same tools through `mcp-gateway`. It now reports
|
|
71
|
+
`package.json`'s version, which is what makes two builds distinguishable
|
|
72
|
+
at all.
|
|
73
|
+
|
|
74
|
+
### Added
|
|
75
|
+
- **Provenance-context emit on agent writes (ENG-1756 / decision 15).** Every
|
|
76
|
+
write call (`POST`/`PUT`/`PATCH`/`DELETE`) now carries
|
|
77
|
+
`X-Rockhopper-Surface` (`mcp`), a stable per-client-instance
|
|
78
|
+
`X-Rockhopper-Session-Id`, and — once the driving human is known —
|
|
79
|
+
`X-Driving-Human`. The CLI declares the PAT owner as the driving human from
|
|
80
|
+
its existing `/users/me` preflight. Reads are unchanged (no headers).
|
|
81
|
+
This satisfies the backend's decision-15 accountability invariant, which
|
|
82
|
+
rejects (403) an agent-surface write with no resolvable driving human, and
|
|
83
|
+
populates the `cell_change_provenance_context` sidecar for etymology reads.
|
|
84
|
+
New public API: `ApiClient` config `provenanceContext` +
|
|
85
|
+
`ApiClient.setDrivingHuman()` (used by `mcp-gateway` to declare the
|
|
86
|
+
`gateway` surface and its OAuth session id).
|
|
87
|
+
|
|
10
88
|
- **Local rotating diagnostic logfile (KI-225).** The server now writes a
|
|
11
89
|
local diagnostic log to `~/.rockhopper/mcp-server/` (rotated via
|
|
12
90
|
`pino-roll`, ~5 MB × 5 files). It captures request latency plus the
|
package/README.md
CHANGED
|
@@ -183,6 +183,14 @@ npm run generate:postman
|
|
|
183
183
|
| `cancel_review` | Cancel a pending review request (requester only) |
|
|
184
184
|
| `update_file_description` | Update the display name of an enrolled file |
|
|
185
185
|
|
|
186
|
+
## Identifiers
|
|
187
|
+
|
|
188
|
+
Users and teams are named by a **uuid** (`id`) — for example `0198f3a1-2b4c-7d8e-9f01-23456789abcd`. This is the identifier to send as a `reviewerIds` entry on `create_review_request`, and as `{teamId}` in `rockhopper://teams/{teamId}`. Read it from the team resource, where every record carries both an `id` (uuid) and an `internalId` (number).
|
|
189
|
+
|
|
190
|
+
The legacy numeric `internalId` is **also accepted** for users and teams, and the two spellings can be mixed in one `reviewerIds` array — nothing you have written today stops working. It is accepted until **2027-09-14** and removed after, so migrate to the uuid before then.
|
|
191
|
+
|
|
192
|
+
Everything else keeps its existing type: `fileMsId` is a string, and version and comment ids stay numeric.
|
|
193
|
+
|
|
186
194
|
## Development
|
|
187
195
|
|
|
188
196
|
```bash
|
package/dist/api-client.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { CellHistoryEntry, EnrolledFile, FileChat, FileVersion, PaginatedUnattributedResponse, ReviewActivity, ReviewRequest, Team, UnattributedChange, UserSummary } from './types.js';
|
|
1
|
+
import type { CellHistoryEntry, EnrolledFile, FileChat, FileVersion, FoldStatus, PaginatedUnattributedResponse, ReviewActivity, ReviewRequest, RockhopperId, Team, UnattributedChange, UserSummary } from './types.js';
|
|
2
2
|
export interface ApiClientConfig {
|
|
3
3
|
baseUrl: string;
|
|
4
4
|
token: string;
|
|
@@ -12,12 +12,53 @@ export interface ApiClientConfig {
|
|
|
12
12
|
* a freshly minted UUID v4.
|
|
13
13
|
*/
|
|
14
14
|
correlationId?: string;
|
|
15
|
+
/**
|
|
16
|
+
* ENG-1756 (plan §9 decision 15) — provenance-context EMIT config. Every
|
|
17
|
+
* WRITE call carries `X-Rockhopper-Surface` + `X-Rockhopper-Session-Id`
|
|
18
|
+
* (and `X-Driving-Human` once known) so the backend's decision-15
|
|
19
|
+
* admission never 403s a well-behaved agent client and the capture
|
|
20
|
+
* sidecar (`cell_change_provenance_context`) gets its surface/session.
|
|
21
|
+
* Defaults: surface `'mcp'`, a per-client-instance UUID session id, no
|
|
22
|
+
* driving human until {@link ApiClient.setDrivingHuman} is called (the
|
|
23
|
+
* backend then falls back to the PAT owner — the same human).
|
|
24
|
+
*/
|
|
25
|
+
provenanceContext?: {
|
|
26
|
+
/** `'mcp'` (local server, default) | `'gateway'` (remote gateway). */
|
|
27
|
+
surface?: string;
|
|
28
|
+
/** Session correlation id for the sidecar; default: per-instance UUID. */
|
|
29
|
+
sessionId?: string;
|
|
30
|
+
/** Platform id (msId/googleId) of the human driving this agent. */
|
|
31
|
+
drivingHumanPlatformId?: string;
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* A non-OK HTTP answer, carrying its status so callers can tell a DEFINITIVE
|
|
36
|
+
* rejection (404 the file is not there, 403 no access) from an ambiguous one
|
|
37
|
+
* (5xx, transport). The strict no-partial gate needs that distinction: failing
|
|
38
|
+
* closed on an ambiguous probe is right, but reporting "retry later" for a file
|
|
39
|
+
* that does not exist would be a fabricated capacity signal. Message text is
|
|
40
|
+
* unchanged from the previous plain `Error` — callers render it verbatim.
|
|
41
|
+
*/
|
|
42
|
+
export declare class RockhopperApiError extends Error {
|
|
43
|
+
readonly status: number;
|
|
44
|
+
constructor(status: number, message: string);
|
|
15
45
|
}
|
|
16
46
|
export declare class ApiClient {
|
|
17
47
|
private readonly baseUrl;
|
|
18
48
|
private readonly token;
|
|
19
49
|
private readonly correlationId?;
|
|
50
|
+
private readonly surface;
|
|
51
|
+
private readonly sessionId;
|
|
52
|
+
private drivingHumanPlatformId;
|
|
20
53
|
constructor(config: ApiClientConfig);
|
|
54
|
+
/**
|
|
55
|
+
* ENG-1756: declare (or clear) the human driving this agent. The CLI sets
|
|
56
|
+
* it from the `/users/me` preflight (`msId`/`googleId` — the PAT owner);
|
|
57
|
+
* subsequent writes then carry `X-Driving-Human`. While unset, the backend
|
|
58
|
+
* resolves the driving human as the PAT owner server-side, so writes keep
|
|
59
|
+
* working — this header is the explicit, forward-compatible form.
|
|
60
|
+
*/
|
|
61
|
+
setDrivingHuman(platformId: string | null): void;
|
|
21
62
|
/**
|
|
22
63
|
* KI-096: optional `responseSchema` validates the response shape with
|
|
23
64
|
* zod. When supplied, drift between backend's actual response and the
|
|
@@ -28,7 +69,13 @@ export declare class ApiClient {
|
|
|
28
69
|
*/
|
|
29
70
|
private request;
|
|
30
71
|
getMe(): Promise<UserSummary>;
|
|
31
|
-
|
|
72
|
+
/**
|
|
73
|
+
* ENG-2230 — `teamId` is either spelling: the version-7 uuid or the legacy
|
|
74
|
+
* numeric internal id. Both are interpolated into the path unchanged and
|
|
75
|
+
* both name the same row (backend #1717). Widened from `number`, so no
|
|
76
|
+
* existing caller changes.
|
|
77
|
+
*/
|
|
78
|
+
getTeam(teamId: RockhopperId): Promise<Team>;
|
|
32
79
|
listEnrolledFiles(params?: {
|
|
33
80
|
search?: string;
|
|
34
81
|
matchIn?: 'name' | 'comments' | 'versions' | 'all';
|
|
@@ -36,6 +83,13 @@ export declare class ApiClient {
|
|
|
36
83
|
getEnrolledFile(fileMsId: string): Promise<EnrolledFile>;
|
|
37
84
|
getFileVersions(fileMsId: string): Promise<FileVersion[]>;
|
|
38
85
|
getFileVersion(versionInternalId: number): Promise<FileVersion>;
|
|
86
|
+
/**
|
|
87
|
+
* Plan 02 ruling 5 — the completeness probe for every change-history
|
|
88
|
+
* surface. `foldPending: true` means a commit-diff fold is queued, retrying
|
|
89
|
+
* or running, i.e. the change-log window is mid-rewrite: incomplete.
|
|
90
|
+
* Consumed by `assertChangeHistoryComplete`, never rendered to the user.
|
|
91
|
+
*/
|
|
92
|
+
getFoldStatus(fileMsId: string): Promise<FoldStatus>;
|
|
39
93
|
/**
|
|
40
94
|
* KI-096: passes `?format=mcp` to opt into the backend's normalized
|
|
41
95
|
* projection `{versionId, value, changedBy, changedAt}` (added by
|
|
@@ -43,6 +97,14 @@ export declare class ApiClient {
|
|
|
43
97
|
* row shape the frontend cell-history popover consumes — we never
|
|
44
98
|
* call that path. Zod-parses the response so future drift between
|
|
45
99
|
* backend and mcp-server contracts fails loudly.
|
|
100
|
+
*
|
|
101
|
+
* ENG-1638 (P3-2) remainder: the backend now routes this read through the
|
|
102
|
+
* SAME ledger read-decision choke point as the webapp/add-in popovers
|
|
103
|
+
* (cross-surface parity). An eligible file serves the WIDENED entries
|
|
104
|
+
* (+ formula, provenance, actorKind, drivingHuman, formatted — including
|
|
105
|
+
* live events with versionId 'uncommitted'); a not-eligible file, a Google
|
|
106
|
+
* file, or an older backend serves the four-field legacy projection. The
|
|
107
|
+
* schema accepts both.
|
|
46
108
|
*/
|
|
47
109
|
getCellHistory(fileMsId: string, sheetName: string, cellAddress: string): Promise<CellHistoryEntry[]>;
|
|
48
110
|
getFileComments(fileMsId: string): Promise<FileChat[]>;
|
|
@@ -70,11 +132,18 @@ export declare class ApiClient {
|
|
|
70
132
|
getReviewsForLatestVersion(fileMsId: string): Promise<ReviewRequest[]>;
|
|
71
133
|
getReview(reviewId: number): Promise<ReviewRequest>;
|
|
72
134
|
getReviewActivities(reviewId: number): Promise<ReviewActivity[]>;
|
|
135
|
+
/**
|
|
136
|
+
* ENG-2230 — `reviewerIds` accepts either spelling of a user id (uuid or
|
|
137
|
+
* legacy numeric internal id), mixed freely. Values are serialised
|
|
138
|
+
* verbatim; the backend resolves both (`@AcceptsResourceId({ reviewerIds:
|
|
139
|
+
* 'user' })` on `POST|PUT /reviews/requests`). `versionId` is a FILE
|
|
140
|
+
* VERSION id and is NOT re-keyed — it stays numeric.
|
|
141
|
+
*/
|
|
73
142
|
createReviewRequest(body: {
|
|
74
143
|
versionId: number;
|
|
75
144
|
subject: string;
|
|
76
145
|
description?: string;
|
|
77
|
-
reviewerIds:
|
|
146
|
+
reviewerIds: RockhopperId[];
|
|
78
147
|
}): Promise<ReviewRequest>;
|
|
79
148
|
approveReview(reviewId: number, body: {
|
|
80
149
|
notes?: string;
|
package/dist/api-client.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api-client.d.ts","sourceRoot":"","sources":["../src/api-client.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EACV,gBAAgB,EAChB,YAAY,EACZ,QAAQ,EACR,WAAW,EACX,6BAA6B,EAC7B,cAAc,EACd,aAAa,EACb,IAAI,EACJ,kBAAkB,EAClB,WAAW,EACZ,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"api-client.d.ts","sourceRoot":"","sources":["../src/api-client.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EACV,gBAAgB,EAChB,YAAY,EACZ,QAAQ,EACR,WAAW,EACX,UAAU,EACV,6BAA6B,EAC7B,cAAc,EACd,aAAa,EACb,YAAY,EACZ,IAAI,EACJ,k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EAAE,MAAM,EAChB,IAAI,EAAE;QAAE,IAAI,CAAC,EAAE,MAAM,CAAA;KAAE,GACtB,OAAO,CAAC,YAAY,CAAC;CAUzB"}
|
package/dist/api-client.js
CHANGED
|
@@ -1,15 +1,67 @@
|
|
|
1
1
|
import { randomUUID } from 'node:crypto';
|
|
2
2
|
import { getCorrelationId } from './correlation.js';
|
|
3
3
|
import { log } from './logger.js';
|
|
4
|
-
import { CellHistoryEntryArraySchema, EnrolledFileSchema, FileChatSchema, } from './zod-schemas.js';
|
|
4
|
+
import { CellHistoryEntryArraySchema, EnrolledFileSchema, FileChatSchema, FoldStatusSchema, } from './zod-schemas.js';
|
|
5
|
+
import { ChangeHistoryNotReadyError, DEFAULT_RETRY_AFTER_SECONDS, } from './not-ready.js';
|
|
6
|
+
/**
|
|
7
|
+
* Plan 02 ruling 5 — the poll hint comes from the SERVER's `Retry-After`
|
|
8
|
+
* (the produce ETA), never from a local guess. A missing/garbage header falls
|
|
9
|
+
* back to the shared default rather than inventing a shorter interval: a hint
|
|
10
|
+
* that is too short turns one waiting client into the herd the parser lease
|
|
11
|
+
* exists to prevent (SP02 adversarial S6).
|
|
12
|
+
*/
|
|
13
|
+
function parseRetryAfterSeconds(response) {
|
|
14
|
+
const raw = response.headers?.get('Retry-After');
|
|
15
|
+
if (!raw)
|
|
16
|
+
return DEFAULT_RETRY_AFTER_SECONDS;
|
|
17
|
+
const seconds = Number.parseInt(raw, 10);
|
|
18
|
+
return Number.isFinite(seconds) && seconds > 0
|
|
19
|
+
? seconds
|
|
20
|
+
: DEFAULT_RETRY_AFTER_SECONDS;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* A non-OK HTTP answer, carrying its status so callers can tell a DEFINITIVE
|
|
24
|
+
* rejection (404 the file is not there, 403 no access) from an ambiguous one
|
|
25
|
+
* (5xx, transport). The strict no-partial gate needs that distinction: failing
|
|
26
|
+
* closed on an ambiguous probe is right, but reporting "retry later" for a file
|
|
27
|
+
* that does not exist would be a fabricated capacity signal. Message text is
|
|
28
|
+
* unchanged from the previous plain `Error` — callers render it verbatim.
|
|
29
|
+
*/
|
|
30
|
+
export class RockhopperApiError extends Error {
|
|
31
|
+
status;
|
|
32
|
+
constructor(status, message) {
|
|
33
|
+
super(message);
|
|
34
|
+
this.name = 'RockhopperApiError';
|
|
35
|
+
this.status = status;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
/** HTTP methods the decision-15 admission treats as agent writes. */
|
|
39
|
+
const WRITE_METHODS = new Set(['POST', 'PUT', 'PATCH', 'DELETE']);
|
|
5
40
|
export class ApiClient {
|
|
6
41
|
baseUrl;
|
|
7
42
|
token;
|
|
8
43
|
correlationId;
|
|
44
|
+
surface;
|
|
45
|
+
sessionId;
|
|
46
|
+
drivingHumanPlatformId;
|
|
9
47
|
constructor(config) {
|
|
10
48
|
this.baseUrl = config.baseUrl.replace(/\/+$/, '');
|
|
11
49
|
this.token = config.token;
|
|
12
50
|
this.correlationId = config.correlationId;
|
|
51
|
+
this.surface = config.provenanceContext?.surface ?? 'mcp';
|
|
52
|
+
this.sessionId = config.provenanceContext?.sessionId ?? randomUUID();
|
|
53
|
+
this.drivingHumanPlatformId =
|
|
54
|
+
config.provenanceContext?.drivingHumanPlatformId ?? null;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* ENG-1756: declare (or clear) the human driving this agent. The CLI sets
|
|
58
|
+
* it from the `/users/me` preflight (`msId`/`googleId` — the PAT owner);
|
|
59
|
+
* subsequent writes then carry `X-Driving-Human`. While unset, the backend
|
|
60
|
+
* resolves the driving human as the PAT owner server-side, so writes keep
|
|
61
|
+
* working — this header is the explicit, forward-compatible form.
|
|
62
|
+
*/
|
|
63
|
+
setDrivingHuman(platformId) {
|
|
64
|
+
this.drivingHumanPlatformId = platformId;
|
|
13
65
|
}
|
|
14
66
|
/**
|
|
15
67
|
* KI-096: optional `responseSchema` validates the response shape with
|
|
@@ -39,6 +91,20 @@ export class ApiClient {
|
|
|
39
91
|
// id can't be dropped. Precedence: per-call > config > ALS > mint.
|
|
40
92
|
// Non-sensitive UUID — never co-logged with the bearer token above.
|
|
41
93
|
'X-Correlation-Id': this.correlationId ?? getCorrelationId() ?? randomUUID(),
|
|
94
|
+
// ENG-1756 (decision 15): agent writes carry the provenance
|
|
95
|
+
// context so the backend's anonymous-agent-write admission never
|
|
96
|
+
// fires for this well-behaved client and the capture sidecar gets
|
|
97
|
+
// its surface/session. Reads carry none (no admission on reads).
|
|
98
|
+
// Placed before the spread so a per-call header still wins.
|
|
99
|
+
...(WRITE_METHODS.has(method)
|
|
100
|
+
? {
|
|
101
|
+
'X-Rockhopper-Surface': this.surface,
|
|
102
|
+
'X-Rockhopper-Session-Id': this.sessionId,
|
|
103
|
+
...(this.drivingHumanPlatformId
|
|
104
|
+
? { 'X-Driving-Human': this.drivingHumanPlatformId }
|
|
105
|
+
: {}),
|
|
106
|
+
}
|
|
107
|
+
: {}),
|
|
42
108
|
...init?.headers,
|
|
43
109
|
},
|
|
44
110
|
});
|
|
@@ -53,9 +119,18 @@ export class ApiClient {
|
|
|
53
119
|
if (!response.ok) {
|
|
54
120
|
// KI-225: classify auth rejections (401/403) so they're greppable
|
|
55
121
|
// separately from generic HTTP errors.
|
|
122
|
+
// Plan 02 ruling 5: 429/503 on a read lane is the backend's "outputs
|
|
123
|
+
// still producing" answer (SP02 maps the typed not-ready to 429 +
|
|
124
|
+
// Retry-After). It must NOT reach a formatter as a generic error string —
|
|
125
|
+
// an assistant reading `Rockhopper API 429: …` has no reliable way to
|
|
126
|
+
// tell a capacity signal from a real failure, and either way it is not
|
|
127
|
+
// data. Classified here, at the one place every call passes through.
|
|
128
|
+
const notReady = response.status === 429 || response.status === 503;
|
|
56
129
|
const classification = response.status === 401 || response.status === 403
|
|
57
130
|
? 'auth_failed'
|
|
58
|
-
:
|
|
131
|
+
: notReady
|
|
132
|
+
? 'not_ready'
|
|
133
|
+
: 'http_error';
|
|
59
134
|
log.warn({
|
|
60
135
|
event: 'api_request_failed',
|
|
61
136
|
method,
|
|
@@ -65,7 +140,14 @@ export class ApiClient {
|
|
|
65
140
|
classification,
|
|
66
141
|
}, 'api_request_failed');
|
|
67
142
|
const body = await response.text().catch(() => '');
|
|
68
|
-
|
|
143
|
+
if (notReady) {
|
|
144
|
+
throw new ChangeHistoryNotReadyError({
|
|
145
|
+
reason: 'still_producing',
|
|
146
|
+
retryAfterSeconds: parseRetryAfterSeconds(response),
|
|
147
|
+
detail: `${response.status} ${response.statusText} at ${pathname}`,
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
throw new RockhopperApiError(response.status, `Rockhopper API ${response.status}: ${response.statusText} — ${body}`);
|
|
69
151
|
}
|
|
70
152
|
log.info({ event: 'api_request', method, path: pathname, status: response.status, durationMs }, 'api_request');
|
|
71
153
|
const json = await response.json();
|
|
@@ -98,6 +180,12 @@ export class ApiClient {
|
|
|
98
180
|
return this.request('/users/me');
|
|
99
181
|
}
|
|
100
182
|
// --- Teams ---
|
|
183
|
+
/**
|
|
184
|
+
* ENG-2230 — `teamId` is either spelling: the version-7 uuid or the legacy
|
|
185
|
+
* numeric internal id. Both are interpolated into the path unchanged and
|
|
186
|
+
* both name the same row (backend #1717). Widened from `number`, so no
|
|
187
|
+
* existing caller changes.
|
|
188
|
+
*/
|
|
101
189
|
async getTeam(teamId) {
|
|
102
190
|
return this.request(`/teams/${teamId}`);
|
|
103
191
|
}
|
|
@@ -121,6 +209,15 @@ export class ApiClient {
|
|
|
121
209
|
async getFileVersion(versionInternalId) {
|
|
122
210
|
return this.request(`/file-versions/file/version/${versionInternalId}`);
|
|
123
211
|
}
|
|
212
|
+
/**
|
|
213
|
+
* Plan 02 ruling 5 — the completeness probe for every change-history
|
|
214
|
+
* surface. `foldPending: true` means a commit-diff fold is queued, retrying
|
|
215
|
+
* or running, i.e. the change-log window is mid-rewrite: incomplete.
|
|
216
|
+
* Consumed by `assertChangeHistoryComplete`, never rendered to the user.
|
|
217
|
+
*/
|
|
218
|
+
async getFoldStatus(fileMsId) {
|
|
219
|
+
return this.request(`/file-versions/file/${fileMsId}/fold-status`, undefined, FoldStatusSchema);
|
|
220
|
+
}
|
|
124
221
|
/**
|
|
125
222
|
* KI-096: passes `?format=mcp` to opt into the backend's normalized
|
|
126
223
|
* projection `{versionId, value, changedBy, changedAt}` (added by
|
|
@@ -128,6 +225,14 @@ export class ApiClient {
|
|
|
128
225
|
* row shape the frontend cell-history popover consumes — we never
|
|
129
226
|
* call that path. Zod-parses the response so future drift between
|
|
130
227
|
* backend and mcp-server contracts fails loudly.
|
|
228
|
+
*
|
|
229
|
+
* ENG-1638 (P3-2) remainder: the backend now routes this read through the
|
|
230
|
+
* SAME ledger read-decision choke point as the webapp/add-in popovers
|
|
231
|
+
* (cross-surface parity). An eligible file serves the WIDENED entries
|
|
232
|
+
* (+ formula, provenance, actorKind, drivingHuman, formatted — including
|
|
233
|
+
* live events with versionId 'uncommitted'); a not-eligible file, a Google
|
|
234
|
+
* file, or an older backend serves the four-field legacy projection. The
|
|
235
|
+
* schema accepts both.
|
|
131
236
|
*/
|
|
132
237
|
async getCellHistory(fileMsId, sheetName, cellAddress) {
|
|
133
238
|
const query = new URLSearchParams({
|
|
@@ -183,6 +288,13 @@ export class ApiClient {
|
|
|
183
288
|
async getReviewActivities(reviewId) {
|
|
184
289
|
return this.request(`/reviews/requests/${reviewId}/activities`);
|
|
185
290
|
}
|
|
291
|
+
/**
|
|
292
|
+
* ENG-2230 — `reviewerIds` accepts either spelling of a user id (uuid or
|
|
293
|
+
* legacy numeric internal id), mixed freely. Values are serialised
|
|
294
|
+
* verbatim; the backend resolves both (`@AcceptsResourceId({ reviewerIds:
|
|
295
|
+
* 'user' })` on `POST|PUT /reviews/requests`). `versionId` is a FILE
|
|
296
|
+
* VERSION id and is NOT re-keyed — it stays numeric.
|
|
297
|
+
*/
|
|
186
298
|
async createReviewRequest(body) {
|
|
187
299
|
return this.request('/reviews/requests', {
|
|
188
300
|
method: 'POST',
|
package/dist/api-client.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api-client.js","sourceRoot":"","sources":["../src/api-client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzC,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,EAAE,GAAG,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"api-client.js","sourceRoot":"","sources":["../src/api-client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzC,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,EAAE,GAAG,EAAE,MAAM,aAAa,CAAC;AAelC,OAAO,EACL,2BAA2B,EAC3B,kBAAkB,EAClB,cAAc,EACd,gBAAgB,GACjB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EACL,0BAA0B,EAC1B,2BAA2B,GAC5B,MAAM,gBAAgB,CAAC;AAExB;;;;;;GAMG;AACH,SAAS,sBAAsB,CAAC,QAE/B;IACC,MAAM,GAAG,GAAG,QAAQ,CAAC,OAAO,EAAE,GAAG,CAAC,aAAa,CAAC,CAAC;IACjD,IAAI,CAAC,GAAG;QAAE,OAAO,2BAA2B,CAAC;IAC7C,MAAM,OAAO,GAAG,MAAM,CAAC,QAAQ,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;IACzC,OAAO,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAI,OAAO,GAAG,CAAC;QAC5C,CAAC,CAAC,OAAO;QACT,CAAC,CAAC,2BAA2B,CAAC;AAClC,CAAC;AAmCD;;;;;;;GAOG;AACH,MAAM,OAAO,kBAAmB,SAAQ,KAAK;IAClC,MAAM,CAAS;IACxB,YAAY,MAAc,EAAE,OAAe;QACzC,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,oBAAo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|
token: resolved.accessToken,
|
|
65
65
|
});
|
|
66
66
|
try {
|
|
67
|
-
await apiClient.getMe();
|
|
67
|
+
const me = await apiClient.getMe();
|
|
68
|
+
// ENG-1756 (plan §9 decision 15): the PAT owner IS the human driving this
|
|
69
|
+
// local agent — reuse the preflight to declare them, so every write carries
|
|
70
|
+
// `X-Driving-Human` and the backend's anonymous-agent-write admission
|
|
71
|
+
// never fires for this client. Best-effort: while unset, the backend
|
|
72
|
+
// resolves the PAT owner server-side (same human).
|
|
73
|
+
apiClient.setDrivingHuman(me?.msId ?? me?.googleId ?? null);
|
|
68
74
|
}
|
|
69
75
|
catch (err) {
|
|
70
76
|
const msg = err instanceof Error ? err.message : String(err);
|
package/dist/cli.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AACjF,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EACL,mBAAmB,EACnB,WAAW,GAEZ,MAAM,wBAAwB,CAAC;AAChC,OAAO,EACL,eAAe,EACf,UAAU,EACV,GAAG,EACH,cAAc,GACf,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAE3C,MAAM,kBAAkB,GACtB,OAAO,CAAC,GAAG,CAAC,kBAAkB,IAAI,2BAA2B,CAAC;AAEhE,4EAA4E;AAC5E,0EAA0E;AAC1E,oEAAoE;AACpE,MAAM,UAAU,EAAE,CAAC;AAEnB,6EAA6E;AAC7E,4EAA4E;AAC5E,2EAA2E;AAC3E,qDAAqD;AACrD,OAAO,CAAC,EAAE,CAAC,mBAAmB,EAAE,CAAC,GAAG,EAAE,EAAE;IACtC,GAAG,CAAC,KAAK,CAAC,EAAE,KAAK,EAAE,oBAAoB,EAAE,GAAG,EAAE,EAAE,oBAAoB,CAAC,C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MAAM,KAAK,KAAK,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,eAAe;SACpE,EACD,aAAa,CACd,CAAC;QACF,IAAI,QAAQ,CAAC,MAAM,KAAK,KAAK,EAAE,CAAC;YAC9B,OAAO,CAAC,KAAK,CACX,kDAAkD;gBAChD,2FAA2F,CAC9F,CAAC;QACJ,CAAC;aAAM,CAAC;YACN,OAAO,CAAC,KAAK,CACX,iDAAiD,QAAQ,CAAC,MAAM,MAAM;gBACpE,qEAAqE,CACxE,CAAC;QACJ,CAAC;IACH,CAAC;SAAM,CAAC;QACN,OAAO,CAAC,KAAK,CACX,4CAA4C,kBAAkB,KAAK;YACjE,YAAY,GAAG,EAAE,CACpB,CAAC;IACJ,CAAC;IACD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC;AAED,MAAM,MAAM,GAAG,YAAY,CAAC,SAAS,CAAC,CAAC;AAEvC,+DAA+D;AAC/D,GAAG,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,kBAAkB,EAAE,OAAO,EAAE,cAAc,EAAE,EAAE,kBAAkB,CAAC,CAAC;AAErF,MAAM,SAAS,GAAG,IAAI,oBAAoB,EAAE,CAAC;AAC7C,MAAM,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC"}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Plan 02 ruling 5 (David, 2026-08-04) — STRICT no-partial, on the machine
|
|
3
|
+
* surfaces.
|
|
4
|
+
*
|
|
5
|
+
* The rule David landed is "nothing serves change history until it is
|
|
6
|
+
* complete", and he chose STRICT specifically because THIS server is a
|
|
7
|
+
* consumer: rows leave here for Claude Desktop / Cursor, which get no banner,
|
|
8
|
+
* no colour and no human in the loop, and will narrate whatever arrives as
|
|
9
|
+
* fact. An empty list is the dangerous answer — "there are no changes" is a
|
|
10
|
+
* factual claim, and it is the claim an assistant makes when handed zero rows.
|
|
11
|
+
*
|
|
12
|
+
* So a not-ready answer here is a REFUSAL, not a value: `isError: true`, a
|
|
13
|
+
* shouting marker, an explicit "this is not an empty result", and a JSON
|
|
14
|
+
* object an assistant can branch on. A resource or prompt THROWS for the same
|
|
15
|
+
* reason a tool cannot return rows — a protocol error cannot be summarised as
|
|
16
|
+
* data.
|
|
17
|
+
*
|
|
18
|
+
* Vocabulary is deliberately the backend's, not a second one: the reasons
|
|
19
|
+
* mirror the SP02 `ParsedOutputNotReadyReason` family
|
|
20
|
+
* (`backend/src/common/parsed-output/parsed-output-not-ready.error.ts`), and
|
|
21
|
+
* `isNotReady` matches both the typed error and a wrapper carrying it as
|
|
22
|
+
* `cause`, exactly like the backend's `isParsedOutputNotReady`.
|
|
23
|
+
*/
|
|
24
|
+
/** Why a change-history answer is being refused. */
|
|
25
|
+
export type NotReadyReason =
|
|
26
|
+
/** A commit-diff fold is still rewriting this file's change-log window. */
|
|
27
|
+
'change_history_incomplete'
|
|
28
|
+
/** The backend answered 429/503: parsed outputs are still being produced. */
|
|
29
|
+
| 'still_producing'
|
|
30
|
+
/**
|
|
31
|
+
* The completeness probe itself could not answer. Fail CLOSED: under STRICT
|
|
32
|
+
* an unknown completeness state is not permission to serve rows. This is the
|
|
33
|
+
* one reason that is NOT a statement about the file.
|
|
34
|
+
*/
|
|
35
|
+
| 'completeness_unknown';
|
|
36
|
+
/** Grep marker; also the first token of every refusal an assistant sees. */
|
|
37
|
+
export declare const NOT_READY_MARKER = "CHANGE_HISTORY_NOT_READY";
|
|
38
|
+
/** Poll hint when the backend gave none — mirrors the backend's own default. */
|
|
39
|
+
export declare const DEFAULT_RETRY_AFTER_SECONDS = 15;
|
|
40
|
+
export declare class ChangeHistoryNotReadyError extends Error {
|
|
41
|
+
/** Structural marker, so a wrapper can be recognised without importing. */
|
|
42
|
+
readonly notReady: true;
|
|
43
|
+
readonly reason: NotReadyReason;
|
|
44
|
+
readonly retryAfterSeconds: number;
|
|
45
|
+
readonly fileMsId: string | null;
|
|
46
|
+
constructor(ctx: {
|
|
47
|
+
reason: NotReadyReason;
|
|
48
|
+
retryAfterSeconds?: number | null;
|
|
49
|
+
fileMsId?: string | null;
|
|
50
|
+
detail?: string;
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
/** Matches the typed error AND any error carrying one as `cause`. */
|
|
54
|
+
export declare function isNotReady(err: unknown): err is ChangeHistoryNotReadyError;
|
|
55
|
+
export interface NotReadyToolResult {
|
|
56
|
+
/** The SDK's `CallToolResult` carries an index signature; mirror it so this
|
|
57
|
+
* shape is assignable to a tool handler's return type. */
|
|
58
|
+
[key: string]: unknown;
|
|
59
|
+
content: Array<{
|
|
60
|
+
type: 'text';
|
|
61
|
+
text: string;
|
|
62
|
+
}>;
|
|
63
|
+
isError: true;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* The tool answer for a refusal. Three defences, because one is not enough
|
|
67
|
+
* against a model that wants to be helpful: `isError`, prose that names the
|
|
68
|
+
* wrong inference explicitly, and a JSON object to branch on.
|
|
69
|
+
*/
|
|
70
|
+
export declare function notReadyToolResult(err: unknown): NotReadyToolResult;
|
|
71
|
+
/** The completeness probe this module needs from the API client. */
|
|
72
|
+
export interface CompletenessProbe {
|
|
73
|
+
getFoldStatus(fileMsId: string): Promise<{
|
|
74
|
+
foldPending: boolean;
|
|
75
|
+
foldTargetVersionId: number | null;
|
|
76
|
+
}>;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Throws {@link ChangeHistoryNotReadyError} unless the file's change history is
|
|
80
|
+
* complete.
|
|
81
|
+
*
|
|
82
|
+
* `foldPending` is the backend's own authoritative queue read
|
|
83
|
+
* (`GET /file-versions/file/:fileMsId/fold-status`, KI-1399) — while it is
|
|
84
|
+
* true a commit-diff fold is queued, retrying or running, and the change-log
|
|
85
|
+
* window is mid-rewrite. That is precisely the incomplete state, and after
|
|
86
|
+
* plan 02's write-path decoupling (David Q3, 2026-08-03: save the version row
|
|
87
|
+
* first, defer the fold) it is the NORMAL state immediately after any write.
|
|
88
|
+
*
|
|
89
|
+
* A probe that cannot answer refuses. The backend's own probe fails OPEN to
|
|
90
|
+
* not-pending on purpose — a UI lock that can hang is worse than a stale row —
|
|
91
|
+
* but that trade does not transfer here: for a machine consumer a wrong
|
|
92
|
+
* "complete" is a fabricated fact, so the client-side default is the opposite.
|
|
93
|
+
*/
|
|
94
|
+
export declare function assertChangeHistoryComplete(api: CompletenessProbe, fileMsId: string): Promise<void>;
|
|
95
|
+
//# sourceMappingURL=not-ready.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"not-ready.d.ts","sourceRoot":"","sources":["../src/not-ready.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,oDAAoD;AACpD,MAAM,MAAM,cAAc;AACxB,2EAA2E;AACzE,2BAA2B;AAC7B,6EAA6E;GAC3E,iBAAiB;AACnB;;;;GAIG;GACD,sBAAsB,CAAC;AAE3B,4EAA4E;AAC5E,eAAO,MAAM,gBAAgB,6BAA6B,CAAC;AAE3D,gFAAgF;AAChF,eAAO,MAAM,2BAA2B,KAAK,CAAC;AAE9C,qBAAa,0BAA2B,SAAQ,KAAK;IACnD,2EAA2E;IAC3E,QAAQ,CAAC,QAAQ,EAAG,IAAI,CAAU;IAClC,QAAQ,CAAC,MAAM,EAAE,cAAc,CAAC;IAChC,QAAQ,CAAC,iBAAiB,EAAE,MAAM,CAAC;IACnC,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;gBAErB,GAAG,EAAE;QACf,MAAM,EAAE,cAAc,CAAC;QACvB,iBAAiB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;QAClC,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;QACzB,MAAM,CAAC,EAAE,MAAM,CAAC;KACjB;CAeF;AAED,qEAAqE;AACrE,wBAAgB,UAAU,CAAC,GAAG,EAAE,OAAO,GAAG,GAAG,IAAI,0BAA0B,CAI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