@michinarai/cli 0.1.1 → 0.2.0

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/README.md CHANGED
@@ -62,6 +62,7 @@ node scripts/build.mjs && narai build
62
62
  ```sh
63
63
  narai dev --locale ja --task task.json # task.json: the task Narai would start it on ({id, kind, assist, prompt})
64
64
  narai dev --preset preset.json --port 4000
65
+ narai dev --grant microphone # as a step that grants the microphone: only if capabilities.microphone is true
65
66
  ```
66
67
 
67
68
  **`narai login`** signs in to Narai in the browser. The answer comes back to this machine only (127.0.0.1), and the
@@ -9,6 +9,7 @@ export default class Dev extends NaraiCommand<typeof Dev> {
9
9
  locale: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
10
10
  task: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
11
11
  preset: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
12
+ grant: import("@oclif/core/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/interfaces").CustomOptions>;
12
13
  };
13
14
  run(): Promise<void>;
14
15
  }
@@ -25,6 +25,10 @@ export default class Dev extends NaraiCommand {
25
25
  locale: Flags.string({ description: "The locale the tool starts in (default: its first)." }),
26
26
  task: Flags.string({ description: "A JSON file: the task Narai would start it on ({id, kind, assist, prompt})." }),
27
27
  preset: Flags.string({ description: "A JSON file: the step's preset payload ({schema, ...})." }),
28
+ grant: Flags.string({
29
+ description: "What the step grants the tool, as Narai's start does: only what the manifest's capabilities declare.",
30
+ options: ["microphone"], multiple: true,
31
+ }),
28
32
  };
