@shipfox/api-workflows 7.1.0 → 9.0.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.
- package/.turbo/turbo-build.log +4 -4
- package/CHANGELOG.md +80 -0
- package/dist/core/agent-defaults.d.ts +2 -1
- package/dist/core/agent-defaults.d.ts.map +1 -1
- package/dist/core/agent-defaults.js.map +1 -1
- package/dist/core/agent-tools.d.ts +5 -2
- package/dist/core/agent-tools.d.ts.map +1 -1
- package/dist/core/agent-tools.js.map +1 -1
- package/dist/core/checkout.d.ts +2 -2
- package/dist/core/checkout.d.ts.map +1 -1
- package/dist/core/checkout.js.map +1 -1
- package/dist/core/entities/step.d.ts +2 -1
- package/dist/core/entities/step.d.ts.map +1 -1
- package/dist/core/entities/step.js.map +1 -1
- package/dist/core/errors.d.ts +0 -4
- package/dist/core/errors.d.ts.map +1 -1
- package/dist/core/errors.js +0 -6
- package/dist/core/errors.js.map +1 -1
- package/dist/core/job-execution.d.ts +0 -2
- package/dist/core/job-execution.d.ts.map +1 -1
- package/dist/core/job-execution.js +3 -7
- package/dist/core/job-execution.js.map +1 -1
- package/dist/core/run-workflow.d.ts +2 -2
- package/dist/core/run-workflow.d.ts.map +1 -1
- package/dist/core/run-workflow.js.map +1 -1
- package/dist/core/step-config/agent.d.ts +1 -1
- package/dist/core/step-config/agent.d.ts.map +1 -1
- package/dist/core/step-config/agent.js.map +1 -1
- package/dist/db/job-listeners.d.ts +2 -2
- package/dist/db/job-listeners.d.ts.map +1 -1
- package/dist/db/job-listeners.js.map +1 -1
- package/dist/db/workflow-runs/job-executions.d.ts +0 -5
- package/dist/db/workflow-runs/job-executions.d.ts.map +1 -1
- package/dist/db/workflow-runs/job-executions.js +0 -7
- package/dist/db/workflow-runs/job-executions.js.map +1 -1
- package/dist/db/workflow-runs/run-create.d.ts +2 -2
- package/dist/db/workflow-runs/run-create.d.ts.map +1 -1
- package/dist/db/workflow-runs/run-create.js.map +1 -1
- package/dist/db/workflow-runs.d.ts +1 -1
- package/dist/db/workflow-runs.d.ts.map +1 -1
- package/dist/db/workflow-runs.js +1 -1
- package/dist/db/workflow-runs.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/presentation/inter-module.d.ts +2 -2
- package/dist/presentation/inter-module.d.ts.map +1 -1
- package/dist/presentation/inter-module.js +2 -1
- package/dist/presentation/inter-module.js.map +1 -1
- package/dist/presentation/routes/cancel-run.d.ts +1 -1
- package/dist/presentation/routes/cancel-run.d.ts.map +1 -1
- package/dist/presentation/routes/cancel-run.js.map +1 -1
- package/dist/presentation/routes/checkout-token.d.ts +2 -2
- package/dist/presentation/routes/checkout-token.d.ts.map +1 -1
- package/dist/presentation/routes/checkout-token.js +1 -1
- package/dist/presentation/routes/checkout-token.js.map +1 -1
- package/dist/presentation/routes/get-run-aggregates.d.ts +1 -1
- package/dist/presentation/routes/get-run-aggregates.d.ts.map +1 -1
- package/dist/presentation/routes/get-run-aggregates.js.map +1 -1
- package/dist/presentation/routes/get-run.d.ts +1 -1
- package/dist/presentation/routes/get-run.d.ts.map +1 -1
- package/dist/presentation/routes/get-run.js.map +1 -1
- package/dist/presentation/routes/index.d.ts +2 -2
- package/dist/presentation/routes/index.d.ts.map +1 -1
- package/dist/presentation/routes/index.js.map +1 -1
- package/dist/presentation/routes/list-run-attempts.d.ts +1 -1
- package/dist/presentation/routes/list-run-attempts.d.ts.map +1 -1
- package/dist/presentation/routes/list-run-attempts.js.map +1 -1
- package/dist/presentation/routes/list-runs.d.ts +1 -1
- package/dist/presentation/routes/list-runs.d.ts.map +1 -1
- package/dist/presentation/routes/list-runs.js.map +1 -1
- package/dist/presentation/routes/next-step.d.ts.map +1 -1
- package/dist/presentation/routes/next-step.js +11 -8
- package/dist/presentation/routes/next-step.js.map +1 -1
- package/dist/presentation/routes/project-access.d.ts +1 -1
- package/dist/presentation/routes/project-access.d.ts.map +1 -1
- package/dist/presentation/routes/project-access.js.map +1 -1
- package/dist/presentation/routes/require-accessible-run.d.ts +1 -1
- package/dist/presentation/routes/require-accessible-run.d.ts.map +1 -1
- package/dist/presentation/routes/require-accessible-run.js.map +1 -1
- package/dist/presentation/routes/rerun-run.d.ts +1 -1
- package/dist/presentation/routes/rerun-run.d.ts.map +1 -1
- package/dist/presentation/routes/rerun-run.js.map +1 -1
- package/dist/temporal/activities/index.d.ts +2 -2
- package/dist/temporal/activities/index.d.ts.map +1 -1
- package/dist/temporal/activities/index.js.map +1 -1
- package/dist/temporal/activities/orchestration-activities.d.ts +2 -2
- package/dist/temporal/activities/orchestration-activities.d.ts.map +1 -1
- package/dist/temporal/activities/orchestration-activities.js.map +1 -1
- package/dist/tsconfig.test.tsbuildinfo +1 -1
- package/package.json +26 -28
- package/src/core/agent-defaults.ts +2 -1
- package/src/core/agent-tool-capability-warning.test.ts +26 -56
- package/src/core/agent-tools.ts +9 -7
- package/src/core/checkout.test.ts +2 -2
- package/src/core/checkout.ts +2 -2
- package/src/core/entities/step.ts +1 -2
- package/src/core/errors.ts +0 -7
- package/src/core/job-execution.ts +3 -10
- package/src/core/run-workflow.test.ts +22 -55
- package/src/core/run-workflow.ts +2 -2
- package/src/core/step-config/agent.ts +1 -1
- package/src/core/step-config/materialize-job-execution-steps.test.ts +1 -2
- package/src/core/step-config/materialize-workflow-model.test.ts +10 -13
- package/src/db/job-listeners.ts +2 -2
- package/src/db/workflow-runs/job-executions.ts +0 -21
- package/src/db/workflow-runs/run-create.test.ts +30 -23
- package/src/db/workflow-runs/run-create.ts +2 -2
- package/src/db/workflow-runs.ts +0 -1
- package/src/index.ts +3 -3
- package/src/presentation/dto/checkout-token.test.ts +7 -1
- package/src/presentation/inter-module.ts +4 -7
- package/src/presentation/routes/agent-runtime-config.test.ts +40 -132
- package/src/presentation/routes/cancel-run.test.ts +1 -1
- package/src/presentation/routes/cancel-run.ts +1 -1
- package/src/presentation/routes/checkout-token.test.ts +4 -37
- package/src/presentation/routes/checkout-token.ts +2 -2
- package/src/presentation/routes/get-run-aggregates.test.ts +1 -1
- package/src/presentation/routes/get-run-aggregates.ts +1 -1
- package/src/presentation/routes/get-run.test.ts +1 -1
- package/src/presentation/routes/get-run.ts +1 -1
- package/src/presentation/routes/get-step-secrets.test.ts +2 -2
- package/src/presentation/routes/index.test.ts +3 -3
- package/src/presentation/routes/index.ts +2 -2
- package/src/presentation/routes/list-run-attempts.test.ts +1 -1
- package/src/presentation/routes/list-run-attempts.ts +1 -1
- package/src/presentation/routes/list-runs.test.ts +1 -1
- package/src/presentation/routes/list-runs.ts +1 -1
- package/src/presentation/routes/next-step.test.ts +27 -69
- package/src/presentation/routes/next-step.ts +9 -5
- package/src/presentation/routes/project-access.ts +1 -1
- package/src/presentation/routes/report-step.test.ts +2 -3
- package/src/presentation/routes/require-accessible-run.ts +1 -1
- package/src/presentation/routes/rerun-run.test.ts +1 -1
- package/src/presentation/routes/rerun-run.ts +1 -1
- package/src/temporal/activities/index.ts +2 -2
- package/src/temporal/activities/orchestration-activities.ts +2 -2
- package/test/factories/workflow-model.ts +3 -1
- package/test/fixtures/active-lease-token.ts +5 -32
- package/test/fixtures/agent-inter-module.ts +32 -1
- package/test/fixtures/auth-inter-module.ts +2 -13
- package/test/fixtures/lease-token.ts +43 -29
- package/test/fixtures/projects-inter-module.ts +1 -1
- package/test/fixtures/runners-inter-module.ts +40 -48
- package/test/globalSetup.ts +0 -38
- package/test/setup.ts +2 -0
- package/tsconfig.build.tsbuildinfo +1 -1
- package/dist/db/runner-lease-table.d.ts +0 -469
- package/dist/db/runner-lease-table.d.ts.map +0 -1
- package/dist/db/runner-lease-table.js +0 -43
- package/dist/db/runner-lease-table.js.map +0 -1
- package/src/db/runner-lease-table.ts +0 -39
|
@@ -1,52 +1,44 @@
|
|
|
1
|
-
import {runnerToolCapabilitiesSchema} from '@shipfox/api-runners-dto';
|
|
2
1
|
import type {RunnersInterModuleClient} from '@shipfox/api-runners-dto/inter-module';
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
|
|
3
|
+
const activeLeases = new Set<string>();
|
|
4
|
+
const toolCapabilities = new Map<
|
|
5
|
+
string,
|
|
6
|
+
Awaited<ReturnType<RunnersInterModuleClient['getEffectiveRunnerToolCapabilities']>>
|
|
7
|
+
>();
|
|
8
|
+
|
|
9
|
+
function leaseKey(params: {
|
|
10
|
+
jobId: string;
|
|
11
|
+
jobExecutionId: string;
|
|
12
|
+
runnerSessionId: string;
|
|
13
|
+
}): string {
|
|
14
|
+
return `${params.jobId}:${params.jobExecutionId}:${params.runnerSessionId}`;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export function registerActiveRunnerLease(params: {
|
|
18
|
+
jobId: string;
|
|
19
|
+
jobExecutionId: string;
|
|
20
|
+
runnerSessionId: string;
|
|
21
|
+
}): void {
|
|
22
|
+
activeLeases.add(leaseKey(params));
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export function setRunnerToolCapabilities(
|
|
26
|
+
runnerSessionId: string,
|
|
27
|
+
capabilities: Awaited<ReturnType<RunnersInterModuleClient['getEffectiveRunnerToolCapabilities']>>,
|
|
28
|
+
): void {
|
|
29
|
+
toolCapabilities.set(runnerSessionId, capabilities);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export function resetRunnersTestClient(): void {
|
|
33
|
+
activeLeases.clear();
|
|
34
|
+
toolCapabilities.clear();
|
|
35
|
+
}
|
|
5
36
|
|
|
6
37
|
export const runnersTestClient: RunnersInterModuleClient = {
|
|
7
|
-
enqueueJobExecution() {
|
|
8
|
-
|
|
9
|
-
},
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
cancelJobs() {
|
|
14
|
-
return Promise.resolve({});
|
|
15
|
-
},
|
|
16
|
-
async getLeaseState({jobId, jobExecutionId, runnerSessionId}) {
|
|
17
|
-
const result = await db().execute<{active: boolean}>(sql`
|
|
18
|
-
SELECT EXISTS(
|
|
19
|
-
SELECT 1
|
|
20
|
-
FROM runners_running_jobs
|
|
21
|
-
WHERE job_id = ${jobId}
|
|
22
|
-
AND job_execution_id = ${jobExecutionId}
|
|
23
|
-
AND runner_session_id = ${runnerSessionId}
|
|
24
|
-
) AS active
|
|
25
|
-
`);
|
|
26
|
-
return {active: result.rows[0]?.active ?? false};
|
|
27
|
-
},
|
|
28
|
-
async getEffectiveRunnerToolCapabilities({runnerSessionId}) {
|
|
29
|
-
const result = await db().execute<{
|
|
30
|
-
toolCapabilities: unknown;
|
|
31
|
-
toolCapabilitiesReportedAt: Date | string | null;
|
|
32
|
-
}>(sql`
|
|
33
|
-
SELECT
|
|
34
|
-
tool_capabilities AS "toolCapabilities",
|
|
35
|
-
tool_capabilities_reported_at AS "toolCapabilitiesReportedAt"
|
|
36
|
-
FROM runners_runner_sessions
|
|
37
|
-
WHERE id = ${runnerSessionId}
|
|
38
|
-
`);
|
|
39
|
-
const row = result.rows[0];
|
|
40
|
-
const reportedAt = row?.toolCapabilitiesReportedAt;
|
|
41
|
-
const reportFresh =
|
|
42
|
-
reportedAt !== null &&
|
|
43
|
-
reportedAt !== undefined &&
|
|
44
|
-
Date.now() - new Date(reportedAt).getTime() <= 60_000;
|
|
45
|
-
return {
|
|
46
|
-
capabilities: reportFresh
|
|
47
|
-
? runnerToolCapabilitiesSchema.parse(row?.toolCapabilities ?? {harnesses: {}})
|
|
48
|
-
: {harnesses: {}},
|
|
49
|
-
reportFresh,
|
|
50
|
-
};
|
|
51
|
-
},
|
|
38
|
+
enqueueJobExecution: async () => ({}),
|
|
39
|
+
releaseJobExecution: async () => ({}),
|
|
40
|
+
cancelJobs: async () => ({}),
|
|
41
|
+
getLeaseState: async (params) => ({active: activeLeases.has(leaseKey(params))}),
|
|
42
|
+
getEffectiveRunnerToolCapabilities: async ({runnerSessionId}) =>
|
|
43
|
+
toolCapabilities.get(runnerSessionId) ?? {capabilities: {harnesses: {}}, reportFresh: false},
|
|
52
44
|
};
|
package/test/globalSetup.ts
CHANGED
|
@@ -1,8 +1,4 @@
|
|
|
1
1
|
import './env.js';
|
|
2
|
-
import {annotationsModule} from '@shipfox/annotations';
|
|
3
|
-
import {createAgentModule} from '@shipfox/api-agent';
|
|
4
|
-
import type {AuthInterModuleClient} from '@shipfox/api-auth-dto/inter-module';
|
|
5
|
-
import {createRunnersModule} from '@shipfox/api-runners';
|
|
6
2
|
import {runMigrations} from '@shipfox/node-drizzle';
|
|
7
3
|
import {closePostgresClient, createPostgresClient} from '@shipfox/node-postgres';
|
|
8
4
|
import {sql} from 'drizzle-orm';
|
|
@@ -10,44 +6,10 @@ import {closeDb, db, migrationsPath} from '#db/index.js';
|
|
|
10
6
|
|
|
11
7
|
export async function setup() {
|
|
12
8
|
createPostgresClient();
|
|
13
|
-
const runnersModule = createRunnersModule({auth: {} as AuthInterModuleClient});
|
|
14
|
-
|
|
15
|
-
const agentModule = createAgentModule({
|
|
16
|
-
secrets: {
|
|
17
|
-
deleteSecrets: async () => ({deleted: 0}),
|
|
18
|
-
getSecretsByNamespace: async () => ({values: {}}),
|
|
19
|
-
setSecrets: async () => ({}),
|
|
20
|
-
},
|
|
21
|
-
});
|
|
22
|
-
if (!agentModule.database || Array.isArray(agentModule.database)) {
|
|
23
|
-
throw new Error('Agent module database is not configured');
|
|
24
|
-
}
|
|
25
|
-
await runMigrations(
|
|
26
|
-
agentModule.database.db(),
|
|
27
|
-
agentModule.database.migrationsPath,
|
|
28
|
-
'__drizzle_migrations_agent',
|
|
29
|
-
);
|
|
30
|
-
if (!runnersModule.database || Array.isArray(runnersModule.database)) {
|
|
31
|
-
throw new Error('Runners module database is not configured');
|
|
32
|
-
}
|
|
33
|
-
await runMigrations(
|
|
34
|
-
runnersModule.database.db(),
|
|
35
|
-
runnersModule.database.migrationsPath,
|
|
36
|
-
'__drizzle_migrations_runners',
|
|
37
|
-
);
|
|
38
|
-
if (!annotationsModule.database || Array.isArray(annotationsModule.database)) {
|
|
39
|
-
throw new Error('Annotations module database is not configured');
|
|
40
|
-
}
|
|
41
|
-
await runMigrations(
|
|
42
|
-
annotationsModule.database.db(),
|
|
43
|
-
annotationsModule.database.migrationsPath,
|
|
44
|
-
'__drizzle_migrations_annotations',
|
|
45
|
-
);
|
|
46
9
|
await runMigrations(db(), migrationsPath, '__drizzle_migrations_workflows');
|
|
47
10
|
await db().execute(sql`TRUNCATE workflows_workflow_runs CASCADE`);
|
|
48
11
|
await db().execute(sql`TRUNCATE workflows_job_listener_events CASCADE`);
|
|
49
12
|
await db().execute(sql`TRUNCATE workflows_outbox CASCADE`);
|
|
50
|
-
await db().execute(sql`TRUNCATE annotations_annotations CASCADE`);
|
|
51
13
|
|
|
52
14
|
closeDb();
|
|
53
15
|
await closePostgresClient();
|
package/test/setup.ts
CHANGED
|
@@ -2,6 +2,7 @@ import './env.js';
|
|
|
2
2
|
import {closePostgresClient, createPostgresClient} from '@shipfox/node-postgres';
|
|
3
3
|
import {afterAll, afterEach, beforeAll, vi} from '@shipfox/vitest/vi';
|
|
4
4
|
import {closeDb} from '#db/index.js';
|
|
5
|
+
import {resetRunnersTestClient} from '#test/fixtures/runners-inter-module.js';
|
|
5
6
|
|
|
6
7
|
beforeAll(() => {
|
|
7
8
|
createPostgresClient();
|
|
@@ -9,6 +10,7 @@ beforeAll(() => {
|
|
|
9
10
|
|
|
10
11
|
afterEach(() => {
|
|
11
12
|
vi.restoreAllMocks();
|
|
13
|
+
resetRunnersTestClient();
|
|
12
14
|
});
|
|
13
15
|
|
|
14
16
|
afterAll(async () => {
|