@unbrained/pm-http 0.0.0-stage → 2026.11.19
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/ARCHITECTURE.md +59 -0
- package/CHANGELOG.md +29 -0
- package/LICENSE +21 -0
- package/README.md +186 -2
- package/dist/index.d.ts +116 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +30 -0
- package/dist/index.js.map +1 -0
- package/dist/src/api.d.ts +56 -0
- package/dist/src/api.d.ts.map +1 -0
- package/dist/src/api.js +200 -0
- package/dist/src/api.js.map +1 -0
- package/dist/src/capture.d.ts +23 -0
- package/dist/src/capture.d.ts.map +1 -0
- package/dist/src/capture.js +113 -0
- package/dist/src/capture.js.map +1 -0
- package/dist/src/commands.d.ts +6 -0
- package/dist/src/commands.d.ts.map +1 -0
- package/dist/src/commands.js +84 -0
- package/dist/src/commands.js.map +1 -0
- package/dist/src/core.d.ts +36 -0
- package/dist/src/core.d.ts.map +1 -0
- package/dist/src/core.js +75 -0
- package/dist/src/core.js.map +1 -0
- package/dist/src/derive.d.ts +62 -0
- package/dist/src/derive.d.ts.map +1 -0
- package/dist/src/derive.js +139 -0
- package/dist/src/derive.js.map +1 -0
- package/dist/src/policy.d.ts +29 -0
- package/dist/src/policy.d.ts.map +1 -0
- package/dist/src/policy.js +137 -0
- package/dist/src/policy.js.map +1 -0
- package/dist/src/store.d.ts +42 -0
- package/dist/src/store.d.ts.map +1 -0
- package/dist/src/store.js +124 -0
- package/dist/src/store.js.map +1 -0
- package/dist/src/transport.d.ts +9 -0
- package/dist/src/transport.d.ts.map +1 -0
- package/dist/src/transport.js +144 -0
- package/dist/src/transport.js.map +1 -0
- package/dist/src/types.d.ts +140 -0
- package/dist/src/types.d.ts.map +1 -0
- package/dist/src/types.js +2 -0
- package/dist/src/types.js.map +1 -0
- package/docs/real-data.md +20 -0
- package/manifest.json +14 -0
- package/package.json +150 -4
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import { randomUUID } from 'node:crypto';
|
|
2
|
+
import { acquireLockLease, commitItemMutations, PmClient, readSettings, selectImportAuthor } from '@unbrained/pm-cli/sdk';
|
|
3
|
+
import { digest, HttpError, requireInput } from './core.js';
|
|
4
|
+
/** Registered native extension field, portable through native item exports. */
|
|
5
|
+
export const FIELDS = [{ name: 'http_state', type: 'string', optional: true }];
|
|
6
|
+
/** Reserve a bounded result plus journal overhead before admitting any network effect. */
|
|
7
|
+
export const RESPONSE_RESERVATION = 131072;
|
|
8
|
+
/** Preserve a typed stale-revision reason without changing the public conflict category. */
|
|
9
|
+
export function assertRevision(actual, expected) {
|
|
10
|
+
if (expected !== undefined && actual !== expected)
|
|
11
|
+
throw new HttpError('conflict', 'Expected HTTP revision changed', 'Read current context and declare a new operation with that revision', { reason: 'stale_revision' });
|
|
12
|
+
}
|
|
13
|
+
/** Bind all native task content and comments to one operation without trusting text as ownership. */
|
|
14
|
+
export function targetDigest(item, operation) {
|
|
15
|
+
const { http_state: _state, updated_at: _updated, collection_counts: _counts, comments, ...content } = item;
|
|
16
|
+
return digest({ operation, item: { ...content, comments: comments ?? [] } });
|
|
17
|
+
}
|
|
18
|
+
/** Enforce UTF-8 state capacity and recording slots, including every in-flight reservation. */
|
|
19
|
+
export function capacity(value) {
|
|
20
|
+
const pending = value.plans.filter(plan => plan.stage !== 'recorded' && plan.stage !== 'cancelled');
|
|
21
|
+
const reserved = pending.reduce((total, plan) => { const bytes = plan.reservedBytes ?? 0; if (!Number.isSafeInteger(bytes) || bytes < 0)
|
|
22
|
+
throw new HttpError('capacity', 'Pending response reservation is malformed', 'Inspect the journal before declaring a new operation'); return total + bytes; }, 0);
|
|
23
|
+
const transitions = pending.reduce((total, plan) => total + (plan.stage === 'planned' ? 3 : plan.stage === 'sending' ? 2 : 1), 0);
|
|
24
|
+
if (!Number.isSafeInteger(value.revision + transitions) || value.probes.length > 32 || value.plans.length > 128 || value.observations.length + pending.length > 128 || Buffer.byteLength(JSON.stringify(value)) + reserved > 1048576)
|
|
25
|
+
throw new HttpError('capacity', 'Task cannot retain the bounded HTTP result', 'Use a new investigation task before sending; in-flight result reservations cannot be consumed');
|
|
26
|
+
}
|
|
27
|
+
/** Process-local admission queues avoid overlapping SDK lock publication windows. */
|
|
28
|
+
const queues = new Map();
|
|
29
|
+
/** Empty state is read-compatible with tasks predating this extension. */
|
|
30
|
+
export function state(raw) {
|
|
31
|
+
if (raw === undefined)
|
|
32
|
+
return { version: 1, revision: 0, probes: [], contracts: [], observations: [], plans: [] };
|
|
33
|
+
try {
|
|
34
|
+
const parsed = JSON.parse(String(raw));
|
|
35
|
+
requireInput(parsed.version === 1 && Number.isSafeInteger(parsed.revision) && parsed.revision >= 0 && ['probes', 'contracts', 'observations', 'plans'].every(key => Array.isArray(parsed[key])), 'Invalid HTTP state');
|
|
36
|
+
return parsed;
|
|
37
|
+
}
|
|
38
|
+
catch {
|
|
39
|
+
throw new HttpError('schema', 'HTTP state is malformed or uses an unsupported version', 'Repair through native pm or use a compatible pm-http version');
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
/** Native SDK repository with cooperating writer leases and best-effort native conflict checks. */
|
|
43
|
+
export class Store {
|
|
44
|
+
/** Explicit tracker and invocation policy binding. */
|
|
45
|
+
options;
|
|
46
|
+
/** Native SDK client preserving the caller's backend. */
|
|
47
|
+
client;
|
|
48
|
+
/** Bind explicitly to one tracker; remote mutation needs a host-owned conditional writer. */
|
|
49
|
+
constructor(options) { this.options = options; this.client = options.client ?? new PmClient({ pmRoot: options.workspace, author: options.author, noExtensions: true }); }
|
|
50
|
+
/** Resolve the SDK's attributed author setting. */
|
|
51
|
+
async author() { return selectImportAuthor(this.options.author, (await readSettings(this.options.workspace)).author_default); }
|
|
52
|
+
/** Refuse unsupported remote effects before schema, journal or network writes. */
|
|
53
|
+
writable() { if (this.options.backend === 'remote')
|
|
54
|
+
throw new HttpError('capability', 'Host lacks backend-owned conditional mutation support', 'Use a filesystem tracker for sends and writes; injected clients support reads'); }
|
|
55
|
+
/** Register through SDK schema services, never edit settings files. */
|
|
56
|
+
async register() {
|
|
57
|
+
this.writable();
|
|
58
|
+
const current = (await this.client.schemaListFields()).fields.find(field => field.key === 'http_state');
|
|
59
|
+
if (current !== undefined) {
|
|
60
|
+
requireInput(current.type === 'string', 'http_state must be a registered string field');
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
await this.client.schemaAddField('http_state', { type: 'string', description: 'Versioned pm-http task context', author: await this.author() });
|
|
64
|
+
}
|
|
65
|
+
/** Read the entire relevant extension field without host truncation or git discovery. */
|
|
66
|
+
async read(id) {
|
|
67
|
+
// Explicit unbounded reads exclude budget-exceeded results; the SDK declaration retains that union.
|
|
68
|
+
// Full native reads preserve historical fields even if their registry entry was removed.
|
|
69
|
+
const result = await this.client.get(id, { outputInclude: 'full', outputBudget: 'unbounded', outputLimit: 'unbounded' });
|
|
70
|
+
return { id: result.item.id, item: result.item, value: state(result.item.http_state) };
|
|
71
|
+
}
|
|
72
|
+
/** Guard one package operation with an SDK lease independent of the native item lock. */
|
|
73
|
+
async locked(key, action) {
|
|
74
|
+
this.writable();
|
|
75
|
+
const identity = this.options.workspace + ':' + key;
|
|
76
|
+
const previous = queues.get(identity) ?? Promise.resolve();
|
|
77
|
+
const pending = Promise.withResolvers();
|
|
78
|
+
const tail = previous.then(() => pending.promise);
|
|
79
|
+
queues.set(identity, tail);
|
|
80
|
+
await previous;
|
|
81
|
+
try {
|
|
82
|
+
const author = await this.author();
|
|
83
|
+
const lockId = `http-${digest(key)}`;
|
|
84
|
+
const lease = await acquireLockLease(this.options.workspace, lockId, 120, author, false, false, 10000, { maxWaitMs: 10000 });
|
|
85
|
+
try {
|
|
86
|
+
return await lease.fence(action);
|
|
87
|
+
}
|
|
88
|
+
finally {
|
|
89
|
+
await lease.release();
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
finally {
|
|
93
|
+
pending.resolve();
|
|
94
|
+
if (queues.get(identity) === tail)
|
|
95
|
+
queues.delete(identity);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
/** Freshly read each target and merge cooperating writes; native atomic preconditions remain an SDK gap. */
|
|
99
|
+
async change(id, change, comment, references) {
|
|
100
|
+
this.writable();
|
|
101
|
+
return this.locked(`state:${id}`, async () => {
|
|
102
|
+
const snapshot = await this.read(id);
|
|
103
|
+
const before = JSON.stringify(snapshot.value);
|
|
104
|
+
assertRevision(snapshot.value.revision, this.options.expectedRevision);
|
|
105
|
+
const value = snapshot.value;
|
|
106
|
+
if (!await change(value)) {
|
|
107
|
+
const current = await this.read(id);
|
|
108
|
+
if (JSON.stringify(current.value) !== before)
|
|
109
|
+
throw new HttpError('conflict', 'HTTP target changed during unchanged verification', 'Read the current target and retry');
|
|
110
|
+
return current.value;
|
|
111
|
+
}
|
|
112
|
+
value.revision++;
|
|
113
|
+
capacity(value);
|
|
114
|
+
try {
|
|
115
|
+
await commitItemMutations({ pmRoot: this.options.workspace, author: await this.author(), transactionId: `http-${randomUUID()}`, lockWaitMs: 10000, onTransition: this.options.onTransition, mutations: [{ op: 'update', id: snapshot.id, match: snapshot.item.http_state === undefined ? { key: 'updated_at', value: snapshot.item.updated_at } : { key: 'http_state', value: snapshot.item.http_state }, options: { httpState: JSON.stringify(value), comment: comment === undefined ? undefined : [comment], doc: references } }] });
|
|
116
|
+
}
|
|
117
|
+
catch {
|
|
118
|
+
throw new HttpError('conflict', 'Conditional HTTP context write did not complete', 'Read the current target and recover using the same operation identity');
|
|
119
|
+
}
|
|
120
|
+
return value;
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
//# sourceMappingURL=store.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"store.js","sourceRoot":"","sources":["../../src/store.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,QAAQ,EAAE,YAA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,EAAE,EAAE,EAAE,QAAQ,CAAC,EAAE,EAAE,KAAK,EAAE,QAAQ,CAAC,IAAI,CAAC,UAAU,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE,YAAY,EAAE,KAAK,EAAE,QAAQ,CAAC,IAAI,CAAC,UAAU,EAAE,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE,YAAY,EAAE,KAAK,EAAE,QAAQ,CAAC,IAAI,CAAC,UAAU,EAAE,EAAE,OAAO,EAAE,EAAE,SAAS,EAAE,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,EAAE,OAAO,EAAE,OAAO,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,EAAE,GAAG,EAAE,UAAU,EAAE,EAAE,CAAC,EAAE,CAAC,CAAC;YACzgB,CAAC;YAAC,MAAM,CAAC;gBAAC,MAAM,IAAI,SAAS,CAAC,UAAU,EAAE,iDAAiD,EAAE,uEAAuE,CAAC,CAAC;YAAC,CAAC;YACxK,OAAO,KAAK,CAAC;QACf,CAAC,CAAC,CAAC;IACL,CAAC;CACF"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { Resolver } from './policy.ts';
|
|
2
|
+
import type { Observation, Probe } from './types.ts';
|
|
3
|
+
/** Recognize a runtime's structured upgrade refusal without inspecting or retaining its raw message. */
|
|
4
|
+
export declare function protocolUpgrade(error: unknown): boolean;
|
|
5
|
+
/** Construct a conservative terminal uncertainty without inventing a response. */
|
|
6
|
+
export declare function uncertain(id: string, probe: Probe, reason: string, total?: number | null): Observation;
|
|
7
|
+
/** Send exactly once per hop with one total deadline, DNS pinning, and no automatic retries. */
|
|
8
|
+
export declare function capture(id: string, probe: Probe, caller?: AbortSignal, resolver?: Resolver): Promise<Observation>;
|
|
9
|
+
//# sourceMappingURL=transport.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transport.d.ts","sourceRoot":"","sources":["../../src/transport.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,KAAK,EAAE,WAAW,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAErD,wGAAwG;AACxG,wBAAgB,eAAe,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAAkH;AAC1K,kFAAkF;AAClF,wBAAgB,SAAS,CAAC,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,GAAE,MAAM,GAAG,IAAW,GAAG,WAAW,CAE5G;AACD,gGAAgG;AAChG,wBAAsB,OAAO,CAAC,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,CAAC,EAAE,WAAW,EAAE,QAAQ,CAAC,EAAE,QAAQ,GAAG,OAAO,CAAC,WAAW,CAAC,CA2EvH"}
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
import { request as httpRequest } from 'node:http';
|
|
2
|
+
import { request as httpsRequest } from 'node:https';
|
|
3
|
+
import { performance } from 'node:perf_hooks';
|
|
4
|
+
import { bodyDigest, bodyShape, captureHeaders, jsonMediaType } from './capture.js';
|
|
5
|
+
import { HttpError, digest } from './core.js';
|
|
6
|
+
import { destination, mutating, parseUrl, requestFor, within } from './policy.js';
|
|
7
|
+
/** Recognize a runtime's structured upgrade refusal without inspecting or retaining its raw message. */
|
|
8
|
+
export function protocolUpgrade(error) { return typeof error === 'object' && error !== null && 'code' in error && error.code === 'UnrequestedUpgrade'; }
|
|
9
|
+
/** Construct a conservative terminal uncertainty without inventing a response. */
|
|
10
|
+
export function uncertain(id, probe, reason, total = null) {
|
|
11
|
+
return { id, probe: probe.name, probeDigest: digest(probe), at: new Date().toISOString(), outcome: 'uncertain', headers: {}, selectedHeaders: probe.responseHeaders, bytes: 0, timing: { total }, redirects: [], receipt: { bodyTruncated: false, headersOmitted: 0, shapeIncomplete: true, redactions: 0, redirectsOmitted: 0, digestScope: 'captured-prefix' }, retry: { automaticRetries: 0, safeToRepeat: !mutating(probe), reason } };
|
|
12
|
+
}
|
|
13
|
+
/** Send exactly once per hop with one total deadline, DNS pinning, and no automatic retries. */
|
|
14
|
+
export async function capture(id, probe, caller, resolver) {
|
|
15
|
+
const request = requestFor(probe, true);
|
|
16
|
+
const started = performance.now();
|
|
17
|
+
const controller = new AbortController();
|
|
18
|
+
/** Preserve caller cancellation separately from timeouts. */
|
|
19
|
+
const cancel = () => controller.abort();
|
|
20
|
+
caller?.addEventListener('abort', cancel, { once: true });
|
|
21
|
+
if (caller?.aborted)
|
|
22
|
+
cancel();
|
|
23
|
+
const timer = setTimeout(cancel, probe.timeoutMs);
|
|
24
|
+
const redirects = [];
|
|
25
|
+
let unsupportedProtocol = false;
|
|
26
|
+
const timing = { total: 0 };
|
|
27
|
+
/** Interrupt DNS as well as socket IO without logging raw resolver errors. */
|
|
28
|
+
async function addressFor(url) {
|
|
29
|
+
if (controller.signal.aborted)
|
|
30
|
+
throw new HttpError('timeout', 'Request deadline elapsed');
|
|
31
|
+
const cancellation = Promise.withResolvers();
|
|
32
|
+
/** Cancel the pending DNS phase at the same total deadline as socket work. */
|
|
33
|
+
const abort = () => { cancellation.reject(new HttpError('timeout', 'Request deadline elapsed')); };
|
|
34
|
+
controller.signal.addEventListener('abort', abort, { once: true });
|
|
35
|
+
try {
|
|
36
|
+
const result = await Promise.race([destination(url, probe.boundary, resolver), cancellation.promise]);
|
|
37
|
+
timing.dns = performance.now() - started;
|
|
38
|
+
return result;
|
|
39
|
+
}
|
|
40
|
+
finally {
|
|
41
|
+
controller.signal.removeEventListener('abort', abort);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
try {
|
|
45
|
+
let url = request.url;
|
|
46
|
+
let remainingBytes = probe.maxBytes;
|
|
47
|
+
for (let hop = 0; hop <= 5; hop++) {
|
|
48
|
+
within(url, probe.boundary, hop);
|
|
49
|
+
const address = await addressFor(url);
|
|
50
|
+
const response = await new Promise((resolve, reject) => {
|
|
51
|
+
let settled = false;
|
|
52
|
+
let responding = false;
|
|
53
|
+
const req = (url.protocol === 'https:' ? httpsRequest : httpRequest)(url, { method: probe.method, headers: request.headers, signal: controller.signal, agent: false, family: address.family, maxHeaderSize: 16384, lookup: (_host, _options, done) => done(null, address.address, address.family) }, res => {
|
|
54
|
+
if (res.statusCode === 101) {
|
|
55
|
+
stopProtocol(res, res.socket);
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
responding = true;
|
|
59
|
+
timing.firstByte = performance.now() - started;
|
|
60
|
+
const chunks = [];
|
|
61
|
+
let size = 0;
|
|
62
|
+
/** Settle exactly once and close a capped stream promptly. */
|
|
63
|
+
const finish = (truncated) => { if (settled)
|
|
64
|
+
return; settled = true; controller.signal.removeEventListener('abort', fail); resolve({ status: res.statusCode, raw: res.rawHeaders, bytes: Buffer.concat(chunks), truncated, location: res.headers.location }); if (truncated)
|
|
65
|
+
res.destroy(); };
|
|
66
|
+
res.on('data', (chunk) => { const remaining = remainingBytes - size; chunks.push(chunk.subarray(0, remaining)); size += Math.min(chunk.length, remaining); if (chunk.length > remaining)
|
|
67
|
+
finish(true); });
|
|
68
|
+
res.on('end', () => finish(false));
|
|
69
|
+
res.on('error', fail);
|
|
70
|
+
res.once('aborted', fail);
|
|
71
|
+
res.once('close', fail);
|
|
72
|
+
});
|
|
73
|
+
/** Settle independently of ordinary response/error events, including abort and premature close. */
|
|
74
|
+
const fail = (error) => { if (settled)
|
|
75
|
+
return; unsupportedProtocol ||= protocolUpgrade(error); settled = true; controller.signal.removeEventListener('abort', fail); req.destroy(); reject(new Error('Incomplete HTTP exchange')); };
|
|
76
|
+
/** Close detached protocol sockets without admitting unbounded non-HTTP payloads or header values. */
|
|
77
|
+
const stopProtocol = (_response, socket) => { unsupportedProtocol = true; timing.firstByte = performance.now() - started; socket.once('error', fail); socket.destroy(); fail(); };
|
|
78
|
+
req.once('upgrade', stopProtocol);
|
|
79
|
+
req.once('connect', stopProtocol);
|
|
80
|
+
req.once('close', () => { if (!responding)
|
|
81
|
+
fail(); });
|
|
82
|
+
req.on('socket', socket => { socket.once('connect', () => { timing.connect = performance.now() - started; }); socket.once('secureConnect', () => { timing.tls = performance.now() - started; }); });
|
|
83
|
+
req.maxHeadersCount = 0; // The parser's 16 KiB byte cap bounds allocation; count the full header set truthfully.
|
|
84
|
+
req.on('error', fail);
|
|
85
|
+
controller.signal.addEventListener('abort', fail, { once: true });
|
|
86
|
+
req.end(request.body);
|
|
87
|
+
});
|
|
88
|
+
remainingBytes -= response.bytes.length;
|
|
89
|
+
const isRedirect = [301, 302, 303, 307, 308].includes(response.status) && response.location !== undefined;
|
|
90
|
+
const redirectsOmitted = isRedirect && (response.truncated || remainingBytes === 0) ? 1 : 0;
|
|
91
|
+
if (isRedirect && redirectsOmitted === 0) {
|
|
92
|
+
// Never reinterpret a reviewed mutation as a GET or resend its body automatically.
|
|
93
|
+
if (mutating(probe))
|
|
94
|
+
throw new HttpError('mutation_redirect', 'Mutating redirects require a separate reviewed probe', 'Inspect the response and declare the redirect destination explicitly');
|
|
95
|
+
let next;
|
|
96
|
+
try {
|
|
97
|
+
if (response.location.includes('\\'))
|
|
98
|
+
throw new Error();
|
|
99
|
+
next = parseUrl(new URL(response.location, url).href);
|
|
100
|
+
}
|
|
101
|
+
catch {
|
|
102
|
+
throw new HttpError('redirect', 'Redirect target is not an admissible HTTP destination', 'Declare a separate safe probe after reviewing the redirect');
|
|
103
|
+
}
|
|
104
|
+
within(next, probe.boundary, hop + 1);
|
|
105
|
+
// Redirect queries are remote data, so only a digest enters durable context.
|
|
106
|
+
redirects.push(digest(next.href));
|
|
107
|
+
url = next;
|
|
108
|
+
continue;
|
|
109
|
+
}
|
|
110
|
+
const selected = captureHeaders(response.raw, [...probe.responseHeaders, 'content-type'], probe.maxHeaders, request.secrets);
|
|
111
|
+
const json = jsonMediaType(response.raw, probe.maxHeaders);
|
|
112
|
+
if (!probe.responseHeaders.includes('content-type'))
|
|
113
|
+
delete selected.headers['content-type'];
|
|
114
|
+
let shape;
|
|
115
|
+
let shapeIncomplete = response.truncated || json === undefined && selected.omitted > 0;
|
|
116
|
+
if (!response.truncated && response.bytes.length > 0 && json === true) {
|
|
117
|
+
try {
|
|
118
|
+
const result = bodyShape(JSON.parse(response.bytes.toString('utf8')));
|
|
119
|
+
shape = result.shape;
|
|
120
|
+
shapeIncomplete = result.incomplete;
|
|
121
|
+
}
|
|
122
|
+
catch {
|
|
123
|
+
shapeIncomplete = true;
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
timing.total = performance.now() - started;
|
|
127
|
+
return { id, probe: probe.name, probeDigest: digest(probe), at: new Date().toISOString(), outcome: 'response', status: response.status, headers: selected.headers, selectedHeaders: probe.responseHeaders, ...(shape === undefined ? {} : { shape }), digest: bodyDigest(response.bytes), bytes: response.bytes.length, timing: { ...timing }, redirects, receipt: { bodyTruncated: response.truncated, headersOmitted: selected.omitted, shapeIncomplete, redactions: selected.redactions, redirectsOmitted, digestScope: response.truncated ? 'captured-prefix' : 'complete' }, retry: { automaticRetries: 0, safeToRepeat: !mutating(probe), reason: 'No automatic retries; repeat only by explicit new operation' } };
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
catch (error) {
|
|
131
|
+
if (caller?.aborted)
|
|
132
|
+
throw new HttpError('cancelled', 'Send cancelled without an observation', 'Use a new operation identity for any explicitly reviewed retry');
|
|
133
|
+
if (error instanceof HttpError && error.code !== 'timeout')
|
|
134
|
+
throw error;
|
|
135
|
+
timing.total = performance.now() - started;
|
|
136
|
+
return { ...uncertain(id, probe, unsupportedProtocol ? 'HTTP upgrade/tunnel outside capture; inspect the endpoint before any explicit retry' : 'Transport outcome uncertain; no automatic retry', timing.total), timing: { ...timing } };
|
|
137
|
+
}
|
|
138
|
+
finally {
|
|
139
|
+
clearTimeout(timer);
|
|
140
|
+
caller?.removeEventListener('abort', cancel);
|
|
141
|
+
}
|
|
142
|
+
throw new HttpError('redirect_limit', 'Redirect chain exceeds five hops', 'Declare a probe for the final authorized destination');
|
|
143
|
+
}
|
|
144
|
+
//# sourceMappingURL=transport.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transport.js","sourceRoot":"","sources":["../../src/transport.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,WAAW,CAAC;AACnD,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,YAAY,CAAC;AAGrD,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AACpF,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAC9C,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAIlF,wGAAwG;AACxG,MAAM,UAAU,eAAe,CAAC,KAAc,IAAa,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,MAAM,IAAI,KAAK,IAAI,KAAK,CAAC,IAAI,KAAK,oBAAoB,CAAC,CAAC,CAAC;AAC1K,kFAAkF;AAClF,MAAM,UAAU,SAAS,CAAC,EAAU,EAAE,KAAY,EAAE,MAAc,EAAE,KAAK,GAAkB,IAAI;IAC7F,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,KAAK,CAAC,IAAI,EAAE,WAAW,EAAE,MAAM,CAAC,KAAK,CAAC,EAAE,EAAE,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,EAAE,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,EAAE,EAAE,eAAe,EAAE,KAAK,CAAC,eAAe,EAAE,KAAK,EAAE,CAAC,EAAE,MAAM,EAAE,EAAE,KAAK,EAAE,EAAE,SA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C;QAAC,YAAY,CAAC,KAAK,CAAC,CAAC;QAAC,MAAM,EAAE,mBAAmB,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;IAAC,CAAC;IAChF,MAAM,IAAI,SAAS,CAAC,gBAAgB,EAAE,kCAAkC,EAAE,sDAAsD,CAAC,CAAC;AACpI,CAAC"}
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
import type { PmClient, CommitWorkspaceTransactionOptions } from '@unbrained/pm-cli/sdk';
|
|
2
|
+
/** JSON shape without response values or property names. */
|
|
3
|
+
export interface Shape {
|
|
4
|
+
type: string;
|
|
5
|
+
properties?: Record<string, Shape>;
|
|
6
|
+
items?: Shape[];
|
|
7
|
+
}
|
|
8
|
+
/** Explicit destination authorization; private addresses require a literal declaration. */
|
|
9
|
+
export interface Boundary {
|
|
10
|
+
origin: string;
|
|
11
|
+
prefix: string;
|
|
12
|
+
private: boolean;
|
|
13
|
+
}
|
|
14
|
+
/** A reviewed permission is separate from the request declaration. */
|
|
15
|
+
export interface Review {
|
|
16
|
+
allowMutation: true;
|
|
17
|
+
author: string;
|
|
18
|
+
reason: string;
|
|
19
|
+
at: string;
|
|
20
|
+
}
|
|
21
|
+
/** Durable declaration; credentials and bodies are environment references only. */
|
|
22
|
+
export interface Probe {
|
|
23
|
+
name: string;
|
|
24
|
+
method: string;
|
|
25
|
+
url: string;
|
|
26
|
+
headers: Record<string, string>;
|
|
27
|
+
body?: string;
|
|
28
|
+
boundary: Boundary;
|
|
29
|
+
maxBytes: number;
|
|
30
|
+
timeoutMs: number;
|
|
31
|
+
maxHeaders: number;
|
|
32
|
+
responseHeaders: string[];
|
|
33
|
+
review?: Review;
|
|
34
|
+
}
|
|
35
|
+
/** Expected bounded response contract, with structural JSON keys hashed. */
|
|
36
|
+
export interface Contract {
|
|
37
|
+
probe: string;
|
|
38
|
+
statuses: number[];
|
|
39
|
+
headers: string[];
|
|
40
|
+
shape?: Shape;
|
|
41
|
+
maxLatencyMs?: number;
|
|
42
|
+
}
|
|
43
|
+
/** Truthful losses at the HTTP capture boundary. */
|
|
44
|
+
export interface CaptureReceipt {
|
|
45
|
+
bodyTruncated: boolean;
|
|
46
|
+
headersOmitted: number;
|
|
47
|
+
shapeIncomplete: boolean;
|
|
48
|
+
redactions: number;
|
|
49
|
+
redirectsOmitted: number;
|
|
50
|
+
digestScope: 'captured-prefix' | 'complete';
|
|
51
|
+
}
|
|
52
|
+
/** One historical response or uncertain transport outcome; never a live health claim. */
|
|
53
|
+
export interface Observation {
|
|
54
|
+
id: string;
|
|
55
|
+
probe: string;
|
|
56
|
+
probeDigest: string;
|
|
57
|
+
at: string;
|
|
58
|
+
outcome: 'response' | 'uncertain';
|
|
59
|
+
status?: number;
|
|
60
|
+
headers: Record<string, string>;
|
|
61
|
+
selectedHeaders?: string[];
|
|
62
|
+
shape?: Shape;
|
|
63
|
+
digest?: string;
|
|
64
|
+
bytes: number;
|
|
65
|
+
timing: {
|
|
66
|
+
dns?: number;
|
|
67
|
+
connect?: number;
|
|
68
|
+
tls?: number;
|
|
69
|
+
firstByte?: number;
|
|
70
|
+
total: number | null;
|
|
71
|
+
};
|
|
72
|
+
redirects: string[];
|
|
73
|
+
receipt: CaptureReceipt;
|
|
74
|
+
retry: {
|
|
75
|
+
automaticRetries: 0;
|
|
76
|
+
safeToRepeat: boolean;
|
|
77
|
+
reason: string;
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
/** Durable send intent, including the exact revision-bound declaration digest. */
|
|
81
|
+
export interface Plan {
|
|
82
|
+
id: string;
|
|
83
|
+
probe: string;
|
|
84
|
+
probeDigest: string;
|
|
85
|
+
stage: 'planned' | 'sending' | 'received' | 'recorded' | 'cancelled';
|
|
86
|
+
observation?: Observation;
|
|
87
|
+
expectedRevision?: number;
|
|
88
|
+
guardRevision?: number;
|
|
89
|
+
targetDigest?: string;
|
|
90
|
+
reservedBytes?: number;
|
|
91
|
+
}
|
|
92
|
+
/** Native task extension envelope. Every change increments revision. */
|
|
93
|
+
export interface State {
|
|
94
|
+
version: 1;
|
|
95
|
+
revision: number;
|
|
96
|
+
probes: Probe[];
|
|
97
|
+
contracts: Contract[];
|
|
98
|
+
observations: Observation[];
|
|
99
|
+
plans: Plan[];
|
|
100
|
+
}
|
|
101
|
+
/** Public deterministic send/record boundaries used for fault injection. */
|
|
102
|
+
export type Step = 'validated' | 'plan-ready' | 'planned' | 'sending' | 'received' | 'record-ready' | 'recorded' | 'complete';
|
|
103
|
+
/** SDK integration options; no git dependency or implicit network execution. */
|
|
104
|
+
export interface Options {
|
|
105
|
+
workspace: string;
|
|
106
|
+
author?: string;
|
|
107
|
+
client?: PmClient;
|
|
108
|
+
backend?: 'filesystem' | 'remote';
|
|
109
|
+
expectedRevision?: number;
|
|
110
|
+
operationId?: string;
|
|
111
|
+
signal?: AbortSignal;
|
|
112
|
+
boundary?: (step: Step) => Promise<void> | void;
|
|
113
|
+
onTransition?: CommitWorkspaceTransactionOptions['onTransition'];
|
|
114
|
+
}
|
|
115
|
+
/** Probe declaration input shared by CLI previews and SDK writes. */
|
|
116
|
+
export interface ProbeInput {
|
|
117
|
+
url: string;
|
|
118
|
+
method?: string;
|
|
119
|
+
headers?: string[];
|
|
120
|
+
body?: string;
|
|
121
|
+
boundary?: string;
|
|
122
|
+
maxBytes?: number;
|
|
123
|
+
timeoutMs?: number;
|
|
124
|
+
maxHeaders?: number;
|
|
125
|
+
responseHeaders?: string[];
|
|
126
|
+
}
|
|
127
|
+
/** A historical contract verdict, never a claim of present health. */
|
|
128
|
+
export interface Verdict {
|
|
129
|
+
observation: string;
|
|
130
|
+
probe: string;
|
|
131
|
+
at: string;
|
|
132
|
+
result: 'satisfies' | 'violates' | 'unknown';
|
|
133
|
+
reasons: string[];
|
|
134
|
+
}
|
|
135
|
+
/** Exact outstanding evidence request. */
|
|
136
|
+
export interface Missing {
|
|
137
|
+
probe: string;
|
|
138
|
+
evidence: 'observation' | 'contract' | 'complete-response';
|
|
139
|
+
}
|
|
140
|
+
//# source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AACrE,MAAM,WAAW,UAAU;IAAG,GAAG,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAAC,UAAU,CAAC,EAAE,MAAM,CAAC;IAAC,eAAe,CAAC,EAAE,MAAM,EAAE,CAAC;CAAE;AAC3M,sEAAsE;AACtE,MAAM,WAAW,OAAO;IAAG,WAAW,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,EAAE,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,WAAW,GAAG,UAAU,GAAG,SAAS,CAAC;IAAC,OAAO,EAAE,MAAM,EAAE,CAAC;CAAE;AAC7I,0CAA0C;AAC1C,MAAM,WAAW,OAAO;IAAG,KAAK,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,aAAa,GAAG,UAAU,GAAG,mBAAmB,CAAC;CAAE"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# Real-data proof
|
|
2
|
+
|
|
3
|
+
Measured 2026-10-29T00:58:16.455Z. Ten explicit read-only requests in a temporary non-git SDK tracker, deleted after the run. Public calls used the unauthenticated GitHub REST repository endpoints for public fleet packages; remaining calls used a synthetic local incident. No credentials were sent. Throttling stops further public calls.
|
|
4
|
+
|
|
5
|
+
| Measure | Result |
|
|
6
|
+
|---|---:|
|
|
7
|
+
| Observations | 10 |
|
|
8
|
+
| HTTP calls | 10 (2 public, 8 fixture) |
|
|
9
|
+
| Captured raw response body bytes | 103388 |
|
|
10
|
+
| Raw body heuristic units (bytes/4, rounded up) | 25847 |
|
|
11
|
+
| Historical packet heuristic units (bytes/4, rounded up) | 817 |
|
|
12
|
+
| Packet omitted rows | 0 |
|
|
13
|
+
| Header redactions | 90 |
|
|
14
|
+
| Total elapsed milliseconds, including SDK setup and recording | 65151 |
|
|
15
|
+
|
|
16
|
+
Packet costs include the omission receipt and the larger serialized JSON/TOON format. Raw cost includes response bodies only, excluding headers and transcript/request overhead. Body values and keys are never retained. Historical captures are not current health. The incident changes from a successful numeric revision to a failing string revision; the packet identifies the first bad and preceding last good observations. Missing evidence: [{"probe":"pm-evidence","evidence":"complete-response"},{"probe":"pm-hypothesis","evidence":"complete-response"},{"probe":"pending","evidence":"observation"},{"probe":"pending","evidence":"contract"}]. Public schemas wider than 64 properties produce explicit structural omissions.
|
|
17
|
+
|
|
18
|
+
The historical 817 figure is a byte-derived heuristic, not a tokenizer count or guaranteed model-token bound. Exact JSON and TOON lengths were not saved, so they cannot be reconstructed from that rounded value. The SDK fitter and new accounting fields change current packet costs; this table is an immutable historical measurement, not a current-size claim.
|
|
19
|
+
|
|
20
|
+
Successful-task scope: this SDK harness performs tracker initialization and task creation, four probe declarations, three contract declarations, ten explicit `send` operations (two public and eight fixture observations), then `observations`, `differencePacket`, and `missingEvidence` reads. Native SDK recording/journal receipts, request/response metadata, setup returns, the observation-list and missing-evidence responses, and this report are excluded from the body-only baseline. The packet figure includes only its own historical receipt and framing. No automatic request retries are implemented, and this run recorded ten calls for ten sends; no recovery/retry transcript or all-command serialized costs were measured. Consequently these numbers do not establish an end-to-end token reduction. Public responses are not re-fetched for this correction.
|
package/manifest.json
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "pm-http",
|
|
3
|
+
"version": "2026.11.19",
|
|
4
|
+
"description": "Task-scoped HTTP investigation evidence, bounded contracts and difference packets",
|
|
5
|
+
"author": "@unbraind",
|
|
6
|
+
"entry": "./dist/index.js",
|
|
7
|
+
"pm_min_version": "2026.10.28",
|
|
8
|
+
"priority": 90,
|
|
9
|
+
"capabilities": [
|
|
10
|
+
"commands",
|
|
11
|
+
"schema",
|
|
12
|
+
"renderers"
|
|
13
|
+
]
|
|
14
|
+
}
|