@tangle-network/agent-app 0.41.6 → 0.42.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.
package/README.md CHANGED
@@ -117,10 +117,9 @@ Each is an independent entry point — import only what you use.
117
117
  | [`/eval`](src/eval) | `producedFromToolEvents` (bridge tool events into the eval verifier) and `createTokenRecallChecker` (deterministic content check). Re-exports `@tangle-network/agent-eval`'s `verifyCompletion`, `extractProducedState`, `weightedComposite`, `createLlmCorrectnessChecker`. |
118
118
  | [`/tangle`](src/tangle) | App-registration consent URL (`buildConsentUrl`) and a cached, auto-refreshing broker-token provider (`createBrokerTokenProvider`). Structural over the tcloud client. |
119
119
  | [`/billing`](src/billing) | `createWorkspaceKeyManager` — mint / rotate / roll over / report usage on per-workspace, budget-capped model keys. Seams for provisioner, store, and crypto. |
120
- | [`/delegation`](src/delegation) | `buildDelegationMcpServer` — the agent-runtime driven-loop MCP (`delegate_research`, `delegate_code`, `delegation_status`) for multi-step work that runs to completion in its own sandbox. Opt-in. |
121
120
  | [`/crypto`](src/crypto) | AES-GCM field encryption: `encryptAesGcm`, `decryptAesGcm`, `createFieldCrypto`. Key supplied by the caller. |
122
121
  | [`/missions`](src/missions) | Durable multi-step mission orchestration over a `MissionStorePort` seam: guarded status/step machine, idempotent plan engine with budget/approval gates, `:::mission` parser, the client-safe live-event reducer, and the canonical `StepAgentActivity` per-step delegated-run lane. |
123
- | [`/trace`](src/trace) | Flow observability: `buildFlowTrace` + ASCII `renderWaterfall`/`renderHistogram`; the mission trace bridge (`createMissionTraceContext`, `childSpanContext`, `traceEnv`) whose ids/env agent-runtime's delegation MCP inherits; and delegation→FlowSpan converters (`delegationActivityToFlowSpans`, `loopTraceEventsToFlowSpans`, `composeMissionFlowTrace`). |
122
+ | [`/trace`](src/trace) | Flow observability: `buildFlowTrace` + ASCII `renderWaterfall`/`renderHistogram`; the mission trace bridge (`createMissionTraceContext`, `childSpanContext`, `traceEnv`) whose ids/env a delegated run inherits; and delegation→FlowSpan converters (`delegationActivityToFlowSpans`, `loopTraceEventsToFlowSpans`, `composeMissionFlowTrace`). |
124
123
  | [`/web-react`](src/web-react) | Shared React components: `ModelPicker`, `EffortPicker`, `ChatMessages`, `RunDrillIn`, plus the observability surfaces — `MissionActivityLane`, `AgentActivityPanel`, `FlowWaterfall`. React is an optional peer; not re-exported from the root entry. |
125
124
  | [`/web`](src/web) | Request-boundary utilities: `parseJsonObjectBody`, `requireString`, `extractRequestContext`, `checkRateLimit`, `addSecurityHeaders`. |
126
125
  | [`/stream`](src/stream) | SSE normalization and turn identity: `normalizeToolEvent`, `resolveChatTurn`, `encodeEvent`, message-part merging. |
@@ -107,14 +107,6 @@ var agentAppConfigJsonSchema = {
107
107
  generatedUi: { type: "boolean", description: "Whether the agent may emit generated UI." }
108
108
  }
109
109
  },
