@kortix/ui 0.15.3 → 0.15.4

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 (66) hide show
  1. package/dist/_vendor/kortix-shared.js +87 -29
  2. package/dist/_vendor/shared/markdown-math.d.ts +6 -0
  3. package/dist/customize/agents/agent-drives-section.d.ts +1 -3
  4. package/dist/customize/agents/agent-drives-section.js +3 -4
  5. package/dist/customize/agents/agent-page.js +2 -2
  6. package/dist/customize/agents/agent-tabs.d.ts +1 -1
  7. package/dist/customize/agents/agent-tabs.js +1 -2
  8. package/dist/customize/connectors/connectors-page.d.ts +8 -0
  9. package/dist/customize/connectors/connectors-page.js +34 -1
  10. package/dist/customize/sections/view/agent-editor-access-fields.js +1 -3
  11. package/dist/files/project/components/drive-explorer.js +64 -43
  12. package/dist/files/project/components/drive-upload-tray.d.ts +2 -1
  13. package/dist/files/project/components/drive-upload-tray.js +9 -4
  14. package/dist/files/project/drop-tree.d.ts +16 -0
  15. package/dist/files/project/drop-tree.js +39 -0
  16. package/dist/files/project/upload-batch.d.ts +15 -0
  17. package/dist/files/project/upload-batch.js +12 -0
  18. package/dist/i18n/en.d.ts +13 -6
  19. package/dist/i18n/en.js +19 -12
  20. package/dist/internal/billing/use-cost-explorer.d.ts +19 -1
  21. package/dist/internal/billing/use-cost-explorer.js +27 -1
  22. package/dist/internal/lib/billing/billing-gate-state.d.ts +5 -6
  23. package/dist/internal/lib/billing/billing-gate-state.js +10 -11
  24. package/dist/internal/lib/browser-error-noise.d.ts +1 -1
  25. package/dist/internal/lib/browser-error-noise.js +1 -1
  26. package/dist/internal/lib/browser-noise/rules/injected-scripts.d.ts +5 -1
  27. package/dist/internal/lib/browser-noise/rules/injected-scripts.js +86 -0
  28. package/dist/internal/lib/mermaid-utils.js +2 -24
  29. package/dist/primitives/mermaid-render.js +3 -20
  30. package/dist/session/composer/ComposerCard.d.ts +1 -1
  31. package/dist/session/composer/ComposerCard.js +2 -2
  32. package/dist/session/composer/composer-chat-input.d.ts +14 -1
  33. package/dist/session/composer/composer-chat-input.js +4 -2
  34. package/dist/session/composer/composer-toolbar.d.ts +4 -1
  35. package/dist/session/composer/composer-toolbar.js +2 -2
  36. package/dist/session/composer/composer.d.ts +8 -0
  37. package/dist/session/composer/send-stop-control.d.ts +15 -1
  38. package/dist/session/composer/send-stop-control.js +30 -5
  39. package/dist/session/header/session-embed-menu-item.d.ts +12 -0
  40. package/dist/session/header/session-embed-menu-item.js +30 -0
  41. package/dist/{workspace/sidebar/modal/session-embed-section.d.ts → session/header/session-embed-snippet.d.ts} +2 -11
  42. package/dist/session/header/session-embed-snippet.js +21 -0
  43. package/dist/session/header/session-site-header.js +9 -2
  44. package/dist/session/models/ask-owner-for-credits-button.d.ts +7 -1
  45. package/dist/session/models/ask-owner-for-credits-button.js +3 -2
  46. package/dist/session/thread/session-chat.js +11 -1
  47. package/dist/session/voice/composer-call.d.ts +31 -0
  48. package/dist/session/voice/composer-call.js +46 -0
  49. package/dist/session/voice/voice-call-card.js +2 -0
  50. package/dist/session/voice/voice-call-store.d.ts +8 -0
  51. package/dist/session/voice/voice-call-store.js +5 -0
  52. package/dist/session/voice/voice-call.d.ts +2 -2
  53. package/dist/session/voice/voice-call.js +6 -6
  54. package/dist/test-utils/intl.d.ts +13 -6
  55. package/dist/workspace/home/existing-repo-setup-prompt.js +2 -3
  56. package/dist/workspace/instant-session-shell.js +11 -1
  57. package/dist/workspace/layout/project-home.js +24 -2
  58. package/dist/workspace/layout/use-project-home-call.d.ts +24 -0
  59. package/dist/workspace/layout/use-project-home-call.js +56 -0
  60. package/dist/workspace/new/workspace-name.d.ts +13 -0
  61. package/dist/workspace/new/workspace-name.js +20 -0
  62. package/dist/workspace/sidebar/footer/project-balance-warning.js +9 -6
  63. package/dist/workspace/sidebar/footer/sidebar-alert.d.ts +1 -1
  64. package/dist/workspace/sidebar/modal/share-session-modal.js +2 -3
  65. package/package.json +7 -7
  66. package/dist/workspace/sidebar/modal/session-embed-section.js +0 -71
@@ -32,3 +32,19 @@ export declare function hasFolder(entries: readonly DroppedEntry[]): boolean;
32
32
  export declare function readDroppedTree(entries: readonly DroppedEntry[]): Promise<TreeFile[]>;
33
33
  /** Folders to create for `items`, grouped by depth: each level only after its parents. */
34
34
  export declare function treeLevels(items: readonly TreeFile[]): string[][];
35
+ /** `ensure(rel)` makes `rel` and its parents; `forget(rel)` lets a failed one be tried again. */
36
+ export interface FolderMaker {
37
+ (rel: string): Promise<void>;
38
+ forget: (rel: string) => void;
39
+ }
40
+ /**
41
+ * Make the folders of an uploading tree on demand: `ensure(rel)` resolves once
42
+ * `rel` and every parent above it exist. Each folder is asked for once, so a
43
+ * file waits only on its own folder and the upload starts with the first one
44
+ * made, not after the whole tree. A folder already there (409) counts as
45
+ * made. A failure is kept for the batch, so the other files in that folder
46
+ * fail at once instead of asking a busy server again; `forget` (a Retry)
47
+ * clears it and the failed parents above it. `''` is the folder the tree
48
+ * lands in, which already exists.
49
+ */
50
+ export declare function folderMaker(mkdir: (rel: string) => Promise<unknown>): FolderMaker;
@@ -61,3 +61,42 @@ export function treeLevels(items) {
61
61
  }
