negotium 0.1.37 → 0.1.39

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 (64) hide show
  1. package/README.md +19 -0
  2. package/dist/agent-helpers.js +15637 -5674
  3. package/dist/agent-helpers.js.map +85 -37
  4. package/dist/browser-runtime.js +1600 -0
  5. package/dist/browser-runtime.js.map +28 -0
  6. package/dist/hosted-agent.js +8 -8
  7. package/dist/hosted-agent.js.map +6 -5
  8. package/dist/main.js +3790 -3113
  9. package/dist/main.js.map +33 -29
  10. package/dist/mcp-factories.js +15141 -301
  11. package/dist/mcp-factories.js.map +100 -7
  12. package/dist/prompts.js +117 -49
  13. package/dist/prompts.js.map +3 -3
  14. package/dist/query-runtime.js +310 -1
  15. package/dist/query-runtime.js.map +10 -5
  16. package/dist/runtime/src/agents/archiver.ts +407 -296
  17. package/dist/runtime/src/agents/mcp-tools/ask-user.ts +440 -274
  18. package/dist/runtime/src/agents/mcp-tools/self-config.ts +139 -65
  19. package/dist/runtime/src/agents/mcp-tools/spawn-subagent.ts +1037 -816
  20. package/dist/runtime/src/agents/public-helpers.ts +82 -0
  21. package/dist/runtime/src/agents/self-config-core.ts +574 -278
  22. package/dist/runtime/src/agents/topic-cleanup.ts +167 -129
  23. package/dist/runtime/src/index.ts +4 -1
  24. package/dist/runtime/src/mcp/factories/index.ts +9 -0
  25. package/dist/runtime/src/mcp/session-comm/topic-catalog.ts +132 -0
  26. package/dist/runtime/src/mcp/session-comm/topics.ts +23 -57
  27. package/dist/runtime/src/platform/mcp-config.ts +2 -4
  28. package/dist/runtime/src/platform/playwright/browser-processes.ts +3 -2
  29. package/dist/runtime/src/platform/playwright/capability.ts +5 -0
  30. package/dist/runtime/src/platform/playwright/manager.ts +380 -66
  31. package/dist/runtime/src/platform/playwright/public-runtime.ts +45 -0
  32. package/dist/runtime/src/platform/playwright/transport-probe.ts +89 -0
  33. package/dist/runtime/src/prompts/builders.ts +192 -51
  34. package/dist/runtime/src/query/active-rooms.ts +2 -0
  35. package/dist/runtime/src/query/public-runtime.ts +8 -0
  36. package/dist/runtime/src/query/state.ts +69 -33
  37. package/dist/runtime/src/query/types.ts +1 -0
  38. package/dist/runtime/src/runtime/playwright-turn-abort.ts +59 -0
  39. package/dist/runtime/src/runtime/turn-event-stream.ts +23 -6
  40. package/dist/runtime/src/runtime/turn-runner.ts +6 -1
  41. package/dist/runtime/src/version.ts +1 -1
  42. package/dist/types/packages/core/src/agents/api-topic-agent-switch.d.ts +38 -0
  43. package/dist/types/packages/core/src/agents/archiver.d.ts +52 -16
  44. package/dist/types/packages/core/src/agents/mcp-tools/ask-user.d.ts +75 -4
  45. package/dist/types/packages/core/src/agents/mcp-tools/self-config.d.ts +17 -0
  46. package/dist/types/packages/core/src/agents/mcp-tools/spawn-subagent.d.ts +112 -25
  47. package/dist/types/packages/core/src/agents/public-helpers.d.ts +7 -0
  48. package/dist/types/packages/core/src/agents/self-config-core.d.ts +185 -0
  49. package/dist/types/packages/core/src/agents/topic-cleanup.d.ts +30 -24
  50. package/dist/types/packages/core/src/mcp/factories/index.d.ts +1 -0
  51. package/dist/types/packages/core/src/mcp/session-comm/topic-catalog.d.ts +46 -0
  52. package/dist/types/packages/core/src/platform/mcp-config.d.ts +2 -1
  53. package/dist/types/packages/core/src/platform/playwright/capability.d.ts +1 -0
  54. package/dist/types/packages/core/src/platform/playwright/manager.d.ts +65 -5
  55. package/dist/types/packages/core/src/platform/playwright/public-runtime.d.ts +4 -0
  56. package/dist/types/packages/core/src/platform/playwright/transport-probe.d.ts +13 -0
  57. package/dist/types/packages/core/src/prompts/builders.d.ts +29 -3
  58. package/dist/types/packages/core/src/query/active-rooms.d.ts +2 -0
  59. package/dist/types/packages/core/src/query/public-runtime.d.ts +1 -0
  60. package/dist/types/packages/core/src/query/state.d.ts +13 -0
  61. package/dist/types/packages/core/src/query/types.d.ts +2 -1
  62. package/dist/types/packages/core/src/runtime/playwright-turn-abort.d.ts +12 -0
  63. package/dist/types/packages/core/src/version.d.ts +1 -1
  64. package/package.json +6 -1
