@ductape/mcp 0.2.15 → 0.2.16

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.
Files changed (2) hide show
  1. package/dist/index.js +80 -7
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -805,7 +805,7 @@ ALL params are passed as a JSON array in positional order matching the SDK signa
805
805
  graph.dropConstraint [name: string]
806
806
  graph.listLabels []
807
807
  graph.listRelationshipTypes []
808
- graph.createAction [{ graphTag, tag, name, query, params? }, productTag?]
808
+ graph.createAction [{ graphTag, name, description?, operation, query: { operation, options }, parameters: [{ name, path, defaultValue, type, description?, required? }] }, productTag?]
809
809
  graph.listActions [graphTag?, productTag?]
810
810
  graph.getAction [actionTag, graphTag?, productTag?]
811
811
  graph.updateAction [actionTag, updates, graphTag?, productTag?]
@@ -4716,9 +4716,51 @@ EXACT CODE-FIRST GRAPH CONTEXT:
4716
4716
  ctx.graph.deleteRelationship({ graph, id })
4717
4717
  ctx.graph.query<T>({ graph, action, params? })
4718
4718
  ctx.graph.execute<T>({ graph, action, input })
4719
- Every call must be inside ctx.step(). createNode/createRelationship are not projection upserts.
4720
- For replay-safe Neo4j projections, register a saved graph action whose Cypher uses MERGE and call
4721
- that action through ctx.graph.execute. Do not describe CREATE as idempotent.
4719
+ Every call must be inside ctx.step(). Prefer the direct ctx.graph primitive that expresses the
4720
+ operation. Saved actions are not generally preferred over createNode/updateNode/deleteNode,
4721
+ relationship operations, or query; use a saved action only for a reusable parameterized operation
4722
+ that the typed primitives cannot express. createNode/createRelationship are not projection upserts.
4723
+
4724
+ SAVED GRAPH ACTION ASSET AND CLI CONTRACT:
4725
+ Canonical project path:
4726
+ ductape/graphs/<graph-tag>/actions/<action-tag>.action.json
4727
+ action-tag is generated by lowercasing name, replacing non-alphanumerics with hyphens, and trimming
4728
+ hyphens. Exactly one action object belongs in each file. Allowed top-level fields are graphTag,
4729
+ name, description, operation, query, and parameters. Required fields are graphTag, name, operation,
4730
+ query, and parameters. There is no persisted version field.
4731
+
4732
+ Example ductape/graphs/discovery-graph/actions/upsert-product-v1.action.json:
4733
+ {
4734
+ "graphTag": "discovery-graph",
4735
+ "name": "Upsert Product V1",
4736
+ "description": "Idempotently project one product by stable domain ID",
4737
+ "operation": "executeRaw",
4738
+ "query": {
4739
+ "operation": "executeRaw",
4740
+ "options": {
4741
+ "query": "MERGE (p:Product {id: $productId}) SET p.name = $name, p.sourceVersion = $sourceVersion RETURN p",
4742
+ "params": { "productId": null, "name": null, "sourceVersion": null }
4743
+ }
4744
+ },
4745
+ "parameters": [
4746
+ { "name": "productId", "path": "options.params.productId", "defaultValue": null, "type": "string", "required": true },
4747
+ { "name": "name", "path": "options.params.name", "defaultValue": null, "type": "string", "required": true },
4748
+ { "name": "sourceVersion", "path": "options.params.sourceVersion", "defaultValue": 0, "type": "number", "required": true }
4749
+ ]
4750
+ }
4751
+ Validate without mutation:
4752
+ ductape graph validateAction -f ductape/graphs/discovery-graph/actions/upsert-product-v1.action.json --json
4753
+ Create and persist against the linked product:
4754
+ ductape graph createAction -f ductape/graphs/discovery-graph/actions/upsert-product-v1.action.json --json
4755
+ Read back with graph.getAction/listActions before relying on it. In-place updates use:
4756
+ ductape graph updateAction -f <patch.json> --json
4757
+ where patch.json is { "actionTag":"upsert-product-v1", "graphTag":"discovery-graph", "updates":{...} }.
4758
+ Updating name does not change the stored tag. For breaking query/input/result changes, create a new
4759
+ name/tag such as V2 and migrate callers; use updateAction for compatible corrections only.
4760
+ ctx.graph.execute returns IExecuteGraphActionResult<T>: { success, executionTime, data: T[], count,
4761
+ error? }. It resolves parameter values by each parameter.path. The SDK currently returns
4762
+ success:false for action execution errors, so Feature code must inspect success and throw to fail
4763
+ the step; do not treat a resolved unsuccessful result as success.
4722
4764
 