62
62
  return levels.map((level) => [...level]);
63
63
  }
64
+ /**
65
+ * Make the folders of an uploading tree on demand: `ensure(rel)` resolves once
66
+ * `rel` and every parent above it exist. Each folder is asked for once, so a
67
+ * file waits only on its own folder and the upload starts with the first one
68
+ * made, not after the whole tree. A folder already there (409) counts as
69
+ * made. A failure is kept for the batch, so the other files in that folder
70
+ * fail at once instead of asking a busy server again; `forget` (a Retry)
71
+ * clears it and the failed parents above it. `''` is the folder the tree
72
+ * lands in, which already exists.
73
+ */
74
+ export function folderMaker(mkdir) {
75
+ const made = new Map();
76
+ const failed = new Set();
77
+ const parentOf = (rel) => (rel.includes('/') ? rel.slice(0, rel.lastIndexOf('/')) : '');
78
+ const ensure = ((rel) => {
79
+ if (!rel)
80
+ return Promise.resolve();
81
+ const known = made.get(rel);
82
+ if (known)
83
+ return known;
84
+ const run = ensure(parentOf(rel))
85
+ .then(() => mkdir(rel))
86
+ .then(() => undefined, (err) => {
87
+ if (err?.status === 409)
88
+ return;
89
+ failed.add(rel);
90
+ throw err;
91
+ });
92
+ made.set(rel, run);
93
+ return run;
94
+ });
95
+ ensure.forget = (rel) => {
96
+ for (let at = rel; at; at = parentOf(at)) {
97
+ if (failed.delete(at))
98
+ made.delete(at);
99
+ }
100
+ };
101
+ return ensure;
102
+ }
@@ -54,6 +54,20 @@ export declare function uploadedFraction(uploads: readonly {
54
54
  status: string;
55
55
  sent?: number;
56
56
  }[]): number;
57
+ declare const TRAY_RANK: {
58
+ readonly uploading: 0;
59
+ readonly error: 1;
60
+ readonly queued: 2;
61
+ readonly done: 3;
62
+ };
63
+ /**
64
+ * Tray rows in reading order: files going up now, then failures with their
65
+ * Retry (in view, not under a long queue), then files waiting, then finished
66
+ * files. Stable inside each group, so a second batch queues under the first.
67
+ */
68
+ export declare function trayOrder<T extends {
69
+ status: keyof typeof TRAY_RANK;
70
+ }>(uploads: readonly T[]): T[];
57
71
  /** Files sent at once. Enough to fill the pipe, few enough not to starve the listing. */
58
72
  export declare const UPLOAD_CONCURRENCY = 4;
59
73
  /**
@@ -92,3 +106,4 @@ export declare function rowDragIntent(types: readonly string[], options: {
92
106
  /** The explorer's internal drag MIME (`DRAG_MIME`). */
93
107
  moveMime: string;
94
108
  }): RowDragIntent;
109
+ export {};
@@ -61,6 +61,18 @@ export function uploadedFraction(uploads) {
61
61
  const sent = live.reduce((n, u) => n + (u.status === 'done' ? u.file.size : Math.min(u.sent ?? 0, u.file.size)), 0);
62
62
  return sent / total;
63
63
  }
64
+ const TRAY_RANK = { uploading: 0, error: 1, queued: 2, done: 3 };
65
+ /**
66
+ * Tray rows in reading order: files going up now, then failures with their
67
+ * Retry (in view, not under a long queue), then files waiting, then finished
68
+ * files. Stable inside each group, so a second batch queues under the first.
69
+ */
70
+ export function trayOrder(uploads) {
71
+ return uploads
72
+ .map((u, i) => ({ u, i }))
73
+ .sort((a, b) => TRAY_RANK[a.u.status] - TRAY_RANK[b.u.status] || a.i - b.i)
74
+ .map(({ u }) => u);
75
+ }
64
76
  /** Files sent at once. Enough to fill the pipe, few enough not to starve the listing. */
65
77
  export const UPLOAD_CONCURRENCY = 4;