@@ -11,8 +11,12 @@
11
11
  * Permanent forensic preservation lives in `wiki/archive/` via
12
12
  * `archiveSessionLogs`; this module is the matching teardown side.
13
13
  */
14
- import { type ConversationEntry } from "../storage/conversations";
15
- import type { AgentKind } from "../types";
14
+ import type { AgentKind, UnifiedEvent } from "../types";
15
+ export interface TopicConversationEntry {
16
+ ts: string;
17
+ agent: AgentKind;
18
+ event: UnifiedEvent;
19
+ }
16
20
  export interface PurgeSessionRef {
17
21
  agent: AgentKind;
18
22
  sessionId: string;
@@ -37,10 +41,21 @@ export interface PurgeTopicLogsOptions {
37
41
  */
38
42
  extraSessions?: PurgeSessionRef[];
39
43
  }
40
- /** Remove every provider rollout currently manifested by a topic log. */
41
- export declare function cleanupTopicRollouts(opts: PurgeTopicLogsOptions): Promise<boolean>;
42
- /** Remove rollout ids captured from a point-in-time conversation manifest. */
43
- export declare function cleanupTopicRolloutsFromEntries(opts: PurgeTopicLogsOptions, entries: ConversationEntry[]): Promise<boolean>;
44
+ export interface TopicLogMaintenanceHost {
45
+ readonly agents: readonly AgentKind[];
46
+ readonly readActiveConversation: (userId: number | string, topicName: string) => TopicConversationEntry[];
47
+ readonly readRawConversation: (userId: number | string, topicName: string) => TopicConversationEntry[];
48
+ readonly activeConversationPath: (userId: number | string, topicName: string) => string;
49
+ readonly rawConversationPath: (userId: number | string, topicName: string) => string;
50
+ readonly cleanupRollouts: (agent: AgentKind, cwd: string, sessionIds: string[]) => Promise<void>;
51
+ readonly warn: (context: Record<string, unknown>, message: string) => void;
52
+ }
53
+ export interface TopicLogMaintenance {
54
+ cleanupTopicRollouts(opts: PurgeTopicLogsOptions): Promise<boolean>;
55
+ cleanupTopicRolloutsFromEntries(opts: PurgeTopicLogsOptions, entries: TopicConversationEntry[]): Promise<boolean>;
56
+ rotateTopicLogs(opts: RotateTopicLogsOptions): Promise<RotateTopicLogsResult>;
57
+ purgeTopicLogs(opts: PurgeTopicLogsOptions): Promise<boolean>;
58
+ }
44
59
  export interface RotateTopicLogsOptions extends PurgeTopicLogsOptions {
45
60
  /** Number of complete user turns carried into the replacement session. */
46
61
  retainTurns: number;
@@ -51,27 +66,18 @@ export interface RotateTopicLogsResult {
51
66
  retainedTurns: number;
52
67
  retainedEntries: number;
53
68
  }
69
+ export declare function createTopicLogMaintenance(host: TopicLogMaintenanceHost): TopicLogMaintenance;
70
+ /** Remove every provider rollout currently manifested by a topic log. */
71
+ export declare const cleanupTopicRollouts: (opts: PurgeTopicLogsOptions) => Promise<boolean>;
72
+ /** Remove rollout ids captured from a point-in-time conversation manifest. */
73
+ export declare const cleanupTopicRolloutsFromEntries: (opts: PurgeTopicLogsOptions, entries: TopicConversationEntry[]) => Promise<boolean>;
54
74
  /**
55
75
  * Replace a topic's native provider sessions while retaining a bounded tail
56
- * of its provider-neutral conversation log. This is used by long-lived Cron
57
- * topics: a fresh native rollout keeps prompt/session state bounded, and the
58
- * retained tail gives the next rollout enough context to continue naturally.
76
+ * of its provider-neutral conversation log.
59
77
  */
60
- export declare function rotateTopicLogs(opts: RotateTopicLogsOptions): Promise<RotateTopicLogsResult>;
78
+ export declare const rotateTopicLogs: (opts: RotateTopicLogsOptions) => Promise<RotateTopicLogsResult>;
61
79
  /**
62
80
  * Best-effort teardown of every artifact associated with a topic's
63
- * conversation lifecycle. Order matters and is intentional:
64
- *
65
- * 1. Read the unified log first — it's the authoritative manifest of
66
- * every SDK session id the topic has emitted. Merge any DB session id
67
- * passed via `extraSessions` for synthetic rollouts not yet emitted.
68
- * 2. Dispatch per-agent rollout cleanup in parallel (independent
69
- * filesystems, no shared state).
70
- * 3. Unlink the unified log LAST so a partial rollout-cleanup failure
71
- * leaves the manifest in place for a future retry.
72
- *
73
- * Errors at every step are logged and reported through the return value.
74
- * Callers must not commit a reset/delete state transition when this returns
75
- * false, because the retained manifest can otherwise resurrect old context.
81
+ * conversation lifecycle.
76
82
  */
77
- export declare function purgeTopicLogs(opts: PurgeTopicLogsOptions): Promise<boolean>;
83
+ export declare const purgeTopicLogs: (opts: PurgeTopicLogsOptions) => Promise<boolean>;
@@ -1,4 +1,5 @@
1
1
  export { parseSessionCommContext, type SessionCommContext, type SessionCommContextDefaults, } from "../session-comm/context";
2
+ export { createSessionTargetCatalog, type SessionTarget, type SessionTargetCatalog, type SessionTargetCatalogHost, type SessionTopicEntry, type SessionTopicRow, type ValidateSessionTargetResult, } from "../session-comm/topic-catalog";
2
3
  export { executeVaultHttpRequest } from "../vault-http";
3
4
  export { executeVaultRun } from "../vault-run";
4
5
  export { createWikiMcpServer, type WikiMcpContext, type WikiMcpHost, type WikiSurface, type WikiTopicBrief, } from "../wiki-server";
@@ -0,0 +1,46 @@
1
+ export interface SessionTopicRow {
2
+ id: string;
3
+ title: string;
4
+ kind: string | null;
5
+ agent: string | null;
6
+ sessionId: string | null;
7
+ description: string | null;
8
+ }
9
+ export interface SessionTopicEntry<TAgent extends string = string> {
10
+ sessionId: string;
11
+ messageThreadId: number;
12
+ name: string;
13
+ kind: "agent" | "channel";
14
+ description?: string;
15
+ topicId?: string;
16
+ agent?: TAgent;
17
+ }
18
+ export interface SessionTarget<TAgent extends string = string> {
19
+ key: string;
20
+ topic: SessionTopicEntry<TAgent>;
21
+ }
22
+ export type ValidateSessionTargetResult<TAgent extends string = string> = {
23
+ ok: true;
24
+ target: SessionTopicEntry<TAgent>;
25
+ } | {
26
+ ok: false;
27
+ error: {
28
+ content: Array<{
29
+ type: "text";
30
+ text: string;
31
+ }>;
32
+ isError: true;
33
+ };
34
+ };
35
+ export interface SessionTargetCatalogHost<TAgent extends string = string> {
36
+ readonly listRows: () => SessionTopicRow[];
37
+ readonly currentTopicId?: string;
38
+ readonly currentTopicName?: string;
39
+ readonly isAgent: (value: string | null) => value is TAgent;
40
+ }
41
+ export interface SessionTargetCatalog<TAgent extends string = string> {
42
+ listTargets(): SessionTarget<TAgent>[];
43
+ getTopics(): Record<string, SessionTopicEntry<TAgent>>;
44
+ validateTarget(to: string): ValidateSessionTargetResult<TAgent>;
45
+ }
46
+ export declare function createSessionTargetCatalog<TAgent extends string = string>(host: SessionTargetCatalogHost<TAgent>): SessionTargetCatalog<TAgent>;
@@ -1,4 +1,5 @@
1
1
  import { type RuntimeMcpScope } from "./mcp-catalog-policy";
2
+ import { browserOwnerCapability } from "./playwright/capability";
2
3
  import type { AgentKind, AgentQueryOptions, PeerRuntimeBridgeContext } from "../types";
3
4
  export type { RuntimeMcpScope } from "./mcp-catalog-policy";
4
5
  /**
@@ -100,7 +101,7 @@ export interface RuntimeMcpCatalogEntry {
100
101
  build(ctx: RuntimeMcpBuildContext): Record<string, unknown> | null;
101
102
  }
102
103
  export declare const CODEX_BROWSER_CAPABILITY_ENV = "NEGOTIUM_BROWSER_CAPABILITY";
103
- export declare function browserOwnerCapability(capability: string, owner: string): string;
104
+ export { browserOwnerCapability };
104
105
  export declare function browserOwnerForContext(ctx: {
105
106
  userId?: string;
106
107
  session?: string;
@@ -0,0 +1 @@
1
+ export declare function browserOwnerCapability(capability: string, owner: string): string;
@@ -1,18 +1,78 @@
1
- import { PLAYWRIGHT_PORTS_DIR } from "../config";
2
- export { cleanupZombiePlaywright, isBrowserJanitorOwner, selectOrphanBrowserPids, } from "./browser-processes";
1
+ import { type BrowserProxyConfig, PLAYWRIGHT_PORTS_DIR } from "../config";
2
+ export interface PlaywrightProfileBinding {
3
+ readonly instanceKey: string;
4
+ readonly ownerId: string;
5
+ readonly profile: string;
6
+ }
7
+ export interface PlaywrightChildEnvironmentContext {
8
+ instanceKey: string;
9
+ ownerId: string;
10
+ capability: string;
11
+ proxy: BrowserProxyConfig | null;
12
+ browserRsBin?: string;
13
+ environment: NodeJS.ProcessEnv;
14
+ }
15
+ export interface PlaywrightManagerHost {
16
+ readonly portsDir: string;
17
+ readonly basePort: number;
18
+ readonly maxPort: number;
19
+ readonly browserBin: string;
20
+ readonly fallbackBrowserBin: string;
21
+ readonly browserRsBin?: string;
22
+ readonly resolveProxy: () => BrowserProxyConfig | null;
23
+ readonly resolveTopicBinding: (userId: string, topic?: string) => PlaywrightProfileBinding;
24
+ readonly resolveNamedBinding: (ownerId: string, rawProfile: string) => PlaywrightProfileBinding;
25
+ readonly resolveInstanceDataDir: (instanceKey: string) => string;
26
+ readonly createChildEnvironment: (context: PlaywrightChildEnvironmentContext) => NodeJS.ProcessEnv;
27
+ /** Reap an orphan that owns this exact host-managed data directory. */
28
+ readonly cleanupBrowserProcessesForDataDir: (userDataDir: string) => void;
29
+ /** Reap host-managed browsers that are not represented by the supplied live directories. */
30
+ readonly reapOrphanBrowsers: (liveUserDataDirs: Iterable<string>) => void;
31
+ }
32
+ export { cleanupZombiePlaywright, isBrowserJanitorOwner, reapOrphanBrowsers, selectOrphanBrowserPids, } from "./browser-processes";
33
+ export { probePlaywrightMcpTransports } from "./transport-probe";
3
34
  export { browserProcessMatchesExpectedProfile, extractUserDataDirArg, selectIdleEvictionKey, selectReusablePort, waitForChildProcessExit, waitForChildProcessSpawnError, } from "./manager-utils";
4
35
  export { PLAYWRIGHT_PORTS_DIR };
5
36
  /** Multiple topics assigned to one profile reuse one browser process. */
6
37
  export declare function makeInstanceKey(userId: string, topic: string | undefined): string;
38
+ export declare function resolvePlaywrightTopicBinding(userId: string, topic: string | undefined): PlaywrightProfileBinding;
7
39
  export declare function makeBrowserProfileInstanceKey(ownerId: string, rawProfile: string): string;
40
+ export declare function resolvePlaywrightProfileBinding(ownerId: string, rawProfile: string): PlaywrightProfileBinding;
8
41
  export declare function legacyBrowserProfileName(topic: string): string;
42
+ /**
43
+ * Configure product-specific profile storage and browser launch glue.
44
+ * Call once during bootstrap, before any browser instance is started.
45
+ */
46
+ export declare function configurePlaywrightManagerHost(overrides: Partial<PlaywrightManagerHost>): Readonly<PlaywrightManagerHost>;
47
+ export declare function getPlaywrightManagerHost(): Readonly<PlaywrightManagerHost>;
48
+ /** Restore Negotium's built-in browser host after all instances are stopped. */
49
+ export declare function resetPlaywrightManagerHost(): void;
50
+ export interface PlaywrightMaintenanceControl {
51
+ /** Stop one of the locked instances before mutating its profile directory. */
52
+ stopInstance(instanceKey: string): Promise<boolean>;
53
+ }
9
54
  /** Serialize destructive profile maintenance with normal browser startup. */
10
- export declare function withPlaywrightInstanceMaintenance<T>(rawKeys: string[], operation: () => Promise<T>): Promise<T>;
55
+ export declare function withPlaywrightInstanceMaintenance<T>(rawKeys: string[], operation: (control: PlaywrightMaintenanceControl) => Promise<T>): Promise<T>;
56
+ /** Stop one managed instance under the same serialization used by startup and profile mutation. */
57
+ export declare function stopPlaywrightInstance(instanceKey: string): Promise<boolean>;
58
+ /** Run owner-aware named-profile maintenance under one lifecycle barrier. */
59
+ export declare function withPlaywrightProfileMaintenance<T>(ownerId: string, rawProfile: string, operation: (binding: PlaywrightProfileBinding, control: PlaywrightMaintenanceControl) => Promise<T>): Promise<T>;
60
+ /** Stop a named profile before deleting or replacing its host-managed data directory. */
61
+ export declare function stopPlaywrightProfile(ownerId: string, rawProfile: string): Promise<boolean>;
11
62
  export declare function pinPlaywrightInstance(instanceKey: string): void;
12
63
  export declare function unpinPlaywrightInstance(instanceKey: string): void;
13
64
  export declare function getPlaywrightCapability(instanceKey: string): string | undefined;
14
- type PlaywrightExitHandler = (instanceKey: string, code: number | null) => void;
15
- export declare function onPlaywrightExit(handler: PlaywrightExitHandler): void;
65
+ /** Resolve a live browser capability back to its owning user. */
66
+ export declare function resolvePlaywrightCapabilityOwner(capability: string): string | undefined;
67
+ /** Run the configured host's path-bounded orphan sweep against current live instances. */
68
+ export declare function reapPlaywrightOrphans(): void;
69
+ export interface PlaywrightFailure {
70
+ reason: "exit" | "process-error" | "unhealthy";
71
+ code?: number | null;
72
+ error?: string;
73
+ }
74
+ type PlaywrightFailureHandler = (instanceKey: string, failure: PlaywrightFailure) => void;
75
+ export declare function onPlaywrightFailure(handler: PlaywrightFailureHandler): () => void;
16
76
  /**
17
77
  * Ensure a healthy browser MCP server is running for this topic's profile.
18
78
  * Topics assigned to the same profile reuse one process and data directory.
@@ -0,0 +1,4 @@
1
+ export { isBrowserJanitorOwner, selectOrphanBrowserPids, } from "./browser-processes";
2
+ export { closeBrowserOwnerTabs, configurePlaywrightManagerHost, ensureBrowserProfile, ensurePlaywright, getPlaywrightCapability, getPlaywrightManagerHost, killAllPlaywright, makeBrowserProfileInstanceKey, makeInstanceKey, onPlaywrightFailure, type PlaywrightChildEnvironmentContext, type PlaywrightFailure, type PlaywrightMaintenanceControl, type PlaywrightManagerHost, type PlaywrightProfileBinding, pinPlaywrightInstance, reapPlaywrightOrphans, resetPlaywrightManagerHost, resolvePlaywrightCapabilityOwner, resolvePlaywrightProfileBinding, resolvePlaywrightTopicBinding, resolveTopicProfileDir, stopPlaywrightInstance, stopPlaywrightProfile, unpinPlaywrightInstance, withPlaywrightInstanceMaintenance, withPlaywrightProfileMaintenance, } from "./manager";
3
+ export { browserProcessMatchesExpectedProfile, extractUserDataDirArg, selectIdleEvictionKey, selectReusablePort, waitForChildProcessExit, waitForChildProcessSpawnError, } from "./manager-utils";
4
+ export { probeMcpTransport, probePlaywrightMcpTransports, } from "./transport-probe";
@@ -0,0 +1,13 @@
1
+ import type { FetchLike, Transport } from "@modelcontextprotocol/sdk/shared/transport.js";
2
+ interface ProbeTransportOptions {
3
+ terminate?: () => Promise<void>;
4
+ timeoutMs?: number;
5
+ }
6
+ export declare function probeMcpTransport(transport: Transport, options?: ProbeTransportOptions): Promise<boolean>;
7
+ /**
8
+ * Exercise both authenticated transports used by browser-enabled agents.
9
+ * A process-only response or partial SSE handshake is insufficient: each
10
+ * transport must initialize, complete tools/list, and close cleanly.
11
+ */
12
+ export declare function probePlaywrightMcpTransports(port: number, capability: string, fetchImpl?: FetchLike): Promise<boolean>;
13
+ export {};
@@ -31,9 +31,35 @@ export interface SessionSystemPromptOpts {
31
31
  /** True only when the current adapter can deliver files to its chat. */
32
32
  fileDeliveryTools?: boolean;
33
33
  }
34
- export declare function buildTopicSystemPrompt(opts: SessionSystemPromptOpts): string;
35
- export declare function buildChannelSystemPrompt(opts: SessionSystemPromptOpts): string;
36
- export declare function buildManagerSystemPrompt(opts: SessionSystemPromptOpts): string;
34
+ export type SessionPromptKind = "topic" | "channel" | "manager";
35
+ export type PromptSectionSlot = "after-runtime-tools" | "after-shared-tasks" | "before-session-communication" | "after-session-communication" | "before-topic-configuration" | "after-topic-configuration" | "after-system-prompt";
36
+ export interface PromptSectionContext extends SessionSystemPromptOpts {
37
+ sessionKind: SessionPromptKind;
38
+ }
39
+ export interface PromptExtraSection {
40
+ id: string;
41
+ slot: PromptSectionSlot;
42
+ order?: number;
43
+ render(context: PromptSectionContext): string | null | undefined;
44
+ }
45
+ export interface PromptTemplateRequest {
46
+ kind: "topic-system" | "channel-system" | "manager-system" | "visual-design";
47
+ filename: string;
48
+ fallback: string;
49
+ }
50
+ export interface PromptBuilderHost {
51
+ readonly loadTemplate?: (request: PromptTemplateRequest) => string | null | undefined;
52
+ readonly extraSections?: readonly PromptExtraSection[];
53
+ }
54
+ export interface PromptBuilders {
55
+ buildTopicSystemPrompt(opts: SessionSystemPromptOpts): string;
56
+ buildChannelSystemPrompt(opts: SessionSystemPromptOpts): string;
57
+ buildManagerSystemPrompt(opts: SessionSystemPromptOpts): string;
58
+ }
59
+ export declare function createPromptBuilders(host?: PromptBuilderHost): PromptBuilders;
60
+ export declare const buildTopicSystemPrompt: (opts: SessionSystemPromptOpts) => string;
61
+ export declare const buildChannelSystemPrompt: (opts: SessionSystemPromptOpts) => string;
62
+ export declare const buildManagerSystemPrompt: (opts: SessionSystemPromptOpts) => string;
37
63
  export declare function buildMemoryPromptSection(opts: {
38
64
  briefFile: string;
39
65
  wikiDir: string;
@@ -104,6 +104,8 @@ export interface RoomQueryControl {
104
104
  sessionId?: string | null;
105
105
  abortController: AbortController;
106
106
  abortReason: AbortReason;
107
+ /** Specific failure surfaced when infrastructure aborts the turn. */
108
+ abortError?: string;
107
109
  /** Epoch ms when this turn claimed the room (stale-abort guard). */
108
110
  startedAt?: number;
109
111
  /**
@@ -1,3 +1,4 @@
1
1
  export { type DeferredInject, DeferredInjectBatcher, type DeferredInjectBatcherOptions, InterSessionQueue, type PrepareInjectSession, wsAbortReason, } from "./active-rooms";
2
2
  export { createRoomQueryRegistry, isIsolatedTurnRoomId, isolatedTurnRoomId, isUserOrigin, type RoomQueryControlLike, type RoomQueryDecision, type RoomQueryRegistry, type RoomQueryRegistryHost, type RuntimeTurnLeaseLike, } from "./room-query-registry";
3
+ export { clearQueryState, createQueryStateStore, type QueryStateStore, type QueryStateStoreLogger, type QueryStateStoreOptions, writeQueryState, } from "./state";
3
4
  export { AbortReason, type HandleAgentQueryOutcome, type HandleAgentQueryParams, } from "./types";
@@ -1,4 +1,17 @@
1
1
  type QueryStateUserId = number | string;
2
+ export interface QueryStateStoreLogger {
3
+ warn(context: Record<string, unknown>, message: string): void;
4
+ }
5
+ export interface QueryStateStoreOptions {
6
+ usersLogDir: string;
7
+ logger?: QueryStateStoreLogger;
8
+ sanitizeTopicId?: (topicId: string) => string;
9
+ }
10
+ export interface QueryStateStore {
11
+ write(userId: QueryStateUserId, topicId: string, topicName: string, task?: string): void;
12
+ clear(userId: QueryStateUserId, topicId: string, legacyTopicName?: string): void;
13
+ }
14
+ export declare function createQueryStateStore(options: QueryStateStoreOptions): QueryStateStore;
2
15
  export declare function writeQueryState(userId: QueryStateUserId, topicId: string, topicName: string, task?: string): void;
3
16
  export declare function clearQueryState(userId: QueryStateUserId, topicId: string, legacyTopicName?: string): void;
4
17
  export {};
@@ -59,6 +59,7 @@ export interface HandleAgentQueryParams extends BaseQueryParams, OutputParams, I
59
59
  export declare enum AbortReason {
60
60
  None = "none",
61
61
  Internal = "internal",// replaced by a newer query on the same topic
62
- External = "external"
62
+ External = "external",// /abort command or abort_session via session-inbox
63
+ Infrastructure = "infrastructure"
63
64
  }
64
65
  export {};
@@ -0,0 +1,12 @@
1
+ import { type PlaywrightFailure } from "../platform/playwright/manager";
2
+ import { AbortReason } from "../query/types";
3
+ export interface PlaywrightTurnControl {
4
+ topicId: string;
5
+ queryId: string;
6
+ abortController: AbortController;
7
+ abortReason: AbortReason;
8
+ abortError?: string;
9
+ }
10
+ export declare function trackPlaywrightTurn(instanceKey: string, control: PlaywrightTurnControl): void;
11
+ export declare function untrackPlaywrightTurn(instanceKey: string, control: PlaywrightTurnControl): void;
12
+ export declare function abortPlaywrightTurns(instanceKey: string, failure: PlaywrightFailure): number;
@@ -1 +1 @@
1
- export declare const NEGOTIUM_VERSION = "0.1.37";
1
+ export declare const NEGOTIUM_VERSION = "0.1.39";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "negotium",
3
- "version": "0.1.37",
3
+ "version": "0.1.39",
4
4
  "type": "module",
5
5
  "description": "Install the Negotium multi-agent runtime and CLI with one package",
6
6
  "license": "Apache-2.0",
@@ -78,6 +78,11 @@
78
78
  "import": "./dist/background-bash.js",
79
79
  "default": "./dist/background-bash.js"
80
80
  },
81
+ "./browser-runtime": {
82
+ "types": "./dist/types/packages/core/src/platform/playwright/public-runtime.d.ts",
83
+ "import": "./dist/browser-runtime.js",
84
+ "default": "./dist/browser-runtime.js"
85
+ },
81
86
  "./outbox": {
82
87
  "types": "./dist/types/packages/core/src/outbox/index.d.ts",
83
88
  "import": "./dist/outbox.js",