4723
4765
  EXACT CODE-FIRST VECTOR CONTEXT:
4724
4766
  ctx.vector.upsert<T>({
@@ -4738,9 +4780,40 @@ EXACT CODE-FIRST VECTOR CONTEXT:
4738
4780
  them into the Feature definition. Note the deliberate naming: ctx.vector.query uses values for
4739
4781
  the embedding, while the lower-level ductape.vector.query runtime facade uses vector.
4740
4782
  Vertex AI Vector Search stores and searches supplied vectors. It does NOT generate embeddings.
4741
- Generate embeddings through a separately registered/called model or App/function contract and
4742
- verify that the returned number[] dimension exactly matches the vector component. Do not claim
4743
- that a Vertex Vector Search index embeds text.
4783
+ Do not claim that a Vertex Vector Search index embeds text.
4784
+
4785
+ EMBEDDING EXECUTION CURRENT CODE-FIRST CONTRACT:
4786
+ Registered product models are configuration CRUD only in the current SDK. There is no ctx.model,
4787
+ ctx.models, ctx.ai, or registered-model execute method, so never generate those calls. To execute
4788
+ discovery-embeddings portably inside a Feature, define it as a portable function contract (preferred
4789
+ for application-owned embedding code) or call an already registered App action via ctx.api.run.
4790
+
4791
+ import { defineFunctions } from '@ductape/sdk';
4792
+ type EmbedInput = { texts: string[] };
4793
+ type EmbedOutput = { embeddings: number[][]; dimensions: number; model: string };
4794
+ export const DiscoveryEmbeddings = defineFunctions({
4795
+ namespace: 'discovery-embeddings', version: '1', operations: { embed: {
4796
+ input: { type:'object', required:['texts'], additionalProperties:false,
4797
+ properties:{ texts:{ type:'array', items:{ type:'string', minLength:1 } } } },
4798
+ output: { type:'object', required:['embeddings','dimensions','model'], additionalProperties:false,
4799
+ properties:{ embeddings:{ type:'array', items:{ type:'array', items:{ type:'number' } } },
4800
+ dimensions:{ type:'integer', minimum:1 }, model:{ type:'string', minLength:1 } } },
4801
+ timeout_ms: 15000, idempotent: true, transports:[{ type:'local' }]
4802
+ } } });
4803
+
4804
+ In the Feature handler:
4805
+ const embeddings = ctx.functions.use(DiscoveryEmbeddings);
4806
+ const generated = await ctx.step('embed-products', () =>
4807
+ embeddings.embed({ texts: ctx.input.texts }));
4808
+ if (generated.embeddings.length !== ctx.input.texts.length ||
4809
+ generated.embeddings.some(v => v.length !== EXPECTED_VECTOR_DIMENSIONS)) {
4810
+ throw new Error('EMBEDDING_DIMENSION_MISMATCH');
4811
+ }
4812
+ Register a real local handler at application bootstrap or configure a signed HTTPS/events transport.
4813
+ Input and output JSON schemas are validated at runtime. Missing implementation fails with
4814
+ FUNCTION_UNAVAILABLE; schema mismatch fails with FUNCTION_SCHEMA_VALIDATION_FAILED; timeout fails
4815
+ with FUNCTION_TIMEOUT. Never substitute sample/random/recording-time embeddings. The Feature's
4816
+ session is inherited in the portable function context, outside its business input.
4744
4817
 
4745
4818
  NESTJS CONSUMER ROUTING AND FEATURE INPUT:
4746
4819
  @Events.Consumer receives the published message object. Ductape may add
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ductape/mcp",
3
- "version": "0.2.15",
3
+ "version": "0.2.16",
4
4
  "description": "MCP server that exposes Ductape SDK operations via the backend proxy",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",