nexus-agentd 0.2.6 → 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.
- package/LICENSE +22 -22
- package/README.md +103 -14
- package/dist/a2a/runtime.d.ts +4 -1
- package/dist/a2a/runtime.js +213 -10
- package/dist/acp/runtime.js +13 -6
- package/dist/artifact-store.d.ts +162 -0
- package/dist/artifact-store.js +1081 -0
- package/dist/cli.js +13 -14
- package/dist/config.js +45 -5
- package/dist/control-plane-validation.d.ts +54 -0
- package/dist/control-plane-validation.js +152 -0
- package/dist/control-plane.d.ts +9 -32
- package/dist/control-plane.js +41 -157
- package/dist/drivers/index.js +12 -0
- package/dist/drivers/pi.js +1 -1
- package/dist/drivers/stdio.d.ts +4 -1
- package/dist/drivers/stdio.js +135 -19
- package/dist/events.d.ts +9 -0
- package/dist/events.js +17 -4
- package/dist/index.js +10 -1
- package/dist/process-tree.js +15 -6
- package/dist/run-store.d.ts +52 -7
- package/dist/run-store.js +178 -22
- package/dist/server/auth-policy.d.ts +27 -0
- package/dist/server/auth-policy.js +143 -0
- package/dist/server/connection.d.ts +8 -0
- package/dist/server/connection.js +67 -0
- package/dist/server/diagnostics.d.ts +40 -0
- package/dist/server/diagnostics.js +130 -0
- package/dist/server/metrics.d.ts +51 -0
- package/dist/server/metrics.js +56 -0
- package/dist/server/quota.d.ts +59 -0
- package/dist/server/quota.js +176 -0
- package/dist/server/validation.d.ts +29 -0
- package/dist/server/validation.js +221 -0
- package/dist/server.d.ts +3 -0
- package/dist/server.js +682 -418
- package/dist/session/admin-runs.d.ts +73 -0
- package/dist/session/admin-runs.js +297 -0
- package/dist/session/admission.d.ts +32 -0
- package/dist/session/admission.js +62 -0
- package/dist/session/readiness.d.ts +33 -0
- package/dist/session/readiness.js +174 -0
- package/dist/session.d.ts +58 -6
- package/dist/session.js +244 -109
- package/dist/sse-writer.d.ts +7 -0
- package/dist/sse-writer.js +60 -0
- package/dist/types.d.ts +44 -2
- package/dist/types.js +1 -0
- package/dist/webui/app/sources.js +16 -8
- package/dist/webui/index.js +11 -11
- package/dist/webui/markup.js +2 -0
- package/dist/webui/styles.js +46 -1
- package/examples/client.mjs +102 -0
- package/nexus-agentd.example.json +53 -34
- package/package.json +3 -2
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
import type { AgentdArtifact, AgentdRunArtifactView } from './types.js';
|
|
2
|
+
/**
|
|
3
|
+
* The value is persisted with run metadata so callers can distinguish a
|
|
4
|
+
* downloadable artifact from one for which the gateway only retained
|
|
5
|
+
* protocol metadata.
|
|
6
|
+
*/
|
|
7
|
+
export type ArtifactStorageStatus = 'pending' | 'available' | 'metadata_only' | 'expired' | 'evicted' | 'failed';
|
|
8
|
+
export interface StoredArtifactView extends AgentdRunArtifactView {
|
|
9
|
+
id: string;
|
|
10
|
+
storageStatus: ArtifactStorageStatus;
|
|
11
|
+
downloadable: boolean;
|
|
12
|
+
size?: number;
|
|
13
|
+
sha256?: string;
|
|
14
|
+
createdAt: number;
|
|
15
|
+
storedAt?: number;
|
|
16
|
+
expiresAt?: number;
|
|
17
|
+
storageError?: string;
|
|
18
|
+
}
|
|
19
|
+
export interface ArtifactReadResult {
|
|
20
|
+
bytes: Buffer;
|
|
21
|
+
filename: string;
|
|
22
|
+
mediaType?: string;
|
|
23
|
+
}
|
|
24
|
+
export interface ArtifactStoreMetrics {
|
|
25
|
+
totalPayloadBytes: number;
|
|
26
|
+
/** Short alias useful to metrics consumers. */
|
|
27
|
+
payloadBytes: number;
|
|
28
|
+
queuedBytes: number;
|
|
29
|
+
pendingWrites: number;
|
|
30
|
+
retainedPayloads: number;
|
|
31
|
+
retainedRuns: number;
|
|
32
|
+
lastWriteMs: number;
|
|
33
|
+
writeFailures: number;
|
|
34
|
+
maxTotalBytes: number;
|
|
35
|
+
maxQueuedBytes: number;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* A small, deliberately structural IO seam. Tests can inject failures or
|
|
39
|
+
* latency without replacing the filesystem globally. Production callers can
|
|
40
|
+
* leave this unset and the node fs/promises implementation is used.
|
|
41
|
+
*/
|
|
42
|
+
export interface ArtifactStoreIo {
|
|
43
|
+
mkdir?: (...args: any[]) => Promise<any>;
|
|
44
|
+
readFile?: (...args: any[]) => Promise<any>;
|
|
45
|
+
writeFile?: (...args: any[]) => Promise<any>;
|
|
46
|
+
rename?: (...args: any[]) => Promise<any>;
|
|
47
|
+
chmod?: (...args: any[]) => Promise<any>;
|
|
48
|
+
readdir?: (...args: any[]) => Promise<any>;
|
|
49
|
+
lstat?: (...args: any[]) => Promise<any>;
|
|
50
|
+
unlink?: (...args: any[]) => Promise<any>;
|
|
51
|
+
rm?: (...args: any[]) => Promise<any>;
|
|
52
|
+
open?: (...args: any[]) => Promise<any>;
|
|
53
|
+
}
|
|
54
|
+
export interface ArtifactStoreOptions {
|
|
55
|
+
/** Directory owned by this store. Defaults to `<run-file>.artifacts`. */
|
|
56
|
+
rootDir?: string;
|
|
57
|
+
/** Alias accepted for configuration adapters. */
|
|
58
|
+
artifactRootDir?: string;
|
|
59
|
+
/** Maximum payload size for one artifact. Defaults to 12 MiB. */
|
|
60
|
+
maxArtifactBytes?: number;
|
|
61
|
+
/** Maximum number of artifact metadata entries retained per run. */
|
|
62
|
+
maxArtifactsPerRun?: number;
|
|
63
|
+
/** Maximum aggregate payload bytes owned by this store. */
|
|
64
|
+
maxTotalBytes?: number;
|
|
65
|
+
/** Alias accepted for history/disk budget configuration. */
|
|
66
|
+
maxDiskBytes?: number;
|
|
67
|
+
/** Maximum bytes awaiting asynchronous persistence. */
|
|
68
|
+
maxQueuedBytes?: number;
|
|
69
|
+
/** Payload retention duration. Zero expires payloads immediately. */
|
|
70
|
+
retentionDays?: number;
|
|
71
|
+
/** Clock seam used by retention and deterministic tests. */
|
|
72
|
+
now?: () => number;
|
|
73
|
+
/** Optional IO seam used by tests. */
|
|
74
|
+
io?: ArtifactStoreIo;
|
|
75
|
+
/** Called whenever the public metadata view changes. */
|
|
76
|
+
onViewsChanged?: (runId: string, views: StoredArtifactView[]) => void;
|
|
77
|
+
/** Active runs are protected from retention and disk-budget eviction. */
|
|
78
|
+
isRunActive?: (runId: string) => boolean;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Durable payload store for run artifacts.
|
|
82
|
+
*
|
|
83
|
+
* The store keeps an index in memory and a small manifest per run. Payloads
|
|
84
|
+
* are written into a hashed run directory with hashed file names; incoming
|
|
85
|
+
* artifact ids, URLs, and filenames are never used as filesystem paths.
|
|
86
|
+
*/
|
|
87
|
+
export declare class ArtifactStore {
|
|
88
|
+
readonly rootDir: string;
|
|
89
|
+
readonly maxArtifactBytes: number;
|
|
90
|
+
readonly maxArtifactsPerRun: number;
|
|
91
|
+
readonly maxTotalBytes: number;
|
|
92
|
+
readonly maxQueuedBytes: number;
|
|
93
|
+
readonly retentionDays: number;
|
|
94
|
+
private readonly now;
|
|
95
|
+
private readonly io;
|
|
96
|
+
private readonly onViewsChanged?;
|
|
97
|
+
private readonly isRunActive;
|
|
98
|
+
private readonly entries;
|
|
99
|
+
private readonly runIds;
|
|
100
|
+
private readonly pending;
|
|
101
|
+
private readonly inFlight;
|
|
102
|
+
private readonly pendingDeletes;
|
|
103
|
+
private queuedBytes;
|
|
104
|
+
private totalBytes;
|
|
105
|
+
private activeDrain?;
|
|
106
|
+
private initialized;
|
|
107
|
+
private lastError?;
|
|
108
|
+
private lastWriteMs;
|
|
109
|
+
private writeFailures;
|
|
110
|
+
constructor(rootDir: string, options?: ArtifactStoreOptions);
|
|
111
|
+
init(): Promise<void>;
|
|
112
|
+
/**
|
|
113
|
+
* Reconcile metadata loaded from the legacy run JSON file with manifests
|
|
114
|
+
* found on disk. A run JSON file remains the source of truth for metadata;
|
|
115
|
+
* manifests only make payload bytes durable.
|
|
116
|
+
*/
|
|
117
|
+
restoreRun(runId: string, views: AgentdRunArtifactView[]): StoredArtifactView[];
|
|
118
|
+
/**
|
|
119
|
+
* Record protocol artifacts synchronously. Payload conversion and queue
|
|
120
|
+
* insertion happen in memory; disk IO is scheduled in the background.
|
|
121
|
+
*/
|
|
122
|
+
recordArtifacts(runId: string, artifacts: AgentdArtifact[]): StoredArtifactView[];
|
|
123
|
+
/** Merge display metadata from a RunStore update without dropping storage state. */
|
|
124
|
+
mergeViews(runId: string, views: AgentdRunArtifactView[], notify?: boolean): StoredArtifactView[];
|
|
125
|
+
views(runId: string): StoredArtifactView[];
|
|
126
|
+
readArtifact(runId: string, artifactId: string): Promise<ArtifactReadResult | undefined>;
|
|
127
|
+
/** Queue removal of one run's own directory. Active runs are protected. */
|
|
128
|
+
removeRun(runId: string): void;
|
|
129
|
+
flush(): Promise<void>;
|
|
130
|
+
get queuedByteCount(): number;
|
|
131
|
+
get storedByteCount(): number;
|
|
132
|
+
stats(): ArtifactStoreMetrics;
|
|
133
|
+
private runDrain;
|
|
134
|
+
private scheduleDrain;
|
|
135
|
+
private drainLoop;
|
|
136
|
+
private writePending;
|
|
137
|
+
private ensureBudget;
|
|
138
|
+
private evict;
|
|
139
|
+
private prune;
|
|
140
|
+
private expire;
|
|
141
|
+
private deleteRunDirectory;
|
|
142
|
+
private writeManifest;
|
|
143
|
+
private loadManifests;
|
|
144
|
+
private cleanupTemps;
|
|
145
|
+
private ensureDirectory;
|
|
146
|
+
private realDirectory;
|
|
147
|
+
private realPath;
|
|
148
|
+
private readRegularFile;
|
|
149
|
+
private safeUnlink;
|
|
150
|
+
private runDirectory;
|
|
151
|
+
private manifestPath;
|
|
152
|
+
private payloadPath;
|
|
153
|
+
private viewsForRun;
|
|
154
|
+
private addPending;
|
|
155
|
+
private removePending;
|
|
156
|
+
private requeue;
|
|
157
|
+
private emit;
|
|
158
|
+
private assertInitialized;
|
|
159
|
+
}
|
|
160
|
+
export declare class ArtifactBudgetError extends Error {
|
|
161
|
+
}
|
|
162
|
+
export declare function artifactStorePathForRunStore(runStorePath: string): string;
|