@myvillage/cli 1.69.0 → 1.71.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@myvillage/cli",
3
- "version": "1.69.0",
3
+ "version": "1.71.0",
4
4
  "description": "MyVillageOS CLI for community developers",
5
5
  "type": "module",
6
6
  "bin": {
@@ -0,0 +1,41 @@
1
+ /**
2
+ * Registry of native built-in agent tools — plain data only (no `ai`/`zod`/
3
+ * tfjs imports), so the Studio can read tool metadata cheaply to show built-ins
4
+ * in its tool palette / allowlist alongside MCP tools.
5
+ *
6
+ * Single source of truth for built-in tool name + description + tier:
7
+ * - the agent loop's builtin-tools.js pulls descriptions from here
8
+ * - the Studio (via cli-bridge) imports this to list selectable built-ins
9
+ *
10
+ * `builtin: true` marks them so the UI can distinguish them from MCP tools.
11
+ * Permission `tier` reuses the notification send-tier model.
12
+ */
13
+
14
+ export const DATASET_APPEND_DESCRIPTION =
15
+ 'Append labeled training example(s) to a LOCAL dataset on this machine. ' +
16
+ 'The dataset must already exist (created via the Studio Lab or ' +
17
+ '`myvillage dataset create`). For classification provide `label`; for ' +
18
+ 'regression provide a numeric `target`. Data stays local; provenance ' +
19
+ 'is recorded automatically.';
20
+
21
+ export const MODEL_PREDICT_DESCRIPTION =
22
+ 'Run a prediction with a LOCAL trained model on this machine. ' +
23
+ 'Returns the predicted class with per-class confidence scores ' +
24
+ '(classification) or a numeric value (regression). The model must already ' +
25
+ 'exist (trained in the Studio Lab or via `myvillage model train`).';
26
+
27
+ /** All native built-in tools available to every local agent. */
28
+ export const BUILTIN_TOOL_DEFS = [
29
+ {
30
+ name: 'dataset_append',
31
+ description: DATASET_APPEND_DESCRIPTION,
32
+ tier: 'villager',
33
+ builtin: true,
34
+ },
35
+ {
36
+ name: 'model_predict',
37
+ description: MODEL_PREDICT_DESCRIPTION,
38
+ tier: 'villager',
39
+ builtin: true,
40
+ },
41
+ ];
@@ -15,6 +15,9 @@
15
15
  import { tool } from 'ai';
16
16
  import { z } from 'zod';
17
17
  import { appendRows, datasetExists } from '../utils/dataset-workspace.js';
18
+ import { DATASET_APPEND_DESCRIPTION, MODEL_PREDICT_DESCRIPTION } from './builtin-tools-registry.js';
19
+
20
+ export { BUILTIN_TOOL_DEFS } from './builtin-tools-registry.js';
18
21
 
19
22
  /**
20
23
  * Build the native built-in tools for an agent.
@@ -25,12 +28,7 @@ import { appendRows, datasetExists } from '../utils/dataset-workspace.js';
25
28
  export function getBuiltinTools(agentName, config) {
26
29
  return {
27
30
  dataset_append: tool({
28
- description:
29
- 'Append labeled training example(s) to a LOCAL dataset on this machine. ' +
30
- 'The dataset must already exist (created via the Studio Lab or ' +
31
- '`myvillage dataset create`). For classification provide `label`; for ' +
32
- 'regression provide a numeric `target`. Data stays local; provenance ' +
33
- 'is recorded automatically.',
31
+ description: DATASET_APPEND_DESCRIPTION,
34
32
  inputSchema: z.object({
35
33
  datasetId: z.string().describe('Slug of the local dataset to append to'),
36
34
  rows: z
@@ -73,5 +71,37 @@ export function getBuiltinTools(agentName, config) {
73
71
  }
74
72
  },
75
73
  }),
74
+
75
+ model_predict: tool({
76
+ description: MODEL_PREDICT_DESCRIPTION,
77
+ inputSchema: z.object({
78
+ modelId: z.string().describe('Slug of the local trained model'),
79
+ input: z
80
+ .union([z.string(), z.array(z.number())])
81
+ .describe('Text, or a numeric vector for tabular models'),
82
+ }),
83
+ execute: async ({ modelId, input }) => {
84
+ try {
85
+ // Lazy-load the model/tfjs code so agent startup stays light — tfjs
86
+ // only loads the first time an agent actually predicts.
87
+ const { modelExists, readModelManifest, loadModel } = await import(
88
+ '../utils/model-workspace.js'
89
+ );
90
+ if (!modelExists(modelId)) {
91
+ return {
92
+ error:
93
+ `Model "${modelId}" not found locally. Train one first ` +
94
+ '(Studio Lab or `myvillage model train`).',
95
+ };
96
+ }
97
+ const { predictWithModel } = await import('../utils/model-trainer.js');
98
+ const record = readModelManifest(modelId);
99
+ const model = await loadModel(modelId);
100
+ return predictWithModel(model, record, input);
101
+ } catch (e) {
102
+ return { error: e.message };
103
+ }
104
+ },
105
+ }),
76
106
  };
77
107
  }