@rudderhq/cli 0.7.9 → 0.7.11

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/index.js CHANGED
@@ -441,6 +441,7 @@ var init_constants = __esm({
441
441
  "rudder_goal_list",
442
442
  "rudder_goal_context",
443
443
  "rudder_goal_progress",
444
+ "rudder_goal_checkpoint",
444
445
  "rudder_goal_change_propose",
445
446
  "rudder_goal_result_propose",
446
447
  "rudder_issue_get",
@@ -4024,7 +4025,7 @@ var init_workspace_backup2 = __esm({
4024
4025
 
4025
4026
  // ../packages/shared/dist/validators/goal.js
4026
4027
  import { z as z27 } from "zod";
4027
- var jsonRecord, evidenceRefSchema, sha256HexSchema, criterionSchema, continuationSchema, planPayloadSchema, createGoalSchema, updateGoalSchema, activateGoalSchema, goalStartPacketSchema, previewGoalStartSchema, startGoalSchema, createGoalActivitySchema, assignGoalOwnerSchema, goalFeedbackAttachmentSchema, createGoalFeedbackSchema, goalContractPatchSchema, createGoalChangeProposalSchema, decideGoalChangeProposalSchema, goalEvaluationCandidateFields, goalEvaluationCandidateSchema, createGoalResultProposalSchema, acceptGoalResultProposalSchema, rejectGoalResultProposalSchema, evaluateGoalSchema, setGoalFocusSchema;
4028
+ var jsonRecord, evidenceRefSchema, sha256HexSchema, criterionSchema, continuationSchema, goalPlanPayloadSchema, createGoalSchema, updateGoalSchema, activateGoalSchema, goalStartPacketSchema, previewGoalStartSchema, startGoalSchema, createGoalCheckpointSchema, goalCheckpointSchema, createGoalActivitySchema, assignGoalOwnerSchema, goalFeedbackAttachmentSchema, createGoalFeedbackSchema, goalContractPatchSchema, createGoalChangeProposalSchema, decideGoalChangeProposalSchema, goalEvaluationCandidateFields, goalEvaluationCandidateSchema, createGoalResultProposalSchema, acceptGoalResultProposalSchema, rejectGoalResultProposalSchema, evaluateGoalSchema, setGoalFocusSchema;
4028
4029
  var init_goal = __esm({
4029
4030
  "../packages/shared/dist/validators/goal.js"() {
4030
4031
  "use strict";
@@ -4044,7 +4045,7 @@ var init_goal = __esm({
4044
4045
  summary: z27.string().trim().min(1),
4045
4046
  wakeCondition: z27.string().trim().min(1).optional().nullable()
4046
4047
  });
4047
- planPayloadSchema = z27.object({
4048
+ goalPlanPayloadSchema = z27.object({
4048
4049
  summary: z27.string().trim().min(1),
4049
4050
  hypotheses: z27.array(z27.unknown()).optional().default([]),
4050
4051
  selectedPaths: z27.array(z27.unknown()).optional().default([]),
@@ -4084,7 +4085,7 @@ var init_goal = __esm({
4084
4085
  actionDeadline: z27.coerce.date().optional().nullable(),
4085
4086
  evaluationDeadline: z27.coerce.date().optional().nullable(),
4086
4087
  initialContinuation: continuationSchema,
4087
- initialPlan: planPayloadSchema
4088
+ initialPlan: goalPlanPayloadSchema
4088
4089
  }).superRefine((value, ctx) => {
4089
4090
  if (value.evaluationDeadline && value.actionDeadline && value.evaluationDeadline < value.actionDeadline) {
4090
4091
  ctx.addIssue({ code: z27.ZodIssueCode.custom, path: ["evaluationDeadline"], message: "Evaluation deadline must not precede action deadline" });
@@ -4125,6 +4126,15 @@ var init_goal = __esm({
4125
4126
  allowCapabilityMismatch: z27.boolean().optional(),
4126
4127
  draftGoalId: z27.string().uuid().optional()
4127
4128
  }).strict();
4129
+ createGoalCheckpointSchema = z27.object({
4130
+ summary: z27.string().trim().min(1),
4131
+ evidenceRefs: z27.array(evidenceRefSchema).max(100),
4132
+ expectedPlanRevision: z27.number().int().positive(),
4133
+ plan: goalPlanPayloadSchema.optional(),
4134
+ continuation: continuationSchema,
4135
+ idempotencyKey: z27.string().trim().min(1)
4136
+ }).strict();
4137
+ goalCheckpointSchema = createGoalCheckpointSchema.extend({ goal: z27.string().uuid() });
4128
4138
  createGoalActivitySchema = z27.object({
4129
4139
  summary: z27.string().trim().min(1),
4130
4140
  activityKind: z27.enum(GOAL_ACTIVITY_KINDS).optional().nullable(),
@@ -4790,6 +4800,7 @@ var init_short_refs = __esm({
4790
4800
  "use strict";
4791
4801
  SHORT_REF_PREFIX_BY_KIND = {
4792
4802
  agent: "agt",
4803
+ chat: "cht",
4793
4804
  issue_comment: "cmt"
4794
4805
  };
4795
4806
  SHORT_REF_KIND_BY_PREFIX = Object.fromEntries(Object.entries(SHORT_REF_PREFIX_BY_KIND).map(([kind, prefix]) => [prefix, kind]));
@@ -5018,6 +5029,7 @@ var init_dist = __esm({
5018
5029
  init_agent_issue_creation();
5019
5030
  init_validators();
5020
5031
  init_validators();
5032
+ init_goal();
5021
5033
  init_agent_url_key();
5022
5034
  init_api();
5023
5035
  init_markdown_source_boundary();
@@ -9343,6 +9355,15 @@ var RUDDER_MCP_TOOL_DESCRIPTORS = [
9343
9355
  "requiresAgentId": true,
9344
9356
  "attachesRunIdWhenAvailable": true
9345
9357
  },
9358
+ {
9359
+ "capabilityId": "goal.checkpoint",
9360
+ "name": "rudder_goal_checkpoint",
9361
+ "description": "Atomically persist a Goal checkpoint, optional Plan revision, continuation, checkpoint activity, and eligible automatic continuation wake.",
9362
+ "mutating": true,
9363
+ "requiresOrgId": false,
9364
+ "requiresAgentId": true,
9365
+ "attachesRunIdWhenAvailable": true
9366
+ },
9346
9367
  {
9347
9368
  "capabilityId": "goal.change.propose",
9348
9369
  "name": "rudder_goal_change_propose",
@@ -10459,6 +10480,44 @@ function coreMcpInputSchema(id) {
10459
10480
  },
10460
10481
  idempotencyKey: string("Stable key for safe retry.", { maxLength: 500 })
10461
10482
  }, ["goal", "summary", "evidenceRefs", "idempotencyKey"]);
10483
+ case "goal.checkpoint":
10484
+ return schema({
10485
+ goal,
10486
+ summary: string("Plain-language bounded-run checkpoint summary."),
10487
+ evidenceRefs: {
10488
+ type: "array",
10489
+ description: "URI-like references to artifacts, measurements, or other supporting evidence.",
10490
+ maxItems: 100,
10491
+ items: string("URI-like evidence reference.", { maxLength: 8192 })
10492
+ },
10493
+ expectedPlanRevision: number("Plan revision read before this checkpoint.", 1, 1e9),
10494
+ plan: {
10495
+ type: "object",
10496
+ description: "Optional complete next Plan revision; omit when the current Plan remains valid.",
10497
+ additionalProperties: false,
10498
+ properties: {
10499
+ summary: string("Plan summary."),
10500
+ hypotheses: { type: "array", maxItems: 1e3, items: {} },
10501
+ selectedPaths: { type: "array", maxItems: 1e3, items: {} },
10502
+ rejectedPaths: { type: "array", maxItems: 1e3, items: {} },
10503
+ sequencing: { type: "array", maxItems: 1e3, items: {} },
10504
+ budgetAllocations: { type: "object", additionalProperties: true },
10505
+ invalidationConditions: { type: "array", maxItems: 1e3, items: {} }
10506
+ },
10507
+ required: ["summary"]
10508
+ },
10509
+ continuation: {
10510
+ type: "object",
10511
+ additionalProperties: false,
10512
+ properties: {
10513
+ kind: string("Continuation policy.", { enum: ["commitment", "wait", "decision", "verification"] }),
10514
+ summary: string("What should happen next or what is awaited."),
10515
+ wakeCondition: { oneOf: [{ type: "string", minLength: 1 }, { type: "null" }] }
10516
+ },
10517
+ required: ["kind", "summary"]
10518
+ },
10519
+ idempotencyKey: string("Stable key for safe retry.", { maxLength: 500 })
10520
+ }, ["goal", "summary", "evidenceRefs", "expectedPlanRevision", "continuation", "idempotencyKey"]);
10462
10521
  case "goal.change.propose":
10463
10522
  return schema({
10464
10523
  goal,
@@ -11121,6 +11180,18 @@ var AGENT_CLI_CAPABILITIES = [
11121
11180
  requiresRunId: true,
11122
11181
  attachesRunIdWhenAvailable: true
11123
11182
  },
11183
+ {
11184
+ id: "goal.checkpoint",
11185
+ command: "rudder goal checkpoint <goal-id> --summary <text> --evidence-refs <json> --expected-plan-revision <n> --continuation <json> --idempotency-key <key>",
11186
+ category: "goal",
11187
+ description: "Atomically persist a Goal checkpoint, optional Plan revision, continuation, checkpoint activity, and eligible automatic continuation wake.",
11188
+ mutating: true,
11189
+ contract: "agent-v1",
11190
+ requiresOrgId: false,
11191
+ requiresAgentId: true,
11192
+ requiresRunId: true,
11193
+ attachesRunIdWhenAvailable: true
11194
+ },
11124
11195
  {
11125
11196
  id: "goal.change.propose",
11126
11197
  command: "rudder goal change propose <goal-id> --contract-revision <n> --after-contract <json> --rationale <text> --idempotency-key <key>",
@@ -12131,7 +12202,7 @@ var AGENT_CLI_CAPABILITIES = [
12131
12202
  },
12132
12203
  {
12133
12204
  id: "chat.get",
12134
- command: "rudder chat get <chat-id>",
12205
+ command: "rudder chat get <chat-id-or-cht-ref>",
12135
12206
  category: "chat",
12136
12207
  description: "Read one chat conversation record.",
12137
12208
  mutating: false,
@@ -12143,7 +12214,7 @@ var AGENT_CLI_CAPABILITIES = [
12143
12214
  },
12144
12215
  {
12145
12216
  id: "chat.messages",
12146
- command: "rudder chat messages <chat-id> [--limit <n>] [--cursor <cursor>] [--include-transcript]",
12217
+ command: "rudder chat messages <chat-id-or-cht-ref> [--limit <n>] [--cursor <cursor>] [--include-transcript]",
12147
12218
  category: "chat",
12148
12219
  description: "Read bounded chat messages with page cursors; transcript output is omitted unless requested.",
12149
12220
  mutating: false,
@@ -12155,7 +12226,7 @@ var AGENT_CLI_CAPABILITIES = [
12155
12226
  },
12156
12227
  {
12157
12228
  id: "chat.transcript",
12158
- command: "rudder chat transcript <chat-id> [--limit <n>] [--cursor <cursor>] [--max-output-chars <n>]",
12229
+ command: "rudder chat transcript <chat-id-or-cht-ref> [--limit <n>] [--cursor <cursor>] [--max-output-chars <n>]",
12159
12230
  category: "chat",
12160
12231
  description: "Read paginated chat messages with assistant transcript entries clipped in human output.",
12161
12232
  mutating: false,
@@ -12167,7 +12238,7 @@ var AGENT_CLI_CAPABILITIES = [
12167
12238
  },
12168
12239
  {
12169
12240
  id: "chat.read",
12170
- command: "rudder chat read <chat-id> [--turn-limit <n>] [--cursor <cursor>] [--include-output]",
12241
+ command: "rudder chat read <chat-id-or-cht-ref> [--turn-limit <n>] [--cursor <cursor>] [--include-output]",
12171
12242
  category: "chat",
12172
12243
  description: "Read a bounded recent-message snapshot for one chat with page cursors.",
12173
12244
  mutating: false,
@@ -12191,7 +12262,7 @@ var AGENT_CLI_CAPABILITIES = [
12191
12262
  },
12192
12263
  {
12193
12264
  id: "chat.send",
12194
- command: "rudder chat send <chat-id> --body <text>",
12265
+ command: "rudder chat send <chat-id-or-cht-ref> --body <text>",
12195
12266
  category: "chat",
12196
12267
  description: "Send an agent-authored message directly to the operator in a chat.",
12197
12268
  mutating: true,
@@ -12203,7 +12274,7 @@ var AGENT_CLI_CAPABILITIES = [
12203
12274
  },
12204
12275
  {
12205
12276
  id: "chat.archive",
12206
- command: "rudder chat archive <chat-id>",
12277
+ command: "rudder chat archive <chat-id-or-cht-ref>",
12207
12278
  category: "chat",
12208
12279
  description: "Archive a chat conversation without deleting it.",
12209
12280
  mutating: true,
@@ -12619,6 +12690,7 @@ var LEGACY_ARGUMENT_ALIASES = {
12619
12690
  },
12620
12691
  "goal.context": { goalId: "goal" },
12621
12692
  "goal.progress": { goalId: "goal" },
12693
+ "goal.checkpoint": { goalId: "goal" },
12622
12694
  "goal.change.propose": { goalId: "goal" },
12623
12695
  "goal.result.propose": { goalId: "goal" },
12624
12696
  "issue.get": { issueId: "issue" },
@@ -13077,6 +13149,21 @@ async function callToolDirectlyIfSupported(toolName, rawArgs, env, signal) {
13077
13149
  payload
13078
13150
  ));
13079
13151
  }
13152
+ case "goal.checkpoint": {
13153
+ const goalId = requiredAnyString(input, ["goal", "goalId"]);
13154
+ const payload = createGoalCheckpointSchema.parse({
13155
+ summary: requiredString(input, "summary"),
13156
+ evidenceRefs: input.evidenceRefs,
13157
+ expectedPlanRevision: input.expectedPlanRevision,
13158
+ plan: input.plan,
13159
+ continuation: input.continuation,
13160
+ idempotencyKey: requiredString(input, "idempotencyKey")
13161
+ });
13162
+ return success(await api.post(
13163
+ `/api/goals/${encodeURIComponent(goalId)}/checkpoint`,
13164
+ payload
13165
+ ));
13166
+ }
13080
13167
  case "goal.change.propose": {
13081
13168
  const payload = createGoalChangeProposalSchema.parse({
13082
13169
  expectedContractRevision: input.contractRevision,
@@ -13476,6 +13563,25 @@ function cliArgsForCapability(capabilityId, input, tempFiles, env) {
13476
13563
  pushOptional(args, "--activity-kind", input.activityKind);
13477
13564
  return args;
13478
13565
  }
13566
+ case "goal.checkpoint": {
13567
+ const args = [
13568
+ "goal",
13569
+ "checkpoint",
13570
+ requiredAnyString(input, ["goal", "goalId"]),
13571
+ "--summary",
13572
+ requiredString(input, "summary"),
13573
+ "--evidence-refs",
13574
+ JSON.stringify(input.evidenceRefs),
13575
+ "--expected-plan-revision",
13576
+ String(input.expectedPlanRevision),
13577
+ "--continuation",
13578
+ JSON.stringify(input.continuation),
13579
+ "--idempotency-key",
13580
+ requiredString(input, "idempotencyKey")
13581
+ ];
13582
+ if (input.plan !== void 0) args.push("--plan", JSON.stringify(input.plan));
13583
+ return args;
13584
+ }
13479
13585
  case "goal.change.propose": {
13480
13586
  const args = [
13481
13587
  "goal",
@@ -15057,17 +15163,99 @@ function asString(value, fallback) {
15057
15163
  }
15058
15164
 
15059
15165
  // ../packages/agent-runtime-utils/dist/server-utils.prompts.js
15060
- var RUDDER_GOAL_RUNTIME_BOUNDARY = `This is a Rudder product Goal, not a Codex internal goal. Do not call Codex \`create_goal\`, \`update_goal\`, or \`get_goal\` for it; those tools do not manage Rudder Goals. If the Goal packet names an exact managed Rudder tool, call that typed tool directly. Do not load \`rudder-docs\`, inspect skill files, or run discovery commands merely to confirm a tool that the packet already names. If the Rudder Goal context is missing or stale, report the named blocker and request refreshed context instead of using shell, Bash, curl, or the \`rudder\` CLI to retrieve it.
15166
+ var RUDDER_GOAL_RUNTIME_BOUNDARY = `This is a Rudder product Goal, not a Codex internal goal. Do not call Codex \`create_goal\`, \`update_goal\`, or \`get_goal\` for it; those tools do not manage Rudder Goals.
15167
+
15168
+ Treat the supplied Goal Runtime Context as the current wake snapshot. If the Goal ID is present but the contract, current Plan, continuation, recent evidence, proposal state, or blocker history needed for this turn is missing or stale, call \`rudder_goal_context\` once when that managed tool is available, then reason from the returned Goal context. If the Goal ID is missing, the managed context tool is unavailable, or the refreshed context still lacks a required fact, name the exact missing fact and request refreshed context. Missing context is not by itself a validated blocked conclusion.
15169
+
15170
+ If the Goal packet or this protocol names an exact managed Rudder tool, call that typed tool directly. Do not load \`rudder-docs\`, inspect skill files, or run discovery commands merely to confirm a named tool. Do not use shell, Bash, curl, or the \`rudder\` CLI to read or mutate Goal state.
15171
+
15172
+ Use only tools that are actually available in the runtime. Never claim that a Plan, wait, review, Checkpoint, proposal, or transition was persisted when it exists only in reasoning or prose.
15173
+
15174
+ Record meaningful evidence-backed advancement with \`rudder_goal_progress\`; the tool automatically attributes progress to this Run. If evidence shows the Goal contract itself must change, use \`rudder_goal_change_propose\` so a human can review the exact delta; never silently redefine the outcome or boundaries. When the outcome is ready for review, use \`rudder_goal_result_propose\` with the current contract revision and supporting evidence. A human must accept every terminal Goal result. A Result Proposal requests acceptance; it does not let the runtime mark, close, or claim the Goal complete.`;
15175
+ var RUDDER_GOAL_ADVANCEMENT_PROTOCOL = `## Goal Advancement Protocol
15176
+
15177
+ Use this as a phase router, not a checklist to replay mechanically. Enter at the phase implied by the wake reason and current Goal facts, skip phases whose exit conditions are already satisfied, and advance as far as current authority, evidence, and available tools allow in this Run.
15178
+
15179
+ ### Phase 1 - Reconstruct the current state
15180
+
15181
+ - Read the accepted Contract, current persisted Plan, current continuation, latest relevant Evidence and feedback, open proposals or reviews, deadlines, and autonomy envelope.
15182
+ - Keep three things separate: the Contract defines the outcome and boundaries; the Plan is the current mutable strategy; a bounded Run is one attempt under that Plan.
15183
+ - Treat the recorded continuation as the current handoff hypothesis, not an instruction to ignore newer Evidence or feedback.
15184
+ - Resolve missing or stale context through the managed context rule above before making a consequential Goal mutation, a three-turn blocker judgment, or a Result Proposal.
15185
+
15186
+ ### Phase 2 - Check that the Goal is executable
15187
+
15188
+ - An active Goal is already human-confirmed. Do not restart broad Goal shaping on every wake.
15189
+ - Check whether the outcome, required criteria, evaluation boundary, evidence expectations, authority, and next continuation are concrete enough for the next bounded decision.
15190
+ - Ask only for a missing fact that materially changes execution. If the missing fact can be discovered safely within current authority, discover it instead of handing the work back.
15191
+ - If only the strategy must change, stay inside the Contract and Replan. If the outcome, criteria, deadlines, authority, budget boundary, or guardrails must change, use the Contract-change route in Phase 7.
15192
+
15193
+ ### Phase 3 - Plan or Replan
15061
15194
 
15062
- Record meaningful evidence-backed advancement with \`rudder_goal_progress\`; the tool automatically attributes progress to this Run. If evidence shows the Goal contract itself must change, use \`rudder_goal_change_propose\` so a human can review the exact delta; never silently redefine the outcome or boundaries. When the outcome is ready for review, use \`rudder_goal_result_propose\` with the current contract revision and supporting evidence. Do not use shell, Bash, curl, or the \`rudder\` CLI for these actions.
15195
+ - State the current Goal gap, the working hypothesis, one bounded next commitment, the Evidence it should produce, and the stop or invalidation condition.
15196
+ - Prefer a commitment that can produce decision-relevant Evidence in this Run. Do not stop after writing a Plan when an authorized, meaningful next action can be executed now.
15197
+ - Replan when new Evidence, feedback, a failed assumption, a review finding, or a changed Contract invalidates the current path. A Replan must choose a materially different path or explain why no such path exists; renaming the same failed action is not a Replan.
15198
+ - Plan and Replan changes remain Agent-owned while they stay inside the accepted autonomy envelope. They do not silently revise the Goal Contract.
15199
+ - Persist a Plan/Replan only through a real named Goal Plan mechanism. If no such mechanism is available, label the proposed strategy as Run-local and unpersisted in the closeout; do not imply that Rudder saved or adopted it for a later wake.
15063
15200
 
15064
- A human must accept every terminal Goal result. A Result Proposal requests acceptance; it does not let the runtime mark, close, or claim the Goal complete.`;
15201
+ ### Phase 4 - Run an optional Plan or Replan review
15202
+
15203
+ - Invoke a Plan/Replan review only when the Contract, continuation, risk policy, or explicit human instruction requires it and a real Review or Verification mechanism is available.
15204
+ - The review checks assumptions, material risks, authority boundaries, and whether the proposed commitment can produce useful Evidence.
15205
+ - A Reviewer returns findings; it does not become the Goal Owner, approve a Contract change, perform the Owner's work by reviewing it, or replace final human Acceptance.
15206
+ - If review is required but no review mechanism is available, report that exact unpersisted gate. Do not invent a completed review.
15207
+
15208
+ ### Phase 5 - Execute one bounded commitment
15209
+
15210
+ - Perform or delegate one coherent, bounded attempt through the owning work domain. Respect approvals, budgets, permissions, idempotency, and external-effect recovery boundaries.
15211
+ - Preserve candidate, environment, and evidence identity across action and verification. Do not retry an external effect whose outcome is unknown.
15212
+ - A Run ending, a task completing, or an artifact existing is not Goal completion. It is an observation to evaluate against the Contract.
15213
+
15214
+ ### Phase 6 - Observe and checkpoint
15215
+
15216
+ - Separate activity (what was attempted), output (what was produced), and Evidence (what proves an external or criterion-relevant fact).
15217
+ - Compare fresh Evidence and feedback with every affected required criterion, the current hypothesis, guardrails, and deadlines.
15218
+ - Call \`rudder_goal_progress\` only for meaningful advancement, Evidence, or a named bottleneck backed by valid evidence references. Do not manufacture an evidence reference to record narration.
15219
+ - Treat the resulting judgment as the Checkpoint for routing. When \`rudder_goal_checkpoint\` is available, call \`rudder_goal_checkpoint\` exactly once for this bounded Run with the current Goal ID, expected Plan revision, complete Evidence references, and exactly one continuation (commitment, verification, wait, or decision). Include a full next Plan payload only when Replan changed the strategy. Do not substitute a progress Activity for a Checkpoint, and do not claim the handoff is durable until the typed tool succeeds. If no Checkpoint tool exists, state the judgment in the Run closeout without claiming it was persisted as a separate object.
15220
+
15221
+ ### Phase 7 - Choose exactly one primary continuation route
15222
+
15223
+ - **Continue:** the Plan is still viable; execute the next bounded commitment now when possible.
15224
+ - **Replan:** Evidence or feedback invalidated the current path; return to Phase 3.
15225
+ - **Wait:** name the external fact, event, time, or actor being awaited, plus the resume trigger, expiry, and safe fallback. A known wait is not blocked. Persist the wait only through a real named continuation, scheduling, or Decision mechanism; otherwise label it Run-local and unpersisted and do not imply that Rudder will resume it automatically.
15226
+ - **Human decision:** provide the exact question, affected boundary, Evidence, recommendation, options, response deadline, and safe fallback. Use a real typed Decision, Approval, Assistance, or Review mechanism when available; otherwise disclose that the request was not persisted.
15227
+ - **Contract change:** call \`rudder_goal_change_propose\` with the current contract revision, exact before/after meaning, rationale, and supporting Evidence. Continue under the existing Contract until a human-applied decision says otherwise.
15228
+ - **Blocked audit:** use Phase 8. Do not transfer responsibility on the first failure.
15229
+ - **Result Proposal:** use Phase 9 only when every required criterion can be honestly mapped to fresh Evidence or an explicit non-success verdict.
15230
+
15231
+ ### Phase 8 - Audit a possible block
15232
+
15233
+ - Do not mark or claim the Goal blocked the first time a blocker appears.
15234
+ - If the same blocker persists for three consecutive Goal turns, first perform a Replan audit and look for a materially different path.
15235
+ - If Replan finds a viable path, continue through that path.
15236
+ - If Replan still cannot produce meaningful progress, report the Goal as operationally blocked and ask for the exact human input or external-state change required.
15237
+ - Resuming after a blocked conclusion starts a fresh three-turn audit.
15238
+ - Do not use blocked merely because the work is hard, slow, uncertain, incomplete, or would benefit from clarification.
15239
+ - Judge whether the blocker is materially the same from recent Goal history; no blocker fingerprint schema is required. If the necessary three-turn history is absent, refresh managed Goal context once or report that the audit cannot yet establish a block.
15240
+
15241
+ ### Phase 9 - Review and propose the result
15242
+
15243
+ - Build a criterion-to-Evidence packet with the current contract revision, evidence identity and freshness, guardrail state, unresolved risk, and the mode-specific proposed result.
15244
+ - If policy requires a Result review, route the packet through the available Review or Verification mechanism first. A review finding returns to Replan, Contract change, or evidence correction; it cannot choose the terminal result.
15245
+ - Call \`rudder_goal_result_propose\` only after the evidence packet passes required preflight and any required review. No Evidence means no successful terminal proposal.
15246
+ - Stop execution while a Result Proposal is ready for human Acceptance. Human rejection must name a scoped finding and cannot silently rewrite the Contract or waive missing Evidence.
15247
+
15248
+ ### Required turn closeout
15249
+
15250
+ Before ending the Run, state: the phase reached, what materially changed, the Evidence observed or still missing, the primary continuation route, and the next responsible actor or resume trigger. Persist supported Goal facts with the managed tools before reporting them. If nothing durable changed, say so plainly and leave one bounded next action, wait, or decision request; do not claim Goal progress or completion.`;
15065
15251
  var GOAL_STARTED_PROMPT_TEMPLATE = `You are agent {{agent.id}} ({{agent.name}}). A Goal has started and you are responsible for advancing it.
15066
15252
 
15067
15253
  {{context.rudderWorkspace.orgResourcesPrompt}}
15068
15254
 
15069
15255
  ${RUDDER_GOAL_RUNTIME_BOUNDARY}
15070
15256
 
15257
+ ${RUDDER_GOAL_ADVANCEMENT_PROTOCOL}
15258
+
15071
15259
  ## Goal Runtime Context
15072
15260
 
15073
15261
  **Goal:** {{context.goalRuntime.goalTitle}}
@@ -15079,16 +15267,28 @@ ${RUDDER_GOAL_RUNTIME_BOUNDARY}
15079
15267
  **Current contract:**
15080
15268
  {{context.goalRuntime.currentContract}}
15081
15269
 
15270
+ **Current Plan:**
15271
+ {{context.goalRuntime.currentPlan}}
15272
+
15082
15273
  **Continuation:**
15083
15274
  {{context.goalRuntime.continuation}}
15084
15275
 
15085
- Advance this Goal from the current contract and continuation. Preserve the stated outcome and contract boundaries; do not silently redefine them.`;
15276
+ **Latest checkpoint facts:**
15277
+ {{context.goalRuntime.latestCheckpoint}}
15278
+
15279
+ ## Wake Entry - Goal Started
15280
+
15281
+ Start at Plan/Replan because activation already confirmed the Contract. Validate and use the persisted initial Plan before replacing it. Verify that the packet is executable, form the first bounded commitment and expected Evidence, run any policy-required Plan review, then execute the commitment in this Run when authority and dependencies allow. Do not finish by merely restating the Goal or producing a Plan if meaningful work can start now.
15282
+
15283
+ Preserve the stated outcome and Contract boundaries. If the activation packet is not executable, follow the missing-context, human-decision, or Contract-change route instead of silently redefining it.`;
15086
15284
  var GOAL_FEEDBACK_PROMPT_TEMPLATE = `You are agent {{agent.id}} ({{agent.name}}). New feedback requires your review on a Goal you own.
15087
15285
 
15088
15286
  {{context.rudderWorkspace.orgResourcesPrompt}}
15089
15287
 
15090
15288
  ${RUDDER_GOAL_RUNTIME_BOUNDARY}
15091
15289
 
15290
+ ${RUDDER_GOAL_ADVANCEMENT_PROTOCOL}
15291
+
15092
15292
  ## Goal Runtime Context
15093
15293
 
15094
15294
  **Goal:** {{context.goalRuntime.goalTitle}}
@@ -15100,9 +15300,15 @@ ${RUDDER_GOAL_RUNTIME_BOUNDARY}
15100
15300
  **Current contract:**
15101
15301
  {{context.goalRuntime.currentContract}}
15102
15302
 
15303
+ **Current Plan:**
15304
+ {{context.goalRuntime.currentPlan}}
15305
+
15103
15306
  **Continuation:**
15104
15307
  {{context.goalRuntime.continuation}}
15105
15308
 
15309
+ **Latest checkpoint facts:**
15310
+ {{context.goalRuntime.latestCheckpoint}}
15311
+
15106
15312
  ## Goal Feedback
15107
15313
 
15108
15314
  **Feedback ID:** {{context.goalRuntime.feedbackId}}
@@ -15110,13 +15316,25 @@ ${RUDDER_GOAL_RUNTIME_BOUNDARY}
15110
15316
  **Feedback body:**
15111
15317
  {{context.goalRuntime.feedbackBody}}
15112
15318
 
15113
- Review the feedback against the current Goal contract, then continue from the recorded continuation. Treat any outcome or contract change as an explicit proposal instead of silently changing the Goal.`;
15319
+ ## Wake Entry - Goal Feedback
15320
+
15321
+ Classify the feedback before acting:
15322
+
15323
+ - new fact or Evidence -> observe and checkpoint;
15324
+ - strategy guidance inside the Contract -> Plan/Replan;
15325
+ - outcome, criteria, boundary, deadline, authority, or guardrail change -> Contract-change proposal;
15326
+ - review or result finding -> scoped remediation, evidence correction, or Replan;
15327
+ - question or clarification -> answer it without treating it as implicit authorization.
15328
+
15329
+ Reconcile the feedback with newer Goal facts, then continue from the selected route in this Run when possible. Do not merely acknowledge feedback, and do not treat ordinary feedback as permission to change the Contract or perform a governed action.`;
15114
15330
  var GOAL_CHANGE_DECIDED_PROMPT_TEMPLATE = `You are agent {{agent.id}} ({{agent.name}}). A human decided a proposed change to a Goal you own.
15115
15331
 
15116
15332
  {{context.rudderWorkspace.orgResourcesPrompt}}
15117
15333
 
15118
15334
  ${RUDDER_GOAL_RUNTIME_BOUNDARY}
15119
15335
 
15336
+ ${RUDDER_GOAL_ADVANCEMENT_PROTOCOL}
15337
+
15120
15338
  ## Goal Runtime Context
15121
15339
 
15122
15340
  **Goal:** {{context.goalRuntime.goalTitle}}
@@ -15128,9 +15346,15 @@ ${RUDDER_GOAL_RUNTIME_BOUNDARY}
15128
15346
  **Current contract:**
15129
15347
  {{context.goalRuntime.currentContract}}
15130
15348
 
15349
+ **Current Plan:**
15350
+ {{context.goalRuntime.currentPlan}}
15351
+
15131
15352
  **Continuation:**
15132
15353
  {{context.goalRuntime.continuation}}
15133
15354
 
15355
+ **Latest checkpoint facts:**
15356
+ {{context.goalRuntime.latestCheckpoint}}
15357
+
15134
15358
  ## Goal Change Decision
15135
15359
 
15136
15360
  **Decision:** {{context.goalRuntime.decision}}
@@ -15139,7 +15363,46 @@ ${RUDDER_GOAL_RUNTIME_BOUNDARY}
15139
15363
  **Decision note:**
15140
15364
  {{context.goalRuntime.decisionNote}}
15141
15365
 
15142
- Continue from the current Goal contract and this human decision. Do not apply a rejected change or silently reinterpret the decision.`;
15366
+ ## Wake Entry - Goal Change Decision
15367
+
15368
+ - If the decision is approved and applied, treat the supplied latest Contract revision as authoritative, invalidate Plan assumptions tied to the prior revision, and Replan before the next bounded commitment.
15369
+ - If the proposal was rejected, preserve the current Contract, use the decision note as feedback, and find a viable path inside the accepted boundaries. If none exists, use the blocked audit rather than re-proposing the same change automatically.
15370
+ - If the proposal is superseded, cancelled, stale, or otherwise not applied, do not assume its patch changed the Contract; refresh managed Goal context when the authoritative revision is unclear.
15371
+
15372
+ Continue from the resulting Contract and decision state in this Run when possible. Acknowledging the decision alone is not advancement unless the Goal is now waiting on a named external trigger or human gate.`;
15373
+ var GOAL_CONTINUATION_PROMPT_TEMPLATE = `You are agent {{agent.id}} ({{agent.name}}). A prior bounded Goal Run persisted a checkpoint and this continuation wake is ready.
15374
+
15375
+ {{context.rudderWorkspace.orgResourcesPrompt}}
15376
+
15377
+ ${RUDDER_GOAL_RUNTIME_BOUNDARY}
15378
+
15379
+ ${RUDDER_GOAL_ADVANCEMENT_PROTOCOL}
15380
+
15381
+ ## Goal Runtime Context
15382
+
15383
+ **Goal:** {{context.goalRuntime.goalTitle}}
15384
+ **Goal ID:** {{context.goalRuntime.goalId}}
15385
+
15386
+ **Goal outcome:**
15387
+ {{context.goalRuntime.goalOutcome}}
15388
+
15389
+ **Current contract:**
15390
+ {{context.goalRuntime.currentContract}}
15391
+
15392
+ **Current Plan:**
15393
+ {{context.goalRuntime.currentPlan}}
15394
+
15395
+ **Continuation:**
15396
+ {{context.goalRuntime.continuation}}
15397
+
15398
+ **Latest checkpoint facts:**
15399
+ {{context.goalRuntime.latestCheckpoint}}
15400
+
15401
+ ## Wake Entry - Goal Continuation
15402
+
15403
+ The prior Run has already persisted the checkpoint named above. Reconstruct the current Contract, Plan revision, Evidence, and continuation before acting. Continue only the checkpoint's bounded commitment or verification when its wake condition is satisfied and the Goal is still active. Do not replay the prior action blindly, create a duplicate checkpoint for the same effect, or treat checkpoint persistence as Goal completion.
15404
+
15405
+ If the checkpoint instead records a wait or human decision, this wake is unexpected: do not invent authorization or execute the waiting action. Refresh managed Goal context, report the mismatch, and leave the Goal waiting for its named actor or external trigger. If a ready Result Proposal exists, stop and wait for human Acceptance.`;
15143
15406
  var ISSUE_ASSIGNEE_EXECUTION_RAIL = "Before doing issue-scoped execution as the assignee, check out the assigned issue. If checkout returns `409`, do not retry; stop and report the ownership conflict.";
15144
15407
  var ISSUE_ASSIGN_PROMPT_TEMPLATE = `You are agent {{agent.id}} ({{agent.name}}). You have been assigned to work on an issue.
15145
15408
 
@@ -16760,7 +17023,7 @@ function registerChatCommands(program) {
16760
17023
  { includeCompany: false }
16761
17024
  );
16762
17025
  addCommonClientOptions(
16763
- chat.command("get").description(getAgentCliCapabilityById("chat.get").description).argument("<chatId>", "Chat conversation ID").action(async (chatId, opts) => {
17026
+ chat.command("get").description(getAgentCliCapabilityById("chat.get").description).argument("<chatId>", "Chat conversation UUID or cht_<uuid-prefix> short ref").action(async (chatId, opts) => {
16764
17027
  try {
16765
17028
  const ctx = resolveCommandContext(opts);
16766
17029
  const row = await ctx.api.get(`/api/chats/${encodeURIComponent(chatId)}`);
@@ -16771,7 +17034,7 @@ function registerChatCommands(program) {
16771
17034
  })
16772
17035
  );
16773
17036
  addCommonClientOptions(
16774
- chat.command("messages").description(getAgentCliCapabilityById("chat.messages").description).argument("<chatId>", "Chat conversation ID").option("--include-transcript", "Include assistant transcript entries").option("--include-output", "Alias for --include-transcript").option("--include-outputs", "Alias for --include-transcript").option("--limit <n>", "Maximum messages to print").option("--cursor <cursor>", "Stable message cursor returned in page.nextCursor").option("--max-output-chars <n>", "Maximum transcript output chars for human output", "1200").action(async (chatId, opts) => {
17037
+ chat.command("messages").description(getAgentCliCapabilityById("chat.messages").description).argument("<chatId>", "Chat conversation UUID or cht_<uuid-prefix> short ref").option("--include-transcript", "Include assistant transcript entries").option("--include-output", "Alias for --include-transcript").option("--include-outputs", "Alias for --include-transcript").option("--limit <n>", "Maximum messages to print").option("--cursor <cursor>", "Stable message cursor returned in page.nextCursor").option("--max-output-chars <n>", "Maximum transcript output chars for human output", "1200").action(async (chatId, opts) => {
16775
17038
  try {
16776
17039
  const ctx = resolveCommandContext(opts);
16777
17040
  const page = await getChatMessagesPage(ctx, chatId, {
@@ -16789,7 +17052,7 @@ function registerChatCommands(program) {
16789
17052
  })
16790
17053
  );
16791
17054
  addCommonClientOptions(
16792
- chat.command("transcript").description(getAgentCliCapabilityById("chat.transcript").description).argument("<chatId>", "Chat conversation ID").option("--limit <n>", "Maximum messages to print").option("--cursor <cursor>", "Stable message cursor returned in page.nextCursor").option("--max-chars <n>", "Maximum transcript chars per message", "1200").option("--max-output-chars <n>", "Alias for --max-chars").action(async (chatId, opts) => {
17055
+ chat.command("transcript").description(getAgentCliCapabilityById("chat.transcript").description).argument("<chatId>", "Chat conversation UUID or cht_<uuid-prefix> short ref").option("--limit <n>", "Maximum messages to print").option("--cursor <cursor>", "Stable message cursor returned in page.nextCursor").option("--max-chars <n>", "Maximum transcript chars per message", "1200").option("--max-output-chars <n>", "Alias for --max-chars").action(async (chatId, opts) => {
16793
17056
  try {
16794
17057
  const ctx = resolveCommandContext(opts);
16795
17058
  const page = await getChatMessagesPage(ctx, chatId, {
@@ -16808,15 +17071,15 @@ function registerChatCommands(program) {
16808
17071
  })
16809
17072
  );
16810
17073
  addCommonClientOptions(
16811
- chat.command("read").description(getAgentCliCapabilityById("chat.read").description).argument("<chatId>", "Chat conversation ID").option("--include-transcript", "Include assistant transcript entries").option("--include-output", "Alias for --include-transcript").option("--include-outputs", "Alias for --include-transcript").option("--limit <n>", "Maximum recent messages", "20").option("--turn-limit <n>", "Alias for --limit for chat turn snapshots").option("--cursor <cursor>", "Stable message cursor returned in page.nextCursor").option("--max-output-chars <n>", "Maximum transcript output chars for human output", "1200").addHelpText("after", formatExamplesAndCautions({
17074
+ chat.command("read").description(getAgentCliCapabilityById("chat.read").description).argument("<chatId>", "Chat conversation UUID or cht_<uuid-prefix> short ref").option("--include-transcript", "Include assistant transcript entries").option("--include-output", "Alias for --include-transcript").option("--include-outputs", "Alias for --include-transcript").option("--limit <n>", "Maximum recent messages", "20").option("--turn-limit <n>", "Alias for --limit for chat turn snapshots").option("--cursor <cursor>", "Stable message cursor returned in page.nextCursor").option("--max-output-chars <n>", "Maximum transcript output chars for human output", "1200").addHelpText("after", formatExamplesAndCautions({
16812
17075
  examples: [
16813
17076
  {
16814
17077
  description: "Read a bounded conversation page with transcript output when needed:",
16815
- command: "rudder chat read <chat-id> --turn-limit 20 --include-output"
17078
+ command: "rudder chat read <chat-id-or-cht-ref> --turn-limit 20 --include-output"
16816
17079
  },
16817
17080
  {
16818
17081
  description: "Continue from a stable cursor in scripts:",
16819
- command: "rudder chat read <chat-id> --cursor <nextCursor> --json"
17082
+ command: "rudder chat read <chat-id-or-cht-ref> --cursor <nextCursor> --json"
16820
17083
  }
16821
17084
  ],
16822
17085
  cautions: [
@@ -16873,15 +17136,15 @@ function registerChatCommands(program) {
16873
17136
  { includeCompany: false }
16874
17137
  );
16875
17138
  addCommonClientOptions(
16876
- chat.command("send").description(getAgentCliCapabilityById("chat.send").description).argument("<chatId>", "Chat conversation ID").option("--body <text>", "Message body").option("--edit-user-message-id <id>", "Regenerate/edit from a prior user message").addHelpText("after", formatExamplesAndCautions({
17139
+ chat.command("send").description(getAgentCliCapabilityById("chat.send").description).argument("<chatId>", "Chat conversation UUID or cht_<uuid-prefix> short ref").option("--body <text>", "Message body").option("--edit-user-message-id <id>", "Regenerate/edit from a prior user message").addHelpText("after", formatExamplesAndCautions({
16877
17140
  examples: [
16878
17141
  {
16879
17142
  description: "Append a short agent-authored status note:",
16880
- command: 'rudder chat send <chat-id> --body "Status: validation is running"'
17143
+ command: 'rudder chat send <chat-id-or-cht-ref> --body "Status: validation is running"'
16881
17144
  },
16882
17145
  {
16883
17146
  description: "Send a longer or multiline note through stdin:",
16884
- command: "printf '%s\\n' 'Multiline note' | rudder chat send <chat-id>"
17147
+ command: "printf '%s\\n' 'Multiline note' | rudder chat send <chat-id-or-cht-ref>"
16885
17148
  }
16886
17149
  ],
16887
17150
  cautions: [
@@ -16904,7 +17167,7 @@ function registerChatCommands(program) {
16904
17167
  })
16905
17168
  );
16906
17169
  addCommonClientOptions(
16907
- chat.command("archive").description(getAgentCliCapabilityById("chat.archive").description).argument("<chatId>", "Chat conversation ID").action(async (chatId, opts) => {
17170
+ chat.command("archive").description(getAgentCliCapabilityById("chat.archive").description).argument("<chatId>", "Chat conversation UUID or cht_<uuid-prefix> short ref").action(async (chatId, opts) => {
16908
17171
  try {
16909
17172
  const ctx = resolveCommandContext(opts);
16910
17173
  const payload = updateChatConversationSchema.parse({ status: "archived" });
@@ -16948,7 +17211,7 @@ function filterChatSearchRows(rows, query, scope) {
16948
17211
  }
16949
17212
  function formatChatConversation(row) {
16950
17213
  return {
16951
- id: row.id,
17214
+ id: row.shortRef ?? row.id,
16952
17215
  title: row.title,
16953
17216
  status: row.status,
16954
17217
  preferredAgentId: row.preferredAgentId ?? "-",
@@ -16959,7 +17222,7 @@ function formatChatConversation(row) {
16959
17222
  }
16960
17223
  function formatChatSearchResult(row, maxChars) {
16961
17224
  return {
16962
- id: row.id,
17225
+ id: row.shortRef ?? row.id,
16963
17226
  title: row.title,
16964
17227
  status: row.status,
16965
17228
  lastMessageAt: row.lastMessageAt ?? "-",
@@ -18406,6 +18669,25 @@ function registerGoalCommands(program) {
18406
18669
  }
18407
18670
  })
18408
18671
  );
18672
+ addCommonClientOptions(
18673
+ goal.command("checkpoint").description(getAgentCliCapabilityById("goal.checkpoint").description).argument("<goalId>", "Goal ID from the current Goal Runtime Context").requiredOption("--summary <text>", "Checkpoint summary").requiredOption("--evidence-refs <json>", "JSON array of URI-like evidence references").requiredOption("--expected-plan-revision <n>", "Current Goal Plan revision").option("--plan <json>", "Optional next Plan revision payload").requiredOption("--continuation <json>", "JSON continuation payload").requiredOption("--idempotency-key <key>", "Stable key for safe retry").action(async (goalId, opts) => {
18674
+ try {
18675
+ const ctx = resolveCommandContext(opts);
18676
+ const payload = createGoalCheckpointSchema.parse({
18677
+ summary: opts.summary,
18678
+ evidenceRefs: parseJsonArray(opts.evidenceRefs, "evidence refs"),
18679
+ expectedPlanRevision: Number(opts.expectedPlanRevision),
18680
+ ...opts.plan !== void 0 ? { plan: parseJsonObject3(opts.plan, "plan") } : {},
18681
+ continuation: parseJsonObject3(opts.continuation, "continuation"),
18682
+ idempotencyKey: opts.idempotencyKey
18683
+ });
18684
+ const checkpoint = await ctx.api.post(`/api/goals/${goalId}/checkpoint`, payload);
18685
+ printOutput(checkpoint, { json: ctx.json });
18686
+ } catch (err) {
18687
+ handleCommandError(err);
18688
+ }
18689
+ })
18690
+ );
18409
18691
  const change = goal.command("change").description("Goal contract change operations");
18410
18692
  addCommonClientOptions(
18411
18693
  change.command("propose").description(getAgentCliCapabilityById("goal.change.propose").description).argument("<goalId>", "Goal ID from the current Goal Runtime Context").requiredOption("--contract-revision <n>", "Current Goal contract revision").requiredOption("--after-contract <json>", "JSON object containing only proposed contract field changes").requiredOption("--rationale <text>", "Why the current Goal contract should change").option("--evidence-refs <json>", "JSON array of URI-like evidence references", "[]").requiredOption("--idempotency-key <key>", "Stable key for safe retry").action(async (goalId, opts) => {