@immediately-run/sdk 0.72.0 → 0.74.1
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/dist/dnd.cjs +2 -5
- package/dist/dnd.cjs.map +1 -1
- package/dist/dnd.d.cts +8 -1
- package/dist/dnd.d.ts +8 -1
- package/dist/dnd.js +2 -5
- package/dist/dnd.js.map +1 -1
- package/dist/editor.cjs +2 -5
- package/dist/editor.cjs.map +1 -1
- package/dist/editor.d.cts +34 -5
- package/dist/editor.d.ts +34 -5
- package/dist/editor.js +2 -5
- package/dist/editor.js.map +1 -1
- package/dist/generated/spaces.cjs +40 -0
- package/dist/generated/spaces.cjs.map +1 -1
- package/dist/generated/spaces.d.cts +96 -1
- package/dist/generated/spaces.d.ts +96 -1
- package/dist/generated/spaces.js +35 -0
- package/dist/generated/spaces.js.map +1 -1
- package/dist/index.cjs +2 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/ipc.cjs +3 -10
- package/dist/ipc.cjs.map +1 -1
- package/dist/ipc.js +3 -10
- package/dist/ipc.js.map +1 -1
- package/dist/llm.cjs.map +1 -1
- package/dist/llm.d.cts +14 -0
- package/dist/llm.d.ts +14 -0
- package/dist/llm.js.map +1 -1
- package/dist/mounts.cjs +14 -15
- package/dist/mounts.cjs.map +1 -1
- package/dist/mounts.d.cts +9 -2
- package/dist/mounts.d.ts +9 -2
- package/dist/mounts.js +15 -16
- package/dist/mounts.js.map +1 -1
- package/dist/openExternal.cjs +2 -7
- package/dist/openExternal.cjs.map +1 -1
- package/dist/openExternal.d.cts +7 -1
- package/dist/openExternal.d.ts +7 -1
- package/dist/openExternal.js +2 -7
- package/dist/openExternal.js.map +1 -1
- package/dist/openRepository.cjs +2 -7
- package/dist/openRepository.cjs.map +1 -1
- package/dist/openRepository.d.cts +7 -1
- package/dist/openRepository.d.ts +7 -1
- package/dist/openRepository.js +2 -7
- package/dist/openRepository.js.map +1 -1
- package/dist/protocolRefusal.cjs +35 -0
- package/dist/protocolRefusal.cjs.map +1 -0
- package/dist/protocolRefusal.d.cts +54 -0
- package/dist/protocolRefusal.d.ts +54 -0
- package/dist/protocolRefusal.js +12 -0
- package/dist/protocolRefusal.js.map +1 -0
- package/dist/protocolSchemes.cjs +1 -0
- package/dist/protocolSchemes.cjs.map +1 -1
- package/dist/protocolSchemes.d.cts +1 -0
- package/dist/protocolSchemes.d.ts +1 -0
- package/dist/protocolSchemes.js +2 -0
- package/dist/protocolSchemes.js.map +1 -1
- package/dist/secrets.cjs +2 -5
- package/dist/secrets.cjs.map +1 -1
- package/dist/secrets.d.cts +8 -1
- package/dist/secrets.d.ts +8 -1
- package/dist/secrets.js +2 -5
- package/dist/secrets.js.map +1 -1
- package/dist/spacesMode.cjs +101 -0
- package/dist/spacesMode.cjs.map +1 -0
- package/dist/spacesMode.d.cts +149 -0
- package/dist/spacesMode.d.ts +149 -0
- package/dist/spacesMode.js +75 -0
- package/dist/spacesMode.js.map +1 -0
- package/dist/vcs.cjs +2 -5
- package/dist/vcs.cjs.map +1 -1
- package/dist/vcs.d.cts +8 -1
- package/dist/vcs.d.ts +8 -1
- package/dist/vcs.js +2 -5
- package/dist/vcs.js.map +1 -1
- package/dist/version.cjs +1 -1
- package/dist/version.cjs.map +1 -1
- package/dist/version.d.cts +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/dist/version.js.map +1 -1
- package/package.json +4 -3
package/dist/openExternal.cjs
CHANGED
|
@@ -22,17 +22,12 @@ __export(openExternal_exports, {
|
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(openExternal_exports);
|
|
24
24
|
var import_sandboxUtils = require("./sandboxUtils");
|
|
25
|
+
var import_protocolRefusal = require("./protocolRefusal");
|
|
25
26
|
var import_protocol = require("./generated/protocol");
|
|
26
27
|
var import_protocolSchemes = require("./protocolSchemes");
|
|
27
28
|
async function openExternal(url) {
|
|
28
29
|
const res = await (0, import_sandboxUtils.protocolRequest)(import_protocolSchemes.SCHEMES[import_protocol.PROTOCOL_OPENLINK], "open", [{ url }]);
|
|
29
|
-
|
|
30
|
-
const err = new Error(
|
|
31
|
-
(res && "message" in res ? res.message : void 0) ?? "external link open refused"
|
|
32
|
-
);
|
|
33
|
-
err.code = (res && "code" in res ? res.code : void 0) ?? "unknown";
|
|
34
|
-
throw err;
|
|
35
|
-
}
|
|
30
|
+
(0, import_protocolRefusal.throwOnRefusal)(res, "external link open refused");
|
|
36
31
|
}
|
|
37
32
|
// Annotate the CommonJS export names for ESM import in node:
|
|
38
33
|
0 && (module.exports = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/openExternal.ts"],"sourcesContent":["// Host-mediated \"open this external link in a new tab\" (R3-619).\n//\n// An app frame cannot open an ordinary top-level tab itself for a destination that has to\n// act as itself: a `window.open` or `<a target=\"_blank\">` from inside the sandboxed frame\n// inherits the sandbox (`allow-popups` without `allow-popups-to-escape-sandbox`), so the\n// opened tab runs at the same opaque origin and anything that signs in or posts fails.\n//\n// Unlike `openRepository`, the app here names a URL, not coordinates — the destination is\n// arbitrary, not a platform route. So the host validates the URL and confirms every call\n// (the full destination in its own chrome, opened only on the user's click). The app never\n// receives a `Window` handle; it asks, and the host decides whether and how to open.\n//\n// The same two host-side conditions as `openRepository` hold, and neither is something this\n// call can assert for itself: the confirmation needs the HOST document's live transient\n// user activation (a real click, which the host samples rather than believes), and the\n// confirmation must not consume that activation before the open. Both surface here as\n// ordinary coded refusals.\nimport { protocolRequest } from './sandboxUtils';\nimport { PROTOCOL_OPENLINK } from './generated/protocol';\nimport { SCHEMES } from './protocolSchemes';\n\n/** Why the host refused to open the link.\n *\n * - `invalid` — the URL is not a clean `https:` external destination (scheme, credentials,\n * length, or the host's own origin).\n * - `no-activation` — no live user gesture on the host document. Call this from a click\n * handler; a timer or a boot path will always get this.\n * - `declined` — the host showed the confirmation and the user did not confirm.\n * - `forbidden` — the app does not hold the baseline `link:open` capability.\n * - `unsupported` — this host has no outward-link surface wired (an older host).\n * - `unknown` — the host refused without naming a code. */\nexport type OpenExternalErrorCode = 'invalid' | 'no-activation' | 'declined' | 'forbidden' | 'unsupported' | 'unknown';\n\nexport interface OpenExternalError extends Error {\n code: OpenExternalErrorCode;\n}\n\n/** The host's reply: the envelope resolves inside the promise, so a refusal is a resolved\n * `{ ok: false }` rather than a rejection at the transport layer. */\ntype OpenExternalReply = { ok: true; url?: string } | { ok: false; code?: string; message?: string };\n\n/**\n * Ask the host to open an external link in a new browser tab.\n *\n * Resolves once the host has performed the open; it does not wait for — and cannot observe —\n * the opened tab loading. Rejects with a typed {@link OpenExternalError} carrying `code` when\n * the host refuses.\n *\n * Call it directly from a user gesture. The host samples its own transient activation when\n * the request arrives, so anything that defers the call past the gesture (an `await` before\n * it, a `setTimeout`, a retry) will be refused `no-activation`. None of the refusals are\n * worth retrying: each names a condition a retry cannot change.\n */\nexport async function openExternal(url: string): Promise<void> {\n const res = (await protocolRequest(SCHEMES[PROTOCOL_OPENLINK], 'open', [{ url }])) as OpenExternalReply;\n
|
|
1
|
+
{"version":3,"sources":["../src/openExternal.ts"],"sourcesContent":["// Host-mediated \"open this external link in a new tab\" (R3-619).\n//\n// An app frame cannot open an ordinary top-level tab itself for a destination that has to\n// act as itself: a `window.open` or `<a target=\"_blank\">` from inside the sandboxed frame\n// inherits the sandbox (`allow-popups` without `allow-popups-to-escape-sandbox`), so the\n// opened tab runs at the same opaque origin and anything that signs in or posts fails.\n//\n// Unlike `openRepository`, the app here names a URL, not coordinates — the destination is\n// arbitrary, not a platform route. So the host validates the URL and confirms every call\n// (the full destination in its own chrome, opened only on the user's click). The app never\n// receives a `Window` handle; it asks, and the host decides whether and how to open.\n//\n// The same two host-side conditions as `openRepository` hold, and neither is something this\n// call can assert for itself: the confirmation needs the HOST document's live transient\n// user activation (a real click, which the host samples rather than believes), and the\n// confirmation must not consume that activation before the open. Both surface here as\n// ordinary coded refusals.\nimport { protocolRequest } from './sandboxUtils';\nimport { throwOnRefusal } from './protocolRefusal';\nimport { PROTOCOL_OPENLINK } from './generated/protocol';\nimport { SCHEMES } from './protocolSchemes';\n\n/** Why the host refused to open the link.\n *\n * - `invalid` — the URL is not a clean `https:` external destination (scheme, credentials,\n * length, or the host's own origin).\n * - `no-activation` — no live user gesture on the host document. Call this from a click\n * handler; a timer or a boot path will always get this.\n * - `declined` — the host showed the confirmation and the user did not confirm.\n * - `forbidden` — the app does not hold the baseline `link:open` capability.\n * - `unsupported` — this host has no outward-link surface wired (an older host).\n * - `unknown` — the host refused without naming a code.\n *\n * **What you actually catch.** The SDK throws a plain `Error` with `.code` assigned — a\n * `CodedRefusalError` from `protocolRefusal.ts` — never a distinct class. These are the\n * `.code` VALUES the host sends; the union was always a cast and is not enforced at\n * runtime, so treat an unlisted code as possible and `instanceof Error` as the only\n * reliable test. */\nexport type OpenExternalErrorCode = 'invalid' | 'no-activation' | 'declined' | 'forbidden' | 'unsupported' | 'unknown';\n\nexport interface OpenExternalError extends Error {\n code: OpenExternalErrorCode;\n}\n\n/** The host's reply: the envelope resolves inside the promise, so a refusal is a resolved\n * `{ ok: false }` rather than a rejection at the transport layer. */\ntype OpenExternalReply = { ok: true; url?: string } | { ok: false; code?: string; message?: string };\n\n/**\n * Ask the host to open an external link in a new browser tab.\n *\n * Resolves once the host has performed the open; it does not wait for — and cannot observe —\n * the opened tab loading. Rejects with a typed {@link OpenExternalError} carrying `code` when\n * the host refuses.\n *\n * Call it directly from a user gesture. The host samples its own transient activation when\n * the request arrives, so anything that defers the call past the gesture (an `await` before\n * it, a `setTimeout`, a retry) will be refused `no-activation`. None of the refusals are\n * worth retrying: each names a condition a retry cannot change.\n */\nexport async function openExternal(url: string): Promise<void> {\n const res = (await protocolRequest(SCHEMES[PROTOCOL_OPENLINK], 'open', [{ url }])) as OpenExternalReply;\n throwOnRefusal(res, 'external link open refused');\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAiBA,0BAAgC;AAChC,6BAA+B;AAC/B,sBAAkC;AAClC,6BAAwB;AAwCxB,eAAsB,aAAa,KAA4B;AAC7D,QAAM,MAAO,UAAM,qCAAgB,+BAAQ,iCAAiB,GAAG,QAAQ,CAAC,EAAE,IAAI,CAAC,CAAC;AAChF,6CAAe,KAAK,4BAA4B;AAClD;","names":[]}
|
package/dist/openExternal.d.cts
CHANGED
|
@@ -7,7 +7,13 @@
|
|
|
7
7
|
* - `declined` — the host showed the confirmation and the user did not confirm.
|
|
8
8
|
* - `forbidden` — the app does not hold the baseline `link:open` capability.
|
|
9
9
|
* - `unsupported` — this host has no outward-link surface wired (an older host).
|
|
10
|
-
* - `unknown` — the host refused without naming a code.
|
|
10
|
+
* - `unknown` — the host refused without naming a code.
|
|
11
|
+
*
|
|
12
|
+
* **What you actually catch.** The SDK throws a plain `Error` with `.code` assigned — a
|
|
13
|
+
* `CodedRefusalError` from `protocolRefusal.ts` — never a distinct class. These are the
|
|
14
|
+
* `.code` VALUES the host sends; the union was always a cast and is not enforced at
|
|
15
|
+
* runtime, so treat an unlisted code as possible and `instanceof Error` as the only
|
|
16
|
+
* reliable test. */
|
|
11
17
|
type OpenExternalErrorCode = 'invalid' | 'no-activation' | 'declined' | 'forbidden' | 'unsupported' | 'unknown';
|
|
12
18
|
interface OpenExternalError extends Error {
|
|
13
19
|
code: OpenExternalErrorCode;
|
package/dist/openExternal.d.ts
CHANGED
|
@@ -7,7 +7,13 @@
|
|
|
7
7
|
* - `declined` — the host showed the confirmation and the user did not confirm.
|
|
8
8
|
* - `forbidden` — the app does not hold the baseline `link:open` capability.
|
|
9
9
|
* - `unsupported` — this host has no outward-link surface wired (an older host).
|
|
10
|
-
* - `unknown` — the host refused without naming a code.
|
|
10
|
+
* - `unknown` — the host refused without naming a code.
|
|
11
|
+
*
|
|
12
|
+
* **What you actually catch.** The SDK throws a plain `Error` with `.code` assigned — a
|
|
13
|
+
* `CodedRefusalError` from `protocolRefusal.ts` — never a distinct class. These are the
|
|
14
|
+
* `.code` VALUES the host sends; the union was always a cast and is not enforced at
|
|
15
|
+
* runtime, so treat an unlisted code as possible and `instanceof Error` as the only
|
|
16
|
+
* reliable test. */
|
|
11
17
|
type OpenExternalErrorCode = 'invalid' | 'no-activation' | 'declined' | 'forbidden' | 'unsupported' | 'unknown';
|
|
12
18
|
interface OpenExternalError extends Error {
|
|
13
19
|
code: OpenExternalErrorCode;
|
package/dist/openExternal.js
CHANGED
|
@@ -1,16 +1,11 @@
|
|
|
1
1
|
import "./chunk-VHAA22YE.js";
|
|
2
2
|
import { protocolRequest } from "./sandboxUtils.js";
|
|
3
|
+
import { throwOnRefusal } from "./protocolRefusal.js";
|
|
3
4
|
import { PROTOCOL_OPENLINK } from "./generated/protocol.js";
|
|
4
5
|
import { SCHEMES } from "./protocolSchemes.js";
|
|
5
6
|
async function openExternal(url) {
|
|
6
7
|
const res = await protocolRequest(SCHEMES[PROTOCOL_OPENLINK], "open", [{ url }]);
|
|
7
|
-
|
|
8
|
-
const err = new Error(
|
|
9
|
-
(res && "message" in res ? res.message : void 0) ?? "external link open refused"
|
|
10
|
-
);
|
|
11
|
-
err.code = (res && "code" in res ? res.code : void 0) ?? "unknown";
|
|
12
|
-
throw err;
|
|
13
|
-
}
|
|
8
|
+
throwOnRefusal(res, "external link open refused");
|
|
14
9
|
}
|
|
15
10
|
export {
|
|
16
11
|
openExternal
|
package/dist/openExternal.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/openExternal.ts"],"sourcesContent":["// Host-mediated \"open this external link in a new tab\" (R3-619).\n//\n// An app frame cannot open an ordinary top-level tab itself for a destination that has to\n// act as itself: a `window.open` or `<a target=\"_blank\">` from inside the sandboxed frame\n// inherits the sandbox (`allow-popups` without `allow-popups-to-escape-sandbox`), so the\n// opened tab runs at the same opaque origin and anything that signs in or posts fails.\n//\n// Unlike `openRepository`, the app here names a URL, not coordinates — the destination is\n// arbitrary, not a platform route. So the host validates the URL and confirms every call\n// (the full destination in its own chrome, opened only on the user's click). The app never\n// receives a `Window` handle; it asks, and the host decides whether and how to open.\n//\n// The same two host-side conditions as `openRepository` hold, and neither is something this\n// call can assert for itself: the confirmation needs the HOST document's live transient\n// user activation (a real click, which the host samples rather than believes), and the\n// confirmation must not consume that activation before the open. Both surface here as\n// ordinary coded refusals.\nimport { protocolRequest } from './sandboxUtils';\nimport { PROTOCOL_OPENLINK } from './generated/protocol';\nimport { SCHEMES } from './protocolSchemes';\n\n/** Why the host refused to open the link.\n *\n * - `invalid` — the URL is not a clean `https:` external destination (scheme, credentials,\n * length, or the host's own origin).\n * - `no-activation` — no live user gesture on the host document. Call this from a click\n * handler; a timer or a boot path will always get this.\n * - `declined` — the host showed the confirmation and the user did not confirm.\n * - `forbidden` — the app does not hold the baseline `link:open` capability.\n * - `unsupported` — this host has no outward-link surface wired (an older host).\n * - `unknown` — the host refused without naming a code. */\nexport type OpenExternalErrorCode = 'invalid' | 'no-activation' | 'declined' | 'forbidden' | 'unsupported' | 'unknown';\n\nexport interface OpenExternalError extends Error {\n code: OpenExternalErrorCode;\n}\n\n/** The host's reply: the envelope resolves inside the promise, so a refusal is a resolved\n * `{ ok: false }` rather than a rejection at the transport layer. */\ntype OpenExternalReply = { ok: true; url?: string } | { ok: false; code?: string; message?: string };\n\n/**\n * Ask the host to open an external link in a new browser tab.\n *\n * Resolves once the host has performed the open; it does not wait for — and cannot observe —\n * the opened tab loading. Rejects with a typed {@link OpenExternalError} carrying `code` when\n * the host refuses.\n *\n * Call it directly from a user gesture. The host samples its own transient activation when\n * the request arrives, so anything that defers the call past the gesture (an `await` before\n * it, a `setTimeout`, a retry) will be refused `no-activation`. None of the refusals are\n * worth retrying: each names a condition a retry cannot change.\n */\nexport async function openExternal(url: string): Promise<void> {\n const res = (await protocolRequest(SCHEMES[PROTOCOL_OPENLINK], 'open', [{ url }])) as OpenExternalReply;\n
|
|
1
|
+
{"version":3,"sources":["../src/openExternal.ts"],"sourcesContent":["// Host-mediated \"open this external link in a new tab\" (R3-619).\n//\n// An app frame cannot open an ordinary top-level tab itself for a destination that has to\n// act as itself: a `window.open` or `<a target=\"_blank\">` from inside the sandboxed frame\n// inherits the sandbox (`allow-popups` without `allow-popups-to-escape-sandbox`), so the\n// opened tab runs at the same opaque origin and anything that signs in or posts fails.\n//\n// Unlike `openRepository`, the app here names a URL, not coordinates — the destination is\n// arbitrary, not a platform route. So the host validates the URL and confirms every call\n// (the full destination in its own chrome, opened only on the user's click). The app never\n// receives a `Window` handle; it asks, and the host decides whether and how to open.\n//\n// The same two host-side conditions as `openRepository` hold, and neither is something this\n// call can assert for itself: the confirmation needs the HOST document's live transient\n// user activation (a real click, which the host samples rather than believes), and the\n// confirmation must not consume that activation before the open. Both surface here as\n// ordinary coded refusals.\nimport { protocolRequest } from './sandboxUtils';\nimport { throwOnRefusal } from './protocolRefusal';\nimport { PROTOCOL_OPENLINK } from './generated/protocol';\nimport { SCHEMES } from './protocolSchemes';\n\n/** Why the host refused to open the link.\n *\n * - `invalid` — the URL is not a clean `https:` external destination (scheme, credentials,\n * length, or the host's own origin).\n * - `no-activation` — no live user gesture on the host document. Call this from a click\n * handler; a timer or a boot path will always get this.\n * - `declined` — the host showed the confirmation and the user did not confirm.\n * - `forbidden` — the app does not hold the baseline `link:open` capability.\n * - `unsupported` — this host has no outward-link surface wired (an older host).\n * - `unknown` — the host refused without naming a code.\n *\n * **What you actually catch.** The SDK throws a plain `Error` with `.code` assigned — a\n * `CodedRefusalError` from `protocolRefusal.ts` — never a distinct class. These are the\n * `.code` VALUES the host sends; the union was always a cast and is not enforced at\n * runtime, so treat an unlisted code as possible and `instanceof Error` as the only\n * reliable test. */\nexport type OpenExternalErrorCode = 'invalid' | 'no-activation' | 'declined' | 'forbidden' | 'unsupported' | 'unknown';\n\nexport interface OpenExternalError extends Error {\n code: OpenExternalErrorCode;\n}\n\n/** The host's reply: the envelope resolves inside the promise, so a refusal is a resolved\n * `{ ok: false }` rather than a rejection at the transport layer. */\ntype OpenExternalReply = { ok: true; url?: string } | { ok: false; code?: string; message?: string };\n\n/**\n * Ask the host to open an external link in a new browser tab.\n *\n * Resolves once the host has performed the open; it does not wait for — and cannot observe —\n * the opened tab loading. Rejects with a typed {@link OpenExternalError} carrying `code` when\n * the host refuses.\n *\n * Call it directly from a user gesture. The host samples its own transient activation when\n * the request arrives, so anything that defers the call past the gesture (an `await` before\n * it, a `setTimeout`, a retry) will be refused `no-activation`. None of the refusals are\n * worth retrying: each names a condition a retry cannot change.\n */\nexport async function openExternal(url: string): Promise<void> {\n const res = (await protocolRequest(SCHEMES[PROTOCOL_OPENLINK], 'open', [{ url }])) as OpenExternalReply;\n throwOnRefusal(res, 'external link open refused');\n}\n"],"mappings":";AAiBA,SAAS,uBAAuB;AAChC,SAAS,sBAAsB;AAC/B,SAAS,yBAAyB;AAClC,SAAS,eAAe;AAwCxB,eAAsB,aAAa,KAA4B;AAC7D,QAAM,MAAO,MAAM,gBAAgB,QAAQ,iBAAiB,GAAG,QAAQ,CAAC,EAAE,IAAI,CAAC,CAAC;AAChF,iBAAe,KAAK,4BAA4B;AAClD;","names":[]}
|
package/dist/openRepository.cjs
CHANGED
|
@@ -22,6 +22,7 @@ __export(openRepository_exports, {
|
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(openRepository_exports);
|
|
24
24
|
var import_sandboxUtils = require("./sandboxUtils");
|
|
25
|
+
var import_protocolRefusal = require("./protocolRefusal");
|
|
25
26
|
var import_protocol = require("./generated/protocol");
|
|
26
27
|
var import_protocolSchemes = require("./protocolSchemes");
|
|
27
28
|
async function openRepository(coordinates) {
|
|
@@ -29,13 +30,7 @@ async function openRepository(coordinates) {
|
|
|
29
30
|
const res = await (0, import_sandboxUtils.protocolRequest)(import_protocolSchemes.SCHEMES[import_protocol.PROTOCOL_OPENREPO], "open", [
|
|
30
31
|
{ provider, namespace, repository }
|
|
31
32
|
]);
|
|
32
|
-
|
|
33
|
-
const err = new Error(
|
|
34
|
-
(res && "message" in res ? res.message : void 0) ?? "repository open refused"
|
|
35
|
-
);
|
|
36
|
-
err.code = (res && "code" in res ? res.code : void 0) ?? "unknown";
|
|
37
|
-
throw err;
|
|
38
|
-
}
|
|
33
|
+
(0, import_protocolRefusal.throwOnRefusal)(res, "repository open refused");
|
|
39
34
|
}
|
|
40
35
|
// Annotate the CommonJS export names for ESM import in node:
|
|
41
36
|
0 && (module.exports = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/openRepository.ts"],"sourcesContent":["// Host-mediated \"open this repository in a new tab\" (R3-476).\n//\n// An app frame cannot open a first-party tab itself. A `window.open` from inside the\n// sandboxed frame inherits the sandbox — the opened tab runs at the same opaque origin and\n// cannot load the host — and `target=\"_top\"` would replace the app's own frame rather than\n// open a tab. So the app asks the host, and the host performs the open from its own context.\n//\n// The app names COORDINATES and nothing else. It cannot pass a URL, a route prefix or a\n// path: the host builds the destination from its own route grammar, so this call can only\n// ever reach one of the platform's own repository routes. That is the point of the shape —\n// an app that could spell the destination could open anything.\n//\n// Two more conditions hold on the host side, and neither is something this call can assert\n// for itself: the open needs the HOST document's live transient user activation (a real\n// click, which the host samples rather than believes), and one gesture opens exactly one\n// tab. Both surface here as ordinary coded refusals.\nimport { protocolRequest } from './sandboxUtils';\nimport { PROTOCOL_OPENREPO } from './generated/protocol';\nimport { SCHEMES } from './protocolSchemes';\n\n/** Where a repository lives. The same three fields a `RecentProject` carries — this is a\n * location the user may already have navigated to under their own authority. */\nexport interface RepositoryCoordinates {\n provider: string;\n namespace: string;\n repository: string;\n}\n\n/** Why the host refused to open a tab.\n *\n * - `invalid` — the coordinates are not three clean path segments.\n * - `no-activation` — no live user gesture on the host document. Call this from a click\n * handler; a timer or a boot path will always get this. A SECOND call inside one gesture\n * also lands here: `window.open` consumes the host's transient activation, so one click\n * buys exactly one tab and the next needs a real second click.\n * - `forbidden` — the app does not hold the baseline `route:read` capability.\n * - `unsupported` — this host has no repository-open surface wired.\n * - `unknown` — the host refused without naming a code. */\nexport type OpenRepositoryErrorCode = 'invalid' | 'no-activation' | 'forbidden' | 'unsupported' | 'unknown';\n\nexport interface OpenRepositoryError extends Error {\n code: OpenRepositoryErrorCode;\n}\n\n/** The host's reply: the envelope resolves INSIDE the promise, so a refusal is a resolved\n * `{ ok: false }` rather than a rejection at the transport layer. */\ntype OpenRepositoryReply = { ok: true; url?: string } | { ok: false; code?: string; message?: string };\n\n/**\n * Ask the host to open a repository in a new browser tab.\n *\n * Resolves once the host has performed the open; it does not wait for — and cannot observe —\n * the opened tab loading. Rejects with a typed {@link OpenRepositoryError} carrying `code`\n * when the host refuses.\n *\n * Call it directly from a user gesture. The host samples its own transient activation when\n * the request arrives, so anything that defers the call past the gesture (an `await` before\n * it, a `setTimeout`, a retry) will be refused `no-activation`. None of the refusals are\n * worth retrying: each names a condition a retry cannot change.\n */\nexport async function openRepository(coordinates: RepositoryCoordinates): Promise<void> {\n const { provider, namespace, repository } = coordinates;\n const res = (await protocolRequest(SCHEMES[PROTOCOL_OPENREPO], 'open', [\n { provider, namespace, repository },\n ])) as OpenRepositoryReply;\n
|
|
1
|
+
{"version":3,"sources":["../src/openRepository.ts"],"sourcesContent":["// Host-mediated \"open this repository in a new tab\" (R3-476).\n//\n// An app frame cannot open a first-party tab itself. A `window.open` from inside the\n// sandboxed frame inherits the sandbox — the opened tab runs at the same opaque origin and\n// cannot load the host — and `target=\"_top\"` would replace the app's own frame rather than\n// open a tab. So the app asks the host, and the host performs the open from its own context.\n//\n// The app names COORDINATES and nothing else. It cannot pass a URL, a route prefix or a\n// path: the host builds the destination from its own route grammar, so this call can only\n// ever reach one of the platform's own repository routes. That is the point of the shape —\n// an app that could spell the destination could open anything.\n//\n// Two more conditions hold on the host side, and neither is something this call can assert\n// for itself: the open needs the HOST document's live transient user activation (a real\n// click, which the host samples rather than believes), and one gesture opens exactly one\n// tab. Both surface here as ordinary coded refusals.\nimport { protocolRequest } from './sandboxUtils';\nimport { throwOnRefusal } from './protocolRefusal';\nimport { PROTOCOL_OPENREPO } from './generated/protocol';\nimport { SCHEMES } from './protocolSchemes';\n\n/** Where a repository lives. The same three fields a `RecentProject` carries — this is a\n * location the user may already have navigated to under their own authority. */\nexport interface RepositoryCoordinates {\n provider: string;\n namespace: string;\n repository: string;\n}\n\n/** Why the host refused to open a tab.\n *\n * - `invalid` — the coordinates are not three clean path segments.\n * - `no-activation` — no live user gesture on the host document. Call this from a click\n * handler; a timer or a boot path will always get this. A SECOND call inside one gesture\n * also lands here: `window.open` consumes the host's transient activation, so one click\n * buys exactly one tab and the next needs a real second click.\n * - `forbidden` — the app does not hold the baseline `route:read` capability.\n * - `unsupported` — this host has no repository-open surface wired.\n * - `unknown` — the host refused without naming a code.\n *\n * **What you actually catch.** The SDK throws a plain `Error` with `.code` assigned — a\n * `CodedRefusalError` from `protocolRefusal.ts` — never a distinct class. These are the\n * `.code` VALUES the host sends; the union was always a cast and is not enforced at\n * runtime, so treat an unlisted code as possible and `instanceof Error` as the only\n * reliable test. */\nexport type OpenRepositoryErrorCode = 'invalid' | 'no-activation' | 'forbidden' | 'unsupported' | 'unknown';\n\nexport interface OpenRepositoryError extends Error {\n code: OpenRepositoryErrorCode;\n}\n\n/** The host's reply: the envelope resolves INSIDE the promise, so a refusal is a resolved\n * `{ ok: false }` rather than a rejection at the transport layer. */\ntype OpenRepositoryReply = { ok: true; url?: string } | { ok: false; code?: string; message?: string };\n\n/**\n * Ask the host to open a repository in a new browser tab.\n *\n * Resolves once the host has performed the open; it does not wait for — and cannot observe —\n * the opened tab loading. Rejects with a typed {@link OpenRepositoryError} carrying `code`\n * when the host refuses.\n *\n * Call it directly from a user gesture. The host samples its own transient activation when\n * the request arrives, so anything that defers the call past the gesture (an `await` before\n * it, a `setTimeout`, a retry) will be refused `no-activation`. None of the refusals are\n * worth retrying: each names a condition a retry cannot change.\n */\nexport async function openRepository(coordinates: RepositoryCoordinates): Promise<void> {\n const { provider, namespace, repository } = coordinates;\n const res = (await protocolRequest(SCHEMES[PROTOCOL_OPENREPO], 'open', [\n { provider, namespace, repository },\n ])) as OpenRepositoryReply;\n throwOnRefusal(res, 'repository open refused');\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAgBA,0BAAgC;AAChC,6BAA+B;AAC/B,sBAAkC;AAClC,6BAAwB;AAgDxB,eAAsB,eAAe,aAAmD;AACtF,QAAM,EAAE,UAAU,WAAW,WAAW,IAAI;AAC5C,QAAM,MAAO,UAAM,qCAAgB,+BAAQ,iCAAiB,GAAG,QAAQ;AAAA,IACrE,EAAE,UAAU,WAAW,WAAW;AAAA,EACpC,CAAC;AACD,6CAAe,KAAK,yBAAyB;AAC/C;","names":[]}
|
|
@@ -14,7 +14,13 @@ interface RepositoryCoordinates {
|
|
|
14
14
|
* buys exactly one tab and the next needs a real second click.
|
|
15
15
|
* - `forbidden` — the app does not hold the baseline `route:read` capability.
|
|
16
16
|
* - `unsupported` — this host has no repository-open surface wired.
|
|
17
|
-
* - `unknown` — the host refused without naming a code.
|
|
17
|
+
* - `unknown` — the host refused without naming a code.
|
|
18
|
+
*
|
|
19
|
+
* **What you actually catch.** The SDK throws a plain `Error` with `.code` assigned — a
|
|
20
|
+
* `CodedRefusalError` from `protocolRefusal.ts` — never a distinct class. These are the
|
|
21
|
+
* `.code` VALUES the host sends; the union was always a cast and is not enforced at
|
|
22
|
+
* runtime, so treat an unlisted code as possible and `instanceof Error` as the only
|
|
23
|
+
* reliable test. */
|
|
18
24
|
type OpenRepositoryErrorCode = 'invalid' | 'no-activation' | 'forbidden' | 'unsupported' | 'unknown';
|
|
19
25
|
interface OpenRepositoryError extends Error {
|
|
20
26
|
code: OpenRepositoryErrorCode;
|
package/dist/openRepository.d.ts
CHANGED
|
@@ -14,7 +14,13 @@ interface RepositoryCoordinates {
|
|
|
14
14
|
* buys exactly one tab and the next needs a real second click.
|
|
15
15
|
* - `forbidden` — the app does not hold the baseline `route:read` capability.
|
|
16
16
|
* - `unsupported` — this host has no repository-open surface wired.
|
|
17
|
-
* - `unknown` — the host refused without naming a code.
|
|
17
|
+
* - `unknown` — the host refused without naming a code.
|
|
18
|
+
*
|
|
19
|
+
* **What you actually catch.** The SDK throws a plain `Error` with `.code` assigned — a
|
|
20
|
+
* `CodedRefusalError` from `protocolRefusal.ts` — never a distinct class. These are the
|
|
21
|
+
* `.code` VALUES the host sends; the union was always a cast and is not enforced at
|
|
22
|
+
* runtime, so treat an unlisted code as possible and `instanceof Error` as the only
|
|
23
|
+
* reliable test. */
|
|
18
24
|
type OpenRepositoryErrorCode = 'invalid' | 'no-activation' | 'forbidden' | 'unsupported' | 'unknown';
|
|
19
25
|
interface OpenRepositoryError extends Error {
|
|
20
26
|
code: OpenRepositoryErrorCode;
|
package/dist/openRepository.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import "./chunk-VHAA22YE.js";
|
|
2
2
|
import { protocolRequest } from "./sandboxUtils.js";
|
|
3
|
+
import { throwOnRefusal } from "./protocolRefusal.js";
|
|
3
4
|
import { PROTOCOL_OPENREPO } from "./generated/protocol.js";
|
|
4
5
|
import { SCHEMES } from "./protocolSchemes.js";
|
|
5
6
|
async function openRepository(coordinates) {
|
|
@@ -7,13 +8,7 @@ async function openRepository(coordinates) {
|
|
|
7
8
|
const res = await protocolRequest(SCHEMES[PROTOCOL_OPENREPO], "open", [
|
|
8
9
|
{ provider, namespace, repository }
|
|
9
10
|
]);
|
|
10
|
-
|
|
11
|
-
const err = new Error(
|
|
12
|
-
(res && "message" in res ? res.message : void 0) ?? "repository open refused"
|
|
13
|
-
);
|
|
14
|
-
err.code = (res && "code" in res ? res.code : void 0) ?? "unknown";
|
|
15
|
-
throw err;
|
|
16
|
-
}
|
|
11
|
+
throwOnRefusal(res, "repository open refused");
|
|
17
12
|
}
|
|
18
13
|
export {
|
|
19
14
|
openRepository
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/openRepository.ts"],"sourcesContent":["// Host-mediated \"open this repository in a new tab\" (R3-476).\n//\n// An app frame cannot open a first-party tab itself. A `window.open` from inside the\n// sandboxed frame inherits the sandbox — the opened tab runs at the same opaque origin and\n// cannot load the host — and `target=\"_top\"` would replace the app's own frame rather than\n// open a tab. So the app asks the host, and the host performs the open from its own context.\n//\n// The app names COORDINATES and nothing else. It cannot pass a URL, a route prefix or a\n// path: the host builds the destination from its own route grammar, so this call can only\n// ever reach one of the platform's own repository routes. That is the point of the shape —\n// an app that could spell the destination could open anything.\n//\n// Two more conditions hold on the host side, and neither is something this call can assert\n// for itself: the open needs the HOST document's live transient user activation (a real\n// click, which the host samples rather than believes), and one gesture opens exactly one\n// tab. Both surface here as ordinary coded refusals.\nimport { protocolRequest } from './sandboxUtils';\nimport { PROTOCOL_OPENREPO } from './generated/protocol';\nimport { SCHEMES } from './protocolSchemes';\n\n/** Where a repository lives. The same three fields a `RecentProject` carries — this is a\n * location the user may already have navigated to under their own authority. */\nexport interface RepositoryCoordinates {\n provider: string;\n namespace: string;\n repository: string;\n}\n\n/** Why the host refused to open a tab.\n *\n * - `invalid` — the coordinates are not three clean path segments.\n * - `no-activation` — no live user gesture on the host document. Call this from a click\n * handler; a timer or a boot path will always get this. A SECOND call inside one gesture\n * also lands here: `window.open` consumes the host's transient activation, so one click\n * buys exactly one tab and the next needs a real second click.\n * - `forbidden` — the app does not hold the baseline `route:read` capability.\n * - `unsupported` — this host has no repository-open surface wired.\n * - `unknown` — the host refused without naming a code. */\nexport type OpenRepositoryErrorCode = 'invalid' | 'no-activation' | 'forbidden' | 'unsupported' | 'unknown';\n\nexport interface OpenRepositoryError extends Error {\n code: OpenRepositoryErrorCode;\n}\n\n/** The host's reply: the envelope resolves INSIDE the promise, so a refusal is a resolved\n * `{ ok: false }` rather than a rejection at the transport layer. */\ntype OpenRepositoryReply = { ok: true; url?: string } | { ok: false; code?: string; message?: string };\n\n/**\n * Ask the host to open a repository in a new browser tab.\n *\n * Resolves once the host has performed the open; it does not wait for — and cannot observe —\n * the opened tab loading. Rejects with a typed {@link OpenRepositoryError} carrying `code`\n * when the host refuses.\n *\n * Call it directly from a user gesture. The host samples its own transient activation when\n * the request arrives, so anything that defers the call past the gesture (an `await` before\n * it, a `setTimeout`, a retry) will be refused `no-activation`. None of the refusals are\n * worth retrying: each names a condition a retry cannot change.\n */\nexport async function openRepository(coordinates: RepositoryCoordinates): Promise<void> {\n const { provider, namespace, repository } = coordinates;\n const res = (await protocolRequest(SCHEMES[PROTOCOL_OPENREPO], 'open', [\n { provider, namespace, repository },\n ])) as OpenRepositoryReply;\n
|
|
1
|
+
{"version":3,"sources":["../src/openRepository.ts"],"sourcesContent":["// Host-mediated \"open this repository in a new tab\" (R3-476).\n//\n// An app frame cannot open a first-party tab itself. A `window.open` from inside the\n// sandboxed frame inherits the sandbox — the opened tab runs at the same opaque origin and\n// cannot load the host — and `target=\"_top\"` would replace the app's own frame rather than\n// open a tab. So the app asks the host, and the host performs the open from its own context.\n//\n// The app names COORDINATES and nothing else. It cannot pass a URL, a route prefix or a\n// path: the host builds the destination from its own route grammar, so this call can only\n// ever reach one of the platform's own repository routes. That is the point of the shape —\n// an app that could spell the destination could open anything.\n//\n// Two more conditions hold on the host side, and neither is something this call can assert\n// for itself: the open needs the HOST document's live transient user activation (a real\n// click, which the host samples rather than believes), and one gesture opens exactly one\n// tab. Both surface here as ordinary coded refusals.\nimport { protocolRequest } from './sandboxUtils';\nimport { throwOnRefusal } from './protocolRefusal';\nimport { PROTOCOL_OPENREPO } from './generated/protocol';\nimport { SCHEMES } from './protocolSchemes';\n\n/** Where a repository lives. The same three fields a `RecentProject` carries — this is a\n * location the user may already have navigated to under their own authority. */\nexport interface RepositoryCoordinates {\n provider: string;\n namespace: string;\n repository: string;\n}\n\n/** Why the host refused to open a tab.\n *\n * - `invalid` — the coordinates are not three clean path segments.\n * - `no-activation` — no live user gesture on the host document. Call this from a click\n * handler; a timer or a boot path will always get this. A SECOND call inside one gesture\n * also lands here: `window.open` consumes the host's transient activation, so one click\n * buys exactly one tab and the next needs a real second click.\n * - `forbidden` — the app does not hold the baseline `route:read` capability.\n * - `unsupported` — this host has no repository-open surface wired.\n * - `unknown` — the host refused without naming a code.\n *\n * **What you actually catch.** The SDK throws a plain `Error` with `.code` assigned — a\n * `CodedRefusalError` from `protocolRefusal.ts` — never a distinct class. These are the\n * `.code` VALUES the host sends; the union was always a cast and is not enforced at\n * runtime, so treat an unlisted code as possible and `instanceof Error` as the only\n * reliable test. */\nexport type OpenRepositoryErrorCode = 'invalid' | 'no-activation' | 'forbidden' | 'unsupported' | 'unknown';\n\nexport interface OpenRepositoryError extends Error {\n code: OpenRepositoryErrorCode;\n}\n\n/** The host's reply: the envelope resolves INSIDE the promise, so a refusal is a resolved\n * `{ ok: false }` rather than a rejection at the transport layer. */\ntype OpenRepositoryReply = { ok: true; url?: string } | { ok: false; code?: string; message?: string };\n\n/**\n * Ask the host to open a repository in a new browser tab.\n *\n * Resolves once the host has performed the open; it does not wait for — and cannot observe —\n * the opened tab loading. Rejects with a typed {@link OpenRepositoryError} carrying `code`\n * when the host refuses.\n *\n * Call it directly from a user gesture. The host samples its own transient activation when\n * the request arrives, so anything that defers the call past the gesture (an `await` before\n * it, a `setTimeout`, a retry) will be refused `no-activation`. None of the refusals are\n * worth retrying: each names a condition a retry cannot change.\n */\nexport async function openRepository(coordinates: RepositoryCoordinates): Promise<void> {\n const { provider, namespace, repository } = coordinates;\n const res = (await protocolRequest(SCHEMES[PROTOCOL_OPENREPO], 'open', [\n { provider, namespace, repository },\n ])) as OpenRepositoryReply;\n throwOnRefusal(res, 'repository open refused');\n}\n"],"mappings":";AAgBA,SAAS,uBAAuB;AAChC,SAAS,sBAAsB;AAC/B,SAAS,yBAAyB;AAClC,SAAS,eAAe;AAgDxB,eAAsB,eAAe,aAAmD;AACtF,QAAM,EAAE,UAAU,WAAW,WAAW,IAAI;AAC5C,QAAM,MAAO,MAAM,gBAAgB,QAAQ,iBAAiB,GAAG,QAAQ;AAAA,IACrE,EAAE,UAAU,WAAW,WAAW;AAAA,EACpC,CAAC;AACD,iBAAe,KAAK,yBAAyB;AAC/C;","names":[]}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var protocolRefusal_exports = {};
|
|
20
|
+
__export(protocolRefusal_exports, {
|
|
21
|
+
throwOnRefusal: () => throwOnRefusal
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(protocolRefusal_exports);
|
|
24
|
+
function throwOnRefusal(res, fallbackMessage) {
|
|
25
|
+
const r = res;
|
|
26
|
+
if (r && r.ok === true) return;
|
|
27
|
+
const err = new Error(typeof r?.message === "string" ? r.message : fallbackMessage);
|
|
28
|
+
err.code = typeof r?.code === "string" ? r.code : "unknown";
|
|
29
|
+
throw err;
|
|
30
|
+
}
|
|
31
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
32
|
+
0 && (module.exports = {
|
|
33
|
+
throwOnRefusal
|
|
34
|
+
});
|
|
35
|
+
//# sourceMappingURL=protocolRefusal.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/protocolRefusal.ts"],"sourcesContent":["// The one place the SDK turns a host reply envelope into a typed, coded rejection (R6).\n//\n// ---------------------------------------------------------------------------\n// THE CENSUS — miscounted four times. COUNT THE GREP, and say which unit.\n// ---------------------------------------------------------------------------\n//\n// R3-708's review said three copies, then five, then \"ten across eight files\". This file\n// then said ten while the list beneath it summed to twelve, and a fourth reviewer caught\n// that. The count is:\n//\n// **twelve CALL SITES across nine FILES** — `grep -n 'throwOnRefusal(' src/*.ts`, minus\n// the declaration here and minus `*.test.*`:\n//\n// dnd.ts · editor.ts · ipc.ts (×2) · mounts.ts (×3) · openExternal.ts ·\n// openRepository.ts · secrets.ts · spacesMode.ts · vcs.ts\n//\n// Every miscount came from the same two mistakes: reading files instead of counting the\n// grep, and never saying which unit was being counted. `mounts.ts` has three separate\n// request helpers, each with its own copy; R3-780 touched five FILES and seven SITES.\n// \"Ten\" was neither.\n//\n// Not folded, deliberately, and the reason is NOT that they are all unalike — that was the\n// previous excuse and it was false for three of them:\n//\n// · `catalog.ts`, `recents.ts`, `tasks.ts` are pure copies of the shape `ipc.ts` had\n// until R3-780 folded it — untyped `Error & { code?: string }`, `res?.code ??\n// 'unknown'`. (`recents.ts` casts `code` as required rather than optional; immaterial,\n// the cast erases.) They are foldable and nothing here argues otherwise;\n// · `feed.ts`, `netFetch.ts` and `theme.ts` (×3) read `res && 'code' in res`, which\n// THROWS `TypeError: Cannot use 'in' operator` on a string reply. Folding them fixes\n// that, so it is a behaviour change — an improvement, but not an extraction. Note the\n// precedent cuts both ways: R3-708 already folded two sites carrying this exact form\n// (`openExternal`, `openRepository`), so \"behaviour change\" is a reason to review them\n// as their own item, not a reason they cannot be folded;\n// · `launch.ts` folds `!res.data?.launchId` into the same condition and RETURNS\n// `{ ok: false, code }` instead of throwing. Different control flow entirely.\n//\n// So the remaining work is two items, not one, and they are not the same size.\n//\n// `check:clones` cannot help with any of this: minLines 6, minTokens 50, and no identifier\n// normalisation, so blocks differing only in type names read as distinct.\n//\n// ---------------------------------------------------------------------------\n// THIS FILE'S OWN TEST IS LOAD-BEARING FOR ALL TWELVE SITES\n// ---------------------------------------------------------------------------\n//\n// Measured: changing the guard to `r.ok !== false` compiles clean and leaves **ten of the\n// twelve SITES** green — seven of the nine files: `dnd`, `editor`, `ipc`, `mounts`,\n// `secrets`, `spacesMode` and `vcs`. Every one of them stubs an explicit `{ ok: false }`,\n// so they pin \"throws on a refusal envelope\" and nothing about a malformed or absent\n// reply. Only `openExternal` and `openRepository` — two sites — plus\n// `protocolRefusal.test.ts` catch it: 7 tests across 3 suites.\n//\n// (An earlier version of this paragraph said \"nine of the twelve sites' suites\", which\n// mixes sites with suites — the exact mistake the census block above is headed about —\n// and omitted `secrets` and `spacesMode` from the green list.)\n//\n// Each inline form this replaced carried its own `!res ||` guard, visible at the call site.\n// That guarantee now lives here alone. Do not weaken `protocolRefusal.test.ts` on the\n// grounds that \"the consumers cover it\" — they do not, and twelve near-duplicate malformed\n// -reply tests would be the duplication this extraction exists to remove.\n//\n// ---------------------------------------------------------------------------\n// WHICH `ok` THIS READS, AND WHY IT MATTERS\n// ---------------------------------------------------------------------------\n//\n// It reads the DISPATCHER ENVELOPE's `ok` — the host's answer to \"did this call\n// succeed\", not a handler's own return value. site-main declares that envelope\n// (`src/editor/requestDispatcher.ts`):\n//\n// type SpaceResult =\n// | { ok: true; data: unknown }\n// | { ok: false; code: string; message: string };\n//\n// and the sandbox resolves it to the SDK unmodified (`src/protocol/iframe.ts`,\n// `resolve(msg.result)`). So a refusal reaches us as `{ok:false, code, message}` — which\n// is exactly what this function unwraps — and the host produces that frame by THROWING\n// `spaceError(code, message)`. The dispatcher's `.catch` turns the throw into the frame.\n//\n// **A handler that RETURNS `{ok:false, code}` instead of throwing does not produce a\n// refusal.** The dispatcher wraps a return value as `result: {ok: true, data: <return>}`,\n// so the envelope says the call succeeded and the refusal is buried one level down, where\n// nothing looks. Two shipped handlers did this until R3-778 closed it (site-main; audited sdk#184 round 2, 2026-09-25; fixed 2026-09-28 — both now throw, and a dispatcher assertion reddens on the shape):\n//\n// `handleOpenRepository` returns `invalid`, `no-activation`\n// `handleOpenLink` returns `invalid`, `no-activation`, **`declined`**\n//\n// `declined` is the user pressing \"no\" on the host's confirmation dialog, and\n// `openExternal()` reported that to the app as a successful open, until R3-778 closed it. Driven against the built\n// SDK with each reply shape:\n//\n// thrown -> threw, code=no-activation\n// returned -> RESOLVED (the app believes the tab opened)\n//\n// That was a live defect in site-main's handlers until R3-778 closed it (2026-09-28), not here — the envelope is the contract\n// and this reads the contract. Filed as R3-778. It is written down here because this is\n// the file a host author will be pointed at when they ask what shape to reply with, and\n// the answer is: **throw `spaceError`; never return `{ok:false}`.**\n//\n// Deliberately NOT done: sniffing `res.data?.ok === false` as a second refusal shape. On a\n// SUCCESS, `data` is whatever the handler returned — so a handler whose legitimate payload\n// happens to carry `ok: false` would be turned into a refusal. It would bless the broken\n// shape and create a second contract where the spec names one.\n\n/** An error carrying a stable, host-supplied `code` the app can branch on. */\nexport interface CodedRefusalError<C extends string = string> extends Error {\n code: C;\n}\n\n/**\n * Throw a typed, coded error unless the host's reply envelope says the call succeeded.\n *\n * `fallbackMessage` is used when the host refused without a message, and `'unknown'` is\n * the code when it refused without one — a refusal is never reported as a success just\n * because it arrived under-specified.\n *\n * `code` and `message` must be STRINGS to be used. Twelve sites call this; **eleven** had\n * an inline copy it replaced (`spacesMode.ts` was written against the helper in R3-708 and\n * replaced nothing). All eleven tested for PRESENCE, in **three** shapes:\n *\n * - **seven** cast the value: `(res?.code as SomeError['code']) ?? 'unknown'` —\n * `dnd`, `editor`, `vcs`, `mounts` (×3), `secrets`;\n * - **two** used the `in` operator: `((res && 'code' in res ? res.code : undefined) as\n * Code) ?? 'unknown'` — `openExternal`, `openRepository`, both folded in R3-708;\n * - **two** used a bare `res?.code ?? 'unknown'` onto `Error & { code?: string }` —\n * `ipc.ts`.\n *\n * Every one of them let a host sending `code: 42` surface `err.code === 42` on a field\n * declared `string`, and turned `message: 42` into the string `\"42\"`. Both now fall back,\n * to `'unknown'` and `fallbackMessage`. A deliberate tightening, pinned by\n * `protocolRefusal.test.ts` — and since this package ships no changelog, this paragraph is\n * where a consumer learns of it.\n *\n * The `ipc.ts` pair changed one more thing: their anonymous type declared `code` OPTIONAL\n * and `CodedRefusalError` requires it. No runtime difference for a missing code — the old\n * code assigned `'unknown'` exactly when the new one does (a non-string `code` falls back\n * too, as the paragraph above discloses) — but a consumer narrowing on `'code' in err`\n * can stop.\n *\n * Folding the two `in`-operator sites also removed a latent `TypeError`: `'code' in res`\n * throws on a string reply. Two revisions of this paragraph got that backwards — first\n * claiming the `in` form was among the shapes replaced without saying which sites, then\n * \"correcting\" that to say NO replaced site used it. It was two of them. Both errors came\n * from reading `main`, where R3-708 had already erased the form, instead of the tree before\n * it (`d4b07cc1^`).\n *\n * It is an ASSERTION function, not a `void` one, because the inline form it replaced\n * narrowed `res` as a side effect of its `if`/`throw`: `secrets.ts` and `mounts.ts` read\n * `res.data` on the next line and stopped compiling without it. A caller that only needs\n * the throw can ignore the narrowing; one that reads the payload gets it for free. (TS\n * requires the call target to be an explicitly-typed declared name — this is why it is a\n * `function` declaration and not an arrow const.)\n */\nexport function throwOnRefusal(res: unknown, fallbackMessage: string): asserts res is { ok: true; data?: unknown } {\n const r = res as { ok?: unknown; code?: unknown; message?: unknown } | null | undefined;\n if (r && r.ok === true) return;\n const err = new Error(typeof r?.message === 'string' ? r.message : fallbackMessage) as CodedRefusalError;\n err.code = typeof r?.code === 'string' ? r.code : 'unknown';\n throw err;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAyJO,SAAS,eAAe,KAAc,iBAAsE;AACjH,QAAM,IAAI;AACV,MAAI,KAAK,EAAE,OAAO,KAAM;AACxB,QAAM,MAAM,IAAI,MAAM,OAAO,GAAG,YAAY,WAAW,EAAE,UAAU,eAAe;AAClF,MAAI,OAAO,OAAO,GAAG,SAAS,WAAW,EAAE,OAAO;AAClD,QAAM;AACR;","names":[]}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/** An error carrying a stable, host-supplied `code` the app can branch on. */
|
|
2
|
+
interface CodedRefusalError<C extends string = string> extends Error {
|
|
3
|
+
code: C;
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* Throw a typed, coded error unless the host's reply envelope says the call succeeded.
|
|
7
|
+
*
|
|
8
|
+
* `fallbackMessage` is used when the host refused without a message, and `'unknown'` is
|
|
9
|
+
* the code when it refused without one — a refusal is never reported as a success just
|
|
10
|
+
* because it arrived under-specified.
|
|
11
|
+
*
|
|
12
|
+
* `code` and `message` must be STRINGS to be used. Twelve sites call this; **eleven** had
|
|
13
|
+
* an inline copy it replaced (`spacesMode.ts` was written against the helper in R3-708 and
|
|
14
|
+
* replaced nothing). All eleven tested for PRESENCE, in **three** shapes:
|
|
15
|
+
*
|
|
16
|
+
* - **seven** cast the value: `(res?.code as SomeError['code']) ?? 'unknown'` —
|
|
17
|
+
* `dnd`, `editor`, `vcs`, `mounts` (×3), `secrets`;
|
|
18
|
+
* - **two** used the `in` operator: `((res && 'code' in res ? res.code : undefined) as
|
|
19
|
+
* Code) ?? 'unknown'` — `openExternal`, `openRepository`, both folded in R3-708;
|
|
20
|
+
* - **two** used a bare `res?.code ?? 'unknown'` onto `Error & { code?: string }` —
|
|
21
|
+
* `ipc.ts`.
|
|
22
|
+
*
|
|
23
|
+
* Every one of them let a host sending `code: 42` surface `err.code === 42` on a field
|
|
24
|
+
* declared `string`, and turned `message: 42` into the string `"42"`. Both now fall back,
|
|
25
|
+
* to `'unknown'` and `fallbackMessage`. A deliberate tightening, pinned by
|
|
26
|
+
* `protocolRefusal.test.ts` — and since this package ships no changelog, this paragraph is
|
|
27
|
+
* where a consumer learns of it.
|
|
28
|
+
*
|
|
29
|
+
* The `ipc.ts` pair changed one more thing: their anonymous type declared `code` OPTIONAL
|
|
30
|
+
* and `CodedRefusalError` requires it. No runtime difference for a missing code — the old
|
|
31
|
+
* code assigned `'unknown'` exactly when the new one does (a non-string `code` falls back
|
|
32
|
+
* too, as the paragraph above discloses) — but a consumer narrowing on `'code' in err`
|
|
33
|
+
* can stop.
|
|
34
|
+
*
|
|
35
|
+
* Folding the two `in`-operator sites also removed a latent `TypeError`: `'code' in res`
|
|
36
|
+
* throws on a string reply. Two revisions of this paragraph got that backwards — first
|
|
37
|
+
* claiming the `in` form was among the shapes replaced without saying which sites, then
|
|
38
|
+
* "correcting" that to say NO replaced site used it. It was two of them. Both errors came
|
|
39
|
+
* from reading `main`, where R3-708 had already erased the form, instead of the tree before
|
|
40
|
+
* it (`d4b07cc1^`).
|
|
41
|
+
*
|
|
42
|
+
* It is an ASSERTION function, not a `void` one, because the inline form it replaced
|
|
43
|
+
* narrowed `res` as a side effect of its `if`/`throw`: `secrets.ts` and `mounts.ts` read
|
|
44
|
+
* `res.data` on the next line and stopped compiling without it. A caller that only needs
|
|
45
|
+
* the throw can ignore the narrowing; one that reads the payload gets it for free. (TS
|
|
46
|
+
* requires the call target to be an explicitly-typed declared name — this is why it is a
|
|
47
|
+
* `function` declaration and not an arrow const.)
|
|
48
|
+
*/
|
|
49
|
+
declare function throwOnRefusal(res: unknown, fallbackMessage: string): asserts res is {
|
|
50
|
+
ok: true;
|
|
51
|
+
data?: unknown;
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
export { type CodedRefusalError, throwOnRefusal };
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/** An error carrying a stable, host-supplied `code` the app can branch on. */
|
|
2
|
+
interface CodedRefusalError<C extends string = string> extends Error {
|
|
3
|
+
code: C;
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* Throw a typed, coded error unless the host's reply envelope says the call succeeded.
|
|
7
|
+
*
|
|
8
|
+
* `fallbackMessage` is used when the host refused without a message, and `'unknown'` is
|
|
9
|
+
* the code when it refused without one — a refusal is never reported as a success just
|
|
10
|
+
* because it arrived under-specified.
|
|
11
|
+
*
|
|
12
|
+
* `code` and `message` must be STRINGS to be used. Twelve sites call this; **eleven** had
|
|
13
|
+
* an inline copy it replaced (`spacesMode.ts` was written against the helper in R3-708 and
|
|
14
|
+
* replaced nothing). All eleven tested for PRESENCE, in **three** shapes:
|
|
15
|
+
*
|
|
16
|
+
* - **seven** cast the value: `(res?.code as SomeError['code']) ?? 'unknown'` —
|
|
17
|
+
* `dnd`, `editor`, `vcs`, `mounts` (×3), `secrets`;
|
|
18
|
+
* - **two** used the `in` operator: `((res && 'code' in res ? res.code : undefined) as
|
|
19
|
+
* Code) ?? 'unknown'` — `openExternal`, `openRepository`, both folded in R3-708;
|
|
20
|
+
* - **two** used a bare `res?.code ?? 'unknown'` onto `Error & { code?: string }` —
|
|
21
|
+
* `ipc.ts`.
|
|
22
|
+
*
|
|
23
|
+
* Every one of them let a host sending `code: 42` surface `err.code === 42` on a field
|
|
24
|
+
* declared `string`, and turned `message: 42` into the string `"42"`. Both now fall back,
|
|
25
|
+
* to `'unknown'` and `fallbackMessage`. A deliberate tightening, pinned by
|
|
26
|
+
* `protocolRefusal.test.ts` — and since this package ships no changelog, this paragraph is
|
|
27
|
+
* where a consumer learns of it.
|
|
28
|
+
*
|
|
29
|
+
* The `ipc.ts` pair changed one more thing: their anonymous type declared `code` OPTIONAL
|
|
30
|
+
* and `CodedRefusalError` requires it. No runtime difference for a missing code — the old
|
|
31
|
+
* code assigned `'unknown'` exactly when the new one does (a non-string `code` falls back
|
|
32
|
+
* too, as the paragraph above discloses) — but a consumer narrowing on `'code' in err`
|
|
33
|
+
* can stop.
|
|
34
|
+
*
|
|
35
|
+
* Folding the two `in`-operator sites also removed a latent `TypeError`: `'code' in res`
|
|
36
|
+
* throws on a string reply. Two revisions of this paragraph got that backwards — first
|
|
37
|
+
* claiming the `in` form was among the shapes replaced without saying which sites, then
|
|
38
|
+
* "correcting" that to say NO replaced site used it. It was two of them. Both errors came
|
|
39
|
+
* from reading `main`, where R3-708 had already erased the form, instead of the tree before
|
|
40
|
+
* it (`d4b07cc1^`).
|
|
41
|
+
*
|
|
42
|
+
* It is an ASSERTION function, not a `void` one, because the inline form it replaced
|
|
43
|
+
* narrowed `res` as a side effect of its `if`/`throw`: `secrets.ts` and `mounts.ts` read
|
|
44
|
+
* `res.data` on the next line and stopped compiling without it. A caller that only needs
|
|
45
|
+
* the throw can ignore the narrowing; one that reads the payload gets it for free. (TS
|
|
46
|
+
* requires the call target to be an explicitly-typed declared name — this is why it is a
|
|
47
|
+
* `function` declaration and not an arrow const.)
|
|
48
|
+
*/
|
|
49
|
+
declare function throwOnRefusal(res: unknown, fallbackMessage: string): asserts res is {
|
|
50
|
+
ok: true;
|
|
51
|
+
data?: unknown;
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
export { type CodedRefusalError, throwOnRefusal };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import "./chunk-VHAA22YE.js";
|
|
2
|
+
function throwOnRefusal(res, fallbackMessage) {
|
|
3
|
+
const r = res;
|
|
4
|
+
if (r && r.ok === true) return;
|
|
5
|
+
const err = new Error(typeof r?.message === "string" ? r.message : fallbackMessage);
|
|
6
|
+
err.code = typeof r?.code === "string" ? r.code : "unknown";
|
|
7
|
+
throw err;
|
|
8
|
+
}
|
|
9
|
+
export {
|
|
10
|
+
throwOnRefusal
|
|
11
|
+
};
|
|
12
|
+
//# sourceMappingURL=protocolRefusal.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/protocolRefusal.ts"],"sourcesContent":["// The one place the SDK turns a host reply envelope into a typed, coded rejection (R6).\n//\n// ---------------------------------------------------------------------------\n// THE CENSUS — miscounted four times. COUNT THE GREP, and say which unit.\n// ---------------------------------------------------------------------------\n//\n// R3-708's review said three copies, then five, then \"ten across eight files\". This file\n// then said ten while the list beneath it summed to twelve, and a fourth reviewer caught\n// that. The count is:\n//\n// **twelve CALL SITES across nine FILES** — `grep -n 'throwOnRefusal(' src/*.ts`, minus\n// the declaration here and minus `*.test.*`:\n//\n// dnd.ts · editor.ts · ipc.ts (×2) · mounts.ts (×3) · openExternal.ts ·\n// openRepository.ts · secrets.ts · spacesMode.ts · vcs.ts\n//\n// Every miscount came from the same two mistakes: reading files instead of counting the\n// grep, and never saying which unit was being counted. `mounts.ts` has three separate\n// request helpers, each with its own copy; R3-780 touched five FILES and seven SITES.\n// \"Ten\" was neither.\n//\n// Not folded, deliberately, and the reason is NOT that they are all unalike — that was the\n// previous excuse and it was false for three of them:\n//\n// · `catalog.ts`, `recents.ts`, `tasks.ts` are pure copies of the shape `ipc.ts` had\n// until R3-780 folded it — untyped `Error & { code?: string }`, `res?.code ??\n// 'unknown'`. (`recents.ts` casts `code` as required rather than optional; immaterial,\n// the cast erases.) They are foldable and nothing here argues otherwise;\n// · `feed.ts`, `netFetch.ts` and `theme.ts` (×3) read `res && 'code' in res`, which\n// THROWS `TypeError: Cannot use 'in' operator` on a string reply. Folding them fixes\n// that, so it is a behaviour change — an improvement, but not an extraction. Note the\n// precedent cuts both ways: R3-708 already folded two sites carrying this exact form\n// (`openExternal`, `openRepository`), so \"behaviour change\" is a reason to review them\n// as their own item, not a reason they cannot be folded;\n// · `launch.ts` folds `!res.data?.launchId` into the same condition and RETURNS\n// `{ ok: false, code }` instead of throwing. Different control flow entirely.\n//\n// So the remaining work is two items, not one, and they are not the same size.\n//\n// `check:clones` cannot help with any of this: minLines 6, minTokens 50, and no identifier\n// normalisation, so blocks differing only in type names read as distinct.\n//\n// ---------------------------------------------------------------------------\n// THIS FILE'S OWN TEST IS LOAD-BEARING FOR ALL TWELVE SITES\n// ---------------------------------------------------------------------------\n//\n// Measured: changing the guard to `r.ok !== false` compiles clean and leaves **ten of the\n// twelve SITES** green — seven of the nine files: `dnd`, `editor`, `ipc`, `mounts`,\n// `secrets`, `spacesMode` and `vcs`. Every one of them stubs an explicit `{ ok: false }`,\n// so they pin \"throws on a refusal envelope\" and nothing about a malformed or absent\n// reply. Only `openExternal` and `openRepository` — two sites — plus\n// `protocolRefusal.test.ts` catch it: 7 tests across 3 suites.\n//\n// (An earlier version of this paragraph said \"nine of the twelve sites' suites\", which\n// mixes sites with suites — the exact mistake the census block above is headed about —\n// and omitted `secrets` and `spacesMode` from the green list.)\n//\n// Each inline form this replaced carried its own `!res ||` guard, visible at the call site.\n// That guarantee now lives here alone. Do not weaken `protocolRefusal.test.ts` on the\n// grounds that \"the consumers cover it\" — they do not, and twelve near-duplicate malformed\n// -reply tests would be the duplication this extraction exists to remove.\n//\n// ---------------------------------------------------------------------------\n// WHICH `ok` THIS READS, AND WHY IT MATTERS\n// ---------------------------------------------------------------------------\n//\n// It reads the DISPATCHER ENVELOPE's `ok` — the host's answer to \"did this call\n// succeed\", not a handler's own return value. site-main declares that envelope\n// (`src/editor/requestDispatcher.ts`):\n//\n// type SpaceResult =\n// | { ok: true; data: unknown }\n// | { ok: false; code: string; message: string };\n//\n// and the sandbox resolves it to the SDK unmodified (`src/protocol/iframe.ts`,\n// `resolve(msg.result)`). So a refusal reaches us as `{ok:false, code, message}` — which\n// is exactly what this function unwraps — and the host produces that frame by THROWING\n// `spaceError(code, message)`. The dispatcher's `.catch` turns the throw into the frame.\n//\n// **A handler that RETURNS `{ok:false, code}` instead of throwing does not produce a\n// refusal.** The dispatcher wraps a return value as `result: {ok: true, data: <return>}`,\n// so the envelope says the call succeeded and the refusal is buried one level down, where\n// nothing looks. Two shipped handlers did this until R3-778 closed it (site-main; audited sdk#184 round 2, 2026-09-25; fixed 2026-09-28 — both now throw, and a dispatcher assertion reddens on the shape):\n//\n// `handleOpenRepository` returns `invalid`, `no-activation`\n// `handleOpenLink` returns `invalid`, `no-activation`, **`declined`**\n//\n// `declined` is the user pressing \"no\" on the host's confirmation dialog, and\n// `openExternal()` reported that to the app as a successful open, until R3-778 closed it. Driven against the built\n// SDK with each reply shape:\n//\n// thrown -> threw, code=no-activation\n// returned -> RESOLVED (the app believes the tab opened)\n//\n// That was a live defect in site-main's handlers until R3-778 closed it (2026-09-28), not here — the envelope is the contract\n// and this reads the contract. Filed as R3-778. It is written down here because this is\n// the file a host author will be pointed at when they ask what shape to reply with, and\n// the answer is: **throw `spaceError`; never return `{ok:false}`.**\n//\n// Deliberately NOT done: sniffing `res.data?.ok === false` as a second refusal shape. On a\n// SUCCESS, `data` is whatever the handler returned — so a handler whose legitimate payload\n// happens to carry `ok: false` would be turned into a refusal. It would bless the broken\n// shape and create a second contract where the spec names one.\n\n/** An error carrying a stable, host-supplied `code` the app can branch on. */\nexport interface CodedRefusalError<C extends string = string> extends Error {\n code: C;\n}\n\n/**\n * Throw a typed, coded error unless the host's reply envelope says the call succeeded.\n *\n * `fallbackMessage` is used when the host refused without a message, and `'unknown'` is\n * the code when it refused without one — a refusal is never reported as a success just\n * because it arrived under-specified.\n *\n * `code` and `message` must be STRINGS to be used. Twelve sites call this; **eleven** had\n * an inline copy it replaced (`spacesMode.ts` was written against the helper in R3-708 and\n * replaced nothing). All eleven tested for PRESENCE, in **three** shapes:\n *\n * - **seven** cast the value: `(res?.code as SomeError['code']) ?? 'unknown'` —\n * `dnd`, `editor`, `vcs`, `mounts` (×3), `secrets`;\n * - **two** used the `in` operator: `((res && 'code' in res ? res.code : undefined) as\n * Code) ?? 'unknown'` — `openExternal`, `openRepository`, both folded in R3-708;\n * - **two** used a bare `res?.code ?? 'unknown'` onto `Error & { code?: string }` —\n * `ipc.ts`.\n *\n * Every one of them let a host sending `code: 42` surface `err.code === 42` on a field\n * declared `string`, and turned `message: 42` into the string `\"42\"`. Both now fall back,\n * to `'unknown'` and `fallbackMessage`. A deliberate tightening, pinned by\n * `protocolRefusal.test.ts` — and since this package ships no changelog, this paragraph is\n * where a consumer learns of it.\n *\n * The `ipc.ts` pair changed one more thing: their anonymous type declared `code` OPTIONAL\n * and `CodedRefusalError` requires it. No runtime difference for a missing code — the old\n * code assigned `'unknown'` exactly when the new one does (a non-string `code` falls back\n * too, as the paragraph above discloses) — but a consumer narrowing on `'code' in err`\n * can stop.\n *\n * Folding the two `in`-operator sites also removed a latent `TypeError`: `'code' in res`\n * throws on a string reply. Two revisions of this paragraph got that backwards — first\n * claiming the `in` form was among the shapes replaced without saying which sites, then\n * \"correcting\" that to say NO replaced site used it. It was two of them. Both errors came\n * from reading `main`, where R3-708 had already erased the form, instead of the tree before\n * it (`d4b07cc1^`).\n *\n * It is an ASSERTION function, not a `void` one, because the inline form it replaced\n * narrowed `res` as a side effect of its `if`/`throw`: `secrets.ts` and `mounts.ts` read\n * `res.data` on the next line and stopped compiling without it. A caller that only needs\n * the throw can ignore the narrowing; one that reads the payload gets it for free. (TS\n * requires the call target to be an explicitly-typed declared name — this is why it is a\n * `function` declaration and not an arrow const.)\n */\nexport function throwOnRefusal(res: unknown, fallbackMessage: string): asserts res is { ok: true; data?: unknown } {\n const r = res as { ok?: unknown; code?: unknown; message?: unknown } | null | undefined;\n if (r && r.ok === true) return;\n const err = new Error(typeof r?.message === 'string' ? r.message : fallbackMessage) as CodedRefusalError;\n err.code = typeof r?.code === 'string' ? r.code : 'unknown';\n throw err;\n}\n"],"mappings":";AAyJO,SAAS,eAAe,KAAc,iBAAsE;AACjH,QAAM,IAAI;AACV,MAAI,KAAK,EAAE,OAAO,KAAM;AACxB,QAAM,MAAM,IAAI,MAAM,OAAO,GAAG,YAAY,WAAW,EAAE,UAAU,eAAe;AAClF,MAAI,OAAO,OAAO,GAAG,SAAS,WAAW,EAAE,OAAO;AAClD,QAAM;AACR;","names":[]}
|
package/dist/protocolSchemes.cjs
CHANGED
|
@@ -41,6 +41,7 @@ const SCHEMES = {
|
|
|
41
41
|
[import_protocol.PROTOCOL_SECRETS]: schemeOf(import_protocol.PROTOCOL_SECRETS),
|
|
42
42
|
[import_protocol.PROTOCOL_SETTINGS]: schemeOf(import_protocol.PROTOCOL_SETTINGS),
|
|
43
43
|
[import_protocol.PROTOCOL_SPACES]: schemeOf(import_protocol.PROTOCOL_SPACES),
|
|
44
|
+
[import_protocol.PROTOCOL_SPACES_MODE]: schemeOf(import_protocol.PROTOCOL_SPACES_MODE),
|
|
44
45
|
[import_protocol.PROTOCOL_TASK]: schemeOf(import_protocol.PROTOCOL_TASK),
|
|
45
46
|
[import_protocol.PROTOCOL_THEME]: schemeOf(import_protocol.PROTOCOL_THEME),
|
|
46
47
|
[import_protocol.PROTOCOL_VCS]: schemeOf(import_protocol.PROTOCOL_VCS)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/protocolSchemes.ts"],"sourcesContent":["// The `protocol-<scheme>` SCHEMES, derived from the wire names.\n//\n// `protocolRequest(scheme, method, params)` takes the scheme — `'theme'` — while the\n// wire name the frame dispatches on is `'protocol-theme'`; the frame adds the prefix.\n// So the typed service wrappers cannot pass the published `PROTOCOL_*` constant\n// directly, and spelling the scheme inline would put a second, unguarded copy of the\n// name back in the tree — exactly what R3-274c removes.\n//\n// Instead the schemes are *derived* from the wire names, keyed BY the wire name:\n//\n// protocolRequest(SCHEMES[PROTOCOL_THEME], 'set', [{ theme }])\n//\n// Keying by the constant is what makes the derivation unfalsifiable — there is no\n// second place to name the family, so there is no pair to get wrong. `schemeOf`\n// returns a template-literal conditional, so each value has a literal type (`'theme'`),\n// which buys two more things:\n//\n// - a wire name that stops matching `protocol-*` stops compiling here, rather than\n// silently producing an empty scheme at runtime;\n// - `check-protocol-snapshot.mjs` resolves `SCHEMES[PROTOCOL_THEME]` through the type\n// checker exactly like a plain literal, so the call sites stay visible to the gate.\n//\n// One export, deliberately: `./*` is a public subpath, so every name added here is\n// public API forever (ways_of_working §6, additive-only).\n//\n// This module is NOT generated — the derivation is the content — so it lives outside\n// `src/generated/`.\nimport {\n PROTOCOL_ANALYTICS,\n PROTOCOL_CONTRIBUTE,\n PROTOCOL_DND,\n PROTOCOL_EDITOR,\n PROTOCOL_FEED,\n PROTOCOL_FETCH,\n PROTOCOL_IPC,\n PROTOCOL_LAUNCH,\n PROTOCOL_LLM,\n PROTOCOL_LOCALSTORE,\n PROTOCOL_OPENLINK,\n PROTOCOL_OPENREPO,\n PROTOCOL_RECENTS,\n PROTOCOL_SECRETS,\n PROTOCOL_SETTINGS,\n PROTOCOL_SPACES,\n PROTOCOL_TASK,\n PROTOCOL_THEME,\n PROTOCOL_VCS,\n} from './generated/protocol';\n\nconst PREFIX = 'protocol-';\n\n/** The scheme half of a `protocol-<scheme>` wire name. */\ntype SchemeOf<N extends string> = N extends `${typeof PREFIX}${infer S}` ? S : never;\n\n/**\n * `'protocol-theme'` → `'theme'`, as a literal type.\n *\n * The cast is the only place the derivation is asserted rather than computed; the\n * `N extends \\`protocol-${string}\\`` bound is what makes it sound — a wire name that is\n * not scheme-shaped is a compile error at the call, not a `never` at runtime.\n */\nconst schemeOf = <N extends `${typeof PREFIX}${string}`>(name: N): SchemeOf<N> =>\n name.slice(PREFIX.length) as SchemeOf<N>;\n\n/** Every `protocol-*` scheme the SDK speaks, keyed by its wire name. */\nexport const SCHEMES = {\n [PROTOCOL_ANALYTICS]: schemeOf(PROTOCOL_ANALYTICS),\n [PROTOCOL_CONTRIBUTE]: schemeOf(PROTOCOL_CONTRIBUTE),\n [PROTOCOL_DND]: schemeOf(PROTOCOL_DND),\n [PROTOCOL_EDITOR]: schemeOf(PROTOCOL_EDITOR),\n [PROTOCOL_FEED]: schemeOf(PROTOCOL_FEED),\n [PROTOCOL_FETCH]: schemeOf(PROTOCOL_FETCH),\n [PROTOCOL_IPC]: schemeOf(PROTOCOL_IPC),\n [PROTOCOL_LAUNCH]: schemeOf(PROTOCOL_LAUNCH),\n [PROTOCOL_LLM]: schemeOf(PROTOCOL_LLM),\n [PROTOCOL_LOCALSTORE]: schemeOf(PROTOCOL_LOCALSTORE),\n [PROTOCOL_OPENLINK]: schemeOf(PROTOCOL_OPENLINK),\n [PROTOCOL_OPENREPO]: schemeOf(PROTOCOL_OPENREPO),\n [PROTOCOL_RECENTS]: schemeOf(PROTOCOL_RECENTS),\n [PROTOCOL_SECRETS]: schemeOf(PROTOCOL_SECRETS),\n [PROTOCOL_SETTINGS]: schemeOf(PROTOCOL_SETTINGS),\n [PROTOCOL_SPACES]: schemeOf(PROTOCOL_SPACES),\n [PROTOCOL_TASK]: schemeOf(PROTOCOL_TASK),\n [PROTOCOL_THEME]: schemeOf(PROTOCOL_THEME),\n [PROTOCOL_VCS]: schemeOf(PROTOCOL_VCS),\n} as const;\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AA2BA,
|
|
1
|
+
{"version":3,"sources":["../src/protocolSchemes.ts"],"sourcesContent":["// The `protocol-<scheme>` SCHEMES, derived from the wire names.\n//\n// `protocolRequest(scheme, method, params)` takes the scheme — `'theme'` — while the\n// wire name the frame dispatches on is `'protocol-theme'`; the frame adds the prefix.\n// So the typed service wrappers cannot pass the published `PROTOCOL_*` constant\n// directly, and spelling the scheme inline would put a second, unguarded copy of the\n// name back in the tree — exactly what R3-274c removes.\n//\n// Instead the schemes are *derived* from the wire names, keyed BY the wire name:\n//\n// protocolRequest(SCHEMES[PROTOCOL_THEME], 'set', [{ theme }])\n//\n// Keying by the constant is what makes the derivation unfalsifiable — there is no\n// second place to name the family, so there is no pair to get wrong. `schemeOf`\n// returns a template-literal conditional, so each value has a literal type (`'theme'`),\n// which buys two more things:\n//\n// - a wire name that stops matching `protocol-*` stops compiling here, rather than\n// silently producing an empty scheme at runtime;\n// - `check-protocol-snapshot.mjs` resolves `SCHEMES[PROTOCOL_THEME]` through the type\n// checker exactly like a plain literal, so the call sites stay visible to the gate.\n//\n// One export, deliberately: `./*` is a public subpath, so every name added here is\n// public API forever (ways_of_working §6, additive-only).\n//\n// This module is NOT generated — the derivation is the content — so it lives outside\n// `src/generated/`.\nimport {\n PROTOCOL_ANALYTICS,\n PROTOCOL_CONTRIBUTE,\n PROTOCOL_DND,\n PROTOCOL_EDITOR,\n PROTOCOL_FEED,\n PROTOCOL_FETCH,\n PROTOCOL_IPC,\n PROTOCOL_LAUNCH,\n PROTOCOL_LLM,\n PROTOCOL_LOCALSTORE,\n PROTOCOL_OPENLINK,\n PROTOCOL_OPENREPO,\n PROTOCOL_RECENTS,\n PROTOCOL_SECRETS,\n PROTOCOL_SETTINGS,\n PROTOCOL_SPACES,\n PROTOCOL_SPACES_MODE,\n PROTOCOL_TASK,\n PROTOCOL_THEME,\n PROTOCOL_VCS,\n} from './generated/protocol';\n\nconst PREFIX = 'protocol-';\n\n/** The scheme half of a `protocol-<scheme>` wire name. */\ntype SchemeOf<N extends string> = N extends `${typeof PREFIX}${infer S}` ? S : never;\n\n/**\n * `'protocol-theme'` → `'theme'`, as a literal type.\n *\n * The cast is the only place the derivation is asserted rather than computed; the\n * `N extends \\`protocol-${string}\\`` bound is what makes it sound — a wire name that is\n * not scheme-shaped is a compile error at the call, not a `never` at runtime.\n */\nconst schemeOf = <N extends `${typeof PREFIX}${string}`>(name: N): SchemeOf<N> =>\n name.slice(PREFIX.length) as SchemeOf<N>;\n\n/** Every `protocol-*` scheme the SDK speaks, keyed by its wire name. */\nexport const SCHEMES = {\n [PROTOCOL_ANALYTICS]: schemeOf(PROTOCOL_ANALYTICS),\n [PROTOCOL_CONTRIBUTE]: schemeOf(PROTOCOL_CONTRIBUTE),\n [PROTOCOL_DND]: schemeOf(PROTOCOL_DND),\n [PROTOCOL_EDITOR]: schemeOf(PROTOCOL_EDITOR),\n [PROTOCOL_FEED]: schemeOf(PROTOCOL_FEED),\n [PROTOCOL_FETCH]: schemeOf(PROTOCOL_FETCH),\n [PROTOCOL_IPC]: schemeOf(PROTOCOL_IPC),\n [PROTOCOL_LAUNCH]: schemeOf(PROTOCOL_LAUNCH),\n [PROTOCOL_LLM]: schemeOf(PROTOCOL_LLM),\n [PROTOCOL_LOCALSTORE]: schemeOf(PROTOCOL_LOCALSTORE),\n [PROTOCOL_OPENLINK]: schemeOf(PROTOCOL_OPENLINK),\n [PROTOCOL_OPENREPO]: schemeOf(PROTOCOL_OPENREPO),\n [PROTOCOL_RECENTS]: schemeOf(PROTOCOL_RECENTS),\n [PROTOCOL_SECRETS]: schemeOf(PROTOCOL_SECRETS),\n [PROTOCOL_SETTINGS]: schemeOf(PROTOCOL_SETTINGS),\n [PROTOCOL_SPACES]: schemeOf(PROTOCOL_SPACES),\n [PROTOCOL_SPACES_MODE]: schemeOf(PROTOCOL_SPACES_MODE),\n [PROTOCOL_TASK]: schemeOf(PROTOCOL_TASK),\n [PROTOCOL_THEME]: schemeOf(PROTOCOL_THEME),\n [PROTOCOL_VCS]: schemeOf(PROTOCOL_VCS),\n} as const;\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AA2BA,sBAqBO;AAEP,MAAM,SAAS;AAYf,MAAM,WAAW,CAAwC,SACvD,KAAK,MAAM,OAAO,MAAM;AAGnB,MAAM,UAAU;AAAA,EACrB,CAAC,kCAAkB,GAAG,SAAS,kCAAkB;AAAA,EACjD,CAAC,mCAAmB,GAAG,SAAS,mCAAmB;AAAA,EACnD,CAAC,4BAAY,GAAG,SAAS,4BAAY;AAAA,EACrC,CAAC,+BAAe,GAAG,SAAS,+BAAe;AAAA,EAC3C,CAAC,6BAAa,GAAG,SAAS,6BAAa;AAAA,EACvC,CAAC,8BAAc,GAAG,SAAS,8BAAc;AAAA,EACzC,CAAC,4BAAY,GAAG,SAAS,4BAAY;AAAA,EACrC,CAAC,+BAAe,GAAG,SAAS,+BAAe;AAAA,EAC3C,CAAC,4BAAY,GAAG,SAAS,4BAAY;AAAA,EACrC,CAAC,mCAAmB,GAAG,SAAS,mCAAmB;AAAA,EACnD,CAAC,iCAAiB,GAAG,SAAS,iCAAiB;AAAA,EAC/C,CAAC,iCAAiB,GAAG,SAAS,iCAAiB;AAAA,EAC/C,CAAC,gCAAgB,GAAG,SAAS,gCAAgB;AAAA,EAC7C,CAAC,gCAAgB,GAAG,SAAS,gCAAgB;AAAA,EAC7C,CAAC,iCAAiB,GAAG,SAAS,iCAAiB;AAAA,EAC/C,CAAC,+BAAe,GAAG,SAAS,+BAAe;AAAA,EAC3C,CAAC,oCAAoB,GAAG,SAAS,oCAAoB;AAAA,EACrD,CAAC,6BAAa,GAAG,SAAS,6BAAa;AAAA,EACvC,CAAC,8BAAc,GAAG,SAAS,8BAAc;AAAA,EACzC,CAAC,4BAAY,GAAG,SAAS,4BAAY;AACvC;","names":[]}
|
|
@@ -16,6 +16,7 @@ declare const SCHEMES: {
|
|
|
16
16
|
readonly "protocol-secrets": "secrets";
|
|
17
17
|
readonly "protocol-settings": "settings";
|
|
18
18
|
readonly "protocol-spaces": "spaces";
|
|
19
|
+
readonly "protocol-spaces-mode": "spaces-mode";
|
|
19
20
|
readonly "protocol-task": "task";
|
|
20
21
|
readonly "protocol-theme": "theme";
|
|
21
22
|
readonly "protocol-vcs": "vcs";
|
|
@@ -16,6 +16,7 @@ declare const SCHEMES: {
|
|
|
16
16
|
readonly "protocol-secrets": "secrets";
|
|
17
17
|
readonly "protocol-settings": "settings";
|
|
18
18
|
readonly "protocol-spaces": "spaces";
|
|
19
|
+
readonly "protocol-spaces-mode": "spaces-mode";
|
|
19
20
|
readonly "protocol-task": "task";
|
|
20
21
|
readonly "protocol-theme": "theme";
|
|
21
22
|
readonly "protocol-vcs": "vcs";
|
package/dist/protocolSchemes.js
CHANGED
|
@@ -16,6 +16,7 @@ import {
|
|
|
16
16
|
PROTOCOL_SECRETS,
|
|
17
17
|
PROTOCOL_SETTINGS,
|
|
18
18
|
PROTOCOL_SPACES,
|
|
19
|
+
PROTOCOL_SPACES_MODE,
|
|
19
20
|
PROTOCOL_TASK,
|
|
20
21
|
PROTOCOL_THEME,
|
|
21
22
|
PROTOCOL_VCS
|
|
@@ -39,6 +40,7 @@ const SCHEMES = {
|
|
|
39
40
|
[PROTOCOL_SECRETS]: schemeOf(PROTOCOL_SECRETS),
|
|
40
41
|
[PROTOCOL_SETTINGS]: schemeOf(PROTOCOL_SETTINGS),
|
|
41
42
|
[PROTOCOL_SPACES]: schemeOf(PROTOCOL_SPACES),
|
|
43
|
+
[PROTOCOL_SPACES_MODE]: schemeOf(PROTOCOL_SPACES_MODE),
|
|
42
44
|
[PROTOCOL_TASK]: schemeOf(PROTOCOL_TASK),
|
|
43
45
|
[PROTOCOL_THEME]: schemeOf(PROTOCOL_THEME),
|
|
44
46
|
[PROTOCOL_VCS]: schemeOf(PROTOCOL_VCS)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/protocolSchemes.ts"],"sourcesContent":["// The `protocol-<scheme>` SCHEMES, derived from the wire names.\n//\n// `protocolRequest(scheme, method, params)` takes the scheme — `'theme'` — while the\n// wire name the frame dispatches on is `'protocol-theme'`; the frame adds the prefix.\n// So the typed service wrappers cannot pass the published `PROTOCOL_*` constant\n// directly, and spelling the scheme inline would put a second, unguarded copy of the\n// name back in the tree — exactly what R3-274c removes.\n//\n// Instead the schemes are *derived* from the wire names, keyed BY the wire name:\n//\n// protocolRequest(SCHEMES[PROTOCOL_THEME], 'set', [{ theme }])\n//\n// Keying by the constant is what makes the derivation unfalsifiable — there is no\n// second place to name the family, so there is no pair to get wrong. `schemeOf`\n// returns a template-literal conditional, so each value has a literal type (`'theme'`),\n// which buys two more things:\n//\n// - a wire name that stops matching `protocol-*` stops compiling here, rather than\n// silently producing an empty scheme at runtime;\n// - `check-protocol-snapshot.mjs` resolves `SCHEMES[PROTOCOL_THEME]` through the type\n// checker exactly like a plain literal, so the call sites stay visible to the gate.\n//\n// One export, deliberately: `./*` is a public subpath, so every name added here is\n// public API forever (ways_of_working §6, additive-only).\n//\n// This module is NOT generated — the derivation is the content — so it lives outside\n// `src/generated/`.\nimport {\n PROTOCOL_ANALYTICS,\n PROTOCOL_CONTRIBUTE,\n PROTOCOL_DND,\n PROTOCOL_EDITOR,\n PROTOCOL_FEED,\n PROTOCOL_FETCH,\n PROTOCOL_IPC,\n PROTOCOL_LAUNCH,\n PROTOCOL_LLM,\n PROTOCOL_LOCALSTORE,\n PROTOCOL_OPENLINK,\n PROTOCOL_OPENREPO,\n PROTOCOL_RECENTS,\n PROTOCOL_SECRETS,\n PROTOCOL_SETTINGS,\n PROTOCOL_SPACES,\n PROTOCOL_TASK,\n PROTOCOL_THEME,\n PROTOCOL_VCS,\n} from './generated/protocol';\n\nconst PREFIX = 'protocol-';\n\n/** The scheme half of a `protocol-<scheme>` wire name. */\ntype SchemeOf<N extends string> = N extends `${typeof PREFIX}${infer S}` ? S : never;\n\n/**\n * `'protocol-theme'` → `'theme'`, as a literal type.\n *\n * The cast is the only place the derivation is asserted rather than computed; the\n * `N extends \\`protocol-${string}\\`` bound is what makes it sound — a wire name that is\n * not scheme-shaped is a compile error at the call, not a `never` at runtime.\n */\nconst schemeOf = <N extends `${typeof PREFIX}${string}`>(name: N): SchemeOf<N> =>\n name.slice(PREFIX.length) as SchemeOf<N>;\n\n/** Every `protocol-*` scheme the SDK speaks, keyed by its wire name. */\nexport const SCHEMES = {\n [PROTOCOL_ANALYTICS]: schemeOf(PROTOCOL_ANALYTICS),\n [PROTOCOL_CONTRIBUTE]: schemeOf(PROTOCOL_CONTRIBUTE),\n [PROTOCOL_DND]: schemeOf(PROTOCOL_DND),\n [PROTOCOL_EDITOR]: schemeOf(PROTOCOL_EDITOR),\n [PROTOCOL_FEED]: schemeOf(PROTOCOL_FEED),\n [PROTOCOL_FETCH]: schemeOf(PROTOCOL_FETCH),\n [PROTOCOL_IPC]: schemeOf(PROTOCOL_IPC),\n [PROTOCOL_LAUNCH]: schemeOf(PROTOCOL_LAUNCH),\n [PROTOCOL_LLM]: schemeOf(PROTOCOL_LLM),\n [PROTOCOL_LOCALSTORE]: schemeOf(PROTOCOL_LOCALSTORE),\n [PROTOCOL_OPENLINK]: schemeOf(PROTOCOL_OPENLINK),\n [PROTOCOL_OPENREPO]: schemeOf(PROTOCOL_OPENREPO),\n [PROTOCOL_RECENTS]: schemeOf(PROTOCOL_RECENTS),\n [PROTOCOL_SECRETS]: schemeOf(PROTOCOL_SECRETS),\n [PROTOCOL_SETTINGS]: schemeOf(PROTOCOL_SETTINGS),\n [PROTOCOL_SPACES]: schemeOf(PROTOCOL_SPACES),\n [PROTOCOL_TASK]: schemeOf(PROTOCOL_TASK),\n [PROTOCOL_THEME]: schemeOf(PROTOCOL_THEME),\n [PROTOCOL_VCS]: schemeOf(PROTOCOL_VCS),\n} as const;\n"],"mappings":";AA2BA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAEP,MAAM,SAAS;AAYf,MAAM,WAAW,CAAwC,SACvD,KAAK,MAAM,OAAO,MAAM;AAGnB,MAAM,UAAU;AAAA,EACrB,CAAC,kBAAkB,GAAG,SAAS,kBAAkB;AAAA,EACjD,CAAC,mBAAmB,GAAG,SAAS,mBAAmB;AAAA,EACnD,CAAC,YAAY,GAAG,SAAS,YAAY;AAAA,EACrC,CAAC,eAAe,GAAG,SAAS,eAAe;AAAA,EAC3C,CAAC,aAAa,GAAG,SAAS,aAAa;AAAA,EACvC,CAAC,cAAc,GAAG,SAAS,cAAc;AAAA,EACzC,CAAC,YAAY,GAAG,SAAS,YAAY;AAAA,EACrC,CAAC,eAAe,GAAG,SAAS,eAAe;AAAA,EAC3C,CAAC,YAAY,GAAG,SAAS,YAAY;AAAA,EACrC,CAAC,mBAAmB,GAAG,SAAS,mBAAmB;AAAA,EACnD,CAAC,iBAAiB,GAAG,SAAS,iBAAiB;AAAA,EAC/C,CAAC,iBAAiB,GAAG,SAAS,iBAAiB;AAAA,EAC/C,CAAC,gBAAgB,GAAG,SAAS,gBAAgB;AAAA,EAC7C,CAAC,gBAAgB,GAAG,SAAS,gBAAgB;AAAA,EAC7C,CAAC,iBAAiB,GAAG,SAAS,iBAAiB;AAAA,EAC/C,CAAC,eAAe,GAAG,SAAS,eAAe;AAAA,EAC3C,CAAC,aAAa,GAAG,SAAS,aAAa;AAAA,EACvC,CAAC,cAAc,GAAG,SAAS,cAAc;AAAA,EACzC,CAAC,YAAY,GAAG,SAAS,YAAY;AACvC;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../src/protocolSchemes.ts"],"sourcesContent":["// The `protocol-<scheme>` SCHEMES, derived from the wire names.\n//\n// `protocolRequest(scheme, method, params)` takes the scheme — `'theme'` — while the\n// wire name the frame dispatches on is `'protocol-theme'`; the frame adds the prefix.\n// So the typed service wrappers cannot pass the published `PROTOCOL_*` constant\n// directly, and spelling the scheme inline would put a second, unguarded copy of the\n// name back in the tree — exactly what R3-274c removes.\n//\n// Instead the schemes are *derived* from the wire names, keyed BY the wire name:\n//\n// protocolRequest(SCHEMES[PROTOCOL_THEME], 'set', [{ theme }])\n//\n// Keying by the constant is what makes the derivation unfalsifiable — there is no\n// second place to name the family, so there is no pair to get wrong. `schemeOf`\n// returns a template-literal conditional, so each value has a literal type (`'theme'`),\n// which buys two more things:\n//\n// - a wire name that stops matching `protocol-*` stops compiling here, rather than\n// silently producing an empty scheme at runtime;\n// - `check-protocol-snapshot.mjs` resolves `SCHEMES[PROTOCOL_THEME]` through the type\n// checker exactly like a plain literal, so the call sites stay visible to the gate.\n//\n// One export, deliberately: `./*` is a public subpath, so every name added here is\n// public API forever (ways_of_working §6, additive-only).\n//\n// This module is NOT generated — the derivation is the content — so it lives outside\n// `src/generated/`.\nimport {\n PROTOCOL_ANALYTICS,\n PROTOCOL_CONTRIBUTE,\n PROTOCOL_DND,\n PROTOCOL_EDITOR,\n PROTOCOL_FEED,\n PROTOCOL_FETCH,\n PROTOCOL_IPC,\n PROTOCOL_LAUNCH,\n PROTOCOL_LLM,\n PROTOCOL_LOCALSTORE,\n PROTOCOL_OPENLINK,\n PROTOCOL_OPENREPO,\n PROTOCOL_RECENTS,\n PROTOCOL_SECRETS,\n PROTOCOL_SETTINGS,\n PROTOCOL_SPACES,\n PROTOCOL_SPACES_MODE,\n PROTOCOL_TASK,\n PROTOCOL_THEME,\n PROTOCOL_VCS,\n} from './generated/protocol';\n\nconst PREFIX = 'protocol-';\n\n/** The scheme half of a `protocol-<scheme>` wire name. */\ntype SchemeOf<N extends string> = N extends `${typeof PREFIX}${infer S}` ? S : never;\n\n/**\n * `'protocol-theme'` → `'theme'`, as a literal type.\n *\n * The cast is the only place the derivation is asserted rather than computed; the\n * `N extends \\`protocol-${string}\\`` bound is what makes it sound — a wire name that is\n * not scheme-shaped is a compile error at the call, not a `never` at runtime.\n */\nconst schemeOf = <N extends `${typeof PREFIX}${string}`>(name: N): SchemeOf<N> =>\n name.slice(PREFIX.length) as SchemeOf<N>;\n\n/** Every `protocol-*` scheme the SDK speaks, keyed by its wire name. */\nexport const SCHEMES = {\n [PROTOCOL_ANALYTICS]: schemeOf(PROTOCOL_ANALYTICS),\n [PROTOCOL_CONTRIBUTE]: schemeOf(PROTOCOL_CONTRIBUTE),\n [PROTOCOL_DND]: schemeOf(PROTOCOL_DND),\n [PROTOCOL_EDITOR]: schemeOf(PROTOCOL_EDITOR),\n [PROTOCOL_FEED]: schemeOf(PROTOCOL_FEED),\n [PROTOCOL_FETCH]: schemeOf(PROTOCOL_FETCH),\n [PROTOCOL_IPC]: schemeOf(PROTOCOL_IPC),\n [PROTOCOL_LAUNCH]: schemeOf(PROTOCOL_LAUNCH),\n [PROTOCOL_LLM]: schemeOf(PROTOCOL_LLM),\n [PROTOCOL_LOCALSTORE]: schemeOf(PROTOCOL_LOCALSTORE),\n [PROTOCOL_OPENLINK]: schemeOf(PROTOCOL_OPENLINK),\n [PROTOCOL_OPENREPO]: schemeOf(PROTOCOL_OPENREPO),\n [PROTOCOL_RECENTS]: schemeOf(PROTOCOL_RECENTS),\n [PROTOCOL_SECRETS]: schemeOf(PROTOCOL_SECRETS),\n [PROTOCOL_SETTINGS]: schemeOf(PROTOCOL_SETTINGS),\n [PROTOCOL_SPACES]: schemeOf(PROTOCOL_SPACES),\n [PROTOCOL_SPACES_MODE]: schemeOf(PROTOCOL_SPACES_MODE),\n [PROTOCOL_TASK]: schemeOf(PROTOCOL_TASK),\n [PROTOCOL_THEME]: schemeOf(PROTOCOL_THEME),\n [PROTOCOL_VCS]: schemeOf(PROTOCOL_VCS),\n} as const;\n"],"mappings":";AA2BA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAEP,MAAM,SAAS;AAYf,MAAM,WAAW,CAAwC,SACvD,KAAK,MAAM,OAAO,MAAM;AAGnB,MAAM,UAAU;AAAA,EACrB,CAAC,kBAAkB,GAAG,SAAS,kBAAkB;AAAA,EACjD,CAAC,mBAAmB,GAAG,SAAS,mBAAmB;AAAA,EACnD,CAAC,YAAY,GAAG,SAAS,YAAY;AAAA,EACrC,CAAC,eAAe,GAAG,SAAS,eAAe;AAAA,EAC3C,CAAC,aAAa,GAAG,SAAS,aAAa;AAAA,EACvC,CAAC,cAAc,GAAG,SAAS,cAAc;AAAA,EACzC,CAAC,YAAY,GAAG,SAAS,YAAY;AAAA,EACrC,CAAC,eAAe,GAAG,SAAS,eAAe;AAAA,EAC3C,CAAC,YAAY,GAAG,SAAS,YAAY;AAAA,EACrC,CAAC,mBAAmB,GAAG,SAAS,mBAAmB;AAAA,EACnD,CAAC,iBAAiB,GAAG,SAAS,iBAAiB;AAAA,EAC/C,CAAC,iBAAiB,GAAG,SAAS,iBAAiB;AAAA,EAC/C,CAAC,gBAAgB,GAAG,SAAS,gBAAgB;AAAA,EAC7C,CAAC,gBAAgB,GAAG,SAAS,gBAAgB;AAAA,EAC7C,CAAC,iBAAiB,GAAG,SAAS,iBAAiB;AAAA,EAC/C,CAAC,eAAe,GAAG,SAAS,eAAe;AAAA,EAC3C,CAAC,oBAAoB,GAAG,SAAS,oBAAoB;AAAA,EACrD,CAAC,aAAa,GAAG,SAAS,aAAa;AAAA,EACvC,CAAC,cAAc,GAAG,SAAS,cAAc;AAAA,EACzC,CAAC,YAAY,GAAG,SAAS,YAAY;AACvC;","names":[]}
|
package/dist/secrets.cjs
CHANGED
|
@@ -27,16 +27,13 @@ __export(secrets_exports, {
|
|
|
27
27
|
});
|
|
28
28
|
module.exports = __toCommonJS(secrets_exports);
|
|
29
29
|
var import_sandboxUtils = require("./sandboxUtils");
|
|
30
|
+
var import_protocolRefusal = require("./protocolRefusal");
|
|
30
31
|
var import_pushChannel = require("./pushChannel");
|
|
31
32
|
var import_protocol = require("./generated/protocol");
|
|
32
33
|
var import_protocolSchemes = require("./protocolSchemes");
|
|
33
34
|
const request = async (method, query = {}) => {
|
|
34
35
|
const res = await (0, import_sandboxUtils.protocolRequest)(import_protocolSchemes.SCHEMES[import_protocol.PROTOCOL_SECRETS], method, [query]);
|
|
35
|
-
|
|
36
|
-
const err = new Error(res?.message ?? "secret request failed");
|
|
37
|
-
err.code = res?.code ?? "unknown";
|
|
38
|
-
throw err;
|
|
39
|
-
}
|
|
36
|
+
(0, import_protocolRefusal.throwOnRefusal)(res, "secret request failed");
|
|
40
37
|
return res.data;
|
|
41
38
|
};
|
|
42
39
|
const requestAddSecret = (hints = {}) => request("add", hints);
|