@sellable/install 0.1.606 → 0.1.610-wip.phase187.20260811.18
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/container/Dockerfile +7 -7
- package/container/README.md +2 -2
- package/lib/sellable-agent/admin-runtime-reconciler.mjs +2 -2
- package/lib/sellable-agent/external-runtime-builder.mjs +1 -1
- package/lib/sellable-agent/fly-admin-image/Dockerfile +16 -0
- package/lib/sellable-agent/fly-admin-image/admin-runtime.mjs +43 -9
- package/lib/sellable-agent/fly-customer-image/Dockerfile +3 -3
- package/lib/sellable-agent/fly-customer-image/customer-runtime.mjs +9 -2
- package/lib/sellable-agent/hermes-memory-snapshot.mjs +404 -56
- package/lib/sellable-agent/host-bootstrap.mjs +2 -2
- package/lib/sellable-agent/host-worker.mjs +2 -2
- package/lib/sellable-agent/profile-materializer.mjs +2 -2
- package/lib/sellable-agent/provisioning-adapter.mjs +2 -2
- package/package.json +1 -1
package/container/Dockerfile
CHANGED
|
@@ -3,13 +3,13 @@ FROM ${HERMES_IMAGE}
|
|
|
3
3
|
|
|
4
4
|
USER root
|
|
5
5
|
|
|
6
|
-
ARG INSTALLER_PACKAGE=@sellable/install@0.1.
|
|
7
|
-
ARG MCP_PACKAGE=@sellable/mcp@0.1.
|
|
6
|
+
ARG INSTALLER_PACKAGE=@sellable/install@0.1.610-wip.phase187.20260811.18
|
|
7
|
+
ARG MCP_PACKAGE=@sellable/mcp@0.1.865-wip.phase187.20260811.15
|
|
8
8
|
ARG INSTALLER_INTEGRITY
|
|
9
|
-
ARG MCP_INTEGRITY=sha512-
|
|
9
|
+
ARG MCP_INTEGRITY=sha512-eMgElGCRnQia1P9NUNuBoc3T/OKHbmDAGwurVljWK5ED+tifDYmXla3VWEmUrqImkthr+9zfJnApCqVBLZIpSA==
|
|
10
10
|
|
|
11
|
-
RUN test "${INSTALLER_PACKAGE}" = "@sellable/install@0.1.
|
|
12
|
-
&& test "${MCP_PACKAGE}" = "@sellable/mcp@0.1.
|
|
11
|
+
RUN test "${INSTALLER_PACKAGE}" = "@sellable/install@0.1.610-wip.phase187.20260811.18" \
|
|
12
|
+
&& test "${MCP_PACKAGE}" = "@sellable/mcp@0.1.865-wip.phase187.20260811.15" \
|
|
13
13
|
&& test -n "${INSTALLER_INTEGRITY}" \
|
|
14
14
|
&& test "$(npm view "${INSTALLER_PACKAGE}" dist.integrity)" = "${INSTALLER_INTEGRITY}" \
|
|
15
15
|
&& test "$(npm view "${MCP_PACKAGE}" dist.integrity)" = "${MCP_INTEGRITY}" \
|
|
@@ -23,9 +23,9 @@ RUN test "${INSTALLER_PACKAGE}" = "@sellable/install@0.1.606" \
|
|
|
23
23
|
&& mkdir -p /opt/sellable-agent/install-root /opt/sellable-agent/mcp-root \
|
|
24
24
|
&& npm install --prefix /opt/sellable-agent/install-root --omit=dev --ignore-scripts --no-audit --no-fund "${INSTALLER_PACKAGE}" \
|
|
25
25
|
&& npm install --prefix /opt/sellable-agent/mcp-root --omit=dev --ignore-scripts --no-audit --no-fund "${MCP_PACKAGE}" \
|
|
26
|
-
&& node --input-type=module -e "import { readFileSync } from 'node:fs'; const install = JSON.parse(readFileSync('/opt/sellable-agent/install-root/node_modules/@sellable/install/package.json')); const mcp = JSON.parse(readFileSync('/opt/sellable-agent/mcp-root/node_modules/@sellable/mcp/package.json')); if (install.name !== '@sellable/install' || install.version !== '0.1.
|
|
26
|
+
&& node --input-type=module -e "import { readFileSync } from 'node:fs'; const install = JSON.parse(readFileSync('/opt/sellable-agent/install-root/node_modules/@sellable/install/package.json')); const mcp = JSON.parse(readFileSync('/opt/sellable-agent/mcp-root/node_modules/@sellable/mcp/package.json')); if (install.name !== '@sellable/install' || install.version !== '0.1.608-wip.phase187.20260811.16-wip.hermes-desktop.20260811160530' || mcp.name !== '@sellable/mcp' || mcp.version !== '0.1.865-wip.phase187.20260811.15') throw new Error('package identity rejected');" \
|
|
27
27
|
&& node --input-type=module -e "import { buildExternalRuntimeClosure } from '/opt/sellable-agent/install-root/node_modules/@sellable/install/lib/sellable-agent/external-runtime-builder.mjs'; const built = buildExternalRuntimeClosure({ mcpPackageRoot: '/opt/sellable-agent/mcp-root/node_modules/@sellable/mcp', mcpNodeModulesRoot: '/opt/sellable-agent/mcp-root/node_modules', hermesSourceRoot: '/opt/hermes', ownerUid: 0, ownerGid: 0 }); if (!built.closureDigest) throw new Error('runtime closure rejected');" \
|
|
28
|
-
&& node --input-type=module -e "import { chmodSync, writeFileSync } from 'node:fs'; const release = { installerPackage: '@sellable/install@0.1.
|
|
28
|
+
&& node --input-type=module -e "import { chmodSync, writeFileSync } from 'node:fs'; const release = { installerPackage: '@sellable/install@0.1.610-wip.phase187.20260811.18', installerIntegrity: process.argv[1], mcpPackage: '@sellable/mcp@0.1.865-wip.phase187.20260811.15', mcpIntegrity: process.argv[2] }; writeFileSync('/opt/sellable-agent/release.json', JSON.stringify(release) + '\\n', { mode: 0o444 }); chmodSync('/opt/sellable-agent/release.json', 0o444);" "${INSTALLER_INTEGRITY}" "${MCP_INTEGRITY}" \
|
|
29
29
|
&& npm cache clean --force
|
|
30
30
|
|
|
31
31
|
COPY entrypoint.sh /usr/local/bin/sellable-agent-container-entrypoint
|
package/container/README.md
CHANGED
|
@@ -3,13 +3,13 @@
|
|
|
3
3
|
This image is a dedicated Agent worker/runtime boundary beside an existing Hermes dashboard. It never replaces or reconfigures the dashboard container.
|
|
4
4
|
|
|
5
5
|
Build from this directory after
|
|
6
|
-
`@sellable/install@0.1.
|
|
6
|
+
`@sellable/install@0.1.610-wip.phase187.20260811.18` is
|
|
7
7
|
published:
|
|
8
8
|
|
|
9
9
|
```sh
|
|
10
10
|
docker build --platform linux/amd64 \
|
|
11
11
|
--build-arg INSTALLER_INTEGRITY='sha512-…' \
|
|
12
|
-
--tag sellable-agent-host:0.1.
|
|
12
|
+
--tag sellable-agent-host:0.1.608-wip.phase187.20260811.16-wip.hermes-desktop.20260811160530 .
|
|
13
13
|
```
|
|
14
14
|
|
|
15
15
|
Create a private `bootstrap/` directory owned by root with mode `0700`. It must contain `bootstrap.json`, `provider-auth`, and `slack-app`, each owned by root with mode `0600`. `bootstrap.json` contains only non-secret identities, hashes, package integrities, and the control-plane URL. The other two files contain the provider JSON and global Slack app token whose hashes are pinned by `bootstrap.json`.
|
|
@@ -20,6 +20,7 @@ import { createHash } from "node:crypto";
|
|
|
20
20
|
|
|
21
21
|
const SHA256 = /^[a-f0-9]{64}$/;
|
|
22
22
|
const EXACT_VERSION = /^\d+\.\d+\.\d+(?:[-.A-Za-z0-9]+)?$/;
|
|
23
|
+
const PACKAGE_DISPOSITIONS = new Set(["changed", "reused"]);
|
|
23
24
|
const PUBLIC_ACTIONS = new Set(["INSTANTIATE", "REFRESH"]);
|
|
24
25
|
const RESTORATION_ACTIONS = new Set([
|
|
25
26
|
"START",
|
|
@@ -64,14 +65,13 @@ export function validateAdminRuntimeTuple(tuple) {
|
|
|
64
65
|
}
|
|
65
66
|
for (const name of ADMIN_RUNTIME_TUPLE_MEMBERS) {
|
|
66
67
|
const item = tuple.packages[name];
|
|
67
|
-
const expectedDisposition = name === "@sellable/mcp" ? "reused" : "changed";
|
|
68
68
|
if (
|
|
69
69
|
!item ||
|
|
70
70
|
item.name !== name ||
|
|
71
71
|
!EXACT_VERSION.test(item.version ?? "") ||
|
|
72
72
|
typeof item.integrity !== "string" ||
|
|
73
73
|
!/^sha512-[A-Za-z0-9+/]{80,}={0,2}$/.test(item.integrity) ||
|
|
74
|
-
item.disposition
|
|
74
|
+
!PACKAGE_DISPOSITIONS.has(item.disposition)
|
|
75
75
|
) {
|
|
76
76
|
return {
|
|
77
77
|
ok: false,
|
|
@@ -28,7 +28,7 @@ import {
|
|
|
28
28
|
|
|
29
29
|
const MANIFEST_VERSION = "sellable-agent-external-runtime-closure/v1";
|
|
30
30
|
const MCP_PACKAGE = "@sellable/mcp";
|
|
31
|
-
const MCP_VERSION = "0.1.
|
|
31
|
+
const MCP_VERSION = "0.1.865-wip.phase187.20260811.15";
|
|
32
32
|
const SAFE_COMPONENT = /^[A-Za-z0-9@._+-]+$/;
|
|
33
33
|
const HERMES_EXCLUDES = new Set([".git", ".playwright", "node_modules"]);
|
|
34
34
|
|
|
@@ -1,4 +1,17 @@
|
|
|
1
1
|
ARG HERMES_IMAGE=nousresearch/hermes-agent@sha256:c0cab4e3711bcb27a312be1b3776254fc06fd50d5f7a6b8017915fc7171cb39e
|
|
2
|
+
ARG SLACK_PP_GO_IMAGE=golang@sha256:386d475a660466863d9f8c766fec64d7fdad3edac2c6a05020c09534d71edb4b
|
|
3
|
+
|
|
4
|
+
FROM ${SLACK_PP_GO_IMAGE} AS slack-pp-cli-builder
|
|
5
|
+
|
|
6
|
+
ARG SLACK_PP_CLI_PACKAGE=github.com/mvanhorn/printing-press-library/library/productivity/slack/cmd/slack-pp-cli@v0.0.0-20260519210111-529e9728df37
|
|
7
|
+
ARG SLACK_PP_CLI_SHA256=2d7289d9e0d7f6ab85e2f650dfb95d1841ea6a1e97c31f74b91e9f0b71b39a8e
|
|
8
|
+
|
|
9
|
+
RUN set -eux; \
|
|
10
|
+
install -d -m 0755 /out; \
|
|
11
|
+
env GOBIN=/out CGO_ENABLED=0 GOOS=linux GOARCH=amd64 \
|
|
12
|
+
go install -trimpath "${SLACK_PP_CLI_PACKAGE}"; \
|
|
13
|
+
test "$(sha256sum /out/slack-pp-cli | cut -d ' ' -f 1)" = "${SLACK_PP_CLI_SHA256}"
|
|
14
|
+
|
|
2
15
|
FROM ${HERMES_IMAGE}
|
|
3
16
|
|
|
4
17
|
USER root
|
|
@@ -20,6 +33,8 @@ ARG TUS_JS_CLIENT_VERSION=4.3.1
|
|
|
20
33
|
ARG STRIPE_CLI_PACKAGE=@stripe/cli-linux-x64@1.45.0
|
|
21
34
|
ARG STRIPE_CLI_INTEGRITY=sha512-1ZhoPpoweYfynqsvhCLlTjZ7lPz5IKtxqAMT5MBy6zrwLRTP9x0T6r8h/jLYL8lRH1c7zC/6X6/XUu2V+r9Bog==
|
|
22
35
|
|
|
36
|
+
COPY --from=slack-pp-cli-builder --chmod=0555 /out/slack-pp-cli /usr/local/bin/slack-pp-cli
|
|
37
|
+
|
|
23
38
|
RUN set -eux; \
|
|
24
39
|
test -n "${ADMIN_PACKAGE_LOCK_B64}"; \
|
|
25
40
|
test -n "${ADMIN_PROFILE_CONTRACT_TEMPLATE_B64}"; \
|
|
@@ -65,6 +80,7 @@ RUN set -eux; \
|
|
|
65
80
|
stripe_cli_version="$(node -p "require('/usr/local/lib/sellable-agent/stripe-cli/node_modules/@stripe/cli-linux-x64/package.json').version")"; \
|
|
66
81
|
test "$(stripe version | head -n 1)" = "stripe version ${stripe_cli_version}"; \
|
|
67
82
|
test "$(node -p "require('/usr/local/lib/sellable-agent/node_modules/tus-js-client/package.json').version")" = "${TUS_JS_CLIENT_VERSION}"; \
|
|
83
|
+
slack-pp-cli --help >/dev/null; \
|
|
68
84
|
test -f /usr/local/lib/sellable-agent/admin-artifact/node_modules/@sellable/install/lib/sellable-agent/admin-runtime-reconciler.mjs; \
|
|
69
85
|
test -f /usr/local/lib/sellable-agent/admin-artifact/node_modules/@sellable/admin-mcp/dist/index.js; \
|
|
70
86
|
node -e 'const p=require("/usr/local/lib/sellable-agent/admin-artifact/node_modules/@sellable/admin-mcp/package.json"); if(p.main!=="dist/index.js" || p.bin?.["sellable-admin-mcp"]!=="dist/index.js") process.exit(1);'; \
|
|
@@ -67,9 +67,11 @@ import {
|
|
|
67
67
|
HERMES_SNAPSHOT_HOOKS,
|
|
68
68
|
HERMES_SNAPSHOT_HOOK_ALLOWLIST_BYTES,
|
|
69
69
|
applyHermesHostedBackgroundReviewPolicy,
|
|
70
|
+
ensureHermesOpportunitySequencesCron,
|
|
70
71
|
ensureHermesSnapshotCron,
|
|
71
72
|
markHermesSnapshotDirty,
|
|
72
73
|
mergeHermesState,
|
|
74
|
+
migrateLegacyHermesUserState,
|
|
73
75
|
reconcileHermesSnapshot,
|
|
74
76
|
restoreLatestHermesSnapshot,
|
|
75
77
|
} from "../hermes-memory-snapshot.mjs";
|
|
@@ -382,18 +384,14 @@ function installAdminHome({ settingsRoot, layout }) {
|
|
|
382
384
|
} catch {
|
|
383
385
|
throw new Error("admin_runtime_admin_home_wrappers_rejected");
|
|
384
386
|
}
|
|
385
|
-
// The
|
|
386
|
-
//
|
|
387
|
-
// not carry. Every wrapper it generates from local bytes must still be ready.
|
|
387
|
+
// The sealed image carries the checksum-pinned Printing Press binary, so
|
|
388
|
+
// every wrapper generated from local bytes must be immediately usable.
|
|
388
389
|
if (
|
|
389
390
|
generated.error ||
|
|
390
391
|
summary?.adminHome !== layout.adminHome ||
|
|
391
392
|
!Array.isArray(summary.wrappers) ||
|
|
392
393
|
summary.wrappers.length < 1 ||
|
|
393
|
-
summary.wrappers.some(
|
|
394
|
-
(wrapper) =>
|
|
395
|
-
wrapper?.kind !== "external-binary" && wrapper?.ready !== true
|
|
396
|
-
)
|
|
394
|
+
summary.wrappers.some((wrapper) => wrapper?.ready !== true)
|
|
397
395
|
) {
|
|
398
396
|
throw new Error("admin_runtime_admin_home_wrappers_rejected");
|
|
399
397
|
}
|
|
@@ -696,6 +694,22 @@ const ADMIN_LIVE_SKILLS_CONFIG_KEYS = Object.freeze([
|
|
|
696
694
|
"disabled",
|
|
697
695
|
"platform_disabled",
|
|
698
696
|
]);
|
|
697
|
+
function packagedAdminSkillDirectories() {
|
|
698
|
+
const skillsRoot = join(ADMIN_INSTALL_ASSET_ROOT, "mcp", "skills");
|
|
699
|
+
const directories = new Set(["sellable"]);
|
|
700
|
+
for (const entry of readdirSync(skillsRoot, { withFileTypes: true })) {
|
|
701
|
+
if (entry.isSymbolicLink() || !entry.isDirectory()) {
|
|
702
|
+
throw new Error("admin_runtime_packaged_skills_inventory_rejected");
|
|
703
|
+
}
|
|
704
|
+
directories.add(entry.name);
|
|
705
|
+
}
|
|
706
|
+
return directories;
|
|
707
|
+
}
|
|
708
|
+
|
|
709
|
+
// Candidate run 31458025989 proved that a fresh profile must not classify
|
|
710
|
+
// package-backed Admin skills as operator state: doing so made both allowed
|
|
711
|
+
// SOUL restage attempts compare an empty live inventory with the sealed stage.
|
|
712
|
+
const ADMIN_SEALED_SKILL_DIRECTORIES = packagedAdminSkillDirectories();
|
|
699
713
|
|
|
700
714
|
function adminPreservedSlackToolsets(config) {
|
|
701
715
|
const platformToolsets = config?.platform_toolsets;
|
|
@@ -715,17 +729,17 @@ function adminPreservedSlackToolsets(config) {
|
|
|
715
729
|
|
|
716
730
|
function adminPreservedSkillsIdentity(profileRoot) {
|
|
717
731
|
if (!existsSync(profileRoot)) return null;
|
|
718
|
-
const entries = [];
|
|
719
732
|
const skillsRoot = join(profileRoot, "skills");
|
|
720
733
|
const configPath = join(profileRoot, "config.yaml");
|
|
721
734
|
// Admin settings are delivered into .sellable-admin before the Hermes
|
|
722
735
|
// profile is staged. That settings-only directory is not an existing live
|
|
723
736
|
// profile and therefore has no skills state to preserve.
|
|
724
737
|
if (!existsSync(skillsRoot) && !existsSync(configPath)) return null;
|
|
738
|
+
const entries = [];
|
|
725
739
|
const walk = (directory, relativePath = "") => {
|
|
726
740
|
for (const name of readdirSync(directory).sort()) {
|
|
727
741
|
const nextRelative = relativePath ? `${relativePath}/${name}` : name;
|
|
728
|
-
if (nextRelative
|
|
742
|
+
if (ADMIN_SEALED_SKILL_DIRECTORIES.has(nextRelative)) continue;
|
|
729
743
|
const path = join(directory, name);
|
|
730
744
|
const stat = lstatSync(path);
|
|
731
745
|
if (stat.isSymbolicLink()) {
|
|
@@ -1032,12 +1046,22 @@ async function materializeAdminProfile({
|
|
|
1032
1046
|
hermesCli: HERMES,
|
|
1033
1047
|
});
|
|
1034
1048
|
if (!memoryCron.ok) throw new Error(memoryCron.code);
|
|
1049
|
+
const opportunitySequencesCron = await ensureHermesOpportunitySequencesCron({
|
|
1050
|
+
profileId: profile,
|
|
1051
|
+
profileRoot: profileHome,
|
|
1052
|
+
hermesRoot: DATA_ROOT,
|
|
1053
|
+
statePath: layout.statePath,
|
|
1054
|
+
});
|
|
1055
|
+
if (!opportunitySequencesCron.ok) {
|
|
1056
|
+
throw new Error(opportunitySequencesCron.code);
|
|
1057
|
+
}
|
|
1035
1058
|
return {
|
|
1036
1059
|
stage,
|
|
1037
1060
|
promotion: promoted.promotion,
|
|
1038
1061
|
profile,
|
|
1039
1062
|
profileHome,
|
|
1040
1063
|
adminHome,
|
|
1064
|
+
opportunitySequencesCron,
|
|
1041
1065
|
observedSoulRawSha256: promoted.observedSoulRawSha256,
|
|
1042
1066
|
servers: [serverProofs.sellable, serverProofs["sellable-admin"]].map(
|
|
1043
1067
|
({ tools: _tools, ...proof }) => proof
|
|
@@ -2491,6 +2515,7 @@ export async function runAdminCanary() {
|
|
|
2491
2515
|
}
|
|
2492
2516
|
const fixtureWorkspaceId = "phase158-canary-workspace";
|
|
2493
2517
|
const fixtureAgentId = "phase158-canary-admin-agent";
|
|
2518
|
+
const fixtureNotificationSlackUserId = "U187CANARY";
|
|
2494
2519
|
const fixtureFiles = {
|
|
2495
2520
|
".env": "PHASE158_ADMIN_CANARY=nonsecret\n",
|
|
2496
2521
|
"settings.json": `${JSON.stringify({
|
|
@@ -2503,6 +2528,9 @@ export async function runAdminCanary() {
|
|
|
2503
2528
|
})}\n`,
|
|
2504
2529
|
"config-state.json": `${JSON.stringify({
|
|
2505
2530
|
sellable: { workspaceIds: [], workspaceNames: {} },
|
|
2531
|
+
opportunitySequences: {
|
|
2532
|
+
notificationSlackUserId: fixtureNotificationSlackUserId,
|
|
2533
|
+
},
|
|
2506
2534
|
})}\n`,
|
|
2507
2535
|
};
|
|
2508
2536
|
for (const [name, value] of Object.entries(fixtureFiles)) {
|
|
@@ -3170,6 +3198,12 @@ async function runAdminProduction() {
|
|
|
3170
3198
|
fetchLatest: () => client.getMemorySnapshot(),
|
|
3171
3199
|
});
|
|
3172
3200
|
if (!memoryRestore.ok) throw new Error(memoryRestore.code);
|
|
3201
|
+
const legacyUserState = migrateLegacyHermesUserState({
|
|
3202
|
+
profileId: basename(profileContract.profileHome),
|
|
3203
|
+
profileRoot: profileContract.profileHome,
|
|
3204
|
+
hermesRoot: DATA_ROOT,
|
|
3205
|
+
});
|
|
3206
|
+
if (!legacyUserState.ok) throw new Error(legacyUserState.code);
|
|
3173
3207
|
const profile = await materializeAdminProfile({
|
|
3174
3208
|
profileContract,
|
|
3175
3209
|
settingsRoot: imported.receipt.generationRoot,
|
|
@@ -4,9 +4,9 @@ FROM ${HERMES_IMAGE}
|
|
|
4
4
|
|
|
5
5
|
USER root
|
|
6
6
|
|
|
7
|
-
ARG MCP_PACKAGE=@sellable/mcp@0.1.
|
|
8
|
-
ARG MCP_INTEGRITY=sha512-
|
|
9
|
-
ARG INSTALLER_PACKAGE=@sellable/install@0.1.
|
|
7
|
+
ARG MCP_PACKAGE=@sellable/mcp@0.1.865-wip.phase187.20260811.15
|
|
8
|
+
ARG MCP_INTEGRITY=sha512-eMgElGCRnQia1P9NUNuBoc3T/OKHbmDAGwurVljWK5ED+tifDYmXla3VWEmUrqImkthr+9zfJnApCqVBLZIpSA==
|
|
9
|
+
ARG INSTALLER_PACKAGE=@sellable/install@0.1.610-wip.phase187.20260811.18
|
|
10
10
|
ARG ADMIN_MCP_PACKAGE=@sellable/admin-mcp@0.1.186-wip.phase158.20260802034727
|
|
11
11
|
ARG ADMIN_MCP_INTEGRITY=sha512-qYNew5wd2IfgVcp1UYOG9QvpF/8Mx19YJ5HQtMKzvSfUf3evePjtaKsoXLf2C/GUJ5QlLlHJo84VWOI3V01+9A==
|
|
12
12
|
ARG TUS_JS_CLIENT_VERSION=4.3.1
|
|
@@ -44,6 +44,7 @@ import {
|
|
|
44
44
|
import {
|
|
45
45
|
ensureHermesSnapshotCron,
|
|
46
46
|
markHermesSnapshotDirty,
|
|
47
|
+
migrateLegacyHermesUserState,
|
|
47
48
|
reconcileHermesSnapshot,
|
|
48
49
|
restoreLatestHermesSnapshot,
|
|
49
50
|
} from "../hermes-memory-snapshot.mjs";
|
|
@@ -95,9 +96,9 @@ const RUNTIME_GENERATION = Number(
|
|
|
95
96
|
const BOOT_SESSION_ID = randomUUID();
|
|
96
97
|
const HERMES_VERSION = process.env.SELLABLE_AGENT_HERMES_VERSION ?? "0.20.0";
|
|
97
98
|
const INSTALLER_PACKAGE =
|
|
98
|
-
process.env.SELLABLE_AGENT_INSTALLER_PACKAGE ?? "@sellable/install@0.1.
|
|
99
|
+
process.env.SELLABLE_AGENT_INSTALLER_PACKAGE ?? "@sellable/install@0.1.610-wip.phase187.20260811.18";
|
|
99
100
|
const MCP_PACKAGE =
|
|
100
|
-
process.env.SELLABLE_AGENT_MCP_PACKAGE ?? "@sellable/mcp@0.1.
|
|
101
|
+
process.env.SELLABLE_AGENT_MCP_PACKAGE ?? "@sellable/mcp@0.1.865-wip.phase187.20260811.15";
|
|
101
102
|
|
|
102
103
|
const sha256 = (value) => createHash("sha256").update(value).digest("hex");
|
|
103
104
|
const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
@@ -2674,6 +2675,12 @@ async function processOperation({ claim, exchange, client, identity }) {
|
|
|
2674
2675
|
fetchLatest: () => client.getMemorySnapshot(),
|
|
2675
2676
|
});
|
|
2676
2677
|
if (!memoryRestore.ok) throw new Error(memoryRestore.code);
|
|
2678
|
+
const legacyUserState = migrateLegacyHermesUserState({
|
|
2679
|
+
profileId: desired.profileId,
|
|
2680
|
+
profileRoot,
|
|
2681
|
+
hermesRoot: DATA_ROOT,
|
|
2682
|
+
});
|
|
2683
|
+
if (!legacyUserState.ok) throw new Error(legacyUserState.code);
|
|
2677
2684
|
const materialized = materializeNativeSlackCustomerProfile({
|
|
2678
2685
|
desired,
|
|
2679
2686
|
profilesRoot: PROFILES_ROOT,
|
|
@@ -25,7 +25,7 @@ import { withProfileSoulLock } from "./fly-soul-bridge.mjs";
|
|
|
25
25
|
export const HERMES_SNAPSHOT_HOOKS = Object.freeze({
|
|
26
26
|
post_tool_call: Object.freeze([
|
|
27
27
|
Object.freeze({
|
|
28
|
-
matcher: "^(memory|skill_manage)$",
|
|
28
|
+
matcher: "^(cronjob|memory|skill_manage)$",
|
|
29
29
|
command: "/opt/sellable/bin/hermes-memory-dirty",
|
|
30
30
|
// Node startup can exceed one second when a shared-CPU customer is also
|
|
31
31
|
// serving Slack and an operator Desktop. Missing this hook defers a real
|
|
@@ -55,9 +55,20 @@ export const HERMES_SNAPSHOT_CRON = Object.freeze({
|
|
|
55
55
|
installedScript: "scripts/hermes-memory-reconcile.sh",
|
|
56
56
|
noAgent: true,
|
|
57
57
|
});
|
|
58
|
+
export const HERMES_OPPORTUNITY_SEQUENCES_CRON = Object.freeze({
|
|
59
|
+
name: "sellable-opportunity-sequences",
|
|
60
|
+
schedule: "every 30m",
|
|
61
|
+
deliver: "slack",
|
|
62
|
+
skills: Object.freeze(["sellable-admin-opportunity-sequences"]),
|
|
63
|
+
enabledToolsets: Object.freeze(["safe", "sellable", "mcp"]),
|
|
64
|
+
noAgent: false,
|
|
65
|
+
});
|
|
66
|
+
export const HERMES_OPPORTUNITY_SEQUENCES_JOURNAL_ROOT =
|
|
67
|
+
"/opt/data/.sellable-agent/admin-runtime/opportunity-sequences";
|
|
58
68
|
const LEGACY_HERMES_SNAPSHOT_SCRIPT = "scripts/hermes-memory-reconcile.sh";
|
|
59
69
|
|
|
60
70
|
const HERMES = "/opt/hermes/.venv/bin/hermes";
|
|
71
|
+
const HERMES_PYTHON = "/opt/hermes/.venv/bin/python";
|
|
61
72
|
const VERSION = "0.20.0";
|
|
62
73
|
const ID = /^[A-Za-z0-9][A-Za-z0-9_-]{0,127}$/;
|
|
63
74
|
const SHA256 = /^[a-f0-9]{64}$/;
|
|
@@ -125,6 +136,8 @@ const SNAPSHOT_TRANSIENT_DIRECTORIES = new Set([
|
|
|
125
136
|
"venv",
|
|
126
137
|
]);
|
|
127
138
|
const SOUL_LOCK_ROOT = "soul-locks";
|
|
139
|
+
const LEGACY_USER_STATE_MIGRATION_SCHEMA =
|
|
140
|
+
"sellable-hermes-legacy-user-state-migration/v1";
|
|
128
141
|
const RESTORE_STATE_SCHEMA = "sellable-hermes-restore-state/v1";
|
|
129
142
|
const RETRY_STATE_SCHEMA = "sellable-hermes-snapshot-retry/v1";
|
|
130
143
|
const snapshotReconciles = new Map();
|
|
@@ -262,6 +275,68 @@ function cronJobs(profileRoot) {
|
|
|
262
275
|
return jobs;
|
|
263
276
|
}
|
|
264
277
|
|
|
278
|
+
const sameJson = (left, right) =>
|
|
279
|
+
JSON.stringify(left) === JSON.stringify(right);
|
|
280
|
+
|
|
281
|
+
export async function ensureHermesNamedCron({
|
|
282
|
+
profileRoot,
|
|
283
|
+
name,
|
|
284
|
+
isExpected,
|
|
285
|
+
isUpdatable = () => true,
|
|
286
|
+
create,
|
|
287
|
+
update,
|
|
288
|
+
codePrefix = "hermes_named_cron",
|
|
289
|
+
}) {
|
|
290
|
+
if (
|
|
291
|
+
!isAbsolute(profileRoot) ||
|
|
292
|
+
!ID.test(name ?? "") ||
|
|
293
|
+
typeof isExpected !== "function" ||
|
|
294
|
+
typeof create !== "function" ||
|
|
295
|
+
typeof update !== "function"
|
|
296
|
+
) {
|
|
297
|
+
return failed(`${codePrefix}_identity_rejected`);
|
|
298
|
+
}
|
|
299
|
+
try {
|
|
300
|
+
const before = cronJobs(profileRoot);
|
|
301
|
+
const named = before.filter((job) => job?.name === name);
|
|
302
|
+
if (named.length > 1 || (named[0] && !isUpdatable(named[0]))) {
|
|
303
|
+
return failed(`${codePrefix}_inventory_rejected`);
|
|
304
|
+
}
|
|
305
|
+
if (named[0] && isExpected(named[0])) {
|
|
306
|
+
return {
|
|
307
|
+
ok: true,
|
|
308
|
+
status: "REUSED",
|
|
309
|
+
jobId: named[0].id,
|
|
310
|
+
job: named[0],
|
|
311
|
+
};
|
|
312
|
+
}
|
|
313
|
+
const siblings = before.filter((job) => job?.name !== name);
|
|
314
|
+
const mutation = named[0] ? await update(named[0]) : await create();
|
|
315
|
+
if (childFailed(mutation)) {
|
|
316
|
+
return failed(`${codePrefix}_${named[0] ? "update" : "create"}_failed`);
|
|
317
|
+
}
|
|
318
|
+
const after = cronJobs(profileRoot);
|
|
319
|
+
const readback = after.filter((job) => job?.name === name);
|
|
320
|
+
const afterSiblings = after.filter((job) => job?.name !== name);
|
|
321
|
+
if (!sameJson(afterSiblings, siblings)) {
|
|
322
|
+
return failed(`${codePrefix}_sibling_readback_rejected`);
|
|
323
|
+
}
|
|
324
|
+
if (readback.length !== 1 || !isExpected(readback[0])) {
|
|
325
|
+
return failed(
|
|
326
|
+
`${codePrefix}_${named[0] ? "update_readback" : "readback"}_rejected`
|
|
327
|
+
);
|
|
328
|
+
}
|
|
329
|
+
return {
|
|
330
|
+
ok: true,
|
|
331
|
+
status: named[0] ? "UPDATED" : "CREATED",
|
|
332
|
+
jobId: readback[0].id,
|
|
333
|
+
job: readback[0],
|
|
334
|
+
};
|
|
335
|
+
} catch {
|
|
336
|
+
return failed(`${codePrefix}_install_failed`);
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
|
|
265
340
|
function isCron(job) {
|
|
266
341
|
return Boolean(
|
|
267
342
|
job?.id &&
|
|
@@ -396,6 +471,118 @@ function stageHermesUserState({ profileId, profileRoot, hermesRoot }) {
|
|
|
396
471
|
return stagingRoot;
|
|
397
472
|
}
|
|
398
473
|
|
|
474
|
+
function legacyUserStateMigrationMarker(profileRoot) {
|
|
475
|
+
return join(
|
|
476
|
+
profileRoot,
|
|
477
|
+
".sellable-agent",
|
|
478
|
+
"migrations",
|
|
479
|
+
"legacy-root-user-state-v1.json"
|
|
480
|
+
);
|
|
481
|
+
}
|
|
482
|
+
|
|
483
|
+
function readLegacyUserStateMigration(path, profileId) {
|
|
484
|
+
regularFile(path);
|
|
485
|
+
const value = JSON.parse(readFileSync(path, "utf8"));
|
|
486
|
+
if (
|
|
487
|
+
value?.schemaVersion !== LEGACY_USER_STATE_MIGRATION_SCHEMA ||
|
|
488
|
+
value.profileId !== profileId ||
|
|
489
|
+
!Array.isArray(value.entries) ||
|
|
490
|
+
value.entries.some(
|
|
491
|
+
(name) =>
|
|
492
|
+
typeof name !== "string" ||
|
|
493
|
+
!HERMES_SNAPSHOT_USER_STATE_ENTRIES.includes(name)
|
|
494
|
+
) ||
|
|
495
|
+
new Set(value.entries).size !== value.entries.length
|
|
496
|
+
) {
|
|
497
|
+
throw new Error("hermes_legacy_user_state_migration_rejected");
|
|
498
|
+
}
|
|
499
|
+
return value;
|
|
500
|
+
}
|
|
501
|
+
|
|
502
|
+
/**
|
|
503
|
+
* Move the pre-profile Hermes layout into the current profile exactly once.
|
|
504
|
+
*
|
|
505
|
+
* Older Admin Machines stored durable user state directly under HERMES_HOME
|
|
506
|
+
* (for example /opt/data/skills and /opt/data/cron). Profile isolation moved
|
|
507
|
+
* those paths under profiles/<id>. Snapshot restore cannot discover that
|
|
508
|
+
* unscoped state because it intentionally restores profile archives only.
|
|
509
|
+
* Stage only the same bounded user-state allowlist used by snapshots, merge
|
|
510
|
+
* without overwriting newer profile bytes, then mark the resulting profile
|
|
511
|
+
* dirty so the next portable snapshot becomes self-contained.
|
|
512
|
+
*/
|
|
513
|
+
export function migrateLegacyHermesUserState({
|
|
514
|
+
profileId,
|
|
515
|
+
profileRoot,
|
|
516
|
+
hermesRoot,
|
|
517
|
+
}) {
|
|
518
|
+
if (!validProfilePath(profileId, profileRoot, hermesRoot)) {
|
|
519
|
+
return failed("hermes_legacy_user_state_identity_rejected");
|
|
520
|
+
}
|
|
521
|
+
const marker = legacyUserStateMigrationMarker(profileRoot);
|
|
522
|
+
try {
|
|
523
|
+
if (existsSync(marker)) {
|
|
524
|
+
const receipt = readLegacyUserStateMigration(marker, profileId);
|
|
525
|
+
return {
|
|
526
|
+
ok: true,
|
|
527
|
+
status: "REUSED",
|
|
528
|
+
profileId,
|
|
529
|
+
entries: receipt.entries,
|
|
530
|
+
};
|
|
531
|
+
}
|
|
532
|
+
const entries = HERMES_SNAPSHOT_USER_STATE_ENTRIES.filter((name) =>
|
|
533
|
+
existsSync(join(hermesRoot, name))
|
|
534
|
+
);
|
|
535
|
+
if (entries.length === 0) {
|
|
536
|
+
return { ok: true, status: "NO_LEGACY_STATE", profileId, entries: [] };
|
|
537
|
+
}
|
|
538
|
+
const backupsRoot = join(hermesRoot, "backups");
|
|
539
|
+
mkdirSync(backupsRoot, { recursive: true, mode: 0o700 });
|
|
540
|
+
const stagingRoot = mkdtempSync(join(backupsRoot, ".legacy-user-state-"));
|
|
541
|
+
chmodSync(stagingRoot, 0o700);
|
|
542
|
+
try {
|
|
543
|
+
for (const name of entries) {
|
|
544
|
+
const source = join(hermesRoot, name);
|
|
545
|
+
const stat = lstatSync(source);
|
|
546
|
+
if (stat.isSymbolicLink()) {
|
|
547
|
+
throw new Error("hermes_legacy_user_state_symlink_rejected");
|
|
548
|
+
}
|
|
549
|
+
stageUserStateEntry(source, join(stagingRoot, name));
|
|
550
|
+
if (name.endsWith(".db")) {
|
|
551
|
+
for (const suffix of ["-wal", "-shm", "-journal"]) {
|
|
552
|
+
const sidecar = `${source}${suffix}`;
|
|
553
|
+
if (existsSync(sidecar)) {
|
|
554
|
+
stageUserStateEntry(
|
|
555
|
+
sidecar,
|
|
556
|
+
join(stagingRoot, `${name}${suffix}`)
|
|
557
|
+
);
|
|
558
|
+
}
|
|
559
|
+
}
|
|
560
|
+
}
|
|
561
|
+
}
|
|
562
|
+
mkdirSync(profileRoot, { recursive: true, mode: 0o700 });
|
|
563
|
+
mergeHermesState(stagingRoot, profileRoot);
|
|
564
|
+
if (entries.some((name) => !existsSync(join(profileRoot, name)))) {
|
|
565
|
+
throw new Error("hermes_legacy_user_state_readback_rejected");
|
|
566
|
+
}
|
|
567
|
+
atomicWrite(
|
|
568
|
+
marker,
|
|
569
|
+
`${JSON.stringify({
|
|
570
|
+
schemaVersion: LEGACY_USER_STATE_MIGRATION_SCHEMA,
|
|
571
|
+
profileId,
|
|
572
|
+
entries,
|
|
573
|
+
})}\n`,
|
|
574
|
+
0o600
|
|
575
|
+
);
|
|
576
|
+
markHermesSnapshotDirty(profileRoot);
|
|
577
|
+
return { ok: true, status: "MIGRATED", profileId, entries };
|
|
578
|
+
} finally {
|
|
579
|
+
rmSync(stagingRoot, { recursive: true, force: true });
|
|
580
|
+
}
|
|
581
|
+
} catch {
|
|
582
|
+
return failed("hermes_legacy_user_state_migration_failed");
|
|
583
|
+
}
|
|
584
|
+
}
|
|
585
|
+
|
|
399
586
|
export function markHermesSnapshotDirty(profileRoot) {
|
|
400
587
|
if (
|
|
401
588
|
!isAbsolute(profileRoot) ||
|
|
@@ -433,25 +620,23 @@ export async function ensureHermesSnapshotCron({
|
|
|
433
620
|
readFileSync(reconcileTemplatePath),
|
|
434
621
|
0o700
|
|
435
622
|
);
|
|
436
|
-
const
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
}
|
|
445
|
-
if (before[0]) {
|
|
446
|
-
if (isLegacyCron(before[0])) {
|
|
447
|
-
const migrated = await childRunner(runChild)(
|
|
623
|
+
const result = await ensureHermesNamedCron({
|
|
624
|
+
profileRoot,
|
|
625
|
+
name: HERMES_SNAPSHOT_CRON.name,
|
|
626
|
+
isExpected: isCron,
|
|
627
|
+
isUpdatable: (job) => isCron(job) || isLegacyCron(job),
|
|
628
|
+
codePrefix: "hermes_snapshot_cron",
|
|
629
|
+
create: () =>
|
|
630
|
+
childRunner(runChild)(
|
|
448
631
|
invocation(
|
|
449
632
|
[
|
|
450
633
|
"--profile",
|
|
451
634
|
profileId,
|
|
452
635
|
"cron",
|
|
453
|
-
"
|
|
454
|
-
|
|
636
|
+
"create",
|
|
637
|
+
HERMES_SNAPSHOT_CRON.schedule,
|
|
638
|
+
"--name",
|
|
639
|
+
HERMES_SNAPSHOT_CRON.name,
|
|
455
640
|
"--script",
|
|
456
641
|
HERMES_SNAPSHOT_CRON.script,
|
|
457
642
|
"--no-agent",
|
|
@@ -459,53 +644,216 @@ export async function ensureHermesSnapshotCron({
|
|
|
459
644
|
hermesRoot,
|
|
460
645
|
hermesCli
|
|
461
646
|
)
|
|
462
|
-
)
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
);
|
|
469
|
-
return afterMigration.length === 1 && isCron(afterMigration[0])
|
|
470
|
-
? {
|
|
471
|
-
ok: true,
|
|
472
|
-
status: "MIGRATED",
|
|
473
|
-
jobId: afterMigration[0].id,
|
|
647
|
+
),
|
|
648
|
+
update: (job) =>
|
|
649
|
+
childRunner(runChild)(
|
|
650
|
+
invocation(
|
|
651
|
+
[
|
|
652
|
+
"--profile",
|
|
474
653
|
profileId,
|
|
475
|
-
|
|
476
|
-
|
|
654
|
+
"cron",
|
|
655
|
+
"edit",
|
|
656
|
+
job.id,
|
|
657
|
+
"--script",
|
|
658
|
+
HERMES_SNAPSHOT_CRON.script,
|
|
659
|
+
"--no-agent",
|
|
660
|
+
],
|
|
661
|
+
hermesRoot,
|
|
662
|
+
hermesCli
|
|
663
|
+
)
|
|
664
|
+
),
|
|
665
|
+
});
|
|
666
|
+
if (!result.ok) {
|
|
667
|
+
if (result.code === "hermes_snapshot_cron_update_failed") {
|
|
668
|
+
return failed("hermes_snapshot_cron_migrate_failed");
|
|
669
|
+
}
|
|
670
|
+
if (result.code === "hermes_snapshot_cron_update_readback_rejected") {
|
|
671
|
+
return failed("hermes_snapshot_cron_migrate_readback_rejected");
|
|
477
672
|
}
|
|
478
|
-
return
|
|
673
|
+
return result;
|
|
479
674
|
}
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
675
|
+
return {
|
|
676
|
+
ok: true,
|
|
677
|
+
status: result.status === "UPDATED" ? "MIGRATED" : result.status,
|
|
678
|
+
jobId: result.jobId,
|
|
679
|
+
profileId,
|
|
680
|
+
};
|
|
681
|
+
} catch {
|
|
682
|
+
return failed("hermes_snapshot_cron_install_failed");
|
|
683
|
+
}
|
|
684
|
+
}
|
|
685
|
+
|
|
686
|
+
const OPPORTUNITY_SEQUENCE_ASSETS = Object.freeze([
|
|
687
|
+
"SKILL.md",
|
|
688
|
+
"references/outbound-multichannel-v1.md",
|
|
689
|
+
"references/positive-reply-to-agreed-meeting-v1.md",
|
|
690
|
+
]);
|
|
691
|
+
const SLACK_USER_ID = /^U[A-Z0-9]{8,20}$/;
|
|
692
|
+
const OPPORTUNITY_SEQUENCE_CRON_PYTHON = [
|
|
693
|
+
"import json,sys",
|
|
694
|
+
"from cron.jobs import create_job, update_job",
|
|
695
|
+
"value=json.loads(sys.argv[1])",
|
|
696
|
+
"job_id=value.pop('jobId', None)",
|
|
697
|
+
"enabled=value.pop('enabled')",
|
|
698
|
+
"result=update_job(job_id, {**value, 'enabled': enabled}) if job_id else create_job(**value)",
|
|
699
|
+
"print(json.dumps({'id': result.get('id') if result else None}))",
|
|
700
|
+
].join("\n");
|
|
701
|
+
|
|
702
|
+
function opportunitySequenceIdentity(profileRoot) {
|
|
703
|
+
const root = join(
|
|
704
|
+
profileRoot,
|
|
705
|
+
"skills",
|
|
706
|
+
"sellable-admin",
|
|
707
|
+
HERMES_OPPORTUNITY_SEQUENCES_CRON.skills[0]
|
|
708
|
+
);
|
|
709
|
+
return Object.fromEntries(
|
|
710
|
+
OPPORTUNITY_SEQUENCE_ASSETS.map((relative) => {
|
|
711
|
+
const path = join(root, relative);
|
|
712
|
+
regularFile(path);
|
|
713
|
+
return [relative, sha256(readFileSync(path))];
|
|
714
|
+
})
|
|
715
|
+
);
|
|
716
|
+
}
|
|
717
|
+
|
|
718
|
+
function opportunitySequencePrompt({
|
|
719
|
+
notificationSlackUserId,
|
|
720
|
+
journalRoot,
|
|
721
|
+
hashes,
|
|
722
|
+
}) {
|
|
723
|
+
return [
|
|
724
|
+
"Run the installed opportunity-sequences skill for one bounded page.",
|
|
725
|
+
`Use the private journal at ${journalRoot}.`,
|
|
726
|
+
`Require these installed asset hashes: ${JSON.stringify(hashes)}.`,
|
|
727
|
+
`End with a compact native Slack summary addressed to <@${notificationSlackUserId}>.`,
|
|
728
|
+
"Never send prospect outreach; never claim exactly-once delivery; never use a direct Slack or Lightfield transport outside the installed skill and Product MCP.",
|
|
729
|
+
].join(" ");
|
|
730
|
+
}
|
|
731
|
+
|
|
732
|
+
export async function ensureHermesOpportunitySequencesCron({
|
|
733
|
+
profileId,
|
|
734
|
+
profileRoot,
|
|
735
|
+
hermesRoot,
|
|
736
|
+
statePath,
|
|
737
|
+
journalRoot = HERMES_OPPORTUNITY_SEQUENCES_JOURNAL_ROOT,
|
|
738
|
+
hermesPython = HERMES_PYTHON,
|
|
739
|
+
runChild,
|
|
740
|
+
}) {
|
|
741
|
+
if (
|
|
742
|
+
!validProfilePath(profileId, profileRoot, hermesRoot) ||
|
|
743
|
+
!existsSync(profileRoot) ||
|
|
744
|
+
!isAbsolute(statePath) ||
|
|
745
|
+
!isAbsolute(journalRoot)
|
|
746
|
+
) {
|
|
747
|
+
return failed("hermes_opportunity_sequences_cron_identity_rejected");
|
|
748
|
+
}
|
|
749
|
+
try {
|
|
750
|
+
const stateStat = regularFile(statePath);
|
|
751
|
+
if ((stateStat.mode & 0o077) !== 0) {
|
|
752
|
+
return failed("hermes_opportunity_sequences_cron_state_mode_rejected");
|
|
753
|
+
}
|
|
754
|
+
const state = JSON.parse(readFileSync(statePath, "utf8"));
|
|
755
|
+
const notificationSlackUserId =
|
|
756
|
+
state?.opportunitySequences?.notificationSlackUserId;
|
|
757
|
+
if (!SLACK_USER_ID.test(notificationSlackUserId ?? "")) {
|
|
758
|
+
return failed("hermes_opportunity_sequences_cron_notification_rejected");
|
|
759
|
+
}
|
|
760
|
+
mkdirSync(journalRoot, { recursive: true, mode: 0o700 });
|
|
761
|
+
chmodSync(journalRoot, 0o700);
|
|
762
|
+
const journalStat = lstatSync(journalRoot);
|
|
763
|
+
if (
|
|
764
|
+
journalStat.isSymbolicLink() ||
|
|
765
|
+
!journalStat.isDirectory() ||
|
|
766
|
+
(journalStat.mode & 0o077) !== 0
|
|
767
|
+
) {
|
|
768
|
+
return failed("hermes_opportunity_sequences_cron_journal_rejected");
|
|
769
|
+
}
|
|
770
|
+
const hashes = opportunitySequenceIdentity(profileRoot);
|
|
771
|
+
const prompt = opportunitySequencePrompt({
|
|
772
|
+
notificationSlackUserId,
|
|
773
|
+
journalRoot,
|
|
774
|
+
hashes,
|
|
775
|
+
});
|
|
776
|
+
const expected = (job) =>
|
|
777
|
+
Boolean(
|
|
778
|
+
job?.id &&
|
|
779
|
+
job.name === HERMES_OPPORTUNITY_SEQUENCES_CRON.name &&
|
|
780
|
+
job.prompt === prompt &&
|
|
781
|
+
job.no_agent === false &&
|
|
782
|
+
job.enabled === true &&
|
|
783
|
+
job.deliver === HERMES_OPPORTUNITY_SEQUENCES_CRON.deliver &&
|
|
784
|
+
sameJson(job.skills, HERMES_OPPORTUNITY_SEQUENCES_CRON.skills) &&
|
|
785
|
+
sameJson(
|
|
786
|
+
job.enabled_toolsets,
|
|
787
|
+
HERMES_OPPORTUNITY_SEQUENCES_CRON.enabledToolsets
|
|
788
|
+
) &&
|
|
789
|
+
job.schedule?.kind === "interval" &&
|
|
790
|
+
job.schedule?.minutes === 30
|
|
791
|
+
);
|
|
792
|
+
const mutate = (jobId = null) => {
|
|
793
|
+
const spec = {
|
|
794
|
+
prompt,
|
|
795
|
+
schedule: HERMES_OPPORTUNITY_SEQUENCES_CRON.schedule,
|
|
796
|
+
name: HERMES_OPPORTUNITY_SEQUENCES_CRON.name,
|
|
797
|
+
deliver: HERMES_OPPORTUNITY_SEQUENCES_CRON.deliver,
|
|
798
|
+
skills: [...HERMES_OPPORTUNITY_SEQUENCES_CRON.skills],
|
|
799
|
+
enabled_toolsets: [
|
|
800
|
+
...HERMES_OPPORTUNITY_SEQUENCES_CRON.enabledToolsets,
|
|
493
801
|
],
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
802
|
+
no_agent: false,
|
|
803
|
+
enabled: true,
|
|
804
|
+
...(jobId ? { jobId } : {}),
|
|
805
|
+
};
|
|
806
|
+
return childRunner(runChild)({
|
|
807
|
+
command: hermesPython,
|
|
808
|
+
args: ["-c", OPPORTUNITY_SEQUENCE_CRON_PYTHON, JSON.stringify(spec)],
|
|
809
|
+
env: {
|
|
810
|
+
...process.env,
|
|
811
|
+
HOME: hermesRoot,
|
|
812
|
+
HERMES_HOME: profileRoot,
|
|
813
|
+
HERMES_PROFILE: profileId,
|
|
814
|
+
NO_COLOR: "1",
|
|
815
|
+
},
|
|
816
|
+
shell: false,
|
|
817
|
+
timeoutMs: NATIVE_COMMAND_TIMEOUT_MS,
|
|
818
|
+
maxOutputBytes: 64 * 1024,
|
|
819
|
+
});
|
|
820
|
+
};
|
|
821
|
+
const result = await ensureHermesNamedCron({
|
|
822
|
+
profileRoot,
|
|
823
|
+
name: HERMES_OPPORTUNITY_SEQUENCES_CRON.name,
|
|
824
|
+
isExpected: expected,
|
|
825
|
+
create: () => mutate(),
|
|
826
|
+
update: (job) => mutate(job.id),
|
|
827
|
+
codePrefix: "hermes_opportunity_sequences_cron",
|
|
828
|
+
});
|
|
829
|
+
if (!result.ok) return result;
|
|
830
|
+
const jobsMode =
|
|
831
|
+
lstatSync(join(profileRoot, "cron", "jobs.json")).mode & 0o777;
|
|
832
|
+
if ((jobsMode & 0o077) !== 0) {
|
|
833
|
+
return failed("hermes_opportunity_sequences_cron_jobs_mode_rejected");
|
|
500
834
|
}
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
:
|
|
835
|
+
return {
|
|
836
|
+
ok: true,
|
|
837
|
+
status: result.status,
|
|
838
|
+
jobId: result.jobId,
|
|
839
|
+
name: result.job.name,
|
|
840
|
+
prompt: result.job.prompt,
|
|
841
|
+
schedule: result.job.schedule,
|
|
842
|
+
profileId,
|
|
843
|
+
enabledToolsets: result.job.enabled_toolsets,
|
|
844
|
+
skills: result.job.skills,
|
|
845
|
+
assetHashes: hashes,
|
|
846
|
+
notificationSlackUserIdSource:
|
|
847
|
+
"config-state.json:opportunitySequences.notificationSlackUserId",
|
|
848
|
+
journalRoot,
|
|
849
|
+
modes: {
|
|
850
|
+
state: stateStat.mode & 0o777,
|
|
851
|
+
journal: journalStat.mode & 0o777,
|
|
852
|
+
jobs: jobsMode,
|
|
853
|
+
},
|
|
854
|
+
};
|
|
507
855
|
} catch {
|
|
508
|
-
return failed("
|
|
856
|
+
return failed("hermes_opportunity_sequences_cron_install_failed");
|
|
509
857
|
}
|
|
510
858
|
}
|
|
511
859
|
|
|
@@ -38,8 +38,8 @@ import { installAgentHostServices } from "./service-installer.mjs";
|
|
|
38
38
|
const PACKAGE_ROOT = resolve(dirname(fileURLToPath(import.meta.url)), "../..");
|
|
39
39
|
const VERSION = "sellable-agent-host-bootstrap/v1";
|
|
40
40
|
const RECEIPT_VERSION = "sellable-agent-host-registration/v1";
|
|
41
|
-
const INSTALLER_PACKAGE = "@sellable/install@0.1.
|
|
42
|
-
const MCP_PACKAGE = "@sellable/mcp@0.1.
|
|
41
|
+
const INSTALLER_PACKAGE = "@sellable/install@0.1.610-wip.phase187.20260811.18";
|
|
42
|
+
const MCP_PACKAGE = "@sellable/mcp@0.1.865-wip.phase187.20260811.15";
|
|
43
43
|
const HERMES_VERSION = "0.18.0";
|
|
44
44
|
const SHA256 = /^[a-f0-9]{64}$/;
|
|
45
45
|
const SHA256_16 = /^[a-f0-9]{16}$/;
|
|
@@ -1546,8 +1546,8 @@ export function compileClaimToProfileDesired(activeClaim, config) {
|
|
|
1546
1546
|
]) ||
|
|
1547
1547
|
pinned.hermesCli !== "hermes" ||
|
|
1548
1548
|
pinned.hermesVersion !== "0.18.0" ||
|
|
1549
|
-
pinned.installerPackage !== "@sellable/install@0.1.
|
|
1550
|
-
pinned.mcpPackage !== "@sellable/mcp@0.1.
|
|
1549
|
+
pinned.installerPackage !== "@sellable/install@0.1.610-wip.phase187.20260811.18" ||
|
|
1550
|
+
pinned.mcpPackage !== "@sellable/mcp@0.1.865-wip.phase187.20260811.15" ||
|
|
1551
1551
|
!Array.isArray(policy.toolInclude) ||
|
|
1552
1552
|
policy.toolInclude.length === 0 ||
|
|
1553
1553
|
!Number.isSafeInteger(slack.generation) ||
|
|
@@ -278,8 +278,8 @@ function validateDesired(desired) {
|
|
|
278
278
|
desired.serviceCredentialGeneration < 1 ||
|
|
279
279
|
desired.hermesCli !== "hermes" ||
|
|
280
280
|
desired.hermesVersion !== "0.18.0" ||
|
|
281
|
-
desired.installerPackage !== "@sellable/install@0.1.
|
|
282
|
-
desired.mcpPackage !== "@sellable/mcp@0.1.
|
|
281
|
+
desired.installerPackage !== "@sellable/install@0.1.610-wip.phase187.20260811.18" ||
|
|
282
|
+
desired.mcpPackage !== "@sellable/mcp@0.1.865-wip.phase187.20260811.15" ||
|
|
283
283
|
!Array.isArray(desired.toolInclude) ||
|
|
284
284
|
desired.toolInclude.length === 0 ||
|
|
285
285
|
desired.toolInclude.some((tool) => !/^[a-z][a-z0-9_]{0,127}$/.test(tool)) ||
|
|
@@ -25,8 +25,8 @@ import { fileURLToPath } from "node:url";
|
|
|
25
25
|
import { deriveContainedProfileId } from "./profile-materializer.mjs";
|
|
26
26
|
|
|
27
27
|
export const PROVISIONING_ACTION = "PROVISION_HERMES_PROFILE";
|
|
28
|
-
export const PINNED_INSTALL_PACKAGE = "@sellable/install@0.1.
|
|
29
|
-
export const PINNED_MCP_PACKAGE = "@sellable/mcp@0.1.
|
|
28
|
+
export const PINNED_INSTALL_PACKAGE = "@sellable/install@0.1.610-wip.phase187.20260811.18";
|
|
29
|
+
export const PINNED_MCP_PACKAGE = "@sellable/mcp@0.1.865-wip.phase187.20260811.15";
|
|
30
30
|
const PINNED_INSTALL_VERSION = PINNED_INSTALL_PACKAGE.slice(
|
|
31
31
|
PINNED_INSTALL_PACKAGE.lastIndexOf("@") + 1
|
|
32
32
|
);
|