@adapt-toolkit/a2adapt 0.6.0 → 0.7.0

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.
@@ -4,10 +4,11 @@ import { createRequire } from 'node:module'; const require = createRequire(impor
4
4
  // src/hooks/runner.ts
5
5
  import * as fs from "node:fs";
6
6
  import { homedir } from "node:os";
7
- import { resolve, join } from "node:path";
7
+ import { resolve, join, dirname } from "node:path";
8
8
  var STATE_DIR = resolve(
9
9
  process.env.A2ADAPT_STATE_DIR ?? resolve(homedir(), ".a2adapt")
10
10
  );
11
+ var IDENTITY_FILE = ".a2adapt-identity";
11
12
  function readStdin() {
12
13
  try {
13
14
  return fs.readFileSync(0, "utf8");
@@ -72,23 +73,61 @@ ${lines.join("\n")}
72
73
 
73
74
  To read: choose_identity({ name }) then get_messages() (returns the bodies and marks them read). To wait for live replies, arm a Monitor on the per-identity wake source \`a2adapt-mcp watch <name>\` (each new-mail line wakes you).`;
74
75
  }
76
+ function findPinnedIdentity(start) {
77
+ let dir = resolve(start);
78
+ for (; ; ) {
79
+ let raw;
80
+ try {
81
+ raw = fs.readFileSync(join(dir, IDENTITY_FILE), "utf8");
82
+ } catch {
83
+ const parent = dirname(dir);
84
+ if (parent === dir) return null;
85
+ dir = parent;
86
+ continue;
87
+ }
88
+ try {
89
+ const name = String(JSON.parse(raw).identity ?? "").trim();
90
+ return name || null;
91
+ } catch {
92
+ return null;
93
+ }
94
+ }
95
+ }
96
+ function identityExists(name) {
97
+ try {
98
+ return fs.statSync(join(STATE_DIR, name)).isDirectory();
99
+ } catch {
100
+ return false;
101
+ }
102
+ }
103
+ function renderIdentityDirective(name, exists) {
104
+ const bind = exists ? `call \`choose_identity({ name: "${name}" })\` to bind it to this session` : `it does not exist yet \u2014 call \`create_identity({ name: "${name}" })\` to create and bind it`;
105
+ return `a2adapt \u2014 this workspace is pinned to identity "${name}" (via ${IDENTITY_FILE}). Before other a2adapt work, ${bind}. Then arm a Monitor on the wake source \`a2adapt-mcp watch ${name}\` so new mail wakes you. Do this once, up front; if a different identity is already bound, prefer this pinned one.`;
106
+ }
75
107
  function sessionStart() {
76
108
  const raw = readStdin();
77
109
  let source = "";
110
+ let cwd = process.cwd();
78
111
  if (raw) {
79
112
  try {
80
- source = JSON.parse(raw).source ?? "";
113
+ const payload = JSON.parse(raw);
114
+ source = payload.source ?? "";
115
+ if (typeof payload.cwd === "string" && payload.cwd) cwd = payload.cwd;
81
116
  } catch {
82
117
  }
83
118
  }
84
119
  if (source === "compact") return noop();
120
+ const pinned = findPinnedIdentity(cwd);
85
121
  const unread = collectUnread();
86
- if (unread.length === 0) return noop();
122
+ const blocks = [];
123
+ if (pinned) blocks.push(renderIdentityDirective(pinned, identityExists(pinned)));
124
+ if (unread.length > 0) blocks.push(renderContext(unread));
125
+ if (blocks.length === 0) return noop();
87
126
  emit({
88
127
  continue: true,
89
128
  hookSpecificOutput: {
90
129
  hookEventName: "SessionStart",
91
- additionalContext: renderContext(unread)
130
+ additionalContext: blocks.join("\n\n")
92
131
  }
93
132
  });
94
133
  }
package/dist/index.js CHANGED
@@ -22489,7 +22489,7 @@ function loadConfig() {
22489
22489
  }
22490
22490
 
22491
22491
  // src/index.ts
22492
- var VERSION = true ? "0.6.0" : "0.0.0-dev";
22492
+ var VERSION = true ? "0.7.0" : "0.0.0-dev";
22493
22493
  var CONFIG = loadConfig();
22494
22494
  var STATE_DIR = CONFIG.stateDir;
22495
22495
  var BROKER_URL = CONFIG.brokerUrl;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adapt-toolkit/a2adapt",
3
- "version": "0.6.0",
3
+ "version": "0.7.0",
4
4
  "description": "MCP server daemon for a2adapt — one native ADAPT wrapper hosting N self-sovereign identities, exposing secure agent-to-agent messaging tools over HTTP (Streamable HTTP). Run `a2adapt-mcp start`.",
5
5
  "type": "module",
6
6
  "license": "MIT",