@sentry/junior 0.115.0 → 0.116.1
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/{agent-hooks-4EUUXP2F.js → agent-hooks-GUAAS3XH.js} +9 -9
- package/dist/api/conversations/detail.d.ts +18 -0
- package/dist/api/conversations/event-page.d.ts +1 -1
- package/dist/api/conversations/events.d.ts +1 -1
- package/dist/api/people/profile.d.ts +2 -2
- package/dist/api/people/shared.d.ts +1 -1
- package/dist/api/personal-tokens/create.d.ts +11 -0
- package/dist/api/personal-tokens/list.d.ts +12 -0
- package/dist/api/personal-tokens/revoke.d.ts +5 -0
- package/dist/api/personal-tokens/routes.d.ts +4 -0
- package/dist/api/plugins.d.ts +0 -1
- package/dist/api/route.d.ts +1 -1
- package/dist/api/schema/conversation.d.ts +18 -0
- package/dist/api/schema/person.d.ts +3 -3
- package/dist/api/schema/personal-token.d.ts +38 -0
- package/dist/api/schema.d.ts +2 -0
- package/dist/api/schema.js +15 -3
- package/dist/api.d.ts +1 -0
- package/dist/api.js +179 -39
- package/dist/app.js +1035 -853
- package/dist/{catalog-runtime-Y32UEQLB.js → catalog-runtime-WMPC4J4U.js} +5 -5
- package/dist/chat/agent/request.d.ts +1 -0
- package/dist/chat/agent/resume.d.ts +1 -0
- package/dist/chat/agent/sandbox.d.ts +1 -0
- package/dist/chat/agent/tools.d.ts +1 -0
- package/dist/chat/agent-dispatch/context.d.ts +2 -0
- package/dist/chat/agent-dispatch/heartbeat.d.ts +11 -5
- package/dist/chat/agent-dispatch/signing.d.ts +14 -5
- package/dist/chat/agent-dispatch/store.d.ts +36 -15
- package/dist/chat/agent-dispatch/types.d.ts +23 -10
- package/dist/chat/agent-dispatch/work.d.ts +58 -0
- package/dist/chat/app/factory.d.ts +12 -3
- package/dist/chat/conversations/history.d.ts +285 -290
- package/dist/chat/conversations/projection.d.ts +2 -2
- package/dist/chat/mcp/tool-manager.d.ts +2 -1
- package/dist/chat/pi/conversation-events.d.ts +6 -2
- package/dist/chat/plugins/annotations.d.ts +8 -0
- package/dist/chat/plugins/registry.d.ts +0 -3
- package/dist/chat/plugins/types.d.ts +0 -2
- package/dist/chat/runtime/agent-continue-runner.d.ts +4 -0
- package/dist/chat/runtime/reply-executor.d.ts +6 -1
- package/dist/chat/runtime/slack-resume.d.ts +5 -1
- package/dist/chat/runtime/turn-input.d.ts +3 -0
- package/dist/chat/sandbox/sandbox.d.ts +2 -1
- package/dist/chat/sandbox/session.d.ts +2 -11
- package/dist/chat/sandbox/workspace.d.ts +10 -2
- package/dist/chat/services/turn-session-record.d.ts +14 -1
- package/dist/chat/slack/dispatch-turn.d.ts +25 -0
- package/dist/chat/state/turn-session.d.ts +11 -0
- package/dist/chat/tool-support/text-range-result.d.ts +3 -0
- package/dist/chat/tool-support/zod-tool.d.ts +1 -0
- package/dist/chat/tools/definition.d.ts +3 -10
- package/dist/chat/tools/query-conversation-events.d.ts +68 -0
- package/dist/chat/tools/sandbox/file-utils.d.ts +8 -1
- package/dist/chat/tools/sandbox/find-files.d.ts +2 -1
- package/dist/chat/tools/sandbox/grep.d.ts +2 -1
- package/dist/{chunk-6V762AB4.js → chunk-2YYPXQNQ.js} +1 -1
- package/dist/{chunk-MIAKQNYX.js → chunk-6ZK6FZIV.js} +1 -1
- package/dist/{chunk-67CVNDJ7.js → chunk-7CSVG54J.js} +1 -1
- package/dist/{chunk-HWCQRGLL.js → chunk-BFYVIOTS.js} +105 -37
- package/dist/{chunk-LYA2AB5G.js → chunk-CGXLCMWI.js} +8 -52
- package/dist/{chunk-SYJT7AKB.js → chunk-CY7NXM32.js} +1 -1
- package/dist/{chunk-2QG4MZQ7.js → chunk-DLLW5ITL.js} +2 -2
- package/dist/{chunk-NVUQSFWX.js → chunk-F3SWGSPG.js} +3 -15
- package/dist/{chunk-CWEZEPD4.js → chunk-FAEALXEH.js} +68 -2
- package/dist/{chunk-43RYMWJ2.js → chunk-GDAXWEIJ.js} +809 -213
- package/dist/{chunk-AGLQYELI.js → chunk-H35BDAUS.js} +170 -170
- package/dist/{chunk-YCLO7D7M.js → chunk-JPKGW6L6.js} +77 -26
- package/dist/{chunk-G5SX4UPR.js → chunk-KNCELO2M.js} +2 -2
- package/dist/{chunk-FHC4JUSF.js → chunk-N3C4XCRE.js} +1 -2
- package/dist/{chunk-6FKLPVF3.js → chunk-OY2PQQ4P.js} +1 -1
- package/dist/{chunk-6OPTF4BQ.js → chunk-PE44LDDQ.js} +0 -1
- package/dist/{chunk-JQFJO5WH.js → chunk-RXRQJF7Y.js} +74 -17
- package/dist/{chunk-CEYOL62C.js → chunk-RYFAVWP3.js} +120 -20
- package/dist/{chunk-G36V2YGB.js → chunk-TC4ZEM2D.js} +33 -1
- package/dist/{chunk-PVZHG2XZ.js → chunk-VBMMMVVQ.js} +112 -35
- package/dist/{chunk-SG5WAA7H.js → chunk-WKU7TY22.js} +0 -3
- package/dist/{chunk-TVE25LPW.js → chunk-WLT72MRP.js} +1 -1
- package/dist/{chunk-EW5MLKT5.js → chunk-XA3VLFPK.js} +1 -55
- package/dist/{chunk-RAVKCKXA.js → chunk-ZYHLNTC2.js} +20 -5
- package/dist/cli/chat.js +23 -23
- package/dist/cli/check.js +6 -6
- package/dist/cli/plugins.js +13 -13
- package/dist/cli/snapshot-warmup.js +8 -8
- package/dist/cli/upgrade.js +7 -7
- package/dist/db/schema/api-tokens.d.ts +160 -0
- package/dist/db/schema/conversation-annotations.d.ts +142 -0
- package/dist/db/schema.d.ts +305 -1
- package/dist/{db-KBSJHAZU.js → db-FH4R5ZQ4.js} +6 -6
- package/dist/handlers/agent-dispatch.d.ts +7 -3
- package/dist/instrumentation.js +2 -2
- package/dist/nitro.js +5 -5
- package/dist/{oauth-callback-server-EYRMJTCS.js → oauth-callback-server-C2SSJ3FQ.js} +18 -18
- package/dist/personal-tokens/store.d.ts +27 -0
- package/dist/{plugins-PZMDS7AT.js → plugins-IUJA4VBU.js} +1 -1
- package/dist/reporting-schema.d.ts +0 -2
- package/dist/{runner-RQGZ5Z2S.js → runner-NAALFIXM.js} +12 -12
- package/dist/{skills-JJQIE3BT.js → skills-UN2JXYYF.js} +6 -6
- package/dist/{validation-MZ47PZP5.js → validation-EEF4ROHR.js} +6 -6
- package/dist/version.js +1 -1
- package/migrations/0008_sticky_rage.sql +14 -0
- package/migrations/0009_slippery_harrier.sql +12 -0
- package/migrations/0010_native_conversation_history.sql +142 -0
- package/migrations/meta/0008_snapshot.json +1076 -0
- package/migrations/meta/0009_snapshot.json +1146 -0
- package/migrations/meta/0010_snapshot.json +1190 -0
- package/migrations/meta/_journal.json +22 -1
- package/package.json +5 -6
- package/dist/chat/agent-dispatch/runner.d.ts +0 -13
- package/dist/chat/capabilities/catalog.d.ts +0 -16
- package/dist/{chunk-KNFROR7R.js → chunk-5I6ORJUY.js} +1 -1
|
@@ -1,8 +1,12 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ConversationWorkQueue } from "@/chat/task-execution/queue";
|
|
2
2
|
import type { WaitUntilFn } from "@/handlers/types";
|
|
3
3
|
interface AgentDispatchHandlerOptions {
|
|
4
|
-
|
|
4
|
+
conversationWorkQueue: ConversationWorkQueue;
|
|
5
5
|
}
|
|
6
|
-
/**
|
|
6
|
+
/**
|
|
7
|
+
* Convert a legacy authenticated dispatch callback into conversation work.
|
|
8
|
+
*
|
|
9
|
+
* TODO(v0.116.0): Remove with the v0.114 callback verification route.
|
|
10
|
+
*/
|
|
7
11
|
export declare function POST(request: Request, waitUntil: WaitUntilFn, options: AgentDispatchHandlerOptions): Promise<Response>;
|
|
8
12
|
export {};
|
package/dist/instrumentation.js
CHANGED
|
@@ -16,8 +16,8 @@ import {
|
|
|
16
16
|
import {
|
|
17
17
|
getDeploymentServiceVersion,
|
|
18
18
|
getDeploymentTelemetryAttributes
|
|
19
|
-
} from "./chunk-
|
|
20
|
-
import "./chunk-
|
|
19
|
+
} from "./chunk-WLT72MRP.js";
|
|
20
|
+
import "./chunk-N3C4XCRE.js";
|
|
21
21
|
import "./chunk-MLKGABMK.js";
|
|
22
22
|
|
|
23
23
|
// src/chat/sentry-payload-filter.ts
|
package/dist/nitro.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import {
|
|
2
2
|
resolveConversationWorkQueueTopic
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-6ZK6FZIV.js";
|
|
4
4
|
import {
|
|
5
5
|
PLUGIN_TASK_QUEUE_TOPIC
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-5I6ORJUY.js";
|
|
7
7
|
import {
|
|
8
8
|
pluginCatalogConfigFromPluginSet,
|
|
9
9
|
pluginRuntimeRegistrationsFromPluginSet
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-WKU7TY22.js";
|
|
11
11
|
import {
|
|
12
12
|
loadPluginSetFromModule,
|
|
13
13
|
resolvePluginModule
|
|
@@ -25,8 +25,8 @@ import {
|
|
|
25
25
|
JUNIOR_PLUGIN_TASK_CALLBACK_ROUTE,
|
|
26
26
|
JUNIOR_RETENTION_CRON_SCHEDULE,
|
|
27
27
|
JUNIOR_RETENTION_ROUTE
|
|
28
|
-
} from "./chunk-
|
|
29
|
-
import "./chunk-
|
|
28
|
+
} from "./chunk-WLT72MRP.js";
|
|
29
|
+
import "./chunk-N3C4XCRE.js";
|
|
30
30
|
import "./chunk-MLKGABMK.js";
|
|
31
31
|
|
|
32
32
|
// src/nitro.ts
|
|
@@ -2,40 +2,40 @@ import {
|
|
|
2
2
|
GET,
|
|
3
3
|
GET2,
|
|
4
4
|
syncLocalOAuthCredential
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-JPKGW6L6.js";
|
|
6
6
|
import "./chunk-FA6POGLH.js";
|
|
7
|
-
import "./chunk-
|
|
7
|
+
import "./chunk-H35BDAUS.js";
|
|
8
8
|
import "./chunk-4CODA7P5.js";
|
|
9
|
-
import "./chunk-
|
|
10
|
-
import "./chunk-
|
|
9
|
+
import "./chunk-6ZK6FZIV.js";
|
|
10
|
+
import "./chunk-5I6ORJUY.js";
|
|
11
11
|
import {
|
|
12
12
|
createUserTokenStore
|
|
13
|
-
} from "./chunk-
|
|
14
|
-
import "./chunk-
|
|
13
|
+
} from "./chunk-CGXLCMWI.js";
|
|
14
|
+
import "./chunk-RYFAVWP3.js";
|
|
15
15
|
import "./chunk-MU6HHZEN.js";
|
|
16
16
|
import "./chunk-PDO5BLNM.js";
|
|
17
|
-
import "./chunk-
|
|
18
|
-
import "./chunk-
|
|
19
|
-
import "./chunk-
|
|
20
|
-
import "./chunk-
|
|
21
|
-
import "./chunk-
|
|
17
|
+
import "./chunk-ZYHLNTC2.js";
|
|
18
|
+
import "./chunk-7CSVG54J.js";
|
|
19
|
+
import "./chunk-FAEALXEH.js";
|
|
20
|
+
import "./chunk-BFYVIOTS.js";
|
|
21
|
+
import "./chunk-RXRQJF7Y.js";
|
|
22
22
|
import "./chunk-4ZNGQH7C.js";
|
|
23
|
-
import "./chunk-
|
|
23
|
+
import "./chunk-CY7NXM32.js";
|
|
24
24
|
import "./chunk-VFUK3X5B.js";
|
|
25
25
|
import "./chunk-FXOYURO4.js";
|
|
26
|
-
import "./chunk-
|
|
27
|
-
import "./chunk-
|
|
28
|
-
import "./chunk-
|
|
26
|
+
import "./chunk-DLLW5ITL.js";
|
|
27
|
+
import "./chunk-OY2PQQ4P.js";
|
|
28
|
+
import "./chunk-XA3VLFPK.js";
|
|
29
29
|
import "./chunk-W3U3YQYI.js";
|
|
30
30
|
import "./chunk-HZF5P5UN.js";
|
|
31
|
-
import "./chunk-
|
|
31
|
+
import "./chunk-F3SWGSPG.js";
|
|
32
32
|
import "./chunk-OB42YVAE.js";
|
|
33
33
|
import "./chunk-F3B2YJ76.js";
|
|
34
34
|
import "./chunk-6GWA276C.js";
|
|
35
35
|
import "./chunk-B3IT5END.js";
|
|
36
36
|
import "./chunk-3V7OFJZC.js";
|
|
37
|
-
import "./chunk-
|
|
38
|
-
import "./chunk-
|
|
37
|
+
import "./chunk-WLT72MRP.js";
|
|
38
|
+
import "./chunk-N3C4XCRE.js";
|
|
39
39
|
import "./chunk-MLKGABMK.js";
|
|
40
40
|
|
|
41
41
|
// src/chat/local/oauth-callback-server.ts
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export interface PersonalTokenMetadata {
|
|
2
|
+
id: string;
|
|
3
|
+
name: string;
|
|
4
|
+
tokenSuffix: string;
|
|
5
|
+
createdAt: string;
|
|
6
|
+
expiresAt: string;
|
|
7
|
+
lastUsedAt: string | null;
|
|
8
|
+
}
|
|
9
|
+
export interface CreatedPersonalToken extends PersonalTokenMetadata {
|
|
10
|
+
token: string;
|
|
11
|
+
}
|
|
12
|
+
/** Create a personal token and return its plaintext value exactly once. */
|
|
13
|
+
export declare function createPersonalToken(args: {
|
|
14
|
+
email: string;
|
|
15
|
+
name: string;
|
|
16
|
+
now?: Date;
|
|
17
|
+
}): Promise<CreatedPersonalToken>;
|
|
18
|
+
/** List active personal tokens owned by one verified user. */
|
|
19
|
+
export declare function listPersonalTokens(email: string, now?: Date): Promise<PersonalTokenMetadata[]>;
|
|
20
|
+
/** Revoke a personal token owned by one verified user. */
|
|
21
|
+
export declare function revokePersonalToken(args: {
|
|
22
|
+
email: string;
|
|
23
|
+
id: string;
|
|
24
|
+
now?: Date;
|
|
25
|
+
}): Promise<boolean>;
|
|
26
|
+
/** Resolve an active personal bearer token to its verified owner email. */
|
|
27
|
+
export declare function authenticatePersonalToken(token: string, now?: Date): Promise<string | undefined>;
|
|
@@ -5,14 +5,12 @@ export declare const healthReportSchema: z.ZodObject<{
|
|
|
5
5
|
timestamp: z.ZodString;
|
|
6
6
|
}, z.core.$strict>;
|
|
7
7
|
export declare const pluginSchema: z.ZodObject<{
|
|
8
|
-
capabilities: z.ZodArray<z.ZodString>;
|
|
9
8
|
configKeys: z.ZodArray<z.ZodString>;
|
|
10
9
|
description: z.ZodString;
|
|
11
10
|
displayName: z.ZodString;
|
|
12
11
|
name: z.ZodString;
|
|
13
12
|
}, z.core.$strict>;
|
|
14
13
|
export declare const pluginsSchema: z.ZodArray<z.ZodObject<{
|
|
15
|
-
capabilities: z.ZodArray<z.ZodString>;
|
|
16
14
|
configKeys: z.ZodArray<z.ZodString>;
|
|
17
15
|
description: z.ZodString;
|
|
18
16
|
displayName: z.ZodString;
|
|
@@ -5,8 +5,8 @@ import {
|
|
|
5
5
|
finalizeFailedTurnReplyWithEvent,
|
|
6
6
|
processPluginTask,
|
|
7
7
|
scheduleSessionCompletedPluginTasks
|
|
8
|
-
} from "./chunk-
|
|
9
|
-
import "./chunk-
|
|
8
|
+
} from "./chunk-H35BDAUS.js";
|
|
9
|
+
import "./chunk-5I6ORJUY.js";
|
|
10
10
|
import {
|
|
11
11
|
authorizationId
|
|
12
12
|
} from "./chunk-DIB4GX3G.js";
|
|
@@ -32,29 +32,29 @@ import {
|
|
|
32
32
|
trimTrailingAssistantMessages,
|
|
33
33
|
updateConversationStats,
|
|
34
34
|
upsertConversationMessage
|
|
35
|
-
} from "./chunk-
|
|
35
|
+
} from "./chunk-RYFAVWP3.js";
|
|
36
36
|
import "./chunk-MU6HHZEN.js";
|
|
37
37
|
import "./chunk-PDO5BLNM.js";
|
|
38
|
-
import "./chunk-
|
|
39
|
-
import "./chunk-
|
|
40
|
-
import "./chunk-
|
|
38
|
+
import "./chunk-ZYHLNTC2.js";
|
|
39
|
+
import "./chunk-7CSVG54J.js";
|
|
40
|
+
import "./chunk-FAEALXEH.js";
|
|
41
41
|
import {
|
|
42
42
|
getConversationEventStore
|
|
43
|
-
} from "./chunk-
|
|
44
|
-
import "./chunk-
|
|
43
|
+
} from "./chunk-BFYVIOTS.js";
|
|
44
|
+
import "./chunk-RXRQJF7Y.js";
|
|
45
45
|
import "./chunk-4ZNGQH7C.js";
|
|
46
|
-
import "./chunk-
|
|
46
|
+
import "./chunk-CY7NXM32.js";
|
|
47
47
|
import "./chunk-VFUK3X5B.js";
|
|
48
48
|
import "./chunk-FXOYURO4.js";
|
|
49
49
|
import "./chunk-HZF5P5UN.js";
|
|
50
50
|
import {
|
|
51
51
|
logException
|
|
52
|
-
} from "./chunk-
|
|
52
|
+
} from "./chunk-F3SWGSPG.js";
|
|
53
53
|
import "./chunk-OB42YVAE.js";
|
|
54
54
|
import "./chunk-F3B2YJ76.js";
|
|
55
55
|
import "./chunk-6GWA276C.js";
|
|
56
|
-
import "./chunk-
|
|
57
|
-
import "./chunk-
|
|
56
|
+
import "./chunk-WLT72MRP.js";
|
|
57
|
+
import "./chunk-N3C4XCRE.js";
|
|
58
58
|
import "./chunk-MLKGABMK.js";
|
|
59
59
|
|
|
60
60
|
// src/chat/local/runner.ts
|
|
@@ -6,19 +6,19 @@ import {
|
|
|
6
6
|
parseSkillInvocation,
|
|
7
7
|
resetSkillDiscoveryCache,
|
|
8
8
|
stripFrontmatter
|
|
9
|
-
} from "./chunk-
|
|
10
|
-
import "./chunk-
|
|
11
|
-
import "./chunk-
|
|
9
|
+
} from "./chunk-DLLW5ITL.js";
|
|
10
|
+
import "./chunk-OY2PQQ4P.js";
|
|
11
|
+
import "./chunk-XA3VLFPK.js";
|
|
12
12
|
import "./chunk-W3U3YQYI.js";
|
|
13
13
|
import "./chunk-HZF5P5UN.js";
|
|
14
|
-
import "./chunk-
|
|
14
|
+
import "./chunk-F3SWGSPG.js";
|
|
15
15
|
import "./chunk-OB42YVAE.js";
|
|
16
16
|
import "./chunk-F3B2YJ76.js";
|
|
17
17
|
import "./chunk-6GWA276C.js";
|
|
18
18
|
import "./chunk-B3IT5END.js";
|
|
19
19
|
import "./chunk-3V7OFJZC.js";
|
|
20
|
-
import "./chunk-
|
|
21
|
-
import "./chunk-
|
|
20
|
+
import "./chunk-WLT72MRP.js";
|
|
21
|
+
import "./chunk-N3C4XCRE.js";
|
|
22
22
|
import "./chunk-MLKGABMK.js";
|
|
23
23
|
export {
|
|
24
24
|
discoverSkills,
|
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
import {
|
|
2
2
|
validatePluginEgressCredentialHooks,
|
|
3
3
|
validatePluginRegistrations
|
|
4
|
-
} from "./chunk-
|
|
5
|
-
import "./chunk-
|
|
6
|
-
import "./chunk-
|
|
4
|
+
} from "./chunk-2YYPXQNQ.js";
|
|
5
|
+
import "./chunk-OY2PQQ4P.js";
|
|
6
|
+
import "./chunk-XA3VLFPK.js";
|
|
7
7
|
import "./chunk-W3U3YQYI.js";
|
|
8
8
|
import "./chunk-HZF5P5UN.js";
|
|
9
|
-
import "./chunk-
|
|
9
|
+
import "./chunk-F3SWGSPG.js";
|
|
10
10
|
import "./chunk-OB42YVAE.js";
|
|
11
11
|
import "./chunk-F3B2YJ76.js";
|
|
12
12
|
import "./chunk-6GWA276C.js";
|
|
13
13
|
import "./chunk-B3IT5END.js";
|
|
14
14
|
import "./chunk-3V7OFJZC.js";
|
|
15
|
-
import "./chunk-
|
|
16
|
-
import "./chunk-
|
|
15
|
+
import "./chunk-WLT72MRP.js";
|
|
16
|
+
import "./chunk-N3C4XCRE.js";
|
|
17
17
|
import "./chunk-MLKGABMK.js";
|
|
18
18
|
export {
|
|
19
19
|
validatePluginEgressCredentialHooks,
|
package/dist/version.js
CHANGED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
CREATE TABLE "junior_api_tokens" (
|
|
2
|
+
"id" text PRIMARY KEY NOT NULL,
|
|
3
|
+
"owner_email_normalized" text NOT NULL,
|
|
4
|
+
"name" text NOT NULL,
|
|
5
|
+
"token_hash" text NOT NULL,
|
|
6
|
+
"token_suffix" text NOT NULL,
|
|
7
|
+
"created_at" timestamp with time zone NOT NULL,
|
|
8
|
+
"expires_at" timestamp with time zone NOT NULL,
|
|
9
|
+
"last_used_at" timestamp with time zone,
|
|
10
|
+
"revoked_at" timestamp with time zone
|
|
11
|
+
);
|
|
12
|
+
--> statement-breakpoint
|
|
13
|
+
CREATE UNIQUE INDEX "junior_api_tokens_token_hash_uidx" ON "junior_api_tokens" USING btree ("token_hash");--> statement-breakpoint
|
|
14
|
+
CREATE INDEX "junior_api_tokens_owner_email_idx" ON "junior_api_tokens" USING btree ("owner_email_normalized");
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
CREATE TABLE "junior_conversation_annotations" (
|
|
2
|
+
"conversation_id" text NOT NULL,
|
|
3
|
+
"plugin" text NOT NULL,
|
|
4
|
+
"kind" text NOT NULL,
|
|
5
|
+
"key" text NOT NULL,
|
|
6
|
+
"annotation_json" jsonb NOT NULL,
|
|
7
|
+
"created_at" timestamp with time zone NOT NULL,
|
|
8
|
+
"updated_at" timestamp with time zone NOT NULL,
|
|
9
|
+
CONSTRAINT "junior_conversation_annotations_pk" PRIMARY KEY("conversation_id","plugin","kind","key")
|
|
10
|
+
);
|
|
11
|
+
--> statement-breakpoint
|
|
12
|
+
ALTER TABLE "junior_conversation_annotations" ADD CONSTRAINT "junior_conversation_annotations_conversation_id_fk" FOREIGN KEY ("conversation_id") REFERENCES "public"."junior_conversations"("conversation_id") ON DELETE cascade ON UPDATE no action;
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
DO $$
|
|
2
|
+
BEGIN
|
|
3
|
+
IF EXISTS (
|
|
4
|
+
SELECT 1
|
|
5
|
+
FROM "junior_conversation_events"
|
|
6
|
+
WHERE "schema_version" = 1
|
|
7
|
+
AND "type" = 'agent_step'
|
|
8
|
+
AND (
|
|
9
|
+
jsonb_typeof("payload") IS DISTINCT FROM 'object'
|
|
10
|
+
OR jsonb_typeof("payload"->'message') IS DISTINCT FROM 'object'
|
|
11
|
+
OR "payload"->'message'->>'role' IS NULL
|
|
12
|
+
OR "payload"->'message'->>'role' NOT IN ('user', 'assistant', 'toolResult')
|
|
13
|
+
)
|
|
14
|
+
) THEN
|
|
15
|
+
RAISE EXCEPTION 'Cannot migrate malformed agent_step conversation events';
|
|
16
|
+
END IF;
|
|
17
|
+
|
|
18
|
+
IF EXISTS (
|
|
19
|
+
SELECT 1
|
|
20
|
+
FROM "junior_conversation_events" AS "event"
|
|
21
|
+
WHERE "event"."schema_version" = 1
|
|
22
|
+
AND "event"."type" IN ('compaction', 'handoff', 'rollback')
|
|
23
|
+
AND (
|
|
24
|
+
jsonb_typeof("event"."payload") IS DISTINCT FROM 'object'
|
|
25
|
+
OR jsonb_typeof("event"."payload"->'replacementHistory') IS DISTINCT FROM 'array'
|
|
26
|
+
)
|
|
27
|
+
) THEN
|
|
28
|
+
RAISE EXCEPTION 'Cannot migrate malformed conversation history replacements';
|
|
29
|
+
END IF;
|
|
30
|
+
|
|
31
|
+
IF EXISTS (
|
|
32
|
+
SELECT 1
|
|
33
|
+
FROM "junior_conversation_events" AS "event"
|
|
34
|
+
CROSS JOIN LATERAL jsonb_array_elements(
|
|
35
|
+
"event"."payload"->'replacementHistory'
|
|
36
|
+
) AS "replacement"("item")
|
|
37
|
+
WHERE "event"."schema_version" = 1
|
|
38
|
+
AND "event"."type" IN ('compaction', 'handoff', 'rollback')
|
|
39
|
+
AND (
|
|
40
|
+
jsonb_typeof("replacement"."item") IS DISTINCT FROM 'object'
|
|
41
|
+
OR (
|
|
42
|
+
"replacement"."item" ? 'message'
|
|
43
|
+
AND (
|
|
44
|
+
jsonb_typeof("replacement"."item"->'message') IS DISTINCT FROM 'object'
|
|
45
|
+
OR "replacement"."item"->'message'->>'role' IS NULL
|
|
46
|
+
OR "replacement"."item"->'message'->>'role' NOT IN ('user', 'assistant', 'toolResult')
|
|
47
|
+
)
|
|
48
|
+
)
|
|
49
|
+
OR (
|
|
50
|
+
NOT ("replacement"."item" ? 'message')
|
|
51
|
+
AND (
|
|
52
|
+
jsonb_typeof("replacement"."item"->'item') IS DISTINCT FROM 'object'
|
|
53
|
+
OR "replacement"."item"->'item'->>'type' IS NULL
|
|
54
|
+
OR "replacement"."item"->'item'->>'type' NOT IN ('user_message', 'assistant_message', 'tool_result')
|
|
55
|
+
OR "replacement"."item"->'item' ? 'role'
|
|
56
|
+
OR (
|
|
57
|
+
"replacement"."item"->'item'->>'type' = 'user_message'
|
|
58
|
+
AND jsonb_typeof("replacement"."item"->'item'->'provenance') IS DISTINCT FROM 'object'
|
|
59
|
+
)
|
|
60
|
+
)
|
|
61
|
+
)
|
|
62
|
+
)
|
|
63
|
+
) THEN
|
|
64
|
+
RAISE EXCEPTION 'Cannot migrate malformed replacement history items';
|
|
65
|
+
END IF;
|
|
66
|
+
END $$;
|
|
67
|
+
--> statement-breakpoint
|
|
68
|
+
UPDATE "junior_conversation_events"
|
|
69
|
+
SET
|
|
70
|
+
"type" = CASE "payload"->'message'->>'role'
|
|
71
|
+
WHEN 'user' THEN 'user_message'
|
|
72
|
+
WHEN 'assistant' THEN 'assistant_message'
|
|
73
|
+
WHEN 'toolResult' THEN 'tool_result'
|
|
74
|
+
END,
|
|
75
|
+
"payload" = CASE "payload"->'message'->>'role'
|
|
76
|
+
WHEN 'user' THEN
|
|
77
|
+
(("payload"->'message') - 'role')
|
|
78
|
+
|| jsonb_build_object(
|
|
79
|
+
'provenance',
|
|
80
|
+
coalesce("payload"->'provenance', '{"authority":"context"}'::jsonb)
|
|
81
|
+
)
|
|
82
|
+
ELSE ("payload"->'message') - 'role'
|
|
83
|
+
END
|
|
84
|
+
WHERE "schema_version" = 1
|
|
85
|
+
AND "type" = 'agent_step';
|
|
86
|
+
--> statement-breakpoint
|
|
87
|
+
UPDATE "junior_conversation_events" AS "event"
|
|
88
|
+
SET "payload" = jsonb_set(
|
|
89
|
+
"event"."payload",
|
|
90
|
+
'{replacementHistory}',
|
|
91
|
+
(
|
|
92
|
+
SELECT coalesce(
|
|
93
|
+
jsonb_agg(
|
|
94
|
+
CASE
|
|
95
|
+
WHEN "replacement"."item" ? 'message' THEN
|
|
96
|
+
(("replacement"."item" - 'message') - 'provenance')
|
|
97
|
+
|| jsonb_build_object(
|
|
98
|
+
'item',
|
|
99
|
+
CASE "replacement"."item"->'message'->>'role'
|
|
100
|
+
WHEN 'user' THEN
|
|
101
|
+
(("replacement"."item"->'message') - 'role')
|
|
102
|
+
|| jsonb_build_object('type', 'user_message')
|
|
103
|
+
|| jsonb_build_object(
|
|
104
|
+
'provenance',
|
|
105
|
+
coalesce(
|
|
106
|
+
"replacement"."item"->'provenance',
|
|
107
|
+
'{"authority":"context"}'::jsonb
|
|
108
|
+
)
|
|
109
|
+
)
|
|
110
|
+
WHEN 'assistant' THEN
|
|
111
|
+
(("replacement"."item"->'message') - 'role')
|
|
112
|
+
|| jsonb_build_object('type', 'assistant_message')
|
|
113
|
+
WHEN 'toolResult' THEN
|
|
114
|
+
(("replacement"."item"->'message') - 'role')
|
|
115
|
+
|| jsonb_build_object('type', 'tool_result')
|
|
116
|
+
END
|
|
117
|
+
)
|
|
118
|
+
ELSE "replacement"."item"
|
|
119
|
+
END
|
|
120
|
+
ORDER BY "replacement"."position"
|
|
121
|
+
),
|
|
122
|
+
'[]'::jsonb
|
|
123
|
+
)
|
|
124
|
+
FROM jsonb_array_elements(
|
|
125
|
+
"event"."payload"->'replacementHistory'
|
|
126
|
+
) WITH ORDINALITY AS "replacement"("item", "position")
|
|
127
|
+
)
|
|
128
|
+
)
|
|
129
|
+
WHERE "event"."schema_version" = 1
|
|
130
|
+
AND "event"."type" IN ('compaction', 'handoff', 'rollback')
|
|
131
|
+
AND EXISTS (
|
|
132
|
+
SELECT 1
|
|
133
|
+
FROM jsonb_array_elements(
|
|
134
|
+
"event"."payload"->'replacementHistory'
|
|
135
|
+
) AS "replacement"("item")
|
|
136
|
+
WHERE "replacement"."item" ? 'message'
|
|
137
|
+
);
|
|
138
|
+
--> statement-breakpoint
|
|
139
|
+
UPDATE "junior_conversation_events"
|
|
140
|
+
SET "type" = 'compaction'
|
|
141
|
+
WHERE "schema_version" = 1
|
|
142
|
+
AND "type" = 'rollback';
|