@sentry/junior 0.182.0 → 0.184.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 (98) hide show
  1. package/dist/{agent-hooks-3S25UIHO.js → agent-hooks-XTZVALGQ.js} +11 -11
  2. package/dist/api/acp/auth.d.ts +46 -0
  3. package/dist/api/acp/authorization-page.d.ts +11 -0
  4. package/dist/api/acp/conversations.d.ts +70 -0
  5. package/dist/api/acp/errors.d.ts +6 -0
  6. package/dist/api/acp/route.d.ts +16 -0
  7. package/dist/api/acp/schema.d.ts +97 -0
  8. package/dist/api/acp/sleep.d.ts +2 -0
  9. package/dist/api/acp/state.d.ts +22 -0
  10. package/dist/api/acp/transport.d.ts +113 -0
  11. package/dist/api/code/overview.d.ts +35 -0
  12. package/dist/api/code/routes.d.ts +4 -0
  13. package/dist/api/schema/code.d.ts +75 -0
  14. package/dist/api/schema.d.ts +2 -0
  15. package/dist/api/schema.js +9 -1
  16. package/dist/api.js +258 -134
  17. package/dist/app.d.ts +0 -4
  18. package/dist/app.js +2171 -220
  19. package/dist/{catalog-runtime-ESLMBQBV.js → catalog-runtime-5357XR4F.js} +4 -4
  20. package/dist/chat/agent-invocations/store.d.ts +4 -2
  21. package/dist/chat/agent-invocations/work.d.ts +1 -3
  22. package/dist/chat/app/factory.d.ts +3 -3
  23. package/dist/chat/app/services.d.ts +3 -3
  24. package/dist/chat/code/publisher.d.ts +3 -0
  25. package/dist/chat/code/store.d.ts +9 -0
  26. package/dist/chat/event-tasks/store.d.ts +10 -0
  27. package/dist/chat/ingress/slack-webhook.d.ts +1 -1
  28. package/dist/chat/plugins/agent-hooks.d.ts +5 -0
  29. package/dist/chat/{runtime/slack-runtime.d.ts → providers/slack/runtime.d.ts} +2 -2
  30. package/dist/chat/{runtime/reply-executor.d.ts → providers/slack/turn.d.ts} +10 -9
  31. package/dist/chat/resource-events/store.d.ts +12 -0
  32. package/dist/chat/runtime/turn-execution.d.ts +30 -0
  33. package/dist/chat/slack/dispatch-turn.d.ts +12 -14
  34. package/dist/chat/task-execution/slack-work.d.ts +1 -1
  35. package/dist/{chunk-SXOZIG5X.js → chunk-2ZQPVX7C.js} +6 -6
  36. package/dist/{chunk-UQP54CXZ.js → chunk-3S7ULUWW.js} +1 -1
  37. package/dist/{chunk-2CEOXDG2.js → chunk-4CNDGK25.js} +174 -6
  38. package/dist/{chunk-3THPTNN6.js → chunk-4RONS3WR.js} +4 -4
  39. package/dist/{chunk-LHQK5XCU.js → chunk-6UDPINOX.js} +2 -2
  40. package/dist/{chunk-BZD4ADQH.js → chunk-6VOYP4M6.js} +2 -3
  41. package/dist/{chunk-QHALFHZA.js → chunk-6WGC3SO4.js} +9 -9
  42. package/dist/{chunk-BDDWVY32.js → chunk-ACPDVEJO.js} +22 -20
  43. package/dist/{chunk-44BQ3TSK.js → chunk-BCHYQS4B.js} +233 -173
  44. package/dist/{chunk-SVFSYQMT.js → chunk-BHYRYYLY.js} +1 -1
  45. package/dist/{chunk-LT4QYGKM.js → chunk-BT53RIGJ.js} +160 -97
  46. package/dist/{chunk-Z7ALSQS3.js → chunk-DUKIDPF6.js} +1 -1
  47. package/dist/{chunk-PQES5LB5.js → chunk-E57WPXWY.js} +5 -5
  48. package/dist/{chunk-GGYA5NPN.js → chunk-FKEZZMXS.js} +8 -8
  49. package/dist/{chunk-LB4FWMCV.js → chunk-HIPUIPJM.js} +183 -155
  50. package/dist/{chunk-3NFHI2NA.js → chunk-HUXFMDBZ.js} +1 -1
  51. package/dist/{chunk-6TSWXBTQ.js → chunk-IZDYYYGP.js} +3 -3
  52. package/dist/{chunk-YHL2L2ZZ.js → chunk-JA43DV4Y.js} +1 -1
  53. package/dist/{chunk-V5UZCCNW.js → chunk-JM2COLGC.js} +6 -6
  54. package/dist/{chunk-A7THOQ6N.js → chunk-JNO2GUDS.js} +21 -21
  55. package/dist/{chunk-KGMHUDVF.js → chunk-K7VDC2QW.js} +6 -6
  56. package/dist/{chunk-CVBIM4Z3.js → chunk-LCP4EDKR.js} +1 -1
  57. package/dist/{chunk-4DZ62L36.js → chunk-LHXIZLFF.js} +1 -1
  58. package/dist/{chunk-D6OHGAIO.js → chunk-M5YWNMTE.js} +5 -5
  59. package/dist/{chunk-3ENUMZNG.js → chunk-MAPJFUMV.js} +3 -3
  60. package/dist/{chunk-UUMBHORH.js → chunk-MLSQX2EX.js} +1 -1
  61. package/dist/{chunk-WOIALVN2.js → chunk-PJPRXO2T.js} +1 -1
  62. package/dist/{chunk-VHMAFMHB.js → chunk-QABCY33S.js} +1 -1
  63. package/dist/{chunk-UKIHNBBD.js → chunk-SHJK75Z2.js} +3 -3
  64. package/dist/{chunk-S35OZMSL.js → chunk-UBOIHNTH.js} +13 -13
  65. package/dist/{chunk-DZR3L74W.js → chunk-UF6BUA5W.js} +3 -3
  66. package/dist/{chunk-JIOKUIAS.js → chunk-WQFEWULF.js} +2 -2
  67. package/dist/chunk-WVIA7V3M.js +975 -0
  68. package/dist/{chunk-MJISSOWB.js → chunk-YKX6MTLU.js} +1 -1
  69. package/dist/{chunk-TEFNHMO2.js → chunk-Z3QAXJR7.js} +4 -4
  70. package/dist/cli/chat.js +33 -35
  71. package/dist/cli/check.js +5 -5
  72. package/dist/cli/plugins.js +12 -12
  73. package/dist/cli/snapshot-create.js +9 -9
  74. package/dist/cli/upgrade.js +6 -6
  75. package/dist/db/schema/code.d.ts +367 -0
  76. package/dist/db/schema.d.ts +367 -1
  77. package/dist/{db-NYIWZ4L5.js → db-MA52H62H.js} +6 -6
  78. package/dist/instrumentation.js +3 -3
  79. package/dist/nitro.js +6 -6
  80. package/dist/{oauth-callback-server-A2YTPVVX.js → oauth-callback-server-DXGHKN6S.js} +25 -25
  81. package/dist/{runner-VKAEU52J.js → runner-4IXUAQNK.js} +18 -18
  82. package/dist/{skills-52GMXUTY.js → skills-X3DY7AXO.js} +5 -5
  83. package/dist/spawn-43WGS6CH.js +37 -0
  84. package/dist/task-runner-VDRKITPV.js +32 -0
  85. package/dist/{validation-VD2YQX2W.js → validation-Z6JXSTJS.js} +5 -5
  86. package/dist/version.js +1 -1
  87. package/dist/{work-ZWBTGEQP.js → work-OKWRFBDW.js} +18 -18
  88. package/dist/worker-B236AE72.js +22 -0
  89. package/migrations/0036_complex_rage.sql +32 -0
  90. package/migrations/meta/0036_snapshot.json +3186 -0
  91. package/migrations/meta/_journal.json +8 -1
  92. package/package.json +6 -7
  93. package/dist/app-adapter.d.ts +0 -85
  94. package/dist/chat/api-turns/adapter-conversations.d.ts +0 -15
  95. package/dist/chunk-CZYNWPWD.js +0 -930
  96. package/dist/spawn-GSS4EBLR.js +0 -37
  97. package/dist/task-runner-DUGDWF5O.js +0 -32
  98. package/dist/worker-XUWD5WS7.js +0 -22
