@caplets/core 0.24.1 → 0.25.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 (60) hide show
  1. package/dist/attach/options.d.ts +1 -0
  2. package/dist/attach/server.d.ts +3 -0
  3. package/dist/caplet-source.js +14 -11
  4. package/dist/cli/commands.d.ts +10 -2
  5. package/dist/cli/doctor.d.ts +4 -1
  6. package/dist/cli.d.ts +3 -2
  7. package/dist/code-mode/platform-runtime.generated.d.ts +1 -1
  8. package/dist/code-mode.js +6 -6
  9. package/dist/{completion-BeVXdm9q.js → completion-De4t5MtT.js} +32 -10
  10. package/dist/config-runtime.js +2 -2
  11. package/dist/daemon/config.d.ts +8 -0
  12. package/dist/daemon/env.d.ts +2 -0
  13. package/dist/daemon/index.d.ts +18 -0
  14. package/dist/daemon/logs.d.ts +15 -0
  15. package/dist/daemon/manager.d.ts +2 -0
  16. package/dist/daemon/paths.d.ts +2 -0
  17. package/dist/daemon/platform-darwin.d.ts +3 -0
  18. package/dist/daemon/platform-linux.d.ts +3 -0
  19. package/dist/daemon/platform-windows.d.ts +3 -0
  20. package/dist/daemon/process.d.ts +11 -0
  21. package/dist/daemon/shell.d.ts +20 -0
  22. package/dist/daemon/types.d.ts +178 -0
  23. package/dist/daemon/validation.d.ts +14 -0
  24. package/dist/daemon/xml.d.ts +1 -0
  25. package/dist/generated-tool-input-schema.js +1 -1
  26. package/dist/index.js +5854 -3559
  27. package/dist/native/options.d.ts +5 -2
  28. package/dist/native/remote.d.ts +6 -1
  29. package/dist/native.js +1 -1
  30. package/dist/observed-output-shapes/pure.js +1 -1
  31. package/dist/{observed-output-shapes-D2k2-q8K.js → observed-output-shapes-DuP7mJQf.js} +1 -1
  32. package/dist/observed-output-shapes.js +1 -1
  33. package/dist/project-binding/attach.d.ts +1 -3
  34. package/dist/project-binding/session.d.ts +1 -0
  35. package/dist/remote/credential-store.d.ts +12 -0
  36. package/dist/remote/options.d.ts +2 -7
  37. package/dist/remote/pairing.d.ts +13 -0
  38. package/dist/remote/profile-store.d.ts +94 -0
  39. package/dist/remote/profiles.d.ts +47 -0
  40. package/dist/remote/selection.d.ts +4 -4
  41. package/dist/remote/server-credential-store.d.ts +84 -0
  42. package/dist/remote/server-credentials.d.ts +21 -0
  43. package/dist/remote-control/client.d.ts +4 -1
  44. package/dist/{schemas-C0PNPwjS.js → schemas-BoqMu4MG.js} +11 -8
  45. package/dist/serve/http.d.ts +5 -0
  46. package/dist/serve/index.d.ts +1 -3
  47. package/dist/serve/options.d.ts +7 -12
  48. package/dist/server/options.d.ts +2 -9
  49. package/dist/{service-Cvnuu9wr.js → service-Ut6dN9M8.js} +1119 -289
  50. package/dist/{validation-DgxCzt-A.js → validation-C4tYXw6G.js} +1 -1
  51. package/package.json +1 -1
  52. package/dist/serve/daemon/config.d.ts +0 -8
  53. package/dist/serve/daemon/index.d.ts +0 -16
  54. package/dist/serve/daemon/paths.d.ts +0 -3
  55. package/dist/serve/daemon/platform-darwin.d.ts +0 -2
  56. package/dist/serve/daemon/platform-linux.d.ts +0 -2
  57. package/dist/serve/daemon/platform-windows.d.ts +0 -2
  58. package/dist/serve/daemon/platform.d.ts +0 -9
  59. package/dist/serve/daemon/process.d.ts +0 -5
  60. package/dist/serve/daemon/types.d.ts +0 -86
@@ -1,7 +1,10 @@
1
- import { type CapletsRemoteEnv, type CapletsRemoteInput } from "../remote/options";
1
+ import { type CapletsRemoteEnv } from "../remote/options";
2
2
  type CapletsMode = "auto" | "local" | "remote" | "cloud";
3
3
  export type NativeCapletsMode = CapletsMode;
