@otium-team/negotium 0.23.15 → 0.24.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.
Files changed (43) hide show
  1. package/dist/agent-helpers.js +951 -243
  2. package/dist/agent-helpers.js.map +12 -9
  3. package/dist/{chunk-3hf8y6bd.js → chunk-3r4xfhkx.js} +3 -3
  4. package/dist/{chunk-3hf8y6bd.js.map → chunk-3r4xfhkx.js.map} +2 -2
  5. package/dist/{chunk-ng13grfj.js → chunk-fzfzskjq.js} +18 -2
  6. package/dist/{chunk-ng13grfj.js.map → chunk-fzfzskjq.js.map} +4 -4
  7. package/dist/{chunk-m1ngkjdd.js → chunk-hn2cqdd0.js} +1 -1
  8. package/dist/hosted-agent.js +19 -3
  9. package/dist/hosted-agent.js.map +5 -5
  10. package/dist/main.js +3701 -2961
  11. package/dist/main.js.map +15 -12
  12. package/dist/mcp-factories.js +941 -227
  13. package/dist/mcp-factories.js.map +13 -10
  14. package/dist/prompts.js +221 -1
  15. package/dist/prompts.js.map +7 -5
  16. package/dist/registry.js +3 -3
  17. package/dist/rollout.js +2 -2
  18. package/dist/runtime/src/mcp/wiki-server.ts +8 -0
  19. package/dist/runtime/src/platform/mcp-config.ts +26 -0
  20. package/dist/runtime/src/prompts/builders.ts +5 -0
  21. package/dist/runtime/src/runtime/turn-runner.ts +65 -1
  22. package/dist/runtime/src/storage/api-topics.ts +29 -0
  23. package/dist/runtime/src/topics/agent-plugins/mcp.schema.json +120 -0
  24. package/dist/runtime/src/topics/agent-plugins/plugin.schema.json +65 -0
  25. package/dist/runtime/src/topics/plugin-server-instructions.ts +201 -0
  26. package/dist/runtime/src/topics/plugin-turn.ts +37 -0
  27. package/dist/runtime/src/topics/plugins.ts +445 -0
  28. package/dist/runtime/src/topics/update.ts +34 -0
  29. package/dist/runtime/src/types/api.ts +5 -0
  30. package/dist/runtime/src/version.ts +1 -1
  31. package/dist/storage.js +23 -2
  32. package/dist/storage.js.map +3 -3
  33. package/dist/types/packages/core/src/platform/mcp-config.d.ts +6 -0
  34. package/dist/types/packages/core/src/prompts/builders.d.ts +3 -0
  35. package/dist/types/packages/core/src/runtime/turn-runner.d.ts +14 -1
  36. package/dist/types/packages/core/src/storage/api-topics.d.ts +3 -0
  37. package/dist/types/packages/core/src/topics/plugin-server-instructions.d.ts +55 -0
  38. package/dist/types/packages/core/src/topics/plugin-turn.d.ts +17 -0
  39. package/dist/types/packages/core/src/topics/plugins.d.ts +66 -0
  40. package/dist/types/packages/core/src/types/api.d.ts +5 -0
  41. package/dist/types/packages/core/src/version.d.ts +1 -1
  42. package/package.json +1 -1
  43. /package/dist/{chunk-m1ngkjdd.js.map → chunk-hn2cqdd0.js.map} +0 -0
@@ -180,6 +180,12 @@ export declare function isReservedRuntimeMcpServerName(name: string): boolean;
180
180
  * room. A subagent room takes none.
181
181
  */
182
182
  export declare function hostMcpGrantRefusal(topic: Pick<TopicDto, "kind" | "isSubagent">, names: readonly string[]): string | null;
183
+ /**
184
+ * Why servers from a room's plugins (their root `mcp.json`) may not join its
185
+ * turns, or null when they may. They take the checks host grants get, and must not
186
+ * share a name with the host's own servers for the room.
187
+ */
188
+ export declare function pluginMcpRefusal(topic: Pick<TopicDto, "kind" | "isSubagent">, names: readonly string[], hostNames?: readonly string[]): string | null;
183
189
  /**
184
190
  * Lazily prepare per-topic HTTP manifest entries before a provider resolves
185
191
  * its otherwise-synchronous MCP config. One failed custom server is omitted
@@ -1,3 +1,4 @@
1
+ import { type TopicPlugin } from "../topics/plugins";
1
2
  import type { AgentKind, EffortLevel } from "../types";
2
3
  import type { SubagentReportMode, TopicSurface } from "../types/api";
3
4
  export interface AgentDef {
@@ -32,6 +33,8 @@ export interface SessionSystemPromptOpts {
32
33
  visualTools?: boolean;
33
34
  /** True only when the current adapter can deliver files to its chat. */
