@qvac/core 0.6.6 → 0.7.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/CHANGELOG.md +185 -1
- package/README.md +2 -0
- package/dist-lib/lib/api/app-config.d.ts +3 -1
- package/dist-lib/lib/api/app-config.js +15 -4
- package/dist-lib/lib/assistant/fake-models.d.ts +22 -0
- package/dist-lib/lib/assistant/fake-models.js +112 -0
- package/dist-lib/lib/assistant/harness.d.ts +10 -0
- package/dist-lib/lib/assistant/harness.js +26 -0
- package/dist-lib/lib/assistant/history.d.ts +5 -1
- package/dist-lib/lib/assistant/history.js +14 -2
- package/dist-lib/lib/assistant-tree.d.ts +4 -0
- package/dist-lib/lib/assistant-tree.js +45 -7
- package/dist-lib/lib/assistant.d.ts +16 -2
- package/dist-lib/lib/assistant.js +184 -44
- package/dist-lib/lib/constants.d.ts +6 -0
- package/dist-lib/lib/constants.js +6 -0
- package/dist-lib/lib/core/chat-activity.d.ts +1 -1
- package/dist-lib/lib/core/chat-activity.js +3 -0
- package/dist-lib/lib/core/collections.d.ts +1 -0
- package/dist-lib/lib/core/collections.js +1 -0
- package/dist-lib/lib/core/contract/compute.d.ts +1 -1
- package/dist-lib/lib/core/contract/compute.js +2 -1
- package/dist-lib/lib/core/contract/index.js +6 -1
- package/dist-lib/lib/core/contract/invites.d.ts +1 -11
- package/dist-lib/lib/core/contract/invites.js +3 -3
- package/dist-lib/lib/core/contract/mesh-seeds.d.ts +2 -0
- package/dist-lib/lib/core/contract/mesh-seeds.js +26 -0
- package/dist-lib/lib/core/contract/open-join.d.ts +2 -0
- package/dist-lib/lib/core/contract/open-join.js +57 -0
- package/dist-lib/lib/core/departures.d.ts +3 -0
- package/dist-lib/lib/core/departures.js +44 -1
- package/dist-lib/lib/core/fs-drives.js +9 -6
- package/dist-lib/lib/core/handoff-channel.d.ts +1 -0
- package/dist-lib/lib/core/handoff-channel.js +7 -2
- package/dist-lib/lib/core/harness-loan.d.ts +1 -0
- package/dist-lib/lib/core/harness-loan.js +7 -2
- package/dist-lib/lib/core/identity.d.ts +1 -1
- package/dist-lib/lib/core/identity.js +6 -4
- package/dist-lib/lib/core/invite.d.ts +2 -0
- package/dist-lib/lib/core/invite.js +6 -2
- package/dist-lib/lib/core/membership.d.ts +1 -12
- package/dist-lib/lib/core/membership.js +1 -94
- package/dist-lib/lib/core/mesh.d.ts +8 -13
- package/dist-lib/lib/core/mesh.js +41 -87
- package/dist-lib/lib/core/protocol-pairing.d.ts +11 -0
- package/dist-lib/lib/core/protocol-pairing.js +22 -0
- package/dist-lib/lib/core/sync/index.js +2 -16
- package/dist-lib/lib/core.d.ts +43 -49
- package/dist-lib/lib/core.js +451 -909
- package/dist-lib/lib/diagnostics.d.ts +7 -0
- package/dist-lib/lib/diagnostics.js +22 -0
- package/dist-lib/lib/doctor/checks.d.ts +15 -0
- package/dist-lib/lib/doctor/checks.js +269 -0
- package/dist-lib/lib/doctor/redact.d.ts +4 -0
- package/dist-lib/lib/doctor/redact.js +31 -0
- package/dist-lib/lib/doctor/render.d.ts +8 -0
- package/dist-lib/lib/doctor/render.js +83 -0
- package/dist-lib/lib/doctor/tree.d.ts +5 -0
- package/dist-lib/lib/doctor/tree.js +167 -0
- package/dist-lib/lib/downloads-allowed-pusher.d.ts +10 -0
- package/dist-lib/lib/downloads-allowed-pusher.js +37 -0
- package/dist-lib/lib/guards.d.ts +1 -0
- package/dist-lib/lib/guards.js +4 -0
- package/dist-lib/lib/inference-calls.js +1 -5
- package/dist-lib/lib/kv-cache-reclaim.d.ts +2 -1
- package/dist-lib/lib/kv-cache-reclaim.js +24 -0
- package/dist-lib/lib/mesh-scoped-engine.js +1 -0
- package/dist-lib/lib/model-download-status.d.ts +1 -1
- package/dist-lib/lib/model-download.d.ts +9 -1
- package/dist-lib/lib/model-download.js +48 -3
- package/dist-lib/lib/model-memory-cap.d.ts +29 -0
- package/dist-lib/lib/model-memory-cap.js +69 -0
- package/dist-lib/lib/models-watch.d.ts +1 -1
- package/dist-lib/lib/models-watch.js +4 -4
- package/dist-lib/lib/oauth/flow.js +1 -1
- package/dist-lib/lib/oauth/loopback.js +16 -2
- package/dist-lib/lib/oauth/redirect-types.d.ts +1 -0
- package/dist-lib/lib/run-replay.d.ts +26 -0
- package/dist-lib/lib/run-replay.js +107 -0
- package/dist-lib/schema/config.d.ts +1 -1
- package/dist-lib/schema/config.js +1 -1
- package/dist-lib/schema/content.js +9 -1
- package/dist-lib/schema/engine.js +30 -5
- package/dist-lib/schema/local.js +3 -2
- package/dist-lib/schema/qvac.js +18 -1
- package/dist-lib/spec/bind.js +3 -0
- package/dist-lib/spec/calls.js +1 -0
- package/dist-lib/spec/capabilities.d.ts +2 -0
- package/dist-lib/spec/config/hyperconf/index.js +1 -1
- package/dist-lib/spec/hrpc/hrpc.json +13 -0
- package/dist-lib/spec/hrpc/index.js +15 -3
- package/dist-lib/spec/hrpc/messages.js +646 -557
- package/dist-lib/spec/hyperschema/index.js +646 -557
- package/dist-lib/spec/hyperschema/schema.json +80 -0
- package/dist-lib/spec/hyperschema/types.d.ts +20 -3
- package/dist-lib/spec/local/hyperdb/messages.js +22 -10
- package/dist-lib/spec/local/hyperschema/index.js +16 -7
- package/dist-lib/spec/local/hyperschema/schema.json +10 -1
- package/dist-lib/spec/local/hyperschema/types.d.ts +3 -2
- package/dist-lib/spec/mesh/hyperdb/db.json +16 -1
- package/dist-lib/spec/mesh/hyperdb/index.js +71 -2
- package/dist-lib/spec/mesh/hyperdb/messages.js +477 -240
- package/dist-lib/spec/mesh/hyperdispatch/dispatch.json +13 -1
- package/dist-lib/spec/mesh/hyperdispatch/index.js +35 -1
- package/dist-lib/spec/mesh/hyperdispatch/messages.js +180 -7
- package/dist-lib/spec/mesh/hyperschema/index.js +180 -7
- package/dist-lib/spec/mesh/hyperschema/schema.json +98 -1
- package/dist-lib/spec/mesh/hyperschema/types.d.ts +26 -2
- package/package.json +9 -17
- package/tui/README.md +7 -1
- package/tui/app.mjs +245 -11
- package/tui/boot.mjs +1 -0
- package/tui/index.mjs +1 -0
- package/tui/lib/render.mjs +25 -1
- package/worker/assistant-sidecar.mjs +5 -2
- package/dist-lib/lib/core/device-invites.d.ts +0 -11
- package/dist-lib/lib/core/device-invites.js +0 -63
- package/dist-lib/lib/core/grant-expiry.d.ts +0 -11
- package/dist-lib/lib/core/grant-expiry.js +0 -66
- package/dist-lib/lib/core/mesh-seed-handoff.d.ts +0 -27
- package/dist-lib/lib/core/mesh-seed-handoff.js +0 -53
- package/dist-lib/lib/oauth/loopback.stub.d.ts +0 -3
- package/dist-lib/lib/oauth/loopback.stub.js +0 -6
package/tui/boot.mjs
CHANGED
|
@@ -80,6 +80,7 @@ export async function boot(args) {
|
|
|
80
80
|
},
|
|
81
81
|
skillsDir,
|
|
82
82
|
harnessEntry,
|
|
83
|
+
fakeModels: args.fakeModels || process.env.QVAC_FAKE_MODELS === '1',
|
|
83
84
|
// only the image keys cross: the arg is argv, readable by anything that can list processes
|
|
84
85
|
imageEnv: Object.fromEntries(
|
|
85
86
|
Object.entries(process.env).filter(([key]) => key.startsWith('QVAC_IMAGE_'))
|
package/tui/index.mjs
CHANGED
|
@@ -13,6 +13,7 @@ const cmd = command(
|
|
|
13
13
|
flag('--storage|-s [dir]', 'a self-contained root, its own corestore and SDK home'),
|
|
14
14
|
flag('--temp', 'the same, in a throwaway dir'),
|
|
15
15
|
flag('--headless', 'no TUI: print the mesh invite and stream logs until ctrl+C'),
|
|
16
|
+
flag('--fake-models', 'adds the quack model: a deterministic fake LLM for testing without AI'),
|
|
16
17
|
flag('--version|-v', 'versions of core, harness and the SDK')
|
|
17
18
|
)
|
|
18
19
|
|
package/tui/lib/render.mjs
CHANGED
|
@@ -155,7 +155,24 @@ export function runInFlight(turns) {
|
|
|
155
155
|
return false
|
|
156
156
|
}
|
|
157
157
|
|
|
158
|
-
|
|
158
|
+
function awaitingDownloadText(model, runTurn, { selfId, downloads }) {
|
|
159
|
+
const row = selfId !== '' && runTurn.statusDeviceId === selfId ? downloads.get(model) : null
|
|
160
|
+
if (row?.phase === 'held') {
|
|
161
|
+
return `waiting for ${model} - /models download ${model}`
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
if (row?.phase === 'downloading') {
|
|
165
|
+
return `downloading ${model}: ${row.percentage ?? 0}%`
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
return `waiting for ${model} to be downloaded`
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
export function busyStatus(
|
|
172
|
+
modelState,
|
|
173
|
+
runTurn,
|
|
174
|
+
{ elapsed = Infinity, selfId = '', downloads = new Map() } = {}
|
|
175
|
+
) {
|
|
159
176
|
if (modelState?.status === 'loading') {
|
|
160
177
|
return { text: `loading ${modelState.model}…`, on: 'local' }
|
|
161
178
|
}
|
|
@@ -188,6 +205,13 @@ export function busyStatus(modelState, runTurn, elapsed) {
|
|
|
188
205
|
return { text: `queued - agent busy in ${progress.busyChatId}`, on: 'host' }
|
|
189
206
|
}
|
|
190
207
|
|
|
208
|
+
if (progress?.phase === 'awaiting-download') {
|
|
209
|
+
return {
|
|
210
|
+
text: awaitingDownloadText(progress.model, runTurn, { selfId, downloads }),
|
|
211
|
+
on: 'host'
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
|
|
191
215
|
if (progress?.phase === 'compacting') {
|
|
192
216
|
return { text: 'compacting conversation…', on: 'host' }
|
|
193
217
|
}
|
|
@@ -33,7 +33,8 @@ export default stowEntry((ipc) => {
|
|
|
33
33
|
app = undefined,
|
|
34
34
|
llm = DEFAULT_KV_CACHE,
|
|
35
35
|
hostsModelSource = true,
|
|
36
|
-
eager = true
|
|
36
|
+
eager = true,
|
|
37
|
+
fakeModels = false
|
|
37
38
|
} = JSON.parse(Bare.argv[2] || '{}')
|
|
38
39
|
|
|
39
40
|
const bootstrapNodes = bootstrapJson ? JSON.parse(bootstrapJson) : undefined
|
|
@@ -116,7 +117,9 @@ export default stowEntry((ipc) => {
|
|
|
116
117
|
eager
|
|
117
118
|
}),
|
|
118
119
|
onHarness: (harness, { engine }) => startCredentialPusher(harness, engine, logger),
|
|
119
|
-
|
|
120
|
+
runReplayDir: `${storage.root}/run-replay`,
|
|
121
|
+
logger,
|
|
122
|
+
fakeModels
|
|
120
123
|
})
|
|
121
124
|
)
|
|
122
125
|
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
export declare const DEVICE_INVITE_SPENT = "This device invite has already been used";
|
|
2
|
-
export interface DeviceInvites {
|
|
3
|
-
issue(): Promise<Buffer>;
|
|
4
|
-
redeem(token: Buffer | null | undefined, deviceId: Buffer): Promise<boolean>;
|
|
5
|
-
spent(token: Buffer | null | undefined, deviceId: Buffer): Promise<boolean>;
|
|
6
|
-
}
|
|
7
|
-
export interface DeviceInviteStore {
|
|
8
|
-
get(key: string): Promise<unknown>;
|
|
9
|
-
set(key: string, value: unknown): Promise<void>;
|
|
10
|
-
}
|
|
11
|
-
export declare function openDeviceInvites(store: DeviceInviteStore): DeviceInvites;
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
import crypto from 'hypercore-crypto';
|
|
2
|
-
import ScopeLock from 'scope-lock';
|
|
3
|
-
import { deviceInviteToken } from './identity.js';
|
|
4
|
-
import b4a from 'b4a';
|
|
5
|
-
const NONCES_KEY = 'device-invite-nonces';
|
|
6
|
-
const INVITE_TTL_MS = 48 * 60 * 60 * 1000;
|
|
7
|
-
const MAX_OUTSTANDING = 5;
|
|
8
|
-
export const DEVICE_INVITE_SPENT = 'This device invite has already been used';
|
|
9
|
-
export function openDeviceInvites(store) {
|
|
10
|
-
const lock = new ScopeLock();
|
|
11
|
-
async function outstanding() {
|
|
12
|
-
const value = await store.get(NONCES_KEY);
|
|
13
|
-
const now = Date.now();
|
|
14
|
-
return (Array.isArray(value) ? value : []).filter((entry) => typeof entry?.nonce === 'string' && now - entry.issuedAt < INVITE_TTL_MS);
|
|
15
|
-
}
|
|
16
|
-
function matching(issued, token, deviceId) {
|
|
17
|
-
return issued.findIndex(({ nonce }) => b4a.equals(deviceInviteToken(b4a.from(nonce, 'hex'), deviceId), token));
|
|
18
|
-
}
|
|
19
|
-
return {
|
|
20
|
-
async issue() {
|
|
21
|
-
const nonce = crypto.randomBytes(32);
|
|
22
|
-
await lock.lock();
|
|
23
|
-
try {
|
|
24
|
-
const issued = await outstanding();
|
|
25
|
-
const spent = issued.filter((entry) => entry.spent);
|
|
26
|
-
const kept = issued.filter((entry) => !entry.spent).slice(-(MAX_OUTSTANDING - 1));
|
|
27
|
-
await store.set(NONCES_KEY, [
|
|
28
|
-
...spent,
|
|
29
|
-
...kept,
|
|
30
|
-
{ nonce: b4a.toHex(nonce), issuedAt: Date.now() }
|
|
31
|
-
]);
|
|
32
|
-
}
|
|
33
|
-
finally {
|
|
34
|
-
lock.unlock();
|
|
35
|
-
}
|
|
36
|
-
return nonce;
|
|
37
|
-
},
|
|
38
|
-
async redeem(token, deviceId) {
|
|
39
|
-
if (!token)
|
|
40
|
-
return false;
|
|
41
|
-
await lock.lock();
|
|
42
|
-
try {
|
|
43
|
-
const issued = await outstanding();
|
|
44
|
-
const index = matching(issued, token, deviceId);
|
|
45
|
-
if (index === -1 || issued[index].spent) {
|
|
46
|
-
return false;
|
|
47
|
-
}
|
|
48
|
-
await store.set(NONCES_KEY, issued.map((entry, i) => (i === index ? { ...entry, spent: true } : entry)));
|
|
49
|
-
return true;
|
|
50
|
-
}
|
|
51
|
-
finally {
|
|
52
|
-
lock.unlock();
|
|
53
|
-
}
|
|
54
|
-
},
|
|
55
|
-
async spent(token, deviceId) {
|
|
56
|
-
if (!token)
|
|
57
|
-
return false;
|
|
58
|
-
const issued = await outstanding();
|
|
59
|
-
const index = matching(issued, token, deviceId);
|
|
60
|
-
return index !== -1 && issued[index].spent === true;
|
|
61
|
-
}
|
|
62
|
-
};
|
|
63
|
-
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import type { Mesh } from './mesh.ts';
|
|
2
|
-
export declare class GrantExpiry {
|
|
3
|
-
private readonly _mesh;
|
|
4
|
-
private readonly _onError;
|
|
5
|
-
private readonly _timer;
|
|
6
|
-
private _pass;
|
|
7
|
-
constructor(mesh: Mesh, onError: (err: unknown) => void);
|
|
8
|
-
refresh(): Promise<void>;
|
|
9
|
-
close(): void;
|
|
10
|
-
private _sweep;
|
|
11
|
-
}
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
import { liveDeviceForWriter } from './contract/activity.js';
|
|
2
|
-
import { DeadlineScheduler } from '../deadline.js';
|
|
3
|
-
import { MESH_INVITE_GRANTS } from './collections.js';
|
|
4
|
-
const MAX_DELAY_MS = 2 ** 31 - 1;
|
|
5
|
-
export class GrantExpiry {
|
|
6
|
-
_mesh;
|
|
7
|
-
_onError;
|
|
8
|
-
_timer;
|
|
9
|
-
_pass = Promise.resolve();
|
|
10
|
-
constructor(mesh, onError) {
|
|
11
|
-
this._mesh = mesh;
|
|
12
|
-
this._onError = onError;
|
|
13
|
-
this._timer = new DeadlineScheduler(() => void this.refresh());
|
|
14
|
-
}
|
|
15
|
-
refresh() {
|
|
16
|
-
this._pass = this._pass.then(() => this._sweep()).catch(this._onError);
|
|
17
|
-
return this._pass;
|
|
18
|
-
}
|
|
19
|
-
close() {
|
|
20
|
-
this._timer.clear();
|
|
21
|
-
}
|
|
22
|
-
async _sweep() {
|
|
23
|
-
const mesh = this._mesh;
|
|
24
|
-
this._timer.clear();
|
|
25
|
-
if (mesh.closing || !mesh.writable) {
|
|
26
|
-
return;
|
|
27
|
-
}
|
|
28
|
-
const now = Date.now();
|
|
29
|
-
const expired = [];
|
|
30
|
-
let soonest = Infinity;
|
|
31
|
-
const snap = mesh.view.snapshot();
|
|
32
|
-
try {
|
|
33
|
-
if (!(await liveDeviceForWriter(snap, mesh.localWriterKey))) {
|
|
34
|
-
return;
|
|
35
|
-
}
|
|
36
|
-
for await (const grant of snap.find(MESH_INVITE_GRANTS)) {
|
|
37
|
-
if (grant.revokedAt || !grant.expiresAt)
|
|
38
|
-
continue;
|
|
39
|
-
if (now > grant.expiresAt) {
|
|
40
|
-
expired.push(grant.grantKey);
|
|
41
|
-
}
|
|
42
|
-
else {
|
|
43
|
-
soonest = Math.min(soonest, grant.expiresAt);
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
finally {
|
|
48
|
-
await snap.close();
|
|
49
|
-
}
|
|
50
|
-
if (mesh.closing) {
|
|
51
|
-
return;
|
|
52
|
-
}
|
|
53
|
-
if (expired.length) {
|
|
54
|
-
const batch = mesh.batch();
|
|
55
|
-
for (const grantKey of expired) {
|
|
56
|
-
batch.dispatch('put-mesh-invite-grant', {
|
|
57
|
-
grant: { grantKey, revokedAt: now, updatedAt: now }
|
|
58
|
-
});
|
|
59
|
-
}
|
|
60
|
-
await batch.flush();
|
|
61
|
-
}
|
|
62
|
-
if (soonest !== Infinity && !mesh.closing) {
|
|
63
|
-
this._timer.schedule(Math.min(soonest, now + MAX_DELAY_MS));
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { type HandoffStream } from './handoff-channel.ts';
|
|
2
|
-
import type { AssistantMeshAdmissionRequest, AssistantMeshSeedRequest } from '../../spec/hyperschema/types.d.ts';
|
|
3
|
-
export { type HandoffStream };
|
|
4
|
-
export declare const SEED_REFUSED = "the device holding this mesh would not share its seed";
|
|
5
|
-
export declare const SEED_ASKER_UNSEEN = "the device holding this mesh has not seen the asking device yet";
|
|
6
|
-
export declare const ADMISSION_DEFERRED = "the device holding this mesh cannot admit the asking device yet";
|
|
7
|
-
export type MeshAdmissionRequest = AssistantMeshAdmissionRequest;
|
|
8
|
-
export type MeshSeedRequest = AssistantMeshSeedRequest | MeshAdmissionRequest;
|
|
9
|
-
export type MeshAdmissionClaim = Omit<MeshSeedRequest, 'meshKey'>;
|
|
10
|
-
export type MeshSeedResult = {
|
|
11
|
-
readonly seed: Buffer;
|
|
12
|
-
} | {
|
|
13
|
-
readonly admitted: true;
|
|
14
|
-
};
|
|
15
|
-
export type MeshSeedRequestHandler = (request: MeshSeedRequest, fromDeviceId: Uint8Array) => Promise<MeshSeedResult | null>;
|
|
16
|
-
export interface MeshSeedHandoffOptions {
|
|
17
|
-
readonly onrequest: MeshSeedRequestHandler;
|
|
18
|
-
readonly ackTimeoutMs?: number;
|
|
19
|
-
}
|
|
20
|
-
export declare class MeshSeedHandoff {
|
|
21
|
-
private readonly _channel;
|
|
22
|
-
constructor(opts: MeshSeedHandoffOptions);
|
|
23
|
-
addStream(stream: HandoffStream): void;
|
|
24
|
-
request(holderDeviceId: Uint8Array, meshKey: Buffer): Promise<Buffer | null>;
|
|
25
|
-
admit(holderDeviceId: Uint8Array, meshKey: Buffer, claim: MeshAdmissionClaim): Promise<boolean>;
|
|
26
|
-
destroy(): void;
|
|
27
|
-
}
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import { getStruct } from '../../spec/hyperschema/index.js';
|
|
2
|
-
import { HandoffChannel } from './handoff-channel.js';
|
|
3
|
-
const PROTOCOL = 'qvac/mesh-seed-handoff';
|
|
4
|
-
export {};
|
|
5
|
-
export const SEED_REFUSED = 'the device holding this mesh would not share its seed';
|
|
6
|
-
export const SEED_ASKER_UNSEEN = 'the device holding this mesh has not seen the asking device yet';
|
|
7
|
-
export const ADMISSION_DEFERRED = 'the device holding this mesh cannot admit the asking device yet';
|
|
8
|
-
const handoff = getStruct('@assistant/mesh-seed-handoff');
|
|
9
|
-
const handoffAck = getStruct('@assistant/mesh-seed-handoff-ack');
|
|
10
|
-
const admissionHandoff = getStruct('@assistant/mesh-admission-handoff');
|
|
11
|
-
export class MeshSeedHandoff {
|
|
12
|
-
_channel;
|
|
13
|
-
constructor(opts) {
|
|
14
|
-
this._channel = new HandoffChannel({
|
|
15
|
-
protocol: PROTOCOL,
|
|
16
|
-
requestEncoding: handoff,
|
|
17
|
-
extraRequestEncodings: [admissionHandoff],
|
|
18
|
-
ackEncoding: handoffAck,
|
|
19
|
-
onrequest: opts.onrequest,
|
|
20
|
-
buildAck: (id, error, result) => ({
|
|
21
|
-
id,
|
|
22
|
-
error: error || (result ? undefined : SEED_REFUSED),
|
|
23
|
-
seed: result && 'seed' in result ? result.seed : undefined,
|
|
24
|
-
admitted: result && 'admitted' in result ? true : undefined
|
|
25
|
-
}),
|
|
26
|
-
readAck: (ack) => ({
|
|
27
|
-
error: ack.error ?? '',
|
|
28
|
-
result: seedResult(ack)
|
|
29
|
-
}),
|
|
30
|
-
ackTimeoutMs: opts.ackTimeoutMs
|
|
31
|
-
});
|
|
32
|
-
}
|
|
33
|
-
addStream(stream) {
|
|
34
|
-
this._channel.addStream(stream);
|
|
35
|
-
}
|
|
36
|
-
async request(holderDeviceId, meshKey) {
|
|
37
|
-
const result = await this._channel.send(holderDeviceId, { meshKey });
|
|
38
|
-
return result && 'seed' in result ? result.seed : null;
|
|
39
|
-
}
|
|
40
|
-
async admit(holderDeviceId, meshKey, claim) {
|
|
41
|
-
const result = await this._channel.send(holderDeviceId, { meshKey, ...claim }, 1);
|
|
42
|
-
return !!result && 'admitted' in result;
|
|
43
|
-
}
|
|
44
|
-
destroy() {
|
|
45
|
-
this._channel.destroy();
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
function seedResult(ack) {
|
|
49
|
-
if (ack.admitted) {
|
|
50
|
-
return { admitted: true };
|
|
51
|
-
}
|
|
52
|
-
return ack.seed ? { seed: ack.seed } : null;
|
|
53
|
-
}
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import type { OAuthLoopbackServer, OAuthLoopbackTarget } from './redirect-types.ts';
|
|
2
|
-
export declare function abortOAuthLoopback(_credentialKey: string): Promise<boolean>;
|
|
3
|
-
export declare function openOAuthLoopback(_port: number, _target: OAuthLoopbackTarget): Promise<OAuthLoopbackServer>;
|