@majkapp/plugin-kit 3.7.6 → 3.7.10

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.
@@ -179,7 +179,7 @@ cli.addCommand('--tasks',
179
179
  // Knowledge API
180
180
  cli.addCommand('--knowledge',
181
181
  cli.createFullDocCommand('KNOWLEDGE.md'),
182
- { description: 'Knowledge trees and search' }
182
+ { description: 'Knowledge Fabric for semantic search and contribution' }
183
183
  );
184
184
 
185
185
  // Agents API
@@ -79,7 +79,7 @@ if (!isHelpRequest) {
79
79
  // Normal commander behavior (generator commands)
80
80
  commander_1.program
81
81
  .name('plugin-kit')
82
- .version('1.0.20')
82
+ .version('3.7.10')
83
83
  .description('Plugin Kit CLI - Generate TypeScript clients from plugin definitions');
84
84
  commander_1.program
85
85
  .command('generate')
@@ -193,11 +193,27 @@ commander_1.program
193
193
  .option('--llm:context', 'Show context API documentation')
194
194
  .option('--llm:services', 'Show service grouping documentation')
195
195
  .option('--llm:teammates', 'Show AI teammates documentation')
196
+ .option('--llm:ai', 'Show AI providers and LLMs documentation')
196
197
  .option('--llm:lifecycle', 'Show lifecycle hooks documentation')
197
198
  .option('--llm:testing', 'Show testing guide')
198
199
  .option('--llm:config', 'Show project configuration guide')
199
200
  .option('--llm:api', 'Show API reference')
200
- .option('--llm:full', 'Show complete reference');
201
+ .option('--llm:full', 'Show complete reference')
202
+ // Additional MAJK APIs
203
+ .option('--llm:delegation', 'Multi-agent task delegation with witnesses')
204
+ .option('--llm:batch', 'Batch processing for large datasets')
205
+ .option('--llm:reports', 'Knowledge management and reports')
206
+ .option('--llm:scripting', 'Execute scripts that orchestrate tools')
207
+ .option('--llm:tool-discovery', 'Discover and invoke tools dynamically')
208
+ .option('--llm:skills', 'Skill registration and management')
209
+ .option('--llm:auth', 'Cognito authentication for MAJK services')
210
+ .option('--llm:secrets', 'Secure secret storage and retrieval')
211
+ .option('--llm:config-api', 'Access MAJK configuration')
212
+ .option('--llm:plugins', 'Plugin lifecycle management')
213
+ .option('--llm:tasks', 'Start and monitor async tasks')
214
+ .option('--llm:knowledge', 'Knowledge Fabric for semantic search and contribution')
215
+ .option('--llm:agents', 'Agent configuration and testing')
216
+ .option('--llm:conversations', 'Conversation access and management');
201
217
  commander_1.program.parse();
202
218
  async function extractMetadata(entryPath) {
203
219
  // Create a temp file for the output
@@ -1035,11 +1035,428 @@ export interface KnowledgeSearchOptions {
1035
1035
  tree?: string;
1036
1036
  limit?: number;
1037
1037
  }
1038
+ /**
1039
+ * System-reserved prefixes that plugins cannot use for contributions.
1040
+ */
1041
+ export declare const RESERVED_PREFIXES: readonly ["/projects", "/teammates", "/tools", "/skills", "/reports", "/characterizations"];
1042
+ /**
1043
+ * Node status in the Knowledge Fabric.
1044
+ */
1045
+ export type FabricNodeStatus = 'active' | 'pending' | 'inactive';
1046
+ /**
1047
+ * A node in the Knowledge Fabric.
1048
+ *
1049
+ * This is the API-facing representation of a fabric node.
1050
+ */
1051
+ export interface KnowledgeFabricNode {
1052
+ /** Hierarchical key path (e.g., "/plugins/my-plugin/entities/item-1") */
1053
+ key: string;
1054
+ /** Human-readable title */
1055
+ title: string;
1056
+ /** The searchable content */
1057
+ content: string;
1058
+ /** Child node keys */
1059
+ children: string[];
1060
+ /** Metadata and source references */
1061
+ refs: Record<string, unknown>;
1062
+ /** Who contributed this node */
1063
+ contributorId: string;
1064
+ /** Current lifecycle status */
1065
+ status: FabricNodeStatus;
1066
+ /** When this node was created (timestamp) */
1067
+ createdAt: number;
1068
+ /** When this node was last contributed (timestamp) */
1069
+ lastContributed: number;
1070
+ }
1071
+ /**
1072
+ * Input for contributing a node to the fabric.
1073
+ */
1074
+ export interface ContributeNodeInput {
1075
+ /**
1076
+ * Key for this node (relative to the contribution prefix).
1077
+ *
1078
+ * Will be combined with the contribution prefix:
1079
+ * prefix: "/plugins/my-plugin/entities"
1080
+ * key: "item-1"
1081
+ * → full key: "/plugins/my-plugin/entities/item-1"
1082
+ */
1083
+ key: string;
1084
+ /** Human-readable title */
1085
+ title: string;
1086
+ /** Searchable content (what gets embedded for semantic search) */
1087
+ content: string;
1088
+ /** Optional child keys (relative to prefix) */
1089
+ children?: string[];
1090
+ /** Optional metadata/references */
1091
+ refs?: Record<string, unknown>;
1092
+ }
1093
+ /**
1094
+ * Options for semantic search.
1095
+ */
1096
+ export interface FabricSearchOptions {
1097
+ /**
1098
+ * Scope search to this key prefix.
1099
+ *
1100
+ * @example
1101
+ * // Search only within your plugin's knowledge
1102
+ * { under: handle.prefix }
1103
+ *
1104
+ * // Search within a specific project
1105
+ * { under: '/projects/project-abc123' }
1106
+ */
1107
+ under?: string;
1108
+ /** Maximum number of results (default: 10, max: 100) */
1109
+ limit?: number;
1110
+ /** Minimum similarity score 0-1 */
1111
+ minScore?: number;
1112
+ }
1113
+ /**
1114
+ * A single search result.
1115
+ */
1116
+ export interface FabricSearchResult {
1117
+ /** The matching node */
1118
+ node: KnowledgeFabricNode;
1119
+ /** Similarity score 0-1 (1 = most similar) */
1120
+ score: number;
1121
+ }
1122
+ /**
1123
+ * Response from a search operation.
1124
+ */
1125
+ export interface FabricSearchResponse {
1126
+ /** Search results ordered by relevance */
1127
+ results: FabricSearchResult[];
1128
+ /** Current indexing status */
1129
+ indexingStatus: {
1130
+ /** Are all nodes in scope fully indexed? */
1131
+ complete: boolean;
1132
+ /** Number of nodes still being indexed */
1133
+ pendingCount: number;
1134
+ };
1135
+ }
1136
+ /**
1137
+ * Result of expanding a node to see its children.
1138
+ */
1139
+ export interface FabricExpandResult {
1140
+ /** The expanded node */
1141
+ node: KnowledgeFabricNode;
1142
+ /** Direct children of this node */
1143
+ children: KnowledgeFabricNode[];
1144
+ }
1145
+ /**
1146
+ * Overall status of the Knowledge Fabric.
1147
+ */
1148
+ export interface FabricStatus {
1149
+ /** Total number of nodes in the fabric */
1150
+ totalNodes: number;
1151
+ /** Number of active, searchable nodes */
1152
+ activeNodes: number;
1153
+ /** Number of nodes awaiting embedding */
1154
+ pendingNodes: number;
1155
+ /** Total number of unique embeddings */
1156
+ totalEmbeddings: number;
1157
+ /** Whether semantic search is available */
1158
+ searchAvailable: boolean;
1159
+ }
1160
+ /**
1161
+ * Options for registering a knowledge contribution.
1162
+ */
1163
+ export interface RegisterContributionOptions {
1164
+ /**
1165
+ * Custom prefix for this contribution.
1166
+ *
1167
+ * DEFAULT: `/plugins/{pluginId}/{subPrefix}`
1168
+ *
1169
+ * CUSTOM: Any prefix except:
1170
+ * - Reserved system prefixes: /projects, /teammates, /tools, /skills, /reports
1171
+ * - Other plugins' namespaces: /plugins/{otherPluginId}/...
1172
+ *
1173
+ * Prefixes are EXCLUSIVE - first to register owns it.
1174
+ * To share a namespace with other plugins, use sub-prefixes:
1175
+ * Plugin A: /contacts/hubspot
1176
+ * Plugin B: /contacts/salesforce
1177
+ */
1178
+ prefix?: string;
1179
+ /**
1180
+ * Initial nodes to contribute on registration.
1181
+ *
1182
+ * These are contributed before the handle is returned,
1183
+ * so they're immediately available for search (after indexing).
1184
+ */
1185
+ initialNodes?: ContributeNodeInput[];
1186
+ /**
1187
+ * Optional label resolver for virtual nodes in the hierarchy.
1188
+ *
1189
+ * Called when the fabric needs a human-readable label for a path segment.
1190
+ *
1191
+ * @param key - The full key path
1192
+ * @param segment - The specific segment to label
1193
+ * @param depth - The depth of the segment (1-indexed)
1194
+ * @returns Display label, or null to use default formatting
1195
+ */
1196
+ resolveLabel?: (key: string, segment: string, depth: number) => string | null;
1197
+ }
1198
+ /**
1199
+ * Handle for managing a knowledge contribution.
1200
+ *
1201
+ * Returned by `registerContribution()`. Use this to add, update,
1202
+ * and remove nodes from your contribution.
1203
+ */
1204
+ export interface KnowledgeContributionHandle {
1205
+ /**
1206
+ * The full key prefix for this contribution.
1207
+ *
1208
+ * All nodes you contribute will be under this prefix.
1209
+ */
1210
+ readonly prefix: string;
1211
+ /**
1212
+ * The contributor ID for this contribution.
1213
+ *
1214
+ * Format: `plugin:{pluginId}:{subPrefix}`
1215
+ */
1216
+ readonly contributorId: string;
1217
+ /**
1218
+ * Contribute a single node.
1219
+ *
1220
+ * If a node with this key already exists (from this contributor),
1221
+ * it will be updated. The node will be queued for embedding.
1222
+ *
1223
+ * @param node - The node to contribute
1224
+ */
1225
+ contribute(node: ContributeNodeInput): Promise<void>;
1226
+ /**
1227
+ * Contribute multiple nodes in batch.
1228
+ *
1229
+ * More efficient than calling contribute() multiple times.
1230
+ *
1231
+ * @param nodes - The nodes to contribute
1232
+ */
1233
+ contributeBatch(nodes: ContributeNodeInput[]): Promise<void>;
1234
+ /**
1235
+ * Remove a node by key.
1236
+ *
1237
+ * The key is relative to the contribution prefix.
1238
+ *
1239
+ * @param key - The key of the node to remove (relative to prefix)
1240
+ * @returns true if the node was found and removed
1241
+ */
1242
+ remove(key: string): Promise<boolean>;
1243
+ /**
1244
+ * Get the current number of nodes in this contribution.
1245
+ */
1246
+ getNodeCount(): Promise<number>;
1247
+ /**
1248
+ * List all keys in this contribution.
1249
+ *
1250
+ * @param options - Optional filtering options
1251
+ * @returns Array of full keys
1252
+ */
1253
+ listKeys(options?: {
1254
+ status?: 'active' | 'pending' | 'all';
1255
+ }): Promise<string[]>;
1256
+ /**
1257
+ * Reconcile this contribution.
1258
+ *
1259
+ * This re-syncs the contribution by:
1260
+ * 1. Marking all existing nodes as inactive
1261
+ * 2. Re-contributing all nodes from the source
1262
+ * 3. Nodes not re-contributed stay inactive (will be GC'd)
1263
+ *
1264
+ * Useful when the underlying data source may have changed.
1265
+ *
1266
+ * @returns Statistics about what changed
1267
+ */
1268
+ reconcile(): Promise<{
1269
+ added: number;
1270
+ updated: number;
1271
+ deactivated: number;
1272
+ }>;
1273
+ /**
1274
+ * Unregister this contribution.
1275
+ *
1276
+ * All nodes from this contribution will be marked inactive
1277
+ * and eventually garbage collected.
1278
+ *
1279
+ * After calling this, the handle is no longer usable.
1280
+ */
1281
+ unregister(): Promise<void>;
1282
+ }
1283
+ /**
1284
+ * Summary of a contribution for listing.
1285
+ */
1286
+ export interface ContributionSummary {
1287
+ /** The full key prefix */
1288
+ prefix: string;
1289
+ /** The contributor ID */
1290
+ contributorId: string;
1291
+ /** Number of active nodes */
1292
+ nodeCount: number;
1293
+ /** Number of pending nodes */
1294
+ pendingCount: number;
1295
+ /** Current status */
1296
+ status: 'ready' | 'indexing' | 'unregistered';
1297
+ }
1298
+ /**
1299
+ * Events emitted by the fabric that plugins can subscribe to.
1300
+ */
1301
+ export type FabricNodeEvent = {
1302
+ type: 'indexed';
1303
+ key: string;
1304
+ } | {
1305
+ type: 'activated';
1306
+ key: string;
1307
+ } | {
1308
+ type: 'deactivated';
1309
+ key: string;
1310
+ } | {
1311
+ type: 'reindexed';
1312
+ key: string;
1313
+ };
1314
+ /**
1315
+ * Knowledge Fabric API for plugins.
1316
+ *
1317
+ * Provides unified access to the Knowledge Fabric for:
1318
+ * - Semantic search across all knowledge
1319
+ * - Browsing the knowledge hierarchy
1320
+ * - Contributing plugin-specific knowledge
1321
+ *
1322
+ * Access via `ctx.majk.knowledge.fabric`
1323
+ */
1324
+ export interface KnowledgeFabricAPI {
1325
+ /**
1326
+ * Semantic search across all knowledge in the system.
1327
+ *
1328
+ * Searches:
1329
+ * - Project notes (knowledge trees)
1330
+ * - Teammates
1331
+ * - Tools
1332
+ * - Plugins
1333
+ * - Skills
1334
+ * - Reports
1335
+ * - Plugin-contributed knowledge
1336
+ *
1337
+ * @param query - Natural language search query
1338
+ * @param options - Search options (scope, limit, min score)
1339
+ * @returns Matching nodes ordered by relevance
1340
+ *
1341
+ * @example
1342
+ * // Search all knowledge
1343
+ * const results = await fabric.search('authentication patterns');
1344
+ *
1345
+ * // Search within a specific scope
1346
+ * const results = await fabric.search('authentication', {
1347
+ * under: '/projects/my-project',
1348
+ * limit: 5,
1349
+ * minScore: 0.3
1350
+ * });
1351
+ */
1352
+ search(query: string, options?: FabricSearchOptions): Promise<FabricSearchResponse>;
1353
+ /**
1354
+ * Get root nodes of the knowledge hierarchy.
1355
+ *
1356
+ * @returns Top-level nodes (/projects, /plugins, /teammates, etc.)
1357
+ */
1358
+ getRoots(): Promise<KnowledgeFabricNode[]>;
1359
+ /**
1360
+ * Expand a node to see its children.
1361
+ *
1362
+ * @param key - The node key to expand
1363
+ * @returns The node and its direct children, or null if not found
1364
+ *
1365
+ * @example
1366
+ * const result = await fabric.expand('/plugins');
1367
+ * console.log(result.children); // All plugin nodes
1368
+ */
1369
+ expand(key: string): Promise<FabricExpandResult | null>;
1370
+ /**
1371
+ * Get a single node by key.
1372
+ *
1373
+ * @param key - The node key
1374
+ * @returns The node or null if not found
1375
+ */
1376
+ getNode(key: string): Promise<KnowledgeFabricNode | null>;
1377
+ /**
1378
+ * Get the current status of the Knowledge Fabric.
1379
+ *
1380
+ * @returns Status including node counts and search availability
1381
+ */
1382
+ getStatus(): Promise<FabricStatus>;
1383
+ /**
1384
+ * Register a knowledge contribution for this plugin.
1385
+ *
1386
+ * Creates a scoped namespace for the plugin to contribute knowledge.
1387
+ * Returns a handle for managing nodes in the contribution.
1388
+ *
1389
+ * @param subPrefix - Sub-namespace name (e.g., "entities", "docs")
1390
+ * @param options - Configuration including custom prefix and initial nodes
1391
+ * @returns Handle for managing the contribution
1392
+ *
1393
+ * @example
1394
+ * // Using default prefix (recommended)
1395
+ * const handle = await fabric.registerContribution('contacts', {
1396
+ * initialNodes: [
1397
+ * { key: 'john', title: 'John Doe', content: 'CEO at Acme Corp...' }
1398
+ * ]
1399
+ * });
1400
+ * // Prefix: /plugins/{pluginId}/contacts
1401
+ *
1402
+ * // Using custom prefix
1403
+ * const handle = await fabric.registerContribution('contacts', {
1404
+ * prefix: '/crm/contacts'
1405
+ * });
1406
+ * // Prefix: /crm/contacts
1407
+ */
1408
+ registerContribution(subPrefix: string, options?: RegisterContributionOptions): Promise<KnowledgeContributionHandle>;
1409
+ /**
1410
+ * List all contributions registered by this plugin.
1411
+ *
1412
+ * @returns Array of contribution summaries
1413
+ */
1414
+ listContributions(): Promise<ContributionSummary[]>;
1415
+ /**
1416
+ * Subscribe to node change events.
1417
+ *
1418
+ * Events are filtered to this plugin's contributions by default.
1419
+ *
1420
+ * @param handler - Event handler function
1421
+ * @param options - Optional filter options
1422
+ * @returns Unsubscribe function
1423
+ *
1424
+ * @example
1425
+ * const unsub = fabric.onNodeChange((event) => {
1426
+ * console.log(`Node ${event.key} was ${event.type}`);
1427
+ * });
1428
+ *
1429
+ * // Later: unsub();
1430
+ */
1431
+ onNodeChange(handler: (event: FabricNodeEvent) => void, options?: {
1432
+ allNodes?: boolean;
1433
+ }): () => void;
1434
+ }
1038
1435
  export interface KnowledgeAPI {
1436
+ /**
1437
+ * Access to the unified Knowledge Fabric.
1438
+ *
1439
+ * Provides semantic search across all knowledge and
1440
+ * the ability to contribute plugin-specific knowledge.
1441
+ *
1442
+ * @example
1443
+ * // Search all knowledge
1444
+ * const results = await ctx.majk.knowledge.fabric.search('authentication');
1445
+ *
1446
+ * // Contribute knowledge
1447
+ * const handle = await ctx.majk.knowledge.fabric.registerContribution('contacts');
1448
+ * await handle.contribute({ key: 'c1', title: 'Contact', content: '...' });
1449
+ */
1450
+ readonly fabric: KnowledgeFabricAPI;
1451
+ /** @deprecated Use fabric.search() for semantic search */
1039
1452
  add(input: AddKnowledgeInput): Promise<void>;
1453
+ /** @deprecated Use fabric.search() for semantic search */
1040
1454
  search(query: string, options?: KnowledgeSearchOptions): Promise<KnowledgeNode[]>;
1455
+ /** @deprecated Use fabric for knowledge operations */
1041
1456
  getByReference(ref: string): Promise<KnowledgeNode[]>;
1457
+ /** @deprecated Use fabric for knowledge operations */
1042
1458
  getTree(conversationId: string, treeName: string): Promise<KnowledgeTree>;
1459
+ /** @deprecated Use fabric for knowledge operations */
1043
1460
  listTrees(conversationId: string): Promise<string[]>;
1044
1461
  }
1045
1462
  /**
@@ -2038,6 +2455,17 @@ export interface DelegationAPI {
2038
2455
  context?: Witness;
2039
2456
  witness: Witness;
2040
2457
  workingDirectory?: string;
2458
+ /**
2459
+ * Run the task in the background (hidden from UI).
2460
+ * Use this for batch operations or when you want to run multiple tasks without UI clutter.
2461
+ */
2462
+ background?: boolean;
2463
+ /**
2464
+ * If true, use the task field as-is without any enhancement.
2465
+ * By default, tasks are enhanced with context, witness criteria, and reporting instructions.
2466
+ * When using rawPrompt, YOU must include reporting instructions (use get_reporting_instructions to get them).
2467
+ */
2468
+ rawPrompt?: boolean;
2041
2469
  }): Promise<{
2042
2470
  taskId: string;
2043
2471
  teammateId: string;
@@ -2046,6 +2474,29 @@ export interface DelegationAPI {
2046
2474
  status: 'running';
2047
2475
  _hint: string;
2048
2476
  }>;
2477
+ /**
2478
+ * Get the standard reporting instructions template for delegated tasks.
2479
+ *
2480
+ * Use this when using rawPrompt: true in delegate_task and you want to include
2481
+ * the standard reporting instructions in your custom prompt.
2482
+ *
2483
+ * The instructions tell the delegate how to report completion (report_done)
2484
+ * or blockers (report_blocker).
2485
+ */
2486
+ get_reporting_instructions(input?: {
2487
+ /** Optional task ID to include in the instructions */
2488
+ taskId?: string;
2489
+ }): Promise<{
2490
+ /** The reporting instructions template markdown */
2491
+ instructions: string;
2492
+ /** Names of the delegate tools */
2493
+ toolNames: {
2494
+ reportDone: string;
2495
+ reportBlocker: string;
2496
+ checkWitness: string;
2497
+ };
2498
+ _hint: string;
2499
+ }>;
2049
2500
  /**
2050
2501
  * Check the current status of a delegated task.
2051
2502
  */