@tangle-network/agent-profile-materialize 0.4.0 → 0.5.1

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 (3) hide show
  1. package/dist/index.d.ts +51 -10
  2. package/dist/index.js +1162 -219
  3. package/package.json +2 -2
package/dist/index.d.ts CHANGED
@@ -21,7 +21,7 @@
21
21
  * `node:fs` IO consumer. It was previously copied byte-for-byte into both
22
22
  * cli-bridge and agent-dev-container — this is the single source those re-export.
23
23
  */
24
- import type { AgentCandidateConfigValue, AgentCandidateProfile, AgentCandidateProfileApplication, AgentCandidateProfilePlanEvidence, AgentProfile, Sha256Digest } from "@tangle-network/agent-interface";
24
+ import type { AgentCandidateConfigValue, AgentCandidateProfile, AgentCandidateProfileActivation, AgentCandidateProfileApplication, AgentCandidateProfilePlanEvidence, AgentCandidateProfilePlanMaterial, AgentProfile, AgentProfileMcpServer, Sha256Digest } from "@tangle-network/agent-interface";
25
25
  export type HarnessId = "claude-code" | "claude" | "claudish" | "nanoclaw" | "codex" | "opencode" | "kimi-code" | "kimi" | "pi" | "gemini" | "hermes" | "openclaw";
