@agentproto/corpus-cli 0.1.0-alpha.5 → 0.1.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/dist/cli.mjs +59 -1
- package/dist/cli.mjs.map +1 -1
- package/dist/ports/index.d.ts +16 -2
- package/dist/ports/index.mjs +59 -1
- package/dist/ports/index.mjs.map +1 -1
- package/dist/specs/resources/aip-52/draft/ADAPTER.md +193 -0
- package/package.json +3 -3
package/dist/ports/index.d.ts
CHANGED
|
@@ -410,8 +410,22 @@ declare class AnthropicDistiller implements DistillPort {
|
|
|
410
410
|
* cost. Same DistillPort contract + same prompt/parse, swappable transport.
|
|
411
411
|
*
|
|
412
412
|
* Engines register full descriptors and are dispatched by id (no `engineId ===`
|
|
413
|
-
* branching at the call site). Add a CLI by adding a descriptor below
|
|
414
|
-
*
|
|
413
|
+
* branching at the call site). Add a CLI by adding a descriptor below.
|
|
414
|
+
*
|
|
415
|
+
* Two output shapes are covered:
|
|
416
|
+
* - **JSON-envelope** (claude-code) — `--output-format json` wraps the answer;
|
|
417
|
+
* `parseClaudeJsonOutput` unwraps `{ result }`.
|
|
418
|
+
* - **plain-text** (gemini / codex / opencode) — the CLI prints the answer
|
|
419
|
+
* straight to stdout; `plainTextOutput` only strips ANSI, and the tolerant
|
|
420
|
+
* `parseItems` grabs the `[…]` JSON array out of the text.
|
|
421
|
+
*
|
|
422
|
+
* NOTE on verification: claude-code's flags are verified against `claude -p
|
|
423
|
+
* --help`. The other three use each CLI's *first-party non-interactive* print
|
|
424
|
+
* mode (`gemini` piped stdin · `codex exec -` · `opencode run`), distinct from
|
|
425
|
+
* the ACP wrappers `@agentproto/adapter-*` use for streaming/tool sessions. They
|
|
426
|
+
* read the prompt from stdin and print plain text — the right fit for one-shot
|
|
427
|
+
* distill with no adapter dependency. Confirm the exact flags against each CLI's
|
|
428
|
+
* `--help` on the host before relying on them; they are easy to tweak here.
|
|
415
429
|
*/
|
|
416
430
|
/** What a CLI engine needs to drive one stdin→stdout completion. */
|
|
417
431
|
interface CliEngine {
|
package/dist/ports/index.mjs
CHANGED
|
@@ -828,6 +828,32 @@ var CliAgentDistiller = class {
|
|
|
828
828
|
return parseItems(text);
|
|
829
829
|
}
|
|
830
830
|
};
|
|
831
|
+
var ANSI = new RegExp(String.fromCharCode(27) + "\\[[0-9;]*m", "g");
|
|
832
|
+
function plainTextOutput(stdout) {
|
|
833
|
+
return stdout.replace(ANSI, "");
|
|
834
|
+
}
|
|
835
|
+
function parseCodexJsonl(stdout) {
|
|
836
|
+
let found = null;
|
|
837
|
+
for (const line of stdout.split("\n")) {
|
|
838
|
+
const trimmed = line.trim();
|
|
839
|
+
if (!trimmed.startsWith("{")) continue;
|
|
840
|
+
let evt;
|
|
841
|
+
try {
|
|
842
|
+
evt = JSON.parse(trimmed);
|
|
843
|
+
} catch {
|
|
844
|
+
continue;
|
|
845
|
+
}
|
|
846
|
+
if (!evt || typeof evt !== "object") continue;
|
|
847
|
+
const e = evt;
|
|
848
|
+
const item = e.item;
|
|
849
|
+
if (item?.type === "agent_message" && typeof item.text === "string") {
|
|
850
|
+
found = item.text;
|
|
851
|
+
} else if (e.type === "agent_message" && typeof e.message === "string") {
|
|
852
|
+
found = e.message;
|
|
853
|
+
}
|
|
854
|
+
}
|
|
855
|
+
return found;
|
|
856
|
+
}
|
|
831
857
|
var CLAUDE_CODE = {
|
|
832
858
|
id: "claude-code",
|
|
833
859
|
subscriptionBilled: true,
|
|
@@ -841,8 +867,38 @@ var CLAUDE_CODE = {
|
|
|
841
867
|
],
|
|
842
868
|
parseOutput: parseClaudeJsonOutput
|
|
843
869
|
};
|
|
870
|
+
var GEMINI = {
|
|
871
|
+
id: "gemini",
|
|
872
|
+
subscriptionBilled: true,
|
|
873
|
+
command: "gemini",
|
|
874
|
+
buildArgs: ({ model }) => [...model ? ["-m", model] : []],
|
|
875
|
+
parseOutput: plainTextOutput
|
|
876
|
+
};
|
|
877
|
+
var CODEX = {
|
|
878
|
+
id: "codex",
|
|
879
|
+
subscriptionBilled: true,
|
|
880
|
+
command: "codex",
|
|
881
|
+
buildArgs: ({ model }) => [
|
|
882
|
+
"exec",
|
|
883
|
+
"--skip-git-repo-check",
|
|
884
|
+
"--json",
|
|
885
|
+
...model ? ["-m", model] : [],
|
|
886
|
+
"-"
|
|
887
|
+
],
|
|
888
|
+
parseOutput: parseCodexJsonl
|
|
889
|
+
};
|
|
890
|
+
var OPENCODE = {
|
|
891
|
+
id: "opencode",
|
|
892
|
+
subscriptionBilled: false,
|
|
893
|
+
command: "opencode",
|
|
894
|
+
buildArgs: ({ model }) => ["run", ...model ? ["-m", model] : []],
|
|
895
|
+
parseOutput: plainTextOutput
|
|
896
|
+
};
|
|
844
897
|
var CLI_ENGINES = {
|
|
845
|
-
[CLAUDE_CODE.id]: CLAUDE_CODE
|
|
898
|
+
[CLAUDE_CODE.id]: CLAUDE_CODE,
|
|
899
|
+
[GEMINI.id]: GEMINI,
|
|
900
|
+
[CODEX.id]: CODEX,
|
|
901
|
+
[OPENCODE.id]: OPENCODE
|
|
846
902
|
};
|
|
847
903
|
var RPC_RESPONSE = z.object({ result: z.unknown().optional(), error: z.unknown().optional() }).loose();
|
|
848
904
|
var RPC_MESSAGE = z.object({
|
|
@@ -924,6 +980,7 @@ var SseMcpClient = class {
|
|
|
924
980
|
this.opts = opts;
|
|
925
981
|
this.base = new URL(opts.endpoint);
|
|
926
982
|
}
|
|
983
|
+
opts;
|
|
927
984
|
id = 0;
|
|
928
985
|
messagesUrl;
|
|
929
986
|
pending = /* @__PURE__ */ new Map();
|
|
@@ -1051,6 +1108,7 @@ var McpSink = class {
|
|
|
1051
1108
|
this.config = config;
|
|
1052
1109
|
this.client = client;
|
|
1053
1110
|
}
|
|
1111
|
+
config;
|
|
1054
1112
|
client;
|
|
1055
1113
|
async ensure() {
|
|
1056
1114
|
if (!this.client) {
|