@vectorplane/ctrl-cli 0.1.11 → 0.1.12

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.
@@ -0,0 +1,73 @@
1
+ import { ensureSessionAvailable, loadSession, upsertProfile } from "./config.js";
2
+ import { collectGitContext } from "./git.js";
3
+ import { collectMachineContext, collectRuntimeContext } from "./machine.js";
4
+ import { VectorPlaneApiClient } from "./api.js";
5
+ import { ensureFreshSession } from "./session.js";
6
+ import { ensureAgentSetupCurrent } from "./agent-setup.js";
7
+ import { resolveWorkspaceRoot } from "./workspace-binding.js";
8
+ import { resolveAuthorizedWorkspace } from "./workspace-resolution.js";
9
+ export async function buildInitLoginArgs(params) {
10
+ const loginArgs = [];
11
+ if (params.manual) {
12
+ loginArgs.push("--manual");
13
+ }
14
+ if (params.noBrowser) {
15
+ loginArgs.push("--no-browser");
16
+ }
17
+ if (params.profile) {
18
+ loginArgs.push("--profile", params.profile);
19
+ }
20
+ return loginArgs;
21
+ }
22
+ export async function runInitWorkspaceUseCase(params) {
23
+ let session = await loadSession(params.runtime.profile.name);
24
+ if (!session) {
25
+ params.runtime.logger.info("sessão local ausente, iniciando login...");
26
+ await params.ensureLoggedIn();
27
+ session = await ensureSessionAvailable(params.runtime.profile.name);
28
+ }
29
+ const [git, machine, runtimeContext] = await Promise.all([
30
+ collectGitContext(process.cwd()),
31
+ collectMachineContext(params.runtime.device, params.runtime.config),
32
+ collectRuntimeContext(params.cliVersion, "init", params.commandArgs),
33
+ ]);
34
+ const apiClient = new VectorPlaneApiClient(params.runtime.profile.apiBaseUrl, params.runtime.config.requestTimeoutMs, params.runtime.logger);
35
+ const freshSession = await ensureFreshSession({
36
+ profileName: params.runtime.profile.name,
37
+ session,
38
+ machine,
39
+ runtime: runtimeContext,
40
+ device: params.runtime.device,
41
+ apiClient,
42
+ logger: params.runtime.logger,
43
+ });
44
+ const rootPath = resolveWorkspaceRoot(process.cwd(), git);
45
+ const workspace = await resolveAuthorizedWorkspace({
46
+ apiClient,
47
+ accessToken: freshSession.accessToken,
48
+ git,
49
+ explicitWorkspace: params.explicitWorkspace,
50
+ profile: params.runtime.profile,
51
+ session: freshSession,
52
+ });
53
+ const result = await ensureAgentSetupCurrent({
54
+ rootPath,
55
+ workspace,
56
+ repoUrl: git.remoteOrigin,
57
+ source: git.remoteOrigin ? "api-resolve" : "manual",
58
+ accessToken: freshSession.accessToken,
59
+ apiClient,
60
+ logger: params.runtime.logger,
61
+ explicitAgent: params.requestedAgent,
62
+ force: params.force,
63
+ });
64
+ await upsertProfile(params.runtime.profile.name, { workspace });
65
+ return {
66
+ workspace,
67
+ agent: result.agent,
68
+ confidence: result.confidence,
69
+ templatePath: result.templatePath,
70
+ fileStatus: result.fileStatus,
71
+ };
72
+ }
73
+ //# sourceMappingURL=init-workspace.js.map
@@ -0,0 +1,18 @@
1
+ import type { VectorPlaneApiClient } from "./api.js";
2
+ import type { Logger } from "./logger.js";
3
+ import type { AuthSession } from "../types/auth.js";
4
+ import type { GitContext } from "../types/workspace.js";
5
+ export declare function ensureRuntimeAgentSetup(params: {
6
+ rootPath: string;
7
+ workspace: string;
8
+ git: GitContext;
9
+ session: AuthSession;
10
+ apiClient: VectorPlaneApiClient;
11
+ logger: Logger;
12
+ }): Promise<{
13
+ agent: import("./agent-runtime-detection.js").SupportedAgent;
14
+ templatePath: string;
15
+ fileStatus: "created" | "updated" | "unchanged";
16
+ changed: boolean;
17
+ confidence: import("./agent-runtime-detection.js").DetectionConfidence;
18
+ }>;
@@ -0,0 +1,13 @@
1
+ import { ensureAgentSetupCurrent } from "./agent-setup.js";
2
+ export async function ensureRuntimeAgentSetup(params) {
3
+ return ensureAgentSetupCurrent({
4
+ rootPath: params.rootPath,
5
+ workspace: params.workspace,
6
+ repoUrl: params.git.remoteOrigin,
7
+ source: params.git.remoteOrigin ? "api-resolve" : "manual",
8
+ accessToken: params.session.accessToken,
9
+ apiClient: params.apiClient,
10
+ logger: params.logger,
11
+ });
12
+ }
13
+ //# sourceMappingURL=runtime-agent-setup.js.map
@@ -0,0 +1,16 @@
1
+ export interface LocalTaskExecutionInput {
2
+ execution: Record<string, unknown> | null | undefined;
3
+ workspaceRoot: string;
4
+ workspaceRef: string;
5
+ taskId: string;
6
+ stepId: string;
7
+ capability: string;
8
+ }
9
+ export declare function executeLocalTaskStep(input: LocalTaskExecutionInput): Promise<{
10
+ command: string;
11
+ args: string[];
12
+ cwd: string;
13
+ exitCode: number;
14
+ stdout: string;
15
+ stderr: string;
16
+ }>;
@@ -0,0 +1,62 @@
1
+ import { spawn } from "node:child_process";
2
+ import { ValidationError } from "./errors.js";
3
+ function interpolate(value, context) {
4
+ return value.replace(/\{([a-zA-Z0-9_]+)\}/g, (_, key) => context[key] ?? "");
5
+ }
6
+ function asStringArray(value) {
7
+ return Array.isArray(value) ? value.map((item) => String(item)) : [];
8
+ }
9
+ export async function executeLocalTaskStep(input) {
10
+ const execution = input.execution ?? {};
11
+ const type = typeof execution.type === "string" ? execution.type : "command";
12
+ if (type !== "command") {
13
+ throw new ValidationError("A execução local do step exige `metadata.execution.type = command`.");
14
+ }
15
+ const rawCommand = typeof execution.command === "string" ? execution.command.trim() : "";
16
+ if (!rawCommand) {
17
+ throw new ValidationError("A execução local do step exige `metadata.execution.command`.");
18
+ }
19
+ const context = {
20
+ workspaceRoot: input.workspaceRoot,
21
+ workspace: input.workspaceRef,
22
+ taskId: input.taskId,
23
+ stepId: input.stepId,
24
+ capability: input.capability,
25
+ };
26
+ const command = interpolate(rawCommand, context);
27
+ const args = asStringArray(execution.args).map((item) => interpolate(item, context));
28
+ const cwd = typeof execution.cwd === "string" && execution.cwd.trim()
29
+ ? interpolate(execution.cwd, context)
30
+ : input.workspaceRoot;
31
+ const envOverrides = execution.env && typeof execution.env === "object"
32
+ ? Object.fromEntries(Object.entries(execution.env).map(([key, value]) => [key, interpolate(String(value), context)]))
33
+ : {};
34
+ return new Promise((resolve, reject) => {
35
+ const child = spawn(command, args, {
36
+ cwd,
37
+ env: { ...process.env, ...envOverrides },
38
+ stdio: ["ignore", "pipe", "pipe"],
39
+ shell: false,
40
+ });
41
+ let stdout = "";
42
+ let stderr = "";
43
+ child.stdout.on("data", (chunk) => {
44
+ stdout += String(chunk);
45
+ });
46
+ child.stderr.on("data", (chunk) => {
47
+ stderr += String(chunk);
48
+ });
49
+ child.on("error", reject);
50
+ child.on("close", (exitCode) => {
51
+ resolve({
52
+ command,
53
+ args,
54
+ cwd,
55
+ exitCode: exitCode ?? 1,
56
+ stdout: stdout.trim(),
57
+ stderr: stderr.trim(),
58
+ });
59
+ });
60
+ });
61
+ }
62
+ //# sourceMappingURL=task-runner.js.map
package/dist/index.js CHANGED
@@ -10,9 +10,11 @@ import { runEventCommand } from "./commands/event.js";
10
10
  import { runInitCommand } from "./commands/init.js";
