@truefoundry/assistant-ui-runtime 0.1.3-rc.3 → 0.1.4

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@truefoundry/assistant-ui-runtime",
3
- "version": "0.1.3-rc.3",
3
+ "version": "0.1.4",
4
4
  "description": "TrueFoundry Gateway agent runtime adapter for assistant-ui",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -50,7 +50,7 @@
50
50
  "peerDependencies": {
51
51
  "@types/react": "*",
52
52
  "react": "^18 || ^19",
53
- "truefoundry-gateway-sdk": "^0.3.2-rc.1"
53
+ "truefoundry-gateway-sdk": "^0.4.0-rc.1"
54
54
  },
55
55
  "peerDependenciesMeta": {
56
56
  "@types/react": {
@@ -63,7 +63,7 @@
63
63
  "@types/react": "^19.2.17",
64
64
  "jsdom": "^29.1.1",
65
65
  "react": "^19.2.4",
66
- "truefoundry-gateway-sdk": "0.3.2-rc.1",
66
+ "truefoundry-gateway-sdk": "0.4.0-rc.1",
67
67
  "tsup": "^8.5.0",
68
68
  "typescript": "^5.9.3",
69
69
  "vitest": "^4.1.9"
@@ -178,7 +178,7 @@ async function sessionEventItemsFromTurns(
178
178
  turnId: turn.id,
179
179
  input: turn.input,
180
180
  state: { status: "running" },
181
- createdBy: { subjectId: "u1", subjectType: "user" },
181
+ createdBy: { subjectId: "u1", subjectType: "user", subjectSlug: "u1" },
182
182
  createdAt: turn.createdAt,
183
183
  },
184
184
  });
