gitd-client 0.0.0-stage → 0.8.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.
@@ -0,0 +1,232 @@
1
+ import type { Progress } from "./gen/gitd/v1/gitd_pb.js";
2
+ import type { OpenedPullRequest, Provenance } from "./publishing-types.js";
3
+ /** How a workspace was made: a layer on a shared template, a block clone, or every file written. */
4
+ export type StrategyName = "overlay" | "reflink" | "copy";
5
+ /** Where a workspace ended up. */
6
+ export interface Workspace {
7
+ path: string;
8
+ commit: string;
9
+ /** The branch it follows; empty when detached at a commit. */
10
+ branch: string;
11
+ strategy: StrategyName;
12
+ /** An overlay workspace's template (lower), its own layer (upper, work), and its warm layer. */
13
+ layers?: Layers;
14
+ /** Submodules that could not be checked out, and why. */
15
+ pendingSubmodules: PendingSubmodule[];
16
+ /** Files the repository keeps in git LFS: pointers here, as gitd does not download them. */
17
+ lfsPatterns: string[];
18
+ }
19
+ export interface Layers {
20
+ lower: string;
21
+ upper: string;
22
+ work: string;
23
+ /** The warm layer between the template and its own, when it stands on one; else empty. */
24
+ warm: string;
25
+ }
26
+ /** A layer sealed from a workspace — what installing its dependencies wrote — for later ones to stand on. */
27
+ export interface WarmLayer {
28
+ url: string;
29
+ name: string;
30
+ /** Workspaces stand on it at this commit only. */
31
+ commit: string;
32
+ sealedAt: Date;
33
+ sealedFrom: string;
34
+ /** Files it changes that git does not ignore, e.g. a lock file rewritten. */
35
+ changedFiles: number;
36
+ /** Workspaces standing on it now. */
37
+ users: number;
38
+ }
39
+ export interface PendingSubmodule {
40
+ path: string;
41
+ url: string;
42
+ reason: string;
43
+ }
44
+ /** What a workspace is on disk. */
45
+ export interface Description {
46
+ url: string;
47
+ commit: string;
48
+ branch: string;
49
+ /** Whether there are uncommitted changes. */
50
+ modified: boolean;
51
+ strategy: StrategyName;
52
+ submodules: Submodule[];
53
+ /** Files kept in git LFS, which are pointers here. */
54
+ lfsPatterns: string[];
55
+ }
56
+ export interface Submodule {
57
+ path: string;
58
+ url: string;
59
+ commit: string;
60
+ checkedOut: boolean;
61
+ }
62
+ /** Why gitd refused something: its reason (POLICY_REFUSED, AUTH_REQUIRED, …) and what was said. */
63
+ export interface Refusal {
64
+ reason: string;
65
+ said: string;
66
+ }
67
+ /**
68
+ * What a publish pushed: the workspace's repository first, then each submodule; the pull
69
+ * request it opened, or why it could not, the branch being published either way.
70
+ */
71
+ export interface Published {
72
+ branch: string;
73
+ repositories: PublishedRepository[];
74
+ pullRequest?: OpenedPullRequest;
75
+ pullRequestRefused?: Refusal;
76
+ }
77
+ export interface PublishedRepository {
78
+ url: string;
79
+ /** The submodule's path; empty for the workspace's own repository. */
80
+ path: string;
81
+ commit: string;
82
+ /** The subjects of the new commits, newest first. */
83
+ subjects: string[];
84
+ }
85
+ /** How a file changed. */
86
+ export type ChangeKind = "added" | "modified" | "deleted";
87
+ /** A file changed, relative to the workspace, with its lines; a binary one counts none. */
88
+ export interface ChangedFile {
89
+ path: string;
90
+ kind: ChangeKind;
91
+ addedLines: number;
92
+ removedLines: number;
93
+ binary: boolean;
94
+ }
95
+ /** What was changed in a workspace since gitd put it on `base`, committed or not. */
96
+ export interface Changes {
97
+ base: string;
98
+ /** Read from the agent's own layer, with no git run in the workspace. */
99
+ fromLayer: boolean;
100
+ files: ChangedFile[];
101
+ }
102
+ /** The unified diff of a workspace's changes. */
103
+ export interface Diff {
104
+ base: string;
105
+ diff: string;
106
+ /** Cut short at maxBytes. */
107
+ truncated: boolean;
108
+ }
109
+ export interface DiffOptions {
110
+ /** Only these files, relative to the workspace. */
111
+ files?: string[];
112
+ /** At most this many bytes: 512 KiB by default, never more than 8 MiB. */
113
+ maxBytes?: number;
114
+ includeIgnored?: boolean;
115
+ }
116
+ /** One work: a workspace by its path, or a branch gitd published or its pool holds. */
117
+ export type Side = {
118
+ workspace: string;
119
+ } | {
120
+ branch: string;
121
+ };
122
+ export interface CompareOptions {
123
+ /** The repository, when both sides are branches. */
124
+ url?: string;
125
+ withDiff?: boolean;
126
+ maxBytes?: number;
127
+ includeIgnored?: boolean;
128
+ }
129
+ /** How two works differ, from the first to the second. */
130
+ export interface Comparison {
131
+ files: ChangedFile[];
132
+ diff: string;
133
+ truncated: boolean;
134
+ }
135
+ /** Two works that do not merge cleanly, and the files they conflict on. */
136
+ export interface Conflict {
137
+ first: Side;
138
+ second: Side;
139
+ paths: string[];
140
+ }
141
+ /** What happened to a workspace. */
142
+ export interface WorkspaceEvent {
143
+ kind: "made" | "changed" | "published" | "refused" | "removed";
144
+ path: string;
145
+ time: Date;
146
+ branch: string;
147
+ detail: string;
148
+ }
149
+ /** Which gitd answers, and how it makes workspaces on its machine. */
150
+ export interface Info {
151
+ version: string;
152
+ gitVersion: string;
153
+ pools: number;
154
+ poolsBytes: number;
155
+ templates: number;
156
+ templatesBytes: number;
157
+ strategy: StrategyName;
158
+ strategyReason: string;
159
+ }
160
+ /** Whether a repository can be read, and its branches. */
161
+ export interface Probe {
162
+ access: "public" | "reachable" | "denied";
163
+ defaultBranch: string;
164
+ /** Each branch and the commit it points at. */
165
+ branches: Record<string, string>;
166
+ /** Why it cannot be read, when denied. */
167
+ denied?: string;
168
+ }
169
+ /** A change to the credentials or publishing settings, as the audit log keeps it. */
170
+ export interface ConfigurationChange {
171
+ /** connection_added, connection_removed, settings_set or settings_removed. */
172
+ action: string;
173
+ /** The credential's id, or the settings' prefix. */
174
+ subject: string;
175
+ urlPrefix: string;
176
+ }
177
+ /** One publish, done or refused, or one change to credentials or settings, as the audit log keeps it. */
178
+ export interface AuditEntry {
179
+ time: Date;
180
+ /** The workspace's path, as the caller gave it. */
181
+ workspace: string;
182
+ /** The workspace's repository; empty when the workspace could not be opened. */
183
+ url: string;
184
+ branch: string;
185
+ /** What was pushed, the workspace's repository first; empty when refused. */
186
+ repositories: PublishedRepository[];
187
+ /** Why it was refused, when it was. */
188
+ refused?: Refusal;
189
+ /** Who asked for the work, as the publish said. */
190
+ requestedBy: string;
191
+ pullRequest?: OpenedPullRequest;
192
+ pullRequestRefused?: Refusal;
193
+ change?: ConfigurationChange;
194
+ provenance?: Provenance;
195
+ }
196
+ export interface AuditOptions {
197
+ /** Only the publishes from this time on. */
198
+ since?: Date;
199
+ /** Only the publishes of this repository, by its URL. */
200
+ url?: string;
201
+ /** At most this many: 100 by default, never more than 1000. */
202
+ limit?: number;
203
+ }
204
+ /** Options of a call that streams progress. */
205
+ export interface Progressing {
206
+ /** Told what git is doing while the call runs. */
207
+ onProgress?: (progress: Progress) => void;
208
+ signal?: AbortSignal;
209
+ }
210
+ export interface PrepareOptions extends Progressing {
211
+ url: string;
212
+ path: string;
213
+ branch?: string;
214
+ commit?: string;
215
+ submodules?: boolean;
216
+ fullHistory?: boolean;
217
+ /** A preference; gitd falls back to copy when it cannot run here. */
218
+ strategy?: StrategyName;
219
+ /**
220
+ * A warm layer to stand on, its dependencies installed already: the workspace is then made
221
+ * by overlay, at the commit the layer was sealed at, or not at all.
222
+ */
223
+ warm?: string;
224
+ }
225
+ export interface UpdateOptions extends Progressing {
226
+ /** The branch to follow; default: the one it follows. */
227
+ branch?: string;
228
+ submodules?: boolean;
229
+ }
230
+ export interface CheckoutOptions extends Progressing {
231
+ submodules?: boolean;
232
+ }
package/dist/types.js ADDED
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,4 @@
1
+ import type { WarmLayer as WarmLayerMessage } from "./gen/gitd/v1/gitd_pb.js";
2
+ import type { WarmLayer } from "./types.js";
3
+ /** A warm layer as gitd answers it, read as this client's. */
4
+ export declare function toWarmLayer(warm: WarmLayerMessage | undefined): WarmLayer;
@@ -0,0 +1,12 @@
1
+ /** A warm layer as gitd answers it, read as this client's. */
2
+ export function toWarmLayer(warm) {
3
+ return {
4
+ url: warm?.url ?? "",
5
+ name: warm?.name ?? "",
6
+ commit: warm?.commit ?? "",
7
+ sealedAt: new Date(Number(warm?.sealedAt ?? 0n) * 1000),
8
+ sealedFrom: warm?.sealedFrom ?? "",
9
+ changedFiles: warm?.changedFiles ?? 0,
10
+ users: warm?.users ?? 0,
11
+ };
12
+ }
package/package.json CHANGED
@@ -1,6 +1,52 @@
1
1
  {
2
2
  "name": "gitd-client",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.8.0",
4
+ "description": "Client for gitd: instant, secretless git checkouts for agent sandboxes",
5
+ "license": "Apache-2.0",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "git+https://github.com/dooservice/gitd.git",
9
+ "directory": "sdk/typescript"
10
+ },
11
+ "homepage": "https://github.com/dooservice/gitd",
12
+ "keywords": [
13
+ "git",
14
+ "ai-agents",
15
+ "sandbox",
16
+ "workspace",
17
+ "connectrpc"
18
+ ],
19
+ "type": "module",
20
+ "main": "./dist/index.js",
21
+ "types": "./dist/index.d.ts",
22
+ "exports": {
23
+ ".": {
24
+ "types": "./dist/index.d.ts",
25
+ "default": "./dist/index.js"
26
+ }
27
+ },
28
+ "files": [
29
+ "dist"
30
+ ],
31
+ "engines": {
32
+ "node": ">=22"
33
+ },
34
+ "scripts": {
35
+ "generate": "buf generate --template buf.gen.yaml ../../proto",
36
+ "build": "tsc -p tsconfig.json",
37
+ "prepublishOnly": "npm run build",
38
+ "example": "tsx examples/agent.ts"
39
+ },
40
+ "dependencies": {
41
+ "@bufbuild/protobuf": "^2.16.0",
42
+ "@connectrpc/connect": "^2.2.0",
43
+ "@connectrpc/connect-node": "^2.2.0"
44
+ },
45
+ "devDependencies": {
46
+ "@bufbuild/buf": "^1.74.0",
47
+ "@bufbuild/protoc-gen-es": "^2.16.0",
48
+ "@types/node": "^26.6.5",
49
+ "tsx": "^4.23.15",
50
+ "typescript": "^7.0.2"
51
+ }
52
+ }