@mastra/factory 0.26.0 → 0.27.0-alpha.1
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/README.md +10 -0
- package/dist/factory.d.ts.map +1 -1
- package/dist/factory.js +7 -3
- package/dist/factory.js.map +1 -1
- package/dist/integrations/gitlab/default-rules.d.ts +1 -1
- package/dist/integrations/gitlab/default-rules.d.ts.map +1 -1
- package/dist/integrations/incidentio/default-rules.d.ts +0 -1
- package/dist/integrations/incidentio/default-rules.d.ts.map +1 -1
- package/dist/integrations/incidentio/default-rules.js +0 -2
- package/dist/integrations/incidentio/default-rules.js.map +1 -1
- package/dist/integrations/incidentio/rules.d.ts.map +1 -1
- package/dist/integrations/incidentio/rules.js +2 -27
- package/dist/integrations/incidentio/rules.js.map +1 -1
- package/dist/integrations/jira/default-rules.d.ts +0 -1
- package/dist/integrations/jira/default-rules.d.ts.map +1 -1
- package/dist/integrations/jira/default-rules.js +0 -2
- package/dist/integrations/jira/default-rules.js.map +1 -1
- package/dist/integrations/jira/routes.d.ts +1 -1
- package/dist/integrations/jira/routes.d.ts.map +1 -1
- package/dist/integrations/jira/routes.js +6 -3
- package/dist/integrations/jira/routes.js.map +1 -1
- package/dist/integrations/jira/rules.d.ts.map +1 -1
- package/dist/integrations/jira/rules.js +2 -22
- package/dist/integrations/jira/rules.js.map +1 -1
- package/dist/integrations/linear/default-rules.d.ts +0 -1
- package/dist/integrations/linear/default-rules.d.ts.map +1 -1
- package/dist/integrations/linear/default-rules.js +0 -2
- package/dist/integrations/linear/default-rules.js.map +1 -1
- package/dist/integrations/linear/routes.d.ts +1 -1
- package/dist/integrations/linear/routes.d.ts.map +1 -1
- package/dist/integrations/linear/routes.js +13 -15
- package/dist/integrations/linear/routes.js.map +1 -1
- package/dist/integrations/linear/rules.d.ts.map +1 -1
- package/dist/integrations/linear/rules.js +2 -23
- package/dist/integrations/linear/rules.js.map +1 -1
- package/dist/integrations/platform/jira/routes.d.ts +1 -1
- package/dist/integrations/platform/jira/routes.d.ts.map +1 -1
- package/dist/integrations/platform/jira/routes.js +6 -3
- package/dist/integrations/platform/jira/routes.js.map +1 -1
- package/dist/routes/contracts.d.ts +54 -1
- package/dist/routes/contracts.d.ts.map +1 -1
- package/dist/routes/contracts.js +54 -1
- package/dist/routes/contracts.js.map +1 -1
- package/dist/routes/knowledge.d.ts +12 -228
- package/dist/routes/knowledge.d.ts.map +1 -1
- package/dist/routes/knowledge.js +207 -1045
- package/dist/routes/knowledge.js.map +1 -1
- package/dist/routes/skills.d.ts +9 -0
- package/dist/routes/skills.d.ts.map +1 -1
- package/dist/routes/skills.js +145 -4
- package/dist/routes/skills.js.map +1 -1
- package/dist/routes/surface.d.ts +2 -0
- package/dist/routes/surface.d.ts.map +1 -1
- package/dist/routes/surface.js +7 -5
- package/dist/routes/surface.js.map +1 -1
- package/dist/rules/dispatcher.d.ts.map +1 -1
- package/dist/rules/dispatcher.js +24 -45
- package/dist/rules/dispatcher.js.map +1 -1
- package/dist/rules/processor.d.ts.map +1 -1
- package/dist/rules/processor.js +1 -0
- package/dist/rules/processor.js.map +1 -1
- package/dist/rules/types.d.ts +0 -7
- package/dist/rules/types.d.ts.map +1 -1
- package/dist/rules/types.js.map +1 -1
- package/dist/rules/validation.d.ts.map +1 -1
- package/dist/rules/validation.js +0 -2
- package/dist/rules/validation.js.map +1 -1
- package/dist/session/org-seed.d.ts +1 -1
- package/dist/session/org-seed.js.map +1 -1
- package/dist/skills/catalog.d.ts +28 -3
- package/dist/skills/catalog.d.ts.map +1 -1
- package/dist/skills/catalog.js +51 -8
- package/dist/skills/catalog.js.map +1 -1
- package/dist/storage/domains/audit/actions.d.ts +1 -0
- package/dist/storage/domains/audit/actions.d.ts.map +1 -1
- package/dist/storage/domains/audit/actions.js +2 -1
- package/dist/storage/domains/audit/actions.js.map +1 -1
- package/dist/storage/domains/skill-overrides/base.d.ts +56 -0
- package/dist/storage/domains/skill-overrides/base.d.ts.map +1 -0
- package/dist/storage/domains/skill-overrides/base.js +157 -0
- package/dist/storage/domains/skill-overrides/base.js.map +1 -0
- package/dist/storage/domains/work-items/base.d.ts +0 -34
- package/dist/storage/domains/work-items/base.d.ts.map +1 -1
- package/dist/storage/domains/work-items/base.js +10 -139
- package/dist/storage/domains/work-items/base.js.map +1 -1
- package/dist/workspace.d.ts +13 -1
- package/dist/workspace.d.ts.map +1 -1
- package/dist/workspace.js +94 -17
- package/dist/workspace.js.map +1 -1
- package/package.json +9 -9
- package/dist/integrations/incidentio/claim.d.ts +0 -8
- package/dist/integrations/incidentio/claim.d.ts.map +0 -1
- package/dist/integrations/incidentio/claim.js +0 -13
- package/dist/integrations/incidentio/claim.js.map +0 -1
- package/dist/integrations/jira/claim.d.ts +0 -21
- package/dist/integrations/jira/claim.d.ts.map +0 -1
- package/dist/integrations/jira/claim.js +0 -37
- package/dist/integrations/jira/claim.js.map +0 -1
- package/dist/integrations/linear/claim.d.ts +0 -8
- package/dist/integrations/linear/claim.d.ts.map +0 -1
- package/dist/integrations/linear/claim.js +0 -13
- package/dist/integrations/linear/claim.js.map +0 -1
|
@@ -1,247 +1,31 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Read-only Mastra `apiRoutes`
|
|
2
|
+
* Read-only Mastra `apiRoutes` behind Factory's Knowledge page: the schema-4 page tree, a page with its
|
|
3
|
+
* notes, the bounded page graph, search and activity, all through the same core page readers Studio uses,
|
|
4
|
+
* plus a change stream (`/events`, SSE) naming the pages and scopes each committed write touched.
|
|
5
|
+
* Every endpoint is a GET; this module never writes Knowledge.
|
|
3
6
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
* view queries `[org:<orgId>, resource:<projectId>]` (org + project records).
|
|
11
|
-
* Thread-scoped records are reachable ONLY via an explicit, server-validated
|
|
12
|
-
* `threadId` query parameter (the drill-down view), which appends the thread
|
|
13
|
-
* rung to the query scope. A thread is drillable iff it produced knowledge
|
|
14
|
-
* visible under the caller's org/project prefix; unknown or cross-org threads
|
|
15
|
-
* 404 — never a silent fallback to the default view.
|
|
7
|
+
* Scoping is fail-closed and server-side. The caller must be signed in to an org that owns the `:id`
|
|
8
|
+
* project, and reads are limited to what the Knowledge's own declarations give the principals
|
|
9
|
+
* `org:<orgId>` and `project:<projectId>`: the scopes a run in that project holds at org and project
|
|
10
|
+
* level. Session (`resource:`/`thread:`) scopes are not principals here, so no member browses another
|
|
11
|
+
* member's session pages. The host must declare `project:$projectId` (as its session runs need); without
|
|
12
|
+
* it reads fail with 500 `knowledge_misconfigured`.
|
|
16
13
|
*/
|
|
17
14
|
import type { Knowledge } from '@mastra/core/knowledge';
|
|
18
15
|
import type { ApiRoute } from '@mastra/core/server';
|
|
19
|
-
import type { KnowledgeScope, KnowledgeScopeNodeSummary } from '@mastra/core/storage';
|
|
20
16
|
import type { FactoryProjectsStorage } from '../storage/domains/projects/base.js';
|
|
21
17
|
import type { RouteDependencies } from './route.js';
|
|
22
18
|
import { Route } from './route.js';
|
|
23
|
-
export type KnowledgeScopeLevel = 'org' | 'resource' | 'thread';
|
|
24
|
-
export interface KnowledgeScopeTreeNode extends KnowledgeScopeNodeSummary {
|
|
25
|
-
/** Viewer-visible direct members, capped by the route's node window. */
|
|
26
|
-
memberCount: number;
|
|
27
|
-
/** True when more direct members may exist beyond `memberCount`. */
|
|
28
|
-
memberCountTruncated: boolean;
|
|
29
|
-
/** Viewer-visible content nodes directly assigned to this scope. */
|
|
30
|
-
contentNodeCount: number;
|
|
31
|
-
/** Direct child scopes available for lazy expansion. */
|
|
32
|
-
childScopeCount: number;
|
|
33
|
-
}
|
|
34
|
-
export interface KnowledgeSearchResult {
|
|
35
|
-
id: string;
|
|
36
|
-
name: string;
|
|
37
|
-
kind: string;
|
|
38
|
-
type: 'scope' | 'node';
|
|
39
|
-
rung: KnowledgeScopeLevel | null;
|
|
40
|
-
/** Present when a thread-scoped content result needs to restore its owning session lens. */
|
|
41
|
-
threadId?: string;
|
|
42
|
-
}
|
|
43
|
-
export interface KnowledgeSearchPayload {
|
|
44
|
-
results: KnowledgeSearchResult[];
|
|
45
|
-
truncated: boolean;
|
|
46
|
-
}
|
|
47
|
-
export interface KnowledgeScopeTreePayload {
|
|
48
|
-
roots: Array<{
|
|
49
|
-
level: KnowledgeScopeLevel;
|
|
50
|
-
id: string;
|
|
51
|
-
available: boolean;
|
|
52
|
-
/**
|
|
53
|
-
* Set when a reconciled structural scope node has this rung's canonical
|
|
54
|
-
* address (`org:<orgId>`, `resource:<projectId>`, `thread:<threadId>`) —
|
|
55
|
-
* the client renders ONE merged entry (structural name, identity marker)
|
|
56
|
-
* that opens the structural lens instead of duplicating the scope.
|
|
57
|
-
*/
|
|
58
|
-
scopeNodeId?: string;
|
|
59
|
-
/** Structural name of the matched scope node (present iff scopeNodeId). */
|
|
60
|
-
name?: string;
|
|
61
|
-
}>;
|
|
62
|
-
defaultLevel: 'resource';
|
|
63
|
-
/**
|
|
64
|
-
* Reconciled structural scope tree (isScope nodes with membership edges),
|
|
65
|
-
* e.g. `mastra → features → memory` and `repo:mastra → issues/prs`. Omitted
|
|
66
|
-
* only when the storage adapter does not expose structural scope nodes.
|
|
67
|
-
*/
|
|
68
|
-
scopeNodes?: KnowledgeScopeTreeNode[];
|
|
69
|
-
/** Cursor for the next sibling page (roots when parentId is omitted). */
|
|
70
|
-
nextCursor?: string;
|
|
71
|
-
/** Initial child-page cursors keyed by parent scope id. */
|
|
72
|
-
childCursors?: Record<string, string>;
|
|
73
|
-
/** True when the org has more scopes than the route reads, so whole scopes are missing from the tree. */
|
|
74
|
-
truncated?: boolean;
|
|
75
|
-
}
|
|
76
|
-
/** Window caps. Injectable at construction only — never per-request. */
|
|
77
|
-
export interface KnowledgeRouteLimits {
|
|
78
|
-
/** Max nodes in a graph snapshot (newest-first). */
|
|
79
|
-
maxNodes: number;
|
|
80
|
-
/** Max records parsed for edges per snapshot (newest-first). */
|
|
81
|
-
maxRecords: number;
|
|
82
|
-
/** Max fallback `resolveNode` store lookups per request (deduped per unique name+scope). */
|
|
83
|
-
maxFallbackLookups: number;
|
|
84
|
-
/** Max `listScopeNodes` pages (of up to 1,000 scopes) read for one org; past it responses report `truncated`. */
|
|
85
|
-
maxOrgScopePages: number;
|
|
86
|
-
}
|
|
87
19
|
export interface KnowledgeRoutesDeps extends RouteDependencies {
|
|
88
|
-
/** Factory projects domain
|
|
20
|
+
/** Factory projects domain: validates that the `:id` project belongs to the caller's org. */
|
|
89
21
|
projects: FactoryProjectsStorage;
|
|
90
22
|
/** Lazy handle to the host-registered Knowledge runtime; endpoints 503 when absent. */
|
|
91
23
|
knowledge: (key: string) => Promise<Knowledge | undefined>;
|
|
92
|
-
/** Host-selected Knowledge key. Requests cannot override it
|
|
24
|
+
/** Host-selected Knowledge key. Requests cannot override it. */
|
|
93
25
|
defaultKnowledgeKey?: string;
|
|
94
|
-
limits?: Partial<KnowledgeRouteLimits>;
|
|
95
|
-
/**
|
|
96
|
-
* Current title of a thread, read when a session scope is listed so its label follows renames.
|
|
97
|
-
* Sessions fall back to `session <first 8 of id>` when absent or untitled.
|
|
98
|
-
*/
|
|
99
|
-
threadTitle?: (threadId: string) => Promise<string | undefined>;
|
|
100
|
-
}
|
|
101
|
-
/** A graph node. `recordCount` is window-derived (records inside the snapshot window only). */
|
|
102
|
-
export interface KnowledgeGraphNode {
|
|
103
|
-
id: string;
|
|
104
|
-
name: string;
|
|
105
|
-
kind: string;
|
|
106
|
-
description?: string;
|
|
107
|
-
/** Null for structural scope-node members (global, not identity-scoped). */
|
|
108
|
-
scope: KnowledgeScope | null;
|
|
109
|
-
/** Deepest rung of the record's scope: org | resource | thread; null for scope nodes. */
|
|
110
|
-
rung: 'org' | 'resource' | 'thread' | null;
|
|
111
|
-
/** True for structural scope nodes (member-lens drill targets); absent for content nodes. */
|
|
112
|
-
isScope?: boolean;
|
|
113
|
-
/**
|
|
114
|
-
* True when a non-deleted pinned record's wikilinks reference ONLY this
|
|
115
|
-
* node (A9: multi-target pins mark their edges instead — the pin is
|
|
116
|
-
* about the relationship; a single-target pin has no edge to carry it).
|
|
117
|
-
*/
|
|
118
|
-
pinned: boolean;
|
|
119
|
-
/** Records owned by this node INSIDE the snapshot window (not a total). */
|
|
120
|
-
recordCount: number;
|
|
121
|
-
/** Viewer-visible direct-member counts, present only for structural scope nodes. */
|
|
122
|
-
memberCount?: number;
|
|
123
|
-
memberCountTruncated?: boolean;
|
|
124
|
-
contentNodeCount?: number;
|
|
125
|
-
childScopeCount?: number;
|
|
126
|
-
/** Omitted for a structural lens root when the adapter cannot read it back as a node. */
|
|
127
|
-
createdAt?: string;
|
|
128
|
-
updatedAt?: string;
|
|
129
|
-
}
|
|
130
|
-
export interface KnowledgeGraphEdge {
|
|
131
|
-
id: string;
|
|
132
|
-
/** The owning node of the record (its `node`); the scope node for containment edges. */
|
|
133
|
-
source: string;
|
|
134
|
-
/** The wikilink-resolved node; the contained member for containment edges. */
|
|
135
|
-
target: string;
|
|
136
|
-
/**
|
|
137
|
-
* 'wikilink': derived from a record's wikilinks (the record's `node` is the
|
|
138
|
-
* edge SOURCE, so the plan's "parent link" collapses into the wikilink edge).
|
|
139
|
-
* 'contains': structural lens only — the selected scope node contains the
|
|
140
|
-
* target member, so the clicked scope is visible as its own graph root.
|
|
141
|
-
*/
|
|
142
|
-
type: 'wikilink' | 'contains';
|
|
143
|
-
/** The record whose text produced the edge; absent on containment edges. */
|
|
144
|
-
recordId?: string;
|
|
145
|
-
/**
|
|
146
|
-
* True when the edge is derived from a PINNED record linking two nodes —
|
|
147
|
-
* the pin marks the relationship, so the accent lives on the edge (A9).
|
|
148
|
-
*/
|
|
149
|
-
pinned?: boolean;
|
|
150
|
-
}
|
|
151
|
-
/**
|
|
152
|
-
* A knowledge record as a first-class graph element (A11): every record in the window,
|
|
153
|
-
* with the in-window nodes it touches. The client renders by arity —
|
|
154
|
-
* 1 node: a small dot linked to it; 2: the connecting line; 3+: a midpoint
|
|
155
|
-
* junction splitting to each node. Pin records have their hidden reserved
|
|
156
|
-
* owner omitted, so their arity comes purely from wikilink targets.
|
|
157
|
-
*/
|
|
158
|
-
export interface KnowledgeGraphRecord {
|
|
159
|
-
/** The record id. */
|
|
160
|
-
id: string;
|
|
161
|
-
/** Owner node first (omitted for pins), then resolved wikilink targets. */
|
|
162
|
-
nodeIds: string[];
|
|
163
|
-
pinned: boolean;
|
|
164
|
-
/** Record text, truncated for hover cards. */
|
|
165
|
-
text: string;
|
|
166
|
-
}
|
|
167
|
-
export interface KnowledgeGraphPayload {
|
|
168
|
-
view: 'project' | 'thread';
|
|
169
|
-
threadId?: string;
|
|
170
|
-
nodes: KnowledgeGraphNode[];
|
|
171
|
-
edges: KnowledgeGraphEdge[];
|
|
172
|
-
records: KnowledgeGraphRecord[];
|
|
173
|
-
/** True when the node or record window cap was hit (newest-first window). */
|
|
174
|
-
truncated: boolean;
|
|
175
|
-
/** Authorized wikilink targets outside the node window, including enough scope context for a deep-link jump. */
|
|
176
|
-
outOfWindow: Array<{
|
|
177
|
-
id: string;
|
|
178
|
-
name: string;
|
|
179
|
-
scope: KnowledgeScope;
|
|
180
|
-
rung: 'org' | 'resource' | 'thread';
|
|
181
|
-
}>;
|
|
182
|
-
/** Unique unknown names skipped once the fallback-lookup cap was hit. */
|
|
183
|
-
unresolvedCapped: {
|
|
184
|
-
count: number;
|
|
185
|
-
names: string[];
|
|
186
|
-
};
|
|
187
|
-
/** Pin counts per rung of the active view (thread is null in the default view). */
|
|
188
|
-
pinCensus: {
|
|
189
|
-
resource: number;
|
|
190
|
-
thread: number | null;
|
|
191
|
-
};
|
|
192
|
-
/** Change hint: newest knowledge activity id (per-process monotonic — hint only). */
|
|
193
|
-
version: string | null;
|
|
194
|
-
}
|
|
195
|
-
export interface KnowledgeNodeRecordPayload {
|
|
196
|
-
id: string;
|
|
197
|
-
node: string;
|
|
198
|
-
/** 'owned' when the node is the record's parent, 'mentions' when it only wikilinks it. */
|
|
199
|
-
relation: 'owned' | 'mentions';
|
|
200
|
-
text: string;
|
|
201
|
-
scope: KnowledgeScope;
|
|
202
|
-
rung: 'org' | 'resource' | 'thread';
|
|
203
|
-
sourceThreadId: string;
|
|
204
|
-
capturedAt: string;
|
|
205
|
-
when?: string;
|
|
206
|
-
pinned: boolean;
|
|
207
|
-
metadata?: Record<string, unknown>;
|
|
208
|
-
}
|
|
209
|
-
export interface KnowledgeActivityPayload {
|
|
210
|
-
events: Array<{
|
|
211
|
-
id: string;
|
|
212
|
-
action: string;
|
|
213
|
-
recordType: string;
|
|
214
|
-
recordId?: string;
|
|
215
|
-
scope: KnowledgeScope;
|
|
216
|
-
node: {
|
|
217
|
-
id: string;
|
|
218
|
-
name: string;
|
|
219
|
-
rung: 'org' | 'resource' | 'thread';
|
|
220
|
-
threadId?: string;
|
|
221
|
-
};
|
|
222
|
-
createdAt: string;
|
|
223
|
-
}>;
|
|
224
|
-
nextCursor?: string;
|
|
225
|
-
/** The scope has more members than the activity filter reads; events for the rest are omitted. */
|
|
226
|
-
truncated?: true;
|
|
227
|
-
}
|
|
228
|
-
export interface KnowledgeNodePayload {
|
|
229
|
-
node: {
|
|
230
|
-
id: string;
|
|
231
|
-
name: string;
|
|
232
|
-
kind: string;
|
|
233
|
-
content: string;
|
|
234
|
-
description?: string;
|
|
235
|
-
scope: KnowledgeScope;
|
|
236
|
-
rung: 'org' | 'resource' | 'thread';
|
|
237
|
-
createdAt: string;
|
|
238
|
-
updatedAt: string;
|
|
239
|
-
};
|
|
240
|
-
records: KnowledgeNodeRecordPayload[];
|
|
241
26
|
}
|
|
242
27
|
export declare class KnowledgeRoutes extends Route<KnowledgeRoutesDeps> {
|
|
243
28
|
#private;
|
|
244
|
-
constructor(deps: KnowledgeRoutesDeps);
|
|
245
29
|
routes(): ApiRoute[];
|
|
246
30
|
}
|
|
247
31
|
//# sourceMappingURL=knowledge.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"knowledge.d.ts","sourceRoot":"","sources":["../../src/routes/knowledge.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"knowledge.d.ts","sourceRoot":"","sources":["../../src/routes/knowledge.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAwB,MAAM,wBAAwB,CAAC;AAU9E,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAMpD,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,qCAAqC,CAAC;AAClF,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AACpD,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAgBnC,MAAM,WAAW,mBAAoB,SAAQ,iBAAiB;IAC5D,6FAA6F;IAC7F,QAAQ,EAAE,sBAAsB,CAAC;IACjC,uFAAuF;IACvF,SAAS,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC,SAAS,GAAG,SAAS,CAAC,CAAC;IAC3D,gEAAgE;IAChE,mBAAmB,CAAC,EAAE,MAAM,CAAC;CAC9B;AA6DD,qBAAa,eAAgB,SAAQ,KAAK,CAAC,mBAAmB,CAAC;;IA8C7D,MAAM,IAAI,QAAQ,EAAE,CA2KnB;CACF"}
|