@kosuke-ai/kosuke 1.0.73 → 1.0.74

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/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.0.74
4
+
5
+ - Show your own time in `kosuke agent summary get` and count `user usage get` and `workspaces usage breakdown get` days in your own timezone unless `--tz` is passed. Other JSON stays ISO UTC.
6
+
3
7
  ## 1.0.73
4
8
 
5
9
  - A Mac that cannot read its Screen Recording permission now reports it as unknown, not off, and a permission granted in System Settings takes effect within 20 seconds without quitting the app. The app never starts a screen helper from an update installed while it runs.
@@ -2,6 +2,7 @@ import { providers } from '../generated/providers.js';
2
2
  import { readOverview } from '../integrations/api.js';
3
3
  import { createApiClient } from '../runtime/client.js';
4
4
  import { isTurnToken } from '../runtime/credentials.js';
5
+ import { localStamp, readMemberTimeZone, } from '../runtime/member-time-zone.js';
5
6
  import { HttpError, paginationTotal } from './http.js';
6
7
  /**
7
8
  * `kosuke agent summary`: which providers and integrations are connected and what is
@@ -281,6 +282,16 @@ function integrationLine(toolkit, connection) {
281
282
  const identity = clip(connection.accountIdentity ?? 'account unknown', NAME_MAX);
282
283
  return `- ${clip(toolkit, NAME_MAX)}: ${connection.alias}, ${connection.scope}, "${label}", ${identity}`;
283
284
  }
285
+ /**
286
+ * `2026-11-05 09:12 Europe/Rome`, the member's own wall clock: Sensei repeats it to them. UTC,
287
+ * saying why, when their zone could not be read or Kosuke knows none for them.
288
+ */
289
+ function headerStamp(now, zone) {
290
+ if (!zone)
291
+ return `${localStamp(now, 'UTC')} (your timezone could not be read)`;
292
+ const stamp = localStamp(now, zone.timeZone);
293
+ return zone.guessed ? `${stamp} (no timezone known for you)` : stamp;
294
+ }
284
295
  /** Never clipped: a workspace missing here would read as one the digest did not cover. */
