negotium 0.2.33 → 0.3.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.
Files changed (66) hide show
  1. package/dist/agent-helpers.js +57 -5
  2. package/dist/agent-helpers.js.map +12 -12
  3. package/dist/background-bash.js +3 -2
  4. package/dist/background-bash.js.map +4 -4
  5. package/dist/browser-runtime.js +3 -2
  6. package/dist/browser-runtime.js.map +4 -4
  7. package/dist/chunk-s2gez3wg.js.map +1 -1
  8. package/dist/{chunk-1y2xw0xe.js → chunk-vvfwqxnh.js} +33 -3
  9. package/dist/{chunk-1y2xw0xe.js.map → chunk-vvfwqxnh.js.map} +8 -8
  10. package/dist/hosted-agent.js +34 -4
  11. package/dist/hosted-agent.js.map +8 -8
  12. package/dist/main.js +1135 -370
  13. package/dist/main.js.map +27 -24
  14. package/dist/mcp-catalog.js +2 -1
  15. package/dist/mcp-catalog.js.map +3 -3
  16. package/dist/mcp-factories.js +585 -255
  17. package/dist/mcp-factories.js.map +16 -14
  18. package/dist/mcp-servers.js +3 -1
  19. package/dist/mcp-servers.js.map +3 -3
  20. package/dist/prompts.js +8 -2
  21. package/dist/prompts.js.map +5 -5
  22. package/dist/query-runtime.js +3 -2
  23. package/dist/query-runtime.js.map +4 -4
  24. package/dist/registry.js +3 -3
  25. package/dist/registry.js.map +2 -2
  26. package/dist/rollout.js +1 -1
  27. package/dist/runtime/cron/mcp-server.ts +2 -2
  28. package/dist/runtime/src/mcp/canonical-bridge-config.ts +1 -1
  29. package/dist/runtime/src/mcp/canonical-proxy-server.ts +74 -1
  30. package/dist/runtime/src/mcp/decision-server.ts +21 -0
  31. package/dist/runtime/src/mcp/factories/decision.ts +178 -0
  32. package/dist/runtime/src/mcp/factories/index.ts +6 -0
  33. package/dist/runtime/src/mcp/runtime-spec.ts +1 -0
  34. package/dist/runtime/src/mcp/session-comm/topic-config.ts +7 -1
  35. package/dist/runtime/src/node-host.ts +1 -0
  36. package/dist/runtime/src/platform/config.ts +2 -1
  37. package/dist/runtime/src/platform/mcp-catalog-policy.ts +1 -0
  38. package/dist/runtime/src/platform/mcp-config.ts +31 -1
  39. package/dist/runtime/src/prompts/builders.ts +5 -0
  40. package/dist/runtime/src/runtime/inbox.ts +6 -4
  41. package/dist/runtime/src/runtime/visual-html.ts +18 -1
  42. package/dist/runtime/src/storage/api-topics.ts +30 -2
  43. package/dist/runtime/src/storage/decisions.ts +231 -0
  44. package/dist/runtime/src/storage/storage-public.ts +2 -0
  45. package/dist/runtime/src/types.ts +13 -0
  46. package/dist/runtime/src/version.ts +1 -1
  47. package/dist/runtime-helpers.js +21 -3
  48. package/dist/runtime-helpers.js.map +5 -5
  49. package/dist/storage.js +263 -57
  50. package/dist/storage.js.map +6 -5
  51. package/dist/types/apps/negotium/src/mcp-servers.d.ts +1 -1
  52. package/dist/types/packages/core/src/mcp/canonical-bridge-config.d.ts +1 -1
  53. package/dist/types/packages/core/src/mcp/factories/decision.d.ts +16 -0
  54. package/dist/types/packages/core/src/mcp/factories/index.d.ts +1 -0
  55. package/dist/types/packages/core/src/mcp/runtime-spec.d.ts +1 -1
  56. package/dist/types/packages/core/src/platform/config.d.ts +2 -1
  57. package/dist/types/packages/core/src/platform/mcp-catalog-policy.d.ts +4 -0
  58. package/dist/types/packages/core/src/storage/api-topics.d.ts +29 -4
  59. package/dist/types/packages/core/src/storage/decisions.d.ts +45 -0
  60. package/dist/types/packages/core/src/storage/storage-public.d.ts +2 -0
  61. package/dist/types/packages/core/src/types.d.ts +12 -0
  62. package/dist/types/packages/core/src/version.d.ts +1 -1
  63. package/dist/vault.js +3 -2
  64. package/dist/vault.js.map +4 -4
  65. package/install-browser-rs.mjs +3 -3
  66. package/package.json +2 -2
