newmark-agent 0.5.14 → 0.5.15

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/dist/conversation-utility-host.bundle.cjs +3373 -1900
  2. package/dist/conversation-utility-host.js +1 -1
  3. package/dist/core/agent.d.ts +105 -14
  4. package/dist/core/agent.js +658 -104
  5. package/dist/core/agentKernel/agent.d.ts +1 -0
  6. package/dist/core/agentKernel/agent.js +9 -0
  7. package/dist/core/agentKernelDiagnostics.d.ts +4 -6
  8. package/dist/core/agentKernelDiagnostics.js +12 -9
  9. package/dist/core/agentKernelRunner.d.ts +5 -0
  10. package/dist/core/agentKernelRunner.js +236 -85
  11. package/dist/core/autoRouter.js +16 -3
  12. package/dist/core/conversationCommandState.d.ts +17 -0
  13. package/dist/core/conversationCommandState.js +140 -0
  14. package/dist/core/conversationKernel.d.ts +25 -4
  15. package/dist/core/conversationKernel.js +347 -83
  16. package/dist/core/conversationListEvent.d.ts +6 -0
  17. package/dist/core/conversationListEvent.js +14 -0
  18. package/dist/core/electronUtilityAgentClient.d.ts +4 -1
  19. package/dist/core/electronUtilityAgentClient.js +4 -4
  20. package/dist/core/electronUtilityRuntimePool.d.ts +8 -2
  21. package/dist/core/electronUtilityRuntimePool.js +11 -5
  22. package/dist/core/installUpdate.js +41 -29
  23. package/dist/core/providerUsageAccounting.d.ts +47 -0
  24. package/dist/core/providerUsageAccounting.js +71 -0
  25. package/dist/core/requestContextEstimate.d.ts +18 -0
  26. package/dist/core/requestContextEstimate.js +54 -0
  27. package/dist/core/subagent.d.ts +89 -5
  28. package/dist/core/subagent.js +264 -41
  29. package/dist/core/subagentCommunication.d.ts +43 -0
  30. package/dist/core/subagentCommunication.js +167 -0
  31. package/dist/core/types.d.ts +32 -1
  32. package/dist/core/utilityAgentProtocol.d.ts +4 -0
  33. package/dist/core/workEventCoalescer.js +4 -1
  34. package/dist/core/wslAgentClient.d.ts +18 -5
  35. package/dist/core/wslAgentClient.js +79 -27
  36. package/dist/core/wslAgentProtocol.d.ts +7 -0
  37. package/dist/core/wslAgentRuntimePool.d.ts +8 -2
  38. package/dist/core/wslAgentRuntimePool.js +19 -6
  39. package/dist/core/wslRuntimeProcessTree.d.ts +10 -0
  40. package/dist/core/wslRuntimeProcessTree.js +104 -0
  41. package/dist/llm/provider.d.ts +5 -12
  42. package/dist/llm/provider.js +148 -267
  43. package/dist/main.js +582 -356
  44. package/dist/preload.js +3 -3
  45. package/dist/providers/chat-completions.adapter.d.ts +2 -0
  46. package/dist/providers/chat-completions.adapter.js +84 -36
  47. package/dist/providers/provider-adapter.d.ts +2 -0
  48. package/dist/providers/provider-events.d.ts +23 -14
  49. package/dist/providers/provider-events.js +148 -43
  50. package/dist/providers/provider-headers.d.ts +7 -3
  51. package/dist/providers/provider-headers.js +109 -39
  52. package/dist/providers/provider-request-compat.d.ts +6 -0
  53. package/dist/providers/provider-request-compat.js +37 -0
  54. package/dist/providers/responses.adapter.d.ts +2 -0
  55. package/dist/providers/responses.adapter.js +192 -126
  56. package/dist/server.d.ts +9 -2
  57. package/dist/server.js +100 -24
  58. package/dist/tools/index.js +17 -1
  59. package/dist/ui/index.html +2374 -616
  60. package/dist/ui/lucide-sprite.svg +7 -0
  61. package/dist/ui/startup.html +6 -6
  62. package/dist/wsl-agent-host.bundle.cjs +3381 -1906
  63. package/dist/wsl-agent-host.js +9 -4
  64. package/package.json +23 -4
