@kaoruisaac/pedelec 0.1.15 → 0.1.16

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
@@ -143,6 +143,8 @@ const assets = await session.listAssets();
143
143
 
144
144
  The first time an origin calls `createSession()` or `resumeSession()`, the extension asks the user to approve that origin in the popup. After approval, the same origin can create sessions directly.
145
145
 
146
+ Sessions created through the SDK are bound to the creating origin. The same origin may resume them after reload, in another tab, or from another SDK instance; a different scheme, host, subdomain, or port cannot use the ID. A `sessionId` is an identifier, not a cross-origin bearer credential, and applications cannot supply or override its owner origin.
147
+
146
148
  You can query the current origin's approval status first to decide whether to show UI such as "Connect Pedelec":
147
149
 
148
150
  ```ts
@@ -151,7 +153,11 @@ const status = await pedelec.getApprovalStatus();
151
153
  console.log(status.installed, status.approved, status.origin);
152
154
  ```
153
155
 
154
- For a complete Extension, approval, and Desktop readiness probe, use `checkAvailability()`. It never creates/resumes a session or opens approval. When approved it validates Desktop by calling `getSettings()`, which may invoke the existing Native Host auto-launch fallback.
156
+ `getApprovalStatus()` includes `appConnected`, a non-sensitive Core `ping` result. It does not require approval or open the approval popup, but it may use the Native Host's existing Desktop auto-launch fallback. `appConnected` does not mean the origin is approved or a provider is ready.
157
+
158
+ `getSettings()` and `listProviders()` require origin approval and may open the approval popup. Settings expose only defaults (never provider credentials); providers expose only `name`, `code`, `available`, and `error`. Use `getApprovalStatus().appConnected` rather than `listProviders()` as a connection probe.
159
+
160
+ For a complete Extension, approval, and Desktop readiness probe, use `checkAvailability()`. It never creates/resumes a session or opens approval. Its status ping may attempt Desktop launch even for an unapproved origin.
155
161
 
