@gera2ld/pb-datacenter 0.0.3

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,55 @@
1
+ import { z } from "zod";
2
+ export declare const capabilitySchema: z.ZodObject<{
3
+ name: z.ZodString;
4
+ category: z.ZodCatch<z.ZodEnum<{
5
+ mode: "mode";
6
+ tool: "tool";
7
+ }>>;
8
+ phase: z.ZodCatch<z.ZodEnum<{
9
+ plan: "plan";
10
+ respond: "respond";
11
+ }>>;
12
+ description: z.ZodString;
13
+ triggerHint: z.ZodString;
14
+ alwaysActive: z.ZodBoolean;
15
+ threshold: z.ZodNumber;
16
+ presentationPrompt: z.ZodOptional<z.ZodNullable<z.ZodString>>;
17
+ inputSchema: z.ZodOptional<z.ZodNullable<z.ZodObject<{
18
+ type: z.ZodLiteral<"object">;
19
+ properties: z.ZodRecord<z.ZodString, z.ZodUnknown>;
20
+ required: z.ZodOptional<z.ZodArray<z.ZodString>>;
21
+ }, z.core.$loose>>>;
22
+ }, z.core.$strip>;
23
+ export type CapabilitySchema = z.infer<typeof capabilitySchema>;
24
+ export declare function fetchCapabilities(): Promise<{
25
+ name: string;
26
+ category: "mode" | "tool";
27
+ phase: "plan" | "respond";
28
+ description: string;
29
+ triggerHint: string;
30
+ alwaysActive: boolean;
31
+ threshold: number;
32
+ presentationPrompt?: string | null | undefined;
33
+ inputSchema?: {
34
+ [x: string]: unknown;
35
+ type: "object";
36
+ properties: Record<string, unknown>;
37
+ required?: string[] | undefined;
38
+ } | null | undefined;
39
+ }[]>;
40
+ export declare const cachedFetchCapabilities: import("@gera2ld/async-memo").CachedFunction<[], {
41
+ name: string;
42
+ category: "mode" | "tool";
43
+ phase: "plan" | "respond";
44
+ description: string;
45
+ triggerHint: string;
46
+ alwaysActive: boolean;
47
+ threshold: number;
48
+ presentationPrompt?: string | null | undefined;
49
+ inputSchema?: {
50
+ [x: string]: unknown;
51
+ type: "object";
52
+ properties: Record<string, unknown>;
53
+ required?: string[] | undefined;
54
+ } | null | undefined;
55
+ }[], Map<string, import("@gera2ld/async-memo").CacheData<unknown>>>;
@@ -0,0 +1,28 @@
1
+ import { z } from "zod";
2
+ export declare const jsonSchema: z.ZodObject<{
3
+ type: z.ZodLiteral<"object">;
4
+ properties: z.ZodRecord<z.ZodString, z.ZodUnknown>;
5
+ required: z.ZodOptional<z.ZodArray<z.ZodString>>;
6
+ }, z.core.$loose>;
7
+ export declare const outputSchema: z.ZodUnion<readonly [z.ZodObject<{
8
+ type: z.ZodEnum<{
9
+ object: "object";
10
+ array: "array";
11
+ }>;
12
+ description: z.ZodOptional<z.ZodString>;
13
+ schema: z.ZodObject<{
14
+ type: z.ZodLiteral<"object">;
15
+ properties: z.ZodRecord<z.ZodString, z.ZodUnknown>;
16
+ required: z.ZodOptional<z.ZodArray<z.ZodString>>;
17
+ }, z.core.$loose>;
18
+ }, z.core.$strip>, z.ZodObject<{
19
+ type: z.ZodLiteral<"choice">;
20
+ description: z.ZodOptional<z.ZodString>;
21
+ options: z.ZodArray<z.ZodString>;
22
+ }, z.core.$strip>]>;
23
+ export type OutputSchema = z.infer<typeof outputSchema>;
24
+ export declare const overrideOptionsSchema: z.ZodObject<{
25
+ maxOutputTokens: z.ZodOptional<z.ZodCoercedNumber<unknown>>;
26
+ temperature: z.ZodOptional<z.ZodCoercedNumber<unknown>>;
27
+ }, z.core.$strip>;
28
+ export type OverrideOptionsSchema = z.infer<typeof overrideOptionsSchema>;
@@ -0,0 +1,5 @@
1
+ export * from "./capabilities";
2
+ export * from "./common";
3
+ export * from "./pocketbase";
4
+ export * from "./providers";
5
+ export * from "./souls";
package/dist/index.js ADDED
@@ -0,0 +1,91 @@
1
+ import { asyncMemo as e } from "@gera2ld/async-memo";
2
+ import { z as t } from "zod";
3
+ import { once as n, pick as r } from "es-toolkit";
4
+ import i from "pocketbase";
5
+ //#region src/common.ts
6
+ var a = t.looseObject({
7
+ type: t.literal("object"),
8
+ properties: t.record(t.string(), t.unknown()),
9
+ required: t.string().array().optional()
10
+ }), o = t.union([t.object({
11
+ type: t.enum(["object", "array"]),
12
+ description: t.string().optional(),
13
+ schema: a
14
+ }), t.object({
15
+ type: t.literal("choice"),
16
+ description: t.string().optional(),
17
+ options: t.string().array()
18
+ })]), s = t.object({
19
+ maxOutputTokens: t.coerce.number(),
20
+ temperature: t.coerce.number()
21
+ }).partial(), c = [
22
+ "POCKETBASE_BASE_URL",
23
+ "POCKETBASE_ADMIN_USER",
24
+ "POCKETBASE_ADMIN_PASS"
25
+ ], l = r(process.env, c);
26
+ function u(e) {
27
+ c.forEach((t) => {
28
+ e[t] != null && (l[t] = e[t]);
29
+ });
30
+ }
31
+ var d = n(async function() {
32
+ let e = c.filter((e) => !l[e]);
33
+ if (e.length) throw Error(`Missing env keys: ${e.join(", ")}`);
34
+ let { POCKETBASE_BASE_URL: t, POCKETBASE_ADMIN_USER: n, POCKETBASE_ADMIN_PASS: r } = l, a = new i(t).autoCancellation(!1);
35
+ return await a.collection("_superusers").authWithPassword(n, r, { autoRefreshThreshold: 1800 }), a;
36
+ }), f = t.object({
37
+ name: t.string(),
38
+ category: t.enum(["mode", "tool"]).catch("tool"),
39
+ phase: t.enum(["plan", "respond"]).catch("plan"),
40
+ description: t.string(),
41
+ triggerHint: t.string(),
42
+ alwaysActive: t.boolean(),
43
+ threshold: t.number(),
44
+ presentationPrompt: t.string().nullish(),
45
+ inputSchema: a.nullish()
46
+ });
47
+ async function p() {
48
+ return (await (await d()).collection("ai_capabilities").getFullList()).map((e) => f.parse(e));
49
+ }
50
+ var m = e(p, { ttl: 6e4 }), h = t.object({
51
+ name: t.string(),
52
+ enabled: t.boolean(),
53
+ handler: t.string(),
54
+ model: t.string(),
55
+ metadata: t.object({
56
+ price: t.number(),
57
+ image: t.object({ single: t.boolean() }).partial()
58
+ }).partial().nullish(),
59
+ options: t.record(t.string(), t.any()).nullish()
60
+ });
61
+ async function g(e) {
62
+ let t = await d(), n = await t.collection("ai_providers").getFirstListItem(t.filter("name={:name}", { name: e }));
63
+ return h.parse(n);
64
+ }
65
+ var _ = e(g, {
66
+ ttl: 6e4,
67
+ resolver: (e) => e
68
+ }), v = t.object({
69
+ id: t.string(),
70
+ name: t.string(),
71
+ basePrompt: t.string(),
72
+ presentationPrompt: t.string(),
73
+ providers: t.string().array().min(1),
74
+ outputSchema: o.nullish(),
75
+ overrideOptions: s.nullish(),
76
+ capabilities: t.string().array(),
77
+ expand: t.object({
78
+ providers: h.array().min(1),
79
+ capabilities: f.array().optional()
80
+ })
81
+ });
82
+ async function y(e) {
83
+ let t = await d(), n = await t.collection("ai_souls").getFirstListItem(t.filter("name={:name}", { name: e }), { expand: "providers,capabilities" });
84
+ return v.parse(n);
85
+ }
86
+ var b = e(y, {
87
+ ttl: 6e4,
88
+ resolver: (e) => e
89
+ });
90
+ //#endregion
91
+ export { m as cachedFetchCapabilities, _ as cachedFetchProvider, b as cachedFetchSoul, f as capabilitySchema, p as fetchCapabilities, g as fetchProvider, y as fetchSoul, d as getPb, a as jsonSchema, o as outputSchema, s as overrideOptionsSchema, h as providerSchema, u as setPocketBaseEnv, v as soulSchema };
@@ -0,0 +1,3 @@
1
+ import PocketBase from "pocketbase";
2
+ export declare function setPocketBaseEnv(value: Record<string, string>): void;
3
+ export declare const getPb: () => Promise<PocketBase>;
@@ -0,0 +1,41 @@
1
+ import { z } from "zod";
2
+ export declare const providerSchema: z.ZodObject<{
3
+ name: z.ZodString;
4
+ enabled: z.ZodBoolean;
5
+ handler: z.ZodString;
6
+ model: z.ZodString;
7
+ metadata: z.ZodOptional<z.ZodNullable<z.ZodObject<{
8
+ price: z.ZodOptional<z.ZodNumber>;
9
+ image: z.ZodOptional<z.ZodObject<{
10
+ single: z.ZodOptional<z.ZodBoolean>;
11
+ }, z.core.$strip>>;
12
+ }, z.core.$strip>>>;
13
+ options: z.ZodOptional<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodAny>>>;
14
+ }, z.core.$strip>;
15
+ export type ProviderSchema = z.infer<typeof providerSchema>;
16
+ export declare function fetchProvider(name: string): Promise<{
17
+ name: string;
18
+ enabled: boolean;
19
+ handler: string;
20
+ model: string;
21
+ metadata?: {
22
+ price?: number | undefined;
23
+ image?: {
24
+ single?: boolean | undefined;
25
+ } | undefined;
26
+ } | null | undefined;
27
+ options?: Record<string, any> | null | undefined;
28
+ }>;
29
+ export declare const cachedFetchProvider: import("@gera2ld/async-memo").CachedFunction<[name: string], {
30
+ name: string;
31
+ enabled: boolean;
32
+ handler: string;
33
+ model: string;
34
+ metadata?: {
35
+ price?: number | undefined;
36
+ image?: {
37
+ single?: boolean | undefined;
38
+ } | undefined;
39
+ } | null | undefined;
40
+ options?: Record<string, any> | null | undefined;
41
+ }, Map<string, import("@gera2ld/async-memo").CacheData<unknown>>>;
@@ -0,0 +1,180 @@
1
+ import { z } from "zod";
2
+ export declare const soulSchema: z.ZodObject<{
3
+ id: z.ZodString;
4
+ name: z.ZodString;
5
+ basePrompt: z.ZodString;
6
+ presentationPrompt: z.ZodString;
7
+ providers: z.ZodArray<z.ZodString>;
8
+ outputSchema: z.ZodOptional<z.ZodNullable<z.ZodUnion<readonly [z.ZodObject<{
9
+ type: z.ZodEnum<{
10
+ object: "object";
11
+ array: "array";
12
+ }>;
13
+ description: z.ZodOptional<z.ZodString>;
14
+ schema: z.ZodObject<{
15
+ type: z.ZodLiteral<"object">;
16
+ properties: z.ZodRecord<z.ZodString, z.ZodUnknown>;
17
+ required: z.ZodOptional<z.ZodArray<z.ZodString>>;
18
+ }, z.core.$loose>;
19
+ }, z.core.$strip>, z.ZodObject<{
20
+ type: z.ZodLiteral<"choice">;
21
+ description: z.ZodOptional<z.ZodString>;
22
+ options: z.ZodArray<z.ZodString>;
23
+ }, z.core.$strip>]>>>;
24
+ overrideOptions: z.ZodOptional<z.ZodNullable<z.ZodObject<{
25
+ maxOutputTokens: z.ZodOptional<z.ZodCoercedNumber<unknown>>;
26
+ temperature: z.ZodOptional<z.ZodCoercedNumber<unknown>>;
27
+ }, z.core.$strip>>>;
28
+ capabilities: z.ZodArray<z.ZodString>;
29
+ expand: z.ZodObject<{
30
+ providers: z.ZodArray<z.ZodObject<{
31
+ name: z.ZodString;
32
+ enabled: z.ZodBoolean;
33
+ handler: z.ZodString;
34
+ model: z.ZodString;
35
+ metadata: z.ZodOptional<z.ZodNullable<z.ZodObject<{
36
+ price: z.ZodOptional<z.ZodNumber>;
37
+ image: z.ZodOptional<z.ZodObject<{
38
+ single: z.ZodOptional<z.ZodBoolean>;
39
+ }, z.core.$strip>>;
40
+ }, z.core.$strip>>>;
41
+ options: z.ZodOptional<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodAny>>>;
42
+ }, z.core.$strip>>;
43
+ capabilities: z.ZodOptional<z.ZodArray<z.ZodObject<{
44
+ name: z.ZodString;
45
+ category: z.ZodCatch<z.ZodEnum<{
46
+ mode: "mode";
47
+ tool: "tool";
48
+ }>>;
49
+ phase: z.ZodCatch<z.ZodEnum<{
50
+ plan: "plan";
51
+ respond: "respond";
52
+ }>>;
53
+ description: z.ZodString;
54
+ triggerHint: z.ZodString;
55
+ alwaysActive: z.ZodBoolean;
56
+ threshold: z.ZodNumber;
57
+ presentationPrompt: z.ZodOptional<z.ZodNullable<z.ZodString>>;
58
+ inputSchema: z.ZodOptional<z.ZodNullable<z.ZodObject<{
59
+ type: z.ZodLiteral<"object">;
60
+ properties: z.ZodRecord<z.ZodString, z.ZodUnknown>;
61
+ required: z.ZodOptional<z.ZodArray<z.ZodString>>;
62
+ }, z.core.$loose>>>;
63
+ }, z.core.$strip>>>;
64
+ }, z.core.$strip>;
65
+ }, z.core.$strip>;
66
+ export type SoulSchema = z.infer<typeof soulSchema>;
67
+ export declare function fetchSoul(name: string): Promise<{
68
+ id: string;
69
+ name: string;
70
+ basePrompt: string;
71
+ presentationPrompt: string;
72
+ providers: string[];
73
+ capabilities: string[];
74
+ expand: {
75
+ providers: {
76
+ name: string;
77
+ enabled: boolean;
78
+ handler: string;
79
+ model: string;
80
+ metadata?: {
81
+ price?: number | undefined;
82
+ image?: {
83
+ single?: boolean | undefined;
84
+ } | undefined;
85
+ } | null | undefined;
86
+ options?: Record<string, any> | null | undefined;
87
+ }[];
88
+ capabilities?: {
89
+ name: string;
90
+ category: "mode" | "tool";
91
+ phase: "plan" | "respond";
92
+ description: string;
93
+ triggerHint: string;
94
+ alwaysActive: boolean;
95
+ threshold: number;
96
+ presentationPrompt?: string | null | undefined;
97
+ inputSchema?: {
98
+ [x: string]: unknown;
99
+ type: "object";
100
+ properties: Record<string, unknown>;
101
+ required?: string[] | undefined;
102
+ } | null | undefined;
103
+ }[] | undefined;
104
+ };
105
+ outputSchema?: {
106
+ type: "object" | "array";
107
+ schema: {
108
+ [x: string]: unknown;
109
+ type: "object";
110
+ properties: Record<string, unknown>;
111
+ required?: string[] | undefined;
112
+ };
113
+ description?: string | undefined;
114
+ } | {
115
+ type: "choice";
116
+ options: string[];
117
+ description?: string | undefined;
118
+ } | null | undefined;
119
+ overrideOptions?: {
120
+ maxOutputTokens?: number | undefined;
121
+ temperature?: number | undefined;
122
+ } | null | undefined;
123
+ }>;
124
+ export declare const cachedFetchSoul: import("@gera2ld/async-memo").CachedFunction<[name: string], {
125
+ id: string;
126
+ name: string;
127
+ basePrompt: string;
128
+ presentationPrompt: string;
129
+ providers: string[];
130
+ capabilities: string[];
131
+ expand: {
132
+ providers: {
133
+ name: string;
134
+ enabled: boolean;
135
+ handler: string;
136
+ model: string;
137
+ metadata?: {
138
+ price?: number | undefined;
139
+ image?: {
140
+ single?: boolean | undefined;
141
+ } | undefined;
142
+ } | null | undefined;
143
+ options?: Record<string, any> | null | undefined;
144
+ }[];
145
+ capabilities?: {
146
+ name: string;
147
+ category: "mode" | "tool";
148
+ phase: "plan" | "respond";
149
+ description: string;
150
+ triggerHint: string;
151
+ alwaysActive: boolean;
152
+ threshold: number;
153
+ presentationPrompt?: string | null | undefined;
154
+ inputSchema?: {
155
+ [x: string]: unknown;
156
+ type: "object";
157
+ properties: Record<string, unknown>;
158
+ required?: string[] | undefined;
159
+ } | null | undefined;
160
+ }[] | undefined;
161
+ };
162
+ outputSchema?: {
163
+ type: "object" | "array";
164
+ schema: {
165
+ [x: string]: unknown;
166
+ type: "object";
167
+ properties: Record<string, unknown>;
168
+ required?: string[] | undefined;
169
+ };
170
+ description?: string | undefined;
171
+ } | {
172
+ type: "choice";
173
+ options: string[];
174
+ description?: string | undefined;
175
+ } | null | undefined;
176
+ overrideOptions?: {
177
+ maxOutputTokens?: number | undefined;
178
+ temperature?: number | undefined;
179
+ } | null | undefined;
180
+ }, Map<string, import("@gera2ld/async-memo").CacheData<unknown>>>;
package/package.json ADDED
@@ -0,0 +1,33 @@
1
+ {
2
+ "name": "@gera2ld/pb-datacenter",
3
+ "version": "0.0.3",
4
+ "type": "module",
5
+ "exports": {
6
+ ".": {
7
+ "import": "./dist/index.js",
8
+ "types": "./dist/index.d.ts"
9
+ }
10
+ },
11
+ "files": [
12
+ "dist"
13
+ ],
14
+ "publishConfig": {
15
+ "access": "public",
16
+ "registry": "https://registry.npmjs.org/"
17
+ },
18
+ "devDependencies": {
19
+ "@gera2ld/common-node": "^0.0.3"
20
+ },
21
+ "dependencies": {
22
+ "@gera2ld/async-memo": "^1.0.0",
23
+ "es-toolkit": "^1.45.1",
24
+ "pocketbase": "^0.26.8",
25
+ "zod": "^4.3.6"
26
+ },
27
+ "scripts": {
28
+ "clean": "del-cli dist tsconfig.tsbuildinfo",
29
+ "build:types": "tsc",
30
+ "build:js": "vite build",
31
+ "build": "pnpm clean && pnpm /^build:/"
32
+ }
33
+ }