@agentxm/extension-authoring 0.28.12 → 0.28.14-preview.1789139351.5cd4595aa
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/src/adopt/adopt-extension.d.ts +71 -0
- package/dist/src/adopt/adopt-extension.js +174 -0
- package/dist/src/authored-declaration.d.ts +49 -0
- package/dist/src/authored-declaration.js +86 -0
- package/dist/src/authored-package-errors.d.ts +91 -0
- package/dist/src/authored-package-errors.js +36 -0
- package/dist/src/create/authoring-owner.d.ts +54 -0
- package/dist/src/create/authoring-owner.js +93 -0
- package/dist/src/create/create-extension.d.ts +127 -0
- package/dist/src/create/create-extension.js +440 -0
- package/dist/src/create/errors.d.ts +59 -0
- package/dist/src/create/errors.js +54 -0
- package/dist/src/create/scaffold-name.d.ts +15 -0
- package/dist/src/create/scaffold-name.js +16 -0
- package/dist/src/create/scaffolds/hook.d.ts +19 -0
- package/dist/src/create/scaffolds/hook.js +118 -0
- package/dist/src/create/scaffolds/knowledge.d.ts +14 -0
- package/dist/src/create/scaffolds/knowledge.js +45 -0
- package/dist/src/create/scaffolds/mcp-server.d.ts +17 -0
- package/dist/src/create/scaffolds/mcp-server.js +57 -0
- package/dist/src/create/scaffolds/pack.d.ts +13 -0
- package/dist/src/create/scaffolds/pack.js +37 -0
- package/dist/src/create/scaffolds/rule.d.ts +14 -0
- package/dist/src/create/scaffolds/rule.js +46 -0
- package/dist/src/create/scaffolds/scaffold.d.ts +51 -0
- package/dist/src/create/scaffolds/scaffold.js +45 -0
- package/dist/src/create/scaffolds/skill.d.ts +12 -0
- package/dist/src/create/scaffolds/skill.js +47 -0
- package/dist/src/create/scaffolds/subagent.d.ts +12 -0
- package/dist/src/create/scaffolds/subagent.js +47 -0
- package/dist/src/create-preflight.d.ts +3 -2
- package/dist/src/create-preflight.js +2 -1
- package/dist/src/errors.d.ts +1 -1
- package/dist/src/errors.js +1 -1
- package/dist/src/fork/fork-extension.d.ts +87 -0
- package/dist/src/fork/fork-extension.js +253 -0
- package/dist/src/fork-package.d.ts +2 -2
- package/dist/src/fork-package.js +4 -4
- package/dist/src/import/import-native-extension.d.ts +119 -0
- package/dist/src/import/import-native-extension.js +310 -0
- package/dist/src/import-native-package.d.ts +2 -2
- package/dist/src/import-native-package.js +4 -4
- package/dist/src/index.d.ts +20 -11
- package/dist/src/index.js +26 -13
- package/dist/src/packs/add-to-pack.d.ts +2 -2
- package/dist/src/packs/add-to-pack.js +4 -3
- package/dist/src/packs/change-pack-membership.d.ts +56 -0
- package/dist/src/packs/change-pack-membership.js +246 -0
- package/dist/src/packs/configured-pack-selector.d.ts +24 -0
- package/dist/src/packs/configured-pack-selector.js +53 -0
- package/dist/src/packs/glob.d.ts +14 -0
- package/dist/src/packs/glob.js +44 -0
- package/dist/src/packs/membership-errors.d.ts +122 -0
- package/dist/src/packs/membership-errors.js +47 -0
- package/dist/src/packs/remove-from-pack.d.ts +2 -2
- package/dist/src/packs/remove-from-pack.js +4 -3
- package/dist/src/step-failure.d.ts +31 -0
- package/dist/src/step-failure.js +253 -0
- package/dist/src/testing.d.ts +68 -0
- package/dist/src/testing.js +135 -0
- package/dist/src/version/change-authored-version.d.ts +73 -0
- package/dist/src/version/change-authored-version.js +224 -0
- package/dist/src/version/errors.d.ts +65 -0
- package/dist/src/version/errors.js +73 -0
- package/package.json +23 -8
- package/dist/src/desired-identity.d.ts +0 -19
- package/dist/src/desired-identity.js +0 -26
- package/dist/src/failure-adapter.d.ts +0 -31
- package/dist/src/failure-adapter.js +0 -23
- package/dist/src/hooks/new-hook.d.ts +0 -46
- package/dist/src/hooks/new-hook.js +0 -164
- package/dist/src/packs/new-pack.d.ts +0 -37
- package/dist/src/packs/new-pack.js +0 -90
- package/dist/src/skills/new-skill.d.ts +0 -38
- package/dist/src/skills/new-skill.js +0 -102
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Adopting an acquired package into workspace authorship.
|
|
3
|
+
*
|
|
4
|
+
* Adoption moves rather than copies: the canonical package the workspace
|
|
5
|
+
* acquired becomes the authored package, its accepted external resolution is
|
|
6
|
+
* retired, and its declaration is rewritten to name the workspace as its
|
|
7
|
+
* source. The activation it already carried is preserved, and a package that
|
|
8
|
+
* was never declared becomes enabled — adopting content you cannot see would
|
|
9
|
+
* leave the workspace holding authored work it never materializes.
|
|
10
|
+
*
|
|
11
|
+
* `prepare` settles the identity, the destination, and the activation, and
|
|
12
|
+
* writes nothing. `previewOrApply` resolves that same candidate inside the
|
|
13
|
+
* workspace transaction, so a failed move restores both directories.
|
|
14
|
+
*
|
|
15
|
+
* @experimental This API is unstable and may change without notice.
|
|
16
|
+
*/
|
|
17
|
+
import * as Effect from "effect/Effect";
|
|
18
|
+
import * as FileSystem from "effect/FileSystem";
|
|
19
|
+
import type * as HttpClient from "effect/unstable/http/HttpClient";
|
|
20
|
+
import * as Path from "effect/Path";
|
|
21
|
+
import { ExtensionManagers, McpSecretStore, type ManagerRequirements, type RecipeRequirements } from "@agentxm/extension-materialization";
|
|
22
|
+
import { type ExtensionType, type FqnInvalidError, type Handle } from "@agentxm/extension-model/unstable/extensions";
|
|
23
|
+
import { type CandidateFingerprintFailed, type ExecutionCandidate, type PlanExecution } from "@agentxm/workspace-operations";
|
|
24
|
+
import type { CodingAgentRepository } from "@agentxm/workspace-projection";
|
|
25
|
+
import { WorkspaceMutations, type ConfiguredAgentOutcomesProvider, type LockfileValidationError, type WorkspaceLockfileReadFailure, type WorkspaceSettingsReadFailure } from "@agentxm/workspace-state";
|
|
26
|
+
import type { AuthoredPackageError } from "../authored-package-errors.js";
|
|
27
|
+
import { AuthoringFailed } from "../errors.js";
|
|
28
|
+
import { AuthoringScopeUnsupported, type AuthoringOwnerMismatch, type AuthoringOwnerRequired } from "../create/errors.js";
|
|
29
|
+
export interface AdoptExtensionRequest {
|
|
30
|
+
/** Canonical, owner-qualified identity of the package being adopted. */
|
|
31
|
+
readonly fqn: string;
|
|
32
|
+
/**
|
|
33
|
+
* Whether the invoking surface can prompt for a connection input an MCP
|
|
34
|
+
* server's manifest requires.
|
|
35
|
+
*/
|
|
36
|
+
readonly nonInteractive: boolean;
|
|
37
|
+
}
|
|
38
|
+
/** What every step in an adoption may require when it runs. */
|
|
39
|
+
export type AdoptExtensionRequirements = ManagerRequirements | RecipeRequirements | WorkspaceMutations | CodingAgentRepository | McpSecretStore;
|
|
40
|
+
/** A settled adoption: every decision is made and nothing is written. */
|
|
41
|
+
export interface AdoptExtensionCandidate {
|
|
42
|
+
readonly type: ExtensionType;
|
|
43
|
+
readonly fqn: string;
|
|
44
|
+
readonly owner: Handle;
|
|
45
|
+
readonly name: string;
|
|
46
|
+
/** Workspace-relative directory the package is moved out of. */
|
|
47
|
+
readonly acquiredPath: string;
|
|
48
|
+
/** Workspace-relative directory the package is moved into. */
|
|
49
|
+
readonly authoredPath: string;
|
|
50
|
+
/** Workspace-relative settings file the declaration is rewritten in. */
|
|
51
|
+
readonly settingsPath: string;
|
|
52
|
+
/** The activation the adopted package keeps. */
|
|
53
|
+
readonly enabled: boolean;
|
|
54
|
+
readonly execution: ExecutionCandidate<AdoptExtensionRequirements>;
|
|
55
|
+
}
|
|
56
|
+
/** Every failure settling an adoption can surface before anything is written. */
|
|
57
|
+
export type AdoptExtensionFailure = AuthoringFailed | AuthoredPackageError | AuthoringOwnerRequired | AuthoringOwnerMismatch | AuthoringScopeUnsupported | LockfileValidationError | WorkspaceLockfileReadFailure | WorkspaceSettingsReadFailure | CandidateFingerprintFailed | FqnInvalidError;
|
|
58
|
+
/** Everything settling an adoption reads before it freezes a candidate. */
|
|
59
|
+
export type PrepareAdoptExtensionRequirements = FileSystem.FileSystem | Path.Path | HttpClient.HttpClient | WorkspaceMutations | ExtensionManagers | ConfiguredAgentOutcomesProvider;
|
|
60
|
+
/** The plan an adoption resolves. */
|
|
61
|
+
export declare const adoptExtensionPlanName = "Adopt workspace extension";
|
|
62
|
+
/** Settle an adoption without writing anything. */
|
|
63
|
+
export declare const prepareAdoptExtension: (request: AdoptExtensionRequest) => Effect.Effect<AdoptExtensionCandidate, AdoptExtensionFailure, PrepareAdoptExtensionRequirements>;
|
|
64
|
+
/** Preview or apply a settled adoption, resolving to one operation outcome. */
|
|
65
|
+
export declare const previewOrApplyAdoptExtension: (candidate: AdoptExtensionCandidate, execution: PlanExecution) => Effect.Effect<import("@agentxm/workspace-operations").OperationResolution<never>, WorkspaceSettingsReadFailure | import("@agentxm/workspace-operations").ApprovalRecoveryMissing | import("@agentxm/workspace-operations").PlanInteractionFailed | import("@agentxm/workspace-transactions").WorkspaceTransitionAcquireFailure, ConfiguredAgentOutcomesProvider | import("@agentxm/workspace-operations").OperationJournal | import("@agentxm/workspace-operations").ResolvePlanInteraction | import("@agentxm/workspace-transactions").FootprintRecorder | AdoptExtensionRequirements>;
|
|
66
|
+
/** The adoption use case: settle a request, then preview or apply it. */
|
|
67
|
+
export declare const AdoptExtension: {
|
|
68
|
+
readonly prepare: (request: AdoptExtensionRequest) => Effect.Effect<AdoptExtensionCandidate, AdoptExtensionFailure, PrepareAdoptExtensionRequirements>;
|
|
69
|
+
readonly previewOrApply: (candidate: AdoptExtensionCandidate, execution: PlanExecution) => Effect.Effect<import("@agentxm/workspace-operations").OperationResolution<never>, WorkspaceSettingsReadFailure | import("@agentxm/workspace-operations").ApprovalRecoveryMissing | import("@agentxm/workspace-operations").PlanInteractionFailed | import("@agentxm/workspace-transactions").WorkspaceTransitionAcquireFailure, ConfiguredAgentOutcomesProvider | import("@agentxm/workspace-operations").OperationJournal | import("@agentxm/workspace-operations").ResolvePlanInteraction | import("@agentxm/workspace-transactions").FootprintRecorder | AdoptExtensionRequirements>;
|
|
70
|
+
};
|
|
71
|
+
//# sourceMappingURL=adopt-extension.d.ts.map
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Adopting an acquired package into workspace authorship.
|
|
3
|
+
*
|
|
4
|
+
* Adoption moves rather than copies: the canonical package the workspace
|
|
5
|
+
* acquired becomes the authored package, its accepted external resolution is
|
|
6
|
+
* retired, and its declaration is rewritten to name the workspace as its
|
|
7
|
+
* source. The activation it already carried is preserved, and a package that
|
|
8
|
+
* was never declared becomes enabled — adopting content you cannot see would
|
|
9
|
+
* leave the workspace holding authored work it never materializes.
|
|
10
|
+
*
|
|
11
|
+
* `prepare` settles the identity, the destination, and the activation, and
|
|
12
|
+
* writes nothing. `previewOrApply` resolves that same candidate inside the
|
|
13
|
+
* workspace transaction, so a failed move restores both directories.
|
|
14
|
+
*
|
|
15
|
+
* @experimental This API is unstable and may change without notice.
|
|
16
|
+
*/
|
|
17
|
+
import * as Effect from "effect/Effect";
|
|
18
|
+
import * as FileSystem from "effect/FileSystem";
|
|
19
|
+
import * as Option from "effect/Option";
|
|
20
|
+
import * as Path from "effect/Path";
|
|
21
|
+
import { ExtensionManagers, McpSecretStore, buildAuthoredExtensionStep, materializeAuthoredMcpServer, } from "@agentxm/extension-materialization";
|
|
22
|
+
import { extensionTypeToPlural, formatFqn, parseFqn, } from "@agentxm/extension-model/unstable/extensions";
|
|
23
|
+
import { operationPresentation, prepareExecutionCandidate, resolveExecutionCandidate, } from "@agentxm/workspace-operations";
|
|
24
|
+
import { WorkspaceMutations, resolveWorkspaceExtensionRef, } from "@agentxm/workspace-state";
|
|
25
|
+
import { protectCreatedAncestors } from "@agentxm/workspace-transactions";
|
|
26
|
+
import { authoredDeclaration } from "../authored-declaration.js";
|
|
27
|
+
import { preflightCreateOnly } from "../create-preflight.js";
|
|
28
|
+
import { AuthoringFailed } from "../errors.js";
|
|
29
|
+
import { requireAuthoredOwner, settingsRelativePath } from "../create/authoring-owner.js";
|
|
30
|
+
import { AuthoringScopeUnsupported, } from "../create/errors.js";
|
|
31
|
+
import { authoringStepFailure } from "../step-failure.js";
|
|
32
|
+
/**
|
|
33
|
+
* Build the adoption step with the requirements this use case keeps in `R`.
|
|
34
|
+
*/
|
|
35
|
+
const adoptStep = (manager, args) => buildAuthoredExtensionStep(manager, args);
|
|
36
|
+
/** The plan an adoption resolves. */
|
|
37
|
+
export const adoptExtensionPlanName = "Adopt workspace extension";
|
|
38
|
+
// -----------------------------------------------------------------------------
|
|
39
|
+
// prepare
|
|
40
|
+
// -----------------------------------------------------------------------------
|
|
41
|
+
/** Settle an adoption without writing anything. */
|
|
42
|
+
export const prepareAdoptExtension = Effect.fn("AdoptExtension.prepare")(function* (request) {
|
|
43
|
+
const ws = yield* WorkspaceMutations;
|
|
44
|
+
const fs = yield* FileSystem.FileSystem;
|
|
45
|
+
const path = yield* Path.Path;
|
|
46
|
+
const managers = yield* ExtensionManagers;
|
|
47
|
+
const parsed = yield* Effect.fromResult(parseFqn(request.fqn));
|
|
48
|
+
if (ws.layout.scope !== "project") {
|
|
49
|
+
return yield* new AuthoringScopeUnsupported({ subject: "adoption", scope: ws.layout.scope });
|
|
50
|
+
}
|
|
51
|
+
yield* requireAuthoredOwner(parsed.owner, { subject: "package", command: "adopt" });
|
|
52
|
+
const name = parsed.name;
|
|
53
|
+
const fqn = formatFqn(parsed);
|
|
54
|
+
const sourceDir = path.join(ws.layout.acquiredRoot, "agentxm", parsed.owner, extensionTypeToPlural[parsed.type], name);
|
|
55
|
+
const targetDir = path.join(ws.layout.authoredRoot(parsed.type), name);
|
|
56
|
+
const acquiredPath = path.relative(ws.baseDir, sourceDir);
|
|
57
|
+
const authoredPath = path.relative(ws.baseDir, targetDir);
|
|
58
|
+
const settingsPath = settingsRelativePath(path, ws);
|
|
59
|
+
// Refuse an occupied authoring destination here, so a preview refuses it
|
|
60
|
+
// too; the closure repeats the check under the transaction lock.
|
|
61
|
+
const createOnly = preflightCreateOnly({
|
|
62
|
+
subject: "Adopt target",
|
|
63
|
+
name,
|
|
64
|
+
configured: false,
|
|
65
|
+
destinations: [targetDir],
|
|
66
|
+
});
|
|
67
|
+
yield* createOnly;
|
|
68
|
+
const declaration = authoredDeclaration(ws, parsed.type, name);
|
|
69
|
+
const current = yield* declaration.read;
|
|
70
|
+
// A package the workspace never declared becomes enabled: adopting content
|
|
71
|
+
// that stays invisible is not what adoption was asked for.
|
|
72
|
+
const enabled = Option.getOrElse(current.enabled, () => true);
|
|
73
|
+
const artifact = {
|
|
74
|
+
path: authoredPath,
|
|
75
|
+
scope: ws.scope,
|
|
76
|
+
change: "created",
|
|
77
|
+
targets: [
|
|
78
|
+
{ path: acquiredPath, change: "removed" },
|
|
79
|
+
{ path: authoredPath, change: "created" },
|
|
80
|
+
{ path: settingsPath, change: "updated" },
|
|
81
|
+
],
|
|
82
|
+
};
|
|
83
|
+
const common = {
|
|
84
|
+
toStepFailure: authoringStepFailure,
|
|
85
|
+
location: targetDir,
|
|
86
|
+
transactionTargets: [sourceDir],
|
|
87
|
+
versionRange: Option.none(),
|
|
88
|
+
label: `Adopt ${fqn}`,
|
|
89
|
+
message: `Adopted ${fqn}`,
|
|
90
|
+
enabled,
|
|
91
|
+
allowConfiguredSourceTransition: true,
|
|
92
|
+
markAuthored: Effect.andThen(declaration.retireExternalResolution, declaration.declare({ enabled: true, env: current.env })),
|
|
93
|
+
finalizeAuthored: declaration.declare({ enabled, env: current.env }),
|
|
94
|
+
plannedArtifact: artifact,
|
|
95
|
+
buildArtifact: () => Effect.succeed(artifact),
|
|
96
|
+
preflight: Effect.gen(function* () {
|
|
97
|
+
yield* createOnly;
|
|
98
|
+
// The acquired directory must already hold a resolvable package: a move
|
|
99
|
+
// that lands unreadable content would leave the workspace authoring
|
|
100
|
+
// something it cannot materialize.
|
|
101
|
+
yield* resolveWorkspaceExtensionRef({
|
|
102
|
+
settingsName: name,
|
|
103
|
+
source: "workspace",
|
|
104
|
+
expectedType: parsed.type,
|
|
105
|
+
layout: ws.layout,
|
|
106
|
+
scope: ws.scope,
|
|
107
|
+
staticPackage: { owner: parsed.owner, name, root: sourceDir },
|
|
108
|
+
});
|
|
109
|
+
}).pipe(Effect.asVoid),
|
|
110
|
+
scaffold: Effect.gen(function* () {
|
|
111
|
+
yield* protectCreatedAncestors(fs, path, path.dirname(targetDir));
|
|
112
|
+
yield* fs.makeDirectory(path.dirname(targetDir), { recursive: true });
|
|
113
|
+
yield* fs.rename(sourceDir, targetDir);
|
|
114
|
+
}).pipe(Effect.mapError((cause) => new AuthoringFailed({
|
|
115
|
+
category: "internal",
|
|
116
|
+
detail: `Could not move ${fqn} into authored package storage`,
|
|
117
|
+
cause,
|
|
118
|
+
}))),
|
|
119
|
+
};
|
|
120
|
+
const step = (() => {
|
|
121
|
+
switch (parsed.type) {
|
|
122
|
+
case "skill":
|
|
123
|
+
return adoptStep(managers.skill, { ...common, target: { type: "skill", name } });
|
|
124
|
+
case "subagent":
|
|
125
|
+
return adoptStep(managers.subagent, { ...common, target: { type: "subagent", name } });
|
|
126
|
+
case "rule":
|
|
127
|
+
return adoptStep(managers.rule, { ...common, target: { type: "rule", name } });
|
|
128
|
+
case "hook":
|
|
129
|
+
return adoptStep(managers.hook, { ...common, target: { type: "hook", name } });
|
|
130
|
+
case "knowledge":
|
|
131
|
+
return adoptStep(managers.knowledge, { ...common, target: { type: "knowledge", name } });
|
|
132
|
+
case "pack":
|
|
133
|
+
return adoptStep(managers.pack, {
|
|
134
|
+
...common,
|
|
135
|
+
target: { type: "pack", owner: parsed.owner, name },
|
|
136
|
+
});
|
|
137
|
+
case "mcp-server":
|
|
138
|
+
return adoptStep(managers["mcp-server"], {
|
|
139
|
+
...common,
|
|
140
|
+
target: { type: "mcp-server", name },
|
|
141
|
+
materializeInstall: (ref) => materializeAuthoredMcpServer({ ref, nonInteractive: request.nonInteractive }),
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
})();
|
|
145
|
+
const plan = {
|
|
146
|
+
_tag: "Plan",
|
|
147
|
+
name: adoptExtensionPlanName,
|
|
148
|
+
description: Option.some("Adopt the canonical package as authoritative workspace source content"),
|
|
149
|
+
presentation: operationPresentation({ imperative: "adopt", past: "Adopted", gerund: "Adopting" }, parsed.type),
|
|
150
|
+
jobs: [{ concurrency: 1, steps: [step] }],
|
|
151
|
+
};
|
|
152
|
+
return {
|
|
153
|
+
type: parsed.type,
|
|
154
|
+
fqn,
|
|
155
|
+
owner: parsed.owner,
|
|
156
|
+
name,
|
|
157
|
+
acquiredPath,
|
|
158
|
+
authoredPath,
|
|
159
|
+
settingsPath,
|
|
160
|
+
enabled,
|
|
161
|
+
execution: yield* prepareExecutionCandidate(plan),
|
|
162
|
+
};
|
|
163
|
+
});
|
|
164
|
+
// -----------------------------------------------------------------------------
|
|
165
|
+
// previewOrApply
|
|
166
|
+
// -----------------------------------------------------------------------------
|
|
167
|
+
/** Preview or apply a settled adoption, resolving to one operation outcome. */
|
|
168
|
+
export const previewOrApplyAdoptExtension = (candidate, execution) => resolveExecutionCandidate(candidate.execution, execution);
|
|
169
|
+
/** The adoption use case: settle a request, then preview or apply it. */
|
|
170
|
+
export const AdoptExtension = {
|
|
171
|
+
prepare: prepareAdoptExtension,
|
|
172
|
+
previewOrApply: previewOrApplyAdoptExtension,
|
|
173
|
+
};
|
|
174
|
+
//# sourceMappingURL=adopt-extension.js.map
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* How a workspace declares that it authors a package, for every extension
|
|
3
|
+
* type.
|
|
4
|
+
*
|
|
5
|
+
* Creating, forking, adopting, and importing all answer the same three
|
|
6
|
+
* questions — is this name already declared, what activation does it carry,
|
|
7
|
+
* and what accepted external resolution does becoming authored retire — and
|
|
8
|
+
* every one of them answers it per type. Deciding it once here is what keeps
|
|
9
|
+
* the four use cases from repeating a seven-way table each, and what makes a
|
|
10
|
+
* new extension type a compile error in one place instead of four.
|
|
11
|
+
*
|
|
12
|
+
* @experimental This API is unstable and may change without notice.
|
|
13
|
+
*/
|
|
14
|
+
import * as Effect from "effect/Effect";
|
|
15
|
+
import * as Option from "effect/Option";
|
|
16
|
+
import type { ExtensionType } from "@agentxm/extension-model/unstable/extensions";
|
|
17
|
+
import { type WorkspaceLockfileMutationFailure, type WorkspaceMutationsService, type WorkspaceSettingsMutationFailure, type WorkspaceSettingsReadFailure, type WorkspaceStateMutationFailure } from "@agentxm/workspace-state";
|
|
18
|
+
/** What the workspace currently declares about one name of one type. */
|
|
19
|
+
export interface AuthoredDeclarationState {
|
|
20
|
+
/** Whether any entry of this type carries this name. */
|
|
21
|
+
readonly configured: boolean;
|
|
22
|
+
/** The activation the existing entry carries, or none when undeclared. */
|
|
23
|
+
readonly enabled: Option.Option<boolean>;
|
|
24
|
+
/** The source the entry names, or none when undeclared or sourceless. */
|
|
25
|
+
readonly source: Option.Option<string>;
|
|
26
|
+
/**
|
|
27
|
+
* Connection inputs an existing MCP declaration carries. Empty for every
|
|
28
|
+
* other type, which declares no inputs.
|
|
29
|
+
*/
|
|
30
|
+
readonly env: Readonly<Record<string, string>>;
|
|
31
|
+
}
|
|
32
|
+
/** Reading and writing one workspace declaration. */
|
|
33
|
+
export interface AuthoredDeclaration {
|
|
34
|
+
readonly read: Effect.Effect<AuthoredDeclarationState, WorkspaceSettingsReadFailure>;
|
|
35
|
+
/** Declare the name as workspace-authored with the given activation. */
|
|
36
|
+
readonly declare: (args: {
|
|
37
|
+
readonly enabled: boolean;
|
|
38
|
+
/** Inputs to preserve on an MCP declaration; ignored by other types. */
|
|
39
|
+
readonly env?: Readonly<Record<string, string>>;
|
|
40
|
+
}) => Effect.Effect<void, WorkspaceSettingsMutationFailure>;
|
|
41
|
+
/**
|
|
42
|
+
* Retire the accepted external resolution the name held before the
|
|
43
|
+
* workspace took authorship of it.
|
|
44
|
+
*/
|
|
45
|
+
readonly retireExternalResolution: Effect.Effect<void, WorkspaceLockfileMutationFailure | WorkspaceStateMutationFailure>;
|
|
46
|
+
}
|
|
47
|
+
/** The declaration surface for one extension type and name. */
|
|
48
|
+
export declare const authoredDeclaration: (ws: WorkspaceMutationsService, type: ExtensionType, name: string) => AuthoredDeclaration;
|
|
49
|
+
//# sourceMappingURL=authored-declaration.d.ts.map
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* How a workspace declares that it authors a package, for every extension
|
|
3
|
+
* type.
|
|
4
|
+
*
|
|
5
|
+
* Creating, forking, adopting, and importing all answer the same three
|
|
6
|
+
* questions — is this name already declared, what activation does it carry,
|
|
7
|
+
* and what accepted external resolution does becoming authored retire — and
|
|
8
|
+
* every one of them answers it per type. Deciding it once here is what keeps
|
|
9
|
+
* the four use cases from repeating a seven-way table each, and what makes a
|
|
10
|
+
* new extension type a compile error in one place instead of four.
|
|
11
|
+
*
|
|
12
|
+
* @experimental This API is unstable and may change without notice.
|
|
13
|
+
*/
|
|
14
|
+
import * as Effect from "effect/Effect";
|
|
15
|
+
import * as Option from "effect/Option";
|
|
16
|
+
import {} from "@agentxm/workspace-state";
|
|
17
|
+
const WORKSPACE_SOURCE = "workspace";
|
|
18
|
+
const entrySource = (entry) => {
|
|
19
|
+
if (typeof entry === "string")
|
|
20
|
+
return Option.some(entry);
|
|
21
|
+
if (typeof entry !== "object" || entry === null || !("source" in entry))
|
|
22
|
+
return Option.none();
|
|
23
|
+
return typeof entry.source === "string" ? Option.some(entry.source) : Option.none();
|
|
24
|
+
};
|
|
25
|
+
const state = (entry, env = {}) => ({
|
|
26
|
+
configured: entry !== undefined,
|
|
27
|
+
enabled: entry === undefined
|
|
28
|
+
? Option.none()
|
|
29
|
+
: Option.some(typeof entry === "string" ? true : (entry.enabled ?? true)),
|
|
30
|
+
source: entrySource(entry),
|
|
31
|
+
env,
|
|
32
|
+
});
|
|
33
|
+
/** The declaration surface for one extension type and name. */
|
|
34
|
+
export const authoredDeclaration = (ws, type, name) => {
|
|
35
|
+
switch (type) {
|
|
36
|
+
case "skill":
|
|
37
|
+
return {
|
|
38
|
+
read: ws.getConfiguredSkillEntries().pipe(Effect.map((entries) => state(entries[name]))),
|
|
39
|
+
declare: ({ enabled }) => ws.setSkillEntry(name, { source: WORKSPACE_SOURCE, enabled }),
|
|
40
|
+
retireExternalResolution: ws.removeSkillLock(name),
|
|
41
|
+
};
|
|
42
|
+
case "subagent":
|
|
43
|
+
return {
|
|
44
|
+
read: ws.getConfiguredSubagentEntries().pipe(Effect.map((entries) => state(entries[name]))),
|
|
45
|
+
declare: ({ enabled }) => ws.setSubagentEntry(name, { source: WORKSPACE_SOURCE, enabled }),
|
|
46
|
+
retireExternalResolution: ws.removeSubagentLock(name),
|
|
47
|
+
};
|
|
48
|
+
case "rule":
|
|
49
|
+
return {
|
|
50
|
+
read: ws.getConfiguredRuleEntries().pipe(Effect.map((entries) => state(entries[name]))),
|
|
51
|
+
declare: ({ enabled }) => ws.setRuleEntry(name, { source: WORKSPACE_SOURCE, enabled }),
|
|
52
|
+
retireExternalResolution: ws.removeRuleLock(name),
|
|
53
|
+
};
|
|
54
|
+
case "hook":
|
|
55
|
+
return {
|
|
56
|
+
read: ws.getConfiguredHookEntries().pipe(Effect.map((entries) => state(entries[name]))),
|
|
57
|
+
declare: ({ enabled }) => ws.setHookEntry(name, { source: WORKSPACE_SOURCE, enabled }),
|
|
58
|
+
retireExternalResolution: ws.removeHookLock(name),
|
|
59
|
+
};
|
|
60
|
+
case "knowledge":
|
|
61
|
+
return {
|
|
62
|
+
read: ws
|
|
63
|
+
.getConfiguredKnowledgeEntries()
|
|
64
|
+
.pipe(Effect.map((entries) => state(entries[name]))),
|
|
65
|
+
declare: ({ enabled }) => ws.setKnowledgeEntry(name, { source: WORKSPACE_SOURCE, enabled }),
|
|
66
|
+
retireExternalResolution: ws.removeKnowledgeLock(name),
|
|
67
|
+
};
|
|
68
|
+
case "pack":
|
|
69
|
+
return {
|
|
70
|
+
read: ws.getConfiguredPackEntries().pipe(Effect.map((entries) => state(entries[name]))),
|
|
71
|
+
declare: ({ enabled }) => ws.setPackEntry(name, { source: WORKSPACE_SOURCE, enabled }),
|
|
72
|
+
retireExternalResolution: ws.removePackLock(name),
|
|
73
|
+
};
|
|
74
|
+
case "mcp-server":
|
|
75
|
+
return {
|
|
76
|
+
read: ws
|
|
77
|
+
.getConfiguredMcpServerEntries()
|
|
78
|
+
.pipe(Effect.map((entries) => state(entries[name], entries[name]?.env ?? {}))),
|
|
79
|
+
declare: ({ enabled, env }) => ws.setMcpServerEntry(name, { source: WORKSPACE_SOURCE, enabled, env: env ?? {} }),
|
|
80
|
+
// Resolve the old connection before its workspace declaration replaces
|
|
81
|
+
// it, preserving any resolution still shared by another connection.
|
|
82
|
+
retireExternalResolution: ws.removeMcpServer(name),
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
//# sourceMappingURL=authored-declaration.js.map
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Typed failure family for authored-package creation: create preflight, fork,
|
|
3
|
+
* and native import. Fields are domain facts; the application error boundary
|
|
4
|
+
* owns rendering, codes, and suggestions.
|
|
5
|
+
*
|
|
6
|
+
* @experimental This API is unstable and may change without notice.
|
|
7
|
+
*/
|
|
8
|
+
import type { CreateDestinationExists } from "@agentxm/extension-materialization";
|
|
9
|
+
import type { ExtensionType } from "@agentxm/extension-model/unstable/extensions/common";
|
|
10
|
+
declare const CreateNameConfigured_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => import("effect/Cause").YieldableError & {
|
|
11
|
+
readonly _tag: "CreateNameConfigured";
|
|
12
|
+
} & Readonly<A>;
|
|
13
|
+
/** A create operation's name is already declared in workspace settings. */
|
|
14
|
+
export declare class CreateNameConfigured extends CreateNameConfigured_base<{
|
|
15
|
+
readonly subject: string;
|
|
16
|
+
readonly name: string;
|
|
17
|
+
}> {
|
|
18
|
+
}
|
|
19
|
+
declare const CreateDestinationInspectionFailed_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => import("effect/Cause").YieldableError & {
|
|
20
|
+
readonly _tag: "CreateDestinationInspectionFailed";
|
|
21
|
+
} & Readonly<A>;
|
|
22
|
+
/** Inspecting a create destination before scaffolding failed. */
|
|
23
|
+
export declare class CreateDestinationInspectionFailed extends CreateDestinationInspectionFailed_base<{
|
|
24
|
+
readonly path: string;
|
|
25
|
+
readonly cause: unknown;
|
|
26
|
+
}> {
|
|
27
|
+
}
|
|
28
|
+
declare const ForkPackageInvalid_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => import("effect/Cause").YieldableError & {
|
|
29
|
+
readonly _tag: "ForkPackageInvalid";
|
|
30
|
+
} & Readonly<A>;
|
|
31
|
+
/** Fork input content or identity did not validate. */
|
|
32
|
+
export declare class ForkPackageInvalid extends ForkPackageInvalid_base<{
|
|
33
|
+
readonly detail: string;
|
|
34
|
+
readonly cause?: unknown;
|
|
35
|
+
}> {
|
|
36
|
+
}
|
|
37
|
+
declare const ForkPackageConflict_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => import("effect/Cause").YieldableError & {
|
|
38
|
+
readonly _tag: "ForkPackageConflict";
|
|
39
|
+
} & Readonly<A>;
|
|
40
|
+
/** Fork found conflicting workspace or source state. */
|
|
41
|
+
export declare class ForkPackageConflict extends ForkPackageConflict_base<{
|
|
42
|
+
readonly detail: string;
|
|
43
|
+
}> {
|
|
44
|
+
}
|
|
45
|
+
declare const ForkPackageFailed_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => import("effect/Cause").YieldableError & {
|
|
46
|
+
readonly _tag: "ForkPackageFailed";
|
|
47
|
+
} & Readonly<A>;
|
|
48
|
+
/** A fork filesystem step failed. */
|
|
49
|
+
export declare class ForkPackageFailed extends ForkPackageFailed_base<{
|
|
50
|
+
readonly detail: string;
|
|
51
|
+
readonly cause: unknown;
|
|
52
|
+
}> {
|
|
53
|
+
}
|
|
54
|
+
declare const NativeImportUnsupported_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => import("effect/Cause").YieldableError & {
|
|
55
|
+
readonly _tag: "NativeImportUnsupported";
|
|
56
|
+
} & Readonly<A>;
|
|
57
|
+
/** Native package import does not support the requested extension type. */
|
|
58
|
+
export declare class NativeImportUnsupported extends NativeImportUnsupported_base<{
|
|
59
|
+
readonly type: ExtensionType;
|
|
60
|
+
}> {
|
|
61
|
+
}
|
|
62
|
+
declare const NativeImportInvalid_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => import("effect/Cause").YieldableError & {
|
|
63
|
+
readonly _tag: "NativeImportInvalid";
|
|
64
|
+
} & Readonly<A>;
|
|
65
|
+
/** Native import input content did not validate. */
|
|
66
|
+
export declare class NativeImportInvalid extends NativeImportInvalid_base<{
|
|
67
|
+
readonly detail: string;
|
|
68
|
+
readonly cause?: unknown;
|
|
69
|
+
}> {
|
|
70
|
+
}
|
|
71
|
+
declare const NativeImportConflict_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => import("effect/Cause").YieldableError & {
|
|
72
|
+
readonly _tag: "NativeImportConflict";
|
|
73
|
+
} & Readonly<A>;
|
|
74
|
+
/** Native import found existing state at its target directory. */
|
|
75
|
+
export declare class NativeImportConflict extends NativeImportConflict_base<{
|
|
76
|
+
readonly targetDir: string;
|
|
77
|
+
}> {
|
|
78
|
+
}
|
|
79
|
+
declare const NativeImportFailed_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => import("effect/Cause").YieldableError & {
|
|
80
|
+
readonly _tag: "NativeImportFailed";
|
|
81
|
+
} & Readonly<A>;
|
|
82
|
+
/** A native-import filesystem step failed. */
|
|
83
|
+
export declare class NativeImportFailed extends NativeImportFailed_base<{
|
|
84
|
+
readonly detail: string;
|
|
85
|
+
readonly cause: unknown;
|
|
86
|
+
}> {
|
|
87
|
+
}
|
|
88
|
+
/** Every failure the authored-package creation operations construct. */
|
|
89
|
+
export type AuthoredPackageError = CreateDestinationExists | CreateNameConfigured | CreateDestinationInspectionFailed | ForkPackageInvalid | ForkPackageConflict | ForkPackageFailed | NativeImportUnsupported | NativeImportInvalid | NativeImportConflict | NativeImportFailed;
|
|
90
|
+
export {};
|
|
91
|
+
//# sourceMappingURL=authored-package-errors.d.ts.map
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Typed failure family for authored-package creation: create preflight, fork,
|
|
3
|
+
* and native import. Fields are domain facts; the application error boundary
|
|
4
|
+
* owns rendering, codes, and suggestions.
|
|
5
|
+
*
|
|
6
|
+
* @experimental This API is unstable and may change without notice.
|
|
7
|
+
*/
|
|
8
|
+
import * as Data from "effect/Data";
|
|
9
|
+
/** A create operation's name is already declared in workspace settings. */
|
|
10
|
+
export class CreateNameConfigured extends Data.TaggedError("CreateNameConfigured") {
|
|
11
|
+
}
|
|
12
|
+
/** Inspecting a create destination before scaffolding failed. */
|
|
13
|
+
export class CreateDestinationInspectionFailed extends Data.TaggedError("CreateDestinationInspectionFailed") {
|
|
14
|
+
}
|
|
15
|
+
/** Fork input content or identity did not validate. */
|
|
16
|
+
export class ForkPackageInvalid extends Data.TaggedError("ForkPackageInvalid") {
|
|
17
|
+
}
|
|
18
|
+
/** Fork found conflicting workspace or source state. */
|
|
19
|
+
export class ForkPackageConflict extends Data.TaggedError("ForkPackageConflict") {
|
|
20
|
+
}
|
|
21
|
+
/** A fork filesystem step failed. */
|
|
22
|
+
export class ForkPackageFailed extends Data.TaggedError("ForkPackageFailed") {
|
|
23
|
+
}
|
|
24
|
+
/** Native package import does not support the requested extension type. */
|
|
25
|
+
export class NativeImportUnsupported extends Data.TaggedError("NativeImportUnsupported") {
|
|
26
|
+
}
|
|
27
|
+
/** Native import input content did not validate. */
|
|
28
|
+
export class NativeImportInvalid extends Data.TaggedError("NativeImportInvalid") {
|
|
29
|
+
}
|
|
30
|
+
/** Native import found existing state at its target directory. */
|
|
31
|
+
export class NativeImportConflict extends Data.TaggedError("NativeImportConflict") {
|
|
32
|
+
}
|
|
33
|
+
/** A native-import filesystem step failed. */
|
|
34
|
+
export class NativeImportFailed extends Data.TaggedError("NativeImportFailed") {
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=authored-package-errors.js.map
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The owner every authored package is created under.
|
|
3
|
+
*
|
|
4
|
+
* The selected workspace scope is the only silent source. An explicitly
|
|
5
|
+
* requested owner must match a configured one, and establishes ownership when
|
|
6
|
+
* the scope configures none. When neither is present the refusal names the
|
|
7
|
+
* owners the person could have meant rather than resolving one for them:
|
|
8
|
+
* creating under an owner the scope does not record leaves the workspace
|
|
9
|
+
* failing its own desired-state invariant.
|
|
10
|
+
*
|
|
11
|
+
* @experimental This API is unstable and may change without notice.
|
|
12
|
+
*/
|
|
13
|
+
import * as Effect from "effect/Effect";
|
|
14
|
+
import * as Option from "effect/Option";
|
|
15
|
+
import * as Path from "effect/Path";
|
|
16
|
+
import type { Handle } from "@agentxm/extension-model/unstable/extensions";
|
|
17
|
+
import { CredentialStore } from "@agentxm/registry-auth";
|
|
18
|
+
import { RegistryUrl } from "@agentxm/registry-client";
|
|
19
|
+
import { WorkspaceMutations, type WorkspaceMutationsService, type WorkspaceSettingsMutationFailure, type WorkspaceSettingsReadFailure } from "@agentxm/workspace-state";
|
|
20
|
+
import { AuthoringOwnerMismatch, AuthoringOwnerRequired } from "./errors.js";
|
|
21
|
+
/** The `axm <type> new <name>` invocation named in an ownership refusal. */
|
|
22
|
+
export interface AuthoringTarget {
|
|
23
|
+
/** Subject named in the refusal, e.g. `skill`. */
|
|
24
|
+
readonly subject: string;
|
|
25
|
+
/** Command route named in the recovery action, e.g. `skills new`. */
|
|
26
|
+
readonly command: string;
|
|
27
|
+
/** Name being created, so the recovery action is a runnable command. */
|
|
28
|
+
readonly name: string;
|
|
29
|
+
}
|
|
30
|
+
export interface AuthoringOwner {
|
|
31
|
+
/** The owner the new package and its workspace declaration carry. */
|
|
32
|
+
readonly owner: Handle;
|
|
33
|
+
/**
|
|
34
|
+
* Record `owner` in the selected scope's settings, or `Effect.void` when
|
|
35
|
+
* the scope already names it. It runs inside the authoring transaction, so
|
|
36
|
+
* establishment is atomic with the desired-state entry and absent from
|
|
37
|
+
* preview.
|
|
38
|
+
*/
|
|
39
|
+
readonly establish: Effect.Effect<void, WorkspaceSettingsMutationFailure>;
|
|
40
|
+
}
|
|
41
|
+
/** The settings file that records ownership, relative to the workspace root. */
|
|
42
|
+
export declare const settingsRelativePath: (path: Path.Path, ws: WorkspaceMutationsService) => string;
|
|
43
|
+
/**
|
|
44
|
+
* Resolve the owner an authoring command creates under, or refuse with the
|
|
45
|
+
* facts that make the refusal recoverable.
|
|
46
|
+
*/
|
|
47
|
+
export declare const resolveAuthoringOwner: (target: AuthoringTarget, explicit: Option.Option<string>) => Effect.Effect<AuthoringOwner, AuthoringOwnerRequired | AuthoringOwnerMismatch | WorkspaceSettingsReadFailure, WorkspaceMutations | Path.Path | CredentialStore | RegistryUrl>;
|
|
48
|
+
/**
|
|
49
|
+
* Require an already-authored package's identity to agree with the selected
|
|
50
|
+
* workspace. Fork, adopt, and native import carry an owner in the identity
|
|
51
|
+
* they were given, so they confirm rather than resolve.
|
|
52
|
+
*/
|
|
53
|
+
export declare const requireAuthoredOwner: (owner: Handle, target: Pick<AuthoringTarget, "subject" | "command">) => Effect.Effect<void, AuthoringOwnerRequired | AuthoringOwnerMismatch, WorkspaceMutations | Path.Path>;
|
|
54
|
+
//# sourceMappingURL=authoring-owner.d.ts.map
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The owner every authored package is created under.
|
|
3
|
+
*
|
|
4
|
+
* The selected workspace scope is the only silent source. An explicitly
|
|
5
|
+
* requested owner must match a configured one, and establishes ownership when
|
|
6
|
+
* the scope configures none. When neither is present the refusal names the
|
|
7
|
+
* owners the person could have meant rather than resolving one for them:
|
|
8
|
+
* creating under an owner the scope does not record leaves the workspace
|
|
9
|
+
* failing its own desired-state invariant.
|
|
10
|
+
*
|
|
11
|
+
* @experimental This API is unstable and may change without notice.
|
|
12
|
+
*/
|
|
13
|
+
import * as Effect from "effect/Effect";
|
|
14
|
+
import * as Option from "effect/Option";
|
|
15
|
+
import * as Path from "effect/Path";
|
|
16
|
+
import { CredentialStore, getCurrentUserHandle } from "@agentxm/registry-auth";
|
|
17
|
+
import { RegistryUrl } from "@agentxm/registry-client";
|
|
18
|
+
import { WorkspaceMutations, } from "@agentxm/workspace-state";
|
|
19
|
+
import { AuthoringOwnerMismatch, AuthoringOwnerRequired } from "./errors.js";
|
|
20
|
+
import { normalizeScaffoldOwner } from "./scaffold-name.js";
|
|
21
|
+
/** The settings file that records ownership, relative to the workspace root. */
|
|
22
|
+
export const settingsRelativePath = (path, ws) => path.relative(ws.baseDir, ws.layout.settingsPath);
|
|
23
|
+
/**
|
|
24
|
+
* Owners the person could plausibly have meant, most local first.
|
|
25
|
+
*
|
|
26
|
+
* These are named in the refusal only. Neither the user-scope owner nor the
|
|
27
|
+
* signed-in handle silently supplies authorship for the selected scope.
|
|
28
|
+
*/
|
|
29
|
+
const ownerCandidates = (ws) => Effect.gen(function* () {
|
|
30
|
+
const configured = yield* ws.getConfiguredOwner();
|
|
31
|
+
const registryUrl = yield* RegistryUrl;
|
|
32
|
+
// A keychain that cannot be read must not mask the ownership refusal that
|
|
33
|
+
// this lookup only decorates.
|
|
34
|
+
const loggedIn = yield* getCurrentUserHandle(registryUrl).pipe(Effect.catch(() => Effect.succeed(Option.none())));
|
|
35
|
+
const candidates = new Set();
|
|
36
|
+
if (Option.isSome(configured))
|
|
37
|
+
candidates.add(configured.value);
|
|
38
|
+
if (Option.isSome(loggedIn))
|
|
39
|
+
candidates.add(loggedIn.value);
|
|
40
|
+
return Array.from(candidates);
|
|
41
|
+
});
|
|
42
|
+
/**
|
|
43
|
+
* Resolve the owner an authoring command creates under, or refuse with the
|
|
44
|
+
* facts that make the refusal recoverable.
|
|
45
|
+
*/
|
|
46
|
+
export const resolveAuthoringOwner = (target, explicit) => Effect.gen(function* () {
|
|
47
|
+
const ws = yield* WorkspaceMutations;
|
|
48
|
+
const path = yield* Path.Path;
|
|
49
|
+
const configured = ws.layout.owner;
|
|
50
|
+
if (Option.isNone(explicit)) {
|
|
51
|
+
if (configured === undefined) {
|
|
52
|
+
return yield* new AuthoringOwnerRequired({
|
|
53
|
+
subject: target.subject,
|
|
54
|
+
command: target.command,
|
|
55
|
+
name: target.name,
|
|
56
|
+
candidates: yield* ownerCandidates(ws),
|
|
57
|
+
settingsPath: settingsRelativePath(path, ws),
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
return { owner: configured, establish: Effect.void };
|
|
61
|
+
}
|
|
62
|
+
const requested = normalizeScaffoldOwner(explicit.value);
|
|
63
|
+
if (configured === undefined) {
|
|
64
|
+
return { owner: requested, establish: ws.setOwner(requested) };
|
|
65
|
+
}
|
|
66
|
+
if (configured !== requested) {
|
|
67
|
+
return yield* new AuthoringOwnerMismatch({ requested, configured });
|
|
68
|
+
}
|
|
69
|
+
return { owner: requested, establish: Effect.void };
|
|
70
|
+
});
|
|
71
|
+
/**
|
|
72
|
+
* Require an already-authored package's identity to agree with the selected
|
|
73
|
+
* workspace. Fork, adopt, and native import carry an owner in the identity
|
|
74
|
+
* they were given, so they confirm rather than resolve.
|
|
75
|
+
*/
|
|
76
|
+
export const requireAuthoredOwner = (owner, target) => Effect.gen(function* () {
|
|
77
|
+
const ws = yield* WorkspaceMutations;
|
|
78
|
+
const path = yield* Path.Path;
|
|
79
|
+
const configured = ws.layout.owner;
|
|
80
|
+
if (configured === undefined) {
|
|
81
|
+
return yield* new AuthoringOwnerRequired({
|
|
82
|
+
subject: target.subject,
|
|
83
|
+
command: target.command,
|
|
84
|
+
name: owner,
|
|
85
|
+
candidates: [owner],
|
|
86
|
+
settingsPath: settingsRelativePath(path, ws),
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
if (configured !== owner) {
|
|
90
|
+
return yield* new AuthoringOwnerMismatch({ requested: owner, configured });
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
//# sourceMappingURL=authoring-owner.js.map
|