@sentry/junior 0.305.0 → 0.307.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/{adapter-context-BpvbUki8.js → adapter-context-B69WPn6b.js} +2 -2
  2. package/dist/{admin-CoDt35ny.js → admin-nCJXMgkp.js} +2 -2
  3. package/dist/{agent-runner-C5d6rY5g.js → agent-runner-DdFcxAxG.js} +463 -303
  4. package/dist/api/schema.d.ts +2 -2
  5. package/dist/api/schema.js +7 -8
  6. package/dist/api.d.ts +19 -4
  7. package/dist/api.js +437 -310
  8. package/dist/{app-Cs157Zc5.d.ts → app-EZur8cVC.d.ts} +12 -3
  9. package/dist/app.d.ts +2 -2
  10. package/dist/app.js +532 -439
  11. package/dist/background-compaction-queue-BhEe4UfU.js +231 -0
  12. package/dist/{briefs-BRdznF7c.js → briefs-Dl9lxi7J.js} +3 -3
  13. package/dist/{catalog-runtime-J52Tej47.js → catalog-runtime-OXrv2Ewn.js} +1 -1
  14. package/dist/cli/chat.d.ts +1 -1
  15. package/dist/cli/chat.js +17 -16
  16. package/dist/cli/check.js +58 -48
  17. package/dist/cli/main.js +3 -3
  18. package/dist/cli/plugins.d.ts +1 -1
  19. package/dist/cli/plugins.js +4 -4
  20. package/dist/cli/snapshot-create.js +5 -5
  21. package/dist/cli/upgrade.d.ts +2 -2
  22. package/dist/cli/upgrade.js +3 -8
  23. package/dist/{config-CBZp0udd.js → config-362yMSIz.js} +183 -49
  24. package/dist/{connections-BYmuJ6Vm.js → connections-BJv3EjmB.js} +10 -8
  25. package/dist/{continue-in-slack-Cvot6S38.js → continue-in-slack-CFEevC7z.js} +5 -5
  26. package/dist/{conversation-BOqdRtUx.js → conversation--f85g4zL.js} +132 -132
  27. package/dist/{conversation-feed-CgpgP7yi.js → conversation-feed-BNs9KiqC.js} +1 -1
  28. package/dist/{conversation-privacy-D2pOzBNl.js → conversation-privacy-Tjj5P2W6.js} +1 -1
  29. package/dist/{conversation-turn-CI8WDpnK.js → conversation-turn-DU0_WDAr.js} +26 -72
  30. package/dist/{credential-sync-COqnZ1Dx.js → credential-sync-D6aFARKE.js} +28 -27
  31. package/dist/{db-DU84dCVu.js → db-Bcbd9zQc.js} +226 -18
  32. package/dist/{db-zbN5ZV_o.d.ts → db-C41UgdBj.d.ts} +1 -1
  33. package/dist/{executor-CFyrgOu1.js → executor-DBMBrpNV.js} +137 -33
  34. package/dist/{history-m2-ceTTX.js → history-N7IVbUom.js} +5 -1
  35. package/dist/{install-CQ76CfRw.js → install-CgoAbzfF.js} +2 -2
  36. package/dist/instrumentation.js +2 -2
  37. package/dist/{lineage-DLd2UxVP.js → lineage-CsZDmz3e.js} +2 -2
  38. package/dist/{logging-BPNTQVFu.js → logging-CHCuQ5iz.js} +1 -1
  39. package/dist/{message-BWJLeQ5e.js → message-B8vCbZZB.js} +8 -8
  40. package/dist/{model-input-DoM9Ht-d.js → model-input-Xluiy-1W.js} +3 -3
  41. package/dist/nitro.d.ts +2 -2
  42. package/dist/nitro.js +3 -4
  43. package/dist/{oauth-callback-server-DeHbnAQl.js → oauth-callback-server-BUuNvfvu.js} +2 -2
  44. package/dist/{oauth-relay-DAmfVmJu.js → oauth-relay-DGAZzg9m.js} +1 -1
  45. package/dist/{plugins-B_0Cr0MO.d.ts → plugins-fBrz8PCV.d.ts} +2 -0
  46. package/dist/{projection-CcFBVFUo.js → projection-xPpvqexa.js} +13423 -11432
  47. package/dist/{prompt-C5LREK2p.js → prompt-D8u4jFs_.js} +15 -7
  48. package/dist/{registry-BjZZqKqi.js → registry-D20hG3r6.js} +19 -9
  49. package/dist/{resolve-CeJgXuH1.js → resolve-BhCySRCW.js} +3 -3
  50. package/dist/{result-icDrueyB.js → result-DddO63S9.js} +13 -11
  51. package/dist/{runner-nVfMkMMB.js → runner-DQR9vYce.js} +13 -15
  52. package/dist/{sandbox-egress-signals-H9vQ5qRf.js → sandbox-egress-signals-DFlNUOnK.js} +1 -1
  53. package/dist/{automation-CuA3yEcD.js → schedule-BG1tEbRF.js} +380 -8
  54. package/dist/{schema-CKcu-IK6.d.ts → schema-CRXcj4fj.d.ts} +420 -143
  55. package/dist/{schema-Bx0Mlo32.js → schema-D4jdesIu.js} +62 -8
  56. package/dist/{service-account-DU5865XA.js → service-account-Bv5QwrEq.js} +8 -6
  57. package/dist/{service-account-Dw06p3zm.js → service-account-CNfycv0z.js} +3 -3
  58. package/dist/{session-stop-uotLtp4g.js → session-stop-BDdwyZaa.js} +878 -171
  59. package/dist/{skills-Bex1EaO5.js → skills-63i1Bcv1.js} +32 -28
  60. package/dist/{slack-conversation-unfurl-EPG3riWF.js → slack-conversation-unfurl-DtpBUlUu.js} +10 -9
  61. package/dist/{spawn-CoD3vDuS.js → spawn-mwimEY9_.js} +6 -6
  62. package/dist/{state-nCR4Muhn.js → state-BBn9L6gC.js} +4 -4
  63. package/dist/{stop-BFVd0P0m.js → stop-Da-Ug7tg.js} +172 -239
  64. package/dist/{store-Ca6G962n.js → store-CdWg2r2L.js} +5 -5
  65. package/dist/{background-compaction-queue-BTqMIfTA.js → task-queue-BcjAYWyB.js} +164 -180
  66. package/dist/{task-runner-xsOPIxCZ.js → task-runner-CoXmMlsW.js} +13 -11
  67. package/dist/{thread-context-BOvZhsKK.js → thread-context-ZPGqOjW7.js} +8 -91
  68. package/dist/turn-session-routing-DFYak28Q.js +263 -0
  69. package/dist/{turn-user-message-BrhuyYrH.js → turn-user-message-B1S8nOnG.js} +3 -3
  70. package/dist/users-DDbENg-I.js +181 -0
  71. package/dist/{validation-BnY9K5WB.js → validation-fl21ps-k.js} +1 -1
  72. package/dist/{version-qROlRQGF.js → version-DCdMMx_0.js} +1 -1
  73. package/dist/version.js +1 -1
  74. package/dist/{viewer-CxUiOraX.js → viewer-DN_xzVKj.js} +3 -3
  75. package/dist/{warmup--Gkz7iB-.js → warmup-CxhEhm71.js} +842 -532
  76. package/dist/{web-message-id-lNodcCOI.js → web-message-id-BT8Mg8LL.js} +16 -1
  77. package/dist/{worker-DJ8d9fmD.js → worker-Btb1SB5h.js} +8 -7
  78. package/migrations/0114_plan_items.sql +22 -0
  79. package/migrations/0115_automation_creator_slack_index.sql +1 -0
  80. package/migrations/0116_conversation_event_search.sql +25 -0
  81. package/migrations/0117_automation_last_run.sql +46 -0
  82. package/migrations/0118_automation_last_run_index.sql +1 -0
  83. package/migrations/0119_money_micro_usd.sql +29 -0
  84. package/migrations/0120_conversation_cost_micro_usd.sql +8 -0
  85. package/migrations/meta/0114_snapshot.json +5203 -0
  86. package/migrations/meta/0115_snapshot.json +5225 -0
  87. package/migrations/meta/0116_snapshot.json +5388 -0
  88. package/migrations/meta/0117_snapshot.json +5413 -0
  89. package/migrations/meta/0118_snapshot.json +5428 -0
  90. package/migrations/meta/0119_snapshot.json +5441 -0
  91. package/migrations/meta/0120_snapshot.json +5441 -0
  92. package/migrations/meta/_journal.json +49 -0
  93. package/package.json +10 -9
  94. package/dist/queue-B2AAL3ym.js +0 -115
  95. package/dist/schedule-cP0AACm1.js +0 -344
  96. package/dist/secrets-DHaJ5TTn.js +0 -18
  97. package/dist/task-queue-BLPZU6kC.js +0 -89
  98. package/dist/turn-session-routing-2bW2qfeb.js +0 -1792
