@niwa-labs/harness-mcode 0.0.0-stage → 0.0.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.
@@ -0,0 +1,91 @@
1
+ /**
2
+ * The ACP dialect of the published MiniMax Code (`@minimax-ai/code` 0.7.1, `mcode acp`), over the
3
+ * official ACP snapshot it serves (`@agentclientprotocol/sdk` 1.3.0, generated).
4
+ *
5
+ * Hand-written, since MiniMax Code publishes no schema for its extensions, from its bundle
6
+ * (`chunks/run-acp-command-*.js`): the extension advertisement in the `initialize` reply, the
7
+ * extension methods and notifications, the `set_mode` transition. Only what upstream sends is
8
+ * here; what the owner's fork adds is `../ncode/protocol.ts`, which this file never reads.
9
+ */
10
+
11
+ import { z } from "zod";
12
+
13
+ import { Acp13 as Acp } from "@niwa-labs/acp";
14
+ import { ProtocolNameSchema } from "@niwa-labs/harness";
15
+
16
+ export { Acp };
17
+
18
+ /** The name niwa gives this protocol in the unknowns it records. */
19
+ export const MCODE_ACP_PROTOCOL = ProtocolNameSchema.parse(`acp-${Acp.ACP_SDK_VERSION}/mcode`);
20
+
21
+ /** The `_meta` key of the extensions, in the client's capabilities and in the `initialize` reply. */
22
+ export const EXTENSIONS_META = "minimax-code/extensions";
23
+
24
+ /** What the `initialize` reply says of the extensions it serves. */
25
+ export const McodeExtensions = z.object({
26
+ version: z.number().int(),
27
+ methods: z.array(z.string()),
28
+ notifications: z.array(z.string()),
29
+ });
30
+
31
+ /** The `_meta` of the `initialize` reply. */
32
+ export const McodeInitializeMeta = z.object({ [EXTENSIONS_META]: McodeExtensions });
33
+
34
+ /** The extension methods upstream serves (the goal methods only while goals are on). */
35
+ export const MCODE_METHODS = [
36
+ "session/activate",
37
+ "mcode/session/activate",
38
+ "mcode/session/steer",
39
+ "mcode/session/queue/list",
40
+ "mcode/session/queue/enqueue",
41
+ "mcode/session/queue/update",
42
+ "mcode/session/queue/delete",
43
+ "mcode/session/queue/steer",
44
+ "mcode/session/goal/get",
45
+ "mcode/session/goal/create",
46
+ "mcode/session/goal/patch",
47
+ "mcode/session/goal/clear",
48
+ "mcode/session/delegation/get",
49
+ "mcode/session/delegation/stop",
50
+ ] as const;
51
+ export type McodeMethod = (typeof MCODE_METHODS)[number];
52
+
53
+ /** The values of the `permissionMode` config option. */
54
+ export const McodePermissionMode = z.enum(["default", "auto", "bypassPermissions"]);
55
+ export type McodePermissionMode = z.output<typeof McodePermissionMode>;
56
+
57
+ /** The extension notifications, sent to a client that opted in to them. */
58
+ const McodeExtNotification = [
59
+ z.object({
60
+ jsonrpc: z.literal("2.0").optional(),
61
+ method: z.literal("mcode/session/current_session_update"),
62
+ params: z.object({ sessionId: Acp.SessionId.nullable() }),
63
+ }),
64
+ z.object({
65
+ jsonrpc: z.literal("2.0").optional(),
66
+ method: z.literal("mcode/session/queue_update"),
67
+ params: z.object({ sessionId: Acp.SessionId, items: z.array(z.unknown()) }),
68
+ }),
69
+ z.object({
70
+ jsonrpc: z.literal("2.0").optional(),
71
+ method: z.literal("mcode/session/goal_update"),
72
+ params: z.object({ sessionId: Acp.SessionId, goal: z.unknown(), goalId: z.string().optional() }),
73
+ }),
74
+ z.object({
75
+ jsonrpc: z.literal("2.0").optional(),
76
+ method: z.literal("mcode/session/delegation_update"),
77
+ params: z.object({ sessionId: Acp.SessionId, snapshot: z.unknown() }),
78
+ }),
79
+ ] as const;
80
+
81
+ /** A notification upstream sends the client: the snapshot's own and its extensions. */
82
+ export const McodeAgentNotification = z.discriminatedUnion("method", [
83
+ ...Acp.AgentToClientNotification.options,
84
+ ...McodeExtNotification,
85
+ ]);
86
+ export type McodeAgentNotification = z.output<typeof McodeAgentNotification>;
87
+
88
+ /** A request upstream sends the client: the snapshot's own; it has none of its own. */
89
+ export const McodeAgentRequest = Acp.AgentToClientRequest;
90
+ export type McodeAgentRequest = z.output<typeof McodeAgentRequest>;
91
+