@@ -636,7 +636,7 @@ describe("convertTurnMessages", () => {
636
636
  input: [{ type: "user.message", content: "run tool" }],
637
637
  state: {
638
638
  status: "done",
639
- output: null,
639
+ output: undefined,
640
640
  requiredActions: [
641
641
  approvalRequired({
642
642
  id: "approval-event",
@@ -703,7 +703,7 @@ describe("convertTurnMessages", () => {
703
703
  input: [{ type: "user.message", content: "run tool" }],
704
704
  state: {
705
705
  status: "done",
706
- output: null,
706
+ output: undefined,
707
707
  requiredActions: [
708
708
  approvalRequired({
709
709
  id: "approval-event",
@@ -787,7 +787,7 @@ describe("convertTurnMessages", () => {
787
787
  input: [{ type: "user.message", content: "ask me" }],
788
788
  state: {
789
789
  status: "done",
790
- output: null,
790
+ output: undefined,
791
791
  requiredActions: [
792
792
  responseRequired({
793
793
  id: "resp-req-1",
@@ -859,7 +859,7 @@ describe("convertTurnMessages", () => {
859
859
  input: [{ type: "user.message", content: "ask me" }],
860
860
  state: {
861
861
  status: "done",
862
- output: null,
862
+ output: undefined,
863
863
  requiredActions: [
864
864
  responseRequired({
865
865
  id: "resp-req-1",
@@ -2186,7 +2186,7 @@ describe("buildSnapshotFromSessionEvents", () => {
2186
2186
  turnId: "t1",
2187
2187
  input: [{ type: "user.message", content: "hello" }],
2188
2188
  state: { status: "running" },
2189
- createdBy: { subjectId: "u1", subjectType: "user" },
2189
+ createdBy: { subjectId: "u1", subjectType: "user", subjectSlug: "u1" },
2190
2190
  createdAt,
2191
2191
  },
2192
2192
  },
@@ -2241,7 +2241,7 @@ describe("buildSnapshotFromSessionEvents", () => {
2241
2241
  turnId: "t1",
2242
2242
  input: [{ type: "user.message", content: "first" }],
2243
2243
  state: { status: "running" },
2244
- createdBy: { subjectId: "u1", subjectType: "user" },
2244
+ createdBy: { subjectId: "u1", subjectType: "user", subjectSlug: "u1" },
2245
2245
  createdAt,
2246
2246
  },
2247
2247
  },
@@ -2286,7 +2286,7 @@ describe("buildSnapshotFromSessionEvents", () => {
2286
2286
  turnId: "t1",
2287
2287
  input: [{ type: "user.message", content: "first" }],
2288
2288
  state: { status: "running" },
2289
- createdBy: { subjectId: "u1", subjectType: "user" },
2289
+ createdBy: { subjectId: "u1", subjectType: "user", subjectSlug: "u1" },
2290
2290
  createdAt,
2291
2291
  },
2292
2292
  },
@@ -2311,7 +2311,7 @@ describe("buildSnapshotFromSessionEvents", () => {
2311
2311
  turnId: "t2",
2312
2312
  input: [{ type: "user.message", content: "second" }],
2313
2313
  state: { status: "running" },
2314
- createdBy: { subjectId: "u1", subjectType: "user" },
2314
+ createdBy: { subjectId: "u1", subjectType: "user", subjectSlug: "u1" },
2315
2315
  createdAt,
2316
2316
  },
2317
2317
  },
@@ -2380,7 +2380,7 @@ describe("buildSnapshotFromSessionEvents", () => {
2380
2380
  turnId: id,
2381
2381
  input: [{ type: "user.message", content: text }],
2382
2382
  state: { status: "running" },
2383
- createdBy: { subjectId: "u1", subjectType: "user" },
2383
+ createdBy: { subjectId: "u1", subjectType: "user", subjectSlug: "u1" },
2384
2384
  createdAt,
2385
2385
  },
2386
2386
  },
@@ -1,6 +1,6 @@
1
1
  import { describe, expect, it } from "vitest";
2
2
 
3
- import { mergeAgentSpec } from "./private/agentSpec.js";
3
+ import { mergeAgentSpec, type AgentSpec } from "./private/agentSpec.js";
4
4
  import {
5
5
  resolveTrueFoundryAgentConfig,
6
6
  resolveTrueFoundryAgentRuntimeOptions,
@@ -80,14 +80,14 @@ describe("mergeAgentSpec", () => {
80
80
  });
81
81
 
82
82
  it("replaces mcpServers array wholesale", () => {
83
- const base = {
83
+ const base: AgentSpec = {
84
84
  model: { name: "openai/gpt-4o" },
85
- mcpServers: [{ name: "github", enableTools: ["@all"] }],
85
+ mcpServers: [{ type: "truefoundry-mcp-registry", name: "github", enableTools: ["@all"] }],
86
86
  };
87
87
  const next = mergeAgentSpec(base, {
88
- mcpServers: [{ name: "slack", enableTools: ["@all"] }],
88
+ mcpServers: [{ type: "truefoundry-mcp-registry", name: "slack", enableTools: ["@all"] }],
89
89
  });
90
- expect(next.mcpServers).toEqual([{ name: "slack", enableTools: ["@all"] }]);
90
+ expect(next.mcpServers).toEqual([{ type: "truefoundry-mcp-registry", name: "slack", enableTools: ["@all"] }]);
91
91
  });
92
92
 
93
93
  it("replaces skills array wholesale", () => {
@@ -102,9 +102,9 @@ describe("mergeAgentSpec", () => {
102
102
  });
103
103
 
104
104
  it("model partial update does not clear mcpServers or skills", () => {
105
- const base = {
105
+ const base: AgentSpec = {
106
106
  model: { name: "openai/gpt-4o", params: { maxTokens: 1024 } },
107
- mcpServers: [{ name: "github", enableTools: ["@all"] }],
107
+ mcpServers: [{ type: "truefoundry-mcp-registry", name: "github", enableTools: ["@all"] }],
108
108
  skills: [{ fqn: "acme/skill-a:1", preload: false }],
109
109
  };
110
110
  const next = mergeAgentSpec(base, {
@@ -142,7 +142,7 @@ describe("foldPeerThreads", () => {
142
142
  id: "spawn-1",
143
143
  type: "function",
144
144
  function: { name: "create_sub_agent", arguments: "{}" },
145
- },
145
+ toolInfo: { type: "truefoundry-system", name: "create_sub_agent" }, },
146
146
  ],
147
147
  }),
148
148
  );
@@ -74,7 +74,9 @@ function ensureModelMessageContentArray(message: ModelMessageEvent): void {
74
74
  if (Array.isArray(message.content)) {
75
75
  return;
76
76
  }
77
- message.content = normalizeModelMessageContent(message);
77
+ // Gateway may stream `image_url` content blocks that aren't in the SDK content union yet.
78
+ (message as { content?: ModelMessageContentPart[] }).content =
79
+ normalizeModelMessageContent(message);
78
80
  }
79
81
 
80
82
  function mergeContentBlockDeltas(
@@ -104,7 +104,7 @@ describe("createTrueFoundryDraftThreadListAdapter", () => {
104
104
  const liveAgentSpec: AgentSpec = {
105
105
  model: { name: "anthropic/claude-opus-4-8" },
106
106
  instructions: "You are helpful.",
107
- mcpServers: [{ name: "github", enableTools: ["@all"] }],
107
+ mcpServers: [{ type: "truefoundry-mcp-registry", name: "github", enableTools: ["@all"] }],
108
108
  skills: [{ fqn: "acme/skill-a:1", preload: false }],
109
109
  };
110
110
  const createDraftSession = vi.fn().mockResolvedValue(
@@ -13,9 +13,9 @@ const createdAt = new Date().toISOString();
13
13
 
14
14
  function streamData(
15
15
  sequenceNumber: number,
16
- event: TurnStreamData["event"],
16
+ event: TurnStreamData["event"] | Record<string, unknown>,
17
17
  ): TurnStreamData {
18
- return { sequenceNumber, event };
18
+ return { sequenceNumber, event: event as TurnStreamData["event"] };
19
19
  }
20
20
 
21
21
  async function collectUpdates(
@@ -150,7 +150,7 @@ describe("streamTurn", () => {
150
150
  });
151
151
  });
152
152
 
153
- it("omits previousTurnId when branching from root", async () => {
153
+ it("forwards previousTurnId null when branching from root", async () => {
154
154
  const execute = vi.fn(() => (async function* () {})());
155
155
  const prepareTurn = vi.fn(() => ({ execute }));
156
156
  const session = {
@@ -169,6 +169,7 @@ describe("streamTurn", () => {
169
169
 
170
170
  expect(prepareTurn).toHaveBeenCalledWith({
171
171
  input: [{ type: "user.message", content: "first" }],
172
+ previousTurnId: null,
172
173
  });
173
174
  });
174
175
 
@@ -248,6 +249,7 @@ describe("streamTurn", () => {
248
249
  status: "error",
249
250
  message:
250
251
  "Publisher Model is not servable in region us-central1.",
252
+ completedAt: createdAt,
251
253
  },
252
254
  });
253
255
  })(),
@@ -285,6 +287,7 @@ describe("streamTurn", () => {
285
287
  createdAt,
286
288
  state: {
287
289
  status: "error",
290
+ completedAt: createdAt,
288
291
  message: "boom",
289
292
  },
290
293
  });
package/src/streamTurn.ts CHANGED
@@ -1,9 +1,9 @@
1
- import {
2
- type AgentSession,
3
- type Turn,
4
- type TurnInputItem,
5
- TrueFoundryGatewayApi,
1
+ import type {
2
+ AgentSession,
3
+ Turn,
4
+ TurnInputItem,
6
5
  } from "truefoundry-gateway-sdk/agents";
6
+ import type { TruefoundryGatewayApi } from "truefoundry-gateway-sdk";
7
7
 
8
8
  import {
9
9
  streamTurnEvents,
@@ -65,14 +65,14 @@ export async function* streamTurnContent(
65
65
  // When previousTurnId is explicitly null, pass it through to prepareTurn so the
66
66
  // SDK serializer emits `previous_turn_id: null` on the wire (first turn in session).
67
67
  // The SDK type doesn't admit null, but the Fern serializer handles it correctly.
68
- const previousTurnId: TrueFoundryGatewayApi.PreviousTurnIdInput | null | undefined =
68
+ const previousTurnId: TruefoundryGatewayApi.PreviousTurnIdInput | null | undefined =
69
69
  options.previousTurnId === null
70
70
  ? null
71
71
  : (options.previousTurnId ?? "auto");
72
72
  const turn = session.prepareTurn({
73
73
  input: buildTurnInput(options),
74
74
  ...(previousTurnId !== undefined
75
- ? { previousTurnId: previousTurnId as TrueFoundryGatewayApi.PreviousTurnIdInput }
75
+ ? { previousTurnId: previousTurnId as TruefoundryGatewayApi.PreviousTurnIdInput }
76
76
  : {}),
77
77
  });
78
78
 
@@ -30,7 +30,6 @@ import {
30
30
  createDraftSessionBridge,
31
31
  DRAFT_SESSION_LAST_UPDATED_AT_HEADER,
32
32
  } from "./private/draftSessionBridge.js";
33
- import { getGatewayFromPrivateClient } from "./private/getGatewayFromPrivateClient.js";
34
33
  import { MCP_AUTH_RESUME_RUN_CUSTOM_KEY } from "./mcpAuth.js";
35
34
  import { createTrueFoundryDraftThreadListAdapter } from "./private/truefoundryDraftThreadListAdapter.js";
36
35
  import { trueFoundryExtras } from "./truefoundryExtras.js";
@@ -164,9 +163,7 @@ function useTrueFoundryAgentRuntimeImpl(
164
163
  onError?.(error);
165
164
  throw error;
166
165
  }
167
- // Same gateway.agents.downloadSandboxFile path as before, via the wrapped client.
168
- const gateway = getGatewayFromPrivateClient(privateClient);
169
- const response = await gateway.agents.downloadSandboxFile(sandboxId, { path });
166
+ const response = await privateClient.downloadSandboxFile(sandboxId, { path });
170
167
  return await response.blob();
171
168
  },
172
169
  [privateClient, sandboxId, onError],