66
78
  /**
package/dist/i18n/en.d.ts CHANGED
@@ -911,6 +911,14 @@ declare const catalog: {
911
911
  historyDescription: string;
912
912
  openLedger: string;
913
913
  unit: string;
914
+ dailySpend: string;
915
+ heatLess: string;
916
+ heatMore: string;
917
+ busiestDay: string;
918
+ noSpendInRange: string;
919
+ idleWorkspaces: string;
920
+ showIdle: string;
921
+ hideIdle: string;
914
922
  };
915
923
  tokens: {
916
924
  keyRevoked: string;
@@ -6387,11 +6395,6 @@ declare const catalog: {
6387
6395
  recentThreads: string;
6388
6396
  searchChannels: string;
6389
6397
  };
6390
- repositoryAccess: {
6391
- label: string;
6392
- enabled: string;
6393
- disabled: string;
6394
- };
6395
6398
  customProvider: {
6396
6399
  intro: string;
6397
6400
  add: string;
@@ -7756,6 +7759,10 @@ declare const catalog: {
7756
7759
  treeYou: string;
7757
7760
  treeExpand: string;
7758
7761
  treeCollapse: string;
7762
+ emptyWorkspaces: string;
7763
+ storageMoreWorkspaces: string;
7764
+ storageWorkspaceLimit: string;
7765
+ storageShowFewer: string;
7759
7766
  };
7760
7767
  genui: {
7761
7768
  showData: string;
@@ -9363,6 +9370,7 @@ declare const catalog: {
9363
9370
  call: string;
9364
9371
  calling: string;
9365
9372
  start: string;
9373
+ inCall: string;
9366
9374
  end: string;
9367
9375
  connecting: string;
9368
9376
  listening: string;
@@ -9431,7 +9439,6 @@ declare const catalog: {
9431
9439
  agentMounts: {
9432
9440
  lead: string;
9433
9441
  mount: string;
9434
- repository: string;
9435
9442
  viaAgent: string;
9436
9443
  viaProject: string;
9437
9444
  from: string;
package/dist/i18n/en.js CHANGED
@@ -838,7 +838,7 @@ const catalog = {
838
838
  },
839
839
  "voice_call": {
840
840
  "name": "Voice calls",
841
- "description": "Call an agent from its page (Customize → Agents) and talk it through. A call is a session of its own on that agent: it hears you, answers in a voice and sees a screen you share, and the conversation is that session's chat."
841
+ "description": "Call an agent from an empty message box, where the send button becomes a call button, or from its page (Customize → Agents), and talk it through. In a session, the call goes to that session's agent; on the workspace home, it starts a new session. The agent hears you, answers in a voice and sees a screen you share, and the conversation is the session's chat."
842
842
  },
843
843
  "shared_drives": {
844
844
  "name": "Shared drives",
@@ -911,7 +911,15 @@ const catalog = {
911
911
  "history": "History",
912
912
  "historyDescription": "What every session cost, and every credit added or spent.",
913
913
  "openLedger": "Open ledger",
914
- "unit": "{count, plural, one {credit} other {credits}}"
914
+ "unit": "{count, plural, one {credit} other {credits}}",
915
+ "dailySpend": "Daily spend",
916
+ "heatLess": "Less",
917
+ "heatMore": "More",
918
+ "busiestDay": "{name}: {amount} on {day}, the busiest day",
919
+ "noSpendInRange": "{name}: no spend in this range",
920
+ "idleWorkspaces": "{count, plural, one {# workspace} other {# workspaces}} with no spend in this range",
921
+ "showIdle": "Show",
922
+ "hideIdle": "Hide"
915
923
  },
916
924
  "tokens": {
917
925
  "keyRevoked": "API key revoked",
@@ -3792,7 +3800,7 @@ const catalog = {
3792
3800
  "text5e3de76869f3": "Waking up the sandbox…",
3793
3801
  "text5e4efd91b927": "Everything resumed",
3794
3802
  "text5ea44c3961f1": "lines",
3795
- "text5ecbbab0d8d8": "Your wallet is empty, so sessions can’t start. Top up to keep compute and the latest AI models running — {value0} unaffected.",
3803
+ "text5ecbbab0d8d8": "Your wallet is empty, so sessions can’t start. Add credits to keep compute and the latest AI models running — {value0} unaffected.",
3796
3804
  "text5ecf97e61ad9": "Copy this code. Then open the auth page and enter it to connect ChatGPT.",
3797
3805
  "text5ed9bd98de1b": "Could not update the workspace default",
3798
3806
  "text5eeb1e6ce9d5": "⌘P",
@@ -5125,7 +5133,7 @@ const catalog = {
5125
5133
  "textcdbf6975e8a3": "Goal",
5126
5134
  "textcdca8801db76": "per week",
5127
5135
  "textcdef3f586a58": "text-kortix-yellow",
5128
- "textce0c20c05842": "Your last payment didn’t go through. Update your payment method under Manage billing, or top up to keep running in the meantime.",
5136
+ "textce0c20c05842": "Your last payment didn’t go through. Update your payment method so your plan keeps running.",
5129
5137
  "textce0faee27592": "billing payment credit card subscription manage wallet tier plan limits overview spend",
5130
5138
  "textce18e358bf01": "Try a different term.",
5131
5139
  "textce1e609b7bf5": "Sandbox ports only",
@@ -6089,7 +6097,7 @@ const catalog = {
6089
6097
  "texta37dd5ef6ef2": "Customize Sidebar",
6090
6098
  "text8c712bd7c1ec": "sidebar customize reorder hide show navigation rows",
6091
6099
  "text3fa17bba73e1": "This workspace has no plan yet. Pick a monthly amount of credits to run sessions. Every member shares one pool.",
6092
- "text6821e42be2c1": "Your wallet is empty, so sessions can’t run. Top up to keep compute and the latest AI models going — your plan is unaffected.",
6100
+ "text6821e42be2c1": "Your wallet is empty, so sessions can’t run. Add credits to keep compute and the latest AI models going — your plan is unaffected.",
6093
6101
  "text1554fd387f25": "Free is $0: 500 credits a month on your first workspace and every feature, with your own key or ChatGPT subscription for models. Kortix-managed models need a paid plan. Paid plans are credits: pick a monthly amount, members are free and unlimited, and one pool covers the whole workspace. Self-hosting the software costs nothing; you pay your own model bill and your own compute bill instead.",
6094
6102
  "text5dffd4db88c5": "Your plan, credits, and billing for this workspace.",
6095
6103
  "textad828837ddd8": "members member workspace access collaborators people teammates roster who can see permissions grant share",
@@ -6388,11 +6396,6 @@ const catalog = {
6388
6396
  "recentThreads": "Recent threads",
6389
6397
  "searchChannels": "Search spaces, threads, commands..."
6390
6398
  },
6391
- "repositoryAccess": {
6392
- "label": "Workspace repository access",
6393
- "enabled": "New sessions receive the workspace repository. Git permissions still apply. Existing sessions keep their access setting.",
6394
- "disabled": "New sessions run without the workspace repository. They can still create files and use granted tools. Existing sessions keep their access setting."
6395
- },
6396
6399
  "customProvider": {
6397
6400
  "intro": "Endpoints the catalogue does not carry.",
6398
6401
  "add": "Add custom provider",
@@ -7756,7 +7759,11 @@ const catalog = {
7756
7759
  "folderTree": "Folders",
7757
7760
  "treeYou": "{name} (You)",
7758
7761
  "treeExpand": "Open {name}",
7759
- "treeCollapse": "Close {name}"
7762
+ "treeCollapse": "Close {name}",
7763
+ "emptyWorkspaces": "{count, plural, one {# workspace holds} other {# workspaces hold}} no files",
7764
+ "storageMoreWorkspaces": "{count, plural, one {# more workspace} other {# more workspaces}}",
7765
+ "storageWorkspaceLimit": "Each workspace holds up to {limit}",
7766
+ "storageShowFewer": "Show fewer"
7760
7767
  },
7761
7768
  "genui": {
7762
7769
  "showData": "Show data",
@@ -9364,6 +9371,7 @@ const catalog = {
9364
9371
  "call": "Call",
9365
9372
  "calling": "Calling…",
9366
9373
  "start": "Start a voice call",
9374
+ "inCall": "You are on a call",
9367
9375
  "end": "End call",
9368
9376
  "connecting": "Connecting…",
9369
9377
  "listening": "Listening",
@@ -9432,7 +9440,6 @@ const catalog = {
9432
9440
  "agentMounts": {
9433
9441
  "lead": "Folders from Files this agent's sessions mount. A change applies at once and reaches every new session.",
9434
9442
  "mount": "Mount folder",
9435
- "repository": "Workspace repository",
9436
9443
  "viaAgent": "shared with this agent",
9437
9444
  "viaProject": "shared with everyone in this workspace",
9438
9445
  "from": "{path} · {who}",
@@ -1,5 +1,5 @@
1
1
  /** @internal Kortix apps only. No semver: it may change in any release. */
