mia-code 0.2.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/.claude/settings.local.json +9 -0
- package/.coaia/pde/d77620fc-1cd9-47e2-ba00-c03e114e42e9.jsonl +16 -0
- package/.coaia/pde/de44d838-b58b-4e91-b791-dd3b0f940ed1.jsonl +60 -0
- package/.gemini/settings.json +8 -0
- package/.hch/issue_.env +4 -0
- package/.hch/issue_add__2601211715.json +77 -0
- package/.hch/issue_add__2601211715.md +4 -0
- package/.hch/issue_add__2602242020.json +78 -0
- package/.hch/issue_add__2602242020.md +7 -0
- package/.hch/issues.json +2312 -0
- package/.hch/issues.md +30 -0
- package/260123084839.coaia-narrative.autoRevisionOfInitial_NewStructuralTensionChart-to-initiate-HierarchicalThinking.txt +5 -0
- package/2602010101.issue.txt +31 -0
- package/BUGS.md +242 -0
- package/CLAUDE.md +2 -0
- package/ENHANCEMENTS.md +129 -0
- package/FEATURES_ENDING_SESSIONS.md +21 -0
- package/FIXES.md +114 -0
- package/GUILLAUME.md +77 -0
- package/KINSHIP.md +50 -0
- package/LAUNCH__session_id__MiaCodeNextWorkReviewAndCommits_2601312020.sh +7 -0
- package/PHASE_2.md +153 -0
- package/PHASE_2_IMPLEMENTATION.md +134 -0
- package/README.md +203 -0
- package/RESUME__issueMaker__540244c2-b096-40d8-8c3f-398408d3e0eb.2602041757.sh +1 -0
- package/RUN_COPILOT_with_related_folders__260130.sh +2 -0
- package/WS__mia-code__260214__IAIP_PDE.code-workspace +29 -0
- package/WS__mia-code__src332__260122.code-workspace +23 -0
- package/_env.sh +12 -0
- package/dist/cli.d.ts +11 -0
- package/dist/cli.js +679 -0
- package/dist/commands.d.ts +43 -0
- package/dist/commands.js +108 -0
- package/dist/config.d.ts +8 -0
- package/dist/config.js +57 -0
- package/dist/formatting.d.ts +12 -0
- package/dist/formatting.js +133 -0
- package/dist/geminiHeadless.d.ts +25 -0
- package/dist/geminiHeadless.js +246 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +186 -0
- package/dist/mcp/config-generator.d.ts +23 -0
- package/dist/mcp/config-generator.js +116 -0
- package/dist/mcp/index.d.ts +18 -0
- package/dist/mcp/index.js +43 -0
- package/dist/mcp/miaco-server.d.ts +15 -0
- package/dist/mcp/miaco-server.js +161 -0
- package/dist/mcp/miatel-server.d.ts +15 -0
- package/dist/mcp/miatel-server.js +123 -0
- package/dist/mcp/miawa-server.d.ts +15 -0
- package/dist/mcp/miawa-server.js +125 -0
- package/dist/mcp/utils.d.ts +51 -0
- package/dist/mcp/utils.js +76 -0
- package/dist/multiline-input.d.ts +98 -0
- package/dist/multiline-input.js +630 -0
- package/dist/narrative/index.d.ts +9 -0
- package/dist/narrative/index.js +11 -0
- package/dist/narrative/router.d.ts +89 -0
- package/dist/narrative/router.js +186 -0
- package/dist/narrative/tracer.d.ts +75 -0
- package/dist/narrative/tracer.js +180 -0
- package/dist/sessionStore.d.ts +10 -0
- package/dist/sessionStore.js +93 -0
- package/dist/types.d.ts +44 -0
- package/dist/types.js +1 -0
- package/dist/unifier.d.ts +6 -0
- package/dist/unifier.js +147 -0
- package/issue-358--architecture/ARCHITECTURE_OVERVIEW.md +60 -0
- package/issue-358--architecture/CLI_INTEGRATION.md +61 -0
- package/issue-358--architecture/COVER_ART_BRIEF.md +68 -0
- package/issue-358--architecture/MEMORY_SYSTEM.md +89 -0
- package/issue-358--architecture/PERSONA_REGISTRY.md +97 -0
- package/issue-358--architecture/PODCAST_PRODUCTION_PLAN.md +61 -0
- package/issue-358--architecture/PODCAST_SCRIPT_FINAL.md +109 -0
- package/issue-358--architecture/PROTOTYPE_CHARACTER_SPEC.md +59 -0
- package/issue-358--architecture/RESOURCES.md +41 -0
- package/issue-358--architecture/TEAM_LISTENING_GUIDE.md +53 -0
- package/llms-gemini-cli.txt +145 -0
- package/package.json +39 -0
- package/samples/copilot/session-state/be76abaa-a27f-4725-b2a9-22fb45f7e0f7/checkpoints/index.md +6 -0
- package/samples/copilot/session-state/be76abaa-a27f-4725-b2a9-22fb45f7e0f7/events.jsonl +213 -0
- package/samples/copilot/session-state/be76abaa-a27f-4725-b2a9-22fb45f7e0f7/plan.md +243 -0
- package/samples/copilot/session-state/be76abaa-a27f-4725-b2a9-22fb45f7e0f7/workspace.yaml +5 -0
- package/src/cli.ts +742 -0
- package/src/commands.ts +127 -0
- package/src/config.ts +67 -0
- package/src/formatting.ts +157 -0
- package/src/geminiHeadless.ts +300 -0
- package/src/index.ts +194 -0
- package/src/mcp/config-generator.ts +141 -0
- package/src/mcp/index.ts +55 -0
- package/src/mcp/miaco-server.ts +199 -0
- package/src/mcp/miatel-server.ts +138 -0
- package/src/mcp/miawa-server.ts +158 -0
- package/src/mcp/utils.ts +121 -0
- package/src/multiline-input.ts +739 -0
- package/src/narrative/index.ts +33 -0
- package/src/narrative/router.ts +260 -0
- package/src/narrative/tracer.ts +249 -0
- package/src/sessionStore.ts +111 -0
- package/src/types.ts +49 -0
- package/src/unifier.ts +171 -0
- package/tsconfig.json +15 -0
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MCP Server for miatel - Story World CLI
|
|
3
|
+
*
|
|
4
|
+
* Exposes beat/arc/theme tools as MCP tools
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { runCLI, parseJSONOutput, createToolResult, buildArgs, MCPTool, MCPToolResult } from "./utils.js";
|
|
8
|
+
import { dirname, join } from "path";
|
|
9
|
+
import { fileURLToPath } from "url";
|
|
10
|
+
|
|
11
|
+
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
12
|
+
const CLI_PATH = join(__dirname, "../../miatel/dist/index.js");
|
|
13
|
+
|
|
14
|
+
export const miatelTools: MCPTool[] = [
|
|
15
|
+
{
|
|
16
|
+
name: "miatel_beat_create",
|
|
17
|
+
description: "Create a story beat in the narrative intelligence system",
|
|
18
|
+
inputSchema: {
|
|
19
|
+
type: "object",
|
|
20
|
+
properties: {
|
|
21
|
+
text: { type: "string", description: "Story beat content" },
|
|
22
|
+
character: { type: "string", description: "Character ID" },
|
|
23
|
+
tone: {
|
|
24
|
+
type: "string",
|
|
25
|
+
description: "Emotional tone",
|
|
26
|
+
enum: ["joy", "fear", "anticipation", "surprise", "sadness", "anger", "disgust", "trust", "neutral"]
|
|
27
|
+
},
|
|
28
|
+
phase: {
|
|
29
|
+
type: "string",
|
|
30
|
+
description: "Narrative phase",
|
|
31
|
+
enum: ["setup", "confrontation", "resolution", "unspecified"]
|
|
32
|
+
},
|
|
33
|
+
session: { type: "string", description: "Session ID" }
|
|
34
|
+
},
|
|
35
|
+
required: ["text"]
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
name: "miatel_beat_list",
|
|
40
|
+
description: "List story beats in current session",
|
|
41
|
+
inputSchema: {
|
|
42
|
+
type: "object",
|
|
43
|
+
properties: {
|
|
44
|
+
limit: { type: "string", description: "Maximum number of results" },
|
|
45
|
+
character: { type: "string", description: "Filter by character ID" },
|
|
46
|
+
session: { type: "string", description: "Session ID" }
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
name: "miatel_beat_analyze",
|
|
52
|
+
description: "Analyze a specific story beat",
|
|
53
|
+
inputSchema: {
|
|
54
|
+
type: "object",
|
|
55
|
+
properties: {
|
|
56
|
+
beatId: { type: "string", description: "Beat ID to analyze" },
|
|
57
|
+
universe: {
|
|
58
|
+
type: "string",
|
|
59
|
+
description: "Universe lens for analysis",
|
|
60
|
+
enum: ["engineer", "ceremony", "story_engine", "all"]
|
|
61
|
+
},
|
|
62
|
+
session: { type: "string", description: "Session ID" }
|
|
63
|
+
},
|
|
64
|
+
required: ["beatId"]
|
|
65
|
+
}
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
name: "miatel_beat_enrich",
|
|
69
|
+
description: "Apply emotional enrichment to a beat",
|
|
70
|
+
inputSchema: {
|
|
71
|
+
type: "object",
|
|
72
|
+
properties: {
|
|
73
|
+
beatId: { type: "string", description: "Beat ID to enrich" },
|
|
74
|
+
technique: {
|
|
75
|
+
type: "string",
|
|
76
|
+
description: "Enrichment technique",
|
|
77
|
+
enum: ["sensory", "stakes", "dialogue", "auto-detect"]
|
|
78
|
+
},
|
|
79
|
+
session: { type: "string", description: "Session ID" }
|
|
80
|
+
},
|
|
81
|
+
required: ["beatId"]
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
];
|
|
85
|
+
|
|
86
|
+
export async function handleMiatelTool(name: string, args: Record<string, any>): Promise<MCPToolResult> {
|
|
87
|
+
try {
|
|
88
|
+
let cliArgs: string[];
|
|
89
|
+
|
|
90
|
+
switch (name) {
|
|
91
|
+
case "miatel_beat_create":
|
|
92
|
+
cliArgs = buildArgs(
|
|
93
|
+
["beat", "create"],
|
|
94
|
+
args,
|
|
95
|
+
{ text: "-t", character: "--character", tone: "--tone", phase: "--phase" }
|
|
96
|
+
);
|
|
97
|
+
break;
|
|
98
|
+
|
|
99
|
+
case "miatel_beat_list":
|
|
100
|
+
cliArgs = buildArgs(
|
|
101
|
+
["beat", "list"],
|
|
102
|
+
args,
|
|
103
|
+
{ limit: "-n", character: "--character" }
|
|
104
|
+
);
|
|
105
|
+
break;
|
|
106
|
+
|
|
107
|
+
case "miatel_beat_analyze":
|
|
108
|
+
cliArgs = ["beat", "analyze", args.beatId];
|
|
109
|
+
if (args.universe) cliArgs.push("--universe", args.universe);
|
|
110
|
+
if (args.session) cliArgs.push("--session", args.session);
|
|
111
|
+
break;
|
|
112
|
+
|
|
113
|
+
case "miatel_beat_enrich":
|
|
114
|
+
cliArgs = ["beat", "enrich", args.beatId];
|
|
115
|
+
if (args.technique) cliArgs.push("--technique", args.technique);
|
|
116
|
+
if (args.session) cliArgs.push("--session", args.session);
|
|
117
|
+
break;
|
|
118
|
+
|
|
119
|
+
default:
|
|
120
|
+
return createToolResult({ error: `Unknown tool: ${name}` }, true);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
const output = await runCLI(CLI_PATH, cliArgs);
|
|
124
|
+
const result = parseJSONOutput(output);
|
|
125
|
+
return createToolResult(result);
|
|
126
|
+
|
|
127
|
+
} catch (err: any) {
|
|
128
|
+
return createToolResult({ error: err.message }, true);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
export const miatelServerConfig = {
|
|
133
|
+
name: "miatel",
|
|
134
|
+
version: "0.1.0",
|
|
135
|
+
description: "Story World MCP Server - Beats, arcs, themes, narrative analysis",
|
|
136
|
+
tools: miatelTools,
|
|
137
|
+
handleTool: handleMiatelTool
|
|
138
|
+
};
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MCP Server for miawa - Ceremony World CLI
|
|
3
|
+
*
|
|
4
|
+
* Exposes ceremony/wound/eva tools as MCP tools
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { runCLI, parseJSONOutput, createToolResult, buildArgs, MCPTool, MCPToolResult } from "./utils.js";
|
|
8
|
+
import { dirname, join } from "path";
|
|
9
|
+
import { fileURLToPath } from "url";
|
|
10
|
+
|
|
11
|
+
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
12
|
+
const CLI_PATH = join(__dirname, "../../miawa/dist/index.js");
|
|
13
|
+
|
|
14
|
+
export const miawaTools: MCPTool[] = [
|
|
15
|
+
{
|
|
16
|
+
name: "miawa_ceremony_init",
|
|
17
|
+
description: "Initiate a new ceremony session with intention",
|
|
18
|
+
inputSchema: {
|
|
19
|
+
type: "object",
|
|
20
|
+
properties: {
|
|
21
|
+
title: { type: "string", description: "Ceremony title" },
|
|
22
|
+
type: {
|
|
23
|
+
type: "string",
|
|
24
|
+
description: "Type of ceremony",
|
|
25
|
+
enum: ["group_reflection", "seasonal", "healing_circle", "wisdom_sharing"]
|
|
26
|
+
},
|
|
27
|
+
intention: { type: "string", description: "Ceremony intention" },
|
|
28
|
+
session: { type: "string", description: "Session ID" }
|
|
29
|
+
},
|
|
30
|
+
required: ["title", "type"]
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
name: "miawa_ceremony_list",
|
|
35
|
+
description: "List ceremonies in current session",
|
|
36
|
+
inputSchema: {
|
|
37
|
+
type: "object",
|
|
38
|
+
properties: {
|
|
39
|
+
session: { type: "string", description: "Session ID" }
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
name: "miawa_ceremony_advance",
|
|
45
|
+
description: "Advance ceremony to next movement (1-4)",
|
|
46
|
+
inputSchema: {
|
|
47
|
+
type: "object",
|
|
48
|
+
properties: {
|
|
49
|
+
ceremony: { type: "string", description: "Ceremony ID" },
|
|
50
|
+
session: { type: "string", description: "Session ID" }
|
|
51
|
+
},
|
|
52
|
+
required: ["ceremony"]
|
|
53
|
+
}
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
name: "miawa_ceremony_close",
|
|
57
|
+
description: "Close ceremony with wisdom archiving",
|
|
58
|
+
inputSchema: {
|
|
59
|
+
type: "object",
|
|
60
|
+
properties: {
|
|
61
|
+
ceremony: { type: "string", description: "Ceremony ID (uses active if not provided)" },
|
|
62
|
+
session: { type: "string", description: "Session ID" }
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
name: "miawa_ceremony_wisdom",
|
|
68
|
+
description: "Retrieve wisdom from completed ceremonies",
|
|
69
|
+
inputSchema: {
|
|
70
|
+
type: "object",
|
|
71
|
+
properties: {
|
|
72
|
+
ceremony: { type: "string", description: "Specific ceremony ID" },
|
|
73
|
+
session: { type: "string", description: "Session ID" }
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
name: "miawa_ceremony_stage",
|
|
79
|
+
description: "Check current ceremony stage and Four Movements",
|
|
80
|
+
inputSchema: {
|
|
81
|
+
type: "object",
|
|
82
|
+
properties: {
|
|
83
|
+
ceremony: { type: "string", description: "Ceremony ID" },
|
|
84
|
+
session: { type: "string", description: "Session ID" }
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
];
|
|
89
|
+
|
|
90
|
+
export async function handleMiawaTool(name: string, args: Record<string, any>): Promise<MCPToolResult> {
|
|
91
|
+
try {
|
|
92
|
+
let cliArgs: string[];
|
|
93
|
+
|
|
94
|
+
switch (name) {
|
|
95
|
+
case "miawa_ceremony_init":
|
|
96
|
+
cliArgs = buildArgs(
|
|
97
|
+
["ceremony", "init"],
|
|
98
|
+
args,
|
|
99
|
+
{ title: "-t", type: "--type", intention: "-i" }
|
|
100
|
+
);
|
|
101
|
+
break;
|
|
102
|
+
|
|
103
|
+
case "miawa_ceremony_list":
|
|
104
|
+
cliArgs = buildArgs(["ceremony", "list"], args, {});
|
|
105
|
+
break;
|
|
106
|
+
|
|
107
|
+
case "miawa_ceremony_advance":
|
|
108
|
+
cliArgs = buildArgs(
|
|
109
|
+
["ceremony", "advance"],
|
|
110
|
+
args,
|
|
111
|
+
{ ceremony: "--ceremony" }
|
|
112
|
+
);
|
|
113
|
+
break;
|
|
114
|
+
|
|
115
|
+
case "miawa_ceremony_close":
|
|
116
|
+
cliArgs = buildArgs(
|
|
117
|
+
["ceremony", "close"],
|
|
118
|
+
args,
|
|
119
|
+
{ ceremony: "--ceremony" }
|
|
120
|
+
);
|
|
121
|
+
break;
|
|
122
|
+
|
|
123
|
+
case "miawa_ceremony_wisdom":
|
|
124
|
+
cliArgs = buildArgs(
|
|
125
|
+
["ceremony", "wisdom"],
|
|
126
|
+
args,
|
|
127
|
+
{ ceremony: "--ceremony" }
|
|
128
|
+
);
|
|
129
|
+
break;
|
|
130
|
+
|
|
131
|
+
case "miawa_ceremony_stage":
|
|
132
|
+
cliArgs = buildArgs(
|
|
133
|
+
["ceremony", "stage"],
|
|
134
|
+
args,
|
|
135
|
+
{ ceremony: "--ceremony" }
|
|
136
|
+
);
|
|
137
|
+
break;
|
|
138
|
+
|
|
139
|
+
default:
|
|
140
|
+
return createToolResult({ error: `Unknown tool: ${name}` }, true);
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
const output = await runCLI(CLI_PATH, cliArgs);
|
|
144
|
+
const result = parseJSONOutput(output);
|
|
145
|
+
return createToolResult(result);
|
|
146
|
+
|
|
147
|
+
} catch (err: any) {
|
|
148
|
+
return createToolResult({ error: err.message }, true);
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
export const miawaServerConfig = {
|
|
153
|
+
name: "miawa",
|
|
154
|
+
version: "0.1.0",
|
|
155
|
+
description: "Ceremony World MCP Server - Ceremonies, wounds, circles, Eva integration",
|
|
156
|
+
tools: miawaTools,
|
|
157
|
+
handleTool: handleMiawaTool
|
|
158
|
+
};
|
package/src/mcp/utils.ts
ADDED
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MCP Server base utilities for mia-code sub-CLIs
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { spawn } from "child_process";
|
|
6
|
+
import { dirname, join } from "path";
|
|
7
|
+
import { fileURLToPath } from "url";
|
|
8
|
+
|
|
9
|
+
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
10
|
+
|
|
11
|
+
export interface MCPTool {
|
|
12
|
+
name: string;
|
|
13
|
+
description: string;
|
|
14
|
+
inputSchema: {
|
|
15
|
+
type: "object";
|
|
16
|
+
properties: Record<string, {
|
|
17
|
+
type: string;
|
|
18
|
+
description: string;
|
|
19
|
+
enum?: string[];
|
|
20
|
+
}>;
|
|
21
|
+
required?: string[];
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export interface MCPToolResult {
|
|
26
|
+
content: Array<{
|
|
27
|
+
type: "text";
|
|
28
|
+
text: string;
|
|
29
|
+
}>;
|
|
30
|
+
isError?: boolean;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export interface MCPServerConfig {
|
|
34
|
+
name: string;
|
|
35
|
+
version: string;
|
|
36
|
+
cliPath: string;
|
|
37
|
+
tools: MCPTool[];
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Run a CLI command and return parsed JSON output
|
|
42
|
+
*/
|
|
43
|
+
export function runCLI(cliPath: string, args: string[]): Promise<string> {
|
|
44
|
+
return new Promise((resolve, reject) => {
|
|
45
|
+
const child = spawn("node", [cliPath, ...args, "--json"], {
|
|
46
|
+
cwd: process.cwd(),
|
|
47
|
+
env: { ...process.env, FORCE_COLOR: "0" }
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
let stdout = "";
|
|
51
|
+
let stderr = "";
|
|
52
|
+
|
|
53
|
+
child.stdout?.on("data", (chunk) => stdout += chunk.toString());
|
|
54
|
+
child.stderr?.on("data", (chunk) => stderr += chunk.toString());
|
|
55
|
+
|
|
56
|
+
child.on("close", (code) => {
|
|
57
|
+
if (code === 0) {
|
|
58
|
+
resolve(stdout.trim());
|
|
59
|
+
} else {
|
|
60
|
+
reject(new Error(`CLI exited with code ${code}: ${stderr}`));
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
child.on("error", reject);
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Parse JSON output from CLI, handling errors gracefully
|
|
70
|
+
*/
|
|
71
|
+
export function parseJSONOutput(output: string): any {
|
|
72
|
+
try {
|
|
73
|
+
return JSON.parse(output);
|
|
74
|
+
} catch {
|
|
75
|
+
return { success: false, error: "Failed to parse CLI output", raw: output };
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Create MCP tool result from parsed data
|
|
81
|
+
*/
|
|
82
|
+
export function createToolResult(data: any, isError = false): MCPToolResult {
|
|
83
|
+
return {
|
|
84
|
+
content: [{
|
|
85
|
+
type: "text",
|
|
86
|
+
text: typeof data === "string" ? data : JSON.stringify(data, null, 2)
|
|
87
|
+
}],
|
|
88
|
+
isError
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Get session ID from args or environment
|
|
94
|
+
*/
|
|
95
|
+
export function getSessionId(args: { session?: string }): string | undefined {
|
|
96
|
+
return args.session || process.env.MIA_SESSION_ID;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* Build CLI arguments from tool input
|
|
101
|
+
*/
|
|
102
|
+
export function buildArgs(
|
|
103
|
+
command: string[],
|
|
104
|
+
args: Record<string, any>,
|
|
105
|
+
mapping: Record<string, string>
|
|
106
|
+
): string[] {
|
|
107
|
+
const result = [...command];
|
|
108
|
+
|
|
109
|
+
for (const [key, flag] of Object.entries(mapping)) {
|
|
110
|
+
const value = args[key];
|
|
111
|
+
if (value !== undefined && value !== null && value !== "") {
|
|
112
|
+
result.push(flag, String(value));
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
if (args.session) {
|
|
117
|
+
result.push("--session", args.session);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
return result;
|
|
121
|
+
}
|