156
162
  ```ts
157
163
  const availability = await pedelec.checkAvailability();
package/dist/index.d.ts CHANGED
@@ -97,7 +97,6 @@ export type CreateSessionInput<TTools extends readonly ToolDefinition[] = readon
97
97
  export type ProviderInfo = {
98
98
  name: string;
99
99
  code: ProviderCode;
100
- path: string | null;
101
100
  available: boolean;
102
101
  error: string | null;
103
102
  };
@@ -109,6 +108,7 @@ export type ApprovalStatus = {
109
108
  installed: boolean;
110
109
  approved: boolean;
111
110
  origin: string | null;
111
+ appConnected: boolean;
112
112
  };
113
113
  export type PedelecAvailability = {
114
114
  available: boolean;
package/dist/index.js CHANGED
@@ -147,15 +147,10 @@ export class Pedelec {
147
147
  return this.registerSession(result.sessionId, resolvedInput.provider, resolvedInput.model, resolvedInput.inlineToolHandlers);
148
148
  }
149
149
  async listProviders() {
150
- const result = await this.request("list_providers");
151
- if (!Array.isArray(result)) {
152
- throw makeError("SDK_PROTOCOL_ERROR", "list_providers response was not an array");
153
- }
154
- return result;
150
+ return normalizeProviderInfoList(await this.request("list_providers"));
155
151
  }
156
152
  async getSettings() {
157
- const result = await this.request("get_settings");
158
- return result;
153
+ return normalizePedelecSettings(await this.request("get_settings"));
159
154
  }
160
155
  async getApprovalStatus() {
161
156
  if (this.disconnectedError) {
@@ -163,13 +158,11 @@ export class Pedelec {
163
158
  installed: false,
164
159
  approved: false,
165
160
  origin: getCurrentOrigin(this.pageWindow),
161
+ appConnected: false,
166
162
  };
167
163
  }
168
164
  try {
169
165
  const result = await this.request("get_approval_status");
170
- if (!isApprovalStatus(result)) {
171
- throw makeError("SDK_PROTOCOL_ERROR", "get_approval_status response had invalid shape");
172
- }
173
166
  return result;
174
167
  }
175
168
  catch (err) {
@@ -179,6 +172,7 @@ export class Pedelec {
179
172
  installed: false,
180
173
  approved: false,
181
174
  origin: getCurrentOrigin(this.pageWindow),
175
+ appConnected: false,
182
176
  };
183
177
  }
184
178
  throw error;
@@ -287,7 +281,7 @@ export class Pedelec {
287
281
  available: false,
288
282
  extension: { available: true },
289
283
  approval: { approved: false, origin: approval.origin },
290
- desktop: { available: false, launchAttempted: false },
284
+ desktop: { available: approval.appConnected, launchAttempted: true },
291
285
  };
292
286
  }
293
287
  try {
@@ -894,13 +888,38 @@ function isSessionEvent(message) {
894
888
  message.type === "error" ||
895
889
  message.type === "ended");
896
890
  }
897
- function isApprovalStatus(value) {
898
- if (!value || typeof value !== "object")
899
- return false;
900
- const status = value;
901
- return (typeof status.installed === "boolean" &&
902
- typeof status.approved === "boolean" &&
903
- (status.origin === null || typeof status.origin === "string"));
891
+ function isProviderCode(value) {
892
+ return value === "codex" || value === "antigravity" || value === "opencode" ||
893
+ value === "cursor" || value === "claude" || value === "ollama";
894
+ }
895
+ function isPlainObject(value) {
896
+ return !!value && typeof value === "object" && !Array.isArray(value);
897
+ }
898
+ function normalizePedelecSettings(value) {
899
+ if (!isPlainObject(value) || (value.defaultProvider !== null && !isProviderCode(value.defaultProvider)) ||
900
+ !isPlainObject(value.defaultModels)) {
901
+ throw makeError("SDK_PROTOCOL_ERROR", "get_settings response had invalid shape");
902
+ }
903
+ const defaultModels = {};
904
+ for (const [code, model] of Object.entries(value.defaultModels)) {
905
+ if (!isProviderCode(code) || typeof model !== "string") {
906
+ throw makeError("SDK_PROTOCOL_ERROR", "get_settings response had invalid shape");
907
+ }
908
+ defaultModels[code] = model;
909
+ }
910
+ return { defaultProvider: value.defaultProvider, defaultModels };
911
+ }
912
+ function normalizeProviderInfoList(value) {
913
+ if (!Array.isArray(value))
914
+ throw makeError("SDK_PROTOCOL_ERROR", "list_providers response was not an array");
915
+ return value.map((item) => {
916
+ if (!isPlainObject(item) || typeof item.name !== "string" || item.name.length === 0 ||
917
+ !isProviderCode(item.code) || typeof item.available !== "boolean" ||
918
+ (item.error !== null && typeof item.error !== "string")) {
919
+ throw makeError("SDK_PROTOCOL_ERROR", "list_providers response had invalid provider data");
920
+ }
921
+ return { name: item.name, code: item.code, available: item.available, error: item.error };
922
+ });
904
923
  }
905
924
  function makeError(code, message, details) {
906
925
  return details === undefined ? { code, message } : { code, message, details };
@@ -103,11 +103,24 @@ async function availabilityHasPublicType() {
103
103
  void availability;
104
104
  void promise;
105
105
  }
106
+ function publicSecurityTypesAreRestricted() {
107
+ const status = {
108
+ installed: true,
109
+ approved: true,
110
+ origin: "https://app.example.test",
111
+ appConnected: true,
112
+ };
113
+ const provider = {};
114
+ // @ts-expect-error SDK provider metadata must not expose executable paths
115
+ provider.path;
116
+ return status;
117
+ }
106
118
  void typedOnToolNameFromCreateSession;
107
119
  void resumedSessionFallsBackToString;
108
120
  void noSkillsFallsBackToString;
109
121
  void listAssetsHasPublicTypes;
110
122
  void availabilityHasPublicType;
123
+ void publicSecurityTypesAreRestricted;
111
124
  const baseContext = {
112
125
  sessionId: "thread_1",
113
126
  provider: "codex",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kaoruisaac/pedelec",
3
- "version": "0.1.15",
3
+ "version": "0.1.16",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",