@sentry/junior 0.310.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.
- package/dist/adapter-B1wujchl.js +259 -0
- package/dist/{adapter-context-BhKpjpGD.js → adapter-context-G2M0y6rP.js} +2 -2
- package/dist/{admin-tgZEZAk2.js → admin-DCiBhUT1.js} +1 -2
- package/dist/{agent-runner-D9cvNlQl.js → agent-runner-BVHPUIc8.js} +543 -1703
- package/dist/api/schema.d.ts +2 -2
- package/dist/api/schema.js +7 -6
- package/dist/api.d.ts +21 -3
- package/dist/api.js +1479 -372
- package/dist/{app-B_7Wn0en.d.ts → app-Cw5Vy6H6.d.ts} +14 -3
- package/dist/app.d.ts +2 -2
- package/dist/app.js +232 -506
- package/dist/{background-compaction-queue-BGHqkhkY.js → background-compaction-queue-CJDnWVOJ.js} +4 -4
- package/dist/{briefs-DKxkoruh.js → briefs-BDjnug6Y.js} +3 -3
- package/dist/{catalog-runtime-BxwzbLKY.js → catalog-runtime-DMY3VV-D.js} +1 -1
- package/dist/cli/chat.js +16 -16
- package/dist/cli/check.js +23 -29
- package/dist/cli/init.js +1 -6
- package/dist/cli/main.js +3 -3
- package/dist/cli/plugins.js +8 -7
- package/dist/cli/snapshot-create.js +5 -5
- package/dist/cli/upgrade.d.ts +1 -1
- package/dist/cli/upgrade.js +3 -3
- package/dist/{config-Dkt2Le2b.js → config-BrXDQefC.js} +239 -5
- package/dist/{continue-in-slack-BWVwePKD.js → continue-in-slack-DNXSC9So.js} +6 -5
- package/dist/{conversation-M9KZ5JxF.js → conversation-ca__NDQW.js} +47 -8
- package/dist/{conversation-feed-Ci6YD1N-.js → conversation-feed-DkinDu5o.js} +15 -6
- package/dist/{conversation-privacy-C39g8BY4.js → conversation-privacy-DxttrKb9.js} +1 -1
- package/dist/{conversation-turn-CBlZIH02.js → conversation-turn-DWw7Xhdr.js} +41 -38
- package/dist/{credential-sync-vGnrB0BY.js → credential-sync-Bk8wGb8Y.js} +15 -16
- package/dist/{db-B4Hjxr-u.d.ts → db-7ETESH44.d.ts} +3 -1
- package/dist/{db-CFZggNoy.js → db-DTxzH7u5.js} +1609 -1040
- package/dist/{executor-BPkZDx5-.js → executor-DqTiYj9S.js} +450 -99
- package/dist/{html-2r2KmLwi.js → html-B9Sl4Axb.js} +6 -6
- package/dist/{install-C-oE6C_u.js → install-Sg4ePfLl.js} +2 -2
- package/dist/instrumentation.js +3 -3
- package/dist/{lineage-CsvrEFQe.js → lineage-BHAMpNKr.js} +2 -2
- package/dist/{logging-D5gkyvnK.js → logging-FjclQsXu.js} +47 -9
- package/dist/{message-DwvJ-I3w.js → message-CJ7_RL50.js} +5 -8
- package/dist/{model-input-MAq2881y.js → model-input-CMLh4Cwq.js} +3 -3
- package/dist/nitro.d.ts +1 -1
- package/dist/nitro.js +3 -3
- package/dist/{oauth-callback-server-DIF6Li06.js → oauth-callback-server-RVcbiDjL.js} +2 -2
- package/dist/{oauth-relay-DPE-wrwO.js → oauth-relay-Bu9kkaQu.js} +1 -1
- package/dist/{projection-jZSlEAXG.js → projection-Cns7XwWa.js} +9445 -5574
- package/dist/{prompt-CaMyeCpA.js → prompt-CDqcsDYC.js} +4 -4
- package/dist/{registry-BBkWFCl8.js → registry-BPwuOP2O.js} +5 -8
- package/dist/{resolve-B38MkHXE.js → resolve-BK29bBry.js} +3 -3
- package/dist/rule-DAxQY-1h.js +20 -0
- package/dist/{runner-11h8PrHh.js → runner-BcAE-cJm.js} +10 -10
- package/dist/{sandbox-egress-signals-CTcACAtJ.js → sandbox-egress-signals-C-q0go5b.js} +1 -1
- package/dist/{schedule-DWxZ3kja.js → schedule-BLJ476XQ.js} +209 -43
- package/dist/{schema-obw5jvR4.js → schema-BLgSZXcL.js} +255 -49
- package/dist/{schema-DriSvB40.d.ts → schema-DYcJeV7d.d.ts} +701 -62
- package/dist/{service-account-Zc5bUcIJ.js → service-account-gN0zqf0S.js} +68 -68
- package/dist/{service-account-Bx93N1n1.js → service-account-iJoCtkHR.js} +3 -3
- package/dist/{skills-C8Npu5zO.js → skills-BoZ80epJ.js} +2 -2
- package/dist/{slack-conversation-unfurl-DlRVA02H.js → slack-conversation-unfurl-CogYrITA.js} +8 -10
- package/dist/{spawn-CXr58R0x.js → spawn-Dk92r7mX.js} +5 -6
- package/dist/{state-CGrGVeQC.js → state-DH3Cmgp3.js} +4 -4
- package/dist/{stop-DYzjRf2U.js → stop-CYsfc0Ed.js} +1063 -313
- package/dist/{store-D4FQ1Nml.js → store-DmmMIrQi.js} +5 -5
- package/dist/{task-queue-CaZffYaH.js → task-queue-C_zldF5J.js} +3 -3
- package/dist/{task-runner-Dm7BHbGp.js → task-runner-C7oCJQIx.js} +20 -13
- package/dist/{thread-context-Dyj1KWaY.js → thread-context-BW2BsQbH.js} +13 -11
- package/dist/{turn-session-routing-CD0BRCex.js → turn-session-routing-Xh_2nSQe.js} +52 -54
- package/dist/{validation-DxVNIxA0.js → validation-DrJd0nnq.js} +1 -1
- package/dist/{version-Cr7Z71yG.js → version-CNKZ8owc.js} +1 -1
- package/dist/version.js +1 -1
- package/dist/{warmup-C6LOZ2d2.js → warmup-BWdHew2H.js} +14287 -7195
- package/dist/{web-message-id-BT8Mg8LL.js → web-message-id-Ch5dPq-a.js} +32 -144
- package/dist/{worker-CUBtu1Li.js → worker-t9qpu_Zx.js} +7 -8
- package/migrations/0126_artifact_drop_public.sql +8 -0
- package/migrations/0127_artifact_path.sql +4 -0
- package/migrations/0128_artifact_path_index.sql +1 -0
- package/migrations/0129_review_item_answered_index.sql +1 -0
- package/migrations/0130_review_item_status_index.sql +1 -0
- package/migrations/0131_brief_outcome_status.sql +1 -0
- package/migrations/0132_brief_outcome_status_backfill.sql +7 -0
- package/migrations/0133_brief_created_at_index.sql +1 -0
- package/migrations/0134_slack_person_search_index.sql +1 -0
- package/migrations/0135_code_change_size.sql +3 -0
- package/migrations/0136_merge_conflict_notice_dismiss.sql +16 -0
- package/migrations/0137_inbox_snoozes.sql +27 -0
- package/migrations/0138_code_change_search_index.sql +2 -0
- package/migrations/0139_review_item_owner.sql +22 -0
- package/migrations/0140_review_item_owner_index.sql +1 -0
- package/migrations/0141_memory_core_adoption.sql +89 -0
- package/migrations/0142_memory_core_indexes.sql +17 -0
- package/migrations/meta/0126_snapshot.json +5488 -0
- package/migrations/meta/0127_snapshot.json +5519 -0
- package/migrations/meta/0128_snapshot.json +5519 -0
- package/migrations/meta/0129_snapshot.json +5547 -0
- package/migrations/meta/0130_snapshot.json +5563 -0
- package/migrations/meta/0131_snapshot.json +5569 -0
- package/migrations/meta/0132_snapshot.json +5569 -0
- package/migrations/meta/0133_snapshot.json +5590 -0
- package/migrations/meta/0134_snapshot.json +5606 -0
- package/migrations/meta/0135_snapshot.json +5624 -0
- package/migrations/meta/0136_snapshot.json +5624 -0
- package/migrations/meta/0137_snapshot.json +5864 -0
- package/migrations/meta/0138_snapshot.json +5894 -0
- package/migrations/meta/0139_snapshot.json +5898 -0
- package/migrations/meta/0140_snapshot.json +5919 -0
- package/migrations/meta/0141_snapshot.json +6429 -0
- package/migrations/meta/0142_snapshot.json +6457 -0
- package/migrations/meta/_journal.json +120 -1
- package/package.json +6 -7
- package/dist/result-BaqSZcJb.js +0 -548
- package/dist/session-stop-BfY4rhJs.js +0 -4255
- package/dist/turn-user-message-9IxeEv5v.js +0 -364
- package/dist/users-CaUAYMb3.js +0 -181
- package/dist/viewer-AHldghAD.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,
|
|
2
|
-
import { E as withSpan, _ as runBestEffort, a as extractGenAiUsageSummary, i as extractGenAiUsageAttributes, p as logException } from "./logging-
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
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-
|
|
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 ===
|
|
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 ===
|
|
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 ===
|
|
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 ===
|
|
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-
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
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 {
|
|
2
|
-
import { a as buildDeliveredTurnStatePatch, o as loadPendingMessageCards, r as completeAuthPauseTurn, t as buildTurnThreadContext } from "./thread-context-
|
|
3
|
-
import { A as latestConversationMessageSeq, I as upsertConversationMessage, M as normalizeConversationText, N as recordDeliveredAssistantMessage, S as persistConversationMessages, W as authorizationId, b as hydrateConversationMessages,
|
|
4
|
-
import { S as setTags, T as withLogContext, p as logException } from "./logging-
|
|
5
|
-
import { n as scheduleSessionCompletedPluginTasks, t as processPluginTask } from "./task-runner-
|
|
6
|
-
import { a as getPersistedThreadState, c as coerceThreadConversationState, i as getPersistedSandboxState, s as persistThreadStateById } from "./turn-session-routing-
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import { p as credentialContextForActor } from "./registry-
|
|
10
|
-
import {
|
|
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 {
|
|
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-
|
|
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,
|
|
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 };
|