@mattstack/rt-client 0.1.1 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -17,8 +17,11 @@ const repos = await rtCommand(['repos', 'list']);
17
17
  const mrs = await readProjectMRs('group/repo');
18
18
  ```
19
19
 
20
- Requires a running rt daemon. Install rt with `brew install m4ttheweric/tap/rt`,
21
- then `rt verify`.
20
+ Requires a running rt daemon. Install rt from the latest GitHub Release
21
+ (`./rt --post-install`), then `rt verify`.
22
+
23
+ Bun-only: the settings exec path (`src/settings/exec.ts`) shells out via
24
+ `Bun.spawn`, so this package does not run under Node.
22
25
 
23
26
  `@mattstack/glance` is a peer dependency: rt-client returns glance's forge types
24
27
  so merge request shapes stay identical across rt, gitq, and mr-board.
package/dist/client.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import type { RtResponse, RtClientOptions } from "./transport.ts";
2
- import type { DemandDecl, ProjectMRsData, DiscussionsData, MrByBranchData } from "./commands.ts";
2
+ import type { DemandDecl, ProjectMRsData, DiscussionsData, MrByBranchData, ForgeSlug, ForgeTokenData, RunSummary, RunDetail } from "./commands.ts";
3
3
  /**
4
4
  * One repo's project open-MR store. A cold repo forces a full paginated sync
5
5
  * on the daemon side when maxAgeMs demands it, which can run tens of seconds
@@ -13,3 +13,15 @@ import type { DemandDecl, ProjectMRsData, DiscussionsData, MrByBranchData } from
13
13
  export declare function readProjectMRs(repoName: string, maxAgeMs?: number, opts?: RtClientOptions, demand?: DemandDecl): Promise<RtResponse<ProjectMRsData>>;
14
14
  export declare function readDiscussions(repoName: string, iid: number, opts?: RtClientOptions): Promise<RtResponse<DiscussionsData>>;
15
15
  export declare function readMrsByBranch(repoName: string, branches: string[], opts?: RtClientOptions): Promise<RtResponse<MrByBranchData>>;
16
+ /**
17
+ * The forge token for one tracked repo (MAT-33). Grant-gated on the daemon
18
+ * side: an untracked repo comes back `ok: false` with the `rt daemon track`
19
+ * command to run, which is the fail-closed shape callers should surface
20
+ * verbatim. Callers keep env-var precedence on their own side; this is the
21
+ * fallback that replaces reading ~/.mattstack/rt/secrets.json directly.
22
+ */
23
+ export declare function resolveForgeToken(repoName: string, forge: ForgeSlug, opts?: RtClientOptions): Promise<RtResponse<ForgeTokenData>>;
24
+ export declare function listRuns(repo?: string, opts?: RtClientOptions): Promise<RtResponse<{
25
+ runs: RunSummary[];
26
+ }>>;
27
+ export declare function getRun(runId: string, repo?: string, opts?: RtClientOptions): Promise<RtResponse<RunDetail>>;
@@ -40,6 +40,59 @@ export interface MrByBranchData {
40
40
  byBranch: Record<string, MrByBranchEntry | null>;
41
41
  syncedAt: number;
42
42
  }
43
+ /** Forges the daemon can hold a token for. */
44
+ export type ForgeSlug = "gitlab" | "github";
45
+ export interface ForgeTokenData {
46
+ token: string;
47
+ }
48
+ /**
49
+ * Duplicated shape on purpose (RT-44): rt-client cannot import daemon
50
+ * internals, so this mirrors lib/daemon/events-bus.ts's BusEvent.
51
+ */
52
+ export interface EventsBusEvent {
53
+ id: number;
54
+ topic: string;
55
+ payload: unknown;
56
+ emittedAt: number;
57
+ }
58
+ export interface RunSummary {
59
+ id: string;
60
+ repo: string;
61
+ work_type: string;
62
+ pipeline: string;
63
+ status: string;
64
+ current_stage: string | null;
65
+ spawned_by: string | null;
66
+ started_at: number;
67
+ ended_at: number | null;
68
+ }
69
+ export interface RunStageRow {
70
+ name: string;
71
+ status: string;
72
+ attempt: number;
73
+ started_at: number | null;
74
+ ended_at: number | null;
75
+ }
76
+ export interface RunFieldRow {
77
+ key: string;
78
+ value: string;
79
+ produced_by: string;
80
+ at: number;
81
+ }
82
+ export interface RunDecisionRow {
83
+ contract: string;
84
+ scope: string;
85
+ selection: string;
86
+ decided_by: string;
87
+ decided_at: number;
88
+ }
89
+ export interface RunDetail {
90
+ run: RunSummary;
91
+ stages: RunStageRow[];
92
+ fields: RunFieldRow[];
93
+ decisions: RunDecisionRow[];
94
+ schemaAhead: boolean;
95
+ }
43
96
  export interface Commands {
44
97
  "project-mrs:read": {
45
98
  payload: {
@@ -63,6 +116,109 @@ export interface Commands {
63
116
  };
64
117
  data: MrByBranchData;
65
118
  };
119
+ /**
120
+ * The forge token for one tracked repo (MAT-33). Repo-scoped on purpose:
121
+ * rt gates access per repo through repo-tracking.json, and this verb is
122
+ * what lets consumers stop reading ~/.mattstack/rt/secrets.json directly, which
123
+ * walked around that grant model entirely. An untracked repo is refused;
124
+ * the caller's env vars keep precedence on the caller's side.
125
+ */
126
+ "secrets:forge-token": {
127
+ payload: {
128
+ repoName: string;
129
+ forge: ForgeSlug;
130
+ };
131
+ data: ForgeTokenData;
132
+ };
133
+ /**
134
+ * A per-`scope` whitelisted subset of secrets, each scope reading its own
135
+ * encrypted domain(s): "extension" (default, so the VS Code extension
136
+ * needs no change) is linearApiKey/gitlabToken from the `rt` domain;
137
+ * "deck" is cfApiToken/cfZoneId from the `deck` domain; "board" is
138
+ * cross-domain — slackToken/slackClientSecret/slackSigningSecret from the
139
+ * `board` domain plus gitlabToken/switchboardToken/switchboardAdminToken
140
+ * from the `rt` domain. `data` is a union of the per-scope shapes, not a
141
+ * merged bag of every key — that makes a caller narrowing on the wrong
142
+ * scope's fields a compile error instead of a silent `undefined`. Every
143
+ * key optional (present only when set). Not a general secrets export —
144
+ * extend a whitelist here, in lockstep with
145
+ * lib/daemon/handlers/secrets.ts and (for "extension")
146
+ * extensions/vscode/rt-context/src/secrets.ts, if a consumer needs another
147
+ * key.
148
+ *
149
+ * `token` is required and checked in the HANDLER (not a transport-layer
150
+ * gate alone), since this verb is reachable over the unauthenticated unix
151
+ * socket too — see lib/daemon/handlers/secrets.ts's doc comment. HTTP
152
+ * callers get it forwarded automatically from their X-RT-Token header;
153
+ * socket callers must read ~/.mattstack/rt/api-token themselves. The gate
154
+ * applies identically to every scope.
155
+ */
156
+ "secrets:read": {
157
+ payload: {
158
+ token?: string;
159
+ scope?: "extension" | "deck" | "board";
160
+ };
161
+ data: {
162
+ linearApiKey?: string;
163
+ gitlabToken?: string;
164
+ } | {
165
+ cfApiToken?: string;
166
+ cfZoneId?: string;
167
+ } | {
168
+ slackToken?: string;
169
+ slackClientSecret?: string;
170
+ slackSigningSecret?: string;
171
+ gitlabToken?: string;
172
+ switchboardToken?: string;
173
+ switchboardAdminToken?: string;
174
+ };
175
+ };
176
+ "events:emit": {
177
+ payload: {
178
+ topic: string;
179
+ payload?: unknown;
180
+ };
181
+ data: {
182
+ id: number;
183
+ };
184
+ };
185
+ "events:wait": {
186
+ payload: {
187
+ pattern: string;
188
+ after?: number;
189
+ waitMs?: number;
190
+ };
191
+ data: {
192
+ events: EventsBusEvent[];
193
+ cursor: number;
194
+ };
195
+ };
196
+ "events:list": {
197
+ payload: {
198
+ pattern: string;
199
+ after?: number;
200
+ limit?: number;
201
+ };
202
+ data: {
203
+ events: EventsBusEvent[];
204
+ cursor: number;
205
+ };
206
+ };
207
+ "runs:list": {
208
+ payload: {
209
+ repo?: string;
210
+ };
211
+ data: {
212
+ runs: RunSummary[];
213
+ };
214
+ };
215
+ "runs:get": {
216
+ payload: {
217
+ runId: string;
218
+ repo?: string;
219
+ };
220
+ data: RunDetail;
221
+ };
66
222
  }
67
223
  export type CommandName = keyof Commands;
68
224
  export declare const COMMAND_NAMES: readonly CommandName[];
package/dist/index.d.ts CHANGED
@@ -1,8 +1,18 @@
1
1
  export { rtCommand, DEFAULT_SOCK } from "./transport.ts";
2
2
  export type { RtResponse, RtClientOptions } from "./transport.ts";
3
- export { readProjectMRs, readDiscussions, readMrsByBranch } from "./client.ts";
3
+ export { readProjectMRs, readDiscussions, readMrsByBranch, resolveForgeToken } from "./client.ts";
4
4
  export { COMMAND_NAMES } from "./commands.ts";
5
- export type { Discussion, DemandDecl, ProjectMRsScope, ProjectMRsData, DiscussionsData, MrByBranchEntry, MrByBranchData, Commands, CommandName, } from "./commands.ts";
5
+ export type { Discussion, DemandDecl, ProjectMRsScope, ProjectMRsData, DiscussionsData, MrByBranchEntry, MrByBranchData, Commands, CommandName, ForgeSlug, ForgeTokenData, } from "./commands.ts";
6
6
  export { subscribe, DEFAULT_WS_URL } from "./relay.ts";
7
7
  export type { RelayEventType } from "./relay.ts";
8
8
  export { repoNameForPath } from "./repos.ts";
9
+ export { getSetting, listSettings, explainSetting, expandVariables, SCOPE_ORDER } from "./settings/resolve.ts";
10
+ export type { Scope, Provenance, ResolveOpts, Resolved, InvalidScope, ListedSetting, ExplainRow, ExpandCtx, } from "./settings/resolve.ts";
11
+ export { setSetting } from "./settings/write.ts";
12
+ export type { SetSettingOpts } from "./settings/write.ts";
13
+ export { getDef, allDefs, validateValue, isMigrated } from "./settings/registry-machinery.ts";
14
+ export type { SettingDef, SettingScope } from "./settings/registry-machinery.ts";
15
+ export { REGISTRY } from "./settings/registry-defs.ts";
16
+ export { readStore, listTeams } from "./settings/stores.ts";
17
+ export type { StoreFile } from "./settings/stores.ts";
18
+ export { normalizeRemote, identityFromRemote, deriveRepoIdentity, clearIdentityMemo } from "./settings/identity.ts";