trucontext 0.9.1 → 0.10.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/bin/cli.js CHANGED
@@ -13,7 +13,7 @@ import { ingestCommand } from '../src/commands/ingest.js';
13
13
  import { queryCommand } from '../src/commands/query.js';
14
14
  import { recallCommand } from '../src/commands/recall.js';
15
15
  import { schemaShowCommand, schemaGenerateCommand, schemaSetAuthorshipCommand } from '../src/commands/schema.js';
16
- import { entitiesListCommand, entitiesGetCommand, entitiesCreateCommand, entitiesUpdateCommand, entitiesDeleteCommand, entitiesEdgesCommand } from '../src/commands/entities.js';
16
+ import { entitiesListCommand, entitiesGetCommand, entitiesCreateCommand, entitiesUpdateCommand, entitiesDeleteCommand, entitiesEdgesCommand, edgesCreateCommand, edgesDeleteCommand } from '../src/commands/entities.js';
17
17
  import { recipesListCommand, recipesGetCommand, recipesCreateCommand, recipesUpdateCommand, recipesDeleteCommand } from '../src/commands/recipes.js';
18
18
  import { relationshipTypesListCommand, relationshipTypesCreateCommand, relationshipTypesDeleteCommand } from '../src/commands/relationship-types.js';
19
19
  import { docsListCommand, docsShowCommand } from '../src/commands/docs.js';
@@ -63,6 +63,7 @@ program.command('use <app>')
63
63
  // Ingest
64
64
  program.command('ingest <source>')
65
65
  .description('Ingest a file or text string')
66
+ .requiredOption('-a, --agent <agent-id>', 'Agent ID (required — provision first)')
66
67
  .option('-c, --context <entry>', 'Link to context node (entity-id:RELATIONSHIP, repeatable)', (val, prev) => [...prev, val], [])
67
68
  .option('--confidence <n>', 'Confidence level (0.0-1.0)')
68
69
  .option('--temporal', 'Content can decay over time (default)')
@@ -129,6 +130,19 @@ entities.command('delete <entityId>')
129
130
  entities.command('edges <entityId>')
130
131
  .description('List edges for an entity')
131
132
  .action(entitiesEdgesCommand);
133
+ entities.command('edges-create')
134
+ .description('Create an edge between two entities')
135
+ .requiredOption('--type <type>', 'Edge type (UPPER_SNAKE_CASE)')
136
+ .requiredOption('--from <entityId>', 'Source entity ID')
137
+ .requiredOption('--to <entityId>', 'Target entity ID')
138
+ .option('--properties <json>', 'Edge properties as JSON')
139
+ .action(edgesCreateCommand);
140
+ entities.command('edges-delete')
141
+ .description('Delete an edge between two entities')
142
+ .requiredOption('--type <type>', 'Edge type')
143
+ .requiredOption('--from <entityId>', 'Source entity ID')
144
+ .requiredOption('--to <entityId>', 'Target entity ID')
145
+ .action(edgesDeleteCommand);
132
146
 
133
147
  // Recipes
134
148
  const recipes = program.command('recipes').description('Manage recipes').action(function() { this.help(); });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "trucontext",
3
- "version": "0.9.1",
3
+ "version": "0.10.0",
4
4
  "description": "TruContext CLI — contextual memory for AI applications",
5
5
  "type": "module",
6
6
  "bin": {
package/src/client.js CHANGED
@@ -13,7 +13,7 @@ async function request(baseUrl, method, path, body, retry = true) {
13
13
  };
14
14
 
15
15
  const ac = new AbortController();
16
- const timeout = setTimeout(() => ac.abort(), 15000);
16
+ const timeout = setTimeout(() => ac.abort(), 60000);
17
17
 
18
18
  try {
19
19
  const res = await fetch(`${baseUrl}${path}`, {
@@ -80,7 +80,7 @@ export function controlPlane(method, path, body) {
80
80
 
81
81
  export async function publicApi(method, path) {
82
82
  const ac = new AbortController();
83
- const timeout = setTimeout(() => ac.abort(), 15000);
83
+ const timeout = setTimeout(() => ac.abort(), 60000);
84
84
  try {
85
85
  const res = await fetch(`${CONTROL_PLANE_URL}${path}`, {
86
86
  method,
@@ -197,6 +197,64 @@ export async function entitiesDeleteCommand(entityId) {
197
197
  }
198
198
  }
199
199
 
200
+ export async function edgesCreateCommand(options) {
201
+ try {
202
+ const body = {
203
+ type: options.type,
204
+ from: {},
205
+ to: {},
206
+ };
207
+
208
+ // From reference
209
+ if (options.from) body.from.entityId = options.from;
210
+ if (options.fromType && options.fromKey) {
211
+ body.from = { nodeType: options.fromType, key: JSON.parse(options.fromKey) };
212
+ }
213
+
214
+ // To reference
215
+ if (options.to) body.to.entityId = options.to;
216
+ if (options.toType && options.toKey) {
217
+ body.to = { nodeType: options.toType, key: JSON.parse(options.toKey) };
218
+ }
219
+
220
+ // Properties
221
+ if (options.properties) {
222
+ try {
223
+ body.properties = JSON.parse(options.properties);
224
+ } catch {
225
+ console.error(chalk.red('Invalid properties JSON'));
226
+ process.exit(1);
227
+ }
228
+ }
229
+
230
+ const res = await dataPlane('POST', '/v1/entities/edges', body);
231
+ const edge = res.data;
232
+ console.log(chalk.green(`Edge created: ${edge.source || options.from} -[${chalk.cyan(options.type)}]-> ${edge.target || options.to}`));
233
+ } catch (err) {
234
+ console.error(chalk.red(`Failed: ${err.message}`));
235
+ process.exit(1);
236
+ }
237
+ }
238
+
239
+ export async function edgesDeleteCommand(options) {
240
+ try {
241
+ const body = {
242
+ type: options.type,
243
+ from: {},
244
+ to: {},
245
+ };
246
+
247
+ if (options.from) body.from.entityId = options.from;
248
+ if (options.to) body.to.entityId = options.to;
249
+
250
+ await dataPlane('DELETE', '/v1/entities/edges', body);
251
+ console.log(chalk.green(`Edge deleted: ${options.from} -[${options.type}]-> ${options.to}`));
252
+ } catch (err) {
253
+ console.error(chalk.red(`Failed: ${err.message}`));
254
+ process.exit(1);
255
+ }
256
+ }
257
+
200
258
  export async function entitiesEdgesCommand(entityId) {
201
259
  try {
202
260
  const appId = getActiveApp();
@@ -34,6 +34,9 @@ export async function ingestCommand(source, options) {
34
34
  if (options.confidence !== undefined) body.confidence = parseFloat(options.confidence);
35
35
  if (options.temporal !== undefined) body.temporal = options.temporal;
36
36
 
37
+ // Agent ID (required — enforced by commander's requiredOption)
38
+ body.agent_id = options.agent;
39
+
37
40
  // Build contexts array from --context flags: "entity-id:RELATIONSHIP" (required)
38
41
  if (!options.context || options.context.length === 0) {
39
42
  console.error(chalk.red('At least one context is required.'));