wip: lazy adapter imports to break bundle cycles
parent
129fe1e350
commit
552269d8f9
|
|
@ -1,34 +1,26 @@
|
||||||
import { Effect, Option } from "effect"
|
import { Option } from "effect"
|
||||||
|
import { run } from "@/effect/run"
|
||||||
import { Account as S, type AccountError, type AccessToken, AccountID, Info as Model, OrgID } from "./effect"
|
import { type AccessToken, AccountID, Info as Model, OrgID } from "./effect"
|
||||||
|
|
||||||
export { AccessToken, AccountID, OrgID } from "./effect"
|
export { AccessToken, AccountID, OrgID } from "./effect"
|
||||||
|
|
||||||
import { runtime } from "@/effect/runtime"
|
const svc = () => import("./effect").then((m) => m.Account.Service)
|
||||||
|
|
||||||
function runSync<A>(f: (service: S.Interface) => Effect.Effect<A, AccountError>) {
|
|
||||||
return runtime.runSync(S.Service.use(f))
|
|
||||||
}
|
|
||||||
|
|
||||||
function runPromise<A>(f: (service: S.Interface) => Effect.Effect<A, AccountError>) {
|
|
||||||
return runtime.runPromise(S.Service.use(f))
|
|
||||||
}
|
|
||||||
|
|
||||||
export namespace Account {
|
export namespace Account {
|
||||||
export const Info = Model
|
export const Info = Model
|
||||||
export type Info = Model
|
export type Info = Model
|
||||||
|
|
||||||
export function active(): Info | undefined {
|
export async function active(): Promise<Info | undefined> {
|
||||||
return Option.getOrUndefined(runSync((service) => service.active()))
|
return Option.getOrUndefined(await run((await svc()).use((s) => s.active())))
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function config(accountID: AccountID, orgID: OrgID): Promise<Record<string, unknown> | undefined> {
|
export async function config(accountID: AccountID, orgID: OrgID): Promise<Record<string, unknown> | undefined> {
|
||||||
const config = await runPromise((service) => service.config(accountID, orgID))
|
const config = await run((await svc()).use((s) => s.config(accountID, orgID)))
|
||||||
return Option.getOrUndefined(config)
|
return Option.getOrUndefined(config)
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function token(accountID: AccountID): Promise<AccessToken | undefined> {
|
export async function token(accountID: AccountID): Promise<AccessToken | undefined> {
|
||||||
const token = await runPromise((service) => service.token(accountID))
|
const token = await run((await svc()).use((s) => s.token(accountID)))
|
||||||
return Option.getOrUndefined(token)
|
return Option.getOrUndefined(token)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,9 @@
|
||||||
import { Effect } from "effect"
|
|
||||||
import z from "zod"
|
import z from "zod"
|
||||||
import { runtime } from "@/effect/runtime"
|
import { run } from "@/effect/run"
|
||||||
import * as S from "./effect"
|
|
||||||
|
|
||||||
export { OAUTH_DUMMY_KEY } from "./effect"
|
export { OAUTH_DUMMY_KEY } from "./effect"
|
||||||
|
|
||||||
function runPromise<A>(f: (service: S.Auth.Interface) => Effect.Effect<A, S.AuthError>) {
|
const svc = () => import("./effect").then((m) => m.Auth.Service)
|
||||||
return runtime.runPromise(S.Auth.Service.use(f))
|
|
||||||
}
|
|
||||||
|
|
||||||
export namespace Auth {
|
export namespace Auth {
|
||||||
export const Oauth = z
|
export const Oauth = z
|
||||||
|
|
@ -40,18 +36,18 @@ export namespace Auth {
|
||||||
export type Info = z.infer<typeof Info>
|
export type Info = z.infer<typeof Info>
|
||||||
|
|
||||||
export async function get(providerID: string) {
|
export async function get(providerID: string) {
|
||||||
return runPromise((service) => service.get(providerID))
|
return run((await svc()).use((s) => s.get(providerID)))
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function all(): Promise<Record<string, Info>> {
|
export async function all(): Promise<Record<string, Info>> {
|
||||||
return runPromise((service) => service.all())
|
return run((await svc()).use((s) => s.all()))
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function set(key: string, info: Info) {
|
export async function set(key: string, info: Info) {
|
||||||
return runPromise((service) => service.set(key, info))
|
return run((await svc()).use((s) => s.set(key, info)))
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function remove(key: string) {
|
export async function remove(key: string) {
|
||||||
return runPromise((service) => service.remove(key))
|
return run((await svc()).use((s) => s.remove(key)))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,6 @@ import fs from "fs/promises"
|
||||||
import { lazy } from "../util/lazy"
|
import { lazy } from "../util/lazy"
|
||||||
import { NamedError } from "@opencode-ai/util/error"
|
import { NamedError } from "@opencode-ai/util/error"
|
||||||
import { Flag } from "../flag/flag"
|
import { Flag } from "../flag/flag"
|
||||||
import { Auth } from "../auth"
|
|
||||||
import { Env } from "../env"
|
import { Env } from "../env"
|
||||||
import {
|
import {
|
||||||
type ParseError as JsoncParseError,
|
type ParseError as JsoncParseError,
|
||||||
|
|
@ -33,12 +32,14 @@ import { Glob } from "../util/glob"
|
||||||
import { PackageRegistry } from "@/bun/registry"
|
import { PackageRegistry } from "@/bun/registry"
|
||||||
import { proxied } from "@/util/proxied"
|
import { proxied } from "@/util/proxied"
|
||||||
import { iife } from "@/util/iife"
|
import { iife } from "@/util/iife"
|
||||||
import { Account } from "@/account"
|
|
||||||
import { ConfigPaths } from "./paths"
|
import { ConfigPaths } from "./paths"
|
||||||
import { Filesystem } from "@/util/filesystem"
|
import { Filesystem } from "@/util/filesystem"
|
||||||
import { Process } from "@/util/process"
|
import { Process } from "@/util/process"
|
||||||
import { Lock } from "@/util/lock"
|
import { Lock } from "@/util/lock"
|
||||||
|
|
||||||
|
const auth = lazy(() => import("../auth").then((x) => x.Auth))
|
||||||
|
const account = lazy(() => import("@/account").then((x) => x.Account))
|
||||||
|
|
||||||
export namespace Config {
|
export namespace Config {
|
||||||
const ModelId = z.string().meta({ $ref: "https://models.dev/model-schema.json#/$defs/Model" })
|
const ModelId = z.string().meta({ $ref: "https://models.dev/model-schema.json#/$defs/Model" })
|
||||||
|
|
||||||
|
|
@ -76,7 +77,7 @@ export namespace Config {
|
||||||
}
|
}
|
||||||
|
|
||||||
export const state = Instance.state(async () => {
|
export const state = Instance.state(async () => {
|
||||||
const auth = await Auth.all()
|
const entries = await (await auth()).all()
|
||||||
|
|
||||||
// Config loading order (low -> high precedence): https://opencode.ai/docs/config#precedence-order
|
// Config loading order (low -> high precedence): https://opencode.ai/docs/config#precedence-order
|
||||||
// 1) Remote .well-known/opencode (org defaults)
|
// 1) Remote .well-known/opencode (org defaults)
|
||||||
|
|
@ -87,7 +88,7 @@ export namespace Config {
|
||||||
// 6) Inline config (OPENCODE_CONFIG_CONTENT)
|
// 6) Inline config (OPENCODE_CONFIG_CONTENT)
|
||||||
// Managed config directory is enterprise-only and always overrides everything above.
|
// Managed config directory is enterprise-only and always overrides everything above.
|
||||||
let result: Info = {}
|
let result: Info = {}
|
||||||
for (const [key, value] of Object.entries(auth)) {
|
for (const [key, value] of Object.entries(entries)) {
|
||||||
if (value.type === "wellknown") {
|
if (value.type === "wellknown") {
|
||||||
const url = key.replace(/\/+$/, "")
|
const url = key.replace(/\/+$/, "")
|
||||||
process.env[value.key] = value.token
|
process.env[value.key] = value.token
|
||||||
|
|
@ -177,13 +178,11 @@ export namespace Config {
|
||||||
log.debug("loaded custom config from OPENCODE_CONFIG_CONTENT")
|
log.debug("loaded custom config from OPENCODE_CONFIG_CONTENT")
|
||||||
}
|
}
|
||||||
|
|
||||||
const active = Account.active()
|
const acct = await account()
|
||||||
|
const active = await acct.active()
|
||||||
if (active?.active_org_id) {
|
if (active?.active_org_id) {
|
||||||
try {
|
try {
|
||||||
const [config, token] = await Promise.all([
|
const [config, token] = await Promise.all([acct.config(active.id, active.active_org_id), acct.token(active.id)])
|
||||||
Account.config(active.id, active.active_org_id),
|
|
||||||
Account.token(active.id),
|
|
||||||
])
|
|
||||||
if (token) {
|
if (token) {
|
||||||
process.env["OPENCODE_CONSOLE_TOKEN"] = token
|
process.env["OPENCODE_CONSOLE_TOKEN"] = token
|
||||||
Env.set("OPENCODE_CONSOLE_TOKEN", token)
|
Env.set("OPENCODE_CONSOLE_TOKEN", token)
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,21 @@
|
||||||
|
import type { Effect } from "effect"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Lazy wrappers that defer the import of @/effect/runtime to call time.
|
||||||
|
*
|
||||||
|
* Adapter modules must not eagerly import @/effect/runtime — or even
|
||||||
|
* their own service modules — because bun's bundler can evaluate them
|
||||||
|
* before their dependencies have finished initializing.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** For global services (Auth, Account, etc.) */
|
||||||
|
export async function run<A, E>(effect: Effect.Effect<A, E, any>): Promise<A> {
|
||||||
|
const { runtime } = await import("@/effect/runtime")
|
||||||
|
return runtime.runPromise(effect)
|
||||||
|
}
|
||||||
|
|
||||||
|
/** For instance-scoped services (Skill, Snapshot, Question, etc.) */
|
||||||
|
export async function runInstance<A, E>(effect: Effect.Effect<A, E, any>): Promise<A> {
|
||||||
|
const { runPromiseInstance } = await import("@/effect/runtime")
|
||||||
|
return runPromiseInstance(effect)
|
||||||
|
}
|
||||||
|
|
@ -9,7 +9,7 @@ import { Instance } from "@/project/instance"
|
||||||
|
|
||||||
export const runtime = ManagedRuntime.make(
|
export const runtime = ManagedRuntime.make(
|
||||||
Layer.mergeAll(
|
Layer.mergeAll(
|
||||||
Account.defaultLayer, //
|
Account.defaultLayer,
|
||||||
Installation.defaultLayer,
|
Installation.defaultLayer,
|
||||||
Truncate.defaultLayer,
|
Truncate.defaultLayer,
|
||||||
Instances.layer,
|
Instances.layer,
|
||||||
|
|
|
||||||
|
|
@ -1,40 +1,37 @@
|
||||||
import { runPromiseInstance } from "@/effect/runtime"
|
import { runInstance } from "@/effect/run"
|
||||||
import { File as S } from "./service"
|
import { File as S } from "./service"
|
||||||
|
|
||||||
|
const svc = () => import("./service").then((m) => m.File.Service)
|
||||||
|
|
||||||
export namespace File {
|
export namespace File {
|
||||||
export const Info = S.Info
|
export const Info = S.Info
|
||||||
export type Info = S.Info
|
export type Info = S.Info
|
||||||
|
|
||||||
export const Node = S.Node
|
export const Node = S.Node
|
||||||
export type Node = S.Node
|
export type Node = S.Node
|
||||||
|
|
||||||
export const Content = S.Content
|
export const Content = S.Content
|
||||||
export type Content = S.Content
|
export type Content = S.Content
|
||||||
|
|
||||||
export const Event = S.Event
|
export const Event = S.Event
|
||||||
|
|
||||||
export type Interface = S.Interface
|
export type Interface = S.Interface
|
||||||
|
|
||||||
export const Service = S.Service
|
export const Service = S.Service
|
||||||
export const layer = S.layer
|
export const layer = S.layer
|
||||||
|
|
||||||
export function init() {
|
export async function init() {
|
||||||
return runPromiseInstance(S.Service.use((svc) => svc.init()))
|
return runInstance((await svc()).use((s) => s.init()))
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function status() {
|
export async function status() {
|
||||||
return runPromiseInstance(S.Service.use((svc) => svc.status()))
|
return runInstance((await svc()).use((s) => s.status()))
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function read(file: string): Promise<Content> {
|
export async function read(file: string): Promise<Content> {
|
||||||
return runPromiseInstance(S.Service.use((svc) => svc.read(file)))
|
return runInstance((await svc()).use((s) => s.read(file)))
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function list(dir?: string) {
|
export async function list(dir?: string) {
|
||||||
return runPromiseInstance(S.Service.use((svc) => svc.list(dir)))
|
return runInstance((await svc()).use((s) => s.list(dir)))
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function search(input: { query: string; limit?: number; dirs?: boolean; type?: "file" | "directory" }) {
|
export async function search(input: { query: string; limit?: number; dirs?: boolean; type?: "file" | "directory" }) {
|
||||||
return runPromiseInstance(S.Service.use((svc) => svc.search(input)))
|
return runInstance((await svc()).use((s) => s.search(input)))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,28 +1,28 @@
|
||||||
import { runPromiseInstance } from "@/effect/runtime"
|
import { runInstance } from "@/effect/run"
|
||||||
import type { SessionID } from "@/session/schema"
|
import type { SessionID } from "@/session/schema"
|
||||||
import { FileTime as S } from "./time-service"
|
import { FileTime as S } from "./time-service"
|
||||||
|
|
||||||
|
const svc = () => import("./time-service").then((m) => m.FileTime.Service)
|
||||||
|
|
||||||
export namespace FileTime {
|
export namespace FileTime {
|
||||||
export type Stamp = S.Stamp
|
export type Stamp = S.Stamp
|
||||||
|
|
||||||
export type Interface = S.Interface
|
export type Interface = S.Interface
|
||||||
|
|
||||||
export const Service = S.Service
|
export const Service = S.Service
|
||||||
export const layer = S.layer
|
export const layer = S.layer
|
||||||
|
|
||||||
export function read(sessionID: SessionID, file: string) {
|
export async function read(sessionID: SessionID, file: string) {
|
||||||
return runPromiseInstance(S.Service.use((s) => s.read(sessionID, file)))
|
return runInstance((await svc()).use((s) => s.read(sessionID, file)))
|
||||||
}
|
}
|
||||||
|
|
||||||
export function get(sessionID: SessionID, file: string) {
|
export async function get(sessionID: SessionID, file: string) {
|
||||||
return runPromiseInstance(S.Service.use((s) => s.get(sessionID, file)))
|
return runInstance((await svc()).use((s) => s.get(sessionID, file)))
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function assert(sessionID: SessionID, filepath: string) {
|
export async function assert(sessionID: SessionID, filepath: string) {
|
||||||
return runPromiseInstance(S.Service.use((s) => s.assert(sessionID, filepath)))
|
return runInstance((await svc()).use((s) => s.assert(sessionID, filepath)))
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function withLock<T>(filepath: string, fn: () => Promise<T>): Promise<T> {
|
export async function withLock<T>(filepath: string, fn: () => Promise<T>): Promise<T> {
|
||||||
return runPromiseInstance(S.Service.use((s) => s.withLock(filepath, fn)))
|
return runInstance((await svc()).use((s) => s.withLock(filepath, fn)))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,16 +1,9 @@
|
||||||
import { runPromiseInstance } from "@/effect/runtime"
|
import { runInstance } from "@/effect/run"
|
||||||
import { Format as S } from "./service"
|
|
||||||
|
const svc = () => import("./service").then((m) => m.Format.Service)
|
||||||
|
|
||||||
export namespace Format {
|
export namespace Format {
|
||||||
export const Status = S.Status
|
|
||||||
export type Status = S.Status
|
|
||||||
|
|
||||||
export type Interface = S.Interface
|
|
||||||
|
|
||||||
export const Service = S.Service
|
|
||||||
export const layer = S.layer
|
|
||||||
|
|
||||||
export async function status() {
|
export async function status() {
|
||||||
return runPromiseInstance(S.Service.use((s) => s.status()))
|
return runInstance((await svc()).use((s) => s.status()))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,52 +1,43 @@
|
||||||
import { runPromiseInstance } from "@/effect/runtime"
|
import { runInstance } from "@/effect/run"
|
||||||
import { fn } from "@/util/fn"
|
|
||||||
import z from "zod"
|
|
||||||
import { Permission as S } from "./service"
|
import { Permission as S } from "./service"
|
||||||
|
|
||||||
|
const svc = () => import("./service").then((m) => m.Permission.Service)
|
||||||
|
|
||||||
export namespace PermissionNext {
|
export namespace PermissionNext {
|
||||||
export const Action = S.Action
|
export const Action = S.Action
|
||||||
export type Action = S.Action
|
export type Action = S.Action
|
||||||
|
|
||||||
export const Rule = S.Rule
|
export const Rule = S.Rule
|
||||||
export type Rule = S.Rule
|
export type Rule = S.Rule
|
||||||
|
|
||||||
export const Ruleset = S.Ruleset
|
|
||||||
export type Ruleset = S.Ruleset
|
export type Ruleset = S.Ruleset
|
||||||
|
|
||||||
export const Request = S.Request
|
export const Request = S.Request
|
||||||
export type Request = S.Request
|
export type Request = S.Request
|
||||||
|
|
||||||
export const Reply = S.Reply
|
export const Reply = S.Reply
|
||||||
export type Reply = S.Reply
|
export type Reply = S.Reply
|
||||||
|
|
||||||
export const Approval = S.Approval
|
export const Approval = S.Approval
|
||||||
export type Approval = z.infer<typeof S.Approval>
|
|
||||||
|
|
||||||
export const Event = S.Event
|
export const Event = S.Event
|
||||||
|
|
||||||
export const RejectedError = S.RejectedError
|
export const RejectedError = S.RejectedError
|
||||||
export const CorrectedError = S.CorrectedError
|
export const CorrectedError = S.CorrectedError
|
||||||
export const DeniedError = S.DeniedError
|
export const DeniedError = S.DeniedError
|
||||||
export type Error = S.Error
|
export type Error = S.Error
|
||||||
|
|
||||||
export const AskInput = S.AskInput
|
export const AskInput = S.AskInput
|
||||||
export const ReplyInput = S.ReplyInput
|
export const ReplyInput = S.ReplyInput
|
||||||
|
|
||||||
export type Interface = S.Interface
|
export type Interface = S.Interface
|
||||||
|
|
||||||
export const Service = S.Service
|
export const Service = S.Service
|
||||||
export const layer = S.layer
|
export const layer = S.layer
|
||||||
|
|
||||||
export const evaluate = S.evaluate
|
export const evaluate = S.evaluate
|
||||||
export const fromConfig = S.fromConfig
|
export const fromConfig = S.fromConfig
|
||||||
export const merge = S.merge
|
export const merge = S.merge
|
||||||
export const disabled = S.disabled
|
export const disabled = S.disabled
|
||||||
|
|
||||||
export const ask = fn(S.AskInput, async (input) => runPromiseInstance(S.Service.use((s) => s.ask(input))))
|
export async function ask(input: S.AskInput) {
|
||||||
|
return runInstance((await svc()).use((s) => s.ask(input)))
|
||||||
|
}
|
||||||
|
|
||||||
export const reply = fn(S.ReplyInput, async (input) => runPromiseInstance(S.Service.use((s) => s.reply(input))))
|
export async function reply(input: S.ReplyInput) {
|
||||||
|
return runInstance((await svc()).use((s) => s.reply(input)))
|
||||||
|
}
|
||||||
|
|
||||||
export async function list() {
|
export async function list() {
|
||||||
return runPromiseInstance(S.Service.use((s) => s.list()))
|
return runInstance((await svc()).use((s) => s.list()))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -105,16 +105,18 @@ export namespace Permission {
|
||||||
export const AskInput = Request.partial({ id: true }).extend({
|
export const AskInput = Request.partial({ id: true }).extend({
|
||||||
ruleset: Ruleset,
|
ruleset: Ruleset,
|
||||||
})
|
})
|
||||||
|
export type AskInput = z.infer<typeof AskInput>
|
||||||
|
|
||||||
export const ReplyInput = z.object({
|
export const ReplyInput = z.object({
|
||||||
requestID: PermissionID.zod,
|
requestID: PermissionID.zod,
|
||||||
reply: Reply,
|
reply: Reply,
|
||||||
message: z.string().optional(),
|
message: z.string().optional(),
|
||||||
})
|
})
|
||||||
|
export type ReplyInput = z.infer<typeof ReplyInput>
|
||||||
|
|
||||||
export interface Interface {
|
export interface Interface {
|
||||||
readonly ask: (input: z.infer<typeof AskInput>) => Effect.Effect<void, Error>
|
readonly ask: (input: AskInput) => Effect.Effect<void, Error>
|
||||||
readonly reply: (input: z.infer<typeof ReplyInput>) => Effect.Effect<void>
|
readonly reply: (input: ReplyInput) => Effect.Effect<void>
|
||||||
readonly list: () => Effect.Effect<Request[]>
|
readonly list: () => Effect.Effect<Request[]>
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -140,7 +142,7 @@ export namespace Permission {
|
||||||
const pending = new Map<PermissionID, PendingEntry>()
|
const pending = new Map<PermissionID, PendingEntry>()
|
||||||
const approved: Ruleset = row?.data ?? []
|
const approved: Ruleset = row?.data ?? []
|
||||||
|
|
||||||
const ask = Effect.fn("Permission.ask")(function* (input: z.infer<typeof AskInput>) {
|
const ask = Effect.fn("Permission.ask")(function* (input: AskInput) {
|
||||||
const { ruleset, ...request } = input
|
const { ruleset, ...request } = input
|
||||||
let needsAsk = false
|
let needsAsk = false
|
||||||
|
|
||||||
|
|
@ -176,7 +178,7 @@ export namespace Permission {
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
const reply = Effect.fn("Permission.reply")(function* (input: z.infer<typeof ReplyInput>) {
|
const reply = Effect.fn("Permission.reply")(function* (input: ReplyInput) {
|
||||||
const existing = pending.get(input.requestID)
|
const existing = pending.get(input.requestID)
|
||||||
if (!existing) return
|
if (!existing) return
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,30 +1,28 @@
|
||||||
import { runPromiseInstance } from "@/effect/runtime"
|
import { runInstance } from "@/effect/run"
|
||||||
import { fn } from "@/util/fn"
|
import { fn } from "@/util/fn"
|
||||||
import { ProviderID } from "./schema"
|
import { ProviderID } from "./schema"
|
||||||
import z from "zod"
|
import z from "zod"
|
||||||
import { ProviderAuth as S } from "./auth-service"
|
import { ProviderAuth as S } from "./auth-service"
|
||||||
|
|
||||||
|
const svc = () => import("./auth-service").then((m) => m.ProviderAuth.Service)
|
||||||
|
|
||||||
export namespace ProviderAuth {
|
export namespace ProviderAuth {
|
||||||
export const Method = S.Method
|
export const Method = S.Method
|
||||||
export type Method = S.Method
|
export type Method = S.Method
|
||||||
|
|
||||||
export const Authorization = S.Authorization
|
export const Authorization = S.Authorization
|
||||||
export type Authorization = S.Authorization
|
export type Authorization = S.Authorization
|
||||||
|
|
||||||
export const OauthMissing = S.OauthMissing
|
export const OauthMissing = S.OauthMissing
|
||||||
export const OauthCodeMissing = S.OauthCodeMissing
|
export const OauthCodeMissing = S.OauthCodeMissing
|
||||||
export const OauthCallbackFailed = S.OauthCallbackFailed
|
export const OauthCallbackFailed = S.OauthCallbackFailed
|
||||||
export const ValidationFailed = S.ValidationFailed
|
export const ValidationFailed = S.ValidationFailed
|
||||||
export type Error = S.Error
|
export type Error = S.Error
|
||||||
|
|
||||||
export type Interface = S.Interface
|
export type Interface = S.Interface
|
||||||
|
|
||||||
export const Service = S.Service
|
export const Service = S.Service
|
||||||
export const layer = S.layer
|
export const layer = S.layer
|
||||||
export const defaultLayer = S.defaultLayer
|
export const defaultLayer = S.defaultLayer
|
||||||
|
|
||||||
export async function methods() {
|
export async function methods() {
|
||||||
return runPromiseInstance(S.Service.use((svc) => svc.methods()))
|
return runInstance((await svc()).use((s) => s.methods()))
|
||||||
}
|
}
|
||||||
|
|
||||||
export const authorize = fn(
|
export const authorize = fn(
|
||||||
|
|
@ -34,7 +32,7 @@ export namespace ProviderAuth {
|
||||||
inputs: z.record(z.string(), z.string()).optional(),
|
inputs: z.record(z.string(), z.string()).optional(),
|
||||||
}),
|
}),
|
||||||
async (input): Promise<Authorization | undefined> =>
|
async (input): Promise<Authorization | undefined> =>
|
||||||
runPromiseInstance(S.Service.use((svc) => svc.authorize(input))),
|
runInstance((await svc()).use((s) => s.authorize(input))),
|
||||||
)
|
)
|
||||||
|
|
||||||
export const callback = fn(
|
export const callback = fn(
|
||||||
|
|
@ -43,6 +41,6 @@ export namespace ProviderAuth {
|
||||||
method: z.number(),
|
method: z.number(),
|
||||||
code: z.string().optional(),
|
code: z.string().optional(),
|
||||||
}),
|
}),
|
||||||
async (input) => runPromiseInstance(S.Service.use((svc) => svc.callback(input))),
|
async (input) => runInstance((await svc()).use((s) => s.callback(input))),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,29 +1,24 @@
|
||||||
import { runPromiseInstance } from "@/effect/runtime"
|
import { runInstance } from "@/effect/run"
|
||||||
import type { MessageID, SessionID } from "@/session/schema"
|
import type { MessageID, SessionID } from "@/session/schema"
|
||||||
import type { QuestionID } from "./schema"
|
import type { QuestionID } from "./schema"
|
||||||
import { Question as S } from "./service"
|
import { Question as S } from "./service"
|
||||||
|
|
||||||
export namespace Question {
|
const svc = () => import("./service").then((m) => m.Question.Service)
|
||||||
export const Option = S.Option
|
|
||||||
export type Option = S.Option
|
|
||||||
|
|
||||||
|
export namespace Question {
|
||||||
export const Info = S.Info
|
export const Info = S.Info
|
||||||
export type Info = S.Info
|
export type Info = S.Info
|
||||||
|
|
||||||
export const Request = S.Request
|
export const Request = S.Request
|
||||||
export type Request = S.Request
|
export type Request = S.Request
|
||||||
|
|
||||||
export const Answer = S.Answer
|
export const Answer = S.Answer
|
||||||
export type Answer = S.Answer
|
export type Answer = S.Answer
|
||||||
|
|
||||||
export const Reply = S.Reply
|
export const Reply = S.Reply
|
||||||
export type Reply = S.Reply
|
export type Reply = S.Reply
|
||||||
|
export const Option = S.Option
|
||||||
|
export type Option = S.Option
|
||||||
export const Event = S.Event
|
export const Event = S.Event
|
||||||
export const RejectedError = S.RejectedError
|
export const RejectedError = S.RejectedError
|
||||||
|
|
||||||
export type Interface = S.Interface
|
export type Interface = S.Interface
|
||||||
|
|
||||||
export const Service = S.Service
|
export const Service = S.Service
|
||||||
export const layer = S.layer
|
export const layer = S.layer
|
||||||
|
|
||||||
|
|
@ -32,18 +27,18 @@ export namespace Question {
|
||||||
questions: Info[]
|
questions: Info[]
|
||||||
tool?: { messageID: MessageID; callID: string }
|
tool?: { messageID: MessageID; callID: string }
|
||||||
}): Promise<Answer[]> {
|
}): Promise<Answer[]> {
|
||||||
return runPromiseInstance(S.Service.use((s) => s.ask(input)))
|
return runInstance((await svc()).use((s) => s.ask(input)))
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function reply(input: { requestID: QuestionID; answers: Answer[] }) {
|
export async function reply(input: { requestID: QuestionID; answers: Answer[] }) {
|
||||||
return runPromiseInstance(S.Service.use((s) => s.reply(input)))
|
return runInstance((await svc()).use((s) => s.reply(input)))
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function reject(requestID: QuestionID) {
|
export async function reject(requestID: QuestionID) {
|
||||||
return runPromiseInstance(S.Service.use((s) => s.reject(requestID)))
|
return runInstance((await svc()).use((s) => s.reject(requestID)))
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function list() {
|
export async function list() {
|
||||||
return runPromiseInstance(S.Service.use((s) => s.list()))
|
return runInstance((await svc()).use((s) => s.list()))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,8 @@
|
||||||
import { Hono } from "hono"
|
import { Hono } from "hono"
|
||||||
import { describeRoute, validator, resolver } from "hono-openapi"
|
import { describeRoute, validator, resolver } from "hono-openapi"
|
||||||
import z from "zod"
|
import z from "zod"
|
||||||
import { File } from "../../file"
|
import { File } from "../../file/service"
|
||||||
|
import { File as FileApi } from "../../file"
|
||||||
import { Ripgrep } from "../../file/ripgrep"
|
import { Ripgrep } from "../../file/ripgrep"
|
||||||
import { LSP } from "../../lsp"
|
import { LSP } from "../../lsp"
|
||||||
import { Instance } from "../../project/instance"
|
import { Instance } from "../../project/instance"
|
||||||
|
|
@ -73,7 +74,7 @@ export const FileRoutes = lazy(() =>
|
||||||
const dirs = c.req.valid("query").dirs
|
const dirs = c.req.valid("query").dirs
|
||||||
const type = c.req.valid("query").type
|
const type = c.req.valid("query").type
|
||||||
const limit = c.req.valid("query").limit
|
const limit = c.req.valid("query").limit
|
||||||
const results = await File.search({
|
const results = await FileApi.search({
|
||||||
query,
|
query,
|
||||||
limit: limit ?? 10,
|
limit: limit ?? 10,
|
||||||
dirs: dirs !== "false",
|
dirs: dirs !== "false",
|
||||||
|
|
@ -139,7 +140,7 @@ export const FileRoutes = lazy(() =>
|
||||||
),
|
),
|
||||||
async (c) => {
|
async (c) => {
|
||||||
const path = c.req.valid("query").path
|
const path = c.req.valid("query").path
|
||||||
const content = await File.list(path)
|
const content = await FileApi.list(path)
|
||||||
return c.json(content)
|
return c.json(content)
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
@ -168,7 +169,7 @@ export const FileRoutes = lazy(() =>
|
||||||
),
|
),
|
||||||
async (c) => {
|
async (c) => {
|
||||||
const path = c.req.valid("query").path
|
const path = c.req.valid("query").path
|
||||||
const content = await File.read(path)
|
const content = await FileApi.read(path)
|
||||||
return c.json(content)
|
return c.json(content)
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
@ -190,7 +191,7 @@ export const FileRoutes = lazy(() =>
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
async (c) => {
|
async (c) => {
|
||||||
const content = await File.status()
|
const content = await FileApi.status()
|
||||||
return c.json(content)
|
return c.json(content)
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
import { Hono } from "hono"
|
import { Hono } from "hono"
|
||||||
import { describeRoute, validator, resolver } from "hono-openapi"
|
import { describeRoute, validator, resolver } from "hono-openapi"
|
||||||
import z from "zod"
|
import z from "zod"
|
||||||
|
import { Permission } from "@/permission/service"
|
||||||
import { PermissionNext } from "@/permission"
|
import { PermissionNext } from "@/permission"
|
||||||
import { PermissionID } from "@/permission/schema"
|
import { PermissionID } from "@/permission/schema"
|
||||||
import { errors } from "../error"
|
import { errors } from "../error"
|
||||||
|
|
@ -32,7 +33,7 @@ export const PermissionRoutes = lazy(() =>
|
||||||
requestID: PermissionID.zod,
|
requestID: PermissionID.zod,
|
||||||
}),
|
}),
|
||||||
),
|
),
|
||||||
validator("json", z.object({ reply: PermissionNext.Reply, message: z.string().optional() })),
|
validator("json", z.object({ reply: Permission.Reply, message: z.string().optional() })),
|
||||||
async (c) => {
|
async (c) => {
|
||||||
const params = c.req.valid("param")
|
const params = c.req.valid("param")
|
||||||
const json = c.req.valid("json")
|
const json = c.req.valid("json")
|
||||||
|
|
@ -55,7 +56,7 @@ export const PermissionRoutes = lazy(() =>
|
||||||
description: "List of pending permissions",
|
description: "List of pending permissions",
|
||||||
content: {
|
content: {
|
||||||
"application/json": {
|
"application/json": {
|
||||||
schema: resolver(PermissionNext.Request.array()),
|
schema: resolver(Permission.Request.array()),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,8 @@ import z from "zod"
|
||||||
import { Config } from "../../config/config"
|
import { Config } from "../../config/config"
|
||||||
import { Provider } from "../../provider/provider"
|
import { Provider } from "../../provider/provider"
|
||||||
import { ModelsDev } from "../../provider/models"
|
import { ModelsDev } from "../../provider/models"
|
||||||
import { ProviderAuth } from "../../provider/auth"
|
import { ProviderAuth } from "../../provider/auth-service"
|
||||||
|
import { ProviderAuth as ProviderAuthApi } from "../../provider/auth"
|
||||||
import { ProviderID } from "../../provider/schema"
|
import { ProviderID } from "../../provider/schema"
|
||||||
import { mapValues } from "remeda"
|
import { mapValues } from "remeda"
|
||||||
import { errors } from "../error"
|
import { errors } from "../error"
|
||||||
|
|
@ -81,7 +82,7 @@ export const ProviderRoutes = lazy(() =>
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
async (c) => {
|
async (c) => {
|
||||||
return c.json(await ProviderAuth.methods())
|
return c.json(await ProviderAuthApi.methods())
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
.post(
|
.post(
|
||||||
|
|
@ -118,7 +119,7 @@ export const ProviderRoutes = lazy(() =>
|
||||||
async (c) => {
|
async (c) => {
|
||||||
const providerID = c.req.valid("param").providerID
|
const providerID = c.req.valid("param").providerID
|
||||||
const { method, inputs } = c.req.valid("json")
|
const { method, inputs } = c.req.valid("json")
|
||||||
const result = await ProviderAuth.authorize({
|
const result = await ProviderAuthApi.authorize({
|
||||||
providerID,
|
providerID,
|
||||||
method,
|
method,
|
||||||
inputs,
|
inputs,
|
||||||
|
|
@ -160,7 +161,7 @@ export const ProviderRoutes = lazy(() =>
|
||||||
async (c) => {
|
async (c) => {
|
||||||
const providerID = c.req.valid("param").providerID
|
const providerID = c.req.valid("param").providerID
|
||||||
const { method, code } = c.req.valid("json")
|
const { method, code } = c.req.valid("json")
|
||||||
await ProviderAuth.callback({
|
await ProviderAuthApi.callback({
|
||||||
providerID,
|
providerID,
|
||||||
method,
|
method,
|
||||||
code,
|
code,
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,8 @@ import { Hono } from "hono"
|
||||||
import { describeRoute, validator } from "hono-openapi"
|
import { describeRoute, validator } from "hono-openapi"
|
||||||
import { resolver } from "hono-openapi"
|
import { resolver } from "hono-openapi"
|
||||||
import { QuestionID } from "@/question/schema"
|
import { QuestionID } from "@/question/schema"
|
||||||
import { Question } from "../../question"
|
import { Question } from "../../question/service"
|
||||||
|
import { Question as QuestionApi } from "../../question"
|
||||||
import z from "zod"
|
import z from "zod"
|
||||||
import { errors } from "../error"
|
import { errors } from "../error"
|
||||||
import { lazy } from "../../util/lazy"
|
import { lazy } from "../../util/lazy"
|
||||||
|
|
@ -27,7 +28,7 @@ export const QuestionRoutes = lazy(() =>
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
async (c) => {
|
async (c) => {
|
||||||
const questions = await Question.list()
|
const questions = await QuestionApi.list()
|
||||||
return c.json(questions)
|
return c.json(questions)
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
@ -59,7 +60,7 @@ export const QuestionRoutes = lazy(() =>
|
||||||
async (c) => {
|
async (c) => {
|
||||||
const params = c.req.valid("param")
|
const params = c.req.valid("param")
|
||||||
const json = c.req.valid("json")
|
const json = c.req.valid("json")
|
||||||
await Question.reply({
|
await QuestionApi.reply({
|
||||||
requestID: params.requestID,
|
requestID: params.requestID,
|
||||||
answers: json.answers,
|
answers: json.answers,
|
||||||
})
|
})
|
||||||
|
|
@ -92,7 +93,7 @@ export const QuestionRoutes = lazy(() =>
|
||||||
),
|
),
|
||||||
async (c) => {
|
async (c) => {
|
||||||
const params = c.req.valid("param")
|
const params = c.req.valid("param")
|
||||||
await Question.reject(params.requestID)
|
await QuestionApi.reject(params.requestID)
|
||||||
return c.json(true)
|
return c.json(true)
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
|
|
||||||
|
|
@ -8,13 +8,15 @@ import z from "zod"
|
||||||
import { Provider } from "../provider/provider"
|
import { Provider } from "../provider/provider"
|
||||||
import { NamedError } from "@opencode-ai/util/error"
|
import { NamedError } from "@opencode-ai/util/error"
|
||||||
import { LSP } from "../lsp"
|
import { LSP } from "../lsp"
|
||||||
|
import { Format as FormatService } from "../format/service"
|
||||||
import { Format } from "../format"
|
import { Format } from "../format"
|
||||||
import { TuiRoutes } from "./routes/tui"
|
import { TuiRoutes } from "./routes/tui"
|
||||||
import { Instance } from "../project/instance"
|
import { Instance } from "../project/instance"
|
||||||
import { Vcs } from "../project/vcs"
|
import { Vcs } from "../project/vcs"
|
||||||
import { runPromiseInstance } from "@/effect/runtime"
|
import { runPromiseInstance } from "@/effect/runtime"
|
||||||
import { Agent } from "../agent/agent"
|
import { Agent } from "../agent/agent"
|
||||||
import { Skill } from "../skill/skill"
|
import { Skill as SkillService } from "../skill/service"
|
||||||
|
import { Skill } from "../skill"
|
||||||
import { Auth } from "../auth"
|
import { Auth } from "../auth"
|
||||||
import { Flag } from "../flag/flag"
|
import { Flag } from "../flag/flag"
|
||||||
import { Command } from "../command"
|
import { Command } from "../command"
|
||||||
|
|
@ -444,7 +446,7 @@ export namespace Server {
|
||||||
description: "List of skills",
|
description: "List of skills",
|
||||||
content: {
|
content: {
|
||||||
"application/json": {
|
"application/json": {
|
||||||
schema: resolver(Skill.Info.array()),
|
schema: resolver(SkillService.Info.array()),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
@ -487,7 +489,7 @@ export namespace Server {
|
||||||
description: "Formatter status",
|
description: "Formatter status",
|
||||||
content: {
|
content: {
|
||||||
"application/json": {
|
"application/json": {
|
||||||
schema: resolver(Format.Status.array()),
|
schema: resolver(FormatService.Status.array()),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -45,7 +45,7 @@ export namespace ShareNext {
|
||||||
}> {
|
}> {
|
||||||
const headers: Record<string, string> = {}
|
const headers: Record<string, string> = {}
|
||||||
|
|
||||||
const active = Account.active()
|
const active = await Account.active()
|
||||||
if (!active?.active_org_id) {
|
if (!active?.active_org_id) {
|
||||||
const baseUrl = await Config.get().then((x) => x.enterprise?.url ?? "https://opncd.ai")
|
const baseUrl = await Config.get().then((x) => x.enterprise?.url ?? "https://opncd.ai")
|
||||||
return { headers, api: legacyApi, baseUrl }
|
return { headers, api: legacyApi, baseUrl }
|
||||||
|
|
|
||||||
|
|
@ -1 +1,30 @@
|
||||||
export * from "./skill"
|
import type { Agent } from "@/agent/agent"
|
||||||
|
import { runInstance } from "@/effect/run"
|
||||||
|
|
||||||
|
const svc = () => import("./service").then((m) => m.Skill.Service)
|
||||||
|
const mod = () => import("./service").then((m) => m.Skill)
|
||||||
|
|
||||||
|
export namespace Skill {
|
||||||
|
export type Info = import("./service").Skill.Info
|
||||||
|
export type Interface = import("./service").Skill.Interface
|
||||||
|
|
||||||
|
export async function get(name: string) {
|
||||||
|
return runInstance((await svc()).use((s) => s.get(name)))
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function all() {
|
||||||
|
return runInstance((await svc()).use((s) => s.all()))
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function dirs() {
|
||||||
|
return runInstance((await svc()).use((s) => s.dirs()))
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function available(agent?: Agent.Info) {
|
||||||
|
return runInstance((await svc()).use((s) => s.available(agent)))
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function fmt(list: Info[], opts: { verbose: boolean }) {
|
||||||
|
return (await mod()).fmt(list, opts)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,35 +0,0 @@
|
||||||
import { runPromiseInstance } from "@/effect/runtime"
|
|
||||||
import type { Agent } from "@/agent/agent"
|
|
||||||
import { Skill as S } from "./service"
|
|
||||||
|
|
||||||
export namespace Skill {
|
|
||||||
export const Info = S.Info
|
|
||||||
export type Info = S.Info
|
|
||||||
|
|
||||||
export const InvalidError = S.InvalidError
|
|
||||||
export const NameMismatchError = S.NameMismatchError
|
|
||||||
|
|
||||||
export type Interface = S.Interface
|
|
||||||
|
|
||||||
export const Service = S.Service
|
|
||||||
export const layer = S.layer
|
|
||||||
export const defaultLayer = S.defaultLayer
|
|
||||||
|
|
||||||
export const fmt = S.fmt
|
|
||||||
|
|
||||||
export async function get(name: string) {
|
|
||||||
return runPromiseInstance(S.Service.use((skill) => skill.get(name)))
|
|
||||||
}
|
|
||||||
|
|
||||||
export async function all() {
|
|
||||||
return runPromiseInstance(S.Service.use((skill) => skill.all()))
|
|
||||||
}
|
|
||||||
|
|
||||||
export async function dirs() {
|
|
||||||
return runPromiseInstance(S.Service.use((skill) => skill.dirs()))
|
|
||||||
}
|
|
||||||
|
|
||||||
export async function available(agent?: Agent.Info) {
|
|
||||||
return runPromiseInstance(S.Service.use((skill) => skill.available(agent)))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,44 +1,43 @@
|
||||||
import { runPromiseInstance } from "@/effect/runtime"
|
import { runInstance } from "@/effect/run"
|
||||||
import { Snapshot as S } from "./service"
|
import { Snapshot as S } from "./service"
|
||||||
|
|
||||||
|
const svc = () => import("./service").then((m) => m.Snapshot.Service)
|
||||||
|
|
||||||
export namespace Snapshot {
|
export namespace Snapshot {
|
||||||
export const Patch = S.Patch
|
export const Patch = S.Patch
|
||||||
export type Patch = S.Patch
|
export type Patch = S.Patch
|
||||||
|
|
||||||
export const FileDiff = S.FileDiff
|
export const FileDiff = S.FileDiff
|
||||||
export type FileDiff = S.FileDiff
|
export type FileDiff = S.FileDiff
|
||||||
|
|
||||||
export type Interface = S.Interface
|
export type Interface = S.Interface
|
||||||
|
|
||||||
export const Service = S.Service
|
export const Service = S.Service
|
||||||
export const layer = S.layer
|
export const layer = S.layer
|
||||||
export const defaultLayer = S.defaultLayer
|
export const defaultLayer = S.defaultLayer
|
||||||
|
|
||||||
export async function cleanup() {
|
export async function cleanup() {
|
||||||
return runPromiseInstance(S.Service.use((svc) => svc.cleanup()))
|
return runInstance((await svc()).use((s) => s.cleanup()))
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function track() {
|
export async function track() {
|
||||||
return runPromiseInstance(S.Service.use((svc) => svc.track()))
|
return runInstance((await svc()).use((s) => s.track()))
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function patch(hash: string) {
|
export async function patch(hash: string) {
|
||||||
return runPromiseInstance(S.Service.use((svc) => svc.patch(hash)))
|
return runInstance((await svc()).use((s) => s.patch(hash)))
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function restore(snapshot: string) {
|
export async function restore(snapshot: string) {
|
||||||
return runPromiseInstance(S.Service.use((svc) => svc.restore(snapshot)))
|
return runInstance((await svc()).use((s) => s.restore(snapshot)))
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function revert(patches: Patch[]) {
|
export async function revert(patches: Patch[]) {
|
||||||
return runPromiseInstance(S.Service.use((svc) => svc.revert(patches)))
|
return runInstance((await svc()).use((s) => s.revert(patches)))
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function diff(hash: string) {
|
export async function diff(hash: string) {
|
||||||
return runPromiseInstance(S.Service.use((svc) => svc.diff(hash)))
|
return runInstance((await svc()).use((s) => s.diff(hash)))
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function diffFull(from: string, to: string) {
|
export async function diffFull(from: string, to: string) {
|
||||||
return runPromiseInstance(S.Service.use((svc) => svc.diffFull(from, to)))
|
return runInstance((await svc()).use((s) => s.diffFull(from, to)))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@ test("ShareNext.request uses legacy share API without active org account", async
|
||||||
const originalActive = Account.active
|
const originalActive = Account.active
|
||||||
const originalConfigGet = Config.get
|
const originalConfigGet = Config.get
|
||||||
|
|
||||||
Account.active = mock(() => undefined)
|
Account.active = mock(async () => undefined)
|
||||||
Config.get = mock(async () => ({ enterprise: { url: "https://legacy-share.example.com" } }))
|
Config.get = mock(async () => ({ enterprise: { url: "https://legacy-share.example.com" } }))
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
@ -29,7 +29,7 @@ test("ShareNext.request uses org share API with auth headers when account is act
|
||||||
const originalActive = Account.active
|
const originalActive = Account.active
|
||||||
const originalToken = Account.token
|
const originalToken = Account.token
|
||||||
|
|
||||||
Account.active = mock(() => ({
|
Account.active = mock(async () => ({
|
||||||
id: AccountID.make("account-1"),
|
id: AccountID.make("account-1"),
|
||||||
email: "user@example.com",
|
email: "user@example.com",
|
||||||
url: "https://control.example.com",
|
url: "https://control.example.com",
|
||||||
|
|
@ -59,7 +59,7 @@ test("ShareNext.request fails when org account has no token", async () => {
|
||||||
const originalActive = Account.active
|
const originalActive = Account.active
|
||||||
const originalToken = Account.token
|
const originalToken = Account.token
|
||||||
|
|
||||||
Account.active = mock(() => ({
|
Account.active = mock(async () => ({
|
||||||
id: AccountID.make("account-1"),
|
id: AccountID.make("account-1"),
|
||||||
email: "user@example.com",
|
email: "user@example.com",
|
||||||
url: "https://control.example.com",
|
url: "https://control.example.com",
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue