@tonbo/yield 0.2.0 → 0.2.2

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 (2) hide show
  1. package/dist/bin/yield.js +25 -8
  2. package/package.json +1 -1
package/dist/bin/yield.js CHANGED
@@ -1185,13 +1185,15 @@ var AuthClient = class {
1185
1185
  browserOpener;
1186
1186
  hostname;
1187
1187
  loginHint;
1188
- constructor(credentials, fetcher, loginOrigin2 = "https://tonbo.dev", browserOpener = openBrowser, hostname = loginHostname(), loginHint = DEFAULT_LOGIN_HINT) {
1188
+ entryLine;
1189
+ constructor(credentials, fetcher, loginOrigin2 = "https://tonbo.dev", browserOpener = openBrowser, hostname = loginHostname(), loginHint = DEFAULT_LOGIN_HINT, entryLine = "cli") {
1189
1190
  this.credentials = credentials;
1190
1191
  this.fetcher = fetcher;
1191
1192
  this.loginOrigin = loginOrigin2;
1192
1193
  this.browserOpener = browserOpener;
1193
1194
  this.hostname = hostname;
1194
1195
  this.loginHint = loginHint;
1196
+ this.entryLine = entryLine;
1195
1197
  }
1196
1198
  /** The personal key requests are made with: TONBO_API_KEY, or the saved
1197
1199
  * login while it has not expired. */
@@ -1234,6 +1236,7 @@ var AuthClient = class {
1234
1236
  redirect_uri: redirectUri,
1235
1237
  state,
1236
1238
  hostname: this.hostname,
1239
+ from: this.entryLine,
1237
1240
  ...account ? { account } : {}
1238
1241
  }).toString();
1239
1242
  return authorization.toString();
@@ -5052,7 +5055,8 @@ var ProjectRouter = class {
5052
5055
  const found = bound.get(folder_id);
5053
5056
  if (!found) continue;
5054
5057
  if (found.binding.device_handle) return null;
5055
- return { folder, gitRoot: await this.deps.gitRoot(folder), ...found };
5058
+ const account = found.account.kind ? found.account : { ...found.account, kind: await this.kindOf(found.account.key) };
5059
+ return { folder, gitRoot: await this.deps.gitRoot(folder), ...found, account };
5056
5060
  }
5057
5061
  const root = await this.deps.gitRoot(directory2);
5058
5062
  if (!root) return null;
@@ -5104,19 +5108,24 @@ var ProjectRouter = class {
5104
5108
  const logins = accountLogins(file);
5105
5109
  if (logins.some((login) => login.kind)) return null;
5106
5110
  const top = logins.find((login) => login.account_id === file.account_id);
5107
- let kind = this.kinds.get(top.key);
5111
+ const kind = await this.kindOf(top.key);
5112
+ return kind === "user" ? { ...top, kind } : null;
5113
+ }
5114
+ /** A login's account kind from `GET /v1/account`, once per key. */
5115
+ async kindOf(key) {
5116
+ let kind = this.kinds.get(key);
5108
5117
  if (!kind) {
5109
5118
  const { data } = await requestJson(
5110
5119
  this.deps.fetch,
5111
5120
  `${this.deps.apiOrigin}${managementApiBasePath}/account`,
5112
- { headers: { authorization: `Bearer ${top.key}` } }
5121
+ { headers: { authorization: `Bearer ${key}` } }
5113
5122
  );
5114
5123
  if (data?.kind !== "user" && data?.kind !== "organization")
5115
5124
  throw new Error("The account answer is malformed.");
5116
5125
  kind = data.kind;
5117
- this.kinds.set(top.key, kind);
5126
+ this.kinds.set(key, kind);
5118
5127
  }
5119
- return kind === "user" ? { ...top, kind } : null;
5128
+ return kind;
5120
5129
  }
5121
5130
  /** Every account's bindings on this device, read again after `ttlMs`; an
5122
5131
  * account that cannot be read keeps its last answer. */
@@ -8061,7 +8070,15 @@ function createDependencies() {
8061
8070
  tokens: new AccessTokens(fetch, loginOrigin(api), STREAMS_AUDIENCE, LOGIN_HINT),
8062
8071
  gitTokens: new AccessTokens(fetch, loginOrigin(api), GIT_AUDIENCE, LOGIN_HINT),
8063
8072
  api: new ManagementApi(fetch, api, LOGIN_HINT),
8064
- auth: new AuthClient(credentials, fetch, loginOrigin(api), void 0, void 0, LOGIN_HINT),
8073
+ auth: new AuthClient(
8074
+ credentials,
8075
+ fetch,
8076
+ loginOrigin(api),
8077
+ void 0,
8078
+ void 0,
8079
+ LOGIN_HINT,
8080
+ "yield"
8081
+ ),
8065
8082
  credentials,
8066
8083
  output: (text3) => console.log(text3),
8067
8084
  progress: new TerminalProgress(process.stderr)
@@ -8169,7 +8186,7 @@ function renderMessages(messages, maxChars) {
8169
8186
  return messages.map((message3) => `${message3.role}: ${truncate(message3.text, maxChars)}`);
8170
8187
  }
8171
8188
  function createProgram(dependencies = createDependencies) {
8172
- const program = new Command().name("yield").description("Capture your agents' sessions on this machine and list them from any machine.").version(CLIENT_VERSION);
8189
+ const program = new Command().name("yield").description("Capture your agents' sessions on this machine and list them from any machine.").version(CLIENT_VERSION).enablePositionalOptions();
8173
8190
  program.option("--session <id>", "local session id when this Project has more than one").option("--task <text>", "optional instruction for the continuation").option(
8174
8191
  "--new",
8175
8192
  "start another handoff for this session, even if the previous one may have succeeded"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tonbo/yield",
3
- "version": "0.2.0",
3
+ "version": "0.2.2",
4
4
  "description": "Tonbo Yield: capture your agents' sessions on every machine and list them from any.",
5
5
  "homepage": "https://tonbo.dev",
6
6
  "bugs": {