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,17 @@
|
|
|
1
|
+
import {
|
|
2
|
+
RemoteEnvironmentAuthFetchError,
|
|
3
|
+
type RemoteEnvironmentAuthError,
|
|
4
|
+
RemoteEnvironmentAuthInvalidJsonError,
|
|
5
|
+
RemoteEnvironmentAuthTimeoutError,
|
|
6
|
+
RemoteEnvironmentAuthUndeclaredStatusError,
|
|
7
|
+
} from "@t3tools/client-runtime/authorization";
|
|
8
|
+
import { EnvironmentHttpCommonError } from "@t3tools/contracts";
|
|
9
|
+
import * as Schema from "effect/Schema";
|
|
10
|
+
|
|
11
|
+
export const RemoteEnvironmentAuthErrorSchema = Schema.Union([
|
|
12
|
+
EnvironmentHttpCommonError,
|
|
13
|
+
Schema.instanceOf(RemoteEnvironmentAuthFetchError),
|
|
14
|
+
Schema.instanceOf(RemoteEnvironmentAuthInvalidJsonError),
|
|
15
|
+
Schema.instanceOf(RemoteEnvironmentAuthTimeoutError),
|
|
16
|
+
Schema.instanceOf(RemoteEnvironmentAuthUndeclaredStatusError),
|
|
17
|
+
]) satisfies Schema.Schema<RemoteEnvironmentAuthError>;
|
package/src/auth/service.ts
CHANGED
|
@@ -11,6 +11,7 @@ import type {
|
|
|
11
11
|
AuthUseResult,
|
|
12
12
|
LocalAuthInput,
|
|
13
13
|
LocalAuthResult,
|
|
14
|
+
AuthPairInput,
|
|
14
15
|
PairResult,
|
|
15
16
|
PersistEnvironmentInput,
|
|
16
17
|
} from "./type.ts";
|
|
@@ -18,7 +19,7 @@ import type {
|
|
|
18
19
|
export class T3Auth extends Context.Service<
|
|
19
20
|
T3Auth,
|
|
20
21
|
{
|
|
21
|
-
readonly pair: (
|
|
22
|
+
readonly pair: (input: AuthPairInput) => Effect.Effect<PairResult, AuthError>;
|
|
22
23
|
readonly local: (input: LocalAuthInput) => Effect.Effect<LocalAuthResult, AuthError>;
|
|
23
24
|
readonly writeConfig: (input: AuthConfigInput) => Effect.Effect<void, AuthError>;
|
|
24
25
|
readonly persistEnvironment: (
|
package/src/auth/transport.ts
CHANGED
|
@@ -1,23 +1,20 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
} from "@t3tools/
|
|
2
|
+
bootstrapRemoteBearerSession,
|
|
3
|
+
fetchRemoteSessionState,
|
|
4
|
+
issueRemoteWebSocketTicket,
|
|
5
|
+
} from "@t3tools/client-runtime/authorization";
|
|
6
6
|
import * as Context from "effect/Context";
|
|
7
7
|
import * as DateTime from "effect/DateTime";
|
|
8
8
|
import * as Effect from "effect/Effect";
|
|
9
9
|
import * as Layer from "effect/Layer";
|
|
10
|
-
import { HttpClient
|
|
10
|
+
import { HttpClient } from "effect/unstable/http";
|
|
11
11
|
|
|
12
|
-
import {
|
|
12
|
+
import type { AuthClientPresentationMetadata } from "../contracts/index.ts";
|
|
13
13
|
import { AuthTransportError } from "./error.ts";
|
|
14
14
|
import {
|
|
15
15
|
type AuthBearerBootstrapResult,
|
|
16
|
-
decodeAuthAccessTokenResult,
|
|
17
16
|
type AuthSessionState,
|
|
18
|
-
decodeAuthSessionState,
|
|
19
17
|
type AuthWebSocketTicketResult,
|
|
20
|
-
decodeAuthWebSocketTicketResult,
|
|
21
18
|
} from "./schema.ts";
|
|
22
19
|
|
|
23
20
|
export type AuthTransportConnection = {
|
|
@@ -31,6 +28,7 @@ export class T3AuthTransport extends Context.Service<
|
|
|
31
28
|
readonly bootstrapBearer: (input: {
|
|
32
29
|
readonly baseUrl: string;
|
|
33
30
|
readonly credential: string;
|
|
31
|
+
readonly clientMetadata?: AuthClientPresentationMetadata;
|
|
34
32
|
}) => Effect.Effect<AuthBearerBootstrapResult, AuthTransportError>;
|
|
35
33
|
readonly getSession: (
|
|
36
34
|
connection: AuthTransportConnection,
|
|
@@ -42,53 +40,27 @@ export class T3AuthTransport extends Context.Service<
|
|
|
42
40
|
>()("t3cli/T3AuthTransport") {}
|
|
43
41
|
|
|
44
42
|
const makeT3AuthTransport = Effect.fn("makeT3AuthTransport")(function* () {
|
|
45
|
-
const
|
|
43
|
+
const httpClient = yield* HttpClient.HttpClient;
|
|
46
44
|
|
|
47
45
|
const bootstrapBearer = Effect.fn("AuthTransport.bootstrapBearer")(function* (input: {
|
|
48
46
|
readonly baseUrl: string;
|
|
49
47
|
readonly credential: string;
|
|
48
|
+
readonly clientMetadata?: AuthClientPresentationMetadata;
|
|
50
49
|
}) {
|
|
51
|
-
const
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
);
|
|
61
|
-
const response = yield* client.execute(request).pipe(
|
|
62
|
-
Effect.catchTags({
|
|
63
|
-
HttpClientError: (error) =>
|
|
64
|
-
Effect.fail(
|
|
65
|
-
new AuthTransportError({
|
|
66
|
-
message: "auth request failed",
|
|
67
|
-
cause: HttpClientError.HttpClientErrorSchema.fromHttpClientError(error),
|
|
68
|
-
}),
|
|
69
|
-
),
|
|
70
|
-
}),
|
|
71
|
-
);
|
|
72
|
-
const result = yield* response.json.pipe(
|
|
73
|
-
Effect.flatMap(decodeAuthAccessTokenResult),
|
|
74
|
-
Effect.catchTags({
|
|
75
|
-
HttpClientError: (error) =>
|
|
76
|
-
Effect.fail(
|
|
77
|
-
new AuthTransportError({
|
|
78
|
-
message: "auth request failed",
|
|
79
|
-
cause: HttpClientError.HttpClientErrorSchema.fromHttpClientError(error),
|
|
80
|
-
}),
|
|
81
|
-
),
|
|
82
|
-
SchemaError: (error) =>
|
|
83
|
-
Effect.fail(
|
|
84
|
-
new AuthTransportError({ message: "auth response decode failed", cause: error }),
|
|
85
|
-
),
|
|
86
|
-
}),
|
|
50
|
+
const result = yield* bootstrapRemoteBearerSession({
|
|
51
|
+
httpBaseUrl: input.baseUrl,
|
|
52
|
+
credential: input.credential,
|
|
53
|
+
...(input.clientMetadata !== undefined ? { clientMetadata: input.clientMetadata } : {}),
|
|
54
|
+
}).pipe(
|
|
55
|
+
Effect.provideService(HttpClient.HttpClient, httpClient),
|
|
56
|
+
Effect.mapError(
|
|
57
|
+
(error) => new AuthTransportError({ message: "auth request failed", cause: error }),
|
|
58
|
+
),
|
|
87
59
|
);
|
|
88
60
|
const now = yield* DateTime.now;
|
|
89
61
|
return {
|
|
90
62
|
authenticated: true,
|
|
91
|
-
role: result.scope
|
|
63
|
+
role: inferRole(result.scope),
|
|
92
64
|
sessionMethod: "bearer-access-token",
|
|
93
65
|
expiresAt: DateTime.formatIso(DateTime.add(now, { seconds: result.expires_in })),
|
|
94
66
|
sessionToken: result.access_token,
|
|
@@ -98,69 +70,41 @@ const makeT3AuthTransport = Effect.fn("makeT3AuthTransport")(function* () {
|
|
|
98
70
|
const getSession = Effect.fn("AuthTransport.getSession")(function* (
|
|
99
71
|
connection: AuthTransportConnection,
|
|
100
72
|
) {
|
|
101
|
-
const
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
cause: HttpClientError.HttpClientErrorSchema.fromHttpClientError(error),
|
|
110
|
-
}),
|
|
111
|
-
),
|
|
112
|
-
}),
|
|
113
|
-
);
|
|
114
|
-
return yield* response.json.pipe(
|
|
115
|
-
Effect.flatMap(decodeAuthSessionState),
|
|
116
|
-
Effect.catchTags({
|
|
117
|
-
HttpClientError: (error) =>
|
|
118
|
-
Effect.fail(
|
|
119
|
-
new AuthTransportError({
|
|
120
|
-
message: "auth request failed",
|
|
121
|
-
cause: HttpClientError.HttpClientErrorSchema.fromHttpClientError(error),
|
|
122
|
-
}),
|
|
123
|
-
),
|
|
124
|
-
SchemaError: (error) =>
|
|
125
|
-
Effect.fail(
|
|
126
|
-
new AuthTransportError({ message: "auth response decode failed", cause: error }),
|
|
127
|
-
),
|
|
128
|
-
}),
|
|
73
|
+
const result = yield* fetchRemoteSessionState({
|
|
74
|
+
httpBaseUrl: connection.url,
|
|
75
|
+
bearerToken: connection.token,
|
|
76
|
+
}).pipe(
|
|
77
|
+
Effect.provideService(HttpClient.HttpClient, httpClient),
|
|
78
|
+
Effect.mapError(
|
|
79
|
+
(error) => new AuthTransportError({ message: "auth request failed", cause: error }),
|
|
80
|
+
),
|
|
129
81
|
);
|
|
82
|
+
return {
|
|
83
|
+
authenticated: result.authenticated,
|
|
84
|
+
...(result.scopes !== undefined ? { role: inferRole(result.scopes.join(" ")) } : {}),
|
|
85
|
+
...(result.sessionMethod !== undefined ? { sessionMethod: result.sessionMethod } : {}),
|
|
86
|
+
...(result.expiresAt !== undefined
|
|
87
|
+
? { expiresAt: DateTime.formatIso(result.expiresAt) }
|
|
88
|
+
: {}),
|
|
89
|
+
} satisfies AuthSessionState;
|
|
130
90
|
});
|
|
131
91
|
|
|
132
92
|
const issueWebSocketTicket = Effect.fn("AuthTransport.issueWebSocketTicket")(function* (
|
|
133
93
|
connection: AuthTransportConnection,
|
|
134
94
|
) {
|
|
135
|
-
const
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
cause: HttpClientError.HttpClientErrorSchema.fromHttpClientError(error),
|
|
144
|
-
}),
|
|
145
|
-
),
|
|
146
|
-
}),
|
|
147
|
-
);
|
|
148
|
-
return yield* response.json.pipe(
|
|
149
|
-
Effect.flatMap(decodeAuthWebSocketTicketResult),
|
|
150
|
-
Effect.catchTags({
|
|
151
|
-
HttpClientError: (error) =>
|
|
152
|
-
Effect.fail(
|
|
153
|
-
new AuthTransportError({
|
|
154
|
-
message: "auth request failed",
|
|
155
|
-
cause: HttpClientError.HttpClientErrorSchema.fromHttpClientError(error),
|
|
156
|
-
}),
|
|
157
|
-
),
|
|
158
|
-
SchemaError: (error) =>
|
|
159
|
-
Effect.fail(
|
|
160
|
-
new AuthTransportError({ message: "auth response decode failed", cause: error }),
|
|
161
|
-
),
|
|
162
|
-
}),
|
|
95
|
+
const result = yield* issueRemoteWebSocketTicket({
|
|
96
|
+
httpBaseUrl: connection.url,
|
|
97
|
+
bearerToken: connection.token,
|
|
98
|
+
}).pipe(
|
|
99
|
+
Effect.provideService(HttpClient.HttpClient, httpClient),
|
|
100
|
+
Effect.mapError(
|
|
101
|
+
(error) => new AuthTransportError({ message: "auth request failed", cause: error }),
|
|
102
|
+
),
|
|
163
103
|
);
|
|
104
|
+
return {
|
|
105
|
+
ticket: result.ticket,
|
|
106
|
+
expiresAt: DateTime.formatIso(result.expiresAt),
|
|
107
|
+
} satisfies AuthWebSocketTicketResult;
|
|
164
108
|
});
|
|
165
109
|
|
|
166
110
|
return {
|
|
@@ -172,15 +116,6 @@ const makeT3AuthTransport = Effect.fn("makeT3AuthTransport")(function* () {
|
|
|
172
116
|
|
|
173
117
|
export const T3AuthTransportLive = Layer.effect(T3AuthTransport, makeT3AuthTransport());
|
|
174
118
|
|
|
175
|
-
|
|
176
|
-
(
|
|
177
|
-
request.pipe(HttpClientRequest.acceptJson, HttpClientRequest.bearerToken(connection.token));
|
|
178
|
-
|
|
179
|
-
function makeHttpEndpointUrl(baseUrl: string, path: string) {
|
|
180
|
-
return toHttpEndpointUrl(baseUrl, path).pipe(
|
|
181
|
-
Effect.catchTags({
|
|
182
|
-
UrlError: (error) =>
|
|
183
|
-
Effect.fail(new AuthTransportError({ message: "auth request failed", cause: error })),
|
|
184
|
-
}),
|
|
185
|
-
);
|
|
119
|
+
function inferRole(scope: string): AuthBearerBootstrapResult["role"] {
|
|
120
|
+
return scope.split(/\s+/u).includes("access:write") ? "owner" : "client";
|
|
186
121
|
}
|
package/src/auth/type.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { AuthClientPresentationMetadata } from "../contracts/index.ts";
|
|
1
2
|
import type { AuthBearerBootstrapResult } from "./schema.ts";
|
|
2
3
|
import type { AuthSessionState } from "./schema.ts";
|
|
3
4
|
|
|
@@ -8,6 +9,11 @@ export type PairingUrl = {
|
|
|
8
9
|
readonly credential: string;
|
|
9
10
|
};
|
|
10
11
|
|
|
12
|
+
export interface AuthPairInput {
|
|
13
|
+
readonly pairingUrl: string;
|
|
14
|
+
readonly clientMetadata?: AuthClientPresentationMetadata;
|
|
15
|
+
}
|
|
16
|
+
|
|
11
17
|
export type AuthConfigInput = {
|
|
12
18
|
readonly name: string;
|
|
13
19
|
readonly url: string;
|
package/src/cli/auth.ts
CHANGED
|
@@ -75,7 +75,13 @@ const pairCommand = Command.make(
|
|
|
75
75
|
const t3CliEnv = yield* loadT3CliEnv;
|
|
76
76
|
const output = yield* T3Output;
|
|
77
77
|
const resolvedFormat = resolveOutputFormat(format, cliRuntime, t3CliEnv, "json");
|
|
78
|
-
const result = yield* auth.pair(
|
|
78
|
+
const result = yield* auth.pair({
|
|
79
|
+
pairingUrl: url,
|
|
80
|
+
clientMetadata: {
|
|
81
|
+
label: "t3cli",
|
|
82
|
+
deviceType: "bot",
|
|
83
|
+
},
|
|
84
|
+
});
|
|
79
85
|
const fallbackName = yield* auth.defaultNameFromUrl(result.url);
|
|
80
86
|
const environmentName = yield* persistAuthEnvironment({
|
|
81
87
|
explicitName: name,
|
package/src/connection/error.ts
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
import * as Schema from "effect/Schema";
|
|
2
2
|
|
|
3
|
+
import { ConfigError } from "../config/error.ts";
|
|
4
|
+
import { UrlError } from "../config/url/error.ts";
|
|
5
|
+
|
|
3
6
|
export class T3CodeConnectionError extends Schema.TaggedErrorClass<T3CodeConnectionError>()(
|
|
4
7
|
"T3CodeConnectionError",
|
|
5
8
|
{
|
|
6
9
|
message: Schema.String,
|
|
7
|
-
cause: Schema.
|
|
10
|
+
cause: Schema.Union([ConfigError, UrlError]),
|
|
8
11
|
},
|
|
9
12
|
) {}
|
package/src/connection/layer.ts
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
import * as Layer from "effect/Layer";
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import { T3PreparedConnectionProviderLive } from "./prepared.ts";
|
|
4
4
|
import { T3RpcLive } from "../rpc/layer.ts";
|
|
5
|
+
import { T3RpcSessionFactoryLive } from "../rpc/session.ts";
|
|
5
6
|
|
|
6
7
|
export function makeT3CodeRpcLayer() {
|
|
7
|
-
return T3RpcLive.pipe(
|
|
8
|
+
return T3RpcLive.pipe(
|
|
9
|
+
Layer.provide(Layer.mergeAll(T3PreparedConnectionProviderLive, T3RpcSessionFactoryLive)),
|
|
10
|
+
);
|
|
8
11
|
}
|
|
9
12
|
|
|
10
13
|
export const T3CodeRpcLayer = makeT3CodeRpcLayer();
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { resolveRemoteWebSocketConnectionUrl } from "@t3tools/client-runtime/authorization";
|
|
2
|
+
import {
|
|
3
|
+
BearerConnectionTarget,
|
|
4
|
+
type ConnectionAttemptError,
|
|
5
|
+
mapRemoteEnvironmentError,
|
|
6
|
+
type PreparedConnection,
|
|
7
|
+
} from "@t3tools/client-runtime/connection";
|
|
8
|
+
import { fetchRemoteEnvironmentDescriptor } from "@t3tools/client-runtime/environment";
|
|
9
|
+
import * as Context from "effect/Context";
|
|
10
|
+
import * as Effect from "effect/Effect";
|
|
11
|
+
import * as Layer from "effect/Layer";
|
|
12
|
+
import { HttpClient } from "effect/unstable/http";
|
|
13
|
+
|
|
14
|
+
import { toWebSocketEndpointUrl } from "../config/url/url.ts";
|
|
15
|
+
import { T3CodeConnectionError } from "./error.ts";
|
|
16
|
+
import { T3CodeConnectionProvider } from "./service.ts";
|
|
17
|
+
import type { T3CodeConnection } from "./type.ts";
|
|
18
|
+
|
|
19
|
+
export class T3PreparedConnectionProvider extends Context.Service<
|
|
20
|
+
T3PreparedConnectionProvider,
|
|
21
|
+
{
|
|
22
|
+
readonly get: Effect.Effect<PreparedConnection, ConnectionAttemptError | T3CodeConnectionError>;
|
|
23
|
+
}
|
|
24
|
+
>()("t3cli/T3PreparedConnectionProvider") {}
|
|
25
|
+
|
|
26
|
+
const makePreparedConnection = Effect.fn("makePreparedConnection")(function* (
|
|
27
|
+
connection: T3CodeConnection,
|
|
28
|
+
) {
|
|
29
|
+
const httpBaseUrl = connection.origin.url;
|
|
30
|
+
const wsBaseUrl = yield* toWebSocketEndpointUrl(httpBaseUrl, "/ws").pipe(
|
|
31
|
+
Effect.mapError(
|
|
32
|
+
(error) =>
|
|
33
|
+
new T3CodeConnectionError({
|
|
34
|
+
message: "failed to resolve websocket endpoint",
|
|
35
|
+
cause: error,
|
|
36
|
+
}),
|
|
37
|
+
),
|
|
38
|
+
);
|
|
39
|
+
const descriptor = yield* fetchRemoteEnvironmentDescriptor({ httpBaseUrl }).pipe(
|
|
40
|
+
Effect.mapError(mapRemoteEnvironmentError),
|
|
41
|
+
);
|
|
42
|
+
const socketUrl = yield* resolveRemoteWebSocketConnectionUrl({
|
|
43
|
+
httpBaseUrl,
|
|
44
|
+
wsBaseUrl,
|
|
45
|
+
bearerToken: connection.auth.token,
|
|
46
|
+
}).pipe(Effect.mapError(mapRemoteEnvironmentError));
|
|
47
|
+
|
|
48
|
+
return {
|
|
49
|
+
environmentId: descriptor.environmentId,
|
|
50
|
+
label: descriptor.label,
|
|
51
|
+
httpBaseUrl,
|
|
52
|
+
socketUrl,
|
|
53
|
+
httpAuthorization: {
|
|
54
|
+
_tag: "Bearer",
|
|
55
|
+
token: connection.auth.token,
|
|
56
|
+
},
|
|
57
|
+
target: new BearerConnectionTarget({
|
|
58
|
+
environmentId: descriptor.environmentId,
|
|
59
|
+
label: descriptor.label,
|
|
60
|
+
connectionId: descriptor.environmentId,
|
|
61
|
+
}),
|
|
62
|
+
} satisfies PreparedConnection;
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
const makeT3PreparedConnectionProvider = Effect.fn("makeT3PreparedConnectionProvider")(
|
|
66
|
+
function* () {
|
|
67
|
+
const connectionProvider = yield* T3CodeConnectionProvider;
|
|
68
|
+
const httpClient = yield* HttpClient.HttpClient;
|
|
69
|
+
const get = connectionProvider.get.pipe(
|
|
70
|
+
Effect.flatMap((connection) =>
|
|
71
|
+
makePreparedConnection(connection).pipe(
|
|
72
|
+
Effect.provideService(HttpClient.HttpClient, httpClient),
|
|
73
|
+
),
|
|
74
|
+
),
|
|
75
|
+
);
|
|
76
|
+
return T3PreparedConnectionProvider.of({ get });
|
|
77
|
+
},
|
|
78
|
+
);
|
|
79
|
+
|
|
80
|
+
export const T3PreparedConnectionProviderLive = Layer.effect(
|
|
81
|
+
T3PreparedConnectionProvider,
|
|
82
|
+
makeT3PreparedConnectionProvider(),
|
|
83
|
+
);
|
package/src/contracts/index.ts
CHANGED
|
@@ -1,8 +1,16 @@
|
|
|
1
1
|
export type {
|
|
2
|
+
AuthClientPresentationMetadata,
|
|
2
3
|
OrchestrationMessage,
|
|
3
4
|
OrchestrationProjectShell,
|
|
4
5
|
OrchestrationShellSnapshot,
|
|
5
6
|
OrchestrationThread,
|
|
6
7
|
OrchestrationThreadShell,
|
|
8
|
+
PreviewAutomationHost,
|
|
9
|
+
PreviewAutomationHostFocus,
|
|
10
|
+
PreviewAutomationResizeInput,
|
|
11
|
+
PreviewAutomationResponse,
|
|
12
|
+
PreviewAutomationStreamEvent,
|
|
13
|
+
PreviewViewportPresetId,
|
|
7
14
|
ServerProvider,
|
|
8
15
|
} from "@t3tools/contracts";
|
|
16
|
+
export { PREVIEW_VIEWPORT_PRESET_IDS, PreviewViewportSetting } from "@t3tools/contracts";
|
|
@@ -8,9 +8,11 @@ import {
|
|
|
8
8
|
ThreadId,
|
|
9
9
|
WS_METHODS,
|
|
10
10
|
type ClientOrchestrationCommand,
|
|
11
|
+
type OrchestrationShellSnapshot,
|
|
11
12
|
type OrchestrationShellStreamItem,
|
|
12
13
|
type OrchestrationThreadStreamItem,
|
|
13
14
|
} from "@t3tools/contracts";
|
|
15
|
+
import { applyShellStreamEvent } from "@t3tools/client-runtime/state/shell";
|
|
14
16
|
|
|
15
17
|
import { RpcError } from "../rpc/error.ts";
|
|
16
18
|
import { T3RpcOperations } from "../rpc/operation.ts";
|
|
@@ -19,13 +21,47 @@ import { T3Orchestration, type OpenThread, type Orchestration } from "./service.
|
|
|
19
21
|
export const makeT3Orchestration = Effect.fn("makeT3Orchestration")(function* () {
|
|
20
22
|
const rpc = yield* T3RpcOperations;
|
|
21
23
|
|
|
24
|
+
const watchShellSnapshots: Orchestration["watchShellSnapshots"] = () =>
|
|
25
|
+
rpc
|
|
26
|
+
.subscribe(ORCHESTRATION_WS_METHODS.subscribeShell, (client) =>
|
|
27
|
+
client[ORCHESTRATION_WS_METHODS.subscribeShell]({}),
|
|
28
|
+
)
|
|
29
|
+
.pipe(
|
|
30
|
+
Stream.filter(
|
|
31
|
+
(
|
|
32
|
+
item,
|
|
33
|
+
): item is Exclude<OrchestrationShellStreamItem, { readonly kind: "synchronized" }> =>
|
|
34
|
+
item.kind !== "synchronized",
|
|
35
|
+
),
|
|
36
|
+
Stream.mapAccum(
|
|
37
|
+
() => Option.none<OrchestrationShellSnapshot>(),
|
|
38
|
+
(
|
|
39
|
+
current,
|
|
40
|
+
item,
|
|
41
|
+
): readonly [
|
|
42
|
+
Option.Option<OrchestrationShellSnapshot>,
|
|
43
|
+
ReadonlyArray<OrchestrationShellSnapshot>,
|
|
44
|
+
] => {
|
|
45
|
+
if (item.kind === "snapshot") {
|
|
46
|
+
return [Option.some(item.snapshot), [item.snapshot]];
|
|
47
|
+
}
|
|
48
|
+
if (Option.isNone(current)) {
|
|
49
|
+
return [current, []];
|
|
50
|
+
}
|
|
51
|
+
const next = applyShellStreamEvent(current.value, item);
|
|
52
|
+
return [Option.some(next), [next]];
|
|
53
|
+
},
|
|
54
|
+
),
|
|
55
|
+
);
|
|
56
|
+
|
|
22
57
|
const watchShellSequence: Orchestration["watchShellSequence"] = () =>
|
|
23
58
|
rpc
|
|
24
59
|
.subscribe(ORCHESTRATION_WS_METHODS.subscribeShell, (client) =>
|
|
25
60
|
client[ORCHESTRATION_WS_METHODS.subscribeShell]({}),
|
|
26
61
|
)
|
|
27
62
|
.pipe(
|
|
28
|
-
Stream.
|
|
63
|
+
Stream.filter((item: OrchestrationShellStreamItem) => item.kind !== "synchronized"),
|
|
64
|
+
Stream.map((item) =>
|
|
29
65
|
item.kind === "snapshot" ? item.snapshot.snapshotSequence : item.sequence,
|
|
30
66
|
),
|
|
31
67
|
);
|
|
@@ -125,6 +161,7 @@ export const makeT3Orchestration = Effect.fn("makeT3Orchestration")(function* ()
|
|
|
125
161
|
getShellSnapshot,
|
|
126
162
|
getArchivedShellSnapshot,
|
|
127
163
|
getThreadSnapshot,
|
|
164
|
+
watchShellSnapshots,
|
|
128
165
|
watchShellSequence,
|
|
129
166
|
watchThreadItems,
|
|
130
167
|
openThread,
|
|
@@ -38,6 +38,11 @@ export type Orchestration = {
|
|
|
38
38
|
readonly getThreadSnapshot: (
|
|
39
39
|
threadId: string,
|
|
40
40
|
) => Effect.Effect<OrchestrationThread, OrchestrationError>;
|
|
41
|
+
readonly watchShellSnapshots: () => Stream.Stream<
|
|
42
|
+
OrchestrationShellSnapshot,
|
|
43
|
+
OrchestrationError,
|
|
44
|
+
Scope.Scope
|
|
45
|
+
>;
|
|
41
46
|
readonly watchShellSequence: () => Stream.Stream<number, OrchestrationError, Scope.Scope>;
|
|
42
47
|
readonly watchThreadItems: (
|
|
43
48
|
threadId: string,
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export {
|
|
2
|
+
T3PreviewAutomation,
|
|
3
|
+
T3PreviewAutomationLive,
|
|
4
|
+
makeT3PreviewAutomation,
|
|
5
|
+
} from "./service.ts";
|
|
6
|
+
export type {
|
|
7
|
+
PreviewAutomationHost,
|
|
8
|
+
PreviewAutomationHostFocus,
|
|
9
|
+
PreviewAutomationResponse,
|
|
10
|
+
PreviewAutomationStreamEvent,
|
|
11
|
+
} from "../contracts/index.ts";
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { WS_METHODS } from "@t3tools/contracts";
|
|
2
|
+
import * as Context from "effect/Context";
|
|
3
|
+
import * as Effect from "effect/Effect";
|
|
4
|
+
import * as Layer from "effect/Layer";
|
|
5
|
+
import type * as Stream from "effect/Stream";
|
|
6
|
+
|
|
7
|
+
import type {
|
|
8
|
+
PreviewAutomationHost,
|
|
9
|
+
PreviewAutomationHostFocus,
|
|
10
|
+
PreviewAutomationResponse,
|
|
11
|
+
PreviewAutomationStreamEvent,
|
|
12
|
+
} from "../contracts/index.ts";
|
|
13
|
+
import type { RpcError } from "../rpc/error.ts";
|
|
14
|
+
import { T3RpcOperations } from "../rpc/operation.ts";
|
|
15
|
+
|
|
16
|
+
export class T3PreviewAutomation extends Context.Service<
|
|
17
|
+
T3PreviewAutomation,
|
|
18
|
+
{
|
|
19
|
+
readonly connect: (
|
|
20
|
+
host: PreviewAutomationHost,
|
|
21
|
+
) => Stream.Stream<PreviewAutomationStreamEvent, RpcError>;
|
|
22
|
+
readonly respond: (response: PreviewAutomationResponse) => Effect.Effect<void, RpcError>;
|
|
23
|
+
readonly focusHost: (input: PreviewAutomationHostFocus) => Effect.Effect<void, RpcError>;
|
|
24
|
+
}
|
|
25
|
+
>()("t3cli/T3PreviewAutomation") {}
|
|
26
|
+
|
|
27
|
+
export const makeT3PreviewAutomation = Effect.fn("makeT3PreviewAutomation")(function* () {
|
|
28
|
+
const rpc = yield* T3RpcOperations;
|
|
29
|
+
|
|
30
|
+
const connect: T3PreviewAutomation["Service"]["connect"] = (host) =>
|
|
31
|
+
rpc.subscribe(WS_METHODS.previewAutomationConnect, (client) =>
|
|
32
|
+
client[WS_METHODS.previewAutomationConnect](host),
|
|
33
|
+
);
|
|
34
|
+
const respond = Effect.fn("T3PreviewAutomation.respond")(function* (
|
|
35
|
+
response: PreviewAutomationResponse,
|
|
36
|
+
) {
|
|
37
|
+
return yield* rpc.run(WS_METHODS.previewAutomationRespond, (client) =>
|
|
38
|
+
client[WS_METHODS.previewAutomationRespond](response),
|
|
39
|
+
);
|
|
40
|
+
});
|
|
41
|
+
const focusHost = Effect.fn("T3PreviewAutomation.focusHost")(function* (
|
|
42
|
+
input: PreviewAutomationHostFocus,
|
|
43
|
+
) {
|
|
44
|
+
return yield* rpc.run(WS_METHODS.previewAutomationFocusHost, (client) =>
|
|
45
|
+
client[WS_METHODS.previewAutomationFocusHost](input),
|
|
46
|
+
);
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
return T3PreviewAutomation.of({ connect, respond, focusHost });
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
export const T3PreviewAutomationLive = Layer.effect(T3PreviewAutomation, makeT3PreviewAutomation());
|
package/src/rpc/error.ts
CHANGED
|
@@ -1,21 +1,20 @@
|
|
|
1
|
-
import
|
|
1
|
+
import {
|
|
2
|
+
ConnectionBlockedError,
|
|
3
|
+
ConnectionTransientError,
|
|
4
|
+
} from "@t3tools/client-runtime/connection";
|
|
2
5
|
import {
|
|
3
6
|
EnvironmentAuthorizationError,
|
|
4
7
|
KeybindingsConfigError,
|
|
5
8
|
OrchestrationDispatchCommandError,
|
|
6
9
|
OrchestrationGetSnapshotError,
|
|
10
|
+
PreviewAutomationError,
|
|
7
11
|
ServerSettingsError,
|
|
8
|
-
|
|
9
|
-
TerminalHistoryError,
|
|
10
|
-
TerminalNotRunningError,
|
|
11
|
-
TerminalSessionLookupError,
|
|
12
|
+
TerminalError,
|
|
12
13
|
} from "@t3tools/contracts";
|
|
13
|
-
import
|
|
14
|
+
import * as Schema from "effect/Schema";
|
|
14
15
|
import { RpcClientError } from "effect/unstable/rpc";
|
|
15
16
|
|
|
16
|
-
import { AuthTransportError } from "../auth/error.ts";
|
|
17
17
|
import { T3CodeConnectionError } from "../connection/error.ts";
|
|
18
|
-
import { UrlError } from "../config/url/error.ts";
|
|
19
18
|
|
|
20
19
|
const RpcErrorCauseSchema = Schema.Union([
|
|
21
20
|
RpcClientError.RpcClientError,
|
|
@@ -23,16 +22,12 @@ const RpcErrorCauseSchema = Schema.Union([
|
|
|
23
22
|
KeybindingsConfigError,
|
|
24
23
|
OrchestrationDispatchCommandError,
|
|
25
24
|
OrchestrationGetSnapshotError,
|
|
25
|
+
PreviewAutomationError,
|
|
26
26
|
ServerSettingsError,
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
TerminalSessionLookupError,
|
|
31
|
-
AuthTransportError,
|
|
27
|
+
TerminalError,
|
|
28
|
+
ConnectionBlockedError,
|
|
29
|
+
ConnectionTransientError,
|
|
32
30
|
T3CodeConnectionError,
|
|
33
|
-
HttpClientError.HttpClientErrorSchema,
|
|
34
|
-
UrlError,
|
|
35
|
-
Schema.instanceOf(Schema.SchemaError),
|
|
36
31
|
]);
|
|
37
32
|
|
|
38
33
|
export type RpcKnownCause = Schema.Schema.Type<typeof RpcErrorCauseSchema>;
|
package/src/rpc/index.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
export { RpcError } from "./error.ts";
|
|
1
|
+
export { RpcError, type OrchestrationError } from "./error.ts";
|
|
2
2
|
export { makeT3RpcLayer, T3RpcLive } from "./layer.ts";
|
|
3
3
|
export { T3RpcOperations, T3RpcOperationsLive, makeT3RpcOperations } from "./operation.ts";
|
|
4
|
+
export type { T3RpcOperationsService } from "./operation.ts";
|
|
4
5
|
export { T3Rpc } from "./service.ts";
|
|
5
|
-
export type { WsClient } from "./service.ts";
|
|
6
|
+
export type { T3RpcService, WsClient } from "./service.ts";
|