@tangle-network/agent-app 0.60.103 → 0.60.105
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/agent-profiles/d1.js +1 -1
- package/dist/agent-profiles/index.d.ts +28 -0
- package/dist/agent-profiles/index.js +3 -1
- package/dist/app-auth/index.js +3 -3
- package/dist/assistant/index.js +6 -6
- package/dist/chat-routes/index.js +8 -8
- package/dist/chat-store/index.js +2 -2
- package/dist/{chunk-WKD4E52F.js → chunk-2YLSWZ5W.js} +4 -4
- package/dist/{chunk-P2EKAQUB.js → chunk-BTBDJNHK.js} +114 -18
- package/dist/chunk-BTBDJNHK.js.map +1 -0
- package/dist/{chunk-A76WPE5K.js → chunk-CDMVGIME.js} +19 -1
- package/dist/chunk-CDMVGIME.js.map +1 -0
- package/dist/{chunk-FZSIYAKQ.js → chunk-JWZ32ZGD.js} +2 -2
- package/dist/{chunk-DO6JHTJY.js → chunk-NBZQYRRM.js} +2 -2
- package/dist/public-consultation/index.js +4 -4
- package/dist/sandbox/index.d.ts +1 -1
- package/dist/sandbox/index.js +1 -1
- package/dist/stream/index.js +17 -17
- package/dist/teams/invitations-api.js +3 -3
- package/dist/web-react/index.js +10 -10
- package/dist/workspace-store/d1.d.ts +43 -0
- package/dist/workspace-store/d1.js +210 -0
- package/dist/workspace-store/d1.js.map +1 -0
- package/package.json +8 -3
- package/dist/chunk-A76WPE5K.js.map +0 -1
- package/dist/chunk-P2EKAQUB.js.map +0 -1
- /package/dist/{chunk-WKD4E52F.js.map → chunk-2YLSWZ5W.js.map} +0 -0
- /package/dist/{chunk-FZSIYAKQ.js.map → chunk-JWZ32ZGD.js.map} +0 -0
- /package/dist/{chunk-DO6JHTJY.js.map → chunk-NBZQYRRM.js.map} +0 -0
|
@@ -302,7 +302,35 @@ export interface ProfileToolContext<TTurn extends ProfileToolTurn = ProfileToolT
|
|
|
302
302
|
store: ProfileRevisionStore;
|
|
303
303
|
/** Return a store whose revision append atomically rechecks product turn authority. */
|
|
304
304
|
storeForTurn?(turn: TTurn): ProfileRevisionStore;
|
|
305
|
+
/**
|
|
306
|
+
* When set, `profile.remember` writes to this workspace memory store instead
|
|
307
|
+
* of appending a profile revision, so remembered facts never change the
|
|
308
|
+
* hashed profile (or anything that pins its version, such as a phone line).
|
|
309
|
+
* Structurally matches agent-runtime's `WorkspaceStore`.
|
|
310
|
+
*/
|
|
311
|
+
memory?: ProfileMemoryStore;
|
|
305
312
|
}
|
|
313
|
+
/** The subset of agent-runtime's `WorkspaceStore` that `profile.remember` uses. */
|
|
314
|
+
export interface ProfileMemoryStore {
|
|
315
|
+
list(workspaceId: string, prefix: string): Promise<Array<{
|
|
316
|
+
id: string;
|
|
317
|
+
content?: string;
|
|
318
|
+
}>>;
|
|
319
|
+
put(input: {
|
|
320
|
+
workspaceId: string;
|
|
321
|
+
path: string;
|
|
322
|
+
kind: 'fact';
|
|
323
|
+
ifRevision: null;
|
|
324
|
+
actor: string;
|
|
325
|
+
content: string;
|
|
326
|
+
id?: string;
|
|
327
|
+
}): Promise<{
|
|
328
|
+
id: string;
|
|
329
|
+
revision: number;
|
|
330
|
+
}>;
|
|
331
|
+
}
|
|
332
|
+
/** Workspace-shared memories live under this prefix in the workspace store. */
|
|
333
|
+
export declare const PROFILE_MEMORY_PREFIX = "/memories/workspace/";
|
|
306
334
|
/** Shared self-edit tools; only the authenticated active turn can name the profile. */
|
|
307
335
|
export declare function profileTools<TTurn extends ProfileToolTurn>(context: ProfileToolContext<TTurn>): McpToolDefinition<Record<string, never>>[];
|
|
308
336
|
export * from './self-management';
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
PERMITTED_SELF_MOUNT_DIMENSIONS,
|
|
3
3
|
PROFILE_CHANGE_POLICY,
|
|
4
|
+
PROFILE_MEMORY_PREFIX,
|
|
4
5
|
ProfileAccessError,
|
|
5
6
|
ProfileConflictError,
|
|
6
7
|
addProfileKnowledgeDocument,
|
|
@@ -24,7 +25,7 @@ import {
|
|
|
24
25
|
rollbackProfileBinding,
|
|
25
26
|
serializeProfileRevisionDiff,
|
|
26
27
|
switchProfile
|
|
27
|
-
} from "../chunk-
|
|
28
|
+
} from "../chunk-CDMVGIME.js";
|
|
28
29
|
import {
|
|
29
30
|
normalizeProfileName,
|
|
30
31
|
parseProfileSwitch
|
|
@@ -35,6 +36,7 @@ import "../chunk-TMOYOMSW.js";
|
|
|
35
36
|
export {
|
|
36
37
|
PERMITTED_SELF_MOUNT_DIMENSIONS,
|
|
37
38
|
PROFILE_CHANGE_POLICY,
|
|
39
|
+
PROFILE_MEMORY_PREFIX,
|
|
38
40
|
ProfileAccessError,
|
|
39
41
|
ProfileConflictError,
|
|
40
42
|
addProfileKnowledgeDocument,
|
package/dist/app-auth/index.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
+
import {
|
|
2
|
+
noticeEmail
|
|
3
|
+
} from "../chunk-WOTWQ2ST.js";
|
|
1
4
|
import {
|
|
2
5
|
createAuthGuard,
|
|
3
6
|
createBetterAuthSessionCookieMinter,
|
|
4
7
|
createTangleSsoHandlers
|
|
5
8
|
} from "../chunk-WN3UK23P.js";
|
|
6
|
-
import {
|
|
7
|
-
noticeEmail
|
|
8
|
-
} from "../chunk-WOTWQ2ST.js";
|
|
9
9
|
import "../chunk-D6UJEOZQ.js";
|
|
10
10
|
import "../chunk-UTAIRVOK.js";
|
|
11
11
|
import "../chunk-RN4WPTBH.js";
|
package/dist/assistant/index.js
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import {
|
|
2
2
|
chatToolCallPart
|
|
3
|
-
} from "../chunk-
|
|
4
|
-
import "../chunk-Y4WLCFDZ.js";
|
|
3
|
+
} from "../chunk-NBZQYRRM.js";
|
|
5
4
|
import "../chunk-3HUFJ5LO.js";
|
|
5
|
+
import "../chunk-Y4WLCFDZ.js";
|
|
6
6
|
import "../chunk-FBVLEGEG.js";
|
|
7
7
|
import "../chunk-Y6PRDUFJ.js";
|
|
8
|
+
import "../chunk-GEYACSFW.js";
|
|
8
9
|
import {
|
|
9
10
|
ChatComposer
|
|
10
11
|
} from "../chunk-VIYABB6R.js";
|
|
@@ -19,20 +20,19 @@ import "../chunk-NJDQ2JCP.js";
|
|
|
19
20
|
import {
|
|
20
21
|
ModelPicker
|
|
21
22
|
} from "../chunk-HG4OONJA.js";
|
|
22
|
-
import "../chunk-GEYACSFW.js";
|
|
23
|
-
import "../chunk-MLG6XKPV.js";
|
|
24
23
|
import {
|
|
25
24
|
AsyncView
|
|
26
25
|
} from "../chunk-LSUELMHY.js";
|
|
26
|
+
import "../chunk-MLG6XKPV.js";
|
|
27
27
|
import "../chunk-FQYAJYPW.js";
|
|
28
28
|
import "../chunk-ZMU54CBG.js";
|
|
29
29
|
import "../chunk-WVESWAJJ.js";
|
|
30
30
|
import "../chunk-B7CL7ENS.js";
|
|
31
31
|
import "../chunk-PV33JZKV.js";
|
|
32
32
|
import "../chunk-7YA4QNTU.js";
|
|
33
|
-
import "../chunk-
|
|
34
|
-
import "../chunk-6E7LKHYV.js";
|
|
33
|
+
import "../chunk-2YLSWZ5W.js";
|
|
35
34
|
import "../chunk-ZVEEWGDK.js";
|
|
35
|
+
import "../chunk-6E7LKHYV.js";
|
|
36
36
|
import "../chunk-TXD5HXLE.js";
|
|
37
37
|
import "../chunk-ZGUXI5SI.js";
|
|
38
38
|
import "../chunk-6VQCFJWP.js";
|
|
@@ -42,7 +42,7 @@ import {
|
|
|
42
42
|
flattenHistory,
|
|
43
43
|
readSandboxBinaryBytes,
|
|
44
44
|
statSandboxFileSize
|
|
45
|
-
} from "../chunk-
|
|
45
|
+
} from "../chunk-BTBDJNHK.js";
|
|
46
46
|
import "../chunk-4LBCTFBP.js";
|
|
47
47
|
import "../chunk-WVESWAJJ.js";
|
|
48
48
|
import "../chunk-LWSJK546.js";
|
|
@@ -69,7 +69,7 @@ import {
|
|
|
69
69
|
rowIdOf,
|
|
70
70
|
storeSupportsDraftPersistence,
|
|
71
71
|
streamChatRouteAsSandboxEvents
|
|
72
|
-
} from "../chunk-
|
|
72
|
+
} from "../chunk-JWZ32ZGD.js";
|
|
73
73
|
import "../chunk-Q7WEEN7P.js";
|
|
74
74
|
import "../chunk-UTAIRVOK.js";
|
|
75
75
|
import "../chunk-RN4WPTBH.js";
|
|
@@ -78,7 +78,8 @@ import {
|
|
|
78
78
|
attachmentInputToPart,
|
|
79
79
|
attachmentKindForMime,
|
|
80
80
|
toChatMessageParts
|
|
81
|
-
} from "../chunk-
|
|
81
|
+
} from "../chunk-2YLSWZ5W.js";
|
|
82
|
+
import "../chunk-ZVEEWGDK.js";
|
|
82
83
|
import {
|
|
83
84
|
ChatTurnInputError,
|
|
84
85
|
DISPATCH_MAX_MEDIA_PARTS,
|
|
@@ -110,12 +111,15 @@ import {
|
|
|
110
111
|
turnResponseEventFor,
|
|
111
112
|
validateSandboxMentionPath
|
|
112
113
|
} from "../chunk-6E7LKHYV.js";
|
|
113
|
-
import "../chunk-ZVEEWGDK.js";
|
|
114
114
|
import {
|
|
115
115
|
isWorkspaceFileExportable
|
|
116
116
|
} from "../chunk-TXD5HXLE.js";
|
|
117
117
|
import "../chunk-Z4RD5UF7.js";
|
|
118
118
|
import "../chunk-YG66IHDU.js";
|
|
119
|
+
import {
|
|
120
|
+
coalesceDeltas,
|
|
121
|
+
createBufferedTurnTap
|
|
122
|
+
} from "../chunk-ISP6ZH3G.js";
|
|
119
123
|
import {
|
|
120
124
|
asRecord,
|
|
121
125
|
asString,
|
|
@@ -145,10 +149,6 @@ import {
|
|
|
145
149
|
planFollowUpTurnId,
|
|
146
150
|
planToPersistedPart
|
|
147
151
|
} from "../chunk-LQYIBL3G.js";
|
|
148
|
-
import {
|
|
149
|
-
coalesceDeltas,
|
|
150
|
-
createBufferedTurnTap
|
|
151
|
-
} from "../chunk-ISP6ZH3G.js";
|
|
152
152
|
|
|
153
153
|
// src/chat-routes/model-failover-stream.ts
|
|
154
154
|
var TERMINAL_FAILURE_TYPES = /* @__PURE__ */ new Set(["error", "session.run.failed"]);
|
package/dist/chat-store/index.js
CHANGED
|
@@ -14,9 +14,9 @@ import {
|
|
|
14
14
|
mentionInputToPart,
|
|
15
15
|
mentionPartsFromMessageParts,
|
|
16
16
|
toChatMessageParts
|
|
17
|
-
} from "../chunk-
|
|
18
|
-
import "../chunk-6E7LKHYV.js";
|
|
17
|
+
} from "../chunk-2YLSWZ5W.js";
|
|
19
18
|
import "../chunk-ZVEEWGDK.js";
|
|
19
|
+
import "../chunk-6E7LKHYV.js";
|
|
20
20
|
import "../chunk-TXD5HXLE.js";
|
|
21
21
|
import {
|
|
22
22
|
attachmentPartKey
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
mentionKindForPath
|
|
3
|
-
} from "./chunk-6E7LKHYV.js";
|
|
4
1
|
import {
|
|
5
2
|
persistedPartToWorkProduct
|
|
6
3
|
} from "./chunk-ZVEEWGDK.js";
|
|
4
|
+
import {
|
|
5
|
+
mentionKindForPath
|
|
6
|
+
} from "./chunk-6E7LKHYV.js";
|
|
7
7
|
import {
|
|
8
8
|
persistedPartToInteraction
|
|
9
9
|
} from "./chunk-6VQCFJWP.js";
|
|
@@ -135,4 +135,4 @@ export {
|
|
|
135
135
|
buildAttachmentPromptBlock,
|
|
136
136
|
historyContentWithAttachments
|
|
137
137
|
};
|
|
138
|
-
//# sourceMappingURL=chunk-
|
|
138
|
+
//# sourceMappingURL=chunk-2YLSWZ5W.js.map
|
|
@@ -1197,6 +1197,7 @@ var DEFAULT_SANDBOX_RESOURCES = {
|
|
|
1197
1197
|
};
|
|
1198
1198
|
var _cached = null;
|
|
1199
1199
|
var livenessVerifiedAt = /* @__PURE__ */ new Map();
|
|
1200
|
+
var verifiedEgress = /* @__PURE__ */ new Map();
|
|
1200
1201
|
function getClientFromCreds(creds) {
|
|
1201
1202
|
const fingerprint = `${creds.apiKey} ${creds.baseUrl}`;
|
|
1202
1203
|
if (_cached && _cached.fingerprint === fingerprint) return _cached.client;
|
|
@@ -1215,6 +1216,7 @@ function getClient(shell) {
|
|
|
1215
1216
|
function resetClientCache() {
|
|
1216
1217
|
_cached = null;
|
|
1217
1218
|
livenessVerifiedAt.clear();
|
|
1219
|
+
verifiedEgress.clear();
|
|
1218
1220
|
}
|
|
1219
1221
|
function buildAppToolMcpServers(options) {
|
|
1220
1222
|
const entries = {};
|
|
@@ -1619,7 +1621,7 @@ function deferredCorpusHash(files) {
|
|
|
1619
1621
|
})).sort((a, b) => a.p < b.p ? -1 : a.p > b.p ? 1 : 0);
|
|
1620
1622
|
return createHash("sha256").update(JSON.stringify(norm), "utf8").digest("hex");
|
|
1621
1623
|
}
|
|
1622
|
-
async function materializeDeferredFilesForExistingBox(shell, client, box, stage, name, workspaceId, userId, harness) {
|
|
1624
|
+
async function materializeDeferredFilesForExistingBox(shell, client, box, stage, name, workspaceId, userId, harness, corpusMarker) {
|
|
1623
1625
|
if (!shell.deferProfileFiles) return ok(box);
|
|
1624
1626
|
const connectedIntegrationIds = await shell.connectedIntegrationIds(workspaceId);
|
|
1625
1627
|
const buildCtx = {
|
|
@@ -1631,9 +1633,31 @@ async function materializeDeferredFilesForExistingBox(shell, client, box, stage,
|
|
|
1631
1633
|
const fullProfile = shell.profile({ extraFiles: files, harness });
|
|
1632
1634
|
const { deferredFiles } = splitDeferredProfileFiles(fullProfile);
|
|
1633
1635
|
if (deferredFiles.length === 0) return ok(box);
|
|
1636
|
+
const corpusHash = deferredCorpusHash(deferredFiles);
|
|
1634
1637
|
const stampedHash = box.metadata?.[DEFERRED_CORPUS_HASH_KEY];
|
|
1635
|
-
if (typeof stampedHash === "string" && stampedHash ===
|
|
1636
|
-
|
|
1638
|
+
if (typeof stampedHash === "string" && stampedHash === corpusHash) return ok(box);
|
|
1639
|
+
if (corpusMarker && await corpusMarker === corpusHash) return ok(box);
|
|
1640
|
+
const written = await writeDeferredFilesWithRuntimeAuthRefresh(client, box, deferredFiles, stage, name);
|
|
1641
|
+
if (written.succeeded) await writeDeferredCorpusMarker(written.value, corpusHash);
|
|
1642
|
+
return written;
|
|
1643
|
+
}
|
|
1644
|
+
var DEFERRED_CORPUS_MARKER_PATH = ".agent-app/deferred-corpus-hash";
|
|
1645
|
+
var DEFERRED_CORPUS_HASH_RE = /^[0-9a-f]{64}$/;
|
|
1646
|
+
async function readDeferredCorpusMarker(box) {
|
|
1647
|
+
if (typeof box.read !== "function") return null;
|
|
1648
|
+
try {
|
|
1649
|
+
const value = (await box.read(`/home/agent/${DEFERRED_CORPUS_MARKER_PATH}`)).trim();
|
|
1650
|
+
return DEFERRED_CORPUS_HASH_RE.test(value) ? value : null;
|
|
1651
|
+
} catch {
|
|
1652
|
+
return null;
|
|
1653
|
+
}
|
|
1654
|
+
}
|
|
1655
|
+
async function writeDeferredCorpusMarker(box, corpusHash) {
|
|
1656
|
+
if (typeof box.fs?.writeMany !== "function") return;
|
|
1657
|
+
try {
|
|
1658
|
+
await box.fs.writeMany([{ path: DEFERRED_CORPUS_MARKER_PATH, content: corpusHash }]);
|
|
1659
|
+
} catch {
|
|
1660
|
+
}
|
|
1637
1661
|
}
|
|
1638
1662
|
async function listRunning(client, name) {
|
|
1639
1663
|
try {
|
|
@@ -1986,8 +2010,62 @@ async function resolveWorkspaceRuntimeEnv(shell, scope) {
|
|
|
1986
2010
|
assertEnvWithinLimits(env);
|
|
1987
2011
|
return env;
|
|
1988
2012
|
}
|
|
1989
|
-
|
|
1990
|
-
|
|
2013
|
+
function prefetchExistingBoxReads(shell, box, runtimeEnv, measure) {
|
|
2014
|
+
const prefetch = {};
|
|
2015
|
+
if (shell.egressPolicy && hasVerifiedEgress(box, shell.egressPolicy)) {
|
|
2016
|
+
prefetch.egressVerified = true;
|
|
2017
|
+
} else if (shell.egressPolicy) {
|
|
2018
|
+
prefetch.egress = measure("egress", async () => {
|
|
2019
|
+
try {
|
|
2020
|
+
return ok(await box.egress.get());
|
|
2021
|
+
} catch (cause) {
|
|
2022
|
+
return fail(cause);
|
|
2023
|
+
}
|
|
2024
|
+
});
|
|
2025
|
+
}
|
|
2026
|
+
if (shell.deferProfileFiles) prefetch.corpusMarker = readDeferredCorpusMarker(box);
|
|
2027
|
+
if (!egressGatesCredentials(shell.egressPolicy)) {
|
|
2028
|
+
prefetch.runtimeEnv = runtimeEnv.then(
|
|
2029
|
+
(env) => Object.keys(env).length === 0 ? ok(void 0) : measure("runtime_env_push", () => box.setRuntimeEnv(env)).then(() => ok(void 0), (cause) => fail(cause)),
|
|
2030
|
+
() => ok(void 0)
|
|
2031
|
+
);
|
|
2032
|
+
}
|
|
2033
|
+
return prefetch;
|
|
2034
|
+
}
|
|
2035
|
+
function egressGatesCredentials(desired) {
|
|
2036
|
+
return desired !== void 0 && desired.mode !== "open";
|
|
2037
|
+
}
|
|
2038
|
+
var VERIFIED_EGRESS_TTL_MS = 10 * 6e4;
|
|
2039
|
+
var VERIFIED_EGRESS_MAX = 1e3;
|
|
2040
|
+
function verifiedEgressKey(box, desired) {
|
|
2041
|
+
if (desired.mode !== "open" || !box.id) return null;
|
|
2042
|
+
const startedAt = box.startedAt instanceof Date ? box.startedAt.getTime() : Number.NaN;
|
|
2043
|
+
if (!Number.isFinite(startedAt)) return null;
|
|
2044
|
+
return `${box.id}|${startedAt}|${normalizedEgressPolicy(desired)}`;
|
|
2045
|
+
}
|
|
2046
|
+
function hasVerifiedEgress(box, desired, now = Date.now()) {
|
|
2047
|
+
const key = verifiedEgressKey(box, desired);
|
|
2048
|
+
if (!key) return false;
|
|
2049
|
+
const verifiedAt = verifiedEgress.get(key);
|
|
2050
|
+
if (verifiedAt !== void 0 && now - verifiedAt < VERIFIED_EGRESS_TTL_MS) return true;
|
|
2051
|
+
verifiedEgress.delete(key);
|
|
2052
|
+
return false;
|
|
2053
|
+
}
|
|
2054
|
+
function recordVerifiedEgress(box, desired) {
|
|
2055
|
+
const key = verifiedEgressKey(box, desired);
|
|
2056
|
+
if (!key) return;
|
|
2057
|
+
verifiedEgress.delete(key);
|
|
2058
|
+
verifiedEgress.set(key, Date.now());
|
|
2059
|
+
while (verifiedEgress.size > VERIFIED_EGRESS_MAX) {
|
|
2060
|
+
const oldest = verifiedEgress.keys().next().value;
|
|
2061
|
+
if (oldest === void 0) break;
|
|
2062
|
+
verifiedEgress.delete(oldest);
|
|
2063
|
+
}
|
|
2064
|
+
}
|
|
2065
|
+
async function finalizeExistingBox(shell, client, box, stage, name, workspaceId, userId, harness, scope, runtimeEnv, prefetch = {}) {
|
|
2066
|
+
if (!prefetch.egressVerified) {
|
|
2067
|
+
await assertExistingBoxEgress(box, shell.egressPolicy, shell.migrateEgressPolicy, stage, name, prefetch.egress);
|
|
2068
|
+
}
|
|
1991
2069
|
const written = await materializeDeferredFilesForExistingBox(
|
|
1992
2070
|
shell,
|
|
1993
2071
|
client,
|
|
@@ -1996,13 +2074,17 @@ async function finalizeExistingBox(shell, client, box, stage, name, workspaceId,
|
|
|
1996
2074
|
name,
|
|
1997
2075
|
workspaceId,
|
|
1998
2076
|
userId,
|
|
1999
|
-
harness
|
|
2077
|
+
harness,
|
|
2078
|
+
prefetch.corpusMarker
|
|
2000
2079
|
);
|
|
2001
2080
|
if (!written.succeeded) {
|
|
2002
2081
|
throw deferredProfileWriteFailed(stage, name, written.error);
|
|
2003
2082
|
}
|
|
2004
2083
|
const finalBox = written.value;
|
|
2005
|
-
if (
|
|
2084
|
+
if (prefetch.runtimeEnv) {
|
|
2085
|
+
const renewed = await prefetch.runtimeEnv;
|
|
2086
|
+
if (!renewed.succeeded) throw renewed.error;
|
|
2087
|
+
} else if (Object.keys(runtimeEnv).length > 0) {
|
|
2006
2088
|
await finalBox.setRuntimeEnv(runtimeEnv);
|
|
2007
2089
|
}
|
|
2008
2090
|
if (shell.bootstrap) {
|
|
@@ -2048,23 +2130,35 @@ function existingBoxEgressError(operation, box, stage, name, cause) {
|
|
|
2048
2130
|
}
|
|
2049
2131
|
);
|
|
2050
2132
|
}
|
|
2051
|
-
async function assertExistingBoxEgress(box, desired, migrate, stage, name) {
|
|
2133
|
+
async function assertExistingBoxEgress(box, desired, migrate, stage, name, prefetched) {
|
|
2052
2134
|
if (!desired) return;
|
|
2053
2135
|
let current;
|
|
2054
|
-
|
|
2055
|
-
|
|
2056
|
-
|
|
2057
|
-
|
|
2136
|
+
if (prefetched) {
|
|
2137
|
+
const read = await prefetched;
|
|
2138
|
+
if (!read.succeeded) throw existingBoxEgressError("read", box, stage, name, read.error);
|
|
2139
|
+
current = read.value;
|
|
2140
|
+
} else {
|
|
2141
|
+
try {
|
|
2142
|
+
current = await box.egress.get();
|
|
2143
|
+
} catch (cause) {
|
|
2144
|
+
throw existingBoxEgressError("read", box, stage, name, cause);
|
|
2145
|
+
}
|
|
2058
2146
|
}
|
|
2059
2147
|
const matchingPolicy = normalizedEgressPolicy(current.policy) === normalizedEgressPolicy(desired);
|
|
2060
2148
|
const explicitSource = current.source !== "platform";
|
|
2061
|
-
if (matchingPolicy && explicitSource)
|
|
2149
|
+
if (matchingPolicy && explicitSource) {
|
|
2150
|
+
recordVerifiedEgress(box, desired);
|
|
2151
|
+
return;
|
|
2152
|
+
}
|
|
2062
2153
|
if (migrate) {
|
|
2063
2154
|
try {
|
|
2064
2155
|
await box.egress.update(desired);
|
|
2065
2156
|
const migrated = await box.egress.get();
|
|
2066
2157
|
const migratedPolicy = normalizedEgressPolicy(migrated.policy) === normalizedEgressPolicy(desired);
|
|
2067
|
-
if (migratedPolicy && migrated.source !== "platform")
|
|
2158
|
+
if (migratedPolicy && migrated.source !== "platform") {
|
|
2159
|
+
recordVerifiedEgress(box, desired);
|
|
2160
|
+
return;
|
|
2161
|
+
}
|
|
2068
2162
|
current = migrated;
|
|
2069
2163
|
} catch (cause) {
|
|
2070
2164
|
throw existingBoxEgressError("migration", box, stage, name, cause);
|
|
@@ -2171,8 +2265,10 @@ async function provisionWorkspaceSandbox(shell, options) {
|
|
|
2171
2265
|
throw new Error(`forceNew: sandbox ${name} could not be deleted`, { cause: dropped.error });
|
|
2172
2266
|
}
|
|
2173
2267
|
} else if (found.metadata?.harness === harness) {
|
|
2268
|
+
const runtimeEnvMint = measure("runtime_env", () => resolveWorkspaceRuntimeEnv(shell, scope));
|
|
2269
|
+
const prefetch = prefetchExistingBoxReads(shell, found, runtimeEnvMint, measure);
|
|
2174
2270
|
const [envResult, readyResult] = await Promise.allSettled([
|
|
2175
|
-
|
|
2271
|
+
runtimeEnvMint,
|
|
2176
2272
|
measure("refresh", () => refreshRuntimeConnection(client, found))
|
|
2177
2273
|
]);
|
|
2178
2274
|
if (envResult.status === "rejected") throw envResult.reason;
|
|
@@ -2181,7 +2277,7 @@ async function provisionWorkspaceSandbox(shell, options) {
|
|
|
2181
2277
|
if (readyResult.status === "rejected") throw readyResult.reason;
|
|
2182
2278
|
const ready = readyResult.value;
|
|
2183
2279
|
if ((await measure("liveness", () => isReusableBox(ready, shell.livenessProbe))).succeeded) {
|
|
2184
|
-
return await measure("finalize", () => finalizeExistingBox(shell, client, ready, "reused", name, workspaceId, userId, harness, scope, runtimeEnv2));
|
|
2280
|
+
return await measure("finalize", () => finalizeExistingBox(shell, client, ready, "reused", name, workspaceId, userId, harness, scope, runtimeEnv2, prefetch));
|
|
2185
2281
|
}
|
|
2186
2282
|
const recovered = await recoverUnresponsiveBox(
|
|
2187
2283
|
client,
|
|
@@ -2292,7 +2388,7 @@ async function provisionWorkspaceSandbox(shell, options) {
|
|
|
2292
2388
|
}
|
|
2293
2389
|
}
|
|
2294
2390
|
const storage = shell.storage?.(buildCtx);
|
|
2295
|
-
const restore = recoveryRestore === void 0 ? shell.restore?.(buildCtx) : recoveryRestore;
|
|
2391
|
+
const restore = recoveryRestore === void 0 ? await shell.restore?.(buildCtx) : recoveryRestore;
|
|
2296
2392
|
const payload = {
|
|
2297
2393
|
name,
|
|
2298
2394
|
image: resources.image,
|
|
@@ -3035,4 +3131,4 @@ export {
|
|
|
3035
3131
|
isTerminalPromptEvent,
|
|
3036
3132
|
detectInteractiveQuestion
|
|
3037
3133
|
};
|
|
3038
|
-
//# sourceMappingURL=chunk-
|
|
3134
|
+
//# sourceMappingURL=chunk-BTBDJNHK.js.map
|