@joshski/dust 0.1.85 → 0.1.87
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/artifacts.js +21 -5
- package/dist/bucket/repository-loop.d.ts +11 -0
- package/dist/bucket/repository.d.ts +3 -0
- package/dist/bucket/server-messages.d.ts +38 -0
- package/dist/bucket/tool-prompt.d.ts +9 -0
- package/dist/claude/spawn-claude-code.d.ts +5 -1
- package/dist/claude/types.d.ts +4 -2
- package/dist/cli/commands/loop.d.ts +2 -0
- package/dist/docker/docker-agent.d.ts +35 -0
- package/dist/dust.js +920 -342
- package/dist/proxy/claude-api-proxy.d.ts +59 -0
- package/dist/proxy/git-credential-proxy.d.ts +68 -0
- package/package.json +1 -1
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Claude API Proxy Server
|
|
3
|
+
*
|
|
4
|
+
* An HTTP server that proxies Claude API requests from Docker containers.
|
|
5
|
+
* The container sends plain HTTP requests to this proxy, and the proxy
|
|
6
|
+
* forwards them to the Anthropic API with the OAuth token injected.
|
|
7
|
+
*
|
|
8
|
+
* This allows removing:
|
|
9
|
+
* - CLAUDE_CODE_OAUTH_TOKEN environment variable from containers
|
|
10
|
+
* - ~/.claude mount (currently read-write for OAuth token refresh)
|
|
11
|
+
* - ~/.claude.json mount
|
|
12
|
+
*
|
|
13
|
+
* The proxy handles token management (including refresh) on the host side.
|
|
14
|
+
*
|
|
15
|
+
* Flow:
|
|
16
|
+
* ```
|
|
17
|
+
* Container: HTTP request to proxy:3002/v1/messages
|
|
18
|
+
* → Proxy receives plain HTTP request
|
|
19
|
+
* → Proxy reads OAuth token from ~/.claude/.credentials.json
|
|
20
|
+
* → Proxy forwards to https://api.anthropic.com/v1/messages with Authorization header
|
|
21
|
+
* → Returns response to container
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
export interface ClaudeApiProxyDependencies {
|
|
25
|
+
homedir: () => string;
|
|
26
|
+
readFileSync: (path: string, encoding: 'utf-8') => string;
|
|
27
|
+
fetch: typeof fetch;
|
|
28
|
+
}
|
|
29
|
+
export declare const defaultDependencies: ClaudeApiProxyDependencies;
|
|
30
|
+
/**
|
|
31
|
+
* Credentials stored in ~/.claude/.credentials.json by Claude Code
|
|
32
|
+
*/
|
|
33
|
+
export interface ClaudeCredentials {
|
|
34
|
+
claudeAiOauth?: {
|
|
35
|
+
accessToken?: string;
|
|
36
|
+
refreshToken?: string;
|
|
37
|
+
expiresAt?: string;
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Read OAuth token from Claude Code's credentials file.
|
|
42
|
+
* Returns null if the file doesn't exist or doesn't contain a valid token.
|
|
43
|
+
*/
|
|
44
|
+
export declare function readOAuthToken(dependencies?: ClaudeApiProxyDependencies): string | null;
|
|
45
|
+
/**
|
|
46
|
+
* Check if the OAuth token is expired or about to expire.
|
|
47
|
+
* Returns true if the token expires within the next 5 minutes.
|
|
48
|
+
*/
|
|
49
|
+
export declare function isTokenExpired(dependencies?: ClaudeApiProxyDependencies): boolean;
|
|
50
|
+
export interface ClaudeApiProxyServer {
|
|
51
|
+
port: number;
|
|
52
|
+
stop: () => void;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Creates a Claude API proxy server.
|
|
56
|
+
* The server accepts HTTP requests and forwards them to the Anthropic API
|
|
57
|
+
* with the OAuth token injected.
|
|
58
|
+
*/
|
|
59
|
+
export declare function createClaudeApiProxyServer(dependencies?: ClaudeApiProxyDependencies): Promise<ClaudeApiProxyServer>;
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Git Credential Proxy Server
|
|
3
|
+
*
|
|
4
|
+
* An HTTP server that proxies git requests from Docker containers.
|
|
5
|
+
* The container talks plain HTTP to this proxy, and the proxy forwards
|
|
6
|
+
* requests to the upstream HTTPS URL with credentials injected.
|
|
7
|
+
*
|
|
8
|
+
* The proxy uses the host's existing git credential system (`git credential fill`)
|
|
9
|
+
* so no new auth setup is required from the user.
|
|
10
|
+
*
|
|
11
|
+
* Flow:
|
|
12
|
+
* ```
|
|
13
|
+
* Container: git clone http://host.docker.internal:<port>/org/repo.git
|
|
14
|
+
* → Proxy receives plain HTTP git smart protocol request
|
|
15
|
+
* → Proxy runs `git credential fill` on host to get credentials
|
|
16
|
+
* → Proxy forwards as https://github.com/org/repo.git with Authorization header
|
|
17
|
+
* → Returns response to container
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
20
|
+
import type { spawn as nodeSpawn } from 'node:child_process';
|
|
21
|
+
export interface GitCredentialProxyDependencies {
|
|
22
|
+
spawn: typeof nodeSpawn;
|
|
23
|
+
}
|
|
24
|
+
export interface GitCredentials {
|
|
25
|
+
username: string;
|
|
26
|
+
password: string;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Parse a git URL path to extract the host, owner, and repo.
|
|
30
|
+
* Expected format: /<host>/<owner>/<repo>.git or /<owner>/<repo>.git (defaults to github.com)
|
|
31
|
+
*/
|
|
32
|
+
export declare function parseGitPath(urlPath: string): {
|
|
33
|
+
host: string;
|
|
34
|
+
owner: string;
|
|
35
|
+
repo: string;
|
|
36
|
+
} | null;
|
|
37
|
+
/**
|
|
38
|
+
* Runs `git credential fill` to obtain credentials for a given URL.
|
|
39
|
+
* Returns the username and password from the git credential helper.
|
|
40
|
+
*/
|
|
41
|
+
export declare function getGitCredentials(host: string, dependencies: GitCredentialProxyDependencies): Promise<GitCredentials | null>;
|
|
42
|
+
/**
|
|
43
|
+
* Creates the Authorization header value for git HTTP authentication.
|
|
44
|
+
* Uses Basic authentication with base64-encoded credentials.
|
|
45
|
+
*/
|
|
46
|
+
export declare function createAuthHeader(credentials: GitCredentials): string;
|
|
47
|
+
/**
|
|
48
|
+
* Extracts the git smart protocol endpoint from a URL path.
|
|
49
|
+
* Git smart protocol uses these endpoints:
|
|
50
|
+
* - /info/refs?service=git-upload-pack (fetch/clone discovery)
|
|
51
|
+
* - /info/refs?service=git-receive-pack (push discovery)
|
|
52
|
+
* - /git-upload-pack (fetch/clone data)
|
|
53
|
+
* - /git-receive-pack (push data)
|
|
54
|
+
*/
|
|
55
|
+
export declare function extractGitEndpoint(urlPath: string): {
|
|
56
|
+
basePath: string;
|
|
57
|
+
endpoint: string;
|
|
58
|
+
} | null;
|
|
59
|
+
export interface GitCredentialProxyServer {
|
|
60
|
+
port: number;
|
|
61
|
+
stop: () => void;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Creates a git credential proxy server.
|
|
65
|
+
* The server accepts git smart HTTP protocol requests and forwards them
|
|
66
|
+
* to the upstream HTTPS URL with credentials injected.
|
|
67
|
+
*/
|
|
68
|
+
export declare function createGitCredentialProxyServer(dependencies: GitCredentialProxyDependencies): Promise<GitCredentialProxyServer>;
|