34
35
  fileDeliveryTools?: boolean;
36
+ /** The room's plugins (`#topics/plugins`): their rules and skills follow the topic's own instructions. */
37
+ plugins?: readonly TopicPlugin[];
35
38
  }
36
39
  export type SessionPromptKind = "topic" | "channel" | "manager";
37
40
  export type PromptSectionSlot = "after-runtime-tools" | "after-shared-tasks" | "before-session-communication" | "after-session-communication" | "before-topic-configuration" | "after-topic-configuration" | "after-system-prompt";
@@ -4,7 +4,9 @@ import { AbortReason } from "../query/types";
4
4
  import { type StreamAgentOutcome } from "./turn-event-stream";
5
5
  import { type AiTurnTopic } from "./turn-session";
6
6
  import { type UserTurnEnvelope } from "./user-turn-envelope";
7
+ import type { HostMcpServerSpec } from "../runtime-gateway";
7
8
  import type { PendingAskUserId } from "../storage/session-asks";
9
+ import type { TopicPlugin } from "../topics/plugins";
8
10
  import type { ActorTopicScope, AgentKind, EffortLevel, PeerRuntimeBridgeContext, RemoteSessionGrant, UnifiedEvent } from "../types";
9
11
  import type { MessageDto, TopicDto } from "../types/api";
10
12
  export * from "../agents/model-catalog";
