@iicp/web-node 0.2.5 → 0.2.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -36,6 +36,14 @@ does not support them, and can enforce strict region and signed-policy-manifest
36
36
  before a prompt is sent. Declared prohibited or high-risk public-mesh intents are refused
37
37
  locally. Successful routing receipts exclude prompt, response, token, and endpoint content.
38
38
 
39
+ Restricted trust-domain, federated-private, local-only and custom operating
40
+ modes are not supported by the browser package yet. Passing an explicit
41
+ non-public `operating_mode` to `IicpBrowserClient`, or `operatingMode` to
42
+ `BrowserNodeProvider`, throws `restricted_profile_unsupported` during
43
+ construction, before discovery, registration or relay traffic. The package
44
+ does not persist membership credentials in browser storage and never downgrades
45
+ an explicit private mode to the public directory.
46
+
39
47
  When the chosen node advertises an encryption key (`nodeCxKey(node)`), the payload is
40
48
  **sealed end-to-end** — the directory, relays, and network see only ciphertext. There is
41
49
  no opt-out. A node that does not advertise `cx_public_key`/`public_key` is refused before
@@ -1,5 +1,6 @@
1
1
  import type { ChatMessage } from "./iicpConsumer.js";
2
2
  import type { EffectiveCapability } from "./effectiveCapability.js";
