@slopus/happy-providers 0.0.63 → 0.0.67
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/VENDOR_CODEX.md +5 -0
- package/dist/core/happyProvidersVersion.d.ts +1 -1
- package/dist/core/happyProvidersVersion.js +1 -1
- package/dist/core/hiddenChildProcess.d.ts +15 -0
- package/dist/core/hiddenChildProcess.d.ts.map +1 -0
- package/dist/core/hiddenChildProcess.js +45 -0
- package/dist/core/hiddenChildProcess.js.map +1 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/protocol/acp/AcpConnection.d.ts +5 -0
- package/dist/protocol/acp/AcpConnection.d.ts.map +1 -1
- package/dist/protocol/acp/AcpConnection.js +5 -0
- package/dist/protocol/acp/AcpConnection.js.map +1 -1
- package/dist/protocol/acp/AcpProvider.d.ts +24 -3
- package/dist/protocol/acp/AcpProvider.d.ts.map +1 -1
- package/dist/protocol/acp/AcpProvider.js.map +1 -1
- package/dist/protocol/acp/AcpSession.d.ts.map +1 -1
- package/dist/protocol/acp/AcpSession.js +64 -35
- package/dist/protocol/acp/AcpSession.js.map +1 -1
- package/dist/protocol/acp/impl/AcpToolBridgeServer.d.ts +44 -1
- package/dist/protocol/acp/impl/AcpToolBridgeServer.d.ts.map +1 -1
- package/dist/protocol/acp/impl/AcpToolBridgeServer.js +152 -11
- package/dist/protocol/acp/impl/AcpToolBridgeServer.js.map +1 -1
- package/dist/protocol/acp/impl/acpConnectionSpawn.d.ts.map +1 -1
- package/dist/protocol/acp/impl/acpConnectionSpawn.js +2 -3
- package/dist/protocol/acp/impl/acpConnectionSpawn.js.map +1 -1
- package/dist/protocol/acp/impl/acpResponseEvents.d.ts +15 -0
- package/dist/protocol/acp/impl/acpResponseEvents.d.ts.map +1 -1
- package/dist/protocol/acp/impl/acpResponseEvents.js +62 -3
- package/dist/protocol/acp/impl/acpResponseEvents.js.map +1 -1
- package/dist/protocol/acp/impl/acpToolGuide.d.ts +17 -0
- package/dist/protocol/acp/impl/acpToolGuide.d.ts.map +1 -0
- package/dist/protocol/acp/impl/acpToolGuide.js +54 -0
- package/dist/protocol/acp/impl/acpToolGuide.js.map +1 -0
- package/dist/protocol/acp/impl/processTree.d.ts +1 -1
- package/dist/protocol/acp/impl/processTree.d.ts.map +1 -1
- package/dist/protocol/acp/impl/processTree.js +3 -4
- package/dist/protocol/acp/impl/processTree.js.map +1 -1
- package/dist/vendors/claude/impl/auth.js +2 -2
- package/dist/vendors/claude/impl/auth.js.map +1 -1
- package/dist/vendors/claude/impl/spawnClaudeCodeChild.d.ts +1 -1
- package/dist/vendors/claude/impl/spawnClaudeCodeChild.d.ts.map +1 -1
- package/dist/vendors/claude/impl/spawnClaudeCodeChild.js +2 -3
- package/dist/vendors/claude/impl/spawnClaudeCodeChild.js.map +1 -1
- package/dist/vendors/claudeAgent/claudeAgentConnect.d.ts.map +1 -1
- package/dist/vendors/claudeAgent/claudeAgentConnect.js +6 -2
- package/dist/vendors/claudeAgent/claudeAgentConnect.js.map +1 -1
- package/dist/vendors/codex/impl/codexUserAgent.js +2 -2
- package/dist/vendors/codex/impl/codexUserAgent.js.map +1 -1
- package/dist/vendors/codexAppServer/codexAppServerConnect.js +2 -3
- package/dist/vendors/codexAppServer/codexAppServerConnect.js.map +1 -1
- package/dist/vendors/foreignAgents/antigravityAgent.d.ts +5 -3
- package/dist/vendors/foreignAgents/antigravityAgent.d.ts.map +1 -1
- package/dist/vendors/foreignAgents/antigravityAgent.js +29 -31
- package/dist/vendors/foreignAgents/antigravityAgent.js.map +1 -1
- package/dist/vendors/foreignAgents/antigravityHappyOnly.d.ts +19 -0
- package/dist/vendors/foreignAgents/antigravityHappyOnly.d.ts.map +1 -0
- package/dist/vendors/foreignAgents/antigravityHappyOnly.js +131 -0
- package/dist/vendors/foreignAgents/antigravityHappyOnly.js.map +1 -0
- package/package.json +1 -1
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { execFileHidden } from "../../core/hiddenChildProcess.js";
|
|
2
|
+
import { antigravityHappyOnly } from "../../vendors/foreignAgents/antigravityHappyOnly.js";
|
|
2
3
|
import { acpSpawnConnect, foreignAgentLaunch, foreignAgentModelName, } from "../../vendors/foreignAgents/ForeignAgent.js";
|
|
3
4
|
const THREE = ["low", "medium", "high"];
|
|
4
5
|
/** Efforts Antigravity spells as a model-value suffix, in Happy's picker order. */
|
|
@@ -10,8 +11,8 @@ const EFFORT_SUFFIXES = [
|
|
|
10
11
|
"xhigh",
|
|
11
12
|
"max",
|
|
12
13
|
];
|
|
13
|
-
/** The first `agy`
|
|
14
|
-
const MIN_AGY_VERSION = [1, 5,
|
|
14
|
+
/** The first `agy` known to run Happy's custom agent: no tools of its own, Happy's MCP allowed. */
|
|
15
|
+
const MIN_AGY_VERSION = [1, 5, 15];
|
|
15
16
|
const VERSION_TIMEOUT_MS = 15_000;
|
|
16
17
|
const models = [
|
|
17
18
|
model("gemini-4-carbon", "Gemini 4 Carbon", THREE, "medium"),
|
|
@@ -24,9 +25,11 @@ const models = [
|
|
|
24
25
|
/**
|
|
25
26
|
* Google Antigravity through its own ACP server, `agy acp`, with the signed-in `agy` CLI.
|
|
26
27
|
*
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
*
|
|
28
|
+
* Happy starts agy as a custom agent with none of agy's own tools but web search (see
|
|
29
|
+
* {@link antigravityHappyOnly}), so it reads, writes, runs commands and starts sub-agents only
|
|
30
|
+
* through Happy's bridged tools, under Happy's one sandbox and reviewer. agy asks before every
|
|
31
|
+
* MCP call; those asks are approved, because Happy decides each call when it runs. Happy's
|
|
32
|
+
* instructions and a guide to its tools become the end of agy's system prompt.
|
|
30
33
|
*/
|
|
31
34
|
export const antigravityAgent = {
|
|
32
35
|
type: "antigravity",
|
|
@@ -34,22 +37,19 @@ export const antigravityAgent = {
|
|
|
34
37
|
label: "Antigravity",
|
|
35
38
|
connect: (start) => {
|
|
36
39
|
const launch = foreignAgentLaunch(start, { command: "agy", args: ["acp"] });
|
|
37
|
-
|
|
38
|
-
//
|
|
39
|
-
|
|
40
|
-
|
|
40
|
+
// A configured command may be any adapter, run as it is; only Happy's own launch is known
|
|
41
|
+
// to take a custom agent, and only it is version-checked, until it passes once.
|
|
42
|
+
if (start.command !== undefined)
|
|
43
|
+
return acpSpawnConnect(launch);
|
|
44
|
+
const connect = antigravityHappyOnly(launch);
|
|
41
45
|
let checked;
|
|
42
46
|
return async (cwd, client) => {
|
|
43
|
-
|
|
44
|
-
checked
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
await checked;
|
|
49
|
-
}
|
|
47
|
+
checked ??= requireAgyVersion(launch).catch((error) => {
|
|
48
|
+
checked = undefined;
|
|
49
|
+
throw error;
|
|
50
|
+
});
|
|
51
|
+
await checked;
|
|
50
52
|
const connection = await connect(cwd, client);
|
|
51
|
-
if (!own)
|
|
52
|
-
return connection;
|
|
53
53
|
const capabilities = connection.init.agentCapabilities;
|
|
54
54
|
return {
|
|
55
55
|
...connection,
|
|
@@ -81,17 +81,15 @@ export const antigravityAgent = {
|
|
|
81
81
|
{ configId: "thought_level", value: level },
|
|
82
82
|
];
|
|
83
83
|
},
|
|
84
|
-
//
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
},
|
|
94
|
-
],
|
|
84
|
+
// agy 1.5.10 declared about 60 KB of MCP tools to its model and dropped the rest without a
|
|
85
|
+
// way to call them; the margin leaves room for its own schema additions. 1.5.15 shows its
|
|
86
|
+
// model only the tools' names, and call_tool describes them.
|
|
87
|
+
toolDeclarationBudget: 48_000,
|
|
88
|
+
// One mode for every Happy mode: agy's `default` asks before each MCP call, and before any
|
|
89
|
+
// edit or command of its own should it ever have tools again. Happy's own mode decides
|
|
90
|
+
// what its tools may do.
|
|
91
|
+
permissionOptions: () => [{ configId: "mode", value: "default" }],
|
|
92
|
+
systemPromptMeta: (prompt) => ({ antigravity: { systemPrompt: { append: prompt } } }),
|
|
95
93
|
},
|
|
96
94
|
credentialEnvironment: (credentials) => credentials.apiKey === undefined ? {} : { GEMINI_API_KEY: credentials.apiKey },
|
|
97
95
|
};
|
|
@@ -145,7 +143,7 @@ function model(name, label, effortLevels, defaultEffort) {
|
|
|
145
143
|
async function requireAgyVersion(launch) {
|
|
146
144
|
const required = MIN_AGY_VERSION.join(".");
|
|
147
145
|
const output = await new Promise((resolve, reject) => {
|
|
148
|
-
|
|
146
|
+
execFileHidden(launch.command, ["--version"], { env: { ...process.env, ...launch.env }, timeout: VERSION_TIMEOUT_MS }, (error, stdout) => (error === null ? resolve(stdout) : reject(error)));
|
|
149
147
|
}).catch((error) => {
|
|
150
148
|
throw new Error(error.code === "ENOENT"
|
|
151
149
|
? `Antigravity's agy command was not found. Install Antigravity ${required} or newer and sign in to agy.`
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"antigravityAgent.js","sourceRoot":"","sources":["../../../sources/vendors/foreignAgents/antigravityAgent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"antigravityAgent.js","sourceRoot":"","sources":["../../../sources/vendors/foreignAgents/antigravityAgent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAK9D,OAAO,EAAE,oBAAoB,EAAE,MAAM,iDAAiD,CAAC;AACvF,OAAO,EACH,eAAe,EACf,kBAAkB,EAClB,qBAAqB,GAGxB,MAAM,yCAAyC,CAAC;AAEjD,MAAM,KAAK,GAAG,CAAC,KAAK,EAAE,QAAQ,EAAE,MAAM,CAAU,CAAC;AACjD,mFAAmF;AACnF,MAAM,eAAe,GAAsC;IACvD,SAAS;IACT,KAAK;IACL,QAAQ;IACR,MAAM;IACN,OAAO;IACP,KAAK;CACR,CAAC;AAEF,mGAAmG;AACnG,MAAM,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C,CAAC;IACH,MAAM,KAAK,GAAG,sBAAsB,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IAClD,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;QACjB,MAAM,IAAI,KAAK,CAAC,yDAAyD,MAAM,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IAChG,CAAC;IACD,MAAM,OAAO,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;IAC9C,KAAK,MAAM,CAAC,KAAK,EAAE,IAAI,CAAC,IAAI,OAAO,CAAC,OAAO,EAAE,EAAE,CAAC;QAC5C,MAAM,OAAO,GAAG,eAAe,CAAC,KAAK,CAAE,CAAC;QACxC,IAAI,IAAI,GAAG,OAAO;YAAE,OAAO;QAC3B,IAAI,IAAI,GAAG,OAAO,EAAE,CAAC;YACjB,MAAM,IAAI,KAAK,CACX,iCAAiC,QAAQ,kBAAkB,KAAK,CAAC,CAAC,CAAC,kDAAkD,CACxH,CAAC;QACN,CAAC;IACL,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type * as acp from "@agentclientprotocol/sdk";
|
|
2
|
+
import type { AcpConnect } from "../../protocol/acp/AcpConnection.js";
|
|
3
|
+
import type { AcpAgentLaunch } from "../../protocol/acp/AcpProvider.js";
|
|
4
|
+
/**
|
|
5
|
+
* Start `agy acp` as an agent with none of agy's own tools but web search, working only through
|
|
6
|
+
* Happy's bridged tools, so Happy's sandbox and reviewer decide everything it does.
|
|
7
|
+
*
|
|
8
|
+
* Each connection writes a custom agent file into a private folder of its own, outside the
|
|
9
|
+
* project, and starts agy with `--agent` naming it and `--add-dir` adding the folder. agy reads
|
|
10
|
+
* the file when a session opens; the file names Happy's MCP server with the session's URL and
|
|
11
|
+
* token, because agy refuses an ACP-passed server its agent file does not name and expands no
|
|
12
|
+
* variables there. An agent file agy cannot load makes it log that and fall back to its default
|
|
13
|
+
* agent, with every tool of its own, so the session fails instead. Anything agy still asks about
|
|
14
|
+
* other than a Happy tool call is refused without asking anyone.
|
|
15
|
+
*/
|
|
16
|
+
export declare function antigravityHappyOnly(launch: AcpAgentLaunch): AcpConnect;
|
|
17
|
+
/** The custom agent file: agy's tools reduced to web search, and Happy's MCP server allowed. */
|
|
18
|
+
export declare function agentMarkdown(name: string, servers: readonly acp.McpServer[]): string;
|
|
19
|
+
//# sourceMappingURL=antigravityHappyOnly.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"antigravityHappyOnly.d.ts","sourceRoot":"","sources":["../../../sources/vendors/foreignAgents/antigravityHappyOnly.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,KAAK,GAAG,MAAM,0BAA0B,CAAC;AAErD,OAAO,KAAK,EAAE,UAAU,EAAiB,MAAM,iCAAiC,CAAC;AACjF,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AA4BpE;;;;;;;;;;;GAWG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,cAAc,GAAG,UAAU,CAwEvE;AAED,gGAAgG;AAChG,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,SAAS,GAAG,CAAC,SAAS,EAAE,GAAG,MAAM,CAyBrF"}
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import { randomBytes } from "node:crypto";
|
|
2
|
+
import { mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs";
|
|
3
|
+
import { tmpdir } from "node:os";
|
|
4
|
+
import { join } from "node:path";
|
|
5
|
+
import { acpConnectionSpawn } from "../../protocol/acp/impl/acpConnectionSpawn.js";
|
|
6
|
+
import { ACP_BRIDGE_NAME, acpBridgedCallOfAsk } from "../../protocol/acp/impl/acpResponseEvents.js";
|
|
7
|
+
/** agy's own tools the agent keeps: web search, which reads nothing on this machine. */
|
|
8
|
+
const AGY_TOOLS = ["search_web"];
|
|
9
|
+
/**
|
|
10
|
+
* The agent file's system prompt, ahead of what agy still adds itself (the person's OS, the MCP
|
|
11
|
+
* server list, artifacts, its behavioral guidelines and communication style). Happy's own
|
|
12
|
+
* instructions and its tool guide follow at the end, in the session's `_meta`.
|
|
13
|
+
*/
|
|
14
|
+
const AGENT_PROMPT = `# Happy
|
|
15
|
+
|
|
16
|
+
You are working as an agent inside Happy. Happy owns this conversation, its tools, its sandbox and its permission review.
|
|
17
|
+
|
|
18
|
+
You have no file, terminal, browser or sub-agent tools of your own. Every action goes through the tools of the MCP server named "${ACP_BRIDGE_NAME}": read and change files with its Read, Write, Edit, Glob and Grep, run commands with its Bash, and start sub-agents with its create_agent or create_subtask. Call a ${ACP_BRIDGE_NAME} tool with call_mcp_tool, ServerName "${ACP_BRIDGE_NAME}", ToolName the tool's name and Arguments its arguments; one listed among your functions as mcp_${ACP_BRIDGE_NAME}_<name> may be called by that name instead. <happy-tools> at the end of these instructions describes the tools and their parameters, and call_tool with only a tool's name describes any other. Never read MCP tool schema files.
|
|
19
|
+
|
|
20
|
+
Happy runs every call in its sandbox under the conversation's permission mode and may review it first. A refused call comes back as an error saying why: take a materially safer route or stop and explain, and never pursue the same outcome another way. When a command genuinely needs to reach outside the sandbox, request that with the tool's own escalation argument as its description explains.
|
|
21
|
+
|
|
22
|
+
Search the web with search_web.
|
|
23
|
+
|
|
24
|
+
Text wrapped in <system-reminder> comes from Happy, not from the person. <agent-message> is a message from another agent, and <happy-tool-result> is the late result of a Happy tool call.
|
|
25
|
+
`;
|
|
26
|
+
/** What agy logs when the agent it was started with cannot be loaded, before using its own. */
|
|
27
|
+
const fallbackLine = (name) => `Agent "${name}" not found`;
|
|
28
|
+
/**
|
|
29
|
+
* Start `agy acp` as an agent with none of agy's own tools but web search, working only through
|
|
30
|
+
* Happy's bridged tools, so Happy's sandbox and reviewer decide everything it does.
|
|
31
|
+
*
|
|
32
|
+
* Each connection writes a custom agent file into a private folder of its own, outside the
|
|
33
|
+
* project, and starts agy with `--agent` naming it and `--add-dir` adding the folder. agy reads
|
|
34
|
+
* the file when a session opens; the file names Happy's MCP server with the session's URL and
|
|
35
|
+
* token, because agy refuses an ACP-passed server its agent file does not name and expands no
|
|
36
|
+
* variables there. An agent file agy cannot load makes it log that and fall back to its default
|
|
37
|
+
* agent, with every tool of its own, so the session fails instead. Anything agy still asks about
|
|
38
|
+
* other than a Happy tool call is refused without asking anyone.
|
|
39
|
+
*/
|
|
40
|
+
export function antigravityHappyOnly(launch) {
|
|
41
|
+
return async (cwd, client) => {
|
|
42
|
+
const directory = mkdtempSync(join(tmpdir(), "happy-agy-"));
|
|
43
|
+
const name = `happy-${randomBytes(6).toString("hex")}`;
|
|
44
|
+
const agentFile = join(directory, ".agents", "agents", name, "agent.md");
|
|
45
|
+
const logFile = join(directory, "agy.log");
|
|
46
|
+
let connection;
|
|
47
|
+
try {
|
|
48
|
+
connection = await acpConnectionSpawn({
|
|
49
|
+
...launch,
|
|
50
|
+
args: [
|
|
51
|
+
...(launch.args ?? []),
|
|
52
|
+
"--agent",
|
|
53
|
+
name,
|
|
54
|
+
"--add-dir",
|
|
55
|
+
directory,
|
|
56
|
+
"--log-file",
|
|
57
|
+
logFile,
|
|
58
|
+
],
|
|
59
|
+
}, cwd, {
|
|
60
|
+
...client,
|
|
61
|
+
requestPermission: async (params) => acpBridgedCallOfAsk(params.toolCall, undefined) === undefined
|
|
62
|
+
? refuse(params)
|
|
63
|
+
: await client.requestPermission(params),
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
catch (error) {
|
|
67
|
+
rmSync(directory, { recursive: true, force: true });
|
|
68
|
+
throw error;
|
|
69
|
+
}
|
|
70
|
+
// The agent file holds the bridge's token, so the whole private folder goes with agy.
|
|
71
|
+
void connection.exited.then(() => rmSync(directory, { recursive: true, force: true }));
|
|
72
|
+
const open = async (params, request) => {
|
|
73
|
+
mkdirSync(join(agentFile, ".."), { recursive: true, mode: 0o700 });
|
|
74
|
+
writeFileSync(agentFile, agentMarkdown(name, params.mcpServers), { mode: 0o600 });
|
|
75
|
+
const response = await request();
|
|
76
|
+
let log;
|
|
77
|
+
try {
|
|
78
|
+
log = readFileSync(logFile, "utf8");
|
|
79
|
+
}
|
|
80
|
+
catch {
|
|
81
|
+
log = "";
|
|
82
|
+
}
|
|
83
|
+
if (log.length === 0 || log.includes(fallbackLine(name))) {
|
|
84
|
+
connection.terminate();
|
|
85
|
+
throw new Error("Antigravity did not load Happy's agent and would have used its own tools instead, so the session was stopped.");
|
|
86
|
+
}
|
|
87
|
+
return response;
|
|
88
|
+
};
|
|
89
|
+
const conn = connection.conn;
|
|
90
|
+
return {
|
|
91
|
+
...connection,
|
|
92
|
+
conn: Object.assign(Object.create(conn), {
|
|
93
|
+
newSession: async (params) => await open(params, () => conn.newSession(params)),
|
|
94
|
+
loadSession: async (params) => await open(params, () => conn.loadSession(params)),
|
|
95
|
+
resumeSession: async (params) => await open(params, () => conn.resumeSession(params)),
|
|
96
|
+
}),
|
|
97
|
+
};
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
/** The custom agent file: agy's tools reduced to web search, and Happy's MCP server allowed. */
|
|
101
|
+
export function agentMarkdown(name, servers) {
|
|
102
|
+
const happy = servers.find((server) => "type" in server && server.type === "http" && server.name === ACP_BRIDGE_NAME);
|
|
103
|
+
const lines = [
|
|
104
|
+
"---",
|
|
105
|
+
`name: ${name}`,
|
|
106
|
+
"description: Works only through Happy's tools.",
|
|
107
|
+
"mainAgent: true",
|
|
108
|
+
"subagent: false",
|
|
109
|
+
"inheritMcp: false",
|
|
110
|
+
...(happy === undefined
|
|
111
|
+
? []
|
|
112
|
+
: [
|
|
113
|
+
"mcpServers:",
|
|
114
|
+
` - name: ${ACP_BRIDGE_NAME}`,
|
|
115
|
+
` serverUrl: ${JSON.stringify(happy.url)}`,
|
|
116
|
+
` headers: ${JSON.stringify(Object.fromEntries(happy.headers.map((header) => [header.name, header.value])))}`,
|
|
117
|
+
]),
|
|
118
|
+
`tools: [${AGY_TOOLS.join(", ")}]`,
|
|
119
|
+
"---",
|
|
120
|
+
AGENT_PROMPT,
|
|
121
|
+
];
|
|
122
|
+
return lines.join("\n");
|
|
123
|
+
}
|
|
124
|
+
/** Refuse an ask, as agy's own tools never act for a Happy agent. */
|
|
125
|
+
function refuse(params) {
|
|
126
|
+
const option = params.options.find((candidate) => candidate.kind === "reject_once" || candidate.kind === "reject_always");
|
|
127
|
+
return option === undefined
|
|
128
|
+
? { outcome: { outcome: "cancelled" } }
|
|
129
|
+
: { outcome: { outcome: "selected", optionId: option.optionId } };
|
|
130
|
+
}
|
|
131
|
+
//# sourceMappingURL=antigravityHappyOnly.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"antigravityHappyOnly.js","sourceRoot":"","sources":["../../../sources/vendors/foreignAgents/antigravityHappyOnly.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACtF,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACjC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAMjC,OAAO,EAAE,kBAAkB,EAAE,MAAM,2CAA2C,CAAC;AAC/E,OAAO,EAAE,eAAe,EAAE,mBAAmB,EAAE,MAAM,0CAA0C,CAAC;AAEhG,wFAAwF;AACxF,MAAM,SAAS,GAAG,CAAC,YAAY,CAAU,CAAC;AAE1C;;;;GAIG;AACH,MAAM,YAAY,GAAG;;;;mIAI8G,eAAe,wKAAwK,eAAe,yCAAyC,eAAe,mGAAmG,eAAe;;;;;;;CAOlf,CAAC;AAEF,+FAA+F;AAC/F,MAAM,YAAY,GAAG,CAAC,IAAY,EAAU,EAAE,CAAC,UAAU,IAAI,aAAa,CAAC;AAE3E;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,oBAAo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