@sentry/junior 0.309.0 → 0.311.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 (117) hide show
  1. package/dist/adapter-B1wujchl.js +259 -0
  2. package/dist/{adapter-context-1YUbMpD3.js → adapter-context-G2M0y6rP.js} +2 -2
  3. package/dist/{admin-u30A8TcD.js → admin-DCiBhUT1.js} +1 -2
  4. package/dist/{agent-runner-sJLhgPQV.js → agent-runner-BVHPUIc8.js} +695 -1817
  5. package/dist/api/schema.d.ts +2 -2
  6. package/dist/api/schema.js +8 -7
  7. package/dist/api.d.ts +21 -3
  8. package/dist/api.js +1479 -372
  9. package/dist/{app-B_7Wn0en.d.ts → app-Cw5Vy6H6.d.ts} +14 -3
  10. package/dist/app.d.ts +2 -2
  11. package/dist/app.js +233 -506
  12. package/dist/{background-compaction-queue-CUJXVKG3.js → background-compaction-queue-CJDnWVOJ.js} +4 -4
  13. package/dist/{briefs-BHi70IR5.js → briefs-BDjnug6Y.js} +3 -3
  14. package/dist/{catalog-runtime-Chc_IP2o.js → catalog-runtime-DMY3VV-D.js} +1 -1
  15. package/dist/cli/chat.js +16 -16
  16. package/dist/cli/check.js +23 -29
  17. package/dist/cli/init.js +1 -6
  18. package/dist/cli/main.js +3 -3
  19. package/dist/cli/plugins.js +8 -7
  20. package/dist/cli/snapshot-create.js +5 -5
  21. package/dist/cli/upgrade.d.ts +1 -1
  22. package/dist/cli/upgrade.js +3 -3
  23. package/dist/{config-BIyIdTtA.js → config-BrXDQefC.js} +239 -5
  24. package/dist/{continue-in-slack-BQJBfiQh.js → continue-in-slack-DNXSC9So.js} +6 -5
  25. package/dist/{conversation-CzrLhdHG.js → conversation-ca__NDQW.js} +48 -9
  26. package/dist/{conversation-feed-B9e3_gxz.js → conversation-feed-DkinDu5o.js} +15 -6
  27. package/dist/{conversation-privacy-CkTW29hd.js → conversation-privacy-DxttrKb9.js} +1 -1
  28. package/dist/{conversation-turn-CZaYQUum.js → conversation-turn-DWw7Xhdr.js} +42 -39
  29. package/dist/{credential-sync-58m_CyIJ.js → credential-sync-Bk8wGb8Y.js} +15 -16
  30. package/dist/{db-B4Hjxr-u.d.ts → db-7ETESH44.d.ts} +3 -1
  31. package/dist/{db-CFUpEZi9.js → db-DTxzH7u5.js} +1618 -1041
  32. package/dist/{executor-DXL0O0MV.js → executor-DqTiYj9S.js} +454 -96
  33. package/dist/{history-N7IVbUom.js → history-CYstOMKX.js} +6 -0
  34. package/dist/{html-CaBu2VbT.js → html-B9Sl4Axb.js} +6 -6
  35. package/dist/{install-DhTBUUov.js → install-Sg4ePfLl.js} +2 -2
  36. package/dist/instrumentation.js +3 -3
  37. package/dist/{lineage-CxtOI2_p.js → lineage-BHAMpNKr.js} +2 -2
  38. package/dist/{logging-BNUovdcX.js → logging-FjclQsXu.js} +47 -9
  39. package/dist/{message-DcUsS2vg.js → message-CJ7_RL50.js} +5 -8
  40. package/dist/{model-input-o3rEqgwM.js → model-input-CMLh4Cwq.js} +3 -3
  41. package/dist/nitro.d.ts +1 -1
  42. package/dist/nitro.js +3 -3
  43. package/dist/{oauth-callback-server-1Fizd1EM.js → oauth-callback-server-RVcbiDjL.js} +2 -2
  44. package/dist/{oauth-relay-DOwngqdM.js → oauth-relay-Bu9kkaQu.js} +1 -1
  45. package/dist/{projection-Ce4pmhKP.js → projection-Cns7XwWa.js} +9206 -5318
  46. package/dist/{prompt-DEqjDVMs.js → prompt-CDqcsDYC.js} +4 -4
  47. package/dist/{registry-CNE4ZBnG.js → registry-BPwuOP2O.js} +5 -8
  48. package/dist/{resolve-qbPg-aC-.js → resolve-BK29bBry.js} +3 -3
  49. package/dist/rule-DAxQY-1h.js +20 -0
  50. package/dist/{runner-eGIxpAMf.js → runner-BcAE-cJm.js} +10 -10
  51. package/dist/{sandbox-egress-signals-DMFB1kCp.js → sandbox-egress-signals-C-q0go5b.js} +1 -1
  52. package/dist/{schedule-Cire6NU7.js → schedule-BLJ476XQ.js} +209 -43
  53. package/dist/{schema-CfIey9Ao.js → schema-BLgSZXcL.js} +255 -49
  54. package/dist/{schema-DriSvB40.d.ts → schema-DYcJeV7d.d.ts} +701 -62
  55. package/dist/{service-account-Cw_LWZ4-.js → service-account-gN0zqf0S.js} +68 -68
  56. package/dist/{service-account-B1VXCTqg.js → service-account-iJoCtkHR.js} +3 -3
  57. package/dist/{skills-Zg8-vrje.js → skills-BoZ80epJ.js} +77 -31
  58. package/dist/{slack-conversation-unfurl-DA51qH0c.js → slack-conversation-unfurl-CogYrITA.js} +8 -10
  59. package/dist/{spawn-DBi4-zD8.js → spawn-Dk92r7mX.js} +5 -6
  60. package/dist/{state-C-Ftk23K.js → state-DH3Cmgp3.js} +4 -4
  61. package/dist/{stop-D9xideLM.js → stop-CYsfc0Ed.js} +1064 -314
  62. package/dist/{store-BjIXA0Al.js → store-DmmMIrQi.js} +5 -5
  63. package/dist/{task-queue-D0_qbnpo.js → task-queue-C_zldF5J.js} +3 -3
  64. package/dist/{task-runner-DQMq4XY0.js → task-runner-C7oCJQIx.js} +21 -14
  65. package/dist/{thread-context-D0i1e-5O.js → thread-context-BW2BsQbH.js} +13 -11
  66. package/dist/{turn-session-routing-C0l68I_O.js → turn-session-routing-Xh_2nSQe.js} +52 -54
  67. package/dist/{validation-CRbvRPvu.js → validation-DrJd0nnq.js} +1 -1
  68. package/dist/{version-BYdVs12p.js → version-CNKZ8owc.js} +1 -1
  69. package/dist/version.js +1 -1
  70. package/dist/{warmup-DN9OHN1-.js → warmup-BWdHew2H.js} +14289 -7197
  71. package/dist/{web-message-id-BT8Mg8LL.js → web-message-id-Ch5dPq-a.js} +32 -144
  72. package/dist/{worker-C9ZfJXmV.js → worker-t9qpu_Zx.js} +7 -8
  73. package/migrations/0124_artifact_visibility.sql +9 -0
  74. package/migrations/0125_artifact_public_sha_index.sql +1 -0
  75. package/migrations/0126_artifact_drop_public.sql +8 -0
  76. package/migrations/0127_artifact_path.sql +4 -0
  77. package/migrations/0128_artifact_path_index.sql +1 -0
  78. package/migrations/0129_review_item_answered_index.sql +1 -0
  79. package/migrations/0130_review_item_status_index.sql +1 -0
  80. package/migrations/0131_brief_outcome_status.sql +1 -0
  81. package/migrations/0132_brief_outcome_status_backfill.sql +7 -0
  82. package/migrations/0133_brief_created_at_index.sql +1 -0
  83. package/migrations/0134_slack_person_search_index.sql +1 -0
  84. package/migrations/0135_code_change_size.sql +3 -0
  85. package/migrations/0136_merge_conflict_notice_dismiss.sql +16 -0
  86. package/migrations/0137_inbox_snoozes.sql +27 -0
  87. package/migrations/0138_code_change_search_index.sql +2 -0
  88. package/migrations/0139_review_item_owner.sql +22 -0
  89. package/migrations/0140_review_item_owner_index.sql +1 -0
  90. package/migrations/0141_memory_core_adoption.sql +89 -0
  91. package/migrations/0142_memory_core_indexes.sql +17 -0
  92. package/migrations/meta/0124_snapshot.json +5516 -0
  93. package/migrations/meta/0125_snapshot.json +5516 -0
  94. package/migrations/meta/0126_snapshot.json +5488 -0
  95. package/migrations/meta/0127_snapshot.json +5519 -0
  96. package/migrations/meta/0128_snapshot.json +5519 -0
  97. package/migrations/meta/0129_snapshot.json +5547 -0
  98. package/migrations/meta/0130_snapshot.json +5563 -0
  99. package/migrations/meta/0131_snapshot.json +5569 -0
  100. package/migrations/meta/0132_snapshot.json +5569 -0
  101. package/migrations/meta/0133_snapshot.json +5590 -0
  102. package/migrations/meta/0134_snapshot.json +5606 -0
  103. package/migrations/meta/0135_snapshot.json +5624 -0
  104. package/migrations/meta/0136_snapshot.json +5624 -0
  105. package/migrations/meta/0137_snapshot.json +5864 -0
  106. package/migrations/meta/0138_snapshot.json +5894 -0
  107. package/migrations/meta/0139_snapshot.json +5898 -0
  108. package/migrations/meta/0140_snapshot.json +5919 -0
  109. package/migrations/meta/0141_snapshot.json +6429 -0
  110. package/migrations/meta/0142_snapshot.json +6457 -0
  111. package/migrations/meta/_journal.json +134 -1
  112. package/package.json +6 -7
  113. package/dist/result-ZGnDzcsb.js +0 -548
  114. package/dist/session-stop-P2XdTiwr.js +0 -4252
  115. package/dist/turn-user-message-nBVvOXjs.js +0 -364
  116. package/dist/users-DdjMjbmM.js +0 -181
  117. package/dist/viewer-DudYrQGj.js +0 -212
