@hraness/xcb 0.9.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/MANAGED-CODEX.md +213 -0
- package/README.md +555 -0
- package/dist/accounts.d.ts +46 -0
- package/dist/broker-descriptors.d.ts +5 -0
- package/dist/broker.d.ts +62 -0
- package/dist/browser-session.d.ts +161 -0
- package/dist/canonical-json.d.ts +2 -0
- package/dist/capabilities.d.ts +72 -0
- package/dist/claude-api-models.d.ts +24 -0
- package/dist/claude-api-transport.d.ts +5 -0
- package/dist/claude-api.d.ts +23 -0
- package/dist/claude-credentials.d.ts +13 -0
- package/dist/claude-options.d.ts +10 -0
- package/dist/claude-sdk.d.ts +48 -0
- package/dist/claude-task-adapter.d.ts +65 -0
- package/dist/cli.js +4190 -0
- package/dist/codex-account-process.d.ts +149 -0
- package/dist/codex-account-transport.d.ts +39 -0
- package/dist/codex-account.d.ts +126 -0
- package/dist/codex-config.d.ts +53 -0
- package/dist/codex-host.d.ts +40 -0
- package/dist/codex-managed-baseline.d.ts +5 -0
- package/dist/codex-managed-catalog.d.ts +32 -0
- package/dist/codex-managed-config.d.ts +93 -0
- package/dist/codex-managed-ledger.d.ts +37 -0
- package/dist/codex-managed-session.d.ts +62 -0
- package/dist/codex-managed-task-adapter.d.ts +21 -0
- package/dist/codex-process.d.ts +67 -0
- package/dist/codex-protocol-manifest.d.ts +27 -0
- package/dist/codex-relay.d.ts +80 -0
- package/dist/codex-scratch.d.ts +36 -0
- package/dist/codex-session.d.ts +44 -0
- package/dist/codex-task-adapter.d.ts +24 -0
- package/dist/codex-task-process.d.ts +21 -0
- package/dist/devin-acp.d.ts +105 -0
- package/dist/devin-adapter.d.ts +44 -0
- package/dist/devin-client.d.ts +36 -0
- package/dist/devin-mcp.d.ts +28 -0
- package/dist/egress-bridge.d.ts +35 -0
- package/dist/egress-client.d.ts +66 -0
- package/dist/index-kg2gx694.js +7217 -0
- package/dist/index.d.ts +58 -0
- package/dist/index.js +3455 -0
- package/dist/judge.d.ts +121 -0
- package/dist/loopback-server.d.ts +17 -0
- package/dist/managed-account.d.ts +176 -0
- package/dist/models.d.ts +23 -0
- package/dist/os-sandbox.d.ts +168 -0
- package/dist/private-file.d.ts +215 -0
- package/dist/process-port.d.ts +44 -0
- package/dist/process-write.d.ts +13 -0
- package/dist/provider-process.d.ts +26 -0
- package/dist/public-web.d.ts +21 -0
- package/dist/router.d.ts +43 -0
- package/dist/runtime.d.ts +90 -0
- package/dist/sqlite-port.d.ts +29 -0
- package/dist/task-runtime.d.ts +150 -0
- package/dist/validation.d.ts +6 -0
- package/package.json +70 -0
- package/sandbox/loopback-forwarder.cjs +172 -0
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
import { type ChildProcessWithoutNullStreams } from "node:child_process";
|
|
2
|
+
/**
|
|
3
|
+
* Per-account browser-session custody. Interactive provider sign-in runs inside
|
|
4
|
+
* one fixed, privately owned browser profile per provider account: cookies and
|
|
5
|
+
* site state persist across launches under that profile, so a returning account
|
|
6
|
+
* is already signed in and a new account never shares another account's
|
|
7
|
+
* session. The profile directory, never its contents, is the custody boundary:
|
|
8
|
+
* this module creates it privately, binds it to the exact account identity,
|
|
9
|
+
* serializes launches through an exclusive durable lock, bounds every launch
|
|
10
|
+
* through a hash-chained journal, and requires proven process exit plus group
|
|
11
|
+
* absence before releasing the lock. A stale lock is a recovery requirement,
|
|
12
|
+
* never permission to take over.
|
|
13
|
+
*
|
|
14
|
+
* No credentials, cookies, page contents, or browser output are read, returned,
|
|
15
|
+
* or logged. The provider supplies only the initial navigation URL; the host
|
|
16
|
+
* supplies the admitted executable. This module cannot prove a rendered page,
|
|
17
|
+
* a completed sign-in, or provider account state — it proves custody.
|
|
18
|
+
*/
|
|
19
|
+
export type BrowserSessionBinding = Readonly<{
|
|
20
|
+
/** Namespace label for the account's provider family, e.g. "codex". This is
|
|
21
|
+
* an identifier, not provider admission or a closed routing union. */
|
|
22
|
+
provider: string;
|
|
23
|
+
accountId: string;
|
|
24
|
+
owner: string;
|
|
25
|
+
/** The caller's current account-lease fence at launch time. */
|
|
26
|
+
leaseGeneration: number;
|
|
27
|
+
/** This launch's process fence; increments per session process. */
|
|
28
|
+
processGeneration: number;
|
|
29
|
+
}>;
|
|
30
|
+
export type BrowserSessionRuntimeAdmission = Readonly<{
|
|
31
|
+
/** Absolute canonical path of the reviewed browser executable. */
|
|
32
|
+
executablePath: string;
|
|
33
|
+
/** Observed version evidence, recorded verbatim. */
|
|
34
|
+
version: string;
|
|
35
|
+
/** SHA-256 of the reviewed executable bytes, re-verified at launch. */
|
|
36
|
+
sha256: string;
|
|
37
|
+
}>;
|
|
38
|
+
export type BrowserSessionOptions = Readonly<{
|
|
39
|
+
binding: BrowserSessionBinding;
|
|
40
|
+
/** Host-owned private root, mode 0700, canonical and user-only. */
|
|
41
|
+
stateRoot: string;
|
|
42
|
+
runtime: BrowserSessionRuntimeAdmission;
|
|
43
|
+
/** Optional initial navigation. https only; no userinfo or fragment policy
|
|
44
|
+
* is relaxed. Omitted launches open the browser's default blank page. */
|
|
45
|
+
url?: string;
|
|
46
|
+
/** Whole preparation deadline, 1 to 120000 milliseconds. */
|
|
47
|
+
startupTimeoutMs?: number;
|
|
48
|
+
/** Maximum session lifetime before a graceful close begins, 60000 to
|
|
49
|
+
* 3600000 milliseconds; default 900000. A login browser must not linger. */
|
|
50
|
+
maxSessionMs?: number;
|
|
51
|
+
/** Ambient environment the GUI-attach allowlist filters. Defaults to
|
|
52
|
+
* `process.env`; trusted hosts and tests pass an explicit map. */
|
|
53
|
+
environment?: Readonly<Record<string, string | undefined>>;
|
|
54
|
+
}>;
|
|
55
|
+
export type BrowserSessionSpawn = Readonly<{
|
|
56
|
+
executable: string;
|
|
57
|
+
args: readonly string[];
|
|
58
|
+
cwd: string;
|
|
59
|
+
env: Readonly<Record<string, string>>;
|
|
60
|
+
detached: true;
|
|
61
|
+
stdio: readonly ["pipe", "pipe", "pipe"];
|
|
62
|
+
}>;
|
|
63
|
+
/** Trusted system seam for synthetic process tests. This is not a plugin, an
|
|
64
|
+
* agent tool, a configuration input, or a sandboxing decision. */
|
|
65
|
+
export interface BrowserSessionSystem {
|
|
66
|
+
spawn(request: BrowserSessionSpawn): ChildProcessWithoutNullStreams;
|
|
67
|
+
processGroup(pid: number): number | null;
|
|
68
|
+
signalGroup(pgid: number, signal: "SIGTERM" | "SIGKILL" | 0): boolean;
|
|
69
|
+
}
|
|
70
|
+
export type BrowserSessionPhase = "preparing" | "launch-pending" | "running" | "recovery-required" | "closed";
|
|
71
|
+
export type BrowserSessionReceipt = Readonly<{
|
|
72
|
+
schema: "xcb.browser-session.v1";
|
|
73
|
+
binding: BrowserSessionBinding;
|
|
74
|
+
productionQualified: false;
|
|
75
|
+
browserVersion: string;
|
|
76
|
+
browserSha256: string;
|
|
77
|
+
launchAttempted: boolean;
|
|
78
|
+
pid: number | null;
|
|
79
|
+
pgid: number | null;
|
|
80
|
+
rootExited: boolean;
|
|
81
|
+
groupAbsent: boolean;
|
|
82
|
+
stdoutJoined: boolean;
|
|
83
|
+
stderrJoined: boolean;
|
|
84
|
+
lockReleased: boolean;
|
|
85
|
+
forcedExit: boolean;
|
|
86
|
+
gracefulExit: boolean;
|
|
87
|
+
journalPath: string | null;
|
|
88
|
+
phase: BrowserSessionPhase;
|
|
89
|
+
failures: readonly string[];
|
|
90
|
+
}>;
|
|
91
|
+
export type BrowserSessionCloseReceipt = Readonly<{
|
|
92
|
+
binding: BrowserSessionBinding;
|
|
93
|
+
processExited: boolean;
|
|
94
|
+
processGroupStopped: boolean;
|
|
95
|
+
stdoutEnded: boolean;
|
|
96
|
+
stderrEnded: boolean;
|
|
97
|
+
gracefulExit: boolean;
|
|
98
|
+
}>;
|
|
99
|
+
export interface BrowserSessionPort {
|
|
100
|
+
readonly binding: BrowserSessionBinding;
|
|
101
|
+
/** Resolves once the launch is proven running; rejects on refused launch. */
|
|
102
|
+
readonly ready: Promise<void>;
|
|
103
|
+
/** Resolves when the session has fully closed, however it ended. */
|
|
104
|
+
readonly closed: Promise<BrowserSessionCloseReceipt>;
|
|
105
|
+
receipt(): BrowserSessionReceipt;
|
|
106
|
+
/** Graceful close bound to the exact session binding: SIGTERM so the
|
|
107
|
+
* profile flushes, SIGKILL fallback, then proven exit, group absence, and
|
|
108
|
+
* stream joins before lock release. A mismatched binding refuses. */
|
|
109
|
+
close(request: {
|
|
110
|
+
binding: BrowserSessionBinding;
|
|
111
|
+
deadlineMs?: number;
|
|
112
|
+
}): Promise<BrowserSessionCloseReceipt>;
|
|
113
|
+
}
|
|
114
|
+
/** Fixed Chromium-family launch argv for the account's own profile. The
|
|
115
|
+
* password store stays profile-local (`basic`) so cookies never touch the
|
|
116
|
+
* system keyring and no interactive prompt can stall a managed launch; sync is
|
|
117
|
+
* disabled so the session cannot join a vendor account; crash/restore bubbles
|
|
118
|
+
* are suppressed so a recovered profile opens cleanly. */
|
|
119
|
+
export declare function browserSessionArgv(input: {
|
|
120
|
+
executable: string;
|
|
121
|
+
profile: string;
|
|
122
|
+
url?: string;
|
|
123
|
+
}): readonly string[];
|
|
124
|
+
export declare function browserSessionEnvironment(ambient: Readonly<Record<string, string | undefined>>, input: {
|
|
125
|
+
home: string;
|
|
126
|
+
tmp: string;
|
|
127
|
+
}): Record<string, string>;
|
|
128
|
+
/**
|
|
129
|
+
* Recovers a session directory whose launch lock outlived its process. The
|
|
130
|
+
* caller proves the recorded process is stopped; this function then removes
|
|
131
|
+
* the stale lock and the browser's singleton trio so the profile opens
|
|
132
|
+
* cleanly. It never deletes cookies, history, or the binding marker, and it
|
|
133
|
+
* refuses to run while any lock holder could be alive.
|
|
134
|
+
*/
|
|
135
|
+
export declare function recoverBrowserSession(input: Readonly<{
|
|
136
|
+
stateRoot: string;
|
|
137
|
+
provider: string;
|
|
138
|
+
accountId: string;
|
|
139
|
+
proveStopped(binding: BrowserSessionBinding): Promise<boolean>;
|
|
140
|
+
}>): Promise<{
|
|
141
|
+
recovered: true;
|
|
142
|
+
}>;
|
|
143
|
+
/**
|
|
144
|
+
* Destroys one account's whole browser-session directory as a unit — profile,
|
|
145
|
+
* cookies, markers, locks, and run journals — after proving no launch lock is
|
|
146
|
+
* held by a live process. This is the sign-out/revocation boundary; it is
|
|
147
|
+
* never implied by a close, an expiry, or a failed launch.
|
|
148
|
+
*/
|
|
149
|
+
export declare function purgeBrowserSession(input: Readonly<{
|
|
150
|
+
stateRoot: string;
|
|
151
|
+
provider: string;
|
|
152
|
+
accountId: string;
|
|
153
|
+
proveStopped(binding: BrowserSessionBinding): Promise<boolean>;
|
|
154
|
+
}>): Promise<{
|
|
155
|
+
purged: true;
|
|
156
|
+
}>;
|
|
157
|
+
/** Synchronous custody handle; preparation and launch proceed asynchronously.
|
|
158
|
+
* The caller must already hold the matching account lease. Callers pass only
|
|
159
|
+
* the admitted executable, the account binding, and an optional https URL —
|
|
160
|
+
* profile, environment, and argv are owned here. */
|
|
161
|
+
export declare function createBrowserSession(options: BrowserSessionOptions, trustedSystem?: BrowserSessionSystem): BrowserSessionPort;
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
export type CapabilityJson = null | boolean | number | string | readonly CapabilityJson[] | CapabilityObject;
|
|
2
|
+
export type CapabilityObject = {
|
|
3
|
+
readonly [key: string]: CapabilityJson;
|
|
4
|
+
};
|
|
5
|
+
export declare const CAPABILITY_LIMITS: Readonly<{
|
|
6
|
+
tools: 64;
|
|
7
|
+
schemaBytes: number;
|
|
8
|
+
manifestBytes: number;
|
|
9
|
+
inputBytes: number;
|
|
10
|
+
outputBytes: number;
|
|
11
|
+
depth: 16;
|
|
12
|
+
nodes: 8192;
|
|
13
|
+
objectKeys: 256;
|
|
14
|
+
arrayItems: 4096;
|
|
15
|
+
calls: 256;
|
|
16
|
+
pendingCalls: 32;
|
|
17
|
+
}>;
|
|
18
|
+
export type CapabilityDescriptor = Readonly<{
|
|
19
|
+
name: string;
|
|
20
|
+
description: string;
|
|
21
|
+
inputSchema: CapabilityObject;
|
|
22
|
+
}>;
|
|
23
|
+
export type CapabilityProfileIdentity = Readonly<{
|
|
24
|
+
id: string;
|
|
25
|
+
version: number;
|
|
26
|
+
digest: string;
|
|
27
|
+
}>;
|
|
28
|
+
export type CapabilityProfile = CapabilityProfileIdentity & Readonly<{
|
|
29
|
+
tools: readonly CapabilityDescriptor[];
|
|
30
|
+
}>;
|
|
31
|
+
export type CapabilityContext = Readonly<{
|
|
32
|
+
workspaceId: string;
|
|
33
|
+
runId: string;
|
|
34
|
+
signal: AbortSignal;
|
|
35
|
+
/** Trusted handlers must recheck immediately before each effect, including
|
|
36
|
+
* after their own awaits, and retain their conditional-write/authority gates. */
|
|
37
|
+
assertActive(): void;
|
|
38
|
+
}>;
|
|
39
|
+
export type CapabilityTool = CapabilityDescriptor & Readonly<{
|
|
40
|
+
/** Trusted code enforces the complete semantic contract. Schema descriptors
|
|
41
|
+
* are not evaluated as a JSON Schema program by this broker. */
|
|
42
|
+
parseInput(input: CapabilityObject): CapabilityJson;
|
|
43
|
+
execute(input: CapabilityJson, context: CapabilityContext): unknown | Promise<unknown>;
|
|
44
|
+
}>;
|
|
45
|
+
export interface CapabilityBroker {
|
|
46
|
+
readonly profile: CapabilityProfile;
|
|
47
|
+
readonly workspaceId: string;
|
|
48
|
+
readonly runId: string;
|
|
49
|
+
invoke(name: unknown, input: unknown): Promise<CapabilityJson>;
|
|
50
|
+
assertActive(): void;
|
|
51
|
+
revoke(): void;
|
|
52
|
+
/** Revoke immediately and join all admitted handlers. This does not prove
|
|
53
|
+
* that an external provider process or controller has stopped. */
|
|
54
|
+
close(): Promise<void>;
|
|
55
|
+
}
|
|
56
|
+
/** The digest covers this ordered declarative manifest, not executable handler
|
|
57
|
+
* code, credentials or OS confinement. Runtime provenance is a separate gate. */
|
|
58
|
+
export declare function createCapabilityProfile(options: {
|
|
59
|
+
id: string;
|
|
60
|
+
version: number;
|
|
61
|
+
tools: readonly CapabilityTool[];
|
|
62
|
+
}): CapabilityProfile;
|
|
63
|
+
/** Match the exact host-created profile against adapter qualification. A
|
|
64
|
+
* deserialized lookalike has no registered trusted implementation authority. */
|
|
65
|
+
export declare function assertCapabilityProfile(profile: CapabilityProfile, expected: CapabilityProfileIdentity): void;
|
|
66
|
+
export declare function createCapabilityBroker(options: {
|
|
67
|
+
profile: CapabilityProfile;
|
|
68
|
+
workspaceId: string;
|
|
69
|
+
runId: string;
|
|
70
|
+
isActive(): boolean;
|
|
71
|
+
signal?: AbortSignal;
|
|
72
|
+
}): CapabilityBroker;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { ClaudeApiKeyResolver } from "./claude-sdk.ts";
|
|
2
|
+
import { type ClaudeApiClient } from "./claude-api-transport.ts";
|
|
3
|
+
import { type ModelCatalog } from "./models.ts";
|
|
4
|
+
export type ClaudePriceCatalog = Readonly<{
|
|
5
|
+
observedAt: number;
|
|
6
|
+
models: readonly Readonly<{
|
|
7
|
+
id: string;
|
|
8
|
+
inputUsdPerMillion: number;
|
|
9
|
+
outputUsdPerMillion: number;
|
|
10
|
+
classifierEligible: boolean;
|
|
11
|
+
}>[];
|
|
12
|
+
}>;
|
|
13
|
+
export type ClaudeModelDiscoveryOptions = Readonly<{
|
|
14
|
+
credentials: ClaudeApiKeyResolver;
|
|
15
|
+
accountId: string;
|
|
16
|
+
priceCatalog: ClaudePriceCatalog;
|
|
17
|
+
signal: AbortSignal;
|
|
18
|
+
now?: () => number;
|
|
19
|
+
}>;
|
|
20
|
+
/** Lists availability only. It never sends a model prompt or invents provider prices. */
|
|
21
|
+
export declare function discoverClaudeModels(options: ClaudeModelDiscoveryOptions): Promise<ModelCatalog>;
|
|
22
|
+
/** Internal test seam: transport cannot be selected by owner/contact configuration. */
|
|
23
|
+
export declare function parseClaudePriceCatalog(value: unknown, now?: number): ClaudePriceCatalog;
|
|
24
|
+
export declare function discoverWithClient(client: ClaudeApiClient, prices: ClaudePriceCatalog, signal: AbortSignal, now: () => number): Promise<ModelCatalog>;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import Anthropic from "@anthropic-ai/sdk";
|
|
2
|
+
export declare const CLAUDE_API_SDK_VERSION = "0.127.0";
|
|
3
|
+
export type ClaudeApiClient = Pick<Anthropic, "messages" | "models">;
|
|
4
|
+
/** Internal host transport. Public setup never accepts a custom endpoint or fetch. */
|
|
5
|
+
export declare function claudeApiClient(key: string, signal: AbortSignal, networkFetch?: (input: string, init: RequestInit) => Promise<Response>): ClaudeApiClient;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { ClaudeApiKeyResolver } from "./claude-sdk.ts";
|
|
2
|
+
import { type ClaudeApiClient } from "./claude-api-transport.ts";
|
|
3
|
+
import { type ModelCatalog } from "./models.ts";
|
|
4
|
+
import { type AgentAdapter, type RuntimeQualification } from "./runtime.ts";
|
|
5
|
+
export type ClaudeApiAdapterOptions = Readonly<{
|
|
6
|
+
/** Trusted host's reviewed compiled entrypoint; never owner/contact configuration. */
|
|
7
|
+
runtimeArtifact: Readonly<{
|
|
8
|
+
entrypoint: string;
|
|
9
|
+
sha256: string;
|
|
10
|
+
}>;
|
|
11
|
+
credentials: ClaudeApiKeyResolver;
|
|
12
|
+
modelCatalog: (accountId: string) => Promise<ModelCatalog>;
|
|
13
|
+
now?: () => number;
|
|
14
|
+
maxTurns?: number;
|
|
15
|
+
maxOutputTokens?: number;
|
|
16
|
+
deadlineMs?: number;
|
|
17
|
+
/** Conservative local reservation at supplied prices; not a provider billing cap. */
|
|
18
|
+
maxBudgetUsd?: number;
|
|
19
|
+
}>;
|
|
20
|
+
/** This is Claude API, not Claude Code, and never launches a process or loads CLI settings. */
|
|
21
|
+
export declare function createClaudeApiAdapter(options: ClaudeApiAdapterOptions): Promise<AgentAdapter>;
|
|
22
|
+
/** Internal fixture seam. Production account configuration cannot replace the client. */
|
|
23
|
+
export declare function apiAdapter(options: Omit<ClaudeApiAdapterOptions, "runtimeArtifact">, qualification: RuntimeQualification, clientFor: (key: string, signal: AbortSignal) => ClaudeApiClient): AgentAdapter;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { ClaudeApiKeyResolver } from "./claude-sdk.ts";
|
|
2
|
+
/**
|
|
3
|
+
* Explicit host-owned account bindings for unattended local use. Only selected
|
|
4
|
+
* environment variables are read, at invocation time. No ambient provider key,
|
|
5
|
+
* personal provider home, subscription token or account discovery is consulted.
|
|
6
|
+
* A desktop Keychain integration can implement the same withApiKey interface.
|
|
7
|
+
*/
|
|
8
|
+
export declare function createEnvironmentClaudeApiKeyResolver(bindings: Readonly<Record<string, string>>, readEnvironment?: (name: string) => string | undefined): ClaudeApiKeyResolver;
|
|
9
|
+
/** Explicit owner-selected files, never contact configuration or provider-home discovery. */
|
|
10
|
+
export declare function createFileClaudeApiKeyResolver(options: Readonly<{
|
|
11
|
+
directory: string;
|
|
12
|
+
bindings: Readonly<Record<string, string>>;
|
|
13
|
+
}>): ClaudeApiKeyResolver;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { Options } from "@anthropic-ai/claude-agent-sdk";
|
|
2
|
+
type HostInputs = Pick<Options, "abortController" | "cwd" | "env" | "model" | "maxTurns" | "maxBudgetUsd" | "pathToClaudeCodeExecutable" | "spawnClaudeCodeProcess" | "mcpServers"> & {
|
|
3
|
+
brokerToolNames: readonly string[];
|
|
4
|
+
systemPrompt?: string;
|
|
5
|
+
};
|
|
6
|
+
/** Shared with the explicit native qualification harness; never accepts model configuration. */
|
|
7
|
+
export declare function restrictedClaudeOptions({ brokerToolNames, systemPrompt, ...host }: HostInputs): Options;
|
|
8
|
+
/** Keep task text out of the native CLI's slash/bang command parser. */
|
|
9
|
+
export declare function literalClaudePrompt(prompt: string): string;
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { type SDKSystemMessage } from "@anthropic-ai/claude-agent-sdk";
|
|
2
|
+
import { type BoundedProviderProcessFactory } from "./provider-process.ts";
|
|
3
|
+
import { type ToolBroker } from "./broker.ts";
|
|
4
|
+
import { type AgentAdapter, type AgentRunRequest, type RuntimeQualification } from "./runtime.ts";
|
|
5
|
+
export declare const CLAUDE_SDK_VERSION = "0.3.278";
|
|
6
|
+
/** The CLI release the bundled SDK package declares as its build pair — the
|
|
7
|
+
* manifest check uses this; installed-binary admission uses the floor below. */
|
|
8
|
+
export declare const CLAUDE_SDK_CODE_VERSION = "2.1.278";
|
|
9
|
+
/** Oldest admitted installed Claude Code release within major 2. Admission
|
|
10
|
+
* still binds the exact inspected version and executable SHA-256 into the
|
|
11
|
+
* qualification record, and the init assertion re-proves the effective
|
|
12
|
+
* boundary on every run; the floor only decides which binaries doctor may
|
|
13
|
+
* admit, so routine CLI patch/minor releases stop revoking the product. */
|
|
14
|
+
export declare const CLAUDE_CODE_MIN_VERSION = "2.1.268";
|
|
15
|
+
export declare const CLAUDE_CODE_MAX_MAJOR = 2;
|
|
16
|
+
export declare function claudeCodeVersionAdmitted(version: string): boolean;
|
|
17
|
+
/** Host-only credential use: never pass a subscription token, personal config home, or credential file. */
|
|
18
|
+
export interface ClaudeApiKeyResolver {
|
|
19
|
+
withApiKey<T>(accountId: string, signal: AbortSignal, use: (apiKey: string) => Promise<T>): Promise<T>;
|
|
20
|
+
}
|
|
21
|
+
export interface ClaudeSdkAdapterOptions {
|
|
22
|
+
runtime: Readonly<{
|
|
23
|
+
executablePath: string;
|
|
24
|
+
executableSha256: string;
|
|
25
|
+
cliVersion: string;
|
|
26
|
+
}>;
|
|
27
|
+
/** Existing physical mode-0700 directory owned by this user, outside all contact folders. */
|
|
28
|
+
stateRoot: string;
|
|
29
|
+
credentials: ClaudeApiKeyResolver;
|
|
30
|
+
qualification: RuntimeQualification;
|
|
31
|
+
/** Trusted host seam beneath the unchanged SDK restrictions. No native
|
|
32
|
+
* package is selected implicitly; omitted retains the existing process owner. */
|
|
33
|
+
processFactory?: BoundedProviderProcessFactory;
|
|
34
|
+
now?: () => number;
|
|
35
|
+
maxTurns?: number;
|
|
36
|
+
maxBudgetUsd?: number;
|
|
37
|
+
deadlineMs?: number;
|
|
38
|
+
}
|
|
39
|
+
export declare function inspectClaudeSdkRuntime(runtime: ClaudeSdkAdapterOptions["runtime"]): Promise<Readonly<{
|
|
40
|
+
executablePath: string;
|
|
41
|
+
executableSha256: string;
|
|
42
|
+
sdkSha256: string;
|
|
43
|
+
runtimeDigest: string;
|
|
44
|
+
runtimeVersion: string;
|
|
45
|
+
}>>;
|
|
46
|
+
export declare function assertClaudeInitialization(value: SDKSystemMessage, request: AgentRunRequest, broker: ToolBroker, cwd: string): void;
|
|
47
|
+
/** A real SDK subprocess adapter. Qualification is independent host evidence, never inferred from a response. */
|
|
48
|
+
export declare function createClaudeSdkAdapter(options: ClaudeSdkAdapterOptions): AgentAdapter;
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { type ClaudeApiKeyResolver } from "./claude-sdk.ts";
|
|
2
|
+
import { type BoundedProviderProcessFactory } from "./provider-process.ts";
|
|
3
|
+
import { type AgentTaskAdapter, type AgentTaskRoute, type TaskRuntimeQualification } from "./task-runtime.ts";
|
|
4
|
+
export type ClaudeTaskAuthentication = "api" | "subscription";
|
|
5
|
+
/** Returns the account's long-lived Claude subscription OAuth token
|
|
6
|
+
* (`sk-ant-oat…`) for one task, or fails closed. The host owns storage; the
|
|
7
|
+
* token reaches the provider only through CLAUDE_CODE_OAUTH_TOKEN env. */
|
|
8
|
+
export type ClaudeSubscriptionTokenResolver = (accountId: string, signal: AbortSignal) => Promise<string>;
|
|
9
|
+
/** Display-channel callbacks for one run. Deliberately not part of the
|
|
10
|
+
* execution request: the events are observational, never admission or custody
|
|
11
|
+
* evidence. The host owns the object and may swap handlers between turns —
|
|
12
|
+
* each property is read at emit time. */
|
|
13
|
+
export type ClaudeTaskEvents = {
|
|
14
|
+
/** Assistant text as the provider completes each content block (bounded). */
|
|
15
|
+
onAssistantText?: ((text: string) => void) | undefined;
|
|
16
|
+
/** Provider-declared error text from a failed result envelope (bounded). */
|
|
17
|
+
onProviderError?: ((text: string) => void) | undefined;
|
|
18
|
+
};
|
|
19
|
+
export type ClaudeTaskAdapterOptions = Readonly<{
|
|
20
|
+
route: AgentTaskRoute;
|
|
21
|
+
runtime: Readonly<{
|
|
22
|
+
executablePath: string;
|
|
23
|
+
executableSha256: string;
|
|
24
|
+
cliVersion: string;
|
|
25
|
+
}>;
|
|
26
|
+
/** Existing physical mode-0700 directory owned by this user, outside all workspaces. */
|
|
27
|
+
stateRoot: string;
|
|
28
|
+
/** Persistent physical mode-0700 directory holding the managed Claude
|
|
29
|
+
* configuration and subscription credentials. */
|
|
30
|
+
authDirectory: string;
|
|
31
|
+
/** Required when `authentication` is `"api"`. */
|
|
32
|
+
credentials?: ClaudeApiKeyResolver;
|
|
33
|
+
/** Required when `authentication` is `"subscription"`. */
|
|
34
|
+
subscriptionToken?: ClaudeSubscriptionTokenResolver;
|
|
35
|
+
/** Optional display channel; kept by reference and read per emit. */
|
|
36
|
+
events?: ClaudeTaskEvents;
|
|
37
|
+
authentication: ClaudeTaskAuthentication;
|
|
38
|
+
qualification: TaskRuntimeQualification;
|
|
39
|
+
/** System prompt for the host's own product surface. */
|
|
40
|
+
systemPrompt: string;
|
|
41
|
+
processFactory?: BoundedProviderProcessFactory;
|
|
42
|
+
now?: () => number;
|
|
43
|
+
maxTurns?: number;
|
|
44
|
+
maxBudgetUsd?: number;
|
|
45
|
+
deadlineMs?: number;
|
|
46
|
+
}>;
|
|
47
|
+
/** The adapter's stable runtime identity for one authentication mode and exact
|
|
48
|
+
* inspected binary (digest + admitted version). Hosts bind qualification
|
|
49
|
+
* records to this digest. */
|
|
50
|
+
export declare function claudeTaskRuntimeIdentity(input: Readonly<{
|
|
51
|
+
executableSha256: string;
|
|
52
|
+
cliVersion: string;
|
|
53
|
+
authentication: ClaudeTaskAuthentication;
|
|
54
|
+
}>): Readonly<{
|
|
55
|
+
version: string;
|
|
56
|
+
digest: string;
|
|
57
|
+
}>;
|
|
58
|
+
/**
|
|
59
|
+
* Claude Code through the Agent SDK as an application-profile task adapter. The
|
|
60
|
+
* model's entire tool surface is the capability broker; subscription auth uses
|
|
61
|
+
* the managed CLAUDE_CONFIG_DIR written by `xcb-compat auth claude`, while API
|
|
62
|
+
* auth keeps the key-resolver seam. No native tools, hooks, plugins, skills or
|
|
63
|
+
* inherited configuration reach the provider.
|
|
64
|
+
*/
|
|
65
|
+
export declare function createClaudeTaskAdapter(options: ClaudeTaskAdapterOptions): AgentTaskAdapter;
|