-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcairnline.go
More file actions
272 lines (235 loc) · 12.2 KB
/
Copy pathcairnline.go
File metadata and controls
272 lines (235 loc) · 12.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
// Package cairnline exposes the embeddable project coordination core.
//
// The root package is the public API intended for applications such as Hecate.
// Concrete storage internals remain in internal packages; NewMCPServer exposes
// the MCP protocol server so an embedding host can mount Cairnline's tool and
// resource surface on its own transport.
package cairnline
import (
"context"
"time"
"github.com/hecatehq/cairnline/internal/app"
"github.com/hecatehq/cairnline/internal/core"
"github.com/hecatehq/cairnline/internal/mcp"
"github.com/hecatehq/cairnline/internal/sqlitestore"
)
var (
ErrNotFound = core.ErrNotFound
ErrInvalid = core.ErrInvalid
ErrDuplicate = core.ErrDuplicate
ErrConflict = core.ErrConflict
)
type Store = core.Store
type Service = core.Service
type ServiceOption = core.ServiceOption
type MemoryStore = core.MemoryStore
type SQLiteStore = sqlitestore.Store
type Project = core.Project
type Root = core.Root
type Source = core.Source
type ProjectSkill = core.ProjectSkill
type RequiredPermissions = core.RequiredPermissions
type Role = core.Role
type WorkItem = core.WorkItem
type WorkItemCloseoutReadiness = core.WorkItemCloseoutReadiness
type ProjectSetupReadiness = core.ProjectSetupReadiness
type ProjectSetupReadinessSummary = core.ProjectSetupReadinessSummary
type ProjectSetupReadinessCheck = core.ProjectSetupReadinessCheck
type ProjectSetupReadinessAction = core.ProjectSetupReadinessAction
type ProjectHealth = core.ProjectHealth
type ProjectHealthSummary = core.ProjectHealthSummary
type ProjectHealthAttentionItem = core.ProjectHealthAttentionItem
type AssistantProposal = core.AssistantProposal
type AssistantProposalRecord = core.AssistantProposalRecord
type AssistantApplyAttempt = core.AssistantApplyAttempt
type AssistantAction = core.AssistantAction
type AssistantTarget = core.AssistantTarget
type AssistantApplyResult = core.AssistantApplyResult
type AssistantActionResult = core.AssistantActionResult
type ProjectOperationsBrief = core.ProjectOperationsBrief
type ProjectOperationsCounts = core.ProjectOperationsCounts
type ProjectOperationItem = core.ProjectOperationItem
type ProjectActivity = core.ProjectActivity
type ProjectActivityCounts = core.ProjectActivityCounts
type ProjectActivityBuckets = core.ProjectActivityBuckets
type ProjectActivityItem = core.ProjectActivityItem
type ReviewFollowUpReadiness = core.ReviewFollowUpReadiness
type DesiredAgent = core.DesiredAgent
type ExecutionRef = core.ExecutionRef
type Assignment = core.Assignment
type AssignmentClaimLease = core.AssignmentClaimLease
type AssignmentCoordination = core.AssignmentCoordination
type QueuedAssignmentUpdate = core.QueuedAssignmentUpdate
type AssignmentPreparation = core.AssignmentPreparation
type AssignmentCompatibilityFilter = core.AssignmentCompatibilityFilter
type AssignmentContext = core.AssignmentContext
type AssignmentLaunchPacket = core.AssignmentLaunchPacket
type Artifact = core.Artifact
type Evidence = core.Evidence
type Review = core.Review
type Handoff = core.Handoff
type HandoffPatch = core.HandoffPatch
type HandoffUpdate = core.HandoffUpdate
type HandoffStatusUpdate = core.HandoffStatusUpdate
type HandoffDelete = core.HandoffDelete
type AcceptHandoffWithFollowUpCommand = core.AcceptHandoffWithFollowUpCommand
type HandoffFollowUpResult = core.HandoffFollowUpResult
type MemoryEntry = core.MemoryEntry
type MemoryCandidate = core.MemoryCandidate
type MemoryCandidateSourceRef = core.MemoryCandidateSourceRef
type MemoryCandidateFilter = core.MemoryCandidateFilter
type MemoryCandidatePromotion = core.MemoryCandidatePromotion
type Snapshot = core.Snapshot
const (
SnapshotVersion = core.SnapshotVersion
DefaultAssignmentClaimLeaseTTL = core.DefaultAssignmentClaimLeaseTTL
WorkStatusReady = core.WorkStatusReady
WorkStatusDone = core.WorkStatusDone
PriorityNormal = core.PriorityNormal
ExecutionManual = core.ExecutionManual
ExecutionMCPPull = core.ExecutionMCPPull
ExecutionExternalAdapter = core.ExecutionExternalAdapter
ExecutionOrchestrated = core.ExecutionOrchestrated
AssignmentQueued = core.AssignmentQueued
AssignmentClaimed = core.AssignmentClaimed
AssignmentRunning = core.AssignmentRunning
AssignmentAwaitingApproval = core.AssignmentAwaitingApproval
AssignmentReview = core.AssignmentReview
AssignmentCompleted = core.AssignmentCompleted
AssignmentFailed = core.AssignmentFailed
AssignmentCancelled = core.AssignmentCancelled
DesiredAgentAny = core.DesiredAgentAny
HandoffFollowUpIntentAcceptAndEnsure = core.HandoffFollowUpIntentAcceptAndEnsure
HandoffFollowUpCreated = core.HandoffFollowUpCreated
HandoffFollowUpLinkedExisting = core.HandoffFollowUpLinkedExisting
HandoffFollowUpAlreadySatisfied = core.HandoffFollowUpAlreadySatisfied
SkillFormatMarkdown = core.SkillFormatMarkdown
SkillStatusAvailable = core.SkillStatusAvailable
SkillStatusMissing = core.SkillStatusMissing
SkillStatusInvalid = core.SkillStatusInvalid
SkillStatusConflict = core.SkillStatusConflict
SkillTrustWorkspace = core.SkillTrustWorkspace
SkillPathAgents = core.SkillPathAgents
SkillPathHecate = core.SkillPathHecate
SkillPathCairnline = core.SkillPathCairnline
SkillPathClaude = core.SkillPathClaude
SkillPathGemini = core.SkillPathGemini
EvidenceTrustOperator = core.EvidenceTrustOperator
ReviewVerdictApproved = core.ReviewVerdictApproved
ReviewVerdictChangesRequested = core.ReviewVerdictChangesRequested
ReviewVerdictBlocked = core.ReviewVerdictBlocked
ReviewVerdictRisk = core.ReviewVerdictRisk
ReviewVerdictPass = core.ReviewVerdictPass
ReviewVerdictConcerns = core.ReviewVerdictConcerns
ReviewRiskLow = core.ReviewRiskLow
ReviewRiskMedium = core.ReviewRiskMedium
ReviewRiskHigh = core.ReviewRiskHigh
ReviewRiskUnknown = core.ReviewRiskUnknown
ReviewStatusRecorded = core.ReviewStatusRecorded
HandoffStatusOpen = core.HandoffStatusOpen
HandoffStatusAccepted = core.HandoffStatusAccepted
HandoffStatusSuperseded = core.HandoffStatusSuperseded
HandoffStatusDismissed = core.HandoffStatusDismissed
MemoryTrustOperator = core.MemoryTrustOperator
MemoryTrustGenerated = core.MemoryTrustGenerated
MemorySourceOperator = core.MemorySourceOperator
MemorySourceGenerated = core.MemorySourceGenerated
MemoryCandidatePending = core.MemoryCandidatePending
MemoryCandidatePromoted = core.MemoryCandidatePromoted
MemoryCandidateRejected = core.MemoryCandidateRejected
MemoryCandidateProposed = core.MemoryCandidateProposed
ProjectOperationsStatusClear = core.ProjectOperationsStatusClear
ProjectOperationsStatusAttention = core.ProjectOperationsStatusAttention
ProjectSetupStatusReady = core.ProjectSetupStatusReady
ProjectSetupStatusTodo = core.ProjectSetupStatusTodo
ProjectSetupStatusOptional = core.ProjectSetupStatusOptional
ProjectSetupActionSetupProject = core.ProjectSetupActionSetupProject
ProjectSetupActionCreateWorkItem = core.ProjectSetupActionCreateWorkItem
ProjectSetupActionUpdateProject = core.ProjectSetupActionUpdateProject
ProjectSetupActionManageContext = core.ProjectSetupActionManageContext
ProjectSetupActionManageRoles = core.ProjectSetupActionManageRoles
ProjectHealthStatusClear = core.ProjectHealthStatusClear
ProjectHealthStatusAttention = core.ProjectHealthStatusAttention
AssistantProposalSourceAPI = core.AssistantProposalSourceAPI
AssistantProposalSourceAssistant = core.AssistantProposalSourceAssistant
AssistantProposalStatusProposed = core.AssistantProposalStatusProposed
AssistantProposalStatusNeedsConfirm = core.AssistantProposalStatusNeedsConfirm
AssistantProposalStatusApplied = core.AssistantProposalStatusApplied
AssistantProposalStatusPartial = core.AssistantProposalStatusPartial
AssistantProposalStatusRejected = core.AssistantProposalStatusRejected
AssistantActionCreateProject = core.AssistantActionCreateProject
AssistantActionUpdateProject = core.AssistantActionUpdateProject
AssistantActionAttachProjectRoot = core.AssistantActionAttachProjectRoot
AssistantActionRemoveProjectRoot = core.AssistantActionRemoveProjectRoot
AssistantActionSetProjectDefaults = core.AssistantActionSetProjectDefaults
AssistantActionCreateRole = core.AssistantActionCreateRole
AssistantActionUpdateRole = core.AssistantActionUpdateRole
AssistantActionCreateWorkItem = core.AssistantActionCreateWorkItem
AssistantActionUpdateWorkItem = core.AssistantActionUpdateWorkItem
AssistantActionCreateAssignment = core.AssistantActionCreateAssignment
AssistantActionCreateEvidence = core.AssistantActionCreateEvidence
AssistantActionCreateReview = core.AssistantActionCreateReview
AssistantActionCreateHandoff = core.AssistantActionCreateHandoff
AssistantActionUpdateHandoff = core.AssistantActionUpdateHandoff
AssistantActionCreateMemoryCandidate = core.AssistantActionCreateMemoryCandidate
AssistantApplyStatusApplied = core.AssistantApplyStatusApplied
AssistantApplyStatusNeedsConfirm = core.AssistantApplyStatusNeedsConfirm
AssistantApplyStatusPartial = core.AssistantApplyStatusPartial
AssistantApplyStatusRejected = core.AssistantApplyStatusRejected
ProjectOperationKindAssignment = core.ProjectOperationKindAssignment
ProjectOperationKindCloseoutReady = core.ProjectOperationKindCloseoutReady
ProjectOperationKindHandoff = core.ProjectOperationKindHandoff
ProjectOperationKindMemoryCandidate = core.ProjectOperationKindMemoryCandidate
ProjectOperationKindMissingEvidence = core.ProjectOperationKindMissingEvidence
ProjectOperationKindReviewFollowUp = core.ProjectOperationKindReviewFollowUp
ProjectOperationKindProjectSetup = core.ProjectOperationKindProjectSetup
ProjectOperationKindSkill = core.ProjectOperationKindSkill
ProjectOperationKindWorkItem = core.ProjectOperationKindWorkItem
ProjectOperationActionRecoverClaim = core.ProjectOperationActionRecoverClaim
ProjectOperationSeverityBlocked = core.ProjectOperationSeverityBlocked
ProjectOperationSeverityAction = core.ProjectOperationSeverityAction
ProjectOperationSeverityActive = core.ProjectOperationSeverityActive
ProjectOperationSeverityReady = core.ProjectOperationSeverityReady
ProjectOperationSeverityInfo = core.ProjectOperationSeverityInfo
ProjectActivityBucketActive = core.ProjectActivityBucketActive
ProjectActivityBucketBlocked = core.ProjectActivityBucketBlocked
ProjectActivityBucketCompleted = core.ProjectActivityBucketCompleted
ProjectActivityBucketOther = core.ProjectActivityBucketOther
LaunchPacketKindAssignment = core.LaunchPacketKindAssignment
)
func NewService(store Store, options ...ServiceOption) *Service {
return core.NewService(store, options...)
}
// WithAssignmentClaimLeaseTTL configures the pre-start lease used by portable
// worker claims created through ClaimAssignmentWithLease and MCP. Positive
// values are rounded up to whole seconds with a one-second minimum.
func WithAssignmentClaimLeaseTTL(ttl time.Duration) ServiceOption {
return core.WithAssignmentClaimLeaseTTL(ttl)
}
func NewMemoryStore() *MemoryStore {
return core.NewMemoryStore()
}
func NewMemoryService() *Service {
return NewService(NewMemoryStore())
}
func OpenSQLiteStore(ctx context.Context, path string) (*SQLiteStore, error) {
return sqlitestore.Open(ctx, path)
}
func NewSQLiteService(ctx context.Context, path string) (*Service, *SQLiteStore, error) {
store, err := OpenSQLiteStore(ctx, path)
if err != nil {
return nil, nil, err
}
return NewService(store), store, nil
}
// MCPServer is the MCP protocol server that exposes Cairnline's coordination
// tools and resources. Build one with NewMCPServer, then mount it on a custom
// transport via HandleMessage or run the built-in stdio loop with Serve.
// DeclareExtension advertises optional protocol extensions during initialize.
type MCPServer = mcp.Server
// NewMCPServer builds an MCP server with Cairnline's full tool and resource set
// registered against service. version is reported in serverInfo and the
// coordination.capabilities tool.
func NewMCPServer(service *Service, version string) *MCPServer {
return app.NewServer(service, version)
}