@calltelemetry/openclaw-linear 0.4.1 → 0.5.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.
@@ -133,7 +133,7 @@ function resolveDefaultAgent(api: OpenClawPluginApi): string {
133
133
  if (defaultAgent) return defaultAgent[0];
134
134
  } catch { /* fall through */ }
135
135
 
136
- return "zoe";
136
+ return "default";
137
137
  }
138
138
 
139
139
  function parseAssessment(raw: string): TierAssessment | null {
package/src/webhook.ts CHANGED
@@ -3,9 +3,10 @@ import { readFileSync } from "node:fs";
3
3
  import { join } from "node:path";
4
4
  import type { OpenClawPluginApi } from "openclaw/plugin-sdk";
5
5
  import { LinearAgentApi, resolveLinearToken } from "./linear-api.js";
6
- import { runFullPipeline, type PipelineContext } from "./pipeline.js";
6
+ import { spawnWorker, type HookContext } from "./pipeline.js";
7
7
  import { setActiveSession, clearActiveSession } from "./active-session.js";
8
8
  import { readDispatchState, getActiveDispatch, registerDispatch, updateDispatchStatus, completeDispatch, removeActiveDispatch } from "./dispatch-state.js";
9
+ import { createDiscordNotifier, createNoopNotifier, type NotifyFn } from "./notify.js";
9
10
  import { assessTier } from "./tier-assess.js";
10
11
  import { createWorktree, prepareWorkspace } from "./codex-worktree.js";
11
12
 
@@ -1225,6 +1226,7 @@ async function handleDispatch(
1225
1226
  status: "dispatched",
1226
1227
  dispatchedAt: now,
1227
1228
  agentSessionId,
1229
+ attempt: 0,
1228
1230
  }, statePath);
1229
1231
 
1230
1232
  // 8. Register active session for tool resolution
@@ -1274,41 +1276,48 @@ async function handleDispatch(
1274
1276
  api.logger.warn(`@dispatch: could not apply tier label: ${err}`);
1275
1277
  }
1276
1278
 
1277
- // 11. Run pipeline (non-blocking)
1278
- const agentId = resolveAgentId(api);
1279
- const pipelineCtx: PipelineContext = {
1279
+ // 11. Run v2 pipeline: worker → audit → verdict (non-blocking)
1280
+ activeRuns.add(issue.id);
1281
+
1282
+ // Instantiate notifier
1283
+ const discordBotToken = (() => {
1284
+ try {
1285
+ const config = JSON.parse(
1286
+ require("node:fs").readFileSync(
1287
+ require("node:path").join(process.env.HOME ?? "/home/claw", ".openclaw", "openclaw.json"),
1288
+ "utf8",
1289
+ ),
1290
+ );
1291
+ return config?.channels?.discord?.token as string | undefined;
1292
+ } catch { return undefined; }
1293
+ })();
1294
+ const flowDiscordChannel = pluginConfig?.flowDiscordChannel as string | undefined;
1295
+ const notify: NotifyFn = (discordBotToken && flowDiscordChannel)
1296
+ ? createDiscordNotifier(discordBotToken, flowDiscordChannel)
1297
+ : createNoopNotifier();
1298
+
1299
+ const hookCtx: HookContext = {
1280
1300
  api,
1281
1301
  linearApi,
1282
- agentSessionId: agentSessionId ?? `dispatch-${identifier}-${Date.now()}`,
1283
- agentId,
1284
- issue: {
1285
- id: issue.id,
1286
- identifier,
1287
- title: enrichedIssue.title ?? "(untitled)",
1288
- description: enrichedIssue.description,
1289
- },
1290
- worktreePath: worktree.path,
1291
- codexBranch: worktree.branch,
1292
- tier: assessment.tier,
1293
- model: assessment.model,
1302
+ notify,
1303
+ pluginConfig,
1304
+ configPath: statePath,
1294
1305
  };
1295
1306
 
1296
- activeRuns.add(issue.id);
1307
+ // Re-read dispatch to get fresh state after registration
1308
+ const freshState = await readDispatchState(statePath);
1309
+ const dispatch = getActiveDispatch(freshState, identifier)!;
1297
1310
 
1298
- // Update status to running
1299
- await updateDispatchStatus(identifier, "running", statePath);
1300
-
1301
- runFullPipeline(pipelineCtx)
1302
- .then(async () => {
1303
- await completeDispatch(identifier, {
1304
- tier: assessment.tier,
1305
- status: "done",
1306
- completedAt: new Date().toISOString(),
1307
- }, statePath);
1308
- api.logger.info(`@dispatch: pipeline completed for ${identifier}`);
1309
- })
1311
+ await notify("dispatch", {
1312
+ identifier,
1313
+ title: enrichedIssue.title ?? "(untitled)",
1314
+ status: "dispatched",
1315
+ });
1316
+
1317
+ // spawnWorker handles: dispatched→working→auditing→done/rework/stuck
1318
+ spawnWorker(hookCtx, dispatch)
1310
1319
  .catch(async (err) => {
1311
- api.logger.error(`@dispatch: pipeline failed for ${identifier}: ${err}`);
1320
+ api.logger.error(`@dispatch: pipeline v2 failed for ${identifier}: ${err}`);
1312
1321
  await updateDispatchStatus(identifier, "failed", statePath);
1313
1322
  })
1314
1323
  .finally(() => {