@hachej/boring-core 0.1.63 → 0.1.65

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.
@@ -0,0 +1,65 @@
1
+ import * as react from 'react';
2
+ import { ReactNode } from 'react';
3
+
4
+ interface CompanyAdminStatus {
5
+ enabled: boolean;
6
+ admin: boolean;
7
+ role?: string | null;
8
+ details?: unknown;
9
+ }
10
+ type LoadCompanyAdminStatus = () => Promise<CompanyAdminStatus | null>;
11
+ type RenderCompanyAdminContent = (status: CompanyAdminStatus) => ReactNode;
12
+ interface CompanyAdminLabels {
13
+ menuLabel?: string;
14
+ pageTitle?: string;
15
+ deniedMessage?: string;
16
+ }
17
+ interface CompanyAdminContextValue {
18
+ configured: boolean;
19
+ loading: boolean;
20
+ status: CompanyAdminStatus | null;
21
+ error: string | null;
22
+ renderContent: RenderCompanyAdminContent | null;
23
+ labels: CompanyAdminLabels;
24
+ refresh(): Promise<void>;
25
+ }
26
+ interface CompanyAdminProviderProps {
27
+ children: ReactNode;
28
+ loadStatus?: LoadCompanyAdminStatus;
29
+ renderContent?: RenderCompanyAdminContent;
30
+ labels?: CompanyAdminLabels;
31
+ /**
32
+ * Optional authenticated-user cache key. When null, status is cleared and no
33
+ * request is made. When it changes, status is refetched.
34
+ */
35
+ identityKey?: string | null;
36
+ }
37
+ declare function CompanyAdminProvider({ children, loadStatus, renderContent, labels, identityKey }: CompanyAdminProviderProps): react.JSX.Element;
38
+ declare function useCompanyAdminStatus(): CompanyAdminContextValue;
39
+
40
+ interface CoreFrontAuthPagesOverride {
41
+ signIn?: React.FC;
42
+ signUp?: React.FC;
43
+ forgotPassword?: React.FC;
44
+ resetPassword?: React.FC;
45
+ verifyEmail?: React.FC;
46
+ authError?: React.FC;
47
+ userSettings?: React.FC;
48
+ }
49
+ interface CoreFrontCompanyAdminOptions {
50
+ loadStatus?: LoadCompanyAdminStatus;
51
+ renderContent?: RenderCompanyAdminContent;
52
+ labels?: CompanyAdminLabels;
53
+ }
54
+ interface CoreFrontProps {
55
+ children?: ReactNode;
56
+ authPages?: CoreFrontAuthPagesOverride;
57
+ cspNonce?: string;
58
+ workspaceRoute?: string;
59
+ workspaceIdParam?: string;
60
+ publicPaths?: string[];
61
+ companyAdmin?: CoreFrontCompanyAdminOptions;
62
+ }
63
+ declare function CoreFront({ children, authPages, cspNonce, workspaceRoute, workspaceIdParam, publicPaths, companyAdmin }: CoreFrontProps): react.JSX.Element;
64
+
65
+ export { type CoreFrontAuthPagesOverride as C, type LoadCompanyAdminStatus as L, type RenderCompanyAdminContent as R, type CoreFrontCompanyAdminOptions as a, type CompanyAdminLabels as b, CompanyAdminProvider as c, type CompanyAdminProviderProps as d, type CompanyAdminStatus as e, CoreFront as f, type CoreFrontProps as g, useCompanyAdminStatus as u };
@@ -1,4 +1,4 @@
1
- import { C as CoreConfig } from './types-Bb7I-83I.js';
1
+ import { C as CoreConfig } from './types-DVgeIw1d.js';
2
2
  import { PostgresJsDatabase } from 'drizzle-orm/postgres-js';
3
3
 
