@sentry/junior 0.164.0 → 0.165.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.
Files changed (69) hide show
  1. package/dist/{agent-hooks-WTBPNRTC.js → agent-hooks-GSNL33UA.js} +9 -9
  2. package/dist/api/schema/workspace.d.ts +8 -4
  3. package/dist/api/schema.js +1 -1
  4. package/dist/api.js +59 -27
  5. package/dist/app.js +34 -34
  6. package/dist/{catalog-runtime-CZ2SQINY.js → catalog-runtime-4ERDVI7V.js} +5 -5
  7. package/dist/chat/repository-instructions.d.ts +12 -1
  8. package/dist/chat/sandbox/sandbox.d.ts +1 -1
  9. package/dist/chat/sandbox/snapshot/resolve.d.ts +12 -0
  10. package/dist/chat/sandbox/snapshot/runtime.d.ts +2 -0
  11. package/dist/chat/workspaces/store.d.ts +0 -2
  12. package/dist/chat/workspaces/types.d.ts +0 -1
  13. package/dist/chat/workspaces/validation.d.ts +0 -1
  14. package/dist/{chunk-VHSEMJTS.js → chunk-32CCG4WP.js} +1 -1
  15. package/dist/{chunk-WJUKESU2.js → chunk-3V2EIQLT.js} +1 -1
  16. package/dist/{chunk-26JYGL2L.js → chunk-5T6WPPEI.js} +1 -1
  17. package/dist/{chunk-YHCTPDXS.js → chunk-5WDDWMQ7.js} +8 -22
  18. package/dist/{chunk-BXBZDV3C.js → chunk-65B3PDY7.js} +1 -1
  19. package/dist/{chunk-5GLGQHO3.js → chunk-6OWVPXNO.js} +2 -1
  20. package/dist/{chunk-XAIRI54J.js → chunk-6RZ6MMEK.js} +1 -1
  21. package/dist/{chunk-NAGI2XH3.js → chunk-6YXCG2XL.js} +4 -4
  22. package/dist/{chunk-6BXV63YX.js → chunk-7J26TW64.js} +5 -5
  23. package/dist/{chunk-RULIISEI.js → chunk-7S2JVUWS.js} +1 -1
  24. package/dist/{chunk-5FWQ73UZ.js → chunk-AEBF6AO2.js} +1 -1
  25. package/dist/{chunk-ZUTAGCPH.js → chunk-AQEBOQUC.js} +9 -9
  26. package/dist/{chunk-PU45BSBS.js → chunk-BEC542E6.js} +8 -5
  27. package/dist/{chunk-RJHZNPDH.js → chunk-BEHPIDVZ.js} +5 -4
  28. package/dist/{chunk-RYYEHWIL.js → chunk-DKO4RRGJ.js} +1 -1
  29. package/dist/{chunk-HHW6ZVIZ.js → chunk-EA4UL5H2.js} +73 -14
  30. package/dist/{chunk-FX4PX3SA.js → chunk-FMOFCEAA.js} +2 -2
  31. package/dist/{chunk-CGCNFEAU.js → chunk-FNNQCHOL.js} +4 -4
  32. package/dist/{chunk-JW23XD4I.js → chunk-FXX4NHOM.js} +6 -6
  33. package/dist/{chunk-4GTOFUQF.js → chunk-G72LBEMZ.js} +1 -1
  34. package/dist/{chunk-7WKWMMYQ.js → chunk-HPWZ4BJJ.js} +68 -64
  35. package/dist/{chunk-6ENAACWN.js → chunk-HZDLOFO4.js} +9 -5
  36. package/dist/{chunk-ZSNABC2E.js → chunk-IZHR2OES.js} +4 -13
  37. package/dist/{chunk-VV2DN24T.js → chunk-N2BRRIQZ.js} +1 -1
  38. package/dist/{chunk-FKDY7NTC.js → chunk-NPW6LM2X.js} +12 -12
  39. package/dist/{chunk-LPLVNMVN.js → chunk-RQQTOF3H.js} +3 -3
  40. package/dist/{chunk-Y2B6AXZQ.js → chunk-SA5FVUWJ.js} +6 -6
  41. package/dist/{chunk-3L23VTY7.js → chunk-T6BAHCT6.js} +17 -17
  42. package/dist/{chunk-NLTQRYNP.js → chunk-TCWPG5VL.js} +2 -2
  43. package/dist/{chunk-2K25MRZK.js → chunk-VDNNVTX2.js} +5 -5
  44. package/dist/{chunk-H36GJVJV.js → chunk-XOINKFDJ.js} +7 -7
  45. package/dist/{chunk-RBV4JHCP.js → chunk-ZUKU2Y3J.js} +1 -1
  46. package/dist/cli/chat.js +29 -29
  47. package/dist/cli/check.js +6 -6
  48. package/dist/cli/plugins.js +12 -12
  49. package/dist/cli/snapshot-create.js +9 -9
  50. package/dist/cli/upgrade.js +7 -7
  51. package/dist/db/schema/workspaces.d.ts +0 -17
  52. package/dist/db/schema.d.ts +0 -17
  53. package/dist/{db-32KRFS6L.js → db-5TTEPMTY.js} +7 -7
  54. package/dist/instrumentation.js +4 -4
  55. package/dist/nitro.js +2 -2
  56. package/dist/{oauth-callback-server-CGZP2Z6U.js → oauth-callback-server-IVFC5YHY.js} +22 -22
  57. package/dist/{runner-S5N4Q2XL.js → runner-G76TSHWO.js} +12 -12
  58. package/dist/{skills-KYPSHSQR.js → skills-F6PSLVSG.js} +6 -6
  59. package/dist/spawn-WMJPIAZL.js +37 -0
  60. package/dist/{validation-SZBE7JNF.js → validation-56EJI6UQ.js} +6 -6
  61. package/dist/version.js +1 -1
  62. package/dist/{work-GCZKHEZX.js → work-RNRQCP3Y.js} +17 -17
  63. package/dist/worker-FBR2WUI4.js +24 -0
  64. package/migrations/0030_drop_workspace_repo_primary.sql +2 -0
  65. package/migrations/meta/0030_snapshot.json +2799 -0
  66. package/migrations/meta/_journal.json +8 -1
  67. package/package.json +5 -4
  68. package/dist/spawn-EGOB3CLV.js +0 -37
  69. package/dist/worker-6MY5Q4A2.js +0 -24
