|
|
|
@@ -25,6 +25,7 @@ export interface PlatformClientOptions {
|
|
|
|
|
role?: string;
|
|
|
|
|
capabilities?: string[];
|
|
|
|
|
protocolVersion?: number;
|
|
|
|
|
defaultSessionId?: string;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export interface RegisterPushTokenInput {
|
|
|
|
@@ -51,12 +52,25 @@ export interface PlatformBootstrapResult {
|
|
|
|
|
capabilities: NodeCapabilitiesResult;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export interface PlatformPutCanvasArtifactInput extends Omit<PutCanvasArtifactInput, 'sessionId'> {
|
|
|
|
|
sessionId?: string;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export interface PlatformGetCanvasArtifactInput extends Omit<GetCanvasArtifactInput, 'sessionId'> {
|
|
|
|
|
sessionId?: string;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export interface PlatformDeleteCanvasArtifactInput extends Omit<DeleteCanvasArtifactInput, 'sessionId'> {
|
|
|
|
|
sessionId?: string;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export class MacOSCompanionClient {
|
|
|
|
|
private readonly runtime: CompanionRuntimeClient;
|
|
|
|
|
private readonly nodeId: string;
|
|
|
|
|
private readonly role: string;
|
|
|
|
|
private readonly capabilities: string[];
|
|
|
|
|
private readonly protocolVersion?: number;
|
|
|
|
|
private readonly defaultSessionId?: string;
|
|
|
|
|
|
|
|
|
|
constructor(options: PlatformClientOptions) {
|
|
|
|
|
this.runtime = options.runtime;
|
|
|
|
@@ -64,6 +78,7 @@ export class MacOSCompanionClient {
|
|
|
|
|
this.role = options.role ?? 'companion';
|
|
|
|
|
this.capabilities = options.capabilities ?? ['ui.canvas', 'node.location.write', 'node.push.register'];
|
|
|
|
|
this.protocolVersion = options.protocolVersion;
|
|
|
|
|
this.defaultSessionId = options.defaultSessionId;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
connect(): Promise<void> {
|
|
|
|
@@ -139,24 +154,45 @@ export class MacOSCompanionClient {
|
|
|
|
|
return this.runtime.listSystemNodes({ platform: 'macos', role: this.role });
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
putCanvasArtifact(input: PutCanvasArtifactInput): Promise<CanvasPutResult> {
|
|
|
|
|
return this.runtime.putCanvasArtifact(input);
|
|
|
|
|
putCanvasArtifact(input: PlatformPutCanvasArtifactInput): Promise<CanvasPutResult> {
|
|
|
|
|
return this.runtime.putCanvasArtifact({
|
|
|
|
|
sessionId: this.resolveSessionId(input.sessionId),
|
|
|
|
|
artifactId: input.artifactId,
|
|
|
|
|
type: input.type,
|
|
|
|
|
title: input.title,
|
|
|
|
|
content: input.content,
|
|
|
|
|
metadata: input.metadata,
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
getCanvasArtifact(input: GetCanvasArtifactInput): Promise<CanvasGetResult> {
|
|
|
|
|
return this.runtime.getCanvasArtifact(input);
|
|
|
|
|
getCanvasArtifact(input: PlatformGetCanvasArtifactInput): Promise<CanvasGetResult> {
|
|
|
|
|
return this.runtime.getCanvasArtifact({
|
|
|
|
|
sessionId: this.resolveSessionId(input.sessionId),
|
|
|
|
|
artifactId: input.artifactId,
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
listCanvasArtifacts(sessionId: string): Promise<CanvasListResult> {
|
|
|
|
|
return this.runtime.listCanvasArtifacts(sessionId);
|
|
|
|
|
listCanvasArtifacts(sessionId?: string): Promise<CanvasListResult> {
|
|
|
|
|
return this.runtime.listCanvasArtifacts(this.resolveSessionId(sessionId));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
deleteCanvasArtifact(input: DeleteCanvasArtifactInput): Promise<CanvasDeleteResult> {
|
|
|
|
|
return this.runtime.deleteCanvasArtifact(input);
|
|
|
|
|
deleteCanvasArtifact(input: PlatformDeleteCanvasArtifactInput): Promise<CanvasDeleteResult> {
|
|
|
|
|
return this.runtime.deleteCanvasArtifact({
|
|
|
|
|
sessionId: this.resolveSessionId(input.sessionId),
|
|
|
|
|
artifactId: input.artifactId,
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
clearCanvasArtifacts(sessionId: string): Promise<CanvasClearResult> {
|
|
|
|
|
return this.runtime.clearCanvasArtifacts(sessionId);
|
|
|
|
|
clearCanvasArtifacts(sessionId?: string): Promise<CanvasClearResult> {
|
|
|
|
|
return this.runtime.clearCanvasArtifacts(this.resolveSessionId(sessionId));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private resolveSessionId(sessionId?: string): string {
|
|
|
|
|
const resolved = sessionId ?? this.defaultSessionId;
|
|
|
|
|
if (!resolved) {
|
|
|
|
|
throw new Error('sessionId is required (provide one or configure defaultSessionId)');
|
|
|
|
|
}
|
|
|
|
|
return resolved;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -166,6 +202,7 @@ export class IOSCompanionClient {
|
|
|
|
|
private readonly role: string;
|
|
|
|
|
private readonly capabilities: string[];
|
|
|
|
|
private readonly protocolVersion?: number;
|
|
|
|
|
private readonly defaultSessionId?: string;
|
|
|
|
|
|
|
|
|
|
constructor(options: PlatformClientOptions) {
|
|
|
|
|
this.runtime = options.runtime;
|
|
|
|
@@ -173,6 +210,7 @@ export class IOSCompanionClient {
|
|
|
|
|
this.role = options.role ?? 'companion';
|
|
|
|
|
this.capabilities = options.capabilities ?? ['node.location.write', 'node.push.register'];
|
|
|
|
|
this.protocolVersion = options.protocolVersion;
|
|
|
|
|
this.defaultSessionId = options.defaultSessionId;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
connect(): Promise<void> {
|
|
|
|
@@ -248,24 +286,45 @@ export class IOSCompanionClient {
|
|
|
|
|
return this.runtime.listSystemNodes({ platform: 'ios', role: this.role });
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
putCanvasArtifact(input: PutCanvasArtifactInput): Promise<CanvasPutResult> {
|
|
|
|
|
return this.runtime.putCanvasArtifact(input);
|
|
|
|
|
putCanvasArtifact(input: PlatformPutCanvasArtifactInput): Promise<CanvasPutResult> {
|
|
|
|
|
return this.runtime.putCanvasArtifact({
|
|
|
|
|
sessionId: this.resolveSessionId(input.sessionId),
|
|
|
|
|
artifactId: input.artifactId,
|
|
|
|
|
type: input.type,
|
|
|
|
|
title: input.title,
|
|
|
|
|
content: input.content,
|
|
|
|
|
metadata: input.metadata,
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
getCanvasArtifact(input: GetCanvasArtifactInput): Promise<CanvasGetResult> {
|
|
|
|
|
return this.runtime.getCanvasArtifact(input);
|
|
|
|
|
getCanvasArtifact(input: PlatformGetCanvasArtifactInput): Promise<CanvasGetResult> {
|
|
|
|
|
return this.runtime.getCanvasArtifact({
|
|
|
|
|
sessionId: this.resolveSessionId(input.sessionId),
|
|
|
|
|
artifactId: input.artifactId,
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
listCanvasArtifacts(sessionId: string): Promise<CanvasListResult> {
|
|
|
|
|
return this.runtime.listCanvasArtifacts(sessionId);
|
|
|
|
|
listCanvasArtifacts(sessionId?: string): Promise<CanvasListResult> {
|
|
|
|
|
return this.runtime.listCanvasArtifacts(this.resolveSessionId(sessionId));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
deleteCanvasArtifact(input: DeleteCanvasArtifactInput): Promise<CanvasDeleteResult> {
|
|
|
|
|
return this.runtime.deleteCanvasArtifact(input);
|
|
|
|
|
deleteCanvasArtifact(input: PlatformDeleteCanvasArtifactInput): Promise<CanvasDeleteResult> {
|
|
|
|
|
return this.runtime.deleteCanvasArtifact({
|
|
|
|
|
sessionId: this.resolveSessionId(input.sessionId),
|
|
|
|
|
artifactId: input.artifactId,
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
clearCanvasArtifacts(sessionId: string): Promise<CanvasClearResult> {
|
|
|
|
|
return this.runtime.clearCanvasArtifacts(sessionId);
|
|
|
|
|
clearCanvasArtifacts(sessionId?: string): Promise<CanvasClearResult> {
|
|
|
|
|
return this.runtime.clearCanvasArtifacts(this.resolveSessionId(sessionId));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private resolveSessionId(sessionId?: string): string {
|
|
|
|
|
const resolved = sessionId ?? this.defaultSessionId;
|
|
|
|
|
if (!resolved) {
|
|
|
|
|
throw new Error('sessionId is required (provide one or configure defaultSessionId)');
|
|
|
|
|
}
|
|
|
|
|
return resolved;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -275,6 +334,7 @@ export class AndroidCompanionClient {
|
|
|
|
|
private readonly role: string;
|
|
|
|
|
private readonly capabilities: string[];
|
|
|
|
|
private readonly protocolVersion?: number;
|
|
|
|
|
private readonly defaultSessionId?: string;
|
|
|
|
|
|
|
|
|
|
constructor(options: PlatformClientOptions) {
|
|
|
|
|
this.runtime = options.runtime;
|
|
|
|
@@ -282,6 +342,7 @@ export class AndroidCompanionClient {
|
|
|
|
|
this.role = options.role ?? 'companion';
|
|
|
|
|
this.capabilities = options.capabilities ?? ['node.location.write', 'node.push.register'];
|
|
|
|
|
this.protocolVersion = options.protocolVersion;
|
|
|
|
|
this.defaultSessionId = options.defaultSessionId;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
connect(): Promise<void> {
|
|
|
|
@@ -355,23 +416,44 @@ export class AndroidCompanionClient {
|
|
|
|
|
return this.runtime.listSystemNodes({ platform: 'android', role: this.role });
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
putCanvasArtifact(input: PutCanvasArtifactInput): Promise<CanvasPutResult> {
|
|
|
|
|
return this.runtime.putCanvasArtifact(input);
|
|
|
|
|
putCanvasArtifact(input: PlatformPutCanvasArtifactInput): Promise<CanvasPutResult> {
|
|
|
|
|
return this.runtime.putCanvasArtifact({
|
|
|
|
|
sessionId: this.resolveSessionId(input.sessionId),
|
|
|
|
|
artifactId: input.artifactId,
|
|
|
|
|
type: input.type,
|
|
|
|
|
title: input.title,
|
|
|
|
|
content: input.content,
|
|
|
|
|
metadata: input.metadata,
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
getCanvasArtifact(input: GetCanvasArtifactInput): Promise<CanvasGetResult> {
|
|
|
|
|
return this.runtime.getCanvasArtifact(input);
|
|
|
|
|
getCanvasArtifact(input: PlatformGetCanvasArtifactInput): Promise<CanvasGetResult> {
|
|
|
|
|
return this.runtime.getCanvasArtifact({
|
|
|
|
|
sessionId: this.resolveSessionId(input.sessionId),
|
|
|
|
|
artifactId: input.artifactId,
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
listCanvasArtifacts(sessionId: string): Promise<CanvasListResult> {
|
|
|
|
|
return this.runtime.listCanvasArtifacts(sessionId);
|
|
|
|
|
listCanvasArtifacts(sessionId?: string): Promise<CanvasListResult> {
|
|
|
|
|
return this.runtime.listCanvasArtifacts(this.resolveSessionId(sessionId));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
deleteCanvasArtifact(input: DeleteCanvasArtifactInput): Promise<CanvasDeleteResult> {
|
|
|
|
|
return this.runtime.deleteCanvasArtifact(input);
|
|
|
|
|
deleteCanvasArtifact(input: PlatformDeleteCanvasArtifactInput): Promise<CanvasDeleteResult> {
|
|
|
|
|
return this.runtime.deleteCanvasArtifact({
|
|
|
|
|
sessionId: this.resolveSessionId(input.sessionId),
|
|
|
|
|
artifactId: input.artifactId,
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
clearCanvasArtifacts(sessionId: string): Promise<CanvasClearResult> {
|
|
|
|
|
return this.runtime.clearCanvasArtifacts(sessionId);
|
|
|
|
|
clearCanvasArtifacts(sessionId?: string): Promise<CanvasClearResult> {
|
|
|
|
|
return this.runtime.clearCanvasArtifacts(this.resolveSessionId(sessionId));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private resolveSessionId(sessionId?: string): string {
|
|
|
|
|
const resolved = sessionId ?? this.defaultSessionId;
|
|
|
|
|
if (!resolved) {
|
|
|
|
|
throw new Error('sessionId is required (provide one or configure defaultSessionId)');
|
|
|
|
|
}
|
|
|
|
|
return resolved;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|