impel-cli 0.19.3 → 0.20.0-beta.0
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/README.md +55 -0
- package/package.json +6 -5
- package/src/agents.js +186 -11
- package/src/apps.js +102 -10
- package/src/cliProfiles.js +47 -8
- package/src/commands/launch.js +11 -2
- package/src/commands/mcp.js +201 -17
- package/src/commands/remote.js +166 -36
- package/src/directAnswer.js +59 -0
- package/src/selfInvocation.js +27 -0
- package/src/verbatimRelay.js +64 -0
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Catalog opt-in for Impel MCP `answer_native_agent`.
|
|
3
|
+
*
|
|
4
|
+
* When `directAnswer` is true, managed Claude/Codex adapters call that one-shot
|
|
5
|
+
* tool (Impel auth → Eve `/eve/v1/answer`) and return forUser/answer instead of
|
|
6
|
+
* list → start → poll. Distinct from agent-internal retrieve shortcuts.
|
|
7
|
+
*
|
|
8
|
+
* Does not replace the verbatimRelay description / fork_turns override: when an
|
|
9
|
+
* agent also sets verbatimRelay, keep that marker and spawn guidance so parents
|
|
10
|
+
* still use fork_turns="none" and relay the adapter result verbatim.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
import {
|
|
14
|
+
VERBATIM_FINAL_TEXT_CONSTRAINTS,
|
|
15
|
+
} from "./verbatimRelay.js";
|
|
16
|
+
|
|
17
|
+
export function usesDirectAnswer(agent) {
|
|
18
|
+
return agent?.directAnswer === true;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export function extractAnswerFinalText(payload) {
|
|
22
|
+
if (!payload || typeof payload !== "object" || Array.isArray(payload)) return null;
|
|
23
|
+
for (const key of ["forUser", "answer"]) {
|
|
24
|
+
const text = payload[key];
|
|
25
|
+
if (typeof text === "string" && text.trim()) return text;
|
|
26
|
+
}
|
|
27
|
+
return null;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export function claudeAnswerHardCompletionGuidance() {
|
|
31
|
+
return (
|
|
32
|
+
`When it succeeds, return forUser if present, otherwise answer, exactly with ${VERBATIM_FINAL_TEXT_CONSTRAINTS}. ` +
|
|
33
|
+
"When it fails, return the tool error without inventing a replacement result. " +
|
|
34
|
+
"Never invent or independently synthesize a replacement result."
|
|
35
|
+
);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export function claudeAnswerSoftCompletionGuidance() {
|
|
39
|
+
return (
|
|
40
|
+
"When it succeeds, return forUser if present, otherwise answer, faithfully as the answer. " +
|
|
41
|
+
"When it fails, return the tool error without inventing a replacement result. " +
|
|
42
|
+
"Never invent or independently synthesize a replacement result."
|
|
43
|
+
);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export function adapterAnswerHardCompletionGuidance() {
|
|
47
|
+
return (
|
|
48
|
+
`After the orchestration completes, return its single text output verbatim with ${VERBATIM_FINAL_TEXT_CONSTRAINTS}. ` +
|
|
49
|
+
"A successful output is forUser (else answer) exactly. A failure output preserves the error payload."
|
|
50
|
+
);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export function adapterAnswerSoftCompletionGuidance() {
|
|
54
|
+
return (
|
|
55
|
+
"After the orchestration completes, return its single text output as the answer. " +
|
|
56
|
+
"A successful output is forUser (else answer). A failure output preserves the error payload. " +
|
|
57
|
+
"Never invent or independently synthesize a replacement result."
|
|
58
|
+
);
|
|
59
|
+
}
|
package/src/selfInvocation.js
CHANGED
|
@@ -65,6 +65,7 @@ export function impelCliInvocation(args = [], options = {}) {
|
|
|
65
65
|
}
|
|
66
66
|
|
|
67
67
|
export const IMPEL_MANAGED_MCP_ENV = brandedEnvironmentName("MANAGED_MCP");
|
|
68
|
+
export const IMPEL_TASKS_MCP_SERVER_NAME = `${RUNTIME_BRAND.cli.providerId}-tasks`;
|
|
68
69
|
|
|
69
70
|
export function impelMcpInvocation(args = [], options = {}) {
|
|
70
71
|
return {
|
|
@@ -73,3 +74,29 @@ export function impelMcpInvocation(args = [], options = {}) {
|
|
|
73
74
|
env: { [IMPEL_MANAGED_MCP_ENV]: "1" },
|
|
74
75
|
};
|
|
75
76
|
}
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* The tenant-bound Tasks MCP process launched by managed Claude/Codex hosts.
|
|
80
|
+
* The PAT remains in Impel's private config and is read by the child process;
|
|
81
|
+
* it must never be baked into this invocation or a vendor profile.
|
|
82
|
+
*/
|
|
83
|
+
export function impelTasksMcpInvocation(tenantId, options = {}) {
|
|
84
|
+
if (typeof tenantId !== "string" || !tenantId.trim()) {
|
|
85
|
+
throw new Error("a tenant is required for the managed Tasks MCP invocation");
|
|
86
|
+
}
|
|
87
|
+
return impelMcpInvocation(["--target", "tasks", "--tenant", tenantId], options);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/** Recognize only the marker-bearing Tasks invocation that impel-cli owns. */
|
|
91
|
+
export function isImpelTasksMcpInvocation(value) {
|
|
92
|
+
if (!value || typeof value !== "object" || !Array.isArray(value.args)) return false;
|
|
93
|
+
const suffix = value.args.slice(-5);
|
|
94
|
+
return value.type === "stdio"
|
|
95
|
+
&& value.env?.[IMPEL_MANAGED_MCP_ENV] === "1"
|
|
96
|
+
&& suffix[0] === "mcp"
|
|
97
|
+
&& suffix[1] === "--target"
|
|
98
|
+
&& suffix[2] === "tasks"
|
|
99
|
+
&& suffix[3] === "--tenant"
|
|
100
|
+
&& typeof suffix[4] === "string"
|
|
101
|
+
&& suffix[4].length > 0;
|
|
102
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
export const VERBATIM_RELAY_OPT_IN_MARKER = "verbatimRelay enabled";
|
|
2
|
+
|
|
3
|
+
export const VERBATIM_SPAWN_REQUIREMENT = 'fork_turns="none"';
|
|
4
|
+
|
|
5
|
+
export const VERBATIM_FINAL_TEXT_CONSTRAINTS =
|
|
6
|
+
"no preface, rewriting, Markdown changes, or independent synthesis";
|
|
7
|
+
|
|
8
|
+
export function usesVerbatimRelay(agent) {
|
|
9
|
+
return agent?.verbatimRelay === true;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export function parentVerbatimRelayAppendix() {
|
|
13
|
+
return (
|
|
14
|
+
`When an explicit custom agent's catalog-derived description declares ${VERBATIM_RELAY_OPT_IN_MARKER}, ` +
|
|
15
|
+
`spawn it with ${VERBATIM_SPAWN_REQUIREMENT} and relay its finalText verbatim with ${VERBATIM_FINAL_TEXT_CONSTRAINTS}; ` +
|
|
16
|
+
"preserve Sources sections and citations exactly. " +
|
|
17
|
+
"Custom agents without that declaration keep the default delegation behavior."
|
|
18
|
+
);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export function customAgentVerbatimDescriptionLead() {
|
|
22
|
+
return (
|
|
23
|
+
`Explicit custom agent with ${VERBATIM_RELAY_OPT_IN_MARKER}: ` +
|
|
24
|
+
`callers must use ${VERBATIM_SPAWN_REQUIREMENT} and relay its result verbatim`
|
|
25
|
+
);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export function adapterCallerSpawnGuidance(clientLabel) {
|
|
29
|
+
return (
|
|
30
|
+
`Callers must spawn this explicit custom ${clientLabel} agent with ${VERBATIM_SPAWN_REQUIREMENT} ` +
|
|
31
|
+
"and must relay your result verbatim; this is caller guidance and cannot enforce host spawn behavior."
|
|
32
|
+
);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export function adapterHardCompletionGuidance() {
|
|
36
|
+
return (
|
|
37
|
+
`After the orchestration completes, return its single text output verbatim with ${VERBATIM_FINAL_TEXT_CONSTRAINTS}. ` +
|
|
38
|
+
"A successful output is result.finalText exactly. A failure output preserves the durable runId, output, and error."
|
|
39
|
+
);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export function adapterSoftCompletionGuidance() {
|
|
43
|
+
return (
|
|
44
|
+
"After the orchestration completes, return its single text output as the answer. " +
|
|
45
|
+
"A successful output is result.finalText. A failure output preserves the durable runId, output, and error. " +
|
|
46
|
+
"Never invent or independently synthesize a replacement result."
|
|
47
|
+
);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export function claudeHardCompletionGuidance() {
|
|
51
|
+
return (
|
|
52
|
+
`When it succeeds, return result.finalText exactly with ${VERBATIM_FINAL_TEXT_CONSTRAINTS}. ` +
|
|
53
|
+
"When it fails, return the durable runId, preserved output, and error. " +
|
|
54
|
+
"Never invent or independently synthesize a replacement result."
|
|
55
|
+
);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export function claudeSoftCompletionGuidance() {
|
|
59
|
+
return (
|
|
60
|
+
"When it succeeds, return result.finalText faithfully as the answer. " +
|
|
61
|
+
"When it fails, return the durable runId, preserved output, and error. " +
|
|
62
|
+
"Never invent or independently synthesize a replacement result."
|
|
63
|
+
);
|
|
64
|
+
}
|