@skhema/cli 0.4.6 → 0.4.8

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.
@@ -1 +1 @@
1
- {"version":3,"file":"component.d.ts","sourceRoot":"","sources":["../../src/commands/component.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAkEnC,wBAAgB,yBAAyB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAkKhE"}
1
+ {"version":3,"file":"component.d.ts","sourceRoot":"","sources":["../../src/commands/component.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAoEnC,wBAAgB,yBAAyB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAkKhE"}
@@ -17,11 +17,12 @@ function renderComponents(components = []) {
17
17
  return;
18
18
  }
19
19
  logHeader(`Components (${components.length})`);
20
- logTable(['id', 'name', 'type', 'pos'], components.map((c) => [
20
+ logTable(['id', 'name', 'type', 'pos', 'elements'], components.map((c) => [
21
21
  c.id,
22
22
  c.name ?? '',
23
23
  c.componentType ?? '',
24
24
  c.position === undefined ? '' : String(c.position),
25
+ c.elementCount === undefined ? '' : String(c.elementCount),
25
26
  ]));
26
27
  }
27
28
  function renderComponentLinks(links = []) {
@@ -1 +1 @@
1
- {"version":3,"file":"element.d.ts","sourceRoot":"","sources":["../../src/commands/element.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAkBnC;;;GAGG;AACH,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAwS9D"}
1
+ {"version":3,"file":"element.d.ts","sourceRoot":"","sources":["../../src/commands/element.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAkBnC;;;GAGG;AACH,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CA8S9D"}
@@ -99,6 +99,7 @@ export function registerElementCommands(program) {
99
99
  .description('Create an element')
100
100
  .option('--content <content>', 'Element content')
101
101
  .option('--component-type <type>', 'Component type')
102
+ .option('--component-id <id>', 'Target component instance (find ids with `skhema component list`); omitted, the element lands in the first instance of the type by position (auto-created if none exists)')
102
103
  .option('--element-type <type>', 'Element type')
103
104
  .option('--file <path>', 'JSON payload file for the full body ("-" for stdin)')).action(async (options) => {
104
105
  await runCommand('element create', async () => {
@@ -106,6 +107,7 @@ export function registerElementCommands(program) {
106
107
  const body = buildBody(readPayloadFile(options.file), {
107
108
  content: options.content,
108
109
  componentType: options.componentType,
110
+ componentId: options.componentId,
109
111
  elementType: options.elementType,
110
112
  });
111
113
  if (Object.keys(body).length === 0) {
@@ -1 +1 @@
1
- {"version":3,"file":"token-store.d.ts","sourceRoot":"","sources":["../../../src/lib/auth/token-store.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAA;AAoFnD,wBAAsB,gBAAgB,CACpC,WAAW,EAAE,iBAAiB,GAC7B,OAAO,CAAC,IAAI,CAAC,CAOf;AAED,wBAAsB,oBAAoB,IAAI,OAAO,CAAC,iBAAiB,GAAG,IAAI,CAAC,CAuC9E;AAED,wBAAsB,gBAAgB,IAAI,OAAO,CAAC,IAAI,CAAC,CAGtD;AAED,wBAAgB,kBAAkB,IAAI,MAAM,CAQ3C"}
1
+ {"version":3,"file":"token-store.d.ts","sourceRoot":"","sources":["../../../src/lib/auth/token-store.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAA;AAoFnD,wBAAsB,gBAAgB,CACpC,WAAW,EAAE,iBAAiB,GAC7B,OAAO,CAAC,IAAI,CAAC,CAOf;AAED,wBAAsB,oBAAoB,IAAI,OAAO,CAAC,iBAAiB,GAAG,IAAI,CAAC,CA6D9E;AAED,wBAAsB,gBAAgB,IAAI,OAAO,CAAC,IAAI,CAAC,CAGtD;AAED,wBAAgB,kBAAkB,IAAI,MAAM,CAQ3C"}
@@ -90,28 +90,51 @@ export async function getStoredCredentials() {
90
90
  const credentials = JSON.parse(data);
91
91
  // Auto-refresh if within buffer of expiry
92
92
  if (credentials.expires_at - Date.now() < TOKEN_REFRESH_BUFFER) {
93
+ let newTokens;
94
+ try {
95
+ newTokens = await refreshAccessToken(credentials.refresh_token);
96
+ }
97
+ catch {
98
+ // Refresh failed. If the access token is still valid (refresh was just
99
+ // the pre-expiry buffer, e.g. a network blip), the credentials remain
100
+ // usable. If it has ALREADY expired, the session is dead (refresh
101
+ // tokens live 7 days) — returning it would present an unusable bearer
102
+ // downstream as a "valid session" and surface as a bare 401 far from
103
+ // the cause. Treat as unauthenticated instead.
104
+ if (credentials.expires_at > Date.now()) {
105
+ return credentials;
106
+ }
107
+ return null;
108
+ }
109
+ // Refresh succeeded — the session is alive. Nothing past this point is
110
+ // allowed to discard it: userinfo is cosmetic (keep the prior identity
111
+ // on failure) and a persist failure still leaves the tokens usable for
112
+ // this invocation.
113
+ const refreshed = {
114
+ ...credentials,
115
+ access_token: newTokens.access_token,
116
+ refresh_token: newTokens.refresh_token,
117
+ expires_at: Date.now() + newTokens.expires_in * 1000,
118
+ scope: newTokens.scope,
119
+ };
93
120
  try {
94
- const newTokens = await refreshAccessToken(credentials.refresh_token);
95
121
  const userInfo = await fetchUserInfo(newTokens.access_token);
96
- const refreshed = {
97
- ...credentials,
98
- access_token: newTokens.access_token,
99
- refresh_token: newTokens.refresh_token,
100
- expires_at: Date.now() + newTokens.expires_in * 1000,
101
- scope: newTokens.scope,
102
- user: {
103
- id: userInfo.sub,
104
- email: userInfo.email,
105
- name: userInfo.name,
106
- },
122
+ refreshed.user = {
123
+ id: userInfo.sub,
124
+ email: userInfo.email,
125
+ name: userInfo.name,
107
126
  };
127
+ }
128
+ catch {
129
+ /* keep the previously stored user */
130
+ }
131
+ try {
108
132
  await storeCredentials(refreshed);
109
- return refreshed;
110
133
  }
111
134
  catch {
112
- // Refresh failed - return stale credentials, caller can handle
113
- return credentials;
135
+ /* still return the in-memory refreshed session */
114
136
  }
137
+ return refreshed;
115
138
  }
116
139
  return credentials;
117
140
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@skhema/cli",
3
- "version": "0.4.6",
3
+ "version": "0.4.8",
4
4
  "description": "Skhema CLI - Authentication and AI skills management for agent platforms",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -43,7 +43,7 @@
43
43
  "dependencies": {
44
44
  "@skhema/agent-sdk": "0.1.4",
45
45
  "@skhema/method": "0.3.0",
46
- "@skhema/sdk": "0.2.3",
46
+ "@skhema/sdk": "0.2.4",
47
47
  "chalk": "^5.3.0",
48
48
  "commander": "^12.0.0",
49
49
  "ora": "^8.0.0"