@todos-dev/cli 0.1.5 → 0.1.6

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/dist/index.js +19 -272
  2. package/package.json +7 -7
package/dist/index.js CHANGED
@@ -481,21 +481,13 @@ function text(s, details) {
481
481
  return { content: [{ type: "text", text: s }], details };
482
482
  }
483
483
 
484
- // src/lib/todoTools.ts
484
+ // src/lib/remoteTools.ts
485
485
  var REQUEST_TIMEOUT_MS = 1e4;
486
- var LIST_CAP = 8e3;
487
- function toolScope(step) {
488
- if (step.workspace?.projectId) return { kind: "project", projectId: step.workspace.projectId };
489
- if (step.chiefId) return { kind: "account", chiefId: step.chiefId };
490
- return null;
491
- }
492
- async function request(serverUrl, method, path, token, body) {
493
- const headers = { "Content-Type": "application/json" };
494
- if (token) headers["Authorization"] = `Bearer ${token}`;
486
+ async function request(serverUrl, path, token, body) {
495
487
  const res = await fetch(`${serverUrl}${path}`, {
496
- method,
497
- headers,
498
- ...body !== void 0 ? { body: JSON.stringify(body) } : {},
488
+ method: "POST",
489
+ headers: { "Content-Type": "application/json", ...token ? { Authorization: `Bearer ${token}` } : {} },
490
+ body: JSON.stringify(body),
499
491
  signal: AbortSignal.timeout(REQUEST_TIMEOUT_MS)
500
492
  });
501
493
  const json2 = await res.json().catch(() => null);
@@ -504,250 +496,22 @@ async function request(serverUrl, method, path, token, body) {
504
496
  function text2(s) {
505
497
  return { content: [{ type: "text", text: s }], details: {} };
506
498
  }
507
- function errorText(reply, fallback) {
508
- const msg = reply.body?.error;
509
- return typeof msg === "string" ? msg : `${fallback} (HTTP ${reply.status}).`;
510
- }
511
- function makeTodoTools(serverUrl, token, step) {
512
- return [
513
- makeListTodosTool(serverUrl, token, step),
514
- makeCreateTodoTool(serverUrl, token, step),
515
- makeUpdateTodoTool(serverUrl, token, step)
516
- ];
517
- }
518
- function makeListTodosTool(serverUrl, token, step) {
519
- const scope = toolScope(step);
520
- return {
521
- name: "list_todos",
522
- label: "List Todos",
523
- description: scope?.kind === "account" ? `List the todo boards of every project across the user's teams, grouped by project. Each project header carries its projectId (required by create_todo); each todo renders as "#<seq> [<phase>] <title> (id: <id>)".` : `List the todos in this project so you can see existing/related work and find a todo to update. The first line lists the project's tags with their ids (usable as update_todo's tagIds). Returns each todo as "#<seq> [<phase>] <title> (id: <id>) [tags: \u2026]"; todos you created are marked (yours).`,
524
- parameters: { type: "object", properties: {}, required: [], additionalProperties: false },
525
- async execute() {
526
- if (scope?.kind === "project") {
527
- const { projectId } = scope;
528
- const [reply, tagsReply] = await Promise.all([
529
- request(serverUrl, "GET", `/api/projects/${projectId}/todos`, token),
530
- request(serverUrl, "GET", `/api/projects/${projectId}/tags`, token)
531
- ]);
532
- if (!reply.ok) return text2(errorText(reply, "Failed to list todos"));
533
- const todos = reply.body ?? [];
534
- if (!todos.length) return text2("No todos in this project yet.");
535
- const tags = tagsReply.ok ? tagsReply.body ?? [] : [];
536
- const tagName = new Map(tags.map((t) => [t.id, t.name]));
537
- const header = tags.length ? `Project tags: ${tags.map((t) => `${t.name} (id: ${t.id})`).join(", ")}
538
- ` : "";
539
- const lines = todos.map((t) => {
540
- const mine = t.createdBy === step.agent.agentId ? " (yours)" : "";
541
- const names = (t.tagIds ?? []).map((id) => tagName.get(id)).filter(Boolean);
542
- const tagsStr = names.length ? ` [tags: ${names.join(", ")}]` : "";
543
- return `#${t.seqNum} [${t.phase}] ${t.title} (id: ${t.id})${tagsStr}${mine}`;
544
- });
545
- let out = header + lines.join("\n");
546
- if (out.length > LIST_CAP) out = out.slice(0, LIST_CAP) + "\n\u2026(truncated)";
547
- return text2(out);
548
- }
549
- if (scope?.kind === "account") {
550
- const reply = await request(serverUrl, "GET", `/api/machine/chief/todos?chiefId=${encodeURIComponent(scope.chiefId)}`, token);
551
- if (!reply.ok) return text2(errorText(reply, "Failed to list todos"));
552
- const projects = reply.body?.projects ?? [];
553
- if (!projects.length) return text2("No projects in your teams yet.");
554
- const blocks = projects.map((p) => {
555
- const lines = p.todos.length ? p.todos.map((t) => `#${t.seqNum} [${t.phase}] ${t.title} (id: ${t.id})`).join("\n") : "(no todos)";
556
- return `## ${p.name} (projectId: ${p.id})
557
- ${lines}`;
558
- });
559
- let out = blocks.join("\n\n");
560
- if (out.length > LIST_CAP) out = out.slice(0, LIST_CAP) + "\n\u2026(truncated)";
561
- return text2(out);
562
- }
563
- return text2("No project context for this turn \u2014 todos are unavailable.");
564
- }
565
- };
566
- }
567
- function makeCreateTodoTool(serverUrl, token, step) {
568
- const scope = toolScope(step);
569
- const accountScope = scope?.kind === "account";
570
- return {
571
- name: "create_todo",
572
- label: "Create Todo",
573
- description: accountScope ? "Create a todo in one of the user's projects (projectId comes from list_todos's project headers). The new todo lands in that project's backlog and does NOT run automatically \u2014 propose it with propose_builds when it should run. Use a clear, actionable title and put the objective, boundaries, and acceptance criteria in spec." : "Create a follow-up todo for work you discovered but that is out of scope for the current task (e.g. a refactor, a separate bug, a next step). The new todo is added to the project backlog and does NOT run automatically \u2014 the user decides when to start it. Use a clear, actionable title and put the context/acceptance criteria in spec.",
574
- parameters: {
575
- type: "object",
576
- properties: {
577
- ...accountScope ? { projectId: { type: "string", description: "Target project id (from list_todos)." } } : {},
578
- title: { type: "string", description: "Short, actionable title for the work." },
579
- spec: { type: "string", description: "Details: what to do, why, and any acceptance criteria. Optional but recommended." }
580
- },
581
- required: accountScope ? ["projectId", "title"] : ["title"],
582
- additionalProperties: false
583
- },
499
+ function makeRemoteTools(serverUrl, token, step) {
500
+ return (step.remoteTools ?? []).map((def) => ({
501
+ name: def.name,
502
+ label: def.label,
503
+ description: def.description,
504
+ parameters: def.parameters,
584
505
  async execute(_id, params) {
585
- const p = params ?? {};
586
- const projectId = scope?.kind === "project" ? scope.projectId : p.projectId;
587
- if (!scope || !projectId) return text2(accountScope ? "A projectId is required (find it with list_todos)." : "No project context for this turn \u2014 cannot create a todo.");
588
- if (!p.title?.trim()) return text2("A title is required to create a todo.");
589
- const reply = await request(serverUrl, "POST", `/api/projects/${projectId}/todos`, token, {
590
- title: p.title,
591
- spec: p.spec ?? "",
592
- buildId: scope.kind === "account" ? scope.chiefId : step.conversationId
593
- });
594
- if (!reply.ok) return text2(errorText(reply, "Failed to create todo"));
595
- const t = reply.body;
596
- return text2(`Created todo #${t.seqNum} "${t.title}". It is in the backlog and will not run until the user starts it.`);
597
- }
598
- };
599
- }
600
- function makeUpdateTodoTool(serverUrl, token, step) {
601
- const scope = toolScope(step);
602
- return {
603
- name: "update_todo",
604
- label: "Update Todo",
605
- description: scope?.kind === "account" ? "Update a todo's title or spec \u2014 use this to groom a todo before proposing it: make the spec state the objective, boundaries, and acceptance criteria. You cannot change a todo's phase, assignment, or start a build." : `Update a todo YOU created (only your own \u2014 found via list_todos, marked "(yours)"). You can change its title, spec, or tags (tag ids come from the "Project tags" line of list_todos). Use this to refine a follow-up todo as you learn more. You cannot edit todos created by others or the user, change a todo's phase, or start a build.`,
606
- parameters: {
607
- type: "object",
608
- properties: {
609
- id: { type: "string", description: "The id of the todo to update (from list_todos)." },
610
- title: { type: "string", description: "New title (optional)." },
611
- spec: { type: "string", description: "New spec/description (optional)." },
612
- tagIds: { type: "array", items: { type: "string" }, description: `Replacement tag id list; ids come from list_todos's "Project tags" line (optional).` }
613
- },
614
- required: ["id"],
615
- additionalProperties: false
616
- },
617
- async execute(_id, params) {
618
- const p = params ?? {};
619
- if (!p.id) return text2("A todo id is required (find it with list_todos).");
620
- const patch = { buildId: scope?.kind === "account" ? scope.chiefId : step.conversationId };
621
- if (p.title !== void 0) patch.title = p.title;
622
- if (p.spec !== void 0) patch.spec = p.spec;
623
- if (p.tagIds !== void 0) patch.tagIds = p.tagIds;
624
- const reply = await request(serverUrl, "PATCH", `/api/todos/${p.id}`, token, patch);
625
- if (!reply.ok) return text2(errorText(reply, "Failed to update todo"));
626
- const t = reply.body;
627
- return text2(`Updated todo #${t.seqNum} "${t.title}".`);
506
+ const reply = await request(serverUrl, `/api/machine/tool/${step.stepId}`, token, { name: def.name, params });
507
+ if (!reply.ok) {
508
+ const msg = reply.body?.error;
509
+ return text2(typeof msg === "string" ? msg : `${def.name} failed (HTTP ${reply.status}).`);
510
+ }
511
+ return text2(typeof reply.body?.text === "string" ? reply.body.text : "");
628
512
  }
629
- };
630
- }
631
-
632
- // src/lib/chiefTools.ts
633
- function makeChiefTools(serverUrl, token, step) {
634
- return [
635
- makeProposeBuildsTool(serverUrl, token, step),
636
- makeRunBuildsTool(serverUrl, token, step),
637
- makeUpdateMemoryTool(serverUrl, token, step)
638
- ];
639
- }
640
- var DISPATCH_ITEMS_SCHEMA = {
641
- type: "array",
642
- minItems: 1,
643
- items: {
644
- type: "object",
645
- properties: {
646
- todoId: { type: "string", description: "The todo to run (id from list_todos)." },
647
- withPlan: { type: "boolean", description: "Start with a plan step the user confirms before implementation. Default false." },
648
- agentId: { type: "string", description: "Suggested agent (from the available-agents list). Omit to use the todo's own assignment." },
649
- thinkingLevel: { type: "string", description: "Suggested thinking level for the agent (only with agentId)." },
650
- reason: { type: "string", description: "One line on why this todo, this agent, now." }
651
- },
652
- required: ["todoId"],
653
- additionalProperties: false
654
- }
655
- };
656
- function itemsToBody(items) {
657
- return items.map((i) => ({
658
- todoId: i.todoId,
659
- ...i.withPlan !== void 0 ? { withPlan: i.withPlan } : {},
660
- ...i.agentId ? { agent: { agentId: i.agentId, ...i.thinkingLevel ? { thinkingLevel: i.thinkingLevel } : {} } } : {},
661
- ...i.reason ? { reason: i.reason } : {}
662
513
  }));
663
514
  }
664
- function makeProposeBuildsTool(serverUrl, token, step) {
665
- const chiefId = step.chiefId;
666
- return {
667
- name: "propose_builds",
668
- label: "Propose Builds",
669
- description: "Propose which todos to run next. This does NOT start anything \u2014 it creates a proposal card the user reviews, adjusts, and runs. Use this for work YOU are initiating; when the user has explicitly asked to run something, use run_builds instead. Pick the agent (agentId from the available-agents list) and thinking level per item to match the work; set withPlan for tasks that deserve a reviewed plan first. Groom each todo (update_todo: objective, boundaries, acceptance criteria) BEFORE proposing it. On success, reference the returned doc id in your reply as [Run N todos](doc:<id>) so the user sees the card.",
670
- parameters: {
671
- type: "object",
672
- properties: {
673
- items: DISPATCH_ITEMS_SCHEMA,
674
- summary: { type: "string", description: "One-line summary of the proposal as a whole (optional)." }
675
- },
676
- required: ["items"],
677
- additionalProperties: false
678
- },
679
- async execute(_id, params) {
680
- if (!chiefId) return text2("propose_builds is only available in the chief conversation.");
681
- const p = params ?? {};
682
- const items = (p.items ?? []).filter((i) => i?.todoId);
683
- if (!items.length) return text2("At least one item with a todoId is required.");
684
- const reply = await request(serverUrl, "POST", "/api/machine/chief/proposals", token, {
685
- chiefId,
686
- items: itemsToBody(items),
687
- ...p.summary ? { summary: p.summary } : {}
688
- });
689
- if (!reply.ok) return text2(errorText(reply, "Failed to create the proposal"));
690
- const docId = reply.body?.docId;
691
- return text2(`Created a proposal with ${items.length} item(s). Reference it in your reply as [Run ${items.length} todo${items.length > 1 ? "s" : ""}](doc:${docId}) so the user sees the proposal card.`);
692
- }
693
- };
694
- }
695
- function makeRunBuildsTool(serverUrl, token, step) {
696
- const chiefId = step.chiefId;
697
- return {
698
- name: "run_builds",
699
- label: "Run Builds",
700
- description: "Start builds for todos IMMEDIATELY \u2014 no confirmation card. Use this ONLY when the user has explicitly asked for the work to run in this conversation (their message is the approval); for work you are initiating yourself, use propose_builds instead. Same item shape as propose_builds: pick agent/thinkingLevel per item, withPlan for tasks needing a reviewed plan. Groom each todo before running it.",
701
- parameters: {
702
- type: "object",
703
- properties: {
704
- items: DISPATCH_ITEMS_SCHEMA
705
- },
706
- required: ["items"],
707
- additionalProperties: false
708
- },
709
- async execute(_id, params) {
710
- if (!chiefId) return text2("run_builds is only available in the chief conversation.");
711
- const p = params ?? {};
712
- const items = (p.items ?? []).filter((i) => i?.todoId);
713
- if (!items.length) return text2("At least one item with a todoId is required.");
714
- const reply = await request(serverUrl, "POST", "/api/machine/chief/builds", token, {
715
- chiefId,
716
- items: itemsToBody(items)
717
- });
718
- if (!reply.ok) return text2(errorText(reply, "Failed to start builds"));
719
- const started = reply.body?.started ?? [];
720
- const skipped = items.length - started.length;
721
- return text2(
722
- `Started ${started.length} build(s): ${started.map((s) => `#${s.seqNum}`).join(", ")}.` + (skipped > 0 ? ` ${skipped} item(s) were skipped (phase changed or no resolvable agent).` : "") + " Tell the user what is now running and with which agents."
723
- );
724
- }
725
- };
726
- }
727
- function makeUpdateMemoryTool(serverUrl, token, step) {
728
- const chiefId = step.chiefId;
729
- return {
730
- name: "update_memory",
731
- label: "Update Memory",
732
- description: "Rewrite your persistent memory \u2014 the notes injected into every future turn, surviving session resets. FULL REPLACEMENT: send the complete new text, not a diff; prune stale entries to stay under the size cap. Save immediately when you learn a durable routing preference, a user preference, or a lesson \u2014 do not wait. Every update is kept as a version the user can restore.",
733
- parameters: {
734
- type: "object",
735
- properties: {
736
- content: { type: "string", description: "The complete new memory text (replaces the old entirely)." }
737
- },
738
- required: ["content"],
739
- additionalProperties: false
740
- },
741
- async execute(_id, params) {
742
- if (!chiefId) return text2("update_memory is only available in the chief conversation.");
743
- const p = params ?? {};
744
- if (!p.content?.trim()) return text2("Memory content is required (full replacement text).");
745
- const reply = await request(serverUrl, "POST", "/api/machine/chief/memory", token, { chiefId, content: p.content });
746
- if (!reply.ok) return text2(errorText(reply, "Failed to update memory"));
747
- return text2("Memory updated. It will be injected into your future turns.");
748
- }
749
- };
750
- }
751
515
 
752
516
  // src/lib/sessionStore.ts
753
517
  var import_node_fs3 = require("node:fs");
@@ -1358,8 +1122,7 @@ async function executeStep(step, serverUrl, token, tunnel) {
1358
1122
  const skills = await materializeSkills(step.skills, agentDir);
1359
1123
  const extraCustomTools = [
1360
1124
  makeClientShellTool(tunnel, conversationId, runnersRef),
1361
- ...makeTodoTools(serverUrl, token, step),
1362
- ...makeChiefTools(serverUrl, token, step)
1125
+ ...makeRemoteTools(serverUrl, token, step)
1363
1126
  ];
1364
1127
  const session = await createSession(sdk, {
1365
1128
  authStorage,
@@ -1367,7 +1130,7 @@ async function executeStep(step, serverUrl, token, tunnel) {
1367
1130
  model,
1368
1131
  cwd,
1369
1132
  agentDir,
1370
- tools: step.tools,
1133
+ tools: [...step.tools, ...(step.remoteTools ?? []).map((t) => t.name)],
1371
1134
  sessionManager: m.sessionManager,
1372
1135
  thinkingLevel: step.agent.thinkingLevel ?? "",
1373
1136
  webSearch: true,
@@ -16254,8 +16017,6 @@ var UpdateTodoRequestSchema = external_exports.object({
16254
16017
  orderIndex: external_exports.number().optional(),
16255
16018
  assignment: AgentAssignmentSchema.nullable().optional()
16256
16019
  });
16257
- var MachineCreateTodoRequestSchema = CreateTodoRequestSchema.extend({ buildId: external_exports.string() });
16258
- var MachineUpdateTodoRequestSchema = UpdateTodoRequestSchema.omit({ assignment: true }).extend({ buildId: external_exports.string() });
16259
16020
  var UpdateChiefRequestSchema = external_exports.object({
16260
16021
  agent: AgentEntrySchema.nullable().optional(),
16261
16022
  charter: external_exports.string().optional()
@@ -16269,20 +16030,6 @@ var DispatchItemSchema = external_exports.object({
16269
16030
  agent: AgentEntrySchema.optional(),
16270
16031
  reason: external_exports.string().optional()
16271
16032
  });
16272
- var MAX_DISPATCH_ITEMS = 20;
16273
- var MachineProposeBuildsRequestSchema = external_exports.object({
16274
- chiefId: external_exports.string().min(1),
16275
- items: external_exports.array(DispatchItemSchema).min(1).max(MAX_DISPATCH_ITEMS),
16276
- summary: external_exports.string().optional()
16277
- });
16278
- var MachineRunBuildsRequestSchema = external_exports.object({
16279
- chiefId: external_exports.string().min(1),
16280
- items: external_exports.array(DispatchItemSchema).min(1).max(MAX_DISPATCH_ITEMS)
16281
- });
16282
- var MachineUpdateMemoryRequestSchema = external_exports.object({
16283
- chiefId: external_exports.string().min(1),
16284
- content: external_exports.string().min(1)
16285
- });
16286
16033
  var TriggerBuildRequestSchema = external_exports.object({
16287
16034
  todoIds: external_exports.array(external_exports.string()).min(1),
16288
16035
  // One-time assignment override; falls back to todo.assignment. Server enriches model.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@todos-dev/cli",
3
- "version": "0.1.5",
3
+ "version": "0.1.6",
4
4
  "bin": {
5
5
  "tds": "dist/index.js"
6
6
  },
@@ -27,12 +27,12 @@
27
27
  "@tds/types": "0.1.0"
28
28
  },
29
29
  "optionalDependencies": {
30
- "@todos-dev/cli-darwin-arm64": "0.1.5",
31
- "@todos-dev/cli-darwin-x64": "0.1.5",
32
- "@todos-dev/cli-linux-x64": "0.1.5",
33
- "@todos-dev/cli-linux-arm64": "0.1.5",
34
- "@todos-dev/cli-win32-x64": "0.1.5",
35
- "@todos-dev/cli-win32-arm64": "0.1.5"
30
+ "@todos-dev/cli-darwin-arm64": "0.1.6",
31
+ "@todos-dev/cli-darwin-x64": "0.1.6",
32
+ "@todos-dev/cli-linux-x64": "0.1.6",
33
+ "@todos-dev/cli-linux-arm64": "0.1.6",
34
+ "@todos-dev/cli-win32-x64": "0.1.6",
35
+ "@todos-dev/cli-win32-arm64": "0.1.6"
36
36
  },
37
37
  "scripts": {
38
38
  "dev": "tsx watch src/index.ts",