aismemory 0.7.0 → 0.7.2

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 (59) hide show
  1. package/README.md +11 -2
  2. package/dist/__tests__/agent-key-mode-e2e.test.js +78 -0
  3. package/dist/__tests__/agent-key-mode-e2e.test.js.map +1 -1
  4. package/dist/__tests__/agent-key-mode.test.js +63 -0
  5. package/dist/__tests__/agent-key-mode.test.js.map +1 -1
  6. package/dist/__tests__/agent-load-session-override-e2e.test.js +7 -5
  7. package/dist/__tests__/agent-load-session-override-e2e.test.js.map +1 -1
  8. package/dist/__tests__/agent-preference.test.js +99 -2
  9. package/dist/__tests__/agent-preference.test.js.map +1 -1
  10. package/dist/__tests__/ais-http.test.d.ts +1 -0
  11. package/dist/__tests__/ais-http.test.js +119 -0
  12. package/dist/__tests__/ais-http.test.js.map +1 -0
  13. package/dist/__tests__/auto-enroll-key.test.js +20 -0
  14. package/dist/__tests__/auto-enroll-key.test.js.map +1 -1
  15. package/dist/__tests__/delegated-read-args.test.d.ts +9 -0
  16. package/dist/__tests__/delegated-read-args.test.js +80 -0
  17. package/dist/__tests__/delegated-read-args.test.js.map +1 -0
  18. package/dist/__tests__/inbox-client.test.d.ts +1 -0
  19. package/dist/__tests__/inbox-client.test.js +108 -0
  20. package/dist/__tests__/inbox-client.test.js.map +1 -0
  21. package/dist/__tests__/key-auth.test.js +7 -1
  22. package/dist/__tests__/key-auth.test.js.map +1 -1
  23. package/dist/__tests__/provisional-register-mcp-remember.test.d.ts +1 -0
  24. package/dist/__tests__/provisional-register-mcp-remember.test.js +192 -0
  25. package/dist/__tests__/provisional-register-mcp-remember.test.js.map +1 -0
  26. package/dist/__tests__/reconnect-survival-e2e.test.d.ts +1 -0
  27. package/dist/__tests__/reconnect-survival-e2e.test.js +248 -0
  28. package/dist/__tests__/reconnect-survival-e2e.test.js.map +1 -0
  29. package/dist/__tests__/silent-renewal-e2e.test.js +12 -9
  30. package/dist/__tests__/silent-renewal-e2e.test.js.map +1 -1
  31. package/dist/__tests__/split-brain-upgrade-e2e.test.d.ts +1 -0
  32. package/dist/__tests__/split-brain-upgrade-e2e.test.js +206 -0
  33. package/dist/__tests__/split-brain-upgrade-e2e.test.js.map +1 -0
  34. package/dist/__tests__/token-manager.test.js +158 -1
  35. package/dist/__tests__/token-manager.test.js.map +1 -1
  36. package/dist/__tests__/tool-args.test.js +68 -1
  37. package/dist/__tests__/tool-args.test.js.map +1 -1
  38. package/dist/agent-key-mode.js +39 -5
  39. package/dist/agent-key-mode.js.map +1 -1
  40. package/dist/agent-preference.d.ts +36 -1
  41. package/dist/agent-preference.js +79 -3
  42. package/dist/agent-preference.js.map +1 -1
  43. package/dist/ais-http.d.ts +6 -0
  44. package/dist/ais-http.js +75 -0
  45. package/dist/ais-http.js.map +1 -0
  46. package/dist/inbox-client.d.ts +9 -0
  47. package/dist/inbox-client.js +74 -0
  48. package/dist/inbox-client.js.map +1 -0
  49. package/dist/index.js +189 -79
  50. package/dist/index.js.map +1 -1
  51. package/dist/key-auth.js +12 -6
  52. package/dist/key-auth.js.map +1 -1
  53. package/dist/token-manager.d.ts +33 -6
  54. package/dist/token-manager.js +115 -44
  55. package/dist/token-manager.js.map +1 -1
  56. package/dist/tool-args.d.ts +42 -0
  57. package/dist/tool-args.js +70 -0
  58. package/dist/tool-args.js.map +1 -1
  59. package/package.json +1 -1
@@ -18,11 +18,22 @@
18
18
  * successful renewal — retries never stop, and recovery needs no restart.
