@assemblyline-agents/postgres 0.1.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.
Files changed (79) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +19 -0
  3. package/dist/adapter-checkpoints.d.ts +6 -0
  4. package/dist/adapter-checkpoints.d.ts.map +1 -0
  5. package/dist/adapter-checkpoints.js +110 -0
  6. package/dist/adapter-checkpoints.js.map +1 -0
  7. package/dist/adapter-conversation-turns.d.ts +20 -0
  8. package/dist/adapter-conversation-turns.d.ts.map +1 -0
  9. package/dist/adapter-conversation-turns.js +216 -0
  10. package/dist/adapter-conversation-turns.js.map +1 -0
  11. package/dist/adapter-conversations.d.ts +46 -0
  12. package/dist/adapter-conversations.d.ts.map +1 -0
  13. package/dist/adapter-conversations.js +129 -0
  14. package/dist/adapter-conversations.js.map +1 -0
  15. package/dist/adapter-delivery.d.ts +13 -0
  16. package/dist/adapter-delivery.d.ts.map +1 -0
  17. package/dist/adapter-delivery.js +157 -0
  18. package/dist/adapter-delivery.js.map +1 -0
  19. package/dist/adapter-grants.d.ts +11 -0
  20. package/dist/adapter-grants.d.ts.map +1 -0
  21. package/dist/adapter-grants.js +125 -0
  22. package/dist/adapter-grants.js.map +1 -0
  23. package/dist/adapter-memory.d.ts +21 -0
  24. package/dist/adapter-memory.d.ts.map +1 -0
  25. package/dist/adapter-memory.js +181 -0
  26. package/dist/adapter-memory.js.map +1 -0
  27. package/dist/adapter-misc.d.ts +61 -0
  28. package/dist/adapter-misc.d.ts.map +1 -0
  29. package/dist/adapter-misc.js +127 -0
  30. package/dist/adapter-misc.js.map +1 -0
  31. package/dist/adapter-runs.d.ts +20 -0
  32. package/dist/adapter-runs.d.ts.map +1 -0
  33. package/dist/adapter-runs.js +193 -0
  34. package/dist/adapter-runs.js.map +1 -0
  35. package/dist/adapter-sandbox.d.ts +27 -0
  36. package/dist/adapter-sandbox.d.ts.map +1 -0
  37. package/dist/adapter-sandbox.js +267 -0
  38. package/dist/adapter-sandbox.js.map +1 -0
  39. package/dist/adapter-settings.d.ts +8 -0
  40. package/dist/adapter-settings.d.ts.map +1 -0
  41. package/dist/adapter-settings.js +38 -0
  42. package/dist/adapter-settings.js.map +1 -0
  43. package/dist/adapter-usage.d.ts +7 -0
  44. package/dist/adapter-usage.d.ts.map +1 -0
  45. package/dist/adapter-usage.js +243 -0
  46. package/dist/adapter-usage.js.map +1 -0
  47. package/dist/client-types.d.ts +6 -0
  48. package/dist/client-types.d.ts.map +1 -0
  49. package/dist/client-types.js +2 -0
  50. package/dist/client-types.js.map +1 -0
  51. package/dist/index.d.ts +208 -0
  52. package/dist/index.d.ts.map +1 -0
  53. package/dist/index.js +424 -0
  54. package/dist/index.js.map +1 -0
  55. package/dist/migrations.d.ts +35 -0
  56. package/dist/migrations.d.ts.map +1 -0
  57. package/dist/migrations.js +694 -0
  58. package/dist/migrations.js.map +1 -0
  59. package/dist/presets.d.ts +19 -0
  60. package/dist/presets.d.ts.map +1 -0
  61. package/dist/presets.js +31 -0
  62. package/dist/presets.js.map +1 -0
  63. package/dist/provider.d.ts +12 -0
  64. package/dist/provider.d.ts.map +1 -0
  65. package/dist/provider.js +86 -0
  66. package/dist/provider.js.map +1 -0
  67. package/dist/row-mappers.d.ts +24 -0
  68. package/dist/row-mappers.d.ts.map +1 -0
  69. package/dist/row-mappers.js +450 -0
  70. package/dist/row-mappers.js.map +1 -0
  71. package/dist/sql-helpers.d.ts +46 -0
  72. package/dist/sql-helpers.d.ts.map +1 -0
  73. package/dist/sql-helpers.js +244 -0
  74. package/dist/sql-helpers.js.map +1 -0
  75. package/dist/stores.d.ts +40 -0
  76. package/dist/stores.d.ts.map +1 -0
  77. package/dist/stores.js +210 -0
  78. package/dist/stores.js.map +1 -0
  79. package/package.json +49 -0
