pi-roundtable 0.53.5 → 0.54.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/CHANGELOG.md +19 -0
- package/README.md +14 -2
- package/README.zh-TW.md +14 -2
- package/docs/plugins.md +201 -8
- package/package.json +3 -1
- package/runner/Dockerfile +46 -0
- package/runner/Dockerfile.dockerignore +5 -0
- package/src/cli/checks/images.ts +3 -2
- package/src/cli/checks/preset.ts +20 -0
- package/src/cli/checks/runner.ts +45 -0
- package/src/cli/doctor.ts +7 -1
- package/src/core/agents/agent-claim.ts +7 -4
- package/src/core/agents/agent-prompt.ts +11 -2
- package/src/core/agents/helper-workspace.ts +72 -0
- package/src/core/agents/team-options.ts +2 -0
- package/src/core/agents/team-prompt.ts +12 -1
- package/src/core/attachments/attachment-expiry.ts +12 -0
- package/src/core/attachments/attachment-store.ts +20 -5
- package/src/core/attachments/model-images.ts +3 -2
- package/src/core/builtin/agent-server.ts +8 -0
- package/src/core/builtin/polls.ts +67 -0
- package/src/core/builtin/runner.ts +139 -0
- package/src/core/config/config-schema.ts +4 -0
- package/src/core/config/config.ts +49 -185
- package/src/core/config/preset.ts +51 -0
- package/src/core/config/resolve-config.ts +175 -0
- package/src/core/config/runner-config.ts +80 -0
- package/src/core/contract/attachments.ts +2 -0
- package/src/core/contract/polls.ts +71 -0
- package/src/core/contract/runtime.ts +12 -0
- package/src/core/contract/surface.ts +13 -0
- package/src/core/discord/discord-polls.ts +156 -0
- package/src/core/discord/discord-replies.ts +55 -0
- package/src/core/discord/discord-surface.ts +13 -43
- package/src/core/domain/client.ts +6 -2
- package/src/core/domain/errors.ts +5 -0
- package/src/core/domain/sessions.ts +8 -1
- package/src/core/host/define-roundtable.ts +8 -0
- package/src/core/host/host-registration.ts +7 -0
- package/src/core/host/host.ts +8 -0
- package/src/core/i18n/schedules.ts +2 -0
- package/src/core/modules/polls/poll-result-turns.ts +124 -0
- package/src/core/modules/polls/poll-rules.ts +108 -0
- package/src/core/modules/polls/poll-service.ts +477 -0
- package/src/core/modules/polls/poll-store.ts +336 -0
- package/src/core/modules/polls/poll-tools.ts +118 -0
- package/src/core/modules/polls/poll-turn-text.ts +60 -0
- package/src/core/plugin-api/define.ts +9 -2
- package/src/core/plugin-api/holds.ts +2 -0
- package/src/core/plugin-api/plugin.ts +8 -0
- package/src/core/runner/protocol.ts +456 -0
- package/src/core/runner/runner-client.ts +450 -0
- package/src/core/runner/runner-drivers.ts +356 -0
- package/src/core/runner/runner-files.ts +102 -0
- package/src/core/runner/runner-holds.ts +76 -0
- package/src/core/runner/runner-port.ts +77 -0
- package/src/core/runner/runner-probe.ts +53 -0
- package/src/core/runner/runner-prompt.ts +36 -0
- package/src/core/runner/runner-session.ts +131 -0
- package/src/core/runner/runner-tiers.ts +20 -0
- package/src/core/runner/runner-tools.ts +325 -0
- package/src/core/runner/settings.ts +108 -0
- package/src/core/runtime/conversation-sessions.ts +73 -15
- package/src/core/runtime/extensions/approval-card.ts +29 -2
- package/src/core/runtime/extensions/confirmation-gate.ts +24 -63
- package/src/core/runtime/extensions/gate-card.ts +105 -0
- package/src/core/runtime/extensions/yolo.ts +17 -3
- package/src/core/runtime/pi-agent-runtime.ts +37 -68
- package/src/core/runtime/runtime-plugin.ts +9 -0
- package/src/core/runtime/runtime-types.ts +29 -1
- package/src/core/runtime/session-factory.ts +59 -62
- package/src/core/runtime/session-shell.ts +43 -0
- package/src/core/runtime/session-tool-names.ts +78 -0
- package/src/core/runtime/turn-selection.ts +97 -0
- package/src/core/shared/attachment-reader.ts +10 -1
- package/src/core/shared/generate-image-tool.ts +4 -4
- package/src/core/shared/poll-target.ts +14 -0
- package/src/core/shared/workspace-files.ts +42 -4
- package/src/core/testing/fake-polls.ts +131 -0
- package/src/core/testing/fake-runner.ts +146 -0
- package/src/core/testing/surface-contract-approvals.ts +215 -0
- package/src/core/testing/surface-contract-polls.ts +142 -0
- package/src/core/testing/surface-contract.ts +32 -208
- package/src/core/tool-set.snapshot.json +8 -0
- package/src/index.ts +17 -0
- package/src/kit/index.ts +6 -0
- package/src/kit/polls.ts +8 -0
- package/src/runner-server/exec.ts +174 -0
- package/src/runner-server/file-helper.ts +208 -0
- package/src/runner-server/files.ts +93 -0
- package/src/runner-server/host.ts +65 -0
- package/src/runner-server/main.ts +89 -0
- package/src/runner-server/server.ts +318 -0
- package/src/runner-server/shared-dirs.ts +45 -0
- package/src/runner-server/state.ts +293 -0
- package/src/runner-server/transports.ts +187 -0
- package/src/testing.ts +7 -0
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import { ConfigError } from "../domain/errors.ts";
|
|
2
|
+
import type { Logger } from "../kernel/log.ts";
|
|
3
|
+
import type { RoundtablePlugin, Service } from "../plugin-api/plugin.ts";
|
|
4
|
+
import { RunnerClient, type RunnerDriver } from "../runner/runner-client.ts";
|
|
5
|
+
import { DockerDriver, socketDriver } from "../runner/runner-drivers.ts";
|
|
6
|
+
import { runnerShellRule } from "../runner/runner-holds.ts";
|
|
7
|
+
import { RUNNER } from "../runner/runner-port.ts";
|
|
8
|
+
import type { RunnerSettings } from "../runner/settings.ts";
|
|
9
|
+
|
|
10
|
+
/** The name of the runner's plugin. */
|
|
11
|
+
export const RUNNER_PLUGIN = "runner";
|
|
12
|
+
|
|
13
|
+
/** The wait between two sweeps of idle workspaces. */
|
|
14
|
+
export const RUNNER_SWEEP_EVERY_MS = 24 * 60 * 60_000;
|
|
15
|
+
|
|
16
|
+
/** A driver and what it checks before the host starts. */
|
|
17
|
+
export interface RunnerStart {
|
|
18
|
+
driver: RunnerDriver;
|
|
19
|
+
/**
|
|
20
|
+
* Throws a ConfigError when the host must not start, as the docker driver does without the
|
|
21
|
+
* docker CLI or the image; a runner that is only not up yet is logged and the host starts.
|
|
22
|
+
*/
|
|
23
|
+
check(logger: Logger): Promise<void>;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/** The configured driver: the docker CLI's container, or a sidecar's socket. */
|
|
27
|
+
export function runnerStart(
|
|
28
|
+
settings: RunnerSettings,
|
|
29
|
+
dataDir: string,
|
|
30
|
+
): RunnerStart {
|
|
31
|
+
if (settings.driver === "docker") {
|
|
32
|
+
const driver = new DockerDriver(settings, dataDir);
|
|
33
|
+
return { driver, check: () => driver.check() };
|
|
34
|
+
}
|
|
35
|
+
const driver = socketDriver(settings.socket);
|
|
36
|
+
return {
|
|
37
|
+
driver,
|
|
38
|
+
check: async (logger) => {
|
|
39
|
+
// The two containers start in either order: a missing socket is waited for, then logged.
|
|
40
|
+
if (!(await driver.ready()))
|
|
41
|
+
logger.error(
|
|
42
|
+
{ socket: settings.socket },
|
|
43
|
+
"the runner's socket is not there; the runner's tools fail until it is",
|
|
44
|
+
);
|
|
45
|
+
},
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export interface RunnerPluginOptions {
|
|
50
|
+
/** The data directory, which names the docker driver's container. */
|
|
51
|
+
dataDir: string;
|
|
52
|
+
/** The driver for the host's `env.runner`; default `runnerStart`, a test hands its own. */
|
|
53
|
+
start?: (settings: RunnerSettings) => RunnerStart;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* The runner, provided as `RUNNER` for the runtime's sessions, from the host's `env.runner`. At
|
|
58
|
+
* start it checks the driver (a docker host without the CLI or the image stops with a
|
|
59
|
+
* ConfigError naming `runner.image`), then removes the workspaces idle for `keepDays`, and again
|
|
60
|
+
* once a day. It links the `runner-shell` hold rule, which judges only the calls of sessions the
|
|
61
|
+
* runner serves.
|
|
62
|
+
*/
|
|
63
|
+
export function runnerPlugin(options: RunnerPluginOptions): RoundtablePlugin {
|
|
64
|
+
return {
|
|
65
|
+
name: RUNNER_PLUGIN,
|
|
66
|
+
provides: [RUNNER],
|
|
67
|
+
setup: ({ env, logger, services }) => {
|
|
68
|
+
const settings = env.runner;
|
|
69
|
+
if (!settings)
|
|
70
|
+
throw new ConfigError(
|
|
71
|
+
"the runner plugin needs the host's runner setting (environment.runner); set runner in the configuration, or leave the plugin out.",
|
|
72
|
+
);
|
|
73
|
+
const start = (options.start ?? ((s) => runnerStart(s, options.dataDir)))(
|
|
74
|
+
settings,
|
|
75
|
+
);
|
|
76
|
+
const client = new RunnerClient(start.driver);
|
|
77
|
+
services.provide(RUNNER, client);
|
|
78
|
+
return {
|
|
79
|
+
holdRules: [runnerShellRule],
|
|
80
|
+
services: [runnerService(client, start, settings, logger)],
|
|
81
|
+
};
|
|
82
|
+
},
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
function runnerService(
|
|
87
|
+
client: RunnerClient,
|
|
88
|
+
start: RunnerStart,
|
|
89
|
+
settings: RunnerSettings,
|
|
90
|
+
logger: Logger,
|
|
91
|
+
): Service {
|
|
92
|
+
let timer: ReturnType<typeof setInterval> | undefined;
|
|
93
|
+
let sweeping: Promise<void> | undefined;
|
|
94
|
+
const sweep = (): Promise<void> => {
|
|
95
|
+
sweeping ??= client
|
|
96
|
+
.sweep(settings.keepDays)
|
|
97
|
+
.then(
|
|
98
|
+
(removed) => {
|
|
99
|
+
if (removed.length > 0)
|
|
100
|
+
logger.info(
|
|
101
|
+
{ removed: removed.length, keepDays: settings.keepDays },
|
|
102
|
+
"idle runner workspaces removed",
|
|
103
|
+
);
|
|
104
|
+
},
|
|
105
|
+
(error: unknown) =>
|
|
106
|
+
logger.warn({ err: error }, "idle runner workspaces not swept"),
|
|
107
|
+
)
|
|
108
|
+
.finally(() => {
|
|
109
|
+
sweeping = undefined;
|
|
110
|
+
});
|
|
111
|
+
return sweeping;
|
|
112
|
+
};
|
|
113
|
+
return {
|
|
114
|
+
name: "runner",
|
|
115
|
+
start: async () => {
|
|
116
|
+
await start.check(logger);
|
|
117
|
+
try {
|
|
118
|
+
const { version } = await client.ping();
|
|
119
|
+
logger.info(
|
|
120
|
+
{ driver: settings.driver, target: client.target, version },
|
|
121
|
+
"runner reachable",
|
|
122
|
+
);
|
|
123
|
+
} catch (error) {
|
|
124
|
+
logger.error(
|
|
125
|
+
{ driver: settings.driver, target: client.target, err: error },
|
|
126
|
+
"the runner is not reachable; its tools fail until it is",
|
|
127
|
+
);
|
|
128
|
+
}
|
|
129
|
+
void sweep();
|
|
130
|
+
timer = setInterval(() => void sweep(), RUNNER_SWEEP_EVERY_MS);
|
|
131
|
+
},
|
|
132
|
+
stop: async () => {
|
|
133
|
+
clearInterval(timer);
|
|
134
|
+
timer = undefined;
|
|
135
|
+
await sweeping;
|
|
136
|
+
client.end();
|
|
137
|
+
},
|
|
138
|
+
};
|
|
139
|
+
}
|
|
@@ -12,6 +12,7 @@ import { helpersField } from "./helpers.ts";
|
|
|
12
12
|
import { limitsShape } from "./limits.ts";
|
|
13
13
|
import { profilesShape } from "./profiles.ts";
|
|
14
14
|
import { routingShape } from "./routing.ts";
|
|
15
|
+
import { runnerField } from "./runner-config.ts";
|
|
15
16
|
import {
|
|
16
17
|
bool,
|
|
17
18
|
characterInput,
|
|
@@ -118,6 +119,9 @@ export const configSchema = shape({
|
|
|
118
119
|
),
|
|
119
120
|
}),
|
|
120
121
|
),
|
|
122
|
+
preset: optional(oneOf("shared")),
|
|
123
|
+
imageTool: optional(oneOf("every-selection", "selected")),
|
|
124
|
+
runner: optional(runnerField),
|
|
121
125
|
toolTiers: optional(record(oneOf<Tier>("owner", "admin", "member"))),
|
|
122
126
|
prompts: optional(shape({ shared: text, guest: optional(text) })),
|
|
123
127
|
agents: optional(
|
|
@@ -1,14 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { join } from "node:path";
|
|
3
|
-
import { CATALOG, type Hex } from "../../characters/index.ts";
|
|
1
|
+
import type { Hex } from "../../characters/index.ts";
|
|
4
2
|
import type { AgentSeed } from "../agents/agent-rules.ts";
|
|
5
|
-
import { ConfigError } from "../domain/errors.ts";
|
|
6
3
|
import type { InterimTextMode } from "../domain/interim.ts";
|
|
7
|
-
import {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
type ThinkingLevel,
|
|
4
|
+
import type {
|
|
5
|
+
EffortPolicy,
|
|
6
|
+
ModelRef,
|
|
7
|
+
ThinkingLevel,
|
|
12
8
|
} from "../domain/models.ts";
|
|
13
9
|
import type { Locale } from "../i18n/index.ts";
|
|
14
10
|
import type { AccessRules } from "../identity/access-policy.ts";
|
|
@@ -16,40 +12,26 @@ import type { OwnerIdentity } from "../identity/owner-identity.ts";
|
|
|
16
12
|
import type { ProfileRules } from "../identity/profiles.ts";
|
|
17
13
|
import type { Tier, TierMembers } from "../identity/speakers.ts";
|
|
18
14
|
import type { AgentTools, RoundtablePlugin } from "../plugin-api/plugin.ts";
|
|
19
|
-
import {
|
|
15
|
+
import type { RunnerConfig, RunnerSettings } from "../runner/settings.ts";
|
|
20
16
|
import type { ShellEnvConfig } from "../shared/child-env.ts";
|
|
21
17
|
import type { PerPrincipalLimits } from "../shared/personal-target.ts";
|
|
22
|
-
import {
|
|
23
|
-
import {
|
|
24
|
-
type DiscordConfig,
|
|
25
|
-
liftAdapters,
|
|
26
|
-
type ResolvedDiscord,
|
|
27
|
-
resolvedDiscord,
|
|
28
|
-
} from "./adapters.ts";
|
|
29
|
-
import {
|
|
30
|
-
checkAgentGuild,
|
|
31
|
-
checkAgentServerOff,
|
|
32
|
-
checkAgentTeamKeys,
|
|
33
|
-
} from "./agent-team.ts";
|
|
18
|
+
import type { AccessConfig } from "./access.ts";
|
|
19
|
+
import type { DiscordConfig, ResolvedDiscord } from "./adapters.ts";
|
|
34
20
|
import type { AttachmentsConfig } from "./attachments.ts";
|
|
35
|
-
import { configSchema, DRAIN_LIMIT_MS } from "./config-schema.ts";
|
|
36
21
|
import type { ConversationsConfig } from "./conversations.ts";
|
|
37
|
-
import {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
} from "./
|
|
42
|
-
import { type LimitsConfig, limitsOf, type ResolvedLimits } from "./limits.ts";
|
|
43
|
-
import { opsOf, opsOfPlace, type ResolvedOps } from "./ops.ts";
|
|
44
|
-
import { type ProfilesConfig, profileRulesOf } from "./profiles.ts";
|
|
45
|
-
import {
|
|
46
|
-
type ResolvedRouting,
|
|
47
|
-
type RoutingConfig,
|
|
48
|
-
routingOf,
|
|
49
|
-
} from "./routing.ts";
|
|
22
|
+
import type { HelpersConfig, ResolvedHelpers } from "./helpers.ts";
|
|
23
|
+
import type { LimitsConfig, ResolvedLimits } from "./limits.ts";
|
|
24
|
+
import type { ResolvedOps } from "./ops.ts";
|
|
25
|
+
import type { ProfilesConfig } from "./profiles.ts";
|
|
26
|
+
import type { ResolvedRouting, RoutingConfig } from "./routing.ts";
|
|
50
27
|
import type { SkillsConfig } from "./skills-config.ts";
|
|
51
|
-
import {
|
|
28
|
+
import type { ResolvedTeam, TeamConfig } from "./team.ts";
|
|
52
29
|
|
|
30
|
+
export {
|
|
31
|
+
AVATAR_DEPRECATION,
|
|
32
|
+
OPS_DEPRECATION,
|
|
33
|
+
resolveConfig,
|
|
34
|
+
} from "./resolve-config.ts";
|
|
53
35
|
export type { DiscordConfig };
|
|
54
36
|
|
|
55
37
|
/** How prompts refer back to the owner. */
|
|
@@ -85,6 +67,15 @@ export interface BackgroundConfig {
|
|
|
85
67
|
export interface RoundtableConfig extends LimitsConfig, ShellEnvConfig {
|
|
86
68
|
/** The assistant's display name; default "Roundtable". */
|
|
87
69
|
name?: string;
|
|
70
|
+
/**
|
|
71
|
+
* Defaults for one kind of host, under every key the configuration writes itself. `"shared"`
|
|
72
|
+
* is a host many people talk to: it requires `runner`, so every conversation but the owner's
|
|
73
|
+
* own runs `bash`, `read`, `edit` and `write` in the runner's container (and a persona's
|
|
74
|
+
* selection may name them on a chat-only host), sets `imageTool: "selected"`, and gives
|
|
75
|
+
* `generate_image`, `poll_create` and `poll_end` the `member` tier in `toolTiers`. A selection
|
|
76
|
+
* still has to name each tool. Left out, nothing is preset.
|
|
77
|
+
*/
|
|
78
|
+
preset?: "shared";
|
|
88
79
|
/**
|
|
89
80
|
* The one owner, as 0.8 wrote it: their id, which is both their principal and their Discord
|
|
90
81
|
* user id, their name, and pronouns. Deprecated, going away in 0.10: write `access` instead,
|
|
@@ -164,6 +155,15 @@ export interface RoundtableConfig extends LimitsConfig, ShellEnvConfig {
|
|
|
164
155
|
* `perPrincipal.delegations` running at once. Unset, only each conversation's, as in 0.8.
|
|
165
156
|
*/
|
|
166
157
|
background?: BackgroundConfig;
|
|
158
|
+
imageTool?: "every-selection" | "selected";
|
|
159
|
+
/**
|
|
160
|
+
* The runner container where multi-user conversations' `bash`, `read`, `edit` and `write` run:
|
|
161
|
+
* `{ driver: "docker", image }` for a container the host runs with the docker CLI, or
|
|
162
|
+
* `{ driver: "socket", socket }` for a sidecar's socket. Every conversation but the owner's own
|
|
163
|
+
* then uses it, agents' included unless `agentServer.tools` is "chat-only"; it holds no
|
|
164
|
+
* credential and reaches no network. Without it every tool runs as before. See `RunnerConfig`.
|
|
165
|
+
*/
|
|
166
|
+
runner?: RunnerConfig;
|
|
167
167
|
toolTiers?: Record<string, Tier>;
|
|
168
168
|
/** Prompt files, read once at start; `shared` starts every agent's prompt. */
|
|
169
169
|
prompts?: { shared: string; guest?: string };
|
|
@@ -266,17 +266,18 @@ export interface RoundtableConfig extends LimitsConfig, ShellEnvConfig {
|
|
|
266
266
|
plugins?: RoundtablePlugin[];
|
|
267
267
|
}
|
|
268
268
|
|
|
269
|
-
/** Logged once when the top-level `ops` is set: it is an alias of the `ops` place. */
|
|
270
|
-
export const OPS_DEPRECATION =
|
|
271
|
-
"`ops` is an alias of `routing.places.ops` since 0.27 and goes away in 1.0; move it there";
|
|
272
|
-
|
|
273
|
-
/** Logged once when `avatar` is set: agents are composed characters and no picture is drawn from it. */
|
|
274
|
-
export const AVATAR_DEPRECATION =
|
|
275
|
-
"agents are composed characters since 0.23; `avatar` is ignored";
|
|
276
|
-
|
|
277
269
|
/** The configuration with every default filled in. */
|
|
278
270
|
export interface ResolvedConfig extends ResolvedLimits {
|
|
279
271
|
name: string;
|
|
272
|
+
/**
|
|
273
|
+
* The preset the configuration chose, and each setting it filled in as `key: value`, such as
|
|
274
|
+
* `imageTool: "selected"`; a setting the configuration wrote itself is not listed, since it
|
|
275
|
+
* wins. Undefined without `preset`.
|
|
276
|
+
*/
|
|
277
|
+
preset?: {
|
|
278
|
+
name: NonNullable<RoundtableConfig["preset"]>;
|
|
279
|
+
set: readonly string[];
|
|
280
|
+
};
|
|
280
281
|
/**
|
|
281
282
|
* The process's short name: the logger's and the scratch dir's, and the root slash command's
|
|
282
283
|
* with Discord. `discord.rootCommand` when Discord is on, else the lowercase assistant name.
|
|
@@ -322,6 +323,9 @@ export interface ResolvedConfig extends ResolvedLimits {
|
|
|
322
323
|
speakers: { admins?: TierMembers; members?: TierMembers };
|
|
323
324
|
/** Each person's limits across their conversations; a limit left out is unset. */
|
|
324
325
|
background: { perPrincipal: PerPrincipalLimits };
|
|
326
|
+
imageTool: NonNullable<RoundtableConfig["imageTool"]>;
|
|
327
|
+
/** The runner with its defaults; undefined when none is configured. */
|
|
328
|
+
runner?: RunnerSettings;
|
|
325
329
|
toolTiers: Record<string, Tier>;
|
|
326
330
|
prompts: { shared?: string; guest?: string };
|
|
327
331
|
agents: AgentSeed[];
|
|
@@ -357,143 +361,3 @@ export interface ResolvedConfig extends ResolvedLimits {
|
|
|
357
361
|
interimPrimaryChars: number;
|
|
358
362
|
plugins: RoundtablePlugin[];
|
|
359
363
|
}
|
|
360
|
-
|
|
361
|
-
function modelOf(value: string, path: string): ModelRef {
|
|
362
|
-
const parsed = parseModelRef(value);
|
|
363
|
-
if (!parsed)
|
|
364
|
-
throw new ConfigError(
|
|
365
|
-
`config ${path}: expected <provider>/<id>, got ${JSON.stringify(value)}. Write it like anthropic/claude-sonnet-5-5.`,
|
|
366
|
-
);
|
|
367
|
-
return parsed;
|
|
368
|
-
}
|
|
369
|
-
|
|
370
|
-
/** The skin tones the configuration chose, or the package's own. */
|
|
371
|
-
function skinsOf(skins: readonly string[] | undefined): readonly Hex[] {
|
|
372
|
-
return (skins as readonly Hex[] | undefined) ?? CATALOG.skins;
|
|
373
|
-
}
|
|
374
|
-
|
|
375
|
-
/** The configuration checked against its schema, defaults filled; throws a ConfigError naming the key and the fix. */
|
|
376
|
-
export function resolveConfig(input: unknown): ResolvedConfig {
|
|
377
|
-
const config = configSchema.check(
|
|
378
|
-
liftAdapters(input),
|
|
379
|
-
"",
|
|
380
|
-
) as RoundtableConfig;
|
|
381
|
-
const name = config.name ?? "Roundtable";
|
|
382
|
-
const model = modelOf(config.model, "model");
|
|
383
|
-
const thinking = config.thinking ?? "medium";
|
|
384
|
-
const { discord, http } = config;
|
|
385
|
-
const agentServer = config.agentServer !== false;
|
|
386
|
-
if (!agentServer) checkAgentServerOff(config);
|
|
387
|
-
// Whether the agents have Discord channels: with `discord.guild`, else they live in the app's rooms.
|
|
388
|
-
const agentGuild = checkAgentGuild(config, agentServer);
|
|
389
|
-
checkAgentTeamKeys(config, agentGuild);
|
|
390
|
-
const slug =
|
|
391
|
-
discord?.rootCommand ?? name.toLowerCase().replace(/[^a-z0-9-]+/g, "-");
|
|
392
|
-
const routing = routingOf(config.routing, {
|
|
393
|
-
withDiscord: agentGuild,
|
|
394
|
-
agentServer:
|
|
395
|
-
agentServer && (agentGuild || (config.agents?.length ?? 0) > 0),
|
|
396
|
-
topLevelOps: config.ops !== undefined,
|
|
397
|
-
});
|
|
398
|
-
const ops = opsOf(config.ops, agentGuild) ?? opsOfPlace(routing?.places.ops);
|
|
399
|
-
const access = accessOf(config, discord !== undefined);
|
|
400
|
-
const { primaryOwner } = access;
|
|
401
|
-
return {
|
|
402
|
-
name,
|
|
403
|
-
slug,
|
|
404
|
-
...access,
|
|
405
|
-
profiles: profileRulesOf(config.profiles),
|
|
406
|
-
deprecations: [
|
|
407
|
-
...access.deprecations,
|
|
408
|
-
...(config.avatar ? [AVATAR_DEPRECATION] : []),
|
|
409
|
-
...(config.ops ? [OPS_DEPRECATION] : []),
|
|
410
|
-
],
|
|
411
|
-
owner: {
|
|
412
|
-
id: primaryOwner.id,
|
|
413
|
-
name: primaryOwner.name,
|
|
414
|
-
pronouns: primaryOwner.pronouns,
|
|
415
|
-
},
|
|
416
|
-
...(discord ? { discord: resolvedDiscord(discord, slug) } : {}),
|
|
417
|
-
databaseUrl: config.database.url,
|
|
418
|
-
dataDir: config.dataDir,
|
|
419
|
-
attachments: config.attachments?.retention
|
|
420
|
-
? { retention: config.attachments.retention }
|
|
421
|
-
: {},
|
|
422
|
-
conversations: {
|
|
423
|
-
keepDays: { ...config.conversations?.keepDays },
|
|
424
|
-
...(config.conversations?.keep
|
|
425
|
-
? { keep: config.conversations.keep }
|
|
426
|
-
: {}),
|
|
427
|
-
},
|
|
428
|
-
agentDir: config.agentDir ?? `${config.dataDir}/pi`,
|
|
429
|
-
model,
|
|
430
|
-
thinking,
|
|
431
|
-
judge: {
|
|
432
|
-
model: config.judge?.model
|
|
433
|
-
? modelOf(config.judge.model, "judge.model")
|
|
434
|
-
: model,
|
|
435
|
-
threshold: config.judge?.threshold ?? 0.6,
|
|
436
|
-
},
|
|
437
|
-
...(config.effortPolicy ? { effortPolicy: config.effortPolicy } : {}),
|
|
438
|
-
delegation: {
|
|
439
|
-
model: config.delegation?.model
|
|
440
|
-
? modelOf(config.delegation.model, "delegation.model")
|
|
441
|
-
: model,
|
|
442
|
-
thinking: config.delegation?.thinking ?? "medium",
|
|
443
|
-
},
|
|
444
|
-
locale: config.locale ?? "en",
|
|
445
|
-
timeZone: config.timeZone ?? "UTC",
|
|
446
|
-
speakers: {
|
|
447
|
-
...(config.speakers?.admins ? { admins: config.speakers.admins } : {}),
|
|
448
|
-
...(config.speakers?.members ? { members: config.speakers.members } : {}),
|
|
449
|
-
},
|
|
450
|
-
background: { perPrincipal: { ...config.background?.perPrincipal } },
|
|
451
|
-
toolTiers: config.toolTiers ?? {},
|
|
452
|
-
prompts: config.prompts ?? {},
|
|
453
|
-
agents: config.agents ?? [],
|
|
454
|
-
agentServer:
|
|
455
|
-
agentServer && (agentGuild || (config.agents?.length ?? 0) > 0),
|
|
456
|
-
agentTools:
|
|
457
|
-
typeof config.agentServer === "object"
|
|
458
|
-
? config.agentServer.tools
|
|
459
|
-
: "full",
|
|
460
|
-
...(!agentGuild && config.agents?.[0]
|
|
461
|
-
? { coordinator: config.coordinator ?? config.agents[0].name }
|
|
462
|
-
: {}),
|
|
463
|
-
team: teamOf(config.team),
|
|
464
|
-
characters: {
|
|
465
|
-
skins: skinsOf(config.characters?.skins),
|
|
466
|
-
refreshAvatars: config.characters?.refreshAvatars ?? false,
|
|
467
|
-
},
|
|
468
|
-
...(http
|
|
469
|
-
? {
|
|
470
|
-
http: {
|
|
471
|
-
...(http.publicUrl ? { publicUrl: http.publicUrl } : {}),
|
|
472
|
-
port: http.port ?? 3000,
|
|
473
|
-
...(http.hostname ? { hostname: http.hostname } : {}),
|
|
474
|
-
...(http.socketPath ? { socketPath: http.socketPath } : {}),
|
|
475
|
-
...(http.socketMode === undefined
|
|
476
|
-
? {}
|
|
477
|
-
: { socketMode: http.socketMode }),
|
|
478
|
-
},
|
|
479
|
-
}
|
|
480
|
-
: {}),
|
|
481
|
-
...(config.avatar ? { avatar: config.avatar } : {}),
|
|
482
|
-
workDir: config.workDir ?? `${config.dataDir}/work`,
|
|
483
|
-
scratchDir: config.scratchDir ?? join(tmpdir(), `${slug}-scratch`),
|
|
484
|
-
// Without Discord and without agents there is no one to carry skills, so the addon is off.
|
|
485
|
-
skills: agentServer
|
|
486
|
-
? (config.skills ?? (discord || config.agents?.length ? {} : false))
|
|
487
|
-
: false,
|
|
488
|
-
memory: config.memory ?? true,
|
|
489
|
-
...(ops ? { ops } : {}),
|
|
490
|
-
opsKey: config.ops ? "ops" : "routing.places.ops",
|
|
491
|
-
...(routing ? { routing } : {}),
|
|
492
|
-
helpers: agentServer ? helpersOf(config.helpers) : false,
|
|
493
|
-
drainMs: (config.drainSeconds ?? DRAIN_LIMIT_MS / 1_000) * 1_000,
|
|
494
|
-
...limitsOf(config),
|
|
495
|
-
interimText: config.interimText ?? "on",
|
|
496
|
-
interimPrimaryChars: config.interimPrimaryChars ?? PRIMARY_CHARS,
|
|
497
|
-
plugins: config.plugins ?? [],
|
|
498
|
-
};
|
|
499
|
-
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { ConfigError } from "../domain/errors.ts";
|
|
2
|
+
import type { Tier } from "../identity/speakers.ts";
|
|
3
|
+
import type { ResolvedConfig, RoundtableConfig } from "./config.ts";
|
|
4
|
+
|
|
5
|
+
/** The tiers `"shared"` gives the tools a selection opens to everyone it serves. */
|
|
6
|
+
export const SHARED_TOOL_TIERS: Readonly<Record<string, Tier>> = {
|
|
7
|
+
generate_image: "member",
|
|
8
|
+
poll_create: "member",
|
|
9
|
+
poll_end: "member",
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
/** The preset a configuration chose, and each setting it filled in. */
|
|
13
|
+
export type ResolvedPreset = NonNullable<ResolvedConfig["preset"]>;
|
|
14
|
+
|
|
15
|
+
/** The settings a preset may fill in. */
|
|
16
|
+
interface PresetValues {
|
|
17
|
+
imageTool: NonNullable<RoundtableConfig["imageTool"]>;
|
|
18
|
+
toolTiers: Record<string, Tier>;
|
|
19
|
+
preset?: ResolvedPreset;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* The image tool's mode and the tool tiers, with the preset's defaults under what the
|
|
24
|
+
* configuration wrote; without `preset`, exactly what it wrote. `"shared"` is a host many people
|
|
25
|
+
* talk to, each in conversations of their own, so it needs `runner`: their shell and file tools
|
|
26
|
+
* must not run on the host. Its picture and poll tools are then theirs where a selection names them.
|
|
27
|
+
*/
|
|
28
|
+
export function presetValues(config: RoundtableConfig): PresetValues {
|
|
29
|
+
const written = config.toolTiers ?? {};
|
|
30
|
+
if (config.preset !== "shared")
|
|
31
|
+
return {
|
|
32
|
+
imageTool: config.imageTool ?? "every-selection",
|
|
33
|
+
toolTiers: written,
|
|
34
|
+
};
|
|
35
|
+
if (!config.runner)
|
|
36
|
+
throw new ConfigError(
|
|
37
|
+
'config runner: required by preset: "shared", whose conversations run bash, read, edit and write in the runner\'s container. Add runner: { driver: "socket", socket } beside a sidecar or { driver: "docker", image }, or remove preset.',
|
|
38
|
+
);
|
|
39
|
+
const set: string[] = [];
|
|
40
|
+
if (config.imageTool === undefined) set.push('imageTool: "selected"');
|
|
41
|
+
const tiers = Object.entries(SHARED_TOOL_TIERS).filter(
|
|
42
|
+
([tool]) => written[tool] === undefined,
|
|
43
|
+
);
|
|
44
|
+
for (const [tool, tier] of tiers)
|
|
45
|
+
set.push(`toolTiers.${tool}: ${JSON.stringify(tier)}`);
|
|
46
|
+
return {
|
|
47
|
+
imageTool: config.imageTool ?? "selected",
|
|
48
|
+
toolTiers: { ...Object.fromEntries(tiers), ...written },
|
|
49
|
+
preset: { name: "shared", set },
|
|
50
|
+
};
|
|
51
|
+
}
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
import { tmpdir } from "node:os";
|
|
2
|
+
import { join } from "node:path";
|
|
3
|
+
import { CATALOG, type Hex } from "../../characters/index.ts";
|
|
4
|
+
import { ConfigError } from "../domain/errors.ts";
|
|
5
|
+
import { type ModelRef, parseModelRef } from "../domain/models.ts";
|
|
6
|
+
import { runnerSettings } from "../runner/settings.ts";
|
|
7
|
+
import { PRIMARY_CHARS } from "../runtime/interim-text.ts";
|
|
8
|
+
import { accessOf } from "./access.ts";
|
|
9
|
+
import { liftAdapters, resolvedDiscord } from "./adapters.ts";
|
|
10
|
+
import {
|
|
11
|
+
checkAgentGuild,
|
|
12
|
+
checkAgentServerOff,
|
|
13
|
+
checkAgentTeamKeys,
|
|
14
|
+
} from "./agent-team.ts";
|
|
15
|
+
import type { ResolvedConfig, RoundtableConfig } from "./config.ts";
|
|
16
|
+
import { configSchema, DRAIN_LIMIT_MS } from "./config-schema.ts";
|
|
17
|
+
import { helpersOf } from "./helpers.ts";
|
|
18
|
+
import { limitsOf } from "./limits.ts";
|
|
19
|
+
import { opsOf, opsOfPlace } from "./ops.ts";
|
|
20
|
+
import { presetValues } from "./preset.ts";
|
|
21
|
+
import { profileRulesOf } from "./profiles.ts";
|
|
22
|
+
import { routingOf } from "./routing.ts";
|
|
23
|
+
import { teamOf } from "./team.ts";
|
|
24
|
+
|
|
25
|
+
/** Logged once when the top-level `ops` is set: it is an alias of the `ops` place. */
|
|
26
|
+
export const OPS_DEPRECATION =
|
|
27
|
+
"`ops` is an alias of `routing.places.ops` since 0.27 and goes away in 1.0; move it there";
|
|
28
|
+
|
|
29
|
+
/** Logged once when `avatar` is set: agents are composed characters and no picture is drawn from it. */
|
|
30
|
+
export const AVATAR_DEPRECATION =
|
|
31
|
+
"agents are composed characters since 0.23; `avatar` is ignored";
|
|
32
|
+
|
|
33
|
+
function modelOf(value: string, path: string): ModelRef {
|
|
34
|
+
const parsed = parseModelRef(value);
|
|
35
|
+
if (!parsed)
|
|
36
|
+
throw new ConfigError(
|
|
37
|
+
`config ${path}: expected <provider>/<id>, got ${JSON.stringify(value)}. Write it like anthropic/claude-sonnet-5-5.`,
|
|
38
|
+
);
|
|
39
|
+
return parsed;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/** The skin tones the configuration chose, or the package's own. */
|
|
43
|
+
function skinsOf(skins: readonly string[] | undefined): readonly Hex[] {
|
|
44
|
+
return (skins as readonly Hex[] | undefined) ?? CATALOG.skins;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/** The configuration checked against its schema, defaults filled; throws a ConfigError naming the key and the fix. */
|
|
48
|
+
export function resolveConfig(input: unknown): ResolvedConfig {
|
|
49
|
+
const config = configSchema.check(
|
|
50
|
+
liftAdapters(input),
|
|
51
|
+
"",
|
|
52
|
+
) as RoundtableConfig;
|
|
53
|
+
const name = config.name ?? "Roundtable";
|
|
54
|
+
const model = modelOf(config.model, "model");
|
|
55
|
+
const thinking = config.thinking ?? "medium";
|
|
56
|
+
const { discord, http } = config;
|
|
57
|
+
const agentServer = config.agentServer !== false;
|
|
58
|
+
if (!agentServer) checkAgentServerOff(config);
|
|
59
|
+
// Whether the agents have Discord channels: with `discord.guild`, else they live in the app's rooms.
|
|
60
|
+
const agentGuild = checkAgentGuild(config, agentServer);
|
|
61
|
+
checkAgentTeamKeys(config, agentGuild);
|
|
62
|
+
const slug =
|
|
63
|
+
discord?.rootCommand ?? name.toLowerCase().replace(/[^a-z0-9-]+/g, "-");
|
|
64
|
+
const routing = routingOf(config.routing, {
|
|
65
|
+
withDiscord: agentGuild,
|
|
66
|
+
agentServer:
|
|
67
|
+
agentServer && (agentGuild || (config.agents?.length ?? 0) > 0),
|
|
68
|
+
topLevelOps: config.ops !== undefined,
|
|
69
|
+
});
|
|
70
|
+
const ops = opsOf(config.ops, agentGuild) ?? opsOfPlace(routing?.places.ops);
|
|
71
|
+
const access = accessOf(config, discord !== undefined);
|
|
72
|
+
const { primaryOwner } = access;
|
|
73
|
+
const { imageTool, toolTiers, preset } = presetValues(config);
|
|
74
|
+
return {
|
|
75
|
+
name,
|
|
76
|
+
slug,
|
|
77
|
+
...(preset ? { preset } : {}),
|
|
78
|
+
...access,
|
|
79
|
+
profiles: profileRulesOf(config.profiles),
|
|
80
|
+
deprecations: [
|
|
81
|
+
...access.deprecations,
|
|
82
|
+
...(config.avatar ? [AVATAR_DEPRECATION] : []),
|
|
83
|
+
...(config.ops ? [OPS_DEPRECATION] : []),
|
|
84
|
+
],
|
|
85
|
+
owner: {
|
|
86
|
+
id: primaryOwner.id,
|
|
87
|
+
name: primaryOwner.name,
|
|
88
|
+
pronouns: primaryOwner.pronouns,
|
|
89
|
+
},
|
|
90
|
+
...(discord ? { discord: resolvedDiscord(discord, slug) } : {}),
|
|
91
|
+
databaseUrl: config.database.url,
|
|
92
|
+
dataDir: config.dataDir,
|
|
93
|
+
attachments: config.attachments?.retention
|
|
94
|
+
? { retention: config.attachments.retention }
|
|
95
|
+
: {},
|
|
96
|
+
conversations: {
|
|
97
|
+
keepDays: { ...config.conversations?.keepDays },
|
|
98
|
+
...(config.conversations?.keep
|
|
99
|
+
? { keep: config.conversations.keep }
|
|
100
|
+
: {}),
|
|
101
|
+
},
|
|
102
|
+
agentDir: config.agentDir ?? `${config.dataDir}/pi`,
|
|
103
|
+
model,
|
|
104
|
+
thinking,
|
|
105
|
+
judge: {
|
|
106
|
+
model: config.judge?.model
|
|
107
|
+
? modelOf(config.judge.model, "judge.model")
|
|
108
|
+
: model,
|
|
109
|
+
threshold: config.judge?.threshold ?? 0.6,
|
|
110
|
+
},
|
|
111
|
+
...(config.effortPolicy ? { effortPolicy: config.effortPolicy } : {}),
|
|
112
|
+
delegation: {
|
|
113
|
+
model: config.delegation?.model
|
|
114
|
+
? modelOf(config.delegation.model, "delegation.model")
|
|
115
|
+
: model,
|
|
116
|
+
thinking: config.delegation?.thinking ?? "medium",
|
|
117
|
+
},
|
|
118
|
+
locale: config.locale ?? "en",
|
|
119
|
+
timeZone: config.timeZone ?? "UTC",
|
|
120
|
+
speakers: {
|
|
121
|
+
...(config.speakers?.admins ? { admins: config.speakers.admins } : {}),
|
|
122
|
+
...(config.speakers?.members ? { members: config.speakers.members } : {}),
|
|
123
|
+
},
|
|
124
|
+
background: { perPrincipal: { ...config.background?.perPrincipal } },
|
|
125
|
+
imageTool,
|
|
126
|
+
...(config.runner ? { runner: runnerSettings(config.runner) } : {}),
|
|
127
|
+
toolTiers,
|
|
128
|
+
prompts: config.prompts ?? {},
|
|
129
|
+
agents: config.agents ?? [],
|
|
130
|
+
agentServer:
|
|
131
|
+
agentServer && (agentGuild || (config.agents?.length ?? 0) > 0),
|
|
132
|
+
agentTools:
|
|
133
|
+
typeof config.agentServer === "object"
|
|
134
|
+
? config.agentServer.tools
|
|
135
|
+
: "full",
|
|
136
|
+
...(!agentGuild && config.agents?.[0]
|
|
137
|
+
? { coordinator: config.coordinator ?? config.agents[0].name }
|
|
138
|
+
: {}),
|
|
139
|
+
team: teamOf(config.team),
|
|
140
|
+
characters: {
|
|
141
|
+
skins: skinsOf(config.characters?.skins),
|
|
142
|
+
refreshAvatars: config.characters?.refreshAvatars ?? false,
|
|
143
|
+
},
|
|
144
|
+
...(http
|
|
145
|
+
? {
|
|
146
|
+
http: {
|
|
147
|
+
...(http.publicUrl ? { publicUrl: http.publicUrl } : {}),
|
|
148
|
+
port: http.port ?? 3000,
|
|
149
|
+
...(http.hostname ? { hostname: http.hostname } : {}),
|
|
150
|
+
...(http.socketPath ? { socketPath: http.socketPath } : {}),
|
|
151
|
+
...(http.socketMode === undefined
|
|
152
|
+
? {}
|
|
153
|
+
: { socketMode: http.socketMode }),
|
|
154
|
+
},
|
|
155
|
+
}
|
|
156
|
+
: {}),
|
|
157
|
+
...(config.avatar ? { avatar: config.avatar } : {}),
|
|
158
|
+
workDir: config.workDir ?? `${config.dataDir}/work`,
|
|
159
|
+
scratchDir: config.scratchDir ?? join(tmpdir(), `${slug}-scratch`),
|
|
160
|
+
// Without Discord and without agents there is no one to carry skills, so the addon is off.
|
|
161
|
+
skills: agentServer
|
|
162
|
+
? (config.skills ?? (discord || config.agents?.length ? {} : false))
|
|
163
|
+
: false,
|
|
164
|
+
memory: config.memory ?? true,
|
|
165
|
+
...(ops ? { ops } : {}),
|
|
166
|
+
opsKey: config.ops ? "ops" : "routing.places.ops",
|
|
167
|
+
...(routing ? { routing } : {}),
|
|
168
|
+
helpers: agentServer ? helpersOf(config.helpers) : false,
|
|
169
|
+
drainMs: (config.drainSeconds ?? DRAIN_LIMIT_MS / 1_000) * 1_000,
|
|
170
|
+
...limitsOf(config),
|
|
171
|
+
interimText: config.interimText ?? "on",
|
|
172
|
+
interimPrimaryChars: config.interimPrimaryChars ?? PRIMARY_CHARS,
|
|
173
|
+
plugins: config.plugins ?? [],
|
|
174
|
+
};
|
|
175
|
+
}
|