@akasecurity/ai-tc-codex 0.9.18 → 0.9.19

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.
@@ -23171,6 +23171,31 @@ var DeviceCommandAckBody = external_exports.discriminatedUnion("outcome", [
23171
23171
  projectsScanned: external_exports.number().int().nonnegative()
23172
23172
  }).strict()
23173
23173
  ]);
23174
+ var SIGHTING_KEY_MATERIAL = /^[A-Za-z0-9_-]{42}[AEIMQUYcgkosw048]$/;
23175
+ var sightingKeyMaterial = external_exports.string().regex(SIGHTING_KEY_MATERIAL, "must be the base64url encoding of exactly 32 bytes");
23176
+ var sightingKeyVersion = external_exports.number().int().min(1);
23177
+ var SightingKeyVersion = external_exports.object({
23178
+ keyVersion: sightingKeyVersion,
23179
+ key: sightingKeyMaterial
23180
+ });
23181
+ var SightingKeyResponse = external_exports.object({
23182
+ keyVersion: sightingKeyVersion,
23183
+ algorithm: external_exports.literal("hmac-sha256"),
23184
+ key: sightingKeyMaterial,
23185
+ previous: external_exports.array(SightingKeyVersion).optional()
23186
+ }).refine(
23187
+ (body) => {
23188
+ const versions = [body.keyVersion, ...(body.previous ?? []).map((p) => p.keyVersion)];
23189
+ return new Set(versions).size === versions.length;
23190
+ },
23191
+ { message: "key versions must be distinct", path: ["previous"] }
23192
+ );
23193
+ var StoredSightingKeys = SightingKeyResponse.and(
23194
+ external_exports.object({
23195
+ fetchedAtMs: external_exports.number().int().nonnegative(),
23196
+ endpointFingerprint: external_exports.string().regex(/^[0-9a-f]{64}$/)
23197
+ })
23198
+ );
23174
23199
 
23175
23200
  // ../../packages/schema/src/zod/registry.ts
23176
23201
  var Namespace = external_exports.string().regex(/^[a-z][a-z0-9-]*$/);
@@ -25161,6 +25186,26 @@ var ManagedSettings = external_exports.object({
25161
25186
  };
25162
25187
  }).meta({ id: "ManagedSettings" });
25163
25188
 
25189
+ // ../../packages/schema/src/zod/mod-finding.ts
25190
+ var MOD_FINDINGS_MAX_BYTES = 4 * 1024 * 1024;
25191
+ var ModFindingAction = external_exports.enum(["redacted", "vaulted", "blocked", "warned", "logged"]).meta({ id: "ModFindingAction" });
25192
+ var ModFindingWhere = external_exports.enum(["prompt", "attachment", "tool-input", "tool-output", "memory", "subagent"]).meta({ id: "ModFindingWhere" });
25193
+ var ModFinding = external_exports.strictObject({
25194
+ v: external_exports.literal(1),
25195
+ id: external_exports.string().regex(/^[0-9a-f]{16}$/),
25196
+ at: external_exports.iso.datetime(),
25197
+ ruleId: external_exports.string().min(1),
25198
+ shortName: external_exports.string().min(1).max(64).optional(),
25199
+ category: DetectionCategory,
25200
+ severity: Severity,
25201
+ action: ModFindingAction,
25202
+ where: ModFindingWhere,
25203
+ pointer: external_exports.string().regex(POINTER_TOKEN_ANCHORED).optional()
25204
+ }).refine((f) => f.action === "vaulted" === (f.pointer !== void 0), {
25205
+ path: ["pointer"],
25206
+ message: "pointer is present only for a vaulted finding, and a vaulted finding has one"
25207
+ }).meta({ id: "ModFinding" });
25208
+
25164
25209
  // ../../packages/schema/src/zod/mod-policy-snapshot.ts
25165
25210
  var MOD_POLICY_SNAPSHOT_VERSION = 1;
25166
25211
  var MOD_POLICY_SNAPSHOT_MAX_BYTES = 4 * 1024 * 1024;
@@ -27948,12 +27993,21 @@ var TIMELINE_COLUMNS = `
27948
27993
  json_extract(attributes, '$.targetId') AS target_id,
27949
27994
  json_extract(attributes, '$.internal') AS internal,
27950
27995
  json_extract(attributes, '$.flagged') AS flagged`;
