@agimon-ai/po-cloudflare 0.0.2-alpha.13 → 0.0.2-alpha.14
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/{agent-DYFqCLl2.js → agent-DTjnYFAN.js} +1 -1
- package/dist/{apiContracts-CDJ9sPkE.js → apiContracts-DepyzMNr.js} +80 -80
- package/dist/{approval-BSX-MRTE.js → approval-Biq3NCWj.js} +2 -2
- package/dist/{approvalPrompt-1FPgNwMA.js → approvalPrompt-DoHlIPkU.js} +2 -2
- package/dist/assets/plugins/compositions.json +1 -1
- package/dist/{atomicJson-BF1fVXy1.js → atomicJson-DCIsEywH.js} +3 -3
- package/dist/{backgroundWork-BaczP3Z1.js → backgroundWork-Bswjs1av.js} +1 -1
- package/dist/{codemode-CZ_eYTwm.js → codemode-CgVosRtU.js} +1 -1
- package/dist/{contracts-CnRs-Twx.js → contracts-CylyLZC8.js} +1 -1
- package/dist/{domains-Bl6T2dKV.js → domains-BqChtBLN.js} +23 -5
- package/dist/{exports-DlcCEAe3.js → exports-DERO0cQf.js} +760 -147
- package/dist/{exports-CxkWsXI9.js → exports-DX8LJfSj.js} +9 -9
- package/dist/{extensionFile-D7wk8tFr.js → extensionFile-Ds7RCpnb.js} +1 -1
- package/dist/{harnessStore-flLz1I0F.js → harnessStore-BectazJQ.js} +4 -4
- package/dist/harnessStore-C0Zwvny8.js +1 -0
- package/dist/{help-DjybmnPW.js → help-Dpm82qDr.js} +2 -2
- package/dist/{hubChannel-Bi3PQrfD.js → hubChannel-COvmdWGO.js} +4 -2
- package/dist/{index.edge-CJ2TFpgF.js → index.edge-B0D_Lgbx.js} +2 -2
- package/dist/{index.edge-C9_xuXyy.js → index.edge-BLmsRNW8.js} +2 -2
- package/dist/{layeredConfig-B4s0eZ5o.js → layeredConfig-pQGjhAks.js} +92 -6
- package/dist/{majorModes-IygGmbb8.js → majorModes-BrL4EtzH.js} +5 -14
- package/dist/majorModes-WXt22_km.js +1 -0
- package/dist/{mcpProjection-BA6baFpi.js → mcpProjection-pbPBBuvs.js} +2 -2
- package/dist/{notification-bGq1frYG.js → notification-CINsJWDL.js} +7 -4
- package/dist/{piConfig-CcoMX-1L.js → piConfig-BDUpA6w0.js} +5 -5
- package/dist/piSettings-tdui0CZI.js +1 -0
- package/dist/{platform-CyvF7X-b.js → platform-yhQXrrM_.js} +1 -1
- package/dist/{platformFiles-Ccj9HCvA.js → platformFiles-DB3Cw1l_.js} +1 -1
- package/dist/{protocol-Q7TFrOIs.js → protocol-B6LbEIe6.js} +2 -2
- package/dist/{server-4CmqIbH2.js → server-2o-hl3o0.js} +55 -14
- package/dist/{server-DSu_uLDX.js → server-B-br6deK.js} +6 -6
- package/dist/{server-C9gff7gU.js → server-B2G-c0hg.js} +5 -5
- package/dist/{server-CIhwIcbA.js → server-B3RgnYiZ.js} +13 -4
- package/dist/{server-C8HyW7wN.js → server-BBNCtQtl.js} +7 -7
- package/dist/{server-C_34VM3M.js → server-BmIU37Ei.js} +3 -3
- package/dist/{server-ClsNJwdv.js → server-Bqm5R8kV.js} +13 -13
- package/dist/{server-Co57A8MH.js → server-Bt6Zsqo8.js} +2 -2
- package/dist/{server-il_s2Ycz.js → server-BvYolSs9.js} +339 -43
- package/dist/{server-CpJNq249.js → server-C1x2LoKK.js} +10 -10
- package/dist/{server-CjsKNdSN.js → server-CCwwnpH0.js} +5 -5
- package/dist/{server-CxGGQFJs.js → server-CRPxNGv6.js} +6 -6
- package/dist/{server-COE7BKSa.js → server-Ci_BGVwd.js} +3 -3
- package/dist/{server-CTSvwoDy.js → server-CyYesT-G.js} +9 -9
- package/dist/{server-ziNfBZ2M.js → server-CzJjYgVk.js} +3 -3
- package/dist/{server-C_3jK2WM.js → server-D9qM5XCP.js} +23 -11
- package/dist/{server-C82Qzoh3.js → server-DE3Gzgfb.js} +10 -10
- package/dist/{server-CMaTba5B.js → server-DL6UyXfJ.js} +8 -8
- package/dist/{server-5vLvBTTs.js → server-DPTp6GXS.js} +4 -4
- package/dist/{server-CcNMwEFQ.js → server-Dgn4el5K.js} +5 -5
- package/dist/{server-CQXqMpeC.js → server-DuDp9MhD.js} +116 -54
- package/dist/{server-DeSuziRK.js → server-OerXqXJT.js} +4 -4
- package/dist/{server-ZsazKk-n.js → server-V8W5mcGu.js} +6 -6
- package/dist/{server-Bm6pAAw8.js → server-_0288DYR.js} +4 -4
- package/dist/{server-BHhb0oir.js → server-cStfn1Yv.js} +4 -4
- package/dist/{serverPlugin-pCqlBqQG.js → serverPlugin-OOfjB8tm.js} +1114 -1111
- package/dist/{sessionConfig-DzAs6Pt-.js → sessionConfig-C-zJI72k.js} +242 -54
- package/dist/{validation-CkjZwpf-.js → validation-DuOGOKEi.js} +2 -2
- package/dist/{value-DGT5IoiK.js → value-DyVsxCwZ.js} +1 -1
- package/dist/{vaultSettings-BRr8n821.js → vaultSettings-BFCRCBM3.js} +1 -1
- package/dist/web-cN41ySs9.js +3 -0
- package/dist/worker.js +15822 -1103
- package/dist/workflow-BgwWq0nq.js +79 -0
- package/package.json +32 -32
- package/dist/contextProjection-DlB6wzhm.js +0 -209
- package/dist/harnessStore-Bap8lsAg.js +0 -1
- package/dist/majorModes-xpLK9HpD.js +0 -1
- package/dist/piSettings-B6fsgIBA.js +0 -1
- package/dist/web-Cfvbn9H1.js +0 -3
- package/dist/workflow-w5JPZXgc.js +0 -23
- /package/dist/assets/plugins/slots/{approval.8b3f37d9-CqQk6XG_.js → approval.293d9a00-CqQk6XG_.js} +0 -0
- /package/dist/assets/plugins/slots/{artifacts.47d00f81-D-vQ-7Iz.js → artifacts.24567664-D-vQ-7Iz.js} +0 -0
- /package/dist/assets/plugins/slots/{autocompact.9a92993d-B3KTYwW1.js → autocompact.dd97d013-B3KTYwW1.js} +0 -0
- /package/dist/assets/plugins/slots/{builtin-tools.939bbfff-CZRYQVIP.js → builtin-tools.36d7400b-CZRYQVIP.js} +0 -0
- /package/dist/assets/plugins/slots/{codemode.782e5bb1-Bzl_K_vt.js → codemode.8eaee717-Bzl_K_vt.js} +0 -0
- /package/dist/assets/plugins/slots/{domain.21790b66-CvnpuKCY.js → domain.5e95fc37-CvnpuKCY.js} +0 -0
- /package/dist/assets/plugins/slots/{edit.c7c85129-kaxIknZ-.js → edit.385c9aa9-kaxIknZ-.js} +0 -0
- /package/dist/assets/plugins/slots/{files.bbcef824-wuB8gcQA.js → files.daf34ed8-wuB8gcQA.js} +0 -0
- /package/dist/assets/plugins/slots/{grep.3dfd3214-3FnU8p-d.js → grep.02052cdc-3FnU8p-d.js} +0 -0
- /package/dist/assets/plugins/slots/{log.33bc7d38-C0PXQ0O1.js → log.a86eb6d0-C0PXQ0O1.js} +0 -0
- /package/dist/assets/plugins/slots/{mcp.59c68bcb-D0CkHnIw.js → mcp.974af249-D0CkHnIw.js} +0 -0
- /package/dist/assets/plugins/slots/{profile.ea55f5e1-BSY3iYfJ.js → profile.48851a1d-BSY3iYfJ.js} +0 -0
- /package/dist/assets/plugins/slots/{prompts.9957cc84-xdCkNkoA.js → prompts.723d7748-xdCkNkoA.js} +0 -0
- /package/dist/assets/plugins/slots/{read.30a617e7-qqaxVlEX.js → read.46bf6536-qqaxVlEX.js} +0 -0
- /package/dist/assets/plugins/slots/{runner.9f3559b0-DfO2Z9HG.js → runner.53e9bd76-DfO2Z9HG.js} +0 -0
- /package/dist/assets/plugins/slots/{skill.f506a5ea-CL_n-l4h.js → skill.086701a4-CL_n-l4h.js} +0 -0
- /package/dist/assets/plugins/slots/{vault.01657352-DbG3F_on.js → vault.ac9935c8-DbG3F_on.js} +0 -0
|
@@ -1,28 +1,23 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { i as readTextIfExists, s as writeFileAtomic } from "./platformFiles-
|
|
3
|
-
import
|
|
4
|
-
import "./
|
|
5
|
-
import { t as
|
|
6
|
-
import {
|
|
7
|
-
import { a as defaultDomainsForMajorMode, l as readPoConfig } from "./domains-Bl6T2dKV.js";
|
|
1
|
+
import { B as String$1, Bn as BACKGROUND_CONTEXT, R as Union, W as Null, b as Service, bn as getOrThrow, ft as _Object_, gn as nodeHost, mn as createSerialRunner, mt as Optional, rr as defineServiceContract, x as PO_CONFIG_SERVICE } from "./serverPlugin-OOfjB8tm.js";
|
|
2
|
+
import { i as readTextIfExists, s as writeFileAtomic } from "./platformFiles-DB3Cw1l_.js";
|
|
3
|
+
import "./platform-yhQXrrM_.js";
|
|
4
|
+
import { t as createDirectoryWithMode } from "./atomicJson-DCIsEywH.js";
|
|
5
|
+
import { C as isSeq, _ as parseDocument, b as YAMLMap, c as globalPoConfigPath, f as repositoryPoConfigPath, g as parse, h as parsePoConfig, m as configScopeOf, n as poConfigCandidates, s as globalPoConfigDirectory, t as readPoConfigSourcesAsync, v as stringify, x as isMap } from "./layeredConfig-pQGjhAks.js";
|
|
6
|
+
import { a as defaultDomainsForMajorMode, l as readPoConfig, n as loadDomainsAsync, u as readPoConfigLayers } from "./domains-BqChtBLN.js";
|
|
8
7
|
import { n as defineApiRoutes, t as apiResponse } from "./hubRevisions-58pU2dW5.js";
|
|
9
|
-
import "./web-
|
|
10
|
-
import { n as savePiImageSettingsAsync, r as DEFAULT_IMAGE_MAX_DIMENSION, t as readPiImageSettings } from "./piConfig-
|
|
11
|
-
import {
|
|
12
|
-
import { t as loadHarnessStateAsync } from "./harnessStore-
|
|
8
|
+
import "./web-cN41ySs9.js";
|
|
9
|
+
import { n as savePiImageSettingsAsync, r as DEFAULT_IMAGE_MAX_DIMENSION, t as readPiImageSettings } from "./piConfig-BDUpA6w0.js";
|
|
10
|
+
import { r as MODES_FILE, t as readMajorModesConfig } from "./majorModes-BrL4EtzH.js";
|
|
11
|
+
import { t as loadHarnessStateAsync } from "./harnessStore-BectazJQ.js";
|
|
13
12
|
import path from "node:path";
|
|
14
13
|
import { Buffer as Buffer$1 } from "node:buffer";
|
|
15
14
|
//#region ../../foundations/po-config/src/services/config/sync.edge.ts
|
|
16
|
-
function nodeOnly
|
|
15
|
+
function nodeOnly(name, asyncName) {
|
|
17
16
|
throw new Error(`${name} is Node-only; use ${asyncName} with a PoPlatform on the edge.`);
|
|
18
17
|
}
|
|
19
18
|
/** @deprecated Node-only sync shim; use readPoConfig. Removed in M2. */
|
|
20
19
|
function loadPoConfig(_repoRoot, _homeDirectory, _environment) {
|
|
21
|
-
return nodeOnly
|
|
22
|
-
}
|
|
23
|
-
/** @deprecated Node-only sync shim; use readPoConfigLayers. Removed in M2. */
|
|
24
|
-
function loadPoConfigLayers(_repoRoot, _homeDirectory, _environment) {
|
|
25
|
-
return nodeOnly$2("loadPoConfigLayers", "readPoConfigLayers");
|
|
20
|
+
return nodeOnly("loadPoConfig", "readPoConfig");
|
|
26
21
|
}
|
|
27
22
|
//#endregion
|
|
28
23
|
//#region ../../foundations/po-config/src/services/configWriter/core.ts
|
|
@@ -138,15 +133,6 @@ async function writePoConfigValuesAsync(fs, filePath, edits, context, options =
|
|
|
138
133
|
});
|
|
139
134
|
}
|
|
140
135
|
//#endregion
|
|
141
|
-
//#region ../../foundations/po-config/src/services/domains/sync.edge.ts
|
|
142
|
-
function nodeOnly$1(name, asyncName) {
|
|
143
|
-
throw new Error(`${name} is Node-only; use ${asyncName} with a PoPlatform on the edge.`);
|
|
144
|
-
}
|
|
145
|
-
/** @deprecated Node-only sync shim; use loadDomainsAsync. Removed in M2. */
|
|
146
|
-
function loadDomains(_repoRoot, _homeDirectory) {
|
|
147
|
-
return nodeOnly$1("loadDomains", "loadDomainsAsync");
|
|
148
|
-
}
|
|
149
|
-
//#endregion
|
|
150
136
|
//#region ../../foundations/po-config/src/constants/settings.ts
|
|
151
137
|
const SELECTION_KEYS = {
|
|
152
138
|
majorMode: ["selection", "majorMode"],
|
|
@@ -352,6 +338,66 @@ function parsePersonaFrontMatter(content) {
|
|
|
352
338
|
};
|
|
353
339
|
}
|
|
354
340
|
//#endregion
|
|
341
|
+
//#region ../../core/po-core/src/schemas/profileIdentity.ts
|
|
342
|
+
/**
|
|
343
|
+
* The custom session entry the runtime journals when the active profile's
|
|
344
|
+
* persona identity changes.
|
|
345
|
+
*
|
|
346
|
+
* A profile has always been prompt text only, so a cockpit had nothing to show
|
|
347
|
+
* for it beyond the profile name already published as footer status. This entry
|
|
348
|
+
* carries the persona's display name and avatar so the transcript can attribute
|
|
349
|
+
* each assistant message to the persona that produced it.
|
|
350
|
+
*
|
|
351
|
+
* It rides Pi's `entry_appended` frames on the road the agent-model projection
|
|
352
|
+
* already uses, so any RPC client sees the change live and on replay without a
|
|
353
|
+
* new protocol.
|
|
354
|
+
*
|
|
355
|
+
* Unlike the minor-mode, context, and agent-model projections, this entry is
|
|
356
|
+
* NOT a projection: it is transcript, positioned in journal order. A cockpit
|
|
357
|
+
* folding it must keep every occurrence rather than collapsing to the latest
|
|
358
|
+
* one, because a message written before a switch keeps the identity it was
|
|
359
|
+
* written under. Collapsing would rewrite history.
|
|
360
|
+
*/
|
|
361
|
+
const PO_PROFILE_IDENTITY_ENTRY_TYPE = "po-profile-identity";
|
|
362
|
+
/**
|
|
363
|
+
* Ceiling on the encoded icon, counted on the finished `data:` URL rather than
|
|
364
|
+
* the file, so one number bounds both the journal entry and the transport.
|
|
365
|
+
*
|
|
366
|
+
* An avatar renders at 32 CSS pixels. This much room is already generous, and
|
|
367
|
+
* the cap exists because the entry is replayed with the transcript: an oversize
|
|
368
|
+
* icon is dropped and the persona keeps its name, never failing a profile load.
|
|
369
|
+
*/
|
|
370
|
+
const PROFILE_ICON_MAX_DATA_URL_LENGTH = 262144;
|
|
371
|
+
const MAX_PROFILE_NAME_LENGTH = 128;
|
|
372
|
+
/**
|
|
373
|
+
* Image types allowed for a persona icon.
|
|
374
|
+
*
|
|
375
|
+
* Deliberately narrower than the cockpit's general media catalog: `image/svg+xml`
|
|
376
|
+
* is excluded because an SVG rendered same-origin executes script, and the icon
|
|
377
|
+
* path comes from user-authored persona front-matter. Do not reconcile this list
|
|
378
|
+
* with the broader media type map.
|
|
379
|
+
*/
|
|
380
|
+
const PROFILE_ICON_MIME_TYPES = [
|
|
381
|
+
"image/png",
|
|
382
|
+
"image/jpeg",
|
|
383
|
+
"image/gif",
|
|
384
|
+
"image/webp"
|
|
385
|
+
];
|
|
386
|
+
_Object_({
|
|
387
|
+
profile: Union([String$1({
|
|
388
|
+
minLength: 1,
|
|
389
|
+
maxLength: MAX_PROFILE_NAME_LENGTH
|
|
390
|
+
}), Null()]),
|
|
391
|
+
name: Optional(String$1({
|
|
392
|
+
minLength: 1,
|
|
393
|
+
maxLength: MAX_PROFILE_NAME_LENGTH
|
|
394
|
+
})),
|
|
395
|
+
icon: Optional(String$1({
|
|
396
|
+
minLength: 1,
|
|
397
|
+
maxLength: PROFILE_ICON_MAX_DATA_URL_LENGTH
|
|
398
|
+
}))
|
|
399
|
+
}, { additionalProperties: false });
|
|
400
|
+
//#endregion
|
|
355
401
|
//#region ../../foundations/po-config/src/services/personaIcon/core.ts
|
|
356
402
|
/**
|
|
357
403
|
* Pure half of persona icon loading: confinement and image sniffing. The
|
|
@@ -439,6 +485,27 @@ async function readPersonaIconAsync(fs, personaPath, iconRelative, context) {
|
|
|
439
485
|
}
|
|
440
486
|
}
|
|
441
487
|
//#endregion
|
|
488
|
+
//#region ../../core/po-core/src/schemas/personTimeZone.ts
|
|
489
|
+
const PO_PERSON_TIME_ZONE_SERVICE = "po/person-time-zone";
|
|
490
|
+
defineServiceContract(PO_PERSON_TIME_ZONE_SERVICE, { scope: "session" });
|
|
491
|
+
function readPoPersonTimeZone(context) {
|
|
492
|
+
return context.get(PO_PERSON_TIME_ZONE_SERVICE);
|
|
493
|
+
}
|
|
494
|
+
/** True for a zone name this runtime's Intl accepts, such as `Australia/Sydney`. */
|
|
495
|
+
function isTimeZone(value) {
|
|
496
|
+
if (typeof value !== "string" || value.length === 0 || value.length > 64) return false;
|
|
497
|
+
try {
|
|
498
|
+
new Intl.DateTimeFormat("en", { timeZone: value });
|
|
499
|
+
return true;
|
|
500
|
+
} catch {
|
|
501
|
+
return false;
|
|
502
|
+
}
|
|
503
|
+
}
|
|
504
|
+
/** The system prompt line. It names no clock time, so it stays stable and the prompt cache holds. */
|
|
505
|
+
function personTimeZoneLine(zone) {
|
|
506
|
+
return zone === void 0 ? "Person's timezone: unknown. Ask the person before acting on a clock time or date; never assume the server's zone." : `Person's timezone: ${zone.timeZone} (from their ${zone.source}). Read and write dates and clock times in this zone unless the person names another.`;
|
|
507
|
+
}
|
|
508
|
+
//#endregion
|
|
442
509
|
//#region ../../foundations/po-config/src/services/profileBinding/index.ts
|
|
443
510
|
const BINDING_KEYS = /* @__PURE__ */ new Set([
|
|
444
511
|
"provider",
|
|
@@ -920,19 +987,6 @@ function sortProfiles(byName) {
|
|
|
920
987
|
return [...byName.values()].sort((left, right) => left.name.localeCompare(right.name));
|
|
921
988
|
}
|
|
922
989
|
//#endregion
|
|
923
|
-
//#region ../../foundations/po-config/src/services/profiles/sync.edge.ts
|
|
924
|
-
function nodeOnly(name, asyncName) {
|
|
925
|
-
throw new Error(`${name} is Node-only; use ${asyncName} with a PoPlatform on the edge.`);
|
|
926
|
-
}
|
|
927
|
-
/** @deprecated Node-only sync shim; use loadProfilesAsync. Removed in M2. */
|
|
928
|
-
function loadProfiles(_repoRoot, _homeDirectory) {
|
|
929
|
-
return nodeOnly("loadProfiles", "loadProfilesAsync");
|
|
930
|
-
}
|
|
931
|
-
/** @deprecated Node-only sync shim; use buildPersonaPromptAsync. Removed in M2. */
|
|
932
|
-
function buildPersonaPrompt(_personaRoot, _personaDirectory) {
|
|
933
|
-
return nodeOnly("buildPersonaPrompt", "buildPersonaPromptAsync");
|
|
934
|
-
}
|
|
935
|
-
//#endregion
|
|
936
990
|
//#region ../../foundations/po-config/src/services/profiles/index.ts
|
|
937
991
|
/** Profile reads over a FileSystem; the Node shims in `./sync` give the same answers from node:fs. */
|
|
938
992
|
const realPath = async (fs, target, context) => getOrThrow(await fs.canonicalPath(target, context));
|
|
@@ -1090,6 +1144,13 @@ async function commitGlobalProfileRootAsync(fs, plan, context) {
|
|
|
1090
1144
|
}
|
|
1091
1145
|
//#endregion
|
|
1092
1146
|
//#region ../../foundations/po-config/src/services/settings/index.ts
|
|
1147
|
+
/** The mount's admitted home and environment, so no reader falls back to the host's. */
|
|
1148
|
+
function readOptions(homeDirectory, environment) {
|
|
1149
|
+
return {
|
|
1150
|
+
...homeDirectory === void 0 ? {} : { homeDirectory },
|
|
1151
|
+
environment
|
|
1152
|
+
};
|
|
1153
|
+
}
|
|
1093
1154
|
function isRecord(value) {
|
|
1094
1155
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
1095
1156
|
}
|
|
@@ -1142,12 +1203,13 @@ function configuredSelectionValue(layers, key, effective) {
|
|
|
1142
1203
|
origin
|
|
1143
1204
|
};
|
|
1144
1205
|
}
|
|
1145
|
-
function repositorySettingsView(repository, homeDirectory, environment) {
|
|
1206
|
+
async function repositorySettingsView(fs, repository, homeDirectory, environment, io) {
|
|
1146
1207
|
const repoRoot = repository.path;
|
|
1147
|
-
const
|
|
1148
|
-
const
|
|
1149
|
-
const
|
|
1150
|
-
const
|
|
1208
|
+
const options = readOptions(homeDirectory, environment);
|
|
1209
|
+
const layers = await readPoConfigLayers(fs, repoRoot, io, options);
|
|
1210
|
+
const modes = await readMajorModesConfig(fs, repoRoot, io, options);
|
|
1211
|
+
const domains = await loadDomainsAsync(fs, repoRoot, io, homeDirectory);
|
|
1212
|
+
const profiles = await loadProfilesAsync(fs, repoRoot, io, homeDirectory);
|
|
1151
1213
|
const configured = layers.effective.selection;
|
|
1152
1214
|
const effectiveMajorMode = configured?.majorMode ?? modes.defaultMajorMode;
|
|
1153
1215
|
const effectiveDomains = configured?.domains ?? defaultDomainsForMajorMode(effectiveMajorMode, {}, domains.defaultDomains);
|
|
@@ -1226,9 +1288,9 @@ function selectionEdits(changes) {
|
|
|
1226
1288
|
...value === null ? {} : { value }
|
|
1227
1289
|
}));
|
|
1228
1290
|
}
|
|
1229
|
-
function configView(context, keys) {
|
|
1291
|
+
async function configView(fs, context, keys, io) {
|
|
1230
1292
|
const root = context.scope === "workspace" ? context.workspaceRoot : void 0;
|
|
1231
|
-
const layers =
|
|
1293
|
+
const layers = await readPoConfigLayers(fs, root, io, readOptions(context.homeDirectory, context.environment ?? {}));
|
|
1232
1294
|
const values = {};
|
|
1233
1295
|
for (const key of keys) {
|
|
1234
1296
|
const keyPath = key.split(".");
|
|
@@ -1252,7 +1314,7 @@ function configView(context, keys) {
|
|
|
1252
1314
|
//#region ../../foundations/po-config/src/services/settingsApi/index.ts
|
|
1253
1315
|
/**
|
|
1254
1316
|
* Config handlers are bound to their mount. Request paths cannot choose a different repository.
|
|
1255
|
-
*
|
|
1317
|
+
* Reads, writes and image settings all go through the host's FileSystem.
|
|
1256
1318
|
*/
|
|
1257
1319
|
const createSettingsApi = (fs) => ({
|
|
1258
1320
|
basePath: "settings",
|
|
@@ -1286,9 +1348,9 @@ const createSettingsApi = (fs) => ({
|
|
|
1286
1348
|
*/
|
|
1287
1349
|
const addresses = (route) => url.pathname === route.path && request.method === route.method;
|
|
1288
1350
|
const currentRepository = repository();
|
|
1289
|
-
if (addresses(apiRoutes_default.config)) return Response.json(configView(context, url.searchParams.getAll("key")));
|
|
1351
|
+
if (addresses(apiRoutes_default.config)) return Response.json(await configView(fs, context, url.searchParams.getAll("key"), io));
|
|
1290
1352
|
if (addresses(apiRoutes_default.repositories)) return Response.json({ repositories: context.repositories?.() ?? [] });
|
|
1291
|
-
if (addresses(apiRoutes_default.repository)) return currentRepository ? Response.json(repositorySettingsView(currentRepository, homeDirectory, environment)) : Response.json({ error: "Choose a workspace." }, { status: 404 });
|
|
1353
|
+
if (addresses(apiRoutes_default.repository)) return currentRepository ? Response.json(await repositorySettingsView(fs, currentRepository, homeDirectory, environment, io)) : Response.json({ error: "Choose a workspace." }, { status: 404 });
|
|
1292
1354
|
if (url.pathname === apiRoutes_default.images.path && context.scope === "global") {
|
|
1293
1355
|
if (request.method === apiRoutes_default.images.method) return Response.json(await imageView());
|
|
1294
1356
|
if (request.method === apiRoutes_default.saveImages.method) {
|
|
@@ -1318,7 +1380,7 @@ const createSettingsApi = (fs) => ({
|
|
|
1318
1380
|
const body = parseSelectionWrite(await request.json());
|
|
1319
1381
|
if (!body) return Response.json({ error: "A selection write needs typed changes and a file hash." }, { status: 400 });
|
|
1320
1382
|
if (!currentRepository || body.repositoryId !== currentRepository.id) return Response.json({ error: "Workspace not found in this mount." }, { status: 404 });
|
|
1321
|
-
const before = repositorySettingsView(currentRepository, homeDirectory, environment);
|
|
1383
|
+
const before = await repositorySettingsView(fs, currentRepository, homeDirectory, environment, io);
|
|
1322
1384
|
if (before.hash !== body.expectedHash) return Response.json({
|
|
1323
1385
|
error: "The repository config changed since it was read.",
|
|
1324
1386
|
hash: before.hash
|
|
@@ -1327,7 +1389,7 @@ const createSettingsApi = (fs) => ({
|
|
|
1327
1389
|
if (invalid) return Response.json({ error: invalid }, { status: 422 });
|
|
1328
1390
|
await writePoConfigValuesAsync(fs, repositoryPoConfigPath(currentRepository.path), selectionEdits(body.changes), io, { scope: "repository" });
|
|
1329
1391
|
context.configurationChanged?.();
|
|
1330
|
-
return Response.json(repositorySettingsView(currentRepository, homeDirectory, environment));
|
|
1392
|
+
return Response.json(await repositorySettingsView(fs, currentRepository, homeDirectory, environment, io));
|
|
1331
1393
|
}
|
|
1332
1394
|
if (addresses(apiRoutes_default.value)) {
|
|
1333
1395
|
const body = parseWrite(await request.json());
|
|
@@ -1338,7 +1400,7 @@ const createSettingsApi = (fs) => ({
|
|
|
1338
1400
|
const allowed = configScopeOf(edit.keyPath);
|
|
1339
1401
|
return allowed !== "both" && allowed !== scope;
|
|
1340
1402
|
})) return Response.json({ error: "This key cannot be set at this scope." }, { status: 409 });
|
|
1341
|
-
const before = configView(context, []);
|
|
1403
|
+
const before = await configView(fs, context, [], io);
|
|
1342
1404
|
if (before.hashes[scope] !== body.expectedHash) return Response.json({
|
|
1343
1405
|
error: "The config changed since it was read.",
|
|
1344
1406
|
hash: before.hashes[scope]
|
|
@@ -1348,7 +1410,7 @@ const createSettingsApi = (fs) => ({
|
|
|
1348
1410
|
...value === null ? {} : { value }
|
|
1349
1411
|
})), io, { scope });
|
|
1350
1412
|
context.configurationChanged?.();
|
|
1351
|
-
return Response.json(configView(context, body.edits.map((edit) => edit.keyPath.join("."))));
|
|
1413
|
+
return Response.json(await configView(fs, context, body.edits.map((edit) => edit.keyPath.join(".")), io));
|
|
1352
1414
|
}
|
|
1353
1415
|
return Response.json({ error: "Configuration route not found." }, { status: 404 });
|
|
1354
1416
|
};
|
|
@@ -1373,6 +1435,132 @@ const createSettingsApi = (fs) => ({
|
|
|
1373
1435
|
}
|
|
1374
1436
|
});
|
|
1375
1437
|
//#endregion
|
|
1438
|
+
//#region ../../core/po-core/src/services/toolCost/index.ts
|
|
1439
|
+
/** Mirrors the wire shape MCP advertises, so both estimates stay comparable. */
|
|
1440
|
+
function schemaPayload(entry) {
|
|
1441
|
+
return JSON.stringify({
|
|
1442
|
+
name: entry.name,
|
|
1443
|
+
...entry.description === void 0 ? {} : { description: entry.description },
|
|
1444
|
+
...entry.parameters === void 0 ? {} : { parameters: entry.parameters }
|
|
1445
|
+
});
|
|
1446
|
+
}
|
|
1447
|
+
function promptPayload(entry) {
|
|
1448
|
+
return [entry.promptSnippet ?? "", ...entry.promptGuidelines ?? []].filter(Boolean).join("\n");
|
|
1449
|
+
}
|
|
1450
|
+
function tokensForTool(entry, countTokens) {
|
|
1451
|
+
const schemaTokens = countTokens(schemaPayload(entry));
|
|
1452
|
+
const prompt = promptPayload(entry);
|
|
1453
|
+
const promptTokens = prompt.length === 0 ? 0 : countTokens(prompt);
|
|
1454
|
+
return {
|
|
1455
|
+
schemaTokens,
|
|
1456
|
+
promptTokens,
|
|
1457
|
+
totalTokens: schemaTokens + promptTokens
|
|
1458
|
+
};
|
|
1459
|
+
}
|
|
1460
|
+
/** Journal entry the cockpit reads; mirrored by CONTEXT_ENTRY_TYPE in po-web. */
|
|
1461
|
+
const PO_CONTEXT_ENTRY_TYPE = "po-context";
|
|
1462
|
+
/** Session selection and transition journal identities, not transport channels. */
|
|
1463
|
+
const PO_CONFIG_ENTRY_TYPE = "po:config:v1";
|
|
1464
|
+
const PO_CONFIG_TRANSITION_ENTRY_TYPE = "po:transition:v1";
|
|
1465
|
+
/** The tokenizer these counts came from, so a reader can judge them. */
|
|
1466
|
+
const CONTEXT_PROJECTION_ESTIMATOR = "gpt-tokenizer";
|
|
1467
|
+
/** Everything the runtime could not attribute lands here rather than vanishing. */
|
|
1468
|
+
const CORE_GROUP = "core";
|
|
1469
|
+
/** Pi's own tools have no package; the runtime itself is the owner. */
|
|
1470
|
+
const CORE_OWNER = "pi";
|
|
1471
|
+
const KIND_ORDER = {
|
|
1472
|
+
major: 0,
|
|
1473
|
+
minor: 1,
|
|
1474
|
+
domain: 2,
|
|
1475
|
+
shared: 3,
|
|
1476
|
+
core: 4
|
|
1477
|
+
};
|
|
1478
|
+
const SOURCE_ORDER = {
|
|
1479
|
+
extension: 0,
|
|
1480
|
+
mcp: 1,
|
|
1481
|
+
plugin: 2,
|
|
1482
|
+
core: 3
|
|
1483
|
+
};
|
|
1484
|
+
function skillSource(group) {
|
|
1485
|
+
if (group === "plugins") return "plugin";
|
|
1486
|
+
if (group === "extensions") return "extension";
|
|
1487
|
+
return "core";
|
|
1488
|
+
}
|
|
1489
|
+
function byRow(left, right) {
|
|
1490
|
+
return SOURCE_ORDER[left.source] - SOURCE_ORDER[right.source] || left.name.localeCompare(right.name);
|
|
1491
|
+
}
|
|
1492
|
+
function projectContext(input) {
|
|
1493
|
+
const buckets = /* @__PURE__ */ new Map();
|
|
1494
|
+
const declare = (id, label, kind) => {
|
|
1495
|
+
if (!buckets.has(id)) buckets.set(id, {
|
|
1496
|
+
kind,
|
|
1497
|
+
label,
|
|
1498
|
+
items: []
|
|
1499
|
+
});
|
|
1500
|
+
};
|
|
1501
|
+
if (input.majorMode) declare(input.majorMode, input.majorMode, "major");
|
|
1502
|
+
for (const group of input.groups) declare(group.id, group.label, group.kind);
|
|
1503
|
+
for (const domain of input.domains) declare(domain, domain, "domain");
|
|
1504
|
+
const place = (owner, item, conditional) => {
|
|
1505
|
+
const attributed = conditional ?? input.attribution[owner];
|
|
1506
|
+
const id = attributed?.mode ?? CORE_GROUP;
|
|
1507
|
+
const kind = attributed?.kind ?? "core";
|
|
1508
|
+
declare(id, attributed && "label" in attributed ? attributed.label ?? id : id, kind);
|
|
1509
|
+
buckets.get(id)?.items.push(item);
|
|
1510
|
+
};
|
|
1511
|
+
for (const source of input.sources) {
|
|
1512
|
+
const owner = source.kind === "extension" ? source.packageName ?? source.key : source.kind === "mcp" ? source.key.slice(4) : CORE_OWNER;
|
|
1513
|
+
for (const tool of source.tools) {
|
|
1514
|
+
const cost = tokensForTool(tool, input.countTokens);
|
|
1515
|
+
const item = {
|
|
1516
|
+
name: tool.name,
|
|
1517
|
+
itemKind: "tool",
|
|
1518
|
+
source: source.kind === "core" ? "core" : source.kind,
|
|
1519
|
+
owner,
|
|
1520
|
+
tokens: cost.totalTokens,
|
|
1521
|
+
active: tool.active
|
|
1522
|
+
};
|
|
1523
|
+
if (source.kind === "core") {
|
|
1524
|
+
declare(CORE_GROUP, CORE_GROUP, "core");
|
|
1525
|
+
buckets.get(CORE_GROUP)?.items.push(item);
|
|
1526
|
+
} else place(owner, item, tool.contextAttribution);
|
|
1527
|
+
}
|
|
1528
|
+
}
|
|
1529
|
+
for (const skill of input.skills) place(skill.owner, {
|
|
1530
|
+
name: skill.name,
|
|
1531
|
+
itemKind: "skill",
|
|
1532
|
+
source: skillSource(skill.group),
|
|
1533
|
+
owner: skill.owner,
|
|
1534
|
+
tokens: skill.promptTokens ?? 0,
|
|
1535
|
+
active: true
|
|
1536
|
+
}, skill.contextAttribution);
|
|
1537
|
+
const groups = [...buckets.entries()].map(([id, bucket]) => {
|
|
1538
|
+
const items = [...bucket.items].sort(byRow);
|
|
1539
|
+
return {
|
|
1540
|
+
id,
|
|
1541
|
+
label: bucket.label,
|
|
1542
|
+
kind: bucket.kind,
|
|
1543
|
+
items,
|
|
1544
|
+
tokens: items.reduce((total, item) => total + (item.active ? item.tokens : 0), 0),
|
|
1545
|
+
inactiveTokens: items.reduce((total, item) => total + (item.active ? 0 : item.tokens), 0)
|
|
1546
|
+
};
|
|
1547
|
+
}).sort((left, right) => KIND_ORDER[left.kind] - KIND_ORDER[right.kind] || left.label.localeCompare(right.label));
|
|
1548
|
+
return {
|
|
1549
|
+
version: 1,
|
|
1550
|
+
revision: input.revision,
|
|
1551
|
+
selection: {
|
|
1552
|
+
majorMode: input.majorMode,
|
|
1553
|
+
domains: [...input.domains],
|
|
1554
|
+
...input.profile === void 0 ? {} : { profile: input.profile }
|
|
1555
|
+
},
|
|
1556
|
+
groups,
|
|
1557
|
+
totalTokens: groups.reduce((total, group) => total + group.tokens, 0),
|
|
1558
|
+
inactiveTokens: groups.reduce((total, group) => total + group.inactiveTokens, 0),
|
|
1559
|
+
...input.systemPrompt === void 0 ? {} : { systemPrompt: input.systemPrompt },
|
|
1560
|
+
estimator: CONTEXT_PROJECTION_ESTIMATOR
|
|
1561
|
+
};
|
|
1562
|
+
}
|
|
1563
|
+
//#endregion
|
|
1376
1564
|
//#region ../../foundations/po-config/src/services/poConfigService/index.ts
|
|
1377
1565
|
function deepFreeze$1(value) {
|
|
1378
1566
|
if (typeof value !== "object" || value === null || Object.isFrozen(value)) return value;
|
|
@@ -1523,4 +1711,4 @@ function providePoConfigContext(ctx, context, generation = `po-config:${crypto.r
|
|
|
1523
1711
|
return new PoConfigService(ctx, deepFreeze(context), loadPoConfig, generation);
|
|
1524
1712
|
}
|
|
1525
1713
|
//#endregion
|
|
1526
|
-
export {
|
|
1714
|
+
export { readPoPersonTimeZone as _, tokensForTool as a, PROFILE_ICON_MIME_TYPES as b, commitGlobalProfileRootAsync as c, inlineProfile as d, parseProfileBinding as f, personTimeZoneLine as g, isTimeZone as h, projectContext as i, loadProfilesAsync as l, PO_PERSON_TIME_ZONE_SERVICE as m, providePoConfigContext as n, createSettingsApi as o, parseProfileVaultSecrets as p, PO_CONTEXT_ENTRY_TYPE as r, ProfileCatalogChangedError as s, createNativePoConfigContext as t, planGlobalProfileRootAsync as u, PO_PROFILE_IDENTITY_ENTRY_TYPE as v, loadPoConfig as x, PROFILE_ICON_MAX_DATA_URL_LENGTH as y };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { t as PoProtocolError } from "./protocol-
|
|
1
|
+
import { $ as Boolean, B as String, H as Number$1, M as Record, R as Union, X as Literal, Z as Integer, ft as _Object_, mt as Optional, ut as Unknown, yt as _Array_ } from "./serverPlugin-OOfjB8tm.js";
|
|
2
|
+
import { t as PoProtocolError } from "./protocol-B6LbEIe6.js";
|
|
3
3
|
//#region ../../foundations/po-minor-mode/src/schemas/mode.ts
|
|
4
4
|
const MINOR_MODE_CATALOG_SOURCE = "@agimon-ai/po/mode-catalog";
|
|
5
5
|
const PO_MINOR_MODE_CATALOG_SERVICE = "po/minor-mode-catalog";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { $t as IsString, At as Every, B as String$1, Bt as IsFunction, Dt as Counted, Ft as IsBoolean, Gt as IsLessThan, Ht as IsGreaterThan, Jt as IsMultipleOf$1, Kt as IsMaxLength$1, Lt as IsConstructor, Mt as HasPropertyKey, Nt as IsArray, Ot as Entries, Pt as IsBigInt, Qt as IsObjectNotArray, R as Union, Rt as IsDeepEqual, St as Get$2, Ut as IsInteger, Vt as IsGreaterEqualThan, Wt as IsLessEqualThan, X as Literal, Xt as IsNumber, Yt as IsNull, Zt as IsObject, an as Some, en as IsSymbol, ft as _Object_, in as Keys, jt as EveryAll, nn as IsUnsafePropertyKey, on as SomeAll, qt as IsMinLength$1, rn as IsValueLike, rt as Hash, tn as IsUndefined, ut as Unknown, zt as IsEqual } from "./serverPlugin-OOfjB8tm.js";
|
|
2
2
|
//#endregion
|
|
3
3
|
//#region ../../../node_modules/.pnpm/typebox@1.4.2/node_modules/typebox/build/system/arguments/arguments.mjs
|
|
4
4
|
/**
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { rr as defineServiceContract } from "./serverPlugin-OOfjB8tm.js";
|
|
2
2
|
//#region ../../foundations/po-vault/src/constants/vault.ts
|
|
3
3
|
const PO_VAULT_SERVICE = "po/vault";
|
|
4
4
|
/** The signed-in account's shared vault, bound by a host that can reach it; absent otherwise. */
|