@tangle-network/agent-runtime 0.103.1 → 0.104.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 +4 -0
- package/dist/agent.d.ts +1 -1
- package/dist/agent.js +5 -5
- package/dist/analyst-loop.d.ts +1 -1
- package/dist/{chunk-TUSOOIDV.js → chunk-2QJSNOGK.js} +2 -2
- package/dist/{chunk-ZOYN3JR5.js → chunk-2UABGGUB.js} +3 -3
- package/dist/{chunk-6WZZXQV5.js → chunk-2X65HYMI.js} +1 -1
- package/dist/chunk-2X65HYMI.js.map +1 -0
- package/dist/{chunk-AAN2MB2X.js → chunk-3PPVCS75.js} +3 -3
- package/dist/chunk-3PPVCS75.js.map +1 -0
- package/dist/{chunk-EAQ5YRRY.js → chunk-5HNDYWUT.js} +39 -22
- package/dist/chunk-5HNDYWUT.js.map +1 -0
- package/dist/{chunk-3LJF5XSE.js → chunk-ATDFUJYI.js} +6 -6
- package/dist/chunk-ATDFUJYI.js.map +1 -0
- package/dist/{chunk-LFM4JBRW.js → chunk-FJI3EXU3.js} +46 -5
- package/dist/chunk-FJI3EXU3.js.map +1 -0
- package/dist/{chunk-5AITUUHO.js → chunk-HAO4CXHP.js} +2 -2
- package/dist/{chunk-M6MD6JBS.js → chunk-KRBFHMV6.js} +429 -1
- package/dist/chunk-KRBFHMV6.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-QYCKIV6C.js → chunk-STJEHM5F.js} +2 -2
- package/dist/{completion-gate-DLINnrkM.d.ts → completion-gate-Bv47cOnn.d.ts} +2 -2
- package/dist/{coordination-DTehA977.d.ts → coordination-CxtzMxSM.d.ts} +27 -27
- package/dist/environment-provider.d.ts +18 -7
- package/dist/environment-provider.js +3 -1
- package/dist/{improve-B40dRu0X.d.ts → improve--2A0gK1-.d.ts} +10 -4
- package/dist/index.d.ts +13 -13
- package/dist/index.js +10 -10
- package/dist/index.js.map +1 -1
- package/dist/intelligence.d.ts +46 -9
- package/dist/intelligence.js +117 -20
- package/dist/intelligence.js.map +1 -1
- package/dist/knowledge.d.ts +5 -5
- package/dist/knowledge.js +7 -7
- package/dist/{loop-runner-bin-DhIXsLAd.d.ts → loop-runner-bin-DUOGtvOl.d.ts} +3 -3
- package/dist/loop-runner-bin.d.ts +5 -5
- package/dist/loop-runner-bin.js +6 -6
- package/dist/loops.d.ts +66 -41
- package/dist/loops.js +9 -5
- package/dist/mcp/bin.js +4 -4
- package/dist/mcp/index.d.ts +6 -6
- package/dist/mcp/index.js +10 -10
- package/dist/mcp/index.js.map +1 -1
- package/dist/primeintellect/index.d.ts +1 -1
- package/dist/primeintellect/index.js.map +1 -1
- package/dist/profiles.d.ts +6 -6
- package/dist/profiles.js.map +1 -1
- package/dist/{structural-rollout-BFPIy3iw.d.ts → structural-rollout-C4mabf87.d.ts} +3 -3
- package/dist/{supervise-Cp8bNcJi.d.ts → supervise-7q9F5brx.d.ts} +3 -3
- package/dist/testing.js +8 -8
- 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-WsOzt8qu.d.ts} +5 -5
- package/package.json +3 -3
- 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-LFM4JBRW.js.map +0 -1
- package/dist/chunk-M6MD6JBS.js.map +0 -1
- /package/dist/{chunk-TUSOOIDV.js.map → chunk-2QJSNOGK.js.map} +0 -0
- /package/dist/{chunk-ZOYN3JR5.js.map → chunk-2UABGGUB.js.map} +0 -0
- /package/dist/{chunk-5AITUUHO.js.map → chunk-HAO4CXHP.js.map} +0 -0
- /package/dist/{chunk-QYCKIV6C.js.map → chunk-STJEHM5F.js.map} +0 -0
package/dist/intelligence.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
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 { c as LoopTraceEvent } from './types-
|
|
3
|
+
import { c as LoopTraceEvent } from './types-BCoemcXU.js';
|
|
4
4
|
import { b as ToolSpec, c as RuntimeTelemetryOptions } from './sanitize-DEbPNtyI.js';
|
|
5
5
|
import { R as RuntimeStreamEvent } from './types-BwoZWq-i.js';
|
|
6
6
|
import { P as PrepareAgentCandidateExecutionOptions, E as ExecutePreparedAgentCandidateOptions, A as AgentCandidateExecutionClaimStore, C as CreateProtectedAgentCandidateModelPortOptions } from './protected-model-port-DzkUY3HQ.js';
|
|
@@ -14,9 +14,9 @@ import { c as AgentCandidateRunFinalization, d as AgentCandidateTaskExecution, e
|
|
|
14
14
|
import { AgentEnvironmentProviderRef, AgentEnvironmentProviderRegistry } from './environment-provider.js';
|
|
15
15
|
import { AnalystFinding } from '@tangle-network/agent-eval/analyst';
|
|
16
16
|
import { R as RunAnalystLoopOpts, a as RunAnalystLoopResult } from './types-CmYCMbFT.js';
|
|
17
|
-
import { I as ImproveOptions, a as ImproveResult } from './improve
|
|
17
|
+
import { I as ImproveOptions, a as ImproveResult } from './improve--2A0gK1-.js';
|
|
18
18
|
import '@tangle-network/sandbox';
|
|
19
|
-
import './types-
|
|
19
|
+
import './types-CvNwMzQt.js';
|
|
20
20
|
import '@tangle-network/agent-eval/campaign';
|
|
21
21
|
import './local-harness-CtK9dSny.js';
|
|
22
22
|
import 'node:child_process';
|
|
@@ -282,11 +282,40 @@ interface PullCertifiedOptions {
|
|
|
282
282
|
baseUrl?: string;
|
|
283
283
|
/** fetch impl (tests / non-global-fetch runtimes). Defaults to global fetch. */
|
|
284
284
|
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). */
|
|
285
|
+
/** Abort the request after this many ms. Default 10000. */
|
|
288
286
|
timeoutMs?: number;
|
|
289
287
|
}
|
|
288
|
+
/** What Runtime knows about a failed proposal submission.
|
|
289
|
+
* `not-sent` means no request began, `rejected` means Intelligence returned a
|
|
290
|
+
* definitive 4xx response, and `unconfirmed` means the caller may safely retry
|
|
291
|
+
* the same immutable proposal. */
|
|
292
|
+
type AgentImprovementProposalSubmissionState = 'not-sent' | 'rejected' | 'unconfirmed';
|
|
293
|
+
/** Submit a completed measured proposal for product-side review. */
|
|
294
|
+
interface SubmitAgentImprovementProposalOptions {
|
|
295
|
+
proposal: AgentImprovementProposal;
|
|
296
|
+
/** Bearer key. Defaults to `process.env.TANGLE_API_KEY`. */
|
|
297
|
+
apiKey?: string;
|
|
298
|
+
/** Plane base URL. Defaults to `process.env.TANGLE_INTELLIGENCE_URL` then
|
|
299
|
+
* `https://intelligence.tangle.tools`. */
|
|
300
|
+
baseUrl?: string;
|
|
301
|
+
/** fetch impl (tests / non-global-fetch runtimes). Defaults to global fetch. */
|
|
302
|
+
fetchImpl?: typeof fetch;
|
|
303
|
+
/** Abort the request after this many ms. Default 10000. */
|
|
304
|
+
timeoutMs?: number;
|
|
305
|
+
}
|
|
306
|
+
/** Typed result for proposal submission. A successful result contains the
|
|
307
|
+
* exact immutable proposal Intelligence recorded. */
|
|
308
|
+
type SubmitAgentImprovementProposalOutcome = {
|
|
309
|
+
succeeded: true;
|
|
310
|
+
value: AgentImprovementProposal;
|
|
311
|
+
status: number;
|
|
312
|
+
} | {
|
|
313
|
+
succeeded: false;
|
|
314
|
+
submission: AgentImprovementProposalSubmissionState;
|
|
315
|
+
error: string;
|
|
316
|
+
status?: number;
|
|
317
|
+
code?: string;
|
|
318
|
+
};
|
|
290
319
|
/** Resolve the ONE Intelligence base URL — the single knob both the send and
|
|
291
320
|
* receive paths derive from. Env fallback: `TANGLE_INTELLIGENCE_URL`. */
|
|
292
321
|
declare function resolveIntelligenceBaseUrl(baseUrl: string | undefined): string;
|
|
@@ -304,6 +333,14 @@ declare function normalizeCertifiedProfile(raw: unknown): CertifiedProfile;
|
|
|
304
333
|
* the normal "nothing promoted yet" signal, carried as `status: 404`.
|
|
305
334
|
*/
|
|
306
335
|
declare function pullCertified(opts: PullCertifiedOptions): Promise<PullOutcome>;
|
|
336
|
+
/**
|
|
337
|
+
* Submit a completed Runtime proposal to Intelligence for product-side review.
|
|
338
|
+
* This never runs an experiment, approves a proposal, or applies a candidate.
|
|
339
|
+
* A 4xx response is a confirmed `rejected` request. Network failures, timeouts,
|
|
340
|
+
* 5xx responses, and invalid success responses are `unconfirmed`, so callers
|
|
341
|
+
* can retry the same digest because Intelligence stores proposals idempotently.
|
|
342
|
+
*/
|
|
343
|
+
declare function submitAgentImprovementProposal(opts: SubmitAgentImprovementProposalOptions): Promise<SubmitAgentImprovementProposalOutcome>;
|
|
307
344
|
/**
|
|
308
345
|
* Fold the certified prompt surface (and any certified prompt-folding artifacts:
|
|
309
346
|
* `prompt-surface` / `skill` / `instructions`) into a base system prompt under a
|
|
@@ -1331,7 +1368,7 @@ interface IntelligenceClient {
|
|
|
1331
1368
|
traceRun<T>(meta: TraceMeta, fn: (trace: TraceHandle) => Promise<T>): Promise<T>;
|
|
1332
1369
|
/**
|
|
1333
1370
|
* Export a run's full loop topology — the ordered `LoopTraceEvent` stream a
|
|
1334
|
-
* `
|
|
1371
|
+
* `runAgentRounds`/`Supervisor` run emits — as a nested OTLP span tree (loop → round →
|
|
1335
1372
|
* iteration) into ONE trace. Reuses the shipped `buildLoopOtelSpans` builder
|
|
1336
1373
|
* (NO second span builder), so the topology a viewer renders matches the
|
|
1337
1374
|
* kernel's. `traceId` defaults to a fresh id; `rootParentSpanId` parents the
|
|
@@ -1386,4 +1423,4 @@ interface DoctorReport {
|
|
|
1386
1423
|
*/
|
|
1387
1424
|
declare function createIntelligenceClient(config: IntelligenceConfig): IntelligenceClient;
|
|
1388
1425
|
|
|
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, type Redactor, type RepoConfig, type ResolveCtx, type ResolvedHook, type ResolvedRetrieval, type ResolvedSubagent, type ResolvedSurface, type ReviewAgentImprovementInput, type RunAgentCandidateExperimentOptions, type RunAgentCandidateExperimentResult, type RunRecord, type RunReport, 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, createProtectedExactProcessCandidateExperimentExecutor, defaultEffortTier, defaultRedactor, exactProcessCandidateExperimentExecutionSupport, executeAgentCandidateExperimentCell, isAgentImprovementProfileSurface, isIntelligenceOff, manifestFromProfile, normalizeCertifiedProfile, prepareAgentImprovementProfileActivation, proposeAgentImprovement, pullCertified, resolveEffort, resolveIntelligenceBaseUrl, resolveRedactor, reviewAgentImprovementProposal, runAgentCandidateExperiment, verifyAgentImprovementActivation, verifyAgentImprovementProposal, verifyAgentImprovementReview, verifyCandidateExecutionEvidence, withIntelligence };
|
|
1426
|
+
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 ProposeAgentImprovementOptions, type ProposeAgentImprovementResult, type ProposedProfileDiff, type ProtectedExactProcessCandidateExperimentExecutor, type ProvisionedHost, type PullCertifiedOptions, type PullOutcome, type RecordTraceMeta, type 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, createProtectedExactProcessCandidateExperimentExecutor, defaultEffortTier, defaultRedactor, exactProcessCandidateExperimentExecutionSupport, executeAgentCandidateExperimentCell, isAgentImprovementProfileSurface, isIntelligenceOff, manifestFromProfile, normalizeCertifiedProfile, prepareAgentImprovementProfileActivation, proposeAgentImprovement, pullCertified, resolveEffort, resolveIntelligenceBaseUrl, resolveRedactor, reviewAgentImprovementProposal, runAgentCandidateExperiment, submitAgentImprovementProposal, verifyAgentImprovementActivation, verifyAgentImprovementProposal, verifyAgentImprovementReview, verifyCandidateExecutionEvidence, withIntelligence };
|
package/dist/intelligence.js
CHANGED
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
createAgentImprovementActivationResult,
|
|
7
7
|
executeAgentImprovementActivation,
|
|
8
8
|
verifyAgentImprovementActivationResult
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-HAO4CXHP.js";
|
|
10
10
|
import {
|
|
11
11
|
AGENT_IMPROVEMENT_PROFILE_SURFACES,
|
|
12
12
|
AgentCandidateExperimentCellExecutionError,
|
|
@@ -26,7 +26,7 @@ import {
|
|
|
26
26
|
verifyAgentImprovementProposal,
|
|
27
27
|
verifyAgentImprovementReview,
|
|
28
28
|
verifyCandidateExecutionEvidence
|
|
29
|
-
} from "./chunk-
|
|
29
|
+
} from "./chunk-FJI3EXU3.js";
|
|
30
30
|
import {
|
|
31
31
|
AGENT_CANDIDATE_EXECUTION_SUPPORT,
|
|
32
32
|
applyExactAgentProfileDiff,
|
|
@@ -35,7 +35,7 @@ import {
|
|
|
35
35
|
parseAgentCandidateProfileActivation,
|
|
36
36
|
parseExactAgentProfile
|
|
37
37
|
} from "./chunk-SBTWKPVR.js";
|
|
38
|
-
import "./chunk-
|
|
38
|
+
import "./chunk-STJEHM5F.js";
|
|
39
39
|
import "./chunk-UPWGXKXB.js";
|
|
40
40
|
import {
|
|
41
41
|
buildLoopOtelSpans,
|
|
@@ -43,11 +43,11 @@ import {
|
|
|
43
43
|
createOtelExporter,
|
|
44
44
|
flatOtelSpan
|
|
45
45
|
} from "./chunk-2VZYRB55.js";
|
|
46
|
-
import "./chunk-
|
|
46
|
+
import "./chunk-2X65HYMI.js";
|
|
47
47
|
import "./chunk-ISPWRSEC.js";
|
|
48
48
|
import {
|
|
49
49
|
resolveAgentEnvironmentProvider
|
|
50
|
-
} from "./chunk-
|
|
50
|
+
} from "./chunk-KRBFHMV6.js";
|
|
51
51
|
import "./chunk-3MDZX7YU.js";
|
|
52
52
|
import "./chunk-FD2MBMOH.js";
|
|
53
53
|
import "./chunk-M22PL4GH.js";
|
|
@@ -59,7 +59,8 @@ import { contentHash } from "@tangle-network/agent-eval";
|
|
|
59
59
|
// src/intelligence/delivery.ts
|
|
60
60
|
var defaultPlaneBaseUrl = "https://intelligence.tangle.tools";
|
|
61
61
|
var defaultRefreshMs = 3e5;
|
|
62
|
-
var
|
|
62
|
+
var defaultPlaneRequestTimeoutMs = 1e4;
|
|
63
|
+
var maxPlaneErrorTextLength = 200;
|
|
63
64
|
function resolveIntelligenceBaseUrl(baseUrl) {
|
|
64
65
|
if (baseUrl) return baseUrl.replace(/\/+$/, "");
|
|
65
66
|
if (typeof process !== "undefined" && process.env.TANGLE_INTELLIGENCE_URL) {
|
|
@@ -73,9 +74,44 @@ function resolveApiKey(apiKey) {
|
|
|
73
74
|
return process.env.TANGLE_API_KEY;
|
|
74
75
|
return "";
|
|
75
76
|
}
|
|
77
|
+
async function requestPlane(input) {
|
|
78
|
+
const doFetch = input.fetchImpl ?? globalThis.fetch;
|
|
79
|
+
if (!doFetch) {
|
|
80
|
+
return { succeeded: false, attempted: false, error: "no fetch implementation available" };
|
|
81
|
+
}
|
|
82
|
+
const apiKey = resolveApiKey(input.apiKey);
|
|
83
|
+
if (!apiKey) {
|
|
84
|
+
return {
|
|
85
|
+
succeeded: false,
|
|
86
|
+
attempted: false,
|
|
87
|
+
error: "no apiKey (set TANGLE_API_KEY or opts.apiKey)"
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
try {
|
|
91
|
+
const response = await doFetch(`${resolveIntelligenceBaseUrl(input.baseUrl)}${input.path}`, {
|
|
92
|
+
...input.method === void 0 ? {} : { method: input.method },
|
|
93
|
+
headers: {
|
|
94
|
+
authorization: `Bearer ${apiKey}`,
|
|
95
|
+
...input.headers ?? {}
|
|
96
|
+
},
|
|
97
|
+
...input.body === void 0 ? {} : { body: input.body },
|
|
98
|
+
signal: AbortSignal.timeout(input.timeoutMs ?? defaultPlaneRequestTimeoutMs)
|
|
99
|
+
});
|
|
100
|
+
return { succeeded: true, response };
|
|
101
|
+
} catch (err) {
|
|
102
|
+
return {
|
|
103
|
+
succeeded: false,
|
|
104
|
+
attempted: true,
|
|
105
|
+
error: err instanceof Error ? err.message : String(err)
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
}
|
|
76
109
|
function asRecord(value) {
|
|
77
110
|
return value && typeof value === "object" ? value : {};
|
|
78
111
|
}
|
|
112
|
+
function capPlaneErrorText(value) {
|
|
113
|
+
return value.slice(0, maxPlaneErrorTextLength);
|
|
114
|
+
}
|
|
79
115
|
function toDiffProvenance(value) {
|
|
80
116
|
const p = asRecord(value);
|
|
81
117
|
return {
|
|
@@ -105,24 +141,17 @@ function normalizeCertifiedProfile(raw) {
|
|
|
105
141
|
};
|
|
106
142
|
}
|
|
107
143
|
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) {
|
|
144
|
+
const request = await requestPlane({
|
|
145
|
+
...opts,
|
|
146
|
+
path: `/v1/profiles/${encodeURIComponent(opts.target)}/composed`
|
|
147
|
+
});
|
|
148
|
+
if (!request.succeeded) {
|
|
121
149
|
return {
|
|
122
150
|
succeeded: false,
|
|
123
|
-
error: `pull request failed: ${
|
|
151
|
+
error: request.attempted ? `pull request failed: ${request.error}` : request.error
|
|
124
152
|
};
|
|
125
153
|
}
|
|
154
|
+
const res = request.response;
|
|
126
155
|
if (res.status === 404) {
|
|
127
156
|
return {
|
|
128
157
|
succeeded: false,
|
|
@@ -147,6 +176,73 @@ async function pullCertified(opts) {
|
|
|
147
176
|
};
|
|
148
177
|
}
|
|
149
178
|
}
|
|
179
|
+
async function submitAgentImprovementProposal(opts) {
|
|
180
|
+
let proposal;
|
|
181
|
+
try {
|
|
182
|
+
proposal = verifyAgentImprovementProposal(opts.proposal);
|
|
183
|
+
} catch (err) {
|
|
184
|
+
return {
|
|
185
|
+
succeeded: false,
|
|
186
|
+
submission: "not-sent",
|
|
187
|
+
error: `proposal validation failed: ${err instanceof Error ? err.message : String(err)}`
|
|
188
|
+
};
|
|
189
|
+
}
|
|
190
|
+
const request = await requestPlane({
|
|
191
|
+
...opts,
|
|
192
|
+
path: "/v1/improvements/proposals",
|
|
193
|
+
method: "POST",
|
|
194
|
+
headers: { "content-type": "application/json" },
|
|
195
|
+
body: JSON.stringify({ proposal })
|
|
196
|
+
});
|
|
197
|
+
if (!request.succeeded) {
|
|
198
|
+
return {
|
|
199
|
+
succeeded: false,
|
|
200
|
+
submission: request.attempted ? "unconfirmed" : "not-sent",
|
|
201
|
+
error: request.attempted ? `proposal submission request failed: ${request.error}` : request.error
|
|
202
|
+
};
|
|
203
|
+
}
|
|
204
|
+
const res = request.response;
|
|
205
|
+
if (!res.ok) {
|
|
206
|
+
const body = await res.text().catch(() => "");
|
|
207
|
+
let code;
|
|
208
|
+
let message = capPlaneErrorText(body);
|
|
209
|
+
try {
|
|
210
|
+
const parsed = asRecord(JSON.parse(body));
|
|
211
|
+
if (typeof parsed.error === "string") code = capPlaneErrorText(parsed.error);
|
|
212
|
+
if (typeof parsed.message === "string") message = capPlaneErrorText(parsed.message);
|
|
213
|
+
} catch {
|
|
214
|
+
}
|
|
215
|
+
return {
|
|
216
|
+
succeeded: false,
|
|
217
|
+
submission: res.status >= 400 && res.status < 500 ? "rejected" : "unconfirmed",
|
|
218
|
+
error: `proposal submission ${res.status}: ${message}`,
|
|
219
|
+
status: res.status,
|
|
220
|
+
...code === void 0 ? {} : { code }
|
|
221
|
+
};
|
|
222
|
+
}
|
|
223
|
+
try {
|
|
224
|
+
const response = asRecord(await res.json());
|
|
225
|
+
const recorded = verifyAgentImprovementProposal(response.proposal);
|
|
226
|
+
if (recorded.digest !== proposal.digest) {
|
|
227
|
+
return {
|
|
228
|
+
succeeded: false,
|
|
229
|
+
submission: "unconfirmed",
|
|
230
|
+
error: "proposal submission returned a different proposal digest",
|
|
231
|
+
status: res.status
|
|
232
|
+
};
|
|
233
|
+
}
|
|
234
|
+
return { succeeded: true, value: recorded, status: res.status };
|
|
235
|
+
} catch (err) {
|
|
236
|
+
return {
|
|
237
|
+
succeeded: false,
|
|
238
|
+
submission: "unconfirmed",
|
|
239
|
+
error: `proposal submission response parse failed: ${capPlaneErrorText(
|
|
240
|
+
err instanceof Error ? err.message : String(err)
|
|
241
|
+
)}`,
|
|
242
|
+
status: res.status
|
|
243
|
+
};
|
|
244
|
+
}
|
|
245
|
+
}
|
|
150
246
|
var promptFoldTypes = ["prompt-surface", "skill", "instructions"];
|
|
151
247
|
function composeCertifiedPrompt(base, certified) {
|
|
152
248
|
if (!certified) return base;
|
|
@@ -1416,6 +1512,7 @@ export {
|
|
|
1416
1512
|
resolveRedactor,
|
|
1417
1513
|
reviewAgentImprovementProposal,
|
|
1418
1514
|
runAgentCandidateExperiment,
|
|
1515
|
+
submitAgentImprovementProposal,
|
|
1419
1516
|
verifyAgentImprovementActivation,
|
|
1420
1517
|
verifyAgentImprovementActivationResult,
|
|
1421
1518
|
verifyAgentImprovementProposal,
|