@absolutejs/agent 0.23.17 → 0.23.18
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/migrations.d.ts +20 -0
- package/dist/migrations.js +476 -0
- package/dist/migrations.js.map +11 -0
- package/package.json +11 -6
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export type AgentPostgresMigration = {
|
|
2
|
+
digest: string;
|
|
3
|
+
id: string;
|
|
4
|
+
packageName: string;
|
|
5
|
+
packageVersion: string;
|
|
6
|
+
sql: string;
|
|
7
|
+
};
|
|
8
|
+
export type AgentPostgresMigrationClient = {
|
|
9
|
+
query: <Row = Record<string, unknown>>(text: string, values?: ReadonlyArray<unknown>) => Promise<{
|
|
10
|
+
rows: ReadonlyArray<Row>;
|
|
11
|
+
}>;
|
|
12
|
+
};
|
|
13
|
+
export type AgentPostgresMigrationResult = {
|
|
14
|
+
applied: string[];
|
|
15
|
+
skipped: string[];
|
|
16
|
+
};
|
|
17
|
+
/** Complete ordered database contract for the production AbsoluteJS agent stack. */
|
|
18
|
+
export declare const agentPostgresMigrations: () => AgentPostgresMigration[];
|
|
19
|
+
/** Apply every package-owned agent migration once under a cross-replica lock. */
|
|
20
|
+
export declare const applyAgentPostgresMigrations: (client: AgentPostgresMigrationClient) => Promise<AgentPostgresMigrationResult>;
|
|
@@ -0,0 +1,476 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
// src/commerce.ts
|
|
3
|
+
import {
|
|
4
|
+
effectAdapterExecutionInputDigest
|
|
5
|
+
} from "@absolutejs/execution";
|
|
6
|
+
import { and, desc, eq, sql } from "drizzle-orm";
|
|
7
|
+
import {
|
|
8
|
+
bigint,
|
|
9
|
+
customType,
|
|
10
|
+
index,
|
|
11
|
+
pgSchema,
|
|
12
|
+
text,
|
|
13
|
+
uniqueIndex
|
|
14
|
+
} from "drizzle-orm/pg-core";
|
|
15
|
+
|
|
16
|
+
class AgentPurchaseIntentError extends Error {
|
|
17
|
+
}
|
|
18
|
+
var keyOf = (tenantId, purchaseId) => `${tenantId}\x00${purchaseId}`;
|
|
19
|
+
var createMemoryAgentPurchaseIntentStore = () => {
|
|
20
|
+
const records = new Map;
|
|
21
|
+
return {
|
|
22
|
+
get: async (tenantId, purchaseId) => {
|
|
23
|
+
const value = records.get(keyOf(tenantId, purchaseId));
|
|
24
|
+
return value ? structuredClone(value) : undefined;
|
|
25
|
+
},
|
|
26
|
+
getByIdempotencyKey: async (tenantId, idempotencyKey) => {
|
|
27
|
+
const value = [...records.values()].find((intent) => intent.input.tenantId === tenantId && intent.input.idempotencyKey === idempotencyKey);
|
|
28
|
+
return value ? structuredClone(value) : undefined;
|
|
29
|
+
},
|
|
30
|
+
list: async (input) => [...records.values()].filter(({ input: intent, status }) => (!input.tenantId || intent.tenantId === input.tenantId) && (!input.ownerId || intent.ownerId === input.ownerId) && (!input.status || status === input.status)).sort((left, right) => right.createdAt - left.createdAt).slice(0, input.limit).map((value) => structuredClone(value)),
|
|
31
|
+
save: async (intent) => {
|
|
32
|
+
const key = keyOf(intent.input.tenantId, intent.input.purchaseId);
|
|
33
|
+
const existing = records.get(key);
|
|
34
|
+
if (existing && existing.inputDigest !== intent.inputDigest)
|
|
35
|
+
throw new AgentPurchaseIntentError("Purchase identity belongs to another immutable request");
|
|
36
|
+
const idempotent = [...records.values()].find(({ input }) => input.tenantId === intent.input.tenantId && input.idempotencyKey === intent.input.idempotencyKey);
|
|
37
|
+
if (idempotent && idempotent.input.purchaseId !== intent.input.purchaseId)
|
|
38
|
+
throw new AgentPurchaseIntentError("Purchase idempotency key belongs to another request");
|
|
39
|
+
records.set(key, structuredClone(intent));
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
};
|
|
43
|
+
var namespaceOf = (namespace) => {
|
|
44
|
+
if (!/^[a-z_][a-z0-9_]*$/.test(namespace))
|
|
45
|
+
throw new AgentPurchaseIntentError("Purchase intent namespace must be a simple identifier");
|
|
46
|
+
return namespace;
|
|
47
|
+
};
|
|
48
|
+
var portableJsonb = customType({
|
|
49
|
+
dataType: () => "jsonb",
|
|
50
|
+
fromDriver: (value) => typeof value === "string" ? JSON.parse(value) : value,
|
|
51
|
+
toDriver: (value) => JSON.stringify(value)
|
|
52
|
+
});
|
|
53
|
+
var encodedJsonb = (value) => sql`${JSON.stringify(value)}::text::jsonb`;
|
|
54
|
+
var agentPurchaseIntentDrizzleSchema = (namespace = "agent_commerce") => {
|
|
55
|
+
const schema = pgSchema(namespaceOf(namespace));
|
|
56
|
+
const purchaseIntents = schema.table("purchase_intents", {
|
|
57
|
+
created_at: bigint({ mode: "number" }).notNull(),
|
|
58
|
+
data: portableJsonb().$type().notNull(),
|
|
59
|
+
idempotency_key: text().notNull(),
|
|
60
|
+
input_digest: text().notNull(),
|
|
61
|
+
owner_id: text().notNull(),
|
|
62
|
+
purchase_id: text().primaryKey(),
|
|
63
|
+
status: text().$type().notNull(),
|
|
64
|
+
tenant_id: text().notNull(),
|
|
65
|
+
updated_at: bigint({ mode: "number" }).notNull()
|
|
66
|
+
}, (table) => [
|
|
67
|
+
uniqueIndex("purchase_intents_tenant_idempotency_idx").on(table.tenant_id, table.idempotency_key),
|
|
68
|
+
uniqueIndex("purchase_intents_tenant_purchase_idx").on(table.tenant_id, table.purchase_id),
|
|
69
|
+
index("purchase_intents_inventory_idx").on(table.tenant_id, table.created_at.desc()),
|
|
70
|
+
index("purchase_intents_owner_idx").on(table.owner_id, table.created_at.desc())
|
|
71
|
+
]);
|
|
72
|
+
return { purchaseIntents };
|
|
73
|
+
};
|
|
74
|
+
var createDrizzleAgentPurchaseIntentStore = (db, options = {}) => {
|
|
75
|
+
const { purchaseIntents } = agentPurchaseIntentDrizzleSchema(options.namespace);
|
|
76
|
+
const first = async (conditions) => {
|
|
77
|
+
const [row] = await db.select({ data: purchaseIntents.data }).from(purchaseIntents).where(and(...conditions)).limit(1);
|
|
78
|
+
return row?.data;
|
|
79
|
+
};
|
|
80
|
+
return {
|
|
81
|
+
get: (tenantId, purchaseId) => first([
|
|
82
|
+
eq(purchaseIntents.tenant_id, tenantId),
|
|
83
|
+
eq(purchaseIntents.purchase_id, purchaseId)
|
|
84
|
+
]),
|
|
85
|
+
getByIdempotencyKey: (tenantId, idempotencyKey) => first([
|
|
86
|
+
eq(purchaseIntents.tenant_id, tenantId),
|
|
87
|
+
eq(purchaseIntents.idempotency_key, idempotencyKey)
|
|
88
|
+
]),
|
|
89
|
+
list: async (input) => {
|
|
90
|
+
const conditions = [];
|
|
91
|
+
if (input.tenantId)
|
|
92
|
+
conditions.push(eq(purchaseIntents.tenant_id, input.tenantId));
|
|
93
|
+
if (input.ownerId)
|
|
94
|
+
conditions.push(eq(purchaseIntents.owner_id, input.ownerId));
|
|
95
|
+
if (input.status)
|
|
96
|
+
conditions.push(eq(purchaseIntents.status, input.status));
|
|
97
|
+
const rows = await db.select({ data: purchaseIntents.data }).from(purchaseIntents).where(and(...conditions)).orderBy(desc(purchaseIntents.created_at)).limit(input.limit);
|
|
98
|
+
return rows.map(({ data }) => data);
|
|
99
|
+
},
|
|
100
|
+
save: async (intent) => {
|
|
101
|
+
const rows = await db.insert(purchaseIntents).values({
|
|
102
|
+
created_at: intent.createdAt,
|
|
103
|
+
data: encodedJsonb(intent),
|
|
104
|
+
idempotency_key: intent.input.idempotencyKey,
|
|
105
|
+
input_digest: intent.inputDigest,
|
|
106
|
+
owner_id: intent.input.ownerId,
|
|
107
|
+
purchase_id: intent.input.purchaseId,
|
|
108
|
+
status: intent.status,
|
|
109
|
+
tenant_id: intent.input.tenantId,
|
|
110
|
+
updated_at: intent.updatedAt
|
|
111
|
+
}).onConflictDoUpdate({
|
|
112
|
+
set: {
|
|
113
|
+
data: encodedJsonb(intent),
|
|
114
|
+
status: intent.status,
|
|
115
|
+
updated_at: intent.updatedAt
|
|
116
|
+
},
|
|
117
|
+
setWhere: and(eq(purchaseIntents.tenant_id, intent.input.tenantId), eq(purchaseIntents.input_digest, intent.inputDigest), eq(purchaseIntents.idempotency_key, intent.input.idempotencyKey)),
|
|
118
|
+
target: purchaseIntents.purchase_id
|
|
119
|
+
}).returning({ id: purchaseIntents.purchase_id });
|
|
120
|
+
if (rows.length !== 1)
|
|
121
|
+
throw new AgentPurchaseIntentError("Purchase identity belongs to another immutable request");
|
|
122
|
+
}
|
|
123
|
+
};
|
|
124
|
+
};
|
|
125
|
+
var agentPurchaseIntentsPostgresSchemaSql = (namespace = "agent_commerce") => {
|
|
126
|
+
const ns = namespaceOf(namespace);
|
|
127
|
+
return `CREATE SCHEMA IF NOT EXISTS ${ns};
|
|
128
|
+
CREATE TABLE IF NOT EXISTS ${ns}.purchase_intents (
|
|
129
|
+
purchase_id text PRIMARY KEY,
|
|
130
|
+
tenant_id text NOT NULL,
|
|
131
|
+
owner_id text NOT NULL,
|
|
132
|
+
idempotency_key text NOT NULL,
|
|
133
|
+
status text NOT NULL,
|
|
134
|
+
input_digest text NOT NULL,
|
|
135
|
+
data jsonb NOT NULL,
|
|
136
|
+
created_at bigint NOT NULL,
|
|
137
|
+
updated_at bigint NOT NULL,
|
|
138
|
+
UNIQUE (tenant_id, idempotency_key),
|
|
139
|
+
UNIQUE (tenant_id, purchase_id)
|
|
140
|
+
);
|
|
141
|
+
CREATE INDEX IF NOT EXISTS purchase_intents_inventory_idx ON ${ns}.purchase_intents (tenant_id, created_at DESC);
|
|
142
|
+
CREATE INDEX IF NOT EXISTS purchase_intents_owner_idx ON ${ns}.purchase_intents (owner_id, created_at DESC);`;
|
|
143
|
+
};
|
|
144
|
+
var parseRow = (row) => {
|
|
145
|
+
if (!row)
|
|
146
|
+
return;
|
|
147
|
+
return typeof row.data === "string" ? JSON.parse(row.data) : row.data;
|
|
148
|
+
};
|
|
149
|
+
var createPostgresAgentPurchaseIntentStore = (options) => {
|
|
150
|
+
const ns = namespaceOf(options.namespace ?? "agent_commerce");
|
|
151
|
+
return {
|
|
152
|
+
get: async (tenantId, purchaseId) => parseRow((await options.client.query(`SELECT data FROM ${ns}.purchase_intents WHERE tenant_id = $1 AND purchase_id = $2`, [tenantId, purchaseId])).rows[0]),
|
|
153
|
+
getByIdempotencyKey: async (tenantId, idempotencyKey) => parseRow((await options.client.query(`SELECT data FROM ${ns}.purchase_intents WHERE tenant_id = $1 AND idempotency_key = $2`, [tenantId, idempotencyKey])).rows[0]),
|
|
154
|
+
list: async (input) => {
|
|
155
|
+
const clauses = [];
|
|
156
|
+
const values = [];
|
|
157
|
+
if (input.tenantId) {
|
|
158
|
+
values.push(input.tenantId);
|
|
159
|
+
clauses.push(`tenant_id = $${values.length}`);
|
|
160
|
+
}
|
|
161
|
+
if (input.ownerId) {
|
|
162
|
+
values.push(input.ownerId);
|
|
163
|
+
clauses.push(`owner_id = $${values.length}`);
|
|
164
|
+
}
|
|
165
|
+
if (input.status) {
|
|
166
|
+
values.push(input.status);
|
|
167
|
+
clauses.push(`status = $${values.length}`);
|
|
168
|
+
}
|
|
169
|
+
values.push(input.limit);
|
|
170
|
+
const where = clauses.length > 0 ? ` WHERE ${clauses.join(" AND ")}` : "";
|
|
171
|
+
const result = await options.client.query(`SELECT data FROM ${ns}.purchase_intents${where} ORDER BY created_at DESC LIMIT $${values.length}`, values);
|
|
172
|
+
return result.rows.map((row) => parseRow(row));
|
|
173
|
+
},
|
|
174
|
+
save: async (intent) => {
|
|
175
|
+
const result = await options.client.query(`INSERT INTO ${ns}.purchase_intents
|
|
176
|
+
(purchase_id, tenant_id, owner_id, idempotency_key, status, input_digest, data, created_at, updated_at)
|
|
177
|
+
VALUES ($1, $2, $3, $4, $5, $6, $7::jsonb, $8, $9)
|
|
178
|
+
ON CONFLICT (purchase_id) DO UPDATE SET
|
|
179
|
+
status = excluded.status,
|
|
180
|
+
data = excluded.data,
|
|
181
|
+
updated_at = excluded.updated_at
|
|
182
|
+
WHERE ${ns}.purchase_intents.tenant_id = excluded.tenant_id
|
|
183
|
+
AND ${ns}.purchase_intents.input_digest = excluded.input_digest
|
|
184
|
+
AND ${ns}.purchase_intents.idempotency_key = excluded.idempotency_key
|
|
185
|
+
RETURNING purchase_id`, [
|
|
186
|
+
intent.input.purchaseId,
|
|
187
|
+
intent.input.tenantId,
|
|
188
|
+
intent.input.ownerId,
|
|
189
|
+
intent.input.idempotencyKey,
|
|
190
|
+
intent.status,
|
|
191
|
+
intent.inputDigest,
|
|
192
|
+
JSON.stringify(intent),
|
|
193
|
+
intent.createdAt,
|
|
194
|
+
intent.updatedAt
|
|
195
|
+
]);
|
|
196
|
+
if (result.rows.length !== 1)
|
|
197
|
+
throw new AgentPurchaseIntentError("Purchase identity belongs to another immutable request");
|
|
198
|
+
}
|
|
199
|
+
};
|
|
200
|
+
};
|
|
201
|
+
var createAgentPurchaseOrchestrator = (options) => {
|
|
202
|
+
const now = options.now ?? Date.now;
|
|
203
|
+
const saveStatus = async (intent, status, mandate) => {
|
|
204
|
+
let mandateSummary;
|
|
205
|
+
if (mandate) {
|
|
206
|
+
const { signature, ...summary } = mandate;
|
|
207
|
+
mandateSummary = summary;
|
|
208
|
+
}
|
|
209
|
+
const next = {
|
|
210
|
+
...intent,
|
|
211
|
+
...mandateSummary ? { mandate: mandateSummary } : {},
|
|
212
|
+
status,
|
|
213
|
+
updatedAt: now()
|
|
214
|
+
};
|
|
215
|
+
await options.store.save(next);
|
|
216
|
+
return next;
|
|
217
|
+
};
|
|
218
|
+
const submit = async (input) => {
|
|
219
|
+
if (!input.purchaseId.trim() || !input.idempotencyKey.trim())
|
|
220
|
+
throw new AgentPurchaseIntentError("Purchase and idempotency identities are required");
|
|
221
|
+
if (!Number.isSafeInteger(input.amountMinor) || input.amountMinor <= 0)
|
|
222
|
+
throw new AgentPurchaseIntentError("Purchase amount must be positive integer minor units");
|
|
223
|
+
const mandateId = `mandate:purchase:${input.purchaseId}`;
|
|
224
|
+
const effectId = `purchase:${input.purchaseId}`;
|
|
225
|
+
const envelope = {
|
|
226
|
+
currency: input.currency,
|
|
227
|
+
...input.destination ? { destination: input.destination } : {},
|
|
228
|
+
effect: input.effect,
|
|
229
|
+
installationId: input.installationId,
|
|
230
|
+
mandateId,
|
|
231
|
+
payload: input.payload,
|
|
232
|
+
spendMinor: input.amountMinor
|
|
233
|
+
};
|
|
234
|
+
const inputDigest = await effectAdapterExecutionInputDigest(envelope);
|
|
235
|
+
const existing = await options.store.get(input.tenantId, input.purchaseId);
|
|
236
|
+
const idempotent = await options.store.getByIdempotencyKey(input.tenantId, input.idempotencyKey);
|
|
237
|
+
const prior = existing ?? idempotent;
|
|
238
|
+
if (prior) {
|
|
239
|
+
if (prior.input.purchaseId !== input.purchaseId || prior.inputDigest !== inputDigest)
|
|
240
|
+
throw new AgentPurchaseIntentError("Purchase identity belongs to another immutable request");
|
|
241
|
+
if (prior.status === "enqueued" || prior.status === "cancelled")
|
|
242
|
+
return prior;
|
|
243
|
+
}
|
|
244
|
+
let intent = prior ?? {
|
|
245
|
+
createdAt: now(),
|
|
246
|
+
effectId,
|
|
247
|
+
envelope,
|
|
248
|
+
input,
|
|
249
|
+
inputDigest,
|
|
250
|
+
mandateId,
|
|
251
|
+
status: "drafted",
|
|
252
|
+
updatedAt: now()
|
|
253
|
+
};
|
|
254
|
+
await options.store.save(intent);
|
|
255
|
+
const spendRequest = {
|
|
256
|
+
action: input.effect,
|
|
257
|
+
agentId: input.agentId,
|
|
258
|
+
allowanceId: input.allowanceId,
|
|
259
|
+
amountCents: input.amountMinor,
|
|
260
|
+
cartHash: inputDigest,
|
|
261
|
+
...input.category ? { category: input.category } : {},
|
|
262
|
+
currency: input.currency,
|
|
263
|
+
expiresAt: input.expiresAt,
|
|
264
|
+
idempotencyKey: `purchase:${input.idempotencyKey}`,
|
|
265
|
+
merchantId: input.merchantId,
|
|
266
|
+
...input.refundable === undefined ? {} : { refundable: input.refundable }
|
|
267
|
+
};
|
|
268
|
+
const requested = await options.wallet.requestSpend(spendRequest, {
|
|
269
|
+
mandateId
|
|
270
|
+
});
|
|
271
|
+
if (requested.mandate.status === "pending_approval")
|
|
272
|
+
return await saveStatus(intent, "pending_approval", requested.mandate);
|
|
273
|
+
if (requested.mandate.status !== "active")
|
|
274
|
+
throw new AgentPurchaseIntentError(`Purchase mandate is ${requested.mandate.status}`);
|
|
275
|
+
intent = await saveStatus(intent, "mandate_ready", requested.mandate);
|
|
276
|
+
await options.installations.put({
|
|
277
|
+
adapterId: input.adapterId,
|
|
278
|
+
installationId: input.installationId,
|
|
279
|
+
policy: {
|
|
280
|
+
credentials: input.credentials ?? [],
|
|
281
|
+
destinations: input.destination ? [input.destination] : [],
|
|
282
|
+
effects: [input.effect],
|
|
283
|
+
spend: {
|
|
284
|
+
currency: input.currency,
|
|
285
|
+
mandateId,
|
|
286
|
+
maxMinorPerEffect: input.amountMinor
|
|
287
|
+
}
|
|
288
|
+
},
|
|
289
|
+
tenantId: input.tenantId
|
|
290
|
+
});
|
|
291
|
+
await options.installations.enable(input.tenantId, input.installationId);
|
|
292
|
+
intent = await saveStatus(intent, "installation_ready");
|
|
293
|
+
const timestamp = now();
|
|
294
|
+
const effect = {
|
|
295
|
+
actionId: input.actionId,
|
|
296
|
+
attempts: 0,
|
|
297
|
+
availableAt: timestamp,
|
|
298
|
+
createdAt: timestamp,
|
|
299
|
+
effectId,
|
|
300
|
+
handler: input.handler,
|
|
301
|
+
idempotencyKey: `purchase:${input.idempotencyKey}`,
|
|
302
|
+
input: envelope,
|
|
303
|
+
inputDigest,
|
|
304
|
+
status: "pending",
|
|
305
|
+
tenantId: input.tenantId,
|
|
306
|
+
updatedAt: timestamp
|
|
307
|
+
};
|
|
308
|
+
if (!await options.effects.enqueue(effect)) {
|
|
309
|
+
const duplicate = await options.effects.getByIdempotencyKey(input.tenantId, effect.idempotencyKey);
|
|
310
|
+
if (!duplicate || duplicate.effectId !== effect.effectId || duplicate.inputDigest !== effect.inputDigest) {
|
|
311
|
+
await options.installations.disable(input.tenantId, input.installationId);
|
|
312
|
+
await options.wallet.cancelSpend(mandateId);
|
|
313
|
+
throw new AgentPurchaseIntentError("Purchase effect idempotency key belongs to another request");
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
return await saveStatus(intent, "enqueued");
|
|
317
|
+
};
|
|
318
|
+
return {
|
|
319
|
+
list: options.store.list,
|
|
320
|
+
submit
|
|
321
|
+
};
|
|
322
|
+
};
|
|
323
|
+
|
|
324
|
+
// src/migrations.ts
|
|
325
|
+
import { createHash } from "crypto";
|
|
326
|
+
import { a2aPostgresSchemaSql } from "@absolutejs/a2a";
|
|
327
|
+
import { agencyPostgresMigrations } from "@absolutejs/agency";
|
|
328
|
+
import { agentControlPostgresSchemaSql } from "@absolutejs/agent-control";
|
|
329
|
+
import { agentInboxPostgresSchemaSql } from "@absolutejs/agent-inbox";
|
|
330
|
+
import { agentMemoryPostgresSchemaSql } from "@absolutejs/agent-memory";
|
|
331
|
+
import { agentRuntimePostgresSchemaSql } from "@absolutejs/agent-runtime";
|
|
332
|
+
import { executionPostgresMigrations } from "@absolutejs/execution";
|
|
333
|
+
import { mcpPostgresSchemaSql } from "@absolutejs/mcp";
|
|
334
|
+
import {
|
|
335
|
+
walletAgentTenantInventoryPostgresSchemaSql,
|
|
336
|
+
walletPostgresSchemaSql
|
|
337
|
+
} from "@absolutejs/wallet";
|
|
338
|
+
var LOCK_KEY = "absolutejs:agent:migrations";
|
|
339
|
+
var JOURNAL_TABLE = "absolutejs_agent_migrations";
|
|
340
|
+
var JOURNAL_SQL = `CREATE TABLE IF NOT EXISTS ${JOURNAL_TABLE} (
|
|
341
|
+
id text PRIMARY KEY,
|
|
342
|
+
package_name text NOT NULL,
|
|
343
|
+
package_version text NOT NULL,
|
|
344
|
+
digest text NOT NULL,
|
|
345
|
+
applied_at timestamptz NOT NULL DEFAULT now()
|
|
346
|
+
)`;
|
|
347
|
+
var definitions = [
|
|
348
|
+
...agencyPostgresMigrations().map((migration) => ({
|
|
349
|
+
...migration,
|
|
350
|
+
packageName: "@absolutejs/agency",
|
|
351
|
+
packageVersion: migration.id.split("@").at(-1) ?? "unknown"
|
|
352
|
+
})),
|
|
353
|
+
{
|
|
354
|
+
id: "agent-runtime@0.1.0",
|
|
355
|
+
packageName: "@absolutejs/agent-runtime",
|
|
356
|
+
packageVersion: "0.1.0",
|
|
357
|
+
sql: agentRuntimePostgresSchemaSql()
|
|
358
|
+
},
|
|
359
|
+
{
|
|
360
|
+
id: "agent-memory@0.1.0",
|
|
361
|
+
packageName: "@absolutejs/agent-memory",
|
|
362
|
+
packageVersion: "0.1.0",
|
|
363
|
+
sql: agentMemoryPostgresSchemaSql()
|
|
364
|
+
},
|
|
365
|
+
{
|
|
366
|
+
id: "agent-inbox@0.1.0",
|
|
367
|
+
packageName: "@absolutejs/agent-inbox",
|
|
368
|
+
packageVersion: "0.1.0",
|
|
369
|
+
sql: agentInboxPostgresSchemaSql()
|
|
370
|
+
},
|
|
371
|
+
{
|
|
372
|
+
id: "mcp@0.10.1",
|
|
373
|
+
packageName: "@absolutejs/mcp",
|
|
374
|
+
packageVersion: "0.10.1",
|
|
375
|
+
sql: mcpPostgresSchemaSql()
|
|
376
|
+
},
|
|
377
|
+
{
|
|
378
|
+
id: "a2a@0.2.2",
|
|
379
|
+
packageName: "@absolutejs/a2a",
|
|
380
|
+
packageVersion: "0.2.2",
|
|
381
|
+
sql: a2aPostgresSchemaSql()
|
|
382
|
+
},
|
|
383
|
+
{
|
|
384
|
+
id: "wallet@0.3.0",
|
|
385
|
+
packageName: "@absolutejs/wallet",
|
|
386
|
+
packageVersion: "0.3.0",
|
|
387
|
+
sql: walletPostgresSchemaSql()
|
|
388
|
+
},
|
|
389
|
+
{
|
|
390
|
+
id: "wallet-agent-tenant-inventory@0.5.0",
|
|
391
|
+
packageName: "@absolutejs/wallet",
|
|
392
|
+
packageVersion: "0.5.0",
|
|
393
|
+
sql: walletAgentTenantInventoryPostgresSchemaSql()
|
|
394
|
+
},
|
|
395
|
+
{
|
|
396
|
+
id: "agent-control@0.4.0",
|
|
397
|
+
packageName: "@absolutejs/agent-control",
|
|
398
|
+
packageVersion: "0.4.0",
|
|
399
|
+
sql: agentControlPostgresSchemaSql()
|
|
400
|
+
},
|
|
401
|
+
...executionPostgresMigrations(),
|
|
402
|
+
{
|
|
403
|
+
id: "agent-commerce-purchase-intents@0.23.1",
|
|
404
|
+
packageName: "@absolutejs/agent",
|
|
405
|
+
packageVersion: "0.23.1",
|
|
406
|
+
sql: agentPurchaseIntentsPostgresSchemaSql()
|
|
407
|
+
}
|
|
408
|
+
];
|
|
409
|
+
var digest = (value) => createHash("sha256").update(value).digest("hex");
|
|
410
|
+
var agentPostgresMigrations = () => definitions.map((migration) => ({
|
|
411
|
+
...migration,
|
|
412
|
+
digest: digest(migration.sql)
|
|
413
|
+
}));
|
|
414
|
+
var rollback = async (client) => {
|
|
415
|
+
try {
|
|
416
|
+
await client.query("ROLLBACK");
|
|
417
|
+
} catch {}
|
|
418
|
+
};
|
|
419
|
+
var migrationDisposition = async (client, migration) => {
|
|
420
|
+
const existing = await client.query(`SELECT digest FROM ${JOURNAL_TABLE} WHERE id = $1 FOR UPDATE`, [migration.id]);
|
|
421
|
+
const [recorded] = existing.rows;
|
|
422
|
+
if (!recorded)
|
|
423
|
+
return "applied";
|
|
424
|
+
if (recorded.digest !== migration.digest) {
|
|
425
|
+
throw new Error(`Agent migration ${migration.id} changed after it was applied`);
|
|
426
|
+
}
|
|
427
|
+
return "skipped";
|
|
428
|
+
};
|
|
429
|
+
var recordMigration = async (client, migration) => {
|
|
430
|
+
await client.query(migration.sql);
|
|
431
|
+
await client.query(`INSERT INTO ${JOURNAL_TABLE}
|
|
432
|
+
(id, package_name, package_version, digest)
|
|
433
|
+
VALUES ($1, $2, $3, $4)`, [
|
|
434
|
+
migration.id,
|
|
435
|
+
migration.packageName,
|
|
436
|
+
migration.packageVersion,
|
|
437
|
+
migration.digest
|
|
438
|
+
]);
|
|
439
|
+
};
|
|
440
|
+
var migrateOne = async (client, migration, result) => {
|
|
441
|
+
await client.query("BEGIN");
|
|
442
|
+
try {
|
|
443
|
+
const disposition = await migrationDisposition(client, migration);
|
|
444
|
+
if (disposition === "applied")
|
|
445
|
+
await recordMigration(client, migration);
|
|
446
|
+
result[disposition].push(migration.id);
|
|
447
|
+
await client.query("COMMIT");
|
|
448
|
+
} catch (error) {
|
|
449
|
+
await rollback(client);
|
|
450
|
+
throw error;
|
|
451
|
+
}
|
|
452
|
+
};
|
|
453
|
+
var applyAgentPostgresMigrations = async (client) => {
|
|
454
|
+
const result = { applied: [], skipped: [] };
|
|
455
|
+
await client.query("SELECT pg_advisory_lock(hashtextextended($1, 0))", [
|
|
456
|
+
LOCK_KEY
|
|
457
|
+
]);
|
|
458
|
+
try {
|
|
459
|
+
await client.query(JOURNAL_SQL);
|
|
460
|
+
for (const migration of agentPostgresMigrations()) {
|
|
461
|
+
await migrateOne(client, migration, result);
|
|
462
|
+
}
|
|
463
|
+
} finally {
|
|
464
|
+
await client.query("SELECT pg_advisory_unlock(hashtextextended($1, 0))", [
|
|
465
|
+
LOCK_KEY
|
|
466
|
+
]);
|
|
467
|
+
}
|
|
468
|
+
return result;
|
|
469
|
+
};
|
|
470
|
+
export {
|
|
471
|
+
applyAgentPostgresMigrations,
|
|
472
|
+
agentPostgresMigrations
|
|
473
|
+
};
|
|
474
|
+
|
|
475
|
+
//# debugId=53A41277E62BDD0864756E2164756E21
|
|
476
|
+
//# sourceMappingURL=migrations.js.map
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/commerce.ts", "../src/migrations.ts"],
|
|
4
|
+
"sourcesContent": [
|
|
5
|
+
"import {\n effectAdapterExecutionInputDigest,\n type EffectAdapterCredentialInstallation,\n type EffectAdapterExecutionEnvelope,\n type EffectAdapterInstallationRegistry,\n type EffectRecord,\n type EffectStore,\n type ExecutionSqlClient,\n} from \"@absolutejs/execution\";\nimport type {\n AgentSpendRequest,\n SpendRequestResult,\n SpendMandate,\n} from \"@absolutejs/wallet\";\nimport { and, desc, eq, sql, type SQL } from \"drizzle-orm\";\nimport {\n bigint,\n customType,\n index,\n pgSchema,\n text,\n uniqueIndex,\n type PgAsyncDatabase,\n} from \"drizzle-orm/pg-core\";\n\nexport type AgentPurchaseIntentStatus =\n | \"drafted\"\n | \"pending_approval\"\n | \"mandate_ready\"\n | \"installation_ready\"\n | \"enqueued\"\n | \"cancelled\";\n\nexport type AgentPurchaseIntentInput<Payload = unknown> = {\n actionId: string;\n adapterId: string;\n agentId: string;\n allowanceId: string;\n amountMinor: number;\n category?: string;\n credentials?: ReadonlyArray<EffectAdapterCredentialInstallation>;\n currency: string;\n destination?: string;\n effect: string;\n expiresAt: string;\n handler: string;\n idempotencyKey: string;\n installationId: string;\n merchantId: string;\n ownerId: string;\n payload: Payload;\n purchaseId: string;\n refundable?: boolean;\n tenantId: string;\n};\n\nexport type AgentPurchaseIntent<Payload = unknown> = {\n createdAt: number;\n effectId: string;\n envelope: EffectAdapterExecutionEnvelope<Payload>;\n input: AgentPurchaseIntentInput<Payload>;\n inputDigest: string;\n mandate?: Omit<SpendMandate, \"signature\">;\n mandateId: string;\n status: AgentPurchaseIntentStatus;\n updatedAt: number;\n};\n\nexport type AgentPurchaseIntentStore = {\n get: (\n tenantId: string,\n purchaseId: string,\n ) => Promise<AgentPurchaseIntent | undefined>;\n getByIdempotencyKey: (\n tenantId: string,\n idempotencyKey: string,\n ) => Promise<AgentPurchaseIntent | undefined>;\n list: (input: {\n limit: number;\n ownerId?: string;\n status?: AgentPurchaseIntentStatus;\n tenantId?: string;\n }) => Promise<AgentPurchaseIntent[]>;\n save: (intent: AgentPurchaseIntent) => Promise<void>;\n};\n\nexport class AgentPurchaseIntentError extends Error {}\n\nconst keyOf = (tenantId: string, purchaseId: string) =>\n `${tenantId}\\u0000${purchaseId}`;\n\nexport const createMemoryAgentPurchaseIntentStore =\n (): AgentPurchaseIntentStore => {\n const records = new Map<string, AgentPurchaseIntent>();\n return {\n get: async (tenantId, purchaseId) => {\n const value = records.get(keyOf(tenantId, purchaseId));\n return value ? structuredClone(value) : undefined;\n },\n getByIdempotencyKey: async (tenantId, idempotencyKey) => {\n const value = [...records.values()].find(\n (intent) =>\n intent.input.tenantId === tenantId &&\n intent.input.idempotencyKey === idempotencyKey,\n );\n return value ? structuredClone(value) : undefined;\n },\n list: async (input) =>\n [...records.values()]\n .filter(\n ({ input: intent, status }) =>\n (!input.tenantId || intent.tenantId === input.tenantId) &&\n (!input.ownerId || intent.ownerId === input.ownerId) &&\n (!input.status || status === input.status),\n )\n .sort((left, right) => right.createdAt - left.createdAt)\n .slice(0, input.limit)\n .map((value) => structuredClone(value)),\n save: async (intent) => {\n const key = keyOf(intent.input.tenantId, intent.input.purchaseId);\n const existing = records.get(key);\n if (existing && existing.inputDigest !== intent.inputDigest)\n throw new AgentPurchaseIntentError(\n \"Purchase identity belongs to another immutable request\",\n );\n const idempotent = [...records.values()].find(\n ({ input }) =>\n input.tenantId === intent.input.tenantId &&\n input.idempotencyKey === intent.input.idempotencyKey,\n );\n if (\n idempotent &&\n idempotent.input.purchaseId !== intent.input.purchaseId\n )\n throw new AgentPurchaseIntentError(\n \"Purchase idempotency key belongs to another request\",\n );\n records.set(key, structuredClone(intent));\n },\n };\n };\n\nconst namespaceOf = (namespace: string) => {\n if (!/^[a-z_][a-z0-9_]*$/.test(namespace))\n throw new AgentPurchaseIntentError(\n \"Purchase intent namespace must be a simple identifier\",\n );\n return namespace;\n};\n\ntype AnyPgDatabase = PgAsyncDatabase<any, any>;\nconst portableJsonb = customType<{ data: unknown; driverData: unknown }>({\n dataType: () => \"jsonb\",\n fromDriver: (value) =>\n typeof value === \"string\" ? JSON.parse(value) : value,\n toDriver: (value) => JSON.stringify(value),\n});\nconst encodedJsonb = <Value>(value: Value) =>\n sql<Value>`${JSON.stringify(value)}::text::jsonb`;\n\nexport const agentPurchaseIntentDrizzleSchema = (\n namespace = \"agent_commerce\",\n) => {\n const schema = pgSchema(namespaceOf(namespace));\n const purchaseIntents = schema.table(\n \"purchase_intents\",\n {\n created_at: bigint({ mode: \"number\" }).notNull(),\n data: portableJsonb().$type<AgentPurchaseIntent>().notNull(),\n idempotency_key: text().notNull(),\n input_digest: text().notNull(),\n owner_id: text().notNull(),\n purchase_id: text().primaryKey(),\n status: text().$type<AgentPurchaseIntentStatus>().notNull(),\n tenant_id: text().notNull(),\n updated_at: bigint({ mode: \"number\" }).notNull(),\n },\n (table) => [\n uniqueIndex(\"purchase_intents_tenant_idempotency_idx\").on(\n table.tenant_id,\n table.idempotency_key,\n ),\n uniqueIndex(\"purchase_intents_tenant_purchase_idx\").on(\n table.tenant_id,\n table.purchase_id,\n ),\n index(\"purchase_intents_inventory_idx\").on(\n table.tenant_id,\n table.created_at.desc(),\n ),\n index(\"purchase_intents_owner_idx\").on(\n table.owner_id,\n table.created_at.desc(),\n ),\n ],\n );\n\n return { purchaseIntents };\n};\n\nexport const createDrizzleAgentPurchaseIntentStore = <DB extends AnyPgDatabase>(\n db: DB,\n options: { namespace?: string } = {},\n): AgentPurchaseIntentStore => {\n const { purchaseIntents } = agentPurchaseIntentDrizzleSchema(\n options.namespace,\n );\n const first = async (conditions: SQL[]) => {\n const [row] = await db\n .select({ data: purchaseIntents.data })\n .from(purchaseIntents)\n .where(and(...conditions))\n .limit(1);\n\n return row?.data;\n };\n\n return {\n get: (tenantId, purchaseId) =>\n first([\n eq(purchaseIntents.tenant_id, tenantId),\n eq(purchaseIntents.purchase_id, purchaseId),\n ]),\n getByIdempotencyKey: (tenantId, idempotencyKey) =>\n first([\n eq(purchaseIntents.tenant_id, tenantId),\n eq(purchaseIntents.idempotency_key, idempotencyKey),\n ]),\n list: async (input) => {\n const conditions: SQL[] = [];\n if (input.tenantId)\n conditions.push(eq(purchaseIntents.tenant_id, input.tenantId));\n if (input.ownerId)\n conditions.push(eq(purchaseIntents.owner_id, input.ownerId));\n if (input.status)\n conditions.push(eq(purchaseIntents.status, input.status));\n\n const rows = await db\n .select({ data: purchaseIntents.data })\n .from(purchaseIntents)\n .where(and(...conditions))\n .orderBy(desc(purchaseIntents.created_at))\n .limit(input.limit);\n\n return rows.map(({ data }) => data);\n },\n save: async (intent) => {\n const rows = await db\n .insert(purchaseIntents)\n .values({\n created_at: intent.createdAt,\n data: encodedJsonb(intent),\n idempotency_key: intent.input.idempotencyKey,\n input_digest: intent.inputDigest,\n owner_id: intent.input.ownerId,\n purchase_id: intent.input.purchaseId,\n status: intent.status,\n tenant_id: intent.input.tenantId,\n updated_at: intent.updatedAt,\n })\n .onConflictDoUpdate({\n set: {\n data: encodedJsonb(intent),\n status: intent.status,\n updated_at: intent.updatedAt,\n },\n setWhere: and(\n eq(purchaseIntents.tenant_id, intent.input.tenantId),\n eq(purchaseIntents.input_digest, intent.inputDigest),\n eq(purchaseIntents.idempotency_key, intent.input.idempotencyKey),\n ),\n target: purchaseIntents.purchase_id,\n })\n .returning({ id: purchaseIntents.purchase_id });\n if (rows.length !== 1)\n throw new AgentPurchaseIntentError(\n \"Purchase identity belongs to another immutable request\",\n );\n },\n };\n};\n\nexport const agentPurchaseIntentsPostgresSchemaSql = (\n namespace = \"agent_commerce\",\n) => {\n const ns = namespaceOf(namespace);\n return `CREATE SCHEMA IF NOT EXISTS ${ns};\nCREATE TABLE IF NOT EXISTS ${ns}.purchase_intents (\n purchase_id text PRIMARY KEY,\n tenant_id text NOT NULL,\n owner_id text NOT NULL,\n idempotency_key text NOT NULL,\n status text NOT NULL,\n input_digest text NOT NULL,\n data jsonb NOT NULL,\n created_at bigint NOT NULL,\n updated_at bigint NOT NULL,\n UNIQUE (tenant_id, idempotency_key),\n UNIQUE (tenant_id, purchase_id)\n);\nCREATE INDEX IF NOT EXISTS purchase_intents_inventory_idx ON ${ns}.purchase_intents (tenant_id, created_at DESC);\nCREATE INDEX IF NOT EXISTS purchase_intents_owner_idx ON ${ns}.purchase_intents (owner_id, created_at DESC);`;\n};\n\ntype AgentPurchaseIntentRow = { data: AgentPurchaseIntent | string };\nconst parseRow = (row: AgentPurchaseIntentRow | undefined) => {\n if (!row) return undefined;\n return (\n typeof row.data === \"string\" ? JSON.parse(row.data) : row.data\n ) as AgentPurchaseIntent;\n};\n\nexport const createPostgresAgentPurchaseIntentStore = (options: {\n client: ExecutionSqlClient;\n namespace?: string;\n}): AgentPurchaseIntentStore => {\n const ns = namespaceOf(options.namespace ?? \"agent_commerce\");\n return {\n get: async (tenantId, purchaseId) =>\n parseRow(\n (\n await options.client.query<AgentPurchaseIntentRow>(\n `SELECT data FROM ${ns}.purchase_intents WHERE tenant_id = $1 AND purchase_id = $2`,\n [tenantId, purchaseId],\n )\n ).rows[0],\n ),\n getByIdempotencyKey: async (tenantId, idempotencyKey) =>\n parseRow(\n (\n await options.client.query<AgentPurchaseIntentRow>(\n `SELECT data FROM ${ns}.purchase_intents WHERE tenant_id = $1 AND idempotency_key = $2`,\n [tenantId, idempotencyKey],\n )\n ).rows[0],\n ),\n list: async (input) => {\n const clauses: string[] = [];\n const values: unknown[] = [];\n if (input.tenantId) {\n values.push(input.tenantId);\n clauses.push(`tenant_id = $${values.length}`);\n }\n if (input.ownerId) {\n values.push(input.ownerId);\n clauses.push(`owner_id = $${values.length}`);\n }\n if (input.status) {\n values.push(input.status);\n clauses.push(`status = $${values.length}`);\n }\n values.push(input.limit);\n const where = clauses.length > 0 ? ` WHERE ${clauses.join(\" AND \")}` : \"\";\n const result = await options.client.query<AgentPurchaseIntentRow>(\n `SELECT data FROM ${ns}.purchase_intents${where} ORDER BY created_at DESC LIMIT $${values.length}`,\n values,\n );\n return result.rows.map((row) => parseRow(row)!);\n },\n save: async (intent) => {\n const result = await options.client.query<{ purchase_id: string }>(\n `INSERT INTO ${ns}.purchase_intents\n (purchase_id, tenant_id, owner_id, idempotency_key, status, input_digest, data, created_at, updated_at)\n VALUES ($1, $2, $3, $4, $5, $6, $7::jsonb, $8, $9)\n ON CONFLICT (purchase_id) DO UPDATE SET\n status = excluded.status,\n data = excluded.data,\n updated_at = excluded.updated_at\n WHERE ${ns}.purchase_intents.tenant_id = excluded.tenant_id\n AND ${ns}.purchase_intents.input_digest = excluded.input_digest\n AND ${ns}.purchase_intents.idempotency_key = excluded.idempotency_key\n RETURNING purchase_id`,\n [\n intent.input.purchaseId,\n intent.input.tenantId,\n intent.input.ownerId,\n intent.input.idempotencyKey,\n intent.status,\n intent.inputDigest,\n JSON.stringify(intent),\n intent.createdAt,\n intent.updatedAt,\n ],\n );\n if (result.rows.length !== 1)\n throw new AgentPurchaseIntentError(\n \"Purchase identity belongs to another immutable request\",\n );\n },\n };\n};\n\ntype PurchaseWallet = {\n cancelSpend: (mandateId: string) => Promise<unknown>;\n requestSpend: (\n request: AgentSpendRequest,\n options?: { mandateId?: string },\n ) => Promise<SpendRequestResult>;\n};\n\nexport const createAgentPurchaseOrchestrator = (options: {\n effects: Pick<EffectStore, \"enqueue\" | \"getByIdempotencyKey\">;\n installations: Pick<\n EffectAdapterInstallationRegistry,\n \"disable\" | \"enable\" | \"put\"\n >;\n now?: () => number;\n store: AgentPurchaseIntentStore;\n wallet: PurchaseWallet;\n}) => {\n const now = options.now ?? Date.now;\n\n const saveStatus = async (\n intent: AgentPurchaseIntent,\n status: AgentPurchaseIntentStatus,\n mandate?: SpendMandate,\n ) => {\n let mandateSummary: Omit<SpendMandate, \"signature\"> | undefined;\n if (mandate) {\n const { signature, ...summary } = mandate;\n void signature;\n mandateSummary = summary;\n }\n const next: AgentPurchaseIntent = {\n ...intent,\n ...(mandateSummary ? { mandate: mandateSummary } : {}),\n status,\n updatedAt: now(),\n };\n await options.store.save(next);\n return next;\n };\n\n const submit = async <Payload>(\n input: AgentPurchaseIntentInput<Payload>,\n ): Promise<AgentPurchaseIntent<Payload>> => {\n if (!input.purchaseId.trim() || !input.idempotencyKey.trim())\n throw new AgentPurchaseIntentError(\n \"Purchase and idempotency identities are required\",\n );\n if (!Number.isSafeInteger(input.amountMinor) || input.amountMinor <= 0)\n throw new AgentPurchaseIntentError(\n \"Purchase amount must be positive integer minor units\",\n );\n const mandateId = `mandate:purchase:${input.purchaseId}`;\n const effectId = `purchase:${input.purchaseId}`;\n const envelope: EffectAdapterExecutionEnvelope<Payload> = {\n currency: input.currency,\n ...(input.destination ? { destination: input.destination } : {}),\n effect: input.effect,\n installationId: input.installationId,\n mandateId,\n payload: input.payload,\n spendMinor: input.amountMinor,\n };\n const inputDigest = await effectAdapterExecutionInputDigest(envelope);\n const existing = await options.store.get(input.tenantId, input.purchaseId);\n const idempotent = await options.store.getByIdempotencyKey(\n input.tenantId,\n input.idempotencyKey,\n );\n const prior = existing ?? idempotent;\n if (prior) {\n if (\n prior.input.purchaseId !== input.purchaseId ||\n prior.inputDigest !== inputDigest\n )\n throw new AgentPurchaseIntentError(\n \"Purchase identity belongs to another immutable request\",\n );\n if (prior.status === \"enqueued\" || prior.status === \"cancelled\")\n return prior as AgentPurchaseIntent<Payload>;\n }\n let intent = (prior ?? {\n createdAt: now(),\n effectId,\n envelope,\n input,\n inputDigest,\n mandateId,\n status: \"drafted\" as const,\n updatedAt: now(),\n }) as AgentPurchaseIntent<Payload>;\n await options.store.save(intent);\n\n const spendRequest: AgentSpendRequest = {\n action: input.effect,\n agentId: input.agentId,\n allowanceId: input.allowanceId,\n amountCents: input.amountMinor,\n cartHash: inputDigest,\n ...(input.category ? { category: input.category } : {}),\n currency: input.currency,\n expiresAt: input.expiresAt,\n idempotencyKey: `purchase:${input.idempotencyKey}`,\n merchantId: input.merchantId,\n ...(input.refundable === undefined\n ? {}\n : { refundable: input.refundable }),\n };\n const requested = await options.wallet.requestSpend(spendRequest, {\n mandateId,\n });\n if (requested.mandate.status === \"pending_approval\")\n return (await saveStatus(\n intent,\n \"pending_approval\",\n requested.mandate,\n )) as AgentPurchaseIntent<Payload>;\n if (requested.mandate.status !== \"active\")\n throw new AgentPurchaseIntentError(\n `Purchase mandate is ${requested.mandate.status}`,\n );\n intent = (await saveStatus(\n intent,\n \"mandate_ready\",\n requested.mandate,\n )) as AgentPurchaseIntent<Payload>;\n\n await options.installations.put({\n adapterId: input.adapterId,\n installationId: input.installationId,\n policy: {\n credentials: input.credentials ?? [],\n destinations: input.destination ? [input.destination] : [],\n effects: [input.effect],\n spend: {\n currency: input.currency,\n mandateId,\n maxMinorPerEffect: input.amountMinor,\n },\n },\n tenantId: input.tenantId,\n });\n await options.installations.enable(input.tenantId, input.installationId);\n intent = (await saveStatus(\n intent,\n \"installation_ready\",\n )) as AgentPurchaseIntent<Payload>;\n\n const timestamp = now();\n const effect: EffectRecord = {\n actionId: input.actionId,\n attempts: 0,\n availableAt: timestamp,\n createdAt: timestamp,\n effectId,\n handler: input.handler,\n idempotencyKey: `purchase:${input.idempotencyKey}`,\n input: envelope,\n inputDigest,\n status: \"pending\",\n tenantId: input.tenantId,\n updatedAt: timestamp,\n };\n if (!(await options.effects.enqueue(effect))) {\n const duplicate = await options.effects.getByIdempotencyKey(\n input.tenantId,\n effect.idempotencyKey,\n );\n if (\n !duplicate ||\n duplicate.effectId !== effect.effectId ||\n duplicate.inputDigest !== effect.inputDigest\n ) {\n await options.installations.disable(\n input.tenantId,\n input.installationId,\n );\n await options.wallet.cancelSpend(mandateId);\n throw new AgentPurchaseIntentError(\n \"Purchase effect idempotency key belongs to another request\",\n );\n }\n }\n return (await saveStatus(\n intent,\n \"enqueued\",\n )) as AgentPurchaseIntent<Payload>;\n };\n\n return {\n list: options.store.list,\n submit,\n };\n};\n",
|
|
6
|
+
"import { createHash } from \"node:crypto\";\nimport { a2aPostgresSchemaSql } from \"@absolutejs/a2a\";\nimport { agencyPostgresMigrations } from \"@absolutejs/agency\";\nimport { agentControlPostgresSchemaSql } from \"@absolutejs/agent-control\";\nimport { agentInboxPostgresSchemaSql } from \"@absolutejs/agent-inbox\";\nimport { agentMemoryPostgresSchemaSql } from \"@absolutejs/agent-memory\";\nimport { agentRuntimePostgresSchemaSql } from \"@absolutejs/agent-runtime\";\nimport { executionPostgresMigrations } from \"@absolutejs/execution\";\nimport { mcpPostgresSchemaSql } from \"@absolutejs/mcp\";\nimport {\n walletAgentTenantInventoryPostgresSchemaSql,\n walletPostgresSchemaSql,\n} from \"@absolutejs/wallet\";\nimport { agentPurchaseIntentsPostgresSchemaSql } from \"./commerce\";\n\nexport type AgentPostgresMigration = {\n digest: string;\n id: string;\n packageName: string;\n packageVersion: string;\n sql: string;\n};\n\nexport type AgentPostgresMigrationClient = {\n query: <Row = Record<string, unknown>>(\n text: string,\n values?: ReadonlyArray<unknown>,\n ) => Promise<{ rows: ReadonlyArray<Row> }>;\n};\n\nexport type AgentPostgresMigrationResult = {\n applied: string[];\n skipped: string[];\n};\n\nconst LOCK_KEY = \"absolutejs:agent:migrations\";\nconst JOURNAL_TABLE = \"absolutejs_agent_migrations\";\nconst JOURNAL_SQL = `CREATE TABLE IF NOT EXISTS ${JOURNAL_TABLE} (\n id text PRIMARY KEY,\n package_name text NOT NULL,\n package_version text NOT NULL,\n digest text NOT NULL,\n applied_at timestamptz NOT NULL DEFAULT now()\n)`;\n\nconst definitions = [\n ...agencyPostgresMigrations().map((migration) => ({\n ...migration,\n packageName: \"@absolutejs/agency\",\n packageVersion: migration.id.split(\"@\").at(-1) ?? \"unknown\",\n })),\n {\n id: \"agent-runtime@0.1.0\",\n packageName: \"@absolutejs/agent-runtime\",\n packageVersion: \"0.1.0\",\n sql: agentRuntimePostgresSchemaSql(),\n },\n {\n id: \"agent-memory@0.1.0\",\n packageName: \"@absolutejs/agent-memory\",\n packageVersion: \"0.1.0\",\n sql: agentMemoryPostgresSchemaSql(),\n },\n {\n id: \"agent-inbox@0.1.0\",\n packageName: \"@absolutejs/agent-inbox\",\n packageVersion: \"0.1.0\",\n sql: agentInboxPostgresSchemaSql(),\n },\n {\n id: \"mcp@0.10.1\",\n packageName: \"@absolutejs/mcp\",\n packageVersion: \"0.10.1\",\n sql: mcpPostgresSchemaSql(),\n },\n {\n id: \"a2a@0.2.2\",\n packageName: \"@absolutejs/a2a\",\n packageVersion: \"0.2.2\",\n sql: a2aPostgresSchemaSql(),\n },\n {\n id: \"wallet@0.3.0\",\n packageName: \"@absolutejs/wallet\",\n packageVersion: \"0.3.0\",\n sql: walletPostgresSchemaSql(),\n },\n {\n id: \"wallet-agent-tenant-inventory@0.5.0\",\n packageName: \"@absolutejs/wallet\",\n packageVersion: \"0.5.0\",\n sql: walletAgentTenantInventoryPostgresSchemaSql(),\n },\n {\n id: \"agent-control@0.4.0\",\n packageName: \"@absolutejs/agent-control\",\n packageVersion: \"0.4.0\",\n sql: agentControlPostgresSchemaSql(),\n },\n ...executionPostgresMigrations(),\n {\n id: \"agent-commerce-purchase-intents@0.23.1\",\n packageName: \"@absolutejs/agent\",\n packageVersion: \"0.23.1\",\n sql: agentPurchaseIntentsPostgresSchemaSql(),\n },\n] as const;\n\nconst digest = (value: string) =>\n createHash(\"sha256\").update(value).digest(\"hex\");\n\n/** Complete ordered database contract for the production AbsoluteJS agent stack. */\nexport const agentPostgresMigrations = (): AgentPostgresMigration[] =>\n definitions.map((migration) => ({\n ...migration,\n digest: digest(migration.sql),\n }));\n\nconst rollback = async (client: AgentPostgresMigrationClient) => {\n try {\n await client.query(\"ROLLBACK\");\n } catch {\n // Preserve the migration failure when the connection itself was lost.\n }\n};\n\nconst migrationDisposition = async (\n client: AgentPostgresMigrationClient,\n migration: AgentPostgresMigration,\n) => {\n const existing = await client.query<{ digest: string }>(\n `SELECT digest FROM ${JOURNAL_TABLE} WHERE id = $1 FOR UPDATE`,\n [migration.id],\n );\n const [recorded] = existing.rows;\n if (!recorded) return \"applied\" as const;\n if (recorded.digest !== migration.digest) {\n throw new Error(\n `Agent migration ${migration.id} changed after it was applied`,\n );\n }\n\n return \"skipped\" as const;\n};\n\nconst recordMigration = async (\n client: AgentPostgresMigrationClient,\n migration: AgentPostgresMigration,\n) => {\n await client.query(migration.sql);\n await client.query(\n `INSERT INTO ${JOURNAL_TABLE}\n (id, package_name, package_version, digest)\n VALUES ($1, $2, $3, $4)`,\n [\n migration.id,\n migration.packageName,\n migration.packageVersion,\n migration.digest,\n ],\n );\n};\n\nconst migrateOne = async (\n client: AgentPostgresMigrationClient,\n migration: AgentPostgresMigration,\n result: AgentPostgresMigrationResult,\n) => {\n await client.query(\"BEGIN\");\n try {\n const disposition = await migrationDisposition(client, migration);\n if (disposition === \"applied\") await recordMigration(client, migration);\n result[disposition].push(migration.id);\n await client.query(\"COMMIT\");\n } catch (error) {\n await rollback(client);\n throw error;\n }\n};\n\n/** Apply every package-owned agent migration once under a cross-replica lock. */\nexport const applyAgentPostgresMigrations = async (\n client: AgentPostgresMigrationClient,\n) => {\n const result: AgentPostgresMigrationResult = { applied: [], skipped: [] };\n await client.query(\"SELECT pg_advisory_lock(hashtextextended($1, 0))\", [\n LOCK_KEY,\n ]);\n try {\n await client.query(JOURNAL_SQL);\n for (const migration of agentPostgresMigrations()) {\n await migrateOne(client, migration, result);\n }\n } finally {\n await client.query(\"SELECT pg_advisory_unlock(hashtextextended($1, 0))\", [\n LOCK_KEY,\n ]);\n }\n\n return result;\n};\n"
|
|
7
|
+
],
|
|
8
|
+
"mappings": ";;AAAA;AAAA;AAAA;AAcA;AACA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAuEO,MAAM,iCAAiC,MAAM;AAAC;AAErD,IAAM,QAAQ,CAAC,UAAkB,eAC/B,GAAG,eAAiB;AAEf,IAAM,uCACX,MAAgC;AAAA,EAC9B,MAAM,UAAU,IAAI;AAAA,EACpB,OAAO;AAAA,IACL,KAAK,OAAO,UAAU,eAAe;AAAA,MACnC,MAAM,QAAQ,QAAQ,IAAI,MAAM,UAAU,UAAU,CAAC;AAAA,MACrD,OAAO,QAAQ,gBAAgB,KAAK,IAAI;AAAA;AAAA,IAE1C,qBAAqB,OAAO,UAAU,mBAAmB;AAAA,MACvD,MAAM,QAAQ,CAAC,GAAG,QAAQ,OAAO,CAAC,EAAE,KAClC,CAAC,WACC,OAAO,MAAM,aAAa,YAC1B,OAAO,MAAM,mBAAmB,cACpC;AAAA,MACA,OAAO,QAAQ,gBAAgB,KAAK,IAAI;AAAA;AAAA,IAE1C,MAAM,OAAO,UACX,CAAC,GAAG,QAAQ,OAAO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AAA,EACD,IAAI;AAAA,IACF,MAAM,OAAO,MAAM,WAAW;AAAA,IAC9B,WAAW,aAAa,wBAAwB,GAAG;AAAA,MACjD,MAAM,WAAW,QAAQ,WAAW,MAAM;AAAA,IAC5C;AAAA,YACA;AAAA,IACA,MAAM,OAAO,MAAM,sDAAsD;AAAA,MACvE;AAAA,IACF,CAAC;AAAA;AAAA,EAGH,OAAO;AAAA;",
|
|
9
|
+
"debugId": "53A41277E62BDD0864756E2164756E21",
|
|
10
|
+
"names": []
|
|
11
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@absolutejs/agent",
|
|
3
|
-
"version": "0.23.
|
|
3
|
+
"version": "0.23.18",
|
|
4
4
|
"description": "The production-grade, provider-neutral agent stack for AbsoluteJS: auth, actions, runtime, sandboxing, trust, memory, inbox, discovery, MCP, A2A, policy, wallet limits, controls, and conformance.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -117,7 +117,12 @@
|
|
|
117
117
|
"import": "./dist/manifest.js",
|
|
118
118
|
"default": "./dist/manifest.js"
|
|
119
119
|
},
|
|
120
|
-
"./manifest.json": "./dist/manifest.json"
|
|
120
|
+
"./manifest.json": "./dist/manifest.json",
|
|
121
|
+
"./migrations": {
|
|
122
|
+
"types": "./dist/migrations.d.ts",
|
|
123
|
+
"import": "./dist/migrations.js",
|
|
124
|
+
"default": "./dist/migrations.js"
|
|
125
|
+
}
|
|
121
126
|
},
|
|
122
127
|
"files": [
|
|
123
128
|
"dist",
|
|
@@ -156,7 +161,7 @@
|
|
|
156
161
|
"@sinclair/typebox": "^0.34.0"
|
|
157
162
|
},
|
|
158
163
|
"devDependencies": {
|
|
159
|
-
"@absolutejs/execution": "0.14.
|
|
164
|
+
"@absolutejs/execution": "0.14.6",
|
|
160
165
|
"@types/bun": "^1.3.14",
|
|
161
166
|
"drizzle-orm": "1.0.0-rc.4",
|
|
162
167
|
"prettier": "^3.8.3",
|
|
@@ -182,8 +187,8 @@
|
|
|
182
187
|
"@absolutejs/execution"
|
|
183
188
|
],
|
|
184
189
|
"optional": false,
|
|
185
|
-
"range": ">=0.14.
|
|
186
|
-
"tested": "0.14.
|
|
190
|
+
"range": ">=0.14.6 <0.15",
|
|
191
|
+
"tested": "0.14.6"
|
|
187
192
|
},
|
|
188
193
|
"drizzle-orm": {
|
|
189
194
|
"artifactImports": [
|
|
@@ -200,7 +205,7 @@
|
|
|
200
205
|
}
|
|
201
206
|
},
|
|
202
207
|
"peerDependencies": {
|
|
203
|
-
"@absolutejs/execution": ">=0.14.
|
|
208
|
+
"@absolutejs/execution": ">=0.14.6 <0.15",
|
|
204
209
|
"drizzle-orm": ">=1.0.0-rc.4 <2"
|
|
205
210
|
}
|
|
206
211
|
}
|