@qvac/core 0.6.7 → 0.7.1

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.
Files changed (146) hide show
  1. package/CHANGELOG.md +211 -1
  2. package/README.md +2 -0
  3. package/dist-lib/lib/api/app-config.d.ts +3 -1
  4. package/dist-lib/lib/api/app-config.js +15 -4
  5. package/dist-lib/lib/api/chat.d.ts +1 -1
  6. package/dist-lib/lib/api/chat.js +9 -0
  7. package/dist-lib/lib/api/index.d.ts +2 -1
  8. package/dist-lib/lib/api/index.js +2 -1
  9. package/dist-lib/lib/api/network.d.ts +8 -1
  10. package/dist-lib/lib/api/network.js +6 -0
  11. package/dist-lib/lib/assistant/fake-models.d.ts +22 -0
  12. package/dist-lib/lib/assistant/fake-models.js +112 -0
  13. package/dist-lib/lib/assistant/harness.d.ts +12 -0
  14. package/dist-lib/lib/assistant/harness.js +26 -0
  15. package/dist-lib/lib/assistant/history.d.ts +5 -1
  16. package/dist-lib/lib/assistant/history.js +14 -2
  17. package/dist-lib/lib/assistant-tree.d.ts +4 -0
  18. package/dist-lib/lib/assistant-tree.js +45 -7
  19. package/dist-lib/lib/assistant.d.ts +15 -2
  20. package/dist-lib/lib/assistant.js +181 -42
  21. package/dist-lib/lib/constants.d.ts +6 -0
  22. package/dist-lib/lib/constants.js +6 -0
  23. package/dist-lib/lib/core/agent.d.ts +2 -0
  24. package/dist-lib/lib/core/agent.js +16 -5
  25. package/dist-lib/lib/core/blind-peers.d.ts +4 -0
  26. package/dist-lib/lib/core/blind-peers.js +1 -0
  27. package/dist-lib/lib/core/chat-activity.d.ts +1 -1
  28. package/dist-lib/lib/core/chat-activity.js +3 -0
  29. package/dist-lib/lib/core/chat-copy.d.ts +4 -0
  30. package/dist-lib/lib/core/chat-copy.js +1 -1
  31. package/dist-lib/lib/core/chat-fork.d.ts +21 -0
  32. package/dist-lib/lib/core/chat-fork.js +245 -0
  33. package/dist-lib/lib/core/chat-move.js +1 -4
  34. package/dist-lib/lib/core/chat.d.ts +1 -0
  35. package/dist-lib/lib/core/chat.js +1 -1
  36. package/dist-lib/lib/core/collections.d.ts +1 -0
  37. package/dist-lib/lib/core/collections.js +1 -0
  38. package/dist-lib/lib/core/contract/compute.d.ts +1 -1
  39. package/dist-lib/lib/core/contract/compute.js +2 -1
  40. package/dist-lib/lib/core/contract/index.js +6 -1
  41. package/dist-lib/lib/core/contract/invites.d.ts +1 -11
  42. package/dist-lib/lib/core/contract/invites.js +3 -3
  43. package/dist-lib/lib/core/contract/mesh-seeds.d.ts +2 -0
  44. package/dist-lib/lib/core/contract/mesh-seeds.js +26 -0
  45. package/dist-lib/lib/core/contract/open-join.d.ts +2 -0
  46. package/dist-lib/lib/core/contract/open-join.js +57 -0
  47. package/dist-lib/lib/core/departures.d.ts +8 -1
  48. package/dist-lib/lib/core/departures.js +59 -2
  49. package/dist-lib/lib/core/fs-drives.d.ts +8 -1
  50. package/dist-lib/lib/core/fs-drives.js +47 -15
  51. package/dist-lib/lib/core/harness-loan.d.ts +4 -20
  52. package/dist-lib/lib/core/harness-loan.js +7 -184
  53. package/dist-lib/lib/core/id.d.ts +1 -0
  54. package/dist-lib/lib/core/id.js +3 -0
  55. package/dist-lib/lib/core/identity.d.ts +1 -1
  56. package/dist-lib/lib/core/identity.js +6 -4
  57. package/dist-lib/lib/core/invite.d.ts +2 -0
  58. package/dist-lib/lib/core/invite.js +6 -2
  59. package/dist-lib/lib/core/membership.d.ts +1 -12
  60. package/dist-lib/lib/core/membership.js +1 -94
  61. package/dist-lib/lib/core/mesh.d.ts +11 -15
  62. package/dist-lib/lib/core/mesh.js +52 -88
  63. package/dist-lib/lib/core/migrations/agent-tools-scope.d.ts +2 -0
  64. package/dist-lib/lib/core/migrations/agent-tools-scope.js +24 -0
  65. package/dist-lib/lib/core/migrations/index.js +3 -1
  66. package/dist-lib/lib/core/peer-duplex.d.ts +32 -0
  67. package/dist-lib/lib/core/peer-duplex.js +207 -0
  68. package/dist-lib/lib/core/sync/index.js +2 -16
  69. package/dist-lib/lib/core.d.ts +47 -50
  70. package/dist-lib/lib/core.js +524 -878
  71. package/dist-lib/lib/diagnostics.d.ts +7 -0
  72. package/dist-lib/lib/diagnostics.js +22 -0
  73. package/dist-lib/lib/doctor/checks.d.ts +15 -0
  74. package/dist-lib/lib/doctor/checks.js +272 -0
  75. package/dist-lib/lib/doctor/redact.d.ts +4 -0
  76. package/dist-lib/lib/doctor/redact.js +31 -0
  77. package/dist-lib/lib/doctor/render.d.ts +8 -0
  78. package/dist-lib/lib/doctor/render.js +83 -0
  79. package/dist-lib/lib/doctor/tree.d.ts +5 -0
  80. package/dist-lib/lib/doctor/tree.js +167 -0
  81. package/dist-lib/lib/downloads-allowed-pusher.d.ts +10 -0
  82. package/dist-lib/lib/downloads-allowed-pusher.js +37 -0
  83. package/dist-lib/lib/guards.d.ts +1 -0
  84. package/dist-lib/lib/guards.js +4 -0
  85. package/dist-lib/lib/inference-calls.js +1 -5
  86. package/dist-lib/lib/kv-cache-reclaim.d.ts +2 -1
  87. package/dist-lib/lib/kv-cache-reclaim.js +24 -0
  88. package/dist-lib/lib/mesh-scoped-engine.js +4 -0
  89. package/dist-lib/lib/model-download-status.d.ts +1 -1
  90. package/dist-lib/lib/model-download.d.ts +9 -10
  91. package/dist-lib/lib/model-download.js +49 -16
  92. package/dist-lib/lib/model-memory-cap.d.ts +29 -0
  93. package/dist-lib/lib/model-memory-cap.js +69 -0
  94. package/dist-lib/lib/models-watch.d.ts +1 -1
  95. package/dist-lib/lib/models-watch.js +4 -4
  96. package/dist-lib/lib/oauth/flow.js +1 -1
  97. package/dist-lib/lib/oauth/loopback.js +16 -2
  98. package/dist-lib/lib/oauth/redirect-types.d.ts +1 -0
  99. package/dist-lib/lib/run-replay.d.ts +26 -0
  100. package/dist-lib/lib/run-replay.js +107 -0
  101. package/dist-lib/schema/config.d.ts +1 -1
  102. package/dist-lib/schema/config.js +1 -1
  103. package/dist-lib/schema/content.js +9 -1
  104. package/dist-lib/schema/engine.js +75 -6
  105. package/dist-lib/schema/field-order.js +1 -1
  106. package/dist-lib/schema/local.js +3 -2
  107. package/dist-lib/schema/qvac.js +28 -2
  108. package/dist-lib/spec/bind.js +17 -0
  109. package/dist-lib/spec/calls.js +4 -0
  110. package/dist-lib/spec/capabilities.d.ts +8 -0
  111. package/dist-lib/spec/config/hyperconf/index.js +1 -1
  112. package/dist-lib/spec/hrpc/hrpc.json +52 -0
  113. package/dist-lib/spec/hrpc/index.js +53 -4
  114. package/dist-lib/spec/hrpc/messages.js +1498 -1278
  115. package/dist-lib/spec/hyperschema/index.js +1498 -1278
  116. package/dist-lib/spec/hyperschema/schema.json +182 -0
  117. package/dist-lib/spec/hyperschema/types.d.ts +49 -3
  118. package/dist-lib/spec/local/hyperdb/messages.js +22 -10
  119. package/dist-lib/spec/local/hyperschema/index.js +16 -7
  120. package/dist-lib/spec/local/hyperschema/schema.json +10 -1
  121. package/dist-lib/spec/local/hyperschema/types.d.ts +3 -2
  122. package/dist-lib/spec/mesh/hyperdb/db.json +16 -1
  123. package/dist-lib/spec/mesh/hyperdb/index.js +71 -2
  124. package/dist-lib/spec/mesh/hyperdb/messages.js +530 -246
  125. package/dist-lib/spec/mesh/hyperdispatch/dispatch.json +13 -1
  126. package/dist-lib/spec/mesh/hyperdispatch/index.js +35 -1
  127. package/dist-lib/spec/mesh/hyperdispatch/messages.js +223 -10
  128. package/dist-lib/spec/mesh/hyperschema/index.js +223 -10
  129. package/dist-lib/spec/mesh/hyperschema/schema.json +128 -1
  130. package/dist-lib/spec/mesh/hyperschema/types.d.ts +34 -2
  131. package/package.json +14 -19
  132. package/tui/README.md +7 -1
  133. package/tui/app.mjs +366 -78
  134. package/tui/boot.mjs +1 -0
  135. package/tui/index.mjs +1 -0
  136. package/tui/lib/fork-command.mjs +43 -0
  137. package/tui/lib/render.mjs +25 -1
  138. package/worker/assistant-sidecar.mjs +5 -2
  139. package/dist-lib/lib/core/device-invites.d.ts +0 -11
  140. package/dist-lib/lib/core/device-invites.js +0 -63
  141. package/dist-lib/lib/core/grant-expiry.d.ts +0 -11
  142. package/dist-lib/lib/core/grant-expiry.js +0 -66
  143. package/dist-lib/lib/core/mesh-seed-handoff.d.ts +0 -27
  144. package/dist-lib/lib/core/mesh-seed-handoff.js +0 -53
  145. package/dist-lib/lib/oauth/loopback.stub.d.ts +0 -3
  146. 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
 
