@kadi.build/core 0.9.0 → 0.11.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/README.md +424 -1
- package/agent.json +19 -0
- package/dist/agent-json.d.ts +231 -0
- package/dist/agent-json.d.ts.map +1 -0
- package/dist/agent-json.js +554 -0
- package/dist/agent-json.js.map +1 -0
- package/dist/client.d.ts +34 -0
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +50 -0
- package/dist/client.js.map +1 -1
- package/dist/errors.d.ts +1 -1
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js.map +1 -1
- package/dist/index.d.ts +5 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8 -0
- package/dist/index.js.map +1 -1
- package/dist/process-manager.d.ts +235 -0
- package/dist/process-manager.d.ts.map +1 -0
- package/dist/process-manager.js +647 -0
- package/dist/process-manager.js.map +1 -0
- package/dist/stdio-framing.d.ts +88 -0
- package/dist/stdio-framing.d.ts.map +1 -0
- package/dist/stdio-framing.js +194 -0
- package/dist/stdio-framing.js.map +1 -0
- package/dist/transports/stdio.d.ts.map +1 -1
- package/dist/transports/stdio.js +3 -181
- package/dist/transports/stdio.js.map +1 -1
- package/dist/types.d.ts +256 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/utils.d.ts +107 -0
- package/dist/utils.d.ts.map +1 -0
- package/dist/utils.js +212 -0
- package/dist/utils.js.map +1 -0
- package/package.json +3 -1
- package/scripts/symlink.mjs +131 -0
- package/src/agent-json.ts +655 -0
- package/src/client.ts +56 -0
- package/src/errors.ts +15 -0
- package/src/index.ts +32 -0
- package/src/process-manager.ts +821 -0
- package/src/stdio-framing.ts +227 -0
- package/src/transports/stdio.ts +4 -221
- package/src/types.ts +277 -0
- package/src/utils.ts +246 -0
package/src/client.ts
CHANGED
|
@@ -59,6 +59,8 @@ import { resolveAbilityEntry, resolveAbilityScript } from './lockfile.js';
|
|
|
59
59
|
import { loadNativeTransport } from './transports/native.js';
|
|
60
60
|
import { loadStdioTransport } from './transports/stdio.js';
|
|
61
61
|
import { loadBrokerTransport } from './transports/broker.js';
|
|
62
|
+
import { AgentJsonManager } from './agent-json.js';
|
|
63
|
+
import { ProcessManager } from './process-manager.js';
|
|
62
64
|
|
|
63
65
|
// ═══════════════════════════════════════════════════════════════
|
|
64
66
|
// CONSTANTS
|
|
@@ -204,6 +206,12 @@ export class KadiClient {
|
|
|
204
206
|
/** Registered disconnect hooks */
|
|
205
207
|
private readonly disconnectHooks: Array<() => Promise<void>> = [];
|
|
206
208
|
|
|
209
|
+
/** Lazy-initialized AgentJsonManager */
|
|
210
|
+
private _agentJson: AgentJsonManager | null = null;
|
|
211
|
+
|
|
212
|
+
/** Lazy-initialized ProcessManager */
|
|
213
|
+
private _processes: ProcessManager | null = null;
|
|
214
|
+
|
|
207
215
|
// ─────────────────────────────────────────────────────────────
|
|
208
216
|
// IDENTITY (single keypair shared across all broker connections)
|
|
209
217
|
// ─────────────────────────────────────────────────────────────
|
|
@@ -2409,6 +2417,54 @@ export class KadiClient {
|
|
|
2409
2417
|
await new Promise(() => {});
|
|
2410
2418
|
}
|
|
2411
2419
|
|
|
2420
|
+
// ─────────────────────────────────────────────────────────────
|
|
2421
|
+
// AGENT JSON MANAGER
|
|
2422
|
+
// ─────────────────────────────────────────────────────────────
|
|
2423
|
+
|
|
2424
|
+
/**
|
|
2425
|
+
* Access the AgentJsonManager for reading/writing agent.json files.
|
|
2426
|
+
*
|
|
2427
|
+
* Lazily created on first access. Provides unified API for project root,
|
|
2428
|
+
* installed ability, and KADI home agent.json files.
|
|
2429
|
+
*
|
|
2430
|
+
* @example
|
|
2431
|
+
* ```typescript
|
|
2432
|
+
* const config = await client.agentJson.readProject();
|
|
2433
|
+
* const deploy = await client.agentJson.readProject('deploy.local');
|
|
2434
|
+
* await client.agentJson.writeProject('deploy.staging', { target: 'akash' });
|
|
2435
|
+
* ```
|
|
2436
|
+
*/
|
|
2437
|
+
get agentJson(): AgentJsonManager {
|
|
2438
|
+
if (!this._agentJson) {
|
|
2439
|
+
this._agentJson = new AgentJsonManager();
|
|
2440
|
+
}
|
|
2441
|
+
return this._agentJson;
|
|
2442
|
+
}
|
|
2443
|
+
|
|
2444
|
+
// ─────────────────────────────────────────────────────────────
|
|
2445
|
+
// PROCESS MANAGER
|
|
2446
|
+
// ─────────────────────────────────────────────────────────────
|
|
2447
|
+
|
|
2448
|
+
/**
|
|
2449
|
+
* Access the ProcessManager for spawning and managing background processes.
|
|
2450
|
+
*
|
|
2451
|
+
* Lazily created on first access. Supports headless, piped, and bridge modes.
|
|
2452
|
+
*
|
|
2453
|
+
* @example
|
|
2454
|
+
* ```typescript
|
|
2455
|
+
* const build = await client.processes.spawn('build', {
|
|
2456
|
+
* command: 'docker', args: ['build', '.'], mode: 'piped',
|
|
2457
|
+
* });
|
|
2458
|
+
* build.on('exit', ({ exitCode }) => console.log('done:', exitCode));
|
|
2459
|
+
* ```
|
|
2460
|
+
*/
|
|
2461
|
+
get processes(): ProcessManager {
|
|
2462
|
+
if (!this._processes) {
|
|
2463
|
+
this._processes = new ProcessManager();
|
|
2464
|
+
}
|
|
2465
|
+
return this._processes;
|
|
2466
|
+
}
|
|
2467
|
+
|
|
2412
2468
|
// ─────────────────────────────────────────────────────────────
|
|
2413
2469
|
// UTILITY
|
|
2414
2470
|
// ─────────────────────────────────────────────────────────────
|
package/src/errors.ts
CHANGED
|
@@ -65,6 +65,21 @@ export type ErrorCode =
|
|
|
65
65
|
| 'INVALID_INPUT'
|
|
66
66
|
| 'PROJECT_ROOT_NOT_FOUND'
|
|
67
67
|
|
|
68
|
+
// Agent.json errors
|
|
69
|
+
| 'AGENT_JSON_NOT_FOUND'
|
|
70
|
+
| 'AGENT_JSON_PARSE_ERROR'
|
|
71
|
+
| 'AGENT_JSON_WRITE_ERROR'
|
|
72
|
+
| 'AGENT_JSON_FIELD_NOT_FOUND'
|
|
73
|
+
| 'AGENT_JSON_VERSION_AMBIGUOUS'
|
|
74
|
+
|
|
75
|
+
// Process manager errors
|
|
76
|
+
| 'PROCESS_ALREADY_EXISTS'
|
|
77
|
+
| 'PROCESS_NOT_FOUND'
|
|
78
|
+
| 'PROCESS_NOT_RUNNING'
|
|
79
|
+
| 'PROCESS_BRIDGE_ERROR'
|
|
80
|
+
| 'PROCESS_SPAWN_FAILED'
|
|
81
|
+
| 'PROCESS_TIMEOUT'
|
|
82
|
+
|
|
68
83
|
// Transport errors
|
|
69
84
|
| 'STDIO_ERROR'
|
|
70
85
|
| 'STDIO_PROCESS_FAILED'
|
package/src/index.ts
CHANGED
|
@@ -91,8 +91,40 @@ export type {
|
|
|
91
91
|
|
|
92
92
|
// Script resolution
|
|
93
93
|
ResolvedScript,
|
|
94
|
+
|
|
95
|
+
// Agent.json types
|
|
96
|
+
AgentJson,
|
|
97
|
+
AgentJsonScripts,
|
|
98
|
+
AgentJsonBuildProfile,
|
|
99
|
+
AgentJsonDeployProfile,
|
|
100
|
+
AgentJsonManagerOptions,
|
|
101
|
+
ReadAbilityOptions,
|
|
102
|
+
AbilityInfo,
|
|
103
|
+
AgentJsonPaths,
|
|
104
|
+
|
|
105
|
+
// Process manager types
|
|
106
|
+
ProcessMode,
|
|
107
|
+
ProcessState,
|
|
108
|
+
SpawnOptions,
|
|
109
|
+
ProcessInfo,
|
|
110
|
+
ProcessExitInfo,
|
|
111
|
+
ProcessOutput,
|
|
112
|
+
ProcessListOptions,
|
|
113
|
+
ProcessPruneOptions,
|
|
94
114
|
} from './types.js';
|
|
95
115
|
|
|
116
|
+
// Agent.json manager
|
|
117
|
+
export { AgentJsonManager } from './agent-json.js';
|
|
118
|
+
|
|
119
|
+
// Process manager
|
|
120
|
+
export { ProcessManager, ManagedProcess } from './process-manager.js';
|
|
121
|
+
|
|
122
|
+
// Dot-path utilities
|
|
123
|
+
export { getByPath, setByPath, deleteByPath, deepMerge } from './utils.js';
|
|
124
|
+
|
|
125
|
+
// Stdio framing (for advanced use cases — building custom bridge protocols)
|
|
126
|
+
export { StdioMessageReader, StdioMessageWriter } from './stdio-framing.js';
|
|
127
|
+
|
|
96
128
|
// Zod utilities
|
|
97
129
|
export { zodToJsonSchema, isZodSchema } from './zod.js';
|
|
98
130
|
|