@cef-ai/cli 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/README.md +75 -1247
- package/dist/build/duration.d.ts +22 -0
- package/dist/build/duration.d.ts.map +1 -0
- package/dist/build/duration.js +44 -0
- package/dist/build/duration.js.map +1 -0
- package/dist/build/esbuild-plugin.d.ts +32 -0
- package/dist/build/esbuild-plugin.d.ts.map +1 -0
- package/dist/build/esbuild-plugin.js +53 -0
- package/dist/build/esbuild-plugin.js.map +1 -0
- package/dist/build/lints.d.ts +55 -0
- package/dist/build/lints.d.ts.map +1 -0
- package/dist/build/lints.js +214 -0
- package/dist/build/lints.js.map +1 -0
- package/dist/build/load-config.d.ts +114 -0
- package/dist/build/load-config.d.ts.map +1 -0
- package/dist/build/load-config.js +150 -0
- package/dist/build/load-config.js.map +1 -0
- package/dist/build/manifest.d.ts +156 -0
- package/dist/build/manifest.d.ts.map +1 -0
- package/dist/build/manifest.js +111 -0
- package/dist/build/manifest.js.map +1 -0
- package/dist/build/targeting.d.ts +15 -0
- package/dist/build/targeting.d.ts.map +1 -0
- package/dist/build/targeting.js +69 -0
- package/dist/build/targeting.js.map +1 -0
- package/dist/cli.d.ts +2 -2
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +107 -62
- package/dist/cli.js.map +1 -0
- package/dist/commands/build.d.ts +41 -0
- package/dist/commands/build.d.ts.map +1 -0
- package/dist/commands/build.js +252 -0
- package/dist/commands/build.js.map +1 -0
- package/dist/commands/inspect.d.ts +49 -0
- package/dist/commands/inspect.d.ts.map +1 -0
- package/dist/commands/inspect.js +135 -0
- package/dist/commands/inspect.js.map +1 -0
- package/dist/commands/typegen.d.ts +36 -0
- package/dist/commands/typegen.d.ts.map +1 -0
- package/dist/commands/typegen.js +210 -0
- package/dist/commands/typegen.js.map +1 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +6 -0
- package/dist/index.js.map +1 -0
- package/dist/lib.d.ts +12 -0
- package/dist/lib.d.ts.map +1 -0
- package/dist/lib.js +9 -0
- package/dist/lib.js.map +1 -0
- package/dist/typegen/augment.d.ts +57 -0
- package/dist/typegen/augment.d.ts.map +1 -0
- package/dist/typegen/augment.js +87 -0
- package/dist/typegen/augment.js.map +1 -0
- package/dist/typegen/fetch.d.ts +30 -0
- package/dist/typegen/fetch.d.ts.map +1 -0
- package/dist/typegen/fetch.js +38 -0
- package/dist/typegen/fetch.js.map +1 -0
- package/dist/typegen/lockfile.d.ts +42 -0
- package/dist/typegen/lockfile.d.ts.map +1 -0
- package/dist/typegen/lockfile.js +58 -0
- package/dist/typegen/lockfile.js.map +1 -0
- package/dist/typegen/schema-to-ts.d.ts +21 -0
- package/dist/typegen/schema-to-ts.d.ts.map +1 -0
- package/dist/typegen/schema-to-ts.js +29 -0
- package/dist/typegen/schema-to-ts.js.map +1 -0
- package/package.json +20 -58
- package/dist/commands/auth/index.d.ts +0 -2
- package/dist/commands/auth/index.js +0 -162
- package/dist/commands/deploy/clone.d.ts +0 -13
- package/dist/commands/deploy/clone.js +0 -143
- package/dist/commands/deploy/delete.d.ts +0 -14
- package/dist/commands/deploy/delete.js +0 -134
- package/dist/commands/deploy/deploy.d.ts +0 -24
- package/dist/commands/deploy/deploy.js +0 -654
- package/dist/commands/deploy/index.d.ts +0 -2
- package/dist/commands/deploy/index.js +0 -216
- package/dist/commands/deploy/status.d.ts +0 -14
- package/dist/commands/deploy/status.js +0 -61
- package/dist/commands/dev/index.d.ts +0 -2
- package/dist/commands/dev/index.js +0 -134
- package/dist/commands/dev/server.d.ts +0 -14
- package/dist/commands/dev/server.js +0 -195
- package/dist/commands/dev/static/app.js +0 -633
- package/dist/commands/dev/static/index.html +0 -205
- package/dist/commands/dev/static/static/app.js +0 -633
- package/dist/commands/dev/static/static/index.html +0 -205
- package/dist/commands/dev/static/static/style.css +0 -184
- package/dist/commands/dev/static/style.css +0 -184
- package/dist/commands/playground/index.d.ts +0 -2
- package/dist/commands/playground/index.js +0 -75
- package/dist/commands/playground/test.d.ts +0 -15
- package/dist/commands/playground/test.js +0 -166
- package/dist/commands/service/index.d.ts +0 -2
- package/dist/commands/service/index.js +0 -75
- package/dist/lib/api.d.ts +0 -146
- package/dist/lib/api.js +0 -330
- package/dist/lib/config.d.ts +0 -12
- package/dist/lib/config.js +0 -145
- package/dist/lib/credentials.d.ts +0 -19
- package/dist/lib/credentials.js +0 -68
- package/dist/lib/runtime/agent-router.d.ts +0 -12
- package/dist/lib/runtime/agent-router.js +0 -67
- package/dist/lib/runtime/context-builder.d.ts +0 -27
- package/dist/lib/runtime/context-builder.js +0 -166
- package/dist/lib/runtime/cubby-manager.d.ts +0 -20
- package/dist/lib/runtime/cubby-manager.js +0 -162
- package/dist/lib/runtime/index.d.ts +0 -51
- package/dist/lib/runtime/index.js +0 -181
- package/dist/lib/runtime/log-collector.d.ts +0 -17
- package/dist/lib/runtime/log-collector.js +0 -61
- package/dist/lib/runtime/stream-manager.d.ts +0 -10
- package/dist/lib/runtime/stream-manager.js +0 -77
- package/dist/lib/runtime/types.d.ts +0 -76
- package/dist/lib/runtime/types.js +0 -2
- package/dist/lib/transpile.d.ts +0 -1
- package/dist/lib/transpile.js +0 -9
- package/dist/lib/typecheck.d.ts +0 -31
- package/dist/lib/typecheck.js +0 -175
- package/dist/lib/types.d.ts +0 -246
- package/dist/lib/types.js +0 -2
- package/dist/lib/utils.d.ts +0 -4
- package/dist/lib/utils.js +0 -33
- package/example/.env.example +0 -6
- package/example/agents/object-detection/tasks/yolo.ts +0 -28
- package/example/agents/parking-violation-detector/tasks/detect.ts +0 -326
- package/example/cef.config.yaml +0 -91
- package/example/engagements/engagement.ts +0 -902
|
@@ -1,134 +0,0 @@
|
|
|
1
|
-
import readline from 'readline/promises';
|
|
2
|
-
import { createApiClient } from '../../lib/api.js';
|
|
3
|
-
import { writeIdsBack } from './deploy.js';
|
|
4
|
-
import { errorMessage } from '../../lib/utils.js';
|
|
5
|
-
function collectEntitiesToDelete(config, api) {
|
|
6
|
-
const entities = [];
|
|
7
|
-
// Reverse dependency order: deployments -> rafts -> streams -> workspaces -> agents -> engagements
|
|
8
|
-
for (const ws of config.workspaces ?? []) {
|
|
9
|
-
for (const stream of ws.streams ?? []) {
|
|
10
|
-
for (const dep of stream.deployments ?? []) {
|
|
11
|
-
if (dep.deploymentId) {
|
|
12
|
-
entities.push({
|
|
13
|
-
entity: 'deployment',
|
|
14
|
-
name: dep.name,
|
|
15
|
-
id: dep.deploymentId,
|
|
16
|
-
deleteFn: () => api.deleteDeployment(dep.deploymentId),
|
|
17
|
-
clearId: () => { dep.deploymentId = undefined; },
|
|
18
|
-
});
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
for (const raft of stream.rafts ?? []) {
|
|
22
|
-
if (raft.raftId) {
|
|
23
|
-
entities.push({
|
|
24
|
-
entity: 'raft',
|
|
25
|
-
name: raft.name,
|
|
26
|
-
id: raft.raftId,
|
|
27
|
-
deleteFn: () => api.deleteRaft(raft.raftId),
|
|
28
|
-
clearId: () => { raft.raftId = undefined; },
|
|
29
|
-
});
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
if (stream.streamId) {
|
|
33
|
-
entities.push({
|
|
34
|
-
entity: 'stream',
|
|
35
|
-
name: stream.name,
|
|
36
|
-
id: stream.streamId,
|
|
37
|
-
deleteFn: () => api.deleteStream(stream.streamId),
|
|
38
|
-
clearId: () => { stream.streamId = undefined; },
|
|
39
|
-
});
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
if (ws.workspaceId) {
|
|
43
|
-
entities.push({
|
|
44
|
-
entity: 'workspace',
|
|
45
|
-
name: ws.name,
|
|
46
|
-
id: ws.workspaceId,
|
|
47
|
-
deleteFn: () => api.deleteWorkspace(ws.workspaceId),
|
|
48
|
-
clearId: () => { ws.workspaceId = undefined; },
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
for (const agent of config.agents ?? []) {
|
|
53
|
-
if (agent.agentId) {
|
|
54
|
-
entities.push({
|
|
55
|
-
entity: 'agent',
|
|
56
|
-
name: agent.name,
|
|
57
|
-
id: agent.agentId,
|
|
58
|
-
deleteFn: () => api.deleteAgent(agent.agentId),
|
|
59
|
-
clearId: () => { agent.agentId = undefined; },
|
|
60
|
-
});
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
for (const eng of config.engagements ?? []) {
|
|
64
|
-
if (eng.engagementId) {
|
|
65
|
-
entities.push({
|
|
66
|
-
entity: 'engagement',
|
|
67
|
-
name: eng.name,
|
|
68
|
-
id: eng.engagementId,
|
|
69
|
-
deleteFn: () => api.deleteEngagement(eng.engagementId),
|
|
70
|
-
clearId: () => { eng.engagementId = undefined; },
|
|
71
|
-
});
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
return entities;
|
|
75
|
-
}
|
|
76
|
-
async function confirmDelete(count, pubkey) {
|
|
77
|
-
if (!process.stdin.isTTY || !process.stdout.isTTY) {
|
|
78
|
-
throw new Error(`Cannot confirm deletion of ${count} entities in non-interactive mode. Use --force to skip confirmation.`);
|
|
79
|
-
}
|
|
80
|
-
const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
|
|
81
|
-
try {
|
|
82
|
-
const answer = await rl.question(`Delete ${count} entity/entities from agent service ${pubkey}? This cannot be undone. (y/n) `);
|
|
83
|
-
return /^y(es)?$/i.test((answer ?? '').trim());
|
|
84
|
-
}
|
|
85
|
-
finally {
|
|
86
|
-
rl.close();
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
export async function runDelete(resolved, options) {
|
|
90
|
-
const { config, env, configPath } = resolved;
|
|
91
|
-
const api = createApiClient(env, config.agentServicePubKey, config.agentServiceId);
|
|
92
|
-
let entities = collectEntitiesToDelete(config, api);
|
|
93
|
-
if (options.only) {
|
|
94
|
-
entities = entities.filter(e => e.entity === options.only);
|
|
95
|
-
}
|
|
96
|
-
// Warn about cubbies that cannot be deleted via CLI
|
|
97
|
-
for (const cubby of config.cubbies ?? []) {
|
|
98
|
-
if (cubby.cubbyId && (!options.only || options.only === 'cubby')) {
|
|
99
|
-
console.warn(`Warning: cubby "${cubby.name}" cannot be deleted via CLI. Remove manually if needed.`);
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
if (entities.length === 0) {
|
|
103
|
-
console.log('No entities with IDs to delete.');
|
|
104
|
-
return [];
|
|
105
|
-
}
|
|
106
|
-
console.log(`\nEntities to delete (${entities.length}):`);
|
|
107
|
-
for (const e of entities) {
|
|
108
|
-
console.log(` ${e.entity}: ${e.name} (${e.id})`);
|
|
109
|
-
}
|
|
110
|
-
if (!options.force) {
|
|
111
|
-
const confirmed = await confirmDelete(entities.length, config.agentServicePubKey);
|
|
112
|
-
if (!confirmed) {
|
|
113
|
-
console.log('Cancelled.');
|
|
114
|
-
return entities.map(e => ({ entity: e.entity, name: e.name, id: e.id, action: 'skipped' }));
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
const results = [];
|
|
118
|
-
for (const e of entities) {
|
|
119
|
-
try {
|
|
120
|
-
console.log(`Deleting ${e.entity}: ${e.name} (${e.id})`);
|
|
121
|
-
await e.deleteFn();
|
|
122
|
-
e.clearId();
|
|
123
|
-
results.push({ entity: e.entity, name: e.name, id: e.id, action: 'deleted' });
|
|
124
|
-
}
|
|
125
|
-
catch (err) {
|
|
126
|
-
const msg = errorMessage(err);
|
|
127
|
-
console.error(` Failed to delete ${e.entity} "${e.name}": ${msg}`);
|
|
128
|
-
results.push({ entity: e.entity, name: e.name, id: e.id, action: 'failed', error: msg });
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
// Write cleaned config (IDs removed for successfully deleted entities)
|
|
132
|
-
writeIdsBack(configPath, config);
|
|
133
|
-
return results;
|
|
134
|
-
}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import type { ResolvedConfig, DeployResult, CefConfig } from '../../lib/types.js';
|
|
2
|
-
export type PromptForCopyEntity = 'engagement' | 'agent' | 'workspace' | 'stream' | 'deployment' | 'raft';
|
|
3
|
-
export type PromptForCopy = (entity: PromptForCopyEntity, name: string) => Promise<boolean>;
|
|
4
|
-
/** Return workspace ID for this agent service, or undefined to create new. */
|
|
5
|
-
export type PromptForWorkspaceId = (workspaceName: string) => Promise<string | undefined>;
|
|
6
|
-
/** Called when config.agentServiceId doesn't match the resolved ID from ROB, indicating the config was likely copied from another service. Return true to clear all entity IDs and deploy fresh. */
|
|
7
|
-
export type PromptForClearIds = (oldServiceId: string, newServiceId: string) => Promise<boolean>;
|
|
8
|
-
interface DeployOptions {
|
|
9
|
-
dryRun?: boolean;
|
|
10
|
-
only?: string;
|
|
11
|
-
/** When update returns 404 (e.g. ID from another agent service), call this to ask if we should create a copy. Default: interactive y/n when TTY, else throw. */
|
|
12
|
-
promptForCopy?: PromptForCopy;
|
|
13
|
-
/** When workspace has no workspaceId and we can't resolve it from the orchestrator, call this. Return ID or undefined to create new. Default: interactive prompt when TTY. */
|
|
14
|
-
promptForWorkspaceId?: PromptForWorkspaceId;
|
|
15
|
-
/** When agentServiceId mismatch is detected (config copied from another service), call this to ask if all entity IDs should be cleared. Default: interactive y/n when TTY, else throw. */
|
|
16
|
-
promptForClearIds?: PromptForClearIds;
|
|
17
|
-
}
|
|
18
|
-
/** Strip all entity IDs from config so everything deploys as new. */
|
|
19
|
-
export declare function clearAllEntityIds(config: CefConfig): void;
|
|
20
|
-
/** Detect if config was copied from a different agent service and offer to clear all entity IDs. */
|
|
21
|
-
export declare function detectAndClearStaleIds(config: CefConfig, oldServiceId: string | undefined, newServiceId: string, promptFn: PromptForClearIds): Promise<boolean>;
|
|
22
|
-
export declare function writeIdsBack(configPath: string, config: CefConfig): void;
|
|
23
|
-
export declare function runDeploy(resolved: ResolvedConfig, options: DeployOptions): Promise<DeployResult[]>;
|
|
24
|
-
export {};
|