@gera2ld/pb-datacenter 0.0.20 → 0.0.21
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/index.d.ts +1 -2
- package/dist/index.js +31 -54
- package/dist/tokens.d.ts +23 -0
- package/package.json +2 -1
- package/dist/capabilities.d.ts +0 -55
- package/dist/souls.d.ts +0 -180
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -1,53 +1,39 @@
|
|
|
1
|
-
import {
|
|
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
|
|
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
|
-
}),
|
|
10
|
+
}), s = t.union([t.object({
|
|
11
11
|
type: t.enum(["object", "array"]),
|
|
12
12
|
description: t.string().optional(),
|
|
13
|
-
schema:
|
|
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
|
-
})]),
|
|
18
|
+
})]), c = t.object({
|
|
19
19
|
maxOutputTokens: t.coerce.number(),
|
|
20
20
|
temperature: t.coerce.number()
|
|
21
|
-
}).partial(),
|
|
21
|
+
}).partial(), l = [
|
|
22
22
|
"POCKETBASE_URL",
|
|
23
23
|
"POCKETBASE_ADMIN_USER",
|
|
24
24
|
"POCKETBASE_ADMIN_PASS"
|
|
25
|
-
],
|
|
26
|
-
function
|
|
27
|
-
|
|
28
|
-
e[t] != null && (
|
|
25
|
+
], u = r(process.env, l);
|
|
26
|
+
function d(e) {
|
|
27
|
+
l.forEach((t) => {
|
|
28
|
+
e[t] != null && (u[t] = e[t]);
|
|
29
29
|
});
|
|
30
30
|
}
|
|
31
|
-
var
|
|
32
|
-
let e =
|
|
31
|
+
var f = n(async function() {
|
|
32
|
+
let e = l.filter((e) => !u[e]);
|
|
33
33
|
if (e.length) throw Error(`Missing env keys: ${e.join(", ")}`);
|
|
34
|
-
let { POCKETBASE_URL: t, POCKETBASE_ADMIN_USER: n, POCKETBASE_ADMIN_PASS: r } =
|
|
34
|
+
let { POCKETBASE_URL: t, POCKETBASE_ADMIN_USER: n, POCKETBASE_ADMIN_PASS: r } = u, a = new i(t).autoCancellation(!1);
|
|
35
35
|
return await a.collection("_superusers").authWithPassword(n, r, { autoRefreshThreshold: 1800 }), a;
|
|
36
|
-
}),
|
|
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({
|
|
36
|
+
}), p = t.object({
|
|
51
37
|
name: t.string(),
|
|
52
38
|
enabled: t.boolean(),
|
|
53
39
|
handler: t.string(),
|
|
@@ -58,34 +44,25 @@ var m = e(p, { ttl: 6e4 }), h = t.object({
|
|
|
58
44
|
}).partial().nullish(),
|
|
59
45
|
options: t.record(t.string(), t.any()).nullish()
|
|
60
46
|
});
|
|
61
|
-
async function
|
|
62
|
-
let t = await
|
|
63
|
-
return
|
|
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);
|
|
64
50
|
}
|
|
65
|
-
var
|
|
51
|
+
var h = a(m, {
|
|
66
52
|
ttl: 6e4,
|
|
67
53
|
resolver: (e) => e
|
|
68
|
-
}),
|
|
69
|
-
id:
|
|
70
|
-
name:
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
capabilities: t.string().array(),
|
|
77
|
-
expand: t.object({
|
|
78
|
-
providers: h.array().min(1),
|
|
79
|
-
capabilities: f.array().optional()
|
|
80
|
-
})
|
|
54
|
+
}), g = e.object({
|
|
55
|
+
id: e.string(),
|
|
56
|
+
name: e.string(),
|
|
57
|
+
token: e.string(),
|
|
58
|
+
user: e.string().nullish(),
|
|
59
|
+
payload: e.unknown(),
|
|
60
|
+
created: e.string(),
|
|
61
|
+
updated: e.string()
|
|
81
62
|
});
|
|
82
|
-
async function
|
|
83
|
-
let t = await
|
|
84
|
-
return
|
|
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);
|
|
65
|
+
return await t.collection("tokens").getFirstListItem(n);
|
|
85
66
|
}
|
|
86
|
-
var b = e(y, {
|
|
87
|
-
ttl: 6e4,
|
|
88
|
-
resolver: (e) => e
|
|
89
|
-
});
|
|
90
67
|
//#endregion
|
|
91
|
-
export {
|
|
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 };
|
package/dist/tokens.d.ts
ADDED
|
@@ -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
package/dist/capabilities.d.ts
DELETED
|
@@ -1,55 +0,0 @@
|
|
|
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>>>;
|
package/dist/souls.d.ts
DELETED
|
@@ -1,180 +0,0 @@
|
|
|
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>>>;
|