@lucern/sdk 0.3.0-alpha.17 → 0.3.0-alpha.3
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 +0 -12
- package/README.md +4 -110
- package/dist/adminClient.d.ts +8 -8
- package/dist/adminClient.js +40 -70
- package/dist/adminClient.js.map +1 -1
- package/dist/answersClient.js +12 -49
- package/dist/answersClient.js.map +1 -1
- package/dist/audience/index.d.ts +1 -2
- package/dist/audience/index.js +3 -1
- package/dist/audience/index.js.map +1 -1
- package/dist/audiencesClient.d.ts +16 -16
- package/dist/audiencesClient.js +91 -125
- package/dist/audiencesClient.js.map +1 -1
- package/dist/auditClient.js +14 -53
- package/dist/auditClient.js.map +1 -1
- package/dist/authContext.d.ts +2 -2
- package/dist/authContext.js +3 -4
- package/dist/authContext.js.map +1 -1
- package/dist/authDeviceClient.js +3 -16
- package/dist/authDeviceClient.js.map +1 -1
- package/dist/beliefs/index.d.ts +4 -9
- package/dist/beliefs/index.js +1305 -1943
- package/dist/beliefs/index.js.map +1 -1
- package/dist/beliefsClient.d.ts +2 -2
- package/dist/beliefsClient.js +23 -54
- package/dist/beliefsClient.js.map +1 -1
- package/dist/boundaryClientSurface.js +3 -10
- package/dist/boundaryClientSurface.js.map +1 -1
- package/dist/client-EiG9nJOY.d.ts +2911 -0
- package/dist/client.d.ts +41 -3038
- package/dist/client.js +1305 -1943
- package/dist/client.js.map +1 -1
- package/dist/contextClient.d.ts +3 -4
- package/dist/contextClient.js +30 -79
- package/dist/contextClient.js.map +1 -1
- package/dist/contextFacade.js +16 -25
- package/dist/contextFacade.js.map +1 -1
- package/dist/contextPackCompiler.js +30 -19
- package/dist/contextPackCompiler.js.map +1 -1
- package/dist/contextPackPolicy.js +17 -7
- package/dist/contextPackPolicy.js.map +1 -1
- package/dist/contextTypes.d.ts +0 -2
- package/dist/contracts/api-enums.contract.d.ts +2 -2
- package/dist/contracts/api-enums.contract.js +1 -6
- package/dist/contracts/api-enums.contract.js.map +1 -1
- package/dist/contracts/auth-session.contract.d.ts +1 -1
- package/dist/contracts/auth-session.contract.js +2 -14
- package/dist/contracts/auth-session.contract.js.map +1 -1
- package/dist/contracts/index.js +6 -30
- package/dist/contracts/index.js.map +1 -1
- package/dist/contracts/lens-filter.contract.js +3 -4
- package/dist/contracts/lens-filter.contract.js.map +1 -1
- package/dist/contracts/lens-workflow.contract.js +3 -4
- package/dist/contracts/lens-workflow.contract.js.map +1 -1
- package/dist/contracts/lensFilter.js +3 -4
- package/dist/contracts/lensFilter.js.map +1 -1
- package/dist/contracts/lensWorkflow.js +3 -4
- package/dist/contracts/lensWorkflow.js.map +1 -1
- package/dist/contracts/mcpTools.js +0 -6
- package/dist/contracts/mcpTools.js.map +1 -1
- package/dist/contradictions/index.d.ts +3 -8
- package/dist/contradictions/index.js +1305 -1943
- package/dist/contradictions/index.js.map +1 -1
- package/dist/coreClient.d.ts +2 -19
- package/dist/coreClient.js +15 -50
- package/dist/coreClient.js.map +1 -1
- package/dist/decisions/index.d.ts +13 -18
- package/dist/decisions/index.js +1305 -1943
- package/dist/decisions/index.js.map +1 -1
- package/dist/decisionsClient.d.ts +12 -4
- package/dist/decisionsClient.js +35 -60
- package/dist/decisionsClient.js.map +1 -1
- package/dist/edges/index.d.ts +86 -31
- package/dist/edges/index.js +1305 -1943
- package/dist/edges/index.js.map +1 -1
- package/dist/embeddingsClient.js +18 -60
- package/dist/embeddingsClient.js.map +1 -1
- package/dist/eventingClient.js +18 -60
- package/dist/eventingClient.js.map +1 -1
- package/dist/events.js +3 -6
- package/dist/events.js.map +1 -1
- package/dist/eventsCore.d.ts +1 -1
- package/dist/eventsCore.js +15 -50
- package/dist/eventsCore.js.map +1 -1
- package/dist/evidence/index.d.ts +3 -8
- package/dist/evidence/index.js +1305 -1943
- package/dist/evidence/index.js.map +1 -1
- package/dist/evidenceClient.js +15 -50
- package/dist/evidenceClient.js.map +1 -1
- package/dist/facade/context.d.ts +1 -2
- package/dist/facade/context.js +16 -25
- package/dist/facade/context.js.map +1 -1
- package/dist/gatewayFacades.d.ts +48 -90
- package/dist/gatewayFacades.js +128 -251
- package/dist/gatewayFacades.js.map +1 -1
- package/dist/graphAnalysisClient.d.ts +1 -53
- package/dist/graphAnalysisClient.js +17 -81
- package/dist/graphAnalysisClient.js.map +1 -1
- package/dist/graphClient.d.ts +13 -6
- package/dist/graphClient.js +39 -65
- package/dist/graphClient.js.map +1 -1
- package/dist/graphRecommendationsClient.js +17 -54
- package/dist/graphRecommendationsClient.js.map +1 -1
- package/dist/graphStateClassifierClient.js +19 -60
- package/dist/graphStateClassifierClient.js.map +1 -1
- package/dist/harnessClient.d.ts +24 -13
- package/dist/harnessClient.js +41 -61
- package/dist/harnessClient.js.map +1 -1
- package/dist/identityClient.d.ts +9 -27
- package/dist/identityClient.js +39 -203
- package/dist/identityClient.js.map +1 -1
- package/dist/index.d.ts +6 -15
- package/dist/index.js +1171 -2256
- package/dist/index.js.map +1 -1
- package/dist/jobsClient.js +19 -60
- package/dist/jobsClient.js.map +1 -1
- package/dist/learningClient.d.ts +6 -6
- package/dist/learningClient.js +43 -78
- package/dist/learningClient.js.map +1 -1
- package/dist/lenses/index.d.ts +37 -60
- package/dist/lenses/index.js +1305 -1943
- package/dist/lenses/index.js.map +1 -1
- package/dist/mcpClient.js +13 -51
- package/dist/mcpClient.js.map +1 -1
- package/dist/modelRuntimeClient.js +18 -60
- package/dist/modelRuntimeClient.js.map +1 -1
- package/dist/nodes/index.d.ts +22 -49
- package/dist/nodes/index.js +1305 -1943
- package/dist/nodes/index.js.map +1 -1
- package/dist/ontologies/index.d.ts +31 -37
- package/dist/ontologies/index.js +1305 -1943
- package/dist/ontologies/index.js.map +1 -1
- package/dist/ontologyClient.d.ts +25 -17
- package/dist/ontologyClient.js +41 -86
- package/dist/ontologyClient.js.map +1 -1
- package/dist/ontologyLinksClient.js +19 -60
- package/dist/ontologyLinksClient.js.map +1 -1
- package/dist/orgGraphSearchClient.js +14 -53
- package/dist/orgGraphSearchClient.js.map +1 -1
- package/dist/packRuntime.d.ts +1 -2
- package/dist/packsClient.d.ts +23 -9
- package/dist/packsClient.js +47 -62
- package/dist/packsClient.js.map +1 -1
- package/dist/policyClient.d.ts +10 -11
- package/dist/policyClient.js +26 -71
- package/dist/policyClient.js.map +1 -1
- package/dist/questions/index.d.ts +3 -8
- package/dist/questions/index.js +1305 -1943
- package/dist/questions/index.js.map +1 -1
- package/dist/realtime/index.d.ts +1 -1
- package/dist/reportsClient.d.ts +7 -7
- package/dist/reportsClient.js +52 -107
- package/dist/reportsClient.js.map +1 -1
- package/dist/schemaClient.d.ts +3 -3
- package/dist/schemaClient.js +30 -63
- package/dist/schemaClient.js.map +1 -1
- package/dist/sdkSurface.d.ts +3 -6
- package/dist/sdkSurface.js +6 -10
- package/dist/sdkSurface.js.map +1 -1
- package/dist/sourcesClient.js +15 -50
- package/dist/sourcesClient.js.map +1 -1
- package/dist/telemetryClient.js +19 -60
- package/dist/telemetryClient.js.map +1 -1
- package/dist/toolRegistryClient.d.ts +2 -10
- package/dist/toolRegistryClient.js +20 -73
- package/dist/toolRegistryClient.js.map +1 -1
- package/dist/topics/index.d.ts +8 -19
- package/dist/topics/index.js +1305 -1945
- package/dist/topics/index.js.map +1 -1
- package/dist/topicsClient.d.ts +0 -2
- package/dist/topicsClient.js +20 -60
- package/dist/topicsClient.js.map +1 -1
- package/dist/types.d.ts +0 -17
- 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 +40 -58
- package/dist/workflowClient.js +54 -66
- package/dist/workflowClient.js.map +1 -1
- package/dist/worktrees/index.d.ts +33 -54
- package/dist/worktrees/index.js +1305 -1943
- package/dist/worktrees/index.js.map +1 -1
- package/package.json +3 -17
- package/dist/accessControl.d.ts +0 -79
- package/dist/accessControl.js +0 -1270
- package/dist/accessControl.js.map +0 -1
- package/dist/clientHelpers.d.ts +0 -48
- package/dist/clientHelpers.js +0 -137
- package/dist/clientHelpers.js.map +0 -1
- package/dist/control-plane.d.ts +0 -69
- package/dist/control-plane.js +0 -674
- package/dist/control-plane.js.map +0 -1
- package/dist/functionSurface.d.ts +0 -144
- package/dist/functionSurface.js +0 -1227
- package/dist/functionSurface.js.map +0 -1
- package/dist/functionSurfaceClient.d.ts +0 -8
- package/dist/functionSurfaceClient.js +0 -1227
- package/dist/functionSurfaceClient.js.map +0 -1
- package/dist/graphIntel.d.ts +0 -4
- package/dist/graphIntel.js +0 -3
- package/dist/graphIntel.js.map +0 -1
- package/dist/graphIntelligence.d.ts +0 -2
- package/dist/graphIntelligence.js +0 -47
- package/dist/graphIntelligence.js.map +0 -1
- package/dist/infisicalRuntime.d.ts +0 -43
- package/dist/infisicalRuntime.js +0 -346
- package/dist/infisicalRuntime.js.map +0 -1
- package/dist/secrets.d.ts +0 -1
- package/dist/secrets.js +0 -3
- package/dist/secrets.js.map +0 -1
package/dist/workflowClient.d.ts
CHANGED
|
@@ -24,49 +24,12 @@ type WorkflowMergeOutcome = "validated" | "invalidated" | "forked" | "inconclusi
|
|
|
24
24
|
type AddWorktreeInput = {
|
|
25
25
|
title: string;
|
|
26
26
|
topicId?: string;
|
|
27
|
-
topicHint?: string;
|
|
28
27
|
branchId?: string;
|
|
29
28
|
objective?: string;
|
|
30
29
|
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;
|
|
38
30
|
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[];
|
|
64
31
|
autoShape?: boolean;
|
|
65
32
|
domainPackId?: string;
|
|
66
|
-
tags?: string[];
|
|
67
|
-
touchedPaths?: string[];
|
|
68
|
-
sourceRef?: string;
|
|
69
|
-
sourceKind?: string;
|
|
70
33
|
campaign?: number;
|
|
71
34
|
lane?: string;
|
|
72
35
|
laneOrderInCampaign?: number;
|
|
@@ -78,16 +41,14 @@ type AddWorktreeInput = {
|
|
|
78
41
|
staffingHint?: WorkflowStaffingHint | string;
|
|
79
42
|
lastReconciledAt?: number;
|
|
80
43
|
autoFixPolicy?: WorkflowAutoFixPolicy;
|
|
81
|
-
lensId?: string;
|
|
82
44
|
} & TopicIdentifierInput;
|
|
83
|
-
|
|
84
|
-
beliefId: string;
|
|
85
|
-
confidence: number;
|
|
86
|
-
rationale: string;
|
|
87
|
-
};
|
|
88
|
-
/** Input for merging worktree findings with optional belief confidence outcomes. */
|
|
45
|
+
/** Input for merging worktree findings with belief confidence outcomes. */
|
|
89
46
|
type MergeInput = {
|
|
90
|
-
outcomes:
|
|
47
|
+
outcomes: Array<{
|
|
48
|
+
beliefId: string;
|
|
49
|
+
confidence: number;
|
|
50
|
+
rationale: string;
|
|
51
|
+
}>;
|
|
91
52
|
summary?: string;
|
|
92
53
|
};
|
|
93
54
|
/** Input for updating the beliefs and questions tracked by a worktree. */
|
|
@@ -157,8 +118,6 @@ type UpdateTaskInput = {
|
|
|
157
118
|
linkedWorktreeId?: string;
|
|
158
119
|
priority?: "critical" | "high" | "medium" | "low";
|
|
159
120
|
status?: "todo" | "in_progress" | "blocked" | "done";
|
|
160
|
-
assigneeId?: string;
|
|
161
|
-
blockedReason?: string;
|
|
162
121
|
};
|
|
163
122
|
/**
|
|
164
123
|
* Create the workflow client for lenses, legacy branches, worktrees, context,
|
|
@@ -256,6 +215,10 @@ declare function createWorkflowClient(config?: WorkflowClientConfig): {
|
|
|
256
215
|
* Create a workflow worktree.
|
|
257
216
|
*/
|
|
258
217
|
createWorktree(input: AddWorktreeInput, idempotencyKey?: string): Promise<PlatformGatewaySuccess<WorkflowWorktreeRecord>>;
|
|
218
|
+
/**
|
|
219
|
+
* @deprecated Use createWorktree.
|
|
220
|
+
*/
|
|
221
|
+
addWorktree(input: AddWorktreeInput, idempotencyKey?: string): Promise<PlatformGatewaySuccess<WorkflowWorktreeRecord>>;
|
|
259
222
|
/**
|
|
260
223
|
* Merge a worktree into the main belief line.
|
|
261
224
|
*/
|
|
@@ -324,26 +287,45 @@ declare function createWorkflowClient(config?: WorkflowClientConfig): {
|
|
|
324
287
|
* Update a workflow task.
|
|
325
288
|
*/
|
|
326
289
|
updateTask(taskId: string, input: UpdateTaskInput, idempotencyKey?: string): Promise<PlatformGatewaySuccess<UpdateTaskResponse>>;
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
290
|
+
/**
|
|
291
|
+
* @deprecated Use createBranch.
|
|
292
|
+
*/
|
|
293
|
+
createPillar(input: {
|
|
330
294
|
name: string;
|
|
331
295
|
topicId?: string;
|
|
332
296
|
description?: string;
|
|
333
297
|
metadata?: JsonObject;
|
|
334
|
-
} & TopicIdentifierInput, idempotencyKey?: string)
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
298
|
+
} & TopicIdentifierInput, idempotencyKey?: string): Promise<PlatformGatewaySuccess<WorkflowBranchRecord>>;
|
|
299
|
+
/**
|
|
300
|
+
* @deprecated Use addWorktree.
|
|
301
|
+
*/
|
|
302
|
+
createSprint(input: {
|
|
303
|
+
title: string;
|
|
304
|
+
topicId?: string;
|
|
305
|
+
branchId?: string;
|
|
306
|
+
hypothesis?: string;
|
|
307
|
+
beliefIds?: string[];
|
|
308
|
+
} & TopicIdentifierInput, idempotencyKey?: string): Promise<PlatformGatewaySuccess<WorkflowWorktreeRecord>>;
|
|
309
|
+
/**
|
|
310
|
+
* @deprecated Use merge.
|
|
311
|
+
*/
|
|
312
|
+
completeSprint(worktreeId: string, input: MergeInput, idempotencyKey?: string): Promise<PlatformGatewaySuccess<MergeWorktreeResponse>>;
|
|
313
|
+
/**
|
|
314
|
+
* @deprecated Use openPullRequest.
|
|
315
|
+
*/
|
|
316
|
+
requestReview(worktreeId: string, input: {
|
|
338
317
|
summary: string;
|
|
339
318
|
reviewers?: string[];
|
|
340
319
|
status?: "pending_review" | "changes_requested" | "approved" | "blocked";
|
|
341
|
-
}, idempotencyKey?: string)
|
|
342
|
-
|
|
320
|
+
}, idempotencyKey?: string): Promise<PlatformGatewaySuccess<OpenPullRequestResponse>>;
|
|
321
|
+
/**
|
|
322
|
+
* @deprecated Use push.
|
|
323
|
+
*/
|
|
324
|
+
publishFindings(worktreeId: string, input: {
|
|
343
325
|
targetContext: string;
|
|
344
326
|
beliefIds?: string[];
|
|
345
327
|
metadata?: JsonObject;
|
|
346
|
-
}, idempotencyKey?: string)
|
|
328
|
+
}, idempotencyKey?: string): Promise<PlatformGatewaySuccess<PushWorktreeResponse>>;
|
|
347
329
|
};
|
|
348
330
|
|
|
349
|
-
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
|
|
331
|
+
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 };
|
package/dist/workflowClient.js
CHANGED
|
@@ -82,15 +82,14 @@ function normalizeCanonicalLucernAuthContext(input) {
|
|
|
82
82
|
);
|
|
83
83
|
const roles = cleanStringList(input.roles);
|
|
84
84
|
const scopes = cleanStringList(input.scopes);
|
|
85
|
-
|
|
86
|
-
const authMode = requireAuthMode(input.authMode);
|
|
87
|
-
const roleBasedInteractiveAuth = authMode === "interactive_user" && roles.length > 0;
|
|
88
|
-
if (roles.length === 0 || scopes.length === 0 && !roleBasedInteractiveAuth) {
|
|
85
|
+
if (roles.length === 0 || scopes.length === 0) {
|
|
89
86
|
throw new LucernSdkAuthContextError(
|
|
90
87
|
"membership_missing",
|
|
91
88
|
"Canonical Lucern SDK auth context requires non-empty roles and scopes."
|
|
92
89
|
);
|
|
93
90
|
}
|
|
91
|
+
const principalType = requirePrincipalType(input.principalType);
|
|
92
|
+
const authMode = requireAuthMode(input.authMode);
|
|
94
93
|
const subject = cleanString(input.permit?.subject) ?? principalId;
|
|
95
94
|
const tenant = cleanString(input.permit?.tenant) ?? tenantId;
|
|
96
95
|
const workspace = cleanString(input.permit?.workspace) ?? workspaceId;
|
|
@@ -232,7 +231,9 @@ function generatePortableRequestId() {
|
|
|
232
231
|
8
|
|
233
232
|
).join("")}-${hex.slice(8, 10).join("")}-${hex.slice(10).join("")}`;
|
|
234
233
|
}
|
|
235
|
-
|
|
234
|
+
function randomIdempotencyKey() {
|
|
235
|
+
return generatePortableRequestId();
|
|
236
|
+
}
|
|
236
237
|
function isRetryableStatus(status) {
|
|
237
238
|
return status >= 500 || status === 408 || status === 429;
|
|
238
239
|
}
|
|
@@ -297,11 +298,8 @@ function timeoutError(timeoutMs) {
|
|
|
297
298
|
error.name = "AbortError";
|
|
298
299
|
return error;
|
|
299
300
|
}
|
|
300
|
-
function isRecord(value) {
|
|
301
|
-
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
302
|
-
}
|
|
303
301
|
function readPolicySummaryFromDetails(details) {
|
|
304
|
-
if (!
|
|
302
|
+
if (!details || typeof details !== "object" || Array.isArray(details)) {
|
|
305
303
|
return null;
|
|
306
304
|
}
|
|
307
305
|
const directSummary = details.summary;
|
|
@@ -309,11 +307,11 @@ function readPolicySummaryFromDetails(details) {
|
|
|
309
307
|
return directSummary.trim();
|
|
310
308
|
}
|
|
311
309
|
const policy = details.policy;
|
|
312
|
-
if (!
|
|
310
|
+
if (!policy || typeof policy !== "object" || Array.isArray(policy)) {
|
|
313
311
|
return null;
|
|
314
312
|
}
|
|
315
313
|
const explanation = policy.explanation;
|
|
316
|
-
if (!
|
|
314
|
+
if (!explanation || typeof explanation !== "object" || Array.isArray(explanation)) {
|
|
317
315
|
return null;
|
|
318
316
|
}
|
|
319
317
|
const nestedSummary = explanation.summary;
|
|
@@ -342,31 +340,13 @@ function mergeHeaderRecord(base, addition) {
|
|
|
342
340
|
}
|
|
343
341
|
return Object.fromEntries(headers.entries());
|
|
344
342
|
}
|
|
345
|
-
function cleanHeaderValue(value) {
|
|
346
|
-
const normalized = value?.trim();
|
|
347
|
-
return normalized ? normalized : void 0;
|
|
348
|
-
}
|
|
349
343
|
function createGatewayRequestClient(config = {}) {
|
|
350
344
|
const fetchImpl = config.fetchImpl ?? fetch;
|
|
351
345
|
const baseUrl = config.baseUrl?.replace(/\/+$/, "") ?? "";
|
|
352
346
|
const maxRetries = config.maxRetries ?? 2;
|
|
353
347
|
const requestIdFactory = config.requestIdFactory ?? (() => generatePortableRequestId());
|
|
354
348
|
async function resolveAuthHeaders() {
|
|
355
|
-
const
|
|
356
|
-
const headers = new Headers(provided);
|
|
357
|
-
const setIfAbsent = (name, value) => {
|
|
358
|
-
const normalized = cleanHeaderValue(value);
|
|
359
|
-
if (normalized && !headers.has(name)) {
|
|
360
|
-
headers.set(name, normalized);
|
|
361
|
-
}
|
|
362
|
-
};
|
|
363
|
-
setIfAbsent("x-lucern-key", config.apiKey);
|
|
364
|
-
setIfAbsent("x-lucern-session-token", config.userToken);
|
|
365
|
-
setIfAbsent("x-lucern-environment", config.environment);
|
|
366
|
-
setIfAbsent("x-lucern-clerk-id", config.clerkId);
|
|
367
|
-
setIfAbsent("x-lucern-user-id", config.userId ?? config.clerkId);
|
|
368
|
-
setIfAbsent("x-lucern-deployment-host", config.deploymentHost);
|
|
369
|
-
const base = Object.fromEntries(headers.entries());
|
|
349
|
+
const base = config.getAuthHeaders ? await config.getAuthHeaders() : {};
|
|
370
350
|
const authContextInput = await resolveConfiguredAuthContext(
|
|
371
351
|
config.authContext
|
|
372
352
|
);
|
|
@@ -395,11 +375,11 @@ function createGatewayRequestClient(config = {}) {
|
|
|
395
375
|
if (!text) {
|
|
396
376
|
return null;
|
|
397
377
|
}
|
|
398
|
-
|
|
399
|
-
|
|
378
|
+
try {
|
|
379
|
+
return JSON.parse(text);
|
|
380
|
+
} catch {
|
|
400
381
|
return null;
|
|
401
382
|
}
|
|
402
|
-
return isRecord(parsed.value) ? parsed.value : null;
|
|
403
383
|
}
|
|
404
384
|
function resolveTimeoutMs(method, requestTimeoutMs) {
|
|
405
385
|
if (typeof requestTimeoutMs === "number") {
|
|
@@ -411,31 +391,16 @@ function createGatewayRequestClient(config = {}) {
|
|
|
411
391
|
}
|
|
412
392
|
return config.timeoutMs ?? 15e3;
|
|
413
393
|
}
|
|
414
|
-
function tryParseGatewayEnvelopeJson(text) {
|
|
415
|
-
const trimmed = text.trim();
|
|
416
|
-
if (!trimmed.startsWith("{") && !trimmed.startsWith("[")) {
|
|
417
|
-
return { ok: false, reason: "non-json" };
|
|
418
|
-
}
|
|
419
|
-
try {
|
|
420
|
-
return { ok: true, value: JSON.parse(trimmed) };
|
|
421
|
-
} catch (error) {
|
|
422
|
-
if (error instanceof SyntaxError) {
|
|
423
|
-
return { ok: false, reason: "invalid-json", error };
|
|
424
|
-
}
|
|
425
|
-
throw error;
|
|
426
|
-
}
|
|
427
|
-
}
|
|
428
394
|
function buildApiError(args) {
|
|
429
395
|
const failure = args.failure;
|
|
430
|
-
const legacyError = failure &&
|
|
396
|
+
const legacyError = failure && typeof failure.error === "object" && failure.error !== null ? failure.error : failure?.legacyError;
|
|
431
397
|
const correlationId = failure?.correlationId ?? args.response.headers.get("x-lucern-correlation-id")?.trim() ?? args.requestId;
|
|
432
398
|
const policyTraceId = failure?.policyTraceId ?? args.response.headers.get("x-lucern-policy-trace-id")?.trim() ?? null;
|
|
433
399
|
const details = failure?.details ?? legacyError?.details;
|
|
434
400
|
const policySummary = readPolicySummaryFromDetails(details);
|
|
435
|
-
const failureMessage = typeof failure?.error === "string" ? failure.error : legacyError?.message;
|
|
436
401
|
return new LucernApiError({
|
|
437
402
|
code: failure?.code ?? legacyError?.code ?? fallbackErrorCode(args.response.status),
|
|
438
|
-
message: policySummary ??
|
|
403
|
+
message: policySummary ?? (typeof failure?.error === "string" ? failure.error : legacyError?.message ?? (args.response.ok ? "Platform API returned an invalid success payload." : "Platform API request failed.")),
|
|
439
404
|
status: args.response.status,
|
|
440
405
|
invariant: failure?.invariant,
|
|
441
406
|
suggestion: failure?.suggestion,
|
|
@@ -561,11 +526,8 @@ function createGatewayRequestClient(config = {}) {
|
|
|
561
526
|
}
|
|
562
527
|
|
|
563
528
|
// src/sdkSurface.ts
|
|
564
|
-
function isRecord2(value) {
|
|
565
|
-
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
566
|
-
}
|
|
567
529
|
function asRecord(value) {
|
|
568
|
-
return
|
|
530
|
+
return value && typeof value === "object" ? value : {};
|
|
569
531
|
}
|
|
570
532
|
function cleanString2(value) {
|
|
571
533
|
return typeof value === "string" && value.trim().length > 0 ? value.trim() : void 0;
|
|
@@ -619,10 +581,7 @@ function createListResult(items, legacyKey) {
|
|
|
619
581
|
total: items.length
|
|
620
582
|
};
|
|
621
583
|
if (legacyKey) {
|
|
622
|
-
|
|
623
|
-
...result,
|
|
624
|
-
[legacyKey]: items
|
|
625
|
-
};
|
|
584
|
+
result[legacyKey] = items;
|
|
626
585
|
}
|
|
627
586
|
return result;
|
|
628
587
|
}
|
|
@@ -831,6 +790,12 @@ function createWorkflowClient(config = {}) {
|
|
|
831
790
|
)
|
|
832
791
|
);
|
|
833
792
|
},
|
|
793
|
+
/**
|
|
794
|
+
* @deprecated Use createWorktree.
|
|
795
|
+
*/
|
|
796
|
+
async addWorktree(input, idempotencyKey) {
|
|
797
|
+
return client.createWorktree(input, idempotencyKey);
|
|
798
|
+
},
|
|
834
799
|
/**
|
|
835
800
|
* Merge a worktree into the main belief line.
|
|
836
801
|
*/
|
|
@@ -1028,16 +993,39 @@ function createWorkflowClient(config = {}) {
|
|
|
1028
993
|
body: input,
|
|
1029
994
|
idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
|
|
1030
995
|
});
|
|
996
|
+
},
|
|
997
|
+
/**
|
|
998
|
+
* @deprecated Use createBranch.
|
|
999
|
+
*/
|
|
1000
|
+
async createPillar(input, idempotencyKey) {
|
|
1001
|
+
return client.createBranch(input, idempotencyKey);
|
|
1002
|
+
},
|
|
1003
|
+
/**
|
|
1004
|
+
* @deprecated Use addWorktree.
|
|
1005
|
+
*/
|
|
1006
|
+
async createSprint(input, idempotencyKey) {
|
|
1007
|
+
return client.createWorktree(input, idempotencyKey);
|
|
1008
|
+
},
|
|
1009
|
+
/**
|
|
1010
|
+
* @deprecated Use merge.
|
|
1011
|
+
*/
|
|
1012
|
+
async completeSprint(worktreeId, input, idempotencyKey) {
|
|
1013
|
+
return client.merge(worktreeId, input, idempotencyKey);
|
|
1014
|
+
},
|
|
1015
|
+
/**
|
|
1016
|
+
* @deprecated Use openPullRequest.
|
|
1017
|
+
*/
|
|
1018
|
+
async requestReview(worktreeId, input, idempotencyKey) {
|
|
1019
|
+
return client.openPullRequest(worktreeId, input, idempotencyKey);
|
|
1020
|
+
},
|
|
1021
|
+
/**
|
|
1022
|
+
* @deprecated Use push.
|
|
1023
|
+
*/
|
|
1024
|
+
async publishFindings(worktreeId, input, idempotencyKey) {
|
|
1025
|
+
return client.push(worktreeId, input, idempotencyKey);
|
|
1031
1026
|
}
|
|
1032
1027
|
};
|
|
1033
|
-
return
|
|
1034
|
-
addWorktree: client.createWorktree,
|
|
1035
|
-
createPillar: client.createBranch,
|
|
1036
|
-
createSprint: client.createWorktree,
|
|
1037
|
-
completeSprint: client.merge,
|
|
1038
|
-
requestReview: client.openPullRequest,
|
|
1039
|
-
publishFindings: client.push
|
|
1040
|
-
});
|
|
1028
|
+
return client;
|
|
1041
1029
|
}
|
|
1042
1030
|
|
|
1043
1031
|
export { LucernApiError, createWorkflowClient };
|