110
- delegation: {
111
- type: "object",
112
- additionalProperties: false,
113
- description: "Background-agent / delegated-loop capability (sandbox path).",
114
- properties: {
115
- enabled: { type: "boolean", description: "Whether the agent may spawn delegate_research/delegate_code loops." }
116
- }
117
- },
118
110
  model: {
119
111
  type: "object",
120
112
  additionalProperties: false,
@@ -134,4 +126,4 @@ export {
134
126
  defineAgentApp,
135
127
  agentAppConfigJsonSchema
136
128
  };
137
- //# sourceMappingURL=chunk-OC3RAUZ2.js.map
129
+ //# sourceMappingURL=chunk-OSMNYPOG.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/config/index.ts"],"sourcesContent":["/**\n * `@tangle-network/agent-app/config` — the typed `AgentAppConfig` contract.\n *\n * This is the single declarative DATA surface a coding agent fills to stand up a\n * new agent product. Everything an agent product otherwise hand-rolls as\n * imperative wiring — who the agent is, which proposal types exist and which are\n * approval-gated, what knowledge the control loop requires, which integrations\n * are connectable, how the model resolves — is expressed here as plain data the\n * rest of agent-app's modules consume through their typed seams:\n *\n * - `identity` → the system-prompt + disclaimer surface the chat pipeline reads.\n * - `taxonomy` → which `submit_proposal` types the `./tools` side channel\n * accepts, and which the approval queue treats as regulated\n * (certified-human-gated).\n * - `knowledge` → the `./knowledge` requirement specs that gate the loop, plus\n * the acquisition-loop goal/threshold the researcher pursues.\n * - `integrations` → which `@tangle-network/agent-integrations` catalog kinds the\n * product enables.\n * - `ui` → whether the agent may emit generated UI (`render_ui`).\n * - `model` → the `./runtime` `TangleModelConfig` (or null to resolve from env).\n *\n * Layering: this module is the CONTRACT only — pure types + an identity helper.\n * It introduces no behavior and no engine dependency; it REUSES the existing\n * `KnowledgeRequirementSpec`/`SatisfiedByRule` (from `../knowledge`) and\n * `TangleModelConfig` (from `../runtime`) rather than redefining them, so the\n * config a product authors is the exact shape those modules already consume.\n * Steps that build the composer/loader read this file as the schema floor.\n */\n\nimport type {\n KnowledgeRequirementSpec,\n SatisfiedByRule,\n} from '../knowledge/index'\nimport type { TangleModelConfig } from '../runtime/index'\n\n// Re-export the borrowed types so a config author has a single import surface\n// (`@tangle-network/agent-app/config`) and never has to reach into `../knowledge`\n// or `../runtime` to spell out a field's type. These are the SAME types the\n// knowledge gate and runtime model resolver consume — not parallel copies.\nexport type { KnowledgeRequirementSpec, SatisfiedByRule, TangleModelConfig }\n\n/**\n * Who the agent is, as data. Composed into the chat pipeline's system prompt;\n * never baked into agent-app (a domain value, per the layering contract).\n */\nexport interface AgentIdentityConfig {\n /** Product/agent name, e.g. `\"Acme Support Copilot\"`. Shown to the user and\n * available to the system-prompt builder. */\n name: string\n /** One-paragraph persona statement — the agent's role, voice, and remit. The\n * spine of the system prompt. */\n persona: string\n /** Additional system-prompt fragments appended verbatim after the persona\n * (standing workflows, hard rules, tone). Order is preserved. Optional. */\n systemPromptFragments?: string[]\n /** Named disclaimers the product surfaces (e.g. a regulatory human-in-the-loop\n * notice). Keyed by a stable id (`compliance`, `not-advice`, …) so the chat\n * pipeline / UI can select one by name. Values are the literal text. Optional. */\n disclaimers?: Record<string, string>\n}\n\n/**\n * The proposal taxonomy, as data. `proposalTypes` is the closed set of\n * `submit_proposal` types the `./tools` side channel accepts; `regulatedTypes`\n * is the subset that is approval-gated — the executor refuses to run one without\n * a certified human approver. `regulatedTypes` MUST be a subset of\n * `proposalTypes` (validated by the loader step; not enforced at the type level).\n */\nexport interface AgentTaxonomyConfig {\n /** Every proposal type this product can emit, e.g.\n * `['recommend', 'contact', 'escalate']`. The closed allow-list\n * the tool layer validates a `submit_proposal` call against. */\n proposalTypes: string[]\n /** The subset of `proposalTypes` that is regulated → cannot execute without a\n * certified-human approver. The approval executor reads this to decide which\n * proposals are fail-loud certified-gated. */\n regulatedTypes: string[]\n}\n\n/** A knowledge source the acquisition loop / researcher may draw on. */\nexport interface KnowledgeSourceSpec {\n /** Where the source lives — a URL, a `vault://` path, an integration ref, etc.\n * Opaque to agent-app; the consumer's loader resolves it. */\n uri: string\n /** Optional source classifier the researcher uses to pick a fetch strategy,\n * e.g. `'web'`, `'vault'`, `'regulation'`, `'integration'`. Free-form. */\n kind?: string\n}\n\n/**\n * The knowledge-acquisition loop config — the goal the researcher pursues and\n * the gate it must clear before the loop is considered satisfied. All optional;\n * a product with only static requirement specs omits it.\n */\nexport interface KnowledgeLoopConfig {\n /** The acquisition goal in natural language, e.g.\n * `\"ground every quoted premium against a real policy record\"`. */\n goal?: string\n /** The minimum aggregate confidence [0, 1] the loop must reach to pass its\n * gate. The runtime control loop blocks below this. Default decided by the\n * consumer's loop wiring when omitted. */\n minConfidence?: number\n /** How fresh acquired knowledge must be, e.g. `'static'`, `'7d'`, `'session'`.\n * Free-form; the consumer's loop interprets it. */\n freshness?: string\n}\n\n/**\n * The knowledge surface, as data. `sources` are what the researcher may read;\n * `requirements` are the declarative `./knowledge` specs that gate the control\n * loop (reused verbatim — the same `KnowledgeRequirementSpec` the gate scores);\n * `loop` configures the acquisition pass.\n */\nexport interface AgentKnowledgeConfig {\n /** Sources the acquisition loop / researcher may draw on. */\n sources: KnowledgeSourceSpec[]\n /** The declarative requirement specs that gate the loop. Reuses\n * `KnowledgeRequirementSpec` from `../knowledge` — `buildKnowledgeRequirements`\n * + `deriveSignals` consume these directly. */\n requirements: KnowledgeRequirementSpec[]\n /** Optional acquisition-loop config (goal + confidence gate + freshness). */\n loop?: KnowledgeLoopConfig\n}\n\n/**\n * Which integrations the product enables, as data. `enabled` lists\n * `@tangle-network/agent-integrations` catalog kinds the product connects\n * (e.g. `['salesforce', 'gmail', 'whatsapp']`); the integration hub resolves\n * each to a connector. Strings, not connector objects — agent-app bakes no\n * catalog value.\n */\nexport interface AgentIntegrationsConfig {\n /** Catalog kinds this product enables. */\n enabled: string[]\n}\n\n/** UI capability flags, as data. */\nexport interface AgentUiConfig {\n /** Whether the agent may emit generated UI (the `render_ui` / OpenUI side\n * channel). When false/omitted, the tool layer can omit/refuse the tool.\n * Default behavior decided by the consumer; omit to leave unset. */\n generatedUi?: boolean\n}\n\n/**\n * The declarative domain surface of a Tangle agent product.\n *\n * A coding agent fills THIS object and nothing else to define a product's\n * identity, proposal taxonomy, knowledge gate, integrations, UI capability, and\n * model. Every field is DATA consumed by an agent-app module through its typed\n * seam — no field is behavior. Author it through {@link defineAgentApp} for\n * autocomplete and a single import.\n */\nexport interface AgentAppConfig {\n /** Who the agent is — name, persona, system-prompt fragments, disclaimers. */\n identity: AgentIdentityConfig\n /** Proposal types + which are regulated/approval-gated. */\n taxonomy: AgentTaxonomyConfig\n /** Knowledge sources, requirement specs (the loop gate), and loop config. */\n knowledge: AgentKnowledgeConfig\n /** Enabled integration catalog kinds. */\n integrations: AgentIntegrationsConfig\n /** UI capability flags. Optional. */\n ui?: AgentUiConfig\n /** The resolved model config (`../runtime`'s `TangleModelConfig`). Omit to\n * resolve from env at boot via `resolveTangleModelConfig`. */\n model?: TangleModelConfig\n}\n\n/**\n * Identity helper: returns its argument unchanged, but anchors inference so a\n * coding agent authoring a config gets full autocomplete + type-checking from a\n * single import. The canonical way to declare a product config:\n *\n * ```ts\n * import { defineAgentApp } from '@tangle-network/agent-app/config'\n *\n * export const config = defineAgentApp({\n * identity: { name: 'Acme Ops', persona: '…' },\n * taxonomy: { proposalTypes: ['recommend', 'contact'], regulatedTypes: ['recommend'] },\n * knowledge: { sources: [], requirements: [] },\n * integrations: { enabled: ['salesforce'] },\n * })\n * ```\n */\nexport function defineAgentApp<const T extends AgentAppConfig>(config: T): T {\n return config\n}\n\n/**\n * Machine-readable JSON Schema (draft 2020-12) for {@link AgentAppConfig}.\n *\n * The schema FLOOR a non-TypeScript coding agent (or a config validator/UI) reads\n * to know the shape without parsing the `.d.ts`. Kept in lockstep with the\n * interfaces above by the config test, which asserts the documented fields are\n * present. `KnowledgeRequirementSpec`'s full sub-shape is intentionally left\n * `additionalProperties: true` here — its authoritative definition lives in\n * `../knowledge`; this floor pins only the fields the config contract owns.\n */\nexport const agentAppConfigJsonSchema = {\n $schema: 'https://json-schema.org/draft/2020-12/schema',\n $id: 'https://tangle.tools/schemas/agent-app-config.json',\n title: 'AgentAppConfig',\n description: 'The declarative domain surface of a Tangle agent product.',\n type: 'object',\n additionalProperties: false,\n required: ['identity', 'taxonomy', 'knowledge', 'integrations'],\n properties: {\n identity: {\n type: 'object',\n additionalProperties: false,\n required: ['name', 'persona'],\n properties: {\n name: { type: 'string', description: 'Product/agent name.' },\n persona: { type: 'string', description: 'One-paragraph persona — the system-prompt spine.' },\n systemPromptFragments: {\n type: 'array',\n items: { type: 'string' },\n description: 'Verbatim system-prompt fragments appended after the persona, in order.',\n },\n disclaimers: {\n type: 'object',\n additionalProperties: { type: 'string' },\n description: 'Named disclaimers keyed by stable id; values are literal text.',\n },\n },\n },\n taxonomy: {\n type: 'object',\n additionalProperties: false,\n required: ['proposalTypes', 'regulatedTypes'],\n properties: {\n proposalTypes: {\n type: 'array',\n items: { type: 'string' },\n description: 'Closed allow-list of proposal types the product can emit.',\n },\n regulatedTypes: {\n type: 'array',\n items: { type: 'string' },\n description: 'Subset of proposalTypes that is approval-gated (certified-human required).',\n },\n },\n },\n knowledge: {\n type: 'object',\n additionalProperties: false,\n required: ['sources', 'requirements'],\n properties: {\n sources: {\n type: 'array',\n description: 'Sources the acquisition loop may draw on.',\n items: {\n type: 'object',\n additionalProperties: false,\n required: ['uri'],\n properties: {\n uri: { type: 'string', description: 'Where the source lives (opaque to agent-app).' },\n kind: { type: 'string', description: 'Optional source classifier (web/vault/regulation/…).' },\n },\n },\n },\n requirements: {\n type: 'array',\n description: \"Declarative KnowledgeRequirementSpec[] (../knowledge) that gate the loop.\",\n items: { type: 'object', additionalProperties: true },\n },\n loop: {\n type: 'object',\n additionalProperties: false,\n description: 'Acquisition-loop config.',\n properties: {\n goal: { type: 'string', description: 'Acquisition goal in natural language.' },\n minConfidence: {\n type: 'number',\n minimum: 0,\n maximum: 1,\n description: 'Minimum aggregate confidence the loop must reach.',\n },\n freshness: { type: 'string', description: 'How fresh acquired knowledge must be.' },\n },\n },\n },\n },\n integrations: {\n type: 'object',\n additionalProperties: false,\n required: ['enabled'],\n properties: {\n enabled: {\n type: 'array',\n items: { type: 'string' },\n description: 'Enabled agent-integrations catalog kinds.',\n },\n },\n },\n ui: {\n type: 'object',\n additionalProperties: false,\n description: 'UI capability flags.',\n properties: {\n generatedUi: { type: 'boolean', description: 'Whether the agent may emit generated UI.' },\n },\n },\n model: {\n type: 'object',\n additionalProperties: false,\n description: \"Resolved TangleModelConfig (../runtime). Omit to resolve from env.\",\n required: ['provider', 'model', 'apiKey', 'baseUrl'],\n properties: {\n provider: { type: 'string', enum: ['openai-compat', 'anthropic'] },\n model: { type: 'string' },\n apiKey: { type: 'string' },\n baseUrl: { type: 'string' },\n },\n },\n },\n} as const\n"],"mappings":"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","names":[]}
@@ -11,4 +11,4 @@ export {
11
11
  DesignCanvasLazy,
12
12
  DesignCanvasChromeLazy
13
13
  };
14
- //# sourceMappingURL=chunk-FJUOBNIY.js.map
14
+ //# sourceMappingURL=chunk-WOVCWPFF.js.map
@@ -128,15 +128,6 @@ interface AgentUiConfig {
128
128
  * Default behavior decided by the consumer; omit to leave unset. */
129
129
  generatedUi?: boolean;
130
130
  }
131
- /** Background-agent / delegated-loop capability, as data. */
132
- interface AgentDelegationConfig {
133
- /** When true, the app's own agent may spawn `delegate_research` /
134
- * `delegate_code` loops that run to completion in their OWN sandbox and
135
- * return the artifact (the `../delegation` driven-loop MCP). Sandbox-path
136
- * ONLY — the browser/edge path ignores it. Wired via the existing
137
- * `buildDelegationMcpServer`; never reimplemented. */
138
- enabled?: boolean;
139
- }
140
131
  /**
141
132
  * The declarative domain surface of a Tangle agent product.
142
133
  *
@@ -157,8 +148,6 @@ interface AgentAppConfig {
157
148
  integrations: AgentIntegrationsConfig;
158
149
  /** UI capability flags. Optional. */
159
150
  ui?: AgentUiConfig;
160
- /** Background-agent / delegated-loop capability (sandbox path). Optional. */
161
- delegation?: AgentDelegationConfig;
162
151
  /** The resolved model config (`../runtime`'s `TangleModelConfig`). Omit to
163
152
  * resolve from env at boot via `resolveTangleModelConfig`. */
164
153
  model?: TangleModelConfig;
@@ -329,17 +318,6 @@ declare const agentAppConfigJsonSchema: {
329
318
  };
330
319
  };