@@ -13,24 +13,24 @@ import {
13
13
  getPlugins,
14
14
  setPlugins,
15
15
  validatePlugins
16
- } from "./chunk-2CEOXDG2.js";
16
+ } from "./chunk-4CNDGK25.js";
17
17
  import "./chunk-3Y47VMHV.js";
18
- import "./chunk-6TSWXBTQ.js";
19
- import "./chunk-44BQ3TSK.js";
20
- import "./chunk-UKIHNBBD.js";
21
- import "./chunk-Z7ALSQS3.js";
18
+ import "./chunk-IZDYYYGP.js";
19
+ import "./chunk-BCHYQS4B.js";
20
+ import "./chunk-SHJK75Z2.js";
21
+ import "./chunk-DUKIDPF6.js";
22
22
  import "./chunk-VFUK3X5B.js";
23
- import "./chunk-LHQK5XCU.js";
24
- import "./chunk-SVFSYQMT.js";
25
- import "./chunk-WOIALVN2.js";
26
- import "./chunk-4DZ62L36.js";
23
+ import "./chunk-6UDPINOX.js";
24
+ import "./chunk-BHYRYYLY.js";
25
+ import "./chunk-PJPRXO2T.js";
26
+ import "./chunk-LHXIZLFF.js";
27
27
  import "./chunk-CEMMLV5L.js";
