@keystrokehq/cli 1.0.18 → 1.0.20

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.
@@ -1,1921 +0,0 @@
1
- #!/usr/bin/env node
2
- import { An as array, Dn as ZodType, Fn as string, In as union, It as ROUTE_MANIFEST_REL_PATH, Ln as toJSONSchema, Mn as discriminatedUnion, Nn as literal, Nt as PromptResponseSchema, On as _enum, Pn as object, jn as custom, kn as _function, xn as normalizeCredentialList } from "./dist-DfEfdcEL.mjs";
3
- import "./chunk-BZUGFHVS-CPWRFwK8.mjs";
4
- import "./chunk-DLL7UR66-BUYgzxnR.mjs";
5
- import "./chunk-TN7HHBQW-CSB_R-XD.mjs";
6
- import "./chunk-L64BMZUV-CyR7RKok.mjs";
7
- import "./chunk-4RUAZWKT-D60fyWAB.mjs";
8
- import "./chunk-NRSASXYY-CuWyREpD.mjs";
9
- import "./chunk-SAI2SPQQ-CVRoDNs9.mjs";
10
- import "./chunk-STHBFACM-lyj-j2a-.mjs";
11
- import "./chunk-W5DWRFSU-lCyWk0ph.mjs";
12
- import "./chunk-WNH3HOQA-BCZUOjCJ.mjs";
13
- import "./chunk-HBVMHTO5-CJyD-QZX.mjs";
14
- import "./chunk-FOCWZZDE-BIntqBh2.mjs";
15
- import "./chunk-L2UW7DWF-B3tEHhPF.mjs";
16
- import "./chunk-XRFHFXFP-BGxzVZgK.mjs";
17
- import { createRequire } from "node:module";
18
- import "node:os";
19
- import { basename, dirname, join, relative, sep } from "node:path";
20
- import { existsSync, mkdirSync, readFileSync, readdirSync, statSync, writeFileSync } from "node:fs";
21
- import { readdir, stat } from "node:fs/promises";
22
- import { pathToFileURL } from "node:url";
23
- import { AsyncLocalStorage } from "node:async_hooks";
24
- //#region ../../node_modules/.pnpm/just-bash@3.0.1/node_modules/just-bash/dist/bundle/chunks/chunk-G5EVRAOO.js
25
- createRequire(import.meta.url);
26
- var p;
27
- (function(e) {
28
- e.EOF = "EOF", e.NEWLINE = "NEWLINE", e.SEMICOLON = "SEMICOLON", e.AMP = "AMP", e.PIPE = "PIPE", e.PIPE_AMP = "PIPE_AMP", e.AND_AND = "AND_AND", e.OR_OR = "OR_OR", e.BANG = "BANG", e.LESS = "LESS", e.GREAT = "GREAT", e.DLESS = "DLESS", e.DGREAT = "DGREAT", e.LESSAND = "LESSAND", e.GREATAND = "GREATAND", e.LESSGREAT = "LESSGREAT", e.DLESSDASH = "DLESSDASH", e.CLOBBER = "CLOBBER", e.TLESS = "TLESS", e.AND_GREAT = "AND_GREAT", e.AND_DGREAT = "AND_DGREAT", e.LPAREN = "LPAREN", e.RPAREN = "RPAREN", e.LBRACE = "LBRACE", e.RBRACE = "RBRACE", e.DSEMI = "DSEMI", e.SEMI_AND = "SEMI_AND", e.SEMI_SEMI_AND = "SEMI_SEMI_AND", e.DBRACK_START = "DBRACK_START", e.DBRACK_END = "DBRACK_END", e.DPAREN_START = "DPAREN_START", e.DPAREN_END = "DPAREN_END", e.IF = "IF", e.THEN = "THEN", e.ELSE = "ELSE", e.ELIF = "ELIF", e.FI = "FI", e.FOR = "FOR", e.WHILE = "WHILE", e.UNTIL = "UNTIL", e.DO = "DO", e.DONE = "DONE", e.CASE = "CASE", e.ESAC = "ESAC", e.IN = "IN", e.FUNCTION = "FUNCTION", e.SELECT = "SELECT", e.TIME = "TIME", e.COPROC = "COPROC", e.WORD = "WORD", e.NAME = "NAME", e.NUMBER = "NUMBER", e.ASSIGNMENT_WORD = "ASSIGNMENT_WORD", e.FD_VARIABLE = "FD_VARIABLE", e.COMMENT = "COMMENT", e.HEREDOC_CONTENT = "HEREDOC_CONTENT";
29
- })(p || (p = {}));
30
- new Map([
31
- ["if", p.IF],
32
- ["then", p.THEN],
33
- ["else", p.ELSE],
34
- ["elif", p.ELIF],
35
- ["fi", p.FI],
36
- ["for", p.FOR],
37
- ["while", p.WHILE],
38
- ["until", p.UNTIL],
39
- ["do", p.DO],
40
- ["done", p.DONE],
41
- ["case", p.CASE],
42
- ["esac", p.ESAC],
43
- ["in", p.IN],
44
- ["function", p.FUNCTION],
45
- ["select", p.SELECT],
46
- ["time", p.TIME],
47
- ["coproc", p.COPROC]
48
- ]);
49
- p.SEMI_SEMI_AND, p.TLESS, p.AND_DGREAT;
50
- p.DBRACK_START, p.DBRACK_END, p.DPAREN_START, p.DPAREN_END, p.AND_AND, p.OR_OR, p.DSEMI, p.SEMI_AND, p.PIPE_AMP, p.DGREAT, p.LESSAND, p.GREATAND, p.LESSGREAT, p.CLOBBER, p.AND_GREAT;
51
- new Map([
52
- ["|", p.PIPE],
53
- ["&", p.AMP],
54
- [";", p.SEMICOLON],
55
- ["(", p.LPAREN],
56
- [")", p.RPAREN],
57
- ["<", p.LESS],
58
- [">", p.GREAT]
59
- ]);
60
- new Set([
61
- p.LESS,
62
- p.GREAT,
63
- p.DLESS,
64
- p.DGREAT,
65
- p.LESSAND,
66
- p.GREATAND,
67
- p.LESSGREAT,
68
- p.DLESSDASH,
69
- p.CLOBBER,
70
- p.TLESS,
71
- p.AND_GREAT,
72
- p.AND_DGREAT
73
- ]);
74
- new Set([
75
- p.LESS,
76
- p.GREAT,
77
- p.DLESS,
78
- p.DGREAT,
79
- p.LESSAND,
80
- p.GREATAND,
81
- p.LESSGREAT,
82
- p.DLESSDASH,
83
- p.CLOBBER,
84
- p.TLESS
85
- ]);
86
- new Set([
87
- p.LESS,
88
- p.GREAT,
89
- p.DLESS,
90
- p.DGREAT,
91
- p.LESSAND,
92
- p.GREATAND,
93
- p.LESSGREAT,
94
- p.DLESSDASH,
95
- p.CLOBBER,
96
- p.TLESS,
97
- p.AND_GREAT,
98
- p.AND_DGREAT
99
- ]);
100
- new Set([
101
- p.AMP,
102
- p.PIPE,
103
- p.PIPE_AMP,
104
- p.SEMICOLON,
105
- p.AND_AND,
106
- p.OR_OR,
107
- p.DSEMI,
108
- p.SEMI_AND,
109
- p.SEMI_SEMI_AND
110
- ]);
111
- //#endregion
112
- //#region ../../packages/manifest/dist/discovery-CWjr_liZ.mjs
113
- const SOURCE_EXT = /\.(ts|mts|mjs|js)$/;
114
- const DECLARATION_FILE$1 = /\.d\.(ts|mts|cts)$/;
115
- function entryIdFromFile(rootDir, filePath, options) {
116
- if (DECLARATION_FILE$1.test(filePath)) return null;
117
- const baseName = filePath.split(sep).at(-1) ?? "";
118
- if (/\.(int\.)?test\.(ts|mts)$/.test(baseName)) return null;
119
- const segments = relative(rootDir, filePath).replace(SOURCE_EXT, "").split(sep).filter((segment) => segment.length > 0);
120
- if (segments.length === 1) return segments[0] ?? null;
121
- const last = segments.at(-1);
122
- const entryNames = new Set([options.nestedEntry]);
123
- if (options.allowIndex !== false) entryNames.add("index");
124
- if (!last || !entryNames.has(last)) return null;
125
- const id = segments.slice(0, -1).join("/");
126
- return id.length > 0 ? id : null;
127
- }
128
- const SOURCE_FILE = /\.(ts|mts|mjs|js)$/;
129
- const TEST_FILE = /\.(int\.)?test\.(ts|mts)$/;
130
- const DECLARATION_FILE = /\.d\.(ts|mts|cts)$/;
131
- const JUNK_FILE = /^\._|\.DS_Store$/;
132
- async function walkTypeScriptFiles(dir) {
133
- let names;
134
- try {
135
- names = await readdir(dir);
136
- } catch (error) {
137
- if (error.code === "ENOENT") return [];
138
- throw error;
139
- }
140
- const files = [];
141
- for (const name of names) {
142
- const path = join(dir, name);
143
- if ((await stat(path)).isDirectory()) files.push(...await walkTypeScriptFiles(path));
144
- else if (!JUNK_FILE.test(name) && SOURCE_FILE.test(name) && !DECLARATION_FILE.test(name) && !TEST_FILE.test(name)) files.push(path);
145
- }
146
- return files;
147
- }
148
- async function discoverEntries(rootDir, options) {
149
- const files = await walkTypeScriptFiles(rootDir);
150
- const byKey = /* @__PURE__ */ new Map();
151
- for (const filePath of files) {
152
- const id = entryIdFromFile(rootDir, filePath, options);
153
- if (!id) continue;
154
- const key = options.formatKey(id);
155
- const moduleFile = relative(rootDir, filePath);
156
- const existing = byKey.get(key);
157
- if (existing) throw new Error(`Duplicate ${options.duplicateLabel} ${key}: ${existing.filePath} and ${filePath}`);
158
- byKey.set(key, {
159
- key,
160
- filePath,
161
- moduleFile
162
- });
163
- }
164
- return [...byKey.values()];
165
- }
166
- async function discoverModuleFileEntries(rootDir, options) {
167
- return (await discoverEntries(rootDir, {
168
- nestedEntry: options.nestedEntry,
169
- formatKey: (id) => id,
170
- duplicateLabel: options.duplicateLabel
171
- })).filter((entry) => options.shouldDiscoverFile?.(entry.filePath) ?? true).map(({ filePath, moduleFile }) => ({
172
- filePath,
173
- moduleFile
174
- }));
175
- }
176
- const HEADER_BYTES = 2048;
177
- const DIRECTIVE_RE = /@keystroke\s+ignore(?::([a-z]+))?/;
178
- /** Parse `@keystroke ignore` directives from a file header snippet. */
179
- function parseKeystrokeIgnoreDirective(header) {
180
- for (const line of header.slice(0, HEADER_BYTES).split("\n")) {
181
- const trimmed = line.trim();
182
- if (trimmed.length === 0) continue;
183
- if (!isCommentLine(trimmed)) break;
184
- const match = DIRECTIVE_RE.exec(trimmed);
185
- if (!match) continue;
186
- const scope = match[1];
187
- if (!scope) return "ignore";
188
- if (scope === "deploy") return "ignore:deploy";
189
- throw new Error(`Unknown @keystroke ignore target "${scope}" in directive "@keystroke ignore:${scope}"`);
190
- }
191
- return null;
192
- }
193
- /** Read `@keystroke ignore` directives from the top of a module file. */
194
- function readKeystrokeIgnoreDirective(filePath) {
195
- return parseKeystrokeIgnoreDirective(readFileSync(filePath, "utf8").slice(0, HEADER_BYTES));
196
- }
197
- /** Whether a discovered module file should be skipped for the given build phase. */
198
- function shouldSkipKeystrokeModuleFile(directive, phase) {
199
- if (!directive) return false;
200
- if (directive === "ignore") return true;
201
- return phase === "deploy";
202
- }
203
- function isCommentLine(line) {
204
- return line.startsWith("//") || line.startsWith("/*") || line.startsWith("*");
205
- }
206
- //#endregion
207
- //#region ../../packages/sandbox/dist/files-BOUCjfCQ.mjs
208
- const SandboxModeSchema = _enum(["in-process", "vm"]);
209
- const SandboxFileContentSchema = object({
210
- path: string(),
211
- file: string()
212
- });
213
- /** Destination path under `/workspace`. For `dir`, used as a prefix. */
214
- const SandboxFileSchema = object({
215
- path: string(),
216
- /** Single file body — typically from a build-time import (`import doc from "./doc.md"`). */
217
- file: string().optional(),
218
- /** Directory contents — each path is relative to `path`. */
219
- dir: array(SandboxFileContentSchema).optional()
220
- });
221
- /** Author-facing project file set reference under `src/files/`. */
222
- const SandboxProjectFilesSchema = union([literal(true), string()]);
223
- /** Author-facing sandbox files: inline entries or a project file set. */
224
- const SandboxFilesInputSchema = union([array(SandboxFileSchema), SandboxProjectFilesSchema]);
225
- object({
226
- key: string().optional(),
227
- /** Sandbox execution mode. Defaults to in-process when omitted. */
228
- mode: SandboxModeSchema.optional(),
229
- files: SandboxFilesInputSchema.optional()
230
- });
231
- object({
232
- key: string().optional(),
233
- mode: SandboxModeSchema.optional(),
234
- files: array(SandboxFileSchema).optional()
235
- });
236
- const SKIP_DIRS$1 = new Set([".git", "node_modules"]);
237
- /** Recursively read a host file or directory into sandbox-relative `{ path, file }` entries. */
238
- function packDirFromDisk(rootPath) {
239
- const stat = statSync(rootPath);
240
- if (stat.isFile()) return [{
241
- path: basename(rootPath),
242
- file: readFileSync(rootPath, "utf8")
243
- }];
244
- if (!stat.isDirectory()) throw new Error(`Expected a file or directory at ${rootPath}`);
245
- const files = [];
246
- walkDir(rootPath, rootPath, files);
247
- return files;
248
- }
249
- function walkDir(rootPath, currentPath, files) {
250
- for (const name of readdirSync(currentPath)) {
251
- if (SKIP_DIRS$1.has(name)) continue;
252
- const entryPath = join(currentPath, name);
253
- const stat = statSync(entryPath);
254
- if (stat.isDirectory()) {
255
- walkDir(rootPath, entryPath, files);
256
- continue;
257
- }
258
- if (!stat.isFile()) continue;
259
- files.push({
260
- path: relative(rootPath, entryPath),
261
- file: readFileSync(entryPath, "utf8")
262
- });
263
- }
264
- }
265
- const SKIP_DIRS$2 = new Set([".git", "node_modules"]);
266
- /** Pack every subdir under `src/skills/` and `src/files/` into an asset manifest. */
267
- function packAssetDirs(appRoot, srcDir = "src") {
268
- return {
269
- skills: packAssetRoot(join(appRoot, srcDir, "skills")),
270
- files: packAssetRoot(join(appRoot, srcDir, "files"))
271
- };
272
- }
273
- function packAssetRoot(rootPath) {
274
- if (!statSync(rootPath, { throwIfNoEntry: false })?.isDirectory()) return {};
275
- const manifest = {};
276
- for (const name of readdirSync(rootPath)) {
277
- if (SKIP_DIRS$2.has(name)) continue;
278
- const entryPath = join(rootPath, name);
279
- if (!statSync(entryPath).isDirectory()) continue;
280
- manifest[name] = packDirFromDisk(entryPath);
281
- }
282
- return manifest;
283
- }
284
- const appRootStorage = new AsyncLocalStorage();
285
- /** Run with an explicit user-app root (parallel-safe alternative to mutating `KEYSTROKE_ROOT`). */
286
- function runWithAppRoot(appRoot, fn) {
287
- return appRootStorage.run(appRoot, fn);
288
- }
289
- /** Walk upward from a module file to find the user app root (`src/agents`, `src/skills`, etc.). */
290
- function resolveAppRoot(fromPath) {
291
- let dir = statSync(fromPath).isDirectory() ? fromPath : dirname(fromPath);
292
- while (dir !== dirname(dir)) {
293
- if (hasAppLayout(dir)) return dir;
294
- dir = dirname(dir);
295
- }
296
- return process.env.KEYSTROKE_ROOT ?? process.cwd();
297
- }
298
- function hasAppLayout(dir) {
299
- const src = join(dir, "src");
300
- const dist = join(dir, "dist");
301
- return existsSync(join(src, "agents")) || existsSync(join(src, "skills")) || existsSync(join(src, "files")) || existsSync(join(dist, "agents")) || existsSync(join(dist, ".keystroke", "assets.mjs"));
302
- }
303
- //#endregion
304
- //#region ../../node_modules/.pnpm/typebox@1.1.38/node_modules/typebox/build/system/memory/metrics.mjs
305
- /** TypeBox instantiation metrics */
306
- const Metrics = {
307
- assign: 0,
308
- create: 0,
309
- clone: 0,
310
- discard: 0,
311
- update: 0
312
- };
313
- //#endregion
314
- //#region ../../node_modules/.pnpm/typebox@1.1.38/node_modules/typebox/build/guard/guard.mjs
315
- /** Returns true if this value is an array */
316
- function IsArray(value) {
317
- return Array.isArray(value);
318
- }
319
- /** Returns true if this value is null */
320
- function IsNull(value) {
321
- return IsEqual(value, null);
322
- }
323
- /** Returns true if this value is an object */
324
- function IsObject(value) {
325
- return IsEqual(typeof value, "object") && !IsNull(value);
326
- }
327
- function IsEqual(left, right) {
328
- return left === right;
329
- }
330
- /** Returns true if the PropertyKey is Unsafe (ref: prototype-pollution). */
331
- function IsUnsafePropertyKey(key) {
332
- return IsEqual(key, "__proto__") || IsEqual(key, "constructor") || IsEqual(key, "prototype");
333
- }
334
- /** Returns true if this value has this property key */
335
- function HasPropertyKey(value, key) {
336
- return IsUnsafePropertyKey(key) ? Object.prototype.hasOwnProperty.call(value, key) : key in value;
337
- }
338
- /** Returns property keys for this object via `Object.getOwnPropertyKeys({ ... })` */
339
- function Keys(value) {
340
- return Object.getOwnPropertyNames(value);
341
- }
342
- //#endregion
343
- //#region ../../node_modules/.pnpm/typebox@1.1.38/node_modules/typebox/build/system/memory/clone.mjs
344
- function IsGuard(value) {
345
- return IsObject(value) && HasPropertyKey(value, "~guard");
346
- }
347
- function FromGuard(value) {
348
- return value;
349
- }
350
- function FromArray(value) {
351
- return value.map((value) => FromValue(value));
352
- }
353
- function FromObject(value) {
354
- const result = {};
355
- const descriptors = Object.getOwnPropertyDescriptors(value);
356
- for (const key of Object.keys(descriptors)) {
357
- const descriptor = descriptors[key];
358
- if (HasPropertyKey(descriptor, "value")) Object.defineProperty(result, key, {
359
- ...descriptor,
360
- value: FromValue(descriptor.value)
361
- });
362
- }
363
- return result;
364
- }
365
- function FromRegExp(value) {
366
- return new RegExp(value.source, value.flags);
367
- }
368
- function FromUnknown(value) {
369
- return value;
370
- }
371
- function FromValue(value) {
372
- return value instanceof RegExp ? FromRegExp(value) : IsGuard(value) ? FromGuard(value) : IsArray(value) ? FromArray(value) : IsObject(value) ? FromObject(value) : FromUnknown(value);
373
- }
374
- /**
375
- * Clones a value using the TypeBox type cloning strategy. This function preserves non-enumerable
376
- * properties from the source value. This is to ensure cloned types retain discriminable
377
- * hidden properties.
378
- */
379
- function Clone(value) {
380
- Metrics.clone += 1;
381
- return FromValue(value);
382
- }
383
- //#endregion
384
- //#region ../../node_modules/.pnpm/typebox@1.1.38/node_modules/typebox/build/system/settings/settings.mjs
385
- const settings = {
386
- immutableTypes: false,
387
- maxErrors: 8,
388
- useAcceleration: true,
389
- exactOptionalPropertyTypes: false,
390
- enumerableKind: false,
391
- correctiveParse: false
392
- };
393
- /** Gets current system settings */
394
- function Get() {
395
- return settings;
396
- }
397
- //#endregion
398
- //#region ../../node_modules/.pnpm/typebox@1.1.38/node_modules/typebox/build/system/memory/create.mjs
399
- function MergeHidden(left, right) {
400
- for (const key of Object.keys(right)) Object.defineProperty(left, key, {
401
- configurable: true,
402
- writable: true,
403
- enumerable: false,
404
- value: right[key]
405
- });
406
- return left;
407
- }
408
- function Merge(left, right) {
409
- return {
410
- ...left,
411
- ...right
412
- };
413
- }
414
- /**
415
- * Creates an object with hidden, enumerable, and optional property sets. This function
416
- * ensures types are instantiated according to configuration rules for enumerable and
417
- * non-enumerable properties.
418
- */
419
- function Create(hidden, enumerable, options = {}) {
420
- Metrics.create += 1;
421
- const settings = Get();
422
- const withOptions = Merge(enumerable, options);
423
- const withHidden = settings.enumerableKind ? Merge(withOptions, hidden) : MergeHidden(withOptions, hidden);
424
- return settings.immutableTypes ? Object.freeze(withHidden) : withHidden;
425
- }
426
- //#endregion
427
- //#region ../../node_modules/.pnpm/typebox@1.1.38/node_modules/typebox/build/system/memory/update.mjs
428
- /**
429
- * Updates a value with new properties while preserving property enumerability. Use this function to modify
430
- * existing types without altering their configuration.
431
- */
432
- function Update(current, hidden, enumerable) {
433
- Metrics.update += 1;
434
- const settings = Get();
435
- const result = Clone(current);
436
- for (const key of Object.keys(hidden)) Object.defineProperty(result, key, {
437
- configurable: true,
438
- writable: true,
439
- enumerable: settings.enumerableKind,
440
- value: hidden[key]
441
- });
442
- for (const key of Object.keys(enumerable)) Object.defineProperty(result, key, {
443
- configurable: true,
444
- enumerable: true,
445
- writable: true,
446
- value: enumerable[key]
447
- });
448
- return result;
449
- }
450
- //#endregion
451
- //#region ../../node_modules/.pnpm/typebox@1.1.38/node_modules/typebox/build/type/types/schema.mjs
452
- function IsSchema(value) {
453
- return IsObject(value);
454
- }
455
- //#endregion
456
- //#region ../../node_modules/.pnpm/typebox@1.1.38/node_modules/typebox/build/type/types/_optional.mjs
457
- /** Adds Optional to the given type. */
458
- function OptionalAdd(type) {
459
- return Update(type, { "~optional": true }, {});
460
- }
461
- /** Applies an Optional modifier to the given type. */
462
- function Optional(type) {
463
- return OptionalAdd(type);
464
- }
465
- /** Returns true if the given value is TOptional */
466
- function IsOptional(value) {
467
- return IsSchema(value) && HasPropertyKey(value, "~optional");
468
- }
469
- //#endregion
470
- //#region ../../node_modules/.pnpm/typebox@1.1.38/node_modules/typebox/build/type/types/array.mjs
471
- /** Creates an Array type. */
472
- function _Array_(items, options) {
473
- return Create({ "~kind": "Array" }, {
474
- type: "array",
475
- items
476
- }, options);
477
- }
478
- //#endregion
479
- //#region ../../node_modules/.pnpm/typebox@1.1.38/node_modules/typebox/build/type/types/properties.mjs
480
- /** Creates a RequiredArray derived from the given TProperties value. */
481
- function RequiredArray(properties) {
482
- return Keys(properties).filter((key) => !IsOptional(properties[key]));
483
- }
484
- //#endregion
485
- //#region ../../node_modules/.pnpm/typebox@1.1.38/node_modules/typebox/build/type/types/object.mjs
486
- /** Creates an Object type. */
487
- function _Object_(properties, options = {}) {
488
- const requiredKeys = RequiredArray(properties);
489
- return Create({ "~kind": "Object" }, {
490
- type: "object",
491
- ...requiredKeys.length > 0 ? { required: requiredKeys } : {},
492
- properties
493
- }, options);
494
- }
495
- //#endregion
496
- //#region ../../node_modules/.pnpm/typebox@1.1.38/node_modules/typebox/build/system/hashing/hash.mjs
497
- var ByteMarker;
498
- (function(ByteMarker) {
499
- ByteMarker[ByteMarker["Array"] = 0] = "Array";
500
- ByteMarker[ByteMarker["BigInt"] = 1] = "BigInt";
501
- ByteMarker[ByteMarker["Boolean"] = 2] = "Boolean";
502
- ByteMarker[ByteMarker["Date"] = 3] = "Date";
503
- ByteMarker[ByteMarker["Constructor"] = 4] = "Constructor";
504
- ByteMarker[ByteMarker["Function"] = 5] = "Function";
505
- ByteMarker[ByteMarker["Null"] = 6] = "Null";
506
- ByteMarker[ByteMarker["Number"] = 7] = "Number";
507
- ByteMarker[ByteMarker["Object"] = 8] = "Object";
508
- ByteMarker[ByteMarker["RegExp"] = 9] = "RegExp";
509
- ByteMarker[ByteMarker["String"] = 10] = "String";
510
- ByteMarker[ByteMarker["Symbol"] = 11] = "Symbol";
511
- ByteMarker[ByteMarker["TypeArray"] = 12] = "TypeArray";
512
- ByteMarker[ByteMarker["Undefined"] = 13] = "Undefined";
513
- })(ByteMarker || (ByteMarker = {}));
514
- Array.from({ length: 256 }).map((_, i) => BigInt(i));
515
- const F64 = new Float64Array(1);
516
- new DataView(F64.buffer);
517
- new Uint8Array(F64.buffer);
518
- new TextEncoder();
519
- //#endregion
520
- //#region ../../node_modules/.pnpm/typebox@1.1.38/node_modules/typebox/build/type/types/integer.mjs
521
- const IntegerPattern = "-?(?:0|[1-9][0-9]*)";
522
- /** Creates a Number type. */
523
- function Number$1(options) {
524
- return Create({ "~kind": "Number" }, { type: "number" }, options);
525
- }
526
- //#endregion
527
- //#region ../../node_modules/.pnpm/typebox@1.1.38/node_modules/typebox/build/type/types/string.mjs
528
- /** Creates a String type. */
529
- function String$1(options) {
530
- return Create({ "~kind": "String" }, { type: "string" }, options);
531
- }
532
- //#endregion
533
- //#region ../../node_modules/.pnpm/typebox@1.1.38/node_modules/typebox/build/type/types/record.mjs
534
- const IntegerKey = `^${IntegerPattern}$`;
535
- //#endregion
536
- //#region ../../node_modules/.pnpm/typebox@1.1.38/node_modules/typebox/build/type/script/token/internal/char.mjs
537
- function Range(start, end) {
538
- return Array.from({ length: end - start + 1 }, (_, i) => String.fromCharCode(start + i));
539
- }
540
- const Alpha = [...Range(97, 122), ...Range(65, 90)];
541
- const Digit = ["0", ...Range(49, 57)];
542
- [...Digit];
543
- [...[
544
- ...Alpha,
545
- "_",
546
- "$"
547
- ], ...Digit];
548
- [...Digit];
549
- new RegExp(IntegerKey);
550
- const replaceEditSchema = _Object_({
551
- oldText: String$1({ description: "Exact text to replace. Must be unique in the file and must not overlap other edits in this call." }),
552
- newText: String$1({ description: "Replacement text" })
553
- }, { additionalProperties: false });
554
- _Object_({
555
- path: String$1({ description: "Path under /workspace (e.g. session/out.txt or agent/data.json)" }),
556
- edits: _Array_(replaceEditSchema, { description: "Replacements applied against the original file (not chained). Each oldText must be unique and non-overlapping." })
557
- }, { additionalProperties: false });
558
- _Object_({
559
- path: String$1({ description: "Path under /workspace (e.g. session/out.txt or agent/data.json)" }),
560
- offset: Optional(Number$1({ description: "Line number to start reading from (1-indexed)" })),
561
- limit: Optional(Number$1({ description: "Maximum number of lines to read" }))
562
- });
563
- _Object_({
564
- path: String$1({ description: "Path under /workspace (e.g. session/out.txt or agent/data.json)" }),
565
- content: String$1({ description: "Content to write to the file" })
566
- });
567
- //#endregion
568
- //#region ../../node_modules/.pnpm/just-bash@3.0.1/node_modules/just-bash/dist/bundle/index.js
569
- createRequire(import.meta.url);
570
- var tt = [
571
- {
572
- name: "echo",
573
- load: async () => (await import("./echo-NDWZZHPO-CCp_-MxA.mjs")).echoCommand
574
- },
575
- {
576
- name: "cat",
577
- load: async () => (await import("./cat-TSFMZVYS-Dz3-oHsV.mjs")).catCommand
578
- },
579
- {
580
- name: "printf",
581
- load: async () => (await import("./printf-TWGXF445-B7cTysaa.mjs")).printfCommand
582
- },
583
- {
584
- name: "ls",
585
- load: async () => (await import("./ls-ZJGQER7M-DLDSfI4x.mjs")).lsCommand
586
- },
587
- {
588
- name: "mkdir",
589
- load: async () => (await import("./mkdir-MEPGZOB6-BjUKzhdL.mjs")).mkdirCommand
590
- },
591
- {
592
- name: "rmdir",
593
- load: async () => (await import("./rmdir-OC4ZLPYA-D3QCHlIB.mjs")).rmdirCommand
594
- },
595
- {
596
- name: "touch",
597
- load: async () => (await import("./touch-UA33VN3N-oW1SBT1r.mjs")).touchCommand
598
- },
599
- {
600
- name: "rm",
601
- load: async () => (await import("./rm-SSGETQVQ-Ch53Rmrr.mjs")).rmCommand
602
- },
603
- {
604
- name: "cp",
605
- load: async () => (await import("./cp-BISAAS7A-CMWayU4n.mjs")).cpCommand
606
- },
607
- {
608
- name: "mv",
609
- load: async () => (await import("./mv-W5BIQ646-CdSIyY-U.mjs")).mvCommand
610
- },
611
- {
612
- name: "ln",
613
- load: async () => (await import("./ln-4LGSXXGD-Dg0R9i5G.mjs")).lnCommand
614
- },
615
- {
616
- name: "chmod",
617
- load: async () => (await import("./chmod-TFEPA42X-YF02QJUv.mjs")).chmodCommand
618
- },
619
- {
620
- name: "pwd",
621
- load: async () => (await import("./pwd-WE6EN5AV-CO8o2WQS.mjs")).pwdCommand
622
- },
623
- {
624
- name: "readlink",
625
- load: async () => (await import("./readlink-OPJF4DL5-Rc1Mz_Xx.mjs")).readlinkCommand
626
- },
627
- {
628
- name: "head",
629
- load: async () => (await import("./head-442HYESI-D96RMdki.mjs")).headCommand
630
- },
631
- {
632
- name: "tail",
633
- load: async () => (await import("./tail-R4PCA2C4-CUfroNeu.mjs")).tailCommand
634
- },
635
- {
636
- name: "wc",
637
- load: async () => (await import("./wc-LF7NU4LA-BFPabrwD.mjs")).wcCommand
638
- },
639
- {
640
- name: "stat",
641
- load: async () => (await import("./stat-CD34IZ4P-B5ZOJh4J.mjs")).statCommand
642
- },
643
- {
644
- name: "grep",
645
- load: async () => (await import("./grep-V3LQVMRQ-D99Bq7Kj.mjs")).grepCommand
646
- },
647
- {
648
- name: "fgrep",
649
- load: async () => (await import("./grep-V3LQVMRQ-D99Bq7Kj.mjs")).fgrepCommand
650
- },
651
- {
652
- name: "egrep",
653
- load: async () => (await import("./grep-V3LQVMRQ-D99Bq7Kj.mjs")).egrepCommand
654
- },
655
- {
656
- name: "rg",
657
- load: async () => (await import("./rg-S4FXYXWB-BbXVo6JX.mjs")).rgCommand
658
- },
659
- {
660
- name: "sed",
661
- load: async () => (await import("./sed-S5UIK574-DE1KeTk3.mjs")).sedCommand
662
- },
663
- {
664
- name: "awk",
665
- load: async () => (await import("./awk2-LA3USKJP-BbsfXVlR.mjs")).awkCommand2
666
- },
667
- {
668
- name: "sort",
669
- load: async () => (await import("./sort-SW2YEO5B-B7j1zw8k.mjs")).sortCommand
670
- },
671
- {
672
- name: "uniq",
673
- load: async () => (await import("./uniq-XSIZR6PB-D5lt-IXF.mjs")).uniqCommand
674
- },
675
- {
676
- name: "comm",
677
- load: async () => (await import("./comm-VV2LDX2J-ppxDJFkY.mjs")).commCommand
678
- },
679
- {
680
- name: "cut",
681
- load: async () => (await import("./cut-OKARJCCV-Bt8b58eI.mjs")).cutCommand
682
- },
683
- {
684
- name: "paste",
685
- load: async () => (await import("./paste-7JC6S4DX-CtmM5Qy8.mjs")).pasteCommand
686
- },
687
- {
688
- name: "tr",
689
- load: async () => (await import("./tr-36LHWFRQ-CTq3z6wq.mjs")).trCommand
690
- },
691
- {
692
- name: "rev",
693
- load: async () => (await import("./rev-5EHFX4EJ-3dd9vwHW.mjs")).rev
694
- },
695
- {
696
- name: "nl",
697
- load: async () => (await import("./nl-WSDW7I4O-DmtCnyKU.mjs")).nl
698
- },
699
- {
700
- name: "fold",
701
- load: async () => (await import("./fold-4TQNYMSW-C54bHzLd.mjs")).fold
702
- },
703
- {
704
- name: "expand",
705
- load: async () => (await import("./expand-JSPG6VOP-B-YUvYpu.mjs")).expand
706
- },
707
- {
708
- name: "unexpand",
709
- load: async () => (await import("./unexpand-CADSA4VO-Cq9DTcUg.mjs")).unexpand
710
- },
711
- {
712
- name: "strings",
713
- load: async () => (await import("./strings-6WDHLGMX-DdiEdoL-.mjs")).strings
714
- },
715
- {
716
- name: "split",
717
- load: async () => (await import("./split-4KKZZXXE-h8GD4HP4.mjs")).split
718
- },
719
- {
720
- name: "column",
721
- load: async () => (await import("./column-XT6UFXNQ-DHENV9D2.mjs")).column
722
- },
723
- {
724
- name: "join",
725
- load: async () => (await import("./join-TBRGI3LQ-B8I9tkJ5.mjs")).join
726
- },
727
- {
728
- name: "tee",
729
- load: async () => (await import("./tee-YUZ2FKCJ-po_dfyc_.mjs")).teeCommand
730
- },
731
- {
732
- name: "find",
733
- load: async () => (await import("./find-INTH3OLC-6p47KeeT.mjs")).findCommand
734
- },
735
- {
736
- name: "basename",
737
- load: async () => (await import("./basename-UB3CIYNI-BgNN3bGm.mjs")).basenameCommand
738
- },
739
- {
740
- name: "dirname",
741
- load: async () => (await import("./dirname-MPHRFUTI-Dkb3S4OX.mjs")).dirnameCommand
742
- },
743
- {
744
- name: "tree",
745
- load: async () => (await import("./tree-YLD52CNT-CIozNsLQ.mjs")).treeCommand
746
- },
747
- {
748
- name: "du",
749
- load: async () => (await import("./du-572XNP42-ClP4jXB1.mjs")).duCommand
750
- },
751
- {
752
- name: "env",
753
- load: async () => (await import("./env-36M5BO7M-CsP_aiWr.mjs")).envCommand
754
- },
755
- {
756
- name: "printenv",
757
- load: async () => (await import("./env-36M5BO7M-CsP_aiWr.mjs")).printenvCommand
758
- },
759
- {
760
- name: "alias",
761
- load: async () => (await import("./alias-RTYYYW3D-CLFgrowj.mjs")).aliasCommand
762
- },
763
- {
764
- name: "unalias",
765
- load: async () => (await import("./alias-RTYYYW3D-CLFgrowj.mjs")).unaliasCommand
766
- },
767
- {
768
- name: "history",
769
- load: async () => (await import("./history-WYYKSLSZ-ACNQVupn.mjs")).historyCommand
770
- },
771
- {
772
- name: "xargs",
773
- load: async () => (await import("./xargs-MGZPH7AX-D2bIgrdg.mjs")).xargsCommand
774
- },
775
- {
776
- name: "true",
777
- load: async () => (await import("./true-FHQXJXBE-DsJOznSp.mjs")).trueCommand
778
- },
779
- {
780
- name: "false",
781
- load: async () => (await import("./true-FHQXJXBE-DsJOznSp.mjs")).falseCommand
782
- },
783
- {
784
- name: "clear",
785
- load: async () => (await import("./clear-HKGFEOF6-CekN2x-O.mjs")).clearCommand
786
- },
787
- {
788
- name: "bash",
789
- load: async () => (await import("./bash-YZ33HQZQ-N6YyKtUH.mjs")).bashCommand
790
- },
791
- {
792
- name: "sh",
793
- load: async () => (await import("./bash-YZ33HQZQ-N6YyKtUH.mjs")).shCommand
794
- },
795
- {
796
- name: "jq",
797
- load: async () => (await import("./jq-4XLYLOS5-wFZYfsfJ.mjs")).jqCommand
798
- },
799
- {
800
- name: "base64",
801
- load: async () => (await import("./base64-C2AIWVNC-C0WIgu5V.mjs")).base64Command
802
- },
803
- {
804
- name: "diff",
805
- load: async () => (await import("./diff-MWJFIG7X-DhnPc_5r.mjs")).diffCommand
806
- },
807
- {
808
- name: "date",
809
- load: async () => (await import("./date-UUUPW43J-B7T5OTZZ.mjs")).dateCommand
810
- },
811
- {
812
- name: "sleep",
813
- load: async () => (await import("./sleep-X22JJINO-Do5hEQQW.mjs")).sleepCommand
814
- },
815
- {
816
- name: "timeout",
817
- load: async () => (await import("./timeout-YDCRSLPQ-B_yntmXU.mjs")).timeoutCommand
818
- },
819
- {
820
- name: "time",
821
- load: async () => (await import("./time-D4LNBSWX-DVWhAldK.mjs")).timeCommand
822
- },
823
- {
824
- name: "seq",
825
- load: async () => (await import("./seq-M5EC7Q57-BHfGjQvK.mjs")).seqCommand
826
- },
827
- {
828
- name: "expr",
829
- load: async () => (await import("./expr-5JAACS4X-1TBq84gG.mjs")).exprCommand
830
- },
831
- {
832
- name: "md5sum",
833
- load: async () => (await import("./md5sum-SPU24VSG-DQc8sqXO.mjs")).md5sumCommand
834
- },
835
- {
836
- name: "sha1sum",
837
- load: async () => (await import("./sha1sum-2PTOAFR6-DNjSNcYK.mjs")).sha1sumCommand
838
- },
839
- {
840
- name: "sha256sum",
841
- load: async () => (await import("./sha256sum-NS7D3IXX-BMaCKkT5.mjs")).sha256sumCommand
842
- },
843
- {
844
- name: "file",
845
- load: async () => (await import("./file-IPZJC3FQ-DcZNOWyY.mjs")).fileCommand
846
- },
847
- {
848
- name: "html-to-markdown",
849
- load: async () => (await import("./html-to-markdown-JW4MSQZO-DQOxFIvF.mjs")).htmlToMarkdownCommand
850
- },
851
- {
852
- name: "help",
853
- load: async () => (await import("./help-HZ6M2CKN--DK8mY2L.mjs")).helpCommand
854
- },
855
- {
856
- name: "which",
857
- load: async () => (await import("./which-XEM24D5D-2LvlkpUo.mjs")).whichCommand
858
- },
859
- {
860
- name: "tac",
861
- load: async () => (await import("./tac-2STMMJYW-DPyeWM9R.mjs")).tac
862
- },
863
- {
864
- name: "hostname",
865
- load: async () => (await import("./hostname-C4HQXXUP-CXVVFkUK.mjs")).hostname
866
- },
867
- {
868
- name: "whoami",
869
- load: async () => (await import("./whoami-XMTX52VE-24Kwqrk6.mjs")).whoami
870
- },
871
- {
872
- name: "od",
873
- load: async () => (await import("./od-WOKFDJTP-DZ2nxQNJ.mjs")).od
874
- },
875
- {
876
- name: "gzip",
877
- load: async () => (await import("./gzip-O5ASJAFY-CZDRROqP.mjs")).gzipCommand
878
- },
879
- {
880
- name: "gunzip",
881
- load: async () => (await import("./gzip-O5ASJAFY-CZDRROqP.mjs")).gunzipCommand
882
- },
883
- {
884
- name: "zcat",
885
- load: async () => (await import("./gzip-O5ASJAFY-CZDRROqP.mjs")).zcatCommand
886
- }
887
- ];
888
- (typeof __BROWSER__ > "u" || !__BROWSER__) && (tt.push({
889
- name: "tar",
890
- load: async () => (await import("./tar-STHHZTZ6-DRf60e-G.mjs")).tarCommand
891
- }), tt.push({
892
- name: "yq",
893
- load: async () => (await import("./yq-4QJW3EQG-XhB3aACo.mjs")).yqCommand
894
- }), tt.push({
895
- name: "xan",
896
- load: async () => (await import("./xan-Y6WF3IRG-DjKO96Pj.mjs")).xanCommand
897
- }), tt.push({
898
- name: "sqlite3",
899
- load: async () => (await import("./sqlite3-CGOEFJAO-DvzzghDg.mjs")).sqlite3Command
900
- }));
901
- var Yt = [];
902
- (typeof __BROWSER__ > "u" || !__BROWSER__) && (Yt.push({
903
- name: "python3",
904
- load: async () => (await import("./python3-POMOR4OA-CKy80mpF.mjs")).python3Command
905
- }), Yt.push({
906
- name: "python",
907
- load: async () => (await import("./python3-POMOR4OA-CKy80mpF.mjs")).pythonCommand
908
- }));
909
- var Qt = [];
910
- (typeof __BROWSER__ > "u" || !__BROWSER__) && (Qt.push({
911
- name: "js-exec",
912
- load: async () => (await import("./js-exec-N5KEZBH7-CgtG-I6s.mjs")).jsExecCommand
913
- }), Qt.push({
914
- name: "node",
915
- load: async () => (await import("./js-exec-N5KEZBH7-CgtG-I6s.mjs")).nodeStubCommand
916
- }));
917
- new TextEncoder();
918
- Object.freeze({
919
- stdout: "",
920
- stderr: "",
921
- exitCode: 0
922
- });
923
- [...new Map([
924
- [":", [": [arguments]", `Null command.
925
- No effect; the command does nothing.
926
- Exit Status:
927
- Always succeeds.`]],
928
- [".", [". filename [arguments]", `Execute commands from a file in the current shell.
929
- Read and execute commands from FILENAME in the current shell.
930
- The entries in $PATH are used to find the directory containing FILENAME.
931
- Exit Status:
932
- Returns the status of the last command executed in FILENAME.`]],
933
- ["[", ["[ arg... ]", `Evaluate conditional expression.
934
- This is a synonym for the "test" builtin, but the last argument must
935
- be a literal \`]', to match the opening \`['.`]],
936
- ["alias", ["alias [-p] [name[=value] ... ]", `Define or display aliases.
937
- Without arguments, \`alias' prints the list of aliases in the reusable
938
- form \`alias NAME=VALUE' on standard output.
939
- Exit Status:
940
- alias returns true unless a NAME is supplied for which no alias has been
941
- defined.`]],
942
- ["bg", ["bg [job_spec ...]", `Move jobs to the background.
943
- Place the jobs identified by each JOB_SPEC in the background, as if they
944
- had been started with \`&'.`]],
945
- ["break", ["break [n]", `Exit for, while, or until loops.
946
- Exit a FOR, WHILE or UNTIL loop. If N is specified, break N enclosing
947
- loops.
948
- Exit Status:
949
- The exit status is 0 unless N is not greater than or equal to 1.`]],
950
- ["builtin", ["builtin [shell-builtin [arg ...]]", `Execute shell builtins.
951
- Execute SHELL-BUILTIN with arguments ARGs without performing command
952
- lookup. This is useful when you wish to reimplement a shell builtin
953
- as a shell function, but need to execute the builtin within the function.
954
- Exit Status:
955
- Returns the exit status of SHELL-BUILTIN, or false if SHELL-BUILTIN is
956
- not a shell builtin.`]],
957
- ["caller", ["caller [expr]", `Return the context of the current subroutine call.
958
- Without EXPR, returns "$line $filename". With EXPR, returns
959
- "$line $subroutine $filename"; this extra information can be used to
960
- provide a stack trace.
961
- Exit Status:
962
- Returns 0 unless the shell is not executing a subroutine call or
963
- EXPR is invalid.`]],
964
- ["cd", ["cd [-L|-P] [dir]", `Change the shell working directory.
965
- Change the current directory to DIR. The default DIR is the value of the
966
- HOME shell variable.
967
-
968
- The variable CDPATH defines the search path for the directory containing
969
- DIR. Alternative directory names in CDPATH are separated by a colon (:).
970
- A null directory name is the same as the current directory. If DIR begins
971
- with a slash (/), then CDPATH is not used.
972
-
973
- If the directory is not found, and the shell option \`cdable_vars' is set,
974
- the word is assumed to be a variable name. If that variable has a value,
975
- its value is used for DIR.
976
-
977
- Options:
978
- -L force symbolic links to be followed
979
- -P use the physical directory structure without following symbolic
980
- links
981
-
982
- The default is to follow symbolic links, as if \`-L' were specified.
983
-
984
- Exit Status:
985
- Returns 0 if the directory is changed; non-zero otherwise.`]],
986
- ["command", ["command [-pVv] command [arg ...]", `Execute a simple command or display information about commands.
987
- Runs COMMAND with ARGS suppressing shell function lookup, or display
988
- information about the specified COMMANDs.
989
-
990
- Options:
991
- -p use a default value for PATH that is guaranteed to find all of
992
- the standard utilities
993
- -v print a description of COMMAND similar to the \`type' builtin
994
- -V print a more verbose description of each COMMAND
995
-
996
- Exit Status:
997
- Returns exit status of COMMAND, or failure if COMMAND is not found.`]],
998
- ["compgen", ["compgen [-abcdefgjksuv] [-o option] [-A action] [-G globpat] [-W wordlist] [-F function] [-C command] [-X filterpat] [-P prefix] [-S suffix] [word]", `Display possible completions depending on the options.
999
- Intended to be used from within a shell function generating possible
1000
- completions. If the optional WORD argument is supplied, matches against
1001
- WORD are generated.
1002
- Exit Status:
1003
- Returns success unless an invalid option is supplied or an error occurs.`]],
1004
- ["complete", ["complete [-abcdefgjksuv] [-pr] [-DEI] [-o option] [-A action] [-G globpat] [-W wordlist] [-F function] [-C command] [-X filterpat] [-P prefix] [-S suffix] [name ...]", `Specify how arguments are to be completed.
1005
- For each NAME, specify how arguments are to be completed.
1006
- Exit Status:
1007
- Returns success unless an invalid option is supplied or an error occurs.`]],
1008
- ["continue", ["continue [n]", `Resume for, while, or until loops.
1009
- Resumes the next iteration of the enclosing FOR, WHILE or UNTIL loop.
1010
- If N is specified, resumes the Nth enclosing loop.
1011
- Exit Status:
1012
- The exit status is 0 unless N is not greater than or equal to 1.`]],
1013
- ["declare", ["declare [-aAfFgilnrtux] [-p] [name[=value] ...]", `Set variable values and attributes.
1014
- Declare variables and give them attributes. If no NAMEs are given,
1015
- display the attributes and values of all variables.
1016
-
1017
- Options:
1018
- -a to make NAMEs indexed arrays (if supported)
1019
- -A to make NAMEs associative arrays (if supported)
1020
- -i to make NAMEs have the \`integer' attribute
1021
- -l to convert the value of each NAME to lower case on assignment
1022
- -n make NAME a reference to the variable named by its value
1023
- -r to make NAMEs readonly
1024
- -t to make NAMEs have the \`trace' attribute
1025
- -u to convert the value of each NAME to upper case on assignment
1026
- -x to make NAMEs export
1027
-
1028
- Exit Status:
1029
- Returns success unless an invalid option is supplied or a variable
1030
- assignment error occurs.`]],
1031
- ["dirs", ["dirs [-clpv] [+N] [-N]", `Display directory stack.
1032
- Display the list of currently remembered directories. Directories
1033
- find their way onto the list with the \`pushd' command; you can get
1034
- back up through the list with the \`popd' command.
1035
- Exit Status:
1036
- Returns success unless an invalid option is supplied or an error occurs.`]],
1037
- ["disown", ["disown [-h] [-ar] [jobspec ...]", `Remove jobs from current shell.
1038
- Without any JOBSPECs, remove the current job.`]],
1039
- ["echo", ["echo [-neE] [arg ...]", `Write arguments to the standard output.
1040
- Display the ARGs, separated by a single space character and followed by a
1041
- newline, on the standard output.
1042
-
1043
- Options:
1044
- -n do not append a newline
1045
- -e enable interpretation of the following backslash escapes
1046
- -E explicitly suppress interpretation of backslash escapes
1047
-
1048
- Exit Status:
1049
- Returns success unless a write error occurs.`]],
1050
- ["enable", ["enable [-a] [-dnps] [-f filename] [name ...]", `Enable and disable shell builtins.
1051
- Enables and disables builtin shell commands.
1052
- Exit Status:
1053
- Returns success unless NAME is not a shell builtin or an error occurs.`]],
1054
- ["eval", ["eval [arg ...]", `Execute arguments as a shell command.
1055
- Combine ARGs into a single string, use the result as input to the shell,
1056
- and execute the resulting commands.
1057
- Exit Status:
1058
- Returns exit status of command or success if command is null.`]],
1059
- ["exec", ["exec [-cl] [-a name] [command [arguments ...]] [redirection ...]", `Replace the shell with the given command.
1060
- Execute COMMAND, replacing this shell with the specified program.
1061
- ARGUMENTS become the arguments to COMMAND. If COMMAND is not specified,
1062
- any redirections take effect in the current shell.
1063
- Exit Status:
1064
- Returns success unless COMMAND is not found or a redirection error occurs.`]],
1065
- ["exit", ["exit [n]", `Exit the shell.
1066
- Exits the shell with a status of N. If N is omitted, the exit status
1067
- is that of the last command executed.`]],
1068
- ["export", ["export [-fn] [name[=value] ...] or export -p", `Set export attribute for shell variables.
1069
- Marks each NAME for automatic export to the environment of subsequently
1070
- executed commands. If VALUE is supplied, assign VALUE before exporting.
1071
-
1072
- Options:
1073
- -f refer to shell functions
1074
- -n remove the export property from each NAME
1075
- -p display a list of all exported variables and functions
1076
-
1077
- Exit Status:
1078
- Returns success unless an invalid option is given or NAME is invalid.`]],
1079
- ["false", ["false", `Return an unsuccessful result.
1080
- Exit Status:
1081
- Always fails.`]],
1082
- ["fc", ["fc [-e ename] [-lnr] [first] [last] or fc -s [pat=rep] [command]", `Display or execute commands from the history list.
1083
- Exit Status:
1084
- Returns success or status of executed command.`]],
1085
- ["fg", ["fg [job_spec]", `Move job to the foreground.
1086
- Place the job identified by JOB_SPEC in the foreground, making it the
1087
- current job.`]],
1088
- ["getopts", ["getopts optstring name [arg]", `Parse option arguments.
1089
- Getopts is used by shell procedures to parse positional parameters
1090
- as options.
1091
-
1092
- OPTSTRING contains the option letters to be recognized; if a letter
1093
- is followed by a colon, the option is expected to have an argument,
1094
- which should be separated from it by white space.
1095
- Exit Status:
1096
- Returns success if an option is found; fails if the end of options is
1097
- encountered or an error occurs.`]],
1098
- ["hash", ["hash [-lr] [-p pathname] [-dt] [name ...]", `Remember or display program locations.
1099
- Determine and remember the full pathname of each command NAME.
1100
- Exit Status:
1101
- Returns success unless NAME is not found or an invalid option is given.`]],
1102
- ["help", ["help [-s] [pattern ...]", `Display information about builtin commands.
1103
- Displays brief summaries of builtin commands. If PATTERN is
1104
- specified, gives detailed help on all commands matching PATTERN,
1105
- otherwise the list of help topics is printed.
1106
-
1107
- Options:
1108
- -s output only a short usage synopsis for each topic matching
1109
- PATTERN
1110
-
1111
- Exit Status:
1112
- Returns success unless PATTERN is not found.`]],
1113
- ["history", ["history [-c] [-d offset] [n] or history -anrw [filename] or history -ps arg [arg...]", `Display or manipulate the history list.
1114
- Display the history list with line numbers, prefixing each modified
1115
- entry with a \`*'.
1116
- Exit Status:
1117
- Returns success unless an invalid option is given or an error occurs.`]],
1118
- ["jobs", ["jobs [-lnprs] [jobspec ...] or jobs -x command [args]", `Display status of jobs.
1119
- Lists the active jobs.
1120
- Exit Status:
1121
- Returns success unless an invalid option is given or an error occurs.`]],
1122
- ["kill", ["kill [-s sigspec | -n signum | -sigspec] pid | jobspec ... or kill -l [sigspec]", `Send a signal to a job.
1123
- Send the processes identified by PID or JOBSPEC the signal named by
1124
- SIGSPEC or SIGNUM.
1125
- Exit Status:
1126
- Returns success unless an invalid option is given or an error occurs.`]],
1127
- ["let", ["let arg [arg ...]", `Evaluate arithmetic expressions.
1128
- Evaluate each ARG as an arithmetic expression. Evaluation is done in
1129
- fixed-width integers with no check for overflow, though division by 0
1130
- is trapped and flagged as an error.
1131
- Exit Status:
1132
- If the last ARG evaluates to 0, let returns 1; 0 is returned otherwise.`]],
1133
- ["local", ["local [option] name[=value] ...", `Define local variables.
1134
- Create a local variable called NAME, and give it VALUE. OPTION can
1135
- be any option accepted by \`declare'.
1136
-
1137
- Local can only be used within a function; it makes the variable NAME
1138
- have a visible scope restricted to that function and its children.
1139
- Exit Status:
1140
- Returns success unless an invalid option is supplied, a variable
1141
- assignment error occurs, or the shell is not executing a function.`]],
1142
- ["logout", ["logout [n]", `Exit a login shell.
1143
- Exits a login shell with exit status N. Returns an error if not executed
1144
- in a login shell.`]],
1145
- ["mapfile", ["mapfile [-d delim] [-n count] [-O origin] [-s count] [-t] [-u fd] [-C callback] [-c quantum] [array]", `Read lines from the standard input into an indexed array variable.
1146
- Read lines from the standard input into the indexed array variable ARRAY,
1147
- or from file descriptor FD if the -u option is supplied.
1148
-
1149
- Options:
1150
- -d delim Use DELIM to terminate lines, instead of newline
1151
- -n count Copy at most COUNT lines
1152
- -O origin Begin assigning to ARRAY at index ORIGIN
1153
- -s count Discard the first COUNT lines read
1154
- -t Remove a trailing DELIM from each line read (default newline)
1155
- -u fd Read lines from file descriptor FD instead of standard input
1156
-
1157
- Exit Status:
1158
- Returns success unless an invalid option is given or ARRAY is readonly.`]],
1159
- ["popd", ["popd [-n] [+N | -N]", `Remove directories from stack.
1160
- Removes entries from the directory stack.
1161
- Exit Status:
1162
- Returns success unless an invalid argument is supplied or the directory
1163
- change fails.`]],
1164
- ["printf", ["printf [-v var] format [arguments]", `Formats and prints ARGUMENTS under control of the FORMAT.
1165
-
1166
- Options:
1167
- -v var assign the output to shell variable VAR rather than
1168
- display it on the standard output
1169
-
1170
- FORMAT is a character string which contains three types of objects: plain
1171
- characters, which are simply copied to standard output; character escape
1172
- sequences, which are converted and copied to the standard output; and
1173
- format specifications, each of which causes printing of the next successive
1174
- argument.
1175
- Exit Status:
1176
- Returns success unless an invalid option is given or a write or assignment
1177
- error occurs.`]],
1178
- ["pushd", ["pushd [-n] [+N | -N | dir]", `Add directories to stack.
1179
- Adds a directory to the top of the directory stack, or rotates
1180
- the stack, making the new top of the stack the current working
1181
- directory.
1182
- Exit Status:
1183
- Returns success unless an invalid argument is supplied or the directory
1184
- change fails.`]],
1185
- ["pwd", ["pwd [-LP]", `Print the name of the current working directory.
1186
-
1187
- Options:
1188
- -L print the value of $PWD if it names the current working
1189
- directory
1190
- -P print the physical directory, without any symbolic links
1191
-
1192
- By default, \`pwd' behaves as if \`-L' were specified.
1193
- Exit Status:
1194
- Returns 0 unless an invalid option is given or the current directory
1195
- cannot be read.`]],
1196
- ["read", ["read [-ers] [-a array] [-d delim] [-i text] [-n nchars] [-N nchars] [-p prompt] [-t timeout] [-u fd] [name ...]", `Read a line from the standard input and split it into fields.
1197
- Reads a single line from the standard input, or from file descriptor FD
1198
- if the -u option is supplied. The line is split into fields as with word
1199
- splitting, and the first word is assigned to the first NAME, the second
1200
- word to the second NAME, and so on, with any leftover words assigned to
1201
- the last NAME.
1202
- Exit Status:
1203
- The return code is zero, unless end-of-file is encountered, read times out,
1204
- or an invalid file descriptor is supplied as the argument to -u.`]],
1205
- ["readarray", ["readarray [-d delim] [-n count] [-O origin] [-s count] [-t] [-u fd] [-C callback] [-c quantum] [array]", "Read lines from a file into an array variable.\n A synonym for `mapfile'."]],
1206
- ["readonly", ["readonly [-aAf] [name[=value] ...] or readonly -p", `Mark shell variables as unchangeable.
1207
- Mark each NAME as read-only; the values of these NAMEs may not be
1208
- changed by subsequent assignment.
1209
- Exit Status:
1210
- Returns success unless an invalid option is given or NAME is invalid.`]],
1211
- ["return", ["return [n]", `Return from a shell function.
1212
- Causes a function or sourced script to exit with the return value
1213
- specified by N. If N is omitted, the return status is that of the
1214
- last command executed within the function or script.
1215
- Exit Status:
1216
- Returns N, or failure if the shell is not executing a function or script.`]],
1217
- ["set", ["set [-abefhkmnptuvxBCHP] [-o option-name] [--] [arg ...]", `Set or unset values of shell options and positional parameters.
1218
- Change the value of shell attributes and positional parameters, or
1219
- display the names and values of shell variables.
1220
-
1221
- Options:
1222
- -e Exit immediately if a command exits with a non-zero status.
1223
- -u Treat unset variables as an error when substituting.
1224
- -x Print commands and their arguments as they are executed.
1225
- -o option-name
1226
- Set the variable corresponding to option-name
1227
-
1228
- Exit Status:
1229
- Returns success unless an invalid option is given.`]],
1230
- ["shift", ["shift [n]", `Shift positional parameters.
1231
- Rename the positional parameters $N+1,$N+2 ... to $1,$2 ... If N is
1232
- not given, it is assumed to be 1.
1233
- Exit Status:
1234
- Returns success unless N is negative or greater than $#.`]],
1235
- ["shopt", ["shopt [-pqsu] [-o] [optname ...]", `Set and unset shell options.
1236
- Change the setting of each shell option OPTNAME. Without any option
1237
- arguments, list each supplied OPTNAME, or all shell options if no
1238
- OPTNAMEs are given, with an indication of whether or not each is set.
1239
-
1240
- Options:
1241
- -o restrict OPTNAMEs to those defined for use with \`set -o'
1242
- -p print each shell option with an indication of its status
1243
- -q suppress output
1244
- -s enable (set) each OPTNAME
1245
- -u disable (unset) each OPTNAME
1246
-
1247
- Exit Status:
1248
- Returns success if OPTNAME is enabled; fails if an invalid option is
1249
- given or OPTNAME is disabled.`]],
1250
- ["source", ["source filename [arguments]", `Execute commands from a file in the current shell.
1251
- Read and execute commands from FILENAME in the current shell.
1252
- The entries in $PATH are used to find the directory containing FILENAME.
1253
- Exit Status:
1254
- Returns the status of the last command executed in FILENAME.`]],
1255
- ["suspend", ["suspend [-f]", `Suspend shell execution.
1256
- Suspend the execution of this shell until it receives a SIGCONT signal.`]],
1257
- ["test", ["test [expr]", `Evaluate conditional expression.
1258
- Exits with a status of 0 (true) or 1 (false) depending on
1259
- the evaluation of EXPR. Expressions may be unary or binary.
1260
- Exit Status:
1261
- Returns success if EXPR evaluates to true; fails if EXPR evaluates to
1262
- false or an invalid argument is given.`]],
1263
- ["times", ["times", `Display process times.
1264
- Prints the accumulated user and system times for the shell and all of its
1265
- child processes.
1266
- Exit Status:
1267
- Always succeeds.`]],
1268
- ["trap", ["trap [-lp] [[arg] signal_spec ...]", `Trap signals and other events.
1269
- Defines and activates handlers to be run when the shell receives signals
1270
- or other conditions.
1271
- Exit Status:
1272
- Returns success unless a SIGSPEC is invalid or an invalid option is given.`]],
1273
- ["true", ["true", `Return a successful result.
1274
- Exit Status:
1275
- Always succeeds.`]],
1276
- ["type", ["type [-afptP] name [name ...]", `Display information about command type.
1277
- For each NAME, indicate how it would be interpreted if used as a
1278
- command name.
1279
-
1280
- Options:
1281
- -a display all locations containing an executable named NAME
1282
- -f suppress shell function lookup
1283
- -P force a PATH search for each NAME, even if it is an alias,
1284
- builtin, or function, and returns the name of the disk file
1285
- that would be executed
1286
- -p returns either the name of the disk file that would be executed,
1287
- or nothing if \`type -t NAME' would not return \`file'
1288
- -t output a single word which is one of \`alias', \`keyword',
1289
- \`function', \`builtin', \`file' or \`', if NAME is an alias,
1290
- shell reserved word, shell function, shell builtin, disk file,
1291
- or not found, respectively
1292
-
1293
- Exit Status:
1294
- Returns success if all of the NAMEs are found; fails if any are not found.`]],
1295
- ["typeset", ["typeset [-aAfFgilnrtux] [-p] name[=value] ...", "Set variable values and attributes.\n A synonym for `declare'."]],
1296
- ["ulimit", ["ulimit [-SHabcdefiklmnpqrstuvxPT] [limit]", `Modify shell resource limits.
1297
- Provides control over the resources available to the shell and processes
1298
- it creates, on systems that allow such control.
1299
- Exit Status:
1300
- Returns success unless an invalid option is supplied or an error occurs.`]],
1301
- ["umask", ["umask [-p] [-S] [mode]", `Display or set file mode mask.
1302
- Sets the user file-creation mask to MODE. If MODE is omitted, prints
1303
- the current value of the mask.
1304
- Exit Status:
1305
- Returns success unless MODE is invalid or an invalid option is given.`]],
1306
- ["unalias", ["unalias [-a] name [name ...]", `Remove each NAME from the list of defined aliases.
1307
- Exit Status:
1308
- Returns success unless a NAME is not an existing alias.`]],
1309
- ["unset", ["unset [-f] [-v] [-n] [name ...]", `Unset values and attributes of shell variables and functions.
1310
- For each NAME, remove the corresponding variable or function.
1311
-
1312
- Options:
1313
- -f treat each NAME as a shell function
1314
- -v treat each NAME as a shell variable
1315
- -n treat each NAME as a name reference and unset the variable itself
1316
- rather than the variable it references
1317
-
1318
- Without options, unset first tries to unset a variable, and if that fails,
1319
- tries to unset a function.
1320
- Exit Status:
1321
- Returns success unless an invalid option is given or a NAME is read-only.`]],
1322
- ["wait", ["wait [-fn] [id ...]", `Wait for job completion and return exit status.
1323
- Waits for each process identified by an ID, which may be a process ID or a
1324
- job specification, and reports its termination status.
1325
- Exit Status:
1326
- Returns the status of the last ID; fails if ID is invalid or an invalid
1327
- option is given.`]]
1328
- ]).keys()].sort();
1329
- new TextDecoder("utf-8", { fatal: !0 });
1330
- //#endregion
1331
- //#region ../../packages/manifest/dist/index.mjs
1332
- function isManifestAgent(value) {
1333
- if (typeof value !== "object" || value === null) return false;
1334
- const agent = value;
1335
- return typeof agent.slug === "string" && agent.slug.trim().length > 0 && typeof agent.buildRuntime === "function" && typeof agent.model === "string" && typeof agent.systemPrompt === "string";
1336
- }
1337
- function validateManifestAgent(value, filePath) {
1338
- if (!isManifestAgent(value)) throw new Error(`${filePath} must default-export defineAgent(...)`);
1339
- return value;
1340
- }
1341
- function normalizeWebhookEndpoint(endpoint) {
1342
- return endpoint.replace(/^\/+|\/+$/g, "").replace(/^triggers\/?/, "");
1343
- }
1344
- function agentRouteFromKey(key) {
1345
- return `/agents/${key}`;
1346
- }
1347
- function workflowRouteFromKey(key) {
1348
- return `/workflows/${key}`;
1349
- }
1350
- function webhookRouteFromEndpoint(endpoint) {
1351
- const normalized = normalizeWebhookEndpoint(endpoint);
1352
- if (!normalized) throw new Error("Webhook endpoint must not be empty");
1353
- return `/triggers/${normalized}`;
1354
- }
1355
- async function discoverAgentEntries(agentsDir, options) {
1356
- const files = await discoverModuleFileEntries(agentsDir, {
1357
- nestedEntry: "agent",
1358
- duplicateLabel: "agent module file"
1359
- });
1360
- const entries = [];
1361
- for (const { filePath, moduleFile } of files) {
1362
- const agent = await importAgentDefinition(filePath, options);
1363
- entries.push({
1364
- key: agent.slug,
1365
- route: agentRouteFromKey(agent.slug),
1366
- filePath,
1367
- moduleFile
1368
- });
1369
- }
1370
- return entries;
1371
- }
1372
- async function importAgentDefinition(filePath, options) {
1373
- const appRoot = resolveAppRoot(filePath);
1374
- const href = pathToFileURL(filePath).href;
1375
- return runWithAppRoot(appRoot, async () => {
1376
- return validateManifestAgent((await (options?.reload ? import(`${href}?keystroke=${Date.now()}`) : import(href))).default, filePath);
1377
- });
1378
- }
1379
- const ACTION = Symbol.for("keystroke.action");
1380
- function isManifestAction(value) {
1381
- if (typeof value !== "object" || value === null) return false;
1382
- return ACTION in value && value[ACTION] === true;
1383
- }
1384
- function getManifestActionCredentialRequirements(action) {
1385
- return Array.isArray(action.credentials) ? action.credentials : void 0;
1386
- }
1387
- function actionSlug(tool) {
1388
- const record = tool;
1389
- return typeof record.slug === "string" ? record.slug : void 0;
1390
- }
1391
- /** App-kind slugs required by the agent's tools (same as `credential_instances.app_slug`). */
1392
- function collectAgentAppSlugs(agent) {
1393
- const slugs = /* @__PURE__ */ new Set();
1394
- for (const tool of agent.tools ?? []) {
1395
- const record = tool;
1396
- const requirements = isManifestAction(tool) ? getManifestActionCredentialRequirements(tool) : "credentials" in record && Array.isArray(record.credentials) ? record.credentials : void 0;
1397
- if (!requirements?.length) continue;
1398
- for (const requirement of normalizeCredentialList(requirements)) slugs.add(requirement.key);
1399
- }
1400
- return [...slugs].sort();
1401
- }
1402
- function collectAgentToolSlugs(agent) {
1403
- const slugs = [];
1404
- for (const tool of agent.tools ?? []) {
1405
- const slug = actionSlug(tool);
1406
- if (slug) slugs.push(slug);
1407
- }
1408
- return slugs;
1409
- }
1410
- function countAgentCredentials(agent) {
1411
- return collectAgentAppSlugs(agent).length;
1412
- }
1413
- /** Single source of truth for the `kind: "agent"` route-manifest entry shape. */
1414
- function agentManifestEntry(agent, options) {
1415
- return {
1416
- kind: "agent",
1417
- slug: agent.slug,
1418
- moduleFile: options.moduleFile,
1419
- name: agent.name,
1420
- description: agent.description,
1421
- model: agent.model,
1422
- systemPrompt: agent.systemPrompt,
1423
- toolCount: agent.tools?.length ?? 0,
1424
- credentialCount: countAgentCredentials(agent),
1425
- appSlugs: collectAgentAppSlugs(agent),
1426
- toolSlugs: collectAgentToolSlugs(agent)
1427
- };
1428
- }
1429
- const SKIP_DIRS = new Set([".git", "node_modules"]);
1430
- function toPosix$1(path) {
1431
- return path.split(sep).join("/");
1432
- }
1433
- function parseSkillFrontmatter(raw) {
1434
- const match = raw.match(/^---\s*\n([\s\S]*?)\n---/);
1435
- if (!match) return {};
1436
- const out = {};
1437
- for (const line of match[1]?.split("\n") ?? []) {
1438
- const trimmed = line.trim();
1439
- if (!trimmed || trimmed.startsWith("#")) continue;
1440
- const colon = trimmed.indexOf(":");
1441
- if (colon < 0) continue;
1442
- const key = trimmed.slice(0, colon).trim();
1443
- let value = trimmed.slice(colon + 1).trim();
1444
- if (value.startsWith("\"") && value.endsWith("\"") || value.startsWith("'") && value.endsWith("'")) value = value.slice(1, -1);
1445
- if (key === "name") out.name = value;
1446
- else if (key === "description") out.description = value;
1447
- }
1448
- return out;
1449
- }
1450
- function walkSkillFiles(root, dir, out) {
1451
- for (const name of readdirSync(dir).sort()) {
1452
- const absolute = join(dir, name);
1453
- const stats = statSync(absolute);
1454
- if (stats.isDirectory()) {
1455
- if (SKIP_DIRS.has(name)) continue;
1456
- walkSkillFiles(root, absolute, out);
1457
- continue;
1458
- }
1459
- if (!stats.isFile() || name !== "SKILL.md") continue;
1460
- const moduleFile = toPosix$1(relative(root, absolute));
1461
- const slug = toPosix$1(relative(join(root, "src", "skills"), absolute)).replace(/\/?SKILL\.md$/, "");
1462
- if (!slug) continue;
1463
- const frontmatter = parseSkillFrontmatter(readFileSync(absolute, "utf8"));
1464
- out.push({
1465
- slug,
1466
- name: frontmatter.name,
1467
- description: frontmatter.description,
1468
- moduleFile
1469
- });
1470
- }
1471
- }
1472
- /** Discover skill metadata from src/skills SKILL.md files for the route manifest. */
1473
- function discoverSkillManifestEntries(projectRoot) {
1474
- const skillsDir = join(projectRoot, "src", "skills");
1475
- if (!statSync(skillsDir, { throwIfNoEntry: false })?.isDirectory()) return [];
1476
- const entries = [];
1477
- walkSkillFiles(projectRoot, skillsDir, entries);
1478
- return entries;
1479
- }
1480
- function schemaToJson(schema) {
1481
- return toJSONSchema(schema, { target: "openapi-3.0" });
1482
- }
1483
- function collectIntegrationKeys(integrations) {
1484
- return integrations.map((integration) => integration.key);
1485
- }
1486
- function serializeRouteManifest(manifest) {
1487
- const entries = [];
1488
- for (const entry of manifest) switch (entry.kind) {
1489
- case "health":
1490
- entries.push(entry);
1491
- break;
1492
- case "agent":
1493
- entries.push({
1494
- kind: entry.kind,
1495
- slug: entry.slug,
1496
- moduleFile: entry.moduleFile,
1497
- name: entry.name,
1498
- description: entry.description,
1499
- model: entry.model,
1500
- systemPrompt: entry.systemPrompt,
1501
- toolCount: entry.toolCount,
1502
- credentialCount: entry.credentialCount,
1503
- appSlugs: entry.appSlugs,
1504
- toolSlugs: entry.toolSlugs
1505
- });
1506
- break;
1507
- case "workflow":
1508
- entries.push({
1509
- kind: entry.kind,
1510
- slug: entry.slug,
1511
- name: entry.name,
1512
- description: entry.description,
1513
- subscribable: entry.subscribable,
1514
- moduleFile: entry.moduleFile,
1515
- requestSchema: schemaToJson(entry.request)
1516
- });
1517
- break;
1518
- case "trigger-webhook":
1519
- entries.push({
1520
- kind: entry.kind,
1521
- endpoint: entry.endpoint,
1522
- attachmentIds: entry.attachmentIds,
1523
- moduleFile: entry.moduleFile,
1524
- attachmentSchemas: Object.fromEntries(Object.entries(entry.attachmentSchemas).map(([attachmentKey, schemas]) => [attachmentKey, {
1525
- requestSchema: schemaToJson(schemas.request),
1526
- ...schemas.filter ? { filterSchema: schemaToJson(schemas.filter) } : {}
1527
- }]))
1528
- });
1529
- break;
1530
- case "trigger-poll":
1531
- entries.push({
1532
- kind: entry.kind,
1533
- attachmentId: entry.attachmentId,
1534
- moduleFile: entry.moduleFile,
1535
- schedule: entry.schedule
1536
- });
1537
- break;
1538
- case "trigger-poll-group":
1539
- entries.push({
1540
- kind: entry.kind,
1541
- pollId: entry.pollId,
1542
- attachmentIds: entry.attachmentIds,
1543
- moduleFile: entry.moduleFile,
1544
- schedule: entry.schedule
1545
- });
1546
- break;
1547
- case "cron-schedule":
1548
- entries.push(entry);
1549
- break;
1550
- default: break;
1551
- }
1552
- return entries;
1553
- }
1554
- function toStoredRouteManifest(manifest, options) {
1555
- return {
1556
- version: 2,
1557
- entries: serializeRouteManifest(manifest),
1558
- skills: options?.skills ?? [],
1559
- integrations: options?.integrations
1560
- };
1561
- }
1562
- function buildStoredRouteManifestFromContext(ctx) {
1563
- const integrations = ctx.options?.integrations ?? ctx.options?.plugins?.map((plugin) => ({
1564
- key: plugin.name,
1565
- mount: plugin.register
1566
- })) ?? [];
1567
- return toStoredRouteManifest(ctx.manifest, {
1568
- integrations: collectIntegrationKeys(integrations),
1569
- skills: ctx.skills ?? (ctx.projectRoot ? discoverSkillManifestEntries(ctx.projectRoot) : void 0) ?? []
1570
- });
1571
- }
1572
- function persistStoredRouteManifest(projectRoot, manifest) {
1573
- const path = join(projectRoot, ROUTE_MANIFEST_REL_PATH);
1574
- mkdirSync(dirname(path), { recursive: true });
1575
- writeFileSync(path, `${JSON.stringify(manifest, null, 2)}\n`);
1576
- }
1577
- const WORKFLOW = Symbol.for("keystroke.workflow");
1578
- function isManifestWorkflow(value) {
1579
- if (typeof value !== "object" || value === null) return false;
1580
- if (!(WORKFLOW in value) || value[WORKFLOW] !== true) return false;
1581
- const workflow = value;
1582
- return typeof workflow.slug === "string" && workflow.slug.trim().length > 0 && workflow.input instanceof Object && "safeParse" in workflow.input && workflow.output instanceof Object && "safeParse" in workflow.output;
1583
- }
1584
- function validateManifestWorkflow(value, filePath) {
1585
- if (!isManifestWorkflow(value)) throw new Error(`${filePath} must default-export defineWorkflow(...)`);
1586
- return value;
1587
- }
1588
- const TRIGGER_ATTACHMENT = Symbol.for("keystroke.triggerAttachment");
1589
- const zodSchema = custom((value) => value instanceof ZodType, "must be a Zod schema");
1590
- const cronScheduleSchema = string().trim().min(1, "cron schedule must be a non-empty string");
1591
- const workflowSchema = custom((value) => isManifestWorkflow(value), "must be defineWorkflow(...)");
1592
- const agentSchema = custom((value) => typeof value === "object" && value !== null && typeof value.slug === "string" && value.slug.trim().length > 0 && typeof value.prompt === "function", "must be defineAgent(...)");
1593
- const promptSchema = union([string(), _function()]);
1594
- const baseSourceShape = {
1595
- key: string().trim().min(1),
1596
- attach: _function()
1597
- };
1598
- const triggerSourceSchema = discriminatedUnion("kind", [
1599
- object({
1600
- kind: literal("webhook"),
1601
- ...baseSourceShape,
1602
- endpoint: string().min(1),
1603
- request: zodSchema,
1604
- filter: zodSchema.optional(),
1605
- passes: _function()
1606
- }),
1607
- object({
1608
- kind: literal("cron"),
1609
- ...baseSourceShape,
1610
- schedule: cronScheduleSchema
1611
- }),
1612
- object({
1613
- kind: literal("poll"),
1614
- ...baseSourceShape,
1615
- id: string().optional(),
1616
- schedule: cronScheduleSchema,
1617
- run: _function(),
1618
- filters: array(_function()),
1619
- passes: _function()
1620
- })
1621
- ]);
1622
- const triggerAttachmentCoreSchema = discriminatedUnion("target", [object({
1623
- key: string().trim().min(1),
1624
- source: triggerSourceSchema,
1625
- target: literal("workflow"),
1626
- workflow: workflowSchema,
1627
- transform: _function().optional()
1628
- }), object({
1629
- key: string().trim().min(1),
1630
- source: triggerSourceSchema,
1631
- target: literal("agent"),
1632
- agent: agentSchema,
1633
- prompt: promptSchema
1634
- })]);
1635
- function isManifestTriggerAttachment(value) {
1636
- if (typeof value !== "object" || value === null) return false;
1637
- if (!(TRIGGER_ATTACHMENT in value) || value[TRIGGER_ATTACHMENT] !== true) return false;
1638
- return triggerAttachmentCoreSchema.safeParse(value).success;
1639
- }
1640
- function validateManifestTriggerAttachment(value, filePath) {
1641
- if (!isManifestTriggerAttachment(value)) throw new Error(`${filePath} must default-export a trigger attachment from .attach({ workflow }) or .attach({ agent, prompt })`);
1642
- return value;
1643
- }
1644
- function shouldDiscoverTriggerFile(triggersDir, filePath) {
1645
- return !relative(triggersDir, filePath).split(sep).includes("sources");
1646
- }
1647
- async function discoverTriggerAttachments(triggersDir, options) {
1648
- const files = await discoverModuleFileEntries(triggersDir, {
1649
- nestedEntry: "trigger",
1650
- duplicateLabel: "trigger module file",
1651
- shouldDiscoverFile: (filePath) => shouldDiscoverTriggerFile(triggersDir, filePath)
1652
- });
1653
- const attachments = [];
1654
- for (const { filePath, moduleFile } of files) {
1655
- const attachment = await importTriggerAttachment(filePath, options);
1656
- attachments.push({
1657
- key: attachment.key,
1658
- filePath,
1659
- moduleFile,
1660
- attachment
1661
- });
1662
- }
1663
- return attachments;
1664
- }
1665
- function validateImportedTriggerAttachment(def, filePath) {
1666
- return validateManifestTriggerAttachment(def, filePath);
1667
- }
1668
- async function importTriggerAttachment(filePath, options) {
1669
- const href = pathToFileURL(filePath).href;
1670
- return validateImportedTriggerAttachment((await (options?.reload ? import(`${href}?keystroke=${Date.now()}`) : import(href))).default, filePath);
1671
- }
1672
- function pollGroupId(discovered) {
1673
- const source = discovered.attachment.source;
1674
- if (source.kind !== "poll") throw new Error(`Attachment "${discovered.key}" is not a poll trigger`);
1675
- return source.id ?? source.key;
1676
- }
1677
- function buildPollGroups(attachments) {
1678
- const byId = /* @__PURE__ */ new Map();
1679
- for (const discovered of attachments) {
1680
- if (discovered.attachment.source.kind !== "poll") continue;
1681
- const id = pollGroupId(discovered);
1682
- const group = byId.get(id) ?? [];
1683
- group.push(discovered);
1684
- byId.set(id, group);
1685
- }
1686
- return [...byId.entries()].map(([id, groupAttachments]) => ({
1687
- id,
1688
- attachments: groupAttachments
1689
- }));
1690
- }
1691
- function buildWebhookBindingsByRoute(attachments, handlerOptionsFor) {
1692
- const webhookBindingsByRoute = /* @__PURE__ */ new Map();
1693
- for (const discovered of attachments) {
1694
- const source = discovered.attachment.source;
1695
- if (source.kind !== "webhook") continue;
1696
- const route = webhookRouteFromEndpoint(source.endpoint);
1697
- const bindings = webhookBindingsByRoute.get(route) ?? [];
1698
- bindings.push({
1699
- discovered,
1700
- options: handlerOptionsFor(discovered.key)
1701
- });
1702
- webhookBindingsByRoute.set(route, bindings);
1703
- }
1704
- return webhookBindingsByRoute;
1705
- }
1706
- function webhookSchemaEntriesFromBindings(bindings) {
1707
- return bindings.flatMap((binding) => {
1708
- const source = binding.discovered.attachment.source;
1709
- if (source.kind !== "webhook") return [];
1710
- return [{
1711
- attachmentKey: binding.discovered.key,
1712
- request: source.request,
1713
- ...source.filter ? { filter: source.filter } : {}
1714
- }];
1715
- });
1716
- }
1717
- function webhookMatchSchemaForBindings(bindings) {
1718
- const schemas = bindings.flatMap((binding) => {
1719
- const source = binding.discovered.attachment.source;
1720
- return source.kind === "webhook" ? [source.request] : [];
1721
- });
1722
- if (schemas.length === 0) throw new Error("Webhook bindings require at least one webhook source");
1723
- if (schemas.length === 1) return schemas[0];
1724
- return union(schemas);
1725
- }
1726
- function webhookManifestAttachmentSchemasFromBindings(bindings) {
1727
- return Object.fromEntries(webhookSchemaEntriesFromBindings(bindings).map((entry) => [entry.attachmentKey, {
1728
- request: entry.request,
1729
- ...entry.filter ? { filter: entry.filter } : {}
1730
- }]));
1731
- }
1732
- async function discoverWorkflowEntries(workflowsDir, options) {
1733
- const files = await discoverModuleFileEntries(workflowsDir, {
1734
- nestedEntry: "workflow",
1735
- duplicateLabel: "workflow module file"
1736
- });
1737
- const entries = [];
1738
- for (const { filePath, moduleFile } of files) {
1739
- const definition = await importWorkflowDefinition(filePath, options);
1740
- entries.push({
1741
- key: definition.slug,
1742
- route: workflowRouteFromKey(definition.slug),
1743
- filePath,
1744
- moduleFile
1745
- });
1746
- }
1747
- return entries;
1748
- }
1749
- function validateImportedWorkflowDefinition(def, filePath) {
1750
- return validateManifestWorkflow(def, filePath);
1751
- }
1752
- async function importWorkflowDefinition(filePath, options) {
1753
- const href = pathToFileURL(filePath).href;
1754
- return validateImportedWorkflowDefinition((await (options?.reload ? import(`${href}?keystroke=${Date.now()}`) : import(href))).default, filePath);
1755
- }
1756
- async function discoverWorkflows(workflowsDir, options) {
1757
- const entries = await discoverWorkflowEntries(workflowsDir, options);
1758
- const workflows = [];
1759
- for (const entry of entries) {
1760
- const definition = await importWorkflowDefinition(entry.filePath, options);
1761
- workflows.push({
1762
- key: definition.slug,
1763
- route: workflowRouteFromKey(definition.slug),
1764
- filePath: entry.filePath,
1765
- definition
1766
- });
1767
- }
1768
- return workflows;
1769
- }
1770
- function resolveDistModuleDirs(projectRoot) {
1771
- const distBase = join(projectRoot, "dist");
1772
- if (!existsSync(distBase)) throw new Error(`Build output missing at ${distBase}. Run keystroke build before emitting the route manifest.`);
1773
- return {
1774
- agentsDir: join(distBase, "agents"),
1775
- workflowsDir: join(distBase, "workflows"),
1776
- triggersDir: join(distBase, "triggers")
1777
- };
1778
- }
1779
- function toPosix(path) {
1780
- return path.split(sep).join("/");
1781
- }
1782
- /**
1783
- * Resolve manifest moduleFile values to project-root-relative source paths.
1784
- *
1785
- * Discovery runs over compiled `dist/` modules, so the raw moduleFile is a
1786
- * dist-relative `.mjs` path. Dist entries are named by their source entry id
1787
- * (`team/escalation.mjs` ← `src/agents/team/escalation/agent.ts`), so walking
1788
- * the matching source dir by the same id rules recovers the source path. Falls
1789
- * back to the dist-relative value when no source file matches (e.g. building
1790
- * a dist-only artifact with no `src/`).
1791
- */
1792
- var SourceModuleFileResolver = class {
1793
- projectRoot;
1794
- mapsByKind = /* @__PURE__ */ new Map();
1795
- constructor(projectRoot) {
1796
- this.projectRoot = projectRoot;
1797
- }
1798
- async sourceMapFor(kindDir, nestedEntry) {
1799
- const existing = this.mapsByKind.get(kindDir);
1800
- if (existing) return existing;
1801
- const map = /* @__PURE__ */ new Map();
1802
- const sourceDir = join(this.projectRoot, "src", kindDir);
1803
- for (const filePath of await walkTypeScriptFiles(sourceDir)) {
1804
- const id = entryIdFromFile(sourceDir, filePath, { nestedEntry });
1805
- if (id) map.set(id, toPosix(relative(this.projectRoot, filePath)));
1806
- }
1807
- this.mapsByKind.set(kindDir, map);
1808
- return map;
1809
- }
1810
- async resolve(kindDir, nestedEntry, distDir, distFilePath) {
1811
- const fallback = toPosix(relative(distDir, distFilePath));
1812
- const id = entryIdFromFile(distDir, distFilePath, { nestedEntry });
1813
- if (!id) return fallback;
1814
- return (await this.sourceMapFor(kindDir, nestedEntry)).get(id) ?? fallback;
1815
- }
1816
- };
1817
- /** Build a stored route manifest from compiled dist/ modules without starting a server. */
1818
- async function buildStoredRouteManifestForProject(projectRoot, options) {
1819
- const previousRoot = process.env.KEYSTROKE_ROOT;
1820
- process.env.KEYSTROKE_ROOT = projectRoot;
1821
- const reload = options?.reloadModules ? { reload: true } : void 0;
1822
- try {
1823
- const dirs = resolveDistModuleDirs(projectRoot);
1824
- const sourcePaths = new SourceModuleFileResolver(projectRoot);
1825
- const manifest = [{ kind: "health" }];
1826
- const agentEntries = await discoverAgentEntries(dirs.agentsDir, reload);
1827
- for (const entry of agentEntries) {
1828
- const agent = await importAgentDefinition(entry.filePath, reload);
1829
- const moduleFile = await sourcePaths.resolve("agents", "agent", dirs.agentsDir, entry.filePath);
1830
- manifest.push(agentManifestEntry(agent, { moduleFile }));
1831
- }
1832
- const workflows = await discoverWorkflows(dirs.workflowsDir, reload);
1833
- for (const workflow of workflows) {
1834
- const moduleFile = await sourcePaths.resolve("workflows", "workflow", dirs.workflowsDir, workflow.filePath);
1835
- manifest.push({
1836
- kind: "workflow",
1837
- slug: workflow.definition.slug,
1838
- name: workflow.definition.name,
1839
- description: workflow.definition.description,
1840
- subscribable: workflow.definition.subscription?.mode === "subscribable",
1841
- moduleFile,
1842
- request: workflow.definition.input
1843
- });
1844
- }
1845
- const attachments = await discoverTriggerAttachments(dirs.triggersDir, reload);
1846
- const discoveredByKey = new Map(attachments.map((attachment) => [attachment.key, attachment]));
1847
- const pollGroups = buildPollGroups(attachments);
1848
- for (const discovered of discoveredByKey.values()) {
1849
- const source = discovered.attachment.source;
1850
- const moduleFile = await sourcePaths.resolve("triggers", "trigger", dirs.triggersDir, discovered.filePath);
1851
- if (source.kind === "cron") {
1852
- manifest.push({
1853
- kind: "cron-schedule",
1854
- attachmentId: discovered.key,
1855
- moduleFile,
1856
- schedule: source.schedule
1857
- });
1858
- continue;
1859
- }
1860
- if (source.kind === "poll") {
1861
- manifest.push({
1862
- kind: "trigger-poll",
1863
- attachmentId: discovered.key,
1864
- moduleFile,
1865
- schedule: source.schedule,
1866
- response: PromptResponseSchema
1867
- });
1868
- continue;
1869
- }
1870
- if (source.kind === "webhook") {
1871
- const route = webhookRouteFromEndpoint(source.endpoint);
1872
- const bindings = buildWebhookBindingsByRoute(discoveredByKey.values(), () => ({
1873
- execution: { attachmentKey: discovered.key },
1874
- attachmentKey: discovered.key
1875
- })).get(route) ?? [{
1876
- discovered,
1877
- options: { attachmentKey: discovered.key }
1878
- }];
1879
- manifest.push({
1880
- kind: "trigger-webhook",
1881
- endpoint: source.endpoint,
1882
- attachmentIds: bindings.map(({ discovered: row }) => row.key),
1883
- moduleFile,
1884
- request: webhookMatchSchemaForBindings(bindings),
1885
- attachmentSchemas: webhookManifestAttachmentSchemasFromBindings(bindings),
1886
- response: PromptResponseSchema
1887
- });
1888
- }
1889
- }
1890
- for (const group of pollGroups) {
1891
- if (group.attachments.length <= 1) continue;
1892
- const first = group.attachments[0];
1893
- const source = first.attachment.source;
1894
- manifest.push({
1895
- kind: "trigger-poll-group",
1896
- pollId: group.id,
1897
- attachmentIds: group.attachments.map((attachment) => attachment.key),
1898
- moduleFile: await sourcePaths.resolve("triggers", "trigger", dirs.triggersDir, first.filePath),
1899
- schedule: source.kind === "poll" ? source.schedule : "",
1900
- response: PromptResponseSchema
1901
- });
1902
- }
1903
- return buildStoredRouteManifestFromContext({
1904
- manifest,
1905
- options: {},
1906
- projectRoot,
1907
- skills: discoverSkillManifestEntries(projectRoot)
1908
- });
1909
- } finally {
1910
- if (previousRoot === void 0) delete process.env.KEYSTROKE_ROOT;
1911
- else process.env.KEYSTROKE_ROOT = previousRoot;
1912
- }
1913
- }
1914
- /** Write `dist/.keystroke/route-manifest.json` for the project. */
1915
- async function emitStoredRouteManifestForProject(projectRoot) {
1916
- persistStoredRouteManifest(projectRoot, await buildStoredRouteManifestForProject(projectRoot));
1917
- }
1918
- //#endregion
1919
- export { packAssetDirs as A, toStoredRouteManifest as C, webhookMatchSchemaForBindings as D, webhookManifestAttachmentSchemasFromBindings as E, shouldSkipKeystrokeModuleFile as F, walkTypeScriptFiles as I, discoverModuleFileEntries as M, entryIdFromFile as N, webhookRouteFromEndpoint as O, readKeystrokeIgnoreDirective as P, serializeRouteManifest as S, validateImportedWorkflowDefinition as T, importTriggerAttachment as _, buildStoredRouteManifestFromContext as a, pollGroupId as b, collectAgentToolSlugs as c, discoverSkillManifestEntries as d, discoverTriggerAttachments as f, importAgentDefinition as g, emitStoredRouteManifestForProject as h, buildStoredRouteManifestForProject as i, discoverEntries as j, workflowRouteFromKey as k, countAgentCredentials as l, discoverWorkflows as m, agentRouteFromKey as n, buildWebhookBindingsByRoute as o, discoverWorkflowEntries as p, buildPollGroups as r, collectAgentAppSlugs as s, agentManifestEntry as t, discoverAgentEntries as u, importWorkflowDefinition as v, validateImportedTriggerAttachment as w, schemaToJson as x, persistStoredRouteManifest as y };
1920
-
1921
- //# sourceMappingURL=dist-CuGYI4rV.mjs.map