3
+ import { type BrowserOperatingMode } from "./operatingMode.js";
3
4
  export interface BrowserProviderRuntime {
4
5
  chat(messages: ChatMessage[], opts?: {
5
6
  temperature?: number;
@@ -7,6 +8,8 @@ export interface BrowserProviderRuntime {
7
8
  }): Promise<string>;
8
9
  }
9
10
  export interface BrowserProviderConfig {
11
+ /** Explicit operating mode. Browser CUG/local modes currently fail closed. */
12
+ operatingMode?: BrowserOperatingMode;
10
13
  /** Relay node base URL, e.g. "http://127.0.0.1:9484". Required. */
11
14
  relayUrl: string;
12
15
  /** Auto-discovered relay node id. Used to audience-scope relay bind tickets. */
@@ -18,6 +18,7 @@
18
18
  // consumers route to a browser worker with zero client changes.
19
19
  import { maskTunnelUrl } from "./iicpConsumer.js";
20
20
  import { createCxKeyPair, decryptPayload } from "./cxConfidentiality.js";
21
+ import { requireSupportedBrowserMode } from "./operatingMode.js";
21
22
  import { BROWSER_NODE_SDK_COMPATIBILITY_VERSION, BROWSER_NODE_SDK_VERSION, BROWSER_NODE_VERSION, } from "./version.js";
22
23
  const CHAT_INTENT = "urn:iicp:intent:llm:chat:v1";
23
24
  export { BROWSER_NODE_SDK_VERSION } from "./version.js";
@@ -172,6 +173,7 @@ export class BrowserNodeProvider {
172
173
  constructor(runtime, cfg) {
173
174
  this.runtime = runtime;
174
175
  this.cfg = cfg;
176
+ requireSupportedBrowserMode(cfg.operatingMode);
175
177
  this.nodeId = `browser-${crypto.randomUUID().slice(0, 8)}`;
176
178
  }
177
179
  get state() {
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "schema": "iicp.browser_build_provenance.v1",
3
3
  "package": "@iicp/web-node",
4
- "implementation_version": "0.2.5",
4
+ "implementation_version": "0.2.6",
5
5
  "sdk_compatibility_version": "0.7.102",
6
- "source_commit": "6f28256d0d67cf08beddadbc762dbd339786fcd8",
7
- "lockfile_sha256": "1a398bdcc85e5a650a394aac26851a04c44bd3e6ec9c8c1c359d4d3015338a7e"
6
+ "source_commit": "2d839c075c649ca8320af1734845862c8265588f",
7
+ "lockfile_sha256": "3a86e8b68bd9cee5ab5f99b1975b75db0ed924fe582873b9590f0047bb87eea1"
8
8
  }
@@ -1,7 +1,10 @@
1
1
  import { type CxPublicKey } from "./cxConfidentiality.js";
2
2
  import { type RuntimeIdentityOptions } from "./runtimeIdentity.js";
3
+ import { type BrowserOperatingMode } from "./operatingMode.js";
3
4
  export declare const DEFAULT_DIRECTORY_URL = "https://iicp.network";
4
5
  export interface ClientConfig {
6
+ /** Explicit operating mode. Browser CUG/local modes currently fail closed. */
7
+ operating_mode?: BrowserOperatingMode;
5
8
  /** Directory base URL. Default: https://iicp.network (CORS-enabled). */
6
9
  directory_url?: string;
7
10
  /** Per-request timeout (ms). Default 10000. */
@@ -19,6 +19,7 @@ import { encryptPayload } from "./cxConfidentiality.js";
19
19
  import { verifyDispatchTicket } from "./dispatchTicket.js";
20
20
  import { composeRuntimeIdentity, withRuntimeFacts } from "./runtimeIdentity.js";
21
21
  import { BROWSER_NODE_VERSION } from "./version.js";
22
+ import { requireSupportedBrowserMode } from "./operatingMode.js";
22
23
  const REFUSED_INTENT_RULES = [
23
24
  { category: "prohibited", rule_id: "eu-ai-act-social-scoring", label: "social scoring", fragments: ["social-scoring", "social_scoring", "social:scoring"] },
24
25
  { category: "prohibited", rule_id: "eu-ai-act-criminal-risk", label: "individual criminal risk prediction", fragments: ["criminal-risk", "criminal_risk", "criminal:risk", "predict-crime"] },
@@ -317,6 +318,7 @@ export class IicpBrowserClient {
317
318
  routeDiscoveryMode;
318
319
  dispatchTicketKey;
319
320
  constructor(cfg = {}) {
321
+ requireSupportedBrowserMode(cfg.operating_mode);
320
322
  this.directory = (cfg.directory_url ?? DEFAULT_DIRECTORY_URL).replace(/\/+$/, "");
321
323
  this.timeout = cfg.timeout_ms ?? 10_000;
322
324
  this.allowedRegions = normalizeAllowedRegions(cfg.allowed_regions);
package/dist/index.d.ts CHANGED
@@ -3,6 +3,7 @@ export * from "./dispatchTicket.js";
3
3
  export * from "./cxConfidentiality.js";
4
4
  export * from "./effectiveCapability.js";
5
5
  export * from "./runtimeIdentity.js";
6
+ export * from "./operatingMode.js";
6
7
  export * from "./browserNodeProvider.js";
7
8
  export * from "./webllmRuntime.js";
8
9
  export * from "./version.js";
package/dist/index.js CHANGED
@@ -10,6 +10,7 @@ export * from "./dispatchTicket.js";
10
10
  export * from "./cxConfidentiality.js";
11
11
  export * from "./effectiveCapability.js";
12
12
  export * from "./runtimeIdentity.js";
13
+ export * from "./operatingMode.js";
13
14
  export * from "./browserNodeProvider.js";
14
15
  export * from "./webllmRuntime.js";
15
16
  export * from "./version.js";
@@ -0,0 +1,4 @@
1
+ export type BrowserOperatingMode = "public" | "private" | "federated_private" | "local_only" | "custom";
2
+ export declare const RESTRICTED_BROWSER_UNSUPPORTED = "restricted_profile_unsupported";
3
+ /** Refuse unsupported modes before discovery, registration or relay work. */
4
+ export declare function requireSupportedBrowserMode(mode?: BrowserOperatingMode): void;
@@ -0,0 +1,8 @@
1
+ // SPDX-License-Identifier: Apache-2.0
2
+ export const RESTRICTED_BROWSER_UNSUPPORTED = "restricted_profile_unsupported";
3
+ /** Refuse unsupported modes before discovery, registration or relay work. */
4
+ export function requireSupportedBrowserMode(mode = "public") {
5
+ if (mode !== "public") {
6
+ throw new Error(RESTRICTED_BROWSER_UNSUPPORTED);
7
+ }
8
+ }
@@ -3,6 +3,9 @@ export declare const RUNTIME_IDENTITY_PROFILE_ID = "urn:iicp:profile:runtime-ide
3
3
  export declare const RUNTIME_IDENTITY_MARKER = "IICP-RUNTIME-CONTEXT/1";
4
4
  export declare const RUNTIME_IDENTITY_CHAT_INTENT = "urn:iicp:intent:llm:chat:v1";
5
5
  export declare const RUNTIME_IDENTITY_MAX_BYTES = 2048;
6
+ export declare const CANONICAL_IICP_EXPLANATION = "IICP is the Intent-based Inter-agent Communication Protocol: a provider-neutral control plane that discovers eligible intelligence services, evaluates them under explicit constraints, selects a provider, and leaves execution to a supported provider mechanism.";
7
+ export declare function isDirectIicpExplainer(prompt: string): boolean;
8
+ export declare function validIicpExplanation(answer: string): boolean;
6
9
  export type RuntimeIdentityMode = "auto" | "disabled" | "explicit" | "required";
7
10
  export type RuntimeIdentityInstructionChannel = "system" | "unsupported";
8
11
  export type RuntimeIdentityConnectionMode = "routed" | "local_browser";
@@ -4,7 +4,18 @@ export const RUNTIME_IDENTITY_CHAT_INTENT = "urn:iicp:intent:llm:chat:v1";
4
4
  export const RUNTIME_IDENTITY_MAX_BYTES = 2048;
5
5
  const MAX_FACT_BYTES = 160;
6
6
  const MAX_CAPABILITIES = 32;
7
- const BASE_CAPSULE = "This request reached you through IICP, the Intent-based Inter-agent Communication Protocol. IICP discovers eligible services and routes requests. You are the selected model or service, not IICP. When asked about this connection, use only supplied runtime facts; do not guess missing facts.";
7
+ export const CANONICAL_IICP_EXPLANATION = "IICP is the Intent-based Inter-agent Communication Protocol: a provider-neutral control plane that discovers eligible intelligence services, evaluates them under explicit constraints, selects a provider, and leaves execution to a supported provider mechanism.";
8
+ export function isDirectIicpExplainer(prompt) {
9
+ const value = prompt.trim().toLowerCase().replace(/[.?!]+$/u, "");
10
+ return ["what is iicp", "what does iicp stand for", "explain iicp", "describe iicp", "what is this"].includes(value);
11
+ }
12
+ export function validIicpExplanation(answer) {
13
+ const value = answer.toLowerCase();
14
+ return value.includes("intent-based inter-agent communication protocol")
15
+ && (value.includes("control plane") || value.includes("discover"))
16
+ && !value.includes("industrial internet of things computing");
17
+ }
18
+ const BASE_CAPSULE = "This request reached you through IICP, the Intent-based Inter-agent Communication Protocol. IICP is a provider-neutral control plane that turns a requested intent and constraints into discovery, eligibility evaluation and provider selection; execution then uses a supported provider mechanism. You are the selected model or service, not IICP. If asked what IICP is or stands for, use this definition. IICP does not mean Industrial Internet of Things Computing. Use only supplied runtime facts and do not guess missing facts.";
8
19
  export class RuntimeIdentityContextUnsupported extends Error {
9
20
  constructor() {
10
21
  super("required_identity_context_unsupported");
package/dist/version.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export declare const BROWSER_NODE_VERSION = "0.2.5";
1
+ export declare const BROWSER_NODE_VERSION = "0.2.6";
2
2
  export declare const BROWSER_NODE_SDK_COMPATIBILITY_VERSION = "0.7.102";
3
3
  /** Backward-compatible registration value for directories that know only sdk_version. */
4
4
  export declare const BROWSER_NODE_SDK_VERSION = "0.7.102";
package/dist/version.js CHANGED
@@ -1,7 +1,7 @@
1
1
  // Browser implementation and IICP SDK-compatibility versions are separate axes.
2
2
  // Keep package.json synchronized with BROWSER_NODE_VERSION; the quality gate
3
3
  // rejects drift. SDK compatibility describes the registration contract only.
4
- export const BROWSER_NODE_VERSION = "0.2.5";
4
+ export const BROWSER_NODE_VERSION = "0.2.6";
5
5
  export const BROWSER_NODE_SDK_COMPATIBILITY_VERSION = "0.7.102";
6
6
  /** Backward-compatible registration value for directories that know only sdk_version. */
7
7
  export const BROWSER_NODE_SDK_VERSION = BROWSER_NODE_SDK_COMPATIBILITY_VERSION;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@iicp/web-node",
3
- "version": "0.2.5",
3
+ "version": "0.2.6",
4
4
  "description": "Browser-native IICP node (consume + serve): discovery-mesh client with mandatory E2E encryption (IICP-CX) + WebLLM provider. Zero-config, ESM.",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",