@app-vitals/agent-runtime 1.36.2 → 1.38.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -25,6 +25,7 @@ import type { createConfig } from "./config.ts";
25
25
  import type { createContextStampReader } from "./context-stamp.ts";
26
26
  import type { CronRunReporter } from "./cron-run-reporter.ts";
27
27
  import type { createFileSessionStore } from "./sessions.ts";
28
+ import type { TranscriptUploader } from "./transcript-uploader.ts";
28
29
 
29
30
  /** Minimal structural view of a cron job, as the seam needs it. */
30
31
  export interface ExtensionCronJob {
@@ -57,6 +58,12 @@ export interface AgentExtensionContext {
57
58
  cronRunReporter: CronRunReporter | undefined;
58
59
  contextStamp: ReturnType<typeof createContextStampReader>;
59
60
  sentryClient: ErrorCapturingClient | undefined;
61
+ /**
62
+ * Redacted transcript upload for extension-driven runs (the coding loop).
63
+ * A no-op unless the synced `features.loopTranscriptUpload` is true.
64
+ * Absent when the runtime has no admin API url / agent id.
65
+ */
66
+ transcriptUploader?: TranscriptUploader;
60
67
  }
61
68
 
62
69
  export interface AgentExtension<TBundle = unknown> {
@@ -10,6 +10,7 @@
10
10
 
11
11
  export interface AgentFeatures {
12
12
  transcriptUpload?: boolean;
13
+ loopTranscriptUpload?: boolean;
13
14
  repoAccessCheck?: boolean;
14
15
  }
15
16
 
package/boot.ts CHANGED
@@ -111,7 +111,10 @@ import {
111
111
  buildProductionDeps as buildSyncConfigCloneDeps,
112
112
  syncClonedRepos,
113
113
  } from "./sync-config-clone.ts";
114
- import { createTranscriptUploader } from "./transcript-uploader.ts";
114
+ import {
115
+ createTranscriptUploader,
116
+ type TranscriptUploaderDeps,
117
+ } from "./transcript-uploader.ts";
115
118
  import { resolveDisplayName, resolveUserEmail } from "./users.ts";
116
119
  import {
117
120
  buildVoiceConfig,
@@ -294,6 +297,25 @@ export async function startAgent(
294
297
  claudeCodeVersion: () => claudeVersionState.version,
295
298
  });
296
299
 
300
+ // COS-43.1: redacted transcript upload deps, shared by the cron handler and
301
+ // the extension capability (they differ only in the gating feature flag).
302
+ const transcriptUploadDeps: TranscriptUploaderDeps | undefined =
303
+ config.shipwright.apiUrl && config.shipwright.agentId
304
+ ? {
305
+ fs: {
306
+ readFile: (path) => readFile(path, "utf8"),
307
+ readdir: (path) => readdir(path),
308
+ },
309
+ fetch,
310
+ clock: SystemClock(),
311
+ env: process.env,
312
+ log: (line) => console.warn(line),
313
+ apiUrl: config.shipwright.apiUrl,
314
+ agentId: config.shipwright.agentId,
315
+ getFeatures: () => agentFeaturesRef.get(),
316
+ }
317
+ : undefined;
318
+
297
319
  const cronDeps: CronHandlerDeps = {
298
320
  // SLK-1.1: a getter, not a plain field — Slack may start after boot (see
299
321
  // slack-startup.ts's startSlackIfPossible()), so cron dispatch must read
@@ -332,22 +354,8 @@ export async function startAgent(
332
354
  defaultOwnerOf(githubInstallationsManagerRef.get()?.getState?.()),
333
355
  // COS-43.1: redacted transcript upload after completeRun; gated by the
334
356
  // synced features.transcriptUpload flag, failures swallowed.
335
- ...(config.shipwright.apiUrl && config.shipwright.agentId
336
- ? {
337
- transcriptUploader: createTranscriptUploader({
338
- fs: {
339
- readFile: (path) => readFile(path, "utf8"),
340
- readdir: (path) => readdir(path),
341
- },
342
- fetch,
343
- clock: SystemClock(),
344
- env: process.env,
345
- log: (line) => console.warn(line),
346
- apiUrl: config.shipwright.apiUrl,
347
- agentId: config.shipwright.agentId,
348
- getFeatures: () => agentFeaturesRef.get(),
349
- }),
350
- }
357
+ ...(transcriptUploadDeps
358
+ ? { transcriptUploader: createTranscriptUploader(transcriptUploadDeps) }
351
359
  : {}),
352
360
  };
353
361
 
@@ -363,6 +371,15 @@ export async function startAgent(
363
371
  cronRunReporter,
364
372
  contextStamp,
365
373
  sentryClient: process.env.SENTRY_DSN ? Sentry : undefined,
374
+ // Same uploader (redaction, size cap, retention), gated by the loop flag.
375
+ ...(transcriptUploadDeps
376
+ ? {
377
+ transcriptUploader: createTranscriptUploader({
378
+ ...transcriptUploadDeps,
379
+ featureFlag: "loopTranscriptUpload",
380
+ }),
381
+ }
382
+ : {}),
366
383
  };
367
384
  const extension = composeExtensions(
368
385
  extensions.map((createExtension) => createExtension(extensionContext)),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@app-vitals/agent-runtime",
3
- "version": "1.36.2",
3
+ "version": "1.38.0",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/app-vitals/agent.git",
@@ -40,8 +40,8 @@
40
40
  "./workspace-paths": "./workspace-paths.ts"
41
41
  },
42
42
  "dependencies": {
43
- "@app-vitals/agent-admin": "1.36.2",
44
- "@app-vitals/agent-lib": "1.36.2",
43
+ "@app-vitals/agent-admin": "1.38.0",
44
+ "@app-vitals/agent-lib": "1.38.0",
45
45
  "@octokit/auth-app": "^8.2.0",
46
46
  "@sentry/bun": "^10.63.0",
47
47
  "@slack/bolt": "^5.0.0",
@@ -4,7 +4,8 @@
4
4
  * admin API (COS-43.1) once the run is recorded.
5
5
  *
6
6
  * Gated by the synced config bundle's `features.transcriptUpload` (the admin
7
- * flag SHIPWRIGHT_TRANSCRIPT_API_ENABLED). Redaction happens HERE, before the
7
+ * flag SHIPWRIGHT_TRANSCRIPT_API_ENABLED), or `features.loopTranscriptUpload`
8
+ * for the extension-facing loop uploader. Redaction happens HERE, before the
8
9
  * transcript leaves the pod: live SECRET_ENV_VARS values plus well-known token
9
10
  * shapes (lib/redact.ts). The body is tail-truncated to 1 MiB on whole lines
10
11
  * with a marker line first. Every failure logs one line (never the body) and
@@ -30,6 +31,7 @@ export interface TranscriptFs {
30
31
 
31
32
  export interface TranscriptFeatures {
32
33
  transcriptUpload?: boolean;
34
+ loopTranscriptUpload?: boolean;
33
35
  }
34
36
 
35
37
  export interface TranscriptUploaderDeps {
@@ -43,6 +45,11 @@ export interface TranscriptUploaderDeps {
43
45
  agentId: string;
44
46
  /** The last synced `features` from the config bundle (absent before sync). */
45
47
  getFeatures: () => TranscriptFeatures | undefined;
48
+ /**
49
+ * Which synced feature flag gates uploads. Defaults to `transcriptUpload`
50
+ * (regular cron runs); the loop capability uses `loopTranscriptUpload`.
51
+ */
52
+ featureFlag?: keyof TranscriptFeatures;
46
53
  }
47
54
 
48
55
  export interface TranscriptUploadArgs {
@@ -119,7 +126,11 @@ export function createTranscriptUploader(
119
126
  ): TranscriptUploader {
120
127
  return {
121
128
  async upload({ cronId, runId, sessionId, cwd }) {
122
- if (deps.getFeatures()?.transcriptUpload !== true) return;
129
+ if (
130
+ deps.getFeatures()?.[deps.featureFlag ?? "transcriptUpload"] !== true
131
+ ) {
132
+ return;
133
+ }
123
134
  if (!sessionId) return;
124
135
  const apiKey = deps.env.SHIPWRIGHT_AGENT_API_KEY;
125
136
  if (!apiKey) return;
@@ -45,7 +45,10 @@ interface Call {
45
45
  function setup(
46
46
  files: Record<string, string>,
47
47
  opts: {
48
- features?: { transcriptUpload: boolean } | undefined;
48
+ features?:
49
+ | { transcriptUpload?: boolean; loopTranscriptUpload?: boolean }
50
+ | undefined;
51
+ featureFlag?: "transcriptUpload" | "loopTranscriptUpload";
49
52
  status?: number;
50
53
  throwFetch?: boolean;
51
54
  env?: Record<string, string>;
@@ -72,6 +75,7 @@ function setup(
72
75
  apiUrl: "https://admin.example",
73
76
  agentId: "agent-1",
74
77
  getFeatures: () => features,
78
+ featureFlag: opts.featureFlag,
75
79
  });
76
80
  const run = (sessionId: string | null = SESSION) =>
77
81
  uploader.upload({
@@ -181,6 +185,42 @@ describe("transcript uploader", () => {
181
185
  expect(calls).toHaveLength(0);
182
186
  });
183
187
 
188
+ it("loop uploader never uploads for an agent not on the allowlist", async () => {
189
+ for (const features of [
190
+ { transcriptUpload: true },
191
+ { transcriptUpload: true, loopTranscriptUpload: false },
192
+ undefined,
193
+ ]) {
194
+ const { calls, run } = setup(
195
+ { [PRIMARY]: "x\n" },
196
+ { features, featureFlag: "loopTranscriptUpload" },
197
+ );
198
+ await run();
199
+ expect(calls).toHaveLength(0);
200
+ }
201
+ });
202
+
203
+ it("loop uploader uploads when loopTranscriptUpload is true, regardless of transcriptUpload", async () => {
204
+ const { calls, run } = setup(
205
+ { [PRIMARY]: "x\n" },
206
+ {
207
+ features: { transcriptUpload: false, loopTranscriptUpload: true },
208
+ featureFlag: "loopTranscriptUpload",
209
+ },
210
+ );
211
+ await run();
212
+ expect(calls).toHaveLength(1);
213
+ });
214
+
215
+ it("regular uploader ignores loopTranscriptUpload", async () => {
216
+ const { calls, run } = setup(
217
+ { [PRIMARY]: "x\n" },
218
+ { features: { loopTranscriptUpload: true } },
219
+ );
220
+ await run();
221
+ expect(calls).toHaveLength(0);
222
+ });
223
+
184
224
  it("does nothing without an API key", async () => {
185
225
  const { calls, run } = setup(
186
226
  { [PRIMARY]: "x\n" },