agent-nuvira 3.1.3 → 3.2.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/dist/agents/agents/reasoner.d.ts +8 -0
- package/dist/agents/agents/reasoner.d.ts.map +1 -1
- package/dist/agents/agents/reasoner.js +53 -2
- package/dist/agents/agents/reasoner.js.map +1 -1
- package/dist/agents/agents/writer.d.ts +24 -0
- package/dist/agents/agents/writer.d.ts.map +1 -1
- package/dist/agents/agents/writer.js +194 -0
- package/dist/agents/agents/writer.js.map +1 -1
- package/dist/agents/composite-plan.d.ts +143 -0
- package/dist/agents/composite-plan.d.ts.map +1 -0
- package/dist/agents/composite-plan.js +399 -0
- package/dist/agents/composite-plan.js.map +1 -0
- package/dist/agents/long-form-plan.d.ts +156 -0
- package/dist/agents/long-form-plan.d.ts.map +1 -0
- package/dist/agents/long-form-plan.js +274 -0
- package/dist/agents/long-form-plan.js.map +1 -0
- package/dist/agents/orchestrator.d.ts +107 -0
- package/dist/agents/orchestrator.d.ts.map +1 -1
- package/dist/agents/orchestrator.js +501 -35
- package/dist/agents/orchestrator.js.map +1 -1
- package/dist/agents/prompt-assembly.d.ts +8 -0
- package/dist/agents/prompt-assembly.d.ts.map +1 -1
- package/dist/agents/prompt-assembly.js +17 -0
- package/dist/agents/prompt-assembly.js.map +1 -1
- package/dist/cli/chat.d.ts +27 -0
- package/dist/cli/chat.d.ts.map +1 -1
- package/dist/cli/chat.js +116 -6
- package/dist/cli/chat.js.map +1 -1
- package/dist/cli/execute.d.ts +12 -0
- package/dist/cli/execute.d.ts.map +1 -1
- package/dist/cli/execute.js +105 -2
- package/dist/cli/execute.js.map +1 -1
- package/dist/cli/models.d.ts.map +1 -1
- package/dist/cli/models.js +10 -0
- package/dist/cli/models.js.map +1 -1
- package/dist/cli/trace.d.ts.map +1 -1
- package/dist/cli/trace.js +27 -0
- package/dist/cli/trace.js.map +1 -1
- package/dist/gateway/registry.d.ts +31 -0
- package/dist/gateway/registry.d.ts.map +1 -1
- package/dist/gateway/registry.js +143 -13
- package/dist/gateway/registry.js.map +1 -1
- package/dist/inference/model-entitlement.d.ts +46 -0
- package/dist/inference/model-entitlement.d.ts.map +1 -0
- package/dist/inference/model-entitlement.js +98 -0
- package/dist/inference/model-entitlement.js.map +1 -0
- package/dist/learning/autonomy-policy.d.ts +334 -0
- package/dist/learning/autonomy-policy.d.ts.map +1 -0
- package/dist/learning/autonomy-policy.js +500 -0
- package/dist/learning/autonomy-policy.js.map +1 -0
- package/dist/learning/credential-fingerprint.d.ts +58 -0
- package/dist/learning/credential-fingerprint.d.ts.map +1 -0
- package/dist/learning/credential-fingerprint.js +126 -0
- package/dist/learning/credential-fingerprint.js.map +1 -0
- package/dist/learning/deliverable-class.d.ts +130 -0
- package/dist/learning/deliverable-class.d.ts.map +1 -0
- package/dist/learning/deliverable-class.js +432 -0
- package/dist/learning/deliverable-class.js.map +1 -0
- package/dist/learning/long-form.d.ts +252 -0
- package/dist/learning/long-form.d.ts.map +1 -0
- package/dist/learning/long-form.js +510 -0
- package/dist/learning/long-form.js.map +1 -0
- package/dist/learning/model-first-router.d.ts +17 -0
- package/dist/learning/model-first-router.d.ts.map +1 -1
- package/dist/learning/model-first-router.js +27 -0
- package/dist/learning/model-first-router.js.map +1 -1
- package/dist/learning/model-registry.d.ts +66 -4
- package/dist/learning/model-registry.d.ts.map +1 -1
- package/dist/learning/model-registry.js +67 -6
- package/dist/learning/model-registry.js.map +1 -1
- package/dist/learning/model-warmup.d.ts +97 -2
- package/dist/learning/model-warmup.d.ts.map +1 -1
- package/dist/learning/model-warmup.js +165 -60
- package/dist/learning/model-warmup.js.map +1 -1
- package/dist/learning/prompt-layers.d.ts +61 -0
- package/dist/learning/prompt-layers.d.ts.map +1 -0
- package/dist/learning/prompt-layers.js +140 -0
- package/dist/learning/prompt-layers.js.map +1 -0
- package/dist/learning/provider-limits.d.ts +66 -0
- package/dist/learning/provider-limits.d.ts.map +1 -0
- package/dist/learning/provider-limits.js +184 -0
- package/dist/learning/provider-limits.js.map +1 -0
- package/dist/learning/reasoning-trace.d.ts +36 -1
- package/dist/learning/reasoning-trace.d.ts.map +1 -1
- package/dist/learning/reasoning-trace.js +36 -2
- package/dist/learning/reasoning-trace.js.map +1 -1
- package/dist/learning/resilient-call.d.ts +36 -1
- package/dist/learning/resilient-call.d.ts.map +1 -1
- package/dist/learning/resilient-call.js +80 -5
- package/dist/learning/resilient-call.js.map +1 -1
- package/dist/learning/unattended-job.d.ts +293 -0
- package/dist/learning/unattended-job.d.ts.map +1 -0
- package/dist/learning/unattended-job.js +544 -0
- package/dist/learning/unattended-job.js.map +1 -0
- package/dist/learning/unattended-progress.d.ts +95 -0
- package/dist/learning/unattended-progress.d.ts.map +1 -0
- package/dist/learning/unattended-progress.js +147 -0
- package/dist/learning/unattended-progress.js.map +1 -0
- package/dist/learning/working-state.d.ts +109 -0
- package/dist/learning/working-state.d.ts.map +1 -0
- package/dist/learning/working-state.js +244 -0
- package/dist/learning/working-state.js.map +1 -0
- package/dist/nlu/conversation-gate.d.ts +24 -0
- package/dist/nlu/conversation-gate.d.ts.map +1 -1
- package/dist/nlu/conversation-gate.js +47 -3
- package/dist/nlu/conversation-gate.js.map +1 -1
- package/dist/tools/coding-tools.d.ts.map +1 -1
- package/dist/tools/coding-tools.js +95 -19
- package/dist/tools/coding-tools.js.map +1 -1
- package/dist/tools/edit-verification.d.ts +125 -0
- package/dist/tools/edit-verification.d.ts.map +1 -0
- package/dist/tools/edit-verification.js +237 -0
- package/dist/tools/edit-verification.js.map +1 -0
- package/dist/tools/git-tool.d.ts.map +1 -1
- package/dist/tools/git-tool.js +37 -4
- package/dist/tools/git-tool.js.map +1 -1
- package/dist/tools/registry.d.ts +30 -2
- package/dist/tools/registry.d.ts.map +1 -1
- package/dist/tools/registry.js +40 -11
- package/dist/tools/registry.js.map +1 -1
- package/dist/tools/run-cli.d.ts.map +1 -1
- package/dist/tools/run-cli.js +40 -13
- package/dist/tools/run-cli.js.map +1 -1
- package/dist/tools/run-terminal.d.ts +6 -1
- package/dist/tools/run-terminal.d.ts.map +1 -1
- package/dist/tools/run-terminal.js +158 -18
- package/dist/tools/run-terminal.js.map +1 -1
- package/dist/tools/tool-loop.d.ts +35 -0
- package/dist/tools/tool-loop.d.ts.map +1 -1
- package/dist/tools/tool-loop.js +141 -1
- package/dist/tools/tool-loop.js.map +1 -1
- package/dist/web-dashboard/chat-console.d.ts +6 -0
- package/dist/web-dashboard/chat-console.d.ts.map +1 -1
- package/dist/web-dashboard/chat-console.js.map +1 -1
- package/dist/web-dashboard/chat-retry.d.ts.map +1 -1
- package/dist/web-dashboard/chat-retry.js +10 -2
- package/dist/web-dashboard/chat-retry.js.map +1 -1
- package/dist/web-dashboard/server.d.ts.map +1 -1
- package/dist/web-dashboard/server.js +80 -8
- package/dist/web-dashboard/server.js.map +1 -1
- package/dist/web-dashboard/src/types.d.ts +81 -4
- package/dist/web-dashboard/src/types.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/web-dashboard/public/assets/{index-Co7Hk2FT.js → index-kCUkORm7.js} +2 -2
- package/src/web-dashboard/public/assets/{index-Co7Hk2FT.js.map → index-kCUkORm7.js.map} +1 -1
- package/src/web-dashboard/public/index.html +1 -1
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Credential Fingerprint — notice when the user's keys change, and re-probe.
|
|
3
|
+
*
|
|
4
|
+
* WHY THIS EXISTS. The routing pool can only contain models a probe has
|
|
5
|
+
* VERIFIED, and a probe only ever ran on a cold start or a maintenance command.
|
|
6
|
+
* So a purchase made mid-session — the exact case where a user expects the new
|
|
7
|
+
* models to appear — changed nothing: the credential was fine, the catalog was
|
|
8
|
+
* stale, and the next run would have picked the models up only if it happened to
|
|
9
|
+
* cold-start. There is no per-model entitlement API to ask ("may I buy
|
|
10
|
+
* `meta-llama/...`?" is not a question OpenRouter answers); the only honest
|
|
11
|
+
* signal is *"we sent one token with this key and it answered"*. But it is
|
|
12
|
+
* genuinely cheap to notice that the KEY SET changed and force that probe
|
|
13
|
+
* instead of waiting for an accident.
|
|
14
|
+
*
|
|
15
|
+
* WHAT IS STORED: a SHA-256 digest of the credential SHAPE — which providers are
|
|
16
|
+
* configured, a digest of each key, each base URL, each env-var presence. Never
|
|
17
|
+
* a key, not even truncated, and the digest is one-way, so the file is safe to
|
|
18
|
+
* read, copy or commit by accident. Its only job is equality.
|
|
19
|
+
*/
|
|
20
|
+
import { createHash } from 'node:crypto';
|
|
21
|
+
import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs';
|
|
22
|
+
import { dirname, join } from 'node:path';
|
|
23
|
+
import { envBuff, resolveNuviraHome } from '../config/paths.js';
|
|
24
|
+
import { CATALOG_PROVIDER_IDS, catalogEnvVar, getCatalogProvider } from '../inference/provider-catalog.js';
|
|
25
|
+
/** Sidecar file (under the memory dir) holding the last-seen credential shape. */
|
|
26
|
+
export const CREDENTIAL_FINGERPRINT_FILENAME = 'credential-fingerprint.json';
|
|
27
|
+
const DEFAULT_MEMORY_DIR = join(resolveNuviraHome(), 'memory');
|
|
28
|
+
function memoryDir() {
|
|
29
|
+
return envBuff('MEMORY_DIR') || DEFAULT_MEMORY_DIR;
|
|
30
|
+
}
|
|
31
|
+
/** Path of the fingerprint sidecar (exported so tests can redirect it). */
|
|
32
|
+
export function credentialFingerprintPath() {
|
|
33
|
+
return join(memoryDir(), CREDENTIAL_FINGERPRINT_FILENAME);
|
|
34
|
+
}
|
|
35
|
+
/** One-way digest of a secret — never the secret itself. */
|
|
36
|
+
function digest(value) {
|
|
37
|
+
return createHash('sha256').update(value).digest('hex').slice(0, 16);
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* The credential SHAPE, as a list of comparable lines.
|
|
41
|
+
*
|
|
42
|
+
* Exported (and separate from the hashing) so a test — or a support call — can
|
|
43
|
+
* see exactly which inputs are considered without needing to reverse a digest.
|
|
44
|
+
* The lines carry digests, never keys.
|
|
45
|
+
*/
|
|
46
|
+
export function credentialShapeInputs(configManager) {
|
|
47
|
+
const lines = [];
|
|
48
|
+
for (const provider of [...CATALOG_PROVIDER_IDS].sort()) {
|
|
49
|
+
const parts = [provider];
|
|
50
|
+
// 1. Config-resolved key (vault refs resolved by getProviderConfig, so a
|
|
51
|
+
// key that moved from plaintext into the vault is NOT a change).
|
|
52
|
+
let configKey;
|
|
53
|
+
let baseUrl;
|
|
54
|
+
try {
|
|
55
|
+
const { config } = configManager.getProviderConfig(provider);
|
|
56
|
+
configKey = typeof config?.apiKey === 'string' ? config.apiKey : undefined;
|
|
57
|
+
baseUrl = typeof config?.baseUrl === 'string' ? config.baseUrl : undefined;
|
|
58
|
+
}
|
|
59
|
+
catch {
|
|
60
|
+
// A provider the manager cannot describe contributes only its env state.
|
|
61
|
+
}
|
|
62
|
+
if (configKey)
|
|
63
|
+
parts.push(`cfg:${digest(configKey)}`);
|
|
64
|
+
if (baseUrl)
|
|
65
|
+
parts.push(`url:${baseUrl}`);
|
|
66
|
+
// 2. The standard env var — presence AND digest, so replacing a key in the
|
|
67
|
+
// environment is a change while an unrelated env tweak is not.
|
|
68
|
+
const envVar = catalogEnvVar(provider);
|
|
69
|
+
if (envVar) {
|
|
70
|
+
const fromEnv = process.env[envVar];
|
|
71
|
+
if (fromEnv)
|
|
72
|
+
parts.push(`env:${digest(fromEnv)}`);
|
|
73
|
+
}
|
|
74
|
+
// 3. Reachability class: keyless runners appear/disappear from the probe
|
|
75
|
+
// set when their catalog entry changes, not when a key changes.
|
|
76
|
+
const entry = getCatalogProvider(provider);
|
|
77
|
+
if (entry?.keyless)
|
|
78
|
+
parts.push('keyless');
|
|
79
|
+
lines.push(parts.join('|'));
|
|
80
|
+
}
|
|
81
|
+
return lines;
|
|
82
|
+
}
|
|
83
|
+
/** SHA-256 digest of the credential shape. Safe to log. */
|
|
84
|
+
export function credentialFingerprint(configManager) {
|
|
85
|
+
return digest(credentialShapeInputs(configManager).join('\n'));
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Compare the current credential shape against the last one recorded and RECORD
|
|
89
|
+
* the new one.
|
|
90
|
+
*
|
|
91
|
+
* Recording on every call is what makes this fire once per change rather than
|
|
92
|
+
* once per cycle: the caller sees `changed: true` a single time and can force a
|
|
93
|
+
* probe, and every later call in the same process is a no-op. `firstRun` is
|
|
94
|
+
* reported separately because "no previous record" is not evidence of a change —
|
|
95
|
+
* a fresh machine must not be treated as though a purchase just landed.
|
|
96
|
+
*/
|
|
97
|
+
export function detectCredentialChange(configManager, options = {}) {
|
|
98
|
+
const path = options.path ?? credentialFingerprintPath();
|
|
99
|
+
const fingerprint = credentialFingerprint(configManager);
|
|
100
|
+
let previous;
|
|
101
|
+
try {
|
|
102
|
+
if (existsSync(path)) {
|
|
103
|
+
const raw = JSON.parse(readFileSync(path, 'utf-8'));
|
|
104
|
+
if (typeof raw?.fingerprint === 'string')
|
|
105
|
+
previous = raw.fingerprint;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
catch {
|
|
109
|
+
// A corrupt sidecar is treated as absent — the worst case is one extra
|
|
110
|
+
// catalog probe, which is cheap and idempotent.
|
|
111
|
+
}
|
|
112
|
+
try {
|
|
113
|
+
mkdirSync(dirname(path), { recursive: true });
|
|
114
|
+
writeFileSync(path, JSON.stringify({ fingerprint, at: Date.now() }), 'utf-8');
|
|
115
|
+
}
|
|
116
|
+
catch {
|
|
117
|
+
// Best-effort: failing to record must never break a run.
|
|
118
|
+
}
|
|
119
|
+
return {
|
|
120
|
+
changed: previous !== undefined && previous !== fingerprint,
|
|
121
|
+
firstRun: previous === undefined,
|
|
122
|
+
fingerprint,
|
|
123
|
+
previous,
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
//# sourceMappingURL=credential-fingerprint.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"credential-fingerprint.js","sourceRoot":"","sources":["../../src/learning/credential-fingerprint.ts"],"names":[],"mappings":"AAAA;;;;;;;;;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|
|
4
|
+
*
|
|
5
|
+
* WHY THIS EXISTS (the WhatsApp story audit):
|
|
6
|
+
* A user asked, over WhatsApp, for a 100-page Harry-Potter-style story as a
|
|
7
|
+
* PDF. Six orchestrator runs over 32 minutes ALL failed, and the reason was
|
|
8
|
+
* not model availability (507 models were eligible). The reasoner — the
|
|
9
|
+
* technical-decision layer that runs BEFORE the planner — read "write a story"
|
|
10
|
+
* and emitted:
|
|
11
|
+
*
|
|
12
|
+
* {"language":"python","framework":"none","deliverable":"markdown_file",
|
|
13
|
+
* "reasoning":"…a Python script is the most efficient way to read existing
|
|
14
|
+
* chapters, process the outline, and update the target file…"}
|
|
15
|
+
*
|
|
16
|
+
* The planner then produced ZERO prose steps: step-02 was "Create a Python
|
|
17
|
+
* script to append the story continuation", step-03 "Run the Python script".
|
|
18
|
+
* The agent built a TOOL to write the story instead of writing the story, and
|
|
19
|
+
* because the tool-creation step itself failed, nothing was written at all —
|
|
20
|
+
* the target directory did not exist afterwards.
|
|
21
|
+
*
|
|
22
|
+
* The decision layer had no vocabulary for authored work: every branch of its
|
|
23
|
+
* taxonomy (language/framework/buildCommand/architecture/deliverable) assumes
|
|
24
|
+
* the deliverable is a PROGRAM. So a creative ask could only ever be expressed
|
|
25
|
+
* as a program that emits the creative artifact.
|
|
26
|
+
*
|
|
27
|
+
* This module is the missing vocabulary. It is deliberately DETERMINISTIC and
|
|
28
|
+
* LLM-free — the classifier is a safety net that the LLM's own decision is
|
|
29
|
+
* checked against, so a weak model cannot reintroduce the category error. It
|
|
30
|
+
* runs on the raw goal before planning, and for `document`/`creative` the
|
|
31
|
+
* orchestrator plans SECTIONS instead of a program.
|
|
32
|
+
*/
|
|
33
|
+
/**
|
|
34
|
+
* The five kinds of work the planner knows how to plan.
|
|
35
|
+
*
|
|
36
|
+
* `code` is the historical default and keeps every software ask on its
|
|
37
|
+
* existing path — this module must never change how a code task is planned.
|
|
38
|
+
*/
|
|
39
|
+
export type DeliverableClass = 'code' | 'document' | 'creative' | 'data' | 'research';
|
|
40
|
+
/**
|
|
41
|
+
* What a deliverable is physically MADE OF.
|
|
42
|
+
*
|
|
43
|
+
* Added for the hybrid asks: "develop a web based book which might require
|
|
44
|
+
* Python for voice assistance or interactiveness" is not one thing — it is
|
|
45
|
+
* prose + a web experience + (optionally) a Python narration service. A single
|
|
46
|
+
* `class` cannot express that, and forcing a choice is how the original audit
|
|
47
|
+
* produced a Python script instead of a story: the taxonomy only had room for
|
|
48
|
+
* one answer, and it picked the program.
|
|
49
|
+
*/
|
|
50
|
+
export type Substrate = 'prose' | 'web' | 'python' | 'asset' | 'data';
|
|
51
|
+
/** The result of classifying a goal. */
|
|
52
|
+
export interface DeliverableVerdict {
|
|
53
|
+
/** The winning class. */
|
|
54
|
+
class: DeliverableClass;
|
|
55
|
+
/** 0–1. Below `AUTHORED_CONFIDENCE_FLOOR` the caller should not override the LLM. */
|
|
56
|
+
confidence: number;
|
|
57
|
+
/** Which words drove the decision (auditable, shown in logs/traces). */
|
|
58
|
+
signals: string[];
|
|
59
|
+
/**
|
|
60
|
+
* True when the deliverable IS authored content (prose), as opposed to a
|
|
61
|
+
* program/library that manipulates it. This is the flag that switches the
|
|
62
|
+
* pipeline from "plan code steps" to "plan sections".
|
|
63
|
+
*/
|
|
64
|
+
authored: boolean;
|
|
65
|
+
/**
|
|
66
|
+
* Ordered materials, primary first. A plain story is `['prose']`; an
|
|
67
|
+
* interactive web book is `['web', 'prose']` (+ `'python'` when a narration
|
|
68
|
+
* service was asked for). Always at least one entry.
|
|
69
|
+
*/
|
|
70
|
+
substrates: Substrate[];
|
|
71
|
+
/**
|
|
72
|
+
* True when the deliverable is MORE THAN ONE thing joined — a book AND the
|
|
73
|
+
* site that presents it. Composite asks need a PHASED plan (scaffold first,
|
|
74
|
+
* then the content, then the experience layer), not a single-mode plan.
|
|
75
|
+
*/
|
|
76
|
+
composite: boolean;
|
|
77
|
+
/**
|
|
78
|
+
* True when the deliverable must be experienced, not just read: a site to
|
|
79
|
+
* navigate, narration to play, chapters to flip through. Drives the
|
|
80
|
+
* interactivity phase and the end-to-end verification step.
|
|
81
|
+
*/
|
|
82
|
+
interactive: boolean;
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Below this the verdict is a hint, not a ruling: the caller keeps the LLM's
|
|
86
|
+
* own decision. Set high enough that a passing mention ("write a report about
|
|
87
|
+
* the API I built") cannot hijack a genuine engineering task.
|
|
88
|
+
*/
|
|
89
|
+
export declare const AUTHORED_CONFIDENCE_FLOOR = 0.55;
|
|
90
|
+
/**
|
|
91
|
+
* Classify a goal into a deliverable class.
|
|
92
|
+
*
|
|
93
|
+
* Scoring is additive with per-signal weights rather than first-match, so a
|
|
94
|
+
* goal that mixes signals ("write a story AND package it as a CLI") resolves
|
|
95
|
+
* on the balance of evidence. Confidence is derived from the winning margin,
|
|
96
|
+
* so a clear call scores high and a coin-flip stays low — which is exactly
|
|
97
|
+
* what the caller needs to decide whether to override the LLM.
|
|
98
|
+
*
|
|
99
|
+
* Defaults to `code` when nothing matches: that preserves today's behaviour
|
|
100
|
+
* for every goal this module does not understand.
|
|
101
|
+
*/
|
|
102
|
+
export declare function classifyDeliverable(goal: string): DeliverableVerdict;
|
|
103
|
+
/**
|
|
104
|
+
* Convenience: is this goal asking for authored content (prose) rather than a
|
|
105
|
+
* program? The orchestrator uses this one predicate to switch planning modes.
|
|
106
|
+
*/
|
|
107
|
+
export declare function isAuthoredGoal(goal: string): boolean;
|
|
108
|
+
/**
|
|
109
|
+
* Is this a HYBRID deliverable — content plus a way to experience it?
|
|
110
|
+
*
|
|
111
|
+
* The orchestrator uses this one predicate to switch from "plan the content" to
|
|
112
|
+
* "plan the phases" (scaffold → content → experience → assets → verify). Kept
|
|
113
|
+
* here rather than in the planner so the intent vocabulary lives in one place.
|
|
114
|
+
*/
|
|
115
|
+
export declare function isCompositeGoal(goal: string): boolean;
|
|
116
|
+
/** Human-readable substrate list, for logs, traces and prompts. */
|
|
117
|
+
export declare function describeSubstrates(verdict: DeliverableVerdict): string;
|
|
118
|
+
/** Human-readable label for logs, traces and prompts. */
|
|
119
|
+
export declare function deliverableClassLabel(cls: DeliverableClass): string;
|
|
120
|
+
/**
|
|
121
|
+
* The instruction handed to the reasoner so its technical-decision document
|
|
122
|
+
* stops pretending an authored ask is a program.
|
|
123
|
+
*
|
|
124
|
+
* This is the fix for the exact reasoning string the audit captured
|
|
125
|
+
* ("a Python script is the most efficient way to…"): the reasoner is told, in
|
|
126
|
+
* its own JSON vocabulary, that `language` must NOT be a programming language
|
|
127
|
+
* for these classes, and that building a generator is the wrong deliverable.
|
|
128
|
+
*/
|
|
129
|
+
export declare function authoredDeliverableGuidance(cls: DeliverableClass, substrates?: Substrate[]): string;
|
|
130
|
+
//# sourceMappingURL=deliverable-class.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"deliverable-class.d.ts","sourceRoot":"","sources":["../../src/learning/deliverable-class.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AAIH;;;;;GAKG;AACH,MAAM,MAAM,gBAAgB,GAAG,MAAM,GAAG,UAAU,GAAG,UAAU,GAAG,MAAM,GAAG,UAAU,CAAC;AAEtF;;;;;;;;;GASG;AACH,MAAM,MAAM,SAAS,GAAG,OAAO,GAAG,KAAK,GAAG,QAAQ,GAAG,OAAO,GAAG,MAAM,CAAC;AAEtE,wCAAwC;AACxC,MAAM,WAAW,kBAAkB;IACjC,yBAAyB;IACzB,KAAK,EAAE,gBAAgB,CAAC;IACxB,qFAAqF;IACrF,UAAU,EAAE,MAAM,CAAC;IACnB,wEAAwE;IACxE,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB;;;;OAIG;IACH,QAAQ,EAAE,OAAO,CAAC;IAClB;;;;OAIG;IACH,UAAU,EAAE,SAAS,EAAE,CAAC;IACxB;;;;OAIG;IACH,SAAS,EAAE,OAAO,CAAC;IACnB;;;;OAIG;IACH,WAAW,EAAE,OAAO,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