super-dsh 0.3.3 → 0.3.4-a
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 +15 -14
- package/agent-agy/package.json +6 -6
- package/agent-agy-sdk/package.json +5 -5
- package/agent-claude/package.json +8 -8
- package/agent-codex/package.json +7 -7
- package/agent-codex-sdk/package.json +7 -7
- package/agent-hermes/bridge/hermes-ws-bridge.py +273 -0
- package/agent-hermes/dist/agent.js +27 -4
- package/agent-hermes/dist/hermes-client.js +39 -10
- package/agent-hermes/dist/index.js +12 -3
- package/agent-hermes/package.json +7 -7
- package/agent-omp/package.json +8 -8
- package/agent-omp-sdk/package.json +8 -8
- package/agent-pi/package.json +7 -7
- package/client/index.js +106 -249
- package/cordis.patch.yml +0 -6
- package/package.json +23 -27
- package/remote/plugin.d.ts +93 -20
- package/remote/plugin.js +921 -452
- package/remote/provenance.json +15 -13
- package/superd-hub/dist/fusion-transport.js +0 -1
- package/superd-hub/lib/client/index.js +106 -249
- package/superd-hub/package.json +11 -11
- package/superd-hub/dist/bundle-setup.d.ts +0 -27
- package/superd-hub/dist/bundle-setup.js +0 -94
- package/superd-hub/dist/client/companion-api.d.ts +0 -5
- package/superd-hub/dist/client/companion-api.js +0 -30
- package/superd-hub/dist/companion-contract.d.ts +0 -9
- package/superd-hub/dist/companion-contract.js +0 -1
- package/superd-hub/dist/companions.d.ts +0 -30
- package/superd-hub/dist/companions.js +0 -211
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
/** Local ctx0 companion management, independent of the selected agent world. */
|
|
2
|
-
import { mintRpcId } from './runtime-settings-api.js';
|
|
3
|
-
export async function callCompanion(operation, doFetch) {
|
|
4
|
-
const method = `superdCompanions/${operation}`;
|
|
5
|
-
const send = doFetch ?? ((path, init) => fetch(path, init));
|
|
6
|
-
const response = await send(`/api/${method}`, {
|
|
7
|
-
method: 'POST', credentials: 'same-origin', headers: { 'content-type': 'application/json' },
|
|
8
|
-
body: JSON.stringify({ type: 'client-request', rpcId: mintRpcId(), method, payload: { args: {} } }),
|
|
9
|
-
});
|
|
10
|
-
if (!response.ok)
|
|
11
|
-
throw new Error(`Better Dash: HTTP ${response.status}`);
|
|
12
|
-
let body;
|
|
13
|
-
try {
|
|
14
|
-
body = JSON.parse(await response.text());
|
|
15
|
-
}
|
|
16
|
-
catch {
|
|
17
|
-
throw new Error('Better Dash: unreadable response');
|
|
18
|
-
}
|
|
19
|
-
const result = body?.result;
|
|
20
|
-
if (result?.ok !== true)
|
|
21
|
-
throw new Error(result?.error?.message ?? 'Better Dash: request failed');
|
|
22
|
-
const value = result.value;
|
|
23
|
-
if (value === null || typeof value !== 'object' || typeof value.installed !== 'boolean'
|
|
24
|
-
|| typeof value.installing !== 'boolean' || typeof value.requestedVersion !== 'string'
|
|
25
|
-
|| (value.version !== undefined && typeof value.version !== 'string')
|
|
26
|
-
|| (value.enabled !== undefined && typeof value.enabled !== 'boolean')
|
|
27
|
-
|| (value.error !== undefined && typeof value.error !== 'string'))
|
|
28
|
-
throw new Error('Better Dash: invalid status');
|
|
29
|
-
return value;
|
|
30
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import type { ProfileContext } from '@deepseek-ai/dsh-app-boot';
|
|
2
|
-
import type { PluginManager } from '@deepseek-ai/dsh-plugin-manager';
|
|
3
|
-
import type { BetterDashStatus } from './companion-contract.js';
|
|
4
|
-
type Manager = Pick<PluginManager, 'listBundles' | 'installBundle'>;
|
|
5
|
-
/** One controller per native profile; no package, registry, HMR or selection writer of its own. */
|
|
6
|
-
export declare class BetterDashCompanion {
|
|
7
|
-
private readonly version;
|
|
8
|
-
private readonly manager;
|
|
9
|
-
private readonly directory;
|
|
10
|
-
private readonly receipt;
|
|
11
|
-
private readonly legacy;
|
|
12
|
-
private initialized?;
|
|
13
|
-
private intent;
|
|
14
|
-
private active?;
|
|
15
|
-
private stopped;
|
|
16
|
-
private restartNotice?;
|
|
17
|
-
constructor(profile: Pick<ProfileContext, 'home' | 'dir'>, version: string, manager: () => Manager | undefined);
|
|
18
|
-
private initialize;
|
|
19
|
-
private cleanLegacy;
|
|
20
|
-
private save;
|
|
21
|
-
getBetterDash(): Promise<BetterDashStatus>;
|
|
22
|
-
ensureAutomatic(): Promise<BetterDashStatus>;
|
|
23
|
-
installBetterDash(): Promise<BetterDashStatus>;
|
|
24
|
-
private run;
|
|
25
|
-
private install;
|
|
26
|
-
/** Read-only observation: an intermediate native event must never trigger reinstatement. */
|
|
27
|
-
observeNativeChange(): Promise<BetterDashStatus>;
|
|
28
|
-
dispose(): void;
|
|
29
|
-
}
|
|
30
|
-
export {};
|
|
@@ -1,211 +0,0 @@
|
|
|
1
|
-
/** Companion intent and the single native installation operation. */
|
|
2
|
-
import { createHash } from 'node:crypto';
|
|
3
|
-
import { readFile, mkdir, unlink, rmdir } from 'node:fs/promises';
|
|
4
|
-
import { join, dirname } from 'node:path';
|
|
5
|
-
import { writeFileAtomic } from '@deepseek-ai/dsh-atomic-write';
|
|
6
|
-
// done marks a CONFIRMED first use (Better observed installed); removed marks a
|
|
7
|
-
// migrated legacy removal record. A receipt with attempted but neither done,
|
|
8
|
-
// error, nor removed is an interrupted first use — e.g. killed by the restart
|
|
9
|
-
// that installing Super itself triggers — and must re-arm, not suppress, the retry.
|
|
10
|
-
const message = (error) => error instanceof Error ? error.message : String(error);
|
|
11
|
-
async function optionalJson(path) {
|
|
12
|
-
try {
|
|
13
|
-
return JSON.parse(await readFile(path, 'utf8'));
|
|
14
|
-
}
|
|
15
|
-
catch (error) {
|
|
16
|
-
if (error.code === 'ENOENT')
|
|
17
|
-
return undefined;
|
|
18
|
-
throw error;
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
function nativeFailure(result) {
|
|
22
|
-
if ((result.application === 'applied' || result.application === 'restart-required') && result.error === undefined
|
|
23
|
-
&& (result.packageResult === undefined || result.packageResult.exitCode === 0))
|
|
24
|
-
return undefined;
|
|
25
|
-
return [result.application, result.error?.code, result.error?.diagnostic,
|
|
26
|
-
result.packageResult?.kind, result.packageResult?.logPath].filter(Boolean).join(': ');
|
|
27
|
-
}
|
|
28
|
-
/** One controller per native profile; no package, registry, HMR or selection writer of its own. */
|
|
29
|
-
export class BetterDashCompanion {
|
|
30
|
-
version;
|
|
31
|
-
manager;
|
|
32
|
-
directory;
|
|
33
|
-
receipt;
|
|
34
|
-
legacy;
|
|
35
|
-
initialized;
|
|
36
|
-
intent = { attempted: false };
|
|
37
|
-
active;
|
|
38
|
-
stopped = false;
|
|
39
|
-
restartNotice;
|
|
40
|
-
constructor(profile, version, manager) {
|
|
41
|
-
this.version = version;
|
|
42
|
-
this.manager = manager;
|
|
43
|
-
const key = createHash('sha256').update(profile.dir).digest('hex') + '.json';
|
|
44
|
-
this.directory = join(profile.home, 'superd', 'companions');
|
|
45
|
-
this.receipt = join(this.directory, key);
|
|
46
|
-
this.legacy = join(profile.home, 'companion-registration', key);
|
|
47
|
-
}
|
|
48
|
-
initialize() {
|
|
49
|
-
return this.initialized ??= (async () => {
|
|
50
|
-
const saved = await optionalJson(this.receipt);
|
|
51
|
-
if (saved !== undefined) {
|
|
52
|
-
// Never-resurrect applies to a CONFIRMED first use, a recorded failure,
|
|
53
|
-
// or a migrated removal record; an interrupted first use (no done, no
|
|
54
|
-
// error, no removal marker) re-arms.
|
|
55
|
-
this.intent = saved.attempted && saved.done !== true && saved.error === undefined && saved.removed !== true
|
|
56
|
-
? { attempted: false } : saved;
|
|
57
|
-
await this.cleanLegacy();
|
|
58
|
-
return;
|
|
59
|
-
}
|
|
60
|
-
const old = await optionalJson(this.legacy);
|
|
61
|
-
// Any old registration was first use. An absent Better now means removal,
|
|
62
|
-
// including when Super has since changed version; never resurrect it.
|
|
63
|
-
if (old?.['super-dsh:better-dsh'] !== undefined) {
|
|
64
|
-
this.intent = { attempted: true, removed: true };
|
|
65
|
-
await this.save();
|
|
66
|
-
await this.cleanLegacy();
|
|
67
|
-
}
|
|
68
|
-
})();
|
|
69
|
-
}
|
|
70
|
-
async cleanLegacy() {
|
|
71
|
-
try {
|
|
72
|
-
await unlink(this.legacy);
|
|
73
|
-
}
|
|
74
|
-
catch (error) {
|
|
75
|
-
if (error.code !== 'ENOENT')
|
|
76
|
-
throw error;
|
|
77
|
-
}
|
|
78
|
-
try {
|
|
79
|
-
await rmdir(dirname(this.legacy));
|
|
80
|
-
}
|
|
81
|
-
catch (error) {
|
|
82
|
-
if (!['ENOENT', 'ENOTEMPTY'].includes(error.code ?? ''))
|
|
83
|
-
throw error;
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
async save() {
|
|
87
|
-
await mkdir(this.directory, { recursive: true, mode: 0o700 });
|
|
88
|
-
await writeFileAtomic(this.receipt, JSON.stringify(this.intent) + '\n', { mode: 0o600 });
|
|
89
|
-
}
|
|
90
|
-
async getBetterDash() {
|
|
91
|
-
const status = { installed: false, installing: this.active !== undefined, requestedVersion: this.version };
|
|
92
|
-
try {
|
|
93
|
-
await this.initialize();
|
|
94
|
-
const manager = this.manager();
|
|
95
|
-
if (manager === undefined)
|
|
96
|
-
throw new Error('Native Plugin Manager is unavailable; enable it and retry Install in Settings.');
|
|
97
|
-
const better = (await manager.listBundles()).find(bundle => bundle.name === 'better-dsh' && bundle.installed);
|
|
98
|
-
if (better !== undefined) {
|
|
99
|
-
status.installed = true;
|
|
100
|
-
if (better.version !== undefined)
|
|
101
|
-
status.version = better.version;
|
|
102
|
-
status.enabled = better.enabled;
|
|
103
|
-
// An installed dependency alone does not prove application succeeded:
|
|
104
|
-
// native configure can fail after writing that dependency. Only a
|
|
105
|
-
// missing -> installed recovery clears a previous failure here.
|
|
106
|
-
if (this.active === undefined && this.intent.attempted
|
|
107
|
-
&& (this.intent.done !== true || (this.intent.error !== undefined && this.intent.missingAfterFailure === true))) {
|
|
108
|
-
this.intent.done = true;
|
|
109
|
-
delete this.intent.error;
|
|
110
|
-
delete this.intent.missingAfterFailure;
|
|
111
|
-
await this.save();
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
else {
|
|
115
|
-
this.restartNotice = undefined;
|
|
116
|
-
if (this.active === undefined && this.intent.error !== undefined && this.intent.missingAfterFailure !== true) {
|
|
117
|
-
this.intent.missingAfterFailure = true;
|
|
118
|
-
await this.save();
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
const error = this.intent.error ?? this.restartNotice;
|
|
122
|
-
if (error !== undefined)
|
|
123
|
-
status.error = error;
|
|
124
|
-
}
|
|
125
|
-
catch (error) {
|
|
126
|
-
status.error = message(error);
|
|
127
|
-
}
|
|
128
|
-
return status;
|
|
129
|
-
}
|
|
130
|
-
ensureAutomatic() { return this.run(false); }
|
|
131
|
-
installBetterDash() { return this.run(true); }
|
|
132
|
-
run(manual) {
|
|
133
|
-
if (this.active !== undefined)
|
|
134
|
-
return this.active;
|
|
135
|
-
const task = this.install(manual).catch(async (error) => {
|
|
136
|
-
this.intent.error = `Better Dash installation failed: ${message(error)}. Check Better Dash in Plugin Manager; if missing, retry Install in Settings.`;
|
|
137
|
-
const status = await this.getBetterDash();
|
|
138
|
-
this.intent.missingAfterFailure = !status.installed;
|
|
139
|
-
try {
|
|
140
|
-
await this.save();
|
|
141
|
-
}
|
|
142
|
-
catch { /* Report the operation error even when persistence is unavailable. */ }
|
|
143
|
-
return status;
|
|
144
|
-
}).then(status => ({ ...status, installing: false })).finally(() => { this.active = undefined; });
|
|
145
|
-
this.active = task;
|
|
146
|
-
return task;
|
|
147
|
-
}
|
|
148
|
-
async install(manual) {
|
|
149
|
-
await this.initialize();
|
|
150
|
-
const before = await this.getBetterDash();
|
|
151
|
-
if (this.stopped)
|
|
152
|
-
return before;
|
|
153
|
-
if (before.installed) {
|
|
154
|
-
this.intent.attempted = true;
|
|
155
|
-
this.intent.done = true;
|
|
156
|
-
if (this.intent.missingAfterFailure === true) {
|
|
157
|
-
delete this.intent.error;
|
|
158
|
-
delete this.intent.missingAfterFailure;
|
|
159
|
-
}
|
|
160
|
-
await this.save();
|
|
161
|
-
return this.getBetterDash(); // Native disablement and installed versions belong to the user.
|
|
162
|
-
}
|
|
163
|
-
// Native changed notifications enter through this operation, so its
|
|
164
|
-
// read is active and deliberately cannot update the receipt itself.
|
|
165
|
-
// Record removal here even when first-use installation is already done.
|
|
166
|
-
if (this.intent.error !== undefined && this.intent.missingAfterFailure !== true) {
|
|
167
|
-
this.intent.missingAfterFailure = true;
|
|
168
|
-
await this.save();
|
|
169
|
-
}
|
|
170
|
-
if (!manual && this.intent.attempted)
|
|
171
|
-
return before;
|
|
172
|
-
this.intent = { attempted: true };
|
|
173
|
-
await this.save(); // First use is durable before native HMR can unload this row.
|
|
174
|
-
const manager = this.manager();
|
|
175
|
-
if (manager === undefined)
|
|
176
|
-
throw new Error('Native Plugin Manager is unavailable');
|
|
177
|
-
if (this.version === 'unknown' || this.version.trim() === '')
|
|
178
|
-
throw new Error('The installed Super Dash package version could not be read');
|
|
179
|
-
const failures = [];
|
|
180
|
-
for (const spec of [`better-dsh@${this.version}`, 'better-dsh@latest', 'better-dsh']) {
|
|
181
|
-
if (this.stopped)
|
|
182
|
-
break;
|
|
183
|
-
try {
|
|
184
|
-
const result = await manager.installBundle(spec);
|
|
185
|
-
const failure = nativeFailure(result);
|
|
186
|
-
if (failure === undefined) {
|
|
187
|
-
const after = await this.getBetterDash();
|
|
188
|
-
if (after.installed) {
|
|
189
|
-
this.intent.done = true;
|
|
190
|
-
delete this.intent.error;
|
|
191
|
-
delete this.intent.missingAfterFailure;
|
|
192
|
-
this.restartNotice = result.application === 'restart-required'
|
|
193
|
-
? 'Better Dash is installed; restart DSH to apply the native change.' : undefined;
|
|
194
|
-
await this.save();
|
|
195
|
-
return this.getBetterDash();
|
|
196
|
-
}
|
|
197
|
-
failures.push(`${spec}: native manager reported ${result.application}, but Better Dash is not installed`);
|
|
198
|
-
}
|
|
199
|
-
else
|
|
200
|
-
failures.push(`${spec}: ${failure}`);
|
|
201
|
-
}
|
|
202
|
-
catch (error) {
|
|
203
|
-
failures.push(`${spec}: ${message(error)}`);
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
|
-
throw new Error(failures.join('; ') || 'Super Dash companion component was unloaded');
|
|
207
|
-
}
|
|
208
|
-
/** Read-only observation: an intermediate native event must never trigger reinstatement. */
|
|
209
|
-
async observeNativeChange() { return this.getBetterDash(); }
|
|
210
|
-
dispose() { this.stopped = true; }
|
|
211
|
-
}
|