@stoneforge/quarry 0.1.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/LICENSE +13 -0
- package/README.md +160 -0
- package/dist/api/index.d.ts +8 -0
- package/dist/api/index.d.ts.map +1 -0
- package/dist/api/index.js +8 -0
- package/dist/api/index.js.map +1 -0
- package/dist/api/quarry-api.d.ts +268 -0
- package/dist/api/quarry-api.d.ts.map +1 -0
- package/dist/api/quarry-api.js +3905 -0
- package/dist/api/quarry-api.js.map +1 -0
- package/dist/api/types.d.ts +1359 -0
- package/dist/api/types.d.ts.map +1 -0
- package/dist/api/types.js +204 -0
- package/dist/api/types.js.map +1 -0
- package/dist/bin/sf.d.ts +3 -0
- package/dist/bin/sf.d.ts.map +1 -0
- package/dist/bin/sf.js +9 -0
- package/dist/bin/sf.js.map +1 -0
- package/dist/cli/commands/admin.d.ts +11 -0
- package/dist/cli/commands/admin.d.ts.map +1 -0
- package/dist/cli/commands/admin.js +465 -0
- package/dist/cli/commands/admin.js.map +1 -0
- package/dist/cli/commands/alias.d.ts +8 -0
- package/dist/cli/commands/alias.d.ts.map +1 -0
- package/dist/cli/commands/alias.js +70 -0
- package/dist/cli/commands/alias.js.map +1 -0
- package/dist/cli/commands/channel.d.ts +13 -0
- package/dist/cli/commands/channel.d.ts.map +1 -0
- package/dist/cli/commands/channel.js +680 -0
- package/dist/cli/commands/channel.js.map +1 -0
- package/dist/cli/commands/completion.d.ts +8 -0
- package/dist/cli/commands/completion.d.ts.map +1 -0
- package/dist/cli/commands/completion.js +87 -0
- package/dist/cli/commands/completion.js.map +1 -0
- package/dist/cli/commands/config.d.ts +12 -0
- package/dist/cli/commands/config.d.ts.map +1 -0
- package/dist/cli/commands/config.js +242 -0
- package/dist/cli/commands/config.js.map +1 -0
- package/dist/cli/commands/crud.d.ts +64 -0
- package/dist/cli/commands/crud.d.ts.map +1 -0
- package/dist/cli/commands/crud.js +805 -0
- package/dist/cli/commands/crud.js.map +1 -0
- package/dist/cli/commands/dep.d.ts +16 -0
- package/dist/cli/commands/dep.d.ts.map +1 -0
- package/dist/cli/commands/dep.js +499 -0
- package/dist/cli/commands/dep.js.map +1 -0
- package/dist/cli/commands/document.d.ts +12 -0
- package/dist/cli/commands/document.d.ts.map +1 -0
- package/dist/cli/commands/document.js +1039 -0
- package/dist/cli/commands/document.js.map +1 -0
- package/dist/cli/commands/embeddings.d.ts +12 -0
- package/dist/cli/commands/embeddings.d.ts.map +1 -0
- package/dist/cli/commands/embeddings.js +273 -0
- package/dist/cli/commands/embeddings.js.map +1 -0
- package/dist/cli/commands/entity.d.ts +16 -0
- package/dist/cli/commands/entity.d.ts.map +1 -0
- package/dist/cli/commands/entity.js +522 -0
- package/dist/cli/commands/entity.js.map +1 -0
- package/dist/cli/commands/gc.d.ts +10 -0
- package/dist/cli/commands/gc.d.ts.map +1 -0
- package/dist/cli/commands/gc.js +257 -0
- package/dist/cli/commands/gc.js.map +1 -0
- package/dist/cli/commands/help.d.ts +11 -0
- package/dist/cli/commands/help.d.ts.map +1 -0
- package/dist/cli/commands/help.js +169 -0
- package/dist/cli/commands/help.js.map +1 -0
- package/dist/cli/commands/history.d.ts +9 -0
- package/dist/cli/commands/history.d.ts.map +1 -0
- package/dist/cli/commands/history.js +160 -0
- package/dist/cli/commands/history.js.map +1 -0
- package/dist/cli/commands/identity.d.ts +18 -0
- package/dist/cli/commands/identity.d.ts.map +1 -0
- package/dist/cli/commands/identity.js +698 -0
- package/dist/cli/commands/identity.js.map +1 -0
- package/dist/cli/commands/inbox.d.ts +20 -0
- package/dist/cli/commands/inbox.d.ts.map +1 -0
- package/dist/cli/commands/inbox.js +493 -0
- package/dist/cli/commands/inbox.js.map +1 -0
- package/dist/cli/commands/init.d.ts +20 -0
- package/dist/cli/commands/init.d.ts.map +1 -0
- package/dist/cli/commands/init.js +144 -0
- package/dist/cli/commands/init.js.map +1 -0
- package/dist/cli/commands/install.d.ts +9 -0
- package/dist/cli/commands/install.d.ts.map +1 -0
- package/dist/cli/commands/install.js +200 -0
- package/dist/cli/commands/install.js.map +1 -0
- package/dist/cli/commands/library.d.ts +12 -0
- package/dist/cli/commands/library.d.ts.map +1 -0
- package/dist/cli/commands/library.js +665 -0
- package/dist/cli/commands/library.js.map +1 -0
- package/dist/cli/commands/message.d.ts +11 -0
- package/dist/cli/commands/message.d.ts.map +1 -0
- package/dist/cli/commands/message.js +608 -0
- package/dist/cli/commands/message.js.map +1 -0
- package/dist/cli/commands/plan.d.ts +17 -0
- package/dist/cli/commands/plan.d.ts.map +1 -0
- package/dist/cli/commands/plan.js +698 -0
- package/dist/cli/commands/plan.js.map +1 -0
- package/dist/cli/commands/playbook.d.ts +12 -0
- package/dist/cli/commands/playbook.d.ts.map +1 -0
- package/dist/cli/commands/playbook.js +730 -0
- package/dist/cli/commands/playbook.js.map +1 -0
- package/dist/cli/commands/reset.d.ts +12 -0
- package/dist/cli/commands/reset.d.ts.map +1 -0
- package/dist/cli/commands/reset.js +306 -0
- package/dist/cli/commands/reset.js.map +1 -0
- package/dist/cli/commands/serve.d.ts +11 -0
- package/dist/cli/commands/serve.d.ts.map +1 -0
- package/dist/cli/commands/serve.js +106 -0
- package/dist/cli/commands/serve.js.map +1 -0
- package/dist/cli/commands/stats.d.ts +8 -0
- package/dist/cli/commands/stats.d.ts.map +1 -0
- package/dist/cli/commands/stats.js +82 -0
- package/dist/cli/commands/stats.js.map +1 -0
- package/dist/cli/commands/sync.d.ts +14 -0
- package/dist/cli/commands/sync.d.ts.map +1 -0
- package/dist/cli/commands/sync.js +370 -0
- package/dist/cli/commands/sync.js.map +1 -0
- package/dist/cli/commands/task.d.ts +25 -0
- package/dist/cli/commands/task.d.ts.map +1 -0
- package/dist/cli/commands/task.js +1153 -0
- package/dist/cli/commands/task.js.map +1 -0
- package/dist/cli/commands/team.d.ts +13 -0
- package/dist/cli/commands/team.d.ts.map +1 -0
- package/dist/cli/commands/team.js +471 -0
- package/dist/cli/commands/team.js.map +1 -0
- package/dist/cli/commands/workflow.d.ts +16 -0
- package/dist/cli/commands/workflow.d.ts.map +1 -0
- package/dist/cli/commands/workflow.js +753 -0
- package/dist/cli/commands/workflow.js.map +1 -0
- package/dist/cli/completion.d.ts +28 -0
- package/dist/cli/completion.d.ts.map +1 -0
- package/dist/cli/completion.js +295 -0
- package/dist/cli/completion.js.map +1 -0
- package/dist/cli/db.d.ts +38 -0
- package/dist/cli/db.d.ts.map +1 -0
- package/dist/cli/db.js +90 -0
- package/dist/cli/db.js.map +1 -0
- package/dist/cli/formatter.d.ts +87 -0
- package/dist/cli/formatter.d.ts.map +1 -0
- package/dist/cli/formatter.js +464 -0
- package/dist/cli/formatter.js.map +1 -0
- package/dist/cli/index.d.ts +33 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +38 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/cli/parser.d.ts +45 -0
- package/dist/cli/parser.d.ts.map +1 -0
- package/dist/cli/parser.js +256 -0
- package/dist/cli/parser.js.map +1 -0
- package/dist/cli/plugin-loader.d.ts +39 -0
- package/dist/cli/plugin-loader.d.ts.map +1 -0
- package/dist/cli/plugin-loader.js +165 -0
- package/dist/cli/plugin-loader.js.map +1 -0
- package/dist/cli/plugin-registry.d.ts +50 -0
- package/dist/cli/plugin-registry.d.ts.map +1 -0
- package/dist/cli/plugin-registry.js +206 -0
- package/dist/cli/plugin-registry.js.map +1 -0
- package/dist/cli/plugin-types.d.ts +106 -0
- package/dist/cli/plugin-types.d.ts.map +1 -0
- package/dist/cli/plugin-types.js +103 -0
- package/dist/cli/plugin-types.js.map +1 -0
- package/dist/cli/runner.d.ts +35 -0
- package/dist/cli/runner.d.ts.map +1 -0
- package/dist/cli/runner.js +340 -0
- package/dist/cli/runner.js.map +1 -0
- package/dist/cli/suggest.d.ts +15 -0
- package/dist/cli/suggest.d.ts.map +1 -0
- package/dist/cli/suggest.js +49 -0
- package/dist/cli/suggest.js.map +1 -0
- package/dist/cli/types.d.ts +138 -0
- package/dist/cli/types.d.ts.map +1 -0
- package/dist/cli/types.js +63 -0
- package/dist/cli/types.js.map +1 -0
- package/dist/config/config.d.ts +86 -0
- package/dist/config/config.d.ts.map +1 -0
- package/dist/config/config.js +348 -0
- package/dist/config/config.js.map +1 -0
- package/dist/config/defaults.d.ts +66 -0
- package/dist/config/defaults.d.ts.map +1 -0
- package/dist/config/defaults.js +114 -0
- package/dist/config/defaults.js.map +1 -0
- package/dist/config/duration.d.ts +75 -0
- package/dist/config/duration.d.ts.map +1 -0
- package/dist/config/duration.js +190 -0
- package/dist/config/duration.js.map +1 -0
- package/dist/config/env.d.ts +67 -0
- package/dist/config/env.d.ts.map +1 -0
- package/dist/config/env.js +207 -0
- package/dist/config/env.js.map +1 -0
- package/dist/config/file.d.ts +97 -0
- package/dist/config/file.d.ts.map +1 -0
- package/dist/config/file.js +365 -0
- package/dist/config/file.js.map +1 -0
- package/dist/config/index.d.ts +35 -0
- package/dist/config/index.d.ts.map +1 -0
- package/dist/config/index.js +41 -0
- package/dist/config/index.js.map +1 -0
- package/dist/config/merge.d.ts +53 -0
- package/dist/config/merge.d.ts.map +1 -0
- package/dist/config/merge.js +226 -0
- package/dist/config/merge.js.map +1 -0
- package/dist/config/types.d.ts +257 -0
- package/dist/config/types.d.ts.map +1 -0
- package/dist/config/types.js +72 -0
- package/dist/config/types.js.map +1 -0
- package/dist/config/validation.d.ts +55 -0
- package/dist/config/validation.d.ts.map +1 -0
- package/dist/config/validation.js +251 -0
- package/dist/config/validation.js.map +1 -0
- package/dist/http/index.d.ts +8 -0
- package/dist/http/index.d.ts.map +1 -0
- package/dist/http/index.js +12 -0
- package/dist/http/index.js.map +1 -0
- package/dist/http/sync-handlers.d.ts +162 -0
- package/dist/http/sync-handlers.d.ts.map +1 -0
- package/dist/http/sync-handlers.js +271 -0
- package/dist/http/sync-handlers.js.map +1 -0
- package/dist/index.d.ts +25 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +69 -0
- package/dist/index.js.map +1 -0
- package/dist/server/index.d.ts +34 -0
- package/dist/server/index.d.ts.map +1 -0
- package/dist/server/index.js +3329 -0
- package/dist/server/index.js.map +1 -0
- package/dist/server/static.d.ts +18 -0
- package/dist/server/static.d.ts.map +1 -0
- package/dist/server/static.js +71 -0
- package/dist/server/static.js.map +1 -0
- package/dist/server/ws/broadcaster.d.ts +8 -0
- package/dist/server/ws/broadcaster.d.ts.map +1 -0
- package/dist/server/ws/broadcaster.js +7 -0
- package/dist/server/ws/broadcaster.js.map +1 -0
- package/dist/server/ws/handler.d.ts +55 -0
- package/dist/server/ws/handler.d.ts.map +1 -0
- package/dist/server/ws/handler.js +160 -0
- package/dist/server/ws/handler.js.map +1 -0
- package/dist/services/blocked-cache.d.ts +297 -0
- package/dist/services/blocked-cache.d.ts.map +1 -0
- package/dist/services/blocked-cache.js +755 -0
- package/dist/services/blocked-cache.js.map +1 -0
- package/dist/services/dependency.d.ts +205 -0
- package/dist/services/dependency.d.ts.map +1 -0
- package/dist/services/dependency.js +566 -0
- package/dist/services/dependency.js.map +1 -0
- package/dist/services/embeddings/fusion.d.ts +33 -0
- package/dist/services/embeddings/fusion.d.ts.map +1 -0
- package/dist/services/embeddings/fusion.js +34 -0
- package/dist/services/embeddings/fusion.js.map +1 -0
- package/dist/services/embeddings/index.d.ts +12 -0
- package/dist/services/embeddings/index.d.ts.map +1 -0
- package/dist/services/embeddings/index.js +10 -0
- package/dist/services/embeddings/index.js.map +1 -0
- package/dist/services/embeddings/local-provider.d.ts +31 -0
- package/dist/services/embeddings/local-provider.d.ts.map +1 -0
- package/dist/services/embeddings/local-provider.js +80 -0
- package/dist/services/embeddings/local-provider.js.map +1 -0
- package/dist/services/embeddings/service.d.ts +76 -0
- package/dist/services/embeddings/service.d.ts.map +1 -0
- package/dist/services/embeddings/service.js +153 -0
- package/dist/services/embeddings/service.js.map +1 -0
- package/dist/services/embeddings/types.d.ts +70 -0
- package/dist/services/embeddings/types.d.ts.map +1 -0
- package/dist/services/embeddings/types.js +8 -0
- package/dist/services/embeddings/types.js.map +1 -0
- package/dist/services/id-length-cache.d.ts +156 -0
- package/dist/services/id-length-cache.d.ts.map +1 -0
- package/dist/services/id-length-cache.js +197 -0
- package/dist/services/id-length-cache.js.map +1 -0
- package/dist/services/inbox.d.ts +147 -0
- package/dist/services/inbox.d.ts.map +1 -0
- package/dist/services/inbox.js +428 -0
- package/dist/services/inbox.js.map +1 -0
- package/dist/services/index.d.ts +10 -0
- package/dist/services/index.d.ts.map +1 -0
- package/dist/services/index.js +10 -0
- package/dist/services/index.js.map +1 -0
- package/dist/services/priority-service.d.ts +145 -0
- package/dist/services/priority-service.d.ts.map +1 -0
- package/dist/services/priority-service.js +272 -0
- package/dist/services/priority-service.js.map +1 -0
- package/dist/services/search-utils.d.ts +47 -0
- package/dist/services/search-utils.d.ts.map +1 -0
- package/dist/services/search-utils.js +83 -0
- package/dist/services/search-utils.js.map +1 -0
- package/dist/sync/hash.d.ts +48 -0
- package/dist/sync/hash.d.ts.map +1 -0
- package/dist/sync/hash.js +136 -0
- package/dist/sync/hash.js.map +1 -0
- package/dist/sync/index.d.ts +11 -0
- package/dist/sync/index.d.ts.map +1 -0
- package/dist/sync/index.js +16 -0
- package/dist/sync/index.js.map +1 -0
- package/dist/sync/merge.d.ts +80 -0
- package/dist/sync/merge.d.ts.map +1 -0
- package/dist/sync/merge.js +310 -0
- package/dist/sync/merge.js.map +1 -0
- package/dist/sync/serialization.d.ts +132 -0
- package/dist/sync/serialization.d.ts.map +1 -0
- package/dist/sync/serialization.js +306 -0
- package/dist/sync/serialization.js.map +1 -0
- package/dist/sync/service.d.ts +102 -0
- package/dist/sync/service.d.ts.map +1 -0
- package/dist/sync/service.js +493 -0
- package/dist/sync/service.js.map +1 -0
- package/dist/sync/types.d.ts +275 -0
- package/dist/sync/types.d.ts.map +1 -0
- package/dist/sync/types.js +76 -0
- package/dist/sync/types.js.map +1 -0
- package/dist/systems/identity.d.ts +479 -0
- package/dist/systems/identity.d.ts.map +1 -0
- package/dist/systems/identity.js +817 -0
- package/dist/systems/identity.js.map +1 -0
- package/dist/systems/index.d.ts +8 -0
- package/dist/systems/index.d.ts.map +1 -0
- package/dist/systems/index.js +29 -0
- package/dist/systems/index.js.map +1 -0
- package/package.json +121 -0
- package/web/assets/charts-vendor-D1YcbGux.js +55 -0
- package/web/assets/dnd-vendor-DmxE-_ZH.js +5 -0
- package/web/assets/editor-vendor-BxraAWts.js +279 -0
- package/web/assets/index-B77vv208.js +341 -0
- package/web/assets/index-CF_XnVLh.css +1 -0
- package/web/assets/router-vendor-BCKpRBrB.js +41 -0
- package/web/assets/ui-vendor-DUahGnbT.js +45 -0
- package/web/assets/utils-vendor-CfYKiENT.js +813 -0
- package/web/favicon.ico +0 -0
- package/web/index.html +23 -0
- package/web/logo.png +0 -0
|
@@ -0,0 +1,1359 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Query API Type Definitions
|
|
3
|
+
*
|
|
4
|
+
* This module defines all types, interfaces, and filters for the Stoneforge Query API.
|
|
5
|
+
* The Query API provides the primary programmatic interface to Stoneforge, enabling
|
|
6
|
+
* CRUD operations, queries, dependency management, and system administration.
|
|
7
|
+
*/
|
|
8
|
+
import type { Element, ElementId, ElementType, EntityId, Timestamp, Task, TaskStatus, Priority, Complexity, TaskTypeValue, CreateTaskInput, Document, DocumentId, ContentType, DocumentCategory, DocumentStatus, Dependency, DependencyType, Event, EventFilter, PlanProgress, Message, MessageId, ChannelId, Team, WorkflowStatus } from '@stoneforge/core';
|
|
9
|
+
import type { EmbeddingService } from '../services/embeddings/service.js';
|
|
10
|
+
export type { PlanProgress };
|
|
11
|
+
/**
|
|
12
|
+
* Sort direction for query results
|
|
13
|
+
*/
|
|
14
|
+
export type SortDirection = 'asc' | 'desc';
|
|
15
|
+
/**
|
|
16
|
+
* Base pagination options for list queries
|
|
17
|
+
*/
|
|
18
|
+
export interface PaginationOptions {
|
|
19
|
+
/** Maximum number of results to return */
|
|
20
|
+
limit?: number;
|
|
21
|
+
/** Number of results to skip */
|
|
22
|
+
offset?: number;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Base sorting options for list queries
|
|
26
|
+
*/
|
|
27
|
+
export interface SortOptions {
|
|
28
|
+
/** Field to sort by */
|
|
29
|
+
orderBy?: string;
|
|
30
|
+
/** Sort direction */
|
|
31
|
+
orderDir?: SortDirection;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Base filter for all element queries.
|
|
35
|
+
* All filters are optional and are combined with AND logic.
|
|
36
|
+
*/
|
|
37
|
+
export interface ElementFilter extends PaginationOptions, SortOptions {
|
|
38
|
+
/** Filter by element type(s) */
|
|
39
|
+
type?: ElementType | ElementType[];
|
|
40
|
+
/** Must have ALL specified tags */
|
|
41
|
+
tags?: string[];
|
|
42
|
+
/** Must have ANY of the specified tags */
|
|
43
|
+
tagsAny?: string[];
|
|
44
|
+
/** Filter by creator */
|
|
45
|
+
createdBy?: EntityId;
|
|
46
|
+
/** Created after this timestamp (inclusive) */
|
|
47
|
+
createdAfter?: Timestamp;
|
|
48
|
+
/** Created before this timestamp (exclusive) */
|
|
49
|
+
createdBefore?: Timestamp;
|
|
50
|
+
/** Updated after this timestamp (inclusive) */
|
|
51
|
+
updatedAfter?: Timestamp;
|
|
52
|
+
/** Updated before this timestamp (exclusive) */
|
|
53
|
+
updatedBefore?: Timestamp;
|
|
54
|
+
/** Include soft-deleted elements (tombstones) */
|
|
55
|
+
includeDeleted?: boolean;
|
|
56
|
+
/** Hydration options for resolving document references */
|
|
57
|
+
hydrate?: HydrationOptions;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Extended filter for task queries.
|
|
61
|
+
* Includes all ElementFilter options plus task-specific filters.
|
|
62
|
+
*/
|
|
63
|
+
export interface TaskFilter extends ElementFilter {
|
|
64
|
+
/** Filter by status(es) */
|
|
65
|
+
status?: TaskStatus | TaskStatus[];
|
|
66
|
+
/** Filter by priority level(s) */
|
|
67
|
+
priority?: Priority | Priority[];
|
|
68
|
+
/** Filter by complexity level(s) */
|
|
69
|
+
complexity?: Complexity | Complexity[];
|
|
70
|
+
/** Filter by assignee */
|
|
71
|
+
assignee?: EntityId;
|
|
72
|
+
/** Filter by owner */
|
|
73
|
+
owner?: EntityId;
|
|
74
|
+
/** Filter by task type classification(s) */
|
|
75
|
+
taskType?: TaskTypeValue | TaskTypeValue[];
|
|
76
|
+
/** Filter tasks that have a deadline set */
|
|
77
|
+
hasDeadline?: boolean;
|
|
78
|
+
/** Filter tasks with deadline before this timestamp */
|
|
79
|
+
deadlineBefore?: Timestamp;
|
|
80
|
+
/**
|
|
81
|
+
* Include tasks belonging to ephemeral workflows.
|
|
82
|
+
* By default, tasks from ephemeral workflows are excluded from ready() queries.
|
|
83
|
+
*/
|
|
84
|
+
includeEphemeral?: boolean;
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Extended filter for document queries.
|
|
88
|
+
* Includes all ElementFilter options plus document-specific filters.
|
|
89
|
+
*/
|
|
90
|
+
export interface DocumentFilter extends ElementFilter {
|
|
91
|
+
/** Filter by content type(s) */
|
|
92
|
+
contentType?: ContentType | ContentType[];
|
|
93
|
+
/** Filter by exact version number */
|
|
94
|
+
version?: number;
|
|
95
|
+
/** Filter by minimum version (inclusive) */
|
|
96
|
+
minVersion?: number;
|
|
97
|
+
/** Filter by maximum version (inclusive) */
|
|
98
|
+
maxVersion?: number;
|
|
99
|
+
/** Filter by document category(ies) */
|
|
100
|
+
category?: DocumentCategory | DocumentCategory[];
|
|
101
|
+
/** Filter by document status(es) */
|
|
102
|
+
status?: DocumentStatus | DocumentStatus[];
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Options for FTS5 full-text search.
|
|
106
|
+
*/
|
|
107
|
+
export interface FTSSearchOptions {
|
|
108
|
+
/** Filter by document category(ies) */
|
|
109
|
+
category?: DocumentCategory | DocumentCategory[];
|
|
110
|
+
/** Filter by document status(es) (default: active only) */
|
|
111
|
+
status?: DocumentStatus | DocumentStatus[];
|
|
112
|
+
/** Hard cap on results before adaptive filtering. Default: 50 */
|
|
113
|
+
hardCap?: number;
|
|
114
|
+
/** Sensitivity for elbow detection (higher = more aggressive cutoff). Default: 1.5 */
|
|
115
|
+
elbowSensitivity?: number;
|
|
116
|
+
/** Minimum results to return. Default: 1 */
|
|
117
|
+
minResults?: number;
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* A single FTS search result with score and snippet.
|
|
121
|
+
*/
|
|
122
|
+
export interface FTSSearchResult {
|
|
123
|
+
/** The matched document */
|
|
124
|
+
document: Document;
|
|
125
|
+
/** BM25 relevance score (lower = more relevant in SQLite FTS5) */
|
|
126
|
+
score: number;
|
|
127
|
+
/** Highlighted snippet from content */
|
|
128
|
+
snippet: string;
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* Extended filter for message queries.
|
|
132
|
+
* Includes all ElementFilter options plus message-specific filters.
|
|
133
|
+
*/
|
|
134
|
+
export interface MessageFilter extends ElementFilter {
|
|
135
|
+
/** Filter by channel(s) */
|
|
136
|
+
channelId?: ChannelId | ChannelId[];
|
|
137
|
+
/** Filter by sender entity(ies) */
|
|
138
|
+
sender?: EntityId | EntityId[];
|
|
139
|
+
/** Filter by thread (null for root messages only, specific ID for thread replies) */
|
|
140
|
+
threadId?: MessageId | null;
|
|
141
|
+
/** Filter by presence of attachments */
|
|
142
|
+
hasAttachments?: boolean;
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Options for hydrating document references on elements.
|
|
146
|
+
* When enabled, the corresponding Ref field will be resolved
|
|
147
|
+
* and its content will be included in the hydrated result.
|
|
148
|
+
*/
|
|
149
|
+
export interface HydrationOptions {
|
|
150
|
+
/** Hydrate descriptionRef -> description */
|
|
151
|
+
description?: boolean;
|
|
152
|
+
/** Hydrate contentRef -> content */
|
|
153
|
+
content?: boolean;
|
|
154
|
+
/** Hydrate attachment references */
|
|
155
|
+
attachments?: boolean;
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* Options for get operations
|
|
159
|
+
*/
|
|
160
|
+
export interface GetOptions {
|
|
161
|
+
/** References to hydrate */
|
|
162
|
+
hydrate?: HydrationOptions;
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* A task that is blocked with details about why.
|
|
166
|
+
* Extends Task with blocking information.
|
|
167
|
+
*/
|
|
168
|
+
export interface BlockedTask extends Task {
|
|
169
|
+
/** ID of the element blocking this task */
|
|
170
|
+
blockedBy: ElementId;
|
|
171
|
+
/** Human-readable explanation of why this task is blocked */
|
|
172
|
+
blockReason: string;
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* Result of recording an approval
|
|
176
|
+
*/
|
|
177
|
+
export interface ApprovalResult {
|
|
178
|
+
/** Whether the operation succeeded */
|
|
179
|
+
success: boolean;
|
|
180
|
+
/** Current number of approvals */
|
|
181
|
+
currentCount: number;
|
|
182
|
+
/** Required number of approvals */
|
|
183
|
+
requiredCount: number;
|
|
184
|
+
/** Whether the gate is now satisfied */
|
|
185
|
+
satisfied: boolean;
|
|
186
|
+
}
|
|
187
|
+
/**
|
|
188
|
+
* A node in the dependency tree.
|
|
189
|
+
* Represents an element with its incoming and outgoing dependencies.
|
|
190
|
+
*/
|
|
191
|
+
export interface DependencyTreeNode<T extends Element = Element> {
|
|
192
|
+
/** The element at this node */
|
|
193
|
+
element: T;
|
|
194
|
+
/** Outgoing dependencies (elements this element depends on) */
|
|
195
|
+
dependencies: DependencyTreeNode[];
|
|
196
|
+
/** Incoming dependencies (elements that depend on this element) */
|
|
197
|
+
dependents: DependencyTreeNode[];
|
|
198
|
+
}
|
|
199
|
+
/**
|
|
200
|
+
* Complete dependency tree for an element.
|
|
201
|
+
* Contains the full graph of dependencies in both directions.
|
|
202
|
+
*/
|
|
203
|
+
export interface DependencyTree<T extends Element = Element> {
|
|
204
|
+
/** Root element of the tree */
|
|
205
|
+
root: DependencyTreeNode<T>;
|
|
206
|
+
/** Maximum depth traversed in dependencies direction */
|
|
207
|
+
dependencyDepth: number;
|
|
208
|
+
/** Maximum depth traversed in dependents direction */
|
|
209
|
+
dependentDepth: number;
|
|
210
|
+
/** Total number of nodes in the tree */
|
|
211
|
+
nodeCount: number;
|
|
212
|
+
}
|
|
213
|
+
/**
|
|
214
|
+
* Input for creating a new dependency via the API.
|
|
215
|
+
*/
|
|
216
|
+
export interface DependencyInput {
|
|
217
|
+
/** Element that is waiting/blocked */
|
|
218
|
+
blockedId: ElementId;
|
|
219
|
+
/** Element doing the blocking/being depended on */
|
|
220
|
+
blockerId: ElementId;
|
|
221
|
+
/** Type of dependency relationship */
|
|
222
|
+
type: DependencyType;
|
|
223
|
+
/** Type-specific metadata */
|
|
224
|
+
metadata?: Record<string, unknown>;
|
|
225
|
+
/** Actor creating the dependency (optional, falls back to blocked element's createdBy) */
|
|
226
|
+
actor?: EntityId;
|
|
227
|
+
}
|
|
228
|
+
/**
|
|
229
|
+
* Options for operations that support actor specification
|
|
230
|
+
*/
|
|
231
|
+
export interface OperationOptions {
|
|
232
|
+
/** Actor performing the operation (for audit trail) */
|
|
233
|
+
actor?: EntityId;
|
|
234
|
+
}
|
|
235
|
+
/**
|
|
236
|
+
* Options for update operations
|
|
237
|
+
*/
|
|
238
|
+
export interface UpdateOptions extends OperationOptions {
|
|
239
|
+
/**
|
|
240
|
+
* Expected updatedAt timestamp for optimistic concurrency control.
|
|
241
|
+
* If provided, the update will fail with CONFLICT error if the element's
|
|
242
|
+
* current updatedAt doesn't match this value, indicating another process
|
|
243
|
+
* modified the element since it was read.
|
|
244
|
+
*/
|
|
245
|
+
expectedUpdatedAt?: string;
|
|
246
|
+
}
|
|
247
|
+
/**
|
|
248
|
+
* Options for delete operations
|
|
249
|
+
*/
|
|
250
|
+
export interface DeleteOptions extends OperationOptions {
|
|
251
|
+
/** Reason for deletion (stored in audit trail) */
|
|
252
|
+
reason?: string;
|
|
253
|
+
}
|
|
254
|
+
/**
|
|
255
|
+
* Options for adding a task to a plan
|
|
256
|
+
*/
|
|
257
|
+
export interface AddTaskToPlanOptions extends OperationOptions {
|
|
258
|
+
/** Use hierarchical ID (el-planid.n) - only valid for newly created tasks */
|
|
259
|
+
useHierarchicalId?: boolean;
|
|
260
|
+
}
|
|
261
|
+
/**
|
|
262
|
+
* Options for creating a task within a plan
|
|
263
|
+
*/
|
|
264
|
+
export interface CreateTaskInPlanOptions extends OperationOptions {
|
|
265
|
+
/** Use hierarchical ID (el-planid.n) - default true */
|
|
266
|
+
useHierarchicalId?: boolean;
|
|
267
|
+
}
|
|
268
|
+
/**
|
|
269
|
+
* Options for bulk close operation
|
|
270
|
+
*/
|
|
271
|
+
export interface BulkCloseOptions extends OperationOptions {
|
|
272
|
+
/** Reason for closing all tasks */
|
|
273
|
+
closeReason?: string;
|
|
274
|
+
/** Only close tasks matching this filter */
|
|
275
|
+
filter?: TaskFilter;
|
|
276
|
+
}
|
|
277
|
+
/**
|
|
278
|
+
* Options for bulk defer operation
|
|
279
|
+
*/
|
|
280
|
+
export interface BulkDeferOptions extends OperationOptions {
|
|
281
|
+
/** Only defer tasks matching this filter */
|
|
282
|
+
filter?: TaskFilter;
|
|
283
|
+
}
|
|
284
|
+
/**
|
|
285
|
+
* Options for bulk reassign operation
|
|
286
|
+
*/
|
|
287
|
+
export interface BulkReassignOptions extends OperationOptions {
|
|
288
|
+
/** Only reassign tasks matching this filter */
|
|
289
|
+
filter?: TaskFilter;
|
|
290
|
+
}
|
|
291
|
+
/**
|
|
292
|
+
* Options for bulk tag operation
|
|
293
|
+
*/
|
|
294
|
+
export interface BulkTagOptions extends OperationOptions {
|
|
295
|
+
/** Tags to add to all tasks */
|
|
296
|
+
addTags?: string[];
|
|
297
|
+
/** Tags to remove from all tasks */
|
|
298
|
+
removeTags?: string[];
|
|
299
|
+
/** Only tag tasks matching this filter */
|
|
300
|
+
filter?: TaskFilter;
|
|
301
|
+
}
|
|
302
|
+
/**
|
|
303
|
+
* Result of a bulk operation on plan tasks
|
|
304
|
+
*/
|
|
305
|
+
export interface BulkOperationResult {
|
|
306
|
+
/** Number of tasks successfully updated */
|
|
307
|
+
updated: number;
|
|
308
|
+
/** Number of tasks skipped (didn't match filter or status) */
|
|
309
|
+
skipped: number;
|
|
310
|
+
/** IDs of tasks that were updated */
|
|
311
|
+
updatedIds: ElementId[];
|
|
312
|
+
/** IDs of tasks that were skipped */
|
|
313
|
+
skippedIds: ElementId[];
|
|
314
|
+
/** Errors encountered during the operation */
|
|
315
|
+
errors: Array<{
|
|
316
|
+
taskId: ElementId;
|
|
317
|
+
message: string;
|
|
318
|
+
}>;
|
|
319
|
+
}
|
|
320
|
+
/**
|
|
321
|
+
* Options for deleting a workflow
|
|
322
|
+
*/
|
|
323
|
+
export interface DeleteWorkflowOptions {
|
|
324
|
+
/** Actor performing the delete operation */
|
|
325
|
+
actor?: EntityId;
|
|
326
|
+
}
|
|
327
|
+
/**
|
|
328
|
+
* Result of deleting a workflow
|
|
329
|
+
*/
|
|
330
|
+
export interface DeleteWorkflowResult {
|
|
331
|
+
/** ID of the workflow that was deleted */
|
|
332
|
+
workflowId: ElementId;
|
|
333
|
+
/** Number of tasks that were deleted */
|
|
334
|
+
tasksDeleted: number;
|
|
335
|
+
/** Number of dependencies that were deleted */
|
|
336
|
+
dependenciesDeleted: number;
|
|
337
|
+
/** Whether the workflow was ephemeral */
|
|
338
|
+
wasEphemeral: boolean;
|
|
339
|
+
}
|
|
340
|
+
/**
|
|
341
|
+
* Options for garbage collection
|
|
342
|
+
*/
|
|
343
|
+
export interface GarbageCollectionOptions {
|
|
344
|
+
/** Maximum age in milliseconds for workflows to be eligible */
|
|
345
|
+
maxAgeMs: number;
|
|
346
|
+
/** Whether to run in dry-run mode (no actual deletion) */
|
|
347
|
+
dryRun?: boolean;
|
|
348
|
+
/** Maximum number of workflows to delete in one run */
|
|
349
|
+
limit?: number;
|
|
350
|
+
}
|
|
351
|
+
/**
|
|
352
|
+
* Result of garbage collection
|
|
353
|
+
*/
|
|
354
|
+
export interface GarbageCollectionResult {
|
|
355
|
+
/** Number of workflows that were deleted */
|
|
356
|
+
workflowsDeleted: number;
|
|
357
|
+
/** Number of tasks that were deleted */
|
|
358
|
+
tasksDeleted: number;
|
|
359
|
+
/** Number of dependencies that were deleted */
|
|
360
|
+
dependenciesDeleted: number;
|
|
361
|
+
/** IDs of workflows that were deleted */
|
|
362
|
+
deletedWorkflowIds: ElementId[];
|
|
363
|
+
}
|
|
364
|
+
/**
|
|
365
|
+
* Options for task garbage collection
|
|
366
|
+
*/
|
|
367
|
+
export interface TaskGarbageCollectionOptions {
|
|
368
|
+
/** Maximum age in milliseconds for tasks to be eligible (since closedAt/deletedAt) */
|
|
369
|
+
maxAgeMs: number;
|
|
370
|
+
/** Whether to run in dry-run mode (no actual deletion) */
|
|
371
|
+
dryRun?: boolean;
|
|
372
|
+
/** Maximum number of tasks to delete in one run */
|
|
373
|
+
limit?: number;
|
|
374
|
+
}
|
|
375
|
+
/**
|
|
376
|
+
* Result of task garbage collection
|
|
377
|
+
*/
|
|
378
|
+
export interface TaskGarbageCollectionResult {
|
|
379
|
+
/** Number of tasks that were deleted */
|
|
380
|
+
tasksDeleted: number;
|
|
381
|
+
/** Number of dependencies that were deleted */
|
|
382
|
+
dependenciesDeleted: number;
|
|
383
|
+
/** IDs of tasks that were deleted */
|
|
384
|
+
deletedTaskIds: ElementId[];
|
|
385
|
+
}
|
|
386
|
+
/**
|
|
387
|
+
* Extended filter for workflow queries.
|
|
388
|
+
* Includes all ElementFilter options plus workflow-specific filters.
|
|
389
|
+
*/
|
|
390
|
+
export interface WorkflowFilter extends ElementFilter {
|
|
391
|
+
/** Filter by status(es) */
|
|
392
|
+
status?: WorkflowStatus | WorkflowStatus[];
|
|
393
|
+
/** Filter by ephemeral state */
|
|
394
|
+
ephemeral?: boolean;
|
|
395
|
+
/** Filter by playbook ID */
|
|
396
|
+
playbookId?: string;
|
|
397
|
+
}
|
|
398
|
+
/**
|
|
399
|
+
* Progress metrics for a workflow
|
|
400
|
+
*/
|
|
401
|
+
export interface WorkflowProgress {
|
|
402
|
+
/** Workflow identifier */
|
|
403
|
+
workflowId: ElementId;
|
|
404
|
+
/** Total number of tasks in the workflow */
|
|
405
|
+
totalTasks: number;
|
|
406
|
+
/** Task counts by status */
|
|
407
|
+
statusCounts: Record<string, number>;
|
|
408
|
+
/** Completion percentage (0-100) */
|
|
409
|
+
completionPercentage: number;
|
|
410
|
+
/** Number of ready tasks */
|
|
411
|
+
readyTasks: number;
|
|
412
|
+
/** Number of blocked tasks */
|
|
413
|
+
blockedTasks: number;
|
|
414
|
+
}
|
|
415
|
+
/**
|
|
416
|
+
* Export format options
|
|
417
|
+
*/
|
|
418
|
+
export type ExportFormat = 'jsonl';
|
|
419
|
+
/**
|
|
420
|
+
* Options for exporting elements
|
|
421
|
+
*/
|
|
422
|
+
export interface ExportOptions {
|
|
423
|
+
/** Export format (default: jsonl) */
|
|
424
|
+
format?: ExportFormat;
|
|
425
|
+
/** Element types to export (default: all) */
|
|
426
|
+
types?: ElementType[];
|
|
427
|
+
/** Export only elements modified after this timestamp */
|
|
428
|
+
modifiedAfter?: Timestamp;
|
|
429
|
+
/** Include soft-deleted elements */
|
|
430
|
+
includeDeleted?: boolean;
|
|
431
|
+
/** Export dependencies */
|
|
432
|
+
includeDependencies?: boolean;
|
|
433
|
+
/** Export events */
|
|
434
|
+
includeEvents?: boolean;
|
|
435
|
+
/** Output file path (if not provided, returns string) */
|
|
436
|
+
outputPath?: string;
|
|
437
|
+
}
|
|
438
|
+
/**
|
|
439
|
+
* Options for importing elements
|
|
440
|
+
*/
|
|
441
|
+
export interface ImportOptions {
|
|
442
|
+
/** Input file path */
|
|
443
|
+
inputPath?: string;
|
|
444
|
+
/** Raw JSONL data (alternative to inputPath) */
|
|
445
|
+
data?: string;
|
|
446
|
+
/** How to handle conflicts */
|
|
447
|
+
conflictStrategy?: ConflictStrategy;
|
|
448
|
+
/** Whether to validate all data before importing */
|
|
449
|
+
validateFirst?: boolean;
|
|
450
|
+
/** Whether to run in dry-run mode (validate but don't import) */
|
|
451
|
+
dryRun?: boolean;
|
|
452
|
+
}
|
|
453
|
+
/**
|
|
454
|
+
* Strategy for handling import conflicts
|
|
455
|
+
*/
|
|
456
|
+
export type ConflictStrategy = 'skip' | 'overwrite' | 'error';
|
|
457
|
+
/**
|
|
458
|
+
* A conflict encountered during import
|
|
459
|
+
*/
|
|
460
|
+
export interface ImportConflict {
|
|
461
|
+
/** ID of the conflicting element */
|
|
462
|
+
elementId: ElementId;
|
|
463
|
+
/** Type of conflict */
|
|
464
|
+
conflictType: 'exists' | 'type_mismatch' | 'validation_failed';
|
|
465
|
+
/** Additional details about the conflict */
|
|
466
|
+
details: string;
|
|
467
|
+
}
|
|
468
|
+
/**
|
|
469
|
+
* Result of an import operation
|
|
470
|
+
*/
|
|
471
|
+
export interface ImportResult {
|
|
472
|
+
/** Whether the import succeeded */
|
|
473
|
+
success: boolean;
|
|
474
|
+
/** Number of elements imported */
|
|
475
|
+
elementsImported: number;
|
|
476
|
+
/** Number of dependencies imported */
|
|
477
|
+
dependenciesImported: number;
|
|
478
|
+
/** Number of events imported */
|
|
479
|
+
eventsImported: number;
|
|
480
|
+
/** Conflicts encountered */
|
|
481
|
+
conflicts: ImportConflict[];
|
|
482
|
+
/** Errors that occurred */
|
|
483
|
+
errors: string[];
|
|
484
|
+
/** Whether this was a dry run */
|
|
485
|
+
dryRun: boolean;
|
|
486
|
+
}
|
|
487
|
+
/**
|
|
488
|
+
* Count of elements by type
|
|
489
|
+
*/
|
|
490
|
+
export type ElementCountByType = {
|
|
491
|
+
[K in ElementType]?: number;
|
|
492
|
+
};
|
|
493
|
+
/**
|
|
494
|
+
* System-wide statistics
|
|
495
|
+
*/
|
|
496
|
+
export interface SystemStats {
|
|
497
|
+
/** Total number of elements */
|
|
498
|
+
totalElements: number;
|
|
499
|
+
/** Element count broken down by type */
|
|
500
|
+
elementsByType: ElementCountByType;
|
|
501
|
+
/** Total number of dependencies */
|
|
502
|
+
totalDependencies: number;
|
|
503
|
+
/** Total number of events */
|
|
504
|
+
totalEvents: number;
|
|
505
|
+
/** Number of tasks in ready state (open/in_progress, not blocked) */
|
|
506
|
+
readyTasks: number;
|
|
507
|
+
/** Number of blocked tasks */
|
|
508
|
+
blockedTasks: number;
|
|
509
|
+
/** Database file size in bytes */
|
|
510
|
+
databaseSize: number;
|
|
511
|
+
/** When stats were computed */
|
|
512
|
+
computedAt: Timestamp;
|
|
513
|
+
}
|
|
514
|
+
/**
|
|
515
|
+
* Paginated list result
|
|
516
|
+
*/
|
|
517
|
+
export interface ListResult<T> {
|
|
518
|
+
/** Items in this page */
|
|
519
|
+
items: T[];
|
|
520
|
+
/** Total count of matching items (before pagination) */
|
|
521
|
+
total: number;
|
|
522
|
+
/** Offset used for this page */
|
|
523
|
+
offset: number;
|
|
524
|
+
/** Limit used for this page */
|
|
525
|
+
limit: number;
|
|
526
|
+
/** Whether there are more results */
|
|
527
|
+
hasMore: boolean;
|
|
528
|
+
}
|
|
529
|
+
/**
|
|
530
|
+
* Result of point-in-time state reconstruction.
|
|
531
|
+
*/
|
|
532
|
+
export interface ReconstructedState<T extends Element = Element> {
|
|
533
|
+
/** The reconstructed element state at the target timestamp */
|
|
534
|
+
element: T;
|
|
535
|
+
/** The timestamp at which the state was reconstructed */
|
|
536
|
+
asOf: Timestamp;
|
|
537
|
+
/** Number of events applied to reconstruct this state */
|
|
538
|
+
eventsApplied: number;
|
|
539
|
+
/** Whether the element existed at this timestamp */
|
|
540
|
+
exists: boolean;
|
|
541
|
+
}
|
|
542
|
+
/**
|
|
543
|
+
* A snapshot in an element's history timeline.
|
|
544
|
+
*/
|
|
545
|
+
export interface TimelineSnapshot {
|
|
546
|
+
/** The event that caused this state change */
|
|
547
|
+
event: Event;
|
|
548
|
+
/** The element state after this event was applied */
|
|
549
|
+
state: Record<string, unknown> | null;
|
|
550
|
+
/** Human-readable description of the change */
|
|
551
|
+
summary: string;
|
|
552
|
+
}
|
|
553
|
+
/**
|
|
554
|
+
* Complete timeline of an element's history.
|
|
555
|
+
*/
|
|
556
|
+
export interface ElementTimeline {
|
|
557
|
+
/** The element ID */
|
|
558
|
+
elementId: ElementId;
|
|
559
|
+
/** The current state (or null if deleted) */
|
|
560
|
+
currentState: Element | null;
|
|
561
|
+
/** Timeline of all state changes (oldest first) */
|
|
562
|
+
snapshots: TimelineSnapshot[];
|
|
563
|
+
/** Total number of events in the element's history */
|
|
564
|
+
totalEvents: number;
|
|
565
|
+
}
|
|
566
|
+
/**
|
|
567
|
+
* Base input for creating any element.
|
|
568
|
+
* Type-specific create functions will extend this.
|
|
569
|
+
*/
|
|
570
|
+
export interface ElementInput {
|
|
571
|
+
/** Optional: Specific ID (if not provided, one will be generated) */
|
|
572
|
+
id?: ElementId;
|
|
573
|
+
/** Entity creating the element */
|
|
574
|
+
createdBy: EntityId;
|
|
575
|
+
/** Initial tags */
|
|
576
|
+
tags?: string[];
|
|
577
|
+
/** Initial metadata */
|
|
578
|
+
metadata?: Record<string, unknown>;
|
|
579
|
+
}
|
|
580
|
+
/**
|
|
581
|
+
* The main Stoneforge API interface.
|
|
582
|
+
*
|
|
583
|
+
* Provides type-safe CRUD operations, queries, dependency management,
|
|
584
|
+
* and system administration capabilities.
|
|
585
|
+
*
|
|
586
|
+
* @example
|
|
587
|
+
* ```typescript
|
|
588
|
+
* const api = createQuarryAPI(storage);
|
|
589
|
+
*
|
|
590
|
+
* // Get a task by ID
|
|
591
|
+
* const task = await api.get<Task>(taskId);
|
|
592
|
+
*
|
|
593
|
+
* // List open tasks
|
|
594
|
+
* const tasks = await api.list<Task>({ type: 'task', status: 'open' });
|
|
595
|
+
*
|
|
596
|
+
* // Get ready tasks
|
|
597
|
+
* const ready = await api.ready({ assignee: myEntityId });
|
|
598
|
+
* ```
|
|
599
|
+
*/
|
|
600
|
+
export interface QuarryAPI {
|
|
601
|
+
/**
|
|
602
|
+
* Retrieve a single element by ID.
|
|
603
|
+
*
|
|
604
|
+
* @param id - Element identifier
|
|
605
|
+
* @param options - Hydration options
|
|
606
|
+
* @returns The element or null if not found
|
|
607
|
+
*/
|
|
608
|
+
get<T extends Element>(id: ElementId, options?: GetOptions): Promise<T | null>;
|
|
609
|
+
/**
|
|
610
|
+
* Retrieve multiple elements matching a filter.
|
|
611
|
+
*
|
|
612
|
+
* @param filter - Query constraints
|
|
613
|
+
* @returns Array of matching elements
|
|
614
|
+
*/
|
|
615
|
+
list<T extends Element>(filter?: ElementFilter): Promise<T[]>;
|
|
616
|
+
/**
|
|
617
|
+
* Retrieve multiple elements with pagination info.
|
|
618
|
+
*
|
|
619
|
+
* @param filter - Query constraints
|
|
620
|
+
* @returns Paginated result with items and metadata
|
|
621
|
+
*/
|
|
622
|
+
listPaginated<T extends Element>(filter?: ElementFilter): Promise<ListResult<T>>;
|
|
623
|
+
/**
|
|
624
|
+
* Create a new element.
|
|
625
|
+
*
|
|
626
|
+
* @param input - Element data (type-specific)
|
|
627
|
+
* @returns The created element
|
|
628
|
+
*/
|
|
629
|
+
create<T extends Element>(input: ElementInput & Record<string, unknown>): Promise<T>;
|
|
630
|
+
/**
|
|
631
|
+
* Update an existing element.
|
|
632
|
+
*
|
|
633
|
+
* @param id - Element identifier
|
|
634
|
+
* @param updates - Fields to update
|
|
635
|
+
* @param options - Operation options including actor
|
|
636
|
+
* @returns The updated element
|
|
637
|
+
* @throws NotFoundError if element doesn't exist
|
|
638
|
+
* @throws ConstraintError if element is immutable (e.g., Message)
|
|
639
|
+
*/
|
|
640
|
+
update<T extends Element>(id: ElementId, updates: Partial<T>, options?: UpdateOptions): Promise<T>;
|
|
641
|
+
/**
|
|
642
|
+
* Soft-delete an element.
|
|
643
|
+
*
|
|
644
|
+
* @param id - Element identifier
|
|
645
|
+
* @param options - Delete options including reason and actor
|
|
646
|
+
* @throws NotFoundError if element doesn't exist
|
|
647
|
+
* @throws ConstraintError if element is immutable
|
|
648
|
+
*/
|
|
649
|
+
delete(id: ElementId, options?: DeleteOptions): Promise<void>;
|
|
650
|
+
/**
|
|
651
|
+
* Look up an entity by name.
|
|
652
|
+
*
|
|
653
|
+
* @param name - Entity name to look up
|
|
654
|
+
* @returns The entity if found, null otherwise
|
|
655
|
+
*/
|
|
656
|
+
lookupEntityByName(name: string): Promise<Element | null>;
|
|
657
|
+
/**
|
|
658
|
+
* Sets the manager (reportsTo) for an entity.
|
|
659
|
+
*
|
|
660
|
+
* @param entityId - The entity to set the manager for
|
|
661
|
+
* @param managerId - The manager entity ID
|
|
662
|
+
* @param actor - Entity performing this action (for audit trail)
|
|
663
|
+
* @returns The updated entity
|
|
664
|
+
* @throws NotFoundError if entity or manager doesn't exist
|
|
665
|
+
* @throws ValidationError if self-reference or manager is deactivated
|
|
666
|
+
* @throws ConflictError if circular chain would be created
|
|
667
|
+
*/
|
|
668
|
+
setEntityManager(entityId: EntityId, managerId: EntityId, actor: EntityId): Promise<Element>;
|
|
669
|
+
/**
|
|
670
|
+
* Clears the manager (reportsTo) for an entity.
|
|
671
|
+
*
|
|
672
|
+
* @param entityId - The entity to clear the manager for
|
|
673
|
+
* @param actor - Entity performing this action (for audit trail)
|
|
674
|
+
* @returns The updated entity
|
|
675
|
+
* @throws NotFoundError if entity doesn't exist
|
|
676
|
+
*/
|
|
677
|
+
clearEntityManager(entityId: EntityId, actor: EntityId): Promise<Element>;
|
|
678
|
+
/**
|
|
679
|
+
* Gets all entities that report directly to a manager.
|
|
680
|
+
*
|
|
681
|
+
* @param managerId - The manager entity ID
|
|
682
|
+
* @returns Array of entities that report to the manager
|
|
683
|
+
*/
|
|
684
|
+
getDirectReports(managerId: EntityId): Promise<Element[]>;
|
|
685
|
+
/**
|
|
686
|
+
* Gets the management chain for an entity (from entity up to root).
|
|
687
|
+
*
|
|
688
|
+
* @param entityId - The entity to get the management chain for
|
|
689
|
+
* @returns Array of entities in the management chain (empty if no manager)
|
|
690
|
+
* @throws NotFoundError if entity doesn't exist
|
|
691
|
+
*/
|
|
692
|
+
getManagementChain(entityId: EntityId): Promise<Element[]>;
|
|
693
|
+
/**
|
|
694
|
+
* Add an existing task to a plan.
|
|
695
|
+
* Creates a parent-child dependency from the task to the plan.
|
|
696
|
+
*
|
|
697
|
+
* @param taskId - The task to add
|
|
698
|
+
* @param planId - The plan to add the task to
|
|
699
|
+
* @param options - Operation options
|
|
700
|
+
* @returns The created dependency
|
|
701
|
+
* @throws NotFoundError if task or plan doesn't exist
|
|
702
|
+
* @throws ConstraintError if task is already in a plan
|
|
703
|
+
*/
|
|
704
|
+
addTaskToPlan(taskId: ElementId, planId: ElementId, options?: AddTaskToPlanOptions): Promise<Dependency>;
|
|
705
|
+
/**
|
|
706
|
+
* Remove a task from a plan.
|
|
707
|
+
* Removes the parent-child dependency.
|
|
708
|
+
*
|
|
709
|
+
* @param taskId - The task to remove
|
|
710
|
+
* @param planId - The plan to remove the task from
|
|
711
|
+
* @param actor - Optional actor for audit trail
|
|
712
|
+
* @throws NotFoundError if task-plan relationship doesn't exist
|
|
713
|
+
*/
|
|
714
|
+
removeTaskFromPlan(taskId: ElementId, planId: ElementId, actor?: EntityId): Promise<void>;
|
|
715
|
+
/**
|
|
716
|
+
* Get all tasks in a plan.
|
|
717
|
+
* Returns tasks with parent-child dependency to the plan.
|
|
718
|
+
*
|
|
719
|
+
* @param planId - The plan ID
|
|
720
|
+
* @param filter - Optional task filter constraints
|
|
721
|
+
* @returns Array of tasks in the plan
|
|
722
|
+
* @throws NotFoundError if plan doesn't exist
|
|
723
|
+
*/
|
|
724
|
+
getTasksInPlan(planId: ElementId, filter?: TaskFilter): Promise<Task[]>;
|
|
725
|
+
/**
|
|
726
|
+
* Get progress metrics for a plan.
|
|
727
|
+
* Computes task status counts and completion percentage.
|
|
728
|
+
*
|
|
729
|
+
* @param planId - The plan ID
|
|
730
|
+
* @returns Progress metrics for the plan
|
|
731
|
+
* @throws NotFoundError if plan doesn't exist
|
|
732
|
+
*/
|
|
733
|
+
getPlanProgress(planId: ElementId): Promise<PlanProgress>;
|
|
734
|
+
/**
|
|
735
|
+
* Create a new task directly in a plan.
|
|
736
|
+
* Automatically creates the task with a hierarchical ID and parent-child dependency.
|
|
737
|
+
*
|
|
738
|
+
* @param planId - The plan to create the task in
|
|
739
|
+
* @param taskInput - Task creation input (without ID - it will be generated)
|
|
740
|
+
* @param options - Operation options
|
|
741
|
+
* @returns The created task with hierarchical ID
|
|
742
|
+
* @throws NotFoundError if plan doesn't exist
|
|
743
|
+
* @throws ConstraintError if plan is not in draft or active status
|
|
744
|
+
*/
|
|
745
|
+
createTaskInPlan<T extends Task = Task>(planId: ElementId, taskInput: Omit<CreateTaskInput, 'id'>, options?: CreateTaskInPlanOptions): Promise<T>;
|
|
746
|
+
/**
|
|
747
|
+
* Close all tasks in a plan.
|
|
748
|
+
* Only closes tasks that are not already closed or tombstoned.
|
|
749
|
+
*
|
|
750
|
+
* @param planId - The plan containing the tasks
|
|
751
|
+
* @param options - Bulk operation options including optional filter and close reason
|
|
752
|
+
* @returns Result with counts of updated/skipped tasks
|
|
753
|
+
* @throws NotFoundError if plan doesn't exist
|
|
754
|
+
*/
|
|
755
|
+
bulkClosePlanTasks(planId: ElementId, options?: BulkCloseOptions): Promise<BulkOperationResult>;
|
|
756
|
+
/**
|
|
757
|
+
* Defer all tasks in a plan.
|
|
758
|
+
* Only defers tasks that are in open, in_progress, or blocked status.
|
|
759
|
+
*
|
|
760
|
+
* @param planId - The plan containing the tasks
|
|
761
|
+
* @param options - Bulk operation options including optional filter
|
|
762
|
+
* @returns Result with counts of updated/skipped tasks
|
|
763
|
+
* @throws NotFoundError if plan doesn't exist
|
|
764
|
+
*/
|
|
765
|
+
bulkDeferPlanTasks(planId: ElementId, options?: BulkDeferOptions): Promise<BulkOperationResult>;
|
|
766
|
+
/**
|
|
767
|
+
* Reassign all tasks in a plan to a new entity.
|
|
768
|
+
*
|
|
769
|
+
* @param planId - The plan containing the tasks
|
|
770
|
+
* @param newAssignee - The entity to assign all tasks to (undefined to unassign)
|
|
771
|
+
* @param options - Bulk operation options including optional filter
|
|
772
|
+
* @returns Result with counts of updated/skipped tasks
|
|
773
|
+
* @throws NotFoundError if plan doesn't exist
|
|
774
|
+
*/
|
|
775
|
+
bulkReassignPlanTasks(planId: ElementId, newAssignee: EntityId | undefined, options?: BulkReassignOptions): Promise<BulkOperationResult>;
|
|
776
|
+
/**
|
|
777
|
+
* Add or remove tags from all tasks in a plan.
|
|
778
|
+
*
|
|
779
|
+
* @param planId - The plan containing the tasks
|
|
780
|
+
* @param options - Options including tags to add/remove and optional filter
|
|
781
|
+
* @returns Result with counts of updated/skipped tasks
|
|
782
|
+
* @throws NotFoundError if plan doesn't exist
|
|
783
|
+
*/
|
|
784
|
+
bulkTagPlanTasks(planId: ElementId, options: BulkTagOptions): Promise<BulkOperationResult>;
|
|
785
|
+
/**
|
|
786
|
+
* Get tasks that are ready for work.
|
|
787
|
+
*
|
|
788
|
+
* Ready criteria:
|
|
789
|
+
* - Status is 'open' or 'in_progress'
|
|
790
|
+
* - Not blocked by any dependency
|
|
791
|
+
* - scheduledFor is null or in the past
|
|
792
|
+
* - Not ephemeral (unless includeEphemeral is true)
|
|
793
|
+
*
|
|
794
|
+
* @param filter - Optional task filter constraints
|
|
795
|
+
* @returns Array of ready tasks
|
|
796
|
+
*/
|
|
797
|
+
ready(filter?: TaskFilter): Promise<Task[]>;
|
|
798
|
+
/**
|
|
799
|
+
* Get tasks in backlog (not ready for work, needs triage)
|
|
800
|
+
*
|
|
801
|
+
* @param filter - Optional task filter constraints
|
|
802
|
+
* @returns Array of backlog tasks
|
|
803
|
+
*/
|
|
804
|
+
backlog(filter?: TaskFilter): Promise<Task[]>;
|
|
805
|
+
/**
|
|
806
|
+
* Get blocked tasks with blocking details.
|
|
807
|
+
*
|
|
808
|
+
* @param filter - Optional task filter constraints
|
|
809
|
+
* @returns Array of blocked tasks with block reasons
|
|
810
|
+
*/
|
|
811
|
+
blocked(filter?: TaskFilter): Promise<BlockedTask[]>;
|
|
812
|
+
/**
|
|
813
|
+
* Create a new dependency between elements.
|
|
814
|
+
*
|
|
815
|
+
* @param dep - Dependency data
|
|
816
|
+
* @returns The created dependency
|
|
817
|
+
* @throws NotFoundError if source element doesn't exist
|
|
818
|
+
* @throws ConflictError if dependency would create a cycle
|
|
819
|
+
* @throws ConflictError if dependency already exists
|
|
820
|
+
*/
|
|
821
|
+
addDependency(dep: DependencyInput): Promise<Dependency>;
|
|
822
|
+
/**
|
|
823
|
+
* Remove a dependency.
|
|
824
|
+
*
|
|
825
|
+
* @param blockedId - Blocked element
|
|
826
|
+
* @param blockerId - Blocker element
|
|
827
|
+
* @param type - Dependency type
|
|
828
|
+
* @param actor - Optional actor for the event (defaults to dependency creator)
|
|
829
|
+
* @throws NotFoundError if dependency doesn't exist
|
|
830
|
+
*/
|
|
831
|
+
removeDependency(blockedId: ElementId, blockerId: ElementId, type: DependencyType, actor?: EntityId): Promise<void>;
|
|
832
|
+
/**
|
|
833
|
+
* Get dependencies of an element (outgoing edges).
|
|
834
|
+
*
|
|
835
|
+
* @param id - Element ID
|
|
836
|
+
* @param types - Optional filter by dependency type(s)
|
|
837
|
+
* @returns Array of dependencies
|
|
838
|
+
*/
|
|
839
|
+
getDependencies(id: ElementId, types?: DependencyType[]): Promise<Dependency[]>;
|
|
840
|
+
/**
|
|
841
|
+
* Get dependents of an element (incoming edges).
|
|
842
|
+
*
|
|
843
|
+
* @param id - Element ID
|
|
844
|
+
* @param types - Optional filter by dependency type(s)
|
|
845
|
+
* @returns Array of dependencies where this element is the target
|
|
846
|
+
*/
|
|
847
|
+
getDependents(id: ElementId, types?: DependencyType[]): Promise<Dependency[]>;
|
|
848
|
+
/**
|
|
849
|
+
* Get the full dependency tree for an element.
|
|
850
|
+
*
|
|
851
|
+
* @param id - Root element ID
|
|
852
|
+
* @returns Complete dependency tree in both directions
|
|
853
|
+
*/
|
|
854
|
+
getDependencyTree(id: ElementId): Promise<DependencyTree>;
|
|
855
|
+
/**
|
|
856
|
+
* Mark an external or webhook gate as satisfied.
|
|
857
|
+
* Used to indicate that an external system or webhook has completed.
|
|
858
|
+
*
|
|
859
|
+
* @param blockedId - Element that has the awaits dependency
|
|
860
|
+
* @param blockerId - Blocker element ID of the awaits dependency
|
|
861
|
+
* @param actor - Entity marking the gate as satisfied
|
|
862
|
+
* @returns True if gate was found and satisfied, false if not found or wrong type
|
|
863
|
+
*/
|
|
864
|
+
satisfyGate(blockedId: ElementId, blockerId: ElementId, actor: EntityId): Promise<boolean>;
|
|
865
|
+
/**
|
|
866
|
+
* Record an approval for an approval gate.
|
|
867
|
+
* Updates the dependency metadata with the new approver.
|
|
868
|
+
*
|
|
869
|
+
* @param blockedId - Element that has the awaits dependency
|
|
870
|
+
* @param blockerId - Blocker element ID of the awaits dependency
|
|
871
|
+
* @param approver - Entity recording their approval
|
|
872
|
+
* @returns Result indicating success and current approval status
|
|
873
|
+
*/
|
|
874
|
+
recordApproval(blockedId: ElementId, blockerId: ElementId, approver: EntityId): Promise<ApprovalResult>;
|
|
875
|
+
/**
|
|
876
|
+
* Remove an approval from an approval gate.
|
|
877
|
+
*
|
|
878
|
+
* @param blockedId - Element that has the awaits dependency
|
|
879
|
+
* @param blockerId - Blocker element ID of the awaits dependency
|
|
880
|
+
* @param approver - Entity removing their approval
|
|
881
|
+
* @returns Result indicating success and current approval status
|
|
882
|
+
*/
|
|
883
|
+
removeApproval(blockedId: ElementId, blockerId: ElementId, approver: EntityId): Promise<ApprovalResult>;
|
|
884
|
+
/**
|
|
885
|
+
* Full-text search across elements.
|
|
886
|
+
*
|
|
887
|
+
* Searches:
|
|
888
|
+
* - Element titles (Tasks, Plans, etc.)
|
|
889
|
+
* - Element content (via Documents)
|
|
890
|
+
* - Tags
|
|
891
|
+
*
|
|
892
|
+
* @param query - Search text
|
|
893
|
+
* @param filter - Additional filter constraints
|
|
894
|
+
* @returns Array of matching elements
|
|
895
|
+
*/
|
|
896
|
+
search(query: string, filter?: ElementFilter): Promise<Element[]>;
|
|
897
|
+
/**
|
|
898
|
+
* Full-text search documents using FTS5 with adaptive top-K.
|
|
899
|
+
*
|
|
900
|
+
* Uses the FTS5 virtual table for BM25-ranked search with snippet generation.
|
|
901
|
+
* Applies adaptive elbow detection to return a natural number of results.
|
|
902
|
+
*
|
|
903
|
+
* @param query - Search query text
|
|
904
|
+
* @param options - Search options (category, status, limits, sensitivity)
|
|
905
|
+
* @returns Array of search results with scores and snippets
|
|
906
|
+
*/
|
|
907
|
+
searchDocumentsFTS(query: string, options?: FTSSearchOptions): Promise<FTSSearchResult[]>;
|
|
908
|
+
/**
|
|
909
|
+
* Archive a document (sets status to 'archived').
|
|
910
|
+
*
|
|
911
|
+
* @param id - Document ID
|
|
912
|
+
* @returns The updated document
|
|
913
|
+
* @throws NotFoundError if document doesn't exist or element is not a document
|
|
914
|
+
*/
|
|
915
|
+
archiveDocument(id: ElementId): Promise<Document>;
|
|
916
|
+
/**
|
|
917
|
+
* Unarchive a document (sets status back to 'active').
|
|
918
|
+
*
|
|
919
|
+
* @param id - Document ID
|
|
920
|
+
* @returns The updated document
|
|
921
|
+
* @throws NotFoundError if document doesn't exist or element is not a document
|
|
922
|
+
*/
|
|
923
|
+
unarchiveDocument(id: ElementId): Promise<Document>;
|
|
924
|
+
/**
|
|
925
|
+
* Register an EmbeddingService for automatic document embedding on create/update/delete.
|
|
926
|
+
* This is opt-in: embeddings are only generated when a service is registered.
|
|
927
|
+
*
|
|
928
|
+
* @param service - The embedding service to use for auto-indexing
|
|
929
|
+
*/
|
|
930
|
+
registerEmbeddingService(service: EmbeddingService): void;
|
|
931
|
+
/**
|
|
932
|
+
* Rebuild FTS index for all documents without creating version history entries.
|
|
933
|
+
* Use after import/sync or when search results seem stale.
|
|
934
|
+
*
|
|
935
|
+
* @returns Count of indexed documents and errors
|
|
936
|
+
*/
|
|
937
|
+
reindexAllDocumentsFTS(): {
|
|
938
|
+
indexed: number;
|
|
939
|
+
errors: number;
|
|
940
|
+
};
|
|
941
|
+
/**
|
|
942
|
+
* Get audit events for an element.
|
|
943
|
+
*
|
|
944
|
+
* @param id - Element ID
|
|
945
|
+
* @param filter - Optional event filter
|
|
946
|
+
* @returns Array of events (newest first)
|
|
947
|
+
*/
|
|
948
|
+
getEvents(id: ElementId, filter?: EventFilter): Promise<Event[]>;
|
|
949
|
+
/**
|
|
950
|
+
* List all events across all elements.
|
|
951
|
+
*
|
|
952
|
+
* @param filter - Optional event filter (including elementId filter, event types, actor, time range)
|
|
953
|
+
* @returns Array of events (newest first)
|
|
954
|
+
*/
|
|
955
|
+
listEvents(filter?: EventFilter): Promise<Event[]>;
|
|
956
|
+
/**
|
|
957
|
+
* Count events matching a filter.
|
|
958
|
+
*
|
|
959
|
+
* @param filter - Optional event filter (including elementId filter, event types, actor, time range)
|
|
960
|
+
* @returns Total count of matching events
|
|
961
|
+
*/
|
|
962
|
+
countEvents(filter?: EventFilter): Promise<number>;
|
|
963
|
+
/**
|
|
964
|
+
* Get a specific version of a document.
|
|
965
|
+
*
|
|
966
|
+
* @param id - Document ID
|
|
967
|
+
* @param version - Version number
|
|
968
|
+
* @returns The document at that version, or null if not found
|
|
969
|
+
*/
|
|
970
|
+
getDocumentVersion(id: DocumentId, version: number): Promise<Document | null>;
|
|
971
|
+
/**
|
|
972
|
+
* Get the full version history of a document.
|
|
973
|
+
*
|
|
974
|
+
* @param id - Document ID
|
|
975
|
+
* @returns Array of document versions (newest first)
|
|
976
|
+
*/
|
|
977
|
+
getDocumentHistory(id: DocumentId): Promise<Document[]>;
|
|
978
|
+
/**
|
|
979
|
+
* Reconstruct an element's state at a specific point in time.
|
|
980
|
+
*
|
|
981
|
+
* Algorithm:
|
|
982
|
+
* 1. Find the creation event for the element
|
|
983
|
+
* 2. Apply all events up to the target timestamp
|
|
984
|
+
* 3. Return the reconstructed state
|
|
985
|
+
*
|
|
986
|
+
* @param id - Element ID
|
|
987
|
+
* @param asOf - Target timestamp to reconstruct state at
|
|
988
|
+
* @returns Reconstructed state, or null if element didn't exist at that time
|
|
989
|
+
* @throws NotFoundError if element has no events (never existed)
|
|
990
|
+
*/
|
|
991
|
+
reconstructAtTime<T extends Element = Element>(id: ElementId, asOf: Timestamp): Promise<ReconstructedState<T> | null>;
|
|
992
|
+
/**
|
|
993
|
+
* Generate a complete timeline of an element's history.
|
|
994
|
+
*
|
|
995
|
+
* Shows the evolution of the element through all its events,
|
|
996
|
+
* with state snapshots after each event.
|
|
997
|
+
*
|
|
998
|
+
* @param id - Element ID
|
|
999
|
+
* @param filter - Optional event filter (e.g., limit to certain event types)
|
|
1000
|
+
* @returns Element timeline with snapshots
|
|
1001
|
+
* @throws NotFoundError if element has no events (never existed)
|
|
1002
|
+
*/
|
|
1003
|
+
getElementTimeline(id: ElementId, filter?: EventFilter): Promise<ElementTimeline>;
|
|
1004
|
+
/**
|
|
1005
|
+
* Find an existing direct channel between two entities, or create one if it doesn't exist.
|
|
1006
|
+
*
|
|
1007
|
+
* @param entityA - First entity
|
|
1008
|
+
* @param entityB - Second entity
|
|
1009
|
+
* @param actor - Actor performing the operation (must be one of the entities)
|
|
1010
|
+
* @returns The channel (existing or newly created) and whether it was created
|
|
1011
|
+
*/
|
|
1012
|
+
findOrCreateDirectChannel(entityA: EntityId, entityB: EntityId, actor: EntityId): Promise<FindOrCreateDirectChannelResult>;
|
|
1013
|
+
/**
|
|
1014
|
+
* Add a member to a channel.
|
|
1015
|
+
*
|
|
1016
|
+
* @param channelId - The channel to add the member to
|
|
1017
|
+
* @param entityId - The entity to add as a member
|
|
1018
|
+
* @param options - Operation options including actor
|
|
1019
|
+
* @returns The result of the operation
|
|
1020
|
+
* @throws NotFoundError if channel doesn't exist
|
|
1021
|
+
* @throws ConstraintError if channel is a direct channel (immutable membership)
|
|
1022
|
+
* @throws ConstraintError if actor doesn't have permission to modify members
|
|
1023
|
+
*/
|
|
1024
|
+
addChannelMember(channelId: ElementId, entityId: EntityId, options?: AddMemberOptions): Promise<MembershipResult>;
|
|
1025
|
+
/**
|
|
1026
|
+
* Remove a member from a channel.
|
|
1027
|
+
*
|
|
1028
|
+
* @param channelId - The channel to remove the member from
|
|
1029
|
+
* @param entityId - The entity to remove
|
|
1030
|
+
* @param options - Operation options including actor and reason
|
|
1031
|
+
* @returns The result of the operation
|
|
1032
|
+
* @throws NotFoundError if channel doesn't exist
|
|
1033
|
+
* @throws ConstraintError if channel is a direct channel (immutable membership)
|
|
1034
|
+
* @throws ConstraintError if actor doesn't have permission to modify members
|
|
1035
|
+
* @throws ConstraintError if entity is not a member
|
|
1036
|
+
*/
|
|
1037
|
+
removeChannelMember(channelId: ElementId, entityId: EntityId, options?: RemoveMemberOptions): Promise<MembershipResult>;
|
|
1038
|
+
/**
|
|
1039
|
+
* Leave a channel (remove self from members).
|
|
1040
|
+
*
|
|
1041
|
+
* @param channelId - The channel to leave
|
|
1042
|
+
* @param actor - The entity leaving the channel
|
|
1043
|
+
* @returns The result of the operation
|
|
1044
|
+
* @throws NotFoundError if channel doesn't exist
|
|
1045
|
+
* @throws ConstraintError if channel is a direct channel (cannot leave)
|
|
1046
|
+
* @throws ConstraintError if actor is not a member
|
|
1047
|
+
*/
|
|
1048
|
+
leaveChannel(channelId: ElementId, actor: EntityId): Promise<MembershipResult>;
|
|
1049
|
+
/**
|
|
1050
|
+
* Search for channels by name, with optional filtering.
|
|
1051
|
+
*
|
|
1052
|
+
* Searches channel names using pattern matching and allows filtering by
|
|
1053
|
+
* channel type, visibility, join policy, and membership.
|
|
1054
|
+
*
|
|
1055
|
+
* @param query - Search text to match against channel names
|
|
1056
|
+
* @param filter - Optional filter constraints (channelType, visibility, joinPolicy, member)
|
|
1057
|
+
* @returns Array of matching channels (up to 100 results, newest first)
|
|
1058
|
+
*/
|
|
1059
|
+
searchChannels(query: string, filter?: ChannelFilter): Promise<Channel[]>;
|
|
1060
|
+
/**
|
|
1061
|
+
* Merge two group channels: move all messages from source to target,
|
|
1062
|
+
* merge member lists, and archive the source channel.
|
|
1063
|
+
*/
|
|
1064
|
+
mergeChannels(sourceId: ElementId, targetId: ElementId, options?: {
|
|
1065
|
+
newName?: string;
|
|
1066
|
+
actor?: EntityId;
|
|
1067
|
+
}): Promise<{
|
|
1068
|
+
target: Channel;
|
|
1069
|
+
sourceArchived: boolean;
|
|
1070
|
+
messagesMoved: number;
|
|
1071
|
+
}>;
|
|
1072
|
+
/**
|
|
1073
|
+
* Add a member to a team with event recording.
|
|
1074
|
+
*
|
|
1075
|
+
* @param teamId - The team to add the member to
|
|
1076
|
+
* @param entityId - The entity to add as a member
|
|
1077
|
+
* @param options - Operation options including actor
|
|
1078
|
+
* @returns The result of the operation
|
|
1079
|
+
* @throws NotFoundError if team doesn't exist
|
|
1080
|
+
* @throws ConstraintError if team is deleted
|
|
1081
|
+
* @throws ConstraintError if entity is already a member
|
|
1082
|
+
*/
|
|
1083
|
+
addTeamMember(teamId: ElementId, entityId: EntityId, options?: AddMemberOptions): Promise<TeamMembershipResult>;
|
|
1084
|
+
/**
|
|
1085
|
+
* Remove a member from a team with event recording.
|
|
1086
|
+
*
|
|
1087
|
+
* @param teamId - The team to remove the member from
|
|
1088
|
+
* @param entityId - The entity to remove
|
|
1089
|
+
* @param options - Operation options including actor and reason
|
|
1090
|
+
* @returns The result of the operation
|
|
1091
|
+
* @throws NotFoundError if team doesn't exist
|
|
1092
|
+
* @throws ConstraintError if team is deleted
|
|
1093
|
+
* @throws ConstraintError if entity is not a member
|
|
1094
|
+
*/
|
|
1095
|
+
removeTeamMember(teamId: ElementId, entityId: EntityId, options?: RemoveMemberOptions): Promise<TeamMembershipResult>;
|
|
1096
|
+
/**
|
|
1097
|
+
* Get tasks assigned to a team or its members.
|
|
1098
|
+
*
|
|
1099
|
+
* @param teamId - The team identifier
|
|
1100
|
+
* @param options - Filter options
|
|
1101
|
+
* @returns Tasks assigned to the team or its members
|
|
1102
|
+
* @throws NotFoundError if team doesn't exist
|
|
1103
|
+
*/
|
|
1104
|
+
getTasksForTeam(teamId: ElementId, options?: TaskFilter): Promise<Task[]>;
|
|
1105
|
+
/**
|
|
1106
|
+
* Claim a team-assigned task for an individual member.
|
|
1107
|
+
* Updates the task's assignee from the team to the claiming entity.
|
|
1108
|
+
*
|
|
1109
|
+
* @param taskId - The task to claim
|
|
1110
|
+
* @param entityId - The entity claiming the task
|
|
1111
|
+
* @param options - Operation options including actor
|
|
1112
|
+
* @returns The updated task
|
|
1113
|
+
* @throws NotFoundError if task doesn't exist
|
|
1114
|
+
* @throws ConstraintError if task is not assigned to a team
|
|
1115
|
+
* @throws ConstraintError if entity is not a member of the team
|
|
1116
|
+
*/
|
|
1117
|
+
claimTaskFromTeam(taskId: ElementId, entityId: EntityId, options?: OperationOptions): Promise<Task>;
|
|
1118
|
+
/**
|
|
1119
|
+
* Get aggregated metrics for a team.
|
|
1120
|
+
*
|
|
1121
|
+
* @param teamId - The team identifier
|
|
1122
|
+
* @returns Team metrics
|
|
1123
|
+
* @throws NotFoundError if team doesn't exist
|
|
1124
|
+
*/
|
|
1125
|
+
getTeamMetrics(teamId: ElementId): Promise<TeamMetrics>;
|
|
1126
|
+
/**
|
|
1127
|
+
* Delete a workflow and all its child tasks.
|
|
1128
|
+
* This is a hard delete that removes the workflow, all its tasks, and their dependencies.
|
|
1129
|
+
*
|
|
1130
|
+
* @param workflowId - The workflow to delete
|
|
1131
|
+
* @param options - Operation options including actor
|
|
1132
|
+
* @returns Result with counts of deleted elements
|
|
1133
|
+
* @throws NotFoundError if workflow doesn't exist
|
|
1134
|
+
*/
|
|
1135
|
+
deleteWorkflow(workflowId: ElementId, options?: DeleteWorkflowOptions): Promise<DeleteWorkflowResult>;
|
|
1136
|
+
/**
|
|
1137
|
+
* Run garbage collection on ephemeral workflows.
|
|
1138
|
+
* Deletes ephemeral workflows that are in terminal state and older than maxAgeMs.
|
|
1139
|
+
*
|
|
1140
|
+
* @param options - GC configuration including maxAgeMs
|
|
1141
|
+
* @returns Result with counts of deleted elements
|
|
1142
|
+
*/
|
|
1143
|
+
garbageCollectWorkflows(options: GarbageCollectionOptions): Promise<GarbageCollectionResult>;
|
|
1144
|
+
/**
|
|
1145
|
+
* Garbage collect ephemeral tasks.
|
|
1146
|
+
* Deletes ephemeral tasks that are in terminal state (closed or tombstone) and older than maxAgeMs.
|
|
1147
|
+
* Only affects standalone ephemeral tasks - tasks belonging to workflows should be cleaned up via
|
|
1148
|
+
* garbageCollectWorkflows() instead.
|
|
1149
|
+
*
|
|
1150
|
+
* @param options - GC configuration including maxAgeMs
|
|
1151
|
+
* @returns Result with counts of deleted elements
|
|
1152
|
+
*/
|
|
1153
|
+
garbageCollectTasks(options: TaskGarbageCollectionOptions): Promise<TaskGarbageCollectionResult>;
|
|
1154
|
+
/**
|
|
1155
|
+
* Get all tasks in a workflow.
|
|
1156
|
+
* Returns tasks with parent-child dependency to the workflow.
|
|
1157
|
+
*
|
|
1158
|
+
* @param workflowId - The workflow ID
|
|
1159
|
+
* @param filter - Optional task filter constraints
|
|
1160
|
+
* @returns Array of tasks in the workflow
|
|
1161
|
+
* @throws NotFoundError if workflow doesn't exist
|
|
1162
|
+
*/
|
|
1163
|
+
getTasksInWorkflow(workflowId: ElementId, filter?: TaskFilter): Promise<Task[]>;
|
|
1164
|
+
/**
|
|
1165
|
+
* Get ready tasks in a workflow.
|
|
1166
|
+
* Returns tasks that are ready for work (open/in_progress, not blocked, not scheduled for future).
|
|
1167
|
+
*
|
|
1168
|
+
* @param workflowId - The workflow ID
|
|
1169
|
+
* @param filter - Optional task filter constraints
|
|
1170
|
+
* @returns Array of ready tasks in the workflow
|
|
1171
|
+
* @throws NotFoundError if workflow doesn't exist
|
|
1172
|
+
*/
|
|
1173
|
+
getReadyTasksInWorkflow(workflowId: ElementId, filter?: TaskFilter): Promise<Task[]>;
|
|
1174
|
+
/**
|
|
1175
|
+
* Get progress metrics for a workflow.
|
|
1176
|
+
* Computes task status counts and completion percentage.
|
|
1177
|
+
*
|
|
1178
|
+
* @param workflowId - The workflow ID
|
|
1179
|
+
* @returns Progress metrics for the workflow
|
|
1180
|
+
* @throws NotFoundError if workflow doesn't exist
|
|
1181
|
+
*/
|
|
1182
|
+
getWorkflowProgress(workflowId: ElementId): Promise<WorkflowProgress>;
|
|
1183
|
+
/**
|
|
1184
|
+
* Get tasks in a workflow ordered by execution order (topological sort).
|
|
1185
|
+
* Tasks are ordered such that blockers come before the tasks they block.
|
|
1186
|
+
* This represents the order in which tasks should be executed.
|
|
1187
|
+
*
|
|
1188
|
+
* @param workflowId - The workflow ID
|
|
1189
|
+
* @param filter - Optional task filter constraints
|
|
1190
|
+
* @returns Tasks in execution order (topological sort based on blocks dependencies)
|
|
1191
|
+
* @throws NotFoundError if workflow doesn't exist
|
|
1192
|
+
*/
|
|
1193
|
+
getOrderedTasksInWorkflow(workflowId: ElementId, filter?: TaskFilter): Promise<Task[]>;
|
|
1194
|
+
/**
|
|
1195
|
+
* Export elements to JSONL format.
|
|
1196
|
+
*
|
|
1197
|
+
* @param options - Export configuration
|
|
1198
|
+
* @returns JSONL string if no outputPath specified
|
|
1199
|
+
*/
|
|
1200
|
+
export(options?: ExportOptions): Promise<string | void>;
|
|
1201
|
+
/**
|
|
1202
|
+
* Import elements from JSONL format.
|
|
1203
|
+
*
|
|
1204
|
+
* @param options - Import configuration
|
|
1205
|
+
* @returns Import result with counts and any errors
|
|
1206
|
+
*/
|
|
1207
|
+
import(options: ImportOptions): Promise<ImportResult>;
|
|
1208
|
+
/**
|
|
1209
|
+
* Get system statistics.
|
|
1210
|
+
*
|
|
1211
|
+
* @returns Current system statistics
|
|
1212
|
+
*/
|
|
1213
|
+
stats(): Promise<SystemStats>;
|
|
1214
|
+
}
|
|
1215
|
+
/**
|
|
1216
|
+
* Check if a value is a valid SortDirection
|
|
1217
|
+
*/
|
|
1218
|
+
export declare function isSortDirection(value: unknown): value is SortDirection;
|
|
1219
|
+
/**
|
|
1220
|
+
* Check if a value is a valid ConflictStrategy
|
|
1221
|
+
*/
|
|
1222
|
+
export declare function isConflictStrategy(value: unknown): value is ConflictStrategy;
|
|
1223
|
+
/**
|
|
1224
|
+
* Check if a value is a valid ExportFormat
|
|
1225
|
+
*/
|
|
1226
|
+
export declare function isExportFormat(value: unknown): value is ExportFormat;
|
|
1227
|
+
/**
|
|
1228
|
+
* Validate an ElementFilter object
|
|
1229
|
+
*/
|
|
1230
|
+
export declare function isValidElementFilter(value: unknown): value is ElementFilter;
|
|
1231
|
+
/**
|
|
1232
|
+
* Validate a TaskFilter object
|
|
1233
|
+
*/
|
|
1234
|
+
export declare function isValidTaskFilter(value: unknown): value is TaskFilter;
|
|
1235
|
+
/**
|
|
1236
|
+
* Validate a DocumentFilter object
|
|
1237
|
+
*/
|
|
1238
|
+
export declare function isValidDocumentFilter(value: unknown): value is DocumentFilter;
|
|
1239
|
+
/**
|
|
1240
|
+
* Validate a GetOptions object
|
|
1241
|
+
*/
|
|
1242
|
+
export declare function isValidGetOptions(value: unknown): value is GetOptions;
|
|
1243
|
+
/**
|
|
1244
|
+
* Validate ExportOptions
|
|
1245
|
+
*/
|
|
1246
|
+
export declare function isValidExportOptions(value: unknown): value is ExportOptions;
|
|
1247
|
+
/**
|
|
1248
|
+
* Validate ImportOptions
|
|
1249
|
+
*/
|
|
1250
|
+
export declare function isValidImportOptions(value: unknown): value is ImportOptions;
|
|
1251
|
+
import type { Channel, ChannelType, Visibility, JoinPolicy } from '@stoneforge/core';
|
|
1252
|
+
/**
|
|
1253
|
+
* Filter for channel queries
|
|
1254
|
+
*/
|
|
1255
|
+
export interface ChannelFilter extends ElementFilter {
|
|
1256
|
+
/** Filter by channel type (direct or group) */
|
|
1257
|
+
channelType?: ChannelType;
|
|
1258
|
+
/** Filter by visibility */
|
|
1259
|
+
visibility?: Visibility;
|
|
1260
|
+
/** Filter by join policy */
|
|
1261
|
+
joinPolicy?: JoinPolicy;
|
|
1262
|
+
/** Filter channels containing a specific member */
|
|
1263
|
+
member?: EntityId;
|
|
1264
|
+
}
|
|
1265
|
+
/**
|
|
1266
|
+
* Options for adding a member to a channel
|
|
1267
|
+
*/
|
|
1268
|
+
export interface AddMemberOptions extends OperationOptions {
|
|
1269
|
+
}
|
|
1270
|
+
/**
|
|
1271
|
+
* Options for removing a member from a channel
|
|
1272
|
+
*/
|
|
1273
|
+
export interface RemoveMemberOptions extends OperationOptions {
|
|
1274
|
+
/** Reason for removal */
|
|
1275
|
+
reason?: string;
|
|
1276
|
+
}
|
|
1277
|
+
/**
|
|
1278
|
+
* Result of a channel membership operation
|
|
1279
|
+
*/
|
|
1280
|
+
export interface MembershipResult {
|
|
1281
|
+
/** Whether the operation succeeded */
|
|
1282
|
+
success: boolean;
|
|
1283
|
+
/** The updated channel */
|
|
1284
|
+
channel: Channel;
|
|
1285
|
+
/** The entity that was added/removed */
|
|
1286
|
+
entityId: EntityId;
|
|
1287
|
+
}
|
|
1288
|
+
/**
|
|
1289
|
+
* Result of find-or-create direct channel operation
|
|
1290
|
+
*/
|
|
1291
|
+
export interface FindOrCreateDirectChannelResult {
|
|
1292
|
+
/** The channel (existing or newly created) */
|
|
1293
|
+
channel: Channel;
|
|
1294
|
+
/** Whether a new channel was created */
|
|
1295
|
+
created: boolean;
|
|
1296
|
+
}
|
|
1297
|
+
/**
|
|
1298
|
+
* Input for sending a direct message
|
|
1299
|
+
*/
|
|
1300
|
+
export interface SendDirectMessageInput {
|
|
1301
|
+
/** The recipient entity ID */
|
|
1302
|
+
recipient: EntityId;
|
|
1303
|
+
/** Reference to content Document (must be created first) */
|
|
1304
|
+
contentRef: DocumentId;
|
|
1305
|
+
/** Optional: References to attachment Documents */
|
|
1306
|
+
attachments?: DocumentId[];
|
|
1307
|
+
/** Optional: tags */
|
|
1308
|
+
tags?: string[];
|
|
1309
|
+
/** Optional: metadata */
|
|
1310
|
+
metadata?: Record<string, unknown>;
|
|
1311
|
+
}
|
|
1312
|
+
/**
|
|
1313
|
+
* Result of sending a direct message
|
|
1314
|
+
*/
|
|
1315
|
+
export interface SendDirectMessageResult {
|
|
1316
|
+
/** The created message */
|
|
1317
|
+
message: Message;
|
|
1318
|
+
/** The channel used (existing or newly created) */
|
|
1319
|
+
channel: Channel;
|
|
1320
|
+
/** Whether a new channel was created for this message */
|
|
1321
|
+
channelCreated: boolean;
|
|
1322
|
+
}
|
|
1323
|
+
/**
|
|
1324
|
+
* Result of a team membership operation
|
|
1325
|
+
*/
|
|
1326
|
+
export interface TeamMembershipResult {
|
|
1327
|
+
/** Whether the operation succeeded */
|
|
1328
|
+
success: boolean;
|
|
1329
|
+
/** The updated team */
|
|
1330
|
+
team: Team;
|
|
1331
|
+
/** The entity that was added/removed */
|
|
1332
|
+
entityId: EntityId;
|
|
1333
|
+
}
|
|
1334
|
+
/**
|
|
1335
|
+
* Team metrics aggregation
|
|
1336
|
+
*/
|
|
1337
|
+
export interface TeamMetrics {
|
|
1338
|
+
/** Team identifier */
|
|
1339
|
+
teamId: ElementId;
|
|
1340
|
+
/** Number of tasks completed by team members */
|
|
1341
|
+
tasksCompleted: number;
|
|
1342
|
+
/** Number of tasks currently in progress */
|
|
1343
|
+
tasksInProgress: number;
|
|
1344
|
+
/** Number of tasks assigned to team or members */
|
|
1345
|
+
totalTasks: number;
|
|
1346
|
+
/** Tasks assigned directly to the team */
|
|
1347
|
+
tasksAssignedToTeam: number;
|
|
1348
|
+
/** Average time from task open to close (ms) */
|
|
1349
|
+
averageCycleTimeMs: number | null;
|
|
1350
|
+
}
|
|
1351
|
+
/** Default page size for list queries */
|
|
1352
|
+
export declare const DEFAULT_PAGE_SIZE = 10000;
|
|
1353
|
+
/** Maximum page size for list queries */
|
|
1354
|
+
export declare const MAX_PAGE_SIZE = 10000;
|
|
1355
|
+
/** Default conflict strategy for imports */
|
|
1356
|
+
export declare const DEFAULT_CONFLICT_STRATEGY: ConflictStrategy;
|
|
1357
|
+
/** Default export format */
|
|
1358
|
+
export declare const DEFAULT_EXPORT_FORMAT: ExportFormat;
|
|
1359
|
+
//# sourceMappingURL=types.d.ts.map
|