@elizaos/capacitor-phone 1.0.0
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/android/build.gradle +30 -0
- package/android/src/main/AndroidManifest.xml +9 -0
- package/android/src/main/java/ai/eliza/plugins/phone/PhonePlugin.kt +207 -0
- package/dist/esm/definitions.d.ts +48 -0
- package/dist/esm/definitions.d.ts.map +1 -0
- package/dist/esm/definitions.js +2 -0
- package/dist/esm/definitions.js.map +1 -0
- package/dist/esm/index.d.ts +4 -0
- package/dist/esm/index.d.ts.map +1 -0
- package/dist/esm/index.js +7 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/web.d.ts +14 -0
- package/dist/esm/web.d.ts.map +1 -0
- package/dist/esm/web.js +24 -0
- package/dist/esm/web.js.map +1 -0
- package/dist/plugin.cjs.js +39 -0
- package/dist/plugin.cjs.js.map +1 -0
- package/dist/plugin.js +42 -0
- package/dist/plugin.js.map +1 -0
- package/package.json +56 -0
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
ext {
|
|
2
|
+
junitVersion = project.hasProperty('junitVersion') ? rootProject.ext.junitVersion : '4.13.2'
|
|
3
|
+
androidxAppCompatVersion = project.hasProperty('androidxAppCompatVersion') ? rootProject.ext.androidxAppCompatVersion : '1.6.1'
|
|
4
|
+
androidxJunitVersion = project.hasProperty('androidxJunitVersion') ? rootProject.ext.androidxJunitVersion : '1.1.5'
|
|
5
|
+
androidxEspressoCoreVersion = project.hasProperty('androidxEspressoCoreVersion') ? rootProject.ext.androidxEspressoCoreVersion : '3.5.1'
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
apply plugin: 'com.android.library'
|
|
9
|
+
android {
|
|
10
|
+
namespace = "ai.eliza.plugins.phone"
|
|
11
|
+
compileSdk project.hasProperty('compileSdkVersion') ? rootProject.ext.compileSdkVersion : 34
|
|
12
|
+
defaultConfig {
|
|
13
|
+
minSdkVersion project.hasProperty('minSdkVersion') ? rootProject.ext.minSdkVersion : 23
|
|
14
|
+
targetSdkVersion project.hasProperty('targetSdkVersion') ? rootProject.ext.targetSdkVersion : 34
|
|
15
|
+
}
|
|
16
|
+
compileOptions {
|
|
17
|
+
sourceCompatibility JavaVersion.VERSION_17
|
|
18
|
+
targetCompatibility JavaVersion.VERSION_17
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
repositories {
|
|
23
|
+
google()
|
|
24
|
+
maven { url = uri(rootProject.ext.mavenCentralMirrorUrl) }
|
|
25
|
+
mavenCentral()
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
dependencies {
|
|
29
|
+
implementation project(':capacitor-android')
|
|
30
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
|
2
|
+
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
|
|
3
|
+
<uses-permission android:name="android.permission.CALL_PHONE" />
|
|
4
|
+
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
|
|
5
|
+
<uses-permission android:name="android.permission.ANSWER_PHONE_CALLS" />
|
|
6
|
+
<uses-permission android:name="android.permission.MANAGE_OWN_CALLS" />
|
|
7
|
+
<uses-permission android:name="android.permission.READ_CALL_LOG" />
|
|
8
|
+
<uses-permission android:name="android.permission.WRITE_CALL_LOG" />
|
|
9
|
+
</manifest>
|
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
package ai.eliza.plugins.phone
|
|
2
|
+
|
|
3
|
+
import android.Manifest
|
|
4
|
+
import android.content.Context
|
|
5
|
+
import android.content.Intent
|
|
6
|
+
import android.net.Uri
|
|
7
|
+
import android.os.Bundle
|
|
8
|
+
import android.provider.CallLog
|
|
9
|
+
import android.telecom.TelecomManager
|
|
10
|
+
import com.getcapacitor.JSArray
|
|
11
|
+
import com.getcapacitor.JSObject
|
|
12
|
+
import com.getcapacitor.Plugin
|
|
13
|
+
import com.getcapacitor.PluginCall
|
|
14
|
+
import com.getcapacitor.PluginMethod
|
|
15
|
+
import com.getcapacitor.annotation.CapacitorPlugin
|
|
16
|
+
import org.json.JSONObject
|
|
17
|
+
|
|
18
|
+
@CapacitorPlugin(name = "ElizaPhone")
|
|
19
|
+
class PhonePlugin : Plugin() {
|
|
20
|
+
private val transcriptPreferencesName = "eliza_phone_call_transcripts"
|
|
21
|
+
|
|
22
|
+
@PluginMethod
|
|
23
|
+
fun getStatus(call: PluginCall) {
|
|
24
|
+
val telecom = context.getSystemService(Context.TELECOM_SERVICE) as? TelecomManager
|
|
25
|
+
val result = JSObject()
|
|
26
|
+
result.put("hasTelecom", telecom != null)
|
|
27
|
+
result.put("canPlaceCalls", hasPermission(Manifest.permission.CALL_PHONE))
|
|
28
|
+
result.put("defaultDialerPackage", telecom?.defaultDialerPackage)
|
|
29
|
+
result.put("isDefaultDialer", telecom?.defaultDialerPackage == context.packageName)
|
|
30
|
+
call.resolve(result)
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
@PluginMethod
|
|
34
|
+
fun placeCall(call: PluginCall) {
|
|
35
|
+
val number = call.getString("number")?.trim()
|
|
36
|
+
if (number.isNullOrEmpty()) {
|
|
37
|
+
call.reject("number is required")
|
|
38
|
+
return
|
|
39
|
+
}
|
|
40
|
+
val telecom = context.getSystemService(Context.TELECOM_SERVICE) as? TelecomManager
|
|
41
|
+
if (telecom == null) {
|
|
42
|
+
call.reject("Telecom service is unavailable")
|
|
43
|
+
return
|
|
44
|
+
}
|
|
45
|
+
try {
|
|
46
|
+
telecom.placeCall(Uri.parse("tel:$number"), Bundle())
|
|
47
|
+
call.resolve()
|
|
48
|
+
} catch (error: SecurityException) {
|
|
49
|
+
call.reject("CALL_PHONE permission is required", error)
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
@PluginMethod
|
|
54
|
+
fun openDialer(call: PluginCall) {
|
|
55
|
+
val number = call.getString("number")?.trim()
|
|
56
|
+
val uri = if (number.isNullOrEmpty()) Uri.parse("tel:") else Uri.parse("tel:$number")
|
|
57
|
+
val intent = Intent(Intent.ACTION_DIAL, uri)
|
|
58
|
+
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
|
|
59
|
+
context.startActivity(intent)
|
|
60
|
+
call.resolve()
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
@PluginMethod
|
|
64
|
+
fun listRecentCalls(call: PluginCall) {
|
|
65
|
+
if (!hasPermission(Manifest.permission.READ_CALL_LOG)) {
|
|
66
|
+
call.reject("READ_CALL_LOG permission is required")
|
|
67
|
+
return
|
|
68
|
+
}
|
|
69
|
+
val limit = call.getInt("limit") ?: 100
|
|
70
|
+
if (limit <= 0 || limit > 500) {
|
|
71
|
+
call.reject("limit must be between 1 and 500")
|
|
72
|
+
return
|
|
73
|
+
}
|
|
74
|
+
val number = call.getString("number")?.trim()
|
|
75
|
+
val selection = if (number.isNullOrEmpty()) null else "${CallLog.Calls.NUMBER} LIKE ?"
|
|
76
|
+
val selectionArgs = if (number.isNullOrEmpty()) null else arrayOf("%$number%")
|
|
77
|
+
val calls = JSArray()
|
|
78
|
+
val transcripts = readSavedTranscripts()
|
|
79
|
+
val cursor = context.contentResolver.query(
|
|
80
|
+
CallLog.Calls.CONTENT_URI,
|
|
81
|
+
arrayOf(
|
|
82
|
+
CallLog.Calls._ID,
|
|
83
|
+
CallLog.Calls.NUMBER,
|
|
84
|
+
CallLog.Calls.CACHED_NAME,
|
|
85
|
+
CallLog.Calls.DATE,
|
|
86
|
+
CallLog.Calls.DURATION,
|
|
87
|
+
CallLog.Calls.TYPE,
|
|
88
|
+
CallLog.Calls.NEW,
|
|
89
|
+
CallLog.Calls.PHONE_ACCOUNT_ID,
|
|
90
|
+
CallLog.Calls.GEOCODED_LOCATION,
|
|
91
|
+
CallLog.Calls.TRANSCRIPTION,
|
|
92
|
+
CallLog.Calls.VOICEMAIL_URI
|
|
93
|
+
),
|
|
94
|
+
selection,
|
|
95
|
+
selectionArgs,
|
|
96
|
+
"${CallLog.Calls.DATE} DESC"
|
|
97
|
+
)
|
|
98
|
+
if (cursor == null) {
|
|
99
|
+
call.reject("Call log provider returned no cursor")
|
|
100
|
+
return
|
|
101
|
+
}
|
|
102
|
+
cursor.use {
|
|
103
|
+
val idCol = cursor.getColumnIndexOrThrow(CallLog.Calls._ID)
|
|
104
|
+
val numberCol = cursor.getColumnIndexOrThrow(CallLog.Calls.NUMBER)
|
|
105
|
+
val nameCol = cursor.getColumnIndexOrThrow(CallLog.Calls.CACHED_NAME)
|
|
106
|
+
val dateCol = cursor.getColumnIndexOrThrow(CallLog.Calls.DATE)
|
|
107
|
+
val durationCol = cursor.getColumnIndexOrThrow(CallLog.Calls.DURATION)
|
|
108
|
+
val typeCol = cursor.getColumnIndexOrThrow(CallLog.Calls.TYPE)
|
|
109
|
+
val newCol = cursor.getColumnIndexOrThrow(CallLog.Calls.NEW)
|
|
110
|
+
val accountCol = cursor.getColumnIndexOrThrow(CallLog.Calls.PHONE_ACCOUNT_ID)
|
|
111
|
+
val locationCol = cursor.getColumnIndexOrThrow(CallLog.Calls.GEOCODED_LOCATION)
|
|
112
|
+
val transcriptionCol = cursor.getColumnIndexOrThrow(CallLog.Calls.TRANSCRIPTION)
|
|
113
|
+
val voicemailCol = cursor.getColumnIndexOrThrow(CallLog.Calls.VOICEMAIL_URI)
|
|
114
|
+
var count = 0
|
|
115
|
+
while (cursor.moveToNext() && count < limit) {
|
|
116
|
+
val id = cursor.getString(idCol)
|
|
117
|
+
val type = cursor.getInt(typeCol)
|
|
118
|
+
val savedTranscript = transcripts[id]
|
|
119
|
+
val entry = JSObject()
|
|
120
|
+
entry.put("id", id)
|
|
121
|
+
entry.put("number", cursor.getString(numberCol) ?: "")
|
|
122
|
+
entry.put("cachedName", cursor.getString(nameCol))
|
|
123
|
+
entry.put("date", cursor.getLong(dateCol))
|
|
124
|
+
entry.put("durationSeconds", cursor.getLong(durationCol))
|
|
125
|
+
entry.put("type", callLogType(type))
|
|
126
|
+
entry.put("rawType", type)
|
|
127
|
+
entry.put("isNew", cursor.getInt(newCol) == 1)
|
|
128
|
+
entry.put("phoneAccountId", cursor.getString(accountCol))
|
|
129
|
+
entry.put("geocodedLocation", cursor.getString(locationCol))
|
|
130
|
+
entry.put("transcription", cursor.getString(transcriptionCol))
|
|
131
|
+
entry.put("voicemailUri", cursor.getString(voicemailCol))
|
|
132
|
+
entry.put("agentTranscript", savedTranscript?.optionalString("transcript"))
|
|
133
|
+
entry.put("agentSummary", savedTranscript?.optionalString("summary"))
|
|
134
|
+
entry.put(
|
|
135
|
+
"agentTranscriptUpdatedAt",
|
|
136
|
+
if (savedTranscript != null && savedTranscript.has("updatedAt")) {
|
|
137
|
+
savedTranscript.optLong("updatedAt")
|
|
138
|
+
} else {
|
|
139
|
+
null
|
|
140
|
+
}
|
|
141
|
+
)
|
|
142
|
+
calls.put(entry)
|
|
143
|
+
count += 1
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
val result = JSObject()
|
|
147
|
+
result.put("calls", calls)
|
|
148
|
+
call.resolve(result)
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
@PluginMethod
|
|
152
|
+
fun saveCallTranscript(call: PluginCall) {
|
|
153
|
+
val callId = call.getString("callId")?.trim()
|
|
154
|
+
if (callId.isNullOrEmpty()) {
|
|
155
|
+
call.reject("callId is required")
|
|
156
|
+
return
|
|
157
|
+
}
|
|
158
|
+
val transcript = call.getString("transcript")?.trim()
|
|
159
|
+
if (transcript.isNullOrEmpty()) {
|
|
160
|
+
call.reject("transcript is required")
|
|
161
|
+
return
|
|
162
|
+
}
|
|
163
|
+
val summary = call.getString("summary")?.trim()
|
|
164
|
+
val updatedAt = System.currentTimeMillis()
|
|
165
|
+
val payload = JSONObject()
|
|
166
|
+
.put("transcript", transcript)
|
|
167
|
+
.put("summary", if (summary.isNullOrEmpty()) JSONObject.NULL else summary)
|
|
168
|
+
.put("updatedAt", updatedAt)
|
|
169
|
+
context.getSharedPreferences(transcriptPreferencesName, Context.MODE_PRIVATE)
|
|
170
|
+
.edit()
|
|
171
|
+
.putString(callId, payload.toString())
|
|
172
|
+
.apply()
|
|
173
|
+
|
|
174
|
+
val result = JSObject()
|
|
175
|
+
result.put("updatedAt", updatedAt)
|
|
176
|
+
call.resolve(result)
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
private fun readSavedTranscripts(): Map<String, JSONObject> {
|
|
180
|
+
val preferences = context.getSharedPreferences(transcriptPreferencesName, Context.MODE_PRIVATE)
|
|
181
|
+
val entries = mutableMapOf<String, JSONObject>()
|
|
182
|
+
for ((key, value) in preferences.all) {
|
|
183
|
+
val raw = value as? String ?: continue
|
|
184
|
+
val parsed = JSONObject(raw)
|
|
185
|
+
entries[key] = parsed
|
|
186
|
+
}
|
|
187
|
+
return entries
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
private fun callLogType(type: Int): String {
|
|
191
|
+
return when (type) {
|
|
192
|
+
CallLog.Calls.INCOMING_TYPE -> "incoming"
|
|
193
|
+
CallLog.Calls.OUTGOING_TYPE -> "outgoing"
|
|
194
|
+
CallLog.Calls.MISSED_TYPE -> "missed"
|
|
195
|
+
CallLog.Calls.VOICEMAIL_TYPE -> "voicemail"
|
|
196
|
+
CallLog.Calls.REJECTED_TYPE -> "rejected"
|
|
197
|
+
CallLog.Calls.BLOCKED_TYPE -> "blocked"
|
|
198
|
+
CallLog.Calls.ANSWERED_EXTERNALLY_TYPE -> "answered_externally"
|
|
199
|
+
else -> "unknown"
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
private fun JSONObject.optionalString(key: String): String? {
|
|
204
|
+
if (!has(key) || isNull(key)) return null
|
|
205
|
+
return optString(key)
|
|
206
|
+
}
|
|
207
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
export interface PlaceCallOptions {
|
|
2
|
+
number: string;
|
|
3
|
+
}
|
|
4
|
+
export interface PhoneStatus {
|
|
5
|
+
hasTelecom: boolean;
|
|
6
|
+
canPlaceCalls: boolean;
|
|
7
|
+
isDefaultDialer: boolean;
|
|
8
|
+
defaultDialerPackage: string | null;
|
|
9
|
+
}
|
|
10
|
+
export type CallLogType = "incoming" | "outgoing" | "missed" | "voicemail" | "rejected" | "blocked" | "answered_externally" | "unknown";
|
|
11
|
+
export interface CallLogEntry {
|
|
12
|
+
id: string;
|
|
13
|
+
number: string;
|
|
14
|
+
cachedName: string | null;
|
|
15
|
+
date: number;
|
|
16
|
+
durationSeconds: number;
|
|
17
|
+
type: CallLogType;
|
|
18
|
+
rawType: number;
|
|
19
|
+
isNew: boolean;
|
|
20
|
+
phoneAccountId: string | null;
|
|
21
|
+
geocodedLocation: string | null;
|
|
22
|
+
transcription: string | null;
|
|
23
|
+
voicemailUri: string | null;
|
|
24
|
+
agentTranscript: string | null;
|
|
25
|
+
agentSummary: string | null;
|
|
26
|
+
agentTranscriptUpdatedAt: number | null;
|
|
27
|
+
}
|
|
28
|
+
export interface ListRecentCallsOptions {
|
|
29
|
+
limit?: number;
|
|
30
|
+
number?: string;
|
|
31
|
+
}
|
|
32
|
+
export interface SaveCallTranscriptOptions {
|
|
33
|
+
callId: string;
|
|
34
|
+
transcript: string;
|
|
35
|
+
summary?: string;
|
|
36
|
+
}
|
|
37
|
+
export interface PhonePlugin {
|
|
38
|
+
getStatus(): Promise<PhoneStatus>;
|
|
39
|
+
placeCall(options: PlaceCallOptions): Promise<void>;
|
|
40
|
+
openDialer(options?: Partial<PlaceCallOptions>): Promise<void>;
|
|
41
|
+
listRecentCalls(options?: ListRecentCallsOptions): Promise<{
|
|
42
|
+
calls: CallLogEntry[];
|
|
43
|
+
}>;
|
|
44
|
+
saveCallTranscript(options: SaveCallTranscriptOptions): Promise<{
|
|
45
|
+
updatedAt: number;
|
|
46
|
+
}>;
|
|
47
|
+
}
|
|
48
|
+
//# sourceMappingURL=definitions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"definitions.d.ts","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,gBAAgB;IAC/B,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,WAAW;IAC1B,UAAU,EAAE,OAAO,CAAC;IACpB,aAAa,EAAE,OAAO,CAAC;IACvB,eAAe,EAAE,OAAO,CAAC;IACzB,oBAAoB,EAAE,MAAM,GAAG,IAAI,CAAC;CACrC;AAED,MAAM,MAAM,WAAW,GACnB,UAAU,GACV,UAAU,GACV,QAAQ,GACR,WAAW,GACX,UAAU,GACV,SAAS,GACT,qBAAqB,GACrB,SAAS,CAAC;AAEd,MAAM,WAAW,YAAY;IAC3B,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,eAAe,EAAE,MAAM,CAAC;IACxB,IAAI,EAAE,WAAW,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,OAAO,CAAC;IACf,cAAc,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,gBAAgB,EAAE,MAAM,GAAG,IAAI,CAAC;IAChC,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,eAAe,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,wBAAwB,EAAE,MAAM,GAAG,IAAI,CAAC;CACzC;AAED,MAAM,WAAW,sBAAsB;IACrC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,yBAAyB;IACxC,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,WAAW;IAC1B,SAAS,IAAI,OAAO,CAAC,WAAW,CAAC,CAAC;IAClC,SAAS,CAAC,OAAO,EAAE,gBAAgB,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACpD,UAAU,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC,gBAAgB,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC/D,eAAe,CAAC,OAAO,CAAC,EAAE,sBAAsB,GAAG,OAAO,CAAC;QACzD,KAAK,EAAE,YAAY,EAAE,CAAC;KACvB,CAAC,CAAC;IACH,kBAAkB,CAAC,OAAO,EAAE,yBAAyB,GAAG,OAAO,CAAC;QAC9D,SAAS,EAAE,MAAM,CAAC;KACnB,CAAC,CAAC;CACJ"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAEjD,cAAc,eAAe,CAAC;AAI9B,eAAO,MAAM,KAAK,aAEhB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAIjD,cAAc,eAAe,CAAC;AAE9B,MAAM,OAAO,GAAG,GAAG,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAC;AAEpE,MAAM,CAAC,MAAM,KAAK,GAAG,cAAc,CAAc,YAAY,EAAE;IAC7D,GAAG,EAAE,OAAO;CACb,CAAC,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { WebPlugin } from "@capacitor/core";
|
|
2
|
+
import type { CallLogEntry, ListRecentCallsOptions, PhonePlugin, PhoneStatus, PlaceCallOptions, SaveCallTranscriptOptions } from "./definitions";
|
|
3
|
+
export declare class PhoneWeb extends WebPlugin implements PhonePlugin {
|
|
4
|
+
getStatus(): Promise<PhoneStatus>;
|
|
5
|
+
placeCall(_options: PlaceCallOptions): Promise<void>;
|
|
6
|
+
openDialer(_options?: Partial<PlaceCallOptions>): Promise<void>;
|
|
7
|
+
listRecentCalls(_options?: ListRecentCallsOptions): Promise<{
|
|
8
|
+
calls: CallLogEntry[];
|
|
9
|
+
}>;
|
|
10
|
+
saveCallTranscript(_options: SaveCallTranscriptOptions): Promise<{
|
|
11
|
+
updatedAt: number;
|
|
12
|
+
}>;
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=web.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"web.d.ts","sourceRoot":"","sources":["../../src/web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE5C,OAAO,KAAK,EACV,YAAY,EACZ,sBAAsB,EACtB,WAAW,EACX,WAAW,EACX,gBAAgB,EAChB,yBAAyB,EAC1B,MAAM,eAAe,CAAC;AAEvB,qBAAa,QAAS,SAAQ,SAAU,YAAW,WAAW;IACtD,SAAS,IAAI,OAAO,CAAC,WAAW,CAAC;IASjC,SAAS,CAAC,QAAQ,EAAE,gBAAgB,GAAG,OAAO,CAAC,IAAI,CAAC;IAIpD,UAAU,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAC,gBAAgB,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;IAI/D,eAAe,CACnB,QAAQ,CAAC,EAAE,sBAAsB,GAChC,OAAO,CAAC;QAAE,KAAK,EAAE,YAAY,EAAE,CAAA;KAAE,CAAC;IAI/B,kBAAkB,CACtB,QAAQ,EAAE,yBAAyB,GAClC,OAAO,CAAC;QAAE,SAAS,EAAE,MAAM,CAAA;KAAE,CAAC;CAGlC"}
|
package/dist/esm/web.js
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { WebPlugin } from "@capacitor/core";
|
|
2
|
+
export class PhoneWeb extends WebPlugin {
|
|
3
|
+
async getStatus() {
|
|
4
|
+
return {
|
|
5
|
+
hasTelecom: false,
|
|
6
|
+
canPlaceCalls: false,
|
|
7
|
+
isDefaultDialer: false,
|
|
8
|
+
defaultDialerPackage: null,
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
async placeCall(_options) {
|
|
12
|
+
throw new Error("Phone calls are only available on Android.");
|
|
13
|
+
}
|
|
14
|
+
async openDialer(_options) {
|
|
15
|
+
throw new Error("Phone dialer is only available on Android.");
|
|
16
|
+
}
|
|
17
|
+
async listRecentCalls(_options) {
|
|
18
|
+
return { calls: [] };
|
|
19
|
+
}
|
|
20
|
+
async saveCallTranscript(_options) {
|
|
21
|
+
throw new Error("Call transcripts are only available on Android.");
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=web.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"web.js","sourceRoot":"","sources":["../../src/web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAW5C,MAAM,OAAO,QAAS,SAAQ,SAAS;IACrC,KAAK,CAAC,SAAS;QACb,OAAO;YACL,UAAU,EAAE,KAAK;YACjB,aAAa,EAAE,KAAK;YACpB,eAAe,EAAE,KAAK;YACtB,oBAAoB,EAAE,IAAI;SAC3B,CAAC;IACJ,CAAC;IAED,KAAK,CAAC,SAAS,CAAC,QAA0B;QACxC,MAAM,IAAI,KAAK,CAAC,4CAA4C,CAAC,CAAC;IAChE,CAAC;IAED,KAAK,CAAC,UAAU,CAAC,QAAoC;QACnD,MAAM,IAAI,KAAK,CAAC,4CAA4C,CAAC,CAAC;IAChE,CAAC;IAED,KAAK,CAAC,eAAe,CACnB,QAAiC;QAEjC,OAAO,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC;IACvB,CAAC;IAED,KAAK,CAAC,kBAAkB,CACtB,QAAmC;QAEnC,MAAM,IAAI,KAAK,CAAC,iDAAiD,CAAC,CAAC;IACrE,CAAC;CACF"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var core = require('@capacitor/core');
|
|
4
|
+
|
|
5
|
+
const loadWeb = () => Promise.resolve().then(function () { return web; }).then((m) => new m.PhoneWeb());
|
|
6
|
+
const Phone = core.registerPlugin("ElizaPhone", {
|
|
7
|
+
web: loadWeb,
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
class PhoneWeb extends core.WebPlugin {
|
|
11
|
+
async getStatus() {
|
|
12
|
+
return {
|
|
13
|
+
hasTelecom: false,
|
|
14
|
+
canPlaceCalls: false,
|
|
15
|
+
isDefaultDialer: false,
|
|
16
|
+
defaultDialerPackage: null,
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
async placeCall(_options) {
|
|
20
|
+
throw new Error("Phone calls are only available on Android.");
|
|
21
|
+
}
|
|
22
|
+
async openDialer(_options) {
|
|
23
|
+
throw new Error("Phone dialer is only available on Android.");
|
|
24
|
+
}
|
|
25
|
+
async listRecentCalls(_options) {
|
|
26
|
+
return { calls: [] };
|
|
27
|
+
}
|
|
28
|
+
async saveCallTranscript(_options) {
|
|
29
|
+
throw new Error("Call transcripts are only available on Android.");
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
var web = /*#__PURE__*/Object.freeze({
|
|
34
|
+
__proto__: null,
|
|
35
|
+
PhoneWeb: PhoneWeb
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
exports.Phone = Phone;
|
|
39
|
+
//# sourceMappingURL=plugin.cjs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin.cjs.js","sources":["esm/index.js","esm/web.js"],"sourcesContent":["import { registerPlugin } from \"@capacitor/core\";\nexport * from \"./definitions\";\nconst loadWeb = () => import(\"./web\").then((m) => new m.PhoneWeb());\nexport const Phone = registerPlugin(\"ElizaPhone\", {\n web: loadWeb,\n});\n//# sourceMappingURL=index.js.map","import { WebPlugin } from \"@capacitor/core\";\nexport class PhoneWeb extends WebPlugin {\n async getStatus() {\n return {\n hasTelecom: false,\n canPlaceCalls: false,\n isDefaultDialer: false,\n defaultDialerPackage: null,\n };\n }\n async placeCall(_options) {\n throw new Error(\"Phone calls are only available on Android.\");\n }\n async openDialer(_options) {\n throw new Error(\"Phone dialer is only available on Android.\");\n }\n async listRecentCalls(_options) {\n return { calls: [] };\n }\n async saveCallTranscript(_options) {\n throw new Error(\"Call transcripts are only available on Android.\");\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["registerPlugin","WebPlugin"],"mappings":";;;;AAEA,MAAM,OAAO,GAAG,MAAM,mDAAe,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,QAAQ,EAAE,CAAC;AACvD,MAAC,KAAK,GAAGA,mBAAc,CAAC,YAAY,EAAE;AAClD,IAAI,GAAG,EAAE,OAAO;AAChB,CAAC;;ACJM,MAAM,QAAQ,SAASC,cAAS,CAAC;AACxC,IAAI,MAAM,SAAS,GAAG;AACtB,QAAQ,OAAO;AACf,YAAY,UAAU,EAAE,KAAK;AAC7B,YAAY,aAAa,EAAE,KAAK;AAChC,YAAY,eAAe,EAAE,KAAK;AAClC,YAAY,oBAAoB,EAAE,IAAI;AACtC,SAAS;AACT,IAAI;AACJ,IAAI,MAAM,SAAS,CAAC,QAAQ,EAAE;AAC9B,QAAQ,MAAM,IAAI,KAAK,CAAC,4CAA4C,CAAC;AACrE,IAAI;AACJ,IAAI,MAAM,UAAU,CAAC,QAAQ,EAAE;AAC/B,QAAQ,MAAM,IAAI,KAAK,CAAC,4CAA4C,CAAC;AACrE,IAAI;AACJ,IAAI,MAAM,eAAe,CAAC,QAAQ,EAAE;AACpC,QAAQ,OAAO,EAAE,KAAK,EAAE,EAAE,EAAE;AAC5B,IAAI;AACJ,IAAI,MAAM,kBAAkB,CAAC,QAAQ,EAAE;AACvC,QAAQ,MAAM,IAAI,KAAK,CAAC,iDAAiD,CAAC;AAC1E,IAAI;AACJ;;;;;;;;;"}
|
package/dist/plugin.js
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
var capacitorPhone = (function (exports, core) {
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
const loadWeb = () => Promise.resolve().then(function () { return web; }).then((m) => new m.PhoneWeb());
|
|
5
|
+
const Phone = core.registerPlugin("ElizaPhone", {
|
|
6
|
+
web: loadWeb,
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
class PhoneWeb extends core.WebPlugin {
|
|
10
|
+
async getStatus() {
|
|
11
|
+
return {
|
|
12
|
+
hasTelecom: false,
|
|
13
|
+
canPlaceCalls: false,
|
|
14
|
+
isDefaultDialer: false,
|
|
15
|
+
defaultDialerPackage: null,
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
async placeCall(_options) {
|
|
19
|
+
throw new Error("Phone calls are only available on Android.");
|
|
20
|
+
}
|
|
21
|
+
async openDialer(_options) {
|
|
22
|
+
throw new Error("Phone dialer is only available on Android.");
|
|
23
|
+
}
|
|
24
|
+
async listRecentCalls(_options) {
|
|
25
|
+
return { calls: [] };
|
|
26
|
+
}
|
|
27
|
+
async saveCallTranscript(_options) {
|
|
28
|
+
throw new Error("Call transcripts are only available on Android.");
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
var web = /*#__PURE__*/Object.freeze({
|
|
33
|
+
__proto__: null,
|
|
34
|
+
PhoneWeb: PhoneWeb
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
exports.Phone = Phone;
|
|
38
|
+
|
|
39
|
+
return exports;
|
|
40
|
+
|
|
41
|
+
})({}, capacitorExports);
|
|
42
|
+
//# sourceMappingURL=plugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin.js","sources":["esm/index.js","esm/web.js"],"sourcesContent":["import { registerPlugin } from \"@capacitor/core\";\nexport * from \"./definitions\";\nconst loadWeb = () => import(\"./web\").then((m) => new m.PhoneWeb());\nexport const Phone = registerPlugin(\"ElizaPhone\", {\n web: loadWeb,\n});\n//# sourceMappingURL=index.js.map","import { WebPlugin } from \"@capacitor/core\";\nexport class PhoneWeb extends WebPlugin {\n async getStatus() {\n return {\n hasTelecom: false,\n canPlaceCalls: false,\n isDefaultDialer: false,\n defaultDialerPackage: null,\n };\n }\n async placeCall(_options) {\n throw new Error(\"Phone calls are only available on Android.\");\n }\n async openDialer(_options) {\n throw new Error(\"Phone dialer is only available on Android.\");\n }\n async listRecentCalls(_options) {\n return { calls: [] };\n }\n async saveCallTranscript(_options) {\n throw new Error(\"Call transcripts are only available on Android.\");\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["registerPlugin","WebPlugin"],"mappings":";;;IAEA,MAAM,OAAO,GAAG,MAAM,mDAAe,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,QAAQ,EAAE,CAAC;AACvD,UAAC,KAAK,GAAGA,mBAAc,CAAC,YAAY,EAAE;IAClD,IAAI,GAAG,EAAE,OAAO;IAChB,CAAC;;ICJM,MAAM,QAAQ,SAASC,cAAS,CAAC;IACxC,IAAI,MAAM,SAAS,GAAG;IACtB,QAAQ,OAAO;IACf,YAAY,UAAU,EAAE,KAAK;IAC7B,YAAY,aAAa,EAAE,KAAK;IAChC,YAAY,eAAe,EAAE,KAAK;IAClC,YAAY,oBAAoB,EAAE,IAAI;IACtC,SAAS;IACT,IAAI;IACJ,IAAI,MAAM,SAAS,CAAC,QAAQ,EAAE;IAC9B,QAAQ,MAAM,IAAI,KAAK,CAAC,4CAA4C,CAAC;IACrE,IAAI;IACJ,IAAI,MAAM,UAAU,CAAC,QAAQ,EAAE;IAC/B,QAAQ,MAAM,IAAI,KAAK,CAAC,4CAA4C,CAAC;IACrE,IAAI;IACJ,IAAI,MAAM,eAAe,CAAC,QAAQ,EAAE;IACpC,QAAQ,OAAO,EAAE,KAAK,EAAE,EAAE,EAAE;IAC5B,IAAI;IACJ,IAAI,MAAM,kBAAkB,CAAC,QAAQ,EAAE;IACvC,QAAQ,MAAM,IAAI,KAAK,CAAC,iDAAiD,CAAC;IAC1E,IAAI;IACJ;;;;;;;;;;;;;;;"}
|
package/package.json
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@elizaos/capacitor-phone",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Android phone and Telecom bridge for ElizaOS.",
|
|
5
|
+
"main": "./dist/plugin.cjs.js",
|
|
6
|
+
"module": "./dist/esm/index.js",
|
|
7
|
+
"types": "./dist/esm/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/esm/index.d.ts",
|
|
11
|
+
"import": "./dist/esm/index.js",
|
|
12
|
+
"require": "./dist/plugin.cjs.js"
|
|
13
|
+
},
|
|
14
|
+
"./package.json": "./package.json"
|
|
15
|
+
},
|
|
16
|
+
"files": [
|
|
17
|
+
"android/src/main/",
|
|
18
|
+
"android/build.gradle",
|
|
19
|
+
"dist/"
|
|
20
|
+
],
|
|
21
|
+
"scripts": {
|
|
22
|
+
"build": "npm run clean && tsc && rollup -c rollup.config.mjs",
|
|
23
|
+
"clean": "rimraf ./dist",
|
|
24
|
+
"prepublishOnly": "npm run build"
|
|
25
|
+
},
|
|
26
|
+
"license": "MIT",
|
|
27
|
+
"capacitor": {
|
|
28
|
+
"android": {
|
|
29
|
+
"src": "android"
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
"devDependencies": {
|
|
33
|
+
"@capacitor/cli": "^8.0.0",
|
|
34
|
+
"@capacitor/core": "^8.3.1",
|
|
35
|
+
"rimraf": "^6.0.0",
|
|
36
|
+
"rollup": "^4.60.2",
|
|
37
|
+
"typescript": "^6.0.0"
|
|
38
|
+
},
|
|
39
|
+
"peerDependencies": {
|
|
40
|
+
"@capacitor/core": "^8.3.1"
|
|
41
|
+
},
|
|
42
|
+
"elizaos": {
|
|
43
|
+
"platforms": [
|
|
44
|
+
"browser",
|
|
45
|
+
"node"
|
|
46
|
+
],
|
|
47
|
+
"runtime": "both",
|
|
48
|
+
"platformDetails": {
|
|
49
|
+
"browser": "Web fallback reports phone APIs unavailable.",
|
|
50
|
+
"android": true
|
|
51
|
+
}
|
|
52
|
+
},
|
|
53
|
+
"publishConfig": {
|
|
54
|
+
"access": "public"
|
|
55
|
+
}
|
|
56
|
+
}
|