@@ -1,7 +1,7 @@
1
- import { A as searchWeb$1, C as completeObject$1, D as generateImages$1, E as gatewayCostUsd, S as completeDecision$1, T as embedTexts$1, Y as ProviderError, Z as createProviderError, b as GEN_AI_PROVIDER_NAME, it as resolveGatewayCredential, nt as isProviderRetryError, w as completeText$1, x as GEN_AI_SERVER_ADDRESS } from "./config-BIyIdTtA.js";
2
- import { E as withSpan, _ as runBestEffort, a as extractGenAiUsageSummary, i as extractGenAiUsageAttributes, p as logException } from "./logging-BNUovdcX.js";
3
- import { r as getConversationEventStore, vt as agentTurnCostUsd } from "./db-CFUpEZi9.js";
4
- import { I as conversationBriefSchema, L as parseBriefInput, P as briefOutcomeStatusSchema } from "./conversation-CzrLhdHG.js";
1
+ import { A as searchWeb$1, C as completeObject$1, D as generateImages$1, E as gatewayCostUsd, S as completeDecision$1, T as embedTexts$1, b as GEN_AI_PROVIDER_NAME, ct as createProviderError, ht as resolveGatewayCredential, ot as ProviderError, pt as isProviderRetryError, w as completeText$1, x as GEN_AI_SERVER_ADDRESS } from "./config-BrXDQefC.js";
2
+ import { E as withSpan, _ as runBestEffort, a as extractGenAiUsageSummary, i as extractGenAiUsageAttributes, p as logException } from "./logging-FjclQsXu.js";
3
+ import { Tn as agentTurnCostUsd, r as getConversationEventStore } from "./db-DTxzH7u5.js";
4
+ import { F as briefOutcomeStatusSchema, L as conversationBriefSchema, R as parseBriefInput } from "./conversation-ca__NDQW.js";
5
5
  import * as z from "zod";
