@holon-run/agentinbox 0.7.0 → 1.0.0-beta.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.
Files changed (33) hide show
  1. package/README.md +36 -7
  2. package/dist/src/adapters.js +55 -0
  3. package/dist/src/backend.js +4 -16
  4. package/dist/src/cli.js +329 -52
  5. package/dist/src/client.js +2 -2
  6. package/dist/src/http.js +479 -55
  7. package/dist/src/runtime_gate.js +49 -41
  8. package/dist/src/service.js +922 -200
  9. package/dist/src/source_hosts.js +75 -0
  10. package/dist/src/source_resolution.js +2 -2
  11. package/dist/src/source_schema.js +2 -2
  12. package/dist/src/sources/feishu.js +66 -28
  13. package/dist/src/sources/github.js +222 -36
  14. package/dist/src/sources/remote.js +50 -3
  15. package/dist/src/sources/remote_modules.js +100 -15
  16. package/dist/src/store.js +875 -110
  17. package/dist/src/terminal.js +33 -7
  18. package/dist/src/util.js +46 -1
  19. package/drizzle/migrations/{0000_initial.sql → 0000_v1_initial.sql} +182 -6
  20. package/drizzle/migrations/0002_host_scoped_lifecycle_retirements.sql +42 -0
  21. package/drizzle/migrations/0003_subscription_tracked_resource_indexes.sql +5 -0
  22. package/drizzle/schema.ts +98 -3
  23. package/package.json +2 -1
  24. package/scripts/release_smoke.sh +123 -0
  25. package/dist/src/sources/remote_profiles.js +0 -13
  26. package/drizzle/migrations/0001_inbox_items_source_occurred_at_idx.sql +0 -3
  27. package/drizzle/migrations/0002_subscription_cleanup_policy.sql +0 -45
  28. package/drizzle/migrations/0003_subscription_lifecycle_retirements.sql +0 -14
  29. package/drizzle/migrations/0004_source_idle_states.sql +0 -10
  30. package/drizzle/migrations/0005_timers.sql +0 -22
  31. package/drizzle/migrations/0006_terminal_runtime_pid.sql +0 -1
  32. package/drizzle/migrations/0007_activation_dispatch_last_notified_fingerprint.sql +0 -2
  33. package/drizzle/migrations/0008_inbox_item_sequence.sql +0 -21