@@ -2,7 +2,7 @@ import {
2
2
  getConversationEventStore,
3
3
  getDb,
4
4
  getSqlExecutor
5
- } from "./chunk-LPLVNMVN.js";
5
+ } from "./chunk-RQQTOF3H.js";
6
6
  import {
7
7
  juniorConversationAnnotations,
8
8
  juniorConversationEvents,
@@ -10,7 +10,7 @@ import {
10
10
  juniorUsers,
11
11
  juniorWorkspaceRepos,
12
12
  juniorWorkspaces
13
- } from "./chunk-ZSNABC2E.js";
13
+ } from "./chunk-IZHR2OES.js";
14
14
  import {
15
15
  SANDBOX_WORKSPACE_ROOT,
16
16
  runNonInteractiveCommand,
@@ -18,14 +18,14 @@ import {
18
18
  } from "./chunk-BVREIWBD.js";
19
19
  import {
20
20
  getStateAdapter
21
- } from "./chunk-BXBZDV3C.js";
21
+ } from "./chunk-65B3PDY7.js";
22
22
  import {
23
23
  botConfig,
24
24
  completeObject,
25
25
  embedTexts,
26
26
  getSlackBotToken,
27
27
  standardModelId
28
- } from "./chunk-FX4PX3SA.js";
28
+ } from "./chunk-FMOFCEAA.js";
29
29
  import {
30
30
  isActorUserId,
31
31
  parseActorUserId,
@@ -41,7 +41,7 @@ import {
41
41
  setSpanAttributes,
42
42
  setSpanStatus,
43
43
  withSpan
44
- } from "./chunk-VHSEMJTS.js";
44
+ } from "./chunk-32CCG4WP.js";
45
45
 
