@granular-software/sdk 0.4.51 → 0.4.53
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/dist/agent-evals.d.mts +2 -2
- package/dist/agent-evals.d.ts +2 -2
- package/dist/agent-evals.js +285 -31
- package/dist/agent-evals.js.map +1 -1
- package/dist/agent-evals.mjs +285 -31
- package/dist/agent-evals.mjs.map +1 -1
- package/dist/cli/index.js +316 -50
- package/dist/{client-djorlOpn.d.mts → client-CfTDojJF.d.mts} +31 -3
- package/dist/{client-NSH-tpNU.d.ts → client-DcRzwuGp.d.ts} +31 -3
- package/dist/index.d.mts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +285 -31
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +285 -31
- package/dist/index.mjs.map +1 -1
- package/dist/{spend-BA-jZwZ0.d.mts → spend-DpRRCrAr.d.mts} +37 -2
- package/dist/{spend-BA-jZwZ0.d.ts → spend-DpRRCrAr.d.ts} +37 -2
- package/dist/spend.d.mts +1 -1
- package/dist/spend.d.ts +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export { E as Environment, a as EnvironmentSession, G as Granular, O as OntologyHandle, S as Session, W as WSClient } from './client-
|
|
2
|
-
import { E as EndpointMode, T as ToolWithHandler, a as EffectHandlerContext, M as ManifestEffectMetamodelSpec, R as ResolvedEffectBehaviors, S as SessionHeapEntry, b as SessionHeapList, c as SessionHeapSnapshot, P as Prompt, d as SessionTranscriptEntry } from './spend-
|
|
3
|
-
export {
|
|
1
|
+
export { E as Environment, a as EnvironmentSession, G as Granular, O as OntologyHandle, S as Session, W as WSClient } from './client-CfTDojJF.mjs';
|
|
2
|
+
import { E as EndpointMode, T as ToolWithHandler, a as EffectHandlerContext, M as ManifestEffectMetamodelSpec, R as ResolvedEffectBehaviors, S as SessionHeapEntry, b as SessionHeapList, c as SessionHeapSnapshot, P as Prompt, d as SessionTranscriptEntry } from './spend-DpRRCrAr.mjs';
|
|
3
|
+
export { cN as APIError, A as AccessTokenProvider, J as AdoptEnvironmentOptions, bg as ArtifactApprovalDecisionInput, bh as ArtifactApprovalDecisionResult, be as ArtifactApprovalTask, bf as ArtifactApprovalTaskListOptions, bd as ArtifactApprovalTaskStatus, aa as Assignment, ab as AssignmentListResponse, al as Build, an as BuildListResponse, ac as BuildPolicy, ak as BuildStatus, C as ConditionIR, K as ConnectOptions, aV as ConversationActionSuggestion, aZ as ConversationAppendResult, aW as ConversationMessageAction, aY as ConversationMessageInput, aX as ConversationMessagePart, aP as ConversationMessageShowRefs, Q as ConversationSessionInfo, W as ConversationSessionListOptions, V as ConversationSessionListStatus, aQ as ConversationTableCell, aR as ConversationTableColumn, aU as ConversationTableProjection, aT as ConversationTableRow, aS as ConversationTableRowReference, ag as CreateEnvironmentData, a8 as CreatePermissionProfileData, a4 as CreateSandboxData, L as CreateSessionOptions, bV as DefineRelationshipOptions, cO as DeleteResponse, D as DomainState, aE as EffectHandler, aB as EffectInfo, av as EffectInvocationMetadata, au as EffectInvocationMode, aw as EffectSchema, az as EffectVersionSelector, ax as EffectWithHandler, aD as EffectsChangedEvent, af as EnvironmentData, aM as EnvironmentFeedbackRecord, ci as EnvironmentImporter, ch as EnvironmentImporterImportOptions, ah as EnvironmentListResponse, cb as EnvironmentRecordImportSummary, cg as EnvironmentSetupImporterClaim, ce as EnvironmentSetupLifecycleStatus, cf as EnvironmentSetupSummary, cc as EnvironmentSetupTriggerReason, b$ as EnvironmentStateMachineProxy, bZ as EnvironmentStateObservationInput, c0 as EnvironmentStateProxy, bY as EnvironmentStateTarget, b_ as EnvironmentStateUpdateInput, z as GranularAuth, y as GranularOptions, a1 as GranularQuotaPolicy, a2 as GranularQuotaProgress, G as GranularSpendContext, cM as GraphQLResult, aF as InstanceEffectHandler, I as InstanceToolHandler, aO as Job, aK as JobFeedbackInput, aJ as JobFeedbackMetadata, aL as JobFeedbackRecord, aH as JobFeedbackSentiment, aI as JobFeedbackToolCall, aG as JobStatus, aN as JobSubmitResult, ai as Manifest, cB as ManifestApprovalRequiredSpec, cL as ManifestContent, cC as ManifestCreatesSpec, cz as ManifestDryRunSpec, cF as ManifestEffectDeclaration, cE as ManifestEffectSchema, cl as ManifestEnumRuleSpec, cH as ManifestEventStreamDef, cG as ManifestEventTypeDef, cm as ManifestFilterBySpec, cJ as ManifestImport, aj as ManifestListResponse, cI as ManifestOperation, cy as ManifestPostConditionSpec, cj as ManifestPropertySpec, cD as ManifestRelationshipDef, cA as ManifestReverseSpec, cx as ManifestStateMachineSpec, co as ManifestStateMachineStateSpec, cw as ManifestStateMachineTransitionSpec, cq as ManifestStateTransitionActionSpec, cr as ManifestStateTransitionAssigneeSpec, cv as ManifestStateTransitionExpectedOutcomeSpec, cp as ManifestStateTransitionInputBinding, cu as ManifestStateTransitionPermissionSpec, cs as ManifestStateTransitionRelatedStateRequirementSpec, ct as ManifestStateTransitionRequirementsSpec, ck as ManifestValidationOperator, cn as ManifestValidationRuleSpec, cK as ManifestVolume, bp as ManualActionListOptions, bn as ManualActionOccurrence, bo as ManualActionRecordResult, bl as ManualActionRelatedRecord, bj as ManualActionSource, bi as ManualActionStatus, bq as ManualActionSuggestion, br as ManualActionSuggestionOptions, bk as ManualActionTarget, bJ as MarkUserEnvironmentReadOptions, x as MatchedPolicy, bT as ModelRef, N as NormalizedOpenAIUsage, i as OPENAI_MODEL_PRICING_USD_PER_MILLION, O as OpenAIModelPricing, h as OpenAITokenSpend, l as OpenAIUsageSpendEvent, H as OpenEnvironmentOptions, a7 as PermissionProfile, a9 as PermissionProfileListResponse, a6 as PermissionRules, u as PolicyOperator, v as PolicyOrigin, s as PolicyPredicateSource, w as PolicyRuleIR, q as PolicySource, ay as PublishEffectsResult, f as PublishToolsResult, a0 as QuotaLineItemFilter, Z as QuotaPeriod, Y as QuotaScopeType, _ as QuotaStatus, bN as RPCRequest, bQ as RPCRequestFromServer, bO as RPCResponse, ca as RecordImport, c9 as RecordImportItem, c7 as RecordImportItemStatus, c5 as RecordImportOptions, c8 as RecordImportStats, c6 as RecordImportStatus, c4 as RecordImportWriteMode, bm as RecordManualActionInput, bz as RecordMentionInput, bW as RecordObjectOptions, c1 as RecordObjectResult, bX as RecordObjectStateValue, c2 as RecordObjectsChunkInfo, c3 as RecordObjectsOptions, m as RecordOpenAIUsageSpendOptions, o as RecordOpenAIUsageSpendResult, by as RecordSearchOptions, bx as RecordSearchResult, B as RecordUserOptions, bU as RelationshipInfo, at as ResolvedEffectApprovalRequired, ar as ResolvedEffectDryRun, aq as ResolvedEffectPostCondition, as as ResolvedEffectReverse, cd as RunEnvironmentImporterOptions, a3 as Sandbox, a5 as SandboxListResponse, ap as SemanticVersionDiff, ao as SemanticVersionDiffEntry, bc as SessionArtifactApprovalOptions, b6 as SessionArtifactAutonomyPolicy, bb as SessionArtifactExecutionOptions, ba as SessionArtifactExecutionResult, b5 as SessionArtifactKind, b8 as SessionArtifactListOptions, b7 as SessionArtifactRecord, b4 as SessionArtifactStatus, b9 as SessionArtifactValidationResult, bB as SessionCollectionListOptions, bD as SessionCollectionListResult, a_ as SessionConversationMessage, bA as SessionDocumentResult, b1 as SessionFileKind, b3 as SessionFileRecord, b0 as SessionFileSource, b2 as SessionFileStatus, bs as SessionFileUploadOptions, bu as SessionHeapFieldType, bv as SessionHeapFieldValue, bw as SessionHeapVariable, bC as SessionJobListOptions, bt as SessionJobRecord, a$ as SessionTimelineEvent, X as SpendLineItemType, $ as SpendSummary, cP as StreamEvent, cR as StreamStats, cQ as StreamSubscription, F as Subject, bP as SyncMessage, g as ToolHandler, aA as ToolInfo, bR as ToolInvokeParams, bS as ToolResultParams, e as ToolSchema, aC as ToolsChangedEvent, U as User, bF as UserEnvironmentMessagePreview, bE as UserEnvironmentPrompt, bG as UserEnvironmentSessionState, bH as UserEnvironmentState, bI as UserEnvironmentStateOptions, am as Version, ae as VersionTag, ad as VersionTracking, bM as WSClientOptions, bK as WSDisconnectInfo, bL as WSReconnectErrorInfo, p as buildOpenAISpendEventId, k as calculateOpenAITokenSpend, j as getOpenAIModelPricing, n as normalizeOpenAIUsage, r as recordOpenAIUsageSpend, t as toGranularHttpBase } from './spend-DpRRCrAr.mjs';
|
|
4
4
|
export { BuildGranularAgentSystemPromptInput, GeneratedJobCodeIssue, GranularAgentExecutionCheckpoint, GranularAgentHeapSummaryOptions, GranularAgentManualActionMemorySuggestion, GranularAgentPromptCapabilities, GranularAgentReferentFocus, GranularAgentSessionContext, GranularAgentToolInfo, GranularAgentWorkflowFocus, GranularReasoningTraceChunkResult, GranularReasoningTraceOptions, HarnessContinuationDecision, HarnessControllerBudgets, HarnessProjectionOptions, HarnessPromptLike, HarnessRenderedContinuation, HarnessRenderedPrompt, HarnessTemplate, HarnessTemplateManifest, HarnessTemplateSelectionOptions, HarnessTemplateStatus, HarnessVerifierSnapshot, HarnessVerifierSnapshotInput, ReviewGeneratedJobCodeOptions, buildContinuationInstruction, buildContinuationInstructionFromTemplate, buildGranularAgentCheckpointBlock, buildGranularAgentDomainBlock, buildGranularAgentFileBlock, buildGranularAgentHeapBlock, buildGranularAgentLoopBlock, buildGranularAgentManualActionBlock, buildGranularAgentManualActionMemorySummary, buildGranularAgentReferentBlock, buildGranularAgentRuntimeImportsBlock, buildGranularAgentSessionBlock, buildGranularAgentSystemPrompt, buildGranularAgentSystemPromptFromTemplate, buildGranularAgentToolBlock, buildGranularAgentWorkflowBlock, consumeGranularReasoningOnlyChunk, consumeGranularReasoningTraceChunk, createHarnessVerifierSnapshot, evaluateContinuation, getCurrentClosureId, getDefaultHarnessTemplateId, getExclusivePromptTarget, hasOpenPrompt, hashHarnessTemplateValue, listHarnessTemplates, projectConversationReferentFocus, projectConversationReferentSummary, projectHeapSummary, projectLoopSummary, projectSessionFileSummary, projectWorkflowFocus, projectWorkflowSummary, renderContinuationInstructionFromTemplate, renderGranularAgentSystemPromptFromTemplate, resolveHarnessTemplate, reviewGeneratedJobCode, stripGranularReasoningTrace, validateHarnessTemplateManifest } from './agent-harness.mjs';
|
|
5
5
|
import '@automerge/automerge';
|
|
6
6
|
import '@automerge/automerge/slim';
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export { E as Environment, a as EnvironmentSession, G as Granular, O as OntologyHandle, S as Session, W as WSClient } from './client-
|
|
2
|
-
import { E as EndpointMode, T as ToolWithHandler, a as EffectHandlerContext, M as ManifestEffectMetamodelSpec, R as ResolvedEffectBehaviors, S as SessionHeapEntry, b as SessionHeapList, c as SessionHeapSnapshot, P as Prompt, d as SessionTranscriptEntry } from './spend-
|
|
3
|
-
export {
|
|
1
|
+
export { E as Environment, a as EnvironmentSession, G as Granular, O as OntologyHandle, S as Session, W as WSClient } from './client-DcRzwuGp.js';
|
|
2
|
+
import { E as EndpointMode, T as ToolWithHandler, a as EffectHandlerContext, M as ManifestEffectMetamodelSpec, R as ResolvedEffectBehaviors, S as SessionHeapEntry, b as SessionHeapList, c as SessionHeapSnapshot, P as Prompt, d as SessionTranscriptEntry } from './spend-DpRRCrAr.js';
|
|
3
|
+
export { cN as APIError, A as AccessTokenProvider, J as AdoptEnvironmentOptions, bg as ArtifactApprovalDecisionInput, bh as ArtifactApprovalDecisionResult, be as ArtifactApprovalTask, bf as ArtifactApprovalTaskListOptions, bd as ArtifactApprovalTaskStatus, aa as Assignment, ab as AssignmentListResponse, al as Build, an as BuildListResponse, ac as BuildPolicy, ak as BuildStatus, C as ConditionIR, K as ConnectOptions, aV as ConversationActionSuggestion, aZ as ConversationAppendResult, aW as ConversationMessageAction, aY as ConversationMessageInput, aX as ConversationMessagePart, aP as ConversationMessageShowRefs, Q as ConversationSessionInfo, W as ConversationSessionListOptions, V as ConversationSessionListStatus, aQ as ConversationTableCell, aR as ConversationTableColumn, aU as ConversationTableProjection, aT as ConversationTableRow, aS as ConversationTableRowReference, ag as CreateEnvironmentData, a8 as CreatePermissionProfileData, a4 as CreateSandboxData, L as CreateSessionOptions, bV as DefineRelationshipOptions, cO as DeleteResponse, D as DomainState, aE as EffectHandler, aB as EffectInfo, av as EffectInvocationMetadata, au as EffectInvocationMode, aw as EffectSchema, az as EffectVersionSelector, ax as EffectWithHandler, aD as EffectsChangedEvent, af as EnvironmentData, aM as EnvironmentFeedbackRecord, ci as EnvironmentImporter, ch as EnvironmentImporterImportOptions, ah as EnvironmentListResponse, cb as EnvironmentRecordImportSummary, cg as EnvironmentSetupImporterClaim, ce as EnvironmentSetupLifecycleStatus, cf as EnvironmentSetupSummary, cc as EnvironmentSetupTriggerReason, b$ as EnvironmentStateMachineProxy, bZ as EnvironmentStateObservationInput, c0 as EnvironmentStateProxy, bY as EnvironmentStateTarget, b_ as EnvironmentStateUpdateInput, z as GranularAuth, y as GranularOptions, a1 as GranularQuotaPolicy, a2 as GranularQuotaProgress, G as GranularSpendContext, cM as GraphQLResult, aF as InstanceEffectHandler, I as InstanceToolHandler, aO as Job, aK as JobFeedbackInput, aJ as JobFeedbackMetadata, aL as JobFeedbackRecord, aH as JobFeedbackSentiment, aI as JobFeedbackToolCall, aG as JobStatus, aN as JobSubmitResult, ai as Manifest, cB as ManifestApprovalRequiredSpec, cL as ManifestContent, cC as ManifestCreatesSpec, cz as ManifestDryRunSpec, cF as ManifestEffectDeclaration, cE as ManifestEffectSchema, cl as ManifestEnumRuleSpec, cH as ManifestEventStreamDef, cG as ManifestEventTypeDef, cm as ManifestFilterBySpec, cJ as ManifestImport, aj as ManifestListResponse, cI as ManifestOperation, cy as ManifestPostConditionSpec, cj as ManifestPropertySpec, cD as ManifestRelationshipDef, cA as ManifestReverseSpec, cx as ManifestStateMachineSpec, co as ManifestStateMachineStateSpec, cw as ManifestStateMachineTransitionSpec, cq as ManifestStateTransitionActionSpec, cr as ManifestStateTransitionAssigneeSpec, cv as ManifestStateTransitionExpectedOutcomeSpec, cp as ManifestStateTransitionInputBinding, cu as ManifestStateTransitionPermissionSpec, cs as ManifestStateTransitionRelatedStateRequirementSpec, ct as ManifestStateTransitionRequirementsSpec, ck as ManifestValidationOperator, cn as ManifestValidationRuleSpec, cK as ManifestVolume, bp as ManualActionListOptions, bn as ManualActionOccurrence, bo as ManualActionRecordResult, bl as ManualActionRelatedRecord, bj as ManualActionSource, bi as ManualActionStatus, bq as ManualActionSuggestion, br as ManualActionSuggestionOptions, bk as ManualActionTarget, bJ as MarkUserEnvironmentReadOptions, x as MatchedPolicy, bT as ModelRef, N as NormalizedOpenAIUsage, i as OPENAI_MODEL_PRICING_USD_PER_MILLION, O as OpenAIModelPricing, h as OpenAITokenSpend, l as OpenAIUsageSpendEvent, H as OpenEnvironmentOptions, a7 as PermissionProfile, a9 as PermissionProfileListResponse, a6 as PermissionRules, u as PolicyOperator, v as PolicyOrigin, s as PolicyPredicateSource, w as PolicyRuleIR, q as PolicySource, ay as PublishEffectsResult, f as PublishToolsResult, a0 as QuotaLineItemFilter, Z as QuotaPeriod, Y as QuotaScopeType, _ as QuotaStatus, bN as RPCRequest, bQ as RPCRequestFromServer, bO as RPCResponse, ca as RecordImport, c9 as RecordImportItem, c7 as RecordImportItemStatus, c5 as RecordImportOptions, c8 as RecordImportStats, c6 as RecordImportStatus, c4 as RecordImportWriteMode, bm as RecordManualActionInput, bz as RecordMentionInput, bW as RecordObjectOptions, c1 as RecordObjectResult, bX as RecordObjectStateValue, c2 as RecordObjectsChunkInfo, c3 as RecordObjectsOptions, m as RecordOpenAIUsageSpendOptions, o as RecordOpenAIUsageSpendResult, by as RecordSearchOptions, bx as RecordSearchResult, B as RecordUserOptions, bU as RelationshipInfo, at as ResolvedEffectApprovalRequired, ar as ResolvedEffectDryRun, aq as ResolvedEffectPostCondition, as as ResolvedEffectReverse, cd as RunEnvironmentImporterOptions, a3 as Sandbox, a5 as SandboxListResponse, ap as SemanticVersionDiff, ao as SemanticVersionDiffEntry, bc as SessionArtifactApprovalOptions, b6 as SessionArtifactAutonomyPolicy, bb as SessionArtifactExecutionOptions, ba as SessionArtifactExecutionResult, b5 as SessionArtifactKind, b8 as SessionArtifactListOptions, b7 as SessionArtifactRecord, b4 as SessionArtifactStatus, b9 as SessionArtifactValidationResult, bB as SessionCollectionListOptions, bD as SessionCollectionListResult, a_ as SessionConversationMessage, bA as SessionDocumentResult, b1 as SessionFileKind, b3 as SessionFileRecord, b0 as SessionFileSource, b2 as SessionFileStatus, bs as SessionFileUploadOptions, bu as SessionHeapFieldType, bv as SessionHeapFieldValue, bw as SessionHeapVariable, bC as SessionJobListOptions, bt as SessionJobRecord, a$ as SessionTimelineEvent, X as SpendLineItemType, $ as SpendSummary, cP as StreamEvent, cR as StreamStats, cQ as StreamSubscription, F as Subject, bP as SyncMessage, g as ToolHandler, aA as ToolInfo, bR as ToolInvokeParams, bS as ToolResultParams, e as ToolSchema, aC as ToolsChangedEvent, U as User, bF as UserEnvironmentMessagePreview, bE as UserEnvironmentPrompt, bG as UserEnvironmentSessionState, bH as UserEnvironmentState, bI as UserEnvironmentStateOptions, am as Version, ae as VersionTag, ad as VersionTracking, bM as WSClientOptions, bK as WSDisconnectInfo, bL as WSReconnectErrorInfo, p as buildOpenAISpendEventId, k as calculateOpenAITokenSpend, j as getOpenAIModelPricing, n as normalizeOpenAIUsage, r as recordOpenAIUsageSpend, t as toGranularHttpBase } from './spend-DpRRCrAr.js';
|
|
4
4
|
export { BuildGranularAgentSystemPromptInput, GeneratedJobCodeIssue, GranularAgentExecutionCheckpoint, GranularAgentHeapSummaryOptions, GranularAgentManualActionMemorySuggestion, GranularAgentPromptCapabilities, GranularAgentReferentFocus, GranularAgentSessionContext, GranularAgentToolInfo, GranularAgentWorkflowFocus, GranularReasoningTraceChunkResult, GranularReasoningTraceOptions, HarnessContinuationDecision, HarnessControllerBudgets, HarnessProjectionOptions, HarnessPromptLike, HarnessRenderedContinuation, HarnessRenderedPrompt, HarnessTemplate, HarnessTemplateManifest, HarnessTemplateSelectionOptions, HarnessTemplateStatus, HarnessVerifierSnapshot, HarnessVerifierSnapshotInput, ReviewGeneratedJobCodeOptions, buildContinuationInstruction, buildContinuationInstructionFromTemplate, buildGranularAgentCheckpointBlock, buildGranularAgentDomainBlock, buildGranularAgentFileBlock, buildGranularAgentHeapBlock, buildGranularAgentLoopBlock, buildGranularAgentManualActionBlock, buildGranularAgentManualActionMemorySummary, buildGranularAgentReferentBlock, buildGranularAgentRuntimeImportsBlock, buildGranularAgentSessionBlock, buildGranularAgentSystemPrompt, buildGranularAgentSystemPromptFromTemplate, buildGranularAgentToolBlock, buildGranularAgentWorkflowBlock, consumeGranularReasoningOnlyChunk, consumeGranularReasoningTraceChunk, createHarnessVerifierSnapshot, evaluateContinuation, getCurrentClosureId, getDefaultHarnessTemplateId, getExclusivePromptTarget, hasOpenPrompt, hashHarnessTemplateValue, listHarnessTemplates, projectConversationReferentFocus, projectConversationReferentSummary, projectHeapSummary, projectLoopSummary, projectSessionFileSummary, projectWorkflowFocus, projectWorkflowSummary, renderContinuationInstructionFromTemplate, renderGranularAgentSystemPromptFromTemplate, resolveHarnessTemplate, reviewGeneratedJobCode, stripGranularReasoningTrace, validateHarnessTemplateManifest } from './agent-harness.js';
|
|
5
5
|
import '@automerge/automerge';
|
|
6
6
|
import '@automerge/automerge/slim';
|
package/dist/index.js
CHANGED
|
@@ -14309,7 +14309,8 @@ function normalizeEnvironmentSetupSummary(setup) {
|
|
|
14309
14309
|
environmentId: String(setup.environmentId || ""),
|
|
14310
14310
|
sandboxId: String(setup.sandboxId || ""),
|
|
14311
14311
|
subjectId: String(setup.subjectId || ""),
|
|
14312
|
-
triggerReason: setup.triggerReason === "fresh_after_version_update" ? "fresh_after_version_update" : "new_environment",
|
|
14312
|
+
triggerReason: setup.triggerReason === "fresh_after_version_update" ? "fresh_after_version_update" : setup.triggerReason === "explicit_reset" ? "explicit_reset" : "new_environment",
|
|
14313
|
+
operationKey: typeof setup.operationKey === "string" ? setup.operationKey : null,
|
|
14313
14314
|
lifecycleStatus: setup.lifecycleStatus === "completed" || setup.lifecycleStatus === "failed" ? setup.lifecycleStatus : "running",
|
|
14314
14315
|
stage: typeof setup.stage === "string" ? setup.stage : null,
|
|
14315
14316
|
totalObjectsToImport: Number(setup.totalObjectsToImport || 0),
|
|
@@ -15591,6 +15592,7 @@ var Environment = class _Environment {
|
|
|
15591
15592
|
records: recordsToImport,
|
|
15592
15593
|
batchSize: options.batchSize,
|
|
15593
15594
|
setupRunId: options.setupRunId,
|
|
15595
|
+
operationKey: options.operationKey,
|
|
15594
15596
|
writeMode: options.writeMode
|
|
15595
15597
|
})
|
|
15596
15598
|
}
|
|
@@ -16395,6 +16397,156 @@ var Granular = class _Granular {
|
|
|
16395
16397
|
await this.maybeRunEnvironmentImporter(resolved, environment);
|
|
16396
16398
|
return environment;
|
|
16397
16399
|
}
|
|
16400
|
+
/**
|
|
16401
|
+
* Read the active environment selected by Granular for an already-recorded
|
|
16402
|
+
* external user. This is intentionally read-only: browser/login code must
|
|
16403
|
+
* not create subjects or environments as a side effect.
|
|
16404
|
+
*/
|
|
16405
|
+
async getActiveEnvironmentForUser(options) {
|
|
16406
|
+
const sandboxId = options.sandboxId.trim();
|
|
16407
|
+
const tagName = options.tag.trim();
|
|
16408
|
+
const userId = options.userId.trim();
|
|
16409
|
+
if (!sandboxId || !tagName || !userId) {
|
|
16410
|
+
throw new Error(
|
|
16411
|
+
"getActiveEnvironmentForUser() requires sandboxId, tag, and userId."
|
|
16412
|
+
);
|
|
16413
|
+
}
|
|
16414
|
+
const subjects = await this.request(
|
|
16415
|
+
`/control/subjects?identityId=${encodeURIComponent(userId)}`
|
|
16416
|
+
);
|
|
16417
|
+
const subject = (subjects.items || []).find(
|
|
16418
|
+
(item) => item.identityId === userId || item.userId === userId
|
|
16419
|
+
);
|
|
16420
|
+
if (!subject?.subjectId && !subject?.granularId) {
|
|
16421
|
+
return null;
|
|
16422
|
+
}
|
|
16423
|
+
const subjectId = subject.subjectId || subject.granularId;
|
|
16424
|
+
const tags = await this.request(
|
|
16425
|
+
`/control/sandboxes/${encodeURIComponent(sandboxId)}/tags`
|
|
16426
|
+
);
|
|
16427
|
+
const tag = (tags.items || []).find(
|
|
16428
|
+
(item) => item?.name === tagName
|
|
16429
|
+
);
|
|
16430
|
+
if (!tag) return null;
|
|
16431
|
+
const query = new URLSearchParams({
|
|
16432
|
+
tagId: tag.tagId,
|
|
16433
|
+
slot: options.slot?.trim() || "default"
|
|
16434
|
+
});
|
|
16435
|
+
try {
|
|
16436
|
+
const payload = await this.request(
|
|
16437
|
+
`/control/sandboxes/${encodeURIComponent(sandboxId)}/subjects/${encodeURIComponent(subjectId)}/active-environment?${query.toString()}`
|
|
16438
|
+
);
|
|
16439
|
+
return payload.environment ? this.bindEnvironmentHandle(
|
|
16440
|
+
normalizeEnvironmentData(payload.environment)
|
|
16441
|
+
) : null;
|
|
16442
|
+
} catch (error) {
|
|
16443
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
16444
|
+
if (message.includes("404") || message.includes("not found")) {
|
|
16445
|
+
return null;
|
|
16446
|
+
}
|
|
16447
|
+
throw error;
|
|
16448
|
+
}
|
|
16449
|
+
}
|
|
16450
|
+
/**
|
|
16451
|
+
* Resolve one exact environment only when Granular confirms that it belongs
|
|
16452
|
+
* to the given external user in the requested sandbox (and, optionally,
|
|
16453
|
+
* tag). This is deliberately read-only: callers use it to keep an already
|
|
16454
|
+
* opened delegated workspace stable while a newer active environment is
|
|
16455
|
+
* being prepared in the background.
|
|
16456
|
+
*/
|
|
16457
|
+
async getEnvironmentForUser(options) {
|
|
16458
|
+
const sandboxId = options.sandboxId.trim();
|
|
16459
|
+
const userId = options.userId.trim();
|
|
16460
|
+
const environmentId = options.environmentId.trim();
|
|
16461
|
+
const tagName = options.tag?.trim();
|
|
16462
|
+
if (!sandboxId || !userId || !environmentId) {
|
|
16463
|
+
throw new Error(
|
|
16464
|
+
"getEnvironmentForUser() requires sandboxId, userId, and environmentId."
|
|
16465
|
+
);
|
|
16466
|
+
}
|
|
16467
|
+
const subjects = await this.request(
|
|
16468
|
+
`/control/subjects?identityId=${encodeURIComponent(userId)}`
|
|
16469
|
+
);
|
|
16470
|
+
const subject = (subjects.items || []).find(
|
|
16471
|
+
(item) => item.identityId === userId || item.userId === userId
|
|
16472
|
+
);
|
|
16473
|
+
const subjectId = subject?.subjectId || subject?.granularId;
|
|
16474
|
+
if (!subjectId) return null;
|
|
16475
|
+
let environment;
|
|
16476
|
+
try {
|
|
16477
|
+
environment = await this.environments.get(environmentId);
|
|
16478
|
+
} catch (error) {
|
|
16479
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
16480
|
+
if (message.includes("404") || message.includes("not found")) {
|
|
16481
|
+
return null;
|
|
16482
|
+
}
|
|
16483
|
+
throw error;
|
|
16484
|
+
}
|
|
16485
|
+
if (environment.sandboxId !== sandboxId || environment.subjectId !== subjectId) {
|
|
16486
|
+
return null;
|
|
16487
|
+
}
|
|
16488
|
+
if (tagName) {
|
|
16489
|
+
const tags = await this.request(`/control/sandboxes/${encodeURIComponent(sandboxId)}/tags`);
|
|
16490
|
+
const tag = (tags.items || []).find(
|
|
16491
|
+
(candidate) => candidate?.name === tagName
|
|
16492
|
+
);
|
|
16493
|
+
if (!tag || environment.tagId !== tag.tagId) {
|
|
16494
|
+
return null;
|
|
16495
|
+
}
|
|
16496
|
+
}
|
|
16497
|
+
return this.bindEnvironmentHandle(environment);
|
|
16498
|
+
}
|
|
16499
|
+
/**
|
|
16500
|
+
* Register one reviewed, pre-existing environment as the active workspace
|
|
16501
|
+
* for an external user. This is for a controlled migration only: it does
|
|
16502
|
+
* not create an environment and it does not run an importer.
|
|
16503
|
+
*/
|
|
16504
|
+
async adoptEnvironmentForUser(options) {
|
|
16505
|
+
const sandboxId = options.sandboxId.trim();
|
|
16506
|
+
const tagName = options.tag.trim();
|
|
16507
|
+
const userId = options.userId.trim();
|
|
16508
|
+
const environmentId = options.environmentId.trim();
|
|
16509
|
+
if (!sandboxId || !tagName || !userId || !environmentId) {
|
|
16510
|
+
throw new Error(
|
|
16511
|
+
"adoptEnvironmentForUser() requires sandboxId, tag, userId, and environmentId."
|
|
16512
|
+
);
|
|
16513
|
+
}
|
|
16514
|
+
const subjects = await this.request(
|
|
16515
|
+
`/control/subjects?identityId=${encodeURIComponent(userId)}`
|
|
16516
|
+
);
|
|
16517
|
+
const subject = (subjects.items || []).find(
|
|
16518
|
+
(item) => item.identityId === userId || item.userId === userId
|
|
16519
|
+
);
|
|
16520
|
+
if (!subject?.subjectId && !subject?.granularId) {
|
|
16521
|
+
throw new Error(`No Granular subject exists for user ${userId}.`);
|
|
16522
|
+
}
|
|
16523
|
+
const tags = await this.request(`/control/sandboxes/${encodeURIComponent(sandboxId)}/tags`);
|
|
16524
|
+
const tag = (tags.items || []).find(
|
|
16525
|
+
(item) => item?.name === tagName
|
|
16526
|
+
);
|
|
16527
|
+
if (!tag) {
|
|
16528
|
+
throw new Error(`Tag ${tagName} was not found in sandbox ${sandboxId}.`);
|
|
16529
|
+
}
|
|
16530
|
+
const payload = await this.request(
|
|
16531
|
+
"/control/environment-activations/adopt",
|
|
16532
|
+
{
|
|
16533
|
+
method: "POST",
|
|
16534
|
+
body: JSON.stringify({
|
|
16535
|
+
environmentId,
|
|
16536
|
+
subjectId: subject.subjectId || subject.granularId,
|
|
16537
|
+
tagId: tag.tagId,
|
|
16538
|
+
slot: options.slot?.trim() || "default",
|
|
16539
|
+
confirmExistingData: true
|
|
16540
|
+
})
|
|
16541
|
+
}
|
|
16542
|
+
);
|
|
16543
|
+
if (!payload.environment) {
|
|
16544
|
+
throw new Error("Granular did not return the adopted environment.");
|
|
16545
|
+
}
|
|
16546
|
+
return this.bindEnvironmentHandle(
|
|
16547
|
+
normalizeEnvironmentData(payload.environment)
|
|
16548
|
+
);
|
|
16549
|
+
}
|
|
16398
16550
|
/**
|
|
16399
16551
|
* Deprecated compatibility alias for `openEnvironment()`.
|
|
16400
16552
|
*
|
|
@@ -16426,7 +16578,9 @@ var Granular = class _Granular {
|
|
|
16426
16578
|
requestedOntology,
|
|
16427
16579
|
sandboxId: environmentData.sandboxId,
|
|
16428
16580
|
subjectId: environmentData.subjectId,
|
|
16429
|
-
|
|
16581
|
+
externalUserId: environmentData.subjectId,
|
|
16582
|
+
setupTriggerReason: options.reason || "new_environment",
|
|
16583
|
+
setupOperationKey: options.operationKey
|
|
16430
16584
|
},
|
|
16431
16585
|
environment
|
|
16432
16586
|
);
|
|
@@ -16438,20 +16592,17 @@ var Granular = class _Granular {
|
|
|
16438
16592
|
}
|
|
16439
16593
|
return tag;
|
|
16440
16594
|
}
|
|
16441
|
-
buildManagedEnvironmentName(tag, versionId) {
|
|
16442
|
-
|
|
16595
|
+
buildManagedEnvironmentName(tag, versionId, resetKey) {
|
|
16596
|
+
if (!resetKey) {
|
|
16597
|
+
return `__sdk__${tag}__${versionId}__tracked`;
|
|
16598
|
+
}
|
|
16599
|
+
const safeResetKey = resetKey.replace(/[^a-zA-Z0-9_-]/g, "_").slice(0, 80);
|
|
16600
|
+
return `__sdk__${tag}__${versionId}__reset__${safeResetKey}`;
|
|
16443
16601
|
}
|
|
16444
16602
|
isManagedEnvironmentName(environment, tagName) {
|
|
16445
16603
|
const name = environment.environment || environment.envName || "";
|
|
16446
16604
|
return name.startsWith(`__sdk__${tagName}__`);
|
|
16447
16605
|
}
|
|
16448
|
-
isPinnedToVersion(environment, versionId) {
|
|
16449
|
-
return environment.buildPolicy.mode === "pinned" && (environment.versionId === versionId || environment.buildPolicy.versionId === versionId || environment.buildPolicy.buildId === versionId);
|
|
16450
|
-
}
|
|
16451
|
-
matchesTagTrackedEnvironment(environment, tagName, tagId) {
|
|
16452
|
-
const environmentTagName = environment.tag?.name || environment.buildPolicy.tagName || null;
|
|
16453
|
-
return environment.tagId === tagId || environmentTagName === tagName || environment.environment === tagName || environment.envName === tagName || environment.environment === this.buildManagedEnvironmentName(tagName, environment.versionId) || environment.envName === this.buildManagedEnvironmentName(tagName, environment.versionId);
|
|
16454
|
-
}
|
|
16455
16606
|
sortEnvironmentsByRecency(environments) {
|
|
16456
16607
|
return [...environments].sort(
|
|
16457
16608
|
(left, right) => right.updatedAt - left.updatedAt
|
|
@@ -16501,48 +16652,119 @@ var Granular = class _Granular {
|
|
|
16501
16652
|
`Tag "${tagName}" does not currently point to a build/version.`
|
|
16502
16653
|
);
|
|
16503
16654
|
}
|
|
16655
|
+
const slot = options.slot?.trim() || "default";
|
|
16656
|
+
const resetKey = options.resetKey?.trim() || void 0;
|
|
16657
|
+
const resolveActive = async (operationKey) => {
|
|
16658
|
+
const query = new URLSearchParams({ tagId: tag.tagId, slot });
|
|
16659
|
+
if (operationKey) query.set("operationKey", operationKey);
|
|
16660
|
+
try {
|
|
16661
|
+
const payload = await this.request(
|
|
16662
|
+
`/control/sandboxes/${encodeURIComponent(sandbox.sandboxId)}/subjects/${encodeURIComponent(user.granularId)}/active-environment?${query.toString()}`
|
|
16663
|
+
);
|
|
16664
|
+
return payload.environment ? normalizeEnvironmentData(payload.environment) : null;
|
|
16665
|
+
} catch (error) {
|
|
16666
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
16667
|
+
if (message.includes("404") || message.includes("not found")) {
|
|
16668
|
+
return null;
|
|
16669
|
+
}
|
|
16670
|
+
throw error;
|
|
16671
|
+
}
|
|
16672
|
+
};
|
|
16673
|
+
const activate = async (environment2) => {
|
|
16674
|
+
const payload = await this.request(
|
|
16675
|
+
"/control/environment-activations",
|
|
16676
|
+
{
|
|
16677
|
+
method: "POST",
|
|
16678
|
+
body: JSON.stringify({
|
|
16679
|
+
environmentId: environment2.environmentId,
|
|
16680
|
+
tagId: tag.tagId,
|
|
16681
|
+
slot,
|
|
16682
|
+
operationKey: resetKey,
|
|
16683
|
+
operation: resetKey ? "explicit_reset" : void 0
|
|
16684
|
+
})
|
|
16685
|
+
}
|
|
16686
|
+
);
|
|
16687
|
+
return normalizeEnvironmentData(payload.environment);
|
|
16688
|
+
};
|
|
16689
|
+
if (resetKey) {
|
|
16690
|
+
const resetEnvironment = await resolveActive(resetKey);
|
|
16691
|
+
if (resetEnvironment) {
|
|
16692
|
+
return {
|
|
16693
|
+
environment: resetEnvironment,
|
|
16694
|
+
requestedOntology: ontology,
|
|
16695
|
+
sandboxId: sandbox.sandboxId,
|
|
16696
|
+
subjectId: user.granularId,
|
|
16697
|
+
externalUserId: user.userId,
|
|
16698
|
+
// Retrying an explicit reset must also resume its durable setup run.
|
|
16699
|
+
// Otherwise a Container crash after queue submission would leave a
|
|
16700
|
+
// valid environment permanently marked as "running".
|
|
16701
|
+
setupTriggerReason: "explicit_reset",
|
|
16702
|
+
setupOperationKey: resetKey
|
|
16703
|
+
};
|
|
16704
|
+
}
|
|
16705
|
+
} else {
|
|
16706
|
+
const active = await resolveActive();
|
|
16707
|
+
if (active && (active.versionId === targetVersionId || options.createFreshIfOutdated !== true)) {
|
|
16708
|
+
return {
|
|
16709
|
+
environment: active,
|
|
16710
|
+
requestedOntology: ontology,
|
|
16711
|
+
sandboxId: sandbox.sandboxId,
|
|
16712
|
+
subjectId: user.granularId,
|
|
16713
|
+
externalUserId: user.userId
|
|
16714
|
+
};
|
|
16715
|
+
}
|
|
16716
|
+
}
|
|
16504
16717
|
const allEnvironments = await this.environments.list(sandbox.sandboxId);
|
|
16505
16718
|
const userEnvironments = allEnvironments.filter(
|
|
16506
|
-
(
|
|
16719
|
+
(environment2) => environment2.subjectId === user.granularId
|
|
16507
16720
|
);
|
|
16508
16721
|
const currentMatches = this.sortEnvironmentsByRecency(
|
|
16509
16722
|
userEnvironments.filter(
|
|
16510
|
-
(
|
|
16723
|
+
(environment2) => environment2.tagId === tag.tagId && environment2.versionId === targetVersionId
|
|
16511
16724
|
)
|
|
16512
16725
|
);
|
|
16513
|
-
if (currentMatches.length > 0) {
|
|
16726
|
+
if (!resetKey && currentMatches.length > 0) {
|
|
16727
|
+
const environment2 = await activate(currentMatches[0]);
|
|
16514
16728
|
return {
|
|
16515
|
-
environment:
|
|
16729
|
+
environment: environment2,
|
|
16516
16730
|
requestedOntology: ontology,
|
|
16517
16731
|
sandboxId: sandbox.sandboxId,
|
|
16518
|
-
subjectId: user.granularId
|
|
16732
|
+
subjectId: user.granularId,
|
|
16733
|
+
externalUserId: user.userId
|
|
16519
16734
|
};
|
|
16520
16735
|
}
|
|
16521
16736
|
const outdatedMatches = this.sortEnvironmentsByRecency(
|
|
16522
|
-
userEnvironments.filter(
|
|
16523
|
-
(environment) => this.matchesTagTrackedEnvironment(environment, tagName, tag.tagId)
|
|
16524
|
-
)
|
|
16737
|
+
userEnvironments.filter((environment2) => environment2.tagId === tag.tagId)
|
|
16525
16738
|
);
|
|
16526
16739
|
if (outdatedMatches.length > 0 && options.createFreshIfOutdated !== true) {
|
|
16740
|
+
const environment2 = await activate(outdatedMatches[0]);
|
|
16527
16741
|
return {
|
|
16528
|
-
environment:
|
|
16742
|
+
environment: environment2,
|
|
16529
16743
|
requestedOntology: ontology,
|
|
16530
16744
|
sandboxId: sandbox.sandboxId,
|
|
16531
|
-
subjectId: user.granularId
|
|
16745
|
+
subjectId: user.granularId,
|
|
16746
|
+
externalUserId: user.userId
|
|
16532
16747
|
};
|
|
16533
16748
|
}
|
|
16749
|
+
const created = await this.environments.create(sandbox.sandboxId, {
|
|
16750
|
+
subjectId: user.granularId,
|
|
16751
|
+
environment: this.buildManagedEnvironmentName(
|
|
16752
|
+
tagName,
|
|
16753
|
+
targetVersionId,
|
|
16754
|
+
resetKey
|
|
16755
|
+
),
|
|
16756
|
+
tagId: tag.tagId,
|
|
16757
|
+
permissionProfileId: null
|
|
16758
|
+
});
|
|
16759
|
+
const environment = await activate(created);
|
|
16534
16760
|
return {
|
|
16535
|
-
environment
|
|
16536
|
-
subjectId: user.granularId,
|
|
16537
|
-
environment: this.buildManagedEnvironmentName(tagName, targetVersionId),
|
|
16538
|
-
tagId: tag.tagId,
|
|
16539
|
-
versionId: targetVersionId,
|
|
16540
|
-
permissionProfileId: null
|
|
16541
|
-
}),
|
|
16761
|
+
environment,
|
|
16542
16762
|
requestedOntology: ontology,
|
|
16543
16763
|
sandboxId: sandbox.sandboxId,
|
|
16544
16764
|
subjectId: user.granularId,
|
|
16545
|
-
|
|
16765
|
+
externalUserId: user.userId,
|
|
16766
|
+
setupTriggerReason: resetKey ? "explicit_reset" : outdatedMatches.length > 0 ? "fresh_after_version_update" : "new_environment",
|
|
16767
|
+
setupOperationKey: resetKey
|
|
16546
16768
|
};
|
|
16547
16769
|
}
|
|
16548
16770
|
/**
|
|
@@ -16821,11 +17043,24 @@ var Granular = class _Granular {
|
|
|
16821
17043
|
{
|
|
16822
17044
|
method: "POST",
|
|
16823
17045
|
body: JSON.stringify({
|
|
16824
|
-
triggerReason: resolved.setupTriggerReason
|
|
17046
|
+
triggerReason: resolved.setupTriggerReason,
|
|
17047
|
+
operationKey: resolved.setupOperationKey
|
|
16825
17048
|
})
|
|
16826
17049
|
}
|
|
16827
17050
|
);
|
|
16828
17051
|
const setupRunId = setupRun.setupRunId;
|
|
17052
|
+
let claim = null;
|
|
17053
|
+
for (let attempt = 0; attempt < 3; attempt += 1) {
|
|
17054
|
+
claim = await this.request(
|
|
17055
|
+
`/control/environment-setup-runs/${setupRunId}/importer-claim`,
|
|
17056
|
+
{ method: "POST", body: JSON.stringify({}) }
|
|
17057
|
+
);
|
|
17058
|
+
if (claim.action !== "busy") break;
|
|
17059
|
+
await sleep(Math.min(3e4, Math.max(250, claim.retryAfterMs || 1e3)));
|
|
17060
|
+
}
|
|
17061
|
+
if (!claim) {
|
|
17062
|
+
throw new Error(`Unable to claim environment setup run ${setupRunId}.`);
|
|
17063
|
+
}
|
|
16829
17064
|
const updateSetupRun = async (patch) => {
|
|
16830
17065
|
await this.request(
|
|
16831
17066
|
`/control/environment-setup-runs/${setupRunId}`,
|
|
@@ -16835,10 +17070,26 @@ var Granular = class _Granular {
|
|
|
16835
17070
|
}
|
|
16836
17071
|
);
|
|
16837
17072
|
};
|
|
17073
|
+
if (claim.action === "submitted") {
|
|
17074
|
+
const completedSetupRun = await this.request(
|
|
17075
|
+
`/control/environment-setup-runs/${setupRunId}`,
|
|
17076
|
+
{ method: "PATCH", body: JSON.stringify({ markHookCompleted: true }) }
|
|
17077
|
+
);
|
|
17078
|
+
const refreshedEnvironment = await this.environments.get(
|
|
17079
|
+
environment.environmentId
|
|
17080
|
+
);
|
|
17081
|
+
environment.syncEnvironmentData(refreshedEnvironment);
|
|
17082
|
+
return completedSetupRun;
|
|
17083
|
+
}
|
|
17084
|
+
if (claim.action === "busy" || claim.action === "terminal") {
|
|
17085
|
+
return claim.summary;
|
|
17086
|
+
}
|
|
17087
|
+
let importSequence = 0;
|
|
16838
17088
|
const importerContext = {
|
|
16839
17089
|
environmentId: environment.environmentId,
|
|
16840
17090
|
sandboxId: environment.sandboxId,
|
|
16841
17091
|
subjectId: environment.subjectId,
|
|
17092
|
+
externalUserId: resolved.externalUserId,
|
|
16842
17093
|
reason: resolved.setupTriggerReason,
|
|
16843
17094
|
incrementTotalObjectsToImportCount: async (n) => {
|
|
16844
17095
|
const safeIncrement = Math.max(0, Math.trunc(n));
|
|
@@ -16855,7 +17106,10 @@ var Granular = class _Granular {
|
|
|
16855
17106
|
importRecords: async (records, options) => environment.enqueueRecordImport(records, {
|
|
16856
17107
|
batchSize: options?.batchSize,
|
|
16857
17108
|
writeMode: options?.writeMode,
|
|
16858
|
-
setupRunId
|
|
17109
|
+
setupRunId,
|
|
17110
|
+
// Sequence is deterministic for a retry of one importer hook. It
|
|
17111
|
+
// prevents a Container restart from creating a second queue import.
|
|
17112
|
+
operationKey: `${setupRunId}:import:${importSequence++}`
|
|
16859
17113
|
})
|
|
16860
17114
|
};
|
|
16861
17115
|
try {
|