aismemory 0.8.8 → 0.8.10
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 +38 -7
- package/dist/agent-key-mode.d.ts +26 -0
- package/dist/agent-key-mode.js +165 -26
- package/dist/agent-only-pass.d.ts +41 -0
- package/dist/agent-only-pass.js +539 -0
- package/dist/ais-http.d.ts +11 -0
- package/dist/ais-http.js +31 -17
- package/dist/cli/hooks.d.ts +35 -5
- package/dist/cli/hooks.js +280 -66
- package/dist/cli/install.d.ts +8 -0
- package/dist/cli/install.js +15 -0
- package/dist/cli/orientation-load.d.ts +18 -0
- package/dist/cli/orientation-load.js +50 -0
- package/dist/cli/read-claude-memory-tree.d.ts +37 -0
- package/dist/cli/read-claude-memory-tree.js +247 -2
- package/dist/cli/setup-core.js +7 -3
- package/dist/cli/slack.d.ts +2 -0
- package/dist/cli/slack.js +263 -0
- package/dist/cli/sync-memory.js +13 -5
- package/dist/cli-info.d.ts +1 -0
- package/dist/cli-info.js +6 -0
- package/dist/decision-card.d.ts +42 -0
- package/dist/decision-card.js +50 -0
- package/dist/decision-ledger.d.ts +24 -0
- package/dist/decision-ledger.js +59 -0
- package/dist/decision-receipt.d.ts +33 -0
- package/dist/decision-receipt.js +72 -0
- package/dist/device-poll.d.ts +16 -7
- package/dist/device-poll.js +31 -3
- package/dist/handoff-doc.d.ts +9 -0
- package/dist/handoff-doc.js +53 -0
- package/dist/inbox-client.js +33 -26
- package/dist/index.js +298 -71
- package/dist/mcp/tools.d.ts +5 -0
- package/dist/mcp/tools.js +121 -31
- package/dist/operating-layer-read.d.ts +38 -0
- package/dist/operating-layer-read.js +164 -0
- package/dist/pending-device-flow.d.ts +2 -0
- package/dist/pending-device-flow.js +1 -0
- package/dist/pipeline/bulk-store.d.ts +4 -3
- package/dist/pipeline/bulk-store.js +45 -8
- package/dist/pipeline/ingestion.d.ts +1 -0
- package/dist/pipeline/ingestion.js +6 -1
- package/dist/pipeline/types.d.ts +4 -0
- package/dist/recall-warning.d.ts +14 -0
- package/dist/recall-warning.js +36 -0
- package/dist/request-timeout.d.ts +27 -2
- package/dist/request-timeout.js +92 -2
- package/dist/run-pass-mode.js +34 -16
- package/dist/session-identity.js +3 -1
- package/dist/session-start.d.ts +13 -3
- package/dist/session-start.js +53 -10
- package/dist/skill-fetch.d.ts +30 -0
- package/dist/skill-fetch.js +88 -0
- package/dist/slack-tools.d.ts +44 -0
- package/dist/slack-tools.js +156 -0
- package/dist/sources/local-claude.js +16 -2
- package/dist/sources/types.d.ts +2 -0
- package/dist/startup-identity.d.ts +4 -0
- package/dist/startup-identity.js +2 -0
- package/dist/tool-args.d.ts +12 -1
- package/dist/tool-args.js +15 -0
- package/dist/tool-scope-filter.d.ts +29 -0
- package/dist/tool-scope-filter.js +123 -0
- package/dist/version-check.d.ts +30 -3
- package/dist/version-check.js +59 -4
- package/dist/workspace-key-mode.js +36 -22
- package/package.json +4 -3
package/dist/ais-http.js
CHANGED
|
@@ -6,8 +6,8 @@ import { isAuthErrorResult } from './auth-staleness.js';
|
|
|
6
6
|
import { AisHttpError, AisInvalidJsonHttpError } from './ais-http-error.js';
|
|
7
7
|
import { emitTelemetry } from './telemetry.js';
|
|
8
8
|
import { retryAfterOf, shouldHonourRetryAfter, sleepSeconds } from './retry-after.js';
|
|
9
|
-
import { readPackageVersion, setServerUpdateNotice } from './version-check.js';
|
|
10
|
-
import { getAisRequestTimeoutMs, toAisRequestError } from './request-timeout.js';
|
|
9
|
+
import { readPackageVersion, setServerMinimumVersion, setServerUpdateNotice, } from './version-check.js';
|
|
10
|
+
import { aisRequestSignal, getAisRequestTimeoutMs, setInboxReadStage, toAisRequestError } from './request-timeout.js';
|
|
11
11
|
import { withDeclaredAgent } from './declared-agent.js';
|
|
12
12
|
import { captureCredentialExpiry, withCredentialExpiry } from './credential-expiry.js';
|
|
13
13
|
// GETs are idempotent, so a single upstream 502/503 is worth one bounded
|
|
@@ -24,6 +24,8 @@ export const AIS_GET_RETRYABLE_STATUSES = new Set([502, 503]);
|
|
|
24
24
|
export const AIS_GET_RETRY_DELAY_MS = 250;
|
|
25
25
|
export const CLIENT_VERSION_HEADER = 'X-AIS-Client-Version';
|
|
26
26
|
export const UPDATE_NOTICE_HEADER = 'X-AIS-Update-Notice';
|
|
27
|
+
/** Structured minimum the client compares locally (CORBOT-4142F77E). */
|
|
28
|
+
export const MIN_CLIENT_VERSION_HEADER = 'X-AIS-Min-Client-Version';
|
|
27
29
|
let clientVersionValue;
|
|
28
30
|
/** `aismemory/<package version>`, from the one shared version reader; null when unreadable. */
|
|
29
31
|
function clientVersionHeaderValue() {
|
|
@@ -37,14 +39,23 @@ function clientVersionHeaderValue() {
|
|
|
37
39
|
}
|
|
38
40
|
return clientVersionValue;
|
|
39
41
|
}
|
|
40
|
-
|
|
42
|
+
/** Attach `X-AIS-Client-Version` for every AIS HTTP stack (bearer, agent-key, …). */
|
|
43
|
+
export function withAisClientVersion(headers) {
|
|
41
44
|
const value = clientVersionHeaderValue();
|
|
42
45
|
if (value !== null)
|
|
43
46
|
headers[CLIENT_VERSION_HEADER] = value;
|
|
44
47
|
return headers;
|
|
45
48
|
}
|
|
46
|
-
/**
|
|
47
|
-
|
|
49
|
+
/**
|
|
50
|
+
* Hand server-sent version signals to the same path whoami / full_context /
|
|
51
|
+
* first-tool reads. Structured minimum (CORBOT-4142F77E) is preferred; the
|
|
52
|
+
* free-text notice covers older servers that only set X-AIS-Update-Notice.
|
|
53
|
+
* Exported so agent-key / workspace-key / run-pass HTTP helpers share one path.
|
|
54
|
+
*/
|
|
55
|
+
export function captureServerVersionHeaders(res) {
|
|
56
|
+
const minimum = res.headers.get(MIN_CLIENT_VERSION_HEADER);
|
|
57
|
+
if (minimum !== null)
|
|
58
|
+
setServerMinimumVersion(minimum);
|
|
48
59
|
const notice = res.headers.get(UPDATE_NOTICE_HEADER);
|
|
49
60
|
if (notice !== null)
|
|
50
61
|
setServerUpdateNotice(notice);
|
|
@@ -78,9 +89,11 @@ function buildUrl(path) {
|
|
|
78
89
|
const baseUrl = aisUrl.endsWith('/') ? aisUrl : `${aisUrl}/`;
|
|
79
90
|
return new URL(path, baseUrl).toString();
|
|
80
91
|
}
|
|
81
|
-
async function readJsonBody(res, path) {
|
|
92
|
+
async function readJsonBody(res, path, method = 'GET') {
|
|
82
93
|
const warning = captureCredentialExpiry(res);
|
|
94
|
+
setInboxReadStage(`${method} ${path}: body`);
|
|
83
95
|
const text = await res.text();
|
|
96
|
+
setInboxReadStage(`${method} ${path}: body`);
|
|
84
97
|
if (text.trim() === '')
|
|
85
98
|
return null;
|
|
86
99
|
try {
|
|
@@ -93,7 +106,7 @@ async function readJsonBody(res, path) {
|
|
|
93
106
|
}
|
|
94
107
|
}
|
|
95
108
|
export async function aisPost(path, body, token) {
|
|
96
|
-
const headers = withDeclaredAgent(
|
|
109
|
+
const headers = withDeclaredAgent(withAisClientVersion({ 'Content-Type': 'application/json' }));
|
|
97
110
|
if (token)
|
|
98
111
|
headers['Authorization'] = `Bearer ${token}`;
|
|
99
112
|
const timeoutMs = getAisRequestTimeoutMs();
|
|
@@ -104,7 +117,7 @@ export async function aisPost(path, body, token) {
|
|
|
104
117
|
headers,
|
|
105
118
|
body: JSON.stringify(body),
|
|
106
119
|
redirect: 'error',
|
|
107
|
-
signal:
|
|
120
|
+
signal: aisRequestSignal(path, timeoutMs, 'POST'),
|
|
108
121
|
});
|
|
109
122
|
}
|
|
110
123
|
catch (err) {
|
|
@@ -116,8 +129,8 @@ export async function aisPost(path, body, token) {
|
|
|
116
129
|
});
|
|
117
130
|
throw wrapped;
|
|
118
131
|
}
|
|
119
|
-
|
|
120
|
-
const data = await readJsonBody(res, path);
|
|
132
|
+
captureServerVersionHeaders(res);
|
|
133
|
+
const data = await readJsonBody(res, path, 'POST');
|
|
121
134
|
if (!res.ok) {
|
|
122
135
|
emitTelemetry({
|
|
123
136
|
event: 'ais.http.failure',
|
|
@@ -135,7 +148,7 @@ export async function aisPost(path, body, token) {
|
|
|
135
148
|
return data;
|
|
136
149
|
}
|
|
137
150
|
export async function aisPatch(path, body, token) {
|
|
138
|
-
const headers = withDeclaredAgent(
|
|
151
|
+
const headers = withDeclaredAgent(withAisClientVersion({ 'Content-Type': 'application/json' }));
|
|
139
152
|
if (token)
|
|
140
153
|
headers['Authorization'] = `Bearer ${token}`;
|
|
141
154
|
const timeoutMs = getAisRequestTimeoutMs();
|
|
@@ -146,7 +159,7 @@ export async function aisPatch(path, body, token) {
|
|
|
146
159
|
headers,
|
|
147
160
|
body: JSON.stringify(body),
|
|
148
161
|
redirect: 'error',
|
|
149
|
-
signal:
|
|
162
|
+
signal: aisRequestSignal(path, timeoutMs, 'PATCH'),
|
|
150
163
|
});
|
|
151
164
|
}
|
|
152
165
|
catch (err) {
|
|
@@ -158,8 +171,8 @@ export async function aisPatch(path, body, token) {
|
|
|
158
171
|
});
|
|
159
172
|
throw wrapped;
|
|
160
173
|
}
|
|
161
|
-
|
|
162
|
-
const data = await readJsonBody(res, path);
|
|
174
|
+
captureServerVersionHeaders(res);
|
|
175
|
+
const data = await readJsonBody(res, path, 'PATCH');
|
|
163
176
|
if (!res.ok) {
|
|
164
177
|
emitTelemetry({
|
|
165
178
|
event: 'ais.http.failure',
|
|
@@ -180,9 +193,9 @@ export async function aisGet(path, token) {
|
|
|
180
193
|
for (;;) {
|
|
181
194
|
try {
|
|
182
195
|
res = await fetch(buildUrl(path), {
|
|
183
|
-
headers: withDeclaredAgent(
|
|
196
|
+
headers: withDeclaredAgent(withAisClientVersion({ 'Authorization': `Bearer ${token}` })),
|
|
184
197
|
redirect: 'error',
|
|
185
|
-
signal:
|
|
198
|
+
signal: aisRequestSignal(path, timeoutMs),
|
|
186
199
|
});
|
|
187
200
|
}
|
|
188
201
|
catch (err) {
|
|
@@ -204,6 +217,7 @@ export async function aisGet(path, token) {
|
|
|
204
217
|
captureCredentialExpiry(res);
|
|
205
218
|
attempt += 1;
|
|
206
219
|
emitTelemetry({ event: 'ais.http.retry', path, httpStatus: res.status });
|
|
220
|
+
setInboxReadStage(`GET ${path}: retry delay`);
|
|
207
221
|
if (retryAfter === null) {
|
|
208
222
|
await new Promise((resolve) => setTimeout(resolve, AIS_GET_RETRY_DELAY_MS));
|
|
209
223
|
}
|
|
@@ -214,7 +228,7 @@ export async function aisGet(path, token) {
|
|
|
214
228
|
}
|
|
215
229
|
break;
|
|
216
230
|
}
|
|
217
|
-
|
|
231
|
+
captureServerVersionHeaders(res);
|
|
218
232
|
const data = await readJsonBody(res, path);
|
|
219
233
|
if (!res.ok) {
|
|
220
234
|
emitTelemetry({
|
package/dist/cli/hooks.d.ts
CHANGED
|
@@ -39,6 +39,7 @@ export declare function resolveHookClient(env: NodeJS.ProcessEnv, home: string):
|
|
|
39
39
|
export declare function redactSecrets(text: string): string;
|
|
40
40
|
/** One concise, secret-free stderr line naming the cause and the fix. */
|
|
41
41
|
export declare function describeHookFailure(err: unknown): string;
|
|
42
|
+
/** Character budget for the rules and recalled memory blocks. */
|
|
42
43
|
export declare const SESSION_START_MAX_CHARS = 8000;
|
|
43
44
|
/** Per-run tags: stored text cannot guess the nonce, so it cannot close the block. */
|
|
44
45
|
export declare function contextTags(nonce: string): {
|
|
@@ -46,14 +47,15 @@ export declare function contextTags(nonce: string): {
|
|
|
46
47
|
close: string;
|
|
47
48
|
};
|
|
48
49
|
export declare const CONTEXT_PREAMBLE: string;
|
|
49
|
-
export declare const OPERATING_LAYER_MAX_CHARS =
|
|
50
|
+
export declare const OPERATING_LAYER_MAX_CHARS = 6000;
|
|
51
|
+
export declare const OPERATING_LAYER_AGENT_RULES_RESERVED_CHARS = 2500;
|
|
50
52
|
export declare function rulesTags(nonce: string): {
|
|
51
53
|
open: string;
|
|
52
54
|
close: string;
|
|
53
55
|
};
|
|
54
56
|
export declare const OPERATING_LAYER_PREAMBLE: string;
|
|
55
|
-
/** Strip
|
|
56
|
-
export declare function stripInvisibles(text: string): string;
|
|
57
|
+
/** Strip invisible controls, optionally preserving the original Unicode characters in a saved note. */
|
|
58
|
+
export declare function stripInvisibles(text: string, normalize?: boolean): string;
|
|
57
59
|
/**
|
|
58
60
|
* Stored text is one line and never a heading: other principals (grant
|
|
59
61
|
* holders, shared sources) can write these fields. The nonce is what stops a
|
|
@@ -61,8 +63,13 @@ export declare function stripInvisibles(text: string): string;
|
|
|
61
63
|
* fullwidth brackets) only keeps the block readable.
|
|
62
64
|
*/
|
|
63
65
|
export declare function inline(text: string): string;
|
|
64
|
-
/**
|
|
65
|
-
|
|
66
|
+
/**
|
|
67
|
+
* The compact, delimited markdown block Claude Code adds to the session.
|
|
68
|
+
* reservedChars is output already printed ahead of it (the RULES head), so
|
|
69
|
+
* the status line, rules and recalled memory share SESSION_START_MAX_CHARS.
|
|
70
|
+
* Startup skill bodies retain their separate byte budget.
|
|
71
|
+
*/
|
|
72
|
+
export declare function formatSessionContext(response: unknown, agentId: string, nonce?: string, reservedChars?: number): string;
|
|
66
73
|
export interface HookOutput {
|
|
67
74
|
stdout: string;
|
|
68
75
|
stderr: string;
|
|
@@ -72,7 +79,22 @@ export interface HookDeps {
|
|
|
72
79
|
home?: string;
|
|
73
80
|
/** Runs `git <args>` in `cwd` and resolves its stdout. */
|
|
74
81
|
runGit?: (cwd: string, args: string[]) => Promise<string>;
|
|
82
|
+
/** Session-start time budget; past it the hook prints RULES NOT LOADED. */
|
|
83
|
+
budgetMs?: number;
|
|
84
|
+
/** Claude Code's SessionStart `source`: startup, resume, clear or compact. */
|
|
85
|
+
source?: string;
|
|
75
86
|
}
|
|
87
|
+
export declare const SESSION_START_BUDGET_MS = 5000;
|
|
88
|
+
export declare const RULES_FIRST_REPLY = "Say the RULES line above, word for word, as the first line of your first reply.";
|
|
89
|
+
/**
|
|
90
|
+
* The rules come back after compaction and on resume, but the ask to repeat
|
|
91
|
+
* the line belongs to the first reply of a conversation, not the middle of one.
|
|
92
|
+
*/
|
|
93
|
+
export declare function asksForRulesLine(source: string | undefined): boolean;
|
|
94
|
+
/** The `source` field of Claude Code's SessionStart hook input, if any. */
|
|
95
|
+
export declare function sessionStartSource(stdin: string): string | undefined;
|
|
96
|
+
/** `version` is a verified layer version (sha256:<64 hex>). */
|
|
97
|
+
export declare function rulesLoadedLine(version: string, ruleCount: number, rulesShown?: number): string;
|
|
76
98
|
export declare function runSessionStart(deps?: HookDeps): Promise<HookOutput>;
|
|
77
99
|
export interface SetupFullContextResult {
|
|
78
100
|
response: unknown;
|
|
@@ -91,5 +113,13 @@ export declare function lastUserMessage(transcriptPath: string | undefined): Pro
|
|
|
91
113
|
/** The handoff summary stored before compaction. */
|
|
92
114
|
export declare function buildPreCompactSummary(input: z.infer<typeof hookInputSchema>, runGit?: typeof defaultRunGit): Promise<string>;
|
|
93
115
|
export declare function runPreCompact(stdin: string, deps?: HookDeps): Promise<HookOutput>;
|
|
116
|
+
/**
|
|
117
|
+
* CORBOT-1417ABA6: the hook entries and the settings file they belong in,
|
|
118
|
+
* printed only. It never reads or writes that file, so nothing already in it
|
|
119
|
+
* (an env block holding a key, say) is echoed. The default target is the
|
|
120
|
+
* user-level ~/.claude/settings.json, which every Claude Code session for this
|
|
121
|
+
* OS user loads, in any folder.
|
|
122
|
+
*/
|
|
123
|
+
export declare function printHookFragment(dir: string, version: string): string;
|
|
94
124
|
export declare function main(argv: string[]): Promise<void>;
|
|
95
125
|
export {};
|