@tangle-network/agent-runtime 0.89.0 → 0.90.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 +51 -18
- package/dist/agent.d.ts +53 -2
- package/dist/agent.js +168 -6
- package/dist/agent.js.map +1 -1
- package/dist/analyst-loop.d.ts +1 -1
- package/dist/chunk-5QOB7H74.js +387 -0
- package/dist/chunk-5QOB7H74.js.map +1 -0
- package/dist/{chunk-4WXGK6GV.js → chunk-7ON74BQO.js} +2 -2
- package/dist/{chunk-7LO5GMAO.js → chunk-CMYMTRGA.js} +14 -5
- package/dist/chunk-CMYMTRGA.js.map +1 -0
- package/dist/{chunk-UD4BHQMI.js → chunk-IVGYLCFH.js} +2 -2
- package/dist/{chunk-UD4BHQMI.js.map → chunk-IVGYLCFH.js.map} +1 -1
- package/dist/{chunk-VNOOH22O.js → chunk-OOL3675H.js} +85 -4
- package/dist/chunk-OOL3675H.js.map +1 -0
- package/dist/{chunk-5AVV7KAH.js → chunk-QK4DV5PR.js} +2 -2
- package/dist/chunk-R2VAJGR3.js +214 -0
- package/dist/chunk-R2VAJGR3.js.map +1 -0
- package/dist/{chunk-N7EJV7N3.js → chunk-RYBVU4M3.js} +3592 -3562
- package/dist/chunk-RYBVU4M3.js.map +1 -0
- package/dist/{chunk-BQPFZE2C.js → chunk-WRUSWK4F.js} +5 -5
- package/dist/{chunk-PIPPLSOF.js → chunk-ZV4LXYCJ.js} +451 -24
- package/dist/chunk-ZV4LXYCJ.js.map +1 -0
- package/dist/{worktree-harness-CX_McRLp.d.ts → completion-gate-DkAnUmpb.d.ts} +45 -45
- package/dist/{coordination-CuDLO8wj.d.ts → coordination-rRj5hjJK.d.ts} +415 -227
- package/dist/environment-provider.d.ts +3 -3
- package/dist/index.d.ts +255 -16
- package/dist/index.js +463 -72
- package/dist/index.js.map +1 -1
- package/dist/intelligence.d.ts +228 -84
- package/dist/intelligence.js +259 -166
- package/dist/intelligence.js.map +1 -1
- package/dist/knowledge.d.ts +120 -0
- package/dist/knowledge.js +28 -0
- package/dist/knowledge.js.map +1 -0
- package/dist/lifecycle.d.ts +2 -2
- package/dist/lifecycle.js +2 -2
- package/dist/{local-harness-sI0S_XNA.d.ts → local-harness-dcD5WTTr.d.ts} +3 -0
- package/dist/{loop-runner-bin-hQDUL8Ld.d.ts → loop-runner-bin-DTbZVGfM.d.ts} +2 -2
- package/dist/loop-runner-bin.d.ts +6 -6
- package/dist/loop-runner-bin.js +7 -7
- package/dist/loops.d.ts +34 -369
- package/dist/loops.js +31 -5
- package/dist/mcp/bin.js +5 -5
- package/dist/mcp/index.d.ts +10 -11
- package/dist/mcp/index.js +10 -10
- package/dist/{mcp-serve-verifier-FL7-ZEb_.d.ts → mcp-serve-verifier-XsX8rkB9.d.ts} +12 -1
- package/dist/{openai-tools-BnrOmGjN.d.ts → openai-tools-C4ZfUD4L.d.ts} +1 -1
- package/dist/profiles.d.ts +196 -5
- package/dist/profiles.js +8 -0
- package/dist/profiles.js.map +1 -1
- package/dist/{router-client-r8y_VFVM.d.ts → router-client-DJImUDlm.d.ts} +1 -1
- package/dist/structural-rollout-MwlpgQ-6.d.ts +446 -0
- package/dist/supervise-DPmYPk0j.d.ts +131 -0
- package/dist/{types-ESeMOj94.d.ts → types-SyuwunY_.d.ts} +1 -1
- package/dist/{types-Driepl87.d.ts → types-eMNgWgFi.d.ts} +2 -2
- package/dist/{worktree-fanout-D6xR2CIA.d.ts → worktree-fanout-BDFQIO-Y.d.ts} +234 -234
- package/package.json +12 -4
- package/skills/agent-runtime-adoption/SKILL.md +74 -24
- package/skills/build-with-agent-runtime/SKILL.md +23 -20
- package/skills/loop-writer/SKILL.md +6 -5
- package/skills/supervise/SKILL.md +2 -2
- package/dist/chunk-7LO5GMAO.js.map +0 -1
- package/dist/chunk-N7EJV7N3.js.map +0 -1
- package/dist/chunk-PIPPLSOF.js.map +0 -1
- package/dist/chunk-VNOOH22O.js.map +0 -1
- package/dist/otel-export-BKmNwiCb.d.ts +0 -180
- /package/dist/{chunk-4WXGK6GV.js.map → chunk-7ON74BQO.js.map} +0 -0
- /package/dist/{chunk-5AVV7KAH.js.map → chunk-QK4DV5PR.js.map} +0 -0
- /package/dist/{chunk-BQPFZE2C.js.map → chunk-WRUSWK4F.js.map} +0 -0
package/dist/intelligence.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { AgentProfileMcpServer } from '@tangle-network/agent-interface';
|
|
3
|
-
import {
|
|
1
|
+
import { d as LoopTraceEvent } from './types-SyuwunY_.js';
|
|
2
|
+
import { AgentProfileDiff, AgentProfile, AgentProfileMcpServer } from '@tangle-network/agent-interface';
|
|
3
|
+
import { b as ToolSpec } from './router-client-DJImUDlm.js';
|
|
4
4
|
import '@tangle-network/agent-eval';
|
|
5
5
|
import '@tangle-network/sandbox';
|
|
6
6
|
|
|
@@ -152,28 +152,29 @@ declare function resolveRedactor(redact: Redactor | false | undefined): Redactor
|
|
|
152
152
|
|
|
153
153
|
/**
|
|
154
154
|
*
|
|
155
|
-
* Tangle Intelligence — the
|
|
155
|
+
* Tangle Intelligence — the RECEIVE half of the loop (pull-by-default).
|
|
156
156
|
*
|
|
157
|
-
* The sibling Observe
|
|
157
|
+
* The sibling Observe path (`./index`) sends run records UP to the plane. This
|
|
158
158
|
* module pulls certified artifacts DOWN: it reads the tenant's promoted,
|
|
159
|
-
* gate-certified profile from the deployed Intelligence plane
|
|
160
|
-
* the running agent
|
|
161
|
-
*
|
|
162
|
-
* the
|
|
159
|
+
* gate-certified profile from the deployed Intelligence plane so an approved
|
|
160
|
+
* improvement actually reaches the running agent. The pull carries three things
|
|
161
|
+
* the plane already composes:
|
|
162
|
+
* - the certified PROMPT surface + prompt-folding artifacts (delivered into the
|
|
163
|
+
* system prompt via {@link composeCertifiedPrompt} — the promoted prompt);
|
|
164
|
+
* - the typed profile DIFFS the plane has promoted, each with its held-out
|
|
165
|
+
* provenance (surfaced as PROPOSALS — never auto-applied at runtime);
|
|
166
|
+
* - the composed `agentProfile` those diffs fold to, for inspection.
|
|
163
167
|
*
|
|
164
168
|
* Pull contract (deployed plane): GET /v1/profiles/:target/composed →
|
|
165
|
-
* { target, generatedAt,
|
|
166
|
-
*
|
|
169
|
+
* { target, generatedAt,
|
|
170
|
+
* promptSurface: {surface,surfaceHash,version,lift}|null,
|
|
171
|
+
* artifacts: { <artifactType>: [{path,content,contentHash,version,lift,promotedAt}] },
|
|
172
|
+
* capabilities: [{id,iface:{surface},binding:{path,content},provenance}],
|
|
173
|
+
* agentProfileDiffs: [{diff, provenance:{version,lift,contentHash,promotedAt}}],
|
|
174
|
+
* agentProfile: AgentProfile|null }
|
|
167
175
|
* Auth: Bearer <apiKey> (the one TANGLE_API_KEY shared by router + sandbox +
|
|
168
176
|
* intelligence), resolved to a tenant by platform-api's key-verify S2S contract.
|
|
169
177
|
*
|
|
170
|
-
* import { withCertifiedDelivery } from '@tangle-network/agent-runtime/intelligence'
|
|
171
|
-
*
|
|
172
|
-
* export const agent = withCertifiedDelivery(
|
|
173
|
-
* async (input, applied) => myAgent(input, { systemPrompt: applied.composePrompt(BASE) }),
|
|
174
|
-
* { project: 'support-agent', target: 'support-agent' },
|
|
175
|
-
* )
|
|
176
|
-
*
|
|
177
178
|
* @experimental
|
|
178
179
|
*/
|
|
179
180
|
|
|
@@ -195,6 +196,39 @@ interface CertifiedPromptSurface {
|
|
|
195
196
|
version: number | null;
|
|
196
197
|
lift: string | null;
|
|
197
198
|
}
|
|
199
|
+
/** The held-out provenance the plane's certify step stamps on a promoted diff.
|
|
200
|
+
* `lift` is the held-out gate lift (e.g. "+3.1pp"), never a within-run claim. */
|
|
201
|
+
interface DiffProvenance {
|
|
202
|
+
version: number | null;
|
|
203
|
+
lift: string | null;
|
|
204
|
+
contentHash: string;
|
|
205
|
+
promotedAt: string;
|
|
206
|
+
}
|
|
207
|
+
/**
|
|
208
|
+
* A gate-certified profile diff the plane has already promoted, plus the
|
|
209
|
+
* held-out provenance it carries. This is the previously-DROPPED typed diff the
|
|
210
|
+
* composed endpoint returns; `withIntelligence` deserializes it and surfaces it
|
|
211
|
+
* as a PROPOSAL — a human, or the gated local `improve()` loop, turns a proposal
|
|
212
|
+
* into a shipped profile. It is NEVER auto-applied at runtime.
|
|
213
|
+
*/
|
|
214
|
+
interface ProposedProfileDiff {
|
|
215
|
+
diff: AgentProfileDiff;
|
|
216
|
+
provenance: DiffProvenance;
|
|
217
|
+
}
|
|
218
|
+
/** The composed endpoint's per-capability summary — the narrow shape on the
|
|
219
|
+
* wire (id + surface + path/content + provenance). Distinct from the richer
|
|
220
|
+
* `CertifiedCapability` the capability resolver lowers a manifest into. */
|
|
221
|
+
interface CertifiedCapabilitySummary {
|
|
222
|
+
id: string;
|
|
223
|
+
iface: {
|
|
224
|
+
surface: string;
|
|
225
|
+
};
|
|
226
|
+
binding: {
|
|
227
|
+
path: string | null;
|
|
228
|
+
content: string;
|
|
229
|
+
};
|
|
230
|
+
provenance: DiffProvenance;
|
|
231
|
+
}
|
|
198
232
|
/** The composed certified profile — exactly the shape the plane's
|
|
199
233
|
* `GET /v1/profiles/:target/composed` returns. */
|
|
200
234
|
interface CertifiedProfile {
|
|
@@ -202,6 +236,14 @@ interface CertifiedProfile {
|
|
|
202
236
|
generatedAt: string;
|
|
203
237
|
promptSurface: CertifiedPromptSurface | null;
|
|
204
238
|
artifacts: Record<string, CertifiedArtifact[]>;
|
|
239
|
+
/** The typed profile diffs the plane has promoted, each with held-out
|
|
240
|
+
* provenance. Surfaced as proposals; never auto-applied. Empty when none. */
|
|
241
|
+
agentProfileDiffs: ProposedProfileDiff[];
|
|
242
|
+
/** The composed capability summaries the plane returns. Empty when none. */
|
|
243
|
+
capabilities: CertifiedCapabilitySummary[];
|
|
244
|
+
/** The composed profile the promoted diffs fold to, for inspection. `null`
|
|
245
|
+
* when no diffs are promoted. */
|
|
246
|
+
agentProfile: AgentProfile | null;
|
|
205
247
|
}
|
|
206
248
|
/** Typed outcome for the pull — inspect `succeeded` before `value`. A 404
|
|
207
249
|
* (nothing promoted yet) is a normal, non-error `succeeded: false`. */
|
|
@@ -228,6 +270,16 @@ interface PullCertifiedOptions {
|
|
|
228
270
|
* false` (the agent runs on its base surface). */
|
|
229
271
|
timeoutMs?: number;
|
|
230
272
|
}
|
|
273
|
+
/** Resolve the ONE Intelligence base URL — the single knob both the send and
|
|
274
|
+
* receive paths derive from. Env fallback: `TANGLE_INTELLIGENCE_URL`. */
|
|
275
|
+
declare function resolveIntelligenceBaseUrl(baseUrl: string | undefined): string;
|
|
276
|
+
/**
|
|
277
|
+
* Deserialize the composed-endpoint response into a `CertifiedProfile`. The
|
|
278
|
+
* previously-dropped `agentProfileDiffs`/`capabilities`/`agentProfile` are read
|
|
279
|
+
* here so they round-trip to the consumer; a plane that has not yet promoted any
|
|
280
|
+
* diffs simply yields empty arrays / a null profile (fail-closed, never a crash).
|
|
281
|
+
*/
|
|
282
|
+
declare function normalizeCertifiedProfile(raw: unknown): CertifiedProfile;
|
|
231
283
|
/**
|
|
232
284
|
* Pull the certified composed profile for a target. Fail-closed: a network
|
|
233
285
|
* error or a non-2xx returns a typed `succeeded: false` (never throws), so a
|
|
@@ -242,13 +294,13 @@ declare function pullCertified(opts: PullCertifiedOptions): Promise<PullOutcome>
|
|
|
242
294
|
* additions. Order is stable (prompt surface first, then artifact buckets in
|
|
243
295
|
* `promptFoldTypes` order, then by path within a bucket) so the same profile
|
|
244
296
|
* renders byte-identically each call. Returns `base` unchanged when there is no
|
|
245
|
-
* usable certified content.
|
|
297
|
+
* usable certified content. Reads only the prompt-folding slice of a profile.
|
|
246
298
|
*/
|
|
247
|
-
declare function composeCertifiedPrompt(base: string, certified: CertifiedProfile | null): string;
|
|
299
|
+
declare function composeCertifiedPrompt(base: string, certified: Pick<CertifiedProfile, 'promptSurface' | 'artifacts'> | null): string;
|
|
248
300
|
/** A cached, self-refreshing source of a target's certified prompt additions —
|
|
249
301
|
* the prompt-only delivery lane for callers that assemble their OWN system
|
|
250
302
|
* prompt (product chat routes) rather than wrapping an agent fn. Same
|
|
251
|
-
* fail-closed semantics as {@link
|
|
303
|
+
* fail-closed semantics as {@link pullCertified}: pulls at most every
|
|
252
304
|
* `refreshMs`, coalesces concurrent pulls, keeps the last-known profile on a
|
|
253
305
|
* failed/404 pull, never throws, never blocks past the pull timeout. */
|
|
254
306
|
interface CertifiedPromptSource {
|
|
@@ -269,46 +321,10 @@ interface CertifiedPromptSourceOptions extends PullCertifiedOptions {
|
|
|
269
321
|
/**
|
|
270
322
|
* Create the cached certified-prompt source — the ONE module-scope-cache +
|
|
271
323
|
* coalesced-refresh + keep-last-known implementation. Product wiring uses this
|
|
272
|
-
* rather than hand-rolling the same lines around `pullCertified
|
|
273
|
-
*
|
|
324
|
+
* rather than hand-rolling the same lines around `pullCertified`. The
|
|
325
|
+
* `withIntelligence` hook rides this same source for its prompt delivery.
|
|
274
326
|
*/
|
|
275
327
|
declare function createCertifiedPromptSource(opts: CertifiedPromptSourceOptions): CertifiedPromptSource;
|
|
276
|
-
/** What the delivery wrapper hands the agent each run. */
|
|
277
|
-
interface AppliedIntelligence {
|
|
278
|
-
/** The certified profile in effect (null when none promoted / pull failed —
|
|
279
|
-
* fail-closed: the agent runs on its base surface). */
|
|
280
|
-
certified: CertifiedProfile | null;
|
|
281
|
-
/** Fold the certified prompt surface into a base system prompt. */
|
|
282
|
-
composePrompt(base: string): string;
|
|
283
|
-
}
|
|
284
|
-
/** An agent wrapped by {@link withCertifiedDelivery}: receives the input plus
|
|
285
|
-
* the certified intelligence delivered for this run. */
|
|
286
|
-
type DeliveredAgent<I, O> = (input: I, applied: AppliedIntelligence) => Promise<O>;
|
|
287
|
-
/** Delivery config = the Observe config plus the pull target + refresh cadence. */
|
|
288
|
-
interface DeliveryConfig extends IntelligenceConfig {
|
|
289
|
-
/** Pull target. Defaults to `project`. */
|
|
290
|
-
target?: string;
|
|
291
|
-
/** Plane base URL for the pull (NOT the OTLP `endpoint`). Defaults to
|
|
292
|
-
* `TANGLE_INTELLIGENCE_URL` then `https://intelligence.tangle.tools`. */
|
|
293
|
-
baseUrl?: string;
|
|
294
|
-
/** Min interval between certified-profile pulls. Default 5m. */
|
|
295
|
-
refreshMs?: number;
|
|
296
|
-
/** Per-pull timeout in ms (fail-closed on a hung plane). Default 10000. */
|
|
297
|
-
timeoutMs?: number;
|
|
298
|
-
/** fetch impl for the pull (tests). Defaults to global fetch. */
|
|
299
|
-
fetchImpl?: typeof fetch;
|
|
300
|
-
}
|
|
301
|
-
/**
|
|
302
|
-
* Wrap an agent so it (a) Observes each run via the shipped Observe client and
|
|
303
|
-
* (b) RECEIVES the tenant's certified artifacts pulled from the deployed plane.
|
|
304
|
-
* The certified profile is cached and refreshed at most every `refreshMs`; a
|
|
305
|
-
* failed pull is fail-closed — the agent runs on its base surface and never
|
|
306
|
-
* breaks because Intelligence is unreachable. When the plane promotes a new
|
|
307
|
-
* gate-certified surface, the next refresh delivers it to the running agent.
|
|
308
|
-
*/
|
|
309
|
-
declare function withCertifiedDelivery<I, O>(agent: DeliveredAgent<I, O>, config: DeliveryConfig): ((input: I) => Promise<O>) & {
|
|
310
|
-
refresh(): Promise<void>;
|
|
311
|
-
};
|
|
312
328
|
|
|
313
329
|
/**
|
|
314
330
|
*
|
|
@@ -711,6 +727,98 @@ declare function composeCertifiedProfileFromWire(base: {
|
|
|
711
727
|
systemPrompt: string;
|
|
712
728
|
}, profile: CertifiedProfile | null, ctx?: ResolveCtx): Promise<ResolvedSurface>;
|
|
713
729
|
|
|
730
|
+
/**
|
|
731
|
+
*
|
|
732
|
+
* `withIntelligence` — the ONE agent-runtime hook that unifies Tangle
|
|
733
|
+
* Intelligence send + receive.
|
|
734
|
+
*
|
|
735
|
+
* It does two things per call, both fail-open:
|
|
736
|
+
* 1. RECEIVE — pull the tenant's certified profile from the deployed plane
|
|
737
|
+
* (cached + refreshed), hand the agent the certified prompt surface to fold
|
|
738
|
+
* (`applied.composePrompt`) and the promoted, gate-certified profile DIFFS
|
|
739
|
+
* as PROPOSALS (`applied.proposals` / `applied.applyProfile`).
|
|
740
|
+
* 2. SEND — serialize a typed {@link RunRecord} for the call through the shipped
|
|
741
|
+
* OTLP builders to the plane's `/v1/otlp` ingest, best-effort.
|
|
742
|
+
*
|
|
743
|
+
* SAFETY — observe + deliver ONLY. This hook NEVER auto-applies a received diff
|
|
744
|
+
* at runtime. A promoted diff is surfaced as a proposal; a human, or the gated
|
|
745
|
+
* local `improve()` loop, turns a proposal into a shipped profile. That
|
|
746
|
+
* preserves the held-out invariant the plane enforces — a runtime that silently
|
|
747
|
+
* folded an un-gated diff into itself would defeat the very gate the diff cleared.
|
|
748
|
+
*
|
|
749
|
+
* import { withIntelligence } from '@tangle-network/agent-runtime/intelligence'
|
|
750
|
+
*
|
|
751
|
+
* export const agent = withIntelligence(
|
|
752
|
+
* async (input, applied) => {
|
|
753
|
+
* const out = await myAgent(input, { systemPrompt: applied.composePrompt(BASE) })
|
|
754
|
+
* applied.record({ success: true, usage: { inferenceUsd: 0.002, intelligenceUsd: 0 } })
|
|
755
|
+
* return out
|
|
756
|
+
* },
|
|
757
|
+
* { project: 'support-agent', target: 'support-agent' },
|
|
758
|
+
* )
|
|
759
|
+
*
|
|
760
|
+
* @experimental
|
|
761
|
+
*/
|
|
762
|
+
|
|
763
|
+
/** What the hook hands the agent each run. Additive over the prompt-only
|
|
764
|
+
* delivery: `composePrompt` folds the certified prompt surface (as before);
|
|
765
|
+
* `proposals`/`applyProfile` surface the promoted profile DIFFS — never
|
|
766
|
+
* auto-applied; `record` enriches the {@link RunRecord} that is sent. */
|
|
767
|
+
interface AppliedIntelligence {
|
|
768
|
+
/** The certified profile in effect (null when none promoted / pull failed —
|
|
769
|
+
* fail-closed: the agent runs on its base surface). */
|
|
770
|
+
certified: CertifiedProfile | null;
|
|
771
|
+
/** Fold the certified prompt surface into a base system prompt (the promoted
|
|
772
|
+
* prompt). The consumer opts in by calling it. */
|
|
773
|
+
composePrompt(base: string): string;
|
|
774
|
+
/** The promoted, gate-certified profile diffs — surfaced for a human or the
|
|
775
|
+
* gated `improve()` loop. NEVER auto-applied by this hook. Empty when none. */
|
|
776
|
+
proposals: ProposedProfileDiff[];
|
|
777
|
+
/** Fold every proposal into `base` via `applyAgentProfileDiff`, in promotion
|
|
778
|
+
* order, and return the result. The caller invokes this EXPLICITLY (it is the
|
|
779
|
+
* human/gated apply step) — the hook never calls it on the run path. */
|
|
780
|
+
applyProfile(base: AgentProfile): AgentProfile;
|
|
781
|
+
/** Enrich the {@link RunRecord} sent for this call — outcome, usage split,
|
|
782
|
+
* model/provider, and the loop event stream. Optional; an un-recorded run
|
|
783
|
+
* still sends input/output with an inference-only zero usage split. */
|
|
784
|
+
record(report: RunReport): void;
|
|
785
|
+
}
|
|
786
|
+
/** An agent wrapped by {@link withIntelligence}: receives the input plus the
|
|
787
|
+
* intelligence delivered for this run. */
|
|
788
|
+
type IntelligenceAgent<I, O> = (input: I, applied: AppliedIntelligence) => Promise<O>;
|
|
789
|
+
/** `withIntelligence` config = the Observe config plus the pull target, refresh
|
|
790
|
+
* cadence, and a proposals callback. One base URL (`baseUrl` /
|
|
791
|
+
* `TANGLE_INTELLIGENCE_URL`) drives both the send and receive paths. */
|
|
792
|
+
interface IntelligenceHookConfig extends IntelligenceConfig {
|
|
793
|
+
/** Pull target. Defaults to `project`. */
|
|
794
|
+
target?: string;
|
|
795
|
+
/** Min interval between certified-profile pulls. Default 5m. */
|
|
796
|
+
refreshMs?: number;
|
|
797
|
+
/** Per-pull timeout in ms (fail-closed on a hung plane). Default 10000. */
|
|
798
|
+
timeoutMs?: number;
|
|
799
|
+
/** fetch impl for the pull (tests). Defaults to global fetch. */
|
|
800
|
+
fetchImpl?: typeof fetch;
|
|
801
|
+
/** Notified when a refresh delivers a NEW set of promoted proposals (by
|
|
802
|
+
* provenance content hash). Surfaces diffs without auto-applying them. */
|
|
803
|
+
onProposals?: (proposals: ProposedProfileDiff[]) => void;
|
|
804
|
+
}
|
|
805
|
+
/** The wrapped agent — same `(input) => Promise<output>` shape, plus a manual
|
|
806
|
+
* `refresh()` and a `proposals()` accessor for the currently-promoted diffs. */
|
|
807
|
+
type IntelligenceWrapped<I, O> = ((input: I) => Promise<O>) & {
|
|
808
|
+
refresh(): Promise<void>;
|
|
809
|
+
proposals(): ProposedProfileDiff[];
|
|
810
|
+
};
|
|
811
|
+
/**
|
|
812
|
+
* Wrap an agent so it (a) RECEIVES the tenant's certified profile — the prompt
|
|
813
|
+
* surface to fold and the promoted profile diffs as proposals — and (b) SENDS a
|
|
814
|
+
* typed {@link RunRecord} per call to the plane. The pull is cached and refreshed
|
|
815
|
+
* at most every `refreshMs`; a failed pull is fail-closed (the agent runs on its
|
|
816
|
+
* base surface, never breaks because Intelligence is unreachable). The send is
|
|
817
|
+
* best-effort — an export failure never fails the agent's turn — while an error
|
|
818
|
+
* thrown by the agent itself propagates unchanged.
|
|
819
|
+
*/
|
|
820
|
+
declare function withIntelligence<I, O>(agent: IntelligenceAgent<I, O>, config: IntelligenceHookConfig): IntelligenceWrapped<I, O>;
|
|
821
|
+
|
|
714
822
|
/**
|
|
715
823
|
*
|
|
716
824
|
* Tangle Intelligence SDK — the Observe + Mode-0 product layer.
|
|
@@ -751,6 +859,44 @@ interface UsageSplit {
|
|
|
751
859
|
/** Intelligence-spawn spend in USD. Provably `0` at the OFF tier. */
|
|
752
860
|
intelligenceUsd: number;
|
|
753
861
|
}
|
|
862
|
+
/**
|
|
863
|
+
* The typed record `withIntelligence` sends per call — serialized through the
|
|
864
|
+
* shipped OTLP builders to the plane's `/v1/otlp` ingest. `input`/`output` are
|
|
865
|
+
* redacted on export; the per-class `usage` split carries the billing proof;
|
|
866
|
+
* `loopEvents`, when present, export as the nested loop→round→iteration span
|
|
867
|
+
* tree under the same `traceId`.
|
|
868
|
+
*/
|
|
869
|
+
interface RunRecord {
|
|
870
|
+
runId: string;
|
|
871
|
+
traceId: string;
|
|
872
|
+
project: string;
|
|
873
|
+
target: string;
|
|
874
|
+
input: unknown;
|
|
875
|
+
output: unknown;
|
|
876
|
+
outcome: {
|
|
877
|
+
success?: boolean;
|
|
878
|
+
score?: number;
|
|
879
|
+
usage: UsageSplit;
|
|
880
|
+
};
|
|
881
|
+
model?: string;
|
|
882
|
+
provider?: string;
|
|
883
|
+
loopEvents?: LoopTraceEvent[];
|
|
884
|
+
}
|
|
885
|
+
/**
|
|
886
|
+
* What an agent reports (via `applied.record`) to enrich the {@link RunRecord}
|
|
887
|
+
* sent for its call. All optional — an un-recorded run still sends input/output
|
|
888
|
+
* with an inference-only zero usage split. `costUsd` without a split is treated
|
|
889
|
+
* as pure inference (the base stream).
|
|
890
|
+
*/
|
|
891
|
+
interface RunReport {
|
|
892
|
+
success?: boolean;
|
|
893
|
+
score?: number;
|
|
894
|
+
usage?: Partial<UsageSplit>;
|
|
895
|
+
costUsd?: number;
|
|
896
|
+
model?: string;
|
|
897
|
+
provider?: string;
|
|
898
|
+
loopEvents?: LoopTraceEvent[];
|
|
899
|
+
}
|
|
754
900
|
/** Repo coordinates a product may declare for the (later) Gated-PR mode. The
|
|
755
901
|
* Observe slice only records their PRESENCE for `doctor()`; it never touches
|
|
756
902
|
* the repo. */
|
|
@@ -773,12 +919,13 @@ interface IntelligenceConfig {
|
|
|
773
919
|
overrides?: EffortOverrides;
|
|
774
920
|
};
|
|
775
921
|
/**
|
|
776
|
-
*
|
|
777
|
-
*
|
|
778
|
-
*
|
|
779
|
-
*
|
|
922
|
+
* The ONE Tangle Intelligence base URL — both the send (OTLP `/v1/otlp`) and
|
|
923
|
+
* receive (`/v1/profiles/:target/composed`) paths derive from it. Reads
|
|
924
|
+
* `TANGLE_INTELLIGENCE_URL` when omitted, else `https://intelligence.tangle.tools`.
|
|
925
|
+
* Send is best-effort and only ships when an `apiKey` is present (the tenant
|
|
926
|
+
* key the ingest requires); absent a key, export is a no-op.
|
|
780
927
|
*/
|
|
781
|
-
|
|
928
|
+
baseUrl?: string;
|
|
782
929
|
/**
|
|
783
930
|
* Redaction hook run over every exported input/output. A function replaces
|
|
784
931
|
* the default scrubber; `false` opts out entirely (raw fidelity, caller has
|
|
@@ -874,6 +1021,18 @@ interface IntelligenceClient {
|
|
|
874
1021
|
* Best-effort: export failures are swallowed. Returns the resolved `traceId`.
|
|
875
1022
|
*/
|
|
876
1023
|
recordTrace(events: ReadonlyArray<LoopTraceEvent>, meta?: RecordTraceMeta): string;
|
|
1024
|
+
/**
|
|
1025
|
+
* Send one typed {@link RunRecord} — the run's flat span (input/output/outcome/
|
|
1026
|
+
* usage/model/provider, redacted) plus, when `loopEvents` are present, the
|
|
1027
|
+
* nested loop topology under the same `traceId`. Reuses the shipped
|
|
1028
|
+
* `flatOtelSpan` + `buildLoopOtelSpans` builders (no second builder).
|
|
1029
|
+
* Best-effort: export failures are swallowed. Returns the record's `traceId`.
|
|
1030
|
+
*/
|
|
1031
|
+
exportRunRecord(record: RunRecord): string;
|
|
1032
|
+
/** Mint a fresh run id (`run-<hex>`). */
|
|
1033
|
+
freshRunId(): string;
|
|
1034
|
+
/** Mint a fresh 32-hex trace id. */
|
|
1035
|
+
freshTraceId(): string;
|
|
877
1036
|
/**
|
|
878
1037
|
* Network-free readiness report: which adoption modes are reachable given
|
|
879
1038
|
* this config. Observe is always reachable; Recommend needs outcomes; PR
|
|
@@ -902,26 +1061,11 @@ interface DoctorReport {
|
|
|
902
1061
|
};
|
|
903
1062
|
}
|
|
904
1063
|
/**
|
|
905
|
-
* Create an Observe-mode Intelligence client. Resolves effort,
|
|
906
|
-
* redactor up front; the exporter is built lazily and is `undefined` when no
|
|
907
|
-
*
|
|
908
|
-
*
|
|
1064
|
+
* Create an Observe-mode Intelligence client. Resolves effort, the base URL, and
|
|
1065
|
+
* the redactor up front; the exporter is built lazily and is `undefined` when no
|
|
1066
|
+
* `apiKey` is present (send becomes a no-op — the ingest requires a tenant key,
|
|
1067
|
+
* and best-effort export must never spam an unauthenticated plane).
|
|
909
1068
|
*/
|
|
910
1069
|
declare function createIntelligenceClient(config: IntelligenceConfig): IntelligenceClient;
|
|
911
|
-
/** A generic agent: one async input → output. The shape `withTangleIntelligence`
|
|
912
|
-
* preserves exactly. */
|
|
913
|
-
type Agent<TInput, TOutput> = (input: TInput) => Promise<TOutput>;
|
|
914
|
-
/** Either a built client or the config to build one. */
|
|
915
|
-
type ClientOrConfig = IntelligenceClient | IntelligenceConfig;
|
|
916
|
-
/**
|
|
917
|
-
* Wrap a generic `agent` with best-effort Observe-mode tracing, returning the
|
|
918
|
-
* SAME shape. Each call runs the agent under a trace and exports one span; an
|
|
919
|
-
* export failure is swallowed (the live agent never fails because Intelligence
|
|
920
|
-
* is down) but an error from the agent itself propagates unchanged.
|
|
921
|
-
*
|
|
922
|
-
* At `effort: 'off'` this is pure passthrough plus best-effort telemetry —
|
|
923
|
-
* zero intelligence spawns, `intelligenceUsd: 0` on the trace.
|
|
924
|
-
*/
|
|
925
|
-
declare function withTangleIntelligence<TInput, TOutput>(agent: Agent<TInput, TOutput>, clientOrConfig: ClientOrConfig): Agent<TInput, TOutput>;
|
|
926
1070
|
|
|
927
|
-
export { type
|
|
1071
|
+
export { type AppliedIntelligence, type CapabilityAuth, type CapabilityInterface, type CapabilityManifest, CapabilityNotAdmittedError, type CapabilitySurface, type CertProvenance, type CertifiedArtifact, type CertifiedCapability, type CertifiedCapabilitySummary, type CertifiedProfile, type CertifiedPromptSource, type CertifiedPromptSourceOptions, type CertifiedPromptSurface, type ContentRef, type CorpusAccess, type CredentialRef, type DeliveryBinding, type DeliveryBindingKind, type DiffProvenance, type DoctorReport, type EffortOverrides, type EffortOverridesCompiled, type EffortSettings, type EffortTier, type HostSpec, type IntelligenceAgent, type IntelligenceClient, type IntelligenceConfig, type IntelligenceHookConfig, type IntelligenceWrapped, type JsonSchema, type ModeReadiness, type ProposedProfileDiff, type ProvisionedHost, type PullCertifiedOptions, type PullOutcome, type RecordTraceMeta, type Redactor, type RepoConfig, type ResolveCtx, type ResolvedHook, type ResolvedRetrieval, type ResolvedSubagent, type ResolvedSurface, type RunRecord, type RunReport, type TraceHandle, type TraceMeta, type TraceOutcome, type UsageClass, type UsageSplit, compileEffort, composeCertifiedProfile, composeCertifiedProfileFromWire, composeCertifiedPrompt, createCertifiedPromptSource, createIntelligenceClient, defaultEffortTier, defaultRedactor, isIntelligenceOff, manifestFromProfile, normalizeCertifiedProfile, pullCertified, resolveEffort, resolveIntelligenceBaseUrl, resolveRedactor, withIntelligence };
|