@hachej/boring-core 0.1.42 → 0.1.44
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/PostgresMeteringStore-CzNv6xil.d.ts +224 -0
- package/dist/app/front/index.d.ts +216 -3
- package/dist/app/front/index.js +834 -43
- package/dist/app/server/index.d.ts +3 -3
- package/dist/app/server/index.js +33 -8
- package/dist/{authHook-DUqyxueY.d.ts → authHook-CzBsMwwM.d.ts} +2 -2
- package/dist/{chunk-C3YMOITB.js → chunk-I56OTSPB.js} +649 -6
- package/dist/{chunk-H5KU6R6Y.js → chunk-LIBHVT7V.js} +5 -1
- package/dist/{chunk-GZVKZD4P.js → chunk-UM5SHYIS.js} +11 -2
- package/dist/{chunk-MLTJKZL4.js → chunk-VYXEXOCO.js} +21 -10
- package/dist/{connection-AL8KSENV.d.ts → connection-C5SiqoNc.d.ts} +1 -1
- package/dist/front/index.d.ts +15 -2
- package/dist/front/index.js +2 -2
- package/dist/server/db/index.d.ts +4 -4
- package/dist/server/db/index.js +6 -2
- package/dist/server/index.d.ts +594 -7
- package/dist/server/index.js +1467 -4
- package/dist/shared/index.d.ts +1 -1
- package/dist/shared/index.js +1 -1
- package/dist/{types-CbMOXLBf.d.ts → types-CWtJ4kgd.d.ts} +3 -0
- package/drizzle/0011_usage_metering.sql +57 -0
- package/drizzle/0012_credit_purchases.sql +9 -0
- package/drizzle/0013_credit_purchase_lifecycle.sql +28 -0
- package/drizzle/0014_reservation_charge_on_expire.sql +7 -0
- package/drizzle/meta/_journal.json +28 -0
- package/package.json +4 -4
- package/dist/migrate-B4dwdtGP.d.ts +0 -8
|
@@ -2,10 +2,10 @@ import { RuntimeProvisioningContribution, RegisterAgentRoutesOptions } from '@ha
|
|
|
2
2
|
import { DirPluginEntry, CreateWorkspaceAgentServerOptions } from '@hachej/boring-workspace/app/server';
|
|
3
3
|
import { WorkspaceServerPlugin } from '@hachej/boring-workspace/server';
|
|
4
4
|
import { FastifyInstance } from 'fastify';
|
|
5
|
-
import { C as CoreConfig } from '../../types-
|
|
5
|
+
import { C as CoreConfig } from '../../types-CWtJ4kgd.js';
|
|
6
6
|
import { TelemetrySink } from '../../shared/index.js';
|
|
7
|
-
import { B as BetterAuthInstance, L as LoadConfigOptions } from '../../authHook-
|
|
8
|
-
import { D as Database, U as UserStore, W as WorkspaceStore } from '../../connection-
|
|
7
|
+
import { B as BetterAuthInstance, L as LoadConfigOptions } from '../../authHook-CzBsMwwM.js';
|
|
8
|
+
import { D as Database, U as UserStore, W as WorkspaceStore } from '../../connection-C5SiqoNc.js';
|
|
9
9
|
import { IncomingMessage, ServerResponse } from 'node:http';
|
|
10
10
|
import 'better-auth';
|
|
11
11
|
import 'drizzle-orm/postgres-js';
|
package/dist/app/server/index.js
CHANGED
|
@@ -9,20 +9,20 @@ import {
|
|
|
9
9
|
registerRoutes,
|
|
10
10
|
registerSettingsRoutes,
|
|
11
11
|
registerWorkspaceRoutes
|
|
12
|
-
} from "../../chunk-
|
|
12
|
+
} from "../../chunk-UM5SHYIS.js";
|
|
13
13
|
import {
|
|
14
14
|
PostgresUserStore,
|
|
15
15
|
PostgresWorkspaceStore,
|
|
16
16
|
createDatabase,
|
|
17
17
|
telemetryEvents
|
|
18
|
-
} from "../../chunk-
|
|
18
|
+
} from "../../chunk-I56OTSPB.js";
|
|
19
19
|
import {
|
|
20
20
|
noopTelemetry,
|
|
21
21
|
safeCapture
|
|
22
22
|
} from "../../chunk-AQBXNPMD.js";
|
|
23
23
|
import {
|
|
24
24
|
ERROR_CODES
|
|
25
|
-
} from "../../chunk-
|
|
25
|
+
} from "../../chunk-LIBHVT7V.js";
|
|
26
26
|
import "../../chunk-MLKGABMK.js";
|
|
27
27
|
|
|
28
28
|
// src/app/server/createCoreWorkspaceAgentServer.ts
|
|
@@ -31,6 +31,7 @@ import { createReadStream } from "fs";
|
|
|
31
31
|
import path from "path";
|
|
32
32
|
import {
|
|
33
33
|
compactPiPackages,
|
|
34
|
+
createRemoteWorkerModeAdapter,
|
|
34
35
|
provisionWorkspaceRuntime,
|
|
35
36
|
registerAgentRoutes
|
|
36
37
|
} from "@hachej/boring-agent/server";
|
|
@@ -578,7 +579,8 @@ async function createCoreWorkspaceAgentServer(options = {}) {
|
|
|
578
579
|
pluginResolveContext
|
|
579
580
|
))
|
|
580
581
|
);
|
|
581
|
-
const
|
|
582
|
+
const externalPluginsEnabled = options.externalPlugins !== false;
|
|
583
|
+
const installPluginAuthoring = externalPluginsEnabled && options.installPluginAuthoring === true;
|
|
582
584
|
const pluginCollection = collectWorkspaceAgentServerPlugins({
|
|
583
585
|
workspaceRoot: pluginWorkspaceRoot,
|
|
584
586
|
systemPromptAppend: staticSystemPromptAppend,
|
|
@@ -592,6 +594,8 @@ async function createCoreWorkspaceAgentServer(options = {}) {
|
|
|
592
594
|
const root = options.getWorkspaceRoot ? await options.getWorkspaceRoot(workspaceId, request) : await resolveWorkspaceRoot(workspaceRoot, workspaceId);
|
|
593
595
|
return root;
|
|
594
596
|
};
|
|
597
|
+
const workerBaseUrl = process.env.BORING_WORKER_BASE_URL?.trim();
|
|
598
|
+
const remoteWorkerModeAdapter = workerBaseUrl ? createRemoteWorkerModeAdapter({ baseUrl: workerBaseUrl }) : void 0;
|
|
595
599
|
const piOptionsByRoot = /* @__PURE__ */ new Map();
|
|
596
600
|
const getPluginPiOptions = (root) => {
|
|
597
601
|
const resolvedRoot = path.resolve(root);
|
|
@@ -613,16 +617,37 @@ async function createCoreWorkspaceAgentServer(options = {}) {
|
|
|
613
617
|
return scopedPluginCollection.agentOptions.pi;
|
|
614
618
|
};
|
|
615
619
|
const resolvePiOptions = async (ctx) => {
|
|
616
|
-
const pluginOptions = getPluginPiOptions(ctx.workspaceRoot);
|
|
620
|
+
const pluginOptions = remoteWorkerModeAdapter ? pluginCollection.agentOptions.pi : getPluginPiOptions(ctx.workspaceRoot);
|
|
617
621
|
const callerOptions = options.getPi ? await options.getPi(ctx) : void 0;
|
|
618
622
|
return mergePiOptions(pluginOptions, callerOptions);
|
|
619
623
|
};
|
|
624
|
+
app.get("/api/v1/workspace/meta", async (request, reply) => {
|
|
625
|
+
try {
|
|
626
|
+
const workspaceId = await resolveWorkspaceId(request);
|
|
627
|
+
const [workspace, workspaceRootForRequest] = await Promise.all([
|
|
628
|
+
workspaceStore.get(workspaceId),
|
|
629
|
+
resolveRoot(workspaceId, request)
|
|
630
|
+
]);
|
|
631
|
+
return {
|
|
632
|
+
workspaceId,
|
|
633
|
+
workspaceRoot: workspaceRootForRequest,
|
|
634
|
+
projectName: workspace?.name ?? "Workspace"
|
|
635
|
+
};
|
|
636
|
+
} catch (error) {
|
|
637
|
+
const statusCode = typeof error?.statusCode === "number" ? error.statusCode : 500;
|
|
638
|
+
const message = error instanceof Error ? error.message : "workspace meta failed";
|
|
639
|
+
return reply.code(statusCode).send({ error: message });
|
|
640
|
+
}
|
|
641
|
+
});
|
|
642
|
+
const resolveSessionNamespace = async (ctx) => options.getSessionNamespace ? await options.getSessionNamespace(ctx) : options.sessionNamespace ?? ctx.workspaceId;
|
|
620
643
|
await app.register(registerAgentRoutes, {
|
|
621
644
|
workspaceRoot,
|
|
622
645
|
sessionId: options.sessionId,
|
|
623
646
|
templatePath: options.templatePath,
|
|
624
647
|
getTemplatePath: options.getTemplatePath,
|
|
625
648
|
mode: options.mode,
|
|
649
|
+
externalPlugins: externalPluginsEnabled,
|
|
650
|
+
runtimeModeAdapter: remoteWorkerModeAdapter,
|
|
626
651
|
version: options.version,
|
|
627
652
|
extraTools: [
|
|
628
653
|
...options.extraTools ?? [],
|
|
@@ -631,8 +656,7 @@ async function createCoreWorkspaceAgentServer(options = {}) {
|
|
|
631
656
|
systemPromptAppend: pluginCollection.agentOptions.systemPromptAppend,
|
|
632
657
|
pi: pluginCollection.agentOptions.pi,
|
|
633
658
|
getPi: resolvePiOptions,
|
|
634
|
-
|
|
635
|
-
getSessionNamespace: options.getSessionNamespace,
|
|
659
|
+
getSessionNamespace: resolveSessionNamespace,
|
|
636
660
|
getExtraTools: async (ctx) => {
|
|
637
661
|
const callerTools = options.getExtraTools ? await options.getExtraTools(ctx) : [];
|
|
638
662
|
return [
|
|
@@ -665,7 +689,8 @@ async function createCoreWorkspaceAgentServer(options = {}) {
|
|
|
665
689
|
},
|
|
666
690
|
provisionWorkspace: options.provisionWorkspace,
|
|
667
691
|
registerHealthRoute: options.registerHealthRoute ?? false,
|
|
668
|
-
telemetry
|
|
692
|
+
telemetry,
|
|
693
|
+
metering: options.metering
|
|
669
694
|
});
|
|
670
695
|
await app.register(uiRoutes, {
|
|
671
696
|
getWorkspaceId: resolveWorkspaceId,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { C as CoreConfig, R as RuntimeConfig } from './types-
|
|
1
|
+
import { C as CoreConfig, R as RuntimeConfig } from './types-CWtJ4kgd.js';
|
|
2
2
|
import { FastifyPluginAsync } from 'fastify';
|
|
3
3
|
import { Auth } from 'better-auth';
|
|
4
|
-
import { W as WorkspaceStore, D as Database } from './connection-
|
|
4
|
+
import { W as WorkspaceStore, D as Database } from './connection-C5SiqoNc.js';
|
|
5
5
|
|
|
6
6
|
interface LoadConfigOptions {
|
|
7
7
|
tomlPath?: string;
|