11
11
  import { runLoginCommand } from "./commands/login.js";
12
12
  import { runLogoutCommand } from "./commands/logout.js";
13
+ import { runRegistryCommand } from "./commands/registry.js";
13
14
  import { runSessionCommand } from "./commands/session.js";
14
15
  import { runStatusCommand } from "./commands/status.js";
15
16
  import { runSyncCommand } from "./commands/sync.js";
17
+ import { runTaskCommand } from "./commands/task.js";
16
18
  import { runWhoAmICommand } from "./commands/whoami.js";
17
19
  import { runWorkspaceCommand } from "./commands/workspace.js";
18
20
  import { CLIError } from "./core/errors.js";
@@ -33,6 +35,8 @@ function printHelp() {
33
35
  process.stdout.write(" logout\n");
34
36
  process.stdout.write(" sync [--force]\n");
35
37
  process.stdout.write(" status\n");
38
+ process.stdout.write(" task <run|templates|list|inspect|claim|execute|daemon|approve|reject|delegate|step-update|handoff|observability|health>\n");
39
+ process.stdout.write(" registry <list|register|update|deactivate>\n");
36
40
  process.stdout.write(" whoami\n");
37
41
  process.stdout.write(" doctor\n");
38
42
  process.stdout.write(" draft <create|list>\n");
@@ -60,8 +64,12 @@ export async function runCli(args) {
60
64
  return runSyncCommand(cliVersion, rest);
61
65
  case "logout":
62
66
  return runLogoutCommand();
67
+ case "registry":
68
+ return runRegistryCommand(rest);
63
69
  case "status":
64
70
  return runStatusCommand();
71
+ case "task":
72
+ return runTaskCommand(cliVersion, rest);
65
73
  case "whoami":
66
74
  return runWhoAmICommand(cliVersion);
67
75
  case "doctor":
@@ -66,6 +66,58 @@ export interface ResolveWorkspaceResponse {
66
66
  repoUrl?: string | null;
67
67
  [key: string]: unknown;
68
68
  }
69
+ export type WorkspacePolicyRuleEffect = "allow" | "require_approval" | "block";
70
+ export interface WorkspacePolicyRuleConditions {
71
+ archetypes?: string[];
72
+ minTargetPathCount?: number;
73
+ requiredCapabilities?: string[];
74
+ }
75
+ export interface WorkspacePolicyRuleRecord {
76
+ id: string;
77
+ orgId: string;
78
+ workspaceId: string;
79
+ name: string;
80
+ pathPrefix: string | null;
81
+ capability: string | null;
82
+ effect: WorkspacePolicyRuleEffect;
83
+ rationale: string | null;
84
+ conditions: WorkspacePolicyRuleConditions | null;
85
+ approvalRole: string | null;
86
+ enabled: boolean;
87
+ createdAt: string;
88
+ updatedAt: string;
89
+ [key: string]: unknown;
90
+ }
91
+ export interface AgentRegistryRecord {
92
+ id: string;
93
+ orgId: string | null;
94
+ name: string;
95
+ runtimeType: string;
96
+ provider: string;
97
+ model: string;
98
+ capabilities: string[];
99
+ costProfile: string;
100
+ latencyProfile: string;
101
+ reliabilityScore: number;
102
+ status: string;
103
+ metadata?: Record<string, unknown> | null;
104
+ createdAt: string;
105
+ updatedAt: string;
106
+ }
107
+ export interface TaskTemplateRecord {
108
+ id: string;
109
+ slug: string;
110
+ name: string;
111
+ description: string | null;
112
+ defaultCapabilities: string[];
113
+ suggestedPaths: string[];
114
+ archetypeScope: string | null;
115
+ defaultRiskLevel: string | null;
116
+ enabled: boolean;
117
+ createdAt: string;
118
+ updatedAt: string;
119
+ [key: string]: unknown;
120
+ }
69
121
  export interface AgentSessionRequest {
70
122
  workspaceId: string;
71
123
  agentName: string;
@@ -122,3 +174,120 @@ export interface MemoryDraftRecord {
122
174
  updatedAt?: string;
123
175
  [key: string]: unknown;
124
176
  }
177
+ export interface MemorySearchRecord {
178
+ id: string;
179
+ workspaceId: string;
180
+ docType: MemoryDraftType;
181
+ authority: string;
182
+ title: string;
183
+ memoryKey: string | null;
184
+ excerpt: string;
185
+ score: number;
186
+ createdAt: string;
187
+ metadata?: Record<string, unknown> | null;
188
+ }
189
+ export interface TaskCreateRequest {
190
+ title: string;
191
+ intention: string;
192
+ templateSlug?: string;
193
+ requestedCapabilities?: string[];
194
+ targetPaths?: string[];
195
+ featureKey?: string;
196
+ taskKey?: string;
197
+ }
198
+ export interface TaskStepRecord {
199
+ id: string;
200
+ order: number;
201
+ name: string;
202
+ capability: string;
203
+ status: string;
204
+ assignedAgentId?: string | null;
205
+ assignedAgentName?: string | null;
206
+ output?: Record<string, unknown> | null;
207
+ lastError?: string | null;
208
+ [key: string]: unknown;
209
+ }
210
+ export interface ClaimableTaskStepRecord {
211
+ workspaceId: string;
212
+ taskId: string;
213
+ taskTitle: string;
214
+ stepId: string;
215
+ stepName: string;
216
+ capability: string;
217
+ status: string;
218
+ assignedAgentId: string;
219
+ assignedAgentName: string;
220
+ execution?: Record<string, unknown> | null;
221
+ createdAt: string;
222
+ updatedAt: string;
223
+ }
224
+ export interface ClaimedTaskStepResponse {
225
+ task: TaskRecord;
226
+ claim: ClaimableTaskStepRecord;
227
+ }
228
+ export interface TaskRecord {
229
+ id: string;
230
+ workspaceId: string;
231
+ title: string;
232
+ intention: string;
233
+ status: string;
234
+ riskLevel: string;
235
+ riskScore: number;
236
+ policyStatus: string;
237
+ conflictStatus: string;
238
+ requiresApproval?: boolean;
239
+ approvedBy?: string | null;
240
+ handoffSummary?: Record<string, unknown> | null;
241
+ requestedCapabilities: string[];
242
+ targetPaths: string[];
243
+ warnings: string[];
244
+ recommendedApproach?: string | null;
245
+ createdAt?: string;
246
+ updatedAt?: string;
247
+ handoffs?: Array<{
248
+ id: string;
249
+ title: string;
250
+ summary?: Record<string, unknown> | null;
251
+ nextSteps?: string[];
252
+ risks?: string[];
253
+ createdAt: string;
254
+ }>;
255
+ steps: TaskStepRecord[];
256
+ [key: string]: unknown;
257
+ }
258
+ export interface TaskHandoffRecord {
259
+ taskId: string;
260
+ workspaceId: string;
261
+ status: string;
262
+ title: string;
263
+ currentTitle?: string;
264
+ currentSummary?: Record<string, unknown> | null;
265
+ nextSteps?: string[];
266
+ risks?: string[];
267
+ memoryLanes?: string[];
268
+ [key: string]: unknown;
269
+ }
270
+ export interface TaskObservabilityRecord {
271
+ workspaceId: string;
272
+ taskId?: string;
273
+ title?: string;
274
+ status?: string;
275
+ riskLevel?: string;
276
+ policyStatus?: string;
277
+ conflictStatus?: string;
278
+ durationMs?: number;
279
+ delegationCount?: number;
280
+ handoffCount?: number;
281
+ attempts?: number;
282
+ totalTasks?: number;
283
+ completedTasks?: number;
284
+ failedTasks?: number;
285
+ blockedTasks?: number;
286
+ delegatedTasks?: number;
287
+ averageDurationMs?: number;
288
+ successRate?: number;
289
+ recentTasks?: Array<Record<string, unknown>>;
290
+ steps?: Array<Record<string, unknown>>;
291
+ timeline?: Array<Record<string, unknown>>;
292
+ [key: string]: unknown;
293
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vectorplane/ctrl-cli",
3
- "version": "0.1.11",
3
+ "version": "0.1.12",
4
4
  "description": "Official VectorPlane CLI.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",