@catamorphic/fastify-plugin 0.1.0-alpha.42 → 0.1.0-alpha.44
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/dist/index.js +81 -21
- package/dist/index.js.map +5 -5
- package/dist/routes/client-runners.d.ts.map +1 -1
- package/dist/routes/git-gateway.d.ts +1 -1
- package/dist/routes/git-gateway.d.ts.map +1 -1
- package/dist/schemas.d.ts +488 -5
- package/dist/schemas.d.ts.map +1 -1
- package/package.json +12 -12
- package/src/routes/client-runners.ts +2 -1
- package/src/routes/git-gateway.ts +79 -17
- package/src/schemas.ts +56 -5
package/dist/index.js
CHANGED
|
@@ -454,8 +454,11 @@ var PublishedRevisionSchema = z.object({
|
|
|
454
454
|
"superseded",
|
|
455
455
|
"failed"
|
|
456
456
|
]),
|
|
457
|
-
|
|
458
|
-
|
|
457
|
+
deployEventId: z.string().uuid().nullable(),
|
|
458
|
+
deployRuns: z.array(z.object({
|
|
459
|
+
workflowName: z.string(),
|
|
460
|
+
runId: z.string().uuid().nullable()
|
|
461
|
+
})),
|
|
459
462
|
previousCommitSha: z.string().nullable(),
|
|
460
463
|
error: z.string().nullable(),
|
|
461
464
|
report: z.array(z.object({
|
|
@@ -755,7 +758,8 @@ var CacheFillSchema = z.object({
|
|
|
755
758
|
cache: z.string(),
|
|
756
759
|
machine: z.string().nullable(),
|
|
757
760
|
status: z.enum(["queued", "running", "succeeded", "failed", "evicted"]),
|
|
758
|
-
reason: z.enum(["requested", "first-use"]),
|
|
761
|
+
reason: z.enum(["requested", "first-use", "prepare"]),
|
|
762
|
+
restored: z.boolean(),
|
|
759
763
|
commit: z.string().nullable(),
|
|
760
764
|
generation: z.number().nullable(),
|
|
761
765
|
attempts: z.number(),
|
|
@@ -1422,6 +1426,21 @@ var AgentTurnUsageSchema = describes()(z.object({
|
|
|
1422
1426
|
contextTokens: z.number().optional(),
|
|
1423
1427
|
contextWindow: z.number().optional()
|
|
1424
1428
|
}));
|
|
1429
|
+
var TurnEndingSchema = describes()(z.discriminatedUnion("cause", [
|
|
1430
|
+
z.object({
|
|
1431
|
+
cause: z.literal("stopped"),
|
|
1432
|
+
by: z.string(),
|
|
1433
|
+
through: z.enum(["agent", "message", "closing"]).optional(),
|
|
1434
|
+
sessionId: z.string().optional()
|
|
1435
|
+
}),
|
|
1436
|
+
z.object({ cause: z.literal("host_stopped") }),
|
|
1437
|
+
z.object({
|
|
1438
|
+
cause: z.literal("process_ended"),
|
|
1439
|
+
exitCode: z.number().int().optional(),
|
|
1440
|
+
signal: z.string().optional()
|
|
1441
|
+
}),
|
|
1442
|
+
z.object({ cause: z.literal("machine_lost") })
|
|
1443
|
+
]));
|
|
1425
1444
|
var TurnOutcomeSchema = describes()(z.object({
|
|
1426
1445
|
changedFiles: z.array(z.object({ path: z.string(), kind: z.enum(["modified", "deleted"]) })),
|
|
1427
1446
|
usage: AgentTurnUsageSchema.optional(),
|
|
@@ -1456,6 +1475,7 @@ var TurnSchema = describes()(z.object({
|
|
|
1456
1475
|
providerThreadId: z.string().nullable(),
|
|
1457
1476
|
retryAt: z.string().nullable(),
|
|
1458
1477
|
cancellationRequested: z.boolean(),
|
|
1478
|
+
ending: TurnEndingSchema.nullable().describe("Why the turn ended without completing, or who asked a running turn to stop: stopped (by someone), host_stopped, process_ended or machine_lost. Only stopped is somebody's stop."),
|
|
1459
1479
|
error: TurnErrorSchema.nullable(),
|
|
1460
1480
|
outcome: TurnOutcomeSchema.nullable(),
|
|
1461
1481
|
checkpoint: z.object({
|
|
@@ -1493,6 +1513,7 @@ var AttemptSchema = describes()(z.object({
|
|
|
1493
1513
|
providerThreadId: z.string().nullable(),
|
|
1494
1514
|
nativeTurnRef: NativeRefSchema.nullable(),
|
|
1495
1515
|
error: TurnErrorSchema.nullable(),
|
|
1516
|
+
ending: TurnEndingSchema.nullable(),
|
|
1496
1517
|
createdAt: z.string(),
|
|
1497
1518
|
startedAt: z.string().nullable(),
|
|
1498
1519
|
completedAt: z.string().nullable()
|
|
@@ -1853,7 +1874,12 @@ var TurnAttemptsSchema = z.object({
|
|
|
1853
1874
|
completedAt: z.string().nullable(),
|
|
1854
1875
|
progressAt: z.string().nullable(),
|
|
1855
1876
|
stalledAt: z.string().nullable(),
|
|
1856
|
-
diagnostics: z.object({ runner: z.string(), harness: z.string() }).nullable()
|
|
1877
|
+
diagnostics: z.object({ runner: z.string(), harness: z.string() }).nullable(),
|
|
1878
|
+
phases: z.array(z.object({
|
|
1879
|
+
phase: z.string(),
|
|
1880
|
+
startedAt: z.string(),
|
|
1881
|
+
endedAt: z.string().nullable()
|
|
1882
|
+
}))
|
|
1857
1883
|
}))
|
|
1858
1884
|
});
|
|
1859
1885
|
var TurnIdParamsSchema = z.object({
|
|
@@ -4851,6 +4877,7 @@ function registerClientRunnerRoutes(app, ctx) {
|
|
|
4851
4877
|
"network.setup",
|
|
4852
4878
|
"volumes",
|
|
4853
4879
|
"caches",
|
|
4880
|
+
"caches.archive",
|
|
4854
4881
|
"commands.separate"
|
|
4855
4882
|
])).optional(),
|
|
4856
4883
|
publicKey: ExecutorPublicKeySchema.optional()
|
|
@@ -6231,6 +6258,9 @@ function registerEnvironmentRoutes(app, ctx) {
|
|
|
6231
6258
|
|
|
6232
6259
|
// src/routes/git-gateway.ts
|
|
6233
6260
|
import { Readable } from "node:stream";
|
|
6261
|
+
import {
|
|
6262
|
+
checkoutTarget
|
|
6263
|
+
} from "@catamorphic/core";
|
|
6234
6264
|
function registerGitGatewayRoutes(app, ctx) {
|
|
6235
6265
|
app.register(async (git) => {
|
|
6236
6266
|
git.removeAllContentTypeParsers();
|
|
@@ -6241,7 +6271,43 @@ function registerGitGatewayRoutes(app, ctx) {
|
|
|
6241
6271
|
};
|
|
6242
6272
|
git.get("/gateway/git/:alias/*", options, (request, reply) => serve(ctx, request, reply, "GET"));
|
|
6243
6273
|
git.post("/gateway/git/:alias/*", options, (request, reply) => serve(ctx, request, reply, "POST"));
|
|
6274
|
+
git.get("/gateway/checkout/*", options, (request, reply) => serveCheckout(ctx, request, reply, "GET"));
|
|
6275
|
+
git.post("/gateway/checkout/*", options, (request, reply) => serveCheckout(ctx, request, reply, "POST"));
|
|
6276
|
+
});
|
|
6277
|
+
}
|
|
6278
|
+
async function serveCheckout(ctx, request, reply, method) {
|
|
6279
|
+
const checkouts = ctx.core?.workspaceCheckouts;
|
|
6280
|
+
if (!checkouts)
|
|
6281
|
+
return reply.status(404).type("text/plain").send(`This host serves no checkouts
|
|
6282
|
+
`);
|
|
6283
|
+
const params = request.params;
|
|
6284
|
+
const query = request.query;
|
|
6285
|
+
const target = checkoutTarget({
|
|
6286
|
+
method,
|
|
6287
|
+
path: params["*"] ?? "",
|
|
6288
|
+
service: query.service
|
|
6244
6289
|
});
|
|
6290
|
+
if (!target)
|
|
6291
|
+
return reply.status(404).type("text/plain").send(`Not a Git request
|
|
6292
|
+
`);
|
|
6293
|
+
const headers = {};
|
|
6294
|
+
for (const [name, value] of Object.entries(request.headers))
|
|
6295
|
+
headers[name] = Array.isArray(value) ? value.join(", ") : value;
|
|
6296
|
+
return send(reply, method, await checkouts.handle({
|
|
6297
|
+
id: target.id,
|
|
6298
|
+
operation: target.operation,
|
|
6299
|
+
authorization: headers.authorization,
|
|
6300
|
+
headers,
|
|
6301
|
+
...method === "POST" ? { body: request.raw } : {}
|
|
6302
|
+
}));
|
|
6303
|
+
}
|
|
6304
|
+
function send(reply, method, response) {
|
|
6305
|
+
reply.status(response.status);
|
|
6306
|
+
for (const [name, value] of Object.entries(response.headers))
|
|
6307
|
+
reply.header(name, value);
|
|
6308
|
+
if (method === "POST" && response.status >= 400)
|
|
6309
|
+
reply.header("connection", "close");
|
|
6310
|
+
return reply.send(response.body instanceof Uint8Array ? Buffer.from(response.body) : Readable.from(response.body));
|
|
6245
6311
|
}
|
|
6246
6312
|
async function serve(ctx, request, reply, method) {
|
|
6247
6313
|
const gateway = ctx.core?.gitGateway;
|
|
@@ -6259,20 +6325,14 @@ async function serve(ctx, request, reply, method) {
|
|
|
6259
6325
|
const headers = {};
|
|
6260
6326
|
for (const [name, value] of Object.entries(request.headers))
|
|
6261
6327
|
headers[name] = Array.isArray(value) ? value.join(", ") : value;
|
|
6262
|
-
|
|
6328
|
+
return send(reply, method, await gateway.handle({
|
|
6263
6329
|
alias,
|
|
6264
6330
|
repositoryPath: target.repositoryPath,
|
|
6265
6331
|
operation: target.operation,
|
|
6266
6332
|
authorization: headers.authorization,
|
|
6267
6333
|
headers,
|
|
6268
6334
|
...method === "POST" ? { body: request.raw } : {}
|
|
6269
|
-
});
|
|
6270
|
-
reply.status(response.status);
|
|
6271
|
-
for (const [name, value] of Object.entries(response.headers))
|
|
6272
|
-
reply.header(name, value);
|
|
6273
|
-
if (method === "POST" && response.status >= 400)
|
|
6274
|
-
reply.header("connection", "close");
|
|
6275
|
-
return reply.send(response.body instanceof Uint8Array ? Buffer.from(response.body) : Readable.from(response.body));
|
|
6335
|
+
}));
|
|
6276
6336
|
}
|
|
6277
6337
|
function gitTarget(input) {
|
|
6278
6338
|
const path = input.path.replace(/\/+$/, "");
|
|
@@ -6338,7 +6398,7 @@ function routeTarget(request) {
|
|
|
6338
6398
|
...query ? { query } : {}
|
|
6339
6399
|
};
|
|
6340
6400
|
}
|
|
6341
|
-
function
|
|
6401
|
+
function send2(reply, response) {
|
|
6342
6402
|
reply.status(response.status);
|
|
6343
6403
|
for (const [name, value] of Object.entries(response.headers))
|
|
6344
6404
|
reply.header(name, value);
|
|
@@ -6356,7 +6416,7 @@ async function admit(ctx, request, reply) {
|
|
|
6356
6416
|
if ("admitted" in result)
|
|
6357
6417
|
return;
|
|
6358
6418
|
reply.header("connection", "close");
|
|
6359
|
-
return
|
|
6419
|
+
return send2(reply, result.refused);
|
|
6360
6420
|
}
|
|
6361
6421
|
async function serve2(ctx, request, reply) {
|
|
6362
6422
|
const gateway = ctx.core?.httpGateway;
|
|
@@ -6370,7 +6430,7 @@ async function serve2(ctx, request, reply) {
|
|
|
6370
6430
|
body: new Uint8Array(request.body.buffer, request.body.byteOffset, request.body.byteLength)
|
|
6371
6431
|
} : {}
|
|
6372
6432
|
});
|
|
6373
|
-
return
|
|
6433
|
+
return send2(reply, response);
|
|
6374
6434
|
}
|
|
6375
6435
|
|
|
6376
6436
|
// src/routes/me.ts
|
|
@@ -6630,7 +6690,7 @@ function routeTarget2(request) {
|
|
|
6630
6690
|
...query ? { query } : {}
|
|
6631
6691
|
};
|
|
6632
6692
|
}
|
|
6633
|
-
function
|
|
6693
|
+
function send3(reply, response) {
|
|
6634
6694
|
reply.status(response.status);
|
|
6635
6695
|
for (const [name, value] of Object.entries(response.headers))
|
|
6636
6696
|
reply.header(name, value);
|
|
@@ -6649,7 +6709,7 @@ async function admit2(ctx, request, reply) {
|
|
|
6649
6709
|
if ("admitted" in result)
|
|
6650
6710
|
return;
|
|
6651
6711
|
reply.header("connection", "close");
|
|
6652
|
-
return
|
|
6712
|
+
return send3(reply, result.refused);
|
|
6653
6713
|
}
|
|
6654
6714
|
async function serve3(ctx, request, reply) {
|
|
6655
6715
|
const gateway = ctx.core?.modelGateway;
|
|
@@ -6663,7 +6723,7 @@ async function serve3(ctx, request, reply) {
|
|
|
6663
6723
|
body: new Uint8Array(request.body.buffer, request.body.byteOffset, request.body.byteLength)
|
|
6664
6724
|
} : {}
|
|
6665
6725
|
});
|
|
6666
|
-
return
|
|
6726
|
+
return send3(reply, response);
|
|
6667
6727
|
}
|
|
6668
6728
|
|
|
6669
6729
|
// src/routes/notifications.ts
|
|
@@ -11405,7 +11465,7 @@ async function serve4(ctx, request, reply) {
|
|
|
11405
11465
|
} : {}
|
|
11406
11466
|
});
|
|
11407
11467
|
reply.removeHeader(PREVIEW_REFUSAL_HEADER);
|
|
11408
|
-
return
|
|
11468
|
+
return send4({ reply, response, prefix: target.prefix, port });
|
|
11409
11469
|
} catch (error) {
|
|
11410
11470
|
if (error instanceof SessionPreviewError)
|
|
11411
11471
|
return reply.status(error.reason === "invalid" ? 400 : 502).send({ error: error.message, code: error.reason });
|
|
@@ -11455,7 +11515,7 @@ function requestHeaderPairs(request) {
|
|
|
11455
11515
|
}
|
|
11456
11516
|
return pairs;
|
|
11457
11517
|
}
|
|
11458
|
-
function
|
|
11518
|
+
function send4(input) {
|
|
11459
11519
|
const { reply, response } = input;
|
|
11460
11520
|
reply.status(response.status);
|
|
11461
11521
|
const grouped = new Map;
|
|
@@ -12398,5 +12458,5 @@ export {
|
|
|
12398
12458
|
serveSpaDist
|
|
12399
12459
|
};
|
|
12400
12460
|
|
|
12401
|
-
//# debugId=
|
|
12461
|
+
//# debugId=00789418A69F295964756E2164756E21
|
|
12402
12462
|
//# sourceMappingURL=index.js.map
|