Fixes to evenhub extensions library
This commit is contained in:
1 parent
4bf2769d24
commit
07859c95ad
8 files changed
+203
-34
No files matched your search
@@ -1055,6 +1055,12 @@ export class EvenHubSession implements EvenHubMicClient, EvenHubImuClient, EvenH
|
||||
);
|
||||
}
|
||||
|
||||
/** Log a problem with the app's own calls where its developer will see it: the app's console. */
|
||||
private warnApp(message: string): void {
|
||||
this.log(`evenhub: ${message}`);
|
||||
this.webViewHandle?.evaluateJs(`window.console && console.warn(${JSON.stringify(`Faceclaw: ${message}`)})`);
|
||||
}
|
||||
|
||||
/** Deliver an extension event to the app (e.g. windowLifecycle). */
|
||||
private pushExtEvent(name: string, data: unknown): void {
|
||||
this.webViewHandle?.evaluateJs(
|
||||
@@ -1266,12 +1272,16 @@ export class EvenHubSession implements EvenHubMicClient, EvenHubImuClient, EvenH
|
||||
for (const raw of rawSpecs) {
|
||||
const record = asRecord(raw);
|
||||
const name = readString(record, "name", "");
|
||||
if (!name) continue;
|
||||
const problem = appToolProblem(name, record.parameters);
|
||||
if (problem) {
|
||||
this.warnApp(`setAssistantTools: skipped tool ${JSON.stringify(name)}: ${problem}`);
|
||||
continue;
|
||||
}
|
||||
const availability = record.availability === "open" ? "open" : "foreground";
|
||||
specs.push({
|
||||
name,
|
||||
description: readString(record, "description", ""),
|
||||
inputSchema: asRecord(record.parameters),
|
||||
inputSchema: record.parameters == null ? { type: "object", properties: {} } : asRecord(record.parameters),
|
||||
availability,
|
||||
});
|
||||
}
|
||||
@@ -1362,13 +1372,8 @@ export class EvenHubSession implements EvenHubMicClient, EvenHubImuClient, EvenH
|
||||
if (steps.length === 0) return;
|
||||
for (let i = 0; i < steps.length; i += CFW_SEQ_MAX) {
|
||||
const chunk = steps.slice(i, i + CFW_SEQ_MAX);
|
||||
const payload = buildSoundSequencePayload(chunk);
|
||||
try {
|
||||
await this.sendBuzzerSequence(payload);
|
||||
} catch (error) {
|
||||
this.log(`evenhub: playBuzzer failed: ${error}`);
|
||||
return;
|
||||
}
|
||||
// A send failure rejects the app's promise (handleExtensionCall logs it).
|
||||
await this.sendBuzzerSequence(buildSoundSequencePayload(chunk));
|
||||
if (i + CFW_SEQ_MAX < steps.length) await delay(phraseDurationMs(chunk));
|
||||
}
|
||||
}
|
||||
@@ -1511,6 +1516,35 @@ function configuredApiKeyServices(): string[] {
|
||||
return API_KEY_SERVICES.filter((service) => service.setting.get().trim()).map((service) => service.id);
|
||||
}
|
||||
|
||||
/** App assistant-tool names: what every model provider accepts in a tool name. */
|
||||
const APP_TOOL_NAME = /^[A-Za-z0-9_-]{1,64}$/;
|
||||
|
||||
/**
|
||||
* Why an app's assistant tool can't be offered, or null if it can. Provider
|
||||
* APIs reject a whole request over one bad tool definition, so offering it
|
||||
* would break every assistant turn while the app runs.
|
||||
*/
|
||||
function appToolProblem(name: string, parameters: unknown): string | null {
|
||||
if (!APP_TOOL_NAME.test(name)) return "name must be 1-64 letters, digits, underscores or hyphens";
|
||||
if (parameters == null) return null;
|
||||
const schema = parameters as Record<string, unknown>;
|
||||
if (typeof parameters !== "object" || Array.isArray(parameters) || schema.type !== "object") {
|
||||
return 'parameters must be a JSON Schema with type "object"';
|
||||
}
|
||||
if ("oneOf" in schema || "anyOf" in schema || "allOf" in schema) {
|
||||
return "parameters can't use oneOf, anyOf or allOf at the top level";
|
||||
}
|
||||
const properties = schema.properties;
|
||||
if (properties !== undefined && (!properties || typeof properties !== "object" || Array.isArray(properties))) {
|
||||
return "parameters.properties must be an object";
|
||||
}
|
||||
const required = schema.required;
|
||||
if (required !== undefined && !(Array.isArray(required) && required.every((key) => typeof key === "string"))) {
|
||||
return "parameters.required must be an array of property names";
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/** Coerce an app-supplied buzzer step list into validated {freq, ms, duty?}. */
|
||||
function normalizeBuzzerSteps(raw: unknown[]): Step[] {
|
||||
const out: Step[] = [];
|
||||
|
||||
@@ -34,6 +34,11 @@ export type AssistantBackendConfig =
|
||||
/** Trim history from the head once it grows past this many messages. */
|
||||
const MAX_HISTORY_MESSAGES = 40;
|
||||
|
||||
/** The longest tool name every provider accepts (OpenAI allows 64; Anthropic, 128). */
|
||||
const MAX_API_TOOL_NAME_LENGTH = 64;
|
||||
/** Characters of the sanitized name kept at the start when shortening it. */
|
||||
const SHORTENED_TOOL_NAME_HEAD = 16;
|
||||
|
||||
|
||||
/** Hermes brings its own persona and tools; it only needs to know where the reply is shown. */
|
||||
const HERMES_SYSTEM_PROMPT =
|
||||
@@ -237,13 +242,20 @@ export class AssistantSession {
|
||||
/** Convert a canonical registry name to a provider-legal tool name. */
|
||||
private toApiToolName(name: string): string {
|
||||
let base = name.replace(/[^a-zA-Z0-9_-]/g, "_");
|
||||
// Disambiguate the rare case where two canonical names sanitize alike.
|
||||
if (this.toolNameMap.has(base)) {
|
||||
let i = 2;
|
||||
while (this.toolNameMap.has(`${base}_${i}`)) i++;
|
||||
base = `${base}_${i}`;
|
||||
if (base.length > MAX_API_TOOL_NAME_LENGTH) {
|
||||
// Keep the start (the namespace) and the end (the tool's own name). The
|
||||
// hash of the whole name keeps shortened names distinct and stable.
|
||||
const hash = fnv32(name).toString(16).padStart(8, "0");
|
||||
const tail = MAX_API_TOOL_NAME_LENGTH - SHORTENED_TOOL_NAME_HEAD - hash.length - 2;
|
||||
base = `${base.slice(0, SHORTENED_TOOL_NAME_HEAD)}_${hash}_${base.slice(-tail)}`;
|
||||
}
|
||||
return base;
|
||||
// Disambiguate the rare case where two canonical names sanitize alike.
|
||||
let apiName = base;
|
||||
for (let i = 2; this.toolNameMap.has(apiName); i++) {
|
||||
const suffix = `_${i}`;
|
||||
apiName = base.slice(0, MAX_API_TOOL_NAME_LENGTH - suffix.length) + suffix;
|
||||
}
|
||||
return apiName;
|
||||
}
|
||||
|
||||
private trimHistory(): void {
|
||||
@@ -266,3 +278,13 @@ function startsWithToolResult(message: LlmMessage): boolean {
|
||||
message.content[0]!.type === "tool_result"
|
||||
);
|
||||
}
|
||||
|
||||
/** FNV-1a over UTF-16 code units: a small stable hash for shortened tool names. */
|
||||
function fnv32(text: string): number {
|
||||
let hash = 2166136261;
|
||||
for (let i = 0; i < text.length; i++) {
|
||||
hash ^= text.charCodeAt(i);
|
||||
hash = Math.imul(hash, 16777619);
|
||||
}
|
||||
return hash >>> 0;
|
||||
}
|
||||
@@ -51,8 +51,9 @@ if (!fc) {
|
||||
}
|
||||
```
|
||||
|
||||
`getFaceclawExtensions()` returns `null` everywhere except inside Faceclaw:
|
||||
in the stock Even app, in the EvenHub simulator, in a browser, and in Node.
|
||||
`getFaceclawExtensions()` returns `null` everywhere except inside Faceclaw
|
||||
0.8.3 or later: in the stock Even app, in the EvenHub simulator, in a browser,
|
||||
and in Node.
|
||||
Faceclaw installs the API before any page script runs, so you can call it at
|
||||
startup. You don't need to wait for the bridge first.
|
||||
|
||||
@@ -81,7 +82,12 @@ if (fc && fc.apiVersion >= 2) {
|
||||
}
|
||||
```
|
||||
|
||||
Everything in this release is API level 1.
|
||||
Everything in this release is API level 1, which Faceclaw 0.8.3 and later
|
||||
implement. Faceclaw 0.8.0–0.8.2 injected an incomplete, unversioned preview of
|
||||
the API; `getFaceclawExtensions()` returns `null` there, so whenever it returns
|
||||
the API, every level-1 member is present. If you use
|
||||
`window.getFaceclawExtensions` directly, check that `apiVersion` is a number
|
||||
before relying on it.
|
||||
|
||||
## TypeScript
|
||||
|
||||
@@ -284,9 +290,16 @@ fc.setAssistantTools([
|
||||
|
||||
The assistant sees each tool under your package name, as
|
||||
`app.<packageName>.set_bpm`. Whatever the handler returns is reported back to
|
||||
the assistant. If it throws, the assistant gets the error message. Tools are
|
||||
removed when the app closes; call `setAssistantTools([])` to remove them
|
||||
sooner.
|
||||
the assistant. If it throws, the assistant gets the error message. A handler
|
||||
has 10 seconds to finish before the assistant is told the tool timed out.
|
||||
Tools are removed when the app closes; call `setAssistantTools([])` to remove
|
||||
them sooner.
|
||||
|
||||
Tool names are 1–64 letters, digits, underscores or hyphens. `parameters`
|
||||
must be an object schema (`type: "object"`) without a top-level `oneOf`,
|
||||
`anyOf` or `allOf`, since that is what the assistant's model providers accept.
|
||||
Faceclaw skips a tool that breaks these rules and logs a warning to the app's
|
||||
console.
|
||||
|
||||
### API keys
|
||||
|
||||
|
||||
@@ -42,7 +42,7 @@ carry them out.
|
||||
|
||||
| Property | Modifier | Type | Description |
|
||||
| ------ | ------ | ------ | ------ |
|
||||
| <a id="property-apiversion"></a> `apiVersion` | `readonly` | `number` | The extension API level the host implements. It is `1` for the API described here, and increases by one each time members are added. Members added later are documented with the level that introduced them, so an app can check for them before calling: `if (fc.apiVersion >= 2) fc.someNewerMethod();` |
|
||||
| <a id="property-apiversion"></a> `apiVersion` | `readonly` | `number` | The extension API level the host implements. It is `1` for the API described here (Faceclaw 0.8.3 and later), and increases by one each time members are added. Members added later are documented with the level that introduced them, so an app can check for them before calling: `if (fc.apiVersion >= 2) fc.someNewerMethod();` |
|
||||
|
||||
#### Methods
|
||||
|
||||
@@ -165,7 +165,9 @@ firmware's per-message limit of 48 steps are split and paced automatically.
|
||||
`Promise`\<`void`\>
|
||||
|
||||
A promise that resolves once every part of the sequence has been
|
||||
queued on the glasses, which can be before it finishes playing.
|
||||
queued on the glasses, which can be before it finishes playing. It
|
||||
rejects if sending to the glasses fails. If the glasses aren't
|
||||
connected, the sequence is dropped and the promise still resolves.
|
||||
|
||||
##### addCompassListener()
|
||||
|
||||
@@ -251,6 +253,9 @@ setAssistantTools(tools): void;
|
||||
Declare the app's voice-assistant tools, replacing any set earlier. Each
|
||||
tool's `handler` runs in the app when the assistant calls it.
|
||||
|
||||
Faceclaw skips a tool whose `name` or `parameters` break the rules in
|
||||
[AssistantTool](#assistanttool), and logs a warning to the app's console saying why.
|
||||
|
||||
###### Parameters
|
||||
|
||||
| Parameter | Type | Description |
|
||||
@@ -436,6 +441,10 @@ Return the Faceclaw extension API if the app is running inside Faceclaw, or
|
||||
Safe to call anywhere, at any time; Faceclaw installs the API before any page
|
||||
script runs.
|
||||
|
||||
It also returns `null` in Faceclaw 0.8.0–0.8.2, which had an incomplete,
|
||||
unversioned preview of the API. Whenever it returns the API, every member
|
||||
of API level 1 is present.
|
||||
|
||||
#### Returns
|
||||
|
||||
[`FaceclawExtensions`](#faceclawextensions) \| `null`
|
||||
@@ -878,8 +887,8 @@ The assistant sees the tool namespaced by the app's package name, as
|
||||
|
||||
| Property | Type | Default value | Description |
|
||||
| ------ | ------ | ------ | ------ |
|
||||
| <a id="property-name"></a> `name` | `string` | `undefined` | Bare tool name (no package prefix), for example `"set_color"`. |
|
||||
| <a id="property-name"></a> `name` | `string` | `undefined` | Bare tool name (no package prefix), for example `"set_color"`: 1–64 letters, digits, underscores or hyphens. |
|
||||
| <a id="property-description"></a> `description` | `string` | `undefined` | What the tool does. The assistant reads this to decide when to call it. |
|
||||
| <a id="property-parameters"></a> `parameters?` | [`JsonSchema`](#jsonschema) | `{ type: "object", properties: {} }` | JSON Schema for the arguments object the assistant will pass to `handler`. |
|
||||
| <a id="property-parameters"></a> `parameters?` | [`JsonSchema`](#jsonschema) | `{ type: "object", properties: {} }` | JSON Schema for the arguments object the assistant will pass to `handler`. It must describe an object (`type: "object"`), with any `properties` an object and any `required` an array of names, and must not use `oneOf`, `anyOf` or `allOf` at the top level. These are the schemas the assistant's model providers accept. |
|
||||
| <a id="property-availability"></a> `availability?` | `"open"` \| `"foreground"` | `"foreground"` | When the tool can be called: `"foreground"` only while the app owns the visible window, or `"open"` any time the app is running, including in the background. |
|
||||
| <a id="property-handler"></a> `handler` | (`args`) => `unknown` | `undefined` | Called when the assistant invokes the tool. Return a string, or any JSON-serializable value, to report back to the assistant. Throw (or reject) to report an error. May be async. |
|
||||
| <a id="property-handler"></a> `handler` | (`args`) => `unknown` | `undefined` | Called when the assistant invokes the tool. Return a string, or any JSON-serializable value, to report back to the assistant. Throw (or reject) to report an error. May be async, but must finish within 10 seconds, or the assistant is told the tool timed out. |
|
||||
@@ -489,12 +489,19 @@ export type JsonSchema = Record<string, unknown>;
|
||||
* @group Assistant tools
|
||||
*/
|
||||
export interface AssistantTool<Args = any> {
|
||||
/** Bare tool name (no package prefix), for example `"set_color"`. */
|
||||
/**
|
||||
* Bare tool name (no package prefix), for example `"set_color"`: 1–64
|
||||
* letters, digits, underscores or hyphens.
|
||||
*/
|
||||
name: string;
|
||||
/** What the tool does. The assistant reads this to decide when to call it. */
|
||||
description: string;
|
||||
/**
|
||||
* JSON Schema for the arguments object the assistant will pass to `handler`.
|
||||
* It must describe an object (`type: "object"`), with any `properties` an
|
||||
* object and any `required` an array of names, and must not use `oneOf`,
|
||||
* `anyOf` or `allOf` at the top level. These are the schemas the
|
||||
* assistant's model providers accept.
|
||||
* @defaultValue { type: "object", properties: {} }
|
||||
*/
|
||||
parameters?: JsonSchema;
|
||||
@@ -508,7 +515,8 @@ export interface AssistantTool<Args = any> {
|
||||
/**
|
||||
* Called when the assistant invokes the tool. Return a string, or any
|
||||
* JSON-serializable value, to report back to the assistant. Throw (or reject)
|
||||
* to report an error. May be async.
|
||||
* to report an error. May be async, but must finish within 10 seconds, or
|
||||
* the assistant is told the tool timed out.
|
||||
*/
|
||||
handler: (args: Args) => unknown;
|
||||
}
|
||||
@@ -525,9 +533,9 @@ export interface AssistantTool<Args = any> {
|
||||
export interface FaceclawExtensions {
|
||||
/**
|
||||
* The extension API level the host implements. It is `1` for the API
|
||||
* described here, and increases by one each time members are added. Members
|
||||
* added later are documented with the level that introduced them, so an app
|
||||
* can check for them before calling:
|
||||
* described here (Faceclaw 0.8.3 and later), and increases by one each time
|
||||
* members are added. Members added later are documented with the level that
|
||||
* introduced them, so an app can check for them before calling:
|
||||
*
|
||||
* ```ts
|
||||
* if (fc.apiVersion >= 2) fc.someNewerMethod();
|
||||
@@ -587,7 +595,9 @@ export interface FaceclawExtensions {
|
||||
* firmware's per-message limit of 48 steps are split and paced automatically.
|
||||
*
|
||||
* @returns A promise that resolves once every part of the sequence has been
|
||||
* queued on the glasses, which can be before it finishes playing.
|
||||
* queued on the glasses, which can be before it finishes playing. It
|
||||
* rejects if sending to the glasses fails. If the glasses aren't
|
||||
* connected, the sequence is dropped and the promise still resolves.
|
||||
*/
|
||||
playBuzzer(steps: BuzzerStep[]): Promise<void>;
|
||||
|
||||
@@ -632,6 +642,9 @@ export interface FaceclawExtensions {
|
||||
* Declare the app's voice-assistant tools, replacing any set earlier. Each
|
||||
* tool's `handler` runs in the app when the assistant calls it.
|
||||
*
|
||||
* Faceclaw skips a tool whose `name` or `parameters` break the rules in
|
||||
* {@link AssistantTool}, and logs a warning to the app's console saying why.
|
||||
*
|
||||
* @param tools - The tools to offer. Pass `[]` to remove them all.
|
||||
*/
|
||||
setAssistantTools(tools: AssistantTool[]): void;
|
||||
@@ -718,7 +731,9 @@ declare global {
|
||||
/**
|
||||
* Injected by Faceclaw before any page script runs. `undefined` in the
|
||||
* stock Even app and other hosts. Prefer {@link getFaceclawExtensions},
|
||||
* which checks for it.
|
||||
* which checks for it. If you call it directly, check that the result's
|
||||
* `apiVersion` is a number: Faceclaw 0.8.0–0.8.2 returned an incomplete
|
||||
* preview without one.
|
||||
*/
|
||||
getFaceclawExtensions?: (() => FaceclawExtensions) | null;
|
||||
}
|
||||
@@ -730,9 +745,17 @@ declare global {
|
||||
* Safe to call anywhere, at any time; Faceclaw installs the API before any page
|
||||
* script runs.
|
||||
*
|
||||
* It also returns `null` in Faceclaw 0.8.0–0.8.2, which had an incomplete,
|
||||
* unversioned preview of the API. Whenever it returns the API, every member
|
||||
* of API level 1 is present.
|
||||
*
|
||||
* @group Entry point
|
||||
*/
|
||||
export function getFaceclawExtensions(): FaceclawExtensions | null {
|
||||
const getter = typeof window !== "undefined" ? window.getFaceclawExtensions : null;
|
||||
return typeof getter === "function" ? getter() : null;
|
||||
if (typeof getter !== "function") return null;
|
||||
const extensions = getter();
|
||||
// Faceclaw 0.8.0–0.8.2 injected an unversioned preview with only some of
|
||||
// the level-1 members; treat it as absent.
|
||||
return extensions && typeof extensions.apiVersion === "number" ? extensions : null;
|
||||
}
|
||||
@@ -117,6 +117,27 @@ test('cancelled tools and late callbacks cannot mutate the next turn or its hist
|
||||
assert.equal(session.isTurnActive(), false);
|
||||
});
|
||||
|
||||
test('tool names are sanitized, shortened to 64 characters, kept distinct, and mapped back', () => {
|
||||
const env = sessions();
|
||||
const pkg = 'com.example.some-long-developer-name.evenhub';
|
||||
const names = ['glasses.get_state', `app.${pkg}.set_metronome_tempo_and_signature`,
|
||||
`app.${pkg}.set_metronome_tempo_and_signature_v2`, 'a.b', 'a_b'];
|
||||
const registry = { listTools: () => names.map(name => ({ name, description: '', inputSchema: { type: 'object' } })) };
|
||||
const session = new env.AssistantSession(config(), registry);
|
||||
session.sendUtterance('hi', {}, callbacks());
|
||||
const turn = env.turns.at(-1);
|
||||
const apiNames = turn.buildTools().map(tool => tool.name);
|
||||
assert.equal(apiNames[0], 'glasses_get_state');
|
||||
assert.ok(apiNames.every(name => /^[a-zA-Z0-9_-]{1,64}$/.test(name)), apiNames.join(', '));
|
||||
assert.equal(new Set(apiNames).size, names.length);
|
||||
assert.match(apiNames[1], /^app_com_example_/);
|
||||
assert.match(apiNames[1], /tempo_and_signature$/);
|
||||
assert.deepEqual(apiNames.slice(3), ['a_b', 'a_b_2']);
|
||||
assert.deepEqual(apiNames.map(turn.resolveToolName), names);
|
||||
// The same canonical name shortens the same way on the next turn.
|
||||
assert.deepEqual(turn.buildTools().map(tool => tool.name), apiNames);
|
||||
});
|
||||
|
||||
test('synchronous provider errors do not leave a permanently active turn', () => {
|
||||
const env = sessions(); env.setError();
|
||||
const session = new env.AssistantSession(config());
|
||||
|
||||
@@ -30,6 +30,16 @@ function page() {
|
||||
return { win, fc, posted };
|
||||
}
|
||||
|
||||
test('the package helper returns the shim, and treats unversioned 0.8.0-0.8.2 hosts as absent', () => {
|
||||
const { loader } = require('./helpers/load-typescript.cjs');
|
||||
const helper = (window) => loader(window === undefined ? {} : { window })('evenhub-extensions/src/index.ts').getFaceclawExtensions();
|
||||
const { win, fc } = page();
|
||||
assert.equal(helper(win), fc);
|
||||
assert.equal(helper({ getFaceclawExtensions: () => ({ getVersion: () => 'Faceclaw/0.8.2' }) }), null);
|
||||
assert.equal(helper({}), null);
|
||||
assert.equal(helper(undefined), null);
|
||||
});
|
||||
|
||||
test('the shim implements exactly the members the package declares', () => {
|
||||
const { fc } = page();
|
||||
assert.deepEqual(Object.keys(fc).sort(), interfaceMembers('FaceclawExtensions'));
|
||||
|
||||
@@ -260,3 +260,40 @@ test('EvenHub buzzer RPC uses the host action on iOS and chunks and paces long s
|
||||
assert.equal(played.length, 2);
|
||||
h.session.close();
|
||||
});
|
||||
|
||||
test('EvenHub buzzer RPC rejects the app promise when sending fails', async () => {
|
||||
const sounds = loader()('app/ui/sound-effects.ts');
|
||||
const h = sessionHarness({ '../../ui/sound-effects': sounds }, () => Promise.reject(new Error('link lost')));
|
||||
await assert.rejects(h.session.dispatchExtension('playBuzzer', [[{ freq: 880, ms: 50 }]]), /link lost/);
|
||||
h.session.close();
|
||||
});
|
||||
|
||||
test('EvenHub assistant tools skip malformed names and schemas with a warning in the app console', () => {
|
||||
const offered = [];
|
||||
const h = sessionHarness({ '../../assistant/tool-registry': { toolRegistry: { setAppTools: provider => offered.push(provider), removeAppTools() {} } } });
|
||||
const warnings = [];
|
||||
h.web.console = { warn: message => warnings.push(message) };
|
||||
const object = { type: 'object', properties: { n: { type: 'number' } }, required: ['n'] };
|
||||
h.session.dispatchExtension('setAssistantTools', [[
|
||||
{ name: 'ok', description: 'fine', parameters: object },
|
||||
{ name: 'no_params', description: 'defaults' },
|
||||
{ name: 'has space', parameters: object },
|
||||
{ name: 'x'.repeat(65), parameters: object },
|
||||
{ name: 'untyped', parameters: { properties: {} } },
|
||||
{ name: 'string', parameters: { type: 'string' } },
|
||||
{ name: 'union', parameters: { type: 'object', anyOf: [object] } },
|
||||
{ name: 'bad_props', parameters: { type: 'object', properties: [] } },
|
||||
{ name: 'bad_required', parameters: { type: 'object', required: 'n' } },
|
||||
]]);
|
||||
// Through JSON: the default schema is built in the session's realm.
|
||||
assert.deepEqual(JSON.parse(JSON.stringify(offered[0].specs.map(spec => [spec.name, spec.inputSchema]))), [
|
||||
['ok', object],
|
||||
['no_params', { type: 'object', properties: {} }],
|
||||
]);
|
||||
assert.equal(warnings.length, 7);
|
||||
assert.ok(warnings.every(message => message.startsWith('Faceclaw: setAssistantTools: skipped tool')));
|
||||
assert.match(warnings[0], /"has space": name must be/);
|
||||
assert.match(warnings[2], /"untyped": parameters must be a JSON Schema with type "object"/);
|
||||
assert.match(warnings[4], /"union": parameters can't use oneOf, anyOf or allOf/);
|
||||
h.session.close();
|
||||
});
|
||||
Reference in new issue
Block a user