negotium 0.7.0 → 0.7.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/registry.js CHANGED
@@ -133,7 +133,7 @@ var codexRegistryOperations = {
133
133
  return { sessionId: threadId, rolloutPath };
134
134
  },
135
135
  async forkSession({ parentSessionId }) {
136
- const { forkCodexSession } = await import("./chunk-9h53kw24.js");
136
+ const { forkCodexSession } = await import("./chunk-4y98yvq8.js");
137
137
  return await forkCodexSession(parentSessionId);
138
138
  },
139
139
  async cleanupRollouts({ sessionIds }) {
@@ -395,8 +395,15 @@ export type {
395
395
  RestartTopicSessionResult,
396
396
  } from "#topics/session";
397
397
  export { compactTopicSession, restartTopicSession } from "#topics/session";
398
- export type { UpdateTopicSettingsOptions } from "#topics/update";
399
- export { TopicUpdateConflictError, updateTopicSettings } from "#topics/update";
398
+ export type {
399
+ UpdateManagerTopicRuntimeConfigOptions,
400
+ UpdateTopicSettingsOptions,
401
+ } from "#topics/update";
402
+ export {
403
+ TopicUpdateConflictError,
404
+ updateManagerTopicRuntimeConfig,
405
+ updateTopicSettings,
406
+ } from "#topics/update";
400
407
  export * from "#types";
401
408
  // ── Types ───────────────────────────────────────────────────────────
402
409
  export { EFFORT_VALUES } from "#types";
@@ -109,7 +109,11 @@ export {
109
109
  } from "#topics/derive";
110
110
  export { ensurePersonalGeneral } from "#topics/personal-general";
111
111
  export { compactTopicSession } from "#topics/session";
112
- export { TopicUpdateConflictError, updateTopicSettings } from "#topics/update";
112
+ export {
113
+ TopicUpdateConflictError,
114
+ updateManagerTopicRuntimeConfig,
115
+ updateTopicSettings,
116
+ } from "#topics/update";
113
117
  export type { AgentKind, EffortLevel } from "#types";
114
118
  export type { AiMode, AttachmentDto, TopicDto, TopicSurface } from "#types/api";
115
119
  export { NEGOTIUM_VERSION } from "#version";
@@ -14,15 +14,17 @@ import { resolveModelForAgent } from "#agents/model-catalog";
14
14
  import { getRegistry } from "#agents/registry";
15
15
  import { WsHub } from "#bus";
16
16
  import { RESERVED_TOPIC_NAMES } from "#platform/constants";
17
- import { getApiTopicConfig, setApiTopicConfig } from "#storage/api-topic-config";
17
+ import { getApiTopicConfig, setApiTopicConfig, type TopicConfig } from "#storage/api-topic-config";
18
18
  import {
19
19
  findTopicTitleConflict,
20
20
  getTopic,
21
21
  normalizeAiMode,
22
22
  normalizeTopicKind,
23
23
  normalizeTopicState,
24
+ setApiTopicAgent,
24
25
  upsertTopic,
25
26
  } from "#storage/api-topics";
27
+ import { db } from "#storage/forum-db";
26
28
  import { TopicValidationError } from "#topics/create";
27
29
  import { type AgentKind, type EffortLevel, isAgentKind } from "#types";
28
30
  import type { AiMode, TopicDto } from "#types/api";
@@ -42,6 +44,69 @@ export interface UpdateTopicSettingsOptions {
42
44
  aiMode?: AiMode;
43
45
  }
44
46
 
47
+ export interface UpdateManagerTopicRuntimeConfigOptions {
48
+ topicId: string;
49
+ agent: AgentKind;
50
+ config: TopicConfig;
51
+ }
52
+
53
+ /**
54
+ * Atomically update the execution settings of a system-managed General room.
55
+ * Its identity fields remain protected by updateTopicSettings; only the
56
+ * canonical agent/defaults and per-topic override move together here.
57
+ */
58
+ export function updateManagerTopicRuntimeConfig(
59
+ opts: UpdateManagerTopicRuntimeConfigOptions,
60
+ ): TopicDto {
61
+ const current = getTopic(opts.topicId);
62
+ if (!current) throw new TopicValidationError("Topic not found");
63
+ if (current.kind !== "manager") {
64
+ throw new TopicValidationError("Runtime config agent updates are manager-only");
65
+ }
66
+ if (!isAgentKind(opts.agent)) throw new TopicValidationError(`Unknown agent '${opts.agent}'`);
67
+
68
+ const registry = getRegistry(opts.agent);
69
+ if (
70
+ opts.config.model &&
71
+ resolveModelForAgent(opts.agent, opts.config.model, registry) !== opts.config.model
72
+ ) {
73
+ throw new TopicValidationError(`Invalid model for agent ${opts.agent}`);
74
+ }
75
+ if (opts.config.effort && !registry.validateEffort(opts.config.effort)) {
76
+ throw new TopicValidationError(`Invalid effort for agent ${opts.agent}`);
77
+ }
78
+
79
+ const defaultModel = resolveModelForAgent(
80
+ opts.agent,
81
+ opts.config.model ?? (opts.agent === current.agent ? current.defaultModel : undefined),
82
+ registry,
83
+ );
84
+ const requestedEffort =
85
+ opts.config.effort ?? (opts.agent === current.agent ? current.defaultEffort : undefined);
86
+ const defaultEffort =
87
+ requestedEffort && registry.validateEffort(requestedEffort)
88
+ ? requestedEffort
89
+ : (registry.defaultEffort ?? "medium");
90
+
91
+ db.transaction(() => {
92
+ setApiTopicAgent(current.id, opts.agent, {
93
+ model: defaultModel,
94
+ effort: defaultEffort,
95
+ });
96
+ setApiTopicConfig(current.id, opts.config);
97
+ })();
98
+
99
+ WsHub.get().broadcastTopicUpdated(current.id);
100
+ return (
101
+ getTopic(current.id) ?? {
102
+ ...current,
103
+ agent: opts.agent,
104
+ defaultModel,
105
+ defaultEffort,
106
+ }
107
+ );
108
+ }
109
+
45
110
  /** A title that is already taken by another room on the same surface. */
46
111
  export class TopicUpdateConflictError extends Error {
47
112
  constructor(message: string) {
@@ -1 +1 @@
1
- export const NEGOTIUM_VERSION = "0.7.0";
1
+ export const NEGOTIUM_VERSION = "0.7.1";
@@ -1 +1 @@
1
- export declare const NEGOTIUM_VERSION = "0.7.0";
1
+ export declare const NEGOTIUM_VERSION = "0.7.1";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "negotium",
3
- "version": "0.7.0",
3
+ "version": "0.7.1",
4
4
  "type": "module",
5
5
  "description": "Install the Negotium multi-agent runtime and CLI with one package",
6
6
  "license": "Apache-2.0",