46
46
  // src/chat/plugins/agent-hooks.ts
47
47
  import {
@@ -1277,8 +1277,7 @@ function normalizeWorkspaceRecipe(input) {
1277
1277
  }
1278
1278
  return {
1279
1279
  provider,
1280
- repo,
1281
- isPrimary: entry.isPrimary === true
1280
+ repo
1282
1281
  };
1283
1282
  });
1284
1283
  const identities = /* @__PURE__ */ new Set();
@@ -1302,17 +1301,6 @@ function normalizeWorkspaceRecipe(input) {
1302
1301
  }
1303
1302
  checkoutPaths.add(key);
1304
1303
  }
1305
- const primaryCount = repos.filter((repo) => repo.isPrimary).length;
1306
- if (repos.length > 0 && primaryCount === 0) {
1307
- throw new WorkspaceValidationError(
1308
- "Select one primary repository for AGENTS.md instructions."
1309
- );
1310
- }
1311
- if (primaryCount > 1) {
1312
- throw new WorkspaceValidationError(
1313
- "A Workspace can have only one primary repository."
1314
- );
1315
- }
1316
1304
  return { name, setupScript, repos };
1317
1305
  }
1318
1306
 
@@ -1324,8 +1312,7 @@ function workspaceFromRows(row, repos) {
1324
1312
  setupScript: row.setupScript,
1325
1313
  repos: repos.map((repo) => ({
1326
1314
  provider: repo.provider,
1327
- repo: repo.repo,
1328
- isPrimary: repo.isPrimary
1315
+ repo: repo.repo
1329
1316
  }))
1330
1317
  };
1331
1318
  }
@@ -1342,8 +1329,7 @@ async function replaceWorkspaceRepos(db, workspaceId, repos) {
1342
1329
  repos.map((repo) => ({
1343
1330
  workspaceId,
1344
1331
  provider: repo.provider,
1345
- repo: repo.repo,
1346
- isPrimary: repo.isPrimary
1332
+ repo: repo.repo
1347
1333
  }))
1348
1334
  );
1349
1335
  }
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  getChatConfig
3
- } from "./chunk-FX4PX3SA.js";
3
+ } from "./chunk-FMOFCEAA.js";
4
4
 
5
5
  // src/chat/state/adapter.ts
6
6
  import { createMemoryState } from "@chat-adapter/state-memory";
@@ -1,7 +1,7 @@
1
1
  // package.json
2
2
  var package_default = {
3
3
  name: "@sentry/junior",
4
- version: "0.164.0",
4
+ version: "0.165.0",
5
5
  private: false,
6
6
  publishConfig: {
7
7
  access: "public"
@@ -65,6 +65,7 @@ var package_default = {
65
65
  typecheck: "tsc --noEmit",
66
66
  "skills:check": "node --test scripts/check-skills.test.mjs && node scripts/check-skills.mjs",
67
67
  "tool-annotations:check": "node --test scripts/check-tool-annotations.test.mjs && node scripts/check-tool-annotations.mjs",
68
+ "tool-error-classification:check": "node --test scripts/check-tool-error-classification.test.mjs && node scripts/check-tool-error-classification.mjs",
68
69
  "test:coverage": "vitest run --maxWorkers=4 --coverage --reporter=default --reporter=junit --outputFile.junit=coverage/results.junit.xml"
69
70
  },
70
71
  dependencies: {
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  createAndEnqueueAgentInvocation
3
- } from "./chunk-Y2B6AXZQ.js";
3
+ } from "./chunk-SA5FVUWJ.js";
4
4
  import {
5
5
  actorFromRun,
6
6
  toolInvocationDestination
@@ -8,14 +8,14 @@ import {
8
8
  getConversationStore,
9
9
  parseDestination,
10
10
  sameDestination
11
- } from "./chunk-LPLVNMVN.js";
11
+ } from "./chunk-RQQTOF3H.js";
12
12
  import {
13
13
  getDefaultRedisStateAdapterFor,
14
14
  getStateAdapter
15
- } from "./chunk-BXBZDV3C.js";
15
+ } from "./chunk-65B3PDY7.js";
16
16
  import {
17
17
  getChatConfig
18
- } from "./chunk-FX4PX3SA.js";
18
+ } from "./chunk-FMOFCEAA.js";
19
19
  import {
20
20
  parseStoredSlackActor
21
21
  } from "./chunk-V7YE4WCP.js";