19
19
  * - No code path ever serializes the token to disk; it lives only in the
20
20
  * closure state below for the process lifetime.
21
- * - `invalidate()` drops the current token (without touching backoff state)
22
- * so a caller that discovers the server rejected it mid-session — e.g. a
23
- * 401 from a JWT_SECRET rotation, CORBOT-A5BBD580 — can force the next
24
- * `getCredentials()` to acquire a fresh one instead of re-serving the
25
- * rejected token.
21
+ * - `invalidate()` drops the current token (without touching backoff state,
22
+ * unless `{ resetBackoff: true }` is passed) so a caller that discovers the
23
+ * server rejected it mid-session — e.g. a 401 from a JWT_SECRET rotation,
24
+ * CORBOT-A5BBD580 — can force the next `getCredentials()` to acquire a
25
+ * fresh one instead of re-serving the rejected token. `resetBackoff: true`
26
+ * additionally clears any escalated backoff window, so a server-rejection
27
+ * that arrives mid-outage (after prior renewal failures already escalated
28
+ * retryDelayMs) still re-proves immediately instead of being held behind
29
+ * the stale backoff gate (CORBOT-4F7CAA8E).
30
+ * - The background renewal loop and the on-demand backoff gate in
31
+ * `getCredentials()` are driven off the SAME single-flight `inFlight`
32
+ * promise and the same jittered `nextAttemptAt` timestamp — computed once
33
+ * per failure — so a caller can never race the timer into a second,
34
+ * concurrent `authenticate()` call, and a failed attempt is recorded into
35
+ * backoff state exactly once no matter how many callers were waiting on it
36
+ * (CORBOT-4F7CAA8E).
26
37
  */
27
38
  /** Credentials handed back by `getCredentials()`. */