285
296
  function coverageLine(read) {
286
297
  const covered = read?.meta?.workspaces;
@@ -293,8 +304,7 @@ function coverageLine(read) {
293
304
  export function planSummary(options) {
294
305
  const { covered, apiUrl, now, workspace, peek = false } = options;
295
306
  const scope = workspace ? ` --workspace ${workspace}` : '';
296
- const stamp = new Date(now).toISOString().slice(0, 16).replace('T', ' ') + ' UTC';
297
- const head = [`Sensei summary, ${stamp}, ${apiUrl}`, ''];
307
+ const head = [`Sensei summary, ${headerStamp(now, options.timeZone ?? null)}, ${apiUrl}`, ''];
298
308
  if (options.providers?.length)
299
309
  head.push('Providers:', ...options.providers, '');
300
310
  if (options.integrations?.length) {
@@ -346,7 +356,7 @@ export function renderSummary(plan, activity) {
346
356
  }
347
357
  /**
348
358
  * The whole digest, or one line saying why not, so the agent reading it
349
- * knows to query the CLI itself. The coverage, the providers and the integrations are read first:
359
+ * knows to query the CLI itself. The coverage, the providers, the integrations and the member's timezone are read first:
350
360
  * their lines decide how many events fit, and the Activity read marks events
351
361
  * seen, so a digest that failed after it would lose them.
352
362
  */
@@ -361,18 +371,20 @@ export async function fetchSummary(options) {
361
371
  const signal = AbortSignal.timeout(options.timeoutMs ?? SUMMARY_TIMEOUT_MS);
362
372
  try {
363
373
  const workspace = options.workspace ? { workspace: options.workspace } : {};
364
- const [coverage, providers, integrations] = await Promise.all([
374
+ const [coverage, providers, integrations, timeZone] = await Promise.all([
365
375
  client.GET('/api/activity', {
366
376
  params: { query: { ...COVERAGE_QUERY, ...workspace } },
367
377
  signal,
368
378
  }),
369
379
  fetchProviders(client, options.workspace, AbortSignal.any([signal, AbortSignal.timeout(PROVIDERS_TIMEOUT_MS)])),
370
380
  fetchIntegrations(client, options.workspace, options.apiKey, AbortSignal.any([signal, AbortSignal.timeout(INTEGRATIONS_TIMEOUT_MS)])),
381
+ readMemberTimeZone(client, signal),
371
382
  ]);
372
383
  const plan = planSummary({
373
384
  covered: body(coverage),
374
385
  providers,
375
386
  integrations,
387
+ timeZone,
376
388
  apiUrl: options.apiUrl,
377
389
  now: (options.now ?? Date.now)(),
378
390
  ...workspace,
@@ -6,7 +6,7 @@ export const operation = {
6
6
  "usage",
7
7
  "get"
8
8
  ],
9
- "summary": "Read what used your AI work over range (7d by default, 30d or all) in calendar days of tz (an IANA time zone, UTC by default): totals and per-day counts, then rows grouped by work, repository and model, each with its Providers and busiest Chat Sessions or Sensei Threads (the top five by every count, so sort by the one you show). Counts your personal Subscription attempts and Sensei free Turns since recording began on 22 October 2026; days before it have recorded false and are never 0. turns counts every attempt; the four token counts are sums of reported counts only, never added together, with missing and inProgress counted apart. A repository or session in a workspace you no longer belong to keeps its counts but no name, title or link. Workspace Credentials and platform work are excluded. Your own sign-in or API key only; agent tokens are refused. 400 on another range or an unknown time zone.",
9
+ "summary": "Read what used your AI work over range (7d by default, 30d or all) in calendar days of tz (an IANA time zone, UTC by default; the kosuke CLI sends your own timezone): totals and per-day counts, then rows grouped by work, repository and model, each with its Providers and busiest Chat Sessions or Sensei Threads (the top five by every count, so sort by the one you show). Counts your personal Subscription attempts and Sensei free Turns since recording began on 22 October 2026; days before it have recorded false and are never 0. turns counts every attempt; the four token counts are sums of reported counts only, never added together, with missing and inProgress counted apart. A repository or session in a workspace you no longer belong to keeps its counts but no name, title or link. Workspace Credentials and platform work are excluded. Your own sign-in or API key only; agent tokens are refused. 400 on another range or an unknown time zone.",
10
10
  "pathParams": [],
11
11
  "query": [
12
12
  {
@@ -26,7 +26,7 @@ export const operation = {
26
26
  "flag": "tz",
27
27
  "kind": "string",
28
28
  "required": false,
29
- "description": "IANA time zone for calendar days. Default: UTC."
29
+ "description": "IANA time zone for calendar days. Default: UTC; the kosuke CLI sends your own timezone."
30
30
  }
31
31
  ],
32
32
  "body": null,
@@ -7,7 +7,7 @@ export const operation = {
7
7
  "breakdown",
8
8
  "get"
9
9
  ],
10
- "summary": "Read what used the workspace's Credentials over range (7d by default, 30d or all) in calendar days of tz (an IANA time zone, UTC by default): totals and per-day counts, then rows grouped by work, repository and model, each with its Providers and busiest Chat Sessions (the top five by every count, so sort by the one you show). Counts attempts run on the workspace's Credentials since recording began on 22 October 2026; days before it have recorded false and are never 0. turns counts every attempt; the four token counts are sums of reported counts only, never added together, with missing and inProgress counted apart. Members' own Subscriptions, Sensei, Sensei free and platform work are excluded. Owners and admins only. 400 on another range or an unknown time zone.",
10
+ "summary": "Read what used the workspace's Credentials over range (7d by default, 30d or all) in calendar days of tz (an IANA time zone, UTC by default; the kosuke CLI sends your own timezone): totals and per-day counts, then rows grouped by work, repository and model, each with its Providers and busiest Chat Sessions (the top five by every count, so sort by the one you show). Counts attempts run on the workspace's Credentials since recording began on 22 October 2026; days before it have recorded false and are never 0. turns counts every attempt; the four token counts are sums of reported counts only, never added together, with missing and inProgress counted apart. Members' own Subscriptions, Sensei, Sensei free and platform work are excluded. Owners and admins only. 400 on another range or an unknown time zone.",
11
11
  "pathParams": [
12
12
  "workspaceId"
13
13
  ],
@@ -29,7 +29,7 @@ export const operation = {
29
29
  "flag": "tz",
30
30
  "kind": "string",
31
31
  "required": false,
32
- "description": "IANA time zone for calendar days. Default: UTC."
32
+ "description": "IANA time zone for calendar days. Default: UTC; the kosuke CLI sends your own timezone."
33
33
  }
34
34
  ],
35
35
  "body": null,
package/dist/program.js CHANGED
@@ -38,6 +38,7 @@ export function createProgram(options = {}) {
38
38
  credentials: () => runtimeFor().credentials(),
39
39
  client: (o) => runtimeFor().client(o),
40
40
  output: (outcome) => runtimeFor().output(outcome),
41
+ notice: (line) => runtimeFor().notice?.(line),
41
42
  };
42
43
  attachAuthCommands(program, lazy, options.auth);
43
44
  // An agent's credential reaches what its member's API key does, less the
@@ -3,6 +3,7 @@ import { Argument, Command, InvalidArgumentError, Option } from 'commander';
3
3
  import { addsSessionIdFlag, CLI_ONLY_FLAGS, omitsProject, SESSION_ID_FLAG, sessionIdField, } from './arguments.js';
4
4
  import { setAfterHelp, setOptionShape, shortSummary, usageError } from './help.js';
5
5
  import { buildRequest, execute, readWholeBody, UsageError } from './invoke.js';
6
+ import { withMemberTimeZone } from './member-time-zone.js';
6
7
  import { PERSONAL_SPACE_PARAM } from './personal-space.js';
7
8
  import { personalSpaceId } from './personal-space-id.js';
8
9
  import { threadView, TOOLS_FLAG_HELP } from './thread-text.js';
@@ -320,6 +321,7 @@ async function run(leaf, runtime, operation, input, options = {}) {
320
321
  leaf.error(error.message);
321
322
  throw error;
322
323
  }
324
+ request = await withMemberTimeZone(runtime, operation, input, request);
323
325
  const client = runtime.client({
324
326
  anonymous: operation.anonymous,
325
327
  answerTimeoutMs: operation.answerTimeoutMs,
@@ -0,0 +1,82 @@
1
+ import { buildRequest } from './invoke.js';
2
+ /**
3
+ * The member's own timezone, for the few places the CLI prints time for a person to read:
4
+ * the `agent summary` header and the usage commands' calendar days. Everything else stays
5
+ * ISO UTC, which is what agents and scripts parse.
6
+ */
7
+ /** A slow settings read must cost the command its local time, never the command. */
8
+ const MEMBER_TIME_ZONE_TIMEOUT_MS = 3000;
9
+ /** The zone as Intl spells it, or null when Intl knows none. */
10
+ function knownZone(zone) {
11
+ if (typeof zone !== 'string' || !zone)
12
+ return null;
13
+ try {
14
+ return new Intl.DateTimeFormat('en-US', { timeZone: zone }).resolvedOptions().timeZone;
15
+ }
16
+ catch {
17
+ return null;
18
+ }
19
+ }
20
+ /**
21
+ * `GET /api/user/settings`'s resolved zone, or null when it could not be read: refused, failed,
22
+ * too slow, or a zone this machine's Intl does not know. Never throws.
23
+ */
24
+ export async function readMemberTimeZone(client, signal) {
25
+ try {
26
+ const timeout = AbortSignal.timeout(MEMBER_TIME_ZONE_TIMEOUT_MS);
27
+ const { data, response } = await client.GET('/api/user/settings', {
28
+ signal: signal ? AbortSignal.any([signal, timeout]) : timeout,
29
+ });
30
+ if (!response.ok)
31
+ return null;
32
+ const settings = data
33
+ ?.data;
34
+ const timeZone = knownZone(settings?.resolvedTimeZone);
35
+ return timeZone ? { timeZone, guessed: settings?.resolvedFrom === 'default' } : null;
36
+ }
37
+ catch {
38
+ return null;
39
+ }
40
+ }
41
+ /** `2026-11-05 09:12 Europe/Rome`: the wall-clock minute in `timeZone`, and the zone named. */
42
+ export function localStamp(now, timeZone) {
43
+ const parts = Object.fromEntries(new Intl.DateTimeFormat('en-US', {
44
+ timeZone,
45
+ year: 'numeric',
46
+ month: '2-digit',
47
+ day: '2-digit',
48
+ hour: '2-digit',
49
+ minute: '2-digit',
50
+ hourCycle: 'h23',
51
+ })
52
+ .formatToParts(now)
53
+ .map((part) => [part.type, part.value]));
54
+ return `${parts.year}-${parts.month}-${parts.day} ${parts.hour}:${parts.minute} ${timeZone}`;
55
+ }
56
+ /**
57
+ * Commands whose `--tz` names the calendar days a person reads: left out, the CLI sends the
58
+ * member's own timezone, where the API itself defaults to UTC. A `--tz` given always wins.
59
+ */
60
+ const MEMBER_TIME_ZONE_DEFAULTS = new Set([
61
+ 'user usage get',
62
+ 'workspaces usage breakdown get',
63
+ ]);
64
+ /**
65
+ * `request` with the member's zone as the `tz` the call left out; unchanged for any other
66
+ * command, or with a note and the API's UTC when the zone cannot be read. Called once `request`
67
+ * is built, so a call missing a flag fails before this read.
68
+ */
69
+ export async function withMemberTimeZone(runtime, operation, input, request) {
70
+ if (!MEMBER_TIME_ZONE_DEFAULTS.has(operation.command.join(' ')))
71
+ return request;
72
+ if (!operation.query.some((field) => field.name === 'tz'))
73
+ return request;
74
+ if (input.fields.tz !== undefined)
75
+ return request;
76
+ const zone = await readMemberTimeZone(runtime.client());
77
+ if (!zone) {
78
+ runtime.notice?.('Your timezone could not be read, so days are in UTC. Pass --tz to choose.');
79
+ return request;
80
+ }
81
+ return buildRequest(operation, { ...input, fields: { ...input.fields, tz: zone.timeZone } });
82
+ }
@@ -29,6 +29,9 @@ export function createRuntime({ flags, env = process.env, fetch, stdout = (line)
29
29
  answerTimeoutMs,
30
30
  });
31
31
  },
32
+ notice(line) {
33
+ stderr(line);
34
+ },
32
35
  output(outcome) {
33
36
  if (outcome.ok) {
34
37
  // 204 has nothing to print; anything else is passed through as JSON so
package/openapi.json CHANGED
@@ -9511,7 +9511,7 @@
9511
9511
  "/api/organizations/{workspaceId}/usage/breakdown": {
9512
9512
  "get": {
9513
9513
  "operationId": "workspacesUsageBreakdownGet",
9514
- "summary": "Read what used the workspace's Credentials over range (7d by default, 30d or all) in calendar days of tz (an IANA time zone, UTC by default): totals and per-day counts, then rows grouped by work, repository and model, each with its Providers and busiest Chat Sessions (the top five by every count, so sort by the one you show). Counts attempts run on the workspace's Credentials since recording began on 22 October 2026; days before it have recorded false and are never 0. turns counts every attempt; the four token counts are sums of reported counts only, never added together, with missing and inProgress counted apart. Members' own Subscriptions, Sensei, Sensei free and platform work are excluded. Owners and admins only. 400 on another range or an unknown time zone.",
9514
+ "summary": "Read what used the workspace's Credentials over range (7d by default, 30d or all) in calendar days of tz (an IANA time zone, UTC by default; the kosuke CLI sends your own timezone): totals and per-day counts, then rows grouped by work, repository and model, each with its Providers and busiest Chat Sessions (the top five by every count, so sort by the one you show). Counts attempts run on the workspace's Credentials since recording began on 22 October 2026; days before it have recorded false and are never 0. turns counts every attempt; the four token counts are sums of reported counts only, never added together, with missing and inProgress counted apart. Members' own Subscriptions, Sensei, Sensei free and platform work are excluded. Owners and admins only. 400 on another range or an unknown time zone.",
9515
9515
  "tags": ["workspaces"],
9516
9516
  "x-kosuke-command": ["workspaces", "usage", "breakdown", "get"],
9517
9517
  "x-kosuke-sandbox-token": true,
@@ -9543,10 +9543,10 @@
9543
9543
  "name": "tz",
9544
9544
  "in": "query",
9545
9545
  "required": false,
9546
- "description": "IANA time zone for calendar days. Default: UTC.",
9546
+ "description": "IANA time zone for calendar days. Default: UTC; the kosuke CLI sends your own timezone.",
9547
9547
  "schema": {
9548
9548
  "default": "UTC",
9549
- "description": "IANA time zone for calendar days. Default: UTC.",
9549
+ "description": "IANA time zone for calendar days. Default: UTC; the kosuke CLI sends your own timezone.",
9550
9550
  "type": "string"
9551
9551
  }
9552
9552
  }
@@ -29297,7 +29297,7 @@
29297
29297
  "/api/user/usage/breakdown": {
29298
29298
  "get": {
29299
29299
  "operationId": "userUsageGet",
29300
- "summary": "Read what used your AI work over range (7d by default, 30d or all) in calendar days of tz (an IANA time zone, UTC by default): totals and per-day counts, then rows grouped by work, repository and model, each with its Providers and busiest Chat Sessions or Sensei Threads (the top five by every count, so sort by the one you show). Counts your personal Subscription attempts and Sensei free Turns since recording began on 22 October 2026; days before it have recorded false and are never 0. turns counts every attempt; the four token counts are sums of reported counts only, never added together, with missing and inProgress counted apart. A repository or session in a workspace you no longer belong to keeps its counts but no name, title or link. Workspace Credentials and platform work are excluded. Your own sign-in or API key only; agent tokens are refused. 400 on another range or an unknown time zone.",
29300
+ "summary": "Read what used your AI work over range (7d by default, 30d or all) in calendar days of tz (an IANA time zone, UTC by default; the kosuke CLI sends your own timezone): totals and per-day counts, then rows grouped by work, repository and model, each with its Providers and busiest Chat Sessions or Sensei Threads (the top five by every count, so sort by the one you show). Counts your personal Subscription attempts and Sensei free Turns since recording began on 22 October 2026; days before it have recorded false and are never 0. turns counts every attempt; the four token counts are sums of reported counts only, never added together, with missing and inProgress counted apart. A repository or session in a workspace you no longer belong to keeps its counts but no name, title or link. Workspace Credentials and platform work are excluded. Your own sign-in or API key only; agent tokens are refused. 400 on another range or an unknown time zone.",
29301
29301
  "tags": ["user"],
29302
29302
  "x-kosuke-command": ["user", "usage", "get"],
29303
29303
  "parameters": [
@@ -29317,10 +29317,10 @@
29317
29317
  "name": "tz",
29318
29318
  "in": "query",
29319
29319
  "required": false,
29320
- "description": "IANA time zone for calendar days. Default: UTC.",
29320
+ "description": "IANA time zone for calendar days. Default: UTC; the kosuke CLI sends your own timezone.",
29321
29321
  "schema": {
29322
29322
  "default": "UTC",
29323
- "description": "IANA time zone for calendar days. Default: UTC.",
29323
+ "description": "IANA time zone for calendar days. Default: UTC; the kosuke CLI sends your own timezone.",
29324
29324
  "type": "string"
29325
29325
  }
29326
29326
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kosuke-ai/kosuke",
3
- "version": "1.0.73",
3
+ "version": "1.0.74",
4
4
  "description": "Sensei platform CLI. The client customers install to drive app.kosuke.ai from their own machine.",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -43,10 +43,10 @@
43
43
  "minimatch": "^11.0.1"
44
44
  },
45
45
  "kosukeRelease": {
46
- "sourceCommit": "f5e7299d0cfb687520075fd96ff868e311150c02",
47
- "sourceIdentity": "1bc9f374930843d18bc01f197129d71d72abe4cc05703be97fa86b2d72ba1e90",
46
+ "sourceCommit": "ea906260a23d549bf0919c11e7fd7cf972e7726f",
47
+ "sourceIdentity": "e9b425585b87d8b82b09f3dd1c4947b27476185e6542c0e457e0f2383215c3f2",
48
48
  "fragments": [
49
- "desktop-screen-recording-unknown-m1s42y.json"
49
+ "cli-member-time-zone-wevg70.json"
50
50
  ]
51
51
  }
52
52
  }