331
320
  };
332
- readonly delegation: {
333
- readonly type: "object";
334
- readonly additionalProperties: false;
335
- readonly description: "Background-agent / delegated-loop capability (sandbox path).";
336
- readonly properties: {
337
- readonly enabled: {
338
- readonly type: "boolean";
339
- readonly description: "Whether the agent may spawn delegate_research/delegate_code loops.";
340
- };
341
- };
342
- };
343
321
  readonly model: {
344
322
  readonly type: "object";
345
323
  readonly additionalProperties: false;
@@ -364,4 +342,4 @@ declare const agentAppConfigJsonSchema: {
364
342
  };
365
343
  };
366
344
 
367
- export { type AgentAppConfig, type AgentDelegationConfig, type AgentIdentityConfig, type AgentIntegrationsConfig, type AgentKnowledgeConfig, type AgentTaxonomyConfig, type AgentUiConfig, type KnowledgeLoopConfig, KnowledgeRequirementSpec, type KnowledgeSourceSpec, TangleModelConfig, agentAppConfigJsonSchema, defineAgentApp };
345
+ export { type AgentAppConfig, type AgentIdentityConfig, type AgentIntegrationsConfig, type AgentKnowledgeConfig, type AgentTaxonomyConfig, type AgentUiConfig, type KnowledgeLoopConfig, KnowledgeRequirementSpec, type KnowledgeSourceSpec, TangleModelConfig, agentAppConfigJsonSchema, defineAgentApp };
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  agentAppConfigJsonSchema,
3
3
  defineAgentApp
