@sentry/junior 0.257.0 → 0.258.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/{actor-BTtLaeWy.js → actor-tlxzqaRe.js} +3 -6
- package/dist/{admin-DgIkm6Vy.js → admin-My1SLGVO.js} +2 -3
- package/dist/{agent-hooks-BjtTzvru.js → agent-hooks-BJ_5mlRH.js} +69 -109
- package/dist/{agent-invocations-Bdu3ROfo.js → agent-invocations-Qfz7dWgU.js} +6 -12
- package/dist/{agent-runner-D7OboVb3.js → agent-runner-DGsFQw72.js} +261 -458
- package/dist/api/schema.d.ts +414 -448
- package/dist/api/schema.js +5 -5
- package/dist/api.d.ts +2 -12
- package/dist/api.js +94 -158
- package/dist/{app-BsU5QNBd.d.ts → app-PX2H1PxU.d.ts} +21 -44
- package/dist/app.d.ts +3 -3
- package/dist/app.js +204 -321
- package/dist/{assistant-reply-CbTPebzL.js → assistant-reply-H1M-91oF.js} +3 -5
- package/dist/{automation-CHdlHVZP.js → automation-DWBFBenG.js} +6 -11
- package/dist/{briefs-oLOldnDM.js → briefs-vYoK85rJ.js} +8 -11
- package/dist/{cadence-D00SCzT1.js → cadence-R7Em4RjE.js} +1 -2
- package/dist/{catalog-runtime-CZzhGQ7F.js → catalog-runtime-BN4DVxco.js} +3 -4
- package/dist/cli/chat.d.ts +2 -4
- package/dist/cli/chat.js +22 -24
- package/dist/cli/check.d.ts +1 -3
- package/dist/cli/check.js +4 -5
- package/dist/cli/env.d.ts +1 -3
- package/dist/cli/env.js +1 -2
- package/dist/cli/init.d.ts +1 -3
- package/dist/cli/init.js +3 -3
- package/dist/cli/main.d.ts +1 -3
- package/dist/cli/main.js +4 -5
- package/dist/cli/plugins.d.ts +2 -4
- package/dist/cli/plugins.js +7 -8
- package/dist/cli/run.d.ts +1 -2
- package/dist/cli/run.js +1 -2
- package/dist/cli/snapshot-create.d.ts +1 -3
- package/dist/cli/snapshot-create.js +4 -5
- package/dist/cli/upgrade.d.ts +3 -6
- package/dist/cli/upgrade.js +11 -17
- package/dist/{client-D8HnkOQX.js → client-DbyHuMFU.js} +9 -16
- package/dist/{config-CJRnWK9H.js → config-_WO_AjCB.js} +18 -15
- package/dist/{connections-ClYrKzpX.js → connections-ag_1JOhB.js} +14 -19
- package/dist/{conversation-CKNLYBJt.js → conversation-DjN3mlog.js} +8 -15
- package/dist/{conversation-privacy-C8b1nphZ.js → conversation-privacy-DHP_xnVj.js} +2 -3
- package/dist/{conversation-work-C6y3T5Hx.js → conversation-work-BaT_T6EB.js} +1 -2
- package/dist/{credential-sync-BXfohNmJ.js → credential-sync-B-CPX_ag.js} +23 -28
- package/dist/{db-Ca9Nt5ci.d.ts → db-BnRqQ7G5.d.ts} +1 -1
- package/dist/{executor-Do0THDRR.js → executor-RvG6kVe1.js} +30 -52
- package/dist/{experimental-CQIvMUO7.js → experimental-BNK1l1jv.js} +2 -4
- package/dist/{history-9pO1Zd4Y.js → history-AY8rs-FR.js} +5 -9
- package/dist/{history-DvqWZlYX.d.ts → history-BgI33Kie.d.ts} +12 -20
- package/dist/{images-BN_BiBXF.js → images-C2J_bj2g.js} +5 -6
- package/dist/instrumentation.d.ts +1 -3
- package/dist/instrumentation.js +6 -8
- package/dist/{job-queue-B6SV9uVa.js → job-queue-DVe37it2.js} +6 -12
- package/dist/{logging-CWxiIuCF.js → logging-DsHONhVm.js} +7 -12
- package/dist/{message-TUOdbSBW.js → message-DyitL8no.js} +5 -6
- package/dist/{model-profile-BwU8mqwD.js → model-profile-Bg8EoCKD.js} +2 -4
- package/dist/nitro.d.ts +3 -5
- package/dist/nitro.js +12 -17
- package/dist/{oauth-authorization-BA4Dt6a7.js → oauth-authorization-djQn5Nhy.js} +2 -4
- package/dist/{oauth-callback-server-Dj5UJODo.js → oauth-callback-server-CDby-pCn.js} +3 -4
- package/dist/{oauth-relay-CdCnu80W.js → oauth-relay-CTygMkNx.js} +2 -3
- package/dist/{package-discovery-BVvSnQBB.js → package-discovery-DJBompdd.js} +17 -21
- package/dist/{pending-auth-s_QFribU.js → pending-auth-D8J1uJUS.js} +37 -28
- package/dist/{plugin-module-CVvEUSMH.js → plugin-module-Cf5gVPWP.js} +1 -2
- package/dist/{plugins-CjfUP5gJ.d.ts → plugins-B11Mfkmv.d.ts} +0 -4
- package/dist/{plugins-egKWjgue.js → plugins-DOm9Y6qI.js} +2 -3
- package/dist/{private-trace-result-BLvBjy_e.js → private-trace-result-CE7_lEdq.js} +1 -2
- package/dist/{profile-h-72wM78.js → profile-DpYjfKke.js} +16 -28
- package/dist/{prompt-DyoEj9c2.js → prompt-xgpyMtg7.js} +5 -9
- package/dist/{queue-B5SnqRln.d.ts → queue-C37RbDVc.d.ts} +0 -2
- package/dist/{registry-sLTr-sV9.js → registry-Du566MtJ.js} +16 -29
- package/dist/{resolve-ncQPZROQ.js → resolve-ClCIgh8E.js} +7 -12
- package/dist/{result-C883vngT.js → result-BBbKA61B.js} +13 -17
- package/dist/{rolldown-runtime-B4FMCO8f.js → rolldown-runtime-nwUcYXjP.js} +1 -2
- package/dist/{runner-CzYImdOF.js → runner-CCuqFSqx.js} +12 -13
- package/dist/{sandbox-egress-signals-CZbMINHI.js → sandbox-egress-signals-DY1mbKF4.js} +2 -3
- package/dist/{schema-Dy69D4Ge.js → schema-DrMh3NtR.js} +15 -26
- package/dist/{sentry-CgWZM_kV.js → sentry-BBUlHih9.js} +2 -3
- package/dist/{session-stop-CQjKd4a2.js → session-stop-CIoFiwwe.js} +23 -33
- package/dist/{skills-C22SLruK.js → skills-DyQBLIrK.js} +9 -9
- package/dist/{spawn-DY9CLXDL.js → spawn-Dqfeo7XP.js} +4 -5
- package/dist/{store-DoewL5mG.d.ts → store-CG0VJyye.d.ts} +0 -14
- package/dist/{store-DXFIQy-G.js → store-DJLwq4x8.js} +13 -15
- package/dist/{task-queue-B17vV0La.js → task-queue-BzW4MaWU.js} +5 -7
- package/dist/{task-runner-DUjvzYXj.js → task-runner-D3qJh4fK.js} +22 -26
- package/dist/{tasks-D_WIJtvO.js → tasks-CEXKTASS.js} +62 -78
- package/dist/{thread-state-Ch4yuCqG.js → thread-state-W3f6kAtz.js} +13 -19
- package/dist/{turn-failure-response-C5nBKC4S.js → turn-failure-response-CWx7aNIh.js} +16 -22
- package/dist/{turn-lifecycle-CO-ylUmV.js → turn-lifecycle-C9JFst7-.js} +2 -3
- package/dist/{turn-session-routing-B3LWooK5.js → turn-session-routing-CUxtfpr7.js} +2 -3
- package/dist/{validation-CXYxaNYx.js → validation-BHRxa5G4.js} +3 -4
- package/dist/vercel.d.ts +1 -3
- package/dist/vercel.js +1 -2
- package/dist/{version-BcdZy2zg.js → version-C0U6rHg0.js} +3 -5
- package/dist/{version-CnXZ614E.d.ts → version-Cc2OFd9G.d.ts} +0 -2
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -2
- package/dist/{viewer-DSZXygMU.js → viewer-CGvvRqKp.js} +26 -57
- package/dist/{web-input-B9Bv0_lR.js → web-input-Keb5GRWj.js} +98 -155
- package/dist/{web-message-id-xPI_EFSC.js → web-message-id-CJSUiksE.js} +3 -6
- package/dist/{work-nAfDSUFP.js → work-DRcsJ3hV.js} +14 -16
- package/dist/{worker-vGXZ6XFT.js → worker-Cjo-QqPq.js} +7 -8
- package/package.json +7 -6
|
@@ -1,33 +1,33 @@
|
|
|
1
|
-
import { b as getGatewayApiKey, c as hasCompactedConversationContext, d as unwrapCurrentInstruction, f as escapeXml, g as getProviderErrorAttributes, h as findProviderError, i as completeText, l as isCompactionSummaryText, m as createProviderError, n as GEN_AI_SERVER_ADDRESS, o as resolveGatewayModel, p as ProviderError, r as completeObject, s as COMPACTION_SUMMARY_PREFIX, t as GEN_AI_PROVIDER_NAME, u as renderCurrentInstruction, v as isProviderRetryError, x as resolveGatewayCredential, y as MISSING_GATEWAY_CREDENTIALS_ERROR } from "./client-
|
|
2
|
-
import { R as normalizeIdentityEmail, S as summarizeMessageText, T as withSpan, V as toOptionalString, _ as serializeGenAiAttribute, a as extractGenAiUsageSummary, b as setSpanStatus, c as getLogContextAttributesForSpan, d as logError, f as logException, h as normalizeGenAiFinishReason, i as extractGenAiUsageAttributes, l as getTracePropagationHeaders, m as logWarn, p as logInfo, u as logAudit, w as withLogContext, x as setTags, y as setSpanAttributes, z as isRecord$4 } from "./logging-
|
|
3
|
-
import { m as startInactiveSpan, v as withActiveSpan } from "./sentry-
|
|
4
|
-
import { a as toCanonicalInputMessage, c as toGenAiPayloadMetadata, i as runWithConversationPrivacy, l as toGenAiPayloadTraceAttributes, o as toCanonicalOutputMessage, r as resolveConversationPrivacy, s as toGenAiMessagesTraceAttributes, t as canExposeConversationPayload } from "./conversation-privacy-
|
|
5
|
-
import { n as botConfig, v as normalizeSlackEmojiName } from "./config-
|
|
6
|
-
import { a as formatModelProfiles, c as profileConfig, i as formatModelProfile, l as TURN_REASONING_LEVELS, n as ModelProfileNotConfiguredError, o as modelIdForProfile, s as modelProfileSchema } from "./model-profile-
|
|
7
|
-
import { a as isUserActor, d as parseSlackTeamId, f as parseSlackUserId, g as parseSlackMessageTs, l as parseSlackChannelId, u as parseSlackChannelReferenceId } from "./actor-
|
|
8
|
-
import {
|
|
9
|
-
import { a as juniorAgentInvocations, c as juniorIdentities, d as juniorDestinations, i as juniorAgentBindings, n as AGENT_INVOCATION_PARENT_MAILBOX_STATUSES, s as juniorConversations, t as AGENT_INVOCATION_MAILBOX_STATUSES } from "./agent-invocations-
|
|
10
|
-
import { _ as juniorConversationAnnotations, a as juniorAutomationRuns, b as juniorAttachments, c as juniorStats, f as juniorConversationBriefs, x as juniorArtifacts } from "./executor-
|
|
11
|
-
import { d as contextProvenance, f as instructionActors, m as sameActorIdentity, p as instructionProvenanceFor, t as KNOWN_CONVERSATION_EVENT_TYPES, u as agentInstructionProvenance } from "./history-
|
|
12
|
-
import { a as listReferenceFiles, c as soulPathCandidates, l as worldPathCandidates } from "./package-discovery-
|
|
13
|
-
import { _ as CredentialUnavailableError, a as resolveAuthTokenPlaceholder, c as fetchWithBoundedOAuthErrorBodies, d as actorLogContext, f as credentialContextForActor, g as credentialUserSubjectId, i as resolvePluginHeaderEnvRefs, l as getOAuthProviderErrorAttributes, o as resolvePluginCommandEnv, p as credentialContextSchema, s as OAuthProviderError } from "./registry-
|
|
14
|
-
import { n as pluginCatalogRuntime } from "./catalog-runtime-
|
|
15
|
-
import { a as parseSkillInvocation, i as parseSkillFile, n as findSkillByName, r as loadSkillsByName, t as discoverSkills } from "./skills-
|
|
16
|
-
import { A as escapeSlackMrkdwnText, B as postSlackMessage, Ct as ToolInputError, Dt as loadConversationProjection, Et as loadConnectedMcpProviders, G as continuableMessages, H as uploadFilesToConversation, Ht as recordTurnRoute, I as addReactionToMessage, K as loadTurnCheckpoint, L as getSlackMessagePermalink, Lt as recordAuthorizationRequested, Mt as openConversationProjection, Nt as recordAgentsInstructionsUpdated, O as automationRevision, Ot as loadLastModelProfile, P as slackMention, Pt as recordAttachmentsDelivered, R as openSlackDirectMessage, Rt as recordGuardianActionReviewed, St as TURN_CONTEXT_TAG, Vt as recordToolExecutionStarted, Xt as fallbackShortTitle, Zt as resolveTaskTitle, _t as isToolResultMessage, a as saveScheduledAutomation, bt as stripRuntimeTurnContext, ct as extractAssistantText, d as createEventAutomation, dn as getAgentContextInputLimitTokens, dt as getUserMessageInstructionText, f as deleteEventAutomation, fn as historyItemFromPiMessage, ft as hasRuntimeTurnContext, g as listEventAutomationsForTeam, gt as isToolResultError, ht as isContinuablePiBoundary, i as readScheduledAutomation, it as TurnToolCallLimitExceededError, j as formatSlackLink, jt as loadTurnRoute, ln as estimateTextTokens, lt as getPiMessageRole, m as getEventAutomation, mt as isAssistantMessage, n as listScheduledAutomationsForTeam, nt as TurnBudgetExceededError, ot as createTurnLimitGate, pn as piMessageFromHistoryItem, q as saveTurnCheckpoint, rt as TurnSliceLimitExceededError, st as isTurnExecutionLimitExceededError, t as createScheduledAutomation, tt as TURN_LIMIT_DISABLED_REASON, un as getAgentContextCompactionTriggerTokens, ut as getTerminalAssistantMessages, v as saveEventAutomation, vt as normalizeToolNameFromResult, xt as trimTrailingAssistantMessages, y as setEventAutomationStatus, yt as retainRuntimeTurnContext, z as postSlackEphemeralMessage, zt as recordMcpProviderConnected } from "./tasks-
|
|
17
|
-
import { A as getWorkspaceSnapshotBuilder, B as STOP_WATCHING_TOOL_NAME, Bt as getFilePermalink, C as WorkspaceValidationError, D as setWorkspaceSnapshotBuild, Dt as matchSlackAttachments, E as setWorkspaceSnapshot, F as isSlackMessageTurn, Ft as defaultTimezone, G as createWatch, Gt as normalizeSlackConversationId, H as cancelWatch, Ht as getSlackClient, I as slackMessageTurnDisabledReason, It as resolveUserTimezone, J as getWatch, K as deliverWatch, L as RESOURCE_SUBSCRIPTION_DEFAULT_TTL_MS, M as workspaceRepoCheckoutPath, Mt as createPluginAnnotations, N as resolveChannelCapabilities, O as SANDBOX_RUNTIME, P as getSlackToolContext, R as RESOURCE_SUBSCRIPTION_MAX_TTL_MS, Rt as SlackActionError, S as updateWorkspace, T as loadSnapshotsForProfile, Ut as isConversationScopedChannel, V as cancelSubscriptions, W as createTimerWatch, Wt as isDmChannel$1, Xt as JUNIOR_NATIVE_EVENT_NAMESPACE, Y as listWatches, _ as deleteWorkspace, at as getDashboardConversationLink, b as listWorkspaces, c as getPluginTools, en as conversationNoteEvent, ft as createPluginLogger, g as createWorkspace, j as tryWorkspaceRepoCheckoutPath, jt as saveObjectAnnotations, k as deleteWorkspaceSnapshotBuilders, l as getPluginUserPromptContributions, q as findMatchingWatches, qt as withSlackRetries, r as createPluginHookRunner, s as getPluginSystemPromptContributions, st as getDashboardTaskLink, u as getPlugins, v as getWorkspace, w as invalidateReadySnapshot, y as getWorkspaceByName, z as RESOURCE_WATCH_TOOL_SOURCE, zt as downloadPrivateSlackFile } from "./agent-hooks-
|
|
18
|
-
import { B as briefLinkSchema, H as conversationBriefSchema, J as removedCardSchema, L as detectImageMediaType, R as isVisionImageMediaType, V as briefOutcomeStatusSchema } from "./conversation-
|
|
19
|
-
import { A as SANDBOX_DATA_ROOT, D as fenceLock, E as acquireActiveLock, F as sandboxSkillFile, I as sandboxSkillPathResolution, M as SANDBOX_SKILLS_ROOT, N as SANDBOX_WORKSPACE_ROOT, O as withLock, P as sandboxSkillDir, _ as workspaceSnapshotNotReadyUserMessage, a as isAbortError, b as buildNonInteractiveShellScript, c as isSandboxCommandStreamInterruptedError, d as isSnapshottingError, f as throwSandboxOperationError, g as isWorkspaceSnapshotNotReadyError, h as getWorkspaceSnapshotNotReadyError, i as ensureDockerDaemon, j as SANDBOX_REPOS_ROOT, k as sleep, l as isSandboxMissingError, m as WorkspaceSnapshotNotReadyError, n as hash, o as isAlreadyExistsError, p as wrapSandboxSetupError, r as isStale, s as isSandboxApiTransientError, t as create, u as isSandboxUnavailableError, v as getVercelSandboxCredentials, w as getStateAdapter, x as runNonInteractiveCommand, y as buildCommandScript } from "./profile-
|
|
20
|
-
import { n as canReusePendingAuthLink, t as abandonReplacedPendingAuth } from "./pending-auth-
|
|
21
|
-
import { c as isTurnInputCommitLostError, i as TurnInputCommitLostError, r as CooperativeTurnYieldError, t as authorizationId } from "./oauth-authorization-
|
|
22
|
-
import { a as isNoReplyMarker, i as NO_REPLY_MARKER, n as getAssistantReplyText, r as sanitizeAssistantText, t as decideReply } from "./assistant-reply-
|
|
23
|
-
import { C as pluginSupportsEvent, D as requireEventIdentifier, E as registeredResourceTypeSchema, L as readAutomationResult, N as FINISH_AUTOMATION_RUN_TOOL_NAME, O as requireSupportedEventMatch, P as automationResultSchema, R as remindMissingAutomationResult, S as hasEventCatalogEntries, T as registeredEventTypeSchema, _ as workspaceSnapshotFinishedEvent, d as requireSlackChannelMessageScope, g as WORKSPACE_SNAPSHOT_READY_EVENT, h as WORKSPACE_SNAPSHOT_FAILED_EVENT, l as getEventCatalog, n as markConversationsStopped, o as enqueueEventNotification, t as getConversationStoppedAtMs, v as workspaceSnapshotWatch, w as registeredEventMatchSchema, x as eventNamespaceSchema, y as automationEventCatalog } from "./session-stop-
|
|
24
|
-
import { i as isValidTimeZone, r as getZonedDateTimeParts } from "./cadence-
|
|
25
|
-
import { a as createSandboxSession, c as postinstall, d as getSandboxResources, i as bindSandboxFileSystem, l as setSnapshotSpanAttributes, n as isMissingError, o as stopSession, r as resolve$1, s as dependencies } from "./resolve-
|
|
26
|
-
import { a as getVercelConversationWorkQueue, f as getTurnRequestDeadline, n as sendNextWorkspaceSnapshotJob, r as sendWorkspaceSnapshotJob } from "./job-queue-
|
|
27
|
-
import { E as stopConversationWork } from "./store-
|
|
28
|
-
import { F as taskOutcomeInputSchema, M as compileScheduleIntent, N as scheduleIntentSchema, O as automationInstructionToolSchema, T as SCHEDULED_AUTOMATION_SYSTEM_ACTOR, j as ScheduleIntentError, k as automationTitleSchema } from "./automation-
|
|
29
|
-
import { r as isExperimentalFeatureEnabled } from "./experimental-
|
|
30
|
-
import { n as privateTraceResultAttributes } from "./private-trace-result-
|
|
1
|
+
import { b as getGatewayApiKey, c as hasCompactedConversationContext, d as unwrapCurrentInstruction, f as escapeXml, g as getProviderErrorAttributes, h as findProviderError, i as completeText, l as isCompactionSummaryText, m as createProviderError, n as GEN_AI_SERVER_ADDRESS, o as resolveGatewayModel, p as ProviderError, r as completeObject, s as COMPACTION_SUMMARY_PREFIX, t as GEN_AI_PROVIDER_NAME, u as renderCurrentInstruction, v as isProviderRetryError, x as resolveGatewayCredential, y as MISSING_GATEWAY_CREDENTIALS_ERROR } from "./client-DbyHuMFU.js";
|
|
2
|
+
import { R as normalizeIdentityEmail, S as summarizeMessageText, T as withSpan, V as toOptionalString, _ as serializeGenAiAttribute, a as extractGenAiUsageSummary, b as setSpanStatus, c as getLogContextAttributesForSpan, d as logError, f as logException, h as normalizeGenAiFinishReason, i as extractGenAiUsageAttributes, l as getTracePropagationHeaders, m as logWarn, p as logInfo, u as logAudit, w as withLogContext, x as setTags, y as setSpanAttributes, z as isRecord$4 } from "./logging-DsHONhVm.js";
|
|
3
|
+
import { m as startInactiveSpan, v as withActiveSpan } from "./sentry-BBUlHih9.js";
|
|
4
|
+
import { a as toCanonicalInputMessage, c as toGenAiPayloadMetadata, i as runWithConversationPrivacy, l as toGenAiPayloadTraceAttributes, o as toCanonicalOutputMessage, r as resolveConversationPrivacy, s as toGenAiMessagesTraceAttributes, t as canExposeConversationPayload } from "./conversation-privacy-DHP_xnVj.js";
|
|
5
|
+
import { n as botConfig, v as normalizeSlackEmojiName } from "./config-_WO_AjCB.js";
|
|
6
|
+
import { a as formatModelProfiles, c as profileConfig, i as formatModelProfile, l as TURN_REASONING_LEVELS, n as ModelProfileNotConfiguredError, o as modelIdForProfile, s as modelProfileSchema } from "./model-profile-Bg8EoCKD.js";
|
|
7
|
+
import { a as isUserActor, d as parseSlackTeamId, f as parseSlackUserId, g as parseSlackMessageTs, l as parseSlackChannelId, u as parseSlackChannelReferenceId } from "./actor-tlxzqaRe.js";
|
|
8
|
+
import { C as addAgentTurnUsage, D as hasAgentTurnUsage, R as parseDestination, c as getConversationEventStore, d as getDb, f as getSqlExecutor, l as getConversationMessageSearchStore, r as readActorIdentity, u as getConversationStore, w as agentTurnCostUsd } from "./viewer-CGvvRqKp.js";
|
|
9
|
+
import { a as juniorAgentInvocations, c as juniorIdentities, d as juniorDestinations, i as juniorAgentBindings, n as AGENT_INVOCATION_PARENT_MAILBOX_STATUSES, s as juniorConversations, t as AGENT_INVOCATION_MAILBOX_STATUSES } from "./agent-invocations-Qfz7dWgU.js";
|
|
10
|
+
import { _ as juniorConversationAnnotations, a as juniorAutomationRuns, b as juniorAttachments, c as juniorStats, f as juniorConversationBriefs, x as juniorArtifacts } from "./executor-RvG6kVe1.js";
|
|
11
|
+
import { d as contextProvenance, f as instructionActors, m as sameActorIdentity, p as instructionProvenanceFor, t as KNOWN_CONVERSATION_EVENT_TYPES, u as agentInstructionProvenance } from "./history-AY8rs-FR.js";
|
|
12
|
+
import { a as listReferenceFiles, c as soulPathCandidates, l as worldPathCandidates } from "./package-discovery-DJBompdd.js";
|
|
13
|
+
import { _ as CredentialUnavailableError, a as resolveAuthTokenPlaceholder, c as fetchWithBoundedOAuthErrorBodies, d as actorLogContext, f as credentialContextForActor, g as credentialUserSubjectId, i as resolvePluginHeaderEnvRefs, l as getOAuthProviderErrorAttributes, o as resolvePluginCommandEnv, p as credentialContextSchema, s as OAuthProviderError } from "./registry-Du566MtJ.js";
|
|
14
|
+
import { n as pluginCatalogRuntime } from "./catalog-runtime-BN4DVxco.js";
|
|
15
|
+
import { a as parseSkillInvocation, i as parseSkillFile, n as findSkillByName, r as loadSkillsByName, t as discoverSkills } from "./skills-DyQBLIrK.js";
|
|
16
|
+
import { A as escapeSlackMrkdwnText, B as postSlackMessage, Ct as ToolInputError, Dt as loadConversationProjection, Et as loadConnectedMcpProviders, G as continuableMessages, H as uploadFilesToConversation, Ht as recordTurnRoute, I as addReactionToMessage, K as loadTurnCheckpoint, L as getSlackMessagePermalink, Lt as recordAuthorizationRequested, Mt as openConversationProjection, Nt as recordAgentsInstructionsUpdated, O as automationRevision, Ot as loadLastModelProfile, P as slackMention, Pt as recordAttachmentsDelivered, R as openSlackDirectMessage, Rt as recordGuardianActionReviewed, St as TURN_CONTEXT_TAG, Vt as recordToolExecutionStarted, Xt as fallbackShortTitle, Zt as resolveTaskTitle, _t as isToolResultMessage, a as saveScheduledAutomation, bt as stripRuntimeTurnContext, ct as extractAssistantText, d as createEventAutomation, dn as getAgentContextInputLimitTokens, dt as getUserMessageInstructionText, f as deleteEventAutomation, fn as historyItemFromPiMessage, ft as hasRuntimeTurnContext, g as listEventAutomationsForTeam, gt as isToolResultError, ht as isContinuablePiBoundary, i as readScheduledAutomation, it as TurnToolCallLimitExceededError, j as formatSlackLink, jt as loadTurnRoute, ln as estimateTextTokens, lt as getPiMessageRole, m as getEventAutomation, mt as isAssistantMessage, n as listScheduledAutomationsForTeam, nt as TurnBudgetExceededError, ot as createTurnLimitGate, pn as piMessageFromHistoryItem, q as saveTurnCheckpoint, rt as TurnSliceLimitExceededError, st as isTurnExecutionLimitExceededError, t as createScheduledAutomation, tt as TURN_LIMIT_DISABLED_REASON, un as getAgentContextCompactionTriggerTokens, ut as getTerminalAssistantMessages, v as saveEventAutomation, vt as normalizeToolNameFromResult, xt as trimTrailingAssistantMessages, y as setEventAutomationStatus, yt as retainRuntimeTurnContext, z as postSlackEphemeralMessage, zt as recordMcpProviderConnected } from "./tasks-CEXKTASS.js";
|
|
17
|
+
import { A as getWorkspaceSnapshotBuilder, B as STOP_WATCHING_TOOL_NAME, Bt as getFilePermalink, C as WorkspaceValidationError, D as setWorkspaceSnapshotBuild, Dt as matchSlackAttachments, E as setWorkspaceSnapshot, F as isSlackMessageTurn, Ft as defaultTimezone, G as createWatch, Gt as normalizeSlackConversationId, H as cancelWatch, Ht as getSlackClient, I as slackMessageTurnDisabledReason, It as resolveUserTimezone, J as getWatch, K as deliverWatch, L as RESOURCE_SUBSCRIPTION_DEFAULT_TTL_MS, M as workspaceRepoCheckoutPath, Mt as createPluginAnnotations, N as resolveChannelCapabilities, O as SANDBOX_RUNTIME, P as getSlackToolContext, R as RESOURCE_SUBSCRIPTION_MAX_TTL_MS, Rt as SlackActionError, S as updateWorkspace, T as loadSnapshotsForProfile, Ut as isConversationScopedChannel, V as cancelSubscriptions, W as createTimerWatch, Wt as isDmChannel$1, Xt as JUNIOR_NATIVE_EVENT_NAMESPACE, Y as listWatches, _ as deleteWorkspace, at as getDashboardConversationLink, b as listWorkspaces, c as getPluginTools, en as conversationNoteEvent, ft as createPluginLogger, g as createWorkspace, j as tryWorkspaceRepoCheckoutPath, jt as saveObjectAnnotations, k as deleteWorkspaceSnapshotBuilders, l as getPluginUserPromptContributions, q as findMatchingWatches, qt as withSlackRetries, r as createPluginHookRunner, s as getPluginSystemPromptContributions, st as getDashboardTaskLink, u as getPlugins, v as getWorkspace, w as invalidateReadySnapshot, y as getWorkspaceByName, z as RESOURCE_WATCH_TOOL_SOURCE, zt as downloadPrivateSlackFile } from "./agent-hooks-BJ_5mlRH.js";
|
|
18
|
+
import { B as briefLinkSchema, H as conversationBriefSchema, J as removedCardSchema, L as detectImageMediaType, R as isVisionImageMediaType, V as briefOutcomeStatusSchema } from "./conversation-DjN3mlog.js";
|
|
19
|
+
import { A as SANDBOX_DATA_ROOT, D as fenceLock, E as acquireActiveLock, F as sandboxSkillFile, I as sandboxSkillPathResolution, M as SANDBOX_SKILLS_ROOT, N as SANDBOX_WORKSPACE_ROOT, O as withLock, P as sandboxSkillDir, _ as workspaceSnapshotNotReadyUserMessage, a as isAbortError, b as buildNonInteractiveShellScript, c as isSandboxCommandStreamInterruptedError, d as isSnapshottingError, f as throwSandboxOperationError, g as isWorkspaceSnapshotNotReadyError, h as getWorkspaceSnapshotNotReadyError, i as ensureDockerDaemon, j as SANDBOX_REPOS_ROOT, k as sleep, l as isSandboxMissingError, m as WorkspaceSnapshotNotReadyError, n as hash, o as isAlreadyExistsError, p as wrapSandboxSetupError, r as isStale, s as isSandboxApiTransientError, t as create, u as isSandboxUnavailableError, v as getVercelSandboxCredentials, w as getStateAdapter, x as runNonInteractiveCommand, y as buildCommandScript } from "./profile-DpYjfKke.js";
|
|
20
|
+
import { n as canReusePendingAuthLink, t as abandonReplacedPendingAuth } from "./pending-auth-D8J1uJUS.js";
|
|
21
|
+
import { c as isTurnInputCommitLostError, i as TurnInputCommitLostError, r as CooperativeTurnYieldError, t as authorizationId } from "./oauth-authorization-djQn5Nhy.js";
|
|
22
|
+
import { a as isNoReplyMarker, i as NO_REPLY_MARKER, n as getAssistantReplyText, r as sanitizeAssistantText, t as decideReply } from "./assistant-reply-H1M-91oF.js";
|
|
23
|
+
import { C as pluginSupportsEvent, D as requireEventIdentifier, E as registeredResourceTypeSchema, L as readAutomationResult, N as FINISH_AUTOMATION_RUN_TOOL_NAME, O as requireSupportedEventMatch, P as automationResultSchema, R as remindMissingAutomationResult, S as hasEventCatalogEntries, T as registeredEventTypeSchema, _ as workspaceSnapshotFinishedEvent, d as requireSlackChannelMessageScope, g as WORKSPACE_SNAPSHOT_READY_EVENT, h as WORKSPACE_SNAPSHOT_FAILED_EVENT, l as getEventCatalog, n as markConversationsStopped, o as enqueueEventNotification, t as getConversationStoppedAtMs, v as workspaceSnapshotWatch, w as registeredEventMatchSchema, x as eventNamespaceSchema, y as automationEventCatalog } from "./session-stop-CIoFiwwe.js";
|
|
24
|
+
import { i as isValidTimeZone, r as getZonedDateTimeParts } from "./cadence-R7Em4RjE.js";
|
|
25
|
+
import { a as createSandboxSession, c as postinstall, d as getSandboxResources, i as bindSandboxFileSystem, l as setSnapshotSpanAttributes, n as isMissingError, o as stopSession, r as resolve$1, s as dependencies } from "./resolve-ClCIgh8E.js";
|
|
26
|
+
import { a as getVercelConversationWorkQueue, f as getTurnRequestDeadline, n as sendNextWorkspaceSnapshotJob, r as sendWorkspaceSnapshotJob } from "./job-queue-DVe37it2.js";
|
|
27
|
+
import { E as stopConversationWork } from "./store-DJLwq4x8.js";
|
|
28
|
+
import { F as taskOutcomeInputSchema, M as compileScheduleIntent, N as scheduleIntentSchema, O as automationInstructionToolSchema, T as SCHEDULED_AUTOMATION_SYSTEM_ACTOR, j as ScheduleIntentError, k as automationTitleSchema } from "./automation-DWBFBenG.js";
|
|
29
|
+
import { r as isExperimentalFeatureEnabled } from "./experimental-BNK1l1jv.js";
|
|
30
|
+
import { n as privateTraceResultAttributes } from "./private-trace-result-CE7_lEdq.js";
|
|
31
31
|
import { streamSimple } from "@earendil-works/pi-ai/compat";
|
|
32
32
|
import { createGatewayProvider } from "@ai-sdk/gateway";
|
|
33
33
|
import { generateText } from "ai";
|
|
@@ -57,7 +57,7 @@ import net from "node:net";
|
|
|
57
57
|
import { NodeHtmlMarkdown } from "node-html-markdown";
|
|
58
58
|
import { Value } from "@sinclair/typebox/value";
|
|
59
59
|
import { SignJWT, importPKCS8 } from "jose";
|
|
60
|
-
|
|
60
|
+
// src/chat/configuration/defaults.ts
|
|
61
61
|
let installDefaults = {};
|
|
62
62
|
function cloneDefaults(defaults) {
|
|
63
63
|
return structuredClone(defaults);
|
|
@@ -78,8 +78,7 @@ function setConfigDefaults(defaults) {
|
|
|
78
78
|
function getConfigDefaults() {
|
|
79
79
|
return cloneDefaults(installDefaults);
|
|
80
80
|
}
|
|
81
|
-
|
|
82
|
-
//#region src/chat/sandbox/skill-sandbox.ts
|
|
81
|
+
// src/chat/sandbox/skill-sandbox.ts
|
|
83
82
|
const MAX_SKILL_FILE_BYTES = 262144;
|
|
84
83
|
const DEFAULT_MAX_SKILL_FILE_CHARS = 2e4;
|
|
85
84
|
const DEFAULT_MAX_SKILL_LIST_ENTRIES = 200;
|
|
@@ -219,12 +218,12 @@ var SkillSandbox = class {
|
|
|
219
218
|
}
|
|
220
219
|
const active = this.getActiveSkill();
|
|
221
220
|
if (active) return active;
|
|
222
|
-
|
|
221
|
+
const [onlySkill, ...otherSkills] = this.loadedSkills.values();
|
|
222
|
+
if (onlySkill && otherSkills.length === 0) return onlySkill;
|
|
223
223
|
throw new Error("No active skill is loaded. Call loadSkill first or pass skill_name explicitly.");
|
|
224
224
|
}
|
|
225
225
|
};
|
|
226
|
-
|
|
227
|
-
//#region src/chat/tools/sandbox/file-utils.ts
|
|
226
|
+
// src/chat/tools/sandbox/file-utils.ts
|
|
228
227
|
const MAX_TEXT_CHARS = 6e4;
|
|
229
228
|
const RIPGREP_EXCLUDED_GLOBS = ["!**/.git/**", "!**/node_modules/**"];
|
|
230
229
|
const DEFAULT_SEARCH_COMMAND_TIMEOUT_MS = 3e4;
|
|
@@ -269,7 +268,7 @@ function escapeRegExp(value) {
|
|
|
269
268
|
function globToRegExp(pattern) {
|
|
270
269
|
let source = "";
|
|
271
270
|
for (let index = 0; index < pattern.length; index += 1) {
|
|
272
|
-
const char = pattern
|
|
271
|
+
const char = pattern.charAt(index);
|
|
273
272
|
const next = pattern[index + 1];
|
|
274
273
|
if (char === "*" && next === "*") {
|
|
275
274
|
if (pattern[index + 2] === "/") {
|
|
@@ -390,8 +389,7 @@ async function collectFiles(params) {
|
|
|
390
389
|
missingRoot: missingPath === params.root
|
|
391
390
|
};
|
|
392
391
|
}
|
|
393
|
-
|
|
394
|
-
//#region src/chat/repository-instructions.ts
|
|
392
|
+
// src/chat/repository-instructions.ts
|
|
395
393
|
const AGENTS_FILENAME = "AGENTS.md";
|
|
396
394
|
const MAX_REPOSITORY_INSTRUCTIONS_BYTES = 32768;
|
|
397
395
|
/** Repository skill directories, in priority order, relative to the Git root. */
|
|
@@ -649,8 +647,7 @@ function findVisibleAgentsInstructions(messages) {
|
|
|
649
647
|
}
|
|
650
648
|
}
|
|
651
649
|
}
|
|
652
|
-
|
|
653
|
-
//#region src/chat/agent/repository-context.ts
|
|
650
|
+
// src/chat/agent/repository-context.ts
|
|
654
651
|
function findRestoredInstructions(messages, provenance) {
|
|
655
652
|
const restoredContext = messages?.map((message, index) => ({
|
|
656
653
|
message,
|
|
@@ -691,8 +688,7 @@ function createRepositoryInstructionsContext(options) {
|
|
|
691
688
|
};
|
|
692
689
|
} };
|
|
693
690
|
}
|
|
694
|
-
|
|
695
|
-
//#region src/chat/pi/traced-stream.ts
|
|
691
|
+
// src/chat/pi/traced-stream.ts
|
|
696
692
|
function attributeModeForPrivacy(conversationPrivacy) {
|
|
697
693
|
return conversationPrivacy === "public" ? "content" : "metadata";
|
|
698
694
|
}
|
|
@@ -800,13 +796,11 @@ function createTracedStreamFn(baseOrOptions = streamSimple) {
|
|
|
800
796
|
}
|
|
801
797
|
};
|
|
802
798
|
}
|
|
803
|
-
|
|
804
|
-
//#region src/chat/runtime/dev-agent-trace.ts
|
|
799
|
+
// src/chat/runtime/dev-agent-trace.ts
|
|
805
800
|
function shouldEmitDevAgentTrace() {
|
|
806
801
|
return process.env.NODE_ENV === "development";
|
|
807
802
|
}
|
|
808
|
-
|
|
809
|
-
//#region src/chat/agent-invocations/blocked-report.ts
|
|
803
|
+
// src/chat/agent-invocations/blocked-report.ts
|
|
810
804
|
/** Blocked report of a child agent. See "Blocked Reports" in README.md. */
|
|
811
805
|
/** Model-facing tool that ends a child agent run as blocked. */
|
|
812
806
|
const REPORT_BLOCKED_TOOL_NAME = "reportBlocked";
|
|
@@ -825,8 +819,7 @@ function readBlockedReport(messages) {
|
|
|
825
819
|
if (parsed.success) return parsed.data;
|
|
826
820
|
}
|
|
827
821
|
}
|
|
828
|
-
|
|
829
|
-
//#region src/chat/services/turn-result.ts
|
|
822
|
+
// src/chat/services/turn-result.ts
|
|
830
823
|
/** Process raw agent messages into a structured AgentRunResult. */
|
|
831
824
|
function buildTurnResult(input) {
|
|
832
825
|
if (input.requireAutomationResult) return buildAutomationTurnResult(input);
|
|
@@ -939,8 +932,7 @@ function buildAutomationTurnResult(input) {
|
|
|
939
932
|
})
|
|
940
933
|
};
|
|
941
934
|
}
|
|
942
|
-
|
|
943
|
-
//#region src/chat/services/provider-retry.ts
|
|
935
|
+
// src/chat/services/provider-retry.ts
|
|
944
936
|
const PROVIDER_RETRY_DELAYS_MS = [
|
|
945
937
|
2e3,
|
|
946
938
|
4e3,
|
|
@@ -965,8 +957,7 @@ function nextProviderRetry(args) {
|
|
|
965
957
|
providerError
|
|
966
958
|
};
|
|
967
959
|
}
|
|
968
|
-
|
|
969
|
-
//#region src/chat/services/empty-output-continuation.ts
|
|
960
|
+
// src/chat/services/empty-output-continuation.ts
|
|
970
961
|
/**
|
|
971
962
|
* Decide whether empty assistant output gets one continuation after a
|
|
972
963
|
* history replacement.
|
|
@@ -987,8 +978,7 @@ function nextEmptyOutputContinuation(args) {
|
|
|
987
978
|
messages
|
|
988
979
|
} : { kind: "exhausted" };
|
|
989
980
|
}
|
|
990
|
-
|
|
991
|
-
//#region src/chat/agent/retry-usage.ts
|
|
981
|
+
// src/chat/agent/retry-usage.ts
|
|
992
982
|
/**
|
|
993
983
|
* Return usage discarded when a retry keeps an exact prefix of agent history.
|
|
994
984
|
*
|
|
@@ -999,8 +989,7 @@ function getDiscardedRetryUsage(messages, retryMessages) {
|
|
|
999
989
|
const usage = extractGenAiUsageSummary(...messages.slice(retryMessages.length).filter(isAssistantMessage));
|
|
1000
990
|
return hasAgentTurnUsage(usage) ? usage : void 0;
|
|
1001
991
|
}
|
|
1002
|
-
|
|
1003
|
-
//#region src/chat/tool-support/structured-result.ts
|
|
992
|
+
// src/chat/tool-support/structured-result.ts
|
|
1004
993
|
const juniorToolContinuationSchema = z.object({
|
|
1005
994
|
arguments: z.record(z.string(), z.unknown()),
|
|
1006
995
|
reason: z.string().min(1).optional()
|
|
@@ -1042,8 +1031,7 @@ function makeStructuredToolOutput(details, options = {}) {
|
|
|
1042
1031
|
details
|
|
1043
1032
|
};
|
|
1044
1033
|
}
|
|
1045
|
-
|
|
1046
|
-
//#region src/chat/tool-support/timed-out-tool-result.ts
|
|
1034
|
+
// src/chat/tool-support/timed-out-tool-result.ts
|
|
1047
1035
|
/**
|
|
1048
1036
|
* Project a host-preempted tool attempt onto the normal tool-result shape.
|
|
1049
1037
|
*
|
|
@@ -1068,8 +1056,7 @@ function projectTimedOutToolResult(result) {
|
|
|
1068
1056
|
isError: false
|
|
1069
1057
|
};
|
|
1070
1058
|
}
|
|
1071
|
-
|
|
1072
|
-
//#region src/chat/services/turn-router.ts
|
|
1059
|
+
// src/chat/services/turn-router.ts
|
|
1073
1060
|
const CLASSIFIER_CONFIDENCE_THRESHOLD = .75;
|
|
1074
1061
|
const MAX_ROUTER_CONTEXT_CHARS = 8e3;
|
|
1075
1062
|
const ROUTER_CONTEXT_HEAD_CHARS = 3e3;
|
|
@@ -1304,8 +1291,7 @@ function toPiReasoningLevel(level) {
|
|
|
1304
1291
|
case "xhigh": return "xhigh";
|
|
1305
1292
|
}
|
|
1306
1293
|
}
|
|
1307
|
-
|
|
1308
|
-
//#region src/chat/services/auth-pause.ts
|
|
1294
|
+
// src/chat/services/auth-pause.ts
|
|
1309
1295
|
/**
|
|
1310
1296
|
* Runtime-owned signal that the current turn must park until the user
|
|
1311
1297
|
* completes an external authorization step.
|
|
@@ -1344,8 +1330,7 @@ var AuthorizationFlowDisabledError = class extends Error {
|
|
|
1344
1330
|
this.provider = provider;
|
|
1345
1331
|
}
|
|
1346
1332
|
};
|
|
1347
|
-
|
|
1348
|
-
//#region src/chat/tools/definition.ts
|
|
1333
|
+
// src/chat/tools/definition.ts
|
|
1349
1334
|
/** Distinguish legacy TypeBox schemas from JSON Schema projected from Zod. */
|
|
1350
1335
|
function isTypeBoxInputSchema(schema) {
|
|
1351
1336
|
return typeof schema === "object" && schema !== null && Kind in schema;
|
|
@@ -1367,8 +1352,7 @@ function disableTools(tools, reason) {
|
|
|
1367
1352
|
disabledReason: reason
|
|
1368
1353
|
}]));
|
|
1369
1354
|
}
|
|
1370
|
-
|
|
1371
|
-
//#region src/chat/agent/types.ts
|
|
1355
|
+
// src/chat/agent/types.ts
|
|
1372
1356
|
/** Resume the agent turn after a transient or ambiguous delivery failure. */
|
|
1373
1357
|
var RetryableDeliveryError = class extends Error {
|
|
1374
1358
|
constructor(cause) {
|
|
@@ -1434,8 +1418,7 @@ function surfaceFromRun(run) {
|
|
|
1434
1418
|
if (run.source.kind === "web") return "api";
|
|
1435
1419
|
return "internal";
|
|
1436
1420
|
}
|
|
1437
|
-
|
|
1438
|
-
//#region src/chat/tool-support/action-review-history.ts
|
|
1421
|
+
// src/chat/tool-support/action-review-history.ts
|
|
1439
1422
|
const MAX_VISIBLE_HISTORY_CHARS = 12e3;
|
|
1440
1423
|
const priorRejectionSchema = z.object({
|
|
1441
1424
|
decision: z.enum(["ask", "deny"]),
|
|
@@ -1537,8 +1520,7 @@ function restoreToolActionRejections(messages) {
|
|
|
1537
1520
|
}
|
|
1538
1521
|
return priorRejections;
|
|
1539
1522
|
}
|
|
1540
|
-
|
|
1541
|
-
//#region src/chat/agent/action-confirmation-retry.ts
|
|
1523
|
+
// src/chat/agent/action-confirmation-retry.ts
|
|
1542
1524
|
const RUN_ENDING_TOOL_NAMES = /* @__PURE__ */ new Set([FINISH_AUTOMATION_RUN_TOOL_NAME, REPORT_BLOCKED_TOOL_NAME]);
|
|
1543
1525
|
function endsRun(message) {
|
|
1544
1526
|
return isToolResultMessage(message) && !isToolResultError(message) && RUN_ENDING_TOOL_NAMES.has(normalizeToolNameFromResult(message) ?? "");
|
|
@@ -1567,8 +1549,7 @@ function actionConfirmationRetryMessages(messages) {
|
|
|
1567
1549
|
if (getPiMessageRole(retryMessages.at(-1)) !== "toolResult") return;
|
|
1568
1550
|
return retryMessages;
|
|
1569
1551
|
}
|
|
1570
|
-
|
|
1571
|
-
//#region src/chat/tool-support/action-review.ts
|
|
1552
|
+
// src/chat/tool-support/action-review.ts
|
|
1572
1553
|
/**
|
|
1573
1554
|
* Owns the execution gate for reviewable tool actions.
|
|
1574
1555
|
*
|
|
@@ -1843,8 +1824,7 @@ async function reviewToolAction(toolCallId, toolName, tool, input, review, signa
|
|
|
1843
1824
|
if (!review) throw new ToolActionReviewUnavailableError();
|
|
1844
1825
|
return review.review(toolCallId, toolName, tool, input, signal);
|
|
1845
1826
|
}
|
|
1846
|
-
|
|
1847
|
-
//#region src/chat/agent/skills.ts
|
|
1827
|
+
// src/chat/agent/skills.ts
|
|
1848
1828
|
/** Run-scoped skill discovery and explicit invocation. */
|
|
1849
1829
|
let startupDiscoveryLogged = false;
|
|
1850
1830
|
/** Upsert a skill into the active skills list by name. */
|
|
@@ -1894,8 +1874,7 @@ async function loadRunSkill(args) {
|
|
|
1894
1874
|
if (loadedSkill) upsertActiveSkill(args.activeSkills, loadedSkill);
|
|
1895
1875
|
return loadedSkill;
|
|
1896
1876
|
}
|
|
1897
|
-
|
|
1898
|
-
//#region src/chat/prompt.ts
|
|
1877
|
+
// src/chat/prompt.ts
|
|
1899
1878
|
/**
|
|
1900
1879
|
* Prompt assembly.
|
|
1901
1880
|
*
|
|
@@ -2378,8 +2357,7 @@ function buildTurnContextPrompt(params) {
|
|
|
2378
2357
|
`</${TURN_CONTEXT_TAG}>`
|
|
2379
2358
|
].filter((section) => Boolean(section)).join("\n\n");
|
|
2380
2359
|
}
|
|
2381
|
-
|
|
2382
|
-
//#region src/chat/conversations/notes.ts
|
|
2360
|
+
// src/chat/conversations/notes.ts
|
|
2383
2361
|
/**
|
|
2384
2362
|
* Conversation notes: short facts that core attaches to a Conversation without
|
|
2385
2363
|
* starting a Turn. The next Turn shows them to the model in its runtime turn
|
|
@@ -2436,8 +2414,7 @@ async function loadTurnConversationNotes(input) {
|
|
|
2436
2414
|
}
|
|
2437
2415
|
return newestFirst.reverse();
|
|
2438
2416
|
}
|
|
2439
|
-
|
|
2440
|
-
//#region src/chat/agent/prompt.ts
|
|
2417
|
+
// src/chat/agent/prompt.ts
|
|
2441
2418
|
/**
|
|
2442
2419
|
* Per-run prompt assembly.
|
|
2443
2420
|
*
|
|
@@ -2812,8 +2789,7 @@ async function assemblePrompt(args) {
|
|
|
2812
2789
|
userContentParts
|
|
2813
2790
|
};
|
|
2814
2791
|
}
|
|
2815
|
-
|
|
2816
|
-
//#region src/chat/capabilities/router.ts
|
|
2792
|
+
// src/chat/capabilities/router.ts
|
|
2817
2793
|
var ProviderCredentialRouter = class {
|
|
2818
2794
|
brokersByProvider;
|
|
2819
2795
|
constructor(input) {
|
|
@@ -2828,11 +2804,9 @@ var ProviderCredentialRouter = class {
|
|
|
2828
2804
|
});
|
|
2829
2805
|
}
|
|
2830
2806
|
};
|
|
2831
|
-
|
|
2832
|
-
//#region src/chat/credentials/user-token-store.ts
|
|
2807
|
+
// src/chat/credentials/user-token-store.ts
|
|
2833
2808
|
const storedTokensSchema = pluginStoredTokensSchema;
|
|
2834
|
-
|
|
2835
|
-
//#region src/chat/credentials/state-adapter-token-store.ts
|
|
2809
|
+
// src/chat/credentials/state-adapter-token-store.ts
|
|
2836
2810
|
const KEY_PREFIX = "oauth-token";
|
|
2837
2811
|
const BUFFER_MS = 864e5;
|
|
2838
2812
|
const LONG_LIVED_TTL_MS = 31536e6;
|
|
@@ -2878,8 +2852,7 @@ var StateAdapterTokenStore = class {
|
|
|
2878
2852
|
}
|
|
2879
2853
|
}
|
|
2880
2854
|
};
|
|
2881
|
-
|
|
2882
|
-
//#region src/chat/capabilities/factory.ts
|
|
2855
|
+
// src/chat/capabilities/factory.ts
|
|
2883
2856
|
const sandboxEgressRouters = /* @__PURE__ */ new WeakMap();
|
|
2884
2857
|
/** Create the user token store used by OAuth-backed credential brokers. */
|
|
2885
2858
|
function createUserTokenStore() {
|
|
@@ -2907,8 +2880,7 @@ function getSandboxEgressRouter() {
|
|
|
2907
2880
|
async function issueProviderCredentialLease(input) {
|
|
2908
2881
|
return await getSandboxEgressRouter().issue(input);
|
|
2909
2882
|
}
|
|
2910
|
-
|
|
2911
|
-
//#region src/chat/capabilities/jr-rpc-command.ts
|
|
2883
|
+
// src/chat/capabilities/jr-rpc-command.ts
|
|
2912
2884
|
function commandResult(input) {
|
|
2913
2885
|
let stdout = "";
|
|
2914
2886
|
if (typeof input.stdout === "string") stdout = input.stdout;
|
|
@@ -2941,7 +2913,7 @@ function parsePrefixFlag(extras) {
|
|
|
2941
2913
|
...prefix ? { prefix } : void 0
|
|
2942
2914
|
};
|
|
2943
2915
|
}
|
|
2944
|
-
if (extras.length === 1 && extras[0]
|
|
2916
|
+
if (extras.length === 1 && extras[0]?.startsWith("--prefix=")) {
|
|
2945
2917
|
const prefix = extras[0].slice(9).trim();
|
|
2946
2918
|
return {
|
|
2947
2919
|
ok: true,
|
|
@@ -3163,8 +3135,7 @@ async function maybeExecuteJrRpcCustomCommand(command, deps) {
|
|
|
3163
3135
|
}
|
|
3164
3136
|
};
|
|
3165
3137
|
}
|
|
3166
|
-
|
|
3167
|
-
//#region src/chat/sandbox/command-result.ts
|
|
3138
|
+
// src/chat/sandbox/command-result.ts
|
|
3168
3139
|
/** Format one shell command outcome as Junior's structured tool result. */
|
|
3169
3140
|
function formatSandboxCommandResult(params) {
|
|
3170
3141
|
return makeStructuredToolOutput({
|
|
@@ -3184,8 +3155,7 @@ function formatSandboxCommandResult(params) {
|
|
|
3184
3155
|
...params.permission_denied ? { permission_denied: params.permission_denied } : void 0
|
|
3185
3156
|
});
|
|
3186
3157
|
}
|
|
3187
|
-
|
|
3188
|
-
//#region src/chat/slack/oauth-authorization-message.ts
|
|
3158
|
+
// src/chat/slack/oauth-authorization-message.ts
|
|
3189
3159
|
const ACCOUNT_SCOPE_NOTE = "This connects only your account. Junior sees only what you can see.";
|
|
3190
3160
|
/** Present private OAuth authorization with a clear action and text fallback. */
|
|
3191
3161
|
function buildSlackOAuthAuthorizationMessage(args) {
|
|
@@ -3210,8 +3180,7 @@ function buildSlackOAuthAuthorizationMessage(args) {
|
|
|
3210
3180
|
}]
|
|
3211
3181
|
};
|
|
3212
3182
|
}
|
|
3213
|
-
|
|
3214
|
-
//#region src/chat/oauth-flow.ts
|
|
3183
|
+
// src/chat/oauth-flow.ts
|
|
3215
3184
|
const OAUTH_STATE_TTL_MS = 6e5;
|
|
3216
3185
|
function optionalString(value) {
|
|
3217
3186
|
return typeof value === "string" ? value : void 0;
|
|
@@ -3377,8 +3346,7 @@ async function startOAuthFlow(provider, input) {
|
|
|
3377
3346
|
})
|
|
3378
3347
|
};
|
|
3379
3348
|
}
|
|
3380
|
-
|
|
3381
|
-
//#region src/chat/sandbox/egress/schemas.ts
|
|
3349
|
+
// src/chat/sandbox/egress/schemas.ts
|
|
3382
3350
|
const finiteNumberSchema = z.number().refine(Number.isFinite);
|
|
3383
3351
|
const httpStatusSchema = z.number().int().min(100).max(599);
|
|
3384
3352
|
const providerNameSchema = z.string().regex(/^[a-z][a-z0-9-]*$/);
|
|
@@ -3441,8 +3409,7 @@ function parseSandboxEgressPermissionDeniedSignal(value) {
|
|
|
3441
3409
|
const result = sandboxEgressPermissionDeniedSignalSchema.safeParse(value);
|
|
3442
3410
|
return result.success ? result.data : void 0;
|
|
3443
3411
|
}
|
|
3444
|
-
|
|
3445
|
-
//#region src/chat/sandbox/egress/session.ts
|
|
3412
|
+
// src/chat/sandbox/egress/session.ts
|
|
3446
3413
|
const SANDBOX_EGRESS_PROXY_PATH = "/api/internal/sandbox-egress";
|
|
3447
3414
|
const SANDBOX_EGRESS_TOKEN_VERSION = "v1";
|
|
3448
3415
|
const SANDBOX_EGRESS_HMAC_CONTEXT = "junior.sandbox_egress.v1";
|
|
@@ -3650,8 +3617,7 @@ async function consumeSandboxEgressPermissionDeniedSignal(egressId) {
|
|
|
3650
3617
|
await Promise.all([state.delete(permissionSignalKey(egressId, "read")), state.delete(permissionSignalKey(egressId, "write"))]);
|
|
3651
3618
|
return signal;
|
|
3652
3619
|
}
|
|
3653
|
-
|
|
3654
|
-
//#region src/chat/sandbox/egress/tracing.ts
|
|
3620
|
+
// src/chat/sandbox/egress/tracing.ts
|
|
3655
3621
|
function isValidDomainPattern(domain) {
|
|
3656
3622
|
if (domain.includes("*")) return domain.startsWith("*.") && domain.indexOf("*", 1) === -1;
|
|
3657
3623
|
return true;
|
|
@@ -3679,8 +3645,7 @@ function shouldPropagateSandboxEgressTrace(host, config = {}) {
|
|
|
3679
3645
|
return domain === normalizedHost;
|
|
3680
3646
|
});
|
|
3681
3647
|
}
|
|
3682
|
-
|
|
3683
|
-
//#region src/chat/sandbox/egress/policy.ts
|
|
3648
|
+
// src/chat/sandbox/egress/policy.ts
|
|
3684
3649
|
/** Return whether an outbound host is covered by a provider domain rule. */
|
|
3685
3650
|
function matchesSandboxEgressDomain(host, domain) {
|
|
3686
3651
|
return host.toLowerCase() === domain.toLowerCase();
|
|
@@ -3749,8 +3714,7 @@ async function resolveSandboxCommandEnvironment() {
|
|
|
3749
3714
|
}
|
|
3750
3715
|
return env;
|
|
3751
3716
|
}
|
|
3752
|
-
|
|
3753
|
-
//#region src/chat/sandbox/prepare-workspace.ts
|
|
3717
|
+
// src/chat/sandbox/prepare-workspace.ts
|
|
3754
3718
|
const WORKSPACE_SETUP_FAILURE_OUTPUT_MAX_CHARS = 7e3;
|
|
3755
3719
|
const WORKSPACE_SETUP_FAILURE_TRUNCATION_MARKER = "[earlier setup output truncated]\n";
|
|
3756
3720
|
const WORKSPACE_SETUP_NODE_OPTIONS = "--max-old-space-size=4096";
|
|
@@ -3830,8 +3794,7 @@ async function prepareWorkspaceSnapshot(params) {
|
|
|
3830
3794
|
});
|
|
3831
3795
|
if (result.exitCode !== 0) throw new Error(`Workspace setup failed: ${workspaceSetupFailureDetail(result)}`);
|
|
3832
3796
|
}
|
|
3833
|
-
|
|
3834
|
-
//#region src/chat/events/people.ts
|
|
3797
|
+
// src/chat/events/people.ts
|
|
3835
3798
|
const linkedSlackIdentity$1 = alias(juniorIdentities, "event_people_slack");
|
|
3836
3799
|
function personKey(person) {
|
|
3837
3800
|
return "email" in person ? `email:${normalizeIdentityEmail(person.email)}` : `${person.provider}:${person.handle.toLowerCase()}`;
|
|
@@ -3876,8 +3839,7 @@ async function resolveEventPeopleMentions(people, slackTeamId) {
|
|
|
3876
3839
|
}
|
|
3877
3840
|
return mentions;
|
|
3878
3841
|
}
|
|
3879
|
-
|
|
3880
|
-
//#region src/chat/events/ingest.ts
|
|
3842
|
+
// src/chat/events/ingest.ts
|
|
3881
3843
|
/** Match a normalized event and enqueue notifications into conversations. */
|
|
3882
3844
|
async function ingestEvent(input, options) {
|
|
3883
3845
|
const event = eventSchema.parse(input);
|
|
@@ -3929,8 +3891,7 @@ async function ingestEvent(input, options) {
|
|
|
3929
3891
|
if (errors.length > 0) throw new AggregateError(errors, "Failed to deliver one or more watches");
|
|
3930
3892
|
return { enqueued };
|
|
3931
3893
|
}
|
|
3932
|
-
|
|
3933
|
-
//#region src/chat/sandbox/snapshot/workspace.ts
|
|
3894
|
+
// src/chat/sandbox/snapshot/workspace.ts
|
|
3934
3895
|
const BUILD_TIMEOUT_MS = 36e5;
|
|
3935
3896
|
const BUILD_TIMEOUT_ERROR = "Workspace snapshot build timed out after 1 hour";
|
|
3936
3897
|
const BUILD_LOCK_TTL_MS = 12e4;
|
|
@@ -4312,8 +4273,7 @@ async function resolveWorkspaceSnapshot(params) {
|
|
|
4312
4273
|
await sleep(WAIT_POLL_MS, params.signal);
|
|
4313
4274
|
}
|
|
4314
4275
|
}
|
|
4315
|
-
|
|
4316
|
-
//#region src/chat/sandbox/snapshot/job-runner.ts
|
|
4276
|
+
// src/chat/sandbox/snapshot/job-runner.ts
|
|
4317
4277
|
/** Build Workspace snapshots in a background job. */
|
|
4318
4278
|
const SNAPSHOT_BUILD_SYSTEM_ACTOR = {
|
|
4319
4279
|
platform: "system",
|
|
@@ -4437,8 +4397,7 @@ async function ensureWorkspaceSnapshotBuild(input) {
|
|
|
4437
4397
|
else await sendWorkspaceSnapshotJob(message);
|
|
4438
4398
|
return "building";
|
|
4439
4399
|
}
|
|
4440
|
-
|
|
4441
|
-
//#region src/chat/sandbox/skill-sync.ts
|
|
4400
|
+
// src/chat/sandbox/skill-sync.ts
|
|
4442
4401
|
const DIRECTORY_CREATE_CONCURRENCY = 8;
|
|
4443
4402
|
function toPosixRelative(base, absolute) {
|
|
4444
4403
|
return path.relative(base, absolute).split(path.sep).join("/");
|
|
@@ -4567,8 +4526,7 @@ async function syncSkillsToSandbox(params) {
|
|
|
4567
4526
|
});
|
|
4568
4527
|
});
|
|
4569
4528
|
}
|
|
4570
|
-
|
|
4571
|
-
//#region src/chat/sandbox/session.ts
|
|
4529
|
+
// src/chat/sandbox/session.ts
|
|
4572
4530
|
const DEFAULT_MAX_OUTPUT_LENGTH = 3e4;
|
|
4573
4531
|
const DEFAULT_BASH_COMMAND_TIMEOUT_MS = 3e5;
|
|
4574
4532
|
const SANDBOX_RUNTIME_BIN_DIR = `${SANDBOX_WORKSPACE_ROOT}/.junior/bin`;
|
|
@@ -5158,8 +5116,7 @@ function createSandboxRuntime(options) {
|
|
|
5158
5116
|
}
|
|
5159
5117
|
};
|
|
5160
5118
|
}
|
|
5161
|
-
|
|
5162
|
-
//#region src/chat/tools/sandbox/text-edits.ts
|
|
5119
|
+
// src/chat/tools/sandbox/text-edits.ts
|
|
5163
5120
|
const MAX_DIFF_LINE_CHARS = 4e3;
|
|
5164
5121
|
/** Preserve a text artifact's dominant line-ending style across rewrites. */
|
|
5165
5122
|
function detectLineEnding(value) {
|
|
@@ -5279,8 +5236,7 @@ function validateAndApplyTextEdits(content, edits, targetName) {
|
|
|
5279
5236
|
};
|
|
5280
5237
|
});
|
|
5281
5238
|
const matchedEdits = [];
|
|
5282
|
-
for (
|
|
5283
|
-
const edit = normalizedEdits[index];
|
|
5239
|
+
for (const [index, edit] of normalizedEdits.entries()) {
|
|
5284
5240
|
const matchIndex = content.indexOf(edit.oldText);
|
|
5285
5241
|
if (matchIndex === -1) throw new ToolInputError(`Could not find edits[${index}] in ${targetName}. oldText must match exactly including whitespace and newlines.`);
|
|
5286
5242
|
const occurrences = countOccurrences(content, edit.oldText);
|
|
@@ -5293,24 +5249,20 @@ function validateAndApplyTextEdits(content, edits, targetName) {
|
|
|
5293
5249
|
});
|
|
5294
5250
|
}
|
|
5295
5251
|
matchedEdits.sort((a, b) => a.matchIndex - b.matchIndex);
|
|
5296
|
-
for (
|
|
5252
|
+
for (const [index, current] of matchedEdits.entries()) {
|
|
5297
5253
|
const previous = matchedEdits[index - 1];
|
|
5298
|
-
|
|
5254
|
+
if (!previous) continue;
|
|
5299
5255
|
if (previous.matchIndex + previous.matchLength > current.matchIndex) throw new ToolInputError(`edits[${previous.editIndex}] and edits[${current.editIndex}] overlap in ${targetName}. Merge overlapping replacements into one edit.`);
|
|
5300
5256
|
}
|
|
5301
5257
|
let newContent = content;
|
|
5302
|
-
for (
|
|
5303
|
-
const edit = matchedEdits[index];
|
|
5304
|
-
newContent = newContent.slice(0, edit.matchIndex) + edit.newText + newContent.slice(edit.matchIndex + edit.matchLength);
|
|
5305
|
-
}
|
|
5258
|
+
for (const edit of [...matchedEdits].reverse()) newContent = newContent.slice(0, edit.matchIndex) + edit.newText + newContent.slice(edit.matchIndex + edit.matchLength);
|
|
5306
5259
|
if (newContent === content) throw new ToolInputError(`No changes made to ${targetName}.`);
|
|
5307
5260
|
return {
|
|
5308
5261
|
baseContent: content,
|
|
5309
5262
|
newContent
|
|
5310
5263
|
};
|
|
5311
5264
|
}
|
|
5312
|
-
|
|
5313
|
-
//#region src/chat/tool-support/zod-tool.ts
|
|
5265
|
+
// src/chat/tool-support/zod-tool.ts
|
|
5314
5266
|
function isContentOnlyToolResult(value) {
|
|
5315
5267
|
return value !== null && typeof value === "object" && Array.isArray(value.content) && !("details" in value);
|
|
5316
5268
|
}
|
|
@@ -5367,8 +5319,7 @@ function zodTool(definition) {
|
|
|
5367
5319
|
} } : void 0
|
|
5368
5320
|
};
|
|
5369
5321
|
}
|
|
5370
|
-
|
|
5371
|
-
//#region src/chat/tools/sandbox/edit-file.ts
|
|
5322
|
+
// src/chat/tools/sandbox/edit-file.ts
|
|
5372
5323
|
/** Accept common edit argument variants before Pi validates the canonical schema. */
|
|
5373
5324
|
function prepareEditFileArguments(input) {
|
|
5374
5325
|
return prepareTextReplacementArguments(input);
|
|
@@ -5423,8 +5374,7 @@ function createEditFileTool() {
|
|
|
5423
5374
|
}
|
|
5424
5375
|
});
|
|
5425
5376
|
}
|
|
5426
|
-
|
|
5427
|
-
//#region src/chat/tools/sandbox/find-files.ts
|
|
5377
|
+
// src/chat/tools/sandbox/find-files.ts
|
|
5428
5378
|
const DEFAULT_FIND_LIMIT = 100;
|
|
5429
5379
|
/** Find workspace files with structured limits instead of ad hoc shell output. */
|
|
5430
5380
|
async function findFiles(params) {
|
|
@@ -5571,8 +5521,7 @@ function createFindFilesTool() {
|
|
|
5571
5521
|
}
|
|
5572
5522
|
});
|
|
5573
5523
|
}
|
|
5574
|
-
|
|
5575
|
-
//#region src/chat/tools/sandbox/grep.ts
|
|
5524
|
+
// src/chat/tools/sandbox/grep.ts
|
|
5576
5525
|
const DEFAULT_GREP_LIMIT = 100;
|
|
5577
5526
|
const MAX_GREP_LINE_CHARS = 500;
|
|
5578
5527
|
const booleanInput$2 = (description) => z.preprocess((value) => value === "true" ? true : value === "false" ? false : value, z.boolean()).describe(description);
|
|
@@ -5645,10 +5594,10 @@ async function grepFiles(params) {
|
|
|
5645
5594
|
const lines = normalizeToLf$1(content).split("\n");
|
|
5646
5595
|
const relativePath = files.length === 1 && filePath === root ? path.posix.basename(filePath) : path.posix.relative(root, filePath);
|
|
5647
5596
|
const matchedLines = [];
|
|
5648
|
-
for (
|
|
5597
|
+
for (const [lineIndex, line] of lines.entries()) {
|
|
5649
5598
|
if (!lineMatches({
|
|
5650
5599
|
ignoreCase: params.ignoreCase,
|
|
5651
|
-
line
|
|
5600
|
+
line,
|
|
5652
5601
|
literal: params.literal,
|
|
5653
5602
|
pattern: params.pattern,
|
|
5654
5603
|
regex
|
|
@@ -5668,7 +5617,7 @@ async function grepFiles(params) {
|
|
|
5668
5617
|
for (let current = start; current <= end; current += 1) {
|
|
5669
5618
|
if (emittedLines.has(current)) continue;
|
|
5670
5619
|
emittedLines.add(current);
|
|
5671
|
-
const truncated = truncateGrepLine(lines[current]);
|
|
5620
|
+
const truncated = truncateGrepLine(lines[current] ?? "");
|
|
5672
5621
|
lineTruncated ||= truncated.truncated;
|
|
5673
5622
|
const separator = matchedLineSet.has(current) ? ":" : "-";
|
|
5674
5623
|
output.push(`${relativePath}${separator}${current + 1}${separator} ${truncated.line}`);
|
|
@@ -5850,8 +5799,7 @@ function createGrepTool() {
|
|
|
5850
5799
|
}
|
|
5851
5800
|
});
|
|
5852
5801
|
}
|
|
5853
|
-
|
|
5854
|
-
//#region src/chat/tools/sandbox/list-dir.ts
|
|
5802
|
+
// src/chat/tools/sandbox/list-dir.ts
|
|
5855
5803
|
const DEFAULT_LIST_LIMIT = 500;
|
|
5856
5804
|
/** List workspace directories without forcing the model through shell output. */
|
|
5857
5805
|
async function listDir(params) {
|
|
@@ -5926,8 +5874,7 @@ function createListDirTool() {
|
|
|
5926
5874
|
}
|
|
5927
5875
|
});
|
|
5928
5876
|
}
|
|
5929
|
-
|
|
5930
|
-
//#region src/chat/tool-support/text-range-result.ts
|
|
5877
|
+
// src/chat/tool-support/text-range-result.ts
|
|
5931
5878
|
const DEFAULT_READ_LIMIT = 1e3;
|
|
5932
5879
|
const MAX_READ_CHARS = 6e4;
|
|
5933
5880
|
function positiveInteger(value) {
|
|
@@ -6001,8 +5948,7 @@ function sliceFileContent(params) {
|
|
|
6001
5948
|
function missingFileResult(path) {
|
|
6002
5949
|
throw new ToolInputError(`File not found: ${path}`);
|
|
6003
5950
|
}
|
|
6004
|
-
|
|
6005
|
-
//#region src/chat/tools/sandbox/read-file.ts
|
|
5951
|
+
// src/chat/tools/sandbox/read-file.ts
|
|
6006
5952
|
/** Create the sandbox read tool definition exposed to the agent. */
|
|
6007
5953
|
function createReadFileTool() {
|
|
6008
5954
|
return zodTool({
|
|
@@ -6024,8 +5970,7 @@ function createReadFileTool() {
|
|
|
6024
5970
|
}
|
|
6025
5971
|
});
|
|
6026
5972
|
}
|
|
6027
|
-
|
|
6028
|
-
//#region src/chat/sandbox/sandbox.ts
|
|
5973
|
+
// src/chat/sandbox/sandbox.ts
|
|
6029
5974
|
/** Create the safe expected tool error for an unavailable sandbox operation. */
|
|
6030
5975
|
function createSandboxUnavailableToolError(operation, cause) {
|
|
6031
5976
|
return new ToolInputError(`The temporary sandbox became unavailable during ${operation}, so the operation did not complete reliably. The next sandbox operation will use a fresh session. It may have produced side effects; retry only if it is safe.`, { cause });
|
|
@@ -6436,8 +6381,7 @@ function createSandbox(options) {
|
|
|
6436
6381
|
}
|
|
6437
6382
|
};
|
|
6438
6383
|
}
|
|
6439
|
-
|
|
6440
|
-
//#region src/chat/tools/sandbox/file-uploads.ts
|
|
6384
|
+
// src/chat/tools/sandbox/file-uploads.ts
|
|
6441
6385
|
/** Maximum single file size accepted by model-facing upload tools. */
|
|
6442
6386
|
const MAX_SANDBOX_FILE_UPLOAD_BYTES = 10485760;
|
|
6443
6387
|
/** Sandbox directory for generated files that later tools can consume. */
|
|
@@ -6539,8 +6483,7 @@ async function readSandboxFileUpload(workspace, input) {
|
|
|
6539
6483
|
path: targetPath
|
|
6540
6484
|
};
|
|
6541
6485
|
}
|
|
6542
|
-
|
|
6543
|
-
//#region src/chat/tools/sandbox/generated-artifacts.ts
|
|
6486
|
+
// src/chat/tools/sandbox/generated-artifacts.ts
|
|
6544
6487
|
async function fileUploadDataToBuffer(data) {
|
|
6545
6488
|
if (Buffer.isBuffer(data)) return data;
|
|
6546
6489
|
if (data instanceof ArrayBuffer) return Buffer.from(data);
|
|
@@ -6572,8 +6515,7 @@ async function writeSandboxGeneratedArtifacts(workspace, files) {
|
|
|
6572
6515
|
})));
|
|
6573
6516
|
return artifacts.map((artifact) => artifact.ref);
|
|
6574
6517
|
}
|
|
6575
|
-
|
|
6576
|
-
//#region src/chat/tool-support/normalize-result.ts
|
|
6518
|
+
// src/chat/tool-support/normalize-result.ts
|
|
6577
6519
|
function isToolContent(value) {
|
|
6578
6520
|
return Array.isArray(value) && value.every((part) => {
|
|
6579
6521
|
if (!part || typeof part !== "object") return false;
|
|
@@ -6714,8 +6656,7 @@ function normalizeToolResult(result, options = {}) {
|
|
|
6714
6656
|
details: normalized.details
|
|
6715
6657
|
};
|
|
6716
6658
|
}
|
|
6717
|
-
|
|
6718
|
-
//#region src/chat/agent/sandbox.ts
|
|
6659
|
+
// src/chat/agent/sandbox.ts
|
|
6719
6660
|
function record(value) {
|
|
6720
6661
|
return value && typeof value === "object" && !Array.isArray(value) ? value : {};
|
|
6721
6662
|
}
|
|
@@ -6824,8 +6765,7 @@ function createAgentSandbox(options) {
|
|
|
6824
6765
|
}
|
|
6825
6766
|
};
|
|
6826
6767
|
}
|
|
6827
|
-
|
|
6828
|
-
//#region src/chat/mcp/errors.ts
|
|
6768
|
+
// src/chat/mcp/errors.ts
|
|
6829
6769
|
/** Safe failure at an MCP network or OAuth boundary. */
|
|
6830
6770
|
var McpProviderError = class extends Error {
|
|
6831
6771
|
phase;
|
|
@@ -6890,8 +6830,7 @@ function getMcpAwareTelemetryMessage(error, _privacy) {
|
|
|
6890
6830
|
if (error instanceof McpProviderError) return error.message;
|
|
6891
6831
|
return getMcpAwareErrorMessage(error);
|
|
6892
6832
|
}
|
|
6893
|
-
|
|
6894
|
-
//#region src/chat/mcp/client.ts
|
|
6833
|
+
// src/chat/mcp/client.ts
|
|
6895
6834
|
const MCP_CLIENT_INFO = {
|
|
6896
6835
|
name: "junior-mcp-client",
|
|
6897
6836
|
version: "1.0.0"
|
|
@@ -6924,8 +6863,6 @@ function isMissingSessionError(error) {
|
|
|
6924
6863
|
return error instanceof StreamableHTTPError && (error.code === 404 || /Session not found/i.test(error.message));
|
|
6925
6864
|
}
|
|
6926
6865
|
var PluginMcpClient = class {
|
|
6927
|
-
plugin;
|
|
6928
|
-
options;
|
|
6929
6866
|
client;
|
|
6930
6867
|
clientPromise;
|
|
6931
6868
|
lastAttemptedTransportSessionId;
|
|
@@ -6933,6 +6870,8 @@ var PluginMcpClient = class {
|
|
|
6933
6870
|
transport;
|
|
6934
6871
|
listedTools;
|
|
6935
6872
|
resourceHost;
|
|
6873
|
+
plugin;
|
|
6874
|
+
options;
|
|
6936
6875
|
constructor(plugin, options = {}) {
|
|
6937
6876
|
this.plugin = plugin;
|
|
6938
6877
|
this.options = options;
|
|
@@ -7100,8 +7039,7 @@ var PluginMcpClient = class {
|
|
|
7100
7039
|
await provider.saveMcpServerSessionId(sessionId);
|
|
7101
7040
|
}
|
|
7102
7041
|
};
|
|
7103
|
-
|
|
7104
|
-
//#region src/chat/mcp/tool-manager.ts
|
|
7042
|
+
// src/chat/mcp/tool-manager.ts
|
|
7105
7043
|
const MAX_TOOL_RESULT_TOKENS = 1e4;
|
|
7106
7044
|
const MAX_TOOL_RESULT_BYTES = 32768;
|
|
7107
7045
|
const CHARS_PER_ESTIMATED_TOKEN = 4;
|
|
@@ -7233,13 +7171,13 @@ function extractMcpErrorMessage(result) {
|
|
|
7233
7171
|
return "MCP tool call failed";
|
|
7234
7172
|
}
|
|
7235
7173
|
var McpToolManager = class {
|
|
7236
|
-
options;
|
|
7237
7174
|
pluginsByProvider = /* @__PURE__ */ new Map();
|
|
7238
7175
|
activeProviders = /* @__PURE__ */ new Set();
|
|
7239
7176
|
authorizationPendingProviders = /* @__PURE__ */ new Set();
|
|
7240
7177
|
clientsByProvider = /* @__PURE__ */ new Map();
|
|
7241
7178
|
clientPromisesByProvider = /* @__PURE__ */ new Map();
|
|
7242
7179
|
toolsByProvider = /* @__PURE__ */ new Map();
|
|
7180
|
+
options;
|
|
7243
7181
|
constructor(plugins, options = {}) {
|
|
7244
7182
|
this.options = options;
|
|
7245
7183
|
for (const plugin of plugins) if (plugin.manifest.mcp) this.pluginsByProvider.set(plugin.manifest.name, plugin);
|
|
@@ -7479,8 +7417,7 @@ function serializeMcpPayload(payload, privacy, options = {}) {
|
|
|
7479
7417
|
if (privacy !== "private") return serializeGenAiAttribute(payload);
|
|
7480
7418
|
return options.privateMetadata ? serializeGenAiAttribute(toGenAiPayloadMetadata(payload)) : void 0;
|
|
7481
7419
|
}
|
|
7482
|
-
|
|
7483
|
-
//#region src/chat/tools/sandbox/bash.ts
|
|
7420
|
+
// src/chat/tools/sandbox/bash.ts
|
|
7484
7421
|
/** Create the sandbox shell tool definition exposed to the agent. */
|
|
7485
7422
|
function createBashTool() {
|
|
7486
7423
|
return zodTool({
|
|
@@ -7503,8 +7440,7 @@ function createBashTool() {
|
|
|
7503
7440
|
}
|
|
7504
7441
|
});
|
|
7505
7442
|
}
|
|
7506
|
-
|
|
7507
|
-
//#region src/chat/tools/sandbox/image-files.ts
|
|
7443
|
+
// src/chat/tools/sandbox/image-files.ts
|
|
7508
7444
|
/**
|
|
7509
7445
|
* Read a sandbox image for a model request. The file signature, not the file
|
|
7510
7446
|
* name, sets the MIME type.
|
|
@@ -7522,8 +7458,7 @@ async function readSandboxImage(path, readFile, maxBytes) {
|
|
|
7522
7458
|
mimeType
|
|
7523
7459
|
};
|
|
7524
7460
|
}
|
|
7525
|
-
|
|
7526
|
-
//#region src/chat/tools/web/image-generate.ts
|
|
7461
|
+
// src/chat/tools/web/image-generate.ts
|
|
7527
7462
|
const MAX_REQUEST_IMAGE_BYTES = 3145728;
|
|
7528
7463
|
const MAX_SOURCE_IMAGE_BYTES = 26214400;
|
|
7529
7464
|
const RESIZE_LONGEST_EDGES = [
|
|
@@ -7762,8 +7697,7 @@ function createImageGenerateTool(hooks, options, deps = {}) {
|
|
|
7762
7697
|
}
|
|
7763
7698
|
});
|
|
7764
7699
|
}
|
|
7765
|
-
|
|
7766
|
-
//#region src/chat/mcp/tool-name.ts
|
|
7700
|
+
// src/chat/mcp/tool-name.ts
|
|
7767
7701
|
/** Extract the provider from canonical `mcp__<provider>__<tool>` names. */
|
|
7768
7702
|
function parseMcpProviderFromToolName(toolName) {
|
|
7769
7703
|
if (!toolName.startsWith("mcp__")) return void 0;
|
|
@@ -7771,8 +7705,7 @@ function parseMcpProviderFromToolName(toolName) {
|
|
|
7771
7705
|
const delimiterIndex = afterPrefix.indexOf("__");
|
|
7772
7706
|
return delimiterIndex > 0 ? afterPrefix.slice(0, delimiterIndex) : void 0;
|
|
7773
7707
|
}
|
|
7774
|
-
|
|
7775
|
-
//#region src/chat/tools/skill/call-mcp-tool.ts
|
|
7708
|
+
// src/chat/tools/skill/call-mcp-tool.ts
|
|
7776
7709
|
function resolveMcpArguments(input) {
|
|
7777
7710
|
const extraKeys = Object.keys(input).filter((key) => key !== "tool_name" && key !== "arguments" && key !== "intent");
|
|
7778
7711
|
if (extraKeys.length > 0) throw new ToolInputError(`callMcpTool MCP arguments must be nested under arguments, not top-level fields: ${extraKeys.join(", ")}`);
|
|
@@ -7852,8 +7785,7 @@ function createCallMcpToolTool(mcpToolManager) {
|
|
|
7852
7785
|
}
|
|
7853
7786
|
});
|
|
7854
7787
|
}
|
|
7855
|
-
|
|
7856
|
-
//#region src/chat/tools/skill/load-skill.ts
|
|
7788
|
+
// src/chat/tools/skill/load-skill.ts
|
|
7857
7789
|
function toLoadedSkill(result, availableSkills) {
|
|
7858
7790
|
if (typeof result.skill_name !== "string" || typeof result.description !== "string" || typeof result.skill_dir !== "string" || typeof result.instructions !== "string") return null;
|
|
7859
7791
|
const metadata = availableSkills.find((skill) => skill.name === result.skill_name) ?? null;
|
|
@@ -7904,8 +7836,7 @@ function createLoadSkillTool(availableSkills, options) {
|
|
|
7904
7836
|
}
|
|
7905
7837
|
});
|
|
7906
7838
|
}
|
|
7907
|
-
|
|
7908
|
-
//#region src/chat/tool-support/skill/mcp-tool-summary.ts
|
|
7839
|
+
// src/chat/tool-support/skill/mcp-tool-summary.ts
|
|
7909
7840
|
/** Convert a managed MCP tool descriptor into agent-visible search output. */
|
|
7910
7841
|
function toExposedToolSummary(toolDef) {
|
|
7911
7842
|
return {
|
|
@@ -7928,8 +7859,7 @@ function toActiveMcpCatalogSummaries(toolDefs) {
|
|
|
7928
7859
|
available_tool_count: availableToolCount
|
|
7929
7860
|
})).sort((left, right) => left.provider.localeCompare(right.provider));
|
|
7930
7861
|
}
|
|
7931
|
-
|
|
7932
|
-
//#region src/chat/tools/skill/search-mcp-tools.ts
|
|
7862
|
+
// src/chat/tools/skill/search-mcp-tools.ts
|
|
7933
7863
|
const DEFAULT_MAX_RESULTS$1 = 5;
|
|
7934
7864
|
const MAX_RESULTS$2 = 20;
|
|
7935
7865
|
const providerSummarySchema = z.object({
|
|
@@ -8078,8 +8008,7 @@ function createSearchMcpToolsTool(mcpToolManager) {
|
|
|
8078
8008
|
}
|
|
8079
8009
|
});
|
|
8080
8010
|
}
|
|
8081
|
-
|
|
8082
|
-
//#region src/chat/tools/sandbox/view-image.ts
|
|
8011
|
+
// src/chat/tools/sandbox/view-image.ts
|
|
8083
8012
|
const MAX_VIEW_IMAGE_BYTES = 5242880;
|
|
8084
8013
|
const viewImageInputSchema = z.object({ path: z.string().min(1).describe("Path to an image file in the sandbox workspace.") }).strict();
|
|
8085
8014
|
/** Create a tool that loads a sandbox image into the active model context. */
|
|
@@ -8105,8 +8034,7 @@ function createViewImageTool(sandbox, supportsImageInput, deps = {}) {
|
|
|
8105
8034
|
}
|
|
8106
8035
|
});
|
|
8107
8036
|
}
|
|
8108
|
-
|
|
8109
|
-
//#region src/chat/tools/runtime/report-progress.ts
|
|
8037
|
+
// src/chat/tools/runtime/report-progress.ts
|
|
8110
8038
|
/** Create the internal tool the model uses for sparse progress updates. */
|
|
8111
8039
|
function createReportProgressTool() {
|
|
8112
8040
|
return zodTool({
|
|
@@ -8122,8 +8050,7 @@ function createReportProgressTool() {
|
|
|
8122
8050
|
execute: async () => ({})
|
|
8123
8051
|
});
|
|
8124
8052
|
}
|
|
8125
|
-
|
|
8126
|
-
//#region src/chat/tools/runtime/update-plan.ts
|
|
8053
|
+
// src/chat/tools/runtime/update-plan.ts
|
|
8127
8054
|
const planItemSchema = z.object({
|
|
8128
8055
|
step: z.string().describe("Task step text."),
|
|
8129
8056
|
status: z.enum([
|
|
@@ -8157,8 +8084,7 @@ function createUpdatePlanTool() {
|
|
|
8157
8084
|
}] })
|
|
8158
8085
|
});
|
|
8159
8086
|
}
|
|
8160
|
-
|
|
8161
|
-
//#region src/chat/conversations/sql/subtree.ts
|
|
8087
|
+
// src/chat/conversations/sql/subtree.ts
|
|
8162
8088
|
/** Columns of the `conversation_subtree` table that `conversationSubtree` returns. */
|
|
8163
8089
|
const conversationSubtreeColumns = {
|
|
8164
8090
|
conversationId: sql`conversation_subtree.conversation_id`,
|
|
@@ -8190,8 +8116,7 @@ function conversationSubtree(conversationIds) {
|
|
|
8190
8116
|
select scope_conversation_id, conversation_id from tree
|
|
8191
8117
|
) conversation_subtree`;
|
|
8192
8118
|
}
|
|
8193
|
-
|
|
8194
|
-
//#region src/chat/agent-invocations/types.ts
|
|
8119
|
+
// src/chat/agent-invocations/types.ts
|
|
8195
8120
|
const exactStringSchema = z.string().min(1).refine((value) => value === value.trim());
|
|
8196
8121
|
const agentNameSchema = exactStringSchema.max(64);
|
|
8197
8122
|
/** `messageAgent` target for the parent of a child agent. */
|
|
@@ -8263,8 +8188,7 @@ const CHILD_AGENT_RESULTS = [
|
|
|
8263
8188
|
"blocked",
|
|
8264
8189
|
"failed"
|
|
8265
8190
|
];
|
|
8266
|
-
|
|
8267
|
-
//#region src/chat/agent-invocations/errors.ts
|
|
8191
|
+
// src/chat/agent-invocations/errors.ts
|
|
8268
8192
|
/** A child agent already uses this name in the parent Conversation. */
|
|
8269
8193
|
var AgentNameInUseError = class extends Error {
|
|
8270
8194
|
constructor(name) {
|
|
@@ -8293,8 +8217,7 @@ var AgentMessageTargetError = class extends Error {
|
|
|
8293
8217
|
this.name = "AgentMessageTargetError";
|
|
8294
8218
|
}
|
|
8295
8219
|
};
|
|
8296
|
-
|
|
8297
|
-
//#region src/chat/agent-invocations/store.ts
|
|
8220
|
+
// src/chat/agent-invocations/store.ts
|
|
8298
8221
|
const CREATE_LOCK_PREFIX = "junior:agent_invocation:create";
|
|
8299
8222
|
/**
|
|
8300
8223
|
* Return the SQL lock that one parent Conversation takes to start, message,
|
|
@@ -8720,8 +8643,7 @@ async function markAgentInvocationSteered(invocationId, nowMs = Date.now()) {
|
|
|
8720
8643
|
function isTerminalAgentInvocation(invocation) {
|
|
8721
8644
|
return TERMINAL_AGENT_INVOCATION_STATUSES.includes(invocation.status);
|
|
8722
8645
|
}
|
|
8723
|
-
|
|
8724
|
-
//#region src/chat/agent-invocations/list.ts
|
|
8646
|
+
// src/chat/agent-invocations/list.ts
|
|
8725
8647
|
function isChildAgentResult(status) {
|
|
8726
8648
|
return CHILD_AGENT_RESULTS.includes(status);
|
|
8727
8649
|
}
|
|
@@ -8813,8 +8735,7 @@ async function listAgentRelatives(input) {
|
|
|
8813
8735
|
siblings: family.filter((agent) => agent.childConversationId !== conversationId)
|
|
8814
8736
|
};
|
|
8815
8737
|
}
|
|
8816
|
-
|
|
8817
|
-
//#region src/chat/tools/runtime/list-agents.ts
|
|
8738
|
+
// src/chat/tools/runtime/list-agents.ts
|
|
8818
8739
|
const TASK_MAX_LENGTH = 1e3;
|
|
8819
8740
|
const ERROR_MAX_LENGTH = 500;
|
|
8820
8741
|
/** How a listed agent relates to the conversation that lists it. */
|
|
@@ -8909,8 +8830,7 @@ function createListAgentsTool(context) {
|
|
|
8909
8830
|
}
|
|
8910
8831
|
});
|
|
8911
8832
|
}
|
|
8912
|
-
|
|
8913
|
-
//#region src/chat/tools/runtime/message-agent.ts
|
|
8833
|
+
// src/chat/tools/runtime/message-agent.ts
|
|
8914
8834
|
/** Bound the text of one message so a loop cannot fill a mailbox quickly. */
|
|
8915
8835
|
const MESSAGE_AGENT_TEXT_MAX_LENGTH = 8e3;
|
|
8916
8836
|
const messageAgentOutputSchema = juniorToolOutputSchema.extend({
|
|
@@ -8956,8 +8876,7 @@ function createMessageAgentTool(messageAgent) {
|
|
|
8956
8876
|
}
|
|
8957
8877
|
});
|
|
8958
8878
|
}
|
|
8959
|
-
|
|
8960
|
-
//#region src/chat/tools/runtime/spawn-agent.ts
|
|
8879
|
+
// src/chat/tools/runtime/spawn-agent.ts
|
|
8961
8880
|
const spawnAgentOutputSchema = juniorToolOutputSchema.extend({ conversation_id: z.string().min(1).describe("Child conversation ID. Pass it to searchConversationEvents to read the child's history.") });
|
|
8962
8881
|
/** Create the asynchronous child-agent tool for one parent run. */
|
|
8963
8882
|
function createSpawnAgentTool(spawnAgent, profileControl) {
|
|
@@ -9014,8 +8933,7 @@ function createSpawnAgentTool(spawnAgent, profileControl) {
|
|
|
9014
8933
|
}
|
|
9015
8934
|
});
|
|
9016
8935
|
}
|
|
9017
|
-
|
|
9018
|
-
//#region src/chat/agent-invocations/markers.ts
|
|
8936
|
+
// src/chat/agent-invocations/markers.ts
|
|
9019
8937
|
/**
|
|
9020
8938
|
* Dashboard records for agent invocations. The parent Conversation gets one
|
|
9021
8939
|
* `subagent_started` and one `subagent_ended` event for each agent invocation.
|
|
@@ -9098,8 +9016,7 @@ async function recordSubagentEnded(invocation) {
|
|
|
9098
9016
|
createdAtMs: invocation.terminalAtMs
|
|
9099
9017
|
}]);
|
|
9100
9018
|
}
|
|
9101
|
-
|
|
9102
|
-
//#region src/chat/agent-invocations/stop.ts
|
|
9019
|
+
// src/chat/agent-invocations/stop.ts
|
|
9103
9020
|
/**
|
|
9104
9021
|
* Stop one child agent of a parent Conversation and every child agent below
|
|
9105
9022
|
* it. The parent gets no result. SQL stops the work first. Then each
|
|
@@ -9208,8 +9125,7 @@ async function stopLockedAgentInvocationTree(conversationId, nowMs) {
|
|
|
9208
9125
|
stopped: stopped.map(invocationFromRow).filter(isTerminalAgentInvocation)
|
|
9209
9126
|
};
|
|
9210
9127
|
}
|
|
9211
|
-
|
|
9212
|
-
//#region src/chat/tools/runtime/stop-agent.ts
|
|
9128
|
+
// src/chat/tools/runtime/stop-agent.ts
|
|
9213
9129
|
const stopAgentOutputSchema = juniorToolOutputSchema.extend({
|
|
9214
9130
|
conversation_id: z.string().min(1).describe("Stopped child conversation ID"),
|
|
9215
9131
|
stopped: z.boolean().describe("True when work was stopped. False when the child agent had already stopped.")
|
|
@@ -9239,8 +9155,7 @@ function createStopAgentTool(conversationId) {
|
|
|
9239
9155
|
}
|
|
9240
9156
|
});
|
|
9241
9157
|
}
|
|
9242
|
-
|
|
9243
|
-
//#region src/chat/tools/runtime/finish-automation-run.ts
|
|
9158
|
+
// src/chat/tools/runtime/finish-automation-run.ts
|
|
9244
9159
|
const RESULT_GUIDANCE = ["Use `no_action` when the run worked and nothing should be posted, such as when a condition in the instruction is not met, or when a temporary failure stopped the work.", "Use `misconfigured` when the run cannot do its job until its creator changes the automation: a provider, tool, account, or access that the job needs is missing, a target no longer exists, or the instruction cannot be done. Do not use it for a temporary failure or a condition that is not met."].join(" ");
|
|
9245
9160
|
/** Create the tool that ends one Automation run with a declared result. */
|
|
9246
9161
|
function createFinishAutomationRunTool(options) {
|
|
@@ -9277,8 +9192,7 @@ function createFinishAutomationRunTool(options) {
|
|
|
9277
9192
|
}
|
|
9278
9193
|
});
|
|
9279
9194
|
}
|
|
9280
|
-
|
|
9281
|
-
//#region src/chat/tools/runtime/report-blocked.ts
|
|
9195
|
+
// src/chat/tools/runtime/report-blocked.ts
|
|
9282
9196
|
/** Create the tool that ends a child agent run as blocked. */
|
|
9283
9197
|
function createReportBlockedTool() {
|
|
9284
9198
|
return zodTool({
|
|
@@ -9294,8 +9208,7 @@ function createReportBlockedTool() {
|
|
|
9294
9208
|
execute: async (input) => ({ missing: input.missing })
|
|
9295
9209
|
});
|
|
9296
9210
|
}
|
|
9297
|
-
|
|
9298
|
-
//#region src/chat/events/owned-watches.ts
|
|
9211
|
+
// src/chat/events/owned-watches.ts
|
|
9299
9212
|
/**
|
|
9300
9213
|
* Watch ownership for the watch tools. A Conversation owns its own watches and
|
|
9301
9214
|
* the watches of every child agent below it, at any depth. A child agent still
|
|
@@ -9341,8 +9254,7 @@ async function stopOwnedWatch(input) {
|
|
|
9341
9254
|
});
|
|
9342
9255
|
return stopped;
|
|
9343
9256
|
}
|
|
9344
|
-
|
|
9345
|
-
//#region src/chat/tools/list-watches.ts
|
|
9257
|
+
// src/chat/tools/list-watches.ts
|
|
9346
9258
|
const listedResourceWatchSchema = z.object({
|
|
9347
9259
|
id: z.string().min(1),
|
|
9348
9260
|
label: z.string().min(1),
|
|
@@ -9395,8 +9307,7 @@ function createListWatchesTool(context) {
|
|
|
9395
9307
|
}
|
|
9396
9308
|
});
|
|
9397
9309
|
}
|
|
9398
|
-
|
|
9399
|
-
//#region src/chat/tools/search-event-types.ts
|
|
9310
|
+
// src/chat/tools/search-event-types.ts
|
|
9400
9311
|
const DEFAULT_SEARCH_RESULTS = 10;
|
|
9401
9312
|
const MAX_SEARCH_RESULTS = 20;
|
|
9402
9313
|
const searchedResourceTypeSchema = z.object({
|
|
@@ -9476,8 +9387,7 @@ function createSearchEventTypesTool(catalog) {
|
|
|
9476
9387
|
}
|
|
9477
9388
|
});
|
|
9478
9389
|
}
|
|
9479
|
-
|
|
9480
|
-
//#region src/chat/tools/stop-watches.ts
|
|
9390
|
+
// src/chat/tools/stop-watches.ts
|
|
9481
9391
|
const resultDataSchema$1 = z.object({
|
|
9482
9392
|
watching_status: z.literal("stopped"),
|
|
9483
9393
|
stoppedIds: z.array(z.string().min(1))
|
|
@@ -9533,8 +9443,7 @@ function createStopWatchingResourcesTool(context) {
|
|
|
9533
9443
|
}
|
|
9534
9444
|
});
|
|
9535
9445
|
}
|
|
9536
|
-
|
|
9537
|
-
//#region src/chat/tools/watch-timer.ts
|
|
9446
|
+
// src/chat/tools/watch-timer.ts
|
|
9538
9447
|
/** Create one heartbeat-backed Watch in the current Conversation. */
|
|
9539
9448
|
function createWatchTimerTool(context) {
|
|
9540
9449
|
return zodTool({
|
|
@@ -9569,8 +9478,7 @@ function createWatchTimerTool(context) {
|
|
|
9569
9478
|
}
|
|
9570
9479
|
});
|
|
9571
9480
|
}
|
|
9572
|
-
|
|
9573
|
-
//#region src/chat/tools/watch-events.ts
|
|
9481
|
+
// src/chat/tools/watch-events.ts
|
|
9574
9482
|
function inputSchema(catalog) {
|
|
9575
9483
|
return z.object({
|
|
9576
9484
|
identifier: z.string().trim().min(1).describe("Plugin-defined resource identifier."),
|
|
@@ -9675,8 +9583,7 @@ function createWatchEventsTool(context, catalog) {
|
|
|
9675
9583
|
}
|
|
9676
9584
|
});
|
|
9677
9585
|
}
|
|
9678
|
-
|
|
9679
|
-
//#region src/chat/tools/events.ts
|
|
9586
|
+
// src/chat/tools/events.ts
|
|
9680
9587
|
/** Build the complete resource-watch tool set for this runtime context. */
|
|
9681
9588
|
function createEventTools(context, catalog) {
|
|
9682
9589
|
const enabled = hasEventCatalogEntries(catalog);
|
|
@@ -9690,8 +9597,7 @@ function createEventTools(context, catalog) {
|
|
|
9690
9597
|
stopWatchingResources: createStopWatchingResourcesTool(context)
|
|
9691
9598
|
};
|
|
9692
9599
|
}
|
|
9693
|
-
|
|
9694
|
-
//#region src/chat/automations/requester-mention.ts
|
|
9600
|
+
// src/chat/automations/requester-mention.ts
|
|
9695
9601
|
function namesPerson(text, name) {
|
|
9696
9602
|
const escaped = name.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
9697
9603
|
return new RegExp(`(?<![\\p{L}\\p{N}])${escaped}(?![\\p{L}\\p{N}])`, "iu").test(text);
|
|
@@ -9708,8 +9614,7 @@ function requireRequesterMention(instruction, actor) {
|
|
|
9708
9614
|
if (instruction.includes(mention)) return;
|
|
9709
9615
|
if (namesPerson(instruction, actor.fullName)) throw new ToolInputError(`The instruction names ${actor.fullName} without a Slack mention. Write ${mention} for this person.`);
|
|
9710
9616
|
}
|
|
9711
|
-
|
|
9712
|
-
//#region src/chat/task-outcomes.ts
|
|
9617
|
+
// src/chat/task-outcomes.ts
|
|
9713
9618
|
/** Resolve explicit message outcomes to the Slack Destinations stored on an Automation. */
|
|
9714
9619
|
async function resolveTaskOutcomes(outcomes, currentDestination, creatorSlackUserId) {
|
|
9715
9620
|
if (outcomes === void 0) return [];
|
|
@@ -9751,8 +9656,7 @@ function moveTaskOutcomes(outcomes, currentDestination, nextDestination) {
|
|
|
9751
9656
|
destination: nextDestination
|
|
9752
9657
|
} : outcome);
|
|
9753
9658
|
}
|
|
9754
|
-
|
|
9755
|
-
//#region src/chat/event-automations/tool-support.ts
|
|
9659
|
+
// src/chat/event-automations/tool-support.ts
|
|
9756
9660
|
const compactEventAutomationResultSchema = z.object({
|
|
9757
9661
|
id: z.string().min(1),
|
|
9758
9662
|
status: z.enum([
|
|
@@ -9915,8 +9819,7 @@ async function eventAutomationToolResult(conversationId, task, catalog, requeste
|
|
|
9915
9819
|
}])
|
|
9916
9820
|
};
|
|
9917
9821
|
}
|
|
9918
|
-
|
|
9919
|
-
//#region src/chat/tools/create-event-automation.ts
|
|
9822
|
+
// src/chat/tools/create-event-automation.ts
|
|
9920
9823
|
/** Build a retry-stable automation id scoped to actor, destination, and tool call. */
|
|
9921
9824
|
function buildEventAutomationId(args) {
|
|
9922
9825
|
const toolCallId = args.toolCallId?.trim();
|
|
@@ -10008,8 +9911,7 @@ function createEventAutomationTool(context, catalog) {
|
|
|
10008
9911
|
}
|
|
10009
9912
|
});
|
|
10010
9913
|
}
|
|
10011
|
-
|
|
10012
|
-
//#region src/chat/tools/delete-event-automation.ts
|
|
9914
|
+
// src/chat/tools/delete-event-automation.ts
|
|
10013
9915
|
/** Create the core tool that deletes an event automation. */
|
|
10014
9916
|
function createDeleteEventAutomationTool(context, catalog) {
|
|
10015
9917
|
return zodTool({
|
|
@@ -10044,8 +9946,7 @@ function createDeleteEventAutomationTool(context, catalog) {
|
|
|
10044
9946
|
}
|
|
10045
9947
|
});
|
|
10046
9948
|
}
|
|
10047
|
-
|
|
10048
|
-
//#region src/chat/tools/list-event-automations.ts
|
|
9949
|
+
// src/chat/tools/list-event-automations.ts
|
|
10049
9950
|
const MAX_LISTED_EVENT_AUTOMATIONS = 50;
|
|
10050
9951
|
/** Create the core tool that lists event automations for this destination. */
|
|
10051
9952
|
function createListEventAutomationsTool(context, catalog) {
|
|
@@ -10070,8 +9971,7 @@ function createListEventAutomationsTool(context, catalog) {
|
|
|
10070
9971
|
}
|
|
10071
9972
|
});
|
|
10072
9973
|
}
|
|
10073
|
-
|
|
10074
|
-
//#region src/chat/automations/edit-rules.ts
|
|
9974
|
+
// src/chat/automations/edit-rules.ts
|
|
10075
9975
|
/** Shared edit rules. Transport access checks run before these rules. */
|
|
10076
9976
|
var AutomationEditError = class extends ToolInputError {
|
|
10077
9977
|
field;
|
|
@@ -10106,8 +10006,7 @@ async function editAutomationFields(current, input, isCreator, changesExecution)
|
|
|
10106
10006
|
outcomes
|
|
10107
10007
|
};
|
|
10108
10008
|
}
|
|
10109
|
-
|
|
10110
|
-
//#region src/chat/event-automations/edit.ts
|
|
10009
|
+
// src/chat/event-automations/edit.ts
|
|
10111
10010
|
function changesEventAutomationTrigger(current, next) {
|
|
10112
10011
|
const currentEvents = [...current.events].sort();
|
|
10113
10012
|
const nextEvents = [...next.events].sort();
|
|
@@ -10147,8 +10046,7 @@ async function editEventAutomation(current, input, isCreator, catalog) {
|
|
|
10147
10046
|
throw error;
|
|
10148
10047
|
}
|
|
10149
10048
|
}
|
|
10150
|
-
|
|
10151
|
-
//#region src/chat/tools/update-event-automation.ts
|
|
10049
|
+
// src/chat/tools/update-event-automation.ts
|
|
10152
10050
|
/** Create the core tool that updates an event automation. */
|
|
10153
10051
|
function createUpdateEventAutomationTool(context, catalog) {
|
|
10154
10052
|
return zodTool({
|
|
@@ -10212,8 +10110,7 @@ function createUpdateEventAutomationTool(context, catalog) {
|
|
|
10212
10110
|
}
|
|
10213
10111
|
});
|
|
10214
10112
|
}
|
|
10215
|
-
|
|
10216
|
-
//#region src/chat/tools/event-automations.ts
|
|
10113
|
+
// src/chat/tools/event-automations.ts
|
|
10217
10114
|
/** Build event automation tools for a Conversation with a Slack Location. */
|
|
10218
10115
|
function createEventAutomationTools(context, catalog) {
|
|
10219
10116
|
if (!getSlackToolContext(context)) return {};
|
|
@@ -10224,8 +10121,7 @@ function createEventAutomationTools(context, catalog) {
|
|
|
10224
10121
|
deleteEventAutomation: createDeleteEventAutomationTool(context, catalog)
|
|
10225
10122
|
}, slackMessageTurnDisabledReason(context));
|
|
10226
10123
|
}
|
|
10227
|
-
|
|
10228
|
-
//#region src/chat/scheduled-automations/telemetry.ts
|
|
10124
|
+
// src/chat/scheduled-automations/telemetry.ts
|
|
10229
10125
|
/** Safe structured telemetry attributes for scheduled-automation lifecycle events. */
|
|
10230
10126
|
/** Correlation attributes shared by scheduled-automation create and run events. */
|
|
10231
10127
|
function scheduledAutomationAttributes(task, extras = {}) {
|
|
@@ -10260,8 +10156,7 @@ function scheduledAutomationRunAttributes(task, run, extras = {}) {
|
|
|
10260
10156
|
function logScheduledAutomationRunSkipped(task, run, extras = {}) {
|
|
10261
10157
|
logInfo("scheduled_automation.run.skipped", scheduledAutomationRunAttributes(task, run, extras));
|
|
10262
10158
|
}
|
|
10263
|
-
|
|
10264
|
-
//#region src/chat/scheduled-automations/identity.ts
|
|
10159
|
+
// src/chat/scheduled-automations/identity.ts
|
|
10265
10160
|
const SLACK_USER_ID_PATTERN = /^[UW][A-Z0-9]{5,}$/;
|
|
10266
10161
|
function clean(value) {
|
|
10267
10162
|
const normalized = value?.trim();
|
|
@@ -10288,8 +10183,7 @@ function sanitizeScheduledAutomationPrincipal(principal) {
|
|
|
10288
10183
|
...userName ? { userName } : void 0
|
|
10289
10184
|
};
|
|
10290
10185
|
}
|
|
10291
|
-
|
|
10292
|
-
//#region src/chat/scheduled-automations/tool-support.ts
|
|
10186
|
+
// src/chat/scheduled-automations/tool-support.ts
|
|
10293
10187
|
const TASK_ID_PREFIX = "sched";
|
|
10294
10188
|
const compactTaskResultSchema = z.object({
|
|
10295
10189
|
id: z.string(),
|
|
@@ -10507,8 +10401,7 @@ function buildTaskId(args) {
|
|
|
10507
10401
|
function normalizeStatus(value) {
|
|
10508
10402
|
if (value === "active" || value === "blocked") return value;
|
|
10509
10403
|
}
|
|
10510
|
-
|
|
10511
|
-
//#region src/chat/scheduled-automations/tools/create.ts
|
|
10404
|
+
// src/chat/scheduled-automations/tools/create.ts
|
|
10512
10405
|
/** Create a tool that stores a scheduled automation for the active Slack context. */
|
|
10513
10406
|
function createSlackScheduleCreateAutomationTool(context) {
|
|
10514
10407
|
return zodTool({
|
|
@@ -10606,8 +10499,7 @@ function createSlackScheduleCreateAutomationTool(context) {
|
|
|
10606
10499
|
}
|
|
10607
10500
|
});
|
|
10608
10501
|
}
|
|
10609
|
-
|
|
10610
|
-
//#region src/chat/scheduled-automations/tools/delete.ts
|
|
10502
|
+
// src/chat/scheduled-automations/tools/delete.ts
|
|
10611
10503
|
/** Create a tool that removes a scheduled automation from the active Slack conversation. */
|
|
10612
10504
|
function createSlackScheduleDeleteAutomationTool(context) {
|
|
10613
10505
|
return zodTool({
|
|
@@ -10650,8 +10542,7 @@ function createSlackScheduleDeleteAutomationTool(context) {
|
|
|
10650
10542
|
}
|
|
10651
10543
|
});
|
|
10652
10544
|
}
|
|
10653
|
-
|
|
10654
|
-
//#region src/chat/slack/id-param.ts
|
|
10545
|
+
// src/chat/slack/id-param.ts
|
|
10655
10546
|
/** Define a model-facing Slack channel ID parameter. */
|
|
10656
10547
|
function slackChannelIdParam(description) {
|
|
10657
10548
|
return z.string().min(1).describe(description);
|
|
@@ -10684,8 +10575,7 @@ function parseRequiredSlackUserIdParam(field, value) {
|
|
|
10684
10575
|
error: `Invalid \`${field}\` Slack user ID. Use a Slack user ID like \`U123\` or \`W123\`.`
|
|
10685
10576
|
};
|
|
10686
10577
|
}
|
|
10687
|
-
|
|
10688
|
-
//#region src/chat/scheduled-automations/tools/list.ts
|
|
10578
|
+
// src/chat/scheduled-automations/tools/list.ts
|
|
10689
10579
|
function taskMatchesQuery(task, query) {
|
|
10690
10580
|
const normalized = query.toLowerCase();
|
|
10691
10581
|
return [
|
|
@@ -10740,8 +10630,7 @@ function createSlackScheduleListAutomationsTool(context) {
|
|
|
10740
10630
|
}
|
|
10741
10631
|
});
|
|
10742
10632
|
}
|
|
10743
|
-
|
|
10744
|
-
//#region src/chat/scheduled-automations/tools/run-now.ts
|
|
10633
|
+
// src/chat/scheduled-automations/tools/run-now.ts
|
|
10745
10634
|
/** Create a tool that marks an existing scheduled automation due immediately. */
|
|
10746
10635
|
function createSlackScheduleRunAutomationNowTool(context) {
|
|
10747
10636
|
return zodTool({
|
|
@@ -10773,8 +10662,7 @@ function createSlackScheduleRunAutomationNowTool(context) {
|
|
|
10773
10662
|
}
|
|
10774
10663
|
});
|
|
10775
10664
|
}
|
|
10776
|
-
|
|
10777
|
-
//#region src/chat/scheduled-automations/edit.ts
|
|
10665
|
+
// src/chat/scheduled-automations/edit.ts
|
|
10778
10666
|
/** Build an edit without restarting completed work or changing creator identity. */
|
|
10779
10667
|
async function editScheduledAutomation(current, input, isCreator, nowMs) {
|
|
10780
10668
|
if (current.status === "completed" || current.status === "deleted") throw new AutomationEditError("Completed scheduled automations cannot be updated. Create a new automation instead.");
|
|
@@ -10807,8 +10695,7 @@ async function editScheduledAutomation(current, input, isCreator, nowMs) {
|
|
|
10807
10695
|
status
|
|
10808
10696
|
};
|
|
10809
10697
|
}
|
|
10810
|
-
|
|
10811
|
-
//#region src/chat/scheduled-automations/tools/update.ts
|
|
10698
|
+
// src/chat/scheduled-automations/tools/update.ts
|
|
10812
10699
|
/** Create a tool that edits a scheduled automation, including moving it here. */
|
|
10813
10700
|
function createSlackScheduleUpdateAutomationTool(context) {
|
|
10814
10701
|
return zodTool({
|
|
@@ -10878,8 +10765,7 @@ function createSlackScheduleUpdateAutomationTool(context) {
|
|
|
10878
10765
|
}
|
|
10879
10766
|
});
|
|
10880
10767
|
}
|
|
10881
|
-
|
|
10882
|
-
//#region src/chat/tools/scheduled-automations.ts
|
|
10768
|
+
// src/chat/tools/scheduled-automations.ts
|
|
10883
10769
|
function scheduledAutomationToolContext(context) {
|
|
10884
10770
|
const slackMessageTurn = isSlackMessageTurn(context) ? {
|
|
10885
10771
|
actor: context.actor,
|
|
@@ -10904,8 +10790,7 @@ function createScheduledAutomationTools(context) {
|
|
|
10904
10790
|
slackScheduleRunAutomationNow: createSlackScheduleRunAutomationNowTool(taskContext)
|
|
10905
10791
|
}, slackMessageTurnDisabledReason(context));
|
|
10906
10792
|
}
|
|
10907
|
-
|
|
10908
|
-
//#region src/chat/slack/channel.ts
|
|
10793
|
+
// src/chat/slack/channel.ts
|
|
10909
10794
|
const replySubtypeSchema = z.object({ subtype: z.string().optional() });
|
|
10910
10795
|
/** List channel history using Slack-native, pre-validated timestamp bounds. */
|
|
10911
10796
|
async function listChannelMessages(input) {
|
|
@@ -10994,8 +10879,7 @@ async function joinPublicChannel(channelId) {
|
|
|
10994
10879
|
idempotent: true
|
|
10995
10880
|
});
|
|
10996
10881
|
}
|
|
10997
|
-
|
|
10998
|
-
//#region src/chat/slack/tool-support/channel-access.ts
|
|
10882
|
+
// src/chat/slack/tool-support/channel-access.ts
|
|
10999
10883
|
const DENIED_PRIVATE = "Cannot read this Slack conversation because it is private. Only the current conversation or public channels are readable.";
|
|
11000
10884
|
const DENIED_NOT_FOUND = "Cannot read this Slack conversation because the channel was not found or the bot cannot see it.";
|
|
11001
10885
|
const DENIED_NOT_IN_CHANNEL = "Cannot read this Slack conversation because the bot is not in the channel.";
|
|
@@ -11118,8 +11002,7 @@ async function resolveOptionalSlackChannelRef(input) {
|
|
|
11118
11002
|
if (input.defaultChannelId) return { channelId: input.defaultChannelId };
|
|
11119
11003
|
throw new ToolInputError("Provide `channel_id`, or use this tool in an active Slack channel context.");
|
|
11120
11004
|
}
|
|
11121
|
-
|
|
11122
|
-
//#region src/chat/slack/tools/channel-join.ts
|
|
11005
|
+
// src/chat/slack/tools/channel-join.ts
|
|
11123
11006
|
/** Create a tool that joins one public Slack channel. */
|
|
11124
11007
|
function createSlackChannelJoinTool(context) {
|
|
11125
11008
|
return zodTool({
|
|
@@ -11168,8 +11051,7 @@ function createSlackChannelJoinTool(context) {
|
|
|
11168
11051
|
}
|
|
11169
11052
|
});
|
|
11170
11053
|
}
|
|
11171
|
-
|
|
11172
|
-
//#region src/chat/slack/context.ts
|
|
11054
|
+
// src/chat/slack/context.ts
|
|
11173
11055
|
function toTrimmedSlackString(value) {
|
|
11174
11056
|
return toOptionalString(value)?.trim() || void 0;
|
|
11175
11057
|
}
|
|
@@ -11235,8 +11117,7 @@ function resolveSlackChannelIdFromMessage(message) {
|
|
|
11235
11117
|
}
|
|
11236
11118
|
return resolveSlackChannelIdFromThreadId(toTrimmedSlackString(message.threadId));
|
|
11237
11119
|
}
|
|
11238
|
-
|
|
11239
|
-
//#region src/chat/slack/timestamp-param.ts
|
|
11120
|
+
// src/chat/slack/timestamp-param.ts
|
|
11240
11121
|
/** Define a model-facing Slack timestamp, normalizing numeric model args to strings. */
|
|
11241
11122
|
function slackTimestampParam(description) {
|
|
11242
11123
|
return z.preprocess((value) => typeof value === "number" && Number.isFinite(value) ? String(value) : value, z.string().min(1)).describe(description);
|
|
@@ -11269,8 +11150,7 @@ function parseRequiredSlackTimestampParam(field, value) {
|
|
|
11269
11150
|
error: `Invalid \`${field}\` Slack timestamp. Use a numeric Slack ts like \`1712345678.123456\`.`
|
|
11270
11151
|
};
|
|
11271
11152
|
}
|
|
11272
|
-
|
|
11273
|
-
//#region src/chat/slack/tools/channel-list-messages.ts
|
|
11153
|
+
// src/chat/slack/tools/channel-list-messages.ts
|
|
11274
11154
|
const booleanInput$1 = (description) => z.preprocess((value) => value === "true" ? true : value === "false" ? false : value, z.boolean()).describe(description);
|
|
11275
11155
|
/**
|
|
11276
11156
|
* Accept numeric Slack ts bounds and recover matching
|
|
@@ -11384,8 +11264,7 @@ function createSlackChannelListMessagesTool(context) {
|
|
|
11384
11264
|
}
|
|
11385
11265
|
});
|
|
11386
11266
|
}
|
|
11387
|
-
|
|
11388
|
-
//#region src/chat/slack/tools/conversation-brief-search.ts
|
|
11267
|
+
// src/chat/slack/tools/conversation-brief-search.ts
|
|
11389
11268
|
/** Create Slack-owned filtering and match details for Brief search. */
|
|
11390
11269
|
function createSlackConversationBriefSearchPort(teamId) {
|
|
11391
11270
|
return {
|
|
@@ -11412,15 +11291,13 @@ function createSlackConversationBriefSearchPort(teamId) {
|
|
|
11412
11291
|
}
|
|
11413
11292
|
};
|
|
11414
11293
|
}
|
|
11415
|
-
|
|
11416
|
-
//#region src/chat/conversations/tool-source.ts
|
|
11294
|
+
// src/chat/conversations/tool-source.ts
|
|
11417
11295
|
/** Deferred tool catalog source for retained Junior conversations. */
|
|
11418
11296
|
const CONVERSATIONS_TOOL_SOURCE = {
|
|
11419
11297
|
id: "conversations",
|
|
11420
11298
|
description: "Search messages and events in retained Junior conversations."
|
|
11421
11299
|
};
|
|
11422
|
-
|
|
11423
|
-
//#region src/chat/slack/tools/conversation-message-search.ts
|
|
11300
|
+
// src/chat/slack/tools/conversation-message-search.ts
|
|
11424
11301
|
const DEFAULT_LIMIT$3 = 20;
|
|
11425
11302
|
const MAX_LIMIT$2 = 50;
|
|
11426
11303
|
const conversationMessageSearchOutputSchema = juniorToolOutputSchema.extend({
|
|
@@ -11534,8 +11411,7 @@ function createSlackConversationMessageSearchTool(scope, currentConversationId)
|
|
|
11534
11411
|
}
|
|
11535
11412
|
});
|
|
11536
11413
|
}
|
|
11537
|
-
|
|
11538
|
-
//#region src/chat/slack/tools/public-search.ts
|
|
11414
|
+
// src/chat/slack/tools/public-search.ts
|
|
11539
11415
|
const DEFAULT_LIMIT$2 = 10;
|
|
11540
11416
|
const DEFAULT_CONTENT_TYPES = ["messages"];
|
|
11541
11417
|
const CONTENT_TYPES = [
|
|
@@ -11833,8 +11709,7 @@ function createSlackPublicSearchTool(actionToken) {
|
|
|
11833
11709
|
}
|
|
11834
11710
|
});
|
|
11835
11711
|
}
|
|
11836
|
-
|
|
11837
|
-
//#region src/chat/tools/idempotency.ts
|
|
11712
|
+
// src/chat/tools/idempotency.ts
|
|
11838
11713
|
function stableSerialize(value) {
|
|
11839
11714
|
if (Array.isArray(value)) return `[${value.map((entry) => stableSerialize(entry)).join(",")}]`;
|
|
11840
11715
|
if (value && typeof value === "object") return `{${Object.entries(value).sort((a, b) => a[0].localeCompare(b[0])).map(([key, entry]) => `${JSON.stringify(key)}:${stableSerialize(entry)}`).join(",")}}`;
|
|
@@ -11844,8 +11719,7 @@ function stableSerialize(value) {
|
|
|
11844
11719
|
function createOperationKey(toolName, input) {
|
|
11845
11720
|
return `${toolName}:${stableSerialize(input)}`;
|
|
11846
11721
|
}
|
|
11847
|
-
|
|
11848
|
-
//#region src/chat/slack/tools/message-add-reaction.ts
|
|
11722
|
+
// src/chat/slack/tools/message-add-reaction.ts
|
|
11849
11723
|
/** Create the tool that reacts to the current inbound Slack message. */
|
|
11850
11724
|
function createSlackMessageAddReactionTool(context, state) {
|
|
11851
11725
|
return zodTool({
|
|
@@ -11890,8 +11764,7 @@ function createSlackMessageAddReactionTool(context, state) {
|
|
|
11890
11764
|
}
|
|
11891
11765
|
});
|
|
11892
11766
|
}
|
|
11893
|
-
|
|
11894
|
-
//#region src/chat/attachments/store.ts
|
|
11767
|
+
// src/chat/attachments/store.ts
|
|
11895
11768
|
const DAY_MS = 864e5;
|
|
11896
11769
|
const ATTACHMENT_GC_BATCH_LIMIT = 200;
|
|
11897
11770
|
/** Time that Junior keeps attachment bytes after the file is stored. */
|
|
@@ -12182,8 +12055,7 @@ async function collectAttachmentGarbage(args) {
|
|
|
12182
12055
|
if (stillEligible.length === 0) return { deleted: 0 };
|
|
12183
12056
|
return { deleted: (await args.db.db().delete(juniorAttachments).where(inArray(juniorAttachments.id, stillEligible.map((row) => row.id))).returning({ id: juniorAttachments.id })).length };
|
|
12184
12057
|
}
|
|
12185
|
-
|
|
12186
|
-
//#region src/chat/tools/send-files.ts
|
|
12058
|
+
// src/chat/tools/send-files.ts
|
|
12187
12059
|
const sendFilesResultSchema = juniorToolOutputSchema.extend({
|
|
12188
12060
|
deduplicated: z.boolean().optional(),
|
|
12189
12061
|
attachment_refs: z.array(z.object({
|
|
@@ -12267,8 +12139,7 @@ function createSendFilesTool(state, materializeFile, output) {
|
|
|
12267
12139
|
}
|
|
12268
12140
|
});
|
|
12269
12141
|
}
|
|
12270
|
-
|
|
12271
|
-
//#region src/chat/slack/tools/send-files.ts
|
|
12142
|
+
// src/chat/slack/tools/send-files.ts
|
|
12272
12143
|
/** Deliver files to the active Slack Location and retain Conversation attachments. */
|
|
12273
12144
|
function createSlackSendFilesTool(context, state, materializeFile, attachments) {
|
|
12274
12145
|
const channelId = context.locationChannelId;
|
|
@@ -12291,8 +12162,7 @@ function createSlackSendFilesTool(context, state, materializeFile, attachments)
|
|
|
12291
12162
|
}
|
|
12292
12163
|
});
|
|
12293
12164
|
}
|
|
12294
|
-
|
|
12295
|
-
//#region src/chat/slack/canvas-references.ts
|
|
12165
|
+
// src/chat/slack/canvas-references.ts
|
|
12296
12166
|
const SLACK_FILE_ID_PATTERN = /^F[A-Z0-9]{4,}$/i;
|
|
12297
12167
|
const SLACK_CANVAS_PATH_PATTERN = /^\/(?:docs|canvas|files)\/(?:T[A-Z0-9]+\/)?(?:U[A-Z0-9]+\/)?(F[A-Z0-9]{4,})(?:\/|$)/i;
|
|
12298
12168
|
function isSlackHost(hostname) {
|
|
@@ -12316,8 +12186,7 @@ function extractCanvasId(input) {
|
|
|
12316
12186
|
return;
|
|
12317
12187
|
}
|
|
12318
12188
|
}
|
|
12319
|
-
|
|
12320
|
-
//#region src/chat/slack/tool-support/canvas/markdown.ts
|
|
12189
|
+
// src/chat/slack/tool-support/canvas/markdown.ts
|
|
12321
12190
|
function getListType(marker) {
|
|
12322
12191
|
return /^\d/.test(marker) ? "numbered" : "bullet";
|
|
12323
12192
|
}
|
|
@@ -12445,8 +12314,7 @@ function normalizeCanvasMarkdown(markdown) {
|
|
|
12445
12314
|
unwrappedBlockquoteCount
|
|
12446
12315
|
};
|
|
12447
12316
|
}
|
|
12448
|
-
|
|
12449
|
-
//#region src/chat/slack/tool-support/canvas/api.ts
|
|
12317
|
+
// src/chat/slack/tool-support/canvas/api.ts
|
|
12450
12318
|
/**
|
|
12451
12319
|
* Create a standalone Slack canvas owned by the bot and best-effort grant write
|
|
12452
12320
|
* access to the active channel. Standalone canvases (`canvases.create`) are not
|
|
@@ -12575,8 +12443,7 @@ async function readCanvas(canvasIdOrUrl) {
|
|
|
12575
12443
|
byteLength: buffer.byteLength
|
|
12576
12444
|
};
|
|
12577
12445
|
}
|
|
12578
|
-
|
|
12579
|
-
//#region src/chat/slack/tools/canvas/create.ts
|
|
12446
|
+
// src/chat/slack/tools/canvas/create.ts
|
|
12580
12447
|
/** Create a tool that provisions a new Slack canvas in the active channel. */
|
|
12581
12448
|
function createSlackCanvasCreateTool(context, state) {
|
|
12582
12449
|
return zodTool({
|
|
@@ -12627,8 +12494,7 @@ function createSlackCanvasCreateTool(context, state) {
|
|
|
12627
12494
|
}
|
|
12628
12495
|
});
|
|
12629
12496
|
}
|
|
12630
|
-
|
|
12631
|
-
//#region src/chat/slack/tool-support/canvas/context.ts
|
|
12497
|
+
// src/chat/slack/tool-support/canvas/context.ts
|
|
12632
12498
|
/** Model-facing Slack canvas ID or docs URL parameter. */
|
|
12633
12499
|
const slackCanvasRefParam = z.string().min(1).describe("Slack canvas/file ID or canvas/docs URL.");
|
|
12634
12500
|
/** Resolve model-provided canvas references before Slack API calls. */
|
|
@@ -12643,8 +12509,7 @@ function resolveCanvasTarget(canvas) {
|
|
|
12643
12509
|
canvasId
|
|
12644
12510
|
};
|
|
12645
12511
|
}
|
|
12646
|
-
|
|
12647
|
-
//#region src/chat/slack/tools/canvas/edit.ts
|
|
12512
|
+
// src/chat/slack/tools/canvas/edit.ts
|
|
12648
12513
|
function prepareCanvasEditArguments(input) {
|
|
12649
12514
|
return prepareTextReplacementArguments(input);
|
|
12650
12515
|
}
|
|
@@ -12714,8 +12579,7 @@ function createSlackCanvasEditTool(state) {
|
|
|
12714
12579
|
}
|
|
12715
12580
|
});
|
|
12716
12581
|
}
|
|
12717
|
-
|
|
12718
|
-
//#region src/chat/slack/tools/canvas/read.ts
|
|
12582
|
+
// src/chat/slack/tools/canvas/read.ts
|
|
12719
12583
|
const slackCanvasReadOutputSchema = juniorToolOutputSchema.extend({
|
|
12720
12584
|
canvas_id: z.string().optional(),
|
|
12721
12585
|
title: z.string().optional(),
|
|
@@ -12777,8 +12641,7 @@ function createSlackCanvasReadTool() {
|
|
|
12777
12641
|
}
|
|
12778
12642
|
});
|
|
12779
12643
|
}
|
|
12780
|
-
|
|
12781
|
-
//#region src/chat/slack/tools/canvas/write.ts
|
|
12644
|
+
// src/chat/slack/tools/canvas/write.ts
|
|
12782
12645
|
/** Create a tool that deliberately replaces a Slack canvas body. */
|
|
12783
12646
|
function createSlackCanvasWriteTool(state) {
|
|
12784
12647
|
return zodTool({
|
|
@@ -12821,8 +12684,7 @@ function createSlackCanvasWriteTool(state) {
|
|
|
12821
12684
|
}
|
|
12822
12685
|
});
|
|
12823
12686
|
}
|
|
12824
|
-
|
|
12825
|
-
//#region src/chat/slack/tool-support/list/api.ts
|
|
12687
|
+
// src/chat/slack/tool-support/list/api.ts
|
|
12826
12688
|
function normalizeKey(value) {
|
|
12827
12689
|
return (value ?? "").toLowerCase().replace(/[^a-z0-9]+/g, "_");
|
|
12828
12690
|
}
|
|
@@ -12981,14 +12843,12 @@ async function updateListItem(input) {
|
|
|
12981
12843
|
cells
|
|
12982
12844
|
}), 3, { action: "slackLists.items.update" });
|
|
12983
12845
|
}
|
|
12984
|
-
|
|
12985
|
-
//#region src/chat/slack/tool-support/list/params.ts
|
|
12846
|
+
// src/chat/slack/tool-support/list/params.ts
|
|
12986
12847
|
/** Model-facing Slack list ID parameter. */
|
|
12987
12848
|
const slackListIdParam = z.string().min(1).describe("Slack list ID.");
|
|
12988
12849
|
/** Model-facing Slack list item ID parameter. */
|
|
12989
12850
|
const slackListItemIdParam = z.string().min(1).describe("Slack list item ID.");
|
|
12990
|
-
|
|
12991
|
-
//#region src/chat/slack/tools/list/add-items.ts
|
|
12851
|
+
// src/chat/slack/tools/list/add-items.ts
|
|
12992
12852
|
/** Create a tool that appends items to an explicit Slack list. */
|
|
12993
12853
|
function createSlackListAddItemsTool(state) {
|
|
12994
12854
|
return zodTool({
|
|
@@ -13036,8 +12896,7 @@ function createSlackListAddItemsTool(state) {
|
|
|
13036
12896
|
}
|
|
13037
12897
|
});
|
|
13038
12898
|
}
|
|
13039
|
-
|
|
13040
|
-
//#region src/chat/slack/tools/list/create.ts
|
|
12899
|
+
// src/chat/slack/tools/list/create.ts
|
|
13041
12900
|
/** Create a tool that provisions a new Slack todo list. */
|
|
13042
12901
|
function createSlackListCreateTool(state) {
|
|
13043
12902
|
return zodTool({
|
|
@@ -13068,8 +12927,7 @@ function createSlackListCreateTool(state) {
|
|
|
13068
12927
|
}
|
|
13069
12928
|
});
|
|
13070
12929
|
}
|
|
13071
|
-
|
|
13072
|
-
//#region src/chat/slack/tools/list/get-items.ts
|
|
12930
|
+
// src/chat/slack/tools/list/get-items.ts
|
|
13073
12931
|
/** Create a tool that reads items from an explicit Slack list. */
|
|
13074
12932
|
function createSlackListGetItemsTool() {
|
|
13075
12933
|
return zodTool({
|
|
@@ -13096,8 +12954,7 @@ function createSlackListGetItemsTool() {
|
|
|
13096
12954
|
}
|
|
13097
12955
|
});
|
|
13098
12956
|
}
|
|
13099
|
-
|
|
13100
|
-
//#region src/chat/slack/tools/list/update-item.ts
|
|
12957
|
+
// src/chat/slack/tools/list/update-item.ts
|
|
13101
12958
|
const booleanInput = (description) => z.preprocess((value) => value === "true" ? true : value === "false" ? false : value, z.boolean()).describe(description);
|
|
13102
12959
|
const updateListItemInputSchema = z.union([z.object({
|
|
13103
12960
|
list_id: slackListIdParam,
|
|
@@ -13152,8 +13009,7 @@ function createSlackListUpdateItemTool(state) {
|
|
|
13152
13009
|
}
|
|
13153
13010
|
});
|
|
13154
13011
|
}
|
|
13155
|
-
|
|
13156
|
-
//#region src/chat/slack/tool-support/slack-message-url.ts
|
|
13012
|
+
// src/chat/slack/tool-support/slack-message-url.ts
|
|
13157
13013
|
/** Parse Slack archive URLs into structured message references. */
|
|
13158
13014
|
const SLACK_HOST_PATTERN = /^[a-z0-9-]+\.slack(?:-gov)?\.com$/;
|
|
13159
13015
|
const ARCHIVE_PATH_PATTERN = /^\/archives\/([CDG][A-Z0-9]+)\/p(\d{10})(\d{6})$/;
|
|
@@ -13228,8 +13084,7 @@ function parseSlackMessageReference(input) {
|
|
|
13228
13084
|
}
|
|
13229
13085
|
};
|
|
13230
13086
|
}
|
|
13231
|
-
|
|
13232
|
-
//#region src/chat/slack/message/blocks.ts
|
|
13087
|
+
// src/chat/slack/message/blocks.ts
|
|
13233
13088
|
const MAX_BLOCKS = 50;
|
|
13234
13089
|
const MAX_CHILDREN = 50;
|
|
13235
13090
|
const MAX_DEPTH = 16;
|
|
@@ -13310,8 +13165,7 @@ function renderBlockText(value) {
|
|
|
13310
13165
|
const budget = { remainingNodes: MAX_NODES };
|
|
13311
13166
|
return value.slice(0, MAX_BLOCKS).flatMap((block) => parseElement(block, budget, 0)).join("\n");
|
|
13312
13167
|
}
|
|
13313
|
-
|
|
13314
|
-
//#region src/chat/slack/message/attachments.ts
|
|
13168
|
+
// src/chat/slack/message/attachments.ts
|
|
13315
13169
|
const MAX_ATTACHMENTS = 10;
|
|
13316
13170
|
const MAX_FIELDS_PER_ATTACHMENT = 20;
|
|
13317
13171
|
const MAX_FIELD_CHARS = 1e3;
|
|
@@ -13414,8 +13268,7 @@ function renderAttachment(raw) {
|
|
|
13414
13268
|
function renderAttachmentText(input) {
|
|
13415
13269
|
return getAttachmentPayload(input).slice(0, MAX_ATTACHMENTS).map(renderAttachment).filter((line) => line.length > 0).map((line) => `[attachment] ${line}`).join("\n").slice(0, MAX_ATTACHMENT_TEXT_CHARS);
|
|
13416
13270
|
}
|
|
13417
|
-
|
|
13418
|
-
//#region src/chat/slack/tools/thread-read.ts
|
|
13271
|
+
// src/chat/slack/tools/thread-read.ts
|
|
13419
13272
|
const MAX_THREAD_READ_CHARS = 4e4;
|
|
13420
13273
|
/**
|
|
13421
13274
|
* Combine top-level `files` with files nested inside `attachments`
|
|
@@ -13611,8 +13464,7 @@ function createSlackThreadReadTool(context, attachmentDeps) {
|
|
|
13611
13464
|
}
|
|
13612
13465
|
});
|
|
13613
13466
|
}
|
|
13614
|
-
|
|
13615
|
-
//#region src/chat/slack/users.ts
|
|
13467
|
+
// src/chat/slack/users.ts
|
|
13616
13468
|
const profileFieldsSchema = z.object({ fields: z.record(z.string(), z.object({
|
|
13617
13469
|
value: z.string().optional(),
|
|
13618
13470
|
alt: z.string().optional(),
|
|
@@ -13765,8 +13617,7 @@ async function searchSlackUsers(options) {
|
|
|
13765
13617
|
truncated: listed.truncated
|
|
13766
13618
|
};
|
|
13767
13619
|
}
|
|
13768
|
-
|
|
13769
|
-
//#region src/chat/tools/user-lookup.ts
|
|
13620
|
+
// src/chat/tools/user-lookup.ts
|
|
13770
13621
|
const linkedSlackIdentity = alias(juniorIdentities, "user_lookup_slack_identity");
|
|
13771
13622
|
function explicitUserLookupError(error) {
|
|
13772
13623
|
if (error.apiError === "user_not_found" || error.code === "not_found") return "No Slack user found for the supplied user ID.";
|
|
@@ -13899,8 +13750,7 @@ function createUserLookupTool(teamId, providers) {
|
|
|
13899
13750
|
}
|
|
13900
13751
|
});
|
|
13901
13752
|
}
|
|
13902
|
-
|
|
13903
|
-
//#region src/chat/tools/system-time.ts
|
|
13753
|
+
// src/chat/tools/system-time.ts
|
|
13904
13754
|
const systemTimeInputSchema = z.object({ timezone: z.string().trim().min(1).optional().describe("Optional IANA timezone, for example America/Los_Angeles. When set, iso_local and timezone_offset_minutes are for that zone.") });
|
|
13905
13755
|
const systemTimeOutputSchema = juniorToolOutputSchema.extend({
|
|
13906
13756
|
unix_ms: z.number(),
|
|
@@ -13971,8 +13821,7 @@ function getTimeZoneOffsetMinutes(timestampMs, timezone) {
|
|
|
13971
13821
|
const asUtcMs = Date.UTC(parts.year, parts.month - 1, parts.day, parts.hour, parts.minute, parts.second);
|
|
13972
13822
|
return Math.round((timestampMs - asUtcMs) / 6e4);
|
|
13973
13823
|
}
|
|
13974
|
-
|
|
13975
|
-
//#region src/chat/tools/operator-sql.ts
|
|
13824
|
+
// src/chat/tools/operator-sql.ts
|
|
13976
13825
|
/** Deferred tool catalog source for operator tools. */
|
|
13977
13826
|
const OPERATOR_TOOL_SOURCE = {
|
|
13978
13827
|
id: "operator",
|
|
@@ -14052,8 +13901,7 @@ function createOperatorTools(context) {
|
|
|
14052
13901
|
}
|
|
14053
13902
|
}) };
|
|
14054
13903
|
}
|
|
14055
|
-
|
|
14056
|
-
//#region src/chat/artifacts/store.ts
|
|
13904
|
+
// src/chat/artifacts/store.ts
|
|
14057
13905
|
const MAX_IMAGE_BYTES = 10485760;
|
|
14058
13906
|
const IMAGE_EXTENSIONS = {
|
|
14059
13907
|
"image/gif": "gif",
|
|
@@ -14194,8 +14042,7 @@ function unpublishedArtifactHeaders() {
|
|
|
14194
14042
|
"x-content-type-options": "nosniff"
|
|
14195
14043
|
});
|
|
14196
14044
|
}
|
|
14197
|
-
|
|
14198
|
-
//#region src/chat/tools/publish-image.ts
|
|
14045
|
+
// src/chat/tools/publish-image.ts
|
|
14199
14046
|
const outputSchema$1 = juniorToolOutputSchema.extend({
|
|
14200
14047
|
bytes: z.number().int().positive(),
|
|
14201
14048
|
content_type: z.string().min(1),
|
|
@@ -14239,8 +14086,7 @@ function createPublishImageTool(args) {
|
|
|
14239
14086
|
}
|
|
14240
14087
|
});
|
|
14241
14088
|
}
|
|
14242
|
-
|
|
14243
|
-
//#region src/chat/tools/unpublish-image.ts
|
|
14089
|
+
// src/chat/tools/unpublish-image.ts
|
|
14244
14090
|
const outputSchema = juniorToolOutputSchema.extend({
|
|
14245
14091
|
filename: z.string().min(1),
|
|
14246
14092
|
unpublished: z.literal(true)
|
|
@@ -14272,8 +14118,7 @@ function createUnpublishImageTool(args) {
|
|
|
14272
14118
|
}
|
|
14273
14119
|
});
|
|
14274
14120
|
}
|
|
14275
|
-
|
|
14276
|
-
//#region src/chat/tools/load-attachment.ts
|
|
14121
|
+
// src/chat/tools/load-attachment.ts
|
|
14277
14122
|
const ATTACHMENT_DIR = ".junior/attachments";
|
|
14278
14123
|
async function readStream(stream) {
|
|
14279
14124
|
const chunks = [];
|
|
@@ -14328,8 +14173,7 @@ function createLoadAttachmentTool(args) {
|
|
|
14328
14173
|
}
|
|
14329
14174
|
});
|
|
14330
14175
|
}
|
|
14331
|
-
|
|
14332
|
-
//#region src/chat/tools/search-conversation-events.ts
|
|
14176
|
+
// src/chat/tools/search-conversation-events.ts
|
|
14333
14177
|
const DEFAULT_LIMIT$1 = 25;
|
|
14334
14178
|
const MAX_LIMIT$1 = 100;
|
|
14335
14179
|
const MAX_EVENT_DATA_BYTES = 4e3;
|
|
@@ -14539,8 +14383,7 @@ function stripReplacementHistoryField(value) {
|
|
|
14539
14383
|
replacement_history_count: Array.isArray(replacementHistory) ? replacementHistory.length : 0
|
|
14540
14384
|
};
|
|
14541
14385
|
}
|
|
14542
|
-
|
|
14543
|
-
//#region src/chat/briefs/search.ts
|
|
14386
|
+
// src/chat/briefs/search.ts
|
|
14544
14387
|
/** Search the latest Brief of each public root Conversation in one scope. */
|
|
14545
14388
|
async function searchConversationBriefs(db, args) {
|
|
14546
14389
|
const query = args.filters.query?.trim() || void 0;
|
|
@@ -14604,8 +14447,7 @@ async function searchConversationBriefs(db, args) {
|
|
|
14604
14447
|
};
|
|
14605
14448
|
});
|
|
14606
14449
|
}
|
|
14607
|
-
|
|
14608
|
-
//#region src/chat/tools/search-conversation-briefs.ts
|
|
14450
|
+
// src/chat/tools/search-conversation-briefs.ts
|
|
14609
14451
|
const DEFAULT_LIMIT = 10;
|
|
14610
14452
|
const MAX_LIMIT = 25;
|
|
14611
14453
|
const conversationBriefSearchOutputSchema = juniorToolOutputSchema.extend({
|
|
@@ -14716,8 +14558,7 @@ function createSearchConversationBriefsTool(scope, currentConversationId, provid
|
|
|
14716
14558
|
}
|
|
14717
14559
|
});
|
|
14718
14560
|
}
|
|
14719
|
-
|
|
14720
|
-
//#region src/chat/tools/handoff/tool.ts
|
|
14561
|
+
// src/chat/tools/handoff/tool.ts
|
|
14721
14562
|
const HANDOFF_TOOL_NAME = "handoff";
|
|
14722
14563
|
function formatHandoffProfiles(handoff) {
|
|
14723
14564
|
return handoff.profiles.map((profile) => `- ${formatModelProfile(profile.name, profile.description)}`).join("\n");
|
|
@@ -14758,8 +14599,7 @@ function createHandoffTool(handoff) {
|
|
|
14758
14599
|
}
|
|
14759
14600
|
});
|
|
14760
14601
|
}
|
|
14761
|
-
|
|
14762
|
-
//#region src/chat/plugins/credential-hooks.ts
|
|
14602
|
+
// src/chat/plugins/credential-hooks.ts
|
|
14763
14603
|
function parseSchema(schema, value, message) {
|
|
14764
14604
|
const result = schema.safeParse(value);
|
|
14765
14605
|
if (!result.success) throw new Error(message);
|
|
@@ -14887,31 +14727,30 @@ async function issuePluginCredential(input) {
|
|
|
14887
14727
|
}
|
|
14888
14728
|
}), plugin.manifest.name);
|
|
14889
14729
|
}
|
|
14890
|
-
|
|
14891
|
-
//#region src/chat/tools/web/constants.ts
|
|
14730
|
+
// src/chat/tools/web/constants.ts
|
|
14892
14731
|
const USER_AGENT = "junior-bot/0.1";
|
|
14893
14732
|
const FETCH_TIMEOUT_MS = 8e3;
|
|
14894
14733
|
const DEFAULT_MAX_CHARS = 6e3;
|
|
14895
14734
|
const MAX_FETCH_CHARS = 12e3;
|
|
14896
14735
|
const MAX_FETCH_BYTES = 1e6;
|
|
14897
|
-
|
|
14898
|
-
//#region src/chat/tools/web/network.ts
|
|
14736
|
+
// src/chat/tools/web/network.ts
|
|
14899
14737
|
function isPrivateIpv4(ip) {
|
|
14900
14738
|
const parts = ip.split(".").map((chunk) => Number.parseInt(chunk, 10));
|
|
14901
|
-
|
|
14902
|
-
if (parts
|
|
14903
|
-
if (
|
|
14904
|
-
if (
|
|
14905
|
-
if (
|
|
14906
|
-
if (
|
|
14739
|
+
const [first, second] = parts;
|
|
14740
|
+
if (parts.length !== 4 || first === void 0 || second === void 0 || parts.some((n) => Number.isNaN(n) || n < 0 || n > 255)) return true;
|
|
14741
|
+
if (first === 10 || first === 127) return true;
|
|
14742
|
+
if (first === 169 && second === 254) return true;
|
|
14743
|
+
if (first === 172 && second >= 16 && second <= 31) return true;
|
|
14744
|
+
if (first === 192 && second === 168) return true;
|
|
14745
|
+
if (first === 0) return true;
|
|
14907
14746
|
return false;
|
|
14908
14747
|
}
|
|
14909
14748
|
function parseMappedIpv4FromIpv6(mapped) {
|
|
14910
14749
|
if (net.isIP(mapped) === 4) return mapped;
|
|
14911
|
-
const
|
|
14912
|
-
if (!
|
|
14913
|
-
const high = Number.parseInt(
|
|
14914
|
-
const low = Number.parseInt(
|
|
14750
|
+
const [, highHex, lowHex] = mapped.match(/^([0-9a-f]{1,4}):([0-9a-f]{1,4})$/i) ?? [];
|
|
14751
|
+
if (!highHex || !lowHex) return;
|
|
14752
|
+
const high = Number.parseInt(highHex, 16);
|
|
14753
|
+
const low = Number.parseInt(lowHex, 16);
|
|
14915
14754
|
return `${high >> 8 & 255}.${high & 255}.${low >> 8 & 255}.${low & 255}`;
|
|
14916
14755
|
}
|
|
14917
14756
|
function isPrivateIpv6(ip) {
|
|
@@ -14937,7 +14776,6 @@ async function resolvePublicHostname(hostname) {
|
|
|
14937
14776
|
all: true,
|
|
14938
14777
|
verbatim: true
|
|
14939
14778
|
});
|
|
14940
|
-
if (records.length === 0) throw new ToolInputError("Could not resolve hostname");
|
|
14941
14779
|
const deduped = /* @__PURE__ */ new Map();
|
|
14942
14780
|
for (const record of records) {
|
|
14943
14781
|
const family = record.family === 6 ? 6 : 4;
|
|
@@ -14948,7 +14786,9 @@ async function resolvePublicHostname(hostname) {
|
|
|
14948
14786
|
family
|
|
14949
14787
|
});
|
|
14950
14788
|
}
|
|
14951
|
-
|
|
14789
|
+
const [first, ...rest] = deduped.values();
|
|
14790
|
+
if (!first) throw new ToolInputError("Could not resolve hostname");
|
|
14791
|
+
return [first, ...rest];
|
|
14952
14792
|
}
|
|
14953
14793
|
async function resolvePinnedAddresses(url) {
|
|
14954
14794
|
const hostname = normalizeHostname(url.hostname);
|
|
@@ -14956,7 +14796,7 @@ async function resolvePinnedAddresses(url) {
|
|
|
14956
14796
|
return resolvePublicHostname(hostname);
|
|
14957
14797
|
}
|
|
14958
14798
|
function createPinnedLookup(resolved) {
|
|
14959
|
-
const fallback = resolved
|
|
14799
|
+
const [fallback] = resolved;
|
|
14960
14800
|
return (_hostname, options, callback) => {
|
|
14961
14801
|
if (options?.all) {
|
|
14962
14802
|
callback(null, resolved.map((entry) => ({
|
|
@@ -15003,7 +14843,7 @@ async function fetchWithPinnedLookup(url, resolved, signal) {
|
|
|
15003
14843
|
signal.removeEventListener("abort", onAbort);
|
|
15004
14844
|
const headers = new Headers();
|
|
15005
14845
|
const rawHeaders = response.rawHeaders;
|
|
15006
|
-
for (let i = 0; i < rawHeaders.length; i += 2) headers.append(rawHeaders[i], rawHeaders[i + 1]);
|
|
14846
|
+
for (let i = 0; i + 1 < rawHeaders.length; i += 2) headers.append(rawHeaders[i] ?? "", rawHeaders[i + 1] ?? "");
|
|
15007
14847
|
const rawStatus = response.statusCode ?? 500;
|
|
15008
14848
|
const status = rawStatus >= 200 && rawStatus <= 599 ? rawStatus : 502;
|
|
15009
14849
|
resolve(new Response(Buffer.concat(chunks), {
|
|
@@ -15078,8 +14918,7 @@ async function readResponseBody(response, maxBytes) {
|
|
|
15078
14918
|
}
|
|
15079
14919
|
return new TextDecoder().decode(Buffer.concat(chunks));
|
|
15080
14920
|
}
|
|
15081
|
-
|
|
15082
|
-
//#region src/chat/tools/web/fetch-content.ts
|
|
14921
|
+
// src/chat/tools/web/fetch-content.ts
|
|
15083
14922
|
const htmlToMarkdownConverter = new NodeHtmlMarkdown({
|
|
15084
14923
|
bulletMarker: "-",
|
|
15085
14924
|
codeBlockStyle: "fenced",
|
|
@@ -15122,7 +14961,7 @@ function decodeHtmlEntities(value) {
|
|
|
15122
14961
|
}
|
|
15123
14962
|
function extractTitle(html) {
|
|
15124
14963
|
const match = html.match(/<title\b[^>]*>([\s\S]*?)<\/title>/i);
|
|
15125
|
-
const title = match ? normalizeWhitespace(decodeHtmlEntities(match[1])) : "";
|
|
14964
|
+
const title = match?.[1] !== void 0 ? normalizeWhitespace(decodeHtmlEntities(match[1])) : "";
|
|
15126
14965
|
return title.length > 0 ? title : void 0;
|
|
15127
14966
|
}
|
|
15128
14967
|
function escapeRegex(value) {
|
|
@@ -15220,8 +15059,7 @@ async function extractWebFetchResponse(url, response, maxChars = DEFAULT_MAX_CHA
|
|
|
15220
15059
|
truncated: extracted.truncated
|
|
15221
15060
|
};
|
|
15222
15061
|
}
|
|
15223
|
-
|
|
15224
|
-
//#region src/chat/tools/web/fetch-tool.ts
|
|
15062
|
+
// src/chat/tools/web/fetch-tool.ts
|
|
15225
15063
|
function extensionForMediaType(mediaType) {
|
|
15226
15064
|
if (mediaType === "image/png") return "png";
|
|
15227
15065
|
if (mediaType === "image/jpeg") return "jpg";
|
|
@@ -15279,8 +15117,7 @@ function createWebFetchTool(hooks, options = {}) {
|
|
|
15279
15117
|
}
|
|
15280
15118
|
});
|
|
15281
15119
|
}
|
|
15282
|
-
|
|
15283
|
-
//#region src/chat/tools/web/search.ts
|
|
15120
|
+
// src/chat/tools/web/search.ts
|
|
15284
15121
|
const SEARCH_TIMEOUT_MS = 6e4;
|
|
15285
15122
|
const MAX_RESULTS$1 = 5;
|
|
15286
15123
|
const SEARCH_TOOL_NAME = "parallelSearch";
|
|
@@ -15352,8 +15189,7 @@ function createWebSearchTool(modelId, override) {
|
|
|
15352
15189
|
}
|
|
15353
15190
|
});
|
|
15354
15191
|
}
|
|
15355
|
-
|
|
15356
|
-
//#region src/chat/tools/sandbox/write-file.ts
|
|
15192
|
+
// src/chat/tools/sandbox/write-file.ts
|
|
15357
15193
|
/** Create the sandbox full-file write tool definition exposed to the agent. */
|
|
15358
15194
|
function createWriteFileTool() {
|
|
15359
15195
|
return zodTool({
|
|
@@ -15375,8 +15211,7 @@ function createWriteFileTool() {
|
|
|
15375
15211
|
}
|
|
15376
15212
|
});
|
|
15377
15213
|
}
|
|
15378
|
-
|
|
15379
|
-
//#region src/stats.ts
|
|
15214
|
+
// src/stats.ts
|
|
15380
15215
|
function utcDate(nowMs) {
|
|
15381
15216
|
return new Date(nowMs).toISOString().slice(0, 10);
|
|
15382
15217
|
}
|
|
@@ -15401,8 +15236,7 @@ async function incrementStat(key, options = {}) {
|
|
|
15401
15236
|
async function readStats(start, end) {
|
|
15402
15237
|
return await getDb().select().from(juniorStats).where(and(gte(juniorStats.date, start), lte(juniorStats.date, end))).orderBy(asc(juniorStats.date), asc(juniorStats.namespace), asc(juniorStats.metric), asc(juniorStats.name));
|
|
15403
15238
|
}
|
|
15404
|
-
|
|
15405
|
-
//#region src/chat/workspaces/tools.ts
|
|
15239
|
+
// src/chat/workspaces/tools.ts
|
|
15406
15240
|
/** Record optional reporting without changing the switchWorkspace outcome. */
|
|
15407
15241
|
async function tryRecordWorkspaceSwitchStat(workspace) {
|
|
15408
15242
|
if (!process.env.DATABASE_URL) return;
|
|
@@ -15677,8 +15511,7 @@ function createWorkspaceTools(context) {
|
|
|
15677
15511
|
})
|
|
15678
15512
|
};
|
|
15679
15513
|
}
|
|
15680
|
-
|
|
15681
|
-
//#region src/chat/tools/index.ts
|
|
15514
|
+
// src/chat/tools/index.ts
|
|
15682
15515
|
function createToolState() {
|
|
15683
15516
|
const operationResultCache = /* @__PURE__ */ new Map();
|
|
15684
15517
|
return {
|
|
@@ -15811,8 +15644,7 @@ function createTools(availableSkills, hooks = {}, context, options = {}) {
|
|
|
15811
15644
|
}
|
|
15812
15645
|
return tools;
|
|
15813
15646
|
}
|
|
15814
|
-
|
|
15815
|
-
//#region src/chat/runtime/report-progress.ts
|
|
15647
|
+
// src/chat/runtime/report-progress.ts
|
|
15816
15648
|
function isActivePlanItem(value) {
|
|
15817
15649
|
if (!value || typeof value !== "object") return false;
|
|
15818
15650
|
const item = value;
|
|
@@ -15853,8 +15685,7 @@ function latestProgressStatus(messages) {
|
|
|
15853
15685
|
}
|
|
15854
15686
|
}
|
|
15855
15687
|
}
|
|
15856
|
-
|
|
15857
|
-
//#region src/chat/tool-support/catalog-tool-call.ts
|
|
15688
|
+
// src/chat/tool-support/catalog-tool-call.ts
|
|
15858
15689
|
function schemaErrorText(schema, value) {
|
|
15859
15690
|
const firstError = [...Value.Errors(schema, value)][0];
|
|
15860
15691
|
if (!firstError) return "invalid arguments";
|
|
@@ -15892,8 +15723,7 @@ function prepareCatalogToolCall(call) {
|
|
|
15892
15723
|
toolName: call.toolName
|
|
15893
15724
|
};
|
|
15894
15725
|
}
|
|
15895
|
-
|
|
15896
|
-
//#region src/chat/tools/execution/build-sandbox-input.ts
|
|
15726
|
+
// src/chat/tools/execution/build-sandbox-input.ts
|
|
15897
15727
|
/** Normalize LLM tool params into the shape expected by the sandbox executor. */
|
|
15898
15728
|
function buildSandboxInput(toolName, params) {
|
|
15899
15729
|
const optionalNumber = (value) => typeof value === "number" && Number.isFinite(value) ? value : void 0;
|
|
@@ -15936,8 +15766,7 @@ function buildSandboxInput(toolName, params) {
|
|
|
15936
15766
|
};
|
|
15937
15767
|
return params;
|
|
15938
15768
|
}
|
|
15939
|
-
|
|
15940
|
-
//#region src/chat/services/plugin-auth-orchestration.ts
|
|
15769
|
+
// src/chat/services/plugin-auth-orchestration.ts
|
|
15941
15770
|
var PluginAuthorizationPauseError = class extends AuthorizationPauseError {
|
|
15942
15771
|
constructor(provider, providerDisplayName, disposition, requestText) {
|
|
15943
15772
|
super("plugin", provider, providerDisplayName, disposition, requestText);
|
|
@@ -16050,8 +15879,7 @@ function createPluginAuthOrchestration(input) {
|
|
|
16050
15879
|
getPendingPause: () => pendingPause
|
|
16051
15880
|
};
|
|
16052
15881
|
}
|
|
16053
|
-
|
|
16054
|
-
//#region src/chat/tools/execution/tool-error-handler.ts
|
|
15882
|
+
// src/chat/tools/execution/tool-error-handler.ts
|
|
16055
15883
|
function isPluginToolInputError(error) {
|
|
16056
15884
|
return error instanceof PluginToolInputError || error instanceof Error && error.name === "PluginToolInputError";
|
|
16057
15885
|
}
|
|
@@ -16112,8 +15940,7 @@ function handleToolExecutionError(error, toolName, toolCallId, shouldTrace, conv
|
|
|
16112
15940
|
});
|
|
16113
15941
|
throw error;
|
|
16114
15942
|
}
|
|
16115
|
-
|
|
16116
|
-
//#region src/chat/tools/execute-tool.ts
|
|
15943
|
+
// src/chat/tools/execute-tool.ts
|
|
16117
15944
|
const EXECUTE_TOOL_NAME = "executeTool";
|
|
16118
15945
|
/** Create the model-visible dispatcher schema for catalog tools. */
|
|
16119
15946
|
function createExecuteToolTool() {
|
|
@@ -16136,8 +15963,7 @@ function createExecuteToolTool() {
|
|
|
16136
15963
|
}
|
|
16137
15964
|
});
|
|
16138
15965
|
}
|
|
16139
|
-
|
|
16140
|
-
//#region src/chat/tool-exposure.ts
|
|
15966
|
+
// src/chat/tool-exposure.ts
|
|
16141
15967
|
/** Return the runtime exposure for a tool, preserving direct compatibility. */
|
|
16142
15968
|
function effectiveToolExposure(definition) {
|
|
16143
15969
|
return definition.exposure ?? "direct";
|
|
@@ -16164,8 +15990,7 @@ function planToolExposure(tools) {
|
|
|
16164
15990
|
excludedTools
|
|
16165
15991
|
};
|
|
16166
15992
|
}
|
|
16167
|
-
|
|
16168
|
-
//#region src/chat/tools/search-tools.ts
|
|
15993
|
+
// src/chat/tools/search-tools.ts
|
|
16169
15994
|
const SEARCH_TOOLS_NAME = "searchTools";
|
|
16170
15995
|
const DEFAULT_MAX_RESULTS = 5;
|
|
16171
15996
|
const MAX_RESULTS = 20;
|
|
@@ -16422,8 +16247,7 @@ function createSearchToolsTool(catalogTools) {
|
|
|
16422
16247
|
}
|
|
16423
16248
|
});
|
|
16424
16249
|
}
|
|
16425
|
-
|
|
16426
|
-
//#region src/chat/tool-support/pi-tool-adapter.ts
|
|
16250
|
+
// src/chat/tool-support/pi-tool-adapter.ts
|
|
16427
16251
|
/**
|
|
16428
16252
|
* How long a preempted tool may take to return its own aborted result. Keep it
|
|
16429
16253
|
* below the agent's abort settle grace, so the parked turn sees the result.
|
|
@@ -16655,8 +16479,7 @@ function createPiAgentTools(tools, sandbox, spanContext, onStatus, sandboxTools,
|
|
|
16655
16479
|
}
|
|
16656
16480
|
}));
|
|
16657
16481
|
}
|
|
16658
|
-
|
|
16659
|
-
//#region src/chat/mcp/jwt-bearer-provider.ts
|
|
16482
|
+
// src/chat/mcp/jwt-bearer-provider.ts
|
|
16660
16483
|
/**
|
|
16661
16484
|
* Non-interactive MCP auth for bot plugins.
|
|
16662
16485
|
*
|
|
@@ -16724,8 +16547,7 @@ function createJwtBearerMcpClientProvider(subject, mcpUrl, auth) {
|
|
|
16724
16547
|
}
|
|
16725
16548
|
};
|
|
16726
16549
|
}
|
|
16727
|
-
|
|
16728
|
-
//#region src/chat/mcp/auth-store.ts
|
|
16550
|
+
// src/chat/mcp/auth-store.ts
|
|
16729
16551
|
const MCP_AUTH_SESSION_PREFIX = "junior:mcp_oauth_attempt:v2";
|
|
16730
16552
|
const MCP_AUTH_CREDENTIALS_PREFIX = "junior:mcp_auth_credentials";
|
|
16731
16553
|
const MCP_AUTH_SESSION_INDEX_PREFIX = "junior:mcp_oauth_attempt_index:v2";
|
|
@@ -16890,8 +16712,7 @@ async function putMcpServerSessionId(userId, provider, sessionId, ttlMs = MCP_SE
|
|
|
16890
16712
|
async function deleteMcpServerSessionId(userId, provider) {
|
|
16891
16713
|
await (await getConnectedStateAdapter()).delete(serverSessionKey(userId, provider));
|
|
16892
16714
|
}
|
|
16893
|
-
|
|
16894
|
-
//#region src/chat/mcp/oauth-provider.ts
|
|
16715
|
+
// src/chat/mcp/oauth-provider.ts
|
|
16895
16716
|
function createClientMetadata(callbackUrl) {
|
|
16896
16717
|
return {
|
|
16897
16718
|
client_name: "Junior MCP Client",
|
|
@@ -16912,12 +16733,12 @@ function requireEnv(name) {
|
|
|
16912
16733
|
return value;
|
|
16913
16734
|
}
|
|
16914
16735
|
var StateBackedMcpOAuthClientProvider = class {
|
|
16736
|
+
clientMetadata;
|
|
16915
16737
|
authSessionId;
|
|
16916
16738
|
callbackUrl;
|
|
16917
16739
|
sessionContext;
|
|
16918
16740
|
runCredentialMutation;
|
|
16919
16741
|
oauthClient;
|
|
16920
|
-
clientMetadata;
|
|
16921
16742
|
constructor(authSessionId, callbackUrl, sessionContext, runCredentialMutation, oauthClient) {
|
|
16922
16743
|
this.authSessionId = authSessionId;
|
|
16923
16744
|
this.callbackUrl = callbackUrl;
|
|
@@ -17050,8 +16871,7 @@ var StateBackedMcpOAuthClientProvider = class {
|
|
|
17050
16871
|
return session;
|
|
17051
16872
|
}
|
|
17052
16873
|
};
|
|
17053
|
-
|
|
17054
|
-
//#region src/chat/mcp/oauth.ts
|
|
16874
|
+
// src/chat/mcp/oauth.ts
|
|
17055
16875
|
function getMcpOAuthCallbackPath(provider) {
|
|
17056
16876
|
return `/api/oauth/callback/mcp/${provider}`;
|
|
17057
16877
|
}
|
|
@@ -17123,8 +16943,7 @@ async function finalizeMcpAuthorization(provider, authSessionId, authorizationCo
|
|
|
17123
16943
|
if (!nextSession) throw new Error(`Unknown MCP auth session: ${authSessionId}`);
|
|
17124
16944
|
return nextSession;
|
|
17125
16945
|
}
|
|
17126
|
-
|
|
17127
|
-
//#region src/chat/services/auth-pause-response.ts
|
|
16946
|
+
// src/chat/services/auth-pause-response.ts
|
|
17128
16947
|
const MAX_AUTH_REQUEST_LENGTH = 200;
|
|
17129
16948
|
function formatAuthRequest(requestText) {
|
|
17130
16949
|
const normalized = requestText.replace(/\s+/g, " ").trim();
|
|
@@ -17144,8 +16963,7 @@ function buildAuthPauseResponse(slackUserId, providerDisplayName, requestText) {
|
|
|
17144
16963
|
const notice = `${mention}I need access to your ${providerDisplayName} account to continue. I sent you a private link.`;
|
|
17145
16964
|
return request ? `${notice}\n\n*Why:* ${request}` : notice;
|
|
17146
16965
|
}
|
|
17147
|
-
|
|
17148
|
-
//#region src/chat/services/mcp-auth-orchestration.ts
|
|
16966
|
+
// src/chat/services/mcp-auth-orchestration.ts
|
|
17149
16967
|
var McpAuthorizationPauseError = class extends AuthorizationPauseError {
|
|
17150
16968
|
constructor(provider, providerDisplayName, disposition, requestText) {
|
|
17151
16969
|
super("mcp", provider, providerDisplayName, disposition, requestText);
|
|
@@ -17265,8 +17083,7 @@ function createMcpAuthOrchestration(input) {
|
|
|
17265
17083
|
getPendingPause: () => pendingPause
|
|
17266
17084
|
};
|
|
17267
17085
|
}
|
|
17268
|
-
|
|
17269
|
-
//#region src/chat/sandbox/egress/credentials.ts
|
|
17086
|
+
// src/chat/sandbox/egress/credentials.ts
|
|
17270
17087
|
const HTTP_READ_METHODS = /* @__PURE__ */ new Set([
|
|
17271
17088
|
"GET",
|
|
17272
17089
|
"HEAD",
|
|
@@ -17438,8 +17255,7 @@ async function sandboxEgressCredentialLease(provider, selection, context) {
|
|
|
17438
17255
|
function hasSandboxEgressLeaseTransformForHost(lease, host) {
|
|
17439
17256
|
return lease.headerTransforms.some((transform) => matchesSandboxEgressDomain(host, transform.domain));
|
|
17440
17257
|
}
|
|
17441
|
-
|
|
17442
|
-
//#region src/chat/egress/credentialed.ts
|
|
17258
|
+
// src/chat/egress/credentialed.ts
|
|
17443
17259
|
const HOP_BY_HOP_HEADERS = /* @__PURE__ */ new Set([
|
|
17444
17260
|
"connection",
|
|
17445
17261
|
"host",
|
|
@@ -17566,7 +17382,7 @@ function logSandboxEgressUpstreamRequest(input) {
|
|
|
17566
17382
|
});
|
|
17567
17383
|
}
|
|
17568
17384
|
async function requestBodyBytes(request) {
|
|
17569
|
-
if (request.method === "GET" || request.method === "HEAD" || request.body === null) return;
|
|
17385
|
+
if (request.method === "GET" || request.method === "HEAD" || request.method === "OPTIONS" || request.body === null) return;
|
|
17570
17386
|
return await request.arrayBuffer();
|
|
17571
17387
|
}
|
|
17572
17388
|
/**
|
|
@@ -17986,8 +17802,7 @@ async function executeCredentialedEgressRequest(input) {
|
|
|
17986
17802
|
});
|
|
17987
17803
|
}
|
|
17988
17804
|
}
|
|
17989
|
-
|
|
17990
|
-
//#region src/chat/egress/plugin.ts
|
|
17805
|
+
// src/chat/egress/plugin.ts
|
|
17991
17806
|
function credentialContextForPluginEgress(credentialContext) {
|
|
17992
17807
|
return {
|
|
17993
17808
|
credentials: credentialContext,
|
|
@@ -18030,8 +17845,7 @@ function createPluginEgress(deps) {
|
|
|
18030
17845
|
});
|
|
18031
17846
|
} };
|
|
18032
17847
|
}
|
|
18033
|
-
|
|
18034
|
-
//#region src/chat/services/guardian-action-policy.ts
|
|
17848
|
+
// src/chat/services/guardian-action-policy.ts
|
|
18035
17849
|
/**
|
|
18036
17850
|
* The only reasons that Guardian can block an action. Keep each rule broad
|
|
18037
17851
|
* and free of tool or provider names. The model sees them in this order.
|
|
@@ -18157,8 +17971,7 @@ ${renderRules("deny")}
|
|
|
18157
17971
|
- Rate risk and user authorization first.
|
|
18158
17972
|
- Then set the rule to the id of the one rule that the action clearly matches. When a hard rule and a confirmation rule both match, name the hard rule. When no definition clearly fits, use \`none\`. Do not name a rule only to express general doubt.
|
|
18159
17973
|
- Keep the reason to one concise, specific sentence. For a confirmation rule, name the exact action, target, and material side effects the user must confirm. For a hard rule, name the risk. For \`none\`, say why the action is ordinary.`;
|
|
18160
|
-
|
|
18161
|
-
//#region src/chat/services/guardian-action-review.ts
|
|
17974
|
+
// src/chat/services/guardian-action-review.ts
|
|
18162
17975
|
const guardianAssessmentSchema = z.object({
|
|
18163
17976
|
riskLevel: z.enum([
|
|
18164
17977
|
"low",
|
|
@@ -18292,8 +18105,7 @@ function createGuardianActionReviewer(options) {
|
|
|
18292
18105
|
};
|
|
18293
18106
|
} };
|
|
18294
18107
|
}
|
|
18295
|
-
|
|
18296
|
-
//#region src/chat/tool-support/action-review-evidence.ts
|
|
18108
|
+
// src/chat/tool-support/action-review-evidence.ts
|
|
18297
18109
|
const MAX_MESSAGE_TRANSCRIPT_TOKENS = 1e4;
|
|
18298
18110
|
const MAX_TOOL_TRANSCRIPT_TOKENS = 1e4;
|
|
18299
18111
|
const MAX_MESSAGE_ENTRY_TOKENS = 2e3;
|
|
@@ -18437,8 +18249,7 @@ function buildToolActionEvidence(messages, options = {}) {
|
|
|
18437
18249
|
omittedEntries: included.filter((value) => !value).length
|
|
18438
18250
|
};
|
|
18439
18251
|
}
|
|
18440
|
-
|
|
18441
|
-
//#region src/chat/agent-invocations/root-conversation.ts
|
|
18252
|
+
// src/chat/agent-invocations/root-conversation.ts
|
|
18442
18253
|
/** Most root messages that Guardian reads, newest first. Codex uses 16. */
|
|
18443
18254
|
const MAX_ROOT_MESSAGES = 16;
|
|
18444
18255
|
/** Most characters of one root message. */
|
|
@@ -18590,8 +18401,7 @@ async function readRootConversation(args) {
|
|
|
18590
18401
|
truncated: hasOlder || orphanEdits || messages.length < all.length
|
|
18591
18402
|
};
|
|
18592
18403
|
}
|
|
18593
|
-
|
|
18594
|
-
//#region src/chat/agent/tools.ts
|
|
18404
|
+
// src/chat/agent/tools.ts
|
|
18595
18405
|
/** Record optional reporting without changing the loadSkill outcome. */
|
|
18596
18406
|
async function tryRecordSkillLoadStat(skill) {
|
|
18597
18407
|
if (!process.env.DATABASE_URL) return;
|
|
@@ -18890,8 +18700,7 @@ async function wireAgentTools(args) {
|
|
|
18890
18700
|
toolRuntimeContext
|
|
18891
18701
|
};
|
|
18892
18702
|
}
|
|
18893
|
-
|
|
18894
|
-
//#region src/chat/agent/resume.ts
|
|
18703
|
+
// src/chat/agent/resume.ts
|
|
18895
18704
|
function extractSliceUsage(messages, beforeMessageCount) {
|
|
18896
18705
|
const usage = extractGenAiUsageSummary(...messages.slice(beforeMessageCount).filter(isAssistantMessage));
|
|
18897
18706
|
return hasAgentTurnUsage(usage) ? usage : void 0;
|
|
@@ -19107,8 +18916,7 @@ function createResumeState(args) {
|
|
|
19107
18916
|
}
|
|
19108
18917
|
};
|
|
19109
18918
|
}
|
|
19110
|
-
|
|
19111
|
-
//#region src/chat/services/plan-continuation.ts
|
|
18919
|
+
// src/chat/services/plan-continuation.ts
|
|
19112
18920
|
const OPEN_PLAN_TAG = "open-plan";
|
|
19113
18921
|
function openItems(input) {
|
|
19114
18922
|
const plan = input && typeof input === "object" ? input.plan : void 0;
|
|
@@ -19172,8 +18980,7 @@ function appendOpenPlan(continuation, messages) {
|
|
|
19172
18980
|
const plan = latestOpenPlanItems(messages);
|
|
19173
18981
|
return plan.length === 0 ? continuation : `${continuation}\n\n<${OPEN_PLAN_TAG}>\n${JSON.stringify(plan)}\n</${OPEN_PLAN_TAG}>`;
|
|
19174
18982
|
}
|
|
19175
|
-
|
|
19176
|
-
//#region src/chat/services/context-compaction.ts
|
|
18983
|
+
// src/chat/services/context-compaction.ts
|
|
19177
18984
|
const RETAINED_USER_MESSAGE_TOKENS = 2e4;
|
|
19178
18985
|
const MAX_SUMMARY_CHARS = 6e3;
|
|
19179
18986
|
/** Raised when Junior cannot compact history below the active model's hard ceiling. */
|
|
@@ -19604,8 +19411,7 @@ async function compactActiveContextIfNeeded(args, deps) {
|
|
|
19604
19411
|
piMessages: messages
|
|
19605
19412
|
};
|
|
19606
19413
|
}
|
|
19607
|
-
|
|
19608
|
-
//#region src/chat/agent/handoff.ts
|
|
19414
|
+
// src/chat/agent/handoff.ts
|
|
19609
19415
|
/** Tools that must be the only tool call in their assistant message. */
|
|
19610
19416
|
const EXCLUSIVE_TOOL_NAMES = [
|
|
19611
19417
|
HANDOFF_TOOL_NAME,
|
|
@@ -19724,8 +19530,7 @@ function applyHandoff(args) {
|
|
|
19724
19530
|
thinkingLevel: args.pending.thinkingLevel
|
|
19725
19531
|
};
|
|
19726
19532
|
}
|
|
19727
|
-
|
|
19728
|
-
//#region src/chat/agent/index.ts
|
|
19533
|
+
// src/chat/agent/index.ts
|
|
19729
19534
|
/**
|
|
19730
19535
|
* Agent executor.
|
|
19731
19536
|
*
|
|
@@ -20720,8 +20525,7 @@ async function executeAgentRunInPrivacyContext(run, conversationPrivacy, runLogC
|
|
|
20720
20525
|
await closeTools?.();
|
|
20721
20526
|
}
|
|
20722
20527
|
}
|
|
20723
|
-
|
|
20724
|
-
//#region src/chat/runtime/agent-runner.ts
|
|
20528
|
+
// src/chat/runtime/agent-runner.ts
|
|
20725
20529
|
/** Compose the agent executor with stable host dependencies. */
|
|
20726
20530
|
function createAgentRunner(execute, options) {
|
|
20727
20531
|
const attachmentStorage = options?.attachmentStorage;
|
|
@@ -20747,7 +20551,7 @@ function createAgentRunner(execute, options) {
|
|
|
20747
20551
|
} } : void 0
|
|
20748
20552
|
};
|
|
20749
20553
|
if (run.instruction.storedAttachments?.length) {
|
|
20750
|
-
const { loadInputImages } = await import("./images-
|
|
20554
|
+
const { loadInputImages } = await import("./images-C2J_bj2g.js").then((n) => n.n);
|
|
20751
20555
|
const storage = nextRun.environment?.attachmentStorage;
|
|
20752
20556
|
if (!storage) throw new Error("Attachment storage is unavailable.");
|
|
20753
20557
|
nextRun.instruction = {
|
|
@@ -20762,5 +20566,4 @@ function createAgentRunner(execute, options) {
|
|
|
20762
20566
|
return await execute(nextRun, streamFn);
|
|
20763
20567
|
} };
|
|
20764
20568
|
}
|
|
20765
|
-
|
|
20766
|
-
export { getAgentInvocation as $, resolveSlackChannelIdFromMessage as A, consumeSandboxEgressPermissionDeniedSignal as At, effectiveTaskOutcomes as B, withoutSavedSteeringMessages as Bt, renderBlockText as C, ingestEvent as Ct, storeAttachment as D, SANDBOX_EGRESS_PROXY_PATH as Dt, requestAttachmentDeletion as E, shouldPropagateSandboxEgressTrace as Et, logScheduledAutomationRunSkipped as F, parseOAuthStatePayload as Ft, recordSubagentStarted as G, readBlockedReport as Gt, stopChildAgentsOf as H, actorFromRun as Ht, scheduledAutomationRunAttributes as I, resolveBaseUrl as It, createAgentInvocation as J, setConfigDefaults as Jt, listChildAgents as K, shouldEmitDevAgentTrace as Kt, editEventAutomation as L, startOAuthFlow as Lt, getConversationInfo as M, sandboxEgressSignalsResponseSchema as Mt, listThreadReplies as N, deliverPrivateMessage as Nt, parseSlackThreadId as O, clearSandboxEgressSignals as Ot, editScheduledAutomation as P, formatProviderLabel as Pt, getActiveAgentInvocationForConversation as Q, AutomationEditError as R, createUserTokenStore as Rt, renderAttachmentText as S, processWorkspaceSnapshotJob as St, readLiveAttachment as T, normalizeSandboxEgressTracePropagationDomains as Tt, stopConversationSession as U, toolInvocationDestination as Ut, resolveTaskOutcomes as V, RetryableDeliveryError as Vt, recordSubagentEnded as W, AuthorizationFlowDisabledError as Wt, createAgentInvocationFromLatest as X, createAgentInvocationForMessage as Y, findChildAgentConversationId as Z, resolvePluginOAuthAccount as _, AgentMessageTargetError as _t, buildAuthPauseResponse as a, getAgentInvocationTurnId as at, unpublishedArtifactHeaders as b, conversationSubtreeColumns as bt, deleteMcpAuthSessionsForUserProvider as c, isTerminalAgentInvocation as ct, getMcpAuthSession as d, markAgentInvocationMailboxAppended as dt, getAgentInvocationIdForEvents as et, getMcpStoredOAuthCredentials as f, markAgentInvocationParentMailboxAppended as ft, readStats as g, reportReplacedAgentInvocation as gt, latestProgressStatus as h, markAgentInvocationSteered as ht, executeCredentialedEgressRequest as i, getAgentInvocationResultMessageId as it, resolveSlackChannelIdFromThreadId as j, parseSandboxEgressCredentialToken as jt, readSlackRawMessageContext as k, consumeSandboxEgressAuthRequiredSignal as kt, deleteMcpServerSessionId as l, listPendingAgentInvocationMailboxAppends as lt, PluginCredentialFailureError as m, markAgentInvocationRunning as mt, executeAgentRun as n, getAgentInvocationIdForResult as nt, finalizeMcpAuthorization as o, getChildAgentLabel as ot, putMcpStoredOAuthCredentials as p, markAgentInvocationPaused as pt, completeAgentInvocation as q, getConfigDefaults as qt, createContextCompactor as r, getAgentInvocationMessageId as rt, deleteMcpAuthSession as s, getLatestAgentInvocationForConversation as st, createAgentRunner as t, getAgentInvocationIdForMessage as tt, deleteMcpStoredOAuthCredentials as u, listPendingAgentInvocationResults as ut, publicArtifactHeaders as v, PARENT_AGENT_TARGET as vt, collectAttachmentGarbage as w, resolveSandboxEgressProviderForHost as wt, lookupSlackUserProfile as x, getMcpProviderErrorAttributes as xt, readPublicArtifact as y, conversationSubtree as yt, eventAutomationTriggerAvailable as z, buildSteeringPiMessage as zt };
|
|
20569
|
+
export { getAgentInvocation as $, resolveSlackChannelIdFromMessage as A, consumeSandboxEgressPermissionDeniedSignal as At, effectiveTaskOutcomes as B, RetryableDeliveryError as Bt, renderBlockText as C, ingestEvent as Ct, storeAttachment as D, SANDBOX_EGRESS_PROXY_PATH as Dt, requestAttachmentDeletion as E, shouldPropagateSandboxEgressTrace as Et, logScheduledAutomationRunSkipped as F, resolveBaseUrl as Ft, recordSubagentStarted as G, shouldEmitDevAgentTrace as Gt, stopChildAgentsOf as H, toolInvocationDestination as Ht, scheduledAutomationRunAttributes as I, startOAuthFlow as It, createAgentInvocation as J, listChildAgents as K, getConfigDefaults as Kt, editEventAutomation as L, createUserTokenStore as Lt, getConversationInfo as M, sandboxEgressSignalsResponseSchema as Mt, listThreadReplies as N, formatProviderLabel as Nt, parseSlackThreadId as O, clearSandboxEgressSignals as Ot, editScheduledAutomation as P, parseOAuthStatePayload as Pt, getActiveAgentInvocationForConversation as Q, AutomationEditError as R, buildSteeringPiMessage as Rt, renderAttachmentText as S, processWorkspaceSnapshotJob as St, readLiveAttachment as T, normalizeSandboxEgressTracePropagationDomains as Tt, stopConversationSession as U, AuthorizationFlowDisabledError as Ut, resolveTaskOutcomes as V, actorFromRun as Vt, recordSubagentEnded as W, readBlockedReport as Wt, createAgentInvocationFromLatest as X, createAgentInvocationForMessage as Y, findChildAgentConversationId as Z, resolvePluginOAuthAccount as _, AgentMessageTargetError as _t, buildAuthPauseResponse as a, getAgentInvocationTurnId as at, unpublishedArtifactHeaders as b, conversationSubtreeColumns as bt, deleteMcpAuthSessionsForUserProvider as c, isTerminalAgentInvocation as ct, getMcpAuthSession as d, markAgentInvocationMailboxAppended as dt, getAgentInvocationIdForEvents as et, getMcpStoredOAuthCredentials as f, markAgentInvocationParentMailboxAppended as ft, readStats as g, reportReplacedAgentInvocation as gt, latestProgressStatus as h, markAgentInvocationSteered as ht, executeCredentialedEgressRequest as i, getAgentInvocationResultMessageId as it, resolveSlackChannelIdFromThreadId as j, parseSandboxEgressCredentialToken as jt, readSlackRawMessageContext as k, consumeSandboxEgressAuthRequiredSignal as kt, deleteMcpServerSessionId as l, listPendingAgentInvocationMailboxAppends as lt, PluginCredentialFailureError as m, markAgentInvocationRunning as mt, executeAgentRun as n, getAgentInvocationIdForResult as nt, finalizeMcpAuthorization as o, getChildAgentLabel as ot, putMcpStoredOAuthCredentials as p, markAgentInvocationPaused as pt, completeAgentInvocation as q, setConfigDefaults as qt, createContextCompactor as r, getAgentInvocationMessageId as rt, deleteMcpAuthSession as s, getLatestAgentInvocationForConversation as st, createAgentRunner as t, getAgentInvocationIdForMessage as tt, deleteMcpStoredOAuthCredentials as u, listPendingAgentInvocationResults as ut, publicArtifactHeaders as v, PARENT_AGENT_TARGET as vt, collectAttachmentGarbage as w, resolveSandboxEgressProviderForHost as wt, lookupSlackUserProfile as x, getMcpProviderErrorAttributes as xt, readPublicArtifact as y, conversationSubtree as yt, eventAutomationTriggerAvailable as z, withoutSavedSteeringMessages as zt };
|