@@ -146,6 +146,21 @@ const AGENT_MESSAGE_EVENT_TYPE = "agent.message";
146
146
  * invocation names.
147
147
  */
148
148
  const AGENT_PARENT_MESSAGE_EVENT_TYPE = "agent.parent_message";
149
+ // src/chat/plan/types.ts
150
+ /** Statuses of a Plan item. `done` and `cancelled` close it. */
151
+ const PLAN_ITEM_STATUSES = [
152
+ "pending",
153
+ "in_progress",
154
+ "blocked",
155
+ "done",
156
+ "cancelled"
157
+ ];
158
+ /** Whether an item with this status is still work to do. */
159
+ function isOpenPlanItemStatus(status) {
160
+ return status !== "done" && status !== "cancelled";
161
+ }
162
+ /** Assignee text for the plan's own agent, in tool results and blocks. */
163
+ const SELF_PLAN_ASSIGNEE = "self";
149
164
  // src/api/schema/user-customization.ts
150
165
  /** Longest customization text one user can save. */
151
166
  const USER_CUSTOMIZATION_MAX_CHARS = 1e3;
@@ -400,4 +415,4 @@ async function webMessageId(args) {
400
415
  const digest = await crypto.subtle.digest("SHA-256", new TextEncoder().encode(`${args.conversationId}\u0000${args.idempotencyKey}`));
401
416
  return `api-msg:${Array.from(new Uint8Array(digest), (byte) => byte.toString(16).padStart(2, "0")).join("").slice(0, 24)}`;
402
417
  }
