@inline-chat/hermes-agent-adapter 1.0.0-alpha.3 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -4
- package/dist/install.js +95 -95
- package/package.json +12 -6
- package/plugin/inline/adapter.py +235 -101
- package/plugin/inline/cli.py +32 -6
- package/plugin/inline/plugin.yaml +1 -1
- package/plugin/inline/sidecar/index.mjs +846 -801
- package/plugin/inline/tools.py +12 -2
package/plugin/inline/cli.py
CHANGED
|
@@ -27,7 +27,10 @@ _CLI_INSTALL_URL = "https://inline.chat/cli/install.sh"
|
|
|
27
27
|
_MAX_TOKEN_BYTES = 16 * 1024
|
|
28
28
|
_MAX_PROBE_RESPONSE_BYTES = 64 * 1024
|
|
29
29
|
_MACHINE_SETUP_PROTOCOL_VERSION = 1
|
|
30
|
-
|
|
30
|
+
# Hermes' own tolerance: macOS readings of one process's start time drift about a second
|
|
31
|
+
# after boot-clock adjustments, and 200 is 2 s on every platform's scale.
|
|
32
|
+
_START_TIME_DRIFT_TOLERANCE = 200
|
|
33
|
+
_PROBE_USER_AGENT = "inline-hermes-agent-adapter/1.0.1"
|
|
31
34
|
_ENV_REFERENCE_RE = re.compile(r"^\$\{([A-Za-z_][A-Za-z0-9_]*)\}$")
|
|
32
35
|
|
|
33
36
|
|
|
@@ -40,6 +43,24 @@ def _open_bot_api_probe(request: urllib.request.Request):
|
|
|
40
43
|
return urllib.request.build_opener(_RejectRedirects()).open(request, timeout=30)
|
|
41
44
|
|
|
42
45
|
|
|
46
|
+
def _setup_ui():
|
|
47
|
+
"""Wizard prompts and output through the helpers Hermes documents for ``setup_fn``:
|
|
48
|
+
prompts from ``hermes_cli.setup`` and output from ``hermes_cli.cli_output``."""
|
|
49
|
+
from types import SimpleNamespace
|
|
50
|
+
|
|
51
|
+
from hermes_cli import cli_output
|
|
52
|
+
from hermes_cli.setup import prompt, prompt_yes_no
|
|
53
|
+
|
|
54
|
+
return SimpleNamespace(
|
|
55
|
+
print_header=cli_output.print_header,
|
|
56
|
+
print_info=cli_output.print_info,
|
|
57
|
+
print_success=cli_output.print_success,
|
|
58
|
+
print_warning=cli_output.print_warning,
|
|
59
|
+
prompt=prompt,
|
|
60
|
+
prompt_yes_no=prompt_yes_no,
|
|
61
|
+
)
|
|
62
|
+
|
|
63
|
+
|
|
43
64
|
def gateway_setup() -> None:
|
|
44
65
|
"""Interactively create or connect an Inline bot.
|
|
45
66
|
|
|
@@ -47,8 +68,9 @@ def gateway_setup() -> None:
|
|
|
47
68
|
persistence inside Hermes' own config helper so profiles and file
|
|
48
69
|
permissions behave exactly like the built-in Telegram setup.
|
|
49
70
|
"""
|
|
50
|
-
from hermes_cli import
|
|
51
|
-
|
|
71
|
+
from hermes_cli import config as hermes_gateway
|
|
72
|
+
|
|
73
|
+
hermes_setup = _setup_ui()
|
|
52
74
|
|
|
53
75
|
hermes_setup.print_header("Inline")
|
|
54
76
|
existing = (
|
|
@@ -400,7 +422,7 @@ def _machine_setup(args) -> int:
|
|
|
400
422
|
token = token.strip()
|
|
401
423
|
if not token:
|
|
402
424
|
raise SystemExit("Inline bot token from stdin is empty")
|
|
403
|
-
from hermes_cli import
|
|
425
|
+
from hermes_cli import config as hermes_gateway
|
|
404
426
|
|
|
405
427
|
hermes_gateway.save_env_value("INLINE_TOKEN", token)
|
|
406
428
|
allowed = _apply_access(
|
|
@@ -428,7 +450,7 @@ def _machine_setup(args) -> int:
|
|
|
428
450
|
|
|
429
451
|
|
|
430
452
|
def _status(args) -> int:
|
|
431
|
-
from hermes_cli import
|
|
453
|
+
from hermes_cli import config as hermes_gateway
|
|
432
454
|
|
|
433
455
|
raw_config = _read_inline_config(hermes_gateway)
|
|
434
456
|
token = (
|
|
@@ -581,7 +603,11 @@ def _gateway_status() -> dict:
|
|
|
581
603
|
return {"supported": False, "ready": False, "reason": "runtime_writer_identity_unavailable"}
|
|
582
604
|
# Runtime status can retain platform entries from the prior process.
|
|
583
605
|
# Only the current process's own connected projection is readiness proof.
|
|
584
|
-
|
|
606
|
+
writer_start_time = inline.get("writer_start_time") if isinstance(inline, dict) else None
|
|
607
|
+
writer_matches = (
|
|
608
|
+
isinstance(inline, dict) and inline.get("writer_pid") == pid and type(writer_start_time) is int
|
|
609
|
+
and abs(writer_start_time - start_time) <= _START_TIME_DRIFT_TOLERANCE
|
|
610
|
+
)
|
|
585
611
|
ready = generation is not None and writer_matches and state == "running" and platform_state == "connected"
|
|
586
612
|
return {
|
|
587
613
|
"supported": True,
|