2
- import { type CostSummary, type GetCostSummaryOptions, type ListCostByProjectOptions, type ProjectCostPage, type ProjectCostSort } from '@kortix/sdk';
2
+ import { type CostSeriesPoint, type CostSummary, type GetCostSummaryOptions, type ListCostByProjectOptions, type ProjectCostPage, type ProjectCostSort } from '@kortix/sdk';
3
3
  /** Rows per page for the account-wide project cost rollup (`GET
4
4
  * /usage/cost-by-project`) — mirrors `SESSION_COST_PAGE_SIZE` in
5
5
  * `use-session-costs.ts`. */
@@ -71,3 +71,21 @@ export declare function useCostByProject(input: {
71
71
  sort?: ProjectCostSort;
72
72
  offset: number;
73
73
  }): import("@tanstack/react-query").UseQueryResult<ProjectCostPage, Error>;
74
+ /**
75
+ * One daily cost series per workspace, for the workspace-by-day heatmap on the
76
+ * top level of the explorer. Each entry is the same `cost-summary` query the
77
+ * drill-down issues for that workspace (`useCostSummary({ projectId })`), with
78
+ * the same key, so opening a workspace after seeing its heatmap row reads from
79
+ * cache instead of fetching again.
80
+ *
81
+ * Bounded by the caller: it passes the workspaces on the visible page (at most
82
+ * `COST_PAGE_SIZE`). A workspace whose series has not arrived maps to
83
+ * `undefined`, which the heatmap draws as a loading strip, never as zeros. A
84
+ * workspace whose request failed maps to `null`: no series to draw, and no
85
+ * loading strip that would never end.
86
+ */
87
+ export declare function useWorkspaceDailySeries(input: {
88
+ projectIds: readonly string[];
89
+ from?: string;
90
+ to?: string;
91
+ }): Record<string, CostSeriesPoint[] | null | undefined>;
@@ -1,5 +1,5 @@
1
1
  import { getCostSummary, listCostByProject, } from '@kortix/sdk';
2
- import { useQuery } from '@tanstack/react-query';
2
+ import { useQueries, useQuery } from '@tanstack/react-query';
3
3
  import { useBillingAccountId } from '../stores/billing-account-context.js';
4
4
  /** Rows per page for the account-wide project cost rollup (`GET
5
5
  * /usage/cost-by-project`) — mirrors `SESSION_COST_PAGE_SIZE` in
@@ -88,3 +88,29 @@ export function useCostByProject(input) {
88
88
  offset: input.offset,
89
89
  }));
90
90
  }
91
+ /**
92
+ * One daily cost series per workspace, for the workspace-by-day heatmap on the
93
+ * top level of the explorer. Each entry is the same `cost-summary` query the
94
+ * drill-down issues for that workspace (`useCostSummary({ projectId })`), with
95
+ * the same key, so opening a workspace after seeing its heatmap row reads from
96
+ * cache instead of fetching again.
97
+ *
98
+ * Bounded by the caller: it passes the workspaces on the visible page (at most
99
+ * `COST_PAGE_SIZE`). A workspace whose series has not arrived maps to
100
+ * `undefined`, which the heatmap draws as a loading strip, never as zeros. A
101
+ * workspace whose request failed maps to `null`: no series to draw, and no
102
+ * loading strip that would never end.
103
+ */
104
+ export function useWorkspaceDailySeries(input) {
105
+ const accountId = useBillingAccountId();
106
+ return useQueries({
107
+ queries: input.projectIds.map((projectId) => buildCostSummaryQuery({ accountId, projectId, sessionId: null, from: input.from, to: input.to })),
108
+ combine: (results) => {
109
+ const byProject = {};
110
+ results.forEach((result, index) => {
111
+ byProject[input.projectIds[index]] = result.isError ? null : result.data?.series;
112
+ });
113
+ return byProject;
114
+ },
115
+ });
116
+ }
@@ -54,12 +54,11 @@ export declare function billingStateNeedsTopUp(state: BillingState | null): bool
54
54
  /** The server's run floor in USD (`MINIMUM_CREDIT_FOR_RUN`, billing/services/tier-facts.ts). */
55
55
  export declare const RUN_FLOOR_USD = 0.01;