403
- export { fillUtcSixHours as A, agentInvocationResultEventType as C, HOUR_MS as D, DAY_MS as E, trailingUtcSixHourWindow as F, utcDayKey as I, utcHourKey as L, sumUtcHoursIntoSixHours as M, trailingUtcDayWindow as N, fillUtcDays as O, trailingUtcHourWindow as P, AGENT_REPLY_EVENT_TYPE as S, apiErrorSchema as T, userCustomizationSchema as _, USER_INPUT_LIMITS as a, AGENT_MESSAGE_EVENT_TYPE as b, formatUserInputAnswer as c, userInputRequestSchema as d, INLINE_VIDEO_TYPES as f, USER_CUSTOMIZATION_MAX_CHARS as g, isVisionImageMediaType as h, AGENT_INVOCATION_STATUSES as i, startOfUtcHour as j, fillUtcHours as k, isEmptyUserInputAnswer as l, detectImageMediaType as m, AGENT_INVOCATION_MAILBOX_STATUSES as n, USER_INPUT_NOTE as o, INPUT_IMAGE_TYPES as p, AGENT_INVOCATION_PARENT_MAILBOX_STATUSES as r, buttonUserInputField as s, webMessageId as t, normalizeUserInputAnswer as u, userCustomizationTextSchema as v, isAgentInvocationResultEventType as w, AGENT_PARENT_MESSAGE_EVENT_TYPE as x, AGENT_INVOCATION_EVENT_NAMESPACE as y };
418
+ export { HOUR_MS as A, AGENT_MESSAGE_EVENT_TYPE as C, isAgentInvocationResultEventType as D, agentInvocationResultEventType as E, sumUtcHoursIntoSixHours as F, trailingUtcDayWindow as I, trailingUtcHourWindow as L, fillUtcHours as M, fillUtcSixHours as N, apiErrorSchema as O, startOfUtcHour as P, trailingUtcSixHourWindow as R, AGENT_INVOCATION_EVENT_NAMESPACE as S, AGENT_REPLY_EVENT_TYPE as T, userCustomizationSchema as _, USER_INPUT_LIMITS as a, SELF_PLAN_ASSIGNEE as b, formatUserInputAnswer as c, userInputRequestSchema as d, INLINE_VIDEO_TYPES as f, USER_CUSTOMIZATION_MAX_CHARS as g, isVisionImageMediaType as h, AGENT_INVOCATION_STATUSES as i, fillUtcDays as j, DAY_MS as k, isEmptyUserInputAnswer as l, detectImageMediaType as m, AGENT_INVOCATION_MAILBOX_STATUSES as n, USER_INPUT_NOTE as o, INPUT_IMAGE_TYPES as p, AGENT_INVOCATION_PARENT_MAILBOX_STATUSES as r, buttonUserInputField as s, webMessageId as t, normalizeUserInputAnswer as u, userCustomizationTextSchema as v, AGENT_PARENT_MESSAGE_EVENT_TYPE as w, isOpenPlanItemStatus as x, PLAN_ITEM_STATUSES as y, utcHourKey as z };
@@ -1,11 +1,12 @@
1
1
  import { t as __exportAll } from "./rolldown-runtime-BKpuH2hG.js";
