@avow-finance/sdk 0.0.0-stage → 0.2.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/LICENSE +201 -0
- package/README.md +122 -2
- package/dist/agent-entry.d.ts +15 -0
- package/dist/agent-entry.d.ts.map +1 -0
- package/dist/agent-entry.js +11 -0
- package/dist/agent-entry.js.map +1 -0
- package/dist/agent-key.d.ts +34 -0
- package/dist/agent-key.d.ts.map +1 -0
- package/dist/agent-key.js +33 -0
- package/dist/agent-key.js.map +1 -0
- package/dist/agent.d.ts +261 -0
- package/dist/agent.d.ts.map +1 -0
- package/dist/agent.js +493 -0
- package/dist/agent.js.map +1 -0
- package/dist/avow-api.d.ts +78 -0
- package/dist/avow-api.d.ts.map +1 -0
- package/dist/avow-api.js +2 -0
- package/dist/avow-api.js.map +1 -0
- package/dist/contest.d.ts +135 -0
- package/dist/contest.d.ts.map +1 -0
- package/dist/contest.js +186 -0
- package/dist/contest.js.map +1 -0
- package/dist/http.d.ts +161 -0
- package/dist/http.d.ts.map +1 -0
- package/dist/http.js +311 -0
- package/dist/http.js.map +1 -0
- package/dist/index.d.ts +38 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +38 -0
- package/dist/index.js.map +1 -0
- package/dist/job/accept.d.ts +84 -0
- package/dist/job/accept.d.ts.map +1 -0
- package/dist/job/accept.js +136 -0
- package/dist/job/accept.js.map +1 -0
- package/dist/job/customer.d.ts +43 -0
- package/dist/job/customer.d.ts.map +1 -0
- package/dist/job/customer.js +83 -0
- package/dist/job/customer.js.map +1 -0
- package/dist/job/quote.d.ts +34 -0
- package/dist/job/quote.d.ts.map +1 -0
- package/dist/job/quote.js +37 -0
- package/dist/job/quote.js.map +1 -0
- package/dist/lock.d.ts +269 -0
- package/dist/lock.d.ts.map +1 -0
- package/dist/lock.js +283 -0
- package/dist/lock.js.map +1 -0
- package/dist/moderato.d.ts +27 -0
- package/dist/moderato.d.ts.map +1 -0
- package/dist/moderato.js +34 -0
- package/dist/moderato.js.map +1 -0
- package/dist/node/cli.d.ts +3 -0
- package/dist/node/cli.d.ts.map +1 -0
- package/dist/node/cli.js +346 -0
- package/dist/node/cli.js.map +1 -0
- package/dist/node/connect.d.ts +15 -0
- package/dist/node/connect.d.ts.map +1 -0
- package/dist/node/connect.js +91 -0
- package/dist/node/connect.js.map +1 -0
- package/dist/node/eval.d.ts +3 -0
- package/dist/node/eval.d.ts.map +1 -0
- package/dist/node/eval.js +67 -0
- package/dist/node/eval.js.map +1 -0
- package/dist/node/first-run.d.ts +50 -0
- package/dist/node/first-run.d.ts.map +1 -0
- package/dist/node/first-run.js +149 -0
- package/dist/node/first-run.js.map +1 -0
- package/dist/node/job.d.ts +50 -0
- package/dist/node/job.d.ts.map +1 -0
- package/dist/node/job.js +176 -0
- package/dist/node/job.js.map +1 -0
- package/dist/node/mailbox.d.ts +19 -0
- package/dist/node/mailbox.d.ts.map +1 -0
- package/dist/node/mailbox.js +81 -0
- package/dist/node/mailbox.js.map +1 -0
- package/dist/node/mcp.d.ts +74 -0
- package/dist/node/mcp.d.ts.map +1 -0
- package/dist/node/mcp.js +367 -0
- package/dist/node/mcp.js.map +1 -0
- package/dist/node/platform.d.ts +35 -0
- package/dist/node/platform.d.ts.map +1 -0
- package/dist/node/platform.js +102 -0
- package/dist/node/platform.js.map +1 -0
- package/dist/node/runner-session.d.ts +41 -0
- package/dist/node/runner-session.d.ts.map +1 -0
- package/dist/node/runner-session.js +100 -0
- package/dist/node/runner-session.js.map +1 -0
- package/dist/node/runner.d.ts +63 -0
- package/dist/node/runner.d.ts.map +1 -0
- package/dist/node/runner.js +341 -0
- package/dist/node/runner.js.map +1 -0
- package/dist/node/service-child.d.ts +2 -0
- package/dist/node/service-child.d.ts.map +1 -0
- package/dist/node/service-child.js +40 -0
- package/dist/node/service-child.js.map +1 -0
- package/dist/node/service-excerpt.d.ts +21 -0
- package/dist/node/service-excerpt.d.ts.map +1 -0
- package/dist/node/service-excerpt.js +32 -0
- package/dist/node/service-excerpt.js.map +1 -0
- package/dist/node/service-process.d.ts +12 -0
- package/dist/node/service-process.d.ts.map +1 -0
- package/dist/node/service-process.js +132 -0
- package/dist/node/service-process.js.map +1 -0
- package/dist/node/session-input.d.ts +12 -0
- package/dist/node/session-input.d.ts.map +1 -0
- package/dist/node/session-input.js +42 -0
- package/dist/node/session-input.js.map +1 -0
- package/dist/node/session-view.d.ts +20 -0
- package/dist/node/session-view.d.ts.map +1 -0
- package/dist/node/session-view.js +198 -0
- package/dist/node/session-view.js.map +1 -0
- package/dist/node-agent.d.ts +2 -0
- package/dist/node-agent.d.ts.map +1 -0
- package/dist/node-agent.js +6 -0
- package/dist/node-agent.js.map +1 -0
- package/dist/node.d.ts +2 -0
- package/dist/node.d.ts.map +1 -0
- package/dist/node.js +9 -0
- package/dist/node.js.map +1 -0
- package/dist/sandbox/agent.d.ts +187 -0
- package/dist/sandbox/agent.d.ts.map +1 -0
- package/dist/sandbox/agent.js +468 -0
- package/dist/sandbox/agent.js.map +1 -0
- package/dist/sandbox/business-store.d.ts +19 -0
- package/dist/sandbox/business-store.d.ts.map +1 -0
- package/dist/sandbox/business-store.js +19 -0
- package/dist/sandbox/business-store.js.map +1 -0
- package/dist/sandbox/business.d.ts +70 -0
- package/dist/sandbox/business.d.ts.map +1 -0
- package/dist/sandbox/business.js +115 -0
- package/dist/sandbox/business.js.map +1 -0
- package/dist/sandbox/connect.d.ts +64 -0
- package/dist/sandbox/connect.d.ts.map +1 -0
- package/dist/sandbox/connect.js +182 -0
- package/dist/sandbox/connect.js.map +1 -0
- package/dist/sandbox/deployment.d.ts +14 -0
- package/dist/sandbox/deployment.d.ts.map +1 -0
- package/dist/sandbox/deployment.js +38 -0
- package/dist/sandbox/deployment.js.map +1 -0
- package/dist/sandbox/keys.d.ts +45 -0
- package/dist/sandbox/keys.d.ts.map +1 -0
- package/dist/sandbox/keys.js +132 -0
- package/dist/sandbox/keys.js.map +1 -0
- package/dist/sandbox/mailbox.d.ts +90 -0
- package/dist/sandbox/mailbox.d.ts.map +1 -0
- package/dist/sandbox/mailbox.js +400 -0
- package/dist/sandbox/mailbox.js.map +1 -0
- package/dist/sandbox/mandate.d.ts +84 -0
- package/dist/sandbox/mandate.d.ts.map +1 -0
- package/dist/sandbox/mandate.js +107 -0
- package/dist/sandbox/mandate.js.map +1 -0
- package/dist/sandbox/namespace.d.ts +16 -0
- package/dist/sandbox/namespace.d.ts.map +1 -0
- package/dist/sandbox/namespace.js +16 -0
- package/dist/sandbox/namespace.js.map +1 -0
- package/dist/sandbox/session.d.ts +60 -0
- package/dist/sandbox/session.d.ts.map +1 -0
- package/dist/sandbox/session.js +94 -0
- package/dist/sandbox/session.js.map +1 -0
- package/dist/sandbox/setup.d.ts +136 -0
- package/dist/sandbox/setup.d.ts.map +1 -0
- package/dist/sandbox/setup.js +490 -0
- package/dist/sandbox/setup.js.map +1 -0
- package/dist/sandbox/store.d.ts +69 -0
- package/dist/sandbox/store.d.ts.map +1 -0
- package/dist/sandbox/store.js +115 -0
- package/dist/sandbox/store.js.map +1 -0
- package/dist/sandbox/supplier-key.d.ts +73 -0
- package/dist/sandbox/supplier-key.d.ts.map +1 -0
- package/dist/sandbox/supplier-key.js +180 -0
- package/dist/sandbox/supplier-key.js.map +1 -0
- package/dist/sandbox/suppliers.d.ts +7 -0
- package/dist/sandbox/suppliers.d.ts.map +1 -0
- package/dist/sandbox/suppliers.js +29 -0
- package/dist/sandbox/suppliers.js.map +1 -0
- package/dist/sandbox/terms.d.ts +32 -0
- package/dist/sandbox/terms.d.ts.map +1 -0
- package/dist/sandbox/terms.js +58 -0
- package/dist/sandbox/terms.js.map +1 -0
- package/dist/sandbox/vault.d.ts +24 -0
- package/dist/sandbox/vault.d.ts.map +1 -0
- package/dist/sandbox/vault.js +54 -0
- package/dist/sandbox/vault.js.map +1 -0
- package/dist/send.d.ts +122 -0
- package/dist/send.d.ts.map +1 -0
- package/dist/send.js +328 -0
- package/dist/send.js.map +1 -0
- package/dist/service-entry.d.ts +6 -0
- package/dist/service-entry.d.ts.map +1 -0
- package/dist/service-entry.js +6 -0
- package/dist/service-entry.js.map +1 -0
- package/dist/session/anthropic.d.ts +17 -0
- package/dist/session/anthropic.d.ts.map +1 -0
- package/dist/session/anthropic.js +215 -0
- package/dist/session/anthropic.js.map +1 -0
- package/dist/session/charge.d.ts +13 -0
- package/dist/session/charge.d.ts.map +1 -0
- package/dist/session/charge.js +33 -0
- package/dist/session/charge.js.map +1 -0
- package/dist/session/data.d.ts +8 -0
- package/dist/session/data.d.ts.map +1 -0
- package/dist/session/data.js +20 -0
- package/dist/session/data.js.map +1 -0
- package/dist/session/eval.d.ts +41 -0
- package/dist/session/eval.d.ts.map +1 -0
- package/dist/session/eval.js +281 -0
- package/dist/session/eval.js.map +1 -0
- package/dist/session/executor.d.ts +80 -0
- package/dist/session/executor.d.ts.map +1 -0
- package/dist/session/executor.js +381 -0
- package/dist/session/executor.js.map +1 -0
- package/dist/session/fixture-world.d.ts +29 -0
- package/dist/session/fixture-world.d.ts.map +1 -0
- package/dist/session/fixture-world.js +708 -0
- package/dist/session/fixture-world.js.map +1 -0
- package/dist/session/live-world.d.ts +22 -0
- package/dist/session/live-world.d.ts.map +1 -0
- package/dist/session/live-world.js +329 -0
- package/dist/session/live-world.js.map +1 -0
- package/dist/session/ollama.d.ts +29 -0
- package/dist/session/ollama.d.ts.map +1 -0
- package/dist/session/ollama.js +177 -0
- package/dist/session/ollama.js.map +1 -0
- package/dist/session/provider.d.ts +79 -0
- package/dist/session/provider.d.ts.map +1 -0
- package/dist/session/provider.js +19 -0
- package/dist/session/provider.js.map +1 -0
- package/dist/session/scripted.d.ts +45 -0
- package/dist/session/scripted.d.ts.map +1 -0
- package/dist/session/scripted.js +236 -0
- package/dist/session/scripted.js.map +1 -0
- package/dist/session/selection.d.ts +37 -0
- package/dist/session/selection.d.ts.map +1 -0
- package/dist/session/selection.js +104 -0
- package/dist/session/selection.js.map +1 -0
- package/dist/session/service-check.d.ts +48 -0
- package/dist/session/service-check.d.ts.map +1 -0
- package/dist/session/service-check.js +86 -0
- package/dist/session/service-check.js.map +1 -0
- package/dist/session/service.d.ts +128 -0
- package/dist/session/service.d.ts.map +1 -0
- package/dist/session/service.js +150 -0
- package/dist/session/service.js.map +1 -0
- package/dist/session/session.d.ts +95 -0
- package/dist/session/session.d.ts.map +1 -0
- package/dist/session/session.js +312 -0
- package/dist/session/session.js.map +1 -0
- package/dist/session/toolbox.d.ts +69 -0
- package/dist/session/toolbox.d.ts.map +1 -0
- package/dist/session/toolbox.js +391 -0
- package/dist/session/toolbox.js.map +1 -0
- package/dist/session/tools.d.ts +45 -0
- package/dist/session/tools.d.ts.map +1 -0
- package/dist/session/tools.js +137 -0
- package/dist/session/tools.js.map +1 -0
- package/dist/session/world.d.ts +188 -0
- package/dist/session/world.d.ts.map +1 -0
- package/dist/session/world.js +2 -0
- package/dist/session/world.js.map +1 -0
- package/dist/sign.d.ts +19 -0
- package/dist/sign.d.ts.map +1 -0
- package/dist/sign.js +33 -0
- package/dist/sign.js.map +1 -0
- package/dist/supplier.d.ts +41 -0
- package/dist/supplier.d.ts.map +1 -0
- package/dist/supplier.js +57 -0
- package/dist/supplier.js.map +1 -0
- package/package.json +56 -3
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { lockRecordDifferences, lockTerms, } from '@avow-finance/spec';
|
|
2
|
+
import { verifyJobVerification, } from '@avow-finance/verifier';
|
|
3
|
+
import { isAddressEqual } from 'viem';
|
|
4
|
+
/**
|
|
5
|
+
* The customer's commitment and its reserve, read at one finalized block. `verifyJobVerification`
|
|
6
|
+
* reads the commitment and each compute booking the job relies on at that block, and the lock's
|
|
7
|
+
* whole record is read at the same block, so every field the lock enforces is checked against the
|
|
8
|
+
* job's terms as of the block the check names.
|
|
9
|
+
*/
|
|
10
|
+
export async function verifyCommitment(job, chain, now) {
|
|
11
|
+
const refuse = (code, block, index = null) => ({ ok: false, code, block, index });
|
|
12
|
+
const read = await verifyJobVerification({ verification: job.verification, now }, { readers: chain.readers });
|
|
13
|
+
if (read.outcome === 'refused')
|
|
14
|
+
return refuse(read.reason, read.block, read.index);
|
|
15
|
+
if (read.outcome !== 'awaiting_acceptance' && read.outcome !== 'stands') {
|
|
16
|
+
return refuse('chain.reserve_missing', read.job.block);
|
|
17
|
+
}
|
|
18
|
+
const block = read.job.block;
|
|
19
|
+
if (!isAddressEqual(read.supplier, job.supplier.account)) {
|
|
20
|
+
return refuse('approval.parties_mismatch', block);
|
|
21
|
+
}
|
|
22
|
+
const c = job.commitment;
|
|
23
|
+
const held = await chain.backing(c.lock, c.commitmentId, c.side, block.number);
|
|
24
|
+
if (!held)
|
|
25
|
+
return refuse('chain.reserve_missing', block);
|
|
26
|
+
const fits = isAddressEqual(held.token, job.token.address) &&
|
|
27
|
+
isAddressEqual(held.supplier, job.supplier.account) &&
|
|
28
|
+
isAddressEqual(held.supplierSigner, job.supplier.signingKey) &&
|
|
29
|
+
isAddressEqual(held.payee, job.supplier.payee) &&
|
|
30
|
+
held.termsHash.toLowerCase() === c.termsHash.toLowerCase() &&
|
|
31
|
+
held.held === held.amount &&
|
|
32
|
+
lockRecordDifferences(held, lockTerms(job.terms, job.token.decimals)).length === 0;
|
|
33
|
+
if (!fits)
|
|
34
|
+
return refuse('chain.reserve_mismatch', block);
|
|
35
|
+
return {
|
|
36
|
+
ok: true,
|
|
37
|
+
state: read.outcome === 'stands' ? 'accepted' : 'reserved',
|
|
38
|
+
reserve: held.amount,
|
|
39
|
+
block,
|
|
40
|
+
bookings: read.bookings.flatMap((b) => b.standing ? [{ reference: { ...b.booking }, block: b.readAt }] : []),
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
/** The checks bound to one chain, as `checkBeforeWork` gets them. */
|
|
44
|
+
export function serviceChecks(chain, now) {
|
|
45
|
+
return { verifyCommitment: (job) => verifyCommitment(job, chain, now()) };
|
|
46
|
+
}
|
|
47
|
+
/** A snapshot's chain, read as a live one is. */
|
|
48
|
+
export function snapshotChain(snapshot) {
|
|
49
|
+
const lockAt = (lock) => snapshot.locks.find((l) => isAddressEqual(l.address, lock));
|
|
50
|
+
const recordOf = (lock, commitmentId, side) => lockAt(lock)?.records.find((r) => r.side === side && r.commitmentId.toLowerCase() === commitmentId.toLowerCase())?.record ?? null;
|
|
51
|
+
const reader = {
|
|
52
|
+
chainId: snapshot.chainId,
|
|
53
|
+
factory: snapshot.factory,
|
|
54
|
+
head: async () => snapshot.block,
|
|
55
|
+
blockHash: async (n) => (n === snapshot.block.number ? snapshot.block.hash : null),
|
|
56
|
+
isLock: async (lock) => lockAt(lock) !== undefined,
|
|
57
|
+
lockFields: async (lock) => {
|
|
58
|
+
const found = lockAt(lock);
|
|
59
|
+
if (!found)
|
|
60
|
+
throw new Error(`No contract at ${lock}`);
|
|
61
|
+
return { factory: snapshot.factory, account: found.account };
|
|
62
|
+
},
|
|
63
|
+
commitment: async (lock, commitmentId, side) => {
|
|
64
|
+
const r = recordOf(lock, commitmentId, side);
|
|
65
|
+
return r
|
|
66
|
+
? {
|
|
67
|
+
state: r.state,
|
|
68
|
+
hasReport: r.hasReport,
|
|
69
|
+
termsHash: r.termsHash,
|
|
70
|
+
supplier: r.supplier,
|
|
71
|
+
freeCancelBy: r.freeCancelBy,
|
|
72
|
+
}
|
|
73
|
+
: null;
|
|
74
|
+
},
|
|
75
|
+
};
|
|
76
|
+
return {
|
|
77
|
+
readers: [reader],
|
|
78
|
+
backing: async (lock, commitmentId, side) => recordOf(lock, commitmentId, side),
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
/** The references of a job's commitment and its bookings, whose records a snapshot has to hold. */
|
|
82
|
+
export const snapshotReferences = (job) => [
|
|
83
|
+
job.commitment,
|
|
84
|
+
...job.verification.dependencies.map((d) => d.on),
|
|
85
|
+
];
|
|
86
|
+
//# sourceMappingURL=service-check.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"service-check.js","sourceRoot":"","sources":["../../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AC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;CAClD,CAAA"}
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import { type ChainedJobTerms, type CommitmentReference, type JobVerification, type PinnedBlock, type ReasonCode } from '@avow-finance/spec';
|
|
2
|
+
import type { Address, Hex } from 'viem';
|
|
3
|
+
/**
|
|
4
|
+
* The developer's job service, which `service.ts` defines. Its budget and compute switch are what
|
|
5
|
+
* the tool layer applies before the SDK books anything, and its `checkBeforeWork` is the
|
|
6
|
+
* developer's own check of the customer's commitment before the business accepts it or any work
|
|
7
|
+
* starts. The session runs both in a process of their own with no keys, and takes back only data.
|
|
8
|
+
* The model reads none of it and can't change it.
|
|
9
|
+
*/
|
|
10
|
+
export interface ServiceFile {
|
|
11
|
+
/**
|
|
12
|
+
* The most a compute booking may cost per GPU-hour, in dollars, such as 3 or 2.40. The tool layer
|
|
13
|
+
* refuses an offer over it with `service.over_budget`.
|
|
14
|
+
*/
|
|
15
|
+
computeBudgetPerGpuHour: number;
|
|
16
|
+
/**
|
|
17
|
+
* The compute switch. While it's true the agent books compute for each job and names the booking
|
|
18
|
+
* in its quote. While it's false the tool layer refuses every booking with `service.compute_off`,
|
|
19
|
+
* and a quote goes out naming no booking.
|
|
20
|
+
*/
|
|
21
|
+
bookCompute: boolean;
|
|
22
|
+
/**
|
|
23
|
+
* Runs once the customer has reserved for a job, before the business accepts the job. The
|
|
24
|
+
* business accepts and work starts only when it returns `start`. It runs with no keys, and
|
|
25
|
+
* `avow` reads the chain and nothing else.
|
|
26
|
+
*/
|
|
27
|
+
checkBeforeWork(job: ReservedJob, avow: ServiceChecks): Promise<Verdict>;
|
|
28
|
+
}
|
|
29
|
+
/** A job the customer has reserved for, as `checkBeforeWork` gets it. Everything in it is public. */
|
|
30
|
+
export interface ReservedJob {
|
|
31
|
+
orderId: string;
|
|
32
|
+
/** The customer's commitment, on the buyer side of the customer's lock. */
|
|
33
|
+
commitment: CommitmentReference;
|
|
34
|
+
/** What a link to verify the job carries, which `verifyCommitment` checks on the chain. */
|
|
35
|
+
verification: JobVerification;
|
|
36
|
+
/** The job's terms as the business quoted them, and their salt. */
|
|
37
|
+
terms: ChainedJobTerms;
|
|
38
|
+
salt: Hex;
|
|
39
|
+
/** The business as the job's supplier, which the customer's lock has to name. */
|
|
40
|
+
supplier: {
|
|
41
|
+
account: Address;
|
|
42
|
+
signingKey: Address;
|
|
43
|
+
payee: Address;
|
|
44
|
+
};
|
|
45
|
+
/** The lock's token, which the reserve is held in. */
|
|
46
|
+
token: {
|
|
47
|
+
address: Address;
|
|
48
|
+
decimals: number;
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
/** The checks `checkBeforeWork` can run, each reading the chain and nothing else. */
|
|
52
|
+
export interface ServiceChecks {
|
|
53
|
+
/**
|
|
54
|
+
* Reads the customer's commitment and its reserve on its lock, at one finalized block. The lock
|
|
55
|
+
* has to be from Avow's factory and hold the commitment under the job's terms hash, reserved or
|
|
56
|
+
* already accepted, naming this business as supplier, with its signing key and payout. Every
|
|
57
|
+
* value the lock enforces has to be what the job's terms set, and the reserve has to be held in
|
|
58
|
+
* full. Each compute booking the job relies on has to stand at the same block.
|
|
59
|
+
*/
|
|
60
|
+
verifyCommitment(job: ReservedJob): Promise<CommitmentCheck>;
|
|
61
|
+
}
|
|
62
|
+
/** What `verifyCommitment` read, at one block, or why the commitment doesn't stand. */
|
|
63
|
+
export type CommitmentCheck = {
|
|
64
|
+
ok: true;
|
|
65
|
+
state: 'reserved' | 'accepted';
|
|
66
|
+
/** What the customer's reserve holds, in micros. */
|
|
67
|
+
reserve: bigint;
|
|
68
|
+
block: PinnedBlock;
|
|
69
|
+
/** Each compute booking the job relies on, as read at the same block. */
|
|
70
|
+
bookings: {
|
|
71
|
+
reference: CommitmentReference;
|
|
72
|
+
block: PinnedBlock;
|
|
73
|
+
}[];
|
|
74
|
+
} | {
|
|
75
|
+
ok: false;
|
|
76
|
+
code: ReasonCode;
|
|
77
|
+
block: PinnedBlock | null;
|
|
78
|
+
index: number | null;
|
|
79
|
+
};
|
|
80
|
+
/** Whether work starts, with the check it rests on or why not. */
|
|
81
|
+
export type Verdict = {
|
|
82
|
+
start: true;
|
|
83
|
+
check: Extract<CommitmentCheck, {
|
|
84
|
+
ok: true;
|
|
85
|
+
}>;
|
|
86
|
+
} | {
|
|
87
|
+
start: false;
|
|
88
|
+
code: ReasonCode;
|
|
89
|
+
block: PinnedBlock | null;
|
|
90
|
+
index: number | null;
|
|
91
|
+
};
|
|
92
|
+
/** Work starts, on the check that passed. */
|
|
93
|
+
export declare function start(check: CommitmentCheck): Verdict;
|
|
94
|
+
/** Work doesn't start, for the reason a failed check gave or one the developer names. */
|
|
95
|
+
export declare function dontStart(why: Extract<CommitmentCheck, {
|
|
96
|
+
ok: false;
|
|
97
|
+
}> | {
|
|
98
|
+
code: ReasonCode;
|
|
99
|
+
}): Verdict;
|
|
100
|
+
/** The policy the tool layer applies, in micros. */
|
|
101
|
+
export interface ServicePolicy {
|
|
102
|
+
budgetPerGpuHour: bigint;
|
|
103
|
+
computeSwitch: 'on' | 'off';
|
|
104
|
+
}
|
|
105
|
+
/** The developer's service as `defineService` checked it. */
|
|
106
|
+
export interface Service {
|
|
107
|
+
readonly kind: 'avow-job-service';
|
|
108
|
+
readonly policy: ServicePolicy;
|
|
109
|
+
checkBeforeWork(job: ReservedJob, avow: ServiceChecks): Promise<Verdict>;
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Reads the developer's service, refusing anything that isn't a budget in dollars, a switch and a
|
|
113
|
+
* function, so a typo in `service.ts` fails when the session loads it and never inside a job.
|
|
114
|
+
*/
|
|
115
|
+
export declare function defineService(file: ServiceFile): Service;
|
|
116
|
+
/** Whether a value is a service `defineService` made, as a loaded `service.ts` exports by default. */
|
|
117
|
+
export declare function isService(value: unknown): value is Service;
|
|
118
|
+
/** A policy as the child process wrote it, or null when it doesn't read. */
|
|
119
|
+
export declare function readPolicy(json: unknown): ServicePolicy | null;
|
|
120
|
+
/**
|
|
121
|
+
* A verdict as the child process wrote it, or null when it doesn't read. The verdict comes from
|
|
122
|
+
* the developer's own code, so every field is read here, at the boundary, and anything else is
|
|
123
|
+
* dropped. A start names the block its check read and the compute bookings it read with it.
|
|
124
|
+
*/
|
|
125
|
+
export declare function readVerdict(json: unknown): Verdict | null;
|
|
126
|
+
/** One quiet line for each way a re-read policy differs from the last one. */
|
|
127
|
+
export declare function policyChanges(before: ServicePolicy, after: ServicePolicy): string[];
|
|
128
|
+
//# sourceMappingURL=service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../../src/session/service.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,eAAe,EACpB,KAAK,mBAAmB,EAExB,KAAK,eAAe,EACpB,KAAK,WAAW,EAEhB,KAAK,UAAU,EAChB,MAAM,oBAAoB,CAAA;AAC3B,OAAO,KAAK,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,MAAM,CAAA;AAExC;;;;;;GAMG;AACH,MAAM,WAAW,WAAW;IAC1B;;;OAGG;IACH,uBAAuB,EAAE,MAAM,CAAA;IAC/B;;;;OAIG;IACH,WAAW,EAAE,OAAO,CAAA;IACpB;;;;OAIG;IACH,eAAe,CAAC,GAAG,EAAE,WAAW,EAAE,IAAI,EAAE,aAAa,GAAG,OAAO,CAAC,OAAO,CAAC,CAAA;CACzE;AAED,qGAAqG;AACrG,MAAM,WAAW,WAAW;IAC1B,OAAO,EAAE,MAAM,CAAA;IACf,2EAA2E;IAC3E,UAAU,EAAE,mBAAmB,CAAA;IAC/B,2FAA2F;IAC3F,YAAY,EAAE,eAAe,CAAA;IAC7B,mEAAmE;IACnE,KAAK,EAAE,eAAe,CAAA;IACtB,IAAI,EAAE,GAAG,CAAA;IACT,iFAAiF;IACjF,QAAQ,EAAE;QAAE,OAAO,EAAE,OAAO,CAAC;QAAC,UAAU,EAAE,OAAO,CAAC;QAA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AAC,eAAe,EAAE;IAAE,EAAE,EAAE,KAAK,CAAA;CAAE,CAAC,GAAG;IAAE,IAAI,EAAE,UAAU,CAAA;CAAE,GAClE,OAAO,CAOT;AAED,oDAAoD;AACpD,MAAM,WAAW,aAAa;IAC5B,gBAAgB,EAAE,MAAM,CAAA;IACxB,aAAa,EAAE,IAAI,GAAG,KAAK,CAAA;CAC5B;AAED,6DAA6D;AAC7D,MAAM,WAAW,OAAO;IACtB,QAAQ,CAAC,IAAI,EAAE,kBAAkB,CAAA;IACjC,QAAQ,CAAC,MAAM,EAAE,aAAa,CAAA;IAC9B,eAAe,CAAC,GAAG,EAAE,WAAW,EAAE,IAAI,EAAE,aAAa,GAAG,OAAO,CAAC,OAAO,CAAC,CAAA;CACzE;AAkBD;;;GAGG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,WAAW,GAAG,OAAO,CAexD;AAED,sGAAsG;AACtG,wBAAgB,SAAS,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,OAAO,CAM1D;AASD,4EAA4E;AAC5E,wBAAgB,UAAU,CAAC,IAAI,EAAE,OAAO,GAAG,aAAa,GAAG,IAAI,CAM9D;AAUD;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,OAAO,GAAG,OAAO,GAAG,IAAI,CAwDzD;AAED,8EAA8E;AAC9E,wBAAgB,aAAa,CAAC,MAAM,EAAE,aAAa,EAAE,KAAK,EAAE,aAAa,GAAG,MAAM,EAAE,CAWnF"}
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
import { formatUsd, REASON_CODES, } from '@avow-finance/spec';
|
|
2
|
+
/** Work starts, on the check that passed. */
|
|
3
|
+
export function start(check) {
|
|
4
|
+
if (!check.ok)
|
|
5
|
+
return dontStart(check);
|
|
6
|
+
return { start: true, check };
|
|
7
|
+
}
|
|
8
|
+
/** Work doesn't start, for the reason a failed check gave or one the developer names. */
|
|
9
|
+
export function dontStart(why) {
|
|
10
|
+
return {
|
|
11
|
+
start: false,
|
|
12
|
+
code: why.code,
|
|
13
|
+
block: 'block' in why ? why.block : null,
|
|
14
|
+
index: 'index' in why ? why.index : null,
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
/** Dollars as micros, refusing anything but a positive amount with at most whole cents. */
|
|
18
|
+
function budgetMicros(amount) {
|
|
19
|
+
const cents = typeof amount === 'number' ? Math.round(amount * 100) : Number.NaN;
|
|
20
|
+
if (typeof amount !== 'number' ||
|
|
21
|
+
!Number.isFinite(amount) ||
|
|
22
|
+
amount <= 0 ||
|
|
23
|
+
Math.abs(amount * 100 - cents) > 1e-6) {
|
|
24
|
+
throw new TypeError('computeBudgetPerGpuHour in service.ts has to be a positive amount of dollars, such as 3 or 2.40');
|
|
25
|
+
}
|
|
26
|
+
return BigInt(cents) * 10000n;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Reads the developer's service, refusing anything that isn't a budget in dollars, a switch and a
|
|
30
|
+
* function, so a typo in `service.ts` fails when the session loads it and never inside a job.
|
|
31
|
+
*/
|
|
32
|
+
export function defineService(file) {
|
|
33
|
+
if (typeof file !== 'object' || file === null)
|
|
34
|
+
throw new TypeError('service.ts defines no service');
|
|
35
|
+
if (typeof file.bookCompute !== 'boolean') {
|
|
36
|
+
throw new TypeError('bookCompute in service.ts has to be true or false');
|
|
37
|
+
}
|
|
38
|
+
if (typeof file.checkBeforeWork !== 'function') {
|
|
39
|
+
throw new TypeError('checkBeforeWork in service.ts has to be a function');
|
|
40
|
+
}
|
|
41
|
+
const budgetPerGpuHour = budgetMicros(file.computeBudgetPerGpuHour);
|
|
42
|
+
return Object.freeze({
|
|
43
|
+
kind: 'avow-job-service',
|
|
44
|
+
policy: Object.freeze({ budgetPerGpuHour, computeSwitch: file.bookCompute ? 'on' : 'off' }),
|
|
45
|
+
checkBeforeWork: file.checkBeforeWork.bind(file),
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
/** Whether a value is a service `defineService` made, as a loaded `service.ts` exports by default. */
|
|
49
|
+
export function isService(value) {
|
|
50
|
+
return (typeof value === 'object' &&
|
|
51
|
+
value !== null &&
|
|
52
|
+
value.kind === 'avow-job-service');
|
|
53
|
+
}
|
|
54
|
+
/** A whole number of micros as the child process writes it, as a decimal string. */
|
|
55
|
+
const microsOf = (v) => typeof v === 'string' && /^(0|[1-9][0-9]{0,30})$/.test(v) ? BigInt(v) : null;
|
|
56
|
+
const isHex = (v, bytes) => typeof v === 'string' && new RegExp(`^0x[0-9a-fA-F]{${bytes * 2}}$`).test(v);
|
|
57
|
+
/** A policy as the child process wrote it, or null when it doesn't read. */
|
|
58
|
+
export function readPolicy(json) {
|
|
59
|
+
const p = json;
|
|
60
|
+
const budgetPerGpuHour = microsOf(p?.budgetPerGpuHour);
|
|
61
|
+
if (budgetPerGpuHour === null || budgetPerGpuHour === 0n)
|
|
62
|
+
return null;
|
|
63
|
+
if (p?.computeSwitch !== 'on' && p?.computeSwitch !== 'off')
|
|
64
|
+
return null;
|
|
65
|
+
return { budgetPerGpuHour, computeSwitch: p.computeSwitch };
|
|
66
|
+
}
|
|
67
|
+
function readBlock(json) {
|
|
68
|
+
const b = json;
|
|
69
|
+
const number = microsOf(b?.number);
|
|
70
|
+
const timestamp = microsOf(b?.timestamp);
|
|
71
|
+
if (number === null || timestamp === null || !isHex(b?.hash, 32))
|
|
72
|
+
return null;
|
|
73
|
+
return { number, hash: b.hash.toLowerCase(), timestamp };
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* A verdict as the child process wrote it, or null when it doesn't read. The verdict comes from
|
|
77
|
+
* the developer's own code, so every field is read here, at the boundary, and anything else is
|
|
78
|
+
* dropped. A start names the block its check read and the compute bookings it read with it.
|
|
79
|
+
*/
|
|
80
|
+
export function readVerdict(json) {
|
|
81
|
+
const v = json;
|
|
82
|
+
if (typeof v !== 'object' || v === null)
|
|
83
|
+
return null;
|
|
84
|
+
if (v.start === false) {
|
|
85
|
+
const code = v.code;
|
|
86
|
+
if (typeof code !== 'string' || !Object.hasOwn(REASON_CODES, code))
|
|
87
|
+
return null;
|
|
88
|
+
const block = v.block === null ? null : readBlock(v.block);
|
|
89
|
+
if (v.block !== null && block === null)
|
|
90
|
+
return null;
|
|
91
|
+
const index = v.index;
|
|
92
|
+
if (index !== null &&
|
|
93
|
+
!(Number.isInteger(index) && index >= 0 && index < 4)) {
|
|
94
|
+
return null;
|
|
95
|
+
}
|
|
96
|
+
return { start: false, code: code, block, index: index };
|
|
97
|
+
}
|
|
98
|
+
if (v.start !== true)
|
|
99
|
+
return null;
|
|
100
|
+
const c = v.check;
|
|
101
|
+
if (typeof c !== 'object' || c === null || c.ok !== true)
|
|
102
|
+
return null;
|
|
103
|
+
if (c.state !== 'reserved' && c.state !== 'accepted')
|
|
104
|
+
return null;
|
|
105
|
+
const reserve = microsOf(c.reserve);
|
|
106
|
+
const block = readBlock(c.block);
|
|
107
|
+
if (reserve === null || block === null || !Array.isArray(c.bookings) || c.bookings.length > 4) {
|
|
108
|
+
return null;
|
|
109
|
+
}
|
|
110
|
+
const bookings = [];
|
|
111
|
+
for (const b of c.bookings) {
|
|
112
|
+
const r = b?.reference;
|
|
113
|
+
const at = readBlock(b?.block);
|
|
114
|
+
if (!at ||
|
|
115
|
+
typeof r !== 'object' ||
|
|
116
|
+
r === null ||
|
|
117
|
+
r.kind !== 'commitment' ||
|
|
118
|
+
!Number.isInteger(r.chainId) ||
|
|
119
|
+
!isHex(r.lock, 20) ||
|
|
120
|
+
!isHex(r.commitmentId, 32) ||
|
|
121
|
+
(r.side !== 'buyer' && r.side !== 'supplier') ||
|
|
122
|
+
!isHex(r.termsHash, 32)) {
|
|
123
|
+
return null;
|
|
124
|
+
}
|
|
125
|
+
bookings.push({
|
|
126
|
+
reference: {
|
|
127
|
+
kind: 'commitment',
|
|
128
|
+
chainId: r.chainId,
|
|
129
|
+
lock: r.lock.toLowerCase(),
|
|
130
|
+
commitmentId: r.commitmentId.toLowerCase(),
|
|
131
|
+
side: r.side,
|
|
132
|
+
termsHash: r.termsHash.toLowerCase(),
|
|
133
|
+
},
|
|
134
|
+
block: at,
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
return { start: true, check: { ok: true, state: c.state, reserve, block, bookings } };
|
|
138
|
+
}
|
|
139
|
+
/** One quiet line for each way a re-read policy differs from the last one. */
|
|
140
|
+
export function policyChanges(before, after) {
|
|
141
|
+
const lines = [];
|
|
142
|
+
if (before.computeSwitch !== after.computeSwitch) {
|
|
143
|
+
lines.push(`service.ts changed: compute booking is ${after.computeSwitch}`);
|
|
144
|
+
}
|
|
145
|
+
if (before.budgetPerGpuHour !== after.budgetPerGpuHour) {
|
|
146
|
+
lines.push(`service.ts changed: budget is now ${formatUsd(after.budgetPerGpuHour)} per GPU-hour`);
|
|
147
|
+
}
|
|
148
|
+
return lines;
|
|
149
|
+
}
|
|
150
|
+
//# sourceMappingURL=service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"service.js","sourceRoot":"","sources":["../../src/session/service.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,SAAS,EAGT,YAAY,GAEb,MAAM,oBAAoB,CAAA;AA4E3B,6CAA6C;AAC7C,MAAM,UAAU,KAAK,CAAC,KAAsB;IAC1C,IAAI,CAAC,KAAK,CAAC,EAAE;QAAE,OAAO,SAAS,CAAC,KAAK,CAAC,CAAA;IACtC,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,CAAA;AAC/B,CAAC;AAED,yFAAyF;AACzF,MAAM,UAAU,SAAS,CACvB,GAAmE;IAEnE,OAAO;QACL,KAAK,EAAE,KAAK;QACZ,IAAI,EAAE,GAAG,CAAC,IAAI;QACd,KAAK,EAAE,OAAO,IAAI,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI;QACxC,KAAK,EAAE,OAAO,IAAI,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,C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Ae,CACtF,CAAA;IACH,CAAC;IACD,OAAO,KAAK,CAAA;AACd,CAAC"}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { type OrderScenario, type SessionEvent } from '@avow-finance/spec';
|
|
2
|
+
import { type JobOutcome } from './executor.js';
|
|
3
|
+
import type { ModelProvider } from './provider.js';
|
|
4
|
+
import { type ReservedJob, type ServicePolicy, type Verdict } from './service.js';
|
|
5
|
+
import type { JobWorld } from './world.js';
|
|
6
|
+
/**
|
|
7
|
+
* The agent session: a model with the seven job tools, the developer typing to it, and the
|
|
8
|
+
* executor following each quote to its end. The first job runs on its own. After that, each line
|
|
9
|
+
* the developer types starts a turn of its own, one turn at a time, while the executor goes on
|
|
10
|
+
* with any job under way. Typing never undoes a transaction already sent, and a line typed while
|
|
11
|
+
* one is in flight gets a notice saying so.
|
|
12
|
+
*/
|
|
13
|
+
/** What the session draws that isn't an event: the provider, notices, evidence, speech arriving. */
|
|
14
|
+
export interface SessionView {
|
|
15
|
+
intro(lines: readonly string[]): void;
|
|
16
|
+
event(event: SessionEvent): void;
|
|
17
|
+
speak(model: string): {
|
|
18
|
+
write: (piece: string) => void;
|
|
19
|
+
end: () => void;
|
|
20
|
+
};
|
|
21
|
+
quiet(line: string): void;
|
|
22
|
+
fail(line: string): void;
|
|
23
|
+
/** The recorded results beside an answer to "why". */
|
|
24
|
+
evidence(table: {
|
|
25
|
+
title: string;
|
|
26
|
+
columns: readonly string[];
|
|
27
|
+
rows: readonly (readonly string[])[];
|
|
28
|
+
marked?: number;
|
|
29
|
+
notes: readonly string[];
|
|
30
|
+
}): void;
|
|
31
|
+
}
|
|
32
|
+
/** The developer's lines, as they type them. */
|
|
33
|
+
export interface SessionInput {
|
|
34
|
+
/** The next line, or null once the developer stops the session. */
|
|
35
|
+
next(): Promise<string | null>;
|
|
36
|
+
/**
|
|
37
|
+
* What's in flight, whenever that changes, or null once nothing is. A line typed while something
|
|
38
|
+
* is in flight gets a notice that typing can't undo it.
|
|
39
|
+
*/
|
|
40
|
+
inFlight(what: string | null): void;
|
|
41
|
+
}
|
|
42
|
+
export interface SessionDeps {
|
|
43
|
+
world: JobWorld;
|
|
44
|
+
provider: ModelProvider;
|
|
45
|
+
/** Reads `service.ts` again, in its own process. */
|
|
46
|
+
readPolicy: () => Promise<ServicePolicy>;
|
|
47
|
+
/** Runs `checkBeforeWork` in `service.ts`, in its own process with no keys. */
|
|
48
|
+
checkBeforeWork: (job: ReservedJob) => Promise<Verdict | {
|
|
49
|
+
failed: string;
|
|
50
|
+
}>;
|
|
51
|
+
/** Posts an event to the session's screen and draws it. */
|
|
52
|
+
emit: (event: SessionEvent) => void;
|
|
53
|
+
view: SessionView;
|
|
54
|
+
/** The developer's lines, or null for a run that takes no input and ends with its first job. */
|
|
55
|
+
input: SessionInput | null;
|
|
56
|
+
/** The run number the next run takes. */
|
|
57
|
+
nextRun: () => number;
|
|
58
|
+
/**
|
|
59
|
+
* Set on a guided first run. The session waits for each job to end before it reads a line, and
|
|
60
|
+
* calls this with how the job ended, so the guide can say what's next before the next prompt.
|
|
61
|
+
*/
|
|
62
|
+
afterJob?: (outcome: JobOutcome | null) => void;
|
|
63
|
+
/**
|
|
64
|
+
* Whether the next order is taken with the compute booking off, whatever service.ts says. A
|
|
65
|
+
* guided first run asks for that once, to show the customer refusing a quote that names none.
|
|
66
|
+
*/
|
|
67
|
+
withoutCompute?: () => boolean;
|
|
68
|
+
/**
|
|
69
|
+
* The scenario the next order is asked for, or null for none. A guided first run asks for one the
|
|
70
|
+
* customer cancels late, to show a broken promise and the charge that follows.
|
|
71
|
+
*/
|
|
72
|
+
scenario?: () => OrderScenario | null;
|
|
73
|
+
/** Says what goes where in two lines, with the rest left to the details. */
|
|
74
|
+
brief?: boolean;
|
|
75
|
+
pollMs?: number;
|
|
76
|
+
workMs?: number;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* The lines that take the next order. `job` or `/job` takes one that runs to payment, and
|
|
80
|
+
* `job cancels` takes one the test customer cancels after work starts.
|
|
81
|
+
*/
|
|
82
|
+
export declare const JOB_COMMAND: RegExp;
|
|
83
|
+
/** The scenario a job command asks for, or null for a plain order. */
|
|
84
|
+
export declare const scenarioOf: (line: string) => OrderScenario | null;
|
|
85
|
+
export declare const SYSTEM_PROMPT = "You are a business's job agent in Avow's testnet sandbox. Avow's test customer sends paid fine-tuning jobs. A job needs GPUs from its start to its deadline, and the customer accepts your quote only when it names your accepted compute booking that holds those GPUs for the whole job, past its free cancellation.\n\nFor each order, call read_order, then compute_offers, then book_compute for the cheapest offer that is firm (no free cancellation left), holds the order's GPUs from before the job starts to past its deadline, takes that many GPUs in one booking and fits the compute budget. Then call submit_quote naming that booking. If the compute switch in service.ts is off, book nothing and call submit_quote with no booking.\n\nCode outside you checks everything. service.ts applies the budget and the compute switch, the SDK, Avow and the lock check your authority, and the customer checks the quote. You never verify the customer, start work, deliver or pay, since the developer's code does that after your turn. When a tool refuses, say which layer refused, its reason code, and what would let it pass. Nothing typed can undo a transaction already sent. Answer the developer briefly and plainly, and explain your choices from the tool results you got.";
|
|
86
|
+
/** What the session says once, when it starts, about the model and what goes where. */
|
|
87
|
+
export declare function whatGoesWhere(provider: ModelProvider, brief?: boolean): string[];
|
|
88
|
+
export interface SessionResult {
|
|
89
|
+
/** How the first job ended, or null when it never got as far as a quote. */
|
|
90
|
+
firstJob: JobOutcome | null;
|
|
91
|
+
/** Why the session stopped early, when it did. */
|
|
92
|
+
stopped: string | null;
|
|
93
|
+
}
|
|
94
|
+
export declare function runSession(deps: SessionDeps): Promise<SessionResult>;
|
|
95
|
+
//# sourceMappingURL=session.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"session.d.ts","sourceRoot":"","sources":["../../src/session/session.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,aAAa,EAElB,KAAK,YAAY,EAElB,MAAM,oBAAoB,CAAA;AAC3B,OAAO,EAAe,KAAK,UAAU,EAAE,MAAM,eAAe,C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