@valuya/bot-channel-bootstrap-core 0.2.0-beta.1

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Valuya
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,11 @@
1
+ # @valuya/bot-channel-bootstrap-core
2
+
3
+ Shared bootstrap helpers for gated bot-channel packages.
4
+
5
+ This package keeps small but repeated startup concerns in one place:
6
+
7
+ - normalizing `human` vs `agent` mode
8
+ - applying optional soul prompt/schema overrides from env
9
+ - creating optional OpenAI-backed soul runtimes
10
+
11
+ It sits above the app/server core packages and below transport-specific servers.
@@ -0,0 +1,30 @@
1
+ export type ChannelMode = {
2
+ kind: "human";
3
+ } | {
4
+ kind: "agent";
5
+ soulId: string;
6
+ };
7
+ export declare function normalizeChannelMode(args: {
8
+ value?: string;
9
+ soulId: string;
10
+ }): ChannelMode;
11
+ export declare function createConfiguredSoul<TSoul extends {
12
+ locale?: string;
13
+ systemPrompt: string;
14
+ responseSchema?: unknown;
15
+ }>(args: {
16
+ baseSoul: TSoul;
17
+ responseSchemaJson?: string;
18
+ }): TSoul;
19
+ export declare function createOptionalOpenAISoulRuntime<TRuntime>(args: {
20
+ mode: ChannelMode;
21
+ apiKey?: string;
22
+ model?: string;
23
+ createRunner: (args: {
24
+ apiKey: string;
25
+ model: string;
26
+ }) => unknown;
27
+ createRuntime: (args: {
28
+ runCompletion: unknown;
29
+ }) => TRuntime;
30
+ }): TRuntime | undefined;
package/dist/index.js ADDED
@@ -0,0 +1,36 @@
1
+ export function normalizeChannelMode(args) {
2
+ return String(args.value || "human").trim().toLowerCase() === "agent"
3
+ ? { kind: "agent", soulId: args.soulId }
4
+ : { kind: "human" };
5
+ }
6
+ export function createConfiguredSoul(args) {
7
+ const raw = String(args.responseSchemaJson || "").trim();
8
+ if (!raw)
9
+ return args.baseSoul;
10
+ try {
11
+ const parsed = JSON.parse(raw);
12
+ if (parsed && typeof parsed === "object") {
13
+ return {
14
+ ...args.baseSoul,
15
+ responseSchema: parsed,
16
+ };
17
+ }
18
+ }
19
+ catch {
20
+ // keep default soul config
21
+ }
22
+ return args.baseSoul;
23
+ }
24
+ export function createOptionalOpenAISoulRuntime(args) {
25
+ if (args.mode.kind !== "agent")
26
+ return undefined;
27
+ const apiKey = String(args.apiKey || "").trim();
28
+ if (!apiKey)
29
+ return undefined;
30
+ return args.createRuntime({
31
+ runCompletion: args.createRunner({
32
+ apiKey,
33
+ model: String(args.model || "gpt-4.1-mini").trim() || "gpt-4.1-mini",
34
+ }),
35
+ });
36
+ }
package/package.json ADDED
@@ -0,0 +1,30 @@
1
+ {
2
+ "name": "@valuya/bot-channel-bootstrap-core",
3
+ "version": "0.2.0-beta.1",
4
+ "description": "Shared bootstrap helpers for gated bot-channel packages",
5
+ "type": "module",
6
+ "main": "dist/index.js",
7
+ "types": "dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/index.d.ts",
11
+ "default": "./dist/index.js"
12
+ }
13
+ },
14
+ "files": [
15
+ "dist",
16
+ "README.md"
17
+ ],
18
+ "devDependencies": {
19
+ "@types/node": "^25.0.10"
20
+ },
21
+ "publishConfig": {
22
+ "access": "public",
23
+ "tag": "next"
24
+ },
25
+ "license": "MIT",
26
+ "scripts": {
27
+ "build": "rm -rf dist && tsc -p tsconfig.json",
28
+ "test": "pnpm run build && node --test dist/*.test.js"
29
+ }
30
+ }