@intuned/runtime-dev 0.1.0-test.9 → 1.0.0-udas.1

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 (46) hide show
  1. package/.babelrc +0 -2
  2. package/InterfaceTemplate/index.playwright.ts +5 -0
  3. package/InterfaceTemplate/utils.ts +39 -0
  4. package/WebTemplate/api.ts +90 -92
  5. package/WebTemplate/controllers/async.ts +52 -48
  6. package/WebTemplate/controllers/authSessions/check.ts +4 -5
  7. package/WebTemplate/controllers/authSessions/create.ts +6 -8
  8. package/WebTemplate/controllers/authSessions/resumeOperation.ts +1 -1
  9. package/WebTemplate/controllers/runApi/helpers.ts +13 -8
  10. package/WebTemplate/index.playwright.ts +32 -42
  11. package/WebTemplate/jobs.ts +13 -2
  12. package/WebTemplate/utils.ts +48 -1
  13. package/api/test2.ts +6 -1
  14. package/auth-sessions/check.ts +3 -1
  15. package/auth-sessions/create.ts +10 -10
  16. package/bin/intuned-ts-check +1 -1
  17. package/dist/commands/api/run.js +7 -5
  18. package/dist/commands/auth-sessions/run-check.js +9 -3
  19. package/dist/commands/auth-sessions/run-create.js +11 -6
  20. package/dist/commands/build.js +17 -12
  21. package/dist/commands/common/tsNodeImport.d.ts +1 -0
  22. package/dist/commands/common/tsNodeImport.js +20 -0
  23. package/dist/commands/common/utils/settings.js +5 -5
  24. package/dist/commands/common/utils/template.d.ts +2 -0
  25. package/dist/commands/common/utils/{webTemplate.js → template.js} +7 -7
  26. package/dist/commands/interface/run.d.ts +1 -2
  27. package/dist/commands/interface/run.js +150 -110
  28. package/dist/commands/ts-check.js +9 -7
  29. package/dist/common/formatZodError.d.ts +2 -0
  30. package/dist/common/formatZodError.js +18 -0
  31. package/dist/common/getPlaywrightConstructs.js +6 -2
  32. package/dist/common/runApi/errors.d.ts +8 -3
  33. package/dist/common/runApi/errors.js +26 -3
  34. package/dist/common/runApi/index.d.ts +1 -1
  35. package/dist/common/runApi/index.js +37 -65
  36. package/dist/common/runApi/types.d.ts +287 -71
  37. package/dist/common/runApi/types.js +29 -5
  38. package/dist/runtime/executionHelpers.test.js +6 -6
  39. package/package.json +1 -1
  40. package/tsconfig.json +1 -2
  41. package/InterfaceTemplate/index.ts +0 -1
  42. package/dist/commands/common/getDefaultExportFromFile.d.ts +0 -1
  43. package/dist/commands/common/getDefaultExportFromFile.js +0 -17
  44. package/dist/commands/common/utils/webTemplate.d.ts +0 -1
  45. package/preserve-dynamic-imports.js +0 -16
  46. package/testing +0 -0
package/.babelrc CHANGED
@@ -13,9 +13,7 @@
13
13
  "@babel/preset-typescript"
14
14
  ],
15
15
  "plugins": [
16
- ["./preserve-dynamic-imports.js"],
17
16
  "babel-plugin-macros",
18
- "@babel/plugin-syntax-dynamic-import",
19
17
  "@babel/plugin-transform-export-namespace-from"
20
18
  ],
21
19
  "sourceMaps": false,