26
26
  export interface PlanFile {
27
27
  relPath: string;
@@ -30,7 +30,7 @@ export interface PlanFile {
30
30
  mode?: number;
31
31
  }
32
32
  export interface Unsupported {
33
- dimension: "files" | "skills" | "mcp" | "hooks" | "subagents" | "commands" | "instructions" | "systemPrompt" | "permissions" | "tools";
33
+ dimension: "files" | "skills" | "mcp" | "hooks" | "subagents" | "commands" | "instructions" | "systemPrompt" | "connections" | "confidential" | "permissions" | "tools" | "modes" | "extensions";
34
34
  reason: string;
35
35
  }
36
36
  /** The plan a caller writes into the run cwd, then applies to the spawn. */
@@ -42,6 +42,8 @@ export interface WorkspacePlan {
42
42
  env: Record<string, string>;
43
43
  /** Extra CLI flags to pass (e.g. kimi --mcp-config-file <path>). */
44
44
  flags: string[];
45
+ /** Exact system-prompt replacement supplied to the harness. */
46
+ systemPrompt?: string;
45
47
  /** Dimensions requested but with NO cwd path on this harness — fail-closed record. */
46
48
  unsupported: Unsupported[];
47
49
  }
@@ -54,31 +56,57 @@ export interface WorkspacePlanReceipt {
54
56
  workspacePlanDigest: string;
55
57
  env: Record<string, string>;
56
58
  flags: string[];
59
+ systemPrompt?: string;
57
60
  unsupported: Unsupported[];
58
61
  written: string[];
59
62
  }
63
+ /** The plan was applied, but one or more private staging files remain. */
64
+ export declare class WorkspacePlanCleanupError extends AggregateError {
65
+ readonly receipt: WorkspacePlanReceipt;
66
+ readonly temporaryPaths: readonly string[];
67
+ constructor(errors: readonly unknown[], receipt: WorkspacePlanReceipt, temporaryPaths: readonly string[]);
68
+ }
69
+ export interface ApplyWorkspacePlanOptions {
70
+ /** Plan files consumed in memory by the runtime and never persisted to cwd. */
71
+ runtimeOnlyFiles?: readonly string[];
72
+ /** Existing workspace paths are either exact idempotent inputs or forbidden. */
73
+ existingFiles?: "allow-identical" | "reject";
74
+ }
75
+ /** Fail when a profile asks for controls the chosen harness cannot execute. */
76
+ export declare function assertWorkspacePlanSupported(plan: Pick<WorkspacePlan, "unsupported">): void;
60
77
  /**
61
78
  * Candidate-safe workspace plan. Spawn values remain typed until the runtime
62
79
  * resolves them; the materializer never joins argv into a shell command.
63
80
  */
64
81
  export interface AgentCandidateWorkspacePlan {
82
+ sourceProfileDigest: Sha256Digest;
65
83
  harness: HarnessId;
66
84
  files: PlanFile[];
67
85
  env: Record<string, AgentCandidateConfigValue>;
68
86
  flags: AgentCandidateConfigValue[];
87
+ systemPrompt?: AgentCandidateConfigValue;
69
88
  unsupported: Unsupported[];
70
89
  }
71
90
  export interface AgentCandidateWorkspacePlanReceipt {
72
- profilePlan: AgentCandidateProfilePlanEvidence;
91
+ profileActivation: AgentCandidateProfileActivation;
73
92
  application: AgentCandidateProfileApplication;
74
93
  env: Record<string, AgentCandidateConfigValue>;
75
94
  flags: AgentCandidateConfigValue[];
95
+ systemPrompt?: AgentCandidateConfigValue;
76
96
  unsupported: Unsupported[];
77
97
  }
78
98
  export interface MaterializeCandidateProfileOptions {
79
99
  /** Exact text fetched from pinned resource refs, keyed by declared SHA-256. */
80
100
  resolvedResources?: ReadonlyMap<Sha256Digest, string>;
81
101
  }
102
+ export interface ResolveAgentProfileResourcesOptions {
103
+ /** Repository used when a GitHub resource omits its own `repository`. */
104
+ repository?: string;
105
+ fetch?: typeof globalThis.fetch;
106
+ timeoutMs?: number;
107
+ }
108
+ /** Resolve every GitHub resource to exact inline bytes before materialization. */
109
+ export declare function resolveAgentProfileResources(inputProfile: AgentProfile, options?: ResolveAgentProfileResourcesOptions): Promise<AgentProfile>;
82
110
  /** Normalize any skill markdown (VB frontmatter `skill:`/`description:`, or raw) into a
83
111
  * harness SKILL.md with `name:`/`description:` frontmatter the harnesses require. */
84
112
  export declare function normalizeSkillMd(name: string, raw: string): string;
@@ -86,14 +114,13 @@ export declare function normalizeSkillMd(name: string, raw: string): string;
86
114
  * Build the WorkspacePlan for `profile` on `harness`. Pure — no IO. The caller
87
115
  * writes plan.files into the run cwd and applies plan.env/plan.flags to the spawn.
88
116
  */
89
- export declare function materializeProfile(profile: AgentProfile, harness: HarnessId, opts?: {
117
+ export declare function materializeProfile(inputProfile: AgentProfile, harness: HarnessId, opts?: {
90
118
  skip?: Unsupported["dimension"][];
91
119
  }): WorkspacePlan;
92
120
  /**
93
121
  * Materialize a sealed candidate profile without weakening its process values.
94
- * Candidate hooks deliberately fail closed because the currently supported
95
- * native hook formats accept a shell command string rather than executable +
96
- * argv + env as separate fields.
122
+ * Codex and Claude hooks use generated no-shell wrappers to preserve executable,
123
+ * argv, and environment values separately. Other hook formats fail closed.
97
124
  */
98
125
  export declare function materializeCandidateProfile(profile: AgentCandidateProfile, harness: HarnessId, opts?: MaterializeCandidateProfileOptions): AgentCandidateWorkspacePlan;
99
126
  /**
@@ -103,13 +130,13 @@ export declare function materializeCandidateProfile(profile: AgentCandidateProfi
103
130
  */
104
131
  export declare function hashWorkspacePlan(plan: WorkspacePlan): string;
105
132
  /** Build the exact digest-free identity document required by agent-interface. */
106
- export declare function agentCandidateProfilePlanMaterial(plan: AgentCandidateWorkspacePlan): AgentCandidateProfilePlanEvidence["material"];
133
+ export declare function agentCandidateProfilePlanMaterial(plan: AgentCandidateWorkspacePlan): AgentCandidateProfilePlanMaterial;
107
134
  /**
108
135
  * Return the RFC 8785 UTF-8 bytes and SHA-256 identity of a candidate profile
109
136
  * plan. The returned bytes are the exact bytes embedded in receipt evidence.
110
137
  */
111
138
  export declare function canonicalizeAgentCandidateProfilePlan(plan: AgentCandidateWorkspacePlan): {
112
- material: AgentCandidateProfilePlanEvidence["material"];
139
+ material: AgentCandidateProfilePlanMaterial;
113
140
  bytes: Uint8Array;
114
141
  digest: Sha256Digest;
115
142
  };
@@ -126,4 +153,18 @@ export declare function applyAgentCandidateWorkspacePlan(plan: AgentCandidateWor
126
153
  * consumer of the pure `materializeProfile` — used by the cli-bridge host spawn, the
127
154
  * agent-dev-container box, and VB. Returns `unsupported` so the caller can log/fail.
128
155
  */
129
- export declare function applyWorkspacePlan(plan: WorkspacePlan, workspaceDir: string): WorkspacePlanReceipt;
156
+ export declare function applyWorkspacePlan(plan: WorkspacePlan, workspaceDir: string, options?: ApplyWorkspacePlanOptions): WorkspacePlanReceipt;
157
+ /** OpenCode-native MCP configuration used by workspace and startup paths. */
158
+ export type OpenCodeMcpConfig = Record<string, {
159
+ type: "remote";
160
+ url: string;
161
+ enabled: boolean;
162
+ headers?: Record<string, string>;
163
+ } | {
164
+ type: "local";
165
+ command: string[];
166
+ enabled: boolean;
167
+ environment?: Record<string, string>;
168
+ }>;
169
+ /** Lower canonical MCP definitions to OpenCode's native startup configuration. */
170
+ export declare function openCodeMcpConfig(mcp: Record<string, AgentProfileMcpServer>): OpenCodeMcpConfig;