amp-acp 0.6.0 → 0.6.2
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/index.js +140 -30
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -5104,6 +5104,7 @@ import { spawn } from "node:child_process";
|
|
|
5104
5104
|
import fs from "node:fs";
|
|
5105
5105
|
import { mkdir, readFile, rm, writeFile } from "node:fs/promises";
|
|
5106
5106
|
import { createRequire } from "node:module";
|
|
5107
|
+
import os from "node:os";
|
|
5107
5108
|
import path from "node:path";
|
|
5108
5109
|
import { createInterface } from "node:readline";
|
|
5109
5110
|
var __defProp2 = Object.defineProperty;
|
|
@@ -9119,18 +9120,42 @@ var PermissionSchema = exports_external2.object({
|
|
|
9119
9120
|
});
|
|
9120
9121
|
}
|
|
9121
9122
|
});
|
|
9122
|
-
var
|
|
9123
|
+
var MCPOAuthConfigSchema = exports_external2.object({
|
|
9124
|
+
clientId: exports_external2.string().describe("OAuth client ID"),
|
|
9125
|
+
clientSecret: exports_external2.string().describe("OAuth client secret").optional(),
|
|
9126
|
+
authUrl: exports_external2.string().describe("OAuth authorization URL"),
|
|
9127
|
+
tokenUrl: exports_external2.string().describe("OAuth token URL"),
|
|
9128
|
+
scopes: exports_external2.array(exports_external2.string()).describe("OAuth scopes").optional(),
|
|
9129
|
+
redirectUrl: exports_external2.string().describe("OAuth redirect URL").optional()
|
|
9130
|
+
}).describe("OAuth configuration for HTTP MCP servers");
|
|
9131
|
+
var MCPStdioServerSchema = exports_external2.object({
|
|
9123
9132
|
command: exports_external2.string().describe("Command to run the MCP server"),
|
|
9124
9133
|
args: exports_external2.array(exports_external2.string()).describe("Arguments for the MCP server command").optional(),
|
|
9125
9134
|
env: exports_external2.record(exports_external2.string(), exports_external2.string()).describe("Environment variables for the server").optional(),
|
|
9126
9135
|
disabled: exports_external2.boolean().describe("Whether the server is disabled").optional()
|
|
9127
9136
|
});
|
|
9137
|
+
var MCPHttpServerSchema = exports_external2.object({
|
|
9138
|
+
url: exports_external2.string().describe("URL of the HTTP MCP server"),
|
|
9139
|
+
headers: exports_external2.record(exports_external2.string(), exports_external2.string()).describe("HTTP headers to send with requests").optional(),
|
|
9140
|
+
transport: exports_external2.string().describe('Transport type (e.g., "sse")').optional(),
|
|
9141
|
+
oauth: MCPOAuthConfigSchema.describe("OAuth configuration for authentication").optional(),
|
|
9142
|
+
disabled: exports_external2.boolean().describe("Whether the server is disabled").optional()
|
|
9143
|
+
});
|
|
9144
|
+
var MCPServerSchema = exports_external2.union([MCPStdioServerSchema, MCPHttpServerSchema]);
|
|
9128
9145
|
var MCPConfigSchema = exports_external2.record(exports_external2.string(), MCPServerSchema).describe("MCP server configurations keyed by server name");
|
|
9146
|
+
var VisibilitySchema = exports_external2.enum(["private", "public", "workspace", "group"]);
|
|
9147
|
+
var ThreadsNewOptionsSchema = exports_external2.object({
|
|
9148
|
+
visibility: VisibilitySchema.optional().describe("Thread visibility")
|
|
9149
|
+
});
|
|
9150
|
+
var ThreadsMarkdownOptionsSchema = exports_external2.object({
|
|
9151
|
+
threadId: exports_external2.string().describe("The thread ID to get markdown for")
|
|
9152
|
+
});
|
|
9129
9153
|
var AmpOptionsSchema = exports_external2.object({
|
|
9130
9154
|
cwd: exports_external2.string().describe("Current working directory").optional(),
|
|
9131
|
-
mode: exports_external2.enum(["smart", "rush", "large"]).describe("Agent mode - controls the model, system prompt, and tool selection").default("smart").optional(),
|
|
9155
|
+
mode: exports_external2.enum(["smart", "rush", "large", "deep"]).describe("Agent mode - controls the model, system prompt, and tool selection").default("smart").optional(),
|
|
9132
9156
|
dangerouslyAllowAll: exports_external2.boolean().describe("Allow all tool usage without asking for permission").optional(),
|
|
9133
|
-
|
|
9157
|
+
archive: exports_external2.boolean().describe("Archive the thread after execution completes").optional(),
|
|
9158
|
+
visibility: VisibilitySchema.describe("Visibility level for new threads").default("workspace").optional(),
|
|
9134
9159
|
settingsFile: exports_external2.string().describe("Settings file path").optional(),
|
|
9135
9160
|
logLevel: exports_external2.enum(["debug", "info", "warn", "error", "audit"]).describe("Log level").optional(),
|
|
9136
9161
|
logFile: exports_external2.string().describe("Log file path").optional(),
|
|
@@ -9138,7 +9163,11 @@ var AmpOptionsSchema = exports_external2.object({
|
|
|
9138
9163
|
env: exports_external2.record(exports_external2.string(), exports_external2.string()).describe("Additional environment variables").optional(),
|
|
9139
9164
|
continue: exports_external2.union([exports_external2.boolean(), exports_external2.string()]).describe("Continue the most recent thread (true) or a specific thread by ID (string)").optional(),
|
|
9140
9165
|
toolbox: exports_external2.string().describe("Folder path with toolbox scripts").optional(),
|
|
9141
|
-
|
|
9166
|
+
skills: exports_external2.string().describe("Folder path with custom skills").optional(),
|
|
9167
|
+
permissions: exports_external2.array(PermissionSchema).describe("Permission rules for tool usage").optional(),
|
|
9168
|
+
labels: exports_external2.array(exports_external2.string().regex(/^[a-zA-Z0-9][a-zA-Z0-9-]*$/, "Labels must start with alphanumeric and contain only alphanumeric characters and hyphens").min(1, "Label must be at least 1 character").max(32, "Label must be at most 32 characters")).max(20, "Maximum 20 labels allowed").describe("Labels to add to the thread (repeatable CLI --label)").optional(),
|
|
9169
|
+
enabledTools: exports_external2.array(exports_external2.string()).describe('Array of tool name patterns to enable. Supports glob patterns (e.g., "mcp__metabase__*"). If not provided, all tools are enabled. If provided, only matching tools are enabled.').optional(),
|
|
9170
|
+
systemPrompt: exports_external2.string().describe("Custom system prompt text to append to the base system prompt for integration-specific customizations").optional()
|
|
9142
9171
|
}).strict();
|
|
9143
9172
|
var isWindows = process.platform === "win32";
|
|
9144
9173
|
async function* execute(options) {
|
|
@@ -9172,22 +9201,9 @@ async function* execute(options) {
|
|
|
9172
9201
|
}
|
|
9173
9202
|
yield* processOutputStream(ampProcess.stdout);
|
|
9174
9203
|
const { exitCode, stderr, signal: processSignal } = await waitForProcess(ampProcess, signal);
|
|
9175
|
-
|
|
9176
|
-
if (signal?.aborted) {
|
|
9177
|
-
throw new Error("Amp CLI process was aborted");
|
|
9178
|
-
} else if (processSignal) {
|
|
9179
|
-
throw new Error(`Amp CLI process was killed by signal ${processSignal}`);
|
|
9180
|
-
} else {
|
|
9181
|
-
throw new Error("Amp CLI process terminated unexpectedly");
|
|
9182
|
-
}
|
|
9183
|
-
} else if (exitCode !== 0) {
|
|
9184
|
-
const errorDetails = stderr ? `: ${stderr}` : "";
|
|
9185
|
-
throw new Error(`Amp CLI process exited with code ${exitCode}${errorDetails}`);
|
|
9186
|
-
}
|
|
9204
|
+
throwIfProcessFailed(exitCode, stderr, processSignal, signal);
|
|
9187
9205
|
} catch (error) {
|
|
9188
|
-
|
|
9189
|
-
ampProcess.kill(isWindows ? "SIGKILL" : "SIGTERM");
|
|
9190
|
-
}
|
|
9206
|
+
killProcess(ampProcess);
|
|
9191
9207
|
throw error;
|
|
9192
9208
|
} finally {
|
|
9193
9209
|
await cleanupTempFile();
|
|
@@ -9198,7 +9214,14 @@ function generateSessionId() {
|
|
|
9198
9214
|
return `sdk-${Date.now()}-${randomHex}`;
|
|
9199
9215
|
}
|
|
9200
9216
|
async function buildSettingsFile(options, sessionId) {
|
|
9201
|
-
|
|
9217
|
+
const settingsFields = [
|
|
9218
|
+
options.permissions,
|
|
9219
|
+
options.mode,
|
|
9220
|
+
options.skills,
|
|
9221
|
+
options.enabledTools,
|
|
9222
|
+
options.systemPrompt
|
|
9223
|
+
];
|
|
9224
|
+
if (!settingsFields.some(Boolean)) {
|
|
9202
9225
|
return {
|
|
9203
9226
|
settingsFilePath: null,
|
|
9204
9227
|
cleanupTempFile: async () => {}
|
|
@@ -9218,11 +9241,22 @@ async function buildSettingsFile(options, sessionId) {
|
|
|
9218
9241
|
}
|
|
9219
9242
|
}
|
|
9220
9243
|
}
|
|
9221
|
-
|
|
9222
|
-
|
|
9223
|
-
|
|
9244
|
+
if (options.permissions) {
|
|
9245
|
+
mergedSettings["amp.permissions"] = options.permissions;
|
|
9246
|
+
}
|
|
9247
|
+
if (options.enabledTools) {
|
|
9248
|
+
mergedSettings["amp.tools.enable"] = options.enabledTools;
|
|
9249
|
+
}
|
|
9250
|
+
if (options.systemPrompt) {
|
|
9251
|
+
mergedSettings["amp.systemPrompt"] = options.systemPrompt;
|
|
9252
|
+
}
|
|
9253
|
+
if (options.skills) {
|
|
9254
|
+
mergedSettings["amp.skills.path"] = options.skills;
|
|
9224
9255
|
}
|
|
9225
9256
|
await mkdir(tempDir, { recursive: true });
|
|
9257
|
+
if (process.env.AMP_DEBUG) {
|
|
9258
|
+
console.log("[SDK] Writing settings file:", tempSettingsPath, mergedSettings);
|
|
9259
|
+
}
|
|
9226
9260
|
await writeFile(tempSettingsPath, JSON.stringify(mergedSettings, null, 2), "utf-8");
|
|
9227
9261
|
return {
|
|
9228
9262
|
settingsFilePath: tempSettingsPath,
|
|
@@ -9243,7 +9277,7 @@ function buildEnvironmentVariables(options) {
|
|
|
9243
9277
|
if (options.env) {
|
|
9244
9278
|
Object.assign(env, options.env);
|
|
9245
9279
|
}
|
|
9246
|
-
env.AMP_SDK_VERSION = "0.1.0-
|
|
9280
|
+
env.AMP_SDK_VERSION = "0.1.0-20260220044036-g88868e6";
|
|
9247
9281
|
return env;
|
|
9248
9282
|
}
|
|
9249
9283
|
function spawnAmpCli(args, options) {
|
|
@@ -9259,6 +9293,21 @@ function spawnAmpCli(args, options) {
|
|
|
9259
9293
|
return childProcess;
|
|
9260
9294
|
}
|
|
9261
9295
|
function findAmpCommand() {
|
|
9296
|
+
const localAmpCommand = resolveLocalAmpPackageCommand();
|
|
9297
|
+
if (localAmpCommand) {
|
|
9298
|
+
return localAmpCommand;
|
|
9299
|
+
}
|
|
9300
|
+
const homeAmpCommand = resolveLocalAmpCommand();
|
|
9301
|
+
if (homeAmpCommand) {
|
|
9302
|
+
return homeAmpCommand;
|
|
9303
|
+
}
|
|
9304
|
+
const pathAmpCommand = resolveAmpFromPath();
|
|
9305
|
+
if (pathAmpCommand) {
|
|
9306
|
+
return pathAmpCommand;
|
|
9307
|
+
}
|
|
9308
|
+
throw new Error("Could not find local @sourcegraph/amp package or amp binary. Make sure it is installed.");
|
|
9309
|
+
}
|
|
9310
|
+
function resolveLocalAmpPackageCommand() {
|
|
9262
9311
|
try {
|
|
9263
9312
|
const require2 = createRequire(import.meta.url);
|
|
9264
9313
|
const pkgJsonPath = require2.resolve("@sourcegraph/amp/package.json");
|
|
@@ -9276,8 +9325,41 @@ function findAmpCommand() {
|
|
|
9276
9325
|
if (error instanceof Error && error.message.includes("Local @sourcegraph/amp")) {
|
|
9277
9326
|
throw error;
|
|
9278
9327
|
}
|
|
9279
|
-
|
|
9328
|
+
return null;
|
|
9329
|
+
}
|
|
9330
|
+
}
|
|
9331
|
+
function resolveLocalAmpCommand() {
|
|
9332
|
+
const candidates = isWindows ? ["amp.exe", "amp.cmd", "amp"] : ["amp"];
|
|
9333
|
+
const ampBinDir = path.join(os.homedir(), ".amp", "bin");
|
|
9334
|
+
for (const candidate of candidates) {
|
|
9335
|
+
const candidatePath = path.join(ampBinDir, candidate);
|
|
9336
|
+
if (fs.existsSync(candidatePath)) {
|
|
9337
|
+
return {
|
|
9338
|
+
command: candidatePath,
|
|
9339
|
+
args: []
|
|
9340
|
+
};
|
|
9341
|
+
}
|
|
9342
|
+
}
|
|
9343
|
+
return null;
|
|
9344
|
+
}
|
|
9345
|
+
function resolveAmpFromPath() {
|
|
9346
|
+
const pathEntries = process.env.PATH?.split(path.delimiter) ?? [];
|
|
9347
|
+
const candidates = isWindows ? ["amp.exe", "amp.cmd", "amp"] : ["amp"];
|
|
9348
|
+
for (const pathEntry of pathEntries) {
|
|
9349
|
+
if (!pathEntry) {
|
|
9350
|
+
continue;
|
|
9351
|
+
}
|
|
9352
|
+
for (const candidate of candidates) {
|
|
9353
|
+
const candidatePath = path.join(pathEntry, candidate);
|
|
9354
|
+
if (fs.existsSync(candidatePath)) {
|
|
9355
|
+
return {
|
|
9356
|
+
command: candidatePath,
|
|
9357
|
+
args: []
|
|
9358
|
+
};
|
|
9359
|
+
}
|
|
9360
|
+
}
|
|
9280
9361
|
}
|
|
9362
|
+
return null;
|
|
9281
9363
|
}
|
|
9282
9364
|
function buildCliArgs(options) {
|
|
9283
9365
|
const args = [];
|
|
@@ -9290,6 +9372,9 @@ function buildCliArgs(options) {
|
|
|
9290
9372
|
if (options.dangerouslyAllowAll) {
|
|
9291
9373
|
args.push("--dangerously-allow-all");
|
|
9292
9374
|
}
|
|
9375
|
+
if (options.archive) {
|
|
9376
|
+
args.push("--archive");
|
|
9377
|
+
}
|
|
9293
9378
|
if (options.visibility) {
|
|
9294
9379
|
args.push("--visibility", options.visibility);
|
|
9295
9380
|
}
|
|
@@ -9309,8 +9394,32 @@ function buildCliArgs(options) {
|
|
|
9309
9394
|
if (options.mode) {
|
|
9310
9395
|
args.push("--mode", options.mode);
|
|
9311
9396
|
}
|
|
9397
|
+
if (options.labels) {
|
|
9398
|
+
for (const label of options.labels) {
|
|
9399
|
+
args.push("--label", label);
|
|
9400
|
+
}
|
|
9401
|
+
}
|
|
9312
9402
|
return args;
|
|
9313
9403
|
}
|
|
9404
|
+
function throwIfProcessFailed(exitCode, stderr, processSignal, signal) {
|
|
9405
|
+
if (exitCode === null) {
|
|
9406
|
+
if (signal?.aborted) {
|
|
9407
|
+
throw new Error("Amp CLI process was aborted");
|
|
9408
|
+
} else if (processSignal) {
|
|
9409
|
+
throw new Error(`Amp CLI process was killed by signal ${processSignal}`);
|
|
9410
|
+
} else {
|
|
9411
|
+
throw new Error("Amp CLI process terminated unexpectedly");
|
|
9412
|
+
}
|
|
9413
|
+
} else if (exitCode !== 0) {
|
|
9414
|
+
const errorDetails = stderr ? `: ${stderr.trim()}` : "";
|
|
9415
|
+
throw new Error(`Amp CLI process exited with code ${exitCode}${errorDetails}`);
|
|
9416
|
+
}
|
|
9417
|
+
}
|
|
9418
|
+
function killProcess(proc) {
|
|
9419
|
+
if (!proc.killed) {
|
|
9420
|
+
proc.kill(isWindows ? "SIGKILL" : "SIGTERM");
|
|
9421
|
+
}
|
|
9422
|
+
}
|
|
9314
9423
|
async function* processOutputStream(stdout) {
|
|
9315
9424
|
if (!stdout) {
|
|
9316
9425
|
throw new Error("No stdout stream available from Amp CLI process");
|
|
@@ -9535,7 +9644,7 @@ function safeJson(x) {
|
|
|
9535
9644
|
// package.json
|
|
9536
9645
|
var package_default = {
|
|
9537
9646
|
name: "amp-acp",
|
|
9538
|
-
version: "0.6.
|
|
9647
|
+
version: "0.6.2",
|
|
9539
9648
|
private: false,
|
|
9540
9649
|
type: "module",
|
|
9541
9650
|
main: "dist/index.js",
|
|
@@ -9553,17 +9662,17 @@ var package_default = {
|
|
|
9553
9662
|
},
|
|
9554
9663
|
scripts: {
|
|
9555
9664
|
build: "bun build src/index.ts --target=node --outdir=dist --entry-naming=[dir]/[name].js",
|
|
9556
|
-
"build:binary": "bun build src/index.ts --compile --outfile dist/amp-acp",
|
|
9665
|
+
"build:binary": "bun build src/index.ts --target=node --outdir=dist --entry-naming=[dir]/[name].js && bun build dist/index.js --compile --outfile dist/amp-acp",
|
|
9557
9666
|
start: "bun dist/index.js",
|
|
9558
9667
|
lint: "tsc --noEmit",
|
|
9559
9668
|
test: "bun test src/",
|
|
9560
|
-
"test:binary": "bun build src/index.ts --compile --outfile dist/amp-acp-test && bun test test/binary.test.ts",
|
|
9669
|
+
"test:binary": "bun build src/index.ts --target=node --outdir=dist --entry-naming=[dir]/[name].js && bun build dist/index.js --compile --outfile dist/amp-acp-test && bun test test/binary.test.ts",
|
|
9561
9670
|
"test:all": "bun run test && bun run test:binary"
|
|
9562
9671
|
},
|
|
9563
9672
|
dependencies: {
|
|
9564
9673
|
"@agentclientprotocol/sdk": "0.4.8",
|
|
9565
9674
|
"@sourcegraph/amp": "^0.0.1765685598-g5365e6",
|
|
9566
|
-
"@sourcegraph/amp-sdk": "
|
|
9675
|
+
"@sourcegraph/amp-sdk": "0.1.0-20260220044036-g88868e6"
|
|
9567
9676
|
},
|
|
9568
9677
|
devDependencies: {
|
|
9569
9678
|
"@types/bun": "^1.2.5",
|
|
@@ -9683,7 +9792,8 @@ ${chunk.resource.text}
|
|
|
9683
9792
|
}
|
|
9684
9793
|
}
|
|
9685
9794
|
const options = {
|
|
9686
|
-
cwd: s.cwd
|
|
9795
|
+
cwd: s.cwd,
|
|
9796
|
+
env: { TERM: "dumb" }
|
|
9687
9797
|
};
|
|
9688
9798
|
if (s.mode === "bypass") {
|
|
9689
9799
|
options.dangerouslyAllowAll = true;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "amp-acp",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.2",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -18,17 +18,17 @@
|
|
|
18
18
|
},
|
|
19
19
|
"scripts": {
|
|
20
20
|
"build": "bun build src/index.ts --target=node --outdir=dist --entry-naming=[dir]/[name].js",
|
|
21
|
-
"build:binary": "bun build src/index.ts --compile --outfile dist/amp-acp",
|
|
21
|
+
"build:binary": "bun build src/index.ts --target=node --outdir=dist --entry-naming=[dir]/[name].js && bun build dist/index.js --compile --outfile dist/amp-acp",
|
|
22
22
|
"start": "bun dist/index.js",
|
|
23
23
|
"lint": "tsc --noEmit",
|
|
24
24
|
"test": "bun test src/",
|
|
25
|
-
"test:binary": "bun build src/index.ts --compile --outfile dist/amp-acp-test && bun test test/binary.test.ts",
|
|
25
|
+
"test:binary": "bun build src/index.ts --target=node --outdir=dist --entry-naming=[dir]/[name].js && bun build dist/index.js --compile --outfile dist/amp-acp-test && bun test test/binary.test.ts",
|
|
26
26
|
"test:all": "bun run test && bun run test:binary"
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
29
|
"@agentclientprotocol/sdk": "0.4.8",
|
|
30
30
|
"@sourcegraph/amp": "^0.0.1765685598-g5365e6",
|
|
31
|
-
"@sourcegraph/amp-sdk": "
|
|
31
|
+
"@sourcegraph/amp-sdk": "0.1.0-20260220044036-g88868e6"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
34
|
"@types/bun": "^1.2.5",
|