nexus-agentd 0.2.6 → 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 (56) hide show
  1. package/README.md +103 -14
  2. package/dist/a2a/runtime.d.ts +4 -1
  3. package/dist/a2a/runtime.js +213 -10
  4. package/dist/acp/runtime.js +13 -6
  5. package/dist/artifact-store.d.ts +168 -0
  6. package/dist/artifact-store.js +1111 -0
  7. package/dist/cli.js +13 -14
  8. package/dist/config.js +45 -5
  9. package/dist/control-plane-validation.d.ts +54 -0
  10. package/dist/control-plane-validation.js +152 -0
  11. package/dist/control-plane.d.ts +9 -32
  12. package/dist/control-plane.js +41 -157
  13. package/dist/drivers/index.js +12 -0
  14. package/dist/drivers/pi.js +1 -1
  15. package/dist/drivers/stdio.d.ts +4 -1
  16. package/dist/drivers/stdio.js +135 -19
  17. package/dist/events.d.ts +9 -0
  18. package/dist/events.js +17 -4
  19. package/dist/index.js +10 -1
  20. package/dist/process-tree.js +15 -6
  21. package/dist/run-store.d.ts +90 -7
  22. package/dist/run-store.js +254 -22
  23. package/dist/server/auth-policy.d.ts +27 -0
  24. package/dist/server/auth-policy.js +143 -0
  25. package/dist/server/connection.d.ts +8 -0
  26. package/dist/server/connection.js +67 -0
  27. package/dist/server/diagnostics.d.ts +40 -0
  28. package/dist/server/diagnostics.js +130 -0
  29. package/dist/server/metrics.d.ts +51 -0
  30. package/dist/server/metrics.js +56 -0
  31. package/dist/server/quota.d.ts +59 -0
  32. package/dist/server/quota.js +176 -0
  33. package/dist/server/validation.d.ts +29 -0
  34. package/dist/server/validation.js +221 -0
  35. package/dist/server.d.ts +3 -0
  36. package/dist/server.js +737 -419
  37. package/dist/session/admin-runs.d.ts +73 -0
  38. package/dist/session/admin-runs.js +298 -0
  39. package/dist/session/admission.d.ts +32 -0
  40. package/dist/session/admission.js +62 -0
  41. package/dist/session/readiness.d.ts +33 -0
  42. package/dist/session/readiness.js +174 -0
  43. package/dist/session.d.ts +65 -7
  44. package/dist/session.js +256 -109
  45. package/dist/sse-writer.d.ts +7 -0
  46. package/dist/sse-writer.js +60 -0
  47. package/dist/types.d.ts +46 -2
  48. package/dist/types.js +1 -0
  49. package/dist/webui/app/sources.js +18 -9
  50. package/dist/webui/icons.d.ts +1 -0
  51. package/dist/webui/icons.js +1 -0
  52. package/dist/webui/markup.js +3 -0
  53. package/dist/webui/styles.js +105 -15
  54. package/examples/client.mjs +102 -0
  55. package/nexus-agentd.example.json +19 -0
  56. package/package.json +3 -2
@@ -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,21 @@ 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';
271
+ createdAt?: number;
238
272
  }
239
273
  export interface AgentdRunView {
240
274
  id: string;
241
275
  sessionId: string;
276
+ retryOfRunId?: string;
242
277
  agentId: string;
243
278
  agentName: string;
244
279
  protocol: AgentdProtocol;
245
280
  workspace?: string;
246
281
  protocolSessionId?: string;
247
- task: string;
282
+ taskPreview: string;
248
283
  taskTruncated?: boolean;
249
284
  state: AgentdSessionState;
250
285
  progress: AgentdRunProgress;
@@ -259,8 +294,17 @@ export interface AgentdRunView {
259
294
  durationMs?: number;
260
295
  }
261
296
  export interface AgentdRunDetail extends AgentdRunView {
297
+ task: string;
262
298
  output?: string;
263
299
  artifacts: AgentdRunArtifactView[];
300
+ controls?: AgentdRunControls;
301
+ }
302
+ export interface AgentdRunControls {
303
+ canCancel: boolean;
304
+ canRetry: boolean;
305
+ canDelete?: boolean;
306
+ pendingRequest?: AgentdPendingRequest;
307
+ unavailableReason?: string;
264
308
  }
265
309
  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
310
  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',