29
33
  async run() {
30
34
  const root = await toolRoot(process.cwd());
@@ -42,8 +46,15 @@ export default class Dev extends NaraiCommand {
42
46
  options.task = task;
43
47
  if (preset)
44
48
  options.preset = preset;
49
+ // Narai grants only what the manifest declares and drops the rest: so does this, saying so
50
+ const asked = (this.flags.grant ?? []);
51
+ const granted = asked.filter((g) => manifest.capabilities?.[g] === true);
52
+ for (const g of asked)
53
+ if (!granted.includes(g))
54
+ this.out.progress(`not granted: ${g} (the manifest's capabilities.${g} isn't true)`);
55
+ options.granted = granted;
45
56
  const harness = await startHarness(options);
46
- this.out.result({ host: harness.hostUrl, tool: harness.toolUrl }, () => [`host ${harness.hostUrl}`, `tool ${harness.toolUrl}`]);
57
+ this.out.result({ host: harness.hostUrl, tool: harness.toolUrl, granted }, () => [`host ${harness.hostUrl}`, `tool ${harness.toolUrl}`, ...(granted.length ? [`granted ${granted.join(", ")}`] : [])]);
47
58
  this.out.progress("Ctrl-C to stop");
48
59
  await new Promise((done) => {
49
60
  const stop = () => { void harness.close().then(done); };
@@ -1 +1 @@
1
- {"version":3,"file":"dev.js","sourceRoot":"","sources":["../../src/commands/dev.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACpC,OAAO,EAAE,YAAY,EAAuB,MAAM,yBAAyB,CAAC;AAC5E,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,eAAe,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAE9D,KAAK,UAAU,IAAI,CAAC,IAAwB,EAAE,IAAY;IACxD,IAAI,CAAC,IAAI;QAAE,OAAO,SAAS,CAAC;IAC5B,IAAI,CAAC;QACH,OAAO,IAAI,CAAC,KAAK,CAAC,MAAM,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC,CAAY,CAAC;IAC7D,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,IAAI,UAAU,CAAC,GAAG,IAAI,IAAI,IAAI,KAAM,KAAe,CAAC,OAAO,EA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K,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;YACxD,OAAO,CAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;YAC7B,OAAO,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC;QAChC,CAAC,CAAC,CAAC;IACL,CAAC"}
@@ -4,7 +4,7 @@ import { NaraiError } from "../lib/errors.js";
4
4
  import { MANIFEST, checkedManifest, readManifest, toolRoot } from "../lib/project.js";
5
5
  export default class Validate extends NaraiCommand {
6
6
  static summary = `Check ${MANIFEST} against the contract, as Narai's registry does.`;
7
- static description = "The schema, then what a schema can't say: every payload a manifest names is declared, no answer payload carries a verdict, commands and answers need an embed that runs the SDK, files sorted by path.";
7
+ static description = "The schema (slugs are lower-case words joined by single hyphens), then what a schema can't say: every payload a manifest names is declared, a music.* payload Narai owns is declared with Narai's schema (musicPayloads), no answer or task payload carries a verdict, commands and answers need an embed that runs the SDK, <name>--<publisher> fits a DNS label, a relative embed url is one of the files, files sorted by path.";
8
8
  async run() {
9
9
  const root = await toolRoot(process.cwd());
10
10
  try {
@@ -1 +1 @@
1
- {"version":3,"file":"validate.js","sourceRoot":"","sources":["../../src/commands/validate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AACnD,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,QAAQ,EAAE,eAAe,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAEtF,MAAM,CAAC,OAAO,OAAO,QAAS,SAAQ,YAA6B;IACjE,MAAM,CAAU,OAAO,GAAG,SAAS,QAAQ,kDAAkD,CAAC;IAC9F,MAAM,CAAU,WAAW,GAAG,wMAAwM,CAAC;IAEvO,KAAK,CAAC,GAAG;QACP,MAAM,IAAI,GAAG,M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AAM,KAAK,CAAC;QACd,CAAC;IACH,CAAC"}
@@ -205,6 +205,34 @@ export interface paths {
205
205
  patch?: never;
206
206
  trace?: never;
207
207
  };
208
+ "/api/tools/launches/{launch}/storage/{key}": {
209
+ parameters: {
210
+ query?: never;
211
+ header?: never;
212
+ path?: never;
213
+ cookie?: never;
214
+ };
215
+ /**
216
+ * Storage Get
217
+ * @description A key the tool kept in this launch.
218
+ */
219
+ get: operations["storage_get_api_tools_launches__launch__storage__key__get"];
220
+ /**
221
+ * Storage Put
222
+ * @description Keep a key in this launch, or rewrite it.
223
+ */
224
+ put: operations["storage_put_api_tools_launches__launch__storage__key__put"];
225
+ post?: never;
226
+ /**
227
+ * Storage Delete
228
+ * @description Remove a key from this launch (done whether or not it was there).
229
+ */
230
+ delete: operations["storage_delete_api_tools_launches__launch__storage__key__delete"];
231
+ options?: never;
232
+ head?: never;
233
+ patch?: never;
234
+ trace?: never;
235
+ };
208
236
  }
209
237
  export type webhooks = Record<string, never>;
210
238
  export interface components {
@@ -281,6 +309,11 @@ export interface components {
281
309
  /** Tokens */
282
310
  tokens: components["schemas"]["CiTokenOut"][];
283
311
  };
312
+ /** HTTPValidationError */
313
+ HTTPValidationError: {
314
+ /** Detail */
315
+ detail?: components["schemas"]["ValidationError"][];
316
+ };
284
317
  /** LaunchIn */
285
318
  LaunchIn: {
286
319
  /** Preset */
@@ -395,6 +428,19 @@ export interface components {
395
428
  /** Scopes */
396
429
  scopes: components["schemas"]["Scope"][];
397
430
  };
431
+ /** StorageIn */
432
+ StorageIn: {
433
+ /**
434
+ * Value
435
+ * @description Any JSON, at most 16384 bytes of it compact
436
+ */
437
+ value: unknown;
438
+ };
439
+ /** StorageOut */
440
+ StorageOut: {
441
+ /** Value */
442
+ value: unknown;
443
+ };
398
444
  /** ToolIn */
399
445
  ToolIn: {
400
446
  /** Name */
@@ -426,6 +472,19 @@ export interface components {
426
472
  /** Tools */
427
473
  tools: components["schemas"]["ToolOut"][];
428
474
  };
475
+ /** ValidationError */
476
+ ValidationError: {
477
+ /** Location */
478
+ loc: (string | number)[];
479
+ /** Message */
480
+ msg: string;
481
+ /** Error Type */
482
+ type: string;
483
+ /** Input */
484
+ input?: unknown;
485
+ /** Context */
486
+ ctx?: Record<string, never>;
487
+ };
429
488
  /** VersionDetail */
430
489
  VersionDetail: {
431
490
  /**
@@ -1496,4 +1555,100 @@ export interface operations {
1496
1555
  };
1497
1556
  };
1498
1557
  };
1558
+ storage_get_api_tools_launches__launch__storage__key__get: {
1559
+ parameters: {
1560
+ query?: never;
1561
+ header?: never;
1562
+ path: {
1563
+ launch: string;
1564
+ key: string;
1565
+ };
1566
+ cookie?: never;
1567
+ };
1568
+ requestBody?: never;
1569
+ responses: {
1570
+ /** @description Successful Response */
1571
+ 200: {
1572
+ headers: {
1573
+ [name: string]: unknown;
1574
+ };
1575
+ content: {
1576
+ "application/json": components["schemas"]["StorageOut"];
1577
+ };
1578
+ };
1579
+ /** @description Validation Error */
1580
+ 422: {
1581
+ headers: {
1582
+ [name: string]: unknown;
1583
+ };
1584
+ content: {
1585
+ "application/json": components["schemas"]["HTTPValidationError"];
1586
+ };
1587
+ };
1588
+ };
1589
+ };
1590
+ storage_put_api_tools_launches__launch__storage__key__put: {
1591
+ parameters: {
1592
+ query?: never;
1593
+ header?: never;
1594
+ path: {
1595
+ launch: string;
1596
+ key: string;
1597
+ };
1598
+ cookie?: never;
1599
+ };
1600
+ requestBody: {
1601
+ content: {
1602
+ "application/json": components["schemas"]["StorageIn"];
1603
+ };
1604
+ };
1605
+ responses: {
1606
+ /** @description Successful Response */
1607
+ 204: {
1608
+ headers: {
1609
+ [name: string]: unknown;
1610
+ };
1611
+ content?: never;
1612
+ };
1613
+ /** @description Validation Error */
1614
+ 422: {
1615
+ headers: {
1616
+ [name: string]: unknown;
1617
+ };
1618
+ content: {
1619
+ "application/json": components["schemas"]["HTTPValidationError"];
1620
+ };
1621
+ };
1622
+ };
1623
+ };
1624
+ storage_delete_api_tools_launches__launch__storage__key__delete: {
1625
+ parameters: {
1626
+ query?: never;
1627
+ header?: never;
1628
+ path: {
1629
+ launch: string;
1630
+ key: string;
1631
+ };
1632
+ cookie?: never;
1633
+ };
1634
+ requestBody?: never;
1635
+ responses: {
1636
+ /** @description Successful Response */
1637
+ 204: {
1638
+ headers: {
1639
+ [name: string]: unknown;
1640
+ };
1641
+ content?: never;
1642
+ };
1643
+ /** @description Validation Error */
1644
+ 422: {
1645
+ headers: {
1646
+ [name: string]: unknown;
1647
+ };
1648
+ content: {
1649
+ "application/json": components["schemas"]["HTTPValidationError"];
1650
+ };
1651
+ };
1652
+ };
1653
+ };
1499
1654
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@michinarai/cli",
3
- "version": "0.1.1",
3
+ "version": "0.2.0",
4
4
  "description": "The narai command: scaffold, validate, build, run and register tools for Narai lessons.",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -43,7 +43,7 @@
43
43
  },
44
44
  "dependencies": {
45
45
  "@inquirer/confirm": "6.3.3",
46
- "@michinarai/sdk": "0.2.1",
46
+ "@michinarai/sdk": "0.3.0",
47
47
  "@napi-rs/keyring": "2.1.1",
48
48
  "@oclif/core": "5.1.7",
49
49
  "openapi-fetch": "0.17.0"
@@ -15,6 +15,8 @@ learner: a tool never grades and never learns who the learner is.
15
15
  - With `assist: honors`, a task whose `assist` is `none` gets no hints and no self-checks from the tool.
16
16
  - Show the task's `prompt` as Narai sends it; it is already in the learner's language. Say `ready` in the locale the
17
17
  tool actually renders.
18
+ - The microphone is the step's to grant, launch by launch: declare `capabilities.microphone: true`, and show its
19
+ control only when `tool.start.granted` has `"microphone"`. `narai dev --grant microphone` simulates the grant.
18
20
  - Only the SDK talks to Narai (`connect`, `ready`, `answer`, `practice`, `onCommand`, `close`). No other `postMessage`,
19
21
  no network unless `capabilities.network` says so.
20
22
 
@@ -13,6 +13,7 @@
13
13
  <input id="text" autocomplete="off">
14
14
  <button id="say">Answer</button>
15
15
  <button id="drill">Practice</button>
16
+ <button id="mic" hidden>Listen</button>
16
17
  </main>
17
18
  <script type="module" src="./tool.js"></script>
18
19
  </body>
@@ -19,3 +19,14 @@ $("say").onclick = () => {
19
19
  $("drill").onclick = () => {
20
20
  tool.practice("drill", { duration_s: 30, attempts: 1, payload: { schema: manifest.practice.drill, rounds: 1 } });
21
21
  };
22
+
23
+ // The microphone is the step's to grant, launch by launch (tool.start.granted), and only when the manifest declares it
24
+ // (capabilities.microphone: true). Without the grant the frame can't open it: show no control for it.
25
+ if (tool.start.granted?.includes("microphone")) {
26
+ $("mic").hidden = false;
27
+ $("mic").onclick = async () => {
28
+ const stream = await navigator.mediaDevices.getUserMedia({ audio: true });
29
+ // listen here, then report what was played (an answer payload such as music.played@1), never whether it's right
30
+ stream.getTracks().forEach((t) => t.stop());
31
+ };
32
+ }