@@ -0,0 +1,123 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+
4
+ if [ "$#" -ne 1 ]; then
5
+ echo "usage: scripts/release_smoke.sh <packed-tarball>" >&2
6
+ exit 1
7
+ fi
8
+
9
+ PACK_FILE="$(cd "$(dirname "$1")" && pwd)/$(basename "$1")"
10
+ if [ ! -f "$PACK_FILE" ]; then
11
+ echo "packed tarball not found: $PACK_FILE" >&2
12
+ exit 1
13
+ fi
14
+
15
+ TMP_BASE="${TMPDIR:-/tmp}"
16
+ TMP_ROOT="$(mktemp -d "$TMP_BASE/aixsmk.XXXXXX")"
17
+ cleanup() {
18
+ rm -rf "$TMP_ROOT" >/dev/null 2>&1 || true
19
+ }
20
+ trap cleanup EXIT
21
+
22
+ PKG_ROOT="$TMP_ROOT/pkg"
23
+ HOME_DIR="$TMP_ROOT/home"
24
+ mkdir -p "$PKG_ROOT" "$HOME_DIR"
25
+
26
+ cd "$PKG_ROOT"
27
+ npm init -y >/dev/null 2>&1
28
+ npm install "$PACK_FILE" >/dev/null 2>&1
29
+
30
+ export HOME="$HOME_DIR"
31
+ unset AGENTINBOX_SOCKET
32
+ unset AGENTINBOX_URL
33
+ FRESH_HOME="$TMP_ROOT/f1"
34
+ LEGACY_HOME="$TMP_ROOT/f2"
35
+ CLI_HOME="$TMP_ROOT/f3"
36
+
37
+ echo "[smoke] fresh install"
38
+ export AGENTINBOX_HOME="$FRESH_HOME"
39
+ DB_PATH="$AGENTINBOX_HOME/agentinbox.sqlite"
40
+ npx agentinbox --version >/dev/null
41
+ npx agentinbox daemon start >/dev/null
42
+ npx agentinbox host list >/dev/null
43
+ [ -f "$DB_PATH" ]
44
+
45
+ echo "[smoke] archive pre-v1 database and start fresh"
46
+ export AGENTINBOX_HOME="$LEGACY_HOME"
47
+ DB_PATH="$AGENTINBOX_HOME/agentinbox.sqlite"
48
+ rm -rf "$AGENTINBOX_HOME"
49
+ mkdir -p "$AGENTINBOX_HOME"
50
+ python3 - "$DB_PATH" <<'PY'
51
+ import sqlite3
52
+ import sys
53
+
54
+ db_path = sys.argv[1]
55
+ conn = sqlite3.connect(db_path)
56
+ conn.execute("create table sources (source_id text primary key, source_type text, source_key text)")
57
+ conn.commit()
58
+ conn.close()
59
+ PY
60
+ npx agentinbox daemon start >/dev/null
61
+ npx agentinbox host list >/dev/null
62
+ [ -f "$DB_PATH" ]
63
+ find "$AGENTINBOX_HOME" -maxdepth 1 -name 'agentinbox.sqlite.pre-v1.*.bak*' | grep -q .
64
+
65
+ echo "[smoke] canonical v1 CLI and HTTP surfaces"
66
+ export AGENTINBOX_HOME="$CLI_HOME"
67
+ DB_PATH="$AGENTINBOX_HOME/agentinbox.sqlite"
68
+ npx agentinbox daemon start >/dev/null
69
+ HOST_JSON="$(npx agentinbox host add local_event smoke-local)"
70
+ HOST_ID="$(printf '%s' "$HOST_JSON" | node -e 'let input=""; process.stdin.on("data", (chunk) => input += chunk); process.stdin.on("end", () => process.stdout.write(JSON.parse(input).hostId));')"
71
+ SOURCE_JSON="$(npx agentinbox source add "$HOST_ID" events smoke-local)"
72
+ SOURCE_ID="$(printf '%s' "$SOURCE_JSON" | node -e 'let input=""; process.stdin.on("data", (chunk) => input += chunk); process.stdin.on("end", () => process.stdout.write(JSON.parse(input).sourceId));')"
73
+ npx agentinbox source schema "$SOURCE_ID" >/dev/null
74
+
75
+ node - "$AGENTINBOX_HOME/agentinbox.sock" <<'PY'
76
+ const http = require("http");
77
+
78
+ const socketPath = process.argv[2];
79
+
80
+ function request(pathname) {
81
+ return new Promise((resolve, reject) => {
82
+ const req = http.request({
83
+ agent: false,
84
+ socketPath,
85
+ path: pathname,
86
+ method: "GET",
87
+ }, (res) => {
88
+ let body = "";
89
+ res.setEncoding("utf8");
90
+ res.on("data", (chunk) => {
91
+ body += chunk;
92
+ });
93
+ res.on("end", () => resolve({ statusCode: res.statusCode ?? 0, body }));
94
+ });
95
+ req.on("error", reject);
96
+ req.end();
97
+ });
98
+ }
99
+
100
+ (async () => {
101
+ const health = await request("/healthz");
102
+ if (health.statusCode !== 200) {
103
+ throw new Error(`healthz failed: ${health.statusCode}`);
104
+ }
105
+ const openapi = await request("/openapi.json");
106
+ if (openapi.statusCode !== 200) {
107
+ throw new Error(`openapi failed: ${openapi.statusCode}`);
108
+ }
109
+ const schema = JSON.parse(openapi.body);
110
+ const raw = JSON.stringify(schema);
111
+ if (raw.includes("/agents/{agentId}/inbox/raw-items")) {
112
+ throw new Error("legacy raw-items endpoint still exposed");
113
+ }
114
+ if (raw.includes("throughItemId") || raw.includes("afterItemId")) {
115
+ throw new Error("legacy inbox paging fields still exposed");
116
+ }
117
+ })().catch((error) => {
118
+ console.error(error);
119
+ process.exit(1);
120
+ });
121
+ PY
122
+
123
+ echo "[smoke] ok"
@@ -1,13 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.profileConfigForSource = exports.builtInProfileIdForSourceType = exports.RemoteSourceProfileRegistry = exports.moduleConfigForSource = exports.builtInModuleIdForSourceType = exports.RemoteSourceModuleRegistry = void 0;
4
- var remote_modules_1 = require("./remote_modules");
5
- Object.defineProperty(exports, "RemoteSourceModuleRegistry", { enumerable: true, get: function () { return remote_modules_1.RemoteSourceModuleRegistry; } });
6
- Object.defineProperty(exports, "builtInModuleIdForSourceType", { enumerable: true, get: function () { return remote_modules_1.builtInModuleIdForSourceType; } });
7
- Object.defineProperty(exports, "moduleConfigForSource", { enumerable: true, get: function () { return remote_modules_1.moduleConfigForSource; } });
8
- const remote_modules_2 = require("./remote_modules");
9
- class RemoteSourceProfileRegistry extends remote_modules_2.RemoteSourceModuleRegistry {
10
- }
11
- exports.RemoteSourceProfileRegistry = RemoteSourceProfileRegistry;
12
- exports.builtInProfileIdForSourceType = remote_modules_2.builtInModuleIdForSourceType;
13
- exports.profileConfigForSource = remote_modules_2.moduleConfigForSource;
@@ -1,3 +0,0 @@
1
- create index if not exists idx_inbox_items_source_occurred_at
2
- on inbox_items(source_id, occurred_at);
3
-
@@ -1,45 +0,0 @@
1
- create table subscriptions__new (
2
- subscription_id text primary key,
3
- agent_id text not null,
4
- source_id text not null,
5
- filter_json text not null,
6
- tracked_resource_ref text,
7
- cleanup_policy_json text not null,
8
- start_policy text not null,
9
- start_offset integer,
10
- start_time text,
11
- created_at text not null
12
- );
13
-
14
- insert into subscriptions__new (
15
- subscription_id,
16
- agent_id,
17
- source_id,
18
- filter_json,
19
- tracked_resource_ref,
20
- cleanup_policy_json,
21
- start_policy,
22
- start_offset,
23
- start_time,
24
- created_at
25
- )
26
- select
27
- subscription_id,
28
- agent_id,
29
- source_id,
30
- filter_json,
31
- null as tracked_resource_ref,
32
- case
33
- when expires_at is not null then json_object('mode', 'at', 'at', expires_at)
34
- when lifecycle_mode = 'temporary' then json_object('mode', 'manual')
35
- else json_object('mode', 'manual')
36
- end as cleanup_policy_json,
37
- start_policy,
38
- start_offset,
39
- start_time,
40
- created_at
41
- from subscriptions;
42
-
43
- drop table subscriptions;
44
-
45
- alter table subscriptions__new rename to subscriptions;
@@ -1,14 +0,0 @@
1
- create table if not exists subscription_lifecycle_retirements (
2
- subscription_id text primary key,
3
- source_id text not null,
4
- tracked_resource_ref text not null,
5
- retire_at text not null,
6
- terminal_state text,
7
- terminal_result text,
8
- terminal_occurred_at text,
9
- created_at text not null,
10
- updated_at text not null
11
- );
12
-
13
- create index if not exists idx_subscription_lifecycle_retirements_retire_at
14
- on subscription_lifecycle_retirements(retire_at);
@@ -1,10 +0,0 @@
1
- create table if not exists source_idle_states (
2
- source_id text primary key not null,
3
- idle_since text not null,
4
- auto_pause_at text not null,
5
- auto_paused_at text,
6
- updated_at text not null
7
- );
8
-
9
- create index if not exists idx_source_idle_states_auto_pause_at
10
- on source_idle_states(auto_pause_at);
@@ -1,22 +0,0 @@
1
- create table if not exists timers (
2
- schedule_id text primary key not null,
3
- agent_id text not null,
4
- status text not null,
5
- mode text not null,
6
- at text,
7
- interval_ms integer,
8
- cron_expr text,
9
- timezone text not null,
10
- message text not null,
11
- sender text,
12
- next_fire_at text,
13
- last_fired_at text,
14
- created_at text not null,
15
- updated_at text not null
16
- );
17
-
18
- create index if not exists idx_timers_agent_next_fire_at
19
- on timers(agent_id, next_fire_at);
20
-
21
- create index if not exists idx_timers_next_fire_at
22
- on timers(next_fire_at);
@@ -1 +0,0 @@
1
- alter table activation_targets add column runtime_pid integer;
@@ -1,2 +0,0 @@
1
- alter table activation_dispatch_states
2
- add column last_notified_fingerprint text;
@@ -1,21 +0,0 @@
1
- alter table inbox_items add column inbox_sequence integer;
2
-
3
- update inbox_items
4
- set inbox_sequence = rowid
5
- where inbox_sequence is null;
6
-
7
- create unique index if not exists idx_inbox_items_inbox_sequence
8
- on inbox_items(inbox_sequence);
9
-
10
- create index if not exists idx_inbox_items_inbox_sequence_order
11
- on inbox_items(inbox_id, inbox_sequence);
12
-
13
- create trigger if not exists trg_inbox_items_set_sequence_after_insert
14
- after insert on inbox_items
15
- for each row
16
- when new.inbox_sequence is null
17
- begin
18
- update inbox_items
19
- set inbox_sequence = new.rowid
20
- where rowid = new.rowid;
21
- end;