@@ -0,0 +1,140 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.ConversationCommandStateStore = void 0;
37
+ const fs = __importStar(require("node:fs"));
38
+ const path = __importStar(require("node:path"));
39
+ const node_crypto_1 = require("node:crypto");
40
+ const modes = new Set(['build', 'plan', 'chat', 'goal', 'flow']);
41
+ function stateValue(value) {
42
+ if (!value || typeof value !== 'object' || Array.isArray(value))
43
+ throw new Error('Invalid conversation command state');
44
+ const row = value;
45
+ const result = {};
46
+ if (row.mode !== undefined) {
47
+ if (typeof row.mode !== 'string' || !modes.has(row.mode))
48
+ throw new Error('Invalid conversation mode');
49
+ result.mode = row.mode;
50
+ }
51
+ if (row.inputMode !== undefined) {
52
+ if (row.inputMode !== 'guide' && row.inputMode !== 'next')
53
+ throw new Error('Invalid conversation input mode');
54
+ result.inputMode = row.inputMode;
55
+ }
56
+ if (row.queuePaused !== undefined) {
57
+ if (typeof row.queuePaused !== 'boolean')
58
+ throw new Error('Invalid conversation queue pause state');
59
+ result.queuePaused = row.queuePaused;
60
+ }
61
+ return result;
62
+ }
63
+ /** GUI command owner only; execution and continuation payloads remain owned by their Agent. */
64
+ class ConversationCommandStateStore {
65
+ file;
66
+ records = new Map();
67
+ constructor(root) {
68
+ this.file = path.join(path.resolve(root), 'conversation-command-state.json');
69
+ let source;
70
+ try {
71
+ source = fs.readFileSync(this.file, 'utf8');
72
+ }
73
+ catch (error) {
74
+ if (error.code === 'ENOENT')
75
+ return;
76
+ throw error;
77
+ }
78
+ const saved = JSON.parse(source);
79
+ if (saved?.version !== 1 || !saved.targets || typeof saved.targets !== 'object' || Array.isArray(saved.targets)) {
80
+ throw new Error('Unsupported conversation command state file');
81
+ }
82
+ for (const [key, value] of Object.entries(saved.targets))
83
+ this.records.set(this.key(key), stateValue(value));
84
+ }
85
+ get(key) {
86
+ const value = this.records.get(this.key(key));
87
+ return value ? { ...value } : undefined;
88
+ }
89
+ set(key, patch) {
90
+ const target = this.key(key);
91
+ const before = this.records.get(target);
92
+ const after = { ...before, ...stateValue(patch) };
93
+ if (before && before.mode === after.mode && before.inputMode === after.inputMode && before.queuePaused === after.queuePaused)
94
+ return { ...before };
95
+ const next = new Map(this.records);
96
+ next.set(target, after);
97
+ this.persist(next);
98
+ return { ...after };
99
+ }
100
+ delete(key) {
101
+ const target = this.key(key);
102
+ if (!this.records.has(target))
103
+ return;
104
+ const next = new Map(this.records);
105
+ next.delete(target);
106
+ this.persist(next);
107
+ }
108
+ key(value) {
109
+ if (typeof value !== 'string' || !value.trim())
110
+ throw new Error('Conversation target key is required');
111
+ return value;
112
+ }
113
+ persist(next) {
114
+ fs.mkdirSync(path.dirname(this.file), { recursive: true });
115
+ const temp = this.file + '.' + (0, node_crypto_1.randomUUID)() + '.tmp';
116
+ let descriptor;
117
+ try {
118
+ descriptor = fs.openSync(temp, 'wx', 0o600);
119
+ fs.writeFileSync(descriptor, JSON.stringify({ version: 1, targets: Object.fromEntries(next) }) + '\n');
120
+ fs.fsyncSync(descriptor);
121
+ fs.closeSync(descriptor);
122
+ descriptor = undefined;
123
+ fs.renameSync(temp, this.file);
124
+ this.records = next;
125
+ }
126
+ finally {
127
+ if (descriptor !== undefined)
128
+ fs.closeSync(descriptor);
129
+ try {
130
+ fs.unlinkSync(temp);
131
+ }
132
+ catch (error) {
133
+ if (error.code !== 'ENOENT')
134
+ throw error;
135
+ }
136
+ }
137
+ }
138
+ }
139
+ exports.ConversationCommandStateStore = ConversationCommandStateStore;
140
+ //# sourceMappingURL=conversationCommandState.js.map
@@ -11,8 +11,9 @@ export interface ConversationQueueItemSnapshot {
11
11
  goalObjective?: string;
12
12
  runId?: string;
13
13
  createdAt: string;
14
+ images?: AgentPromptMessage['images'];
14
15
  }
