nexus-agentd 0.2.5 → 0.3.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 (61) hide show
  1. package/README.md +359 -250
  2. package/dist/a2a/runtime.d.ts +7 -1
  3. package/dist/a2a/runtime.js +290 -17
  4. package/dist/acp/runtime.d.ts +5 -1
  5. package/dist/acp/runtime.js +88 -39
  6. package/dist/artifact-store.d.ts +162 -0
  7. package/dist/artifact-store.js +1081 -0
  8. package/dist/cli.js +13 -14
  9. package/dist/completion-contract.js +1 -1
  10. package/dist/config.js +45 -5
  11. package/dist/control-plane-validation.d.ts +54 -0
  12. package/dist/control-plane-validation.js +152 -0
  13. package/dist/control-plane.d.ts +9 -32
  14. package/dist/control-plane.js +52 -158
  15. package/dist/drivers/index.js +12 -0
  16. package/dist/drivers/pi.js +1 -1
  17. package/dist/drivers/stdio.d.ts +4 -1
  18. package/dist/drivers/stdio.js +135 -19
  19. package/dist/events.d.ts +9 -0
  20. package/dist/events.js +17 -4
  21. package/dist/index.d.ts +1 -1
  22. package/dist/index.js +33 -6
  23. package/dist/process-tree.js +15 -6
  24. package/dist/run-store.d.ts +57 -7
  25. package/dist/run-store.js +188 -23
  26. package/dist/server/auth-policy.d.ts +27 -0
  27. package/dist/server/auth-policy.js +143 -0
  28. package/dist/server/connection.d.ts +8 -0
  29. package/dist/server/connection.js +67 -0
  30. package/dist/server/diagnostics.d.ts +40 -0
  31. package/dist/server/diagnostics.js +130 -0
  32. package/dist/server/metrics.d.ts +51 -0
  33. package/dist/server/metrics.js +56 -0
  34. package/dist/server/quota.d.ts +59 -0
  35. package/dist/server/quota.js +176 -0
  36. package/dist/server/validation.d.ts +29 -0
  37. package/dist/server/validation.js +221 -0
  38. package/dist/server.d.ts +3 -0
  39. package/dist/server.js +682 -418
  40. package/dist/session/admin-runs.d.ts +73 -0
  41. package/dist/session/admin-runs.js +297 -0
  42. package/dist/session/admission.d.ts +32 -0
  43. package/dist/session/admission.js +62 -0
  44. package/dist/session/readiness.d.ts +33 -0
  45. package/dist/session/readiness.js +174 -0
  46. package/dist/session-contract.d.ts +1 -0
  47. package/dist/session.d.ts +64 -7
  48. package/dist/session.js +321 -159
  49. package/dist/sse-writer.d.ts +7 -0
  50. package/dist/sse-writer.js +60 -0
  51. package/dist/types.d.ts +44 -2
  52. package/dist/types.js +1 -0
  53. package/dist/webui/app/sources.js +18 -10
  54. package/dist/webui/index.js +11 -11
  55. package/dist/webui/markup.js +69 -66
  56. package/dist/webui/styles.js +791 -616
  57. package/dist/workspace.d.ts +30 -0
  58. package/dist/workspace.js +67 -2
  59. package/examples/client.mjs +102 -0
  60. package/nexus-agentd.example.json +21 -2
  61. package/package.json +6 -3
@@ -0,0 +1,7 @@
1
+ import type { ServerResponse } from 'node:http';
2
+ /** A false write already accepted the chunk. Queue later chunks until drain,
3
+ * with both a byte ceiling and a deadline independent of socket activity. */
4
+ export declare function createSseWriter(response: ServerResponse, close: () => void, maxBytes?: number, drainMs?: number): {
5
+ write(chunk: string): boolean;
6
+ stop: () => void;
7
+ };
@@ -0,0 +1,60 @@
1
+ /** A false write already accepted the chunk. Queue later chunks until drain,
2
+ * with both a byte ceiling and a deadline independent of socket activity. */
3
+ export function createSseWriter(response, close, maxBytes = 512 * 1024, drainMs = 5_000) {
4
+ let stopped = false;
5
+ let blocked = false;
6
+ let queuedBytes = 0;
7
+ const queue = [];
8
+ let deadline;
9
+ const stop = () => {
10
+ if (stopped)
11
+ return;
12
+ stopped = true;
13
+ clearTimeout(deadline);
14
+ response.off('drain', drain);
15
+ queue.length = 0;
16
+ queuedBytes = 0;
17
+ };
18
+ const fail = () => { stop(); close(); };
19
+ const send = (chunk) => {
20
+ try {
21
+ if (!response.write(chunk)) {
22
+ blocked = true;
23
+ deadline = setTimeout(fail, drainMs);
24
+ deadline.unref?.();
25
+ }
26
+ }
27
+ catch {
28
+ fail();
29
+ }
30
+ };
31
+ const drain = () => {
32
+ clearTimeout(deadline);
33
+ blocked = false;
34
+ while (!stopped && !blocked && queue.length) {
35
+ const chunk = queue.shift();
36
+ queuedBytes -= Buffer.byteLength(chunk);
37
+ send(chunk);
38
+ }
39
+ };
40
+ response.on('drain', drain);
41
+ return {
42
+ write(chunk) {
43
+ if (stopped)
44
+ return false;
45
+ const size = Buffer.byteLength(chunk);
46
+ if (response.destroyed || response.writableEnded || size + queuedBytes + response.writableLength > maxBytes) {
47
+ fail();
48
+ return false;
49
+ }
50
+ if (blocked) {
51
+ queue.push(chunk);
52
+ queuedBytes += size;
53
+ }
54
+ else
55
+ send(chunk);
56
+ return !stopped;
57
+ },
58
+ stop
59
+ };
60
+ }
package/dist/types.d.ts CHANGED
@@ -14,7 +14,7 @@ export interface AgentdTurnCompletion extends AgentdTurnCompletionProof {
14
14
  artifactCount: number;
15
15
  completedAt: number;
16
16
  }
