capdag 0.190.488 → 1.194.499
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/capdag.js +47 -39
- package/capdag.test.js +37 -5
- package/package.json +1 -1
package/capdag.js
CHANGED
|
@@ -1222,69 +1222,69 @@ const MEDIA_OBJECT_LIST = 'media:list;record';
|
|
|
1222
1222
|
|
|
1223
1223
|
// Semantic media types for specialized content
|
|
1224
1224
|
// Media URN for PNG image data
|
|
1225
|
-
const MEDIA_PNG = 'media:image
|
|
1225
|
+
const MEDIA_PNG = 'media:ext=png;image';
|
|
1226
1226
|
// Media URN for JPEG image data
|
|
1227
|
-
const MEDIA_JPEG = 'media:jpeg;image';
|
|
1227
|
+
const MEDIA_JPEG = 'media:ext=jpeg;image';
|
|
1228
1228
|
// Media URN for GIF image data
|
|
1229
|
-
const MEDIA_GIF = 'media:gif;image';
|
|
1229
|
+
const MEDIA_GIF = 'media:ext=gif;image';
|
|
1230
1230
|
// Media URN for BMP image data
|
|
1231
|
-
const MEDIA_BMP = 'media:bmp;image';
|
|
1231
|
+
const MEDIA_BMP = 'media:ext=bmp;image';
|
|
1232
1232
|
// Media URN for TIFF image data
|
|
1233
|
-
const MEDIA_TIFF = 'media:tiff;image';
|
|
1233
|
+
const MEDIA_TIFF = 'media:ext=tiff;image';
|
|
1234
1234
|
// Media URN for WebP image data
|
|
1235
|
-
const MEDIA_WEBP = 'media:webp;image';
|
|
1235
|
+
const MEDIA_WEBP = 'media:ext=webp;image';
|
|
1236
1236
|
// Media URN for audio data (wav, mp3, flac, etc.)
|
|
1237
|
-
const MEDIA_AUDIO = 'media:wav
|
|
1237
|
+
const MEDIA_AUDIO = 'media:audio;ext=wav';
|
|
1238
1238
|
// Media URN for MP3 audio data
|
|
1239
|
-
const MEDIA_MP3 = 'media:mp3
|
|
1239
|
+
const MEDIA_MP3 = 'media:audio;ext=mp3';
|
|
1240
1240
|
// Media URN for WAV audio data
|
|
1241
|
-
const MEDIA_WAV = 'media:wav
|
|
1241
|
+
const MEDIA_WAV = 'media:audio;ext=wav';
|
|
1242
1242
|
// Media URN for FLAC audio data
|
|
1243
|
-
const MEDIA_FLAC = 'media:flac
|
|
1243
|
+
const MEDIA_FLAC = 'media:audio;ext=flac';
|
|
1244
1244
|
// Media URN for OGG audio data
|
|
1245
|
-
const MEDIA_OGG = 'media:ogg
|
|
1245
|
+
const MEDIA_OGG = 'media:audio;ext=ogg';
|
|
1246
1246
|
// Media URN for AAC audio data
|
|
1247
|
-
const MEDIA_AAC = 'media:aac
|
|
1247
|
+
const MEDIA_AAC = 'media:audio;ext=aac';
|
|
1248
1248
|
// Media URN for M4A audio data
|
|
1249
|
-
const MEDIA_M4A = 'media:m4a
|
|
1249
|
+
const MEDIA_M4A = 'media:audio;ext=m4a';
|
|
1250
1250
|
// Media URN for AIFF audio data
|
|
1251
|
-
const MEDIA_AIFF = 'media:aiff
|
|
1251
|
+
const MEDIA_AIFF = 'media:audio;ext=aiff';
|
|
1252
1252
|
// Media URN for Opus audio data
|
|
1253
|
-
const MEDIA_OPUS = 'media:opus
|
|
1253
|
+
const MEDIA_OPUS = 'media:audio;ext=opus';
|
|
1254
1254
|
// Media URN for video data (mp4, webm, mov, etc.)
|
|
1255
1255
|
const MEDIA_VIDEO = 'media:video';
|
|
1256
1256
|
// Media URN for MP4 video data
|
|
1257
|
-
const MEDIA_MP4 = 'media:mp4;video';
|
|
1257
|
+
const MEDIA_MP4 = 'media:ext=mp4;video';
|
|
1258
1258
|
// Media URN for MOV video data
|
|
1259
|
-
const MEDIA_MOV = 'media:mov;video';
|
|
1259
|
+
const MEDIA_MOV = 'media:ext=mov;video';
|
|
1260
1260
|
// Media URN for WebM video data
|
|
1261
|
-
const MEDIA_WEBM = 'media:webm;video';
|
|
1261
|
+
const MEDIA_WEBM = 'media:ext=webm;video';
|
|
1262
1262
|
// Media URN for MKV video data
|
|
1263
|
-
const MEDIA_MKV = 'media:mkv;video';
|
|
1263
|
+
const MEDIA_MKV = 'media:ext=mkv;video';
|
|
1264
1264
|
|
|
1265
1265
|
// Semantic AI input types - distinguished by their purpose/context
|
|
1266
1266
|
// Media URN for audio input containing speech for transcription (Whisper)
|
|
1267
|
-
const MEDIA_AUDIO_SPEECH = 'media:audio;wav;speech';
|
|
1267
|
+
const MEDIA_AUDIO_SPEECH = 'media:audio;ext=wav;speech';
|
|
1268
1268
|
|
|
1269
1269
|
// Document types (PRIMARY naming - type IS the format)
|
|
1270
1270
|
// Media URN for PDF documents
|
|
1271
|
-
const MEDIA_PDF = 'media:pdf';
|
|
1271
|
+
const MEDIA_PDF = 'media:ext=pdf';
|
|
1272
1272
|
// Media URN for EPUB documents
|
|
1273
|
-
const MEDIA_EPUB = 'media:epub';
|
|
1273
|
+
const MEDIA_EPUB = 'media:ext=epub';
|
|
1274
1274
|
|
|
1275
1275
|
// Text format types (PRIMARY naming - type IS the format)
|
|
1276
1276
|
// Media URN for Markdown text
|
|
1277
|
-
const MEDIA_MD = 'media:md;textable';
|
|
1277
|
+
const MEDIA_MD = 'media:ext=md;textable';
|
|
1278
1278
|
// Media URN for plain text
|
|
1279
|
-
const MEDIA_TXT = 'media:txt;textable';
|
|
1279
|
+
const MEDIA_TXT = 'media:ext=txt;textable';
|
|
1280
1280
|
// Media URN for reStructuredText
|
|
1281
|
-
const MEDIA_RST = 'media:rst;textable';
|
|
1281
|
+
const MEDIA_RST = 'media:ext=rst;textable';
|
|
1282
1282
|
// Media URN for log files
|
|
1283
|
-
const MEDIA_LOG = 'media:log;textable';
|
|
1283
|
+
const MEDIA_LOG = 'media:ext=log;textable';
|
|
1284
1284
|
// Media URN for HTML documents
|
|
1285
|
-
const MEDIA_HTML = 'media:html;textable';
|
|
1285
|
+
const MEDIA_HTML = 'media:ext=html;textable';
|
|
1286
1286
|
// Media URN for XML documents
|
|
1287
|
-
const MEDIA_XML = 'media:xml;textable';
|
|
1287
|
+
const MEDIA_XML = 'media:ext=xml;textable';
|
|
1288
1288
|
// Media URN for JSON data - has record marker (structured key-value)
|
|
1289
1289
|
const MEDIA_JSON = 'media:json;record;textable';
|
|
1290
1290
|
// Media URN for JSON with schema constraint (input for structured queries)
|
|
@@ -1301,8 +1301,8 @@ const MEDIA_YAML_VALUE = 'media:textable;yaml';
|
|
|
1301
1301
|
const MEDIA_YAML_RECORD = 'media:record;textable;yaml';
|
|
1302
1302
|
const MEDIA_YAML_LIST = 'media:list;textable;yaml';
|
|
1303
1303
|
const MEDIA_YAML_LIST_RECORD = 'media:list;record;textable;yaml';
|
|
1304
|
-
const MEDIA_CSV = 'media:csv;list;record;textable';
|
|
1305
|
-
const MEDIA_CSV_LIST = 'media:csv;list;record;textable';
|
|
1304
|
+
const MEDIA_CSV = 'media:ext=csv;list;record;textable';
|
|
1305
|
+
const MEDIA_CSV_LIST = 'media:ext=csv;list;record;textable';
|
|
1306
1306
|
|
|
1307
1307
|
// File path type — for arguments that represent filesystem paths.
|
|
1308
1308
|
// There is a single media URN; cardinality (single file vs many files)
|
|
@@ -1338,18 +1338,18 @@ const MEDIA_EMBEDDING_VECTOR = 'media:embedding-vector;record;textable';
|
|
|
1338
1338
|
// Carries `image-description` (the vision-specific marker), `plain-text` (the
|
|
1339
1339
|
// finalised-text marker that opts into cap:save-as-txt's persistence path),
|
|
1340
1340
|
// and `file-type=txt` (binds the URN to the `.txt` extension).
|
|
1341
|
-
const MEDIA_IMAGE_DESCRIPTION = 'media:image-description;plain-text;textable
|
|
1341
|
+
const MEDIA_IMAGE_DESCRIPTION = 'media:ext=txt;image-description;plain-text;textable';
|
|
1342
1342
|
// Media URN for finalised plain text — the canonical input/output of cap:save-as-txt.
|
|
1343
1343
|
// Producers of user-facing prose (LLM text-generation, OCR's extracted text,
|
|
1344
1344
|
// summarisation) declare this URN as their `out` so the planner restricts the .txt
|
|
1345
1345
|
// persistence path to those caps. See fabric/media/plain-text.toml.
|
|
1346
|
-
const MEDIA_PLAIN_TEXT = 'media:plain-text;textable
|
|
1346
|
+
const MEDIA_PLAIN_TEXT = 'media:ext=txt;plain-text;textable';
|
|
1347
1347
|
// Media URN for transcription output - has record marker
|
|
1348
1348
|
const MEDIA_TRANSCRIPTION_OUTPUT = 'media:record;textable;transcription';
|
|
1349
1349
|
// Media URN for decision output - JSON record with textable
|
|
1350
1350
|
const MEDIA_DECISION = 'media:decision;json;record;textable';
|
|
1351
1351
|
// Media URN for textable page output
|
|
1352
|
-
const MEDIA_TEXTABLE_PAGE = 'media:page;plain-text;textable
|
|
1352
|
+
const MEDIA_TEXTABLE_PAGE = 'media:ext=txt;page;plain-text;textable';
|
|
1353
1353
|
// Media URN for Hugging Face API token (secret, textable)
|
|
1354
1354
|
const MEDIA_HF_TOKEN = 'media:hf-token;secret;textable';
|
|
1355
1355
|
// Media URN for a list of model architectures — JSON record
|
|
@@ -1369,6 +1369,7 @@ const MEDIA_ADAPTER_SELECTION = 'media:adapter-selection;json;record';
|
|
|
1369
1369
|
// and cap:lookup-media-def;fabric, both implemented by fetchcartridge).
|
|
1370
1370
|
const MEDIA_CAP_URN = 'media:cap-urn;textable';
|
|
1371
1371
|
const MEDIA_MEDIA_URN = 'media:media-urn;textable';
|
|
1372
|
+
const MEDIA_FABRIC_DEFVER = 'media:defver;textable';
|
|
1372
1373
|
const MEDIA_CAP_DEFINITION = 'media:cap-definition;json;record;textable';
|
|
1373
1374
|
const MEDIA_MEDIA_DEFINITION = 'media:media-definition;json;record;textable';
|
|
1374
1375
|
|
|
@@ -1759,19 +1760,19 @@ const DEFAULT_SCHEMA_BASE = 'https://capdag.com/schema';
|
|
|
1759
1760
|
* Get the schema base URL from environment variables or default
|
|
1760
1761
|
*
|
|
1761
1762
|
* Checks in order:
|
|
1762
|
-
* 1.
|
|
1763
|
-
* 2.
|
|
1763
|
+
* 1. CDG_SCHEMA_BASE_URL environment variable
|
|
1764
|
+
* 2. CDG_FABRIC_REGISTRY_URL environment variable + "/schema"
|
|
1764
1765
|
* 3. Default: "https://capdag.com/schema"
|
|
1765
1766
|
*
|
|
1766
1767
|
* @returns {string} The schema base URL
|
|
1767
1768
|
*/
|
|
1768
1769
|
function getSchemaBaseURL() {
|
|
1769
1770
|
if (typeof process !== 'undefined' && process.env) {
|
|
1770
|
-
if (process.env.
|
|
1771
|
-
return process.env.
|
|
1771
|
+
if (process.env.CDG_SCHEMA_BASE_URL) {
|
|
1772
|
+
return process.env.CDG_SCHEMA_BASE_URL;
|
|
1772
1773
|
}
|
|
1773
|
-
if (process.env.
|
|
1774
|
-
return process.env.
|
|
1774
|
+
if (process.env.CDG_FABRIC_REGISTRY_URL) {
|
|
1775
|
+
return process.env.CDG_FABRIC_REGISTRY_URL + '/schema';
|
|
1775
1776
|
}
|
|
1776
1777
|
}
|
|
1777
1778
|
return DEFAULT_SCHEMA_BASE;
|
|
@@ -2511,6 +2512,7 @@ class Cap {
|
|
|
2511
2512
|
}
|
|
2512
2513
|
|
|
2513
2514
|
this.urn = urn;
|
|
2515
|
+
this.version = 0;
|
|
2514
2516
|
this.title = title;
|
|
2515
2517
|
this.command = command;
|
|
2516
2518
|
this.cap_description = capDescription;
|
|
@@ -2747,6 +2749,10 @@ class Cap {
|
|
|
2747
2749
|
output: this.output
|
|
2748
2750
|
};
|
|
2749
2751
|
|
|
2752
|
+
if (this.version !== 0) {
|
|
2753
|
+
result.version = this.version;
|
|
2754
|
+
}
|
|
2755
|
+
|
|
2750
2756
|
// Long-form markdown documentation. Only emitted when set, to match
|
|
2751
2757
|
// the Rust serializer which skips this field when None.
|
|
2752
2758
|
if (typeof this.documentation === 'string' && this.documentation.length > 0) {
|
|
@@ -2786,6 +2792,7 @@ class Cap {
|
|
|
2786
2792
|
? json.documentation
|
|
2787
2793
|
: null;
|
|
2788
2794
|
const cap = new Cap(urn, json.title, json.command, json.cap_description, json.metadata, json.metadata_json, documentation);
|
|
2795
|
+
cap.version = (typeof json.version === 'number' && json.version !== 0) ? json.version : 0;
|
|
2789
2796
|
// Parse args (new format)
|
|
2790
2797
|
if (json.args && Array.isArray(json.args)) {
|
|
2791
2798
|
cap.args = json.args.map(a => CapArg.fromJSON(a));
|
|
@@ -6495,6 +6502,7 @@ module.exports = {
|
|
|
6495
6502
|
// Fabric registry lookup wire types
|
|
6496
6503
|
MEDIA_CAP_URN,
|
|
6497
6504
|
MEDIA_MEDIA_URN,
|
|
6505
|
+
MEDIA_FABRIC_DEFVER,
|
|
6498
6506
|
MEDIA_CAP_DEFINITION,
|
|
6499
6507
|
MEDIA_MEDIA_DEFINITION,
|
|
6500
6508
|
// Standard cap URN constants
|
package/capdag.test.js
CHANGED
|
@@ -980,12 +980,12 @@ function test072_constantsParse() {
|
|
|
980
980
|
// TEST074: Test media URN conforms_to using tagged URN semantics with specific and generic requirements
|
|
981
981
|
function test074_mediaUrnMatching() {
|
|
982
982
|
const pdfUrn = MediaUrn.fromString(MEDIA_PDF);
|
|
983
|
-
const pdfPattern = MediaUrn.fromString('media:pdf');
|
|
984
|
-
assert(pdfUrn.conformsTo(pdfPattern), 'MEDIA_PDF should conform to media:pdf');
|
|
983
|
+
const pdfPattern = MediaUrn.fromString('media:ext=pdf');
|
|
984
|
+
assert(pdfUrn.conformsTo(pdfPattern), 'MEDIA_PDF should conform to media:ext=pdf');
|
|
985
985
|
|
|
986
986
|
const mdUrn = MediaUrn.fromString(MEDIA_MD);
|
|
987
|
-
const mdPattern = MediaUrn.fromString('media:md');
|
|
988
|
-
assert(mdUrn.conformsTo(mdPattern), 'MEDIA_MD should conform to media:md');
|
|
987
|
+
const mdPattern = MediaUrn.fromString('media:ext=md');
|
|
988
|
+
assert(mdUrn.conformsTo(mdPattern), 'MEDIA_MD should conform to media:ext=md');
|
|
989
989
|
|
|
990
990
|
// Same URN conforms to itself
|
|
991
991
|
assert(pdfUrn.conformsTo(pdfUrn), 'Same URN should conform to itself');
|
|
@@ -2587,7 +2587,7 @@ function test1304_withInOutSpec() {
|
|
|
2587
2587
|
// Chain both
|
|
2588
2588
|
const changedBoth = cap.withInSpec('media:pdf').withOutSpec(MEDIA_TXT);
|
|
2589
2589
|
assertEqual(changedBoth.getInSpec(), 'media:pdf', 'Chain should set inSpec');
|
|
2590
|
-
assertEqual(changedBoth.getOutSpec(), 'media:textable
|
|
2590
|
+
assertEqual(changedBoth.getOutSpec(), 'media:ext=txt;textable', 'Chain should set outSpec');
|
|
2591
2591
|
|
|
2592
2592
|
const identity = CapUrn.fromString('cap:effect=none');
|
|
2593
2593
|
assertThrows(
|
|
@@ -5917,6 +5917,34 @@ function test1846_axisWeightingDecodedLayout() {
|
|
|
5917
5917
|
assertEqual(cap.specificity(), 10000*8 + 100*4 + 2);
|
|
5918
5918
|
}
|
|
5919
5919
|
|
|
5920
|
+
// ============================================================================
|
|
5921
|
+
// Cap.version round-trip tests: TEST1847-TEST1848
|
|
5922
|
+
// ============================================================================
|
|
5923
|
+
|
|
5924
|
+
// TEST1847: Cap with version=0 round-trips with no `version` key on wire
|
|
5925
|
+
function test1847_capVersionZeroOmittedOnWire() {
|
|
5926
|
+
const urn = CapUrn.fromString('cap:in="media:void";test-op;out="media:record;textable"');
|
|
5927
|
+
const cap = new Cap(urn, 'Test Cap', 'test-op');
|
|
5928
|
+
// version defaults to 0
|
|
5929
|
+
assertEqual(cap.version, 0, 'Default version should be 0');
|
|
5930
|
+
const json = cap.toJSON();
|
|
5931
|
+
assert(!('version' in json), 'version=0 must not appear on wire');
|
|
5932
|
+
const restored = Cap.fromJSON(json);
|
|
5933
|
+
assertEqual(restored.version, 0, 'Restored version must be 0');
|
|
5934
|
+
}
|
|
5935
|
+
|
|
5936
|
+
// TEST1848: Cap with version=N round-trips with `version: N` on wire
|
|
5937
|
+
function test1848_capVersionNonZeroOnWire() {
|
|
5938
|
+
const urn = CapUrn.fromString('cap:in="media:void";versioned-op;out="media:record;textable"');
|
|
5939
|
+
const cap = new Cap(urn, 'Versioned Cap', 'versioned-op');
|
|
5940
|
+
cap.version = 42;
|
|
5941
|
+
const json = cap.toJSON();
|
|
5942
|
+
assert('version' in json, 'version!=0 must appear on wire');
|
|
5943
|
+
assertEqual(json.version, 42, 'Wire version must equal 42');
|
|
5944
|
+
const restored = Cap.fromJSON(json);
|
|
5945
|
+
assertEqual(restored.version, 42, 'Restored version must equal 42');
|
|
5946
|
+
}
|
|
5947
|
+
|
|
5920
5948
|
// ============================================================================
|
|
5921
5949
|
// Test runner
|
|
5922
5950
|
// ============================================================================
|
|
@@ -6353,6 +6381,10 @@ async function runTests() {
|
|
|
6353
6381
|
runTest('TEST1845: axis_weighting_in_dominates_y', test1845_axisWeightingInDominatesY);
|
|
6354
6382
|
runTest('TEST1846: axis_weighting_decoded_layout', test1846_axisWeightingDecodedLayout);
|
|
6355
6383
|
|
|
6384
|
+
// Cap.version round-trip tests
|
|
6385
|
+
runTest('TEST1847: cap_version_zero_omitted_on_wire', test1847_capVersionZeroOmittedOnWire);
|
|
6386
|
+
runTest('TEST1848: cap_version_nonzero_on_wire', test1848_capVersionNonZeroOnWire);
|
|
6387
|
+
|
|
6356
6388
|
// Summary
|
|
6357
6389
|
console.log(`\n${passCount + failCount} tests: ${passCount} passed, ${failCount} failed`);
|
|
6358
6390
|
if (failCount > 0) {
|
package/package.json
CHANGED