@mcpc-tech/cli 0.1.7 → 0.1.8-beta.2

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/bin/mcpc.mjs CHANGED
@@ -1039,7 +1039,7 @@ var SystemPrompts = {
1039
1039
  4. **Collect feedback** from each action result
1040
1040
  5. **Decide** next step:
1041
1041
  - **proceed**: More work needed
1042
- - **complete**: Question answered
1042
+ - **complete**: Question answered (do NOT provide action field)
1043
1043
  - **retry**: Current action failed
1044
1044
  6. **Provide** parameter object matching action name
1045
1045
  7. **Continue** until complete
@@ -1048,9 +1048,16 @@ var SystemPrompts = {
1048
1048
  \`\`\`json
1049
1049
  {
1050
1050
  "action": "tool_name",
1051
- "decision": "proceed|retry|complete",
1051
+ "decision": "proceed|retry",
1052
1052
  "tool_name": { /* tool parameters */ }
1053
1053
  }
1054
+ \`\`\`
1055
+
1056
+ **When task is complete:**
1057
+ \`\`\`json
1058
+ {
1059
+ "decision": "complete"
1060
+ }
1054
1061
  \`\`\``,
1055
1062
  /**
1056
1063
  * Workflow execution system prompt
@@ -1090,14 +1097,22 @@ var SystemPrompts = {
1090
1097
  - Continue until question answered
1091
1098
 
1092
1099
  ## JSON Response Format
1100
+ **During execution:**
1093
1101
  \`\`\`json
1094
1102
  {
1095
1103
  "action": "tool_name",
1096
- "decision": "proceed|retry|complete",
1104
+ "decision": "proceed|retry",
1097
1105
  "tool_name": { /* tool parameters */ }
1098
1106
  }
1099
1107
  \`\`\`
1100
1108
 
1109
+ **When task is complete (do NOT include action):**
1110
+ \`\`\`json
1111
+ {
1112
+ "decision": "complete"
1113
+ }
1114
+ \`\`\`
1115
+
1101
1116
  ## Available Tools
1102
1117
  {toolList}`,
