@openai/agents-realtime 0.11.8 → 0.12.1

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/dist/tool.mjs CHANGED
@@ -16,6 +16,43 @@ export function isValidRealtimeTool(tool) {
16
16
  return (tool.type === 'function' ||
17
17
  (tool.type === 'hosted_tool' && tool.name === 'hosted_mcp'));
18
18
  }
19
+ export function validateRealtimeToolNames(tools, handoffs) {
20
+ const sourcesByName = new Map();
21
+ for (const tool of tools) {
22
+ const sources = sourcesByName.get(tool.name) ?? [];
23
+ sources.push('function tool');
24
+ sourcesByName.set(tool.name, sources);
25
+ }
26
+ for (const handoff of handoffs) {
27
+ const sources = sourcesByName.get(handoff.toolName) ?? [];
28
+ sources.push('handoff');
29
+ sourcesByName.set(handoff.toolName, sources);
30
+ }
31
+ const duplicateDescriptions = [...sourcesByName.entries()]
32
+ .filter(([, sources]) => sources.length > 1)
33
+ .sort(([left], [right]) => left.localeCompare(right))
34
+ .map(([name, sources]) => `'${name}' (${formatRealtimeToolSources(sources)})`);
35
+ if (duplicateDescriptions.length === 0) {
36
+ return;
37
+ }
38
+ const label = duplicateDescriptions.length === 1 ? 'name' : 'names';
39
+ throw new UserError(`Duplicate Realtime tool ${label} found: ${duplicateDescriptions.join(', ')}. ` +
40
+ 'Realtime function tool and handoff names must be unique. Rename one of them before starting the session.');
41
+ }
42
+ function formatRealtimeToolSources(sources) {
43
+ const counts = new Map();
44
+ for (const source of sources) {
45
+ counts.set(source, (counts.get(source) ?? 0) + 1);
46
+ }
47
+ const descriptions = [...counts.entries()].map(([source, count]) => count === 1 ? source : `${count} ${source}s`);
48
+ if (descriptions.length === 1) {
49
+ return descriptions[0];
50
+ }
51
+ if (descriptions.length === 2) {
52
+ return `${descriptions[0]} and ${descriptions[1]}`;
53
+ }
54
+ return `${descriptions.slice(0, -1).join(', ')}, and ${descriptions.at(-1)}`;
55
+ }
19
56
  export function toRealtimeToolDefinition(tool) {
20
57
  if (tool.type === 'function') {
21
58
  return tool;
package/dist/tool.mjs.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"tool.mjs","sourceRoot":"","sources":["../src/tool.ts"],"names":[],"mappings":"OAAO,EAIL,SAAS,GACV,MAAM,qBAAqB;OACrB,EAAE,iCAAiC,EAAE,MAAM,2BAA2B;AAG7E,MAAM,CAAC,MAAM,wBAAwB,GAAG,MAAM,CAAC,kBAAkB,CAAC,CAAC;AAOnE,MAAM,UAAU,gBAAgB,CAAI,OAAU;IAC5C,OAAO;QACL,CAAC,wBAAwB,CAAC,EAAE,IAAI;QAChC,OAAO;KACR,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,kBAAkB,CAChC,MAAe;IAEf,OAAO,CACL,OAAO,MAAM,KAAK,QAAQ;QAC1B,MAAM,KAAK,IAAI;QACf,wBAAwB,IAAI,MAAM,CACnC,CAAC;AACJ,CAAC;AAID,MAAM,UAAU,mBAAmB,CAAC,IAAe;IACjD,OAAO,CACL,IAAI,CAAC,IAAI,KAAK,UAAU;QACxB,CAAC,IAAI,CAAC,IAAI,KAAK,aAAa,IAAI,IAAI,CAAC,IAAI,KAAK,YAAY,CAAC,CAC5D,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,wBAAwB,CACtC,IAAkB;IAElB,IAAI,IAAI,CAAC,IAAI,KAAK,UAAU,EAAE,CAAC;QAC7B,OAAO,IAAI,CAAC;IACd,CAAC;IACD,IAAI,IAAI,CAAC,IAAI,KAAK,aAAa,IAAI,IAAI,CAAC,IAAI,KAAK,YAAY,EAAE,CAAC;QAC9D,MAAM,SAAS,GACb,IAAI,CAAC,YAAY,CAAC,UAAU,IAAI,IAAI,CAAC,YAAY,CAAC,UAAU,CAAC,MAAM,GAAG,CAAC;YACrE,CAAC,CAAC,IAAI,CAAC,YAAY,CAAC,UAAU;YAC9B,CAAC,CAAC,SAAS,CAAC;QAChB,MAAM,eAAe,GACnB,OAAO,IAAI,CAAC,YAAY,CAAC,gBAAgB,KAAK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AAC;IACd,CAAC;IACD,IAAI,IAAI,CAAC,IAAI,KAAK,aAAa,IAAI,IAAI,CAAC,IAAI,KAAK,YAAY,EAAE,CAAC;QAC9D,MAAM,SAAS,GACb,IAAI,CAAC,YAAY,CAAC,UAAU,IAAI,IAAI,CAAC,YAAY,CAAC,UAAU,CAAC,MAAM,GAAG,CAAC;YACrE,CAAC,CAAC,IAAI,CAAC,YAAY,CAAC,UAAU;YAC9B,CAAC,CAAC,SAAS,CAAC;QAChB,MAAM,eAAe,GACnB,OAAO,IAAI,CAAC,YAAY,CAAC,gBAAgB,KAAK,WAAW;YACvD,CAAC,CAAC,SAAS;YACX,CAAC,CAAC,iCAAiC,CAAC,IAAI,CAAC,YAAY,CAAC,gBAAgB,CAAC,CAAC;QAC5E,OAAO;YACL,IAAI,EAAE,KAAK;YACX,YAAY,EAAE,IAAI,CAAC,YAAY,CAAC,YAAY;YAC5C,UAAU,EAAE,SAAS;YACrB,OAAO,EAAE,IAAI,CAAC,YAAY,CAAC,OAAO;YAClC,aAAa,EAAE,IAAI,CAAC,YAAY,CAAC,aAAa;YAC9C,GAAG,CAAC,OAAO,eAAe,KAAK,WAAW;gBACxC,CAAC,CAAC,EAAE;gBACJ,CAAC,CAAC,EAAE,gBAAgB,EAAE,eAAe,EAAE,CAAC;SAC3C,CAAC;IACJ,CAAC;IAED,MAAM,IAAI,SAAS,CAAC,sBAAsB,IAAI,EAAE,CAAC,CAAC;AACpD,CAAC"}
@@ -18,6 +18,8 @@ export type TransportToolCallEvent = {
18
18
  callId: string;
19
19
  arguments: string;
20
20
  previousItemId?: string;
21
+ /** The response that produced this tool call. */
22
+ responseId: string;
21
23
  };
22
24
  /**
23
25
  * Event representing audio data from the model on the transport layer.
package/package.json CHANGED
@@ -1,8 +1,11 @@
1
1
  {
2
2
  "name": "@openai/agents-realtime",
3
- "repository": "https://github.com/openai/openai-agents-js",
3
+ "repository": {
4
+ "type": "git",
5
+ "url": "https://github.com/openai/openai-agents-js"
6
+ },
4
7
  "homepage": "https://openai.github.io/openai-agents-js/",
5
- "version": "0.11.8",
8
+ "version": "0.12.1",
6
9
  "description": "The OpenAI Agents SDK is a lightweight yet powerful framework for building multi-agent workflows. This package contains the logic for building realtime voice agents on the server or in the browser.",
7
10
  "author": "OpenAI <support@openai.com>",
8
11
  "main": "dist/index.js",
@@ -50,8 +53,8 @@
50
53
  "dependencies": {
51
54
  "@types/ws": "^8.18.1",
52
55
  "debug": "^4.4.0",
53
- "ws": "^8.18.1",
54
- "@openai/agents-core": "0.11.8"
56
+ "ws": "^8.21.0",
57
+ "@openai/agents-core": "0.12.1"
55
58
  },
56
59
  "keywords": [
57
60
  "openai",
@@ -65,7 +68,7 @@
65
68
  },
66
69
  "devDependencies": {
67
70
  "@types/debug": "^4.1.12",
68
- "vite": "^6.4.2",
71
+ "vite": "^6.4.3",
69
72
  "zod": "^4.0.0"
70
73
  },
71
74
  "files": [