@app-vitals/agent-admin 1.106.2 → 1.107.1
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/e2e/real/admin-access.real.e2e.ts +88 -0
- package/e2e/real/agents-real.real.e2e.ts +116 -0
- package/e2e/real/constants.ts +73 -0
- package/e2e/real/fixture.ts +120 -0
- package/e2e/real/harness.ts +191 -0
- package/e2e/real/member-access-self-serve.real.e2e.ts +114 -0
- package/e2e/real/member-agents.real.e2e.ts +267 -0
- package/e2e/real/member-chat.real.e2e.ts +153 -0
- package/e2e/real/owner-access.real.e2e.ts +237 -0
- package/e2e/real/seed.ts +105 -0
- package/e2e/real/session.ts +29 -0
- package/openapi.json +0 -280
- package/openapi.platform.json +0 -280
- package/package.json +2 -2
- package/playwright.config.ts +11 -0
- package/prisma/client/browser.ts +0 -10
- package/prisma/client/client.ts +0 -10
- package/prisma/client/internal/class.ts +4 -24
- package/prisma/client/internal/prismaNamespace.ts +1 -181
- package/prisma/client/internal/prismaNamespaceBrowser.ts +0 -30
- package/prisma/client/models.ts +0 -2
- package/prisma/migrations/20261129000000_drop_cron_run_transcripts/migration.sql +9 -0
- package/prisma/schema/schema.prisma +0 -34
- package/src/admin-boot.ts +0 -11
- package/src/admin-ui.ts +2 -1
- package/src/agents-api.ts +0 -13
- package/src/api.smoke.test.ts +6 -73
- package/src/api.ts +0 -17
- package/src/cron-run-now.integration.test.ts +163 -0
- package/src/cron-run-transcripts-removed.smoke.test.ts +82 -0
- package/src/drop-cron-run-transcripts-migration.integration.test.ts +114 -0
- package/src/openapi-schemas.ts +0 -55
- package/src/repo-access-config.ts +1 -1
- package/src/secrets-equal.ts +8 -0
- package/src/secrets-equal.unit.test.ts +15 -0
- package/prisma/client/models/AgentCronRunTranscript.ts +0 -1339
- package/prisma/client/models/AgentTranscriptRead.ts +0 -1177
- package/src/cron-run-transcripts.integration.test.ts +0 -220
- package/src/cron-run-transcripts.smoke.test.ts +0 -286
- package/src/cron-run-transcripts.ts +0 -314
- package/src/transcript-config.ts +0 -30
- package/src/transcript-config.unit.test.ts +0 -50
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* admin/src/cron-run-now.integration.test.ts
|
|
3
|
+
* CronRunNowService against a real Postgres (COS-42.1): cron lookup scoping
|
|
4
|
+
* and the atomic stamp + audit-row write, including expiry of a superseded
|
|
5
|
+
* pending request.
|
|
6
|
+
*
|
|
7
|
+
* Requires DATABASE_URL_ADMIN_TEST to be set; skips otherwise.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import { afterEach, beforeEach, describe, expect, it } from "bun:test";
|
|
11
|
+
import type { PrismaClient } from "../prisma/client/client.ts";
|
|
12
|
+
import { CronRunNowService } from "./cron-run-now.ts";
|
|
13
|
+
import { createAdminPrismaClient } from "./prisma-client.ts";
|
|
14
|
+
|
|
15
|
+
const TEST_DB = process.env.DATABASE_URL_ADMIN_TEST;
|
|
16
|
+
const describeOrSkip = TEST_DB ? describe : describe.skip;
|
|
17
|
+
|
|
18
|
+
describeOrSkip("CronRunNowService (integration)", () => {
|
|
19
|
+
let prisma: PrismaClient;
|
|
20
|
+
let service: CronRunNowService;
|
|
21
|
+
let agentId: string;
|
|
22
|
+
let otherAgentId: string;
|
|
23
|
+
let cronId: string;
|
|
24
|
+
|
|
25
|
+
beforeEach(async () => {
|
|
26
|
+
prisma = createAdminPrismaClient(TEST_DB as string);
|
|
27
|
+
service = new CronRunNowService(prisma);
|
|
28
|
+
agentId = (await prisma.agent.create({ data: { name: "RunNowA" } })).id;
|
|
29
|
+
otherAgentId = (await prisma.agent.create({ data: { name: "RunNowB" } }))
|
|
30
|
+
.id;
|
|
31
|
+
cronId = (
|
|
32
|
+
await prisma.agentCronJob.create({
|
|
33
|
+
data: { agentId, name: "c", schedule: "* * * * *", prompt: "p" },
|
|
34
|
+
})
|
|
35
|
+
).id;
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
afterEach(async () => {
|
|
39
|
+
await prisma.agentCronRunRequest.deleteMany({
|
|
40
|
+
where: { agentId: { in: [agentId, otherAgentId] } },
|
|
41
|
+
});
|
|
42
|
+
await prisma.agent.deleteMany({
|
|
43
|
+
where: { id: { in: [agentId, otherAgentId] } },
|
|
44
|
+
});
|
|
45
|
+
await prisma.$disconnect();
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
describe("findCron", () => {
|
|
49
|
+
it("returns the cron's id, agent and lockdown state — never the prompt", async () => {
|
|
50
|
+
const cron = await service.findCron(agentId, cronId);
|
|
51
|
+
expect(cron).toEqual({ id: cronId, agentId, lockdownDisabledAt: null });
|
|
52
|
+
expect(cron).not.toHaveProperty("prompt");
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
it("surfaces lockdownDisabledAt when the lockdown disabled the cron", async () => {
|
|
56
|
+
const at = new Date("2026-01-02T03:04:05.000Z");
|
|
57
|
+
await prisma.agentCronJob.update({
|
|
58
|
+
where: { id: cronId },
|
|
59
|
+
data: { lockdownDisabledAt: at },
|
|
60
|
+
});
|
|
61
|
+
const cron = await service.findCron(agentId, cronId);
|
|
62
|
+
expect(cron?.lockdownDisabledAt?.toISOString()).toBe(at.toISOString());
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
it("returns null for another agent's cron", async () => {
|
|
66
|
+
expect(await service.findCron(otherAgentId, cronId)).toBeNull();
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
it("returns null for an unknown cron id", async () => {
|
|
70
|
+
expect(await service.findCron(agentId, "no-such-cron")).toBeNull();
|
|
71
|
+
});
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
describe("recordRequest", () => {
|
|
75
|
+
it("stamps the cron and writes a requested audit row", async () => {
|
|
76
|
+
const requestedAt = new Date("2026-03-04T05:06:07.000Z");
|
|
77
|
+
const row = await service.recordRequest({
|
|
78
|
+
cronId,
|
|
79
|
+
agentId,
|
|
80
|
+
requestedBy: "root",
|
|
81
|
+
requestedAt,
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
expect(row).toMatchObject({
|
|
85
|
+
cronId,
|
|
86
|
+
agentId,
|
|
87
|
+
requestedBy: "root",
|
|
88
|
+
status: "requested",
|
|
89
|
+
honouredRunId: null,
|
|
90
|
+
});
|
|
91
|
+
expect(row.requestedAt.toISOString()).toBe(requestedAt.toISOString());
|
|
92
|
+
|
|
93
|
+
const job = await prisma.agentCronJob.findUniqueOrThrow({
|
|
94
|
+
where: { id: cronId },
|
|
95
|
+
});
|
|
96
|
+
expect(job.runRequestedAt?.toISOString()).toBe(requestedAt.toISOString());
|
|
97
|
+
expect(job.runRequestedBy).toBe("root");
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
it("expires a still-pending request when a newer one overwrites the stamp", async () => {
|
|
101
|
+
const first = await service.recordRequest({
|
|
102
|
+
cronId,
|
|
103
|
+
agentId,
|
|
104
|
+
requestedBy: "root",
|
|
105
|
+
requestedAt: new Date("2026-03-04T05:00:00.000Z"),
|
|
106
|
+
});
|
|
107
|
+
const second = await service.recordRequest({
|
|
108
|
+
cronId,
|
|
109
|
+
agentId,
|
|
110
|
+
requestedBy: "ops",
|
|
111
|
+
requestedAt: new Date("2026-03-04T05:01:00.000Z"),
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
const rows = await prisma.agentCronRunRequest.findMany({
|
|
115
|
+
where: { cronId },
|
|
116
|
+
});
|
|
117
|
+
const byId = new Map(rows.map((r) => [r.id, r.status]));
|
|
118
|
+
expect(byId.get(first.id)).toBe("expired");
|
|
119
|
+
expect(byId.get(second.id)).toBe("requested");
|
|
120
|
+
|
|
121
|
+
const job = await prisma.agentCronJob.findUniqueOrThrow({
|
|
122
|
+
where: { id: cronId },
|
|
123
|
+
});
|
|
124
|
+
expect(job.runRequestedBy).toBe("ops");
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
it("leaves non-pending rows untouched", async () => {
|
|
128
|
+
const honoured = await prisma.agentCronRunRequest.create({
|
|
129
|
+
data: {
|
|
130
|
+
cronId,
|
|
131
|
+
agentId,
|
|
132
|
+
requestedBy: "root",
|
|
133
|
+
requestedAt: new Date("2026-03-04T04:00:00.000Z"),
|
|
134
|
+
status: "honoured",
|
|
135
|
+
},
|
|
136
|
+
});
|
|
137
|
+
await service.recordRequest({
|
|
138
|
+
cronId,
|
|
139
|
+
agentId,
|
|
140
|
+
requestedBy: "root",
|
|
141
|
+
requestedAt: new Date("2026-03-04T05:00:00.000Z"),
|
|
142
|
+
});
|
|
143
|
+
const after = await prisma.agentCronRunRequest.findUniqueOrThrow({
|
|
144
|
+
where: { id: honoured.id },
|
|
145
|
+
});
|
|
146
|
+
expect(after.status).toBe("honoured");
|
|
147
|
+
});
|
|
148
|
+
|
|
149
|
+
it("rolls back the audit row when the cron does not exist", async () => {
|
|
150
|
+
await expect(
|
|
151
|
+
service.recordRequest({
|
|
152
|
+
cronId: "no-such-cron",
|
|
153
|
+
agentId,
|
|
154
|
+
requestedBy: "root",
|
|
155
|
+
requestedAt: new Date(),
|
|
156
|
+
}),
|
|
157
|
+
).rejects.toThrow();
|
|
158
|
+
expect(
|
|
159
|
+
await prisma.agentCronRunRequest.count({ where: { agentId } }),
|
|
160
|
+
).toBe(0);
|
|
161
|
+
});
|
|
162
|
+
});
|
|
163
|
+
});
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* admin/src/cron-run-transcripts-removed.smoke.test.ts
|
|
3
|
+
*
|
|
4
|
+
* The cron-run transcript API (PUT/GET
|
|
5
|
+
* /agents/{id}/crons/{cronId}/runs/{runId}/transcript) was removed
|
|
6
|
+
* (prompt-audit-removal 2.3). The routes are no longer registered, so every
|
|
7
|
+
* caller gets 404 — including on a deployment that still sets the old
|
|
8
|
+
* SHIPWRIGHT_TRANSCRIPT_API_ENABLED / SHIPWRIGHT_LOOP_TRANSCRIPT_AGENT_IDS envs.
|
|
9
|
+
* Uses app.request() — no real server, no real DB.
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
import { afterEach, beforeEach, describe, expect, it } from "bun:test";
|
|
13
|
+
import {
|
|
14
|
+
type AdminDeps,
|
|
15
|
+
createAdminApp,
|
|
16
|
+
parseAdminApiKeys,
|
|
17
|
+
} from "./agents-api.ts";
|
|
18
|
+
|
|
19
|
+
const ADMIN = "admin-key";
|
|
20
|
+
const READ = "platform-read-token";
|
|
21
|
+
const OPS = "platform-ops-token";
|
|
22
|
+
const AGENT_KEY = "agent-1-key";
|
|
23
|
+
const PATH = "/agents/agent-1/crons/cron-1/runs/run-1/transcript";
|
|
24
|
+
|
|
25
|
+
const LEGACY_ENV = {
|
|
26
|
+
SHIPWRIGHT_TRANSCRIPT_API_ENABLED: "enabled",
|
|
27
|
+
SHIPWRIGHT_LOOP_TRANSCRIPT_AGENT_IDS: "agent-1",
|
|
28
|
+
} as const;
|
|
29
|
+
|
|
30
|
+
function makeApp() {
|
|
31
|
+
const deps = {
|
|
32
|
+
agentService: { exists: async () => true },
|
|
33
|
+
agentTokenService: { validate: async () => null },
|
|
34
|
+
agentMemberService: { listByEmail: async () => [] },
|
|
35
|
+
adminApiKeys: parseAdminApiKeys(
|
|
36
|
+
`root:${ADMIN}:*,reader:${READ}:platform.read,operator:${OPS}:platform.ops,a1:${AGENT_KEY}:agent-1`,
|
|
37
|
+
),
|
|
38
|
+
sessionSecret: "s".repeat(32),
|
|
39
|
+
} as unknown as AdminDeps;
|
|
40
|
+
return createAdminApp(deps);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
describe("removed cron-run transcript routes", () => {
|
|
44
|
+
const saved: Record<string, string | undefined> = {};
|
|
45
|
+
|
|
46
|
+
beforeEach(() => {
|
|
47
|
+
for (const [k, v] of Object.entries(LEGACY_ENV)) {
|
|
48
|
+
saved[k] = process.env[k];
|
|
49
|
+
process.env[k] = v;
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
afterEach(() => {
|
|
54
|
+
for (const k of Object.keys(LEGACY_ENV)) {
|
|
55
|
+
if (saved[k] === undefined) delete process.env[k];
|
|
56
|
+
else process.env[k] = saved[k];
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
it("registers no transcript route", () => {
|
|
61
|
+
const app = makeApp();
|
|
62
|
+
expect(app.routes.some((r) => r.path.endsWith("/transcript"))).toBe(false);
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
it("404s GET for every caller and PUT for every write-capable caller, even with the legacy envs set", async () => {
|
|
66
|
+
const app = makeApp();
|
|
67
|
+
for (const token of [ADMIN, READ, OPS, AGENT_KEY]) {
|
|
68
|
+
const auth = { Authorization: `Bearer ${token}` };
|
|
69
|
+
expect((await app.request(PATH, { headers: auth })).status).toBe(404);
|
|
70
|
+
// platform.read and platform.ops are refused this write by the scope
|
|
71
|
+
// middleware (403) before routing, as for any unknown agent path, so
|
|
72
|
+
// only write-capable callers can observe the 404.
|
|
73
|
+
if (token === READ || token === OPS) continue;
|
|
74
|
+
const put = await app.request(PATH, {
|
|
75
|
+
method: "PUT",
|
|
76
|
+
body: JSON.stringify({ body: "x", truncated: false, redactions: 0 }),
|
|
77
|
+
headers: { ...auth, "Content-Type": "application/json" },
|
|
78
|
+
});
|
|
79
|
+
expect(put.status).toBe(404);
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
});
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* admin/src/drop-cron-run-transcripts-migration.integration.test.ts
|
|
3
|
+
* Migration test for 20261129000000_drop_cron_run_transcripts
|
|
4
|
+
* (prompt-audit-removal 2.3): the cron-run transcript API is gone, so the
|
|
5
|
+
* migration drops "AgentCronRunTranscript" and its audit table
|
|
6
|
+
* "AgentTranscriptRead".
|
|
7
|
+
*
|
|
8
|
+
* Replays the real migration files, in order, inside a throwaway Postgres
|
|
9
|
+
* schema (same pattern as agent-specialty-backfill.integration.test.ts):
|
|
10
|
+
*
|
|
11
|
+
* - seeded: every migration up to the drop, then transcript + read rows,
|
|
12
|
+
* then the drop. Both tables are gone and the rest of the schema
|
|
13
|
+
* ("AgentCronRun" here) is untouched.
|
|
14
|
+
* - fresh: every migration from an empty schema, ending with no transcript
|
|
15
|
+
* tables.
|
|
16
|
+
*
|
|
17
|
+
* Requires DATABASE_URL_ADMIN_TEST; skips otherwise.
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
import { afterEach, beforeEach, describe, expect, it } from "bun:test";
|
|
21
|
+
import { readdirSync, readFileSync } from "node:fs";
|
|
22
|
+
import { Client } from "pg";
|
|
23
|
+
|
|
24
|
+
const TEST_DB = process.env.DATABASE_URL_ADMIN_TEST;
|
|
25
|
+
const describeOrSkip = TEST_DB ? describe : describe.skip;
|
|
26
|
+
|
|
27
|
+
const MIGRATIONS_DIR = new URL("../prisma/migrations/", import.meta.url);
|
|
28
|
+
const DROP = "20261129000000_drop_cron_run_transcripts";
|
|
29
|
+
const TABLES = ["AgentCronRunTranscript", "AgentTranscriptRead"];
|
|
30
|
+
|
|
31
|
+
/** Migration directory names in apply order (Prisma sorts lexically). */
|
|
32
|
+
const ALL_MIGRATIONS = readdirSync(MIGRATIONS_DIR, { withFileTypes: true })
|
|
33
|
+
.filter((d) => d.isDirectory())
|
|
34
|
+
.map((d) => d.name)
|
|
35
|
+
.sort();
|
|
36
|
+
|
|
37
|
+
function migrationSql(dir: string): string {
|
|
38
|
+
return readFileSync(new URL(`${dir}/migration.sql`, MIGRATIONS_DIR), "utf8");
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
describeOrSkip("drop_cron_run_transcripts migration (2.3)", () => {
|
|
42
|
+
const schema = `drop_transcripts_${process.pid}_${Date.now()}`;
|
|
43
|
+
let client: Client;
|
|
44
|
+
|
|
45
|
+
const tables = async (): Promise<string[]> =>
|
|
46
|
+
(
|
|
47
|
+
await client.query<{ table_name: string }>(
|
|
48
|
+
`SELECT table_name FROM information_schema.tables
|
|
49
|
+
WHERE table_schema = $1`,
|
|
50
|
+
[schema],
|
|
51
|
+
)
|
|
52
|
+
).rows.map((r) => r.table_name);
|
|
53
|
+
|
|
54
|
+
const apply = async (dirs: string[]): Promise<void> => {
|
|
55
|
+
for (const dir of dirs) await client.query(migrationSql(dir));
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
beforeEach(async () => {
|
|
59
|
+
client = new Client({ connectionString: TEST_DB as string });
|
|
60
|
+
await client.connect();
|
|
61
|
+
await client.query(`CREATE SCHEMA "${schema}"`);
|
|
62
|
+
await client.query(`SET search_path TO "${schema}"`);
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
afterEach(async () => {
|
|
66
|
+
await client.query(`DROP SCHEMA IF EXISTS "${schema}" CASCADE`);
|
|
67
|
+
await client.end();
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
it("orders the drop after the add migration", () => {
|
|
71
|
+
expect(ALL_MIGRATIONS).toContain(DROP);
|
|
72
|
+
expect(
|
|
73
|
+
ALL_MIGRATIONS.indexOf("20261027000000_add_cron_run_transcripts"),
|
|
74
|
+
).toBeLessThan(ALL_MIGRATIONS.indexOf(DROP));
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
it("drops both tables over seeded transcript rows and leaves AgentCronRun intact", async () => {
|
|
78
|
+
await apply(ALL_MIGRATIONS.slice(0, ALL_MIGRATIONS.indexOf(DROP)));
|
|
79
|
+
expect(await tables()).toEqual(expect.arrayContaining(TABLES));
|
|
80
|
+
|
|
81
|
+
await client.query(
|
|
82
|
+
`INSERT INTO "AgentCronRunTranscript"
|
|
83
|
+
("id","runId","agentId","cronId","sessionId","bytes","truncated","redactions","body")
|
|
84
|
+
VALUES ('t1','run-1','agent-1','cron-1','sess-1',5,false,0,'hello'),
|
|
85
|
+
('t2','run-2','agent-1','cron-1',NULL,3,true,2,'abc')`,
|
|
86
|
+
);
|
|
87
|
+
await client.query(
|
|
88
|
+
`INSERT INTO "AgentTranscriptRead" ("id","runId","agentId","reader","scopeKind")
|
|
89
|
+
VALUES ('r1','run-1','agent-1','root','*')`,
|
|
90
|
+
);
|
|
91
|
+
const before = await tables();
|
|
92
|
+
|
|
93
|
+
await client.query(migrationSql(DROP));
|
|
94
|
+
|
|
95
|
+
const after = await tables();
|
|
96
|
+
for (const t of TABLES) expect(after).not.toContain(t);
|
|
97
|
+
expect(after).toContain("AgentCronRun");
|
|
98
|
+
expect(after.sort()).toEqual(
|
|
99
|
+
before.filter((t) => !TABLES.includes(t)).sort(),
|
|
100
|
+
);
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
it("applies cleanly on a fresh database and ends with no transcript tables", async () => {
|
|
104
|
+
await apply(ALL_MIGRATIONS);
|
|
105
|
+
const after = await tables();
|
|
106
|
+
expect(after).toContain("Agent");
|
|
107
|
+
for (const t of TABLES) expect(after).not.toContain(t);
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
it("is idempotent when the tables are already gone", async () => {
|
|
111
|
+
await expect(client.query(migrationSql(DROP))).resolves.toBeDefined();
|
|
112
|
+
expect(await tables()).toEqual([]);
|
|
113
|
+
});
|
|
114
|
+
});
|
package/src/openapi-schemas.ts
CHANGED
|
@@ -749,51 +749,6 @@ export const ChatCredentialsWrapperSchema = z
|
|
|
749
749
|
.object({ credentials: z.array(ChatCredentialSchema) })
|
|
750
750
|
.openapi("ChatCredentialsWrapper");
|
|
751
751
|
|
|
752
|
-
// ─── Cron-run transcripts (COS-43.1) ─────────────────────────────────────────
|
|
753
|
-
|
|
754
|
-
export const UploadCronRunTranscriptBodySchema = z
|
|
755
|
-
.object({
|
|
756
|
-
sessionId: z.string().min(1).optional().openapi({
|
|
757
|
-
description: "Claude session id the transcript was read from.",
|
|
758
|
-
example: "7c1c8d1e-0000-4000-8000-000000000000",
|
|
759
|
-
}),
|
|
760
|
-
body: z.string().openapi({
|
|
761
|
-
description:
|
|
762
|
-
"The already-redacted transcript (JSONL text). Over 1 MiB (UTF-8 bytes) is a 413. Never logged.",
|
|
763
|
-
}),
|
|
764
|
-
truncated: z.boolean().openapi({
|
|
765
|
-
description: "True when the runtime dropped earlier lines to fit.",
|
|
766
|
-
example: false,
|
|
767
|
-
}),
|
|
768
|
-
redactions: z.number().int().min(0).openapi({
|
|
769
|
-
description: "How many secrets the runtime redacted.",
|
|
770
|
-
example: 0,
|
|
771
|
-
}),
|
|
772
|
-
})
|
|
773
|
-
.openapi("UploadCronRunTranscriptBody");
|
|
774
|
-
|
|
775
|
-
export const CronRunTranscriptUploadResultSchema = z
|
|
776
|
-
.object({
|
|
777
|
-
runId: z.string().openapi({ example: "clx1111111111" }),
|
|
778
|
-
bytes: z.number().int().openapi({ example: 2048 }),
|
|
779
|
-
truncated: z.boolean().openapi({ example: false }),
|
|
780
|
-
redactions: z.number().int().openapi({ example: 0 }),
|
|
781
|
-
})
|
|
782
|
-
.openapi("CronRunTranscriptUploadResult");
|
|
783
|
-
|
|
784
|
-
export const CronRunTranscriptSchema = z
|
|
785
|
-
.object({
|
|
786
|
-
runId: z.string().openapi({ example: "clx1111111111" }),
|
|
787
|
-
cronId: z.string().openapi({ example: "clx0987654321" }),
|
|
788
|
-
sessionId: z.string().nullable().openapi({ example: null }),
|
|
789
|
-
bytes: z.number().int().openapi({ example: 2048 }),
|
|
790
|
-
truncated: z.boolean().openapi({ example: false }),
|
|
791
|
-
redactions: z.number().int().openapi({ example: 0 }),
|
|
792
|
-
createdAt: z.string().openapi({ example: "2026-10-26T12:00:00.000Z" }),
|
|
793
|
-
body: z.string().openapi({ description: "Redacted JSONL transcript." }),
|
|
794
|
-
})
|
|
795
|
-
.openapi("CronRunTranscript");
|
|
796
|
-
|
|
797
752
|
// ─── Agent ask (COS-31.1) ─────────────────────────────────────────────────────
|
|
798
753
|
|
|
799
754
|
export const AgentAskBodySchema = z
|
|
@@ -1489,20 +1444,10 @@ export const AgentConfigResponseSchema = z
|
|
|
1489
1444
|
*/
|
|
1490
1445
|
features: z
|
|
1491
1446
|
.object({
|
|
1492
|
-
transcriptUpload: z.boolean().openapi({
|
|
1493
|
-
description:
|
|
1494
|
-
"True when SHIPWRIGHT_TRANSCRIPT_API_ENABLED is on: the runtime uploads a redacted transcript after each cron run.",
|
|
1495
|
-
example: false,
|
|
1496
|
-
}),
|
|
1497
1447
|
repoAccessCheck: z.boolean().openapi({
|
|
1498
1448
|
description: "Reserved for the repo-access check (COS-44.1).",
|
|
1499
1449
|
example: false,
|
|
1500
1450
|
}),
|
|
1501
|
-
loopTranscriptUpload: z.boolean().optional().openapi({
|
|
1502
|
-
description:
|
|
1503
|
-
"True when SHIPWRIGHT_TRANSCRIPT_API_ENABLED is on and this agent is listed in SHIPWRIGHT_LOOP_TRANSCRIPT_AGENT_IDS: coding-loop runs may upload a redacted transcript through the extension capability.",
|
|
1504
|
-
example: false,
|
|
1505
|
-
}),
|
|
1506
1451
|
})
|
|
1507
1452
|
.optional()
|
|
1508
1453
|
.openapi("AgentConfigFeatures"),
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* injected env object (no process.env reads) so it is deterministically
|
|
6
6
|
* unit-testable; admin-boot reads it once at startup and feeds it into the
|
|
7
7
|
* config bundle as `features.repoAccessCheck`. Same "enabled" convention as
|
|
8
|
-
*
|
|
8
|
+
* the other platform feature flags.
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
11
|
type RepoAccessEnv = Readonly<Record<string, string | undefined>>;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { createHash, timingSafeEqual } from "node:crypto";
|
|
2
|
+
|
|
3
|
+
/** Constant-time string compare; hashes first so length doesn't leak. */
|
|
4
|
+
export function secretsEqual(a: string, b: string): boolean {
|
|
5
|
+
const ha = createHash("sha256").update(a).digest();
|
|
6
|
+
const hb = createHash("sha256").update(b).digest();
|
|
7
|
+
return timingSafeEqual(ha, hb);
|
|
8
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { describe, expect, test } from "bun:test";
|
|
2
|
+
import { secretsEqual } from "./secrets-equal.ts";
|
|
3
|
+
|
|
4
|
+
describe("secretsEqual", () => {
|
|
5
|
+
test("equal strings match", () => {
|
|
6
|
+
expect(secretsEqual("abc", "abc")).toBe(true);
|
|
7
|
+
});
|
|
8
|
+
test("different strings of same length differ", () => {
|
|
9
|
+
expect(secretsEqual("abc", "abd")).toBe(false);
|
|
10
|
+
});
|
|
11
|
+
test("different lengths differ without throwing", () => {
|
|
12
|
+
expect(secretsEqual("abc", "abcd")).toBe(false);
|
|
13
|
+
expect(secretsEqual("", "abc")).toBe(false);
|
|
14
|
+
});
|
|
15
|
+
});
|