2
- import { Ct as countPendingConversationMessages, Nt as isFinalAttempt, Pt as isInvalidConversationRecordError, jt as hasConversationStop } from "./projection-CcFBVFUo.js";
3
- import { X as isProviderRetryError, i as getChatConfig } from "./config-CBZp0udd.js";
4
- import { T as withLogContext, b as setSpanAttributes, h as logWarn, m as logInfo, p as logException } from "./logging-BPNTQVFu.js";
5
- import { t as getConversationStoppedAtMs } from "./session-stop-uotLtp4g.js";
6
- import { _ as nudgeIdempotencyKey, m as ConversationQueueMessageRejectedError, p as getTurnRequestDeadline } from "./background-compaction-queue-BTqMIfTA.js";
7
- import { C as requestAnotherSlice, S as releaseConversationWork, T as startConversationWork, _ as getConversationWorkState, b as recordAttemptFailure, c as clearConsumedConversationWake, d as completeConversationWork, f as deadLetterAttempt, h as ensureConversationWake, i as beginConversationResume, o as checkInConversationWork, p as drainConversationMailbox, t as ackMessages, u as completeConversationStop, x as recordConversationRetry } from "./store-Ca6G962n.js";
8
- import { Ln as isAttemptInterrupt, Rn as selectAttemptMessages } from "./warmup--Gkz7iB-.js";
2
+ import { Mt as isInvalidConversationRecordError, jt as isFinalAttempt, kt as hasConversationStop, xt as countPendingConversationMessages } from "./projection-xPpvqexa.js";
3
+ import { i as getChatConfig, ot as isProviderRetryError } from "./config-362yMSIz.js";
4
+ import { T as withLogContext, b as setSpanAttributes, h as logWarn, m as logInfo, p as logException } from "./logging-CHCuQ5iz.js";
5
+ import { t as getConversationStoppedAtMs } from "./session-stop-BDdwyZaa.js";
6
+ import { g as getTurnRequestDeadline } from "./task-queue-BcjAYWyB.js";
7
+ import { _ as ConversationQueueMessageRejectedError, b as nudgeIdempotencyKey } from "./background-compaction-queue-BhEe4UfU.js";
8
+ import { C as requestAnotherSlice, S as releaseConversationWork, T as startConversationWork, _ as getConversationWorkState, b as recordAttemptFailure, c as clearConsumedConversationWake, d as completeConversationWork, f as deadLetterAttempt, h as ensureConversationWake, i as beginConversationResume, o as checkInConversationWork, p as drainConversationMailbox, t as ackMessages, u as completeConversationStop, x as recordConversationRetry } from "./store-CdWg2r2L.js";
9
+ import { In as isAttemptInterrupt, Ln as selectAttemptMessages } from "./warmup-CxhEhm71.js";
9
10
  // src/chat/task-execution/lost-lease.ts