@@ -23,7 +23,7 @@ import {
23
23
  isRecord,
24
24
  toOptionalNumber,
25
25
  toOptionalString
26
- } from "./chunk-VHSEMJTS.js";
26
+ } from "./chunk-32CCG4WP.js";
27
27
 
28
28
  // src/chat/task-execution/state.ts
29
29
  import { randomUUID } from "crypto";
@@ -4,7 +4,7 @@ import {
4
4
  import {
5
5
  formatProviderLabel,
6
6
  startOAuthFlow
7
- } from "./chunk-JW23XD4I.js";
7
+ } from "./chunk-FXX4NHOM.js";
8
8
  import {
9
9
  parseSandboxEgressAuthRequiredSignal
10
10
  } from "./chunk-7MA4HV4W.js";
@@ -12,16 +12,16 @@ import {
12
12
  abandonReplacedPendingAuth,
13
13
  canReusePendingAuthLink,
14
14
  recordAuthorizationRequested
15
- } from "./chunk-HHW6ZVIZ.js";
15
+ } from "./chunk-EA4UL5H2.js";
16
16
  import {
17
17
  AGENT_INVOCATION_MAILBOX_STATUSES
18
- } from "./chunk-ZSNABC2E.js";
18
+ } from "./chunk-IZHR2OES.js";
19
19
  import {
20
20
  TURN_REASONING_LEVELS
21
- } from "./chunk-FX4PX3SA.js";
21
+ } from "./chunk-FMOFCEAA.js";
22
22
  import {
23
23
  pluginCatalogRuntime
24
- } from "./chunk-RULIISEI.js";
24
+ } from "./chunk-7S2JVUWS.js";
25
25
  import {
26
26
  credentialContextSchema
27
27
  } from "./chunk-BDUENQD3.js";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  createPluginCatalogRuntime
3
- } from "./chunk-VV2DN24T.js";
3
+ } from "./chunk-N2BRRIQZ.js";
4
4
 
5
5
  // src/chat/plugins/catalog-runtime.ts
6
6
  var pluginCatalogRuntime = createPluginCatalogRuntime();
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  getStateAdapter
3
- } from "./chunk-BXBZDV3C.js";
3
+ } from "./chunk-65B3PDY7.js";
4
4
  import {
5
5
  getClient
6
6
  } from "./chunk-6GWA276C.js";
@@ -2,7 +2,7 @@ import {
2
2
  coerceThreadConversationState,
3
3
  getPersistedThreadState,
4
4
  persistThreadStateById
5
- } from "./chunk-2K25MRZK.js";
5
+ } from "./chunk-VDNNVTX2.js";
6
6
  import {
7
7
  pluginTaskId,
8
8
  pluginTaskParamsSchema,
@@ -22,7 +22,7 @@ import {
22
22
  markTurnCompleted,
23
23
  normalizeToolNameFromResult,
24
24
  stripRuntimeTurnContext
25
- } from "./chunk-HHW6ZVIZ.js";
25
+ } from "./chunk-EA4UL5H2.js";
26
26
  import {
27
27
  JUNIOR_THREAD_STATE_TTL_MS
28
28
  } from "./chunk-3Y47VMHV.js";
