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