28
28
  import "./chunk-N7TMSOZH.js";
29
29
  import "./chunk-DWPN6SCH.js";
30
30
  import "./chunk-TXKUKMVO.js";
31
- import "./chunk-UQP54CXZ.js";
31
+ import "./chunk-3S7ULUWW.js";
32
32
  import "./chunk-PEQXYSSE.js";
33
- import "./chunk-BZD4ADQH.js";
33
+ import "./chunk-6VOYP4M6.js";
34
34
  export {
35
35
  PluginHookDeniedError,
36
36
  applyPluginFormatMarkdown,
@@ -0,0 +1,46 @@
1
+ import * as acp from "@agentclientprotocol/sdk";
2
+ import { type User } from "@sentry/junior-plugin-api";
3
+ import { type AcpState } from "./state";
4
+ import { type AcpRequestReceipt } from "./transport";
5
+ export type AcpAuthorizationCompletion = "busy" | "completed" | "conflict" | "expired" | "invalid";
6
+ export declare const ACP_AUTH_METHOD_ID = "junior";
7
+ export declare const ACP_AUTH_METHOD: {
8
+ id: string;
9
+ name: string;
10
+ description: string;
11
+ };
12
+ /** Create the secret cookie that proves control of one ACP connection. */
13
+ export declare function createAcpConnectionCredential(request: Request): {
14
+ cookie: string;
15
+ credentialHash: string;
16
+ };
17
+ /** Verify that this request controls the supplied ACP connection hash. */
18
+ export declare function hasAcpConnectionCredential(request: Request, expectedHash: string): boolean;
19
+ /** Start browser authorization for one ACP authenticate request. */
20
+ export declare function beginAcpAuthorization(args: {
21
+ baseURL?: string;
22
+ connectionId: string;
23
+ credentialHash: string;
24
+ request: Request;
25
+ requestId: acp.JsonRpcId;
26
+ requestKey: string;
27
+ state: AcpState;
28
+ }): Promise<AcpRequestReceipt>;
29
+ /** Bind a Google-authenticated user and resume the pending ACP request. */
30
+ export declare function completeAcpAuthorization(args: {
31
+ state: AcpState;
32
+ transactionId: string;
33
+ user: User;
34
+ userCode: string;
35
+ }): Promise<AcpAuthorizationCompletion>;
36
+ /** Consume a client response to the browser URL elicitation. */
37
+ export declare function handleAcpAuthorizationResponse(args: {
38
+ connectionId: string;
39
+ response: acp.AnyResponse;
40
+ state: AcpState;
41
+ }): Promise<"accepted" | "cancelled" | "ignored">;
42
+ /** Finish an abandoned browser authorization while its connection stream is live. */
43
+ export declare function expireAcpAuthorization(args: {
44
+ connectionId: string;
45
+ state: AcpState;
46
+ }): Promise<boolean>;
@@ -0,0 +1,11 @@
1
+ /** Own the dashboard-authenticated ACP confirmation page. */
2
+ import type { User } from "@sentry/junior-plugin-api";
3
+ import type { AcpState } from "./state";
4
+ export declare const ACP_AUTHORIZATION_PATH = "/_junior/acp/auth/:transactionId";
5
+ /** Complete one ACP browser authorization for a host-authenticated user. */
6
+ export declare function handleAcpAuthorizationPage(args: {
7
+ agentName: string;
8
+ request: Request;
9
+ state: AcpState;
10
+ user: User;
11
+ }): Promise<Response>;
@@ -0,0 +1,70 @@
1
+ /** Bind ACP sessions to Junior's existing Conversation runtime. */
2
+ import type { StateAdapter } from "chat";
3
+ import type { User } from "@sentry/junior-plugin-api";
4
+ import type { ConversationEventStore } from "@/chat/conversations/history";
5
+ import type { ConversationStore } from "@/chat/conversations/store";
6
+ import type { ConversationWorkQueue } from "@/chat/task-execution/queue";
7
+ type ConversationMessage = {
8
+ id: string;
9
+ role: "assistant" | "user";
10
+ text: string;
11
+ };
12
+ type PromptAdmission = {
13
+ afterCursor: number;
14
+ messageId: string;
15
+ status: "accepted";
16
+ turnId: string;
17
+ } | {
18
+ status: "active";
19
+ } | {
20
+ status: "not_found";
21
+ };
22
+ type TurnTerminal = {
23
+ outcome: "cancelled" | "completed";
24
+ status: "completed";
25
+ } | {
26
+ failureCode: string;
27
+ status: "failed";
28
+ };
29
+ type TurnPage = {
30
+ cursor: number;
31
+ messages: ConversationMessage[];
32
+ terminal?: TurnTerminal;
33
+ };
34
+ /** ACP operations backed by Junior Conversations. */
35
+ export type AcpConversations = {
36
+ cancel(args: {
37
+ conversationId: string;
38
+ user: User;
39
+ }): Promise<"cancelled" | "not_found">;
40
+ create(args: {
41
+ conversationId: string;
42
+ user: User;
43
+ }): Promise<void>;
44
+ hasAccess(args: {
45
+ conversationId: string;
46
+ user: User;
47
+ }): Promise<boolean>;
48
+ prompt(args: {
49
+ conversationId: string;
50
+ idempotencyKey: string;
51
+ text: string;
52
+ user: User;
53
+ }): Promise<PromptAdmission>;
54
+ readMessages(conversationId: string): Promise<ConversationMessage[]>;
55
+ readTurn(args: {
56
+ afterCursor: number;
57
+ conversationId: string;
58
+ messageId: string;
59
+ turnId: string;
60
+ }): Promise<TurnPage>;
61
+ };
62
+ interface ConversationOptions {
63
+ conversationStore?: ConversationStore;
64
+ eventStore: ConversationEventStore;
65
+ queue: ConversationWorkQueue;
66
+ state: StateAdapter;
67
+ }
68
+ /** Create the ACP view of Junior's Conversation runtime. */
69
+ export declare function createAcpConversations(options: ConversationOptions): AcpConversations;
70
+ export {};
@@ -0,0 +1,6 @@
1
+ export type AcpErrorContext = {
2
+ connectionId?: string;
3
+ conversationId?: string;
4
+ userId?: string;
5
+ };
6
+ export type ReportAcpError = (error: unknown, event: string, context: AcpErrorContext) => void;
@@ -0,0 +1,16 @@
1
+ import type { ReportAcpError } from "./errors";
2
+ import type { AcpConversations } from "./conversations";
3
+ import type { AcpState } from "./state";
4
+ /** Dependencies for the serverless-safe remote ACP HTTP handler. */
5
+ type AcpHttpHandlerOptions = {
6
+ browserAuth?: {
7
+ baseURL?: string;
8
+ };
9
+ conversations: AcpConversations;
10
+ onError?: ReportAcpError;
11
+ state: AcpState;
12
+ version: string;
13
+ };
14
+ /** Create a serverless-safe remote ACP v1 HTTP handler. */
15
+ export declare function createAcpHttpHandler(options: AcpHttpHandlerOptions): (request: Request) => Promise<Response>;
16
+ export {};
@@ -0,0 +1,97 @@
1
+ import { z } from "zod";
2
+ export declare const SESSION_HEADER_METHODS: Set<string>;
3
+ export declare const acpConnectionIdSchema: z.ZodString;
4
+ export declare const acpSessionIdSchema: z.ZodString;
5
+ export declare const acpCallSchema: z.ZodObject<{
6
+ id: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodNull]>>;
7
+ jsonrpc: z.ZodLiteral<"2.0">;
8
+ method: z.ZodString;
9
+ params: z.ZodOptional<z.ZodUnknown>;
10
+ }, z.core.$strict>;
11
+ export declare const acpResponseSchema: z.ZodUnion<readonly [z.ZodObject<{
12
+ id: z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodNull]>;
13
+ jsonrpc: z.ZodLiteral<"2.0">;
14
+ result: z.ZodUnknown;
15
+ }, z.core.$strict>, z.ZodObject<{
16
+ error: z.ZodObject<{
17
+ code: z.ZodNumber;
18
+ data: z.ZodOptional<z.ZodUnknown>;
19
+ message: z.ZodString;
20
+ }, z.core.$strict>;
21
+ id: z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodNull]>;
22
+ jsonrpc: z.ZodLiteral<"2.0">;
23
+ }, z.core.$strict>]>;
24
+ export declare const acpInboundMessageSchema: z.ZodUnion<readonly [z.ZodObject<{
25
+ id: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodNull]>>;
26
+ jsonrpc: z.ZodLiteral<"2.0">;
27
+ method: z.ZodString;
28
+ params: z.ZodOptional<z.ZodUnknown>;
29
+ }, z.core.$strict>, z.ZodUnion<readonly [z.ZodObject<{
30
+ id: z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodNull]>;
31
+ jsonrpc: z.ZodLiteral<"2.0">;
32
+ result: z.ZodUnknown;
33
+ }, z.core.$strict>, z.ZodObject<{
34
+ error: z.ZodObject<{
35
+ code: z.ZodNumber;
36
+ data: z.ZodOptional<z.ZodUnknown>;
37
+ message: z.ZodString;
38
+ }, z.core.$strict>;
39
+ id: z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodNull]>;
40
+ jsonrpc: z.ZodLiteral<"2.0">;
41
+ }, z.core.$strict>]>]>;
42
+ export declare const initializeParamsSchema: z.ZodObject<{
43
+ _meta: z.ZodOptional<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
44
+ clientCapabilities: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
45
+ clientInfo: z.ZodOptional<z.ZodNullable<z.ZodObject<{
46
+ _meta: z.ZodOptional<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
47
+ name: z.ZodString;
48
+ title: z.ZodOptional<z.ZodNullable<z.ZodString>>;
49
+ version: z.ZodString;
50
+ }, z.core.$strict>>>;
51
+ protocolVersion: z.ZodNumber;
52
+ }, z.core.$strict>;
53
+ export declare const authenticateParamsSchema: z.ZodObject<{
54
+ _meta: z.ZodOptional<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
55
+ methodId: z.ZodString;
56
+ }, z.core.$strict>;
57
+ export declare const newSessionParamsSchema: z.ZodObject<{
58
+ _meta: z.ZodOptional<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
59
+ additionalDirectories: z.ZodOptional<z.ZodArray<z.ZodString>>;
60
+ cwd: z.ZodString;
61
+ mcpServers: z.ZodArray<z.ZodUnknown>;
62
+ }, z.core.$strict>;
63
+ export declare const loadSessionParamsSchema: z.ZodObject<{
64
+ _meta: z.ZodOptional<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
65
+ additionalDirectories: z.ZodOptional<z.ZodArray<z.ZodString>>;
66
+ cwd: z.ZodString;
67
+ mcpServers: z.ZodArray<z.ZodUnknown>;
68
+ sessionId: z.ZodString;
69
+ }, z.core.$strict>;
70
+ export declare const promptParamsSchema: z.ZodObject<{
71
+ _meta: z.ZodOptional<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
72
+ prompt: z.ZodArray<z.ZodObject<{
73
+ _meta: z.ZodOptional<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
74
+ annotations: z.ZodOptional<z.ZodNullable<z.ZodObject<{
75
+ _meta: z.ZodOptional<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
76
+ audience: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodEnum<{
77
+ user: "user";
78
+ assistant: "assistant";
79
+ }>>>>;
80
+ lastModified: z.ZodOptional<z.ZodNullable<z.ZodString>>;
81
+ priority: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
82
+ }, z.core.$strict>>>;
83
+ text: z.ZodString;
84
+ type: z.ZodLiteral<"text">;
85
+ }, z.core.$strict>>;
86
+ sessionId: z.ZodString;
87
+ }, z.core.$strict>;
88
+ export declare const cancelParamsSchema: z.ZodObject<{
89
+ _meta: z.ZodOptional<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
90
+ sessionId: z.ZodString;
91
+ }, z.core.$strict>;
92
+ export type AcpCall = z.output<typeof acpCallSchema>;
93
+ export type AcpResponse = z.output<typeof acpResponseSchema>;
94
+ export type SessionParams = z.output<typeof newSessionParamsSchema>;
95
+ export type LoadSessionParams = z.output<typeof loadSessionParamsSchema>;
96
+ export type PromptParams = z.output<typeof promptParamsSchema>;
97
+ export type CancelParams = z.output<typeof cancelParamsSchema>;
@@ -0,0 +1,2 @@
1
+ /** Wait for a duration and reject when the ACP request stops. */
2
+ export declare function sleep(ms: number, signal: AbortSignal): Promise<void>;
@@ -0,0 +1,22 @@
1
+ import type { Lock, StateAdapter } from "chat";
2
+ /** One lock held in shared ACP state. */
3
+ export type AcpLock = Lock;
4
+ /** Shared state operations required by the ACP transport. */
5
+ export type AcpState = Pick<StateAdapter, "acquireLock" | "appendToList" | "delete" | "extendLock" | "get" | "getList" | "releaseLock" | "set">;
6
+ export declare const MUTATION_LOCK_TTL_MS = 10000;
7
+ type LockAttempt<T> = {
8
+ acquired: false;
9
+ } | {
10
+ acquired: true;
11
+ value: T;
12
+ };
13
+ /** Run one ACP state mutation while its shared lock remains owned. */
14
+ export declare function withLock<T>(state: AcpState, key: string, run: (lock: AcpLock) => Promise<T>, options?: {
15
+ keepAlive?: boolean;
16
+ retryMs?: number;
17
+ ttlMs?: number;
18
+ waitMs?: number;
19
+ }): Promise<LockAttempt<T>>;
20
+ /** Prove ACP lock ownership immediately before a blind state write. */
21
+ export declare function fenceLock(state: AcpState, lock: AcpLock, ttlMs?: number): Promise<void>;
22
+ export {};
@@ -0,0 +1,113 @@
1
+ import { type User } from "@sentry/junior-plugin-api";
2
+ import { z } from "zod";
3
+ import type { ReportAcpError } from "./errors";
4
+ import type { AcpConversations } from "./conversations";
5
+ import { type AcpState } from "./state";
6
+ export declare const ACP_STATE_TTL_MS: number;
7
+ declare const acpConnectionSchema: z.ZodObject<{
8
+ credentialHash: z.ZodString;
9
+ nonce: z.ZodString;
10
+ user: z.ZodOptional<z.ZodObject<{
11
+ displayName: z.ZodOptional<z.ZodString>;
12
+ email: z.ZodString;
13
+ id: z.ZodString;
14
+ identities: z.ZodArray<z.ZodObject<{
15
+ displayName: z.ZodOptional<z.ZodString>;
16
+ handle: z.ZodOptional<z.ZodString>;
17
+ id: z.ZodString;
18
+ provider: z.ZodString;
19
+ providerSubjectId: z.ZodString;
20
+ providerTenantId: z.ZodOptional<z.ZodString>;
21
+ }, z.core.$strict>>;
22
+ }, z.core.$strict>>;
23
+ }, z.core.$strict>;
24
+ declare const acpStreamRouteSchema: z.ZodObject<{
25
+ connectionId: z.ZodString;
26
+ sessionId: z.ZodOptional<z.ZodString>;
27
+ }, z.core.$strict>;
28
+ declare const acpPromptStreamOutputSchema: z.ZodObject<{
29
+ afterSeq: z.ZodNumber;
30
+ kind: z.ZodLiteral<"prompt">;
31
+ messageId: z.ZodString;
32
+ requestId: z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodNull]>;
33
+ turnId: z.ZodString;
34
+ }, z.core.$strict>;
35
+ declare const acpRequestReceiptSchema: z.ZodObject<{
36
+ deliveryKey: z.ZodOptional<z.ZodString>;
37
+ outputs: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
38
+ kind: z.ZodLiteral<"message">;
39
+ message: z.ZodUnion<readonly [z.ZodObject<{
40
+ id: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodNull]>>;
41
+ jsonrpc: z.ZodLiteral<"2.0">;
42
+ method: z.ZodString;
43
+ params: z.ZodOptional<z.ZodUnknown>;
44
+ }, z.core.$strict>, z.ZodUnion<readonly [z.ZodObject<{
45
+ id: z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodNull]>;
46
+ jsonrpc: z.ZodLiteral<"2.0">;
47
+ result: z.ZodUnknown;
48
+ }, z.core.$strict>, z.ZodObject<{
49
+ error: z.ZodObject<{
50
+ code: z.ZodNumber;
51
+ data: z.ZodOptional<z.ZodUnknown>;
52
+ message: z.ZodString;
53
+ }, z.core.$strict>;
54
+ id: z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodNull]>;
55
+ jsonrpc: z.ZodLiteral<"2.0">;
56
+ }, z.core.$strict>]>]>;
57
+ }, z.core.$strict>, z.ZodObject<{
58
+ kind: z.ZodLiteral<"replay">;
59
+ }, z.core.$strict>, z.ZodObject<{
60
+ afterSeq: z.ZodNumber;
61
+ kind: z.ZodLiteral<"prompt">;
62
+ messageId: z.ZodString;
63
+ requestId: z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodNull]>;
64
+ turnId: z.ZodString;
65
+ }, z.core.$strict>], "kind">>;
66
+ sessionId: z.ZodOptional<z.ZodString>;
67
+ }, z.core.$strict>;
68
+ export type AcpConnection = z.output<typeof acpConnectionSchema>;
69
+ export type AcpStreamRoute = z.output<typeof acpStreamRouteSchema>;
70
+ export type AcpPromptStreamOutput = z.output<typeof acpPromptStreamOutputSchema>;
71
+ export type AcpRequestReceipt = z.output<typeof acpRequestReceiptSchema>;
72
+ /** Create one unauthenticated ACP transport connection. */
73
+ export declare function createAcpConnection(state: AcpState, credentialHash: string): Promise<{
74
+ connection: AcpConnection;
75
+ connectionId: string;
76
+ }>;
77
+ /** Read one live ACP transport connection. */
78
+ export declare function readAcpConnection(state: AcpState, connectionId: string): Promise<AcpConnection | undefined>;
79
+ /** Remove one ACP connection so all of its live streams terminate. */
80
+ export declare function deleteAcpConnection(state: AcpState, connectionId: string): Promise<void>;
81
+ /** Bind one live ACP connection to the canonical authorized user. */
82
+ export declare function bindAcpConnectionUser(args: {
83
+ connectionId: string;
84
+ credentialHash: string;
85
+ state: AcpState;
86
+ user: User;
87
+ }): Promise<"completed" | "conflict" | "expired">;
88
+ /** Replace one pending request receipt and queue its final output once. */
89
+ export declare function completeAcpRequest(args: {
90
+ connectionId: string;
91
+ receipt: AcpRequestReceipt;
92
+ requestKey: string;
93
+ state: AcpState;
94
+ }): Promise<"completed" | "expired" | "full">;
95
+ /** Store a receipt once and reserve output before side-effecting creation. */
96
+ export declare function acceptAcpRequest(args: {
97
+ connectionId: string;
98
+ createReceipt: () => Promise<AcpRequestReceipt>;
99
+ reserveRoute?: AcpStreamRoute;
100
+ requestKey: string;
101
+ state: AcpState;
102
+ }): Promise<"accepted" | "busy" | "expired" | "full">;
103
+ /** Open one connection or session SSE reader backed by shared state. */
104
+ export declare function openAcpSse(args: {
105
+ conversations: AcpConversations;
106
+ maintain?: () => Promise<void>;
107
+ onError?: ReportAcpError;
108
+ requestSignal: AbortSignal;
109
+ route: AcpStreamRoute;
110
+ state: AcpState;
111
+ userId?: string;
112
+ }): Promise<Response>;
113
+ export {};
@@ -0,0 +1,35 @@
1
+ /** Read code activity created by Junior across installed code plugins. */
2
+ export declare function readCodeOverview(nowMs?: number): Promise<{
3
+ changes: {
4
+ id: string;
5
+ number: number;
6
+ openedAt: string;
7
+ provider: string;
8
+ repository: string;
9
+ state: "open" | "closed" | "merged";
10
+ closedAt?: string | undefined;
11
+ mergedAt?: string | undefined;
12
+ title?: string | undefined;
13
+ url?: string | undefined;
14
+ }[];
15
+ generatedAt: string;
16
+ repositories: {
17
+ closed: number;
18
+ created: number;
19
+ id: string;
20
+ merged: number;
21
+ name: string;
22
+ open: number;
23
+ provider: string;
24
+ url?: string | undefined;
25
+ }[];
26
+ summary: {
27
+ closed: number;
28
+ created: number;
29
+ merged: number;
30
+ open: number;
31
+ mergeRate?: number | undefined;
32
+ };
33
+ windowEnd: string;
34
+ windowStart: string;
35
+ }>;
@@ -0,0 +1,4 @@
1
+ import { Hono } from "hono";
2
+ import type { JuniorApiEnv } from "../route";
3
+ /** Create the code analytics API. */
4
+ export declare function createCodeRoutes(): Hono<JuniorApiEnv>;
@@ -0,0 +1,75 @@
1
+ import { z } from "zod";
2
+ export declare const codeChangeSummarySchema: z.ZodObject<{
3
+ closed: z.ZodNumber;
4
+ created: z.ZodNumber;
5
+ merged: z.ZodNumber;
6
+ mergeRate: z.ZodOptional<z.ZodNumber>;
7
+ open: z.ZodNumber;
8
+ }, z.core.$strict>;
9
+ export declare const codeRepositorySummarySchema: z.ZodObject<{
10
+ closed: z.ZodNumber;
11
+ created: z.ZodNumber;
12
+ id: z.ZodString;
13
+ merged: z.ZodNumber;
14
+ name: z.ZodString;
15
+ open: z.ZodNumber;
16
+ provider: z.ZodString;
17
+ url: z.ZodOptional<z.ZodString>;
18
+ }, z.core.$strict>;
19
+ export declare const codeChangeSummaryReportSchema: z.ZodObject<{
20
+ closedAt: z.ZodOptional<z.ZodString>;
21
+ id: z.ZodString;
22
+ mergedAt: z.ZodOptional<z.ZodString>;
23
+ number: z.ZodNumber;
24
+ openedAt: z.ZodString;
25
+ provider: z.ZodString;
26
+ repository: z.ZodString;
27
+ state: z.ZodEnum<{
28
+ open: "open";
29
+ closed: "closed";
30
+ merged: "merged";
31
+ }>;
32
+ title: z.ZodOptional<z.ZodString>;
33
+ url: z.ZodOptional<z.ZodString>;
34
+ }, z.core.$strict>;
35
+ export declare const codeOverviewReportSchema: z.ZodObject<{
36
+ changes: z.ZodArray<z.ZodObject<{
37
+ closedAt: z.ZodOptional<z.ZodString>;
38
+ id: z.ZodString;
39
+ mergedAt: z.ZodOptional<z.ZodString>;
40
+ number: z.ZodNumber;
41
+ openedAt: z.ZodString;
42
+ provider: z.ZodString;
43
+ repository: z.ZodString;
44
+ state: z.ZodEnum<{
45
+ open: "open";
46
+ closed: "closed";
47
+ merged: "merged";
48
+ }>;
49
+ title: z.ZodOptional<z.ZodString>;
50
+ url: z.ZodOptional<z.ZodString>;
51
+ }, z.core.$strict>>;
52
+ generatedAt: z.ZodString;
53
+ repositories: z.ZodArray<z.ZodObject<{
54
+ closed: z.ZodNumber;
55
+ created: z.ZodNumber;
56
+ id: z.ZodString;
57
+ merged: z.ZodNumber;
58
+ name: z.ZodString;
59
+ open: z.ZodNumber;
60
+ provider: z.ZodString;
61
+ url: z.ZodOptional<z.ZodString>;
62
+ }, z.core.$strict>>;
63
+ summary: z.ZodObject<{
64
+ closed: z.ZodNumber;
65
+ created: z.ZodNumber;
66
+ merged: z.ZodNumber;
67
+ mergeRate: z.ZodOptional<z.ZodNumber>;
68
+ open: z.ZodNumber;
69
+ }, z.core.$strict>;
70
+ windowEnd: z.ZodString;
71
+ windowStart: z.ZodString;
72
+ }, z.core.$strict>;
73
+ export type CodeChangeSummaryReport = z.infer<typeof codeChangeSummaryReportSchema>;
74
+ export type CodeOverviewReport = z.infer<typeof codeOverviewReportSchema>;
75
+ export type CodeRepositorySummary = z.infer<typeof codeRepositorySummarySchema>;
@@ -1,5 +1,7 @@
1
1
  export { dailyConversationActivitySchema } from "./activity";
