@kosuke-ai/kosuke 1.0.166 → 1.0.168

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,13 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.0.168
4
+
5
+ - Accept a workspace's slug from an app URL wherever a workspace id goes: a refused slug is looked up among your workspaces and sent again as its id.
6
+
7
+ ## 1.0.167
8
+
9
+ - The cards schema text now says a card with a clarification question takes a headline of its own that names its subject, never a question's words.
10
+
3
11
  ## 1.0.166
4
12
 
5
13
  - CLI: your own API key drives your Mac and its signed-in Chrome with `kosuke mac …`, on each Mac whose new CLI switch is on in Settings, Devices; a key needs Full access or the new Mac and browser scope. iPhone: API keys can be made with the Mac and browser scope.
package/README.md CHANGED
@@ -55,6 +55,10 @@ kosuke sensei sessions facts get <sessionId>
55
55
  kosuke sensei threads get <threadId> --since <messageId>
56
56
  ```
57
57
 
58
+ A workspace's slug, as an app URL carries it (`/w/kosuke-core-765bebf6/…`), works where a
59
+ workspace id goes: when the platform refuses it as an id, the CLI looks it up among your
60
+ workspaces and sends the request again with its id.
61
+
58
62
  `kosuke find` prints one row per match: its workspace, project, session, thread, task, pull
59
63
  request number and head SHA. A command whose path starts with the project and session ids
60
64
  takes the session id alone, or `--session-id`, and reads its project with the same lookup; a
@@ -28,7 +28,7 @@ export const operation = {
28
28
  "flag": "blocks",
29
29
  "kind": "json",
30
30
  "required": true,
31
- "description": "The body, in order. The first text block, unless it has a role, opens on a lead of 160 characters at most before its first blank line, the part a phone shows before more. A card with one clarification question takes it, word for word, as its headline. A clarification question offers 2 to 3 options (a session's question relayed as question-<n> keeps its own, and the daily report's archive-sessions-<date> card asks its own, 4 at most). Each option's shown title, label else title, is 4 words at most and clear on its own; its description is 85 characters at most, two lines on a phone, with no line break. A question over these is refused with the field to rewrite.",
31
+ "description": "The body, in order. The first text block, unless it has a role, opens on a lead of 160 characters at most before its first blank line, the part a phone shows before more. A card with a clarification question takes a headline of its own that names its subject, never a question's words: the phone shows the headline above the question. A clarification question offers 2 to 3 options (a session's question relayed as question-<n> keeps its own, and the daily report's archive-sessions-<date> card asks its own, 4 at most). Each option's shown title, label else title, is 4 words at most and clear on its own; its description is 85 characters at most, two lines on a phone, with no line break. A question over these is refused with the field to rewrite.",
32
32
  "shape": [
33
33
  "T[] (max 12), each T one of:",
34
34
  "{type: \"text\", role?: \"message\"|\"draft\", text: string, media?: {eventId: string, parts: integer[] (max 10)}, network?: \"gmail\"|\"slack\"|\"telegram\"|\"whatsapp\"|\"linkedin\"|\"x\", connection?: string, email?: \"new\"|\"reply\"|\"forward\", from?: string}",
@@ -10,6 +10,8 @@ import { isOwnerRepo, ownerRepoParser } from './owner-repo.js';
10
10
  import { PERSONAL_SPACE_PARAM } from './personal-space.js';
11
11
  import { refusedBeforeSending } from './prototype-check.js';
12
12
  import { personalSpaceId } from './personal-space-id.js';
13
+ import { projectOf } from './session-project.js';
14
+ import { sendWithWorkspaceSlug } from './workspace-slug.js';
13
15
  import { PROTOTYPE_CREATE_HELP, prepareOperationInput } from './prototype-create.js';
14
16
  import { threadView, TOOLS_FLAG_HELP } from './thread-text.js';
15
17
  import { fieldsOf, formLabel, formUsage, leafShape, pathParamsFor, PERSONAL, scopeOf, selectForm, } from './variants.js';
@@ -170,28 +172,6 @@ function sessionArgs(operation, operands, options) {
170
172
  },
171
173
  };
172
174
  }
173
- /** The session's project, by the lookup `kosuke find` runs; null once the failure is printed. */
174
- async function projectOf(runtime, sessionId) {
175
- const outcome = await execute(runtime.client(), {
176
- method: 'get',
177
- path: '/api/find/{query}',
178
- pathParams: { query: sessionId },
179
- query: {},
180
- body: null,
181
- });
182
- if (!outcome.ok) {
183
- runtime.output(outcome);
184
- return null;
185
- }
186
- const rows = outcome.body?.data;
187
- const row = (Array.isArray(rows) ? rows : []).find((candidate) => candidate.match === 'session' &&
188
- typeof candidate.sessionId === 'string' &&
189
- candidate.sessionId.toLowerCase() === sessionId.toLowerCase());
190
- if (typeof row?.projectId === 'string')
191
- return row.projectId;
192
- runtime.output({ ok: false, status: 404, body: `error: no session ${sessionId} in your reach.` });
193
- return null;
194
- }
195
175
  /** A leaf over several forms: the union of their flags, the form picked per call. */
196
176
  function attachForms(root, forms, runtime, reachable) {
197
177
  const path = forms[0].command;
@@ -349,7 +329,9 @@ async function run(leaf, runtime, operation, input, options = {}) {
349
329
  process.once('SIGTERM', cancel);
350
330
  }
351
331
  try {
352
- const outcome = await execute(client, request, controller.signal);
332
+ const sent = await sendWithWorkspaceSlug(runtime, operation, input, request, (built) => execute(client, built, controller.signal));
333
+ const outcome = sent.outcome;
334
+ request = sent.request;
353
335
  // `--fields` and `--format` pick from the platform's own JSON, so a text view steps aside.
354
336
  const { fields, format } = leaf.optsWithGlobals();
355
337
  const view = fields || format ? undefined : VIEWS[operation.command.join(' ')]?.view;
@@ -0,0 +1,23 @@
1
+ import { execute } from './invoke.js';
2
+ /** The session's project, by the lookup `kosuke find` runs; null once the failure is printed. */
3
+ export async function projectOf(runtime, sessionId) {
4
+ const outcome = await execute(runtime.client(), {
5
+ method: 'get',
6
+ path: '/api/find/{query}',
7
+ pathParams: { query: sessionId },
8
+ query: {},
9
+ body: null,
10
+ });
11
+ if (!outcome.ok) {
12
+ runtime.output(outcome);
13
+ return null;
14
+ }
15
+ const rows = outcome.body?.data;
16
+ const row = (Array.isArray(rows) ? rows : []).find((candidate) => candidate.match === 'session' &&
17
+ typeof candidate.sessionId === 'string' &&
18
+ candidate.sessionId.toLowerCase() === sessionId.toLowerCase());
19
+ if (typeof row?.projectId === 'string')
20
+ return row.projectId;
21
+ runtime.output({ ok: false, status: 404, body: `error: no session ${sessionId} in your reach.` });
22
+ return null;
23
+ }
@@ -0,0 +1,51 @@
1
+ import { buildRequest, execute, } from './invoke.js';
2
+ import { withMemberTimeZone } from './member-time-zone.js';
3
+ /**
4
+ * A workspace's slug, as the app's URLs carry it (`/w/kosuke-core-765bebf6/tasks`), where a
5
+ * workspace id goes. Read only after the platform refused the value as an id: a value shaped
6
+ * like a slug (lowercase words and dashes, not a UUID) is swapped for the id of the member's
7
+ * workspace that has it. A slug none of their workspaces has comes back unchanged, so the
8
+ * refusal stands.
9
+ */
10
+ /** `kosuke workspaces list`: the member's workspaces, `{ data: [{ id, slug }] }`. */
11
+ const WORKSPACES_PATH = '/api/organizations';
12
+ const WORKSPACE_PARAMS = ['workspaceId', 'organizationId'];
13
+ const SLUG = /^[a-z0-9]+(?:-[a-z0-9]+)+$/;
14
+ const UUID = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/;
15
+ /**
16
+ * Sends `request`; refused with a 403 or 404 for a workspace slug copied from an app URL, sends
17
+ * it again with the workspace's id. Returns the request last sent with its outcome.
18
+ */
19
+ export async function sendWithWorkspaceSlug(runtime, operation, input, request, send) {
20
+ const outcome = await send(request);
21
+ if (outcome.ok || (outcome.status !== 403 && outcome.status !== 404)) {
22
+ return { outcome, request };
23
+ }
24
+ const pathParams = await resolveWorkspaceSlug(runtime, input.pathParams);
25
+ if (pathParams === input.pathParams)
26
+ return { outcome, request };
27
+ const resolved = { ...input, pathParams };
28
+ const retry = await withMemberTimeZone(runtime, operation, resolved, buildRequest(operation, resolved));
29
+ return { outcome: await send(retry), request: retry };
30
+ }
31
+ async function resolveWorkspaceSlug(runtime, pathParams) {
32
+ const param = WORKSPACE_PARAMS.find((name) => {
33
+ const value = pathParams[name] ?? '';
34
+ return SLUG.test(value) && !UUID.test(value);
35
+ });
36
+ if (!param)
37
+ return pathParams;
38
+ const outcome = await execute(runtime.client(), {
39
+ method: 'get',
40
+ path: WORKSPACES_PATH,
41
+ pathParams: {},
42
+ query: {},
43
+ body: null,
44
+ });
45
+ const rows = isRecord(outcome.body) && Array.isArray(outcome.body.data) ? outcome.body.data : [];
46
+ const match = rows.find((row) => isRecord(row) && row.slug === pathParams[param] && typeof row.id === 'string');
47
+ return match ? { ...pathParams, [param]: match.id } : pathParams;
48
+ }
49
+ function isRecord(value) {
50
+ return typeof value === 'object' && value !== null && !Array.isArray(value);
51
+ }
package/openapi.json CHANGED
@@ -24742,7 +24742,7 @@
24742
24742
  }
24743
24743
  ]
24744
24744
  },
24745
- "description": "The body, in order. The first text block, unless it has a role, opens on a lead of 160 characters at most before its first blank line, the part a phone shows before more. A card with one clarification question takes it, word for word, as its headline. A clarification question offers 2 to 3 options (a session's question relayed as question-<n> keeps its own, and the daily report's archive-sessions-<date> card asks its own, 4 at most). Each option's shown title, label else title, is 4 words at most and clear on its own; its description is 85 characters at most, two lines on a phone, with no line break. A question over these is refused with the field to rewrite."
24745
+ "description": "The body, in order. The first text block, unless it has a role, opens on a lead of 160 characters at most before its first blank line, the part a phone shows before more. A card with a clarification question takes a headline of its own that names its subject, never a question's words: the phone shows the headline above the question. A clarification question offers 2 to 3 options (a session's question relayed as question-<n> keeps its own, and the daily report's archive-sessions-<date> card asks its own, 4 at most). Each option's shown title, label else title, is 4 words at most and clear on its own; its description is 85 characters at most, two lines on a phone, with no line break. A question over these is refused with the field to rewrite."
24746
24746
  },
24747
24747
  "instruction": {
24748
24748
  "type": "string",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kosuke-ai/kosuke",
3
- "version": "1.0.166",
3
+ "version": "1.0.168",
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": "d790445dea71119918394ef9eecc5b3078c6d0d3",
47
- "sourceIdentity": "156af8d0edaef4e0d1bdc3a3d235fcb315d3bac44bf1134022835697911b991d",
46
+ "sourceCommit": "0fa55482dc518c6bd3ddcbaae22962b84e6ce455",
47
+ "sourceIdentity": "3909e257786e2bd044575f8de584203f4f89ede99004114724427036f72b68c9",
48
48
  "fragments": [
49
- "cli-drives-mac-r4t8wz.json"
49
+ "cli-workspace-slug-r7k2mq.json"
50
50
  ]
51
51
  }
52
52
  }