4
4
  interface RunMigrationsOptions {
@@ -225,4 +225,46 @@ declare class PostgresMeteringStore {
225
225
  private sumActiveReservations;
226
226
  }
227
227
 
228
- export { type CreditLedgerEntry as C, type FinishReservationInput as F, type GrantOnceInput as G, InsufficientCreditError as I, type MeteringBalance as M, PostgresMeteringStore as P, type RecordUsageInput as R, type RecordUsageResult as a, type ReservationFinalStatus as b, type ReserveInput as c, type ReserveResult as d, type RunMigrationsOptions as e, runMigrations as r };
228
+ declare class ModelBudgetExceededError extends Error {
229
+ readonly usedMicros: number;
230
+ readonly heldMicros: number;
231
+ readonly budgetMicros: number;
232
+ readonly requestedMicros: number;
233
+ readonly statusCode = 402;
234
+ readonly code = "MODEL_BUDGET_EXCEEDED";
235
+ constructor(usedMicros: number, heldMicros: number, budgetMicros: number, requestedMicros: number);
236
+ }
237
+ interface ReserveModelBudgetInput {
238
+ userId: string;
239
+ workspaceId?: string;
240
+ sessionId?: string;
241
+ runId: string;
242
+ provider: string;
243
+ model: string;
244
+ budgetMicros: number;
245
+ holdMicros: number;
246
+ ttlSeconds: number;
247
+ now?: Date;
248
+ }
249
+ interface ReserveModelBudgetResult {
250
+ reservationId: string;
251
+ created: boolean;
252
+ period: string;
253
+ }
254
+ interface FinishModelBudgetReservationInput {
255
+ reservationId?: string;
256
+ runId?: string;
257
+ userId?: string;
258
+ }
259
+ declare class PostgresModelBudgetStore {
260
+ private db;
261
+ constructor(db: PostgresJsDatabase);
262
+ static monthPeriodUtc(now?: Date): string;
263
+ sweepExpired(now?: Date): Promise<number>;
264
+ reserve(input: ReserveModelBudgetInput): Promise<ReserveModelBudgetResult>;
265
+ settle(input: FinishModelBudgetReservationInput): Promise<void>;
266
+ release(input: FinishModelBudgetReservationInput): Promise<void>;
267
+ private finish;
268
+ }
269
+
270
+ export { type CreditLedgerEntry as C, type FinishReservationInput as F, type GrantOnceInput as G, InsufficientCreditError as I, type MeteringBalance as M, PostgresMeteringStore as P, type RecordUsageInput as R, ModelBudgetExceededError as a, PostgresModelBudgetStore as b, type RecordUsageResult as c, type ReservationFinalStatus as d, type ReserveInput as e, type ReserveResult as f, type RunMigrationsOptions as g, runMigrations as r };
@@ -1,6 +1,6 @@
1
- import * as react_jsx_runtime from 'react/jsx-runtime';
1
+ import * as react from 'react';
2
2
  import { ReactNode } from 'react';
3
- import { C as CoreFrontAuthPagesOverride } from '../../CoreFront-N0QJSYaM.js';
3
+ import { C as CoreFrontAuthPagesOverride, a as CoreFrontCompanyAdminOptions } from '../../CoreFront-DB1OfNJU.js';
4
4
  import { WorkspaceAgentSession, WorkspaceAgentFrontProps } from '@hachej/boring-workspace/app/front';
5
5
  import { ChatSuggestion } from '@hachej/boring-agent/front';
6
6
 
@@ -65,6 +65,7 @@ interface CoreWorkspaceAgentFrontProps<TSession extends WorkspaceAgentSession =
65
65
  chatFirstPublicWorkspaceProps?: Partial<RoutedWorkspaceAgentProps<TSession>>;
66
66
  publicPaths?: string[];
67
67
  authPages?: CoreFrontAuthPagesOverride;
68
+ companyAdmin?: CoreFrontCompanyAdminOptions;
68
69
  cspNonce?: string;
69
70
  children?: ReactNode;
70
71
  workspaceRoute?: string;
@@ -75,8 +76,8 @@ interface CoreWorkspaceAgentFrontProps<TSession extends WorkspaceAgentSession =
75
76
  }
76
77
  /** Default top-bar right content. Exported so apps can compose extra widgets
77
78
  * (e.g. a credit balance badge) alongside the user menu. */
78
- declare function DefaultTopBarRight(): react_jsx_runtime.JSX.Element;
79
- declare function CoreWorkspaceAgentFront<TSession extends WorkspaceAgentSession = WorkspaceAgentSession>({ authPages, cspNonce, children, workspaceRoute, workspaceIdParam, workspaceHref, loadingFallback, bootPreloadPaths, topBarLeft, topBarRight, appTitle, bridgeEndpoint, fullPageBasePath, hotReload, chatEntryMode, chatFirstPublicShell, chatFirstPublicWorkspaceProps, publicPaths, ...workspaceProps }: CoreWorkspaceAgentFrontProps<TSession>): react_jsx_runtime.JSX.Element;
79
+ declare function DefaultTopBarRight(): react.JSX.Element;
80
+ declare function CoreWorkspaceAgentFront<TSession extends WorkspaceAgentSession = WorkspaceAgentSession>({ authPages, companyAdmin, cspNonce, children, workspaceRoute, workspaceIdParam, workspaceHref, loadingFallback, bootPreloadPaths, topBarLeft, topBarRight, appTitle, bridgeEndpoint, fullPageBasePath, hotReload, chatEntryMode, chatFirstPublicShell, chatFirstPublicWorkspaceProps, publicPaths, ...workspaceProps }: CoreWorkspaceAgentFrontProps<TSession>): react.JSX.Element;
80
81
 
