@squidcloud/backend 1.0.485 → 1.0.487
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 +4 -0
- package/dist/backend/src/cli-agent/cli-agent-adapter.types.d.ts +19 -7
- package/dist/backend/src/cli-agent/cli-agent-root-status.d.ts +25 -0
- package/dist/backend/src/cli-agent/cli-agent-status.utils.d.ts +9 -0
- package/dist/backend/src/cli-agent/cli-output-stream.utils.d.ts +1 -0
- package/dist/backend/src/cli-agent/codex.adapter.d.ts +4 -0
- package/dist/backend/src/cli-agent/index.d.ts +3 -0
- package/dist/backend/src/source-code/restricted-source-runner.d.ts +3 -2
- package/dist/backend/src/source-code/source-code-analyzer.d.ts +3 -0
- package/dist/backend/src/source-code/source-code-errors.d.ts +1 -1
- package/dist/backend/src/source-code/source-code-limits.d.ts +0 -6
- package/dist/backend/src/source-code/source-code-telemetry.d.ts +1 -5
- package/dist/backend/src/source-code/source-evidence-verifier.d.ts +80 -0
- package/dist/backend/src/source-code/source-workspace-manager.d.ts +3 -22
- package/dist/backend/src/workspace-client.d.ts +2 -77
- package/dist/cjs/index.js +1 -1
- package/dist/cjs/internal/source-code.js +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/internal/source-code.js +1 -1
- package/package.json +2 -2
|
@@ -33,6 +33,8 @@ export declare class ClaudeCodeCliAdapter implements AgentCliSessionAdapter {
|
|
|
33
33
|
readonly maxBlobBytes: number;
|
|
34
34
|
/** Stored between buildArgs and afterRun so we can clean up the MCP session. */
|
|
35
35
|
private mcpSessionId;
|
|
36
|
+
/** Tracks the root status while the process lifecycle is active. */
|
|
37
|
+
private readonly rootStatus;
|
|
36
38
|
/** Creates a Claude adapter for one request. */
|
|
37
39
|
constructor(deps: CliAgentAdapterDeps);
|
|
38
40
|
/**
|
|
@@ -63,6 +65,8 @@ export declare class ClaudeCodeCliAdapter implements AgentCliSessionAdapter {
|
|
|
63
65
|
statePaths(_ctx: SessionCtx): string[];
|
|
64
66
|
/** Parses Claude stream-json output into a terminal response. */
|
|
65
67
|
parseOutput(stdout: Readable, stderr: Readable, prompt: string): Promise<CliRunOutcome>;
|
|
68
|
+
/** Publishes the terminal replacement selected by the process lifecycle. */
|
|
69
|
+
completeRun(outcome: CliRunOutcome): void;
|
|
66
70
|
/** Deletes temporary MCP and working-directory state. */
|
|
67
71
|
afterRun(ctx: SessionCtx): Promise<void>;
|
|
68
72
|
/**
|
|
@@ -48,6 +48,19 @@ export interface CreateAgentToolsSessionResponse {
|
|
|
48
48
|
/** Locates the session-specific MCP endpoint. */
|
|
49
49
|
mcpUrl: string;
|
|
50
50
|
}
|
|
51
|
+
/** Describes one observable CLI activity update. */
|
|
52
|
+
export interface CliAgentStatusUpdate {
|
|
53
|
+
/** Identifies an update so later events can replace it in place. */
|
|
54
|
+
messageId?: string;
|
|
55
|
+
/** Supplies the short activity label. */
|
|
56
|
+
title: string;
|
|
57
|
+
/** Supplies Markdown-formatted activity details. */
|
|
58
|
+
body: string;
|
|
59
|
+
/** Nests this activity beneath another status update. */
|
|
60
|
+
parentStatusUpdateId?: string;
|
|
61
|
+
/** Supplies optional machine-readable activity metadata. */
|
|
62
|
+
tags?: Record<string, unknown>;
|
|
63
|
+
}
|
|
51
64
|
/** Supplies per-request services and settings to a CLI adapter. */
|
|
52
65
|
export interface CliAgentAdapterDeps {
|
|
53
66
|
/** Contains the model and per-request AI options. */
|
|
@@ -75,6 +88,8 @@ export interface CliAgentAdapterDeps {
|
|
|
75
88
|
restrictedSettingsPath?: string;
|
|
76
89
|
/** Overrides the tools exposed to Claude inside an explicitly restricted run. */
|
|
77
90
|
restrictedTools?: string;
|
|
91
|
+
/** Constrains Claude's terminal response to one validated JSON value. */
|
|
92
|
+
structuredOutputSchema?: Record<string, unknown>;
|
|
78
93
|
/** Routes restricted Codex through the source model proxy by default; set to false for direct local development. */
|
|
79
94
|
useSourceModelProxy?: boolean;
|
|
80
95
|
/** Uses the CLI's read-only host sandbox when no outer source-agent jail is available locally. */
|
|
@@ -85,13 +100,8 @@ export interface CliAgentAdapterDeps {
|
|
|
85
100
|
createMcpSession(): Promise<CreateAgentToolsSessionResponse>;
|
|
86
101
|
/** Deletes a temporary MCP session after the run. */
|
|
87
102
|
deleteMcpSession(sessionId: string): Promise<void>;
|
|
88
|
-
/** Publishes
|
|
89
|
-
publishStatus?(update:
|
|
90
|
-
title: string;
|
|
91
|
-
body: string;
|
|
92
|
-
parentStatusUpdateId?: string;
|
|
93
|
-
tags?: Record<string, unknown>;
|
|
94
|
-
}): void;
|
|
103
|
+
/** Publishes an observable activity update for the run. */
|
|
104
|
+
publishStatus?(update: CliAgentStatusUpdate): void;
|
|
95
105
|
}
|
|
96
106
|
/** Describes one supported CLI without owning its process lifecycle. */
|
|
97
107
|
export interface AgentCliSessionAdapter {
|
|
@@ -117,6 +127,8 @@ export interface AgentCliSessionAdapter {
|
|
|
117
127
|
statePaths(ctx: SessionCtx): string[];
|
|
118
128
|
/** Parses bounded process streams into a terminal outcome. */
|
|
119
129
|
parseOutput(stdout: Readable, stderr: Readable, prompt: string): Promise<CliRunOutcome>;
|
|
130
|
+
/** Publishes the terminal run status after the process lifecycle selects its final outcome. */
|
|
131
|
+
completeRun(outcome: CliRunOutcome): void;
|
|
120
132
|
/** Releases provider-specific resources after the process exits. */
|
|
121
133
|
afterRun?(ctx: SessionCtx): Promise<void>;
|
|
122
134
|
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { CliAgentStatusUpdate, CliRunOutcome } from './cli-agent-adapter.types';
|
|
2
|
+
/** Configures the root status shared by CLI-agent adapters. */
|
|
3
|
+
export interface CliAgentRootStatusOptions {
|
|
4
|
+
/** Supplies the provider name shown to users. */
|
|
5
|
+
displayName: string;
|
|
6
|
+
/** Formats provider-specific errors for display. */
|
|
7
|
+
formatError(error: string): string;
|
|
8
|
+
/** Supplies the run bound for timeout status text. */
|
|
9
|
+
maxWallTimeMs(): number;
|
|
10
|
+
/** Publishes status updates when the caller requested them. */
|
|
11
|
+
publishStatus?(update: CliAgentStatusUpdate): void;
|
|
12
|
+
}
|
|
13
|
+
/** Owns one CLI run's root status lifecycle and accumulated token usage. */
|
|
14
|
+
export declare class CliAgentRootStatus {
|
|
15
|
+
private readonly options;
|
|
16
|
+
private active;
|
|
17
|
+
/** Creates a root-status lifecycle for one adapter instance. */
|
|
18
|
+
constructor(options: CliAgentRootStatusOptions);
|
|
19
|
+
/** Starts tracking the root status published by the adapter parser. */
|
|
20
|
+
begin(messageId: string): void;
|
|
21
|
+
/** Records the latest cumulative token usage for the terminal replacement. */
|
|
22
|
+
recordUsage(inputTokens: number, outputTokens: number): void;
|
|
23
|
+
/** Publishes one terminal replacement after the process runner selects its final outcome. */
|
|
24
|
+
complete(outcome: CliRunOutcome): void;
|
|
25
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/** Contains compact user-visible details for one CLI tool invocation. */
|
|
2
|
+
export interface CompactToolActivity {
|
|
3
|
+
/** Supplies the Markdown body shown when the tool invocation is expanded. */
|
|
4
|
+
body: string;
|
|
5
|
+
/** Supplies the single-line description shown in a collapsed tool group. */
|
|
6
|
+
summary: string;
|
|
7
|
+
}
|
|
8
|
+
/** Formats common CLI tool arguments without exposing tool output or internal workspace prefixes. */
|
|
9
|
+
export declare function formatCompactToolActivity(toolName: string, input: Record<string, unknown> | undefined): CompactToolActivity;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -36,6 +36,8 @@ export declare class CodexCliAdapter implements AgentCliSessionAdapter {
|
|
|
36
36
|
private mcpSessionId;
|
|
37
37
|
/** Per-run MCP bearer token; captured in buildArgs, exposed to the CLI via buildEnv. */
|
|
38
38
|
private mcpBearerToken;
|
|
39
|
+
/** Tracks the root status while the process lifecycle is active. */
|
|
40
|
+
private readonly rootStatus;
|
|
39
41
|
/** Creates a Codex adapter for one request. */
|
|
40
42
|
constructor(deps: CliAgentAdapterDeps);
|
|
41
43
|
/**
|
|
@@ -59,6 +61,8 @@ export declare class CodexCliAdapter implements AgentCliSessionAdapter {
|
|
|
59
61
|
statePaths(_ctx: SessionCtx): string[];
|
|
60
62
|
/** Parses Codex JSONL output into a terminal response. */
|
|
61
63
|
parseOutput(stdout: Readable, stderr: Readable, prompt: string): Promise<CliRunOutcome>;
|
|
64
|
+
/** Publishes the terminal replacement selected by the process lifecycle. */
|
|
65
|
+
completeRun(outcome: CliRunOutcome): void;
|
|
62
66
|
/** Deletes temporary MCP and working-directory state. */
|
|
63
67
|
afterRun(ctx: SessionCtx): Promise<void>;
|
|
64
68
|
/** Writes the captured thread id into the sidecar so it round-trips with the session blob. */
|
|
@@ -2,6 +2,9 @@ export * from './claude-code.adapter';
|
|
|
2
2
|
export * from './cli-agent-adapter.types';
|
|
3
3
|
export * from './cli-agent-process-launcher';
|
|
4
4
|
export * from './cli-agent-process-runner';
|
|
5
|
+
export * from './cli-agent-root-status';
|
|
6
|
+
export * from './cli-agent-status.utils';
|
|
7
|
+
export * from './cli-output-stream.utils';
|
|
5
8
|
export * from './codex.adapter';
|
|
6
9
|
export * from './nsjail-source-process-launcher';
|
|
7
10
|
export * from './workspace.utils';
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { CanonicalReasoningEffort, SourceCodeAnalyzerModel, SourceControlProvider } from '@squidcloud/client';
|
|
2
|
+
import { CliAgentStatusUpdate } from '../cli-agent/cli-agent-adapter.types';
|
|
2
3
|
import { CliAgentProcessLauncher } from '../cli-agent/cli-agent-process-launcher';
|
|
3
4
|
import { CliAgentProcessRunner } from '../cli-agent/cli-agent-process-runner';
|
|
4
5
|
import { NsjailSourceProcessLauncherConfig } from '../cli-agent/nsjail-source-process-launcher';
|
|
@@ -38,10 +39,10 @@ export interface RestrictedSourceRunRequest {
|
|
|
38
39
|
prompt: string;
|
|
39
40
|
/** Points to the disposable prepared source tree. */
|
|
40
41
|
analyzerRootDirectory: string;
|
|
41
|
-
/** Aborts the analyzer when its lease or caller ends. */
|
|
42
|
-
signal: AbortSignal;
|
|
43
42
|
/** Requests a timeout no greater than the deployment ceiling. */
|
|
44
43
|
timeoutMs: number;
|
|
44
|
+
/** Publishes observable analyzer activity to the calling AI session. */
|
|
45
|
+
publishStatus?: (update: CliAgentStatusUpdate) => void;
|
|
45
46
|
}
|
|
46
47
|
/** Contains the user-visible response and model usage for one restricted run. */
|
|
47
48
|
export interface RestrictedSourceRunResult {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { type AiAgentSourceCodeIntegrationOptions, type AnalyzeCodeRequest, type AnalyzeCodeResult } from '@squidcloud/client';
|
|
2
|
+
import type { CliAgentStatusUpdate } from '../cli-agent/cli-agent-adapter.types';
|
|
2
3
|
import { RestrictedSourceRunRequest, RestrictedSourceRunResult } from './restricted-source-runner';
|
|
3
4
|
import { type SourceAnalysisAdmissionControllerLike } from './source-analysis-admission-controller';
|
|
4
5
|
import { SourceCodeLimits } from './source-code-limits';
|
|
@@ -22,6 +23,8 @@ export interface SourceCodeAnalyzeInput {
|
|
|
22
23
|
analyzerApiKey: string;
|
|
23
24
|
/** Supplies repository authorization and provider reads. */
|
|
24
25
|
adapter: SourceProviderAdapter;
|
|
26
|
+
/** Publishes observable analyzer activity to the calling AI session. */
|
|
27
|
+
publishStatus?: (update: CliAgentStatusUpdate) => void;
|
|
25
28
|
}
|
|
26
29
|
/** Represents the restricted runner boundary used by orchestration tests. */
|
|
27
30
|
export interface RestrictedSourceRunnerLike {
|
|
@@ -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", "
|
|
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. */
|
|
@@ -20,12 +20,6 @@ export interface SourceCodeLimits {
|
|
|
20
20
|
analyzerTimeoutMs: number;
|
|
21
21
|
/** Bounds cached snapshot age during transient provider failures. */
|
|
22
22
|
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
23
|
}
|
|
30
24
|
/** Supplies the production source-code limits. */
|
|
31
25
|
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' | '
|
|
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,6 +1,86 @@
|
|
|
1
1
|
import type { AnalyzeCodeResult } from '@squidcloud/client';
|
|
2
2
|
import { SourceGitCommand } from './source-git-command';
|
|
3
3
|
import type { PreparedSourceWorkspace } from './source-workspace-manager';
|
|
4
|
+
/**
|
|
5
|
+
* Constrains source analyzers to the evidence envelope accepted by the verifier. The
|
|
6
|
+
* `parseAnalyzerOutput` implementation below remains authoritative for validation.
|
|
7
|
+
*/
|
|
8
|
+
export declare const SOURCE_ANALYZER_OUTPUT_JSON_SCHEMA: {
|
|
9
|
+
readonly additionalProperties: false;
|
|
10
|
+
readonly properties: {
|
|
11
|
+
readonly answer: {
|
|
12
|
+
readonly type: "string";
|
|
13
|
+
};
|
|
14
|
+
readonly repositories: {
|
|
15
|
+
readonly items: {
|
|
16
|
+
readonly additionalProperties: false;
|
|
17
|
+
readonly properties: {
|
|
18
|
+
readonly commitSha: {
|
|
19
|
+
readonly pattern: "^[a-f0-9]{40}$";
|
|
20
|
+
readonly type: "string";
|
|
21
|
+
};
|
|
22
|
+
readonly paths: {
|
|
23
|
+
readonly items: {
|
|
24
|
+
readonly additionalProperties: false;
|
|
25
|
+
readonly properties: {
|
|
26
|
+
readonly lines: {
|
|
27
|
+
readonly additionalProperties: false;
|
|
28
|
+
readonly properties: {
|
|
29
|
+
readonly end: {
|
|
30
|
+
readonly minimum: 1;
|
|
31
|
+
readonly type: "integer";
|
|
32
|
+
};
|
|
33
|
+
readonly start: {
|
|
34
|
+
readonly minimum: 1;
|
|
35
|
+
readonly type: "integer";
|
|
36
|
+
};
|
|
37
|
+
};
|
|
38
|
+
readonly required: readonly ["end", "start"];
|
|
39
|
+
readonly type: "object";
|
|
40
|
+
};
|
|
41
|
+
readonly path: {
|
|
42
|
+
readonly type: "string";
|
|
43
|
+
};
|
|
44
|
+
};
|
|
45
|
+
readonly required: readonly ["path"];
|
|
46
|
+
readonly type: "object";
|
|
47
|
+
};
|
|
48
|
+
readonly minItems: 1;
|
|
49
|
+
readonly type: "array";
|
|
50
|
+
};
|
|
51
|
+
readonly ref: {
|
|
52
|
+
readonly additionalProperties: false;
|
|
53
|
+
readonly properties: {
|
|
54
|
+
readonly name: {
|
|
55
|
+
readonly type: "string";
|
|
56
|
+
};
|
|
57
|
+
readonly type: {
|
|
58
|
+
readonly enum: readonly ["branch", "tag", "commit"];
|
|
59
|
+
readonly type: "string";
|
|
60
|
+
};
|
|
61
|
+
};
|
|
62
|
+
readonly required: readonly ["name", "type"];
|
|
63
|
+
readonly type: "object";
|
|
64
|
+
};
|
|
65
|
+
readonly repository: {
|
|
66
|
+
readonly type: "string";
|
|
67
|
+
};
|
|
68
|
+
};
|
|
69
|
+
readonly required: readonly ["commitSha", "paths", "ref", "repository"];
|
|
70
|
+
readonly type: "object";
|
|
71
|
+
};
|
|
72
|
+
readonly type: "array";
|
|
73
|
+
};
|
|
74
|
+
readonly warnings: {
|
|
75
|
+
readonly items: {
|
|
76
|
+
readonly type: "string";
|
|
77
|
+
};
|
|
78
|
+
readonly type: "array";
|
|
79
|
+
};
|
|
80
|
+
};
|
|
81
|
+
readonly required: readonly ["answer", "repositories", "warnings"];
|
|
82
|
+
readonly type: "object";
|
|
83
|
+
};
|
|
4
84
|
/** Supplies trusted state and one bounded analyzer response for verification. */
|
|
5
85
|
export interface VerifySourceEvidenceInput {
|
|
6
86
|
/** Contains exactly one analyzer JSON object. */
|
|
@@ -1,33 +1,18 @@
|
|
|
1
1
|
import type { SourceCodeRef, SourceRepository } from '@squidcloud/client';
|
|
2
|
-
import {
|
|
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
|
-
/**
|
|
28
|
-
push(id: string
|
|
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
|
}
|
|
@@ -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
|
|
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
|
|
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;
|