@cat-factory/worker 0.174.1 → 0.176.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/dist/infrastructure/config/execution.d.ts +1 -1
- package/dist/infrastructure/config/execution.d.ts.map +1 -1
- package/dist/infrastructure/config/execution.js +12 -3
- package/dist/infrastructure/config/execution.js.map +1 -1
- package/dist/infrastructure/config/gitlab.d.ts +10 -5
- package/dist/infrastructure/config/gitlab.d.ts.map +1 -1
- package/dist/infrastructure/config/gitlab.js +10 -7
- package/dist/infrastructure/config/gitlab.js.map +1 -1
- package/dist/infrastructure/container-assembly.d.ts.map +1 -1
- package/dist/infrastructure/container-assembly.js +5 -1
- package/dist/infrastructure/container-assembly.js.map +1 -1
- package/dist/infrastructure/container-documents-deps.d.ts.map +1 -1
- package/dist/infrastructure/container-documents-deps.js +9 -6
- package/dist/infrastructure/container-documents-deps.js.map +1 -1
- package/dist/infrastructure/container-tracker-deps.d.ts.map +1 -1
- package/dist/infrastructure/container-tracker-deps.js +7 -7
- package/dist/infrastructure/container-tracker-deps.js.map +1 -1
- package/dist/infrastructure/container.js +3 -3
- package/dist/infrastructure/container.js.map +1 -1
- package/dist/infrastructure/containers/CloudflareContainerTransport.d.ts +15 -1
- package/dist/infrastructure/containers/CloudflareContainerTransport.d.ts.map +1 -1
- package/dist/infrastructure/containers/CloudflareContainerTransport.js +55 -16
- package/dist/infrastructure/containers/CloudflareContainerTransport.js.map +1 -1
- package/dist/infrastructure/containers/DeployContainer.d.ts +2 -20
- package/dist/infrastructure/containers/DeployContainer.d.ts.map +1 -1
- package/dist/infrastructure/containers/DeployContainer.js +7 -56
- package/dist/infrastructure/containers/DeployContainer.js.map +1 -1
- package/dist/infrastructure/containers/ExecutionContainer.d.ts +2 -51
- package/dist/infrastructure/containers/ExecutionContainer.d.ts.map +1 -1
- package/dist/infrastructure/containers/ExecutionContainer.js +9 -93
- package/dist/infrastructure/containers/ExecutionContainer.js.map +1 -1
- package/dist/infrastructure/containers/RunContainer.d.ts +98 -0
- package/dist/infrastructure/containers/RunContainer.d.ts.map +1 -0
- package/dist/infrastructure/containers/RunContainer.js +164 -0
- package/dist/infrastructure/containers/RunContainer.js.map +1 -0
- package/dist/infrastructure/containers/stopCause.d.ts +105 -0
- package/dist/infrastructure/containers/stopCause.d.ts.map +1 -0
- package/dist/infrastructure/containers/stopCause.js +108 -0
- package/dist/infrastructure/containers/stopCause.js.map +1 -0
- package/dist/infrastructure/env.d.ts +10 -0
- package/dist/infrastructure/env.d.ts.map +1 -1
- package/dist/infrastructure/env.js.map +1 -1
- package/dist/infrastructure/github-deps.js +1 -1
- package/dist/infrastructure/github-deps.js.map +1 -1
- package/dist/infrastructure/repositories/D1BinaryArtifactMetadataStore.d.ts +3 -1
- package/dist/infrastructure/repositories/D1BinaryArtifactMetadataStore.d.ts.map +1 -1
- package/dist/infrastructure/repositories/D1BinaryArtifactMetadataStore.js +38 -5
- package/dist/infrastructure/repositories/D1BinaryArtifactMetadataStore.js.map +1 -1
- package/dist/infrastructure/repositories/D1DocumentConnectionRepository.d.ts +11 -14
- package/dist/infrastructure/repositories/D1DocumentConnectionRepository.d.ts.map +1 -1
- package/dist/infrastructure/repositories/D1DocumentConnectionRepository.js +11 -38
- package/dist/infrastructure/repositories/D1DocumentConnectionRepository.js.map +1 -1
- package/dist/infrastructure/repositories/D1DocumentRepository.d.ts.map +1 -1
- package/dist/infrastructure/repositories/D1DocumentRepository.js +5 -3
- package/dist/infrastructure/repositories/D1DocumentRepository.js.map +1 -1
- package/dist/infrastructure/repositories/D1TaskConnectionRepository.d.ts +8 -14
- package/dist/infrastructure/repositories/D1TaskConnectionRepository.d.ts.map +1 -1
- package/dist/infrastructure/repositories/D1TaskConnectionRepository.js +8 -38
- package/dist/infrastructure/repositories/D1TaskConnectionRepository.js.map +1 -1
- package/dist/infrastructure/tasks-deps.d.ts.map +1 -1
- package/dist/infrastructure/tasks-deps.js +10 -7
- package/dist/infrastructure/tasks-deps.js.map +1 -1
- package/dist/infrastructure/vcsConnect.d.ts.map +1 -1
- package/dist/infrastructure/vcsConnect.js +5 -2
- package/dist/infrastructure/vcsConnect.js.map +1 -1
- package/dist/infrastructure/workflows/ExecutionWorkflow.d.ts.map +1 -1
- package/dist/infrastructure/workflows/ExecutionWorkflow.js +17 -8
- package/dist/infrastructure/workflows/ExecutionWorkflow.js.map +1 -1
- package/migrations/0087_document_renders.sql +28 -0
- package/package.json +18 -18
|
@@ -1,27 +1,24 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { DocumentConnectionRepository, DocumentSourceKind, SealedDocumentConnectionRecord } from '@cat-factory/kernel';
|
|
2
2
|
import type { D1Database } from '@cloudflare/workers-types';
|
|
3
3
|
/**
|
|
4
4
|
* D1-backed store of workspace → document-source connections (migration 0012).
|
|
5
5
|
*
|
|
6
|
-
* Source credentials
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
6
|
+
* Source credentials are third-party secrets and cross this repository as the AES-256-GCM
|
|
7
|
+
* ENVELOPE they are stored as: the seal is the row's value, not an encoding this class hides.
|
|
8
|
+
* Opening it belongs to `createDocumentConnectionStore` (`@cat-factory/integrations`), which is
|
|
9
|
+
* what lets a deployment holding no key for these rows — a mothership-mode node — still read them
|
|
10
|
+
* (it names the row over `/internal/secrets/unseal`). A repository that decrypted could only be
|
|
11
|
+
* called by a key-holder, which is precisely what kept this integration off the persistence RPC.
|
|
11
12
|
*/
|
|
12
13
|
export declare class D1DocumentConnectionRepository implements DocumentConnectionRepository {
|
|
13
14
|
private readonly db;
|
|
14
|
-
|
|
15
|
-
constructor({ db, cipher }: {
|
|
15
|
+
constructor({ db }: {
|
|
16
16
|
db: D1Database;
|
|
17
|
-
cipher: SecretCipher;
|
|
18
17
|
});
|
|
19
|
-
/** Decode the stored credential blob, decrypting the envelope when present. */
|
|
20
|
-
private decodeCredentials;
|
|
21
18
|
private rowToRecord;
|
|
22
|
-
getByWorkspace(workspaceId: string, source: DocumentSourceKind): Promise<
|
|
23
|
-
listByWorkspace(workspaceId: string): Promise<
|
|
24
|
-
upsert(record:
|
|
19
|
+
getByWorkspace(workspaceId: string, source: DocumentSourceKind): Promise<SealedDocumentConnectionRecord | null>;
|
|
20
|
+
listByWorkspace(workspaceId: string): Promise<SealedDocumentConnectionRecord[]>;
|
|
21
|
+
upsert(record: SealedDocumentConnectionRecord): Promise<void>;
|
|
25
22
|
softDelete(workspaceId: string, source: DocumentSourceKind, at: number): Promise<void>;
|
|
26
23
|
}
|
|
27
24
|
//# sourceMappingURL=D1DocumentConnectionRepository.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"D1DocumentConnectionRepository.d.ts","sourceRoot":"","sources":["../../../src/infrastructure/repositories/D1DocumentConnectionRepository.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,
|
|
1
|
+
{"version":3,"file":"D1DocumentConnectionRepository.d.ts","sourceRoot":"","sources":["../../../src/infrastructure/repositories/D1DocumentConnectionRepository.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,4BAA4B,EAC5B,kBAAkB,EAClB,8BAA8B,EAC/B,MAAM,qBAAqB,CAAA;AAC5B,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAA;AAW3D;;;;;;;;;GASG;AACH,qBAAa,8BAA+B,YAAW,4BAA4B;IACjF,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAY;IAE/B,YAAY,EAAE,EAAE,EAAE,EAAE;QAAE,EAAE,EAAE,UAAU,CAAA;KAAE,EAErC;IAED,OAAO,CAAC,WAAW;IAWb,cAAc,CAClB,WAAW,EAAE,MAAM,EACnB,MAAM,EAAE,kBAAkB,GACzB,OAAO,CAAC,8BAA8B,GAAG,IAAI,CAAC,CAQhD;IAEK,eAAe,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,8BAA8B,EAAE,CAAC,CAQpF;IAEK,MAAM,CAAC,MAAM,EAAE,8BAA8B,GAAG,OAAO,CAAC,IAAI,CAAC,CAsBlE;IAEK,UAAU,CAAC,WAAW,EAAE,MAAM,EAAE,MAAM,EAAE,kBAAkB,EAAE,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAO3F;CACF"}
|
|
@@ -1,49 +1,23 @@
|
|
|
1
|
-
function parseCredentials(json) {
|
|
2
|
-
try {
|
|
3
|
-
const parsed = JSON.parse(json);
|
|
4
|
-
if (parsed && typeof parsed === 'object')
|
|
5
|
-
return parsed;
|
|
6
|
-
}
|
|
7
|
-
catch {
|
|
8
|
-
// A malformed bag is treated as empty; the import path then fails closed.
|
|
9
|
-
}
|
|
10
|
-
return {};
|
|
11
|
-
}
|
|
12
1
|
/**
|
|
13
2
|
* D1-backed store of workspace → document-source connections (migration 0012).
|
|
14
3
|
*
|
|
15
|
-
* Source credentials
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
4
|
+
* Source credentials are third-party secrets and cross this repository as the AES-256-GCM
|
|
5
|
+
* ENVELOPE they are stored as: the seal is the row's value, not an encoding this class hides.
|
|
6
|
+
* Opening it belongs to `createDocumentConnectionStore` (`@cat-factory/integrations`), which is
|
|
7
|
+
* what lets a deployment holding no key for these rows — a mothership-mode node — still read them
|
|
8
|
+
* (it names the row over `/internal/secrets/unseal`). A repository that decrypted could only be
|
|
9
|
+
* called by a key-holder, which is precisely what kept this integration off the persistence RPC.
|
|
20
10
|
*/
|
|
21
11
|
export class D1DocumentConnectionRepository {
|
|
22
12
|
db;
|
|
23
|
-
|
|
24
|
-
constructor({ db, cipher }) {
|
|
13
|
+
constructor({ db }) {
|
|
25
14
|
this.db = db;
|
|
26
|
-
this.cipher = cipher;
|
|
27
|
-
}
|
|
28
|
-
/** Decode the stored credential blob, decrypting the envelope when present. */
|
|
29
|
-
async decodeCredentials(stored) {
|
|
30
|
-
// Legacy plaintext rows (written before encryption) lack the envelope tag.
|
|
31
|
-
if (!stored.startsWith('v1.'))
|
|
32
|
-
return parseCredentials(stored);
|
|
33
|
-
try {
|
|
34
|
-
return parseCredentials(await this.cipher.decrypt(stored));
|
|
35
|
-
}
|
|
36
|
-
catch {
|
|
37
|
-
// Wrong key / corrupt envelope: fail closed with an empty bag so the
|
|
38
|
-
// import path errors rather than leaking a decrypt exception.
|
|
39
|
-
return {};
|
|
40
|
-
}
|
|
41
15
|
}
|
|
42
|
-
|
|
16
|
+
rowToRecord(row) {
|
|
43
17
|
return {
|
|
44
18
|
workspaceId: row.workspace_id,
|
|
45
19
|
source: row.source,
|
|
46
|
-
|
|
20
|
+
credentialsCipher: row.credentials,
|
|
47
21
|
label: row.label,
|
|
48
22
|
createdAt: row.created_at,
|
|
49
23
|
deletedAt: row.deleted_at,
|
|
@@ -61,7 +35,7 @@ export class D1DocumentConnectionRepository {
|
|
|
61
35
|
.prepare('SELECT * FROM document_connections WHERE workspace_id = ? AND deleted_at IS NULL ORDER BY created_at DESC')
|
|
62
36
|
.bind(workspaceId)
|
|
63
37
|
.all();
|
|
64
|
-
return
|
|
38
|
+
return results.map((row) => this.rowToRecord(row));
|
|
65
39
|
}
|
|
66
40
|
async upsert(record) {
|
|
67
41
|
// A workspace has a single live connection per source: clear any prior
|
|
@@ -71,12 +45,11 @@ export class D1DocumentConnectionRepository {
|
|
|
71
45
|
.prepare('DELETE FROM document_connections WHERE workspace_id = ? AND source = ?')
|
|
72
46
|
.bind(record.workspaceId, record.source)
|
|
73
47
|
.run();
|
|
74
|
-
const credentials = await this.cipher.encrypt(JSON.stringify(record.credentials));
|
|
75
48
|
await this.db
|
|
76
49
|
.prepare(`INSERT INTO document_connections
|
|
77
50
|
(workspace_id, source, credentials, label, created_at, deleted_at)
|
|
78
51
|
VALUES (?, ?, ?, ?, ?, NULL)`)
|
|
79
|
-
.bind(record.workspaceId, record.source,
|
|
52
|
+
.bind(record.workspaceId, record.source, record.credentialsCipher, record.label, record.createdAt)
|
|
80
53
|
.run();
|
|
81
54
|
}
|
|
82
55
|
async softDelete(workspaceId, source, at) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"D1DocumentConnectionRepository.js","sourceRoot":"","sources":["../../../src/infrastructure/repositories/D1DocumentConnectionRepository.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"D1DocumentConnectionRepository.js","sourceRoot":"","sources":["../../../src/infrastructure/repositories/D1DocumentConnectionRepository.ts"],"names":[],"mappings":"AAgBA;;;;;;;;;GASG;AACH,MAAM,OAAO,8BAA8B;IACxB,EAAE,CAAY;IAE/B,YAAY,EAAE,EAAE,EAAsB;QACpC,IAAI,CAAC,EAAE,GAAG,EAAE,CAAA;IACd,CAAC;IAEO,WAAW,CAAC,GAA0B;QAC5C,OAAO;YACL,WAAW,EAAE,GAAG,CAAC,YAAY;YAC7B,MAAM,EAAE,GAAG,CAAC,MAA4B;YACxC,iBAAiB,EAAE,GAAG,CAAC,WAAW;YAClC,KAAK,EAAE,GAAG,CAAC,KAAK;YAChB,SAAS,EAAE,GAAG,CAAC,UAAU;YACzB,SAAS,EAAE,GAAG,CAAC,UAAU;SAC1B,CAAA;IACH,CAAC;IAED,KAAK,CAAC,cAAc,CAClB,WAAmB,EACnB,MAA0B;QAE1B,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,EAAE;aACtB,OAAO,CACN,iGAAiG,CAClG;aACA,IAAI,CAAC,WAAW,EAAE,MAAM,CAAC;aACzB,KAAK,EAAyB,CAAA;QACjC,OAAO,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAA;IAC3C,CAAC;IAED,KAAK,CAAC,eAAe,CAAC,WAAmB;QACvC,MAAM,EAAE,OAAO,EAAE,GAAG,MAAM,IAAI,CAAC,EAAE;aAC9B,OAAO,CACN,2GAA2G,CAC5G;aACA,IAAI,CAAC,WAAW,CAAC;aACjB,GAAG,EAAyB,CAAA;QAC/B,OAAO,OAAO,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,CAAA;IACpD,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,MAAsC;QACjD,uEAAuE;QACvE,uEAAuE;QACvE,qDAAqD;QACrD,MAAM,IAAI,CAAC,EAAE;aACV,OAAO,CAAC,wEAAwE,CAAC;aACjF,IAAI,CAAC,MAAM,CAAC,WAAW,EAAE,MAAM,CAAC,MAAM,CAAC;aACvC,GAAG,EAAE,CAAA;QACR,MAAM,IAAI,CAAC,EAAE;aACV,OAAO,CACN;;sCAE8B,CAC/B;aACA,IAAI,CACH,MAAM,CAAC,WAAW,EAClB,MAAM,CAAC,MAAM,EACb,MAAM,CAAC,iBAAiB,EACxB,MAAM,CAAC,KAAK,EACZ,MAAM,CAAC,SAAS,CACjB;aACA,GAAG,EAAE,CAAA;IACV,CAAC;IAED,KAAK,CAAC,UAAU,CAAC,WAAmB,EAAE,MAA0B,EAAE,EAAU;QAC1E,MAAM,IAAI,CAAC,EAAE;aACV,OAAO,CACN,6GAA6G,CAC9G;aACA,IAAI,CAAC,EAAE,EAAE,WAAW,EAAE,MAAM,CAAC;aAC7B,GAAG,EAAE,CAAA;IACV,CAAC;CACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"D1DocumentRepository.d.ts","sourceRoot":"","sources":["../../../src/infrastructure/repositories/D1DocumentRepository.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,OAAO,EACP,gBAAgB,EAChB,cAAc,EACd,cAAc,EACd,WAAW,
|
|
1
|
+
{"version":3,"file":"D1DocumentRepository.d.ts","sourceRoot":"","sources":["../../../src/infrastructure/repositories/D1DocumentRepository.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,OAAO,EACP,gBAAgB,EAChB,cAAc,EACd,cAAc,EACd,WAAW,EAEX,kBAAkB,EACnB,MAAM,qBAAqB,CAAA;AAG5B,OA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C,IAAI,CAAC,CAqBf;IAEK,WAAW,CACf,WAAW,EAAE,MAAM,EACnB,IAAI,EAAE,gBAAgB,EACtB,OAAO,EAAE,OAAO,GACf,OAAO,CAAC,cAAc,GAAG,IAAI,CAAC,CAQhC;IAEK,aAAa,CACjB,WAAW,EAAE,MAAM,EACnB,IAAI,EAAE,gBAAgB,EACtB,OAAO,EAAE,OAAO,GACf,OAAO,CAAC,cAAc,EAAE,CAAC,CAQ3B;IAEK,wBAAwB,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,EAAE,CAAC,CAQ7E;IAEK,OAAO,CACX,WAAW,EAAE,MAAM,EACnB,MAAM,EAAE,cAAc,EACtB,UAAU,EAAE,MAAM,EAClB,IAAI,EAAE,gBAAgB,EACtB,OAAO,EAAE,OAAO,GACf,OAAO,CAAC,IAAI,CAAC,CAOf;IAEK,SAAS,CAAC,WAAW,EAAE,MAAM,EAAE,MAAM,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAO9F;IAEK,gBAAgB,CACpB,WAAW,EAAE,MAAM,EACnB,IAAI,EAAE,gBAAgB,EACtB,OAAO,EAAE,OAAO,GACf,OAAO,CAAC,IAAI,CAAC,CAOf;CACF"}
|
|
@@ -27,6 +27,7 @@ function rowToRecord(row) {
|
|
|
27
27
|
body: row.body,
|
|
28
28
|
contentHash: row.content_hash ?? '',
|
|
29
29
|
sourceVersion: row.source_version,
|
|
30
|
+
renderStatus: row.render_status ?? null,
|
|
30
31
|
linkedBlockId: row.linked_block_id,
|
|
31
32
|
role: row.role ?? null,
|
|
32
33
|
docKind: row.doc_kind ?? null,
|
|
@@ -44,8 +45,8 @@ export class D1DocumentRepository {
|
|
|
44
45
|
await this.db
|
|
45
46
|
.prepare(`INSERT INTO documents
|
|
46
47
|
(workspace_id, source, external_id, title, url, excerpt, body,
|
|
47
|
-
content_hash, source_version, linked_block_id, synced_at, deleted_at)
|
|
48
|
-
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, NULL)
|
|
48
|
+
content_hash, source_version, render_status, linked_block_id, synced_at, deleted_at)
|
|
49
|
+
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, NULL)
|
|
49
50
|
ON CONFLICT (workspace_id, source, external_id) DO UPDATE SET
|
|
50
51
|
title = excluded.title,
|
|
51
52
|
url = excluded.url,
|
|
@@ -53,10 +54,11 @@ export class D1DocumentRepository {
|
|
|
53
54
|
body = excluded.body,
|
|
54
55
|
content_hash = excluded.content_hash,
|
|
55
56
|
source_version = excluded.source_version,
|
|
57
|
+
render_status = excluded.render_status,
|
|
56
58
|
linked_block_id = excluded.linked_block_id,
|
|
57
59
|
synced_at = excluded.synced_at,
|
|
58
60
|
deleted_at = NULL`)
|
|
59
|
-
.bind(record.workspaceId, record.source, record.externalId, record.title, record.url, record.excerpt, record.body, record.contentHash, record.sourceVersion, record.linkedBlockId, record.syncedAt)
|
|
61
|
+
.bind(record.workspaceId, record.source, record.externalId, record.title, record.url, record.excerpt, record.body, record.contentHash, record.sourceVersion, record.renderStatus, record.linkedBlockId, record.syncedAt)
|
|
60
62
|
.run();
|
|
61
63
|
}
|
|
62
64
|
async get(workspaceId, source, externalId) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"D1DocumentRepository.js","sourceRoot":"","sources":["../../../src/infrastructure/repositories/D1DocumentRepository.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"D1DocumentRepository.js","sourceRoot":"","sources":["../../../src/infrastructure/repositories/D1DocumentRepository.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAA;AACxD,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;AAqBpC;;;;GAIG;AACH,SAAS,iBAAiB,CAAC,IAA4B;IACrD,MAAM,QAAQ,GAAG,IAAI,GAAG,EAA4B,CAAA;IACpD,KAAK,MAAM,GAAG,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mB,EACnB,MAAsB,EACtB,UAAkB,EAClB,IAAsB,EACtB,OAAgB;QAEhB,MAAM,IAAI,CAAC,EAAE;aACV,OAAO,CACN,uGAAuG,CACxG;aACA,IAAI,CAAC,IAAI,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,UAAU,CAAC;aACpD,GAAG,EAAE,CAAA;IACV,CAAC;IAED,KAAK,CAAC,SAAS,CAAC,WAAmB,EAAE,MAAsB,EAAE,UAAkB;QAC7E,MAAM,IAAI,CAAC,EAAE;aACV,OAAO,CACN,6GAA6G,CAC9G;aACA,IAAI,CAAC,WAAW,EAAE,MAAM,EAAE,UAAU,CAAC;aACrC,GAAG,EAAE,CAAA;IACV,CAAC;IAED,KAAK,CAAC,gBAAgB,CACpB,WAAmB,EACnB,IAAsB,EACtB,OAAgB;QAEhB,MAAM,IAAI,CAAC,EAAE;aACV,OAAO,CACN,wGAAwG,CACzG;aACA,IAAI,CAAC,WAAW,EAAE,IAAI,EAAE,OAAO,CAAC;aAChC,GAAG,EAAE,CAAA;IACV,CAAC;CACF"}
|
|
@@ -1,27 +1,21 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { SealedTaskConnectionRecord, TaskConnectionRepository, TaskSourceKind } from '@cat-factory/kernel';
|
|
2
2
|
import type { D1Database } from '@cloudflare/workers-types';
|
|
3
3
|
/**
|
|
4
4
|
* D1-backed store of workspace → task-source connections (migration 0014).
|
|
5
5
|
*
|
|
6
|
-
* Source credentials (e.g. a Jira API token)
|
|
7
|
-
* are
|
|
8
|
-
*
|
|
9
|
-
* `credentials` column predates encryption (no `v1.` envelope) is still read as
|
|
10
|
-
* legacy plaintext JSON, then re-encrypted on the next write.
|
|
6
|
+
* Source credentials (e.g. a Jira API token) cross this repository as the AES-256-GCM ENVELOPE
|
|
7
|
+
* they are stored as; opening one belongs to `createTaskConnectionStore`
|
|
8
|
+
* (`@cat-factory/integrations`). Same shape, and the same reason, as its document-source sibling.
|
|
11
9
|
*/
|
|
12
10
|
export declare class D1TaskConnectionRepository implements TaskConnectionRepository {
|
|
13
11
|
private readonly db;
|
|
14
|
-
|
|
15
|
-
constructor({ db, cipher }: {
|
|
12
|
+
constructor({ db }: {
|
|
16
13
|
db: D1Database;
|
|
17
|
-
cipher: SecretCipher;
|
|
18
14
|
});
|
|
19
|
-
/** Decode the stored credential blob, decrypting the envelope when present. */
|
|
20
|
-
private decodeCredentials;
|
|
21
15
|
private rowToRecord;
|
|
22
|
-
getByWorkspace(workspaceId: string, source: TaskSourceKind): Promise<
|
|
23
|
-
listByWorkspace(workspaceId: string): Promise<
|
|
24
|
-
upsert(record:
|
|
16
|
+
getByWorkspace(workspaceId: string, source: TaskSourceKind): Promise<SealedTaskConnectionRecord | null>;
|
|
17
|
+
listByWorkspace(workspaceId: string): Promise<SealedTaskConnectionRecord[]>;
|
|
18
|
+
upsert(record: SealedTaskConnectionRecord): Promise<void>;
|
|
25
19
|
softDelete(workspaceId: string, source: TaskSourceKind, at: number): Promise<void>;
|
|
26
20
|
}
|
|
27
21
|
//# sourceMappingURL=D1TaskConnectionRepository.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"D1TaskConnectionRepository.d.ts","sourceRoot":"","sources":["../../../src/infrastructure/repositories/D1TaskConnectionRepository.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,
|
|
1
|
+
{"version":3,"file":"D1TaskConnectionRepository.d.ts","sourceRoot":"","sources":["../../../src/infrastructure/repositories/D1TaskConnectionRepository.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,0BAA0B,EAC1B,wBAAwB,EACxB,cAAc,EACf,MAAM,qBAAqB,CAAA;AAC5B,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAA;AAW3D;;;;;;GAMG;AACH,qBAAa,0BAA2B,YAAW,wBAAwB;IACzE,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAY;IAE/B,YAAY,EAAE,EAAE,EAAE,EAAE;QAAE,EAAE,EAAE,UAAU,CAAA;KAAE,EAErC;IAED,OAAO,CAAC,WAAW;IAWb,cAAc,CAClB,WAAW,EAAE,MAAM,EACnB,MAAM,EAAE,cAAc,GACrB,OAAO,CAAC,0BAA0B,GAAG,IAAI,CAAC,CAQ5C;IAEK,eAAe,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,0BAA0B,EAAE,CAAC,CAQhF;IAEK,MAAM,CAAC,MAAM,EAAE,0BAA0B,GAAG,OAAO,CAAC,IAAI,CAAC,CAsB9D;IAEK,UAAU,CAAC,WAAW,EAAE,MAAM,EAAE,MAAM,EAAE,cAAc,EAAE,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAOvF;CACF"}
|
|
@@ -1,49 +1,20 @@
|
|
|
1
|
-
function parseCredentials(json) {
|
|
2
|
-
try {
|
|
3
|
-
const parsed = JSON.parse(json);
|
|
4
|
-
if (parsed && typeof parsed === 'object')
|
|
5
|
-
return parsed;
|
|
6
|
-
}
|
|
7
|
-
catch {
|
|
8
|
-
// A malformed bag is treated as empty; the import path then fails closed.
|
|
9
|
-
}
|
|
10
|
-
return {};
|
|
11
|
-
}
|
|
12
1
|
/**
|
|
13
2
|
* D1-backed store of workspace → task-source connections (migration 0014).
|
|
14
3
|
*
|
|
15
|
-
* Source credentials (e.g. a Jira API token)
|
|
16
|
-
* are
|
|
17
|
-
*
|
|
18
|
-
* `credentials` column predates encryption (no `v1.` envelope) is still read as
|
|
19
|
-
* legacy plaintext JSON, then re-encrypted on the next write.
|
|
4
|
+
* Source credentials (e.g. a Jira API token) cross this repository as the AES-256-GCM ENVELOPE
|
|
5
|
+
* they are stored as; opening one belongs to `createTaskConnectionStore`
|
|
6
|
+
* (`@cat-factory/integrations`). Same shape, and the same reason, as its document-source sibling.
|
|
20
7
|
*/
|
|
21
8
|
export class D1TaskConnectionRepository {
|
|
22
9
|
db;
|
|
23
|
-
|
|
24
|
-
constructor({ db, cipher }) {
|
|
10
|
+
constructor({ db }) {
|
|
25
11
|
this.db = db;
|
|
26
|
-
this.cipher = cipher;
|
|
27
|
-
}
|
|
28
|
-
/** Decode the stored credential blob, decrypting the envelope when present. */
|
|
29
|
-
async decodeCredentials(stored) {
|
|
30
|
-
// Legacy plaintext rows (written before encryption) lack the envelope tag.
|
|
31
|
-
if (!stored.startsWith('v1.'))
|
|
32
|
-
return parseCredentials(stored);
|
|
33
|
-
try {
|
|
34
|
-
return parseCredentials(await this.cipher.decrypt(stored));
|
|
35
|
-
}
|
|
36
|
-
catch {
|
|
37
|
-
// Wrong key / corrupt envelope: fail closed with an empty bag so the
|
|
38
|
-
// import path errors rather than leaking a decrypt exception.
|
|
39
|
-
return {};
|
|
40
|
-
}
|
|
41
12
|
}
|
|
42
|
-
|
|
13
|
+
rowToRecord(row) {
|
|
43
14
|
return {
|
|
44
15
|
workspaceId: row.workspace_id,
|
|
45
16
|
source: row.source,
|
|
46
|
-
|
|
17
|
+
credentialsCipher: row.credentials,
|
|
47
18
|
label: row.label,
|
|
48
19
|
createdAt: row.created_at,
|
|
49
20
|
deletedAt: row.deleted_at,
|
|
@@ -61,7 +32,7 @@ export class D1TaskConnectionRepository {
|
|
|
61
32
|
.prepare('SELECT * FROM task_connections WHERE workspace_id = ? AND deleted_at IS NULL ORDER BY created_at DESC')
|
|
62
33
|
.bind(workspaceId)
|
|
63
34
|
.all();
|
|
64
|
-
return
|
|
35
|
+
return results.map((row) => this.rowToRecord(row));
|
|
65
36
|
}
|
|
66
37
|
async upsert(record) {
|
|
67
38
|
// A workspace has a single live connection per source: clear any prior
|
|
@@ -71,12 +42,11 @@ export class D1TaskConnectionRepository {
|
|
|
71
42
|
.prepare('DELETE FROM task_connections WHERE workspace_id = ? AND source = ?')
|
|
72
43
|
.bind(record.workspaceId, record.source)
|
|
73
44
|
.run();
|
|
74
|
-
const credentials = await this.cipher.encrypt(JSON.stringify(record.credentials));
|
|
75
45
|
await this.db
|
|
76
46
|
.prepare(`INSERT INTO task_connections
|
|
77
47
|
(workspace_id, source, credentials, label, created_at, deleted_at)
|
|
78
48
|
VALUES (?, ?, ?, ?, ?, NULL)`)
|
|
79
|
-
.bind(record.workspaceId, record.source,
|
|
49
|
+
.bind(record.workspaceId, record.source, record.credentialsCipher, record.label, record.createdAt)
|
|
80
50
|
.run();
|
|
81
51
|
}
|
|
82
52
|
async softDelete(workspaceId, source, at) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"D1TaskConnectionRepository.js","sourceRoot":"","sources":["../../../src/infrastructure/repositories/D1TaskConnectionRepository.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"D1TaskConnectionRepository.js","sourceRoot":"","sources":["../../../src/infrastructure/repositories/D1TaskConnectionRepository.ts"],"names":[],"mappings":"AAgBA;;;;;;GAMG;AACH,MAAM,OAAO,0BAA0B;IACpB,EAAE,CAAY;IAE/B,YAAY,EAAE,EAAE,EAAsB;QACpC,IAAI,CAAC,EAAE,GAAG,EAAE,CAAA;IACd,CAAC;IAEO,WAAW,CAAC,GAAsB;QACxC,OAAO;YACL,WAAW,EAAE,GAAG,CAAC,YAAY;YAC7B,MAAM,EAAE,GAAG,CAAC,MAAwB;YACpC,iBAAiB,EAAE,GAAG,CAAC,WAAW;YAClC,KAAK,EAAE,GAAG,CAAC,KAAK;YAChB,SAAS,EAAE,GAAG,CAAC,UAAU;YACzB,SAAS,EAAE,GAAG,CAAC,UAAU;SAC1B,CAAA;IACH,CAAC;IAED,KAAK,CAAC,cAAc,CAClB,WAAmB,EACnB,MAAsB;QAEtB,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,EAAE;aACtB,OAAO,CACN,6FAA6F,CAC9F;aACA,IAAI,CAAC,WAAW,EAAE,MAAM,CAAC;aACzB,KAAK,EAAqB,CAAA;QAC7B,OAAO,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAA;IAC3C,CAAC;IAED,KA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|
|
1
|
+
{"version":3,"file":"tasks-deps.d.ts","sourceRoot":"","sources":["../../src/infrastructure/tasks-deps.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,WAAW,EAAsB,MAAM,qBAAqB,CAAA;AACjF,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAA;AASlE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,UAAU,CAAA;AACzC,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,OAAO,CAAA;AAmBhC;;;;;GAKG;AACH,wBAAgB,eAAe,CAC7B,GAAG,EAAE,GAAG,EACR,MAAM,EAAE,SAAS,EACjB,EAAE,EAAE,UAAU,EACd,KAAK,EAAE,KAAK,EACZ,WAAW,EAAE,WAAW,GACvB,OAAO,CAAC,gBAAgB,CAAC,CA2D3B"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { GitHubIssuesProvider, GitLabIssuesProvider, JiraProvider, LinearTaskProvider,
|
|
1
|
+
import { createTaskConnectionStore, GitHubIssuesProvider, GitLabIssuesProvider, gitlabWebBaseFromApiBase, JiraProvider, LinearTaskProvider, } from '@cat-factory/integrations';
|
|
2
2
|
import { buildAppRegistry } from './container';
|
|
3
3
|
import { selectWorkerVcsConnectDeps } from './vcsConnect';
|
|
4
4
|
import { FetchGitHubClient } from './github/FetchGitHubClient';
|
|
@@ -52,16 +52,19 @@ export function selectTasksDeps(env, config, db, clock, idGenerator) {
|
|
|
52
52
|
providers.push(new GitLabIssuesProvider({
|
|
53
53
|
gitlabClient: gitlabConnect.client,
|
|
54
54
|
installations,
|
|
55
|
-
webBaseUrl: gitlabWebBaseFromApiBase(config.gitlab
|
|
55
|
+
webBaseUrl: gitlabWebBaseFromApiBase(config.gitlab.apiBase),
|
|
56
56
|
}));
|
|
57
57
|
}
|
|
58
|
+
const taskConnectionRepository = new D1TaskConnectionRepository({ db });
|
|
58
59
|
return {
|
|
59
60
|
taskSourceProviders: providers,
|
|
60
|
-
taskConnectionRepository
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
//
|
|
64
|
-
|
|
61
|
+
taskConnectionRepository,
|
|
62
|
+
taskConnectionStore: createTaskConnectionStore({
|
|
63
|
+
taskConnectionRepository,
|
|
64
|
+
// The config gate guarantees the key is present when enabled; source credentials are sealed
|
|
65
|
+
// at rest under a tasks-scoped HKDF info. No delegate: a Cloudflare deployment holds its own
|
|
66
|
+
// key (it is the mothership others delegate TO).
|
|
67
|
+
secretCipher: new WebCryptoSecretCipher({
|
|
65
68
|
masterKeyBase64: config.tasks.encryptionKey,
|
|
66
69
|
info: 'cat-factory:tasks',
|
|
67
70
|
}),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tasks-deps.js","sourceRoot":"","sources":["../../src/infrastructure/tasks-deps.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,oBAAoB,EACpB,oBAAoB,EACpB,YAAY,EACZ,kBAAkB,
|
|
1
|
+
{"version":3,"file":"tasks-deps.js","sourceRoot":"","sources":["../../src/infrastructure/tasks-deps.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,yBAAyB,EACzB,oBAAoB,EACpB,oBAAoB,EACpB,wBAAwB,EACxB,YAAY,EACZ,kBAAkB,GACnB,MAAM,2BAA2B,CAAA;AAGlC,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAA;AAC9C,OAAO,EAAE,0BAA0B,EAAE,MAAM,cAAc,CAAA;AACzD,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAA;AAC9D,OAAO,EAAE,qBAAqB,EAAE,MAAM,sCAAsC,CAAA;AAC5E,OAAO,EAAE,8BAA8B,EAAE,MAAM,+CAA+C,CAAA;AAC9F,OAAO,EAAE,qBAAqB,EAAE,MAAM,sCAAsC,CAAA;AAC5E,OAAO,EAAE,0BAA0B,EAAE,MAAM,2CAA2C,CAAA;AACtF,OAAO,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAA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KAAK,GACX;IAAE,MAAM,EAAE,YAAY,CAAC;IAAC,OAAO,EAAE,uBAAuB,CAAA;CAAE,GAAG,SAAS,
|
|
1
|
+
{"version":3,"file":"vcsConnect.d.ts","sourceRoot":"","sources":["../../src/infrastructure/vcsConnect.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,KAAK,EAAE,4BAA4B,EAAE,MAAM,qBAAqB,CAAA;AAC5F,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAA;AAGpD,OAAO,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAA;AAInE;;;;;;;GAOG;AACH,wBAAgB,0BAA0B,CACxC,MAAM,EAAE,SAAS,EACjB,aAAa,EAAE,4BAA4B,EAC3C,EAAE,EAAE,UAAU,EACd,KAAK,EAAE,KAAK,GACX;IAAE,MAAM,EAAE,YAAY,CAAC;IAAC,OAAO,EAAE,uBAAuB,CAAA;CAAE,GAAG,SAAS,CA2BxE"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { logger } from '@cat-factory/server';
|
|
1
|
+
import { logger, resolveVcsWebUrls } from '@cat-factory/server';
|
|
2
2
|
import { buildGitLabConnectClient, GitLabIdentityResolver } from '@cat-factory/gitlab';
|
|
3
3
|
import { VcsPatConnectionService } from '@cat-factory/integrations';
|
|
4
4
|
import { WebCryptoSecretCipher } from './environments/WebCryptoSecretCipher';
|
|
@@ -13,7 +13,7 @@ import { D1WorkspaceRepository } from './repositories/D1WorkspaceRepository';
|
|
|
13
13
|
*/
|
|
14
14
|
export function selectWorkerVcsConnectDeps(config, installations, db, clock) {
|
|
15
15
|
const gitlab = config.gitlab;
|
|
16
|
-
if (!gitlab
|
|
16
|
+
if (!gitlab.enabled || !gitlab.encryptionKey)
|
|
17
17
|
return undefined;
|
|
18
18
|
// One cipher seals (connect) and unseals (token source) under the same domain.
|
|
19
19
|
const cipher = new WebCryptoSecretCipher({
|
|
@@ -34,6 +34,9 @@ export function selectWorkerVcsConnectDeps(config, installations, db, clock) {
|
|
|
34
34
|
identityResolver: new GitLabIdentityResolver({ apiBase: gitlab.apiBase }),
|
|
35
35
|
cipher,
|
|
36
36
|
clock,
|
|
37
|
+
// Where this connection's projects can be opened in a browser, from the SAME resolver the
|
|
38
|
+
// App connect path and the connect-capability route read.
|
|
39
|
+
webUrls: resolveVcsWebUrls(config),
|
|
37
40
|
});
|
|
38
41
|
return { client, service };
|
|
39
42
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vcsConnect.js","sourceRoot":"","sources":["../../src/infrastructure/vcsConnect.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAA;
|
|
1
|
+
{"version":3,"file":"vcsConnect.js","sourceRoot":"","sources":["../../src/infrastructure/vcsConnect.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,MAAM,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAA;AAC/D,OAAO,EAAE,wBAAwB,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAA;AACtF,OAAO,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAA;AACnE,OAAO,EAAE,qBAAqB,EAAE,MAAM,sCAAsC,CAAA;AAC5E,OAAO,EAAE,qBAAqB,EAAE,MAAM,sCAAsC,CAAA;AAE5E;;;;;;;GAOG;AACH,MAAM,UAAU,0BAA0B,CACxC,MAAiB,EACjB,aAA2C,EAC3C,EAAc,EACd,KAAY;IAEZ,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,CAAA;IAC5B,IAAI,CAAC,MAAM,CAAC,OAAO,IAAI,CAAC,MAAM,CAAC,aAAa;QAAE,OAAO,SAAS,CAAA;IAC9D,+EAA+E;IAC/E,MAAM,MAAM,GAAG,IAAI,qBAAqB,CAAC;QACvC,eAAe,EAAE,MAAM,CAAC,aAAa;QACrC,IAAI,EAAE,uBAAuB;KAC9B,CAAC,CAAA;IACF,MAAM,MAAM,GAAG,wBAAwB,CAAC;QACtC,aAAa;QACb,MAAM;QACN,OAAO,EAAE,MAAM,CAAC,OAAO;QACvB,KAAK;QACL,MAAM;KACP,CAAC,CAAA;IACF,MAAM,OAAO,GAAG,IAAI,uBAAuB,CAAC;QAC1C,QAAQ,EAAE,QAAQ;QAClB,aAAa;QACb,mBAAmB,EAAE,IAAI,qBAAqB,CAAC,EAAE,EAAE,EAAE,CAAC;QACtD,gBAAgB,EAAE,IAAI,sBAAsB,CAAC,EAAE,OAAO,EAAE,MAAM,CAAC,OAAO,EAAE,CAAC;QACzE,MAAM;QACN,KAAK;QACL,0FAA0F;QAC1F,0DAA0D;QAC1D,OAAO,EAAE,iBAAiB,CAAC,MAAM,CAAC;KACnC,CAAC,CAAA;IACF,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,CAAA;AAC5B,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ExecutionWorkflow.d.ts","sourceRoot":"","sources":["../../../src/infrastructure/workflows/ExecutionWorkflow.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kBAAkB,EAClB,KAAK,aAAa,EAElB,KAAK,YAAY,EAElB,MAAM,oBAAoB,CAAA;AAQ3B,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,QAAQ,CAAA;AAMjC,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAA;
|
|
1
|
+
{"version":3,"file":"ExecutionWorkflow.d.ts","sourceRoot":"","sources":["../../../src/infrastructure/workflows/ExecutionWorkflow.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kBAAkB,EAClB,KAAK,aAAa,EAElB,KAAK,YAAY,EAElB,MAAM,oBAAoB,CAAA;AAQ3B,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,QAAQ,CAAA;AAMjC,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAA;AA6JpE;;;;;;;GAOG;AACH,qBAAa,iBAAkB,SAAQ,kBAAkB,CAAC,GAAG,EAAE,uBAAuB,CAAC;IAC5E,GAAG,CAAC,KAAK,EAAE,aAAa,CAAC,uBAAuB,CAAC,EAAE,IAAI,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CAM7F;YAEa,KAAK;CA2MpB"}
|
|
@@ -6,11 +6,18 @@ import { loadConfig } from '../config';
|
|
|
6
6
|
import { logger } from '../observability/logger';
|
|
7
7
|
import { withWorkflowLogExport } from './logExport';
|
|
8
8
|
import { buildWorkflowRuntime } from './runtime';
|
|
9
|
-
/**
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
9
|
+
/**
|
|
10
|
+
* Per-step retry policy: failures retry a few times before the run is failed. The timeout is the
|
|
11
|
+
* engine's hang bound on one advance (`ExecutionConfig.advanceTimeout`) rather than a constant,
|
|
12
|
+
* because Node races the SAME value in `driveExecution`: one knob, so the two facades cannot
|
|
13
|
+
* drift apart on how long a wedged advance is waited out (stuck-run audit F9).
|
|
14
|
+
*/
|
|
15
|
+
function buildStepConfig(timeout) {
|
|
16
|
+
return {
|
|
17
|
+
retries: { limit: 3, delay: '5 seconds', backoff: 'exponential' },
|
|
18
|
+
timeout: timeout,
|
|
19
|
+
};
|
|
20
|
+
}
|
|
14
21
|
/**
|
|
15
22
|
* Poll a dispatched async job (a container coding step) for step `i` between durable
|
|
16
23
|
* sleeps until it finishes. A thrown poll error is always transient, so tolerate a
|
|
@@ -97,7 +104,7 @@ async function driveGatePollLoop(deps, i, initial) {
|
|
|
97
104
|
// Poll budget spent. Let the gate decide: a time-windowed watch gate
|
|
98
105
|
// (post-release-health) PASSES, while CI/conflicts resolve to a `job_failed`
|
|
99
106
|
// timeout the checks below funnel through `failRun`. One policy, both runtimes.
|
|
100
|
-
result = (await step.do(`gate-exhausted-${i}`,
|
|
107
|
+
result = (await step.do(`gate-exhausted-${i}`, deps.stepConfig, deps.resolveExhaustion));
|
|
101
108
|
}
|
|
102
109
|
return result;
|
|
103
110
|
}
|
|
@@ -133,6 +140,7 @@ export class ExecutionWorkflow extends WorkflowEntrypoint {
|
|
|
133
140
|
const decisionTimeout = execConfig.decisionTimeout;
|
|
134
141
|
const jobPollInterval = execConfig.jobPollInterval;
|
|
135
142
|
const ciPollInterval = execConfig.ciPollInterval;
|
|
143
|
+
const stepConfig = buildStepConfig(execConfig.advanceTimeout);
|
|
136
144
|
// Chunk length for a spend-paused run's budget re-check (see the `paused` branch below).
|
|
137
145
|
// Reuses the decision-wait cadence (default 24h), NOT the short gate-poll cadence: the run
|
|
138
146
|
// parks on `waitForEvent`, so `/spend/resume` wakes it immediately via `signalResume` and
|
|
@@ -160,7 +168,7 @@ export class ExecutionWorkflow extends WorkflowEntrypoint {
|
|
|
160
168
|
// Eviction / a genuine job failure are RETURNED as an `ok` AdvanceResult, not thrown.
|
|
161
169
|
const pollOnce = async (label, read) => {
|
|
162
170
|
try {
|
|
163
|
-
return { kind: 'ok', result: (await step.do(label,
|
|
171
|
+
return { kind: 'ok', result: (await step.do(label, stepConfig, read)) };
|
|
164
172
|
}
|
|
165
173
|
catch (error) {
|
|
166
174
|
// Scrubbed HERE, once, because this message is both logged and folded into the run's
|
|
@@ -179,6 +187,7 @@ export class ExecutionWorkflow extends WorkflowEntrypoint {
|
|
|
179
187
|
maxPolls: execConfig.jobMaxPolls,
|
|
180
188
|
failureTolerance: execConfig.jobPollFailureTolerance,
|
|
181
189
|
pollInterval: jobPollInterval,
|
|
190
|
+
stepConfig,
|
|
182
191
|
pollOnce,
|
|
183
192
|
failRun,
|
|
184
193
|
poll: () => container.executionService.pollAgentJob(workspaceId, executionId),
|
|
@@ -193,7 +202,7 @@ export class ExecutionWorkflow extends WorkflowEntrypoint {
|
|
|
193
202
|
for (let i = 0;; i++) {
|
|
194
203
|
let result;
|
|
195
204
|
try {
|
|
196
|
-
result = (await step.do(`advance-${i}`,
|
|
205
|
+
result = (await step.do(`advance-${i}`, stepConfig, () => container.executionService.advanceInstance(workspaceId, executionId, {
|
|
197
206
|
rethrowAgentErrors: true,
|
|
198
207
|
})));
|
|
199
208
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ExecutionWorkflow.js","sourceRoot":"","sources":["../../../src/infrastructure/workflows/ExecutionWorkflow.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kBAAkB,GAKnB,MAAM,oBAAoB,CAAA;AAC3B,OAAO,EAAe,aAAa,EAAE,MAAM,qBAAqB,CAAA;AAEhE,OAAO,EACL,uBAAuB,EACvB,iBAAiB,EACjB,iBAAiB,GAClB,MAAM,4BAA4B,CAAA;AAEnC,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAA;AAC7C,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAA;AACtC,OAAO,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAA;AAChD,OAAO,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAA;AACnD,OAAO,EAAE,oBAAoB,EAAE,MAAM,WAAW,CAAA;AAGhD
|
|
1
|
+
{"version":3,"file":"ExecutionWorkflow.js","sourceRoot":"","sources":["../../../src/infrastructure/workflows/ExecutionWorkflow.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kBAAkB,GAKnB,MAAM,oBAAoB,CAAA;AAC3B,OAAO,EAAe,aAAa,EAAE,MAAM,qBAAqB,CAAA;AAEhE,OAAO,EACL,uBAAuB,EACvB,iBAAiB,EACjB,iBAAiB,GAClB,MAAM,4BAA4B,CAAA;AAEnC,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAA;AAC7C,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAA;AACtC,OAAO,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAA;AAChD,OAAO,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAA;AACnD,OAAO,EAAE,oBAAoB,EAAE,MAAM,WAAW,CAAA;AAGhD;;;;;GAKG;AACH,SAAS,eAAe,CAAC,OAAe;IACtC,OAAO;QACL,OAA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;wBAC3C,IAAI,EAAE,cAAc;wBACpB,OAAO,EAAE,mBAAmB;qBAC7B,CAAC,CAAA;gBACJ,CAAC;gBAAC,MAAM,CAAC;oBACP,uFAAuF;gBACzF,CAAC;gBACD,SAAQ;YACV,CAAC;YAED,IAAI,MAAM,CAAC,IAAI,KAAK,mBAAmB,EAAE,CAAC;gBACxC,MAAM,UAAU,GAAG,MAAM,CAAC,UAAU,CAAA;gBACpC,gFAAgF;gBAChF,gFAAgF;gBAChF,0EAA0E;gBAC1E,iFAAiF;gBACjF,6EAA6E;gBAC7E,iFAAiF;gBACjF,6EAA6E;gBAC7E,iFAAiF;gBACjF,IAAI,CAAC;oBACH,MAAM,IAAI,CAAC,YAAY,CAAC,SAAS,UAAU,IAAI,CAAC,EAAE,EAAE;wBAClD,IAAI,EAAE,YAAY,UAAU,EAAE;wBAC9B,OAAO,EAAE,eAAe;qBACzB,CAAC,CAAA;gBACJ,CAAC;gBAAC,MAAM,CAAC;oBACP,+EAA+E;gBACjF,CAAC;YACH,CAAC;YACD,+EAA+E;QACjF,CAAC;IACH,CAAC;CACF"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
-- Design-document renders: the pixels an import retains beside the text.
|
|
2
|
+
--
|
|
3
|
+
-- A design source describes a screen twice over, as the structure/styling an agent reads and as the
|
|
4
|
+
-- picture a person recognises. The second half now lands in the binary-artifact store as a
|
|
5
|
+
-- `reference` artifact, which is the same shelf the visual-confirmation gate already reads from,
|
|
6
|
+
-- so a design frame and a hand-uploaded reference image are the same kind of thing to every reader
|
|
7
|
+
-- downstream. Two columns are needed to make that work.
|
|
8
|
+
|
|
9
|
+
-- What became of the renders at the import that wrote the stored body: `stored` / `partial` /
|
|
10
|
+
-- `none` / `failed` / `storage_unavailable`. Deliberately nullable, and NULL is a distinct fourth
|
|
11
|
+
-- state rather than a default: it means the question does not apply (a prose source, an `upload`,
|
|
12
|
+
-- or a row written before renders existed), where every non-null value means renders WERE in scope
|
|
13
|
+
-- and says how they went. Each of those failures renders as the same absence of images and asks for
|
|
14
|
+
-- a different fix (configure image storage, retry a rate-limited source, or nothing at all), which
|
|
15
|
+
-- is the whole reason this is a vocabulary and not a boolean.
|
|
16
|
+
ALTER TABLE documents ADD COLUMN render_status TEXT;
|
|
17
|
+
|
|
18
|
+
-- Which imported document an artifact was rendered FROM, or NULL for one a person uploaded.
|
|
19
|
+
--
|
|
20
|
+
-- The document's own SOURCE identity (`documents` is keyed by `(workspace_id, source, external_id)`)
|
|
21
|
+
-- rather than the block it happens to be attached to: an import runs before the document is
|
|
22
|
+
-- attached to anything, the attachment can move later, and only artifacts that came from a document
|
|
23
|
+
-- may be replaced wholesale when it is re-imported. Keyed on the pair so the reclaim is one indexed
|
|
24
|
+
-- range delete rather than a scan.
|
|
25
|
+
ALTER TABLE binary_artifacts ADD COLUMN document_source TEXT;
|
|
26
|
+
ALTER TABLE binary_artifacts ADD COLUMN document_external_id TEXT;
|
|
27
|
+
CREATE INDEX idx_binary_artifacts_document
|
|
28
|
+
ON binary_artifacts (workspace_id, document_source, document_external_id);
|