27996
+ var CALL_WRITE_SPLIT = `(coalesce(ephemeral_1h_input_tokens, 0) + coalesce(ephemeral_5m_input_tokens, 0))`;
27951
27997
  var CALL_PROMPT_TOKENS = `(coalesce(input_tokens, 0) + coalesce(cache_read_input_tokens, 0)
27952
- + max(coalesce(cache_creation_input_tokens, 0),
27953
- coalesce(ephemeral_1h_input_tokens, 0) + coalesce(ephemeral_5m_input_tokens, 0)))`;
27954
- var CALL_BAND = LONG_CONTEXT_THRESHOLDS.length === 0 ? "0" : LONG_CONTEXT_THRESHOLDS.map((t) => `(${CALL_PROMPT_TOKENS} > ${String(Math.trunc(t))})`).join(
27955
- " + "
27998
+ + max(coalesce(cache_creation_input_tokens, 0), ${CALL_WRITE_SPLIT}))`;
27999
+ var CALL_BAND = LONG_CONTEXT_THRESHOLDS.map(
28000
+ (t) => `(${CALL_PROMPT_TOKENS} > ${String(Math.trunc(t))})`
27956
28001
  );
28002
+ var CALL_USAGE_SHAPE = [
28003
+ "coalesce(input_tokens, 0) > 0",
28004
+ "coalesce(output_tokens, 0) > 0",
28005
+ "coalesce(cache_read_input_tokens, 0) > 0",
28006
+ "coalesce(ephemeral_1h_input_tokens, 0) > 0",
28007
+ "coalesce(ephemeral_5m_input_tokens, 0) > 0",
28008
+ `coalesce(cache_creation_input_tokens, 0) > ${CALL_WRITE_SPLIT}`,
28009
+ "coalesce(web_search_requests, 0) > 0"
28010
+ ].map((condition) => `(${condition})`);
27957
28011
  var LLM_USAGE_SELECT = `
27958
28012
  SELECT root_session_id AS sessionId,
27959
28013
  provider,
@@ -27968,7 +28022,14 @@ var LLM_USAGE_SELECT = `
27968
28022
  coalesce(sum(web_search_requests), 0) AS webSearchRequests,
27969
28023
  coalesce(max(${CALL_PROMPT_TOKENS}), 0) AS promptTokens`;
27970
28024
  var LLM_USAGE_SCOPE = `event_type = 'llm_call' AND attributes IS NOT NULL AND root_session_id IS NOT NULL`;
