t3code-cli 0.12.0 → 0.14.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/README.md +87 -1
- package/dist/application.d.ts +2 -0
- package/dist/application.js +1 -1
- package/dist/auth.d.ts +50 -0
- package/dist/auth.js +1 -1
- package/dist/bin.d.ts +1 -0
- package/dist/bin.js +392 -630
- package/dist/cli.d.ts +66 -0
- package/dist/cli.js +1 -1
- package/dist/client-runtime/authorization.d.ts +2 -0
- package/dist/client-runtime/authorization.js +2 -0
- package/dist/client-runtime/connection.d.ts +2 -0
- package/dist/client-runtime/connection.js +2 -0
- package/dist/client-runtime/environment.d.ts +57 -0
- package/dist/client-runtime/environment.js +2 -0
- package/dist/client-runtime/errors.d.ts +28 -0
- package/dist/client-runtime/errors.js +35 -0
- package/dist/client-runtime/operations/projects.d.ts +2 -0
- package/dist/client-runtime/operations/projects.js +2 -0
- package/dist/client-runtime/operations.d.ts +2 -0
- package/dist/client-runtime/operations.js +2 -0
- package/dist/client-runtime/platform.d.ts +26 -0
- package/dist/client-runtime/platform.js +74 -0
- package/dist/client-runtime/relay.d.ts +121 -0
- package/dist/client-runtime/relay.js +245 -0
- package/dist/client-runtime/rpc.d.ts +2 -0
- package/dist/client-runtime/rpc.js +2 -0
- package/dist/client-runtime/state/assets.d.ts +40 -0
- package/dist/client-runtime/state/assets.js +53 -0
- package/dist/client-runtime/state/auth.d.ts +98 -0
- package/dist/client-runtime/state/auth.js +48 -0
- package/dist/client-runtime/state/connections.d.ts +2 -0
- package/dist/client-runtime/state/connections.js +52 -0
- package/dist/client-runtime/state/entities.d.ts +33 -0
- package/dist/client-runtime/state/entities.js +2 -0
- package/dist/client-runtime/state/filesystem.d.ts +42 -0
- package/dist/client-runtime/state/filesystem.js +48 -0
- package/dist/client-runtime/state/git.d.ts +43 -0
- package/dist/client-runtime/state/git.js +18 -0
- package/dist/client-runtime/state/models.d.ts +2 -0
- package/dist/client-runtime/state/models.js +2 -0
- package/dist/client-runtime/state/orchestration.d.ts +128 -0
- package/dist/client-runtime/state/orchestration.js +20 -0
- package/dist/client-runtime/state/presentation.d.ts +277 -0
- package/dist/client-runtime/state/presentation.js +34 -0
- package/dist/client-runtime/state/preview.d.ts +447 -0
- package/dist/client-runtime/state/preview.js +103 -0
- package/dist/client-runtime/state/project-grouping.d.ts +26 -0
- package/dist/client-runtime/state/project-grouping.js +73 -0
- package/dist/client-runtime/state/projects.d.ts +192 -0
- package/dist/client-runtime/state/projects.js +2 -0
- package/dist/client-runtime/state/relay.d.ts +10 -0
- package/dist/client-runtime/state/relay.js +19 -0
- package/dist/client-runtime/state/review.d.ts +28 -0
- package/dist/client-runtime/state/review.js +11 -0
- package/dist/client-runtime/state/runtime.d.ts +2 -0
- package/dist/client-runtime/state/runtime.js +2 -0
- package/dist/client-runtime/state/server.d.ts +1495 -0
- package/dist/client-runtime/state/server.js +207 -0
- package/dist/client-runtime/state/session.d.ts +532 -0
- package/dist/client-runtime/state/session.js +21 -0
- package/dist/client-runtime/state/shell.d.ts +529 -0
- package/dist/client-runtime/state/shell.js +2 -0
- package/dist/client-runtime/state/source-control.d.ts +92 -0
- package/dist/client-runtime/state/source-control.js +36 -0
- package/dist/client-runtime/state/terminal.d.ts +237 -0
- package/dist/client-runtime/state/terminal.js +173 -0
- package/dist/client-runtime/state/thread-settled.d.ts +104 -0
- package/dist/client-runtime/state/thread-settled.js +157 -0
- package/dist/client-runtime/state/thread-sort.d.ts +23 -0
- package/dist/client-runtime/state/thread-sort.js +47 -0
- package/dist/client-runtime/state/threads.d.ts +538 -0
- package/dist/client-runtime/state/threads.js +934 -0
- package/dist/client-runtime/state/vcs.d.ts +442 -0
- package/dist/client-runtime/state/vcs.js +756 -0
- package/dist/config.d.ts +84 -0
- package/dist/config.js +1 -1
- package/dist/connection.d.ts +7 -0
- package/dist/connection.js +1 -1
- package/dist/contracts.d.ts +2 -0
- package/dist/contracts.js +2 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.js +1 -1
- package/dist/node.d.ts +6 -0
- package/dist/node.js +1 -1
- package/dist/orchestration.d.ts +1420 -0
- package/dist/orchestration.js +1 -1
- package/dist/preview.d.ts +2 -0
- package/dist/preview.js +2 -0
- package/dist/rolldown-runtime.js +1 -1
- package/dist/rpc.d.ts +6043 -0
- package/dist/rpc.js +1 -1
- package/dist/runtime.d.ts +2 -0
- package/dist/runtime.js +2 -2
- package/dist/shared/DrainableWorker.d.ts +28 -0
- package/dist/shared/DrainableWorker.js +24 -0
- package/dist/shared/KeyedCoalescingWorker.d.ts +13 -0
- package/dist/shared/KeyedCoalescingWorker.js +89 -0
- package/dist/shared/Net.d.ts +43 -0
- package/dist/shared/Net.js +126 -0
- package/dist/shared/String.d.ts +4 -0
- package/dist/shared/String.js +8 -0
- package/dist/shared/Struct.d.ts +5 -0
- package/dist/shared/Struct.js +2 -0
- package/dist/shared/advertisedEndpoint.d.ts +2 -0
- package/dist/shared/advertisedEndpoint.js +2 -0
- package/dist/shared/agentAwareness.d.ts +27 -0
- package/dist/shared/agentAwareness.js +54 -0
- package/dist/shared/backgroundActivitySettings.d.ts +23 -0
- package/dist/shared/backgroundActivitySettings.js +2 -0
- package/dist/shared/chatList.d.ts +12 -0
- package/dist/shared/chatList.js +14 -0
- package/dist/shared/cliArgs.d.ts +33 -0
- package/dist/shared/cliArgs.js +103 -0
- package/dist/shared/composerInlineTokens.d.ts +20 -0
- package/dist/shared/composerInlineTokens.js +72 -0
- package/dist/shared/composerTrigger.d.ts +26 -0
- package/dist/shared/composerTrigger.js +97 -0
- package/dist/shared/connectAuth.d.ts +58 -0
- package/dist/shared/connectAuth.js +89 -0
- package/dist/shared/devHome.d.ts +21 -0
- package/dist/shared/devHome.js +65 -0
- package/dist/shared/devProxy.d.ts +15 -0
- package/dist/shared/devProxy.js +22 -0
- package/dist/shared/dpop.d.ts +32 -0
- package/dist/shared/dpop.js +2724 -0
- package/dist/shared/dpopCommon.d.ts +2 -0
- package/dist/shared/dpopCommon.js +2 -0
- package/dist/shared/filePreview.d.ts +8 -0
- package/dist/shared/filePreview.js +31 -0
- package/dist/shared/git.d.ts +41 -0
- package/dist/shared/git.js +2 -0
- package/dist/shared/hostProcess.d.ts +13 -0
- package/dist/shared/hostProcess.js +2 -0
- package/dist/shared/httpObservability.d.ts +5 -0
- package/dist/shared/httpObservability.js +2 -0
- package/dist/shared/httpReadiness.d.ts +38 -0
- package/dist/shared/httpReadiness.js +110 -0
- package/dist/shared/keybindings.d.ts +35 -0
- package/dist/shared/keybindings.js +330 -0
- package/dist/shared/logging.d.ts +39 -0
- package/dist/shared/logging.js +2 -0
- package/dist/shared/model.d.ts +44 -0
- package/dist/shared/model.js +2 -0
- package/dist/shared/oauthScope.d.ts +23 -0
- package/dist/shared/oauthScope.js +2 -0
- package/dist/shared/observability.d.ts +105 -0
- package/dist/shared/observability.js +346 -0
- package/dist/shared/orchestrationTiming.d.ts +16 -0
- package/dist/shared/orchestrationTiming.js +32 -0
- package/dist/shared/path.d.ts +2 -0
- package/dist/shared/path.js +2 -0
- package/dist/shared/preview.d.ts +35 -0
- package/dist/shared/preview.js +103 -0
- package/dist/shared/previewViewport.d.ts +16 -0
- package/dist/shared/previewViewport.js +159 -0
- package/dist/shared/projectFavicon.d.ts +5 -0
- package/dist/shared/projectFavicon.js +13 -0
- package/dist/shared/projectScripts.d.ts +19 -0
- package/dist/shared/projectScripts.js +18 -0
- package/dist/shared/qrCode.d.ts +87 -0
- package/dist/shared/qrCode.js +870 -0
- package/dist/shared/relayAuth.d.ts +27 -0
- package/dist/shared/relayAuth.js +83 -0
- package/dist/shared/relayClient.d.ts +58 -0
- package/dist/shared/relayClient.js +245 -0
- package/dist/shared/relayJwt.d.ts +39 -0
- package/dist/shared/relayJwt.js +2 -0
- package/dist/shared/relaySigning.d.ts +4 -0
- package/dist/shared/relaySigning.js +2 -0
- package/dist/shared/relayTracing.d.ts +25 -0
- package/dist/shared/relayTracing.js +2 -0
- package/dist/shared/relayUrl.d.ts +5 -0
- package/dist/shared/relayUrl.js +2 -0
- package/dist/shared/remote.d.ts +57 -0
- package/dist/shared/remote.js +2 -0
- package/dist/shared/schemaJson.d.ts +35 -0
- package/dist/shared/schemaJson.js +2 -0
- package/dist/shared/schemaYaml.d.ts +86 -0
- package/dist/shared/schemaYaml.js +99 -0
- package/dist/shared/searchRanking.d.ts +30 -0
- package/dist/shared/searchRanking.js +99 -0
- package/dist/shared/semver.d.ts +23 -0
- package/dist/shared/semver.js +124 -0
- package/dist/shared/serverSettings.d.ts +19 -0
- package/dist/shared/serverSettings.js +103 -0
- package/dist/shared/shell.d.ts +51 -0
- package/dist/shared/shell.js +408 -0
- package/dist/shared/sourceControl.d.ts +26 -0
- package/dist/shared/sourceControl.js +2 -0
- package/dist/shared/t3ProjectFile.d.ts +27 -0
- package/dist/shared/t3ProjectFile.js +25 -0
- package/dist/shared/terminalLabels.d.ts +16 -0
- package/dist/shared/terminalLabels.js +28 -0
- package/dist/shared/toolActivity.d.ts +16 -0
- package/dist/shared/toolActivity.js +159 -0
- package/dist/shared.d.ts +43036 -0
- package/dist/shared.js +36722 -13117
- package/dist/t3tools.d.ts +2 -0
- package/dist/t3tools.js +2 -2
- package/package.json +46 -27
- package/src/application/thread-wait.ts +4 -0
- package/src/auth/error.ts +2 -8
- package/src/auth/index.ts +2 -0
- package/src/auth/pairing.ts +8 -5
- package/src/auth/remote-error.ts +17 -0
- package/src/auth/service.ts +2 -1
- package/src/auth/transport.ts +49 -114
- package/src/auth/type.ts +6 -0
- package/src/cli/auth.ts +7 -1
- package/src/connection/error.ts +4 -1
- package/src/connection/layer.ts +5 -2
- package/src/connection/prepared.ts +83 -0
- package/src/contracts/index.ts +8 -0
- package/src/orchestration/layer.ts +38 -1
- package/src/orchestration/service.ts +5 -0
- package/src/preview/index.ts +11 -0
- package/src/preview/service.ts +52 -0
- package/src/rpc/error.ts +11 -16
- package/src/rpc/index.ts +3 -2
- package/src/rpc/layer.ts +18 -51
- package/src/rpc/operation.ts +21 -6
- package/src/rpc/service.ts +2 -1
- package/src/rpc/session.ts +168 -0
- package/src/rpc/ws-group.ts +18 -26
- package/src/runtime/index.ts +1 -0
- package/src/runtime/layer.ts +11 -3
- package/src/sql/node-sqlite-client.ts +3 -0
- package/dist/src/application/actions.d.ts +0 -25
- package/dist/src/application/error.d.ts +0 -3
- package/dist/src/application/index.d.ts +0 -4
- package/dist/src/application/layer.d.ts +0 -117
- package/dist/src/application/model-selection.d.ts +0 -34
- package/dist/src/application/models.d.ts +0 -8
- package/dist/src/application/project-commands.d.ts +0 -44
- package/dist/src/application/projects.d.ts +0 -23
- package/dist/src/application/service.d.ts +0 -243
- package/dist/src/application/shell-sequence.d.ts +0 -101
- package/dist/src/application/terminals.d.ts +0 -66
- package/dist/src/application/thread-commands.d.ts +0 -157
- package/dist/src/application/thread-update.d.ts +0 -8
- package/dist/src/application/thread-wait.d.ts +0 -111
- package/dist/src/application/threads.d.ts +0 -685
- package/dist/src/auth/error.d.ts +0 -51
- package/dist/src/auth/index.d.ts +0 -10
- package/dist/src/auth/layer.d.ts +0 -53
- package/dist/src/auth/local-base-dir.d.ts +0 -8
- package/dist/src/auth/local-origin.d.ts +0 -18
- package/dist/src/auth/local-token.d.ts +0 -26
- package/dist/src/auth/local.d.ts +0 -24
- package/dist/src/auth/pairing.d.ts +0 -22
- package/dist/src/auth/schema.d.ts +0 -58
- package/dist/src/auth/service.d.ts +0 -27
- package/dist/src/auth/transport.d.ts +0 -22
- package/dist/src/auth/type.d.ts +0 -83
- package/dist/src/cli/env/flag.d.ts +0 -2
- package/dist/src/cli/env/index.d.ts +0 -2
- package/dist/src/cli/env/selection-layer.d.ts +0 -3
- package/dist/src/cli/flags.d.ts +0 -20
- package/dist/src/cli/format/index.d.ts +0 -1
- package/dist/src/cli/format/output.d.ts +0 -12
- package/dist/src/cli/index.d.ts +0 -5
- package/dist/src/cli/runtime/index.d.ts +0 -1
- package/dist/src/cli/runtime/service.d.ts +0 -16
- package/dist/src/cli/scope/index.d.ts +0 -1
- package/dist/src/cli/scope/resolve.d.ts +0 -20
- package/dist/src/cli-path/layer.d.ts +0 -3
- package/dist/src/cli-path/service.d.ts +0 -8
- package/dist/src/config/config.d.ts +0 -49
- package/dist/src/config/credential/cipher-node.d.ts +0 -3
- package/dist/src/config/credential/cipher-web.d.ts +0 -3
- package/dist/src/config/credential/cipher.d.ts +0 -29
- package/dist/src/config/credential/env.d.ts +0 -3
- package/dist/src/config/credential/error.d.ts +0 -8
- package/dist/src/config/credential/index.d.ts +0 -6
- package/dist/src/config/credential/service.d.ts +0 -34
- package/dist/src/config/env/env.d.ts +0 -55
- package/dist/src/config/env/index.d.ts +0 -2
- package/dist/src/config/env/layout.d.ts +0 -11
- package/dist/src/config/environment-name/index.d.ts +0 -1
- package/dist/src/config/environment-name/name.d.ts +0 -10
- package/dist/src/config/error.d.ts +0 -11
- package/dist/src/config/index.d.ts +0 -10
- package/dist/src/config/keystore/error.d.ts +0 -8
- package/dist/src/config/keystore/file.d.ts +0 -9
- package/dist/src/config/keystore/index.d.ts +0 -4
- package/dist/src/config/keystore/keyring-node.d.ts +0 -4
- package/dist/src/config/keystore/service.d.ts +0 -33
- package/dist/src/config/paths/index.d.ts +0 -1
- package/dist/src/config/paths/paths.d.ts +0 -6
- package/dist/src/config/persist/file-mode.d.ts +0 -4
- package/dist/src/config/persist/migration.d.ts +0 -68
- package/dist/src/config/persist/persist.d.ts +0 -40
- package/dist/src/config/persist/schema.d.ts +0 -68
- package/dist/src/config/resolve/resolve.d.ts +0 -40
- package/dist/src/config/selection/index.d.ts +0 -1
- package/dist/src/config/selection/resolve.d.ts +0 -4
- package/dist/src/config/selection/service.d.ts +0 -10
- package/dist/src/config/types.d.ts +0 -36
- package/dist/src/config/url/error.d.ts +0 -10
- package/dist/src/config/url/index.d.ts +0 -2
- package/dist/src/config/url/url.d.ts +0 -6
- package/dist/src/connection/error.d.ts +0 -8
- package/dist/src/connection/index.d.ts +0 -4
- package/dist/src/connection/layer.d.ts +0 -3
- package/dist/src/connection/service.d.ts +0 -13
- package/dist/src/connection/type.d.ts +0 -10
- package/dist/src/contracts/index.d.ts +0 -1
- package/dist/src/domain/error.d.ts +0 -57
- package/dist/src/domain/helpers.d.ts +0 -184
- package/dist/src/domain/model-config.d.ts +0 -325
- package/dist/src/domain/thread-activities.d.ts +0 -14
- package/dist/src/domain/thread-lifecycle.d.ts +0 -125
- package/dist/src/index.d.ts +0 -3
- package/dist/src/node/connection.d.ts +0 -2
- package/dist/src/node/index.d.ts +0 -1
- package/dist/src/orchestration/index.d.ts +0 -2
- package/dist/src/orchestration/layer.d.ts +0 -1634
- package/dist/src/orchestration/service.d.ts +0 -28
- package/dist/src/rpc/error.d.ts +0 -18
- package/dist/src/rpc/index.d.ts +0 -5
- package/dist/src/rpc/layer.d.ts +0 -6271
- package/dist/src/rpc/operation.d.ts +0 -6280
- package/dist/src/rpc/service.d.ts +0 -15
- package/dist/src/rpc/ws-group.d.ts +0 -2725
- package/dist/src/runtime/index.d.ts +0 -1
- package/dist/src/runtime/layer.d.ts +0 -15
- package/dist/src/sql/node-sqlite-client.d.ts +0 -10
- package/dist/src/sql/service.d.ts +0 -17
- package/dist/src/t3tools/index.d.ts +0 -1
|
@@ -0,0 +1,245 @@
|
|
|
1
|
+
import { $D as flatMap, An as findErrorTraceId, EO as succeed, GO as currentTimeMillis, Gr as family, Ik as getOrNull, Jr as setIdleTTL, KE as map, KO as TaggedError, Kr as keepAlive, NO as tryPromise, OO as sync, PE as changes, QD as fail, Qr as toStream, RE as drop, WD as callback, Xr as withLabel, Ya as managedRelay_exports, Yr as swr, ZO as squash, aO as gen, ao as decodeRelayJwt, eO as fn, mO as onExit, oa as discovery_exports, qa as ManagedRelayClient, qr as make, ti as value, vy as RelayEnvironmentConnectScope, yy as RelayEnvironmentStatusScope } from "../shared.js";
|
|
2
|
+
//#region upstream-t3code/packages/client-runtime/src/relay/managedRelayState.ts
|
|
3
|
+
const DEFAULT_STALE_TIME_MS = 15e3;
|
|
4
|
+
const DEFAULT_IDLE_TTL_MS = 5 * 6e4;
|
|
5
|
+
const CLERK_TOKEN_EXPIRY_SKEW_MS = 5e3;
|
|
6
|
+
var ManagedRelaySessionError = class extends TaggedError("ManagedRelaySessionError") {};
|
|
7
|
+
var ManagedRelaySnapshotError = class extends TaggedError("ManagedRelaySnapshotError") {};
|
|
8
|
+
const managedRelaySessionAtom = make(null).pipe(keepAlive, withLabel("managed-relay:session"));
|
|
9
|
+
const managedRelaySessionControls = /* @__PURE__ */ new WeakMap();
|
|
10
|
+
function createManagedRelaySession(input) {
|
|
11
|
+
let cachedToken = null;
|
|
12
|
+
let pendingToken = null;
|
|
13
|
+
let readClerkToken = input.readClerkToken;
|
|
14
|
+
let tokenProviderGeneration = 0;
|
|
15
|
+
const readCachedClerkToken = async (nowMillis) => {
|
|
16
|
+
if (cachedToken && cachedToken.expiresAtMillis > nowMillis + CLERK_TOKEN_EXPIRY_SKEW_MS) return cachedToken.token;
|
|
17
|
+
if (pendingToken) return await pendingToken;
|
|
18
|
+
const operationGeneration = tokenProviderGeneration;
|
|
19
|
+
const operation = readClerkToken().then((token) => {
|
|
20
|
+
if (operationGeneration !== tokenProviderGeneration) return token;
|
|
21
|
+
if (!token) {
|
|
22
|
+
cachedToken = null;
|
|
23
|
+
return null;
|
|
24
|
+
}
|
|
25
|
+
try {
|
|
26
|
+
const expiresAtSeconds = decodeRelayJwt(token).exp;
|
|
27
|
+
cachedToken = typeof expiresAtSeconds === "number" ? {
|
|
28
|
+
token,
|
|
29
|
+
expiresAtMillis: expiresAtSeconds * 1e3
|
|
30
|
+
} : null;
|
|
31
|
+
} catch {
|
|
32
|
+
cachedToken = null;
|
|
33
|
+
}
|
|
34
|
+
return token;
|
|
35
|
+
});
|
|
36
|
+
pendingToken = operation;
|
|
37
|
+
try {
|
|
38
|
+
return await operation;
|
|
39
|
+
} finally {
|
|
40
|
+
if (pendingToken === operation) pendingToken = null;
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
const session = {
|
|
44
|
+
accountId: input.accountId,
|
|
45
|
+
readClerkToken: fn("clientRuntime.managedRelaySession.readClerkToken")(function* () {
|
|
46
|
+
const nowMillis = yield* currentTimeMillis;
|
|
47
|
+
return yield* tryPromise({
|
|
48
|
+
try: () => readCachedClerkToken(nowMillis),
|
|
49
|
+
catch: (cause) => new ManagedRelaySessionError({
|
|
50
|
+
message: "Could not obtain the T3 Connect session token.",
|
|
51
|
+
cause
|
|
52
|
+
})
|
|
53
|
+
});
|
|
54
|
+
})
|
|
55
|
+
};
|
|
56
|
+
managedRelaySessionControls.set(session, { updateReadClerkToken: (nextReadClerkToken) => {
|
|
57
|
+
readClerkToken = nextReadClerkToken;
|
|
58
|
+
tokenProviderGeneration += 1;
|
|
59
|
+
pendingToken = null;
|
|
60
|
+
} });
|
|
61
|
+
return session;
|
|
62
|
+
}
|
|
63
|
+
function setManagedRelaySession(registry, input) {
|
|
64
|
+
const current = registry.get(managedRelaySessionAtom);
|
|
65
|
+
if (input === null) {
|
|
66
|
+
if (current !== null) registry.set(managedRelaySessionAtom, null);
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
if (current?.accountId === input.accountId) {
|
|
70
|
+
const control = managedRelaySessionControls.get(current);
|
|
71
|
+
if (control) {
|
|
72
|
+
control.updateReadClerkToken(input.readClerkToken);
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
registry.set(managedRelaySessionAtom, createManagedRelaySession(input));
|
|
77
|
+
}
|
|
78
|
+
function managedRelayAccountChanges(registry) {
|
|
79
|
+
return toStream(registry, managedRelaySessionAtom).pipe(map((session) => session?.accountId ?? null), changes, drop(1));
|
|
80
|
+
}
|
|
81
|
+
function readSessionClerkToken(session) {
|
|
82
|
+
return session.readClerkToken().pipe(flatMap((token) => token ? succeed(token) : fail(new ManagedRelaySessionError({ message: "The T3 Connect session token is unavailable." }))));
|
|
83
|
+
}
|
|
84
|
+
const waitForManagedRelayClerkToken = fn("clientRuntime.managedRelaySession.waitForClerkToken")(function* (registry) {
|
|
85
|
+
return yield* callback((resume) => {
|
|
86
|
+
let unsubscribe;
|
|
87
|
+
let completed = false;
|
|
88
|
+
const readCurrentSession = () => {
|
|
89
|
+
if (completed) return true;
|
|
90
|
+
const session = registry.get(managedRelaySessionAtom);
|
|
91
|
+
if (!session) return false;
|
|
92
|
+
completed = true;
|
|
93
|
+
unsubscribe?.();
|
|
94
|
+
resume(readSessionClerkToken(session));
|
|
95
|
+
return true;
|
|
96
|
+
};
|
|
97
|
+
if (readCurrentSession()) return;
|
|
98
|
+
unsubscribe = registry.subscribe(managedRelaySessionAtom, readCurrentSession);
|
|
99
|
+
readCurrentSession();
|
|
100
|
+
return sync(() => unsubscribe?.());
|
|
101
|
+
});
|
|
102
|
+
});
|
|
103
|
+
function requireClerkToken(get, accountId) {
|
|
104
|
+
const session = get(managedRelaySessionAtom);
|
|
105
|
+
if (!session || session.accountId !== accountId) return fail(new ManagedRelaySessionError({ message: "Sign in to T3 Connect before loading relay data." }));
|
|
106
|
+
return readSessionClerkToken(session);
|
|
107
|
+
}
|
|
108
|
+
function statusKey(input) {
|
|
109
|
+
return JSON.stringify(input);
|
|
110
|
+
}
|
|
111
|
+
function parseStatusKey(key) {
|
|
112
|
+
return JSON.parse(key);
|
|
113
|
+
}
|
|
114
|
+
function endpointMatches(left, right) {
|
|
115
|
+
return left.httpBaseUrl === right.httpBaseUrl && left.wsBaseUrl === right.wsBaseUrl && left.providerKind === right.providerKind;
|
|
116
|
+
}
|
|
117
|
+
function validateEnvironmentStatus(environment, status) {
|
|
118
|
+
if (status.environmentId !== environment.environmentId) return fail(new ManagedRelaySnapshotError({ message: "Relay returned status for a different environment." }));
|
|
119
|
+
if (!endpointMatches(status.endpoint, environment.endpoint)) return fail(new ManagedRelaySnapshotError({ message: "Relay returned status for a different endpoint." }));
|
|
120
|
+
if (status.descriptor && status.descriptor.environmentId !== environment.environmentId) return fail(new ManagedRelaySnapshotError({ message: "Relay returned status descriptor for a different environment." }));
|
|
121
|
+
return succeed(status);
|
|
122
|
+
}
|
|
123
|
+
function readManagedRelaySnapshotState(result) {
|
|
124
|
+
let error = null;
|
|
125
|
+
let errorTraceId = null;
|
|
126
|
+
if (result._tag === "Failure") {
|
|
127
|
+
const cause = squash(result.cause);
|
|
128
|
+
error = cause instanceof Error ? cause.message : "Could not load T3 Connect data.";
|
|
129
|
+
errorTraceId = findErrorTraceId(cause);
|
|
130
|
+
}
|
|
131
|
+
return {
|
|
132
|
+
data: getOrNull(value(result)),
|
|
133
|
+
error,
|
|
134
|
+
errorTraceId,
|
|
135
|
+
isPending: result.waiting
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
function createManagedRelayQueryManager(runtime, options) {
|
|
139
|
+
const staleTime = options?.staleTimeMs ?? DEFAULT_STALE_TIME_MS;
|
|
140
|
+
const idleTtl = options?.idleTtlMs ?? DEFAULT_IDLE_TTL_MS;
|
|
141
|
+
const observe = (input, effect) => gen(function* () {
|
|
142
|
+
options?.onQueryEvent?.({
|
|
143
|
+
...input,
|
|
144
|
+
phase: "start"
|
|
145
|
+
});
|
|
146
|
+
return yield* effect.pipe(onExit((exit) => sync(() => {
|
|
147
|
+
if (exit._tag === "Success") {
|
|
148
|
+
options?.onQueryEvent?.({
|
|
149
|
+
...input,
|
|
150
|
+
phase: "success"
|
|
151
|
+
});
|
|
152
|
+
return;
|
|
153
|
+
}
|
|
154
|
+
const error = squash(exit.cause);
|
|
155
|
+
options?.onQueryEvent?.({
|
|
156
|
+
...input,
|
|
157
|
+
phase: "failure",
|
|
158
|
+
message: error instanceof Error ? error.message : String(error),
|
|
159
|
+
traceId: findErrorTraceId(error)
|
|
160
|
+
});
|
|
161
|
+
})));
|
|
162
|
+
});
|
|
163
|
+
const environmentsAtom = family((accountId) => runtime.atom((get) => gen(function* () {
|
|
164
|
+
const base = {
|
|
165
|
+
operation: "environments",
|
|
166
|
+
accountId
|
|
167
|
+
};
|
|
168
|
+
const clerkToken = yield* observe({
|
|
169
|
+
...base,
|
|
170
|
+
stage: "clerk-token"
|
|
171
|
+
}, requireClerkToken(get, accountId));
|
|
172
|
+
const relay = yield* ManagedRelayClient;
|
|
173
|
+
return yield* observe({
|
|
174
|
+
...base,
|
|
175
|
+
stage: "relay-request"
|
|
176
|
+
}, relay.listEnvironments({ clerkToken }));
|
|
177
|
+
})).pipe(swr({
|
|
178
|
+
staleTime,
|
|
179
|
+
revalidateOnMount: true
|
|
180
|
+
}), setIdleTTL(idleTtl), withLabel(`managed-relay:environments:${accountId}`)));
|
|
181
|
+
const devicesAtom = family((accountId) => runtime.atom((get) => gen(function* () {
|
|
182
|
+
const base = {
|
|
183
|
+
operation: "devices",
|
|
184
|
+
accountId
|
|
185
|
+
};
|
|
186
|
+
const clerkToken = yield* observe({
|
|
187
|
+
...base,
|
|
188
|
+
stage: "clerk-token"
|
|
189
|
+
}, requireClerkToken(get, accountId));
|
|
190
|
+
const relay = yield* ManagedRelayClient;
|
|
191
|
+
return yield* observe({
|
|
192
|
+
...base,
|
|
193
|
+
stage: "relay-request"
|
|
194
|
+
}, relay.listDevices({ clerkToken }));
|
|
195
|
+
})).pipe(swr({
|
|
196
|
+
staleTime,
|
|
197
|
+
revalidateOnMount: true
|
|
198
|
+
}), setIdleTTL(idleTtl), withLabel(`managed-relay:devices:${accountId}`)));
|
|
199
|
+
const environmentStatusAtom = family((key) => {
|
|
200
|
+
const { accountId, environment } = parseStatusKey(key);
|
|
201
|
+
return runtime.atom((get) => gen(function* () {
|
|
202
|
+
const base = {
|
|
203
|
+
operation: "environment-status",
|
|
204
|
+
accountId,
|
|
205
|
+
environmentId: environment.environmentId
|
|
206
|
+
};
|
|
207
|
+
const clerkToken = yield* observe({
|
|
208
|
+
...base,
|
|
209
|
+
stage: "clerk-token"
|
|
210
|
+
}, requireClerkToken(get, accountId));
|
|
211
|
+
const relay = yield* ManagedRelayClient;
|
|
212
|
+
const status = yield* observe({
|
|
213
|
+
...base,
|
|
214
|
+
stage: "relay-request"
|
|
215
|
+
}, relay.getEnvironmentStatus({
|
|
216
|
+
clerkToken,
|
|
217
|
+
scopes: [RelayEnvironmentStatusScope, RelayEnvironmentConnectScope],
|
|
218
|
+
environmentId: environment.environmentId
|
|
219
|
+
}));
|
|
220
|
+
return yield* observe({
|
|
221
|
+
...base,
|
|
222
|
+
stage: "validation"
|
|
223
|
+
}, validateEnvironmentStatus(environment, status));
|
|
224
|
+
})).pipe(swr({
|
|
225
|
+
staleTime,
|
|
226
|
+
revalidateOnMount: true
|
|
227
|
+
}), setIdleTTL(idleTtl), withLabel(`managed-relay:environment-status:${key}`));
|
|
228
|
+
});
|
|
229
|
+
return {
|
|
230
|
+
environmentsAtom,
|
|
231
|
+
devicesAtom,
|
|
232
|
+
environmentStatusAtom: (input) => environmentStatusAtom(statusKey(input)),
|
|
233
|
+
refreshEnvironments(registry, accountId) {
|
|
234
|
+
registry.refresh(environmentsAtom(accountId));
|
|
235
|
+
},
|
|
236
|
+
refreshDevices(registry, accountId) {
|
|
237
|
+
registry.refresh(devicesAtom(accountId));
|
|
238
|
+
},
|
|
239
|
+
refreshEnvironmentStatus(registry, input) {
|
|
240
|
+
registry.refresh(environmentStatusAtom(statusKey(input)));
|
|
241
|
+
}
|
|
242
|
+
};
|
|
243
|
+
}
|
|
244
|
+
//#endregion
|
|
245
|
+
export { discovery_exports as Discovery, managedRelay_exports as ManagedRelay, ManagedRelaySessionError, ManagedRelaySnapshotError, createManagedRelayQueryManager, createManagedRelaySession, managedRelayAccountChanges, managedRelaySessionAtom, readManagedRelaySnapshotState, setManagedRelaySession, waitForManagedRelayClerkToken };
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { $a as makeWsRpcProtocolClient, $t as EnvironmentRpcRequestObserver, Ba as RemoteEnvironmentAuthInvalidJsonError, Ga as makeEnvironmentHttpApiClient, Ha as RemoteEnvironmentAuthUndeclaredStatusError, Ka as remoteHttpClientLayer, Qa as WsRpcProtocolClient, Qt as EnvironmentRpcRequestObservation, Ua as RemoteEnvironmentRequestError, Va as RemoteEnvironmentAuthTimeoutError, Wa as executeEnvironmentHttpRequest, Xa as RpcSession, Xt as EnvironmentRpcFailure, Za as RpcSessionFactory, Zt as EnvironmentRpcInput, an as EnvironmentRpcTag, cn as EnvironmentStreamRpcTag, dn as config, en as EnvironmentRpcStreamFailure, fn as request, hn as subscribeDynamic, in as EnvironmentRpcSuccess, ln as EnvironmentSubscriptionRpcTag, mn as subscribe, nn as EnvironmentRpcSubscriptionObservation, on as EnvironmentRpcUnavailableError, pn as runStream, rn as EnvironmentRpcSubscriptionObserver, sn as EnvironmentStreamCommandRpcTag, tn as EnvironmentRpcStreamValue, un as EnvironmentUnaryRpcTag, za as RemoteEnvironmentAuthFetchError } from "../shared.js";
|
|
2
|
+
export { EnvironmentRpcFailure, EnvironmentRpcInput, EnvironmentRpcRequestObservation, EnvironmentRpcRequestObserver, EnvironmentRpcStreamFailure, EnvironmentRpcStreamValue, EnvironmentRpcSubscriptionObservation, EnvironmentRpcSubscriptionObserver, EnvironmentRpcSuccess, EnvironmentRpcTag, EnvironmentRpcUnavailableError, EnvironmentStreamCommandRpcTag, EnvironmentStreamRpcTag, EnvironmentSubscriptionRpcTag, EnvironmentUnaryRpcTag, RemoteEnvironmentAuthFetchError, RemoteEnvironmentAuthInvalidJsonError, RemoteEnvironmentAuthTimeoutError, RemoteEnvironmentAuthUndeclaredStatusError, RemoteEnvironmentRequestError, type RpcSession, RpcSessionFactory, WsRpcProtocolClient, config, executeEnvironmentHttpRequest, makeEnvironmentHttpApiClient, makeWsRpcProtocolClient, remoteHttpClientLayer, request, runStream, subscribe, subscribeDynamic };
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { Ao as RemoteEnvironmentAuthTimeoutError, Ba as RpcSessionFactory, Br as config, Hr as runStream, Lr as EnvironmentRpcRequestObserver, Mo as executeEnvironmentHttpRequest, No as makeEnvironmentHttpApiClient, Oo as RemoteEnvironmentAuthFetchError, Po as remoteHttpClientLayer, Rr as EnvironmentRpcSubscriptionObserver, Ur as subscribe, Va as makeWsRpcProtocolClient, Vr as request, Wr as subscribeDynamic, jo as RemoteEnvironmentAuthUndeclaredStatusError, ko as RemoteEnvironmentAuthInvalidJsonError, zr as EnvironmentRpcUnavailableError } from "../shared.js";
|
|
2
|
+
export { EnvironmentRpcRequestObserver, EnvironmentRpcSubscriptionObserver, EnvironmentRpcUnavailableError, RemoteEnvironmentAuthFetchError, RemoteEnvironmentAuthInvalidJsonError, RemoteEnvironmentAuthTimeoutError, RemoteEnvironmentAuthUndeclaredStatusError, RpcSessionFactory, config, executeEnvironmentHttpRequest, makeEnvironmentHttpApiClient, makeWsRpcProtocolClient, remoteHttpClientLayer, request, runStream, subscribe, subscribeDynamic };
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { Ax as AssetProjectFaviconNotFoundError, Bx as AssetWorkspaceRootNormalizationError, Fx as AssetWorkspaceAssetNotFoundError, Ix as AssetWorkspaceContextNotFoundError, Lx as AssetWorkspaceContextResolutionError, Mx as AssetResource, Nx as AssetSigningKeyLoadError, Ox as AssetPreviewTypeValidationError, Px as AssetWorkspaceAssetInspectionError, Rx as AssetWorkspacePathValidationError, Tx as AssetAttachmentNotFoundError, bT as EnvironmentAuthorizationError, ha as EnvironmentRegistry, jx as AssetProjectFaviconResolutionError, kx as AssetProjectFaviconInspectionError, on as EnvironmentRpcUnavailableError, zT as EnvironmentId, zx as AssetWorkspaceResolutionError } from "../../shared.js";
|
|
2
|
+
import * as Schema from "effect/Schema";
|
|
3
|
+
import { Atom } from "effect/unstable/reactivity";
|
|
4
|
+
//#region upstream-t3code/packages/client-runtime/src/state/assets.d.ts
|
|
5
|
+
declare const InvalidAssetCollectionKeyError_base: Schema.Class<InvalidAssetCollectionKeyError, Schema.TaggedStruct<"InvalidAssetCollectionKeyError", {
|
|
6
|
+
readonly key: Schema.String;
|
|
7
|
+
readonly cause: Schema.Defect;
|
|
8
|
+
}>, import("effect/Cause").YieldableError>;
|
|
9
|
+
declare class InvalidAssetCollectionKeyError extends InvalidAssetCollectionKeyError_base {
|
|
10
|
+
get message(): string;
|
|
11
|
+
}
|
|
12
|
+
declare function parseAssetCollectionKey(key: string): readonly [EnvironmentId, ReadonlyArray<AssetResource>];
|
|
13
|
+
declare function resolveAssetUrl(httpBaseUrl: string, relativeUrl: string): string | null;
|
|
14
|
+
declare function createAssetEnvironmentAtoms<R, E>(runtime: Atom.AtomRuntime<EnvironmentRegistry | R, E>): {
|
|
15
|
+
createUrl: (target: {
|
|
16
|
+
readonly environmentId: EnvironmentId;
|
|
17
|
+
readonly input: Schema.Struct.ReadonlyMakeIn<{
|
|
18
|
+
readonly resource: Schema.Union<readonly [Schema.TaggedStruct<"workspace-file", {
|
|
19
|
+
readonly threadId: Schema.brand<Schema.decodeTo<Schema.String, Schema.String, never, never>, "ThreadId">;
|
|
20
|
+
readonly path: Schema.decodeTo<Schema.String, Schema.String, never, never>;
|
|
21
|
+
}>, Schema.TaggedStruct<"attachment", {
|
|
22
|
+
readonly attachmentId: Schema.decodeTo<Schema.String, Schema.String, never, never>;
|
|
23
|
+
}>, Schema.TaggedStruct<"project-favicon", {
|
|
24
|
+
readonly cwd: Schema.decodeTo<Schema.String, Schema.String, never, never>;
|
|
25
|
+
}>]>;
|
|
26
|
+
}>;
|
|
27
|
+
}) => Atom.Atom<import("effect/unstable/reactivity/AsyncResult").AsyncResult<{
|
|
28
|
+
readonly relativeUrl: string;
|
|
29
|
+
readonly expiresAt: number;
|
|
30
|
+
}, E | AssetAttachmentNotFoundError | AssetPreviewTypeValidationError | AssetProjectFaviconInspectionError | AssetProjectFaviconNotFoundError | AssetProjectFaviconResolutionError | AssetSigningKeyLoadError | AssetWorkspaceAssetInspectionError | AssetWorkspaceAssetNotFoundError | AssetWorkspaceContextNotFoundError | AssetWorkspaceContextResolutionError | AssetWorkspacePathValidationError | AssetWorkspaceResolutionError | AssetWorkspaceRootNormalizationError | EnvironmentAuthorizationError | EnvironmentRpcUnavailableError | Error | import("effect/unstable/rpc/RpcClientError").RpcClientError>>;
|
|
31
|
+
createUrls: (target: {
|
|
32
|
+
readonly environmentId: EnvironmentId;
|
|
33
|
+
readonly resources: ReadonlyArray<AssetResource>;
|
|
34
|
+
}) => Atom.Atom<import("effect/unstable/reactivity/AsyncResult").AsyncResult<{
|
|
35
|
+
readonly relativeUrl: string;
|
|
36
|
+
readonly expiresAt: number;
|
|
37
|
+
}, E | AssetAttachmentNotFoundError | AssetPreviewTypeValidationError | AssetProjectFaviconInspectionError | AssetProjectFaviconNotFoundError | AssetProjectFaviconResolutionError | AssetSigningKeyLoadError | AssetWorkspaceAssetInspectionError | AssetWorkspaceAssetNotFoundError | AssetWorkspaceContextNotFoundError | AssetWorkspaceContextResolutionError | AssetWorkspacePathValidationError | AssetWorkspaceResolutionError | AssetWorkspaceRootNormalizationError | EnvironmentAuthorizationError | EnvironmentRpcUnavailableError | Error | import("effect/unstable/rpc/RpcClientError").RpcClientError>[]>;
|
|
38
|
+
};
|
|
39
|
+
//#endregion
|
|
40
|
+
export { InvalidAssetCollectionKeyError, createAssetEnvironmentAtoms, parseAssetCollectionKey, resolveAssetUrl };
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { Fs as WS_METHODS, GT as Defect, Gr as family, JS as EnvironmentId, Jr as setIdleTTL, QT as String, WT as ArraySchema, Xr as withLabel, eE as TaggedErrorClass, fr as createEnvironmentRpcQueryAtomFamily, oE as decodeUnknownSync, ou as AssetResource, qr as make, tE as Tuple } from "../../shared.js";
|
|
2
|
+
//#region upstream-t3code/packages/client-runtime/src/state/assets.ts
|
|
3
|
+
const ASSET_URL_REFRESH_INTERVAL_MS = 30 * 6e4;
|
|
4
|
+
const ASSET_URL_STALE_TIME_MS = 5 * 6e4;
|
|
5
|
+
const ASSET_URL_IDLE_TTL_MS = 60 * 6e4;
|
|
6
|
+
var InvalidAssetCollectionKeyError = class extends TaggedErrorClass()("InvalidAssetCollectionKeyError", {
|
|
7
|
+
key: String,
|
|
8
|
+
cause: Defect()
|
|
9
|
+
}) {
|
|
10
|
+
get message() {
|
|
11
|
+
return `Invalid asset collection atom key: ${JSON.stringify(this.key)}.`;
|
|
12
|
+
}
|
|
13
|
+
};
|
|
14
|
+
const decodeAssetCollectionKey = decodeUnknownSync(Tuple([EnvironmentId, ArraySchema(AssetResource)]));
|
|
15
|
+
function parseAssetCollectionKey(key) {
|
|
16
|
+
try {
|
|
17
|
+
return decodeAssetCollectionKey(JSON.parse(key));
|
|
18
|
+
} catch (cause) {
|
|
19
|
+
throw new InvalidAssetCollectionKeyError({
|
|
20
|
+
key,
|
|
21
|
+
cause
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
function resolveAssetUrl(httpBaseUrl, relativeUrl) {
|
|
26
|
+
try {
|
|
27
|
+
return new URL(relativeUrl, httpBaseUrl).toString();
|
|
28
|
+
} catch {
|
|
29
|
+
return null;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
function createAssetEnvironmentAtoms(runtime) {
|
|
33
|
+
const createUrl = createEnvironmentRpcQueryAtomFamily(runtime, {
|
|
34
|
+
label: "environment-data:assets:create-url",
|
|
35
|
+
tag: WS_METHODS.assetsCreateUrl,
|
|
36
|
+
staleTimeMs: ASSET_URL_STALE_TIME_MS,
|
|
37
|
+
idleTtlMs: ASSET_URL_IDLE_TTL_MS,
|
|
38
|
+
refreshIntervalMs: ASSET_URL_REFRESH_INTERVAL_MS
|
|
39
|
+
});
|
|
40
|
+
const createUrlsFamily = family((key) => {
|
|
41
|
+
const [environmentId, resources] = parseAssetCollectionKey(key);
|
|
42
|
+
return make((get) => resources.map((resource) => get(createUrl({
|
|
43
|
+
environmentId,
|
|
44
|
+
input: { resource }
|
|
45
|
+
})))).pipe(setIdleTTL(ASSET_URL_IDLE_TTL_MS), withLabel(`environment-data:assets:create-urls:${key}`));
|
|
46
|
+
});
|
|
47
|
+
return {
|
|
48
|
+
createUrl,
|
|
49
|
+
createUrls: (target) => createUrlsFamily(JSON.stringify([target.environmentId, target.resources]))
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
//#endregion
|
|
53
|
+
export { InvalidAssetCollectionKeyError, createAssetEnvironmentAtoms, parseAssetCollectionKey, resolveAssetUrl };
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { Bw as AuthAccessStreamError, Lw as AuthAccessSnapshot, Vw as AuthAccessStreamEvent, bT as EnvironmentAuthorizationError, ha as EnvironmentRegistry, zT as EnvironmentId } from "../../shared.js";
|
|
2
|
+
import { Atom } from "effect/unstable/reactivity";
|
|
3
|
+
//#region upstream-t3code/packages/client-runtime/src/state/auth.d.ts
|
|
4
|
+
declare const EMPTY_AUTH_ACCESS_SNAPSHOT: AuthAccessSnapshot;
|
|
5
|
+
declare function applyAuthAccessStreamEvent(current: AuthAccessSnapshot, event: AuthAccessStreamEvent): AuthAccessSnapshot;
|
|
6
|
+
declare function projectAuthAccessSnapshot(current: AuthAccessSnapshot, event: AuthAccessStreamEvent): readonly [AuthAccessSnapshot, ReadonlyArray<AuthAccessStreamEvent>];
|
|
7
|
+
declare function createAuthEnvironmentAtoms<R, E>(runtime: Atom.AtomRuntime<EnvironmentRegistry | R, E>): {
|
|
8
|
+
accessChanges: (target: {
|
|
9
|
+
readonly environmentId: EnvironmentId;
|
|
10
|
+
readonly input: null;
|
|
11
|
+
}) => Atom.Atom<import("effect/unstable/reactivity/AsyncResult").AsyncResult<{
|
|
12
|
+
readonly version: 1;
|
|
13
|
+
readonly revision: number;
|
|
14
|
+
readonly type: "snapshot";
|
|
15
|
+
readonly payload: {
|
|
16
|
+
readonly pairingLinks: readonly {
|
|
17
|
+
readonly id: string;
|
|
18
|
+
readonly credential: string;
|
|
19
|
+
readonly scopes: readonly ("access:read" | "access:write" | "orchestration:operate" | "orchestration:read" | "relay:read" | "relay:write" | "review:write" | "terminal:operate")[];
|
|
20
|
+
readonly subject: string;
|
|
21
|
+
readonly label?: string;
|
|
22
|
+
readonly createdAt: import("effect/DateTime").Utc;
|
|
23
|
+
readonly expiresAt: import("effect/DateTime").Utc;
|
|
24
|
+
}[];
|
|
25
|
+
readonly clientSessions: readonly {
|
|
26
|
+
readonly sessionId: string & import("effect/Brand").Brand<"AuthSessionId">;
|
|
27
|
+
readonly subject: string;
|
|
28
|
+
readonly scopes: readonly ("access:read" | "access:write" | "orchestration:operate" | "orchestration:read" | "relay:read" | "relay:write" | "review:write" | "terminal:operate")[];
|
|
29
|
+
readonly method: "bearer-access-token" | "browser-session-cookie" | "dpop-access-token";
|
|
30
|
+
readonly client: {
|
|
31
|
+
readonly label?: string;
|
|
32
|
+
readonly ipAddress?: string;
|
|
33
|
+
readonly userAgent?: string;
|
|
34
|
+
readonly deviceType: "bot" | "desktop" | "mobile" | "tablet" | "unknown";
|
|
35
|
+
readonly os?: string;
|
|
36
|
+
readonly browser?: string;
|
|
37
|
+
};
|
|
38
|
+
readonly issuedAt: import("effect/DateTime").Utc;
|
|
39
|
+
readonly expiresAt: import("effect/DateTime").Utc;
|
|
40
|
+
readonly lastConnectedAt: import("effect/DateTime").Utc | null;
|
|
41
|
+
readonly connected: boolean;
|
|
42
|
+
readonly current: boolean;
|
|
43
|
+
}[];
|
|
44
|
+
};
|
|
45
|
+
} | {
|
|
46
|
+
readonly version: 1;
|
|
47
|
+
readonly revision: number;
|
|
48
|
+
readonly type: "pairingLinkUpserted";
|
|
49
|
+
readonly payload: {
|
|
50
|
+
readonly id: string;
|
|
51
|
+
readonly credential: string;
|
|
52
|
+
readonly scopes: readonly ("access:read" | "access:write" | "orchestration:operate" | "orchestration:read" | "relay:read" | "relay:write" | "review:write" | "terminal:operate")[];
|
|
53
|
+
readonly subject: string;
|
|
54
|
+
readonly label?: string;
|
|
55
|
+
readonly createdAt: import("effect/DateTime").Utc;
|
|
56
|
+
readonly expiresAt: import("effect/DateTime").Utc;
|
|
57
|
+
};
|
|
58
|
+
} | {
|
|
59
|
+
readonly version: 1;
|
|
60
|
+
readonly revision: number;
|
|
61
|
+
readonly type: "pairingLinkRemoved";
|
|
62
|
+
readonly payload: {
|
|
63
|
+
readonly id: string;
|
|
64
|
+
};
|
|
65
|
+
} | {
|
|
66
|
+
readonly version: 1;
|
|
67
|
+
readonly revision: number;
|
|
68
|
+
readonly type: "clientUpserted";
|
|
69
|
+
readonly payload: {
|
|
70
|
+
readonly sessionId: string & import("effect/Brand").Brand<"AuthSessionId">;
|
|
71
|
+
readonly subject: string;
|
|
72
|
+
readonly scopes: readonly ("access:read" | "access:write" | "orchestration:operate" | "orchestration:read" | "relay:read" | "relay:write" | "review:write" | "terminal:operate")[];
|
|
73
|
+
readonly method: "bearer-access-token" | "browser-session-cookie" | "dpop-access-token";
|
|
74
|
+
readonly client: {
|
|
75
|
+
readonly label?: string;
|
|
76
|
+
readonly ipAddress?: string;
|
|
77
|
+
readonly userAgent?: string;
|
|
78
|
+
readonly deviceType: "bot" | "desktop" | "mobile" | "tablet" | "unknown";
|
|
79
|
+
readonly os?: string;
|
|
80
|
+
readonly browser?: string;
|
|
81
|
+
};
|
|
82
|
+
readonly issuedAt: import("effect/DateTime").Utc;
|
|
83
|
+
readonly expiresAt: import("effect/DateTime").Utc;
|
|
84
|
+
readonly lastConnectedAt: import("effect/DateTime").Utc | null;
|
|
85
|
+
readonly connected: boolean;
|
|
86
|
+
readonly current: boolean;
|
|
87
|
+
};
|
|
88
|
+
} | {
|
|
89
|
+
readonly version: 1;
|
|
90
|
+
readonly revision: number;
|
|
91
|
+
readonly type: "clientRemoved";
|
|
92
|
+
readonly payload: {
|
|
93
|
+
readonly sessionId: string & import("effect/Brand").Brand<"AuthSessionId">;
|
|
94
|
+
};
|
|
95
|
+
}, E | AuthAccessStreamError | EnvironmentAuthorizationError | import("effect/Cause").NoSuchElementError | import("effect/unstable/rpc/RpcClientError").RpcClientError>>;
|
|
96
|
+
};
|
|
97
|
+
//#endregion
|
|
98
|
+
export { EMPTY_AUTH_ACCESS_SNAPSHOT, applyAuthAccessStreamEvent, createAuthEnvironmentAtoms, projectAuthAccessSnapshot };
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { Fs as WS_METHODS, Ur as subscribe, hr as createEnvironmentSubscriptionAtomFamily, qE as mapAccum } from "../../shared.js";
|
|
2
|
+
//#region upstream-t3code/packages/client-runtime/src/state/auth.ts
|
|
3
|
+
const EMPTY_AUTH_ACCESS_SNAPSHOT = {
|
|
4
|
+
pairingLinks: [],
|
|
5
|
+
clientSessions: []
|
|
6
|
+
};
|
|
7
|
+
function upsertByKey(values, next, key) {
|
|
8
|
+
const nextKey = key(next);
|
|
9
|
+
return [...values.filter((value) => key(value) !== nextKey), next];
|
|
10
|
+
}
|
|
11
|
+
function applyAuthAccessStreamEvent(current, event) {
|
|
12
|
+
switch (event.type) {
|
|
13
|
+
case "snapshot": return event.payload;
|
|
14
|
+
case "pairingLinkUpserted": return {
|
|
15
|
+
...current,
|
|
16
|
+
pairingLinks: upsertByKey(current.pairingLinks, event.payload, (value) => value.id)
|
|
17
|
+
};
|
|
18
|
+
case "pairingLinkRemoved": return {
|
|
19
|
+
...current,
|
|
20
|
+
pairingLinks: current.pairingLinks.filter((value) => value.id !== event.payload.id)
|
|
21
|
+
};
|
|
22
|
+
case "clientUpserted": return {
|
|
23
|
+
...current,
|
|
24
|
+
clientSessions: upsertByKey(current.clientSessions, event.payload, (value) => value.sessionId)
|
|
25
|
+
};
|
|
26
|
+
case "clientRemoved": return {
|
|
27
|
+
...current,
|
|
28
|
+
clientSessions: current.clientSessions.filter((value) => value.sessionId !== event.payload.sessionId)
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
function projectAuthAccessSnapshot(current, event) {
|
|
33
|
+
const snapshot = applyAuthAccessStreamEvent(current, event);
|
|
34
|
+
return [snapshot, [{
|
|
35
|
+
version: 1,
|
|
36
|
+
revision: event.revision,
|
|
37
|
+
type: "snapshot",
|
|
38
|
+
payload: snapshot
|
|
39
|
+
}]];
|
|
40
|
+
}
|
|
41
|
+
function createAuthEnvironmentAtoms(runtime) {
|
|
42
|
+
return { accessChanges: createEnvironmentSubscriptionAtomFamily(runtime, {
|
|
43
|
+
label: "environment-data:server:auth-access-changes",
|
|
44
|
+
subscribe: (_input) => subscribe(WS_METHODS.subscribeAuthAccess, {}).pipe(mapAccum(() => EMPTY_AUTH_ACCESS_SNAPSHOT, projectAuthAccessSnapshot))
|
|
45
|
+
}) };
|
|
46
|
+
}
|
|
47
|
+
//#endregion
|
|
48
|
+
export { EMPTY_AUTH_ACCESS_SNAPSHOT, applyAuthAccessStreamEvent, createAuthEnvironmentAtoms, projectAuthAccessSnapshot };
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { $D as flatMap, Aa as EnvironmentSupervisor, Fk as getOrElse, Gr as family, KE as map$1, Oa as EnvironmentRegistry, Sv as changes, Xr as withLabel, gr as createRuntimeCommand, lD as unwrap, lr as createAtomCommandScheduler, qr as make, ti as value, uO as map, us as AVAILABLE_CONNECTION_STATE, xr as followStreamInEnvironment } from "../../shared.js";
|
|
2
|
+
//#region upstream-t3code/packages/client-runtime/src/state/connections.ts
|
|
3
|
+
const EMPTY_ENVIRONMENT_CATALOG_STATE = Object.freeze({
|
|
4
|
+
isReady: false,
|
|
5
|
+
entries: /* @__PURE__ */ new Map()
|
|
6
|
+
});
|
|
7
|
+
function createEnvironmentCatalogAtoms(runtime) {
|
|
8
|
+
const commandScheduler = createAtomCommandScheduler();
|
|
9
|
+
const serial = {
|
|
10
|
+
mode: "serial",
|
|
11
|
+
key: () => "environment-catalog"
|
|
12
|
+
};
|
|
13
|
+
const catalogAtom = runtime.atom(unwrap(EnvironmentRegistry.pipe(map((registry) => changes(registry.entries).pipe(map$1((entries) => ({
|
|
14
|
+
isReady: true,
|
|
15
|
+
entries
|
|
16
|
+
})))))), { initialValue: EMPTY_ENVIRONMENT_CATALOG_STATE });
|
|
17
|
+
const catalogValueAtom = make((get) => getOrElse(value(get(catalogAtom)), () => EMPTY_ENVIRONMENT_CATALOG_STATE)).pipe(withLabel("environment-catalog-value"));
|
|
18
|
+
const networkStatusAtom = runtime.atom(unwrap(EnvironmentRegistry.pipe(map((registry) => changes(registry.networkStatus)))), { initialValue: "unknown" });
|
|
19
|
+
return {
|
|
20
|
+
catalogAtom,
|
|
21
|
+
catalogValueAtom,
|
|
22
|
+
networkStatusAtom,
|
|
23
|
+
networkStatusValueAtom: make((get) => getOrElse(value(get(networkStatusAtom)), () => "unknown")).pipe(withLabel("environment-network-status-value")),
|
|
24
|
+
stateAtom: family((environmentId) => runtime.atom(followStreamInEnvironment(environmentId, unwrap(EnvironmentSupervisor.pipe(map((supervisor) => changes(supervisor.state))))), { initialValue: AVAILABLE_CONNECTION_STATE })),
|
|
25
|
+
register: createRuntimeCommand(runtime, {
|
|
26
|
+
label: "environment-catalog:register",
|
|
27
|
+
scheduler: commandScheduler,
|
|
28
|
+
concurrency: serial,
|
|
29
|
+
execute: (target) => EnvironmentRegistry.pipe(flatMap((registry) => registry.register(target)))
|
|
30
|
+
}),
|
|
31
|
+
remove: createRuntimeCommand(runtime, {
|
|
32
|
+
label: "environment-catalog:remove",
|
|
33
|
+
scheduler: commandScheduler,
|
|
34
|
+
concurrency: serial,
|
|
35
|
+
execute: (environmentId) => EnvironmentRegistry.pipe(flatMap((registry) => registry.remove(environmentId)))
|
|
36
|
+
}),
|
|
37
|
+
removeRelayEnvironments: createRuntimeCommand(runtime, {
|
|
38
|
+
label: "environment-catalog:remove-relay-environments",
|
|
39
|
+
scheduler: commandScheduler,
|
|
40
|
+
concurrency: serial,
|
|
41
|
+
execute: (_input) => EnvironmentRegistry.pipe(flatMap((registry) => registry.removeRelayEnvironments()))
|
|
42
|
+
}),
|
|
43
|
+
retryNow: createRuntimeCommand(runtime, {
|
|
44
|
+
label: "environment-catalog:retry-now",
|
|
45
|
+
scheduler: commandScheduler,
|
|
46
|
+
concurrency: serial,
|
|
47
|
+
execute: (environmentId) => EnvironmentRegistry.pipe(flatMap((registry) => registry.retryNow(environmentId)))
|
|
48
|
+
})
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
//#endregion
|
|
52
|
+
export { EMPTY_ENVIRONMENT_CATALOG_STATE, createEnvironmentCatalogAtoms };
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { Mw as ScopedThreadRef, jw as ScopedProjectRef } from "../../shared.js";
|
|
2
|
+
import * as Schema from "effect/Schema";
|
|
3
|
+
//#region upstream-t3code/packages/client-runtime/src/state/entities.d.ts
|
|
4
|
+
declare const InvalidScopedProjectKeyError_base: Schema.Class<InvalidScopedProjectKeyError, Schema.TaggedStruct<"InvalidScopedProjectKeyError", {
|
|
5
|
+
readonly key: Schema.String;
|
|
6
|
+
}>, import("effect/Cause").YieldableError>;
|
|
7
|
+
declare class InvalidScopedProjectKeyError extends InvalidScopedProjectKeyError_base {
|
|
8
|
+
get message(): string;
|
|
9
|
+
}
|
|
10
|
+
declare const InvalidScopedThreadKeyError_base: Schema.Class<InvalidScopedThreadKeyError, Schema.TaggedStruct<"InvalidScopedThreadKeyError", {
|
|
11
|
+
readonly key: Schema.String;
|
|
12
|
+
}>, import("effect/Cause").YieldableError>;
|
|
13
|
+
declare class InvalidScopedThreadKeyError extends InvalidScopedThreadKeyError_base {
|
|
14
|
+
get message(): string;
|
|
15
|
+
}
|
|
16
|
+
declare const InvalidScopedProjectRefCollectionKeyError_base: Schema.Class<InvalidScopedProjectRefCollectionKeyError, Schema.TaggedStruct<"InvalidScopedProjectRefCollectionKeyError", {
|
|
17
|
+
readonly key: Schema.String;
|
|
18
|
+
readonly cause: Schema.Defect;
|
|
19
|
+
}>, import("effect/Cause").YieldableError>;
|
|
20
|
+
declare class InvalidScopedProjectRefCollectionKeyError extends InvalidScopedProjectRefCollectionKeyError_base {
|
|
21
|
+
get message(): string;
|
|
22
|
+
}
|
|
23
|
+
declare function projectKey(ref: ScopedProjectRef): string;
|
|
24
|
+
declare function threadKey(ref: ScopedThreadRef): string;
|
|
25
|
+
declare function projectRefCollectionKey(refs: ReadonlyArray<ScopedProjectRef>): string;
|
|
26
|
+
declare function parseProjectKey(key: string): ScopedProjectRef;
|
|
27
|
+
declare function parseProjectRefCollectionKey(key: string): ReadonlyArray<ScopedProjectRef>;
|
|
28
|
+
declare function parseThreadKey(key: string): ScopedThreadRef;
|
|
29
|
+
declare function projectRefsEqual(left: ReadonlyArray<ScopedProjectRef>, right: ReadonlyArray<ScopedProjectRef>): boolean;
|
|
30
|
+
declare function threadRefsEqual(left: ReadonlyArray<ScopedThreadRef>, right: ReadonlyArray<ScopedThreadRef>): boolean;
|
|
31
|
+
declare function arrayElementsEqual<A>(left: ReadonlyArray<A>, right: ReadonlyArray<A>): boolean;
|
|
32
|
+
//#endregion
|
|
33
|
+
export { InvalidScopedProjectKeyError, InvalidScopedProjectRefCollectionKeyError, InvalidScopedThreadKeyError, arrayElementsEqual, parseProjectKey, parseProjectRefCollectionKey, parseThreadKey, projectKey, projectRefCollectionKey, projectRefsEqual, threadKey, threadRefsEqual };
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { $t as projectRefCollectionKey, Gt as InvalidScopedProjectKeyError, Jt as arrayElementsEqual, Kt as InvalidScopedProjectRefCollectionKeyError, Qt as projectKey, Xt as parseProjectRefCollectionKey, Yt as parseProjectKey, Zt as parseThreadKey, en as projectRefsEqual, nn as threadRefsEqual, qt as InvalidScopedThreadKeyError, tn as threadKey } from "../../shared.js";
|
|
2
|
+
export { InvalidScopedProjectKeyError, InvalidScopedProjectRefCollectionKeyError, InvalidScopedThreadKeyError, arrayElementsEqual, parseProjectKey, parseProjectRefCollectionKey, parseThreadKey, projectKey, projectRefCollectionKey, projectRefsEqual, threadKey, threadRefsEqual };
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { Hx as FilesystemBrowseError, Vx as FilesystemBrowseEntry, Wi as EnvironmentConnectionPhase, bT as EnvironmentAuthorizationError, ha as EnvironmentRegistry, on as EnvironmentRpcUnavailableError, zT as EnvironmentId } from "../../shared.js";
|
|
2
|
+
import { Atom } from "effect/unstable/reactivity";
|
|
3
|
+
//#region upstream-t3code/packages/client-runtime/src/state/filesystem.d.ts
|
|
4
|
+
declare function getFilesystemBrowsePath(query: string, platform?: string, enabled?: boolean): {
|
|
5
|
+
isBrowsing: boolean;
|
|
6
|
+
directoryPath: string;
|
|
7
|
+
filterQuery: string;
|
|
8
|
+
parentPath: string | null;
|
|
9
|
+
canBrowseUp: boolean;
|
|
10
|
+
};
|
|
11
|
+
declare function filterFilesystemBrowseEntries(entries: ReadonlyArray<FilesystemBrowseEntry>, query: string): {
|
|
12
|
+
visibleEntries: {
|
|
13
|
+
readonly name: string;
|
|
14
|
+
readonly fullPath: string;
|
|
15
|
+
}[];
|
|
16
|
+
exactEntry: {
|
|
17
|
+
readonly name: string;
|
|
18
|
+
readonly fullPath: string;
|
|
19
|
+
} | null;
|
|
20
|
+
};
|
|
21
|
+
declare function createBrowseNavigationCoordinator(): {
|
|
22
|
+
invalidate: () => void;
|
|
23
|
+
run: (load: () => Promise<void>, commit: () => void) => Promise<boolean>;
|
|
24
|
+
};
|
|
25
|
+
declare function canPreloadBrowsePath(connectionPhase: EnvironmentConnectionPhase | null | undefined): boolean;
|
|
26
|
+
declare function createFilesystemEnvironmentAtoms<R, E>(runtime: Atom.AtomRuntime<EnvironmentRegistry | R, E>): {
|
|
27
|
+
browse: (target: {
|
|
28
|
+
readonly environmentId: EnvironmentId;
|
|
29
|
+
readonly input: {
|
|
30
|
+
readonly partialPath: string;
|
|
31
|
+
readonly cwd?: string | undefined;
|
|
32
|
+
};
|
|
33
|
+
}) => Atom.Atom<import("effect/unstable/reactivity/AsyncResult").AsyncResult<{
|
|
34
|
+
readonly parentPath: string;
|
|
35
|
+
readonly entries: readonly {
|
|
36
|
+
readonly name: string;
|
|
37
|
+
readonly fullPath: string;
|
|
38
|
+
}[];
|
|
39
|
+
}, E | EnvironmentAuthorizationError | EnvironmentRpcUnavailableError | Error | FilesystemBrowseError | import("effect/unstable/rpc/RpcClientError").RpcClientError>>;
|
|
40
|
+
};
|
|
41
|
+
//#endregion
|
|
42
|
+
export { canPreloadBrowsePath, createBrowseNavigationCoordinator, createFilesystemEnvironmentAtoms, filterFilesystemBrowseEntries, getFilesystemBrowsePath };
|