@gera2ld/pb-datacenter 0.0.20 → 0.0.22

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.
@@ -10,9 +10,7 @@ export declare const capabilitySchema: z.ZodObject<{
10
10
  respond: "respond";
11
11
  }>>;
12
12
  description: z.ZodString;
13
- triggerHint: z.ZodString;
14
13
  alwaysActive: z.ZodBoolean;
15
- threshold: z.ZodNumber;
16
14
  presentationPrompt: z.ZodOptional<z.ZodNullable<z.ZodString>>;
17
15
  inputSchema: z.ZodOptional<z.ZodNullable<z.ZodObject<{
18
16
  type: z.ZodLiteral<"object">;
@@ -21,35 +19,3 @@ export declare const capabilitySchema: z.ZodObject<{
21
19
  }, z.core.$loose>>>;
22
20
  }, z.core.$strip>;
23
21
  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>>>;
package/dist/index.d.ts CHANGED
@@ -3,3 +3,4 @@ export * from "./common";
3
3
  export * from "./pocketbase";
4
4
  export * from "./providers";
5
5
  export * from "./souls";
6
+ export * from "./tokens";
package/dist/index.js CHANGED
@@ -1,53 +1,47 @@
1
- import { asyncMemo as e } from "@gera2ld/async-memo";
2
- import { z as t } from "zod";
1
+ import e, { z as t } from "zod";
3
2
  import { once as n, pick as r } from "es-toolkit";
4
3
  import i from "pocketbase";
4
+ import { asyncMemo as a } from "@gera2ld/async-memo";
5
5
  //#region src/common.ts
6
- var a = t.looseObject({
6
+ var o = t.looseObject({
7
7
  type: t.literal("object"),
8
8
  properties: t.record(t.string(), t.unknown()),
9
9
  required: t.string().array().optional()
10
- }), o = t.union([t.object({
10
+ }), s = t.union([t.object({
11
11
  type: t.enum(["object", "array"]),
12
12
  description: t.string().optional(),
13
- schema: a
13
+ schema: o
14
14
  }), t.object({
15
15
  type: t.literal("choice"),
16
16
  description: t.string().optional(),
17
17
  options: t.string().array()
18
- })]), s = t.object({
18
+ })]), c = t.object({
19
19
  maxOutputTokens: t.coerce.number(),
20
20
  temperature: t.coerce.number()
21
- }).partial(), c = [
22
- "POCKETBASE_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_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({
21
+ }).partial(), l = t.object({
37
22
  name: t.string(),
38
23
  category: t.enum(["mode", "tool"]).catch("tool"),
39
24
  phase: t.enum(["plan", "respond"]).catch("plan"),
40
25
  description: t.string(),
41
- triggerHint: t.string(),
42
26
  alwaysActive: t.boolean(),
43
- threshold: t.number(),
44
27
  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));
28
+ inputSchema: o.nullish()
29
+ }), u = [
30
+ "POCKETBASE_URL",
31
+ "POCKETBASE_ADMIN_USER",
32
+ "POCKETBASE_ADMIN_PASS"
33
+ ], d = r(process.env, u);
34
+ function f(e) {
35
+ u.forEach((t) => {
36
+ e[t] != null && (d[t] = e[t]);
37
+ });
49
38
  }
50
- var m = e(p, { ttl: 6e4 }), h = t.object({
39
+ var p = n(async function() {
40
+ let e = u.filter((e) => !d[e]);
41
+ if (e.length) throw Error(`Missing env keys: ${e.join(", ")}`);
42
+ let { POCKETBASE_URL: t, POCKETBASE_ADMIN_USER: n, POCKETBASE_ADMIN_PASS: r } = d, a = new i(t).autoCancellation(!1);
43
+ return await a.collection("_superusers").authWithPassword(n, r, { autoRefreshThreshold: 1800 }), a;
44
+ }), m = t.object({
51
45
  name: t.string(),
52
46
  enabled: t.boolean(),
53
47
  handler: t.string(),
@@ -58,34 +52,46 @@ var m = e(p, { ttl: 6e4 }), h = t.object({
58
52
  }).partial().nullish(),
59
53
  options: t.record(t.string(), t.any()).nullish()
60
54
  });
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);
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);
64
58
  }