@@ -0,0 +1,5 @@
1
+ import { runAutomationCLI } from "@intuned/runtime/dist/commands/interface/run";
2
+
3
+ import { importModule } from "./utils";
4
+
5
+ runAutomationCLI(importModule);
@@ -0,0 +1,39 @@
1
+ export async function importModule(path: string) {
2
+ const [folderName, ...functionNameParts] = path.split("/");
3
+ const functionNameDepth = functionNameParts.length;
4
+
5
+ // string literals should be inline
6
+ // currently we support only 5 levels of depth
7
+ // rollup dynamic import does not support multiple levels of dynamic imports so we need to specify the possible paths explicitly
8
+ let imported: any = undefined;
9
+ switch (functionNameDepth) {
10
+ case 1:
11
+ imported = await import(`./${folderName}/${functionNameParts[0]}.ts`);
12
+ break;
13
+ case 2:
14
+ imported = await import(
15
+ `./${folderName}/${functionNameParts[0]}/${functionNameParts[1]}.ts`
16
+ );
17
+ break;
18
+ case 3:
19
+ imported = await import(
20
+ `./${folderName}/${functionNameParts[0]}/${functionNameParts[1]}/${functionNameParts[2]}.ts`
21
+ );
22
+ break;
23
+ case 4:
24
+ imported = await import(
25
+ `./${folderName}/${functionNameParts[0]}/${functionNameParts[1]}/${functionNameParts[2]}/${functionNameParts[3]}.ts`
26
+ );
27
+ break;
28
+ case 5:
29
+ imported = await import(
30
+ `./${folderName}/${functionNameParts[0]}/${functionNameParts[1]}/${functionNameParts[2]}/${functionNameParts[3]}/${functionNameParts[4]}.ts`
31
+ );
32
+ break;
33
+ default:
34
+ throw new Error(
35
+ "intuned supports maximum 5 levels of depth in the api folder"
36
+ );
37
+ }
38
+ return imported;
39
+ }
@@ -33,109 +33,107 @@ import {
33
33
  } from "./headers";
34
34
  import { FEATURES } from "./features";
35
35
 