@@ -0,0 +1,157 @@
1
+ import { randomUUID } from "node:crypto";
2
+ import { mapDelivery } from "./row-mappers.js";
3
+ import { applyDeliveryPatchForPostgres, positiveLimit, postgresSandboxSyncRetryDelayMs, timestamp } from "./sql-helpers.js";
4
+ export async function createDelivery(client, input) {
5
+ const now = timestamp();
6
+ const delivery = {
7
+ ...input,
8
+ attemptCount: input.attemptCount ?? 0,
9
+ maxAttempts: input.maxAttempts ?? 5,
10
+ nextAttemptAt: input.nextAttemptAt ?? now,
11
+ id: randomUUID(),
12
+ createdAt: now,
13
+ updatedAt: now
14
+ };
15
+ await client.query(`insert into openeve_delivery_obligations
16
+ (id, run_id, channel, payload, idempotency_key, status, attempt_count, max_attempts, next_attempt_at,
17
+ lease_token, lease_expires_at, last_error, sent_at, failed_at, created_at, updated_at)
18
+ values ($1,$2,$3,$4::jsonb,$5,$6,$7,$8,$9,$10,$11,$12,$13,$14,$15,$16)`, [
19
+ delivery.id,
20
+ delivery.runId,
21
+ delivery.channel,
22
+ JSON.stringify(delivery.payload),
23
+ delivery.idempotencyKey,
24
+ delivery.status,
25
+ delivery.attemptCount,
26
+ delivery.maxAttempts,
27
+ delivery.nextAttemptAt,
28
+ delivery.leaseToken ?? null,
29
+ delivery.leaseExpiresAt ?? null,
30
+ delivery.lastError ?? null,
31
+ delivery.sentAt ?? null,
32
+ delivery.failedAt ?? null,
33
+ delivery.createdAt,
34
+ delivery.updatedAt
35
+ ]);
36
+ return delivery;
37
+ }
38
+ export async function updateDelivery(client, id, patch) {
39
+ const current = (await client.query("select * from openeve_delivery_obligations where id=$1", [id])).rows[0];
40
+ if (!current)
41
+ throw new Error(`Delivery not found: ${id}`);
42
+ const updated = applyDeliveryPatchForPostgres(mapDelivery(current), patch);
43
+ await persistDelivery(client, updated);
44
+ return updated;
45
+ }
46
+ async function persistDelivery(client, updated) {
47
+ await client.query(`update openeve_delivery_obligations
48
+ set status=$2, payload=$3::jsonb, attempt_count=$4, max_attempts=$5, next_attempt_at=$6,
49
+ lease_token=$7, lease_expires_at=$8, last_error=$9, sent_at=$10, failed_at=$11, updated_at=$12
50
+ where id=$1`, [
51
+ updated.id,
52
+ updated.status,
53
+ JSON.stringify(updated.payload),
54
+ updated.attemptCount,
55
+ updated.maxAttempts,
56
+ updated.nextAttemptAt,
57
+ updated.leaseToken ?? null,
58
+ updated.leaseExpiresAt ?? null,
59
+ updated.lastError ?? null,
60
+ updated.sentAt ?? null,
61
+ updated.failedAt ?? null,
62
+ updated.updatedAt
63
+ ]);
64
+ }
65
+ export async function listDeliveries(client, runId) {
66
+ const result = await client.query("select * from openeve_delivery_obligations where run_id=$1 order by created_at asc", [runId]);
67
+ return result.rows.map(mapDelivery);
68
+ }
69
+ export async function leaseDueDeliveries(client, options = {}) {
70
+ const now = options.now ?? new Date();
71
+ const leaseToken = randomUUID();
72
+ const leaseForMs = positiveLimit(options.leaseForMs, 60_000);
73
+ const leaseExpiresAt = new Date(now.getTime() + leaseForMs).toISOString();
74
+ const result = await client.query(`update openeve_delivery_obligations
75
+ set status='sending',
76
+ lease_token=$1,
77
+ lease_expires_at=$2,
78
+ attempt_count=attempt_count + 1,
79
+ updated_at=$3
80
+ where id in (
81
+ select id from openeve_delivery_obligations
82
+ where status='pending'
83
+ and next_attempt_at <= $3
84
+ and attempt_count < max_attempts
85
+ order by next_attempt_at asc, created_at asc
86
+ limit $4
87
+ for update skip locked
88
+ )
89
+ returning *`, [leaseToken, leaseExpiresAt, now.toISOString(), positiveLimit(options.limit, 10)]);
90
+ return result.rows.map(mapDelivery);
91
+ }
92
+ export async function completeDeliverySend(client, id, leaseToken, patch = {}) {
93
+ const current = (await client.query("select * from openeve_delivery_obligations where id=$1", [id])).rows[0];
94
+ if (!current)
95
+ throw new Error(`Delivery not found: ${id}`);
96
+ const delivery = mapDelivery(current);
97
+ if (delivery.status === "sent")
98
+ return delivery;
99
+ if (delivery.leaseToken !== leaseToken)
100
+ throw new Error(`Delivery lease mismatch: ${id}`);
101
+ const sentAt = timestamp();
102
+ // Token-enforced in the WHERE clause so the settle is atomic: if the lease
103
+ // expired mid-send and a worker re-leased the row between the SELECT above
104
+ // and this UPDATE, 0 rows match and we throw rather than clobbering the new
105
+ // holder's lease (which would re-open the double-send window).
106
+ const result = await client.query(`update openeve_delivery_obligations
107
+ set status='sent', payload=$2::jsonb, lease_token=null, lease_expires_at=null,
108
+ last_error=null, sent_at=$3, updated_at=$3
109
+ where id=$1 and lease_token=$4
110
+ returning *`, [id, JSON.stringify(patch.payload ?? delivery.payload), sentAt, leaseToken]);
111
+ const row = result.rows[0];
112
+ if (!row)
113
+ throw new Error(`Delivery lease mismatch: ${id}`);
114
+ return mapDelivery(row);
115
+ }
116
+ export async function failDeliverySend(client, id, leaseToken, failure) {
117
+ const current = (await client.query("select * from openeve_delivery_obligations where id=$1", [id])).rows[0];
118
+ if (!current)
119
+ throw new Error(`Delivery not found: ${id}`);
120
+ const delivery = mapDelivery(current);
121
+ if (delivery.leaseToken !== leaseToken)
122
+ throw new Error(`Delivery lease mismatch: ${id}`);
123
+ const now = failure.now ?? new Date();
124
+ const permanent = failure.permanent === true || delivery.attemptCount >= delivery.maxAttempts;
125
+ const nextAttemptAt = permanent
126
+ ? delivery.nextAttemptAt
127
+ : new Date(now.getTime() + positiveLimit(failure.retryDelayMs, postgresSandboxSyncRetryDelayMs(delivery.attemptCount))).toISOString();
128
+ const result = await client.query(`update openeve_delivery_obligations
129
+ set status=$2, next_attempt_at=$3, lease_token=null, lease_expires_at=null,
130
+ failed_at=$4, last_error=$5, updated_at=$6
131
+ where id=$1 and lease_token=$7
132
+ returning *`, [
133
+ id,
134
+ permanent ? "failed" : "pending",
135
+ nextAttemptAt,
136
+ permanent ? now.toISOString() : delivery.failedAt ?? null,
137
+ failure.error,
138
+ timestamp(),
139
+ leaseToken
140
+ ]);
141
+ const row = result.rows[0];
142
+ // 0 rows: the lease was reclaimed by another worker between SELECT and
143
+ // UPDATE; throw rather than clobber its state.
144
+ if (!row)
145
+ throw new Error(`Delivery lease mismatch: ${id}`);
146
+ return mapDelivery(row);
147
+ }
148
+ export async function recoverExpiredDeliveries(client, now = new Date()) {
149
+ const result = await client.query(`update openeve_delivery_obligations
150
+ set status='pending', next_attempt_at=$1, lease_token=null, lease_expires_at=null, updated_at=$1
151
+ where status='sending'
152
+ and lease_expires_at is not null
153
+ and lease_expires_at <= $1
154
+ returning *`, [now.toISOString()]);
155
+ return result.rows.map(mapDelivery);
156
+ }
157
+ //# sourceMappingURL=adapter-delivery.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"adapter-delivery.js","sourceRoot":"","sources":["../src/adapter-delivery.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAUzC,OAAO,EAAE,WAAW,EAAY,MAAM,kBAAkB,CAAC;AACzD,OAAO,EAAE,6BAA6B,EAAE,aAAa,EAAE,+BAA+B,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAE5H,MAAM,CAAC,KAAK,UAAU,cAAc,CAAC,MAAmB,EAAE,KAA8B;IACtF,MAAM,GAAG,GAAG,SAAS,EAAE,CAAC;IACxB,MAAM,QAAQ,GAAuB;QACnC,GAAG,KAAK;QACR,YAAY,EAAE,KAAK,CAAC,YAAY,IAAI,CAAC;QACrC,WAAW,EAAE,KAAK,CAAC,WAAW,IAAI,CAAC;QACnC,aAAa,EAAE,KAAK,CAAC,aAAa,IAAI,GAAG;QACzC,EAAE,EAAE,UAAU,EAAE;QAChB,SAAS,EAAE,GAAG;QACd,SAAS,EAAE,GAAG;KACf,CAAC;IACF,MAAM,MAAM,CAAC,KAAK,CAChB;;;8EAG0E,EAC1E;QACE,QAAQ,CAAC,EAAE;QACX,QAAQ,CAAC,KAAK;QACd,QAAQ,CAAC,OAAO;QAChB,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,OAAO,CAAC;QAChC,QAAQ,CAAC,cAAc;QACvB,QAAQ,CAAC,MAAM;QACf,QAAQ,CAAC,YAAY;QACrB,QAAQ,CAAC,WAAW;QACpB,QAAQ,CAAC,aAAa;QACtB,QAAQ,CAAC,UAAU,IAAI,IAAI;QAC3B,QAAQ,CAAC,cAAc,IAAI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C;AACtC,CAAC"}
@@ -0,0 +1,11 @@
1
+ import type { ConnectionAuthorizationSessionRecord, StoredConnectionGrant } from "@assemblyline-agents/runtime";
2
+ import type { QueryClient } from "./client-types.js";
3
+ export declare function getGrant(client: QueryClient, connectionName: string, principalKey: string): Promise<StoredConnectionGrant | undefined>;
4
+ export declare function saveGrant(client: QueryClient, grant: StoredConnectionGrant): Promise<void>;
5
+ export declare function deleteGrant(client: QueryClient, connectionName: string, principalKey: string): Promise<void>;
6
+ export declare function createSession(client: QueryClient, session: ConnectionAuthorizationSessionRecord): Promise<void>;
7
+ export declare function updateSession(client: QueryClient, id: string, patch: Partial<Omit<ConnectionAuthorizationSessionRecord, "id" | "createdAt">>): Promise<ConnectionAuthorizationSessionRecord>;
8
+ export declare function getSession(client: QueryClient, id: string): Promise<ConnectionAuthorizationSessionRecord | undefined>;
9
+ export declare function getSessionByState(client: QueryClient, state: string): Promise<ConnectionAuthorizationSessionRecord | undefined>;
10
+ export declare function findPendingSession(client: QueryClient, connectionName: string, principalKey: string): Promise<ConnectionAuthorizationSessionRecord | undefined>;
11
+ //# sourceMappingURL=adapter-grants.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"adapter-grants.d.ts","sourceRoot":"","sources":["../src/adapter-grants.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,oCAAoC,EACpC,qBAAqB,EACtB,MAAM,8BAA8B,CAAC;AACtC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAIrD,wBAAsB,QAAQ,CAAC,MAAM,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,qBAAqB,GAAG,SAAS,CAAC,CAO5I;AAED,wBAAsB,SAAS,CAAC,MAAM,EAAE,WAAW,EAAE,KAAK,EAAE,qBAAqB,GAAG,OAAO,CAAC,IAAI,CAAC,CA4BhG;AAED,wBAAsB,WAAW,CAAC,MAAM,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAKlH;AAED,wBAAsB,aAAa,CAAC,MAAM,EAAE,WAAW,EAAE,OAAO,EAAE,oCAAoC,GAAG,OAAO,CAAC,IAAI,CAAC,CA0BrH;AAED,wBAAsB,aAAa,CACjC,MAAM,EAAE,WAAW,EACnB,EAAE,EAAE,MAAM,EACV,KAAK,EAAE,OAAO,CAAC,IAAI,CAAC,oCAAoC,EAAE,IAAI,GAAG,WAAW,CAAC,CAAC,GAC7E,OAAO,CAAC,oCAAoC,CAAC,CA4C/C;AAED,wBAAsB,UAAU,CAAC,MAAM,EAAE,WAAW,EAAE,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,oCAAoC,GAAG,SAAS,CAAC,CAI3H;AAED,wBAAsB,iBAAiB,CAAC,MAAM,EAAE,WAAW,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,oCAAoC,GAAG,SAAS,CAAC,CAIrI;AAED,wBAAsB,kBAAkB,CAAC,MAAM,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,oCAAoC,GAAG,SAAS,CAAC,CAUrK"}
@@ -0,0 +1,125 @@
1
+ import { mapConnectionAuthorizationSession, mapConnectionGrant } from "./row-mappers.js";
2
+ import { timestamp } from "./sql-helpers.js";
3
+ export async function getGrant(client, connectionName, principalKey) {
4
+ const result = await client.query("select * from openeve_connection_grants where connection_name=$1 and principal_key=$2", [connectionName, principalKey]);
5
+ const row = result.rows[0];
6
+ return row ? mapConnectionGrant(row) : undefined;
7
+ }
8
+ export async function saveGrant(client, grant) {
9
+ await client.query(`insert into openeve_connection_grants
10
+ (connection_name, principal_key, principal, token, refresh_token, token_type, scopes, expires_at, credential, created_at, updated_at)
11
+ values ($1,$2,$3::jsonb,$4,$5,$6,$7::jsonb,$8,$9::jsonb,$10,$11)
12
+ on conflict (connection_name, principal_key) do update set
13
+ principal=$3::jsonb,
14
+ token=$4,
15
+ refresh_token=$5,
16
+ token_type=$6,
17
+ scopes=$7::jsonb,
18
+ expires_at=$8,
19
+ credential=$9::jsonb,
20
+ updated_at=$11`, [
21
+ grant.connectionName,
22
+ grant.principalKey,
23
+ JSON.stringify(grant.principal),
24
+ grant.token,
25
+ grant.refreshToken ?? null,
26
+ grant.tokenType ?? null,
27
+ grant.scopes ? JSON.stringify(grant.scopes) : null,
28
+ grant.expiresAt ?? null,
29
+ grant.credential ? JSON.stringify(grant.credential) : null,
30
+ grant.createdAt,
31
+ grant.updatedAt
32
+ ]);
33
+ }
34
+ export async function deleteGrant(client, connectionName, principalKey) {
35
+ await client.query("delete from openeve_connection_grants where connection_name=$1 and principal_key=$2", [
36
+ connectionName,
37
+ principalKey
38
+ ]);
39
+ }
40
+ export async function createSession(client, session) {
41
+ await client.query(`insert into openeve_connection_authorization_sessions
42
+ (id, state, connection_name, principal_key, principal, session, callback_url, code_verifier, resume, run_id, tool_call_id, tool_name, challenge, continuation, status, expires_at, created_at, updated_at)
43
+ values ($1,$2,$3,$4,$5::jsonb,$6::jsonb,$7,$8,$9::jsonb,$10,$11,$12,$13::jsonb,$14::jsonb,$15,$16,$17,$18)`, [
44
+ session.id,
45
+ session.state,
46
+ session.connectionName,
47
+ session.principalKey,
48
+ JSON.stringify(session.principal),
49
+ JSON.stringify(session.session),
50
+ session.callbackUrl,
51
+ session.codeVerifier ?? null,
52
+ session.resume === undefined ? null : JSON.stringify(session.resume),
53
+ session.runId ?? null,
54
+ session.toolCallId ?? null,
55
+ session.toolName ?? null,
56
+ JSON.stringify(session.challenge),
57
+ session.continuation === undefined ? null : JSON.stringify(session.continuation),
58
+ session.status,
59
+ session.expiresAt,
60
+ session.createdAt,
61
+ session.updatedAt
62
+ ]);
63
+ }
64
+ export async function updateSession(client, id, patch) {
65
+ const current = await getSession(client, id);
66
+ if (!current)
67
+ throw new Error(`Connection authorization session not found: ${id}`);
68
+ const updated = { ...current, ...patch, updatedAt: timestamp() };
69
+ await client.query(`update openeve_connection_authorization_sessions
70
+ set state=$2,
71
+ connection_name=$3,
72
+ principal_key=$4,
73
+ principal=$5::jsonb,
74
+ session=$6::jsonb,
75
+ callback_url=$7,
76
+ code_verifier=$8,
77
+ resume=$9::jsonb,
78
+ run_id=$10,
79
+ tool_call_id=$11,
80
+ tool_name=$12,
81
+ challenge=$13::jsonb,
82
+ continuation=$14::jsonb,
83
+ status=$15,
84
+ expires_at=$16,
85
+ updated_at=$17
86
+ where id=$1`, [
87
+ updated.id,
88
+ updated.state,
89
+ updated.connectionName,
90
+ updated.principalKey,
91
+ JSON.stringify(updated.principal),
92
+ JSON.stringify(updated.session),
93
+ updated.callbackUrl,
94
+ updated.codeVerifier ?? null,
95
+ updated.resume === undefined ? null : JSON.stringify(updated.resume),
96
+ updated.runId ?? null,
97
+ updated.toolCallId ?? null,
98
+ updated.toolName ?? null,
99
+ JSON.stringify(updated.challenge),
100
+ updated.continuation === undefined ? null : JSON.stringify(updated.continuation),
101
+ updated.status,
102
+ updated.expiresAt,
103
+ updated.updatedAt
104
+ ]);
105
+ return updated;
106
+ }
107
+ export async function getSession(client, id) {
108
+ const result = await client.query("select * from openeve_connection_authorization_sessions where id=$1", [id]);
109
+ const row = result.rows[0];
110
+ return row ? mapConnectionAuthorizationSession(row) : undefined;
111
+ }
112
+ export async function getSessionByState(client, state) {
113
+ const result = await client.query("select * from openeve_connection_authorization_sessions where state=$1", [state]);
114
+ const row = result.rows[0];
115
+ return row ? mapConnectionAuthorizationSession(row) : undefined;
116
+ }
117
+ export async function findPendingSession(client, connectionName, principalKey) {
118
+ const result = await client.query(`select * from openeve_connection_authorization_sessions
119
+ where connection_name=$1 and principal_key=$2 and status='pending' and expires_at>$3
120
+ order by created_at desc
121
+ limit 1`, [connectionName, principalKey, Date.now()]);
122
+ const row = result.rows[0];
123
+ return row ? mapConnectionAuthorizationSession(row) : undefined;
124
+ }
125
+ //# sourceMappingURL=adapter-grants.js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C,CAAC;IACpH,MAAM,GAAG,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAC3B,OAAO,GAAG,CAAC,CAAC,CAAC,iCAAiC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;AAClE,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,iBAAiB,CAAC,MAAmB,EAAE,KAAa;IACxE,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,KAAK,CAAM,wEAAwE,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC;IAC1H,MAAM,GAAG,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAC3B,OAAO,GAAG,CAAC,CAAC,CAAC,iCAAiC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;AAClE,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,kBAAkB,CAAC,MAAmB,EAAE,cAAsB,EAAE,YAAoB;IACxG,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,KAAK,CAC/B;;;aAGS,EACT,CAAC,cAAc,EAAE,YAAY,EAAE,IAAI,CAAC,GAAG,EAAE,CAAC,CAC3C,CAAC;IACF,MAAM,GAAG,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAC3B,OAAO,GAAG,CAAC,CAAC,CAAC,iCAAiC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;AAClE,CAAC"}
@@ -0,0 +1,21 @@
1
+ import type { MemoryListInput, MemorySearchInput } from "@assemblyline-agents/core";
2
+ import type { MemoryDocument, MemoryEmbeddingRecord, MemoryScope, MemorySearchResult } from "@assemblyline-agents/runtime";
3
+ import type { QueryClient } from "./client-types.js";
4
+ export declare function listMemoryDocuments(client: QueryClient, scope: MemoryScope, input?: MemoryListInput): Promise<MemoryDocument[]>;
5
+ export declare function searchMemoryDocuments(client: QueryClient, scope: MemoryScope, input: MemorySearchInput): Promise<MemorySearchResult[]>;
6
+ export declare function getMemoryDocument(client: QueryClient, scope: MemoryScope, path: string): Promise<MemoryDocument | undefined>;
7
+ export declare function upsertMemoryDocument(client: QueryClient, document: MemoryDocument): Promise<MemoryDocument>;
8
+ export declare function deleteMemoryDocument(client: QueryClient, scope: MemoryScope, path: string, options?: {
9
+ embeddingsAvailable?: boolean;
10
+ }): Promise<void>;
11
+ export declare function listMemoryDocumentsNeedingEmbeddings(client: QueryClient, scope: MemoryScope, options: {
12
+ model: string;
13
+ limit?: number;
14
+ }): Promise<MemoryDocument[]>;
15
+ export declare function upsertMemoryEmbedding(client: QueryClient, input: Omit<MemoryEmbeddingRecord, "id" | "createdAt" | "updatedAt">): Promise<MemoryEmbeddingRecord>;
16
+ export declare function searchMemoryEmbeddings(client: QueryClient, scope: MemoryScope, input: MemorySearchInput, embedding: number[], options: {
17
+ model: string;
18
+ limit?: number;
19
+ }): Promise<MemorySearchResult[]>;
20
+ export declare function markMemoryEmbeddingsStale(client: QueryClient, scope: MemoryScope, path: string, currentSha256: string): Promise<void>;
21
+ //# sourceMappingURL=adapter-memory.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"adapter-memory.d.ts","sourceRoot":"","sources":["../src/adapter-memory.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AACpF,OAAO,KAAK,EAAE,cAAc,EAAE,qBAAqB,EAAE,WAAW,EAAE,kBAAkB,EAAE,MAAM,8BAA8B,CAAC;AAC3H,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAkBrD,wBAAsB,mBAAmB,CAAC,MAAM,EAAE,WAAW,EAAE,KAAK,EAAE,WAAW,EAAE,KAAK,GAAE,eAAoB,GAAG,OAAO,CAAC,cAAc,EAAE,CAAC,CAYzI;AAED,wBAAsB,qBAAqB,CAAC,MAAM,EAAE,WAAW,EAAE,KAAK,EAAE,WAAW,EAAE,KAAK,EAAE,iBAAiB,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,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAO3I"}
@@ -0,0 +1,181 @@
1
+ import { randomUUID } from "node:crypto";
2
+ import { mapMemoryDocument, mapMemoryEmbedding, memoryEmbeddingSearchResultFromPostgres, memorySearchResultFromPostgres } from "./row-mappers.js";
3
+ import { memoryScopeMatchesForPostgres, normalizeMemoryPathForPostgres, positiveLimit, postgresMemoryKey, postgresMemoryScopeWhere, postgresVectorLiteral, timestamp } from "./sql-helpers.js";
4
+ export async function listMemoryDocuments(client, scope, input = {}) {
5
+ const result = await client.query("select * from openeve_memory_documents where scope->>'agentScope'=$1 order by updated_at desc", [scope.agentScope]);
6
+ const prefix = normalizeMemoryPathForPostgres(input.pathPrefix ?? "");
7
+ const limit = input.limit === undefined ? Number.MAX_SAFE_INTEGER : positiveLimit(input.limit, 50);
8
+ return result.rows
9
+ .map(mapMemoryDocument)
10
+ .filter((document) => memoryScopeMatchesForPostgres(scope, document.scope))
11
+ .filter((document) => !prefix || document.path.startsWith(prefix))
12
+ .slice(0, limit);
13
+ }
14
+ export async function searchMemoryDocuments(client, scope, input) {
15
+ const query = String(input.query ?? "").trim();
16
+ const pathPrefix = normalizeMemoryPathForPostgres(input.pathPrefix ?? "");
17
+ const limit = positiveLimit(input.limit, 8);
18
+ const mode = input.mode ?? "hybrid";
19
+ const scopeFilter = postgresMemoryScopeWhere(scope, 5);
20
+ const params = [scope.agentScope, query, pathPrefix, limit, ...scopeFilter.params];
21
+ const exact = mode === "exact";
22
+ const result = await client.query(exact
23
+ ? `select *, 1::float as rank
24
+ from openeve_memory_documents
25
+ where scope->>'agentScope'=$1
26
+ and ($3 = '' or normalized_path like ($3 || '%'))
27
+ and (normalized_path = $2 or path = $2)
28
+ ${scopeFilter.sql}
29
+ order by updated_at desc
30
+ limit $4`
31
+ : `select *,
32
+ ts_rank(search_vector, plainto_tsquery('simple', $2)) as rank,
33
+ ts_headline('simple', body::text, plainto_tsquery('simple', $2), 'MaxWords=32, MinWords=8, ShortWord=3') as snippet
34
+ from openeve_memory_documents
35
+ where scope->>'agentScope'=$1
36
+ and ($3 = '' or normalized_path like ($3 || '%'))
37
+ and (
38
+ $2 = ''
39
+ or normalized_path = $2
40
+ or normalized_path like ('%' || $2 || '%')
41
+ or search_vector @@ plainto_tsquery('simple', $2)
42
+ )
43
+ ${scopeFilter.sql}
44
+ order by
45
+ case when normalized_path = $2 then 1000 else 0 end desc,
46
+ rank desc,
47
+ updated_at desc
48
+ limit $4`, params);
49
+ return result.rows.map((row) => memorySearchResultFromPostgres(row, query, mode));
50
+ }
51
+ export async function getMemoryDocument(client, scope, path) {
52
+ const normalizedPath = normalizeMemoryPathForPostgres(path);
53
+ const result = await client.query("select * from openeve_memory_documents where scope_key=$1", [postgresMemoryKey(scope, normalizedPath)]);
54
+ const row = result.rows[0];
55
+ return row ? mapMemoryDocument(row) : undefined;
56
+ }
57
+ export async function upsertMemoryDocument(client, document) {
58
+ const result = await client.query(`insert into openeve_memory_documents
59
+ (id, scope_key, scope, path, normalized_path, body, content_type, title, summary, tags, confidence, source_refs, token_estimate, sha256, revision, created_at, updated_at)
60
+ values ($1,$2,$3::jsonb,$4,$5,$6::jsonb,$7,$8,$9,$10::jsonb,$11,$12::jsonb,$13,$14,$15,$16,$17)
61
+ on conflict (scope_key) do update set
62
+ scope=$3::jsonb,
63
+ path=$4,
64
+ normalized_path=$5,
65
+ body=$6::jsonb,
66
+ content_type=$7,
67
+ title=$8,
68
+ summary=$9,
69
+ tags=$10::jsonb,
70
+ confidence=$11,
71
+ source_refs=$12::jsonb,
72
+ token_estimate=$13,
73
+ sha256=$14,
74
+ revision=$15,
75
+ updated_at=$17
76
+ returning *`, [
77
+ randomUUID(),
78
+ postgresMemoryKey(document.scope, document.path),
79
+ JSON.stringify(document.scope),
80
+ document.path,
81
+ normalizeMemoryPathForPostgres(document.path),
82
+ JSON.stringify(document.body),
83
+ document.contentType,
84
+ document.title ?? null,
85
+ document.summary ?? null,
86
+ JSON.stringify(document.tags),
87
+ document.confidence ?? null,
88
+ JSON.stringify(document.sourceRefs ?? []),
89
+ document.tokenEstimate,
90
+ document.sha256,
91
+ document.revision,
92
+ document.createdAt,
93
+ document.updatedAt
94
+ ]);
95
+ return result.rows[0] ? mapMemoryDocument(result.rows[0]) : document;
96
+ }
97
+ export async function deleteMemoryDocument(client, scope, path, options = {}) {
98
+ const normalizedPath = normalizeMemoryPathForPostgres(path);
99
+ const key = postgresMemoryKey(scope, normalizedPath);
100
+ if (options.embeddingsAvailable !== false) {
101
+ await client.query("delete from openeve_memory_embeddings where scope_key=$1", [key]);
102
+ }
103
+ await client.query("delete from openeve_memory_documents where scope_key=$1", [key]);
104
+ }
105
+ export async function listMemoryDocumentsNeedingEmbeddings(client, scope, options) {
106
+ const scopeFilter = postgresMemoryScopeWhere(scope, 4);
107
+ const result = await client.query(`select d.*
108
+ from openeve_memory_documents d
109
+ left join openeve_memory_embeddings e
110
+ on e.scope_key=d.scope_key and e.model=$2
111
+ where d.scope->>'agentScope'=$1
112
+ and (e.id is null or e.stale=true or e.content_sha256 <> d.sha256)
113
+ ${scopeFilter.sql.replace(/scope/g, "d.scope")}
114
+ order by d.updated_at desc
115
+ limit $3`, [scope.agentScope, options.model, positiveLimit(options.limit, 25), ...scopeFilter.params]);
116
+ return result.rows.map(mapMemoryDocument);
117
+ }
118
+ export async function upsertMemoryEmbedding(client, input) {
119
+ const now = timestamp();
120
+ const result = await client.query(`insert into openeve_memory_embeddings
121
+ (id, scope_key, scope, path, model, dimensions, content_sha256, embedding, stale, metadata, created_at, updated_at)
122
+ values ($1,$2,$3::jsonb,$4,$5,$6,$7,$8::vector,$9,$10::jsonb,$11,$12)
123
+ on conflict (scope_key, model) do update set
124
+ scope=$3::jsonb,
125
+ path=$4,
126
+ dimensions=$6,
127
+ content_sha256=$7,
128
+ embedding=$8::vector,
129
+ stale=$9,
130
+ metadata=$10::jsonb,
131
+ updated_at=$12
132
+ returning *`, [
133
+ randomUUID(),
134
+ postgresMemoryKey(input.scope, input.path),
135
+ JSON.stringify(input.scope),
136
+ normalizeMemoryPathForPostgres(input.path),
137
+ input.model,
138
+ input.dimensions,
139
+ input.contentSha256,
140
+ postgresVectorLiteral(input.embedding),
141
+ input.stale,
142
+ JSON.stringify(input.metadata),
143
+ now,
144
+ now
145
+ ]);
146
+ return result.rows[0] ? mapMemoryEmbedding(result.rows[0]) : {
147
+ ...input,
148
+ id: randomUUID(),
149
+ createdAt: now,
150
+ updatedAt: now
151
+ };
152
+ }
153
+ export async function searchMemoryEmbeddings(client, scope, input, embedding, options) {
154
+ const pathPrefix = normalizeMemoryPathForPostgres(input.pathPrefix ?? "");
155
+ const scopeFilter = postgresMemoryScopeWhere(scope, 6);
156
+ const result = await client.query(`select d.*, (e.embedding <=> $2::vector) as distance
157
+ from openeve_memory_embeddings e
158
+ join openeve_memory_documents d
159
+ on d.scope_key=e.scope_key
160
+ where e.model=$3
161
+ and e.stale=false
162
+ and d.scope->>'agentScope'=$1
163
+ and ($4 = '' or d.normalized_path like ($4 || '%'))
164
+ ${scopeFilter.sql.replace(/scope/g, "d.scope")}
165
+ order by distance asc, d.updated_at desc
166
+ limit $5`, [
167
+ scope.agentScope,
168
+ postgresVectorLiteral(embedding),
169
+ options.model,
170
+ pathPrefix,
171
+ positiveLimit(options.limit ?? input.limit, 8),
172
+ ...scopeFilter.params
173
+ ]);
174
+ return result.rows.map((row) => memoryEmbeddingSearchResultFromPostgres(row, input.query));
175
+ }
176
+ export async function markMemoryEmbeddingsStale(client, scope, path, currentSha256) {
177
+ await client.query(`update openeve_memory_embeddings
178
+ set stale=true, updated_at=$4
179
+ where scope_key=$1 and path=$2 and content_sha256 <> $3`, [postgresMemoryKey(scope, path), normalizeMemoryPathForPostgres(path), currentSha256, timestamp()]);
180
+ }
181
+ //# sourceMappingURL=adapter-memory.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"adapter-memory.js","sourceRoot":"","sources":["../src/adapter-memory.ts"],"names":[],"mappings":"AAAA,OAAO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yB,CAAC,MAAmB,EAAE,KAAkB,EAAE,IAAY,EAAE,aAAqB;IAC1H,MAAM,MAAM,CAAC,KAAK,CAChB;;+DAE2D,EAC3D,CAAC,iBAAiB,CAAC,KAAK,EAAE,IAAI,CAAC,EAAE,8BAA8B,CAAC,IAAI,CAAC,EAAE,aAAa,EAAE,SAAS,EAAE,CAAC,CACnG,CAAC;AACJ,CAAC"}
@@ -0,0 +1,61 @@
1
+ import type { JsonObject } from "@assemblyline-agents/core";
2
+ import type { FileIndexRecord, ScheduleRecord, ScheduleRunRecord } from "@assemblyline-agents/runtime";
3
+ import type { QueryClient } from "./client-types.js";
4
+ export interface PostgresQueueRecord {
5
+ id: string;
6
+ runId: string;
7
+ queue: string;
8
+ status: string;
9
+ availableAt: string;
10
+ idempotencyKey: string;
11
+ createdAt: string;
12
+ updatedAt: string;
13
+ }
14
+ export interface PostgresScheduleRunRecord {
15
+ id: string;
16
+ scheduleId: string;
17
+ runId?: string;
18
+ status: string;
19
+ runAt: string;
20
+ idempotencyKey: string;
21
+ createdAt: string;
22
+ updatedAt: string;
23
+ }
24
+ export declare function enqueueRun(client: QueryClient, runId: string, options?: {
25
+ queue?: string;
26
+ availableAt?: string;
27
+ idempotencyKey?: string;
28
+ }): Promise<PostgresQueueRecord>;
29
+ export declare function enqueueScheduleRun(client: QueryClient, input: {
30
+ scheduleId: string;
31
+ runId?: string;
32
+ runAt: string;
33
+ idempotencyKey: string;
34
+ status?: string;
35
+ }): Promise<PostgresScheduleRunRecord>;
36
+ export declare function reserveIdempotencyKey(client: QueryClient, scope: string, key: string, ownerId?: string): Promise<boolean>;
37
+ export declare function registerSchedule(client: QueryClient, input: {
38
+ id: string;
39
+ name: string;
40
+ cron: string;
41
+ timezone?: string;
42
+ metadata?: JsonObject;
43
+ }): Promise<ScheduleRecord>;
44
+ export declare function recordScheduleRun(client: QueryClient, input: {
45
+ scheduleId: string;
46
+ runId?: string;
47
+ runAt: string;
48
+ idempotencyKey: string;
49
+ status?: string;
50
+ }): Promise<ScheduleRunRecord>;
51
+ export declare function recordFileIndex(client: QueryClient, input: {
52
+ runId?: string;
53
+ path: string;
54
+ kind: FileIndexRecord["kind"];
55
+ blobKey: string;
56
+ sha256: string;
57
+ sizeBytes: number;
58
+ metadata?: JsonObject;
59
+ }): Promise<FileIndexRecord>;
60
+ export declare function listFileIndexes(client: QueryClient, runId?: string): Promise<FileIndexRecord[]>;
61
+ //# sourceMappingURL=adapter-misc.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"adapter-misc.d.ts","sourceRoot":"","sources":["../src/adapter-misc.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAC5D,OAAO,KAAK,EACV,eAAe,EACf,cAAc,EACd,iBAAiB,EAClB,MAAM,8BAA8B,CAAC;AACtC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAIrD,MAAM,WAAW,mBAAmB;IAClC,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,MAAM,CAAC;IACpB,cAAc,EAAE,MAAM,CAAC;IACvB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,yBAAyB;IACxC,EAAE,EAAE,MAAM,CAAC;IACX,UAAU,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,cAAc,EAAE,MAAM,CAAC;IACvB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,wBAAsB,UAAU,CAAC,MAAM,EAAE,WAAW,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,GAAE;IAAE,KAAK,CAAC,EAAE,MA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