65
- var _ = e(g, {
59
+ var g = a(h, {
66
60
  ttl: 6e4,
67
61
  resolver: (e) => e
68
- }), v = t.object({
62
+ }), _ = t.object({
69
63
  id: t.string(),
70
64
  name: t.string(),
71
65
  basePrompt: t.string(),
72
66
  presentationPrompt: t.string(),
73
67
  providers: t.string().array().min(1),
74
- outputSchema: o.nullish(),
75
- overrideOptions: s.nullish(),
68
+ outputSchema: s.nullish(),
69
+ overrideOptions: c.nullish(),
76
70
  capabilities: t.string().array(),
77
71
  expand: t.object({
78
- providers: h.array().min(1),
79
- capabilities: f.array().optional()
72
+ providers: m.array().min(1),
73
+ capabilities: l.array().optional()
80
74
  })
81
75
  });
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);
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);
85
79
  }
86
- var b = e(y, {
80
+ var y = a(v, {
87
81
  ttl: 6e4,
88
82
  resolver: (e) => e
83
+ }), b = e.object({
84
+ id: e.string(),
85
+ name: e.string(),
86
+ token: e.string(),
87
+ user: e.string().nullish(),
88
+ payload: e.unknown(),
89
+ created: e.string(),
90
+ updated: e.string()
89
91
  });
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);
94
+ return await t.collection("tokens").getFirstListItem(n);
95
+ }
90
96
  //#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 };
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 };
package/dist/souls.d.ts CHANGED
@@ -51,9 +51,7 @@ export declare const soulSchema: z.ZodObject<{
51
51
  respond: "respond";
52
52
  }>>;
53
53
  description: z.ZodString;
54
- triggerHint: z.ZodString;
55
54
  alwaysActive: z.ZodBoolean;
56
- threshold: z.ZodNumber;
57
55
  presentationPrompt: z.ZodOptional<z.ZodNullable<z.ZodString>>;
58
56
  inputSchema: z.ZodOptional<z.ZodNullable<z.ZodObject<{
59
57
  type: z.ZodLiteral<"object">;
@@ -90,9 +88,7 @@ export declare function fetchSoul(name: string): Promise<{
90
88
  category: "mode" | "tool";
91
89
  phase: "plan" | "respond";
92
90
  description: string;
93
- triggerHint: string;
94
91
  alwaysActive: boolean;
95
- threshold: number;
96
92
  presentationPrompt?: string | null | undefined;
97
93
  inputSchema?: {
98
94
  [x: string]: unknown;
@@ -147,9 +143,7 @@ export declare const cachedFetchSoul: import("@gera2ld/async-memo").CachedFuncti
147
143
  category: "mode" | "tool";
148
144
  phase: "plan" | "respond";
149
145
  description: string;
150
- triggerHint: string;
151
146
  alwaysActive: boolean;
152
- threshold: number;
153
147
  presentationPrompt?: string | null | undefined;
154
148
  inputSchema?: {
155
149
  [x: string]: unknown;
@@ -0,0 +1,23 @@
1
+ import z from "zod";
2
+ export declare const tokenRecordSchema: z.ZodObject<{
3
+ id: z.ZodString;
4
+ name: z.ZodString;
5
+ token: z.ZodString;
6
+ user: z.ZodOptional<z.ZodNullable<z.ZodString>>;
7
+ payload: z.ZodUnknown;
8
+ created: z.ZodString;
9
+ updated: z.ZodString;
10
+ }, z.core.$strip>;
11
+ export type TokenRecord = z.infer<typeof tokenRecordSchema>;
12
+ export declare function findToken(filters: {
13
+ token?: string;
14
+ user?: string;
15
+ }): Promise<{
16
+ id: string;
17
+ name: string;
18
+ token: string;
19
+ payload: unknown;
20
+ created: string;
21
+ updated: string;
22
+ user?: string | null | undefined;
23
+ }>;
package/package.json CHANGED
@@ -1,7 +1,8 @@
1
1
  {
2
2
  "name": "@gera2ld/pb-datacenter",
3
- "version": "0.0.20",
3
+ "version": "0.0.22",
4
4
  "type": "module",
5
+ "sideEffects": false,
5
6
  "exports": {
6
7
  ".": {
7
8
  "import": "./dist/index.js",