@agentknight/sdk 0.9.40 → 0.9.41
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/chunks/{acp-adapter-TVAW7EHK.js → acp-adapter-SPIMGGL2.js} +3 -3
- package/dist/chunks/{chunk-6RWWNR37.js → chunk-ASHXZ46V.js} +1 -1
- package/dist/chunks/{chunk-SDAEMVSD.js → chunk-J52FWJU4.js} +1 -1
- package/dist/chunks/{chunk-AJ4YL22H.js → chunk-LQIW4ARE.js} +1 -1
- package/dist/chunks/{chunk-CVWUKZX7.js → chunk-QN3OD5UE.js} +1 -1
- package/dist/chunks/{chunk-OV77TRIH.js → chunk-QTBB2U7G.js} +14 -1
- package/dist/chunks/{chunk-D6HWUCVM.js → chunk-RBULXS7T.js} +1 -1
- package/dist/chunks/{chunk-ULJMR33R.js → chunk-SHOE7YAU.js} +3 -3
- package/dist/chunks/{chunk-Q3TQPONK.js → chunk-VDC4G7ZG.js} +2 -2
- package/dist/chunks/{copilot-adapter-KH6NXHGK.js → copilot-adapter-FY75OLIU.js} +7 -8
- package/dist/chunks/{managed-agent-adapter-F7U26CH2.js → managed-agent-adapter-LMHQX6IH.js} +5 -5
- package/dist/chunks/{pi-adapter-G4GQ5ULV.js → pi-adapter-NWQWUNXO.js} +3 -3
- package/dist/index.d.ts +14 -6
- package/dist/index.js +65 -36
- package/dist/runtime.js +2 -2
- package/package.json +1 -1
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import {
|
|
2
2
|
latestPreviewItems
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-RBULXS7T.js";
|
|
4
4
|
import {
|
|
5
5
|
UnsupportedAgentOperationError
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-LQIW4ARE.js";
|
|
7
7
|
import {
|
|
8
8
|
ConversationItemSchema,
|
|
9
9
|
PromptImageAttachmentSchema,
|
|
10
10
|
SESSION_TIMELINE_PAGE_SIZE,
|
|
11
11
|
SessionSummarySchema
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-QTBB2U7G.js";
|
|
13
13
|
|
|
14
14
|
// src/acp-adapter.ts
|
|
15
15
|
import { spawn } from "node:child_process";
|
|
@@ -1150,13 +1150,25 @@ var PairingCreateResultSchema = z10.discriminatedUnion("ok", [
|
|
|
1150
1150
|
z10.object({
|
|
1151
1151
|
ok: z10.literal(true),
|
|
1152
1152
|
code: z10.string().min(32).max(256),
|
|
1153
|
-
expiresAt: z10.number().int().positive()
|
|
1153
|
+
expiresAt: z10.number().int().positive(),
|
|
1154
|
+
// Presence advertises the PC-only status endpoint; older Relays omit it.
|
|
1155
|
+
statusId: z10.string().regex(/^[A-Za-z0-9_-]{43}$/u).optional()
|
|
1154
1156
|
}),
|
|
1155
1157
|
z10.object({
|
|
1156
1158
|
ok: z10.literal(false),
|
|
1157
1159
|
error: ProtocolFailureSchema
|
|
1158
1160
|
})
|
|
1159
1161
|
]);
|
|
1162
|
+
var PairingStatusRequestSchema = z10.object({
|
|
1163
|
+
userId: IdSchema,
|
|
1164
|
+
machineId: IdSchema,
|
|
1165
|
+
statusId: z10.string().regex(/^[A-Za-z0-9_-]{43}$/u)
|
|
1166
|
+
});
|
|
1167
|
+
var PairingStatusSchema = z10.enum(["pending", "paired", "unavailable"]);
|
|
1168
|
+
var PairingStatusResultSchema = z10.discriminatedUnion("ok", [
|
|
1169
|
+
z10.object({ ok: z10.literal(true), state: PairingStatusSchema }),
|
|
1170
|
+
z10.object({ ok: z10.literal(false), error: ProtocolFailureSchema })
|
|
1171
|
+
]);
|
|
1160
1172
|
var PairingExchangeRequestSchema = z10.object({
|
|
1161
1173
|
code: z10.string().min(32).max(256),
|
|
1162
1174
|
clientId: IdSchema
|
|
@@ -2661,6 +2673,7 @@ export {
|
|
|
2661
2673
|
PAIRING_URI_SCHEME,
|
|
2662
2674
|
PAIRING_URI_HOST,
|
|
2663
2675
|
PairingCreateResultSchema,
|
|
2676
|
+
PairingStatusResultSchema,
|
|
2664
2677
|
SECURE_MESSAGE_MAX_CIPHERTEXT_LENGTH,
|
|
2665
2678
|
SecureMessageSchema,
|
|
2666
2679
|
MOBILE_CONNECTED_REPLAY_CAPABILITY,
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
isContentfulAssistant
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-RBULXS7T.js";
|
|
4
4
|
import {
|
|
5
5
|
SessionOperationError
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-LQIW4ARE.js";
|
|
7
7
|
import {
|
|
8
8
|
CONVERSATION_SOURCE_ID_LIMIT,
|
|
9
9
|
SESSION_DIRECTORY_LIST_OPERATION,
|
|
@@ -22,7 +22,7 @@ import {
|
|
|
22
22
|
WorkbenchInsightsSchema,
|
|
23
23
|
WorkbenchQueueMutationResultSchema,
|
|
24
24
|
WorkbenchQueueSnapshotSchema
|
|
25
|
-
} from "./chunk-
|
|
25
|
+
} from "./chunk-QTBB2U7G.js";
|
|
26
26
|
|
|
27
27
|
// src/operation-diagnostics.ts
|
|
28
28
|
import { AsyncLocalStorage } from "node:async_hooks";
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import {
|
|
2
2
|
AgentSessionRenameError,
|
|
3
3
|
validateSessionName
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-LQIW4ARE.js";
|
|
5
5
|
import {
|
|
6
6
|
ConversationItemSchema,
|
|
7
7
|
GroupChatInfoSchema,
|
|
8
8
|
GroupChatParticipantSchema,
|
|
9
9
|
SESSION_TIMELINE_PAGE_SIZE,
|
|
10
10
|
SessionSummarySchema
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-QTBB2U7G.js";
|
|
12
12
|
|
|
13
13
|
// src/group-chat.ts
|
|
14
14
|
import { createHash, randomUUID } from "node:crypto";
|
|
@@ -18,25 +18,25 @@ import {
|
|
|
18
18
|
recordTimelineSyncDiagnostic,
|
|
19
19
|
resolveGitProjectIdentity,
|
|
20
20
|
sanitizeGitRemoteUrl
|
|
21
|
-
} from "./chunk-
|
|
21
|
+
} from "./chunk-SHOE7YAU.js";
|
|
22
22
|
import {
|
|
23
23
|
assertMainSessionId,
|
|
24
24
|
isResearchSessionId
|
|
25
|
-
} from "./chunk-
|
|
25
|
+
} from "./chunk-J52FWJU4.js";
|
|
26
26
|
import {
|
|
27
27
|
GroupChatError,
|
|
28
28
|
GroupChatMessageSchema,
|
|
29
29
|
GroupChatRuntime
|
|
30
|
-
} from "./chunk-
|
|
30
|
+
} from "./chunk-VDC4G7ZG.js";
|
|
31
31
|
import {
|
|
32
32
|
isContentfulAssistant
|
|
33
|
-
} from "./chunk-
|
|
33
|
+
} from "./chunk-RBULXS7T.js";
|
|
34
34
|
import {
|
|
35
35
|
AgentSessionRenameError,
|
|
36
36
|
SessionOperationError,
|
|
37
37
|
TimelinePageBudgetError,
|
|
38
38
|
validateSessionName
|
|
39
|
-
} from "./chunk-
|
|
39
|
+
} from "./chunk-LQIW4ARE.js";
|
|
40
40
|
import {
|
|
41
41
|
ConversationItemSchema,
|
|
42
42
|
CopilotModelOptionSchema,
|
|
@@ -57,7 +57,7 @@ import {
|
|
|
57
57
|
WorkbenchScheduleEntrySchema,
|
|
58
58
|
WorkbenchScheduleProposalSchema,
|
|
59
59
|
WorkbenchScheduleSnapshotSchema
|
|
60
|
-
} from "./chunk-
|
|
60
|
+
} from "./chunk-QTBB2U7G.js";
|
|
61
61
|
|
|
62
62
|
// src/copilot-adapter.ts
|
|
63
63
|
import { createHash as createHash4, randomUUID as randomUUID6 } from "node:crypto";
|
|
@@ -1146,13 +1146,12 @@ var SessionConnections = class {
|
|
|
1146
1146
|
await this.ports.dismissInteractions(sessionId);
|
|
1147
1147
|
this.ports.persistInteractions(sessionId, persistInteractions);
|
|
1148
1148
|
const wasBusy = runtime.activity.busy;
|
|
1149
|
-
const sdkMode = mode === "immediate" && !wasBusy ? "enqueue" : mode;
|
|
1150
1149
|
const submittedAt = this.ports.runtime().client.supportsLocalSubmissionTime === true ? (/* @__PURE__ */ new Date()).toISOString() : void 0;
|
|
1151
1150
|
const activityRevision = runtime.activity.revision;
|
|
1152
1151
|
onDispatch?.();
|
|
1153
1152
|
const receipt = measureOperationStage("session-send", () => session.send({
|
|
1154
1153
|
prompt,
|
|
1155
|
-
mode
|
|
1154
|
+
mode,
|
|
1156
1155
|
...displayPrompt === void 0 ? {} : { displayPrompt },
|
|
1157
1156
|
...sdkAttachments.length === 0 ? {} : { attachments: sdkAttachments }
|
|
1158
1157
|
}));
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import {
|
|
2
2
|
AgentSelectionSchema,
|
|
3
3
|
assertSelectionSnapshotFits
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-ASHXZ46V.js";
|
|
5
5
|
import {
|
|
6
6
|
isResearchSessionId
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-J52FWJU4.js";
|
|
8
8
|
import {
|
|
9
9
|
GroupChatError
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-VDC4G7ZG.js";
|
|
11
11
|
import {
|
|
12
12
|
AgentModelListingError,
|
|
13
13
|
AgentSessionRenameError,
|
|
@@ -15,11 +15,11 @@ import {
|
|
|
15
15
|
UnsupportedAgentOperationError,
|
|
16
16
|
captureWorkbenchAccess,
|
|
17
17
|
validateSessionName
|
|
18
|
-
} from "./chunk-
|
|
18
|
+
} from "./chunk-LQIW4ARE.js";
|
|
19
19
|
import {
|
|
20
20
|
InteractionResponseSchema,
|
|
21
21
|
SessionSummarySchema
|
|
22
|
-
} from "./chunk-
|
|
22
|
+
} from "./chunk-QTBB2U7G.js";
|
|
23
23
|
|
|
24
24
|
// src/managed-agent-adapter.ts
|
|
25
25
|
import { createHash, randomUUID } from "node:crypto";
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import {
|
|
2
2
|
latestPreviewItems
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-RBULXS7T.js";
|
|
4
4
|
import {
|
|
5
5
|
AgentSessionRenameError,
|
|
6
6
|
UnsupportedAgentOperationError,
|
|
7
7
|
validateSessionName
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-LQIW4ARE.js";
|
|
9
9
|
import {
|
|
10
10
|
InteractionRequestSchema,
|
|
11
11
|
REASONING_EFFORTS,
|
|
12
12
|
SESSION_TIMELINE_PAGE_SIZE
|
|
13
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-QTBB2U7G.js";
|
|
14
14
|
|
|
15
15
|
// src/pi-adapter.ts
|
|
16
16
|
import { createHash as createHash2, randomUUID } from "node:crypto";
|
package/dist/index.d.ts
CHANGED
|
@@ -18,6 +18,13 @@ declare const ProtocolErrorSchema: z.ZodObject<{
|
|
|
18
18
|
}, z.core.$strip>;
|
|
19
19
|
type ProtocolError = z.infer<typeof ProtocolErrorSchema>;
|
|
20
20
|
|
|
21
|
+
declare const PairingStatusSchema: z.ZodEnum<{
|
|
22
|
+
pending: "pending";
|
|
23
|
+
paired: "paired";
|
|
24
|
+
unavailable: "unavailable";
|
|
25
|
+
}>;
|
|
26
|
+
type PairingStatus = z.infer<typeof PairingStatusSchema>;
|
|
27
|
+
|
|
21
28
|
declare const SecureEventNameSchema: z.ZodEnum<{
|
|
22
29
|
"session.communication": "session.communication";
|
|
23
30
|
"session.list.result": "session.list.result";
|
|
@@ -1873,24 +1880,25 @@ declare class ContentCipher {
|
|
|
1873
1880
|
interface PairingTicket {
|
|
1874
1881
|
readonly uri: string;
|
|
1875
1882
|
readonly expiresAt: number;
|
|
1883
|
+
readonly statusId?: string;
|
|
1876
1884
|
}
|
|
1877
1885
|
interface PairingProvider {
|
|
1878
1886
|
getPairing(options?: {
|
|
1879
1887
|
readonly force?: boolean;
|
|
1880
1888
|
}): Promise<PairingTicket>;
|
|
1889
|
+
getPairingStatus?(statusId: string): Promise<PairingStatus>;
|
|
1881
1890
|
}
|
|
1882
1891
|
declare class CachedPairingProvider implements PairingProvider {
|
|
1883
1892
|
#private;
|
|
1884
|
-
|
|
1893
|
+
private readonly requestStatus?;
|
|
1894
|
+
constructor(requestPairing: () => Promise<PairingTicket>, minimumValidityMs?: number, requestStatus?: ((statusId: string) => Promise<PairingStatus>) | undefined);
|
|
1885
1895
|
getPairing(options?: {
|
|
1886
1896
|
readonly force?: boolean;
|
|
1887
1897
|
}): Promise<PairingTicket>;
|
|
1898
|
+
getPairingStatus(statusId: string): Promise<PairingStatus>;
|
|
1888
1899
|
}
|
|
1889
1900
|
declare function buildPairingUri(relayUrl: string, code: string, machineId: string, contentKey: string): string;
|
|
1890
|
-
declare function requestPairingUri(config: Pick<PcAgentConfig, "relayUrl" | "relayToken" | "userId">, identity: DeviceIdentity, contentKey: ContentKeyMaterial): Promise<
|
|
1891
|
-
uri: string;
|
|
1892
|
-
expiresAt: number;
|
|
1893
|
-
}>;
|
|
1901
|
+
declare function requestPairingUri(config: Pick<PcAgentConfig, "relayUrl" | "relayToken" | "userId">, identity: DeviceIdentity, contentKey: ContentKeyMaterial): Promise<PairingTicket>;
|
|
1894
1902
|
|
|
1895
1903
|
declare const PEER_CHAT_TIMEOUT_MS = 120000;
|
|
1896
1904
|
declare const PeerChatRequestSchema: z.ZodObject<{
|
|
@@ -2006,7 +2014,7 @@ declare const UploaderConfigSchema: z.ZodObject<{
|
|
|
2006
2014
|
}, z.core.$strip>;
|
|
2007
2015
|
type SessionImageUploaderConfig = z.input<typeof UploaderConfigSchema>;
|
|
2008
2016
|
type Stage = "config" | "source" | "reserve" | "put" | "complete";
|
|
2009
|
-
type SessionImageUploadErrorCode = "IMAGE_CONFIG_INVALID" | "IMAGE_CONTENT_INVALID" | "IMAGE_CAPACITY_EXCEEDED" | "IMAGE_UPLOADER_CLOSED" | "IMAGE_ABORTED" | "IMAGE_TIMEOUT" | "IMAGE_NETWORK_ERROR" | "IMAGE_HTTP_ERROR" | "IMAGE_RESPONSE_INVALID" | "IMAGE_RESPONSE_TOO_LARGE" | "IMAGE_UPLOAD_TARGET_INVALID" | "IMAGE_UPLOAD_EXPIRED" | "IMAGE_COMMIT_MISMATCH" | "IMAGE_COMPLETION_FAILED" | "IMAGE_ACCESS_REVOKED";
|
|
2017
|
+
type SessionImageUploadErrorCode = "IMAGE_CONFIG_INVALID" | "IMAGE_CONTENT_INVALID" | "IMAGE_CAPACITY_EXCEEDED" | "IMAGE_UPLOADER_CLOSED" | "IMAGE_ABORTED" | "IMAGE_TIMEOUT" | "IMAGE_NETWORK_ERROR" | "IMAGE_HTTP_ERROR" | "IMAGE_RESPONSE_INVALID" | "IMAGE_RESPONSE_TOO_LARGE" | "IMAGE_UPLOAD_TARGET_INVALID" | "IMAGE_UPLOAD_EXPIRED" | "IMAGE_COMMIT_MISMATCH" | "IMAGE_COMPLETION_FAILED" | "IMAGE_ACCESS_REVOKED" | "IMAGE_STORAGE_UNAVAILABLE";
|
|
2010
2018
|
/** Safe to log: never retains a response body, URL, token, or raw transport/schema error. */
|
|
2011
2019
|
declare class SessionImageUploadError extends Error {
|
|
2012
2020
|
readonly code: SessionImageUploadErrorCode;
|
package/dist/index.js
CHANGED
|
@@ -4,12 +4,12 @@ import {
|
|
|
4
4
|
PeerChatRequestSchema,
|
|
5
5
|
PeerChatResultSchema,
|
|
6
6
|
validateDataDirectory
|
|
7
|
-
} from "./chunks/chunk-
|
|
7
|
+
} from "./chunks/chunk-QN3OD5UE.js";
|
|
8
8
|
import {
|
|
9
9
|
AgentSelectionSchema,
|
|
10
10
|
assertSelectionSnapshotFits,
|
|
11
11
|
supportsAgentSelection
|
|
12
|
-
} from "./chunks/chunk-
|
|
12
|
+
} from "./chunks/chunk-ASHXZ46V.js";
|
|
13
13
|
import {
|
|
14
14
|
ConversationNormalizer,
|
|
15
15
|
LiveTimelineProjection,
|
|
@@ -31,16 +31,16 @@ import {
|
|
|
31
31
|
resolveGitProjectIdentity,
|
|
32
32
|
sessionRestoreFailure,
|
|
33
33
|
validateOperationResponse
|
|
34
|
-
} from "./chunks/chunk-
|
|
34
|
+
} from "./chunks/chunk-SHOE7YAU.js";
|
|
35
35
|
import {
|
|
36
36
|
GROUP_CHAT_MAX_TURNS,
|
|
37
37
|
GroupChatError
|
|
38
|
-
} from "./chunks/chunk-
|
|
38
|
+
} from "./chunks/chunk-VDC4G7ZG.js";
|
|
39
39
|
import {
|
|
40
40
|
assistantPreview,
|
|
41
41
|
isContentfulAssistant,
|
|
42
42
|
userPreview
|
|
43
|
-
} from "./chunks/chunk-
|
|
43
|
+
} from "./chunks/chunk-RBULXS7T.js";
|
|
44
44
|
import {
|
|
45
45
|
AgentModelListingError,
|
|
46
46
|
AgentSessionRenameError,
|
|
@@ -50,7 +50,7 @@ import {
|
|
|
50
50
|
UnsupportedAgentOperationError,
|
|
51
51
|
captureResearchAccess,
|
|
52
52
|
captureWorkbenchAccess
|
|
53
|
-
} from "./chunks/chunk-
|
|
53
|
+
} from "./chunks/chunk-LQIW4ARE.js";
|
|
54
54
|
import {
|
|
55
55
|
A2aRelayRequestSchema,
|
|
56
56
|
A2aRelayResponseSchema,
|
|
@@ -86,6 +86,7 @@ import {
|
|
|
86
86
|
PC_PEER_CHAT_CAPABILITY,
|
|
87
87
|
PROTOCOL_VERSION,
|
|
88
88
|
PairingCreateResultSchema,
|
|
89
|
+
PairingStatusResultSchema,
|
|
89
90
|
PeerDeliverySchema,
|
|
90
91
|
PeerMessageSchema,
|
|
91
92
|
PermissionRequestPayloadSchema,
|
|
@@ -226,7 +227,7 @@ import {
|
|
|
226
227
|
sessionCommunicationError,
|
|
227
228
|
sessionCommunicationOperationCapability,
|
|
228
229
|
workbenchCapability
|
|
229
|
-
} from "./chunks/chunk-
|
|
230
|
+
} from "./chunks/chunk-QTBB2U7G.js";
|
|
230
231
|
|
|
231
232
|
// src/initialize.ts
|
|
232
233
|
import { createHash as createHash16 } from "node:crypto";
|
|
@@ -304,7 +305,7 @@ async function createCodingAgentAdapter(config, onDiagnostic, owner) {
|
|
|
304
305
|
switch (engine.kind) {
|
|
305
306
|
case "managed": {
|
|
306
307
|
if (owner === void 0) throw new Error("Managed coding agents require the PC owner identity");
|
|
307
|
-
const { ManagedCodingAgentAdapter } = await import("./chunks/managed-agent-adapter-
|
|
308
|
+
const { ManagedCodingAgentAdapter } = await import("./chunks/managed-agent-adapter-LMHQX6IH.js");
|
|
308
309
|
return new ManagedCodingAgentAdapter({
|
|
309
310
|
dataDirectory: config.dataDirectory,
|
|
310
311
|
owner,
|
|
@@ -343,7 +344,7 @@ async function createCodingAgentAdapter(config, onDiagnostic, owner) {
|
|
|
343
344
|
});
|
|
344
345
|
}
|
|
345
346
|
case "copilot": {
|
|
346
|
-
const { GithubCopilotAdapter } = await import("./chunks/copilot-adapter-
|
|
347
|
+
const { GithubCopilotAdapter } = await import("./chunks/copilot-adapter-FY75OLIU.js");
|
|
347
348
|
if (owner !== void 0) {
|
|
348
349
|
return new GithubCopilotAdapter(void 0, void 0, void 0, {
|
|
349
350
|
dataDirectory: config.dataDirectory,
|
|
@@ -363,13 +364,13 @@ async function createCodingAgentAdapter(config, onDiagnostic, owner) {
|
|
|
363
364
|
}
|
|
364
365
|
case "pi": {
|
|
365
366
|
assertPiRuntimeSupported();
|
|
366
|
-
const { PiCodingAgentAdapter } = await import("./chunks/pi-adapter-
|
|
367
|
+
const { PiCodingAgentAdapter } = await import("./chunks/pi-adapter-NWQWUNXO.js");
|
|
367
368
|
return new PiCodingAgentAdapter(
|
|
368
369
|
engine.agentDirectory === void 0 ? {} : { agentDirectory: resolve(engine.agentDirectory) }
|
|
369
370
|
);
|
|
370
371
|
}
|
|
371
372
|
case "acp": {
|
|
372
|
-
const { AcpCodingAgentAdapter } = await import("./chunks/acp-adapter-
|
|
373
|
+
const { AcpCodingAgentAdapter } = await import("./chunks/acp-adapter-SPIMGGL2.js");
|
|
373
374
|
return new AcpCodingAgentAdapter({
|
|
374
375
|
command: engine.command,
|
|
375
376
|
args: engine.args,
|
|
@@ -750,43 +751,47 @@ var DeviceIdentitySchema = z3.object({
|
|
|
750
751
|
|
|
751
752
|
// src/pairing.ts
|
|
752
753
|
var CachedPairingProvider = class {
|
|
754
|
+
constructor(requestPairing, minimumValidityMs = 15e3, requestStatus) {
|
|
755
|
+
this.requestStatus = requestStatus;
|
|
756
|
+
this.#requestPairing = requestPairing;
|
|
757
|
+
this.#minimumValidityMs = minimumValidityMs;
|
|
758
|
+
}
|
|
759
|
+
requestStatus;
|
|
753
760
|
#requestPairing;
|
|
754
761
|
#minimumValidityMs;
|
|
755
762
|
#current;
|
|
756
763
|
#pending;
|
|
757
|
-
#requestSequence = 0;
|
|
758
|
-
#committedSequence = 0;
|
|
759
|
-
constructor(requestPairing, minimumValidityMs = 15e3) {
|
|
760
|
-
this.#requestPairing = requestPairing;
|
|
761
|
-
this.#minimumValidityMs = minimumValidityMs;
|
|
762
|
-
}
|
|
763
764
|
async getPairing(options = {}) {
|
|
764
765
|
const force = options.force ?? false;
|
|
765
766
|
if (this.#pending !== void 0) {
|
|
766
767
|
return this.#pending;
|
|
767
768
|
}
|
|
768
|
-
|
|
769
|
-
return this.#current;
|
|
770
|
-
}
|
|
771
|
-
const sequence = ++this.#requestSequence;
|
|
772
|
-
const pending = this.#requestPairing().then((pairing) => {
|
|
773
|
-
if (pairing.expiresAt <= Date.now()) {
|
|
774
|
-
throw new Error("Relay returned an expired pairing ticket");
|
|
775
|
-
}
|
|
776
|
-
if (sequence >= this.#committedSequence) {
|
|
777
|
-
this.#committedSequence = sequence;
|
|
778
|
-
this.#current = pairing;
|
|
779
|
-
}
|
|
780
|
-
return pairing;
|
|
781
|
-
});
|
|
769
|
+
const pending = this.#getPairing(force);
|
|
782
770
|
this.#pending = pending;
|
|
783
771
|
try {
|
|
784
772
|
return await pending;
|
|
785
773
|
} finally {
|
|
786
|
-
if (this.#pending === pending)
|
|
787
|
-
|
|
788
|
-
|
|
774
|
+
if (this.#pending === pending) this.#pending = void 0;
|
|
775
|
+
}
|
|
776
|
+
}
|
|
777
|
+
async getPairingStatus(statusId) {
|
|
778
|
+
const state = await this.requestStatus?.(statusId) ?? "unavailable";
|
|
779
|
+
if (state !== "pending" && this.#current?.statusId === statusId) {
|
|
780
|
+
this.#current = void 0;
|
|
781
|
+
}
|
|
782
|
+
return state;
|
|
783
|
+
}
|
|
784
|
+
async #getPairing(force) {
|
|
785
|
+
const current = this.#current;
|
|
786
|
+
if (!force && current !== void 0 && current.expiresAt > Date.now() + this.#minimumValidityMs && (current.statusId === void 0 || this.requestStatus === void 0 || await this.getPairingStatus(current.statusId) === "pending")) {
|
|
787
|
+
return current;
|
|
788
|
+
}
|
|
789
|
+
const pairing = await this.#requestPairing();
|
|
790
|
+
if (pairing.expiresAt <= Date.now()) {
|
|
791
|
+
throw new Error("Relay returned an expired pairing ticket");
|
|
789
792
|
}
|
|
793
|
+
this.#current = pairing;
|
|
794
|
+
return pairing;
|
|
790
795
|
}
|
|
791
796
|
};
|
|
792
797
|
function buildPairingUri(relayUrl, code, machineId, contentKey) {
|
|
@@ -830,9 +835,26 @@ async function requestPairingUri(config, identity2, contentKey) {
|
|
|
830
835
|
identity2.machineId,
|
|
831
836
|
contentKey.encoded
|
|
832
837
|
),
|
|
833
|
-
expiresAt: result.expiresAt
|
|
838
|
+
expiresAt: result.expiresAt,
|
|
839
|
+
...result.statusId === void 0 ? {} : { statusId: result.statusId }
|
|
834
840
|
};
|
|
835
841
|
}
|
|
842
|
+
async function requestPairingStatus(config, identity2, statusId) {
|
|
843
|
+
const response = await fetch(`${config.relayUrl.replace(/\/+$/, "")}/auth/pairing/status`, {
|
|
844
|
+
method: "POST",
|
|
845
|
+
headers: {
|
|
846
|
+
authorization: `Bearer ${config.relayToken}`,
|
|
847
|
+
"content-type": "application/json"
|
|
848
|
+
},
|
|
849
|
+
body: JSON.stringify({ userId: config.userId, machineId: identity2.machineId, statusId }),
|
|
850
|
+
signal: AbortSignal.timeout(1e4)
|
|
851
|
+
});
|
|
852
|
+
const result = PairingStatusResultSchema.parse(await response.json());
|
|
853
|
+
if (!response.ok || !result.ok) {
|
|
854
|
+
throw new Error(result.ok ? `Relay pairing status failed with HTTP ${response.status}` : `${result.error.code}: ${result.error.message}`);
|
|
855
|
+
}
|
|
856
|
+
return result.state;
|
|
857
|
+
}
|
|
836
858
|
|
|
837
859
|
// src/pc-agent.ts
|
|
838
860
|
import { AsyncLocalStorage as AsyncLocalStorage2 } from "node:async_hooks";
|
|
@@ -3663,6 +3685,9 @@ var SessionImageUploader = class {
|
|
|
3663
3685
|
headers: { ...this.#headers(), "content-type": "application/json" },
|
|
3664
3686
|
body: JSON.stringify(body)
|
|
3665
3687
|
}, stage, signal, async (response, requestSignal) => {
|
|
3688
|
+
if (stage === "reserve" && response.status === 404) {
|
|
3689
|
+
throw new SessionImageUploadError("IMAGE_STORAGE_UNAVAILABLE", stage, response.status);
|
|
3690
|
+
}
|
|
3666
3691
|
if (response.status !== status) throw new SessionImageUploadError("IMAGE_HTTP_ERROR", stage, response.status);
|
|
3667
3692
|
const contentLength = response.headers.get("content-length");
|
|
3668
3693
|
assert(
|
|
@@ -10654,7 +10679,11 @@ async function initialize(options) {
|
|
|
10654
10679
|
);
|
|
10655
10680
|
const contentKey = await loadOrCreateContentKey(dataDirectory);
|
|
10656
10681
|
const cipher = await createPersistentContentCipher(dataDirectory, contentKey);
|
|
10657
|
-
const pairingProvider = new CachedPairingProvider(
|
|
10682
|
+
const pairingProvider = new CachedPairingProvider(
|
|
10683
|
+
() => requestPairingUri(config, identity2, contentKey),
|
|
10684
|
+
void 0,
|
|
10685
|
+
(statusId) => requestPairingStatus(config, identity2, statusId)
|
|
10686
|
+
);
|
|
10658
10687
|
const sourceAdapter = adapter;
|
|
10659
10688
|
const sourceMetadata = async (sessionId) => {
|
|
10660
10689
|
const access2 = captureResearchAccess(sourceAdapter, sessionId);
|
package/dist/runtime.js
CHANGED
|
@@ -3,8 +3,8 @@ import {
|
|
|
3
3
|
PEER_CHAT_TIMEOUT_MS,
|
|
4
4
|
PeerChatRequestSchema,
|
|
5
5
|
PeerChatResultSchema
|
|
6
|
-
} from "./chunks/chunk-
|
|
7
|
-
import "./chunks/chunk-
|
|
6
|
+
} from "./chunks/chunk-QN3OD5UE.js";
|
|
7
|
+
import "./chunks/chunk-QTBB2U7G.js";
|
|
8
8
|
export {
|
|
9
9
|
DataDirectoryLease,
|
|
10
10
|
PEER_CHAT_TIMEOUT_MS,
|