openmates 0.15.0-alpha.64 → 0.15.0-alpha.65

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.
@@ -17908,6 +17908,12 @@ function withAppSkillRunOptions(input, options) {
17908
17908
  }
17909
17909
  };
17910
17910
  }
17911
+ function normalizeOptionalGoal(value) {
17912
+ if (value === void 0) return null;
17913
+ const trimmed = value.trim();
17914
+ if (!trimmed) throw new OpenMatesConfigError("Chat goal must not be empty");
17915
+ return trimmed;
17916
+ }
17911
17917
  var IDEABUCKET_DEFAULT_PROCESSING_PROMPT2 = `These are my captured ideas for today. Please process them, group related thoughts, suggest next actions, and ask clarifying questions where needed:
17912
17918
 
17913
17919
  If an idea requires deeper work, create or suggest sub-chats for focused research, planning, todos, docs, or implementation.`;
@@ -18905,7 +18911,11 @@ var OpenMatesChats = class {
18905
18911
  async send(message, options = {}) {
18906
18912
  const history = normalizeHistory(options.history);
18907
18913
  const finalMessage = hasRememberMessageReference(message) ? rewriteRememberMessageReferences(message, rememberableMessagesFromRecords(history)) : message;
18908
- if (options.saveToAccount === true) {
18914
+ const goal = normalizeOptionalGoal(options.goal);
18915
+ if (goal && options.saveToAccount === false) {
18916
+ throw new OpenMatesConfigError("Chat goals require a saved account chat. Omit saveToAccount or set saveToAccount: true.");
18917
+ }
18918
+ if (options.saveToAccount === true || goal) {
18909
18919
  return this.sendSaved(finalMessage, options);
18910
18920
  }
18911
18921
  const result = await this.client.request("/v1/sdk/chats", {
@@ -19051,6 +19061,13 @@ var OpenMatesChats = class {
19051
19061
  if (terminal.state !== "TERMINAL") {
19052
19062
  throw new OpenMatesConfigError("Saved chat recovery did not reach terminal persistence");
19053
19063
  }
19064
+ const goal = normalizeOptionalGoal(options.goal);
19065
+ const plan = goal ? await this.createAttachedGoalPlan({
19066
+ chatId,
19067
+ chatKey,
19068
+ goal,
19069
+ title: normalizeOptionalGoal(options.goalTitle) ?? options.title ?? goal
19070
+ }) : null;
19054
19071
  return {
19055
19072
  content: recovered.content,
19056
19073
  category: recovered.category,
@@ -19058,9 +19075,23 @@ var OpenMatesChats = class {
19058
19075
  chat_id: result.chat_id ?? chatId,
19059
19076
  task_id: result.task_id,
19060
19077
  preflight: result.preflight,
19061
- terminal
19078
+ terminal,
19079
+ ...plan ? { plan } : {}
19062
19080
  };
19063
19081
  }
19082
+ async createAttachedGoalPlan(input) {
19083
+ const masterKey = await this.client.masterKey();
19084
+ const payload = await buildCreateUserPlanInput(masterKey, {
19085
+ title: input.title,
19086
+ goal: input.goal,
19087
+ primaryChatId: input.chatId,
19088
+ primaryChatKey: input.chatKey,
19089
+ status: "draft"
19090
+ });
19091
+ const response = await this.client.request("/v1/user-plans", payload);
19092
+ if (!response.plan) throw new OpenMatesApiError(500, { detail: "User plan response missing plan" });
19093
+ return toPublicPlan(await decryptUserPlan(response.plan, masterKey));
19094
+ }
19064
19095
  async pollRecoveryClaim(taskId, timeoutMs, pollIntervalMs) {
19065
19096
  if (!Number.isFinite(timeoutMs) || !Number.isFinite(pollIntervalMs) || timeoutMs <= 0 || pollIntervalMs <= 0) {
19066
19097
  throw new OpenMatesConfigError("Recovery timeout and poll interval must be finite and positive");
@@ -65447,7 +65478,7 @@ async function main() {
65447
65478
  }
65448
65479
  if (parsed.flags.help === true && !subcommand) {
65449
65480
  if (command === "chat") {
65450
- printPlansHelp();
65481
+ printGoalChatHelp();
65451
65482
  return;
65452
65483
  }
65453
65484
  if (command === "chats") {
@@ -65613,7 +65644,7 @@ async function main() {
65613
65644
  return;
65614
65645
  }
65615
65646
  if (command === "chat" && parsed.flags.goal) {
65616
- await handlePlans(client, "create", [], parsed.flags, redactor);
65647
+ await handleGoalChat(client, parsed.flags, redactor);
65617
65648
  return;
65618
65649
  }
65619
65650
  if (command === "tasks") {
@@ -67001,6 +67032,68 @@ function printPlanOutput(plan, flags) {
67001
67032
  printHistoryCommands(plan.encrypted.history ?? null);
67002
67033
  }
67003
67034
  }
67035
+ function normalizeGoalFlag(value) {
67036
+ if (typeof value !== "string" || !value.trim()) {
67037
+ throw new Error("Missing goal. Usage: openmates chat --goal <goal>");
67038
+ }
67039
+ return value.trim();
67040
+ }
67041
+ async function handleGoalChat(client, flags, redactor) {
67042
+ if (resolveApiKey(flags)) {
67043
+ throw new Error("openmates chat --goal uses your paired CLI session. For API-key clients, use the npm or pip SDK chats.send(..., { goal }).");
67044
+ }
67045
+ if (!client.hasSession()) {
67046
+ throw new Error("openmates chat --goal requires login. Run 'openmates login' first.");
67047
+ }
67048
+ const goal = normalizeGoalFlag(flags.goal);
67049
+ const result = await sendMessageStreaming(
67050
+ client,
67051
+ {
67052
+ message: typeof flags.message === "string" && flags.message.trim() ? flags.message.trim() : goal,
67053
+ chatId: void 0,
67054
+ incognito: false,
67055
+ json: flags.json === true,
67056
+ autoApproveSubChats: flags["auto-approve"] === true,
67057
+ autoApproveMemories: flags["auto-approve-memories"] === true,
67058
+ acceptTaskProposals: flags["accept-task-proposals"] === true,
67059
+ piiDetection: flags["no-pii-detection"] !== true,
67060
+ responseTimeoutMs: parseResponseTimeoutMs(flags),
67061
+ ...teamContextFromFlags(flags)
67062
+ },
67063
+ redactor
67064
+ );
67065
+ if (!("chatId" in result) || !result.chatId) {
67066
+ throw new Error("Goal chat did not return a saved chat id.");
67067
+ }
67068
+ const masterKey = client.getMasterKeyBytes();
67069
+ const linkContext = await resolvePlanLinkKeyContext(client, masterKey, flags, {
67070
+ primaryChatId: result.chatId,
67071
+ linkedProjectIds: splitCsvFlag(flags.project ?? flags.projects)
67072
+ });
67073
+ const planInput = await buildCreateUserPlanInput(masterKey, {
67074
+ title: typeof flags.title === "string" && flags.title.trim() ? flags.title.trim() : goal,
67075
+ summary: typeof flags.summary === "string" ? flags.summary : "",
67076
+ goal,
67077
+ status: normalizePlanStatus(typeof flags.status === "string" ? flags.status : void 0),
67078
+ primaryChatId: linkContext.primaryChatId,
67079
+ primaryChatKey: linkContext.primaryChatKey,
67080
+ linkedProjectIds: linkContext.linkedProjectIds,
67081
+ linkedProjectKeys: linkContext.linkedProjectKeys
67082
+ });
67083
+ const plan = await decryptUserPlan(await client.createUserPlan(planInput), masterKey);
67084
+ if (flags.json === true) {
67085
+ printJson2({ ...result, chat_id: result.chatId, plan: planToJson(plan) });
67086
+ return;
67087
+ }
67088
+ const shortChatId = result.chatId.slice(0, 8);
67089
+ process.stdout.write(
67090
+ `${SEP}
67091
+ \x1B[2mPlan attached: ${plan.shortId} (${plan.status.replaceAll("_", " ")})\x1B[0m
67092
+ \x1B[2mPlan: openmates plans show ${plan.shortId}\x1B[0m
67093
+ \x1B[2mContinue: openmates chats send --chat ${shortChatId} "your message"\x1B[0m
67094
+ `
67095
+ );
67096
+ }
67004
67097
  async function handleProjects(client, subcommand, rest, flags, redactor) {
67005
67098
  if (!subcommand || subcommand === "help" || flags.help === true) {
67006
67099
  printProjectsHelp();
@@ -74272,6 +74365,7 @@ Commands:
74272
74365
  openmates signup Create an account from the terminal
74273
74366
  openmates logout Log out and clear session
74274
74367
  openmates whoami [--json] Show account info
74368
+ openmates chat --goal <goal> Start a saved chat with an attached draft plan
74275
74369
  openmates chats [--help] Chat commands (list, search, show, ...)
74276
74370
  openmates tasks [--help] Task commands (list, create, board, ...)
74277
74371
  openmates plans [--help] Plan commands (list, create, approve, checks, ...)
@@ -74716,6 +74810,25 @@ Notes:
74716
74810
  pause currently moves a plan back to awaiting_confirmation; resume sets it active.
74717
74811
  Normal output decrypts plan fields locally; use --json for machine-readable plaintext fields.`);
74718
74812
  }
74813
+ function printGoalChatHelp() {
74814
+ console.log(`Goal chat command:
74815
+ openmates chat --goal <goal> [--title <title>] [--project <id>] [--json]
74816
+
74817
+ Starts a new saved chat and attaches a minimal encrypted draft Plan to it.
74818
+ Use this for lightweight agentic work that should keep a durable goal, checks,
74819
+ and continuation state available from the chat.
74820
+
74821
+ Options:
74822
+ --goal <goal> Required durable goal for the attached Plan
74823
+ --title <title> Optional Plan title (defaults to the goal)
74824
+ --summary <text> Optional Plan summary
74825
+ --project <id> Also link the Plan to a Project
74826
+ --json Output chat and Plan details as JSON
74827
+
74828
+ Examples:
74829
+ openmates chat --goal "Improve the onboarding email and verify it reads clearly"
74830
+ openmates chat --goal "Ship the docs update" --title "Docs launch" --json`);
74831
+ }
74719
74832
  function printProjectsHelp() {
74720
74833
  console.log(`Projects commands:
74721
74834
  openmates projects ask <name> [--description <text>] [--json]
package/dist/cli.js CHANGED
@@ -2,7 +2,7 @@
2
2
  import {
3
3
  getExtForLang,
4
4
  serializeToYaml
5
- } from "./chunk-VRJTT4ML.js";
5
+ } from "./chunk-XBSHGFYK.js";
6
6
  import "./chunk-MLWBMJEN.js";
7
7
  export {
8
8
  getExtForLang,
package/dist/index.d.ts CHANGED
@@ -5950,6 +5950,8 @@ interface ChatCreateOptions {
5950
5950
  focusMode?: FocusModeSelection;
5951
5951
  chatId?: string;
5952
5952
  title?: string;
5953
+ goal?: string;
5954
+ goalTitle?: string;
5953
5955
  }
5954
5956
  interface ChatSendOptions extends ChatCreateOptions {
5955
5957
  history?: Array<Record<string, unknown>> | {
@@ -6367,6 +6369,7 @@ declare class OpenMatesChats {
6367
6369
  retry(options: ChatRetryOptions): Promise<Record<string, unknown>>;
6368
6370
  send(message: string, options?: ChatSendOptions): Promise<ChatResponse>;
6369
6371
  private sendSaved;
6372
+ private createAttachedGoalPlan;
6370
6373
  private pollRecoveryClaim;
6371
6374
  private openRecoveryClaim;
6372
6375
  export(chatId: string, options?: {
package/dist/index.js CHANGED
@@ -36,7 +36,7 @@ import {
36
36
  renderPlanList,
37
37
  renderSupportInfo,
38
38
  serializeToYaml
39
- } from "./chunk-VRJTT4ML.js";
39
+ } from "./chunk-XBSHGFYK.js";
40
40
  import "./chunk-MLWBMJEN.js";
41
41
  export {
42
42
  APP_SKILL_METADATA,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "openmates",
3
- "version": "0.15.0-alpha.64",
3
+ "version": "0.15.0-alpha.65",
4
4
  "description": "OpenMates CLI and SDK",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",