2
2
  export type { DailyConversationActivity } from "./activity";
3
+ export { codeChangeSummaryReportSchema, codeChangeSummarySchema, codeOverviewReportSchema, codeRepositorySummarySchema, } from "./schema/code";
4
+ export type { CodeChangeSummaryReport, CodeOverviewReport, CodeRepositorySummary, } from "./schema/code";
3
5
  export { acceptedConversationMessageSchema, archiveConversationBodySchema, archiveConversationResponseSchema, cancelConversationPendingMessagesBodySchema, cancelConversationPendingMessagesResponseSchema, conversationAuxiliaryCostsSchema, conversationDetailQuerySchema, conversationDetailReportSchema, conversationEventPageSchema, conversationEventHistorySchema, conversationEventsQuerySchema, conversationFeedQuerySchema, conversationFeedSchema, conversationParamsSchema, conversationPendingAuthorizationSchema, conversationPendingMessageDeliverySchema, conversationPendingMessageSchema, conversationPendingMessagesReportSchema, conversationReportEventDataSchema, conversationReportEventSchema, conversationStatsReportSchema, conversationSummaryReportSchema, createConversationBodySchema, createConversationMessageBodySchema, } from "./schema/conversation";
4
6
  export type { AcceptedConversationMessage, ArchiveConversationBody, ArchiveConversationResponse, CancelConversationPendingMessagesBody, CancelConversationPendingMessagesResponse, ActorIdentity, ConversationAuxiliaryCosts, ConversationCost, ConversationDetailReport, ConversationEventPage, ConversationEventHistory, ConversationFeed, ConversationPendingMessage, ConversationPendingMessageDelivery, ConversationPendingMessagesReport, ConversationReportEvent, ConversationReportEventData, ConversationReportStatus, ConversationMetricDay, ConversationModelUsage, ConversationParams, ConversationSourceTask, ConversationStatsItem, ConversationStatsReport, ConversationSummaryReport, ConversationSurface, ConversationUsage, CreateConversationBody, CreateConversationMessageBody, GuardianMetricDay, GuardianStats, } from "./schema/conversation";
