t3code-cli 0.10.0 → 0.12.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 +75 -11
- package/dist/application.js +2 -2
- package/dist/auth.js +1 -1
- package/dist/bin.js +86754 -2675
- package/dist/cli.js +15 -2
- package/dist/config.js +120 -2
- package/dist/connection.js +2 -12
- package/dist/index.js +1 -1
- package/dist/node.js +6 -0
- package/dist/orchestration.js +2 -2
- package/dist/rpc.js +2 -2
- package/dist/runtime.js +2 -2
- package/dist/shared.js +43850 -38040
- package/dist/src/application/actions.d.ts +25 -0
- package/dist/src/application/index.d.ts +3 -2
- package/dist/src/application/layer.d.ts +99 -842
- package/dist/src/application/model-selection.d.ts +17 -2
- package/dist/src/application/models.d.ts +1 -87
- package/dist/src/application/project-commands.d.ts +31 -2
- package/dist/src/application/projects.d.ts +15 -137
- package/dist/src/application/service.d.ts +147 -5
- package/dist/src/application/shell-sequence.d.ts +5 -4
- package/dist/src/application/terminals.d.ts +66 -0
- package/dist/src/application/thread-commands.d.ts +48 -1
- package/dist/src/application/thread-update.d.ts +8 -0
- package/dist/src/application/thread-wait.d.ts +4 -6
- package/dist/src/application/threads.d.ts +36 -14
- package/dist/src/auth/error.d.ts +2 -1
- package/dist/src/auth/index.d.ts +1 -1
- package/dist/src/auth/layer.d.ts +34 -6
- package/dist/src/auth/local-base-dir.d.ts +5 -2
- package/dist/src/auth/local-origin.d.ts +3 -3
- package/dist/src/auth/local-token.d.ts +3 -3
- package/dist/src/auth/service.d.ts +15 -3
- package/dist/src/auth/type.d.ts +40 -1
- package/dist/src/cli/env/flag.d.ts +2 -0
- package/dist/src/cli/env/index.d.ts +2 -0
- package/dist/src/cli/env/selection-layer.d.ts +3 -0
- package/dist/src/cli/flags.d.ts +5 -0
- package/dist/src/cli/format/index.d.ts +1 -0
- package/dist/src/cli/format/output.d.ts +12 -0
- package/dist/src/cli/index.d.ts +4 -0
- package/dist/src/cli/runtime/index.d.ts +1 -0
- package/dist/src/cli/runtime/service.d.ts +16 -0
- package/dist/src/{scope → cli/scope}/resolve.d.ts +5 -4
- package/dist/src/config/config.d.ts +49 -0
- package/dist/src/config/credential/cipher-node.d.ts +3 -0
- package/dist/src/config/credential/cipher-web.d.ts +3 -0
- package/dist/src/config/credential/cipher.d.ts +29 -0
- package/dist/src/config/credential/env.d.ts +3 -0
- package/dist/src/config/credential/error.d.ts +8 -0
- package/dist/src/config/credential/index.d.ts +6 -0
- package/dist/src/config/credential/service.d.ts +34 -0
- package/dist/src/config/env/env.d.ts +55 -0
- package/dist/src/config/env/index.d.ts +2 -0
- package/dist/src/{layout/base-dir.d.ts → config/env/layout.d.ts} +0 -1
- package/dist/src/config/environment-name/index.d.ts +1 -0
- package/dist/src/config/environment-name/name.d.ts +10 -0
- package/dist/src/config/error.d.ts +4 -11
- package/dist/src/config/index.d.ts +10 -5
- package/dist/src/config/keystore/error.d.ts +8 -0
- package/dist/src/config/keystore/file.d.ts +9 -0
- package/dist/src/config/keystore/index.d.ts +4 -0
- package/dist/src/config/keystore/keyring-node.d.ts +4 -0
- package/dist/src/config/keystore/service.d.ts +33 -0
- package/dist/src/config/paths/index.d.ts +1 -0
- package/dist/src/config/paths/paths.d.ts +6 -0
- package/dist/src/config/persist/file-mode.d.ts +4 -0
- package/dist/src/config/persist/migration.d.ts +68 -0
- package/dist/src/config/persist/persist.d.ts +40 -0
- package/dist/src/config/persist/schema.d.ts +68 -0
- package/dist/src/config/resolve/resolve.d.ts +40 -0
- package/dist/src/config/selection/index.d.ts +1 -0
- package/dist/src/config/selection/resolve.d.ts +4 -0
- package/dist/src/config/selection/service.d.ts +10 -0
- package/dist/src/config/types.d.ts +36 -0
- package/dist/src/config/url/error.d.ts +10 -0
- package/dist/src/config/url/index.d.ts +2 -0
- package/dist/src/connection/index.d.ts +0 -1
- package/dist/src/contracts/index.d.ts +1 -1
- package/dist/src/domain/error.d.ts +27 -1
- package/dist/src/domain/helpers.d.ts +8 -2
- package/dist/src/domain/model-config.d.ts +30 -1
- package/dist/src/domain/thread-activities.d.ts +1 -1
- package/dist/src/domain/thread-lifecycle.d.ts +3 -2
- package/dist/src/index.d.ts +1 -2
- package/dist/src/{connection/node.d.ts → node/connection.d.ts} +1 -1
- package/dist/src/node/index.d.ts +1 -0
- package/dist/src/orchestration/index.d.ts +1 -1
- package/dist/src/orchestration/layer.d.ts +120 -829
- package/dist/src/orchestration/service.d.ts +2 -1
- package/dist/src/rpc/error.d.ts +5 -3
- package/dist/src/rpc/index.d.ts +5 -1
- package/dist/src/rpc/layer.d.ts +1166 -40
- package/dist/src/rpc/operation.d.ts +6280 -0
- package/dist/src/rpc/ws-group.d.ts +372 -27
- package/dist/src/runtime/index.d.ts +1 -2
- package/dist/src/runtime/layer.d.ts +12 -8
- package/dist/src/t3tools/index.d.ts +1 -1
- package/dist/t3tools.js +2 -2
- package/package.json +27 -19
- package/src/application/actions.test.ts +328 -0
- package/src/application/actions.ts +475 -0
- package/src/application/index.ts +32 -2
- package/src/application/layer.ts +43 -5
- package/src/application/model-selection.ts +70 -4
- package/src/application/models.ts +14 -14
- package/src/application/project-commands.ts +38 -5
- package/src/application/projects.ts +49 -20
- package/src/application/service.ts +275 -78
- package/src/application/shell-sequence.ts +6 -8
- package/src/application/terminals.ts +208 -0
- package/src/application/thread-commands.test.ts +43 -0
- package/src/application/thread-commands.ts +82 -1
- package/src/application/thread-update.ts +72 -0
- package/src/application/thread-wait.ts +47 -48
- package/src/application/threads.test.ts +172 -0
- package/src/application/threads.ts +128 -45
- package/src/auth/error.ts +2 -1
- package/src/auth/index.ts +7 -0
- package/src/auth/layer.test-utils.ts +34 -0
- package/src/auth/layer.ts +116 -34
- package/src/auth/local-base-dir.ts +13 -6
- package/src/auth/local-origin.ts +10 -7
- package/src/auth/local-token.ts +28 -23
- package/src/auth/service.test.ts +200 -0
- package/src/auth/service.ts +27 -3
- package/src/auth/transport.ts +2 -2
- package/src/auth/type.ts +47 -1
- package/src/bin.ts +26 -6
- package/src/cli/action-format.ts +110 -0
- package/src/cli/action.ts +398 -0
- package/src/cli/app.ts +8 -0
- package/src/cli/auth.ts +76 -23
- package/src/cli/env/flag.ts +8 -0
- package/src/cli/env/index.ts +2 -0
- package/src/cli/env/selection-layer.test.ts +49 -0
- package/src/cli/env/selection-layer.ts +27 -0
- package/src/cli/env.ts +107 -0
- package/src/cli/error.ts +26 -3
- package/src/cli/extra-args.test.ts +32 -0
- package/src/cli/extra-args.ts +22 -0
- package/src/cli/flags.ts +26 -1
- package/src/cli/format/auth.ts +92 -0
- package/src/cli/format/human.ts +131 -0
- package/src/cli/format/index.ts +12 -0
- package/src/cli/format/model.ts +29 -0
- package/src/cli/format/output.ts +51 -0
- package/src/cli/format/project.ts +32 -0
- package/src/cli/format/terminal.ts +87 -0
- package/src/cli/format/thread.test.ts +34 -0
- package/src/cli/format/thread.ts +185 -0
- package/src/cli/index.ts +20 -0
- package/src/cli/input/layer.ts +20 -0
- package/src/cli/input/service.ts +1 -0
- package/src/cli/interaction/confirm.ts +64 -0
- package/src/cli/interaction/self-action.ts +36 -0
- package/src/cli/message-input.ts +1 -1
- package/src/cli/model.ts +9 -5
- package/src/cli/project.ts +15 -8
- package/src/cli/projects/delete.ts +51 -0
- package/src/cli/require.ts +9 -7
- package/src/cli/runtime/index.ts +1 -0
- package/src/cli/runtime/service.ts +28 -0
- package/src/{scope → cli/scope}/resolve.ts +11 -9
- package/src/cli/terminal/attach.ts +29 -0
- package/src/cli/terminal/create.ts +55 -0
- package/src/cli/terminal/destroy.ts +62 -0
- package/src/cli/terminal/encoding.test.ts +63 -0
- package/src/cli/terminal/encoding.ts +23 -0
- package/src/cli/terminal/error.ts +14 -0
- package/src/cli/terminal/io-node-layer.ts +82 -0
- package/src/cli/terminal/io-service.ts +25 -0
- package/src/cli/terminal/list.ts +36 -0
- package/src/cli/terminal/read.test-utils.ts +48 -0
- package/src/cli/terminal/read.test.ts +35 -0
- package/src/cli/terminal/read.ts +99 -0
- package/src/cli/terminal/scope.ts +35 -0
- package/src/cli/terminal/shared.ts +250 -0
- package/src/cli/terminal/stream.ts +61 -0
- package/src/cli/terminal/wait.test.ts +148 -0
- package/src/cli/terminal/wait.ts +223 -0
- package/src/cli/terminal/write.test.ts +34 -0
- package/src/cli/terminal/write.ts +133 -0
- package/src/cli/terminal.ts +26 -0
- package/src/cli/thread.ts +8 -0
- package/src/cli/threads/approve.ts +11 -7
- package/src/cli/threads/archive.ts +23 -25
- package/src/cli/threads/callback.ts +6 -4
- package/src/cli/threads/delete.ts +67 -0
- package/src/cli/threads/interrupt.ts +57 -0
- package/src/cli/threads/list.test.ts +71 -0
- package/src/cli/threads/list.ts +25 -13
- package/src/cli/threads/messages.ts +11 -7
- package/src/cli/threads/respond.ts +11 -7
- package/src/cli/threads/send.ts +39 -9
- package/src/cli/threads/show.ts +11 -7
- package/src/cli/threads/start.ts +18 -13
- package/src/cli/threads/unarchive.ts +48 -0
- package/src/cli/threads/update.ts +155 -0
- package/src/cli/threads/wait.ts +11 -7
- package/src/cli/wait-events.ts +1 -1
- package/src/config/config.ts +260 -0
- package/src/config/credential/cipher-node.ts +40 -0
- package/src/config/credential/cipher-web.ts +82 -0
- package/src/config/credential/cipher.ts +39 -0
- package/src/config/credential/env.ts +13 -0
- package/src/config/credential/error.ts +9 -0
- package/src/config/credential/index.ts +6 -0
- package/src/config/credential/service.test-utils.ts +25 -0
- package/src/config/credential/service.test.ts +116 -0
- package/src/config/credential/service.ts +205 -0
- package/src/config/env/env.test-utils.ts +14 -0
- package/src/config/env/env.ts +81 -0
- package/src/config/env/index.ts +2 -0
- package/src/{layout/base-dir.ts → config/env/layout.ts} +0 -9
- package/src/config/environment-name/index.ts +7 -0
- package/src/config/environment-name/name.test.ts +66 -0
- package/src/config/environment-name/name.ts +49 -0
- package/src/config/error.ts +6 -8
- package/src/config/index.ts +16 -5
- package/src/config/keystore/error.ts +9 -0
- package/src/config/keystore/file.ts +96 -0
- package/src/config/keystore/index.ts +4 -0
- package/src/config/keystore/keyring-node.test.ts +12 -0
- package/src/config/keystore/keyring-node.ts +100 -0
- package/src/config/keystore/service.test-utils.ts +15 -0
- package/src/config/keystore/service.test.ts +18 -0
- package/src/config/keystore/service.ts +29 -0
- package/src/config/layer.test-utils.ts +45 -0
- package/src/config/layer.test.ts +209 -0
- package/src/config/paths/index.ts +1 -0
- package/src/config/paths/paths.ts +36 -0
- package/src/config/persist/file-mode.ts +21 -0
- package/src/config/persist/migration.test.ts +71 -0
- package/src/config/persist/migration.ts +82 -0
- package/src/config/persist/persist.test.ts +113 -0
- package/src/config/persist/persist.ts +65 -0
- package/src/config/persist/schema.ts +37 -0
- package/src/config/platform.test-utils.ts +20 -0
- package/src/config/resolve/resolve.test-utils.ts +20 -0
- package/src/config/resolve/resolve.test.ts +137 -0
- package/src/config/resolve/resolve.ts +104 -0
- package/src/config/selection/index.ts +1 -0
- package/src/config/selection/resolve.ts +14 -0
- package/src/config/selection/service.ts +29 -0
- package/src/config/temp-home.test-utils.ts +7 -0
- package/src/config/types.ts +49 -0
- package/src/config/url/error.ts +8 -0
- package/src/config/url/index.ts +7 -0
- package/src/config/url/url.test.ts +31 -0
- package/src/connection/index.ts +0 -1
- package/src/contracts/index.ts +1 -1
- package/src/domain/error.ts +39 -1
- package/src/domain/helpers.test.ts +1 -1
- package/src/domain/helpers.ts +1 -1
- package/src/domain/model-config.ts +5 -1
- package/src/domain/thread-activities.test.ts +1 -1
- package/src/domain/thread-activities.ts +1 -1
- package/src/domain/thread-lifecycle.test.ts +1 -1
- package/src/domain/thread-lifecycle.ts +15 -1
- package/src/effect.test-utils.ts +25 -0
- package/src/index.ts +1 -1
- package/src/{connection/node.ts → node/connection.ts} +1 -1
- package/src/node/index.ts +1 -0
- package/src/orchestration/index.ts +1 -1
- package/src/orchestration/layer.ts +34 -86
- package/src/orchestration/service.ts +5 -1
- package/src/rpc/error.ts +12 -2
- package/src/rpc/index.ts +5 -1
- package/src/rpc/layer.ts +1 -1
- package/src/rpc/operation.ts +83 -0
- package/src/rpc/ws-group.ts +25 -1
- package/src/runtime/index.ts +2 -1
- package/src/runtime/layer.test-utils.ts +32 -0
- package/src/runtime/layer.test.ts +66 -0
- package/src/runtime/layer.ts +22 -11
- package/src/t3tools/index.ts +1 -1
- package/src/types/marked-terminal.d.ts +11 -0
- package/dist/layout.js +0 -2
- package/dist/scope.js +0 -2
- package/dist/src/cli/output-format.d.ts +0 -9
- package/dist/src/config/layer.d.ts +0 -22
- package/dist/src/config/service.d.ts +0 -22
- package/dist/src/environment/layer.d.ts +0 -3
- package/dist/src/environment/service.d.ts +0 -12
- package/dist/src/layout/index.d.ts +0 -1
- package/dist/upstream-t3code/packages/contracts/src/auth.d.ts +0 -441
- package/dist/upstream-t3code/packages/contracts/src/baseSchemas.d.ts +0 -38
- package/dist/upstream-t3code/packages/contracts/src/desktopBootstrap.d.ts +0 -14
- package/dist/upstream-t3code/packages/contracts/src/editor.d.ts +0 -124
- package/dist/upstream-t3code/packages/contracts/src/environment.d.ts +0 -64
- package/dist/upstream-t3code/packages/contracts/src/environmentHttp.d.ts +0 -785
- package/dist/upstream-t3code/packages/contracts/src/filesystem.d.ts +0 -26
- package/dist/upstream-t3code/packages/contracts/src/git.d.ts +0 -500
- package/dist/upstream-t3code/packages/contracts/src/index.d.ts +0 -25
- package/dist/upstream-t3code/packages/contracts/src/ipc.d.ts +0 -496
- package/dist/upstream-t3code/packages/contracts/src/keybindings.d.ts +0 -133
- package/dist/upstream-t3code/packages/contracts/src/model.d.ts +0 -112
- package/dist/upstream-t3code/packages/contracts/src/orchestration.d.ts +0 -7338
- package/dist/upstream-t3code/packages/contracts/src/project.d.ts +0 -45
- package/dist/upstream-t3code/packages/contracts/src/provider.d.ts +0 -130
- package/dist/upstream-t3code/packages/contracts/src/providerInstance.d.ts +0 -99
- package/dist/upstream-t3code/packages/contracts/src/providerRuntime.d.ts +0 -4450
- package/dist/upstream-t3code/packages/contracts/src/relay.d.ts +0 -1262
- package/dist/upstream-t3code/packages/contracts/src/relayClient.d.ts +0 -48
- package/dist/upstream-t3code/packages/contracts/src/remoteAccess.d.ts +0 -45
- package/dist/upstream-t3code/packages/contracts/src/review.d.ts +0 -37
- package/dist/upstream-t3code/packages/contracts/src/rpc.d.ts +0 -8710
- package/dist/upstream-t3code/packages/contracts/src/server.d.ts +0 -2336
- package/dist/upstream-t3code/packages/contracts/src/settings.d.ts +0 -292
- package/dist/upstream-t3code/packages/contracts/src/sourceControl.d.ts +0 -177
- package/dist/upstream-t3code/packages/contracts/src/terminal.d.ts +0 -333
- package/dist/upstream-t3code/packages/contracts/src/vcs.d.ts +0 -148
- package/src/cli/auth-format.ts +0 -45
- package/src/cli/model-format.ts +0 -18
- package/src/cli/output-format.ts +0 -41
- package/src/cli/project-format.ts +0 -11
- package/src/cli/thread-format.ts +0 -121
- package/src/config/layer.ts +0 -105
- package/src/config/service.ts +0 -26
- package/src/environment/layer.ts +0 -12
- package/src/environment/service.ts +0 -13
- package/src/layout/index.ts +0 -1
- /package/dist/src/{scope → cli/scope}/index.d.ts +0 -0
- /package/dist/src/config/{url.d.ts → url/url.d.ts} +0 -0
- /package/src/{scope → cli/scope}/index.ts +0 -0
- /package/src/config/{url.ts → url/url.ts} +0 -0
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import * as Effect from "effect/Effect";
|
|
2
2
|
import * as Layer from "effect/Layer";
|
|
3
3
|
import * as Option from "effect/Option";
|
|
4
|
-
import * as Schedule from "effect/Schedule";
|
|
5
4
|
import * as Sink from "effect/Sink";
|
|
6
5
|
import * as Stream from "effect/Stream";
|
|
7
6
|
import {
|
|
@@ -11,87 +10,46 @@ import {
|
|
|
11
10
|
type ClientOrchestrationCommand,
|
|
12
11
|
type OrchestrationShellStreamItem,
|
|
13
12
|
type OrchestrationThreadStreamItem,
|
|
14
|
-
} from "
|
|
15
|
-
import { RpcClientError } from "effect/unstable/rpc";
|
|
13
|
+
} from "@t3tools/contracts";
|
|
16
14
|
|
|
17
15
|
import { RpcError } from "../rpc/error.ts";
|
|
18
|
-
import {
|
|
19
|
-
import type
|
|
20
|
-
import { T3Orchestration, type OpenThread } from "./service.ts";
|
|
16
|
+
import { T3RpcOperations } from "../rpc/operation.ts";
|
|
17
|
+
import { T3Orchestration, type OpenThread, type Orchestration } from "./service.ts";
|
|
21
18
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
const rpcRetrySchedule = Schedule.exponential("100 millis").pipe(
|
|
25
|
-
Schedule.take(4),
|
|
26
|
-
Schedule.collectWhile(
|
|
27
|
-
(metadata: Schedule.Metadata) => metadata.input instanceof RpcClientError.RpcClientError,
|
|
28
|
-
),
|
|
29
|
-
);
|
|
19
|
+
export const makeT3Orchestration = Effect.fn("makeT3Orchestration")(function* () {
|
|
20
|
+
const rpc = yield* T3RpcOperations;
|
|
30
21
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
)
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
error instanceof RpcClientError.RpcClientError ? rpc.disconnect : Effect.void,
|
|
42
|
-
),
|
|
43
|
-
Effect.retry(rpcRetrySchedule),
|
|
44
|
-
Effect.catchTags({
|
|
45
|
-
RpcError: (error) => Effect.fail(error),
|
|
46
|
-
EnvironmentAuthorizationError: (error) => Effect.fail(toRpcRequestError(error, method)),
|
|
47
|
-
RpcClientError: (error) => Effect.fail(toRpcRequestError(error, method)),
|
|
48
|
-
KeybindingsConfigParseError: (error) => Effect.fail(toRpcRequestError(error, method)),
|
|
49
|
-
OrchestrationDispatchCommandError: (error) => Effect.fail(toRpcRequestError(error, method)),
|
|
50
|
-
OrchestrationGetSnapshotError: (error) => Effect.fail(toRpcRequestError(error, method)),
|
|
51
|
-
ServerSettingsError: (error) => Effect.fail(toRpcRequestError(error, method)),
|
|
52
|
-
}),
|
|
53
|
-
);
|
|
54
|
-
}
|
|
22
|
+
const watchShellSequence: Orchestration["watchShellSequence"] = () =>
|
|
23
|
+
rpc
|
|
24
|
+
.subscribe(ORCHESTRATION_WS_METHODS.subscribeShell, (client) =>
|
|
25
|
+
client[ORCHESTRATION_WS_METHODS.subscribeShell]({}),
|
|
26
|
+
)
|
|
27
|
+
.pipe(
|
|
28
|
+
Stream.map((item: OrchestrationShellStreamItem) =>
|
|
29
|
+
item.kind === "snapshot" ? item.snapshot.snapshotSequence : item.sequence,
|
|
30
|
+
),
|
|
31
|
+
);
|
|
55
32
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
): Stream.Stream<A, RpcError> {
|
|
61
|
-
return Stream.unwrap(Effect.map(rpc.getClient, f)).pipe(
|
|
62
|
-
Stream.tapError((error) =>
|
|
63
|
-
error instanceof RpcClientError.RpcClientError ? rpc.disconnect : Effect.void,
|
|
64
|
-
),
|
|
65
|
-
Stream.retry(rpcRetrySchedule),
|
|
66
|
-
Stream.catchTags({
|
|
67
|
-
RpcError: (error) => Stream.fail(error),
|
|
68
|
-
EnvironmentAuthorizationError: (error) => Stream.fail(toRpcRequestError(error, method)),
|
|
69
|
-
RpcClientError: (error) => Stream.fail(toRpcRequestError(error, method)),
|
|
70
|
-
KeybindingsConfigParseError: (error) => Stream.fail(toRpcRequestError(error, method)),
|
|
71
|
-
OrchestrationDispatchCommandError: (error) => Stream.fail(toRpcRequestError(error, method)),
|
|
72
|
-
OrchestrationGetSnapshotError: (error) => Stream.fail(toRpcRequestError(error, method)),
|
|
73
|
-
ServerSettingsError: (error) => Stream.fail(toRpcRequestError(error, method)),
|
|
74
|
-
}),
|
|
75
|
-
);
|
|
76
|
-
}
|
|
33
|
+
const watchThreadItems: Orchestration["watchThreadItems"] = (threadId: string) =>
|
|
34
|
+
rpc.subscribe(ORCHESTRATION_WS_METHODS.subscribeThread, (client) =>
|
|
35
|
+
client[ORCHESTRATION_WS_METHODS.subscribeThread]({ threadId: ThreadId.make(threadId) }),
|
|
36
|
+
);
|
|
77
37
|
|
|
78
|
-
export const makeT3Orchestration = Effect.fn("makeT3Orchestration")(function* () {
|
|
79
|
-
const rpc = yield* T3Rpc;
|
|
80
38
|
const dispatch = Effect.fn("T3OrchestrationLive.dispatch")(function* (
|
|
81
39
|
command: ClientOrchestrationCommand,
|
|
82
40
|
) {
|
|
83
|
-
return yield*
|
|
41
|
+
return yield* rpc.run(ORCHESTRATION_WS_METHODS.dispatchCommand, (client) =>
|
|
84
42
|
client[ORCHESTRATION_WS_METHODS.dispatchCommand](command),
|
|
85
43
|
);
|
|
86
44
|
});
|
|
87
45
|
const getServerConfig = Effect.fn("T3OrchestrationLive.getServerConfig")(function* () {
|
|
88
|
-
return yield*
|
|
46
|
+
return yield* rpc.run(WS_METHODS.serverGetConfig, (client) =>
|
|
89
47
|
client[WS_METHODS.serverGetConfig]({}),
|
|
90
48
|
);
|
|
91
49
|
});
|
|
92
50
|
const getShellSnapshot = Effect.fn("T3OrchestrationLive.getShellSnapshot")(function* () {
|
|
93
51
|
const item = yield* Stream.runHead(
|
|
94
|
-
|
|
52
|
+
rpc.subscribe(ORCHESTRATION_WS_METHODS.subscribeShell, (client) =>
|
|
95
53
|
client[ORCHESTRATION_WS_METHODS.subscribeShell]({}),
|
|
96
54
|
),
|
|
97
55
|
);
|
|
@@ -106,12 +64,21 @@ export const makeT3Orchestration = Effect.fn("makeT3Orchestration")(function* ()
|
|
|
106
64
|
}
|
|
107
65
|
return value.snapshot;
|
|
108
66
|
});
|
|
67
|
+
const getArchivedShellSnapshot = Effect.fn("T3OrchestrationLive.getArchivedShellSnapshot")(
|
|
68
|
+
function* () {
|
|
69
|
+
return yield* rpc.run(ORCHESTRATION_WS_METHODS.getArchivedShellSnapshot, (client) =>
|
|
70
|
+
client[ORCHESTRATION_WS_METHODS.getArchivedShellSnapshot]({}),
|
|
71
|
+
);
|
|
72
|
+
},
|
|
73
|
+
);
|
|
109
74
|
const getThreadSnapshot = Effect.fn("T3OrchestrationLive.getThreadSnapshot")(function* (
|
|
110
75
|
threadId: string,
|
|
111
76
|
) {
|
|
112
77
|
const item = yield* Stream.runHead(
|
|
113
|
-
|
|
114
|
-
client[ORCHESTRATION_WS_METHODS.subscribeThread]({
|
|
78
|
+
rpc.subscribe(ORCHESTRATION_WS_METHODS.subscribeThread, (client) =>
|
|
79
|
+
client[ORCHESTRATION_WS_METHODS.subscribeThread]({
|
|
80
|
+
threadId: ThreadId.make(threadId),
|
|
81
|
+
}),
|
|
115
82
|
),
|
|
116
83
|
);
|
|
117
84
|
const value = Option.getOrUndefined(item);
|
|
@@ -125,18 +92,6 @@ export const makeT3Orchestration = Effect.fn("makeT3Orchestration")(function* ()
|
|
|
125
92
|
}
|
|
126
93
|
return value.snapshot.thread;
|
|
127
94
|
});
|
|
128
|
-
const watchShellSequence = () =>
|
|
129
|
-
subscribeRpc(rpc, ORCHESTRATION_WS_METHODS.subscribeShell, (client) =>
|
|
130
|
-
client[ORCHESTRATION_WS_METHODS.subscribeShell]({}),
|
|
131
|
-
).pipe(
|
|
132
|
-
Stream.map((item: OrchestrationShellStreamItem) =>
|
|
133
|
-
item.kind === "snapshot" ? item.snapshot.snapshotSequence : item.sequence,
|
|
134
|
-
),
|
|
135
|
-
);
|
|
136
|
-
const watchThreadItems = (threadId: string) =>
|
|
137
|
-
subscribeRpc(rpc, ORCHESTRATION_WS_METHODS.subscribeThread, (client) =>
|
|
138
|
-
client[ORCHESTRATION_WS_METHODS.subscribeThread]({ threadId: ThreadId.make(threadId) }),
|
|
139
|
-
);
|
|
140
95
|
const openThread = Effect.fn("T3OrchestrationLive.openThread")(function* (threadId: string) {
|
|
141
96
|
return yield* watchThreadItems(threadId).pipe(
|
|
142
97
|
Stream.peel(Sink.head<OrchestrationThreadStreamItem>()),
|
|
@@ -168,6 +123,7 @@ export const makeT3Orchestration = Effect.fn("makeT3Orchestration")(function* ()
|
|
|
168
123
|
dispatch,
|
|
169
124
|
getServerConfig,
|
|
170
125
|
getShellSnapshot,
|
|
126
|
+
getArchivedShellSnapshot,
|
|
171
127
|
getThreadSnapshot,
|
|
172
128
|
watchShellSequence,
|
|
173
129
|
watchThreadItems,
|
|
@@ -176,11 +132,3 @@ export const makeT3Orchestration = Effect.fn("makeT3Orchestration")(function* ()
|
|
|
176
132
|
});
|
|
177
133
|
|
|
178
134
|
export const T3OrchestrationLive = Layer.effect(T3Orchestration, makeT3Orchestration());
|
|
179
|
-
|
|
180
|
-
function toRpcRequestError(error: RpcRequestError, method: string) {
|
|
181
|
-
return new RpcError({
|
|
182
|
-
message: error.message,
|
|
183
|
-
method,
|
|
184
|
-
cause: error,
|
|
185
|
-
});
|
|
186
|
-
}
|
|
@@ -10,7 +10,7 @@ import type {
|
|
|
10
10
|
OrchestrationThread,
|
|
11
11
|
OrchestrationThreadStreamItem,
|
|
12
12
|
ServerProviders,
|
|
13
|
-
} from "
|
|
13
|
+
} from "@t3tools/contracts";
|
|
14
14
|
|
|
15
15
|
import type { RpcError } from "../rpc/error.ts";
|
|
16
16
|
|
|
@@ -31,6 +31,10 @@ export type Orchestration = {
|
|
|
31
31
|
) => Effect.Effect<DispatchResult, OrchestrationError>;
|
|
32
32
|
readonly getServerConfig: () => Effect.Effect<ServerConfigForCli, OrchestrationError>;
|
|
33
33
|
readonly getShellSnapshot: () => Effect.Effect<OrchestrationShellSnapshot, OrchestrationError>;
|
|
34
|
+
readonly getArchivedShellSnapshot: () => Effect.Effect<
|
|
35
|
+
OrchestrationShellSnapshot,
|
|
36
|
+
OrchestrationError
|
|
37
|
+
>;
|
|
34
38
|
readonly getThreadSnapshot: (
|
|
35
39
|
threadId: string,
|
|
36
40
|
) => Effect.Effect<OrchestrationThread, OrchestrationError>;
|
package/src/rpc/error.ts
CHANGED
|
@@ -5,13 +5,17 @@ import {
|
|
|
5
5
|
OrchestrationDispatchCommandError,
|
|
6
6
|
OrchestrationGetSnapshotError,
|
|
7
7
|
ServerSettingsError,
|
|
8
|
-
|
|
8
|
+
TerminalCwdError,
|
|
9
|
+
TerminalHistoryError,
|
|
10
|
+
TerminalNotRunningError,
|
|
11
|
+
TerminalSessionLookupError,
|
|
12
|
+
} from "@t3tools/contracts";
|
|
9
13
|
import { HttpClientError } from "effect/unstable/http";
|
|
10
14
|
import { RpcClientError } from "effect/unstable/rpc";
|
|
11
15
|
|
|
12
16
|
import { AuthTransportError } from "../auth/error.ts";
|
|
13
17
|
import { T3CodeConnectionError } from "../connection/error.ts";
|
|
14
|
-
import { UrlError } from "../config/error.ts";
|
|
18
|
+
import { UrlError } from "../config/url/error.ts";
|
|
15
19
|
|
|
16
20
|
const RpcErrorCauseSchema = Schema.Union([
|
|
17
21
|
RpcClientError.RpcClientError,
|
|
@@ -20,6 +24,10 @@ const RpcErrorCauseSchema = Schema.Union([
|
|
|
20
24
|
OrchestrationDispatchCommandError,
|
|
21
25
|
OrchestrationGetSnapshotError,
|
|
22
26
|
ServerSettingsError,
|
|
27
|
+
TerminalCwdError,
|
|
28
|
+
TerminalHistoryError,
|
|
29
|
+
TerminalNotRunningError,
|
|
30
|
+
TerminalSessionLookupError,
|
|
23
31
|
AuthTransportError,
|
|
24
32
|
T3CodeConnectionError,
|
|
25
33
|
HttpClientError.HttpClientErrorSchema,
|
|
@@ -27,6 +35,8 @@ const RpcErrorCauseSchema = Schema.Union([
|
|
|
27
35
|
Schema.instanceOf(Schema.SchemaError),
|
|
28
36
|
]);
|
|
29
37
|
|
|
38
|
+
export type RpcKnownCause = Schema.Schema.Type<typeof RpcErrorCauseSchema>;
|
|
39
|
+
|
|
30
40
|
export class RpcError extends Schema.TaggedErrorClass<RpcError>()("RpcError", {
|
|
31
41
|
message: Schema.String,
|
|
32
42
|
method: Schema.optionalKey(Schema.String),
|
package/src/rpc/index.ts
CHANGED
|
@@ -1 +1,5 @@
|
|
|
1
|
-
export { RpcError
|
|
1
|
+
export { RpcError } from "./error.ts";
|
|
2
|
+
export { makeT3RpcLayer, T3RpcLive } from "./layer.ts";
|
|
3
|
+
export { T3RpcOperations, T3RpcOperationsLive, makeT3RpcOperations } from "./operation.ts";
|
|
4
|
+
export { T3Rpc } from "./service.ts";
|
|
5
|
+
export type { WsClient } from "./service.ts";
|
package/src/rpc/layer.ts
CHANGED
|
@@ -12,7 +12,7 @@ import * as Socket from "effect/unstable/socket/Socket";
|
|
|
12
12
|
|
|
13
13
|
import { T3AuthTransport } from "../auth/transport.ts";
|
|
14
14
|
import { T3CodeConnectionProvider } from "../connection/service.ts";
|
|
15
|
-
import { normalizeHttpBaseUrl, toWebSocketEndpointUrl } from "../config/url.ts";
|
|
15
|
+
import { normalizeHttpBaseUrl, toWebSocketEndpointUrl } from "../config/url/url.ts";
|
|
16
16
|
import { CliWsRpcGroup } from "./ws-group.ts";
|
|
17
17
|
import { RpcError } from "./error.ts";
|
|
18
18
|
import { T3Rpc, type WsClient } from "./service.ts";
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import * as Context from "effect/Context";
|
|
2
|
+
import * as Effect from "effect/Effect";
|
|
3
|
+
import * as Layer from "effect/Layer";
|
|
4
|
+
import * as Predicate from "effect/Predicate";
|
|
5
|
+
import * as Schedule from "effect/Schedule";
|
|
6
|
+
import * as Stream from "effect/Stream";
|
|
7
|
+
import { RpcClientError } from "effect/unstable/rpc";
|
|
8
|
+
|
|
9
|
+
import { RpcError } from "./error.ts";
|
|
10
|
+
import { T3Rpc, type WsClient } from "./service.ts";
|
|
11
|
+
import type { CliRpcRequestError } from "./ws-group.ts";
|
|
12
|
+
|
|
13
|
+
export type CliRpcOperationError = CliRpcRequestError | RpcClientError.RpcClientError;
|
|
14
|
+
|
|
15
|
+
export const rpcRetrySchedule = Schedule.exponential("100 millis").pipe(
|
|
16
|
+
Schedule.take(4),
|
|
17
|
+
Schedule.collectWhile((metadata: Schedule.Metadata) =>
|
|
18
|
+
Predicate.isTagged(metadata.input, "RpcClientError"),
|
|
19
|
+
),
|
|
20
|
+
);
|
|
21
|
+
|
|
22
|
+
export type T3RpcOperationsService = {
|
|
23
|
+
readonly run: <A, R>(
|
|
24
|
+
method: string,
|
|
25
|
+
operation: (client: WsClient) => Effect.Effect<A, CliRpcOperationError, R>,
|
|
26
|
+
) => Effect.Effect<A, RpcError, R>;
|
|
27
|
+
readonly subscribe: <A>(
|
|
28
|
+
method: string,
|
|
29
|
+
operation: (client: WsClient) => Stream.Stream<A, CliRpcOperationError>,
|
|
30
|
+
) => Stream.Stream<A, RpcError>;
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
export class T3RpcOperations extends Context.Service<T3RpcOperations, T3RpcOperationsService>()(
|
|
34
|
+
"t3cli/T3RpcOperations",
|
|
35
|
+
) {}
|
|
36
|
+
|
|
37
|
+
export const makeT3RpcOperations = Effect.fn("makeT3RpcOperations")(function* () {
|
|
38
|
+
const rpc = yield* T3Rpc;
|
|
39
|
+
|
|
40
|
+
const run: T3RpcOperationsService["run"] = <A, R>(
|
|
41
|
+
method: string,
|
|
42
|
+
operation: (client: WsClient) => Effect.Effect<A, CliRpcOperationError, R>,
|
|
43
|
+
): Effect.Effect<A, RpcError, R> =>
|
|
44
|
+
rpc.getClient.pipe(
|
|
45
|
+
Effect.flatMap((client) => operation(client)),
|
|
46
|
+
Effect.tapError((error) =>
|
|
47
|
+
Predicate.isTagged(error, "RpcClientError") ? rpc.disconnect : Effect.void,
|
|
48
|
+
),
|
|
49
|
+
Effect.retry(rpcRetrySchedule),
|
|
50
|
+
Effect.mapError((error) =>
|
|
51
|
+
Predicate.isTagged(error, "RpcError") ? error : toRpcError(error, method),
|
|
52
|
+
),
|
|
53
|
+
);
|
|
54
|
+
|
|
55
|
+
const subscribe: T3RpcOperationsService["subscribe"] = <A>(
|
|
56
|
+
method: string,
|
|
57
|
+
operation: (client: WsClient) => Stream.Stream<A, CliRpcOperationError>,
|
|
58
|
+
): Stream.Stream<A, RpcError> =>
|
|
59
|
+
Stream.unwrap(rpc.getClient.pipe(Effect.map((client) => operation(client)))).pipe(
|
|
60
|
+
Stream.tapError((error) =>
|
|
61
|
+
Predicate.isTagged(error, "RpcClientError") ? rpc.disconnect : Effect.void,
|
|
62
|
+
),
|
|
63
|
+
Stream.retry(rpcRetrySchedule),
|
|
64
|
+
Stream.mapError((error) =>
|
|
65
|
+
Predicate.isTagged(error, "RpcError") ? error : toRpcError(error, method),
|
|
66
|
+
),
|
|
67
|
+
);
|
|
68
|
+
|
|
69
|
+
return {
|
|
70
|
+
run,
|
|
71
|
+
subscribe,
|
|
72
|
+
} satisfies T3RpcOperationsService;
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
export const T3RpcOperationsLive = Layer.effect(T3RpcOperations, makeT3RpcOperations());
|
|
76
|
+
|
|
77
|
+
function toRpcError(error: CliRpcOperationError, method: string): RpcError {
|
|
78
|
+
return new RpcError({
|
|
79
|
+
message: error.message,
|
|
80
|
+
method,
|
|
81
|
+
cause: error,
|
|
82
|
+
});
|
|
83
|
+
}
|
package/src/rpc/ws-group.ts
CHANGED
|
@@ -6,11 +6,23 @@ import {
|
|
|
6
6
|
ServerConfig,
|
|
7
7
|
ServerProviders,
|
|
8
8
|
ServerSettingsError,
|
|
9
|
+
TerminalCwdError,
|
|
10
|
+
TerminalHistoryError,
|
|
11
|
+
TerminalNotRunningError,
|
|
12
|
+
TerminalSessionLookupError,
|
|
9
13
|
WS_METHODS,
|
|
14
|
+
WsSubscribeTerminalEventsRpc,
|
|
15
|
+
WsSubscribeTerminalMetadataRpc,
|
|
16
|
+
WsTerminalAttachRpc,
|
|
17
|
+
WsTerminalCloseRpc,
|
|
18
|
+
WsTerminalOpenRpc,
|
|
19
|
+
WsTerminalResizeRpc,
|
|
20
|
+
WsTerminalWriteRpc,
|
|
10
21
|
WsOrchestrationDispatchCommandRpc,
|
|
22
|
+
WsOrchestrationGetArchivedShellSnapshotRpc,
|
|
11
23
|
WsOrchestrationSubscribeShellRpc,
|
|
12
24
|
WsOrchestrationSubscribeThreadRpc,
|
|
13
|
-
} from "
|
|
25
|
+
} from "@t3tools/contracts";
|
|
14
26
|
import * as Schema from "effect/Schema";
|
|
15
27
|
import { Rpc, RpcGroup } from "effect/unstable/rpc";
|
|
16
28
|
|
|
@@ -29,7 +41,15 @@ export const WsServerGetConfigRpc = Rpc.make(WS_METHODS.serverGetConfig, {
|
|
|
29
41
|
});
|
|
30
42
|
|
|
31
43
|
export const CliWsRpcGroup = RpcGroup.make(
|
|
44
|
+
WsTerminalOpenRpc,
|
|
45
|
+
WsTerminalAttachRpc,
|
|
46
|
+
WsTerminalWriteRpc,
|
|
47
|
+
WsTerminalResizeRpc,
|
|
48
|
+
WsTerminalCloseRpc,
|
|
49
|
+
WsSubscribeTerminalEventsRpc,
|
|
50
|
+
WsSubscribeTerminalMetadataRpc,
|
|
32
51
|
WsOrchestrationDispatchCommandRpc,
|
|
52
|
+
WsOrchestrationGetArchivedShellSnapshotRpc,
|
|
33
53
|
WsOrchestrationSubscribeShellRpc,
|
|
34
54
|
WsOrchestrationSubscribeThreadRpc,
|
|
35
55
|
WsServerGetConfigRpc,
|
|
@@ -40,4 +60,8 @@ export type CliRpcRequestError =
|
|
|
40
60
|
| KeybindingsConfigError
|
|
41
61
|
| OrchestrationDispatchCommandError
|
|
42
62
|
| OrchestrationGetSnapshotError
|
|
63
|
+
| TerminalCwdError
|
|
64
|
+
| TerminalHistoryError
|
|
65
|
+
| TerminalNotRunningError
|
|
66
|
+
| TerminalSessionLookupError
|
|
43
67
|
| ServerSettingsError;
|
package/src/runtime/index.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
export {
|
|
2
2
|
AppLayer,
|
|
3
3
|
AuthAppLayer,
|
|
4
|
+
BaseAppLayer,
|
|
5
|
+
BaseAuthAppLayer,
|
|
4
6
|
T3AuthLayer,
|
|
5
7
|
T3AuthPairingLayer,
|
|
6
8
|
T3AuthTransportLayer,
|
|
@@ -9,4 +11,3 @@ export {
|
|
|
9
11
|
T3LocalAuthTokenLayer,
|
|
10
12
|
T3OrchestrationLayer,
|
|
11
13
|
} from "./layer.ts";
|
|
12
|
-
export { NodeEnvironmentLive } from "../environment/layer.ts";
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import * as Layer from "effect/Layer";
|
|
2
|
+
|
|
3
|
+
import * as CliSelection from "../cli/env/selection-layer.ts";
|
|
4
|
+
import * as CliRuntime from "../cli/runtime/service.ts";
|
|
5
|
+
import * as Config from "../config/config.ts";
|
|
6
|
+
import * as Credential from "../config/credential/service.ts";
|
|
7
|
+
import * as CredentialCipherNode from "../config/credential/cipher-node.ts";
|
|
8
|
+
import { ConfigPlatformLayer } from "../config/platform.test-utils.ts";
|
|
9
|
+
import { t3CliEnvConfigLayer } from "../config/env/env.test-utils.ts";
|
|
10
|
+
import * as Keystore from "../config/keystore/service.test-utils.ts";
|
|
11
|
+
|
|
12
|
+
export function cliConfigRoutingLayerTest(homeDir: string) {
|
|
13
|
+
const cliRuntimeLayer = CliRuntime.CliRuntime.layerTest({ cwd: homeDir });
|
|
14
|
+
const configLayer = t3CliEnvConfigLayer(homeDir, { T3CLI_ENV: "home" });
|
|
15
|
+
const platformEnvLayer = Layer.mergeAll(cliRuntimeLayer, configLayer);
|
|
16
|
+
|
|
17
|
+
return Layer.mergeAll(
|
|
18
|
+
ConfigPlatformLayer,
|
|
19
|
+
platformEnvLayer,
|
|
20
|
+
Config.layer.pipe(
|
|
21
|
+
Layer.provide(Credential.layer),
|
|
22
|
+
Layer.provide(
|
|
23
|
+
Layer.mergeAll(
|
|
24
|
+
platformEnvLayer,
|
|
25
|
+
CliSelection.layer.pipe(Layer.provide(platformEnvLayer)),
|
|
26
|
+
CredentialCipherNode.layerNode,
|
|
27
|
+
Keystore.unavailableKeystoreFactoryLayer,
|
|
28
|
+
),
|
|
29
|
+
),
|
|
30
|
+
),
|
|
31
|
+
);
|
|
32
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import "vite-plus/test/config";
|
|
2
|
+
|
|
3
|
+
import * as Effect from "effect/Effect";
|
|
4
|
+
import * as Ref from "effect/Ref";
|
|
5
|
+
import * as NodeServices from "@effect/platform-node/NodeServices";
|
|
6
|
+
import { assert, describe, it } from "@effect/vitest";
|
|
7
|
+
import { Command } from "effect/unstable/cli";
|
|
8
|
+
|
|
9
|
+
import { cliEnvironmentSetting } from "../cli/env/flag.ts";
|
|
10
|
+
import type { ResolvedConfig } from "../config/types.ts";
|
|
11
|
+
import { T3Config } from "../config/config.ts";
|
|
12
|
+
import { makeTempHomeScoped } from "../config/temp-home.test-utils.ts";
|
|
13
|
+
import { cliConfigRoutingLayerTest } from "./layer.test-utils.ts";
|
|
14
|
+
|
|
15
|
+
describe("CLI config routing", () => {
|
|
16
|
+
it.effect(
|
|
17
|
+
"routes --environment through Command.run to T3Config.resolve ahead of default and T3CLI_ENV",
|
|
18
|
+
() =>
|
|
19
|
+
Effect.gen(function* () {
|
|
20
|
+
return yield* makeTempHomeScoped("t3cli-runtime-");
|
|
21
|
+
}).pipe(
|
|
22
|
+
Effect.flatMap((homeDir) => {
|
|
23
|
+
const testLayer = cliConfigRoutingLayerTest(homeDir);
|
|
24
|
+
return Effect.gen(function* () {
|
|
25
|
+
const resolvedRef = yield* Ref.make<ResolvedConfig | undefined>(undefined);
|
|
26
|
+
const resolveProbeCommand = Command.make("resolve-probe", {}, () =>
|
|
27
|
+
Effect.gen(function* () {
|
|
28
|
+
const config = yield* T3Config;
|
|
29
|
+
const resolved = yield* config.resolve();
|
|
30
|
+
yield* Ref.set(resolvedRef, resolved);
|
|
31
|
+
}),
|
|
32
|
+
).pipe(Command.withGlobalFlags([cliEnvironmentSetting]));
|
|
33
|
+
const runResolveProbe = Command.runWith(resolveProbeCommand, { version: "0.0.0-test" });
|
|
34
|
+
|
|
35
|
+
yield* Effect.gen(function* () {
|
|
36
|
+
const config = yield* T3Config;
|
|
37
|
+
yield* config.upsertEnvironment({
|
|
38
|
+
name: "home",
|
|
39
|
+
url: "https://home.example",
|
|
40
|
+
token: "home-token",
|
|
41
|
+
local: false,
|
|
42
|
+
});
|
|
43
|
+
yield* config.upsertEnvironment({
|
|
44
|
+
name: "work",
|
|
45
|
+
url: "https://work.example",
|
|
46
|
+
token: "work-token",
|
|
47
|
+
local: false,
|
|
48
|
+
});
|
|
49
|
+
}).pipe(Effect.provide(testLayer));
|
|
50
|
+
|
|
51
|
+
yield* runResolveProbe(["--environment", "work"]).pipe(Effect.provide(testLayer));
|
|
52
|
+
|
|
53
|
+
const resolved = yield* Ref.get(resolvedRef);
|
|
54
|
+
assert.isDefined(resolved);
|
|
55
|
+
assert.equal(resolved.source, "config");
|
|
56
|
+
if (resolved.source === "config") {
|
|
57
|
+
assert.equal(resolved.environment, "work");
|
|
58
|
+
assert.equal(resolved.token, "work-token");
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
}),
|
|
62
|
+
Effect.provide(NodeServices.layer),
|
|
63
|
+
Effect.scoped,
|
|
64
|
+
),
|
|
65
|
+
);
|
|
66
|
+
});
|
package/src/runtime/layer.ts
CHANGED
|
@@ -10,15 +10,18 @@ import { T3LocalAuthOriginLive } from "../auth/local-origin.ts";
|
|
|
10
10
|
import { T3LocalAuthTokenLive } from "../auth/local-token.ts";
|
|
11
11
|
import { T3AuthPairingLive } from "../auth/pairing.ts";
|
|
12
12
|
import { T3AuthTransportLive } from "../auth/transport.ts";
|
|
13
|
-
import
|
|
14
|
-
import
|
|
13
|
+
import * as Config from "../config/config.ts";
|
|
14
|
+
import * as Credential from "../config/credential/service.ts";
|
|
15
|
+
import * as Selection from "../config/selection/service.ts";
|
|
15
16
|
import { T3CodeConnectionError } from "../connection/error.ts";
|
|
16
17
|
import { T3CodeConnectionProvider, makeT3CodeConnectionProvider } from "../connection/service.ts";
|
|
17
18
|
import { T3OrchestrationLive } from "../orchestration/layer.ts";
|
|
18
19
|
import { T3RpcLive } from "../rpc/layer.ts";
|
|
20
|
+
import { T3RpcOperationsLive } from "../rpc/operation.ts";
|
|
19
21
|
import { NodeSqlClientFactoryLive } from "../sql/node-sqlite-client.ts";
|
|
20
22
|
import { NodeCliPathLayer } from "../cli-path/layer.ts";
|
|
21
23
|
|
|
24
|
+
export const T3ConfigLayer = Config.layer.pipe(Layer.provide(Credential.layer));
|
|
22
25
|
export const T3AuthTransportLayer = T3AuthTransportLive.pipe(
|
|
23
26
|
Layer.provide(NodeHttpClient.layerUndici),
|
|
24
27
|
);
|
|
@@ -32,13 +35,13 @@ export const T3LocalAuthLayer = T3LocalAuthLive.pipe(
|
|
|
32
35
|
export const T3AuthPairingLayer = T3AuthPairingLive.pipe(Layer.provide(T3AuthTransportLayer));
|
|
33
36
|
export const T3AuthLayer = T3AuthLive.pipe(
|
|
34
37
|
Layer.provide(
|
|
35
|
-
Layer.mergeAll(
|
|
38
|
+
Layer.mergeAll(T3ConfigLayer, T3AuthTransportLayer, T3LocalAuthLayer, T3AuthPairingLayer),
|
|
36
39
|
),
|
|
37
40
|
);
|
|
38
41
|
const T3ConfigConnectionProviderLayer = Layer.effect(
|
|
39
42
|
T3CodeConnectionProvider,
|
|
40
43
|
Effect.gen(function* () {
|
|
41
|
-
const config = yield* T3Config;
|
|
44
|
+
const config = yield* Config.T3Config;
|
|
42
45
|
return makeT3CodeConnectionProvider(
|
|
43
46
|
config.resolve().pipe(
|
|
44
47
|
Effect.map((resolved) => ({
|
|
@@ -55,7 +58,7 @@ const T3ConfigConnectionProviderLayer = Layer.effect(
|
|
|
55
58
|
),
|
|
56
59
|
);
|
|
57
60
|
}),
|
|
58
|
-
).pipe(Layer.provide(
|
|
61
|
+
).pipe(Layer.provide(T3ConfigLayer));
|
|
59
62
|
|
|
60
63
|
const T3RpcLayer = T3RpcLive.pipe(
|
|
61
64
|
Layer.provide(
|
|
@@ -66,16 +69,24 @@ const T3RpcLayer = T3RpcLive.pipe(
|
|
|
66
69
|
),
|
|
67
70
|
),
|
|
68
71
|
);
|
|
69
|
-
|
|
70
|
-
const
|
|
71
|
-
|
|
72
|
-
|
|
72
|
+
const T3RpcOperationsLayer = T3RpcOperationsLive.pipe(Layer.provide(T3RpcLayer));
|
|
73
|
+
export const T3OrchestrationLayer = T3OrchestrationLive.pipe(Layer.provide(T3RpcOperationsLayer));
|
|
74
|
+
const T3ApplicationLayer = T3ApplicationLive.pipe(
|
|
75
|
+
Layer.provide(Layer.mergeAll(T3RpcOperationsLayer, T3OrchestrationLayer)),
|
|
76
|
+
);
|
|
73
77
|
|
|
74
|
-
export const
|
|
75
|
-
|
|
78
|
+
export const BaseAppLayer = Layer.mergeAll(
|
|
79
|
+
T3ConfigLayer,
|
|
76
80
|
T3AuthLayer,
|
|
77
81
|
T3RpcLayer,
|
|
82
|
+
T3RpcOperationsLayer,
|
|
78
83
|
T3OrchestrationLayer,
|
|
79
84
|
T3ApplicationLayer,
|
|
80
85
|
NodeCliPathLayer,
|
|
81
86
|
);
|
|
87
|
+
|
|
88
|
+
export const BaseAuthAppLayer = Layer.mergeAll(T3ConfigLayer, T3AuthLayer);
|
|
89
|
+
|
|
90
|
+
export const AuthAppLayer = BaseAuthAppLayer.pipe(Layer.provideMerge(Selection.layer));
|
|
91
|
+
|
|
92
|
+
export const AppLayer = BaseAppLayer.pipe(Layer.provideMerge(Selection.layer));
|
package/src/t3tools/index.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from "
|
|
1
|
+
export * from "@t3tools/contracts";
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
declare module "marked-terminal" {
|
|
2
|
+
import type { MarkedExtension } from "marked";
|
|
3
|
+
|
|
4
|
+
export type TerminalRendererOptions = {
|
|
5
|
+
readonly reflowText?: boolean;
|
|
6
|
+
readonly showSectionPrefix?: boolean;
|
|
7
|
+
readonly width?: number;
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export function markedTerminal(options?: TerminalRendererOptions): MarkedExtension;
|
|
11
|
+
}
|
package/dist/layout.js
DELETED
package/dist/scope.js
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import type { EnvironmentShape } from "../environment/service.ts";
|
|
2
|
-
export declare const humanJsonFormatChoices: readonly ["auto", "human", "json"];
|
|
3
|
-
export declare const humanNdjsonFormatChoices: readonly ["auto", "human", "ndjson"];
|
|
4
|
-
export declare const humanJsonNdjsonFormatChoices: readonly ["auto", "human", "json", "ndjson"];
|
|
5
|
-
export type HumanJsonFormat = (typeof humanJsonFormatChoices)[number];
|
|
6
|
-
export type HumanNdjsonFormat = (typeof humanNdjsonFormatChoices)[number];
|
|
7
|
-
export type HumanJsonNdjsonFormat = (typeof humanJsonNdjsonFormatChoices)[number];
|
|
8
|
-
export declare function resolveOutputFormat<T extends "json" | "ndjson">(format: "auto" | "human" | T, environment: EnvironmentShape, nonHumanFormat: T): "human" | T;
|
|
9
|
-
export declare function canRenderLiveTerminal(environment: EnvironmentShape): boolean;
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import * as Effect from "effect/Effect";
|
|
2
|
-
import * as FileSystem from "effect/FileSystem";
|
|
3
|
-
import * as Layer from "effect/Layer";
|
|
4
|
-
import * as Path from "effect/Path";
|
|
5
|
-
import { Environment } from "../environment/service.ts";
|
|
6
|
-
import { ConfigError } from "./error.ts";
|
|
7
|
-
import { T3Config, type StoredConfig } from "./service.ts";
|
|
8
|
-
export declare const makeT3Config: () => Effect.Effect<{
|
|
9
|
-
readStored: () => Effect.Effect<{
|
|
10
|
-
readonly url?: string;
|
|
11
|
-
readonly token?: string;
|
|
12
|
-
readonly local?: boolean;
|
|
13
|
-
}, ConfigError, never>;
|
|
14
|
-
writeStored: (config: StoredConfig) => Effect.Effect<void, ConfigError, never>;
|
|
15
|
-
resolve: () => Effect.Effect<{
|
|
16
|
-
url: string;
|
|
17
|
-
token: string;
|
|
18
|
-
source: "config" | "env";
|
|
19
|
-
local: boolean;
|
|
20
|
-
}, import("./error.ts").UrlError | ConfigError, never>;
|
|
21
|
-
}, never, Environment | Path.Path | FileSystem.FileSystem>;
|
|
22
|
-
export declare const T3ConfigLive: Layer.Layer<T3Config, never, Environment | Path.Path | FileSystem.FileSystem>;
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import * as Context from "effect/Context";
|
|
2
|
-
import type * as Effect from "effect/Effect";
|
|
3
|
-
import type { ConfigError, ConfigServiceError } from "./error.ts";
|
|
4
|
-
export type StoredConfig = {
|
|
5
|
-
readonly url?: string;
|
|
6
|
-
readonly token?: string;
|
|
7
|
-
readonly local?: boolean;
|
|
8
|
-
};
|
|
9
|
-
export type ResolvedConfig = {
|
|
10
|
-
readonly url: string;
|
|
11
|
-
readonly token: string;
|
|
12
|
-
readonly source: "env" | "config";
|
|
13
|
-
readonly local: boolean;
|
|
14
|
-
};
|
|
15
|
-
declare const T3Config_base: Context.ServiceClass<T3Config, "t3cli/T3Config", {
|
|
16
|
-
readonly readStored: () => Effect.Effect<StoredConfig, ConfigError>;
|
|
17
|
-
readonly writeStored: (config: StoredConfig) => Effect.Effect<void, ConfigError>;
|
|
18
|
-
readonly resolve: () => Effect.Effect<ResolvedConfig, ConfigServiceError>;
|
|
19
|
-
}>;
|
|
20
|
-
export declare class T3Config extends T3Config_base {
|
|
21
|
-
}
|
|
22
|
-
export {};
|