@skastr0/prism-darwin-x64 0.1.0 → 0.1.2

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.
Files changed (46) hide show
  1. package/bin/prism +0 -0
  2. package/package.json +9 -1
  3. package/types/compile/bundle-utils.d.ts +16 -0
  4. package/types/compile/cache.d.ts +49 -0
  5. package/types/compile/compile-manifest.d.ts +48 -0
  6. package/types/compile/compose.d.ts +35 -0
  7. package/types/compile/errors.d.ts +124 -0
  8. package/types/compile/generated-plugin.d.ts +8 -0
  9. package/types/compile/load.d.ts +23 -0
  10. package/types/compile/paths.d.ts +2 -0
  11. package/types/compile/protocol-tools.d.ts +47 -0
  12. package/types/compile/refs.d.ts +7 -0
  13. package/types/compile/registry.d.ts +32 -0
  14. package/types/compile/resolve.d.ts +63 -0
  15. package/types/compile/runtime/schema-bridge.d.ts +61 -0
  16. package/types/compile/runtime-deps.d.ts +6 -0
  17. package/types/compile/sources.d.ts +2782 -0
  18. package/types/content-hash.d.ts +1 -0
  19. package/types/errors.d.ts +107 -0
  20. package/types/fs.d.ts +60 -0
  21. package/types/harnesses.d.ts +10 -0
  22. package/types/index.d.ts +493 -0
  23. package/types/lowerer-capabilities.d.ts +559 -0
  24. package/types/manifest.d.ts +106 -0
  25. package/types/prism-home.d.ts +26 -0
  26. package/types/project-key.d.ts +48 -0
  27. package/types/source-selection.d.ts +38 -0
  28. package/types/state/lock.d.ts +14 -0
  29. package/types/types.d.ts +193 -0
  30. package/types/workflow-amp-worker.d.ts +12 -0
  31. package/types/workflow-antigravity-worker.d.ts +14 -0
  32. package/types/workflow-claude-worker.d.ts +13 -0
  33. package/types/workflow-codex-worker.d.ts +12 -0
  34. package/types/workflow-grok-worker.d.ts +14 -0
  35. package/types/workflow-hermes-worker.d.ts +14 -0
  36. package/types/workflow-kimi-worker.d.ts +13 -0
  37. package/types/workflow-loader.d.ts +64 -0
  38. package/types/workflow-opencode-worker.d.ts +12 -0
  39. package/types/workflow-runner.d.ts +69 -0
  40. package/types/workflow-store.d.ts +214 -0
  41. package/types/workflow-tsconfig.d.ts +90 -0
  42. package/types/workflow-worker-contract.d.ts +10 -0
  43. package/types/workflow-worker-metadata.d.ts +8 -0
  44. package/types/workflow-worker-process.d.ts +18 -0
  45. package/types/workflow-workers.d.ts +27 -0
  46. package/types/workflows.d.ts +145 -0
package/bin/prism CHANGED
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@skastr0/prism-darwin-x64",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "type": "module",
5
5
  "description": "Prism standalone CLI binary for macOS x64.",
6
6
  "license": "MIT",
@@ -16,6 +16,13 @@
16
16
  "publishConfig": {
17
17
  "access": "public"
18
18
  },
19
+ "dependencies": {
20
+ "@modelcontextprotocol/sdk": "1.29.0",
21
+ "@opencode-ai/plugin": "^1.15.13",
22
+ "effect": "^3.21.1",
23
+ "typescript": "^5.8.3",
24
+ "zod": "4.4.3"
25
+ },
19
26
  "os": [
20
27
  "darwin"
21
28
  ],
@@ -24,6 +31,7 @@
24
31
  ],
25
32
  "files": [
26
33
  "bin",
34
+ "types",
27
35
  "LICENSE"
28
36
  ]
29
37
  }
