@dobby.ai/dobby 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.
- package/.env.example +9 -0
- package/AGENTS.md +267 -0
- package/README.md +382 -0
- package/ROADMAP.md +34 -0
- package/config/cron.example.json +9 -0
- package/config/gateway.example.json +128 -0
- package/config/models.custom.example.json +27 -0
- package/dist/src/agent/event-forwarder.js +341 -0
- package/dist/src/agent/tests/event-forwarder.test.js +113 -0
- package/dist/src/cli/commands/config.js +243 -0
- package/dist/src/cli/commands/configure.js +61 -0
- package/dist/src/cli/commands/cron.js +288 -0
- package/dist/src/cli/commands/doctor.js +189 -0
- package/dist/src/cli/commands/extension.js +151 -0
- package/dist/src/cli/commands/init.js +286 -0
- package/dist/src/cli/commands/start.js +177 -0
- package/dist/src/cli/commands/topology.js +254 -0
- package/dist/src/cli/index.js +8 -0
- package/dist/src/cli/program.js +386 -0
- package/dist/src/cli/shared/config-io.js +223 -0
- package/dist/src/cli/shared/config-mutators.js +345 -0
- package/dist/src/cli/shared/config-path.js +207 -0
- package/dist/src/cli/shared/config-schema.js +159 -0
- package/dist/src/cli/shared/config-types.js +1 -0
- package/dist/src/cli/shared/configure-sections.js +429 -0
- package/dist/src/cli/shared/discord-config.js +12 -0
- package/dist/src/cli/shared/init-catalog.js +115 -0
- package/dist/src/cli/shared/init-models-file.js +65 -0
- package/dist/src/cli/shared/presets.js +86 -0
- package/dist/src/cli/shared/runtime.js +29 -0
- package/dist/src/cli/shared/schema-prompts.js +325 -0
- package/dist/src/cli/tests/config-command.test.js +42 -0
- package/dist/src/cli/tests/config-io.test.js +64 -0
- package/dist/src/cli/tests/config-mutators.test.js +47 -0
- package/dist/src/cli/tests/config-path.test.js +21 -0
- package/dist/src/cli/tests/discord-config.test.js +23 -0
- package/dist/src/cli/tests/doctor.test.js +107 -0
- package/dist/src/cli/tests/init-catalog.test.js +87 -0
- package/dist/src/cli/tests/presets.test.js +41 -0
- package/dist/src/cli/tests/program-options.test.js +92 -0
- package/dist/src/cli/tests/routing-config.test.js +199 -0
- package/dist/src/cli/tests/routing-legacy.test.js +191 -0
- package/dist/src/core/control-command.js +12 -0
- package/dist/src/core/dedup-store.js +92 -0
- package/dist/src/core/gateway.js +432 -0
- package/dist/src/core/routing.js +306 -0
- package/dist/src/core/runtime-registry.js +119 -0
- package/dist/src/core/tests/control-command.test.js +17 -0
- package/dist/src/core/tests/gateway-update-strategy.test.js +167 -0
- package/dist/src/core/tests/runtime-registry.test.js +116 -0
- package/dist/src/core/tests/typing-controller.test.js +103 -0
- package/dist/src/core/types.js +1 -0
- package/dist/src/core/typing-controller.js +88 -0
- package/dist/src/cron/config.js +114 -0
- package/dist/src/cron/schedule.js +49 -0
- package/dist/src/cron/service.js +196 -0
- package/dist/src/cron/store.js +142 -0
- package/dist/src/cron/types.js +1 -0
- package/dist/src/extension/loader.js +97 -0
- package/dist/src/extension/manager.js +269 -0
- package/dist/src/extension/manifest.js +21 -0
- package/dist/src/extension/registry.js +137 -0
- package/dist/src/main.js +6 -0
- package/dist/src/sandbox/executor.js +1 -0
- package/dist/src/sandbox/host-executor.js +111 -0
- package/docs/BOXLITE_SANDBOX_FEASIBILITY.md +175 -0
- package/docs/CRON_SCHEDULER_DESIGN.md +374 -0
- package/docs/DOCKER_SANDBOX_vs_BOXLITE.md +77 -0
- package/docs/EXTENSION_SYSTEM_ARCHITECTURE.md +119 -0
- package/docs/MVP.md +135 -0
- package/docs/RUNBOOK.md +242 -0
- package/docs/TEAMWORK_HANDOFF_DESIGN.md +440 -0
- package/package.json +43 -0
- package/plugins/connector-discord/dobby.manifest.json +18 -0
- package/plugins/connector-discord/index.js +1 -0
- package/plugins/connector-discord/package-lock.json +360 -0
- package/plugins/connector-discord/package.json +38 -0
- package/plugins/connector-discord/src/connector.ts +350 -0
- package/plugins/connector-discord/src/contribution.ts +21 -0
- package/plugins/connector-discord/src/mapper.ts +102 -0
- package/plugins/connector-discord/tsconfig.json +19 -0
- package/plugins/connector-feishu/dobby.manifest.json +18 -0
- package/plugins/connector-feishu/index.js +1 -0
- package/plugins/connector-feishu/package-lock.json +618 -0
- package/plugins/connector-feishu/package.json +38 -0
- package/plugins/connector-feishu/src/connector.ts +343 -0
- package/plugins/connector-feishu/src/contribution.ts +26 -0
- package/plugins/connector-feishu/src/mapper.ts +401 -0
- package/plugins/connector-feishu/tsconfig.json +19 -0
- package/plugins/plugin-sdk/index.d.ts +261 -0
- package/plugins/plugin-sdk/index.js +1 -0
- package/plugins/plugin-sdk/package-lock.json +12 -0
- package/plugins/plugin-sdk/package.json +22 -0
- package/plugins/provider-claude/dobby.manifest.json +17 -0
- package/plugins/provider-claude/index.js +1 -0
- package/plugins/provider-claude/package-lock.json +3398 -0
- package/plugins/provider-claude/package.json +39 -0
- package/plugins/provider-claude/src/contribution.ts +1018 -0
- package/plugins/provider-claude/tsconfig.json +19 -0
- package/plugins/provider-claude-cli/dobby.manifest.json +17 -0
- package/plugins/provider-claude-cli/index.js +1 -0
- package/plugins/provider-claude-cli/package-lock.json +2898 -0
- package/plugins/provider-claude-cli/package.json +38 -0
- package/plugins/provider-claude-cli/src/contribution.ts +1673 -0
- package/plugins/provider-claude-cli/tsconfig.json +19 -0
- package/plugins/provider-pi/dobby.manifest.json +17 -0
- package/plugins/provider-pi/index.js +1 -0
- package/plugins/provider-pi/package-lock.json +3877 -0
- package/plugins/provider-pi/package.json +40 -0
- package/plugins/provider-pi/src/contribution.ts +476 -0
- package/plugins/provider-pi/tsconfig.json +19 -0
- package/plugins/sandbox-core/boxlite.js +1 -0
- package/plugins/sandbox-core/dobby.manifest.json +17 -0
- package/plugins/sandbox-core/docker.js +1 -0
- package/plugins/sandbox-core/package-lock.json +136 -0
- package/plugins/sandbox-core/package.json +39 -0
- package/plugins/sandbox-core/src/boxlite-context.ts +2 -0
- package/plugins/sandbox-core/src/boxlite-contribution.ts +53 -0
- package/plugins/sandbox-core/src/boxlite-executor.ts +911 -0
- package/plugins/sandbox-core/src/docker-contribution.ts +43 -0
- package/plugins/sandbox-core/src/docker-executor.ts +217 -0
- package/plugins/sandbox-core/tsconfig.json +19 -0
- package/scripts/local-extensions.mjs +168 -0
- package/src/agent/event-forwarder.ts +414 -0
- package/src/cli/commands/config.ts +328 -0
- package/src/cli/commands/configure.ts +92 -0
- package/src/cli/commands/cron.ts +410 -0
- package/src/cli/commands/doctor.ts +230 -0
- package/src/cli/commands/extension.ts +205 -0
- package/src/cli/commands/init.ts +396 -0
- package/src/cli/commands/start.ts +223 -0
- package/src/cli/commands/topology.ts +383 -0
- package/src/cli/index.ts +9 -0
- package/src/cli/program.ts +465 -0
- package/src/cli/shared/config-io.ts +277 -0
- package/src/cli/shared/config-mutators.ts +440 -0
- package/src/cli/shared/config-schema.ts +228 -0
- package/src/cli/shared/config-types.ts +121 -0
- package/src/cli/shared/configure-sections.ts +551 -0
- package/src/cli/shared/discord-config.ts +14 -0
- package/src/cli/shared/init-catalog.ts +189 -0
- package/src/cli/shared/init-models-file.ts +77 -0
- package/src/cli/shared/runtime.ts +33 -0
- package/src/cli/shared/schema-prompts.ts +414 -0
- package/src/cli/tests/config-command.test.ts +56 -0
- package/src/cli/tests/config-io.test.ts +92 -0
- package/src/cli/tests/config-mutators.test.ts +59 -0
- package/src/cli/tests/doctor.test.ts +120 -0
- package/src/cli/tests/init-catalog.test.ts +96 -0
- package/src/cli/tests/program-options.test.ts +113 -0
- package/src/cli/tests/routing-config.test.ts +209 -0
- package/src/core/control-command.ts +12 -0
- package/src/core/dedup-store.ts +103 -0
- package/src/core/gateway.ts +607 -0
- package/src/core/routing.ts +379 -0
- package/src/core/runtime-registry.ts +141 -0
- package/src/core/tests/control-command.test.ts +20 -0
- package/src/core/tests/runtime-registry.test.ts +140 -0
- package/src/core/tests/typing-controller.test.ts +129 -0
- package/src/core/types.ts +318 -0
- package/src/core/typing-controller.ts +119 -0
- package/src/cron/config.ts +154 -0
- package/src/cron/schedule.ts +61 -0
- package/src/cron/service.ts +249 -0
- package/src/cron/store.ts +155 -0
- package/src/cron/types.ts +60 -0
- package/src/extension/loader.ts +145 -0
- package/src/extension/manager.ts +355 -0
- package/src/extension/manifest.ts +26 -0
- package/src/extension/registry.ts +229 -0
- package/src/main.ts +8 -0
- package/src/sandbox/executor.ts +44 -0
- package/src/sandbox/host-executor.ts +118 -0
- package/tsconfig.json +18 -0
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import assert from "node:assert/strict";
|
|
2
|
+
import test from "node:test";
|
|
3
|
+
import {
|
|
4
|
+
buildConfigListEntries,
|
|
5
|
+
CONFIG_SECTION_VALUES,
|
|
6
|
+
isConfigSection,
|
|
7
|
+
previewConfigValue,
|
|
8
|
+
} from "../commands/config.js";
|
|
9
|
+
|
|
10
|
+
test("isConfigSection accepts only supported top-level config sections", () => {
|
|
11
|
+
for (const section of CONFIG_SECTION_VALUES) {
|
|
12
|
+
assert.equal(isConfigSection(section), true);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
assert.equal(isConfigSection("provider"), false);
|
|
16
|
+
assert.equal(isConfigSection("bot"), false);
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
test("previewConfigValue returns stable compact previews", () => {
|
|
20
|
+
assert.equal(previewConfigValue("abc"), "\"abc\"");
|
|
21
|
+
assert.equal(previewConfigValue(123), "123");
|
|
22
|
+
assert.equal(previewConfigValue(true), "true");
|
|
23
|
+
assert.equal(previewConfigValue(null), "null");
|
|
24
|
+
assert.equal(previewConfigValue({ a: 1, b: 2, c: 3, d: 4 }), "{a, b, c, ...}");
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
test("buildConfigListEntries summarizes object values with type and child counts", () => {
|
|
28
|
+
const entries = buildConfigListEntries({
|
|
29
|
+
providers: {
|
|
30
|
+
default: "pi.main",
|
|
31
|
+
items: {
|
|
32
|
+
"pi.main": { type: "provider.pi" },
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
featureFlag: true,
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
assert.deepEqual(
|
|
39
|
+
entries.map((entry) => ({ key: entry.key, type: entry.type, children: entry.children })),
|
|
40
|
+
[
|
|
41
|
+
{ key: "featureFlag", type: "boolean", children: undefined },
|
|
42
|
+
{ key: "providers", type: "object", children: 2 },
|
|
43
|
+
],
|
|
44
|
+
);
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
test("buildConfigListEntries handles primitive roots", () => {
|
|
48
|
+
const entries = buildConfigListEntries("plain");
|
|
49
|
+
assert.deepEqual(entries, [
|
|
50
|
+
{
|
|
51
|
+
key: "(value)",
|
|
52
|
+
type: "string",
|
|
53
|
+
preview: "\"plain\"",
|
|
54
|
+
},
|
|
55
|
+
]);
|
|
56
|
+
});
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import assert from "node:assert/strict";
|
|
2
|
+
import { mkdir, mkdtemp, writeFile } from "node:fs/promises";
|
|
3
|
+
import { homedir } from "node:os";
|
|
4
|
+
import { tmpdir } from "node:os";
|
|
5
|
+
import { resolve } from "node:path";
|
|
6
|
+
import test from "node:test";
|
|
7
|
+
import { DEFAULT_CONFIG_PATH, resolveConfigPath, resolveDataRootDir } from "../shared/config-io.js";
|
|
8
|
+
|
|
9
|
+
test("resolveConfigPath defaults to $HOME/.dobby/gateway.json", () => {
|
|
10
|
+
assert.equal(DEFAULT_CONFIG_PATH, resolve(homedir(), ".dobby", "gateway.json"));
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
test("resolveConfigPath falls back to default path outside dobby repository", async () => {
|
|
14
|
+
const cwd = await mkdtemp(resolve(tmpdir(), "dobby-config-path-default-"));
|
|
15
|
+
assert.equal(resolveConfigPath({ cwd, env: {} }), DEFAULT_CONFIG_PATH);
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
test("resolveConfigPath detects local dobby repository config path", async () => {
|
|
19
|
+
const repoRoot = await mkdtemp(resolve(tmpdir(), "dobby-config-path-repo-"));
|
|
20
|
+
await mkdir(resolve(repoRoot, "config"), { recursive: true });
|
|
21
|
+
await mkdir(resolve(repoRoot, "scripts"), { recursive: true });
|
|
22
|
+
await mkdir(resolve(repoRoot, "src", "cli"), { recursive: true });
|
|
23
|
+
|
|
24
|
+
await writeFile(resolve(repoRoot, "package.json"), JSON.stringify({ name: "dobby" }), "utf-8");
|
|
25
|
+
await writeFile(resolve(repoRoot, "config", "gateway.json"), "{}", "utf-8");
|
|
26
|
+
await writeFile(resolve(repoRoot, "scripts", "local-extensions.mjs"), "#!/usr/bin/env node\n", "utf-8");
|
|
27
|
+
|
|
28
|
+
assert.equal(
|
|
29
|
+
resolveConfigPath({
|
|
30
|
+
cwd: resolve(repoRoot, "src", "cli"),
|
|
31
|
+
env: {},
|
|
32
|
+
}),
|
|
33
|
+
resolve(repoRoot, "config", "gateway.json"),
|
|
34
|
+
);
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
test("resolveConfigPath prioritizes DOBBY_CONFIG_PATH over repository detection", async () => {
|
|
38
|
+
const repoRoot = await mkdtemp(resolve(tmpdir(), "dobby-config-path-env-priority-"));
|
|
39
|
+
await mkdir(resolve(repoRoot, "config"), { recursive: true });
|
|
40
|
+
await mkdir(resolve(repoRoot, "scripts"), { recursive: true });
|
|
41
|
+
await writeFile(resolve(repoRoot, "package.json"), JSON.stringify({ name: "dobby" }), "utf-8");
|
|
42
|
+
await writeFile(resolve(repoRoot, "config", "gateway.json"), "{}", "utf-8");
|
|
43
|
+
await writeFile(resolve(repoRoot, "scripts", "local-extensions.mjs"), "#!/usr/bin/env node\n", "utf-8");
|
|
44
|
+
|
|
45
|
+
const customPath = resolve(tmpdir(), "dobby-custom-gateway.json");
|
|
46
|
+
assert.equal(
|
|
47
|
+
resolveConfigPath({
|
|
48
|
+
cwd: repoRoot,
|
|
49
|
+
env: { DOBBY_CONFIG_PATH: customPath },
|
|
50
|
+
}),
|
|
51
|
+
customPath,
|
|
52
|
+
);
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
test("resolveConfigPath supports relative and home-prefixed DOBBY_CONFIG_PATH", async () => {
|
|
56
|
+
const cwd = await mkdtemp(resolve(tmpdir(), "dobby-config-path-env-expand-"));
|
|
57
|
+
|
|
58
|
+
assert.equal(
|
|
59
|
+
resolveConfigPath({
|
|
60
|
+
cwd,
|
|
61
|
+
env: { DOBBY_CONFIG_PATH: "config/local-gateway.json" },
|
|
62
|
+
}),
|
|
63
|
+
resolve(cwd, "config/local-gateway.json"),
|
|
64
|
+
);
|
|
65
|
+
|
|
66
|
+
assert.equal(
|
|
67
|
+
resolveConfigPath({
|
|
68
|
+
cwd,
|
|
69
|
+
env: { DOBBY_CONFIG_PATH: "~/custom-gateway.json" },
|
|
70
|
+
}),
|
|
71
|
+
resolve(homedir(), "custom-gateway.json"),
|
|
72
|
+
);
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
test("resolveDataRootDir uses repo root for repo-local config/gateway.json", async () => {
|
|
76
|
+
const repoRoot = await mkdtemp(resolve(tmpdir(), "dobby-data-root-repo-"));
|
|
77
|
+
await mkdir(resolve(repoRoot, "config"), { recursive: true });
|
|
78
|
+
await mkdir(resolve(repoRoot, "scripts"), { recursive: true });
|
|
79
|
+
|
|
80
|
+
await writeFile(resolve(repoRoot, "package.json"), JSON.stringify({ name: "dobby" }), "utf-8");
|
|
81
|
+
await writeFile(resolve(repoRoot, "config", "gateway.json"), "{}", "utf-8");
|
|
82
|
+
await writeFile(resolve(repoRoot, "scripts", "local-extensions.mjs"), "#!/usr/bin/env node\n", "utf-8");
|
|
83
|
+
|
|
84
|
+
assert.equal(
|
|
85
|
+
resolveDataRootDir(resolve(repoRoot, "config", "gateway.json"), {
|
|
86
|
+
data: {
|
|
87
|
+
rootDir: "./data",
|
|
88
|
+
},
|
|
89
|
+
}),
|
|
90
|
+
resolve(repoRoot, "data"),
|
|
91
|
+
);
|
|
92
|
+
});
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import test from "node:test";
|
|
2
|
+
import assert from "node:assert/strict";
|
|
3
|
+
import {
|
|
4
|
+
applyContributionTemplates,
|
|
5
|
+
ensureGatewayConfigShape,
|
|
6
|
+
setDefaultProviderIfMissingOrInvalid,
|
|
7
|
+
upsertAllowListPackage,
|
|
8
|
+
} from "../shared/config-mutators.js";
|
|
9
|
+
|
|
10
|
+
test("upsertAllowListPackage is idempotent", () => {
|
|
11
|
+
const config = ensureGatewayConfigShape({});
|
|
12
|
+
upsertAllowListPackage(config, "@dobby.ai/provider-pi", true);
|
|
13
|
+
upsertAllowListPackage(config, "@dobby.ai/provider-pi", true);
|
|
14
|
+
|
|
15
|
+
assert.equal(config.extensions?.allowList?.length, 1);
|
|
16
|
+
assert.equal(config.extensions?.allowList?.[0]?.package, "@dobby.ai/provider-pi");
|
|
17
|
+
assert.equal(config.extensions?.allowList?.[0]?.enabled, true);
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
test("applyContributionTemplates allocates new instance IDs when needed", () => {
|
|
21
|
+
const config = ensureGatewayConfigShape({
|
|
22
|
+
providers: {
|
|
23
|
+
default: "pi.main",
|
|
24
|
+
items: {
|
|
25
|
+
"pi.main": {
|
|
26
|
+
type: "provider.pi",
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
const added = applyContributionTemplates(config, {
|
|
33
|
+
providers: [
|
|
34
|
+
{ id: "pi.main", type: "provider.another", config: {} },
|
|
35
|
+
{ id: "pi.main", type: "provider.third", config: {} },
|
|
36
|
+
],
|
|
37
|
+
connectors: [],
|
|
38
|
+
sandboxes: [],
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
assert.deepEqual(added.providers, ["pi.main-2", "pi.main-3"]);
|
|
42
|
+
assert.equal(config.providers.items["pi.main-2"]?.type, "provider.another");
|
|
43
|
+
assert.equal(config.providers.items["pi.main-3"]?.type, "provider.third");
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
test("setDefaultProviderIfMissingOrInvalid picks lexicographically first provider", () => {
|
|
47
|
+
const config = ensureGatewayConfigShape({
|
|
48
|
+
providers: {
|
|
49
|
+
default: "missing",
|
|
50
|
+
items: {
|
|
51
|
+
"z.main": { type: "provider.z" },
|
|
52
|
+
"a.main": { type: "provider.a" },
|
|
53
|
+
},
|
|
54
|
+
},
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
setDefaultProviderIfMissingOrInvalid(config);
|
|
58
|
+
assert.equal(config.providers.default, "a.main");
|
|
59
|
+
});
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import assert from "node:assert/strict";
|
|
2
|
+
import { spawn } from "node:child_process";
|
|
3
|
+
import { mkdtemp, mkdir, rm, writeFile } from "node:fs/promises";
|
|
4
|
+
import { tmpdir } from "node:os";
|
|
5
|
+
import { join } from "node:path";
|
|
6
|
+
import test from "node:test";
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Writes a temporary default config under HOME/.dobby/gateway.json.
|
|
10
|
+
*/
|
|
11
|
+
async function writeTempHomeConfig(homeDir: string, payload: unknown): Promise<string> {
|
|
12
|
+
const dobbyDir = join(homeDir, ".dobby");
|
|
13
|
+
await mkdir(dobbyDir, { recursive: true });
|
|
14
|
+
const configPath = join(dobbyDir, "gateway.json");
|
|
15
|
+
await writeFile(configPath, `${JSON.stringify(payload, null, 2)}\n`, "utf-8");
|
|
16
|
+
return configPath;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Runs `dobby doctor` in a child process with an isolated HOME directory.
|
|
21
|
+
*/
|
|
22
|
+
async function runDoctorWithHome(homeDir: string, configPath: string): Promise<{ code: number | null; output: string }> {
|
|
23
|
+
return await new Promise((resolve, reject) => {
|
|
24
|
+
const child = spawn(
|
|
25
|
+
process.execPath,
|
|
26
|
+
["--import", "tsx", "src/main.ts", "doctor"],
|
|
27
|
+
{
|
|
28
|
+
cwd: process.cwd(),
|
|
29
|
+
env: {
|
|
30
|
+
...process.env,
|
|
31
|
+
HOME: homeDir,
|
|
32
|
+
DOBBY_CONFIG_PATH: configPath,
|
|
33
|
+
},
|
|
34
|
+
stdio: ["ignore", "pipe", "pipe"],
|
|
35
|
+
},
|
|
36
|
+
);
|
|
37
|
+
|
|
38
|
+
let output = "";
|
|
39
|
+
child.stdout.on("data", (chunk) => {
|
|
40
|
+
output += String(chunk);
|
|
41
|
+
});
|
|
42
|
+
child.stderr.on("data", (chunk) => {
|
|
43
|
+
output += String(chunk);
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
child.once("error", (error) => reject(error));
|
|
47
|
+
child.once("close", (code) => {
|
|
48
|
+
resolve({ code, output });
|
|
49
|
+
});
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
test("doctor reports invalid binding route references", async () => {
|
|
54
|
+
const homeDir = await mkdtemp(join(tmpdir(), "dobby-doctor-home-"));
|
|
55
|
+
|
|
56
|
+
try {
|
|
57
|
+
const configPath = await writeTempHomeConfig(homeDir, {
|
|
58
|
+
extensions: { allowList: [] },
|
|
59
|
+
providers: {
|
|
60
|
+
default: "pi.main",
|
|
61
|
+
items: {
|
|
62
|
+
"pi.main": {
|
|
63
|
+
type: "provider.pi",
|
|
64
|
+
},
|
|
65
|
+
},
|
|
66
|
+
},
|
|
67
|
+
connectors: {
|
|
68
|
+
items: {
|
|
69
|
+
"discord.main": {
|
|
70
|
+
type: "connector.discord",
|
|
71
|
+
botName: "dobby-main",
|
|
72
|
+
botToken: "token",
|
|
73
|
+
},
|
|
74
|
+
},
|
|
75
|
+
},
|
|
76
|
+
sandboxes: {
|
|
77
|
+
default: "host.builtin",
|
|
78
|
+
items: {},
|
|
79
|
+
},
|
|
80
|
+
routes: {
|
|
81
|
+
defaults: {
|
|
82
|
+
provider: "pi.main",
|
|
83
|
+
sandbox: "host.builtin",
|
|
84
|
+
tools: "full",
|
|
85
|
+
mentions: "required",
|
|
86
|
+
},
|
|
87
|
+
items: {
|
|
88
|
+
main: {
|
|
89
|
+
projectRoot: process.cwd(),
|
|
90
|
+
},
|
|
91
|
+
},
|
|
92
|
+
},
|
|
93
|
+
bindings: {
|
|
94
|
+
items: {
|
|
95
|
+
"discord.main.123": {
|
|
96
|
+
connector: "discord.main",
|
|
97
|
+
source: {
|
|
98
|
+
type: "channel",
|
|
99
|
+
id: "123",
|
|
100
|
+
},
|
|
101
|
+
route: "missing-route",
|
|
102
|
+
},
|
|
103
|
+
},
|
|
104
|
+
},
|
|
105
|
+
data: {
|
|
106
|
+
rootDir: "./data",
|
|
107
|
+
dedupTtlMs: 604800000,
|
|
108
|
+
},
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
const result = await runDoctorWithHome(homeDir, configPath);
|
|
112
|
+
assert.equal(result.code, 1);
|
|
113
|
+
assert.equal(
|
|
114
|
+
result.output.includes("bindings.items['discord.main.123'].route") && result.output.includes("missing-route"),
|
|
115
|
+
true,
|
|
116
|
+
);
|
|
117
|
+
} finally {
|
|
118
|
+
await rm(homeDir, { recursive: true, force: true });
|
|
119
|
+
}
|
|
120
|
+
});
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import assert from "node:assert/strict";
|
|
2
|
+
import test from "node:test";
|
|
3
|
+
import { createInitSelectionConfig } from "../shared/init-catalog.js";
|
|
4
|
+
|
|
5
|
+
test("createInitSelectionConfig wires explicit Discord bot config for provider.pi", () => {
|
|
6
|
+
const selected = createInitSelectionConfig(["provider.pi"], "connector.discord", {
|
|
7
|
+
routeId: "main",
|
|
8
|
+
projectRoot: "/tmp/project",
|
|
9
|
+
allowAllMessages: false,
|
|
10
|
+
botName: "dobby-main",
|
|
11
|
+
botToken: "token-abc",
|
|
12
|
+
channelId: "123",
|
|
13
|
+
routeProviderChoiceId: "provider.pi",
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
assert.deepEqual(selected.connectorConfig, {
|
|
17
|
+
botName: "dobby-main",
|
|
18
|
+
botToken: "token-abc",
|
|
19
|
+
reconnectStaleMs: 60_000,
|
|
20
|
+
reconnectCheckIntervalMs: 10_000,
|
|
21
|
+
});
|
|
22
|
+
assert.deepEqual(selected.providerChoiceIds, ["provider.pi"]);
|
|
23
|
+
assert.equal(selected.providerInstances.length, 1);
|
|
24
|
+
assert.equal(selected.providerInstanceId, "pi.main");
|
|
25
|
+
assert.equal(selected.providerContributionId, "provider.pi");
|
|
26
|
+
assert.equal(selected.routeProfile.provider, "pi.main");
|
|
27
|
+
assert.equal(selected.routeProfile.mentions, "required");
|
|
28
|
+
assert.equal(selected.bindingId, "discord.main.main");
|
|
29
|
+
assert.deepEqual(selected.bindingConfig, {
|
|
30
|
+
connector: "discord.main",
|
|
31
|
+
source: {
|
|
32
|
+
type: "channel",
|
|
33
|
+
id: "123",
|
|
34
|
+
},
|
|
35
|
+
route: "main",
|
|
36
|
+
});
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
test("createInitSelectionConfig wires explicit Discord bot config for provider.claude-cli", () => {
|
|
40
|
+
const selected = createInitSelectionConfig(["provider.claude-cli"], "connector.discord", {
|
|
41
|
+
routeId: "support",
|
|
42
|
+
projectRoot: "/tmp/project",
|
|
43
|
+
allowAllMessages: true,
|
|
44
|
+
botName: "ops-bot",
|
|
45
|
+
botToken: "token-xyz",
|
|
46
|
+
channelId: "999",
|
|
47
|
+
routeProviderChoiceId: "provider.claude-cli",
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
assert.deepEqual(selected.connectorConfig, {
|
|
51
|
+
botName: "ops-bot",
|
|
52
|
+
botToken: "token-xyz",
|
|
53
|
+
reconnectStaleMs: 60_000,
|
|
54
|
+
reconnectCheckIntervalMs: 10_000,
|
|
55
|
+
});
|
|
56
|
+
assert.deepEqual(selected.providerChoiceIds, ["provider.claude-cli"]);
|
|
57
|
+
assert.equal(selected.providerInstances.length, 1);
|
|
58
|
+
assert.equal(selected.providerInstanceId, "claude-cli.main");
|
|
59
|
+
assert.equal(selected.providerContributionId, "provider.claude-cli");
|
|
60
|
+
assert.equal(selected.routeProfile.provider, "claude-cli.main");
|
|
61
|
+
assert.equal(selected.routeProfile.mentions, "optional");
|
|
62
|
+
assert.deepEqual(selected.bindingConfig, {
|
|
63
|
+
connector: "discord.main",
|
|
64
|
+
source: {
|
|
65
|
+
type: "channel",
|
|
66
|
+
id: "999",
|
|
67
|
+
},
|
|
68
|
+
route: "support",
|
|
69
|
+
});
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
test("createInitSelectionConfig supports multiple providers and uses explicit route provider", () => {
|
|
73
|
+
const selected = createInitSelectionConfig(["provider.pi", "provider.claude-cli"], "connector.discord", {
|
|
74
|
+
routeId: "ops",
|
|
75
|
+
projectRoot: "/tmp/project",
|
|
76
|
+
allowAllMessages: false,
|
|
77
|
+
botName: "dobby-multi",
|
|
78
|
+
botToken: "token-multi",
|
|
79
|
+
channelId: "777",
|
|
80
|
+
routeProviderChoiceId: "provider.claude-cli",
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
assert.deepEqual(selected.providerChoiceIds, ["provider.pi", "provider.claude-cli"]);
|
|
84
|
+
assert.deepEqual(
|
|
85
|
+
selected.providerInstances.map((item) => item.instanceId),
|
|
86
|
+
["pi.main", "claude-cli.main"],
|
|
87
|
+
);
|
|
88
|
+
assert.deepEqual(selected.extensionPackages, [
|
|
89
|
+
"@dobby.ai/provider-pi",
|
|
90
|
+
"@dobby.ai/provider-claude-cli",
|
|
91
|
+
"@dobby.ai/connector-discord",
|
|
92
|
+
]);
|
|
93
|
+
assert.equal(selected.providerInstanceId, "claude-cli.main");
|
|
94
|
+
assert.equal(selected.routeProfile.provider, "claude-cli.main");
|
|
95
|
+
assert.equal(selected.routeProviderChoiceId, "provider.claude-cli");
|
|
96
|
+
});
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import assert from "node:assert/strict";
|
|
2
|
+
import test from "node:test";
|
|
3
|
+
import { CommanderError } from "commander";
|
|
4
|
+
import { buildProgram } from "../program.js";
|
|
5
|
+
|
|
6
|
+
test("CLI rejects --config option", async () => {
|
|
7
|
+
const program = buildProgram();
|
|
8
|
+
program.configureOutput({
|
|
9
|
+
writeErr: () => {},
|
|
10
|
+
writeOut: () => {},
|
|
11
|
+
});
|
|
12
|
+
program.exitOverride();
|
|
13
|
+
|
|
14
|
+
await assert.rejects(
|
|
15
|
+
program.parseAsync(["node", "dobby", "--config", "./config/gateway.json"]),
|
|
16
|
+
(error) => {
|
|
17
|
+
assert.equal(error instanceof CommanderError, true);
|
|
18
|
+
assert.equal((error as CommanderError).code, "commander.unknownOption");
|
|
19
|
+
assert.match(String((error as CommanderError).message), /unknown option '--config'/i);
|
|
20
|
+
return true;
|
|
21
|
+
},
|
|
22
|
+
);
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
test("init help has no merge/overwrite flags", () => {
|
|
26
|
+
const program = buildProgram();
|
|
27
|
+
const initCommand = program.commands.find((command) => command.name() === "init");
|
|
28
|
+
assert.ok(initCommand);
|
|
29
|
+
|
|
30
|
+
const help = initCommand.helpInformation();
|
|
31
|
+
assert.equal(help.includes("--merge"), false);
|
|
32
|
+
assert.equal(help.includes("--merge-strategy"), false);
|
|
33
|
+
assert.equal(help.includes("--overwrite"), false);
|
|
34
|
+
|
|
35
|
+
assert.equal(help.includes("--preset"), false);
|
|
36
|
+
assert.equal(help.includes("--non-interactive"), false);
|
|
37
|
+
assert.equal(help.includes("--yes"), false);
|
|
38
|
+
assert.equal(help.includes("--config"), false);
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
test("config help shows show/list/edit and schema", () => {
|
|
42
|
+
const program = buildProgram();
|
|
43
|
+
const configCommand = program.commands.find((command) => command.name() === "config");
|
|
44
|
+
assert.ok(configCommand);
|
|
45
|
+
|
|
46
|
+
const help = configCommand.helpInformation();
|
|
47
|
+
assert.match(help, /show \[options\] \[section\]/);
|
|
48
|
+
assert.match(help, /list \[options\] \[section\]/);
|
|
49
|
+
assert.match(help, /edit \[options\]/);
|
|
50
|
+
assert.match(help, /schema/);
|
|
51
|
+
|
|
52
|
+
assert.equal(help.includes("get"), false);
|
|
53
|
+
assert.equal(help.includes("set"), false);
|
|
54
|
+
assert.equal(help.includes("unset"), false);
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
test("config schema help shows list/show subcommands", () => {
|
|
58
|
+
const program = buildProgram();
|
|
59
|
+
const configCommand = program.commands.find((command) => command.name() === "config");
|
|
60
|
+
assert.ok(configCommand);
|
|
61
|
+
|
|
62
|
+
const schemaCommand = configCommand.commands.find((command) => command.name() === "schema");
|
|
63
|
+
assert.ok(schemaCommand);
|
|
64
|
+
|
|
65
|
+
const help = schemaCommand.helpInformation();
|
|
66
|
+
assert.match(help, /list \[options\]/);
|
|
67
|
+
assert.match(help, /show \[options\] <contributionId>/);
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
test("cron help shows core subcommands", () => {
|
|
71
|
+
const program = buildProgram();
|
|
72
|
+
const cronCommand = program.commands.find((command) => command.name() === "cron");
|
|
73
|
+
assert.ok(cronCommand);
|
|
74
|
+
|
|
75
|
+
const help = cronCommand.helpInformation();
|
|
76
|
+
assert.match(help, /add \[options\] <name>/);
|
|
77
|
+
assert.match(help, /list \[options\]/);
|
|
78
|
+
assert.match(help, /run \[options\] <jobId>/);
|
|
79
|
+
assert.match(help, /remove \[options\] <jobId>/);
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
test("binding help shows list, set, and remove subcommands", () => {
|
|
83
|
+
const program = buildProgram();
|
|
84
|
+
const bindingCommand = program.commands.find((command) => command.name() === "binding");
|
|
85
|
+
assert.ok(bindingCommand);
|
|
86
|
+
|
|
87
|
+
const help = bindingCommand.helpInformation();
|
|
88
|
+
assert.match(help, /list \[options\]/);
|
|
89
|
+
assert.match(help, /set \[options\] <bindingId>/);
|
|
90
|
+
assert.match(help, /remove <bindingId>/);
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
test("route help reflects provider, sandbox, mentions, and cascade-bindings options", () => {
|
|
94
|
+
const program = buildProgram();
|
|
95
|
+
const routeCommand = program.commands.find((command) => command.name() === "route");
|
|
96
|
+
assert.ok(routeCommand);
|
|
97
|
+
|
|
98
|
+
const setCommand = routeCommand.commands.find((command) => command.name() === "set");
|
|
99
|
+
const removeCommand = routeCommand.commands.find((command) => command.name() === "remove");
|
|
100
|
+
assert.ok(setCommand);
|
|
101
|
+
assert.ok(removeCommand);
|
|
102
|
+
|
|
103
|
+
const setHelp = setCommand.helpInformation();
|
|
104
|
+
const removeHelp = removeCommand.helpInformation();
|
|
105
|
+
assert.match(setHelp, /--provider <id>/);
|
|
106
|
+
assert.match(setHelp, /--sandbox <id>/);
|
|
107
|
+
assert.match(setHelp, /--mentions <policy>/);
|
|
108
|
+
assert.equal(setHelp.includes("--provider-id"), false);
|
|
109
|
+
assert.equal(setHelp.includes("--sandbox-id"), false);
|
|
110
|
+
assert.equal(setHelp.includes("--mentions-only"), false);
|
|
111
|
+
assert.equal(setHelp.includes("--default"), false);
|
|
112
|
+
assert.match(removeHelp, /--cascade-bindings/);
|
|
113
|
+
});
|