@@ -33,25 +33,25 @@ import {
33
33
  createPluginModel,
34
34
  createPluginState,
35
35
  getPlugins
36
- } from "./chunk-YHCTPDXS.js";
36
+ } from "./chunk-5WDDWMQ7.js";
37
37
  import {
38
38
  getConversationStore,
39
39
  getDb,
40
40
  sameActorIdentity
41
- } from "./chunk-LPLVNMVN.js";
41
+ } from "./chunk-RQQTOF3H.js";
42
42
  import {
43
43
  juniorConversations,
44
44
  juniorTaskExecutions
45
- } from "./chunk-ZSNABC2E.js";
45
+ } from "./chunk-IZHR2OES.js";
46
46
  import {
47
47
  getStateAdapter
48
- } from "./chunk-BXBZDV3C.js";
48
+ } from "./chunk-65B3PDY7.js";
49
49
  import {
50
50
  ProviderError,
51
51
  findProviderError,
52
52
  getProviderErrorAttributes,
53
53
  getProviderErrorUserMessage
54
- } from "./chunk-FX4PX3SA.js";
54
+ } from "./chunk-FMOFCEAA.js";
55
55
  import {
56
56
  credentialSubjectSchema
57
57
  } from "./chunk-BDUENQD3.js";
@@ -61,7 +61,7 @@ import {
61
61
  import {
62
62
  buildTurnFailureResponse,
63
63
  logWarn
64
- } from "./chunk-VHSEMJTS.js";
64
+ } from "./chunk-32CCG4WP.js";
65
65
 
66
66
  // src/chat/runtime/delivered-turn-state.ts
67
67
  function buildDeliveredTurnStatePatch(args) {
@@ -87,7 +87,7 @@ import { pluginRunContextSchema } from "@sentry/junior-plugin-api";
87
87
 
88
88
  // src/chat/services/turn-session-routing.ts
89
89
  async function resolveTurnSessionRouting(args) {
90
- const conversationStore = args.conversationStore ?? (await import("./db-32KRFS6L.js")).getConversationStore();
90
+ const conversationStore = args.conversationStore ?? (await import("./db-5TTEPMTY.js")).getConversationStore();
91
91
  const conversation = await conversationStore.get({
92
92
  conversationId: args.conversationId
93
93
  });
@@ -721,20 +721,23 @@ var revokePersonalTokenResponseSchema = z6.object({ revoked: z6.literal(true) })
721
721
  import { z as z7 } from "zod";
722
722
  var workspaceRepoInputSchema = z7.object({
723
723
  provider: z7.string(),
724
- repo: z7.string(),
725
- isPrimary: z7.boolean().optional()
724
+ repo: z7.string()
726
725
  }).strict();
727
726
  var workspaceRepoSchema = z7.object({
728
727
  provider: z7.string(),
729
728
  repo: z7.string(),
730
- checkoutPath: z7.string(),
731
- isPrimary: z7.boolean()
729
+ checkoutPath: z7.string()
730
+ }).strict();
731
+ var workspaceSnapshotSchema = z7.object({
732
+ id: z7.string(),
733
+ generatedAt: z7.iso.datetime()
732
734
  }).strict();
733
735
  var workspaceSchema = z7.object({
734
736
  id: z7.string().uuid(),
735
737
  name: z7.string(),
736
738
  setupScript: z7.string(),
737
- repos: z7.array(workspaceRepoSchema)
739
+ repos: z7.array(workspaceRepoSchema),
740
+ snapshot: workspaceSnapshotSchema.nullable()
738
741
  }).strict();
739
742
  var workspaceListSchema = z7.object({ workspaces: z7.array(workspaceSchema) }).strict();
740
743
  var workspaceBodySchema = z7.object({
@@ -5,18 +5,18 @@ import {
5
5
  } from "./chunk-BVREIWBD.js";
6
6
  import {
7
7
  getStateAdapter
8
- } from "./chunk-BXBZDV3C.js";
8
+ } from "./chunk-65B3PDY7.js";
9
9
  import {
10
10
  toOptionalTrimmed
11
- } from "./chunk-FX4PX3SA.js";
11
+ } from "./chunk-FMOFCEAA.js";
12
12
  import {
13
13
  pluginCatalogRuntime
14
- } from "./chunk-RULIISEI.js";
14
+ } from "./chunk-7S2JVUWS.js";
15
15
  import {
16
16
  setSpanAttributes,
17
17
  setSpanStatus,
18
18
  withSpan
19
- } from "./chunk-VHSEMJTS.js";
19
+ } from "./chunk-32CCG4WP.js";
20
20
 