@@ -1,4 +1,4 @@
1
- export declare const MCP_SERVER_NAMES: readonly ["agent-health", "background-bash", "canonical-proxy", "cron-manager", "session-comm", "system-health", "task", "token-stats", "vault", "wiki"];
1
+ export declare const MCP_SERVER_NAMES: readonly ["agent-health", "background-bash", "canonical-proxy", "cron-manager", "session-comm", "system-health", "task", "decision", "token-stats", "vault", "wiki"];
2
2
  export type McpServerName = (typeof MCP_SERVER_NAMES)[number];
3
3
  /**
4
4
  * Servers that are a TypeScript entry file a host can spawn. `background-bash`
@@ -1,5 +1,5 @@
1
1
  import type { PeerRuntimeBridgeContext } from "../types";
2
- export type CanonicalMcpSurface = "task" | "wiki";
2
+ export type CanonicalMcpSurface = "task" | "decision" | "wiki";
3
3
  export interface CanonicalMcpBridgeScope {
4
4
  surface: CanonicalMcpSurface;
5
5
  userId: string;
@@ -0,0 +1,16 @@
1
+ import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
2
+ import { type StoredDecision } from "../../storage/decisions";
3
+ import type { AgentKind } from "../../types";
4
+ export interface DecisionMcpContext {
5
+ userId: string;
6
+ topic: string;
7
+ topicId?: string;
8
+ agent: AgentKind;
9
+ model?: string;
10
+ }
11
+ export interface DecisionMcpHost {
12
+ readDecisions(userId: string, scopeKey: string): StoredDecision[];
13
+ writeDecisions(userId: string, scopeKey: string, decisions: StoredDecision[]): void;
14
+ }
15
+ export declare const defaultDecisionMcpHost: DecisionMcpHost;
16
+ export declare function createDecisionMcpServer(context: DecisionMcpContext, host?: DecisionMcpHost): McpServer;
@@ -5,6 +5,7 @@ export { executeVaultRun } from "../vault-run";
5
5
  export { createWikiMcpServer, type WikiMcpContext, type WikiMcpHost, type WikiSurface, type WikiTopicBrief, } from "../wiki-server";
6
6
  export { type AgentHealthMcpContext, createAgentHealthMcpServer, } from "./agent-health";
7
7
  export { type CompactionLogMcpContext, createCompactionLogMcpServer, } from "./compaction-log";
8
+ export { createDecisionMcpServer, type DecisionMcpContext, type DecisionMcpHost, defaultDecisionMcpHost, } from "./decision";
8
9
  export { createSessionCommMcpServer, type SessionCommMcpHost, type SessionCommMcpOptions, type SessionCommMcpResult, } from "./session-comm";
9
10
  export { type McpStdioProtectionTarget, protectMcpStdio, } from "./stdio-protection";
10
11
  export { createSystemHealthMcpServer, defaultSystemHealthMcpHost, type SystemHealthMcpHost, type SystemHealthSnapshot, } from "./system-health";
@@ -10,7 +10,7 @@
10
10
  import { type AgentKind, type PeerRuntimeBridgeContext } from "../types";
11
11
  export declare const RUNTIME_MCP_KEY = "runtime";
12
12
  export declare const RUNTIME_MCP_BASE_PATH = "/mcp/runtime";
13
- export declare const HOSTED_MCP_SURFACES: readonly ["task", "token-stats", "system-health", "vault", "wiki", "skills", "session-comm", "agent-health"];
13
+ export declare const HOSTED_MCP_SURFACES: readonly ["task", "decision", "token-stats", "system-health", "vault", "wiki", "skills", "session-comm", "agent-health"];
14
14
  export type HostedMcpSurface = (typeof HOSTED_MCP_SURFACES)[number];
15
15
  export interface RuntimeMcpContext {
16
16
  userId: string;
@@ -16,7 +16,7 @@ export declare const CLAUDE_EXECUTABLE: string | undefined;
16
16
  export declare const DEFAULT_OUTPUT_LANGUAGE = "English";
17
17
  export declare function resolveOutputLanguage(): string;
18
18
  /** Browser.rs release tested with this Negotium version. */
19
- export declare const BROWSER_RS_VERSION = "v0.1.19";
19
+ export declare const BROWSER_RS_VERSION = "v0.1.21";
20
20
  /** Require the authenticated listener and the current Browser.rs tool contract. */
21
21
  export declare const BROWSER_RS_MIN_SECURE_VERSION = "0.1.15";
