@deepstrike/sdk 0.2.42 → 0.2.43

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,5 +1,6 @@
1
1
  import type { RuntimeRunner } from "../runtime/runner.js";
2
2
  import type { SessionEvent } from "../runtime/session-log.js";
3
+ import type { ContentPart } from "../types.js";
3
4
  import type { WorkflowNodeSpec } from "../types/agent.js";
4
5
  import type { Criterion, Verdict } from "../runtime/eval.js";
5
6
  import type { AttemptJudge, JudgeResult } from "./judge.js";
@@ -8,6 +9,12 @@ export interface AttemptRequest {
8
9
  sessionId?: string;
9
10
  goal: string;
10
11
  criteria?: Criterion[];
12
+ /**
13
+ * Multimodal inputs (images / audio) attached to the task. Forwarded to every attempt
14
+ * unconditionally; the runner seeds them per session idempotently, so fresh-session carries
15
+ * re-seed while same-session carries do not double.
16
+ */
17
+ attachments?: ContentPart[];
11
18
  extensions?: Record<string, unknown>;
12
19
  /** Parent transcript inherited by the first attempt only. */
13
20
  inheritEvents?: Array<{
@@ -14,6 +14,7 @@ export class RuntimeAttemptBody {
14
14
  sessionId: context.sessionId,
15
15
  goal: context.goal,
16
16
  criteria: (context.criteria ?? []).map(criterion => criterion.text),
17
+ ...(context.attachments?.length ? { attachments: context.attachments } : {}),
17
18
  extensions: context.extensions,
18
19
  ...(context.attempt === 1 && context.inheritEvents
19
20
  ? { inheritEvents: context.inheritEvents }
@@ -1208,6 +1208,12 @@ export class RuntimeRunner {
1208
1208
  const runId = midRun && resumedStart?.event.kind === "run_started"
1209
1209
  ? resumedStart.event.run_id
1210
1210
  : crypto.randomUUID();
1211
+ // Idempotent per session: an earlier run's `run_started` already carries these attachments
1212
+ // (same-session retry attempt), so replay reconstructs them — recording and seeding again
1213
+ // would double them in history. Deduping at the append keeps live and replay in agreement.
1214
+ const attachments = req.attachments?.length && !attachmentsAlreadySeeded(prior, req.attachments)
1215
+ ? req.attachments
1216
+ : undefined;
1211
1217
  if (!midRun) {
1212
1218
  await this.opts.sessionLog.append(req.sessionId, {
1213
1219
  kind: "run_started",
@@ -1216,10 +1222,10 @@ export class RuntimeRunner {
1216
1222
  criteria: req.criteria ?? [],
1217
1223
  agent_id: this.opts.agentId,
1218
1224
  system_prompt: this.opts.systemPrompt,
1219
- ...(req.attachments?.length ? { attachments: req.attachments } : {}),
1225
+ ...(attachments ? { attachments } : {}),
1220
1226
  });
1221
1227
  }
1222
- yield* this.execute(req.sessionId, req.goal, req.criteria ?? [], req.extensions, prior.length > 0 ? prior : undefined, midRun, req.attachments, runId);
1228
+ yield* this.execute(req.sessionId, req.goal, req.criteria ?? [], req.extensions, prior.length > 0 ? prior : undefined, midRun, attachments, runId);
1223
1229
  }
1224
1230
  async *wake(sessionId, extensions) {
1225
1231
  const events = await this.opts.sessionLog.read(sessionId);
@@ -2467,6 +2473,15 @@ function isMidRun(events) {
2467
2473
  }
2468
2474
  return lastStarted >= 0 && lastStarted > lastTerminal;
2469
2475
  }
2476
+ /**
2477
+ * True when an earlier run in this session already seeded the same attachments. Replay
2478
+ * reconstructs the attachment message from that run's `run_started`, so recording and
2479
+ * live-seeding them again (a same-session retry attempt) would double them in history.
2480
+ */
2481
+ function attachmentsAlreadySeeded(prior, attachments) {
2482
+ const wanted = JSON.stringify(attachments);
2483
+ return prior.some(({ event }) => event.kind === "run_started" && JSON.stringify(event.attachments ?? []) === wanted);
2484
+ }
2470
2485
  /**
2471
2486
  * Build a kernel `add_history_message` payload from user attachments: a `user`
2472
2487
  * message whose content is the multimodal parts in the kernel's serde shape
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@deepstrike/sdk",
3
- "version": "0.2.42",
3
+ "version": "0.2.43",
4
4
  "description": "DeepStrike Node.js SDK",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -72,7 +72,7 @@
72
72
  },
73
73
  "dependencies": {
74
74
  "@anthropic-ai/sdk": "^0.99.0",
75
- "@deepstrike/core": "0.2.42",
75
+ "@deepstrike/core": "0.2.43",
76
76
  "@google/generative-ai": "^0.24.1",
77
77
  "openai": "^5.23.2"
78
78
  },