@sentry/junior 0.177.0 → 0.179.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (102) hide show
  1. package/dist/{agent-hooks-IYHCN7CO.js → agent-hooks-32IDCLMW.js} +12 -12
  2. package/dist/api/conversations/archive.d.ts +5 -2
  3. package/dist/api/conversations/list.d.ts +0 -1
  4. package/dist/api/conversations/membership.d.ts +14 -0
  5. package/dist/api/conversations/projection.d.ts +2 -1
  6. package/dist/api/locations/detail.d.ts +1 -1
  7. package/dist/api/people/shared.d.ts +2 -2
  8. package/dist/api/schema/conversation.d.ts +4 -4
  9. package/dist/api/schema/location.d.ts +1 -1
  10. package/dist/api/schema/person.d.ts +1 -1
  11. package/dist/api/schema.js +1 -1
  12. package/dist/api.js +399 -287
  13. package/dist/app.js +573 -198
  14. package/dist/{catalog-runtime-2TD4CXSB.js → catalog-runtime-FBVA6WAQ.js} +5 -5
  15. package/dist/chat/agent/sandbox.d.ts +2 -0
  16. package/dist/chat/conversations/sql/participants.d.ts +1 -0
  17. package/dist/chat/conversations/store.d.ts +0 -1
  18. package/dist/chat/sandbox/errors.d.ts +4 -0
  19. package/dist/chat/sandbox/noninteractive-command.d.ts +1 -0
  20. package/dist/chat/sandbox/prepare-workspace.d.ts +27 -3
  21. package/dist/chat/sandbox/sandbox.d.ts +2 -0
  22. package/dist/chat/sandbox/session.d.ts +2 -0
  23. package/dist/chat/sandbox/snapshot/builder-sandbox.d.ts +5 -0
  24. package/dist/chat/sandbox/snapshot/install.d.ts +2 -2
  25. package/dist/chat/sandbox/snapshot/span.d.ts +3 -0
  26. package/dist/chat/sandbox/snapshot/store.d.ts +20 -17
  27. package/dist/chat/sandbox/snapshot/waiting-error.d.ts +15 -0
  28. package/dist/chat/sandbox/snapshot/workspace.d.ts +17 -0
  29. package/dist/chat/scheduled-tasks/personal.d.ts +5 -8
  30. package/dist/chat/scheduled-tasks/runs.d.ts +49 -0
  31. package/dist/chat/scheduled-tasks/schedule-intent.d.ts +1 -1
  32. package/dist/chat/scheduled-tasks/tasks.d.ts +27 -0
  33. package/dist/chat/scheduled-tasks/tool-support.d.ts +0 -4
  34. package/dist/chat/scheduled-tasks/tools/create.d.ts +1 -1
  35. package/dist/chat/scheduled-tasks/tools/update.d.ts +1 -1
  36. package/dist/chat/scheduled-tasks/types.d.ts +127 -78
  37. package/dist/chat/services/workspace-snapshot-wait.d.ts +27 -0
  38. package/dist/chat/workspaces/types.d.ts +1 -0
  39. package/dist/{chunk-CAWBLVBY.js → chunk-2HIPYNQI.js} +6 -6
  40. package/dist/{chunk-ZCYABD7N.js → chunk-3AFVR5UC.js} +5 -5
  41. package/dist/{chunk-PA7QDS7P.js → chunk-3I7XE3PA.js} +204 -100
  42. package/dist/{chunk-VGDOEKO2.js → chunk-3TM3FYLQ.js} +1 -1
  43. package/dist/{chunk-6NZRKJWU.js → chunk-4GWXAILB.js} +1 -1
  44. package/dist/{chunk-LFZODSAY.js → chunk-5IRROPA5.js} +4 -4
  45. package/dist/{chunk-N4YEVOEC.js → chunk-B6ECUSVX.js} +45 -276
  46. package/dist/{chunk-4TWDRU64.js → chunk-CJLBLELR.js} +5 -5
  47. package/dist/{chunk-3FWXQZJJ.js → chunk-FAS6AIMF.js} +1 -1
  48. package/dist/{chunk-I7PKGMKI.js → chunk-FIDMHAO6.js} +6 -6
  49. package/dist/{chunk-4SVAFAI2.js → chunk-FTGD2FBP.js} +1 -1
  50. package/dist/{chunk-LVL5NG5G.js → chunk-G2CAC4CV.js} +19 -19
  51. package/dist/{chunk-DLTP6TUJ.js → chunk-GENV6KF2.js} +2 -2
  52. package/dist/{chunk-FVVYHML7.js → chunk-GPLAT6H7.js} +6 -6
  53. package/dist/{chunk-7CVYXUOJ.js → chunk-HQNE5APD.js} +1 -1
  54. package/dist/{chunk-Q362TECJ.js → chunk-JMJNFEDC.js} +331 -2
  55. package/dist/{chunk-AFOFVEXP.js → chunk-JT4WMD3C.js} +124 -13
  56. package/dist/{chunk-7ZFESKJ2.js → chunk-KJLHIHFF.js} +9 -9
  57. package/dist/{chunk-QLLOX7JY.js → chunk-Q5B3WTGG.js} +8 -8
  58. package/dist/{chunk-DGGIKWYQ.js → chunk-R5NWWYIS.js} +1 -1
  59. package/dist/{chunk-WCQUKX74.js → chunk-R6U7N4FS.js} +14 -5
  60. package/dist/{chunk-WYO2HXY5.js → chunk-RTRBYSF3.js} +1 -1
  61. package/dist/{chunk-2IMQLZHS.js → chunk-RZRYOLCE.js} +1144 -136
  62. package/dist/{chunk-7B6NW4P7.js → chunk-SLGGOASN.js} +1 -1
  63. package/dist/{chunk-SNPQGTHJ.js → chunk-TIEKUH4Q.js} +1 -1
  64. package/dist/{chunk-ELEAIRTG.js → chunk-TKB25A3L.js} +2 -2
  65. package/dist/{chunk-UB5YB2ED.js → chunk-U4TKB6F6.js} +6 -6
  66. package/dist/{chunk-ORMJY4RG.js → chunk-UT6X7XN7.js} +1 -1
  67. package/dist/{chunk-LPMLAJYR.js → chunk-VP4OVRDD.js} +11 -17
  68. package/dist/{chunk-7PZDAXIK.js → chunk-XSPSCWLH.js} +1 -1
  69. package/dist/chunk-XZY6G5YZ.js +1088 -0
  70. package/dist/{chunk-J2EWL6GJ.js → chunk-YFNAMRGE.js} +1 -1
  71. package/dist/{chunk-6KGMMVHF.js → chunk-ZQMG3CL5.js} +2 -2
  72. package/dist/cli/chat.js +31 -30
  73. package/dist/cli/check.js +6 -6
  74. package/dist/cli/plugins.js +13 -13
  75. package/dist/cli/snapshot-create.js +10 -10
  76. package/dist/cli/upgrade.js +7 -7
  77. package/dist/db/schema/conversation-participants.d.ts +17 -0
  78. package/dist/db/schema/conversations.d.ts +629 -1
  79. package/dist/db/schema/scheduled-tasks.d.ts +29 -5
  80. package/dist/db/schema/snapshots.d.ts +1 -1
  81. package/dist/db/schema.d.ts +46 -5
  82. package/dist/{db-A3CB76US.js → db-EJAV7JL6.js} +7 -7
  83. package/dist/instrumentation.js +4 -4
  84. package/dist/nitro.js +2 -2
  85. package/dist/{oauth-callback-server-64QMI3IB.js → oauth-callback-server-GAVSUBTQ.js} +23 -23
  86. package/dist/{runner-EIAE2BGD.js → runner-34JL64JF.js} +15 -15
  87. package/dist/{skills-ZADWFKDG.js → skills-U545HALM.js} +6 -6
  88. package/dist/spawn-I2S4IDUQ.js +37 -0
  89. package/dist/{validation-4I6AF4CV.js → validation-EVXVGA44.js} +6 -6
  90. package/dist/version.js +1 -1
  91. package/dist/{work-BS6BZ66U.js → work-QOAUPDBU.js} +18 -18
  92. package/dist/worker-5GX2IKLZ.js +24 -0
  93. package/migrations/0033_workspace_snapshot_active_build.sql +1 -0
  94. package/migrations/0034_strong_randall.sql +31 -0
  95. package/migrations/meta/0033_snapshot.json +2914 -0
  96. package/migrations/meta/0034_snapshot.json +3038 -0
  97. package/migrations/meta/_journal.json +15 -1
  98. package/package.json +4 -4
  99. package/dist/chat/scheduled-tasks/store.d.ts +0 -78
  100. package/dist/chunk-4TRHPYTL.js +0 -1944
  101. package/dist/spawn-DVUOUFFC.js +0 -37
  102. package/dist/worker-RS5PWTCE.js +0 -24
