veryfront 0.1.76 → 0.1.78

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 (64) hide show
  1. package/esm/cli/commands/pull/command.js +2 -2
  2. package/esm/cli/commands/task/command.d.ts.map +1 -1
  3. package/esm/cli/commands/task/command.js +57 -51
  4. package/esm/cli/commands/workflow/command-help.d.ts +3 -0
  5. package/esm/cli/commands/workflow/command-help.d.ts.map +1 -0
  6. package/esm/cli/commands/workflow/command-help.js +19 -0
  7. package/esm/cli/commands/workflow/command.d.ts +5 -0
  8. package/esm/cli/commands/workflow/command.d.ts.map +1 -0
  9. package/esm/cli/commands/workflow/command.js +119 -0
  10. package/esm/cli/commands/workflow/handler.d.ts +28 -0
  11. package/esm/cli/commands/workflow/handler.d.ts.map +1 -0
  12. package/esm/cli/commands/workflow/handler.js +19 -0
  13. package/esm/cli/help/command-definitions.d.ts.map +1 -1
  14. package/esm/cli/help/command-definitions.js +2 -0
  15. package/esm/cli/router.d.ts.map +1 -1
  16. package/esm/cli/router.js +2 -0
  17. package/esm/cli/shared/project-source-context.d.ts +18 -0
  18. package/esm/cli/shared/project-source-context.d.ts.map +1 -0
  19. package/esm/cli/shared/project-source-context.js +52 -0
  20. package/esm/deno.d.ts +1 -0
  21. package/esm/deno.js +2 -1
  22. package/esm/src/discovery/module-import.d.ts +8 -0
  23. package/esm/src/discovery/module-import.d.ts.map +1 -0
  24. package/esm/src/discovery/module-import.js +24 -0
  25. package/esm/src/platform/adapters/veryfront-api-client/operations.d.ts +3 -3
  26. package/esm/src/platform/adapters/veryfront-api-client/operations.d.ts.map +1 -1
  27. package/esm/src/platform/adapters/veryfront-api-client/operations.js +12 -10
  28. package/esm/src/platform/adapters/veryfront-api-client/schemas/api.schema.d.ts +4 -4
  29. package/esm/src/platform/adapters/veryfront-api-client/schemas/api.schema.js +4 -4
  30. package/esm/src/platform/index.d.ts +1 -0
  31. package/esm/src/platform/index.d.ts.map +1 -1
  32. package/esm/src/platform/index.js +1 -0
  33. package/esm/src/server/runtime-handler/index.d.ts +1 -1
  34. package/esm/src/server/runtime-handler/index.d.ts.map +1 -1
  35. package/esm/src/server/runtime-handler/index.js +0 -3
  36. package/esm/src/task/discovery.d.ts.map +1 -1
  37. package/esm/src/task/discovery.js +5 -13
  38. package/esm/src/workflow/discovery/workflow-discovery.d.ts.map +1 -1
  39. package/esm/src/workflow/discovery/workflow-discovery.js +3 -8
  40. package/package.json +1 -1
  41. package/src/cli/commands/pull/command.ts +3 -3
  42. package/src/cli/commands/task/command.ts +66 -57
  43. package/src/cli/commands/workflow/command-help.ts +21 -0
  44. package/src/cli/commands/workflow/command.ts +152 -0
  45. package/src/cli/commands/workflow/handler.ts +25 -0
  46. package/src/cli/help/command-definitions.ts +2 -0
  47. package/src/cli/router.ts +2 -0
  48. package/src/cli/shared/project-source-context.ts +96 -0
  49. package/src/deno.js +2 -1
  50. package/src/src/discovery/module-import.ts +36 -0
  51. package/src/src/platform/adapters/veryfront-api-client/operations.ts +14 -14
  52. package/src/src/platform/adapters/veryfront-api-client/schemas/api.schema.ts +4 -4
  53. package/src/src/platform/index.ts +1 -0
  54. package/src/src/server/runtime-handler/index.ts +0 -3
  55. package/src/src/task/discovery.ts +7 -15
  56. package/src/src/workflow/discovery/workflow-discovery.ts +3 -9
  57. package/esm/src/server/handlers/request/internal-tasks-list.handler.d.ts +0 -11
  58. package/esm/src/server/handlers/request/internal-tasks-list.handler.d.ts.map +0 -1
  59. package/esm/src/server/handlers/request/internal-tasks-list.handler.js +0 -72
  60. package/esm/src/task/control-plane.d.ts +0 -105
  61. package/esm/src/task/control-plane.d.ts.map +0 -1
  62. package/esm/src/task/control-plane.js +0 -52
  63. package/src/src/server/handlers/request/internal-tasks-list.handler.ts +0 -103
  64. package/src/src/task/control-plane.ts +0 -76
