@olonjs/cli 3.0.165 → 3.0.167

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.
@@ -1817,9 +1817,9 @@ cat << 'END_OF_FILE_CONTENT' > "package.json"
1817
1817
  "@tiptap/extension-link": "^2.11.5",
1818
1818
  "@tiptap/react": "^2.11.5",
1819
1819
  "@tiptap/starter-kit": "^2.11.5",
1820
- "@olonjs/core": "^2.0.1",
1821
- "@olonjs/react": "^0.2.1",
1822
- "@olonjs/studio": "^0.2.1",
1820
+ "@olonjs/core": "^2.0.3",
1821
+ "@olonjs/react": "^0.2.3",
1822
+ "@olonjs/studio": "^0.2.3",
1823
1823
  "class-variance-authority": "^0.7.1",
1824
1824
  "clsx": "^2.1.1",
1825
1825
  "lucide-react": "^0.474.0",
@@ -3206,13 +3206,31 @@ async function main() {
3206
3206
  const runUpdateThenSave = async (value) => {
3207
3207
  const rawUpdate = await page.evaluate(
3208
3208
  async ({ toolName, slug, sectionId, sectionType, fieldKey, value: nextValue }) => {
3209
- const runtime = document.modelContextProtocol;
3210
- if (!runtime?.executeTool) {
3211
- throw new Error('document.modelContextProtocol.executeTool is unavailable.');
3209
+ const args = { slug, sectionId, sectionType, fieldKey, value: nextValue };
3210
+ const native = document.modelContext;
3211
+ const protocol = document.modelContextProtocol;
3212
+ // Native Chrome WebMCP: executeTool(toolObject, args) — the tool object
3213
+ // comes from getTools(). Args format: plain object since Chrome 155;
3214
+ // before that the native expects a JSON string (verified on Chrome 153).
3215
+ if (native && typeof native.executeTool === 'function') {
3216
+ const tools = await native.getTools();
3217
+ const tool = tools.find((entry) => entry.name === toolName);
3218
+ if (!tool) {
3219
+ throw new Error(`Tool "${toolName}" not found in native getTools().`);
3220
+ }
3221
+ const chromeMajor = Number((navigator.userAgent.match(/Chrome\/(\d+)/) ?? [])[1] ?? 0);
3222
+ const nativeArgs = chromeMajor >= 155 ? args : JSON.stringify(args);
3223
+ const result = await native.executeTool(tool, nativeArgs);
3224
+ if (result === null) {
3225
+ throw new Error(`Tool "${toolName}" returned null (navigation).`);
3226
+ }
3227
+ return typeof result === 'string' ? result : JSON.stringify(result);
3228
+ }
3229
+ if (protocol && typeof protocol.executeTool === 'function') {
3230
+ return protocol.executeTool(toolName, JSON.stringify(args));
3212
3231
  }
3213
- return runtime.executeTool(
3214
- toolName,
3215
- JSON.stringify({ slug, sectionId, sectionType, fieldKey, value: nextValue })
3232
+ throw new Error(
3233
+ 'WebMCP runtime unavailable: no document.modelContext (native) and no document.modelContextProtocol (polyfill).',
3216
3234
  );
3217
3235
  },
3218
3236
  {
@@ -3229,7 +3247,30 @@ async function main() {
3229
3247
  throw new Error(`WebMCP ${target.toolName} returned an error: ${rawUpdate}`);
3230
3248
  }
3231
3249
  const rawSave = await page.evaluate(
3232
- async ({ saveToolName }) => document.modelContextProtocol.executeTool(saveToolName, '{}'),
3250
+ async ({ saveToolName }) => {
3251
+ const native = document.modelContext;
3252
+ const protocol = document.modelContextProtocol;
3253
+ if (native && typeof native.executeTool === 'function') {
3254
+ const tools = await native.getTools();
3255
+ const tool = tools.find((entry) => entry.name === saveToolName);
3256
+ if (!tool) {
3257
+ throw new Error(`Tool "${saveToolName}" not found in native getTools().`);
3258
+ }
3259
+ const chromeMajor = Number((navigator.userAgent.match(/Chrome\/(\d+)/) ?? [])[1] ?? 0);
3260
+ const nativeArgs = chromeMajor >= 155 ? {} : '{}';
3261
+ const result = await native.executeTool(tool, nativeArgs);
3262
+ if (result === null) {
3263
+ throw new Error(`Tool "${saveToolName}" returned null (navigation).`);
3264
+ }
3265
+ return typeof result === 'string' ? result : JSON.stringify(result);
3266
+ }
3267
+ if (protocol && typeof protocol.executeTool === 'function') {
3268
+ return protocol.executeTool(saveToolName, '{}');
3269
+ }
3270
+ throw new Error(
3271
+ 'WebMCP runtime unavailable: no document.modelContext (native) and no document.modelContextProtocol (polyfill).',
3272
+ );
3273
+ },
3233
3274
  { saveToolName: target.saveToolName }
3234
3275
  );
3235
3276
  const parsedSave = JSON.parse(rawSave);
@@ -3287,9 +3328,17 @@ async function main() {
3287
3328
  );
3288
3329
  }
3289
3330
 
3290
- const toolNames = await page.evaluate(() => {
3291
- const runtime = document.modelContextProtocol;
3292
- return runtime?.listTools?.().map((tool) => tool.name) ?? [];
3331
+ const toolNames = await page.evaluate(async () => {
3332
+ const native = document.modelContext;
3333
+ const protocol = document.modelContextProtocol;
3334
+ if (native && typeof native.getTools === 'function') {
3335
+ const tools = await native.getTools();
3336
+ return tools.map((tool) => tool.name);
3337
+ }
3338
+ if (protocol && typeof protocol.listTools === 'function') {
3339
+ return protocol.listTools().map((tool) => tool.name);
3340
+ }
3341
+ return [];
3293
3342
  });
3294
3343
  for (const required of [target.toolName, target.saveToolName]) {
3295
3344
  if (!toolNames.includes(required)) {
@@ -1817,9 +1817,9 @@ cat << 'END_OF_FILE_CONTENT' > "package.json"
1817
1817
  "@tiptap/extension-link": "^2.11.5",
1818
1818
  "@tiptap/react": "^2.11.5",
1819
1819
  "@tiptap/starter-kit": "^2.11.5",
1820
- "@olonjs/core": "^2.0.1",
1821
- "@olonjs/react": "^0.2.1",
1822
- "@olonjs/studio": "^0.2.1",
1820
+ "@olonjs/core": "^2.0.3",
1821
+ "@olonjs/react": "^0.2.3",
1822
+ "@olonjs/studio": "^0.2.3",
1823
1823
  "class-variance-authority": "^0.7.1",
1824
1824
  "clsx": "^2.1.1",
1825
1825
  "lucide-react": "^0.474.0",
@@ -3206,13 +3206,31 @@ async function main() {
3206
3206
  const runUpdateThenSave = async (value) => {
3207
3207
  const rawUpdate = await page.evaluate(
3208
3208
  async ({ toolName, slug, sectionId, sectionType, fieldKey, value: nextValue }) => {
3209
- const runtime = document.modelContextProtocol;
3210
- if (!runtime?.executeTool) {
3211
- throw new Error('document.modelContextProtocol.executeTool is unavailable.');
3209
+ const args = { slug, sectionId, sectionType, fieldKey, value: nextValue };
3210
+ const native = document.modelContext;
3211
+ const protocol = document.modelContextProtocol;
3212
+ // Native Chrome WebMCP: executeTool(toolObject, args) — the tool object
3213
+ // comes from getTools(). Args format: plain object since Chrome 155;
3214
+ // before that the native expects a JSON string (verified on Chrome 153).
3215
+ if (native && typeof native.executeTool === 'function') {
3216
+ const tools = await native.getTools();
3217
+ const tool = tools.find((entry) => entry.name === toolName);
3218
+ if (!tool) {
3219
+ throw new Error(`Tool "${toolName}" not found in native getTools().`);
3220
+ }
3221
+ const chromeMajor = Number((navigator.userAgent.match(/Chrome\/(\d+)/) ?? [])[1] ?? 0);
3222
+ const nativeArgs = chromeMajor >= 155 ? args : JSON.stringify(args);
3223
+ const result = await native.executeTool(tool, nativeArgs);
3224
+ if (result === null) {
3225
+ throw new Error(`Tool "${toolName}" returned null (navigation).`);
3226
+ }
3227
+ return typeof result === 'string' ? result : JSON.stringify(result);
3228
+ }
3229
+ if (protocol && typeof protocol.executeTool === 'function') {
3230
+ return protocol.executeTool(toolName, JSON.stringify(args));
3212
3231
  }
3213
- return runtime.executeTool(
3214
- toolName,
3215
- JSON.stringify({ slug, sectionId, sectionType, fieldKey, value: nextValue })
3232
+ throw new Error(
3233
+ 'WebMCP runtime unavailable: no document.modelContext (native) and no document.modelContextProtocol (polyfill).',
3216
3234
  );
3217
3235
  },
3218
3236
  {
@@ -3229,7 +3247,30 @@ async function main() {
3229
3247
  throw new Error(`WebMCP ${target.toolName} returned an error: ${rawUpdate}`);
3230
3248
  }
3231
3249
  const rawSave = await page.evaluate(
3232
- async ({ saveToolName }) => document.modelContextProtocol.executeTool(saveToolName, '{}'),
3250
+ async ({ saveToolName }) => {
3251
+ const native = document.modelContext;
3252
+ const protocol = document.modelContextProtocol;
3253
+ if (native && typeof native.executeTool === 'function') {
3254
+ const tools = await native.getTools();
3255
+ const tool = tools.find((entry) => entry.name === saveToolName);
3256
+ if (!tool) {
3257
+ throw new Error(`Tool "${saveToolName}" not found in native getTools().`);
3258
+ }
3259
+ const chromeMajor = Number((navigator.userAgent.match(/Chrome\/(\d+)/) ?? [])[1] ?? 0);
3260
+ const nativeArgs = chromeMajor >= 155 ? {} : '{}';
3261
+ const result = await native.executeTool(tool, nativeArgs);
3262
+ if (result === null) {
3263
+ throw new Error(`Tool "${saveToolName}" returned null (navigation).`);
3264
+ }
3265
+ return typeof result === 'string' ? result : JSON.stringify(result);
3266
+ }
3267
+ if (protocol && typeof protocol.executeTool === 'function') {
3268
+ return protocol.executeTool(saveToolName, '{}');
3269
+ }
3270
+ throw new Error(
3271
+ 'WebMCP runtime unavailable: no document.modelContext (native) and no document.modelContextProtocol (polyfill).',
3272
+ );
3273
+ },
3233
3274
  { saveToolName: target.saveToolName }
3234
3275
  );
3235
3276
  const parsedSave = JSON.parse(rawSave);
@@ -3287,9 +3328,17 @@ async function main() {
3287
3328
  );
3288
3329
  }
3289
3330
 
3290
- const toolNames = await page.evaluate(() => {
3291
- const runtime = document.modelContextProtocol;
3292
- return runtime?.listTools?.().map((tool) => tool.name) ?? [];
3331
+ const toolNames = await page.evaluate(async () => {
3332
+ const native = document.modelContext;
3333
+ const protocol = document.modelContextProtocol;
3334
+ if (native && typeof native.getTools === 'function') {
3335
+ const tools = await native.getTools();
3336
+ return tools.map((tool) => tool.name);
3337
+ }
3338
+ if (protocol && typeof protocol.listTools === 'function') {
3339
+ return protocol.listTools().map((tool) => tool.name);
3340
+ }
3341
+ return [];
3293
3342
  });
3294
3343
  for (const required of [target.toolName, target.saveToolName]) {
3295
3344
  if (!toolNames.includes(required)) {