@c4a/core 0.4.12-alpha.2 → 0.4.12-beta.14
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/index.js +473 -45
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -7000,6 +7000,7 @@ var RelationType;
|
|
|
7000
7000
|
RelationType2["Triggers"] = "TRIGGERS";
|
|
7001
7001
|
RelationType2["References"] = "REFERENCES";
|
|
7002
7002
|
RelationType2["Corresponds"] = "CORRESPONDS";
|
|
7003
|
+
RelationType2["Mentions"] = "MENTIONS";
|
|
7003
7004
|
})(RelationType ||= {});
|
|
7004
7005
|
var AtomField;
|
|
7005
7006
|
((AtomField2) => {
|
|
@@ -7017,6 +7018,7 @@ var AtomField;
|
|
|
7017
7018
|
AtomField2["Constraints"] = "constraints";
|
|
7018
7019
|
AtomField2["Comparisons"] = "comparisons";
|
|
7019
7020
|
AtomField2["Boundaries"] = "boundaries";
|
|
7021
|
+
AtomField2["Claims"] = "claims";
|
|
7020
7022
|
})(AtomField ||= {});
|
|
7021
7023
|
var Kind;
|
|
7022
7024
|
((Kind2) => {
|
|
@@ -7029,11 +7031,123 @@ var Perspective;
|
|
|
7029
7031
|
Perspective2["Business"] = "business";
|
|
7030
7032
|
Perspective2["Technical"] = "technical";
|
|
7031
7033
|
})(Perspective ||= {});
|
|
7034
|
+
// src/types/edgeSyncRules.ts
|
|
7035
|
+
var EDGE_SYNC_RULES = [
|
|
7036
|
+
{
|
|
7037
|
+
field: "container_id",
|
|
7038
|
+
sourceEntityType: "component" /* Component */,
|
|
7039
|
+
edgeType: "CONTAINS" /* Contains */,
|
|
7040
|
+
direction: "reverse",
|
|
7041
|
+
writeGraph: true
|
|
7042
|
+
},
|
|
7043
|
+
{
|
|
7044
|
+
field: "system_id",
|
|
7045
|
+
sourceEntityType: "container" /* Container */,
|
|
7046
|
+
edgeType: "CONTAINS" /* Contains */,
|
|
7047
|
+
direction: "reverse",
|
|
7048
|
+
writeGraph: true
|
|
7049
|
+
},
|
|
7050
|
+
{
|
|
7051
|
+
field: "ref_sor",
|
|
7052
|
+
sourceEntityType: "sor" /* SoR */,
|
|
7053
|
+
edgeType: "REFERENCES" /* References */,
|
|
7054
|
+
direction: "forward",
|
|
7055
|
+
writeGraph: true
|
|
7056
|
+
},
|
|
7057
|
+
{
|
|
7058
|
+
field: "product_refs",
|
|
7059
|
+
sourceEntityType: "epic" /* Epic */,
|
|
7060
|
+
edgeType: "REFERENCES" /* References */,
|
|
7061
|
+
direction: "forward",
|
|
7062
|
+
writeGraph: true
|
|
7063
|
+
},
|
|
7064
|
+
{
|
|
7065
|
+
field: "atoms.entities.ref",
|
|
7066
|
+
sourceEntityType: "any",
|
|
7067
|
+
edgeType: "MENTIONS" /* Mentions */,
|
|
7068
|
+
direction: "forward",
|
|
7069
|
+
writeGraph: true
|
|
7070
|
+
},
|
|
7071
|
+
{
|
|
7072
|
+
field: "atoms.behaviors.ref",
|
|
7073
|
+
sourceEntityType: "any",
|
|
7074
|
+
edgeType: "MENTIONS" /* Mentions */,
|
|
7075
|
+
direction: "forward",
|
|
7076
|
+
writeGraph: true
|
|
7077
|
+
},
|
|
7078
|
+
{
|
|
7079
|
+
field: "product_id",
|
|
7080
|
+
sourceEntityType: "sor" /* SoR */,
|
|
7081
|
+
edgeType: null,
|
|
7082
|
+
direction: "forward",
|
|
7083
|
+
writeGraph: false
|
|
7084
|
+
},
|
|
7085
|
+
{
|
|
7086
|
+
field: "process_id",
|
|
7087
|
+
sourceEntityType: "sor" /* SoR */,
|
|
7088
|
+
edgeType: "PRODUCES" /* Produces */,
|
|
7089
|
+
direction: "reverse",
|
|
7090
|
+
writeGraph: true
|
|
7091
|
+
}
|
|
7092
|
+
];
|
|
7093
|
+
// src/types/refPointer.ts
|
|
7094
|
+
var REF_POINTER_PATTERN = /^ref:(entity|relation|content):(.+)$/;
|
|
7095
|
+
function parseRef(pointer) {
|
|
7096
|
+
const match = REF_POINTER_PATTERN.exec(pointer);
|
|
7097
|
+
if (!match) {
|
|
7098
|
+
return null;
|
|
7099
|
+
}
|
|
7100
|
+
const [, type, id] = match;
|
|
7101
|
+
if (!id) {
|
|
7102
|
+
return null;
|
|
7103
|
+
}
|
|
7104
|
+
return { type, id };
|
|
7105
|
+
}
|
|
7106
|
+
function buildRef(type, id) {
|
|
7107
|
+
return `ref:${type}:${id}`;
|
|
7108
|
+
}
|
|
7109
|
+
function isRefPointer(value) {
|
|
7110
|
+
return typeof value === "string" && parseRef(value) !== null;
|
|
7111
|
+
}
|
|
7112
|
+
function extractAllRefs(data) {
|
|
7113
|
+
const results = [];
|
|
7114
|
+
const visit = (value, path) => {
|
|
7115
|
+
if (typeof value === "string") {
|
|
7116
|
+
if (isRefPointer(value)) {
|
|
7117
|
+
results.push({ pointer: value, fieldPath: path });
|
|
7118
|
+
}
|
|
7119
|
+
return;
|
|
7120
|
+
}
|
|
7121
|
+
if (Array.isArray(value)) {
|
|
7122
|
+
value.forEach((item, index) => {
|
|
7123
|
+
const nextPath = path ? `${path}[${index}]` : `[${index}]`;
|
|
7124
|
+
visit(item, nextPath);
|
|
7125
|
+
});
|
|
7126
|
+
return;
|
|
7127
|
+
}
|
|
7128
|
+
if (value && typeof value === "object") {
|
|
7129
|
+
for (const [key, entry] of Object.entries(value)) {
|
|
7130
|
+
const nextPath = path ? `${path}.${key}` : key;
|
|
7131
|
+
visit(entry, nextPath);
|
|
7132
|
+
}
|
|
7133
|
+
}
|
|
7134
|
+
};
|
|
7135
|
+
visit(data, "");
|
|
7136
|
+
return results;
|
|
7137
|
+
}
|
|
7032
7138
|
// src/types/serverConfig.ts
|
|
7033
7139
|
var DEFAULT_SERVER_CONFIG = {
|
|
7034
7140
|
server: {
|
|
7035
7141
|
port: 5100,
|
|
7036
|
-
host: "
|
|
7142
|
+
host: "::"
|
|
7143
|
+
},
|
|
7144
|
+
git_hosts: [],
|
|
7145
|
+
daemon_scheduler: {
|
|
7146
|
+
enabled: true,
|
|
7147
|
+
host: "localhost",
|
|
7148
|
+
port: 5110,
|
|
7149
|
+
workspace: "./data/daemon-workspace",
|
|
7150
|
+
max_daemons: 20
|
|
7037
7151
|
},
|
|
7038
7152
|
doc_db: {
|
|
7039
7153
|
provider: "sqlite",
|
|
@@ -7041,7 +7155,7 @@ var DEFAULT_SERVER_CONFIG = {
|
|
|
7041
7155
|
path: "./data/c4a.db"
|
|
7042
7156
|
},
|
|
7043
7157
|
mongodb: {
|
|
7044
|
-
uri: "mongodb://localhost:27017/c4a",
|
|
7158
|
+
uri: "mongodb://localhost:27017/c4a?directConnection=true",
|
|
7045
7159
|
database: "c4a"
|
|
7046
7160
|
}
|
|
7047
7161
|
},
|
|
@@ -7057,6 +7171,9 @@ var DEFAULT_SERVER_CONFIG = {
|
|
|
7057
7171
|
username: "root",
|
|
7058
7172
|
password: "nebula",
|
|
7059
7173
|
space: "c4a"
|
|
7174
|
+
},
|
|
7175
|
+
duckdb: {
|
|
7176
|
+
path: "./data/c4a-graph.duckdb"
|
|
7060
7177
|
}
|
|
7061
7178
|
},
|
|
7062
7179
|
vector_db: {
|
|
@@ -11158,7 +11275,7 @@ var atomFieldSchema = exports_external.enum(Object.values(AtomField));
|
|
|
11158
11275
|
var kindSchema = exports_external.enum(Object.values(Kind));
|
|
11159
11276
|
var scopeSchema = exports_external.literal("project");
|
|
11160
11277
|
var perspectiveSchema = exports_external.enum(Object.values(Perspective));
|
|
11161
|
-
var
|
|
11278
|
+
var extractionConfidenceSchema = exports_external.object({
|
|
11162
11279
|
structural: exports_external.number().min(0).max(1),
|
|
11163
11280
|
semantic: exports_external.number().min(0).max(1)
|
|
11164
11281
|
});
|
|
@@ -11166,13 +11283,29 @@ var metadataSchema = exports_external.object({
|
|
|
11166
11283
|
created_at: exports_external.string().datetime(),
|
|
11167
11284
|
updated_at: exports_external.string().datetime(),
|
|
11168
11285
|
version_tag: exports_external.string().optional(),
|
|
11169
|
-
|
|
11286
|
+
extraction_confidence: extractionConfidenceSchema.optional(),
|
|
11287
|
+
confidence: exports_external.number().min(0).max(1).optional(),
|
|
11288
|
+
aliases: exports_external.array(exports_external.string()).optional(),
|
|
11289
|
+
rank: exports_external.number().optional(),
|
|
11290
|
+
community_id: exports_external.string().optional(),
|
|
11291
|
+
community_level: exports_external.number().optional()
|
|
11292
|
+
});
|
|
11293
|
+
var entityRefPointerSchema = exports_external.string().regex(/^ref:entity:.+$/, "must be a ref pointer in format ref:entity:<id>");
|
|
11294
|
+
var sourceRefSpanSchema = exports_external.object({
|
|
11295
|
+
start: exports_external.number().int().min(1),
|
|
11296
|
+
end: exports_external.number().int().min(1)
|
|
11170
11297
|
});
|
|
11298
|
+
var sourceRefSchema = exports_external.object({
|
|
11299
|
+
ref: exports_external.string(),
|
|
11300
|
+
span: sourceRefSpanSchema.optional()
|
|
11301
|
+
});
|
|
11302
|
+
var sourceRefsSchema = exports_external.array(sourceRefSchema).optional();
|
|
11171
11303
|
// src/schemas/atomsSchema.ts
|
|
11172
11304
|
var confidenceAtomSchema = exports_external.number().min(0).max(1).optional();
|
|
11173
11305
|
var entityAtomSchema = exports_external.object({
|
|
11174
11306
|
name: exports_external.string(),
|
|
11175
11307
|
kind: kindSchema.optional(),
|
|
11308
|
+
ref: exports_external.string().optional(),
|
|
11176
11309
|
confidence: confidenceAtomSchema
|
|
11177
11310
|
});
|
|
11178
11311
|
var relationAtomSchema = exports_external.object({
|
|
@@ -11186,6 +11319,8 @@ var behaviorAtomSchema = exports_external.object({
|
|
|
11186
11319
|
name: exports_external.string(),
|
|
11187
11320
|
signature: exports_external.string().optional(),
|
|
11188
11321
|
description: exports_external.string().optional(),
|
|
11322
|
+
performed_by: exports_external.array(exports_external.string()).optional(),
|
|
11323
|
+
ref: exports_external.string().optional(),
|
|
11189
11324
|
confidence: confidenceAtomSchema
|
|
11190
11325
|
});
|
|
11191
11326
|
var attributeAtomSchema = exports_external.object({
|
|
@@ -11226,6 +11361,7 @@ var decisionPhaseSchema = exports_external.object({
|
|
|
11226
11361
|
rationale: exports_external.string().optional()
|
|
11227
11362
|
});
|
|
11228
11363
|
var decisionAtomSchema = exports_external.object({
|
|
11364
|
+
name: exports_external.string().optional(),
|
|
11229
11365
|
description: exports_external.string(),
|
|
11230
11366
|
rationale: exports_external.string(),
|
|
11231
11367
|
alternatives: exports_external.array(exports_external.string()).optional(),
|
|
@@ -11248,9 +11384,9 @@ var metricAtomSchema = exports_external.object({
|
|
|
11248
11384
|
});
|
|
11249
11385
|
var roleAtomSchema = exports_external.object({
|
|
11250
11386
|
name: exports_external.string(),
|
|
11251
|
-
kind: exports_external.enum(["
|
|
11387
|
+
kind: exports_external.enum(["human", "team", "persona"]),
|
|
11252
11388
|
performs: exports_external.array(exports_external.string()).optional(),
|
|
11253
|
-
|
|
11389
|
+
description: exports_external.string().optional()
|
|
11254
11390
|
});
|
|
11255
11391
|
var constraintAtomSchema = exports_external.object({
|
|
11256
11392
|
description: exports_external.string(),
|
|
@@ -11281,6 +11417,16 @@ var comparisonAtomSchema = exports_external.object({
|
|
|
11281
11417
|
decision_ref: exports_external.string().optional(),
|
|
11282
11418
|
confidence: confidenceAtomSchema
|
|
11283
11419
|
});
|
|
11420
|
+
var claimAtomSchema = exports_external.object({
|
|
11421
|
+
claim_type: exports_external.string(),
|
|
11422
|
+
description: exports_external.string(),
|
|
11423
|
+
status: exports_external.enum(["active", "deprecated", "proposed"]),
|
|
11424
|
+
valid_from: exports_external.string(),
|
|
11425
|
+
valid_until: exports_external.string().optional(),
|
|
11426
|
+
session_ref: exports_external.string().optional(),
|
|
11427
|
+
changed_by: exports_external.string(),
|
|
11428
|
+
confidence: confidenceAtomSchema
|
|
11429
|
+
});
|
|
11284
11430
|
var dataAtomsSchema = exports_external.object({
|
|
11285
11431
|
entities: exports_external.array(entityAtomSchema).optional(),
|
|
11286
11432
|
relations: exports_external.array(relationAtomSchema).optional(),
|
|
@@ -11295,31 +11441,115 @@ var dataAtomsSchema = exports_external.object({
|
|
|
11295
11441
|
roles: exports_external.array(roleAtomSchema).optional(),
|
|
11296
11442
|
constraints: exports_external.array(constraintAtomSchema).optional(),
|
|
11297
11443
|
comparisons: exports_external.array(comparisonAtomSchema).optional(),
|
|
11298
|
-
boundaries: exports_external.array(boundaryAtomSchema).optional()
|
|
11444
|
+
boundaries: exports_external.array(boundaryAtomSchema).optional(),
|
|
11445
|
+
claims: exports_external.array(claimAtomSchema).optional()
|
|
11299
11446
|
}).superRefine((atoms2, ctx) => {
|
|
11300
|
-
if (!atoms2.transitions || atoms2.transitions.length === 0) {
|
|
11301
|
-
return;
|
|
11302
|
-
}
|
|
11303
11447
|
const stateValues = new Set;
|
|
11448
|
+
const stateNames = new Set;
|
|
11304
11449
|
for (const state of atoms2.states ?? []) {
|
|
11450
|
+
stateNames.add(state.name);
|
|
11305
11451
|
for (const value of state.values) {
|
|
11306
11452
|
stateValues.add(value);
|
|
11307
11453
|
}
|
|
11308
11454
|
}
|
|
11309
|
-
|
|
11310
|
-
|
|
11311
|
-
|
|
11312
|
-
|
|
11313
|
-
|
|
11314
|
-
|
|
11315
|
-
|
|
11455
|
+
const behaviorNames = new Set;
|
|
11456
|
+
for (const behavior of atoms2.behaviors ?? []) {
|
|
11457
|
+
behaviorNames.add(behavior.name);
|
|
11458
|
+
}
|
|
11459
|
+
const roleNames = new Set;
|
|
11460
|
+
for (const role of atoms2.roles ?? []) {
|
|
11461
|
+
roleNames.add(role.name);
|
|
11462
|
+
}
|
|
11463
|
+
const eventNames = new Set;
|
|
11464
|
+
for (const event of atoms2.events ?? []) {
|
|
11465
|
+
eventNames.add(event.name);
|
|
11466
|
+
}
|
|
11467
|
+
const metricNames = new Set;
|
|
11468
|
+
for (const metric of atoms2.metrics ?? []) {
|
|
11469
|
+
metricNames.add(metric.name);
|
|
11470
|
+
}
|
|
11471
|
+
if (atoms2.transitions && atoms2.transitions.length > 0) {
|
|
11472
|
+
for (const transition of atoms2.transitions) {
|
|
11473
|
+
if (!stateValues.has(transition.from)) {
|
|
11474
|
+
ctx.addIssue({
|
|
11475
|
+
code: exports_external.ZodIssueCode.custom,
|
|
11476
|
+
path: ["transitions"],
|
|
11477
|
+
message: `transition.from references unknown state: ${transition.from}`
|
|
11478
|
+
});
|
|
11479
|
+
}
|
|
11480
|
+
if (!stateValues.has(transition.to)) {
|
|
11481
|
+
ctx.addIssue({
|
|
11482
|
+
code: exports_external.ZodIssueCode.custom,
|
|
11483
|
+
path: ["transitions"],
|
|
11484
|
+
message: `transition.to references unknown state: ${transition.to}`
|
|
11485
|
+
});
|
|
11486
|
+
}
|
|
11487
|
+
const hasEvents = eventNames.size > 0;
|
|
11488
|
+
const hasBehaviors = behaviorNames.size > 0;
|
|
11489
|
+
if (hasEvents || hasBehaviors) {
|
|
11490
|
+
const triggerMatchesEvent = hasEvents && eventNames.has(transition.trigger);
|
|
11491
|
+
const triggerMatchesBehavior = hasBehaviors && behaviorNames.has(transition.trigger);
|
|
11492
|
+
if (!triggerMatchesEvent && !triggerMatchesBehavior) {
|
|
11493
|
+
ctx.addIssue({
|
|
11494
|
+
code: exports_external.ZodIssueCode.custom,
|
|
11495
|
+
path: ["transitions"],
|
|
11496
|
+
message: `transition.trigger references unknown event/behavior: ${transition.trigger}`
|
|
11497
|
+
});
|
|
11498
|
+
}
|
|
11499
|
+
}
|
|
11316
11500
|
}
|
|
11317
|
-
|
|
11318
|
-
|
|
11319
|
-
|
|
11320
|
-
|
|
11321
|
-
|
|
11322
|
-
|
|
11501
|
+
}
|
|
11502
|
+
if (atoms2.roles && atoms2.roles.length > 0) {
|
|
11503
|
+
for (const [index, role] of atoms2.roles.entries()) {
|
|
11504
|
+
for (const perform of role.performs ?? []) {
|
|
11505
|
+
if (!behaviorNames.has(perform)) {
|
|
11506
|
+
ctx.addIssue({
|
|
11507
|
+
code: exports_external.ZodIssueCode.custom,
|
|
11508
|
+
path: ["roles", index, "performs"],
|
|
11509
|
+
message: `role.performs references unknown behavior: ${perform}`
|
|
11510
|
+
});
|
|
11511
|
+
}
|
|
11512
|
+
}
|
|
11513
|
+
}
|
|
11514
|
+
}
|
|
11515
|
+
if (atoms2.behaviors && atoms2.behaviors.length > 0) {
|
|
11516
|
+
for (const [index, behavior] of atoms2.behaviors.entries()) {
|
|
11517
|
+
for (const performer of behavior.performed_by ?? []) {
|
|
11518
|
+
if (!roleNames.has(performer)) {
|
|
11519
|
+
ctx.addIssue({
|
|
11520
|
+
code: exports_external.ZodIssueCode.custom,
|
|
11521
|
+
path: ["behaviors", index, "performed_by"],
|
|
11522
|
+
message: `behavior.performed_by references unknown role: ${performer}`
|
|
11523
|
+
});
|
|
11524
|
+
}
|
|
11525
|
+
}
|
|
11526
|
+
}
|
|
11527
|
+
}
|
|
11528
|
+
if (atoms2.rules && atoms2.rules.length > 0) {
|
|
11529
|
+
const allowedDependsOn = new Set([...stateNames, ...metricNames]);
|
|
11530
|
+
for (const [index, rule] of atoms2.rules.entries()) {
|
|
11531
|
+
for (const dependency of rule.depends_on ?? []) {
|
|
11532
|
+
if (!allowedDependsOn.has(dependency)) {
|
|
11533
|
+
ctx.addIssue({
|
|
11534
|
+
code: exports_external.ZodIssueCode.custom,
|
|
11535
|
+
path: ["rules", index, "depends_on"],
|
|
11536
|
+
message: `rule.depends_on references unknown state/metric: ${dependency}`
|
|
11537
|
+
});
|
|
11538
|
+
}
|
|
11539
|
+
}
|
|
11540
|
+
}
|
|
11541
|
+
}
|
|
11542
|
+
if (atoms2.events && atoms2.events.length > 0) {
|
|
11543
|
+
for (const [index, event] of atoms2.events.entries()) {
|
|
11544
|
+
for (const behaviorName of event.trigger_for ?? []) {
|
|
11545
|
+
if (!behaviorNames.has(behaviorName)) {
|
|
11546
|
+
ctx.addIssue({
|
|
11547
|
+
code: exports_external.ZodIssueCode.custom,
|
|
11548
|
+
path: ["events", index, "trigger_for"],
|
|
11549
|
+
message: `event.trigger_for references unknown behavior: ${behaviorName}`
|
|
11550
|
+
});
|
|
11551
|
+
}
|
|
11552
|
+
}
|
|
11323
11553
|
}
|
|
11324
11554
|
}
|
|
11325
11555
|
});
|
|
@@ -11335,7 +11565,8 @@ var atomsWhitelistByEntityType = {
|
|
|
11335
11565
|
"states" /* States */,
|
|
11336
11566
|
"rules" /* Rules */,
|
|
11337
11567
|
"transitions" /* Transitions */,
|
|
11338
|
-
"events" /* Events
|
|
11568
|
+
"events" /* Events */,
|
|
11569
|
+
"claims" /* Claims */
|
|
11339
11570
|
]),
|
|
11340
11571
|
["process" /* Process */]: new Set,
|
|
11341
11572
|
["sor" /* SoR */]: new Set([
|
|
@@ -11351,7 +11582,8 @@ var atomsWhitelistByEntityType = {
|
|
|
11351
11582
|
"metrics" /* Metrics */,
|
|
11352
11583
|
"roles" /* Roles */,
|
|
11353
11584
|
"constraints" /* Constraints */,
|
|
11354
|
-
"comparisons" /* Comparisons
|
|
11585
|
+
"comparisons" /* Comparisons */,
|
|
11586
|
+
"claims" /* Claims */
|
|
11355
11587
|
]),
|
|
11356
11588
|
["contract" /* Contract */]: new Set,
|
|
11357
11589
|
["epic" /* Epic */]: new Set([
|
|
@@ -11359,7 +11591,8 @@ var atomsWhitelistByEntityType = {
|
|
|
11359
11591
|
"metrics" /* Metrics */,
|
|
11360
11592
|
"roles" /* Roles */,
|
|
11361
11593
|
"constraints" /* Constraints */,
|
|
11362
|
-
"comparisons" /* Comparisons
|
|
11594
|
+
"comparisons" /* Comparisons */,
|
|
11595
|
+
"claims" /* Claims */
|
|
11363
11596
|
]),
|
|
11364
11597
|
["document" /* Document */]: new Set
|
|
11365
11598
|
};
|
|
@@ -11385,7 +11618,8 @@ var baseEntitySchema = exports_external.object({
|
|
|
11385
11618
|
kind: kindSchema,
|
|
11386
11619
|
scope: scopeSchema,
|
|
11387
11620
|
perspective: perspectiveSchema,
|
|
11388
|
-
metadata: metadataSchema
|
|
11621
|
+
metadata: metadataSchema,
|
|
11622
|
+
source_refs: sourceRefsSchema
|
|
11389
11623
|
});
|
|
11390
11624
|
var productDataSchema = exports_external.object({
|
|
11391
11625
|
description: exports_external.string().optional(),
|
|
@@ -11399,7 +11633,8 @@ var productEntitySchema = baseEntitySchema.extend({
|
|
|
11399
11633
|
});
|
|
11400
11634
|
var systemDataSchema = exports_external.object({
|
|
11401
11635
|
description: exports_external.string().optional(),
|
|
11402
|
-
corresponds_to: exports_external.string().optional()
|
|
11636
|
+
corresponds_to: exports_external.string().optional(),
|
|
11637
|
+
atoms: exports_external.undefined().optional()
|
|
11403
11638
|
});
|
|
11404
11639
|
var systemEntitySchema = baseEntitySchema.extend({
|
|
11405
11640
|
type: exports_external.literal("system" /* System */),
|
|
@@ -11445,9 +11680,10 @@ var sorEntitySchema = baseEntitySchema.extend({
|
|
|
11445
11680
|
data: sorDataSchema
|
|
11446
11681
|
});
|
|
11447
11682
|
var contractDataSchema = exports_external.object({
|
|
11448
|
-
format: exports_external.enum(["openapi", "asyncapi", "proto"]),
|
|
11683
|
+
format: exports_external.enum(["openapi", "asyncapi", "proto", "graphql", "custom"]),
|
|
11449
11684
|
spec: exports_external.string(),
|
|
11450
|
-
|
|
11685
|
+
version: exports_external.string().optional(),
|
|
11686
|
+
description: exports_external.string().optional()
|
|
11451
11687
|
});
|
|
11452
11688
|
var contractEntitySchema = baseEntitySchema.extend({
|
|
11453
11689
|
type: exports_external.literal("contract" /* Contract */),
|
|
@@ -11455,7 +11691,7 @@ var contractEntitySchema = baseEntitySchema.extend({
|
|
|
11455
11691
|
});
|
|
11456
11692
|
var epicDataSchema = exports_external.object({
|
|
11457
11693
|
description: exports_external.string().optional(),
|
|
11458
|
-
product_refs: exports_external.array(
|
|
11694
|
+
product_refs: exports_external.array(entityRefPointerSchema).optional(),
|
|
11459
11695
|
atoms: dataAtomsSchema.optional()
|
|
11460
11696
|
});
|
|
11461
11697
|
var epicEntitySchema = baseEntitySchema.extend({
|
|
@@ -11531,18 +11767,45 @@ var entitySchema = exports_external.discriminatedUnion("type", [
|
|
|
11531
11767
|
});
|
|
11532
11768
|
}
|
|
11533
11769
|
}
|
|
11770
|
+
if (entity2.type === "sor" /* SoR */ && entity2.data.atoms) {
|
|
11771
|
+
const { constraints, rules } = entity2.data.atoms;
|
|
11772
|
+
const hasConstraints = Array.isArray(constraints) && constraints.length > 0;
|
|
11773
|
+
const hasRules = Array.isArray(rules) && rules.length > 0;
|
|
11774
|
+
if (!hasConstraints && !hasRules) {
|
|
11775
|
+
ctx.addIssue({
|
|
11776
|
+
code: exports_external.ZodIssueCode.custom,
|
|
11777
|
+
path: ["data", "atoms"],
|
|
11778
|
+
message: "SoR must have at least one constraint or rule"
|
|
11779
|
+
});
|
|
11780
|
+
}
|
|
11781
|
+
}
|
|
11782
|
+
if (entity2.type === "epic" /* Epic */ && entity2.data.atoms) {
|
|
11783
|
+
const { decisions } = entity2.data.atoms;
|
|
11784
|
+
const hasDecisions = Array.isArray(decisions) && decisions.length > 0;
|
|
11785
|
+
if (!hasDecisions) {
|
|
11786
|
+
ctx.addIssue({
|
|
11787
|
+
code: exports_external.ZodIssueCode.custom,
|
|
11788
|
+
path: ["data", "atoms"],
|
|
11789
|
+
message: "Epic must have at least one decision"
|
|
11790
|
+
});
|
|
11791
|
+
}
|
|
11792
|
+
}
|
|
11534
11793
|
});
|
|
11535
11794
|
// src/schemas/relationSchema.ts
|
|
11536
11795
|
var relationDataSchema = exports_external.object({
|
|
11537
|
-
description: exports_external.string().optional()
|
|
11796
|
+
description: exports_external.string().optional(),
|
|
11797
|
+
_source: exports_external.literal("field_sync").optional()
|
|
11538
11798
|
});
|
|
11539
11799
|
var relationSchema = exports_external.object({
|
|
11540
11800
|
id: exports_external.string(),
|
|
11541
11801
|
type: relationTypeSchema,
|
|
11542
11802
|
from: exports_external.string(),
|
|
11543
11803
|
to: exports_external.string(),
|
|
11804
|
+
weight: exports_external.number().optional(),
|
|
11805
|
+
confidence: exports_external.number().min(0).max(1).optional(),
|
|
11544
11806
|
data: relationDataSchema.optional(),
|
|
11545
|
-
metadata: metadataSchema.optional()
|
|
11807
|
+
metadata: metadataSchema.optional(),
|
|
11808
|
+
source_refs: sourceRefsSchema
|
|
11546
11809
|
});
|
|
11547
11810
|
// src/errors/c4aError.ts
|
|
11548
11811
|
class C4AError extends Error {
|
|
@@ -11590,6 +11853,12 @@ var ErrorCode;
|
|
|
11590
11853
|
ErrorCode2["LLM_NOT_AVAILABLE"] = "LLM_NOT_AVAILABLE";
|
|
11591
11854
|
ErrorCode2["LLM_CALL_FAILED"] = "LLM_CALL_FAILED";
|
|
11592
11855
|
ErrorCode2["LLM_AUTH_FAILED"] = "LLM_AUTH_FAILED";
|
|
11856
|
+
ErrorCode2["AUTH_REQUIRED"] = "AUTH_REQUIRED";
|
|
11857
|
+
ErrorCode2["AUTH_INVALID_TOKEN"] = "AUTH_INVALID_TOKEN";
|
|
11858
|
+
ErrorCode2["AUTH_INVALID_API_KEY"] = "AUTH_INVALID_API_KEY";
|
|
11859
|
+
ErrorCode2["AUTH_PROVIDER_ERROR"] = "AUTH_PROVIDER_ERROR";
|
|
11860
|
+
ErrorCode2["AUTH_RESERVED_NAME"] = "AUTH_RESERVED_NAME";
|
|
11861
|
+
ErrorCode2["WORKSPACE_ISOLATION"] = "WORKSPACE_ISOLATION";
|
|
11593
11862
|
ErrorCode2["VECTOR_DIMENSION_MISMATCH"] = "VECTOR_DIMENSION_MISMATCH";
|
|
11594
11863
|
ErrorCode2["VECTOR_REBUILD_PARTIAL"] = "VECTOR_REBUILD_PARTIAL";
|
|
11595
11864
|
ErrorCode2["UNKNOWN"] = "UNKNOWN";
|
|
@@ -11612,6 +11881,10 @@ var ERROR_CODE_HTTP_STATUS = {
|
|
|
11612
11881
|
["ENTITY_DUPLICATE" /* ENTITY_DUPLICATE */]: 409,
|
|
11613
11882
|
["API_UNAUTHORIZED" /* API_UNAUTHORIZED */]: 401,
|
|
11614
11883
|
["LLM_AUTH_FAILED" /* LLM_AUTH_FAILED */]: 401,
|
|
11884
|
+
["AUTH_REQUIRED" /* AUTH_REQUIRED */]: 401,
|
|
11885
|
+
["AUTH_INVALID_TOKEN" /* AUTH_INVALID_TOKEN */]: 401,
|
|
11886
|
+
["AUTH_INVALID_API_KEY" /* AUTH_INVALID_API_KEY */]: 401,
|
|
11887
|
+
["AUTH_RESERVED_NAME" /* AUTH_RESERVED_NAME */]: 400,
|
|
11615
11888
|
["API_RATE_LIMITED" /* API_RATE_LIMITED */]: 429,
|
|
11616
11889
|
["API_NOT_IMPLEMENTED" /* API_NOT_IMPLEMENTED */]: 501,
|
|
11617
11890
|
["BATCH_PARTIAL_FAILURE" /* BATCH_PARTIAL_FAILURE */]: 200,
|
|
@@ -11624,7 +11897,9 @@ var ERROR_CODE_HTTP_STATUS = {
|
|
|
11624
11897
|
["PURGE_FAILED" /* PURGE_FAILED */]: 500,
|
|
11625
11898
|
["EMBEDDING_NOT_AVAILABLE" /* EMBEDDING_NOT_AVAILABLE */]: 503,
|
|
11626
11899
|
["LLM_NOT_AVAILABLE" /* LLM_NOT_AVAILABLE */]: 503,
|
|
11627
|
-
["
|
|
11900
|
+
["AUTH_PROVIDER_ERROR" /* AUTH_PROVIDER_ERROR */]: 502,
|
|
11901
|
+
["UNKNOWN" /* UNKNOWN */]: 500,
|
|
11902
|
+
["WORKSPACE_ISOLATION" /* WORKSPACE_ISOLATION */]: 400
|
|
11628
11903
|
};
|
|
11629
11904
|
function mapErrorCodeToStatus(code) {
|
|
11630
11905
|
return ERROR_CODE_HTTP_STATUS[code] ?? 500;
|
|
@@ -11681,14 +11956,144 @@ function parseYaml(value) {
|
|
|
11681
11956
|
}
|
|
11682
11957
|
}
|
|
11683
11958
|
// src/constants.ts
|
|
11684
|
-
var
|
|
11685
|
-
var
|
|
11686
|
-
var
|
|
11687
|
-
var
|
|
11688
|
-
var
|
|
11689
|
-
var DEFAULT_CLOUD_LIBRARY_NAME = "个人云";
|
|
11959
|
+
var DEFAULT_WORKSPACE_NAME = "My Brain";
|
|
11960
|
+
var DEFAULT_CLOUD_LIBRARY_NAME = "My Drive";
|
|
11961
|
+
var SUPERTEST_EMAIL = "supertest@context4ai.org";
|
|
11962
|
+
var SUPERTEST_USER_NAME = "SuperTest";
|
|
11963
|
+
var RESERVED_USER_NAMES = ["SuperTest"];
|
|
11690
11964
|
var DAEMON_HEARTBEAT_INTERVAL = 30000;
|
|
11691
11965
|
var DAEMON_OFFLINE_THRESHOLD = 60000;
|
|
11966
|
+
var CLOUD_DAEMON_IDLE_TIMEOUT = 300000;
|
|
11967
|
+
// src/contentTypeRegistry.ts
|
|
11968
|
+
var DEFAULT_CONTENT_TYPES = [
|
|
11969
|
+
{
|
|
11970
|
+
id: "markdown",
|
|
11971
|
+
category: "doc",
|
|
11972
|
+
match: { extensions: [".md", ".txt"] },
|
|
11973
|
+
cas: { encoding: "utf8", hashInput: "content" },
|
|
11974
|
+
pipeline: { digest: ["summary", "outline"], extraction: ["entities", "relations"] },
|
|
11975
|
+
display: { icon: "\uD83D\uDCC4", renderer: "text" }
|
|
11976
|
+
},
|
|
11977
|
+
{
|
|
11978
|
+
id: "typescript",
|
|
11979
|
+
category: "code",
|
|
11980
|
+
match: { extensions: [".ts", ".tsx"] },
|
|
11981
|
+
cas: { encoding: "utf8", hashInput: "content" },
|
|
11982
|
+
pipeline: { digest: ["ast", "summary"], extraction: ["entities", "relations"] },
|
|
11983
|
+
display: { icon: "\uD83D\uDCDC", renderer: "code" }
|
|
11984
|
+
},
|
|
11985
|
+
{
|
|
11986
|
+
id: "package",
|
|
11987
|
+
category: "package",
|
|
11988
|
+
match: { filenames: ["package.json", "go.mod", "pyproject.toml", "Cargo.toml", "pom.xml"] },
|
|
11989
|
+
cas: { encoding: "utf8", hashInput: "identity" },
|
|
11990
|
+
pipeline: { digest: ["summary"], extraction: ["entities", "relations"] },
|
|
11991
|
+
display: { icon: "\uD83D\uDCE6", renderer: "package-card" }
|
|
11992
|
+
},
|
|
11993
|
+
{
|
|
11994
|
+
id: "pdf",
|
|
11995
|
+
category: "binary",
|
|
11996
|
+
match: { extensions: [".pdf"] },
|
|
11997
|
+
cas: { encoding: "base64", hashInput: "content" },
|
|
11998
|
+
pipeline: { digest: [], extraction: [] },
|
|
11999
|
+
display: { icon: "\uD83D\uDCD5", renderer: "binary-preview" }
|
|
12000
|
+
},
|
|
12001
|
+
{
|
|
12002
|
+
id: "msword",
|
|
12003
|
+
category: "binary",
|
|
12004
|
+
match: { extensions: [".doc", ".docx"] },
|
|
12005
|
+
cas: { encoding: "base64", hashInput: "content" },
|
|
12006
|
+
pipeline: { digest: [], extraction: [] },
|
|
12007
|
+
display: { icon: "\uD83D\uDCD8", renderer: "binary-preview" }
|
|
12008
|
+
},
|
|
12009
|
+
{
|
|
12010
|
+
id: "mspowerpoint",
|
|
12011
|
+
category: "binary",
|
|
12012
|
+
match: { extensions: [".ppt", ".pptx"] },
|
|
12013
|
+
cas: { encoding: "base64", hashInput: "content" },
|
|
12014
|
+
pipeline: { digest: [], extraction: [] },
|
|
12015
|
+
display: { icon: "\uD83D\uDCD9", renderer: "binary-preview" }
|
|
12016
|
+
}
|
|
12017
|
+
];
|
|
12018
|
+
var normalizeExtension = (ext) => ext.trim().toLowerCase();
|
|
12019
|
+
var normalizeFilename = (name) => name.trim().toLowerCase();
|
|
12020
|
+
|
|
12021
|
+
class ContentTypeRegistry {
|
|
12022
|
+
definitions;
|
|
12023
|
+
extensionIndex;
|
|
12024
|
+
filenameIndex;
|
|
12025
|
+
constructor(definitions) {
|
|
12026
|
+
this.definitions = definitions;
|
|
12027
|
+
this.extensionIndex = new Map;
|
|
12028
|
+
this.filenameIndex = new Map;
|
|
12029
|
+
for (const def of definitions) {
|
|
12030
|
+
for (const ext of def.match.extensions ?? []) {
|
|
12031
|
+
this.extensionIndex.set(normalizeExtension(ext), def);
|
|
12032
|
+
}
|
|
12033
|
+
for (const name of def.match.filenames ?? []) {
|
|
12034
|
+
this.filenameIndex.set(normalizeFilename(name), def);
|
|
12035
|
+
}
|
|
12036
|
+
}
|
|
12037
|
+
}
|
|
12038
|
+
resolve(filename) {
|
|
12039
|
+
const baseName = filename.includes("/") ? filename.split("/").pop() ?? filename : filename;
|
|
12040
|
+
const normalized = normalizeFilename(baseName);
|
|
12041
|
+
const byName = this.filenameIndex.get(normalized);
|
|
12042
|
+
if (byName)
|
|
12043
|
+
return byName;
|
|
12044
|
+
const dot = normalized.lastIndexOf(".");
|
|
12045
|
+
if (dot < 0)
|
|
12046
|
+
return null;
|
|
12047
|
+
const ext = normalizeExtension(normalized.slice(dot));
|
|
12048
|
+
return this.extensionIndex.get(ext) ?? null;
|
|
12049
|
+
}
|
|
12050
|
+
getManifestFilenames() {
|
|
12051
|
+
const names = new Set;
|
|
12052
|
+
for (const def of this.definitions) {
|
|
12053
|
+
if (def.category !== "package")
|
|
12054
|
+
continue;
|
|
12055
|
+
for (const name of def.match.filenames ?? []) {
|
|
12056
|
+
names.add(normalizeFilename(name));
|
|
12057
|
+
}
|
|
12058
|
+
}
|
|
12059
|
+
return Array.from(names);
|
|
12060
|
+
}
|
|
12061
|
+
getDefinitions() {
|
|
12062
|
+
return [...this.definitions];
|
|
12063
|
+
}
|
|
12064
|
+
}
|
|
12065
|
+
var defaultRegistry = new ContentTypeRegistry(DEFAULT_CONTENT_TYPES);
|
|
12066
|
+
var DEFAULT_CONTENT_TYPE_DEFINITIONS = DEFAULT_CONTENT_TYPES;
|
|
12067
|
+
// src/fileTypes.ts
|
|
12068
|
+
var collectExtensions = (predicate) => {
|
|
12069
|
+
const extensions = new Set;
|
|
12070
|
+
for (const definition of DEFAULT_CONTENT_TYPE_DEFINITIONS) {
|
|
12071
|
+
if (!predicate(definition))
|
|
12072
|
+
continue;
|
|
12073
|
+
for (const ext of definition.match.extensions ?? []) {
|
|
12074
|
+
extensions.add(ext.toLowerCase());
|
|
12075
|
+
}
|
|
12076
|
+
}
|
|
12077
|
+
return extensions;
|
|
12078
|
+
};
|
|
12079
|
+
var INDEXABLE_CODE_EXTENSIONS = collectExtensions((definition) => definition.category === "code");
|
|
12080
|
+
var INDEXABLE_DOC_EXTENSIONS = collectExtensions((definition) => definition.category === "doc");
|
|
12081
|
+
var INDEXABLE_EXTENSIONS = new Set([
|
|
12082
|
+
...INDEXABLE_CODE_EXTENSIONS,
|
|
12083
|
+
...INDEXABLE_DOC_EXTENSIONS
|
|
12084
|
+
]);
|
|
12085
|
+
var UPLOAD_ALLOWED_EXTENSIONS = collectExtensions(() => true);
|
|
12086
|
+
var TEXT_EXTENSIONS = collectExtensions((definition) => definition.cas.encoding === "utf8");
|
|
12087
|
+
var UPLOAD_MAX_FILE_SIZE = 5 * 1024 * 1024;
|
|
12088
|
+
var UPLOAD_MAX_FILES = 10;
|
|
12089
|
+
function getFileExtension(name) {
|
|
12090
|
+
const dot = name.lastIndexOf(".");
|
|
12091
|
+
return dot >= 0 ? name.slice(dot).toLowerCase() : "";
|
|
12092
|
+
}
|
|
12093
|
+
function isIndexableFile(fileName, manifestFiles) {
|
|
12094
|
+
const baseName = fileName.includes("/") ? fileName.split("/").pop() : fileName;
|
|
12095
|
+
return defaultRegistry.resolve(baseName) !== null;
|
|
12096
|
+
}
|
|
11692
12097
|
// src/wsEvents.ts
|
|
11693
12098
|
var WS_SESSION_STATUS = "ws:session:status";
|
|
11694
12099
|
var WS_SESSION_PROGRESS = "ws:session:progress";
|
|
@@ -11703,6 +12108,9 @@ export {
|
|
|
11703
12108
|
transitionAtomSchema,
|
|
11704
12109
|
systemEntitySchema,
|
|
11705
12110
|
stateAtomSchema,
|
|
12111
|
+
sourceRefsSchema,
|
|
12112
|
+
sourceRefSpanSchema,
|
|
12113
|
+
sourceRefSchema,
|
|
11706
12114
|
sorEntitySchema,
|
|
11707
12115
|
sessionDecisionSchema,
|
|
11708
12116
|
serializeYaml,
|
|
@@ -11717,6 +12125,7 @@ export {
|
|
|
11717
12125
|
processEntitySchema,
|
|
11718
12126
|
perspectiveSchema,
|
|
11719
12127
|
parseYaml,
|
|
12128
|
+
parseRef,
|
|
11720
12129
|
modelingSessionDataSchema,
|
|
11721
12130
|
metricMilestoneSchema,
|
|
11722
12131
|
metricAtomSchema,
|
|
@@ -11724,30 +12133,39 @@ export {
|
|
|
11724
12133
|
mapErrorCodeToStatus,
|
|
11725
12134
|
kindSchema,
|
|
11726
12135
|
isValidManifest,
|
|
12136
|
+
isRefPointer,
|
|
11727
12137
|
isPathSafe,
|
|
12138
|
+
isIndexableFile,
|
|
12139
|
+
getFileExtension,
|
|
11728
12140
|
generateUUID,
|
|
11729
12141
|
generateId,
|
|
12142
|
+
extractionConfidenceSchema,
|
|
12143
|
+
extractAllRefs,
|
|
11730
12144
|
eventAtomSchema,
|
|
11731
12145
|
epicEntitySchema,
|
|
11732
12146
|
entityTypeSchema,
|
|
11733
12147
|
entitySchema,
|
|
12148
|
+
entityRefPointerSchema,
|
|
11734
12149
|
entityAtomSchema,
|
|
11735
12150
|
documentSchema,
|
|
11736
12151
|
documentModelingEntitySchema,
|
|
11737
12152
|
documentEntitySchema,
|
|
11738
12153
|
documentAdrEntitySchema,
|
|
12154
|
+
defaultRegistry,
|
|
11739
12155
|
decisionPhaseSchema,
|
|
11740
12156
|
decisionAtomSchema,
|
|
11741
12157
|
dataAtomsSchema,
|
|
11742
12158
|
contractEntitySchema,
|
|
12159
|
+
contractDataSchema,
|
|
11743
12160
|
contentHash,
|
|
11744
12161
|
containerEntitySchema,
|
|
11745
12162
|
constraintAtomSchema,
|
|
11746
|
-
confidenceSchema,
|
|
11747
12163
|
componentEntitySchema,
|
|
11748
12164
|
comparisonDimensionValueSchema,
|
|
11749
12165
|
comparisonDimensionSchema,
|
|
11750
12166
|
comparisonAtomSchema,
|
|
12167
|
+
claimAtomSchema,
|
|
12168
|
+
buildRef,
|
|
11751
12169
|
boundaryAtomSchema,
|
|
11752
12170
|
behaviorAtomSchema,
|
|
11753
12171
|
attributeAtomSchema,
|
|
@@ -11763,21 +12181,31 @@ export {
|
|
|
11763
12181
|
WS_DAEMON_HANDSHAKE_ACK,
|
|
11764
12182
|
WS_DAEMON_HANDSHAKE,
|
|
11765
12183
|
WS_DAEMON_CONNECTED,
|
|
12184
|
+
UPLOAD_MAX_FILE_SIZE,
|
|
12185
|
+
UPLOAD_MAX_FILES,
|
|
12186
|
+
UPLOAD_ALLOWED_EXTENSIONS,
|
|
12187
|
+
TEXT_EXTENSIONS,
|
|
12188
|
+
SUPERTEST_USER_NAME,
|
|
12189
|
+
SUPERTEST_EMAIL,
|
|
11766
12190
|
RelationType,
|
|
12191
|
+
RESERVED_USER_NAMES,
|
|
11767
12192
|
Perspective,
|
|
11768
12193
|
Kind,
|
|
12194
|
+
INDEXABLE_EXTENSIONS,
|
|
12195
|
+
INDEXABLE_DOC_EXTENSIONS,
|
|
12196
|
+
INDEXABLE_CODE_EXTENSIONS,
|
|
11769
12197
|
ErrorCode,
|
|
11770
12198
|
EntityType,
|
|
12199
|
+
EDGE_SYNC_RULES,
|
|
11771
12200
|
DEFAULT_WORKSPACE_NAME,
|
|
11772
|
-
DEFAULT_WORKSPACE_ID,
|
|
11773
|
-
DEFAULT_USER_NAME,
|
|
11774
|
-
DEFAULT_USER_ID,
|
|
11775
12201
|
DEFAULT_SERVER_CONFIG,
|
|
12202
|
+
DEFAULT_CONTENT_TYPE_DEFINITIONS,
|
|
11776
12203
|
DEFAULT_CLOUD_LIBRARY_NAME,
|
|
11777
|
-
DEFAULT_CLOUD_LIBRARY_ID,
|
|
11778
12204
|
DAEMON_OFFLINE_THRESHOLD,
|
|
11779
12205
|
DAEMON_HEARTBEAT_INTERVAL,
|
|
12206
|
+
ContentTypeRegistry,
|
|
11780
12207
|
CODE_PACKAGE_FILES,
|
|
12208
|
+
CLOUD_DAEMON_IDLE_TIMEOUT,
|
|
11781
12209
|
C4AError,
|
|
11782
12210
|
AtomField
|
|
11783
12211
|
};
|