6
6
  import { createGatewayProvider } from "@ai-sdk/gateway";
7
7
  import { transcribe } from "ai";
@@ -1,5 +1,5 @@
1
1
  import { n as normalizePluginPackageNames, o as pluginRoots, t as discoverInstalledPluginPackageContent } from "./package-discovery-DD9vencX.js";
2
- import { b as setSpanAttributes, h as logWarn, m as logInfo } from "./logging-BNUovdcX.js";
2
+ import { b as setSpanAttributes, h as logWarn, m as logInfo } from "./logging-FjclQsXu.js";
3
3
  import { o as isUserActor, s as parseActorUserId } from "./actor-BsBdxDXQ.js";
4
4
  import * as z from "zod";
5
5
  import path from "node:path";
@@ -10,9 +10,6 @@ import { readFileSync, readdirSync, statSync } from "node:fs";
10
10
  function setDefined$1(target, key, value) {
11
11
  if (value !== void 0) target[key] = value;
12
12
  }
13
- function isRecord(value) {
14
- return Boolean(value && typeof value === "object" && !Array.isArray(value));
15
- }
16
13
  function unqualifyManifestToken(name, value) {
17
14
  if (typeof name === "string" && typeof value === "string" && value.startsWith(`${name}.`)) return value.slice(name.length + 1);
18
15
  return value;
@@ -22,7 +19,7 @@ function inlineTokenListSource(name, values) {
22
19
  return values.map((value) => unqualifyManifestToken(name, value));
23
20
  }
24
21
  function inlineCredentialsSource(credentials) {
25
- if (credentials === void 0 || !isRecord(credentials)) return credentials;
22
+ if (typeof credentials !== "object" || credentials === null || Array.isArray(credentials)) return credentials;
26
23
  const result = {};
27
24
  setDefined$1(result, "type", credentials.type);
28
25
  setDefined$1(result, "domains", credentials.domains);
@@ -57,7 +54,7 @@ function accountsSource(accounts) {
57
54
  return result;
58
55
  }
59
56
  function inlineMcpSource(mcp) {
60
- if (mcp === void 0 || !isRecord(mcp)) return mcp;
57
+ if (typeof mcp !== "object" || mcp === null || Array.isArray(mcp)) return mcp;
61
58
  const result = {};
62
59
  setDefined$1(result, "transport", mcp.transport);
63
60
  setDefined$1(result, "url", mcp.url);
@@ -69,7 +66,7 @@ function inlineMcpSource(mcp) {
69
66
  return result;
70
67
  }
71
68
  function inlineOauthSource(oauth) {
72
- if (oauth === void 0 || !isRecord(oauth)) return oauth;
69
+ if (typeof oauth !== "object" || oauth === null || Array.isArray(oauth)) return oauth;
73
70
  const result = {};
74
71
  setDefined$1(result, "client-id-env", oauth.clientIdEnv);
75
72
  setDefined$1(result, "client-secret-env", oauth.clientSecretEnv);
@@ -83,7 +80,7 @@ function inlineOauthSource(oauth) {
83
80
  return result;
84
81
  }
85
82
  function inlineTargetSource(name, target) {
86
- if (target === void 0 || !isRecord(target)) return target;
83
+ if (typeof target !== "object" || target === null || Array.isArray(target)) return target;
87
84
  const result = {};
88
85
  setDefined$1(result, "type", target.type);
89
86
  setDefined$1(result, "config-key", unqualifyManifestToken(name, target.configKey));
@@ -1,6 +1,6 @@
1
- import { i as trace, n as postinstall, o as getSandboxResources, t as dependencies } from "./install-DhTBUUov.js";
2
- import { Ns as sleep, Yi as isStale, Zi as getSandboxProvider, qi as create } from "./projection-Ce4pmhKP.js";
3
- import { et as getStateAdapter } from "./db-CFUpEZi9.js";
1
+ import { i as trace, n as postinstall, o as getSandboxResources, t as dependencies } from "./install-Sg4ePfLl.js";
2
+ import { Ni as getSandboxProvider, ji as isStale, ki as create, os as sleep } from "./projection-Cns7XwWa.js";
3
+ import { i as getStateAdapter } from "./adapter-B1wujchl.js";
4
4
  import * as z from "zod";
5
5
  // src/chat/sandbox/snapshot/resolve.ts
6
6
  const SNAPSHOT_CACHE_PREFIX = "junior:sandbox_snapshot_profile:v2";
@@ -0,0 +1,20 @@
1
+ // src/chat/gateway-providers/rule.ts
2
+ /**
3
+ * The routing rule of the "Enabled providers" admin setting.
4
+ *
5
+ * This module imports nothing, so the dashboard client bundle can use it.
6
+ */
7
+ /**
8
+ * Return the AI Gateway `only` list for one model, or undefined to send none.
9
+ *
10
+ * `enabled` is null when every provider is enabled. `served` lists the
11
+ * providers that serve the model. A model that no enabled provider serves
12
+ * stays unfiltered, so unchecking its providers can never break it. A filter
13
+ * that keeps every provider of the model changes nothing, so it is not sent.
14
+ */
15
+ function gatewayOnlyProviders(enabled, served) {
16
+ if (enabled === null) return void 0;
17
+ const only = served.filter((provider) => enabled.includes(provider));
18
+ return only.length > 0 && only.length < served.length ? only : void 0;
19
+ }
20
+ export { gatewayOnlyProviders as t };
@@ -1,13 +1,13 @@
1
- import { q as messageCardText } from "./conversation-CzrLhdHG.js";
2
- import { a as buildDeliveredTurnStatePatch, o as loadPendingMessageCards, r as completeAuthPauseTurn, t as buildTurnThreadContext } from "./thread-context-D0i1e-5O.js";
3
- import { A as normalizeConversationText, H as authorizationId, O as latestConversationMessageSeq, P as upsertConversationMessage, a as loadProjection, b as persistConversationMessages, cn as getAssistantReplyText, d as recordAuthorizationCompleted, et as saveTurnCheckpoint, j as recordDeliveredAssistantMessage, k as markConversationMessage, t as commitAcceptedReply, v as hydrateConversationMessages, vn as persistWithRetry } from "./projection-Ce4pmhKP.js";
4
- import { S as setTags, T as withLogContext, p as logException } from "./logging-BNUovdcX.js";
5
- import { n as scheduleSessionCompletedPluginTasks, t as processPluginTask } from "./task-runner-DQMq4XY0.js";
6
- import { a as getPersistedThreadState, c as coerceThreadConversationState, i as getPersistedSandboxState, s as persistThreadStateById } from "./turn-session-routing-C0l68I_O.js";
7
- import { _ as ConversationTurnLifecycleService, g as startActiveTurn, h as markTurnFailed } from "./turn-user-message-nBVvOXjs.js";
8
- import { L as finalizeFailedTurnReplyWithEvent } from "./agent-runner-sJLhgPQV.js";
9
- import { p as credentialContextForActor } from "./registry-CNE4ZBnG.js";
10
- import { P as SYSTEM_IDENTITY_ID, a as getConversationStore, r as getConversationEventStore } from "./db-CFUpEZi9.js";
1
+ import { Y as messageCardText } from "./conversation-ca__NDQW.js";
2
+ import { a as buildDeliveredTurnStatePatch, o as loadPendingMessageCards, r as completeAuthPauseTurn, t as buildTurnThreadContext } from "./thread-context-BW2BsQbH.js";
3
+ import { A as latestConversationMessageSeq, I as upsertConversationMessage, M as normalizeConversationText, N as recordDeliveredAssistantMessage, S as persistConversationMessages, W as authorizationId, b as hydrateConversationMessages, dn as getAssistantReplyText, f as recordAuthorizationCompleted, j as markConversationMessage, nt as saveTurnCheckpoint, o as loadProjection, t as commitAcceptedReply, xn as persistWithRetry } from "./projection-Cns7XwWa.js";
4
+ import { S as setTags, T as withLogContext, p as logException } from "./logging-FjclQsXu.js";
5
+ import { n as scheduleSessionCompletedPluginTasks, t as processPluginTask } from "./task-runner-C7oCJQIx.js";
6
+ import { a as getPersistedThreadState, c as coerceThreadConversationState, i as getPersistedSandboxState, s as persistThreadStateById } from "./turn-session-routing-Xh_2nSQe.js";
7
+ import { Ir as ConversationTurnLifecycleService, Mr as markTurnFailed, Nr as startActiveTurn } from "./warmup-BWdHew2H.js";
8
+ import { F as finalizeFailedTurnReplyWithEvent } from "./agent-runner-BVHPUIc8.js";
9
+ import { p as credentialContextForActor } from "./registry-BPwuOP2O.js";
10
+ import { Yt as SYSTEM_IDENTITY_ID, a as getConversationStore, r as getConversationEventStore } from "./db-DTxzH7u5.js";
11
11
  import { randomUUID } from "node:crypto";
12
12
  import { createLocalSource, localDestinationSchema } from "@sentry/junior-plugin-api";
13
13
  // src/chat/local/runner.ts
@@ -1,4 +1,4 @@
1
- import { xa as sandboxEgressSignalsResponseSchema } from "./projection-Ce4pmhKP.js";
1
+ import { ra as sandboxEgressSignalsResponseSchema } from "./projection-Cns7XwWa.js";
2
2
  // src/chat/local/sandbox-egress-signals.ts
3
3
  const SANDBOX_EGRESS_SIGNALS_PATH = "/api/internal/sandbox-egress/signals";
4
4
  const LOCAL_DEV_SERVER_TIMEOUT_MS = 1e3;
@@ -1,4 +1,4 @@
1
- import { i as actorIdentitySchema } from "./conversation-CzrLhdHG.js";
1
+ import { i as actorIdentitySchema } from "./conversation-ca__NDQW.js";
2
2
  import * as z from "zod";
3
3
  import { actorUserIdSchema, destinationVisibilitySchema, eventMatchFieldsSchema, eventMatchSchema, eventReachSchema, eventTypeSchema, pluginEventTypeSchema, slackDestinationSchema, taskOutcomeSchema } from "@sentry/junior-plugin-api";
4
4
  // src/chat/automations/task.ts
@@ -43,6 +43,213 @@ function automationTaskColumns(task) {
43
43
  skill: task.skill
44
44
  };
45
45
  }
46
+ // src/chat/tools/runtime/user-input-request.ts
47
+ const USER_INPUT_LIMITS = {
48
+ maxButtonOptions: 5,
49
+ maxDescriptionChars: 200,
50
+ maxFields: 4,
51
+ maxLabelChars: 75,
52
+ maxOptions: 10,
53
+ maxTextChars: 3e3,
54
+ maxQuestionChars: 3e3,
55
+ minOptions: 2
56
+ };
57
+ const labelSchema = z.string().trim().min(1).max(USER_INPUT_LIMITS.maxLabelChars);
58
+ const descriptionSchema = z.string().trim().min(1).max(USER_INPUT_LIMITS.maxDescriptionChars).optional();
59
+ const optionSchema = z.object({
60
+ label: labelSchema.describe("Short choice text, such as `Accept` or `Decline`. The answer uses this exact text."),
61
+ description: descriptionSchema.describe("Optional short note about what this choice does."),
62
+ recommended: z.boolean().optional().describe("Set true on the choice that you recommend, put that choice first, and say why in its description. A `choice` field can recommend one option.")
63
+ });
64
+ const fieldBase = {
65
+ id: z.string().regex(/^[a-z][a-z0-9_]{0,31}$/).describe("Stable key for this field, such as `approach`."),
66
+ label: labelSchema.describe("Short field name, such as `Approach`."),
67
+ description: descriptionSchema.describe("Optional short help text for this field.")
68
+ };
69
+ function optionsSchema(minOptions) {
70
+ return z.array(optionSchema).min(minOptions).max(USER_INPUT_LIMITS.maxOptions).describe("Choices in display order.");
71
+ }
72
+ function requestSchema(minOptions) {
73
+ const userInputFieldSchema = z.discriminatedUnion("kind", [
74
+ z.object({
75
+ ...fieldBase,
76
+ kind: z.literal("choice").describe("The person picks one option."),
77
+ options: optionsSchema(minOptions)
78
+ }),
79
+ z.object({
80
+ ...fieldBase,
81
+ kind: z.literal("multi_choice").describe("The person picks any number of options."),
82
+ options: optionsSchema(minOptions)
83
+ }),
84
+ z.object({
85
+ ...fieldBase,
86
+ kind: z.literal("text").describe("The person types a short answer.")
87
+ })
88
+ ]);
89
+ return z.object({
90
+ question: z.string().trim().min(1).max(USER_INPUT_LIMITS.maxQuestionChars).describe("The question, in markdown. Include the facts the person needs to decide."),
91
+ fields: z.array(userInputFieldSchema).min(1).max(USER_INPUT_LIMITS.maxFields).describe("What to ask, in display order. Use one `choice` field for a simple decision.")
92
+ }).superRefine((request, context) => {
93
+ const ids = /* @__PURE__ */ new Set();
94
+ for (const field of request.fields) {
95
+ if (ids.has(field.id)) context.addIssue({
96
+ code: "custom",
97
+ message: "Each field needs a different id."
98
+ });
99
+ ids.add(field.id);
100
+ if (field.kind === "text") continue;
101
+ const labels = field.options.map((option) => option.label.toLowerCase());
102
+ if (new Set(labels).size !== labels.length) context.addIssue({
103
+ code: "custom",
104
+ message: "Each choice of a field needs a different label."
105
+ });
106
+ if (field.kind === "choice" && field.options.filter((option) => option.recommended).length > 1) context.addIssue({
107
+ code: "custom",
108
+ message: "A `choice` field can recommend only one option."
109
+ });
110
+ }
111
+ });
112
+ }
113
+ /** A request that an agent writes. Each choice field has two options or more. */
114
+ const userInputRequestSchema = requestSchema(USER_INPUT_LIMITS.minOptions);
115
+ /**
116
+ * A saved request. A plugin item can have one choice, such as Resume, so a
117
+ * saved choice field can have one option. Agents still need two.
118
+ */
119
+ const savedUserInputRequestSchema = requestSchema(1);
120
+ /**
121
+ * Label and help text of the free-text input that every form adds after the
122
+ * fields. The text goes with the picked answers and does not replace them, so
123
+ * every surface says that in the same words.
124
+ */
125
+ const USER_INPUT_NOTE = {
126
+ label: "Anything else?",
127
+ description: "Optional. This note is sent together with your answers above."
128
+ };
129
+ /**
130
+ * Return the single choice field of a request that a surface can show as
131
+ * one row of buttons, where one click is the whole answer.
132
+ */
133
+ function buttonUserInputField(request) {
134
+ const [field, ...rest] = request.fields;
135
+ if (rest.length || field?.kind !== "choice") return void 0;
136
+ return field.options.length <= USER_INPUT_LIMITS.maxButtonOptions ? field : void 0;
137
+ }
138
+ /**
139
+ * Keep only answer values that match the request: known field ids, known
140
+ * option labels, one value for a `choice` field, and trimmed text.
141
+ */
142
+ function normalizeUserInputAnswer(request, answer) {
143
+ const values = {};
144
+ for (const field of request.fields) {
145
+ const raw = (answer.values[field.id] ?? []).map((value) => value.trim()).filter(Boolean);
146
+ if (field.kind === "text") {
147
+ const text = raw.join("\n").slice(0, USER_INPUT_LIMITS.maxTextChars);
148
+ if (text) values[field.id] = [text];
149
+ continue;
150
+ }
151
+ const picked = field.options.map((option) => option.label).filter((label) => raw.includes(label));
152
+ const kept = field.kind === "choice" ? picked.slice(0, 1) : picked;
153
+ if (kept.length) values[field.id] = kept;
154
+ }
155
+ const other = answer.other?.trim().slice(0, USER_INPUT_LIMITS.maxTextChars);
156
+ return {
157
+ requestId: answer.requestId,
158
+ values,
159
+ ...other ? { other } : void 0
160
+ };
161
+ }
162
+ /**
163
+ * Return the option labels that an answer picked, in field order. Text
164
+ * fields and the note pick no option.
165
+ */
166
+ function answeredChoices(request, answer) {
167
+ const { values } = normalizeUserInputAnswer(request, answer);
168
+ return request.fields.flatMap((field) => field.kind === "text" ? [] : values[field.id] ?? []);
169
+ }
170
+ /** Return true when an answer has no value and no free text. */
171
+ function isEmptyUserInputAnswer(answer) {
172
+ return !answer.other && Object.keys(answer.values).length === 0;
173
+ }
174
+ function answerLine(text) {
175
+ return text.split("\n").map((line) => line.trim()).filter(Boolean).join("\n");
176
+ }
177
+ /**
178
+ * Write the fields of an answer, one `Label (field_id): value` line each.
179
+ * Slack, the web dashboard, and the prompt all use this text, so the model
180
+ * reads one format.
181
+ */
182
+ function formatUserInputAnswer(request, answer) {
183
+ const normalized = normalizeUserInputAnswer(request, answer);
184
+ const lines = [];
185
+ for (const field of request.fields) {
186
+ const values = normalized.values[field.id];
187
+ const value = values?.length ? values.join(", ") : "(no answer)";
188
+ lines.push(answerLine(`${field.label} (${field.id}): ${value}`));
189
+ }
190
+ if (normalized.other) lines.push(answerLine(`Other: ${normalized.other}`));
191
+ return lines.join("\n");
192
+ }
193
+ // src/chat/review-items/evidence.ts
194
+ /**
195
+ * One source that an agent cites for a Review item: a link or a
196
+ * Conversation, with a short label and an optional one-line note. A link
197
+ * points outside Junior; a Conversation reference points to work in Junior.
198
+ * The question stores the list, and the dashboard shows it beside the
199
+ * answer choices.
200
+ */
201
+ const reviewItemEvidenceSchema = z.object({
202
+ conversationId: z.string().min(1).max(500).optional(),
203
+ label: z.string().min(1).max(120),
204
+ note: z.string().min(1).max(200).optional(),
205
+ url: z.string().min(1).max(2e3).optional()
206
+ }).strict().refine((entry) => entry.url === void 0 !== (entry.conversationId === void 0), "Evidence has a `url` or a `conversationId`, not both.");
207
+ /**
208
+ * The question of a Review item with the evidence for its answer. Evidence
209
+ * is part of the question, so it is stored in the `request` column.
210
+ */
211
+ const reviewItemRequestSchema = savedUserInputRequestSchema.safeExtend({ evidence: z.array(reviewItemEvidenceSchema).optional() });
212
+ /** Validate the persisted Slack creator identity for an event automation. */
213
+ const eventAutomationPrincipalSchema = z.object({
214
+ slackUserId: actorUserIdSchema,
215
+ fullName: z.string().optional(),
216
+ userName: z.string().optional()
217
+ }).strict();
218
+ /**
219
+ * Validate one persisted event-automation selector and its presentation
220
+ * metadata. A trigger names one resource with a resource type and an
221
+ * identifier, or it names neither. With neither, it runs for every resource
222
+ * of the namespace that its filters match.
223
+ */
224
+ const eventAutomationTriggerSchema = z.object({
225
+ events: z.array(eventTypeSchema).min(1),
226
+ label: z.string().min(1),
227
+ match: eventMatchSchema.optional(),
228
+ namespace: z.string().min(1),
229
+ identifier: z.string().min(1).max(300).optional(),
230
+ resourceType: z.string().min(1).optional()
231
+ }).strict().refine((trigger) => trigger.identifier === void 0 === (trigger.resourceType === void 0), {
232
+ message: "Set both a resource type and an identifier, or leave out both to run for every resource.",
233
+ path: ["identifier"]
234
+ });
235
+ /** Event automations target a Slack channel or DM, never a message thread. */
236
+ const eventAutomationDestinationSchema = slackDestinationSchema.omit({ threadTs: true });
237
+ const eventAutomationOutcomeSchema = taskOutcomeSchema.extend({ destination: eventAutomationDestinationSchema });
238
+ /** Validate one persisted event automation. */
239
+ const eventAutomationSchema = z.object({
240
+ id: z.string().min(1),
241
+ createdAtMs: z.number().finite(),
242
+ createdBy: eventAutomationPrincipalSchema,
243
+ /** Junior identity that created the automation. It decides ownership. */
244
+ creatorIdentityId: z.string().min(1),
245
+ credentialMode: z.enum(["system", "creator"]),
246
+ destination: eventAutomationDestinationSchema,
247
+ destinationVisibility: destinationVisibilitySchema,
248
+ /** Explicit visible effects after successful work. An empty list is silent. */
249
+ outcomes: z.array(eventAutomationOutcomeSchema).max(5),
250
+ task: automationTaskSchema,
251
+ trigger: eventAutomationTriggerSchema
252
+ }).strict();
46
253
  // src/chat/scheduled-automations/cadence.ts
47
254
  const FORMATTERS = /* @__PURE__ */ new Map();
48
255
  function getFormatter(timezone) {
@@ -635,47 +842,6 @@ const SCHEDULED_AUTOMATION_SYSTEM_ACTOR = Object.freeze({
635
842
  platform: "system",
636
843
  name: "scheduled-automation"
637
844
  });
638
- /** Validate the persisted Slack creator identity for an event automation. */
639
- const eventAutomationPrincipalSchema = z.object({
640
- slackUserId: actorUserIdSchema,
641
- fullName: z.string().optional(),
642
- userName: z.string().optional()
643
- }).strict();
644
- /**
645
- * Validate one persisted event-automation selector and its presentation
646
- * metadata. A trigger names one resource with a resource type and an
647
- * identifier, or it names neither. With neither, it runs for every resource
648
- * of the namespace that its filters match.
649
- */
650
- const eventAutomationTriggerSchema = z.object({
651
- events: z.array(eventTypeSchema).min(1),
652
- label: z.string().min(1),
653
- match: eventMatchSchema.optional(),
654
- namespace: z.string().min(1),
655
- identifier: z.string().min(1).max(300).optional(),
656
- resourceType: z.string().min(1).optional()
657
- }).strict().refine((trigger) => trigger.identifier === void 0 === (trigger.resourceType === void 0), {
658
- message: "Set both a resource type and an identifier, or leave out both to run for every resource.",
659
- path: ["identifier"]
660
- });
661
- /** Event automations target a Slack channel or DM, never a message thread. */
662
- const eventAutomationDestinationSchema = slackDestinationSchema.omit({ threadTs: true });
663
- const eventAutomationOutcomeSchema = taskOutcomeSchema.extend({ destination: eventAutomationDestinationSchema });
664
- /** Validate one persisted event automation. */
665
- const eventAutomationSchema = z.object({
666
- id: z.string().min(1),
667
- createdAtMs: z.number().finite(),
668
- createdBy: eventAutomationPrincipalSchema,
669
- /** Junior identity that created the automation. It decides ownership. */
670
- creatorIdentityId: z.string().min(1),
671
- credentialMode: z.enum(["system", "creator"]),
672
- destination: eventAutomationDestinationSchema,
673
- destinationVisibility: destinationVisibilitySchema,
674
- /** Explicit visible effects after successful work. An empty list is silent. */
675
- outcomes: z.array(eventAutomationOutcomeSchema).max(5),
676
- task: automationTaskSchema,
677
- trigger: eventAutomationTriggerSchema
678
- }).strict();
679
845
  // src/chat/task-outcomes-schema.ts
680
846
  const taskMessageDestinationInputSchema = z.enum(["current_conversation", "task_creator"]).describe("Where to send the message. Use current_conversation for posts, digests, summaries, and channel reminders. Use task_creator only when the user asks for a direct reminder or notification.");
681
847
  /** Input accepted by task authoring tools before a user becomes a DM Destination. */
@@ -1143,4 +1309,4 @@ function isWithinNotificationSchedule(schedule, timezone, nowMs) {
1143
1309
  if (minutes < end) return schedule.days.includes((weekday + 6) % 7);
1144
1310
  return false;
1145
1311
  }
1146
- export { automationContextToolSchema as A, compileScheduleIntent as B, automationUpdateSchema as C, automationVersionSchema as D, automationVersionParamsSchema as E, eventAutomationTriggerSchema as F, getNextRunAtMs as G, toolScheduleIntentSchema as H, SCHEDULED_AUTOMATION_SYSTEM_ACTOR as I, automationSkillNameSchema as J, getZonedDateTimeParts as K, scheduledAutomationSchema as L, automationTitleSchema as M, taskOutcomeInputSchema as N, eventAutomationSummarySchema as O, eventAutomationSchema as P, automationTaskText as Q, scheduledRunSchema as R, automationSummarySchema as S, automationVersionListSchema as T, weekdaySchema as U, scheduleIntentFromTool as V, getFirstRunAtMs as W, automationTaskDescription as X, automationTaskColumns as Y, automationTaskSchema as Z, automationRunListSchema as _, automationEditSchema as a, automationScheduleIntentSchema as b, automationExecutionSchema as c, automationLifecycleSchema as d, automationListItemSchema as f, automationParamsSchema as g, automationListSchema as h, automationEditErrorSchema as i, automationInstructionToolSchema as j, scheduledAutomationSummarySchema as k, automationExecutionStatusDaySchema as l, automationListQuerySchema as m, isWithinNotificationSchedule as n, automationEventCatalogSchema as o, automationListPageSchema as p, isValidTimeZone as q, notificationScheduleSchema as r, automationExecutionListSchema as s, DEFAULT_NOTIFICATION_SCHEDULE as t, automationExecutionStatusSchema as u, automationRunSchema as v, automationVersionActivateSchema as w, automationSchedulePreviewSchema as x, automationRunWindowsSchema as y, ScheduleIntentError as z };
1312
+ export { formatUserInputAnswer as $, automationContextToolSchema as A, toolScheduleIntentSchema as B, automationUpdateSchema as C, automationVersionSchema as D, automationVersionParamsSchema as E, scheduledAutomationSchema as F, isValidTimeZone as G, getFirstRunAtMs as H, scheduledRunSchema as I, reviewItemRequestSchema as J, eventAutomationSchema as K, ScheduleIntentError as L, automationTitleSchema as M, taskOutcomeInputSchema as N, eventAutomationSummarySchema as O, SCHEDULED_AUTOMATION_SYSTEM_ACTOR as P, buttonUserInputField as Q, compileScheduleIntent as R, automationSummarySchema as S, automationVersionListSchema as T, getNextRunAtMs as U, weekdaySchema as V, getZonedDateTimeParts as W, USER_INPUT_NOTE as X, USER_INPUT_LIMITS as Y, answeredChoices as Z, automationRunListSchema as _, automationEditSchema as a, automationTaskDescription as at, automationScheduleIntentSchema as b, automationExecutionSchema as c, automationLifecycleSchema as d, isEmptyUserInputAnswer as et, automationListItemSchema as f, automationParamsSchema as g, automationListSchema as h, automationEditErrorSchema as i, automationTaskColumns as it, automationInstructionToolSchema as j, scheduledAutomationSummarySchema as k, automationExecutionStatusDaySchema as l, automationListQuerySchema as m, isWithinNotificationSchedule as n, userInputRequestSchema as nt, automationEventCatalogSchema as o, automationTaskSchema as ot, automationListPageSchema as p, eventAutomationTriggerSchema as q, notificationScheduleSchema as r, automationSkillNameSchema as rt, automationExecutionListSchema as s, automationTaskText as st, DEFAULT_NOTIFICATION_SCHEDULE as t, normalizeUserInputAnswer as tt, automationExecutionStatusSchema as u, automationRunSchema as v, automationVersionActivateSchema as w, automationSchedulePreviewSchema as x, automationRunWindowsSchema as y, scheduleIntentFromTool as z };