@lucern/sdk 0.3.0-alpha.1 → 0.3.0-alpha.11
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/CHANGELOG.md +3 -0
- package/README.md +51 -4
- package/dist/accessControl.d.ts +78 -0
- package/dist/accessControl.js +1118 -0
- package/dist/accessControl.js.map +1 -0
- package/dist/adminClient.d.ts +10 -8
- package/dist/adminClient.js +242 -39
- package/dist/adminClient.js.map +1 -1
- package/dist/answersClient.d.ts +2 -0
- package/dist/answersClient.js +221 -11
- package/dist/answersClient.js.map +1 -1
- package/dist/audience/index.d.ts +2 -1
- package/dist/audience/index.js +1 -3
- package/dist/audience/index.js.map +1 -1
- package/dist/audiencesClient.d.ts +18 -16
- package/dist/audiencesClient.js +297 -90
- package/dist/audiencesClient.js.map +1 -1
- package/dist/auditClient.d.ts +2 -0
- package/dist/auditClient.js +227 -15
- package/dist/auditClient.js.map +1 -1
- package/dist/authContext.d.ts +56 -0
- package/dist/authContext.js +170 -0
- package/dist/authContext.js.map +1 -0
- package/dist/authDeviceClient.d.ts +49 -0
- package/dist/authDeviceClient.js +121 -0
- package/dist/authDeviceClient.js.map +1 -0
- package/dist/beliefs/index.d.ts +26 -5
- package/dist/beliefs/index.js +3625 -1140
- package/dist/beliefs/index.js.map +1 -1
- package/dist/beliefsClient.d.ts +4 -2
- package/dist/beliefsClient.js +230 -26
- package/dist/beliefsClient.js.map +1 -1
- package/dist/boundaryClientSurface.d.ts +20 -0
- package/dist/boundaryClientSurface.js +73 -0
- package/dist/boundaryClientSurface.js.map +1 -0
- package/dist/client.d.ts +2988 -27
- package/dist/client.js +3625 -1140
- package/dist/client.js.map +1 -1
- package/dist/clientHelpers.d.ts +48 -0
- package/dist/clientHelpers.js +137 -0
- package/dist/clientHelpers.js.map +1 -0
- package/dist/contextClient.d.ts +6 -3
- package/dist/contextClient.js +252 -30
- package/dist/contextClient.js.map +1 -1
- package/dist/contextFacade.js +25 -16
- package/dist/contextFacade.js.map +1 -1
- package/dist/contextPackCompiler.js +19 -30
- package/dist/contextPackCompiler.js.map +1 -1
- package/dist/contextPackPolicy.js +7 -17
- package/dist/contextPackPolicy.js.map +1 -1
- package/dist/contextTypes.d.ts +2 -0
- package/dist/contracts/api-enums.contract.d.ts +2 -2
- package/dist/contracts/api-enums.contract.js +6 -1
- package/dist/contracts/api-enums.contract.js.map +1 -1
- package/dist/contracts/index.d.ts +1 -0
- package/dist/contracts/index.js +120 -5
- package/dist/contracts/index.js.map +1 -1
- package/dist/contracts/lens-filter.contract.js +4 -3
- package/dist/contracts/lens-filter.contract.js.map +1 -1
- package/dist/contracts/lens-workflow.contract.js +4 -3
- package/dist/contracts/lens-workflow.contract.js.map +1 -1
- package/dist/contracts/lensFilter.js +4 -3
- package/dist/contracts/lensFilter.js.map +1 -1
- package/dist/contracts/lensWorkflow.js +4 -3
- package/dist/contracts/lensWorkflow.js.map +1 -1
- package/dist/contracts/mcpTools.d.ts +46 -1
- package/dist/contracts/mcpTools.js +108 -0
- package/dist/contracts/mcpTools.js.map +1 -1
- package/dist/contradictions/index.d.ts +25 -4
- package/dist/contradictions/index.js +3625 -1140
- package/dist/contradictions/index.js.map +1 -1
- package/dist/coreClient.d.ts +11 -1
- package/dist/coreClient.js +222 -14
- package/dist/coreClient.js.map +1 -1
- package/dist/decisions/index.d.ts +35 -14
- package/dist/decisions/index.js +3625 -1140
- package/dist/decisions/index.js.map +1 -1
- package/dist/decisionsClient.d.ts +6 -12
- package/dist/decisionsClient.js +235 -37
- package/dist/decisionsClient.js.map +1 -1
- package/dist/edges/index.d.ts +48 -87
- package/dist/edges/index.js +3625 -1140
- package/dist/edges/index.js.map +1 -1
- package/dist/embeddingsClient.d.ts +106 -0
- package/dist/embeddingsClient.js +731 -0
- package/dist/embeddingsClient.js.map +1 -0
- package/dist/eventingClient.d.ts +96 -0
- package/dist/eventingClient.js +728 -0
- package/dist/eventingClient.js.map +1 -0
- package/dist/events.js +6 -3
- package/dist/events.js.map +1 -1
- package/dist/eventsCore.d.ts +3 -1
- package/dist/eventsCore.js +222 -14
- package/dist/eventsCore.js.map +1 -1
- package/dist/evidence/index.d.ts +25 -4
- package/dist/evidence/index.js +3625 -1140
- package/dist/evidence/index.js.map +1 -1
- package/dist/evidenceClient.d.ts +2 -0
- package/dist/evidenceClient.js +222 -14
- package/dist/evidenceClient.js.map +1 -1
- package/dist/facade/context.d.ts +2 -1
- package/dist/facade/context.js +25 -16
- package/dist/facade/context.js.map +1 -1
- package/dist/functionSurface.d.ts +143 -0
- package/dist/functionSurface.js +1204 -0
- package/dist/functionSurface.js.map +1 -0
- package/dist/functionSurfaceClient.d.ts +8 -0
- package/dist/functionSurfaceClient.js +1204 -0
- package/dist/functionSurfaceClient.js.map +1 -0
- package/dist/gatewayFacades.d.ts +64 -46
- package/dist/gatewayFacades.js +461 -128
- package/dist/gatewayFacades.js.map +1 -1
- package/dist/graphAnalysisClient.d.ts +192 -0
- package/dist/graphAnalysisClient.js +799 -0
- package/dist/graphAnalysisClient.js.map +1 -0
- package/dist/graphClient.d.ts +8 -13
- package/dist/graphClient.js +244 -45
- package/dist/graphClient.js.map +1 -1
- package/dist/graphIntel.d.ts +4 -0
- package/dist/graphIntel.js +3 -0
- package/dist/graphIntel.js.map +1 -0
- package/dist/graphIntelligence.d.ts +2 -0
- package/dist/graphIntelligence.js +47 -0
- package/dist/graphIntelligence.js.map +1 -0
- package/dist/graphRecommendationsClient.d.ts +56 -0
- package/dist/graphRecommendationsClient.js +664 -0
- package/dist/graphRecommendationsClient.js.map +1 -0
- package/dist/graphStateClassifierClient.d.ts +73 -0
- package/dist/graphStateClassifierClient.js +716 -0
- package/dist/graphStateClassifierClient.js.map +1 -0
- package/dist/harnessClient.d.ts +15 -24
- package/dist/harnessClient.js +235 -42
- package/dist/harnessClient.js.map +1 -1
- package/dist/identityClient.d.ts +97 -11
- package/dist/identityClient.js +409 -33
- package/dist/identityClient.js.map +1 -1
- package/dist/index.d.ts +30 -5
- package/dist/index.js +4272 -1225
- package/dist/index.js.map +1 -1
- package/dist/infisicalRuntime.d.ts +43 -0
- package/dist/infisicalRuntime.js +346 -0
- package/dist/infisicalRuntime.js.map +1 -0
- package/dist/jobsClient.d.ts +98 -0
- package/dist/jobsClient.js +726 -0
- package/dist/jobsClient.js.map +1 -0
- package/dist/learningClient.d.ts +8 -6
- package/dist/learningClient.js +252 -44
- package/dist/learningClient.js.map +1 -1
- package/dist/lenses/index.d.ts +77 -38
- package/dist/lenses/index.js +3625 -1140
- package/dist/lenses/index.js.map +1 -1
- package/dist/mcpClient.d.ts +28 -0
- package/dist/mcpClient.js +669 -0
- package/dist/mcpClient.js.map +1 -0
- package/dist/modelRuntimeClient.d.ts +72 -0
- package/dist/modelRuntimeClient.js +704 -0
- package/dist/modelRuntimeClient.js.map +1 -0
- package/dist/nodes/index.d.ts +64 -21
- package/dist/nodes/index.js +3625 -1140
- package/dist/nodes/index.js.map +1 -1
- package/dist/ontologies/index.d.ts +54 -32
- package/dist/ontologies/index.js +3625 -1140
- package/dist/ontologies/index.js.map +1 -1
- package/dist/ontologyClient.d.ts +19 -25
- package/dist/ontologyClient.js +258 -40
- package/dist/ontologyClient.js.map +1 -1
- package/dist/ontologyLinksClient.d.ts +71 -0
- package/dist/ontologyLinksClient.js +697 -0
- package/dist/ontologyLinksClient.js.map +1 -0
- package/dist/orgGraphSearchClient.d.ts +85 -0
- package/dist/orgGraphSearchClient.js +672 -0
- package/dist/orgGraphSearchClient.js.map +1 -0
- package/dist/packsClient.d.ts +11 -23
- package/dist/packsClient.js +234 -46
- package/dist/packsClient.js.map +1 -1
- package/dist/policyClient.d.ts +13 -10
- package/dist/policyClient.js +243 -25
- package/dist/policyClient.js.map +1 -1
- package/dist/questions/index.d.ts +25 -4
- package/dist/questions/index.js +3625 -1140
- package/dist/questions/index.js.map +1 -1
- package/dist/realtime/index.d.ts +1 -1
- package/dist/reportsClient.d.ts +9 -7
- package/dist/reportsClient.js +281 -53
- package/dist/reportsClient.js.map +1 -1
- package/dist/schemaClient.d.ts +5 -3
- package/dist/schemaClient.js +235 -29
- package/dist/schemaClient.js.map +1 -1
- package/dist/sdkSurface.d.ts +8 -3
- package/dist/sdkSurface.js +10 -6
- package/dist/sdkSurface.js.map +1 -1
- package/dist/secrets.d.ts +1 -0
- package/dist/secrets.js +3 -0
- package/dist/secrets.js.map +1 -0
- package/dist/sourcesClient.d.ts +2 -0
- package/dist/sourcesClient.js +222 -14
- package/dist/sourcesClient.js.map +1 -1
- package/dist/telemetryClient.d.ts +94 -0
- package/dist/telemetryClient.js +741 -0
- package/dist/telemetryClient.js.map +1 -0
- package/dist/toolRegistryClient.d.ts +115 -0
- package/dist/toolRegistryClient.js +767 -0
- package/dist/toolRegistryClient.js.map +1 -0
- package/dist/topics/index.d.ts +36 -9
- package/dist/topics/index.js +3627 -1140
- package/dist/topics/index.js.map +1 -1
- package/dist/topicsClient.d.ts +4 -0
- package/dist/topicsClient.js +237 -24
- package/dist/topicsClient.js.map +1 -1
- package/dist/types.d.ts +5 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/dist/version.js.map +1 -1
- package/dist/workflowClient.d.ts +58 -40
- package/dist/workflowClient.js +243 -58
- package/dist/workflowClient.js.map +1 -1
- package/dist/worktrees/index.d.ts +70 -33
- package/dist/worktrees/index.js +3625 -1140
- package/dist/worktrees/index.js.map +1 -1
- package/package.json +13 -3
- package/dist/client-B6aWUUwp.d.ts +0 -2552
package/dist/types.d.ts
CHANGED
|
@@ -473,6 +473,11 @@ type TopicRecord = {
|
|
|
473
473
|
topicId?: string;
|
|
474
474
|
id?: string;
|
|
475
475
|
globalId?: string;
|
|
476
|
+
topicGlobalId?: string;
|
|
477
|
+
epistemicNodeId?: string;
|
|
478
|
+
epistemicNodeGlobalId?: string;
|
|
479
|
+
parentEdgeId?: string;
|
|
480
|
+
parentEdgeGlobalId?: string;
|
|
476
481
|
name?: string;
|
|
477
482
|
description?: string;
|
|
478
483
|
type?: string;
|
package/dist/version.d.ts
CHANGED
package/dist/version.js
CHANGED
package/dist/version.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/version.ts"],"names":[],"mappings":";AACO,IAAM,kBAAA,GAAqB","file":"version.js","sourcesContent":["/** Current SDK package version. */\nexport const LUCERN_SDK_VERSION = \"0.
|
|
1
|
+
{"version":3,"sources":["../src/version.ts"],"names":[],"mappings":";AACO,IAAM,kBAAA,GAAqB","file":"version.js","sourcesContent":["/** Current SDK package version. */\nexport const LUCERN_SDK_VERSION = \"0.3.0-alpha.11\";\n"]}
|
package/dist/workflowClient.d.ts
CHANGED
|
@@ -4,6 +4,8 @@ import { TopicIdentifierInput, JsonObject, ListResult, WorkflowBranchRecord, Wor
|
|
|
4
4
|
export { AddWorktreeResponse, CreateBranchResponse, CreateLensResponse, LensTopicBindingResponse, ListBranchesResponse, ListLensesResponse } from './types.js';
|
|
5
5
|
import { LensPerspectiveType, LensStatus, LensPromptTemplateReference, LensWorkflowTemplate, LensTaskTemplate } from './contracts/lens-workflow.contract.js';
|
|
6
6
|
import { WorkflowProofArtifact, WorkflowStaffingHint, WorkflowAutoFixPolicy } from './contracts/workflow-runtime.contract.js';
|
|
7
|
+
import './authContext.js';
|
|
8
|
+
import './contracts/auth-session.contract.js';
|
|
7
9
|
import './contracts/lens-filter.contract.js';
|
|
8
10
|
|
|
9
11
|
/** Configuration for the workflow client. */
|
|
@@ -22,12 +24,49 @@ type WorkflowMergeOutcome = "validated" | "invalidated" | "forked" | "inconclusi
|
|
|
22
24
|
type AddWorktreeInput = {
|
|
23
25
|
title: string;
|
|
24
26
|
topicId?: string;
|
|
27
|
+
topicHint?: string;
|
|
25
28
|
branchId?: string;
|
|
26
29
|
objective?: string;
|
|
27
30
|
hypothesis?: string;
|
|
31
|
+
rationale?: string;
|
|
32
|
+
worktreeType?: string;
|
|
33
|
+
startDate?: number;
|
|
34
|
+
endDate?: number;
|
|
35
|
+
durationWeeks?: number;
|
|
36
|
+
confidenceImpact?: "high" | "medium" | "low";
|
|
37
|
+
beliefFocus?: string;
|
|
28
38
|
beliefIds?: string[];
|
|
39
|
+
targetBeliefIds?: string[];
|
|
40
|
+
targetQuestionIds?: string[];
|
|
41
|
+
keyQuestions?: Array<{
|
|
42
|
+
question: string;
|
|
43
|
+
status?: "open" | "answered" | "forked";
|
|
44
|
+
answer?: string;
|
|
45
|
+
answerConfidence?: "high" | "medium" | "low";
|
|
46
|
+
linkedQuestionId?: string;
|
|
47
|
+
}>;
|
|
48
|
+
evidenceSignals?: Array<{
|
|
49
|
+
signal: string;
|
|
50
|
+
collected?: boolean;
|
|
51
|
+
progress?: string;
|
|
52
|
+
notes?: string;
|
|
53
|
+
}>;
|
|
54
|
+
decisionGate?: {
|
|
55
|
+
goCriteria: string[];
|
|
56
|
+
noGoSignals: string[];
|
|
57
|
+
verdict?: "go" | "no_go" | "pivot" | "pending";
|
|
58
|
+
verdictRationale?: string;
|
|
59
|
+
decidedAt?: number;
|
|
60
|
+
decidedBy?: string;
|
|
61
|
+
};
|
|
62
|
+
goCriteria?: string[];
|
|
63
|
+
noGoSignals?: string[];
|
|
29
64
|
autoShape?: boolean;
|
|
30
65
|
domainPackId?: string;
|
|
66
|
+
tags?: string[];
|
|
67
|
+
touchedPaths?: string[];
|
|
68
|
+
sourceRef?: string;
|
|
69
|
+
sourceKind?: string;
|
|
31
70
|
campaign?: number;
|
|
32
71
|
lane?: string;
|
|
33
72
|
laneOrderInCampaign?: number;
|
|
@@ -39,14 +78,16 @@ type AddWorktreeInput = {
|
|
|
39
78
|
staffingHint?: WorkflowStaffingHint | string;
|
|
40
79
|
lastReconciledAt?: number;
|
|
41
80
|
autoFixPolicy?: WorkflowAutoFixPolicy;
|
|
81
|
+
lensId?: string;
|
|
42
82
|
} & TopicIdentifierInput;
|
|
43
|
-
|
|
83
|
+
type WorkflowMergeInputOutcome = string | {
|
|
84
|
+
beliefId: string;
|
|
85
|
+
confidence: number;
|
|
86
|
+
rationale: string;
|
|
87
|
+
};
|
|
88
|
+
/** Input for merging worktree findings with optional belief confidence outcomes. */
|
|
44
89
|
type MergeInput = {
|
|
45
|
-
outcomes:
|
|
46
|
-
beliefId: string;
|
|
47
|
-
confidence: number;
|
|
48
|
-
rationale: string;
|
|
49
|
-
}>;
|
|
90
|
+
outcomes: WorkflowMergeInputOutcome[];
|
|
50
91
|
summary?: string;
|
|
51
92
|
};
|
|
52
93
|
/** Input for updating the beliefs and questions tracked by a worktree. */
|
|
@@ -213,10 +254,6 @@ declare function createWorkflowClient(config?: WorkflowClientConfig): {
|
|
|
213
254
|
* Create a workflow worktree.
|
|
214
255
|
*/
|
|
215
256
|
createWorktree(input: AddWorktreeInput, idempotencyKey?: string): Promise<PlatformGatewaySuccess<WorkflowWorktreeRecord>>;
|
|
216
|
-
/**
|
|
217
|
-
* @deprecated Use createWorktree.
|
|
218
|
-
*/
|
|
219
|
-
addWorktree(input: AddWorktreeInput, idempotencyKey?: string): Promise<PlatformGatewaySuccess<WorkflowWorktreeRecord>>;
|
|
220
257
|
/**
|
|
221
258
|
* Merge a worktree into the main belief line.
|
|
222
259
|
*/
|
|
@@ -285,45 +322,26 @@ declare function createWorkflowClient(config?: WorkflowClientConfig): {
|
|
|
285
322
|
* Update a workflow task.
|
|
286
323
|
*/
|
|
287
324
|
updateTask(taskId: string, input: UpdateTaskInput, idempotencyKey?: string): Promise<PlatformGatewaySuccess<UpdateTaskResponse>>;
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
createPillar(input: {
|
|
325
|
+
} & {
|
|
326
|
+
addWorktree: (input: AddWorktreeInput, idempotencyKey?: string) => Promise<PlatformGatewaySuccess<WorkflowWorktreeRecord>>;
|
|
327
|
+
createPillar: (input: {
|
|
292
328
|
name: string;
|
|
293
329
|
topicId?: string;
|
|
294
330
|
description?: string;
|
|
295
331
|
metadata?: JsonObject;
|
|
296
|
-
} & TopicIdentifierInput, idempotencyKey?: string)
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
createSprint(input: {
|
|
301
|
-
title: string;
|
|
302
|
-
topicId?: string;
|
|
303
|
-
branchId?: string;
|
|
304
|
-
hypothesis?: string;
|
|
305
|
-
beliefIds?: string[];
|
|
306
|
-
} & TopicIdentifierInput, idempotencyKey?: string): Promise<PlatformGatewaySuccess<WorkflowWorktreeRecord>>;
|
|
307
|
-
/**
|
|
308
|
-
* @deprecated Use merge.
|
|
309
|
-
*/
|
|
310
|
-
completeSprint(worktreeId: string, input: MergeInput, idempotencyKey?: string): Promise<PlatformGatewaySuccess<MergeWorktreeResponse>>;
|
|
311
|
-
/**
|
|
312
|
-
* @deprecated Use openPullRequest.
|
|
313
|
-
*/
|
|
314
|
-
requestReview(worktreeId: string, input: {
|
|
332
|
+
} & TopicIdentifierInput, idempotencyKey?: string) => Promise<PlatformGatewaySuccess<WorkflowBranchRecord>>;
|
|
333
|
+
createSprint: (input: AddWorktreeInput, idempotencyKey?: string) => Promise<PlatformGatewaySuccess<WorkflowWorktreeRecord>>;
|
|
334
|
+
completeSprint: (worktreeId: string, input: MergeInput, idempotencyKey?: string) => Promise<PlatformGatewaySuccess<MergeWorktreeResponse>>;
|
|
335
|
+
requestReview: (worktreeId: string, input: {
|
|
315
336
|
summary: string;
|
|
316
337
|
reviewers?: string[];
|
|
317
338
|
status?: "pending_review" | "changes_requested" | "approved" | "blocked";
|
|
318
|
-
}, idempotencyKey?: string)
|
|
319
|
-
|
|
320
|
-
* @deprecated Use push.
|
|
321
|
-
*/
|
|
322
|
-
publishFindings(worktreeId: string, input: {
|
|
339
|
+
}, idempotencyKey?: string) => Promise<PlatformGatewaySuccess<OpenPullRequestResponse>>;
|
|
340
|
+
publishFindings: (worktreeId: string, input: {
|
|
323
341
|
targetContext: string;
|
|
324
342
|
beliefIds?: string[];
|
|
325
343
|
metadata?: JsonObject;
|
|
326
|
-
}, idempotencyKey?: string)
|
|
344
|
+
}, idempotencyKey?: string) => Promise<PlatformGatewaySuccess<PushWorktreeResponse>>;
|
|
327
345
|
};
|
|
328
346
|
|
|
329
|
-
export { type AddWorktreeInput, type AdvanceWorktreePhaseInput, type BulkCreateWorktreesInput, type CompleteTaskInput, CompleteTaskResponse, type CompleteWorktreeInput, type CreateTaskInput, CreateTaskResponse, type ListTopicsInput, ListTopicsResponse, ListWorktreesResponse, type MergeInput, MergeWorktreeResponse, OpenPullRequestResponse, type PatchWorktreeStateInput, PlatformGatewaySuccess, PushWorktreeResponse, type SetWorktreePhaseInput, type SwitchTopicContextInput, SwitchTopicContextResponse, type UpdateTaskInput, UpdateTaskResponse, type UpdateWorktreeTargetsInput, type WorkflowBranchStatus, type WorkflowClientConfig, type WorkflowLensPerspectiveType, type WorkflowLensStatus, type WorkflowMergeOutcome, type WorkflowWorktreeStatus, createWorkflowClient };
|
|
347
|
+
export { type AddWorktreeInput, type AdvanceWorktreePhaseInput, type BulkCreateWorktreesInput, type CompleteTaskInput, CompleteTaskResponse, type CompleteWorktreeInput, type CreateTaskInput, CreateTaskResponse, type ListTopicsInput, ListTopicsResponse, ListWorktreesResponse, type MergeInput, MergeWorktreeResponse, OpenPullRequestResponse, type PatchWorktreeStateInput, PlatformGatewaySuccess, PushWorktreeResponse, type SetWorktreePhaseInput, type SwitchTopicContextInput, SwitchTopicContextResponse, type UpdateTaskInput, UpdateTaskResponse, type UpdateWorktreeTargetsInput, type WorkflowBranchStatus, type WorkflowClientConfig, type WorkflowLensPerspectiveType, type WorkflowLensStatus, type WorkflowMergeInputOutcome, type WorkflowMergeOutcome, type WorkflowWorktreeStatus, createWorkflowClient };
|
package/dist/workflowClient.js
CHANGED
|
@@ -1,3 +1,170 @@
|
|
|
1
|
+
// src/authContext.ts
|
|
2
|
+
var LucernSdkAuthContextError = class extends Error {
|
|
3
|
+
reason;
|
|
4
|
+
constructor(reason, message) {
|
|
5
|
+
super(message);
|
|
6
|
+
this.name = "LucernSdkAuthContextError";
|
|
7
|
+
this.reason = reason;
|
|
8
|
+
}
|
|
9
|
+
};
|
|
10
|
+
function cleanString(value) {
|
|
11
|
+
const normalized = value?.trim();
|
|
12
|
+
return normalized ? normalized : void 0;
|
|
13
|
+
}
|
|
14
|
+
function cleanStringList(values) {
|
|
15
|
+
if (!values) {
|
|
16
|
+
return [];
|
|
17
|
+
}
|
|
18
|
+
return values.map((value) => value.trim()).filter(
|
|
19
|
+
(value, index, list) => value.length > 0 && list.indexOf(value) === index
|
|
20
|
+
);
|
|
21
|
+
}
|
|
22
|
+
function requireString(value, reason, label) {
|
|
23
|
+
const normalized = cleanString(value);
|
|
24
|
+
if (!normalized) {
|
|
25
|
+
throw new LucernSdkAuthContextError(
|
|
26
|
+
reason,
|
|
27
|
+
`Canonical Lucern SDK auth context is missing ${label}.`
|
|
28
|
+
);
|
|
29
|
+
}
|
|
30
|
+
return normalized;
|
|
31
|
+
}
|
|
32
|
+
function requirePrincipalType(principalType) {
|
|
33
|
+
if (!principalType) {
|
|
34
|
+
throw new LucernSdkAuthContextError(
|
|
35
|
+
"principal_missing",
|
|
36
|
+
"Canonical Lucern SDK auth context is missing principalType."
|
|
37
|
+
);
|
|
38
|
+
}
|
|
39
|
+
return principalType;
|
|
40
|
+
}
|
|
41
|
+
function requireAuthMode(authMode) {
|
|
42
|
+
if (!authMode) {
|
|
43
|
+
throw new LucernSdkAuthContextError(
|
|
44
|
+
"principal_missing",
|
|
45
|
+
"Canonical Lucern SDK auth context is missing authMode."
|
|
46
|
+
);
|
|
47
|
+
}
|
|
48
|
+
return authMode;
|
|
49
|
+
}
|
|
50
|
+
function ensurePermitMatch(args) {
|
|
51
|
+
const actual = cleanString(args.actual);
|
|
52
|
+
if (actual && actual !== args.expected) {
|
|
53
|
+
throw new LucernSdkAuthContextError(
|
|
54
|
+
"policy_denied",
|
|
55
|
+
`Canonical Lucern SDK auth context has conflicting Permit ${args.field}.`
|
|
56
|
+
);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
function normalizeCanonicalLucernAuthContext(input) {
|
|
60
|
+
if (!input) {
|
|
61
|
+
throw new LucernSdkAuthContextError(
|
|
62
|
+
"principal_missing",
|
|
63
|
+
"Canonical Lucern SDK auth context is required."
|
|
64
|
+
);
|
|
65
|
+
}
|
|
66
|
+
if (input.policyDecision === "deny") {
|
|
67
|
+
throw new LucernSdkAuthContextError(
|
|
68
|
+
"policy_denied",
|
|
69
|
+
"Canonical Lucern SDK auth context carries a denied policy decision."
|
|
70
|
+
);
|
|
71
|
+
}
|
|
72
|
+
const principalId = requireString(
|
|
73
|
+
input.principalId,
|
|
74
|
+
"principal_missing",
|
|
75
|
+
"principalId"
|
|
76
|
+
);
|
|
77
|
+
const tenantId = requireString(input.tenantId, "tenant_missing", "tenantId");
|
|
78
|
+
const workspaceId = requireString(
|
|
79
|
+
input.workspaceId,
|
|
80
|
+
"workspace_missing",
|
|
81
|
+
"workspaceId"
|
|
82
|
+
);
|
|
83
|
+
const roles = cleanStringList(input.roles);
|
|
84
|
+
const scopes = cleanStringList(input.scopes);
|
|
85
|
+
const principalType = requirePrincipalType(input.principalType);
|
|
86
|
+
const authMode = requireAuthMode(input.authMode);
|
|
87
|
+
const roleBasedInteractiveAuth = authMode === "interactive_user" && roles.length > 0;
|
|
88
|
+
if (roles.length === 0 || scopes.length === 0 && !roleBasedInteractiveAuth) {
|
|
89
|
+
throw new LucernSdkAuthContextError(
|
|
90
|
+
"membership_missing",
|
|
91
|
+
"Canonical Lucern SDK auth context requires non-empty roles and scopes."
|
|
92
|
+
);
|
|
93
|
+
}
|
|
94
|
+
const subject = cleanString(input.permit?.subject) ?? principalId;
|
|
95
|
+
const tenant = cleanString(input.permit?.tenant) ?? tenantId;
|
|
96
|
+
const workspace = cleanString(input.permit?.workspace) ?? workspaceId;
|
|
97
|
+
ensurePermitMatch({
|
|
98
|
+
field: "subject",
|
|
99
|
+
expected: principalId,
|
|
100
|
+
actual: subject
|
|
101
|
+
});
|
|
102
|
+
ensurePermitMatch({ field: "tenant", expected: tenantId, actual: tenant });
|
|
103
|
+
ensurePermitMatch({
|
|
104
|
+
field: "workspace",
|
|
105
|
+
expected: workspaceId,
|
|
106
|
+
actual: workspace
|
|
107
|
+
});
|
|
108
|
+
const context = input.permit?.context ? { ...input.permit.context } : void 0;
|
|
109
|
+
return {
|
|
110
|
+
clerkId: cleanString(input.clerkId),
|
|
111
|
+
principalId,
|
|
112
|
+
tenantId,
|
|
113
|
+
workspaceId,
|
|
114
|
+
principalType,
|
|
115
|
+
authMode,
|
|
116
|
+
roles,
|
|
117
|
+
scopes,
|
|
118
|
+
delegationChain: input.delegationChain ? [...input.delegationChain] : [],
|
|
119
|
+
policyTraceId: cleanString(input.policyTraceId),
|
|
120
|
+
correlationId: cleanString(input.correlationId),
|
|
121
|
+
membershipId: cleanString(input.membershipId),
|
|
122
|
+
permit: {
|
|
123
|
+
subject,
|
|
124
|
+
tenant,
|
|
125
|
+
workspace,
|
|
126
|
+
resource: cleanString(input.permit?.resource),
|
|
127
|
+
action: cleanString(input.permit?.action),
|
|
128
|
+
relation: cleanString(input.permit?.relation),
|
|
129
|
+
context
|
|
130
|
+
}
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
function createCanonicalAuthHeaders(authContext) {
|
|
134
|
+
const headers = {
|
|
135
|
+
"x-lucern-principal-id": authContext.principalId,
|
|
136
|
+
"x-lucern-principal-type": authContext.principalType,
|
|
137
|
+
"x-lucern-tenant": authContext.tenantId,
|
|
138
|
+
"x-lucern-tenant-id": authContext.tenantId,
|
|
139
|
+
"x-lucern-workspace": authContext.workspaceId,
|
|
140
|
+
"x-lucern-workspace-id": authContext.workspaceId,
|
|
141
|
+
"x-lucern-auth-mode": authContext.authMode,
|
|
142
|
+
"x-lucern-roles": authContext.roles.join(","),
|
|
143
|
+
"x-lucern-scopes": authContext.scopes.join(","),
|
|
144
|
+
"x-lucern-permit-context": JSON.stringify(authContext.permit)
|
|
145
|
+
};
|
|
146
|
+
if (authContext.clerkId) {
|
|
147
|
+
headers["x-lucern-clerk-id"] = authContext.clerkId;
|
|
148
|
+
headers["x-lucern-user-id"] = authContext.clerkId;
|
|
149
|
+
}
|
|
150
|
+
if (authContext.delegationChain.length > 0) {
|
|
151
|
+
headers["x-lucern-delegation-chain"] = JSON.stringify(
|
|
152
|
+
authContext.delegationChain
|
|
153
|
+
);
|
|
154
|
+
}
|
|
155
|
+
if (authContext.policyTraceId) {
|
|
156
|
+
headers["x-lucern-policy-trace-id"] = authContext.policyTraceId;
|
|
157
|
+
}
|
|
158
|
+
if (authContext.correlationId) {
|
|
159
|
+
headers["x-correlation-id"] = authContext.correlationId;
|
|
160
|
+
headers["x-lucern-correlation-id"] = authContext.correlationId;
|
|
161
|
+
}
|
|
162
|
+
if (authContext.membershipId) {
|
|
163
|
+
headers["x-lucern-membership-id"] = authContext.membershipId;
|
|
164
|
+
}
|
|
165
|
+
return headers;
|
|
166
|
+
}
|
|
167
|
+
|
|
1
168
|
// src/coreClient.ts
|
|
2
169
|
var LucernApiError = class extends Error {
|
|
3
170
|
code;
|
|
@@ -65,9 +232,7 @@ function generatePortableRequestId() {
|
|
|
65
232
|
8
|
|
66
233
|
).join("")}-${hex.slice(8, 10).join("")}-${hex.slice(10).join("")}`;
|
|
67
234
|
}
|
|
68
|
-
|
|
69
|
-
return generatePortableRequestId();
|
|
70
|
-
}
|
|
235
|
+
var randomIdempotencyKey = generatePortableRequestId;
|
|
71
236
|
function isRetryableStatus(status) {
|
|
72
237
|
return status >= 500 || status === 408 || status === 429;
|
|
73
238
|
}
|
|
@@ -132,8 +297,11 @@ function timeoutError(timeoutMs) {
|
|
|
132
297
|
error.name = "AbortError";
|
|
133
298
|
return error;
|
|
134
299
|
}
|
|
300
|
+
function isRecord(value) {
|
|
301
|
+
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
302
|
+
}
|
|
135
303
|
function readPolicySummaryFromDetails(details) {
|
|
136
|
-
if (!
|
|
304
|
+
if (!isRecord(details)) {
|
|
137
305
|
return null;
|
|
138
306
|
}
|
|
139
307
|
const directSummary = details.summary;
|
|
@@ -141,11 +309,11 @@ function readPolicySummaryFromDetails(details) {
|
|
|
141
309
|
return directSummary.trim();
|
|
142
310
|
}
|
|
143
311
|
const policy = details.policy;
|
|
144
|
-
if (!
|
|
312
|
+
if (!isRecord(policy)) {
|
|
145
313
|
return null;
|
|
146
314
|
}
|
|
147
315
|
const explanation = policy.explanation;
|
|
148
|
-
if (!
|
|
316
|
+
if (!isRecord(explanation)) {
|
|
149
317
|
return null;
|
|
150
318
|
}
|
|
151
319
|
const nestedSummary = explanation.summary;
|
|
@@ -154,16 +322,41 @@ function readPolicySummaryFromDetails(details) {
|
|
|
154
322
|
}
|
|
155
323
|
return null;
|
|
156
324
|
}
|
|
325
|
+
async function resolveConfiguredAuthContext(authContext) {
|
|
326
|
+
if (typeof authContext === "function") {
|
|
327
|
+
return await authContext();
|
|
328
|
+
}
|
|
329
|
+
return authContext;
|
|
330
|
+
}
|
|
331
|
+
function mergeHeaderRecord(base, addition) {
|
|
332
|
+
const headers = new Headers(base);
|
|
333
|
+
for (const [key, value] of Object.entries(addition)) {
|
|
334
|
+
const existing = headers.get(key);
|
|
335
|
+
if (existing !== null && existing !== value) {
|
|
336
|
+
throw new LucernSdkAuthContextError(
|
|
337
|
+
"policy_denied",
|
|
338
|
+
`Canonical Lucern SDK auth context conflicts with existing ${key} header.`
|
|
339
|
+
);
|
|
340
|
+
}
|
|
341
|
+
headers.set(key, value);
|
|
342
|
+
}
|
|
343
|
+
return Object.fromEntries(headers.entries());
|
|
344
|
+
}
|
|
157
345
|
function createGatewayRequestClient(config = {}) {
|
|
158
346
|
const fetchImpl = config.fetchImpl ?? fetch;
|
|
159
347
|
const baseUrl = config.baseUrl?.replace(/\/+$/, "") ?? "";
|
|
160
348
|
const maxRetries = config.maxRetries ?? 2;
|
|
161
349
|
const requestIdFactory = config.requestIdFactory ?? (() => generatePortableRequestId());
|
|
162
350
|
async function resolveAuthHeaders() {
|
|
163
|
-
|
|
164
|
-
|
|
351
|
+
const base = config.getAuthHeaders ? await config.getAuthHeaders() : {};
|
|
352
|
+
const authContextInput = await resolveConfiguredAuthContext(
|
|
353
|
+
config.authContext
|
|
354
|
+
);
|
|
355
|
+
if (!authContextInput && !config.requireCanonicalAuthContext) {
|
|
356
|
+
return base;
|
|
165
357
|
}
|
|
166
|
-
|
|
358
|
+
const authContext = normalizeCanonicalLucernAuthContext(authContextInput);
|
|
359
|
+
return mergeHeaderRecord(base, createCanonicalAuthHeaders(authContext));
|
|
167
360
|
}
|
|
168
361
|
async function fetchWithTimeout(url, init, timeoutMs) {
|
|
169
362
|
const controller = new AbortController();
|
|
@@ -184,11 +377,11 @@ function createGatewayRequestClient(config = {}) {
|
|
|
184
377
|
if (!text) {
|
|
185
378
|
return null;
|
|
186
379
|
}
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
} catch {
|
|
380
|
+
const parsed = tryParseGatewayEnvelopeJson(text);
|
|
381
|
+
if (!parsed.ok) {
|
|
190
382
|
return null;
|
|
191
383
|
}
|
|
384
|
+
return isRecord(parsed.value) ? parsed.value : null;
|
|
192
385
|
}
|
|
193
386
|
function resolveTimeoutMs(method, requestTimeoutMs) {
|
|
194
387
|
if (typeof requestTimeoutMs === "number") {
|
|
@@ -200,16 +393,31 @@ function createGatewayRequestClient(config = {}) {
|
|
|
200
393
|
}
|
|
201
394
|
return config.timeoutMs ?? 15e3;
|
|
202
395
|
}
|
|
396
|
+
function tryParseGatewayEnvelopeJson(text) {
|
|
397
|
+
const trimmed = text.trim();
|
|
398
|
+
if (!trimmed.startsWith("{") && !trimmed.startsWith("[")) {
|
|
399
|
+
return { ok: false, reason: "non-json" };
|
|
400
|
+
}
|
|
401
|
+
try {
|
|
402
|
+
return { ok: true, value: JSON.parse(trimmed) };
|
|
403
|
+
} catch (error) {
|
|
404
|
+
if (error instanceof SyntaxError) {
|
|
405
|
+
return { ok: false, reason: "invalid-json", error };
|
|
406
|
+
}
|
|
407
|
+
throw error;
|
|
408
|
+
}
|
|
409
|
+
}
|
|
203
410
|
function buildApiError(args) {
|
|
204
411
|
const failure = args.failure;
|
|
205
|
-
const legacyError = failure &&
|
|
412
|
+
const legacyError = failure && isRecord(failure.error) ? failure.error : failure?.legacyError;
|
|
206
413
|
const correlationId = failure?.correlationId ?? args.response.headers.get("x-lucern-correlation-id")?.trim() ?? args.requestId;
|
|
207
414
|
const policyTraceId = failure?.policyTraceId ?? args.response.headers.get("x-lucern-policy-trace-id")?.trim() ?? null;
|
|
208
415
|
const details = failure?.details ?? legacyError?.details;
|
|
209
416
|
const policySummary = readPolicySummaryFromDetails(details);
|
|
417
|
+
const failureMessage = typeof failure?.error === "string" ? failure.error : legacyError?.message;
|
|
210
418
|
return new LucernApiError({
|
|
211
419
|
code: failure?.code ?? legacyError?.code ?? fallbackErrorCode(args.response.status),
|
|
212
|
-
message: policySummary ??
|
|
420
|
+
message: policySummary ?? failureMessage ?? (args.response.ok ? "Platform API returned an invalid success payload." : "Platform API request failed."),
|
|
213
421
|
status: args.response.status,
|
|
214
422
|
invariant: failure?.invariant,
|
|
215
423
|
suggestion: failure?.suggestion,
|
|
@@ -335,27 +543,30 @@ function createGatewayRequestClient(config = {}) {
|
|
|
335
543
|
}
|
|
336
544
|
|
|
337
545
|
// src/sdkSurface.ts
|
|
546
|
+
function isRecord2(value) {
|
|
547
|
+
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
548
|
+
}
|
|
338
549
|
function asRecord(value) {
|
|
339
|
-
return value
|
|
550
|
+
return isRecord2(value) ? value : {};
|
|
340
551
|
}
|
|
341
|
-
function
|
|
552
|
+
function cleanString2(value) {
|
|
342
553
|
return typeof value === "string" && value.trim().length > 0 ? value.trim() : void 0;
|
|
343
554
|
}
|
|
344
555
|
function cloneWith(value, patch) {
|
|
345
556
|
return { ...value, ...patch };
|
|
346
557
|
}
|
|
347
558
|
function resolveTopicId(value) {
|
|
348
|
-
return
|
|
559
|
+
return cleanString2(value.topicId);
|
|
349
560
|
}
|
|
350
561
|
function withTopicAlias(value) {
|
|
351
|
-
const topicId =
|
|
562
|
+
const topicId = cleanString2(value.topicId) ?? void 0;
|
|
352
563
|
if (!topicId) {
|
|
353
564
|
return value;
|
|
354
565
|
}
|
|
355
566
|
return cloneWith(value, { topicId });
|
|
356
567
|
}
|
|
357
568
|
function withTextAlias(value) {
|
|
358
|
-
const text =
|
|
569
|
+
const text = cleanString2(value.text) ?? cleanString2(value.canonicalText) ?? void 0;
|
|
359
570
|
if (!text) {
|
|
360
571
|
return value;
|
|
361
572
|
}
|
|
@@ -365,7 +576,7 @@ function withSdkAliases(value) {
|
|
|
365
576
|
return withTopicAlias(withTextAlias(value));
|
|
366
577
|
}
|
|
367
578
|
function normalizeTopicQuery(value) {
|
|
368
|
-
const topicId =
|
|
579
|
+
const topicId = cleanString2(value.topicId);
|
|
369
580
|
if (!topicId) {
|
|
370
581
|
return value;
|
|
371
582
|
}
|
|
@@ -390,7 +601,10 @@ function createListResult(items, legacyKey) {
|
|
|
390
601
|
total: items.length
|
|
391
602
|
};
|
|
392
603
|
if (legacyKey) {
|
|
393
|
-
|
|
604
|
+
return {
|
|
605
|
+
...result,
|
|
606
|
+
[legacyKey]: items
|
|
607
|
+
};
|
|
394
608
|
}
|
|
395
609
|
return result;
|
|
396
610
|
}
|
|
@@ -599,12 +813,6 @@ function createWorkflowClient(config = {}) {
|
|
|
599
813
|
)
|
|
600
814
|
);
|
|
601
815
|
},
|
|
602
|
-
/**
|
|
603
|
-
* @deprecated Use createWorktree.
|
|
604
|
-
*/
|
|
605
|
-
async addWorktree(input, idempotencyKey) {
|
|
606
|
-
return client.createWorktree(input, idempotencyKey);
|
|
607
|
-
},
|
|
608
816
|
/**
|
|
609
817
|
* Merge a worktree into the main belief line.
|
|
610
818
|
*/
|
|
@@ -802,39 +1010,16 @@ function createWorkflowClient(config = {}) {
|
|
|
802
1010
|
body: input,
|
|
803
1011
|
idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
|
|
804
1012
|
});
|
|
805
|
-
},
|
|
806
|
-
/**
|
|
807
|
-
* @deprecated Use createBranch.
|
|
808
|
-
*/
|
|
809
|
-
async createPillar(input, idempotencyKey) {
|
|
810
|
-
return client.createBranch(input, idempotencyKey);
|
|
811
|
-
},
|
|
812
|
-
/**
|
|
813
|
-
* @deprecated Use addWorktree.
|
|
814
|
-
*/
|
|
815
|
-
async createSprint(input, idempotencyKey) {
|
|
816
|
-
return client.createWorktree(input, idempotencyKey);
|
|
817
|
-
},
|
|
818
|
-
/**
|
|
819
|
-
* @deprecated Use merge.
|
|
820
|
-
*/
|
|
821
|
-
async completeSprint(worktreeId, input, idempotencyKey) {
|
|
822
|
-
return client.merge(worktreeId, input, idempotencyKey);
|
|
823
|
-
},
|
|
824
|
-
/**
|
|
825
|
-
* @deprecated Use openPullRequest.
|
|
826
|
-
*/
|
|
827
|
-
async requestReview(worktreeId, input, idempotencyKey) {
|
|
828
|
-
return client.openPullRequest(worktreeId, input, idempotencyKey);
|
|
829
|
-
},
|
|
830
|
-
/**
|
|
831
|
-
* @deprecated Use push.
|
|
832
|
-
*/
|
|
833
|
-
async publishFindings(worktreeId, input, idempotencyKey) {
|
|
834
|
-
return client.push(worktreeId, input, idempotencyKey);
|
|
835
1013
|
}
|
|
836
1014
|
};
|
|
837
|
-
return client
|
|
1015
|
+
return Object.assign(client, {
|
|
1016
|
+
addWorktree: client.createWorktree,
|
|
1017
|
+
createPillar: client.createBranch,
|
|
1018
|
+
createSprint: client.createWorktree,
|
|
1019
|
+
completeSprint: client.merge,
|
|
1020
|
+
requestReview: client.openPullRequest,
|
|
1021
|
+
publishFindings: client.push
|
|
1022
|
+
});
|
|
838
1023
|
}
|
|
839
1024
|
|
|
840
1025
|
export { LucernApiError, createWorkflowClient };
|