22
22
  /**
@@ -61,6 +61,7 @@ export declare const TSX_LOADER: string;
61
61
  export declare const TSCONFIG_PATH: string;
62
62
  export declare const SESSION_COMM_SERVER: string;
63
63
  export declare const TASK_SERVER: string;
64
+ export declare const DECISION_SERVER: string;
64
65
  export declare const BROWSER_MCP_SSE_PROXY_SERVER: string;
65
66
  export declare const CANONICAL_MCP_PROXY_SERVER: string;
66
67
  export declare const WIKI_SERVER: string;
@@ -21,6 +21,10 @@ export declare const COMMON_RUNTIME_MCP_POLICY: {
21
21
  readonly scopes: readonly ["dm", "forum", "manager", "cron"];
22
22
  readonly forumRequired: true;
23
23
  };
24
+ readonly decision: {
25
+ readonly scopes: readonly ["dm", "forum", "manager", "cron"];
26
+ readonly forumRequired: true;
27
+ };
24
28
  readonly "session-comm": {
25
29
  readonly scopes: readonly ["forum", "fork", "manager"];
26
30
  readonly forumRequired: true;
@@ -147,11 +147,36 @@ export declare function findTopicTitleConflict(title: string, kind: TopicKind, o
147
147
  * lives in that adapter's database, not this one).
148
148
  */
149
149
  export declare function setTopicSurfaces(topicIds: readonly string[], surface: TopicSurface): number;
150
- /** Look up a topic by title, restricted to topics where `userId` participates. */
151
- export declare function getTopicByNameForUser(title: string, userId: string, opts?: {
152
- surface?: TopicSurface;
150
+ /**
151
+ * How wide a title lookup is allowed to reach.
152
+ *
153
+ * `surface` is required rather than optional. It used to default to "search
154
+ * every surface", which contradicted S-6's promise that a missed call site
155
+ * "cannot leak a topic across surfaces" — the guarantee only held where a
156
+ * caller remembered to opt in, and four did not: Telegram's `/load` and `/del`
157
+ * (the latter could delete a terminal room), the runtime MCP id path, the cron
158
+ * id path, and the session inbox. Every one of those was a silent leak with a
159
+ * correct-looking call. Making the parameter explicit turns each future
160
+ * omission into a compile error instead.
161
+ *
162
+ * `{ scope: "all" }` is the deliberate way to search every surface. It exists
163
+ * for operator tooling — the CLI manages jobs across surfaces on purpose — and
164
+ * reads as a decision at the call site rather than as an oversight.
165
+ */
166
+ export type TopicNameLookupScope = {
167
+ surface: TopicSurface;
153
168
  surfaceScope?: string | null;
154
- }): TopicDto | null;
169
+ } | {
170
+ scope: "all";
171
+ };
172
+ /**
173
+ * Look up a topic by title, restricted to topics where `userId` participates.
174
+ *
175
+ * Answers only on a single match: a title is unique per surface (S-3), so an
176
+ * `{ scope: "all" }` lookup of a name used on two surfaces resolves to null
177
+ * rather than picking one.
178
+ */
179
+ export declare function getTopicByNameForUser(title: string, userId: string, lookupScope: TopicNameLookupScope): TopicDto | null;
155
180
  /** Persist the agent session ID for a topic after a successful turn. */
156
181
  export declare function setTopicSessionId(topicId: string, sessionId: string, context?: TopicSessionLogContext): void;
157
182
  /** Clear the session ID (e.g. on topic reset). */
@@ -0,0 +1,45 @@
1
+ import type { AgentKind, DecisionSnapshot } from "../types";
2
+ export type StoredDecision = DecisionSnapshot;
3
+ export declare const DECISION_STATUS_VALUES: readonly ["proposed", "accepted", "executed", "rejected", "superseded"];
4
+ export declare function decisionScopeKey(opts: {
5
+ topicId?: string;
6
+ session: string;
7
+ }): string;
8
+ export declare function getDecisionFilePath(userId: number | string, scopeKey: string): string;
9
+ export declare function getDecisionGraphSvgPath(userId: number | string, scopeKey: string): string;
10
+ export declare function writeDecisionGraphSvg(userId: number | string, scopeKey: string, svg: string): string;
11
+ export declare function readDecisions(userId: number | string, scopeKey: string): StoredDecision[];
12
+ export declare function writeDecisions(userId: number | string, scopeKey: string, decisions: StoredDecision[]): void;
13
+ export interface DecisionCreateInput {
14
+ action: string;
15
+ reasoning: string;
16
+ agent: AgentKind;
17
+ model?: string;
18
+ status?: StoredDecision["status"];
19
+ causedBy?: string[];
20
+ timestamp?: number;
21
+ }
22
+ export interface DecisionUpdateInput {
23
+ id: string;
24
+ action?: string;
25
+ reasoning?: string;
26
+ status?: StoredDecision["status"];
27
+ causedBy?: string[];
28
+ }
29
+ export declare function validateDecisionGraph(decisions: StoredDecision[]): void;
30
+ export declare function createDecisions(decisions: StoredDecision[], inputs: DecisionCreateInput[]): {
31
+ decisions: StoredDecision[];
32
+ created: StoredDecision[];
33
+ };
34
+ export declare function updateDecisions(decisions: StoredDecision[], updates: DecisionUpdateInput[]): {
35
+ decisions: StoredDecision[];
36
+ missing: string[];
37
+ };
38
+ export declare function deleteDecisions(decisions: StoredDecision[], opts: {
39
+ ids?: string[];
40
+ all?: boolean;
41
+ }): {
42
+ decisions: StoredDecision[];
43
+ removed: number;
44
+ };
45
+ export declare function renderDecisionList(decisions: StoredDecision[]): string;
@@ -15,6 +15,8 @@ export * as askUserGates from "./ask-user-gates";
15
15
  export * from "./ask-user-gates";
