@questionbase/deskfree 0.3.0-alpha.40 → 0.3.0-alpha.42

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.d.ts CHANGED
@@ -699,6 +699,7 @@ declare class DeskFreeClient {
699
699
  tasks: Array<{
700
700
  title?: string;
701
701
  instructions?: string;
702
+ steps?: string[];
702
703
  substeps?: string[];
703
704
  file?: {
704
705
  type: 'existing';
package/dist/index.js CHANGED
@@ -4810,7 +4810,7 @@ async function deliverMessageToAgent(ctx, message, client) {
4810
4810
  From: message.humanId,
4811
4811
  To: message.humanId,
4812
4812
  MessageSid: message.messageId,
4813
- ThreadId: message.taskId ?? void 0,
4813
+ MessageThreadId: message.taskId ?? void 0,
4814
4814
  Timestamp: message.createdAt,
4815
4815
  AccountId: ctx.accountId,
4816
4816
  FromName: message.userName ?? "Unknown",
@@ -4827,6 +4827,7 @@ async function deliverMessageToAgent(ctx, message, client) {
4827
4827
  });
4828
4828
  let streamingSession = null;
4829
4829
  let accumulatedText = "";
4830
+ const replyTaskId = message.taskId ?? getActiveTaskId() ?? void 0;
4830
4831
  try {
4831
4832
  const cfg = runtime.config.loadConfig();
4832
4833
  const { dispatcher, replyOptions } = runtime.channel.reply.createReplyDispatcherWithTyping({
@@ -4840,7 +4841,7 @@ async function deliverMessageToAgent(ctx, message, client) {
4840
4841
  log.warn("Deliver callback called with empty text, skipping.");
4841
4842
  return;
4842
4843
  }
4843
- const taskId = message.taskId ?? getActiveTaskId() ?? void 0;
4844
+ const taskId = replyTaskId;
4844
4845
  const kind = info?.kind ?? "final";
4845
4846
  if (kind === "block") {
4846
4847
  accumulatedText += text;
@@ -4878,7 +4879,7 @@ async function deliverMessageToAgent(ctx, message, client) {
4878
4879
  }
4879
4880
  }
4880
4881
  });
4881
- sendWsThinking(message.taskId ?? getActiveTaskId() ?? void 0);
4882
+ sendWsThinking(replyTaskId);
4882
4883
  await runtime.channel.reply.dispatchReplyFromConfig({
4883
4884
  ctx: msgCtx,
4884
4885
  cfg,
@@ -8163,6 +8164,9 @@ var ORCHESTRATOR_TOOLS = {
8163
8164
  name: "deskfree_send_message",
8164
8165
  description: "Send a message to the human. Keep it short \u2014 1-3 sentences. No walls of text.",
8165
8166
  parameters: Type.Object({
8167
+ type: Type.Union([Type.Literal("notify"), Type.Literal("ask")], {
8168
+ description: "notify = general update (quiet). ask = needs human attention (surfaces prominently)."
8169
+ }),
8166
8170
  content: Type.String({
8167
8171
  description: "Message content."
8168
8172
  }),
@@ -8323,11 +8327,6 @@ var SHARED_TOOLS = {
8323
8327
  description: "Updated global Ways of Working (full replacement). Keep surgical \u2014 only add or modify relevant sections, do not inflate with restated context."
8324
8328
  })
8325
8329
  ),
8326
- initiativeId: Type.Optional(
8327
- Type.String({
8328
- description: "Initiative ID to update"
8329
- })
8330
- ),
8331
8330
  initiativeContent: Type.Optional(
8332
8331
  Type.String({
8333
8332
  description: "Updated initiative content (full replacement). Keep surgical \u2014 evolve what exists, do not rewrite from scratch."
@@ -8652,7 +8651,7 @@ var deskFreePlugin = {
8652
8651
  const client = new DeskFreeClient(acct.botToken, acct.apiUrl);
8653
8652
  const log = runtime.logging.createLogger("deskfree");
8654
8653
  try {
8655
- const taskId = ctx.threadId ? String(ctx.threadId) : getActiveTaskId() ?? void 0;
8654
+ const taskId = ctx.threadId ? String(ctx.threadId) : void 0;
8656
8655
  await client.sendMessage({
8657
8656
  content: ctx.text,
8658
8657
  taskId
@@ -9001,16 +9000,17 @@ You do NOT claim tasks, complete tasks, or do work directly \u2014 you have no a
9001
9000
  - Initiative titles should reflect aspirations and outcomes, not activities. "AI Thought Leadership on LinkedIn" over "LinkedIn Content."
9002
9001
  - Initiative descriptions should be 2-3 sentences that make the human think "wow, this will enable my dreams." Reflect their ambition back to them. No headers, no phases, no formal structure. Aspirational, not operational.`;
9003
9002
  var DESKFREE_WORKER_DIRECTIVE = `## DeskFree Worker
9004
- You are a worker sub-agent. Call \`deskfree_start_task\` with your taskId to claim and load context.
9003
+ You are a worker sub-agent. If you have prior conversation history with task context, continue from where you left off. Otherwise, call \`deskfree_start_task\` with your taskId to claim and load context.
9005
9004
  Tools: deskfree_start_task, deskfree_update_steps, deskfree_update_file, deskfree_complete_task, deskfree_send_message, deskfree_propose.
9006
9005
 
9007
9006
  **After claiming a task, your first message should be how you plan to approach it.** Work one step at a time and share progress naturally \u2014 like updating a coworker.
9008
9007
 
9009
- - Claim your task first with deskfree_start_task \u2014 this loads steps, messages, and file context.
9008
+ - If continuing from a previous conversation (you can see prior tool calls and context), respond directly to the human's latest message \u2014 do NOT call deskfree_start_task again.
9009
+ - If starting fresh, claim your task first with deskfree_start_task \u2014 this loads steps, messages, and file context.
9010
9010
  - Use deskfree_update_steps to update step progress as you work. Send the full step list each time with updated statuses.
9011
9011
  - Save work to linked files with deskfree_update_file. Build up incrementally \u2014 start with structure/outline, then flesh out.
9012
9012
  - Use deskfree_send_message with type "notify" for progress updates. Keep it brief \u2014 1-3 sentences.
9013
- - Use deskfree_send_message with type "ask" when you need human input OR when work is ready for review. Terminate after sending an ask.
9013
+ - Use deskfree_send_message with type "ask" when you need human input OR when work is ready for review.
9014
9014
  - Only complete (deskfree_complete_task with humanApproved: true) after the human has confirmed in the thread. Never self-complete without human response.
9015
9015
  - When completing: pass "learnings" only for genuine new knowledge. Pass "followUps" as brief handoffs.
9016
9016
  - On 409 or 404 errors: STOP. Do not retry. Call deskfree_state to find available tasks.`;
@@ -9330,6 +9330,11 @@ function parseProposeTasks(raw) {
9330
9330
  if (typeof title !== "string" || title.trim() === "") {
9331
9331
  throw new Error(`tasks[${i}].title must be a non-empty string`);
9332
9332
  }
9333
+ let steps;
9334
+ if (Array.isArray(item["steps"]) && item["steps"].length > 0) {
9335
+ steps = item["steps"].filter((s2) => typeof s2 === "string" && s2.trim() !== "").map((s2) => s2.trim());
9336
+ if (steps.length === 0) steps = void 0;
9337
+ }
9333
9338
  let substeps;
9334
9339
  if (Array.isArray(item["substeps"]) && item["substeps"].length > 0) {
9335
9340
  substeps = item["substeps"].filter((s2) => typeof s2 === "string" && s2.trim() !== "").map((s2) => s2.trim());
@@ -9351,6 +9356,7 @@ function parseProposeTasks(raw) {
9351
9356
  return {
9352
9357
  title: title.trim(),
9353
9358
  instructions: typeof item["instructions"] === "string" ? item["instructions"] : void 0,
9359
+ steps,
9354
9360
  substeps,
9355
9361
  file,
9356
9362
  estimatedTokens: typeof item["estimatedTokens"] === "number" ? item["estimatedTokens"] : void 0,
@@ -9381,7 +9387,8 @@ function makeUpdateStepsHandler(client) {
9381
9387
  throw new Error("steps must be a non-empty array");
9382
9388
  }
9383
9389
  const steps = rawSteps.map((s) => {
9384
- if (typeof s !== "object" || s === null) throw new Error("Invalid step");
9390
+ if (typeof s !== "object" || s === null)
9391
+ throw new Error("Invalid step");
9385
9392
  const obj = s;
9386
9393
  const label = typeof obj["label"] === "string" ? obj["label"].trim() : "";
9387
9394
  const status = typeof obj["status"] === "string" ? obj["status"] : "pending";
@@ -9392,10 +9399,16 @@ function makeUpdateStepsHandler(client) {
9392
9399
  return { label, status };
9393
9400
  });
9394
9401
  await client.updateSteps({ taskId, steps });
9395
- const doneCount = steps.filter((s) => s.status === "done").length;
9402
+ const doneCount = steps.filter(
9403
+ (s) => s.status === "done"
9404
+ ).length;
9405
+ const allDone = doneCount === steps.length;
9396
9406
  return formatConfirmation(
9397
9407
  `Updated steps for task ${taskId} (${doneCount}/${steps.length} done)`,
9398
- ["Step progress saved \u2014 continue working"]
9408
+ allDone ? [
9409
+ "All steps complete \u2014 send an ask message for human review",
9410
+ 'Use deskfree_send_message with type "ask" to request review, then terminate and wait'
9411
+ ] : ["Step progress saved \u2014 continue working"]
9399
9412
  );
9400
9413
  } catch (err) {
9401
9414
  return errorResult(err);
@@ -9416,7 +9429,7 @@ function makeUpdateFileHandler(client) {
9416
9429
  await client.updateFile({ fileId, content, contentFormat });
9417
9430
  return formatConfirmation(`Updated file ${fileId}`, [
9418
9431
  "File content has been saved",
9419
- "Complete the task with deskfree_complete_task when ready"
9432
+ 'When work is ready for review, send an ask message with deskfree_send_message (type "ask") and terminate'
9420
9433
  ]);
9421
9434
  } catch (err) {
9422
9435
  return errorResult(err);
@@ -9521,6 +9534,7 @@ function makeProposeHandler(client) {
9521
9534
  tasks: tasks.map((t) => ({
9522
9535
  title: t.title,
9523
9536
  instructions: t.instructions,
9537
+ steps: t.steps,
9524
9538
  substeps: t.substeps,
9525
9539
  file: t.file,
9526
9540
  estimatedTokens: t.estimatedTokens,
@@ -9630,16 +9644,13 @@ ${s.criticalSection}`
9630
9644
  const taskJson = JSON.stringify(
9631
9645
  {
9632
9646
  summary: `Claimed task "${result.title}" \u2014 full context loaded${result.skillContext?.length ? ` (${result.skillContext.length} skill${result.skillContext.length > 1 ? "s" : ""} loaded \u2014 use deskfree_read_skill_section for full details)` : ""}`,
9633
- mode: trimmedTask.mode ?? "work",
9634
9647
  nextActions: [
9635
9648
  "Read the instructions and message history carefully",
9636
9649
  ...result.fileContext ? [
9637
9650
  `Task has a linked file "${result.fileContext.name}" (ID: ${result.fileContext.fileId}) \u2014 use deskfree_update_file to save your work to it`
9638
9651
  ] : [],
9639
- ...trimmedTask.mode === "evaluation" ? [
9640
- "This is an evaluation task \u2014 review the WoW context and provide your evaluation in deskfree_complete_task"
9641
- ] : [],
9642
- "Complete with deskfree_complete_task when done (summary required)"
9652
+ 'When work is done, send an ask message (deskfree_send_message type "ask") for human review, then terminate',
9653
+ "Only call deskfree_complete_task after the human has responded in the thread"
9643
9654
  ],
9644
9655
  task: trimmedTask
9645
9656
  },