81
82
  interface CreditBalanceBadgeProps {
82
83
  /** Base URL for the credits API (default: same origin). */
@@ -94,7 +95,7 @@ interface CreditBalanceBadgeProps {
94
95
  * the server-created checkout and opens it. Polls `/api/credits/balance`; hides itself when
95
96
  * credits are disabled or the user is unauthenticated.
96
97
  */
97
- declare function CreditBalanceBadge({ apiBaseUrl, buyEnabled, pollMs, locale, }: CreditBalanceBadgeProps): react_jsx_runtime.JSX.Element | null;
98
+ declare function CreditBalanceBadge({ apiBaseUrl, buyEnabled, pollMs, locale, }: CreditBalanceBadgeProps): react.JSX.Element | null;
98
99
 
99
100
  interface CreditsSettingsPanelProps {
100
101
  /** Base URL for the credits API (default: same origin). */
@@ -106,7 +107,7 @@ interface CreditsSettingsPanelProps {
106
107
  * staleness), a pack picker → checkout, and a lazy-loaded recent-activity list.
107
108
  * Renders nothing when credits are disabled or the user is unauthenticated.
108
109
  */
109
- declare function CreditsSettingsPanel({ apiBaseUrl, locale }: CreditsSettingsPanelProps): react_jsx_runtime.JSX.Element | null;
110
+ declare function CreditsSettingsPanel({ apiBaseUrl, locale }: CreditsSettingsPanelProps): react.JSX.Element | null;
110
111
 
111
112
  /** Front-end helpers for the credit balance badge + buy-credits flow. */
112
113
  /** Display-ready credit pack (server-authored). The client never infers price from
@@ -261,7 +262,7 @@ interface CheckoutReturnBannerProps {
261
262
  * near the app root. It NEVER claims success from the URL — only after the server
262
263
  * balance actually increases. ARIA-live so the status is announced. Self-hides when idle.
263
264
  */
264
- declare function CheckoutReturnBanner({ apiBaseUrl, param }: CheckoutReturnBannerProps): react_jsx_runtime.JSX.Element | null;
265
+ declare function CheckoutReturnBanner({ apiBaseUrl, param }: CheckoutReturnBannerProps): react.JSX.Element | null;
265
266
 
266
267
  interface BuyCreditsNoticeActionProps {
267
268
  /** Base URL for the credits API (default: same origin). */
@@ -274,6 +275,6 @@ interface BuyCreditsNoticeActionProps {
274
275
  * nothing once the server reports checkout is disabled, so it can't dangle a dead button.
275
276
  * Mount it from a host's renderNoticeAction (see isPaymentRequiredNotice).
276
277
  */
277
- declare function BuyCreditsNoticeAction({ apiBaseUrl, label }: BuyCreditsNoticeActionProps): react_jsx_runtime.JSX.Element | null;
278
+ declare function BuyCreditsNoticeAction({ apiBaseUrl, label }: BuyCreditsNoticeActionProps): react.JSX.Element | null;
278
279
 
279
280
  export { BuyCreditsNoticeAction, type BuyCreditsNoticeActionProps, CREDITS_REFRESH_EVENT, type ChatFirstPublicShellOptions, CheckoutReturnBanner, type CheckoutReturnBannerProps, type CheckoutReturnStatus, CoreWorkspaceAgentFront, type CoreWorkspaceAgentFrontProps, CreditBalanceBadge, type CreditBalanceBadgeProps, type CreditBalanceResponse, type CreditLedgerEntry, type CreditLedgerKind, type CreditPack, CreditsSettingsPanel, type CreditsSettingsPanelProps, DefaultTopBarRight, PAYMENT_REQUIRED_ERROR_CODE, type UseCheckoutReturnHandlerResult, type UseCreditBalanceOptions, type UseCreditBalanceResult, type UseCreditHistoryResult, formatCreditMicros, formatMinorPrice, formatSignedCreditMicros, isLowBalance, isPaymentRequiredNotice, useCheckoutReturnHandler, useCreditBalance, useCreditHistory };
@@ -9,7 +9,7 @@ import {
9
9
  useSignIn,
10
10
  useSignUp,
11
11
  useWorkspaceRouteStatus
12
- } from "../../chunk-NC46VGXS.js";
12
+ } from "../../chunk-3B7LU76T.js";
13
13
  import "../../chunk-HYNKZSTF.js";
14
14
  import {
15
15
  isRuntimeEmailVerificationEnabled
@@ -345,6 +345,7 @@ function ChatFirstPublicShell({
345
345
  // a fresh load/hard refresh shows just the hero, not a re-opened
346
346
  // panel unless the app explicitly overrides defaultSurfaceOpen.
347
347
  defaultSurfaceOpen: workspaceProps.defaultSurfaceOpen ?? false,
348
+ defaultAppLeftPaneCollapsed: workspaceProps.defaultAppLeftPaneCollapsed ?? true,
348
349
  topBarRight: /* @__PURE__ */ jsx4(PublicTopBarActions, { contact: publicShell?.contact, onSignIn: () => openAuth() }),
349
350
  // No-auth shell has no real session yet — show just the brand, hide the
350
351
  // "· New session" placeholder that the default TopBar would render.
@@ -800,6 +801,7 @@ function chatFirstPublicPaths(workspaceRoute) {
800
801
  }
801
802
  function CoreWorkspaceAgentFront({
802
803
  authPages,
804
+ companyAdmin,
803
805
  cspNonce,
804
806
  children,
805
807
  workspaceRoute = DEFAULT_WORKSPACE_ROUTE,
@@ -833,6 +835,7 @@ function CoreWorkspaceAgentFront({
833
835
  CoreFront,
834
836
  {
835
837
  authPages,
838
+ companyAdmin,
836
839
  cspNonce,
837
840
  workspaceRoute,
838
841
  workspaceIdParam,
@@ -2,10 +2,10 @@ import { RuntimeProvisioningContribution, RegisterAgentRoutesOptions } from '@ha
2
2
  import { DirPluginEntry, CreateWorkspaceAgentServerOptions } from '@hachej/boring-workspace/app/server';
3
3
  import { WorkspaceServerPlugin, WorkspaceBridgeOperationDefinition, WorkspaceBridgeHandler, WorkspaceBridgeRuntimeEnvOptions, WorkspaceBridgeCallRequest, WorkspaceBridgeCallResponse } from '@hachej/boring-workspace/server';
4
4
  import { FastifyInstance } from 'fastify';
5
- import { C as CoreConfig } from '../../types-Bb7I-83I.js';
5
+ import { C as CoreConfig } from '../../types-DVgeIw1d.js';
6
6
  import { T as TelemetrySink } from '../../telemetry-DR18MeI0.js';
7
- import { B as BetterAuthInstance, L as LoadConfigOptions } from '../../authHook-BbgCBHjP.js';
8
- import { D as Database, U as UserStore, W as WorkspaceStore } from '../../connection-B1iC6B-w.js';
7
+ import { B as BetterAuthInstance, L as LoadConfigOptions } from '../../authHook-BUSGTx_o.js';
8
+ import { D as Database, U as UserStore, W as WorkspaceStore } from '../../connection-D9s7Td0I.js';
9
9
  import { IncomingMessage, ServerResponse } from 'node:http';
10
10
  import 'better-auth';
11
11
  import 'drizzle-orm/postgres-js';
@@ -9,13 +9,13 @@ import {
9
9
  registerRoutes,
10
10
  registerSettingsRoutes,
11
11
  registerWorkspaceRoutes
12
- } from "../../chunk-ZMS6O4CY.js";
12
+ } from "../../chunk-CIRY3ZLU.js";
13
13
  import {
14
14
  PostgresUserStore,
15
15
  PostgresWorkspaceStore,
16
16
  createDatabase,
17
17
  telemetryEvents
18
- } from "../../chunk-BVZ2YT3M.js";
18
+ } from "../../chunk-EFM5IWTK.js";
19
19
  import {
20
20
  noopTelemetry,
21
21
  safeCapture
@@ -923,6 +923,8 @@ async function createCoreWorkspaceAgentServer(options = {}) {
923
923
  registerHealthRoute: options.registerHealthRoute ?? false,
924
924
  telemetry,
925
925
  metering: options.metering,
926
+ filterModels: options.filterModels,
927
+ getFilesystemBindings: options.getFilesystemBindings,
926
928
  runtimeEnvContributions: [
927
929
  ...options.runtimeEnvContributions ?? [],
928
930
  ...coreBridge.runtimeEnvContribution ? [coreBridge.runtimeEnvContribution] : []
@@ -1,7 +1,7 @@
1
- import { C as CoreConfig, R as RuntimeConfig } from './types-Bb7I-83I.js';
1
+ import { C as CoreConfig, R as RuntimeConfig } from './types-DVgeIw1d.js';
2
2
  import { FastifyPluginAsync } from 'fastify';
3
3
  import { Auth } from 'better-auth';
4
- import { W as WorkspaceStore, D as Database } from './connection-B1iC6B-w.js';
4
+ import { W as WorkspaceStore, D as Database } from './connection-D9s7Td0I.js';
5
5
  import { T as TelemetrySink } from './telemetry-DR18MeI0.js';
6
6
 
7
7
  interface LoadConfigOptions {