t3code-cli 0.1.3 → 0.3.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/dist/bin.js +2 -2
- package/dist/index.js +1 -1
- package/dist/{runtime-0wuYCEoH.js → runtime-CMPZpQaG.js} +35 -31
- package/dist/src/application/error.d.ts +3 -0
- package/dist/src/application/layer.d.ts +776 -0
- package/dist/src/application/model-selection.d.ts +19 -0
- package/dist/src/application/models.d.ts +93 -0
- package/dist/src/application/project-commands.d.ts +15 -0
- package/dist/src/application/projects.d.ts +136 -0
- package/dist/src/application/service.d.ts +72 -0
- package/dist/src/application/shell-sequence.d.ts +91 -0
- package/dist/src/application/thread-commands.d.ts +84 -0
- package/dist/src/application/thread-wait.d.ts +104 -0
- package/dist/src/application/threads.d.ts +563 -0
- package/dist/src/auth/error.d.ts +31 -0
- package/dist/src/auth/layer.d.ts +36 -0
- package/dist/src/auth/local.d.ts +19 -0
- package/dist/src/auth/pairing.d.ts +4 -0
- package/dist/src/auth/schema.d.ts +67 -0
- package/dist/src/auth/service.d.ts +14 -0
- package/dist/src/auth/transport.d.ts +26 -0
- package/dist/src/auth/type.d.ts +26 -0
- package/dist/src/config/error.d.ts +18 -0
- package/dist/src/config/layer.d.ts +20 -0
- package/dist/src/config/service.d.ts +20 -0
- package/dist/src/config/url.d.ts +6 -0
- package/dist/src/domain/error.d.ts +31 -0
- package/dist/src/domain/helpers.d.ts +38 -0
- package/dist/src/domain/model-config.d.ts +293 -0
- package/dist/src/domain/thread-lifecycle.d.ts +114 -0
- package/dist/src/environment/layer.d.ts +3 -0
- package/dist/src/environment/service.d.ts +12 -0
- package/dist/src/index.d.ts +6 -0
- package/dist/src/orchestration/layer.d.ts +2128 -0
- package/dist/src/orchestration/service.d.ts +27 -0
- package/dist/src/rpc/error.d.ts +15 -0
- package/dist/src/rpc/layer.d.ts +4678 -0
- package/dist/src/rpc/service.d.ts +15 -0
- package/dist/src/rpc/ws-group.d.ts +2238 -0
- package/dist/src/runtime.d.ts +3 -0
- package/dist/upstream-t3code/packages/contracts/src/auth.d.ts +439 -0
- package/dist/upstream-t3code/packages/contracts/src/baseSchemas.d.ts +38 -0
- package/dist/upstream-t3code/packages/contracts/src/desktopBootstrap.d.ts +14 -0
- package/dist/upstream-t3code/packages/contracts/src/editor.d.ts +124 -0
- package/dist/upstream-t3code/packages/contracts/src/environment.d.ts +64 -0
- package/dist/upstream-t3code/packages/contracts/src/environmentHttp.d.ts +602 -0
- package/dist/upstream-t3code/packages/contracts/src/filesystem.d.ts +26 -0
- package/dist/upstream-t3code/packages/contracts/src/git.d.ts +500 -0
- package/dist/upstream-t3code/packages/contracts/src/index.d.ts +24 -0
- package/dist/upstream-t3code/packages/contracts/src/ipc.d.ts +466 -0
- package/dist/upstream-t3code/packages/contracts/src/keybindings.d.ts +133 -0
- package/dist/upstream-t3code/packages/contracts/src/model.d.ts +112 -0
- package/dist/upstream-t3code/packages/contracts/src/orchestration.d.ts +6682 -0
- package/dist/upstream-t3code/packages/contracts/src/project.d.ts +45 -0
- package/dist/upstream-t3code/packages/contracts/src/provider.d.ts +116 -0
- package/dist/upstream-t3code/packages/contracts/src/providerInstance.d.ts +99 -0
- package/dist/upstream-t3code/packages/contracts/src/providerRuntime.d.ts +4186 -0
- package/dist/upstream-t3code/packages/contracts/src/remoteAccess.d.ts +45 -0
- package/dist/upstream-t3code/packages/contracts/src/review.d.ts +37 -0
- package/dist/upstream-t3code/packages/contracts/src/rpc.d.ts +8149 -0
- package/dist/upstream-t3code/packages/contracts/src/server.d.ts +2291 -0
- package/dist/upstream-t3code/packages/contracts/src/settings.d.ts +271 -0
- package/dist/upstream-t3code/packages/contracts/src/sourceControl.d.ts +177 -0
- package/dist/upstream-t3code/packages/contracts/src/terminal.d.ts +330 -0
- package/dist/upstream-t3code/packages/contracts/src/vcs.d.ts +148 -0
- package/package.json +15 -7
- package/src/application/model-selection.ts +2 -2
- package/src/application/project-commands.ts +1 -1
- package/src/application/service.ts +1 -1
- package/src/application/shell-sequence.ts +1 -1
- package/src/application/thread-commands.ts +1 -1
- package/src/application/thread-wait.ts +1 -1
- package/src/auth/error.ts +5 -1
- package/src/auth/pairing.ts +6 -2
- package/src/auth/transport.ts +21 -10
- package/src/cli/model-format.ts +1 -1
- package/src/cli/project-format.ts +1 -1
- package/src/cli/thread-format.ts +1 -1
- package/src/config/url.ts +46 -2
- package/src/domain/helpers.ts +1 -1
- package/src/domain/model-config.ts +1 -1
- package/src/domain/thread-lifecycle.ts +1 -1
- package/src/index.ts +3 -3
- package/src/orchestration/layer.ts +1 -1
- package/src/orchestration/service.ts +1 -1
- package/src/rpc/error.ts +1 -1
- package/src/rpc/layer.ts +2 -2
- package/src/rpc/ws-group.ts +1 -1
package/src/auth/transport.ts
CHANGED
|
@@ -2,6 +2,7 @@ import * as Effect from "effect/Effect";
|
|
|
2
2
|
import { HttpClient, HttpClientError, HttpClientRequest } from "effect/unstable/http";
|
|
3
3
|
|
|
4
4
|
import type { ResolvedConfig } from "../config/service.ts";
|
|
5
|
+
import { toHttpEndpointUrl } from "../config/url.ts";
|
|
5
6
|
import { AuthTransportError } from "./error.ts";
|
|
6
7
|
import {
|
|
7
8
|
decodeAuthBearerBootstrapResult,
|
|
@@ -16,8 +17,8 @@ export const makeAuthTransport = Effect.fn("makeAuthTransport")(function* () {
|
|
|
16
17
|
readonly baseUrl: string;
|
|
17
18
|
readonly credential: string;
|
|
18
19
|
}) {
|
|
19
|
-
const
|
|
20
|
-
|
|
20
|
+
const url = yield* makeHttpEndpointUrl(input.baseUrl, "/api/auth/bootstrap/bearer");
|
|
21
|
+
const request = HttpClientRequest.post(url).pipe(
|
|
21
22
|
HttpClientRequest.acceptJson,
|
|
22
23
|
HttpClientRequest.bodyJsonUnsafe({ credential: input.credential }),
|
|
23
24
|
);
|
|
@@ -51,7 +52,7 @@ export const makeAuthTransport = Effect.fn("makeAuthTransport")(function* () {
|
|
|
51
52
|
});
|
|
52
53
|
|
|
53
54
|
const getSession = Effect.fn("AuthTransport.getSession")(function* (config: ResolvedConfig) {
|
|
54
|
-
const request = authenticatedRequest(config, "/api/auth/session", "get");
|
|
55
|
+
const request = yield* authenticatedRequest(config, "/api/auth/session", "get");
|
|
55
56
|
const response = yield* client.execute(request).pipe(
|
|
56
57
|
Effect.catchTags({
|
|
57
58
|
HttpClientError: (error) =>
|
|
@@ -84,7 +85,7 @@ export const makeAuthTransport = Effect.fn("makeAuthTransport")(function* () {
|
|
|
84
85
|
const issueWebSocketToken = Effect.fn("AuthTransport.issueWebSocketToken")(function* (
|
|
85
86
|
config: ResolvedConfig,
|
|
86
87
|
) {
|
|
87
|
-
const request = authenticatedRequest(config, "/api/auth/ws-token", "post");
|
|
88
|
+
const request = yield* authenticatedRequest(config, "/api/auth/ws-token", "post");
|
|
88
89
|
const response = yield* client.execute(request).pipe(
|
|
89
90
|
Effect.catchTags({
|
|
90
91
|
HttpClientError: (error) =>
|
|
@@ -122,11 +123,21 @@ export const makeAuthTransport = Effect.fn("makeAuthTransport")(function* () {
|
|
|
122
123
|
});
|
|
123
124
|
|
|
124
125
|
function authenticatedRequest(config: ResolvedConfig, path: string, method: "get" | "post") {
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
126
|
+
return makeHttpEndpointUrl(config.url, path).pipe(
|
|
127
|
+
Effect.map((url) =>
|
|
128
|
+
method === "get" ? HttpClientRequest.get(url) : HttpClientRequest.post(url),
|
|
129
|
+
),
|
|
130
|
+
Effect.map((request) =>
|
|
131
|
+
request.pipe(HttpClientRequest.acceptJson, HttpClientRequest.bearerToken(config.token)),
|
|
132
|
+
),
|
|
133
|
+
);
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
function makeHttpEndpointUrl(baseUrl: string, path: string) {
|
|
137
|
+
return toHttpEndpointUrl(baseUrl, path).pipe(
|
|
138
|
+
Effect.catchTags({
|
|
139
|
+
UrlError: (error) =>
|
|
140
|
+
Effect.fail(new AuthTransportError({ message: "auth request failed", cause: error })),
|
|
141
|
+
}),
|
|
131
142
|
);
|
|
132
143
|
}
|
package/src/cli/model-format.ts
CHANGED
package/src/cli/thread-format.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { WaitEvent } from "../application/service.ts";
|
|
2
|
-
import type { OrchestrationThread, OrchestrationThreadShell } from "
|
|
2
|
+
import type { OrchestrationThread, OrchestrationThreadShell } from "#t3tools/contracts";
|
|
3
3
|
import { latestAssistantMessage, threadStatus } from "../domain/thread-lifecycle.ts";
|
|
4
4
|
|
|
5
5
|
export function formatThreadsHuman(threads: ReadonlyArray<OrchestrationThreadShell>) {
|
package/src/config/url.ts
CHANGED
|
@@ -26,6 +26,31 @@ export function toWebSocketBaseUrl(httpBaseUrl: string) {
|
|
|
26
26
|
);
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
+
export function toHttpEndpointUrl(httpBaseUrl: string, pathname: string) {
|
|
30
|
+
return parseUrl(httpBaseUrl).pipe(
|
|
31
|
+
Effect.flatMap((url) => Effect.succeed(withPathname(url, pathname).toString())),
|
|
32
|
+
);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export function toWebSocketEndpointUrl(httpBaseUrl: string, pathname: string) {
|
|
36
|
+
return parseUrl(httpBaseUrl).pipe(
|
|
37
|
+
Effect.flatMap((url) => {
|
|
38
|
+
if (url.protocol === "http:") {
|
|
39
|
+
return Effect.succeed(withPathname(url, pathname, "ws:").toString());
|
|
40
|
+
}
|
|
41
|
+
if (url.protocol === "https:") {
|
|
42
|
+
return Effect.succeed(withPathname(url, pathname, "wss:").toString());
|
|
43
|
+
}
|
|
44
|
+
return Effect.fail(
|
|
45
|
+
new UrlError({
|
|
46
|
+
message: `unsupported server url protocol: ${url.protocol}`,
|
|
47
|
+
protocol: url.protocol,
|
|
48
|
+
}),
|
|
49
|
+
);
|
|
50
|
+
}),
|
|
51
|
+
);
|
|
52
|
+
}
|
|
53
|
+
|
|
29
54
|
function parseUrl(value: string): Effect.Effect<URL, UrlError> {
|
|
30
55
|
return Effect.fromResult(Url.fromString(value)).pipe(
|
|
31
56
|
Effect.catchTags({
|
|
@@ -39,7 +64,7 @@ function normalizeBaseUrl(url: URL) {
|
|
|
39
64
|
return Url.mutate(url, (current) => {
|
|
40
65
|
current.hash = "";
|
|
41
66
|
current.search = "";
|
|
42
|
-
current.pathname =
|
|
67
|
+
current.pathname = normalizePathname(current.pathname);
|
|
43
68
|
})
|
|
44
69
|
.toString()
|
|
45
70
|
.replace(/\/$/, "");
|
|
@@ -48,8 +73,27 @@ function normalizeBaseUrl(url: URL) {
|
|
|
48
73
|
function makeWebSocketUrl(url: URL, protocol: "ws:" | "wss:") {
|
|
49
74
|
return Url.mutate(url, (current) => {
|
|
50
75
|
current.protocol = protocol;
|
|
51
|
-
current.pathname = "/ws";
|
|
76
|
+
current.pathname = appendPathname(current.pathname, "/ws");
|
|
52
77
|
current.search = "";
|
|
53
78
|
current.hash = "";
|
|
54
79
|
}).toString();
|
|
55
80
|
}
|
|
81
|
+
|
|
82
|
+
function withPathname(url: URL, pathname: string, protocol?: "ws:" | "wss:") {
|
|
83
|
+
return Url.mutate(url, (current) => {
|
|
84
|
+
if (protocol !== undefined) {
|
|
85
|
+
current.protocol = protocol;
|
|
86
|
+
}
|
|
87
|
+
current.pathname = appendPathname(current.pathname, pathname);
|
|
88
|
+
current.search = "";
|
|
89
|
+
current.hash = "";
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
function normalizePathname(pathname: string) {
|
|
94
|
+
return pathname === "/" ? "" : pathname.replace(/\/+$/u, "");
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
function appendPathname(basePathname: string, pathname: string) {
|
|
98
|
+
return `${normalizePathname(basePathname)}${pathname.startsWith("/") ? pathname : `/${pathname}`}`;
|
|
99
|
+
}
|
package/src/domain/helpers.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type * as Path from "effect/Path";
|
|
2
|
-
import type { OrchestrationProjectShell, OrchestrationShellSnapshot } from "
|
|
2
|
+
import type { OrchestrationProjectShell, OrchestrationShellSnapshot } from "#t3tools/contracts";
|
|
3
3
|
|
|
4
4
|
import { ProjectLookupError } from "./error.ts";
|
|
5
5
|
|
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
type OrchestrationMessage as OrchestrationMessageType,
|
|
5
5
|
type OrchestrationThread,
|
|
6
6
|
type OrchestrationThreadShell,
|
|
7
|
-
} from "
|
|
7
|
+
} from "#t3tools/contracts";
|
|
8
8
|
import * as Schema from "effect/Schema";
|
|
9
9
|
|
|
10
10
|
export function isThreadActive(thread: OrchestrationThreadShell | OrchestrationThread) {
|
package/src/index.ts
CHANGED
|
@@ -6,6 +6,8 @@ export type {
|
|
|
6
6
|
WaitEvent,
|
|
7
7
|
} from "./application/service.ts";
|
|
8
8
|
export type { ApplicationError } from "./application/error.ts";
|
|
9
|
+
export { NodeEnvironmentLive } from "./environment/layer.ts";
|
|
10
|
+
export { AppLayer, AuthAppLayer } from "./runtime.ts";
|
|
9
11
|
export type {
|
|
10
12
|
OrchestrationMessage,
|
|
11
13
|
OrchestrationProjectShell,
|
|
@@ -13,6 +15,4 @@ export type {
|
|
|
13
15
|
OrchestrationThread,
|
|
14
16
|
OrchestrationThreadShell,
|
|
15
17
|
ServerProvider,
|
|
16
|
-
} from "
|
|
17
|
-
export { NodeEnvironmentLive } from "./environment/layer.ts";
|
|
18
|
-
export { AppLayer, AuthAppLayer } from "./runtime.ts";
|
|
18
|
+
} from "#t3tools/contracts";
|
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
type ClientOrchestrationCommand,
|
|
12
12
|
type OrchestrationShellStreamItem,
|
|
13
13
|
type OrchestrationThreadStreamItem,
|
|
14
|
-
} from "
|
|
14
|
+
} from "#t3tools/contracts";
|
|
15
15
|
import { RpcClientError } from "effect/unstable/rpc";
|
|
16
16
|
|
|
17
17
|
import { RpcError } from "../rpc/error.ts";
|
package/src/rpc/error.ts
CHANGED
|
@@ -5,7 +5,7 @@ import {
|
|
|
5
5
|
OrchestrationDispatchCommandError,
|
|
6
6
|
OrchestrationGetSnapshotError,
|
|
7
7
|
ServerSettingsError,
|
|
8
|
-
} from "
|
|
8
|
+
} from "#t3tools/contracts";
|
|
9
9
|
import { HttpClientError } from "effect/unstable/http";
|
|
10
10
|
import { RpcClientError } from "effect/unstable/rpc";
|
|
11
11
|
|
package/src/rpc/layer.ts
CHANGED
|
@@ -13,7 +13,7 @@ import * as Socket from "effect/unstable/socket/Socket";
|
|
|
13
13
|
|
|
14
14
|
import { T3Auth } from "../auth/service.ts";
|
|
15
15
|
import { T3Config } from "../config/service.ts";
|
|
16
|
-
import {
|
|
16
|
+
import { toWebSocketEndpointUrl } from "../config/url.ts";
|
|
17
17
|
import { CliWsRpcGroup } from "./ws-group.ts";
|
|
18
18
|
import { RpcError } from "./error.ts";
|
|
19
19
|
import { T3Rpc, type WsClient } from "./service.ts";
|
|
@@ -77,7 +77,7 @@ const makeWsUrl = Effect.fn("makeWsUrl")(function* (input: {
|
|
|
77
77
|
}) {
|
|
78
78
|
const resolved = yield* input.config.resolve();
|
|
79
79
|
const wsToken = yield* input.auth.issueWebSocketToken();
|
|
80
|
-
const wsUrl = yield*
|
|
80
|
+
const wsUrl = yield* toWebSocketEndpointUrl(resolved.url, "/ws");
|
|
81
81
|
const request = HttpClientRequest.get(wsUrl).pipe(
|
|
82
82
|
HttpClientRequest.setUrlParam("wsToken", wsToken.token),
|
|
83
83
|
);
|
package/src/rpc/ws-group.ts
CHANGED
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
WsOrchestrationDispatchCommandRpc,
|
|
11
11
|
WsOrchestrationSubscribeShellRpc,
|
|
12
12
|
WsOrchestrationSubscribeThreadRpc,
|
|
13
|
-
} from "
|
|
13
|
+
} from "#t3tools/contracts";
|
|
14
14
|
import * as Schema from "effect/Schema";
|
|
15
15
|
import { Rpc, RpcGroup } from "effect/unstable/rpc";
|
|
16
16
|
|