@squidcloud/backend 1.0.486 → 1.0.488

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.
@@ -65,6 +65,17 @@ export declare class CodexCliAdapter implements AgentCliSessionAdapter {
65
65
  completeRun(outcome: CliRunOutcome): void;
66
66
  /** Deletes temporary MCP and working-directory state. */
67
67
  afterRun(ctx: SessionCtx): Promise<void>;
68
+ /**
69
+ * Whether this run's sandbox home is a host directory this adapter may write into, which is what
70
+ * separates a session from a restricted source run: the latter's home materialises inside the jail,
71
+ * so it delegates every file it needs — the auth file included — to the rootfs entrypoint.
72
+ */
73
+ private get ownsSandboxHome();
74
+ /**
75
+ * Whether this run gets the session temporary directory of {@link TMPDIR_REL}. A restricted run is
76
+ * excluded on both counts named there: it brings its own, and only a host-owned home can hold one.
77
+ */
78
+ private get ownsSessionTmpDir();
68
79
  /** Writes the captured thread id into the sidecar so it round-trips with the session blob. */
69
80
  private persistThreadId;
70
81
  private readPersistedThreadId;
@@ -1,7 +1,6 @@
1
1
  export * from './local-source-development-runner';
2
2
  export * from './providers';
3
3
  export * from './restricted-source-runner';
4
- export * from './source-analysis-admission-controller';
5
4
  export * from './source-code-analyzer';
6
5
  export * from './source-code-errors';
7
6
  export * from './source-code-limits';
@@ -39,8 +39,6 @@ export interface RestrictedSourceRunRequest {
39
39
  prompt: string;
40
40
  /** Points to the disposable prepared source tree. */
41
41
  analyzerRootDirectory: string;
42
- /** Aborts the analyzer when its lease or caller ends. */
43
- signal: AbortSignal;
44
42
  /** Requests a timeout no greater than the deployment ceiling. */
45
43
  timeoutMs: number;
46
44
  /** Publishes observable analyzer activity to the calling AI session. */
@@ -1,7 +1,6 @@
1
1
  import { type AiAgentSourceCodeIntegrationOptions, type AnalyzeCodeRequest, type AnalyzeCodeResult } from '@squidcloud/client';
2
2
  import type { CliAgentStatusUpdate } from '../cli-agent/cli-agent-adapter.types';
3
3
  import { RestrictedSourceRunRequest, RestrictedSourceRunResult } from './restricted-source-runner';
4
- import { type SourceAnalysisAdmissionControllerLike } from './source-analysis-admission-controller';
5
4
  import { SourceCodeLimits } from './source-code-limits';
6
5
  import { SourceCodeTelemetry } from './source-code-telemetry';
7
6
  import { SourceEvidenceVerifier } from './source-evidence-verifier';
@@ -33,8 +32,6 @@ export interface RestrictedSourceRunnerLike {
33
32
  }
34
33
  /** Configures testable source-analysis orchestration boundaries. */
35
34
  export interface SourceCodeAnalyzerOptions {
36
- /** Overrides process-wide source-analysis admission. */
37
- admissionController?: SourceAnalysisAdmissionControllerLike;
38
35
  /** Overrides trusted workspace preparation. */
39
36
  workspaceManager?: SourceWorkspaceManager;
40
37
  /** Overrides the isolated CLI runner. */
@@ -48,7 +45,6 @@ export interface SourceCodeAnalyzerOptions {
48
45
  }
49
46
  /** Coordinates trusted preparation, the isolated CLI, provenance validation, and telemetry. */
50
47
  export declare class SourceCodeAnalyzer {
51
- private readonly admissionController;
52
48
  private readonly evidenceVerifier;
53
49
  private readonly limits;
54
50
  private readonly restrictedRunner;
@@ -59,5 +55,4 @@ export declare class SourceCodeAnalyzer {
59
55
  /** Runs one source-code analysis and returns only provenance-validated evidence. */
60
56
  analyze(input: SourceCodeAnalyzeInput): Promise<AnalyzeCodeResult>;
61
57
  private recordTelemetry;
62
- private withAdmission;
63
58
  }
@@ -1,5 +1,5 @@
1
1
  /** Lists stable source-analysis error categories exposed to applications. */
2
- export declare const SOURCE_CODE_ERROR_CODES: readonly ["SOURCE_CONFIGURATION_INVALID", "SOURCE_AUTHENTICATION_FAILED", "SOURCE_REPOSITORY_UNAVAILABLE", "SOURCE_WORKSPACE_BUSY", "SOURCE_RESOURCE_LIMIT", "SOURCE_SANDBOX_UNAVAILABLE", "SOURCE_ANALYZER_TIMEOUT", "SOURCE_ANALYZER_FAILED", "SOURCE_LEASE_LOST", "SOURCE_EVIDENCE_UNVERIFIED"];
2
+ export declare const SOURCE_CODE_ERROR_CODES: readonly ["SOURCE_CONFIGURATION_INVALID", "SOURCE_AUTHENTICATION_FAILED", "SOURCE_REPOSITORY_UNAVAILABLE", "SOURCE_WORKSPACE_BUSY", "SOURCE_RESOURCE_LIMIT", "SOURCE_SANDBOX_UNAVAILABLE", "SOURCE_ANALYZER_TIMEOUT", "SOURCE_ANALYZER_FAILED", "SOURCE_EVIDENCE_UNVERIFIED"];
3
3
  /** Identifies a stable source-analysis error category. */
4
4
  export type SourceCodeErrorCode = (typeof SOURCE_CODE_ERROR_CODES)[number];
5
5
  /** Carries a safe source-analysis category without provider or repository details. */
@@ -1,11 +1,7 @@
1
- /** Configures source-code preparation, analysis, storage, and lease ceilings. */
1
+ /** Configures source-code preparation, analysis, and storage ceilings. */
2
2
  export interface SourceCodeLimits {
3
- /** Bounds waiting for process-wide source-analysis capacity. */
4
- admissionWaitMs: number;
5
3
  /** Bounds repositories exposed to one analyzer run. */
6
4
  maxRepositories: number;
7
- /** Bounds simultaneous source analyses in one tenant process. */
8
- maxConcurrentAnalyses: number;
9
5
  /** Bounds persistent or disposable workspace bytes. */
10
6
  maxWorkspaceBytes: number;
11
7
  /** Bounds inodes in the quota-backed analyzer filesystem. */
@@ -20,12 +16,6 @@ export interface SourceCodeLimits {
20
16
  analyzerTimeoutMs: number;
21
17
  /** Bounds cached snapshot age during transient provider failures. */
22
18
  maxStaleAgeMs: number;
23
- /** Bounds waiting for exclusive workspace ownership. */
24
- leaseWaitMs: number;
25
- /** Configures the exclusive workspace lease lifetime. */
26
- leaseTtlMs: number;
27
- /** Configures the exclusive workspace lease heartbeat interval. */
28
- leaseHeartbeatMs: number;
29
19
  }
30
20
  /** Supplies the production source-code limits. */
31
21
  export declare const DEFAULT_SOURCE_CODE_LIMITS: Readonly<SourceCodeLimits>;
@@ -1,6 +1,6 @@
1
1
  import type { SourceCodeAnalyzerModel, SourceControlProvider } from '@squidcloud/client';
2
2
  /** Lists bounded source-analysis outcomes. */
3
- export type SourceCodeOutcome = 'success' | 'stale-success' | 'persistence-warning' | 'configuration' | 'authentication' | 'repository-unavailable' | 'workspace-busy' | 'resource-limit' | 'sandbox-unavailable' | 'analyzer-timeout' | 'analyzer-failed' | 'lease-lost' | 'evidence-unverified';
3
+ export type SourceCodeOutcome = 'success' | 'stale-success' | 'persistence-warning' | 'configuration' | 'authentication' | 'repository-unavailable' | 'workspace-busy' | 'resource-limit' | 'sandbox-unavailable' | 'analyzer-timeout' | 'analyzer-failed' | 'evidence-unverified';
4
4
  /** Contains source-analysis metrics without repository or question content. */
5
5
  export interface SourceCodeTelemetryEvent {
6
6
  /** Identifies the source-control provider. */
@@ -15,12 +15,8 @@ export interface SourceCodeTelemetryEvent {
15
15
  cacheState: 'first-clone' | 'reused' | 'mixed';
16
16
  /** Marks whether any analyzed snapshot was stale. */
17
17
  stale: boolean;
18
- /** Marks whether exclusive workspace ownership was lost. */
19
- leaseLost: boolean;
20
18
  /** Measures total analysis wall-clock duration. */
21
19
  analysisDurationMs: number;
22
- /** Measures time spent acquiring the workspace lease. */
23
- leaseWaitMs: number;
24
20
  /** Measures trusted workspace bytes after preparation. */
25
21
  workspaceBytes: number;
26
22
  /** Counts model input tokens when reported by the CLI. */
@@ -1,33 +1,18 @@
1
1
  import type { SourceCodeRef, SourceRepository } from '@squidcloud/client';
2
- import { WorkspaceAcquireLeaseOptions, WorkspaceMetadata } from '../workspace-client';
2
+ import { WorkspaceMetadata } from '../workspace-client';
3
3
  import { SourceCodeLimits } from './source-code-limits';
4
4
  import { SourceGitCommand } from './source-git-command';
5
5
  import { SourceGitCredentialHelper } from './source-git-credential-helper';
6
6
  import type { SourceProviderAdapter, SourceProviderFailureClassification, TrustedGitTlsProvider } from './source-provider-adapter';
7
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
8
  /** Represents the shared workspace operations consumed by source orchestration. */
20
9
  export interface SourceWorkspaceClient {
21
- /** Acquires exclusive ownership of one integration-wide cache. */
22
- acquireLease(workspaceId: string, options?: WorkspaceAcquireLeaseOptions): Promise<SourceWorkspaceLease>;
23
10
  /** Pulls the latest shared cache to this pod. */
24
11
  create(id: string, options?: {
25
12
  signal?: AbortSignal;
26
13
  }): Promise<WorkspaceMetadata>;
27
- /** Pushes the trusted cache while proving the active fencing identity. */
28
- push(id: string, options?: {
29
- lease?: SourceWorkspaceLease;
30
- }): Promise<WorkspaceMetadata>;
14
+ /** Publishes the refreshed trusted cache for the next run on any replica. */
15
+ push(id: string): Promise<WorkspaceMetadata>;
31
16
  /** Removes a pod-local copy that must not be reused. */
32
17
  discardLocal(id: string): Promise<void>;
33
18
  }
@@ -83,12 +68,8 @@ export interface PreparedSourceWorkspace {
83
68
  submodules: readonly PreparedSourceSubmodule[];
84
69
  /** Lists bounded preparation warnings. */
85
70
  warnings: readonly string[];
86
- /** Aborts the analyzer when exclusive ownership is lost. */
87
- leaseSignal: AbortSignal;
88
71
  /** Describes whether trusted caches were created or reused. */
89
72
  cacheState: 'first-clone' | 'reused' | 'mixed';
90
- /** Measures time spent acquiring exclusive ownership. */
91
- leaseWaitMs: number;
92
73
  /** Measures trusted cache bytes after preparation. */
93
74
  workspaceBytes: number;
94
75
  }
@@ -104,6 +85,17 @@ export interface PrepareSourceWorkspaceInput {
104
85
  repositoryHints?: string;
105
86
  /** Requests one captured branch, tag, or advertised commit. */
106
87
  requestedRef?: string;
88
+ /** Reports coarse preparation stages without exposing credentials or local paths. */
89
+ reportProgress?: (progress: SourceWorkspacePreparationProgress) => void;
90
+ }
91
+ /** Names one user-visible stage in trusted repository preparation. */
92
+ export type SourceWorkspacePreparationStage = 'checking-access' | 'syncing-repositories' | 'saving-cache' | 'creating-checkout';
93
+ /** Describes one coarse repository-preparation transition. */
94
+ export interface SourceWorkspacePreparationProgress {
95
+ /** Lists canonical selected repository names when they are available. */
96
+ repositories?: readonly string[];
97
+ /** Identifies the current preparation stage. */
98
+ stage: SourceWorkspacePreparationStage;
107
99
  }
108
100
  /** Contains a callback value and a nonfatal shared-persistence warning. */
109
101
  export interface PreparedSourceWorkspaceResult<T> {
@@ -148,7 +140,7 @@ export declare class SourceWorkspaceManager {
148
140
  private readonly remoteUrlResolver;
149
141
  private readonly runtimeRootDirectory;
150
142
  private readonly tlsProvider;
151
- private readonly workspaceClient;
143
+ private readonly workspaceClient?;
152
144
  /** Creates a production manager unless explicit test boundaries are supplied. */
153
145
  constructor(options?: SourceWorkspaceManagerOptions);
154
146
  /** Runs a callback over disposable repositories and persists only trusted cache state. */
@@ -165,5 +157,6 @@ export declare class SourceWorkspaceManager {
165
157
  private materializeRepository;
166
158
  private withTrustedGitEnvironment;
167
159
  private runGit;
160
+ private createWorkspaceClientRun;
168
161
  private discardLocalSafely;
169
162
  }
@@ -24,91 +24,24 @@ export interface WorkspaceCreateOptions {
24
24
  /** Cancels local synchronization before the caller loses ownership. */
25
25
  signal?: AbortSignal;
26
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
27
  /** Injectable Core RPC boundary used by direct SDK integration tests and non-global hosts. */
40
28
  export interface WorkspaceRpcTransport {
41
29
  /** Posts a workspace request to Core with an optional cancellation signal. */
42
30
  post<ResponseType>(path: string, request: unknown, abortSignal?: AbortSignal): Promise<ResponseType>;
43
31
  }
44
- /** Construction options for hosts that supply their own RPC boundary or lease identity. */
32
+ /** Construction options for hosts that supply their own RPC boundary or cache root. */
45
33
  export interface WorkspaceClientOptions {
46
34
  /** Overrides the default Squid RPC transport. */
47
35
  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
36
  /** Overrides this process's pod-local workspace cache root. */
53
37
  localCacheRoot?: string;
54
38
  }
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;
65
- }
66
39
  /**
67
40
  * Returns whether the shared workspace server is configured on this pod. Callers that want to degrade
68
41
  * gracefully (treat a shared workspace as best-effort/ephemeral rather than fail) should check this
69
42
  * before calling `WorkspaceClient` methods, which throw when it is not configured.
70
43
  */
71
44
  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
- }
112
45
  /**
113
46
  * Experimental, backend-only API for a scratch directory ("workspace") that survives across `ask()` calls
114
47
  * and pod replicas. The directory lives on this pod's local disk for fast reads/writes; `create` and
@@ -131,13 +64,9 @@ export declare class WorkspaceClient {
131
64
  */
132
65
  private podKeypairReady?;
133
66
  private readonly rpcTransport;
134
- private readonly leaseOwnerIdPrefix;
135
- private readonly leaseHeartbeatIntervalMs;
136
67
  private readonly localCacheRoot;
137
68
  /** Creates a workspace client using Squid's RPC transport by default. */
138
69
  constructor(options?: WorkspaceClientOptions);
139
- /** Acquires exclusive ownership, retrying a busy workspace within the requested bound. */
140
- acquireLease(workspaceId: string, options?: WorkspaceAcquireLeaseOptions): Promise<WorkspaceLease>;
141
70
  /**
142
71
  * Ensures the workspace directory exists on this pod and reflects the latest push, generating a
143
72
  * new workspace id when none is given. Safe to call repeatedly: pulls from the workspace server only
@@ -145,7 +74,7 @@ export declare class WorkspaceClient {
145
74
  */
146
75
  create(id?: string, options?: WorkspaceCreateOptions): Promise<WorkspaceMetadata>;
147
76
  /** Syncs the current state of the workspace directory to the workspace server as the new authoritative state. */
148
- push(id: string, options?: WorkspacePushOptions): Promise<WorkspaceMetadata>;
77
+ push(id: string): Promise<WorkspaceMetadata>;
149
78
  /** Removes only this client's pod-local copy without changing the shared workspace. */
150
79
  discardLocal(id: string): Promise<void>;
151
80
  /**
@@ -156,8 +85,6 @@ export declare class WorkspaceClient {
156
85
  */
157
86
  delete(id: string): Promise<void>;
158
87
  private buildMetadata;
159
- private buildCommitPushRequest;
160
- private assertLeaseForWorkspace;
161
88
  private resolveLocalWorkspaceDir;
162
89
  private resolveLocalWorkspaceMarkerPath;
163
90
  private resolveLocalWorkspaceQuarantineDir;
@@ -196,8 +123,6 @@ export declare class WorkspaceClient {
196
123
  private isMissingRemoteError;
197
124
  private isWorkspaceBusyError;
198
125
  private isTimeoutError;
199
- private createLeaseOwnerId;
200
- private resolveLeaseHeartbeatIntervalMs;
201
126
  private sshHost;
202
127
  private sshPort;
203
128
  private sshUser;