16
16
  export * as conversations from "./conversations";
17
17
  export * from "./conversations";
18
+ export * as decisions from "./decisions";
19
+ export * from "./decisions";
18
20
  export type { ForumTopicInfo, TopicRow, UserForumConfig, UserRow, } from "./forum/index";
19
21
  export * as forum from "./forum/index";
20
22
  export { addTopic, clearDmSessionId, clearSessionForTopic, findUserByThread, flushSessionCache, getAllTopics, getAllUserIds, getCommunicateThreadId, getDmSessionId, getLastShownConfig, getSessionForTopic, getTopicAgent, getTopicByName as getForumTopicByName, getTopicDescription, getTopicMcpConfig, getTopicNames, getUserConfig, removeTopic, renameTopic, setDmSessionId, setLastShownConfig, setSessionForTopic, setTopicAgent, setTopicDescription, setTopicForkOrigin, setTopicMcpEnabled, setTopicMcpExtra, updateTopicThreadId, } from "./forum/index";
@@ -77,6 +77,18 @@ export interface TaskSnapshot {
77
77
  /** Owner / agent name for multi-agent runs, when set. */
78
78
  owner?: string;
79
79
  }
80
+ /** One topic-scoped decision and its incoming causal edges. */
81
+ export interface DecisionSnapshot {
82
+ id: string;
83
+ action: string;
84
+ reasoning: string;
85
+ agent: AgentKind;
86
+ model?: string;
87
+ status: "proposed" | "accepted" | "executed" | "rejected" | "superseded";
88
+ /** Upstream decision ids. Each entry forms a directed upstream -> this edge. */
89
+ causedBy?: string[];
90
+ timestamp: number;
91
+ }
80
92
  export type UnifiedEvent = {
81
93
  type: "user_message";
82
94
  content: string;
@@ -1 +1 @@
1
- export declare const NEGOTIUM_VERSION = "0.2.33";
1
+ export declare const NEGOTIUM_VERSION = "0.3.1";
package/dist/vault.js CHANGED
@@ -126,7 +126,7 @@ var DM_WORKSPACE_DIR = resolve(STATE_DIR, "data", "dm");
126
126
  var SESSION_WORKSPACE_DIR = resolve(STATE_DIR, "data", "sessions");
127
127
  var CLAUDE_EXECUTABLE_ENV = envText("NEGOTIUM_CLAUDE_EXECUTABLE");
128
128
  var CLAUDE_EXECUTABLE = CLAUDE_EXECUTABLE_ENV ? resolve(CLAUDE_EXECUTABLE_ENV) : undefined;
129
- var BROWSER_RS_VERSION = "v0.1.19";
129
+ var BROWSER_RS_VERSION = "v0.1.21";
130
130
  var BROWSER_RS_MIN_SECURE_VERSION = "0.1.15";
131
131
  function versionAtLeast(actualVersion, minimumVersion) {
132
132
  const actual = actualVersion.split(".").map(Number);
@@ -196,6 +196,7 @@ var TSX_LOADER = createRequire(import.meta.url).resolve("tsx");
196
196
  var TSCONFIG_PATH = resolve(PROJECT_ROOT, "tsconfig.json");
197
197
  var SESSION_COMM_SERVER = resolve(PROJECT_ROOT, "src/mcp/session-comm/server.ts");
198
198
  var TASK_SERVER = resolve(PROJECT_ROOT, "src/mcp/task-server.ts");
199
+ var DECISION_SERVER = resolve(PROJECT_ROOT, "src/mcp/decision-server.ts");
199
200
  var BROWSER_MCP_SSE_PROXY_SERVER = resolve(PROJECT_ROOT, "src/mcp/browser-sse-proxy-server.ts");
200
201
  var CANONICAL_MCP_PROXY_SERVER = resolve(PROJECT_ROOT, "src/mcp/canonical-proxy-server.ts");
201
202
  var WIKI_SERVER = resolve(PROJECT_ROOT, "src/mcp/wiki-server.ts");
@@ -773,4 +774,4 @@ export {
773
774
  VAULT_DESCRIPTION_MAX_LENGTH
774
775
  };
775
776
 
776
- //# debugId=F72AB94C01B5095364756E2164756E21
777
+ //# debugId=BFFEA49F4053A73F64756E2164756E21