@@ -1,15 +1,15 @@
1
1
  import {
2
2
  pluginCatalogRuntime
3
- } from "./chunk-J2EWL6GJ.js";
4
- import "./chunk-7B6NW4P7.js";
3
+ } from "./chunk-YFNAMRGE.js";
4
+ import "./chunk-SLGGOASN.js";
5
5
  import "./chunk-CGA4ERJ5.js";
6
6
  import "./chunk-M63DETLL.js";
7
- import "./chunk-7CVYXUOJ.js";
7
+ import "./chunk-HQNE5APD.js";
8
8
  import "./chunk-6GWA276C.js";
9
9
  import "./chunk-OOUNJNMR.js";
10
10
  import "./chunk-H4HBKISO.js";
11
- import "./chunk-ORMJY4RG.js";
12
- import "./chunk-SNPQGTHJ.js";
11
+ import "./chunk-UT6X7XN7.js";
12
+ import "./chunk-TIEKUH4Q.js";
13
13
  import "./chunk-MLKGABMK.js";
14
14
  export {
15
15
  pluginCatalogRuntime
@@ -31,6 +31,8 @@ export interface AgentSandboxOptions {
31
31
  actor?: Actor;
32
32
  locationConfiguration?: LocationConfigurationService;
33
33
  configurationValues: Record<string, unknown>;
34
+ /** Durable-worker soft yield for long Workspace snapshot waits. */
35
+ shouldYield?: () => boolean;
34
36
  getActiveSkill(): Skill | null;
35
37
  prepareSandbox(workspace: SandboxWorkspace): void | Promise<void>;
36
38
  prepareWorkspace?(workspace: SandboxWorkspace, recipe: Workspace, signal?: AbortSignal): Promise<void>;
@@ -9,6 +9,7 @@ export declare function recordConversationParticipant(executor: JuniorSqlDatabas
9
9
  actorIdentityId: string;
10
10
  conversationId: string;
11
11
  atMs: number;
12
+ restoreArchive?: boolean;
12
13
  }): Promise<void>;
13
14
  /** Find which of the supplied root conversations include the linked user. */
14
15
  export declare function rootConversationIdsForParticipant(executor: JuniorSqlDatabase, args: {
@@ -18,7 +18,6 @@ export interface ConversationLineage {
18
18
  parentConversationId: string;
19
19
  }
20
20
  export interface Conversation {
21
- archivedAtMs?: number;
22
21
  channelName?: string;
23
22
  conversationId: string;
24
23
  createdAtMs: number;
@@ -6,6 +6,10 @@ export declare function isSandboxUnavailableError(error: unknown): boolean;
6
6
  export declare function isSandboxMissingError(error: unknown): boolean;
7
7
  /** Detect transient snapshot boot races so sandbox creation can retry. */
8
8
  export declare function isSnapshottingError(error: unknown): boolean;
9
+ /** Detect cancellation so a durable builder stays available for check-in. */
10
+ export declare function isAbortError(error: unknown): boolean;
11
+ /** Detect transient Vercel Sandbox API failures that keep a job resumable. */
12
+ export declare function isSandboxApiTransientError(error: unknown): boolean;
9
13
  /** Detect interrupted command streams where no reliable exit status is available. */
10
14
  export declare function isSandboxCommandStreamInterruptedError(error: unknown): boolean;
11
15
  /** Wrap raw sandbox setup failures into one stable user-facing error contract. */
@@ -10,6 +10,7 @@ interface NonInteractiveCommandInput extends NonInteractiveShellOptions {
10
10
  login?: boolean;
11
11
  signal?: AbortSignal;
12
12
  sudo?: boolean;
13
+ timeoutMs?: number;
13
14
  }
14
15
  /** Render one argv command as a safely quoted shell script. */
15
16
  export declare function buildCommandScript(input: Pick<NonInteractiveCommandInput, "args" | "cmd">): string;
@@ -1,11 +1,35 @@
1
1
  import type { SandboxSession } from "@/chat/sandbox/workspace";
2
2
  import type { Workspace } from "@/chat/workspaces/types";
3
- /** Prepare repositories and setup state before a Workspace snapshot is captured. */
4
- export declare function prepareWorkspaceSnapshot(params: {
3
+ interface PrepareWorkspaceParams {
5
4
  sandbox: SandboxSession;
6
5
  workspace: Workspace;
7
6
  signal?: AbortSignal;
8
7
  applyNetworkPolicy(sandbox: SandboxSession): Promise<unknown>;
9
8
  prepareRepositories?(sandbox: SandboxSession, workspace: Workspace, signal?: AbortSignal): Promise<void>;
10
9
  removeCredentialRoute: boolean;
11
- }): Promise<void>;
10
+ }
11
+ /** Prepare repositories before a Workspace setup script starts. */
12
+ export declare function prepareWorkspaceRepositories(params: PrepareWorkspaceParams): Promise<void>;
13
+ /** Build the command for one Workspace setup script. */
14
+ export declare function workspaceSetupCommand(workspace: Workspace): {
15
+ cmd: string;
16
+ args: string[];
17
+ cwd: string;
18
+ env: {
19
+ JUNIOR_REPOS_ROOT: string;
20
+ JUNIOR_WORKSPACE_ROOT: string;
21
+ };
22
+ };
23
+ /** Build a restart-safe command for one Workspace snapshot setup script. */
24
+ export declare function workspaceSnapshotSetupCommand(workspace: Workspace, buildId: string): {
25
+ cmd: string;
26
+ args: string[];
27
+ cwd: string;
28
+ env: {
29
+ JUNIOR_REPOS_ROOT: string;
30
+ JUNIOR_WORKSPACE_ROOT: string;
31
+ };
32
+ };
33
+ /** Prepare repositories and setup state before a Workspace snapshot is captured. */
34
+ export declare function prepareWorkspaceSnapshot(params: PrepareWorkspaceParams): Promise<void>;
35
+ export {};
@@ -33,6 +33,8 @@ export interface SandboxOptions {
33
33
  skills: SkillMetadata[];
34
34
  referenceFiles: string[];
35
35
  timeoutMs?: number;
36
+ /** Durable-worker soft yield for long Workspace snapshot waits. */
37
+ shouldYield?: () => boolean;
36
38
  traceContext?: LogContext;
37
39
  tracePropagation?: SandboxEgressTracePropagationConfig;
38
40
  credentialEgress?: CredentialContext;
@@ -38,6 +38,8 @@ interface SandboxRuntimeOptions {
38
38
  skills: SkillMetadata[];
39
39
  referenceFiles: string[];
40
40
  timeoutMs?: number;
41
+ /** Durable-worker soft yield for long Workspace snapshot waits. */
42
+ shouldYield?: () => boolean;
41
43
  traceContext?: LogContext;
42
44
  commandEnv?: () => Promise<Record<string, string>>;
43
45
  createNetworkPolicy?: (egressId: string, traceHeaders?: TracePropagationHeaders) => NetworkPolicy | undefined;
@@ -0,0 +1,5 @@
1
+ import { Sandbox } from "@vercel/sandbox";
2
+ /** Resume the named Sandbox that owns one Workspace snapshot build. */
3
+ export declare function getWorkspaceSnapshotBuilder(name: string, signal?: AbortSignal): Promise<Sandbox>;
4
+ /** Permanently delete named Workspace snapshot builders without resuming them. */
5
+ export declare function deleteWorkspaceSnapshotBuilders(names: Iterable<string>): Promise<void>;
@@ -1,6 +1,6 @@
1
1
  import type { PluginRuntimeDependency, PluginRuntimePostinstallCommand } from "@/chat/plugins/types";
2
2
  import type { SandboxSession } from "@/chat/sandbox/workspace";
3
3
  /** Install declared system and npm dependencies into a snapshot sandbox. */
4
- export declare function dependencies(sandbox: SandboxSession, values: PluginRuntimeDependency[], signal?: AbortSignal): Promise<void>;
4
+ export declare function dependencies(sandbox: SandboxSession, values: PluginRuntimeDependency[], signal?: AbortSignal, timeoutMs?: number): Promise<void>;
5
5
  /** Run declared postinstall commands after dependency binaries are available. */
6
- export declare function postinstall(sandbox: SandboxSession, commands: PluginRuntimePostinstallCommand[], signal?: AbortSignal): Promise<void>;
6
+ export declare function postinstall(sandbox: SandboxSession, commands: PluginRuntimePostinstallCommand[], signal?: AbortSignal, timeoutMs?: number): Promise<void>;
@@ -1,2 +1,5 @@
1
+ import type { Snapshot } from "@/chat/sandbox/snapshot/resolve";
2
+ /** Record the reusable snapshot selected for a new Sandbox. */
3
+ export declare function setSnapshotSpanAttributes(snapshot: Snapshot): void;
1
4
  /** Record one stage of dependency snapshot resolution or creation. */
2
5
  export declare function trace<T>(name: string, op: string, attributes: Record<string, unknown>, callback: () => Promise<T>): Promise<T>;
@@ -1,28 +1,31 @@
1
1
  import type { JuniorDatabase } from "@/db/db";
2
- import type { WorkspaceSnapshot, WorkspaceSnapshotBuild } from "@/chat/workspaces/types";
2
+ import type { Workspace, WorkspaceSnapshot, WorkspaceSnapshotBuild } from "@/chat/workspaces/types";
3
3
  /** Current ready artifact and build state for one Workspace profile. */
4
4
  export interface WorkspaceSnapshots {
5
5
  ready: WorkspaceSnapshot | null;
6
6
  build: WorkspaceSnapshotBuild | null;
7
7
  }
8
+ /** Result of replacing the ready snapshot for one Workspace profile. */
9
+ export interface WorkspaceSnapshotWriteResult {
10
+ written: boolean;
11
+ replacedBuilderNames: string[];
12
+ }
8
13
  /** Load bounded ready and build views for one Workspace profile hash. */
9
14
  export declare function loadSnapshotsForProfile(db: JuniorDatabase, workspaceId: string, profileHash: string): Promise<WorkspaceSnapshots>;
10
- /** Drop in-flight or failed rows when a recipe changes. Keep ready rows. */
11
- export declare function clearNonReadySnapshots(db: JuniorDatabase, workspaceId: string): Promise<string[]>;
12
- /** Drop one ready row whose provider snapshot no longer exists. */
13
- export declare function invalidateMissingReadySnapshot(params: {
15
+ /** Drop every snapshot row before its Workspace is deleted. */
16
+ export declare function clearWorkspaceSnapshots(db: JuniorDatabase, workspaceId: string): Promise<string[]>;
17
+ /** Drop one ready snapshot and return the name of its provider owner. */
18
+ export declare function invalidateReadySnapshot(params: {
14
19
  workspaceId: string;
15
20
  profileHash: string;
16
21
  snapshotId: string;
17
- }): Promise<void>;
18
- /** Record the full Sandbox snapshot after a successful Workspace prepare. */
19
- export declare function setWorkspaceSnapshot(workspaceId: string, snapshot: WorkspaceSnapshot): Promise<void>;
20
- /** Record a Workspace snapshot build that can continue across execution slices. */
21
- export declare function setWorkspaceSnapshotBuild(workspaceId: string, build: WorkspaceSnapshotBuild): Promise<void>;
22
- /** Persist Workspace snapshot facts when resolve returns a concrete entry. */
23
- export declare function recordResolvedWorkspaceSnapshot(workspaceId: string, snapshot: {
24
- snapshotId?: string;
25
- profileHash?: string;
26
- createdAtMs?: number;
27
- buildDurationMs?: number;
28
- }): Promise<void>;
22
+ }): Promise<string | null>;
23
+ /** Complete one owned build and report provider owners that it replaced. */
24
+ export declare function setWorkspaceSnapshot(workspaceId: string, snapshot: WorkspaceSnapshot, options: {
25
+ buildId: string;
26
+ }): Promise<WorkspaceSnapshotWriteResult>;
27
+ /** Update an owned build row. Initial creation locks and verifies its Workspace. */
28
+ export declare function setWorkspaceSnapshotBuild(workspaceId: string, build: WorkspaceSnapshotBuild, options?: {
29
+ insertIfMissing?: boolean;
30
+ expectedRecipe?: Pick<Workspace, "setupScript" | "repos">;
31
+ }): Promise<boolean>;
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Soft deadline hit while a Workspace snapshot is still building.
3
+ * The tool returns timed_out so the host can yield at a tool-result boundary.
4
+ */
5
+ export declare class WorkspaceSnapshotWaitingError extends Error {
6
+ readonly code = "workspace_snapshot_waiting";
7
+ readonly workspaceName: string;
8
+ constructor(workspaceName: string);
9
+ }
10
+ /** True when a structured tool result is a soft Workspace snapshot wait. */
11
+ export declare function isWorkspaceSnapshotWaitingResult(details: unknown): boolean;
12
+ /** Workspace name from a soft-wait tool result, if present. */
13
+ export declare function workspaceNameFromWaitingResult(details: unknown): string | undefined;
14
+ /** True when an error chain contains the Workspace snapshot wait signal. */
15
+ export declare function isWorkspaceSnapshotWaitingError(error: unknown): error is WorkspaceSnapshotWaitingError;
@@ -0,0 +1,17 @@
1
+ import type { Snapshot } from "@/chat/sandbox/snapshot/resolve";
2
+ import { type SandboxSession } from "@/chat/sandbox/workspace";
3
+ import type { Workspace } from "@/chat/workspaces/types";
4
+ /**
5
+ * Resolve a Workspace snapshot through resumable execution slices.
6
+ * Cold builds have one shared one-hour budget across every execution slice.
7
+ */
8
+ export declare function resolveWorkspaceSnapshot(params: {
9
+ workspace: Workspace;
10
+ runtime: string;
11
+ staleSnapshotId?: string;
12
+ signal?: AbortSignal;
13
+ shouldYield?: () => boolean;
14
+ applyNetworkPolicy(sandbox: SandboxSession): Promise<unknown>;
15
+ prepareRepositories?(sandbox: SandboxSession, workspace: Workspace, signal?: AbortSignal): Promise<void>;
16
+ removeCredentialRoute: boolean;
17
+ }): Promise<Snapshot>;
@@ -1,8 +1,7 @@
1
1
  /** Viewer-scoped scheduled-task queries and mutations. */
2
2
  import type { User } from "@sentry/junior-plugin-api";
3
- import type { SchedulerStore } from "./store";
3
+ import type { JuniorDatabase } from "@/db/db";
4
4
  import type { ScheduledTask } from "./types";
5
- type PersonalScheduledTaskStore = Pick<SchedulerStore, "getTask" | "listTasksCreatedBy" | "saveTask">;
6
5
  export interface ViewerScheduledTaskPage {
7
6
  nextCursor?: string;
8
7
  tasks: ScheduledTask[];
@@ -18,9 +17,7 @@ export declare class InvalidScheduledTaskCursorError extends Error {
18
17
  export declare class PersonalScheduledTaskNotFoundError extends Error {
19
18
  constructor();
20
19
  }
21
- /** Build scheduled-task operations limited to tasks created by one user. */
22
- export declare function createViewerScheduledTasks(store: PersonalScheduledTaskStore, user: User): {
23
- delete(id: string, nowMs?: number): Promise<void>;
24
- list(input: ViewerScheduledTaskPageInput): Promise<ViewerScheduledTaskPage>;
25
- };
26
- export {};
20
+ /** Delete one scheduled task created by the viewer. */
21
+ export declare function deleteViewerScheduledTask(db: JuniorDatabase, user: User, id: string, nowMs?: number): Promise<void>;
22
+ /** List scheduled tasks created by the viewer with a stable SQL cursor. */
23
+ export declare function listViewerScheduledTasks(db: JuniorDatabase, user: User, input: ViewerScheduledTaskPageInput): Promise<ViewerScheduledTaskPage>;
@@ -0,0 +1,49 @@
1
+ import type { JuniorDatabase } from "@/db/db";
2
+ import { type ScheduledRun } from "./types";
3
+ /** List incomplete runs for retained scheduled tasks. */
4
+ export declare function listIncompleteScheduledRuns(db: JuniorDatabase): Promise<ScheduledRun[]>;
5
+ /** Claim one due scheduler run under the deployed global claim lock. */
6
+ export declare function claimDueScheduledRun(db: JuniorDatabase, args: {
7
+ nowMs: number;
8
+ }): Promise<ScheduledRun | undefined>;
9
+ /** Mark a pending run dispatched only for the active claim. */
10
+ export declare function markScheduledRunDispatched(db: JuniorDatabase, args: {
11
+ claimedAtMs: number;
12
+ dispatchId: string;
13
+ nowMs: number;
14
+ runId: string;
15
+ }): Promise<ScheduledRun | undefined>;
16
+ /** Complete a run only for its active start timestamp. */
17
+ export declare function markScheduledRunCompleted(db: JuniorDatabase, args: {
18
+ completedAtMs: number;
19
+ resultMessageTs?: string;
20
+ runId: string;
21
+ startedAtMs: number;
22
+ }): Promise<ScheduledRun | undefined>;
23
+ /** Fail a claimed or running run only for its active transition guard. */
24
+ export declare function markScheduledRunFailed(db: JuniorDatabase, args: {
25
+ completedAtMs: number;
26
+ errorMessage: string;
27
+ startedAtMs?: number;
28
+ runId: string;
29
+ }): Promise<ScheduledRun | undefined>;
30
+ /** Block a claimed or running run only for its active transition guard. */
31
+ export declare function markScheduledRunBlocked(db: JuniorDatabase, args: {
32
+ completedAtMs: number;
33
+ errorMessage: string;
34
+ runId: string;
35
+ startedAtMs?: number;
36
+ }): Promise<ScheduledRun | undefined>;
37
+ /** Skip a pending run only before dispatch begins. */
38
+ export declare function markScheduledRunSkipped(db: JuniorDatabase, args: {
39
+ completedAtMs: number;
40
+ errorMessage: string;
41
+ runId: string;
42
+ }): Promise<ScheduledRun | undefined>;
43
+ /** Advance a scheduled task after a terminal run under its task lock. */
44
+ export declare function advanceScheduledTaskAfterRun(db: JuniorDatabase, args: {
45
+ errorMessage?: string;
46
+ nowMs: number;
47
+ run: ScheduledRun;
48
+ status: "blocked" | "completed" | "failed";
49
+ }): Promise<void>;
@@ -11,9 +11,9 @@ export declare const scheduleIntentSchema: z.ZodUnion<readonly [z.ZodObject<{
11
11
  type: z.ZodLiteral<"after">;
12
12
  value: z.ZodNumber;
13
13
  unit: z.ZodEnum<{
14
- day: "day";
15
14
  hour: "hour";
16
15
  minute: "minute";
16
+ day: "day";
17
17
  second: "second";
18
18
  week: "week";
19
19
  }>;
@@ -0,0 +1,27 @@
1
+ import type { JuniorDatabase } from "@/db/db";
2
+ import { juniorSchedulerTasks } from "@/db/schema/scheduled-tasks";
3
+ import { type ScheduledTask } from "./types";
4
+ type ScheduledTaskRow = Pick<typeof juniorSchedulerTasks.$inferSelect, "creatorIdentityId" | "record" | "title">;
5
+ /** Decode a retained scheduler task row and reject invalid routing context. */
6
+ export declare function parseScheduledTaskRow(row: ScheduledTaskRow): ScheduledTask | undefined;
7
+ /** Keep scan paths from returning current or legacy tombstones. */
8
+ export declare function isListedScheduledTask(task: ScheduledTask | undefined): task is ScheduledTask;
9
+ /** Build the stable run id for one task occurrence. */
10
+ export declare function scheduledRunId(taskId: string, scheduledForMs: number): string;
11
+ /** Acquire the deployed advisory lock for one scheduled task. */
12
+ export declare function withScheduledTaskLock<T>(db: JuniorDatabase, taskId: string, callback: (db: JuniorDatabase) => Promise<T>): Promise<T>;
13
+ /** Read and decode one scheduled task. */
14
+ export declare function readScheduledTask(db: JuniorDatabase, taskId: string): Promise<ScheduledTask | undefined>;
15
+ /** List decoded scheduled tasks in stable creation order. */
16
+ export declare function listScheduledTasks(db: JuniorDatabase): Promise<ScheduledTask[]>;
17
+ /** List decoded scheduled tasks for one team in stable creation order. */
18
+ export declare function listScheduledTasksForTeam(db: JuniorDatabase, teamId: string): Promise<ScheduledTask[]>;
19
+ /** Create a scheduled task once under its retry-stable task lock. */
20
+ export declare function createScheduledTask(db: JuniorDatabase, task: ScheduledTask): Promise<ScheduledTask>;
21
+ /** Save a scheduled task and clear its blocked occurrence on reactivation. */
22
+ export declare function saveScheduledTask(db: JuniorDatabase, task: ScheduledTask): Promise<ScheduledTask>;
23
+ /** Save a scheduled task inside a task lock already held by the caller. */
24
+ export declare function saveScheduledTaskInLock(db: JuniorDatabase, task: ScheduledTask, current: ScheduledTask | undefined): Promise<void>;
25
+ /** List scheduled tasks whose current Slack destination is public. */
26
+ export declare function listPublicScheduledTasksForTeams(db: JuniorDatabase, teamIds: string[], limit: number): Promise<ScheduledTask[]>;
27
+ export {};
@@ -1,12 +1,10 @@
1
1
  import { type Identity, type SlackDestination, type SlackActor, type SlackSource, type User } from "@sentry/junior-plugin-api";
2
2
  import { z } from "zod";
3
- import { type SchedulerStore } from "./store";
4
3
  import type { ScheduledTask, ScheduledTaskConversationAccess, ScheduledTaskPrincipal, ScheduledTaskStatus } from "./types";
5
4
  export interface SchedulerToolContext {
6
5
  actor?: SlackActor;
7
6
  now?: () => number;
8
7
  source?: SlackSource;
9
- store: SchedulerStore;
10
8
  users: {
11
9
  resolveActor(): Promise<{
12
10
  identity: Identity;
@@ -226,8 +224,6 @@ export declare function buildTaskId(args: {
226
224
  destination: SlackDestination;
227
225
  toolCallId: string | undefined;
228
226
  }): string;
229
- /** Keep concrete scheduler tools coupled to the injected store, not global state. */
230
- export declare function schedulerStore(context: SchedulerToolContext): SchedulerStore;
231
227
  /** Accept only persisted scheduler statuses from model-facing update input. */
232
228
  export declare function normalizeStatus(value: string | undefined): ScheduledTaskStatus | undefined;
233
229
  /** Centralize scheduler timezone defaulting for all concrete tool entry points. */
@@ -20,7 +20,7 @@ export declare function createSlackScheduleCreateTaskTool(context: SchedulerTool
20
20
  timing: {
21
21
  type: "after";
22
22
  value: number;
23
- unit: "day" | "hour" | "minute" | "second" | "week";
23
+ unit: "hour" | "minute" | "day" | "second" | "week";
24
24
  } | {
25
25
  type: "at";
26
26
  date: string;
@@ -21,7 +21,7 @@ export declare function createSlackScheduleUpdateTaskTool(context: SchedulerTool
21
21
  timing: {
22
22
  type: "after";
23
23
  value: number;
24
- unit: "day" | "hour" | "minute" | "second" | "week";
24
+ unit: "hour" | "minute" | "day" | "second" | "week";
25
25
  } | {
26
26
  type: "at";
27
27
  date: string;
@@ -1,86 +1,135 @@
1
- /** Durable scheduled-task domain types owned by Junior core. */
2
- import type { SlackDestination, SystemActor } from "@sentry/junior-plugin-api";
3
1
  import { z } from "zod";
4
- export type ScheduledTaskStatus = "active" | "blocked" | "completed" | "deleted";
5
- export declare const scheduledTaskCredentialModeSchema: z.ZodEnum<{
2
+ declare const scheduledTaskStatusSchema: z.ZodEnum<{
3
+ completed: "completed";
4
+ blocked: "blocked";
5
+ active: "active";
6
+ deleted: "deleted";
7
+ }>;
8
+ export type ScheduledTaskStatus = z.output<typeof scheduledTaskStatusSchema>;
9
+ declare const scheduledTaskCredentialModeSchema: z.ZodEnum<{
6
10
  system: "system";
7
11
  creator: "creator";
8
12
  }>;
9
- export type ScheduledTaskCredentialMode = z.infer<typeof scheduledTaskCredentialModeSchema>;
10
- export type ScheduledRunStatus = "pending" | "running" | "completed" | "failed" | "blocked" | "skipped";
11
- export interface ScheduledTaskPrincipal {
12
- slackUserId: string;
13
- fullName?: string;
14
- userName?: string;
15
- }
16
- export type ScheduledTaskExecutionActor = SystemActor;
13
+ export type ScheduledTaskCredentialMode = z.output<typeof scheduledTaskCredentialModeSchema>;
14
+ declare const scheduledRunStatusSchema: z.ZodEnum<{
15
+ pending: "pending";
16
+ running: "running";
17
+ completed: "completed";
18
+ failed: "failed";
19
+ blocked: "blocked";
20
+ skipped: "skipped";
21
+ }>;
22
+ export type ScheduledRunStatus = z.output<typeof scheduledRunStatusSchema>;
23
+ /** Validate the current scheduled-task domain shape. */
24
+ export declare const scheduledTaskSchema: z.ZodObject<{
25
+ id: z.ZodString;
26
+ conversationAccess: z.ZodObject<{
27
+ audience: z.ZodEnum<{
28
+ channel: "channel";
29
+ direct: "direct";
30
+ group: "group";
31
+ }>;
32
+ visibility: z.ZodEnum<{
33
+ private: "private";
34
+ public: "public";
35
+ }>;
36
+ }, z.core.$strict>;
37
+ createdAtMs: z.ZodNumber;
38
+ createdBy: z.ZodObject<{
39
+ slackUserId: z.ZodString;
40
+ fullName: z.ZodOptional<z.ZodString>;
41
+ userName: z.ZodOptional<z.ZodString>;
42
+ }, z.core.$strict>;
43
+ creatorIdentityId: z.ZodString;
44
+ credentialMode: z.ZodEnum<{
45
+ system: "system";
46
+ creator: "creator";
47
+ }>;
48
+ destination: z.ZodObject<{
49
+ platform: z.ZodLiteral<"slack">;
50
+ teamId: z.ZodString;
51
+ channelId: z.ZodString;
52
+ }, z.core.$strict>;
53
+ executionActor: z.ZodOptional<z.ZodObject<{
54
+ platform: z.ZodLiteral<"system">;
55
+ name: z.ZodString;
56
+ }, z.core.$strict>>;
57
+ lastRunAtMs: z.ZodOptional<z.ZodNumber>;
58
+ nextRunAtMs: z.ZodOptional<z.ZodNumber>;
59
+ originalRequest: z.ZodOptional<z.ZodString>;
60
+ runNowAtMs: z.ZodOptional<z.ZodNumber>;
61
+ schedule: z.ZodObject<{
62
+ description: z.ZodString;
63
+ kind: z.ZodEnum<{
64
+ one_off: "one_off";
65
+ recurring: "recurring";
66
+ }>;
67
+ recurrence: z.ZodOptional<z.ZodObject<{
68
+ dayOfMonth: z.ZodOptional<z.ZodNumber>;
69
+ frequency: z.ZodEnum<{
70
+ daily: "daily";
71
+ weekly: "weekly";
72
+ monthly: "monthly";
73
+ yearly: "yearly";
74
+ }>;
75
+ interval: z.ZodNumber;
76
+ month: z.ZodOptional<z.ZodNumber>;
77
+ startDate: z.ZodString;
78
+ time: z.ZodObject<{
79
+ hour: z.ZodNumber;
80
+ minute: z.ZodNumber;
81
+ }, z.core.$strict>;
82
+ weekdays: z.ZodOptional<z.ZodArray<z.ZodNumber>>;
83
+ }, z.core.$strict>>;
84
+ timezone: z.ZodString;
85
+ }, z.core.$strict>;
86
+ status: z.ZodEnum<{
87
+ completed: "completed";
88
+ blocked: "blocked";
89
+ active: "active";
90
+ deleted: "deleted";
91
+ }>;
92
+ statusReason: z.ZodOptional<z.ZodString>;
93
+ task: z.ZodObject<{
94
+ text: z.ZodString;
95
+ }, z.core.$strict>;
96
+ title: z.ZodOptional<z.ZodString>;
97
+ updatedAtMs: z.ZodNumber;
98
+ }, z.core.$strict>;
99
+ /** Validate the current scheduled-run domain shape. */
100
+ export declare const scheduledRunSchema: z.ZodObject<{
101
+ id: z.ZodString;
102
+ attempt: z.ZodNumber;
103
+ claimedAtMs: z.ZodNumber;
104
+ completedAtMs: z.ZodOptional<z.ZodNumber>;
105
+ dispatchId: z.ZodOptional<z.ZodString>;
106
+ errorMessage: z.ZodOptional<z.ZodString>;
107
+ resultMessageTs: z.ZodOptional<z.ZodString>;
108
+ scheduledForMs: z.ZodNumber;
109
+ startedAtMs: z.ZodOptional<z.ZodNumber>;
110
+ status: z.ZodEnum<{
111
+ pending: "pending";
112
+ running: "running";
113
+ completed: "completed";
114
+ failed: "failed";
115
+ blocked: "blocked";
116
+ skipped: "skipped";
117
+ }>;
118
+ taskId: z.ZodString;
119
+ }, z.core.$strict>;
120
+ export type ScheduledTask = z.output<typeof scheduledTaskSchema>;
121
+ export type ScheduledRun = z.output<typeof scheduledRunSchema>;
122
+ export type ScheduledTaskRecord = Omit<ScheduledTask, "title">;
123
+ export type ScheduledTaskPrincipal = ScheduledTask["createdBy"];
124
+ export type ScheduledTaskExecutionActor = NonNullable<ScheduledTask["executionActor"]>;
125
+ export type ScheduledTaskConversationAccess = ScheduledTask["conversationAccess"];
126
+ export type ScheduledTaskSchedule = ScheduledTask["schedule"];
127
+ export type ScheduledTaskRecurrence = NonNullable<ScheduledTaskSchedule["recurrence"]>;
128
+ export type ScheduledTaskSpec = ScheduledTask["task"];
129
+ export type ScheduledCalendarFrequency = ScheduledTaskRecurrence["frequency"];
130
+ export type ScheduledLocalTime = ScheduledTaskRecurrence["time"];
17
131
  export declare const SCHEDULED_TASK_SYSTEM_ACTOR: Readonly<{
18
132
  platform: "system";
19
133
  name: string;
20
134
  }>;
21
- export interface ScheduledTaskConversationAccess {
22
- audience: "direct" | "group" | "channel";
23
- visibility: "private" | "public";
24
- }
25
- export type ScheduledCalendarFrequency = "daily" | "weekly" | "monthly" | "yearly";
26
- export interface ScheduledLocalTime {
27
- hour: number;
28
- minute: number;
29
- }
30
- export interface ScheduledTaskRecurrence {
31
- dayOfMonth?: number;
32
- frequency: ScheduledCalendarFrequency;
33
- interval: number;
34
- month?: number;
35
- startDate: string;
36
- time: ScheduledLocalTime;
37
- weekdays?: number[];
38
- }
39
- export interface ScheduledTaskSchedule {
40
- description: string;
41
- timezone: string;
42
- kind: "one_off" | "recurring";
43
- recurrence?: ScheduledTaskRecurrence;
44
- }
45
- export interface ScheduledTaskSpec {
46
- text: string;
47
- }
48
- export interface ScheduledTask {
49
- id: string;
50
- createdAtMs: number;
51
- createdBy: ScheduledTaskPrincipal;
52
- /** Authoritative provider identity that created the task. */
53
- creatorIdentityId: string;
54
- conversationAccess: ScheduledTaskConversationAccess;
55
- /** Selects system credentials or task-bound creator credential delegation. */
56
- credentialMode: ScheduledTaskCredentialMode;
57
- destination: SlackDestination;
58
- executionActor?: ScheduledTaskExecutionActor;
59
- lastRunAtMs?: number;
60
- nextRunAtMs?: number;
61
- originalRequest?: string;
62
- runNowAtMs?: number;
63
- schedule: ScheduledTaskSchedule;
64
- status: ScheduledTaskStatus;
65
- statusReason?: string;
66
- task: ScheduledTaskSpec;
67
- /**
68
- * Short display title generated from the task instruction.
69
- * SQL-backed column; never stored inside the JSON record payload.
70
- */
71
- title?: string;
72
- updatedAtMs: number;
73
- }
74
- export interface ScheduledRun {
75
- id: string;
76
- attempt: number;
77
- claimedAtMs: number;
78
- completedAtMs?: number;
79
- dispatchId?: string;
80
- errorMessage?: string;
81
- resultMessageTs?: string;
82
- scheduledForMs: number;
83
- startedAtMs?: number;
84
- status: ScheduledRunStatus;
85
- taskId: string;
86
- }
135
+ export {};
@@ -0,0 +1,27 @@
1
+ import type { AgentTool } from "@earendil-works/pi-agent-core";
2
+ import type { PiMessage } from "@/chat/pi/messages";
3
+ /** Pending soft wait for a Workspace snapshot from the latest tool result. */
4
+ export declare function pendingWorkspaceSnapshotWait(messages: readonly PiMessage[]): {
5
+ name: string;
6
+ } | null;
7
+ /**
8
+ * Continue a soft Workspace snapshot wait without another model turn.
9
+ * Re-invokes switchWorkspace and appends the complete Pi tool boundary.
10
+ */
11
+ export declare function continueWorkspaceSnapshotWait(args: {
12
+ messages: PiMessage[];
13
+ tools: AgentTool[];
14
+ signal?: AbortSignal;
15
+ }): Promise<{
16
+ kind: "none";
17
+ } | {
18
+ kind: "waiting";
19
+ messages: PiMessage[];
20
+ } | {
21
+ kind: "ready";
22
+ messages: PiMessage[];
23
+ } | {
24
+ kind: "failed";
25
+ error: unknown;
26
+ messages: PiMessage[];
27
+ }>;