4
- export type NativeRemoteCapletsOptions = CapletsRemoteInput & {
4
+ export type NativeRemoteCapletsOptions = {
5
+ url?: string;
6
+ workspace?: string;
7
+ fetch?: typeof fetch;
5
8
  pollIntervalMs?: number;
6
9
  cloud?: NativeCloudPresenceInput;
7
10
  };
@@ -23,6 +23,11 @@ export type RemoteCapletsClient = {
23
23
  export type RemoteCapletsClientOptions = ResolvedNativeCapletsServiceOptions & {
24
24
  mode: "remote" | "cloud";
25
25
  };
26
+ export type SdkRemoteCapletsClientOptions = RemoteCapletsClientOptions["remote"] & {
27
+ resolveRuntimeOptions?: () => Promise<RemoteCapletsClientOptions["remote"]>;
28
+ authKind?: "self_hosted_remote" | "hosted_cloud";
29
+ writeErr?: (value: string) => void;
30
+ };
26
31
  export type RemoteNativeCapletsServiceOptions = {
27
32
  client: RemoteCapletsClient;
28
33
  clientFactory?: () => RemoteCapletsClient;
@@ -30,7 +35,7 @@ export type RemoteNativeCapletsServiceOptions = {
30
35
  authKind?: "self_hosted_remote" | "hosted_cloud";
31
36
  writeErr?: (value: string) => void;
32
37
  };
33
- export declare function createSdkRemoteCapletsClient(options: RemoteCapletsClientOptions["remote"]): RemoteCapletsClient;
38
+ export declare function createSdkRemoteCapletsClient(options: SdkRemoteCapletsClientOptions): RemoteCapletsClient;
34
39
  export declare class RemoteNativeCapletsService implements NativeCapletsService {
35
40
  private readonly options;
36
41
  private tools;
package/dist/native.js CHANGED
@@ -1,4 +1,4 @@
1
- import { C as nativeCapletToolDescription, D as nativeCodeModeToolName, E as nativeCodeModeToolId, S as nativeCapletPromptGuidance, T as nativeCapletsSystemGuidance, f as RemoteNativeCapletsService, h as resolveNativeCapletsServiceOptions, p as createSdkRemoteCapletsClient, t as createNativeCapletsService, w as nativeCapletToolName } from "./service-Cvnuu9wr.js";
1
+ import { A as nativeCapletToolDescription, M as nativeCapletsSystemGuidance, N as nativeCodeModeToolId, P as nativeCodeModeToolName, _ as resolveNativeCapletsServiceOptions, h as createSdkRemoteCapletsClient, j as nativeCapletToolName, k as nativeCapletPromptGuidance, m as RemoteNativeCapletsService, t as createNativeCapletsService } from "./service-Ut6dN9M8.js";
2
2
  import { generatedToolInputJsonSchema, generatedToolInputSchema } from "./generated-tool-input-schema.js";
3
3
  //#region src/native/process-cleanup.ts
4
4
  function registerNativeCapletsProcessCleanup(service, options = {}) {
@@ -24,7 +24,7 @@ function mergeJsonShapes(left, right) {
24
24
  }
25
25
  function mergeObjects(left, right) {
26
26
  const fields = {};
27
- const keys = [...new Set([...Object.keys(left.fields), ...Object.keys(right.fields)])].sort();
27
+ const keys = [.../* @__PURE__ */ new Set([...Object.keys(left.fields), ...Object.keys(right.fields)])].sort();
28
28
  let truncated = left.truncated === true || right.truncated === true;
29
29
  const selected = keys.slice(0, OBSERVED_OUTPUT_SHAPE_LIMITS.maxObjectFields);
30
30
  truncated = truncated || keys.length > selected.length;
@@ -277,7 +277,7 @@ function mergeJsonShapes(left, right) {
277
277
  }
278
278
  function mergeObjects(left, right) {
279
279
  const fields = {};
280
- const keys = [...new Set([...Object.keys(left.fields), ...Object.keys(right.fields)])].sort();
280
+ const keys = [.../* @__PURE__ */ new Set([...Object.keys(left.fields), ...Object.keys(right.fields)])].sort();
281
281
  let truncated = left.truncated === true || right.truncated === true;
282
282
  const selected = keys.slice(0, OBSERVED_OUTPUT_SHAPE_LIMITS.maxObjectFields);
283
283
  truncated = truncated || keys.length > selected.length;
@@ -1,2 +1,2 @@
1
- import { _ as OBSERVED_OUTPUT_SHAPE_LIMITS, a as parseShapeableJsonText, c as shapeType, d as backendFingerprint, f as observedOutputShapeKey, i as observeOutputShape, l as mergeJsonShapes, m as stableHash, n as extractJsonShape, o as hasTruncatedShape, p as observedOutputShapeStorageKey, r as normalizedObservableValue, s as shapeToTypeScript, t as usefulOutputSchema, u as FileObservedOutputShapeStore, v as OBSERVED_OUTPUT_SHAPE_VERSION } from "./observed-output-shapes-D2k2-q8K.js";
1
+ import { _ as OBSERVED_OUTPUT_SHAPE_LIMITS, a as parseShapeableJsonText, c as shapeType, d as backendFingerprint, f as observedOutputShapeKey, i as observeOutputShape, l as mergeJsonShapes, m as stableHash, n as extractJsonShape, o as hasTruncatedShape, p as observedOutputShapeStorageKey, r as normalizedObservableValue, s as shapeToTypeScript, t as usefulOutputSchema, u as FileObservedOutputShapeStore, v as OBSERVED_OUTPUT_SHAPE_VERSION } from "./observed-output-shapes-DuP7mJQf.js";
2
2
  export { FileObservedOutputShapeStore, OBSERVED_OUTPUT_SHAPE_LIMITS, OBSERVED_OUTPUT_SHAPE_VERSION, backendFingerprint, extractJsonShape, hasTruncatedShape, mergeJsonShapes, normalizedObservableValue, observeOutputShape, observedOutputShapeKey, observedOutputShapeStorageKey, parseShapeableJsonText, shapeToTypeScript, shapeType, stableHash, usefulOutputSchema };
@@ -3,15 +3,13 @@ import { type ProjectBindingSessionEvent } from "./session";
3
3
  import type { ProjectBindingWebSocketFactory } from "./transport";
4
4
  export type RawAttachOptions = {
5
5
  remoteUrl?: string;
6
- user?: string;
7
- password?: string;
8
- token?: string;
9
6
  workspace?: string;
10
7
  json?: boolean;
11
8
  verbose?: boolean;
12
9
  once?: boolean;
13
10
  projectRoot?: string;
14
11
  fetch?: typeof fetch;
12
+ authDir?: string;
15
13
  };
16
14
  export type ResolvedAttachOptions = {
17
15
  projectRoot: string;
@@ -65,6 +65,7 @@ export type ProjectBindingSocketClientMessage = {
65
65
  export type RunProjectBindingSessionInput = {
66
66
  projectRoot: string;
67
67
  remote: ResolvedCapletsRemote;
68
+ remoteResolver?: (() => Promise<ResolvedCapletsRemote>) | undefined;
68
69
  fetch?: typeof fetch | undefined;
69
70
  webSocketFactory?: ProjectBindingWebSocketFactory | undefined;
70
71
  signal?: AbortSignal | undefined;
@@ -0,0 +1,12 @@
1
+ import type { RemoteProfileCredential } from "./profiles";
2
+ export type RemoteCredentialStoreOptions = {
3
+ root?: string | undefined;
4
+ };
5
+ export declare class FileRemoteCredentialStore {
6
+ readonly root: string;
7
+ constructor(options?: RemoteCredentialStoreOptions);
8
+ pathForKey(key: string): string;
9
+ load(key: string): Promise<RemoteProfileCredential | undefined>;
10
+ save(key: string, credential: RemoteProfileCredential): Promise<void>;
11
+ delete(key: string): Promise<boolean>;
12
+ }
@@ -1,4 +1,4 @@
1
- export type CapletsRemoteEnv = Partial<Record<"CAPLETS_MODE" | "CAPLETS_REMOTE_URL" | "CAPLETS_REMOTE_USER" | "CAPLETS_REMOTE_PASSWORD" | "CAPLETS_REMOTE_TOKEN" | "CAPLETS_REMOTE_WORKSPACE", string>>;
1
+ export type CapletsRemoteEnv = Partial<Record<"CAPLETS_MODE" | "CAPLETS_REMOTE_URL" | "CAPLETS_REMOTE_WORKSPACE", string>>;
2
2
  export type CapletsRemoteModeInput = {
3
3
  mode?: string;
4
4
  remoteUrl?: string;
@@ -6,8 +6,6 @@ export type CapletsRemoteModeInput = {
6
6
  export type CapletsRemoteMode = "local" | "remote" | "cloud";
7
7
  export type CapletsRemoteInput = {
8
8
  url?: string;
9
- user?: string;
10
- password?: string;
11
9
  token?: string;
12
10
  workspace?: string;
13
11
  fetch?: typeof fetch;
@@ -15,10 +13,6 @@ export type CapletsRemoteInput = {
15
13
  export type CapletsRemoteAuth = {
16
14
  type: "none";
17
15
  user: string;
18
- } | {
19
- type: "basic";
20
- user: string;
21
- password: string;
22
16
  } | {
23
17
  type: "bearer";
24
18
  token: string;
@@ -41,5 +35,6 @@ export declare function resolveRemoteMode(input?: CapletsRemoteModeInput, env?:
41
35
  export declare function resolveCapletsRemote(input?: CapletsRemoteInput, env?: CapletsRemoteEnv): ResolvedCapletsRemote;
42
36
  export declare function resolveHostedCloudRemote(input?: CapletsRemoteInput, env?: CapletsRemoteEnv): ResolvedCapletsRemote;
43
37
  export declare function hostedCloudWorkspaceFromRemoteUrl(value: string): string | undefined;
38
+ export declare function normalizeRemoteProfileHostUrl(value: string): string;
44
39
  export declare function projectBindingWebSocketUrlForBase(baseUrl: URL): URL;
45
40
  export declare function isCapletsCloudUrl(value: string): boolean;
@@ -0,0 +1,13 @@
1
+ export type ParsedPairingCode = {
2
+ codeId: string;
3
+ secret: string;
4
+ };
5
+ export declare function createPairingCode(): {
6
+ codeId: string;
7
+ code: string;
8
+ secret: string;
9
+ };
10
+ export declare function createPairingCodeVerifier(codeId: string, secret: string): string;
11
+ export declare function parsePairingCode(value: string): ParsedPairingCode | undefined;
12
+ export declare function isPairingCodeFormat(value: string): boolean;
13
+ export declare function randomToken(bytes?: number): string;
@@ -0,0 +1,94 @@
1
+ import { CloudAuthStore } from "../cloud-auth/store";
2
+ import type { CloudAuthCredentials } from "../cloud-auth/store";
3
+ import { FileRemoteCredentialStore } from "./credential-store";
4
+ import { type RemoteProfileCredential, type RemoteProfileStatus } from "./profiles";
5
+ export type SaveCloudProfileInput = {
6
+ hostUrl: string;
7
+ workspaceId: string;
8
+ workspaceSlug?: string | undefined;
9
+ clientLabel?: string | undefined;
10
+ credentials: RemoteProfileCredential;
11
+ now?: Date | undefined;
12
+ };
13
+ export type CloudProfileLookup = {
14
+ hostUrl: string;
15
+ workspace?: string | undefined;
16
+ };
17
+ export type SaveSelfHostedProfileInput = {
18
+ hostUrl: string;
19
+ clientId: string;
20
+ clientLabel?: string | undefined;
21
+ credentials: RemoteProfileCredential;
22
+ now?: Date | undefined;
23
+ };
24
+ export type SelfHostedProfileLookup = {
25
+ hostUrl: string;
26
+ };
27
+ export type RefreshSelfHostedProfileInput = SelfHostedProfileLookup & {
28
+ needsRefresh: (credential: RemoteProfileCredential) => boolean;
29
+ refresh: (status: RemoteProfileStatus, credential: RemoteProfileCredential) => Promise<SaveSelfHostedProfileInput>;
30
+ };
31
+ export type RefreshCloudProfileInput = CloudProfileLookup & {
32
+ needsRefresh: (credential: RemoteProfileCredential) => boolean;
33
+ refresh: (status: RemoteProfileStatus, credential: RemoteProfileCredential) => Promise<SaveCloudProfileInput>;
34
+ };
35
+ export type RemoteProfileStoreOptions = {
36
+ root?: string | undefined;
37
+ credentials?: FileRemoteCredentialStore | undefined;
38
+ legacyCloudAuthStore?: CloudAuthStore | undefined;
39
+ };
40
+ export type CreateRemoteProfileStoreOptions = {
41
+ authDir?: string | undefined;
42
+ env?: NodeJS.ProcessEnv | Record<string, string | undefined> | undefined;
43
+ legacyCloudAuthStore?: CloudAuthStore | undefined;
44
+ };
45
+ export declare function createRemoteProfileStore(options?: CreateRemoteProfileStoreOptions): FileRemoteProfileStore;
46
+ export declare function cloudCredentialsFromRemoteProfile(status: RemoteProfileStatus, credential: RemoteProfileCredential): CloudAuthCredentials;
47
+ export declare class FileRemoteProfileStore {
48
+ readonly root: string;
49
+ readonly credentials: FileRemoteCredentialStore;
50
+ readonly legacyCloudAuthStore?: CloudAuthStore | undefined;
51
+ constructor(options?: RemoteProfileStoreOptions);
52
+ saveSelfHostedProfile(input: SaveSelfHostedProfileInput): Promise<RemoteProfileStatus>;
53
+ getSelfHostedProfileStatus(input: SelfHostedProfileLookup): Promise<RemoteProfileStatus | undefined>;
54
+ logoutSelfHostedProfile(input: SelfHostedProfileLookup): Promise<boolean>;
55
+ refreshSelfHostedProfileIfNeeded(input: RefreshSelfHostedProfileInput): Promise<{
56
+ status: RemoteProfileStatus;
57
+ credential: RemoteProfileCredential;
58
+ } | undefined>;
59
+ refreshCloudProfileIfNeeded(input: RefreshCloudProfileInput): Promise<{
60
+ status: RemoteProfileStatus;
61
+ credential: RemoteProfileCredential;
62
+ } | undefined>;
63
+ saveCloudProfile(input: SaveCloudProfileInput): Promise<RemoteProfileStatus>;
64
+ getCloudProfileStatus(input: CloudProfileLookup): Promise<RemoteProfileStatus | undefined>;
65
+ listCloudProfileStatuses(hostUrlInput: string): Promise<RemoteProfileStatus[]>;
66
+ listProfileStatuses(): Promise<RemoteProfileStatus[]>;
67
+ logoutCloudProfile(input: CloudProfileLookup): Promise<boolean>;
68
+ clearSelectedCloudWorkspace(hostUrlInput: string): Promise<boolean>;
69
+ private selfHostedRefreshSnapshot;
70
+ private cloudRefreshSnapshot;
71
+ private findCloudStatus;
72
+ private migrateLegacyCloudProfile;
73
+ private clearMatchingLegacyCloudAuth;
74
+ private statusByKey;
75
+ private statusFor;
76
+ private writeSelfHostedProfile;
77
+ private writeCloudProfile;
78
+ private listProfilesForHost;
79
+ private readProfile;
80
+ private readProfileFile;
81
+ private readSelectedWorkspace;
82
+ private profilePath;
83
+ private selectedWorkspacePath;
84
+ private profilesDir;
85
+ private selectionsDir;
86
+ private writeJson;
87
+ private withMutationLock;
88
+ private withRefreshLock;
89
+ private acquireLock;
90
+ private releaseLock;
91
+ private clearStaleLock;
92
+ private lockPath;
93
+ private refreshLockPath;
94
+ }
@@ -0,0 +1,47 @@
1
+ export type RemoteProfileKind = "cloud" | "self-hosted";
2
+ export type RemoteProfileKeyInput = {
3
+ kind: RemoteProfileKind;
4
+ hostUrl: string;
5
+ workspace?: string | undefined;
6
+ };
7
+ export type RemoteProfileCredential = {
8
+ accessToken?: string | undefined;
9
+ refreshToken?: string | undefined;
10
+ tokenType?: string | undefined;
11
+ expiresAt?: string | undefined;
12
+ scope?: string[] | undefined;
13
+ clientSecret?: string | undefined;
14
+ pairingCode?: string | undefined;
15
+ };
16
+ export type RemoteProfileStatusInput = {
17
+ kind: RemoteProfileKind;
18
+ hostUrl: string;
19
+ key?: string | undefined;
20
+ workspaceId?: string | undefined;
21
+ workspaceSlug?: string | undefined;
22
+ clientId?: string | undefined;
23
+ selected?: boolean | undefined;
24
+ clientLabel?: string | undefined;
25
+ createdAt?: string | undefined;
26
+ updatedAt?: string | undefined;
27
+ credential?: RemoteProfileCredential | undefined;
28
+ };
29
+ export type RemoteProfileStatus = {
30
+ authenticated: boolean;
31
+ kind: RemoteProfileKind;
32
+ key: string;
33
+ hostUrl: string;
34
+ workspaceId?: string | undefined;
35
+ workspaceSlug?: string | undefined;
36
+ clientId?: string | undefined;
37
+ selected: boolean;
38
+ clientLabel?: string | undefined;
39
+ createdAt?: string | undefined;
40
+ updatedAt?: string | undefined;
41
+ expiresAt?: string | undefined;
42
+ scope?: string[] | undefined;
43
+ tokenType?: string | undefined;
44
+ };
45
+ export declare function remoteProfileKey(input: RemoteProfileKeyInput): string;
46
+ export declare function selectedWorkspaceKey(hostUrl: string): string;
47
+ export declare function remoteProfileStatus(input: RemoteProfileStatusInput): RemoteProfileStatus;
@@ -1,22 +1,22 @@
1
- import { type CloudAuthCredentials } from "../cloud-auth/store";
1
+ import type { CloudAuthCredentials } from "../cloud-auth/store";
2
2
  import { type ResolvedCapletsRemote } from "./options";
3
3
  export type RemoteSelectionInput = {
4
4
  mode?: string;
5
5
  remoteUrl?: string;
6
- user?: string;
7
- password?: string;
8
- token?: string;
9
6
  workspace?: string;
10
7
  fetch?: typeof fetch;
8
+ authDir?: string;
11
9
  };
12
10
  export type ResolvedRemoteSelection = {
13
11
  kind: "self_hosted_remote";
14
12
  remote: ResolvedCapletsRemote;
13
+ credentialExpiresAt?: string | undefined;
15
14
  } | {
16
15
  kind: "hosted_cloud";
17
16
  remote: ResolvedCapletsRemote;
18
17
  selectedWorkspace: string;
19
18
  credentials: CloudAuthCredentials;
19
+ credentialExpiresAt?: string | undefined;
20
20
  cloudPresence: {
21
21
  url: URL;
22
22
  accessToken: string;
@@ -0,0 +1,84 @@
1
+ import type { IssuedRemoteClientCredentials, RemoteClientStatus, ValidatedRemoteClient } from "./server-credentials";
2
+ export type RemoteServerCredentialStoreOptions = {
3
+ dir: string;
4
+ };
5
+ export type CreatePairingCodeInput = {
6
+ hostUrl: string;
7
+ clientLabel?: string | undefined;
8
+ ttlMs?: number | undefined;
9
+ maxAttempts?: number | undefined;
10
+ now?: Date | undefined;
11
+ };
12
+ export type ExchangePairingCodeInput = {
13
+ hostUrl: string;
14
+ code: string;
15
+ clientLabel?: string | undefined;
16
+ now?: Date | undefined;
17
+ };
18
+ export type ValidateAccessTokenInput = {
19
+ hostUrl: string;
20
+ accessToken: string;
21
+ now?: Date | undefined;
22
+ };
23
+ export type RefreshClientCredentialsInput = {
24
+ hostUrl: string;
25
+ refreshToken: string;
26
+ now?: Date | undefined;
27
+ };
28
+ type StoredPairingCode = {
29
+ codeId: string;
30
+ hostUrl: string;
31
+ secretHash: string;
32
+ clientLabel?: string | undefined;
33
+ createdAt: string;
34
+ expiresAt: string;
35
+ attempts: number;
36
+ maxAttempts: number;
37
+ usedAt?: string | undefined;
38
+ };
39
+ type StoredRemoteClient = {
40
+ clientId: string;
41
+ clientLabel: string;
42
+ hostUrl: string;
43
+ accessTokenHash: string;
44
+ accessExpiresAt: string;
45
+ refreshTokenHash: string;
46
+ supersededRefreshTokenHashes: SupersededRefreshToken[];
47
+ refreshFamilyId: string;
48
+ createdAt: string;
49
+ lastUsedAt?: string | undefined;
50
+ revokedAt?: string | undefined;
51
+ };
52
+ type SupersededRefreshToken = {
53
+ hash: string;
54
+ supersededAt: string;
55
+ };
56
+ type RemoteServerCredentialState = {
57
+ version: 1;
58
+ pairingCodes: StoredPairingCode[];
59
+ clients: StoredRemoteClient[];
60
+ };
61
+ export declare class RemoteServerCredentialStore {
62
+ readonly dir: string;
63
+ constructor(options: RemoteServerCredentialStoreOptions);
64
+ createPairingCode(input: CreatePairingCodeInput): {
65
+ codeId: string;
66
+ code: string;
67
+ expiresAt: string;
68
+ };
69
+ exchangePairingCode(input: ExchangePairingCodeInput): IssuedRemoteClientCredentials;
70
+ listClients(): RemoteClientStatus[];
71
+ revokeClient(clientId: string, now?: Date): boolean;
72
+ validateAccessToken(input: ValidateAccessTokenInput): ValidatedRemoteClient;
73
+ refreshClientCredentials(input: RefreshClientCredentialsInput): IssuedRemoteClientCredentials;
74
+ dumpForTest(): RemoteServerCredentialState;
75
+ private loadState;
76
+ private saveState;
77
+ private statePath;
78
+ private lockPath;
79
+ private withStateLock;
80
+ private acquireLock;
81
+ private releaseLock;
82
+ private clearStaleLock;
83
+ }
84
+ export {};
@@ -0,0 +1,21 @@
1
+ export type IssuedRemoteClientCredentials = {
2
+ hostUrl: string;
3
+ clientId: string;
4
+ clientLabel: string;
5
+ accessToken: string;
6
+ refreshToken: string;
7
+ tokenType: "Bearer";
8
+ expiresAt: string;
9
+ createdAt: string;
10
+ };
11
+ export type RemoteClientStatus = {
12
+ clientId: string;
13
+ clientLabel: string;
14
+ hostUrl: string;
15
+ createdAt: string;
16
+ lastUsedAt?: string | undefined;
17
+ revokedAt?: string | undefined;
18
+ };
19
+ export type ValidatedRemoteClient = RemoteClientStatus & {
20
+ tokenType: "Bearer";
21
+ };
@@ -4,8 +4,11 @@ export type RemoteControlClientOptions = {
4
4
  requestInit: RequestInit;
5
5
  fetch?: typeof fetch;
6
6
  };
7
+ export type ResolvedRemoteControlClientOptions = RemoteControlClientOptions;
7
8
  export declare class RemoteControlClient {
8
9
  #private;
9
- constructor(options: RemoteControlClientOptions);
10
+ constructor(options: RemoteControlClientOptions | {
11
+ resolve: () => Promise<ResolvedRemoteControlClientOptions>;
12
+ });
10
13
  request(command: RemoteCliCommand, args: RemoteCliRequest["arguments"]): Promise<unknown>;
11
14
  }
@@ -121,7 +121,10 @@ function assignProp(target, prop, value) {
121
121
  }
122
122
  function mergeDefs(...defs) {
123
123
  const mergedDescriptors = {};
124
- for (const def of defs) Object.assign(mergedDescriptors, Object.getOwnPropertyDescriptors(def));
124
+ for (const def of defs) {
125
+ const descriptors = Object.getOwnPropertyDescriptors(def);
126
+ Object.assign(mergedDescriptors, descriptors);
127
+ }
125
128
  return Object.defineProperties({}, mergedDescriptors);
126
129
  }
127
130
  function esc(str) {
@@ -1424,7 +1427,7 @@ const $ZodBoolean = /*@__PURE__*/ $constructor("$ZodBoolean", (inst, def) => {
1424
1427
  const $ZodNull = /*@__PURE__*/ $constructor("$ZodNull", (inst, def) => {
1425
1428
  $ZodType.init(inst, def);
1426
1429
  inst._zod.pattern = _null$2;
1427
- inst._zod.values = new Set([null]);
1430
+ inst._zod.values = /* @__PURE__ */ new Set([null]);
1428
1431
  inst._zod.parse = (payload, _ctx) => {
1429
1432
  const input = payload.value;
1430
1433
  if (input === null) return payload;
@@ -1575,13 +1578,13 @@ const $ZodObject = /*@__PURE__*/ $constructor("$ZodObject", (inst, def) => {
1575
1578
  }
1576
1579
  return propValues;
1577
1580
  });
1578
- const isObject$1 = isObject;
1581
+ const isObject$2 = isObject;
1579
1582
  const catchall = def.catchall;
1580
1583
  let value;
1581
1584
  inst._zod.parse = (payload, ctx) => {
1582
1585
  value ?? (value = _normalized.value);
1583
1586
  const input = payload.value;
1584
- if (!isObject$1(input)) {
1587
+ if (!isObject$2(input)) {
1585
1588
  payload.issues.push({
1586
1589
  expected: "object",
1587
1590
  code: "invalid_type",
@@ -1704,7 +1707,7 @@ const $ZodObjectJIT = /*@__PURE__*/ $constructor("$ZodObjectJIT", (inst, def) =>
1704
1707
  return (payload, ctx) => fn(shape, payload, ctx);
1705
1708
  };
1706
1709
  let fastpass;
1707
- const isObject$2 = isObject;
1710
+ const isObject$1 = isObject;
1708
1711
  const jit = !globalConfig.jitless;
1709
1712
  const fastEnabled = jit && allowsEval.value;
1710
1713
  const catchall = def.catchall;
@@ -1712,7 +1715,7 @@ const $ZodObjectJIT = /*@__PURE__*/ $constructor("$ZodObjectJIT", (inst, def) =>
1712
1715
  inst._zod.parse = (payload, ctx) => {
1713
1716
  value ?? (value = _normalized.value);
1714
1717
  const input = payload.value;
1715
- if (!isObject$2(input)) {
1718
+ if (!isObject$1(input)) {
1716
1719
  payload.issues.push({
1717
1720
  expected: "object",
1718
1721
  code: "invalid_type",
@@ -2114,7 +2117,7 @@ const $ZodOptional = /*@__PURE__*/ $constructor("$ZodOptional", (inst, def) => {
2114
2117
  inst._zod.optin = "optional";
2115
2118
  inst._zod.optout = "optional";
2116
2119
  defineLazy(inst._zod, "values", () => {
2117
- return def.innerType._zod.values ? new Set([...def.innerType._zod.values, void 0]) : void 0;
2120
+ return def.innerType._zod.values ? /* @__PURE__ */ new Set([...def.innerType._zod.values, void 0]) : void 0;
2118
2121
  });
2119
2122
  defineLazy(inst._zod, "pattern", () => {
2120
2123
  const pattern = def.innerType._zod.pattern;
@@ -2148,7 +2151,7 @@ const $ZodNullable = /*@__PURE__*/ $constructor("$ZodNullable", (inst, def) => {
2148
2151
  return pattern ? new RegExp(`^(${cleanRegex(pattern.source)}|null)$`) : void 0;
2149
2152
  });
2150
2153
  defineLazy(inst._zod, "values", () => {
2151
- return def.innerType._zod.values ? new Set([...def.innerType._zod.values, null]) : void 0;
2154
+ return def.innerType._zod.values ? /* @__PURE__ */ new Set([...def.innerType._zod.values, null]) : void 0;
2152
2155
  });
2153
2156
  inst._zod.parse = (payload, ctx) => {
2154
2157
  if (payload.value === null) return payload;
@@ -3,6 +3,7 @@ import { Hono } from "hono";
3
3
  import { CapletsEngine, type CapletsEngineOptions } from "../engine";
4
4
  import { type RemoteControlDispatchContext } from "../remote-control/dispatch";
5
5
  import { RemoteAuthFlowStore } from "../remote-control/auth-flow";
6
+ import { RemoteServerCredentialStore } from "../remote/server-credential-store";
6
7
  import type { HttpServeOptions } from "./options";
7
8
  type HttpServeIo = {
8
9
  writeErr?: (value: string) => void;
@@ -10,6 +11,7 @@ type HttpServeIo = {
10
11
  authFlowStore?: RemoteAuthFlowStore;
11
12
  sessionFactory?: HttpMcpSessionFactory;
12
13
  exposeAttach?: boolean;
14
+ remoteCredentialStore?: RemoteServerCredentialStore;
13
15
  };
14
16
  type HttpMcpSession = {
15
17
  connect(transport: StreamableHTTPTransport): Promise<void>;
@@ -32,6 +34,9 @@ export declare function servicePaths(base: string): {
32
34
  attachEvents: string;
33
35
  attachInvoke: string;
34
36
  projectBindings: string;
37
+ pairingExchange: string;
38
+ remoteRefresh: string;
39
+ remoteClient: string;
35
40
  health: string;
36
41
  };
37
42
  export {};
@@ -1,13 +1,11 @@
1
1
  import type { CapletsEngineOptions } from "../engine";
2
2
  import { type RawServeOptions, type ServeOptions } from "./options";
3
3
  export { serveHttp } from "./http";
4
- export { resolveDaemonServeOptions, resolveServeOptions } from "./options";
4
+ export { resolveServeOptions } from "./options";
5
5
  export type { HttpServeOptions, RawServeOptions, ServeOptions, StdioServeOptions } from "./options";
6
6
  export { NativeCapletsMcpSession } from "./native-session";
7
7
  export type { NativeCapletsMcpSessionOptions, NativeToolServer } from "./native-session";
8
8
  export { serveStdio } from "./stdio";
9
- export { buildDaemonPlatformDescriptor, daemonStatus, disableDaemon, enableDaemon, resolveServeDaemonPaths, restartDaemon, startDaemon, stopDaemon, } from "./daemon";
10
- export type { DaemonPlatformDescriptor, DaemonProcessRunner, ServeDaemonConfig, ServeDaemonOperationOptions, ServeDaemonPaths, ServeDaemonState, ServeDaemonStatus, } from "./daemon";
11
9
  export type ServeCapletsOptions = {
12
10
  raw: RawServeOptions;
13
11
  engine?: CapletsEngineOptions;
@@ -4,8 +4,7 @@ export type RawServeOptions = {
4
4
  host?: string;
5
5
  port?: string | number;
6
6
  path?: string;
7
- user?: string;
8
- password?: string;
7
+ remoteStatePath?: string;
9
8
  allowUnauthenticatedHttp?: boolean;
10
9
  trustProxy?: boolean;
11
10
  };
@@ -18,22 +17,18 @@ export type HttpServeOptions = {
18
17
  port: number;
19
18
  path: string;
20
19
  publicOrigin?: string | undefined;
21
- auth: HttpBasicAuthOptions;
20
+ auth: HttpServeAuthOptions;
21
+ remoteCredentialStateDir?: string | undefined;
22
22
  allowUnauthenticatedHttp: boolean;
23
23
  warnUnauthenticatedNetwork: boolean;
24
24
  loopback: boolean;
25
25
  trustProxy: boolean;
26
26
  };
27
- export type HttpBasicAuthOptions = {
28
- enabled: false;
29
- user: string;
27
+ export type HttpServeAuthOptions = {
28
+ type: "remote_credentials";
30
29
  } | {
31
- enabled: true;
32
- user: string;
33
- password: string;
30
+ type: "development_unauthenticated";
34
31
  };
35
32
  export type ServeOptions = StdioServeOptions | HttpServeOptions;
36
- export type ServeEnv = Partial<Record<"CAPLETS_SERVER_URL" | "CAPLETS_SERVER_USER" | "CAPLETS_SERVER_PASSWORD", string>>;
33
+ export type ServeEnv = Partial<Record<"CAPLETS_SERVER_URL" | "CAPLETS_REMOTE_SERVER_STATE_DIR", string>>;
37
34
  export declare function resolveServeOptions(raw: RawServeOptions, env?: ServeEnv): ServeOptions;
38
- export declare function resolveDaemonServeOptions(raw: RawServeOptions, env?: ServeEnv): HttpServeOptions;
39
- export declare function isLoopbackHost(host: string): boolean;
@@ -1,22 +1,15 @@
1
1
  export type CapletsMode = "auto" | "local" | "remote";
2
- export type CapletsServerEnv = Partial<Record<"CAPLETS_MODE" | "CAPLETS_SERVER_URL" | "CAPLETS_SERVER_USER" | "CAPLETS_SERVER_PASSWORD" | "CAPLETS_CLOUD_URL" | "CAPLETS_CLOUD_TOKEN" | "CAPLETS_CLOUD_WORKSPACE_ID" | "CAPLETS_PROJECT_ROOT", string>>;
2
+ export type CapletsServerEnv = Partial<Record<"CAPLETS_MODE" | "CAPLETS_SERVER_URL" | "CAPLETS_CLOUD_URL" | "CAPLETS_CLOUD_TOKEN" | "CAPLETS_CLOUD_WORKSPACE_ID" | "CAPLETS_PROJECT_ROOT", string>>;
3
3
  export type CapletsModeInput = {
4
4
  mode?: string;
5
5
  serverUrl?: string;
6
6
  };
7
7
  export type CapletsServerInput = {
8
8
  url?: string;
9
- user?: string;
10
- password?: string;
11
9
  fetch?: typeof fetch;
12
10
  };
13
11
  export type CapletsServerAuth = {
14
- enabled: false;
15
- user: string;
16
- } | {
17
- enabled: true;
18
- user: string;
19
- password: string;
12
+ type: "none";
20
13
  };
21
14
  export type ResolvedCapletsServer = {
22
15
  baseUrl: URL;