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
|
@@ -2,25 +2,25 @@ import * as Effect from "effect/Effect";
|
|
|
2
2
|
|
|
3
3
|
import { filterProvidersForModelListing } from "../domain/model-config.ts";
|
|
4
4
|
import { T3Orchestration } from "../orchestration/service.ts";
|
|
5
|
+
import type { T3ModelApplicationService } from "./service.ts";
|
|
5
6
|
|
|
6
7
|
export const makeModelsApplication = Effect.fn("makeModelsApplication")(function* () {
|
|
7
8
|
const orchestration = yield* T3Orchestration;
|
|
8
9
|
|
|
9
|
-
const listModels = Effect.fn("T3Application.listModels")(
|
|
10
|
-
readonly all?: boolean;
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
});
|
|
10
|
+
const listModels: T3ModelApplicationService["listModels"] = Effect.fn("T3Application.listModels")(
|
|
11
|
+
function* (input: { readonly all?: boolean; readonly provider?: string }) {
|
|
12
|
+
const config = yield* orchestration.getServerConfig();
|
|
13
|
+
return filterProvidersForModelListing({
|
|
14
|
+
providers: config.providers,
|
|
15
|
+
all: input.all === true,
|
|
16
|
+
...(input.provider !== undefined && input.provider.length > 0
|
|
17
|
+
? { provider: input.provider }
|
|
18
|
+
: {}),
|
|
19
|
+
});
|
|
20
|
+
},
|
|
21
|
+
);
|
|
22
22
|
|
|
23
23
|
return {
|
|
24
24
|
listModels,
|
|
25
|
-
};
|
|
25
|
+
} satisfies T3ModelApplicationService;
|
|
26
26
|
});
|
|
@@ -2,18 +2,16 @@ import * as Crypto from "effect/Crypto";
|
|
|
2
2
|
import * as DateTime from "effect/DateTime";
|
|
3
3
|
import * as Effect from "effect/Effect";
|
|
4
4
|
import * as Path from "effect/Path";
|
|
5
|
-
import { CommandId, ProjectId, type ClientOrchestrationCommand } from "
|
|
6
|
-
|
|
7
|
-
import { Environment } from "../environment/service.ts";
|
|
5
|
+
import { CommandId, ProjectId, type ClientOrchestrationCommand } from "@t3tools/contracts";
|
|
8
6
|
|
|
9
7
|
export const makeProjectCreateCommand = Effect.fn("makeProjectCreateCommand")(function* (input: {
|
|
10
8
|
readonly path: string;
|
|
11
9
|
readonly title?: string;
|
|
10
|
+
readonly cwd: string;
|
|
12
11
|
}) {
|
|
13
12
|
const path = yield* Path.Path;
|
|
14
13
|
const crypto = yield* Crypto.Crypto;
|
|
15
|
-
const
|
|
16
|
-
const workspaceRoot = path.resolve(environment.cwd, input.path);
|
|
14
|
+
const workspaceRoot = path.resolve(input.cwd, input.path);
|
|
17
15
|
const projectId = ProjectId.make(yield* crypto.randomUUIDv4.pipe(Effect.orDie));
|
|
18
16
|
const title = input.title?.trim();
|
|
19
17
|
const createdAt = DateTime.formatIso(yield* DateTime.now);
|
|
@@ -28,3 +26,38 @@ export const makeProjectCreateCommand = Effect.fn("makeProjectCreateCommand")(fu
|
|
|
28
26
|
createdAt,
|
|
29
27
|
} satisfies Extract<ClientOrchestrationCommand, { readonly type: "project.create" }>;
|
|
30
28
|
});
|
|
29
|
+
|
|
30
|
+
export const makeProjectDeleteCommand = Effect.fn("makeProjectDeleteCommand")(function* (input: {
|
|
31
|
+
readonly projectId: string;
|
|
32
|
+
readonly force?: boolean;
|
|
33
|
+
}) {
|
|
34
|
+
const crypto = yield* Crypto.Crypto;
|
|
35
|
+
return {
|
|
36
|
+
type: "project.delete",
|
|
37
|
+
commandId: CommandId.make(
|
|
38
|
+
`t3cli:project-delete:${yield* crypto.randomUUIDv4.pipe(Effect.orDie)}`,
|
|
39
|
+
),
|
|
40
|
+
projectId: ProjectId.make(input.projectId),
|
|
41
|
+
...(input.force === true ? { force: true } : {}),
|
|
42
|
+
} satisfies Extract<ClientOrchestrationCommand, { readonly type: "project.delete" }>;
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
export const makeProjectMetaUpdateCommand = Effect.fn("makeProjectMetaUpdateCommand")(
|
|
46
|
+
function* (input: {
|
|
47
|
+
readonly projectId: string;
|
|
48
|
+
readonly scripts: Extract<
|
|
49
|
+
ClientOrchestrationCommand,
|
|
50
|
+
{ readonly type: "project.meta.update" }
|
|
51
|
+
>["scripts"];
|
|
52
|
+
}) {
|
|
53
|
+
const crypto = yield* Crypto.Crypto;
|
|
54
|
+
return {
|
|
55
|
+
type: "project.meta.update",
|
|
56
|
+
commandId: CommandId.make(
|
|
57
|
+
`t3cli:project-meta-update:${yield* crypto.randomUUIDv4.pipe(Effect.orDie)}`,
|
|
58
|
+
),
|
|
59
|
+
projectId: ProjectId.make(input.projectId),
|
|
60
|
+
scripts: input.scripts,
|
|
61
|
+
} satisfies Extract<ClientOrchestrationCommand, { readonly type: "project.meta.update" }>;
|
|
62
|
+
},
|
|
63
|
+
);
|
|
@@ -2,35 +2,52 @@ import * as Crypto from "effect/Crypto";
|
|
|
2
2
|
import * as Effect from "effect/Effect";
|
|
3
3
|
import * as Path from "effect/Path";
|
|
4
4
|
|
|
5
|
-
import {
|
|
5
|
+
import { CliRuntime } from "../cli/runtime/service.ts";
|
|
6
6
|
import { T3Orchestration } from "../orchestration/service.ts";
|
|
7
|
-
import { ProjectCreateVisibilityError } from "../domain/error.ts";
|
|
8
|
-
import { findProjectById } from "../domain/helpers.ts";
|
|
9
|
-
import { makeProjectCreateCommand } from "./project-commands.ts";
|
|
7
|
+
import { ProjectCreateVisibilityError, ProjectLookupError } from "../domain/error.ts";
|
|
8
|
+
import { findProjectById, resolveProjectScope } from "../domain/helpers.ts";
|
|
9
|
+
import { makeProjectCreateCommand, makeProjectDeleteCommand } from "./project-commands.ts";
|
|
10
10
|
import { waitForShellSequence } from "./shell-sequence.ts";
|
|
11
|
+
import type { T3ProjectApplicationService } from "./service.ts";
|
|
11
12
|
|
|
12
13
|
export const makeProjectApplication = Effect.fn("makeProjectApplication")(function* () {
|
|
13
14
|
const orchestration = yield* T3Orchestration;
|
|
14
15
|
const crypto = yield* Crypto.Crypto;
|
|
15
16
|
const path = yield* Path.Path;
|
|
16
|
-
const
|
|
17
|
-
const loadShell = Effect.fn(
|
|
17
|
+
const cliRuntime = yield* CliRuntime;
|
|
18
|
+
const loadShell: T3ProjectApplicationService["loadShell"] = Effect.fn(
|
|
19
|
+
"T3ApplicationLive.loadShell",
|
|
20
|
+
)(function* () {
|
|
18
21
|
return yield* orchestration.getShellSnapshot();
|
|
19
22
|
});
|
|
20
|
-
const
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
const
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
23
|
+
const resolveProject: T3ProjectApplicationService["resolveProject"] = Effect.fn(
|
|
24
|
+
"T3ApplicationLive.resolveProject",
|
|
25
|
+
)(function* (projectRef: string) {
|
|
26
|
+
const snapshot = yield* orchestration.getShellSnapshot();
|
|
27
|
+
const scope = yield* resolveProjectScope(snapshot, {
|
|
28
|
+
ref: projectRef,
|
|
29
|
+
}).pipe(Effect.provideService(Path.Path, path));
|
|
30
|
+
if (scope === undefined) {
|
|
31
|
+
return yield* Effect.fail(
|
|
32
|
+
new ProjectLookupError({
|
|
33
|
+
message: `project not found: ${projectRef}`,
|
|
34
|
+
ref: projectRef,
|
|
35
|
+
}),
|
|
36
|
+
);
|
|
37
|
+
}
|
|
38
|
+
return scope.project;
|
|
39
|
+
});
|
|
40
|
+
const addProject: T3ProjectApplicationService["addProject"] = Effect.fn(
|
|
41
|
+
"T3ApplicationLive.addProject",
|
|
42
|
+
)(function* (projectInput: { readonly path: string; readonly title?: string }) {
|
|
43
|
+
const command = yield* makeProjectCreateCommand({
|
|
44
|
+
...projectInput,
|
|
45
|
+
cwd: cliRuntime.cwd,
|
|
46
|
+
}).pipe(Effect.provideService(Path.Path, path), Effect.provideService(Crypto.Crypto, crypto));
|
|
29
47
|
const dispatch = yield* orchestration.dispatch(command);
|
|
30
|
-
const snapshot = yield* waitForShellSequence({
|
|
31
|
-
orchestration,
|
|
32
|
-
|
|
33
|
-
});
|
|
48
|
+
const snapshot = yield* waitForShellSequence({ sequence: dispatch.sequence }).pipe(
|
|
49
|
+
Effect.provideService(T3Orchestration, orchestration),
|
|
50
|
+
);
|
|
34
51
|
const project = findProjectById(snapshot, command.projectId);
|
|
35
52
|
if (project === null) {
|
|
36
53
|
return yield* Effect.fail(
|
|
@@ -42,9 +59,21 @@ export const makeProjectApplication = Effect.fn("makeProjectApplication")(functi
|
|
|
42
59
|
}
|
|
43
60
|
return { dispatch, project };
|
|
44
61
|
});
|
|
62
|
+
const deleteProject: T3ProjectApplicationService["deleteProject"] = Effect.fn(
|
|
63
|
+
"T3ApplicationLive.deleteProject",
|
|
64
|
+
)(function* (input: { readonly projectId: string; readonly force?: boolean }) {
|
|
65
|
+
const command = yield* makeProjectDeleteCommand({
|
|
66
|
+
projectId: input.projectId,
|
|
67
|
+
...(input.force === true ? { force: true } : {}),
|
|
68
|
+
}).pipe(Effect.provideService(Crypto.Crypto, crypto));
|
|
69
|
+
const dispatch = yield* orchestration.dispatch(command);
|
|
70
|
+
return { projectId: input.projectId, dispatch };
|
|
71
|
+
});
|
|
45
72
|
|
|
46
73
|
return {
|
|
47
74
|
loadShell,
|
|
48
75
|
addProject,
|
|
49
|
-
|
|
76
|
+
resolveProject,
|
|
77
|
+
deleteProject,
|
|
78
|
+
} satisfies T3ProjectApplicationService;
|
|
50
79
|
});
|
|
@@ -9,9 +9,15 @@ import type {
|
|
|
9
9
|
OrchestrationShellSnapshot,
|
|
10
10
|
OrchestrationThread,
|
|
11
11
|
OrchestrationThreadShell,
|
|
12
|
+
ProjectScript,
|
|
13
|
+
ProjectScriptIcon,
|
|
12
14
|
ProviderUserInputAnswers,
|
|
13
15
|
ServerProvider,
|
|
14
|
-
|
|
16
|
+
TerminalAttachStreamEvent,
|
|
17
|
+
TerminalMetadataStreamEvent,
|
|
18
|
+
TerminalSessionSnapshot,
|
|
19
|
+
TerminalSummary,
|
|
20
|
+
} from "@t3tools/contracts";
|
|
15
21
|
|
|
16
22
|
import type { ApplicationError } from "./error.ts";
|
|
17
23
|
import type { ThreadShow } from "./threads.ts";
|
|
@@ -26,6 +32,23 @@ export type StartThreadInput = {
|
|
|
26
32
|
readonly worktreePath?: string;
|
|
27
33
|
};
|
|
28
34
|
|
|
35
|
+
export type CreateTerminalInput = {
|
|
36
|
+
readonly threadId: string;
|
|
37
|
+
readonly terminalId?: string;
|
|
38
|
+
readonly command?: string;
|
|
39
|
+
readonly env?: Readonly<Record<string, string>>;
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
export type TerminalRef = {
|
|
43
|
+
readonly threadId: string;
|
|
44
|
+
readonly terminalId: string;
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
export type TerminalAttachTarget = TerminalRef & {
|
|
48
|
+
readonly cwd: string;
|
|
49
|
+
readonly worktreePath: string | null;
|
|
50
|
+
};
|
|
51
|
+
|
|
29
52
|
export type SendThreadInput = {
|
|
30
53
|
readonly threadId: string;
|
|
31
54
|
readonly message: string;
|
|
@@ -38,6 +61,18 @@ export type CallbackThreadInput = {
|
|
|
38
61
|
readonly prompt: string;
|
|
39
62
|
};
|
|
40
63
|
|
|
64
|
+
export type ListThreadsInclude = "active" | "archived" | "all";
|
|
65
|
+
|
|
66
|
+
export type UpdateThreadInput = {
|
|
67
|
+
readonly threadId: string;
|
|
68
|
+
readonly title?: string;
|
|
69
|
+
readonly provider?: string;
|
|
70
|
+
readonly model?: string;
|
|
71
|
+
readonly options?: NonNullable<ModelSelection["options"]>;
|
|
72
|
+
readonly branch?: string | null;
|
|
73
|
+
readonly worktreePath?: string | null;
|
|
74
|
+
};
|
|
75
|
+
|
|
41
76
|
export type StartThreadPolicy = {
|
|
42
77
|
readonly until: "dispatch" | "visible" | "complete";
|
|
43
78
|
};
|
|
@@ -48,82 +83,244 @@ export type WaitEvent =
|
|
|
48
83
|
| { readonly type: "status"; readonly status: string; readonly threadId: string }
|
|
49
84
|
| { readonly type: "done"; readonly thread: OrchestrationThread };
|
|
50
85
|
|
|
51
|
-
export
|
|
52
|
-
|
|
53
|
-
{
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
86
|
+
export type ProjectActionSelector =
|
|
87
|
+
| { readonly id: string; readonly name?: never }
|
|
88
|
+
| { readonly id?: never; readonly name: string };
|
|
89
|
+
|
|
90
|
+
export type AddProjectActionInput = {
|
|
91
|
+
readonly projectRef: string;
|
|
92
|
+
readonly id?: string;
|
|
93
|
+
readonly name: string;
|
|
94
|
+
readonly command: string;
|
|
95
|
+
readonly icon?: ProjectScriptIcon;
|
|
96
|
+
readonly setup?: boolean;
|
|
97
|
+
readonly previewUrl?: string;
|
|
98
|
+
readonly autoOpenPreview?: boolean;
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
export type UpdateProjectActionInput = {
|
|
102
|
+
readonly projectRef: string;
|
|
103
|
+
readonly selector: ProjectActionSelector;
|
|
104
|
+
readonly name?: string;
|
|
105
|
+
readonly command?: string;
|
|
106
|
+
readonly icon?: ProjectScriptIcon;
|
|
107
|
+
readonly setup?: boolean;
|
|
108
|
+
readonly previewUrl?: string | null;
|
|
109
|
+
readonly autoOpenPreview?: boolean | null;
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
export type ProjectActionMutationResult = {
|
|
113
|
+
readonly dispatch: DispatchResult;
|
|
114
|
+
readonly project: OrchestrationProjectShell;
|
|
115
|
+
readonly action: ProjectScript;
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
export type ProjectActionDeleteResult = {
|
|
119
|
+
readonly dispatch: DispatchResult;
|
|
120
|
+
readonly project: OrchestrationProjectShell;
|
|
121
|
+
readonly action: ProjectScript;
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
export type ProjectActionRunResult = {
|
|
125
|
+
readonly project: OrchestrationProjectShell;
|
|
126
|
+
readonly action: ProjectScript;
|
|
127
|
+
readonly terminal: TerminalSessionSnapshot;
|
|
128
|
+
};
|
|
129
|
+
|
|
130
|
+
export type T3ActionApplicationService = {
|
|
131
|
+
readonly listActions: (projectRef: string) => Effect.Effect<
|
|
132
|
+
{
|
|
133
|
+
readonly project: OrchestrationProjectShell;
|
|
134
|
+
readonly actions: ReadonlyArray<ProjectScript>;
|
|
135
|
+
},
|
|
136
|
+
ApplicationError
|
|
137
|
+
>;
|
|
138
|
+
readonly addAction: (
|
|
139
|
+
input: AddProjectActionInput,
|
|
140
|
+
) => Effect.Effect<ProjectActionMutationResult, ApplicationError>;
|
|
141
|
+
readonly updateAction: (
|
|
142
|
+
input: UpdateProjectActionInput,
|
|
143
|
+
) => Effect.Effect<ProjectActionMutationResult, ApplicationError>;
|
|
144
|
+
readonly deleteAction: (input: {
|
|
145
|
+
readonly projectRef: string;
|
|
146
|
+
readonly selector: ProjectActionSelector;
|
|
147
|
+
}) => Effect.Effect<ProjectActionDeleteResult, ApplicationError>;
|
|
148
|
+
readonly runAction: (input: {
|
|
149
|
+
readonly threadId: string;
|
|
150
|
+
readonly selector: ProjectActionSelector;
|
|
151
|
+
readonly terminalId?: string;
|
|
152
|
+
}) => Effect.Effect<ProjectActionRunResult, ApplicationError>;
|
|
153
|
+
};
|
|
154
|
+
|
|
155
|
+
export class T3ActionApplication extends Context.Service<
|
|
156
|
+
T3ActionApplication,
|
|
157
|
+
T3ActionApplicationService
|
|
158
|
+
>()("t3cli/T3ActionApplication") {}
|
|
159
|
+
|
|
160
|
+
export type T3ModelApplicationService = {
|
|
161
|
+
readonly listModels: (input: {
|
|
162
|
+
readonly all?: boolean;
|
|
163
|
+
readonly provider?: string;
|
|
164
|
+
}) => Effect.Effect<ReadonlyArray<ServerProvider>, ApplicationError>;
|
|
165
|
+
};
|
|
166
|
+
|
|
167
|
+
export class T3ModelApplication extends Context.Service<
|
|
168
|
+
T3ModelApplication,
|
|
169
|
+
T3ModelApplicationService
|
|
170
|
+
>()("t3cli/T3ModelApplication") {}
|
|
171
|
+
|
|
172
|
+
export type T3ProjectApplicationService = {
|
|
173
|
+
readonly loadShell: () => Effect.Effect<OrchestrationShellSnapshot, ApplicationError>;
|
|
174
|
+
readonly addProject: (input: {
|
|
175
|
+
readonly path: string;
|
|
176
|
+
readonly title?: string;
|
|
177
|
+
}) => Effect.Effect<
|
|
178
|
+
{ readonly dispatch: DispatchResult; readonly project: OrchestrationProjectShell },
|
|
179
|
+
ApplicationError
|
|
180
|
+
>;
|
|
181
|
+
readonly resolveProject: (
|
|
182
|
+
projectRef: string,
|
|
183
|
+
) => Effect.Effect<OrchestrationProjectShell, ApplicationError>;
|
|
184
|
+
readonly deleteProject: (input: {
|
|
185
|
+
readonly projectId: string;
|
|
186
|
+
readonly force?: boolean;
|
|
187
|
+
}) => Effect.Effect<
|
|
188
|
+
{ readonly projectId: string; readonly dispatch: DispatchResult },
|
|
189
|
+
ApplicationError
|
|
190
|
+
>;
|
|
191
|
+
};
|
|
192
|
+
|
|
193
|
+
export class T3ProjectApplication extends Context.Service<
|
|
194
|
+
T3ProjectApplication,
|
|
195
|
+
T3ProjectApplicationService
|
|
196
|
+
>()("t3cli/T3ProjectApplication") {}
|
|
197
|
+
|
|
198
|
+
export type T3ThreadApplicationService = {
|
|
199
|
+
readonly listThreads: (
|
|
200
|
+
projectRef: string,
|
|
201
|
+
options?: {
|
|
202
|
+
readonly include?: ListThreadsInclude;
|
|
203
|
+
},
|
|
204
|
+
) => Effect.Effect<
|
|
205
|
+
{
|
|
206
|
+
readonly project: OrchestrationProjectShell;
|
|
207
|
+
readonly threads: ReadonlyArray<OrchestrationThreadShell>;
|
|
208
|
+
},
|
|
209
|
+
ApplicationError
|
|
210
|
+
>;
|
|
211
|
+
readonly getThreadMessages: (
|
|
212
|
+
threadId: string,
|
|
213
|
+
) => Effect.Effect<OrchestrationThread, ApplicationError>;
|
|
214
|
+
readonly showThread: (threadId: string) => Effect.Effect<ThreadShow, ApplicationError>;
|
|
215
|
+
readonly approveThread: (input: {
|
|
216
|
+
readonly threadId: string;
|
|
217
|
+
readonly requestId: string;
|
|
218
|
+
readonly decision: "accept" | "decline" | "cancel";
|
|
219
|
+
}) => Effect.Effect<
|
|
220
|
+
{ readonly threadId: string; readonly requestId: string; readonly dispatch: DispatchResult },
|
|
221
|
+
ApplicationError
|
|
222
|
+
>;
|
|
223
|
+
readonly respondToThread: (input: {
|
|
224
|
+
readonly threadId: string;
|
|
225
|
+
readonly requestId: string;
|
|
226
|
+
readonly answers: ProviderUserInputAnswers;
|
|
227
|
+
}) => Effect.Effect<
|
|
228
|
+
{ readonly threadId: string; readonly requestId: string; readonly dispatch: DispatchResult },
|
|
229
|
+
ApplicationError
|
|
230
|
+
>;
|
|
231
|
+
readonly archiveThread: (threadId: string) => Effect.Effect<DispatchResult, ApplicationError>;
|
|
232
|
+
readonly interruptThread: (threadId: string) => Effect.Effect<DispatchResult, ApplicationError>;
|
|
233
|
+
readonly unarchiveThread: (threadId: string) => Effect.Effect<DispatchResult, ApplicationError>;
|
|
234
|
+
readonly deleteThread: (
|
|
235
|
+
threadId: string,
|
|
236
|
+
) => Effect.Effect<
|
|
237
|
+
{ readonly threadId: string; readonly dispatch: DispatchResult },
|
|
238
|
+
ApplicationError
|
|
239
|
+
>;
|
|
240
|
+
readonly updateThread: (
|
|
241
|
+
input: UpdateThreadInput,
|
|
242
|
+
) => Effect.Effect<DispatchResult, ApplicationError>;
|
|
243
|
+
readonly startThread: (
|
|
244
|
+
input: StartThreadInput,
|
|
245
|
+
policy?: StartThreadPolicy,
|
|
246
|
+
) => Effect.Effect<
|
|
247
|
+
{
|
|
248
|
+
readonly dispatch: DispatchResult;
|
|
249
|
+
readonly project: OrchestrationProjectShell;
|
|
78
250
|
readonly threadId: string;
|
|
79
|
-
readonly
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
251
|
+
readonly thread?: OrchestrationThread;
|
|
252
|
+
},
|
|
253
|
+
ApplicationError
|
|
254
|
+
>;
|
|
255
|
+
readonly sendThread: (
|
|
256
|
+
input: SendThreadInput,
|
|
257
|
+
policy?: StartThreadPolicy,
|
|
258
|
+
) => Effect.Effect<
|
|
259
|
+
{
|
|
260
|
+
readonly dispatch: DispatchResult;
|
|
86
261
|
readonly threadId: string;
|
|
87
|
-
readonly
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
readonly
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
262
|
+
readonly thread?: OrchestrationThread;
|
|
263
|
+
},
|
|
264
|
+
ApplicationError
|
|
265
|
+
>;
|
|
266
|
+
readonly watchThread: (threadId: string) => Stream.Stream<WaitEvent, ApplicationError>;
|
|
267
|
+
readonly waitForThread: (
|
|
268
|
+
threadId: string,
|
|
269
|
+
) => Effect.Effect<OrchestrationThread, ApplicationError>;
|
|
270
|
+
readonly callbackThread: (input: CallbackThreadInput) => Effect.Effect<
|
|
271
|
+
{
|
|
272
|
+
readonly dispatch: DispatchResult;
|
|
273
|
+
readonly targetThreadId: string;
|
|
274
|
+
},
|
|
275
|
+
ApplicationError
|
|
276
|
+
>;
|
|
277
|
+
};
|
|
278
|
+
|
|
279
|
+
export class T3ThreadApplication extends Context.Service<
|
|
280
|
+
T3ThreadApplication,
|
|
281
|
+
T3ThreadApplicationService
|
|
282
|
+
>()("t3cli/T3ThreadApplication") {}
|
|
283
|
+
|
|
284
|
+
export type T3TerminalApplicationService = {
|
|
285
|
+
readonly listTerminals: (
|
|
286
|
+
threadId: string,
|
|
287
|
+
) => Effect.Effect<ReadonlyArray<TerminalSummary>, ApplicationError>;
|
|
288
|
+
readonly getTerminal: (terminal: TerminalRef) => Effect.Effect<TerminalSummary, ApplicationError>;
|
|
289
|
+
readonly createTerminal: (
|
|
290
|
+
input: CreateTerminalInput,
|
|
291
|
+
) => Effect.Effect<TerminalSessionSnapshot, ApplicationError>;
|
|
292
|
+
readonly attachTerminal: (input: {
|
|
293
|
+
readonly terminal: TerminalAttachTarget;
|
|
294
|
+
readonly cols?: number;
|
|
295
|
+
readonly rows?: number;
|
|
296
|
+
}) => Stream.Stream<TerminalAttachStreamEvent, ApplicationError>;
|
|
297
|
+
readonly watchTerminalMetadata: () => Stream.Stream<
|
|
298
|
+
TerminalMetadataStreamEvent,
|
|
299
|
+
ApplicationError
|
|
300
|
+
>;
|
|
301
|
+
readonly writeTerminal: (input: {
|
|
302
|
+
readonly terminal: TerminalRef;
|
|
303
|
+
readonly data: string;
|
|
304
|
+
}) => Effect.Effect<void, ApplicationError>;
|
|
305
|
+
readonly resizeTerminal: (input: {
|
|
306
|
+
readonly terminal: TerminalRef;
|
|
307
|
+
readonly cols: number;
|
|
308
|
+
readonly rows: number;
|
|
309
|
+
}) => Effect.Effect<void, ApplicationError>;
|
|
310
|
+
readonly destroyTerminal: (terminal: TerminalRef) => Effect.Effect<void, ApplicationError>;
|
|
311
|
+
};
|
|
312
|
+
|
|
313
|
+
export class T3TerminalApplication extends Context.Service<
|
|
314
|
+
T3TerminalApplication,
|
|
315
|
+
T3TerminalApplicationService
|
|
316
|
+
>()("t3cli/T3TerminalApplication") {}
|
|
317
|
+
|
|
318
|
+
export type T3ApplicationService = T3ModelApplicationService &
|
|
319
|
+
T3ActionApplicationService &
|
|
320
|
+
T3ProjectApplicationService &
|
|
321
|
+
T3ThreadApplicationService &
|
|
322
|
+
T3TerminalApplicationService;
|
|
323
|
+
|
|
324
|
+
export class T3Application extends Context.Service<T3Application, T3ApplicationService>()(
|
|
325
|
+
"t3cli/T3Application",
|
|
326
|
+
) {}
|
|
@@ -1,17 +1,15 @@
|
|
|
1
1
|
import * as Effect from "effect/Effect";
|
|
2
2
|
import * as Option from "effect/Option";
|
|
3
3
|
import * as Stream from "effect/Stream";
|
|
4
|
-
import { ORCHESTRATION_WS_METHODS } from "
|
|
4
|
+
import { ORCHESTRATION_WS_METHODS } from "@t3tools/contracts";
|
|
5
5
|
|
|
6
|
-
import
|
|
6
|
+
import { T3Orchestration } from "../orchestration/service.ts";
|
|
7
7
|
import { RpcError } from "../rpc/error.ts";
|
|
8
8
|
|
|
9
|
-
export function waitForShellSequence(input: {
|
|
10
|
-
readonly orchestration: Orchestration;
|
|
11
|
-
readonly sequence: number;
|
|
12
|
-
}) {
|
|
9
|
+
export function waitForShellSequence(input: { readonly sequence: number }) {
|
|
13
10
|
return Effect.gen(function* () {
|
|
14
|
-
const
|
|
11
|
+
const orchestration = yield* T3Orchestration;
|
|
12
|
+
const sequence = yield* orchestration.watchShellSequence().pipe(
|
|
15
13
|
Stream.filter((snapshotSequence) => snapshotSequence >= input.sequence),
|
|
16
14
|
Stream.runHead,
|
|
17
15
|
Effect.scoped,
|
|
@@ -24,6 +22,6 @@ export function waitForShellSequence(input: {
|
|
|
24
22
|
}),
|
|
25
23
|
);
|
|
26
24
|
}
|
|
27
|
-
return yield*
|
|
25
|
+
return yield* orchestration.getShellSnapshot();
|
|
28
26
|
});
|
|
29
27
|
}
|