56
56
  /**
57
- * Whether the billing modal leads with the top-up. True when adding credits
58
- * unblocks the account: out of credits, a failed payment, or a Free account
59
- * that may buy credits and sits below the run floor. The last case is a
60
- * further workspace that gets no free credits, or a Free account that spent
61
- * them: a top-up is the cheapest way to run, so the modal never offers only
62
- * "Continue on Free" there (review finding 10).
57
+ * Whether the billing modal opens on the compact out-of-credits view. True
58
+ * when the account cannot run: out of credits, a failed payment, or a Free
59
+ * account below the run floor. The last case is a further workspace that gets
60
+ * no free credits, or a Free account that spent them: the modal offers the
61
+ * subscription there, never only "Continue on Free" (review finding 10).
63
62
  */
64
63
  export declare function billingModalNeedsTopUp(accountState: AccountStateLike | null | undefined, state: BillingState | null): boolean;
65
64
  /**
@@ -62,19 +62,18 @@ export function billingStateNeedsTopUp(state) {
62
62
  /** The server's run floor in USD (`MINIMUM_CREDIT_FOR_RUN`, billing/services/tier-facts.ts). */
63
63
  export const RUN_FLOOR_USD = 0.01;
64
64
  /**
65
- * Whether the billing modal leads with the top-up. True when adding credits
66
- * unblocks the account: out of credits, a failed payment, or a Free account
67
- * that may buy credits and sits below the run floor. The last case is a
68
- * further workspace that gets no free credits, or a Free account that spent
69
- * them: a top-up is the cheapest way to run, so the modal never offers only
70
- * "Continue on Free" there (review finding 10).
65
+ * Whether the billing modal opens on the compact out-of-credits view. True
66
+ * when the account cannot run: out of credits, a failed payment, or a Free
67
+ * account below the run floor. The last case is a further workspace that gets
68
+ * no free credits, or a Free account that spent them: the modal offers the
69
+ * subscription there, never only "Continue on Free" (review finding 10).
71
70
  */
72
71
  export function billingModalNeedsTopUp(accountState, state) {
73
72
  if (billingStateNeedsTopUp(state))
74
73
  return true;
75
- if (state !== 'no_subscription' || !accountState?.tier?.can_purchase_credits)
74
+ if (state !== 'no_subscription')
76
75
  return false;
77
- const balance = accountState.credits?.total;
76
+ const balance = accountState?.credits?.total;
78
77
  return typeof balance === 'number' && balance < RUN_FLOOR_USD;
79
78
  }
80
79
  /**
@@ -137,8 +136,8 @@ export function walletSeverity(state) {
137
136
  */
138
137
  export function walletAlertCopy(severity, tI18nComplete) {
139
138
  return severity === 'blocked'
140
- ? { label: tI18nComplete.raw('textf1c24ec92034'), action: 'Top up' }
141
- : { label: tI18nComplete.raw('text9757b0277bb1'), action: 'Top up' };
139
+ ? { label: tI18nComplete.raw('textf1c24ec92034'), action: 'Add credits' }
140
+ : { label: tI18nComplete.raw('text9757b0277bb1'), action: 'Add credits' };
142
141
  }
143
142
  /**
144
143
  * Copy for the billing modal. Lives here, beside `billingGateCopy`, so no
@@ -191,7 +190,7 @@ export function billingGateCopy(state, tI18nComplete) {
191
190
  return {
192
191
  title: tI18nComplete.raw('textf1c24ec92034'),
193
192
  message: tI18nComplete.raw('text6821e42be2c1'),
194
- ctaLabel: 'Top up credits',
193
+ ctaLabel: 'Add credits',
195
194
  dialogReason: 'insufficient_credits',
196
195
  };
197
196
  case 'payment_failed':
@@ -4,7 +4,7 @@ export { isEmptyMessageUnresolvedBrowserChunkNoise, isStaleWebpackRuntimeCallNoi
4
4
  export { isClientRequestTimeoutMessage, isExpectedBillingGateMessage, isGitMirrorUnavailableNoiseMessage, isModelNotServableNoise, isRuntimeNotReadyNoiseMessage, isServerDeadlineNoiseMessage, } from './browser-noise/rules/expected-states.js';
5
5
  export { isCaptchaInterceptorNoise, isExtensionRejectedObjectNoise, isExtensionSource, isInjectedAppSource, isInjectedScriptSendMessageNoise, isInpageJsNoErrorMessageNoise, isInpageWalletStreamNoise, isTronLinkProxyNoise, isUserscriptManagerNoise, } from './browser-noise/rules/extensions.js';
6
6
  export { isCanvasImageDataOOMNoise, isPaperShaderImageUniformNoise, isPaperShaderNullContextNoise, isPaperShaderWebGLUnsupportedNoise, isSpoofedWebGLGetParameterNoise, } from './browser-noise/rules/graphics.js';
7
- export { isGoogletagUndefinedNoise, isOneTrustJsonParseNoise, isRedefineInjectedWalletNoise, isRedefineWebdriverNoise, isVercelLiveFeedbackNoise, } from './browser-noise/rules/injected-scripts.js';
7
+ export { isGoogletagUndefinedNoise, isOneTrustJsonParseNoise, isRedefineInjectedWalletNoise, isRedefineWebdriverNoise, isTrackingPixelResponseJsonNoise, isVercelLiveFeedbackNoise, } from './browser-noise/rules/injected-scripts.js';
8
8
  export { isKnownBrowserNoiseMessage, isKnownTestNoiseMessage, } from './browser-noise/rules/messages.js';
9
9
  export { isConnectionClosedNoise, isFailedToSendMessageNoise, isFramelessNetworkErrorNoise, isSignalTimeoutNoise, } from './browser-noise/rules/network.js';
10
10
  export { isIosWebViewInjectedStackOverflowNoise, isOldBrowserDomNullDerefNoise, isFirefoxDeadObjectUnattributableNoise, isOldBrowserSyntaxParseError, isOldWebkitRegexNoiseMessage, isUndefinedVariableThirdPartyNoise, isUnresolvableStackOverflowNoise, } from './browser-noise/rules/old-browsers.js';
@@ -29,7 +29,7 @@ export { isEmptyMessageUnresolvedBrowserChunkNoise, isStaleWebpackRuntimeCallNoi
29
29
  export { isClientRequestTimeoutMessage, isExpectedBillingGateMessage, isGitMirrorUnavailableNoiseMessage, isModelNotServableNoise, isRuntimeNotReadyNoiseMessage, isServerDeadlineNoiseMessage, } from './browser-noise/rules/expected-states.js';
30
30
  export { isCaptchaInterceptorNoise, isExtensionRejectedObjectNoise, isExtensionSource, isInjectedAppSource, isInjectedScriptSendMessageNoise, isInpageJsNoErrorMessageNoise, isInpageWalletStreamNoise, isTronLinkProxyNoise, isUserscriptManagerNoise, } from './browser-noise/rules/extensions.js';
31
31
  export { isCanvasImageDataOOMNoise, isPaperShaderImageUniformNoise, isPaperShaderNullContextNoise, isPaperShaderWebGLUnsupportedNoise, isSpoofedWebGLGetParameterNoise, } from './browser-noise/rules/graphics.js';
32
- export { isGoogletagUndefinedNoise, isOneTrustJsonParseNoise, isRedefineInjectedWalletNoise, isRedefineWebdriverNoise, isVercelLiveFeedbackNoise, } from './browser-noise/rules/injected-scripts.js';
32
+ export { isGoogletagUndefinedNoise, isOneTrustJsonParseNoise, isRedefineInjectedWalletNoise, isRedefineWebdriverNoise, isTrackingPixelResponseJsonNoise, isVercelLiveFeedbackNoise, } from './browser-noise/rules/injected-scripts.js';
33
33
  export { isKnownBrowserNoiseMessage, isKnownTestNoiseMessage, } from './browser-noise/rules/messages.js';
34
34
  export { isConnectionClosedNoise, isFailedToSendMessageNoise, isFramelessNetworkErrorNoise, isSignalTimeoutNoise, } from './browser-noise/rules/network.js';
35
35
  export { isIosWebViewInjectedStackOverflowNoise, isOldBrowserDomNullDerefNoise, isFirefoxDeadObjectUnattributableNoise, isOldBrowserSyntaxParseError, isOldWebkitRegexNoiseMessage, isUndefinedVariableThirdPartyNoise, isUnresolvableStackOverflowNoise, } from './browser-noise/rules/old-browsers.js';
@@ -1,5 +1,5 @@
1
1
  /** @internal Kortix apps only. No semver: it may change in any release. */