@@ -0,0 +1,16 @@
1
+ export declare const NODE_BUILTIN_EXTERNALS: string[];
2
+ export declare const BARE_IMPORT_PATTERN: RegExp;
3
+ export declare const RELATIVE_IMPORT_PATTERN: RegExp;
4
+ export declare const collectRelativeImportSpecifiers: (source: string) => string[];
5
+ export declare const packageNameFromSpecifier: (specifier: string) => string;
6
+ export declare const relativeModulePath: (fromFile: string, toFileWithoutExtension: string) => string;
7
+ export declare const resolveImportedSourcePath: (sourcePath: string, source: string) => string;
8
+ export declare const stripToolAuthoringHelpers: (source: string) => string;
9
+ export declare const rewriteGeneratedPluginBundleImports: (source: string, currentGeneratedPath: string) => string;
10
+ export declare const resolveTsImportCandidate: (absoluteWithoutQuery: string, fileExists: (path: string) => Promise<boolean>) => Promise<string | undefined>;
11
+ export declare const rewriteBareImportsForBundle: (source: string, replacements: ReadonlyMap<string, string>) => string;
12
+ export declare const rewriteBareEffectImportsForBundle: (source: string) => string;
13
+ export declare const rewriteBarePluginDependencyImportsForBundle: (options: {
14
+ readonly source: string;
15
+ readonly pluginRoot?: string;
16
+ }) => Promise<string>;
@@ -0,0 +1,49 @@
1
+ /**
2
+ * Content-addressable cache for compiled agents.
3
+ *
4
+ * Cache key: hash(normalized source fingerprint + target + scope + compiler semantics)
5
+ * Cache value: serialized ComposedAgent + primary output hashes.
6
+ */
7
+ import type { ComposedAgent } from "./compose.js";
8
+ import type { Agent } from "./sources.js";
9
+ import type { PluginRegistry } from "./registry.js";
10
+ interface CacheContext {
11
+ readonly target: string;
12
+ readonly scope: string;
13
+ }
14
+ export declare const CACHE_FORMAT_VERSION = 3;
15
+ /**
16
+ * Bump this whenever compile/lowering semantics change without a corresponding
17
+ * source DSL change. This prevents stale composed agents from surviving compiler
18
+ * fixes such as generated tool naming or permission-lowering changes.
19
+ */
20
+ export declare const COMPILER_SEMANTICS_VERSION = "2026-06-12-compose-manifest-metadata-v1";
21
+ export interface CacheInputFile {
22
+ readonly plugin: string;
23
+ readonly path: string;
24
+ readonly contentHash: string;
25
+ }
26
+ export interface AgentCacheDescriptor {
27
+ readonly key: string;
28
+ readonly sourceHash: string;
29
+ readonly contextHash: string;
30
+ readonly inputs: ReadonlyArray<CacheInputFile>;
31
+ }
32
+ export interface CacheEntry {
33
+ readonly key: string;
34
+ readonly sourceHash: string;
35
+ readonly contextHash: string;
36
+ readonly composed: ComposedAgent;
37
+ readonly outputs: Record<string, string>;
38
+ readonly timestamp: string;
39
+ }
40
+ export declare const computeCacheKey: (agentSource: string, options: CacheContext) => string;
41
+ export declare const computeContentHash: (content: string) => string;
42
+ export declare const computeStableHash: (value: unknown) => string;
43
+ export declare const computeContextHash: (options: CacheContext) => string;
44
+ export declare const computeAgentCacheDescriptor: (agent: Agent, registry: PluginRegistry, options: CacheContext) => Promise<AgentCacheDescriptor>;
45
+ export declare const getCacheDir: (pluginPath: string) => string;
46
+ export declare const readCacheEntry: (cacheDir: string, key: string) => Promise<CacheEntry | null>;
47
+ export declare const writeCacheEntry: (cacheDir: string, entry: CacheEntry) => Promise<void>;
48
+ export declare const cleanCache: (cacheDir: string) => Promise<void>;
49
+ export {};
@@ -0,0 +1,48 @@
1
+ import { type CompileManifest, type HarnessId, type HarnessScope } from "@skastr0/prism-core/compile-manifest";
2
+ import type { AgentCacheDescriptor } from "./cache.js";
3
+ import type { ComposedAgent } from "./compose.js";
4
+ import { type PluginRegistry } from "./registry.js";
5
+ export * from "@skastr0/prism-core/compile-manifest";
6
+ /**
7
+ * The per-project compile manifest partition
8
+ * (~/.prism/state/projects/<key>/compile-manifest.json). The project key
9
+ * dimension fixes the clobbering bug: two projects with a same-named local
10
+ * plugin no longer stomp each other in a single flat global manifest.
11
+ */
12
+ export declare const compileManifestPath: (prismHome: string, projectKey: string) => string;
13
+ export declare const isCompileManifestHarnessId: (value: string) => value is HarnessId;
14
+ export interface CompileManifestReadResult {
15
+ readonly manifest: CompileManifest;
16
+ readonly quarantinedPath?: string;
17
+ }
18
+ export declare const readCompileManifest: (prismHome: string, projectKey: string) => Promise<CompileManifestReadResult>;
19
+ export declare const commitCompileManifest: (options: {
20
+ readonly prismHome: string;
21
+ readonly projectKey: string;
22
+ readonly manifest: CompileManifest;
23
+ }) => Promise<void>;
24
+ export declare const buildCompileManifestForTarget: (options: {
25
+ readonly base: CompileManifest;
26
+ readonly registry: PluginRegistry;
27
+ readonly target: HarnessId;
28
+ readonly scope: HarnessScope;
29
+ readonly composed: ReadonlyArray<ComposedAgent>;
30
+ readonly cacheDescriptors: ReadonlyMap<string, AgentCacheDescriptor>;
31
+ /** When provided, this compile pass is authoritative for the source plugin's orbit identities (from prepareTargetOrbits, non-templates only). Threaded only for orbit-targeting compiles to avoid clearing on other targets. Minimal {name} shape (no sourcePath/phases/body). */
32
+ readonly orbits?: ReadonlyArray<{
33
+ readonly name: string;
34
+ }>;
35
+ }) => CompileManifest;
36
+ export declare const updateCompileManifestForTarget: (options: {
37
+ readonly prismHome: string;
38
+ readonly projectKey: string;
39
+ readonly registry: PluginRegistry;
40
+ readonly target: HarnessId;
41
+ readonly scope: HarnessScope;
42
+ readonly composed: ReadonlyArray<ComposedAgent>;
43
+ readonly cacheDescriptors: ReadonlyMap<string, AgentCacheDescriptor>;
44
+ /** Forwarded from surfaces.orbits pass in compilePluginForTarget; undefined means non-authoritative for orbits (carry base). */
45
+ readonly orbits?: ReadonlyArray<{
46
+ readonly name: string;
47
+ }>;
48
+ }) => Promise<void>;
@@ -0,0 +1,35 @@
1
+ /**
2
+ * Compose phase: take a ResolvedAgent and produce a target-agnostic
3
+ * ComposedAgent for the lowerers.
4
+ */
5
+ import type { NormalizedOrbitPhase as OrbitPhase } from "./sources.js";
6
+ import type { ResolvedAgent, ResolvedContractBinding } from "./resolve.js";
7
+ export interface ComposedAgentManifestMetadata {
8
+ readonly traits: ReadonlyArray<{
9
+ readonly id: string;
10
+ readonly ref: string;
11
+ }>;
12
+ readonly modelBindings: {
13
+ readonly modelspace?: string;
14
+ readonly profile?: string;
15
+ };
16
+ }
17
+ export interface ComposedAgent {
18
+ readonly name: string;
19
+ readonly description: string;
20
+ readonly body: string;
21
+ readonly color: string | undefined;
22
+ readonly model: Record<string, unknown> | undefined;
23
+ readonly targetOverride: Record<string, unknown>;
24
+ readonly skills: ReadonlyArray<string>;
25
+ readonly allowedSkills: ReadonlyArray<string>;
26
+ readonly toolBindings: ReadonlyArray<ResolvedContractBinding>;
27
+ readonly allowedTools: ReadonlyArray<string>;
28
+ readonly manifest?: ComposedAgentManifestMetadata;
29
+ }
30
+ export interface ComposedOrbitPhaseReference {
31
+ readonly label: string;
32
+ readonly detailLines: ReadonlyArray<string>;
33
+ }
34
+ export declare const composeAgent: (resolved: ResolvedAgent) => ComposedAgent;
35
+ export declare const composeOrbitPhaseReference: (phase: OrbitPhase) => ComposedOrbitPhaseReference;
@@ -0,0 +1,124 @@
1
+ /**
2
+ * Typed compile errors for the structured compile-language pipeline.
3
+ *
4
+ * These tags are members of the `PrismError` union in src/errors.ts; the CLI
5
+ * edge renders them via `renderPrismError`/`renderPrismCause`. The canonical
6
+ * `PluginManifestError` lives in src/errors.ts (type-only import here keeps
7
+ * the modules cycle-free at runtime).
8
+ */
9
+ import { Schema } from "effect";
10
+ import type { PluginManifestError } from "../errors.js";
11
+ declare const SourceParseError_base: Schema.TaggedErrorClass<SourceParseError, "SourceParseError", {
12
+ readonly _tag: Schema.tag<"SourceParseError">;
13
+ } & {
14
+ sourcePath: typeof Schema.String;
15
+ kind: Schema.Literal<["identity", "personality", "trait", "agent", "toolspace", "modelspace", "skillspace", "orbit", "tool", "hook"]>;
16
+ message: typeof Schema.String;
17
+ }>;
18
+ export declare class SourceParseError extends SourceParseError_base {
19
+ }
20
+ declare const UnknownReferenceError_base: Schema.TaggedErrorClass<UnknownReferenceError, "UnknownReferenceError", {
21
+ readonly _tag: Schema.tag<"UnknownReferenceError">;
22
+ } & {
23
+ agentName: typeof Schema.String;
24
+ sourcePath: typeof Schema.String;
25
+ field: Schema.Literal<["identity", "personality", "model", "trait", "tool", "tool-group", "skill", "orbit", "phase.orbit", "phase.agent"]>;
26
+ referenceName: typeof Schema.String;
27
+ }>;
28
+ export declare class UnknownReferenceError extends UnknownReferenceError_base {
29
+ }
30
+ declare const UnknownDependencyError_base: Schema.TaggedErrorClass<UnknownDependencyError, "UnknownDependencyError", {
31
+ readonly _tag: Schema.tag<"UnknownDependencyError">;
32
+ } & {
33
+ sourcePath: typeof Schema.String;
34
+ referenceName: typeof Schema.String;
35
+ depPrefix: typeof Schema.String;
36
+ declaredDeps: Schema.Array$<typeof Schema.String>;
37
+ }>;
38
+ export declare class UnknownDependencyError extends UnknownDependencyError_base {
39
+ }
40
+ declare const DependencyCycleError_base: Schema.TaggedErrorClass<DependencyCycleError, "DependencyCycleError", {
41
+ readonly _tag: Schema.tag<"DependencyCycleError">;
42
+ } & {
43
+ cycle: Schema.Array$<typeof Schema.String>;
44
+ }>;
45
+ export declare class DependencyCycleError extends DependencyCycleError_base {
46
+ }
47
+ declare const UnknownTargetError_base: Schema.TaggedErrorClass<UnknownTargetError, "UnknownTargetError", {
48
+ readonly _tag: Schema.tag<"UnknownTargetError">;
49
+ } & {
50
+ target: typeof Schema.String;
51
+ supportedTargets: Schema.Array$<typeof Schema.String>;
52
+ }>;
53
+ export declare class UnknownTargetError extends UnknownTargetError_base {
54
+ }
55
+ declare const InvalidTargetScopeError_base: Schema.TaggedErrorClass<InvalidTargetScopeError, "InvalidTargetScopeError", {
56
+ readonly _tag: Schema.tag<"InvalidTargetScopeError">;
57
+ } & {
58
+ target: typeof Schema.String;
59
+ scope: typeof Schema.String;
60
+ message: typeof Schema.String;
61
+ }>;
62
+ export declare class InvalidTargetScopeError extends InvalidTargetScopeError_base {
63
+ }
64
+ declare const UnsupportedTargetCapabilityError_base: Schema.TaggedErrorClass<UnsupportedTargetCapabilityError, "UnsupportedTargetCapabilityError", {
65
+ readonly _tag: Schema.tag<"UnsupportedTargetCapabilityError">;
66
+ } & {
67
+ target: typeof Schema.String;
68
+ capability: Schema.Literal<["compiled-agents", "generated-canonical-tools", "hooks", "skill-permissions"]>;
69
+ message: typeof Schema.String;
70
+ }>;
71
+ export declare class UnsupportedTargetCapabilityError extends UnsupportedTargetCapabilityError_base {
72
+ }
73
+ declare const OrbitValidationError_base: Schema.TaggedErrorClass<OrbitValidationError, "OrbitValidationError", {
74
+ readonly _tag: Schema.tag<"OrbitValidationError">;
75
+ } & {
76
+ sourcePath: typeof Schema.String;
77
+ orbitName: typeof Schema.String;
78
+ field: typeof Schema.String;
79
+ message: typeof Schema.String;
80
+ }>;
81
+ export declare class OrbitValidationError extends OrbitValidationError_base {
82
+ }
83
+ declare const AgentValidationError_base: Schema.TaggedErrorClass<AgentValidationError, "AgentValidationError", {
84
+ readonly _tag: Schema.tag<"AgentValidationError">;
85
+ } & {
86
+ sourcePath: typeof Schema.String;
87
+ agentName: typeof Schema.String;
88
+ field: typeof Schema.String;
89
+ message: typeof Schema.String;
90
+ }>;
91
+ export declare class AgentValidationError extends AgentValidationError_base {
92
+ }
93
+ declare const DuplicateNameError_base: Schema.TaggedErrorClass<DuplicateNameError, "DuplicateNameError", {
94
+ readonly _tag: Schema.tag<"DuplicateNameError">;
95
+ } & {
96
+ kind: Schema.Literal<["identity", "personality", "trait", "agent", "toolspace", "modelspace", "skillspace", "orbit", "tool", "hook"]>;
97
+ name: typeof Schema.String;
98
+ firstPath: typeof Schema.String;
99
+ secondPath: typeof Schema.String;
100
+ }>;
101
+ export declare class DuplicateNameError extends DuplicateNameError_base {
102
+ }
103
+ declare const AgentNameMismatchError_base: Schema.TaggedErrorClass<AgentNameMismatchError, "AgentNameMismatchError", {
104
+ readonly _tag: Schema.tag<"AgentNameMismatchError">;
105
+ } & {
106
+ sourcePath: typeof Schema.String;
107
+ fileStem: typeof Schema.String;
108
+ agentName: typeof Schema.String;
109
+ }>;
110
+ export declare class AgentNameMismatchError extends AgentNameMismatchError_base {
111
+ }
112
+ declare const MissingTargetResolutionError_base: Schema.TaggedErrorClass<MissingTargetResolutionError, "MissingTargetResolutionError", {
113
+ readonly _tag: Schema.tag<"MissingTargetResolutionError">;
114
+ } & {
115
+ agentName: typeof Schema.String;
116
+ referenceKind: Schema.Literal<["model-profile", "tool", "tool-group", "skill"]>;
117
+ referenceName: typeof Schema.String;
118
+ target: typeof Schema.String;
119
+ }>;
120
+ export declare class MissingTargetResolutionError extends MissingTargetResolutionError_base {
121
+ }
122
+ export type CompileError = SourceParseError | UnknownReferenceError | OrbitValidationError | AgentValidationError | UnknownTargetError | InvalidTargetScopeError | UnsupportedTargetCapabilityError | DuplicateNameError | AgentNameMismatchError | MissingTargetResolutionError | UnknownDependencyError | DependencyCycleError | PluginManifestError;
123
+ export declare const formatCompileError: (error: CompileError) => string;
124
+ export {};
@@ -0,0 +1,8 @@
1
+ import type { ResolvedContractBinding } from "./resolve.js";
2
+ export declare const normalizeGeneratedPluginName: (pluginName: string) => string;
3
+ export declare const sanitizeGeneratedToolSegment: (value: string, fallback: string) => string;
4
+ export declare const generatedToolNamespace: (pluginName: string) => string;
5
+ export declare const generatedOwnerToolName: (toolPluginName: string, toolName: string) => string;
6
+ export declare const generatedSyntheticToolName: (sourcePluginName: string, contractName: string) => string;
7
+ export declare const generatedToolNameForBinding: (sourcePluginName: string, binding: ResolvedContractBinding) => string;
8
+ export declare const sourceIsInside: (sourcePath: string, root: string) => boolean;
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Load phase: discover source files in a plugin and parse them into typed
3
+ * registry entries.
4
+ *
5
+ * Canonical structured artifacts are TypeScript-authored.
6
+ */
7
+ import { Effect } from "effect";
8
+ import { type CompileError } from "./errors.js";
9
+ import { type PluginRegistry } from "./registry.js";
10
+ export declare const getImportRuntimePaths: () => Promise<{
11
+ readonly authoring: string;
12
+ readonly effect: string;
13
+ readonly workflowDsl: string;
14
+ }>;
15
+ export interface PrepareImportWrapperOptions {
16
+ /** When true, resolve `prism`/`prism/refs` for workflow execution rather than plugin compilation. */
17
+ readonly workflow?: boolean;
18
+ }
19
+ export declare const prepareImportWrapper: (sourcePath: string, options?: PrepareImportWrapperOptions) => Promise<{
20
+ readonly specifier: string;
21
+ readonly cleanup: () => Promise<void>;
22
+ }>;
23
+ export declare const loadPlugin: (pluginPath: string) => Effect.Effect<PluginRegistry, CompileError>;
@@ -0,0 +1,2 @@
1
+ export declare const normalizeRelativePath: (from: string, to: string) => string;
2
+ export declare const compareByStringKeys: <T>(first: (value: T) => string, second: (value: T) => string) => (left: T, right: T) => number;
@@ -0,0 +1,47 @@
1
+ import { Contract, type NormalizedTraitBinding, type Trait } from "./sources.js";
2
+ import type { PluginRegistry } from "./registry.js";
3
+ export interface ProtocolSurfaceError {
4
+ readonly field: string;
5
+ readonly message: string;
6
+ }
7
+ export interface ToolPermissionBinding {
8
+ readonly kind: "permission";
9
+ readonly logicalName: string;
10
+ readonly contract?: undefined;
11
+ readonly toolPluginName: string;
12
+ readonly toolName: string;
13
+ readonly toolSourcePath: string;
14
+ }
15
+ export interface SyntheticToolBinding {
16
+ readonly kind: "synthetic";
17
+ readonly logicalName: string;
18
+ readonly contract: Contract;
19
+ readonly toolPluginName: string;
20
+ readonly toolName: string;
21
+ readonly toolSourcePath: string;
22
+ }
23
+ export type MaterializedTraitTool = ToolPermissionBinding | SyntheticToolBinding;
24
+ export type MaterializedOrbitToolPermission = MaterializedTraitTool;
25
+ export type TraitBindingValidationResult = {
26
+ readonly ok: true;
27
+ } | {
28
+ readonly ok: false;
29
+ readonly error: ProtocolSurfaceError;
30
+ };
31
+ type MaterializeTraitToolsOptions = {
32
+ readonly agentName: string;
33
+ readonly ownerPluginName: string;
34
+ readonly canonicalTraitId: string;
35
+ readonly trait: Trait;
36
+ readonly binding: NormalizedTraitBinding;
37
+ readonly registry: PluginRegistry;
38
+ readonly refRegistry?: PluginRegistry;
39
+ };
40
+ export declare const validateTraitBindingSlots: (trait: Trait, binding: NormalizedTraitBinding) => TraitBindingValidationResult;
41
+ export declare const materializeTraitTools: (options: MaterializeTraitToolsOptions) => ReadonlyArray<MaterializedTraitTool> | ProtocolSurfaceError;
42
+ export declare const materializeOrbitToolPermission: (options: {
43
+ readonly logicalName: string;
44
+ readonly toolRef: string;
45
+ readonly registry: PluginRegistry;
46
+ }) => MaterializedOrbitToolPermission | ProtocolSurfaceError;
47
+ export {};
@@ -0,0 +1,7 @@
1
+ import { Effect } from "effect";
2
+ import { parseNamedRef, parseSpaceItemRef, registryForRef } from "@skastr0/prism-core/refs";
3
+ import { type CompileError } from "./errors.js";
4
+ import type { PluginRegistry } from "./registry.js";
5
+ export { parseNamedRef, parseSpaceItemRef, registryForRef };
6
+ export type { ParsedNamedRef, ParsedSpaceItemRef } from "@skastr0/prism-core/refs";
7
+ export declare const resolveRefToRegistry: (ref: string, currentRegistry: PluginRegistry, sourcePath: string) => Effect.Effect<PluginRegistry, CompileError>;
@@ -0,0 +1,32 @@
1
+ /**
2
+ * Plugin-local registry of parsed compile-language sources.
3
+ *
4
+ * Each registry owns its own source maps plus dep registries keyed by the dep
5
+ * alias declared in plugin.json. Bare refs resolve locally; prefixed refs
6
+ * resolve through the dep map.
7
+ */
8
+ import { Agent, CanonicalTool, Hook, Identity, Orbit, Modelspace, Personality, Skill, Skillspace, Toolspace, Trait } from "./sources.js";
9
+ import type { PluginManifestTargets, PluginRuntimeConfig } from "../types.js";
10
+ export interface PluginRegistry {
11
+ pluginPath: string;
12
+ pluginName: string;
13
+ pluginVersion: string;
14
+ dependencyPaths: Record<string, string>;
15
+ targets: PluginManifestTargets;
16
+ runtime: PluginRuntimeConfig;
17
+ identities: Map<string, Identity>;
18
+ personalities: Map<string, Personality>;
19
+ toolspaces: Map<string, Toolspace>;
20
+ modelspaces: Map<string, Modelspace>;
21
+ skillspaces: Map<string, Skillspace>;
22
+ skills: Map<string, Skill>;
23
+ traits: Map<string, Trait>;
24
+ tools: Map<string, CanonicalTool>;
25
+ hooks: Map<string, Hook>;
26
+ orbits: Map<string, Orbit>;
27
+ agents: Map<string, Agent>;
28
+ deps: Map<string, PluginRegistry>;
29
+ }
30
+ export declare const emptyRegistry: (pluginPath: string, pluginName: string, pluginVersion: string, dependencyPaths?: Record<string, string>, targets?: PluginManifestTargets, runtime?: PluginRuntimeConfig) => PluginRegistry;
31
+ export declare const collectPluginRegistries: (registry: PluginRegistry) => Map<string, PluginRegistry>;
32
+ export type Registry = PluginRegistry;
@@ -0,0 +1,63 @@
1
+ /**
2
+ * Resolve phase: materialize referenced parts for each agent and validate
3
+ * orbit wiring against the loaded registry graph.
4
+ */
5
+ import { Effect } from "effect";
6
+ import { Agent, Contract, Identity, Orbit, Personality, Trait, type NormalizedTraitBinding } from "./sources.js";
7
+ import { type CompileError } from "./errors.js";
8
+ import type { PluginRegistry } from "./registry.js";
9
+ export interface ResolvedContractBinding {
10
+ readonly kind: "permission" | "synthetic";
11
+ readonly logicalName: string;
12
+ readonly contract?: Contract;
13
+ readonly toolPluginName: string;
14
+ readonly toolName: string;
15
+ readonly toolSourcePath: string;
16
+ }
17
+ export interface ResolvedToolReference {
18
+ readonly kind: "permission" | "synthetic";
19
+ readonly logicalName: string;
20
+ readonly contract?: Contract;
21
+ readonly toolPluginName: string;
22
+ readonly toolName: string;
23
+ readonly toolSourcePath: string;
24
+ }
25
+ export interface ResolvedTrait {
26
+ readonly ref: string;
27
+ readonly canonicalId: string;
28
+ readonly trait: Trait;
29
+ readonly owner: PluginRegistry;
30
+ readonly binding: NormalizedTraitBinding;
31
+ }
32
+ export interface ResolvedAgentCapabilities {
33
+ readonly agent: Agent;
34
+ readonly traits: ReadonlyArray<ResolvedTrait>;
35
+ readonly canonicalTraitIds: ReadonlyArray<string>;
36
+ readonly skills: ReadonlyArray<string>;
37
+ readonly toolRefs: ReadonlyArray<ResolvedToolReference>;
38
+ readonly access: {
39
+ readonly tools: ReadonlyArray<string>;
40
+ readonly toolGroups: ReadonlyArray<string>;
41
+ readonly skills: ReadonlyArray<string>;
42
+ };
43
+ }
44
+ export interface ResolvedAgent {
45
+ readonly agent: Agent;
46
+ readonly identity: Identity;
47
+ readonly personality: Personality | undefined;
48
+ readonly resolvedModel: Record<string, unknown> | undefined;
49
+ readonly traits: ReadonlyArray<ResolvedTrait>;
50
+ readonly canonicalTraitIds: ReadonlyArray<string>;
51
+ readonly skills: ReadonlyArray<string>;
52
+ readonly allowedSkills: ReadonlyArray<string>;
53
+ readonly toolBindings: ReadonlyArray<ResolvedContractBinding>;
54
+ readonly allowedTools: ReadonlyArray<string>;
55
+ }
56
+ type BindingMap = Readonly<Record<string, string>>;
57
+ export declare const resolveAgentCapabilities: (agent: Agent, registry: PluginRegistry) => Effect.Effect<ResolvedAgentCapabilities, CompileError>;
58
+ export declare const resolveAgent: (agent: Agent, registry: PluginRegistry, target: string) => Effect.Effect<ResolvedAgent, CompileError>;
59
+ export declare const instantiateOrbit: (orbit: Orbit, bindings?: BindingMap) => Effect.Effect<Orbit, CompileError>;
60
+ export declare const resolveOrbitSkillPermissions: (orbits: ReadonlyArray<Orbit>, registry: PluginRegistry) => ReadonlyMap<string, ReadonlyArray<string>>;
61
+ export declare const resolveOrbitToolPermissions: (orbits: ReadonlyArray<Orbit>, registry: PluginRegistry) => Effect.Effect<ReadonlyMap<string, ReadonlyArray<ResolvedContractBinding>>, CompileError>;
62
+ export declare const validateOrbit: (orbit: Orbit, registry: PluginRegistry) => Effect.Effect<void, CompileError>;
63
+ export {};
@@ -0,0 +1,61 @@
1
+ /**
2
+ * Schema bridge: converts Effect Schema → the record of tool.schema builders
3
+ * that opencode's `tool({ args })` expects. Ships verbatim into every
4
+ * generated plugin at src/runtime/schema-bridge.ts.
5
+ *
6
+ * Supports the bounded schema feature set used in contracts:
7
+ *
8
+ * - StringKeyword, NumberKeyword, BooleanKeyword, UnknownKeyword
9
+ * - Literal (single) and Union of Literals (enum)
10
+ * - TupleType with rest (arrays)
11
+ * - TypeLiteral (nested structs)
12
+ * - Refinement and Transformation (unwrapped; brands preserved via description)
13
+ * - optional fields
14
+ *
15
+ * Annotations flow through: a field's Schema.annotations({ description }) is
16
+ * emitted as .describe(...) on the tool schema node so the LLM sees the
17
+ * contract's own documentation.
18
+ */
19
+ import { tool } from "@opencode-ai/plugin";
20
+ import { Schema } from "effect";
21
+ type ZodNode = Parameters<(typeof tool.schema)["array"]>[0] & {
22
+ describe(description: string): ZodNode;
23
+ optional(): ZodNode;
24
+ };
25
+ export interface ToolRuntimeCost {
26
+ inputTokens?: number;
27
+ outputTokens?: number;
28
+ totalTokens?: number;
29
+ estimatedCost?: number;
30
+ currency?: string;
31
+ }
32
+ /**
33
+ * Runtime context passed to synthetic contract handlers.
34
+ *
35
+ * The generated OpenCode adapter always provides `sessionID`, `agent`, and
36
+ * `timestamp`. Additional metadata stays optional so contract authors can
37
+ * tolerate harnesses that do not expose the richer fields yet.
38
+ */
39
+ export interface ToolRuntimeContext {
40
+ sessionID: string;
41
+ agent: string;
42
+ timestamp: string;
43
+ sessionTitle?: string;
44
+ durationMs?: number;
45
+ cost?: ToolRuntimeCost;
46
+ workingDirectory?: string;
47
+ repoRoot?: string;
48
+ signal?: AbortSignal;
49
+ }
50
+ /**
51
+ * Convert a top-level Schema.Struct to the args record opencode expects.
52
+ * Throws at plugin load time if the top-level schema is not a struct.
53
+ */
54
+ export declare const toolArgsFromSchema: (schema: Schema.Schema.Any) => Record<string, ZodNode>;
55
+ /**
56
+ * Decode raw tool-call args against the contract's Input schema. Throws a
57
+ * clear error if decoding fails; the error propagates back to the LLM as the
58
+ * tool call's failure message.
59
+ */
60
+ export declare const decodeInput: <A, I, R>(schema: Schema.Schema<A, I, R>, raw: unknown) => A;
61
+ export {};
@@ -0,0 +1,6 @@
1
+ export declare const effectBundleImportPath: () => string;
2
+ export declare const mcpSdkMcpBundleImportPath: () => string;
3
+ export declare const mcpSdkWebStandardHttpBundleImportPath: () => string;
4
+ export declare const opencodePluginBundleImportPath: () => string;
5
+ export declare const typescriptBundleImportPath: () => string;
6
+ export declare const zodV4BundleImportPath: () => string;