@mcpc-tech/cli 0.1.8-beta.1 → 0.1.8-beta.3

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.
Files changed (2) hide show
  1. package/bin/mcpc.mjs +60 -37
  2. package/package.json +1 -1
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
@@ -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
  ];
@@ -2121,7 +2139,41 @@ var BaseSamplingExecutor = class {
2121
2139
  }
2122
2140
  });
2123
2141
  const action = parsedData["action"];
2124
- const actionStr = action && typeof action === "string" ? String(action) : "unknown_action";
2142
+ const decision = parsedData["decision"];
2143
+ if (typeof decision !== "string") {
2144
+ this.conversationHistory.push({
2145
+ role: "user",
2146
+ content: {
2147
+ type: "text",
2148
+ text: 'Missing required field "decision". Provide: {"action":"<tool>","decision":"proceed|retry","<tool>":{}} or {"decision":"complete"}'
2149
+ }
2150
+ });
2151
+ if (iterationSpan) endSpan(iterationSpan);
2152
+ continue;
2153
+ }
2154
+ if (decision === "complete" && action) {
2155
+ this.conversationHistory.push({
2156
+ role: "user",
2157
+ content: {
2158
+ type: "text",
2159
+ text: 'Invalid: Cannot have both "decision":"complete" and "action" field. When complete, only provide {"decision":"complete"}.'
2160
+ }
2161
+ });
2162
+ if (iterationSpan) endSpan(iterationSpan);
2163
+ continue;
2164
+ }
2165
+ if (decision !== "complete" && !action) {
2166
+ this.conversationHistory.push({
2167
+ role: "user",
2168
+ content: {
2169
+ type: "text",
2170
+ text: 'Missing required field "action". When executing, provide: {"action":"<tool>","decision":"proceed|retry","<tool>":{}}'
2171
+ }
2172
+ });
2173
+ if (iterationSpan) endSpan(iterationSpan);
2174
+ continue;
2175
+ }
2176
+ const actionStr = decision === "complete" ? "completion" : action && typeof action === "string" ? String(action) : "unknown_action";
2125
2177
  const spanName = `mcpc.sampling_iteration.${actionStr}`;
2126
2178
  iterationSpan = this.tracingEnabled ? startSpan(spanName, {
2127
2179
  iteration: this.currentIteration + 1,
@@ -2132,17 +2184,6 @@ var BaseSamplingExecutor = class {
2132
2184
  maxIterations: this.maxIterations,
2133
2185
  messages: JSON.stringify(this.conversationHistory)
2134
2186
  }, loopSpan ?? void 0) : null;
2135
- if (!action || typeof parsedData["decision"] !== "string") {
2136
- this.conversationHistory.push({
2137
- role: "user",
2138
- content: {
2139
- 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>":{}}'
2141
- }
2142
- });
2143
- if (iterationSpan) endSpan(iterationSpan);
2144
- continue;
2145
- }
2146
2187
  const result = await this.processAction(parsedData, schema, state, iterationSpan);
2147
2188
  this.logIterationProgress(parsedData, result, model, stopReason, role);
2148
2189
  if (iterationSpan) {
@@ -2158,6 +2199,7 @@ var BaseSamplingExecutor = class {
2158
2199
  maxIterations: this.maxIterations,
2159
2200
  parsed: rawJson,
2160
2201
  action: typeof action === "string" ? action : String(action),
2202
+ decision: typeof decision === "string" ? decision : String(decision),
2161
2203
  samplingResponse: responseContent,
2162
2204
  toolResult: JSON.stringify(result),
2163
2205
  model,
@@ -2423,15 +2465,6 @@ var SamplingExecutor = class extends BaseSamplingExecutor {
2423
2465
  }
2424
2466
  async processAction(parsedData, schema, _state, parentSpan) {
2425
2467
  const toolCallData = parsedData;
2426
- const isComplete = toolCallData.decision === "complete";
2427
- const actionName = toolCallData.action;
2428
- if (isComplete && actionName && actionName !== "complete") {
2429
- this.logger.debug({
2430
- message: "Decision is 'complete' with action present, treating as 'proceed'",
2431
- action: actionName
2432
- });
2433
- toolCallData.decision = "proceed";
2434
- }
2435
2468
  if (toolCallData.decision === "complete") {
2436
2469
  return await this.createCompletionResult("Task completed", parentSpan);
2437
2470
  }
@@ -2479,8 +2512,7 @@ ${JSON.stringify(context2, null, 2)}`;
2479
2512
  ## Current Task
2480
2513
  You will now use agentic sampling to complete the following task: "${userRequest}"${contextInfo}
2481
2514
 
2482
- When you need to use a tool, specify the tool name in 'action' and provide tool-specific parameters as additional properties.
2483
- 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.`;
2484
2516
  return this.injectJsonInstruction({
2485
2517
  prompt: basePrompt + taskPrompt,
2486
2518
  schema: agenticSchema
@@ -3052,15 +3084,6 @@ var WorkflowSamplingExecutor = class extends BaseSamplingExecutor {
3052
3084
  throw new Error("WorkflowState is required for workflow");
3053
3085
  }
3054
3086
  const toolCallData = parsedData;
3055
- const isComplete = toolCallData.decision === "complete";
3056
- const actionName = toolCallData.action;
3057
- if (isComplete && actionName && actionName !== "complete") {
3058
- this.logger.debug({
3059
- message: "Decision is 'complete' with action present, treating as 'proceed'",
3060
- action: actionName
3061
- });
3062
- toolCallData.decision = "proceed";
3063
- }
3064
3087
  if (toolCallData.decision === "complete") {
3065
3088
  return await this.createCompletionResult("Task completed", parentSpan);
3066
3089
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mcpc-tech/cli",
3
- "version": "0.1.8-beta.1",
3
+ "version": "0.1.8-beta.3",
4
4
  "homepage": "https://jsr.io/@mcpc/cli",
5
5
  "type": "module",
6
6
  "dependencies": {