startup-builder 0.1.0 → 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/LICENSE +21 -0
- package/README.md +83 -142
- package/dist/chunk-ZR74VEI2.js +2322 -0
- package/dist/cli.js +335 -197
- package/dist/index.d.ts +677 -121
- package/dist/index.js +77 -19
- package/package.json +32 -37
- package/dist/chunk-DTWFVPYU.js +0 -190
package/dist/index.d.ts
CHANGED
|
@@ -1,122 +1,678 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
1
|
+
import { Server } from '@modelcontextprotocol/sdk/server/index.js';
|
|
2
|
+
|
|
3
|
+
interface Res<T = any> {
|
|
4
|
+
status: number;
|
|
5
|
+
ok: boolean;
|
|
6
|
+
url: string;
|
|
7
|
+
json: T;
|
|
8
|
+
text: string;
|
|
9
|
+
headers: Record<string, string>;
|
|
10
|
+
}
|
|
11
|
+
interface ApiOpts {
|
|
12
|
+
base: string;
|
|
13
|
+
token?: string;
|
|
14
|
+
bind?: string;
|
|
15
|
+
fetch?: typeof fetch;
|
|
16
|
+
userAgent?: string;
|
|
17
|
+
}
|
|
18
|
+
declare class Api {
|
|
19
|
+
readonly base: string;
|
|
20
|
+
readonly token?: string;
|
|
21
|
+
readonly origin: string;
|
|
22
|
+
readonly reads: string[];
|
|
23
|
+
private f;
|
|
24
|
+
private ua;
|
|
25
|
+
constructor(o: ApiOpts);
|
|
26
|
+
url(pathOrUrl: string): string;
|
|
27
|
+
sameOrigin(url: string): boolean;
|
|
28
|
+
private headers;
|
|
29
|
+
get<T = any>(pathOrUrl: string, accept?: string): Promise<Res<T>>;
|
|
30
|
+
post<T = any>(pathOrUrl: string, body: unknown, o?: {
|
|
31
|
+
idempotencyKey?: string;
|
|
32
|
+
prefer?: string;
|
|
33
|
+
}): Promise<Res<T> & {
|
|
34
|
+
idempotencyKey: string;
|
|
35
|
+
}>;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
interface Stored {
|
|
39
|
+
issuer: string;
|
|
40
|
+
client_id: string;
|
|
41
|
+
access_token: string;
|
|
42
|
+
refresh_token?: string;
|
|
43
|
+
expires_at?: number;
|
|
44
|
+
api: string;
|
|
45
|
+
}
|
|
46
|
+
interface AuthDeps {
|
|
47
|
+
api: string;
|
|
48
|
+
file: string;
|
|
49
|
+
issuer?: string;
|
|
50
|
+
fetch?: typeof fetch;
|
|
51
|
+
openBrowser?: (url: string) => boolean;
|
|
52
|
+
log?: (line: string) => void;
|
|
53
|
+
now?: () => number;
|
|
54
|
+
ports?: number[];
|
|
55
|
+
timeoutMs?: number;
|
|
56
|
+
clientId?: string;
|
|
57
|
+
}
|
|
58
|
+
type J$5 = Record<string, any>;
|
|
59
|
+
declare function pkce(verifier?: string): {
|
|
60
|
+
verifier: string;
|
|
61
|
+
challenge: string;
|
|
62
|
+
};
|
|
63
|
+
declare function unwrapState(s: string | null): string | null;
|
|
64
|
+
declare class Auth {
|
|
65
|
+
readonly api: string;
|
|
66
|
+
readonly file: string;
|
|
67
|
+
readonly issuer: string;
|
|
68
|
+
private f;
|
|
69
|
+
private open;
|
|
70
|
+
private log;
|
|
71
|
+
private now;
|
|
72
|
+
private ports;
|
|
73
|
+
private timeoutMs;
|
|
74
|
+
private fixedClient?;
|
|
75
|
+
constructor(d: AuthDeps);
|
|
76
|
+
stored(): Promise<Stored | undefined>;
|
|
77
|
+
private save;
|
|
78
|
+
clientId(): Promise<string>;
|
|
79
|
+
private token;
|
|
80
|
+
loopback(client: string): Promise<J$5 | undefined>;
|
|
81
|
+
device(client: string): Promise<J$5>;
|
|
82
|
+
current(): Promise<Stored | undefined>;
|
|
83
|
+
login(opts?: {
|
|
84
|
+
device?: boolean;
|
|
85
|
+
force?: boolean;
|
|
86
|
+
}): Promise<{
|
|
87
|
+
stored: Stored;
|
|
88
|
+
fresh: boolean;
|
|
89
|
+
}>;
|
|
90
|
+
logout(): Promise<void>;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
declare const DEFAULT_API = "https://api.sb";
|
|
94
|
+
type Env$1 = Record<string, string | undefined>;
|
|
95
|
+
declare function apiBase(flag?: string, env?: Env$1): string;
|
|
96
|
+
declare function tokenFile(env?: Env$1): string;
|
|
97
|
+
|
|
98
|
+
type J$4 = Record<string, any>;
|
|
99
|
+
interface ClosesOn {
|
|
100
|
+
event: string;
|
|
101
|
+
verb: string;
|
|
102
|
+
url: string;
|
|
103
|
+
target?: string;
|
|
104
|
+
via: 'api.sb' | 'preview' | 'derived';
|
|
105
|
+
permission?: {
|
|
106
|
+
needs: string;
|
|
107
|
+
held: boolean;
|
|
108
|
+
heldBy: Record<string, string>;
|
|
109
|
+
assignee?: string;
|
|
110
|
+
why?: string;
|
|
111
|
+
};
|
|
112
|
+
approvalNeeded?: boolean;
|
|
113
|
+
refused?: string;
|
|
114
|
+
blocked?: string;
|
|
115
|
+
says?: string;
|
|
116
|
+
}
|
|
117
|
+
interface Task {
|
|
118
|
+
$id: string;
|
|
119
|
+
type: string;
|
|
120
|
+
name: string;
|
|
121
|
+
status: string;
|
|
122
|
+
reason?: string;
|
|
123
|
+
startup: string;
|
|
124
|
+
worker: string;
|
|
125
|
+
role?: string;
|
|
126
|
+
verb?: string;
|
|
127
|
+
object?: string;
|
|
128
|
+
about?: string;
|
|
129
|
+
conversation?: string;
|
|
130
|
+
due?: string;
|
|
131
|
+
overdue?: number;
|
|
132
|
+
age?: number;
|
|
133
|
+
since?: string;
|
|
134
|
+
priority: number;
|
|
135
|
+
priorityText?: string;
|
|
136
|
+
priorityWhy: string[];
|
|
137
|
+
step: string;
|
|
138
|
+
stepTitle?: string;
|
|
139
|
+
closesOn?: ClosesOn;
|
|
140
|
+
}
|
|
141
|
+
interface RoleDesk {
|
|
142
|
+
name: string;
|
|
143
|
+
$id: string;
|
|
144
|
+
owns?: string;
|
|
145
|
+
summary: string[];
|
|
146
|
+
permissions: string[];
|
|
147
|
+
mandates?: string[];
|
|
148
|
+
limits: {
|
|
149
|
+
name: string;
|
|
150
|
+
limit?: number;
|
|
151
|
+
used?: number;
|
|
152
|
+
text?: string;
|
|
153
|
+
}[];
|
|
154
|
+
tools: string[];
|
|
155
|
+
}
|
|
156
|
+
interface StartupDesk {
|
|
157
|
+
domain: string;
|
|
158
|
+
$id: string;
|
|
159
|
+
real?: string;
|
|
160
|
+
worker?: {
|
|
161
|
+
name: string;
|
|
162
|
+
kind?: string;
|
|
163
|
+
model?: string;
|
|
164
|
+
$id: string;
|
|
165
|
+
skills: string[];
|
|
166
|
+
};
|
|
167
|
+
roles: RoleDesk[];
|
|
168
|
+
open: number;
|
|
169
|
+
glossary?: string;
|
|
170
|
+
glossaryUrl: string;
|
|
171
|
+
}
|
|
172
|
+
interface Cluster {
|
|
173
|
+
worker: string;
|
|
174
|
+
startup: string;
|
|
175
|
+
step: string;
|
|
176
|
+
stepTitle?: string;
|
|
177
|
+
tasks: Task[];
|
|
178
|
+
}
|
|
179
|
+
interface Worklist {
|
|
180
|
+
source: 'api.sb' | 'stub';
|
|
181
|
+
worker: {
|
|
182
|
+
handle: string;
|
|
183
|
+
name: string;
|
|
184
|
+
kind?: string;
|
|
185
|
+
model?: string;
|
|
186
|
+
$id?: string;
|
|
187
|
+
};
|
|
188
|
+
startups: StartupDesk[];
|
|
189
|
+
open: number;
|
|
190
|
+
limit: number;
|
|
191
|
+
limitMax?: number;
|
|
192
|
+
limitAsked?: number;
|
|
193
|
+
page?: number;
|
|
194
|
+
pages?: number;
|
|
195
|
+
more?: number;
|
|
196
|
+
moreText?: string;
|
|
197
|
+
next?: string;
|
|
198
|
+
links?: {
|
|
199
|
+
next?: string;
|
|
200
|
+
prev?: string;
|
|
201
|
+
first?: string;
|
|
202
|
+
last?: string;
|
|
203
|
+
self?: string;
|
|
204
|
+
};
|
|
205
|
+
batch: Cluster[];
|
|
206
|
+
tasks: Task[];
|
|
207
|
+
planned?: J$4[];
|
|
208
|
+
gaps: string[];
|
|
209
|
+
sources: string[];
|
|
210
|
+
priorityBands?: Record<string, string>;
|
|
211
|
+
rules?: string[];
|
|
212
|
+
asOf?: string;
|
|
213
|
+
datesRelativeTo?: 'asOf';
|
|
214
|
+
clock?: string;
|
|
215
|
+
generatedAt: string;
|
|
216
|
+
}
|
|
217
|
+
declare class WorklistError extends Error {
|
|
218
|
+
readonly status: number;
|
|
219
|
+
readonly body: unknown;
|
|
220
|
+
constructor(message: string, status: number, body: unknown);
|
|
221
|
+
}
|
|
222
|
+
interface WorklistOpts {
|
|
223
|
+
worker: string;
|
|
224
|
+
startups: string[];
|
|
225
|
+
limit?: number;
|
|
226
|
+
page?: number;
|
|
227
|
+
all?: boolean;
|
|
228
|
+
today?: string;
|
|
229
|
+
previews?: boolean;
|
|
230
|
+
stubOnly?: boolean;
|
|
231
|
+
}
|
|
232
|
+
declare function worklistPath(worker: string, startups: string[], limit: number, md?: boolean, page?: number): string;
|
|
233
|
+
declare const heldByNames: (h: Record<string, string> | string[] | undefined) => string[];
|
|
234
|
+
declare function fetchWorklistMarkdown(api: Api, o: {
|
|
235
|
+
worker: string;
|
|
236
|
+
startups: string[];
|
|
237
|
+
limit?: number;
|
|
238
|
+
page?: number;
|
|
239
|
+
}): Promise<string>;
|
|
240
|
+
declare function parseWorker(arg?: string): string | undefined;
|
|
241
|
+
declare function derivePriority(t: J$4, today: string): {
|
|
242
|
+
priority: number;
|
|
243
|
+
why: string[];
|
|
111
244
|
};
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
245
|
+
declare function stepOf(t: J$4, domain: string): string;
|
|
246
|
+
declare function selectBatch(tasks: Task[], limit: number): Cluster[];
|
|
247
|
+
interface StartupGroup {
|
|
248
|
+
startup: string;
|
|
249
|
+
steps: {
|
|
250
|
+
step: string;
|
|
251
|
+
stepTitle?: string;
|
|
252
|
+
tasks: Task[];
|
|
253
|
+
}[];
|
|
254
|
+
}
|
|
255
|
+
declare function groupBatch(batch: Cluster[]): StartupGroup[];
|
|
256
|
+
declare function buildWorklist(api: Api, o: WorklistOpts): Promise<Worklist>;
|
|
257
|
+
|
|
258
|
+
type J$3 = Record<string, any>;
|
|
259
|
+
type Mode = 'try' | 'send' | 'do';
|
|
260
|
+
interface CloseOpts {
|
|
261
|
+
task: string;
|
|
262
|
+
mode?: Mode;
|
|
263
|
+
as?: string;
|
|
264
|
+
input?: J$3;
|
|
265
|
+
idempotencyKey?: string;
|
|
266
|
+
force?: boolean;
|
|
267
|
+
prepare?: (c: ClosesOn) => {
|
|
268
|
+
input?: J$3;
|
|
269
|
+
error?: string;
|
|
270
|
+
};
|
|
271
|
+
}
|
|
272
|
+
type Outcome = 'Done' | 'Pending' | 'Refused' | 'Replayed' | 'KeyReused' | 'Blocked' | 'NotSent' | 'Error';
|
|
273
|
+
interface CloseResult {
|
|
274
|
+
task: {
|
|
275
|
+
$id: string;
|
|
276
|
+
name: string;
|
|
277
|
+
type: string;
|
|
278
|
+
status?: string;
|
|
279
|
+
startup: string;
|
|
280
|
+
worker: string;
|
|
281
|
+
priorityText?: string;
|
|
282
|
+
stepTitle?: string;
|
|
283
|
+
};
|
|
284
|
+
closesOn: ClosesOn;
|
|
285
|
+
mode: Mode;
|
|
286
|
+
as: string;
|
|
287
|
+
request: {
|
|
288
|
+
method: 'POST';
|
|
289
|
+
url: string;
|
|
290
|
+
prefer: string;
|
|
291
|
+
idempotencyKey: string;
|
|
292
|
+
};
|
|
293
|
+
status: number;
|
|
294
|
+
outcome: Outcome;
|
|
295
|
+
action?: J$3;
|
|
296
|
+
replayed: boolean;
|
|
297
|
+
tried: boolean;
|
|
298
|
+
sink?: string;
|
|
299
|
+
blocked?: {
|
|
300
|
+
code?: string;
|
|
301
|
+
message?: string;
|
|
302
|
+
};
|
|
303
|
+
note?: string;
|
|
304
|
+
body: unknown;
|
|
305
|
+
}
|
|
306
|
+
interface ClosingTask {
|
|
307
|
+
$id: string;
|
|
308
|
+
name: string;
|
|
309
|
+
type: string;
|
|
310
|
+
status?: string;
|
|
311
|
+
startup: string;
|
|
312
|
+
worker: string;
|
|
313
|
+
priorityText?: string;
|
|
314
|
+
stepTitle?: string;
|
|
315
|
+
closesOn: ClosesOn;
|
|
316
|
+
}
|
|
317
|
+
declare function findClosesOn(api: Api, taskRef: string): Promise<{
|
|
318
|
+
task: ClosingTask;
|
|
319
|
+
thing: J$3;
|
|
320
|
+
worklist?: Worklist;
|
|
321
|
+
}>;
|
|
322
|
+
declare function closeTask(api: Api, o: CloseOpts): Promise<CloseResult>;
|
|
323
|
+
declare const closesOf: (a: J$3 | undefined) => string[];
|
|
324
|
+
|
|
325
|
+
declare function batchText(w: Worklist, o?: {
|
|
326
|
+
bin?: string;
|
|
327
|
+
}): string;
|
|
328
|
+
declare function closeText(r: CloseResult): string;
|
|
329
|
+
|
|
330
|
+
declare function renderPrompt(w: Worklist, o?: {
|
|
331
|
+
bin?: string;
|
|
332
|
+
}): string;
|
|
333
|
+
|
|
334
|
+
interface CloudSession {
|
|
335
|
+
startup: string;
|
|
336
|
+
via: 'api.sb' | 'claude-runner' | 'none';
|
|
337
|
+
url?: string;
|
|
338
|
+
status?: number;
|
|
339
|
+
session?: string;
|
|
340
|
+
request: {
|
|
341
|
+
url: string;
|
|
342
|
+
body: Record<string, unknown>;
|
|
343
|
+
};
|
|
344
|
+
note?: string;
|
|
345
|
+
}
|
|
346
|
+
declare function runCloud(api: Api, w: Worklist, o: {
|
|
347
|
+
runner: string;
|
|
348
|
+
runnerToken?: string;
|
|
349
|
+
dryRun?: boolean;
|
|
350
|
+
bin?: string;
|
|
351
|
+
model?: string;
|
|
352
|
+
fetch?: typeof fetch;
|
|
353
|
+
}): Promise<CloudSession[]>;
|
|
354
|
+
|
|
355
|
+
type J$2 = Record<string, any>;
|
|
356
|
+
declare function collectionOf(noun: string): string;
|
|
357
|
+
declare function verbPath(spec: string, target: string | undefined, startup: string | undefined): string;
|
|
358
|
+
interface VerbPreview {
|
|
359
|
+
url: string;
|
|
360
|
+
status: number;
|
|
361
|
+
name?: string;
|
|
362
|
+
does?: string;
|
|
363
|
+
event?: string;
|
|
364
|
+
mode?: string;
|
|
365
|
+
state?: string;
|
|
366
|
+
refused?: string;
|
|
367
|
+
permission?: {
|
|
368
|
+
needs: string;
|
|
369
|
+
heldBy: string[];
|
|
370
|
+
};
|
|
371
|
+
approvalNeeded?: boolean;
|
|
372
|
+
inputs: string[];
|
|
373
|
+
error?: string;
|
|
374
|
+
}
|
|
375
|
+
interface DoResult {
|
|
376
|
+
preview: VerbPreview;
|
|
377
|
+
invoked: boolean;
|
|
378
|
+
post?: {
|
|
379
|
+
status: number;
|
|
380
|
+
idempotencyKey: string;
|
|
381
|
+
body: unknown;
|
|
382
|
+
action?: string;
|
|
383
|
+
actionStatus?: string;
|
|
384
|
+
says?: string;
|
|
385
|
+
note?: string;
|
|
386
|
+
};
|
|
387
|
+
}
|
|
388
|
+
declare function doVerb(api: Api, o: {
|
|
389
|
+
spec: string;
|
|
390
|
+
target?: string;
|
|
391
|
+
startup?: string;
|
|
392
|
+
input?: J$2;
|
|
393
|
+
mode?: string;
|
|
394
|
+
as?: string;
|
|
395
|
+
previewOnly?: boolean;
|
|
396
|
+
force?: boolean;
|
|
397
|
+
idempotencyKey?: string;
|
|
398
|
+
}): Promise<DoResult>;
|
|
399
|
+
|
|
400
|
+
type Env = Record<string, string | undefined>;
|
|
401
|
+
interface Lease {
|
|
402
|
+
batch: string;
|
|
403
|
+
worker: string;
|
|
404
|
+
startup: string;
|
|
405
|
+
step: string;
|
|
406
|
+
priority?: number;
|
|
407
|
+
tasks: string[];
|
|
408
|
+
prompt: string;
|
|
409
|
+
until: string;
|
|
410
|
+
token: string;
|
|
411
|
+
session: string;
|
|
412
|
+
claimedAt: string;
|
|
413
|
+
leaseSeconds: number;
|
|
414
|
+
api: string;
|
|
415
|
+
closed: string[];
|
|
416
|
+
held?: 'dispatcher';
|
|
417
|
+
}
|
|
418
|
+
declare function leasesDir(env?: Env): string;
|
|
419
|
+
declare class Leases {
|
|
420
|
+
readonly dir: string;
|
|
421
|
+
private now;
|
|
422
|
+
private env;
|
|
423
|
+
private memory?;
|
|
424
|
+
constructor(dir: string, now?: () => number, env?: Env);
|
|
425
|
+
private ensure;
|
|
426
|
+
private write;
|
|
427
|
+
file(batch: string): string;
|
|
428
|
+
save(l: Lease): Lease;
|
|
429
|
+
adopt(l: Lease): Lease;
|
|
430
|
+
get pin(): string | undefined;
|
|
431
|
+
needsAdoption(): boolean;
|
|
432
|
+
all(): Lease[];
|
|
433
|
+
live(l: Lease): boolean;
|
|
434
|
+
get(ref: string): Lease | undefined;
|
|
435
|
+
current(): Lease | undefined;
|
|
436
|
+
holding(task: string): Lease | undefined;
|
|
437
|
+
update(batch: string, patch: (l: Lease) => void): Lease | undefined;
|
|
438
|
+
markClosed(batch: string, task: string): Lease | undefined;
|
|
439
|
+
remove(batch: string): void;
|
|
440
|
+
remember(kind: 'queue' | 'worklist', ids: string[]): void;
|
|
441
|
+
recall(kind: 'queue' | 'worklist'): string[];
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
type J$1 = Record<string, any>;
|
|
445
|
+
interface Out<T = unknown> {
|
|
446
|
+
text: string;
|
|
447
|
+
data: T;
|
|
448
|
+
exit: number;
|
|
449
|
+
}
|
|
450
|
+
interface Batch {
|
|
451
|
+
$id: string;
|
|
452
|
+
worker: string;
|
|
453
|
+
startup: string;
|
|
454
|
+
startups?: string[];
|
|
455
|
+
step: string;
|
|
456
|
+
stepTitle?: string;
|
|
457
|
+
priority: number;
|
|
458
|
+
tasks: string[];
|
|
459
|
+
prompt: string;
|
|
460
|
+
claim: string;
|
|
461
|
+
[k: string]: unknown;
|
|
462
|
+
}
|
|
463
|
+
interface Cred {
|
|
464
|
+
token: string;
|
|
465
|
+
api: string;
|
|
466
|
+
}
|
|
467
|
+
interface SessionDeps {
|
|
468
|
+
base: string;
|
|
469
|
+
leases: Leases;
|
|
470
|
+
token: () => Promise<string | Cred | undefined>;
|
|
471
|
+
login?: () => Promise<string | Cred | undefined>;
|
|
472
|
+
fetch?: typeof fetch;
|
|
473
|
+
userAgent?: string;
|
|
474
|
+
now?: () => number;
|
|
475
|
+
session?: string;
|
|
476
|
+
leaseSeconds?: number;
|
|
477
|
+
env?: Record<string, string | undefined>;
|
|
478
|
+
}
|
|
479
|
+
declare class Session {
|
|
480
|
+
readonly base: string;
|
|
481
|
+
readonly leases: Leases;
|
|
482
|
+
private d;
|
|
483
|
+
constructor(d: SessionDeps);
|
|
484
|
+
api(c?: string | Cred): Api;
|
|
485
|
+
private cred;
|
|
486
|
+
private leaseCred;
|
|
487
|
+
private now;
|
|
488
|
+
private get env();
|
|
489
|
+
private adopting?;
|
|
490
|
+
ensureLease(): Promise<Out<null> | undefined>;
|
|
491
|
+
private adopt;
|
|
492
|
+
private ended;
|
|
493
|
+
short(u: string | undefined): string;
|
|
494
|
+
when(iso: string | undefined): string;
|
|
495
|
+
private baseToken;
|
|
496
|
+
private fail;
|
|
497
|
+
private none;
|
|
498
|
+
resolve(ref: string, o?: {
|
|
499
|
+
kind?: 'task' | 'batch';
|
|
500
|
+
}): string;
|
|
501
|
+
private label;
|
|
502
|
+
private readToken;
|
|
503
|
+
batchLine(b: Batch, i: number, withWorker: boolean): string;
|
|
504
|
+
listQueue(o?: {
|
|
505
|
+
worker?: string;
|
|
506
|
+
limit?: number;
|
|
507
|
+
}): Promise<{
|
|
508
|
+
r: Res;
|
|
509
|
+
batches: Batch[];
|
|
510
|
+
}>;
|
|
511
|
+
queue(o?: {
|
|
512
|
+
worker?: string;
|
|
513
|
+
limit?: number;
|
|
514
|
+
}): Promise<Out<{
|
|
515
|
+
batches: Batch[];
|
|
516
|
+
}>>;
|
|
517
|
+
private batchOf;
|
|
518
|
+
private claimOne;
|
|
519
|
+
claim(o?: {
|
|
520
|
+
ref?: string;
|
|
521
|
+
worker?: string;
|
|
522
|
+
leaseSeconds?: number;
|
|
523
|
+
skip?: Set<string>;
|
|
524
|
+
}): Promise<Out<{
|
|
525
|
+
lease?: Omit<Lease, 'token'>;
|
|
526
|
+
taken: string[];
|
|
527
|
+
}>>;
|
|
528
|
+
private leaseOf;
|
|
529
|
+
private leasePost;
|
|
530
|
+
renew(o?: {
|
|
531
|
+
batch?: string | Lease;
|
|
532
|
+
leaseSeconds?: number;
|
|
533
|
+
notAfter?: number;
|
|
534
|
+
}): Promise<Out<{
|
|
535
|
+
until?: string;
|
|
536
|
+
lost?: boolean;
|
|
537
|
+
dispatcher?: boolean;
|
|
538
|
+
capped?: boolean;
|
|
539
|
+
}>>;
|
|
540
|
+
release(o?: {
|
|
541
|
+
batch?: string | Lease;
|
|
542
|
+
}): Promise<Out<{
|
|
543
|
+
closed: number;
|
|
544
|
+
returned: number;
|
|
545
|
+
already?: boolean;
|
|
546
|
+
dispatcher?: boolean;
|
|
547
|
+
}>>;
|
|
548
|
+
batchPrompt(l: Lease): Promise<Out<{
|
|
549
|
+
url: string;
|
|
550
|
+
}>>;
|
|
551
|
+
prompt(o?: {
|
|
552
|
+
name?: string;
|
|
553
|
+
set?: string;
|
|
554
|
+
}): Promise<Out<J$1>>;
|
|
555
|
+
private isLeaseToken;
|
|
556
|
+
promptSet(o: {
|
|
557
|
+
name: string;
|
|
558
|
+
text: string;
|
|
559
|
+
idempotencyKey?: string;
|
|
560
|
+
}): Promise<Out<J$1>>;
|
|
561
|
+
show(o: {
|
|
562
|
+
ref: string;
|
|
563
|
+
md?: boolean;
|
|
564
|
+
}): Promise<Out<J$1>>;
|
|
565
|
+
thingText(t: J$1): string;
|
|
566
|
+
value(v: unknown, max?: number): string;
|
|
567
|
+
diffText(a: J$1 | undefined): string;
|
|
568
|
+
closeLine(label: string, r: CloseResult, left?: number): string;
|
|
569
|
+
close(o: {
|
|
570
|
+
ref: string;
|
|
571
|
+
body?: unknown;
|
|
572
|
+
mode?: Mode;
|
|
573
|
+
as?: string;
|
|
574
|
+
force?: boolean;
|
|
575
|
+
idempotencyKey?: string;
|
|
576
|
+
}): Promise<Out<CloseResult | null>>;
|
|
577
|
+
closedOf(l: Lease): Promise<string[]>;
|
|
578
|
+
worklistText(w: Worklist): string;
|
|
579
|
+
taskLine(t: Task, n: number): string;
|
|
580
|
+
worklist(o: {
|
|
581
|
+
worker: string;
|
|
582
|
+
startups?: string[];
|
|
583
|
+
limit?: number;
|
|
584
|
+
page?: number;
|
|
585
|
+
}): Promise<Out<Worklist>>;
|
|
586
|
+
versions(o: {
|
|
587
|
+
ref: string;
|
|
588
|
+
limit?: number;
|
|
589
|
+
}): Promise<Out<J$1>>;
|
|
590
|
+
revert(o: {
|
|
591
|
+
ref: string;
|
|
592
|
+
to: string;
|
|
593
|
+
mode?: Mode;
|
|
594
|
+
idempotencyKey?: string;
|
|
595
|
+
}): Promise<Out<J$1>>;
|
|
596
|
+
changes(o?: {
|
|
597
|
+
worker?: string;
|
|
598
|
+
startup?: string;
|
|
599
|
+
limit?: number;
|
|
600
|
+
}): Promise<Out<J$1>>;
|
|
601
|
+
}
|
|
602
|
+
|
|
603
|
+
type J = Record<string, any>;
|
|
604
|
+
declare const VERDICTS: readonly ["confirmed", "corrected", "unsure"];
|
|
605
|
+
declare function checkBody(event: string, body: unknown): {
|
|
606
|
+
body?: J;
|
|
607
|
+
errors: string[];
|
|
608
|
+
};
|
|
609
|
+
|
|
610
|
+
interface AgentRun {
|
|
611
|
+
prompt: string;
|
|
612
|
+
env: Record<string, string>;
|
|
613
|
+
cwd: string;
|
|
614
|
+
batch: string;
|
|
615
|
+
log: {
|
|
616
|
+
out: (chunk: string) => void;
|
|
617
|
+
err: (chunk: string) => void;
|
|
618
|
+
};
|
|
619
|
+
signal: AbortSignal;
|
|
620
|
+
done: () => Promise<boolean>;
|
|
621
|
+
}
|
|
622
|
+
interface AgentResult {
|
|
623
|
+
exitCode: number | null;
|
|
624
|
+
note?: string;
|
|
625
|
+
}
|
|
626
|
+
type AgentRunner = (r: AgentRun) => Promise<AgentResult>;
|
|
627
|
+
interface WorkOpts {
|
|
628
|
+
agent: AgentRunner;
|
|
629
|
+
agentName: string;
|
|
630
|
+
worker?: string;
|
|
631
|
+
maxBatches?: number;
|
|
632
|
+
wait?: boolean;
|
|
633
|
+
pollMs?: number;
|
|
634
|
+
renewMs?: number;
|
|
635
|
+
watchMs?: number;
|
|
636
|
+
logDir: string;
|
|
637
|
+
line: (s: string) => void;
|
|
638
|
+
signal: AbortSignal;
|
|
639
|
+
env?: Record<string, string | undefined>;
|
|
640
|
+
selfCli?: string;
|
|
641
|
+
tmpRoot?: string;
|
|
642
|
+
now?: () => number;
|
|
643
|
+
wallMinutes?: number;
|
|
644
|
+
}
|
|
645
|
+
interface WorkSummary {
|
|
646
|
+
batches: number;
|
|
647
|
+
tasks: number;
|
|
648
|
+
closed: number;
|
|
649
|
+
errors: number;
|
|
650
|
+
ms: number;
|
|
651
|
+
stopped: 'empty' | 'max' | 'signal' | 'error';
|
|
652
|
+
}
|
|
653
|
+
declare function agentEnv(base: Record<string, string | undefined>, lease: Lease, api: string, binDir?: string, configHome?: string, workdir?: string): Record<string, string>;
|
|
654
|
+
declare function agentPrompt(md: string, n: number): string;
|
|
655
|
+
declare function work(s: Session, o: WorkOpts): Promise<WorkSummary>;
|
|
656
|
+
|
|
657
|
+
declare function printRunner(o?: {
|
|
658
|
+
out?: (s: string) => void;
|
|
659
|
+
pollMs?: number;
|
|
660
|
+
}): AgentRunner;
|
|
661
|
+
|
|
662
|
+
type A = Record<string, any>;
|
|
663
|
+
interface ToolDef {
|
|
664
|
+
name: string;
|
|
665
|
+
description: string;
|
|
666
|
+
inputSchema: {
|
|
667
|
+
type: 'object';
|
|
668
|
+
properties: Record<string, unknown>;
|
|
669
|
+
required?: string[];
|
|
670
|
+
};
|
|
671
|
+
run: (s: Session, a: A) => Promise<Out>;
|
|
672
|
+
}
|
|
673
|
+
declare const TOOLS: ToolDef[];
|
|
674
|
+
declare function mcpServer(session: Session, version: string, o?: {
|
|
675
|
+
owner?: boolean;
|
|
676
|
+
}): Server;
|
|
677
|
+
|
|
678
|
+
export { type AgentRun, type AgentRunner, Api, Auth, type Batch, type CloseResult, type ClosesOn, type ClosingTask, type Cluster, DEFAULT_API, type Lease, Leases, type Mode, type Out, type Res, Session, type SessionDeps, type Stored, TOOLS, type Task, VERDICTS, type WorkOpts, type WorkSummary, type Worklist, WorklistError, agentEnv, agentPrompt, apiBase, batchText, buildWorklist, checkBody, closeTask, closeText, closesOf, collectionOf, derivePriority, doVerb, fetchWorklistMarkdown, findClosesOn, groupBatch, heldByNames, leasesDir, mcpServer, parseWorker, pkce, printRunner, renderPrompt, runCloud, selectBatch, stepOf, tokenFile, unwrapState, verbPath, work, worklistPath };
|