15
- export type ConversationQueueAction = 'enqueue' | 'update' | 'delete' | 'reorder' | 'toggle_pause' | 'guide';
16
+ export type ConversationQueueAction = 'enqueue' | 'update' | 'delete' | 'reorder' | 'toggle_pause' | 'set_pause' | 'guide';
16
17
  export interface ConversationQueueActionInput {
17
18
  id?: string;
18
19
  text?: string;
@@ -21,6 +22,7 @@ export interface ConversationQueueActionInput {
21
22
  createdAt?: string;
22
23
  images?: AgentPromptMessage['images'];
23
24
  orderedIds?: string[];
25
+ paused?: boolean;
24
26
  }
25
27
  export interface AgentPromptMessage {
26
28
  text: string;
@@ -38,6 +40,9 @@ export interface AgentPromptMessage {
38
40
  }>;
39
41
  attachments?: ConversationImageAttachment[];
40
42
  clientMessageId?: string;
43
+ /** Stable ordinary user identity; unlike clientMessageId alone, never denotes a Guide. */
44
+ userMessageId?: string;
45
+ createdAt?: string;
41
46
  guideId?: string;
42
47
  runId?: string;
43
48
  /**
@@ -189,7 +194,19 @@ export declare class ConversationKernel {
189
194
  constructor(root: string, host: Agent, automation: AutomationManager | null, lifecycle?: ConversationKernelLifecycle);
190
195
  subscribe(listener: WorkListener): () => void;
191
196
  isRunning(target: ConversationTargetInput): boolean;
197
+ conversationOwner(target: ConversationTargetInput): Agent | null;
198
+ /** Branch mutations retain the Agent but reload that branch's durable queue. */
199
+ refreshIdleConversation(target: ConversationTargetInput): void;
200
+ /** Detach idle owners before config replacement or workspace removal. */
201
+ disposeIdle(workspaceKey?: string): string[];
202
+ /** A Flow and its queue share one Agent; no second history writer is created. */
203
+ beginExternalRun(targetInput: ConversationTargetInput, options: ConversationKernelRunOptions, createOwner: () => Agent, previousQueuePaused?: boolean): Agent;
204
+ settleExternalRun(target: ConversationTargetInput, completed: boolean): void;
205
+ releaseExternalRun(target: ConversationTargetInput, paused: boolean): void;
206
+ prepareForArchive(target: ConversationTargetInput): Promise<Agent | null>;
207
+ finishArchive(target: ConversationTargetInput, completed: boolean, preserveOwner?: boolean): void;
192
208
  isAnyRunning(): boolean;
209
+ hasRetainedWork(): boolean;
193
210
  flushPersistence(): void;
194
211
  queued(target: ConversationTargetInput): {
195
212
  steering: string[];
@@ -216,7 +233,7 @@ export declare class ConversationKernel {
216
233
  createdAt?: string;
217
234
  images?: AgentPromptMessage['images'];
218
235
  }): ConversationQueueItemSnapshot;
219
- updateQueueItem(target: ConversationTargetInput, idInput: string, textInput: string): ConversationQueueItemSnapshot;
236
+ updateQueueItem(target: ConversationTargetInput, idInput: string, textInput: string, input?: ConversationQueueActionInput): ConversationQueueItemSnapshot;
220
237
  deleteQueueItem(target: ConversationTargetInput, idInput: string): boolean;
221
238
  reorderQueueItems(target: ConversationTargetInput, orderedIdsInput: string[]): ConversationQueueItemSnapshot[];
222
239
  setQueuePaused(target: ConversationTargetInput, paused: boolean): boolean;
@@ -233,7 +250,10 @@ export declare class ConversationKernel {
233
250
  events(target: ConversationTargetInput): AgentWorkEvent[];
234
251
  waitForIdle(target: ConversationTargetInput): Promise<void>;
235
252
  pendingOptions(target: ConversationTargetInput): OptionQuestion[] | undefined;
236
- snapshot(target: ConversationTargetInput): ReturnType<Agent['getConversationSnapshot']> & {
253
+ snapshot(target: ConversationTargetInput, options?: {
254
+ window?: number;
255
+ before?: number;
256
+ }): ReturnType<Agent['getConversationSnapshot']> & {
237
257
  target: NormalizedConversationTarget;
238
258
  queued: {
239
259
  steering: string[];
@@ -277,6 +297,7 @@ export declare class ConversationKernel {
277
297
  setMode(target: ConversationTargetInput, mode: AgentMode): AgentMode;
278
298
  setModel(target: ConversationTargetInput, model: string): string;
279
299
  toggleGoalPause(target: ConversationTargetInput): Promise<boolean>;
300
+ updateGoal(target: ConversationTargetInput, objective: string): ReturnType<Agent['getConversationSnapshot']>['goal'];
280
301
  clearGoal(target: ConversationTargetInput): boolean;
281
302
  updateSetting(section: string, key: string, value: unknown): void;
282
303
  runtimeState(target: ConversationTargetInput): ConversationRuntimeState | null;
@@ -304,6 +325,7 @@ export declare class ConversationKernel {
304
325
  private runtime;
305
326
  private scheduleGoalContinuation;
306
327
  private schedulePendingRuntimeContinuation;
328
+ private runPendingQueueItem;
307
329
  private startGoalDrivenBuild;
308
330
  private createRunner;
309
331
  private enqueueRootInboxWake;
@@ -320,7 +342,6 @@ export declare class ConversationKernel {
320
342
  private enqueueSameSession;
321
343
  private trackQueuedMessage;
322
344
  private consumeQueuedMessage;
323
- private replaceTrackedQueuedMessage;
324
345
  private emitQueueUpdate;
325
346
  private clearQueued;
326
347
  private queueState;