@deepseek-ai/dsh-loader-smoke 0.1.2-alpha.5 → 0.1.3-alpha.2

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/lib/index.js +20 -6
  2. package/package.json +10 -8
package/lib/index.js CHANGED
@@ -1,8 +1,9 @@
1
+ import { clearedProxyEnv } from "@deepseek-ai/dsh-http-proxy";
1
2
  import { mkdtemp, rm } from "node:fs/promises";
2
3
  import { tmpdir } from "node:os";
3
4
  import { join } from "node:path";
4
5
  import { execa } from "execa";
5
- import { createUserMessage } from "@deepseek-ai/dsh-llm";
6
+ import { createUserMessage, expandAssistantStream } from "@deepseek-ai/dsh-llm";
6
7
  //#region lib/types/agent-turn.js
7
8
  /**
8
9
  * Test-only direct-agent turn driver shared by assembled Loader fixtures.
@@ -24,8 +25,16 @@ function assistantText(event) {
24
25
  const blocks = event.data.message.content.filter((block) => block.type === "text");
25
26
  return blocks.length === 0 ? void 0 : blocks.map((block) => block.text).join("");
26
27
  }
27
- function onlyRootAgent(ctx) {
28
- const agents = ctx.get("agents")?.roots() ?? [];
28
+ async function onlyRootAgent(ctx) {
29
+ const registry = ctx.get("agents");
30
+ if (registry === void 0) throw new Error("fixture turn requires exactly one top-level agent, found 0");
31
+ if (registry.roots().length === 0) await new Promise((resolve) => {
32
+ const dispose = ctx.on("agent/created", () => {
33
+ dispose();
34
+ resolve();
35
+ });
36
+ });
37
+ const agents = registry.roots();
29
38
  const [agent] = agents;
30
39
  if (agent === void 0 || agents.length !== 1) throw new Error(`fixture turn requires exactly one top-level agent, found ${agents.length}`);
31
40
  return agent;
@@ -37,7 +46,7 @@ function onlyRootAgent(ctx) {
37
46
  * @returns the final assistant text and accumulated model usage.
38
47
  */
39
48
  async function runFixtureTurn(ctx, options) {
40
- const agent = onlyRootAgent(ctx);
49
+ const agent = await onlyRootAgent(ctx);
41
50
  await agent.whenIdle();
42
51
  const message = createUserMessage({
43
52
  content: [{
@@ -56,10 +65,12 @@ async function runFixtureTurn(ctx, options) {
56
65
  received = true;
57
66
  }
58
67
  options.onEvent?.(session.id, event);
59
- if (event.type === "assistant/chunk" && event.data.chunk.type === "usage") usageByStep.set(`${event.data.turn}/${event.data.step}`, event.data.chunk.usage);
60
68
  if (event.type === "assistant/message") {
61
69
  output = assistantText(event) ?? output;
62
70
  if (event.data.usage !== void 0) usageByStep.set(`${event.data.turn}/${event.data.step}`, event.data.usage);
71
+ } else if (event.type === "assistant/attempt") {
72
+ const usage = expandAssistantStream(event.data.stream).findLast((member) => member.chunk.type === "usage")?.chunk;
73
+ if (usage?.type === "usage") usageByStep.set(`${event.data.turn}/${event.data.step}`, usage.usage);
63
74
  }
64
75
  });
65
76
  try {
@@ -137,7 +148,10 @@ function toLibBin(srcBin) {
137
148
  function resolveExampleLaunch(options) {
138
149
  const mode = options.mode ?? resolveExampleMode();
139
150
  const configArgs = options.configArgs ?? [];
140
- const env = { ...options.env };
151
+ const env = {
152
+ ...clearedProxyEnv(),
153
+ ...options.env
154
+ };
141
155
  if (mode === "src") {
142
156
  if (options.tsconfigPath === void 0) throw new Error("resolveExampleLaunch: 'src' mode needs tsconfigPath for the workspace paths map.");
143
157
  const tsxLoader = options.sourceImport === "tsx/esm" ? import.meta.resolve("tsx/esm") : import.meta.resolve("tsx");
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@deepseek-ai/dsh-loader-smoke",
3
3
  "description": "Shared subprocess and direct-agent harness for keyless real-Loader example smoke tests",
4
- "version": "0.1.2-alpha.5",
4
+ "version": "0.1.3-alpha.2",
5
5
  "publishConfig": {
6
6
  "access": "public"
7
7
  },
@@ -31,16 +31,18 @@
31
31
  "tsx": "^4.22.4"
32
32
  },
33
33
  "peerDependencies": {
34
+ "@deepseek-ai/dsh-agent": "^0.1.3-alpha.2",
34
35
  "@deepseek-ai/cordis": "^4.0.2",
35
- "@deepseek-ai/dsh-llm": "^0.1.2-alpha.5",
36
- "@deepseek-ai/dsh-session": "^0.1.2-alpha.5",
37
- "@deepseek-ai/dsh-agent": "^0.1.2-alpha.5"
36
+ "@deepseek-ai/dsh-llm": "^0.1.3-alpha.2",
37
+ "@deepseek-ai/dsh-http-proxy": "^0.1.3-alpha.2",
38
+ "@deepseek-ai/dsh-session": "^0.1.3-alpha.2"
38
39
  },
39
40
  "devDependencies": {
40
- "@deepseek-ai/dsh-agent": "^0.1.2-alpha.5",
41
+ "@deepseek-ai/dsh-agent": "^0.1.3-alpha.2",
42
+ "@deepseek-ai/dsh-app-boot": "^0.1.3-alpha.2",
41
43
  "@deepseek-ai/cordis": "^4.0.2",
42
- "@deepseek-ai/dsh-app-boot": "^0.1.2-alpha.5",
43
- "@deepseek-ai/dsh-llm": "^0.1.2-alpha.5",
44
- "@deepseek-ai/dsh-session": "^0.1.2-alpha.5"
44
+ "@deepseek-ai/dsh-llm": "^0.1.3-alpha.2",
45
+ "@deepseek-ai/dsh-session": "^0.1.3-alpha.2",
46
+ "@deepseek-ai/dsh-http-proxy": "^0.1.3-alpha.2"
45
47
  }
46
48
  }