paseo-dsh-direct 0.1.4
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/LICENSE +21 -0
- package/README.md +64 -0
- package/README.zh.md +64 -0
- package/dsh.svg +11 -0
- package/index.client.tsx +6 -0
- package/index.server.ts +19 -0
- package/package.json +80 -0
- package/paseo-plugin.json +10 -0
- package/scripts/build.mjs +31 -0
- package/scripts/install-lefthook.mjs +743 -0
- package/server/bridge-client.ts +416 -0
- package/server/dsh/bridge.ts +176 -0
- package/server/dsh/host.ts +204 -0
- package/server/dsh/service.ts +890 -0
- package/server/dsh-version.ts +71 -0
- package/server/plugin-version.ts +7 -0
- package/server/prompt-content.ts +120 -0
- package/server/provider.ts +1101 -0
- package/server/timeline.ts +487 -0
- package/server/turn-end.ts +41 -0
- package/server/values.ts +20 -0
- package/server/version-line.ts +50 -0
- package/shared/bridge-protocol.ts +232 -0
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
DshSessionEvent,
|
|
3
|
+
DshStreamFrame,
|
|
4
|
+
ModelSelection,
|
|
5
|
+
QuestionAnswer,
|
|
6
|
+
QuestionItem,
|
|
7
|
+
SessionSnapshot,
|
|
8
|
+
SessionSummary,
|
|
9
|
+
} from "../../shared/bridge-protocol.js";
|
|
10
|
+
|
|
11
|
+
/** Structural boundary owned by the installed Harness, never a second DSH runtime. */
|
|
12
|
+
export interface HostContext {
|
|
13
|
+
get<K extends keyof HostServices>(name: K): HostServices[K];
|
|
14
|
+
on<K extends keyof HostEvents>(event: K, listener: HostEvents[K]): () => void;
|
|
15
|
+
effect(callback: () => () => void | Promise<void>, label?: string): unknown;
|
|
16
|
+
}
|
|
17
|
+
export interface HostSession {
|
|
18
|
+
id: string;
|
|
19
|
+
header: SessionSummary;
|
|
20
|
+
snapshotEvents(): DshSessionEvent[];
|
|
21
|
+
requestHeader():
|
|
22
|
+
| {
|
|
23
|
+
config?: ModelSelection;
|
|
24
|
+
adapterDefaults?: { reasoningEffort?: boolean };
|
|
25
|
+
}
|
|
26
|
+
| undefined;
|
|
27
|
+
append(type: string, data: unknown): unknown;
|
|
28
|
+
}
|
|
29
|
+
export interface HostAgent {
|
|
30
|
+
id: string;
|
|
31
|
+
ctx: HostContext;
|
|
32
|
+
session: HostSession;
|
|
33
|
+
options: ModelSelection;
|
|
34
|
+
status: "idle" | "running";
|
|
35
|
+
followup(message: unknown): void;
|
|
36
|
+
steer(message: unknown): void;
|
|
37
|
+
cancel(
|
|
38
|
+
reason: { kind: "user" | "disposed" },
|
|
39
|
+
options?: { keepInbox: boolean },
|
|
40
|
+
): void;
|
|
41
|
+
whenIdle(): Promise<void>;
|
|
42
|
+
}
|
|
43
|
+
export interface HostHandle {
|
|
44
|
+
agent: HostAgent;
|
|
45
|
+
dispose(): Promise<void>;
|
|
46
|
+
}
|
|
47
|
+
export interface HostSkills {
|
|
48
|
+
list(options: { cwd?: string; scope?: object }): Promise<
|
|
49
|
+
Array<{
|
|
50
|
+
name: string;
|
|
51
|
+
description: string;
|
|
52
|
+
invocation?: { userInvocable?: boolean };
|
|
53
|
+
}>
|
|
54
|
+
>;
|
|
55
|
+
}
|
|
56
|
+
interface Preset {
|
|
57
|
+
id: string;
|
|
58
|
+
name?: string;
|
|
59
|
+
description?: string;
|
|
60
|
+
broken?: unknown;
|
|
61
|
+
}
|
|
62
|
+
interface AgentOptions {
|
|
63
|
+
sessionId?: string;
|
|
64
|
+
resumeSessionId?: string;
|
|
65
|
+
meta?: { cwd: string; agentPreset: string };
|
|
66
|
+
agentOptions: ModelSelection;
|
|
67
|
+
setup(ctx: HostContext, agent: HostAgent): Promise<void>;
|
|
68
|
+
}
|
|
69
|
+
export interface HostServices {
|
|
70
|
+
agents: {
|
|
71
|
+
get(id: string): HostAgent | undefined;
|
|
72
|
+
create(options: AgentOptions): Promise<HostHandle>;
|
|
73
|
+
resume(options: AgentOptions): Promise<HostHandle>;
|
|
74
|
+
};
|
|
75
|
+
sessionQuery: {
|
|
76
|
+
listSessions(): Promise<Array<{ header: SessionSummary }>>;
|
|
77
|
+
readSession(id: string): Promise<SessionSnapshot>;
|
|
78
|
+
readTitleSnapshots?(
|
|
79
|
+
ids: string[],
|
|
80
|
+
): Promise<
|
|
81
|
+
Array<
|
|
82
|
+
| { status: "fulfilled"; value: { title?: { title: string } } }
|
|
83
|
+
| { status: "rejected" }
|
|
84
|
+
>
|
|
85
|
+
>;
|
|
86
|
+
observeSession(
|
|
87
|
+
id: string,
|
|
88
|
+
options: { projectionMode: "all" },
|
|
89
|
+
): Promise<{
|
|
90
|
+
projections?: { values?: { agentPreset?: string | null } };
|
|
91
|
+
[Symbol.dispose](): void;
|
|
92
|
+
}>;
|
|
93
|
+
};
|
|
94
|
+
agentPresets: {
|
|
95
|
+
list(): Promise<Preset[]>;
|
|
96
|
+
resolve(id?: string): Promise<Preset>;
|
|
97
|
+
mount(ctx: HostContext, id: string): Promise<unknown>;
|
|
98
|
+
select(agent: HostAgent, id: string): Promise<string>;
|
|
99
|
+
serviceFor?(agent: HostAgent, name: "skills"): HostSkills | undefined;
|
|
100
|
+
defaultId: string;
|
|
101
|
+
};
|
|
102
|
+
skills: HostSkills | undefined;
|
|
103
|
+
systemPrompt?: {
|
|
104
|
+
section(definition: { name: string; order: number; text: string }): unknown;
|
|
105
|
+
};
|
|
106
|
+
attachments?: {
|
|
107
|
+
saveImage(input: {
|
|
108
|
+
data: Uint8Array;
|
|
109
|
+
mediaType: string;
|
|
110
|
+
name?: string;
|
|
111
|
+
}): Promise<unknown>;
|
|
112
|
+
saveFile(input: { data: Uint8Array; name?: string }): Promise<unknown>;
|
|
113
|
+
};
|
|
114
|
+
llm: {
|
|
115
|
+
listProviders(): Array<{ id: string; name?: string }>;
|
|
116
|
+
listModels(provider: string): Promise<Array<{ id: string; name?: string }>>;
|
|
117
|
+
resolveModelInfo?(
|
|
118
|
+
provider: string,
|
|
119
|
+
model: string,
|
|
120
|
+
): Promise<{
|
|
121
|
+
inputModalities?: readonly string[];
|
|
122
|
+
reasoning?: {
|
|
123
|
+
efforts?: Array<{ id: string; name: string; description?: string }>;
|
|
124
|
+
};
|
|
125
|
+
}>;
|
|
126
|
+
};
|
|
127
|
+
agentDefaultModel: { currentSelection(): ModelSelection } | undefined;
|
|
128
|
+
sessionTitle:
|
|
129
|
+
{ rename(session: HostSession, title: string): void } | undefined;
|
|
130
|
+
approval: object | undefined;
|
|
131
|
+
permissionPresets?: {
|
|
132
|
+
readonly names: readonly string[];
|
|
133
|
+
readonly defaultPreset: string;
|
|
134
|
+
optionOf(name: string): {
|
|
135
|
+
value: string;
|
|
136
|
+
name: string;
|
|
137
|
+
description?: string;
|
|
138
|
+
};
|
|
139
|
+
current(session: HostSession): string;
|
|
140
|
+
};
|
|
141
|
+
commands?: {
|
|
142
|
+
list(agent: HostAgent): readonly {
|
|
143
|
+
name: string;
|
|
144
|
+
description: string;
|
|
145
|
+
input?: { hint: string };
|
|
146
|
+
}[];
|
|
147
|
+
execute(
|
|
148
|
+
agent: HostAgent,
|
|
149
|
+
line: string,
|
|
150
|
+
attachments: readonly never[],
|
|
151
|
+
signal: AbortSignal,
|
|
152
|
+
): Promise<
|
|
153
|
+
| {
|
|
154
|
+
result: { kind: string; text?: string };
|
|
155
|
+
}
|
|
156
|
+
| undefined
|
|
157
|
+
>;
|
|
158
|
+
};
|
|
159
|
+
userQuestions: object | undefined;
|
|
160
|
+
appReady: { onReady(listener: () => void): () => void } | undefined;
|
|
161
|
+
appExit: ((code: number) => void) | undefined;
|
|
162
|
+
}
|
|
163
|
+
export interface ModelSelectionRef {
|
|
164
|
+
current: ModelSelection | undefined;
|
|
165
|
+
assembled: ModelSelection | undefined;
|
|
166
|
+
}
|
|
167
|
+
export interface HostHelpers {
|
|
168
|
+
installModelSelection(
|
|
169
|
+
ctx: HostContext,
|
|
170
|
+
selection: ModelSelectionRef,
|
|
171
|
+
): () => void;
|
|
172
|
+
}
|
|
173
|
+
export type ApprovalOutcome =
|
|
174
|
+
"allowed-once" | "rejected" | "cancelled" | "unavailable";
|
|
175
|
+
export interface HostEvents {
|
|
176
|
+
"session/created": (session: HostSession) => void;
|
|
177
|
+
"session/event": (session: HostSession, event: DshSessionEvent) => void;
|
|
178
|
+
"agent/assistant-stream": (payload: {
|
|
179
|
+
agent: HostAgent;
|
|
180
|
+
frame: DshStreamFrame;
|
|
181
|
+
}) => void;
|
|
182
|
+
"agent/status": (payload: {
|
|
183
|
+
agent: HostAgent;
|
|
184
|
+
status: "idle" | "running";
|
|
185
|
+
}) => void;
|
|
186
|
+
"approval/request": (
|
|
187
|
+
request: {
|
|
188
|
+
agent: HostAgent;
|
|
189
|
+
signal?: AbortSignal;
|
|
190
|
+
toolName: string;
|
|
191
|
+
callId?: string;
|
|
192
|
+
reason?: string;
|
|
193
|
+
},
|
|
194
|
+
next: () => Promise<ApprovalOutcome>,
|
|
195
|
+
) => Promise<ApprovalOutcome>;
|
|
196
|
+
"user-questions/request": (
|
|
197
|
+
request: {
|
|
198
|
+
agent?: HostAgent;
|
|
199
|
+
signal?: AbortSignal;
|
|
200
|
+
questions: QuestionItem[];
|
|
201
|
+
},
|
|
202
|
+
next: () => Promise<{ answers: QuestionAnswer[] }>,
|
|
203
|
+
) => Promise<{ answers: QuestionAnswer[] }>;
|
|
204
|
+
}
|