28
39
  export interface ManagedCredentials {
@@ -39,6 +50,11 @@ export interface ManagedCredentials {
39
50
  */
40
51
  export declare class AisUnreachableError extends Error {
41
52
  }
53
+ /**
54
+ * Returns true when the error message contains NO_REGISTERED_KEYS or NO_REGISTERED_KEY
55
+ * (the 401 did-prove codes from tryKeyAuth).
56
+ */
57
+ export declare function isNoRegisteredKeyFailure(err: unknown): boolean;
42
58
  export interface TokenManagerOpts {
43
59
  /** Runs challenge/prove; throws on failure. */
44
60
  authenticate: () => Promise<{
@@ -54,8 +70,19 @@ export interface TokenManagerOpts {
54
70
  /** Injectable clock for tests; defaults to Date.now. */
55
71
  now?: () => number;
56
72
  }
73
+ export interface InvalidateOpts {
74
+ /**
75
+ * Also clears any escalated backoff window (retryDelayMs/lastAttemptAt/
76
+ * nextAttemptAt/hardExpiryEmitted) so the next `getCredentials()` re-proves
77
+ * immediately instead of being held behind a stale gate. Use this for a
78
+ * server-rejected-token path (e.g. a 401 mid-session) — the server just
79
+ * proved it can be reached, so waiting out a backoff window computed from
80
+ * unrelated prior failures makes no sense.
81
+ */
82
+ resetBackoff?: boolean;
83
+ }
57
84
  export declare function createTokenManager(opts: TokenManagerOpts): {
58
85
  getCredentials(): Promise<ManagedCredentials>;
59
- invalidate(): void;
86
+ invalidate(invalidateOpts?: InvalidateOpts): void;
60
87
  stop(): void;
61
88
  };
@@ -18,11 +18,22 @@
18
18
  * successful renewal — retries never stop, and recovery needs no restart.
19
19
  * - No code path ever serializes the token to disk; it lives only in the
20
20
  * closure state below for the process lifetime.
21
- * - `invalidate()` drops the current token (without touching backoff state)
22
- * so a caller that discovers the server rejected it mid-session — e.g. a
23
- * 401 from a JWT_SECRET rotation, CORBOT-A5BBD580 — can force the next
24
- * `getCredentials()` to acquire a fresh one instead of re-serving the
25
- * rejected token.
21
+ * - `invalidate()` drops the current token (without touching backoff state,
22
+ * unless `{ resetBackoff: true }` is passed) so a caller that discovers the
23
+ * server rejected it mid-session — e.g. a 401 from a JWT_SECRET rotation,
24
+ * CORBOT-A5BBD580 — can force the next `getCredentials()` to acquire a
25
+ * fresh one instead of re-serving the rejected token. `resetBackoff: true`
26
+ * additionally clears any escalated backoff window, so a server-rejection
27
+ * that arrives mid-outage (after prior renewal failures already escalated
28
+ * retryDelayMs) still re-proves immediately instead of being held behind
29
+ * the stale backoff gate (CORBOT-4F7CAA8E).
30
+ * - The background renewal loop and the on-demand backoff gate in
31
+ * `getCredentials()` are driven off the SAME single-flight `inFlight`
32
+ * promise and the same jittered `nextAttemptAt` timestamp — computed once
33
+ * per failure — so a caller can never race the timer into a second,
34
+ * concurrent `authenticate()` call, and a failed attempt is recorded into
35
+ * backoff state exactly once no matter how many callers were waiting on it
36
+ * (CORBOT-4F7CAA8E).
26
37
  */
27
38
  /**
28
39
  * Thrown by `getCredentials()` once the current token has hard-expired and
@@ -32,6 +43,19 @@
32
43
  */
33
44
  export class AisUnreachableError extends Error {
34
45
  }
46
+ /**
47
+ * Returns true when the error message contains NO_REGISTERED_KEYS or NO_REGISTERED_KEY
48
+ * (the 401 did-prove codes from tryKeyAuth).
49
+ */
50
+ export function isNoRegisteredKeyFailure(err) {
51
+ if (err instanceof Error) {
52
+ return err.message.includes('NO_REGISTERED_KEYS') || err.message.includes('NO_REGISTERED_KEY');
53
+ }
54
+ if (typeof err === 'string') {
55
+ return err.includes('NO_REGISTERED_KEYS') || err.includes('NO_REGISTERED_KEY');
56
+ }
57
+ return false;
58
+ }
35
59
  const RENEW_FRACTION = 0.75;
36
60
  const BACKOFF_BASE_MS = 5_000;
37
61
  const BACKOFF_CAP_MS = 300_000;
@@ -49,6 +73,12 @@ export function createTokenManager(opts) {
49
73
  let timer = null;
50
74
  let retryDelayMs = 0;
51
75
  let lastAttemptAt = 0;
76
+ // Absolute timestamp of the next permitted attempt, computed ONCE per
77
+ // failure (in recordFailure) as `lastAttemptAt + jitter(retryDelayMs)`.
78
+ // Both the background retry timer (renew()'s reschedule) and the on-demand
79
+ // gate in getCredentials() key off this SAME value, so they can never
80
+ // disagree about when the next attempt is due (CORBOT-4F7CAA8E / F1).
81
+ let nextAttemptAt = 0;
52
82
  let hardExpiryEmitted = false;
53
83
  let stopped = false;
54
84
  let lastError = '';
@@ -65,22 +95,27 @@ export function createTokenManager(opts) {
65
95
  }
66
96
  function scheduleRenewal(expiresAt) {
67
97
  const ttlMs = new Date(expiresAt).getTime() - now();
68
- schedule(Math.max(1_000, Math.floor(ttlMs * RENEW_FRACTION)), () => {
98
+ // Floored at 30s (not 1s): a very short or skewed TTL must not turn
99
+ // renewal into a near-1Hz hammer on the auth endpoint (F7).
100
+ schedule(Math.max(30_000, Math.floor(ttlMs * RENEW_FRACTION)), () => {
69
101
  void renew();
70
102
  });
71
103
  }
72
104
  /**
73
105
  * Records a failed authenticate/resolveIdentity attempt into the shared
74
- * backoff state, regardless of whether it came from the background renewal
75
- * loop or from an on-demand `getCredentials()` call on an expired token.
76
- * Escalates retryDelayMs, marks the attempt time (so callers can tell
77
- * whether a fresh attempt is due), emits `renew.retry`, and — once — the
78
- * `renew.hard_expiry` event when the current token has passed hard expiry.
106
+ * backoff state. Called exactly once per failed attempt — from the single
107
+ * `.catch` on the shared `inFlight` promise in `acquireShared()` — no
108
+ * matter how many callers (getCredentials() waiters, or the background
109
+ * renewal loop) were waiting on that attempt (F2a). Escalates
110
+ * retryDelayMs, computes the jittered `nextAttemptAt` gate/schedule value
111
+ * once, emits `renew.retry`, and — once — the `renew.hard_expiry` event
112
+ * when the current token has passed hard expiry.
79
113
  */
80
114
  function recordFailure(err) {
81
115
  lastError = err instanceof Error ? err.message : String(err);
82
116
  lastAttemptAt = now();
83
117
  retryDelayMs = retryDelayMs === 0 ? BACKOFF_BASE_MS : Math.min(retryDelayMs * 2, BACKOFF_CAP_MS);
118
+ nextAttemptAt = lastAttemptAt + jitter(retryDelayMs);
84
119
  opts.onEvent?.('renew.retry', lastError);
85
120
  if (current && new Date(current.expiresAt).getTime() <= now() && !hardExpiryEmitted) {
86
121
  hardExpiryEmitted = true;
@@ -89,9 +124,13 @@ export function createTokenManager(opts) {
89
124
  }
90
125
  async function acquire() {
91
126
  const fresh = await opts.authenticate();
92
- if (!Number.isFinite(new Date(fresh.expiresAt).getTime())) {
127
+ const expiresAtMs = new Date(fresh.expiresAt).getTime();
128
+ if (!Number.isFinite(expiresAtMs)) {
93
129
  throw new Error(`TokenManager.acquire(): authenticate() returned an invalid expiresAt: ${JSON.stringify(fresh.expiresAt)}`);
94
130
  }
131
+ if (expiresAtMs <= now()) {
132
+ throw new Error(`TokenManager.acquire(): authenticate() returned an expiresAt in the past: ${JSON.stringify(fresh.expiresAt)}`);
133
+ }
95
134
  // Identity is resolved only on the very first acquire; every later
96
135
  // acquire (renewal, or a re-acquire after invalidate()) reuses the
97
136
  // cached agentId/tenantId.
@@ -109,20 +148,46 @@ export function createTokenManager(opts) {
109
148
  }
110
149
  current = { token: fresh.token, expiresAt: fresh.expiresAt, agentId, tenantId };
111
150
  retryDelayMs = 0;
151
+ nextAttemptAt = 0;
112
152
  hardExpiryEmitted = false;
113
153
  scheduleRenewal(fresh.expiresAt);
114
154
  return current;
115
155
  }
156
+ /**
157
+ * Starts (or joins) the single in-flight acquire attempt. Both the
158
+ * background renewal loop (`renew()`) and an on-demand `getCredentials()`
159
+ * call on a missing/expired token route through this — so there is never
160
+ * more than one concurrent `authenticate()` call, and a failure is
161
+ * recorded into backoff state exactly once, by this function's own
162
+ * `.catch`, regardless of how many callers are awaiting the same flight
163
+ * (F1, F2a). A failure also schedules the next background retry here, so
164
+ * that retry loop starts even from a failed FIRST acquire — not only from
165
+ * a renewal failure (F3).
166
+ */
167
+ function acquireShared() {
168
+ if (!inFlight) {
169
+ inFlight = acquire()
170
+ .catch((err) => {
171
+ recordFailure(err);
172
+ schedule(Math.max(0, nextAttemptAt - now()), () => {
173
+ void renew();
174
+ });
175
+ throw err;
176
+ })
177
+ .finally(() => {
178
+ inFlight = null;
179
+ });
180
+ }
181
+ return inFlight;
182
+ }
116
183
  async function renew() {
117
184
  try {
118
- await acquire();
185
+ await acquireShared();
119
186
  opts.onEvent?.('renew.success');
120
187
  }
121
- catch (err) {
122
- recordFailure(err);
123
- schedule(jitter(retryDelayMs), () => {
124
- void renew();
125
- });
188
+ catch {
189
+ // Failure already recorded and the next retry already scheduled by
190
+ // acquireShared()'s own .catch — nothing left to do here.
126
191
  }
127
192
  }
128
193
  return {
@@ -130,28 +195,23 @@ export function createTokenManager(opts) {
130
195
  if (current && new Date(current.expiresAt).getTime() > now()) {
131
196
  return current;
132
197
  }
133
- if (!inFlight) {
134
- // The current token is missing or expired. If a prior attempt
135
- // (from here or from the background renewal loop) failed and we're
136
- // still inside its backoff window, don't make a fresh attempt —
137
- // that would let a burst of sequential calls (e.g. several tool
138
- // calls in one MCP chat turn) each hammer the auth endpoint during
139
- // an outage, racing the properly-backed-off background timer and
140
- // defeating the point of backoff. Fail fast with the last known
141
- // error instead; the background timer (or the next call after the
142
- // window elapses) makes the next real attempt.
143
- if (retryDelayMs > 0 && now() - lastAttemptAt < retryDelayMs) {
144
- throw new AisUnreachableError(`AIS unreachable — renewing automatically; no action needed. Last error: ${lastError}`);
145
- }
146
- inFlight = acquire().finally(() => {
147
- inFlight = null;
148
- });
198
+ // The current token is missing or expired. If a prior attempt (from
199
+ // here or from the background renewal loop) failed and we're still
200
+ // inside its jittered backoff window, don't make a fresh attempt —
201
+ // that would let a burst of sequential calls (e.g. several tool calls
202
+ // in one MCP chat turn) each hammer the auth endpoint during an
203
+ // outage, racing the properly-backed-off background timer and
204
+ // defeating the point of backoff. Fail fast with the last known error
205
+ // instead; the background timer (or the next call after the window
206
+ // elapses) makes the next real attempt. Skipped once a flight is
207
+ // already in progress — join it instead of gating it.
208
+ if (!inFlight && nextAttemptAt > 0 && now() < nextAttemptAt) {
209
+ throw new AisUnreachableError(`AIS unreachable — renewing automatically; no action needed. Last error: ${lastError}`);
149
210
  }
150
211
  try {
151
- return await inFlight;
212
+ return await acquireShared();
152
213
  }
153
- catch (err) {
154
- recordFailure(err);
214
+ catch {
155
215
  throw new AisUnreachableError(`AIS unreachable — renewing automatically; no action needed. Last error: ${lastError}`);
156
216
  }
157
217
  },
@@ -159,15 +219,26 @@ export function createTokenManager(opts) {
159
219
  * Drops the current token so the next `getCredentials()` must acquire a
160
220
  * fresh one — used when the server itself rejects a still-time-valid
161
221
  * token (e.g. a mid-session JWT_SECRET rotation, CORBOT-A5BBD580).
162
- * Deliberately does NOT touch backoff bookkeeping (`retryDelayMs` /
163
- * `lastAttemptAt`): a server that keeps rejecting tokens must not turn
164
- * into an unthrottled hammer on the auth endpoint — `recordFailure`'s
165
- * shared-backoff-window gate in `getCredentials()` still applies as-is.
166
- * Does not cancel or reschedule the background renewal timer; a
167
- * successful next acquire reschedules renewal exactly as it does today.
222
+ * By default this does NOT touch backoff bookkeeping (`retryDelayMs` /
223
+ * `lastAttemptAt` / `nextAttemptAt`): a server that keeps rejecting
224
+ * tokens must not turn into an unthrottled hammer on the auth endpoint —
225
+ * the shared-backoff-window gate in `getCredentials()` still applies.
226
+ * Pass `{ resetBackoff: true }` when the caller has independent evidence
227
+ * the server is reachable right now (e.g. it just returned the 401 this
228
+ * invalidate() is responding to) — this clears the backoff window so the
229
+ * re-prove is not held behind a stale gate computed from unrelated prior
230
+ * failures (F2b). Does not cancel or reschedule the background renewal
231
+ * timer; a successful next acquire reschedules renewal exactly as it
232
+ * does today.
168
233
  */
169
- invalidate() {
234
+ invalidate(invalidateOpts) {
170
235
  current = null;
236
+ if (invalidateOpts?.resetBackoff) {
237
+ retryDelayMs = 0;
238
+ lastAttemptAt = 0;
239
+ nextAttemptAt = 0;
240
+ hardExpiryEmitted = false;
241
+ }
171
242
  },
172
243
  stop() {
173
244
  stopped = true;
@@ -1 +1 @@
1
- {"version":3,"file":"token-manager.js","sourceRoot":"","sources":["../src/token-manager.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAUH;;;;;GAKG;AACH,MAAM,OAAO,mBAAoB,SAAQ,KAAK;CAAG;AAYjD,MAAM,cAAc,GAAG,IAAI,CAAC;AAC5B,MAAM,eAAe,GAAG,KAAK,CAAC;AAC9B,MAAM,cAAc,GAAG,OAAO,CAAC;AAE/B,MAAM,UAAU,kBAAkB,CAAC,IAAsB;IAKvD,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,IAAI,IAAI,CAAC,GAAG,CAAC;IACjC,IAAI,OAAO,GAA8B,IAAI,CAAC;IAC9C,mEAAmE;IACnE,qEAAqE;IACrE,qEAAqE;IACrE,yEAAyE;IACzE,qEAAqE;IACrE,0BAA0B;IAC1B,IAAI,gBAAgB,GAAiD,IAAI,CAAC;IAC1E,IAAI,QAAQ,GAAuC,IAAI,CAAC;IACxD,IAAI,KAAK,GAAyC,IAAI,CAAC;IACvD,IAAI,YAAY,GAAG,CAAC,CAAC;IACrB,IAAI,aAAa,GAAG,CAAC,CAAC;IACtB,IAAI,iBAAiB,GAAG,KAAK,CAAC;IAC9B,IAAI,OAAO,GAAG,KAAK,CAAC;IACpB,IAAI,SAAS,GAAG,EAAE,CAAC;IAEnB,SAAS,MAAM,CAAC,EAAU;QACxB,OAAO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7 @@ export declare const rememberArgsSchema: z.ZodObject<{
20
20
  importance: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
21
21
  }, z.core.$strip>;
22
22
  export declare const recallArgsSchema: z.ZodObject<{
23
+ principalAgentId: z.ZodOptional<z.ZodString>;
23
24
  query: z.ZodString;
24
25
  limit: z.ZodOptional<z.ZodNumber>;
25
26
  type: z.ZodOptional<z.ZodEnum<{
@@ -40,13 +41,54 @@ export declare const agentLoadArgsSchema: z.ZodObject<{
40
41
  }, z.core.$strip>;
41
42
  /** Tools with no parameters — reject unexpected keys. */
42
43
  export declare const emptyArgsSchema: z.ZodObject<{}, z.core.$strict>;
44
+ /** full_context: optional delegated-read principal + configurable memory limit (CORBOT-45FE6ECE). */
45
+ export declare const fullContextArgsSchema: z.ZodObject<{
46
+ principalAgentId: z.ZodOptional<z.ZodString>;
47
+ memoriesLimit: z.ZodOptional<z.ZodNumber>;
48
+ }, z.core.$strict>;
49
+ export declare const INBOX_MAX_BODY_CHARS = 8000;
50
+ export declare const INBOX_MAX_TASK_ID_CHARS = 128;
51
+ export declare const INBOX_MIN_TTL_SECONDS = 300;
52
+ export declare const INBOX_MAX_TTL_SECONDS = 604800;
53
+ export declare const INBOX_DEFAULT_TTL_SECONDS: number;
54
+ export declare const INBOX_DEFAULT_PAGE_SIZE = 20;
55
+ export declare const INBOX_MAX_PAGE_SIZE = 100;
56
+ export declare const inboxSendArgsSchema: z.ZodObject<{
57
+ recipientAgentId: z.ZodString;
58
+ kind: z.ZodEnum<{
59
+ task: "task";
60
+ update: "update";
61
+ question: "question";
62
+ decision: "decision";
63
+ handoff: "handoff";
64
+ ack: "ack";
65
+ }>;
66
+ body: z.ZodString;
67
+ threadId: z.ZodOptional<z.ZodString>;
68
+ taskId: z.ZodOptional<z.ZodString>;
69
+ inReplyTo: z.ZodOptional<z.ZodString>;
70
+ messageId: z.ZodOptional<z.ZodString>;
71
+ ttlSeconds: z.ZodOptional<z.ZodNumber>;
72
+ }, z.core.$strict>;
73
+ export declare const inboxReadArgsSchema: z.ZodObject<{
74
+ cursor: z.ZodOptional<z.ZodString>;
75
+ limit: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
76
+ unreadOnly: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
77
+ ack: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
78
+ }, z.core.$strict>;
43
79
  export type RememberArgs = z.infer<typeof rememberArgsSchema>;
44
80
  export type RecallArgs = z.infer<typeof recallArgsSchema>;
45
81
  export type HandoffArgs = z.infer<typeof handoffArgsSchema>;
46
82
  export type AgentLoadArgs = z.infer<typeof agentLoadArgsSchema>;
83
+ export type FullContextArgs = z.infer<typeof fullContextArgsSchema>;
84
+ export type InboxSendArgs = z.infer<typeof inboxSendArgsSchema>;
85
+ export type InboxReadArgs = z.infer<typeof inboxReadArgsSchema>;
47
86
  export declare function formatValidationError(error: z.ZodError): string;
48
87
  export declare function parseRememberArgs(raw: unknown): RememberArgs;
49
88
  export declare function parseRecallArgs(raw: unknown): RecallArgs;
50
89
  export declare function parseHandoffArgs(raw: unknown): HandoffArgs;
51
90
  export declare function parseAgentLoadArgs(raw: unknown): AgentLoadArgs;
52
91
  export declare function parseEmptyToolArgs(raw: unknown): Record<string, never>;
92
+ export declare function parseFullContextArgs(raw: unknown): FullContextArgs;
93
+ export declare function parseInboxSendArgs(raw: unknown): InboxSendArgs;
94
+ export declare function parseInboxReadArgs(raw: unknown): InboxReadArgs;
package/dist/tool-args.js CHANGED
@@ -16,7 +16,18 @@ export const rememberArgsSchema = z.object({
16
16
  type: memoryTypeSchema.optional().default('context'),
17
17
  importance: z.number().min(0).max(1).optional().default(0.5),
18
18
  });
19
+ /**
20
+ * Optional delegated-read principal (CORBOT-3785D10D).
21
+ *
22
+ * Names ANOTHER agent whose memories should be read. The server refuses with
23
+ * 403 unless that agent's owner has granted this agent the `memory:read` scope
24
+ * and both share a tenant. Read-only — never accepted on a write tool.
25
+ */
26
+ const principalAgentIdSchema = z
27
+ .string()
28
+ .regex(/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i, 'principalAgentId must be a valid agent UUID');
19
29
  export const recallArgsSchema = z.object({
30
+ principalAgentId: principalAgentIdSchema.optional(),
20
31
  query: z
21
32
  .string({ message: 'query is required and must be a string' })
22
33
  .min(1, 'query is required and must be a string')
@@ -45,6 +56,56 @@ export const agentLoadArgsSchema = z.object({
45
56
  });
46
57
  /** Tools with no parameters — reject unexpected keys. */
47
58
  export const emptyArgsSchema = z.object({}).strict();
59
+ /** full_context: optional delegated-read principal + configurable memory limit (CORBOT-45FE6ECE). */
60
+ export const fullContextArgsSchema = z
61
+ .object({
62
+ principalAgentId: principalAgentIdSchema.optional(),
63
+ memoriesLimit: z.number().int().min(1).max(50).optional(),
64
+ })
65
+ .strict();
66
+ // ── Agent inbox (CORBOT-7115B8AE) ───────────────────────────────────────
67
+ // Mirrors packages/agent-identity-service/src/core/inbox/types.ts and
68
+ // mcp/handlers/agent-inbox-handlers.ts — this package cannot import from
69
+ // agent-identity-service (it ships standalone to npm), so the limits and
70
+ // arg shapes are duplicated here on purpose. Keep them in sync by hand if
71
+ // the server side ever changes them.
72
+ const AGENT_MESSAGE_KINDS = ['task', 'update', 'question', 'decision', 'handoff', 'ack'];
73
+ export const INBOX_MAX_BODY_CHARS = 8_000;
74
+ export const INBOX_MAX_TASK_ID_CHARS = 128;
75
+ export const INBOX_MIN_TTL_SECONDS = 300;
76
+ export const INBOX_MAX_TTL_SECONDS = 604_800;
77
+ export const INBOX_DEFAULT_TTL_SECONDS = 7 * 24 * 60 * 60;
78
+ export const INBOX_DEFAULT_PAGE_SIZE = 20;
79
+ export const INBOX_MAX_PAGE_SIZE = 100;
80
+ const inboxUuidSchema = z
81
+ .string()
82
+ .regex(/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i, 'must be a valid uuid');
83
+ export const inboxSendArgsSchema = z
84
+ .object({
85
+ recipientAgentId: inboxUuidSchema,
86
+ kind: z.enum(AGENT_MESSAGE_KINDS),
87
+ body: z
88
+ .string({ message: 'body is required' })
89
+ .min(1, 'body is required')
90
+ .max(INBOX_MAX_BODY_CHARS, `body exceeds ${INBOX_MAX_BODY_CHARS} characters`),
91
+ threadId: inboxUuidSchema.optional(),
92
+ taskId: z.string().min(1).max(INBOX_MAX_TASK_ID_CHARS).optional(),
93
+ inReplyTo: inboxUuidSchema.optional(),
94
+ messageId: inboxUuidSchema.optional(),
95
+ ttlSeconds: z.number().int().min(INBOX_MIN_TTL_SECONDS).max(INBOX_MAX_TTL_SECONDS).optional(),
96
+ })
97
+ .strict();
98
+ export const inboxReadArgsSchema = z
99
+ .object({
100
+ cursor: z.string().min(1).max(512).optional(),
101
+ limit: z.number().int().min(1).max(INBOX_MAX_PAGE_SIZE).optional().default(INBOX_DEFAULT_PAGE_SIZE),
102
+ // True by default, unlike the REST default of false — a harness reading
103
+ // its inbox wants what's new, not the whole retained stream (matches the
104
+ // MCP tool contract in agent-identity-service's inbox-tools.ts).
105
+ unreadOnly: z.boolean().optional().default(true),
106
+ ack: z.boolean().optional().default(false),
107
+ })
108
+ .strict();
48
109
  export function formatValidationError(error) {
49
110
  return error.issues
50
111
  .map((issue) => {
@@ -75,4 +136,13 @@ export function parseAgentLoadArgs(raw) {
75
136
  export function parseEmptyToolArgs(raw) {
76
137
  return parseOrThrow(emptyArgsSchema, raw);
77
138
  }
139
+ export function parseFullContextArgs(raw) {
140
+ return parseOrThrow(fullContextArgsSchema, raw);
141
+ }
142
+ export function parseInboxSendArgs(raw) {
143
+ return parseOrThrow(inboxSendArgsSchema, raw);
144
+ }
145
+ export function parseInboxReadArgs(raw) {
146
+ return parseOrThrow(inboxReadArgsSchema, raw);
147
+ }
78
148
  //# sourceMappingURL=tool-args.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"tool-args.js","sourceRoot":"","sources":["../src/tool-args.ts"],"names":[],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AM,CAAC,KAAK,CAAC,CAAC,CAAC;IACvD,CAAC;IACD,OAAO,MAAM,CAAC,IAAI,CAAC;AACrB,CAAC;AAED,MAAM,UAAU,iBAAiB,CAAC,GAAY;IAC5C,OAAO,YAAY,CAAC,kBAAkB,EAAE,GAAG,CAAC,CAAC;AAC/C,CAAC;AAED,MAAM,UAAU,eAAe,CAAC,GAAY;IAC1C,OAAO,YAAY,CAAC,gBAAgB,EAAE,GAAG,CAAC,CAAC;AAC7C,CAAC;AAED,MAAM,UAAU,gBAAgB,CAAC,GAAY;IAC3C,OAAO,YAAY,CAAC,iBAAiB,EAAE,GAAG,CAAC,CAAC;AAC9C,CAAC;AAED,MAAM,UAAU,kBAAkB,CAAC,GAAY;IAC7C,OAAO,YAAY,CAAC,mBAAmB,EAAE,GAAG,CAAC,CAAC;AAChD,CAAC;AAED,MAAM,UAAU,kBAAkB,CAAC,GAAY;IAC7C,OAAO,YAAY,CAAC,eAAe,EAAE,GAAG,CAAC,CAAC;AAC5C,CAAC;AAED,MAAM,UAAU,oBAAoB,CAAC,GAAY;IAC/C,OAAO,YAAY,CAAC,qBAAqB,EAAE,GAAG,CAAC,CAAC;AAClD,CAAC;AAED,MAAM,UAAU,kBAAkB,CAAC,GAAY;IAC7C,OAAO,YAAY,CAAC,mBAAmB,EAAE,GAAG,CAAC,CAAC;AAChD,CAAC;AAED,MAAM,UAAU,kBAAkB,CAAC,GAAY;IAC7C,OAAO,YAAY,CAAC,mBAAmB,EAAE,GAAG,CAAC,CAAC;AAChD,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aismemory",
3
- "version": "0.7.0",
3
+ "version": "0.7.2",
4
4
  "description": "Persistent memory for AI agents. MCP server that connects to Agent Identity Service.",
5
5
  "mcpName": "ai.agentsandswarms/ais-memory",
6
6
  "type": "module",