5
7
  export { actorDirectoryReportSchema, actorProfileReportSchema, personalSpendReportSchema, personParamsSchema, } from "./schema/person";
@@ -8,6 +8,10 @@ import {
8
8
  baselineSnapshotSchema,
9
9
  cancelConversationPendingMessagesBodySchema,
10
10
  cancelConversationPendingMessagesResponseSchema,
11
+ codeChangeSummaryReportSchema,
12
+ codeChangeSummarySchema,
13
+ codeOverviewReportSchema,
14
+ codeRepositorySummarySchema,
11
15
  conversationAuxiliaryCostsSchema,
12
16
  conversationDetailQuerySchema,
13
17
  conversationDetailReportSchema,
@@ -59,7 +63,7 @@ import {
59
63
  workspaceParamsSchema,
60
64
  workspaceRepoSchema,
61
65
  workspaceSchema
62
- } from "../chunk-CZYNWPWD.js";
66
+ } from "../chunk-WVIA7V3M.js";
63
67
  import {
64
68
  healthReportSchema,
65
69
  pluginOperationalReportFeedSchema,
@@ -84,6 +88,10 @@ export {
84
88
  baselineSnapshotSchema,
85
89
  cancelConversationPendingMessagesBodySchema,
86
90
  cancelConversationPendingMessagesResponseSchema,
91
+ codeChangeSummaryReportSchema,
92
+ codeChangeSummarySchema,
93
+ codeOverviewReportSchema,
94
+ codeRepositorySummarySchema,
87
95
  conversationAuxiliaryCostsSchema,
88
96
  conversationDetailQuerySchema,
89
97
  conversationDetailReportSchema,