@squidcloud/backend 1.0.484 → 1.0.486
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 +5 -0
- package/dist/backend/src/cli-agent/cli-agent-adapter.types.d.ts +29 -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/cli-agent/nsjail-source-process-launcher.d.ts +5 -7
- package/dist/backend/src/public-types.d.ts +2 -2
- package/dist/backend/src/source-code/index.d.ts +6 -1
- package/dist/backend/src/source-code/local-source-development-runner.d.ts +10 -0
- package/dist/backend/src/source-code/restricted-source-runner.d.ts +8 -14
- package/dist/backend/src/source-code/source-code-analyzer.d.ts +3 -0
- package/dist/backend/src/source-code/source-development-runtime.d.ts +2 -0
- package/dist/backend/src/source-code/source-evidence-verifier.d.ts +80 -0
- package/dist/backend/src/source-code/source-git-command.d.ts +25 -0
- package/dist/backend/src/source-code/source-model-proxy.constants.d.ts +6 -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 +1 -11
- package/dist/backend/src/source-code/windows-local-cli-process-launcher.d.ts +13 -0
- 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 +13 -3
- package/dist/backend/src/source-code/source-run-filesystem.d.ts +0 -82
|
@@ -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
|
/**
|
|
@@ -71,4 +75,5 @@ export declare class ClaudeCodeCliAdapter implements AgentCliSessionAdapter {
|
|
|
71
75
|
* directly, so quoting would be interpreted literally — return the bare path.
|
|
72
76
|
*/
|
|
73
77
|
private cliPath;
|
|
78
|
+
private cliEmptyArgument;
|
|
74
79
|
}
|
|
@@ -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. */
|
|
@@ -71,17 +84,24 @@ export interface CliAgentAdapterDeps {
|
|
|
71
84
|
writeCodexAuthFile?: boolean;
|
|
72
85
|
/** Enables the fixed no-memory, no-inherited-instructions source-analyzer argument set. */
|
|
73
86
|
restrictedMode?: boolean;
|
|
87
|
+
/** Overrides the immutable Claude settings path for an explicitly local restricted run. */
|
|
88
|
+
restrictedSettingsPath?: string;
|
|
89
|
+
/** Overrides the tools exposed to Claude inside an explicitly restricted run. */
|
|
90
|
+
restrictedTools?: string;
|
|
91
|
+
/** Constrains Claude's terminal response to one validated JSON value. */
|
|
92
|
+
structuredOutputSchema?: Record<string, unknown>;
|
|
93
|
+
/** Routes restricted Codex through the source model proxy by default; set to false for direct local development. */
|
|
94
|
+
useSourceModelProxy?: boolean;
|
|
95
|
+
/** Uses the CLI's read-only host sandbox when no outer source-agent jail is available locally. */
|
|
96
|
+
useHostReadOnlySandbox?: boolean;
|
|
97
|
+
/** Emits literal Windows arguments for a launcher that does not interpolate through cmd.exe. */
|
|
98
|
+
useLiteralWindowsArguments?: boolean;
|
|
74
99
|
/** Creates a temporary MCP session for the run. */
|
|
75
100
|
createMcpSession(): Promise<CreateAgentToolsSessionResponse>;
|
|
76
101
|
/** Deletes a temporary MCP session after the run. */
|
|
77
102
|
deleteMcpSession(sessionId: string): Promise<void>;
|
|
78
|
-
/** Publishes
|
|
79
|
-
publishStatus?(update:
|
|
80
|
-
title: string;
|
|
81
|
-
body: string;
|
|
82
|
-
parentStatusUpdateId?: string;
|
|
83
|
-
tags?: Record<string, unknown>;
|
|
84
|
-
}): void;
|
|
103
|
+
/** Publishes an observable activity update for the run. */
|
|
104
|
+
publishStatus?(update: CliAgentStatusUpdate): void;
|
|
85
105
|
}
|
|
86
106
|
/** Describes one supported CLI without owning its process lifecycle. */
|
|
87
107
|
export interface AgentCliSessionAdapter {
|
|
@@ -107,6 +127,8 @@ export interface AgentCliSessionAdapter {
|
|
|
107
127
|
statePaths(ctx: SessionCtx): string[];
|
|
108
128
|
/** Parses bounded process streams into a terminal outcome. */
|
|
109
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;
|
|
110
132
|
/** Releases provider-specific resources after the process exits. */
|
|
111
133
|
afterRun?(ctx: SessionCtx): Promise<void>;
|
|
112
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,14 +1,12 @@
|
|
|
1
1
|
import { ChildProcess } from 'node:child_process';
|
|
2
|
-
import { type
|
|
2
|
+
import { type Stats } from 'node:fs';
|
|
3
3
|
import { CliAgentLaunchRequest, CliAgentProcessLauncher } from './cli-agent-process-launcher';
|
|
4
4
|
/** Configures the immutable nsjail boundary for one source-analysis run. */
|
|
5
5
|
export interface NsjailSourceProcessLauncherConfig {
|
|
6
6
|
/** Points to the outer per-run directory that owns the broker sockets. */
|
|
7
7
|
runtimeDirectory?: string;
|
|
8
|
-
/** Points to the
|
|
9
|
-
|
|
10
|
-
/** Identifies the rootless namespace owning the quota-backed mount. */
|
|
11
|
-
filesystemNamespace?: SourceFilesystemNamespaceIdentity;
|
|
8
|
+
/** Points to the disposable workspace-local source tree. */
|
|
9
|
+
workspaceDirectory: string;
|
|
12
10
|
/** Points to the trusted model proxy socket. */
|
|
13
11
|
modelSocket: string;
|
|
14
12
|
/** Points to the trusted provider broker socket. */
|
|
@@ -41,5 +39,5 @@ export declare class NsjailSourceProcessLauncher implements CliAgentProcessLaunc
|
|
|
41
39
|
/** Builds nsjail arguments without embedding environment values or credentials. */
|
|
42
40
|
buildArguments(request: CliAgentLaunchRequest): string[];
|
|
43
41
|
}
|
|
44
|
-
/**
|
|
45
|
-
export declare function
|
|
42
|
+
/** Returns whether a security-boundary executable is a root-owned regular file unavailable for tenant writes. */
|
|
43
|
+
export declare function isTrustedBoundaryExecutable(statistics: Pick<Stats, 'gid' | 'isFile' | 'mode' | 'uid'>): boolean;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/** Re-exports source-code values from the client SDK. */
|
|
2
|
-
export { SOURCE_CODE_ANALYZER_MODELS, SOURCE_CODE_ANALYZE_FUNCTION_ID, SOURCE_CODE_INTEGRATION_TYPES, SOURCE_CODE_MAX_REPOSITORIES, SOURCE_CODE_MAX_SUPPLEMENTAL_INSTRUCTIONS_LENGTH, SOURCE_CONTROL_PROVIDERS, normalizeGitHubRepositorySelection, } from '@squidcloud/client';
|
|
2
|
+
export { SOURCE_CODE_ANALYZER_MODELS, SOURCE_CODE_ANALYZE_FUNCTION_ID, SOURCE_CODE_INTEGRATION_TYPES, SOURCE_CODE_MAX_REPOSITORIES, SOURCE_CODE_MAX_SUPPLEMENTAL_INSTRUCTIONS_LENGTH, SOURCE_CONTROL_PROVIDERS, normalizeBitbucketRepositorySelection, normalizeGitHubRepositorySelection, } from '@squidcloud/client';
|
|
3
3
|
/** Re-exports source-code types from the client SDK. */
|
|
4
|
-
export type { AiAgentSourceCodeIntegrationOptions, AnalyzeCodeRequest, AnalyzeCodeResult, DiscoverSourceRepositoriesRequest, DiscoverSourceRepositoriesResponse, GitHubRepositoryConfiguration, SourceCodeAnalyzerModel, SourceCodeIntegrationType, SourceCodeLineRange, SourceCodePathEvidence, SourceCodeRef, SourceCodeRepositoryEvidence, SourceControlProvider, SourceRepository, } from '@squidcloud/client';
|
|
4
|
+
export type { AiAgentSourceCodeIntegrationOptions, AnalyzeCodeRequest, AnalyzeCodeResult, BitbucketRepositoryConfiguration, DiscoverSourceRepositoriesRequest, DiscoverSourceRepositoriesResponse, GitHubRepositoryConfiguration, SourceCodeAnalyzerModel, SourceCodeIntegrationType, SourceCodeLineRange, SourceCodePathEvidence, SourceCodeRef, SourceCodeRepositoryEvidence, SourceControlProvider, SourceRepository, } from '@squidcloud/client';
|
|
5
5
|
export * from '../../internal-common/src/public-types-backend/ai-agent.public-context';
|
|
6
6
|
export * from '../../internal-common/src/public-types-backend/api-call.public-context';
|
|
7
7
|
export * from '../../internal-common/src/public-types-backend/application.public-types';
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
export * from './local-source-development-runner';
|
|
1
2
|
export * from './providers';
|
|
2
3
|
export * from './restricted-source-runner';
|
|
3
4
|
export * from './source-analysis-admission-controller';
|
|
@@ -5,13 +6,17 @@ export * from './source-code-analyzer';
|
|
|
5
6
|
export * from './source-code-errors';
|
|
6
7
|
export * from './source-code-limits';
|
|
7
8
|
export * from './source-code-telemetry';
|
|
9
|
+
export * from './source-development-runtime';
|
|
8
10
|
export * from './source-egress-proxy';
|
|
9
11
|
export * from './source-evidence-verifier';
|
|
10
12
|
export * from './source-git-command';
|
|
11
13
|
export * from './source-git-credential-helper';
|
|
14
|
+
export * from './source-model-proxy.constants';
|
|
12
15
|
export * from './source-provider-adapter';
|
|
13
16
|
export * from './source-provider-operation-broker';
|
|
14
17
|
export * from './source-repository-snapshot';
|
|
15
|
-
export * from './source-
|
|
18
|
+
export * from './source-socket-admission';
|
|
19
|
+
export * from './source-submodule-url';
|
|
16
20
|
export * from './source-workspace-manager';
|
|
17
21
|
export * from './source-workspace-manifest';
|
|
22
|
+
export * from './windows-local-cli-process-launcher';
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { RestrictedSourceRunRequest, RestrictedSourceRunResult, SourceCodeRuntimeOptions } from './restricted-source-runner';
|
|
2
|
+
/** Runs a restricted source analyzer directly on an explicitly local Windows tenant. */
|
|
3
|
+
export declare class LocalSourceDevelopmentRunner {
|
|
4
|
+
private readonly processRunner;
|
|
5
|
+
private readonly runtimeOptions;
|
|
6
|
+
/** Creates the local runner with the production output and timeout ceilings. */
|
|
7
|
+
constructor(runtimeOptions?: SourceCodeRuntimeOptions);
|
|
8
|
+
/** Runs one analyzer with isolated local configuration and removes all per-run state. */
|
|
9
|
+
run(request: RestrictedSourceRunRequest): Promise<RestrictedSourceRunResult>;
|
|
10
|
+
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { SourceCodeAnalyzerModel, SourceControlProvider } from '@squidcloud/client';
|
|
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';
|
|
5
6
|
import { SourceProviderOperationBroker } from './source-provider-operation-broker';
|
|
6
|
-
import { SourceFilesystemNamespaceIdentity, SourceRunFilesystemMount } from './source-run-filesystem';
|
|
7
7
|
/** Configures the resource ceilings and immutable rootfs for source analysis. */
|
|
8
8
|
export interface SourceCodeRuntimeOptions {
|
|
9
9
|
/** Bounds writable workspace bytes. */
|
|
@@ -27,6 +27,10 @@ export interface RestrictedSourceRunRequest {
|
|
|
27
27
|
provider: SourceControlProvider;
|
|
28
28
|
/** Selects the isolated CLI analyzer. */
|
|
29
29
|
analyzerModel: SourceCodeAnalyzerModel;
|
|
30
|
+
/** Selects a concrete model from the analyzer provider's CLI registry. */
|
|
31
|
+
analyzerModelId?: string;
|
|
32
|
+
/** Selects the reasoning effort used by the analyzer CLI. */
|
|
33
|
+
analyzerReasoningEffort?: CanonicalReasoningEffort;
|
|
30
34
|
/** Supplies the real model credential to the outer proxy only. */
|
|
31
35
|
analyzerApiKey: string;
|
|
32
36
|
/** Supplies the credential-owning provider broker. */
|
|
@@ -35,14 +39,12 @@ export interface RestrictedSourceRunRequest {
|
|
|
35
39
|
prompt: string;
|
|
36
40
|
/** Points to the disposable prepared source tree. */
|
|
37
41
|
analyzerRootDirectory: string;
|
|
38
|
-
/** Marks a caller-owned root that already has the analyzer block and inode quotas. */
|
|
39
|
-
analyzerRootAlreadyQuotaBacked?: boolean;
|
|
40
|
-
/** Identifies the rootless mount namespace owning a caller-provided quota mount. */
|
|
41
|
-
analyzerFilesystemNamespace?: SourceFilesystemNamespaceIdentity;
|
|
42
42
|
/** Aborts the analyzer when its lease or caller ends. */
|
|
43
43
|
signal: AbortSignal;
|
|
44
44
|
/** Requests a timeout no greater than the deployment ceiling. */
|
|
45
45
|
timeoutMs: number;
|
|
46
|
+
/** Publishes observable analyzer activity to the calling AI session. */
|
|
47
|
+
publishStatus?: (update: CliAgentStatusUpdate) => void;
|
|
46
48
|
}
|
|
47
49
|
/** Contains the user-visible response and model usage for one restricted run. */
|
|
48
50
|
export interface RestrictedSourceRunResult {
|
|
@@ -60,17 +62,10 @@ export interface SourceModelAuthProxyLike {
|
|
|
60
62
|
/** Stops the proxy and releases its socket. */
|
|
61
63
|
close(): Promise<void>;
|
|
62
64
|
}
|
|
63
|
-
/** Represents the quota-backed filesystem lifecycle used by the runner. */
|
|
64
|
-
export interface SourceRunFilesystemLike {
|
|
65
|
-
/** Creates one disposable quota-backed mount. */
|
|
66
|
-
create(sourceDirectory: string, signal?: AbortSignal): Promise<SourceRunFilesystemMount>;
|
|
67
|
-
}
|
|
68
65
|
/** Supplies testable boundaries to the restricted runner. */
|
|
69
66
|
export interface RestrictedSourceRunnerDependencies {
|
|
70
67
|
/** Runs the bounded CLI process. */
|
|
71
68
|
processRunner: CliAgentProcessRunner;
|
|
72
|
-
/** Creates the disposable quota-backed filesystem. */
|
|
73
|
-
runFilesystem: SourceRunFilesystemLike;
|
|
74
69
|
/** Selects the host directory for private per-run sockets. */
|
|
75
70
|
runtimeRootDirectory: string;
|
|
76
71
|
/** Creates the credential-owning model proxy. */
|
|
@@ -84,7 +79,6 @@ export interface RestrictedSourceRunnerDependencies {
|
|
|
84
79
|
/** Runs a source analyzer with credentials and ambient tenant state outside its jail. */
|
|
85
80
|
export declare class RestrictedSourceRunner {
|
|
86
81
|
private readonly dependencies;
|
|
87
|
-
private readonly requiresFilesystemNamespace;
|
|
88
82
|
private readonly runtimeOptions;
|
|
89
83
|
/** Creates a production runner unless explicit test boundaries are supplied. */
|
|
90
84
|
constructor(dependencies?: RestrictedSourceRunnerDependencies, runtimeOptions?: SourceCodeRuntimeOptions);
|
|
@@ -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,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. */
|
|
@@ -27,6 +27,8 @@ export interface SourceGitCommandOptions {
|
|
|
27
27
|
maxOutputBytes?: number;
|
|
28
28
|
/** Bounds any single file written by a remote Git child on Linux. */
|
|
29
29
|
maxFileBytes?: number;
|
|
30
|
+
/** Restricts Linux Git filesystem access to this workspace-local root. */
|
|
31
|
+
sandboxRootDirectory?: string;
|
|
30
32
|
}
|
|
31
33
|
/** Contains bounded stdout from a successful trusted Git command. */
|
|
32
34
|
export interface SourceGitCommandResult {
|
|
@@ -40,6 +42,27 @@ export interface SourceGitInvocation {
|
|
|
40
42
|
/** Identifies the absolute production executable. */
|
|
41
43
|
executable: string;
|
|
42
44
|
}
|
|
45
|
+
/** Supplies pure inputs for one trusted Git process inside nsjail. */
|
|
46
|
+
export interface SourceGitNsjailArgumentInput {
|
|
47
|
+
/** Supplies the minimal environment forwarded by nsjail. */
|
|
48
|
+
environment: Readonly<NodeJS.ProcessEnv>;
|
|
49
|
+
/** Contains the bounded Git or prlimit invocation. */
|
|
50
|
+
invocation: SourceGitInvocation;
|
|
51
|
+
/** Bounds any single file written by the child. */
|
|
52
|
+
maxFileBytes: number;
|
|
53
|
+
/** Selects whether the process inherits the trusted network namespace. */
|
|
54
|
+
mode: SourceGitCommandMode;
|
|
55
|
+
/** Bounds child wall-clock and CPU time. */
|
|
56
|
+
timeoutMs: number;
|
|
57
|
+
/** Selects a working directory inside the rootfs. */
|
|
58
|
+
workingDirectory?: string;
|
|
59
|
+
/** Maps the source-agent group to the tenant process group. */
|
|
60
|
+
tenantGid: number;
|
|
61
|
+
/** Maps the source-agent user to the tenant process user. */
|
|
62
|
+
tenantUid: number;
|
|
63
|
+
/** Selects the host workspace exposed to trusted Git. */
|
|
64
|
+
workspaceSource: string;
|
|
65
|
+
}
|
|
43
66
|
/** Runs Git through a single command-array boundary with ambient configuration disabled. */
|
|
44
67
|
export declare class SourceGitCommand {
|
|
45
68
|
private readonly runtimeRootDirectory;
|
|
@@ -51,6 +74,8 @@ export declare class SourceGitCommand {
|
|
|
51
74
|
run(args: readonly string[], options: SourceGitCommandOptions): Promise<SourceGitCommandResult>;
|
|
52
75
|
private fixedArguments;
|
|
53
76
|
}
|
|
77
|
+
/** Builds the jail that gives trusted Git only its workspace root and standard runtime files. */
|
|
78
|
+
export declare function buildSourceGitNsjailArguments(input: SourceGitNsjailArgumentInput): string[];
|
|
54
79
|
/** Builds a minimal Git environment without ambient credential controls. */
|
|
55
80
|
export declare function buildSourceGitEnvironment(source: Readonly<NodeJS.ProcessEnv> | undefined, ambient?: Readonly<NodeJS.ProcessEnv>, platform?: NodeJS.Platform): NodeJS.ProcessEnv;
|
|
56
81
|
/** Wraps Git with a kernel-enforced file-size limit on Linux. */
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/** Authority accepted by the loopback source-model proxy. */
|
|
2
|
+
export declare const SOURCE_MODEL_PROXY_AUTHORITY = "127.0.0.1:18080";
|
|
3
|
+
/** Base URL used by restricted analyzers to reach the source-model proxy. */
|
|
4
|
+
export declare const SOURCE_MODEL_PROXY_BASE_URL = "http://127.0.0.1:18080";
|
|
5
|
+
/** OpenAI-compatible base URL exposed by the source-model proxy. */
|
|
6
|
+
export declare const SOURCE_MODEL_PROXY_OPENAI_BASE_URL = "http://127.0.0.1:18080/v1";
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { SourceControlProvider, SourceRepository } from '@squidcloud/client';
|
|
2
|
+
/** Identifies the provider repository addressed by a normalized submodule URL. */
|
|
3
|
+
export interface SourceSubmoduleRepositoryIdentity {
|
|
4
|
+
/** Contains the case-insensitive provider repository name. */
|
|
5
|
+
fullName: string;
|
|
6
|
+
/** Selects the source-control provider owning the repository. */
|
|
7
|
+
provider: SourceControlProvider;
|
|
8
|
+
}
|
|
9
|
+
/** Resolves a supported absolute or safe relative submodule URL to provider repository identity. */
|
|
10
|
+
export declare function normalizeSourceSubmoduleUrl(value: string, parentRepository: Pick<SourceRepository, 'fullName' | 'provider'>): SourceSubmoduleRepositoryIdentity | undefined;
|
|
@@ -5,7 +5,6 @@ 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
|
-
import { SourceFilesystemNamespaceIdentity, SourceRunFilesystemCreateOptions, SourceRunFilesystemMount } from './source-run-filesystem';
|
|
9
8
|
/** Represents the lease lifecycle consumed by source workspace orchestration. */
|
|
10
9
|
export interface SourceWorkspaceLease {
|
|
11
10
|
/** Aborts analysis immediately when exclusive ownership is lost. */
|
|
@@ -32,11 +31,6 @@ export interface SourceWorkspaceClient {
|
|
|
32
31
|
/** Removes a pod-local copy that must not be reused. */
|
|
33
32
|
discardLocal(id: string): Promise<void>;
|
|
34
33
|
}
|
|
35
|
-
/** Creates an empty quota-backed root for direct disposable cloning. */
|
|
36
|
-
export interface SourcePreparationFilesystem {
|
|
37
|
-
/** Creates one caller-owned analyzer mount. */
|
|
38
|
-
createEmpty(options?: SourceRunFilesystemCreateOptions): Promise<SourceRunFilesystemMount>;
|
|
39
|
-
}
|
|
40
34
|
/** Contains one repository prepared for an isolated analyzer. */
|
|
41
35
|
export interface PreparedSourceRepository {
|
|
42
36
|
/** Stores canonical provider repository metadata. */
|
|
@@ -81,8 +75,6 @@ export interface PreparedSourceSubmodule {
|
|
|
81
75
|
export interface PreparedSourceWorkspace {
|
|
82
76
|
/** Points to the only source tree mounted into the analyzer sandbox. */
|
|
83
77
|
analyzerRootDirectory: string;
|
|
84
|
-
/** Identifies the rootless mount namespace owning the analyzer filesystem. */
|
|
85
|
-
analyzerFilesystemNamespace?: SourceFilesystemNamespaceIdentity;
|
|
86
78
|
/** Points to the persistent trusted root used only by the verifier. */
|
|
87
79
|
trustedWorkspaceRootDirectory: string;
|
|
88
80
|
/** Lists prepared allowlisted repositories. */
|
|
@@ -134,8 +126,6 @@ export interface SourceWorkspaceManagerOptions {
|
|
|
134
126
|
gitCommand?: SourceGitCommand;
|
|
135
127
|
/** Overrides the ephemeral HTTPS credential helper. */
|
|
136
128
|
credentialHelper?: SourceGitCredentialHelper;
|
|
137
|
-
/** Overrides the quota-backed analyzer filesystem. */
|
|
138
|
-
runFilesystem?: SourcePreparationFilesystem;
|
|
139
129
|
/** Overrides the cancellation-aware cache-promotion copy boundary. */
|
|
140
130
|
copyDirectory?: (sourceDirectory: string, destinationDirectory: string, signal: AbortSignal) => Promise<void>;
|
|
141
131
|
/** Supplies trusted Git TLS material. */
|
|
@@ -156,7 +146,6 @@ export declare class SourceWorkspaceManager {
|
|
|
156
146
|
private readonly limits;
|
|
157
147
|
private readonly now;
|
|
158
148
|
private readonly remoteUrlResolver;
|
|
159
|
-
private readonly runFilesystem;
|
|
160
149
|
private readonly runtimeRootDirectory;
|
|
161
150
|
private readonly tlsProvider;
|
|
162
151
|
private readonly workspaceClient;
|
|
@@ -173,6 +162,7 @@ export declare class SourceWorkspaceManager {
|
|
|
173
162
|
private prepareStaleRepository;
|
|
174
163
|
private populateDisposableWorkspace;
|
|
175
164
|
private materializeAllowlistedSubmodules;
|
|
165
|
+
private materializeRepository;
|
|
176
166
|
private withTrustedGitEnvironment;
|
|
177
167
|
private runGit;
|
|
178
168
|
private discardLocalSafely;
|
|
@@ -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>;
|