dorkos 0.21.0 → 0.22.0

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.
@@ -1,4 +1,4 @@
1
- var xt=Object.defineProperty;var wt=(e,n,i)=>n in e?xt(e,n,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[n]=i;var N=(e,n,i)=>wt(e,typeof n!="symbol"?n+"":n,i);import{g as bt,j as v,r as ee}from"./index-Bq5VyqwN.js";var on={exports:{}};/*!
1
+ var xt=Object.defineProperty;var wt=(e,n,i)=>n in e?xt(e,n,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[n]=i;var N=(e,n,i)=>wt(e,typeof n!="symbol"?n+"":n,i);import{g as bt,j as v,r as ee}from"./index-DBLhFI7i.js";var on={exports:{}};/*!
2
2
  Copyright (c) 2018 Jed Watson.
3
3
  Licensed under the MIT License (MIT), see
4
4
  http://jedwatson.github.io/classnames
@@ -15,7 +15,7 @@
15
15
  if (dark) document.documentElement.classList.add('dark');
16
16
  })();
17
17
  </script>
18
- <script type="module" crossorigin src="/assets/index-Bq5VyqwN.js"></script>
18
+ <script type="module" crossorigin src="/assets/index-DBLhFI7i.js"></script>
19
19
  <link rel="stylesheet" crossorigin href="/assets/index-BB0dvhXN.css">
20
20
  </head>
21
21
  <body>
@@ -74688,7 +74688,8 @@ var TaskItemSchema = z.object({
74688
74688
  }).openapi("TaskItem");
74689
74689
  var TaskUpdateEventSchema = z.object({
74690
74690
  action: z.enum(["create", "update", "snapshot"]),
74691
- task: TaskItemSchema
74691
+ task: TaskItemSchema,
74692
+ tasks: z.array(TaskItemSchema).optional()
74692
74693
  }).openapi("TaskUpdateEvent");
74693
74694
  var SyncUpdateEventSchema = z.object({
74694
74695
  sessionId: z.string(),
@@ -75600,7 +75601,7 @@ var SERVER_VERSION = resolveVersion();
75600
75601
  var IS_DEV_BUILD = checkDevBuild(SERVER_VERSION);
75601
75602
  function resolveVersion() {
75602
75603
  if (env.DORKOS_VERSION_OVERRIDE) return env.DORKOS_VERSION_OVERRIDE;
75603
- if (true) return "0.21.0";
75604
+ if (true) return "0.22.0";
75604
75605
  const pkgPath = path4.join(path4.dirname(fileURLToPath2(import.meta.url)), "../../package.json");
75605
75606
  return JSON.parse(readFileSync(pkgPath, "utf-8")).version;
75606
75607
  }
@@ -76995,7 +76996,7 @@ var AdapterManifestSchema = z12.object({
76995
76996
  type: z12.string(),
76996
76997
  displayName: z12.string(),
76997
76998
  description: z12.string(),
76998
- iconEmoji: z12.string().optional(),
76999
+ iconId: z12.string().optional(),
76999
77000
  category: AdapterCategorySchema,
77000
77001
  docsUrl: z12.string().url().optional(),
77001
77002
  builtin: z12.boolean(),
@@ -79115,6 +79116,7 @@ function mergeConsecutiveAssistantMessages(messages) {
79115
79116
  }
79116
79117
 
79117
79118
  // ../../apps/server/src/services/runtimes/claude-code/task-reader.ts
79119
+ var TASK_TOOL_NAMES = /* @__PURE__ */ new Set(["TaskCreate", "TaskUpdate", "TodoWrite"]);
79118
79120
  function parseTasks(lines) {
79119
79121
  const tasks = /* @__PURE__ */ new Map();
79120
79122
  let nextId = 1;
@@ -79130,10 +79132,25 @@ function parseTasks(lines) {
79130
79132
  if (!message?.content || !Array.isArray(message.content)) continue;
79131
79133
  for (const block of message.content) {
79132
79134
  if (block.type !== "tool_use") continue;
79133
- if (!block.name || !["TaskCreate", "TaskUpdate"].includes(block.name)) continue;
79135
+ if (!block.name || !TASK_TOOL_NAMES.has(block.name)) continue;
79134
79136
  const input = block.input;
79135
79137
  if (!input) continue;
79136
- if (block.name === "TaskCreate") {
79138
+ if (block.name === "TodoWrite") {
79139
+ tasks.clear();
79140
+ nextId = 1;
79141
+ const todos = input.todos;
79142
+ if (Array.isArray(todos)) {
79143
+ for (const todo of todos) {
79144
+ const id = String(nextId++);
79145
+ tasks.set(id, {
79146
+ id,
79147
+ subject: todo.content ?? "",
79148
+ status: todo.status ?? "pending",
79149
+ activeForm: todo.activeForm ?? void 0
79150
+ });
79151
+ }
79152
+ }
79153
+ } else if (block.name === "TaskCreate") {
79137
79154
  const id = String(nextId++);
79138
79155
  tasks.set(id, {
79139
79156
  id,
@@ -81678,6 +81695,8 @@ function createToolState() {
81678
81695
  let inThinking = false;
81679
81696
  let thinkingStartMs = 0;
81680
81697
  const toolNameById = /* @__PURE__ */ new Map();
81698
+ const resolvedResultIds = /* @__PURE__ */ new Set();
81699
+ const toolInputReceived = /* @__PURE__ */ new Set();
81681
81700
  return {
81682
81701
  get inTool() {
81683
81702
  return inTool;
@@ -81704,6 +81723,8 @@ function createToolState() {
81704
81723
  thinkingStartMs = v5;
81705
81724
  },
81706
81725
  toolNameById,
81726
+ resolvedResultIds,
81727
+ toolInputReceived,
81707
81728
  appendTaskInput: (chunk) => {
81708
81729
  taskToolInput += chunk;
81709
81730
  },
@@ -81838,7 +81859,13 @@ function handleToolApproval(session, toolUseId, toolName, input) {
81838
81859
  }
81839
81860
 
81840
81861
  // ../../apps/server/src/services/runtimes/claude-code/build-task-event.ts
81841
- var TASK_TOOL_NAMES = /* @__PURE__ */ new Set(["TaskCreate", "TaskUpdate", "TaskList", "TaskGet"]);
81862
+ var TASK_TOOL_NAMES2 = /* @__PURE__ */ new Set([
81863
+ "TaskCreate",
81864
+ "TaskUpdate",
81865
+ "TaskList",
81866
+ "TaskGet",
81867
+ "TodoWrite"
81868
+ ]);
81842
81869
  function buildTaskEvent(toolName, input) {
81843
81870
  switch (toolName) {
81844
81871
  case "TaskCreate":
@@ -81869,9 +81896,30 @@ function buildTaskEvent(toolName, input) {
81869
81896
  return null;
81870
81897
  }
81871
81898
  }
81899
+ function buildTodoWriteEvent(input) {
81900
+ const todos = input.todos;
81901
+ if (!Array.isArray(todos) || todos.length === 0) return null;
81902
+ const tasks = todos.map((todo, index2) => ({
81903
+ id: String(index2 + 1),
81904
+ subject: todo.content ?? "",
81905
+ status: todo.status ?? "pending",
81906
+ activeForm: todo.activeForm ?? void 0
81907
+ }));
81908
+ return {
81909
+ action: "snapshot",
81910
+ task: tasks[0],
81911
+ tasks
81912
+ };
81913
+ }
81872
81914
 
81873
81915
  // ../../apps/server/src/services/runtimes/claude-code/sdk-event-mapper.ts
81874
81916
  init_logger();
81917
+ function extractToolResultText(content3) {
81918
+ if (!content3) return "";
81919
+ if (typeof content3 === "string") return content3;
81920
+ if (!Array.isArray(content3)) return "";
81921
+ return content3.filter((b5) => b5.type === "text" && b5.text).map((b5) => b5.text).join("\n");
81922
+ }
81875
81923
  var TOOL_CONTEXTUAL_HOOK_EVENTS = /* @__PURE__ */ new Set(["PreToolUse", "PostToolUse", "PostToolUseFailure"]);
81876
81924
  function mapErrorCategory(subtype) {
81877
81925
  switch (subtype) {
@@ -82057,7 +82105,8 @@ async function* mapSdkMessage(message, session, sessionId, toolState) {
82057
82105
  } else if (delta?.type === "text_delta" && !toolState.inTool) {
82058
82106
  yield { type: "text_delta", data: { text: delta.text } };
82059
82107
  } else if (delta?.type === "input_json_delta" && toolState.inTool) {
82060
- if (TASK_TOOL_NAMES.has(toolState.currentToolName)) {
82108
+ toolState.toolInputReceived.add(toolState.currentToolId);
82109
+ if (TASK_TOOL_NAMES2.has(toolState.currentToolName)) {
82061
82110
  toolState.appendTaskInput(delta.partial_json);
82062
82111
  }
82063
82112
  yield {
@@ -82091,7 +82140,7 @@ async function* mapSdkMessage(message, session, sessionId, toolState) {
82091
82140
  if (toolState.inThinking) {
82092
82141
  toolState.inThinking = false;
82093
82142
  } else if (toolState.inTool) {
82094
- const wasTaskTool = TASK_TOOL_NAMES.has(toolState.currentToolName);
82143
+ const wasTaskTool = TASK_TOOL_NAMES2.has(toolState.currentToolName);
82095
82144
  const taskToolName = toolState.currentToolName;
82096
82145
  yield {
82097
82146
  type: "tool_call_end",
@@ -82105,7 +82154,7 @@ async function* mapSdkMessage(message, session, sessionId, toolState) {
82105
82154
  if (wasTaskTool && toolState.taskToolInput) {
82106
82155
  try {
82107
82156
  const input = JSON.parse(toolState.taskToolInput);
82108
- const taskEvent = buildTaskEvent(taskToolName, input);
82157
+ const taskEvent = taskToolName === "TodoWrite" ? buildTodoWriteEvent(input) : buildTaskEvent(taskToolName, input);
82109
82158
  if (taskEvent) {
82110
82159
  yield { type: "task_update", data: taskEvent };
82111
82160
  }
@@ -82117,9 +82166,56 @@ async function* mapSdkMessage(message, session, sessionId, toolState) {
82117
82166
  }
82118
82167
  return;
82119
82168
  }
82169
+ if (message.type === "assistant") {
82170
+ const content3 = message.message;
82171
+ const contentBlocks = content3?.content;
82172
+ if (Array.isArray(contentBlocks)) {
82173
+ for (const block of contentBlocks) {
82174
+ if (block.type === "tool_use" && typeof block.id === "string" && !toolState.toolInputReceived.has(block.id) && toolState.toolNameById.has(block.id)) {
82175
+ const inputStr = JSON.stringify(block.input ?? {});
82176
+ yield {
82177
+ type: "tool_call_delta",
82178
+ data: {
82179
+ toolCallId: block.id,
82180
+ toolName: toolState.toolNameById.get(block.id) ?? "",
82181
+ input: inputStr,
82182
+ status: "running"
82183
+ }
82184
+ };
82185
+ }
82186
+ }
82187
+ }
82188
+ return;
82189
+ }
82190
+ if (message.type === "user") {
82191
+ if (message.isReplay) return;
82192
+ const content3 = message.message;
82193
+ const contentBlocks = content3?.content;
82194
+ if (Array.isArray(contentBlocks)) {
82195
+ for (const block of contentBlocks) {
82196
+ if (block.type === "tool_result" && typeof block.tool_use_id === "string") {
82197
+ if (toolState.resolvedResultIds.has(block.tool_use_id)) continue;
82198
+ const resultText = extractToolResultText(block.content);
82199
+ if (resultText) {
82200
+ yield {
82201
+ type: "tool_result",
82202
+ data: {
82203
+ toolCallId: block.tool_use_id,
82204
+ toolName: toolState.toolNameById.get(block.tool_use_id) ?? "",
82205
+ result: resultText,
82206
+ status: "complete"
82207
+ }
82208
+ };
82209
+ }
82210
+ }
82211
+ }
82212
+ }
82213
+ return;
82214
+ }
82120
82215
  if (message.type === "tool_use_summary") {
82121
82216
  const summary = message;
82122
82217
  for (const toolUseId of summary.preceding_tool_use_ids) {
82218
+ toolState.resolvedResultIds.add(toolUseId);
82123
82219
  yield {
82124
82220
  type: "tool_result",
82125
82221
  data: {
@@ -83211,7 +83307,8 @@ var ClaudeCodeRuntime = class _ClaudeCodeRuntime {
83211
83307
  // Messaging
83212
83308
  // ---------------------------------------------------------------------------
83213
83309
  async *sendMessage(sessionId, content3, opts) {
83214
- if (!this.sessions.has(sessionId)) {
83310
+ const existingSession = this.findSession(sessionId);
83311
+ if (!existingSession) {
83215
83312
  const effectiveCwd = opts?.cwd ?? this.cwd;
83216
83313
  const hasTranscript = await this.transcriptReader.hasTranscript(effectiveCwd, sessionId);
83217
83314
  logger.debug("[sendMessage] auto-creating session", {
@@ -83225,7 +83322,6 @@ var ClaudeCodeRuntime = class _ClaudeCodeRuntime {
83225
83322
  hasStarted: hasTranscript
83226
83323
  });
83227
83324
  } else {
83228
- const existingSession = this.sessions.get(sessionId);
83229
83325
  if (existingSession.needsTranscriptCheck) {
83230
83326
  existingSession.needsTranscriptCheck = false;
83231
83327
  const effectiveCwd = opts?.cwd || existingSession.cwd || this.cwd;
@@ -83238,7 +83334,7 @@ var ClaudeCodeRuntime = class _ClaudeCodeRuntime {
83238
83334
  }
83239
83335
  }
83240
83336
  }
83241
- const session = this.sessions.get(sessionId);
83337
+ const session = this.findSession(sessionId) ?? this.sessions.get(sessionId);
83242
83338
  yield* executeSdkQuery(
83243
83339
  sessionId,
83244
83340
  content3,
@@ -107612,7 +107708,7 @@ var TELEGRAM_MANIFEST = {
107612
107708
  type: "telegram",
107613
107709
  displayName: "Telegram",
107614
107710
  description: "Send and receive messages via a Telegram bot.",
107615
- iconEmoji: "\u2708\uFE0F",
107711
+ iconId: "telegram",
107616
107712
  category: "messaging",
107617
107713
  docsUrl: "https://core.telegram.org/bots",
107618
107714
  builtin: true,
@@ -107963,7 +108059,7 @@ var WEBHOOK_MANIFEST = {
107963
108059
  type: "webhook",
107964
108060
  displayName: "Webhook",
107965
108061
  description: "Send and receive messages via HMAC-signed HTTP webhooks.",
107966
- iconEmoji: "\u{1F517}",
108062
+ iconId: "webhook",
107967
108063
  category: "automation",
107968
108064
  builtin: true,
107969
108065
  multiInstance: true,
@@ -109226,7 +109322,7 @@ var SLACK_MANIFEST = {
109226
109322
  type: "slack",
109227
109323
  displayName: "Slack",
109228
109324
  description: "Send and receive messages in Slack channels and DMs.",
109229
- iconEmoji: "#",
109325
+ iconId: "slack",
109230
109326
  category: "messaging",
109231
109327
  docsUrl: "https://api.slack.com/start",
109232
109328
  builtin: true,
@@ -110156,7 +110252,7 @@ var CLAUDE_CODE_MANIFEST = {
110156
110252
  type: "claude-code",
110157
110253
  displayName: "Claude Code",
110158
110254
  description: "Routes messages to Claude Agent SDK sessions. Auto-configured.",
110159
- iconEmoji: "\u{1F916}",
110255
+ iconId: "claude-code",
110160
110256
  category: "internal",
110161
110257
  builtin: true,
110162
110258
  multiInstance: false,
@@ -116577,7 +116673,7 @@ var TELEGRAM_CHATSDK_MANIFEST = {
116577
116673
  displayName: "Telegram (Chat SDK)",
116578
116674
  description: "Deprecated \u2014 use the Telegram adapter instead. Lacks streaming previews, interactive approvals, typing indicators, and reconnection logic.",
116579
116675
  deprecated: true,
116580
- iconEmoji: "\u2708\uFE0F",
116676
+ iconId: "telegram",
116581
116677
  category: "messaging",
116582
116678
  docsUrl: "https://github.com/anthropics/chat",
116583
116679
  builtin: true,