@qvac/core 0.3.1 → 0.3.3
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/README.md +4 -4
- package/dist-lib/lib/assistant/history.d.ts +10 -1
- package/dist-lib/lib/assistant/history.js +36 -1
- package/dist-lib/lib/assistant/message.d.ts +2 -0
- package/dist-lib/lib/assistant/message.js +11 -0
- package/dist-lib/lib/assistant/skill-encode.js +27 -1
- package/dist-lib/lib/assistant.d.ts +5 -2
- package/dist-lib/lib/assistant.js +41 -8
- package/dist-lib/lib/core/chat-activity.js +2 -8
- package/dist-lib/lib/core/skill-secrets.js +3 -6
- package/dist-lib/lib/core.d.ts +1 -0
- package/dist-lib/lib/core.js +51 -9
- package/dist-lib/lib/credential-pusher.d.ts +2 -3
- package/dist-lib/lib/credential-pusher.js +67 -39
- package/dist-lib/lib/integrations/index.d.ts +1 -2
- package/dist-lib/lib/integrations/index.js +0 -1
- package/dist-lib/lib/integrations/setup-routes.js +0 -15
- package/dist-lib/lib/oauth/flow-core.js +1 -1
- package/dist-lib/lib/oauth/flow.d.ts +4 -2
- package/dist-lib/lib/oauth/flow.js +3 -4
- package/dist-lib/lib/oauth/host.d.ts +3 -1
- package/dist-lib/lib/oauth/host.js +3 -1
- package/dist-lib/lib/oauth/keys.d.ts +21 -20
- package/dist-lib/lib/oauth/keys.js +59 -85
- package/dist-lib/lib/oauth/loopback.d.ts +2 -2
- package/dist-lib/lib/oauth/loopback.js +32 -19
- package/dist-lib/lib/oauth/loopback.stub.d.ts +2 -2
- package/dist-lib/lib/oauth/loopback.stub.js +2 -2
- package/dist-lib/lib/oauth/providers.d.ts +3 -5
- package/dist-lib/lib/oauth/providers.js +20 -67
- package/dist-lib/lib/oauth/redirect-types.d.ts +1 -0
- package/dist-lib/lib/oauth/registry.d.ts +10 -0
- package/dist-lib/lib/oauth/registry.js +25 -0
- package/dist-lib/lib/oauth/resolve.js +1 -1
- package/dist-lib/lib/oauth/token-exchange-core.js +2 -1
- package/dist-lib/lib/oauth/types.d.ts +1 -1
- package/dist-lib/lib/oauth.client.d.ts +3 -1
- package/dist-lib/lib/oauth.client.js +3 -1
- package/dist-lib/lib/oauth.d.ts +4 -7
- package/dist-lib/lib/oauth.js +4 -7
- package/dist-lib/lib/skill-types.d.ts +12 -0
- package/dist-lib/schema/engine.js +21 -1
- package/dist-lib/spec/hrpc/messages.js +114 -5
- package/dist-lib/spec/hyperschema/index.js +114 -5
- package/dist-lib/spec/hyperschema/schema.json +84 -1
- package/dist-lib/spec/hyperschema/types.d.ts +18 -1
- package/package.json +4 -4
- package/tui/app.mjs +98 -155
- package/tui/lib/save-file.mjs +1 -1
- package/dist-lib/lib/integrations/oauth-providers.d.ts +0 -14
- package/dist-lib/lib/integrations/oauth-providers.js +0 -116
- package/dist-lib/lib/oauth/asana.d.ts +0 -35
- package/dist-lib/lib/oauth/asana.js +0 -71
- package/dist-lib/lib/oauth/google.d.ts +0 -37
- package/dist-lib/lib/oauth/google.js +0 -77
- package/dist-lib/lib/oauth/notion.d.ts +0 -34
- package/dist-lib/lib/oauth/notion.js +0 -82
- package/dist-lib/lib/oauth/spotify.d.ts +0 -32
- package/dist-lib/lib/oauth/spotify.js +0 -74
- package/dist-lib/lib/oauth/verify.d.ts +0 -8
- package/dist-lib/lib/oauth/verify.js +0 -58
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
// This file is autogenerated by the hyperschema compiler
|
|
2
|
-
// Schema Version:
|
|
2
|
+
// Schema Version: 9
|
|
3
3
|
/* eslint-disable camelcase */
|
|
4
4
|
/* eslint-disable quotes */
|
|
5
5
|
/* eslint-disable space-before-function-paren */
|
|
6
6
|
|
|
7
7
|
import { c } from 'hyperschema/runtime'
|
|
8
8
|
|
|
9
|
-
const VERSION =
|
|
9
|
+
const VERSION = 9
|
|
10
10
|
|
|
11
11
|
// eslint-disable-next-line no-unused-vars
|
|
12
12
|
let version = VERSION
|
|
@@ -5241,7 +5241,8 @@ const encoding137 = {
|
|
|
5241
5241
|
(m.steps ? 16 : 0) |
|
|
5242
5242
|
(m.configSteps ? 32 : 0) |
|
|
5243
5243
|
(m.fields ? 64 : 0) |
|
|
5244
|
-
(m.satisfied ? 128 : 0)
|
|
5244
|
+
(m.satisfied ? 128 : 0) |
|
|
5245
|
+
((version >= 9 && m.oauth) ? 256 : 0)
|
|
5245
5246
|
|
|
5246
5247
|
encoding136.preencode(state, m.kind)
|
|
5247
5248
|
c.string.preencode(state, m.label)
|
|
@@ -5254,6 +5255,7 @@ const encoding137 = {
|
|
|
5254
5255
|
if (m.steps) encoding137_6.preencode(state, m.steps)
|
|
5255
5256
|
if (m.configSteps) encoding137_7.preencode(state, m.configSteps)
|
|
5256
5257
|
if (m.fields) encoding137_8.preencode(state, m.fields)
|
|
5258
|
+
if (version >= 9 && m.oauth) encoding137_10.preencode(state, m.oauth)
|
|
5257
5259
|
},
|
|
5258
5260
|
encode(state, m) {
|
|
5259
5261
|
const flags =
|
|
@@ -5264,7 +5266,8 @@ const encoding137 = {
|
|
|
5264
5266
|
(m.steps ? 16 : 0) |
|
|
5265
5267
|
(m.configSteps ? 32 : 0) |
|
|
5266
5268
|
(m.fields ? 64 : 0) |
|
|
5267
|
-
(m.satisfied ? 128 : 0)
|
|
5269
|
+
(m.satisfied ? 128 : 0) |
|
|
5270
|
+
((version >= 9 && m.oauth) ? 256 : 0)
|
|
5268
5271
|
|
|
5269
5272
|
encoding136.encode(state, m.kind)
|
|
5270
5273
|
c.string.encode(state, m.label)
|
|
@@ -5277,6 +5280,7 @@ const encoding137 = {
|
|
|
5277
5280
|
if (m.steps) encoding137_6.encode(state, m.steps)
|
|
5278
5281
|
if (m.configSteps) encoding137_7.encode(state, m.configSteps)
|
|
5279
5282
|
if (m.fields) encoding137_8.encode(state, m.fields)
|
|
5283
|
+
if (version >= 9 && m.oauth) encoding137_10.encode(state, m.oauth)
|
|
5280
5284
|
},
|
|
5281
5285
|
decode(state) {
|
|
5282
5286
|
const r0 = encoding136.decode(state)
|
|
@@ -5293,7 +5297,8 @@ const encoding137 = {
|
|
|
5293
5297
|
steps: (flags & 16) !== 0 ? encoding137_6.decode(state) : null,
|
|
5294
5298
|
configSteps: (flags & 32) !== 0 ? encoding137_7.decode(state) : null,
|
|
5295
5299
|
fields: (flags & 64) !== 0 ? encoding137_8.decode(state) : null,
|
|
5296
|
-
satisfied: (flags & 128) !== 0
|
|
5300
|
+
satisfied: (flags & 128) !== 0,
|
|
5301
|
+
oauth: (version >= 9 && (flags & 256) !== 0) ? encoding137_10.decode(state) : null
|
|
5297
5302
|
}
|
|
5298
5303
|
}
|
|
5299
5304
|
}
|
|
@@ -8690,12 +8695,110 @@ const encoding247 = {
|
|
|
8690
8695
|
}
|
|
8691
8696
|
}
|
|
8692
8697
|
|
|
8698
|
+
const encoding248_enum = {
|
|
8699
|
+
"pkce-only": 'pkce-only',
|
|
8700
|
+
"secret-in-body": 'secret-in-body',
|
|
8701
|
+
"secret-in-basic": 'secret-in-basic'
|
|
8702
|
+
}
|
|
8703
|
+
|
|
8704
|
+
// @assistant/skill-setup-token-auth enum
|
|
8705
|
+
const encoding248 = {
|
|
8706
|
+
preencode (state, m) {
|
|
8707
|
+
state.end++ // max enum is 3 so always one byte
|
|
8708
|
+
},
|
|
8709
|
+
encode (state, m) {
|
|
8710
|
+
switch (m) {
|
|
8711
|
+
case 'pkce-only':
|
|
8712
|
+
c.uint.encode(state, 1)
|
|
8713
|
+
break
|
|
8714
|
+
case 'secret-in-body':
|
|
8715
|
+
c.uint.encode(state, 2)
|
|
8716
|
+
break
|
|
8717
|
+
case 'secret-in-basic':
|
|
8718
|
+
c.uint.encode(state, 3)
|
|
8719
|
+
break
|
|
8720
|
+
default:
|
|
8721
|
+
throw new Error('Unknown enum')
|
|
8722
|
+
}
|
|
8723
|
+
},
|
|
8724
|
+
decode (state) {
|
|
8725
|
+
switch (c.uint.decode(state)) {
|
|
8726
|
+
case 1:
|
|
8727
|
+
return 'pkce-only'
|
|
8728
|
+
case 2:
|
|
8729
|
+
return 'secret-in-body'
|
|
8730
|
+
case 3:
|
|
8731
|
+
return 'secret-in-basic'
|
|
8732
|
+
default: return null
|
|
8733
|
+
}
|
|
8734
|
+
}
|
|
8735
|
+
}
|
|
8736
|
+
|
|
8737
|
+
// @assistant/skill-setup-oauth.scopes
|
|
8738
|
+
const encoding249_4 = encoding12_6
|
|
8739
|
+
|
|
8740
|
+
// @assistant/skill-setup-oauth
|
|
8741
|
+
const encoding249 = {
|
|
8742
|
+
preencode(state, m) {
|
|
8743
|
+
c.string.preencode(state, m.stateKey)
|
|
8744
|
+
c.string.preencode(state, m.authUrl)
|
|
8745
|
+
c.string.preencode(state, m.tokenUrl)
|
|
8746
|
+
encoding248.preencode(state, m.tokenAuth)
|
|
8747
|
+
state.end++ // max flag is 16 so always one byte
|
|
8748
|
+
|
|
8749
|
+
if (version >= 9 && m.scopes) encoding249_4.preencode(state, m.scopes)
|
|
8750
|
+
if (version >= 9 && m.extraAuthParams) c.json.preencode(state, m.extraAuthParams)
|
|
8751
|
+
if (version >= 9 && m.registrationEndpoint) c.string.preencode(state, m.registrationEndpoint)
|
|
8752
|
+
if (version >= 9 && m.port) c.uint.preencode(state, m.port)
|
|
8753
|
+
},
|
|
8754
|
+
encode(state, m) {
|
|
8755
|
+
const flags =
|
|
8756
|
+
((version >= 9 && m.scopes) ? 1 : 0) |
|
|
8757
|
+
((version >= 9 && m.extraAuthParams) ? 2 : 0) |
|
|
8758
|
+
((version >= 9 && m.registrationEndpoint) ? 4 : 0) |
|
|
8759
|
+
((version >= 9 && m.port) ? 8 : 0) |
|
|
8760
|
+
((version >= 9 && m.sharedIosSession) ? 16 : 0)
|
|
8761
|
+
|
|
8762
|
+
c.string.encode(state, m.stateKey)
|
|
8763
|
+
c.string.encode(state, m.authUrl)
|
|
8764
|
+
c.string.encode(state, m.tokenUrl)
|
|
8765
|
+
encoding248.encode(state, m.tokenAuth)
|
|
8766
|
+
c.uint.encode(state, flags)
|
|
8767
|
+
|
|
8768
|
+
if (version >= 9 && m.scopes) encoding249_4.encode(state, m.scopes)
|
|
8769
|
+
if (version >= 9 && m.extraAuthParams) c.json.encode(state, m.extraAuthParams)
|
|
8770
|
+
if (version >= 9 && m.registrationEndpoint) c.string.encode(state, m.registrationEndpoint)
|
|
8771
|
+
if (version >= 9 && m.port) c.uint.encode(state, m.port)
|
|
8772
|
+
},
|
|
8773
|
+
decode(state) {
|
|
8774
|
+
const r0 = c.string.decode(state)
|
|
8775
|
+
const r1 = c.string.decode(state)
|
|
8776
|
+
const r2 = c.string.decode(state)
|
|
8777
|
+
const r3 = encoding248.decode(state)
|
|
8778
|
+
const flags = c.uint.decode(state)
|
|
8779
|
+
|
|
8780
|
+
return {
|
|
8781
|
+
stateKey: r0,
|
|
8782
|
+
authUrl: r1,
|
|
8783
|
+
tokenUrl: r2,
|
|
8784
|
+
tokenAuth: r3,
|
|
8785
|
+
scopes: (version >= 9 && (flags & 1) !== 0) ? encoding249_4.decode(state) : null,
|
|
8786
|
+
extraAuthParams: (version >= 9 && (flags & 2) !== 0) ? c.json.decode(state) : null,
|
|
8787
|
+
registrationEndpoint: (version >= 9 && (flags & 4) !== 0) ? c.string.decode(state) : null,
|
|
8788
|
+
port: (version >= 9 && (flags & 8) !== 0) ? c.uint.decode(state) : 0,
|
|
8789
|
+
sharedIosSession: (version >= 9 && (flags & 16) !== 0)
|
|
8790
|
+
}
|
|
8791
|
+
}
|
|
8792
|
+
}
|
|
8793
|
+
|
|
8693
8794
|
// @assistant/chat-list.groups, deferred due to recusive use
|
|
8694
8795
|
const encoding18_1 = c.array(c.frame(encoding186))
|
|
8695
8796
|
// @assistant/device.toolCatalog, deferred due to recusive use
|
|
8696
8797
|
const encoding23_15 = c.array(c.frame(encoding175))
|
|
8697
8798
|
// @assistant/save-device-capabilities-request.toolCatalog, deferred due to recusive use
|
|
8698
8799
|
const encoding25_5 = encoding23_15
|
|
8800
|
+
// @assistant/skill-setup-route.oauth, deferred due to recusive use
|
|
8801
|
+
const encoding137_10 = c.frame(encoding249)
|
|
8699
8802
|
// @assistant/chat-group-list.groups, deferred due to recusive use
|
|
8700
8803
|
const encoding187_0 = encoding18_1
|
|
8701
8804
|
|
|
@@ -8779,6 +8882,8 @@ function getEnum(name) {
|
|
|
8779
8882
|
return encoding203_enum
|
|
8780
8883
|
case '@assistant/notification-kind':
|
|
8781
8884
|
return encoding209_enum
|
|
8885
|
+
case '@assistant/skill-setup-token-auth':
|
|
8886
|
+
return encoding248_enum
|
|
8782
8887
|
default:
|
|
8783
8888
|
throw new Error('Enum not found ' + name)
|
|
8784
8889
|
}
|
|
@@ -9282,6 +9387,10 @@ function getEncoding(name) {
|
|
|
9282
9387
|
return encoding246
|
|
9283
9388
|
case '@assistant/inference-calls-handoff-ack':
|
|
9284
9389
|
return encoding247
|
|
9390
|
+
case '@assistant/skill-setup-token-auth':
|
|
9391
|
+
return encoding248
|
|
9392
|
+
case '@assistant/skill-setup-oauth':
|
|
9393
|
+
return encoding249
|
|
9285
9394
|
default:
|
|
9286
9395
|
throw new Error('Encoder not found ' + name)
|
|
9287
9396
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version":
|
|
2
|
+
"version": 9,
|
|
3
3
|
"schema": [
|
|
4
4
|
{
|
|
5
5
|
"name": "empty",
|
|
@@ -4174,6 +4174,11 @@
|
|
|
4174
4174
|
"name": "satisfied",
|
|
4175
4175
|
"type": "bool",
|
|
4176
4176
|
"version": 1
|
|
4177
|
+
},
|
|
4178
|
+
{
|
|
4179
|
+
"name": "oauth",
|
|
4180
|
+
"type": "@assistant/skill-setup-oauth",
|
|
4181
|
+
"version": 9
|
|
4177
4182
|
}
|
|
4178
4183
|
]
|
|
4179
4184
|
},
|
|
@@ -6961,6 +6966,84 @@
|
|
|
6961
6966
|
"version": 8
|
|
6962
6967
|
}
|
|
6963
6968
|
]
|
|
6969
|
+
},
|
|
6970
|
+
{
|
|
6971
|
+
"name": "skill-setup-token-auth",
|
|
6972
|
+
"namespace": "assistant",
|
|
6973
|
+
"offset": 1,
|
|
6974
|
+
"enum": [
|
|
6975
|
+
{
|
|
6976
|
+
"key": "pkce-only",
|
|
6977
|
+
"version": 9
|
|
6978
|
+
},
|
|
6979
|
+
{
|
|
6980
|
+
"key": "secret-in-body",
|
|
6981
|
+
"version": 9
|
|
6982
|
+
},
|
|
6983
|
+
{
|
|
6984
|
+
"key": "secret-in-basic",
|
|
6985
|
+
"version": 9
|
|
6986
|
+
}
|
|
6987
|
+
],
|
|
6988
|
+
"strings": true
|
|
6989
|
+
},
|
|
6990
|
+
{
|
|
6991
|
+
"name": "skill-setup-oauth",
|
|
6992
|
+
"namespace": "assistant",
|
|
6993
|
+
"compact": false,
|
|
6994
|
+
"flagsPosition": 4,
|
|
6995
|
+
"fields": [
|
|
6996
|
+
{
|
|
6997
|
+
"name": "stateKey",
|
|
6998
|
+
"required": true,
|
|
6999
|
+
"type": "string",
|
|
7000
|
+
"version": 9
|
|
7001
|
+
},
|
|
7002
|
+
{
|
|
7003
|
+
"name": "authUrl",
|
|
7004
|
+
"required": true,
|
|
7005
|
+
"type": "string",
|
|
7006
|
+
"version": 9
|
|
7007
|
+
},
|
|
7008
|
+
{
|
|
7009
|
+
"name": "tokenUrl",
|
|
7010
|
+
"required": true,
|
|
7011
|
+
"type": "string",
|
|
7012
|
+
"version": 9
|
|
7013
|
+
},
|
|
7014
|
+
{
|
|
7015
|
+
"name": "tokenAuth",
|
|
7016
|
+
"required": true,
|
|
7017
|
+
"type": "@assistant/skill-setup-token-auth",
|
|
7018
|
+
"version": 9
|
|
7019
|
+
},
|
|
7020
|
+
{
|
|
7021
|
+
"name": "scopes",
|
|
7022
|
+
"array": true,
|
|
7023
|
+
"type": "string",
|
|
7024
|
+
"version": 9
|
|
7025
|
+
},
|
|
7026
|
+
{
|
|
7027
|
+
"name": "extraAuthParams",
|
|
7028
|
+
"type": "json",
|
|
7029
|
+
"version": 9
|
|
7030
|
+
},
|
|
7031
|
+
{
|
|
7032
|
+
"name": "registrationEndpoint",
|
|
7033
|
+
"type": "string",
|
|
7034
|
+
"version": 9
|
|
7035
|
+
},
|
|
7036
|
+
{
|
|
7037
|
+
"name": "port",
|
|
7038
|
+
"type": "uint",
|
|
7039
|
+
"version": 9
|
|
7040
|
+
},
|
|
7041
|
+
{
|
|
7042
|
+
"name": "sharedIosSession",
|
|
7043
|
+
"type": "bool",
|
|
7044
|
+
"version": 9
|
|
7045
|
+
}
|
|
7046
|
+
]
|
|
6964
7047
|
}
|
|
6965
7048
|
]
|
|
6966
7049
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// This file is autogenerated by hyperschema-ts
|
|
2
|
-
// Schema version:
|
|
2
|
+
// Schema version: 9
|
|
3
3
|
// Do not edit manually.
|
|
4
4
|
|
|
5
5
|
export interface AssistantEmpty {
|
|
@@ -864,6 +864,7 @@ export interface AssistantSkillSetupRoute {
|
|
|
864
864
|
configSteps?: string[] | null
|
|
865
865
|
fields?: AssistantSkillSetupField[] | null
|
|
866
866
|
satisfied?: boolean
|
|
867
|
+
oauth?: AssistantSkillSetupOauth | null
|
|
867
868
|
}
|
|
868
869
|
|
|
869
870
|
export interface AssistantSkillSetup {
|
|
@@ -1499,6 +1500,20 @@ export interface AssistantInferenceCallsHandoffAck {
|
|
|
1499
1500
|
truncated?: boolean
|
|
1500
1501
|
}
|
|
1501
1502
|
|
|
1503
|
+
export type AssistantSkillSetupTokenAuth = "pkce-only" | "secret-in-body" | "secret-in-basic"
|
|
1504
|
+
|
|
1505
|
+
export interface AssistantSkillSetupOauth {
|
|
1506
|
+
stateKey: string
|
|
1507
|
+
authUrl: string
|
|
1508
|
+
tokenUrl: string
|
|
1509
|
+
tokenAuth: AssistantSkillSetupTokenAuth
|
|
1510
|
+
scopes?: string[] | null
|
|
1511
|
+
extraAuthParams?: unknown | null
|
|
1512
|
+
registrationEndpoint?: string | null
|
|
1513
|
+
port?: number
|
|
1514
|
+
sharedIosSession?: boolean
|
|
1515
|
+
}
|
|
1516
|
+
|
|
1502
1517
|
export interface SchemaTypes {
|
|
1503
1518
|
"@assistant/empty": AssistantEmpty
|
|
1504
1519
|
"@assistant/ok-response": AssistantOkResponse
|
|
@@ -1748,4 +1763,6 @@ export interface SchemaTypes {
|
|
|
1748
1763
|
"@assistant/inference-calls-request": AssistantInferenceCallsRequest
|
|
1749
1764
|
"@assistant/inference-calls-handoff": AssistantInferenceCallsHandoff
|
|
1750
1765
|
"@assistant/inference-calls-handoff-ack": AssistantInferenceCallsHandoffAck
|
|
1766
|
+
"@assistant/skill-setup-token-auth": AssistantSkillSetupTokenAuth
|
|
1767
|
+
"@assistant/skill-setup-oauth": AssistantSkillSetupOauth
|
|
1751
1768
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@qvac/core",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.3",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Peer-to-peer AI across your devices",
|
|
6
6
|
"exports": {
|
|
@@ -221,8 +221,8 @@
|
|
|
221
221
|
}
|
|
222
222
|
},
|
|
223
223
|
"dependencies": {
|
|
224
|
-
"@qvac/harness": "^0.
|
|
225
|
-
"@qvac/skills": "^0.1.
|
|
224
|
+
"@qvac/harness": "^0.3.3",
|
|
225
|
+
"@qvac/skills": "^0.1.9",
|
|
226
226
|
"asenion": "^0.1.0",
|
|
227
227
|
"autobee": "^2.10.0",
|
|
228
228
|
"b4a": "^1.8.1",
|
|
@@ -275,7 +275,7 @@
|
|
|
275
275
|
"protomux": "^3.11.0",
|
|
276
276
|
"protomux-wakeup": "^2.9.0",
|
|
277
277
|
"rache": "^1.0.0",
|
|
278
|
-
"rag-extract": "^0.1.
|
|
278
|
+
"rag-extract": "^0.1.1",
|
|
279
279
|
"ready-guard": "^1.0.0",
|
|
280
280
|
"ready-resource": "^1.2.0",
|
|
281
281
|
"rocksdb-native": "^3.17.4",
|
package/tui/app.mjs
CHANGED
|
@@ -9,13 +9,9 @@ import { TOOLSETS } from '@qvac/harness/lib/tools/toolsets.ts'
|
|
|
9
9
|
import os from 'os'
|
|
10
10
|
import path from 'path'
|
|
11
11
|
import process from 'process'
|
|
12
|
-
import {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
oauthKeySpec,
|
|
16
|
-
scopedKey,
|
|
17
|
-
SPOTIFY_CREDENTIAL_KEY
|
|
18
|
-
} from '../dist-lib/lib/oauth/keys.js'
|
|
12
|
+
import { scopedKey } from '../dist-lib/lib/oauth/keys.js'
|
|
13
|
+
import { oauthSpecs } from '../dist-lib/lib/oauth/registry.js'
|
|
14
|
+
import { settingConfigKey } from '../dist-lib/lib/credential-pusher.js'
|
|
19
15
|
import {
|
|
20
16
|
COMPACTION_MIN_CTX_SIZE,
|
|
21
17
|
contextOptionsForModel,
|
|
@@ -42,6 +38,7 @@ import { compactionTriggerRatio } from '../dist-lib/lib/compaction.js'
|
|
|
42
38
|
import { rememberSelection } from './lib/selection.mjs'
|
|
43
39
|
import {
|
|
44
40
|
configureActions,
|
|
41
|
+
connectSlug,
|
|
45
42
|
isReady,
|
|
46
43
|
setupAction,
|
|
47
44
|
setupActions,
|
|
@@ -245,20 +242,7 @@ const COMMANDS = [
|
|
|
245
242
|
},
|
|
246
243
|
{ name: 'meshes', desc: 'list the meshes this device belongs to', palette: true },
|
|
247
244
|
{ name: 'cred', desc: 'set a credential value for this agent' },
|
|
248
|
-
{
|
|
249
|
-
name: 'connect',
|
|
250
|
-
desc: 'OAuth-connect a skill for this agent',
|
|
251
|
-
sub: [
|
|
252
|
-
{ name: 'gmail', desc: 'Google OAuth (needs GOOGLE_OAUTH_CLIENT_ID + _SECRET)' },
|
|
253
|
-
{ name: 'google-calendar', desc: 'Google OAuth (needs GOOGLE_OAUTH_CLIENT_ID + _SECRET)' },
|
|
254
|
-
{ name: 'google-docs', desc: 'Google OAuth (needs GOOGLE_OAUTH_CLIENT_ID + _SECRET)' },
|
|
255
|
-
{ name: 'google-drive', desc: 'Google OAuth (needs GOOGLE_OAUTH_CLIENT_ID + _SECRET)' },
|
|
256
|
-
{ name: 'google-sheets', desc: 'Google OAuth (needs GOOGLE_OAUTH_CLIENT_ID + _SECRET)' },
|
|
257
|
-
{ name: 'spotify', desc: 'Spotify OAuth, PKCE only (needs SPOTIFY_OAUTH_CLIENT_ID)' },
|
|
258
|
-
{ name: 'notion', desc: 'Notion MCP OAuth, PKCE + dynamic registration (no env)' },
|
|
259
|
-
{ name: 'asana', desc: 'Asana MCP OAuth, PKCE (needs ASANA_OAUTH_CLIENT_ID + _SECRET)' }
|
|
260
|
-
]
|
|
261
|
-
},
|
|
245
|
+
{ name: 'connect', desc: 'OAuth-connect a skill for this agent', palette: true },
|
|
262
246
|
{
|
|
263
247
|
name: 'my-device',
|
|
264
248
|
desc: 'CPU/GPU inventory for this device (manufacturer, cores, drivers, …)'
|
|
@@ -1738,10 +1722,8 @@ export class ChatApp {
|
|
|
1738
1722
|
' /image [model <choice> | steps <n> | size <WxH> | reset] — the agent’s image-generation defaults',
|
|
1739
1723
|
'',
|
|
1740
1724
|
'Connections — a skill that needs an account or a token (Menu ▸ Agent ▸ Connections lists them with their state)',
|
|
1741
|
-
' /connect
|
|
1742
|
-
'
|
|
1743
|
-
' /connect notion — OAuth-connect Notion MCP via PKCE + dynamic registration (no env, no secret)',
|
|
1744
|
-
' /connect asana — OAuth-connect Asana MCP via PKCE (needs ASANA_OAUTH_CLIENT_ID + ASANA_OAUTH_CLIENT_SECRET)',
|
|
1725
|
+
' /connect <skill> — OAuth-connect a skill that declares one (the Connections page lists them)',
|
|
1726
|
+
' the client app credentials come from <PROVIDER>_OAUTH_CLIENT_ID and <PROVIDER>_OAUTH_CLIENT_SECRET; a skill that registers its own client needs neither',
|
|
1745
1727
|
'',
|
|
1746
1728
|
'Voice',
|
|
1747
1729
|
' /speak <text> — synthesize speech (TTS) to a WAV file in the save dir',
|
|
@@ -2092,7 +2074,7 @@ export class ChatApp {
|
|
|
2092
2074
|
const bytes = Buffer.concat(pieces)
|
|
2093
2075
|
if (!bytes.length) return `empty download for ${att.fileName}`
|
|
2094
2076
|
const ext = { 'image/jpeg': '.jpg', 'image/png': '.png' }[att.mimeType]
|
|
2095
|
-
const file = await saveUniqueFile(this._saveDir, att.fileName, bytes, ext
|
|
2077
|
+
const file = await saveUniqueFile(this._saveDir, att.fileName, bytes, ext)
|
|
2096
2078
|
if (file) return `saved ${att.fileName} (${bytes.length}B) to ${file}`
|
|
2097
2079
|
return `not saved: 100 files named ${att.fileName} already exist in ${this._saveDir}`
|
|
2098
2080
|
})
|
|
@@ -2213,134 +2195,103 @@ export class ChatApp {
|
|
|
2213
2195
|
}
|
|
2214
2196
|
|
|
2215
2197
|
if (cmd === 'connect') {
|
|
2216
|
-
const [
|
|
2217
|
-
|
|
2218
|
-
|
|
2219
|
-
|
|
2220
|
-
|
|
2221
|
-
|
|
2222
|
-
|
|
2223
|
-
return
|
|
2198
|
+
const [slug = ''] = rest
|
|
2199
|
+
if (!slug) return notice('usage: /connect <skill> — Menu ▸ Agent ▸ Connections lists them')
|
|
2200
|
+
return run(async () => {
|
|
2201
|
+
let skills
|
|
2202
|
+
try {
|
|
2203
|
+
skills = this._skills ? await this._skills(agent.id, agent.modelName) : []
|
|
2204
|
+
} catch (error) {
|
|
2205
|
+
return `could not read the skill catalog: ${error?.message ?? error}`
|
|
2224
2206
|
}
|
|
2225
|
-
|
|
2226
|
-
|
|
2227
|
-
|
|
2228
|
-
|
|
2229
|
-
|
|
2230
|
-
credentialKey: googleSpec.credentialKey,
|
|
2231
|
-
openUrl: (url) => {
|
|
2232
|
-
this.status = fg.dim.render(`authorize in your browser: ${url}`)
|
|
2233
|
-
this._render()
|
|
2234
|
-
openInBrowser(url)
|
|
2235
|
-
}
|
|
2236
|
-
})
|
|
2237
|
-
await engine.configSet({
|
|
2238
|
-
key: credKey(agent.id, googleSpec.credentialKey),
|
|
2239
|
-
value: tokens.accessToken
|
|
2240
|
-
})
|
|
2241
|
-
await engine.configSet({
|
|
2242
|
-
key: credKey(agent.id, googleSpec.stateKey),
|
|
2243
|
-
value: JSON.stringify({
|
|
2244
|
-
refreshToken: tokens.refreshToken,
|
|
2245
|
-
expiresAt: tokens.expiresAt,
|
|
2246
|
-
clientId,
|
|
2247
|
-
clientSecret
|
|
2248
|
-
})
|
|
2249
|
-
})
|
|
2250
|
-
return `${provider} connected for agent ${agent.name} — token stored, auto-refreshes on use`
|
|
2251
|
-
})
|
|
2252
|
-
}
|
|
2253
|
-
if (provider === 'spotify') {
|
|
2254
|
-
const clientId = process.env.SPOTIFY_OAUTH_CLIENT_ID
|
|
2255
|
-
if (!clientId) {
|
|
2256
|
-
return notice('set SPOTIFY_OAUTH_CLIENT_ID, then retry')
|
|
2207
|
+
const matches = oauthSpecs(skills ?? []).filter(
|
|
2208
|
+
(candidate) => connectSlug(candidate.credentialKey) === slug
|
|
2209
|
+
)
|
|
2210
|
+
if (matches.length === 0) {
|
|
2211
|
+
return `no connectable skill named ${slug} — Menu ▸ Agent ▸ Connections`
|
|
2257
2212
|
}
|
|
2258
|
-
|
|
2259
|
-
const
|
|
2260
|
-
|
|
2261
|
-
clientId,
|
|
2262
|
-
openUrl: (url) => {
|
|
2263
|
-
this.status = fg.dim.render(`authorize in your browser: ${url}`)
|
|
2264
|
-
this._render()
|
|
2265
|
-
openInBrowser(url)
|
|
2266
|
-
}
|
|
2267
|
-
})
|
|
2268
|
-
await engine.configSet({
|
|
2269
|
-
key: credKey(agent.id, SPOTIFY_CREDENTIAL_KEY),
|
|
2270
|
-
value: tokens.accessToken
|
|
2271
|
-
})
|
|
2272
|
-
await engine.configSet({
|
|
2273
|
-
key: credKey(agent.id, SPOTIFY_OAUTH_STATE_KEY),
|
|
2274
|
-
value: JSON.stringify({
|
|
2275
|
-
refreshToken: tokens.refreshToken,
|
|
2276
|
-
expiresAt: tokens.expiresAt,
|
|
2277
|
-
clientId
|
|
2278
|
-
})
|
|
2279
|
-
})
|
|
2280
|
-
return `spotify connected for agent ${agent.name} — token stored, auto-refreshes on use`
|
|
2281
|
-
})
|
|
2282
|
-
}
|
|
2283
|
-
if (provider === 'notion') {
|
|
2284
|
-
return run(async () => {
|
|
2285
|
-
const { connectNotion, NOTION_OAUTH_STATE_KEY } = await import('../dist-lib/lib/oauth.js')
|
|
2286
|
-
const tokens = await connectNotion({
|
|
2287
|
-
openUrl: (url) => {
|
|
2288
|
-
this.status = fg.dim.render(`authorize in your browser: ${url}`)
|
|
2289
|
-
this._render()
|
|
2290
|
-
openInBrowser(url)
|
|
2291
|
-
}
|
|
2292
|
-
})
|
|
2293
|
-
await engine.configSet({
|
|
2294
|
-
key: credKey(agent.id, NOTION_MCP_CREDENTIAL_KEY),
|
|
2295
|
-
value: tokens.accessToken
|
|
2296
|
-
})
|
|
2297
|
-
await engine.configSet({
|
|
2298
|
-
key: credKey(agent.id, NOTION_OAUTH_STATE_KEY),
|
|
2299
|
-
value: JSON.stringify({
|
|
2300
|
-
refreshToken: tokens.refreshToken,
|
|
2301
|
-
expiresAt: tokens.expiresAt,
|
|
2302
|
-
clientId: tokens.clientId
|
|
2303
|
-
})
|
|
2304
|
-
})
|
|
2305
|
-
return `notion connected for agent ${agent.name} — token stored, auto-refreshes on use`
|
|
2306
|
-
})
|
|
2307
|
-
}
|
|
2308
|
-
if (provider === 'asana') {
|
|
2309
|
-
const clientId = process.env.ASANA_OAUTH_CLIENT_ID
|
|
2310
|
-
const clientSecret = process.env.ASANA_OAUTH_CLIENT_SECRET
|
|
2311
|
-
if (!clientId || !clientSecret) {
|
|
2312
|
-
return notice('set ASANA_OAUTH_CLIENT_ID and ASANA_OAUTH_CLIENT_SECRET, then retry')
|
|
2213
|
+
if (matches.length > 1) {
|
|
2214
|
+
const keys = matches.map((m) => m.credentialKey).join(', ')
|
|
2215
|
+
return `${slug} is ambiguous — matches ${keys}, use the full credential key`
|
|
2313
2216
|
}
|
|
2314
|
-
|
|
2315
|
-
|
|
2316
|
-
|
|
2217
|
+
const [spec] = matches
|
|
2218
|
+
// the setup fields are stored per declaring skill, and a `secret` one lands in the
|
|
2219
|
+
// credential namespace rather than the settings one (see lib/core/skill-secrets.ts)
|
|
2220
|
+
const owner = (skills ?? []).find((skill) =>
|
|
2221
|
+
(skill.setup?.routes ?? []).some((route) => route.credentialKey === spec.credentialKey)
|
|
2222
|
+
)
|
|
2223
|
+
const ownerRoute = (owner?.setup?.routes ?? []).find(
|
|
2224
|
+
(route) => route.credentialKey === spec.credentialKey
|
|
2225
|
+
)
|
|
2226
|
+
const storedField = async (name) => {
|
|
2227
|
+
const field = (ownerRoute?.fields ?? []).find((entry) => entry.key === name)
|
|
2228
|
+
if (!field || !owner) return ''
|
|
2229
|
+
const key =
|
|
2230
|
+
field.secret === true
|
|
2231
|
+
? credKey(agent.id, field.key)
|
|
2232
|
+
: settingConfigKey(agent.id, owner.name, field.key)
|
|
2233
|
+
const { value } = await engine.configGet({ key })
|
|
2234
|
+
return typeof value === 'string' ? value : ''
|
|
2235
|
+
}
|
|
2236
|
+
const env = spec.provider.toUpperCase().replaceAll('-', '_')
|
|
2237
|
+
const idVar = `${env}_OAUTH_CLIENT_ID`
|
|
2238
|
+
const secretVar = `${env}_OAUTH_CLIENT_SECRET`
|
|
2239
|
+
const needsSecret = spec.tokenAuth !== 'pkce-only'
|
|
2240
|
+
const clientId = (await storedField('clientId')) || process.env[idVar] || ''
|
|
2241
|
+
const clientSecret = (await storedField('clientSecret')) || process.env[secretVar] || ''
|
|
2242
|
+
// registrationEndpoint implies pkce-only (keys.ts specFromRoute), so a DCR skill never
|
|
2243
|
+
// reaches the secret check below demanding one it has no use for
|
|
2244
|
+
if (!clientId && !spec.registrationEndpoint) {
|
|
2245
|
+
return needsSecret
|
|
2246
|
+
? `set ${idVar} and ${secretVar}, then retry`
|
|
2247
|
+
: `set ${idVar}, then retry`
|
|
2248
|
+
}
|
|
2249
|
+
if (needsSecret && !clientSecret) return `set ${idVar} and ${secretVar}, then retry`
|
|
2250
|
+
|
|
2251
|
+
const { buildProviderConfig, runOAuthFlow } = await import('../dist-lib/lib/oauth.js')
|
|
2252
|
+
let registeredClientId = ''
|
|
2253
|
+
const tokens = await runOAuthFlow(
|
|
2254
|
+
buildProviderConfig(spec, {
|
|
2317
2255
|
clientId,
|
|
2318
|
-
clientSecret
|
|
2256
|
+
...(needsSecret ? { clientSecret } : {})
|
|
2257
|
+
}),
|
|
2258
|
+
{
|
|
2319
2259
|
openUrl: (url) => {
|
|
2320
2260
|
this.status = fg.dim.render(`authorize in your browser: ${url}`)
|
|
2321
2261
|
this._render()
|
|
2322
2262
|
openInBrowser(url)
|
|
2263
|
+
},
|
|
2264
|
+
getClientId: async () => {
|
|
2265
|
+
// a prior run may have registered a client already — read it back from state
|
|
2266
|
+
// instead of re-registering a fresh one at the provider every /connect
|
|
2267
|
+
const { value } = await engine.configGet({ key: credKey(agent.id, spec.stateKey) })
|
|
2268
|
+
try {
|
|
2269
|
+
const state = typeof value === 'string' ? JSON.parse(value) : null
|
|
2270
|
+
return state?.clientId || undefined
|
|
2271
|
+
} catch {
|
|
2272
|
+
return undefined
|
|
2273
|
+
}
|
|
2274
|
+
},
|
|
2275
|
+
saveClientId: async (id) => {
|
|
2276
|
+
registeredClientId = id
|
|
2323
2277
|
}
|
|
2278
|
+
}
|
|
2279
|
+
)
|
|
2280
|
+
await engine.configSet({
|
|
2281
|
+
key: credKey(agent.id, spec.credentialKey),
|
|
2282
|
+
value: tokens.accessToken
|
|
2283
|
+
})
|
|
2284
|
+
await engine.configSet({
|
|
2285
|
+
key: credKey(agent.id, spec.stateKey),
|
|
2286
|
+
value: JSON.stringify({
|
|
2287
|
+
refreshToken: tokens.refreshToken,
|
|
2288
|
+
expiresAt: tokens.expiresAt,
|
|
2289
|
+
clientId: clientId || registeredClientId,
|
|
2290
|
+
...(needsSecret ? { clientSecret } : {})
|
|
2324
2291
|
})
|
|
2325
|
-
await engine.configSet({
|
|
2326
|
-
key: credKey(agent.id, ASANA_MCP_CREDENTIAL_KEY),
|
|
2327
|
-
value: tokens.accessToken
|
|
2328
|
-
})
|
|
2329
|
-
await engine.configSet({
|
|
2330
|
-
key: credKey(agent.id, ASANA_OAUTH_STATE_KEY),
|
|
2331
|
-
value: JSON.stringify({
|
|
2332
|
-
refreshToken: tokens.refreshToken,
|
|
2333
|
-
expiresAt: tokens.expiresAt,
|
|
2334
|
-
clientId,
|
|
2335
|
-
clientSecret
|
|
2336
|
-
})
|
|
2337
|
-
})
|
|
2338
|
-
return `asana connected for agent ${agent.name} — token stored, auto-refreshes on use`
|
|
2339
2292
|
})
|
|
2340
|
-
|
|
2341
|
-
|
|
2342
|
-
'usage: /connect gmail|google-calendar|google-docs|google-drive|google-sheets|spotify|notion|asana'
|
|
2343
|
-
)
|
|
2293
|
+
return `${slug} connected for agent ${agent.name} — token stored, auto-refreshes on use`
|
|
2294
|
+
})
|
|
2344
2295
|
}
|
|
2345
2296
|
|
|
2346
2297
|
if (cmd === 'cred') {
|
|
@@ -3237,23 +3188,15 @@ export class ChatApp {
|
|
|
3237
3188
|
}
|
|
3238
3189
|
}
|
|
3239
3190
|
|
|
3191
|
+
// The fallback page when the engine cannot report skills: which skills are connectable is
|
|
3192
|
+
// theirs to declare, so all this can offer is the command itself.
|
|
3240
3193
|
_connectMenu() {
|
|
3241
3194
|
return {
|
|
3242
3195
|
title: 'Connections',
|
|
3243
3196
|
cursor: 0,
|
|
3244
3197
|
entries: [
|
|
3245
|
-
{ label: 'Connect
|
|
3246
|
-
{
|
|
3247
|
-
label: 'Connect Google Calendar',
|
|
3248
|
-
hint: 'OAuth Calendar',
|
|
3249
|
-
command: '/connect google-calendar'
|
|
3250
|
-
},
|
|
3251
|
-
{ label: 'Connect Google Docs', hint: 'OAuth Docs', command: '/connect google-docs' },
|
|
3252
|
-
{ label: 'Connect Google Drive', hint: 'OAuth Drive', command: '/connect google-drive' },
|
|
3253
|
-
{ label: 'Connect Google Sheets', hint: 'OAuth Sheets', command: '/connect google-sheets' },
|
|
3254
|
-
{ label: 'Connect Spotify', hint: 'OAuth Spotify (PKCE)', command: '/connect spotify' },
|
|
3255
|
-
{ label: 'Connect Notion', hint: 'OAuth Notion MCP', command: '/connect notion' },
|
|
3256
|
-
{ label: 'Connect Asana', hint: 'OAuth Asana MCP', command: '/connect asana' }
|
|
3198
|
+
{ label: 'Connect a skill…', hint: '/connect <skill>', prefill: '/connect ' },
|
|
3199
|
+
{ label: 'Set a credential…', hint: '/cred <key> <value>', prefill: '/cred ' }
|
|
3257
3200
|
]
|
|
3258
3201
|
}
|
|
3259
3202
|
}
|