4
- } from "../chunk-OC3RAUZ2.js";
4
+ } from "../chunk-OSMNYPOG.js";
5
5
  export {
6
6
  agentAppConfigJsonSchema,
7
7
  defineAgentApp
@@ -85,7 +85,7 @@ import {
85
85
  import {
86
86
  DesignCanvasChromeLazy,
87
87
  DesignCanvasLazy
88
- } from "../chunk-FJUOBNIY.js";
88
+ } from "../chunk-WOVCWPFF.js";
89
89
  import "../chunk-LVD37K5V.js";
90
90
  import {
91
91
  assertSceneMediaSrc,
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  DesignCanvasChromeLazy,
3
3
  DesignCanvasLazy
4
- } from "../chunk-FJUOBNIY.js";
4
+ } from "../chunk-WOVCWPFF.js";
5
5
  export {
6
6
  DesignCanvasChromeLazy,
7
7
  DesignCanvasLazy
package/dist/index.d.ts CHANGED
@@ -3,7 +3,6 @@ export { A as AuthenticateOptions, D as DEFAULT_HEADER_NAMES, T as ToolAuthResul
3
3
  export { A as APP_TOOL_NAMES, a as AddCitationArgs, b as AddCitationResult, c as AppToolContext, d as AppToolDefinition, e as AppToolHandlers, f as AppToolName, g as AppToolOutcome, h as AppToolProducedEvent, i as AppToolTaxonomy, B as BuildAppToolsOptions, O as OpenAIFunctionTool, R as RenderUiArgs, j as RenderUiResult, S as ScheduleFollowupArgs, k as ScheduleFollowupResult, l as SubmitProposalArgs, m as SubmitProposalResult, n as buildAppToolOpenAITools, o as customToolToOpenAI, p as defineAppTool, q as findCustomTool, r as isAppToolName } from './types-BEOvc_ue.js';
4
4
  export { A as AppToolMcpServer, B as BuildHttpMcpServerOptions, a as BuildMcpServerOptions, D as DEFAULT_APP_TOOL_PATHS, S as ScopedMcpServerEntryOptions, b as buildAppToolMcpServer, c as buildHttpMcpServer, d as buildScopedMcpServerEntry } from './mcp-BHfIoGLW.js';
5
5
  export { C as CreateMcpToolHandlerOptions, M as MCP_PROTOCOL_VERSIONS, a as McpProtocolVersion, b as McpServerInfo, c as McpToolDefinition, M as SEQUENCES_MCP_PROTOCOL_VERSIONS, d as createMcpToolHandler } from './mcp-rpc-DLw_r9PQ.js';
6
- export { BuildDelegationOptions, DELEGATION_MCP_SERVER_KEY, DELEGATION_TOOLS, DelegationMcpServer, buildDelegationMcpServer, delegationMcpForConfig } from './delegation/index.js';
7
6
  export { BrokerToken, BrokerTokenMinter, BrokerTokenProvider, BrokerTokenProviderOptions, ConsentUrlInput, buildConsentUrl, createBrokerTokenProvider } from './tangle/index.js';
8
7
  export { C as CatalogModel, M as ModelCatalog, R as RouterModel, _ as __resetCatalogCache, b as buildCatalog, f as fetchModelCatalog, n as normalizeModelId } from './model-catalog-BEAEVDaa.js';
9
8
  export { C as CreateTangleRouterModelConfigOptions, D as DEFAULT_TANGLE_BILLING_ENFORCEMENT_ENV_VAR, a as DEFAULT_TANGLE_ROUTER_BASE_URL, R as ResolveModelOptions, b as ResolveTangleDevOrUserKeyOptions, c as ResolveUserTangleExecutionKeyForUserOptions, d as ResolveUserTangleExecutionKeyOptions, e as ResolvedTangleExecutionKey, T as TangleBillingEnforcementOptions, f as TangleExecutionEnvironment, g as TangleExecutionKeyError, h as TangleExecutionKeyErrorCode, i as TangleExecutionKeyHttpError, j as TangleExecutionKeySource, k as TangleModelConfig, l as createTangleRouterModelConfig, m as isTangleBillingEnforcementDisabled, n as isTangleExecutionKeyError, r as resolveTangleDevOrUserKey, o as resolveTangleExecutionEnvironment, p as resolveTangleModelConfig, q as resolveUserTangleExecutionKey, s as resolveUserTangleExecutionKeyForUser, t as tangleExecutionKeyHttpError, u as trimOrNull } from './model-dF2h4xT9.js';
@@ -12,7 +11,7 @@ export { createTokenRecallChecker, producedFromToolEvents } from './eval/index.j
12
11
  export { KnowledgeRequirementSpec, KnowledgeSignal, KnowledgeStateAccessor, SatisfiedByRule, buildKnowledgeRequirements, deriveSignals } from './knowledge/index.js';
13
12
  export { CreateKnowledgeLoopDeps, KnowledgeCandidate, KnowledgeDecider, KnowledgeDeciderInput, KnowledgeDecision, KnowledgeGateVerdict, KnowledgeLoop, KnowledgeLoopDriver, createKnowledgeLoop, createReviewerDecider, reviewCandidate } from './knowledge-loop/index.js';
14
13
  export { DEFAULT_HARNESS, HARNESS_MODEL_POLICIES, Harness, HarnessModelPolicy, KNOWN_HARNESSES, PROVIDER_PREFERRED_HARNESS, ResolveSessionHarnessInput, ResolvedSessionHarness, assertHarnessModelCompatible, coerceHarness, isHarness, isModelCompatibleWithHarness, modelProvider, resolveSessionHarness, snapHarnessToModel, snapModelToHarness } from './harness/index.js';
15
- export { AgentAppConfig, AgentDelegationConfig, AgentIdentityConfig, AgentIntegrationsConfig, AgentKnowledgeConfig, AgentTaxonomyConfig, AgentUiConfig, KnowledgeLoopConfig, KnowledgeSourceSpec, agentAppConfigJsonSchema, defineAgentApp } from './config/index.js';
14
+ export { AgentAppConfig, AgentIdentityConfig, AgentIntegrationsConfig, AgentKnowledgeConfig, AgentTaxonomyConfig, AgentUiConfig, KnowledgeLoopConfig, KnowledgeSourceSpec, agentAppConfigJsonSchema, defineAgentApp } from './config/index.js';
16
15
  export { D1Like, D1PreparedLike, DrizzleColumnLike, DrizzleSqliteCoreLike, PRESET_MIGRATION_SQL, PRESET_TABLES, PresetBillingOptions, PresetKnowledgeAccessorOptions, PresetToolHandlerOptions, VaultKv, createD1KnowledgeStateAccessor, createPresetDrizzleSchema, createPresetFieldCrypto, createPresetToolHandlers, createPresetWorkspaceKeyManager, createPresetWorkspaceKeyStore } from './preset-cloudflare/index.js';
17
16
  export { KeyCrypto, KeyProvisioner, PlanLimit, PlatformBalanceInfo, PlatformBalanceManager, PlatformBalanceManagerOptions, PlatformBillingClient, PlatformIdentity, PlatformProductUsage, SharedBillingState, TcloudKeyClient, WorkspaceKeyManager, WorkspaceKeyManagerOptions, WorkspaceKeyRecord, WorkspaceKeyStore, WorkspaceModelKeyUsage, createPlatformBalanceManager, createTcloudKeyProvisioner, createWorkspaceKeyManager } from './billing/index.js';
18
17
  export { DeriveKeyOptions, createFieldCrypto, decodeHexKey, decryptAesGcm, decryptBytes, decryptWithKey, deriveKey, encryptAesGcm, encryptBytes, encryptWithKey } from './crypto/index.js';
package/dist/index.js CHANGED
@@ -144,10 +144,6 @@ import {
144
144
  snapshotFrame,
145
145
  trackIntervals
146
146
  } from "./chunk-ZYBWGSAZ.js";
147
- import {
148
- agentAppConfigJsonSchema,
149
- defineAgentApp
150
- } from "./chunk-OC3RAUZ2.js";
151
147
  import {
152
148
  PRESET_MIGRATION_SQL,
153
149
  PRESET_TABLES,
@@ -239,11 +235,6 @@ import {
239
235
  requireString,
240
236
  serializeCookie
241
237
  } from "./chunk-HFC4BTWJ.js";
242
- import {
243
- createKnowledgeLoop,
244
- createReviewerDecider,
245
- reviewCandidate
246
- } from "./chunk-EEPJGZJW.js";
247
238
  import {
248
239
  DEFAULT_SANDBOX_RESOURCES,
249
240
  SandboxRuntimeAuthRefreshError,
@@ -308,6 +299,10 @@ import {
308
299
  snapHarnessToModel,
309
300
  snapModelToHarness
310
301
  } from "./chunk-5VXPDXZJ.js";
302
+ import {
303
+ agentAppConfigJsonSchema,
304
+ defineAgentApp
305
+ } from "./chunk-OSMNYPOG.js";
311
306
  import {
312
307
  createCapabilityToken,
313
308
  createExpiringCapabilityToken,
@@ -328,12 +323,6 @@ import {
328
323
  createMcpToolHandler,
329
324
  readToolArgs
330
325
  } from "./chunk-7EVZUIHW.js";
331
- import {
332
- DELEGATION_MCP_SERVER_KEY,
333
- DELEGATION_TOOLS,
334
- buildDelegationMcpServer,
335
- delegationMcpForConfig
336
- } from "./chunk-AQ2BOPOQ.js";
337
326
  import {
338
327
  buildConsentUrl,
339
328
  createBrokerTokenProvider
@@ -392,6 +381,11 @@ import {
392
381
  buildKnowledgeRequirements,
393
382
  deriveSignals
394
383
  } from "./chunk-ZXNXAQAH.js";
384
+ import {
385
+ createKnowledgeLoop,
386
+ createReviewerDecider,
387
+ reviewCandidate
388
+ } from "./chunk-EEPJGZJW.js";
395
389
  export {
396
390
  APP_TOOL_NAMES,
397
391
  ApprovalEventSchema,
@@ -412,8 +406,6 @@ export {
412
406
  DEFAULT_SEQUENCES_MCP_DESCRIPTION,
413
407
  DEFAULT_TANGLE_BILLING_ENFORCEMENT_ENV_VAR,
414
408
  DEFAULT_TANGLE_ROUTER_BASE_URL,
415
- DELEGATION_MCP_SERVER_KEY,
416
- DELEGATION_TOOLS,
417
409
  EXPORT_PRESETS,
418
410
  EmailContentSchema,
419
411
  HARNESS_MODEL_POLICIES,
@@ -481,7 +473,6 @@ export {
481
473
  buildCatalog,
482
474
  buildConsentUrl,
483
475
  buildContactSheetManifest,
484
- buildDelegationMcpServer,
485
476
  buildDesignCanvasMcpServerEntry,
486
477
  buildEdl,
487
478
  buildFlowTrace,
@@ -561,7 +552,6 @@ export {
561
552
  defineAppTool,
562
553
  defineSurfaceKind,
563
554
  delegationActivityToFlowSpans,
564
- delegationMcpForConfig,
565
555
  deleteSecret,
566
556
  deriveKey,
567
557
  deriveSignals,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tangle-network/agent-app",
3
- "version": "0.41.6",
3
+ "version": "0.42.1",
4
4
  "packageManager": "pnpm@10.33.4",
5
5
  "description": "Application-shell framework for Tangle agent products: a bounded tool loop, the structured agent→app tool side channel, integration-hub client, per-workspace billing, and crypto — composed over the Tangle agent substrate through typed seams.",
6
6
  "keywords": [
@@ -43,11 +43,6 @@
43
43
  "import": "./dist/tools/index.js",
44
44
  "default": "./dist/tools/index.js"
45
45
  },
46
- "./delegation": {
47
- "types": "./dist/delegation/index.d.ts",
48
- "import": "./dist/delegation/index.js",
49
- "default": "./dist/delegation/index.js"
50
- },
51
46
  "./tangle": {
52
47
  "types": "./dist/tangle/index.d.ts",
53
48
  "import": "./dist/tangle/index.js",
@@ -1,39 +0,0 @@
1
- // src/delegation/index.ts
2
- var DELEGATION_MCP_SERVER_KEY = "agent-runtime-delegation";
3
- var DELEGATION_TOOLS = [
4
- "delegate_code",
5
- "delegate_research",
6
- "delegate_feedback",
7
- "delegation_status",
8
- "delegation_history"
9
- ];
10
- function buildDelegationMcpServer(opts) {
11
- if (!opts.apiKey) return void 0;
12
- const env = { TANGLE_API_KEY: opts.apiKey };
13
- const forward = opts.forwardEnv ?? {};
14
- for (const key of ["SANDBOX_BASE_URL", "OTEL_EXPORTER_OTLP_ENDPOINT", "OTEL_EXPORTER_OTLP_HEADERS", "TRACE_ID", "PARENT_SPAN_ID"]) {
15
- const value = forward[key];
16
- if (value) env[key] = value;
17
- }
18
- return {
19
- transport: "stdio",
20
- command: "npx",
21
- args: ["-y", opts.packageSpec ?? "@tangle-network/agent-runtime", "mcp"],
22
- env,
23
- enabled: true,
24
- metadata: { surface: "delegation:dispatch", tools: DELEGATION_TOOLS }
25
- };
26
- }
27
- function delegationMcpForConfig(config, opts) {
28
- if (!config.delegation?.enabled) return {};
29
- const server = buildDelegationMcpServer(opts);
30
- return server ? { [DELEGATION_MCP_SERVER_KEY]: server } : {};
31
- }
32
-
33
- export {
34
- DELEGATION_MCP_SERVER_KEY,
35
- DELEGATION_TOOLS,
36
- buildDelegationMcpServer,
37
- delegationMcpForConfig
38
- };
39
- //# sourceMappingURL=chunk-AQ2BOPOQ.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/delegation/index.ts"],"sourcesContent":["/**\n * Delegated looped work — the agent-runtime \"driven loop\" MCP.\n *\n * For multi-step research or document generation, the agent dispatches a loop\n * that runs to completion in its OWN sandbox (via @tangle-network/agent-runtime's\n * stdio MCP, executed in the agent-driver) and returns the artifact. This is\n * how an app's main agent \"programs / delegates\" without doing long mechanical\n * work inline. It is an OPTIONAL module — an app opts in by spreading the\n * server into its profile's `mcp` map.\n *\n * The shape is the portable `AgentProfileMcpServer` the sandbox SDK accepts\n * (transport: 'stdio' → the orchestrator derives `{ type:'local', command }`).\n * Kept structural here so this package needs no sandbox-SDK dependency.\n */\n\nexport const DELEGATION_MCP_SERVER_KEY = 'agent-runtime-delegation'\n\nexport const DELEGATION_TOOLS = [\n 'delegate_code',\n 'delegate_research',\n 'delegate_feedback',\n 'delegation_status',\n 'delegation_history',\n] as const\n\n/** The stdio MCP server entry — structurally an `AgentProfileMcpServer`. */\nexport interface DelegationMcpServer {\n transport: 'stdio'\n command: string\n args: string[]\n env: Record<string, string>\n enabled: true\n metadata: { surface: string; tools: readonly string[] }\n}\n\nexport interface BuildDelegationOptions {\n /** Platform API key the delegated loop authenticates with (required — the\n * loop runs in its own sandbox and bills against this key). Omit/empty →\n * returns undefined (fail-closed: no key, no delegation). */\n apiKey?: string\n /** Extra env to forward into the delegated loop (sandbox base URL, OTel trace\n * propagation, etc.). Only defined values are forwarded. */\n forwardEnv?: Record<string, string | undefined>\n /** npm spec for the runtime MCP. Defaults to the published agent-runtime. */\n packageSpec?: string\n}\n\n/**\n * Build the delegation MCP server entry, keyed under\n * {@link DELEGATION_MCP_SERVER_KEY}, or `undefined` when no platform API key is\n * available. Spread the result into the profile's `mcp` map:\n *\n * const delegation = buildDelegationMcpServer({ apiKey: env.TANGLE_API_KEY, forwardEnv: env })\n * const mcp = { ...(delegation ? { [DELEGATION_MCP_SERVER_KEY]: delegation } : {}) }\n */\nexport function buildDelegationMcpServer(opts: BuildDelegationOptions): DelegationMcpServer | undefined {\n if (!opts.apiKey) return undefined\n const env: Record<string, string> = { TANGLE_API_KEY: opts.apiKey }\n const forward = opts.forwardEnv ?? {}\n for (const key of ['SANDBOX_BASE_URL', 'OTEL_EXPORTER_OTLP_ENDPOINT', 'OTEL_EXPORTER_OTLP_HEADERS', 'TRACE_ID', 'PARENT_SPAN_ID']) {\n const value = forward[key]\n if (value) env[key] = value\n }\n return {\n transport: 'stdio',\n command: 'npx',\n args: ['-y', opts.packageSpec ?? '@tangle-network/agent-runtime', 'mcp'],\n env,\n enabled: true,\n metadata: { surface: 'delegation:dispatch', tools: DELEGATION_TOOLS },\n }\n}\n\n/**\n * Config-driven wiring: returns the delegation MCP entry keyed under\n * {@link DELEGATION_MCP_SERVER_KEY} when the product's `config.delegation.enabled`\n * is true (and a platform key is available), else an empty object. Spread the\n * result directly into the sandbox profile's `mcp` map — this is the seam\n * `agent.config.delegation` flows through, so a coding agent toggles background\n * agents/loops by flipping one boolean, never by wiring the MCP by hand.\n *\n * const mcp = { ...rest, ...delegationMcpForConfig(config, { apiKey: env.TANGLE_API_KEY, forwardEnv: env }) }\n */\nexport function delegationMcpForConfig(\n config: { delegation?: { enabled?: boolean } },\n opts: BuildDelegationOptions,\n): Record<string, DelegationMcpServer> {\n if (!config.delegation?.enabled) return {}\n const server = buildDelegationMcpServer(opts)\n return server ? { [DELEGATION_MCP_SERVER_KEY]: server } : {}\n}\n"],"mappings":";AAeO,IAAM,4BAA4B;AAElC,IAAM,mBAAmB;AAAA,EAC9B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAgCO,SAAS,yBAAyB,MAA+D;AACtG,MAAI,CAAC,KAAK,OAAQ,QAAO;AACzB,QAAM,MAA8B,EAAE,gBAAgB,KAAK,OAAO;AAClE,QAAM,UAAU,KAAK,cAAc,CAAC;AACpC,aAAW,OAAO,CAAC,oBAAoB,+BAA+B,8BAA8B,YAAY,gBAAgB,GAAG;AACjI,UAAM,QAAQ,QAAQ,GAAG;AACzB,QAAI,MAAO,KAAI,GAAG,IAAI;AAAA,EACxB;AACA,SAAO;AAAA,IACL,WAAW;AAAA,IACX,SAAS;AAAA,IACT,MAAM,CAAC,MAAM,KAAK,eAAe,iCAAiC,KAAK;AAAA,IACvE;AAAA,IACA,SAAS;AAAA,IACT,UAAU,EAAE,SAAS,uBAAuB,OAAO,iBAAiB;AAAA,EACtE;AACF;AAYO,SAAS,uBACd,QACA,MACqC;AACrC,MAAI,CAAC,OAAO,YAAY,QAAS,QAAO,CAAC;AACzC,QAAM,SAAS,yBAAyB,IAAI;AAC5C,SAAO,SAAS,EAAE,CAAC,yBAAyB,GAAG,OAAO,IAAI,CAAC;AAC7D;","names":[]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/config/index.ts"],"sourcesContent":["/**\n * `@tangle-network/agent-app/config` — the typed `AgentAppConfig` contract.\n *\n * This is the single declarative DATA surface a coding agent fills to stand up a\n * new agent product. Everything an agent product otherwise hand-rolls as\n * imperative wiring — who the agent is, which proposal types exist and which are\n * approval-gated, what knowledge the control loop requires, which integrations\n * are connectable, how the model resolves — is expressed here as plain data the\n * rest of agent-app's modules consume through their typed seams:\n *\n * - `identity` → the system-prompt + disclaimer surface the chat pipeline reads.\n * - `taxonomy` → which `submit_proposal` types the `./tools` side channel\n * accepts, and which the approval queue treats as regulated\n * (certified-human-gated).\n * - `knowledge` → the `./knowledge` requirement specs that gate the loop, plus\n * the acquisition-loop goal/threshold the researcher pursues.\n * - `integrations` → which `@tangle-network/agent-integrations` catalog kinds the\n * product enables.\n * - `ui` → whether the agent may emit generated UI (`render_ui`).\n * - `model` → the `./runtime` `TangleModelConfig` (or null to resolve from env).\n *\n * Layering: this module is the CONTRACT only — pure types + an identity helper.\n * It introduces no behavior and no engine dependency; it REUSES the existing\n * `KnowledgeRequirementSpec`/`SatisfiedByRule` (from `../knowledge`) and\n * `TangleModelConfig` (from `../runtime`) rather than redefining them, so the\n * config a product authors is the exact shape those modules already consume.\n * Steps that build the composer/loader read this file as the schema floor.\n */\n\nimport type {\n KnowledgeRequirementSpec,\n SatisfiedByRule,\n} from '../knowledge/index'\nimport type { TangleModelConfig } from '../runtime/index'\n\n// Re-export the borrowed types so a config author has a single import surface\n// (`@tangle-network/agent-app/config`) and never has to reach into `../knowledge`\n// or `../runtime` to spell out a field's type. These are the SAME types the\n// knowledge gate and runtime model resolver consume — not parallel copies.\nexport type { KnowledgeRequirementSpec, SatisfiedByRule, TangleModelConfig }\n\n/**\n * Who the agent is, as data. Composed into the chat pipeline's system prompt;\n * never baked into agent-app (a domain value, per the layering contract).\n */\nexport interface AgentIdentityConfig {\n /** Product/agent name, e.g. `\"Acme Support Copilot\"`. Shown to the user and\n * available to the system-prompt builder. */\n name: string\n /** One-paragraph persona statement — the agent's role, voice, and remit. The\n * spine of the system prompt. */\n persona: string\n /** Additional system-prompt fragments appended verbatim after the persona\n * (standing workflows, hard rules, tone). Order is preserved. Optional. */\n systemPromptFragments?: string[]\n /** Named disclaimers the product surfaces (e.g. a regulatory human-in-the-loop\n * notice). Keyed by a stable id (`compliance`, `not-advice`, …) so the chat\n * pipeline / UI can select one by name. Values are the literal text. Optional. */\n disclaimers?: Record<string, string>\n}\n\n/**\n * The proposal taxonomy, as data. `proposalTypes` is the closed set of\n * `submit_proposal` types the `./tools` side channel accepts; `regulatedTypes`\n * is the subset that is approval-gated — the executor refuses to run one without\n * a certified human approver. `regulatedTypes` MUST be a subset of\n * `proposalTypes` (validated by the loader step; not enforced at the type level).\n */\nexport interface AgentTaxonomyConfig {\n /** Every proposal type this product can emit, e.g.\n * `['recommend', 'contact', 'escalate']`. The closed allow-list\n * the tool layer validates a `submit_proposal` call against. */\n proposalTypes: string[]\n /** The subset of `proposalTypes` that is regulated → cannot execute without a\n * certified-human approver. The approval executor reads this to decide which\n * proposals are fail-loud certified-gated. */\n regulatedTypes: string[]\n}\n\n/** A knowledge source the acquisition loop / researcher may draw on. */\nexport interface KnowledgeSourceSpec {\n /** Where the source lives — a URL, a `vault://` path, an integration ref, etc.\n * Opaque to agent-app; the consumer's loader resolves it. */\n uri: string\n /** Optional source classifier the researcher uses to pick a fetch strategy,\n * e.g. `'web'`, `'vault'`, `'regulation'`, `'integration'`. Free-form. */\n kind?: string\n}\n\n/**\n * The knowledge-acquisition loop config — the goal the researcher pursues and\n * the gate it must clear before the loop is considered satisfied. All optional;\n * a product with only static requirement specs omits it.\n */\nexport interface KnowledgeLoopConfig {\n /** The acquisition goal in natural language, e.g.\n * `\"ground every quoted premium against a real policy record\"`. */\n goal?: string\n /** The minimum aggregate confidence [0, 1] the loop must reach to pass its\n * gate. The runtime control loop blocks below this. Default decided by the\n * consumer's loop wiring when omitted. */\n minConfidence?: number\n /** How fresh acquired knowledge must be, e.g. `'static'`, `'7d'`, `'session'`.\n * Free-form; the consumer's loop interprets it. */\n freshness?: string\n}\n\n/**\n * The knowledge surface, as data. `sources` are what the researcher may read;\n * `requirements` are the declarative `./knowledge` specs that gate the control\n * loop (reused verbatim — the same `KnowledgeRequirementSpec` the gate scores);\n * `loop` configures the acquisition pass.\n */\nexport interface AgentKnowledgeConfig {\n /** Sources the acquisition loop / researcher may draw on. */\n sources: KnowledgeSourceSpec[]\n /** The declarative requirement specs that gate the loop. Reuses\n * `KnowledgeRequirementSpec` from `../knowledge` — `buildKnowledgeRequirements`\n * + `deriveSignals` consume these directly. */\n requirements: KnowledgeRequirementSpec[]\n /** Optional acquisition-loop config (goal + confidence gate + freshness). */\n loop?: KnowledgeLoopConfig\n}\n\n/**\n * Which integrations the product enables, as data. `enabled` lists\n * `@tangle-network/agent-integrations` catalog kinds the product connects\n * (e.g. `['salesforce', 'gmail', 'whatsapp']`); the integration hub resolves\n * each to a connector. Strings, not connector objects — agent-app bakes no\n * catalog value.\n */\nexport interface AgentIntegrationsConfig {\n /** Catalog kinds this product enables. */\n enabled: string[]\n}\n\n/** UI capability flags, as data. */\nexport interface AgentUiConfig {\n /** Whether the agent may emit generated UI (the `render_ui` / OpenUI side\n * channel). When false/omitted, the tool layer can omit/refuse the tool.\n * Default behavior decided by the consumer; omit to leave unset. */\n generatedUi?: boolean\n}\n\n/** Background-agent / delegated-loop capability, as data. */\nexport interface AgentDelegationConfig {\n /** When true, the app's own agent may spawn `delegate_research` /\n * `delegate_code` loops that run to completion in their OWN sandbox and\n * return the artifact (the `../delegation` driven-loop MCP). Sandbox-path\n * ONLY — the browser/edge path ignores it. Wired via the existing\n * `buildDelegationMcpServer`; never reimplemented. */\n enabled?: boolean\n}\n\n/**\n * The declarative domain surface of a Tangle agent product.\n *\n * A coding agent fills THIS object and nothing else to define a product's\n * identity, proposal taxonomy, knowledge gate, integrations, UI capability, and\n * model. Every field is DATA consumed by an agent-app module through its typed\n * seam — no field is behavior. Author it through {@link defineAgentApp} for\n * autocomplete and a single import.\n */\nexport interface AgentAppConfig {\n /** Who the agent is — name, persona, system-prompt fragments, disclaimers. */\n identity: AgentIdentityConfig\n /** Proposal types + which are regulated/approval-gated. */\n taxonomy: AgentTaxonomyConfig\n /** Knowledge sources, requirement specs (the loop gate), and loop config. */\n knowledge: AgentKnowledgeConfig\n /** Enabled integration catalog kinds. */\n integrations: AgentIntegrationsConfig\n /** UI capability flags. Optional. */\n ui?: AgentUiConfig\n /** Background-agent / delegated-loop capability (sandbox path). Optional. */\n delegation?: AgentDelegationConfig\n /** The resolved model config (`../runtime`'s `TangleModelConfig`). Omit to\n * resolve from env at boot via `resolveTangleModelConfig`. */\n model?: TangleModelConfig\n}\n\n/**\n * Identity helper: returns its argument unchanged, but anchors inference so a\n * coding agent authoring a config gets full autocomplete + type-checking from a\n * single import. The canonical way to declare a product config:\n *\n * ```ts\n * import { defineAgentApp } from '@tangle-network/agent-app/config'\n *\n * export const config = defineAgentApp({\n * identity: { name: 'Acme Ops', persona: '…' },\n * taxonomy: { proposalTypes: ['recommend', 'contact'], regulatedTypes: ['recommend'] },\n * knowledge: { sources: [], requirements: [] },\n * integrations: { enabled: ['salesforce'] },\n * })\n * ```\n */\nexport function defineAgentApp<const T extends AgentAppConfig>(config: T): T {\n return config\n}\n\n/**\n * Machine-readable JSON Schema (draft 2020-12) for {@link AgentAppConfig}.\n *\n * The schema FLOOR a non-TypeScript coding agent (or a config validator/UI) reads\n * to know the shape without parsing the `.d.ts`. Kept in lockstep with the\n * interfaces above by the config test, which asserts the documented fields are\n * present. `KnowledgeRequirementSpec`'s full sub-shape is intentionally left\n * `additionalProperties: true` here — its authoritative definition lives in\n * `../knowledge`; this floor pins only the fields the config contract owns.\n */\nexport const agentAppConfigJsonSchema = {\n $schema: 'https://json-schema.org/draft/2020-12/schema',\n $id: 'https://tangle.tools/schemas/agent-app-config.json',\n title: 'AgentAppConfig',\n description: 'The declarative domain surface of a Tangle agent product.',\n type: 'object',\n additionalProperties: false,\n required: ['identity', 'taxonomy', 'knowledge', 'integrations'],\n properties: {\n identity: {\n type: 'object',\n additionalProperties: false,\n required: ['name', 'persona'],\n properties: {\n name: { type: 'string', description: 'Product/agent name.' },\n persona: { type: 'string', description: 'One-paragraph persona — the system-prompt spine.' },\n systemPromptFragments: {\n type: 'array',\n items: { type: 'string' },\n description: 'Verbatim system-prompt fragments appended after the persona, in order.',\n },\n disclaimers: {\n type: 'object',\n additionalProperties: { type: 'string' },\n description: 'Named disclaimers keyed by stable id; values are literal text.',\n },\n },\n },\n taxonomy: {\n type: 'object',\n additionalProperties: false,\n required: ['proposalTypes', 'regulatedTypes'],\n properties: {\n proposalTypes: {\n type: 'array',\n items: { type: 'string' },\n description: 'Closed allow-list of proposal types the product can emit.',\n },\n regulatedTypes: {\n type: 'array',\n items: { type: 'string' },\n description: 'Subset of proposalTypes that is approval-gated (certified-human required).',\n },\n },\n },\n knowledge: {\n type: 'object',\n additionalProperties: false,\n required: ['sources', 'requirements'],\n properties: {\n sources: {\n type: 'array',\n description: 'Sources the acquisition loop may draw on.',\n items: {\n type: 'object',\n additionalProperties: false,\n required: ['uri'],\n properties: {\n uri: { type: 'string', description: 'Where the source lives (opaque to agent-app).' },\n kind: { type: 'string', description: 'Optional source classifier (web/vault/regulation/…).' },\n },\n },\n },\n requirements: {\n type: 'array',\n description: \"Declarative KnowledgeRequirementSpec[] (../knowledge) that gate the loop.\",\n items: { type: 'object', additionalProperties: true },\n },\n loop: {\n type: 'object',\n additionalProperties: false,\n description: 'Acquisition-loop config.',\n properties: {\n goal: { type: 'string', description: 'Acquisition goal in natural language.' },\n minConfidence: {\n type: 'number',\n minimum: 0,\n maximum: 1,\n description: 'Minimum aggregate confidence the loop must reach.',\n },\n freshness: { type: 'string', description: 'How fresh acquired knowledge must be.' },\n },\n },\n },\n },\n integrations: {\n type: 'object',\n additionalProperties: false,\n required: ['enabled'],\n properties: {\n enabled: {\n type: 'array',\n items: { type: 'string' },\n description: 'Enabled agent-integrations catalog kinds.',\n },\n },\n },\n ui: {\n type: 'object',\n additionalProperties: false,\n description: 'UI capability flags.',\n properties: {\n generatedUi: { type: 'boolean', description: 'Whether the agent may emit generated UI.' },\n },\n },\n delegation: {\n type: 'object',\n additionalProperties: false,\n description: 'Background-agent / delegated-loop capability (sandbox path).',\n properties: {\n enabled: { type: 'boolean', description: 'Whether the agent may spawn delegate_research/delegate_code loops.' },\n },\n },\n model: {\n type: 'object',\n additionalProperties: false,\n description: \"Resolved TangleModelConfig (../runtime). Omit to resolve from env.\",\n required: ['provider', 'model', 'apiKey', 'baseUrl'],\n properties: {\n provider: { type: 'string', enum: ['openai-compat', 'anthropic'] },\n model: { type: 'string' },\n apiKey: { type: 'string' },\n baseUrl: { type: 'string' },\n },\n },\n },\n} as const\n"],"mappings":"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","names":[]}
@@ -1,65 +0,0 @@
1
- /**
2
- * Delegated looped work — the agent-runtime "driven loop" MCP.
3
- *
4
- * For multi-step research or document generation, the agent dispatches a loop
5
- * that runs to completion in its OWN sandbox (via @tangle-network/agent-runtime's
6
- * stdio MCP, executed in the agent-driver) and returns the artifact. This is
7
- * how an app's main agent "programs / delegates" without doing long mechanical
8
- * work inline. It is an OPTIONAL module — an app opts in by spreading the
9
- * server into its profile's `mcp` map.
10
- *
11
- * The shape is the portable `AgentProfileMcpServer` the sandbox SDK accepts
12
- * (transport: 'stdio' → the orchestrator derives `{ type:'local', command }`).
13
- * Kept structural here so this package needs no sandbox-SDK dependency.
14
- */
15
- declare const DELEGATION_MCP_SERVER_KEY = "agent-runtime-delegation";
16
- declare const DELEGATION_TOOLS: readonly ["delegate_code", "delegate_research", "delegate_feedback", "delegation_status", "delegation_history"];
17
- /** The stdio MCP server entry — structurally an `AgentProfileMcpServer`. */
18
- interface DelegationMcpServer {
19
- transport: 'stdio';
20
- command: string;
21
- args: string[];
22
- env: Record<string, string>;
23
- enabled: true;
24
- metadata: {
25
- surface: string;
26
- tools: readonly string[];
27
- };
28
- }
29
- interface BuildDelegationOptions {
30
- /** Platform API key the delegated loop authenticates with (required — the
31
- * loop runs in its own sandbox and bills against this key). Omit/empty →
32
- * returns undefined (fail-closed: no key, no delegation). */
33
- apiKey?: string;
34
- /** Extra env to forward into the delegated loop (sandbox base URL, OTel trace
35
- * propagation, etc.). Only defined values are forwarded. */
36
- forwardEnv?: Record<string, string | undefined>;
37
- /** npm spec for the runtime MCP. Defaults to the published agent-runtime. */
38
- packageSpec?: string;
39
- }
40
- /**
41
- * Build the delegation MCP server entry, keyed under
42
- * {@link DELEGATION_MCP_SERVER_KEY}, or `undefined` when no platform API key is
43
- * available. Spread the result into the profile's `mcp` map:
44
- *
45
- * const delegation = buildDelegationMcpServer({ apiKey: env.TANGLE_API_KEY, forwardEnv: env })
46
- * const mcp = { ...(delegation ? { [DELEGATION_MCP_SERVER_KEY]: delegation } : {}) }
47
- */
48
- declare function buildDelegationMcpServer(opts: BuildDelegationOptions): DelegationMcpServer | undefined;
49
- /**
50
- * Config-driven wiring: returns the delegation MCP entry keyed under
51
- * {@link DELEGATION_MCP_SERVER_KEY} when the product's `config.delegation.enabled`
52
- * is true (and a platform key is available), else an empty object. Spread the
53
- * result directly into the sandbox profile's `mcp` map — this is the seam
54
- * `agent.config.delegation` flows through, so a coding agent toggles background
55
- * agents/loops by flipping one boolean, never by wiring the MCP by hand.
56
- *
57
- * const mcp = { ...rest, ...delegationMcpForConfig(config, { apiKey: env.TANGLE_API_KEY, forwardEnv: env }) }
58
- */
59
- declare function delegationMcpForConfig(config: {
60
- delegation?: {
61
- enabled?: boolean;
62
- };
63
- }, opts: BuildDelegationOptions): Record<string, DelegationMcpServer>;
64
-
65
- export { type BuildDelegationOptions, DELEGATION_MCP_SERVER_KEY, DELEGATION_TOOLS, type DelegationMcpServer, buildDelegationMcpServer, delegationMcpForConfig };
@@ -1,13 +0,0 @@
1
- import {
2
- DELEGATION_MCP_SERVER_KEY,
3
- DELEGATION_TOOLS,
4
- buildDelegationMcpServer,
5
- delegationMcpForConfig
6
- } from "../chunk-AQ2BOPOQ.js";
7
- export {
8
- DELEGATION_MCP_SERVER_KEY,
9
- DELEGATION_TOOLS,
10
- buildDelegationMcpServer,
11
- delegationMcpForConfig
12
- };
13
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}