@@ -0,0 +1,43 @@
1
+ export const FORK_USAGE = 'usage: /chat fork [turn] [before] · /mesh fork <n|id> [turn] [before]'
2
+
3
+ // `[turn] [before]` to a forkChat cut: turn n is the n-th message, through its answer or before it
4
+ export function forkCut(chunks, args) {
5
+ const [turn, mode, ...extra] = args
6
+ if (!turn) {
7
+ return { request: {}, label: 'every finished turn' }
8
+ }
9
+
10
+ const n = Number(turn)
11
+ if (!Number.isInteger(n) || n < 1 || (mode && mode !== 'before') || extra.length > 0) {
12
+ return { miss: FORK_USAGE }
13
+ }
14
+
15
+ const before = mode === 'before'
16
+ const runId = turnRunId(chunks, { n, before })
17
+ if (!runId) {
18
+ return { miss: `turn ${n} has no answer to fork at` }
19
+ }
20
+
21
+ return {
22
+ request: { runId, exclusive: before },
23
+ label: before ? `everything before turn ${n}` : `through turn ${n}`
24
+ }
25
+ }
26
+
27
+ // a retry answers the same message again, so `through` takes its last answer and `before` its first
28
+ function turnRunId(chunks, { n, before }) {
29
+ const messages = chunks.filter((chunk) => chunk.type === 'user-message' && !chunk.runId)
30
+ const message = messages[n - 1]
31
+ if (!message) {
32
+ return null
33
+ }
34
+
35
+ const next = messages[n]?.seq ?? Infinity
36
+ const answers = chunks.filter(
37
+ (chunk) =>
38
+ chunk.type === 'run-request' && chunk.seq > message.seq && chunk.seq < next && chunk.runId
39
+ )
40
+ const answer = before ? answers[0] : answers.at(-1)
41
+
42
+ return answer?.runId ?? null
43
+ }
@@ -155,7 +155,24 @@ export function runInFlight(turns) {
155
155
  return false
156
156
  }
157
157
 
158
- export function busyStatus(modelState, runTurn, elapsed) {
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
- logger
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>;
@@ -1,6 +0,0 @@
1
- export function abortOAuthLoopback(_credentialKey) {
2
- return Promise.resolve(false);
3
- }
4
- export function openOAuthLoopback(_port, _target) {
5
- return Promise.reject(new Error('OAuth loopback is unavailable in this runtime; inject createRedirect instead'));
6
- }