@squidcloud/backend 1.0.483 → 1.0.485
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/backend/src/cli-agent/claude-code.adapter.d.ts +75 -0
- package/dist/backend/src/cli-agent/cli-agent-adapter.types.d.ts +122 -0
- package/dist/backend/src/cli-agent/cli-agent-process-launcher.d.ts +22 -0
- package/dist/backend/src/cli-agent/cli-agent-process-runner.d.ts +35 -0
- package/dist/backend/src/cli-agent/codex.adapter.d.ts +67 -0
- package/dist/backend/src/cli-agent/index.d.ts +7 -0
- package/dist/backend/src/cli-agent/nsjail-source-process-launcher.d.ts +43 -0
- package/dist/backend/src/cli-agent/workspace.utils.d.ts +20 -0
- package/dist/backend/src/internal/source-code.d.ts +3 -0
- package/dist/backend/src/public-types.d.ts +4 -0
- package/dist/backend/src/source-code/index.d.ts +22 -0
- package/dist/backend/src/source-code/local-source-development-runner.d.ts +10 -0
- package/dist/backend/src/source-code/providers/bitbucket-cloud.client.d.ts +20 -0
- package/dist/backend/src/source-code/providers/github-app.client.d.ts +45 -0
- package/dist/backend/src/source-code/providers/index.d.ts +2 -0
- package/dist/backend/src/source-code/restricted-source-runner.d.ts +86 -0
- package/dist/backend/src/source-code/source-analysis-admission-controller.d.ts +35 -0
- package/dist/backend/src/source-code/source-code-analyzer.d.ts +60 -0
- package/dist/backend/src/source-code/source-code-errors.d.ts +13 -0
- package/dist/backend/src/source-code/source-code-limits.d.ts +33 -0
- package/dist/backend/src/source-code/source-code-telemetry.d.ts +35 -0
- package/dist/backend/src/source-code/source-development-runtime.d.ts +2 -0
- package/dist/backend/src/source-code/source-egress-proxy.d.ts +123 -0
- package/dist/backend/src/source-code/source-evidence-verifier.d.ts +30 -0
- package/dist/backend/src/source-code/source-git-command.d.ts +82 -0
- package/dist/backend/src/source-code/source-git-credential-helper.d.ts +5 -0
- package/dist/backend/src/source-code/source-model-proxy.constants.d.ts +6 -0
- package/dist/backend/src/source-code/source-provider-adapter.d.ts +87 -0
- package/dist/backend/src/source-code/source-provider-operation-broker.d.ts +111 -0
- package/dist/backend/src/source-code/source-repository-snapshot.d.ts +15 -0
- package/dist/backend/src/source-code/source-socket-admission.d.ts +17 -0
- package/dist/backend/src/source-code/source-submodule-url.d.ts +10 -0
- package/dist/backend/src/source-code/source-workspace-manager.d.ts +169 -0
- package/dist/backend/src/source-code/source-workspace-manifest.d.ts +43 -0
- package/dist/backend/src/source-code/windows-local-cli-process-launcher.d.ts +13 -0
- package/dist/backend/src/squid.service.d.ts +16 -0
- package/dist/backend/src/workspace-client.d.ts +104 -2
- package/dist/cjs/index.js +1 -1
- package/dist/cjs/internal/source-code.js +1 -0
- package/dist/esm/index.js +1 -1
- package/dist/esm/internal/source-code.js +1 -0
- package/dist/internal-common/src/public-types-backend/bundle-data.public-types.d.ts +1 -1
- package/package.json +24 -2
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
import type { SourceCodeRef, SourceRepository } from '@squidcloud/client';
|
|
2
|
+
import { WorkspaceAcquireLeaseOptions, WorkspaceMetadata } from '../workspace-client';
|
|
3
|
+
import { SourceCodeLimits } from './source-code-limits';
|
|
4
|
+
import { SourceGitCommand } from './source-git-command';
|
|
5
|
+
import { SourceGitCredentialHelper } from './source-git-credential-helper';
|
|
6
|
+
import type { SourceProviderAdapter, SourceProviderFailureClassification, TrustedGitTlsProvider } from './source-provider-adapter';
|
|
7
|
+
import type { SourceRepositorySnapshot } from './source-repository-snapshot';
|
|
8
|
+
/** Represents the lease lifecycle consumed by source workspace orchestration. */
|
|
9
|
+
export interface SourceWorkspaceLease {
|
|
10
|
+
/** Aborts analysis immediately when exclusive ownership is lost. */
|
|
11
|
+
readonly signal: AbortSignal;
|
|
12
|
+
/** Throws when the local lease identity is no longer active. */
|
|
13
|
+
assertActive(): void;
|
|
14
|
+
/** Confirms exclusive ownership against Core. */
|
|
15
|
+
assertActiveRemotely(): Promise<void>;
|
|
16
|
+
/** Releases exclusive ownership. */
|
|
17
|
+
release(): Promise<void>;
|
|
18
|
+
}
|
|
19
|
+
/** Represents the shared workspace operations consumed by source orchestration. */
|
|
20
|
+
export interface SourceWorkspaceClient {
|
|
21
|
+
/** Acquires exclusive ownership of one integration-wide cache. */
|
|
22
|
+
acquireLease(workspaceId: string, options?: WorkspaceAcquireLeaseOptions): Promise<SourceWorkspaceLease>;
|
|
23
|
+
/** Pulls the latest shared cache to this pod. */
|
|
24
|
+
create(id: string, options?: {
|
|
25
|
+
signal?: AbortSignal;
|
|
26
|
+
}): Promise<WorkspaceMetadata>;
|
|
27
|
+
/** Pushes the trusted cache while proving the active fencing identity. */
|
|
28
|
+
push(id: string, options?: {
|
|
29
|
+
lease?: SourceWorkspaceLease;
|
|
30
|
+
}): Promise<WorkspaceMetadata>;
|
|
31
|
+
/** Removes a pod-local copy that must not be reused. */
|
|
32
|
+
discardLocal(id: string): Promise<void>;
|
|
33
|
+
}
|
|
34
|
+
/** Contains one repository prepared for an isolated analyzer. */
|
|
35
|
+
export interface PreparedSourceRepository {
|
|
36
|
+
/** Stores canonical provider repository metadata. */
|
|
37
|
+
repository: SourceRepository;
|
|
38
|
+
/** Points to the disposable repository inside the analyzer root. */
|
|
39
|
+
analyzerDirectory: string;
|
|
40
|
+
/** Identifies the repository directory relative to the analyzer root. */
|
|
41
|
+
workspacePath: string;
|
|
42
|
+
/** Stores the selected canonical reference. */
|
|
43
|
+
defaultRef: string;
|
|
44
|
+
/** Stores the selected cached commit when available. */
|
|
45
|
+
cachedCommitSha?: string;
|
|
46
|
+
/** Stores the latest successful fetch time. */
|
|
47
|
+
fetchedAt?: string;
|
|
48
|
+
/** Marks a snapshot retained after a transient provider failure. */
|
|
49
|
+
stale: boolean;
|
|
50
|
+
/** Captures immutable trusted refs before the analyzer starts. */
|
|
51
|
+
snapshot: SourceRepositorySnapshot;
|
|
52
|
+
}
|
|
53
|
+
/** Contains one allowlisted submodule materialized at its exact gitlink commit. */
|
|
54
|
+
export interface PreparedSourceSubmodule {
|
|
55
|
+
/** Stores canonical provider repository metadata. */
|
|
56
|
+
repository: SourceRepository;
|
|
57
|
+
/** Points to the disposable submodule inside the analyzer root. */
|
|
58
|
+
analyzerDirectory: string;
|
|
59
|
+
/** Identifies the immediate repository containing the gitlink. */
|
|
60
|
+
parentRepository: string;
|
|
61
|
+
/** Identifies the gitlink path relative to its immediate parent repository. */
|
|
62
|
+
submodulePath: string;
|
|
63
|
+
/** Identifies the submodule directory relative to the analyzer root. */
|
|
64
|
+
workspacePath: string;
|
|
65
|
+
/** Stores the exact commit selected by the parent gitlink. */
|
|
66
|
+
commitSha: string;
|
|
67
|
+
/** Exposes the exact commit reference required for analyzer evidence. */
|
|
68
|
+
ref: SourceCodeRef;
|
|
69
|
+
/** Marks a snapshot retained after a transient provider failure. */
|
|
70
|
+
stale: boolean;
|
|
71
|
+
/** Captures immutable trusted refs used to prove the gitlink commit. */
|
|
72
|
+
snapshot: SourceRepositorySnapshot;
|
|
73
|
+
}
|
|
74
|
+
/** Contains disposable repositories and trusted verification state for one run. */
|
|
75
|
+
export interface PreparedSourceWorkspace {
|
|
76
|
+
/** Points to the only source tree mounted into the analyzer sandbox. */
|
|
77
|
+
analyzerRootDirectory: string;
|
|
78
|
+
/** Points to the persistent trusted root used only by the verifier. */
|
|
79
|
+
trustedWorkspaceRootDirectory: string;
|
|
80
|
+
/** Lists prepared allowlisted repositories. */
|
|
81
|
+
repositories: readonly PreparedSourceRepository[];
|
|
82
|
+
/** Lists allowlisted submodules materialized below the selected repositories. */
|
|
83
|
+
submodules: readonly PreparedSourceSubmodule[];
|
|
84
|
+
/** Lists bounded preparation warnings. */
|
|
85
|
+
warnings: readonly string[];
|
|
86
|
+
/** Aborts the analyzer when exclusive ownership is lost. */
|
|
87
|
+
leaseSignal: AbortSignal;
|
|
88
|
+
/** Describes whether trusted caches were created or reused. */
|
|
89
|
+
cacheState: 'first-clone' | 'reused' | 'mixed';
|
|
90
|
+
/** Measures time spent acquiring exclusive ownership. */
|
|
91
|
+
leaseWaitMs: number;
|
|
92
|
+
/** Measures trusted cache bytes after preparation. */
|
|
93
|
+
workspaceBytes: number;
|
|
94
|
+
}
|
|
95
|
+
/** Selects the integration and optional requested ref for one prepared run. */
|
|
96
|
+
export interface PrepareSourceWorkspaceInput {
|
|
97
|
+
/** Identifies the application using the cache. */
|
|
98
|
+
appId: string;
|
|
99
|
+
/** Identifies the connected source integration. */
|
|
100
|
+
integrationId: string;
|
|
101
|
+
/** Supplies provider authorization and canonical repository metadata. */
|
|
102
|
+
adapter: SourceProviderAdapter;
|
|
103
|
+
/** Narrows preparation to exact allowlisted repository names or unique slugs. */
|
|
104
|
+
repositoryHints?: string;
|
|
105
|
+
/** Requests one captured branch, tag, or advertised commit. */
|
|
106
|
+
requestedRef?: string;
|
|
107
|
+
}
|
|
108
|
+
/** Contains a callback value and a nonfatal shared-persistence warning. */
|
|
109
|
+
export interface PreparedSourceWorkspaceResult<T> {
|
|
110
|
+
/** Stores the verified callback value. */
|
|
111
|
+
value: T;
|
|
112
|
+
/** Warns when the trusted cache could not be synchronized. */
|
|
113
|
+
persistenceWarning?: string;
|
|
114
|
+
}
|
|
115
|
+
/** Classifies preparation failures for stale-cache authorization. */
|
|
116
|
+
export type SourceFetchFailureClassification = SourceProviderFailureClassification;
|
|
117
|
+
/** Configures testable boundaries for source workspace orchestration. */
|
|
118
|
+
export interface SourceWorkspaceManagerOptions {
|
|
119
|
+
/** Overrides the shared workspace client. */
|
|
120
|
+
workspaceClient?: SourceWorkspaceClient;
|
|
121
|
+
/** Overrides trusted Git limits. */
|
|
122
|
+
limits?: SourceCodeLimits;
|
|
123
|
+
/** Selects the private parent for disposable repositories. */
|
|
124
|
+
runtimeRootDirectory?: string;
|
|
125
|
+
/** Overrides the hardened Git command boundary. */
|
|
126
|
+
gitCommand?: SourceGitCommand;
|
|
127
|
+
/** Overrides the ephemeral HTTPS credential helper. */
|
|
128
|
+
credentialHelper?: SourceGitCredentialHelper;
|
|
129
|
+
/** Overrides the cancellation-aware cache-promotion copy boundary. */
|
|
130
|
+
copyDirectory?: (sourceDirectory: string, destinationDirectory: string, signal: AbortSignal) => Promise<void>;
|
|
131
|
+
/** Supplies trusted Git TLS material. */
|
|
132
|
+
tlsProvider?: TrustedGitTlsProvider;
|
|
133
|
+
/** Maps a canonical URL to a test remote without changing stored provenance. */
|
|
134
|
+
remoteUrlResolver?: (repository: SourceRepository) => string;
|
|
135
|
+
/** Overrides typed fetch-failure classification in integration tests. */
|
|
136
|
+
classifyFetchFailure?: (error: unknown) => SourceFetchFailureClassification;
|
|
137
|
+
/** Supplies a deterministic clock. */
|
|
138
|
+
now?: () => Date;
|
|
139
|
+
}
|
|
140
|
+
/** Owns trusted cache reconciliation, disposable clones, leases, and persistence. */
|
|
141
|
+
export declare class SourceWorkspaceManager {
|
|
142
|
+
private readonly classifyFetchFailure;
|
|
143
|
+
private readonly credentialHelper;
|
|
144
|
+
private readonly copyDirectory;
|
|
145
|
+
private readonly git;
|
|
146
|
+
private readonly limits;
|
|
147
|
+
private readonly now;
|
|
148
|
+
private readonly remoteUrlResolver;
|
|
149
|
+
private readonly runtimeRootDirectory;
|
|
150
|
+
private readonly tlsProvider;
|
|
151
|
+
private readonly workspaceClient;
|
|
152
|
+
/** Creates a production manager unless explicit test boundaries are supplied. */
|
|
153
|
+
constructor(options?: SourceWorkspaceManagerOptions);
|
|
154
|
+
/** Runs a callback over disposable repositories and persists only trusted cache state. */
|
|
155
|
+
withPreparedWorkspace<T>(input: PrepareSourceWorkspaceInput, run: (workspace: PreparedSourceWorkspace) => Promise<T>): Promise<PreparedSourceWorkspaceResult<T>>;
|
|
156
|
+
private prepareTrustedWorkspace;
|
|
157
|
+
private prepareRepositoryBatch;
|
|
158
|
+
private prepareAllowlistedSubmoduleDependencies;
|
|
159
|
+
private prepareRepositories;
|
|
160
|
+
private fetchRepository;
|
|
161
|
+
private prepareStaleRepositories;
|
|
162
|
+
private prepareStaleRepository;
|
|
163
|
+
private populateDisposableWorkspace;
|
|
164
|
+
private materializeAllowlistedSubmodules;
|
|
165
|
+
private materializeRepository;
|
|
166
|
+
private withTrustedGitEnvironment;
|
|
167
|
+
private runGit;
|
|
168
|
+
private discardLocalSafely;
|
|
169
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type { SourceControlProvider, SourceRepository } from '@squidcloud/client';
|
|
2
|
+
/** Names the trusted workspace manifest. */
|
|
3
|
+
export declare const SOURCE_WORKSPACE_MANIFEST_FILENAME = ".squid-source-workspace.json";
|
|
4
|
+
/** Identifies the current trusted workspace manifest schema. */
|
|
5
|
+
export declare const SOURCE_WORKSPACE_MANIFEST_VERSION: 2;
|
|
6
|
+
/** Records one trusted repository without source content or credentials. */
|
|
7
|
+
export interface SourceWorkspaceManifestRepository {
|
|
8
|
+
/** Stores the provider's immutable repository identifier. */
|
|
9
|
+
providerRepositoryId: string;
|
|
10
|
+
/** Stores the canonical owner/repository name. */
|
|
11
|
+
fullName: string;
|
|
12
|
+
/** Stores the canonical HTTPS clone URL used by trusted Git. */
|
|
13
|
+
cloneUrl: string;
|
|
14
|
+
/** Stores the last provider-verified default branch. */
|
|
15
|
+
defaultBranch: string;
|
|
16
|
+
/** Stores the canonical provider web URL. */
|
|
17
|
+
webUrl: string;
|
|
18
|
+
/** Stores the deterministic trusted-cache directory name. */
|
|
19
|
+
directory: string;
|
|
20
|
+
/** Stores the selected commit from the latest successful fetch. */
|
|
21
|
+
lastFetchedSha?: string;
|
|
22
|
+
/** Stores the latest successful fetch timestamp. */
|
|
23
|
+
fetchedAt?: string;
|
|
24
|
+
/** Marks a snapshot retained after a transient provider failure. */
|
|
25
|
+
stale: boolean;
|
|
26
|
+
}
|
|
27
|
+
/** Records trusted source-cache identity and freshness. */
|
|
28
|
+
export interface SourceWorkspaceManifest {
|
|
29
|
+
/** Identifies the manifest schema. */
|
|
30
|
+
version: typeof SOURCE_WORKSPACE_MANIFEST_VERSION;
|
|
31
|
+
/** Identifies the source-control provider. */
|
|
32
|
+
provider: SourceControlProvider;
|
|
33
|
+
/** Stores a one-way integration identity. */
|
|
34
|
+
integrationIdHash: string;
|
|
35
|
+
/** Lists trusted repository cache records. */
|
|
36
|
+
repositories: SourceWorkspaceManifestRepository[];
|
|
37
|
+
}
|
|
38
|
+
/** Derives a filesystem-safe repository directory with an immutable identity suffix. */
|
|
39
|
+
export declare function sourceRepositoryDirectory(repository: SourceRepository): string;
|
|
40
|
+
/** Hashes an integration identifier before it enters a shared source manifest. */
|
|
41
|
+
export declare function sourceIntegrationIdHash(integrationId: string): string;
|
|
42
|
+
/** Parses a trusted source manifest and rejects unknown or unsafe fields. */
|
|
43
|
+
export declare function parseSourceWorkspaceManifest(value: unknown, provider: SourceControlProvider, integrationId: string): SourceWorkspaceManifest;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { ChildProcess } from 'node:child_process';
|
|
2
|
+
import type { CliAgentLaunchRequest, CliAgentProcessLauncher } from '../cli-agent/cli-agent-process-launcher';
|
|
3
|
+
/** Launches a local Windows analyzer without interpolating its arguments through a command shell. */
|
|
4
|
+
export declare class WindowsLocalCliProcessLauncher implements CliAgentProcessLauncher {
|
|
5
|
+
private readonly workingDirectory;
|
|
6
|
+
private readonly sensitiveFiles;
|
|
7
|
+
/** Creates a launcher fixed to one prepared source directory. */
|
|
8
|
+
constructor(workingDirectory: string, sensitiveFiles?: readonly string[]);
|
|
9
|
+
/** Launches a native executable or PowerShell shim with literal arguments. */
|
|
10
|
+
launch(request: CliAgentLaunchRequest): Promise<ChildProcess>;
|
|
11
|
+
}
|
|
12
|
+
/** Replaces inherited file permissions with full control for only the current Windows identity. */
|
|
13
|
+
export declare function restrictWindowsFileToCurrentUser(filePath: string): Promise<void>;
|
|
@@ -62,6 +62,22 @@ export declare class SquidService {
|
|
|
62
62
|
* @returns The auth object for the current request or undefined if unauthenticated or if using a user token.
|
|
63
63
|
*/
|
|
64
64
|
getApiKeyAuth(): AuthWithApiKey | undefined;
|
|
65
|
+
/**
|
|
66
|
+
* Whether this service is holding in-memory state that would be lost if the worker running it were
|
|
67
|
+
* recycled. Override it to return true while such state exists — an idle worker is normally torn
|
|
68
|
+
* down after a few minutes, which is invisible for a stateless service and destructive for one
|
|
69
|
+
* keeping a live session, a warm cache or a child process alive between calls.
|
|
70
|
+
*
|
|
71
|
+
* The runtime asks often and expects a cheap, synchronous answer. Returning true indefinitely pins
|
|
72
|
+
* the worker for as long as the pod lives, so it should track the state's own lifetime.
|
|
73
|
+
*/
|
|
74
|
+
hasLiveState(): boolean;
|
|
75
|
+
/**
|
|
76
|
+
* Releases whatever {@link hasLiveState} was reporting. Called by the runtime when the worker is
|
|
77
|
+
* being terminated. Override it together with `hasLiveState` whenever the state owns something the
|
|
78
|
+
* worker's own shutdown does not reclaim — a child process outlives the thread that spawned it.
|
|
79
|
+
*/
|
|
80
|
+
releaseLiveState(): Promise<void>;
|
|
65
81
|
/**
|
|
66
82
|
* Returns true if the current request is authenticated (using a user token or an API key).
|
|
67
83
|
*
|
|
@@ -21,6 +21,47 @@ export interface WorkspaceCreateOptions {
|
|
|
21
21
|
* workspace keeps its stored TTL (or the default — one day — for a new one).
|
|
22
22
|
*/
|
|
23
23
|
idleTtlSeconds?: number;
|
|
24
|
+
/** Cancels local synchronization before the caller loses ownership. */
|
|
25
|
+
signal?: AbortSignal;
|
|
26
|
+
}
|
|
27
|
+
/** Options controlling bounded acquisition of an exclusive workspace lease. */
|
|
28
|
+
export interface WorkspaceAcquireLeaseOptions {
|
|
29
|
+
/** Lease lifetime measured from Core's current time. Defaults to 60 seconds. */
|
|
30
|
+
leaseTtlSeconds?: number;
|
|
31
|
+
/** Maximum time spent retrying a busy workspace. Defaults to five minutes. */
|
|
32
|
+
acquisitionTimeoutMs?: number;
|
|
33
|
+
}
|
|
34
|
+
/** Options for publishing a workspace directory. */
|
|
35
|
+
export interface WorkspacePushOptions {
|
|
36
|
+
/** Exclusive lease used for a staged, fenced publish. Omit only for legacy callers. */
|
|
37
|
+
lease?: WorkspaceLease;
|
|
38
|
+
}
|
|
39
|
+
/** Injectable Core RPC boundary used by direct SDK integration tests and non-global hosts. */
|
|
40
|
+
export interface WorkspaceRpcTransport {
|
|
41
|
+
/** Posts a workspace request to Core with an optional cancellation signal. */
|
|
42
|
+
post<ResponseType>(path: string, request: unknown, abortSignal?: AbortSignal): Promise<ResponseType>;
|
|
43
|
+
}
|
|
44
|
+
/** Construction options for hosts that supply their own RPC boundary or lease identity. */
|
|
45
|
+
export interface WorkspaceClientOptions {
|
|
46
|
+
/** Overrides the default Squid RPC transport. */
|
|
47
|
+
rpcTransport?: WorkspaceRpcTransport;
|
|
48
|
+
/** Overrides the prefix used for the unique owner identity created by each acquisition. */
|
|
49
|
+
leaseOwnerId?: string;
|
|
50
|
+
/** Overrides the default 20-second automatic heartbeat interval. */
|
|
51
|
+
leaseHeartbeatIntervalMs?: number;
|
|
52
|
+
/** Overrides this process's pod-local workspace cache root. */
|
|
53
|
+
localCacheRoot?: string;
|
|
54
|
+
}
|
|
55
|
+
/** Public lease identity returned by Core and maintained by {@link WorkspaceLease}. */
|
|
56
|
+
export interface WorkspaceLeaseIdentity {
|
|
57
|
+
/** Identifies the leased workspace. */
|
|
58
|
+
workspaceId: string;
|
|
59
|
+
/** Identifies the unique lease owner. */
|
|
60
|
+
ownerId: string;
|
|
61
|
+
/** Fences writes from superseded owners. */
|
|
62
|
+
fencingToken: number;
|
|
63
|
+
/** Stores the newest expiry accepted from Core. */
|
|
64
|
+
expiresAt: string;
|
|
24
65
|
}
|
|
25
66
|
/**
|
|
26
67
|
* Returns whether the shared workspace server is configured on this pod. Callers that want to degrade
|
|
@@ -28,6 +69,46 @@ export interface WorkspaceCreateOptions {
|
|
|
28
69
|
* before calling `WorkspaceClient` methods, which throw when it is not configured.
|
|
29
70
|
*/
|
|
30
71
|
export declare function isWorkspaceServerConfigured(): boolean;
|
|
72
|
+
/**
|
|
73
|
+
* Holds exclusive workspace ownership and maintains it with periodic heartbeats until released or lost.
|
|
74
|
+
*/
|
|
75
|
+
export declare class WorkspaceLease {
|
|
76
|
+
private readonly leaseTtlSeconds;
|
|
77
|
+
private readonly heartbeatIntervalMs;
|
|
78
|
+
private readonly rpcTransport;
|
|
79
|
+
readonly signal: AbortSignal;
|
|
80
|
+
readonly workspaceId: string;
|
|
81
|
+
readonly ownerId: string;
|
|
82
|
+
readonly fencingToken: number;
|
|
83
|
+
private readonly abortController;
|
|
84
|
+
private expiryTimer?;
|
|
85
|
+
private heartbeatPromise?;
|
|
86
|
+
private heartbeatTimer?;
|
|
87
|
+
private expiresAtValue;
|
|
88
|
+
private state;
|
|
89
|
+
/** Creates and starts maintaining a lease returned by Core. */
|
|
90
|
+
constructor(identity: WorkspaceLeaseIdentity, leaseTtlSeconds: number, heartbeatIntervalMs: number, rpcTransport: WorkspaceRpcTransport);
|
|
91
|
+
/** Returns the newest lease expiry accepted from Core. */
|
|
92
|
+
get expiresAt(): string;
|
|
93
|
+
/** Renews the lease once, coalescing concurrent callers onto one RPC. */
|
|
94
|
+
heartbeat(): Promise<void>;
|
|
95
|
+
/** Releases this owner/token without affecting any successor lease. */
|
|
96
|
+
release(): Promise<void>;
|
|
97
|
+
/** Throws synchronously when the local lease identity is unusable. */
|
|
98
|
+
assertActive(): void;
|
|
99
|
+
/** Confirms the lease against Core and refreshes its local expiry monotonically. */
|
|
100
|
+
assertActiveRemotely(): Promise<void>;
|
|
101
|
+
private startHeartbeat;
|
|
102
|
+
private scheduleExpiry;
|
|
103
|
+
private stopExpiryTimer;
|
|
104
|
+
private stopHeartbeat;
|
|
105
|
+
private performHeartbeat;
|
|
106
|
+
private postWhileActive;
|
|
107
|
+
private applyIdentity;
|
|
108
|
+
private assertMatchingIdentity;
|
|
109
|
+
private markInactive;
|
|
110
|
+
private leaseLostError;
|
|
111
|
+
}
|
|
31
112
|
/**
|
|
32
113
|
* Experimental, backend-only API for a scratch directory ("workspace") that survives across `ask()` calls
|
|
33
114
|
* and pod replicas. The directory lives on this pod's local disk for fast reads/writes; `create` and
|
|
@@ -49,6 +130,14 @@ export declare class WorkspaceClient {
|
|
|
49
130
|
* — every connection is gated by a fresh, per-workspace certificate.
|
|
50
131
|
*/
|
|
51
132
|
private podKeypairReady?;
|
|
133
|
+
private readonly rpcTransport;
|
|
134
|
+
private readonly leaseOwnerIdPrefix;
|
|
135
|
+
private readonly leaseHeartbeatIntervalMs;
|
|
136
|
+
private readonly localCacheRoot;
|
|
137
|
+
/** Creates a workspace client using Squid's RPC transport by default. */
|
|
138
|
+
constructor(options?: WorkspaceClientOptions);
|
|
139
|
+
/** Acquires exclusive ownership, retrying a busy workspace within the requested bound. */
|
|
140
|
+
acquireLease(workspaceId: string, options?: WorkspaceAcquireLeaseOptions): Promise<WorkspaceLease>;
|
|
52
141
|
/**
|
|
53
142
|
* Ensures the workspace directory exists on this pod and reflects the latest push, generating a
|
|
54
143
|
* new workspace id when none is given. Safe to call repeatedly: pulls from the workspace server only
|
|
@@ -56,7 +145,9 @@ export declare class WorkspaceClient {
|
|
|
56
145
|
*/
|
|
57
146
|
create(id?: string, options?: WorkspaceCreateOptions): Promise<WorkspaceMetadata>;
|
|
58
147
|
/** Syncs the current state of the workspace directory to the workspace server as the new authoritative state. */
|
|
59
|
-
push(id: string): Promise<WorkspaceMetadata>;
|
|
148
|
+
push(id: string, options?: WorkspacePushOptions): Promise<WorkspaceMetadata>;
|
|
149
|
+
/** Removes only this client's pod-local copy without changing the shared workspace. */
|
|
150
|
+
discardLocal(id: string): Promise<void>;
|
|
60
151
|
/**
|
|
61
152
|
* Deletes the workspace everywhere it canonically exists: its directory on the workspace server and its
|
|
62
153
|
* GC tracking record (both via core), plus every copy on this pod — the live directory, its marker, and
|
|
@@ -65,6 +156,12 @@ export declare class WorkspaceClient {
|
|
|
65
156
|
*/
|
|
66
157
|
delete(id: string): Promise<void>;
|
|
67
158
|
private buildMetadata;
|
|
159
|
+
private buildCommitPushRequest;
|
|
160
|
+
private assertLeaseForWorkspace;
|
|
161
|
+
private resolveLocalWorkspaceDir;
|
|
162
|
+
private resolveLocalWorkspaceMarkerPath;
|
|
163
|
+
private resolveLocalWorkspaceQuarantineDir;
|
|
164
|
+
private markLocalWorkspaceUsed;
|
|
68
165
|
/**
|
|
69
166
|
* Pulls the workspace server's copy into `dir`, replacing its content (`--delete`) so a file removed
|
|
70
167
|
* remotely by another pod's push doesn't linger locally and get resurrected by a later push.
|
|
@@ -79,6 +176,7 @@ export declare class WorkspaceClient {
|
|
|
79
176
|
* expires, so it is re-fetched per operation.
|
|
80
177
|
*/
|
|
81
178
|
private rsync;
|
|
179
|
+
private rsyncThroughWsl;
|
|
82
180
|
/**
|
|
83
181
|
* Ensures this pod's ephemeral keypair exists on disk, generating it exactly once. The keypair is a bare
|
|
84
182
|
* identity holder reused for the pod's lifetime; it grants no access without a current certificate.
|
|
@@ -94,8 +192,12 @@ export declare class WorkspaceClient {
|
|
|
94
192
|
* directory server-side, and rrsync resolves the requested path relative to that restricted root.
|
|
95
193
|
*/
|
|
96
194
|
private remoteTarget;
|
|
97
|
-
/** Returns true when
|
|
195
|
+
/** Returns true when rsync reports that the remote workspace has no snapshot yet. */
|
|
98
196
|
private isMissingRemoteError;
|
|
197
|
+
private isWorkspaceBusyError;
|
|
198
|
+
private isTimeoutError;
|
|
199
|
+
private createLeaseOwnerId;
|
|
200
|
+
private resolveLeaseHeartbeatIntervalMs;
|
|
99
201
|
private sshHost;
|
|
100
202
|
private sshPort;
|
|
101
203
|
private sshUser;
|