t3code-cli 0.1.2 → 0.2.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-DU_hs0MM.js → runtime-CMPZpQaG.js} +9930 -2845
- package/package.json +4 -2
- package/src/application/model-selection.ts +13 -15
- package/src/application/models.ts +1 -1
- package/src/application/project-commands.ts +6 -4
- package/src/application/service.ts +26 -22
- package/src/application/shell-sequence.ts +1 -1
- package/src/application/thread-commands.ts +32 -22
- package/src/application/thread-wait.ts +4 -4
- 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 +3 -3
- package/src/cli/thread-format.ts +6 -6
- package/src/config/url.ts +46 -2
- package/src/domain/helpers.ts +11 -3
- package/src/domain/model-config.ts +1 -1
- package/src/domain/thread-lifecycle.ts +24 -30
- package/src/index.ts +6 -6
- package/src/orchestration/layer.ts +41 -48
- package/src/orchestration/service.ts +20 -11
- package/src/rpc/error.ts +12 -0
- package/src/rpc/layer.ts +4 -4
- package/src/rpc/service.ts +2 -3
- package/src/rpc/ws-group.ts +43 -0
- package/src/domain/command-schema.ts +0 -82
- package/src/domain/schema.ts +0 -162
- package/src/protocol/schema.ts +0 -105
package/src/domain/schema.ts
DELETED
|
@@ -1,162 +0,0 @@
|
|
|
1
|
-
import * as Schema from "effect/Schema";
|
|
2
|
-
|
|
3
|
-
export type Format = "human" | "json" | "ndjson";
|
|
4
|
-
|
|
5
|
-
export const FormatSchema = Schema.Literals(["human", "json", "ndjson"]);
|
|
6
|
-
|
|
7
|
-
export const ModelSelectionSchema = Schema.Struct({
|
|
8
|
-
instanceId: Schema.String,
|
|
9
|
-
model: Schema.String,
|
|
10
|
-
options: Schema.optionalKey(
|
|
11
|
-
Schema.Array(
|
|
12
|
-
Schema.Struct({
|
|
13
|
-
id: Schema.String,
|
|
14
|
-
value: Schema.Unknown,
|
|
15
|
-
}),
|
|
16
|
-
),
|
|
17
|
-
),
|
|
18
|
-
});
|
|
19
|
-
export type ModelSelection = typeof ModelSelectionSchema.Type;
|
|
20
|
-
|
|
21
|
-
export const ProjectShellSchema = Schema.Struct({
|
|
22
|
-
id: Schema.String,
|
|
23
|
-
title: Schema.String,
|
|
24
|
-
workspaceRoot: Schema.String,
|
|
25
|
-
defaultModelSelection: Schema.NullOr(ModelSelectionSchema),
|
|
26
|
-
createdAt: Schema.String,
|
|
27
|
-
updatedAt: Schema.String,
|
|
28
|
-
});
|
|
29
|
-
export type ProjectShell = typeof ProjectShellSchema.Type;
|
|
30
|
-
|
|
31
|
-
export const ThreadMessageSchema = Schema.Struct({
|
|
32
|
-
id: Schema.optionalKey(Schema.String),
|
|
33
|
-
messageId: Schema.optionalKey(Schema.String),
|
|
34
|
-
role: Schema.Literals(["user", "assistant", "system"]),
|
|
35
|
-
text: Schema.String,
|
|
36
|
-
streaming: Schema.optionalKey(Schema.Boolean),
|
|
37
|
-
turnId: Schema.optionalKey(Schema.NullOr(Schema.String)),
|
|
38
|
-
createdAt: Schema.String,
|
|
39
|
-
updatedAt: Schema.String,
|
|
40
|
-
});
|
|
41
|
-
export type ThreadMessage = typeof ThreadMessageSchema.Type;
|
|
42
|
-
|
|
43
|
-
export const ThreadSessionSchema = Schema.Struct({
|
|
44
|
-
threadId: Schema.String,
|
|
45
|
-
status: Schema.Literals([
|
|
46
|
-
"idle",
|
|
47
|
-
"starting",
|
|
48
|
-
"running",
|
|
49
|
-
"ready",
|
|
50
|
-
"interrupted",
|
|
51
|
-
"stopped",
|
|
52
|
-
"error",
|
|
53
|
-
]),
|
|
54
|
-
lastError: Schema.NullOr(Schema.String),
|
|
55
|
-
updatedAt: Schema.String,
|
|
56
|
-
});
|
|
57
|
-
export type ThreadSession = typeof ThreadSessionSchema.Type;
|
|
58
|
-
|
|
59
|
-
export const ThreadShellSchema = Schema.Struct({
|
|
60
|
-
id: Schema.String,
|
|
61
|
-
projectId: Schema.String,
|
|
62
|
-
title: Schema.String,
|
|
63
|
-
modelSelection: ModelSelectionSchema,
|
|
64
|
-
runtimeMode: Schema.String,
|
|
65
|
-
interactionMode: Schema.String,
|
|
66
|
-
branch: Schema.NullOr(Schema.String),
|
|
67
|
-
worktreePath: Schema.NullOr(Schema.String),
|
|
68
|
-
latestTurn: Schema.NullOr(Schema.Struct({ state: Schema.String })),
|
|
69
|
-
createdAt: Schema.String,
|
|
70
|
-
updatedAt: Schema.String,
|
|
71
|
-
session: Schema.NullOr(ThreadSessionSchema),
|
|
72
|
-
latestUserMessageAt: Schema.optionalKey(Schema.NullOr(Schema.String)),
|
|
73
|
-
});
|
|
74
|
-
export type ThreadShell = typeof ThreadShellSchema.Type;
|
|
75
|
-
|
|
76
|
-
export const ThreadDetailSchema = Schema.Struct({
|
|
77
|
-
id: Schema.String,
|
|
78
|
-
projectId: Schema.String,
|
|
79
|
-
title: Schema.String,
|
|
80
|
-
modelSelection: ModelSelectionSchema,
|
|
81
|
-
runtimeMode: Schema.String,
|
|
82
|
-
interactionMode: Schema.String,
|
|
83
|
-
branch: Schema.NullOr(Schema.String),
|
|
84
|
-
worktreePath: Schema.NullOr(Schema.String),
|
|
85
|
-
latestTurn: Schema.NullOr(Schema.Struct({ state: Schema.String })),
|
|
86
|
-
createdAt: Schema.String,
|
|
87
|
-
updatedAt: Schema.String,
|
|
88
|
-
session: Schema.NullOr(ThreadSessionSchema),
|
|
89
|
-
latestUserMessageAt: Schema.optionalKey(Schema.NullOr(Schema.String)),
|
|
90
|
-
messages: Schema.Array(ThreadMessageSchema),
|
|
91
|
-
activities: Schema.optionalKey(Schema.Array(Schema.Unknown)),
|
|
92
|
-
});
|
|
93
|
-
export type ThreadDetail = typeof ThreadDetailSchema.Type;
|
|
94
|
-
|
|
95
|
-
export const ShellSnapshotSchema = Schema.Struct({
|
|
96
|
-
snapshotSequence: Schema.Number,
|
|
97
|
-
projects: Schema.Array(ProjectShellSchema),
|
|
98
|
-
threads: Schema.Array(ThreadShellSchema),
|
|
99
|
-
updatedAt: Schema.String,
|
|
100
|
-
});
|
|
101
|
-
export type ShellSnapshot = typeof ShellSnapshotSchema.Type;
|
|
102
|
-
|
|
103
|
-
export const ServerProviderSchema = Schema.Struct({
|
|
104
|
-
instanceId: Schema.String,
|
|
105
|
-
displayName: Schema.optionalKey(Schema.String),
|
|
106
|
-
enabled: Schema.Boolean,
|
|
107
|
-
installed: Schema.Boolean,
|
|
108
|
-
status: Schema.Literals(["ready", "warning", "error", "disabled"]),
|
|
109
|
-
auth: Schema.Struct({
|
|
110
|
-
status: Schema.Literals(["authenticated", "unauthenticated", "unknown"]),
|
|
111
|
-
}),
|
|
112
|
-
models: Schema.Array(
|
|
113
|
-
Schema.Struct({
|
|
114
|
-
slug: Schema.String,
|
|
115
|
-
name: Schema.String,
|
|
116
|
-
}),
|
|
117
|
-
),
|
|
118
|
-
});
|
|
119
|
-
export type ServerProvider = typeof ServerProviderSchema.Type;
|
|
120
|
-
export type ServerProviderModel = NonNullable<ServerProvider["models"]>[number];
|
|
121
|
-
|
|
122
|
-
export const ServerConfigSchema = Schema.Struct({
|
|
123
|
-
providers: Schema.optionalKey(Schema.Array(ServerProviderSchema)),
|
|
124
|
-
});
|
|
125
|
-
export type ServerConfig = typeof ServerConfigSchema.Type;
|
|
126
|
-
|
|
127
|
-
export const ThreadMessageSentEventSchema = Schema.Struct({
|
|
128
|
-
type: Schema.Literal("thread.message-sent"),
|
|
129
|
-
payload: Schema.Struct({
|
|
130
|
-
messageId: Schema.String,
|
|
131
|
-
role: Schema.Literals(["user", "assistant", "system"]),
|
|
132
|
-
text: Schema.String,
|
|
133
|
-
turnId: Schema.NullOr(Schema.String),
|
|
134
|
-
streaming: Schema.optionalKey(Schema.Boolean),
|
|
135
|
-
createdAt: Schema.String,
|
|
136
|
-
updatedAt: Schema.String,
|
|
137
|
-
}),
|
|
138
|
-
});
|
|
139
|
-
export type ThreadMessageSentEvent = typeof ThreadMessageSentEventSchema.Type;
|
|
140
|
-
|
|
141
|
-
export const ThreadSessionSetEventSchema = Schema.Struct({
|
|
142
|
-
type: Schema.Literal("thread.session-set"),
|
|
143
|
-
payload: Schema.Struct({
|
|
144
|
-
session: Schema.NullOr(ThreadSessionSchema),
|
|
145
|
-
}),
|
|
146
|
-
});
|
|
147
|
-
export type ThreadSessionSetEvent = typeof ThreadSessionSetEventSchema.Type;
|
|
148
|
-
|
|
149
|
-
export const UnknownThreadEventSchema = Schema.Struct({
|
|
150
|
-
type: Schema.String,
|
|
151
|
-
payload: Schema.Record(Schema.String, Schema.Unknown),
|
|
152
|
-
});
|
|
153
|
-
export type UnknownThreadEvent = typeof UnknownThreadEventSchema.Type;
|
|
154
|
-
|
|
155
|
-
export const ThreadEventSchema = Schema.Union([
|
|
156
|
-
ThreadMessageSentEventSchema,
|
|
157
|
-
ThreadSessionSetEventSchema,
|
|
158
|
-
UnknownThreadEventSchema,
|
|
159
|
-
]);
|
|
160
|
-
export type ThreadEvent = typeof ThreadEventSchema.Type;
|
|
161
|
-
|
|
162
|
-
export const decodeModelSelection = Schema.decodeUnknownSync(ModelSelectionSchema);
|
package/src/protocol/schema.ts
DELETED
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
import * as Schema from "effect/Schema";
|
|
2
|
-
import { Rpc, RpcGroup } from "effect/unstable/rpc";
|
|
3
|
-
|
|
4
|
-
import {
|
|
5
|
-
ClientOrchestrationCommandSchema,
|
|
6
|
-
DispatchResultSchema,
|
|
7
|
-
} from "../domain/command-schema.ts";
|
|
8
|
-
import {
|
|
9
|
-
ProjectShellSchema,
|
|
10
|
-
ServerConfigSchema,
|
|
11
|
-
ShellSnapshotSchema,
|
|
12
|
-
ThreadDetailSchema,
|
|
13
|
-
ThreadEventSchema,
|
|
14
|
-
ThreadShellSchema,
|
|
15
|
-
} from "../domain/schema.ts";
|
|
16
|
-
import { RpcError } from "../rpc/error.ts";
|
|
17
|
-
|
|
18
|
-
export const ORCHESTRATION_WS_METHODS = {
|
|
19
|
-
dispatchCommand: "orchestration.dispatchCommand",
|
|
20
|
-
subscribeShell: "orchestration.subscribeShell",
|
|
21
|
-
subscribeThread: "orchestration.subscribeThread",
|
|
22
|
-
} as const;
|
|
23
|
-
|
|
24
|
-
export const WS_METHODS = {
|
|
25
|
-
serverGetConfig: "server.getConfig",
|
|
26
|
-
} as const;
|
|
27
|
-
|
|
28
|
-
export const ThreadStreamItemSchema = Schema.Union([
|
|
29
|
-
Schema.Struct({
|
|
30
|
-
kind: Schema.Literal("snapshot"),
|
|
31
|
-
snapshot: Schema.Struct({ thread: ThreadDetailSchema }),
|
|
32
|
-
}),
|
|
33
|
-
Schema.Struct({
|
|
34
|
-
kind: Schema.Literal("event"),
|
|
35
|
-
event: ThreadEventSchema,
|
|
36
|
-
}),
|
|
37
|
-
]);
|
|
38
|
-
export type ThreadStreamItem = typeof ThreadStreamItemSchema.Type;
|
|
39
|
-
|
|
40
|
-
export const ShellStreamItemSchema = Schema.Union([
|
|
41
|
-
Schema.Struct({
|
|
42
|
-
kind: Schema.Literal("snapshot"),
|
|
43
|
-
snapshot: ShellSnapshotSchema,
|
|
44
|
-
}),
|
|
45
|
-
Schema.Struct({
|
|
46
|
-
kind: Schema.Literal("project-upserted"),
|
|
47
|
-
sequence: Schema.Number,
|
|
48
|
-
project: ProjectShellSchema,
|
|
49
|
-
}),
|
|
50
|
-
Schema.Struct({
|
|
51
|
-
kind: Schema.Literal("project-removed"),
|
|
52
|
-
sequence: Schema.Number,
|
|
53
|
-
projectId: Schema.String,
|
|
54
|
-
}),
|
|
55
|
-
Schema.Struct({
|
|
56
|
-
kind: Schema.Literal("thread-upserted"),
|
|
57
|
-
sequence: Schema.Number,
|
|
58
|
-
thread: ThreadShellSchema,
|
|
59
|
-
}),
|
|
60
|
-
Schema.Struct({
|
|
61
|
-
kind: Schema.Literal("thread-removed"),
|
|
62
|
-
sequence: Schema.Number,
|
|
63
|
-
threadId: Schema.String,
|
|
64
|
-
}),
|
|
65
|
-
]);
|
|
66
|
-
export type ShellStreamItem = typeof ShellStreamItemSchema.Type;
|
|
67
|
-
|
|
68
|
-
export const WsOrchestrationDispatchCommandRpc = Rpc.make(
|
|
69
|
-
ORCHESTRATION_WS_METHODS.dispatchCommand,
|
|
70
|
-
{
|
|
71
|
-
payload: ClientOrchestrationCommandSchema,
|
|
72
|
-
success: DispatchResultSchema,
|
|
73
|
-
error: RpcError,
|
|
74
|
-
},
|
|
75
|
-
);
|
|
76
|
-
|
|
77
|
-
export const WsOrchestrationSubscribeShellRpc = Rpc.make(ORCHESTRATION_WS_METHODS.subscribeShell, {
|
|
78
|
-
payload: Schema.Struct({}),
|
|
79
|
-
success: ShellStreamItemSchema,
|
|
80
|
-
error: RpcError,
|
|
81
|
-
stream: true,
|
|
82
|
-
});
|
|
83
|
-
|
|
84
|
-
export const WsOrchestrationSubscribeThreadRpc = Rpc.make(
|
|
85
|
-
ORCHESTRATION_WS_METHODS.subscribeThread,
|
|
86
|
-
{
|
|
87
|
-
payload: Schema.Struct({ threadId: Schema.String }),
|
|
88
|
-
success: ThreadStreamItemSchema,
|
|
89
|
-
error: RpcError,
|
|
90
|
-
stream: true,
|
|
91
|
-
},
|
|
92
|
-
);
|
|
93
|
-
|
|
94
|
-
export const WsServerGetConfigRpc = Rpc.make(WS_METHODS.serverGetConfig, {
|
|
95
|
-
payload: Schema.Struct({}),
|
|
96
|
-
success: ServerConfigSchema,
|
|
97
|
-
error: RpcError,
|
|
98
|
-
});
|
|
99
|
-
|
|
100
|
-
export const WsRpcGroup = RpcGroup.make(
|
|
101
|
-
WsOrchestrationDispatchCommandRpc,
|
|
102
|
-
WsOrchestrationSubscribeShellRpc,
|
|
103
|
-
WsOrchestrationSubscribeThreadRpc,
|
|
104
|
-
WsServerGetConfigRpc,
|
|
105
|
-
);
|