apex-code 0.0.1-alpha.6 → 0.0.1-alpha.7

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.
Files changed (29) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/dist/core/agent-session.d.ts +17 -0
  3. package/dist/core/agent-session.d.ts.map +1 -1
  4. package/dist/core/agent-session.js +28 -0
  5. package/dist/core/agent-session.js.map +1 -1
  6. package/dist/core/permissions/gate.d.ts +7 -0
  7. package/dist/core/permissions/gate.d.ts.map +1 -1
  8. package/dist/core/permissions/gate.js.map +1 -1
  9. package/dist/core/permissions/startup.d.ts +12 -0
  10. package/dist/core/permissions/startup.d.ts.map +1 -1
  11. package/dist/core/permissions/startup.js +12 -4
  12. package/dist/core/permissions/startup.js.map +1 -1
  13. package/dist/main.d.ts.map +1 -1
  14. package/dist/main.js +1 -0
  15. package/dist/main.js.map +1 -1
  16. package/dist/modes/interactive/components/footer.d.ts +3 -0
  17. package/dist/modes/interactive/components/footer.d.ts.map +1 -1
  18. package/dist/modes/interactive/components/footer.js +13 -0
  19. package/dist/modes/interactive/components/footer.js.map +1 -1
  20. package/dist/modes/interactive/components/settings-selector.d.ts +13 -0
  21. package/dist/modes/interactive/components/settings-selector.d.ts.map +1 -1
  22. package/dist/modes/interactive/components/settings-selector.js +96 -0
  23. package/dist/modes/interactive/components/settings-selector.js.map +1 -1
  24. package/dist/modes/interactive/interactive-mode.d.ts +11 -0
  25. package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
  26. package/dist/modes/interactive/interactive-mode.js +62 -3
  27. package/dist/modes/interactive/interactive-mode.js.map +1 -1
  28. package/npm-shrinkwrap.json +5 -5
  29. package/package.json +2 -2
@@ -34,6 +34,7 @@ import { emitSessionShutdownEvent } from "./extensions/runner.js";
34
34
  import { ModelRegistry } from "./model-registry.js";
35
35
  import { evaluateToolCall } from "./permissions/gate.js";
36
36
  import { createInteractiveResponder } from "./permissions/responder.js";
37
+ import { resolveEffectiveModeWithOrigin } from "./permissions/startup.js";
37
38
  import { expandPromptTemplate } from "./prompt-templates.js";
38
39
  import { CURRENT_SESSION_VERSION, getLatestCompactionEntry, TODO_CUSTOM_ENTRY_TYPE, } from "./session-manager.js";
39
40
  import { slugifySkillCommandName } from "./skills.js";
@@ -1296,6 +1297,33 @@ export class AgentSession {
1296
1297
  source,
1297
1298
  });
1298
1299
  }
1300
+ /** True when this session runs behind a permission gate at all. */
1301
+ get hasPermissionGate() {
1302
+ return this._permissionGate !== undefined;
1303
+ }
1304
+ /**
1305
+ * The mode in force right now, and which source won. `getMode` in the gate
1306
+ * config re-reads the store on every decision, so a mode written here applies
1307
+ * to the next tool call with no restart.
1308
+ */
1309
+ async getPermissionMode() {
1310
+ if (!this._permissionGate)
1311
+ return undefined;
1312
+ const snapshot = await this._permissionGate.store.snapshot();
1313
+ return resolveEffectiveModeWithOrigin(this._permissionGate.flagMode, snapshot.modesBySource);
1314
+ }
1315
+ /**
1316
+ * Persist a permission mode to user scope (`~/.apex-code/agent/permissions.json`).
1317
+ * Returns the resolution that is actually in force afterwards, which is *not*
1318
+ * necessarily `mode`: `flag`, `local`, and `project` all outrank `user`, so the
1319
+ * caller has to be able to tell the user their choice was recorded but shadowed.
1320
+ */
1321
+ async setPermissionMode(mode) {
1322
+ if (!this._permissionGate)
1323
+ return undefined;
1324
+ await this._permissionGate.store.apply({ type: "setMode", destination: "user", mode });
1325
+ return this.getPermissionMode();
1326
+ }
1299
1327
  /**
1300
1328
  * Set model directly.
1301
1329
  * Validates that auth is configured, saves to session and settings.