@tangle-network/agent-runtime 0.103.1 → 0.105.0
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 +177 -39
- package/dist/agent.d.ts +1 -1
- package/dist/agent.js +5 -5
- package/dist/analyst-loop.d.ts +1 -1
- package/dist/candidate-execution/index.d.ts +2 -2
- package/dist/candidate-execution/index.js +4 -4
- package/dist/{chunk-TUSOOIDV.js → chunk-C5RTIBNZ.js} +2 -2
- package/dist/{chunk-SNSMRT6H.js → chunk-CTRA64LY.js} +3 -3
- package/dist/{chunk-ZXICDSAK.js → chunk-H5QPIZNX.js} +2 -2
- package/dist/{chunk-6WZZXQV5.js → chunk-HLKC4UYB.js} +1 -13
- package/dist/chunk-HLKC4UYB.js.map +1 -0
- package/dist/{chunk-AAN2MB2X.js → chunk-HNP72PNU.js} +3 -10
- package/dist/chunk-HNP72PNU.js.map +1 -0
- package/dist/{chunk-M6MD6JBS.js → chunk-KRBFHMV6.js} +429 -1
- package/dist/chunk-KRBFHMV6.js.map +1 -0
- package/dist/chunk-OPVWXJ2H.js +75 -0
- package/dist/chunk-OPVWXJ2H.js.map +1 -0
- package/dist/{chunk-AYU35OTU.js → chunk-PZZKQVQV.js} +1 -1
- package/dist/chunk-PZZKQVQV.js.map +1 -0
- package/dist/{chunk-B7K7V22Y.js → chunk-RDOAVVHY.js} +2 -2
- package/dist/{chunk-L5DST3QC.js → chunk-SMQXZGLZ.js} +1 -1
- package/dist/chunk-SMQXZGLZ.js.map +1 -0
- package/dist/{chunk-LFM4JBRW.js → chunk-UHEZW5BU.js} +1084 -527
- package/dist/chunk-UHEZW5BU.js.map +1 -0
- package/dist/{chunk-5AITUUHO.js → chunk-VISA6CI3.js} +3 -3
- package/dist/{chunk-ZOYN3JR5.js → chunk-WMTCUOQL.js} +5 -5
- package/dist/{chunk-3LJF5XSE.js → chunk-WRTOVNN4.js} +6 -6
- package/dist/chunk-WRTOVNN4.js.map +1 -0
- package/dist/{chunk-SBTWKPVR.js → chunk-WSTRQZYQ.js} +1 -1
- package/dist/chunk-WSTRQZYQ.js.map +1 -0
- package/dist/{chunk-EAQ5YRRY.js → chunk-XBG2W2VW.js} +50 -23
- package/dist/chunk-XBG2W2VW.js.map +1 -0
- package/dist/{chunk-QYCKIV6C.js → chunk-YJZA2BIK.js} +2 -2
- package/dist/{chunk-QYCKIV6C.js.map → chunk-YJZA2BIK.js.map} +1 -1
- package/dist/{completion-gate-DLINnrkM.d.ts → completion-gate-BMy5LGoP.d.ts} +3 -3
- package/dist/{coordination-DTehA977.d.ts → coordination-BZZSVYpZ.d.ts} +28 -28
- package/dist/environment-provider.d.ts +18 -7
- package/dist/environment-provider.js +3 -1
- package/dist/index.d.ts +106 -182
- package/dist/index.js +374 -236
- package/dist/index.js.map +1 -1
- package/dist/intelligence.d.ts +93 -47
- package/dist/intelligence.js +127 -73
- package/dist/intelligence.js.map +1 -1
- package/dist/knowledge.d.ts +6 -6
- package/dist/knowledge.js +9 -9
- package/dist/{local-harness-CtK9dSny.d.ts → local-harness-BDNcl6jI.d.ts} +1 -1
- package/dist/{loop-runner-bin-DhIXsLAd.d.ts → loop-runner-bin-68aoM9-7.d.ts} +5 -13
- package/dist/loop-runner-bin.d.ts +6 -8
- package/dist/loop-runner-bin.js +6 -6
- package/dist/loops.d.ts +67 -42
- package/dist/loops.js +10 -6
- package/dist/mcp/bin.js +4 -4
- package/dist/mcp/index.d.ts +9 -10
- package/dist/mcp/index.js +11 -11
- package/dist/mcp/index.js.map +1 -1
- package/dist/mcp/memory-bin.js +1 -1
- package/dist/primeintellect/index.d.ts +3 -4
- package/dist/primeintellect/index.js +5 -6
- package/dist/primeintellect/index.js.map +1 -1
- package/dist/profiles.d.ts +6 -6
- package/dist/profiles.js.map +1 -1
- package/dist/{protected-model-port-DzkUY3HQ.d.ts → protected-model-port-B4t-OQjL.d.ts} +1 -1
- package/dist/{improve-B40dRu0X.d.ts → redact-BuFjxBUJ.d.ts} +201 -154
- package/dist/{structural-rollout-BFPIy3iw.d.ts → structural-rollout-DEh6CEsa.d.ts} +4 -4
- package/dist/{supervise-Cp8bNcJi.d.ts → supervise-4_48wwvy.d.ts} +3 -3
- package/dist/testing.js +9 -9
- package/dist/testing.js.map +1 -1
- package/dist/{types-DK11_O4L.d.ts → types-BCoemcXU.d.ts} +4 -4
- package/dist/{types-lZTE_LBd.d.ts → types-CvNwMzQt.d.ts} +4 -4
- package/dist/{worktree-fanout-DiiJWjJO.d.ts → worktree-fanout-DxhAWr5Z.d.ts} +6 -6
- package/package.json +8 -7
- package/skills/build-with-agent-runtime/SKILL.md +15 -9
- package/skills/loop-writer/SKILL.md +1 -1
- package/dist/chunk-3LJF5XSE.js.map +0 -1
- package/dist/chunk-6WZZXQV5.js.map +0 -1
- package/dist/chunk-AAN2MB2X.js.map +0 -1
- package/dist/chunk-AYU35OTU.js.map +0 -1
- package/dist/chunk-EAQ5YRRY.js.map +0 -1
- package/dist/chunk-L5DST3QC.js.map +0 -1
- package/dist/chunk-LFM4JBRW.js.map +0 -1
- package/dist/chunk-M6MD6JBS.js.map +0 -1
- package/dist/chunk-SBTWKPVR.js.map +0 -1
- /package/dist/{chunk-TUSOOIDV.js.map → chunk-C5RTIBNZ.js.map} +0 -0
- /package/dist/{chunk-SNSMRT6H.js.map → chunk-CTRA64LY.js.map} +0 -0
- /package/dist/{chunk-ZXICDSAK.js.map → chunk-H5QPIZNX.js.map} +0 -0
- /package/dist/{chunk-B7K7V22Y.js.map → chunk-RDOAVVHY.js.map} +0 -0
- /package/dist/{chunk-5AITUUHO.js.map → chunk-VISA6CI3.js.map} +0 -0
- /package/dist/{chunk-ZOYN3JR5.js.map → chunk-WMTCUOQL.js.map} +0 -0
package/dist/intelligence.d.ts
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
import { AgentProfileDiff, AgentProfile, AgentProfileMcpServer, AgentImprovementActivationTarget, Sha256Digest, AgentImprovementSurface, AgentCandidateExperiment, AgentImprovementActivationIntent, AgentCandidateExperimentMaterial, AgentImprovementMeasuredComparison, AgentCandidateExperimentMeasurement,
|
|
1
|
+
import { AgentProfileDiff, AgentProfile, AgentImprovementProposal, AgentProfileMcpServer, AgentImprovementActivationTarget, Sha256Digest, AgentImprovementSurface, AgentCandidateExperiment, AgentImprovementActivationIntent, AgentCandidateExperimentMaterial, AgentImprovementMeasuredComparison, AgentCandidateExperimentMeasurement, AgentImprovementReviewDecision, AgentCandidateBenchmarkCellRef, AgentImprovementReview, AgentImprovementActivation, CandidateExecutionEvidence, AgentImprovementActivationTargetState, AgentImprovementActivationTargetTransition } from '@tangle-network/agent-interface';
|
|
2
2
|
export { AgentImprovementActivation, AgentImprovementActivationIntent, AgentImprovementActivationOutcome, AgentImprovementActivationResult, AgentImprovementMeasuredComparison, AgentImprovementProposal, AgentImprovementReview, AgentImprovementReviewDecision, CandidateExecutionEvidence, AgentCandidateProfileActivation as CandidateProfileMaterialization } from '@tangle-network/agent-interface';
|
|
3
|
-
import {
|
|
3
|
+
import { I as ImproveOptions, a as ImproveResult, b as ImproveMethodResult, R as Redactor } from './redact-BuFjxBUJ.js';
|
|
4
|
+
export { d as defaultRedactor, r as resolveRedactor } from './redact-BuFjxBUJ.js';
|
|
5
|
+
import { c as LoopTraceEvent } from './types-BCoemcXU.js';
|
|
4
6
|
import { b as ToolSpec, c as RuntimeTelemetryOptions } from './sanitize-DEbPNtyI.js';
|
|
5
7
|
import { R as RuntimeStreamEvent } from './types-BwoZWq-i.js';
|
|
6
|
-
import { P as PrepareAgentCandidateExecutionOptions, E as ExecutePreparedAgentCandidateOptions, A as AgentCandidateExecutionClaimStore, C as CreateProtectedAgentCandidateModelPortOptions } from './protected-model-port-
|
|
7
|
-
export { p as parseCandidateProfileMaterialization } from './protected-model-port-
|
|
8
|
+
import { P as PrepareAgentCandidateExecutionOptions, E as ExecutePreparedAgentCandidateOptions, A as AgentCandidateExecutionClaimStore, C as CreateProtectedAgentCandidateModelPortOptions } from './protected-model-port-B4t-OQjL.js';
|
|
9
|
+
export { p as parseCandidateProfileMaterialization } from './protected-model-port-B4t-OQjL.js';
|
|
8
10
|
import { A as AgentImprovementActivationTargetPlan } from './activation-Cm-9MMX1.js';
|
|
9
11
|
export { a as AgentImprovementActivationReconciliation, b as AgentImprovementActivationResultStore, c as AgentImprovementActivationTransition, d as AgentImprovementActivationTransitionInput, C as CreateAgentImprovementActivationResultOptions, E as ExecuteAgentImprovementActivationInput, e as ExecuteAgentImprovementActivationOptions, f as createAgentImprovementActivationResult, g as executeAgentImprovementActivation, v as verifyAgentImprovementActivationResult } from './activation-Cm-9MMX1.js';
|
|
10
12
|
import { TraceStore } from '@tangle-network/agent-eval';
|
|
@@ -14,12 +16,11 @@ import { c as AgentCandidateRunFinalization, d as AgentCandidateTaskExecution, e
|
|
|
14
16
|
import { AgentEnvironmentProviderRef, AgentEnvironmentProviderRegistry } from './environment-provider.js';
|
|
15
17
|
import { AnalystFinding } from '@tangle-network/agent-eval/analyst';
|
|
16
18
|
import { R as RunAnalystLoopOpts, a as RunAnalystLoopResult } from './types-CmYCMbFT.js';
|
|
17
|
-
import {
|
|
18
|
-
import '
|
|
19
|
-
import './types-lZTE_LBd.js';
|
|
20
|
-
import '@tangle-network/agent-eval/campaign';
|
|
21
|
-
import './local-harness-CtK9dSny.js';
|
|
19
|
+
import { OptimizationPackageSource, OptimizationMethodComparison, OptimizationTokenUsage } from '@tangle-network/agent-eval/campaign';
|
|
20
|
+
import './local-harness-BDNcl6jI.js';
|
|
22
21
|
import 'node:child_process';
|
|
22
|
+
import '@tangle-network/sandbox';
|
|
23
|
+
import './types-CvNwMzQt.js';
|
|
23
24
|
|
|
24
25
|
/**
|
|
25
26
|
*
|
|
@@ -134,39 +135,6 @@ interface EffortOverridesCompiled {
|
|
|
134
135
|
*/
|
|
135
136
|
declare function compileEffort(settings: EffortSettings): EffortOverridesCompiled;
|
|
136
137
|
|
|
137
|
-
/**
|
|
138
|
-
*
|
|
139
|
-
* Redaction for Intelligence trace export. The trace carries the customer's
|
|
140
|
-
* real input/output; before any of it leaves the process it passes through a
|
|
141
|
-
* `Redactor`. The default scrubs the obvious leak classes (API keys, bearer
|
|
142
|
-
* tokens, emails, private keys) from strings and walks nested objects/arrays,
|
|
143
|
-
* but a customer with domain-specific PII supplies their own `redact` hook.
|
|
144
|
-
*
|
|
145
|
-
* This is intentionally narrower than `src/sanitize.ts` (which redacts the
|
|
146
|
-
* runtime's *event envelope* field-by-field): here the value is opaque
|
|
147
|
-
* customer payload, so the scrub is value-shaped, not schema-shaped.
|
|
148
|
-
*
|
|
149
|
-
* @experimental
|
|
150
|
-
*/
|
|
151
|
-
/** A redactor maps an arbitrary trace value to a safe-to-export value. Pure;
|
|
152
|
-
* must not throw on cyclic input (the default tolerates cycles). */
|
|
153
|
-
type Redactor = (value: unknown) => unknown;
|
|
154
|
-
/**
|
|
155
|
-
* The built-in redactor. Walks objects and arrays; replaces values under
|
|
156
|
-
* secret-bearing keys wholesale; scrubs in-value patterns from every string.
|
|
157
|
-
* Cycle-safe (a seen-set short-circuits self-referential payloads to
|
|
158
|
-
* `'[circular]'`), depth-bounded, and total — never throws on customer input.
|
|
159
|
-
*/
|
|
160
|
-
declare function defaultRedactor(value: unknown): unknown;
|
|
161
|
-
/**
|
|
162
|
-
* Resolve the redactor a client uses. A caller-supplied hook replaces the
|
|
163
|
-
* default entirely (the customer owns their PII rules); absent one, the
|
|
164
|
-
* built-in `defaultRedactor` runs. Returning `false` is the explicit opt-out —
|
|
165
|
-
* NO redaction, for a caller who has already sanitized upstream and wants raw
|
|
166
|
-
* fidelity. Opt-out is loud (an explicit `false`), never a silent default.
|
|
167
|
-
*/
|
|
168
|
-
declare function resolveRedactor(redact: Redactor | false | undefined): Redactor;
|
|
169
|
-
|
|
170
138
|
/**
|
|
171
139
|
*
|
|
172
140
|
* Tangle Intelligence — the RECEIVE half of the loop (pull-by-default).
|
|
@@ -282,11 +250,40 @@ interface PullCertifiedOptions {
|
|
|
282
250
|
baseUrl?: string;
|
|
283
251
|
/** fetch impl (tests / non-global-fetch runtimes). Defaults to global fetch. */
|
|
284
252
|
fetchImpl?: typeof fetch;
|
|
285
|
-
/** Abort the
|
|
286
|
-
* Default 10000. The timeout surfaces as a normal fail-closed `succeeded:
|
|
287
|
-
* false` (the agent runs on its base surface). */
|
|
253
|
+
/** Abort the request after this many ms. Default 10000. */
|
|
288
254
|
timeoutMs?: number;
|
|
289
255
|
}
|
|
256
|
+
/** What Runtime knows about a failed proposal submission.
|
|
257
|
+
* `not-sent` means no request began, `rejected` means Intelligence returned a
|
|
258
|
+
* definitive 4xx response, and `unconfirmed` means the caller may safely retry
|
|
259
|
+
* the same immutable proposal. */
|
|
260
|
+
type AgentImprovementProposalSubmissionState = 'not-sent' | 'rejected' | 'unconfirmed';
|
|
261
|
+
/** Submit a completed measured proposal for product-side review. */
|
|
262
|
+
interface SubmitAgentImprovementProposalOptions {
|
|
263
|
+
proposal: AgentImprovementProposal;
|
|
264
|
+
/** Bearer key. Defaults to `process.env.TANGLE_API_KEY`. */
|
|
265
|
+
apiKey?: string;
|
|
266
|
+
/** Plane base URL. Defaults to `process.env.TANGLE_INTELLIGENCE_URL` then
|
|
267
|
+
* `https://intelligence.tangle.tools`. */
|
|
268
|
+
baseUrl?: string;
|
|
269
|
+
/** fetch impl (tests / non-global-fetch runtimes). Defaults to global fetch. */
|
|
270
|
+
fetchImpl?: typeof fetch;
|
|
271
|
+
/** Abort the request after this many ms. Default 10000. */
|
|
272
|
+
timeoutMs?: number;
|
|
273
|
+
}
|
|
274
|
+
/** Typed result for proposal submission. A successful result contains the
|
|
275
|
+
* exact immutable proposal Intelligence recorded. */
|
|
276
|
+
type SubmitAgentImprovementProposalOutcome = {
|
|
277
|
+
succeeded: true;
|
|
278
|
+
value: AgentImprovementProposal;
|
|
279
|
+
status: number;
|
|
280
|
+
} | {
|
|
281
|
+
succeeded: false;
|
|
282
|
+
submission: AgentImprovementProposalSubmissionState;
|
|
283
|
+
error: string;
|
|
284
|
+
status?: number;
|
|
285
|
+
code?: string;
|
|
286
|
+
};
|
|
290
287
|
/** Resolve the ONE Intelligence base URL — the single knob both the send and
|
|
291
288
|
* receive paths derive from. Env fallback: `TANGLE_INTELLIGENCE_URL`. */
|
|
292
289
|
declare function resolveIntelligenceBaseUrl(baseUrl: string | undefined): string;
|
|
@@ -304,6 +301,14 @@ declare function normalizeCertifiedProfile(raw: unknown): CertifiedProfile;
|
|
|
304
301
|
* the normal "nothing promoted yet" signal, carried as `status: 404`.
|
|
305
302
|
*/
|
|
306
303
|
declare function pullCertified(opts: PullCertifiedOptions): Promise<PullOutcome>;
|
|
304
|
+
/**
|
|
305
|
+
* Submit a completed Runtime proposal to Intelligence for product-side review.
|
|
306
|
+
* This never runs an experiment, approves a proposal, or applies a candidate.
|
|
307
|
+
* A 4xx response is a confirmed `rejected` request. Network failures, timeouts,
|
|
308
|
+
* 5xx responses, and invalid success responses are `unconfirmed`, so callers
|
|
309
|
+
* can retry the same digest because Intelligence stores proposals idempotently.
|
|
310
|
+
*/
|
|
311
|
+
declare function submitAgentImprovementProposal(opts: SubmitAgentImprovementProposalOptions): Promise<SubmitAgentImprovementProposalOutcome>;
|
|
307
312
|
/**
|
|
308
313
|
* Fold the certified prompt surface (and any certified prompt-folding artifacts:
|
|
309
314
|
* `prompt-surface` / `skill` / `instructions`) into a base system prompt under a
|
|
@@ -849,6 +854,47 @@ declare function createExactProcessCandidateExperimentExecutor(options: CreateEx
|
|
|
849
854
|
/** Compose host-owned execution ports with protected model access for one exact-process run. */
|
|
850
855
|
declare function createProtectedExactProcessCandidateExperimentExecutor(options: CreateProtectedExactProcessCandidateExperimentExecutorOptions): ProtectedExactProcessCandidateExperimentExecutor;
|
|
851
856
|
|
|
857
|
+
type OptimizationProvenance = NonNullable<OptimizationMethodComparison['best']['provenance']>;
|
|
858
|
+
interface OptimizationActivationReceipt {
|
|
859
|
+
kind: 'optimization-activation-receipt';
|
|
860
|
+
method: string;
|
|
861
|
+
source: OptimizationPackageSource;
|
|
862
|
+
bridge?: OptimizationPackageSource;
|
|
863
|
+
modules?: OptimizationProvenance['modules'];
|
|
864
|
+
python?: OptimizationProvenance['python'];
|
|
865
|
+
models?: {
|
|
866
|
+
candidate?: NonNullable<AgentProfile['model']>;
|
|
867
|
+
optimizer?: string;
|
|
868
|
+
};
|
|
869
|
+
usage: {
|
|
870
|
+
optimizerEvaluations: number;
|
|
871
|
+
optimizerTokens?: OptimizationTokenUsage;
|
|
872
|
+
};
|
|
873
|
+
cost: {
|
|
874
|
+
optimization: OptimizationReceiptCost;
|
|
875
|
+
finalTest: OptimizationReceiptCost;
|
|
876
|
+
total: OptimizationReceiptCost;
|
|
877
|
+
};
|
|
878
|
+
invocation: {
|
|
879
|
+
runtimeInvocationId: string;
|
|
880
|
+
optimizerRunId: string;
|
|
881
|
+
compatibleOptimizerRunId?: string;
|
|
882
|
+
resumed: boolean;
|
|
883
|
+
artifactDir: string;
|
|
884
|
+
};
|
|
885
|
+
developmentDataDigest: Sha256Digest;
|
|
886
|
+
digest: Sha256Digest;
|
|
887
|
+
}
|
|
888
|
+
interface OptimizationReceiptCost {
|
|
889
|
+
totalUsd: number;
|
|
890
|
+
accountingComplete: boolean;
|
|
891
|
+
incompleteReasons: string[];
|
|
892
|
+
}
|
|
893
|
+
/** Build a detached receipt only for methods backed by an identified external optimizer. */
|
|
894
|
+
declare function createOptimizationActivationReceipt(improvement: ImproveMethodResult): OptimizationActivationReceipt | undefined;
|
|
895
|
+
/** Read and verify the optimizer evidence carried by a measured proposal. */
|
|
896
|
+
declare function optimizationActivationReceiptFromMetadata(metadata: AgentImprovementMeasuredComparison['metadata']): OptimizationActivationReceipt | undefined;
|
|
897
|
+
|
|
852
898
|
type AgentImprovementProfileActivationTarget = Omit<AgentImprovementActivationTargetPlan, 'surface'> & {
|
|
853
899
|
surface: AgentImprovementProfileSurface;
|
|
854
900
|
};
|
|
@@ -1331,7 +1377,7 @@ interface IntelligenceClient {
|
|
|
1331
1377
|
traceRun<T>(meta: TraceMeta, fn: (trace: TraceHandle) => Promise<T>): Promise<T>;
|
|
1332
1378
|
/**
|
|
1333
1379
|
* Export a run's full loop topology — the ordered `LoopTraceEvent` stream a
|
|
1334
|
-
* `
|
|
1380
|
+
* `runAgentRounds`/`Supervisor` run emits — as a nested OTLP span tree (loop → round →
|
|
1335
1381
|
* iteration) into ONE trace. Reuses the shipped `buildLoopOtelSpans` builder
|
|
1336
1382
|
* (NO second span builder), so the topology a viewer renders matches the
|
|
1337
1383
|
* kernel's. `traceId` defaults to a fresh id; `rootParentSpanId` parents the
|
|
@@ -1386,4 +1432,4 @@ interface DoctorReport {
|
|
|
1386
1432
|
*/
|
|
1387
1433
|
declare function createIntelligenceClient(config: IntelligenceConfig): IntelligenceClient;
|
|
1388
1434
|
|
|
1389
|
-
export { AGENT_IMPROVEMENT_PROFILE_SURFACES, type AgentCandidateExecutionHostPorts, AgentCandidateExperimentCellExecutionError, type AgentCandidateExperimentCellPlacement, type AgentImprovementActivationTargetIdentity, AgentImprovementActivationTargetPlan, type AgentImprovementExperimentMaterial, type AgentImprovementProfileActivationPreparation, type AgentImprovementProfileActivationTarget, type AgentImprovementProfileReplacement, type AgentImprovementProfileSurface, type AgentImprovementProfileTargetState, type AgentImprovementProfileTargetTransition, type AgentImprovementTargetProfileDiffOptions, 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 CreateAgentImprovementActivationOptions, type CreateAgentImprovementProposalOptions, type CreateExactProcessCandidateExperimentExecutorOptions, type CreateProtectedExactProcessCandidateExperimentExecutorOptions, type CredentialRef, type DeliveryBinding, type DeliveryBindingKind, type DiffProvenance, type DoctorReport, type EffortOverrides, type EffortOverridesCompiled, type EffortSettings, type EffortTier, type ExactProcessCandidateExperimentExecution, type ExactProcessCandidateExperimentExecutor, type ExecuteAgentCandidateExperimentCellOptions, type HostSpec, type IntelligenceAgent, type IntelligenceClient, type IntelligenceConfig, type IntelligenceHookConfig, type IntelligenceWrapped, type JsonSchema, type ModeReadiness, type ProposeAgentImprovementOptions, type ProposeAgentImprovementResult, type ProposedProfileDiff, type ProtectedExactProcessCandidateExperimentExecutor, type ProvisionedHost, type PullCertifiedOptions, type PullOutcome, type RecordTraceMeta,
|
|
1435
|
+
export { AGENT_IMPROVEMENT_PROFILE_SURFACES, type AgentCandidateExecutionHostPorts, AgentCandidateExperimentCellExecutionError, type AgentCandidateExperimentCellPlacement, type AgentImprovementActivationTargetIdentity, AgentImprovementActivationTargetPlan, type AgentImprovementExperimentMaterial, type AgentImprovementProfileActivationPreparation, type AgentImprovementProfileActivationTarget, type AgentImprovementProfileReplacement, type AgentImprovementProfileSurface, type AgentImprovementProfileTargetState, type AgentImprovementProfileTargetTransition, type AgentImprovementProposalSubmissionState, type AgentImprovementTargetProfileDiffOptions, 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 CreateAgentImprovementActivationOptions, type CreateAgentImprovementProposalOptions, type CreateExactProcessCandidateExperimentExecutorOptions, type CreateProtectedExactProcessCandidateExperimentExecutorOptions, type CredentialRef, type DeliveryBinding, type DeliveryBindingKind, type DiffProvenance, type DoctorReport, type EffortOverrides, type EffortOverridesCompiled, type EffortSettings, type EffortTier, type ExactProcessCandidateExperimentExecution, type ExactProcessCandidateExperimentExecutor, type ExecuteAgentCandidateExperimentCellOptions, type HostSpec, type IntelligenceAgent, type IntelligenceClient, type IntelligenceConfig, type IntelligenceHookConfig, type IntelligenceWrapped, type JsonSchema, type ModeReadiness, type OptimizationActivationReceipt, type OptimizationReceiptCost, type ProposeAgentImprovementOptions, type ProposeAgentImprovementResult, type ProposedProfileDiff, type ProtectedExactProcessCandidateExperimentExecutor, type ProvisionedHost, type PullCertifiedOptions, type PullOutcome, type RecordTraceMeta, Redactor, type RepoConfig, type ResolveCtx, type ResolvedHook, type ResolvedRetrieval, type ResolvedSubagent, type ResolvedSurface, type ReviewAgentImprovementInput, type RunAgentCandidateExperimentOptions, type RunAgentCandidateExperimentResult, type RunRecord, type RunReport, type SubmitAgentImprovementProposalOptions, type SubmitAgentImprovementProposalOutcome, type TraceHandle, type TraceMeta, type TraceOutcome, type UsageClass, type UsageSplit, type VerifyCandidateExecutionEvidenceOptions, agentImprovementProfileSurfaceDigest, agentImprovementProfileSurfaceInput, agentImprovementTargetProfileDiffs, buildAgentImprovementActivationTargets, compileEffort, composeCertifiedProfile, composeCertifiedProfileFromWire, composeCertifiedPrompt, createAgentImprovementActivation, createAgentImprovementMeasuredComparison, createAgentImprovementProposal, createCertifiedPromptSource, createExactProcessCandidateExperimentExecutor, createIntelligenceClient, createOptimizationActivationReceipt, createProtectedExactProcessCandidateExperimentExecutor, defaultEffortTier, exactProcessCandidateExperimentExecutionSupport, executeAgentCandidateExperimentCell, isAgentImprovementProfileSurface, isIntelligenceOff, manifestFromProfile, normalizeCertifiedProfile, optimizationActivationReceiptFromMetadata, prepareAgentImprovementProfileActivation, proposeAgentImprovement, pullCertified, resolveEffort, resolveIntelligenceBaseUrl, reviewAgentImprovementProposal, runAgentCandidateExperiment, submitAgentImprovementProposal, verifyAgentImprovementActivation, verifyAgentImprovementProposal, verifyAgentImprovementReview, verifyCandidateExecutionEvidence, withIntelligence };
|
package/dist/intelligence.js
CHANGED
|
@@ -1,12 +1,16 @@
|
|
|
1
|
+
import {
|
|
2
|
+
defaultRedactor,
|
|
3
|
+
resolveRedactor
|
|
4
|
+
} from "./chunk-OPVWXJ2H.js";
|
|
1
5
|
import {
|
|
2
6
|
createProtectedAgentCandidateModelPort,
|
|
3
7
|
exactProcessProviderAsCandidateExecutor
|
|
4
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-H5QPIZNX.js";
|
|
5
9
|
import {
|
|
6
10
|
createAgentImprovementActivationResult,
|
|
7
11
|
executeAgentImprovementActivation,
|
|
8
12
|
verifyAgentImprovementActivationResult
|
|
9
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-VISA6CI3.js";
|
|
10
14
|
import {
|
|
11
15
|
AGENT_IMPROVEMENT_PROFILE_SURFACES,
|
|
12
16
|
AgentCandidateExperimentCellExecutionError,
|
|
@@ -17,8 +21,10 @@ import {
|
|
|
17
21
|
createAgentImprovementActivation,
|
|
18
22
|
createAgentImprovementMeasuredComparison,
|
|
19
23
|
createAgentImprovementProposal,
|
|
24
|
+
createOptimizationActivationReceipt,
|
|
20
25
|
executeAgentCandidateExperimentCell,
|
|
21
26
|
isAgentImprovementProfileSurface,
|
|
27
|
+
optimizationActivationReceiptFromMetadata,
|
|
22
28
|
proposeAgentImprovement,
|
|
23
29
|
reviewAgentImprovementProposal,
|
|
24
30
|
runAgentCandidateExperiment,
|
|
@@ -26,7 +32,7 @@ import {
|
|
|
26
32
|
verifyAgentImprovementProposal,
|
|
27
33
|
verifyAgentImprovementReview,
|
|
28
34
|
verifyCandidateExecutionEvidence
|
|
29
|
-
} from "./chunk-
|
|
35
|
+
} from "./chunk-UHEZW5BU.js";
|
|
30
36
|
import {
|
|
31
37
|
AGENT_CANDIDATE_EXECUTION_SUPPORT,
|
|
32
38
|
applyExactAgentProfileDiff,
|
|
@@ -34,8 +40,8 @@ import {
|
|
|
34
40
|
omitUndefinedObjectFields,
|
|
35
41
|
parseAgentCandidateProfileActivation,
|
|
36
42
|
parseExactAgentProfile
|
|
37
|
-
} from "./chunk-
|
|
38
|
-
import "./chunk-
|
|
43
|
+
} from "./chunk-WSTRQZYQ.js";
|
|
44
|
+
import "./chunk-YJZA2BIK.js";
|
|
39
45
|
import "./chunk-UPWGXKXB.js";
|
|
40
46
|
import {
|
|
41
47
|
buildLoopOtelSpans,
|
|
@@ -43,11 +49,11 @@ import {
|
|
|
43
49
|
createOtelExporter,
|
|
44
50
|
flatOtelSpan
|
|
45
51
|
} from "./chunk-2VZYRB55.js";
|
|
46
|
-
import "./chunk-
|
|
52
|
+
import "./chunk-HLKC4UYB.js";
|
|
47
53
|
import "./chunk-ISPWRSEC.js";
|
|
48
54
|
import {
|
|
49
55
|
resolveAgentEnvironmentProvider
|
|
50
|
-
} from "./chunk-
|
|
56
|
+
} from "./chunk-KRBFHMV6.js";
|
|
51
57
|
import "./chunk-3MDZX7YU.js";
|
|
52
58
|
import "./chunk-FD2MBMOH.js";
|
|
53
59
|
import "./chunk-M22PL4GH.js";
|
|
@@ -59,7 +65,8 @@ import { contentHash } from "@tangle-network/agent-eval";
|
|
|
59
65
|
// src/intelligence/delivery.ts
|
|
60
66
|
var defaultPlaneBaseUrl = "https://intelligence.tangle.tools";
|
|
61
67
|
var defaultRefreshMs = 3e5;
|
|
62
|
-
var
|
|
68
|
+
var defaultPlaneRequestTimeoutMs = 1e4;
|
|
69
|
+
var maxPlaneErrorTextLength = 200;
|
|
63
70
|
function resolveIntelligenceBaseUrl(baseUrl) {
|
|
64
71
|
if (baseUrl) return baseUrl.replace(/\/+$/, "");
|
|
65
72
|
if (typeof process !== "undefined" && process.env.TANGLE_INTELLIGENCE_URL) {
|
|
@@ -73,9 +80,44 @@ function resolveApiKey(apiKey) {
|
|
|
73
80
|
return process.env.TANGLE_API_KEY;
|
|
74
81
|
return "";
|
|
75
82
|
}
|
|
83
|
+
async function requestPlane(input) {
|
|
84
|
+
const doFetch = input.fetchImpl ?? globalThis.fetch;
|
|
85
|
+
if (!doFetch) {
|
|
86
|
+
return { succeeded: false, attempted: false, error: "no fetch implementation available" };
|
|
87
|
+
}
|
|
88
|
+
const apiKey = resolveApiKey(input.apiKey);
|
|
89
|
+
if (!apiKey) {
|
|
90
|
+
return {
|
|
91
|
+
succeeded: false,
|
|
92
|
+
attempted: false,
|
|
93
|
+
error: "no apiKey (set TANGLE_API_KEY or opts.apiKey)"
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
try {
|
|
97
|
+
const response = await doFetch(`${resolveIntelligenceBaseUrl(input.baseUrl)}${input.path}`, {
|
|
98
|
+
...input.method === void 0 ? {} : { method: input.method },
|
|
99
|
+
headers: {
|
|
100
|
+
authorization: `Bearer ${apiKey}`,
|
|
101
|
+
...input.headers ?? {}
|
|
102
|
+
},
|
|
103
|
+
...input.body === void 0 ? {} : { body: input.body },
|
|
104
|
+
signal: AbortSignal.timeout(input.timeoutMs ?? defaultPlaneRequestTimeoutMs)
|
|
105
|
+
});
|
|
106
|
+
return { succeeded: true, response };
|
|
107
|
+
} catch (err) {
|
|
108
|
+
return {
|
|
109
|
+
succeeded: false,
|
|
110
|
+
attempted: true,
|
|
111
|
+
error: err instanceof Error ? err.message : String(err)
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
}
|
|
76
115
|
function asRecord(value) {
|
|
77
116
|
return value && typeof value === "object" ? value : {};
|
|
78
117
|
}
|
|
118
|
+
function capPlaneErrorText(value) {
|
|
119
|
+
return value.slice(0, maxPlaneErrorTextLength);
|
|
120
|
+
}
|
|
79
121
|
function toDiffProvenance(value) {
|
|
80
122
|
const p = asRecord(value);
|
|
81
123
|
return {
|
|
@@ -105,24 +147,17 @@ function normalizeCertifiedProfile(raw) {
|
|
|
105
147
|
};
|
|
106
148
|
}
|
|
107
149
|
async function pullCertified(opts) {
|
|
108
|
-
const
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
const url = `${baseUrl}/v1/profiles/${encodeURIComponent(opts.target)}/composed`;
|
|
114
|
-
let res;
|
|
115
|
-
try {
|
|
116
|
-
res = await doFetch(url, {
|
|
117
|
-
headers: { authorization: `Bearer ${apiKey}` },
|
|
118
|
-
signal: AbortSignal.timeout(opts.timeoutMs ?? defaultPullTimeoutMs)
|
|
119
|
-
});
|
|
120
|
-
} catch (err) {
|
|
150
|
+
const request = await requestPlane({
|
|
151
|
+
...opts,
|
|
152
|
+
path: `/v1/profiles/${encodeURIComponent(opts.target)}/composed`
|
|
153
|
+
});
|
|
154
|
+
if (!request.succeeded) {
|
|
121
155
|
return {
|
|
122
156
|
succeeded: false,
|
|
123
|
-
error: `pull request failed: ${
|
|
157
|
+
error: request.attempted ? `pull request failed: ${request.error}` : request.error
|
|
124
158
|
};
|
|
125
159
|
}
|
|
160
|
+
const res = request.response;
|
|
126
161
|
if (res.status === 404) {
|
|
127
162
|
return {
|
|
128
163
|
succeeded: false,
|
|
@@ -147,6 +182,73 @@ async function pullCertified(opts) {
|
|
|
147
182
|
};
|
|
148
183
|
}
|
|
149
184
|
}
|
|
185
|
+
async function submitAgentImprovementProposal(opts) {
|
|
186
|
+
let proposal;
|
|
187
|
+
try {
|
|
188
|
+
proposal = verifyAgentImprovementProposal(opts.proposal);
|
|
189
|
+
} catch (err) {
|
|
190
|
+
return {
|
|
191
|
+
succeeded: false,
|
|
192
|
+
submission: "not-sent",
|
|
193
|
+
error: `proposal validation failed: ${err instanceof Error ? err.message : String(err)}`
|
|
194
|
+
};
|
|
195
|
+
}
|
|
196
|
+
const request = await requestPlane({
|
|
197
|
+
...opts,
|
|
198
|
+
path: "/v1/improvements/proposals",
|
|
199
|
+
method: "POST",
|
|
200
|
+
headers: { "content-type": "application/json" },
|
|
201
|
+
body: JSON.stringify({ proposal })
|
|
202
|
+
});
|
|
203
|
+
if (!request.succeeded) {
|
|
204
|
+
return {
|
|
205
|
+
succeeded: false,
|
|
206
|
+
submission: request.attempted ? "unconfirmed" : "not-sent",
|
|
207
|
+
error: request.attempted ? `proposal submission request failed: ${request.error}` : request.error
|
|
208
|
+
};
|
|
209
|
+
}
|
|
210
|
+
const res = request.response;
|
|
211
|
+
if (!res.ok) {
|
|
212
|
+
const body = await res.text().catch(() => "");
|
|
213
|
+
let code;
|
|
214
|
+
let message = capPlaneErrorText(body);
|
|
215
|
+
try {
|
|
216
|
+
const parsed = asRecord(JSON.parse(body));
|
|
217
|
+
if (typeof parsed.error === "string") code = capPlaneErrorText(parsed.error);
|
|
218
|
+
if (typeof parsed.message === "string") message = capPlaneErrorText(parsed.message);
|
|
219
|
+
} catch {
|
|
220
|
+
}
|
|
221
|
+
return {
|
|
222
|
+
succeeded: false,
|
|
223
|
+
submission: res.status >= 400 && res.status < 500 ? "rejected" : "unconfirmed",
|
|
224
|
+
error: `proposal submission ${res.status}: ${message}`,
|
|
225
|
+
status: res.status,
|
|
226
|
+
...code === void 0 ? {} : { code }
|
|
227
|
+
};
|
|
228
|
+
}
|
|
229
|
+
try {
|
|
230
|
+
const response = asRecord(await res.json());
|
|
231
|
+
const recorded = verifyAgentImprovementProposal(response.proposal);
|
|
232
|
+
if (recorded.digest !== proposal.digest) {
|
|
233
|
+
return {
|
|
234
|
+
succeeded: false,
|
|
235
|
+
submission: "unconfirmed",
|
|
236
|
+
error: "proposal submission returned a different proposal digest",
|
|
237
|
+
status: res.status
|
|
238
|
+
};
|
|
239
|
+
}
|
|
240
|
+
return { succeeded: true, value: recorded, status: res.status };
|
|
241
|
+
} catch (err) {
|
|
242
|
+
return {
|
|
243
|
+
succeeded: false,
|
|
244
|
+
submission: "unconfirmed",
|
|
245
|
+
error: `proposal submission response parse failed: ${capPlaneErrorText(
|
|
246
|
+
err instanceof Error ? err.message : String(err)
|
|
247
|
+
)}`,
|
|
248
|
+
status: res.status
|
|
249
|
+
};
|
|
250
|
+
}
|
|
251
|
+
}
|
|
150
252
|
var promptFoldTypes = ["prompt-surface", "skill", "instructions"];
|
|
151
253
|
function composeCertifiedPrompt(base, certified) {
|
|
152
254
|
if (!certified) return base;
|
|
@@ -254,57 +356,6 @@ function compileEffort(settings) {
|
|
|
254
356
|
};
|
|
255
357
|
}
|
|
256
358
|
|
|
257
|
-
// src/intelligence/redact.ts
|
|
258
|
-
var redactedMarker = "[redacted]";
|
|
259
|
-
var secretKeyPattern = /(api[-_]?key|secret|token|password|passwd|authorization|auth|private[-_]?key|credential|access[-_]?key|client[-_]?secret|session[-_]?(id|token)|cookie|bearer)/i;
|
|
260
|
-
var valuePatterns = [
|
|
261
|
-
// Bearer tokens.
|
|
262
|
-
/\bBearer\s+[A-Za-z0-9._\-+/=]{8,}/gi,
|
|
263
|
-
// Provider-style API keys (sk-..., sk-tan-..., pk_live_..., ghp_...).
|
|
264
|
-
/\b(?:sk|pk|rk|ak)[-_][A-Za-z0-9_-]{12,}/g,
|
|
265
|
-
/\bgh[pousr]_[A-Za-z0-9]{20,}/g,
|
|
266
|
-
// AWS access key ids.
|
|
267
|
-
/\bAKIA[0-9A-Z]{16}\b/g,
|
|
268
|
-
// PEM private-key blocks.
|
|
269
|
-
/-----BEGIN [A-Z ]*PRIVATE KEY-----[\s\S]*?-----END [A-Z ]*PRIVATE KEY-----/g,
|
|
270
|
-
// Email addresses.
|
|
271
|
-
/\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}\b/g
|
|
272
|
-
];
|
|
273
|
-
function scrubString(input) {
|
|
274
|
-
let out = input;
|
|
275
|
-
for (const pattern of valuePatterns) {
|
|
276
|
-
out = out.replace(pattern, redactedMarker);
|
|
277
|
-
}
|
|
278
|
-
return out;
|
|
279
|
-
}
|
|
280
|
-
function defaultRedactor(value) {
|
|
281
|
-
return walk(value, /* @__PURE__ */ new WeakSet(), 0);
|
|
282
|
-
}
|
|
283
|
-
var maxDepth = 32;
|
|
284
|
-
function walk(value, seen, depth) {
|
|
285
|
-
if (depth > maxDepth) return "[truncated]";
|
|
286
|
-
if (typeof value === "string") return scrubString(value);
|
|
287
|
-
if (value === null || typeof value !== "object") return value;
|
|
288
|
-
if (seen.has(value)) return "[circular]";
|
|
289
|
-
seen.add(value);
|
|
290
|
-
if (Array.isArray(value)) {
|
|
291
|
-
return value.map((item) => walk(item, seen, depth + 1));
|
|
292
|
-
}
|
|
293
|
-
const out = {};
|
|
294
|
-
for (const [key, v] of Object.entries(value)) {
|
|
295
|
-
if (secretKeyPattern.test(key)) {
|
|
296
|
-
out[key] = redactedMarker;
|
|
297
|
-
continue;
|
|
298
|
-
}
|
|
299
|
-
out[key] = walk(v, seen, depth + 1);
|
|
300
|
-
}
|
|
301
|
-
return out;
|
|
302
|
-
}
|
|
303
|
-
function resolveRedactor(redact) {
|
|
304
|
-
if (redact === false) return (value) => value;
|
|
305
|
-
return redact ?? defaultRedactor;
|
|
306
|
-
}
|
|
307
|
-
|
|
308
359
|
// src/intelligence/capability.ts
|
|
309
360
|
var CapabilityNotAdmittedError = class extends Error {
|
|
310
361
|
kind;
|
|
@@ -1397,6 +1448,7 @@ export {
|
|
|
1397
1448
|
createCertifiedPromptSource,
|
|
1398
1449
|
createExactProcessCandidateExperimentExecutor,
|
|
1399
1450
|
createIntelligenceClient,
|
|
1451
|
+
createOptimizationActivationReceipt,
|
|
1400
1452
|
createProtectedExactProcessCandidateExperimentExecutor,
|
|
1401
1453
|
defaultEffortTier,
|
|
1402
1454
|
defaultRedactor,
|
|
@@ -1407,6 +1459,7 @@ export {
|
|
|
1407
1459
|
isIntelligenceOff,
|
|
1408
1460
|
manifestFromProfile,
|
|
1409
1461
|
normalizeCertifiedProfile,
|
|
1462
|
+
optimizationActivationReceiptFromMetadata,
|
|
1410
1463
|
parseAgentCandidateProfileActivation as parseCandidateProfileMaterialization,
|
|
1411
1464
|
prepareAgentImprovementProfileActivation,
|
|
1412
1465
|
proposeAgentImprovement,
|
|
@@ -1416,6 +1469,7 @@ export {
|
|
|
1416
1469
|
resolveRedactor,
|
|
1417
1470
|
reviewAgentImprovementProposal,
|
|
1418
1471
|
runAgentCandidateExperiment,
|
|
1472
|
+
submitAgentImprovementProposal,
|
|
1419
1473
|
verifyAgentImprovementActivation,
|
|
1420
1474
|
verifyAgentImprovementActivationResult,
|
|
1421
1475
|
verifyAgentImprovementProposal,
|