17
- export declare const agentdDriverKinds: readonly ["opencode", "claude", "codex", "pi", "openclaw", "hermes"];
17
+ export declare const agentdDriverKinds: readonly ["stdio", "opencode", "claude", "codex", "pi", "openclaw", "hermes"];
18
18
  export type AgentdDriverKind = (typeof agentdDriverKinds)[number];
19
19
  export interface AgentdDriverConfig {
20
20
  protocol?: 'acp';
@@ -25,6 +25,8 @@ export interface AgentdDriverConfig {
25
25
  workspace?: string;
26
26
  command?: string;
27
27
  args?: string[];
28
+ /** Arguments used by a command availability probe. */
29
+ probeArgs?: string[];
28
30
  inheritEnv?: string[];
29
31
  env?: Record<string, string>;
30
32
  permissionPolicy?: PermissionPolicy;
@@ -48,6 +50,10 @@ export interface AgentdA2AConfig {
48
50
  headerName?: string;
49
51
  };
50
52
  timeoutMs?: number;
53
+ /** Maximum time allowed for one logical A2A task. Inherits global promptTimeoutMs when omitted. */
54
+ taskTimeoutMs?: number;
55
+ /** Maximum time between bytes/events while reading an A2A stream. Inherits timeoutMs when omitted. */
56
+ streamIdleTimeoutMs?: number;
51
57
  }
52
58
  export type AgentdAgentConfig = AgentdDriverConfig | AgentdA2AConfig;
53
59
  export interface AgentdApiKeyScope {
@@ -87,6 +93,28 @@ export interface AgentdConfig {
87
93
  maxConnections?: number;
88
94
  adminSessionTtlMs?: number;
89
95
  secureAdminCookies?: boolean;
96
+ /** Exact browser origins for named LAN hosts or TLS reverse proxies. */
97
+ publicOrigins?: string[];
98
+ /** Per-client budgets; changes require a restart. */
99
+ quotas?: {
100
+ maxSessionsPerKey: number;
101
+ maxRunningRunsPerKey: number;
102
+ maxSsePerKey: number;
103
+ maxUploadBytesPerKey: number;
104
+ };
105
+ /** Persisted task metadata and output retention; active runs are protected. */
106
+ history?: {
107
+ maxRuns: number;
108
+ retentionDays: number;
109
+ maxBytes: number;
110
+ };
111
+ /** Persisted artifact payload retention and queue limits. */
112
+ artifacts?: {
113
+ retentionDays: number;
114
+ maxBytes: number;
115
+ maxArtifactBytes: number;
116
+ maxQueuedBytes: number;
117
+ };
90
118
  agents: Record<string, AgentdAgentConfig>;
91
119
  }
92
120
  export interface AgentdAgentView {
@@ -122,6 +150,8 @@ export interface AgentdAgentConfigView {
122
150
  configured: boolean;
123
151
  };
124
152
  timeoutMs?: number;
153
+ taskTimeoutMs?: number;
154
+ streamIdleTimeoutMs?: number;
125
155
  }
126
156
  export interface AgentdControlPlaneView {
127
157
  workspaceRoots: string[];
@@ -235,16 +265,20 @@ export interface AgentdRunArtifactView {
235
265
  filename?: string;
236
266
  mediaType?: string;
237
267
  metadata?: Record<string, unknown>;
268
+ size?: number;
269
+ downloadable?: boolean;
270
+ storageStatus?: 'pending' | 'available' | 'metadata_only' | 'expired' | 'evicted' | 'failed';
238
271
  }
239
272
  export interface AgentdRunView {
240
273
  id: string;
241
274
  sessionId: string;
275
+ retryOfRunId?: string;
242
276
  agentId: string;
243
277
  agentName: string;
244
278
  protocol: AgentdProtocol;
245
279
  workspace?: string;
246
280
  protocolSessionId?: string;
247
- task: string;
281
+ taskPreview: string;
248
282
  taskTruncated?: boolean;
249
283
  state: AgentdSessionState;
250
284
  progress: AgentdRunProgress;
@@ -259,8 +293,16 @@ export interface AgentdRunView {
259
293
  durationMs?: number;
260
294
  }
261
295
  export interface AgentdRunDetail extends AgentdRunView {
296
+ task: string;
262
297
  output?: string;
263
298
  artifacts: AgentdRunArtifactView[];
299
+ controls?: AgentdRunControls;
300
+ }
301
+ export interface AgentdRunControls {
302
+ canCancel: boolean;
303
+ canRetry: boolean;
304
+ pendingRequest?: AgentdPendingRequest;
305
+ unavailableReason?: string;
264
306
  }
265
307
  export type AgentdEventType = 'session_state' | 'assistant_chunk' | 'thought_chunk' | 'plan' | 'tool_call' | 'tool_update' | 'terminal_output' | 'file_activity' | 'artifact' | 'permission_required' | 'input_required' | 'completed' | 'failed' | 'canceled';
266
308
  export interface AgentdEvent {
package/dist/types.js CHANGED
@@ -1,4 +1,5 @@
1
1
  export const agentdDriverKinds = [
2
+ 'stdio',
2
3
  'opencode',
3
4
  'claude',
4
5
  'codex',