10
11
  /**
11
12
  * Count a slice that lost its Conversation Lease as a failed attempt, then
@@ -0,0 +1,22 @@
1
+ CREATE SEQUENCE "public"."junior_plan_item_version_seq" INCREMENT BY 1 MINVALUE 1 MAXVALUE 9223372036854775807 START WITH 1 CACHE 1;--> statement-breakpoint
2
+ CREATE TABLE "junior_plan_items" (
3
+ "conversation_id" text NOT NULL,
4
+ "id" bigint NOT NULL,
5
+ "title" text NOT NULL,
6
+ "notes" text,
7
+ "status" text NOT NULL,
8
+ "assignee_conversation_id" text,
9
+ "assignee_user_id" text,
10
+ "version" bigint NOT NULL,
11
+ "changed_by_user_id" text,
12
+ "created_at" timestamp with time zone NOT NULL,
13
+ "updated_at" timestamp with time zone NOT NULL,
14
+ CONSTRAINT "junior_plan_items_pk" PRIMARY KEY("conversation_id","id"),
15
+ CONSTRAINT "junior_plan_items_status_check" CHECK ("junior_plan_items"."status" in ('pending', 'in_progress', 'blocked', 'done', 'cancelled')),
16
+ CONSTRAINT "junior_plan_items_assignee_check" CHECK ("junior_plan_items"."assignee_conversation_id" is null or "junior_plan_items"."assignee_user_id" is null)
17
+ );
18
+ --> statement-breakpoint
19
+ ALTER TABLE "junior_plan_items" ADD CONSTRAINT "junior_plan_items_assignee_user_id_junior_users_id_fk" FOREIGN KEY ("assignee_user_id") REFERENCES "public"."junior_users"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
20
+ ALTER TABLE "junior_plan_items" ADD CONSTRAINT "junior_plan_items_changed_by_user_id_junior_users_id_fk" FOREIGN KEY ("changed_by_user_id") REFERENCES "public"."junior_users"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
21
+ ALTER TABLE "junior_plan_items" ADD CONSTRAINT "junior_plan_items_conversation_id_fk" FOREIGN KEY ("conversation_id") REFERENCES "public"."junior_conversations"("conversation_id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
22
+ CREATE UNIQUE INDEX "junior_plan_items_in_progress_uidx" ON "junior_plan_items" USING btree ("conversation_id",coalesce("assignee_conversation_id", "assignee_user_id", "conversation_id")) WHERE "junior_plan_items"."status" = 'in_progress';
@@ -0,0 +1 @@
1
+ CREATE INDEX CONCURRENTLY IF NOT EXISTS "junior_automations_creator_slack_idx" ON "junior_automations" USING btree ("team_id","creator_slack_user_id") WHERE "junior_automations"."status" <> 'deleted';
@@ -0,0 +1,25 @@
1
+ CREATE TABLE "junior_conversation_event_embeddings" (
2
+ "conversation_id" text NOT NULL,
3
+ "seq" integer NOT NULL,
4
+ "provider" text NOT NULL,
5
+ "model" text NOT NULL,
6
+ "dimensions" integer NOT NULL,
7
+ "embedding" halfvec NOT NULL,
8
+ "created_at" timestamp with time zone DEFAULT now() NOT NULL,
9
+ CONSTRAINT "junior_conversation_event_embeddings_pk" PRIMARY KEY("conversation_id","seq"),
10
+ CONSTRAINT "junior_conversation_event_embeddings_dimensions_check" CHECK (vector_dims("junior_conversation_event_embeddings"."embedding") = "junior_conversation_event_embeddings"."dimensions")
11
+ );
12
+ --> statement-breakpoint
13
+ -- Keep each 2 KB vector in its row: the exact scan of a Conversation then reads no TOAST.
14
+ ALTER TABLE "junior_conversation_event_embeddings" ALTER COLUMN "embedding" SET STORAGE MAIN;--> statement-breakpoint
15
+ CREATE TABLE "junior_conversation_event_lexemes" (
16
+ "conversation_id" text NOT NULL,
17
+ "seq" integer NOT NULL,
18
+ "lexemes" "tsvector" NOT NULL,
19
+ "created_at" timestamp with time zone DEFAULT now() NOT NULL,
20
+ CONSTRAINT "junior_conversation_event_lexemes_pk" PRIMARY KEY("conversation_id","seq")
21
+ );
22
+ --> statement-breakpoint
23
+ ALTER TABLE "junior_conversation_event_embeddings" ADD CONSTRAINT "junior_conversation_event_embeddings_event_fk" FOREIGN KEY ("conversation_id","seq") REFERENCES "public"."junior_conversation_events"("conversation_id","seq") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
24
+ ALTER TABLE "junior_conversation_event_lexemes" ADD CONSTRAINT "junior_conversation_event_lexemes_event_fk" FOREIGN KEY ("conversation_id","seq") REFERENCES "public"."junior_conversation_events"("conversation_id","seq") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
25
+ CREATE INDEX "junior_conversation_event_lexemes_lexemes_idx" ON "junior_conversation_event_lexemes" USING gin ("lexemes");
@@ -0,0 +1,46 @@
1
+ ALTER TABLE "junior_automation_runs" ADD COLUMN "cost_micro_usd" bigint;--> statement-breakpoint
2
+ ALTER TABLE "junior_automations" ADD COLUMN "last_run_id" text;--> statement-breakpoint
3
+ -- Every row has a null last_run_id here. NOT VALID skips the scan under lock
4
+ -- and still checks every new write.
5
+ ALTER TABLE "junior_automations" ADD CONSTRAINT "junior_automations_last_run_id_junior_automation_runs_id_fk" FOREIGN KEY ("last_run_id") REFERENCES "public"."junior_automation_runs"("id") ON DELETE set null ON UPDATE no action NOT VALID;--> statement-breakpoint
6
+ -- The list orders by the end of this run and finds failed last runs through
7
+ -- it, and each new run write refreshes it. A run that the old runtime writes
8
+ -- during the rollout leaves an older run until that Automation runs again.
9
+ -- junior:bounded-backfill: one row per listed Automation, and each row reads one index range of its runs; deleted Automations are skipped because no list shows them.
10
+ UPDATE "junior_automations"
11
+ SET "last_run_id" = (
12
+ SELECT "id"
13
+ FROM "junior_automation_runs"
14
+ WHERE "junior_automation_runs"."automation_id" = "junior_automations"."id"
15
+ AND "junior_automation_runs"."status" IN ('blocked', 'completed', 'failed')
16
+ AND "junior_automation_runs"."completed_at_ms" IS NOT NULL
17
+ ORDER BY "completed_at_ms" DESC, "id" DESC
18
+ LIMIT 1
19
+ )
20
+ WHERE "status" <> 'deleted';--> statement-breakpoint
21
+ -- Automation cost totals sum this column, in micro-USD. Each usage write of a
22
+ -- Conversation copies its cost to its run, and each run write copies it when
23
+ -- it links the Conversation. This matches costMicroUsdExpr.
24
+ -- junior:bounded-backfill: settled runs only, which no app write changes; each row reads its own Conversation by primary key.
25
+ UPDATE "junior_automation_runs"
26
+ SET "cost_micro_usd" = (
27
+ SELECT round(CASE
28
+ WHEN "usage_json"->'cost'->>'total' IS NOT NULL
29
+ THEN ("usage_json"->'cost'->>'total')::double precision
30
+ WHEN COALESCE(
31
+ "usage_json"->'cost'->>'input',
32
+ "usage_json"->'cost'->>'output',
33
+ "usage_json"->'cost'->>'cacheRead',
34
+ "usage_json"->'cost'->>'cacheWrite'
35
+ ) IS NOT NULL
36
+ THEN COALESCE(("usage_json"->'cost'->>'input')::double precision, 0)
37
+ + COALESCE(("usage_json"->'cost'->>'output')::double precision, 0)
38
+ + COALESCE(("usage_json"->'cost'->>'cacheRead')::double precision, 0)
39
+ + COALESCE(("usage_json"->'cost'->>'cacheWrite')::double precision, 0)
40
+ ELSE NULL
41
+ END * 1000000)::bigint
42
+ FROM "junior_conversations"
43
+ WHERE "junior_conversations"."conversation_id" = "junior_automation_runs"."conversation_id"
44
+ )
45
+ WHERE "conversation_id" IS NOT NULL
46
+ AND "status" IN ('blocked', 'completed', 'failed', 'skipped');
@@ -0,0 +1 @@
1
+ CREATE INDEX CONCURRENTLY IF NOT EXISTS "junior_automations_last_run_idx" ON "junior_automations" USING btree ("last_run_id");
@@ -0,0 +1,29 @@
1
+ ALTER TABLE "junior_conversation_briefs" ADD COLUMN "cost_micro_usd" bigint;--> statement-breakpoint
2
+ ALTER TABLE "junior_stats" ADD COLUMN "value" bigint DEFAULT 0 NOT NULL;--> statement-breakpoint
3
+ -- Money in Postgres is whole micro-USD. The runtime before this release writes
4
+ -- `cost_usd` until its rollout ends; a later repair migration converts those
5
+ -- rows, and the release after it drops the column.
6
+ -- junior:bounded-backfill: Brief versions are append-only, so no app write changes these rows; only a cascade delete of a Conversation waits.
7
+ UPDATE "junior_conversation_briefs"
8
+ SET "cost_micro_usd" = round("cost_usd" * 1000000)::bigint
9
+ WHERE "cost_usd" IS NOT NULL;--> statement-breakpoint
10
+ -- Counters move to the bigint `value`, so a micro-USD counter does not
11
+ -- overflow int4. Cache warming dollar counters stored 1/10,000 USD units, so
12
+ -- 100 micro-USD each. `count` goes to 0, so the repair migration can move the
13
+ -- amounts that the runtime before this release adds to it during the rollout.
14
+ -- junior:bounded-backfill: the table holds a few hundred counters per day and runs last, so app counter writes wait only for one short update.
15
+ UPDATE "junior_stats"
16
+ SET
17
+ "metric" = CASE
18
+ WHEN "namespace" = 'cache_warming'
19
+ AND "metric" IN ('oracle_savings', 'saved', 'unwarmed_oracle_savings', 'warmup_cost')
20
+ THEN "metric" || '_micro_usd'
21
+ ELSE "metric"
22
+ END,
23
+ "value" = CASE
24
+ WHEN "namespace" = 'cache_warming'
25
+ AND "metric" IN ('oracle_savings', 'saved', 'unwarmed_oracle_savings', 'warmup_cost')
26
+ THEN "count"::bigint * 100
27
+ ELSE "count"
28
+ END,
29
+ "count" = 0;
@@ -0,0 +1,8 @@
1
+ -- Run cost metrics move to whole micro-USD in the same double `value`, which
2
+ -- holds every integer up to 2^53 exactly. The runtime before this release
3
+ -- writes `cost_usd` rows until its rollout ends; a later repair migration
4
+ -- converts those rows. This matches usdToMicroUsdSql.
5
+ -- junior:bounded-backfill: one cost row per Run, and the app rewrites the rows of a Run only while it runs, so only Runs in progress wait for this update.
6
+ UPDATE "junior_conversation_metrics"
7
+ SET "metric" = 'cost_micro_usd', "value" = round("value" * 1000000)
8
+ WHERE "metric" = 'cost_usd';