1103
1118
  /**
@@ -1132,9 +1147,12 @@ You MUST respond with a JSON object for workflow execution:
1132
1147
 
1133
1148
  **For Step Execution (Subsequent Calls):**
1134
1149
  - action: "{toolName}"
1135
- - decision: "proceed" (advance), "retry" (retry), or "complete" (finish - sampling mode only)
1150
+ - decision: "proceed" (advance), "retry" (retry)
1136
1151
  - [step parameters]: Tool-specific parameters you autonomously determine for current step
1137
1152
 
1153
+ **When Workflow is Complete (do NOT include action):**
1154
+ - decision: "complete"
1155
+
1138
1156
  **\u{1F3AF} AGENTIC WORKFLOW CONSTRAINTS:**
1139
1157
  - Response must be pure JSON demonstrating autonomous decision-making within workflow structure
1140
1158
  - Invalid JSON indicates failure in agentic workflow reasoning
@@ -1477,13 +1495,13 @@ var AgenticExecutor = class {
1477
1495
  this.tracingEnabled = false;
1478
1496
  }
1479
1497
  }
1480
- async execute(args, schema) {
1498
+ async execute(args, schema, parentSpan) {
1481
1499
  const executeSpan = this.tracingEnabled ? startSpan("mcpc.agentic_execute", {
1482
1500
  agent: this.name,
1483
1501
  action: String(args[this.ACTION_KEY] ?? "unknown"),
1484
1502
  nextAction: String(args[this.NEXT_ACTION_KEY] ?? "none"),
1485
1503
  args: JSON.stringify(args)
1486
- }) : null;
1504
+ }, parentSpan ?? void 0) : null;
1487
1505
  try {
1488
1506
  const validationResult = this.validate(args, schema);
1489
1507
  if (!validationResult.valid) {
@@ -2077,7 +2095,7 @@ var BaseSamplingExecutor = class {
2077
2095
  role: "user",
2078
2096
  content: {
2079
2097
  type: "text",
2080
- text: 'Return ONE AND ONLY ONE raw JSON object (no code fences, explanations, or multiple objects). The JSON MUST include action and decision. Example: {"action":"<tool>","decision":"proceed|complete","<tool>":{}}'
2098
+ text: 'Return ONE AND ONLY ONE raw JSON object (no code fences, explanations, or multiple objects). During execution provide: {"action":"<tool>","decision":"proceed|retry","<tool>":{}}. When complete provide: {"decision":"complete"}'
2081
2099
  }
2082
2100
  }
2083
2101
  ];
@@ -2137,13 +2155,24 @@ var BaseSamplingExecutor = class {
2137
2155
  role: "user",
2138
2156
  content: {
2139
2157
  type: "text",
2140
- text: 'Required fields missing: action or decision. Return ONLY raw JSON, no code fences or explanations. Example: {"action":"<tool>","decision":"proceed|complete","<tool>":{}}'
2158
+ text: 'Required fields missing. During execution provide: {"action":"<tool>","decision":"proceed|retry","<tool>":{}}. When complete provide: {"decision":"complete"}'
2159
+ }
2160
+ });
2161
+ if (iterationSpan) endSpan(iterationSpan);
2162
+ continue;
2163
+ }
2164
+ if (parsedData["decision"] === "complete" && action) {
2165
+ this.conversationHistory.push({
2166
+ role: "user",
2167
+ content: {
2168
+ type: "text",
2169
+ text: 'Invalid: Cannot have both "decision":"complete" and "action" field. When complete, only provide {"decision":"complete"}.'
2141
2170
  }
2142
2171
  });
2143
2172
  if (iterationSpan) endSpan(iterationSpan);
2144
2173
  continue;
2145
2174
  }
2146
- const result = await this.processAction(parsedData, schema, state, loopSpan);
2175
+ const result = await this.processAction(parsedData, schema, state, iterationSpan);
2147
2176
  this.logIterationProgress(parsedData, result, model, stopReason, role);
2148
2177
  if (iterationSpan) {
2149
2178
  let rawJson = "{}";
@@ -2423,12 +2452,25 @@ var SamplingExecutor = class extends BaseSamplingExecutor {
2423
2452
  }
2424
2453
  async processAction(parsedData, schema, _state, parentSpan) {
2425
2454
  const toolCallData = parsedData;
2455
+ const isComplete = toolCallData.decision === "complete";
2456
+ const actionName = toolCallData.action;
2457
+ if (isComplete && actionName) {
2458
+ return {
2459
+ content: [
2460
+ {
2461
+ type: "text",
2462
+ text: 'Invalid: Cannot have both "decision":"complete" and "action" field. When complete, only provide {"decision":"complete"}. When executing, provide {"action":"<tool>","decision":"proceed|retry","<tool>":{}}.'
2463
+ }
2464
+ ],
2465
+ isError: true
2466
+ };
2467
+ }
2426
2468
  if (toolCallData.decision === "complete") {
2427
2469
  return await this.createCompletionResult("Task completed", parentSpan);
2428
2470
  }
2429
2471
  try {
2430
2472
  const { action: _action, decision: _decision, ..._toolArgs } = toolCallData;
2431
- const toolResult = await this.agenticExecutor.execute(toolCallData, schema);
2473
+ const toolResult = await this.agenticExecutor.execute(toolCallData, schema, parentSpan);
2432
2474
  const resultText = toolResult.content?.filter((content) => content.type === "text")?.map((content) => content.text)?.join("\n") || "No result";
2433
2475
  this.conversationHistory.push({
2434
2476
  role: "assistant",
@@ -2470,8 +2512,7 @@ ${JSON.stringify(context2, null, 2)}`;
2470
2512
  ## Current Task
2471
2513
  You will now use agentic sampling to complete the following task: "${userRequest}"${contextInfo}
2472
2514
 
2473
- When you need to use a tool, specify the tool name in 'action' and provide tool-specific parameters as additional properties.
2474
- When the task is complete, use "action": "complete".`;
2515
+ When you need to use a tool, specify the tool name in 'action' and provide tool-specific parameters as additional properties.`;
2475
2516
  return this.injectJsonInstruction({
2476
2517
  prompt: basePrompt + taskPrompt,
2477
2518
  schema: agenticSchema
@@ -3043,6 +3084,19 @@ var WorkflowSamplingExecutor = class extends BaseSamplingExecutor {
3043
3084
  throw new Error("WorkflowState is required for workflow");
3044
3085
  }
3045
3086
  const toolCallData = parsedData;
3087
+ const isComplete = toolCallData.decision === "complete";
3088
+ const actionName = toolCallData.action;
3089
+ if (isComplete && actionName) {
3090
+ return {
3091
+ content: [
3092
+ {
3093
+ type: "text",
3094
+ text: 'Invalid: Cannot have both "decision":"complete" and "action" field. When complete, only provide {"decision":"complete"}. When executing, provide {"action":"<tool>","decision":"proceed|retry","<tool>":{}}.'
3095
+ }
3096
+ ],
3097
+ isError: true
3098
+ };
3099
+ }
3046
3100
  if (toolCallData.decision === "complete") {
3047
3101
  return await this.createCompletionResult("Task completed", parentSpan);
3048
3102
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mcpc-tech/cli",
3
- "version": "0.1.7",
3
+ "version": "0.1.8-beta.2",
4
4
  "homepage": "https://jsr.io/@mcpc/cli",
5
5
  "type": "module",
6
6
  "dependencies": {
@@ -1 +1 @@
1
- {"version":3,"file":"app.d.ts","sources":["../../src/app.ts"],"names":[],"mappings":"AAAA,SAAS,WAAW,4BAAwC;AAI5D,cAAc,mBAAmB,0BAAmD;AACpF,cAAc,UAAU,6BAA6B;AAErD,OAAO,cAAM,eACX,SAAS,eACR,QAAQ,qBA8BT;AAEF,OAAO,cAAM,iBAAgB,YAO3B"}
1
+ {"version":3,"file":"app.d.ts","sources":["../../src/app.ts"],"names":[],"mappings":"AAAA,SAAS,WAAW,4BAAwC;AAI5D,cAAc,mBAAmB,0BAA0D;AAC3F,cAAc,UAAU,6BAA6B;AAErD,OAAO,cAAM,eACX,SAAS,eACR,QAAQ,qBA8BT;AAEF,OAAO,cAAM,iBAAgB,YAO3B"}
@@ -1 +1 @@
1
- {"version":3,"file":"loader.d.ts","sources":["../../../src/config/loader.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA2CC,GAED,cAAc,iBAAiB,0BAAgC;AAK/D,iBAAiB;EACf;;GAEC,GACD,OAAO,MAAM;EACb;;GAEC,GACD,UAAU,MAAM;EAChB;;GAEC,GACD;IACE,QAAQ,OAAO,MAAM,EAAE,OAAO;IAC9B,WAAW,OAAO,MAAM,EAAE,OAAO;;EAEnC;;GAEC,GACD,QAAQ;;AAwHV;;;CAGC,GACD,OAAO,iBAAe,cAAc,QAAQ,aAAa,IAAI;AAoK7D;;CAEC,GACD,OAAO,iBAAS,eAAe,QAAQ,UAAU,GAAG,IAAI"}
1
+ {"version":3,"file":"loader.d.ts","sources":["../../../src/config/loader.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA2CC,GAED,cAAc,iBAAiB,0BAAuC;AAKtE,iBAAiB;EACf;;GAEC,GACD,OAAO,MAAM;EACb;;GAEC,GACD,UAAU,MAAM;EAChB;;GAEC,GACD;IACE,QAAQ,OAAO,MAAM,EAAE,OAAO;IAC9B,WAAW,OAAO,MAAM,EAAE,OAAO;;EAEnC;;GAEC,GACD,QAAQ;;AAwHV;;;CAGC,GACD,OAAO,iBAAe,cAAc,QAAQ,aAAa,IAAI;AAoK7D;;CAEC,GACD,OAAO,iBAAS,eAAe,QAAQ,UAAU,GAAG,IAAI"}