27971
- var LLM_USAGE_GROUP = `GROUP BY root_session_id, provider, model, service_tier, ${CALL_BAND}`;
28025
+ var LLM_USAGE_GROUP = `GROUP BY ${[
28026
+ "root_session_id",
28027
+ "provider",
28028
+ "model",
28029
+ "service_tier",
28030
+ ...CALL_BAND.length === 0 ? [] : [CALL_BAND.join(" + ")],
28031
+ ...CALL_USAGE_SHAPE
28032
+ ].join(", ")}`;
27972
28033
  function usageLeaves(rows) {
27973
28034
  return rows.map((row) => {
27974
28035
  const attributes = {
@@ -28254,7 +28315,9 @@ var SqliteActivityRepository = class {
28254
28315
  * store carries, since opening runs the migrations, so the hard requirement
28255
28316
  * `INDEXED BY` introduces is already met; token-rollup-plans.test.ts pins
28256
28317
  * the plan. All-time is a scan of the whole index — still one narrow entry
28257
- * per call, no bag parsed.
28318
+ * per call, no bag parsed. The usage-shape terms in the key cost the
28319
+ * all-time read ~9 ms at 50k calls (34 → 43 ms, fastest of the run), against
28320
+ * 68 ms for folding the bags in JS.
28258
28321
  */
28259
28322
  tokenReports(fromMs) {
28260
28323
  const rows = allRows(
@@ -28269,8 +28332,8 @@ var SqliteActivityRepository = class {
28269
28332
  return Promise.resolve(buildTokenReports(usageLeaves(rows), defaultCostModel));
28270
28333
  }
28271
28334
  /**
28272
- * One session's token report — its `llm_call`s grouped per (provider,
28273
- * model, tier) with derived cost, or `null` when the session made no
28335
+ * One session's token report — its `llm_call`s grouped as `tokenReports`
28336
+ * groups them (see LlmUsageRow) with derived cost, or `null` when the session made no
28274
28337
  * `llm_call`s (an empty/tool-only session). Feeds the session-detail pane's
28275
28338
  * per-model breakdown + estimated cost. The same rollup as `tokenReports`,
28276
28339
  * seeking one root through a root-led `llm_call` index; the bag-reading fold
@@ -35294,21 +35357,27 @@ import {
35294
35357
  createDecipheriv,
35295
35358
  createHmac as createHmac2,
35296
35359
  hkdfSync,
35360
+ randomBytes as randomBytes2,
35297
35361
  timingSafeEqual
35298
35362
  } from "crypto";
35299
35363
 
35300
35364
  // ../../packages/persistence/src/vault/key-provider.ts
35301
35365
  import { execFileSync } from "child_process";
35302
- import { randomBytes as randomBytes2 } from "crypto";
35366
+ import { randomBytes as randomBytes3 } from "crypto";
35303
35367
  import { chmodSync as chmodSync3, readFileSync as readFileSync10, renameSync as renameSync4, rmSync as rmSync6, statSync as statSync5, writeFileSync as writeFileSync3 } from "fs";
35304
35368
  import { join as join15 } from "path";
35305
35369
 
35370
+ // ../../packages/persistence/src/vault/sighting-keys.ts
35371
+ import { createHash as createHash6 } from "crypto";
35372
+ import { readFileSync as readFileSync11, rmSync as rmSync7 } from "fs";
35373
+ import { join as join16 } from "path";
35374
+
35306
35375
  // ../../packages/persistence/src/vault/vault.ts
35307
- import { randomBytes as randomBytes3, randomUUID as randomUUID12 } from "crypto";
35376
+ import { randomBytes as randomBytes4, randomUUID as randomUUID12 } from "crypto";
35308
35377
 
35309
35378
  // ../../packages/persistence/src/warn-era-cap.ts
35310
35379
  import { existsSync as existsSync7, writeFileSync as writeFileSync4 } from "fs";
35311
- import { join as join16 } from "path";
35380
+ import { join as join17 } from "path";
35312
35381
 
35313
35382
  // ../../packages/remote/src/http.ts
35314
35383
  import { request as httpRequest } from "http";
@@ -35468,7 +35537,8 @@ var ROUTES = {
35468
35537
  policyBundle: "/v1/policy-bundle",
35469
35538
  whoami: "/v1/plugin/whoami",
35470
35539
  shares: "/v1/shares",
35471
- commands: "/v1/plugin/commands"
35540
+ commands: "/v1/plugin/commands",
35541
+ sightingKey: "/v1/sighting-key"
35472
35542
  };
35473
35543
  function ackRoute(id) {
35474
35544
  return `${ROUTES.commands}/${encodeURIComponent(id)}/ack`;
@@ -35615,6 +35685,11 @@ function createRemoteClient(options) {
35615
35685
  body: JSON.stringify(validated.data)
35616
35686
  });
35617
35687
  okBody(response);
35688
+ },
35689
+ async getSightingKey() {
35690
+ const response = await send({ ...common, method: "GET", url: url2(ROUTES.sightingKey) });
35691
+ if (response.status === 404) throw new RemoteRouteAbsent(ROUTES.sightingKey);
35692
+ return parsed(SightingKeyResponse, okBody(response), ROUTES.sightingKey);
35618
35693
  }
35619
35694
  };
35620
35695
  }
@@ -35623,13 +35698,13 @@ function createRemoteClient(options) {
35623
35698
  var REQUEST_TIMEOUT_MS = 2e3;
35624
35699
 
35625
35700
  // ../../packages/plugin-runtime/src/attached/forward-drops.ts
35626
- import { readFileSync as readFileSync11 } from "fs";
35627
- import { join as join17 } from "path";
35701
+ import { readFileSync as readFileSync12 } from "fs";
35702
+ import { join as join18 } from "path";
35628
35703
 
35629
35704
  // ../../packages/plugin-runtime/src/attached/forward-policy.ts
35630
35705
  import { randomUUID as randomUUID13 } from "crypto";
35631
35706
  import { readFile, rename, writeFile } from "fs/promises";
35632
- import { join as join18 } from "path";
35707
+ import { join as join19 } from "path";
35633
35708
 
35634
35709
  // ../../packages/plugin-runtime/src/attached/scope-strip.ts
35635
35710
  function withoutScopeKey(event) {
@@ -35654,7 +35729,7 @@ function withScopedRepo(event, scopeKey) {
35654
35729
  }
35655
35730
 
35656
35731
  // ../../packages/plugin-runtime/src/attached/history-sync.ts
35657
- import { createHash as createHash6 } from "crypto";
35732
+ import { createHash as createHash7 } from "crypto";
35658
35733
  import { hostname as hostname4 } from "os";
35659
35734
 
35660
35735
  // ../../packages/plugin-runtime/src/attached/capture-rebuild.ts
@@ -35868,7 +35943,7 @@ function underByteCeiling(ready) {
35868
35943
  var STRUCTURAL_BUDGET_SHARE = 0.7;
35869
35944
  var BATCH_SIZE = AUDIT_EVENT_BATCH_MAX;
35870
35945
  function endpointFingerprint(endpoint) {
35871
- return createHash6("sha256").update(endpoint).digest("hex");
35946
+ return createHash7("sha256").update(endpoint).digest("hex");
35872
35947
  }
35873
35948
  var didNotRun = (reason) => ({
35874
35949
  attempted: false,
@@ -36396,16 +36471,16 @@ var HISTORY_SYNC_THROTTLE_MS = 5 * 60 * 1e3;
36396
36471
 
36397
36472
  // ../../packages/plugin-runtime/src/attached/install-record.ts
36398
36473
  import { readFile as readFile2, stat } from "fs/promises";
36399
- import { basename as basename2, dirname as dirname4, join as join19, resolve as resolve2 } from "path";
36474
+ import { basename as basename2, dirname as dirname4, join as join20, resolve as resolve2 } from "path";
36400
36475
 
36401
36476
  // ../../packages/plugin-runtime/src/attached/plugin-block.ts
36402
- import { readFileSync as readFileSync12 } from "fs";
36477
+ import { readFileSync as readFileSync13 } from "fs";
36403
36478
  var INSTALL_RECORD_READ_TIMEOUT_MS = REQUEST_TIMEOUT_MS / 2;
36404
36479
 
36405
36480
  // ../../packages/plugin-runtime/src/attached/policy-store.ts
36406
36481
  import { randomUUID as randomUUID14 } from "crypto";
36407
36482
  import { readFile as readFile3, rm, writeFile as writeFile2 } from "fs/promises";
36408
- import { join as join20 } from "path";
36483
+ import { join as join21 } from "path";
36409
36484
 
36410
36485
  // ../../packages/plugin-runtime/src/attached/atomic-publish.ts
36411
36486
  import { rename as rename2 } from "fs/promises";
@@ -36414,8 +36489,8 @@ var TIMED_RETRIES = 4;
36414
36489
  var ATTEMPTS = 1 + IMMEDIATE_RETRIES + TIMED_RETRIES;
36415
36490
 
36416
36491
  // ../../packages/plugin-runtime/src/attached/posture-report-state.ts
36417
- import { readFileSync as readFileSync13 } from "fs";
36418
- import { join as join21 } from "path";
36492
+ import { readFileSync as readFileSync14 } from "fs";
36493
+ import { join as join22 } from "path";
36419
36494
  var OUTCOME_KEYS = {
36420
36495
  ok: true,
36421
36496
  unauthorized: true,
@@ -36438,11 +36513,11 @@ import { DatabaseSync as DatabaseSync3 } from "node:sqlite";
36438
36513
  // ../../packages/plugin-runtime/src/attached/posture-store.ts
36439
36514
  import { randomUUID as randomUUID15 } from "crypto";
36440
36515
  import { readFile as readFile4, rm as rm2, writeFile as writeFile3 } from "fs/promises";
36441
- import { join as join22 } from "path";
36516
+ import { join as join23 } from "path";
36442
36517
 
36443
36518
  // ../../packages/plugin-runtime/src/attached/sync-state.ts
36444
- import { readFileSync as readFileSync14 } from "fs";
36445
- import { join as join23 } from "path";
36519
+ import { readFileSync as readFileSync15 } from "fs";
36520
+ import { join as join24 } from "path";
36446
36521
 
36447
36522
  // ../../packages/plugin-runtime/src/attached/status.ts
36448
36523
  var REFUSAL_LINES = {
@@ -36458,6 +36533,9 @@ var OUTCOME_LINES = {
36458
36533
  "invalid-bundle": "control plane sent a policy bundle this build cannot read"
36459
36534
  };
36460
36535
 
36536
+ // ../../packages/plugin-runtime/src/attached/sighting-key-sync.ts
36537
+ var SIGHTING_KEY_MAX_AGE_MS = 24 * 60 * 60 * 1e3;
36538
+
36461
36539
  // ../../packages/plugin-runtime/src/attached/sync-trigger.ts
36462
36540
  import { spawn as spawn2 } from "child_process";
36463
36541
  import { fileURLToPath as fileURLToPath2 } from "url";
package/scripts/intro.js CHANGED
@@ -22779,6 +22779,31 @@ var DeviceCommandAckBody = external_exports.discriminatedUnion("outcome", [
22779
22779
  projectsScanned: external_exports.number().int().nonnegative()
22780
22780
  }).strict()
22781
22781
  ]);
22782
+ var SIGHTING_KEY_MATERIAL = /^[A-Za-z0-9_-]{42}[AEIMQUYcgkosw048]$/;
22783
+ var sightingKeyMaterial = external_exports.string().regex(SIGHTING_KEY_MATERIAL, "must be the base64url encoding of exactly 32 bytes");
22784
+ var sightingKeyVersion = external_exports.number().int().min(1);
22785
+ var SightingKeyVersion = external_exports.object({
22786
+ keyVersion: sightingKeyVersion,
22787
+ key: sightingKeyMaterial
22788
+ });
22789
+ var SightingKeyResponse = external_exports.object({
22790
+ keyVersion: sightingKeyVersion,
22791
+ algorithm: external_exports.literal("hmac-sha256"),
22792
+ key: sightingKeyMaterial,
22793
+ previous: external_exports.array(SightingKeyVersion).optional()
22794
+ }).refine(
22795
+ (body) => {
22796
+ const versions = [body.keyVersion, ...(body.previous ?? []).map((p) => p.keyVersion)];
22797
+ return new Set(versions).size === versions.length;
22798
+ },
22799
+ { message: "key versions must be distinct", path: ["previous"] }
22800
+ );
22801
+ var StoredSightingKeys = SightingKeyResponse.and(
22802
+ external_exports.object({
22803
+ fetchedAtMs: external_exports.number().int().nonnegative(),
22804
+ endpointFingerprint: external_exports.string().regex(/^[0-9a-f]{64}$/)
22805
+ })
22806
+ );
22782
22807
 
22783
22808
  // ../../packages/schema/src/zod/registry.ts
22784
22809
  var Namespace = external_exports.string().regex(/^[a-z][a-z0-9-]*$/);
@@ -23988,6 +24013,26 @@ var ManagedSettings = external_exports.object({
23988
24013
  };
23989
24014
  }).meta({ id: "ManagedSettings" });
23990
24015
 
24016
+ // ../../packages/schema/src/zod/mod-finding.ts
24017
+ var MOD_FINDINGS_MAX_BYTES = 4 * 1024 * 1024;
24018
+ var ModFindingAction = external_exports.enum(["redacted", "vaulted", "blocked", "warned", "logged"]).meta({ id: "ModFindingAction" });
24019
+ var ModFindingWhere = external_exports.enum(["prompt", "attachment", "tool-input", "tool-output", "memory", "subagent"]).meta({ id: "ModFindingWhere" });
24020
+ var ModFinding = external_exports.strictObject({
24021
+ v: external_exports.literal(1),
24022
+ id: external_exports.string().regex(/^[0-9a-f]{16}$/),
24023
+ at: external_exports.iso.datetime(),
24024
+ ruleId: external_exports.string().min(1),
24025
+ shortName: external_exports.string().min(1).max(64).optional(),
24026
+ category: DetectionCategory,
24027
+ severity: Severity,
24028
+ action: ModFindingAction,
24029
+ where: ModFindingWhere,
24030
+ pointer: external_exports.string().regex(POINTER_TOKEN_ANCHORED).optional()
24031
+ }).refine((f) => f.action === "vaulted" === (f.pointer !== void 0), {
24032
+ path: ["pointer"],
24033
+ message: "pointer is present only for a vaulted finding, and a vaulted finding has one"
24034
+ }).meta({ id: "ModFinding" });
24035
+
23991
24036
  // ../../packages/schema/src/zod/mod-policy-snapshot.ts
23992
24037
  var MOD_POLICY_SNAPSHOT_VERSION = 1;
23993
24038
  var MOD_POLICY_SNAPSHOT_MAX_BYTES = 4 * 1024 * 1024;