@tangle-network/agent-app 0.60.71 → 0.60.73
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/chat-routes/index.js +1 -1
- package/dist/{chunk-GIJZAJ5W.js → chunk-MBEJPQW6.js} +19 -11
- package/dist/{chunk-GIJZAJ5W.js.map → chunk-MBEJPQW6.js.map} +1 -1
- package/dist/sandbox/index.js +1 -1
- package/dist/workspace-export/index.d.ts +1 -0
- package/dist/workspace-export/index.js +29 -1
- package/dist/workspace-export/index.js.map +1 -1
- package/dist/workspace-export/sandbox.d.ts +38 -0
- package/package.json +1 -1
|
@@ -925,40 +925,48 @@ ON CONFLICT(key) DO UPDATE SET last_turn_at = ?2, hold_until = MAX(${t}.hold_unt
|
|
|
925
925
|
WHERE key = ?1 AND lease_id = ?2`;
|
|
926
926
|
const profileSql = `UPDATE ${t} SET slots = ?2, slots_at = ?3, first_seen_at = ?4 WHERE key = ?1`;
|
|
927
927
|
const readSql = `SELECT * FROM ${t} WHERE key = ?1`;
|
|
928
|
+
const q = (sql, ...values) => {
|
|
929
|
+
const ordered = [];
|
|
930
|
+
const text = sql.replace(/\?(\d+)/g, (_, n) => {
|
|
931
|
+
ordered.push(values[Number(n) - 1]);
|
|
932
|
+
return "?";
|
|
933
|
+
});
|
|
934
|
+
return db.prepare(text).bind(...ordered);
|
|
935
|
+
};
|
|
928
936
|
const read = async (key) => {
|
|
929
|
-
const row = await
|
|
937
|
+
const row = await q(readSql, key).first();
|
|
930
938
|
return row ? toRow(row) : null;
|
|
931
939
|
};
|
|
932
|
-
const list = async (sql, ...values) => ((await
|
|
940
|
+
const list = async (sql, ...values) => ((await q(sql, ...values).all()).results ?? []).map(toRow);
|
|
933
941
|
return {
|
|
934
942
|
read,
|
|
935
943
|
async begin(key, leaseId, reason, now, holdUntil) {
|
|
936
|
-
const row = await
|
|
944
|
+
const row = await q(beginSql, key, leaseId, reason, now, holdUntil).first();
|
|
937
945
|
if (!row) throw new Error("warm lease begin returned no row");
|
|
938
946
|
return row.lease_id;
|
|
939
947
|
},
|
|
940
948
|
async markWarm(key, leaseId, warmAt, resumed) {
|
|
941
|
-
await
|
|
949
|
+
await q(markWarmSql, key, leaseId, warmAt, resumed ? 1 : 0).run();
|
|
942
950
|
},
|
|
943
951
|
async markUsed(key, now, holdUntil) {
|
|
944
952
|
const before = await read(key);
|
|
945
|
-
const claimed = await
|
|
946
|
-
await
|
|
953
|
+
const claimed = await q(firstUseSql, key, now).first();
|
|
954
|
+
await q(turnSql, key, now, holdUntil).run();
|
|
947
955
|
if (before && !claimed && before.usedAt <= 0) return { ...before, usedAt: now };
|
|
948
956
|
return before;
|
|
949
957
|
},
|
|
950
958
|
async end(key, leaseId, day, chargeMs, threshold) {
|
|
951
|
-
await
|
|
959
|
+
await q(endSql, key, leaseId, day, Math.max(0, Math.round(chargeMs)), threshold ?? null).run();
|
|
952
960
|
},
|
|
953
961
|
async writeProfile(key, slots, slotsAt, firstSeenAt) {
|
|
954
962
|
const rounded = slots.map((v) => Math.round(v * 1e3) / 1e3);
|
|
955
|
-
await
|
|
963
|
+
await q(profileSql, key, JSON.stringify(rounded), slotsAt, firstSeenAt).run();
|
|
956
964
|
},
|
|
957
965
|
async markPinged(key, at) {
|
|
958
|
-
await
|
|
966
|
+
await q(`UPDATE ${t} SET ping_at = ?2 WHERE key = ?1`, key, at).run();
|
|
959
967
|
},
|
|
960
968
|
async markPredicted(key, at) {
|
|
961
|
-
await
|
|
969
|
+
await q(`UPDATE ${t} SET predicted_at = ?2 WHERE key = ?1`, key, at).run();
|
|
962
970
|
},
|
|
963
971
|
listExpired: (now, limit) => list(`SELECT * FROM ${t} WHERE lease_id IS NOT NULL AND hold_until <= ?1 ORDER BY hold_until LIMIT ?2`, now, limit),
|
|
964
972
|
listHeld: (now, limit) => list(`SELECT * FROM ${t} WHERE hold_until > ?1 ORDER BY ping_at LIMIT ?2`, now, limit),
|
|
@@ -2910,4 +2918,4 @@ export {
|
|
|
2910
2918
|
isTerminalPromptEvent,
|
|
2911
2919
|
detectInteractiveQuestion
|
|
2912
2920
|
};
|
|
2913
|
-
//# sourceMappingURL=chunk-
|
|
2921
|
+
//# sourceMappingURL=chunk-MBEJPQW6.js.map
|