@@ -191,7 +193,18 @@ export declare function resolveTurnToolCapabilities(topicId: string, params: {
191
193
  * room's only forum executions, so cron/ephemeral turns cannot inherit it.
192
194
  * Subagent rooms never take one.
193
195
  */
194
- export declare function resolveTurnHostMcpServers(topic: Pick<TopicDto, "id" | "kind" | "isSubagent">, sessionType?: "dm" | "forum" | "ephemeral" | "manager" | "cron"): Record<string, import("../runtime-gateway").HostMcpServerSpec> | undefined;
196
+ export declare function resolveTurnHostMcpServers(topic: Pick<TopicDto, "id" | "kind" | "isSubagent">, sessionType?: "dm" | "forum" | "ephemeral" | "manager" | "cron"): Record<string, HostMcpServerSpec> | undefined;
197
+ /**
198
+ * The room's plugins for this turn, under the same scope rule as its host
199
+ * grant: the plugins, the servers they add, and the turn's host servers with
200
+ * those added. Broken plugins or unusable servers are logged and left out,
201
+ * never thrown.
202
+ */
203
+ export declare function resolveTurnPlugins(topic: Pick<TopicDto, "id" | "kind" | "isSubagent">, sessionType: "dm" | "forum" | "ephemeral" | "manager" | "cron" | undefined, hostMcpServers: Record<string, HostMcpServerSpec> | undefined): {
204
+ plugins: readonly TopicPlugin[];
205
+ pluginMcpServers: Record<string, HostMcpServerSpec>;
206
+ hostMcpServers: Record<string, HostMcpServerSpec> | undefined;
207
+ };
195
208
  export interface StartAiTurnParams extends AiTurnExecutionOptions {
196
209
  topic: AiTurnTopic;
197
210
  userId: string;
@@ -121,6 +121,7 @@ export interface TopicRow {
121
121
  surface_scope: string | null;
122
122
  browser_profile_owner: string | null;
123
123
  browser_connect_port: number | null;
124
+ plugins_json?: string | null;
124
125
  session_id: string | null;
125
126
  }
126
127
  export interface TopicSessionLogContext {
@@ -128,6 +129,8 @@ export interface TopicSessionLogContext {
128
129
  queryId?: string;
129
130
  agent?: AgentKind;
130
131
  }
132
+ /** The room's plugin folders; an empty list or `null` removes them all. */
133
+ export declare function setTopicPlugins(topicId: string, plugins: readonly string[] | null): void;
131
134
  export declare function normalizeTopicVisibility(value: unknown): TopicVisibility;
132
135
  /** Discovery boundary shared by user-facing adapters. */
133
136
  export declare function isTopicVisible(topic: Pick<TopicDto, "visibility">): boolean;
@@ -0,0 +1,55 @@
1
+ /**
2
+ * The `instructions` a room's plugin MCP servers return from `initialize`,
3
+ * shown to the model the same way on Claude, Codex and Maestro.
4
+ *
5
+ * The engines do not agree on their own. Claude Code puts each connected
6
+ * server's instructions in a reminder of its own, cut at 2048 characters.
7
+ * Codex shows them as tool metadata only, and only for some models. Maestro
8
+ * never reads them. So the node reads them itself and puts the same text in
9
+ * every engine's system prompt; a Claude turn may see a server's text twice.
10
+ */
11
+ import type { HostMcpServerSpec } from "../runtime-gateway";
12
+ /** How long one server gets to answer `initialize`. */
13
+ export declare const SERVER_INSTRUCTIONS_TIMEOUT_MS = 3000;
14
+ /** How long a server's answer is reused before it is read again. */
15
+ export declare const SERVER_INSTRUCTIONS_TTL_MS: number;
16
+ /** The most UTF-8 bytes of one server's text the prompt carries. */
17
+ export declare const SERVER_INSTRUCTIONS_MAX_BYTES: number;
18
+ /** The most UTF-8 bytes the whole section carries. */
19
+ export declare const INSTRUCTIONS_SECTION_MAX_BYTES: number;
20
+ export interface McpServerInstructions {
21
+ server: string;
22
+ /** As the server sent it. */
23
+ text: string;
24
+ }
25
+ export interface FetchedServerInstructions {
26
+ /** Servers that returned non-empty instructions, in the order given. */
27
+ instructions: McpServerInstructions[];
28
+ /** Servers that could not be read in time, each with why. */
29
+ problems: string[];
30
+ }
31
+ export interface FetchInstructionsOptions {
32
+ timeoutMs?: number;
33
+ /** The turn's stop: every read in flight ends when it fires. */
34
+ signal?: AbortSignal;
35
+ }
36
+ /** Forget every cached answer. */
37
+ export declare function clearMcpServerInstructionsCache(): void;
38
+ /**
39
+ * Read every server's `instructions` at once, reusing an answer younger than
40
+ * `SERVER_INSTRUCTIONS_TTL_MS`; never throws. A failed read is not cached.
41
+ */
42
+ export declare function fetchMcpServerInstructions(servers: Readonly<Record<string, HostMcpServerSpec>>, options?: FetchInstructionsOptions): Promise<FetchedServerInstructions>;
43
+ export interface RenderedServerInstructions {
44
+ /** The system prompt section; empty when no server's text is shown. */
45
+ section: string;
46
+ /** Servers whose text was cut or left out for size. */
47
+ problems: string[];
48
+ }
49
+ /**
50
+ * The system prompt section for the servers' instructions, the same text for
51
+ * every engine. A server's text is cut at `SERVER_INSTRUCTIONS_MAX_BYTES` and
52
+ * the section at `INSTRUCTIONS_SECTION_MAX_BYTES`, each cut marked in the
53
+ * text; servers past the section's limit are left out.
54
+ */
55
+ export declare function renderMcpServerInstructions(instructions: readonly McpServerInstructions[]): RenderedServerInstructions;
@@ -0,0 +1,17 @@
1
+ /**
2
+ * What a room's plugins give one turn: the plugins whose skills the system
3
+ * prompt carries, and their root `mcp.json` servers. Turns fail closed: what
4
+ * does not load gives nothing, and servers whose names clash are left out.
5
+ */
6
+ import type { HostMcpServerSpec } from "../runtime-gateway";
7
+ import { type TopicPlugin } from "./plugins";
8
+ import type { TopicDto } from "../types/api";
9
+ export interface TopicPluginTurn {
10
+ plugins: readonly TopicPlugin[];
11
+ mcpServers: Record<string, HostMcpServerSpec>;
12
+ /** What the plugin folders reported while loading. */
13
+ loadProblems: readonly string[];
14
+ /** Why the plugins' servers were left out: a name that clashes. */
15
+ serverProblems: readonly string[];
16
+ }
17
+ export declare function resolveTopicPluginTurn(topic: Pick<TopicDto, "kind" | "isSubagent" | "plugins">, hostServerNames: readonly string[]): TopicPluginTurn;
@@ -0,0 +1,66 @@
1
+ /**
2
+ * Plugins a host attaches to a room (`plugins` on the topic), read as Agent
3
+ * Plugins 1.0.0 (https://agent-plugins.org/specification) the same way for
4
+ * every agent kind, so a room gets the same instructions and tools on Claude,
5
+ * Codex and Maestro. Engine-native plugin systems (`.claude-plugin`,
6
+ * `.codex-plugin`) are deliberately not used.
7
+ *
8
+ * Portable parts:
9
+ * - `plugin.json`: the closed manifest, checked against the vendored schema
10
+ * (`agent-plugins/plugin.schema.json`); never fetched.
11
+ * - `skills/<name>/SKILL.md`: Agent Skills, listed in the system prompt by
12
+ * name, description and path; the model opens them with its file-read tool.
13
+ * - `mcp.json`: remote servers (`streamable-http`, `sse`), taken literally.
14
+ * `stdio` servers are skipped: a gateway host must not make the node launch
15
+ * processes (the same line `parseHostMcpServers` draws).
16
+ *
17
+ * Nothing else is read: other folders, client extension folders (spec §8)
18
+ * and the manifest's `extensions` entries are ignored unread. Servers that
19
+ * only the host can describe, such as one whose url carries a room token,
20
+ * come with each turn's `hostMcpServers`, never from a plugin.
21
+ *
22
+ * A plugin brings no always-on prompt text. A server says how to use its
23
+ * tools in their descriptions and in its MCP `instructions`, which every
24
+ * turn shows the model (`plugin-server-instructions.ts`).
25
+ *
26
+ * Failure boundaries follow the spec: a manifest violation rejects the
27
+ * plugin; a bad skill, server entry or component location is skipped. Every
28
+ * problem is reported.
29
+ */
30
+ import { type HostMcpServerSpec } from "../runtime-gateway";
31
+ export interface PluginSkill {
32
+ /** Folder name, repeated by `SKILL.md`'s `name`. Unique across a room's plugins. */
33
+ name: string;
34
+ /** When to read it; the only text of the skill the system prompt carries. */
35
+ description: string;
36
+ /** Absolute path of its `SKILL.md`. */
37
+ path: string;
38
+ }
39
+ export interface TopicPlugin {
40
+ /** The manifest's `name`. */
41
+ id: string;
42
+ /** Absolute folder path, as the room lists it. */
43
+ dir: string;
44
+ /** In folder name order. */
45
+ skills: readonly PluginSkill[];
46
+ /** Root `mcp.json` servers, ready to connect. */
47
+ mcpServers: Readonly<Record<string, HostMcpServerSpec>>;
48
+ }
49
+ export interface TopicPluginsLoad {
50
+ /** The plugins that loaded, in the room's order, without what was skipped. */
51
+ plugins: readonly TopicPlugin[];
52
+ /** Every rejected plugin and skipped component, with where and why. */
53
+ problems: readonly string[];
54
+ }
55
+ /**
56
+ * Read the plugin folders a room lists, in its order. A plugin name is
57
+ * taken once, and skill and server names are unique across the room: a later
58
+ * duplicate is skipped.
59
+ */
60
+ export declare function loadTopicPlugins(dirs: readonly string[]): TopicPluginsLoad;
61
+ /**
62
+ * The prompt text a room's plugins add: one table of contents of every
63
+ * skill. The same input always renders the same text, whatever the agent
64
+ * kind; empty without skills.
65
+ */
66
+ export declare function renderTopicPluginsPrompt(plugins: readonly TopicPlugin[]): string;
@@ -68,6 +68,11 @@ export interface TopicDto {
68
68
  * launches, kills or deletes it.
69
69
  */
70
70
  browserConnectPort?: number;
71
+ /**
72
+ * Absolute paths of the Agent Plugins folders attached to this room
73
+ * (`#topics/plugins`), in the order their rules and skills reach the prompt.
74
+ */
75
+ plugins?: string[];
71
76
  /** AI agent invited to this topic. */
72
77
  agent?: AgentKind;
73
78
  /** Canonical base model alias used by newer clients. */
@@ -1 +1 @@
1
- export declare const NEGOTIUM_VERSION = "0.23.15";
1
+ export declare const NEGOTIUM_VERSION = "0.24.0";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@otium-team/negotium",
3
- "version": "0.23.15",
3
+ "version": "0.24.0",
4
4
  "type": "module",
5
5
  "description": "Install the Negotium multi-agent runtime and CLI with one package",
6
6
  "license": "Apache-2.0",