@@ -0,0 +1,96 @@
1
+ import { getConfig, type VeryfrontConfig } from "../../src/config/index.js";
2
+ import {
3
+ enhanceAdapterWithFS,
4
+ getEnv,
5
+ isExtendedFSAdapter,
6
+ runtime,
7
+ type RuntimeAdapter,
8
+ } from "../../src/platform/index.js";
9
+
10
+ interface ProxyProjectSourceContext {
11
+ projectSlug: string;
12
+ token: string;
13
+ projectId?: string;
14
+ branchRef?: string | null;
15
+ }
16
+
17
+ export interface ProjectSourceExecutionContext {
18
+ adapter: RuntimeAdapter;
19
+ config: VeryfrontConfig;
20
+ projectDir: string;
21
+ projectId?: string;
22
+ proxyContext?: ProxyProjectSourceContext;
23
+ }
24
+
25
+ function getProxyProjectSourceContext(): ProxyProjectSourceContext | null {
26
+ const projectSlug = getEnv("VERYFRONT_PROJECT_SLUG")?.trim();
27
+ const token = getEnv("VERYFRONT_API_TOKEN")?.trim();
28
+
29
+ if (!projectSlug || !token) {
30
+ return null;
31
+ }
32
+
33
+ const projectId = getEnv("VERYFRONT_PROJECT_ID")?.trim();
34
+ const branchRef = getEnv("VERYFRONT_BRANCH_REF")?.trim();
35
+
36
+ return {
37
+ projectSlug,
38
+ token,
39
+ projectId: projectId || undefined,
40
+ branchRef: branchRef || null,
41
+ };
42
+ }
43
+
44
+ async function loadProjectConfig(
45
+ projectDir: string,
46
+ adapter: RuntimeAdapter,
47
+ proxyContext?: ProxyProjectSourceContext,
48
+ ): Promise<VeryfrontConfig> {
49
+ const cacheKey = proxyContext?.projectId ?? proxyContext?.projectSlug;
50
+ return await getConfig(projectDir, adapter, cacheKey ? { cacheKey } : undefined);
51
+ }
52
+
53
+ export async function withProjectSourceContext<T>(
54
+ projectDir: string,
55
+ run: (context: ProjectSourceExecutionContext) => Promise<T>,
56
+ ): Promise<T> {
57
+ const baseAdapter = await runtime.get();
58
+ const initialConfig = await getConfig(projectDir, baseAdapter);
59
+ const adapter = await enhanceAdapterWithFS(baseAdapter, initialConfig, projectDir);
60
+ const proxyContext = getProxyProjectSourceContext();
61
+
62
+ if (
63
+ proxyContext &&
64
+ isExtendedFSAdapter(adapter.fs) &&
65
+ adapter.fs.isMultiProjectMode()
66
+ ) {
67
+ return await adapter.fs.runWithContext(
68
+ proxyContext.projectSlug,
69
+ proxyContext.token,
70
+ async () => {
71
+ const config = await loadProjectConfig(projectDir, adapter, proxyContext);
72
+ return await run({
73
+ adapter,
74
+ config,
75
+ projectDir,
76
+ projectId: proxyContext.projectId,
77
+ proxyContext,
78
+ });
79
+ },
80
+ proxyContext.projectId,
81
+ {
82
+ productionMode: false,
83
+ branch: proxyContext.branchRef ?? null,
84
+ },
85
+ );
86
+ }
87
+
88
+ const config = await loadProjectConfig(projectDir, adapter);
89
+ return await run({
90
+ adapter,
91
+ config,
92
+ projectDir,
93
+ projectId: proxyContext?.projectId,
94
+ proxyContext: proxyContext ?? undefined,
95
+ });
96
+ }
package/src/deno.js CHANGED
@@ -1,6 +1,6 @@
1
1
  export default {
2
2
  "name": "veryfront",
3
- "version": "0.1.76",
3
+ "version": "0.1.78",
4
4
  "license": "Apache-2.0",
5
5
  "nodeModulesDir": "auto",
6
6
  "exclude": [
@@ -114,6 +114,7 @@ export default {
114
114
  "#cli/shared/types": "./cli/shared/types.ts",
115
115
  "#cli/shared/constants": "./cli/shared/constants.ts",
116
116
  "#cli/shared/config": "./cli/shared/config.ts",
117
+ "#cli/shared/project-source-context": "./cli/shared/project-source-context.ts",
117
118
  "#cli/shared/slug": "./cli/shared/slug.ts",
118
119
  "#cli/shared/reserve-slug": "./cli/shared/reserve-slug.ts",
119
120
  "#cli/shared/server-startup": "./cli/shared/server-startup.ts",
@@ -0,0 +1,36 @@
1
+ import type { RuntimeAdapter } from "../platform/index.js";
2
+ import { detectPlatform } from "../platform/core-platform.js";
3
+ import * as pathHelper from "../platform/compat/path/index.js";
4
+ import { importModule } from "./transpiler.js";
5
+
6
+ interface ImportDiscoveryModuleOptions {
7
+ adapter: RuntimeAdapter;
8
+ projectDir?: string;
9
+ }
10
+
11
+ function normalizeModulePath(filePath: string): string {
12
+ return filePath.startsWith("file://") ? filePath : `file://${filePath}`;
13
+ }
14
+
15
+ function resolveModulePath(filePath: string, projectDir?: string): string {
16
+ if (filePath.startsWith("file://")) return filePath;
17
+ if (pathHelper.isAbsolute(filePath)) return normalizeModulePath(filePath);
18
+ if (!projectDir || projectDir === "." || projectDir === "") {
19
+ return normalizeModulePath(`/${filePath.replace(/^\/+/, "")}`);
20
+ }
21
+
22
+ return normalizeModulePath(pathHelper.join(projectDir, filePath));
23
+ }
24
+
25
+ export async function importDiscoveryModule(
26
+ filePath: string,
27
+ options: ImportDiscoveryModuleOptions,
28
+ ): Promise<Record<string, unknown>> {
29
+ const module = await importModule(resolveModulePath(filePath, options.projectDir), {
30
+ platform: detectPlatform(),
31
+ fsAdapter: options.adapter.fs,
32
+ baseDir: options.projectDir || ".",
33
+ });
34
+
35
+ return module as Record<string, unknown>;
36
+ }
@@ -154,14 +154,13 @@ export class VeryfrontAPIOperations {
154
154
 
155
155
  async listBranchFiles(
156
156
  projectRef: string,
157
- branchName = "main",
157
+ branchRef = "main",
158
158
  options: ListFilesOptions = {},
159
159
  ): Promise<FileListResult> {
160
160
  const params = buildListParams(options);
161
- const url = `/projects/${encodeURIComponent(projectRef)}/branches/${
162
- encodeURIComponent(branchName)
163
- }/files?${params}`;
164
- logger.debug("listBranchFiles", { projectRef, branchName, pattern: options.pattern });
161
+ params.set("branch", branchRef);
162
+ const url = `/projects/${encodeURIComponent(projectRef)}/files?${params}`;
163
+ logger.debug("listBranchFiles", { projectRef, branchRef, pattern: options.pattern });
165
164
 
166
165
  const raw = await this.request(url);
167
166
  const response = ListBranchFilesResponseSchema.parse(raw);
@@ -174,11 +173,11 @@ export class VeryfrontAPIOperations {
174
173
 
175
174
  async listAllBranchFiles(
176
175
  projectRef: string,
177
- branchName = "main",
176
+ branchRef = "main",
178
177
  options: Omit<ListFilesOptions, "cursor"> = {},
179
178
  ): Promise<ProjectFile[]> {
180
179
  const allFiles = await listAllFiles((cursor) =>
181
- this.listBranchFiles(projectRef, branchName, {
180
+ this.listBranchFiles(projectRef, branchRef, {
182
181
  ...options,
183
182
  cursor,
184
183
  limit: DEFAULT_PAGE_LIMIT,
@@ -187,21 +186,22 @@ export class VeryfrontAPIOperations {
187
186
 
188
187
  logger.debug("listAllBranchFiles DONE", {
189
188
  projectRef,
190
- branchName,
189
+ branchRef,
191
190
  totalFiles: allFiles.length,
192
191
  });
193
192
 
194
193
  return allFiles;
195
194
  }
196
195
 
197
- getBranchFile(projectRef: string, branchName: string, pathOrId: string): Promise<FileDetail> {
196
+ getBranchFile(projectRef: string, branchRef: string, pathOrId: string): Promise<FileDetail> {
198
197
  return withSpan(
199
198
  SpanNames.API_GET_FILE,
200
199
  async () => {
201
- const url = `/projects/${encodeURIComponent(projectRef)}/branches/${
202
- encodeURIComponent(branchName)
203
- }/files/${encodeURIComponent(pathOrId)}`;
204
- logger.debug("getBranchFile", { projectRef, branchName, pathOrId });
200
+ const params = new URLSearchParams({ branch: branchRef });
201
+ const url = `/projects/${encodeURIComponent(projectRef)}/files/${
202
+ encodeURIComponent(pathOrId)
203
+ }?${params}`;
204
+ logger.debug("getBranchFile", { projectRef, branchRef, pathOrId });
205
205
 
206
206
  const raw = await this.request(url);
207
207
  const response = BranchFileDetailSchema.parse(raw);
@@ -217,7 +217,7 @@ export class VeryfrontAPIOperations {
217
217
  {
218
218
  "api.operation": "getBranchFile",
219
219
  "api.project": projectRef,
220
- "api.branch": branchName,
220
+ "api.branch": branchRef,
221
221
  "api.path": pathOrId,
222
222
  },
223
223
  );
@@ -179,13 +179,13 @@ export const API_ENDPOINTS = {
179
179
  },
180
180
  listBranchFiles: {
181
181
  method: "GET" as const,
182
- path: "/projects/{projectRef}/branches/{branchName}/files",
183
- description: "List files in a branch (draft/working copy)",
182
+ path: "/projects/{projectRef}/files?branch={branchRef}",
183
+ description: "List files for a branch ref or name (omit branch for main branch)",
184
184
  },
185
185
  getBranchFile: {
186
186
  method: "GET" as const,
187
- path: "/projects/{projectRef}/branches/{branchName}/files/{pathOrId}",
188
- description: "Get file from a branch by path or UUID",
187
+ path: "/projects/{projectRef}/files/{pathOrId}?branch={branchRef}",
188
+ description: "Get file from a branch ref or name by path or UUID",
189
189
  },
190
190
  listEnvironmentFiles: {
191
191
  method: "GET" as const,
@@ -66,6 +66,7 @@ export { isDeno } from "./compat/runtime.js";
66
66
 
67
67
  // Adapters: filesystem
68
68
  export { createFSAdapter, VeryfrontFSAdapter } from "./adapters/fs/index.js";
69
+ export { enhanceAdapterWithFS, isExtendedFSAdapter } from "./adapters/fs/index.js";
69
70
 
70
71
  // Adapters: API client
71
72
  export { VeryfrontApiClient } from "./adapters/veryfront-api-client/index.js";
@@ -55,7 +55,6 @@ import { MarkdownPreviewHandler } from "../handlers/preview/markdown-preview.han
55
55
  import { OpenAPIHandler } from "../handlers/request/openapi.handler.js";
56
56
  import { OpenAPIDocsHandler } from "../handlers/request/openapi-docs.handler.js";
57
57
  import { InternalAgentsListHandler } from "../handlers/request/internal-agents-list.handler.js";
58
- import { InternalTasksListHandler } from "../handlers/request/internal-tasks-list.handler.js";
59
58
  import { AgentStreamHandler } from "../handlers/request/agent-stream.handler.js";
60
59
  import { AgentRunResumeHandler } from "../handlers/request/agent-run-resume.handler.js";
61
60
  import { AgentRunCancelHandler } from "../handlers/request/agent-run-cancel.handler.js";
@@ -132,7 +131,6 @@ export const HANDLER_NAMES = [
132
131
  "OpenAPIHandler",
133
132
  "OpenAPIDocsHandler",
134
133
  "InternalAgentsListHandler",
135
- "InternalTasksListHandler",
136
134
  "AgentStreamHandler",
137
135
  "AgentRunResumeHandler",
138
136
  "AgentRunCancelHandler",
@@ -187,7 +185,6 @@ const handlerFactories: Record<
187
185
  OpenAPIHandler: () => new OpenAPIHandler(),
188
186
  OpenAPIDocsHandler: () => new OpenAPIDocsHandler(),
189
187
  InternalAgentsListHandler: () => new InternalAgentsListHandler(),
190
- InternalTasksListHandler: () => new InternalTasksListHandler(),
191
188
  AgentStreamHandler: () => new AgentStreamHandler(),
192
189
  AgentRunResumeHandler: () => new AgentRunResumeHandler(),
193
190
  AgentRunCancelHandler: () => new AgentRunCancelHandler(),
@@ -25,7 +25,7 @@ import { logger as baseLogger } from "../utils/index.js";
25
25
  import type { RuntimeAdapter } from "../platform/index.js";
26
26
  import type { VeryfrontConfig } from "../config/index.js";
27
27
  import { collectFiles } from "../utils/file-discovery.js";
28
- import { loadHandlerModule } from "../routing/api/module-loader/loader.js";
28
+ import { importDiscoveryModule } from "../discovery/module-import.js";
29
29
  import type { TaskDefinition } from "./types.js";
30
30
  import { isTaskDefinition } from "./types.js";
31
31
 
@@ -144,17 +144,13 @@ export async function discoverTasks(
144
144
 
145
145
  for (const file of files) {
146
146
  try {
147
- const module = await loadHandlerModule({
148
- projectDir,
149
- modulePath: file.path,
147
+ const module = await importDiscoveryModule(file.path, {
150
148
  adapter,
151
- config,
149
+ projectDir,
152
150
  });
153
151
 
154
- if (!module) continue;
155
-
156
152
  // Prefer default export (aligned with discovery-engine behaviour)
157
- const defaultExport = (module as Record<string, unknown>).default;
153
+ const defaultExport = module.default;
158
154
  if (isTaskDefinition(defaultExport)) {
159
155
  const id = deriveTaskId(file.path, baseDir);
160
156
  tasks.push({
@@ -248,16 +244,12 @@ export async function findTaskById(
248
244
  if (id !== taskId) continue;
249
245
 
250
246
  try {
251
- const module = await loadHandlerModule({
252
- projectDir,
253
- modulePath: file.path,
247
+ const module = await importDiscoveryModule(file.path, {
254
248
  adapter,
255
- config,
249
+ projectDir,
256
250
  });
257
251
 
258
- if (!module) continue;
259
-
260
- const defaultExport = (module as Record<string, unknown>).default;
252
+ const defaultExport = module.default;
261
253
  if (isTaskDefinition(defaultExport)) {
262
254
  if (debug) {
263
255
  logger.info(`Found task "${id}" in ${file.path} (export: default)`);
@@ -27,7 +27,7 @@ import { logger as baseLogger } from "../../utils/index.js";
27
27
  import type { RuntimeAdapter } from "../../platform/index.js";
28
28
  import type { VeryfrontConfig } from "../../config/index.js";
29
29
  import { collectFiles } from "../../utils/file-discovery.js";
30
- import { loadHandlerModule } from "../../routing/api/module-loader/loader.js";
30
+ import { importDiscoveryModule } from "../../discovery/module-import.js";
31
31
  import type { WorkflowDefinition } from "../types.js";
32
32
 
33
33
  const logger = baseLogger.component("workflow-discovery");
@@ -167,17 +167,11 @@ export async function discoverWorkflows(
167
167
  // Load and extract workflows from each file
168
168
  for (const file of files) {
169
169
  try {
170
- const module = await loadHandlerModule({
171
- projectDir,
172
- modulePath: file.path,
170
+ const module = await importDiscoveryModule(file.path, {
173
171
  adapter,
174
- config,
172
+ projectDir,
175
173
  });
176
174
 
177
- if (!module) {
178
- continue;
179
- }
180
-
181
175
  // Extract workflows from module exports
182
176
  for (const [exportName, value] of Object.entries(module)) {
183
177
  const definition = extractWorkflowDefinition(value);
@@ -1,11 +0,0 @@
1
- import * as dntShim from "../../../../_dnt.shims.js";
2
- import { type RuntimeTaskDiscoveryDeps } from "../../../task/control-plane.js";
3
- import { BaseHandler } from "../response/base.js";
4
- import type { HandlerContext, HandlerMetadata, HandlerResult } from "../types.js";
5
- export declare class InternalTasksListHandler extends BaseHandler {
6
- private readonly deps;
7
- metadata: HandlerMetadata;
8
- constructor(deps?: RuntimeTaskDiscoveryDeps);
9
- handle(req: dntShim.Request, ctx: HandlerContext): Promise<HandlerResult>;
10
- }
11
- //# sourceMappingURL=internal-tasks-list.handler.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"internal-tasks-list.handler.d.ts","sourceRoot":"","sources":["../../../../../src/src/server/handlers/request/internal-tasks-list.handler.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,OAAO,MAAM,2BAA2B,CAAC;AAGrD,OAAO,EAKL,KAAK,wBAAwB,EAC9B,MAAM,gCAAgC,CAAC;AAUxC,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,KAAK,EAAE,cAAc,EAAE,eAAe,EAAmB,aAAa,EAAE,MAAM,aAAa,CAAC;AAEnG,qBAAa,wBAAyB,SAAQ,WAAW;IAQrD,OAAO,CAAC,QAAQ,CAAC,IAAI;IAPvB,QAAQ,EAAE,eAAe,CAIvB;gBAGiB,IAAI,GAAE,wBAA0D;IAK7E,MAAM,CAAC,GAAG,EAAE,OAAO,CAAC,OAAO,EAAE,GAAG,EAAE,cAAc,GAAG,OAAO,CAAC,aAAa,CAAC;CAmEhF"}
@@ -1,72 +0,0 @@
1
- import { PRIORITY_MEDIUM_API } from "../../../utils/constants/index.js";
2
- import { ZodError } from "zod";
3
- import { ControlPlaneTasksListRequestSchema, defaultRuntimeTaskDiscoveryDeps, listRuntimeTasks, } from "../../../task/control-plane.js";
4
- import { ControlPlaneRequestError, verifyControlPlaneRequest, } from "../../../internal-agents/control-plane-auth.js";
5
- import { INTERNAL_AGENT_CONTROL_PLANE_MAX_BODY_BYTES, InternalAgentRequestBodyTooLargeError, readInternalAgentRequestBody, } from "../../../internal-agents/request-body.js";
6
- import { BaseHandler } from "../response/base.js";
7
- export class InternalTasksListHandler extends BaseHandler {
8
- deps;
9
- metadata = {
10
- name: "InternalTasksListHandler",
11
- priority: PRIORITY_MEDIUM_API,
12
- patterns: [{ pattern: "/internal/tasks/list", exact: true, method: "POST" }],
13
- };
14
- constructor(deps = defaultRuntimeTaskDiscoveryDeps) {
15
- super();
16
- this.deps = deps;
17
- }
18
- async handle(req, ctx) {
19
- if (!this.shouldHandle(req, ctx)) {
20
- return this.continue();
21
- }
22
- return this.withProxyContext(ctx, async () => {
23
- const builder = this.createResponseBuilder(ctx)
24
- .withCORS(req, ctx.securityConfig?.cors)
25
- .withSecurity(ctx.securityConfig ?? undefined, req);
26
- try {
27
- const rawBody = await readInternalAgentRequestBody(req, INTERNAL_AGENT_CONTROL_PLANE_MAX_BODY_BYTES);
28
- const payload = ControlPlaneTasksListRequestSchema.parse(JSON.parse(rawBody));
29
- const claims = await verifyControlPlaneRequest(req, ctx, rawBody, {
30
- expectedSubject: payload.requestId,
31
- expectedSurface: payload.surface,
32
- });
33
- if (payload.projectId !== claims.project_id ||
34
- (ctx.projectId !== undefined && payload.projectId !== ctx.projectId)) {
35
- this.logWarn("Internal tasks list request body did not match signed claims", {
36
- projectSlug: ctx.projectSlug,
37
- projectId: ctx.projectId,
38
- requestId: payload.requestId,
39
- signedRequestId: claims.sub,
40
- surface: payload.surface,
41
- signedSurface: claims.surface,
42
- });
43
- return this.respond(builder.json({ error: "Invalid control-plane signature" }, 401));
44
- }
45
- const response = await listRuntimeTasks(ctx, this.deps);
46
- return this.respond(builder.json(response, 200));
47
- }
48
- catch (error) {
49
- if (error instanceof InternalAgentRequestBodyTooLargeError) {
50
- return this.respond(builder.json({ error: error.message }, error.status));
51
- }
52
- if (error instanceof ControlPlaneRequestError) {
53
- this.logWarn("Internal tasks list signature verification failed", {
54
- error: error.message,
55
- projectSlug: ctx.projectSlug,
56
- projectId: ctx.projectId,
57
- });
58
- return this.respond(builder.json({ error: error.message }, error.status));
59
- }
60
- if (error instanceof SyntaxError || error instanceof ZodError) {
61
- this.logWarn("Internal tasks list request validation failed", {
62
- error: error instanceof Error ? error.message : String(error),
63
- projectSlug: ctx.projectSlug,
64
- projectId: ctx.projectId,
65
- });
66
- return this.respond(builder.json({ error: "Invalid internal tasks request" }, 400));
67
- }
68
- throw error;
69
- }
70
- });
71
- }
72
- }
@@ -1,105 +0,0 @@
1
- import type { HandlerContext } from "../types/index.js";
2
- import { z } from "zod";
3
- import { discoverTasks, type TaskDiscoveryOptions } from "./discovery.js";
4
- export declare const ControlPlaneTasksListRequestSchema: z.ZodObject<{
5
- requestId: z.ZodString;
6
- projectId: z.ZodString;
7
- surface: z.ZodEnum<["studio", "channels", "a2a", "mcp"]>;
8
- }, "strip", z.ZodTypeAny, {
9
- requestId: string;
10
- projectId: string;
11
- surface: "mcp" | "studio" | "channels" | "a2a";
12
- }, {
13
- requestId: string;
14
- projectId: string;
15
- surface: "mcp" | "studio" | "channels" | "a2a";
16
- }>;
17
- export declare const RuntimeTaskSchema: z.ZodObject<{
18
- id: z.ZodString;
19
- name: z.ZodString;
20
- description: z.ZodNullable<z.ZodString>;
21
- target: z.ZodString;
22
- sourcePath: z.ZodString;
23
- inputSchema: z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
24
- outputSchema: z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
25
- schedulable: z.ZodBoolean;
26
- }, "strip", z.ZodTypeAny, {
27
- description: string | null;
28
- name: string;
29
- id: string;
30
- target: string;
31
- sourcePath: string;
32
- outputSchema: Record<string, unknown> | null;
33
- inputSchema: Record<string, unknown> | null;
34
- schedulable: boolean;
35
- }, {
36
- description: string | null;
37
- name: string;
38
- id: string;
39
- target: string;
40
- sourcePath: string;
41
- outputSchema: Record<string, unknown> | null;
42
- inputSchema: Record<string, unknown> | null;
43
- schedulable: boolean;
44
- }>;
45
- export declare const RuntimeTaskListResponseSchema: z.ZodObject<{
46
- tasks: z.ZodArray<z.ZodObject<{
47
- id: z.ZodString;
48
- name: z.ZodString;
49
- description: z.ZodNullable<z.ZodString>;
50
- target: z.ZodString;
51
- sourcePath: z.ZodString;
52
- inputSchema: z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
53
- outputSchema: z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
54
- schedulable: z.ZodBoolean;
55
- }, "strip", z.ZodTypeAny, {
56
- description: string | null;
57
- name: string;
58
- id: string;
59
- target: string;
60
- sourcePath: string;
61
- outputSchema: Record<string, unknown> | null;
62
- inputSchema: Record<string, unknown> | null;
63
- schedulable: boolean;
64
- }, {
65
- description: string | null;
66
- name: string;
67
- id: string;
68
- target: string;
69
- sourcePath: string;
70
- outputSchema: Record<string, unknown> | null;
71
- inputSchema: Record<string, unknown> | null;
72
- schedulable: boolean;
73
- }>, "many">;
74
- }, "strip", z.ZodTypeAny, {
75
- tasks: {
76
- description: string | null;
77
- name: string;
78
- id: string;
79
- target: string;
80
- sourcePath: string;
81
- outputSchema: Record<string, unknown> | null;
82
- inputSchema: Record<string, unknown> | null;
83
- schedulable: boolean;
84
- }[];
85
- }, {
86
- tasks: {
87
- description: string | null;
88
- name: string;
89
- id: string;
90
- target: string;
91
- sourcePath: string;
92
- outputSchema: Record<string, unknown> | null;
93
- inputSchema: Record<string, unknown> | null;
94
- schedulable: boolean;
95
- }[];
96
- }>;
97
- export type ControlPlaneTasksListRequest = z.infer<typeof ControlPlaneTasksListRequestSchema>;
98
- export type RuntimeTask = z.infer<typeof RuntimeTaskSchema>;
99
- export type RuntimeTaskListResponse = z.infer<typeof RuntimeTaskListResponseSchema>;
100
- export interface RuntimeTaskDiscoveryDeps {
101
- discoverTasks: (options: TaskDiscoveryOptions) => ReturnType<typeof discoverTasks>;
102
- }
103
- export declare const defaultRuntimeTaskDiscoveryDeps: RuntimeTaskDiscoveryDeps;
104
- export declare function listRuntimeTasks(ctx: HandlerContext, deps?: RuntimeTaskDiscoveryDeps): Promise<RuntimeTaskListResponse>;
105
- //# sourceMappingURL=control-plane.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"control-plane.d.ts","sourceRoot":"","sources":["../../../src/src/task/control-plane.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACxD,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,aAAa,EAAE,KAAK,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AAE1E,eAAO,MAAM,kCAAkC;;;;;;;;;;;;EAI7C,CAAC;AAIH,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;EAS5B,CAAC;AAEH,eAAO,MAAM,6BAA6B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAExC,CAAC;AAEH,MAAM,MAAM,4BAA4B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kCAAkC,CAAC,CAAC;AAC9F,MAAM,MAAM,WAAW,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,iBAAiB,CAAC,CAAC;AAC5D,MAAM,MAAM,uBAAuB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,6BAA6B,CAAC,CAAC;AAEpF,MAAM,WAAW,wBAAwB;IACvC,aAAa,EAAE,CAAC,OAAO,EAAE,oBAAoB,KAAK,UAAU,CAAC,OAAO,aAAa,CAAC,CAAC;CACpF;AAED,eAAO,MAAM,+BAA+B,EAAE,wBAE7C,CAAC;AAUF,wBAAsB,gBAAgB,CACpC,GAAG,EAAE,cAAc,EACnB,IAAI,GAAE,wBAA0D,GAC/D,OAAO,CAAC,uBAAuB,CAAC,CAwBlC"}
@@ -1,52 +0,0 @@
1
- import { ControlPlaneSurfaceSchema } from "../channels/control-plane.js";
2
- import { z } from "zod";
3
- import { discoverTasks } from "./discovery.js";
4
- export const ControlPlaneTasksListRequestSchema = z.object({
5
- requestId: z.string().min(1),
6
- projectId: z.string().min(1),
7
- surface: ControlPlaneSurfaceSchema,
8
- });
9
- const JsonSchemaRecordSchema = z.record(z.unknown());
10
- export const RuntimeTaskSchema = z.object({
11
- id: z.string().min(1),
12
- name: z.string().min(1),
13
- description: z.string().nullable(),
14
- target: z.string().min(1),
15
- sourcePath: z.string().min(1),
16
- inputSchema: JsonSchemaRecordSchema.nullable(),
17
- outputSchema: JsonSchemaRecordSchema.nullable(),
18
- schedulable: z.boolean(),
19
- });
20
- export const RuntimeTaskListResponseSchema = z.object({
21
- tasks: z.array(RuntimeTaskSchema),
22
- });
23
- export const defaultRuntimeTaskDiscoveryDeps = {
24
- discoverTasks,
25
- };
26
- function normalizeJsonSchema(value) {
27
- if (value == null || typeof value !== "object" || Array.isArray(value)) {
28
- return null;
29
- }
30
- return value;
31
- }
32
- export async function listRuntimeTasks(ctx, deps = defaultRuntimeTaskDiscoveryDeps) {
33
- const discovery = await deps.discoverTasks({
34
- projectDir: ctx.projectDir,
35
- adapter: ctx.adapter,
36
- config: ctx.config,
37
- debug: ctx.debug ?? false,
38
- });
39
- const tasks = discovery.tasks
40
- .map((task) => RuntimeTaskSchema.parse({
41
- id: task.id,
42
- name: task.name,
43
- description: task.definition.description ?? null,
44
- target: `task:${task.id}`,
45
- sourcePath: task.filePath,
46
- inputSchema: normalizeJsonSchema(task.definition.inputSchema),
47
- outputSchema: normalizeJsonSchema(task.definition.outputSchema),
48
- schedulable: task.definition.schedulable ?? true,
49
- }))
50
- .sort((left, right) => left.name.localeCompare(right.name));
51
- return RuntimeTaskListResponseSchema.parse({ tasks });
52
- }