@agentknight/sdk 0.9.49 → 0.9.51

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.
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  SessionAssistantPreviewSchema,
3
3
  SessionUserPreviewSchema
4
- } from "./chunk-BDKVGENQ.js";
4
+ } from "./chunk-BMMKEB6V.js";
5
5
 
6
6
  // src/assistant-preview.ts
7
7
  function isContentfulAssistant(item) {
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  CODING_AGENT_IDS
3
- } from "./chunk-R5LSWHRH.js";
3
+ } from "./chunk-4XVACOU5.js";
4
4
  import {
5
5
  SECURE_MESSAGE_MAX_CIPHERTEXT_LENGTH
6
- } from "./chunk-BDKVGENQ.js";
6
+ } from "./chunk-BMMKEB6V.js";
7
7
 
8
8
  // src/agent-selection.ts
9
9
  import { z } from "zod";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  SessionOperationError
3
- } from "./chunk-R5LSWHRH.js";
3
+ } from "./chunk-4XVACOU5.js";
4
4
 
5
5
  // src/adapters/copilot/runtime/session-identity.ts
6
6
  function assertMainSessionId(sessionId) {
@@ -36,6 +36,16 @@ var DeviceIdentitySchema = z2.object({
36
36
  createdAt: z2.iso.datetime({ offset: true })
37
37
  });
38
38
 
39
+ // src/relay-authorization.ts
40
+ async function relayRequestToken(config) {
41
+ if (config.relayAuthorization === void 0) return config.relayToken;
42
+ const credential = await config.relayAuthorization.getAccessToken();
43
+ if (!Number.isSafeInteger(credential.expiresAt) || credential.expiresAt <= Date.now() || !/^[\x21-\x7e]{1,32768}$/u.test(credential.token)) {
44
+ throw new Error("Relay authorization expired or is invalid. Sign in again.");
45
+ }
46
+ return credential.token;
47
+ }
48
+
39
49
  // src/legacy-client-state.ts
40
50
  var LEGACY_CLIENT_STATE_DIRECTORY = Buffer.from("2e626c7565706177", "hex").toString("utf8");
41
51
 
@@ -44,6 +54,7 @@ export {
44
54
  SessionImagesConfigSchema,
45
55
  SessionImageRelayUrlSchema,
46
56
  DeviceIdentitySchema,
57
+ relayRequestToken,
47
58
  LEGACY_CLIENT_STATE_DIRECTORY
48
59
  };
49
60
  /*!
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  IdSchema
3
- } from "./chunk-BDKVGENQ.js";
3
+ } from "./chunk-BMMKEB6V.js";
4
4
 
5
5
  // src/data-directory.ts
6
6
  import { randomUUID } from "node:crypto";
@@ -1,14 +1,14 @@
1
1
  import {
2
2
  AgentSessionRenameError,
3
3
  validateSessionName
4
- } from "./chunk-R5LSWHRH.js";
4
+ } from "./chunk-4XVACOU5.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-BDKVGENQ.js";
11
+ } from "./chunk-BMMKEB6V.js";
12
12
 
13
13
  // src/group-chat.ts
14
14
  import { createHash, randomUUID } from "node:crypto";
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  isContentfulAssistant
3
- } from "./chunk-6VEMXJW4.js";
3
+ } from "./chunk-FEH4GODE.js";
4
4
  import {
5
5
  SessionOperationError
6
- } from "./chunk-R5LSWHRH.js";
6
+ } from "./chunk-4XVACOU5.js";
7
7
  import {
8
8
  CONVERSATION_SOURCE_ID_LIMIT,
9
9
  SESSION_DIRECTORY_LIST_OPERATION,
@@ -23,7 +23,7 @@ import {
23
23
  WorkbenchInsightsSchema,
24
24
  WorkbenchQueueMutationResultSchema,
25
25
  WorkbenchQueueSnapshotSchema
26
- } from "./chunk-BDKVGENQ.js";
26
+ } from "./chunk-BMMKEB6V.js";
27
27
 
28
28
  // src/operation-diagnostics.ts
29
29
  import { AsyncLocalStorage } from "node:async_hooks";
@@ -3,18 +3,18 @@ import {
3
3
  } from "./chunk-T6226JFS.js";
4
4
  import {
5
5
  latestPreviewItems
6
- } from "./chunk-6VEMXJW4.js";
6
+ } from "./chunk-FEH4GODE.js";
7
7
  import {
8
8
  UnsupportedAgentOperationError,
9
9
  validateSessionName
10
- } from "./chunk-R5LSWHRH.js";
10
+ } from "./chunk-4XVACOU5.js";
11
11
  import {
12
12
  ConversationItemSchema,
13
13
  InteractionRequestSchema,
14
14
  InteractionResponseSchema,
15
15
  SESSION_TIMELINE_PAGE_SIZE,
16
16
  SessionSummarySchema
17
- } from "./chunk-BDKVGENQ.js";
17
+ } from "./chunk-BMMKEB6V.js";
18
18
 
19
19
  // src/claude-adapter.ts
20
20
  import { randomUUID as randomUUID2 } from "node:crypto";
@@ -1,15 +1,15 @@
1
1
  import {
2
2
  latestPreviewItems
3
- } from "./chunk-6VEMXJW4.js";
3
+ } from "./chunk-FEH4GODE.js";
4
4
  import {
5
5
  UnsupportedAgentOperationError
6
- } from "./chunk-R5LSWHRH.js";
6
+ } from "./chunk-4XVACOU5.js";
7
7
  import {
8
8
  ConversationItemSchema,
9
9
  InteractionRequestSchema,
10
10
  SESSION_TIMELINE_PAGE_SIZE,
11
11
  SessionSummarySchema
12
- } from "./chunk-BDKVGENQ.js";
12
+ } from "./chunk-BMMKEB6V.js";
13
13
 
14
14
  // src/codex-adapter.ts
15
15
  import { randomUUID } from "node:crypto";
@@ -18,25 +18,25 @@ import {
18
18
  recordTimelineSyncDiagnostic,
19
19
  resolveGitProjectIdentity,
20
20
  sanitizeGitRemoteUrl
21
- } from "./chunk-RX7VGB3T.js";
21
+ } from "./chunk-ZVPUOCY5.js";
22
22
  import {
23
23
  assertMainSessionId,
24
24
  isResearchSessionId
25
- } from "./chunk-2QHOQXOR.js";
25
+ } from "./chunk-LDF3XNVN.js";
26
26
  import {
27
27
  GroupChatError,
28
28
  GroupChatMessageSchema,
29
29
  GroupChatRuntime
30
- } from "./chunk-H6FG5CCS.js";
30
+ } from "./chunk-UXIZLEZV.js";
31
31
  import {
32
32
  isContentfulAssistant
33
- } from "./chunk-6VEMXJW4.js";
33
+ } from "./chunk-FEH4GODE.js";
34
34
  import {
35
35
  AgentSessionRenameError,
36
36
  SessionOperationError,
37
37
  TimelinePageBudgetError,
38
38
  validateSessionName
39
- } from "./chunk-R5LSWHRH.js";
39
+ } from "./chunk-4XVACOU5.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-BDKVGENQ.js";
60
+ } from "./chunk-BMMKEB6V.js";
61
61
 
62
62
  // src/copilot-adapter.ts
63
63
  import { createHash as createHash4, randomUUID as randomUUID6 } from "node:crypto";
@@ -1,13 +1,13 @@
1
1
  import {
2
2
  AgentSelectionSchema,
3
3
  assertSelectionSnapshotFits
4
- } from "./chunk-YFLDTX2W.js";
4
+ } from "./chunk-HHI2UYWK.js";
5
5
  import {
6
6
  isResearchSessionId
7
- } from "./chunk-2QHOQXOR.js";
7
+ } from "./chunk-LDF3XNVN.js";
8
8
  import {
9
9
  GroupChatError
10
- } from "./chunk-H6FG5CCS.js";
10
+ } from "./chunk-UXIZLEZV.js";
11
11
  import {
12
12
  AgentModelListingError,
13
13
  AgentSessionRenameError,
@@ -16,11 +16,11 @@ import {
16
16
  UnsupportedAgentOperationError,
17
17
  captureWorkbenchAccess,
18
18
  validateSessionName
19
- } from "./chunk-R5LSWHRH.js";
19
+ } from "./chunk-4XVACOU5.js";
20
20
  import {
21
21
  InteractionResponseSchema,
22
22
  SessionSummarySchema
23
- } from "./chunk-BDKVGENQ.js";
23
+ } from "./chunk-BMMKEB6V.js";
24
24
 
25
25
  // src/managed-agent-adapter.ts
26
26
  import { createHash, randomUUID } from "node:crypto";
@@ -1,16 +1,16 @@
1
1
  import {
2
2
  latestPreviewItems
3
- } from "./chunk-6VEMXJW4.js";
3
+ } from "./chunk-FEH4GODE.js";
4
4
  import {
5
5
  AgentSessionRenameError,
6
6
  UnsupportedAgentOperationError,
7
7
  validateSessionName
8
- } from "./chunk-R5LSWHRH.js";
8
+ } from "./chunk-4XVACOU5.js";
9
9
  import {
10
10
  InteractionRequestSchema,
11
11
  REASONING_EFFORTS,
12
12
  SESSION_TIMELINE_PAGE_SIZE
13
- } from "./chunk-BDKVGENQ.js";
13
+ } from "./chunk-BMMKEB6V.js";
14
14
 
15
15
  // src/pi-adapter.ts
16
16
  import { createHash as createHash2, randomUUID } from "node:crypto";
@@ -5,3 +5,4 @@ export { AgentSelectionSchema } from "./index.js";
5
5
  export type { AgentSelection, AgentSelectionProvider } from "./index.js";
6
6
  export { codingAgentPresentation } from "./index.js";
7
7
  export { LEGACY_CLIENT_STATE_DIRECTORY } from "./index.js";
8
+ export { relayRequestToken } from "./index.js";
@@ -3,15 +3,16 @@ import {
3
3
  LEGACY_CLIENT_STATE_DIRECTORY,
4
4
  SessionImageRelayUrlSchema,
5
5
  SessionImagesConfigSchema,
6
- codingAgentPresentation
7
- } from "./chunks/chunk-IU5NTPMF.js";
6
+ codingAgentPresentation,
7
+ relayRequestToken
8
+ } from "./chunks/chunk-RPVK6HQV.js";
8
9
  import {
9
10
  AgentSelectionSchema
10
- } from "./chunks/chunk-YFLDTX2W.js";
11
+ } from "./chunks/chunk-HHI2UYWK.js";
11
12
  import {
12
13
  CODING_AGENT_IDS
13
- } from "./chunks/chunk-R5LSWHRH.js";
14
- import "./chunks/chunk-BDKVGENQ.js";
14
+ } from "./chunks/chunk-4XVACOU5.js";
15
+ import "./chunks/chunk-BMMKEB6V.js";
15
16
  export {
16
17
  AgentSelectionSchema,
17
18
  CODING_AGENT_IDS,
@@ -19,5 +20,6 @@ export {
19
20
  LEGACY_CLIENT_STATE_DIRECTORY,
20
21
  SessionImageRelayUrlSchema,
21
22
  SessionImagesConfigSchema,
22
- codingAgentPresentation
23
+ codingAgentPresentation,
24
+ relayRequestToken
23
25
  };
package/dist/index.d.ts CHANGED
@@ -25,6 +25,29 @@ declare const PairingStatusSchema: z.ZodEnum<{
25
25
  }>;
26
26
  type PairingStatus = z.infer<typeof PairingStatusSchema>;
27
27
 
28
+ declare const MobileAuthorizationViewSchema: z.ZodObject<{
29
+ requestId: z.ZodString;
30
+ state: z.ZodEnum<{
31
+ active: "active";
32
+ cancelled: "cancelled";
33
+ expired: "expired";
34
+ open: "open";
35
+ pending: "pending";
36
+ rejected: "rejected";
37
+ revoked: "revoked";
38
+ }>;
39
+ deviceName: z.ZodString;
40
+ clientId: z.ZodString;
41
+ publicKey: z.ZodString;
42
+ confirmationCode: z.ZodString;
43
+ createdAt: z.ZodNumber;
44
+ expiresAt: z.ZodNumber;
45
+ decidedAt: z.ZodNullable<z.ZodNumber>;
46
+ lastSeenAt: z.ZodNullable<z.ZodNumber>;
47
+ online: z.ZodBoolean;
48
+ }, z.core.$strip>;
49
+ type MobileAuthorizationView = z.infer<typeof MobileAuthorizationViewSchema>;
50
+
28
51
  declare const SecureEventNameSchema: z.ZodEnum<{
29
52
  "conversation.activity.step.upsert": "conversation.activity.step.upsert";
30
53
  "conversation.item.upsert": "conversation.item.upsert";
@@ -1785,6 +1808,15 @@ interface AgentSelectionProvider {
1785
1808
  }
1786
1809
  declare function supportsAgentSelection(adapter: CodingAgentAdapter): adapter is CodingAgentAdapter & AgentSelectionProvider;
1787
1810
 
1811
+ interface RelayAccessToken {
1812
+ token: string;
1813
+ expiresAt: number;
1814
+ }
1815
+ interface RelayAuthorization {
1816
+ getAccessToken(): Promise<RelayAccessToken>;
1817
+ }
1818
+ declare function relayRequestToken(config: Pick<PcAgentConfig, "relayToken" | "relayAuthorization">): Promise<string>;
1819
+
1788
1820
  declare const SessionImagesConfigSchema: z.ZodObject<{
1789
1821
  allowUnencryptedStorage: z.ZodLiteral<true>;
1790
1822
  storageAccount: z.ZodString;
@@ -1818,6 +1850,7 @@ type CodingAgentConfig = {
1818
1850
  interface PcAgentConfig {
1819
1851
  relayUrl: string;
1820
1852
  relayToken: string;
1853
+ relayAuthorization?: RelayAuthorization;
1821
1854
  userId: string;
1822
1855
  workspaceRoot?: string;
1823
1856
  dataDirectory: string;
@@ -1897,6 +1930,9 @@ interface PairingProvider {
1897
1930
  readonly force?: boolean;
1898
1931
  }): Promise<PairingTicket>;
1899
1932
  getPairingStatus?(statusId: string): Promise<PairingStatus>;
1933
+ enableApproval?(): Promise<void>;
1934
+ listClients?(): Promise<MobileAuthorizationView[]>;
1935
+ decideClient?(requestId: string, action: "approve" | "reject" | "revoke", expectedPublicKey: string): Promise<void>;
1900
1936
  }
1901
1937
  declare class CachedPairingProvider implements PairingProvider {
1902
1938
  #private;
@@ -1908,7 +1944,7 @@ declare class CachedPairingProvider implements PairingProvider {
1908
1944
  getPairingStatus(statusId: string): Promise<PairingStatus>;
1909
1945
  }
1910
1946
  declare function buildPairingUri(relayUrl: string, code: string, machineId: string, contentKey: string): string;
1911
- declare function requestPairingUri(config: Pick<PcAgentConfig, "relayUrl" | "relayToken" | "userId">, identity: DeviceIdentity, contentKey: ContentKeyMaterial): Promise<PairingTicket>;
1947
+ declare function requestPairingUri(config: Pick<PcAgentConfig, "relayUrl" | "relayToken" | "relayAuthorization" | "userId">, identity: DeviceIdentity, contentKey: ContentKeyMaterial): Promise<PairingTicket>;
1912
1948
 
1913
1949
  declare const PEER_CHAT_TIMEOUT_MS = 120000;
1914
1950
  declare const PeerChatRequestSchema: z.ZodObject<{
@@ -1970,7 +2006,7 @@ interface RelaySocket {
1970
2006
  connect(): void;
1971
2007
  disconnect(): void;
1972
2008
  }
1973
- type RelaySocketFactory = (uri: string, options: Partial<ManagerOptions & SocketOptions>) => RelaySocket;
2009
+ type RelaySocketFactory = (uri: string, options: Partial<ManagerOptions & SocketOptions>, authorization?: RelayAuthorization) => RelaySocket;
1974
2010
 
1975
2011
  interface InitializeOptions extends Omit<PcAgentConfig, "refreshIntervalMs" | "heartbeatIntervalMs" | "exitAfterSnapshot"> {
1976
2012
  refreshIntervalMs?: number;
@@ -2055,5 +2091,5 @@ declare function codingAgentPresentation(agentId: string): CodingAgentPresentati
2055
2091
 
2056
2092
  declare const LEGACY_CLIENT_STATE_DIRECTORY: string;
2057
2093
 
2058
- export { AgentSelectionSchema, CODING_AGENT_IDS, CachedPairingProvider, ContentCipher, DataDirectoryLease, DeviceIdentitySchema, LEGACY_CLIENT_STATE_DIRECTORY, PEER_CHAT_TIMEOUT_MS, PeerChatRequestSchema, PeerChatResultSchema, SessionImageRelayUrlSchema, SessionImageUploadError, SessionImageUploader, SessionImagesConfigSchema, TimelinePageBudgetError, assertPiRuntimeSupported, buildPairingUri, codingAgentPresentation, createCodingAgentAdapter, createPersistentContentCipher, generateContentKey, initialize, loadOrCreateContentKey, parseContentKey, requestPairingUri, supportsAgentSelection };
2059
- export type { Agent, AgentSelection, AgentSelectionProvider, AgentSessionConfiguration, AgentSessionConfigureOptions, AgentSessionCreateOptions, CodingAgentAdapter, CodingAgentConfig, CodingAgentId, CodingAgentSessionCallbacks, ContentKeyMaterial, DeviceIdentity, InitializeOptions, PairingProvider, PairingTicket, PcAgentConfig, PeerChatRequest, PeerChatResult, RelayRegistrationStatus, RelaySocket, RelaySocketFactory, SelectableAgent, SessionImageUploadErrorCode, SessionImageUploaderConfig, TimelineImageProjection, TimelineReadOptions };
2094
+ export { AgentSelectionSchema, CODING_AGENT_IDS, CachedPairingProvider, ContentCipher, DataDirectoryLease, DeviceIdentitySchema, LEGACY_CLIENT_STATE_DIRECTORY, PEER_CHAT_TIMEOUT_MS, PeerChatRequestSchema, PeerChatResultSchema, SessionImageRelayUrlSchema, SessionImageUploadError, SessionImageUploader, SessionImagesConfigSchema, TimelinePageBudgetError, assertPiRuntimeSupported, buildPairingUri, codingAgentPresentation, createCodingAgentAdapter, createPersistentContentCipher, generateContentKey, initialize, loadOrCreateContentKey, parseContentKey, relayRequestToken, requestPairingUri, supportsAgentSelection };
2095
+ export type { Agent, AgentSelection, AgentSelectionProvider, AgentSessionConfiguration, AgentSessionConfigureOptions, AgentSessionCreateOptions, CodingAgentAdapter, CodingAgentConfig, CodingAgentId, CodingAgentSessionCallbacks, ContentKeyMaterial, DeviceIdentity, InitializeOptions, PairingProvider, PairingTicket, PcAgentConfig, PeerChatRequest, PeerChatResult, RelayAccessToken, RelayAuthorization, RelayRegistrationStatus, RelaySocket, RelaySocketFactory, SelectableAgent, SessionImageUploadErrorCode, SessionImageUploaderConfig, TimelineImageProjection, TimelineReadOptions };