@ultimat3/ai 23.0.0 → 25.0.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/CLAUDE.md +96 -32
- package/README.md +249 -75
- package/package.json +12 -11
- package/src/agent-facts.ts +9 -2
- package/src/agent-transcript.ts +1 -1
- package/src/agent.ts +43 -25
- package/src/budget.ts +178 -51
- package/src/content-blocks.ts +227 -0
- package/src/content-errors.ts +67 -0
- package/src/echo-provider.ts +102 -0
- package/src/embeddings.ts +40 -21
- package/src/error-body.ts +38 -3
- package/src/errors.ts +19 -11
- package/src/eval-baseline.ts +5 -1
- package/src/eval-errors.ts +3 -1
- package/src/evals.ts +1 -1
- package/src/failure-disclosure.ts +90 -0
- package/src/gateway.ts +73 -37
- package/src/hive-pool.ts +24 -16
- package/src/hive-result.ts +4 -1
- package/src/hive.ts +15 -5
- package/src/index.ts +66 -25
- package/src/llm-cache.ts +4 -3
- package/src/llm.ts +27 -65
- package/src/model-resolve.ts +79 -0
- package/src/models.ts +125 -111
- package/src/openai-body.ts +13 -2
- package/src/openai-messages.ts +86 -15
- package/src/openai-provider.ts +28 -31
- package/src/openai-wire.ts +11 -3
- package/src/pg-vector-sql.ts +11 -7
- package/src/pg-vector.ts +21 -10
- package/src/prompt-fence.ts +128 -0
- package/src/prompt.ts +43 -13
- package/src/provider.ts +82 -117
- package/src/rag.ts +17 -9
- package/src/remote-embedder.ts +15 -41
- package/src/respond.ts +86 -0
- package/src/runtime.ts +12 -14
- package/src/scorers.ts +14 -3
- package/src/tool-idempotency.ts +79 -0
- package/src/tools.ts +52 -39
- package/src/vector-scope.ts +46 -4
- package/src/vector.ts +117 -41
- package/src/wire.ts +7 -2
- package/src/fix-line.evals.ts +0 -35
- package/src/fix-line.ts +0 -27
- package/src/openai-models.ts +0 -84
package/src/fix-line.evals.ts
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The eval attached to `fixLinePrompt`. Cases live here rather than in the test file, matching
|
|
3
|
-
* every app's own prompts — a fixture-driven, deterministic `exact` scorer, no judge, because
|
|
4
|
-
* this is a proof of the eval mechanism itself and a proof that can drift is not one.
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
import { defineEval } from './evals';
|
|
8
|
-
import { fixLinePrompt } from './fix-line';
|
|
9
|
-
import { exact } from './scorers';
|
|
10
|
-
|
|
11
|
-
export const fixLineCases = [
|
|
12
|
-
{
|
|
13
|
-
name: 'runnable/x-command',
|
|
14
|
-
vars: { fixLine: 'bun run scripts/verify.ts --only lint,boundaries' },
|
|
15
|
-
expected: 'runnable',
|
|
16
|
-
},
|
|
17
|
-
{ name: 'runnable/cli-flag', vars: { fixLine: 'x db migrate' }, expected: 'runnable' },
|
|
18
|
-
{
|
|
19
|
-
name: 'vague/check',
|
|
20
|
-
vars: { fixLine: 'check the configuration and try again' },
|
|
21
|
-
expected: 'vague',
|
|
22
|
-
},
|
|
23
|
-
{ name: 'vague/see-docs', vars: { fixLine: 'see the docs for details' }, expected: 'vague' },
|
|
24
|
-
];
|
|
25
|
-
|
|
26
|
-
export const fixLineEval = defineEval({
|
|
27
|
-
name: 'ai.fix-line-runnable',
|
|
28
|
-
prompt: fixLinePrompt,
|
|
29
|
-
// The gate is the drop from this recorded score, never an absolute number: models drift,
|
|
30
|
-
// prompts should not. Accepting a new number is a diff in the committed baseline file.
|
|
31
|
-
baseline: import.meta.resolve('./fix-line.v1.baseline.json'),
|
|
32
|
-
tolerance: 0.05,
|
|
33
|
-
scorers: [exact],
|
|
34
|
-
cases: fixLineCases,
|
|
35
|
-
});
|
package/src/fix-line.ts
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The prompt behind `fix-line` — `@ultimat3/ai`'s own dogfood eval, and the package's first
|
|
3
|
-
* framework-level `*.eval.test.ts`. Not an app feature: every app that declares a prompt is
|
|
4
|
-
* required to pair it with an eval and a committed baseline (`defineEval`, `X_EVAL_MISSING`,
|
|
5
|
-
* `X_EVAL_BASELINE_MISSING`), and this proves that whole convention actually catches a
|
|
6
|
-
* regression from inside the package that owns it — through the real opt-in suite `x verify`'s
|
|
7
|
-
* `eval` step runs, not only through `evals.test.ts`'s unit fixtures against a temp-dir baseline.
|
|
8
|
-
*
|
|
9
|
-
* The task is small on purpose: classify whether an error's `fix:` line is a runnable command —
|
|
10
|
-
* axiom 4, "errors are instructions" — or vague guidance ("check the config", "see the docs").
|
|
11
|
-
*/
|
|
12
|
-
|
|
13
|
-
import { definePrompt } from './prompt';
|
|
14
|
-
|
|
15
|
-
export const fixLinePrompt = definePrompt<{ fixLine: string }>({
|
|
16
|
-
id: 'ai.fix-line-runnable',
|
|
17
|
-
version: '1',
|
|
18
|
-
template:
|
|
19
|
-
'Reply with exactly one word: "runnable" if the fix line below names a command to run, or ' +
|
|
20
|
-
'"vague" if it only describes what to do without naming one.\nFix line: {{fixLine}}',
|
|
21
|
-
input: {
|
|
22
|
-
type: 'object',
|
|
23
|
-
properties: { fixLine: { type: 'string' } },
|
|
24
|
-
required: ['fixLine'],
|
|
25
|
-
},
|
|
26
|
-
output: { type: 'string', enum: ['runnable', 'vague'] },
|
|
27
|
-
});
|
package/src/openai-models.ts
DELETED
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
// The OpenAI-format built-in catalogue: the vendor's own list prices, registered through the same
|
|
2
|
-
// public `registerModel` the Anthropic built-ins use. Here rather than in models.ts because these
|
|
3
|
-
// rows belong to a PROVIDER — models.ts owns the registry mechanism, never one vendor's price list.
|
|
4
|
-
|
|
5
|
-
import type { Money } from '@ultimat3/money';
|
|
6
|
-
import type { ModelId } from './models';
|
|
7
|
-
import { registerModel } from './models';
|
|
8
|
-
|
|
9
|
-
/** A price per million tokens, in INTEGER MINOR UNITS. Same rule as models.ts: never a float. */
|
|
10
|
-
const usd = (minor: number): Money => ({ minor, currency: 'USD' });
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* The ids this package prices, in ladder order (most capable first). A provider's `models` list is
|
|
14
|
-
* still its own — an endpoint speaking this format serves whatever ids it was deployed with, and
|
|
15
|
-
* `openAiProvider({ models })` is where those are named.
|
|
16
|
-
*/
|
|
17
|
-
export const OPENAI_MODEL_IDS: readonly ModelId[] = [
|
|
18
|
-
'gpt-5.6-sol',
|
|
19
|
-
'gpt-5.6-terra',
|
|
20
|
-
'gpt-5.6-luna',
|
|
21
|
-
];
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* Shared by the whole 5.6 family: a 1.05M context, a 128k output ceiling, and `reasoning_effort`
|
|
25
|
-
* over exactly the five rungs `EFFORTS` declares (the endpoint also takes `none`, which is what
|
|
26
|
-
* `thinking: 'disabled'` maps onto). `adaptive` is false because the format has no
|
|
27
|
-
* adaptive-thinking control at all — depth is `reasoning_effort` and nothing else.
|
|
28
|
-
*/
|
|
29
|
-
const FAMILY = {
|
|
30
|
-
/** One ladder: `moreCapableThan` compares these three with each other and with nothing else. */
|
|
31
|
-
family: 'openai',
|
|
32
|
-
contextWindow: 1_050_000,
|
|
33
|
-
maxOutput: 128_000,
|
|
34
|
-
/** Automatic caching starts at a 1024-token prefix; a shorter one silently does not cache. */
|
|
35
|
-
cacheMinimumTokens: 1_024,
|
|
36
|
-
reasoning: { effort: true, adaptive: false, disableThinkingUpTo: undefined },
|
|
37
|
-
} as const;
|
|
38
|
-
|
|
39
|
-
/**
|
|
40
|
-
* The three models this package is confident enough to price, and no more.
|
|
41
|
-
*
|
|
42
|
-
* Prices are the vendor's published list, read from developers.openai.com/api/docs/pricing on
|
|
43
|
-
* **2026-08-16**, in USD per million tokens:
|
|
44
|
-
*
|
|
45
|
-
* | id | input | cached input | output |
|
|
46
|
-
* |---|---|---|---|
|
|
47
|
-
* | `gpt-5.6-sol` | $5.00 | $0.50 | $30.00 |
|
|
48
|
-
* | `gpt-5.6-terra` | $2.00 | $0.20 | $12.00 |
|
|
49
|
-
* | `gpt-5.6-luna` | $0.20 | $0.02 | $1.20 |
|
|
50
|
-
*
|
|
51
|
-
* Deliberately not registered: `gpt-4o`, `gpt-4o-mini` and the `o1` family, whose cached input is
|
|
52
|
-
* **0.5x** their input rate rather than the 0.1x `costOf` assumes — a spec that prices them would
|
|
53
|
-
* under-report a cache-heavy workload by four fifths, and `costOf` answers confidently either way.
|
|
54
|
-
* `gpt-5.5-pro` and `o1-pro` are out for the same class of reason: they publish no cached rate.
|
|
55
|
-
* A wrong price is worse than no entry, so an app wanting one of those registers it itself, with
|
|
56
|
-
* the rate its own contract names.
|
|
57
|
-
*/
|
|
58
|
-
export function registerOpenAiModels(): void {
|
|
59
|
-
registerModel({
|
|
60
|
-
id: 'gpt-5.6-sol',
|
|
61
|
-
...FAMILY,
|
|
62
|
-
inputPerMillion: usd(500),
|
|
63
|
-
outputPerMillion: usd(3_000),
|
|
64
|
-
});
|
|
65
|
-
registerModel({
|
|
66
|
-
id: 'gpt-5.6-terra',
|
|
67
|
-
...FAMILY,
|
|
68
|
-
inputPerMillion: usd(200),
|
|
69
|
-
outputPerMillion: usd(1_200),
|
|
70
|
-
});
|
|
71
|
-
registerModel({
|
|
72
|
-
id: 'gpt-5.6-luna',
|
|
73
|
-
...FAMILY,
|
|
74
|
-
inputPerMillion: usd(20),
|
|
75
|
-
outputPerMillion: usd(120),
|
|
76
|
-
});
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
// The same shape models.ts uses for its built-ins: registration is a module side effect, so the
|
|
80
|
-
// default path is the app's path and importing the provider is enough to price what it serves.
|
|
81
|
-
// Exported as well as called, because the registry is module state and a suite that clears it with
|
|
82
|
-
// `resetModels()` otherwise leaves this provider serving ids nothing can price. Re-registering
|
|
83
|
-
// REPLACES, so an app with a negotiated rate calls `registerModel` after this one and wins.
|
|
84
|
-
registerOpenAiModels();
|