21
21
  // src/chat/sandbox/resources.ts
22
22
  var configuredResources;
@@ -1170,6 +1170,7 @@ export {
1170
1170
  bindSandboxFileSystem,
1171
1171
  createSandboxSession,
1172
1172
  stopSession,
1173
+ getCachedSnapshot,
1173
1174
  resolve,
1174
1175
  isMissingError
1175
1176
  };
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  FUNCTION_TIMEOUT_BUFFER_SECONDS,
3
3
  getChatConfig
4
- } from "./chunk-FX4PX3SA.js";
4
+ } from "./chunk-FMOFCEAA.js";
5
5
 
6
6
  // src/chat/runtime/request-deadline.ts
7
7
  import { AsyncLocalStorage } from "async_hooks";
@@ -13,7 +13,7 @@ import {
13
13
  instructionProvenanceFor,
14
14
  sanitizePostgresJson,
15
15
  withConversationEventLock
16
- } from "./chunk-LPLVNMVN.js";
16
+ } from "./chunk-RQQTOF3H.js";
17
17
  import {
18
18
  SANDBOX_REPOS_ROOT,
19
19
  SANDBOX_WORKSPACE_ROOT,
@@ -24,14 +24,14 @@ import {
24
24
  fenceLock,
25
25
  getStateAdapter,
26
26
  withLock
27
- } from "./chunk-BXBZDV3C.js";
27
+ } from "./chunk-65B3PDY7.js";
28
28
  import {
29
29
  botConfig,
30
30
  completeText,
31
31
  escapeXml,
32
32
  resolveGatewayModel,
33
33
  unwrapCurrentInstruction
34
- } from "./chunk-FX4PX3SA.js";
34
+ } from "./chunk-FMOFCEAA.js";
35
35
  import {
36
36
  parseSlackMessageTs,
37
37
  toStoredSlackActor
@@ -41,7 +41,7 @@ import {
41
41
  logException,
42
42
  logWarn,
43
43
  setSpanAttributes
44
- } from "./chunk-VHSEMJTS.js";
44
+ } from "./chunk-32CCG4WP.js";
45
45
 
46
46
  // src/chat/turn-context-tag.ts
47
47
  var TURN_CONTEXT_TAG = "runtime-turn-context";
@@ -2054,9 +2054,9 @@ async function findGitRoot(fs, cwd) {
2054
2054
  current = parent;
2055
2055
  }
2056
2056
  }