2
- import type { NoiseRule } from '../evidence.js';
2
+ import type { NoiseFrame, NoiseRule } from '../evidence.js';
3
3
  /**
4
4
  * Whether a Sentry / window.onerror event is the OneTrust cookie-consent SDK
5
5
  * JSON-parse noise class: OneTrust's `otSDKStub.js?did=<domainId>` bootstrap
@@ -77,6 +77,10 @@ export declare function isGoogletagUndefinedNoise(input: {
77
77
  filename?: unknown;
78
78
  } | undefined>;
79
79
  }): boolean;
80
+ export declare function isTrackingPixelResponseJsonNoise(input: {
81
+ message?: unknown;
82
+ frames?: Array<NoiseFrame | undefined>;
83
+ }): boolean;
80
84
  /** Vercel toolbar frames have a reserved source path outside app bundles. */
81
85
  export declare function isVercelLiveFeedbackNoise(input: {
82
86
  filename?: unknown;
@@ -282,6 +282,91 @@ function isRedeclaredInjectedIdentifierNoise(input) {
282
282
  return (REDECLARED_IDENTIFIER_MESSAGE.test(stripErrorWrappers(normalizeString(input.message))) &&
283
283
  !sourcesOf(input).some((source) => isScriptAssetSource(source) || isFirstPartyResolvedSource(source)));
284
284
  }
285
+ // Third-party tracking-pixel `Response.json()` noise. A marketing pixel
286
+ // (observed: Vector, `https://cdn.vector.co/pixel.js`, loaded on the marketing
287
+ // site by the visitor-identification vendor chain,
288
+ // `apps/web/src/components/analytics/visitor-pixel.tsx`) fetches its own API
289
+ // (`https://api.vector.co/pixel/ip-info`) and calls `response.json()` without
290
+ // checking `response.ok`. When the site's bot protection 403s the request with
291
+ // an empty body, `Response.json()` rejects with the canonical DOM
292
+ // `SyntaxError: Failed to execute 'json' on 'Response': Unexpected end of JSON
293
+ // input`. The pixel catches the rejection into a `console.error`, but it still
294
+ // surfaces as an UNCAUGHT unhandled rejection, so Sentry's global handler
295
+ // captures it (`mechanism auto.browser.global_handlers.onunhandledrejection`,
296
+ // `handled:false`) and it pages Better Stack.
297
+ //
298
+ // Better Stack pattern
299
+ // 19329ead41e26241a830a6706a19f206329d24f5a39f133f8963f7b46b69e4af
300
+ // (Kortix Frontend prod, application_id 2346967): 1 occurrence / 0 identified
301
+ // users, first/last 2026-11-10 05:51:06 UTC, request URL `https://kortix.com/`
302
+ // (marketing root), browser Chrome 153 on Windows tagged `browser.type: "bot"`
303
+ // (Naver's Yeti crawler, `Yeti/1.1; +https://naver.me/spd`). Breadcrumbs: the
304
+ // pixel's own fetches to `api.vector.co` both 403'd (bot blocked), then its
305
+ // `console.error` logged the SyntaxError with the raw vendor stack
306
+ // `https://cdn.vector.co/pixel.js`. Stack frames (5, all `in_app:true`, all the
307
+ // vendor script — Sentry's Next.js frame normalization rewrites the
308
+ // cross-origin URL to the `app:///pixel.js` shape, the same normalization the
309
+ // Chromium-extension frames get at beforeSend): `a` → `s` → `Generator.next` →
310
+ // `Generator.<anonymous>` → `e.<anonymous>` (throw site, the `.json()` call).
311
+ // NO first-party `apps/web/src/…` frame.
312
+ //
313
+ // First-party code cannot fix the vendor's missing `response.ok` check, and
314
+ // the empty body only happens when a blocked bot is denied — 0 identified
315
+ // users. A real first-party `response.json()` regression in our own code
316
+ // throws the SAME DOM wording, so matching the message alone would swallow
317
+ // real bugs: require the EXACT message AND the throw site (the innermost
318
+ // resolvable frame) to be a `pixel.js` script that is not a first-party
319
+ // bundle, with a NEGATIVE guard that keeps any de-minified `apps/web/src/…` /
320
+ // `packages/ui/src/…` frame reporting. A frameless capture is unattributable
321
+ // and this wording routinely comes from first-party fetch code — keep
322
+ // reporting (unlike `isGoogletagUndefinedNoise`, whose message class only ever
323
+ // comes from third-party GPT code). Deliberately NOT added to
324
+ // `sentry.client.config.ts`'s `ignoreErrors` list — that gate has no frame
325
+ // context; the frame-aware `beforeSend` hook is the only safe gate.
326
+ // `appliesTo: 'sentry'`: the runtime gate's unhandledrejection capture carries
327
+ // neither frames nor a filename, so it can never confirm the vendor origin.
328
+ const PIXEL_RESPONSE_JSON_NOISE_MESSAGE = /^Failed to execute 'json' on 'Response': Unexpected end of JSON input$/;
329
+ const LINE_TERMINATOR = /[\n\r\u2028\u2029]/;
330
+ /**
331
+ * True when the source's last line names a `pixel.js` script, optionally
332
+ * followed by a query or fragment: the same set `/pixel\.js(?:[?#].*)?$/`
333
+ * matches, in linear time. That unanchored regex backtracks quadratically on a
334
+ * frame filename of many `pixel.js#` repetitions (CodeQL
335
+ * js/polynomial-redos), and frame filenames are page-controlled.
336
+ */
337
+ function endsWithPixelScript(source) {
338
+ const line = source.split(LINE_TERMINATOR).pop() ?? '';
339
+ for (let i = line.indexOf('pixel.js'); i !== -1; i = line.indexOf('pixel.js', i + 1)) {
340
+ const next = line[i + 'pixel.js'.length];
341
+ if (next === undefined || next === '?' || next === '#')
342
+ return true;
343
+ }
344
+ return false;
345
+ }
346
+ function isTrackingPixelScriptSource(filename) {
347
+ const source = normalizeString(filename);
348
+ return endsWithPixelScript(source) && !isBrowserBundleSource(source);
349
+ }
350
+ export function isTrackingPixelResponseJsonNoise(input) {
351
+ const stripped = stripErrorWrappers(normalizeString(input.message));
352
+ if (!PIXEL_RESPONSE_JSON_NOISE_MESSAGE.test(stripped)) {
353
+ return false;
354
+ }
355
+ const frames = (input.frames ?? []).filter((frame) => Boolean(frame));
356
+ // Negative guard: a resolved first-party source frame means our own code
357
+ // called `response.json()` on a bad body → actionable regression; keep
358
+ // reporting so the call site can be found + fixed.
359
+ if (frames.some((frame) => isFirstPartyResolvedSource(frame.filename))) {
360
+ return false;
361
+ }
362
+ // The throw site decides (the innermost resolvable frame — the `.json()`
363
+ // call), never an outer instrumentation wrapper (the googletag lesson,
364
+ // KRTX-4571).
365
+ const throwSite = [...frames]
366
+ .reverse()
367
+ .find((frame) => isResolvableFrameSource(frame.filename))?.filename;
368
+ return throwSite !== undefined && isTrackingPixelScriptSource(throwSite);
369
+ }
285
370
  /** Vercel toolbar frames have a reserved source path outside app bundles. */
286
371
  export function isVercelLiveFeedbackNoise(input) {
287
372
  const sources = sourcesOf(input);
@@ -297,6 +382,7 @@ export const INJECTED_SCRIPT_RULES = [
297
382
  { id: 'googletag-undefined', appliesTo: 'both', match: isGoogletagUndefinedNoise },
298
383
  { id: 'redeclared-injected-identifier', appliesTo: 'both', match: isRedeclaredInjectedIdentifierNoise },
299
384
  { id: 'vercel-live-feedback', appliesTo: 'both', match: isVercelLiveFeedbackNoise },
385
+ { id: 'injected-tracking-pixel-response-json', appliesTo: 'sentry', match: isTrackingPixelResponseJsonNoise },
300
386
  {
301
387
  // KRTX-4387: an injected `tracking_script.js` (no Kortix code, GTM tag or
302
388
  // vendor loads it) asks Closure's jsloader for the gapi client. The CSP
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * Utility functions for Mermaid diagram detection and processing
3
3
  */
4
- import { isMermaidCode } from '../../_vendor/kortix-shared.js';
4
+ import { MERMAID_DIAGRAM_STARTERS, isMermaidCode } from '../../_vendor/kortix-shared.js';
5
5
  // Shared with apps/mobile, which routes the same fences to its diagram renderer.
6
6
  export { isMermaidCode };
7
7
  /**
@@ -22,29 +22,7 @@ export function validateMermaidSyntax(code) {
22
22
  }
23
23
  // Check for basic mermaid structure
24
24
  const firstLine = lines[0].toLowerCase();
25
- const validStarters = [
26
- 'graph',
27
- 'flowchart',
28
- 'sequencediagram',
29
- 'classdiagram',
30
- 'statediagram',
31
- 'erdiagram',
32
- 'journey',
33
- 'gantt',
34
- 'pie',
35
- 'gitgraph',
36
- 'mindmap',
37
- 'timeline',
38
- 'sankey',
39
- 'block',
40
- 'quadrant',
41
- 'requirement',
42
- 'c4context',
43
- 'c4container',
44
- 'c4component',
45
- 'c4dynamic',
46
- ];
47
- const hasValidStarter = validStarters.some((starter) => firstLine.startsWith(starter) || firstLine.includes(starter));
25
+ const hasValidStarter = MERMAID_DIAGRAM_STARTERS.some((starter) => firstLine.startsWith(starter) || firstLine.includes(starter));
48
26
  if (!hasValidStarter) {
49
27
  return {
50
28
  valid: false,
@@ -1,3 +1,4 @@
1
+ import { MERMAID_DIAGRAM_STARTERS } from '../_vendor/kortix-shared.js';
1
2
  /**
2
3
  * Mermaid configuration and render cleanup, kept apart from the component so
3
4
  * the contract is testable without a DOM.
@@ -74,29 +75,11 @@ export async function renderMermaidSvg(source, onStart) {
74
75
  // Check for basic Mermaid syntax
75
76
  const firstLine = source.split('\n')[0].toLowerCase().trim();
76
77
  const validStarters = [
77
- 'graph',
78
- 'flowchart',
79
- 'sequencediagram',
78
+ ...MERMAID_DIAGRAM_STARTERS,
79
+ // Short aliases only `includes` matching reaches.
80
80
  'sequence',
81
- 'classdiagram',
82
81
  'class',
83
- 'statediagram',
84
82
  'state',
85
- 'erdiagram',
86
- 'journey',
87
- 'gantt',
88
- 'pie',
89
- 'gitgraph',
90
- 'mindmap',
91
- 'timeline',
92
- 'sankey',
93
- 'block',
94
- 'quadrant',
95
- 'requirement',
96
- 'c4context',
97
- 'c4container',
98
- 'c4component',
99
- 'c4dynamic',
100
83
  ];
101
84
  const hasValidStarter = validStarters.some((starter) => firstLine.startsWith(starter) || firstLine.includes(starter));
102
85
  if (!hasValidStarter) {
@@ -77,4 +77,4 @@ export interface ComposerCardDerived {
77
77
  noModelsConnected: boolean;
78
78
  }
79
79
  export type ComposerCardProps = SessionChatInputProps & ComposerCardDerived;
80
- export declare function ComposerCard({ tHardcodedUi, isDragOver, handleDragEnter, handleDragOver, handleDragLeave, handleDropFiles, attachedFiles, promptAttachmentItems, removeAttachedFile, retryAttachedFile, pastes, removePaste, onOpenPastedContent, commandAttachmentPlan, editorDisabled, editorRef, setEditorRef, editorPlaceholder, animatePlaceholder, handleSubmit, handleArrowUpAtStart, handleArrowDownAtEnd, historyPosition, setIsEmpty, handleDocChange, allSessions, slashActions, handleSelectAction, dockId, setMenuOpen, fileInputRef, handleFileSelect, sessionId, handleAttachClick, primaryAgents, availableSelectedModel, agentMenuOpen, setAgentMenuOpen, modelMenuOpen, setModelMenuOpen, reasoningMenuOpen, setReasoningMenuOpen, isEmpty, canSubmit, submitDisabled, attachmentFailed, modelRejectingImages, imagesUnsupportedReason, modelUnavailable, agentUnavailable, noModelsConnected, agents, commands, slashFiles, models, notice, disabled, lockForQuestion, lockForApproval, questionButtonLabel, questionActive, submitLabel, questionCanAct, escCount, isBusy, isSending, onStop, stopDisabled, canStop, modelsLoading, modelRequired, onModelChange, modelDefaultControls, inheritedModel, providers, variants, selectedVariant, onVariantChange, projectId, toolbarSlot, underbarSlot, rewind, selectedAgent, onAgentChange, noAccessibleAgents, agentLocked, onContextClick, messages, underbarPlacement, agentPickerCompact, slashMenuPlacement, cardClassName, }: ComposerCardProps): import("react").JSX.Element;
80
+ export declare function ComposerCard({ tHardcodedUi, isDragOver, handleDragEnter, handleDragOver, handleDragLeave, handleDropFiles, attachedFiles, promptAttachmentItems, removeAttachedFile, retryAttachedFile, pastes, removePaste, onOpenPastedContent, commandAttachmentPlan, editorDisabled, editorRef, setEditorRef, editorPlaceholder, animatePlaceholder, handleSubmit, handleArrowUpAtStart, handleArrowDownAtEnd, historyPosition, setIsEmpty, handleDocChange, allSessions, slashActions, handleSelectAction, dockId, setMenuOpen, fileInputRef, handleFileSelect, sessionId, handleAttachClick, primaryAgents, availableSelectedModel, agentMenuOpen, setAgentMenuOpen, modelMenuOpen, setModelMenuOpen, reasoningMenuOpen, setReasoningMenuOpen, isEmpty, canSubmit, submitDisabled, attachmentFailed, modelRejectingImages, imagesUnsupportedReason, modelUnavailable, agentUnavailable, noModelsConnected, agents, commands, slashFiles, models, notice, disabled, lockForQuestion, lockForApproval, questionButtonLabel, questionActive, submitLabel, questionCanAct, escCount, isBusy, isSending, onStop, stopDisabled, canStop, modelsLoading, modelRequired, onModelChange, modelDefaultControls, inheritedModel, providers, variants, selectedVariant, onVariantChange, projectId, toolbarSlot, underbarSlot, rewind, selectedAgent, onAgentChange, noAccessibleAgents, agentLocked, onContextClick, messages, underbarPlacement, agentPickerCompact, slashMenuPlacement, cardClassName, call, }: ComposerCardProps): import("react").JSX.Element;