@raidiant/notifai 11.7.1-beta.2 → 12.0.0-beta.5
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/CHANGELOG.md +56 -4
- package/NOTICE +16 -0
- package/THIRD_PARTY_NOTICES +725 -0
- package/bin/notifai.mjs +11387 -0
- package/data/install.ps1 +318 -0
- package/data/release.json +1 -0
- package/inventory.json +1 -0
- package/npm-adapter-files.json +52 -0
- package/package.json +14 -44
- package/README.md +0 -168
- package/dist/agent-update-notice.d.ts +0 -7
- package/dist/agent-update-notice.js +0 -77
- package/dist/agent-update-notice.js.map +0 -1
- package/dist/atomic-file.d.ts +0 -30
- package/dist/atomic-file.js +0 -148
- package/dist/atomic-file.js.map +0 -1
- package/dist/attendant-update.d.ts +0 -15
- package/dist/attendant-update.js +0 -96
- package/dist/attendant-update.js.map +0 -1
- package/dist/claude-wake.d.ts +0 -108
- package/dist/claude-wake.js +0 -369
- package/dist/claude-wake.js.map +0 -1
- package/dist/cli-bin.d.ts +0 -26
- package/dist/cli-bin.js +0 -220
- package/dist/cli-bin.js.map +0 -1
- package/dist/cli-contract.d.ts +0 -16
- package/dist/cli-contract.js +0 -27
- package/dist/cli-contract.js.map +0 -1
- package/dist/cli-release.d.ts +0 -36
- package/dist/cli-release.js +0 -85
- package/dist/cli-release.js.map +0 -1
- package/dist/client.d.ts +0 -109
- package/dist/client.js +0 -217
- package/dist/client.js.map +0 -1
- package/dist/codex-answer-control.d.ts +0 -14
- package/dist/codex-answer-control.js +0 -41
- package/dist/codex-answer-control.js.map +0 -1
- package/dist/codex-answer-presentation.d.ts +0 -18
- package/dist/codex-answer-presentation.js +0 -113
- package/dist/codex-answer-presentation.js.map +0 -1
- package/dist/codex-input-lifecycle.d.ts +0 -10
- package/dist/codex-input-lifecycle.js +0 -63
- package/dist/codex-input-lifecycle.js.map +0 -1
- package/dist/codex-native-control.d.ts +0 -13
- package/dist/codex-native-control.js +0 -120
- package/dist/codex-native-control.js.map +0 -1
- package/dist/codex-native-turn.d.ts +0 -37
- package/dist/codex-native-turn.js +0 -155
- package/dist/codex-native-turn.js.map +0 -1
- package/dist/codex-question-bindings.d.ts +0 -76
- package/dist/codex-question-bindings.js +0 -151
- package/dist/codex-question-bindings.js.map +0 -1
- package/dist/codex-queue-control.d.ts +0 -21
- package/dist/codex-queue-control.js +0 -59
- package/dist/codex-queue-control.js.map +0 -1
- package/dist/codex-tool-messages.d.ts +0 -7
- package/dist/codex-tool-messages.js +0 -126
- package/dist/codex-tool-messages.js.map +0 -1
- package/dist/codex-wake.d.ts +0 -58
- package/dist/codex-wake.js +0 -135
- package/dist/codex-wake.js.map +0 -1
- package/dist/command-session.d.ts +0 -14
- package/dist/command-session.js +0 -31
- package/dist/command-session.js.map +0 -1
- package/dist/commands-acknowledge.d.ts +0 -13
- package/dist/commands-acknowledge.js +0 -116
- package/dist/commands-acknowledge.js.map +0 -1
- package/dist/commands-agent-sessions.d.ts +0 -6
- package/dist/commands-agent-sessions.js +0 -51
- package/dist/commands-agent-sessions.js.map +0 -1
- package/dist/commands-ask.d.ts +0 -62
- package/dist/commands-ask.js +0 -503
- package/dist/commands-ask.js.map +0 -1
- package/dist/commands-auth.d.ts +0 -76
- package/dist/commands-auth.js +0 -421
- package/dist/commands-auth.js.map +0 -1
- package/dist/commands-close.d.ts +0 -6
- package/dist/commands-close.js +0 -273
- package/dist/commands-close.js.map +0 -1
- package/dist/commands-config.d.ts +0 -31
- package/dist/commands-config.js +0 -272
- package/dist/commands-config.js.map +0 -1
- package/dist/commands-core.d.ts +0 -145
- package/dist/commands-core.js +0 -190
- package/dist/commands-core.js.map +0 -1
- package/dist/commands-devices.d.ts +0 -41
- package/dist/commands-devices.js +0 -144
- package/dist/commands-devices.js.map +0 -1
- package/dist/commands-doctor.d.ts +0 -25
- package/dist/commands-doctor.js +0 -1553
- package/dist/commands-doctor.js.map +0 -1
- package/dist/commands-guidance.d.ts +0 -27
- package/dist/commands-guidance.js +0 -150
- package/dist/commands-guidance.js.map +0 -1
- package/dist/commands-harness-context.d.ts +0 -57
- package/dist/commands-harness-context.js +0 -102
- package/dist/commands-harness-context.js.map +0 -1
- package/dist/commands-hook-attend.d.ts +0 -70
- package/dist/commands-hook-attend.js +0 -655
- package/dist/commands-hook-attend.js.map +0 -1
- package/dist/commands-hook-diagnostics.d.ts +0 -37
- package/dist/commands-hook-diagnostics.js +0 -136
- package/dist/commands-hook-diagnostics.js.map +0 -1
- package/dist/commands-hook-install.d.ts +0 -26
- package/dist/commands-hook-install.js +0 -784
- package/dist/commands-hook-install.js.map +0 -1
- package/dist/commands-hook-run.d.ts +0 -29
- package/dist/commands-hook-run.js +0 -933
- package/dist/commands-hook-run.js.map +0 -1
- package/dist/commands-hook-shape.d.ts +0 -19
- package/dist/commands-hook-shape.js +0 -48
- package/dist/commands-hook-shape.js.map +0 -1
- package/dist/commands-init.d.ts +0 -42
- package/dist/commands-init.js +0 -901
- package/dist/commands-init.js.map +0 -1
- package/dist/commands-io.d.ts +0 -2
- package/dist/commands-io.js +0 -117
- package/dist/commands-io.js.map +0 -1
- package/dist/commands-logs.d.ts +0 -30
- package/dist/commands-logs.js +0 -201
- package/dist/commands-logs.js.map +0 -1
- package/dist/commands-native-acknowledge.d.ts +0 -8
- package/dist/commands-native-acknowledge.js +0 -114
- package/dist/commands-native-acknowledge.js.map +0 -1
- package/dist/commands-project.d.ts +0 -4
- package/dist/commands-project.js +0 -41
- package/dist/commands-project.js.map +0 -1
- package/dist/commands-receive.d.ts +0 -3
- package/dist/commands-receive.js +0 -59
- package/dist/commands-receive.js.map +0 -1
- package/dist/commands-send-support.d.ts +0 -59
- package/dist/commands-send-support.js +0 -258
- package/dist/commands-send-support.js.map +0 -1
- package/dist/commands-send.d.ts +0 -34
- package/dist/commands-send.js +0 -900
- package/dist/commands-send.js.map +0 -1
- package/dist/commands-setup-proof.d.ts +0 -43
- package/dist/commands-setup-proof.js +0 -134
- package/dist/commands-setup-proof.js.map +0 -1
- package/dist/commands-skill.d.ts +0 -21
- package/dist/commands-skill.js +0 -199
- package/dist/commands-skill.js.map +0 -1
- package/dist/commands-sounds.d.ts +0 -12
- package/dist/commands-sounds.js +0 -35
- package/dist/commands-sounds.js.map +0 -1
- package/dist/commands-update-check.d.ts +0 -6
- package/dist/commands-update-check.js +0 -102
- package/dist/commands-update-check.js.map +0 -1
- package/dist/commands-update-resume.d.ts +0 -7
- package/dist/commands-update-resume.js +0 -143
- package/dist/commands-update-resume.js.map +0 -1
- package/dist/commands-update-skill.d.ts +0 -5
- package/dist/commands-update-skill.js +0 -36
- package/dist/commands-update-skill.js.map +0 -1
- package/dist/commands-update.d.ts +0 -11
- package/dist/commands-update.js +0 -286
- package/dist/commands-update.js.map +0 -1
- package/dist/commands.d.ts +0 -26
- package/dist/commands.js +0 -27
- package/dist/commands.js.map +0 -1
- package/dist/config-schema.d.ts +0 -62
- package/dist/config-schema.js +0 -302
- package/dist/config-schema.js.map +0 -1
- package/dist/config.d.ts +0 -181
- package/dist/config.js +0 -357
- package/dist/config.js.map +0 -1
- package/dist/credentials.d.ts +0 -96
- package/dist/credentials.js +0 -342
- package/dist/credentials.js.map +0 -1
- package/dist/file-lock.d.ts +0 -34
- package/dist/file-lock.js +0 -367
- package/dist/file-lock.js.map +0 -1
- package/dist/generated-session-label.d.ts +0 -2
- package/dist/generated-session-label.js +0 -152
- package/dist/generated-session-label.js.map +0 -1
- package/dist/guidance-content.d.ts +0 -53
- package/dist/guidance-content.js +0 -248
- package/dist/guidance-content.js.map +0 -1
- package/dist/guidance-render.d.ts +0 -25
- package/dist/guidance-render.js +0 -47
- package/dist/guidance-render.js.map +0 -1
- package/dist/guidance.d.ts +0 -69
- package/dist/guidance.js +0 -173
- package/dist/guidance.js.map +0 -1
- package/dist/harness-session-title.d.ts +0 -22
- package/dist/harness-session-title.js +0 -74
- package/dist/harness-session-title.js.map +0 -1
- package/dist/harnesses.d.ts +0 -65
- package/dist/harnesses.js +0 -159
- package/dist/harnesses.js.map +0 -1
- package/dist/hermes-attendant.d.ts +0 -38
- package/dist/hermes-attendant.js +0 -337
- package/dist/hermes-attendant.js.map +0 -1
- package/dist/hermes-plugin.d.ts +0 -11
- package/dist/hermes-plugin.js +0 -299
- package/dist/hermes-plugin.js.map +0 -1
- package/dist/hook-acknowledgements.d.ts +0 -70
- package/dist/hook-acknowledgements.js +0 -490
- package/dist/hook-acknowledgements.js.map +0 -1
- package/dist/hook-adapter.d.ts +0 -48
- package/dist/hook-adapter.js +0 -419
- package/dist/hook-adapter.js.map +0 -1
- package/dist/hook-events.d.ts +0 -105
- package/dist/hook-events.js +0 -130
- package/dist/hook-events.js.map +0 -1
- package/dist/hook-gates.d.ts +0 -7
- package/dist/hook-gates.js +0 -20
- package/dist/hook-gates.js.map +0 -1
- package/dist/hook-input.d.ts +0 -10
- package/dist/hook-input.js +0 -64
- package/dist/hook-input.js.map +0 -1
- package/dist/hook-lifecycle.d.ts +0 -112
- package/dist/hook-lifecycle.js +0 -2031
- package/dist/hook-lifecycle.js.map +0 -1
- package/dist/hook-project-sessions.d.ts +0 -28
- package/dist/hook-project-sessions.js +0 -141
- package/dist/hook-project-sessions.js.map +0 -1
- package/dist/hook-question-lock.d.ts +0 -29
- package/dist/hook-question-lock.js +0 -217
- package/dist/hook-question-lock.js.map +0 -1
- package/dist/hook-question-retirement.d.ts +0 -74
- package/dist/hook-question-retirement.js +0 -314
- package/dist/hook-question-retirement.js.map +0 -1
- package/dist/hook-question-state.d.ts +0 -58
- package/dist/hook-question-state.js +0 -239
- package/dist/hook-question-state.js.map +0 -1
- package/dist/hook-session-state.d.ts +0 -127
- package/dist/hook-session-state.js +0 -488
- package/dist/hook-session-state.js.map +0 -1
- package/dist/hook-types.d.ts +0 -476
- package/dist/hook-types.js +0 -4
- package/dist/hook-types.js.map +0 -1
- package/dist/injection-render.d.ts +0 -36
- package/dist/injection-render.js +0 -61
- package/dist/injection-render.js.map +0 -1
- package/dist/install-hooks.d.ts +0 -470
- package/dist/install-hooks.js +0 -1622
- package/dist/install-hooks.js.map +0 -1
- package/dist/integration-health.d.ts +0 -26
- package/dist/integration-health.js +0 -133
- package/dist/integration-health.js.map +0 -1
- package/dist/interactive.d.ts +0 -22
- package/dist/interactive.js +0 -644
- package/dist/interactive.js.map +0 -1
- package/dist/invocation-context.d.ts +0 -47
- package/dist/invocation-context.js +0 -164
- package/dist/invocation-context.js.map +0 -1
- package/dist/local-path.d.ts +0 -7
- package/dist/local-path.js +0 -27
- package/dist/local-path.js.map +0 -1
- package/dist/logging.d.ts +0 -157
- package/dist/logging.js +0 -599
- package/dist/logging.js.map +0 -1
- package/dist/main-run.d.ts +0 -1
- package/dist/main-run.js +0 -42
- package/dist/main-run.js.map +0 -1
- package/dist/main.d.ts +0 -2
- package/dist/main.js +0 -12
- package/dist/main.js.map +0 -1
- package/dist/native-answer-operation.d.ts +0 -70
- package/dist/native-answer-operation.js +0 -247
- package/dist/native-answer-operation.js.map +0 -1
- package/dist/native-skills.d.ts +0 -64
- package/dist/native-skills.js +0 -167
- package/dist/native-skills.js.map +0 -1
- package/dist/node-floor.d.ts +0 -19
- package/dist/node-floor.js +0 -32
- package/dist/node-floor.js.map +0 -1
- package/dist/npm-invocation.d.ts +0 -34
- package/dist/npm-invocation.js +0 -53
- package/dist/npm-invocation.js.map +0 -1
- package/dist/openclaw-continuation-bridge.d.ts +0 -7
- package/dist/openclaw-continuation-bridge.js +0 -64
- package/dist/openclaw-continuation-bridge.js.map +0 -1
- package/dist/openclaw-gateway-readiness.d.ts +0 -1
- package/dist/openclaw-gateway-readiness.js +0 -24
- package/dist/openclaw-gateway-readiness.js.map +0 -1
- package/dist/openclaw-generation.d.ts +0 -21
- package/dist/openclaw-generation.js +0 -115
- package/dist/openclaw-generation.js.map +0 -1
- package/dist/openclaw-message-bridge.d.ts +0 -8
- package/dist/openclaw-message-bridge.js +0 -93
- package/dist/openclaw-message-bridge.js.map +0 -1
- package/dist/openclaw-pending.d.ts +0 -8
- package/dist/openclaw-pending.js +0 -47
- package/dist/openclaw-pending.js.map +0 -1
- package/dist/openclaw-plugin.d.ts +0 -75
- package/dist/openclaw-plugin.js +0 -1353
- package/dist/openclaw-plugin.js.map +0 -1
- package/dist/openclaw-session-access.d.ts +0 -12
- package/dist/openclaw-session-access.js +0 -79
- package/dist/openclaw-session-access.js.map +0 -1
- package/dist/opencode-plugin.d.ts +0 -88
- package/dist/opencode-plugin.js +0 -286
- package/dist/opencode-plugin.js.map +0 -1
- package/dist/orca-session-title.d.ts +0 -11
- package/dist/orca-session-title.js +0 -111
- package/dist/orca-session-title.js.map +0 -1
- package/dist/pack-feedback-slice.d.ts +0 -35
- package/dist/pack-feedback-slice.js +0 -126
- package/dist/pack-feedback-slice.js.map +0 -1
- package/dist/pairing-qr.d.ts +0 -5
- package/dist/pairing-qr.js +0 -24
- package/dist/pairing-qr.js.map +0 -1
- package/dist/pending-pairing.d.ts +0 -38
- package/dist/pending-pairing.js +0 -70
- package/dist/pending-pairing.js.map +0 -1
- package/dist/platform.d.ts +0 -67
- package/dist/platform.js +0 -140
- package/dist/platform.js.map +0 -1
- package/dist/process-identity.d.ts +0 -26
- package/dist/process-identity.js +0 -82
- package/dist/process-identity.js.map +0 -1
- package/dist/program.d.ts +0 -59
- package/dist/program.js +0 -691
- package/dist/program.js.map +0 -1
- package/dist/project-enablement.d.ts +0 -21
- package/dist/project-enablement.js +0 -71
- package/dist/project-enablement.js.map +0 -1
- package/dist/question-settlement-process.d.ts +0 -17
- package/dist/question-settlement-process.js +0 -35
- package/dist/question-settlement-process.js.map +0 -1
- package/dist/question-timing.d.ts +0 -46
- package/dist/question-timing.js +0 -48
- package/dist/question-timing.js.map +0 -1
- package/dist/readiness.d.ts +0 -153
- package/dist/readiness.js +0 -149
- package/dist/readiness.js.map +0 -1
- package/dist/release.d.ts +0 -31
- package/dist/release.js +0 -52
- package/dist/release.js.map +0 -1
- package/dist/send-attempts.d.ts +0 -26
- package/dist/send-attempts.js +0 -139
- package/dist/send-attempts.js.map +0 -1
- package/dist/send.d.ts +0 -115
- package/dist/send.js +0 -421
- package/dist/send.js.map +0 -1
- package/dist/session-activation.d.ts +0 -13
- package/dist/session-activation.js +0 -64
- package/dist/session-activation.js.map +0 -1
- package/dist/session-attendant-probe.d.ts +0 -85
- package/dist/session-attendant-probe.js +0 -173
- package/dist/session-attendant-probe.js.map +0 -1
- package/dist/session-attendant-state.d.ts +0 -70
- package/dist/session-attendant-state.js +0 -256
- package/dist/session-attendant-state.js.map +0 -1
- package/dist/session-attendant.d.ts +0 -143
- package/dist/session-attendant.js +0 -520
- package/dist/session-attendant.js.map +0 -1
- package/dist/session-delivery.d.ts +0 -249
- package/dist/session-delivery.js +0 -576
- package/dist/session-delivery.js.map +0 -1
- package/dist/session-handoff.d.ts +0 -98
- package/dist/session-handoff.js +0 -118
- package/dist/session-handoff.js.map +0 -1
- package/dist/session-input-wakes.d.ts +0 -78
- package/dist/session-input-wakes.js +0 -239
- package/dist/session-input-wakes.js.map +0 -1
- package/dist/session-inputs.d.ts +0 -57
- package/dist/session-inputs.js +0 -434
- package/dist/session-inputs.js.map +0 -1
- package/dist/session-labels.d.ts +0 -56
- package/dist/session-labels.js +0 -396
- package/dist/session-labels.js.map +0 -1
- package/dist/session-message-handoff.d.ts +0 -39
- package/dist/session-message-handoff.js +0 -107
- package/dist/session-message-handoff.js.map +0 -1
- package/dist/setup-destinations.d.ts +0 -23
- package/dist/setup-destinations.js +0 -44
- package/dist/setup-destinations.js.map +0 -1
- package/dist/skill-integrity.d.ts +0 -54
- package/dist/skill-integrity.js +0 -164
- package/dist/skill-integrity.js.map +0 -1
- package/dist/skill-source/manifest.json +0 -40
- package/dist/skill-source/notifai/SKILL.md +0 -350
- package/dist/skill-source/notifai/references/diagnostics.md +0 -36
- package/dist/skill-source/notifai/references/harness-setup.md +0 -384
- package/dist/skill-source/notifai/references/native-questions.md +0 -51
- package/dist/skill-source/notifai/references/notes-and-edits.md +0 -54
- package/dist/skill-source/notifai/references/send-details.md +0 -14
- package/dist/skill-source/notifai/references/updates.md +0 -116
- package/dist/skill-source/notifai/references/writing-examples.md +0 -56
- package/dist/sound-ref.d.ts +0 -23
- package/dist/sound-ref.js +0 -28
- package/dist/sound-ref.js.map +0 -1
- package/dist/ui/banner.d.ts +0 -22
- package/dist/ui/banner.js +0 -87
- package/dist/ui/banner.js.map +0 -1
- package/dist/ui/config-view.d.ts +0 -30
- package/dist/ui/config-view.js +0 -108
- package/dist/ui/config-view.js.map +0 -1
- package/dist/ui/help.d.ts +0 -44
- package/dist/ui/help.js +0 -107
- package/dist/ui/help.js.map +0 -1
- package/dist/ui/theme.d.ts +0 -90
- package/dist/ui/theme.js +0 -244
- package/dist/ui/theme.js.map +0 -1
- package/dist/update-handoff.d.ts +0 -29
- package/dist/update-handoff.js +0 -69
- package/dist/update-handoff.js.map +0 -1
- package/dist/url-policy.d.ts +0 -85
- package/dist/url-policy.js +0 -369
- package/dist/url-policy.js.map +0 -1
- package/dist/version.d.ts +0 -40
- package/dist/version.js +0 -132
- package/dist/version.js.map +0 -1
- package/dist/wake-support.d.ts +0 -40
- package/dist/wake-support.js +0 -95
- package/dist/wake-support.js.map +0 -1
package/dist/hermes-plugin.js
DELETED
|
@@ -1,299 +0,0 @@
|
|
|
1
|
-
import { spawnSync } from 'node:child_process';
|
|
2
|
-
import { existsSync, lstatSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from 'node:fs';
|
|
3
|
-
import os from 'node:os';
|
|
4
|
-
import path from 'node:path';
|
|
5
|
-
import { pathToFileURL } from 'node:url';
|
|
6
|
-
import { hookAdapterPath } from './hook-adapter.js';
|
|
7
|
-
import { accountHome } from './platform.js';
|
|
8
|
-
export const HERMES_PLUGIN_ID = 'notifai';
|
|
9
|
-
export const HERMES_PLUGIN_MARKER = '# notifai managed hermes plugin v1';
|
|
10
|
-
export function hermesPluginDir(env = process.env) {
|
|
11
|
-
const home = env['HERMES_HOME']?.trim() || path.join(accountHome(env, process.platform), '.hermes');
|
|
12
|
-
return path.join(home, 'plugins', HERMES_PLUGIN_ID);
|
|
13
|
-
}
|
|
14
|
-
export function hermesPluginSource(adapterPath, nodePath) {
|
|
15
|
-
const command = nodePath === undefined ? [adapterPath] : [nodePath, adapterPath];
|
|
16
|
-
return `${HERMES_PLUGIN_MARKER}
|
|
17
|
-
"""Notifai activation and Session Attendant for a local Hermes CLI session."""
|
|
18
|
-
import atexit
|
|
19
|
-
import json
|
|
20
|
-
import os
|
|
21
|
-
import select
|
|
22
|
-
import subprocess
|
|
23
|
-
import threading
|
|
24
|
-
import time
|
|
25
|
-
|
|
26
|
-
COMMAND = ${JSON.stringify(command)}
|
|
27
|
-
_attendants = {}
|
|
28
|
-
_lock = threading.RLock()
|
|
29
|
-
|
|
30
|
-
def _attached_session(ctx):
|
|
31
|
-
cli = getattr(ctx._manager, "_cli_ref", None)
|
|
32
|
-
return str(getattr(cli, "session_id", "") or "") if cli is not None else ""
|
|
33
|
-
|
|
34
|
-
def _run_attendant(ctx, session_id, cwd, stopped):
|
|
35
|
-
proc = None
|
|
36
|
-
wall_anchor = time.time_ns()
|
|
37
|
-
mono_anchor = time.monotonic_ns()
|
|
38
|
-
try:
|
|
39
|
-
proc = subprocess.Popen(COMMAND + ["hook", "hermes-attend", "--owner", "notifai", "--harness", "hermes"],
|
|
40
|
-
cwd=cwd, stdin=subprocess.PIPE, stdout=subprocess.PIPE,
|
|
41
|
-
stderr=subprocess.DEVNULL, text=True, bufsize=1)
|
|
42
|
-
with _lock:
|
|
43
|
-
_attendants[session_id] = (stopped, proc)
|
|
44
|
-
def send(frame):
|
|
45
|
-
with _lock:
|
|
46
|
-
if proc.stdin is None or proc.stdin.closed:
|
|
47
|
-
return False
|
|
48
|
-
try:
|
|
49
|
-
proc.stdin.write(json.dumps(frame, ensure_ascii=False) + "\\n")
|
|
50
|
-
proc.stdin.flush()
|
|
51
|
-
return True
|
|
52
|
-
except (OSError, ValueError):
|
|
53
|
-
return False
|
|
54
|
-
if not send({"type": "hello", "session_id": session_id, "cwd": cwd, "pid": os.getpid()}):
|
|
55
|
-
return
|
|
56
|
-
pending = bytearray()
|
|
57
|
-
while not stopped.is_set() and proc.poll() is None:
|
|
58
|
-
with _lock:
|
|
59
|
-
current = _attached_session(ctx)
|
|
60
|
-
working = bool(getattr(ctx._manager._cli_ref, "_agent_running", False)) if current == session_id else False
|
|
61
|
-
if current != session_id:
|
|
62
|
-
break
|
|
63
|
-
if not send({"type": "state", "session_id": session_id,
|
|
64
|
-
"activity": "working" if working else "idle"}):
|
|
65
|
-
break
|
|
66
|
-
readable, _, _ = select.select([proc.stdout], [], [], 1.0)
|
|
67
|
-
if not readable:
|
|
68
|
-
continue
|
|
69
|
-
chunk = os.read(proc.stdout.fileno(), 65536)
|
|
70
|
-
if not chunk:
|
|
71
|
-
break
|
|
72
|
-
pending.extend(chunk)
|
|
73
|
-
if len(pending) > 2 * 1024 * 1024:
|
|
74
|
-
break
|
|
75
|
-
while b"\\n" in pending:
|
|
76
|
-
raw, _, rest = pending.partition(b"\\n")
|
|
77
|
-
pending = bytearray(rest)
|
|
78
|
-
try:
|
|
79
|
-
frame = json.loads(raw.decode("utf-8"))
|
|
80
|
-
except (UnicodeDecodeError, ValueError):
|
|
81
|
-
continue
|
|
82
|
-
if frame.get("type") != "write" or not isinstance(frame.get("id"), int):
|
|
83
|
-
continue
|
|
84
|
-
accepted = False
|
|
85
|
-
with _lock:
|
|
86
|
-
wall_now = time.time_ns()
|
|
87
|
-
mono_now = time.monotonic_ns()
|
|
88
|
-
# Fail closed after a backward wall-clock step. Node's
|
|
89
|
-
# deadline is wall time because its monotonic origin may
|
|
90
|
-
# differ from Python's on the same macOS host.
|
|
91
|
-
clock_stable = wall_now - wall_anchor + 100_000_000 >= mono_now - mono_anchor
|
|
92
|
-
deadline = frame.get("deadline_ms")
|
|
93
|
-
if (not stopped.is_set() and frame.get("session_id") == session_id and
|
|
94
|
-
_attached_session(ctx) == session_id and
|
|
95
|
-
type(deadline) is int and wall_now < deadline * 1_000_000 and clock_stable):
|
|
96
|
-
try:
|
|
97
|
-
accepted = bool(ctx.inject_message(frame.get("text", "")))
|
|
98
|
-
except Exception:
|
|
99
|
-
pass
|
|
100
|
-
send({"type": "result", "id": frame["id"], "accepted": accepted,
|
|
101
|
-
"reason": "session-replaced" if not accepted else ""})
|
|
102
|
-
send({"type": "end", "session_id": session_id})
|
|
103
|
-
except (OSError, ValueError):
|
|
104
|
-
pass
|
|
105
|
-
finally:
|
|
106
|
-
with _lock:
|
|
107
|
-
if _attendants.get(session_id, (None, None))[0] is stopped:
|
|
108
|
-
_attendants.pop(session_id, None)
|
|
109
|
-
if proc is not None:
|
|
110
|
-
try:
|
|
111
|
-
if proc.stdin is not None:
|
|
112
|
-
proc.stdin.close()
|
|
113
|
-
proc.wait(timeout=4)
|
|
114
|
-
except (OSError, subprocess.TimeoutExpired):
|
|
115
|
-
proc.terminate()
|
|
116
|
-
try:
|
|
117
|
-
proc.wait(timeout=2)
|
|
118
|
-
except subprocess.TimeoutExpired:
|
|
119
|
-
proc.kill()
|
|
120
|
-
|
|
121
|
-
def _start_attendant(ctx, session_id, cwd):
|
|
122
|
-
if os.name == "nt":
|
|
123
|
-
return
|
|
124
|
-
with _lock:
|
|
125
|
-
if _attached_session(ctx) != session_id or os.environ.get("HERMES_SESSION_ID") != session_id:
|
|
126
|
-
return
|
|
127
|
-
if session_id in _attendants:
|
|
128
|
-
return
|
|
129
|
-
stopped = threading.Event()
|
|
130
|
-
_attendants[session_id] = (stopped, None)
|
|
131
|
-
threading.Thread(target=_run_attendant, args=(ctx, session_id, cwd, stopped),
|
|
132
|
-
daemon=True, name="notifai-hermes-attendant").start()
|
|
133
|
-
|
|
134
|
-
def _stop_attendant(session_id):
|
|
135
|
-
with _lock:
|
|
136
|
-
item = _attendants.get(session_id)
|
|
137
|
-
if item is None:
|
|
138
|
-
return
|
|
139
|
-
stopped, proc = item
|
|
140
|
-
stopped.set()
|
|
141
|
-
if proc is not None and proc.stdin is not None and not proc.stdin.closed:
|
|
142
|
-
try:
|
|
143
|
-
proc.stdin.write(json.dumps({"type": "end", "session_id": session_id}) + "\\n")
|
|
144
|
-
proc.stdin.flush()
|
|
145
|
-
except (OSError, ValueError):
|
|
146
|
-
pass
|
|
147
|
-
|
|
148
|
-
def _stop_all():
|
|
149
|
-
for session_id in list(_attendants):
|
|
150
|
-
_stop_attendant(session_id)
|
|
151
|
-
|
|
152
|
-
def _activation(info):
|
|
153
|
-
platform = str(info.get("platform") or "")
|
|
154
|
-
if platform not in ("cli", "subagent"):
|
|
155
|
-
return ""
|
|
156
|
-
if os.environ.get("HERMES_SESSION_SOURCE", "").lower() not in ("", "cli"):
|
|
157
|
-
return ""
|
|
158
|
-
# Hermes may import gateway.run inside a classic CLI and set its process
|
|
159
|
-
# marker there. The attached CLI object and exact session are the proof.
|
|
160
|
-
if os.environ.get("HERMES_TUI_ACTIVE_SESSION_FILE"):
|
|
161
|
-
return ""
|
|
162
|
-
if os.environ.get("TERMINAL_ENV", "").lower() not in ("", "local"):
|
|
163
|
-
return ""
|
|
164
|
-
if os.environ.get("HERMES_SESSION_KEY") or os.environ.get("HERMES_SESSION_PLATFORM"):
|
|
165
|
-
return ""
|
|
166
|
-
session_id = str(info.get("session_id") or "").strip()
|
|
167
|
-
if not session_id:
|
|
168
|
-
return ""
|
|
169
|
-
cwd = str(info.get("cwd") or "").strip()
|
|
170
|
-
if not cwd:
|
|
171
|
-
# A set but invalid TERMINAL_CWD cannot fall back to the launch dir.
|
|
172
|
-
if os.environ.get("TERMINAL_CWD", "").strip():
|
|
173
|
-
return ""
|
|
174
|
-
try:
|
|
175
|
-
cwd = os.getcwd()
|
|
176
|
-
except OSError:
|
|
177
|
-
return ""
|
|
178
|
-
if not os.path.isdir(cwd):
|
|
179
|
-
return ""
|
|
180
|
-
worker = platform == "subagent"
|
|
181
|
-
event = "subagent-start" if worker else "session-start"
|
|
182
|
-
envelope = {"session_id": session_id, "cwd": cwd,
|
|
183
|
-
"hook_event_name": "SubagentStart" if worker else "SessionStart"}
|
|
184
|
-
try:
|
|
185
|
-
result = subprocess.run(COMMAND + ["hook", event, "--owner", "notifai", "--harness", "hermes"],
|
|
186
|
-
input=json.dumps(envelope), text=True, capture_output=True,
|
|
187
|
-
timeout=10, check=False)
|
|
188
|
-
except (OSError, subprocess.TimeoutExpired):
|
|
189
|
-
return ""
|
|
190
|
-
content = result.stdout.strip() if result.returncode == 0 else ""
|
|
191
|
-
if content and not worker:
|
|
192
|
-
_start_attendant(_ctx, session_id, cwd)
|
|
193
|
-
return content
|
|
194
|
-
|
|
195
|
-
def register(ctx):
|
|
196
|
-
global _ctx
|
|
197
|
-
_ctx = ctx
|
|
198
|
-
ctx.register_system_prompt_section("notifai.activation", _activation,
|
|
199
|
-
position="after_memory", max_chars=4000)
|
|
200
|
-
ctx.register_hook("on_session_finalize", lambda session_id=None, **_: _stop_attendant(str(session_id or "")))
|
|
201
|
-
ctx.register_hook("on_session_reset", lambda session_id=None, **_: _stop_all())
|
|
202
|
-
atexit.register(_stop_all)
|
|
203
|
-
`;
|
|
204
|
-
}
|
|
205
|
-
export function isOurHermesPlugin(dir) {
|
|
206
|
-
try {
|
|
207
|
-
if (!lstatSync(dir).isDirectory() ||
|
|
208
|
-
!lstatSync(path.join(dir, '__init__.py')).isFile() ||
|
|
209
|
-
!lstatSync(path.join(dir, 'plugin.yaml')).isFile())
|
|
210
|
-
return false;
|
|
211
|
-
return readFileSync(path.join(dir, '__init__.py'), 'utf8').startsWith(HERMES_PLUGIN_MARKER) &&
|
|
212
|
-
/^name: notifai$/m.test(readFileSync(path.join(dir, 'plugin.yaml'), 'utf8'));
|
|
213
|
-
}
|
|
214
|
-
catch {
|
|
215
|
-
return false;
|
|
216
|
-
}
|
|
217
|
-
}
|
|
218
|
-
function hermesCommand(args, env) {
|
|
219
|
-
const result = spawnSync('hermes', ['plugins', ...args], {
|
|
220
|
-
env, encoding: 'utf8', timeout: 30_000, maxBuffer: 256 * 1024,
|
|
221
|
-
});
|
|
222
|
-
if (result.error || result.status !== 0) {
|
|
223
|
-
throw new Error(`Hermes plugin command failed: ${result.error?.message ?? result.stderr?.trim() ?? result.stdout?.trim() ?? 'unknown error'}`);
|
|
224
|
-
}
|
|
225
|
-
return result.stdout;
|
|
226
|
-
}
|
|
227
|
-
export function hermesVersionSupported(env = process.env) {
|
|
228
|
-
const result = spawnSync('hermes', ['--version'], {
|
|
229
|
-
env, encoding: 'utf8', timeout: 10_000, maxBuffer: 64 * 1024,
|
|
230
|
-
});
|
|
231
|
-
return result.status === 0 && /^Hermes Agent v0\.21\.5\b/m.test(result.stdout);
|
|
232
|
-
}
|
|
233
|
-
export function hermesPluginListed(env = process.env) {
|
|
234
|
-
return hermesCommand(['list', '--plain', '--no-bundled'], env)
|
|
235
|
-
.split(/\r?\n/)
|
|
236
|
-
.some(line => /^enabled\s+\S+\s+\S+\s+notifai\s*$/.test(line));
|
|
237
|
-
}
|
|
238
|
-
export function preflightHermesPlugin(env = process.env) {
|
|
239
|
-
const installed = hermesPluginDir(env);
|
|
240
|
-
if (existsSync(installed) && !isOurHermesPlugin(installed)) {
|
|
241
|
-
throw new Error('Hermes already has a foreign plugin named notifai; leave it unchanged');
|
|
242
|
-
}
|
|
243
|
-
if (!hermesVersionSupported(env)) {
|
|
244
|
-
throw new Error('Hermes v0.21.5 is required for the proven Notifai plugin integration');
|
|
245
|
-
}
|
|
246
|
-
if (!existsSync(installed) && hermesCommand(['list', '--plain'], env)
|
|
247
|
-
.split(/\r?\n/)
|
|
248
|
-
.some(line => /^(?:enabled|disabled|not enabled)\s+\S+\s+\S+\s+notifai\s*$/.test(line))) {
|
|
249
|
-
throw new Error('Hermes already discovers a foreign plugin named notifai; leave it unchanged');
|
|
250
|
-
}
|
|
251
|
-
}
|
|
252
|
-
export function installHermesPlugin(adapterPath, env = process.env, nodePath) {
|
|
253
|
-
const installed = hermesPluginDir(env);
|
|
254
|
-
preflightHermesPlugin(env);
|
|
255
|
-
const source = hermesPluginSource(adapterPath, nodePath);
|
|
256
|
-
if (existsSync(installed) && readFileSync(path.join(installed, '__init__.py'), 'utf8') === source) {
|
|
257
|
-
hermesCommand(['enable', HERMES_PLUGIN_ID], env);
|
|
258
|
-
}
|
|
259
|
-
else {
|
|
260
|
-
const temp = mkdtempSync(path.join(os.tmpdir(), 'notifai-hermes-plugin-'));
|
|
261
|
-
try {
|
|
262
|
-
writeFileSync(path.join(temp, 'plugin.yaml'), 'name: notifai\nversion: "1.0.0"\ndescription: "Notifai activation and Session Attendant"\nprovides_hooks:\n - on_session_finalize\n - on_session_reset\n');
|
|
263
|
-
writeFileSync(path.join(temp, '__init__.py'), source);
|
|
264
|
-
const git = (args) => {
|
|
265
|
-
const result = spawnSync('git', args, { cwd: temp, env, encoding: 'utf8', timeout: 10_000 });
|
|
266
|
-
if (result.error || result.status !== 0)
|
|
267
|
-
throw new Error(`Could not prepare Hermes plugin: ${result.error?.message ?? result.stderr?.trim() ?? 'git failed'}`);
|
|
268
|
-
};
|
|
269
|
-
git(['init', '-q']);
|
|
270
|
-
git(['add', 'plugin.yaml', '__init__.py']);
|
|
271
|
-
git(['-c', 'user.name=Notifai', '-c', 'user.email=notifai@example.invalid', 'commit', '-qm', 'plugin']);
|
|
272
|
-
hermesCommand(['install', pathToFileURL(temp).href, '--enable', '--no-deps', ...(existsSync(installed) ? ['--force'] : [])], env);
|
|
273
|
-
}
|
|
274
|
-
finally {
|
|
275
|
-
rmSync(temp, { recursive: true, force: true });
|
|
276
|
-
}
|
|
277
|
-
}
|
|
278
|
-
if (!isOurHermesPlugin(installed) || !hermesPluginListed(env)) {
|
|
279
|
-
throw new Error('Hermes did not report an enabled Notifai plugin after installation');
|
|
280
|
-
}
|
|
281
|
-
return installed;
|
|
282
|
-
}
|
|
283
|
-
export function uninstallHermesPlugin(env = process.env) {
|
|
284
|
-
const installed = hermesPluginDir(env);
|
|
285
|
-
if (!existsSync(installed))
|
|
286
|
-
return false;
|
|
287
|
-
if (!isOurHermesPlugin(installed))
|
|
288
|
-
throw new Error('Hermes plugin named notifai is foreign; leave it unchanged');
|
|
289
|
-
hermesCommand(['remove', HERMES_PLUGIN_ID], env);
|
|
290
|
-
if (existsSync(installed))
|
|
291
|
-
throw new Error('Hermes still has the Notifai plugin after removal');
|
|
292
|
-
return true;
|
|
293
|
-
}
|
|
294
|
-
export function hermesPluginCurrent(adapterHome, env) {
|
|
295
|
-
const dir = hermesPluginDir(env);
|
|
296
|
-
return isOurHermesPlugin(dir) && readFileSync(path.join(dir, '__init__.py'), 'utf8') ===
|
|
297
|
-
hermesPluginSource(hookAdapterPath(adapterHome), process.platform === 'win32' ? process.execPath : undefined);
|
|
298
|
-
}
|
|
299
|
-
//# sourceMappingURL=hermes-plugin.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"hermes-plugin.js","sourceRoot":"","sources":["../src/hermes-plugin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAA;AAC9C,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AACjG,OAAO,EAAE,MAAM,SAAS,CAAA;AACxB,OAAO,IAAI,MAAM,WAAW,CAAA;AAC5B,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;AACxC,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAA;AACnD,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAE3C,MAAM,CAAC,MAAM,gBAAgB,GAAG,SAAS,CAAA;AACzC,MAAM,CAAC,MAAM,oBAAoB,GAAG,oCAAoC,CAAA;AAExE,MAAM,UAAU,eAAe,CAAC,MAAyB,OAAO,CAAC,GAAG;IAClE,MAAM,IAAI,GAAG,GAAG,CAAC,aAAa,CAAC,EAAE,IAAI,EAAE,IAAI,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,GAAG,EAAE,OAAO,CAAC,QAAQ,CAAC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
-
import type { AcceptedAnswerDelivery, AnsweredPending, HookContext, HookOutcome, MessageAcknowledgementDue, OwedAcknowledgement, SessionState } from './hook-types.js';
|
|
2
|
-
export declare function owedAcknowledgementId(owed: OwedAcknowledgement): string;
|
|
3
|
-
/** Presented messages only: queued Codex input cannot hold its preceding turn. */
|
|
4
|
-
export declare function presentedMessageAcknowledgements(state: SessionState): MessageAcknowledgementDue[];
|
|
5
|
-
/** Every presented acknowledgement this session still owes, request debt first. */
|
|
6
|
-
export declare function owedAcknowledgements(state: SessionState): OwedAcknowledgement[];
|
|
7
|
-
/** Exact queued text entering the owning Codex turn proves presentation, not action. */
|
|
8
|
-
export declare function observeQueuedMessagePrompt(sessionId: string, env: NodeJS.ProcessEnv, prompt: string | undefined): string[];
|
|
9
|
-
/**
|
|
10
|
-
* Record the acknowledgement a Session Message is owed, before it is written:
|
|
11
|
-
* an agent that acknowledges the moment it reads the message must find the
|
|
12
|
-
* debt already there to clear.
|
|
13
|
-
*/
|
|
14
|
-
export declare function recordMessageAcknowledgementDue(sessionId: string, env: NodeJS.ProcessEnv, due: MessageAcknowledgementDue): void;
|
|
15
|
-
export declare function acknowledgementContext(answered: AnsweredPending[]): string;
|
|
16
|
-
/**
|
|
17
|
-
* Every answer that has arrived, as one message. Several registered questions
|
|
18
|
-
* may resolve in one hook pass; the agent reads them together, each answer
|
|
19
|
-
* tied to the question that asked it, with a truthful note about anything
|
|
20
|
-
* still waiting.
|
|
21
|
-
*/
|
|
22
|
-
export declare function answersContext(answered: AnsweredPending[], remaining: number): string;
|
|
23
|
-
export declare function stopAnswerOutput(context: string): string;
|
|
24
|
-
/**
|
|
25
|
-
* Close, truthfully retire, and forget every answered pending question in one
|
|
26
|
-
* state write, without dropping any other retirement debt or any question
|
|
27
|
-
* still waiting. Stop answers also open one bounded continuation generation;
|
|
28
|
-
* UserPromptSubmit answers ride the user's new turn.
|
|
29
|
-
*/
|
|
30
|
-
export declare function stageAcceptedAnswers(ctx: HookContext, sessionId: string, answered: AnsweredPending[], remaining: number): AcceptedAnswerDelivery;
|
|
31
|
-
/** Amend the live accepted record in place, without resurrecting a settled one. */
|
|
32
|
-
export declare function amendAcceptedAnswers(ctx: HookContext, sessionId: string, amend: (accepted: AcceptedAnswerDelivery) => AcceptedAnswerDelivery): void;
|
|
33
|
-
/**
|
|
34
|
-
* Finish a route write that linearized before SessionEnd.
|
|
35
|
-
*
|
|
36
|
-
* Ordinary state writers stop at the ended marker. This one narrow completion
|
|
37
|
-
* is allowed through because the journal's own `delivery_committed_at` proves
|
|
38
|
-
* the irreversible write won the ordering first; without the matching finish,
|
|
39
|
-
* a later SessionStart would replay a write that already reached the harness.
|
|
40
|
-
*/
|
|
41
|
-
export declare function finishCommittedDelivery(ctx: HookContext, sessionId: string, accepted: AcceptedAnswerDelivery, deliveredRoute: string): void;
|
|
42
|
-
export declare function classifyJournaledAcknowledgements(sessionId: string, env: NodeJS.ProcessEnv): AcceptedAnswerDelivery | undefined;
|
|
43
|
-
/** Resume a queue write recorded by an earlier process without replaying it. */
|
|
44
|
-
export declare function recoverQueuedAnswers(sessionId: string, env: NodeJS.ProcessEnv): void;
|
|
45
|
-
/** Forget one owed acknowledgement, dispatched by identifier: `sm_…` or a request id. */
|
|
46
|
-
export declare function clearAcknowledgementObligation(sessionId: string, env: NodeJS.ProcessEnv, id: string): boolean;
|
|
47
|
-
export declare function acknowledgementBlockContext(due: readonly OwedAcknowledgement[]): string;
|
|
48
|
-
/**
|
|
49
|
-
* Hold the turn for an outstanding acknowledgement, or give up and let it
|
|
50
|
-
* through once holding has stopped being worth its cost.
|
|
51
|
-
*
|
|
52
|
-
* Returns the outcome that blocks the turn, or `null` to carry on.
|
|
53
|
-
*/
|
|
54
|
-
export declare function holdForAcknowledgement(ctx: HookContext, sessionId: string, due: readonly OwedAcknowledgement[], notes: string[]): HookOutcome | null;
|
|
55
|
-
/** A turn that was not held resets the streak; only consecutive holds count. */
|
|
56
|
-
export declare function resetAcknowledgementBlocks(sessionId: string, env: NodeJS.ProcessEnv): void;
|
|
57
|
-
/**
|
|
58
|
-
* Ask the service which owed acknowledgements now exist and forget those.
|
|
59
|
-
* Returns what is still owed; a failed check counts as still owed.
|
|
60
|
-
*/
|
|
61
|
-
export declare function reconcileAcknowledgementObligations<T extends OwedAcknowledgement>(ctx: HookContext, sessionId: string, due: readonly T[]): Promise<T[]>;
|
|
62
|
-
/**
|
|
63
|
-
* Retire the answered questions and close the journal.
|
|
64
|
-
*
|
|
65
|
-
* Called once an answer's delivery is acknowledged — by the route's own write,
|
|
66
|
-
* or by the successor Stop of a blocking continuation. The continuation counter
|
|
67
|
-
* grows with each settled generation, so the cap that bounds chained
|
|
68
|
-
* answer-to-question loops is a real count rather than a constant 1.
|
|
69
|
-
*/
|
|
70
|
-
export declare function settleAcceptedAnswers(ctx: HookContext, sessionId: string, accepted: AcceptedAnswerDelivery, cwd?: string): void;
|