instar 1.3.2010 → 1.3.2012
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/dashboard-pair/service-yes.js +48 -5
- package/dist/commands/server.d.ts.map +1 -1
- package/dist/commands/server.js +19 -3
- package/dist/commands/server.js.map +1 -1
- package/dist/core/PinAttemptStore.d.ts +11 -0
- package/dist/core/PinAttemptStore.d.ts.map +1 -1
- package/dist/core/PinAttemptStore.js +30 -7
- package/dist/core/PinAttemptStore.js.map +1 -1
- package/dist/core/devGatedFeatures.d.ts.map +1 -1
- package/dist/core/devGatedFeatures.js +6 -0
- package/dist/core/devGatedFeatures.js.map +1 -1
- package/dist/data/standards-guard-index.json +1 -1
- package/dist/data/standards-guard-index.meta.json +2 -2
- package/dist/data/standards-registry.meta.json +1 -1
- package/dist/native/InstarWedgeCanary.app/Contents/MacOS/InstarWedgeCanary +0 -0
- package/dist/native/instar-desktop-host +0 -0
- package/dist/recommended/confirmStats.d.ts +52 -0
- package/dist/recommended/confirmStats.d.ts.map +1 -0
- package/dist/recommended/confirmStats.js +149 -0
- package/dist/recommended/confirmStats.js.map +1 -0
- package/dist/recommended/confirmTokens.d.ts +29 -4
- package/dist/recommended/confirmTokens.d.ts.map +1 -1
- package/dist/recommended/confirmTokens.js +51 -9
- package/dist/recommended/confirmTokens.js.map +1 -1
- package/dist/server/AgentServer.d.ts +2 -0
- package/dist/server/AgentServer.d.ts.map +1 -1
- package/dist/server/AgentServer.js +151 -46
- package/dist/server/AgentServer.js.map +1 -1
- package/dist/server/middleware.d.ts.map +1 -1
- package/dist/server/middleware.js +4 -0
- package/dist/server/middleware.js.map +1 -1
- package/dist/server/publicPinHook.d.ts +61 -0
- package/dist/server/publicPinHook.d.ts.map +1 -0
- package/dist/server/publicPinHook.js +3 -0
- package/dist/server/publicPinHook.js.map +1 -0
- package/dist/server/recommendedServiceRoutes.d.ts +14 -0
- package/dist/server/recommendedServiceRoutes.d.ts.map +1 -1
- package/dist/server/recommendedServiceRoutes.js +73 -8
- package/dist/server/recommendedServiceRoutes.js.map +1 -1
- package/dist/server/routes.d.ts +2 -0
- package/dist/server/routes.d.ts.map +1 -1
- package/dist/server/routes.js +23 -0
- package/dist/server/routes.js.map +1 -1
- package/package.json +1 -1
- package/src/data/awareness/approval-link-guess-bound.md +4 -0
- package/src/data/builtin-manifest.json +47 -47
- package/src/data/feature-ladders.json +1 -0
- package/src/data/standards-guard-index.json +1 -1
- package/src/data/standards-guard-index.meta.json +2 -2
- package/src/data/standards-registry.meta.json +1 -1
- package/src/data/state-coherence-registry.json +34 -0
- package/upgrades/1.3.2011.md +36 -0
- package/upgrades/1.3.2012.md +22 -0
- package/upgrades/side-effects/sec135-approval-link-guess-bound.md +134 -0
- package/upgrades/side-effects/whatsapp-typed-path-tags.md +29 -0
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
// A recommended service's confirm page (docs/specs/recommended-services.md, Yes). The person reads
|
|
2
|
-
// what the service involves and confirms with their PIN. Nothing is stored in the browser
|
|
2
|
+
// what the service involves and confirms with their PIN. Nothing about the answer is stored in the browser
|
|
3
|
+
// (only a short-lived lock that lets one tab at a time retry a refused open, SEC-135).
|
|
3
4
|
|
|
4
5
|
const root = document.getElementById('pair-root');
|
|
5
6
|
const service = new URLSearchParams(location.search).get('service') || '';
|
|
@@ -15,6 +16,10 @@ const REFUSED = {
|
|
|
15
16
|
'wrong-owner': 'The owner of this agent changed since this page opened. Nothing changed. Open it again.',
|
|
16
17
|
'wrong-machine': 'This page belongs to a different machine. Nothing changed. Open it again.',
|
|
17
18
|
'too-many-pages': 'This page has been opened too many times in a short while. Nothing changed. Wait a minute, then open it again.',
|
|
19
|
+
// SEC-135: every live page for this service is an owner page; the store only knows how many, not which tabs are open.
|
|
20
|
+
'too-many-pages-active': 'Too many approval pages for this service are still active, including some that may already be closed. They expire on their own within 30 minutes. Try again then, or approve from the dashboard.',
|
|
21
|
+
'too-many-pages-gave-up': 'Too many of these pages opened at once. Reload this one when you need it.',
|
|
22
|
+
'timed-out': 'This page timed out while you were away. Reload to continue.',
|
|
18
23
|
'recommended-services-unavailable': 'I can’t save a choice on this machine right now. Nothing changed.',
|
|
19
24
|
'invalid-recipient': 'That doesn’t look like one email address. Nothing changed. Type just the address, like you@example.com.',
|
|
20
25
|
'recipient-is-the-account': 'Email is set up with a Resend account opened at your current address, so it can only send there. A different address means a new setup: say no here first, then yes with the new address. Nothing changed.',
|
|
@@ -76,11 +81,14 @@ function page(d) {
|
|
|
76
81
|
return;
|
|
77
82
|
}
|
|
78
83
|
if ((r.status === 403 && body.error !== 'insecure-connection') || r.status === 429) {
|
|
79
|
-
|
|
84
|
+
// SEC-135: a paused answer carries the server's own wording, which names the ways through.
|
|
85
|
+
error.textContent = r.status === 429 ? (body.error === 'pin-paused' && body.message ? body.message : 'Too many tries. Wait a while, then try again.') : 'That PIN didn’t work. Try again.';
|
|
80
86
|
pin.value = '';
|
|
81
87
|
pin.focus();
|
|
82
88
|
return;
|
|
83
89
|
}
|
|
90
|
+
// A 30-minute page that expired while the owner was away: one reload mints a fresh one.
|
|
91
|
+
if (body.error === 'token-refused' && typeof d.expiresAt === 'number' && Date.now() >= d.expiresAt) { message('This page timed out', REFUSED['timed-out']); return; }
|
|
84
92
|
message('That didn’t go through', REFUSED[body.error] || 'Something went wrong on my side. Nothing changed.');
|
|
85
93
|
} catch {
|
|
86
94
|
error.textContent = 'I couldn’t reach your agent. Nothing changed. Try again.';
|
|
@@ -156,7 +164,7 @@ function copiesSection(d, pin, error) {
|
|
|
156
164
|
showNames.remove();
|
|
157
165
|
return;
|
|
158
166
|
}
|
|
159
|
-
error.textContent = r.status === 429 ? 'Too many tries. Wait a while, then try again.'
|
|
167
|
+
error.textContent = r.status === 429 ? (body.error === 'pin-paused' && body.message ? body.message : 'Too many tries. Wait a while, then try again.')
|
|
160
168
|
: body.error === 'insecure-connection' ? REFUSED['insecure-connection']
|
|
161
169
|
: r.status === 403 ? 'That PIN didn’t work. Type it below, then try again.'
|
|
162
170
|
: (REFUSED[body.error] || 'That didn’t work. Reload the page and try again.');
|
|
@@ -200,10 +208,45 @@ function codeSection() {
|
|
|
200
208
|
el('form', { class: 'pair-pin', onsubmit: (e) => e.preventDefault() }, code, pin, status, button));
|
|
201
209
|
}
|
|
202
210
|
|
|
211
|
+
// SEC-135: opening the page sends X-Instar-Request, which a page on another origin cannot send, so the
|
|
212
|
+
// server can give an owner's browser its own allowance. A refused open is retried with brakes: wait the
|
|
213
|
+
// refill time the server reports plus 0-10 seconds, double the wait after each further refusal, give up
|
|
214
|
+
// after three tries, and let only one tab of this browser retry at a time (a shared lock), so a restore of
|
|
215
|
+
// many tabs drains one by one instead of in a burst. Storage may be unavailable; then each tab retries alone.
|
|
216
|
+
const RETRY_LOCK = 'instar-confirm-open-retry';
|
|
217
|
+
const MAX_TRIES = 3;
|
|
218
|
+
const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
219
|
+
function lockHeldByOther(id) {
|
|
220
|
+
try { const v = JSON.parse(localStorage.getItem(RETRY_LOCK) || 'null'); return !!v && v.id !== id && v.until > Date.now(); } catch { return false; }
|
|
221
|
+
}
|
|
222
|
+
function takeLock(id) { try { localStorage.setItem(RETRY_LOCK, JSON.stringify({ id, until: Date.now() + 20_000 })); } catch { /* storage unavailable: retry alone */ } }
|
|
223
|
+
function dropLock(id) { try { const v = JSON.parse(localStorage.getItem(RETRY_LOCK) || 'null'); if (v && v.id === id) localStorage.removeItem(RETRY_LOCK); } catch { /* storage unavailable */ } }
|
|
224
|
+
|
|
225
|
+
async function openPage() {
|
|
226
|
+
const r = await fetch(`/recommended-services/${encodeURIComponent(service)}/confirm`, { cache: 'no-store', headers: { 'X-Instar-Request': '1' } });
|
|
227
|
+
return { r, d: await r.json().catch(() => ({})) };
|
|
228
|
+
}
|
|
229
|
+
|
|
203
230
|
async function start() {
|
|
204
231
|
try {
|
|
205
|
-
|
|
206
|
-
|
|
232
|
+
let { r, d } = await openPage();
|
|
233
|
+
if (r.status === 429 && d.error === 'too-many-pages' && d.allProtected) { message('This can’t be set up right now', REFUSED['too-many-pages-active']); return; }
|
|
234
|
+
if (r.status === 429 && d.error === 'too-many-pages' && typeof d.retryAfterSeconds === 'number') {
|
|
235
|
+
const id = Math.random().toString(36).slice(2);
|
|
236
|
+
let wait = d.retryAfterSeconds * 1000;
|
|
237
|
+
for (let tries = 1; tries <= MAX_TRIES; tries++) {
|
|
238
|
+
message('Opening this page', 'A lot of these pages were opened at once. This one opens in a moment.');
|
|
239
|
+
await sleep(wait + Math.random() * 10_000);
|
|
240
|
+
const lockWaitUntil = Date.now() + 5 * 60_000;
|
|
241
|
+
while (lockHeldByOther(id) && Date.now() < lockWaitUntil) await sleep(1000 + Math.random() * 2000);
|
|
242
|
+
takeLock(id);
|
|
243
|
+
try { ({ r, d } = await openPage()); } finally { dropLock(id); }
|
|
244
|
+
if (!(r.status === 429 && d.error === 'too-many-pages')) break;
|
|
245
|
+
if (d.allProtected) { message('This can’t be set up right now', REFUSED['too-many-pages-active']); return; }
|
|
246
|
+
if (tries === MAX_TRIES) { message('This can’t be set up right now', REFUSED['too-many-pages-gave-up']); return; }
|
|
247
|
+
wait = Math.max(wait * 2, (d.retryAfterSeconds || 0) * 1000);
|
|
248
|
+
}
|
|
249
|
+
}
|
|
207
250
|
if (r.ok && d.token) { page(d); return; }
|
|
208
251
|
// Without a token nothing can be confirmed. "cannot-reach-you" never comes from opening the page: the page is still served so a no can be given.
|
|
209
252
|
message('This can’t be set up right now', REFUSED[d.error] || 'Something went wrong on my side. Nothing changed.');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/commands/server.ts"],"names":[],"mappings":"AAsMA,OAAO,EAAE,cAAc,EAAwD,MAAM,2BAA2B,CAAC;AAkBjH,OAAO,EAAE,eAAe,EAAiC,MAAM,iCAAiC,CAAC;AA8BjG,OAAO,EAAE,WAAW,EAAiC,MAAM,0BAA0B,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AO,CAAC,IAAI,CAAC,CAuDzE;AA+BD,wBAAsB,aAAa,CAAC,OAAO,EAAE;IAAE,GAAG,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CA0E5E"}
|
package/dist/commands/server.js
CHANGED
|
@@ -7,7 +7,7 @@ import { TeamConfinement } from '../users/TeamConfinement.js';
|
|
|
7
7
|
import { ALWAYS_AVAILABLE_REFUSAL, daemonRunsAgent } from '../core/alwaysAvailable.js';
|
|
8
8
|
import { boundedHead, boundedTail, BOUNDED_INPUT_MIN_CHARS } from '../core/boundedInput.js';
|
|
9
9
|
import { inlineIMessageAttachments } from '../messaging/imessage/inlineAttachments.js';
|
|
10
|
-
import { messageTypeOf, toWireMedia, parseInboundMediaField } from '../core/inboundMedia.js';
|
|
10
|
+
import { messageTypeOf, toWireMedia, parseInboundMediaField, escapeTypedPathTags } from '../core/inboundMedia.js';
|
|
11
11
|
import { buildTelegramSessionText } from '../core/platformMediaForSession.js';
|
|
12
12
|
import { currentRecoveryStatus } from '../recovery/RecoveryRuntime.js';
|
|
13
13
|
import { buildContextLayers, contextLayersEnabled, CONTEXT_LAYERS_FEATURE_ID } from '../monitoring/contextLayers/contextLayersBoot.js';
|
|
@@ -3912,6 +3912,23 @@ async function whatsappMemoryCheck(whatsapp, jid, metadata) {
|
|
|
3912
3912
|
await whatsapp.send({ userId: jid, content, channel: { type: 'whatsapp', identifier: jid } });
|
|
3913
3913
|
return false;
|
|
3914
3914
|
}
|
|
3915
|
+
/**
|
|
3916
|
+
* SEC-149: a typed `[image:/path]` (or document, video, voice, file) from a WhatsApp sender must
|
|
3917
|
+
* not reach the session as a live media tag, as on Telegram, Slack and iMessage. WhatsApp never
|
|
3918
|
+
* delivers real media as a path tag here (its placeholders are `[Image]`, `[Video]` and
|
|
3919
|
+
* `[Document: <sender's file name>]`), so escaping the whole text loses nothing; the document
|
|
3920
|
+
* placeholder, whose file name the sender chooses, is itself made inert. The sender's profile name
|
|
3921
|
+
* is also the sender's choice and goes into the session's tag, so brackets are removed (as
|
|
3922
|
+
* SessionManager.injectWhatsAppMessage already does for live sessions) and a name like
|
|
3923
|
+
* `[image:/path]` cannot become a live tag in a new session's first prompt either.
|
|
3924
|
+
*/
|
|
3925
|
+
function whatsAppInboundText(msg) {
|
|
3926
|
+
const rawSenderName = msg.metadata?.senderName ?? undefined;
|
|
3927
|
+
return {
|
|
3928
|
+
text: escapeTypedPathTags(msg.content),
|
|
3929
|
+
senderName: rawSenderName ? rawSenderName.replace(/[\[\]]/g, '') || undefined : undefined,
|
|
3930
|
+
};
|
|
3931
|
+
}
|
|
3915
3932
|
/**
|
|
3916
3933
|
* Wire WhatsApp message routing: incoming messages → Claude sessions.
|
|
3917
3934
|
*
|
|
@@ -3924,8 +3941,7 @@ function wireWhatsAppRouting(whatsapp, sessionManager) {
|
|
|
3924
3941
|
const jid = msg.channel?.identifier;
|
|
3925
3942
|
if (!jid)
|
|
3926
3943
|
return;
|
|
3927
|
-
const text = msg
|
|
3928
|
-
const senderName = msg.metadata?.senderName ?? undefined;
|
|
3944
|
+
const { text, senderName } = whatsAppInboundText(msg); // SEC-149
|
|
3929
3945
|
const memoryPlaceKey = `whatsapp:${jid}`;
|
|
3930
3946
|
if (!(await whatsappMemoryCheck(whatsapp, jid, msg.metadata)))
|
|
3931
3947
|
return;
|