2057
- async function findSingleRepositoryDirectory(fs) {
2057
+ async function listRepositoryDirectories(fs) {
2058
2058
  if (!await directoryExists(fs, SANDBOX_REPOS_ROOT)) {
2059
- return void 0;
2059
+ return [];
2060
2060
  }
2061
2061
  const entries = await fs.readdir(SANDBOX_REPOS_ROOT);
2062
2062
  const repositories = [];
@@ -2064,12 +2064,11 @@ async function findSingleRepositoryDirectory(fs) {
2064
2064
  const candidate = path2.posix.join(SANDBOX_REPOS_ROOT, entry);
2065
2065
  if (await directoryExists(fs, candidate) && await pathExists(fs, path2.posix.join(candidate, ".git"))) {
2066
2066
  repositories.push(candidate);
2067
- if (repositories.length > 1) {
2068
- return void 0;
2069
- }
2070
2067
  }
2071
2068
  }
2072
- return repositories[0];
2069
+ return repositories.sort(
2070
+ (left, right) => left < right ? -1 : left > right ? 1 : 0
2071
+ );
2073
2072
  }
2074
2073
  async function readInstructionFile(fs, filePath) {
2075
2074
  try {
@@ -2098,7 +2097,10 @@ async function resolveRepositoryInstructions(args) {
2098
2097
  }
2099
2098
  directories.reverse();
2100
2099
  const sources = [];
2101
- let remaining = MAX_REPOSITORY_INSTRUCTIONS_BYTES;
2100
+ let remaining = Math.max(
2101
+ 0,
2102
+ args.maxBytes ?? MAX_REPOSITORY_INSTRUCTIONS_BYTES
2103
+ );
2102
2104
  for (const directory of directories) {
2103
2105
  if (remaining <= 0) {
2104
2106
  break;
@@ -2116,10 +2118,67 @@ async function resolveRepositoryInstructions(args) {
2116
2118
  if (sources.length === 0) {
2117
2119
  return void 0;
2118
2120
  }
2119
- const text = sources.map((source) => source.content).join("\n\n");
2121
+ const text = formatInstructionSources(sources);
2120
2122
  const fingerprint = createHash2("sha256").update(JSON.stringify({ directory: args.cwd, sources })).digest("hex");
2121
2123
  return { directory: args.cwd, fingerprint, sources, text };
2122
2124
  }
2125
+ function formatInstructionSources(sources) {
2126
+ if (sources.length === 1) {
2127
+ return sources[0].content;
2128
+ }
2129
+ return sources.map(
2130
+ (source) => `## ${path2.posix.dirname(source.path)}
2131
+
2132
+ ${source.content}`
2133
+ ).join("\n\n");
2134
+ }
2135
+ function mergeRepositoryInstructions(bundles) {
2136
+ if (bundles.length === 0) {
2137
+ return void 0;
2138
+ }
2139
+ if (bundles.length === 1) {
2140
+ return bundles[0];
2141
+ }
2142
+ const sources = bundles.flatMap((bundle) => bundle.sources);
2143
+ const text = formatInstructionSources(sources);
2144
+ const fingerprint = createHash2("sha256").update(
2145
+ JSON.stringify({
2146
+ directories: bundles.map((bundle) => bundle.directory ?? null),
2147
+ sources
2148
+ })
2149
+ ).digest("hex");
2150
+ return { fingerprint, sources, text };
2151
+ }
2152
+ async function resolveRepositoryInstructionsForDirectories(args) {
2153
+ const uniqueDirectories = [
2154
+ ...new Set(
2155
+ args.directories.filter(
2156
+ (directory) => directory === SANDBOX_WORKSPACE_ROOT || directory.startsWith(`${SANDBOX_WORKSPACE_ROOT}/`)
2157
+ )
2158
+ )
2159
+ ].sort((left, right) => left < right ? -1 : left > right ? 1 : 0);
2160
+ let remaining = MAX_REPOSITORY_INSTRUCTIONS_BYTES;
2161
+ const bundles = [];
2162
+ for (const directory of uniqueDirectories) {
2163
+ if (remaining <= 0) {
2164
+ break;
2165
+ }
2166
+ const instructions = await resolveRepositoryInstructions({
2167
+ cwd: directory,
2168
+ fs: args.fs,
2169
+ maxBytes: remaining
2170
+ });
2171
+ if (!instructions) {
2172
+ continue;
2173
+ }
2174
+ bundles.push(instructions);
2175
+ remaining -= instructions.sources.reduce(
2176
+ (total, source) => total + Buffer.byteLength(source.content, "utf8"),
2177
+ 0
2178
+ );
2179
+ }
2180
+ return mergeRepositoryInstructions(bundles);
2181
+ }
2123
2182
  function renderAgentsInstructions(args) {
2124
2183
  const directory = args.directory ? ` for ${args.directory}` : "";
2125
2184
  return `# AGENTS.md instructions${directory}
@@ -3231,8 +3290,8 @@ export {
3231
3290
  collectFiles,
3232
3291
  AGENTS_REPLACEMENT_NOTICE,
3233
3292
  AGENTS_REMOVAL_NOTICE,
3234
- findSingleRepositoryDirectory,
3235
- resolveRepositoryInstructions,
3293
+ listRepositoryDirectories,
3294
+ resolveRepositoryInstructionsForDirectories,
3236
3295
  renderAgentsInstructions,
3237
3296
  buildAgentsInstructionsMessage,
3238
3297
  findVisibleAgentsInstructions,
@@ -3,7 +3,7 @@ import {
3
3
  toCanonicalInputMessage,
4
4
  toCanonicalOutputMessage,
5
5
  toGenAiMessagesTraceAttributes
6
- } from "./chunk-RBV4JHCP.js";
6
+ } from "./chunk-ZUKU2Y3J.js";
7
7
  import {
8
8
  extractGenAiUsageAttributes,
9
9
  logException,
@@ -11,7 +11,7 @@ import {
11
11
  normalizeGenAiFinishReason,
12
12
  serializeGenAiAttribute,
13
13
  withSpan
14
- } from "./chunk-VHSEMJTS.js";
14
+ } from "./chunk-32CCG4WP.js";
15
15
 
16
16
  // src/chat/services/provider-error.ts
17
17
  var ProviderError = class extends Error {
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  getTurnRequestDeadline
3
- } from "./chunk-RYYEHWIL.js";
3
+ } from "./chunk-DKO4RRGJ.js";
4
4
  import {
5
5
  CONVERSATION_WORK_CHECK_IN_INTERVAL_MS,
6
6
  CONVERSATION_WORK_MAX_RETRIES,
@@ -21,20 +21,20 @@ import {
21
21
  releaseConversationWork,
22
22
  requestAnotherSlice,
23
23
  startConversationWork
24
- } from "./chunk-NAGI2XH3.js";
24
+ } from "./chunk-6YXCG2XL.js";
25
25
  import {
26
26
  ConversationQueueMessageRejectedError
27
27
  } from "./chunk-JAL3CH4G.js";
28
28
  import {
29
29
  getChatConfig,
30
30
  isProviderRetryError
31
- } from "./chunk-FX4PX3SA.js";
31
+ } from "./chunk-FMOFCEAA.js";
32
32
  import {
33
33
  logException,
34
34
  logInfo,
35
35
  logWarn,
36
36
  withLogContext
37
- } from "./chunk-VHSEMJTS.js";
37
+ } from "./chunk-32CCG4WP.js";
38
38
 
39
39
  // src/chat/task-execution/worker.ts
40
40
  var CONVERSATION_WORK_DEFER_DELAY_MS = 15e3;
@@ -5,19 +5,19 @@ import {
5
5
  isDmChannel,
6
6
  normalizeSlackConversationId,
7
7
  withSlackRetries
8
- } from "./chunk-YHCTPDXS.js";
8
+ } from "./chunk-5WDDWMQ7.js";
9
9
  import {
10
10
  parseDestination
11
- } from "./chunk-LPLVNMVN.js";
11
+ } from "./chunk-RQQTOF3H.js";
12
12
  import {
13
13
  getStateAdapter
14
- } from "./chunk-BXBZDV3C.js";
14
+ } from "./chunk-65B3PDY7.js";
15
15
  import {
16
16
  normalizeSlackEmojiName
17
- } from "./chunk-FX4PX3SA.js";
17
+ } from "./chunk-FMOFCEAA.js";
18
18
  import {
19
19
  pluginCatalogRuntime
20
- } from "./chunk-RULIISEI.js";
20
+ } from "./chunk-7S2JVUWS.js";
21
21
  import {
22
22
  parseSlackMessageTs,
23
23
  parseSlackUserId
@@ -26,7 +26,7 @@ import {
26
26
  isRecord,
27
27
  logInfo,
28
28
  logWarn
29
- } from "./chunk-VHSEMJTS.js";
29
+ } from "./chunk-32CCG4WP.js";
30
30
 
31
31
  // src/chat/slack/outbound.ts
32
32
  var MAX_SLACK_MESSAGE_TEXT_CHARS = 4e4;
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  pluginCatalogRuntime
3
- } from "./chunk-RULIISEI.js";
3
+ } from "./chunk-7S2JVUWS.js";
4
4
 
5
5
  // src/chat/plugins/validation.ts
6
6
  import { isDeepStrictEqual } from "util";