36
- export function registerApiEndpoints() {
37
- if (!isJobRunMachine()) {
38
- app.use((req, _, next) => {
39
- const runId = req.headers[RUN_ID_HEADER] as string;
40
- const jobId = req.headers[JOB_ID_HEADER] as string;
41
- const jobRunId = req.headers[JOB_RUN_ID_HEADER] as string;
42
- const queueId = req.headers[QUEUE_ID_HEADER] as string;
43
- const proxy = req?.body?.proxy
44
- ? (proxyToUrl(req.body.proxy as ProxyConfig) as string)
45
- : undefined;
46
- const contextData = {
47
- runId: runId ?? "",
48
- jobId,
49
- jobRunId,
50
- queueId,
51
- proxy,
52
- ...(req?.body?.executionContext ?? {}),
53
- };
54
- runWithContext(contextData, next);
55
- });
56
-
57
- app.get(
58
- "/api/protected/health",
59
- accessKeyValidatorMiddleware,
60
- async (req, res) => {
61
- res.status(200).json({ status: "ok" });
62
- }
63
- );
36
+ if (!isJobRunMachine()) {
37
+ app.use((req, _, next) => {
38
+ const runId = req.headers[RUN_ID_HEADER] as string;
39
+ const jobId = req.headers[JOB_ID_HEADER] as string;
40
+ const jobRunId = req.headers[JOB_RUN_ID_HEADER] as string;
41
+ const queueId = req.headers[QUEUE_ID_HEADER] as string;
42
+ const proxy = req?.body?.proxy
43
+ ? (proxyToUrl(req.body.proxy as ProxyConfig) as string)
44
+ : undefined;
45
+ const contextData = {
46
+ runId: runId ?? "",
47
+ jobId,
48
+ jobRunId,
49
+ queueId,
50
+ proxy,
51
+ ...(req?.body?.executionContext ?? {}),
52
+ };
53
+ runWithContext(contextData, next);
54
+ });
64
55
 
65
- app.post(
66
- "/api/auth-session/create",
67
- accessKeyValidatorMiddleware,
68
- errorRetryMiddleware(createAuthSessionController)
69
- );
56
+ app.get(
57
+ "/api/protected/health",
58
+ accessKeyValidatorMiddleware,
59
+ async (req, res) => {
60
+ res.status(200).json({ status: "ok" });
61
+ }
62
+ );
70
63
 
71
- app.post(
72
- "/api/auth-session-async/create",
73
- accessKeyValidatorMiddleware,
74
- errorRetryMiddleware(createAuthSessionAsyncController)
75
- );
64
+ app.post(
65
+ "/api/auth-session/create",
66
+ accessKeyValidatorMiddleware,
67
+ errorRetryMiddleware(createAuthSessionController)
68
+ );
76
69
 
77
- app.post(
78
- "/api/auth-session/check",
79
- accessKeyValidatorMiddleware,
80
- errorRetryMiddleware(checkAuthSessionController)
81
- );
70
+ app.post(
71
+ "/api/auth-session-async/create",
72
+ accessKeyValidatorMiddleware,
73
+ errorRetryMiddleware(createAuthSessionAsyncController)
74
+ );
82
75
 
83
- app.post(
84
- "/api/auth-session-async/check",
85
- accessKeyValidatorMiddleware,
86
- errorRetryMiddleware(checkAuthSessionAsyncController)
87
- );
76
+ app.post(
77
+ "/api/auth-session/check",
78
+ accessKeyValidatorMiddleware,
79
+ errorRetryMiddleware(checkAuthSessionController)
80
+ );
88
81
 
89
- app.post(
90
- "/api/auth-session/kill",
91
- accessKeyValidatorMiddleware,
92
- errorRetryMiddleware(killAuthSessionOperationController)
93
- );
82
+ app.post(
83
+ "/api/auth-session-async/check",
84
+ accessKeyValidatorMiddleware,
85
+ errorRetryMiddleware(checkAuthSessionAsyncController)
86
+ );
94
87
 
95
- app.post(
96
- "/api/auth-session/resume",
97
- accessKeyValidatorMiddleware,
98
- errorRetryMiddleware(resumeAuthSessionOperationController)
99
- );
88
+ app.post(
89
+ "/api/auth-session/kill",
90
+ accessKeyValidatorMiddleware,
91
+ errorRetryMiddleware(killAuthSessionOperationController)
92
+ );
100
93
 
101
- app.post(
102
- "/api/auth-session-async/resume",
103
- accessKeyValidatorMiddleware,
104
- errorRetryMiddleware(resumeAuthSessionOperationAsyncController)
105
- );
94
+ app.post(
95
+ "/api/auth-session/resume",
96
+ accessKeyValidatorMiddleware,
97
+ errorRetryMiddleware(resumeAuthSessionOperationController)
98
+ );
106
99
 
107
- app.post(
108
- "/api/run/*",
109
- accessKeyValidatorMiddleware,
110
- errorRetryMiddleware(runApiController)
111
- );
100
+ app.post(
101
+ "/api/auth-session-async/resume",
102
+ accessKeyValidatorMiddleware,
103
+ errorRetryMiddleware(resumeAuthSessionOperationAsyncController)
104
+ );
112
105
 
113
- app.post(
114
- "/api/run-async/start/*",
115
- accessKeyValidatorMiddleware,
116
- errorRetryMiddleware(runApiAsyncController) // todo: this probably needs changing
117
- );
106
+ app.post(
107
+ "/api/run/*",
108
+ accessKeyValidatorMiddleware,
109
+ errorRetryMiddleware(runApiController)
110
+ );
118
111
 
119
- app.get(
120
- "/api/run-async/count",
121
- accessKeyValidatorMiddleware,
122
- getActiveAsyncEndpointController
123
- );
112
+ app.post(
113
+ "/api/run-async/start/*",
114
+ accessKeyValidatorMiddleware,
115
+ errorRetryMiddleware(runApiAsyncController) // todo: this probably needs changing
116
+ );
124
117
 
125
- app.post(
126
- "/api/trace/upload/:runId",
127
- accessKeyValidatorMiddleware,
128
- uploadTraceController
129
- );
118
+ app.get(
119
+ "/api/run-async/count",
120
+ accessKeyValidatorMiddleware,
121
+ getActiveAsyncEndpointController
122
+ );
130
123
 
131
- app.post(
132
- "/api/trace/delete/:runId",
133
- accessKeyValidatorMiddleware,
134
- deleteTraceController
135
- );
136
- }
124
+ app.post(
125
+ "/api/trace/upload/:runId",
126
+ accessKeyValidatorMiddleware,
127
+ uploadTraceController
128
+ );
137
129
 
138
- app.get("/api/features", accessKeyValidatorMiddleware, async (_, res) => {
139
- res.status(200).json({ features: FEATURES });
140
- });
130
+ app.post(
131
+ "/api/trace/delete/:runId",
132
+ accessKeyValidatorMiddleware,
133
+ deleteTraceController
134
+ );
141
135
  }
136
+
137
+ app.get("/api/features", accessKeyValidatorMiddleware, async (_, res) => {
138
+ res.status(200).json({ features: FEATURES });
139
+ });
@@ -40,59 +40,63 @@ export async function runEndpointAsync<_Parameters extends any[], _Result>(
40
40
  } catch (e: any) {
41
41
  console.error(`Error running ${requestId} in async mode:`, e);
42
42
  ({ status, body } = getErrorResponse(e));
43
- } finally {
44
- AsyncRunEndpointController.removeRequest(taskToken);
45
43
  }
46
44
 
47
- // report result
48
- console.log("Reporting result for", requestId);
49
45
  try {
50
- // `retry` will keep retrying any errors unless they are thrown through calling `bail`
51
- await retry(
52
- async (bail: (e: Error) => void) => {
53
- const response = await callBackendFunctionWithToken(
54
- "run/reportResult",
55
- {
56
- method: "POST",
57
- headers: {
58
- "Content-Type": "application/json",
59
- "fly-instance-id": process.env.FLY_ALLOC_ID ?? "",
60
- },
61
- body: JSON.stringify({
62
- status,
63
- body,
64
- startTime,
65
- taskToken,
66
- }),
67
- }
68
- );
69
- if (!response.ok) {
70
- // Do not retry unauthenticated, forbidden, not found or too large responses
71
- if ([401, 403, 404, 413].includes(response.status)) {
72
- bail(
73
- new Error(
74
- `Reporting result failed for ${requestId} (non-retryable), status ${response.status}`
75
- )
76
- );
46
+ // report result
47
+ console.log("Reporting result for", requestId);
48
+ try {
49
+ // `retry` will keep retrying any errors unless they are thrown through calling `bail`
50
+ await retry(
51
+ async (bail: (e: Error) => void) => {
52
+ const response = await callBackendFunctionWithToken(
53
+ "run/reportResult",
54
+ {
55
+ method: "POST",
56
+ headers: {
57
+ "Content-Type": "application/json",
58
+ "fly-instance-id": process.env.FLY_ALLOC_ID ?? "",
59
+ },
60
+ body: JSON.stringify({
61
+ status,
62
+ body,
63
+ startTime,
64
+ taskToken,
65
+ }),
66
+ }
67
+ ).catch((e) => {
68
+ const message = `Reporting result failed for ${requestId}, error: ${e.message}`;
69
+ console.error(message);
70
+ throw e;
71
+ });
72
+ if (!response.ok) {
73
+ // Do not retry unauthenticated, forbidden, not found or too large responses
74
+ if ([401, 403, 404, 413].includes(response.status)) {
75
+ const message = `Reporting result failed for ${requestId} (non-retryable), status ${response.status}`;
76
+ console.error(message);
77
+ bail(new Error(message));
78
+ }
79
+ // retry other errors (such as 502)
80
+ const message = `Reporting result failed for ${requestId}, status ${response.status}`;
81
+ console.error(message);
82
+ throw new Error(message);
77
83
  }
78
- // retry other errors (such as 502)
79
- throw new Error(
80
- `Reporting result failed for ${requestId}, status ${response.status}`
81
- );
82
- }
83
84
 
84
- return response;
85
- },
86
- {
87
- retries: 5,
88
- factor: 2,
89
- maxTimeout: 1000 * 60, // 1 minute
90
- minTimeout: 1000 * 5, // 5 seconds
91
- }
92
- );
93
- console.log("Reported result for", requestId);
94
- } catch (e: any) {
95
- console.log(e?.message ?? `Reporting result failed for ${requestId}`);
85
+ return response;
86
+ },
87
+ {
88
+ retries: 5,
89
+ factor: 2,
90
+ maxTimeout: 1000 * 60, // 1 minute
91
+ minTimeout: 1000 * 5, // 5 seconds
92
+ }
93
+ );
94
+ console.log("Reported result for", requestId);
95
+ } catch (e: any) {
96
+ // ignore
97
+ }
98
+ } finally {
99
+ AsyncRunEndpointController.removeRequest(taskToken);
96
100
  }
97
101
 
98
102
  await ShutdownController.instance.checkForShutdown();
@@ -1,6 +1,7 @@
1
1
  import { readJSON } from "fs-extra";
2
2
  import { isHeadless } from "../../utils";
3
3
  import { runApi } from "@intuned/runtime/dist/common/runApi";
4
+ import { importModule } from "../../utils";
4
5
 
5
6
  export async function checkAuthSession({
6
7
  proxy,
@@ -35,7 +36,7 @@ export async function checkAuthSession({
35
36
  name: "auth-sessions/check",
36
37
  },
37
38
  runOptions: {
38
- environment: "deployed",
39
+ environment: "standalone",
39
40
  headless: isHeadless(),
40
41
  proxy,
41
42
  },
@@ -46,12 +47,10 @@ export async function checkAuthSession({
46
47
  },
47
48
  runCheck: false,
48
49
  },
50
+ importFunction: importModule,
49
51
  });
50
52
  if (result.isErr()) {
51
- return {
52
- status: 500,
53
- body: result.error,
54
- };
53
+ return result.error.apiResponse;
55
54
  }
56
55
  return {
57
56
  status: 200,
@@ -1,5 +1,5 @@
1
1
  import { authSessionsContextsStore } from "./store";
2
- import { getTraceFilePath, isHeadless } from "../../utils";
2
+ import { getTraceFilePath, isHeadless, importModule } from "../../utils";
3
3
  import * as fs from "fs-extra";
4
4
  import { runApiGenerator } from "@intuned/runtime/dist/common/runApi";
5
5
  import type { RequestMoreInfoDetails } from "@intuned/runtime/dist/runtime";
@@ -54,7 +54,7 @@ export async function createAuthSession({
54
54
  >({
55
55
  automationFunction: {
56
56
  name: "auth-sessions/create",
57
- params: parameters ?? {},
57
+ params: parameters,
58
58
  },
59
59
  tracing: saveTrace
60
60
  ? {
@@ -63,24 +63,22 @@ export async function createAuthSession({
63
63
  }
64
64
  : { enabled: false },
65
65
  runOptions: {
66
- environment: "deployed",
66
+ environment: "standalone",
67
67
  headless,
68
68
  proxy,
69
69
  },
70
70
  abortSignal: abortController.signal,
71
71
  retrieveSession: true,
72
+ importFunction: importModule,
72
73
  });
73
74
 
74
75
  const result = await createGenerator.next();
75
76
 
76
- if (result.done) {
77
+ if (result.done === true) {
77
78
  const r = result.value;
78
79
 
79
80
  if (r.isErr()) {
80
- return {
81
- status: 500,
82
- body: r.error,
83
- };
81
+ return r.error.apiResponse;
84
82
  }
85
83
 
86
84
  return {
@@ -33,7 +33,7 @@ export async function resumeAuthSessionOperation({
33
33
 
34
34
  const result = await operation.generator.next(input);
35
35
 
36
- if (result.done) {
36
+ if (result.done === true) {
37
37
  authSessionsContextsStore.delete(operationId);
38
38
  if (result.value.isErr()) {
39
39
  return result.value.error.apiResponse;
@@ -1,4 +1,8 @@
1
- import { getTraceFilePath, waitWithExtendableTimeout } from "../../utils";
1
+ import {
2
+ getTraceFilePath,
3
+ importModule,
4
+ waitWithExtendableTimeout,
5
+ } from "../../utils";
2
6
  import * as fs from "fs-extra";
3
7
  import { getExecutionContext } from "@intuned/runtime";
4
8
  import { backendFunctionsTokenManager } from "@intuned/runtime/dist/common/jwtTokenManager";
@@ -61,23 +65,24 @@ export async function runApi({
61
65
 
62
66
  const abortController = new AbortController();
63
67
 
68
+ backendFunctionsTokenManager.token = functionsToken;
64
69
  const resultWithTimeout = await waitWithExtendableTimeout({
65
70
  promise: runApiInternal({
66
71
  automationFunction: {
67
72
  name: `api/${functionName}`,
68
- params: params ?? {},
73
+ params,
69
74
  },
70
- auth: !isAuthSessionEnabled
71
- ? undefined
72
- : {
75
+ auth: isAuthSessionEnabled
76
+ ? {
73
77
  session: {
74
78
  type: "state",
75
79
  state: session,
76
80
  },
77
81
  runCheck: isAuthSessionEnabled,
78
- },
82
+ }
83
+ : undefined,
79
84
  runOptions: {
80
- environment: "deployed",
85
+ environment: "standalone",
81
86
  headless,
82
87
  proxy,
83
88
  },
@@ -87,8 +92,8 @@ export async function runApi({
87
92
  filePath: getTraceFilePath(runId, attemptNumber),
88
93
  }
89
94
  : { enabled: false },
90
- functionsToken,
91
95
  abortSignal: abortController.signal,
96
+ importFunction: importModule,
92
97
  }),
93
98
  initialTimeout: requestTimeout,
94
99
  abortController,
@@ -6,52 +6,42 @@ import { getExecutionContext } from "@intuned/runtime";
6
6
  import { app } from "./app";
7
7
  import { RUN_ID_HEADER } from "./headers";
8
8
  import { ShutdownController } from "./shutdown";
9
- import { registerApiEndpoints } from "./api";
10
- import { runJobsLoop } from "./jobs";
11
- import { isJobRunMachine } from "./utils";
12
9
 
13
- void main();
10
+ const port = process.env.PORT ? parseInt(process.env.PORT) : 4000;
14
11
 
15
- async function main() {
16
- const port = process.env.PORT ? parseInt(process.env.PORT) : 4000;
12
+ initializeAppInsights();
17
13
 
18
- initializeAppInsights();
19
-
20
- app.use((req, res, next) => {
21
- // Cleanup after the response is sent
22
- res.on("finish", () => {
23
- console.log("finished", req.headers[RUN_ID_HEADER]);
24
- void ShutdownController.instance.checkForShutdown();
25
- });
26
-
27
- next();
28
- });
29
-
30
- registerApiEndpoints();
31
- if (isJobRunMachine()) {
32
- console.log("Running in job v3 mode");
33
- void runJobsLoop();
34
- }
35
-
36
- const server = app.listen(port, () => {
37
- // when deployed on flyio, the server will be turned on and
38
- // will shutdown after the specified time in TIME_TO_SHUTDOWN env variable
39
- ShutdownController.initialize(server);
14
+ app.use((req, res, next) => {
15
+ // Cleanup after the response is sent
16
+ res.on("finish", () => {
17
+ console.log("finished", req.headers[RUN_ID_HEADER]);
40
18
  void ShutdownController.instance.checkForShutdown();
41
- console.log(`Server is running on port ${port}`);
42
19
  });
43
20
 
44
- process.on("unhandledRejection", (reason, promise) => {
45
- const telemetryClient = getTelemetryClient();
46
- console.error("Unhandled Rejection at:", promise, "reason:", reason);
47
- const context = getExecutionContext();
48
- telemetryClient?.trackEvent({
49
- name: "UNHANDLED_REJECTION",
50
- properties: {
51
- runId: context?.runId,
52
- promise,
53
- reason,
54
- },
55
- });
21
+ next();
22
+ });
23
+
24
+ export * from "./api";
25
+ export * from "./jobs";
26
+
27
+ const server = app.listen(port, () => {
28
+ // when deployed on flyio, the server will be turned on and
29
+ // will shutdown after the specified time in TIME_TO_SHUTDOWN env variable
30
+ ShutdownController.initialize(server);
31
+ void ShutdownController.instance.checkForShutdown();
32
+ console.log(`Server is running on port ${port}`);
33
+ });
34
+
35
+ process.on("unhandledRejection", (reason, promise) => {
36
+ const telemetryClient = getTelemetryClient();
37
+ console.error("Unhandled Rejection at:", promise, "reason:", reason);
38
+ const context = getExecutionContext();
39
+ telemetryClient?.trackEvent({
40
+ name: "UNHANDLED_REJECTION",
41
+ properties: {
42
+ runId: context?.runId,
43
+ promise,
44
+ reason,
45
+ },
56
46
  });
57
- }
47
+ });
@@ -6,7 +6,13 @@ import {
6
6
  RUN_ID_HEADER,
7
7
  SHOULD_SHUTDOWN_HEADER,
8
8
  } from "./headers";
9
- import { getErrorResponse, isHeadless, ProxyConfig, proxyToUrl } from "./utils";
9
+ import {
10
+ getErrorResponse,
11
+ isHeadless,
12
+ isJobRunMachine,
13
+ ProxyConfig,
14
+ proxyToUrl,
15
+ } from "./utils";
10
16
  import {
11
17
  callBackendFunctionWithToken,
12
18
  backendFunctionsTokenManager,
@@ -26,6 +32,11 @@ type JobPayload = {
26
32
  traceSignedUrl?: string;
27
33
  };
28
34
 
35
+ if (isJobRunMachine()) {
36
+ console.log("Running in job v3 mode");
37
+ void jobsV3();
38
+ }
39
+
29
40
  async function runApiInContext(
30
41
  jobPayload: JobPayload
31
42
  ): Promise<Awaited<ReturnType<typeof runApi>>> {
@@ -72,7 +83,7 @@ async function runApiInContext(
72
83
  }
73
84
  }
74
85
 
75
- export async function runJobsLoop() {
86
+ async function jobsV3() {
76
87
  await reportReady();
77
88
  const initialDelay = 1000;
78
89
  let delay = initialDelay;