t3code-cli 0.14.1 → 0.14.2
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/README.md +1 -0
- package/dist/application.d.ts +2 -2
- package/dist/application.js +1 -1
- package/dist/auth.d.ts +1 -1
- package/dist/auth.js +1 -1
- package/dist/bin.js +544 -262
- package/dist/cli.d.ts +1 -1
- package/dist/cli.js +1 -1
- package/dist/client-runtime/authorization.d.ts +1 -1
- package/dist/client-runtime/authorization.js +1 -1
- package/dist/client-runtime/connection.d.ts +1 -1
- package/dist/client-runtime/connection.js +1 -1
- package/dist/client-runtime/environment.d.ts +5 -1
- package/dist/client-runtime/environment.js +1 -1
- package/dist/client-runtime/errors.js +1 -1
- package/dist/client-runtime/operations/projects.d.ts +2 -2
- package/dist/client-runtime/operations/projects.js +2 -2
- package/dist/client-runtime/operations.d.ts +2 -2
- package/dist/client-runtime/operations.js +2 -2
- package/dist/client-runtime/platform.d.ts +1 -1
- package/dist/client-runtime/platform.js +1 -1
- package/dist/client-runtime/relay.d.ts +5 -1
- package/dist/client-runtime/relay.js +1 -1
- package/dist/client-runtime/rpc.d.ts +2 -2
- package/dist/client-runtime/rpc.js +2 -2
- package/dist/client-runtime/state/assets.d.ts +17 -11
- package/dist/client-runtime/state/assets.js +1 -1
- package/dist/client-runtime/state/auth.d.ts +1 -1
- package/dist/client-runtime/state/auth.js +1 -1
- package/dist/client-runtime/state/connections.js +1 -1
- package/dist/client-runtime/state/entities.d.ts +1 -1
- package/dist/client-runtime/state/entities.js +1 -1
- package/dist/client-runtime/state/filesystem.d.ts +1 -1
- package/dist/client-runtime/state/filesystem.js +1 -1
- package/dist/client-runtime/state/git.d.ts +5 -5
- package/dist/client-runtime/state/git.js +1 -1
- package/dist/client-runtime/state/models.d.ts +1 -1
- package/dist/client-runtime/state/models.js +1 -1
- package/dist/client-runtime/state/orchestration.d.ts +42 -2
- package/dist/client-runtime/state/orchestration.js +13 -1
- package/dist/client-runtime/state/presentation.d.ts +9 -3
- package/dist/client-runtime/state/presentation.js +1 -1
- package/dist/client-runtime/state/preview.d.ts +55 -48
- package/dist/client-runtime/state/preview.js +1 -1
- package/dist/client-runtime/state/project-grouping.d.ts +26 -2
- package/dist/client-runtime/state/project-grouping.js +83 -3
- package/dist/client-runtime/state/projects.d.ts +24 -18
- package/dist/client-runtime/state/projects.js +1 -1
- package/dist/client-runtime/state/relay.d.ts +1 -1
- package/dist/client-runtime/state/relay.js +1 -1
- package/dist/client-runtime/state/review.d.ts +16 -1
- package/dist/client-runtime/state/review.js +27 -6
- package/dist/client-runtime/state/runtime.d.ts +2 -2
- package/dist/client-runtime/state/runtime.js +2 -2
- package/dist/client-runtime/state/server.d.ts +299 -172
- package/dist/client-runtime/state/server.js +192 -16
- package/dist/client-runtime/state/session.d.ts +65 -7
- package/dist/client-runtime/state/session.js +32 -3
- package/dist/client-runtime/state/shell.d.ts +41 -7
- package/dist/client-runtime/state/shell.js +1 -1
- package/dist/client-runtime/state/source-control.d.ts +2 -2
- package/dist/client-runtime/state/source-control.js +1 -1
- package/dist/client-runtime/state/subagentRuntime.d.ts +145 -0
- package/dist/client-runtime/state/subagentRuntime.js +521 -0
- package/dist/client-runtime/state/terminal.d.ts +17 -17
- package/dist/client-runtime/state/terminal.js +1 -1
- package/dist/client-runtime/state/thread-search.d.ts +23 -0
- package/dist/client-runtime/state/thread-search.js +38 -0
- package/dist/client-runtime/state/thread-settled.d.ts +28 -3
- package/dist/client-runtime/state/thread-settled.js +74 -2
- package/dist/client-runtime/state/thread-sort.d.ts +59 -2
- package/dist/client-runtime/state/thread-sort.js +128 -2
- package/dist/client-runtime/state/threads.d.ts +115 -3
- package/dist/client-runtime/state/threads.js +309 -28
- package/dist/client-runtime/state/vcs.d.ts +14 -14
- package/dist/client-runtime/state/vcs.js +1 -1
- package/dist/config.d.ts +1 -1
- package/dist/config.js +1 -1
- package/dist/connection.d.ts +1 -1
- package/dist/connection.js +1 -1
- package/dist/contracts.d.ts +1 -1
- package/dist/contracts.js +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/node.d.ts +1 -1
- package/dist/node.js +1 -1
- package/dist/orchestration.d.ts +144 -1
- package/dist/orchestration.js +1 -1
- package/dist/preview.d.ts +1 -1
- package/dist/preview.js +1 -1
- package/dist/rpc.d.ts +883 -351
- package/dist/rpc.js +1 -1
- package/dist/runtime.d.ts +1 -1
- package/dist/runtime.js +1 -1
- package/dist/shared/DrainableWorker.js +1 -1
- package/dist/shared/KeyedCoalescingWorker.js +1 -1
- package/dist/shared/Net.js +1 -1
- package/dist/shared/advertisedEndpoint.d.ts +1 -1
- package/dist/shared/advertisedEndpoint.js +1 -1
- package/dist/shared/agentAwareness.d.ts +1 -1
- package/dist/shared/backgroundActivitySettings.d.ts +1 -1
- package/dist/shared/composerInlineTokens.js +1 -1
- package/dist/shared/connectAuth.js +1 -1
- package/dist/shared/devHome.js +1 -1
- package/dist/shared/dpop.js +1 -1
- package/dist/shared/git.d.ts +1 -1
- package/dist/shared/httpObservability.js +1 -1
- package/dist/shared/httpReadiness.js +1 -1
- package/dist/shared/keybindings.d.ts +2 -2
- package/dist/shared/keybindings.js +15 -1
- package/dist/shared/model.d.ts +1 -1
- package/dist/shared/oauthScope.js +1 -1
- package/dist/shared/observability.d.ts +8 -1
- package/dist/shared/observability.js +49 -5
- package/dist/shared/path.js +1 -1
- package/dist/shared/preview.js +1 -1
- package/dist/shared/previewViewport.d.ts +1 -1
- package/dist/shared/previewViewport.js +1 -1
- package/dist/shared/projectFavicon.d.ts +2 -1
- package/dist/shared/projectFavicon.js +13 -1
- package/dist/shared/projectScripts.d.ts +1 -1
- package/dist/shared/relayAuth.js +1 -1
- package/dist/shared/relayClient.d.ts +1 -1
- package/dist/shared/relayClient.js +1 -1
- package/dist/shared/relayJwt.js +1 -1
- package/dist/shared/relayTracing.js +1 -1
- package/dist/shared/relayUrl.js +1 -1
- package/dist/shared/remote.js +1 -1
- package/dist/shared/schemaYaml.js +3 -3
- package/dist/shared/semver.js +1 -1
- package/dist/shared/serverSettings.d.ts +1 -1
- package/dist/shared/serverSettings.js +1 -1
- package/dist/shared/shell.d.ts +6 -1
- package/dist/shared/shell.js +42 -4
- package/dist/shared/sourceControl.d.ts +1 -1
- package/dist/shared/t3ProjectFile.d.ts +9 -1
- package/dist/shared/t3ProjectFile.js +12 -2
- package/dist/shared/terminalLabels.d.ts +1 -1
- package/dist/shared/threadEnvMode.d.ts +29 -0
- package/dist/shared/threadEnvMode.js +24 -0
- package/dist/shared/toolActivity.d.ts +1 -1
- package/dist/shared/usageFormat.d.ts +21 -0
- package/dist/shared/usageFormat.js +90 -0
- package/dist/shared/usageMerge.d.ts +67 -0
- package/dist/shared/usageMerge.js +218 -0
- package/dist/shared.d.ts +4472 -668
- package/dist/shared.js +16867 -16273
- package/dist/t3tools.d.ts +2 -2
- package/dist/t3tools.js +2 -2
- package/package.json +5 -5
- package/src/application/index.ts +1 -0
- package/src/application/service.ts +5 -1
- package/src/application/threads.ts +43 -1
- package/src/cli/app.ts +2 -0
- package/src/cli/format/thread.ts +23 -1
- package/src/cli/search.ts +48 -0
- package/src/config/persist/schema.ts +1 -1
- package/src/orchestration/layer.ts +6 -0
- package/src/orchestration/service.ts +5 -0
- package/src/rpc/error.ts +2 -0
- package/src/rpc/operation.ts +2 -0
- package/src/rpc/ws-group.ts +2 -0
|
@@ -1,5 +1,97 @@
|
|
|
1
|
-
import { $
|
|
1
|
+
import { $r as make, AD as TaggedErrorClass, AO as fromQueue, Aj as none, Ak as exit, Ba as safeErrorLogAttributes, Bk as gen, Cj as getOrNull, DO as filterMap, Dj as isSome, Dk as catch_, EO as filter, Ej as isNone, FA as squash, Fy as get, Gk as map$1, HO as runHead, Ia as EnvironmentSupervisor, Iy as make$1, Jr as runStream, Kr as isRpcClientError, Ly as set$1, MA as hasInterruptsOnly, Mj as toArray, Mk as failCause, Mr as scheduleAtomCommandEffect, NA as isFailReason, NO as mapAccum, Nk as flatMap, OD as String, Oj as map, Pa as EnvironmentRegistry, Pk as fn, Py as changes, Rk as forkChild, SO as debounce, Tr as followStreamInEnvironment, Us as WS_METHODS, VD as optional, VO as runForEach, Vk as ignore, Wa as EnvironmentCacheStore, Wk as logWarning, XA as isSuccess, Xk as onExit, YA as isFailure, YO as unwrap, Yr as subscribe, Zr as family, aj as failVoid, bA as void_, bT as set, bk as as, br as createRuntimeCommand, cA as succeed, ck as sliding, ei as setIdleTTL, fj as minutes, gk as addFinalizer, gr as createEnvironmentRpcQueryAtomFamily, hr as createEnvironmentRpcCommand, ik as offer, jj as some, jk as fail, kj as match, lj as succeed$1, ni as withLabel, pA as timeoutOption, pj as seconds, pr as createAtomCommandScheduler, qr as request, sA as sleep, si as value, uA as sync, vT as get$1, vk as andThen, vr as createEnvironmentRpcSubscriptionAtomFamily, wD as Literals, xT as update, xk as asVoid, yT as make$2, yj as flatten, yk as annotateLogs, zk as forkScoped } from "../../shared.js";
|
|
2
2
|
//#region upstream-t3code/packages/client-runtime/src/state/server.ts
|
|
3
|
+
const IDLE_SERVER_UPDATE_STATE = { status: "idle" };
|
|
4
|
+
const EMPTY_SERVER_UPDATE_STATE_ATOM = make(IDLE_SERVER_UPDATE_STATE).pipe(withLabel("environment-data:server:update-state:empty"));
|
|
5
|
+
const serverUpdateStateAtom = family((environmentId) => make(IDLE_SERVER_UPDATE_STATE).pipe(withLabel(`environment-data:server:update-state:${environmentId}`)));
|
|
6
|
+
var ServerUpdateResumeTimeoutError = class extends TaggedErrorClass()("ServerUpdateResumeTimeoutError", {
|
|
7
|
+
environmentId: String,
|
|
8
|
+
targetVersion: String
|
|
9
|
+
}) {
|
|
10
|
+
get message() {
|
|
11
|
+
return `The server did not resume on t3@${this.targetVersion}.`;
|
|
12
|
+
}
|
|
13
|
+
};
|
|
14
|
+
var ServerUpdateProgressIncompleteError = class extends TaggedErrorClass()("ServerUpdateProgressIncompleteError", { targetVersion: String }) {
|
|
15
|
+
get message() {
|
|
16
|
+
return `The t3@${this.targetVersion} update ended before the server accepted the restart.`;
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
var ServerUpdateTerminalError = class extends TaggedErrorClass()("ServerUpdateTerminalError", {
|
|
20
|
+
targetVersion: String,
|
|
21
|
+
status: Literals([
|
|
22
|
+
"committed",
|
|
23
|
+
"rolled-back",
|
|
24
|
+
"failed"
|
|
25
|
+
]),
|
|
26
|
+
reason: optional(String)
|
|
27
|
+
}) {
|
|
28
|
+
get message() {
|
|
29
|
+
return this.reason ?? `The t3@${this.targetVersion} update ${this.status}.`;
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
const SERVER_UPDATE_RESUME_TIMEOUT = minutes(4);
|
|
33
|
+
function matchesServerUpdateReadyEvent(result, event) {
|
|
34
|
+
return result.updateId === void 0 ? event.payload.environment.serverVersion === result.targetVersion : event.payload.updateOutcome?.id === result.updateId;
|
|
35
|
+
}
|
|
36
|
+
function validateServerUpdateReadyEvent(result, event) {
|
|
37
|
+
if (result.updateId === void 0) return void_;
|
|
38
|
+
const outcome = event.payload.updateOutcome;
|
|
39
|
+
if (outcome?.id === result.updateId && outcome.status === "committed" && outcome.targetVersion === result.targetVersion && event.payload.environment.serverVersion === result.targetVersion) return void_;
|
|
40
|
+
return fail(new ServerUpdateTerminalError({
|
|
41
|
+
targetVersion: result.targetVersion,
|
|
42
|
+
status: outcome?.status ?? "failed",
|
|
43
|
+
reason: outcome?.reason ?? "The service launcher resumed without committing the requested server version."
|
|
44
|
+
}));
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Keeps reconnect attempts ~1s apart for the whole update restart.
|
|
48
|
+
*
|
|
49
|
+
* A restart takes the server down for ~15 seconds, but the supervisor's normal
|
|
50
|
+
* backoff ladder (1/2/4/8/16s) assumes an unexpected failure and lands attempts
|
|
51
|
+
* at ~3, 5, 9, 17 and 33 seconds — so a 15-second restart is observed as a
|
|
52
|
+
* 33-second "Resuming". Nudging on every backoff entry (not just the first)
|
|
53
|
+
* holds the retry cadence flat until the server answers again. The sleep before
|
|
54
|
+
* each nudge is the pacer: a connection that fails instantly re-enters backoff
|
|
55
|
+
* immediately and would otherwise spin a tight retry loop.
|
|
56
|
+
*
|
|
57
|
+
* Callers fork this as a child of the update command so it is interrupted as
|
|
58
|
+
* soon as the update settles, whether it succeeds, fails, or times out.
|
|
59
|
+
*/
|
|
60
|
+
function nudgeReconnectDuringUpdateRestart(input) {
|
|
61
|
+
return input.stateChanges.pipe(filter((state) => state.phase === "backoff"), runForEach(() => sleep(input.interval ?? seconds(1)).pipe(andThen(input.retryNow))), timeoutOption(SERVER_UPDATE_RESUME_TIMEOUT), ignore);
|
|
62
|
+
}
|
|
63
|
+
function serverUpdateStateForProgressEvent(fromVersion, targetVersion, event) {
|
|
64
|
+
return {
|
|
65
|
+
status: "running",
|
|
66
|
+
stage: event.type === "complete" ? "resuming" : event.stage,
|
|
67
|
+
fromVersion,
|
|
68
|
+
targetVersion
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
function serverUpdateStateForServerVersion(state, serverVersion) {
|
|
72
|
+
return state.status === "idle" || state.status === "running" || serverVersion === null || state.fromVersion === serverVersion ? state : IDLE_SERVER_UPDATE_STATE;
|
|
73
|
+
}
|
|
74
|
+
function serverUpdateFailureMessage(error) {
|
|
75
|
+
return error instanceof Error ? error.message : "Server update failed.";
|
|
76
|
+
}
|
|
77
|
+
function isRpcSocketError(error) {
|
|
78
|
+
if (!isRpcClientError(error)) return false;
|
|
79
|
+
switch (error.reason._tag) {
|
|
80
|
+
case "SocketReadError":
|
|
81
|
+
case "SocketWriteError":
|
|
82
|
+
case "SocketCloseError": return true;
|
|
83
|
+
default: return false;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
function isLegacyUpdateHandoffLoss(cause) {
|
|
87
|
+
if (hasInterruptsOnly(cause)) return true;
|
|
88
|
+
return cause.reasons.length > 0 && cause.reasons.every((reason) => isFailReason(reason) && isRpcSocketError(reason.error));
|
|
89
|
+
}
|
|
90
|
+
function resolveServerUpdateProgressResult(targetVersion, terminal, streamExit) {
|
|
91
|
+
if (isSome(terminal) && (isSuccess(streamExit) || isLegacyUpdateHandoffLoss(streamExit.cause))) return succeed(terminal.value);
|
|
92
|
+
if (isFailure(streamExit)) return failCause(streamExit.cause);
|
|
93
|
+
return fail(new ServerUpdateProgressIncompleteError({ targetVersion }));
|
|
94
|
+
}
|
|
3
95
|
function applyServerConfigProjection(current, event) {
|
|
4
96
|
switch (event.type) {
|
|
5
97
|
case "snapshot": return some({
|
|
@@ -52,7 +144,7 @@ const makeEnvironmentServerConfigState = fn("EnvironmentServerConfigState.make")
|
|
|
52
144
|
const supervisor = yield* EnvironmentSupervisor;
|
|
53
145
|
const cache = yield* EnvironmentCacheStore;
|
|
54
146
|
const environmentId = supervisor.target.environmentId;
|
|
55
|
-
const state = yield* make(map(yield* cache.loadServerConfig(environmentId).pipe(catch_((error) => logWarning("Could not load cached server configuration.").pipe(annotateLogs({
|
|
147
|
+
const state = yield* make$1(map(yield* cache.loadServerConfig(environmentId).pipe(catch_((error) => logWarning("Could not load cached server configuration.").pipe(annotateLogs({
|
|
56
148
|
environmentId,
|
|
57
149
|
...safeErrorLogAttributes(error)
|
|
58
150
|
}), as(none())))), (config) => ({
|
|
@@ -61,7 +153,7 @@ const makeEnvironmentServerConfigState = fn("EnvironmentServerConfigState.make")
|
|
|
61
153
|
source: "cache"
|
|
62
154
|
})));
|
|
63
155
|
const persistence = yield* sliding(1);
|
|
64
|
-
const pendingPersistence = yield* make$
|
|
156
|
+
const pendingPersistence = yield* make$2(none());
|
|
65
157
|
const persist = fn("EnvironmentServerConfigState.persist")(function* (config) {
|
|
66
158
|
return yield* cache.saveServerConfig(environmentId, config).pipe(as(true), catch_((error) => logWarning("Could not persist cached server configuration.").pipe(annotateLogs({
|
|
67
159
|
environmentId,
|
|
@@ -89,7 +181,7 @@ const makeEnvironmentServerConfigState = fn("EnvironmentServerConfigState.make")
|
|
|
89
181
|
function serverConfigStateChanges(environmentId) {
|
|
90
182
|
return followStreamInEnvironment(environmentId, unwrap(makeEnvironmentServerConfigState().pipe(map$1((state) => changes(state).pipe(filterMap((projection) => match(projection, {
|
|
91
183
|
onNone: () => failVoid,
|
|
92
|
-
onSome: (value) => succeed(value)
|
|
184
|
+
onSome: (value) => succeed$1(value)
|
|
93
185
|
})))))));
|
|
94
186
|
}
|
|
95
187
|
function projectServerWelcome(current, event) {
|
|
@@ -98,31 +190,115 @@ function projectServerWelcome(current, event) {
|
|
|
98
190
|
return [some(welcome), [welcome]];
|
|
99
191
|
}
|
|
100
192
|
function resolveServerConfigValue(projection, initialConfig) {
|
|
101
|
-
if (projection?.source === "live") return projection.config;
|
|
193
|
+
if (projection?.source === "live" && (initialConfig === null || projection.config.environment.serverVersion === initialConfig.environment.serverVersion)) return projection.config;
|
|
102
194
|
return initialConfig ?? projection?.config ?? null;
|
|
103
195
|
}
|
|
104
196
|
function createServerEnvironmentAtoms(runtime, options) {
|
|
105
197
|
const configScheduler = createAtomCommandScheduler();
|
|
198
|
+
const updateScheduler = createAtomCommandScheduler();
|
|
106
199
|
const configConcurrency = {
|
|
107
200
|
mode: "serial",
|
|
108
201
|
key: ({ environmentId }) => environmentId
|
|
109
202
|
};
|
|
110
203
|
const configProjectionFamily = family((environmentId) => runtime.atom(serverConfigStateChanges(environmentId)).pipe(setIdleTTL(5 * 6e4), withLabel(`environment-data:server:config-projection:${environmentId}`)));
|
|
111
204
|
const configProjection = (target) => configProjectionFamily(target.environmentId);
|
|
112
|
-
const emptyConfigAtom = make
|
|
205
|
+
const emptyConfigAtom = make(null).pipe(withLabel("environment-data:server:config:empty"));
|
|
113
206
|
const configValueAtom = family((environmentId) => {
|
|
114
207
|
if (environmentId === null) return emptyConfigAtom;
|
|
115
|
-
return make
|
|
208
|
+
return make((get) => {
|
|
116
209
|
return resolveServerConfigValue(getOrNull(value(get(configProjection({
|
|
117
210
|
environmentId,
|
|
118
211
|
input: {}
|
|
119
212
|
})))), get(options.initialConfigValueAtom(environmentId)));
|
|
120
213
|
}).pipe(withLabel(`environment-data:server:config:${environmentId}`));
|
|
121
214
|
});
|
|
215
|
+
const updateStateValueAtom = family((environmentId) => make((get) => serverUpdateStateForServerVersion(get(serverUpdateStateAtom(environmentId)), get(configValueAtom(environmentId))?.environment.serverVersion ?? null)).pipe(withLabel(`environment-data:server:update-state-value:${environmentId}`)));
|
|
216
|
+
const updateStateAtom = (environmentId) => environmentId === null ? EMPTY_SERVER_UPDATE_STATE_ATOM : updateStateValueAtom(environmentId);
|
|
217
|
+
const updateServer = createRuntimeCommand(runtime, {
|
|
218
|
+
label: "environment-data:server:update-server",
|
|
219
|
+
scheduler: updateScheduler,
|
|
220
|
+
concurrency: configConcurrency,
|
|
221
|
+
execute: (target, atomRegistry) => {
|
|
222
|
+
const stateAtom = serverUpdateStateAtom(target.environmentId);
|
|
223
|
+
const targetVersion = target.input.targetVersion;
|
|
224
|
+
let fromVersion = atomRegistry.get(configValueAtom(target.environmentId))?.environment.serverVersion ?? targetVersion;
|
|
225
|
+
let currentStage = "downloading";
|
|
226
|
+
atomRegistry.set(stateAtom, {
|
|
227
|
+
status: "running",
|
|
228
|
+
stage: currentStage,
|
|
229
|
+
fromVersion,
|
|
230
|
+
targetVersion
|
|
231
|
+
});
|
|
232
|
+
return gen(function* () {
|
|
233
|
+
const environmentRegistry = yield* EnvironmentRegistry;
|
|
234
|
+
const result = yield* scheduleAtomCommandEffect(atomRegistry, configScheduler, configConcurrency, target, gen(function* () {
|
|
235
|
+
const currentConfig = atomRegistry.get(configValueAtom(target.environmentId));
|
|
236
|
+
fromVersion = currentConfig?.environment.serverVersion ?? targetVersion;
|
|
237
|
+
atomRegistry.set(stateAtom, {
|
|
238
|
+
status: "running",
|
|
239
|
+
stage: currentStage,
|
|
240
|
+
fromVersion,
|
|
241
|
+
targetVersion
|
|
242
|
+
});
|
|
243
|
+
const updateResult = currentConfig?.environment.capabilities.serverSelfUpdateProgress === true ? yield* gen(function* () {
|
|
244
|
+
const terminal = yield* make$2(none());
|
|
245
|
+
const streamExit = yield* environmentRegistry.runStream(target.environmentId, runStream(WS_METHODS.serverUpdateServerWithProgress, target.input)).pipe(runForEach((event) => sync(() => {
|
|
246
|
+
currentStage = event.type === "complete" ? "resuming" : event.stage;
|
|
247
|
+
atomRegistry.set(stateAtom, serverUpdateStateForProgressEvent(fromVersion, targetVersion, event));
|
|
248
|
+
}).pipe(andThen(event.type === "complete" ? set(terminal, some(event.result)) : void_))), exit);
|
|
249
|
+
return yield* resolveServerUpdateProgressResult(targetVersion, yield* get$1(terminal), streamExit);
|
|
250
|
+
}) : yield* gen(function* () {
|
|
251
|
+
const selfUpdateMethod = currentConfig?.environment.capabilities.serverSelfUpdate;
|
|
252
|
+
const exit$1 = yield* environmentRegistry.run(target.environmentId, request(WS_METHODS.serverUpdateServer, target.input)).pipe(exit);
|
|
253
|
+
if (isSuccess(exit$1)) return exit$1.value;
|
|
254
|
+
if ((selfUpdateMethod === "boot-service" || selfUpdateMethod === "respawn") && isLegacyUpdateHandoffLoss(exit$1.cause)) return {
|
|
255
|
+
targetVersion,
|
|
256
|
+
method: selfUpdateMethod
|
|
257
|
+
};
|
|
258
|
+
return yield* failCause(exit$1.cause);
|
|
259
|
+
});
|
|
260
|
+
currentStage = "resuming";
|
|
261
|
+
atomRegistry.set(stateAtom, {
|
|
262
|
+
status: "running",
|
|
263
|
+
stage: currentStage,
|
|
264
|
+
fromVersion,
|
|
265
|
+
targetVersion
|
|
266
|
+
});
|
|
267
|
+
return updateResult;
|
|
268
|
+
}));
|
|
269
|
+
yield* nudgeReconnectDuringUpdateRestart({
|
|
270
|
+
stateChanges: environmentRegistry.stateChanges(target.environmentId),
|
|
271
|
+
retryNow: environmentRegistry.retryNow(target.environmentId)
|
|
272
|
+
}).pipe(forkChild);
|
|
273
|
+
const resumed = yield* environmentRegistry.followStream(target.environmentId, subscribe(WS_METHODS.subscribeServerLifecycle, {})).pipe(filter((event) => event.type === "ready" && matchesServerUpdateReadyEvent(result, event)), runHead, timeoutOption(SERVER_UPDATE_RESUME_TIMEOUT), map$1(flatten));
|
|
274
|
+
if (isNone(resumed)) return yield* new ServerUpdateResumeTimeoutError({
|
|
275
|
+
environmentId: target.environmentId,
|
|
276
|
+
targetVersion
|
|
277
|
+
});
|
|
278
|
+
yield* validateServerUpdateReadyEvent(result, resumed.value);
|
|
279
|
+
atomRegistry.set(stateAtom, IDLE_SERVER_UPDATE_STATE);
|
|
280
|
+
return result;
|
|
281
|
+
}).pipe(onExit((exit) => sync(() => {
|
|
282
|
+
if (isSuccess(exit)) return;
|
|
283
|
+
if (hasInterruptsOnly(exit.cause)) {
|
|
284
|
+
atomRegistry.set(stateAtom, IDLE_SERVER_UPDATE_STATE);
|
|
285
|
+
return;
|
|
286
|
+
}
|
|
287
|
+
atomRegistry.set(stateAtom, {
|
|
288
|
+
status: "failed",
|
|
289
|
+
stage: currentStage,
|
|
290
|
+
fromVersion,
|
|
291
|
+
targetVersion,
|
|
292
|
+
message: serverUpdateFailureMessage(squash(exit.cause))
|
|
293
|
+
});
|
|
294
|
+
})));
|
|
295
|
+
}
|
|
296
|
+
});
|
|
122
297
|
return {
|
|
123
298
|
configValueAtom,
|
|
124
|
-
|
|
125
|
-
|
|
299
|
+
updateStateAtom,
|
|
300
|
+
settingsValueAtom: family((environmentId) => make((get) => get(configValueAtom(environmentId))?.settings ?? null).pipe(withLabel(`environment-data:server:settings:${environmentId}`))),
|
|
301
|
+
providersValueAtom: family((environmentId) => make((get) => get(configValueAtom(environmentId))?.providers ?? null).pipe(withLabel(`environment-data:server:providers:${environmentId}`))),
|
|
126
302
|
traceDiagnostics: createEnvironmentRpcQueryAtomFamily(runtime, {
|
|
127
303
|
label: "environment-data:server:trace-diagnostics",
|
|
128
304
|
tag: WS_METHODS.serverGetTraceDiagnostics
|
|
@@ -145,6 +321,11 @@ function createServerEnvironmentAtoms(runtime, options) {
|
|
|
145
321
|
tag: WS_METHODS.serverGetResourceTelemetryHistory,
|
|
146
322
|
staleTimeMs: 5e3
|
|
147
323
|
}),
|
|
324
|
+
usageSummary: createEnvironmentRpcQueryAtomFamily(runtime, {
|
|
325
|
+
label: "environment-data:server:usage-summary",
|
|
326
|
+
tag: WS_METHODS.serverGetUsageSummary,
|
|
327
|
+
staleTimeMs: 6e4
|
|
328
|
+
}),
|
|
148
329
|
configProjection,
|
|
149
330
|
welcome: createEnvironmentRpcSubscriptionAtomFamily(runtime, {
|
|
150
331
|
label: "environment-data:server:welcome",
|
|
@@ -165,12 +346,7 @@ function createServerEnvironmentAtoms(runtime, options) {
|
|
|
165
346
|
scheduler: configScheduler,
|
|
166
347
|
concurrency: configConcurrency
|
|
167
348
|
}),
|
|
168
|
-
updateServer
|
|
169
|
-
label: "environment-data:server:update-server",
|
|
170
|
-
tag: WS_METHODS.serverUpdateServer,
|
|
171
|
-
scheduler: configScheduler,
|
|
172
|
-
concurrency: configConcurrency
|
|
173
|
-
}),
|
|
349
|
+
updateServer,
|
|
174
350
|
upsertKeybinding: createEnvironmentRpcCommand(runtime, {
|
|
175
351
|
label: "environment-data:server:upsert-keybinding",
|
|
176
352
|
tag: WS_METHODS.serverUpsertKeybinding,
|
|
@@ -204,4 +380,4 @@ function createServerEnvironmentAtoms(runtime, options) {
|
|
|
204
380
|
};
|
|
205
381
|
}
|
|
206
382
|
//#endregion
|
|
207
|
-
export { applyServerConfigProjection, createServerEnvironmentAtoms, makeEnvironmentServerConfigState, projectServerConfig, projectServerWelcome, resolveServerConfigValue, serverConfigStateChanges };
|
|
383
|
+
export { ServerUpdateProgressIncompleteError, ServerUpdateResumeTimeoutError, ServerUpdateTerminalError, applyServerConfigProjection, createServerEnvironmentAtoms, isLegacyUpdateHandoffLoss, makeEnvironmentServerConfigState, matchesServerUpdateReadyEvent, nudgeReconnectDuringUpdateRestart, projectServerConfig, projectServerWelcome, resolveServerConfigValue, resolveServerUpdateProgressResult, serverConfigStateChanges, serverUpdateStateForProgressEvent, serverUpdateStateForServerVersion, validateServerUpdateReadyEvent };
|
|
@@ -1,10 +1,32 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { $a as RemoteEnvironmentRequestError, Ta as EnvironmentRegistry, Td as KeybindingWhenNode, bo as ManagedRelayDpopSigner, du as ServerConfig, us as PreparedConnection } from "../../shared.js";
|
|
2
2
|
import * as Effect from "effect/Effect";
|
|
3
3
|
import * as Option from "effect/Option";
|
|
4
|
+
import { HttpClient } from "effect/unstable/http";
|
|
4
5
|
import { AsyncResult, Atom } from "effect/unstable/reactivity";
|
|
5
6
|
//#region upstream-t3code/packages/client-runtime/src/state/session.d.ts
|
|
6
7
|
declare function initialConfigOption<E>(initialConfig: Effect.Effect<ServerConfig, E>): Effect.Effect<Option.Option<ServerConfig>>;
|
|
7
|
-
|
|
8
|
+
/**
|
|
9
|
+
* Read the granted scopes of this client's session on one environment via its
|
|
10
|
+
* `/api/auth/session` endpoint, authenticated with whatever credential the
|
|
11
|
+
* connection was prepared with (cookie, bearer, or DPoP).
|
|
12
|
+
*/
|
|
13
|
+
declare const fetchEnvironmentSessionState: (input: {
|
|
14
|
+
readonly prepared: PreparedConnection;
|
|
15
|
+
readonly signer: Option.Option<ManagedRelayDpopSigner["Service"]>;
|
|
16
|
+
readonly timeoutMs?: number;
|
|
17
|
+
}) => Effect.Effect<{
|
|
18
|
+
readonly authenticated: boolean;
|
|
19
|
+
readonly auth: {
|
|
20
|
+
readonly policy: "desktop-managed-local" | "loopback-browser" | "remote-reachable" | "unsafe-no-auth";
|
|
21
|
+
readonly bootstrapMethods: readonly ("desktop-bootstrap" | "one-time-token")[];
|
|
22
|
+
readonly sessionMethods: readonly ("bearer-access-token" | "browser-session-cookie" | "dpop-access-token")[];
|
|
23
|
+
readonly sessionCookieName: string;
|
|
24
|
+
};
|
|
25
|
+
readonly scopes?: readonly ("access:read" | "access:write" | "orchestration:operate" | "orchestration:read" | "relay:read" | "relay:write" | "review:write" | "terminal:operate")[];
|
|
26
|
+
readonly sessionMethod?: "bearer-access-token" | "browser-session-cookie" | "dpop-access-token";
|
|
27
|
+
readonly expiresAt?: import("effect/DateTime").Utc;
|
|
28
|
+
}, RemoteEnvironmentRequestError, HttpClient.HttpClient>;
|
|
29
|
+
declare function createEnvironmentSessionAtoms<R, E>(runtime: Atom.AtomRuntime<EnvironmentRegistry | HttpClient.HttpClient | R, E>): {
|
|
8
30
|
initialConfigAtom: (arg: string & import("effect/Brand").Brand<"EnvironmentId">) => Atom.Atom<AsyncResult.AsyncResult<Option.Option<{
|
|
9
31
|
readonly environment: {
|
|
10
32
|
readonly environmentId: string & import("effect/Brand").Brand<"EnvironmentId">;
|
|
@@ -19,7 +41,11 @@ declare function createEnvironmentSessionAtoms<R, E>(runtime: Atom.AtomRuntime<E
|
|
|
19
41
|
readonly connectionProbe?: boolean;
|
|
20
42
|
readonly threadSettlement?: boolean;
|
|
21
43
|
readonly threadSnooze?: boolean;
|
|
44
|
+
readonly threadPinning?: boolean;
|
|
45
|
+
readonly threadPinReorder?: boolean;
|
|
46
|
+
readonly threadTitleRegeneration?: boolean;
|
|
22
47
|
readonly serverSelfUpdate?: "boot-service" | "desktop-managed" | "respawn";
|
|
48
|
+
readonly serverSelfUpdateProgress?: boolean;
|
|
23
49
|
};
|
|
24
50
|
};
|
|
25
51
|
readonly auth: {
|
|
@@ -31,7 +57,7 @@ declare function createEnvironmentSessionAtoms<R, E>(runtime: Atom.AtomRuntime<E
|
|
|
31
57
|
readonly cwd: string;
|
|
32
58
|
readonly keybindingsConfigPath: string;
|
|
33
59
|
readonly keybindings: readonly {
|
|
34
|
-
readonly command: "chat.new" | "chat.newLocal" | "commandPalette.toggle" | "composer.stash" | "diff.toggle" | "editor.openFavorite" | "modelPicker.jump.1" | "modelPicker.jump.2" | "modelPicker.jump.3" | "modelPicker.jump.4" | "modelPicker.jump.5" | "modelPicker.jump.6" | "modelPicker.jump.7" | "modelPicker.jump.8" | "modelPicker.jump.9" | "modelPicker.toggle" | "preview.focusUrl" | "preview.refresh" | "preview.resetZoom" | "preview.toggle" | "preview.zoomIn" | "preview.zoomOut" | "rightPanel.toggle" | "sidebar.toggle" | "terminal.close" | "terminal.new" | "terminal.split" | "terminal.splitVertical" | "terminal.toggle" | "thread.jump.1" | "thread.jump.2" | "thread.jump.3" | "thread.jump.4" | "thread.jump.5" | "thread.jump.6" | "thread.jump.7" | "thread.jump.8" | "thread.jump.9" | "thread.next" | "thread.previous" | `script.${string}.run`;
|
|
60
|
+
readonly command: "chat.new" | "chat.newLocal" | "commandPalette.toggle" | "composer.stash" | "diff.toggle" | "editor.openFavorite" | "filePicker.toggle" | "modelPicker.jump.1" | "modelPicker.jump.2" | "modelPicker.jump.3" | "modelPicker.jump.4" | "modelPicker.jump.5" | "modelPicker.jump.6" | "modelPicker.jump.7" | "modelPicker.jump.8" | "modelPicker.jump.9" | "modelPicker.toggle" | "preview.focusUrl" | "preview.refresh" | "preview.resetZoom" | "preview.toggle" | "preview.zoomIn" | "preview.zoomOut" | "projectSearch.toggle" | "rightPanel.toggle" | "sidebar.toggle" | "terminal.close" | "terminal.new" | "terminal.split" | "terminal.splitVertical" | "terminal.toggle" | "themeEditor.toggle" | "thread.jump.1" | "thread.jump.2" | "thread.jump.3" | "thread.jump.4" | "thread.jump.5" | "thread.jump.6" | "thread.jump.7" | "thread.jump.8" | "thread.jump.9" | "thread.next" | "thread.previous" | `script.${string}.run`;
|
|
35
61
|
readonly shortcut: {
|
|
36
62
|
readonly key: string;
|
|
37
63
|
readonly metaKey: boolean;
|
|
@@ -96,6 +122,7 @@ declare function createEnvironmentSessionAtoms<R, E>(runtime: Atom.AtomRuntime<E
|
|
|
96
122
|
readonly subProvider?: string | undefined;
|
|
97
123
|
readonly isCustom: boolean;
|
|
98
124
|
readonly isDefault?: boolean | undefined;
|
|
125
|
+
readonly isLegacy?: boolean | undefined;
|
|
99
126
|
readonly capabilities: {
|
|
100
127
|
readonly optionDescriptors?: readonly ({
|
|
101
128
|
readonly id: string;
|
|
@@ -162,7 +189,7 @@ declare function createEnvironmentSessionAtoms<R, E>(runtime: Atom.AtomRuntime<E
|
|
|
162
189
|
readonly otlpMetricsEnabled: boolean;
|
|
163
190
|
};
|
|
164
191
|
readonly settings: {
|
|
165
|
-
readonly
|
|
192
|
+
readonly enableLegacyTokenStreaming: boolean;
|
|
166
193
|
readonly enableProviderUpdateChecks: boolean;
|
|
167
194
|
readonly backgroundActivity: {
|
|
168
195
|
readonly schemaVersion: 1;
|
|
@@ -264,6 +291,7 @@ declare function createEnvironmentSessionAtoms<R, E>(runtime: Atom.AtomRuntime<E
|
|
|
264
291
|
};
|
|
265
292
|
readonly shellResumeCompletionMarker?: boolean;
|
|
266
293
|
readonly threadResumeCompletionMarker?: boolean;
|
|
294
|
+
readonly threadSnapshotPagination?: boolean;
|
|
267
295
|
}>, E | import("effect/Cause").NoSuchElementError>>;
|
|
268
296
|
initialConfigValueAtom: (arg: string & import("effect/Brand").Brand<"EnvironmentId">) => Atom.Atom<{
|
|
269
297
|
readonly environment: {
|
|
@@ -279,7 +307,11 @@ declare function createEnvironmentSessionAtoms<R, E>(runtime: Atom.AtomRuntime<E
|
|
|
279
307
|
readonly connectionProbe?: boolean;
|
|
280
308
|
readonly threadSettlement?: boolean;
|
|
281
309
|
readonly threadSnooze?: boolean;
|
|
310
|
+
readonly threadPinning?: boolean;
|
|
311
|
+
readonly threadPinReorder?: boolean;
|
|
312
|
+
readonly threadTitleRegeneration?: boolean;
|
|
282
313
|
readonly serverSelfUpdate?: "boot-service" | "desktop-managed" | "respawn";
|
|
314
|
+
readonly serverSelfUpdateProgress?: boolean;
|
|
283
315
|
};
|
|
284
316
|
};
|
|
285
317
|
readonly auth: {
|
|
@@ -291,7 +323,7 @@ declare function createEnvironmentSessionAtoms<R, E>(runtime: Atom.AtomRuntime<E
|
|
|
291
323
|
readonly cwd: string;
|
|
292
324
|
readonly keybindingsConfigPath: string;
|
|
293
325
|
readonly keybindings: readonly {
|
|
294
|
-
readonly command: "chat.new" | "chat.newLocal" | "commandPalette.toggle" | "composer.stash" | "diff.toggle" | "editor.openFavorite" | "modelPicker.jump.1" | "modelPicker.jump.2" | "modelPicker.jump.3" | "modelPicker.jump.4" | "modelPicker.jump.5" | "modelPicker.jump.6" | "modelPicker.jump.7" | "modelPicker.jump.8" | "modelPicker.jump.9" | "modelPicker.toggle" | "preview.focusUrl" | "preview.refresh" | "preview.resetZoom" | "preview.toggle" | "preview.zoomIn" | "preview.zoomOut" | "rightPanel.toggle" | "sidebar.toggle" | "terminal.close" | "terminal.new" | "terminal.split" | "terminal.splitVertical" | "terminal.toggle" | "thread.jump.1" | "thread.jump.2" | "thread.jump.3" | "thread.jump.4" | "thread.jump.5" | "thread.jump.6" | "thread.jump.7" | "thread.jump.8" | "thread.jump.9" | "thread.next" | "thread.previous" | `script.${string}.run`;
|
|
326
|
+
readonly command: "chat.new" | "chat.newLocal" | "commandPalette.toggle" | "composer.stash" | "diff.toggle" | "editor.openFavorite" | "filePicker.toggle" | "modelPicker.jump.1" | "modelPicker.jump.2" | "modelPicker.jump.3" | "modelPicker.jump.4" | "modelPicker.jump.5" | "modelPicker.jump.6" | "modelPicker.jump.7" | "modelPicker.jump.8" | "modelPicker.jump.9" | "modelPicker.toggle" | "preview.focusUrl" | "preview.refresh" | "preview.resetZoom" | "preview.toggle" | "preview.zoomIn" | "preview.zoomOut" | "projectSearch.toggle" | "rightPanel.toggle" | "sidebar.toggle" | "terminal.close" | "terminal.new" | "terminal.split" | "terminal.splitVertical" | "terminal.toggle" | "themeEditor.toggle" | "thread.jump.1" | "thread.jump.2" | "thread.jump.3" | "thread.jump.4" | "thread.jump.5" | "thread.jump.6" | "thread.jump.7" | "thread.jump.8" | "thread.jump.9" | "thread.next" | "thread.previous" | `script.${string}.run`;
|
|
295
327
|
readonly shortcut: {
|
|
296
328
|
readonly key: string;
|
|
297
329
|
readonly metaKey: boolean;
|
|
@@ -356,6 +388,7 @@ declare function createEnvironmentSessionAtoms<R, E>(runtime: Atom.AtomRuntime<E
|
|
|
356
388
|
readonly subProvider?: string | undefined;
|
|
357
389
|
readonly isCustom: boolean;
|
|
358
390
|
readonly isDefault?: boolean | undefined;
|
|
391
|
+
readonly isLegacy?: boolean | undefined;
|
|
359
392
|
readonly capabilities: {
|
|
360
393
|
readonly optionDescriptors?: readonly ({
|
|
361
394
|
readonly id: string;
|
|
@@ -422,7 +455,7 @@ declare function createEnvironmentSessionAtoms<R, E>(runtime: Atom.AtomRuntime<E
|
|
|
422
455
|
readonly otlpMetricsEnabled: boolean;
|
|
423
456
|
};
|
|
424
457
|
readonly settings: {
|
|
425
|
-
readonly
|
|
458
|
+
readonly enableLegacyTokenStreaming: boolean;
|
|
426
459
|
readonly enableProviderUpdateChecks: boolean;
|
|
427
460
|
readonly backgroundActivity: {
|
|
428
461
|
readonly schemaVersion: 1;
|
|
@@ -524,9 +557,34 @@ declare function createEnvironmentSessionAtoms<R, E>(runtime: Atom.AtomRuntime<E
|
|
|
524
557
|
};
|
|
525
558
|
readonly shellResumeCompletionMarker?: boolean;
|
|
526
559
|
readonly threadResumeCompletionMarker?: boolean;
|
|
560
|
+
readonly threadSnapshotPagination?: boolean;
|
|
527
561
|
} | null>;
|
|
528
562
|
preparedConnectionAtom: (arg: string & import("effect/Brand").Brand<"EnvironmentId">) => Atom.Atom<AsyncResult.AsyncResult<Option.Option<PreparedConnection>, E | import("effect/Cause").NoSuchElementError>>;
|
|
529
563
|
preparedConnectionValueAtom: (arg: string & import("effect/Brand").Brand<"EnvironmentId">) => Atom.Atom<Option.Option<PreparedConnection>>;
|
|
564
|
+
sessionStateAtom: (arg: string & import("effect/Brand").Brand<"EnvironmentId">) => Atom.Atom<AsyncResult.AsyncResult<{
|
|
565
|
+
readonly authenticated: boolean;
|
|
566
|
+
readonly auth: {
|
|
567
|
+
readonly policy: "desktop-managed-local" | "loopback-browser" | "remote-reachable" | "unsafe-no-auth";
|
|
568
|
+
readonly bootstrapMethods: readonly ("desktop-bootstrap" | "one-time-token")[];
|
|
569
|
+
readonly sessionMethods: readonly ("bearer-access-token" | "browser-session-cookie" | "dpop-access-token")[];
|
|
570
|
+
readonly sessionCookieName: string;
|
|
571
|
+
};
|
|
572
|
+
readonly scopes?: readonly ("access:read" | "access:write" | "orchestration:operate" | "orchestration:read" | "relay:read" | "relay:write" | "review:write" | "terminal:operate")[];
|
|
573
|
+
readonly sessionMethod?: "bearer-access-token" | "browser-session-cookie" | "dpop-access-token";
|
|
574
|
+
readonly expiresAt?: import("effect/DateTime").Utc;
|
|
575
|
+
}, E | RemoteEnvironmentRequestError>>;
|
|
576
|
+
sessionStateValueAtom: (arg: string & import("effect/Brand").Brand<"EnvironmentId">) => Atom.Atom<{
|
|
577
|
+
readonly authenticated: boolean;
|
|
578
|
+
readonly auth: {
|
|
579
|
+
readonly policy: "desktop-managed-local" | "loopback-browser" | "remote-reachable" | "unsafe-no-auth";
|
|
580
|
+
readonly bootstrapMethods: readonly ("desktop-bootstrap" | "one-time-token")[];
|
|
581
|
+
readonly sessionMethods: readonly ("bearer-access-token" | "browser-session-cookie" | "dpop-access-token")[];
|
|
582
|
+
readonly sessionCookieName: string;
|
|
583
|
+
};
|
|
584
|
+
readonly scopes?: readonly ("access:read" | "access:write" | "orchestration:operate" | "orchestration:read" | "relay:read" | "relay:write" | "review:write" | "terminal:operate")[];
|
|
585
|
+
readonly sessionMethod?: "bearer-access-token" | "browser-session-cookie" | "dpop-access-token";
|
|
586
|
+
readonly expiresAt?: import("effect/DateTime").Utc;
|
|
587
|
+
} | null>;
|
|
530
588
|
};
|
|
531
589
|
//#endregion
|
|
532
|
-
export { createEnvironmentSessionAtoms, initialConfigOption };
|
|
590
|
+
export { createEnvironmentSessionAtoms, fetchEnvironmentSessionState, initialConfigOption };
|
|
@@ -1,8 +1,20 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { $r as make, Aj as none, Ba as safeErrorLogAttributes, Bk as gen, Bo as makeEnvironmentHttpApiClient, Br as buildEnvironmentAuthHeaders, Cj as getOrNull, Dk as catch_, Gk as map, Ia as EnvironmentSupervisor, PO as mapEffect, Pk as fn, Py as changes, Sj as getOrElse, Tr as followStreamInEnvironment, Uo as environmentEndpointUrl, Vr as withEnvironmentCredentials, Wk as logWarning, YO as unwrap, Yk as never, Zr as family, bk as as, cA as succeed, ei as setIdleTTL, jj as some, kj as match, ni as withLabel, oA as serviceOption, si as value, ti as swr, to as ManagedRelayDpopSigner, yk as annotateLogs, zo as executeEnvironmentHttpRequest } from "../../shared.js";
|
|
2
2
|
//#region upstream-t3code/packages/client-runtime/src/state/session.ts
|
|
3
3
|
function initialConfigOption(initialConfig) {
|
|
4
4
|
return initialConfig.pipe(map(some), catch_((error) => logWarning("Could not load the initial environment configuration.").pipe(annotateLogs({ ...safeErrorLogAttributes(error) }), as(none()))));
|
|
5
5
|
}
|
|
6
|
+
const DEFAULT_SESSION_STATE_TIMEOUT_MS = 6e3;
|
|
7
|
+
/**
|
|
8
|
+
* Read the granted scopes of this client's session on one environment via its
|
|
9
|
+
* `/api/auth/session` endpoint, authenticated with whatever credential the
|
|
10
|
+
* connection was prepared with (cookie, bearer, or DPoP).
|
|
11
|
+
*/
|
|
12
|
+
const fetchEnvironmentSessionState = fn("clientRuntime.state.fetchEnvironmentSessionState")(function* (input) {
|
|
13
|
+
const requestUrl = environmentEndpointUrl(input.prepared.httpBaseUrl, "/api/auth/session");
|
|
14
|
+
const client = yield* makeEnvironmentHttpApiClient(input.prepared.httpBaseUrl);
|
|
15
|
+
const headers = yield* buildEnvironmentAuthHeaders(input.prepared.httpAuthorization, "GET", requestUrl, input.signer);
|
|
16
|
+
return yield* executeEnvironmentHttpRequest(requestUrl, input.timeoutMs ?? DEFAULT_SESSION_STATE_TIMEOUT_MS, withEnvironmentCredentials(input.prepared.httpAuthorization, client.auth.session({ headers })));
|
|
17
|
+
});
|
|
6
18
|
function createEnvironmentSessionAtoms(runtime) {
|
|
7
19
|
const initialConfigAtom = family((environmentId) => runtime.atom(followStreamInEnvironment(environmentId, unwrap(EnvironmentSupervisor.pipe(map((supervisor) => changes(supervisor.session).pipe(mapEffect(match({
|
|
8
20
|
onNone: () => succeed(none()),
|
|
@@ -10,12 +22,29 @@ function createEnvironmentSessionAtoms(runtime) {
|
|
|
10
22
|
}))))))), { initialValue: none() }));
|
|
11
23
|
const initialConfigValueAtom = family((environmentId) => make((get) => getOrNull(getOrElse(value(get(initialConfigAtom(environmentId))), () => none()))).pipe(withLabel(`environment-config-value:${environmentId}`)));
|
|
12
24
|
const preparedConnectionAtom = family((environmentId) => runtime.atom(followStreamInEnvironment(environmentId, unwrap(EnvironmentSupervisor.pipe(map((supervisor) => changes(supervisor.prepared))))), { initialValue: none() }));
|
|
25
|
+
const preparedConnectionValueAtom = family((environmentId) => make((get) => getOrElse(value(get(preparedConnectionAtom(environmentId))), () => none())).pipe(withLabel(`environment-prepared-connection:${environmentId}`)));
|
|
26
|
+
const sessionStateAtom = family((environmentId) => runtime.atom((get) => {
|
|
27
|
+
const prepared = getOrNull(get(preparedConnectionValueAtom(environmentId)));
|
|
28
|
+
if (prepared === null) return never;
|
|
29
|
+
return gen(function* () {
|
|
30
|
+
const signer = yield* serviceOption(ManagedRelayDpopSigner);
|
|
31
|
+
return yield* fetchEnvironmentSessionState({
|
|
32
|
+
prepared,
|
|
33
|
+
signer
|
|
34
|
+
});
|
|
35
|
+
});
|
|
36
|
+
}).pipe(swr({
|
|
37
|
+
staleTime: 3e4,
|
|
38
|
+
revalidateOnMount: true
|
|
39
|
+
}), setIdleTTL(5 * 6e4), withLabel(`environment-session-state:${environmentId}`)));
|
|
13
40
|
return {
|
|
14
41
|
initialConfigAtom,
|
|
15
42
|
initialConfigValueAtom,
|
|
16
43
|
preparedConnectionAtom,
|
|
17
|
-
preparedConnectionValueAtom
|
|
44
|
+
preparedConnectionValueAtom,
|
|
45
|
+
sessionStateAtom,
|
|
46
|
+
sessionStateValueAtom: family((environmentId) => make((get) => getOrNull(value(get(sessionStateAtom(environmentId)))) ?? null).pipe(withLabel(`environment-session-state-value:${environmentId}`)))
|
|
18
47
|
};
|
|
19
48
|
}
|
|
20
49
|
//#endregion
|
|
21
|
-
export { createEnvironmentSessionAtoms, initialConfigOption };
|
|
50
|
+
export { createEnvironmentSessionAtoms, fetchEnvironmentSessionState, initialConfigOption };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { $a as RemoteEnvironmentRequestError, $l as ExternalLauncherBrowserSpawnError, CD as EnvironmentId, Da as EnvironmentSupervisor, Na as EnvironmentCacheStore, Oy as OrchestrationShellSnapshot, Ta as EnvironmentRegistry, Td as KeybindingWhenNode, at as EnvironmentProject, bo as ManagedRelayDpopSigner, ct as scopeProject, dt as selectEnvironmentThreadShell, du as ServerConfig, eu as ExternalLauncherCommandNotFoundError, f as AtomCommand, iD as EnvironmentAuthorizationError, it as EnvironmentMessage, iu as ExternalLauncherUnsupportedEditorError, ky as OrchestrationShellStreamEvent, lt as scopeThread, mn as EnvironmentRpcUnavailableError, ot as EnvironmentThread, ru as ExternalLauncherUnknownEditorError, st as EnvironmentThreadShell, tu as ExternalLauncherEditorSpawnError, u as EnvironmentCatalogState, us as PreparedConnection, ut as scopeThreadShell, wa as EnvironmentNotRegisteredError } from "../../shared.js";
|
|
2
2
|
import * as Context from "effect/Context";
|
|
3
3
|
import * as Effect from "effect/Effect";
|
|
4
4
|
import * as Stream from "effect/Stream";
|
|
@@ -46,6 +46,8 @@ declare const fetchEnvironmentShellSnapshot: (input: {
|
|
|
46
46
|
readonly value: string | boolean;
|
|
47
47
|
}[];
|
|
48
48
|
} | null;
|
|
49
|
+
readonly defaultThreadEnvMode?: "local" | "worktree" | null | undefined;
|
|
50
|
+
readonly faviconPath?: string | null | undefined;
|
|
49
51
|
readonly scripts: readonly {
|
|
50
52
|
readonly id: string;
|
|
51
53
|
readonly name: string;
|
|
@@ -93,6 +95,12 @@ declare const fetchEnvironmentShellSnapshot: (input: {
|
|
|
93
95
|
readonly settledAt: string | null;
|
|
94
96
|
readonly snoozedUntil?: string | null | undefined;
|
|
95
97
|
readonly snoozedAt?: string | null | undefined;
|
|
98
|
+
readonly pinnedAt?: string | null | undefined;
|
|
99
|
+
readonly pinOrderKey?: string | null | undefined;
|
|
100
|
+
readonly titleRegeneration?: {
|
|
101
|
+
readonly requestId: string & import("effect/Brand").Brand<"CommandId">;
|
|
102
|
+
readonly startedAt: string;
|
|
103
|
+
} | null | undefined;
|
|
96
104
|
readonly session: {
|
|
97
105
|
readonly threadId: string & import("effect/Brand").Brand<"ThreadId">;
|
|
98
106
|
readonly status: "error" | "idle" | "interrupted" | "ready" | "running" | "starting" | "stopped";
|
|
@@ -107,6 +115,12 @@ declare const fetchEnvironmentShellSnapshot: (input: {
|
|
|
107
115
|
readonly hasPendingApprovals: boolean;
|
|
108
116
|
readonly hasPendingUserInput: boolean;
|
|
109
117
|
readonly hasActionableProposedPlan: boolean;
|
|
118
|
+
readonly backgroundLiveness?: "monitoring" | "working" | null | undefined;
|
|
119
|
+
readonly planProgress?: {
|
|
120
|
+
readonly step: string;
|
|
121
|
+
readonly completedSteps: number;
|
|
122
|
+
readonly totalSteps: number;
|
|
123
|
+
} | null | undefined;
|
|
110
124
|
}[];
|
|
111
125
|
readonly updatedAt: string;
|
|
112
126
|
}, RemoteEnvironmentRequestError, HttpClient.HttpClient>;
|
|
@@ -126,10 +140,10 @@ declare const shellSnapshotLoaderLayer: Layer.Layer<ShellSnapshotLoader, never,
|
|
|
126
140
|
declare function createShellEnvironmentAtoms<R, E>(runtime: Atom.AtomRuntime<EnvironmentRegistry | R, E>): {
|
|
127
141
|
openInEditor: AtomCommand<{
|
|
128
142
|
readonly environmentId: EnvironmentId;
|
|
129
|
-
readonly input:
|
|
130
|
-
readonly cwd:
|
|
131
|
-
readonly editor:
|
|
132
|
-
}
|
|
143
|
+
readonly input: {
|
|
144
|
+
readonly cwd: string;
|
|
145
|
+
readonly editor: "antigravity" | "aqua" | "clion" | "cursor" | "datagrip" | "dataspell" | "file-manager" | "goland" | "idea" | "kiro" | "phpstorm" | "pycharm" | "rider" | "rubymine" | "rustrover" | "trae" | "vscode" | "vscode-insiders" | "vscodium" | "webstorm" | "zed";
|
|
146
|
+
};
|
|
133
147
|
}, void, E | EnvironmentAuthorizationError | EnvironmentNotRegisteredError | EnvironmentRpcUnavailableError | ExternalLauncherBrowserSpawnError | ExternalLauncherCommandNotFoundError | ExternalLauncherEditorSpawnError | ExternalLauncherUnknownEditorError | ExternalLauncherUnsupportedEditorError | import("effect/unstable/rpc/RpcClientError").RpcClientError>;
|
|
134
148
|
};
|
|
135
149
|
//#endregion
|
|
@@ -172,6 +186,8 @@ declare function createEnvironmentSnapshotAtom<E>(shellStateAtom: (environmentId
|
|
|
172
186
|
readonly value: string | boolean;
|
|
173
187
|
}[];
|
|
174
188
|
} | null;
|
|
189
|
+
readonly defaultThreadEnvMode?: "local" | "worktree" | null | undefined;
|
|
190
|
+
readonly faviconPath?: string | null | undefined;
|
|
175
191
|
readonly scripts: readonly {
|
|
176
192
|
readonly id: string;
|
|
177
193
|
readonly name: string;
|
|
@@ -219,6 +235,12 @@ declare function createEnvironmentSnapshotAtom<E>(shellStateAtom: (environmentId
|
|
|
219
235
|
readonly settledAt: string | null;
|
|
220
236
|
readonly snoozedUntil?: string | null | undefined;
|
|
221
237
|
readonly snoozedAt?: string | null | undefined;
|
|
238
|
+
readonly pinnedAt?: string | null | undefined;
|
|
239
|
+
readonly pinOrderKey?: string | null | undefined;
|
|
240
|
+
readonly titleRegeneration?: {
|
|
241
|
+
readonly requestId: string & import("effect/Brand").Brand<"CommandId">;
|
|
242
|
+
readonly startedAt: string;
|
|
243
|
+
} | null | undefined;
|
|
222
244
|
readonly session: {
|
|
223
245
|
readonly threadId: string & import("effect/Brand").Brand<"ThreadId">;
|
|
224
246
|
readonly status: "error" | "idle" | "interrupted" | "ready" | "running" | "starting" | "stopped";
|
|
@@ -233,6 +255,12 @@ declare function createEnvironmentSnapshotAtom<E>(shellStateAtom: (environmentId
|
|
|
233
255
|
readonly hasPendingApprovals: boolean;
|
|
234
256
|
readonly hasPendingUserInput: boolean;
|
|
235
257
|
readonly hasActionableProposedPlan: boolean;
|
|
258
|
+
readonly backgroundLiveness?: "monitoring" | "working" | null | undefined;
|
|
259
|
+
readonly planProgress?: {
|
|
260
|
+
readonly step: string;
|
|
261
|
+
readonly completedSteps: number;
|
|
262
|
+
readonly totalSteps: number;
|
|
263
|
+
} | null | undefined;
|
|
236
264
|
}[];
|
|
237
265
|
readonly updatedAt: string;
|
|
238
266
|
} | null>;
|
|
@@ -275,7 +303,11 @@ declare function createEnvironmentServerConfigsAtom(input: {
|
|
|
275
303
|
readonly connectionProbe?: boolean;
|
|
276
304
|
readonly threadSettlement?: boolean;
|
|
277
305
|
readonly threadSnooze?: boolean;
|
|
306
|
+
readonly threadPinning?: boolean;
|
|
307
|
+
readonly threadPinReorder?: boolean;
|
|
308
|
+
readonly threadTitleRegeneration?: boolean;
|
|
278
309
|
readonly serverSelfUpdate?: "boot-service" | "desktop-managed" | "respawn";
|
|
310
|
+
readonly serverSelfUpdateProgress?: boolean;
|
|
279
311
|
};
|
|
280
312
|
};
|
|
281
313
|
readonly auth: {
|
|
@@ -287,7 +319,7 @@ declare function createEnvironmentServerConfigsAtom(input: {
|
|
|
287
319
|
readonly cwd: string;
|
|
288
320
|
readonly keybindingsConfigPath: string;
|
|
289
321
|
readonly keybindings: readonly {
|
|
290
|
-
readonly command: "chat.new" | "chat.newLocal" | "commandPalette.toggle" | "composer.stash" | "diff.toggle" | "editor.openFavorite" | "modelPicker.jump.1" | "modelPicker.jump.2" | "modelPicker.jump.3" | "modelPicker.jump.4" | "modelPicker.jump.5" | "modelPicker.jump.6" | "modelPicker.jump.7" | "modelPicker.jump.8" | "modelPicker.jump.9" | "modelPicker.toggle" | "preview.focusUrl" | "preview.refresh" | "preview.resetZoom" | "preview.toggle" | "preview.zoomIn" | "preview.zoomOut" | "rightPanel.toggle" | "sidebar.toggle" | "terminal.close" | "terminal.new" | "terminal.split" | "terminal.splitVertical" | "terminal.toggle" | "thread.jump.1" | "thread.jump.2" | "thread.jump.3" | "thread.jump.4" | "thread.jump.5" | "thread.jump.6" | "thread.jump.7" | "thread.jump.8" | "thread.jump.9" | "thread.next" | "thread.previous" | `script.${string}.run`;
|
|
322
|
+
readonly command: "chat.new" | "chat.newLocal" | "commandPalette.toggle" | "composer.stash" | "diff.toggle" | "editor.openFavorite" | "filePicker.toggle" | "modelPicker.jump.1" | "modelPicker.jump.2" | "modelPicker.jump.3" | "modelPicker.jump.4" | "modelPicker.jump.5" | "modelPicker.jump.6" | "modelPicker.jump.7" | "modelPicker.jump.8" | "modelPicker.jump.9" | "modelPicker.toggle" | "preview.focusUrl" | "preview.refresh" | "preview.resetZoom" | "preview.toggle" | "preview.zoomIn" | "preview.zoomOut" | "projectSearch.toggle" | "rightPanel.toggle" | "sidebar.toggle" | "terminal.close" | "terminal.new" | "terminal.split" | "terminal.splitVertical" | "terminal.toggle" | "themeEditor.toggle" | "thread.jump.1" | "thread.jump.2" | "thread.jump.3" | "thread.jump.4" | "thread.jump.5" | "thread.jump.6" | "thread.jump.7" | "thread.jump.8" | "thread.jump.9" | "thread.next" | "thread.previous" | `script.${string}.run`;
|
|
291
323
|
readonly shortcut: {
|
|
292
324
|
readonly key: string;
|
|
293
325
|
readonly metaKey: boolean;
|
|
@@ -352,6 +384,7 @@ declare function createEnvironmentServerConfigsAtom(input: {
|
|
|
352
384
|
readonly subProvider?: string | undefined;
|
|
353
385
|
readonly isCustom: boolean;
|
|
354
386
|
readonly isDefault?: boolean | undefined;
|
|
387
|
+
readonly isLegacy?: boolean | undefined;
|
|
355
388
|
readonly capabilities: {
|
|
356
389
|
readonly optionDescriptors?: readonly ({
|
|
357
390
|
readonly id: string;
|
|
@@ -418,7 +451,7 @@ declare function createEnvironmentServerConfigsAtom(input: {
|
|
|
418
451
|
readonly otlpMetricsEnabled: boolean;
|
|
419
452
|
};
|
|
420
453
|
readonly settings: {
|
|
421
|
-
readonly
|
|
454
|
+
readonly enableLegacyTokenStreaming: boolean;
|
|
422
455
|
readonly enableProviderUpdateChecks: boolean;
|
|
423
456
|
readonly backgroundActivity: {
|
|
424
457
|
readonly schemaVersion: 1;
|
|
@@ -520,6 +553,7 @@ declare function createEnvironmentServerConfigsAtom(input: {
|
|
|
520
553
|
};
|
|
521
554
|
readonly shellResumeCompletionMarker?: boolean;
|
|
522
555
|
readonly threadResumeCompletionMarker?: boolean;
|
|
556
|
+
readonly threadSnapshotPagination?: boolean;
|
|
523
557
|
}>>;
|
|
524
558
|
declare function createEnvironmentShellAtoms<R, E>(runtime: Atom.AtomRuntime<EnvironmentRegistry | EnvironmentCacheStore | ShellSnapshotLoader | R, E>): {
|
|
525
559
|
stateAtom: (arg: string & import("effect/Brand").Brand<"EnvironmentId">) => Atom.Atom<AsyncResult.AsyncResult<EnvironmentShellState, E | Cause.NoSuchElementError>>;
|