@introspection-ai/recipes 0.51.0 → 0.52.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -3
- package/dist/api/api-bindings.d.ts +3 -0
- package/dist/api/api-bindings.d.ts.map +1 -0
- package/dist/api/api-bindings.js +2 -0
- package/dist/api/api-bindings.js.map +1 -0
- package/dist/api/session.d.ts +1 -0
- package/dist/api/session.d.ts.map +1 -1
- package/dist/api-bindings.d.ts +101 -0
- package/dist/api-bindings.d.ts.map +1 -0
- package/dist/api-bindings.js +406 -0
- package/dist/api-bindings.js.map +1 -0
- package/dist/channels/arguments.d.ts +116 -0
- package/dist/channels/arguments.d.ts.map +1 -0
- package/dist/channels/arguments.generated.d.ts +15 -0
- package/dist/channels/arguments.generated.d.ts.map +1 -0
- package/dist/channels/arguments.generated.js +181 -0
- package/dist/channels/arguments.generated.js.map +1 -0
- package/dist/channels/arguments.js +8 -0
- package/dist/channels/arguments.js.map +1 -0
- package/dist/channels/module.d.ts +5 -0
- package/dist/channels/module.d.ts.map +1 -1
- package/dist/channels/module.js +10 -5
- package/dist/channels/module.js.map +1 -1
- package/dist/channels/tools.d.ts.map +1 -1
- package/dist/channels/tools.js +22 -59
- package/dist/channels/tools.js.map +1 -1
- package/dist/channels/types.d.ts +5 -0
- package/dist/channels/types.d.ts.map +1 -1
- package/dist/child/session.d.ts +5 -0
- package/dist/child/session.d.ts.map +1 -1
- package/dist/child/session.js +2 -0
- package/dist/child/session.js.map +1 -1
- package/dist/clock.d.ts +80 -0
- package/dist/clock.d.ts.map +1 -0
- package/dist/clock.js +169 -0
- package/dist/clock.js.map +1 -0
- package/dist/command-parameters.d.ts +37 -5
- package/dist/command-parameters.d.ts.map +1 -1
- package/dist/command-parameters.js +73 -11
- package/dist/command-parameters.js.map +1 -1
- package/dist/connector-tools.d.ts +18 -0
- package/dist/connector-tools.d.ts.map +1 -1
- package/dist/connector-tools.js +48 -2
- package/dist/connector-tools.js.map +1 -1
- package/dist/documents/tools.d.ts.map +1 -1
- package/dist/documents/tools.js +3 -3
- package/dist/documents/tools.js.map +1 -1
- package/dist/introspection-open.d.ts +2 -1
- package/dist/introspection-open.d.ts.map +1 -1
- package/dist/introspection-open.js +14 -6
- package/dist/introspection-open.js.map +1 -1
- package/dist/issues/index.d.ts +7 -0
- package/dist/issues/index.d.ts.map +1 -0
- package/dist/issues/index.js +4 -0
- package/dist/issues/index.js.map +1 -0
- package/dist/issues/module.d.ts +38 -0
- package/dist/issues/module.d.ts.map +1 -0
- package/dist/issues/module.js +114 -0
- package/dist/issues/module.js.map +1 -0
- package/dist/issues/tool.d.ts +95 -0
- package/dist/issues/tool.d.ts.map +1 -0
- package/dist/issues/tool.js +479 -0
- package/dist/issues/tool.js.map +1 -0
- package/dist/issues/types.d.ts +280 -0
- package/dist/issues/types.d.ts.map +1 -0
- package/dist/issues/types.js +79 -0
- package/dist/issues/types.js.map +1 -0
- package/dist/mcp/cli/command-context.d.ts +20 -1
- package/dist/mcp/cli/command-context.d.ts.map +1 -1
- package/dist/mcp/cli/command-context.js.map +1 -1
- package/dist/mcp/cli/core.d.ts +0 -2
- package/dist/mcp/cli/core.d.ts.map +1 -1
- package/dist/mcp/cli/core.js +9 -33
- package/dist/mcp/cli/core.js.map +1 -1
- package/dist/mcp/cli/handshake-retry.d.ts +5 -0
- package/dist/mcp/cli/handshake-retry.d.ts.map +1 -0
- package/dist/mcp/cli/handshake-retry.js +32 -0
- package/dist/mcp/cli/handshake-retry.js.map +1 -0
- package/dist/mcp/daemon/index.js +3 -4
- package/dist/mcp/daemon/index.js.map +1 -1
- package/dist/mcp/pi-client.d.ts +2 -0
- package/dist/mcp/pi-client.d.ts.map +1 -1
- package/dist/mcp/pi-client.js +5 -1
- package/dist/mcp/pi-client.js.map +1 -1
- package/dist/mcp/pi-mcp-runtime.d.ts +25 -0
- package/dist/mcp/pi-mcp-runtime.d.ts.map +1 -0
- package/dist/mcp/pi-mcp-runtime.js +215 -0
- package/dist/mcp/pi-mcp-runtime.js.map +1 -0
- package/dist/mcp/pi-runtime.d.ts +7 -0
- package/dist/mcp/pi-runtime.d.ts.map +1 -0
- package/dist/mcp/pi-runtime.js +26 -0
- package/dist/mcp/pi-runtime.js.map +1 -0
- package/dist/mcp-chunks/chunk-3UVHZECT.js +31 -0
- package/dist/mcp-chunks/{chunk-PO2SOBEN.js → chunk-CGJ2XOSF.js} +43 -35
- package/dist/mcp-chunks/{chunk-GTETFUPQ.js → chunk-IMG2JMBS.js} +8 -8
- package/dist/mcp-chunks/{chunk-UFV6SVQG.js → chunk-LQKMNWDE.js} +2 -2
- package/dist/mcp-chunks/{chunk-S2F7DDP5.js → chunk-QUDOU7MQ.js} +1 -1
- package/dist/mcp-chunks/{cli-IYD7Y7MO.js → cli-BM23ZXPJ.js} +54 -54
- package/dist/mcp-chunks/{client-5MNBV3Z7.js → client-RKTAKDAY.js} +7 -7
- package/dist/mcp-chunks/{daemon-command-V3B3EMXD.js → daemon-command-VU6WTFCJ.js} +8 -8
- package/dist/mcp-chunks/{generate-cli-runner-PW5WJ7KI.js → generate-cli-runner-JAAPSWGX.js} +12 -12
- package/dist/mcp-chunks/{generated-daemon-runtime-3C4NWGAU.js → generated-daemon-runtime-LX4L2X7Z.js} +8 -8
- package/dist/mcp-chunks/pi-mcp-runtime-GHDEPXUL.js +1231 -0
- package/dist/mcp-chunks/{runtime-RMI3XCYJ.js → runtime-T63YI7TC.js} +6 -6
- package/dist/mcp-chunks/{serve-command-UF5SVREV.js → serve-command-75P4VBJ6.js} +7 -7
- package/dist/mcp-daemon.js +21 -19
- package/dist/mcp-run-worker.js +11 -10
- package/dist/open.d.ts +6 -0
- package/dist/open.d.ts.map +1 -1
- package/dist/open.js +9 -1
- package/dist/open.js.map +1 -1
- package/dist/pi-extension.d.ts +3 -0
- package/dist/pi-extension.d.ts.map +1 -1
- package/dist/pi-extension.js +82 -18
- package/dist/pi-extension.js.map +1 -1
- package/dist/productivity/arguments.d.ts +298 -0
- package/dist/productivity/arguments.d.ts.map +1 -0
- package/dist/productivity/arguments.generated.d.ts +28 -0
- package/dist/productivity/arguments.generated.d.ts.map +1 -0
- package/dist/productivity/arguments.generated.js +489 -0
- package/dist/productivity/arguments.generated.js.map +1 -0
- package/dist/productivity/arguments.js +10 -0
- package/dist/productivity/arguments.js.map +1 -0
- package/dist/productivity/http.d.ts.map +1 -1
- package/dist/productivity/http.js +4 -1
- package/dist/productivity/http.js.map +1 -1
- package/dist/productivity/index.d.ts +1 -1
- package/dist/productivity/index.d.ts.map +1 -1
- package/dist/productivity/index.js +1 -1
- package/dist/productivity/index.js.map +1 -1
- package/dist/productivity/module.d.ts +15 -2
- package/dist/productivity/module.d.ts.map +1 -1
- package/dist/productivity/module.js +24 -19
- package/dist/productivity/module.js.map +1 -1
- package/dist/productivity/tools.d.ts +6 -0
- package/dist/productivity/tools.d.ts.map +1 -1
- package/dist/productivity/tools.js +64 -224
- package/dist/productivity/tools.js.map +1 -1
- package/dist/productivity/types.d.ts +2 -0
- package/dist/productivity/types.d.ts.map +1 -1
- package/dist/productivity/types.js.map +1 -1
- package/dist/recipe/agent.d.ts +40 -10
- package/dist/recipe/agent.d.ts.map +1 -1
- package/dist/recipe/agent.js +209 -30
- package/dist/recipe/agent.js.map +1 -1
- package/dist/recipe/companions.js +1 -1
- package/dist/recipe/manifest.generated.d.ts +3 -1
- package/dist/recipe/manifest.generated.d.ts.map +1 -1
- package/dist/recipe/manifest.generated.js +3 -1
- package/dist/recipe/manifest.generated.js.map +1 -1
- package/dist/recipe/package.d.ts +28 -3
- package/dist/recipe/package.d.ts.map +1 -1
- package/dist/recipe/package.js +155 -1
- package/dist/recipe/package.js.map +1 -1
- package/dist/recipe/providers.d.ts +62 -0
- package/dist/recipe/providers.d.ts.map +1 -0
- package/dist/recipe/providers.js +95 -0
- package/dist/recipe/providers.js.map +1 -0
- package/dist/recipe/resolve.d.ts +7 -3
- package/dist/recipe/resolve.d.ts.map +1 -1
- package/dist/recipe/resolve.js +7 -2
- package/dist/recipe/resolve.js.map +1 -1
- package/dist/run-controller.d.ts +6 -0
- package/dist/run-controller.d.ts.map +1 -1
- package/dist/run-controller.js +2 -0
- package/dist/run-controller.js.map +1 -1
- package/dist/search/index.d.ts +2 -1
- package/dist/search/index.d.ts.map +1 -1
- package/dist/search/index.js +1 -1
- package/dist/search/index.js.map +1 -1
- package/dist/search/module.d.ts +19 -7
- package/dist/search/module.d.ts.map +1 -1
- package/dist/search/module.js +38 -16
- package/dist/search/module.js.map +1 -1
- package/dist/search/tool.d.ts +6 -1
- package/dist/search/tool.d.ts.map +1 -1
- package/dist/search/tool.js +22 -9
- package/dist/search/tool.js.map +1 -1
- package/dist/search/types.d.ts +13 -3
- package/dist/search/types.d.ts.map +1 -1
- package/dist/search/types.js +4 -1
- package/dist/search/types.js.map +1 -1
- package/dist/session.d.ts +21 -1
- package/dist/session.d.ts.map +1 -1
- package/dist/session.js +132 -43
- package/dist/session.js.map +1 -1
- package/dist/test-utils.d.ts +2 -0
- package/dist/test-utils.d.ts.map +1 -1
- package/dist/test-utils.js +3 -1
- package/dist/test-utils.js.map +1 -1
- package/dist/tool-search.d.ts +9 -0
- package/dist/tool-search.d.ts.map +1 -1
- package/dist/tool-search.js +23 -0
- package/dist/tool-search.js.map +1 -1
- package/dist/tools/bridge.d.ts +44 -0
- package/dist/tools/bridge.d.ts.map +1 -0
- package/dist/tools/bridge.js +106 -0
- package/dist/tools/bridge.js.map +1 -0
- package/dist/tools/cli.d.ts +20 -0
- package/dist/tools/cli.d.ts.map +1 -0
- package/dist/tools/cli.js +246 -0
- package/dist/tools/cli.js.map +1 -0
- package/dist/tools/entry.d.ts +2 -0
- package/dist/tools/entry.d.ts.map +1 -0
- package/dist/tools/entry.js +3 -0
- package/dist/tools/entry.js.map +1 -0
- package/dist/tools/shell.d.ts +12 -0
- package/dist/tools/shell.d.ts.map +1 -0
- package/dist/tools/shell.js +50 -0
- package/dist/tools/shell.js.map +1 -0
- package/dist/tuning/tpe.d.ts +112 -0
- package/dist/tuning/tpe.d.ts.map +1 -0
- package/dist/tuning/tpe.js +286 -0
- package/dist/tuning/tpe.js.map +1 -0
- package/docs/README.md +3 -1
- package/docs/channels/README.md +10 -0
- package/docs/documents/README.md +20 -19
- package/docs/host-api.md +10 -0
- package/docs/interactions.md +6 -6
- package/docs/issues/README.md +183 -0
- package/docs/mcp-configuration.md +65 -1
- package/docs/pi-extension.md +5 -0
- package/docs/productivity/README.md +8 -3
- package/docs/providers.md +321 -0
- package/docs/recipe-format.md +103 -32
- package/docs/search/README.md +37 -20
- package/package.json +28 -10
- package/skills/documents/SKILL.md +2 -1
- package/dist/mcp-chunks/{auth-command-M7TQE3AL.js → auth-command-UYFOGGQR.js} +6 -6
- package/dist/mcp-chunks/{call-command-7LD7UEFK.js → call-command-6U5BNDR7.js} +17 -17
- package/dist/mcp-chunks/{chunk-PSE442BC.js → chunk-36D4FILJ.js} +26 -26
- package/dist/mcp-chunks/{config-command-6DXILFNO.js → config-command-ZSPJI34E.js} +10 -10
- package/dist/mcp-chunks/{emit-ts-command-NDCDFDRM.js → emit-ts-command-SY4LQE4S.js} +3 -3
- package/dist/mcp-chunks/{inspect-cli-command-4MGF5CPP.js → inspect-cli-command-JPX4ON6N.js} +4 -4
- package/dist/mcp-chunks/{resource-command-SRFQQROJ.js → resource-command-DUY4SVE5.js} +4 -4
|
@@ -0,0 +1,286 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tree-structured Parzen Estimator (TPE): a small Bayesian optimizer for
|
|
3
|
+
* black-box searches such as hyperparameters or a Recipe's settings, the
|
|
4
|
+
* algorithm Hyperopt and Optuna use by default (Bergstra et al., 2011).
|
|
5
|
+
*
|
|
6
|
+
* Each parameter is modelled on its own. After the random startup trials,
|
|
7
|
+
* the trials told so far are split into the best `gamma(n)` and the rest; a
|
|
8
|
+
* Parzen estimator is fitted to each group, `l(x)` to the good and `g(x)` to
|
|
9
|
+
* the bad, and the candidate drawn from `l` with the highest `l(x) / g(x)` is
|
|
10
|
+
* asked next. Numbers use a mixture of truncated Gaussians, on a log scale
|
|
11
|
+
* when `log` is set; choices use smoothed, weighted counts.
|
|
12
|
+
*
|
|
13
|
+
* ```ts
|
|
14
|
+
* const sampler = new TpeSampler({
|
|
15
|
+
* lr: float(1e-5, 1e-1, { log: true }),
|
|
16
|
+
* layers: int(1, 8),
|
|
17
|
+
* optimizer: choice(["adam", "sgd"]),
|
|
18
|
+
* });
|
|
19
|
+
* for (let i = 0; i < 50; i++) {
|
|
20
|
+
* const config = sampler.ask();
|
|
21
|
+
* sampler.tell(config, await evaluate(config));
|
|
22
|
+
* }
|
|
23
|
+
* sampler.best; // { config, value }
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
/** A number in `[low, high]`; `log` samples it on a log scale. */
|
|
27
|
+
export function float(low, high, options = {}) {
|
|
28
|
+
checkRange(low, high, options.log ?? false);
|
|
29
|
+
return { type: "float", low, high, log: options.log ?? false };
|
|
30
|
+
}
|
|
31
|
+
/** An integer in `[low, high]`, both included. */
|
|
32
|
+
export function int(low, high, options = {}) {
|
|
33
|
+
if (!Number.isInteger(low) || !Number.isInteger(high))
|
|
34
|
+
throw new RangeError(`int bounds must be integers: ${low}, ${high}`);
|
|
35
|
+
checkRange(low, high, options.log ?? false);
|
|
36
|
+
return { type: "int", low, high, log: options.log ?? false };
|
|
37
|
+
}
|
|
38
|
+
/** One of `choices`, compared by identity. */
|
|
39
|
+
export function choice(choices) {
|
|
40
|
+
if (choices.length === 0)
|
|
41
|
+
throw new RangeError("choice needs at least one option");
|
|
42
|
+
return { type: "choice", choices };
|
|
43
|
+
}
|
|
44
|
+
function checkRange(low, high, log) {
|
|
45
|
+
if (!(Number.isFinite(low) && Number.isFinite(high) && low <= high))
|
|
46
|
+
throw new RangeError(`invalid range: [${low}, ${high}]`);
|
|
47
|
+
if (log && low <= 0)
|
|
48
|
+
throw new RangeError(`a log range must be positive: [${low}, ${high}]`);
|
|
49
|
+
}
|
|
50
|
+
export class TpeSampler {
|
|
51
|
+
trials = [];
|
|
52
|
+
random;
|
|
53
|
+
sign;
|
|
54
|
+
startupTrials;
|
|
55
|
+
candidates;
|
|
56
|
+
gamma;
|
|
57
|
+
priorWeight;
|
|
58
|
+
space;
|
|
59
|
+
// A plain field, not a parameter property, so Node can strip the types and
|
|
60
|
+
// run this file as it is.
|
|
61
|
+
constructor(space, options = {}) {
|
|
62
|
+
this.space = space;
|
|
63
|
+
this.random = mulberry32(options.seed ?? 0);
|
|
64
|
+
this.sign = options.direction === "maximize" ? -1 : 1;
|
|
65
|
+
this.startupTrials = options.startupTrials ?? 10;
|
|
66
|
+
this.candidates = options.candidates ?? 24;
|
|
67
|
+
this.gamma = options.gamma ?? ((n) => Math.min(Math.ceil(0.1 * n), 25));
|
|
68
|
+
this.priorWeight = options.priorWeight ?? 1;
|
|
69
|
+
}
|
|
70
|
+
/** The next configuration to evaluate. */
|
|
71
|
+
ask() {
|
|
72
|
+
const config = {};
|
|
73
|
+
const told = this.trials.length;
|
|
74
|
+
if (told < this.startupTrials) {
|
|
75
|
+
for (const [name, param] of Object.entries(this.space))
|
|
76
|
+
config[name] = this.sampleRandom(param);
|
|
77
|
+
return config;
|
|
78
|
+
}
|
|
79
|
+
// Lower is better internally; a value that isn't finite (a failed trial)
|
|
80
|
+
// sorts last and is never in the good group.
|
|
81
|
+
const ranked = this.trials
|
|
82
|
+
.map((trial) => ({ config: trial.config, loss: this.loss(trial.value) }))
|
|
83
|
+
.sort((a, b) => a.loss - b.loss);
|
|
84
|
+
const finite = ranked.filter((t) => Number.isFinite(t.loss)).length;
|
|
85
|
+
if (finite === 0) {
|
|
86
|
+
for (const [name, param] of Object.entries(this.space))
|
|
87
|
+
config[name] = this.sampleRandom(param);
|
|
88
|
+
return config;
|
|
89
|
+
}
|
|
90
|
+
const nGood = Math.max(1, Math.min(finite, told - 1, this.gamma(told)));
|
|
91
|
+
const good = ranked.slice(0, nGood).map((t) => t.config);
|
|
92
|
+
const bad = ranked.slice(nGood).map((t) => t.config);
|
|
93
|
+
for (const [name, param] of Object.entries(this.space)) {
|
|
94
|
+
const below = good.map((c) => c[name]);
|
|
95
|
+
const above = bad.map((c) => c[name]);
|
|
96
|
+
config[name] =
|
|
97
|
+
param.type === "choice"
|
|
98
|
+
? this.sampleChoice(param, below, above)
|
|
99
|
+
: this.sampleNumber(param, below, above);
|
|
100
|
+
}
|
|
101
|
+
return config;
|
|
102
|
+
}
|
|
103
|
+
/** Records what `config` scored. `NaN` or `±Infinity` marks a failure. */
|
|
104
|
+
tell(config, value) {
|
|
105
|
+
this.trials.push({ config, value });
|
|
106
|
+
}
|
|
107
|
+
/** The best trial told so far, ignoring failures. */
|
|
108
|
+
get best() {
|
|
109
|
+
let best;
|
|
110
|
+
for (const trial of this.trials) {
|
|
111
|
+
if (!Number.isFinite(trial.value))
|
|
112
|
+
continue;
|
|
113
|
+
if (!best || this.sign * trial.value < this.sign * best.value)
|
|
114
|
+
best = trial;
|
|
115
|
+
}
|
|
116
|
+
return best;
|
|
117
|
+
}
|
|
118
|
+
loss(value) {
|
|
119
|
+
return Number.isFinite(value) ? this.sign * value : Infinity;
|
|
120
|
+
}
|
|
121
|
+
sampleRandom(param) {
|
|
122
|
+
if (param.type === "choice")
|
|
123
|
+
return param.choices[Math.floor(this.random() * param.choices.length)];
|
|
124
|
+
const [low, high] = internalBounds(param);
|
|
125
|
+
return fromInternal(param, low + this.random() * (high - low));
|
|
126
|
+
}
|
|
127
|
+
sampleNumber(param, below, above) {
|
|
128
|
+
const [low, high] = internalBounds(param);
|
|
129
|
+
if (low === high)
|
|
130
|
+
return fromInternal(param, low);
|
|
131
|
+
const l = this.parzen(below.map((v) => toInternal(param, v)), low, high);
|
|
132
|
+
const g = this.parzen(above.map((v) => toInternal(param, v)), low, high);
|
|
133
|
+
let bestX = low;
|
|
134
|
+
let bestScore = -Infinity;
|
|
135
|
+
for (let i = 0; i < this.candidates; i++) {
|
|
136
|
+
const x = sampleMixture(l, low, high, this.random);
|
|
137
|
+
const score = mixtureLogPdf(l, x, low, high) - mixtureLogPdf(g, x, low, high);
|
|
138
|
+
if (score > bestScore)
|
|
139
|
+
[bestX, bestScore] = [x, score];
|
|
140
|
+
}
|
|
141
|
+
return fromInternal(param, bestX);
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* Hyperopt's adaptive Parzen estimator: one Gaussian per observation plus
|
|
145
|
+
* a prior over the whole range, each as wide as the larger gap to its
|
|
146
|
+
* neighbours, clipped to `[range / min(100, n + 1), range]`.
|
|
147
|
+
*/
|
|
148
|
+
parzen(observed, low, high) {
|
|
149
|
+
const range = high - low;
|
|
150
|
+
const prior = {
|
|
151
|
+
mu: (low + high) / 2,
|
|
152
|
+
sigma: range,
|
|
153
|
+
weight: this.priorWeight,
|
|
154
|
+
};
|
|
155
|
+
const components = [
|
|
156
|
+
...observed.map((mu) => ({ mu, sigma: 0, weight: 1 })),
|
|
157
|
+
prior,
|
|
158
|
+
].sort((a, b) => a.mu - b.mu);
|
|
159
|
+
const minSigma = range / Math.min(100, components.length);
|
|
160
|
+
for (let i = 0; i < components.length; i++) {
|
|
161
|
+
const component = components[i];
|
|
162
|
+
if (component === prior)
|
|
163
|
+
continue;
|
|
164
|
+
const left = component.mu - (components[i - 1]?.mu ?? low);
|
|
165
|
+
const right = (components[i + 1]?.mu ?? high) - component.mu;
|
|
166
|
+
component.sigma = Math.min(range, Math.max(minSigma, left, right));
|
|
167
|
+
}
|
|
168
|
+
const total = components.reduce((sum, c) => sum + c.weight, 0);
|
|
169
|
+
for (const component of components)
|
|
170
|
+
component.weight /= total;
|
|
171
|
+
return components;
|
|
172
|
+
}
|
|
173
|
+
sampleChoice(param, below, above) {
|
|
174
|
+
const l = this.choiceWeights(param, below);
|
|
175
|
+
const g = this.choiceWeights(param, above);
|
|
176
|
+
let best = 0;
|
|
177
|
+
let bestScore = -Infinity;
|
|
178
|
+
for (let i = 0; i < this.candidates; i++) {
|
|
179
|
+
const index = pickWeighted(l, this.random);
|
|
180
|
+
const score = Math.log(l[index]) - Math.log(g[index]);
|
|
181
|
+
if (score > bestScore)
|
|
182
|
+
[best, bestScore] = [index, score];
|
|
183
|
+
}
|
|
184
|
+
return param.choices[best];
|
|
185
|
+
}
|
|
186
|
+
/** Each choice's probability: its count plus a share of the prior. */
|
|
187
|
+
choiceWeights(param, observed) {
|
|
188
|
+
const k = param.choices.length;
|
|
189
|
+
const counts = param.choices.map(() => this.priorWeight / k);
|
|
190
|
+
for (const value of observed) {
|
|
191
|
+
const index = param.choices.indexOf(value);
|
|
192
|
+
if (index >= 0)
|
|
193
|
+
counts[index] += 1;
|
|
194
|
+
}
|
|
195
|
+
const total = counts.reduce((sum, c) => sum + c, 0);
|
|
196
|
+
return counts.map((c) => c / total);
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
/** Runs `trials` evaluations of `objective` one after another. */
|
|
200
|
+
export async function optimize(space, objective, options) {
|
|
201
|
+
const sampler = new TpeSampler(space, options);
|
|
202
|
+
for (let i = 0; i < options.trials; i++) {
|
|
203
|
+
const config = sampler.ask();
|
|
204
|
+
sampler.tell(config, await objective(config));
|
|
205
|
+
}
|
|
206
|
+
return { best: sampler.best, trials: sampler.trials };
|
|
207
|
+
}
|
|
208
|
+
// Internal space: log-scaled when `log`; an int widened by half a step each
|
|
209
|
+
// side so both ends are as likely as the values between.
|
|
210
|
+
function internalBounds(param) {
|
|
211
|
+
const pad = param.type === "int" ? 0.5 : 0;
|
|
212
|
+
const low = param.low - pad;
|
|
213
|
+
const high = param.high + pad;
|
|
214
|
+
// A log int's lower bound stays positive: `int(1, 8, { log: true })` → [0.5, 8.5].
|
|
215
|
+
return param.log ? [Math.log(low), Math.log(high)] : [low, high];
|
|
216
|
+
}
|
|
217
|
+
function toInternal(param, value) {
|
|
218
|
+
return param.log ? Math.log(value) : value;
|
|
219
|
+
}
|
|
220
|
+
function fromInternal(param, x) {
|
|
221
|
+
const value = param.log ? Math.exp(x) : x;
|
|
222
|
+
const clamped = Math.min(param.high, Math.max(param.low, value));
|
|
223
|
+
return param.type === "int" ? Math.round(clamped) : clamped;
|
|
224
|
+
}
|
|
225
|
+
function mixtureLogPdf(mixture, x, low, high) {
|
|
226
|
+
let density = 0;
|
|
227
|
+
for (const { mu, sigma, weight } of mixture) {
|
|
228
|
+
const mass = normalCdf((high - mu) / sigma) - normalCdf((low - mu) / sigma);
|
|
229
|
+
const z = (x - mu) / sigma;
|
|
230
|
+
density +=
|
|
231
|
+
(weight * Math.exp(-0.5 * z * z)) /
|
|
232
|
+
(sigma * Math.sqrt(2 * Math.PI) * Math.max(mass, 1e-12));
|
|
233
|
+
}
|
|
234
|
+
return Math.log(Math.max(density, Number.MIN_VALUE));
|
|
235
|
+
}
|
|
236
|
+
/**
|
|
237
|
+
* A draw from the mixture truncated to `[low, high]`. Each component's mean
|
|
238
|
+
* is inside the range and its width at most the range, so rejection accepts
|
|
239
|
+
* at least a third of draws; the clamp is only a backstop.
|
|
240
|
+
*/
|
|
241
|
+
function sampleMixture(mixture, low, high, random) {
|
|
242
|
+
const { mu, sigma } = mixture[pickWeighted(mixture.map((c) => c.weight), random)];
|
|
243
|
+
for (let attempt = 0; attempt < 100; attempt++) {
|
|
244
|
+
const x = mu + sigma * standardNormal(random);
|
|
245
|
+
if (x >= low && x <= high)
|
|
246
|
+
return x;
|
|
247
|
+
}
|
|
248
|
+
return Math.min(high, Math.max(low, mu));
|
|
249
|
+
}
|
|
250
|
+
function pickWeighted(weights, random) {
|
|
251
|
+
let r = random() * weights.reduce((sum, w) => sum + w, 0);
|
|
252
|
+
for (let i = 0; i < weights.length; i++) {
|
|
253
|
+
r -= weights[i];
|
|
254
|
+
if (r < 0)
|
|
255
|
+
return i;
|
|
256
|
+
}
|
|
257
|
+
return weights.length - 1;
|
|
258
|
+
}
|
|
259
|
+
function standardNormal(random) {
|
|
260
|
+
// Box–Muller; `1 - random()` keeps the log's argument above zero.
|
|
261
|
+
return (Math.sqrt(-2 * Math.log(1 - random())) * Math.cos(2 * Math.PI * random()));
|
|
262
|
+
}
|
|
263
|
+
/** Φ(z), via Abramowitz and Stegun 7.1.26 (absolute error below 1.5e-7). */
|
|
264
|
+
function normalCdf(z) {
|
|
265
|
+
const x = Math.abs(z) / Math.SQRT2;
|
|
266
|
+
const t = 1 / (1 + 0.3275911 * x);
|
|
267
|
+
const poly = t *
|
|
268
|
+
(0.254829592 +
|
|
269
|
+
t *
|
|
270
|
+
(-0.284496736 +
|
|
271
|
+
t * (1.421413741 + t * (-1.453152027 + t * 1.061405429))));
|
|
272
|
+
const erf = 1 - poly * Math.exp(-x * x);
|
|
273
|
+
return z >= 0 ? 0.5 * (1 + erf) : 0.5 * (1 - erf);
|
|
274
|
+
}
|
|
275
|
+
/** A small, fast, seedable PRNG; returns floats in `[0, 1)`. */
|
|
276
|
+
function mulberry32(seed) {
|
|
277
|
+
let state = seed >>> 0;
|
|
278
|
+
return () => {
|
|
279
|
+
state = (state + 0x6d2b79f5) >>> 0;
|
|
280
|
+
let t = state;
|
|
281
|
+
t = Math.imul(t ^ (t >>> 15), t | 1);
|
|
282
|
+
t ^= t + Math.imul(t ^ (t >>> 7), t | 61);
|
|
283
|
+
return ((t ^ (t >>> 14)) >>> 0) / 4294967296;
|
|
284
|
+
};
|
|
285
|
+
}
|
|
286
|
+
//# sourceMappingURL=tpe.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tpe.js","sourceRoot":"","sources":["../../src/tuning/tpe.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAiDH,kEAAkE;AAClE,MAAM,UAAU,KAAK,CACnB,GAAW,EACX,IAAY,EACZ,OAAO,GAAsB,EAAE;IAE/B,UAAU,CAAC,GAAG,EAAE,IAAI,EAAE,OAAO,CAAC,GAAG,IAAI,KAAK,CAAC,CAAC;IAC5C,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG,EAAE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AK,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,GAAG,UAAU,CAAC;IAC/C,CAAC,CAAC;AACJ,CAAC"}
|
package/docs/README.md
CHANGED
|
@@ -24,9 +24,11 @@ at run time.
|
|
|
24
24
|
| Declare capability policy and bindings | [MCP configuration](mcp-configuration.md) |
|
|
25
25
|
| Answer a chat message from a Recipe | [Channel tools](channels/README.md) |
|
|
26
26
|
| Add Slack tools to a Recipe | [Slack channel connector](channels/slack.md) |
|
|
27
|
-
| Read and mark up Word and
|
|
27
|
+
| Read and mark up Word, PDF and HTML files from a Recipe | [Document tools](documents/README.md) |
|
|
28
28
|
| Work with a person's mail, calendar and files | [Productivity tools](productivity/README.md) |
|
|
29
29
|
| Search the web from a Recipe | [Web search](search/README.md) |
|
|
30
|
+
| Track work in Linear, Jira or Introspection | [Issues tool](issues/README.md) |
|
|
31
|
+
| Bring a provider for search, productivity or issues | [Provider modules](providers.md) |
|
|
30
32
|
| Define portable evaluation judges | [Recipe judges](recipe-judges.md) |
|
|
31
33
|
|
|
32
34
|
## Boundary
|
package/docs/channels/README.md
CHANGED
|
@@ -270,6 +270,7 @@ const capabilities = {
|
|
|
270
270
|
react: false, edit: true, retract: true, read: false,
|
|
271
271
|
attach: false, fetchFile: false,
|
|
272
272
|
documents: false, resolveAuthors: true, permalinks: false,
|
|
273
|
+
hosts: ["api.my-channel.example"],
|
|
273
274
|
};
|
|
274
275
|
|
|
275
276
|
class MyAdapter implements ChannelAdapter {
|
|
@@ -314,6 +315,15 @@ their own API fields and do not define provider-specific origin types.
|
|
|
314
315
|
Registration checks that the adapter implements every method its capabilities
|
|
315
316
|
claim, so a descriptor cannot promise a tool the adapter does not have.
|
|
316
317
|
|
|
318
|
+
`hosts` lists every host the adapter sends to; only a declared host can be
|
|
319
|
+
rebound by `.pi/api.local.json` (see
|
|
320
|
+
[Bind a provider's API host](../mcp-configuration.md#bind-a-providers-api-host)).
|
|
321
|
+
`createSession` also receives `isApiBound(url)`: a request to a bound host
|
|
322
|
+
goes to a fake or local server rather than through the egress, so the adapter
|
|
323
|
+
sends it without a credential instead of refusing for want of an egress.
|
|
324
|
+
Read `globalThis.fetch` per call rather than capturing it, so the binding
|
|
325
|
+
applies.
|
|
326
|
+
|
|
317
327
|
The host turns the descriptor into an ordinary `RecipeConnectorModule` with
|
|
318
328
|
`createChannelConnectorModule`, which a package may still call itself if it
|
|
319
329
|
depends on Recipes. Manifest validation and agent
|
package/docs/documents/README.md
CHANGED
|
@@ -35,8 +35,8 @@ tools: [documents]
|
|
|
35
35
|
```
|
|
36
36
|
|
|
37
37
|
Each declaration names a format, served by the package
|
|
38
|
-
`@introspection-ai/recipe-documents-<format>`. Recipes installs the docx
|
|
39
|
-
pdf packages alongside itself (they are `optionalDependencies` of
|
|
38
|
+
`@introspection-ai/recipe-documents-<format>`. Recipes installs the docx,
|
|
39
|
+
pdf and html packages alongside itself (they are `optionalDependencies` of
|
|
40
40
|
`@introspection-ai/recipes`), so a Recipe that does not list them uses the
|
|
41
41
|
copy beside the running Recipes, Python environment and profiles included.
|
|
42
42
|
Declare it in `peerDependencies` by default, which says so explicitly: the
|
|
@@ -200,13 +200,13 @@ doesn't ship fails when the Recipe loads, with the names it does ship.
|
|
|
200
200
|
|
|
201
201
|
| Command (`documents` + `command`) | Arguments | Requires |
|
|
202
202
|
| --- | --- | --- |
|
|
203
|
-
| `read` | `path`, `offset?`, `budget?`, `pages?`, `tables?` | always |
|
|
204
|
-
| `revise` | `path`, `output?`, `author`, `revisions[]` (`paragraph`, `text`, `rationale`) | `revise` |
|
|
205
|
-
| `propose_edits` | `path`, `output?`, `author`, `edits[]` | `proposeEdits` |
|
|
206
|
-
| `comment` | `path`, `output?`, `author`, `text`, and `quote` (`paragraph?`, `near?`, `occurrence?`) or `thread` | `comment` |
|
|
207
|
-
| `respond` | `path`, `output?`, `author`, `responses[]` | `respond` |
|
|
208
|
-
| `remove_section` | `path`, `output?`, `author`, `from`, `through`, `keep?`, `rationale` | `removeSection` |
|
|
209
|
-
| `render` | `path`, `pages?` | `render` |
|
|
203
|
+
| `read` | `path`, `offset?`, `budget?`, `pages?`, `tables?` | always | The page as markdown (`.html`, `.htm`; an `.svg` file is one chart): headings, lists and GFM tables, scripts and styles dropped, each chart (an outermost `<figure>` or `<svg>`) a `[chart N: label]` line. Paged by character. |
|
|
204
|
+
| `revise` | `path`, `output?`, `author`, `revisions[]` (`paragraph`, `text`, `rationale`) | `revise` | not registered |
|
|
205
|
+
| `propose_edits` | `path`, `output?`, `author`, `edits[]` | `proposeEdits` | not registered |
|
|
206
|
+
| `comment` | `path`, `output?`, `author`, `text`, and `quote` (`paragraph?`, `near?`, `occurrence?`) or `thread` | `comment` | not registered |
|
|
207
|
+
| `respond` | `path`, `output?`, `author`, `responses[]` | `respond` | not registered |
|
|
208
|
+
| `remove_section` | `path`, `output?`, `author`, `from`, `through`, `keep?`, `rationale` | `removeSection` | not registered |
|
|
209
|
+
| `render` | `path`, `pages?` | `render` | With a browser, the full page light and dark and each chart as its own element screenshot, at 2x; without one, each inline `<svg>` chart through resvg, naming what it could not draw. `pages` picks charts. |
|
|
210
210
|
|
|
211
211
|
An edit is `{ op: "replace" | "delete" | "insert_after", quote, paragraph?,
|
|
212
212
|
near?, occurrence?, new?, rationale }`. A response is `{ action: "accept" |
|
|
@@ -219,15 +219,15 @@ candidate paragraphs. It never returns the whole document; `read` does that.
|
|
|
219
219
|
|
|
220
220
|
## What each format registers
|
|
221
221
|
|
|
222
|
-
| Command | docx (`@introspection-ai/recipe-documents-docx`) | PDF (`@introspection-ai/recipe-documents-pdf`) |
|
|
223
|
-
| --- | --- | --- |
|
|
224
|
-
| `read` | Paragraphs with stable ids (`p-031`, `p-012.r2c3` in tables) and their current text, Word's list numbers, a `markup:` line with tracked changes and comments by author, then numbered changes and comment threads. Paged by paragraph. | The path used (text, tables or page images), then pypdfium2's text page by page in reading order, filled form fields and page comments. `tables: true` adds table cells with the `tables` extra. Pages with no text layer are named, to render. Paged by character. |
|
|
225
|
-
| `revise` | Each paragraph's revised text: on a file with no pending changes, untracked edits on a working copy and paper-docx `compare(granularity="word")` build the redline; if compare refuses the batch, or the file already has changes, the same word-level changes go in as targeted tracked edits. The rationale is a comment on the changed text. | not registered |
|
|
226
|
-
| `propose_edits` | Tracked changes signed by `author`, each with its rationale as a comment, saved with `patch_save` | not registered |
|
|
227
|
-
| `comment` | New comment on a quote, or a reply under a thread's first comment | not registered |
|
|
228
|
-
| `respond` | Accept or reject by change number (tracked moves resolve as a pair), reply, or counter | not registered |
|
|
229
|
-
| `remove_section` | Strikes the paragraphs, leaves `Reserved.` after `keep`, keeps numbering | not registered |
|
|
230
|
-
| `render` | not registered | PNG files of pages, at most 10 per call; returns their paths for Pi's `read` tool |
|
|
222
|
+
| Command | docx (`@introspection-ai/recipe-documents-docx`) | PDF (`@introspection-ai/recipe-documents-pdf`) | HTML (`@introspection-ai/recipe-documents-html`) |
|
|
223
|
+
| --- | --- | --- | --- |
|
|
224
|
+
| `read` | Paragraphs with stable ids (`p-031`, `p-012.r2c3` in tables) and their current text, Word's list numbers, a `markup:` line with tracked changes and comments by author, then numbered changes and comment threads. Paged by paragraph. | The path used (text, tables or page images), then pypdfium2's text page by page in reading order, filled form fields and page comments. `tables: true` adds table cells with the `tables` extra. Pages with no text layer are named, to render. Paged by character. | The page as markdown (`.html`, `.htm`; an `.svg` file is one chart): headings, lists and GFM tables, scripts and styles dropped, each chart (an outermost `<figure>` or `<svg>`) a `[chart N: label]` line. Paged by character. |
|
|
225
|
+
| `revise` | Each paragraph's revised text: on a file with no pending changes, untracked edits on a working copy and paper-docx `compare(granularity="word")` build the redline; if compare refuses the batch, or the file already has changes, the same word-level changes go in as targeted tracked edits. The rationale is a comment on the changed text. | not registered | not registered |
|
|
226
|
+
| `propose_edits` | Tracked changes signed by `author`, each with its rationale as a comment, saved with `patch_save` | not registered | not registered |
|
|
227
|
+
| `comment` | New comment on a quote, or a reply under a thread's first comment | not registered | not registered |
|
|
228
|
+
| `respond` | Accept or reject by change number (tracked moves resolve as a pair), reply, or counter | not registered | not registered |
|
|
229
|
+
| `remove_section` | Strikes the paragraphs, leaves `Reserved.` after `keep`, keeps numbering | not registered | not registered |
|
|
230
|
+
| `render` | not registered | PNG files of pages, at most 10 per call; returns their paths for Pi's `read` tool | With a browser, the full page light and dark and each chart as its own element screenshot, at 2x; without one, each inline `<svg>` chart through resvg, naming what it could not draw. `pages` picks charts. |
|
|
231
231
|
|
|
232
232
|
### docx: revise or propose_edits
|
|
233
233
|
|
|
@@ -338,7 +338,7 @@ recommend the extra; a Recipe that only reads briefs can leave it out.
|
|
|
338
338
|
|
|
339
339
|
## Python
|
|
340
340
|
|
|
341
|
-
The Word and PDF helpers are small Python programs. Each format package
|
|
341
|
+
The Word and PDF helpers are small Python programs (HTML runs in Node and needs none). Each format package
|
|
342
342
|
declares its own `pi.runtime.python` environment, locked by the package's
|
|
343
343
|
`python/uv.lock`: paper-docx for Word, pypdfium2 and pillow for PDF. The host
|
|
344
344
|
prepares that environment for the installed package, as it does every
|
|
@@ -424,3 +424,4 @@ dependency of the Recipe that uses it, installed when the runtime is baked.
|
|
|
424
424
|
|
|
425
425
|
- Word: this page; `packages/documents/docx/README.md`.
|
|
426
426
|
- PDF: this page; `packages/documents/pdf/README.md`.
|
|
427
|
+
- HTML: this page; `packages/documents/html/README.md`.
|
package/docs/host-api.md
CHANGED
|
@@ -75,6 +75,7 @@ const handle = await createAgentSession({
|
|
|
75
75
|
},
|
|
76
76
|
memoryOverride,
|
|
77
77
|
transformSystemPrompt,
|
|
78
|
+
clock: { timeZone: "America/Los_Angeles", locale: "en-US" },
|
|
78
79
|
onDiagnostics,
|
|
79
80
|
onEvent,
|
|
80
81
|
onAgentRunEvent,
|
|
@@ -119,6 +120,15 @@ gateway-decorated model without reimplementing Recipe semantics. The Recipe
|
|
|
119
120
|
continues to own model configuration and tool selection; host seams replace
|
|
120
121
|
transport and materialized resources, not the portable definition.
|
|
121
122
|
|
|
123
|
+
### The person's clock
|
|
124
|
+
|
|
125
|
+
`clock` sets the time zone (IANA) and locale (BCP 47) of the person the
|
|
126
|
+
session serves, and optionally `now`, which pins the clock in tests. Every
|
|
127
|
+
turn's prompt names the date in that zone, and the built-in `today` tool and
|
|
128
|
+
`calendar list`'s default range read the same clock, as do the default
|
|
129
|
+
in-process children. Omitted fields fall back to the host's time zone and
|
|
130
|
+
locale and the system clock; an unknown zone fails construction.
|
|
131
|
+
|
|
122
132
|
### Persistent memory context
|
|
123
133
|
|
|
124
134
|
Hosts can provide one durable memory index through `memory`. Recipes loads the
|
package/docs/interactions.md
CHANGED
|
@@ -120,12 +120,12 @@ envelopes:
|
|
|
120
120
|
The answer is what the person did, not proof: the agent reads the real state
|
|
121
121
|
before it says something is connected.
|
|
122
122
|
|
|
123
|
-
| Host | With `wait: true`
|
|
124
|
-
| ------------------------- |
|
|
125
|
-
| Pi terminal (TUI) and RPC | Runs the Introspection CLI (`INTROSPECTION_CLI`, else `introspection` on `PATH`) until it returns: `connectors authorize <provider> --subject user` for a `connection`, `open --integrations <provider> --wait` for an `integration`, `open --runtime <runtime> --wait` for a `binding
|
|
126
|
-
| Pause/resume host | The interrupt above; the host renders it and resumes with the answer.
|
|
127
|
-
| Headless and child agents | Declined.
|
|
128
|
-
| No channel | The unavailable envelope.
|
|
123
|
+
| Host | With `wait: true` |
|
|
124
|
+
| ------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
125
|
+
| Pi terminal (TUI) and RPC | Runs the Introspection CLI (`INTROSPECTION_CLI`, else `introspection` on `PATH`) until it returns: `connectors authorize <provider> --subject user` for a `connection`, `open --integrations <provider> --wait` for an `integration`, `open --runtime <runtime> --wait` for a `binding`, `open --repository --name <name> [--template <owner/repo>] --wait` for a `repository`. A `runtime` or `task` page has nothing to finish, so, like the hosted card, it runs `open --runtime <runtime>` or `open --task <task>` without `--wait` and answers `returned` once the page opens. Exit 0 answers `connected` (`returned` for a page); another exit answers `failed:` with the CLI's last error line. A `connector` or `sso` target, or a missing CLI, shows a Done / Not now dialog instead. The wait lasts up to an hour. |
|
|
126
|
+
| Pause/resume host | The interrupt above; the host renders it and resumes with the answer; for a `runtime` or `task` page, opening it is the answer (`returned`). |
|
|
127
|
+
| Headless and child agents | Declined. |
|
|
128
|
+
| No channel | The unavailable envelope. |
|
|
129
129
|
|
|
130
130
|
Without `wait`, nothing pauses: Pi's terminal opens a `runtime`, `task` or
|
|
131
131
|
`binding` page, or starts an `integration` install, through the CLI, and the
|